Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[tcf-dev] Can't do address to line for ELF with debug info only

Hi Eugene,

 

We, in the Simics team, are seeing a problem when having a debug only ELF file as the file in a MemoryRegion. Such a debug only ELF file can be created with “objcopy --only-keep-debug” for a ELF binary that contains DWARF debug information. That will strip a lot of the data except debug information. This is something that Yocto will output.

 

Seems TCF somewhat handles debug info files, the ELF_file struct has a debug_info_file member. And adding a debug info only ELF will be identified as such. The problem comes when performing address_to_line, which will not work properly for such files. The reason is that elf_find_unit, in tcf_elf.c, gets the pheader_file_size from the debug info file, where the file_size != mem_size for the loadable segment. The get_pheader_file_size function tries to solve this by getting the file_size from the executable binary, but in our case the exec binary (the file in the memory region) will be the debug info file, which is the same file as “file”. So there is no executable file pointing out a dwarf debug file in the memory map, which that function assumes. The result will be that get_pheader_file_size returns the file_size of the file that is a debug_info_file.

 

What we would like is that the mem size of the pheader is used instead of the file size. The mem size is what we put as size in the MemoryRegion struct.

 

The following patch would solve our problems, but not sure it is good for the general case:

 

--- a/agent/tcf/services/tcf_elf.c

+++ b/agent/tcf/services/tcf_elf.c

@@ -1763,3 +1763,3 @@ UnitAddressRange * elf_find_unit(Context * ctx, ContextAddress addr_min, Context

                 pheader_address = get_debug_pheader_address(file, debug, p);

-                pheader_file_size = get_pheader_file_size(file, p, r);

+                pheader_file_size = r->size > 0 ? r->size : get_pheader_file_size(file, p, r);

                 if (pheader_file_size == 0) continue;

 

It uses that region size if such is specified and otherwise falls back to getting the pheader file size.

 

Regards,

Andreas Ragnerstam

----------------------------------------------------------------------
Intel Sweden AB
Registered Office: Isafjordsgatan 30B, 164 40 Kista, Stockholm, Sweden
Registration Number: 556189-6027

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


Back to the top