GDB (xrefs)
Classes | Macros | Functions | Variables
python.c File Reference
#include "defs.h"
#include "arch-utils.h"
#include "command.h"
#include "ui-out.h"
#include "cli/cli-script.h"
#include "gdbcmd.h"
#include "progspace.h"
#include "objfiles.h"
#include "value.h"
#include "language.h"
#include "event-loop.h"
#include "serial.h"
#include "readline/tilde.h"
#include "python.h"
#include "extension-priv.h"
#include "cli/cli-utils.h"
#include <ctype.h>
#include "location.h"
#include "ser-event.h"
#include "cli/cli-decode.h"
#include "charset.h"
#include "top.h"
#include "solib.h"
#include "python-internal.h"
#include "linespec.h"
#include "source.h"
#include "version.h"
#include "target.h"
#include "gdbthread.h"
#include "interps.h"
#include "event-top.h"
#include "py-ref.h"
#include "py-event.h"
#include "py-event-types.def"

Go to the source code of this file.

Classes

struct  gdbpy_event
 

Macros

#define GDB_PY_DEFINE_EVENT_TYPE(name, py_name, doc, base)
 
#define GDB_PY_DEFINE_EVENT_TYPE(name, py_name, doc, base)
 

Functions

static void gdbpy_finish_initialization (const struct extension_language_defn *)
 
static int gdbpy_initialized (const struct extension_language_defn *)
 
static void gdbpy_eval_from_control_command (const struct extension_language_defn *, struct command_line *cmd)
 
static void gdbpy_start_type_printers (const struct extension_language_defn *, struct ext_lang_type_printers *)
 
static enum ext_lang_rc gdbpy_apply_type_printers (const struct extension_language_defn *, const struct ext_lang_type_printers *, struct type *, char **)
 
static void gdbpy_free_type_printers (const struct extension_language_defn *, struct ext_lang_type_printers *)
 
static void gdbpy_set_quit_flag (const struct extension_language_defn *)
 
static int gdbpy_check_quit_flag (const struct extension_language_defn *)
 
static enum ext_lang_rc gdbpy_before_prompt_hook (const struct extension_language_defn *, const char *current_gdb_prompt)
 
static int eval_python_command (const char *command)
 
static void python_interactive_command (const char *arg, int from_tty)
 
static void python_run_simple_file (FILE *file, const char *filename)
 
static std::string compute_python_string (struct command_line *l)
 
static void python_command (const char *arg, int from_tty)
 
PyObject * gdbpy_parameter_value (enum var_types type, void *var)
 
static PyObject * gdbpy_parameter (PyObject *self, PyObject *args)
 
static PyObject * gdbpy_target_charset (PyObject *self, PyObject *args)
 
static PyObject * gdbpy_target_wide_charset (PyObject *self, PyObject *args)
 
static PyObject * execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
 
static PyObject * gdbpy_solib_name (PyObject *self, PyObject *args)
 
static PyObject * gdbpy_rbreak (PyObject *self, PyObject *args, PyObject *kw)
 
static PyObject * gdbpy_decode_line (PyObject *self, PyObject *args)
 
static PyObject * gdbpy_parse_and_eval (PyObject *self, PyObject *args)
 
static PyObject * gdbpy_find_pc_line (PyObject *self, PyObject *args)
 
static PyObject * gdbpy_invalidate_cached_frames (PyObject *self, PyObject *args)
 
static void gdbpy_source_script (const struct extension_language_defn *extlang, FILE *file, const char *filename)
 
static void gdbpy_run_events (int error, gdb_client_data client_data)
 
static PyObject * gdbpy_post_event (PyObject *self, PyObject *args)
 
static int gdbpy_initialize_events (void)
 
static PyObject * gdbpy_write (PyObject *self, PyObject *args, PyObject *kw)
 
static PyObject * gdbpy_flush (PyObject *self, PyObject *args, PyObject *kw)
 
int gdbpy_print_python_errors_p (void)
 
void gdbpy_print_stack (void)
 
static PyObject * gdbpy_get_current_progspace (PyObject *unused1, PyObject *unused2)
 
static PyObject * gdbpy_progspaces (PyObject *unused1, PyObject *unused2)
 
static void gdbpy_source_objfile_script (const struct extension_language_defn *extlang, struct objfile *objfile, FILE *file, const char *filename)
 
