Home | History | Annotate | Line # | Download | only in gdb.dwarf2
      1 /* Copyright 2019-2024 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 test relies on foo being inlined into main and bar not being
     17    inlined.  The test is checking GDB's behavior as we single step from
     18    main through foo and into bar.  */
     19 
     20 volatile int global_var;
     21 
     22 int  __attribute__ ((noinline))
     23 bar ()
     24 {						/* bar prologue */
     25   asm ("bar_label: .globl bar_label");
     26   return global_var;				/* bar return global_var */
     27 }						/* bar end */
     28 
     29 static inline int __attribute__ ((always_inline))
     30 foo ()
     31 {						/* foo prologue */
     32   return bar ();				/* foo call bar */
     33 }						/* foo end */
     34 
     35 int
     36 main ()
     37 {						/* main prologue */
     38   int ans;
     39   asm ("main_label: .globl main_label");
     40   global_var = 0;				/* main set global_var */
     41   asm ("main_label2: .globl main_label2");
     42   ans = foo ();					/* main call foo */
     43   asm ("main_label3: .globl main_label3");
     44   return ans;
     45 }						/* main end */
     46