[Bug tools/31085] Provide tool to extract path to .dwo from binary

2024-02-09 Thread mark at klomp dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=31085

Mark Wielaard  changed:

   What|Removed |Added

 CC||mark at klomp dot org

--- Comment #1 from Mark Wielaard  ---
This might be a feature request for the debugedit project.

It seems what you want is some kind of move-debug command, which extracts the
debuginfo from an exe, puts it under some DESTDIR, then it might optionally
also move the sources that are referenced from the debuginfo and then also move
(and optionally rewrite?) any associated .dwo files.

Which is basically what the debugedit find-debuginfo script does, except for
the .dwo part.
https://sourceware.org/cgit/debugedit/tree/scripts/find-debuginfo.in

find-debuginfo also (optionally) does a couple more things, like adding
mini-debuginfo, dwz compression, providing source lists, etc.

It could even be extended to actually run dwp to collect all .dwos into a .dwp
file.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[Bug tools/31360] New: Add eu-dwp tool

2024-02-09 Thread mark at klomp dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=31360

Bug ID: 31360
   Summary: Add eu-dwp tool
   Product: elfutils
   Version: unspecified
Status: NEW
  Severity: normal
  Priority: P2
 Component: tools
  Assignee: unassigned at sourceware dot org
  Reporter: mark at klomp dot org
CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

Now that we have more (split-dwarf) dwo and dwp support we should add an eu-dwp
tool to extract the dwo sections and put then into a dwp file.

The DWARF4 GNU DebugFission dwp format is described at:
https://gcc.gnu.org/wiki/DebugFissionDWP

DWARF5 https://dwarfstd.org/doc/DWARF5.pdf describes they standardized DWP
format in section 7.3.5 DWARF Package Files. With an DWARF Package File Example
in Appendix F.3.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Re: [PATCH v2 1/5] strip: Adapt src/strip -o -f on mips

2024-02-09 Thread Mark Wielaard
Hi Ying,

Sorry I keep postponing this. I don't have access to a mips64le box,
the cfarm only has 64bit big endian mips machines. But the part I am
struggling with is the relocation data conversion needed in the
mips64le case.

On Fri, Nov 03, 2023 at 01:18:12PM +0100, Mark Wielaard wrote:
> On Thu, 2023-11-02 at 14:55 +0800, Ying Huang wrote:
> > In mips64 little-endian, r_info consists of four byte fields(contains
> > three reloc types) and a 32-bit symbol index. In order to adapt
> > GELF_R_SYM and GELF_R_TYPE, need convert raw data to get correct symbol
> > index and type.
> 
> This part and the new backends hooks look OK.

So to make progress could you split this part?  Just a patch that adds
the initial mips backend (and the libebl and libelfP.h parts). And
another that introduces the libelf/elf_update and elf_getdata parts?

Also could you take a look at CONTRIBUTING
https://sourceware.org/cgit/elfutils/tree/CONTRIBUTING
And provide a Signed-off-by line if you can/agree with that?

Which MIPS variant(s) have you tested this against?  Is it supposed to
only work for mips64le? Or also maps64[be] and/or mips32 bits?

Thanks,

Mark


[PATCH] Handle DW_AT_decl_file 0

2024-02-09 Thread Aaron Merey
Modify dwarf_decl_file to support DW_AT_decl_file with value 0.

Because of inconsistencies in the DWARF 5 spec, it is ambiguous whether
DW_AT_decl_file value 0 is a valid .debug_line file table index for the
main source file or if it means that there is no source file specified.

dwarf_decl_file interprets DW_AT_decl_file 0 as meaning no source file
is specified.  This works with DWARF 5 produced by gcc, which duplicates
the main source file name at index 0 and 1 of the file table and avoids
using DW_AT_decl_file 0.

However clang uses DW_AT_decl_file 0 for the main source index with no
duplication at another index.  In this case dwarf_decl_file will be
unable to find the file name of the main file.

This patch changes dwarf_decl_file to treat DW_AT_decl_file 0 as a normal
index into the file table, allowing it to work with DWARF 5 debuginfo
produced by clang.

As for earlier DWARF versions which exclusively use DW_AT_decl_file 0
to indicate that no source file is specified, dwarf_decl_file will now
return the name "???" if called on a DIE with DW_AT_decl_file 0.

https://sourceware.org/bugzilla/show_bug.cgi?id=3

Signed-off-by: Aaron Merey 
---
 libdw/dwarf_decl_file.c  |  25 ++---
 tests/Makefile.am|   3 ++-
 tests/run-allfcts.sh |  17 +
 tests/testfile-dwarf5-line-clang.bz2 | Bin 0 -> 2764 bytes
 4 files changed, 29 insertions(+), 16 deletions(-)
 create mode 100755 tests/testfile-dwarf5-line-clang.bz2

