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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
|
# This testcase is part of GDB, the GNU debugger.
# Copyright 2024 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 complaints about .debug_macro section.
load_lib dwarf.exp
require dwarf2_support
require !readnow
standard_testfile main.c .S
lassign [function_range main $srcdir/$subdir/$srcfile] \
main_start main_len
set asm_file [standard_output_file $srcfile2]
set line [gdb_get_line_number "return 0;"]
Dwarf::assemble $asm_file {
declare_labels L cu_macro1
cu {} {
DW_TAG_compile_unit {
{DW_AT_name $::srcfile}
{DW_AT_macros $cu_macro1 DW_FORM_sec_offset}
{DW_AT_stmt_list $L DW_FORM_sec_offset}
} {
declare_labels int_type
int_type: DW_TAG_base_type {
{DW_AT_byte_size 4 DW_FORM_sdata}
{DW_AT_encoding @DW_ATE_signed}
{DW_AT_name int}
}
DW_TAG_subprogram {
{MACRO_AT_func {main}}
{type :$int_type}
}
}
}
lines {version 2} L {
file_name $::srcfile 1
program {
DW_LNE_set_address $::main_start
line $::line
DW_LNS_copy
DW_LNE_set_address "$::main_start + $::main_len"
DW_LNE_end_sequence
}
}
# Define the .debug_macro section.
macro {
cu_macro1: unit {
"debug-line-offset-label" $L
} {
define 0 "M1_01_BUILTIN_OK 1"
define 1 "M1_02_BUILTIN_BADLINE 1"
start_file 0 1
define 1 "M1_03_OK 1"
define 0 "M1_04_BADLINE 1"
start_file 1 1234
define 1 "M1_05_BADFILE 1"
end_file
define 1 "M1_06_OK "
define 1 "M1_07_MALFORMED"
define 1 "M1_08_OK() 1"
define 1 "M1_09_OK(ARG) (ARG)"
define 1 "M1_10_OK(ARG1,ARG2) (ARG1+ARG2)"
define 1 "M1_11_MALFORMED(ARG"
define 1 "M1_12_MALFORMED(ARG,"
define 1 "M1_13_MALFORMED(ARG,)"
define 1 "M1_14_MALFORMED()1"
end_file
}
}
}
if { [build_executable "failed to prepare" $testfile \
[list $srcfile $asm_file] {nodebug}] } {
return
}
clean_restart
set re_complaint1 \
"debug info gives command-line macro definition with non-zero line 1: M1_02_BUILTIN_BADLINE 1"
set re_complaint2 \
"debug info gives in-file macro definition with zero line 0: M1_04_BADLINE 1"
set re_complaint3 \
[string_to_regexp "bad file number in macro information (1234)"]
set re_complaint4 \
[multi_line \
"macro debug info contains a malformed macro definition:" \
"`M1_07_MALFORMED'"]
set re_complaint5 \
[multi_line \
"macro debug info contains a malformed macro definition:" \
[string_to_regexp "`M1_11_MALFORMED(ARG'"]]
set re_complaint6 \
[multi_line \
"macro debug info contains a malformed macro definition:" \
[string_to_regexp "`M1_12_MALFORMED(ARG,'"]]
set re_complaint7 \
[multi_line \
"macro debug info contains a malformed macro definition:" \
[string_to_regexp "`M1_13_MALFORMED(ARG,)'"]]
set re_complaint8 \
[multi_line \
"macro debug info contains a malformed macro definition:" \
[string_to_regexp "`M1_14_MALFORMED()1'"]]
set prefix \
"During symbol reading"
set re \
[multi_line \
"$prefix: $re_complaint1" \
"$prefix: $re_complaint2" \
"$prefix: $re_complaint3" \
"$prefix: $re_complaint4" \
"$prefix: $re_complaint5" \
"$prefix: $re_complaint6" \
"$prefix: $re_complaint7" \
"$prefix: $re_complaint8" \
[string cat [string_to_regexp {$}] "$decimal = \[^\r\n\]+"]]
with_complaints 10 {
gdb_load $binfile
gdb_test "p main" ^$re "complaints"
}
set re_explicit \
[multi_line \
"Defined at $srcfile:0" \
"-DM1_01_BUILTIN_OK=1" \
"Defined at $srcfile:1" \
"#define M1_02_BUILTIN_BADLINE 1" \
"Defined at $srcfile:1" \
"#define M1_03_OK 1" \
"Defined at $srcfile:0" \
"-DM1_04_BADLINE=1" \
"Defined at <bad macro file number 1234>:1" \
" included at $srcfile:1" \
"#define M1_05_BADFILE 1" \
"Defined at $srcfile:1" \
"#define M1_06_OK " \
"Defined at $srcfile:1" \
"#define M1_07_MALFORMED " \
"Defined at $srcfile:1" \
[string_to_regexp "#define M1_08_OK() 1"] \
"Defined at $srcfile:1" \
[string_to_regexp "#define M1_09_OK(ARG) (ARG)"] \
"Defined at $srcfile:1" \
[string_to_regexp "#define M1_10_OK(ARG1, ARG2) (ARG1+ARG2)"] \
"Defined at $srcfile:1" \
[string_to_regexp "#define M1_13_MALFORMED(ARG) "]]
set re_implicit \
[multi_line \
"Defined at $srcfile:-1" \
"#define __FILE__ \"$srcfile\"" \
"Defined at $srcfile:-1" \
"#define __LINE__ $line"]
gdb_test "info macros $line" \
[multi_line \
$re_explicit \
$re_implicit]
|