Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dw2-is-stmt-2.c
CommitLineData
88b9d363 1/* Copyright 2020-2022 Free Software Foundation, Inc.
8c95582d
AB
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
43volatile int var;
44volatile int bar;
45
46int
47main ()
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
81PROLOGUE*
821: L1
832: L1*
843: L2
854: L1
86L3
87L4
88L4*
89L2*
90L2
91L3
92L5
93L5*
94L3
95L4
96L5
97RETURN
98
99#endif
This page took 0.236415 seconds and 4 git commands to generate.