dw2-inline-stepping.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* Copyright 2019-2022 Free Software Foundation, Inc.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; either version 3 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  12. /* This test relies on foo being inlined into main and bar not being
  13. inlined. The test is checking GDB's behaviour as we single step from
  14. main through foo and into bar. */
  15. volatile int global_var;
  16. int __attribute__ ((noinline))
  17. bar ()
  18. { /* bar prologue */
  19. asm ("bar_label: .globl bar_label");
  20. return global_var; /* bar return global_var */
  21. } /* bar end */
  22. static inline int __attribute__ ((always_inline))
  23. foo ()
  24. { /* foo prologue */
  25. return bar (); /* foo call bar */
  26. } /* foo end */
  27. int
  28. main ()
  29. { /* main prologue */
  30. int ans;
  31. asm ("main_label: .globl main_label");
  32. global_var = 0; /* main set global_var */
  33. asm ("main_label2: .globl main_label2");
  34. ans = foo (); /* main call foo */
  35. asm ("main_label3: .globl main_label3");
  36. return ans;
  37. } /* main end */