From: Nick Roberts <nickrob@snap.net.nz>
To: gdb-patches@sourceware.org
Subject: [PATCH] Catch errors in value_get_print_value
Date: Thu, 01 Feb 2007 20:51:00 -0000 [thread overview]
Message-ID: <17858.21211.33629.685339@kahikatea.snap.net.nz> (raw)
Currently when common_val_print throws an error from install_new_value it gets
caught in mi_execute_command and prints an MI error (^error,...) without
cleaning up. This patch catches the error in value_get_print_value so that GDB
can proceed normally. It could be adapted to output something like
"<error_reading_variable>" but I think the empty string works better.
To see what currently happens, compile:
#include <stdlib.h>
typedef struct {
float a;
float b;
} substruct;
struct substruct1 {
float a1;
substruct b1;
};
main () {
struct substruct1 *abc4 = NULL;
int i = 1;
}
-------------------
and run under GDB as follows:
~"Using host libthread_db library \"/lib/libthread_db.so.1\".\n"
(gdb)
start
&"start\n"
Breakpoint 1 at 0x8048365: file temp4.c, line 15.
Starting program: /home/nickrob/temp4
main () at temp4.c:15
15 struct substruct1 *abc4 = NULL;
^done
(gdb)
n
&"n\n"
16 int i = 1;
^done
(gdb)
-var-create - * abc4
^done,name="var1",numchild="2",type="struct substruct1 *"
(gdb)
-var-list-children --all-values var1
&"Cannot access memory at address 0x4\n"
^error,msg="Cannot access memory at address 0x4"
(gdb)
-var-list-children --all-values var1
&&"Duplicate variable object name\n"
^error,msg="Duplicate variable object name"
(gdb)
--
Nick http://www.inet.net.nz/~nickrob
2007-02-02 Nick Roberts <nickrob@snap.net.nz>
* varobj.c (value_get_print_value): Catch errors from
common_val_print.
*** varobj.c 02 Feb 2007 09:32:33 +1300 1.82
--- varobj.c 02 Feb 2007 09:48:59 +1300
*************** value_get_print_value (struct value *val
*** 1702,1707 ****
--- 1702,1708 ----
struct ui_file *stb;
struct cleanup *old_chain;
char *thevalue;
+ struct gdb_exception except;
if (value == NULL)
return NULL;
*************** value_get_print_value (struct value *val
*** 1709,1715 ****
stb = mem_fileopen ();
old_chain = make_cleanup_ui_file_delete (stb);
! common_val_print (value, stb, format_code[(int) format], 1, 0, 0);
thevalue = ui_file_xstrdup (stb, &dummy);
do_cleanups (old_chain);
--- 1710,1720 ----
stb = mem_fileopen ();
old_chain = make_cleanup_ui_file_delete (stb);
! TRY_CATCH (except, RETURN_MASK_ERROR)
! {
! common_val_print (value, stb, format_code[(int) format], 1, 0, 0);
! }
!
thevalue = ui_file_xstrdup (stb, &dummy);
do_cleanups (old_chain);
next reply other threads:[~2007-02-01 20:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-01 20:51 Nick Roberts [this message]
2007-02-08 17:41 ` Daniel Jacobowitz
2007-02-08 22:19 ` Nick Roberts
2007-02-08 22:25 ` Daniel Jacobowitz
2007-02-09 2:21 ` Nick Roberts
2007-02-09 2:26 ` 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=17858.21211.33629.685339@kahikatea.snap.net.nz \
--to=nickrob@snap.net.nz \
--cc=gdb-patches@sourceware.org \
/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