From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: Andreas Schwab <schwab@suse.de>, gdb-patches@sourceware.org
Subject: Re: [patch] Fix a glitch in debugging 32-bit process with 64-bit GDB.
Date: Mon, 15 Dec 2008 21:47:00 -0000 [thread overview]
Message-ID: <8ac60eac0812151347n98f0249mf5ac2ab6ef7543cc@mail.gmail.com> (raw)
In-Reply-To: <20081215085833.GL6866@adacore.com>
[-- Attachment #1: Type: text/plain, Size: 1174 bytes --]
On Mon, Dec 15, 2008 at 12:58 AM, Joel Brobecker <brobecker@adacore.com> wrote:
> I'd like to see the comment detail a little the situation that we are
> trying to solve (64bit gdb debugging a 32bit app). Just as a starting
> point, I suggest for instance:
>
> if (sizeof (nlist.n_value) > 4)
> /* We are a 64bit debugger debugging a 32bit program.
> We have to be a little careful with the n_value in the case
> of N_LSYM and N_PSYM entries, because they are signed offsets
> that we actually read as an unsigned 32bit value. This is
> not a problem with 32bit debuggers where negative values end
> up being interpreted correctly. But we need to sign-extend
> the sign bit on 64bit debuggers. Otherwise, we'll end up
> interpreting negative values as very large positive values... */
> if (type == N_LSYM || type == N_PSYM)
> nlist.n_value = (nlist.n_value ^ 0x80000000) - 0x80000000;
Thanks, I slightly re-worded this.
OK to commit?
--
Paul Pluzhnikov
2008-12-15 Paul Pluzhnikov <ppluzhnikov@google.com>
* dbxread.c (read_ofile_symtab): Sign-extend 32-bit N_LSYM and
N_PSYM STABS values for 64-bit GDB.
[-- Attachment #2: gdb-1526195-20081215.txt --]
[-- Type: text/plain, Size: 1163 bytes --]
Index: dbxread.c
===================================================================
RCS file: /cvs/src/src/gdb/dbxread.c,v
retrieving revision 1.98
diff -u -r1.98 dbxread.c
--- dbxread.c 1 Oct 2008 16:41:27 -0000 1.98
+++ dbxread.c 15 Dec 2008 21:42:41 -0000
@@ -2597,6 +2597,19 @@
if (type & N_STAB)
{
+ if (sizeof (nlist.n_value) > 4
+ /* We are a 64-bit debugger debugging a 32-bit program. */
+ && (type == N_LSYM || type == N_PSYM))
+ /* We have to be careful with the n_value in the case of N_LSYM
+ and N_PSYM entries, because they are signed offsets from frame
+ pointer, but we actually read them as unsigned 32-bit values.
+ This is not a problem for 32-bit debuggers, for which negative
+ values end up being interpreted correctly (as negative
+ offsets) due to integer overflow.
+ But we need to sign-extend the value for 64-bit debuggers,
+ or we'll end up interpreting negative values as very large
+ positive offsets. */
+ nlist.n_value = (nlist.n_value ^ 0x80000000) - 0x80000000;
process_one_symbol (type, nlist.n_desc, nlist.n_value,
namestring, section_offsets, objfile);
}
next prev parent reply other threads:[~2008-12-15 21:47 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
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 [this message]
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=8ac60eac0812151347n98f0249mf5ac2ab6ef7543cc@mail.gmail.com \
--to=ppluzhnikov@google.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=schwab@suse.de \
/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