aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2011-08-09 16:21:18 +0000
committerPedro Alves <palves@redhat.com>2011-08-09 16:21:18 +0000
commit9d8fa392330553fe114ae4137d15415aee2c547c (patch)
treea251e1e85a474b5acd1b00845f79d38480ca1a6a /gdb/testsuite
parentb5503c7b66594da3ea6036c2a76aa42ee1c930c6 (diff)
downloadbinutils-9d8fa392330553fe114ae4137d15415aee2c547c.zip
binutils-9d8fa392330553fe114ae4137d15415aee2c547c.tar.gz
binutils-9d8fa392330553fe114ae4137d15415aee2c547c.tar.bz2
2011-08-09 Pedro Alves <pedro@codesourcery.com>
gdb/ * printcmd.c (current_display_number): Update comment. (disable_current_display_cleanup): Delete. (do_one_display): Use make_cleanup_restore_integer. Gracefully catch errors thrown while evaluating and printing the display. gdb/testsuite/ * gdb.base/display.c (do_loops): New `p_i' local. * gdb.base/display.exp: Test displaying a variable that is temporarily at a bad address.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.base/display.c2
-rw-r--r--gdb/testsuite/gdb.base/display.exp26
3 files changed, 34 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 50d8423..35578ba 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2011-08-09 Pedro Alves <pedro@codesourcery.com>
+
+ * gdb.base/display.c (do_loops): New `p_i' local.
+ * gdb.base/display.exp: Test displaying a variable that is
+ temporarily at a bad address.
+
2011-08-08 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.dwarf2/dw2-op-stack-value.S: New file.
diff --git a/gdb/testsuite/gdb.base/display.c b/gdb/testsuite/gdb.base/display.c
index 332c45b..cd833e2 100644
--- a/gdb/testsuite/gdb.base/display.c
+++ b/gdb/testsuite/gdb.base/display.c
@@ -14,6 +14,8 @@ int do_loops()
int k=0;
int j=0;
float f=3.1415;
+ int *p_i = &i;
+
for( i = 0; i < LOOP; i++ ) { /* set breakpoint 1 here */
for( j = 0; j < LOOP; j++ ) {
for( k = 0; k < LOOP; k++ ) {
diff --git a/gdb/testsuite/gdb.base/display.exp b/gdb/testsuite/gdb.base/display.exp
index 2181c6a..fcf8511 100644
--- a/gdb/testsuite/gdb.base/display.exp
+++ b/gdb/testsuite/gdb.base/display.exp
@@ -119,6 +119,32 @@ gdb_test "undisp" \
"y"
+# Test displaying a variable that is temporarily at a bad address.
+# But if we can examine what's at memory address 0, then we'll also be
+# able to display it without error. Don't run the test in that case.
+set can_read_0 0
+gdb_test_multiple "x 0" "memory at address 0" {
+ -re "0x0:.*Cannot access memory at address 0x0.*$gdb_prompt $" { }
+ -re "0x0:.*Error accessing memory address 0x0.*$gdb_prompt $" { }
+ -re ".*$gdb_prompt $" {
+ set can_read_0 1
+ }
+}
+
+if { !$can_read_0 } {
+ gdb_test "disp *p_i" ".*: \\*p_i = 0"
+ gdb_test "p p_i = 0x0" " = \\(int \\*\\) 0x0"
+ gdb_test "display" ".*: \\*p_i = <error: .*>" "display bad address"
+ gdb_test "p p_i = &i" " = \\(int \\*\\) $hex"
+ gdb_test "display" ".*: \\*p_i = 0" "display good address"
+
+ gdb_test "undisp" \
+ "" \
+ "undisp all again" \
+ ".*Delete all auto-display expressions.*y or n. $" \
+ "y"
+}
+
gdb_test "disab 3" ".*.*" "disab 3"
gdb_test "cont" ".*Breakpoint 4.*" "watch off"