2012-01-04 08:17:56 +00:00
|
|
|
# Copyright 1999-2002, 2004-2005, 2007-2012 Free Software Foundation,
|
|
|
|
# Inc.
|
2000-02-23 00:25:43 +00:00
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-08-23 18:14:19 +00:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2000-02-23 00:25:43 +00:00
|
|
|
# (at your option) any later version.
|
2007-08-23 18:14:19 +00:00
|
|
|
#
|
2000-02-23 00:25:43 +00:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2007-08-23 18:14:19 +00:00
|
|
|
#
|
2000-02-23 00:25:43 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-08-23 18:14:19 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2000-02-23 00:25:43 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Test essential Machine interface (MI) operations
|
|
|
|
#
|
|
|
|
# Verify that, using the MI, we can run a simple program and perform basic
|
|
|
|
# debugging activities like: insert breakpoints, run the program,
|
|
|
|
# step, next, continue until it ends and, last but not least, quit.
|
|
|
|
#
|
|
|
|
# The goal is not to test gdb functionality, which is done by other tests,
|
|
|
|
# but to verify the correct output response to MI operations.
|
|
|
|
#
|
|
|
|
|
|
|
|
load_lib mi-support.exp
|
2001-06-18 17:57:43 +00:00
|
|
|
set MIFLAGS "-i=mi"
|
2000-02-23 00:25:43 +00:00
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
if [mi_gdb_start] {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
set testfile "basics"
|
|
|
|
set srcfile ${testfile}.c
|
* gdb.mi/mi-async.exp, gdb.mi/mi-basics.exp,
gdb.mi/mi-break.exp, gdb.mi/mi-cli.exp,
gdb.mi/mi-disassemble.exp, gdb.mi/mi-eval.exp,
gdb.mi/mi-file-transfer.exp, gdb.mi/mi-file.exp,
gdb.mi/mi-regs.exp, gdb.mi/mi-return.exp,
gdb.mi/mi-simplerun.exp, gdb.mi/mi-stepi.exp,
gdb.mi/mi-var-block.exp, gdb.mi/mi-var-cmd.exp,
gdb.mi/mi-var-display.exp, gdb.mi/mi-var-invalidate.exp,
gdb.mi/mi-watch.exp, gdb.mi/mi2-basics.exp,
gdb.mi/mi2-break.exp, gdb.mi/mi2-cli.exp,
gdb.mi/mi2-disassemble.exp, gdb.mi/mi2-eval.exp,
gdb.mi/mi2-file.exp, gdb.mi/mi2-regs.exp,
gdb.mi/mi2-return.exp, gdb.mi/mi2-simplerun.exp,
gdb.mi/mi2-stepi.exp, gdb.mi/mi2-var-block.exp,
gdb.mi/mi2-var-child.exp, gdb.mi/mi2-var-cmd.exp,
gdb.mi/mi2-var-display.exp, gdb.mi/mi2-watch.exp,
gdb.server/ext-run.exp, gdb.server/file-transfer.exp,
gdb.server/server-mon.exp, gdb.server/server-run.exp,
gdb.trace/actions.exp, gdb.trace/backtrace.exp,
gdb.trace/deltrace.exp, gdb.trace/infotrace.exp,
gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp,
gdb.trace/passcount.exp, gdb.trace/report.exp,
gdb.trace/save-trace.exp, gdb.trace/tfind.exp,
gdb.trace/tracecmd.exp, gdb.trace/while-dyn.exp,
gdb.trace/while-stepping.exp: Use a unique name for the compiled
executable.
2009-06-09 17:12:43 +00:00
|
|
|
set binfile ${objdir}/${subdir}/mi-watch
|
2000-02-23 00:25:43 +00:00
|
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
|
2006-08-10 05:27:22 +00:00
|
|
|
untested mi-watch.exp
|
|
|
|
return -1
|
2000-02-23 00:25:43 +00:00
|
|
|
}
|
|
|
|
|
2007-09-14 17:37:55 +00:00
|
|
|
proc test_watchpoint_creation_and_listing {type} {
|
2000-02-23 00:25:43 +00:00
|
|
|
global mi_gdb_prompt
|
|
|
|
global srcfile
|
|
|
|
global hex
|
|
|
|
|
2004-08-15 10:15:58 +00:00
|
|
|
set line_callee4_head [gdb_get_line_number "callee4 ("]
|
|
|
|
set line_callee4_body [expr $line_callee4_head + 2]
|
|
|
|
|
2000-02-23 00:25:43 +00:00
|
|
|
# Insert a watchpoint and list
|
|
|
|
# Tests:
|
|
|
|
# -break-watch C
|
|
|
|
# -break-list
|
|
|
|
|
|
|
|
mi_gdb_test "111-break-watch C" \
|
|
|
|
"111\\^done,wpt=\{number=\"2\",exp=\"C\"\}" \
|
|
|
|
"break-watch operation"
|
|
|
|
|
|
|
|
mi_gdb_test "222-break-list" \
|
MI breakpoint notifications.
* annotate.c (breakpoint_changed): Adjust parameter type.
* breakpoint.c (set_breakpoint_condition): Adjust to change
in breakpoint_modified type.
(breakpoint_set_commands): Likewise.
(do_map_commands_command): Likewise.
(bpstat_check_breakpoint_conditions): Notify that breakpoint has
changed after bumping hit count.
(bpstat_stop_status): Likewise.
(print_one_breakpoint_location): Don't wrap in tuple here.
(print_one_breakpoint): Always print individual locations.
For locations, use unnamed tuple.
(disable_breakpoints_in_unloaded_shlib): Notify that breakpoint
has changed.
(create_catchpoint, create_syscall_event_catchpoint): Call
breakpoint_created obsever.
(mention): Don't call breakpoint_created observer.
(create_breakpoint_sal): Call breakpoint_created observer.
(create_breakpoint, watch_command_1): Likewise.
(create_ada_exception_breakpoint): Likewise.
(delete_breakpoint): Call breakpoint_deleted breakpoint.
(locations_are_equal): New.
(update_breakpoint_locations): If locations were changed, notify.
(set_ignore_count, disable_breakpoint, do_enable_breakpoint):
Call breakpoint_modified observer.
* mi/mi-cmd-break.c (breakpoint_notify): Adjust.
(mi_cmd_break_insert): Don't set observers for modify and delete.
* mi/mi-interp.c (mi_suppress_breakpoint_notifications): New.
(mi_breakpoint_created, mi_breakpoint_deleted)
(mi_breakpoint_modified): New.
(mi_interpreter_init): Hook the above.
* mi/mi-main.c (mi_cmd_execute): Disable breakpoint notifications
while -break-* commands are executing.
* mi/mi-main.h (mi_suppress_breakpoint_notifications): New.
* mi/mi-out.c (struct ui_out_data): New field original_buffer.
(mi_redirect): New.
(mi_ui_out_impl): Hook in mi_redirect.
(mi_field_skip): True to the name, skip the field, don't output
a field with an empty value.
* python/py-breakpoint.c (gdbpy_breakpoint_created)
(gdbpy_breakpoint_deleted): Adjust.
* tui/tui-hooks.c (tui_event_create_breakpoint)
(tui_event_delete_breakpoint, tui_event_modify_breakpoint): Adjust.
2011-04-27 10:17:39 +00:00
|
|
|
"222\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[bkpt=\{number=\"2\",type=\".*watchpoint\",disp=\"keep\",enabled=\"y\",what=\"C\",times=\"0\",original-location=\"C\"\}\\\]\}" \
|
2000-02-23 00:25:43 +00:00
|
|
|
"list of watchpoints"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
# UNUSED at the time
|
2007-09-14 17:37:55 +00:00
|
|
|
proc test_awatch_creation_and_listing {type} {
|
2000-02-23 00:25:43 +00:00
|
|
|
global mi_gdb_prompt
|
|
|
|
global srcfile
|
|
|
|
global hex
|
|
|
|
|
2004-08-15 10:15:58 +00:00
|
|
|
set line_main_head [gdb_get_line_number "main ("]
|
|
|
|
set line_main_body [expr $line_main_head + 2]
|
|
|
|
|
2000-02-23 00:25:43 +00:00
|
|
|
# Insert an access watchpoint and list it
|
|
|
|
# Tests:
|
|
|
|
# -break-watch -a A
|
|
|
|
# -break-list
|
|
|
|
|
|
|
|
mi_gdb_test "333-break-watch -a A" \
|
2004-08-15 10:15:58 +00:00
|
|
|
"333\\^done,bkpt=\{number=\"1\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_main_body\"\}" \
|
2000-02-23 00:25:43 +00:00
|
|
|
"break-watch -a operation"
|
|
|
|
|
|
|
|
mi_gdb_test "444-break-list" \
|
2004-08-15 10:15:58 +00:00
|
|
|
"444\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"3\",type=\"watchpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"$line_main_body\",times=\"0\"\},.*\}\\\]\}" \
|
2000-02-23 00:25:43 +00:00
|
|
|
"list of watchpoints awatch"
|
|
|
|
|
|
|
|
mi_gdb_test "777-break-delete 3" \
|
|
|
|
"777\\^done" \
|
|
|
|
"delete access watchpoint"
|
|
|
|
}
|
|
|
|
|
|
|
|
# UNUSED at the time
|
2007-09-14 17:37:55 +00:00
|
|
|
proc test_rwatch_creation_and_listing {type} {
|
2000-02-23 00:25:43 +00:00
|
|
|
global mi_gdb_prompt
|
|
|
|
global srcfile
|
|
|
|
global hex
|
|
|
|
|
2004-08-15 10:15:58 +00:00
|
|
|
set line_main_head [gdb_get_line_number "main ("]
|
|
|
|
set line_main_body [expr $line_main_head + 2]
|
|
|
|
|
2000-02-23 00:25:43 +00:00
|
|
|
# Insert a read watchpoint and list it.
|
|
|
|
# Tests:
|
|
|
|
# -break-insert -r B
|
|
|
|
# -break-list
|
|
|
|
|
|
|
|
mi_gdb_test "200-break-watch -r C" \
|
2004-08-15 10:15:58 +00:00
|
|
|
"200\\^done,bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"$line_main_body\",times=\"0\"\}" \
|
2000-02-23 00:25:43 +00:00
|
|
|
"break-insert -r operation"
|
|
|
|
|
|
|
|
mi_gdb_test "300-break-list" \
|
2004-08-15 10:15:58 +00:00
|
|
|
"300\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"$line_main_body\",times=\"0\"\},.*\}\\\}\}" \
|
2000-02-23 00:25:43 +00:00
|
|
|
"list of breakpoints"
|
|
|
|
|
|
|
|
mi_gdb_test "177-break-delete 4" \
|
|
|
|
"177\\^done" \
|
|
|
|
"delete read watchpoint"
|
|
|
|
}
|
|
|
|
|
2007-09-14 17:37:55 +00:00
|
|
|
proc test_watchpoint_triggering {type} {
|
2000-02-23 00:25:43 +00:00
|
|
|
global mi_gdb_prompt
|
2005-05-17 Daniel Jacobowitz <dan@codesourcery.com>
Dennis Brueni <dennis@slickedit.com>
gdb/
* stack.c (print_frame): In MI mode, output a fullname attribute
with the stack frame.
gdb/doc/
* gdb.texinfo (GDB/MI Breakpoint Table Commands)
(GDB/MI Data Manipulation, GDB/MI Program Control)
(GDB/MI Stack Manipulation): Update examples to include the fullname
attribute in stack frames.
gdb/testsuite/
* gdb.mi/mi-cli.exp, gdb.mi/mi-return.exp, gdb.mi/mi-stack.exp,
gdb.mi/mi-stepi.exp, gdb.mi/mi-syn-frame.exp, gdb.mi/mi-until.exp,
gdb.mi/mi-var-display.exp, gdb.mi/mi-watch.exp, gdb.mi/mi2-cli.exp,
gdb.mi/mi2-return.exp, gdb.mi/mi2-stack.exp,
gdb.mi/mi2-syn-frame.exp, gdb.mi/mi2-until.exp,
gdb.mi/mi2-var-display.exp: Expect fullname field in stack frames.
* lib/mi-support.exp (mi_runto, mi_execute_to_helper): Likewise.
2005-05-18 03:41:59 +00:00
|
|
|
global hex fullname_syntax srcfile
|
2000-02-23 00:25:43 +00:00
|
|
|
|
2004-08-15 10:15:58 +00:00
|
|
|
set line_callee4_return_0 [gdb_get_line_number "return 0;"]
|
|
|
|
set line_callee3_head [gdb_get_line_number "callee3 ("]
|
|
|
|
set line_callee3_close_brace [expr $line_callee3_head + 3]
|
|
|
|
|
2000-02-23 00:25:43 +00:00
|
|
|
# Continue execution until the watchpoint is reached, continue again,
|
|
|
|
# to see the watchpoint go out of scope.
|
|
|
|
# Does:
|
|
|
|
# -exec-continue (Here wp triggers)
|
|
|
|
# -exec-continue (Here wp goes out of scope)
|
|
|
|
|
2008-04-05 17:12:46 +00:00
|
|
|
mi_execute_to "exec-continue" "watchpoint-trigger" "callee4" "" \
|
|
|
|
".*basics.c" $line_callee4_return_0 \
|
|
|
|
{"" "wpt=\{number=\"2\",exp=\"C\"\},value=\{old=\".*\",new=\"3\"\}"} \
|
|
|
|
"watchpoint trigger"
|
2000-02-23 00:25:43 +00:00
|
|
|
|
2007-09-14 17:37:55 +00:00
|
|
|
if { $type == "sw" } {
|
|
|
|
setup_xfail *-*-*
|
|
|
|
}
|
2008-04-05 17:12:46 +00:00
|
|
|
mi_execute_to "exec-continue" "watchpoint-scope" "callee3" ".*" \
|
|
|
|
".*basics.c" $line_callee3_close_brace \
|
|
|
|
{"" "wpnum=\"2\""} \
|
|
|
|
"watchpoint trigger"
|
2007-09-14 17:37:55 +00:00
|
|
|
clear_xfail *-*-*
|
2000-02-23 00:25:43 +00:00
|
|
|
}
|
|
|
|
|
2012-02-21 22:01:10 +00:00
|
|
|
proc test_watchpoint_all {type} { with_test_prefix "$type" {
|
2007-09-14 17:21:29 +00:00
|
|
|
upvar srcdir srcdir
|
|
|
|
upvar subdir subdir
|
|
|
|
upvar binfile binfile
|
|
|
|
|
|
|
|
mi_delete_breakpoints
|
|
|
|
mi_gdb_reinitialize_dir $srcdir/$subdir
|
|
|
|
mi_gdb_load ${binfile}
|
|
|
|
|
|
|
|
mi_runto callee4
|
2007-09-14 17:37:55 +00:00
|
|
|
test_watchpoint_creation_and_listing $type
|
|
|
|
#test_rwatch_creation_and_listing $type
|
|
|
|
#test_awatch_creation_and_listing $type
|
|
|
|
test_watchpoint_triggering $type
|
2012-02-21 21:55:39 +00:00
|
|
|
}}
|
2007-09-14 17:21:29 +00:00
|
|
|
|
|
|
|
# Run the tests twice, once using software watchpoints...
|
|
|
|
mi_gdb_test "567-gdb-set can-use-hw-watchpoints 0" \
|
|
|
|
"567\\^done" \
|
|
|
|
"hw watchpoints toggle (1)"
|
|
|
|
test_watchpoint_all sw
|
|
|
|
|
|
|
|
mi_gdb_exit
|
|
|
|
|
|
|
|
# ... and unless requested otherwise...
|
2007-09-06 23:25:41 +00:00
|
|
|
if [target_info exists gdb,no_hardware_watchpoints] {
|
2007-09-14 17:21:29 +00:00
|
|
|
return 0
|
2007-09-06 23:25:41 +00:00
|
|
|
}
|
|
|
|
|
2007-09-14 17:21:29 +00:00
|
|
|
mi_gdb_start
|
|
|
|
|
|
|
|
# ... once using hardware watchpoints (if available).
|
|
|
|
mi_gdb_test "890-gdb-set can-use-hw-watchpoints 1" \
|
|
|
|
"890\\^done" \
|
|
|
|
"hw watchpoints toggle (2)"
|
|
|
|
test_watchpoint_all hw
|
2000-02-23 00:25:43 +00:00
|
|
|
|
|
|
|
mi_gdb_exit
|
|
|
|
return 0
|