aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.c')
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.c b/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.c
new file mode 100644
index 0000000..be3fa45
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.c
@@ -0,0 +1,99 @@
+/* Copyright 2020 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/>. */
+
+/* This tests GDB's handling of the DWARF is-stmt field in the line table.
+
+ This field is used when many addresses all represent the same source
+ line. The address(es) at which it is suitable to place a breakpoint for
+ a line are marked with is-stmt true, while address(es) that are not good
+ places to place a breakpoint are marked as is-stmt false.
+
+ In order to build a reproducible test and exercise GDB's is-stmt
+ support, we will be generating our own DWARF. The test will contain a
+ series of C source lines, ensuring that we get a series of assembler
+ instructions. Each C source line will be given an assembler label,
+ which we use to generate a fake line table.
+
+ In this fake line table each assembler block is claimed to represent a
+ single C source line, however, we will toggle the is-stmt flag. We can
+ then debug this with GDB and test the handling of is-stmt. */
+
+/* Used to insert labels with which we can build a fake line table. */
+#define LL(N) \
+ do \
+ { \
+ asm ("line_label_" #N ": .globl line_label_" #N); \
+ var = (N); \
+ bar = ((N) + 1); \
+ } \
+ while (0)
+
+volatile int var;
+volatile int bar;
+
+int
+main ()
+{ /* main prologue */
+ asm ("main_label: .globl main_label");
+
+ /* main start */
+
+ /* Line 1. */
+ /* Line 2. */
+ /* Line 3. */
+ /* Line 4. */
+ /* Line 5. */
+
+ LL (0);
+ LL (1);
+ LL (2);
+ LL (3);
+ LL (4);
+ LL (5);
+ LL (6);
+ LL (7);
+ LL (8);
+ LL (9);
+ LL (10);
+ LL (11);
+ LL (12);
+ LL (13);
+ LL (14);
+ LL (15);
+ LL (16);
+ return 0; /* main end */
+}
+
+#if 0
+
+PROLOGUE*
+1: L1
+2: L1*
+3: L2
+4: L1
+L3
+L4
+L4*
+L2*
+L2
+L3
+L5
+L5*
+L3
+L4
+L5
+RETURN
+
+#endif