1 # Copyright (C) 2021-2024 Free Software Foundation, Inc. 2 # 3 # This program is free software; you can redistribute it and/or modify 4 # it under the terms of the GNU General Public License as published by 5 # the Free Software Foundation; either version 3 of the License, or 6 # (at your option) any later version. 7 # 8 # This program is distributed in the hope that it will be useful, 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 # GNU General Public License for more details. 12 # 13 # You should have received a copy of the GNU General Public License 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 # Test that the value of gdb.current_objfile is correct even when one 17 # auto-load script loads a second objfile, which triggers the 18 # execution of another (nested) objfile script. 19 20 load_lib gdb-python.exp 21 22 require allow_python_tests 23 24 standard_testfile .c -f1.c -f2.c 25 26 # Two additional object files needed for this test. 27 set f1_o [standard_output_file ${gdb_test_file_name}-f1.o] 28 set f2_o [standard_output_file ${gdb_test_file_name}-f2.o] 29 30 # Now build the object files. 31 if {[gdb_compile "${srcdir}/${subdir}/${srcfile2}" ${f1_o} object {}] != ""} { 32 untested "failed to compile object file f1.o" 33 return -1 34 } 35 36 if {[gdb_compile "${srcdir}/${subdir}/${srcfile3}" ${f2_o} object {}] != ""} { 37 untested "failed to compile object file f2.o" 38 return -1 39 } 40 41 # Copy the two Python scripts to where the tests are being run. 42 set remote_python_file [gdb_remote_download host \ 43 ${srcdir}/${subdir}/${testfile}-f1.o-gdb.py] 44 set remote_python_file [gdb_remote_download host \ 45 ${srcdir}/${subdir}/${testfile}-f2.o-gdb.py] 46 47 # Build the main test executable and start GDB. 48 if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} { 49 return -1 50 } 51 52 if ![runto_main] { 53 return -1 54 } 55 56 set safe_path [standard_output_file ""] 57 gdb_test_no_output "set auto-load safe-path ${safe_path}" \ 58 "set auto-load safe-path" 59 60 gdb_breakpoint [gdb_get_line_number "Break Here"] 61 gdb_continue_to_breakpoint "run to test breakpoint" 62 63 gdb_test_no_output "set confirm off" 64 gdb_test "add-symbol-file ${f1_o} region_1" \ 65 [multi_line \ 66 "Entering f1\\.o auto-load script" \ 67 "Current objfile is: \[^\r\n\]+/py-auto-load-chaining-f1\\.o" \ 68 "Chain loading f2\\.o\\.\\.\\." \ 69 "add symbol table from file \"\[^\r\n\]+/py-auto-load-chaining-f2\\.o\" at" \ 70 "\\s+\\.text_addr = $hex" \ 71 "Entering f2\\.o auto-load script" \ 72 "Current objfile is: \[^\r\n\]+/py-auto-load-chaining-f2\\.o" \ 73 "Leaving f2\\.o auto-load script" \ 74 "After loading f2\\.o\\.\\.\\." \ 75 "Current objfile is: \[^\r\n\]+/py-auto-load-chaining-f1\\.o" \ 76 "Leaving f1\\.o auto-load script"] \ 77 "add-symbol-file f1.o" 78