Index: gdb/testsuite/gdb.python/py-symbol.exp |
diff --git a/gdb/testsuite/gdb.python/py-symbol.exp b/gdb/testsuite/gdb.python/py-symbol.exp |
index aa952fb45b73bd71607a01c4012c3064328a1c40..bc20ee471dbf8e25c13acc8fcc1c8bceb2419656 100644 |
--- a/gdb/testsuite/gdb.python/py-symbol.exp |
+++ b/gdb/testsuite/gdb.python/py-symbol.exp |
@@ -16,26 +16,14 @@ |
# This file is part of the GDB testsuite. It tests the mechanism |
# exposing values to Python. |
-if $tracelevel then { |
- strace $tracelevel |
-} |
- |
load_lib gdb-python.exp |
-set testfile "py-symbol" |
-set srcfile ${testfile}.c |
-set binfile ${objdir}/${subdir}/${testfile} |
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { |
- untested "Couldn't compile ${srcfile}" |
+standard_testfile |
+ |
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} { |
return -1 |
} |
-# Start with a fresh gdb. |
-gdb_exit |
-gdb_start |
-gdb_reinitialize_dir $srcdir/$subdir |
-gdb_load ${binfile} |
- |
# Skip all tests if Python scripting is not enabled. |
if { [skip_python_tests] } { continue } |
@@ -46,6 +34,21 @@ 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_global_symbol('main').value()" "$hex .main." \ |
+ "print value of main" |
+ |
+set qq_line [gdb_get_line_number "line of qq"] |
+gdb_test "python print gdb.lookup_global_symbol('qq').line" "$qq_line" \ |
+ "print line number of qq" |
+ |
+gdb_test "python print gdb.lookup_global_symbol('qq').value()" "72" \ |
+ "print value of qq" |
+ |
+gdb_test "python print gdb.lookup_global_symbol('qq').needs_frame" \ |
+ "False" \ |
+ "print whether qq needs a frame" |
+ |
+ |
if ![runto_main] then { |
fail "Can't run to main" |
return 0 |
@@ -88,6 +91,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" |