static void gdbpy_execute_objfile_script (const struct extension_language_defn *extlang, struct objfile *objfile, const char *name, const char *script)
 
static PyObject * gdbpy_get_current_objfile (PyObject *unused1, PyObject *unused2)
 
static PyObject * gdbpy_objfiles (PyObject *unused1, PyObject *unused2)
 
static void user_set_python (const char *args, int from_tty)
 
static void user_show_python (const char *args, int from_tty)
 
static void finalize_python (void *ignore)
 
static bool do_start_initialization ()
 
void _initialize_python (void)
 
static bool do_finish_initialization (const struct extension_language_defn *extlang)
 

Variables

static const char python_excp_none [] = "none"
 
static const char python_excp_full [] = "full"
 
static const char python_excp_message [] = "message"
 
static const char *const python_excp_enums []
 
static const char * gdbpy_should_print_stack = python_excp_message
 
const struct extension_language_script_ops python_extension_script_ops
 
const struct extension_language_ops python_extension_ops
 
const struct extension_language_defn extension_language_python
 
int gdb_python_initialized
 
PyMethodDef python_GdbMethods []
 
PyObject * gdb_module
 
PyObject * gdb_python_module
 
PyObject * gdbpy_to_string_cst
 
PyObject * gdbpy_children_cst
 
PyObject * gdbpy_display_hint_cst
 
PyObject * gdbpy_doc_cst
 
PyObject * gdbpy_enabled_cst
 
PyObject * gdbpy_value_cst
 
PyObject * gdbpy_gdberror_exc
 
PyObject * gdbpy_gdb_error
 
PyObject * gdbpy_gdb_memory_error
 
static script_sourcer_func gdbpy_source_script
 
static objfile_script_sourcer_func gdbpy_source_objfile_script
 
static objfile_script_executor_func gdbpy_execute_objfile_script
 
struct gdbarchpython_gdbarch
 
const struct language_defnpython_language
 
static struct gdbpy_eventgdbpy_event_list
 
static struct gdbpy_event ** gdbpy_event_list_end
 
static struct serial_event * gdbpy_serial_event
 
static struct objfilegdbpy_current_objfile
 
static struct cmd_list_elementuser_set_python_list
 
static struct cmd_list_elementuser_show_python_list
 

Macro Definition Documentation

◆ GDB_PY_DEFINE_EVENT_TYPE [1/2]

#define GDB_PY_DEFINE_EVENT_TYPE (   name,
  py_name,
  doc,
  base 
)
Value:
if (gdbpy_initialize_event_generic (&name##_event_object_type, py_name) < 0) \
return false;
int gdbpy_initialize_event_generic(PyTypeObject *type, const char *name)
Definition: py-event.c:69
const char *const name
Definition: aarch64-tdep.c:76

Definition at line 2143 of file python.c.

◆ GDB_PY_DEFINE_EVENT_TYPE [2/2]

#define GDB_PY_DEFINE_EVENT_TYPE (   name,
  py_name,
  doc,
  base 
)

Definition at line 2143 of file python.c.

Function Documentation

◆ _initialize_python()

void _initialize_python ( void  )

◆ compute_python_string()

static std::string compute_python_string ( struct command_line l)
static

Definition at line 371 of file python.c.

References command_line::line, command_line::next, and string.

Referenced by gdbpy_eval_from_control_command().

◆ do_finish_initialization()

static bool do_finish_initialization ( const struct extension_language_defn extlang)
static

◆ do_start_initialization()

static bool do_start_initialization ( )
static

◆ eval_python_command()

static int eval_python_command ( const char *  command)
static

Definition at line 266 of file python.c.

References arm-linux::m.

Referenced by python_interactive_command().

◆ execute_gdb_command()

static PyObject* execute_gdb_command ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
)
static

◆ finalize_python()

static void finalize_python ( void *  ignore)
static

◆ gdbpy_apply_type_printers()

static enum ext_lang_rc gdbpy_apply_type_printers ( const struct extension_language_defn extlang,
const struct ext_lang_type_printers ext_printers,
struct type type,
char **  prettied_type 
)
static

◆ gdbpy_before_prompt_hook()

static enum ext_lang_rc gdbpy_before_prompt_hook ( const struct extension_language_defn extlang,
const char *  current_gdb_prompt 
)
static

◆ gdbpy_check_quit_flag()

static int gdbpy_check_quit_flag ( const struct extension_language_defn extlang)
static

