public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* Read .debug_line without .debug_info
@ 2018-03-26 16:41 Sasha Da Rocha Pinheiro
  2018-03-26 19:12 ` Mark Wielaard
  0 siblings, 1 reply; 4+ messages in thread
From: Sasha Da Rocha Pinheiro @ 2018-03-26 16:41 UTC (permalink / raw)
  To: elfutils-devel

Hi,

is it possible to read contents of .debug_line section without the presence of a .debug_info section?

We have CUDA binaries being generated with only .debug_line, and we wish to use that. Is it possible to do that with libdw?

If not, any ideas of how to construct a minimum .debug_info in order to read it?


Regards,
Sasha

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Read .debug_line without .debug_info
  2018-03-26 16:41 Read .debug_line without .debug_info Sasha Da Rocha Pinheiro
@ 2018-03-26 19:12 ` Mark Wielaard
  2018-03-26 19:25   ` Torsten Polle
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Wielaard @ 2018-03-26 19:12 UTC (permalink / raw)
  To: Sasha Da Rocha Pinheiro; +Cc: elfutils-devel

Hi Sasha,

On Mon, Mar 26, 2018 at 04:41:06PM +0000, Sasha Da Rocha Pinheiro wrote:
> is it possible to read contents of .debug_line section without the
> presence of a .debug_info section?

No, because .debug_line sections need some information from the CU
which comes from the .debug_info. In particular the directory table
starts with the compilation directory which can only be gotten from
the CU (DW_AT_comp_dir). The files in the file list (which don't have
an explicit dir associated) are all given relative to that comp dir.

A line table can only be gotten through a CU DIE (from the .debug_info).

But DWARF5 did make some changes that mean the .debug_line tables
can stand on their own (and have their own .debug_line_str section
for the dir and file names). I am about to post patches for that.
But I haven't thought about adding an interface to iterate through
the line tables without associated CUs. It would be nice if that
also worked for pre-DWARF5 line tables. But how to represent the
missing information?

> We have CUDA binaries being generated with only .debug_line, and we
> wish to use that. Is it possible to do that with libdw?

Not at the moment. Sorry.

> If not, any ideas of how to construct a minimum .debug_info in order
> to read it?

At the moment you need a minimal CU DIE with a DW_AT_stmt_list pointing
to the line table, a DW_AT_name for the primary source file and a
DW_AT_comp_dir for the compilation directory to resolve any relative
file.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Read .debug_line without .debug_info
  2018-03-26 19:12 ` Mark Wielaard
@ 2018-03-26 19:25   ` Torsten Polle
  2018-03-27  9:09     ` Mark Wielaard
  0 siblings, 1 reply; 4+ messages in thread
From: Torsten Polle @ 2018-03-26 19:25 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: Sasha Da Rocha Pinheiro, elfutils-devel

Hi Mark,

> Am 26.03.2018 um 21:12 schrieb Mark Wielaard <mark@klomp.org>:
> 
> Hi Sasha,
> 
> On Mon, Mar 26, 2018 at 04:41:06PM +0000, Sasha Da Rocha Pinheiro wrote:
>> is it possible to read contents of .debug_line section without the
>> presence of a .debug_info section?
> 
> No, because .debug_line sections need some information from the CU
> which comes from the .debug_info. In particular the directory table
> starts with the compilation directory which can only be gotten from
> the CU (DW_AT_comp_dir). The files in the file list (which don't have
> an explicit dir associated) are all given relative to that comp dir.

you could take this information from the include directories:

"11. include_directories (sequence of path names)

Entries in this sequence describe each path that was searched for included source files in this compilation. (The paths include those directories specified explicitly by the user for the compiler to search and those the compiler searches without explicit direction.) Each path entry is either a full path name or is relative to the current directory of the compilation.

The last entry is followed by a single null byte.

The line number program assigns numbers to each of the file entries in order, beginning with 1. The current directory of the compilation is understood to be the zeroth entry and is not explicitly represented."

Kind Regards,
Torsten

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Read .debug_line without .debug_info
  2018-03-26 19:25   ` Torsten Polle
@ 2018-03-27  9:09     ` Mark Wielaard
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Wielaard @ 2018-03-27  9:09 UTC (permalink / raw)
  To: Torsten Polle; +Cc: Sasha Da Rocha Pinheiro, elfutils-devel

On Mon, 2018-03-26 at 21:24 +0200, Torsten Polle wrote:
> > > > Am 26.03.2018 um 21:12 schrieb Mark Wielaard <mark@klomp.org>:
> > On Mon, Mar 26, 2018 at 04:41:06PM +0000, Sasha Da Rocha Pinheiro wrote:
> > > is it possible to read contents of .debug_line section without the
> > > presence of a .debug_info section?
> > 
> > No, because .debug_line sections need some information from the CU
> > which comes from the .debug_info. In particular the directory table
> > starts with the compilation directory which can only be gotten from
> > the CU (DW_AT_comp_dir). The files in the file list (which don't have
> > an explicit dir associated) are all given relative to that comp dir.
> 
> you could take this information from the include directories:
> 
> "11. include_directories (sequence of path names)
> 
> Entries in this sequence describe each path that was searched for included source files in this compilation. (The paths include those directories specified explicitly by the user for the compiler to search and those the compiler searches without explicit direction.) Each path entry is either a full path name or is relative to the current directory of the compilation.
> 
> The last entry is followed by a single null byte.
> 
> The line number program assigns numbers to each of the file entries in order, beginning with 1. The current directory of the compilation is understood to be the zeroth entry and is not explicitly represented."

Yes, you are right, if the files don't refer to the current directory
(index zero). But normally most files will be relative to the current
directory, which (at least in DWARF < 5) is not explicitly represented
in the directory table, only implicitly as the CU comp_dir attribute.

Also if you are interested in the code ranges that are covered by the
line table, you have to parse the whole table up front without an
associated debuginfo CU DIE. This might or might not be an issue, but
it is if you have multiple line tables and you quickly need to find the
one that covers a specific address.

So, yes, the line tables might be usable without the .debug_info
present, but it isn't as convenient.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-27  9:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-26 16:41 Read .debug_line without .debug_info Sasha Da Rocha Pinheiro
2018-03-26 19:12 ` Mark Wielaard
2018-03-26 19:25   ` Torsten Polle
2018-03-27  9:09     ` 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).