Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: Daniel Jacobowitz <drow@false.org>
Cc: Tom Tromey <tromey@redhat.com>, gdb-patches@sourceware.org
Subject: Re: Don't disable the current display in throw_exception
Date: Mon, 08 Aug 2011 14:28:00 -0000	[thread overview]
Message-ID: <201108081528.23694.pedro@codesourcery.com> (raw)
In-Reply-To: <CAN9gPaHTbvcY9_=TYfSKyA1XPRYPuZbwTBn=YTngJx+qfrkf9Q@mail.gmail.com>

On Friday 05 August 2011 21:22:28, Daniel Jacobowitz wrote:
> Seconded!  Does this also fix the bug where if you display a variable,
> and it is temporarily at a bad address, the display is disabled? 

Nope...

> Or is that still the case?  That always drives me nuts - yes, I know foo
> is NULL, but I want GDB to go back to displaying *foo when it comes
> back.  

That one doesn't look hard.  Below's a quick patch at it (not regtested).
Here's what I get:

(top-gdb) display 
2: *argv = 0x7fffffffe37c "/home/pedro/gdb/try_catch/build/gdb/gdb"
(top-gdb) p argv = 0
$2 = (char **) 0x0
(top-gdb) display 
2: *argv = <error: Cannot access memory at address 0x0>

Do I still get cookie? :-P :-)

> I don't know what the "infinite recursion" in question is.

Not sure either.  Maybe something with infcalls.  I guess
we'd have to go look at a gdb from when any error brought
you back to the top level.

-- 
Pedro Alves

---
 gdb/printcmd.c |   45 ++++++++++++++++++++++++++-------------------
 1 file changed, 26 insertions(+), 19 deletions(-)

Index: src/gdb/printcmd.c
===================================================================
--- src.orig/gdb/printcmd.c	2011-08-05 16:34:30.000000000 +0100
+++ src/gdb/printcmd.c	2011-08-08 15:12:23.908548270 +0100
@@ -1656,14 +1656,6 @@ undisplay_command (char *args, int from_
   dont_repeat ();
 }
 
-/* Cleanup that just disables the current display.  */
-
-static void
-disable_current_display_cleanup (void *arg)
-{
-  disable_current_display ();
-}
-
 /* Display a single auto-display.  
    Do nothing if the display cannot be printed in the current context,
    or if the display is disabled.  */
@@ -1723,8 +1715,8 @@ do_one_display (struct display *d)
   if (!within_current_scope)
     return;
 
+  old_chain = make_cleanup_restore_integer (&current_display_number);
   current_display_number = d->number;
-  old_chain = make_cleanup (disable_current_display_cleanup, NULL);
 
   annotate_display_begin ();
   printf_filtered ("%d", d->number);
@@ -1732,8 +1724,7 @@ do_one_display (struct display *d)
   printf_filtered (": ");
   if (d->format.size)
     {
-      CORE_ADDR addr;
-      struct value *val;
+      volatile struct gdb_exception ex;
 
       annotate_display_format ();
 
@@ -1755,18 +1746,26 @@ do_one_display (struct display *d)
       else
 	printf_filtered ("  ");
 
-      val = evaluate_expression (d->exp);
-      addr = value_as_address (val);
-      if (d->format.format == 'i')
-	addr = gdbarch_addr_bits_remove (d->exp->gdbarch, addr);
-
       annotate_display_value ();
 
-      do_examine (d->format, d->exp->gdbarch, addr);
+      TRY_CATCH (ex, RETURN_MASK_ERROR)
+        {
+	  struct value *val;
+	  CORE_ADDR addr;
+
+	  val = evaluate_expression (d->exp);
+	  addr = value_as_address (val);
+	  if (d->format.format == 'i')
+	    addr = gdbarch_addr_bits_remove (d->exp->gdbarch, addr);
+	  do_examine (d->format, d->exp->gdbarch, addr);
+	}
+      if (ex.reason < 0)
+	fprintf_filtered (gdb_stdout, _("<error: %s>\n"), ex.message);
     }
   else
     {
       struct value_print_options opts;
+      volatile struct gdb_exception ex;
 
       annotate_display_format ();
 
@@ -1784,8 +1783,16 @@ do_one_display (struct display *d)
 
       get_formatted_print_options (&opts, d->format.format);
       opts.raw = d->format.raw;
-      print_formatted (evaluate_expression (d->exp),
-		       d->format.size, &opts, gdb_stdout);
+
+      TRY_CATCH (ex, RETURN_MASK_ERROR)
+        {
+	  struct value *val;
+
+	  val = evaluate_expression (d->exp);
+	  print_formatted (val, d->format.size, &opts, gdb_stdout);
+	}
+      if (ex.reason < 0)
+	fprintf_filtered (gdb_stdout, _("<error: %s>"), ex.message);
       printf_filtered ("\n");
     }
 


  reply	other threads:[~2011-08-08 14:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-05 14:53 Pedro Alves
2011-08-05 15:10 ` Tom Tromey
2011-08-05 20:22   ` Daniel Jacobowitz
2011-08-08 14:28     ` Pedro Alves [this message]
2011-08-09 16:23       ` Don't disable displays on display eval error (Re: Don't disable the current display in throw_exception) Pedro Alves
2011-08-09 18:20       ` Don't disable the current display in throw_exception Daniel Jacobowitz

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=201108081528.23694.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=drow@false.org \
    --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