From: Hui Zhu Date: Tue, 17 Mar 2009 05:11:40 +0000 (+0000) Subject: *stack.c: Include valprint.h. X-Git-Tag: sid-snapshot-20090401~207 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=30c33a9f4b1132803f7f30fab64ad6b9da075d39;p=platform%2Fupstream%2Fbinutils.git *stack.c: Include valprint.h. (disassemble_next_line): New enum. (show_disassemble_next_line): New function. Show the current value of disassemble-next-line. (gdb_disassembly_stub_args): New struct for argument passing between function do_gdb_disassembly and function gdb_disassembly_stub. (gdb_disassembly_stub): New function. Helper for gdb_disassembly. (do_gdb_disassembly): New function. Use TRY_CATCH to catch the exception from the gdb_disassembly because it will be broken by filter sometime. (print_frame_info): If disassemble-next-line is set to auto or on and doesn't have the line debug messages for $pc, output the next instruction. If disassemble-next-line is set to on and there is line debug messages, output assembly codes for next line. (_initialize_stack): Make the "set disassemble-next-line" command an auto-boolean command. Change its class to class_stack. Place it in the top level set list. Extend help to describe the auto mode. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e71b921..c6f18fd 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,27 @@ +2009-03-17 Hui Zhu + + *stack.c: Include valprint.h. + (disassemble_next_line): New enum. + (show_disassemble_next_line): New function. Show the current + value of disassemble-next-line. + (gdb_disassembly_stub_args): New struct for argument passing + between function do_gdb_disassembly and function + gdb_disassembly_stub. + (gdb_disassembly_stub): New function. Helper for + gdb_disassembly. + (do_gdb_disassembly): New function. Use TRY_CATCH to catch + the exception from the gdb_disassembly because it will be + broken by filter sometime. + (print_frame_info): If disassemble-next-line is set to auto + or on and doesn't have the line debug messages for $pc, + output the next instruction. + If disassemble-next-line is set to on and there is line debug + messages, output assembly codes for next line. + (_initialize_stack): Make the "set disassemble-next-line" + command an auto-boolean command. Change its class to + class_stack. Place it in the top level set list. Extend help + to describe the auto mode. + 2009-03-17 Pedro Alves * infrun.c (normal_stop): Don't overwrite old_chain. diff --git a/gdb/stack.c b/gdb/stack.c index d0ea3bf..9b7d810 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -45,6 +45,7 @@ #include "valprint.h" #include "gdbthread.h" #include "cp-support.h" +#include "disasm.h" #include "gdb_assert.h" #include @@ -456,6 +457,58 @@ set_current_sal_from_frame (struct frame_info *frame, int center) } } +/* If ON, GDB will display disassembly of the next source line when + execution of the program being debugged stops. + If AUTO (which is the default) or the next source line cannot be + ascertained, display disassembly of the next instruction + instead. */ + +static enum auto_boolean disassemble_next_line; + +static void +show_disassemble_next_line (struct ui_file *file, int from_tty, + struct cmd_list_element *c, + const char *value) +{ + fprintf_filtered (file, _("\ +Debugger's willingness to use disassemble-next-line is %s.\n"), + value); +} + +/* Show assembly codes; stub for catch_errors. */ + +struct gdb_disassembly_stub_args +{ + int how_many; + CORE_ADDR low; + CORE_ADDR high; +}; + +static void +gdb_disassembly_stub (void *args) +{ + struct gdb_disassembly_stub_args *p = args; + gdb_disassembly (uiout, 0, 0, p->how_many, p->low, p->high); +} + +/* Use TRY_CATCH to catch the exception from the gdb_disassembly + because it will be broken by filter sometime. */ + +static void +do_gdb_disassembly (int how_many, CORE_ADDR low, CORE_ADDR high) +{ + volatile struct gdb_exception exception; + struct gdb_disassembly_stub_args args; + + args.how_many = how_many; + args.low = low; + args.high = high; + TRY_CATCH (exception, RETURN_MASK_ALL) + { + gdb_disassembly_stub (&args); + } +} + /* Print information about frame FRAME. The output is format according to PRINT_LEVEL and PRINT_WHAT and PRINT ARGS. The meaning of PRINT_WHAT is: @@ -533,6 +586,13 @@ print_frame_info (struct frame_info *frame, int print_level, source_print = (print_what == SRC_LINE || print_what == SRC_AND_LOC); + /* If disassemble-next-line is set to auto or on and doesn't have + the line debug messages for $pc, output the next instruction. */ + if ((disassemble_next_line == AUTO_BOOLEAN_AUTO + || disassemble_next_line == AUTO_BOOLEAN_TRUE) + && source_print && !sal.symtab) + do_gdb_disassembly (1, get_frame_pc (frame), get_frame_pc (frame) + 1); + if (source_print && sal.symtab) { int done = 0; @@ -569,6 +629,11 @@ print_frame_info (struct frame_info *frame, int print_level, print_source_lines (sal.symtab, sal.line, sal.line + 1, 0); } } + + /* If disassemble-next-line is set to on and there is line debug + messages, output assembly codes for next line. */ + if (disassemble_next_line == AUTO_BOOLEAN_TRUE) + do_gdb_disassembly (-1, get_frame_pc (frame), sal.end); } if (print_what != LOCATION) @@ -2071,6 +2136,20 @@ Usage: func \n")); _("Show printing of non-scalar frame arguments"), NULL, NULL, NULL, &setprintlist, &showprintlist); + add_setshow_auto_boolean_cmd ("disassemble-next-line", class_stack, + &disassemble_next_line, _("\ +Set whether to disassemble next source line when execution stops."), _("\ +Show whether to disassemble next source line when execution stops."), _("\ +If ON, GDB will display disassembly of the next source line when\n\ +execution of the program being debugged stops.\n\ +If AUTO (which is the default) or the next source line cannot be\n\ +ascertained, display disassembly of the next instruction\n\ +instead."), + NULL, + show_disassemble_next_line, + &setlist, &showlist); + disassemble_next_line = AUTO_BOOLEAN_AUTO; + #if 0 add_cmd ("backtrace-limit", class_stack, set_backtrace_limit_command, _(\ "Specify maximum number of frames for \"backtrace\" to print by default."),