From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22124 invoked by alias); 22 Dec 2009 14:12:21 -0000 Received: (qmail 22111 invoked by uid 22791); 22 Dec 2009 14:12:19 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mtagate7.de.ibm.com (HELO mtagate7.de.ibm.com) (195.212.17.167) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Dec 2009 14:12:15 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate7.de.ibm.com (8.13.1/8.13.1) with ESMTP id nBMECC0J030515 for ; Tue, 22 Dec 2009 14:12:12 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id nBMECCZE975016 for ; Tue, 22 Dec 2009 15:12:12 +0100 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id nBMECBsm005839 for ; Tue, 22 Dec 2009 15:12:12 +0100 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id nBMECAaX005799; Tue, 22 Dec 2009 15:12:10 +0100 Message-Id: <200912221412.nBMECAaX005799@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Tue, 22 Dec 2009 15:12:10 +0100 Subject: Re: [rfc] Re-parse display expressions if architecture changes To: tromey@redhat.com Date: Tue, 22 Dec 2009 14:12:00 -0000 From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org In-Reply-To: from "Tom Tromey" at Dec 21, 2009 01:32:48 PM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-12/txt/msg00339.txt.bz2 Tom Tromey wrote: > >>>>> "Ulrich" == Ulrich Weigand 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