diff options
author | Phil Muldoon <pmuldoon@redhat.com> | 2010-02-28 21:56:50 +0000 |
---|---|---|
committer | Phil Muldoon <pmuldoon@redhat.com> | 2010-02-28 21:56:50 +0000 |
commit | dc00d89fd009e18f9fc43f4bcc8c7a9661729471 (patch) | |
tree | de077027d456ab6216eba08a47be70014a7c0240 /gdb/testsuite/gdb.python | |
parent | 0e095b7eee9adf0be7109de8662647df7d0ee0ac (diff) | |
download | gdb-dc00d89fd009e18f9fc43f4bcc8c7a9661729471.zip gdb-dc00d89fd009e18f9fc43f4bcc8c7a9661729471.tar.gz gdb-dc00d89fd009e18f9fc43f4bcc8c7a9661729471.tar.bz2 |
2010-02-28 Phil Muldoon <pmuldoon@redhat.com>
PR python/11036
* python/py-frame.c (frapy_read_var): Add block argument and logic
to cope with user provided blocks.
2010-02-28 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block parameter and
description to read_var text.
2010-02-28 Phil Muldoon <pmuldoon@redhat.com>
* gdb.python/py-frame.exp: Add read_var block tests.
* gdb.python/py-frame.c (block): New function.
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r-- | gdb/testsuite/gdb.python/py-frame.c | 16 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-frame.exp | 24 |
2 files changed, 40 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-frame.c b/gdb/testsuite/gdb.python/py-frame.c index 22eb9f2..82db341 100644 --- a/gdb/testsuite/gdb.python/py-frame.c +++ b/gdb/testsuite/gdb.python/py-frame.c @@ -8,7 +8,23 @@ int f1 (int a, int b) return f2(a) + b; } +int block (void) +{ + int i = 99; + { + double i = 1.1; + double f = 2.2; + { + const char *i = "stuff"; + const char *f = "foo"; + const char *b = "bar"; + return 0; /* Block break here. */ + } + } +} + int main (int argc, char *argv[]) { + block (); return f1 (1, 2); } diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp index 6989207..150e737 100644 --- a/gdb/testsuite/gdb.python/py-frame.exp +++ b/gdb/testsuite/gdb.python/py-frame.exp @@ -56,6 +56,30 @@ if ![runto_main] then { return 0 } +gdb_breakpoint [gdb_get_line_number "Block break here."] +gdb_continue_to_breakpoint "Block break here." +gdb_py_test_silent_cmd "python bf1 = gdb.selected_frame ()" "get frame" 0 + +# First test that read_var is unaffected by PR 11036 changes. +gdb_test "python print bf1.read_var(\"i\")" "\"stuff\"" "test i" +gdb_test "python print bf1.read_var(\"f\")" "\"foo\"" "test f" +gdb_test "python print bf1.read_var(\"b\")" "\"bar\"" "test b" + +# Test the read_var function in another block other than the current +# block (in this case, the super block). Test thar read_var is reading +# the correct variables of i and f but they are the correct value and type. +gdb_py_test_silent_cmd "python sb = bf1.block().superblock" "get superblock" 0 +gdb_test "python print bf1.read_var(\"i\", sb)" "1.1.*" "test i = 1.1" +gdb_test "python print bf1.read_var(\"i\", sb).type" "double" "test double i" +gdb_test "python print bf1.read_var(\"f\", sb)" "2.2.*" "test f = 2.2" +gdb_test "python print bf1.read_var(\"f\", sb).type" "double" "test double f" + +# And again test another outerblock, this time testing "i" is the +# correct value and type. +gdb_py_test_silent_cmd "python sb = sb.superblock" "get superblock" 0 +gdb_test "python print bf1.read_var(\"i\", sb)" "99" "test i = 99" +gdb_test "python print bf1.read_var(\"i\", sb).type" "int" "test int i" + gdb_breakpoint "f2" gdb_continue_to_breakpoint "breakpoint at f2" gdb_test "up" "" "" |