This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/20663] New: build-id.c : should not do sign-extension on first byte of ID to form names like .../.build-id/ffffff88/.... from 0x88 !


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

            Bug ID: 20663
           Summary: build-id.c : should not do sign-extension on first
                    byte of ID to form names like
                    .../.build-id/ffffff88/.... from 0x88 !
           Product: gdb
           Version: 7.11.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: jason.vas.dias at gmail dot com
  Target Milestone: ---

Created attachment 9551
  --> https://sourceware.org/bugzilla/attachment.cgi?id=9551&action=edit
patch to make gdb uncompress LZMA compressed separate debuginfo files

In gdb-7.11.1/gdb/build-id.c, @ line 107, it says :
          s += sprintf (s, "%02x", (unsigned) *data++);
to form the directory name XX of ../.build-id/XX/${30 bytes of build_id}.debug.
On machines where -fsigned-char is the default, *data++ will
be sign extended and then converted to unsigned ; if its high
bit 7 is set, then you get a name like 
/usr/lib/debug/.build-id/ffffff88/${30 bytes of build_id}.debug 
(with glibc-2.24's printf & gcc-5.4.0, I do, anyway).

I suggest :

@@ -107 +110 @@
-         s += sprintf (s, "%02x", (unsigned) *data++);
+         s += sprintf (s, "%02hhx", *data++);
or 
+         s += sprintf (s, "%02x", (unsigned)(0xffU & ((unsigned
char)*data++));


I discovered this when developing a patch to make gdb uncompress such
${LIBDIR}/debug/.build-id/*/*.debug.xz 
files into ${TMPDIR} or /tmp/ prior to attempting to load them. Commplete patch
attached.

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]