Definition at line 256 of file python.c.

◆ gdbpy_decode_line()

static PyObject* gdbpy_decode_line ( PyObject *  self,
PyObject *  args 
)
static

◆ gdbpy_eval_from_control_command()

static void gdbpy_eval_from_control_command ( const struct extension_language_defn extlang,
struct command_line cmd 
)
static

◆ gdbpy_execute_objfile_script()

static void gdbpy_execute_objfile_script ( const struct extension_language_defn extlang,
struct objfile objfile,
const char *  name,
const char *  script 
)
static

◆ gdbpy_find_pc_line()

static PyObject* gdbpy_find_pc_line ( PyObject *  self,
PyObject *  args 
)
static

◆ gdbpy_finish_initialization()

static void gdbpy_finish_initialization ( const struct extension_language_defn extlang)
static

◆ gdbpy_flush()

static PyObject* gdbpy_flush ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
)
static

◆ gdbpy_free_type_printers()

static void gdbpy_free_type_printers ( const struct extension_language_defn extlang,
struct ext_lang_type_printers ext_printers 
)
static

◆ gdbpy_get_current_objfile()

static PyObject* gdbpy_get_current_objfile ( PyObject *  unused1,
PyObject *  unused2 
)
static

Definition at line 1416 of file python.c.

References gdbpy_current_objfile, and objfile_to_objfile_object().

◆ gdbpy_get_current_progspace()

static PyObject* gdbpy_get_current_progspace ( PyObject *  unused1,
PyObject *  unused2 
)
static

Definition at line 1329 of file python.c.

References current_program_space, and pspace_to_pspace_object().

◆ gdbpy_initialize_events()

static int gdbpy_initialize_events ( void  )
static

◆ gdbpy_initialized()

static int gdbpy_initialized ( const struct extension_language_defn extlang)
static

Definition at line 1985 of file python.c.

References gdb_python_initialized.

◆ gdbpy_invalidate_cached_frames()

static PyObject* gdbpy_invalidate_cached_frames ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 967 of file python.c.

References reinit_frame_cache().

◆ gdbpy_objfiles()

static PyObject* gdbpy_objfiles ( PyObject *  unused1,
PyObject *  unused2 
)
static

◆ gdbpy_parameter()

static PyObject* gdbpy_parameter ( PyObject *  self,
PyObject *  args 
)
static

◆ gdbpy_parameter_value()

PyObject* gdbpy_parameter_value ( enum var_types  type,
void *  var 
)

◆ gdbpy_parse_and_eval()

static PyObject* gdbpy_parse_and_eval ( PyObject *  self,
PyObject *  args 
)
static

◆ gdbpy_post_event()

static PyObject* gdbpy_post_event ( PyObject *  self,
PyObject *  args 
)
static

◆ gdbpy_print_python_errors_p()

int gdbpy_print_python_errors_p ( void  )

Definition at line 1252 of file python.c.

References gdbpy_should_print_stack, and python_excp_none.

Referenced by print_children().

◆ gdbpy_print_stack()

void gdbpy_print_stack ( void  )

Definition at line 1262 of file python.c.

References _, begin_line(), CATCH, END_CATCH, fprintf_filtered(), gdb_stderr, gdbpy_exception_to_string(), gdbpy_obj_to_string(), gdbpy_should_print_stack, python_excp_full, python_excp_none, RETURN_MASK_ALL, TRY, and type.

Referenced by _initialize_python(), add_thread_object(), bpfinishpy_detect_out_scope_cb(), bpfinishpy_out_of_scope(), bpfinishpy_post_stop_hook(), bpfinishpy_pre_stop_hook(), cmdpy_function(), construct_visualizer(), do_finish_initialization(), evpy_emit_event(), fnpy_call(), gdbpy_apply_frame_filter(), gdbpy_apply_type_printers(), gdbpy_before_prompt_hook(), gdbpy_breakpoint_cond_says_stop(), gdbpy_breakpoint_created(), gdbpy_breakpoint_deleted(), gdbpy_breakpoint_modified(), gdbpy_finish_initialization(), gdbpy_get_display_hint(), gdbpy_get_matching_xmethod_workers(), gdbpy_get_xmethod_arg_types(), gdbpy_get_xmethod_result_type(), gdbpy_invoke_xmethod(), gdbpy_rbreak(), gdbpy_start_type_printers(), get_doc_string(), get_set_value(), get_show_value(), install_default_visualizer(), print_children(), print_stack_unless_memory_error(), py_varobj_get_iterator(), py_varobj_iter_next(), python_inferior_deleted(), python_inferior_exit(), python_interactive_command(), python_new_inferior(), python_new_objfile(), python_on_inferior_call_post(), python_on_inferior_call_pre(), python_on_memory_change(), python_on_normal_stop(), python_on_register_change(), python_on_resume(), python_run_simple_file(), pyuw_sniffer(), varobj_set_visualizer(), varobj_value_get_print_value(), and gdbpy_enter::~gdbpy_enter().

