aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python/py-auto-load-chaining.exp
blob: aac6eb305b9455bca815d22c72ddc1836459d3e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Copyright (C) 2021-2023 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Test that the value of gdb.current_objfile is correct even when one
# auto-load script loads a second objfile, which triggers the
# execution of another (nested) objfile script.

load_lib gdb-python.exp

require !skip_python_tests

standard_testfile .c -f1.c -f2.c

# Two additional object files needed for this test.
set f1_o [standard_output_file ${gdb_test_file_name}-f1.o]
set f2_o [standard_output_file ${gdb_test_file_name}-f2.o]

# Now build the object files.
if {[gdb_compile "${srcdir}/${subdir}/${srcfile2}" ${f1_o} object {}] != ""} {
  untested "failed to compile object file f1.o"
  return -1
}

if {[gdb_compile "${srcdir}/${subdir}/${srcfile3}" ${f2_o} object {}] != ""} {
  untested "failed to compile object file f2.o"
  return -1
}

# Copy the two Python scripts to where the tests are being run.
set remote_python_file [gdb_remote_download host \
			    ${srcdir}/${subdir}/${testfile}-f1.o-gdb.py]
set remote_python_file [gdb_remote_download host \
			    ${srcdir}/${subdir}/${testfile}-f2.o-gdb.py]

# Build the main test executable and start GDB.
if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} {
    return -1
}

if ![runto_main] {
   return -1
}

set safe_path [standard_output_file ""]
gdb_test_no_output "set auto-load safe-path ${safe_path}" \
    "set auto-load safe-path"

gdb_breakpoint [gdb_get_line_number "Break Here"]
gdb_continue_to_breakpoint "run to test breakpoint"

gdb_test_no_output "set confirm off"
gdb_test "add-symbol-file ${f1_o} region_1" \
    [multi_line \
	 "Entering f1\\.o auto-load script" \
	 "Current objfile is: \[^\r\n\]+/py-auto-load-chaining-f1\\.o" \
	 "Chain loading f2\\.o\\.\\.\\." \
	 "add symbol table from file \"\[^\r\n\]+/py-auto-load-chaining-f2\\.o\" at" \
	 "\\s+\\.text_addr = $hex" \
	 "Entering f2\\.o auto-load script" \
	 "Current objfile is: \[^\r\n\]+/py-auto-load-chaining-f2\\.o" \
	 "Leaving f2\\.o auto-load script" \
	 "After loading f2\\.o\\.\\.\\." \
	 "Current objfile is: \[^\r\n\]+/py-auto-load-chaining-f1\\.o" \
	 "Leaving f1\\.o auto-load script"] \
    "add-symbol-file f1.o"