diff options
author | Pedro Alves <palves@redhat.com> | 2011-08-09 16:21:18 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2011-08-09 16:21:18 +0000 |
commit | 9d8fa392330553fe114ae4137d15415aee2c547c (patch) | |
tree | a251e1e85a474b5acd1b00845f79d38480ca1a6a /gdb/testsuite/gdb.base | |
parent | b5503c7b66594da3ea6036c2a76aa42ee1c930c6 (diff) | |
download | binutils-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/gdb.base')
-rw-r--r-- | gdb/testsuite/gdb.base/display.c | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/display.exp | 26 |
2 files changed, 28 insertions, 0 deletions
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" |