This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RFC: Fix breakpoint commands in MI
- From: Vladimir Prus <vladimir at codesourcery dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Thu, 29 Oct 2009 23:59:49 +0300
- Subject: RFC: Fix breakpoint commands in MI
I've run into a couple of embarassing issues with breakpoint commands in MI:
1. Complex commands, such as "while", are not parsed, and their content is
treated as separate top-level commands.
2. Breakpoint commands are not run at all.
The underlying issue there is that mi-break.exp actually does not verify that
breakpoints are hit as desired, and while adding tests for -break-commands,
I have blindly duplicated that issue.
This patch appears to do the right thing. Anybody has comments?
Thanks,
Volodya
Index: gdb/mi/mi-cmd-break.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmd-break.c,v
retrieving revision 1.25
diff -u -p -r1.25 mi-cmd-break.c
--- gdb/mi/mi-cmd-break.c 3 Aug 2009 12:39:00 -0000 1.25
+++ gdb/mi/mi-cmd-break.c 29 Oct 2009 20:56:44 -0000
@@ -298,7 +298,7 @@ mi_cmd_break_commands (char *command, ch
mi_command_line_array_ptr = 1;
mi_command_line_array_cnt = argc;
- break_command = read_command_lines_1 (mi_read_next_line, 0);
+ break_command = read_command_lines_1 (mi_read_next_line, 1);
breakpoint_set_commands (b, break_command);
}
Index: gdb/mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.158
diff -u -p -r1.158 mi-main.c
--- gdb/mi/mi-main.c 19 Oct 2009 09:51:42 -0000 1.158
+++ gdb/mi/mi-main.c 29 Oct 2009 20:56:44 -0000
@@ -1306,6 +1306,8 @@ mi_execute_command (char *cmd, int from_
mi_out_rewind (uiout);
}
+ bpstat_do_actions ();
+
if (/* The notifications are only output when the top-level
interpreter (specified on the command line) is MI. */
ui_out_is_mi_like_p (interp_ui_out (top_level_interpreter ()))
Index: gdb/testsuite/gdb.mi/mi-break.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-break.exp,v
retrieving revision 1.26
diff -u -p -r1.26 mi-break.exp
--- gdb/testsuite/gdb.mi/mi-break.exp 15 Sep 2009 18:51:25 -0000 1.26
+++ gdb/testsuite/gdb.mi/mi-break.exp 29 Oct 2009 20:56:44 -0000
@@ -219,6 +219,21 @@ proc test_breakpoint_commands {} {
mi_list_breakpoints [list [list 7 "keep" "callee2" "basics.c" "$line_callee2_body" $hex]] \
"breakpoint commands: check that commands are cleared"
+
+ mi_run_to_main
+
+ mi_create_breakpoint "basics.c:callee2" 9 keep callee2 ".*basics.c" $line_callee2_body $hex \
+ "breakpoint commands: insert breakpoint at basics.c:callee2, again"
+
+ mi_gdb_test "-break-commands 9 \"set \$i=0\" \"while \$i<10\" \"print \$i\" \"set \$i=\$i+1\" \"end\" \"continue\" " \
+ "\\^done" \
+ "breakpoint commands: set commands"
+
+ mi_gdb_test "-exec-continue" \
+ ".*\\\$1 = 0.*\\\$10 = 9.*\\*running.*\\*stopped,reason=\"exited-normally\".*" \
+ "test hitting breakpoint with commands"
+
+
}
test_tbreak_creation_and_listing