Commit | Line | Data |
---|---|---|
c5867ab6 HZ |
1 | /* This testcase is part of GDB, the GNU debugger. |
2 | ||
42a4f53d | 3 | Copyright (C) 2013-2019 Free Software Foundation, Inc. |
c5867ab6 HZ |
4 | Contributed by Hui Zhu <hui@codesourcery.com> |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 3 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
18 | ||
19 | #include <stdio.h> | |
20 | #include <stdlib.h> | |
21 | ||
dedad4e3 PA |
22 | #include "../lib/unbuffer_output.c" |
23 | ||
c5867ab6 HZ |
24 | static int g; |
25 | ||
26 | void | |
27 | foo (int arg) | |
28 | { | |
29 | g += arg; | |
30 | g *= 2; /* set dprintf 1 here */ | |
31 | g /= 2.5; /* set breakpoint 1 here */ | |
32 | } | |
33 | ||
34 | int | |
35 | main (int argc, char *argv[]) | |
36 | { | |
37 | int loc = 1234; | |
38 | ||
dedad4e3 PA |
39 | gdb_unbuffer_output (); |
40 | ||
c5867ab6 HZ |
41 | /* Ensure these functions are available. */ |
42 | printf ("kickoff %d\n", loc); | |
43 | fprintf (stderr, "also to stderr %d\n", loc); | |
44 | ||
45 | foo (loc++); | |
46 | foo (loc++); | |
47 | foo (loc++); | |
48 | return g; | |
49 | } | |
50 | ||
51 | /* Make sure function 'malloc' is linked into program. On some bare-metal | |
52 | port, if we don't use 'malloc', it will not be linked in program. 'malloc' | |
53 | is needed, otherwise we'll see such error message | |
54 | evaluation of this expression requires the program to have a function | |
55 | "malloc". */ | |
56 | ||
57 | void | |
58 | bar (void) | |
59 | { | |
60 | void *p = malloc (16); | |
61 | ||
62 | free (p); | |
63 | } |