gdb_interface.h 5.7 KB

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