This is the mail archive of the
mailing list for the elfutils project.
Re: File index given line (libdw)
>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.
>What would be a good testcase for this new functionality?
This new function would behave similar to:
int dwarf_lineno (Dwarf_Line *line, int *linep)
if (line == NULL)
*linep = line->line;
But would get line->file instead of line->line;
This way, since I already got the files previously, I now can refer to some line file source by its id.
>A small example program would help to see what the exact semantics
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.