
This is the remainder boring constification that all looks more of less borderline obvious IMO. gdb/ChangeLog: 2017-04-05 Pedro Alves <palves@redhat.com> * ada-exp.y (yyerror): Constify. * ada-lang.c (bound_name, get_selections) (ada_variant_discrim_type) (ada_variant_discrim_name, ada_value_struct_elt) (ada_lookup_struct_elt_type, is_unchecked_variant) (ada_which_variant_applies, standard_exc, ada_get_next_arg) (catch_ada_exception_command_split) (catch_ada_assert_command_split, catch_assert_command) (ada_op_name): Constify. * ada-lang.h (ada_yyerror, get_selections) (ada_variant_discrim_name, ada_value_struct_elt): Constify. * arc-tdep.c (arc_print_frame_cache): Constify. * arm-tdep.c (arm_skip_stub): Constify. * ax-gdb.c (gen_binop, gen_struct_ref_recursive, gen_struct_ref) (gen_aggregate_elt_ref): Constify. * bcache.c (print_bcache_statistics): Constify. * bcache.h (print_bcache_statistics): Constify. * break-catch-throw.c (catch_exception_command_1): * breakpoint.c (struct ep_type_description::description): Constify. (add_solib_catchpoint): Constify. (catch_fork_command_1): Add cast. (add_catch_command): Constify. * breakpoint.h (add_catch_command, add_solib_catchpoint): Constify. * bsd-uthread.c (bsd_uthread_state): Constify. * buildsym.c (patch_subfile_names): Constify. * buildsym.h (next_symbol_text_func, patch_subfile_names): Constify. * c-exp.y (yyerror): Constify. (token::oper): Constify. * c-lang.h (c_yyerror, cp_print_class_member): Constify. * c-varobj.c (cplus_describe_child): Constify. * charset.c (find_charset_names): Add cast. (find_charset_names): Constify array and add const_cast. * cli/cli-cmds.c (complete_command, cd_command): Constify. (edit_command): Constify. * cli/cli-decode.c (lookup_cmd): Constify. * cli/cli-dump.c (dump_memory_command, dump_value_command): Constify. (struct dump_context): Constify. (add_dump_command, restore_command): Constify. * cli/cli-script.c (get_command_line): Constify. * cli/cli-script.h (get_command_line): Constify. * cli/cli-utils.c (check_for_argument): Constify. * cli/cli-utils.h (check_for_argument): Constify. * coff-pe-read.c (struct read_pe_section_data): Constify. * command.h (lookup_cmd): Constify. * common/print-utils.c (decimal2str): Constify. * completer.c (gdb_print_filename): Constify. * corefile.c (set_gnutarget): Constify. * cp-name-parser.y (yyerror): Constify. * cp-valprint.c (cp_print_class_member): Constify. * cris-tdep.c (cris_register_name, crisv32_register_name): Constify. * d-exp.y (yyerror): Constify. (struct token::oper): Constify. * d-lang.h (d_yyerror): Constify. * dbxread.c (struct header_file_location::name): Constify. (add_old_header_file, add_new_header_file, last_function_name) (dbx_next_symbol_text, add_bincl_to_list) (find_corresponding_bincl_psymtab, set_namestring) (find_stab_function_addr, read_dbx_symtab, start_psymtab) (dbx_end_psymtab, read_ofile_symtab, process_one_symbol): * defs.h (command_line_input, print_address_symbolic) (deprecated_readline_begin_hook): Constify. * dwarf2read.c (anonymous_struct_prefix, dwarf_bool_name): Constify. * event-top.c (handle_line_of_input): Constify and add cast. * exceptions.c (catch_errors): Constify. * exceptions.h (catch_errors): Constify. * expprint.c (print_subexp_standard, op_string, op_name) (op_name_standard, dump_raw_expression, dump_raw_expression): * expression.h (op_name, op_string, dump_raw_expression): Constify. * f-exp.y (yyerror): Constify. (struct token::oper): Constify. (struct f77_boolean_val::name): Constify. * f-lang.c (f_word_break_characters): Constify. * f-lang.h (f_yyerror): Constify. * fork-child.c (fork_inferior): Add cast. * frv-tdep.c (struct gdbarch_tdep::register_names): Constify. (new_variant): Constify. * gdbarch.sh (pstring_ptr, pstring_list): Constify. * gdbarch.c: Regenerate. * gdbcore.h (set_gnutarget): Constify. * go-exp.y (yyerror): Constify. (token::oper): Constify. * go-lang.h (go_yyerror): Constify. * go32-nat.c (go32_sysinfo): Constify. * guile/scm-breakpoint.c (gdbscm_breakpoint_expression): Constify. * guile/scm-cmd.c (cmdscm_function): Constify. * guile/scm-param.c (pascm_param_value): Constify. * h8300-tdep.c (h8300_register_name, h8300s_register_name) (h8300sx_register_name): Constify. * hppa-tdep.c (hppa32_register_name, hppa64_register_name): Constify. * ia64-tdep.c (ia64_register_names): Constify. * infcmd.c (construct_inferior_arguments): Constify. (path_command, attach_post_wait): Constify. * language.c (show_range_command, show_case_command) (unk_lang_error): Constify. * language.h (language_defn::la_error) (language_defn::la_name_of_this): Constify. * linespec.c (decode_line_2): Constify. * linux-thread-db.c (thread_db_err_str): Constify. * lm32-tdep.c (lm32_register_name): Constify. * m2-exp.y (yyerror): Constify. * m2-lang.h (m2_yyerror): Constify. * m32r-tdep.c (m32r_register_names): Constify and make static. * m68hc11-tdep.c (m68hc11_register_names): Constify. * m88k-tdep.c (m88k_register_name): Constify. * macroexp.c (appendmem): Constify. * mdebugread.c (fdr_name, add_data_symbol, parse_type) (upgrade_type, parse_external, parse_partial_symbols) (mdebug_next_symbol_text, cross_ref, mylookup_symbol, new_psymtab) (new_symbol): Constify. * memattr.c (mem_info_command): Constify. * mep-tdep.c (register_name_from_keyword): Constify. * mi/mi-cmd-env.c (mi_cmd_env_path, _initialize_mi_cmd_env): Constify. * mi/mi-cmd-stack.c (list_args_or_locals): Constify. * mi/mi-cmd-var.c (mi_cmd_var_show_attributes): Constify. * mi/mi-main.c (captured_mi_execute_command): Constify and add cast. (mi_execute_async_cli_command): Constify. * mips-tdep.c (mips_register_name): Constify. * mn10300-tdep.c (register_name, mn10300_generic_register_name) (am33_register_name, am33_2_register_name) * moxie-tdep.c (moxie_register_names): Constify. * nat/linux-osdata.c (osdata_type): Constify fields. * nto-tdep.c (nto_parse_redirection): Constify. * objc-lang.c (lookup_struct_typedef, lookup_objc_class) (lookup_child_selector): Constify. (objc_methcall::name): Constify. * objc-lang.h (lookup_objc_class, lookup_child_selector) (lookup_struct_typedef): Constify. * objfiles.c (pc_in_section): Constify. * objfiles.h (pc_in_section): Constify. * p-exp.y (struct token::oper): Constify. (yyerror): Constify. * p-lang.h (pascal_yyerror): Constify. * parser-defs.h (op_name_standard): Constify. (op_print::string): Constify. (exp_descriptor::op_name): Constify. * printcmd.c (print_address_symbolic): Constify. * psymtab.c (print_partial_symbols): Constify. * python/py-breakpoint.c (stop_func): Constify. (bppy_get_expression): Constify. * python/py-cmd.c (cmdpy_completer::name): Constify. (cmdpy_function): Constify. * python/py-event.c (evpy_add_attribute) (gdbpy_initialize_event_generic): Constify. * python/py-event.h (evpy_add_attribute) (gdbpy_initialize_event_generic): Constify. * python/py-evts.c (add_new_registry): Constify. * python/py-finishbreakpoint.c (outofscope_func): Constify. * python/py-framefilter.c (get_py_iter_from_func): Constify. * python/py-inferior.c (get_buffer): Add cast. * python/py-param.c (parm_constant::name): Constify. * python/py-unwind.c (fprint_frame_id): Constify. * python/python.c (gdbpy_parameter_value): Constify. * remote-fileio.c (remote_fio_func_map): Make 'name' const. * remote.c (memory_packet_config::name): Constify. (show_packet_config_cmd, remote_write_bytes) (remote_buffer_add_string): * reverse.c (exec_reverse_once): Constify. * rs6000-tdep.c (variant::name, variant::description): Constify. * rust-exp.y (rustyyerror): Constify. * rust-lang.c (rust_op_name): Constify. * rust-lang.h (rustyyerror): Constify. * serial.h (serial_ops::name): Constify. * sh-tdep.c (sh_sh_register_name, sh_sh3_register_name) (sh_sh3e_register_name, sh_sh2e_register_name) (sh_sh2a_register_name, sh_sh2a_nofpu_register_name) (sh_sh_dsp_register_name, sh_sh3_dsp_register_name) (sh_sh4_register_name, sh_sh4_nofpu_register_name) (sh_sh4al_dsp_register_name): Constify. * sh64-tdep.c (sh64_register_name): Constify. * solib-darwin.c (lookup_symbol_from_bfd): Constify. * spu-tdep.c (spu_register_name, info_spu_dma_cmdlist): Constify. * stabsread.c (patch_block_stabs, read_type_number) (ref_map::stabs, ref_add, process_reference) (symbol_reference_defined, define_symbol, define_symbol) (error_type, read_type, read_member_functions, read_cpp_abbrev) (read_one_struct_field, read_struct_fields, read_baseclasses) (read_tilde_fields, read_struct_type, read_array_type) (read_enum_type, read_sun_builtin_type, read_sun_floating_type) (read_huge_number, read_range_type, read_args, common_block_start) (find_name_end): Constify. * stabsread.h (common_block_start, define_symbol) (process_one_symbol, symbol_reference_defined, ref_add): * symfile.c (get_section_index, add_symbol_file_command): * symfile.h (get_section_index): Constify. * target-descriptions.c (tdesc_type::name): Constify. (tdesc_free_type): Add cast. * target.c (find_default_run_target): (add_deprecated_target_alias, find_default_run_target) (target_announce_detach): Constify. (do_option): Constify. * target.h (add_deprecated_target_alias): Constify. * thread.c (print_thread_info_1): Constify. * top.c (deprecated_readline_begin_hook, command_line_input): Constify. (init_main): Add casts. * top.h (handle_line_of_input): Constify. * tracefile-tfile.c (tfile_write_uploaded_tsv): Constify. * tracepoint.c (tvariables_info_1, trace_status_mi): Constify. (tfind_command): Rename to ... (tfind_command_1): ... this and constify. (tfind_command): New function. (tfind_end_command, tfind_start_command): Adjust. (encode_source_string): Constify. * tracepoint.h (encode_source_string): Constify. * tui/tui-data.c (tui_partial_win_by_name): Constify. * tui/tui-data.h (tui_partial_win_by_name): Constify. * tui/tui-source.c (tui_set_source_content_nil): Constify. * tui/tui-source.h (tui_set_source_content_nil): Constify. * tui/tui-win.c (parse_scrolling_args): Constify. * tui/tui-windata.c (tui_erase_data_content): Constify. * tui/tui-windata.h (tui_erase_data_content): Constify. * tui/tui-winsource.c (tui_erase_source_content): Constify. * tui/tui.c (tui_enable): Add cast. * utils.c (defaulted_query): Constify. (init_page_info): Add cast. (puts_debug, subset_compare): Constify. * utils.h (subset_compare): Constify. * varobj.c (varobj_format_string): Constify. * varobj.h (varobj_format_string): Constify. * vax-tdep.c (vax_register_name): Constify. * windows-nat.c (windows_detach): Constify. * xcoffread.c (process_linenos, xcoff_next_symbol_text): Constify. * xml-support.c (gdb_xml_end_element): Constify. * xml-tdesc.c (tdesc_start_reg): Constify. * xstormy16-tdep.c (xstormy16_register_name): Constify. * xtensa-tdep.c (xtensa_find_register_by_name): Constify. * xtensa-tdep.h (xtensa_register_t::name): Constify. gdb/gdbserver/ChangeLog: 2017-04-05 Pedro Alves <palves@redhat.com> * gdbreplay.c (sync_error): Constify. * linux-x86-low.c (push_opcode): Constify.
1143 lines
28 KiB
C
1143 lines
28 KiB
C
/* Python interface to breakpoints
|
||
|
||
Copyright (C) 2008-2017 Free Software Foundation, Inc.
|
||
|
||
This file is part of GDB.
|
||
|
||
This program is free software; you can redistribute it and/or modify
|
||
it under the terms of the GNU General Public License as published by
|
||
the Free Software Foundation; either version 3 of the License, or
|
||
(at your option) any later version.
|
||
|
||
This program is distributed in the hope that it will be useful,
|
||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
GNU General Public License for more details.
|
||
|
||
You should have received a copy of the GNU General Public License
|
||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||
|
||
#include "defs.h"
|
||
#include "value.h"
|
||
#include "python-internal.h"
|
||
#include "python.h"
|
||
#include "charset.h"
|
||
#include "breakpoint.h"
|
||
#include "gdbcmd.h"
|
||
#include "gdbthread.h"
|
||
#include "observer.h"
|
||
#include "cli/cli-script.h"
|
||
#include "ada-lang.h"
|
||
#include "arch-utils.h"
|
||
#include "language.h"
|
||
#include "location.h"
|
||
#include "py-event.h"
|
||
|
||
/* Number of live breakpoints. */
|
||
static int bppy_live;
|
||
|
||
/* Variables used to pass information between the Breakpoint
|
||
constructor and the breakpoint-created hook function. */
|
||
gdbpy_breakpoint_object *bppy_pending_object;
|
||
|
||
/* Function that is called when a Python condition is evaluated. */
|
||
static const char stop_func[] = "stop";
|
||
|
||
/* This is used to initialize various gdb.bp_* constants. */
|
||
struct pybp_code
|
||
{
|
||
/* The name. */
|
||
const char *name;
|
||
/* The code. */
|
||
int code;
|
||
};
|
||
|
||
/* Entries related to the type of user set breakpoints. */
|
||
static struct pybp_code pybp_codes[] =
|
||
{
|
||
{ "BP_NONE", bp_none},
|
||
{ "BP_BREAKPOINT", bp_breakpoint},
|
||
{ "BP_WATCHPOINT", bp_watchpoint},
|
||
{ "BP_HARDWARE_WATCHPOINT", bp_hardware_watchpoint},
|
||
{ "BP_READ_WATCHPOINT", bp_read_watchpoint},
|
||
{ "BP_ACCESS_WATCHPOINT", bp_access_watchpoint},
|
||
{NULL} /* Sentinel. */
|
||
};
|
||
|
||
/* Entries related to the type of watchpoint. */
|
||
static struct pybp_code pybp_watch_types[] =
|
||
{
|
||
{ "WP_READ", hw_read},
|
||
{ "WP_WRITE", hw_write},
|
||
{ "WP_ACCESS", hw_access},
|
||
{NULL} /* Sentinel. */
|
||
};
|
||
|
||
/* Python function which checks the validity of a breakpoint object. */
|
||
static PyObject *
|
||
bppy_is_valid (PyObject *self, PyObject *args)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
|
||
if (self_bp->bp)
|
||
Py_RETURN_TRUE;
|
||
Py_RETURN_FALSE;
|
||
}
|
||
|
||
/* Python function to test whether or not the breakpoint is enabled. */
|
||
static PyObject *
|
||
bppy_get_enabled (PyObject *self, void *closure)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
|
||
BPPY_REQUIRE_VALID (self_bp);
|
||
if (! self_bp->bp)
|
||
Py_RETURN_FALSE;
|
||
if (self_bp->bp->enable_state == bp_enabled)
|
||
Py_RETURN_TRUE;
|
||
Py_RETURN_FALSE;
|
||
}
|
||
|
||
/* Python function to test whether or not the breakpoint is silent. */
|
||
static PyObject *
|
||
bppy_get_silent (PyObject *self, void *closure)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
|
||
BPPY_REQUIRE_VALID (self_bp);
|
||
if (self_bp->bp->silent)
|
||
Py_RETURN_TRUE;
|
||
Py_RETURN_FALSE;
|
||
}
|
||
|
||
/* Python function to set the enabled state of a breakpoint. */
|
||
static int
|
||
bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
int cmp;
|
||
|
||
BPPY_SET_REQUIRE_VALID (self_bp);
|
||
|
||
if (newvalue == NULL)
|
||
{
|
||
PyErr_SetString (PyExc_TypeError,
|
||
_("Cannot delete `enabled' attribute."));
|
||
|
||
return -1;
|
||
}
|
||
else if (! PyBool_Check (newvalue))
|
||
{
|
||
PyErr_SetString (PyExc_TypeError,
|
||
_("The value of `enabled' must be a boolean."));
|
||
return -1;
|
||
}
|
||
|
||
cmp = PyObject_IsTrue (newvalue);
|
||
if (cmp < 0)
|
||
return -1;
|
||
|
||
TRY
|
||
{
|
||
if (cmp == 1)
|
||
enable_breakpoint (self_bp->bp);
|
||
else
|
||
disable_breakpoint (self_bp->bp);
|
||
}
|
||
CATCH (except, RETURN_MASK_ALL)
|
||
{
|
||
GDB_PY_SET_HANDLE_EXCEPTION (except);
|
||
}
|
||
END_CATCH
|
||
|
||
return 0;
|
||
}
|
||
|
||
/* Python function to set the 'silent' state of a breakpoint. */
|
||
static int
|
||
bppy_set_silent (PyObject *self, PyObject *newvalue, void *closure)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
int cmp;
|
||
|
||
BPPY_SET_REQUIRE_VALID (self_bp);
|
||
|
||
if (newvalue == NULL)
|
||
{
|
||
PyErr_SetString (PyExc_TypeError,
|
||
_("Cannot delete `silent' attribute."));
|
||
return -1;
|
||
}
|
||
else if (! PyBool_Check (newvalue))
|
||
{
|
||
PyErr_SetString (PyExc_TypeError,
|
||
_("The value of `silent' must be a boolean."));
|
||
return -1;
|
||
}
|
||
|
||
cmp = PyObject_IsTrue (newvalue);
|
||
if (cmp < 0)
|
||
return -1;
|
||
else
|
||
breakpoint_set_silent (self_bp->bp, cmp);
|
||
|
||
return 0;
|
||
}
|
||
|
||
/* Python function to set the thread of a breakpoint. */
|
||
static int
|
||
bppy_set_thread (PyObject *self, PyObject *newvalue, void *closure)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
long id;
|
||
|
||
BPPY_SET_REQUIRE_VALID (self_bp);
|
||
|
||
if (newvalue == NULL)
|
||
{
|
||
PyErr_SetString (PyExc_TypeError,
|
||
_("Cannot delete `thread' attribute."));
|
||
return -1;
|
||
}
|
||
else if (PyInt_Check (newvalue))
|
||
{
|
||
if (! gdb_py_int_as_long (newvalue, &id))
|
||
return -1;
|
||
|
||
if (!valid_global_thread_id (id))
|
||
{
|
||
PyErr_SetString (PyExc_RuntimeError,
|
||
_("Invalid thread ID."));
|
||
return -1;
|
||
}
|
||
}
|
||
else if (newvalue == Py_None)
|
||
id = -1;
|
||
else
|
||
{
|
||
PyErr_SetString (PyExc_TypeError,
|
||
_("The value of `thread' must be an integer or None."));
|
||
return -1;
|
||
}
|
||
|
||
breakpoint_set_thread (self_bp->bp, id);
|
||
|
||
return 0;
|
||
}
|
||
|
||
/* Python function to set the (Ada) task of a breakpoint. */
|
||
static int
|
||
bppy_set_task (PyObject *self, PyObject *newvalue, void *closure)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
long id;
|
||
int valid_id = 0;
|
||
|
||
BPPY_SET_REQUIRE_VALID (self_bp);
|
||
|
||
if (newvalue == NULL)
|
||
{
|
||
PyErr_SetString (PyExc_TypeError,
|
||
_("Cannot delete `task' attribute."));
|
||
return -1;
|
||
}
|
||
else if (PyInt_Check (newvalue))
|
||
{
|
||
if (! gdb_py_int_as_long (newvalue, &id))
|
||
return -1;
|
||
|
||
TRY
|
||
{
|
||
valid_id = valid_task_id (id);
|
||
}
|
||
CATCH (except, RETURN_MASK_ALL)
|
||
{
|
||
GDB_PY_SET_HANDLE_EXCEPTION (except);
|
||
}
|
||
END_CATCH
|
||
|
||
if (! valid_id)
|
||
{
|
||
PyErr_SetString (PyExc_RuntimeError,
|
||
_("Invalid task ID."));
|
||
return -1;
|
||
}
|
||
}
|
||
else if (newvalue == Py_None)
|
||
id = 0;
|
||
else
|
||
{
|
||
PyErr_SetString (PyExc_TypeError,
|
||
_("The value of `task' must be an integer or None."));
|
||
return -1;
|
||
}
|
||
|
||
breakpoint_set_task (self_bp->bp, id);
|
||
|
||
return 0;
|
||
}
|
||
|
||
/* Python function which deletes the underlying GDB breakpoint. This
|
||
triggers the breakpoint_deleted observer which will call
|
||
gdbpy_breakpoint_deleted; that function cleans up the Python
|
||
sections. */
|
||
|
||
static PyObject *
|
||
bppy_delete_breakpoint (PyObject *self, PyObject *args)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
|
||
BPPY_REQUIRE_VALID (self_bp);
|
||
|
||
TRY
|
||
{
|
||
delete_breakpoint (self_bp->bp);
|
||
}
|
||
CATCH (except, RETURN_MASK_ALL)
|
||
{
|
||
GDB_PY_HANDLE_EXCEPTION (except);
|
||
}
|
||
END_CATCH
|
||
|
||
Py_RETURN_NONE;
|
||
}
|
||
|
||
|
||
/* Python function to set the ignore count of a breakpoint. */
|
||
static int
|
||
bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
long value;
|
||
|
||
BPPY_SET_REQUIRE_VALID (self_bp);
|
||
|
||
if (newvalue == NULL)
|
||
{
|
||
PyErr_SetString (PyExc_TypeError,
|
||
_("Cannot delete `ignore_count' attribute."));
|
||
return -1;
|
||
}
|
||
else if (! PyInt_Check (newvalue))
|
||
{
|
||
PyErr_SetString (PyExc_TypeError,
|
||
_("The value of `ignore_count' must be an integer."));
|
||
return -1;
|
||
}
|
||
|
||
if (! gdb_py_int_as_long (newvalue, &value))
|
||
return -1;
|
||
|
||
if (value < 0)
|
||
value = 0;
|
||
|
||
TRY
|
||
{
|
||
set_ignore_count (self_bp->number, (int) value, 0);
|
||
}
|
||
CATCH (except, RETURN_MASK_ALL)
|
||
{
|
||
GDB_PY_SET_HANDLE_EXCEPTION (except);
|
||
}
|
||
END_CATCH
|
||
|
||
return 0;
|
||
}
|
||
|
||
/* Python function to set the hit count of a breakpoint. */
|
||
static int
|
||
bppy_set_hit_count (PyObject *self, PyObject *newvalue, void *closure)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
|
||
BPPY_SET_REQUIRE_VALID (self_bp);
|
||
|
||
if (newvalue == NULL)
|
||
{
|
||
PyErr_SetString (PyExc_TypeError,
|
||
_("Cannot delete `hit_count' attribute."));
|
||
return -1;
|
||
}
|
||
else
|
||
{
|
||
long value;
|
||
|
||
if (! gdb_py_int_as_long (newvalue, &value))
|
||
return -1;
|
||
|
||
if (value != 0)
|
||
{
|
||
PyErr_SetString (PyExc_AttributeError,
|
||
_("The value of `hit_count' must be zero."));
|
||
return -1;
|
||
}
|
||
}
|
||
|
||
self_bp->bp->hit_count = 0;
|
||
|
||
return 0;
|
||
}
|
||
|
||
/* Python function to get the location of a breakpoint. */
|
||
static PyObject *
|
||
bppy_get_location (PyObject *self, void *closure)
|
||
{
|
||
const char *str;
|
||
gdbpy_breakpoint_object *obj = (gdbpy_breakpoint_object *) self;
|
||
|
||
BPPY_REQUIRE_VALID (obj);
|
||
|
||
if (obj->bp->type != bp_breakpoint)
|
||
Py_RETURN_NONE;
|
||
|
||
str = event_location_to_string (obj->bp->location);
|
||
if (! str)
|
||
str = "";
|
||
return host_string_to_python_string (str);
|
||
}
|
||
|
||
/* Python function to get the breakpoint expression. */
|
||
static PyObject *
|
||
bppy_get_expression (PyObject *self, void *closure)
|
||
{
|
||
const char *str;
|
||
gdbpy_breakpoint_object *obj = (gdbpy_breakpoint_object *) self;
|
||
struct watchpoint *wp;
|
||
|
||
BPPY_REQUIRE_VALID (obj);
|
||
|
||
if (!is_watchpoint (obj->bp))
|
||
Py_RETURN_NONE;
|
||
|
||
wp = (struct watchpoint *) obj->bp;
|
||
|
||
str = wp->exp_string;
|
||
if (! str)
|
||
str = "";
|
||
|
||
return host_string_to_python_string (str);
|
||
}
|
||
|
||
/* Python function to get the condition expression of a breakpoint. */
|
||
static PyObject *
|
||
bppy_get_condition (PyObject *self, void *closure)
|
||
{
|
||
char *str;
|
||
gdbpy_breakpoint_object *obj = (gdbpy_breakpoint_object *) self;
|
||
|
||
BPPY_REQUIRE_VALID (obj);
|
||
|
||
str = obj->bp->cond_string;
|
||
if (! str)
|
||
Py_RETURN_NONE;
|
||
|
||
return host_string_to_python_string (str);
|
||
}
|
||
|
||
/* Returns 0 on success. Returns -1 on error, with a python exception set.
|
||
*/
|
||
|
||
static int
|
||
bppy_set_condition (PyObject *self, PyObject *newvalue, void *closure)
|
||
{
|
||
gdb::unique_xmalloc_ptr<char> exp_holder;
|
||
const char *exp = NULL;
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
struct gdb_exception except = exception_none;
|
||
|
||
BPPY_SET_REQUIRE_VALID (self_bp);
|
||
|
||
if (newvalue == NULL)
|
||
{
|
||
PyErr_SetString (PyExc_TypeError,
|
||
_("Cannot delete `condition' attribute."));
|
||
return -1;
|
||
}
|
||
else if (newvalue == Py_None)
|
||
exp = "";
|
||
else
|
||
{
|
||
exp_holder = python_string_to_host_string (newvalue);
|
||
if (exp_holder == NULL)
|
||
return -1;
|
||
exp = exp_holder.get ();
|
||
}
|
||
|
||
TRY
|
||
{
|
||
set_breakpoint_condition (self_bp->bp, exp, 0);
|
||
}
|
||
CATCH (ex, RETURN_MASK_ALL)
|
||
{
|
||
except = ex;
|
||
}
|
||
END_CATCH
|
||
|
||
GDB_PY_SET_HANDLE_EXCEPTION (except);
|
||
|
||
return 0;
|
||
}
|
||
|
||
/* Python function to get the commands attached to a breakpoint. */
|
||
static PyObject *
|
||
bppy_get_commands (PyObject *self, void *closure)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
struct breakpoint *bp = self_bp->bp;
|
||
long length;
|
||
PyObject *result;
|
||
|
||
BPPY_REQUIRE_VALID (self_bp);
|
||
|
||
if (! self_bp->bp->commands)
|
||
Py_RETURN_NONE;
|
||
|
||
string_file stb;
|
||
|
||
current_uiout->redirect (&stb);
|
||
TRY
|
||
{
|
||
print_command_lines (current_uiout, breakpoint_commands (bp), 0);
|
||
}
|
||
CATCH (except, RETURN_MASK_ALL)
|
||
{
|
||
current_uiout->redirect (NULL);
|
||
gdbpy_convert_exception (except);
|
||
return NULL;
|
||
}
|
||
END_CATCH
|
||
|
||
current_uiout->redirect (NULL);
|
||
return host_string_to_python_string (stb.c_str ());
|
||
}
|
||
|
||
/* Python function to get the breakpoint type. */
|
||
static PyObject *
|
||
bppy_get_type (PyObject *self, void *closure)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
|
||
BPPY_REQUIRE_VALID (self_bp);
|
||
|
||
return PyInt_FromLong (self_bp->bp->type);
|
||
}
|
||
|
||
/* Python function to get the visibility of the breakpoint. */
|
||
|
||
static PyObject *
|
||
bppy_get_visibility (PyObject *self, void *closure)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
|
||
BPPY_REQUIRE_VALID (self_bp);
|
||
|
||
if (user_breakpoint_p (self_bp->bp))
|
||
Py_RETURN_TRUE;
|
||
|
||
Py_RETURN_FALSE;
|
||
}
|
||
|
||
/* Python function to determine if the breakpoint is a temporary
|
||
breakpoint. */
|
||
|
||
static PyObject *
|
||
bppy_get_temporary (PyObject *self, void *closure)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
|
||
BPPY_REQUIRE_VALID (self_bp);
|
||
|
||
if (self_bp->bp->disposition == disp_del
|
||
|| self_bp->bp->disposition == disp_del_at_next_stop)
|
||
Py_RETURN_TRUE;
|
||
|
||
Py_RETURN_FALSE;
|
||
}
|
||
|
||
/* Python function to determine if the breakpoint is a pending
|
||
breakpoint. */
|
||
|
||
static PyObject *
|
||
bppy_get_pending (PyObject *self, void *closure)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
|
||
BPPY_REQUIRE_VALID (self_bp);
|
||
|
||
if (is_watchpoint (self_bp->bp))
|
||
Py_RETURN_FALSE;
|
||
if (pending_breakpoint_p (self_bp->bp))
|
||
Py_RETURN_TRUE;
|
||
|
||
Py_RETURN_FALSE;
|
||
}
|
||
|
||
/* Python function to get the breakpoint's number. */
|
||
static PyObject *
|
||
bppy_get_number (PyObject *self, void *closure)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
|
||
BPPY_REQUIRE_VALID (self_bp);
|
||
|
||
return PyInt_FromLong (self_bp->number);
|
||
}
|
||
|
||
/* Python function to get the breakpoint's thread ID. */
|
||
static PyObject *
|
||
bppy_get_thread (PyObject *self, void *closure)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
|
||
BPPY_REQUIRE_VALID (self_bp);
|
||
|
||
if (self_bp->bp->thread == -1)
|
||
Py_RETURN_NONE;
|
||
|
||
return PyInt_FromLong (self_bp->bp->thread);
|
||
}
|
||
|
||
/* Python function to get the breakpoint's task ID (in Ada). */
|
||
static PyObject *
|
||
bppy_get_task (PyObject *self, void *closure)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
|
||
BPPY_REQUIRE_VALID (self_bp);
|
||
|
||
if (self_bp->bp->task == 0)
|
||
Py_RETURN_NONE;
|
||
|
||
return PyInt_FromLong (self_bp->bp->task);
|
||
}
|
||
|
||
/* Python function to get the breakpoint's hit count. */
|
||
static PyObject *
|
||
bppy_get_hit_count (PyObject *self, void *closure)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
|
||
BPPY_REQUIRE_VALID (self_bp);
|
||
|
||
return PyInt_FromLong (self_bp->bp->hit_count);
|
||
}
|
||
|
||
/* Python function to get the breakpoint's ignore count. */
|
||
static PyObject *
|
||
bppy_get_ignore_count (PyObject *self, void *closure)
|
||
{
|
||
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
|
||
|
||
BPPY_REQUIRE_VALID (self_bp);
|
||
|
||
return PyInt_FromLong (self_bp->bp->ignore_count);
|
||
}
|
||
|
||
/* Python function to create a new breakpoint. */
|
||
static int
|
||
bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
|
||
{
|
||
static const char *keywords[] = { "spec", "type", "wp_class", "internal",
|
||
"temporary", NULL };
|
||
const char *spec;
|
||
int type = bp_breakpoint;
|
||
int access_type = hw_write;
|
||
PyObject *internal = NULL;
|
||
PyObject *temporary = NULL;
|
||
int internal_bp = 0;
|
||
int temporary_bp = 0;
|
||
|
||
if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "s|iiOO", keywords,
|
||
&spec, &type, &access_type,
|
||
&internal, &temporary))
|
||
return -1;
|
||
|
||
if (internal)
|
||
{
|
||
internal_bp = PyObject_IsTrue (internal);
|
||
if (internal_bp == -1)
|
||
return -1;
|
||
}
|
||
|
||
if (temporary != NULL)
|
||
{
|
||
temporary_bp = PyObject_IsTrue (temporary);
|
||
if (temporary_bp == -1)
|
||
return -1;
|
||
}
|
||
|
||
bppy_pending_object = (gdbpy_breakpoint_object *) self;
|
||
bppy_pending_object->number = -1;
|
||
bppy_pending_object->bp = NULL;
|
||
|
||
TRY
|
||
{
|
||
gdb::unique_xmalloc_ptr<char>
|
||
copy_holder (xstrdup (skip_spaces_const (spec)));
|
||
char *copy = copy_holder.get ();
|
||
|
||
switch (type)
|
||
{
|
||
case bp_breakpoint:
|
||
{
|
||
struct event_location *location;
|
||
struct cleanup *cleanup;
|
||
|
||
location
|
||
= string_to_event_location_basic (©, current_language);
|
||
cleanup = make_cleanup_delete_event_location (location);
|
||
create_breakpoint (python_gdbarch,
|
||
location, NULL, -1, NULL,
|
||
0,
|
||
temporary_bp, bp_breakpoint,
|
||
0,
|
||
AUTO_BOOLEAN_TRUE,
|
||
&bkpt_breakpoint_ops,
|
||
0, 1, internal_bp, 0);
|
||
|
||
do_cleanups (cleanup);
|
||
break;
|
||
}
|
||
case bp_watchpoint:
|
||
{
|
||
if (access_type == hw_write)
|
||
watch_command_wrapper (copy, 0, internal_bp);
|
||
else if (access_type == hw_access)
|
||
awatch_command_wrapper (copy, 0, internal_bp);
|
||
else if (access_type == hw_read)
|
||
rwatch_command_wrapper (copy, 0, internal_bp);
|
||
else
|
||
error(_("Cannot understand watchpoint access type."));
|
||
break;
|
||
}
|
||
default:
|
||
error(_("Do not understand breakpoint type to set."));
|
||
}
|
||
}
|
||
CATCH (except, RETURN_MASK_ALL)
|
||
{
|
||
bppy_pending_object = NULL;
|
||
PyErr_Format (except.reason == RETURN_QUIT
|
||
? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
|
||
"%s", except.message);
|
||
return -1;
|
||
}
|
||
END_CATCH
|
||
|
||
BPPY_SET_REQUIRE_VALID ((gdbpy_breakpoint_object *) self);
|
||
return 0;
|
||
}
|
||
|
||
|
||
|
||
static int
|
||
build_bp_list (struct breakpoint *b, void *arg)
|
||
{
|
||
PyObject *list = (PyObject *) arg;
|
||
PyObject *bp = (PyObject *) b->py_bp_object;
|
||
int iserr = 0;
|
||
|
||
/* Not all breakpoints will have a companion Python object.
|
||
Only breakpoints that were created via bppy_new, or
|
||
breakpoints that were created externally and are tracked by
|
||
the Python Scripting API. */
|
||
if (bp)
|
||
iserr = PyList_Append (list, bp);
|
||
|
||
if (iserr == -1)
|
||
return 1;
|
||
|
||
return 0;
|
||
}
|
||
|
||
/* Static function to return a tuple holding all breakpoints. */
|
||
|
||
PyObject *
|
||
gdbpy_breakpoints (PyObject *self, PyObject *args)
|
||
{
|
||
if (bppy_live == 0)
|
||
return PyTuple_New (0);
|
||
|
||
gdbpy_ref<> list (PyList_New (0));
|
||
if (list == NULL)
|
||
return NULL;
|
||
|
||
/* If iterate_over_breakpoints returns non NULL it signals an error
|
||
condition. In that case abandon building the list and return
|
||
NULL. */
|
||
if (iterate_over_breakpoints (build_bp_list, list.get ()) != NULL)
|
||
return NULL;
|
||
|
||
return PyList_AsTuple (list.get ());
|
||
}
|
||
|
||
/* Call the "stop" method (if implemented) in the breakpoint
|
||
class. If the method returns True, the inferior will be
|
||
stopped at the breakpoint. Otherwise the inferior will be
|
||
allowed to continue. */
|
||
|
||
enum ext_lang_bp_stop
|
||
gdbpy_breakpoint_cond_says_stop (const struct extension_language_defn *extlang,
|
||
struct breakpoint *b)
|
||
{
|
||
int stop;
|
||
struct gdbpy_breakpoint_object *bp_obj = b->py_bp_object;
|
||
PyObject *py_bp = (PyObject *) bp_obj;
|
||
struct gdbarch *garch;
|
||
|
||
if (bp_obj == NULL)
|
||
return EXT_LANG_BP_STOP_UNSET;
|
||
|
||
stop = -1;
|
||
garch = b->gdbarch ? b->gdbarch : get_current_arch ();
|
||
|
||
gdbpy_enter enter_py (garch, current_language);
|
||
|
||
if (bp_obj->is_finish_bp)
|
||
bpfinishpy_pre_stop_hook (bp_obj);
|
||
|
||
if (PyObject_HasAttrString (py_bp, stop_func))
|
||
{
|
||
gdbpy_ref<> result (PyObject_CallMethod (py_bp, stop_func, NULL));
|
||
|
||
stop = 1;
|
||
if (result != NULL)
|
||
{
|
||
int evaluate = PyObject_IsTrue (result.get ());
|
||
|
||
if (evaluate == -1)
|
||
gdbpy_print_stack ();
|
||
|
||
/* If the "stop" function returns False that means
|
||
the Python breakpoint wants GDB to continue. */
|
||
if (! evaluate)
|
||
stop = 0;
|
||
}
|
||
else
|
||
gdbpy_print_stack ();
|
||
}
|
||
|
||
if (bp_obj->is_finish_bp)
|
||
bpfinishpy_post_stop_hook (bp_obj);
|
||
|
||
if (stop < 0)
|
||
return EXT_LANG_BP_STOP_UNSET;
|
||
return stop ? EXT_LANG_BP_STOP_YES : EXT_LANG_BP_STOP_NO;
|
||
}
|
||
|
||
/* Checks if the "stop" method exists in this breakpoint.
|
||
Used by condition_command to ensure mutual exclusion of breakpoint
|
||
conditions. */
|
||
|
||
int
|
||
gdbpy_breakpoint_has_cond (const struct extension_language_defn *extlang,
|
||
struct breakpoint *b)
|
||
{
|
||
PyObject *py_bp;
|
||
struct gdbarch *garch;
|
||
|
||
if (b->py_bp_object == NULL)
|
||
return 0;
|
||
|
||
py_bp = (PyObject *) b->py_bp_object;
|
||
garch = b->gdbarch ? b->gdbarch : get_current_arch ();
|
||
|
||
gdbpy_enter enter_py (garch, current_language);
|
||
return PyObject_HasAttrString (py_bp, stop_func);
|
||
}
|
||
|
||
|
||
|
||
/* Event callback functions. */
|
||
|
||
/* Callback that is used when a breakpoint is created. This function
|
||
will create a new Python breakpoint object. */
|
||
static void
|
||
gdbpy_breakpoint_created (struct breakpoint *bp)
|
||
{
|
||
gdbpy_breakpoint_object *newbp;
|
||
PyGILState_STATE state;
|
||
|
||
if (!user_breakpoint_p (bp) && bppy_pending_object == NULL)
|
||
return;
|
||
|
||
if (bp->type != bp_breakpoint
|
||
&& bp->type != bp_watchpoint
|
||
&& bp->type != bp_hardware_watchpoint
|
||
&& bp->type != bp_read_watchpoint
|
||
&& bp->type != bp_access_watchpoint)
|
||
return;
|
||
|
||
state = PyGILState_Ensure ();
|
||
|
||
if (bppy_pending_object)
|
||
{
|
||
newbp = bppy_pending_object;
|
||
bppy_pending_object = NULL;
|
||
}
|
||
else
|
||
newbp = PyObject_New (gdbpy_breakpoint_object, &breakpoint_object_type);
|
||
if (newbp)
|
||
{
|
||
newbp->number = bp->number;
|
||
newbp->bp = bp;
|
||
newbp->bp->py_bp_object = newbp;
|
||
newbp->is_finish_bp = 0;
|
||
Py_INCREF (newbp);
|
||
++bppy_live;
|
||
}
|
||
else
|
||
{
|
||
PyErr_SetString (PyExc_RuntimeError,
|
||
_("Error while creating breakpoint from GDB."));
|
||
gdbpy_print_stack ();
|
||
}
|
||
|
||
if (!evregpy_no_listeners_p (gdb_py_events.breakpoint_created))
|
||
{
|
||
if (evpy_emit_event ((PyObject *) newbp,
|
||
gdb_py_events.breakpoint_created) < 0)
|
||
gdbpy_print_stack ();
|
||
}
|
||
|
||
PyGILState_Release (state);
|
||
}
|
||
|
||
/* Callback that is used when a breakpoint is deleted. This will
|
||
invalidate the corresponding Python object. */
|
||
static void
|
||
gdbpy_breakpoint_deleted (struct breakpoint *b)
|
||
{
|
||
int num = b->number;
|
||
PyGILState_STATE state;
|
||
struct breakpoint *bp = NULL;
|
||
|
||
state = PyGILState_Ensure ();
|
||
bp = get_breakpoint (num);
|
||
if (bp)
|
||
{
|
||
gdbpy_ref<gdbpy_breakpoint_object> bp_obj (bp->py_bp_object);
|
||
if (bp_obj != NULL)
|
||
{
|
||
if (!evregpy_no_listeners_p (gdb_py_events.breakpoint_deleted))
|
||
{
|
||
if (evpy_emit_event ((PyObject *) bp_obj.get (),
|
||
gdb_py_events.breakpoint_deleted) < 0)
|
||
gdbpy_print_stack ();
|
||
}
|
||
|
||
bp_obj->bp = NULL;
|
||
--bppy_live;
|
||
}
|
||
}
|
||
PyGILState_Release (state);
|
||
}
|
||
|
||
/* Callback that is used when a breakpoint is modified. */
|
||
|
||
static void
|
||
gdbpy_breakpoint_modified (struct breakpoint *b)
|
||
{
|
||
int num = b->number;
|
||
PyGILState_STATE state;
|
||
struct breakpoint *bp = NULL;
|
||
gdbpy_breakpoint_object *bp_obj;
|
||
|
||
state = PyGILState_Ensure ();
|
||
bp = get_breakpoint (num);
|
||
if (bp)
|
||
{
|
||
PyObject *bp_obj = (PyObject *) bp->py_bp_object;
|
||
if (bp_obj)
|
||
{
|
||
if (!evregpy_no_listeners_p (gdb_py_events.breakpoint_modified))
|
||
{
|
||
if (evpy_emit_event (bp_obj,
|
||
gdb_py_events.breakpoint_modified) < 0)
|
||
gdbpy_print_stack ();
|
||
}
|
||
}
|
||
}
|
||
PyGILState_Release (state);
|
||
}
|
||
|
||
|
||
|
||
/* Initialize the Python breakpoint code. */
|
||
int
|
||
gdbpy_initialize_breakpoints (void)
|
||
{
|
||
int i;
|
||
|
||
breakpoint_object_type.tp_new = PyType_GenericNew;
|
||
if (PyType_Ready (&breakpoint_object_type) < 0)
|
||
return -1;
|
||
|
||
if (gdb_pymodule_addobject (gdb_module, "Breakpoint",
|
||
(PyObject *) &breakpoint_object_type) < 0)
|
||
return -1;
|
||
|
||
observer_attach_breakpoint_created (gdbpy_breakpoint_created);
|
||
observer_attach_breakpoint_deleted (gdbpy_breakpoint_deleted);
|
||
observer_attach_breakpoint_modified (gdbpy_breakpoint_modified);
|
||
|
||
/* Add breakpoint types constants. */
|
||
for (i = 0; pybp_codes[i].name; ++i)
|
||
{
|
||
if (PyModule_AddIntConstant (gdb_module,
|
||
/* Cast needed for Python 2.4. */
|
||
(char *) pybp_codes[i].name,
|
||
pybp_codes[i].code) < 0)
|
||
return -1;
|
||
}
|
||
|
||
/* Add watchpoint types constants. */
|
||
for (i = 0; pybp_watch_types[i].name; ++i)
|
||
{
|
||
if (PyModule_AddIntConstant (gdb_module,
|
||
/* Cast needed for Python 2.4. */
|
||
(char *) pybp_watch_types[i].name,
|
||
pybp_watch_types[i].code) < 0)
|
||
return -1;
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
|
||
|
||
/* Helper function that overrides this Python object's
|
||
PyObject_GenericSetAttr to allow extra validation of the attribute
|
||
being set. */
|
||
|
||
static int
|
||
local_setattro (PyObject *self, PyObject *name, PyObject *v)
|
||
{
|
||
gdbpy_breakpoint_object *obj = (gdbpy_breakpoint_object *) self;
|
||
gdb::unique_xmalloc_ptr<char> attr (python_string_to_host_string (name));
|
||
|
||
if (attr == NULL)
|
||
return -1;
|
||
|
||
/* If the attribute trying to be set is the "stop" method,
|
||
but we already have a condition set in the CLI or other extension
|
||
language, disallow this operation. */
|
||
if (strcmp (attr.get (), stop_func) == 0)
|
||
{
|
||
const struct extension_language_defn *extlang = NULL;
|
||
|
||
if (obj->bp->cond_string != NULL)
|
||
extlang = get_ext_lang_defn (EXT_LANG_GDB);
|
||
if (extlang == NULL)
|
||
extlang = get_breakpoint_cond_ext_lang (obj->bp, EXT_LANG_PYTHON);
|
||
if (extlang != NULL)
|
||
{
|
||
char *error_text;
|
||
|
||
error_text
|
||
= xstrprintf (_("Only one stop condition allowed. There is"
|
||
" currently a %s stop condition defined for"
|
||
" this breakpoint."),
|
||
ext_lang_capitalized_name (extlang));
|
||
PyErr_SetString (PyExc_RuntimeError, error_text);
|
||
xfree (error_text);
|
||
return -1;
|
||
}
|
||
}
|
||
|
||
return PyObject_GenericSetAttr ((PyObject *)self, name, v);
|
||
}
|
||
|
||
static gdb_PyGetSetDef breakpoint_object_getset[] = {
|
||
{ "enabled", bppy_get_enabled, bppy_set_enabled,
|
||
"Boolean telling whether the breakpoint is enabled.", NULL },
|
||
{ "silent", bppy_get_silent, bppy_set_silent,
|
||
"Boolean telling whether the breakpoint is silent.", NULL },
|
||
{ "thread", bppy_get_thread, bppy_set_thread,
|
||
"Thread ID for the breakpoint.\n\
|
||
If the value is a thread ID (integer), then this is a thread-specific breakpoint.\n\
|
||
If the value is None, then this breakpoint is not thread-specific.\n\
|
||
No other type of value can be used.", NULL },
|
||
{ "task", bppy_get_task, bppy_set_task,
|
||
"Thread ID for the breakpoint.\n\
|
||
If the value is a task ID (integer), then this is an Ada task-specific breakpoint.\n\
|
||
If the value is None, then this breakpoint is not task-specific.\n\
|
||
No other type of value can be used.", NULL },
|
||
{ "ignore_count", bppy_get_ignore_count, bppy_set_ignore_count,
|
||
"Number of times this breakpoint should be automatically continued.",
|
||
NULL },
|
||
{ "number", bppy_get_number, NULL,
|
||
"Breakpoint's number assigned by GDB.", NULL },
|
||
{ "hit_count", bppy_get_hit_count, bppy_set_hit_count,
|
||
"Number of times the breakpoint has been hit.\n\
|
||
Can be set to zero to clear the count. No other value is valid\n\
|
||
when setting this property.", NULL },
|
||
{ "location", bppy_get_location, NULL,
|
||
"Location of the breakpoint, as specified by the user.", NULL},
|
||
{ "expression", bppy_get_expression, NULL,
|
||
"Expression of the breakpoint, as specified by the user.", NULL},
|
||
{ "condition", bppy_get_condition, bppy_set_condition,
|
||
"Condition of the breakpoint, as specified by the user,\
|
||
or None if no condition set."},
|
||
{ "commands", bppy_get_commands, NULL,
|
||
"Commands of the breakpoint, as specified by the user."},
|
||
{ "type", bppy_get_type, NULL,
|
||
"Type of breakpoint."},
|
||
{ "visible", bppy_get_visibility, NULL,
|
||
"Whether the breakpoint is visible to the user."},
|
||
{ "temporary", bppy_get_temporary, NULL,
|
||
"Whether this breakpoint is a temporary breakpoint."},
|
||
{ "pending", bppy_get_pending, NULL,
|
||
"Whether this breakpoint is a pending breakpoint."},
|
||
{ NULL } /* Sentinel. */
|
||
};
|
||
|
||
static PyMethodDef breakpoint_object_methods[] =
|
||
{
|
||
{ "is_valid", bppy_is_valid, METH_NOARGS,
|
||
"Return true if this breakpoint is valid, false if not." },
|
||
{ "delete", bppy_delete_breakpoint, METH_NOARGS,
|
||
"Delete the underlying GDB breakpoint." },
|
||
{ NULL } /* Sentinel. */
|
||
};
|
||
|
||
PyTypeObject breakpoint_object_type =
|
||
{
|
||
PyVarObject_HEAD_INIT (NULL, 0)
|
||
"gdb.Breakpoint", /*tp_name*/
|
||
sizeof (gdbpy_breakpoint_object), /*tp_basicsize*/
|
||
0, /*tp_itemsize*/
|
||
0, /*tp_dealloc*/
|
||
0, /*tp_print*/
|
||
0, /*tp_getattr*/
|
||
0, /*tp_setattr*/
|
||
0, /*tp_compare*/
|
||
0, /*tp_repr*/
|
||
0, /*tp_as_number*/
|
||
0, /*tp_as_sequence*/
|
||
0, /*tp_as_mapping*/
|
||
0, /*tp_hash */
|
||
0, /*tp_call*/
|
||
0, /*tp_str*/
|
||
0, /*tp_getattro*/
|
||
(setattrofunc)local_setattro, /*tp_setattro */
|
||
0, /*tp_as_buffer*/
|
||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
||
"GDB breakpoint object", /* tp_doc */
|
||
0, /* tp_traverse */
|
||
0, /* tp_clear */
|
||
0, /* tp_richcompare */
|
||
0, /* tp_weaklistoffset */
|
||
0, /* tp_iter */
|
||
0, /* tp_iternext */
|
||
breakpoint_object_methods, /* tp_methods */
|
||
0, /* tp_members */
|
||
breakpoint_object_getset, /* tp_getset */
|
||
0, /* tp_base */
|
||
0, /* tp_dict */
|
||
0, /* tp_descr_get */
|
||
0, /* tp_descr_set */
|
||
0, /* tp_dictoffset */
|
||
bppy_init, /* tp_init */
|
||
0, /* tp_alloc */
|
||
};
|