GDB (xrefs)
Classes | 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 "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"

Go to the source code of this file.

Classes

struct  python_env
 
struct  gdbpy_event
 

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_clear_quit_flag (const struct extension_language_defn *)
 
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 void restore_python_env (void *p)
 
struct cleanupensure_python_env (struct gdbarch *gdbarch, const struct language_defn *language)
 
static int eval_python_command (const char *command)
 
static void python_interactive_command (char *arg, int from_tty)
 
static void python_run_simple_file (FILE *file, const char *filename)
 
static char * compute_python_string (struct command_line *l)
 
static void python_command (char *arg, int from_tty)
 
PyObject * gdbpy_parameter_value (enum var_types type, void *var)
 
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_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 void gdbpy_source_script (const struct extension_language_defn *extlang, FILE *file, const char *filename)
 
static void gdbpy_run_events (struct serial *scb, void *context)
 
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 (char *args, int from_tty)
 
static void user_show_python (char *args, int from_tty)
 
static void finalize_python (void *ignore)
 
void _initialize_python (void)
 

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 serialgdbpy_event_fds [2]
 
static struct objfilegdbpy_current_objfile
 
static struct cmd_list_elementuser_set_python_list
 
static struct cmd_list_elementuser_show_python_list
 
initialize_file_ftype _initialize_python
 

Function Documentation

void _initialize_python ( void  )

Definition at line 1629 of file python.c.

References _, add_com(), add_com_alias(), add_prefix_cmd(), add_setshow_enum_cmd(), class_obscure, finalize_python(), gdb_module, gdb_pymodule_addobject(), gdb_python_initialized, gdbpy_children_cst, gdbpy_display_hint_cst, gdbpy_doc_cst, gdbpy_enabled_cst, gdbpy_gdb_error, gdbpy_gdb_memory_error, gdbpy_gdberror_exc, gdbpy_initialize_arch(), gdbpy_initialize_auto_load(), gdbpy_initialize_blocks(), gdbpy_initialize_breakpoint_event(), gdbpy_initialize_breakpoints(), gdbpy_initialize_clear_objfiles_event(), gdbpy_initialize_commands(), gdbpy_initialize_continue_event(), gdbpy_initialize_event(), gdbpy_initialize_eventregistry(), gdbpy_initialize_events(), gdbpy_initialize_exited_event(), gdbpy_initialize_finishbreakpoints(), gdbpy_initialize_frames(), gdbpy_initialize_functions(), gdbpy_initialize_gdb_readline(), gdbpy_initialize_inferior(), gdbpy_initialize_inferior_call_post_event(), gdbpy_initialize_inferior_call_pre_event(), gdbpy_initialize_lazy_string(), gdbpy_initialize_linetable(), gdbpy_initialize_memory_changed_event(), gdbpy_initialize_new_objfile_event(), gdbpy_initialize_objfile(), gdbpy_initialize_parameters(), gdbpy_initialize_pspace(), gdbpy_initialize_py_events(), gdbpy_initialize_register_changed_event(), gdbpy_initialize_signal_event(), gdbpy_initialize_stop_event(), gdbpy_initialize_symbols(), gdbpy_initialize_symtabs(), gdbpy_initialize_thread(), gdbpy_initialize_thread_event(), gdbpy_initialize_types(), gdbpy_initialize_unwind(), gdbpy_initialize_values(), gdbpy_initialize_xmethods(), gdbpy_print_stack(), gdbpy_should_print_stack, gdbpy_to_string_cst, gdbpy_value_cst, HAVE_PYTHON, host_name, ldirname(), make_final_cleanup(), no_class, PyEval_InitThreads, PyEval_ReleaseLock, python_command(), python_excp_enums, python_GdbMethods, python_interactive_command(), python_libdir, PyThreadState_Swap, setlist, showlist, SLASH_STRING, target_name, user_set_python(), user_show_python(), and version.

static char* compute_python_string ( struct command_line l)
static

Definition at line 420 of file python.c.

References len, command_line::line, command_line::next, size, and xmalloc().

Referenced by gdbpy_eval_from_control_command().

struct cleanup* ensure_python_env ( struct gdbarch gdbarch,
const struct language_defn language 
)

Definition at line 247 of file python.c.

References _, error(), python_env::error_traceback, python_env::error_type, python_env::error_value, gdb_python_initialized, python_env::gdbarch, python_env::language, make_cleanup(), python_env::previous_active, PyGILState_Ensure, python_gdbarch, python_language, restore_python_env(), set_active_ext_lang(), python_env::state, and xmalloc().

