2010-04-09 09:41:43 +00:00
|
|
|
|
/* Python interface to breakpoints
|
|
|
|
|
|
2011-01-01 15:34:07 +00:00
|
|
|
|
Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
|
2010-04-09 09:41:43 +00:00
|
|
|
|
|
|
|
|
|
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 "exceptions.h"
|
|
|
|
|
#include "python-internal.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"
|
2011-03-14 16:09:55 +00:00
|
|
|
|
#include "arch-utils.h"
|
|
|
|
|
#include "language.h"
|
2010-04-09 09:41:43 +00:00
|
|
|
|
|
|
|
|
|
static PyTypeObject breakpoint_object_type;
|
|
|
|
|
|
|
|
|
|
/* Number of live breakpoints. */
|
|
|
|
|
static int bppy_live;
|
|
|
|
|
|
|
|
|
|
/* Variables used to pass information between the Breakpoint
|
|
|
|
|
constructor and the breakpoint-created hook function. */
|
|
|
|
|
static breakpoint_object *bppy_pending_object;
|
|
|
|
|
|
2011-03-14 16:09:55 +00:00
|
|
|
|
/* Function that is called when a Python condition is evaluated. */
|
|
|
|
|
static char * const stop_func = "stop";
|
|
|
|
|
|
2010-04-09 09:41:43 +00:00
|
|
|
|
struct breakpoint_object
|
|
|
|
|
{
|
|
|
|
|
PyObject_HEAD
|
|
|
|
|
|
|
|
|
|
/* The breakpoint number according to gdb. */
|
|
|
|
|
int number;
|
|
|
|
|
|
|
|
|
|
/* The gdb breakpoint object, or NULL if the breakpoint has been
|
|
|
|
|
deleted. */
|
|
|
|
|
struct breakpoint *bp;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Require that BREAKPOINT be a valid breakpoint ID; throw a Python
|
|
|
|
|
exception if it is invalid. */
|
|
|
|
|
#define BPPY_REQUIRE_VALID(Breakpoint) \
|
|
|
|
|
do { \
|
2010-11-11 14:11:56 +00:00
|
|
|
|
if ((Breakpoint)->bp == NULL) \
|
2011-01-06 00:57:05 +00:00
|
|
|
|
return PyErr_Format (PyExc_RuntimeError, \
|
|
|
|
|
_("Breakpoint %d is invalid."), \
|
2010-04-09 09:41:43 +00:00
|
|
|
|
(Breakpoint)->number); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
/* Require that BREAKPOINT be a valid breakpoint ID; throw a Python
|
|
|
|
|
exception if it is invalid. This macro is for use in setter functions. */
|
|
|
|
|
#define BPPY_SET_REQUIRE_VALID(Breakpoint) \
|
|
|
|
|
do { \
|
2011-01-06 00:57:05 +00:00
|
|
|
|
if ((Breakpoint)->bp == NULL) \
|
2010-04-09 09:41:43 +00:00
|
|
|
|
{ \
|
|
|
|
|
PyErr_Format (PyExc_RuntimeError, _("Breakpoint %d is invalid."), \
|
|
|
|
|
(Breakpoint)->number); \
|
|
|
|
|
return -1; \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
/* This is used to initialize various gdb.bp_* constants. */
|
|
|
|
|
struct pybp_code
|
|
|
|
|
{
|
|
|
|
|
/* The name. */
|
|
|
|
|
const char *name;
|
|
|
|
|
/* The code. */
|
|
|
|
|
enum type_code 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)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *self_bp = (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)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *self_bp = (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)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *self_bp = (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)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *self_bp = (breakpoint_object *) self;
|
|
|
|
|
int cmp;
|
2011-10-27 09:14:27 +00:00
|
|
|
|
volatile struct gdb_exception except;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
|
|
|
|
|
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;
|
2011-10-27 09:14:27 +00:00
|
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
if (cmp == 1)
|
|
|
|
|
enable_breakpoint (self_bp->bp);
|
|
|
|
|
else
|
|
|
|
|
disable_breakpoint (self_bp->bp);
|
|
|
|
|
}
|
|
|
|
|
GDB_PY_SET_HANDLE_EXCEPTION (except);
|
|
|
|
|
|
2010-04-09 09:41:43 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Python function to set the 'silent' state of a breakpoint. */
|
|
|
|
|
static int
|
|
|
|
|
bppy_set_silent (PyObject *self, PyObject *newvalue, void *closure)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *self_bp = (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
|
2011-01-31 15:16:59 +00:00
|
|
|
|
breakpoint_set_silent (self_bp->bp, cmp);
|
2010-04-09 09:41:43 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Python function to set the thread of a breakpoint. */
|
|
|
|
|
static int
|
|
|
|
|
bppy_set_thread (PyObject *self, PyObject *newvalue, void *closure)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *self_bp = (breakpoint_object *) self;
|
2011-01-26 20:53:45 +00:00
|
|
|
|
long id;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
|
|
|
|
|
BPPY_SET_REQUIRE_VALID (self_bp);
|
|
|
|
|
|
|
|
|
|
if (newvalue == NULL)
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_TypeError,
|
|
|
|
|
_("Cannot delete `thread' attribute."));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
else if (PyInt_Check (newvalue))
|
|
|
|
|
{
|
2011-01-26 20:53:45 +00:00
|
|
|
|
if (! gdb_py_int_as_long (newvalue, &id))
|
|
|
|
|
return -1;
|
|
|
|
|
|
2010-04-09 09:41:43 +00:00
|
|
|
|
if (! valid_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;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-31 15:16:59 +00:00
|
|
|
|
breakpoint_set_thread (self_bp->bp, id);
|
2010-04-09 09:41:43 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Python function to set the (Ada) task of a breakpoint. */
|
|
|
|
|
static int
|
|
|
|
|
bppy_set_task (PyObject *self, PyObject *newvalue, void *closure)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *self_bp = (breakpoint_object *) self;
|
2011-01-26 20:53:45 +00:00
|
|
|
|
long id;
|
2011-10-27 09:14:27 +00:00
|
|
|
|
int valid_id = 0;
|
|
|
|
|
volatile struct gdb_exception except;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
|
|
|
|
|
BPPY_SET_REQUIRE_VALID (self_bp);
|
|
|
|
|
|
|
|
|
|
if (newvalue == NULL)
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_TypeError,
|
|
|
|
|
_("Cannot delete `task' attribute."));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
else if (PyInt_Check (newvalue))
|
|
|
|
|
{
|
2011-01-26 20:53:45 +00:00
|
|
|
|
if (! gdb_py_int_as_long (newvalue, &id))
|
|
|
|
|
return -1;
|
|
|
|
|
|
2011-10-27 09:14:27 +00:00
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
valid_id = valid_task_id (id);
|
|
|
|
|
}
|
|
|
|
|
GDB_PY_SET_HANDLE_EXCEPTION (except);
|
|
|
|
|
|
|
|
|
|
if (! valid_id)
|
2010-04-09 09:41:43 +00:00
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-31 15:16:59 +00:00
|
|
|
|
breakpoint_set_task (self_bp->bp, id);
|
2010-04-09 09:41:43 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-29 13:49:05 +00:00
|
|
|
|
/* 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)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *self_bp = (breakpoint_object *) self;
|
2011-10-27 09:14:27 +00:00
|
|
|
|
volatile struct gdb_exception except;
|
2010-11-29 13:49:05 +00:00
|
|
|
|
|
|
|
|
|
BPPY_REQUIRE_VALID (self_bp);
|
|
|
|
|
|
2011-10-27 09:14:27 +00:00
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
delete_breakpoint (self_bp->bp);
|
|
|
|
|
}
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
2010-11-29 13:49:05 +00:00
|
|
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-09 09:41:43 +00:00
|
|
|
|
|
|
|
|
|
/* Python function to set the ignore count of a breakpoint. */
|
|
|
|
|
static int
|
|
|
|
|
bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *self_bp = (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;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-26 20:53:45 +00:00
|
|
|
|
if (! gdb_py_int_as_long (newvalue, &value))
|
|
|
|
|
return -1;
|
|
|
|
|
|
2010-04-09 09:41:43 +00:00
|
|
|
|
if (value < 0)
|
|
|
|
|
value = 0;
|
|
|
|
|
set_ignore_count (self_bp->number, (int) value, 0);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Python function to set the hit count of a breakpoint. */
|
|
|
|
|
static int
|
|
|
|
|
bppy_set_hit_count (PyObject *self, PyObject *newvalue, void *closure)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *self_bp = (breakpoint_object *) self;
|
|
|
|
|
|
|
|
|
|
BPPY_SET_REQUIRE_VALID (self_bp);
|
|
|
|
|
|
|
|
|
|
if (newvalue == NULL)
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_TypeError,
|
|
|
|
|
_("Cannot delete `hit_count' attribute."));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2011-01-26 20:53:45 +00:00
|
|
|
|
else
|
2010-04-09 09:41:43 +00:00
|
|
|
|
{
|
2011-01-26 20:53:45 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
2010-04-09 09:41:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
char *str;
|
|
|
|
|
breakpoint_object *obj = (breakpoint_object *) self;
|
|
|
|
|
|
|
|
|
|
BPPY_REQUIRE_VALID (obj);
|
|
|
|
|
|
|
|
|
|
if (obj->bp->type != bp_breakpoint)
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
|
|
|
|
|
str = obj->bp->addr_string;
|
|
|
|
|
|
|
|
|
|
if (! str)
|
|
|
|
|
str = "";
|
|
|
|
|
return PyString_Decode (str, strlen (str), host_charset (), NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Python function to get the breakpoint expression. */
|
|
|
|
|
static PyObject *
|
|
|
|
|
bppy_get_expression (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
char *str;
|
|
|
|
|
breakpoint_object *obj = (breakpoint_object *) self;
|
2011-07-25 Pedro Alves <pedro@codesourcery.com>
gdb/
* breakpoint.h (struct breakpoint): Move ops as first field. Move
exp_string, exp_string_reparse, exp, exp_valid_block, cond_exp,
cond_exp_valid_block, val, val_valid, watchpoint_frame,
watchpoint_thread, watchpoint_triggered ...
(struct watchpoint): ... to this new struct.
(is_watchpoint): Declare.
(install_breakpoint): Add new `internal' parameter.
* breakpoint.c (is_watchpoint): Delete declaration.
(set_breakpoint_condition): Handle watchpoints.
(is_watchpoint): Make public.
(watchpoint_in_thread_scope): Change parameter type to struct
watchpoint.
(watchpoint_del_at_next_stop): Change parameter type to struct
watchpoint. Remove assertion. Adjust.
(update_watchpoint): Ditto.
(insert_breakpoints, breakpoint_init_inferior)
(watchpoints_triggered, watchpoint_check)
(bpstat_check_watchpoint, bpstat_check_breakpoint_conditions)
(bpstat_stop_status, print_one_breakpoint_location)
(print_one_breakpoint_location, watchpoint_locations_match): Cast
to struct watchpoint as necessary, and adjust.
(install_breakpoint): Add `internal' argument. If true, don't
mention the new breakpoint. Use set_breakpoint_number.
(create_fork_vfork_event_catchpoint)
(create_syscall_event_catchpoint): Adjust.
(dtor_watchpoint): New.
(re_set_watchpoint, insert_watchpoint, remove_watchpoint)
(breakpoint_hit_watchpoint, resources_needed_watchpoint)
(print_it_watchpoint, print_mention_watchpoint)
(print_recreate_watchpoint, insert_masked_watchpoint)
(remove_masked_watchpoint, resources_needed_masked_watchpoint)
(print_one_detail_masked_watchpoint)
(print_mention_masked_watchpoint)
(print_recreate_masked_watchpoint): Cast to struct watchpoint as
necessary, and adjust.
(watch_command_1): Allocate and initialize a struct watchpoint
instead of a struct breakpoint. Use install_breakpoint.
(catch_exec_command_1): Adjust.
(base_breakpoint_dtor): Delete accesses to watchpoint specific
fields.
(delete_breakpoint, enable_breakpoint_disp)
(invalidate_bp_value_on_memory_change): Cast to struct watchpoint
as necessary, and adjust.
(initialize_breakpoint_ops): Install dtor_watchpoint as
watchpoints' dtor method.
* ada-lang.c (create_ada_exception_catchpoint): Adjust.
* python/py-breakpoint.c (bppy_get_expression): Use is_watchpoint.
to struct watchpoint as necessary, and adjust.
2011-07-25 11:23:03 +00:00
|
|
|
|
struct watchpoint *wp;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
|
|
|
|
|
BPPY_REQUIRE_VALID (obj);
|
|
|
|
|
|
2011-07-25 Pedro Alves <pedro@codesourcery.com>
gdb/
* breakpoint.h (struct breakpoint): Move ops as first field. Move
exp_string, exp_string_reparse, exp, exp_valid_block, cond_exp,
cond_exp_valid_block, val, val_valid, watchpoint_frame,
watchpoint_thread, watchpoint_triggered ...
(struct watchpoint): ... to this new struct.
(is_watchpoint): Declare.
(install_breakpoint): Add new `internal' parameter.
* breakpoint.c (is_watchpoint): Delete declaration.
(set_breakpoint_condition): Handle watchpoints.
(is_watchpoint): Make public.
(watchpoint_in_thread_scope): Change parameter type to struct
watchpoint.
(watchpoint_del_at_next_stop): Change parameter type to struct
watchpoint. Remove assertion. Adjust.
(update_watchpoint): Ditto.
(insert_breakpoints, breakpoint_init_inferior)
(watchpoints_triggered, watchpoint_check)
(bpstat_check_watchpoint, bpstat_check_breakpoint_conditions)
(bpstat_stop_status, print_one_breakpoint_location)
(print_one_breakpoint_location, watchpoint_locations_match): Cast
to struct watchpoint as necessary, and adjust.
(install_breakpoint): Add `internal' argument. If true, don't
mention the new breakpoint. Use set_breakpoint_number.
(create_fork_vfork_event_catchpoint)
(create_syscall_event_catchpoint): Adjust.
(dtor_watchpoint): New.
(re_set_watchpoint, insert_watchpoint, remove_watchpoint)
(breakpoint_hit_watchpoint, resources_needed_watchpoint)
(print_it_watchpoint, print_mention_watchpoint)
(print_recreate_watchpoint, insert_masked_watchpoint)
(remove_masked_watchpoint, resources_needed_masked_watchpoint)
(print_one_detail_masked_watchpoint)
(print_mention_masked_watchpoint)
(print_recreate_masked_watchpoint): Cast to struct watchpoint as
necessary, and adjust.
(watch_command_1): Allocate and initialize a struct watchpoint
instead of a struct breakpoint. Use install_breakpoint.
(catch_exec_command_1): Adjust.
(base_breakpoint_dtor): Delete accesses to watchpoint specific
fields.
(delete_breakpoint, enable_breakpoint_disp)
(invalidate_bp_value_on_memory_change): Cast to struct watchpoint
as necessary, and adjust.
(initialize_breakpoint_ops): Install dtor_watchpoint as
watchpoints' dtor method.
* ada-lang.c (create_ada_exception_catchpoint): Adjust.
* python/py-breakpoint.c (bppy_get_expression): Use is_watchpoint.
to struct watchpoint as necessary, and adjust.
2011-07-25 11:23:03 +00:00
|
|
|
|
if (!is_watchpoint (obj->bp))
|
2010-04-09 09:41:43 +00:00
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
|
2011-07-25 Pedro Alves <pedro@codesourcery.com>
gdb/
* breakpoint.h (struct breakpoint): Move ops as first field. Move
exp_string, exp_string_reparse, exp, exp_valid_block, cond_exp,
cond_exp_valid_block, val, val_valid, watchpoint_frame,
watchpoint_thread, watchpoint_triggered ...
(struct watchpoint): ... to this new struct.
(is_watchpoint): Declare.
(install_breakpoint): Add new `internal' parameter.
* breakpoint.c (is_watchpoint): Delete declaration.
(set_breakpoint_condition): Handle watchpoints.
(is_watchpoint): Make public.
(watchpoint_in_thread_scope): Change parameter type to struct
watchpoint.
(watchpoint_del_at_next_stop): Change parameter type to struct
watchpoint. Remove assertion. Adjust.
(update_watchpoint): Ditto.
(insert_breakpoints, breakpoint_init_inferior)
(watchpoints_triggered, watchpoint_check)
(bpstat_check_watchpoint, bpstat_check_breakpoint_conditions)
(bpstat_stop_status, print_one_breakpoint_location)
(print_one_breakpoint_location, watchpoint_locations_match): Cast
to struct watchpoint as necessary, and adjust.
(install_breakpoint): Add `internal' argument. If true, don't
mention the new breakpoint. Use set_breakpoint_number.
(create_fork_vfork_event_catchpoint)
(create_syscall_event_catchpoint): Adjust.
(dtor_watchpoint): New.
(re_set_watchpoint, insert_watchpoint, remove_watchpoint)
(breakpoint_hit_watchpoint, resources_needed_watchpoint)
(print_it_watchpoint, print_mention_watchpoint)
(print_recreate_watchpoint, insert_masked_watchpoint)
(remove_masked_watchpoint, resources_needed_masked_watchpoint)
(print_one_detail_masked_watchpoint)
(print_mention_masked_watchpoint)
(print_recreate_masked_watchpoint): Cast to struct watchpoint as
necessary, and adjust.
(watch_command_1): Allocate and initialize a struct watchpoint
instead of a struct breakpoint. Use install_breakpoint.
(catch_exec_command_1): Adjust.
(base_breakpoint_dtor): Delete accesses to watchpoint specific
fields.
(delete_breakpoint, enable_breakpoint_disp)
(invalidate_bp_value_on_memory_change): Cast to struct watchpoint
as necessary, and adjust.
(initialize_breakpoint_ops): Install dtor_watchpoint as
watchpoints' dtor method.
* ada-lang.c (create_ada_exception_catchpoint): Adjust.
* python/py-breakpoint.c (bppy_get_expression): Use is_watchpoint.
to struct watchpoint as necessary, and adjust.
2011-07-25 11:23:03 +00:00
|
|
|
|
wp = (struct watchpoint *) obj->bp;
|
|
|
|
|
|
|
|
|
|
str = wp->exp_string;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
if (! str)
|
|
|
|
|
str = "";
|
|
|
|
|
|
|
|
|
|
return PyString_Decode (str, strlen (str), host_charset (), NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Python function to get the condition expression of a breakpoint. */
|
|
|
|
|
static PyObject *
|
|
|
|
|
bppy_get_condition (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
char *str;
|
|
|
|
|
breakpoint_object *obj = (breakpoint_object *) self;
|
|
|
|
|
|
|
|
|
|
BPPY_REQUIRE_VALID (obj);
|
|
|
|
|
|
|
|
|
|
str = obj->bp->cond_string;
|
|
|
|
|
if (! str)
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
|
|
|
|
|
return PyString_Decode (str, strlen (str), host_charset (), NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-13 13:24:40 +00:00
|
|
|
|
/* Returns 0 on success. Returns -1 on error, with a python exception set.
|
|
|
|
|
*/
|
|
|
|
|
|
2010-04-09 09:41:43 +00:00
|
|
|
|
static int
|
|
|
|
|
bppy_set_condition (PyObject *self, PyObject *newvalue, void *closure)
|
|
|
|
|
{
|
|
|
|
|
char *exp;
|
|
|
|
|
breakpoint_object *self_bp = (breakpoint_object *) self;
|
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
|
|
|
|
|
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 = python_string_to_host_string (newvalue);
|
|
|
|
|
if (exp == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
set_breakpoint_condition (self_bp->bp, exp, 0);
|
|
|
|
|
}
|
2011-03-11 22:01:30 +00:00
|
|
|
|
|
|
|
|
|
if (newvalue != Py_None)
|
|
|
|
|
xfree (exp);
|
|
|
|
|
|
2010-04-09 09:41:43 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *self_bp = (breakpoint_object *) self;
|
|
|
|
|
struct breakpoint *bp = self_bp->bp;
|
|
|
|
|
long length;
|
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
struct ui_file *string_file;
|
|
|
|
|
struct cleanup *chain;
|
|
|
|
|
PyObject *result;
|
|
|
|
|
char *cmdstr;
|
|
|
|
|
|
|
|
|
|
BPPY_REQUIRE_VALID (self_bp);
|
|
|
|
|
|
|
|
|
|
if (! self_bp->bp->commands)
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
|
|
|
|
|
string_file = mem_fileopen ();
|
|
|
|
|
chain = make_cleanup_ui_file_delete (string_file);
|
|
|
|
|
|
2011-08-04 Pedro Alves <pedro@codesourcery.com>
* ui-out.h (uiout): Rename to ...
(current_uiout): ... this.
* ui-out.c (uiout): Rename to ...
(current_uiout): ... this.
* ada-lang.c (print_it_exception, print_one_exception)
(print_mention_exception): Adjust.
* breakpoint.c (watchpoint_check): Adjust.
(print_breakpoint_location, print_one_breakpoint, breakpoint_1)
(default_collect_info, watchpoints_info, print_one_catch_fork)
(print_one_catch_vfork, print_one_catch_syscall)
(print_one_catch_exec, mention, print_it_ranged_breakpoint)
(print_one_ranged_breakpoint, print_mention_ranged_breakpoint)
(print_it_watchpoint, print_mention_watchpoint)
(print_it_masked_watchpoint, print_mention_masked_watchpoint)
(print_it_exception_catchpoint, print_one_exception_catchpoint)
(print_mention_exception_catchpoint, say_where, bkpt_print_it)
(bkpt_print_mention, momentary_bkpt_print_it)
(tracepoint_print_mention, update_static_tracepoint)
(tracepoints_info, save_breakpoints): Adjust.
* cli-out.c (field_separator): Adjust.
* cp-abi.c (list_cp_abis, show_cp_abi_cmd): Adjust.
* exceptions.c (catch_exceptions_with_msg, catch_errors): Adjust.
* frame.c (get_current_frame): Adjust.
* infcmd.c (run_command_1, print_return_value): Adjust.
* inferior.c (inferior_command, info_inferiors_command): Adjust.
* infrun.c (print_end_stepping_range_reason): Adjust.
(print_signal_exited_reason, print_exited_reason): Adjust.
(print_signal_received_reason, print_no_history_reason): Adjust.
* interps.c (interp_set): Adjust.
* osdata.c (info_osdata_command): Adjust.
* progspace.c (maintenance_info_program_spaces_command): Adjust.
* remote-fileio.c (remote_fileio_request): Adjust.
* remote.c (show_remote_cmd): Adjust.
* solib.c (info_sharedlibrary_command): Adjust.
* source.c (print_source_lines_base): Adjust.
* stack.c (print_stack_frame): Adjust.
(do_gdb_disassembly, print_frame_info, print_frame): Adjust.
* symfile-mem.c (add_vsyscall_page): Adjust.
* symfile.c (load_progress, generic_load)
(print_transfer_performance): Adjust.
* thread.c (info_threads_command, restore_selected_frame)
(thread_command): Adjust.
* top.c (make_cleanup_restore_ui_file): Adjust.
* tracepoint.c (tvariables_info_1, trace_status_mi, tfind_1)
(print_one_static_tracepoint_marker): Adjust.
* cli/cli-cmds.c (print_disassembly): Adjust.
* cli/cli-decode.c (print_doc_line): Adjust.
* cli/cli-interp.c (safe_execute_command): Adjust.
* cli/cli-logging.c (set_logging_redirect, pop_output_files)
(handle_redirections): Adjust.
* cli/cli-script.c (show_user_1): Adjust.
* cli/cli-setshow.c (do_setshow_command, cmd_show_list): Adjust.
* mi/mi-cmd-break.c (breakpoint_notify): Adjust.
* mi/mi-cmd-disas.c (mi_cmd_disassemble): Adjust.
* mi/mi-cmd-env.c (mi_cmd_env_pwd, mi_cmd_env_path)
(mi_cmd_env_dir): Adjust.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file)
(print_partial_file_name, mi_cmd_file_list_exec_source_files): Adjust.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_frames)
(mi_cmd_stack_info_depth, mi_cmd_stack_list_args)
(list_args_or_locals): Adjust.
* mi/mi-cmd-var.c (print_varobj, mi_cmd_var_create)
(mi_cmd_var_delete, mi_cmd_var_set_format, mi_cmd_var_set_frozen)
(mi_cmd_var_show_format, mi_cmd_var_info_num_children)
(mi_cmd_var_list_children, mi_cmd_var_info_type)
(mi_cmd_var_info_path_expression, mi_cmd_var_info_expression)
(mi_cmd_var_show_attributes, mi_cmd_var_evaluate_expression)
(mi_cmd_var_assign, mi_cmd_var_update, varobj_update_one): Adjust.
* mi/mi-interp.c (mi_on_normal_stop): Adjust.
* mi/mi-main.c (mi_cmd_gdb_exit, mi_cmd_thread_select)
(mi_cmd_thread_list_ids, mi_cmd_thread_info, print_one_inferior)
(list_available_thread_groups, mi_cmd_list_thread_groups)
(mi_cmd_data_list_register_names)
(mi_cmd_data_list_changed_registers)
(mi_cmd_data_list_register_values, get_register)
(mi_cmd_data_evaluate_expression, mi_cmd_data_read_memory)
(mi_cmd_data_read_memory_bytes, mi_cmd_list_features)
(mi_cmd_list_target_features, mi_cmd_add_inferior)
(mi_execute_command, mi_load_progress): Adjust.
* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Adjust.
* python/py-auto-load.c (print_script, info_auto_load_scripts):
Adjust.
* python/py-breakpoint.c (bppy_get_commands): Adjust.
* tui/tui-interp.c (tui_command_loop): Adjust.
* tui/tui-io.c (tui_setup_io, tui_initialize_io): Adjust.
2011-08-04 19:10:14 +00:00
|
|
|
|
ui_out_redirect (current_uiout, string_file);
|
2010-04-09 09:41:43 +00:00
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
2011-08-04 Pedro Alves <pedro@codesourcery.com>
* ui-out.h (uiout): Rename to ...
(current_uiout): ... this.
* ui-out.c (uiout): Rename to ...
(current_uiout): ... this.
* ada-lang.c (print_it_exception, print_one_exception)
(print_mention_exception): Adjust.
* breakpoint.c (watchpoint_check): Adjust.
(print_breakpoint_location, print_one_breakpoint, breakpoint_1)
(default_collect_info, watchpoints_info, print_one_catch_fork)
(print_one_catch_vfork, print_one_catch_syscall)
(print_one_catch_exec, mention, print_it_ranged_breakpoint)
(print_one_ranged_breakpoint, print_mention_ranged_breakpoint)
(print_it_watchpoint, print_mention_watchpoint)
(print_it_masked_watchpoint, print_mention_masked_watchpoint)
(print_it_exception_catchpoint, print_one_exception_catchpoint)
(print_mention_exception_catchpoint, say_where, bkpt_print_it)
(bkpt_print_mention, momentary_bkpt_print_it)
(tracepoint_print_mention, update_static_tracepoint)
(tracepoints_info, save_breakpoints): Adjust.
* cli-out.c (field_separator): Adjust.
* cp-abi.c (list_cp_abis, show_cp_abi_cmd): Adjust.
* exceptions.c (catch_exceptions_with_msg, catch_errors): Adjust.
* frame.c (get_current_frame): Adjust.
* infcmd.c (run_command_1, print_return_value): Adjust.
* inferior.c (inferior_command, info_inferiors_command): Adjust.
* infrun.c (print_end_stepping_range_reason): Adjust.
(print_signal_exited_reason, print_exited_reason): Adjust.
(print_signal_received_reason, print_no_history_reason): Adjust.
* interps.c (interp_set): Adjust.
* osdata.c (info_osdata_command): Adjust.
* progspace.c (maintenance_info_program_spaces_command): Adjust.
* remote-fileio.c (remote_fileio_request): Adjust.
* remote.c (show_remote_cmd): Adjust.
* solib.c (info_sharedlibrary_command): Adjust.
* source.c (print_source_lines_base): Adjust.
* stack.c (print_stack_frame): Adjust.
(do_gdb_disassembly, print_frame_info, print_frame): Adjust.
* symfile-mem.c (add_vsyscall_page): Adjust.
* symfile.c (load_progress, generic_load)
(print_transfer_performance): Adjust.
* thread.c (info_threads_command, restore_selected_frame)
(thread_command): Adjust.
* top.c (make_cleanup_restore_ui_file): Adjust.
* tracepoint.c (tvariables_info_1, trace_status_mi, tfind_1)
(print_one_static_tracepoint_marker): Adjust.
* cli/cli-cmds.c (print_disassembly): Adjust.
* cli/cli-decode.c (print_doc_line): Adjust.
* cli/cli-interp.c (safe_execute_command): Adjust.
* cli/cli-logging.c (set_logging_redirect, pop_output_files)
(handle_redirections): Adjust.
* cli/cli-script.c (show_user_1): Adjust.
* cli/cli-setshow.c (do_setshow_command, cmd_show_list): Adjust.
* mi/mi-cmd-break.c (breakpoint_notify): Adjust.
* mi/mi-cmd-disas.c (mi_cmd_disassemble): Adjust.
* mi/mi-cmd-env.c (mi_cmd_env_pwd, mi_cmd_env_path)
(mi_cmd_env_dir): Adjust.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file)
(print_partial_file_name, mi_cmd_file_list_exec_source_files): Adjust.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_frames)
(mi_cmd_stack_info_depth, mi_cmd_stack_list_args)
(list_args_or_locals): Adjust.
* mi/mi-cmd-var.c (print_varobj, mi_cmd_var_create)
(mi_cmd_var_delete, mi_cmd_var_set_format, mi_cmd_var_set_frozen)
(mi_cmd_var_show_format, mi_cmd_var_info_num_children)
(mi_cmd_var_list_children, mi_cmd_var_info_type)
(mi_cmd_var_info_path_expression, mi_cmd_var_info_expression)
(mi_cmd_var_show_attributes, mi_cmd_var_evaluate_expression)
(mi_cmd_var_assign, mi_cmd_var_update, varobj_update_one): Adjust.
* mi/mi-interp.c (mi_on_normal_stop): Adjust.
* mi/mi-main.c (mi_cmd_gdb_exit, mi_cmd_thread_select)
(mi_cmd_thread_list_ids, mi_cmd_thread_info, print_one_inferior)
(list_available_thread_groups, mi_cmd_list_thread_groups)
(mi_cmd_data_list_register_names)
(mi_cmd_data_list_changed_registers)
(mi_cmd_data_list_register_values, get_register)
(mi_cmd_data_evaluate_expression, mi_cmd_data_read_memory)
(mi_cmd_data_read_memory_bytes, mi_cmd_list_features)
(mi_cmd_list_target_features, mi_cmd_add_inferior)
(mi_execute_command, mi_load_progress): Adjust.
* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Adjust.
* python/py-auto-load.c (print_script, info_auto_load_scripts):
Adjust.
* python/py-breakpoint.c (bppy_get_commands): Adjust.
* tui/tui-interp.c (tui_command_loop): Adjust.
* tui/tui-io.c (tui_setup_io, tui_initialize_io): Adjust.
2011-08-04 19:10:14 +00:00
|
|
|
|
print_command_lines (current_uiout, breakpoint_commands (bp), 0);
|
2010-04-09 09:41:43 +00:00
|
|
|
|
}
|
2011-08-04 Pedro Alves <pedro@codesourcery.com>
* ui-out.h (uiout): Rename to ...
(current_uiout): ... this.
* ui-out.c (uiout): Rename to ...
(current_uiout): ... this.
* ada-lang.c (print_it_exception, print_one_exception)
(print_mention_exception): Adjust.
* breakpoint.c (watchpoint_check): Adjust.
(print_breakpoint_location, print_one_breakpoint, breakpoint_1)
(default_collect_info, watchpoints_info, print_one_catch_fork)
(print_one_catch_vfork, print_one_catch_syscall)
(print_one_catch_exec, mention, print_it_ranged_breakpoint)
(print_one_ranged_breakpoint, print_mention_ranged_breakpoint)
(print_it_watchpoint, print_mention_watchpoint)
(print_it_masked_watchpoint, print_mention_masked_watchpoint)
(print_it_exception_catchpoint, print_one_exception_catchpoint)
(print_mention_exception_catchpoint, say_where, bkpt_print_it)
(bkpt_print_mention, momentary_bkpt_print_it)
(tracepoint_print_mention, update_static_tracepoint)
(tracepoints_info, save_breakpoints): Adjust.
* cli-out.c (field_separator): Adjust.
* cp-abi.c (list_cp_abis, show_cp_abi_cmd): Adjust.
* exceptions.c (catch_exceptions_with_msg, catch_errors): Adjust.
* frame.c (get_current_frame): Adjust.
* infcmd.c (run_command_1, print_return_value): Adjust.
* inferior.c (inferior_command, info_inferiors_command): Adjust.
* infrun.c (print_end_stepping_range_reason): Adjust.
(print_signal_exited_reason, print_exited_reason): Adjust.
(print_signal_received_reason, print_no_history_reason): Adjust.
* interps.c (interp_set): Adjust.
* osdata.c (info_osdata_command): Adjust.
* progspace.c (maintenance_info_program_spaces_command): Adjust.
* remote-fileio.c (remote_fileio_request): Adjust.
* remote.c (show_remote_cmd): Adjust.
* solib.c (info_sharedlibrary_command): Adjust.
* source.c (print_source_lines_base): Adjust.
* stack.c (print_stack_frame): Adjust.
(do_gdb_disassembly, print_frame_info, print_frame): Adjust.
* symfile-mem.c (add_vsyscall_page): Adjust.
* symfile.c (load_progress, generic_load)
(print_transfer_performance): Adjust.
* thread.c (info_threads_command, restore_selected_frame)
(thread_command): Adjust.
* top.c (make_cleanup_restore_ui_file): Adjust.
* tracepoint.c (tvariables_info_1, trace_status_mi, tfind_1)
(print_one_static_tracepoint_marker): Adjust.
* cli/cli-cmds.c (print_disassembly): Adjust.
* cli/cli-decode.c (print_doc_line): Adjust.
* cli/cli-interp.c (safe_execute_command): Adjust.
* cli/cli-logging.c (set_logging_redirect, pop_output_files)
(handle_redirections): Adjust.
* cli/cli-script.c (show_user_1): Adjust.
* cli/cli-setshow.c (do_setshow_command, cmd_show_list): Adjust.
* mi/mi-cmd-break.c (breakpoint_notify): Adjust.
* mi/mi-cmd-disas.c (mi_cmd_disassemble): Adjust.
* mi/mi-cmd-env.c (mi_cmd_env_pwd, mi_cmd_env_path)
(mi_cmd_env_dir): Adjust.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file)
(print_partial_file_name, mi_cmd_file_list_exec_source_files): Adjust.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_frames)
(mi_cmd_stack_info_depth, mi_cmd_stack_list_args)
(list_args_or_locals): Adjust.
* mi/mi-cmd-var.c (print_varobj, mi_cmd_var_create)
(mi_cmd_var_delete, mi_cmd_var_set_format, mi_cmd_var_set_frozen)
(mi_cmd_var_show_format, mi_cmd_var_info_num_children)
(mi_cmd_var_list_children, mi_cmd_var_info_type)
(mi_cmd_var_info_path_expression, mi_cmd_var_info_expression)
(mi_cmd_var_show_attributes, mi_cmd_var_evaluate_expression)
(mi_cmd_var_assign, mi_cmd_var_update, varobj_update_one): Adjust.
* mi/mi-interp.c (mi_on_normal_stop): Adjust.
* mi/mi-main.c (mi_cmd_gdb_exit, mi_cmd_thread_select)
(mi_cmd_thread_list_ids, mi_cmd_thread_info, print_one_inferior)
(list_available_thread_groups, mi_cmd_list_thread_groups)
(mi_cmd_data_list_register_names)
(mi_cmd_data_list_changed_registers)
(mi_cmd_data_list_register_values, get_register)
(mi_cmd_data_evaluate_expression, mi_cmd_data_read_memory)
(mi_cmd_data_read_memory_bytes, mi_cmd_list_features)
(mi_cmd_list_target_features, mi_cmd_add_inferior)
(mi_execute_command, mi_load_progress): Adjust.
* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Adjust.
* python/py-auto-load.c (print_script, info_auto_load_scripts):
Adjust.
* python/py-breakpoint.c (bppy_get_commands): Adjust.
* tui/tui-interp.c (tui_command_loop): Adjust.
* tui/tui-io.c (tui_setup_io, tui_initialize_io): Adjust.
2011-08-04 19:10:14 +00:00
|
|
|
|
ui_out_redirect (current_uiout, NULL);
|
2010-04-09 09:41:43 +00:00
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
|
|
|
|
|
2011-03-11 21:34:34 +00:00
|
|
|
|
cmdstr = ui_file_xstrdup (string_file, &length);
|
|
|
|
|
make_cleanup (xfree, cmdstr);
|
2010-04-09 09:41:43 +00:00
|
|
|
|
result = PyString_Decode (cmdstr, strlen (cmdstr), host_charset (), NULL);
|
|
|
|
|
do_cleanups (chain);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Python function to get the breakpoint type. */
|
|
|
|
|
static PyObject *
|
|
|
|
|
bppy_get_type (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *self_bp = (breakpoint_object *) self;
|
|
|
|
|
|
|
|
|
|
BPPY_REQUIRE_VALID (self_bp);
|
|
|
|
|
|
|
|
|
|
return PyInt_FromLong (self_bp->bp->type);
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-11 14:11:56 +00:00
|
|
|
|
/* Python function to get the visibility of the breakpoint. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
bppy_get_visibility (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *self_bp = (breakpoint_object *) self;
|
|
|
|
|
|
|
|
|
|
BPPY_REQUIRE_VALID (self_bp);
|
|
|
|
|
|
|
|
|
|
if (self_bp->bp->number < 0)
|
|
|
|
|
Py_RETURN_FALSE;
|
|
|
|
|
|
|
|
|
|
Py_RETURN_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-09 09:41:43 +00:00
|
|
|
|
/* Python function to get the breakpoint's number. */
|
|
|
|
|
static PyObject *
|
|
|
|
|
bppy_get_number (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *self_bp = (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)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *self_bp = (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)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *self_bp = (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)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *self_bp = (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)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *self_bp = (breakpoint_object *) self;
|
|
|
|
|
|
|
|
|
|
BPPY_REQUIRE_VALID (self_bp);
|
|
|
|
|
|
|
|
|
|
return PyInt_FromLong (self_bp->bp->ignore_count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Python function to create a new breakpoint. */
|
2011-03-14 16:09:55 +00:00
|
|
|
|
static int
|
|
|
|
|
bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
|
2010-04-09 09:41:43 +00:00
|
|
|
|
{
|
2010-11-11 14:11:56 +00:00
|
|
|
|
static char *keywords[] = { "spec", "type", "wp_class", "internal", NULL };
|
2011-06-24 19:47:37 +00:00
|
|
|
|
const char *spec;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
int type = bp_breakpoint;
|
|
|
|
|
int access_type = hw_write;
|
2010-11-11 14:11:56 +00:00
|
|
|
|
PyObject *internal = NULL;
|
|
|
|
|
int internal_bp = 0;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
|
2010-11-11 14:11:56 +00:00
|
|
|
|
if (! PyArg_ParseTupleAndKeywords (args, kwargs, "s|iiO", keywords,
|
|
|
|
|
&spec, &type, &access_type, &internal))
|
2011-03-14 16:09:55 +00:00
|
|
|
|
return -1;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
|
2010-11-11 14:11:56 +00:00
|
|
|
|
if (internal)
|
|
|
|
|
{
|
|
|
|
|
internal_bp = PyObject_IsTrue (internal);
|
|
|
|
|
if (internal_bp == -1)
|
2011-03-14 16:09:55 +00:00
|
|
|
|
return -1;
|
2010-11-11 14:11:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-14 16:09:55 +00:00
|
|
|
|
bppy_pending_object = (breakpoint_object *) self;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
bppy_pending_object->number = -1;
|
|
|
|
|
bppy_pending_object->bp = NULL;
|
|
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
2011-06-24 19:47:37 +00:00
|
|
|
|
char *copy = xstrdup (spec);
|
|
|
|
|
struct cleanup *cleanup = make_cleanup (xfree, copy);
|
|
|
|
|
|
2010-04-09 09:41:43 +00:00
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case bp_breakpoint:
|
|
|
|
|
{
|
|
|
|
|
create_breakpoint (python_gdbarch,
|
2011-06-24 19:47:37 +00:00
|
|
|
|
copy, NULL, -1,
|
2010-04-09 09:41:43 +00:00
|
|
|
|
0,
|
Static tracepoints support, and UST integration.
gdb/gdbserver/
* configure.ac: Handle --with-ust. substitute ustlibs and ustinc.
* mem-break.c (uninsert_all_breakpoints)
(reinsert_all_breakpoints): New.
* mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints):
* tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New.
(gdb_agent_ust_loaded, helper_thread_id)
(gdb_agent_helper_thread_id): New macros.
(struct ipa_sym_addresses): Add addr_ust_loaded,
addr_helper_thread_id, addr_cmd_buf.
(symbol_list): Add ust_loaded, helper_thread_id, cmd_buf.
(in_process_agent_loaded_ust): New.
(write_e_ust_not_loaded): New.
(maybe_write_ipa_ust_not_loaded): New.
(struct collect_static_trace_data_action): New.
(enum tracepoint_type) <static_tracepoint>: New.
(struct tracepoint) <handle>: Mention static tracepoints.
(struct static_tracepoint_ctx): New.
(CMD_BUF_SIZE): New.
(add_tracepoint_action): Handle static tracepoint actions.
(unprobe_marker_at): New.
(clear_installed_tracepoints): Handle static tracepoints.
(cmd_qtdp): Handle static tracepoints.
(probe_marker_at): New.
(cmd_qtstart): Handle static tracepoints.
(response_tracepoint): Handle static tracepoints.
(cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New.
(handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat.
(get_context_regcache): Handle static tracepoints.
(do_action_at_tracepoint): Handle static tracepoint actions.
(traceframe_find_block_type): Handle static trace data blocks.
(traceframe_read_sdata): New.
(download_tracepoints): Download static tracepoint actions.
[HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h.
(GDB_PROBE_NAME): New.
(ust_ops): New.
(GET_UST_SYM): New.
(USTF): New.
(dlsym_ust): New.
(ust_marker_to_static_tracepoint): New.
(gdb_probe): New.
(collect_ust_data_at_tracepoint): New.
(gdb_ust_probe): New.
(UNIX_PATH_MAX, SOCK_DIR): New.
(gdb_ust_connect_sync_socket): New.
(resume_thread, stop_thread): New.
(run_inferior_command): New.
(init_named_socket): New.
(gdb_ust_socket_init): New.
(cstr_to_hexstr): New.
(next_st): New.
(first_marker, next_marker): New.
(response_ust_marker): New.
(cmd_qtfstm, cmd_qtsstm): New.
(unprobe_marker_at, probe_marker_at): New.
(cmd_qtstmat, gdb_ust_thread): New.
(gdb_ust_init): New.
(initialize_tracepoint_ftlib): Call gdb_ust_init.
* linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h
(ST_REGENTRY): New.
(x86_64_st_collect_regmap): New.
(X86_64_NUM_ST_COLLECT_GREGS): New.
(AMD64_RIP_REGNUM): New.
(supply_static_tracepoint_registers): New.
* linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h
(ST_REGENTRY): New.
(i386_st_collect_regmap): New.
(i386_NUM_ST_COLLECT_GREGS): New.
(supply_static_tracepoint_registers): New.
* server.c (handle_query): Handle qXfer:statictrace:read.
<qSupported>: Report support for StaticTracepoints, and
qXfer:statictrace:read features.
* server.h (traceframe_read_sdata)
(supply_static_tracepoint_registers): Declare.
* remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex)
(unpack_varlen_hex): Include in IPA build.
* Makefile.in (ustlibs, ustinc): New.
(IPA_OBJS): Add remote-utils-ipa.o.
($(IPA_LIB)): Link -ldl and -lpthread.
(UST_CFLAGS): New.
(IPAGENT_CFLAGS): Add UST_CFLAGS.
* config.in, configure: Regenerate.
gdb/
* NEWS: Mention new support for static tracepoints.
(New packets): Mention qTfSTM, qTsSTM, qTSTMat and
qXfer:statictrace:read.
(New features in the GDB remote stub, GDBserver): Mention static
tracepoints support using an UST based backend.
(New commands): Mention "info static-tracepoint-markers" and
"strace".
* breakpoint.c (is_marker_spec): New.
(is_tracepoint): Handle static tracepoints.
(validate_commands_for_breakpoint): Static tracepoints can't do
while-stepping.
(static_tracepoints_here): New.
(bpstat_what): Handle static tracepoints.
(print_one_breakpoint_location, allocate_bp_location, mention):
Ditto.
(create_breakpoint_sal): Ditto.
(decode_static_tracepoint_spec): New.
(create_breakpoint): Replace `hardwareflag', and `traceflag' with
`type_wanted'. Adjust. Handle static tracepoint marker
locations.
(break_command_1): Adjust.
(update_static_tracepoint): New.
(update_breakpoint_locations): Handle static tracepoints.
(breakpoint_re_set_one): Handle static tracepoint marker
locations.
(disable_command, enable_command): Handle static tracepoints.
(trace_command, ftrace_command): Adjust.
(strace_command): New.
(create_tracepoint_from_upload): Adjust.
(save_breakpoints): Handle static tracepoints.
(_initialize_breakpoint): Install the "strace" command.
* breakpoint.h (enum bptype): New bp_static_tracepoint type.
(struct breakpoint): New fields static_trace_marker_id and
static_trace_marker_id_idx.
(breakpoints_here_p): Declare.
(create_breakpoint): Adjust.
(static_tracepoints_here): Declare.
* remote.c (struct remote_state) <static_tracepoints>: New field.
(PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New.
(remote_static_tracepoint_marker_at): New.
(remote_static_tracepoint_markers_by_strid): New.
(remote_static_tracepoint_feature): New.
(remote_disconnected_tracing_feature): Handle "StaticTracepoints".
(remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA.
(remote_supports_static_tracepoints): New.
(remote_download_tracepoint): Download static tracepoints.
(init_remote_ops): Install remote_static_tracepoint_marker_at and
remote_static_tracepoint_markers_by_strid.
(_initialize_remote): Install set|show remote static-tracepoints,
and set|show remote read-sdata-object commands.
* target.c (update_current_target): Inherit and default
to_static_tracepoint_marker_at, and
to_static_tracepoint_markers_by_strid.
* target.h (static_tracepoint_marker): Forward declare.
(enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA.
(static_tracepoint_marker_p): New typedef.
(DEF_VEC_P(static_tracepoint_marker_p)): New VEC type.
(struct target_ops): New fields to_static_tracepoint_marker_at and
to_static_tracepoint_markers_by_strid.
(target_static_tracepoint_marker_at)
(target_static_tracepoint_markers_by_strid): New.
* tracepoint.c: Include source.h.
(validate_actionline): Handle $_sdata.
(struct collection_list): New field strace_data.
(add_static_trace_data): New.
(clear_collection_list): Clear strace_data.
(stringify_collection_list): Account for a possible static trace
data collection.
(encode_actions_1): Encode an $_sdata collection.
(parse_tracepoint_definition): Handle static tracepoints.
(parse_static_tracepoint_marker_definition): New.
(release_static_tracepoint_marker): New.
(print_one_static_tracepoint_marker): New.
(info_static_tracepoint_markers_command): New.
(sdata_make_value): New.
(_initialize_tracepoint): Create the $_sdata convenience variable.
Add the "info static-tracepoint-markers" command.
Mention $_sdata in the "collect" command's help output.
* tracepoint.h (struct static_tracepoint_marker): New.
(parse_static_tracepoint_marker_definition)
(release_static_tracepoint_marker): Declare.
* mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust.
* python/py-breakpoint.c (bppy_new): Adjust.
doc/
* gdb.texinfo (Convenience Variables): Document $_sdata.
(Commands to Set Tracepoints): Describe static tracepoints. Add
`Listing Static Tracepoint Markers' menu entry. Document
"strace".
(Tracepoint Action Lists): Document collecting $_sdata.
(Listing Static Tracepoint Markers): New subsection.
(Tracepoints support in gdbserver): Mention static tracepoints.
(remote packets, enabling and disabling): Mention
read-sdata-object.
(General Query Packets) <qSupported>: Document qXfer:sdata:read
and StaticTracepoint.
Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets.
Document qXfer:sdata:read.
(Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 10:36:12 +00:00
|
|
|
|
0, bp_breakpoint,
|
2010-04-09 09:41:43 +00:00
|
|
|
|
0,
|
|
|
|
|
AUTO_BOOLEAN_TRUE,
|
2011-07-25 Pedro Alves <pedro@codesourcery.com>
Implement most breakpoint_ops methods for all breakpoint types,
and move the default handlings to the proper callbacks.
gdb/
* breakpoint.c (update_watchpoint): Always call the breakpoint's
works_in_software_mode method.
(insert_bp_location): Go through breakpoint_ops->insert_location
for software and hardware watchpoints.
(create_internal_breakpoint): Pass bkpt_breakpoint_ops as
breakpoint_ops.
(remove_breakpoint_1): Go through breakpoint_ops->remove_location
for software and hardware watchpoints.
(print_it_typical): Delete.
(print_bp_stop_message): Always call the breakpoint_ops->print_it
method.
(watchpoint_check): Adjust comment.
(bpstat_check_location): Simply always call the breakpoint's
breakpoint_hit method.
(bpstat_stop_status): Always call the breakpoint's check_status
method. Remove special cases for watchpoints and internal event
breakpoints from here (moved to the check_status implementations).
(print_one_breakpoint_location): Assume b->ops is never NULL.
Remove static tracepoint marker id printing from here (moved to
the print_one_detail callback implementation of tracepoints).
(init_bp_location): Assert OPS is never NULL.
(allocate_bp_location): Always call the breakpoint's
allocate_location method, and remove the default code from here.
(free_bp_location): Always call the location's dtor method, and
remove the default code from here.
(init_raw_breakpoint_without_location): Assert OPS is never NULL.
(set_raw_breakpoint_without_location): Add new breakpoint_ops
parameter. Pass it down.
(set_raw_breakpoint): Ditto.
(print_it_catch_fork): Adjust to take a bpstat as argument.
(catch_fork_breakpoint_ops): Install methods.
(print_it_catch_vfork): Adjust to take a bpstat as argument.
(catch_vfork_breakpoint_ops): Install methods.
(dtor_catch_syscall): Call the base dtor.
(print_it_catch_syscall): Adjust to take a bpstat as argument.
(catch_syscall_breakpoint_ops): Install methods.
(dtor_catch_exec): Call the base dtor.
(print_it_catch_exec): Adjust to take a bpstat as argument.
(catch_exec_breakpoint_ops): Install methods.
(hw_breakpoint_used_count, hw_watchpoint_used_count): Always call
the breakpoint's resources_needed method, and remove the default
code from here.
(set_momentary_breakpoint): Pass bkpt_breakpoint_ops as
breakpoint_ops.
(clone_momentary_breakpoint): Clone the original's ops.
(mention): Always call the breakpoint's print_mention method, and
remove the default code from here.
(create_breakpoint_sal): Adjust to pass the ops to
set_raw_breakpoint rather than setting it manually.
(create_breakpoint): Assert ops is never NULL. Adjust to pass the
ops to set_raw_breakpoint_without_location rather than setting it
manually.
(break_command_1): Pass bkpt_breakpoint_ops as breakpoint_ops.
(print_it_ranged_breakpoint): Adjust to take a bpstat as argument.
(ranged_breakpoint_ops): Install methods.
(break_range_command): Adjust to pass the ops to
set_raw_breakpoint rather than setting it manually.
(re_set_watchpoint, breakpoint_hit_watchpoint)
(check_status_watchpoint, resources_needed_watchpoint)
(works_in_software_mode_watchpoint, print_it_watchpoint)
(print_mention_watchpoint, print_recreate_watchpoint): New
functions.
(watchpoint_breakpoint_ops): Install new methods.
(print_it_masked_watchpoint): New function.
(masked_watchpoint_breakpoint_ops): Install new methods.
(watch_command_1): Adjust to pass the right breakpoint_ops to
set_raw_breakpoint_without_location rather than setting it
manually later. Record the current pspace.
(print_it_exception_catchpoint): Adjust to take a bpstat as
argument.
(gnu_v3_exception_catchpoint_ops): Install new methods.
(say_where): New function.
(null_re_set, null_check_status, null_works_in_software_mode)
(null_resources_needed, null_print_one_detail, bp_location_dtor):
New functions.
(bp_location_ops): New global.
(bkpt_dtor, bkpt_allocate_location, bkpt_re_set)
(bkpt_insert_location, bkpt_remove_location, bkpt_breakpoint_hit)
(bkpt_check_status, bkpt_resources_needed)
(bkpt_works_in_software_mode, bkpt_print_it, bkpt_print_mention)
(bkpt_print_recreate): New functions.
(bkpt_breakpoint_ops): New global.
(tracepoint_re_set, tracepoint_insert_location)
(tracepoint_remove_location, tracepoint_breakpoint_hit)
(tracepoint_check_status, tracepoint_works_in_software_mode)
(tracepoint_print_it, tracepoint_print_one_detail)
(tracepoint_print_mention, tracepoint_print_recreate): New
functions.
(tracepoint_breakpoint_ops): New global.
(delete_breakpoint): Always call the breakpoint's dtor method, and
remove the default handling from here.
(breakpoint_re_set_default): Make static.
(breakpoint_re_set_one): Always call the breakpoints re_set
method, and remove the default handling from here.
(trace_command, ftrace_command, strace_command)
(create_tracepoint_from_upload): Pass appropriate breakpoints_ops
to create_breakpoint.
(save_breakpoints): Always call the breakpoint's print_recreate
method, and remove the default handling from here.
* ada-lang.c (dtor_exception): Call the base dtor.
(re_set_exception): Call the base method.
(print_it_exception, print_it_catch_exception): Adjust to take a
bpstat as argument.
(catch_exception_breakpoint_ops): Install methods.
(print_it_catch_exception_unhandled): Adjust to take a bpstat as
argument.
(catch_exception_unhandled_breakpoint_ops): Install methods.
(print_it_catch_assert): Adjust to take a bpstat as argument.
(catch_assert_breakpoint_ops): Install methods.
* breakpoint.h (struct breakpoint_ops): Adjust the print_it method
to take a bpstat as argument.
(enum print_stop_action): Add describing comments to each enum
value.
(breakpoint_re_set_default): Delete declaration.
(null_re_set, null_works_in_software_mode, null_resources_needed)
(null_check_status, null_print_one_detail): Declare.
(bkpt_breakpoint_ops): Declare.
(bkpt_dtor, bkpt_allocate_location, bkpt_re_set)
(bkpt_insert_location, bkpt_remove_location, bkpt_breakpoint_hit)
(bkpt_check_status, bkpt_resources_needed)
(bkpt_works_in_software_mode, bkpt_print_it)
(null_print_one_detail, bkpt_print_mention, bkpt_print_recreate):
Declare.
* mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust to pass
bkpt_breakpoint_ops.
* python/py-breakpoint.c (bppy_init): Ditto.
2011-07-25 11:16:49 +00:00
|
|
|
|
&bkpt_breakpoint_ops,
|
|
|
|
|
0, 1, internal_bp);
|
2010-04-09 09:41:43 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case bp_watchpoint:
|
|
|
|
|
{
|
|
|
|
|
if (access_type == hw_write)
|
2011-06-24 19:47:37 +00:00
|
|
|
|
watch_command_wrapper (copy, 0, internal_bp);
|
2010-04-09 09:41:43 +00:00
|
|
|
|
else if (access_type == hw_access)
|
2011-06-24 19:47:37 +00:00
|
|
|
|
awatch_command_wrapper (copy, 0, internal_bp);
|
2010-04-09 09:41:43 +00:00
|
|
|
|
else if (access_type == hw_read)
|
2011-06-24 19:47:37 +00:00
|
|
|
|
rwatch_command_wrapper (copy, 0, internal_bp);
|
2010-04-09 09:41:43 +00:00
|
|
|
|
else
|
|
|
|
|
error(_("Cannot understand watchpoint access type."));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
error(_("Do not understand breakpoint type to set."));
|
|
|
|
|
}
|
2011-06-24 19:47:37 +00:00
|
|
|
|
|
|
|
|
|
do_cleanups (cleanup);
|
2010-04-09 09:41:43 +00:00
|
|
|
|
}
|
|
|
|
|
if (except.reason < 0)
|
|
|
|
|
{
|
2011-03-14 16:09:55 +00:00
|
|
|
|
PyErr_Format (except.reason == RETURN_QUIT
|
|
|
|
|
? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
|
|
|
|
|
"%s", except.message);
|
|
|
|
|
return -1;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-14 16:09:55 +00:00
|
|
|
|
BPPY_SET_REQUIRE_VALID ((breakpoint_object *) self);
|
|
|
|
|
return 0;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-11-11 14:11:56 +00:00
|
|
|
|
static int
|
|
|
|
|
build_bp_list (struct breakpoint *b, void *arg)
|
|
|
|
|
{
|
|
|
|
|
PyObject *list = arg;
|
2010-11-25 13:10:07 +00:00
|
|
|
|
PyObject *bp = (PyObject *) b->py_bp_object;
|
2010-11-11 14:11:56 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-09 09:41:43 +00:00
|
|
|
|
/* Static function to return a tuple holding all breakpoints. */
|
|
|
|
|
|
|
|
|
|
PyObject *
|
|
|
|
|
gdbpy_breakpoints (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
2011-10-20 13:34:17 +00:00
|
|
|
|
PyObject *list, *tuple;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
|
|
|
|
|
if (bppy_live == 0)
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
|
2010-11-11 14:11:56 +00:00
|
|
|
|
list = PyList_New (0);
|
|
|
|
|
if (!list)
|
|
|
|
|
return NULL;
|
2010-05-17 21:23:25 +00:00
|
|
|
|
|
2010-11-11 14:11:56 +00:00
|
|
|
|
/* If iteratre_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) != NULL)
|
|
|
|
|
{
|
|
|
|
|
Py_DECREF (list);
|
|
|
|
|
return NULL;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
}
|
2010-11-11 14:11:56 +00:00
|
|
|
|
|
2011-10-20 13:34:17 +00:00
|
|
|
|
tuple = PyList_AsTuple (list);
|
|
|
|
|
Py_DECREF (list);
|
|
|
|
|
|
|
|
|
|
return tuple;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-14 16:09:55 +00:00
|
|
|
|
/* 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. */
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
gdbpy_should_stop (struct breakpoint_object *bp_obj)
|
|
|
|
|
{
|
|
|
|
|
int stop = 1;
|
|
|
|
|
|
|
|
|
|
PyObject *py_bp = (PyObject *) bp_obj;
|
|
|
|
|
struct breakpoint *b = bp_obj->bp;
|
|
|
|
|
struct gdbarch *garch = b->gdbarch ? b->gdbarch : get_current_arch ();
|
|
|
|
|
struct cleanup *cleanup = ensure_python_env (garch, current_language);
|
|
|
|
|
|
|
|
|
|
if (PyObject_HasAttrString (py_bp, stop_func))
|
|
|
|
|
{
|
|
|
|
|
PyObject *result = PyObject_CallMethod (py_bp, stop_func, NULL);
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
int evaluate = PyObject_IsTrue (result);
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
Py_DECREF (result);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
|
}
|
|
|
|
|
do_cleanups (cleanup);
|
|
|
|
|
|
|
|
|
|
return stop;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Checks if the "stop" method exists in this breakpoint.
|
|
|
|
|
Used by condition_command to ensure mutual exclusion of breakpoint
|
|
|
|
|
conditions. */
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
gdbpy_breakpoint_has_py_cond (struct breakpoint_object *bp_obj)
|
|
|
|
|
{
|
|
|
|
|
int has_func = 0;
|
|
|
|
|
PyObject *py_bp = (PyObject *) bp_obj;
|
|
|
|
|
struct gdbarch *garch = bp_obj->bp->gdbarch ? bp_obj->bp->gdbarch :
|
|
|
|
|
get_current_arch ();
|
|
|
|
|
struct cleanup *cleanup = ensure_python_env (garch, current_language);
|
|
|
|
|
|
2011-06-27 19:21:51 +00:00
|
|
|
|
if (py_bp != NULL)
|
|
|
|
|
has_func = PyObject_HasAttrString (py_bp, stop_func);
|
2011-03-14 16:09:55 +00:00
|
|
|
|
|
|
|
|
|
do_cleanups (cleanup);
|
|
|
|
|
|
|
|
|
|
return has_func;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-09 09:41:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Event callback functions. */
|
|
|
|
|
|
|
|
|
|
/* Callback that is used when a breakpoint is created. This function
|
|
|
|
|
will create a new Python breakpoint object. */
|
|
|
|
|
static void
|
MI breakpoint notifications.
* annotate.c (breakpoint_changed): Adjust parameter type.
* breakpoint.c (set_breakpoint_condition): Adjust to change
in breakpoint_modified type.
(breakpoint_set_commands): Likewise.
(do_map_commands_command): Likewise.
(bpstat_check_breakpoint_conditions): Notify that breakpoint has
changed after bumping hit count.
(bpstat_stop_status): Likewise.
(print_one_breakpoint_location): Don't wrap in tuple here.
(print_one_breakpoint): Always print individual locations.
For locations, use unnamed tuple.
(disable_breakpoints_in_unloaded_shlib): Notify that breakpoint
has changed.
(create_catchpoint, create_syscall_event_catchpoint): Call
breakpoint_created obsever.
(mention): Don't call breakpoint_created observer.
(create_breakpoint_sal): Call breakpoint_created observer.
(create_breakpoint, watch_command_1): Likewise.
(create_ada_exception_breakpoint): Likewise.
(delete_breakpoint): Call breakpoint_deleted breakpoint.
(locations_are_equal): New.
(update_breakpoint_locations): If locations were changed, notify.
(set_ignore_count, disable_breakpoint, do_enable_breakpoint):
Call breakpoint_modified observer.
* mi/mi-cmd-break.c (breakpoint_notify): Adjust.
(mi_cmd_break_insert): Don't set observers for modify and delete.
* mi/mi-interp.c (mi_suppress_breakpoint_notifications): New.
(mi_breakpoint_created, mi_breakpoint_deleted)
(mi_breakpoint_modified): New.
(mi_interpreter_init): Hook the above.
* mi/mi-main.c (mi_cmd_execute): Disable breakpoint notifications
while -break-* commands are executing.
* mi/mi-main.h (mi_suppress_breakpoint_notifications): New.
* mi/mi-out.c (struct ui_out_data): New field original_buffer.
(mi_redirect): New.
(mi_ui_out_impl): Hook in mi_redirect.
(mi_field_skip): True to the name, skip the field, don't output
a field with an empty value.
* python/py-breakpoint.c (gdbpy_breakpoint_created)
(gdbpy_breakpoint_deleted): Adjust.
* tui/tui-hooks.c (tui_event_create_breakpoint)
(tui_event_delete_breakpoint, tui_event_modify_breakpoint): Adjust.
2011-04-27 10:17:39 +00:00
|
|
|
|
gdbpy_breakpoint_created (struct breakpoint *bp)
|
2010-04-09 09:41:43 +00:00
|
|
|
|
{
|
|
|
|
|
breakpoint_object *newbp;
|
|
|
|
|
PyGILState_STATE state;
|
|
|
|
|
|
2011-04-27 12:04:42 +00:00
|
|
|
|
if (bp->number < 0 && bppy_pending_object == NULL)
|
2010-11-11 14:11:56 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2010-04-09 09:41:43 +00:00
|
|
|
|
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 (breakpoint_object, &breakpoint_object_type);
|
|
|
|
|
if (newbp)
|
|
|
|
|
{
|
MI breakpoint notifications.
* annotate.c (breakpoint_changed): Adjust parameter type.
* breakpoint.c (set_breakpoint_condition): Adjust to change
in breakpoint_modified type.
(breakpoint_set_commands): Likewise.
(do_map_commands_command): Likewise.
(bpstat_check_breakpoint_conditions): Notify that breakpoint has
changed after bumping hit count.
(bpstat_stop_status): Likewise.
(print_one_breakpoint_location): Don't wrap in tuple here.
(print_one_breakpoint): Always print individual locations.
For locations, use unnamed tuple.
(disable_breakpoints_in_unloaded_shlib): Notify that breakpoint
has changed.
(create_catchpoint, create_syscall_event_catchpoint): Call
breakpoint_created obsever.
(mention): Don't call breakpoint_created observer.
(create_breakpoint_sal): Call breakpoint_created observer.
(create_breakpoint, watch_command_1): Likewise.
(create_ada_exception_breakpoint): Likewise.
(delete_breakpoint): Call breakpoint_deleted breakpoint.
(locations_are_equal): New.
(update_breakpoint_locations): If locations were changed, notify.
(set_ignore_count, disable_breakpoint, do_enable_breakpoint):
Call breakpoint_modified observer.
* mi/mi-cmd-break.c (breakpoint_notify): Adjust.
(mi_cmd_break_insert): Don't set observers for modify and delete.
* mi/mi-interp.c (mi_suppress_breakpoint_notifications): New.
(mi_breakpoint_created, mi_breakpoint_deleted)
(mi_breakpoint_modified): New.
(mi_interpreter_init): Hook the above.
* mi/mi-main.c (mi_cmd_execute): Disable breakpoint notifications
while -break-* commands are executing.
* mi/mi-main.h (mi_suppress_breakpoint_notifications): New.
* mi/mi-out.c (struct ui_out_data): New field original_buffer.
(mi_redirect): New.
(mi_ui_out_impl): Hook in mi_redirect.
(mi_field_skip): True to the name, skip the field, don't output
a field with an empty value.
* python/py-breakpoint.c (gdbpy_breakpoint_created)
(gdbpy_breakpoint_deleted): Adjust.
* tui/tui-hooks.c (tui_event_create_breakpoint)
(tui_event_delete_breakpoint, tui_event_modify_breakpoint): Adjust.
2011-04-27 10:17:39 +00:00
|
|
|
|
newbp->number = bp->number;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
newbp->bp = bp;
|
2010-11-25 13:10:07 +00:00
|
|
|
|
newbp->bp->py_bp_object = newbp;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
Py_INCREF (newbp);
|
2010-11-11 14:11:56 +00:00
|
|
|
|
++bppy_live;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
|
|
|
|
_("Error while creating breakpoint from GDB."));
|
|
|
|
|
gdbpy_print_stack ();
|
2010-04-09 09:41:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PyGILState_Release (state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Callback that is used when a breakpoint is deleted. This will
|
|
|
|
|
invalidate the corresponding Python object. */
|
|
|
|
|
static void
|
MI breakpoint notifications.
* annotate.c (breakpoint_changed): Adjust parameter type.
* breakpoint.c (set_breakpoint_condition): Adjust to change
in breakpoint_modified type.
(breakpoint_set_commands): Likewise.
(do_map_commands_command): Likewise.
(bpstat_check_breakpoint_conditions): Notify that breakpoint has
changed after bumping hit count.
(bpstat_stop_status): Likewise.
(print_one_breakpoint_location): Don't wrap in tuple here.
(print_one_breakpoint): Always print individual locations.
For locations, use unnamed tuple.
(disable_breakpoints_in_unloaded_shlib): Notify that breakpoint
has changed.
(create_catchpoint, create_syscall_event_catchpoint): Call
breakpoint_created obsever.
(mention): Don't call breakpoint_created observer.
(create_breakpoint_sal): Call breakpoint_created observer.
(create_breakpoint, watch_command_1): Likewise.
(create_ada_exception_breakpoint): Likewise.
(delete_breakpoint): Call breakpoint_deleted breakpoint.
(locations_are_equal): New.
(update_breakpoint_locations): If locations were changed, notify.
(set_ignore_count, disable_breakpoint, do_enable_breakpoint):
Call breakpoint_modified observer.
* mi/mi-cmd-break.c (breakpoint_notify): Adjust.
(mi_cmd_break_insert): Don't set observers for modify and delete.
* mi/mi-interp.c (mi_suppress_breakpoint_notifications): New.
(mi_breakpoint_created, mi_breakpoint_deleted)
(mi_breakpoint_modified): New.
(mi_interpreter_init): Hook the above.
* mi/mi-main.c (mi_cmd_execute): Disable breakpoint notifications
while -break-* commands are executing.
* mi/mi-main.h (mi_suppress_breakpoint_notifications): New.
* mi/mi-out.c (struct ui_out_data): New field original_buffer.
(mi_redirect): New.
(mi_ui_out_impl): Hook in mi_redirect.
(mi_field_skip): True to the name, skip the field, don't output
a field with an empty value.
* python/py-breakpoint.c (gdbpy_breakpoint_created)
(gdbpy_breakpoint_deleted): Adjust.
* tui/tui-hooks.c (tui_event_create_breakpoint)
(tui_event_delete_breakpoint, tui_event_modify_breakpoint): Adjust.
2011-04-27 10:17:39 +00:00
|
|
|
|
gdbpy_breakpoint_deleted (struct breakpoint *b)
|
2010-04-09 09:41:43 +00:00
|
|
|
|
{
|
MI breakpoint notifications.
* annotate.c (breakpoint_changed): Adjust parameter type.
* breakpoint.c (set_breakpoint_condition): Adjust to change
in breakpoint_modified type.
(breakpoint_set_commands): Likewise.
(do_map_commands_command): Likewise.
(bpstat_check_breakpoint_conditions): Notify that breakpoint has
changed after bumping hit count.
(bpstat_stop_status): Likewise.
(print_one_breakpoint_location): Don't wrap in tuple here.
(print_one_breakpoint): Always print individual locations.
For locations, use unnamed tuple.
(disable_breakpoints_in_unloaded_shlib): Notify that breakpoint
has changed.
(create_catchpoint, create_syscall_event_catchpoint): Call
breakpoint_created obsever.
(mention): Don't call breakpoint_created observer.
(create_breakpoint_sal): Call breakpoint_created observer.
(create_breakpoint, watch_command_1): Likewise.
(create_ada_exception_breakpoint): Likewise.
(delete_breakpoint): Call breakpoint_deleted breakpoint.
(locations_are_equal): New.
(update_breakpoint_locations): If locations were changed, notify.
(set_ignore_count, disable_breakpoint, do_enable_breakpoint):
Call breakpoint_modified observer.
* mi/mi-cmd-break.c (breakpoint_notify): Adjust.
(mi_cmd_break_insert): Don't set observers for modify and delete.
* mi/mi-interp.c (mi_suppress_breakpoint_notifications): New.
(mi_breakpoint_created, mi_breakpoint_deleted)
(mi_breakpoint_modified): New.
(mi_interpreter_init): Hook the above.
* mi/mi-main.c (mi_cmd_execute): Disable breakpoint notifications
while -break-* commands are executing.
* mi/mi-main.h (mi_suppress_breakpoint_notifications): New.
* mi/mi-out.c (struct ui_out_data): New field original_buffer.
(mi_redirect): New.
(mi_ui_out_impl): Hook in mi_redirect.
(mi_field_skip): True to the name, skip the field, don't output
a field with an empty value.
* python/py-breakpoint.c (gdbpy_breakpoint_created)
(gdbpy_breakpoint_deleted): Adjust.
* tui/tui-hooks.c (tui_event_create_breakpoint)
(tui_event_delete_breakpoint, tui_event_modify_breakpoint): Adjust.
2011-04-27 10:17:39 +00:00
|
|
|
|
int num = b->number;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
PyGILState_STATE state;
|
2010-11-11 14:11:56 +00:00
|
|
|
|
struct breakpoint *bp = NULL;
|
|
|
|
|
breakpoint_object *bp_obj;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
|
|
|
|
|
state = PyGILState_Ensure ();
|
2010-11-11 14:11:56 +00:00
|
|
|
|
bp = get_breakpoint (num);
|
2011-10-13 14:54:14 +00:00
|
|
|
|
if (bp)
|
2010-04-09 09:41:43 +00:00
|
|
|
|
{
|
2011-10-13 14:54:14 +00:00
|
|
|
|
bp_obj = bp->py_bp_object;
|
|
|
|
|
if (bp_obj)
|
|
|
|
|
{
|
|
|
|
|
bp_obj->bp = NULL;
|
|
|
|
|
--bppy_live;
|
|
|
|
|
Py_DECREF (bp_obj);
|
|
|
|
|
}
|
2010-04-09 09:41:43 +00:00
|
|
|
|
}
|
|
|
|
|
PyGILState_Release (state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Initialize the Python breakpoint code. */
|
|
|
|
|
void
|
|
|
|
|
gdbpy_initialize_breakpoints (void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
2011-08-05 14:24:10 +00:00
|
|
|
|
breakpoint_object_type.tp_new = PyType_GenericNew;
|
2010-04-09 09:41:43 +00:00
|
|
|
|
if (PyType_Ready (&breakpoint_object_type) < 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Py_INCREF (&breakpoint_object_type);
|
|
|
|
|
PyModule_AddObject (gdb_module, "Breakpoint",
|
|
|
|
|
(PyObject *) &breakpoint_object_type);
|
|
|
|
|
|
|
|
|
|
observer_attach_breakpoint_created (gdbpy_breakpoint_created);
|
|
|
|
|
observer_attach_breakpoint_deleted (gdbpy_breakpoint_deleted);
|
|
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-03-14 16:09:55 +00:00
|
|
|
|
/* 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)
|
|
|
|
|
{
|
|
|
|
|
breakpoint_object *obj = (breakpoint_object *) self;
|
|
|
|
|
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, disallow this
|
|
|
|
|
operation. */
|
|
|
|
|
if (strcmp (attr, stop_func) == 0 && obj->bp->cond_string)
|
|
|
|
|
{
|
|
|
|
|
xfree (attr);
|
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
|
|
|
|
_("Cannot set 'stop' method. There is an " \
|
|
|
|
|
"existing GDB condition attached to the " \
|
|
|
|
|
"breakpoint."));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xfree (attr);
|
|
|
|
|
|
|
|
|
|
return PyObject_GenericSetAttr ((PyObject *)self, name, v);
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-09 09:41:43 +00:00
|
|
|
|
static 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."},
|
2010-11-11 14:11:56 +00:00
|
|
|
|
{ "visible", bppy_get_visibility, NULL,
|
|
|
|
|
"Whether the breakpoint is visible to the user."},
|
2010-04-09 09:41:43 +00:00
|
|
|
|
{ NULL } /* Sentinel. */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static PyMethodDef breakpoint_object_methods[] =
|
|
|
|
|
{
|
|
|
|
|
{ "is_valid", bppy_is_valid, METH_NOARGS,
|
|
|
|
|
"Return true if this breakpoint is valid, false if not." },
|
2010-11-29 13:49:05 +00:00
|
|
|
|
{ "delete", bppy_delete_breakpoint, METH_NOARGS,
|
|
|
|
|
"Delete the underlying GDB breakpoint." },
|
2010-04-09 09:41:43 +00:00
|
|
|
|
{ NULL } /* Sentinel. */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static PyTypeObject breakpoint_object_type =
|
|
|
|
|
{
|
|
|
|
|
PyObject_HEAD_INIT (NULL)
|
|
|
|
|
0, /*ob_size*/
|
|
|
|
|
"gdb.Breakpoint", /*tp_name*/
|
|
|
|
|
sizeof (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*/
|
2011-03-14 16:09:55 +00:00
|
|
|
|
(setattrofunc)local_setattro, /*tp_setattro */
|
2010-04-09 09:41:43 +00:00
|
|
|
|
0, /*tp_as_buffer*/
|
2011-03-14 16:09:55 +00:00
|
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
2010-04-09 09:41:43 +00:00
|
|
|
|
"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 */
|
2011-03-14 16:09:55 +00:00
|
|
|
|
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 */
|
2010-04-09 09:41:43 +00:00
|
|
|
|
};
|