* line info @ 2019-09-11 21:52 Sasha Da Rocha Pinheiro 2019-09-12 9:04 ` Mark Wielaard 0 siblings, 1 reply; 4+ messages in thread From: Sasha Da Rocha Pinheiro @ 2019-09-11 21:52 UTC (permalink / raw) To: Mark Wielaard, elfutils-devel Hi all, how do we get the line info range end address for a given line and file? For instance, gdb adds 2 breapoint to: (gdb) b /g/g90/devkota1/LULESH/lulesh.cc:233 Breakpoint 1 at 0x4060a0: /g/g90/devkota1/LULESH/lulesh.cc:233. (2 locations) (gdb) i b Num Type Disp Enb Address What 1 breakpoint keep y <MULTIPLE> 1.1 y 0x00000000004060a0 in CollectDomainNodesToElemNodes(Domain&, Index_t const*, Real_t*, Real_t*, Real_t*) at lulesh.cc:233 1.2 y 0x0000000000409c0c in CalcKinematicsForElems(Domain&, double, int) at lulesh.cc:233 And we find all these locations: Compilation Unit name: lulesh.cc [403eb0, ffffffffffffffff) /g/g90/devkota1/LULESH/lulesh.cc:233 [405477, ffffffffffffffff) /g/g90/devkota1/LULESH/lulesh.h:233 [4060a0, ffffffffffffffff) /g/g90/devkota1/LULESH/lulesh.cc:233 [409c0c, ffffffffffffffff) /g/g90/devkota1/LULESH/lulesh.cc:233 But we need to get the whole range, lower and upper addresses. Regars, Sasha ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: line info 2019-09-11 21:52 line info Sasha Da Rocha Pinheiro @ 2019-09-12 9:04 ` Mark Wielaard 2019-09-12 15:22 ` Sasha Da Rocha Pinheiro 0 siblings, 1 reply; 4+ messages in thread From: Mark Wielaard @ 2019-09-12 9:04 UTC (permalink / raw) To: Sasha Da Rocha Pinheiro; +Cc: elfutils-devel Hi Sasha, On Wed, Sep 11, 2019 at 09:52:23PM +0000, Sasha Da Rocha Pinheiro wrote: > how do we get the line info range end address for a given line and file? I am not sure I understand your question competely. What are you using to get at the line and file? In theory there is no "range end address" for a given source file line. The instructions associated with a particular source code line can be scattered around by various compiler optimisations. > For instance, gdb adds 2 breapoint to: > (gdb) b /g/g90/devkota1/LULESH/lulesh.cc:233 > Breakpoint 1 at 0x4060a0: /g/g90/devkota1/LULESH/lulesh.cc:233. (2 locations) > (gdb) i b > Num   Type      Disp Enb Address       What > 1    breakpoint   keep y  <MULTIPLE>     > 1.1             y   0x00000000004060a0 in CollectDomainNodesToElemNodes(Domain&, Index_t const*, Real_t*, Real_t*, Real_t*) at lulesh.cc:233 > 1.2             y   0x0000000000409c0c in CalcKinematicsForElems(Domain&, double, int) >                           at lulesh.cc:233 > > And we find all these locations: > Compilation Unit name: lulesh.cc > [403eb0, ffffffffffffffff) /g/g90/devkota1/LULESH/lulesh.cc:233 > [405477, ffffffffffffffff) /g/g90/devkota1/LULESH/lulesh.h:233 > [4060a0, ffffffffffffffff) /g/g90/devkota1/LULESH/lulesh.cc:233 > [409c0c, ffffffffffffffff) /g/g90/devkota1/LULESH/lulesh.cc:233 > > But we need to get the whole range, lower and upper addresses. Is this in gdb? Or do you mean using one of the elfutils tools or libraries? To see how addresses map to source code lines using eu-readelf, try eu-readelf --debug-dump=line and --debug-dump=decodedline When using the libdw interface you are probably looking for dwarf_next_lines () and dwarf_linesrc (), you can then use the different dwarf_line* () functions to get at the attributes. Cheers, Mark ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: line info 2019-09-12 9:04 ` Mark Wielaard @ 2019-09-12 15:22 ` Sasha Da Rocha Pinheiro 2019-10-02 16:14 ` Mark Wielaard 0 siblings, 1 reply; 4+ messages in thread From: Sasha Da Rocha Pinheiro @ 2019-09-12 15:22 UTC (permalink / raw) To: Mark Wielaard; +Cc: elfutils-devel I'm using libdw to: dwarf_getsrclines(&cuDIE, &lineBuffer, &lineCount); for (size_t i = 0; i < lineCount; i++) { auto line = dwarf_onesrcline(lineBuffer, i); dwarf_lineno(line, ¤t_statement.line_number); const char *file_name = dwarf_linesrc(line, NULL, NULL); status = dwarf_lineaddr(line, ¤t_statement.start_addr); // here add line info to our own structure } In the previous email I gave you an example for the line 233, which gdb adds two breakpoints in two different functions. I understand that, because optimizations, lines can generate scattered instructions. The following is the start address and corresponding file name for the line 233 that libdw gives me: > And we find all these locations: > Compilation Unit name: lulesh.cc > [403eb0, ffffffffffffffff) /g/g90/devkota1/LULESH/lulesh.cc:233 > [4060a0, ffffffffffffffff) /g/g90/devkota1/LULESH/lulesh.cc:233 > [409c0c, ffffffffffffffff) /g/g90/devkota1/LULESH/lulesh.cc:233 That means the line 233 for that file generated three scattered instruction blocks. At 403eb0, 4060a0, and 409c0c. But that doesn't mean it's only one machine instruction. It could be a whole block of instructions. And now I'm trying to find how to determine the end address for each of them. (the ffffffffffffffff address is the address I'm trying to find). Suppose these addresses: .... 403eb0: 48 63 5a 0c movslq 0xc(%rdx),%rbx 403eb4: 4c 63 5a 14 movslq 0x14(%rdx),%r11 403eb8: 4c 63 72 04 movslq 0x4(%rdx),%r14 403ebc: 4c 63 3a movslq (%rdx),%r15 .... 4060a0: 41 56 push %r14 4060a2: 48 8b 07 mov (%rdi),%rax 4060a5: 41 55 push %r13 4060a7: 41 54 push %r12 .... 409c0c: 49 8b 04 24 mov (%r12),%rax 409c10: 4c 63 3b movslq (%rbx),%r15 409c13: 4c 63 73 04 movslq 0x4(%rbx),%r14 409c17: 4c 63 6b 08 movslq 0x8(%rbx),%r13 Libdw says the line 233 are associated with those three address after the dots (....): 403eb0, 4060a0, and 409c0c. But we need to know how far down this association goes. That's what I call range end. For my knowledge about it, this information is not encoded in the dwarf_line state machine instructions. Right? Would you know how to get it? I know that the state machine will shift line number and address number to encode instructions such as: DW_LNS_fixed_advance_pc SPECIAL(2, 0) DW_LNS_fixed_advance_pc SPECIAL(2, 0) DW_LNS_fixed_advance_pc SPECIAL(1, 0) DW_LNS_fixed_advance_pc SPECIAL(1, 0) DW_LNS_fixed_advance_pc DW_LNE_end_sequence And that does not give us range end. Am I correct? Can we make any assumptions for it? Regards, Sasha From: Mark Wielaard <mark@klomp.org> Sent: Thursday, September 12, 2019 4:00 AM To: Sasha Da Rocha Pinheiro <darochapinhe@wisc.edu> Cc: elfutils-devel@sourceware.org <elfutils-devel@sourceware.org> Subject: Re: line info Hi Sasha, On Wed, Sep 11, 2019 at 09:52:23PM +0000, Sasha Da Rocha Pinheiro wrote: > how do we get the line info range end address for a given line and file? I am not sure I understand your question competely. What are you using to get at the line and file? In theory there is no "range end address" for a given source file line. The instructions associated with a particular source code line can be scattered around by various compiler optimisations. > For instance, gdb adds 2 breapoint to: > (gdb) b /g/g90/devkota1/LULESH/lulesh.cc:233 > Breakpoint 1 at 0x4060a0: /g/g90/devkota1/LULESH/lulesh.cc:233. (2 locations) > (gdb) i b > Num Type Disp Enb Address What > 1 breakpoint keep y <MULTIPLE> > 1.1 y 0x00000000004060a0 in CollectDomainNodesToElemNodes(Domain&, Index_t const*, Real_t*, Real_t*, Real_t*) at lulesh.cc:233 > 1.2 y 0x0000000000409c0c in CalcKinematicsForElems(Domain&, double, int) > at lulesh.cc:233 > > And we find all these locations: > Compilation Unit name: lulesh.cc > [403eb0, ffffffffffffffff) /g/g90/devkota1/LULESH/lulesh.cc:233 > [405477, ffffffffffffffff) /g/g90/devkota1/LULESH/lulesh.h:233 > [4060a0, ffffffffffffffff) /g/g90/devkota1/LULESH/lulesh.cc:233 > [409c0c, ffffffffffffffff) /g/g90/devkota1/LULESH/lulesh.cc:233 > > But we need to get the whole range, lower and upper addresses. Is this in gdb? Or do you mean using one of the elfutils tools or libraries? To see how addresses map to source code lines using eu-readelf, try eu-readelf --debug-dump=line and --debug-dump=decodedline When using the libdw interface you are probably looking for dwarf_next_lines () and dwarf_linesrc (), you can then use the different dwarf_line* () functions to get at the attributes. Cheers, Mark ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: line info 2019-09-12 15:22 ` Sasha Da Rocha Pinheiro @ 2019-10-02 16:14 ` Mark Wielaard 0 siblings, 0 replies; 4+ messages in thread From: Mark Wielaard @ 2019-10-02 16:14 UTC (permalink / raw) To: Sasha Da Rocha Pinheiro; +Cc: elfutils-devel Hi Sasha, Sorry for the late reply. On Thu, 2019-09-12 at 15:22 +0000, Sasha Da Rocha Pinheiro wrote: > For my knowledge about it, this information is not encoded in the > dwarf_line state machine instructions. Right? Would you know how to > get it? > > I know that the state machine will shift line number and address > number to encode instructions such as: > DW_LNS_fixed_advance_pc > SPECIAL(2, 0) > DW_LNS_fixed_advance_pc > SPECIAL(2, 0) > DW_LNS_fixed_advance_pc > SPECIAL(1, 0) > DW_LNS_fixed_advance_pc > SPECIAL(1, 0) > DW_LNS_fixed_advance_pc > DW_LNE_end_sequence > > And that does not give us range end. Am I correct? Can we make any > assumptions for it? The line number table gives a mapping from addresses to source line. You could get the reverse information out of it, but since the table is ordered by addresses it isn't very convenient to construct a source line to addresses mapping. Also there is no guarantee that any source line will map to a continuous range of addresses, so there might not be one starting address and one ending address. I don't know what you really need this for, but you could get some information about function or some syntactical scopes from the DIE tree. Which you can get with dwarf_ranges (). Which might or might not be what you are looking for? Cheers, Mark ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-10-02 16:14 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-09-11 21:52 line info Sasha Da Rocha Pinheiro 2019-09-12 9:04 ` Mark Wielaard 2019-09-12 15:22 ` Sasha Da Rocha Pinheiro 2019-10-02 16:14 ` Mark Wielaard
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).