Index: gdb/testsuite/gdb.python/python.exp |
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp |
index 42036dfa6935b79eebb12ce23705009362c882f5..9683b1ccf7a66aa75a7d9758a7f8832294aa0978 100644 |
--- a/gdb/testsuite/gdb.python/python.exp |
+++ b/gdb/testsuite/gdb.python/python.exp |
@@ -16,20 +16,12 @@ |
# 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 "python" |
-set srcfile ${testfile}.c |
-set srcfile1 ${testfile}-1.c |
-set binfile ${objdir}/${subdir}/${testfile} |
+standard_testfile python.c python-1.c |
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile1}" \ |
- ${binfile} executable {debug}] != "" } { |
- untested "Could not compile $binfile." |
+if {[build_executable $testfile.exp $testfile \ |
+ [list $srcfile $srcfile2] debug] == -1} { |
return -1 |
} |
@@ -120,7 +112,7 @@ gdb_test_multiple "python print \"\\n\" * $lines" $test { |
pass $test |
} |
} |
-gdb_test "q" "Quit" "verify pagination beforehand: q" |
+gdb_test "q" "Quit.*Error while executing Python.*" "verify pagination beforehand: q" |
gdb_test "python if gdb.execute('python print \"\\\\n\" * $lines', to_string=True) == \"\\n\" * [expr $lines + 1]: print \"yes\"" "yes" "gdb.execute does not page" |
@@ -136,7 +128,7 @@ gdb_test_multiple "python print \"\\n\" * $lines" $test { |
pass $test |
} |
} |
-gdb_test "q" "Quit" "verify pagination afterwards: q" |
+gdb_test "q" "Quit.*Error while executing Python.*" "verify pagination afterwards: q" |
gdb_test_no_output "set height 0" |
@@ -186,6 +178,9 @@ gdb_test "python print len(symtab)" "2" "Test decode_line func1 length" |
gdb_test "python print len(symtab\[1\])" "1" "Test decode_line func1 length" |
gdb_test "python print symtab\[1\]\[0\].symtab" ".*gdb.python/python-1.c.*" "Test decode_line func1 filename" |
gdb_test "python print symtab\[1\]\[0\].line" "19" "Test decode_line func1 line number" |
+gdb_py_test_silent_cmd {python symtab = gdb.decode_line ("func1,func2")} \ |
+ "test decode_line func1,func2" 1 |
+gdb_test {python print symtab[0]} ",func2" "stop at comma in linespec" |
# gdb.write |
gdb_test "python print sys.stderr" ".*__main__.GdbOutputErrorFile instance at.*" "Test stderr location" |
@@ -368,3 +363,23 @@ gdb_test_multiple "python gdb.prompt_hook = error_prompt" "set the hook" { |
gdb_py_test_silent_cmd "python gdb.prompt_hook = None" \ |
"set the hook to default" 1 |
+ |
+# Start with a fresh gdb. |
+clean_restart ${testfile} |
+ |
+# The following tests require execution. |
+ |
+if ![runto_main] then { |
+ fail "Can't run to main" |
+ return 0 |
+} |
+ |
+runto [gdb_get_line_number "Break at func2 call site."] |
+ |
+gdb_py_test_silent_cmd "python line = gdb.selected_frame().find_sal().line" "Get line number of func2 call site" 1 |
+gdb_test "python print gdb.find_pc_line(gdb.selected_frame().pc()).line == line" "True" "Test find_pc_line at func2 call site" |
+ |
+gdb_py_test_silent_cmd "step" "Step into func2" 1 |
+gdb_py_test_silent_cmd "up" "Step out of func2" 1 |
+ |
+gdb_test "python print gdb.find_pc_line(gdb.selected_frame().pc()).line > line" "True" "Test find_pc_line with resume address" |