gdb_interface.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* Simple interpreter interface for GDB, the GNU debugger.
  2. Copyright (C) 1996, 2000 Free Software Foundation
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. The author can be reached at djurfeldt@nada.kth.se
  16. Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN */
  17. #ifndef GDB_INTERFACE_H
  18. #define GDB_INTERFACE_H
  19. /* This is the header file for GDB's interpreter interface. The
  20. interpreter must supply definitions of all symbols declared in this
  21. file.
  22. Before including this file, you must #define GDB_TYPE to be the
  23. data type used for communication with the interpreter. */
  24. /* The following macro can be used to anchor the symbols of the
  25. interface in your main program. This is necessary if the interface
  26. is defined in a library, such as Guile. */
  27. #define GDB_INTERFACE \
  28. void *gdb_interface[] = { \
  29. &gdb_options, \
  30. &gdb_language, \
  31. &gdb_result, \
  32. &gdb_output, \
  33. &gdb_output_length, \
  34. (void *) gdb_maybe_valid_type_p, \
  35. (void *) gdb_read, \
  36. (void *) gdb_eval, \
  37. (void *) gdb_print, \
  38. (void *) gdb_binding \
  39. }
  40. /* GDB_OPTIONS is a set of flags informing gdb what features are present
  41. in the interface. Currently only one option is supported: */
  42. /* GDB_HAVE_BINDINGS: Set this bit if your interpreter can create new
  43. top level bindings on demand (through gdb_top_level_binding) */
  44. #define GDB_HAVE_BINDINGS 1
  45. extern unsigned short gdb_options;
  46. /* GDB_LANGUAGE holds the name of the preferred language mode for this
  47. interpreter. For lisp interpreters, the suggested mode is "lisp/c". */
  48. extern char *gdb_language;
  49. /* GDB_RESULT is used for passing results from the interpreter to GDB */
  50. extern GDB_TYPE gdb_result;
  51. /* The interpreter passes strings to GDB in GDB_OUTPUT and
  52. GDB_OUTPUT_LENGTH. GDB_OUTPUT should hold the pointer to the
  53. string. GDB_OUTPUT_LENGTH should hold its length. The string
  54. doesn't need to be terminated by '\0'. */
  55. extern char *gdb_output;
  56. extern int gdb_output_length;
  57. /* Return TRUE if the interpreter regards VALUE's type as valid. A
  58. lazy implementation is allowed to pass TRUE always. FALSE should
  59. only be returned when it is certain that VALUE is not valid.
  60. In the "lisp/c" language mode, this is used to heuristically
  61. discriminate lisp values from C values during printing. */
  62. extern int gdb_maybe_valid_type_p (GDB_TYPE value);
  63. /* Parse expression in string STR. Store result in GDB_RESULT, then
  64. return 0 to indicate success. On error, return -1 to indicate
  65. failure. An error string can be passed in GDB_OUTPUT and
  66. GDB_OUTPUT_LENGTH. Be careful to set GDB_OUTPUT_LENGTH to zero if
  67. no message is passed. Please note that the resulting value should
  68. be protected against garbage collection. */
  69. extern int gdb_read (char *str);
  70. /* Evaluate expression EXP. Store result in GDB_RESULT, then return 0
  71. to indicate success. On error, return -1 to indicate failure. Any
  72. output (both on success and failure) can be passed in GDB_OUTPUT
  73. and GDB_OUTPUT_LENGTH. Be careful to set GDB_OUTPUT_LENGTH to zero
  74. if no output is passed. Please note that the resulting lisp object
  75. should be protected against garbage collection. */
  76. extern int gdb_eval (GDB_TYPE exp);
  77. /* Print VALUE. Store output in GDB_OUTPUT and GDB_OUTPUT_LENGTH.
  78. Return 0 to indicate success. On error, return -1 to indicate
  79. failure. GDB will not look at GDB_OUTPUT or GDB_OUTPUT_LENGTH on
  80. failure. Note that this function should be robust against strange
  81. values. It could in fact be passed any kind of value. */
  82. extern int gdb_print (GDB_TYPE value);
  83. /* Bind NAME to VALUE in interpreter. (GDB has previously obtained
  84. NAME by passing a string to gdb_read.) Return 0 to indicate
  85. success or -1 to indicate failure. This feature is optional. GDB
  86. will only call this function if the GDB_HAVE_BINDINGS flag is set
  87. in gdb_options. Note that GDB may call this function many times
  88. for the same name.
  89. For scheme interpreters, this function should introduce top-level
  90. bindings. */
  91. extern int gdb_binding (GDB_TYPE name, GDB_TYPE value);
  92. #endif /* GDB_INTERFACE_H */
  93. /*
  94. Local Variables:
  95. c-file-style: "gnu"
  96. End:
  97. */