Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Peter Schauer <peterschauer@gmx.net>
To: ppluzhnikov@google.com (Paul Pluzhnikov)
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] Fix a glitch in debugging 32-bit process with 64-bit GDB.
Date: Tue, 09 Dec 2008 11:30:00 -0000	[thread overview]
Message-ID: <200812091129.mB9BTqPU010137@licht.localdomain> (raw)
In-Reply-To: <8ac60eac0812081842l6ac5344fw2fd57011d3dfef42@mail.gmail.com> from "Paul Pluzhnikov" at Dec 08, 2008 06:42:52 PM

I had the same problem a very long time ago when trying to debug
32 bit stabs executables with a sparc Solaris 64 bit GDB.

I came up with the following local hack, but didn't dare to RFA it
back then, as it didn't look clean enough.
We abandoned sparc Solaris development later on and were no longer
interested in a proper fix.

*** ./stabsread.c.orig  Sat Jul 20 11:51:50 2002
--- ./stabsread.c       Sun Jul 28 10:43:45 2002
***************
*** 927,932 ****
--- 927,935 ----
      case 'l':
        SYMBOL_TYPE (sym) = read_type (&p, objfile);
        SYMBOL_CLASS (sym) = LOC_LOCAL;
+       /* Sign extend value for 64x32 GDB.  */
+       if ((sizeof (CORE_ADDR) > 4) && ((valu & ~0x7fffffff) == 0x80000000))
+ 	valu = (valu ^ 0x80000000) - 0x80000000;
        SYMBOL_VALUE (sym) = valu;
        SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
        add_symbol_to_list (sym, &local_symbols);
***************
*** 947,952 ****
--- 950,958 ----
  	SYMBOL_TYPE (sym) = read_type (&p, objfile);
  
        SYMBOL_CLASS (sym) = LOC_ARG;
+       /* Sign extend value for 64x32 GDB.  */
+       if ((sizeof (CORE_ADDR) > 4) && ((valu & ~0x7fffffff) == 0x80000000))
+ 	valu = (valu ^ 0x80000000) - 0x80000000;
        SYMBOL_VALUE (sym) = valu;
        SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
        add_symbol_to_list (sym, &local_symbols);

> On Mon, Dec 8, 2008 at 6:07 PM, Daniel Jacobowitz <drow@false.org> wrote:
> 
> >> We end up with an impossible target address of 0x1ffffbf88.
> >
> > Conclusion doesn't follow from example
> 
> Well, that's the value I observed in the debugger...
> 
> > Do you mean that SYMBOL_VALUE is -16U or -16UL, and
> > that's where the wrapping comes from?  But SYMBOL_VALUE is a long,
> > signed.  Is SYMBOL_VALUE (long) 0xfffffff0?
> 
> Yes:
> 
> (top) p *var
> $1 = {ginfo = {name = 0x16feaa0 "ar_ptr", value = {ivalue =
> 4294967280, block = 0xfffffff0,
>       bytes = 0xfffffff0 <Address 0xfffffff0 out of bounds>, address =
> 4294967280, chain = 0xfffffff0}, language_specific = {cplus_specific =
> {
>         demangled_name = 0x0}}, language = language_c, section = 0,
> obj_section = 0x0}, type = 0x16fe418, symtab = 0x1702900,
>   domain = VAR_DOMAIN, aclass = LOC_ARG, is_argument = 1, line = 2742,
> ops = 0x0, aux_value = 0x0, hash_next = 0x0}
> 
> That value was set here:
> 
> #0  define_symbol (valu=4294967280, string=0x2aaaabd3285c
> "ar_ptr:p(0,32)", desc=2742, type=160, objfile=0xed4070)
>     at ../../src/gdb/stabsread.c:936
> #1  0x0000000000545f98 in process_one_symbol (type=160, desc=2742,
> valu=4294967280, name=0x2aaaabd3285c "ar_ptr:p(0,32)",
>     section_offsets=0xe9bcf0, objfile=0xed4070) at ../../src/gdb/dbxread.c:3178
> #2  0x0000000000545001 in read_ofile_symtab (pst=0xf9cde8) at
> ../../src/gdb/dbxread.c:2600
> ...
> 
> And that (AFAICT) is coming from BFD.
> 
> So it appears that BFD gives us 0x00000000fffffff0, but GDB expects
> 0xfffffffffffffff0
> 
> > If that's the case then the debug reader might be to blame.
> 
> This is coming from a rather old glibc-2.2.2, compiled with
> non-exstent :) old compiler:
> 
>   GNU CC version 2.96 20000731 (Red Hat Linux 7.1 2.96-79).
> 
> Here is what 'objdump -g /lib/i686/libc.so.6' has to say:
> 
> static mchunkptr chunk_alloc (arena *ar_ptr /* 0x00000000fffffff0 */,
> size_t nb /* 0x00000000ffffffec */)
> { /* 0x000000000007f2f0 */
>   { /* 0x000000000007f2f0 */
>     register mbinptr q /* 0x0000000000000002 */;
>     register mchunkptr bck /* 0x0000000000000007 */;
> ...
> 
> And here is 'objdump --stabs':
> 
> 105431 FUN    0      2746   0007f2f0 317480 chunk_alloc:f(0,25)
> 105432 PSYM   0      2742   fffffff0 317500 ar_ptr:p(0,32)
> 105433 PSYM   0      2742   ffffffec 317515 nb:p(3,2)
> 
> 
> -- 
> Paul Pluzhnikov
> 


-- 
Peter Schauer			Peter.Schauer@mytum.de


  reply	other threads:[~2008-12-09 11:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-09  1:33 Paul Pluzhnikov
2008-12-09  2:08 ` Daniel Jacobowitz
2008-12-09  2:43   ` Paul Pluzhnikov
2008-12-09 11:30     ` Peter Schauer [this message]
2008-12-09 13:34     ` Daniel Jacobowitz
2008-12-10 11:14       ` Joel Brobecker
2008-12-10 15:59         ` Paul Pluzhnikov
2008-12-10 23:21           ` Paul Pluzhnikov
2008-12-11  8:57             ` Andreas Schwab
     [not found]               ` <8ac60eac0812111601v20566268h6f7977c71e5b8a8f@mail.gmail.com>
2008-12-12  0:11                 ` Paul Pluzhnikov
2008-12-13 16:02                   ` Joel Brobecker
2008-12-13 18:18                     ` Paul Pluzhnikov
2008-12-15  8:59                       ` Joel Brobecker
2008-12-15 21:47                         ` Paul Pluzhnikov
2008-12-16  4:48                           ` Joel Brobecker
2008-12-11  9:21             ` Mark Kettenis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200812091129.mB9BTqPU010137@licht.localdomain \
    --to=peterschauer@gmx.net \
    --cc=gdb-patches@sourceware.org \
    --cc=ppluzhnikov@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox