* gdb.python/lib-types.exp: Use standard_testfile,
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / python.exp
index 2708dcc663ccfe949533a32735b227f61f71d98f..2c7ead2693550a08fc595dca767e51e212fb8399 100644 (file)
 
 load_lib gdb-python.exp
 
-set testfile "python"
-set srcfile  ${testfile}.c
-set srcfile1  ${testfile}-1.c
-set binfile  ${objdir}/${subdir}/${testfile}
-
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile1}" \
-         ${binfile} executable {debug}] != "" } {
-    untested "Could not compile $binfile."
+standard_testfile python.c python-1.c
+
+if {[build_executable $testfile.exp $testfile \
+        [list $srcfile $srcfile2] debug] == -1} {
     return -1
 }
 
@@ -182,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"
@@ -364,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"
This page took 0.025156 seconds and 4 git commands to generate.