Commit | Line | Data |
---|---|---|
504388eb | 1 | /* Simple interpreter interface for GDB, the GNU debugger. |
f2c9fcb0 | 2 | Copyright (C) 1996, 2000 Free Software Foundation |
504388eb MD |
3 | |
4 | This file is part of GDB. | |
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 2 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, write to the Free Software | |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
19 | ||
c22adbeb MV |
20 | As a special exception, the Free Software Foundation gives permission |
21 | for additional uses of the text contained in its release of GUILE. | |
22 | ||
23 | The exception is that, if you link the GUILE library with other files | |
24 | to produce an executable, this does not by itself cause the | |
25 | resulting executable to be covered by the GNU General Public License. | |
26 | Your use of that executable is in no way restricted on account of | |
27 | linking the GUILE library code into it. | |
28 | ||
29 | This exception does not however invalidate any other reasons why | |
30 | the executable file might be covered by the GNU General Public License. | |
31 | ||
32 | This exception applies only to the code released by the | |
33 | Free Software Foundation under the name GUILE. If you copy | |
34 | code from other Free Software Foundation releases into a copy of | |
35 | GUILE, as the General Public License permits, the exception does | |
36 | not apply to the code that you add in this way. To avoid misleading | |
37 | anyone as to the status of such modified files, you must delete | |
38 | this exception notice from them. | |
39 | ||
40 | If you write modifications of your own for GUILE, it is your choice | |
41 | whether to permit this exception to apply to your modifications. | |
42 | If you do not wish that, delete this exception notice. | |
43 | ||
504388eb MD |
44 | The author can be reached at djurfeldt@nada.kth.se |
45 | Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN */ | |
46 | ||
1717856b JB |
47 | #ifndef GDB_INTERFACE_H |
48 | #define GDB_INTERFACE_H | |
49 | ||
504388eb MD |
50 | /* This is the header file for GDB's interpreter interface. The |
51 | interpreter must supply definitions of all symbols declared in this | |
52 | file. | |
53 | ||
54 | Before including this file, you must #define GDB_TYPE to be the | |
55 | data type used for communication with the interpreter. */ | |
56 | ||
57 | /* The following macro can be used to anchor the symbols of the | |
58 | interface in your main program. This is necessary if the interface | |
59 | is defined in a library, such as Guile. */ | |
60 | ||
82893676 | 61 | #ifndef __MINGW32__ |
504388eb MD |
62 | #define GDB_INTERFACE \ |
63 | void *gdb_interface[] = { \ | |
64 | &gdb_options, \ | |
65 | &gdb_language, \ | |
66 | &gdb_result, \ | |
67 | &gdb_output, \ | |
68 | &gdb_output_length, \ | |
01c77a0a MD |
69 | (void *) gdb_maybe_valid_type_p, \ |
70 | (void *) gdb_read, \ | |
71 | (void *) gdb_eval, \ | |
72 | (void *) gdb_print, \ | |
73 | (void *) gdb_binding \ | |
8f9dc614 | 74 | } |
82893676 MG |
75 | #else /* __MINGW32__ */ |
76 | /* Because the following functions are imported from a DLL (some kind of | |
77 | shared library) these are NO static initializers. That is why you need to | |
78 | define them and assign the functions and data items at run time. */ | |
79 | #define GDB_INTERFACE \ | |
80 | void *gdb_interface[] = \ | |
81 | { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; | |
82 | #define GDB_INTERFACE_INIT \ | |
83 | do { \ | |
84 | gdb_interface[0] = &gdb_options; \ | |
85 | gdb_interface[1] = &gdb_language; \ | |
86 | gdb_interface[2] = &gdb_result; \ | |
87 | gdb_interface[3] = &gdb_output; \ | |
88 | gdb_interface[4] = &gdb_output_length; \ | |
89 | gdb_interface[5] = (void *) gdb_maybe_valid_type_p; \ | |
90 | gdb_interface[6] = (void *) gdb_read; \ | |
91 | gdb_interface[7] = (void *) gdb_eval; \ | |
92 | gdb_interface[8] = (void *) gdb_print; \ | |
93 | gdb_interface[9] = (void *) gdb_binding; \ | |
94 | } while (0); | |
95 | #endif /* __MINGW32__ */ | |
504388eb MD |
96 | |
97 | /* GDB_OPTIONS is a set of flags informing gdb what features are present | |
98 | in the interface. Currently only one option is supported: */ | |
99 | ||
100 | /* GDB_HAVE_BINDINGS: Set this bit if your interpreter can create new | |
101 | top level bindings on demand (through gdb_top_level_binding) */ | |
102 | ||
103 | #define GDB_HAVE_BINDINGS 1 | |
104 | ||
105 | extern unsigned short gdb_options; | |
106 | ||
107 | /* GDB_LANGUAGE holds the name of the preferred language mode for this | |
108 | interpreter. For lisp interpreters, the suggested mode is "lisp/c". */ | |
109 | ||
110 | extern char *gdb_language; | |
111 | ||
112 | /* GDB_RESULT is used for passing results from the interpreter to GDB */ | |
113 | ||
114 | extern GDB_TYPE gdb_result; | |
115 | ||
116 | /* The interpreter passes strings to GDB in GDB_OUTPUT and | |
117 | GDB_OUTPUT_LENGTH. GDB_OUTPUT should hold the pointer to the | |
118 | string. GDB_OUTPUT_LENGTH should hold its length. The string | |
119 | doesn't need to be terminated by '\0'. */ | |
120 | ||
121 | extern char *gdb_output; | |
122 | ||
123 | extern int gdb_output_length; | |
124 | ||
504388eb MD |
125 | /* Return TRUE if the interpreter regards VALUE's type as valid. A |
126 | lazy implementation is allowed to pass TRUE always. FALSE should | |
127 | only be returned when it is certain that VALUE is not valid. | |
128 | ||
129 | In the "lisp/c" language mode, this is used to heuristically | |
130 | discriminate lisp values from C values during printing. */ | |
131 | ||
7866a09b | 132 | extern int gdb_maybe_valid_type_p (GDB_TYPE value); |
504388eb MD |
133 | |
134 | /* Parse expression in string STR. Store result in GDB_RESULT, then | |
135 | return 0 to indicate success. On error, return -1 to indicate | |
136 | failure. An error string can be passed in GDB_OUTPUT and | |
137 | GDB_OUTPUT_LENGTH. Be careful to set GDB_OUTPUT_LENGTH to zero if | |
138 | no message is passed. Please note that the resulting value should | |
139 | be protected against garbage collection. */ | |
140 | ||
7866a09b | 141 | extern int gdb_read (char *str); |
504388eb MD |
142 | |
143 | /* Evaluate expression EXP. Store result in GDB_RESULT, then return 0 | |
144 | to indicate success. On error, return -1 to indicate failure. Any | |
145 | output (both on success and failure) can be passed in GDB_OUTPUT | |
146 | and GDB_OUTPUT_LENGTH. Be careful to set GDB_OUTPUT_LENGTH to zero | |
147 | if no output is passed. Please note that the resulting lisp object | |
148 | should be protected against garbage collection. */ | |
149 | ||
7866a09b | 150 | extern int gdb_eval (GDB_TYPE exp); |
504388eb MD |
151 | |
152 | /* Print VALUE. Store output in GDB_OUTPUT and GDB_OUTPUT_LENGTH. | |
153 | Return 0 to indicate success. On error, return -1 to indicate | |
154 | failure. GDB will not look at GDB_OUTPUT or GDB_OUTPUT_LENGTH on | |
155 | failure. Note that this function should be robust against strange | |
156 | values. It could in fact be passed any kind of value. */ | |
157 | ||
7866a09b | 158 | extern int gdb_print (GDB_TYPE value); |
504388eb MD |
159 | |
160 | /* Bind NAME to VALUE in interpreter. (GDB has previously obtained | |
161 | NAME by passing a string to gdb_read.) Return 0 to indicate | |
162 | success or -1 to indicate failure. This feature is optional. GDB | |
163 | will only call this function if the GDB_HAVE_BINDINGS flag is set | |
164 | in gdb_options. Note that GDB may call this function many times | |
165 | for the same name. | |
166 | ||
167 | For scheme interpreters, this function should introduce top-level | |
168 | bindings. */ | |
169 | ||
7866a09b | 170 | extern int gdb_binding (GDB_TYPE name, GDB_TYPE value); |
504388eb | 171 | |
1717856b | 172 | #endif /* GDB_INTERFACE_H */ |
89e00824 ML |
173 | |
174 | /* | |
175 | Local Variables: | |
176 | c-file-style: "gnu" | |
177 | End: | |
178 | */ |