]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dwarf2/dw2-ranges-func.c
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dw2-ranges-func.c
1 /* Copyright 2018-2019 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 /* The idea here is to, via use of the dwarf assembler, create a function
17 which occupies two non-contiguous address ranges.
18
19 foo_low and foo will be combined into a single function foo with a
20 function bar in between these two ranges.
21
22 This test case was motivated by a bug in which a function which
23 occupied two non-contiguous address ranges was calling another
24 function which resides in between these ranges. So we end up with
25 a situation in which the low/start address of our constructed foo
26 (in this case) will be less than any of the addresses in bar, but
27 the high/end address of foo will be greater than any of bar's
28 addresses.
29
30 This situation was causing a problem in the caching code of
31 find_pc_partial_function: When the low and high addresses of foo
32 are placed in the cache, the simple check that was used to see if
33 the cache was applicable would (incorrectly) succeed when presented
34 with an address in bar. I.e. an address in bar presented as an
35 input to find_pc_partial_function could produce the answer "this
36 address belongs to foo". */
37
38 volatile int e = 0;
39
40 void
41 baz (void)
42 {
43 asm ("baz_label: .globl baz_label");
44 } /* baz end */
45
46 void
47 foo_low (void)
48 { /* foo_low prologue */
49 asm ("foo_low_label: .globl foo_low_label");
50 baz (); /* foo_low baz call */
51 asm ("foo_low_label2: .globl foo_low_label2");
52 } /* foo_low end */
53
54 void
55 bar (void)
56 {
57 asm ("bar_label: .globl bar_label");
58 } /* bar end */
59
60 void
61 foo (void)
62 { /* foo prologue */
63 asm ("foo_label: .globl foo_label");
64 bar (); /* foo bar call */
65 asm ("foo_label2: .globl foo_label2");
66 if (e) foo_low (); /* foo foo_low call */
67 asm ("foo_label3: .globl foo_label3");
68 } /* foo end */
69
70 int
71 main (void)
72 { /* main prologue */
73 asm ("main_label: .globl main_label");
74 foo (); /* main foo call */
75 asm ("main_label2: .globl main_label2");
76 return 0; /* main return */
77 } /* main end */
78