◆ gdbpy_progspaces()

static PyObject* gdbpy_progspaces ( PyObject *  unused1,
PyObject *  unused2 
)
static

◆ gdbpy_rbreak()

static PyObject* gdbpy_rbreak ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
)
static

◆ gdbpy_run_events()

static void gdbpy_run_events ( int  error,
gdb_client_data  client_data 
)
static

◆ gdbpy_set_quit_flag()

static void gdbpy_set_quit_flag ( const struct extension_language_defn extlang)
static

Definition at line 248 of file python.c.

◆ gdbpy_solib_name()

static PyObject* gdbpy_solib_name ( PyObject *  self,
PyObject *  args 
)
static

◆ gdbpy_source_objfile_script()

static void gdbpy_source_objfile_script ( const struct extension_language_defn extlang,
struct objfile objfile,
FILE *  file,
const char *  filename 
)
static

◆ gdbpy_source_script()

static void gdbpy_source_script ( const struct extension_language_defn extlang,
FILE *  file,
const char *  filename 
)
static

Definition at line 980 of file python.c.

References current_language, get_current_arch(), and python_run_simple_file().

◆ gdbpy_start_type_printers()

static void gdbpy_start_type_printers ( const struct extension_language_defn extlang,
struct ext_lang_type_printers ext_printers 
)
static

◆ gdbpy_target_charset()

static PyObject* gdbpy_target_charset ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 533 of file python.c.

References host_charset(), python_gdbarch, and target_charset().

◆ gdbpy_target_wide_charset()

static PyObject* gdbpy_target_wide_charset ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 543 of file python.c.

References host_charset(), python_gdbarch, and target_wide_charset().

◆ gdbpy_write()

static PyObject* gdbpy_write ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
)
static

◆ python_command()

static void python_command ( const char *  arg,
int  from_tty 
)
static

◆ python_interactive_command()

static void python_interactive_command ( const char *  arg,
int  from_tty 
)
static

◆ python_run_simple_file()

static void python_run_simple_file ( FILE *  file,
const char *  filename 
)
static

Definition at line 344 of file python.c.

References _, error(), and gdbpy_print_stack().

Referenced by gdbpy_source_objfile_script(), and gdbpy_source_script().

◆ user_set_python()

static void user_set_python ( const char *  args,
int  from_tty 
)
static

Definition at line 1614 of file python.c.

References all_commands, gdb_stdout, help_list(), and user_set_python_list.

Referenced by _initialize_python().

◆ user_show_python()

static void user_show_python ( const char *  args,
int  from_tty 
)
static

Definition at line 1623 of file python.c.

References cmd_show_list(), and user_show_python_list.

Referenced by _initialize_python().

Variable Documentation

◆ extension_language_python

const struct extension_language_defn extension_language_python
Initial value:
=
{
"python",
"Python",
".py",
"-gdb.py",
}
const struct extension_language_script_ops python_extension_script_ops
Definition: python.c:158
const struct extension_language_ops python_extension_ops
Definition: python.c:168

Definition at line 68 of file python.c.

Referenced by finalize_python(), gdbpy_enter::gdbpy_enter(), info_auto_load_python_scripts(), and new_python_xmethod_worker().

◆ gdb_module

PyObject* gdb_module

◆ gdb_python_initialized

int gdb_python_initialized

◆ gdb_python_module

PyObject* gdb_python_module

◆ gdbpy_children_cst

PyObject* gdbpy_children_cst

◆ gdbpy_current_objfile

struct objfile* gdbpy_current_objfile
static

◆ gdbpy_display_hint_cst

PyObject* gdbpy_display_hint_cst

Definition at line 122 of file python.c.

Referenced by do_start_initialization(), and gdbpy_get_display_hint().

◆ gdbpy_doc_cst

