]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.xml/tdesc-reload.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.xml / tdesc-reload.exp
CommitLineData
213516ef 1# Copyright 2020-2023 Free Software Foundation, Inc.
caa7fd04
AB
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# Testing for 'maint print xml-tdesc'. Check we can print out the
17# current target description and load it back in again.
18
19if {[gdb_skip_xml_test]} {
20 unsupported "xml tests not being run"
21 return -1
22}
23
24standard_testfile
25
26if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
27 return -1
28}
29
f50c72da 30if {![runto_main]} {
caa7fd04
AB
31 return 0
32}
33
34# Three files we're going to write out to.
35set xml_file_1 [standard_output_file outfile1.xml]
36set xml_file_2 [standard_output_file outfile2.xml]
37set xml_file_3 [standard_output_file outfile3.xml]
38
39# Write the current target description to a file.
40gdb_test_no_output "pipe maint print xml-tdesc | cat > $xml_file_1" \
41 "write current target description to file"
42
43# Read the target description back in to GDB, and the write it back
44# out to a file.
45gdb_test_no_output \
46 "pipe maint print xml-tdesc $xml_file_1 | cat > $xml_file_2" \
47 "read previous xml description, and write it out to a second file"
48
49# Check the two produced files are identical.
50gdb_test "shell diff -s $xml_file_1 $xml_file_2" \
51 "Files \[^\r\n\]* are identical" \
52 "first two produced xml files are identical"
53
54# Restart GDB.
55clean_restart
56
57# Change to use one of the target descriptions we wrote out earlier.
58gdb_test_no_output "set tdesc filename $xml_file_1" \
59 "set target description to use"
60
61# Load the executable.
62gdb_load ${binfile}
63
64# Run to `main' where we begin our tests.
f50c72da 65if {![runto_main]} {
caa7fd04
AB
66 return -1
67}
68
69# Run info registers just to check this appears to run fine with the
70# new target description.
c76d61da 71gdb_test -lbl "info all-registers" "" "Run info registers"
caa7fd04
AB
72
73# Write out the current target description.
74gdb_test_no_output "pipe maint print xml-tdesc | cat > $xml_file_3" \
75 "write third target description to file"
76
77# And check that it matches the original file we loaded.
78gdb_test "shell diff -s $xml_file_1 $xml_file_3" \
79 "Files \[^\r\n\]* are identical" \
80 "first and third produced xml files are identical"