diff --git a/libdw/dwarf_decl_file.c b/libdw/dwarf_decl_file.c
index 75662a33..07b69f8d 100644
--- a/libdw/dwarf_decl_file.c
+++ b/libdw/dwarf_decl_file.c
@@ -31,7 +31,6 @@
 # include 
 #endif
 
-#include 
 #include 
 #include "libdwP.h"
 
@@ -48,13 +47,6 @@ dwarf_decl_file (Dwarf_Die *die)
   &idx) != 0)
 return NULL;
 
-  /* Zero means no source file information available.  */
-  if (idx == 0)
-{
-  __libdw_seterrno (DWARF_E_NO_ENTRY);
-  return NULL;
-}
-
   /* Get the array of source files for the CU.  */
   struct Dwarf_CU *cu = attr_mem.cu;
   if (cu->lines == NULL)
@@ -63,20 +55,23 @@ dwarf_decl_file (Dwarf_Die *die)
   size_t nlines;
 
   /* Let the more generic function do the work.  It'll create more
-data but that will be needed in an real program anyway.  */
+data but that will be needed in a real program anyway.  */
   (void) INTUSE(dwarf_getsrclines) (&CUDIE (cu), &lines, &nlines);
-  assert (cu->lines != NULL);
 }
 
-  if (cu->lines == (void *) -1l)
+  if (cu->lines == NULL || cu->lines == (void *) -1l)
 {
-  /* If the file index is not zero, there must be file information
-available.  */
-  __libdw_seterrno (DWARF_E_INVALID_DWARF);
+  /* Line table could not be found.  */
   return NULL;
 }
 
-  assert (cu->files != NULL && cu->files != (void *) -1l);
+ if (cu->files == NULL || cu->files == (void *) -1l)
+{
+  /* If the line table was found then then the file table should
+have also been found.  */
+  __libdw_seterrno (DWARF_E_UNKNOWN_ERROR);
+  return NULL;
+}
 
   if (idx >= cu->files->nfiles)
 {
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 13bd9d56..b075e3c3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -634,7 +634,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
 testfile-largealign.o.bz2 run-strip-largealign.sh \
 run-funcretval++11.sh \
 test-ar-duplicates.a.bz2 \
-run-dwfl-core-noncontig.sh testcore-noncontig.bz2
+run-dwfl-core-noncontig.sh testcore-noncontig.bz2 \
+testfile-dwarf5-line-clang.bz2
 
 
 if USE_VALGRIND
diff --git a/tests/run-allfcts.sh b/tests/run-allfcts.sh
index 9c0a55d8..1d4766fe 100755
--- a/tests/run-allfcts.sh
+++ b/tests/run-allfcts.sh
@@ -170,4 +170,21 @@ testrun_compare ${abs_builddir}/allfcts testfile-lto-gcc9 
<<\EOF
 /home/mark/src/tests/testfile-lto-main.c:6:main
 EOF
 
+# = dwarf5-line.c =
+# int
+# main (int argc, char ** argv)
+# {
+#   return 0;
+# }
+
+# Using clang version 17.0.4 (Fedora 17.0.4-1.fc39)
+# clang -gdwarf-5 -O0 -o testfile-dwarf5-line-clang dwarf5-line.c
+
+testfiles testfile-dwarf5-line-clang
+
+# Check that dwarf_decl_file can handle .debug_line file table index 0
+testrun_compare ${abs_builddir}/allfcts testfile-dwarf5-line-clang <<\EOF
+/home/amerey/test/dwarf5-line.c:2:main
+EOF
+
 exit 0
diff --git a/tests/testfile-dwarf5-line-clang.bz2 
b/tests/testfile-dwarf5-line-clang.bz2
new file mode 100755
index 
..ab62b707bd7371268d6e685a2f86a1a3a868b0a9
GIT binary patch
literal 2764
zcmV;-3N!UWT4*^jL0KkKS?3bM4FC%f|NsC0|Nrmr|NH;%|NsBz|NsC0Y46D+q(klP
z_GEV7|6kwvWB?5S00E!|h!aMdntDLhJSItiq3U^0)f#B@ntFzs
z000kAWYa*NhhJXR4jD~;!41flWFeaKAGyq761dR-6)G8o+yQEuT0j3ws|*~V~G%!nj`>pELHrd!u%YwKaMQF=^V6yoOE5?X2@
zAafd&nVd`~H9AZ>f5^t-XG&i(S&zxmz5;Sp>!ekGkT%;963hq(I|)o+t(C9