1 # Test for printing alias symbols.
2 # Copyright 2017-2024 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 standard_testfile symbol-alias.c symbol-alias2.c
18 # Clang versions prior to v15 do not emit debug info for aliases.
19 set old_clang [expr [test_compiler_info {clang-1[0-4]-*-*}] \
20 || [test_compiler_info {clang-[1-9]-*}]]
22 if { [prepare_for_testing "failed to prepare" ${testfile} [list $srcfile $srcfile2]] } {
31 foreach f {"func" "func_alias"} {
32 gdb_test "p $f" " = {(struct )?S \\*\\(void\\)} $hex <func(\\(\\))?>"
33 gdb_test "p *${f}()" "= {field1 = 1, field2 = 2}"
36 # Extern global variable.
37 gdb_test "p g_var_s" "= {field1 = 1, field2 = 2}"
38 foreach v {"g_var_s_alias" "g_var_s_alias2"} {
39 gdb_test_multiple "p $v" "print alias variable $v" {
40 -re -wrap " = {field1 = 1, field2 = 2}" {
43 -re -wrap "has unknown type; cast it to its declared type" {
53 # Static global variable.
54 gdb_test "p g_var" " = 1"
55 gdb_test_multiple "p g_var_alias" "print alias of static variable" {
59 -re -wrap "has unknown type; cast it to its declared type" {
68 # Alias of a variable that is declared later in the scope.
69 gdb_test "p g_def_var" " = 2"
70 gdb_test_multiple "p g_def_var_alias" "print g_def_var_alias" {
74 -re -wrap "has unknown type; cast it to its declared type" {
82 gdb_test_multiple "p g_def_var_alias2" "print g_def_var_alias2" {
86 -re -wrap "has unknown type; cast it to its declared type" {