This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: File index given line (libdw)


[Resending cause it seems it didn't go]

You understood what I need when you said:
"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."

I agree with this "But currently that is an implementation detail. "
But I don't see why this would change. Deliberately sort the files names so it doesn't match with the lines? I don't think so.

What I need is direct access to the files I already have from a previous call to eliminate unnecessary search.

"Why is it important to match this particular filename to one in the vector you created from the Dwarf_Files?"
Because Dyninst needs to make its own parsing and fill its own data structures in the most efficient way.





From: Mark Wielaard <mark@klomp.org>
Sent: Saturday, July 15, 2017 8:56 AM
To: Sasha Da Rocha Pinheiro
Cc: elfutils-devel@sourceware.org
Subject: Re: File index given line (libdw)
    
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.

Cheers,

Mark
    

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]