File index given line (libdw)

Mark Wielaard
Sat Jul 15 13:56:00 GMT 2017

On Sat, 2017-07-15 at 01:22 +0000, Sasha Da Rocha Pinheiro wrote:
> >But why do you want to do that?
> Performance and save memory space.
> >If we would add int dwarf_line_index (Dwarf_Line *line, size_t *idx) how
> >exactly would you use it?
> I would get idx and save it in my data structure so I don't have to save the file name repeatedly for each line.

size_t and char * are the same size. Whether you use an index or a
string pointer doesn't mean the underlying strings are identical or not.
If you really need to know if they are equal you still need to compare
the actual strings.

> >A small example program would help to see what the exact semantics
> >should be.
> How it's currently being done :
> 1. Dwarf_Files dfs <- dwarf_getsrcfiles
> 2. for each file in dfs get name (with dwarf_filesrc) -> save in vector filenames
> 3. Dwarf_Lines dls <- dwarf_getsrclines
> 4. for each line in dls get file name and "search this name in vector filenames"
> We want to eliminate the "search this name in vector filenames", to
> make it from L F log(F) to L, by getting the index and consulting the
> file name of a line in the vector filenames directly.

So you want to keep a vector with filenames for a particular CU. And
then given Dwarf_Lines you want to associate each Dwarf_Line with a
particular filename from that vector.

Do you get the Dwarf_Line from dwarf_onesrcline() or dwarf_getsrc_die()?

I assume you then use dwarf_linesrc() to get the filename associated
with the Dwarf_Line.

Why is it important to match this particular filename to one in the
vector you created from the Dwarf_Files?

There is indeed an association between the DwarfLines and the
Dwarf_Files. But currently that is an implementation detail. If we
expose the Dwarf_Line filename index associated with the Dwarf_Files
then it becomes a public interface.

I am not really that opposed to exposing this information. It might be
fine. But I would like to understand why you need/want this information.



More information about the Elfutils-devel mailing list