aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorYao Qi <yao@codesourcery.com>2012-10-17 00:53:24 +0000
committerYao Qi <yao@codesourcery.com>2012-10-17 00:53:24 +0000
commit8de0566d7a01e024fa43e7e1bde309c718856695 (patch)
tree15e8946c06a60231b27f2ba37926c8ce64b01dfe /gdb/testsuite
parentb1fecbf125225e49517549d561fe5f480ee5055f (diff)
downloadgdb-8de0566d7a01e024fa43e7e1bde309c718856695.zip
gdb-8de0566d7a01e024fa43e7e1bde309c718856695.tar.gz
gdb-8de0566d7a01e024fa43e7e1bde309c718856695.tar.bz2
gdb:
* breakpoint.c (invalidate_bp_value_on_memory_change): Add one more parameter 'inferior'. * corefile.c (write_memory_with_notification): Caller update. * mi/mi-cmd-var.c: Include "mi-main.h". (mi_cmd_var_assign): Set mi_suppress_notification.data_write_memory to 1 and restore it later. * mi/mi-cmds.c (mi_cmd mi_cmds): Update for "data-write-memory" and "data-write-memory-bytes. * mi/mi-interp.c: Include objfiles.h. (mi_interpreter_init): Call observer_attach_memory_changed. (mi_memory_changed): New. * mi/mi-main.h (struct mi_suppress_notification) <memory>: New field. * NEWS: Mention new MI notification "memory-changed". gdb/doc: * observer.texi (GDB Observers): Update observer 'memory_changed'. * gdb.texinfo (GDB/MI Async Records): Document for "memory-changed" notification. gdb/testsuite: * gdb.mi/mi-memory-changed.exp: New.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.mi/mi-memory-changed.exp81
2 files changed, 85 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 671cd8c..f9d40ff 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2012-10-17 Yao Qi <yao@codesourcery.com>
+
+ * gdb.mi/mi-memory-changed.exp: New.
+
2012-10-16 Yao Qi <yao@codesourcery.com>
* gdb.reverse/solib-precsave.exp: Skip if skip_shlib_test
diff --git a/gdb/testsuite/gdb.mi/mi-memory-changed.exp b/gdb/testsuite/gdb.mi/mi-memory-changed.exp
new file mode 100644
index 0000000..f290992
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-memory-changed.exp
@@ -0,0 +1,81 @@
+# Copyright 2012 Free Software Foundation, Inc.
+
+# 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
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+standard_testfile basics.c
+if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
+ executable {debug nowarnings}] != "" } {
+ untested mi-record-changed.exp
+ return -1
+}
+
+load_lib mi-support.exp
+
+if [mi_gdb_start] {
+ return
+}
+mi_gdb_reinitialize_dir $srcdir/$subdir
+mi_gdb_load ${binfile}
+
+mi_gdb_test "-break-insert -t ${srcfile}:[gdb_get_line_number "C = A + B"]" \
+ "\\^done,bkpt=\{number=\"1\".*" \
+ "insert breakpoint"
+mi_run_cmd
+mi_expect_stop "breakpoint-hit" "callee4" "" ".*" ".*" {"" "disp=\"del\""} \
+ "continue to callee4"
+
+mi_gdb_test "set var C = 4" \
+ ".*=memory-changed,thread-group=\"i${decimal}\".addr=\"${hex}\",len=\"${hex}\".*\\^done" \
+ "set var C = 4"
+
+# Write memory through MI commands shouldn't trigger MI notification.
+mi_gdb_test "-var-create var_c * C" \
+ "\\^done,name=\"var_c\",numchild=\"0\",value=\"4\",type=\"int\",thread-id=\"1\",has_more=\"0\"" \
+ "create objvar for C"
+
+mi_gdb_test "-var-assign var_c 5" \
+ "-var-assign var_c 5\r\n\\^done,value=\"5\"" \
+ "change C thru. varobj"
+
+mi_gdb_test "-data-write-memory-bytes &C \"00\"" \
+ {\^done} \
+ "change C thru. -data-write-memory-bytes"
+
+# Modify code section also triggers MI notification.
+
+# Get the instruction content of function main and its address.
+set main_addr ""
+set main_insn ""
+set test "get address of main"
+send_gdb "x/x main\n"
+gdb_expect {
+ -re ".*(${hex}) <main>:.*(${hex}).*$mi_gdb_prompt$" {
+ set main_addr $expect_out(1,string)
+ set main_insn $expect_out(2,string)
+ pass $test
+ }
+ -re ".*$mi_gdb_prompt$" {
+ fail $test
+ return
+ }
+ timeout {
+ fail "$test (timeout)"
+ return
+ }
+}
+
+mi_gdb_test "set var *(unsigned int *) ${main_addr} = ${main_insn}" \
+ ".*=memory-changed,thread-group=\"i${decimal}\".addr=\"${main_addr}\",len=\"0x4\",type=\"code\".*\\^done"
+mi_gdb_exit
+return 0