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