dw2-inline-many-frames.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 sets up a call stack that looks like this:
  13. #11 #10 #9 #8 #7 #6 #5 #4 #3 #2 #1 #0
  14. main -> aaa -> bbb -> ccc -> ddd -> eee -> fff -> ggg -> hhh -> iii -> jjj -> kkk
  15. \_______________________/ \________/ \______________________/ \________/
  16. Inline sequence #1 Normal Inline sequence #2 Normal
  17. We use the 'start' command to move into main, after that we 'step'
  18. through each function until we are in kkk. We then use the 'up' command
  19. to look back at each from to main.
  20. The test checks that we can handle and step through sequences of more
  21. than one inline frame (so 'main .... ccc', and 'fff .... iii'), and also
  22. that we can move around in a stack that contains more than one disjoint
  23. sequence of inline frames.
  24. The order of the functions in this file is deliberately mixed up so that
  25. the line numbers are not "all ascending" or "all descending" in the line
  26. table. */
  27. #define INLINE_FUNCTION __attribute__ ((always_inline)) static inline
  28. #define NON_INLINE_FUNCTION __attribute__ ((noinline))
  29. volatile int global_var = 0;
  30. INLINE_FUNCTION int aaa ();
  31. INLINE_FUNCTION int bbb ();
  32. INLINE_FUNCTION int ccc ();
  33. NON_INLINE_FUNCTION int ddd ();
  34. NON_INLINE_FUNCTION int eee ();
  35. NON_INLINE_FUNCTION int fff ();
  36. INLINE_FUNCTION int ggg ();
  37. INLINE_FUNCTION int hhh ();
  38. INLINE_FUNCTION int iii ();
  39. NON_INLINE_FUNCTION int jjj ();
  40. NON_INLINE_FUNCTION int kkk ();
  41. INLINE_FUNCTION int
  42. aaa ()
  43. { /* aaa prologue */
  44. asm ("aaa_label: .globl aaa_label");
  45. return bbb () + 1; /* aaa return */
  46. } /* aaa end */
  47. NON_INLINE_FUNCTION int
  48. jjj ()
  49. { /* jjj prologue */
  50. int ans;
  51. asm ("jjj_label: .globl jjj_label");
  52. ans = kkk () + 1; /* jjj return */
  53. asm ("jjj_label2: .globl jjj_label2");
  54. return ans;
  55. } /* jjj end */
  56. INLINE_FUNCTION int
  57. ggg ()
  58. { /* ggg prologue */
  59. asm ("ggg_label: .globl ggg_label");
  60. return hhh () + 1; /* ggg return */
  61. } /* ggg end */
  62. INLINE_FUNCTION int
  63. ccc ()
  64. { /* ccc prologue */
  65. asm ("ccc_label: .globl ccc_label");
  66. return ddd () + 1; /* ccc return */
  67. } /* ccc end */
  68. NON_INLINE_FUNCTION int
  69. fff ()
  70. { /* fff prologue */
  71. int ans;
  72. asm ("fff_label: .globl fff_label");
  73. ans = ggg () + 1; /* fff return */
  74. asm ("fff_label2: .globl fff_label2");
  75. return ans;
  76. } /* fff end */
  77. NON_INLINE_FUNCTION int
  78. kkk ()
  79. { /* kkk prologue */
  80. asm ("kkk_label: .globl kkk_label");
  81. return global_var; /* kkk return */
  82. } /* kkk end */
  83. INLINE_FUNCTION int
  84. bbb ()
  85. { /* bbb prologue */
  86. asm ("bbb_label: .globl bbb_label");
  87. return ccc () + 1; /* bbb return */
  88. } /* bbb end */
  89. INLINE_FUNCTION int
  90. hhh ()
  91. { /* hhh prologue */
  92. asm ("hh_label: .globl hhh_label");
  93. return iii () + 1; /* hhh return */
  94. } /* hhh end */
  95. int
  96. main ()
  97. { /* main prologue */
  98. int ans;
  99. asm ("main_label: .globl main_label");
  100. global_var = 0; /* main set global_var */
  101. asm ("main_label2: .globl main_label2");
  102. ans = aaa () + 1; /* main call aaa */
  103. asm ("main_label3: .globl main_label3");
  104. return ans;
  105. } /* main end */
  106. NON_INLINE_FUNCTION int
  107. ddd ()
  108. { /* ddd prologue */
  109. int ans;
  110. asm ("ddd_label: .globl ddd_label");
  111. ans = eee () + 1; /* ddd return */
  112. asm ("ddd_label2: .globl ddd_label2");
  113. return ans;
  114. } /* ddd end */
  115. INLINE_FUNCTION int
  116. iii ()
  117. { /* iii prologue */
  118. int ans;
  119. asm ("iii_label: .globl iii_label");
  120. ans = jjj () + 1; /* iii return */
  121. asm ("iii_label2: .globl iii_label2");
  122. return ans;
  123. } /* iii end */
  124. NON_INLINE_FUNCTION int
  125. eee ()
  126. { /* eee prologue */
  127. int ans;
  128. asm ("eee_label: .globl eee_label");
  129. ans = fff () + 1; /* eee return */
  130. asm ("eee_label2: .globl eee_label2");
  131. return ans;
  132. } /* eee end */