From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: tromey@redhat.com
Cc: gdb-patches@sourceware.org
Subject: Re: [rfc] Re-parse display expressions if architecture changes
Date: Tue, 22 Dec 2009 14:12:00 -0000 [thread overview]
Message-ID: <200912221412.nBMECAaX005799@d12av02.megacenter.de.ibm.com> (raw)
In-Reply-To: <m3vdg09ifj.fsf@fleche.redhat.com> from "Tom Tromey" at Dec 21, 2009 01:32:48 PM
Tom Tromey wrote:
> >>>>> "Ulrich" == Ulrich Weigand <uweigand@de.ibm.com> writes:
>
> Ulrich> The patch below implements this by ensuring the expression is
> Ulrich> re-parsed if the currnet architecture is different from the one
> Ulrich> the expression was originally parsed in.
>
> This seems like a reasonable idea to me.
>
> Ulrich> Any comments? I'm planning to apply this next week.
>
> I think this needs to xfree the old expression to avoid a memory leak.
Oops, thanks for noticing this. Updated patch below.
Bye,
Ulrich
ChangeLog:
* printcmd.c: Include "arch-utils.h".
(do_one_display): Re-parse expression if current architecture changed.
diff -urNp gdb-orig/gdb/printcmd.c gdb-head/gdb/printcmd.c
--- gdb-orig/gdb/printcmd.c 2009-12-18 17:27:13.000000000 +0100
+++ gdb-head/gdb/printcmd.c 2009-12-22 14:23:27.000000000 +0100
@@ -49,6 +49,7 @@
#include "solib.h"
#include "parser-defs.h"
#include "charset.h"
+#include "arch-utils.h"
#ifdef TUI
#include "tui/tui.h" /* For tui_active et.al. */
@@ -1597,6 +1598,20 @@ do_one_display (struct display *d)
if (d->enabled_p == 0)
return;
+ /* The expression carries the architecture that was used at parse time.
+ This is a problem if the expression depends on architecture features
+ (e.g. register numbers), and the current architecture is now different.
+ For example, a display statement like "display/i $pc" is expected to
+ display the PC register of the current architecture, not the arch at
+ the time the display command was given. Therefore, we re-parse the
+ expression if the current architecture has changed. */
+ if (d->exp != NULL && d->exp->gdbarch != get_current_arch ())
+ {
+ xfree (d->exp);
+ d->exp = NULL;
+ d->block = NULL;
+ }
+
if (d->exp == NULL)
{
volatile struct gdb_exception ex;
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
next prev parent reply other threads:[~2009-12-22 14:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-21 15:33 Ulrich Weigand
2009-12-21 20:32 ` Tom Tromey
2009-12-22 14:12 ` Ulrich Weigand [this message]
2010-01-04 15:05 ` Ulrich Weigand
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=200912221412.nBMECAaX005799@d12av02.megacenter.de.ibm.com \
--to=uweigand@de.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.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