120 if (newvalue == NULL)
122 PyErr_SetString (PyExc_TypeError,
123 _(
"Cannot delete `enabled' attribute."));
127 else if (! PyBool_Check (newvalue))
129 PyErr_SetString (PyExc_TypeError,
130 _(
"The value of `enabled' must be a boolean."));
134 cmp = PyObject_IsTrue (newvalue);
163 if (newvalue == NULL)
165 PyErr_SetString (PyExc_TypeError,
166 _(
"Cannot delete `silent' attribute."));
169 else if (! PyBool_Check (newvalue))
171 PyErr_SetString (PyExc_TypeError,
172 _(
"The value of `silent' must be a boolean."));
176 cmp = PyObject_IsTrue (newvalue);
194 if (newvalue == NULL)
196 PyErr_SetString (PyExc_TypeError,
197 _(
"Cannot delete `thread' attribute."));
200 else if (PyInt_Check (newvalue))
207 PyErr_SetString (PyExc_RuntimeError,
208 _(
"Invalid thread ID."));
212 else if (newvalue == Py_None)
216 PyErr_SetString (PyExc_TypeError,
217 _(
"The value of `thread' must be an integer or None."));
236 if (newvalue == NULL)
238 PyErr_SetString (PyExc_TypeError,
239 _(
"Cannot delete `task' attribute."));
242 else if (PyInt_Check (newvalue))
259 PyErr_SetString (PyExc_RuntimeError,
260 _(
"Invalid task ID."));
264 else if (newvalue == Py_None)
268 PyErr_SetString (PyExc_TypeError,
269 _(
"The value of `task' must be an integer or None."));
313 if (newvalue == NULL)
315 PyErr_SetString (PyExc_TypeError,
316 _(
"Cannot delete `ignore_count' attribute."));
319 else if (! PyInt_Check (newvalue))
321 PyErr_SetString (PyExc_TypeError,
322 _(
"The value of `ignore_count' must be an integer."));
353 if (newvalue == NULL)
355 PyErr_SetString (PyExc_TypeError,
356 _(
"Cannot delete `hit_count' attribute."));
368 PyErr_SetString (PyExc_AttributeError,
369 _(
"The value of `hit_count' must be zero."));
395 return PyString_Decode (str, strlen (str),
host_charset (), NULL);
417 return PyString_Decode (str, strlen (str),
host_charset (), NULL);
433 return PyString_Decode (str, strlen (str),
host_charset (), NULL);
448 if (newvalue == NULL)
450 PyErr_SetString (PyExc_TypeError,
451 _(
"Cannot delete `condition' attribute."));
454 else if (newvalue == Py_None)
473 if (newvalue != Py_None)
518 result = PyString_Decode (cmdstr, strlen (cmdstr),
host_charset (), NULL);
531 return PyInt_FromLong (self_bp->
bp->
type);
574 return PyInt_FromLong (self_bp->
number);
588 return PyInt_FromLong (self_bp->
bp->
thread);
599 if (self_bp->
bp->
task == 0)
602 return PyInt_FromLong (self_bp->
bp->
task);
629 bppy_init (PyObject *
self, PyObject *args, PyObject *kwargs)
631 static char *keywords[] = {
"spec",
"type",
"wp_class",
"internal",
636 PyObject *
internal = NULL;
637 PyObject *temporary = NULL;
639 int temporary_bp = 0;
641 if (! PyArg_ParseTupleAndKeywords (args, kwargs,
"s|iiOO", keywords,
642 &spec, &type, &access_type,
643 &
internal, &temporary))
648 internal_bp = PyObject_IsTrue (
internal);
649 if (internal_bp == -1)
653 if (temporary != NULL)
655 temporary_bp = PyObject_IsTrue (temporary);
656 if (temporary_bp == -1)
661 bppy_pending_object->
number = -1;
662 bppy_pending_object->
bp = NULL;
666 char *copy = xstrdup (spec);
674 copy, NULL, -1, NULL,
680 0, 1, internal_bp, 0);
689 else if (access_type ==
hw_read)
692 error(
_(
"Cannot understand watchpoint access type."));
696 error(
_(
"Do not understand breakpoint type to set."));
704 ? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
705 "%s", except.message);
719 PyObject *list =
arg;
728 iserr = PyList_Append (list, bp);
741 PyObject *list, *tuple;
746 list = PyList_New (0);
759 tuple = PyList_AsTuple (list);
776 PyObject *py_bp = (PyObject *) bp_obj;
792 PyObject *result = PyObject_CallMethod (py_bp,
stop_func, NULL);
797 int evaluate = PyObject_IsTrue (result);
858 PyGILState_STATE state;
860 if (bp->
number < 0 && bppy_pending_object == NULL)
872 if (bppy_pending_object)
875 bppy_pending_object = NULL;
890 PyErr_SetString (PyExc_RuntimeError,
891 _(
"Error while creating breakpoint from GDB."));
904 PyGILState_STATE state;
943 for (i = 0; pybp_codes[i].
name; ++i)
947 (
char *) pybp_codes[i].
name,
948 pybp_codes[i].
code) < 0)
953 for (i = 0; pybp_watch_types[i].
name; ++i)
957 (
char *) pybp_watch_types[i].
name,
958 pybp_watch_types[i].
code) < 0)
997 =
xstrprintf (
_(
"Only one stop condition allowed. There is"
998 " currently a %s stop condition defined for"
999 " this breakpoint."),
1001 PyErr_SetString (PyExc_RuntimeError, error_text);
1009 return PyObject_GenericSetAttr ((PyObject *)
self, name, v);
1014 "Boolean telling whether the breakpoint is enabled.", NULL },
1016 "Boolean telling whether the breakpoint is silent.", NULL },
1018 "Thread ID for the breakpoint.\n\
1019 If the value is a thread ID (integer), then this is a thread-specific breakpoint.\n\
1020 If the value is None, then this breakpoint is not thread-specific.\n\
1021 No other type of value can be used.", NULL },
1023 "Thread ID for the breakpoint.\n\
1024 If the value is a task ID (integer), then this is an Ada task-specific breakpoint.\n\
1025 If the value is None, then this breakpoint is not task-specific.\n\
1026 No other type of value can be used.", NULL },
1028 "Number of times this breakpoint should be automatically continued.",
1031 "Breakpoint's number assigned by GDB.", NULL },
1033 "Number of times the breakpoint has been hit.\n\
1034 Can be set to zero to clear the count. No other value is valid\n\
1035 when setting this property.", NULL },
1037 "Location of the breakpoint, as specified by the user.", NULL},
1039 "Expression of the breakpoint, as specified by the user.", NULL},
1041 "Condition of the breakpoint, as specified by the user,\
1042 or None if no condition set."},
1044 "Commands of the breakpoint, as specified by the user."},
1046 "Type of breakpoint."},
1048 "Whether the breakpoint is visible to the user."},
1050 "Whether this breakpoint is a temporary breakpoint."},
1057 "Return true if this breakpoint is valid, false if not." },
1059 "Delete the underlying GDB breakpoint." },
1084 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
1085 "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)
#define BPPY_SET_REQUIRE_VALID(Breakpoint)
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 awatch_command_wrapper(char *arg, int from_tty, int internal)
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)
struct counted_command_line * commands
int gdbpy_initialize_breakpoints(void)
static PyMethodDef breakpoint_object_methods[]
char * ui_file_xstrdup(struct ui_file *file, long *length)
static PyGetSetDef breakpoint_object_getset[]
const struct gdb_exception exception_none
struct gdbpy_breakpoint_object * py_bp_object
struct gdbpy_breakpoint_object gdbpy_breakpoint_object
void rwatch_command_wrapper(char *arg, int from_tty, int internal)
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)
int gdbpy_breakpoint_has_cond(const struct extension_language_defn *extlang, struct breakpoint *b)
#define GDB_PY_HANDLE_EXCEPTION(Exception)
int valid_thread_id(int thread)
static int build_bp_list(struct breakpoint *b, void *arg)
#define PyGILState_Ensure()
#define CATCH(EXCEPTION, MASK)
#define BPPY_REQUIRE_VALID(Breakpoint)
static PyObject * bppy_get_task(PyObject *self, void *closure)
static PyObject * bppy_get_location(PyObject *self, void *closure)
struct breakpoint * iterate_over_breakpoints(int(*callback)(struct breakpoint *, void *), void *data)
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)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
static int bppy_set_silent(PyObject *self, PyObject *newvalue, void *closure)
char * python_string_to_host_string(PyObject *obj)
void disable_breakpoint(struct breakpoint *bpt)
#define GDB_PY_SET_HANDLE_EXCEPTION(Exception)
struct gdbarch * get_current_arch(void)
struct gdbarch * python_gdbarch
struct cleanup * ensure_python_env(struct gdbarch *gdbarch, const struct language_defn *language)
static PyObject * bppy_get_hit_count(PyObject *self, void *closure)
struct breakpoint * get_breakpoint(int num)
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
struct ui_file * mem_fileopen(void)
static int bppy_set_condition(PyObject *self, PyObject *newvalue, void *closure)
const struct extension_language_defn * get_ext_lang_defn(enum extension_language lang)
static PyObject * bppy_get_silent(PyObject *self, void *closure)
static PyObject * bppy_get_ignore_count(PyObject *self, void *closure)
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)
int create_breakpoint(struct gdbarch *gdbarch, char *arg, char *cond_string, int thread, char *extra_string, int parse_arg, 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)
const char * ext_lang_capitalized_name(const struct extension_language_defn *extlang)
struct cleanup * make_cleanup_ui_file_delete(struct ui_file *arg)
void gdbpy_convert_exception(struct gdb_exception exception)
static PyObject * bppy_get_expression(PyObject *self, void *closure)
void watch_command_wrapper(char *arg, int from_tty, int internal)
void gdbpy_print_stack(void)
static PyObject * bppy_get_temporary(PyObject *self, void *closure)
static PyObject * bppy_delete_breakpoint(PyObject *self, PyObject *args)
static PyObject * bppy_get_commands(PyObject *self, void *closure)
static char *const stop_func
static PyObject * bppy_get_number(PyObject *self, void *closure)
void breakpoint_set_silent(struct breakpoint *b, int silent)
int ui_out_redirect(struct ui_out *uiout, struct ui_file *outstream)
void breakpoint_set_thread(struct breakpoint *b, int thread)
int gdb_py_int_as_long(PyObject *obj, long *result)
const char * host_charset(void)
struct ui_out * current_uiout
enum enable_state enable_state
static void gdbpy_breakpoint_created(struct breakpoint *bp)
void delete_breakpoint(struct breakpoint *bpt)
static PyObject * bppy_get_enabled(PyObject *self, void *closure)
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 do_cleanups(struct cleanup *old_chain)
void bpfinishpy_post_stop_hook(struct gdbpy_breakpoint_object *bp_obj)
#define PyVarObject_HEAD_INIT(type, size)