123 if (newvalue == NULL)
125 PyErr_SetString (PyExc_TypeError,
126 _(
"Cannot delete `enabled' attribute."));
130 else if (! PyBool_Check (newvalue))
132 PyErr_SetString (PyExc_TypeError,
133 _(
"The value of `enabled' must be a boolean."));
137 cmp = PyObject_IsTrue (newvalue);
166 if (newvalue == NULL)
168 PyErr_SetString (PyExc_TypeError,
169 _(
"Cannot delete `silent' attribute."));
172 else if (! PyBool_Check (newvalue))
174 PyErr_SetString (PyExc_TypeError,
175 _(
"The value of `silent' must be a boolean."));
179 cmp = PyObject_IsTrue (newvalue);
197 if (newvalue == NULL)
199 PyErr_SetString (PyExc_TypeError,
200 _(
"Cannot delete `thread' attribute."));
203 else if (PyInt_Check (newvalue))
210 PyErr_SetString (PyExc_RuntimeError,
211 _(
"Invalid thread ID."));
215 else if (newvalue == Py_None)
219 PyErr_SetString (PyExc_TypeError,
220 _(
"The value of `thread' must be an integer or None."));
239 if (newvalue == NULL)
241 PyErr_SetString (PyExc_TypeError,
242 _(
"Cannot delete `task' attribute."));
245 else if (PyInt_Check (newvalue))
262 PyErr_SetString (PyExc_RuntimeError,
263 _(
"Invalid task ID."));
267 else if (newvalue == Py_None)
271 PyErr_SetString (PyExc_TypeError,
272 _(
"The value of `task' must be an integer or None."));
316 if (newvalue == NULL)
318 PyErr_SetString (PyExc_TypeError,
319 _(
"Cannot delete `ignore_count' attribute."));
322 else if (! PyInt_Check (newvalue))
324 PyErr_SetString (PyExc_TypeError,
325 _(
"The value of `ignore_count' must be an integer."));
356 if (newvalue == NULL)
358 PyErr_SetString (PyExc_TypeError,
359 _(
"Cannot delete `hit_count' attribute."));
371 PyErr_SetString (PyExc_AttributeError,
372 _(
"The value of `hit_count' must be zero."));
445 const char *
exp = NULL;
451 if (newvalue == NULL)
453 PyErr_SetString (PyExc_TypeError,
454 _(
"Cannot delete `condition' attribute."));
457 else if (newvalue == Py_None)
462 if (exp_holder == NULL)
464 exp = exp_holder.get ();
521 return PyInt_FromLong (self_bp->
bp->
type);
582 return PyInt_FromLong (self_bp->
number);
596 return PyInt_FromLong (self_bp->
bp->
thread);
607 if (self_bp->
bp->
task == 0)
610 return PyInt_FromLong (self_bp->
bp->
task);
640 char *
function,
char *label,
647 if (source != NULL ||
function != NULL || label != NULL || line != NULL)
649 PyErr_SetString (PyExc_RuntimeError,
650 _(
"Breakpoints specified with spec cannot " 651 "have source, function, label or line defined."));
661 PyErr_SetString (PyExc_RuntimeError,
662 _(
"Watchpoints cannot be set by explicit " 663 "location parameters."));
669 if (source == NULL &&
function == NULL && label == NULL
672 PyErr_SetString (PyExc_RuntimeError,
673 _(
"Neither spec nor explicit location set."));
678 if (source != NULL &&
function == NULL && label == NULL
681 PyErr_SetString (PyExc_RuntimeError,
682 _(
"Specifying a source must also include a " 683 "line, label or function."));
693 bppy_init (PyObject *
self, PyObject *args, PyObject *kwargs)
695 static const char *keywords[] = {
"spec",
"type",
"wp_class",
"internal",
696 "temporary",
"source",
"function",
697 "label",
"line",
"qualified", NULL };
698 const char *spec = NULL;
701 PyObject *
internal = NULL;
702 PyObject *temporary = NULL;
703 PyObject *lineobj = NULL;;
705 int temporary_bp = 0;
709 char *
function = NULL;
710 PyObject * qualified = NULL;
713 &spec, &
type, &access_type,
716 &
function, &label, &lineobj,
723 if (PyInt_Check (lineobj))
724 line.reset (
xstrprintf (
"%ld", PyInt_AsLong (lineobj)));
725 else if (PyString_Check (lineobj))
729 PyErr_SetString (PyExc_RuntimeError,
730 _(
"Line keyword should be an integer or a string. "));
737 internal_bp = PyObject_IsTrue (
internal);
738 if (internal_bp == -1)
742 if (temporary != NULL)
744 temporary_bp = PyObject_IsTrue (temporary);
745 if (temporary_bp == -1)
765 = (qualified != NULL && PyObject_IsTrue (qualified)
773 const char *copy = copy_holder.get ();
777 func_name_match_type);
798 location.get (), NULL, -1, NULL,
804 0, 1, internal_bp, 0);
811 char *copy = copy_holder.get ();
817 else if (access_type ==
hw_read)
820 error(
_(
"Cannot understand watchpoint access type."));
824 error(
_(
"Do not understand breakpoint type to set."));
831 ? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
832 "%s", except.message);
846 PyObject *list = (PyObject *) arg;
855 iserr = PyList_Append (list,
bp);
869 return PyTuple_New (0);
881 return PyList_AsTuple (list.
get ());
895 PyObject *py_bp = (PyObject *) bp_obj;
916 int evaluate = PyObject_IsTrue (result.
get ());
969 PyGILState_STATE state;
1001 PyErr_SetString (PyExc_RuntimeError,
1002 _(
"Error while creating breakpoint from GDB."));
1022 PyGILState_STATE state;
1052 PyGILState_STATE state;
1059 PyObject *bp_obj = (PyObject *)
bp->py_bp_object;
1134 if (strcmp (attr.get (),
stop_func) == 0)
1140 if (extlang == NULL)
1142 if (extlang != NULL)
1146 " currently a %s stop condition defined for" 1147 " this breakpoint."),
1149 PyErr_SetString (PyExc_RuntimeError, error_text.c_str ());
1154 return PyObject_GenericSetAttr ((PyObject *)
self,
name, v);
1159 "Boolean telling whether the breakpoint is enabled.", NULL },
1161 "Boolean telling whether the breakpoint is silent.", NULL },
1163 "Thread ID for the breakpoint.\n\ 1164 If the value is a thread ID (integer), then this is a thread-specific breakpoint.\n\ 1165 If the value is None, then this breakpoint is not thread-specific.\n\ 1166 No other type of value can be used.", NULL },
1168 "Thread ID for the breakpoint.\n\ 1169 If the value is a task ID (integer), then this is an Ada task-specific breakpoint.\n\ 1170 If the value is None, then this breakpoint is not task-specific.\n\ 1171 No other type of value can be used.", NULL },
1173 "Number of times this breakpoint should be automatically continued.",
1176 "Breakpoint's number assigned by GDB.", NULL },
1178 "Number of times the breakpoint has been hit.\n\ 1179 Can be set to zero to clear the count. No other value is valid\n\ 1180 when setting this property.", NULL },
1182 "Location of the breakpoint, as specified by the user.", NULL},
1184 "Expression of the breakpoint, as specified by the user.", NULL},
1186 "Condition of the breakpoint, as specified by the user,\ 1187 or None if no condition set."},
1189 "Commands of the breakpoint, as specified by the user."},
1191 "Type of breakpoint."},
1193 "Whether the breakpoint is visible to the user."},
1195 "Whether this breakpoint is a temporary breakpoint."},
1197 "Whether this breakpoint is a pending breakpoint."},
1204 "Return true if this breakpoint is valid, false if not." },
1206 "Delete the underlying GDB breakpoint." },
1231 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
1232 "GDB breakpoint object",
static void gdbpy_breakpoint_deleted(struct breakpoint *b)
static int local_setattro(PyObject *self, PyObject *name, PyObject *v)
int gdb_pymodule_addobject(PyObject *module, const char *name, PyObject *object)
PyObject * gdbpy_breakpoints(PyObject *self, PyObject *args)
static struct pybp_code pybp_codes[]
static PyObject * bppy_get_visibility(PyObject *self, void *closure)
struct command_line * breakpoint_commands(struct breakpoint *b)
struct observer * observer_attach_breakpoint_deleted(observer_breakpoint_deleted_ftype *f)
void bpfinishpy_pre_stop_hook(struct gdbpy_breakpoint_object *bp_obj)
void set_ignore_count(int bptnum, int count, int from_tty)
static PyObject * bppy_get_type(PyObject *self, void *closure)
static PyObject * bppy_is_valid(PyObject *self, PyObject *args)
gdbpy_breakpoint_object * bppy_pending_object
static int bppy_set_ignore_count(PyObject *self, PyObject *newvalue, void *closure)
static PyObject * bppy_get_condition(PyObject *self, void *closure)
int gdbpy_initialize_breakpoints(void)
static PyMethodDef breakpoint_object_methods[]
#define BPPY_REQUIRE_VALID(Breakpoint)
counted_command_line commands
static const char stop_func[]
int valid_global_thread_id(int global_id)
void awatch_command_wrapper(const char *arg, int from_tty, int internal)
const struct gdb_exception exception_none
struct line_offset line_offset
struct gdbpy_breakpoint_object gdbpy_breakpoint_object
char * skip_spaces(char *chp)
static int gdb_PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, const char **keywords,...)
#define PyVarObject_HEAD_INIT(type, size)
static PyObject * bppy_get_thread(PyObject *self, void *closure)
static int bppy_set_enabled(PyObject *self, PyObject *newvalue, void *closure)
void enable_breakpoint(struct breakpoint *bpt)
void breakpoint_set_task(struct breakpoint *b, int task)
void initialize_explicit_location(struct explicit_location *explicit_loc)
int gdbpy_breakpoint_has_cond(const struct extension_language_defn *extlang, struct breakpoint *b)
#define GDB_PY_HANDLE_EXCEPTION(Exception)
static int build_bp_list(struct breakpoint *b, void *arg)
#define PyGILState_Ensure()
PyObject * host_string_to_python_string(const char *str)
#define CATCH(EXCEPTION, MASK)
std::unique_ptr< T, xfree_deleter< T > > unique_xmalloc_ptr
static PyObject * bppy_get_task(PyObject *self, void *closure)
int pending_breakpoint_p(struct breakpoint *b)
static PyObject * bppy_get_location(PyObject *self, void *closure)
struct breakpoint * iterate_over_breakpoints(int(*callback)(struct breakpoint *, void *), void *data)
gdbpy_breakpoint_object * py_bp_object
enum ext_lang_bp_stop gdbpy_breakpoint_cond_says_stop(const struct extension_language_defn *extlang, struct breakpoint *b)
int is_watchpoint(const struct breakpoint *bpt)
#define PyGILState_Release(ARG)
struct observer * observer_attach_breakpoint_created(observer_breakpoint_created_ftype *f)
static int bppy_set_thread(PyObject *self, PyObject *newvalue, void *closure)
static void gdbpy_breakpoint_modified(struct breakpoint *b)
static int bppy_set_silent(PyObject *self, PyObject *newvalue, void *closure)
void disable_breakpoint(struct breakpoint *bpt)
#define BPPY_SET_REQUIRE_VALID(Breakpoint)
#define GDB_PY_SET_HANDLE_EXCEPTION(Exception)
struct gdbarch * get_current_arch(void)
struct gdbarch * python_gdbarch
static PyObject * bppy_get_hit_count(PyObject *self, void *closure)
struct breakpoint * get_breakpoint(int num)
event_location_up new_explicit_location(const struct explicit_location *explicit_loc)
std::unique_ptr< event_location, event_location_deleter > event_location_up
gdb::unique_xmalloc_ptr< char > python_string_to_host_string(PyObject *obj)
static struct pybp_code pybp_watch_types[]
const char * event_location_to_string(struct event_location *location)
char * xstrprintf(const char *format,...)
void print_command_lines(struct ui_out *uiout, struct command_line *cmd, unsigned int depth)
struct breakpoint_ops bkpt_breakpoint_ops
static int bppy_set_condition(PyObject *self, PyObject *newvalue, void *closure)
void watch_command_wrapper(const char *arg, int from_tty, int internal)
const struct extension_language_defn * get_ext_lang_defn(enum extension_language lang)
events_object gdb_py_events
static gdb_PyGetSetDef breakpoint_object_getset[]
static PyObject * bppy_get_silent(PyObject *self, void *closure)
static PyObject * bppy_get_ignore_count(PyObject *self, void *closure)
symbol_name_match_type func_name_match_type
const struct extension_language_defn * get_breakpoint_cond_ext_lang(struct breakpoint *b, enum extension_language skip_lang)
PyTypeObject breakpoint_object_type
const struct language_defn * current_language
static int bppy_set_task(PyObject *self, PyObject *newvalue, void *closure)
static int bppy_init(PyObject *self, PyObject *args, PyObject *kwargs)
struct line_offset linespec_parse_line_offset(const char *string)
const char * ext_lang_capitalized_name(const struct extension_language_defn *extlang)
void gdbpy_convert_exception(struct gdb_exception exception)
event_location_up location
const char * c_str() const
static PyObject * bppy_get_expression(PyObject *self, void *closure)
struct observer * observer_attach_breakpoint_modified(observer_breakpoint_modified_ftype *f)
void gdbpy_print_stack(void)
int create_breakpoint(struct gdbarch *gdbarch, const struct event_location *location, const char *cond_string, int thread, const char *extra_string, int parse_extra, int tempflag, enum bptype type_wanted, int ignore_count, enum auto_boolean pending_break_support, const struct breakpoint_ops *ops, int from_tty, int enabled, int internal, unsigned flags)
static PyObject * bppy_get_temporary(PyObject *self, void *closure)
static PyObject * bppy_delete_breakpoint(PyObject *self, PyObject *args)
int user_breakpoint_p(struct breakpoint *b)
static PyObject * bppy_get_commands(PyObject *self, void *closure)
static PyObject * bppy_get_number(PyObject *self, void *closure)
std::string string_printf(const char *fmt,...)
void breakpoint_set_silent(struct breakpoint *b, int silent)
void breakpoint_set_thread(struct breakpoint *b, int thread)
int gdb_py_int_as_long(PyObject *obj, long *result)
int evpy_emit_event(PyObject *event, eventregistry_object *registry)
static PyObject * bppy_get_pending(PyObject *self, void *closure)
int evregpy_no_listeners_p(eventregistry_object *registry)
#define PyObject_CallMethod
enum enable_state enable_state
static int bppy_init_validate_args(const char *spec, char *source, char *function, char *label, char *line, enum bptype type)
static void gdbpy_breakpoint_created(struct breakpoint *bp)
void rwatch_command_wrapper(const char *arg, int from_tty, int internal)
void delete_breakpoint(struct breakpoint *bpt)
static PyObject * bppy_get_enabled(PyObject *self, void *closure)
event_location_up string_to_event_location(const char **stringp, const struct language_defn *language, symbol_name_match_type match_type)
static int bppy_set_hit_count(PyObject *self, PyObject *newvalue, void *closure)
void error(const char *fmt,...)
void set_breakpoint_condition(struct breakpoint *b, const char *exp, int from_tty)
#define PyObject_HasAttrString(obj, attr)
void bpfinishpy_post_stop_hook(struct gdbpy_breakpoint_object *bp_obj)