Commit | Line | Data |
---|---|---|
ecd75fc8 | 1 | /* Copyright 2013-2014 Free Software Foundation, Inc. |
681f229a NB |
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 | ||
7 | This program is distributed in the hope that it will be useful, | |
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
10 | GNU General Public License for more details. | |
11 | ||
12 | You should have received a copy of the GNU General Public License | |
13 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
14 | */ | |
15 | ||
16 | #include <stdlib.h> | |
17 | #include <stdio.h> | |
18 | ||
19 | #include "sym-file-loader.h" | |
20 | ||
21 | void | |
22 | gdb_add_symbol_file (void *addr, const char *file) | |
23 | { | |
24 | return; | |
25 | } | |
26 | ||
27 | void | |
28 | gdb_remove_symbol_file (void *addr) | |
29 | { | |
30 | return; | |
31 | } | |
32 | ||
33 | /* Load a shared library without relying on the standard | |
34 | loader to test GDB's commands for adding and removing | |
35 | symbol files at runtime. */ | |
36 | ||
37 | int | |
38 | main (int argc, const char *argv[]) | |
39 | { | |
40 | const char *file = SHLIB_NAME; | |
35e5d2f0 | 41 | struct library *lib; |
681f229a NB |
42 | char *text_addr = NULL; |
43 | int (*pbar) () = NULL; | |
44 | int (*pfoo) (int) = NULL; | |
45 | ||
35e5d2f0 PA |
46 | lib = load_shlib (file); |
47 | if (lib == NULL) | |
48 | return 1; | |
681f229a | 49 | |
35e5d2f0 PA |
50 | if (get_text_addr (lib, (void **) &text_addr) != 0) |
51 | return 1; | |
681f229a NB |
52 | |
53 | gdb_add_symbol_file (text_addr, file); | |
54 | ||
55 | /* Call bar from SHLIB_NAME. */ | |
35e5d2f0 PA |
56 | if (lookup_function (lib, "bar", (void *) &pbar) != 0) |
57 | return 1; | |
681f229a NB |
58 | |
59 | (*pbar) (); | |
60 | ||
61 | /* Call foo from SHLIB_NAME. */ | |
35e5d2f0 PA |
62 | if (lookup_function (lib, "foo", (void *) &pfoo) != 0) |
63 | return 1; | |
681f229a NB |
64 | |
65 | (*pfoo) (2); | |
66 | ||
67 | /* Notify GDB to remove the symbol file. */ | |
68 | gdb_remove_symbol_file (text_addr); | |
69 | ||
70 | return 0; | |
71 | } |