PyObject* gdbpy_doc_cst

Definition at line 123 of file python.c.

Referenced by cmdpy_init(), do_start_initialization(), and parmpy_init().

◆ gdbpy_enabled_cst

PyObject* gdbpy_enabled_cst

Definition at line 124 of file python.c.

Referenced by do_start_initialization(), and search_pp_list().

◆ gdbpy_event_list

struct gdbpy_event* gdbpy_event_list
static

Definition at line 1001 of file python.c.

Referenced by gdbpy_initialize_events(), gdbpy_post_event(), and gdbpy_run_events().

◆ gdbpy_event_list_end

struct gdbpy_event** gdbpy_event_list_end
static

Definition at line 1003 of file python.c.

Referenced by gdbpy_initialize_events(), gdbpy_post_event(), and gdbpy_run_events().

◆ gdbpy_execute_objfile_script

objfile_script_executor_func gdbpy_execute_objfile_script
static

Definition at line 138 of file python.c.

◆ gdbpy_gdb_error

PyObject* gdbpy_gdb_error

◆ gdbpy_gdb_memory_error

PyObject* gdbpy_gdb_memory_error

◆ gdbpy_gdberror_exc

PyObject* gdbpy_gdberror_exc

Definition at line 128 of file python.c.

Referenced by cmdpy_function(), do_start_initialization(), and fnpy_call().

◆ gdbpy_serial_event

struct serial_event* gdbpy_serial_event
static

Definition at line 1007 of file python.c.

Referenced by gdbpy_initialize_events(), gdbpy_post_event(), and gdbpy_run_events().

◆ gdbpy_should_print_stack

const char* gdbpy_should_print_stack = python_excp_message
static

Definition at line 58 of file python.c.

Referenced by _initialize_python(), gdbpy_print_python_errors_p(), and gdbpy_print_stack().

◆ gdbpy_source_objfile_script

objfile_script_sourcer_func gdbpy_source_objfile_script
static

Definition at line 137 of file python.c.

◆ gdbpy_source_script

script_sourcer_func gdbpy_source_script
static

Definition at line 136 of file python.c.

◆ gdbpy_to_string_cst

PyObject* gdbpy_to_string_cst

◆ gdbpy_value_cst

PyObject* gdbpy_value_cst

Definition at line 125 of file python.c.

Referenced by convert_value_from_python(), and do_start_initialization().

◆ python_excp_enums

const char* const python_excp_enums[]
static
Initial value:
=
{
NULL
}
static const char python_excp_message[]
Definition: python.c:43
static const char python_excp_none[]
Definition: python.c:41
static const char python_excp_full[]
Definition: python.c:42

Definition at line 46 of file python.c.

Referenced by _initialize_python().

◆ python_excp_full

const char python_excp_full[] = "full"
static

Definition at line 42 of file python.c.

Referenced by gdbpy_print_stack().

◆ python_excp_message

const char python_excp_message[] = "message"
static

Definition at line 43 of file python.c.

◆ python_excp_none

const char python_excp_none[] = "none"
static

Definition at line 41 of file python.c.

Referenced by gdbpy_print_python_errors_p(), and gdbpy_print_stack().

◆ python_extension_ops

const struct extension_language_ops python_extension_ops

Definition at line 168 of file python.c.

◆ python_extension_script_ops

const struct extension_language_script_ops python_extension_script_ops
Initial value:
=
{
}
static objfile_script_executor_func gdbpy_execute_objfile_script
Definition: python.c:138
int gdbpy_auto_load_enabled(const struct extension_language_defn *extlang)
Definition: py-auto-load.c:47
static objfile_script_sourcer_func gdbpy_source_objfile_script
Definition: python.c:137
static script_sourcer_func gdbpy_source_script
Definition: python.c:136

Definition at line 158 of file python.c.

◆ python_gdbarch

struct gdbarch* python_gdbarch

◆ python_GdbMethods

PyMethodDef python_GdbMethods

Definition at line 1996 of file python.c.

Referenced by do_start_initialization().

◆ python_language

const struct language_defn* python_language

◆ user_set_python_list

struct cmd_list_element* user_set_python_list
static

Definition at line 1608 of file python.c.

Referenced by _initialize_python(), and user_set_python().

◆ user_show_python_list

struct cmd_list_element* user_show_python_list
static

Definition at line 1609 of file python.c.

Referenced by _initialize_python(), and user_show_python().