aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2012-02-07 19:47:16 +0000
committerTom Tromey <tromey@redhat.com>2012-02-07 19:47:16 +0000
commitf0823d2ce8e4cb8b64176872a372d8147804fb10 (patch)
treefb7552f824929309c2b65a6b54b656e90066885a /gdb/testsuite
parent64e7d9dddc00228cdbcecdd4c053cf83cf6608b7 (diff)
downloadgdb-f0823d2ce8e4cb8b64176872a372d8147804fb10.zip
gdb-f0823d2ce8e4cb8b64176872a372d8147804fb10.tar.gz
gdb-f0823d2ce8e4cb8b64176872a372d8147804fb10.tar.bz2
PR python/12027:
* python/python-internal.h (frame_object_type): Declare. * python/py-symbol.c (sympy_needs_frame): New function. (sympy_value): New function. (symbol_object_getset): Add "needs_frame". (symbol_object_methods): Add "value". * python/py-frame.c (frame_object_type): No longer static. gdb/doc * gdb.texinfo (Symbols In Python): Document Symbol.needs_frame and Symbol.value. gdb/testsuite * gdb.python/py-symbol.exp: Test Symbol.needs_frame and Symbol.value. * gdb.python/py-symbol.c (qq): Set default value.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog8
-rw-r--r--gdb/testsuite/gdb.python/py-symbol.c2
-rw-r--r--gdb/testsuite/gdb.python/py-symbol.exp18
3 files changed, 26 insertions, 2 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 39a952c..4fd340c 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,4 +1,10 @@
-2012-01-31 Tom Tromey <tromey@redhat.com>
+2012-02-07 Tom Tromey <tromey@redhat.com>
+
+ * gdb.python/py-symbol.exp: Test Symbol.needs_frame and
+ Symbol.value.
+ * gdb.python/py-symbol.c (qq): Set default value.
+
+2012-02-07 Tom Tromey <tromey@redhat.com>
* gdb.python/py-symbol.c (qq): New global.
* gdb.python/py-symbol.exp: Add test for frame-less
diff --git a/gdb/testsuite/gdb.python/py-symbol.c b/gdb/testsuite/gdb.python/py-symbol.c
index d29849b..4c1c26d 100644
--- a/gdb/testsuite/gdb.python/py-symbol.c
+++ b/gdb/testsuite/gdb.python/py-symbol.c
@@ -35,7 +35,7 @@ class SimpleClass
};
#endif
-int qq; /* line of qq */
+int qq = 72; /* line of qq */
int func (int arg)
{
diff --git a/gdb/testsuite/gdb.python/py-symbol.exp b/gdb/testsuite/gdb.python/py-symbol.exp
index 154eb37..0f5eb3c 100644
--- a/gdb/testsuite/gdb.python/py-symbol.exp
+++ b/gdb/testsuite/gdb.python/py-symbol.exp
@@ -42,10 +42,20 @@ gdb_py_test_silent_cmd "python main_func = gdb.lookup_global_symbol(\"main\")" "
gdb_test "python print main_func.is_function" "True" "Test main_func.is_function"
gdb_test "python print gdb.lookup_global_symbol(\"junk\")" "None" "Test lookup_global_symbol(\"junk\")"
+gdb_test "python print gdb.lookup_symbol('main')\[0\].value()" "$hex .main." \
+ "print value of main"
+
set qq_line [gdb_get_line_number "line of qq"]
gdb_test "python print gdb.lookup_symbol('qq')\[0\].line" "$qq_line" \
"print line number of qq"
+gdb_test "python print gdb.lookup_symbol('qq')\[0\].value()" "72" \
+ "print value of qq"
+
+gdb_test "python print gdb.lookup_symbol('qq')\[0\].needs_frame" "False" \
+ "print whether qq needs a frame"
+
+
if ![runto_main] then {
fail "Can't run to main"
return 0
@@ -88,6 +98,14 @@ gdb_test "python print a\[0\].is_argument" "False" "Test a.is_argument"
gdb_test "python print a\[0\].is_function" "False" "Test a.is_function"
gdb_test "python print a\[0\].addr_class == gdb.SYMBOL_LOC_COMPUTED" "True" "Test a.addr_class"
+gdb_test "python print a\[0\].value()" \
+ "symbol requires a frame to compute its value.*"\
+ "try to print value of a without a frame"
+gdb_test "python print a\[0\].value(frame)" "0" \
+ "print value of a"
+gdb_test "python print a\[0\].needs_frame" "True" \
+ "print whether a needs a frame"
+
# Test is_constant attribute
gdb_py_test_silent_cmd "python t = gdb.lookup_symbol(\"one\")" "Get variable a" 0
gdb_test "python print t\[0\].is_variable" "False" "Test t.is_variable"