Commit | Line | Data |
---|---|---|
0527e687 DH |
1 | /* classes: h_files */ |
2 | ||
3 | #ifndef GDB_INTERFACE_H | |
4 | #define GDB_INTERFACE_H | |
504388eb | 5 | /* Simple interpreter interface for GDB, the GNU debugger. |
2b829bbb | 6 | Copyright (C) 1996, 2000, 2001, 2006 Free Software Foundation |
504388eb | 7 | |
53befeb7 NJ |
8 | * This library is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU Lesser General Public License | |
10 | * as published by the Free Software Foundation; either version 3 of | |
11 | * the License, or (at your option) any later version. | |
12 | * | |
13 | * This library is distributed in the hope that it will be useful, but | |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * Lesser General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU Lesser General Public | |
19 | * License along with this library; if not, write to the Free Software | |
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | |
21 | * 02110-1301 USA | |
c22adbeb | 22 | |
504388eb MD |
23 | The author can be reached at djurfeldt@nada.kth.se |
24 | Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN */ | |
25 | ||
26 | /* This is the header file for GDB's interpreter interface. The | |
27 | interpreter must supply definitions of all symbols declared in this | |
28 | file. | |
29 | ||
30 | Before including this file, you must #define GDB_TYPE to be the | |
31 | data type used for communication with the interpreter. */ | |
32 | ||
33 | /* The following macro can be used to anchor the symbols of the | |
34 | interface in your main program. This is necessary if the interface | |
35 | is defined in a library, such as Guile. */ | |
36 | ||
c01a6af5 | 37 | #if !defined (__MINGW32__) && !defined (__CYGWIN__) |
504388eb MD |
38 | #define GDB_INTERFACE \ |
39 | void *gdb_interface[] = { \ | |
40 | &gdb_options, \ | |
41 | &gdb_language, \ | |
42 | &gdb_result, \ | |
43 | &gdb_output, \ | |
44 | &gdb_output_length, \ | |
01c77a0a MD |
45 | (void *) gdb_maybe_valid_type_p, \ |
46 | (void *) gdb_read, \ | |
47 | (void *) gdb_eval, \ | |
48 | (void *) gdb_print, \ | |
49 | (void *) gdb_binding \ | |
8f9dc614 | 50 | } |
c01a6af5 | 51 | #else /* __MINGW32__, __CYGWIN__ */ |
82893676 MG |
52 | /* Because the following functions are imported from a DLL (some kind of |
53 | shared library) these are NO static initializers. That is why you need to | |
54 | define them and assign the functions and data items at run time. */ | |
55 | #define GDB_INTERFACE \ | |
56 | void *gdb_interface[] = \ | |
57 | { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; | |
58 | #define GDB_INTERFACE_INIT \ | |
59 | do { \ | |
60 | gdb_interface[0] = &gdb_options; \ | |
61 | gdb_interface[1] = &gdb_language; \ | |
62 | gdb_interface[2] = &gdb_result; \ | |
63 | gdb_interface[3] = &gdb_output; \ | |
64 | gdb_interface[4] = &gdb_output_length; \ | |
65 | gdb_interface[5] = (void *) gdb_maybe_valid_type_p; \ | |
66 | gdb_interface[6] = (void *) gdb_read; \ | |
67 | gdb_interface[7] = (void *) gdb_eval; \ | |
68 | gdb_interface[8] = (void *) gdb_print; \ | |
69 | gdb_interface[9] = (void *) gdb_binding; \ | |
70 | } while (0); | |
71 | #endif /* __MINGW32__ */ | |
504388eb MD |
72 | |
73 | /* GDB_OPTIONS is a set of flags informing gdb what features are present | |
74 | in the interface. Currently only one option is supported: */ | |
75 | ||
76 | /* GDB_HAVE_BINDINGS: Set this bit if your interpreter can create new | |
77 | top level bindings on demand (through gdb_top_level_binding) */ | |
78 | ||
79 | #define GDB_HAVE_BINDINGS 1 | |
80 | ||
c01a6af5 | 81 | SCM_API unsigned short gdb_options; |
504388eb MD |
82 | |
83 | /* GDB_LANGUAGE holds the name of the preferred language mode for this | |
84 | interpreter. For lisp interpreters, the suggested mode is "lisp/c". */ | |
85 | ||
c01a6af5 | 86 | SCM_API char *gdb_language; |
504388eb MD |
87 | |
88 | /* GDB_RESULT is used for passing results from the interpreter to GDB */ | |
89 | ||
c01a6af5 | 90 | SCM_API GDB_TYPE gdb_result; |
504388eb MD |
91 | |
92 | /* The interpreter passes strings to GDB in GDB_OUTPUT and | |
93 | GDB_OUTPUT_LENGTH. GDB_OUTPUT should hold the pointer to the | |
94 | string. GDB_OUTPUT_LENGTH should hold its length. The string | |
95 | doesn't need to be terminated by '\0'. */ | |
96 | ||
c01a6af5 | 97 | SCM_API char *gdb_output; |
504388eb | 98 | |
c01a6af5 | 99 | SCM_API int gdb_output_length; |
504388eb | 100 | |
504388eb MD |
101 | /* Return TRUE if the interpreter regards VALUE's type as valid. A |
102 | lazy implementation is allowed to pass TRUE always. FALSE should | |
103 | only be returned when it is certain that VALUE is not valid. | |
104 | ||
105 | In the "lisp/c" language mode, this is used to heuristically | |
106 | discriminate lisp values from C values during printing. */ | |
107 | ||
c01a6af5 | 108 | SCM_API int gdb_maybe_valid_type_p (GDB_TYPE value); |
504388eb MD |
109 | |
110 | /* Parse expression in string STR. Store result in GDB_RESULT, then | |
111 | return 0 to indicate success. On error, return -1 to indicate | |
112 | failure. An error string can be passed in GDB_OUTPUT and | |
113 | GDB_OUTPUT_LENGTH. Be careful to set GDB_OUTPUT_LENGTH to zero if | |
114 | no message is passed. Please note that the resulting value should | |
115 | be protected against garbage collection. */ | |
116 | ||
c01a6af5 | 117 | SCM_API int gdb_read (char *str); |
504388eb MD |
118 | |
119 | /* Evaluate expression EXP. Store result in GDB_RESULT, then return 0 | |
120 | to indicate success. On error, return -1 to indicate failure. Any | |
121 | output (both on success and failure) can be passed in GDB_OUTPUT | |
122 | and GDB_OUTPUT_LENGTH. Be careful to set GDB_OUTPUT_LENGTH to zero | |
123 | if no output is passed. Please note that the resulting lisp object | |
124 | should be protected against garbage collection. */ | |
125 | ||
c01a6af5 | 126 | SCM_API int gdb_eval (GDB_TYPE exp); |
504388eb MD |
127 | |
128 | /* Print VALUE. Store output in GDB_OUTPUT and GDB_OUTPUT_LENGTH. | |
129 | Return 0 to indicate success. On error, return -1 to indicate | |
130 | failure. GDB will not look at GDB_OUTPUT or GDB_OUTPUT_LENGTH on | |
131 | failure. Note that this function should be robust against strange | |
132 | values. It could in fact be passed any kind of value. */ | |
133 | ||
c01a6af5 | 134 | SCM_API int gdb_print (GDB_TYPE value); |
504388eb MD |
135 | |
136 | /* Bind NAME to VALUE in interpreter. (GDB has previously obtained | |
137 | NAME by passing a string to gdb_read.) Return 0 to indicate | |
138 | success or -1 to indicate failure. This feature is optional. GDB | |
139 | will only call this function if the GDB_HAVE_BINDINGS flag is set | |
140 | in gdb_options. Note that GDB may call this function many times | |
141 | for the same name. | |
142 | ||
143 | For scheme interpreters, this function should introduce top-level | |
144 | bindings. */ | |
145 | ||
c01a6af5 | 146 | SCM_API int gdb_binding (GDB_TYPE name, GDB_TYPE value); |
504388eb | 147 | |
0527e687 | 148 | #endif /* GDB_INTERFACE_H */ |
89e00824 ML |
149 | |
150 | /* | |
151 | Local Variables: | |
152 | c-file-style: "gnu" | |
153 | End: | |
154 | */ |