]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.c
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dw2-is-stmt-2.c
1 /* Copyright 2020-2021 Free Software Foundation, Inc.
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 /* This tests GDB's handling of the DWARF is-stmt field in the line table.
17
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.
22
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.
28
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. */
32
33 /* Used to insert labels with which we can build a fake line table. */
34 #define LL(N) \
35 do \
36 { \
37 asm ("line_label_" #N ": .globl line_label_" #N); \
38 var = (N); \
39 bar = ((N) + 1); \
40 } \
41 while (0)
42
43 volatile int var;
44 volatile int bar;
45
46 int
47 main ()
48 { /* main prologue */
49 asm ("main_label: .globl main_label");
50
51 /* main start */
52
53 /* Line 1. */
54 /* Line 2. */
55 /* Line 3. */
56 /* Line 4. */
57 /* Line 5. */
58
59 LL (0);
60 LL (1);
61 LL (2);
62 LL (3);
63 LL (4);
64 LL (5);
65 LL (6);
66 LL (7);
67 LL (8);
68 LL (9);
69 LL (10);
70 LL (11);
71 LL (12);
72 LL (13);
73 LL (14);
74 LL (15);
75 LL (16);
76 return 0; /* main end */
77 }
78
79 #if 0
80
81 PROLOGUE*
82 1: L1
83 2: L1*
84 3: L2
85 4: L1
86 L3
87 L4
88 L4*
89 L2*
90 L2
91 L3
92 L5
93 L5*
94 L3
95 L4
96 L5
97 RETURN
98
99 #endif