lkml.org 
[lkml]   [2019]   [Mar]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v5 perf,bpf 12/15] perf, bpf: enable annotation of bpf program
Date


> On Mar 4, 2019, at 5:53 AM, Jiri Olsa <jolsa@redhat.com> wrote:
>
> On Wed, Feb 27, 2019 at 09:06:40PM -0800, Song Liu wrote:
>
> SNIP
>
>> +
>> + disassemble_init_for_target(&info);
>> +
>> +#ifdef DISASM_FOUR_ARGS_SIGNATURE
>> + disassemble = disassembler(info.arch,
>> + bfd_big_endian(bfdf),
>> + info.mach,
>> + bfdf);
>> +#else
>> + disassemble = disassembler(bfdf);
>> +#endif
>> + assert(disassemble);
>> +
>> + fflush(s);
>
> what's the reason for those fflush calls?

fflush() updates buf_size for the stream. This one before the
loop make sure we read proper buf_size (prev_buf_size = bud_size)
in the first iteration. Then, the fflush() in each iteration
makes sure the next iteration reads proper prev_buf_size.

Thanks,
Song


>
> thanks,
> jirka
>
>> + do {
>> + const struct bpf_line_info *linfo = NULL;
>> + struct disasm_line *dl;
>> + size_t prev_buf_size;
>> + const char *srcline;
>> + u64 addr;
>> +
>> + addr = pc + ((u64 *)(info_linear->info.jited_ksyms))[sub_id];
>> + count = disassemble(pc, &info);
>> +
>> + if (prog_linfo)
>> + linfo = bpf_prog_linfo__lfind_addr_func(prog_linfo,
>> + addr, sub_id,
>> + nr_skip);
>> +
>> + if (linfo && btf) {
>> + srcline = btf__name_by_offset(btf, linfo->line_off);
>> + nr_skip++;
>> + } else
>> + srcline = NULL;
>> +
>> + fprintf(s, "\n");
>> + prev_buf_size = buf_size;
>> + fflush(s);
>
> SNIP

\
 
 \ /
  Last update: 2019-03-04 21:53    [W:2.198 / U:0.296 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site