Home | History | Annotate | Line # | Download | only in gdb.dwarf2
      1  1.1.1.3  christos /* Copyright 2020-2024 Free Software Foundation, Inc.
      2      1.1  christos 
      3      1.1  christos    This program is free software; you can redistribute it and/or modify
      4      1.1  christos    it under the terms of the GNU General Public License as published by
      5      1.1  christos    the Free Software Foundation; either version 3 of the License, or
      6      1.1  christos    (at your option) any later version.
      7      1.1  christos 
      8      1.1  christos    This program is distributed in the hope that it will be useful,
      9      1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     10      1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11      1.1  christos    GNU General Public License for more details.
     12      1.1  christos 
     13      1.1  christos    You should have received a copy of the GNU General Public License
     14      1.1  christos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     15      1.1  christos 
     16      1.1  christos /* This tests GDB's handling of the DWARF is-stmt field in the line table.
     17      1.1  christos 
     18      1.1  christos    This field is used when many addresses all represent the same source
     19      1.1  christos    line.  The address(es) at which it is suitable to place a breakpoint for
     20      1.1  christos    a line are marked with is-stmt true, while address(es) that are not good
     21      1.1  christos    places to place a breakpoint are marked as is-stmt false.
     22      1.1  christos 
     23      1.1  christos    In order to build a reproducible test and exercise GDB's is-stmt
     24      1.1  christos    support, we will be generating our own DWARF.  The test will contain a
     25      1.1  christos    series of C source lines, ensuring that we get a series of assembler
     26      1.1  christos    instructions.  Each C source line will be given an assembler label,
     27      1.1  christos    which we use to generate a fake line table.
     28      1.1  christos 
     29      1.1  christos    In this fake line table each assembler block is claimed to represent a
     30      1.1  christos    single C source line, however, we will toggle the is-stmt flag.  We can
     31      1.1  christos    then debug this with GDB and test the handling of is-stmt.  */
     32      1.1  christos 
     33      1.1  christos /* Used to insert labels with which we can build a fake line table.  */
     34      1.1  christos #define LL(N)						\
     35      1.1  christos   do							\
     36      1.1  christos     {							\
     37      1.1  christos       asm ("line_label_" #N ": .globl line_label_" #N); \
     38      1.1  christos       var = (N);					\
     39      1.1  christos       bar = ((N) + 1);					\
     40      1.1  christos     }							\
     41      1.1  christos   while (0)
     42      1.1  christos 
     43      1.1  christos volatile int var;
     44      1.1  christos volatile int bar;
     45      1.1  christos 
     46      1.1  christos int
     47      1.1  christos main ()
     48      1.1  christos {					/* main prologue */
     49      1.1  christos   asm ("main_label: .globl main_label");
     50      1.1  christos 
     51      1.1  christos   /* main start */
     52      1.1  christos 
     53      1.1  christos   /* Line 1.  */
     54      1.1  christos   /* Line 2.  */
     55      1.1  christos   /* Line 3.  */
     56      1.1  christos   /* Line 4.  */
     57      1.1  christos   /* Line 5.  */
     58      1.1  christos 
     59      1.1  christos   LL (0);
     60      1.1  christos   LL (1);
     61      1.1  christos   LL (2);
     62      1.1  christos   LL (3);
     63      1.1  christos   LL (4);
     64      1.1  christos   LL (5);
     65      1.1  christos   LL (6);
     66      1.1  christos   LL (7);
     67      1.1  christos   LL (8);
     68      1.1  christos   LL (9);
     69      1.1  christos   LL (10);
     70      1.1  christos   LL (11);
     71      1.1  christos   LL (12);
     72      1.1  christos   LL (13);
     73      1.1  christos   LL (14);
     74      1.1  christos   LL (15);
     75      1.1  christos   LL (16);
     76      1.1  christos   return 0;				/* main end */
     77      1.1  christos }
     78      1.1  christos 
     79      1.1  christos #if 0
     80      1.1  christos 
     81      1.1  christos PROLOGUE*
     82      1.1  christos 1: L1
     83      1.1  christos 2: L1*
     84      1.1  christos 3: L2
     85      1.1  christos 4: L1
     86      1.1  christos L3
     87      1.1  christos L4
     88      1.1  christos L4*
     89      1.1  christos L2*
     90      1.1  christos L2
     91      1.1  christos L3
     92      1.1  christos L5
     93      1.1  christos L5*
     94      1.1  christos L3
     95      1.1  christos L4
     96      1.1  christos L5
     97      1.1  christos RETURN
     98      1.1  christos 
     99      1.1  christos #endif
    100