aboutsummaryrefslogtreecommitdiff
path: root/gdb/stack.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2012-07-16 19:15:39 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2012-07-16 19:15:39 +0000
commit8f04399994587ef7931511d18d72526de3f6f2b3 (patch)
tree919facc060422aa198d79463c40c02b44f04fdbe /gdb/stack.c
parentae5e0686eef580b284df2f764cf29b38ee41b675 (diff)
downloadgdb-8f04399994587ef7931511d18d72526de3f6f2b3.zip
gdb-8f04399994587ef7931511d18d72526de3f6f2b3.tar.gz
gdb-8f04399994587ef7931511d18d72526de3f6f2b3.tar.bz2
gdb/
PR 11914 * f-valprint.c (info_common_command): New variable frame_id. Reinitialize FI form FRAME_ID after each print_variable_and_value. * printcmd.c (print_variable_and_value): Extend function comment. Add comment for invalidated FRAME. * stack.c (backtrace_command_1): New variable frame_id. Reinitialize FI form FRAME_ID after each print_frame_local_vars. (struct print_variable_and_value_data): Change frame to frame_id. (do_print_variable_and_value): New variable frame, initialize it from p->frame_id. Add comment for invalidated FRAME. (print_frame_local_vars, print_frame_arg_vars): New function comment. Update CB_DATA.FRAME to CB_DATA.FRAME_ID initialization. Add comment for invalidated FRAME. gdb/testsuite/ PR 11914 * gdb.python/py-prettyprint.c (eval_func, eval_sub): New. (main): Call eval_sub. * gdb.python/py-prettyprint.exp: (python execfile ('py-prettyprint.py')): Move it earlier. New breakpoint for eval-break. (continue to breakpoint: eval-break, info locals): New test. (python execfile ('py-prettyprint.py')): Move it from here. * gdb.python/py-prettyprint.py (class pp_eval_type): New. (register_pretty_printers): Register pp_eval_type.
Diffstat (limited to 'gdb/stack.c')
-rw-r--r--gdb/stack.c52
1 files changed, 46 insertions, 6 deletions
diff --git a/gdb/stack.c b/gdb/stack.c
index 2520e2c..35d379d 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -1727,7 +1727,20 @@ backtrace_command_1 (char *count_exp, int show_locals, int from_tty)
the frame->prev field gets set to NULL in that case). */
print_frame_info (fi, 1, LOCATION, 1);
if (show_locals)
- print_frame_local_vars (fi, 1, gdb_stdout);
+ {
+ struct frame_id frame_id = get_frame_id (fi);
+
+ print_frame_local_vars (fi, 1, gdb_stdout);
+
+ /* print_frame_local_vars invalidates FI. */
+ fi = frame_find_by_id (frame_id);
+ if (fi == NULL)
+ {
+ trailing = NULL;
+ warning (_("Unable to restore previously selected frame."));
+ break;
+ }
+ }
/* Save the last frame to check for error conditions. */
trailing = fi;
@@ -1919,7 +1932,7 @@ iterate_over_block_local_vars (struct block *block,
struct print_variable_and_value_data
{
- struct frame_info *frame;
+ struct frame_id frame_id;
int num_tabs;
struct ui_file *stream;
int values_printed;
@@ -1933,12 +1946,28 @@ do_print_variable_and_value (const char *print_name,
void *cb_data)
{
struct print_variable_and_value_data *p = cb_data;
+ struct frame_info *frame;
+
+ frame = frame_find_by_id (p->frame_id);
+ if (frame == NULL)
+ {
+ warning (_("Unable to restore previously selected frame."));
+ return;
+ }
+
+ print_variable_and_value (print_name, sym, frame, p->stream, p->num_tabs);
+
+ /* print_variable_and_value invalidates FRAME. */
+ frame = NULL;
- print_variable_and_value (print_name, sym,
- p->frame, p->stream, p->num_tabs);
p->values_printed = 1;
}
+/* Print all variables from the innermost up to the function block of FRAME.
+ Print them with values to STREAM indented by NUM_TABS.
+
+ This function will invalidate FRAME. */
+
static void
print_frame_local_vars (struct frame_info *frame, int num_tabs,
struct ui_file *stream)
@@ -1961,7 +1990,7 @@ print_frame_local_vars (struct frame_info *frame, int num_tabs,
return;
}
- cb_data.frame = frame;
+ cb_data.frame_id = get_frame_id (frame);
cb_data.num_tabs = 4 * num_tabs;
cb_data.stream = stream;
cb_data.values_printed = 0;
@@ -1970,6 +1999,9 @@ print_frame_local_vars (struct frame_info *frame, int num_tabs,
do_print_variable_and_value,
&cb_data);
+ /* do_print_variable_and_value invalidates FRAME. */
+ frame = NULL;
+
if (!cb_data.values_printed)
fprintf_filtered (stream, _("No locals.\n"));
}
@@ -2016,6 +2048,11 @@ iterate_over_block_arg_vars (struct block *b,
}
}
+/* Print all argument variables of the function of FRAME.
+ Print them with values to STREAM.
+
+ This function will invalidate FRAME. */
+
static void
print_frame_arg_vars (struct frame_info *frame, struct ui_file *stream)
{
@@ -2036,7 +2073,7 @@ print_frame_arg_vars (struct frame_info *frame, struct ui_file *stream)
return;
}
- cb_data.frame = frame;
+ cb_data.frame_id = get_frame_id (frame);
cb_data.num_tabs = 0;
cb_data.stream = gdb_stdout;
cb_data.values_printed = 0;
@@ -2044,6 +2081,9 @@ print_frame_arg_vars (struct frame_info *frame, struct ui_file *stream)
iterate_over_block_arg_vars (SYMBOL_BLOCK_VALUE (func),
do_print_variable_and_value, &cb_data);
+ /* do_print_variable_and_value invalidates FRAME. */
+ frame = NULL;
+
if (!cb_data.values_printed)
fprintf_filtered (stream, _("No arguments.\n"));
}