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
  • From: Eugene Tarassov <eugenet@xxxxxxxxxx>
  • Date: Fri, 27 Sep 2019 16:08:18 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=xilinx.com; dmarc=pass action=none header.from=xilinx.com; dkim=pass header.d=xilinx.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AoIhrBJR/NPpiPjOdFZtLWer9ojOwW1atThpFEZIX/0=; b=evubp1XOaF/DvgU3wdgjLNX3bJe/q86ZsxA/e/ed+N2LKghr+EJVswhz4KNljCgZ89R/JJCcSOR2dPrzfcmSE7kKvsPRnz0gEpRWLeKjS6TSTOfIcats/pXuIxr78u+E81Mv1E0IbwkbyxZLs3zvmy44ATpL6u8/3SZVuPZO7LMuCrc8xOXlGmraM2xPjTOiusiJPIOFPj6WGmFMMLjAimz8VgMTpG68Tn6rbBe4oNEXMiX/Aixcs6NbPeYqjb5v0dM/1s1xAmt2KiCm/QnFkt/QSSc0Z5E6oMNqx4x9I9gfHRNYNAn77DT5s0YJR14rvAcHs1sMImciCDTaD+BPsA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W0hVLwaxBS2CFWYBg1ifAVGHlQqH1VP8qMs0Z7j92igSJa4IZryGpZ5aDipoce6TVFBgBsv6bod8EltwBsmJ3ILg8nCnlOyzLJPsT+ZKFrXBvlSk6/Vn0hZqEg4908aql7rGFUwXuDTRYjlGrPn3tJM9wvY0BI5fb9CEW4dNNXmJkvDUokqywIVVf4HvEGZIH7b0j0yp/BvybT4c1K/dMR+ObSY8J5GnxQku+Qe2MQTrZPL3W14Oh+or9iXeXILoy3N5yGBjqp7hfDO+aaPSnpFIIdn9ikJKsZ2XnfOWesGIjhtzswg87IPIDpFFMmKqjAI90mnW6xww/nvfm5iysg==
  • Delivered-to: tcf-dev@xxxxxxxxxxx
  • List-archive: <https://www.eclipse.org/mailman/private/tcf-dev>
  • List-help: <mailto:tcf-dev-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/tcf-dev>, <mailto:tcf-dev-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/tcf-dev>, <mailto:tcf-dev-request@eclipse.org?subject=unsubscribe>
  • Thread-index: AdV1G4Kvs9GMbkqKS3S3N4zznod2GgAMFDUg
  • Thread-topic: 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.


Back to the top