Skip to main content

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

Hi Eugene,

Thanks for the information!

For me it seems to work, at least for some simple cases, with only using a debug info file after applying the patch from the first mail. But I have only done simple testing and cannot find any documentation saying that this should work.So I guess this is nothing we can assume works. The customer can produce non-stripped binaries and use them instead, so we can probably discard this issue.

 

You might want to check the get_pheader_file_size which will allow the exec file to be the same as the debug only file.

 

Regards,

Andreas

 

From: tcf-dev-bounces@xxxxxxxxxxx <tcf-dev-bounces@xxxxxxxxxxx> On Behalf Of Eugene Tarassov
Sent: Friday, September 27, 2019 6:08 PM
To: TCF Development <tcf-dev@xxxxxxxxxxx>
Subject: Re: [tcf-dev] Can't do address to line for ELF with debug info only

 

Hi Andreas,

 

As far as I know, it is not possible to use debug info only ELF alone, without the exe ELF.

The debug info file is incomplete, by design. It is meant to be used together with its exe file.

You should put exe ELF into memory map, and let debugger to search and load debug info ELF using either “debug link” or “build ID” from the mapped ELF.

 

Regards,

Eugene

 

From: tcf-dev-bounces@xxxxxxxxxxx <tcf-dev-bounces@xxxxxxxxxxx> On Behalf Of Ragnerstam, Andreas
Sent: Friday, September 27, 2019 3:09 AM
To: TCF Development <tcf-dev@xxxxxxxxxxx>
Subject: [tcf-dev] Can't do address to line for ELF with debug info only

 

EXTERNAL EMAIL

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.

----------------------------------------------------------------------
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