Referenced by add_thread_object(), bpfinishpy_handle_exit(), bpfinishpy_handle_stop(), cmdpy_completer_handle_brkchars(), cmdpy_destroyer(), cmdpy_function(), delete_thread_object(), fnpy_call(), gdbpy_apply_frame_filter(), gdbpy_apply_type_printers(), gdbpy_apply_val_pretty_printer(), gdbpy_before_prompt_hook(), gdbpy_breakpoint_cond_says_stop(), gdbpy_breakpoint_has_cond(), gdbpy_clone_xmethod_worker_data(), gdbpy_eval_from_control_command(), gdbpy_execute_objfile_script(), gdbpy_finish_initialization(), gdbpy_free_type_printers(), gdbpy_free_xmethod_worker_data(), gdbpy_get_matching_xmethod_workers(), gdbpy_get_xmethod_arg_types(), gdbpy_get_xmethod_result_type(), gdbpy_invoke_xmethod(), gdbpy_run_events(), gdbpy_source_objfile_script(), gdbpy_source_script(), gdbpy_start_type_printers(), get_set_value(), get_show_value(), py_free_inferior(), py_free_objfile(), py_free_pspace(), python_command(), python_inferior_exit(), python_interactive_command(), 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(), pyuw_sniffer(), save_objfile_types(), varobj_ensure_python_env(), and VEC().

static int eval_python_command ( const char *  command)
static

Definition at line 301 of file python.c.

References arm-linux::m, and Py_DECREF.

Referenced by python_interactive_command().

static PyObject* execute_gdb_command ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
)
static
static void finalize_python ( void *  ignore)
static
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
static enum ext_lang_rc gdbpy_before_prompt_hook ( const struct extension_language_defn extlang,
const char *  current_gdb_prompt 
)
static
static int gdbpy_check_quit_flag ( const struct extension_language_defn extlang)
static

Definition at line 291 of file python.c.

static void gdbpy_clear_quit_flag ( const struct extension_language_defn extlang)
static

Definition at line 274 of file python.c.

static PyObject* gdbpy_decode_line ( PyObject *  self,
PyObject *  args 
)
static
static void gdbpy_eval_from_control_command ( const struct extension_language_defn extlang,
struct command_line cmd 
)
static
static void gdbpy_execute_objfile_script ( const struct extension_language_defn extlang,
struct objfile objfile,
const char *  name,
const char *  script 
)
static
static PyObject* gdbpy_find_pc_line ( PyObject *  self,
PyObject *  args 
)
static
static void gdbpy_finish_initialization ( const struct extension_language_defn extlang)
static
static PyObject* gdbpy_flush ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
)
static

Definition at line 1158 of file python.c.

References gdb_flush(), gdb_stderr, gdb_stdlog, and gdb_stdout.

static void gdbpy_free_type_printers ( const struct extension_language_defn extlang,
struct ext_lang_type_printers ext_printers 
)
static
static PyObject* gdbpy_get_current_objfile ( PyObject *  unused1,
PyObject *  unused2 
)
static

Definition at line 1364 of file python.c.

References objfile_to_objfile_object().

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

Definition at line 1267 of file python.c.

References current_program_space, and pspace_to_pspace_object().

static int gdbpy_initialize_events ( void  )
static

Definition at line 1014 of file python.c.

References gdbpy_event_list, gdbpy_run_events(), serial_async(), and serial_pipe().

Referenced by _initialize_python().

static int gdbpy_initialized ( const struct extension_language_defn extlang)
static

Definition at line 1965 of file python.c.

References gdb_python_initialized.

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

Definition at line 1380 of file python.c.

References ALL_OBJFILES, objfile_to_objfile_object(), and Py_DECREF.

PyObject* gdbpy_parameter ( PyObject *  self,
PyObject *  args 
)
PyObject* gdbpy_parameter_value ( enum var_types  type,
void *  var 
)
static PyObject* gdbpy_parse_and_eval ( PyObject *  self,
PyObject *  args 
)
static
static PyObject* gdbpy_post_event ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 972 of file python.c.

References _, gdbpy_event::event, func, gdbpy_event::next, and serial_write().

int gdbpy_print_python_errors_p ( void  )

Definition at line 1189 of file python.c.

References gdbpy_should_print_stack, and python_excp_none.

Referenced by print_children().

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

Definition at line 1280 of file python.c.

References ALL_PSPACES, cleanup_check::ps, pspace_to_pspace_object(), and Py_DECREF.

static void gdbpy_run_events ( struct serial scb,
void *  context 
)
static
static void gdbpy_set_quit_flag ( const struct extension_language_defn extlang)
static

Definition at line 283 of file python.c.

