Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2020-2022 Free Software Foundation, Inc. |
4a636814 SM |
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 to reproduce the crash described in PR 26693. The following DWARF was | |
17 | # crashing GDB while loading partial symbols: a DW_TAG_subprogram with a | |
18 | # DW_AT_specification (pointing to another subprogram), without a DW_AT_name | |
19 | # and with a template parameter (DW_TAG_template_type_parameter). More | |
20 | # precisely, the crash was happening when trying to compute the full name of the | |
21 | # subprogram. | |
22 | ||
23 | load_lib dwarf.exp | |
24 | ||
25 | if {![dwarf2_support]} { | |
26 | return 0 | |
27 | } | |
28 | ||
29 | standard_testfile main.c .S | |
30 | ||
31 | set asm_file [standard_output_file $srcfile2] | |
32 | Dwarf::assemble $asm_file { | |
33 | cu {} { | |
34 | DW_TAG_compile_unit { | |
35 | {DW_AT_language @DW_LANG_C_plus_plus} | |
36 | } { | |
37 | declare_labels templated_subprogram int | |
38 | ||
39 | int: DW_TAG_base_type { | |
40 | {DW_AT_name "int"} | |
41 | {DW_AT_byte_size 4 DW_FORM_data1} | |
42 | {DW_AT_encoding @DW_ATE_signed} | |
43 | } | |
44 | ||
45 | # The templated subprogram. | |
46 | templated_subprogram: DW_TAG_subprogram { | |
47 | {DW_AT_name "apply"} | |
48 | } | |
49 | ||
50 | # The template specialization. | |
51 | # | |
52 | # The low and high PC are phony: we just need an address range that | |
53 | # is valid in the program, so we use the main function's range. | |
54 | DW_TAG_subprogram { | |
55 | {DW_AT_specification :$templated_subprogram} | |
56 | {MACRO_AT_range main} | |
57 | } { | |
58 | DW_TAG_template_type_param { | |
59 | {DW_AT_name "T"} | |
60 | {DW_AT_type :$int DW_FORM_ref4} | |
61 | } | |
62 | } | |
63 | } | |
64 | } | |
65 | } | |
66 | ||
67 | if { [prepare_for_testing "failed to prepare" ${testfile} \ | |
68 | [list $srcfile $asm_file] {nodebug}] } { | |
69 | return -1 | |
70 | } | |
71 | ||
72 | if ![runto_main] { | |
73 | return -1 | |
74 | } | |
75 | ||
76 | # Just a sanity check to make sure GDB slurped the symbols correctly. | |
77 | gdb_test "print apply<int>" " = {void \\(void\\)} $hex <apply<int>\\(\\)>" |