1 /* Copyright 2020-2022 Free Software Foundation, Inc.
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.
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.
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/>. */
16 /* This tests GDB's handling of the DWARF is-stmt field in the line table.
18 This field is used when many addresses all represent the same source
19 line. The address(es) at which it is suitable to place a breakpoint for
20 a line are marked with is-stmt true, while address(es) that are not good
21 places to place a breakpoint are marked as is-stmt false.
23 In order to build a reproducible test and exercise GDB's is-stmt
24 support, we will be generating our own DWARF. The test will contain a
25 series of C source lines, ensuring that we get a series of assembler
26 instructions. Each C source line will be given an assembler label,
27 which we use to generate a fake line table.
29 In this fake line table each assembler block is claimed to represent a
30 single C source line, however, we will toggle the is-stmt flag. We can
31 then debug this with GDB and test the handling of is-stmt. */
33 /* Used to insert labels with which we can build a fake line table. */
34 #define LL(N) asm ("line_label_" #N ": .globl line_label_" #N)
42 asm ("main_label: .globl main_label");
44 var
= 99; /* main, set var to 99 */
48 var
= 0; /* main, set var to 0 */
52 var
= 1; /* main, set var to 1 */
56 var
= 2; /* main, set var to 2 */
60 return 0; /* main end */