static PyObject* gdbpy_solib_name ( PyObject *  self,
PyObject *  args 
)
static
static void gdbpy_source_objfile_script ( const struct extension_language_defn extlang,
struct objfile objfile,
FILE *  file,
const char *  filename 
)
static
static void gdbpy_source_script ( const struct extension_language_defn extlang,
FILE *  file,
const char *  filename 
)
static
static void gdbpy_start_type_printers ( const struct extension_language_defn extlang,
struct ext_lang_type_printers ext_printers 
)
static
static PyObject* gdbpy_target_charset ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 604 of file python.c.

References host_charset(), and target_charset().

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

Definition at line 614 of file python.c.

References host_charset(), and target_wide_charset().

static PyObject* gdbpy_write ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
)
static
static void python_command ( char *  arg,
int  from_tty 
)
static
static void python_interactive_command ( char *  arg,
int  from_tty 
)
static
static void python_run_simple_file ( FILE *  file,
const char *  filename 
)
static
static void restore_python_env ( void *  p)
static
static void user_set_python ( char *  args,
int  from_tty 
)
static

Definition at line 1579 of file python.c.

References all_commands, gdb_stdout, and help_list().

Referenced by _initialize_python().

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

Definition at line 1588 of file python.c.

References cmd_show_list().

Referenced by _initialize_python().

Variable Documentation

initialize_file_ftype _initialize_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:155
const struct extension_language_ops python_extension_ops
Definition: python.c:165

Definition at line 66 of file python.c.

Referenced by info_auto_load_python_scripts(), and new_python_xmethod_worker().

PyObject* gdb_module
int gdb_python_initialized
PyObject* gdb_python_module
PyObject* gdbpy_children_cst
struct objfile* gdbpy_current_objfile
static

Definition at line 1309 of file python.c.

PyObject* gdbpy_display_hint_cst

Definition at line 118 of file python.c.

Referenced by _initialize_python(), and gdbpy_get_display_hint().

PyObject* gdbpy_doc_cst

Definition at line 119 of file python.c.

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

PyObject* gdbpy_enabled_cst

Definition at line 120 of file python.c.

Referenced by _initialize_python(), and search_pp_list().

struct serial* gdbpy_event_fds[2]
static

Definition at line 927 of file python.c.

struct gdbpy_event* gdbpy_event_list
static

Definition at line 921 of file python.c.

Referenced by gdbpy_initialize_events(), and gdbpy_run_events().

struct gdbpy_event** gdbpy_event_list_end
static

Definition at line 923 of file python.c.

objfile_script_executor_func gdbpy_execute_objfile_script
static

Definition at line 134 of file python.c.

PyObject* gdbpy_gdb_error

Definition at line 127 of file python.c.

Referenced by _initialize_python(), and gdbpy_convert_exception().

PyObject* gdbpy_gdb_memory_error
PyObject* gdbpy_gdberror_exc

Definition at line 124 of file python.c.

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

const char* gdbpy_should_print_stack = python_excp_message
static

Definition at line 56 of file python.c.

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

objfile_script_sourcer_func gdbpy_source_objfile_script
static

Definition at line 133 of file python.c.

script_sourcer_func gdbpy_source_script
static

Definition at line 132 of file python.c.

PyObject* gdbpy_to_string_cst
PyObject* gdbpy_value_cst

Definition at line 121 of file python.c.

Referenced by _initialize_python(), and convert_value_from_python().

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

Definition at line 44 of file python.c.

Referenced by _initialize_python().

const char python_excp_full[] = "full"
static

Definition at line 40 of file python.c.

Referenced by gdbpy_print_stack().

const char python_excp_message[] = "message"
static

Definition at line 41 of file python.c.

const char python_excp_none[] = "none"
static

Definition at line 39 of file python.c.

Referenced by gdbpy_print_python_errors_p(), and gdbpy_print_stack().

const struct extension_language_ops python_extension_ops

Definition at line 165 of file python.c.

const struct extension_language_script_ops python_extension_script_ops
Initial value:
=
{
}
static objfile_script_executor_func gdbpy_execute_objfile_script
Definition: python.c:134
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:133
static script_sourcer_func gdbpy_source_script
Definition: python.c:132

Definition at line 155 of file python.c.

struct gdbarch* python_gdbarch
PyMethodDef python_GdbMethods

Definition at line 1976 of file python.c.

Referenced by _initialize_python().

const struct language_defn* python_language
struct cmd_list_element* user_set_python_list
static

Definition at line 1573 of file python.c.

struct cmd_list_element* user_show_python_list
static

Definition at line 1574 of file python.c.