Re: File index given line (libdw)
On Sat, 2017-07-15 at 01:22 +, 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
Re: Dwarf_FDE (libdw)
On Sat, Jul 15, 2017 at 01:00:04AM +, Sasha Da Rocha Pinheiro wrote: > I did not understand how to get the augmentation_data of a FDE. > Could anyone explain me? Dwarf_FDE is really low level. It might be easier to use a Dwarf_CFI to get a Dwarf_Frame to extract the information. You get a Dwarf_CFI_Entry from dwarf_next_cfi. This is a union. Use dwarf_cfi_cie_p (entry) to see if it is an CIE, if so you can access the augmentation data from the Dwarf_CIE cie. If not it is an FDE and you can only access to Dwarf_FDE fde values. The Dwarf_Off CIE_pointer can be used with dwarf_next_cfi () as offset to find the corresponding > Also, is the start and end of Dwarf_FDE to be used as > [initial_location, initial_location+address_range)?? No, it is the FDE instructions (encoded). How they are encoded is given by the CIE augmentation data, so you would have to decode that first. That is why you really should use Dwarf_CFI and Dwarf_Frame functions. Those use this low level data structures to decode all the information. Cheers, Mark