Commit | Line | Data |
---|---|---|
504388eb MD |
1 | /* Simple interpreter interface for GDB, the GNU debugger. |
2 | Copyright (C) 1996 Mikael Djurfeldt. | |
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 | ||
20 | The author can be reached at djurfeldt@nada.kth.se | |
21 | Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN */ | |
22 | ||
23 | /* This is the header file for GDB's interpreter interface. The | |
24 | interpreter must supply definitions of all symbols declared in this | |
25 | file. | |
26 | ||
27 | Before including this file, you must #define GDB_TYPE to be the | |
28 | data type used for communication with the interpreter. */ | |
29 | ||
30 | /* The following macro can be used to anchor the symbols of the | |
31 | interface in your main program. This is necessary if the interface | |
32 | is defined in a library, such as Guile. */ | |
33 | ||
34 | #define GDB_INTERFACE \ | |
35 | void *gdb_interface[] = { \ | |
36 | &gdb_options, \ | |
37 | &gdb_language, \ | |
38 | &gdb_result, \ | |
39 | &gdb_output, \ | |
40 | &gdb_output_length, \ | |
41 | gdb_maybe_valid_type_p, \ | |
42 | gdb_read, \ | |
43 | gdb_eval, \ | |
44 | gdb_print, \ | |
45 | gdb_binding \ | |
46 | }; \ | |
47 | ||
48 | ||
49 | /* GDB_OPTIONS is a set of flags informing gdb what features are present | |
50 | in the interface. Currently only one option is supported: */ | |
51 | ||
52 | /* GDB_HAVE_BINDINGS: Set this bit if your interpreter can create new | |
53 | top level bindings on demand (through gdb_top_level_binding) */ | |
54 | ||
55 | #define GDB_HAVE_BINDINGS 1 | |
56 | ||
57 | extern unsigned short gdb_options; | |
58 | ||
59 | /* GDB_LANGUAGE holds the name of the preferred language mode for this | |
60 | interpreter. For lisp interpreters, the suggested mode is "lisp/c". */ | |
61 | ||
62 | extern char *gdb_language; | |
63 | ||
64 | /* GDB_RESULT is used for passing results from the interpreter to GDB */ | |
65 | ||
66 | extern GDB_TYPE gdb_result; | |
67 | ||
68 | /* The interpreter passes strings to GDB in GDB_OUTPUT and | |
69 | GDB_OUTPUT_LENGTH. GDB_OUTPUT should hold the pointer to the | |
70 | string. GDB_OUTPUT_LENGTH should hold its length. The string | |
71 | doesn't need to be terminated by '\0'. */ | |
72 | ||
73 | extern char *gdb_output; | |
74 | ||
75 | extern int gdb_output_length; | |
76 | ||
77 | #ifdef __STDC__ | |
78 | ||
79 | /* Return TRUE if the interpreter regards VALUE's type as valid. A | |
80 | lazy implementation is allowed to pass TRUE always. FALSE should | |
81 | only be returned when it is certain that VALUE is not valid. | |
82 | ||
83 | In the "lisp/c" language mode, this is used to heuristically | |
84 | discriminate lisp values from C values during printing. */ | |
85 | ||
86 | extern int gdb_maybe_valid_type_p (GDB_TYPE value); | |
87 | ||
88 | /* Parse expression in string STR. Store result in GDB_RESULT, then | |
89 | return 0 to indicate success. On error, return -1 to indicate | |
90 | failure. An error string can be passed in GDB_OUTPUT and | |
91 | GDB_OUTPUT_LENGTH. Be careful to set GDB_OUTPUT_LENGTH to zero if | |
92 | no message is passed. Please note that the resulting value should | |
93 | be protected against garbage collection. */ | |
94 | ||
95 | extern int gdb_read (char *str); | |
96 | ||
97 | /* Evaluate expression EXP. Store result in GDB_RESULT, then return 0 | |
98 | to indicate success. On error, return -1 to indicate failure. Any | |
99 | output (both on success and failure) can be passed in GDB_OUTPUT | |
100 | and GDB_OUTPUT_LENGTH. Be careful to set GDB_OUTPUT_LENGTH to zero | |
101 | if no output is passed. Please note that the resulting lisp object | |
102 | should be protected against garbage collection. */ | |
103 | ||
104 | extern int gdb_eval (GDB_TYPE exp); | |
105 | ||
106 | /* Print VALUE. Store output in GDB_OUTPUT and GDB_OUTPUT_LENGTH. | |
107 | Return 0 to indicate success. On error, return -1 to indicate | |
108 | failure. GDB will not look at GDB_OUTPUT or GDB_OUTPUT_LENGTH on | |
109 | failure. Note that this function should be robust against strange | |
110 | values. It could in fact be passed any kind of value. */ | |
111 | ||
112 | extern int gdb_print (GDB_TYPE value); | |
113 | ||
114 | /* Bind NAME to VALUE in interpreter. (GDB has previously obtained | |
115 | NAME by passing a string to gdb_read.) Return 0 to indicate | |
116 | success or -1 to indicate failure. This feature is optional. GDB | |
117 | will only call this function if the GDB_HAVE_BINDINGS flag is set | |
118 | in gdb_options. Note that GDB may call this function many times | |
119 | for the same name. | |
120 | ||
121 | For scheme interpreters, this function should introduce top-level | |
122 | bindings. */ | |
123 | ||
124 | extern int gdb_binding (GDB_TYPE name, GDB_TYPE value); | |
125 | ||
126 | #else | |
127 | ||
128 | extern int gdb_maybe_valid_type_p (); | |
129 | ||
130 | extern int gdb_read (); | |
131 | ||
132 | extern int gdb_eval (); | |
133 | ||
134 | extern int gdb_print (); | |
135 | ||
136 | extern int gdb_binding (); | |
137 | ||
138 | #endif /* __STDC__ */ |