gdb/extension.h - gdb

Global variables defined

Data types defined

Macros defined

Source code

  1. /* Interface between gdb and its extension languages.

  2.    Copyright (C) 2014-2015 Free Software Foundation, Inc.

  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 3 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, see <http://www.gnu.org/licenses/>.  */

  14. #ifndef EXTENSION_H
  15. #define EXTENSION_H

  16. #include "mi/mi-cmds.h" /* For PRINT_NO_VALUES, etc.  */
  17. #include "common/vec.h"

  18. struct breakpoint;
  19. struct command_line;
  20. struct frame_info;
  21. struct language_defn;
  22. struct objfile;
  23. struct extension_language_defn;
  24. struct type;
  25. struct ui_file;
  26. struct ui_out;
  27. struct value;
  28. struct value_print_options;

  29. /* A function to load and process a script file.
  30.    The file has been opened and is ready to be read from the beginning.
  31.    Any exceptions are not caught, and are passed to the caller.  */
  32. typedef void script_sourcer_func (const struct extension_language_defn *,
  33.                                   FILE *stream, const char *filename);

  34. /* A function to load and process a script for an objfile.
  35.    The file has been opened and is ready to be read from the beginning.
  36.    Any exceptions are not caught, and are passed to the caller.  */
  37. typedef void objfile_script_sourcer_func
  38.   (const struct extension_language_defn *,
  39.    struct objfile *, FILE *stream, const char *filename);

  40. /* Enum of each extension(/scripting) language.  */

  41. enum extension_language
  42.   {
  43.     EXT_LANG_NONE,
  44.     EXT_LANG_GDB,
  45.     EXT_LANG_PYTHON,
  46.     EXT_LANG_GUILE
  47.   };

  48. /* Extension language frame-filter status return values.  */

  49. enum ext_lang_bt_status
  50.   {
  51.     /* Return when an error has occurred in processing frame filters,
  52.        or when printing the stack.  */
  53.     EXT_LANG_BT_ERROR = -1,

  54.     /* Return from internal routines to indicate that the function
  55.        succeeded.  */
  56.     EXT_LANG_BT_OK = 1,

  57.     /* Return when the frame filter process is complete, and all
  58.        operations have succeeded.  */
  59.     EXT_LANG_BT_COMPLETED = 2,

  60.     /* Return when the frame filter process is complete, but there
  61.        were no filter registered and enabled to process.  */
  62.     EXT_LANG_BT_NO_FILTERS = 3
  63.   };

  64. /* Flags to pass to apply_extlang_frame_filter.  */

  65. enum frame_filter_flags
  66.   {
  67.     /* Set this flag if frame level is to be printed.  */
  68.     PRINT_LEVEL = 1,

  69.     /* Set this flag if frame information is to be printed.  */
  70.     PRINT_FRAME_INFO = 2,

  71.     /* Set this flag if frame arguments are to be printed.  */
  72.     PRINT_ARGS = 4,

  73.     /* Set this flag if frame locals are to be printed.  */
  74.     PRINT_LOCALS = 8,
  75.   };

  76. /* A choice of the different frame argument printing strategies that
  77.    can occur in different cases of frame filter instantiation.  */

  78. enum ext_lang_frame_args
  79.   {
  80.     /* Print no values for arguments when invoked from the MI. */
  81.     NO_VALUES = PRINT_NO_VALUES,

  82.     MI_PRINT_ALL_VALUES = PRINT_ALL_VALUES,

  83.     /* Print only simple values (what MI defines as "simple") for
  84.        arguments when invoked from the MI. */
  85.     MI_PRINT_SIMPLE_VALUES = PRINT_SIMPLE_VALUES,

  86.     /* Print only scalar values for arguments when invoked from the CLI. */
  87.     CLI_SCALAR_VALUES,

  88.     /* Print all values for arguments when invoked from the CLI. */
  89.     CLI_ALL_VALUES
  90.   };

  91. /* The possible results of
  92.    extension_language_ops.breakpoint_cond_says_stop.  */

  93. enum ext_lang_bp_stop
  94.   {
  95.     /* No "stop" condition is set.  */
  96.     EXT_LANG_BP_STOP_UNSET,

  97.     /* A "stop" condition is set, and it says "don't stop".  */
  98.     EXT_LANG_BP_STOP_NO,

  99.     /* A "stop" condition is set, and it says "stop".  */
  100.     EXT_LANG_BP_STOP_YES
  101.   };

  102. /* Table of type printers associated with the global typedef table.  */

  103. struct ext_lang_type_printers
  104. {
  105.   /* Type-printers from Python.  */
  106.   void *py_type_printers;
  107. };

  108. /* A type which holds its extension language specific xmethod worker data.  */

  109. struct xmethod_worker
  110. {
  111.   /* The language the xmethod worker is implemented in.  */
  112.   const struct extension_language_defn *extlang;

  113.   /* The extension language specific data for this xmethod worker.  */
  114.   void *data;

  115.   /* The TYPE_CODE_XMETHOD value corresponding to this worker.
  116.      Always use value_of_xmethod to access it.  */
  117.   struct value *value;
  118. };

  119. typedef struct xmethod_worker *xmethod_worker_ptr;
  120. DEF_VEC_P (xmethod_worker_ptr);
  121. typedef VEC (xmethod_worker_ptr) xmethod_worker_vec;


  122. /* The interface for gdb's own extension(/scripting) language.  */
  123. extern const struct extension_language_defn extension_language_gdb;

  124. extern const struct extension_language_defn *get_ext_lang_defn
  125.   (enum extension_language lang);

  126. extern const struct extension_language_defn *get_ext_lang_of_file
  127.   (const char *file);

  128. extern int ext_lang_present_p (const struct extension_language_defn *);

  129. extern int ext_lang_initialized_p (const struct extension_language_defn *);

  130. extern void throw_ext_lang_unsupported
  131.   (const struct extension_language_defn *);

  132. /* Accessors for "public" attributes of the extension language definition.  */

  133. extern enum extension_language ext_lang_kind
  134.   (const struct extension_language_defn *);

  135. extern const char *ext_lang_name (const struct extension_language_defn *);

  136. extern const char *ext_lang_capitalized_name
  137.   (const struct extension_language_defn *);

  138. extern const char *ext_lang_suffix (const struct extension_language_defn *);

  139. extern const char *ext_lang_auto_load_suffix
  140.   (const struct extension_language_defn *);

  141. extern script_sourcer_func *ext_lang_script_sourcer
  142.   (const struct extension_language_defn *);

  143. extern objfile_script_sourcer_func *ext_lang_objfile_script_sourcer
  144.   (const struct extension_language_defn *);

  145. extern int ext_lang_auto_load_enabled (const struct extension_language_defn *);

  146. /* Wrappers for each extension language API function that iterate over all
  147.    extension languages.  */

  148. extern void finish_ext_lang_initialization (void);

  149. extern void eval_ext_lang_from_control_command (struct command_line *cmd);

  150. extern void auto_load_ext_lang_scripts_for_objfile (struct objfile *);

  151. extern struct ext_lang_type_printers *start_ext_lang_type_printers (void);

  152. extern char *apply_ext_lang_type_printers (struct ext_lang_type_printers *,
  153.                                            struct type *);

  154. extern void free_ext_lang_type_printers (struct ext_lang_type_printers *);

  155. extern int apply_ext_lang_val_pretty_printer
  156.   (struct type *type, const gdb_byte *valaddr,
  157.    int embedded_offset, CORE_ADDR address,
  158.    struct ui_file *stream, int recurse,
  159.    const struct value *val, const struct value_print_options *options,
  160.    const struct language_defn *language);

  161. extern enum ext_lang_bt_status apply_ext_lang_frame_filter
  162.   (struct frame_info *frame, int flags, enum ext_lang_frame_args args_type,
  163.    struct ui_out *out, int frame_low, int frame_high);

  164. extern void preserve_ext_lang_values (struct objfile *, htab_t copied_types);

  165. extern const struct extension_language_defn *get_breakpoint_cond_ext_lang
  166.   (struct breakpoint *b, enum extension_language skip_lang);

  167. extern int breakpoint_ext_lang_cond_says_stop (struct breakpoint *);

  168. extern struct value *invoke_xmethod (struct xmethod_worker *,
  169.                                      struct value *,
  170.                                      struct value **, int nargs);

  171. extern struct xmethod_worker *clone_xmethod_worker (struct xmethod_worker *);

  172. extern struct xmethod_worker *new_xmethod_worker
  173.   (const struct extension_language_defn *extlang, void *data);

  174. extern void free_xmethod_worker (struct xmethod_worker *);

  175. extern void free_xmethod_worker_vec (void *vec);

  176. extern xmethod_worker_vec *get_matching_xmethod_workers
  177.   (struct type *, const char *);

  178. extern struct type **get_xmethod_arg_types (struct xmethod_worker *, int *);

  179. #endif /* EXTENSION_H */