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/15161] symfile.c:struct load_section_data::load_offset is"unsigned long" but should be wider.


http://sourceware.org/bugzilla/show_bug.cgi?id=15161

--- Comment #8 from Pedro Alves <palves at redhat dot com> 2013-02-19 21:20:08 UTC ---
Alright, I almost committed a patch for that, but I noticed that
the "final" local seen on the patch is an "int", and following that
local's usage we see lots of 32-bit assumption.  So I'll just leave
the code as is.

commit 023172580ad3b79cec08ee48fa422ba4cbbcfaa5
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Feb 19 20:59:31 2013 +0000

    Another bit of gdb/15161 - remote-mips.c

    This printf truncates vma's to 32-bit.  I don't know if this is used or
reacheable
    with MIPS64 at all, but as long as I noticed it, better make it follow
    gdb's conventions.

    Actually, the existing code looks weirdly buggy.  "0x%4x" results in
printing things like

     "filename<tab>: 0x   1 .. 0x   2  "

    It must be that "0x%04x" was meant, so we'd get instead:

     "filename<tab>: 0x0001 .. 0x0002  "

    phex does that.

    Tested by building with --enable-targets=all.

    2013-02-19  Pedro Alves  <palves@redhat.com>

        * remote-mips.c (pmon_load_fast): Use phex with target's address
        width instead of "0x%4x" format for printing addresses.

diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index e20a740..8457890 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -3373,6 +3373,7 @@ pmon_load_fast (char *file)
   int final = 0;
   int finished = 0;
   struct cleanup *cleanup;
+  int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8;

   buffer = (char *) xmalloc (MAXRECSIZE + 1);
   binbuf = (unsigned char *) xmalloc (BINCHUNK);
@@ -3413,9 +3414,10 @@ pmon_load_fast (char *file)
     bintotal += bfd_get_section_size (s);
     final = (s->vma + bfd_get_section_size (s));

-    printf_filtered ("%s\t: 0x%4x .. 0x%4x  ", s->name,
-             (unsigned int) s->vma,
-             (unsigned int) (s->vma + bfd_get_section_size (s)));
+    printf_filtered ("%s\t: 0x%s .. 0x%s  ", s->name,
+             phex (s->vma, addr_size),
+             phex (s->vma + bfd_get_section_size (s), addr_size));
+
     gdb_flush (gdb_stdout);

     /* Output the starting address.  */

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- 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]