Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@suse.de>
To: gdb-patches@sources.redhat.com
Subject: Don't error out when variable not available
Date: Sun, 02 Jan 2005 22:13:00 -0000	[thread overview]
Message-ID: <m3wtuvqyly.fsf@igel.m5r.de> (raw)

With the introduction of DWARF location lists it became impossible to get
the full list of local variables of a function when any of them is not
available.  This is especially annoying when the first local or function
parameter is missing.  Here is an attempt at correcting this.  It is
suboptimal because it still prints the error message including the newline
which badly messes up the output.  Any idea how to fix that properly?

Andreas.

2005-01-02  Andreas Schwab  <schwab@suse.de>

	* findvar.c (read_var_value_no_error, read_var_value_no_error_1)
	(struct read_var_value_args): New.
	* value.h (read_var_value_no_error): Declare it.
	* printcmd.c (print_variable_value): Use read_var_value_no_error.
	* stack.c (print_frame_args): Likewise.

--- gdb/findvar.c.~1.82.~	2004-11-17 00:55:13.000000000 +0100
+++ gdb/findvar.c	2005-01-02 22:48:01.469889953 +0100
@@ -589,6 +589,39 @@ addresses have not been bound by the dyn
   return v;
 }
 
+/* Like read_var_value, but catch errors and return NULL if any
+   occured.  */
+
+struct read_var_value_args
+{
+  struct symbol *var;
+  struct frame_info *frame;
+  struct value *val;
+};
+
+static int
+read_var_value_no_error_1 (void *data)
+{
+  struct read_var_value_args *args = data;
+  struct value *val;
+
+  val = read_var_value (args->var, args->frame);
+  args->val = val;
+  return 0;
+}
+
+struct value *
+read_var_value_no_error (struct symbol *var, struct frame_info *frame)
+{
+  struct read_var_value_args args;
+
+  args.var = var;
+  args.frame = frame;
+  args.val = NULL;
+  catch_errors (read_var_value_no_error_1, &args, NULL, RETURN_MASK_ERROR);
+  return args.val;
+}
+
 /* Return a value of type TYPE, stored in register REGNUM, in frame
    FRAME.
 
--- gdb/printcmd.c.~1.81.~	2004-11-13 01:24:52.000000000 +0100
+++ gdb/printcmd.c	2005-01-02 22:58:56.751697758 +0100
@@ -1708,9 +1708,10 @@ void
 print_variable_value (struct symbol *var, struct frame_info *frame,
 		      struct ui_file *stream)
 {
-  struct value *val = read_var_value (var, frame);
+  struct value *val = read_var_value_no_error (var, frame);
 
-  value_print (val, stream, 0, Val_pretty_default);
+  if (val != NULL)
+    value_print (val, stream, 0, Val_pretty_default);
 }
 
 static void
--- gdb/stack.c.~1.119.~	2004-11-13 01:24:52.000000000 +0100
+++ gdb/stack.c	2005-01-02 22:37:25.785526361 +0100
@@ -347,7 +347,7 @@ print_frame_args (struct symbol *func, s
 	     we do not know.  We pass 2 as "recurse" to val_print because our
 	     standard indentation here is 4 spaces, and val_print indents
 	     2 for each recurse.  */
-	  val = read_var_value (sym, fi);
+	  val = read_var_value_no_error (sym, fi);
 
 	  annotate_arg_value (val == NULL ? NULL : value_type (val));
 
--- gdb/value.h.~1.61.~	2004-11-17 00:55:14.000000000 +0100
+++ gdb/value.h	2005-01-02 22:35:28.716424395 +0100
@@ -293,6 +293,9 @@ extern int symbol_read_needs_frame (stru
 extern struct value *read_var_value (struct symbol *var,
 				     struct frame_info *frame);
 
+extern struct value *read_var_value_no_error (struct symbol *var,
+					      struct frame_info *frame);
+
 extern struct value *locate_var_value (struct symbol *var,
 				       struct frame_info *frame);
 

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


             reply	other threads:[~2005-01-02 22:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-02 22:13 Andreas Schwab [this message]
2005-01-02 22:57 ` Daniel Jacobowitz
2005-01-02 23:49   ` Andreas Schwab
2005-01-03  0:49     ` Daniel Jacobowitz
2005-01-03 13:41       ` Andreas Schwab
2005-01-04 22:20 ` Andrew Cagney
2005-01-05 19:23   ` Andreas Schwab
2005-02-28 20:53     ` 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=m3wtuvqyly.fsf@igel.m5r.de \
    --to=schwab@suse.de \
    --cc=gdb-patches@sources.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