Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

upgrade to gdb 7.2

  • Loading branch information...
commit 0f0c81894003195b9aefca7018951921d9585117 1 parent 8e0c479
@tmm1 authored
View
4 ext/extconf.rb
@@ -36,7 +36,7 @@ def sys(cmd)
exit(1)
end
-gdb = File.basename('gdb-7.0.tar.bz2')
+gdb = File.basename('gdb-7.2.tar.bz2')
dir = File.basename(gdb, '.tar.bz2')
puts "(I'm about to compile gdb7.. this will definitely take a while)"
@@ -53,8 +53,6 @@ def sys(cmd)
end
%w[
- gdb-eval
- gdb-breakpoints
gdb-leak
gdb-strings
].each do |patch|
View
BIN  ext/src/gdb-7.0.tar.bz2
Binary file not shown
View
744 patches/gdb-breakpoints.patch
@@ -1,744 +0,0 @@
-diff --git a/Makefile.in b/Makefile.in
-index 7d53205..ed6729e 100644
---- a/Makefile.in
-+++ b/Makefile.in
-@@ -267,6 +267,7 @@ SUBDIR_TUI_CFLAGS= \
- #
- SUBDIR_PYTHON_OBS = \
- python.o \
-+ py-breakpoint.o \
- py-cmd.o \
- py-frame.o \
- py-function.o \
-@@ -277,6 +278,7 @@ SUBDIR_PYTHON_OBS = \
- py-value.o
- SUBDIR_PYTHON_SRCS = \
- python/python.c \
-+ python/py-breakpoint.c \
- python/py-cmd.c \
- python/py-frame.c \
- python/py-function.c \
-@@ -1963,6 +1965,10 @@ python.o: $(srcdir)/python/python.c
- $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python.c
- $(POSTCOMPILE)
-
-+py-breakpoint.o: $(srcdir)/python/py-breakpoint.c
-+ $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-breakpoint.c
-+ $(POSTCOMPILE)
-+
- py-cmd.o: $(srcdir)/python/py-cmd.c
- $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-cmd.c
- $(POSTCOMPILE)
-diff --git a/python/py-breakpoint.c b/python/py-breakpoint.c
-new file mode 100644
-index 0000000..913deec
---- /dev/null
-+++ b/python/py-breakpoint.c
-@@ -0,0 +1,665 @@
-+/* Python interface to breakpoints
-+
-+ Copyright (C) 2008, 2009 Free Software Foundation, Inc.
-+
-+ This file is part of GDB.
-+
-+ This program is free software; you can redistribute it and/or modify
-+ it under the terms of the GNU General Public License as published by
-+ the Free Software Foundation; either version 3 of the License, or
-+ (at your option) any later version.
-+
-+ This program is distributed in the hope that it will be useful,
-+ but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ GNU General Public License for more details.
-+
-+ You should have received a copy of the GNU General Public License
-+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
-+
-+#include "defs.h"
-+#include "value.h"
-+#include "exceptions.h"
-+#include "python-internal.h"
-+#include "charset.h"
-+#include "breakpoint.h"
-+#include "gdbcmd.h"
-+#include "gdbthread.h"
-+#include "observer.h"
-+#include "arch-utils.h"
-+#include "language.h"
-+
-+/* From breakpoint.c. */
-+extern struct breakpoint *breakpoint_chain;
-+
-+
-+typedef struct breakpoint_object breakpoint_object;
-+
-+static PyTypeObject breakpoint_object_type;
-+
-+/* A dynamically allocated vector of breakpoint objects. Each
-+ breakpoint has a number. A breakpoint is valid if its slot in this
-+ vector is non-null. When a breakpoint is deleted, we drop our
-+ reference to it and zero its slot; this is how we let the Python
-+ object have a lifetime which is independent from that of the gdb
-+ breakpoint. */
-+static breakpoint_object **bppy_breakpoints;
-+
-+/* Number of slots in bppy_breakpoints. */
-+static int bppy_slots;
-+
-+/* 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;
-+
-+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;
-+};
-+
-+/* Evaluate to true if the breakpoint NUM is valid, false otherwise. */
-+#define BPPY_VALID_P(Num) \
-+ ((Num) >= 0 \
-+ && (Num) < bppy_slots \
-+ && bppy_breakpoints[Num] != NULL)
-+
-+/* Require that BREAKPOINT be a valid breakpoint ID; throw a Python
-+ exception if it is invalid. */
-+#define BPPY_REQUIRE_VALID(Breakpoint) \
-+ do { \
-+ if (! BPPY_VALID_P ((Breakpoint)->number)) \
-+ return PyErr_Format (PyExc_RuntimeError, "breakpoint %d is invalid", \
-+ (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 { \
-+ if (! BPPY_VALID_P ((Breakpoint)->number)) \
-+ { \
-+ PyErr_Format (PyExc_RuntimeError, "breakpoint %d is invalid", \
-+ (Breakpoint)->number); \
-+ return -1; \
-+ } \
-+ } while (0)
-+
-+/* Python function which checks the validity of a breakpoint object. */
-+static PyObject *
-+bppy_is_valid (PyObject *self, PyObject *args)
-+{
-+ if (((breakpoint_object *) self)->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)
-+{
-+ if (! ((breakpoint_object *) self)->bp)
-+ Py_RETURN_FALSE;
-+ /* Not clear what we really want here. */
-+ if (((breakpoint_object *) self)->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)
-+{
-+ BPPY_REQUIRE_VALID ((breakpoint_object *) self);
-+ if (((breakpoint_object *) self)->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;
-+
-+ 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;
-+ else if (cmp == 1)
-+ enable_breakpoint (self_bp->bp);
-+ else
-+ disable_breakpoint (self_bp->bp);
-+ 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
-+ self_bp->bp->silent = cmp;
-+
-+ 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;
-+ int id;
-+
-+ BPPY_SET_REQUIRE_VALID (self_bp);
-+
-+ if (newvalue == NULL)
-+ {
-+ PyErr_SetString (PyExc_TypeError, "cannot delete `thread' attribute");
-+ return -1;
-+ }
-+ else if (PyInt_Check (newvalue))
-+ {
-+ id = (int) PyInt_AsLong (newvalue);
-+ 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;
-+ }
-+
-+ self_bp->bp->thread = id;
-+
-+ return 0;
-+}
-+
-+/* 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;
-+ }
-+
-+ value = PyInt_AsLong (newvalue);
-+ 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;
-+ }
-+ else if (! PyInt_Check (newvalue) || PyInt_AsLong (newvalue) != 0)
-+ {
-+ PyErr_SetString (PyExc_AttributeError,
-+ "the value of `hit_count' must be zero");
-+ return -1;
-+ }
-+
-+ self_bp->bp->hit_count = 0;
-+
-+ return 0;
-+}
-+
-+/* Python function to get the location of a breakpoint. */
-+static PyObject *
-+bppy_get_location (PyObject *self, void *closure)
-+{
-+ char *str;
-+
-+ BPPY_REQUIRE_VALID ((breakpoint_object *) self);
-+ str = ((breakpoint_object *) self)->bp->addr_string;
-+ /* FIXME: watchpoints? tracepoints? */
-+ 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;
-+// BPPY_REQUIRE_VALID ((breakpoint_object *) self);
-+//
-+// str = ((breakpoint_object *) self)->bp->cond_string;
-+// if (! str)
-+// Py_RETURN_NONE;
-+// return PyString_Decode (str, strlen (str), host_charset (), NULL);
-+// }
-+
-+// 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);
-+// }
-+// GDB_PY_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;
-+ 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);
-+
-+ TRY_CATCH (except, RETURN_MASK_ALL)
-+ {
-+ /* FIXME: this can fail. Maybe we need to be making a new
-+ ui_out object here? */
-+ ui_out_redirect (uiout, string_file);
-+ print_command_lines (uiout, self_bp->bp->commands, 0);
-+ ui_out_redirect (uiout, NULL);
-+ }
-+ cmdstr = ui_file_xstrdup (string_file, &length);
-+ GDB_PY_HANDLE_EXCEPTION (except);
-+
-+ result = PyString_Decode (cmdstr, strlen (cmdstr), host_charset (), NULL);
-+ do_cleanups (chain);
-+ xfree (cmdstr);
-+ return result;
-+}
-+
-+/* 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 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. */
-+static PyObject *
-+bppy_new (PyTypeObject *subtype, PyObject *args, PyObject *kwargs)
-+{
-+ PyObject *result;
-+ char *spec;
-+ volatile struct gdb_exception except;
-+
-+ /* FIXME: allow condition, thread, temporary, ... ? */
-+ if (! PyArg_ParseTuple (args, "s", &spec))
-+ return NULL;
-+ result = subtype->tp_alloc (subtype, 0);
-+ if (! result)
-+ return NULL;
-+ bppy_pending_object = (breakpoint_object *) result;
-+ bppy_pending_object->number = -1;
-+ bppy_pending_object->bp = NULL;
-+
-+ TRY_CATCH (except, RETURN_MASK_ALL)
-+ {
-+ set_breakpoint (python_gdbarch, spec, NULL, 0, 0, -1, 0,
-+ AUTO_BOOLEAN_TRUE, 1);
-+ }
-+ if (except.reason < 0)
-+ {
-+ subtype->tp_free (result);
-+ return PyErr_Format (except.reason == RETURN_QUIT
-+ ? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
-+ "%s", except.message);
-+ }
-+
-+ BPPY_REQUIRE_VALID ((breakpoint_object *) result);
-+ return result;
-+}
-+
-+
-+
-+/* Static function to return a tuple holding all breakpoints. */
-+
-+PyObject *
-+gdbpy_breakpoints (PyObject *self, PyObject *args)
-+{
-+ PyObject *result;
-+
-+ if (bppy_live == 0)
-+ Py_RETURN_NONE;
-+
-+ result = PyTuple_New (bppy_live);
-+ if (result)
-+ {
-+ int i, out = 0;
-+ for (i = 0; out < bppy_live; ++i)
-+ {
-+ if (! bppy_breakpoints[i])
-+ continue;
-+ Py_INCREF (bppy_breakpoints[i]);
-+ PyTuple_SetItem (result, out, (PyObject *) bppy_breakpoints[i]);
-+ ++out;
-+ }
-+ }
-+ return result;
-+}
-+
-+
-+
-+/* Event callback functions. */
-+
-+/* Callback that is used when a breakpoint is created. This function
-+ will create a new Python breakpoint object. */
-+static void
-+gdbpy_breakpoint_created (int num)
-+{
-+ breakpoint_object *newbp;
-+ struct breakpoint *bp;
-+ struct cleanup *cleanup;
-+
-+ if (num < 0)
-+ return;
-+
-+ for (bp = breakpoint_chain; bp; bp = bp->next)
-+ if (bp->number == num)
-+ break;
-+ if (! bp)
-+ return;
-+
-+ if (num >= bppy_slots)
-+ {
-+ int old = bppy_slots;
-+ bppy_slots = bppy_slots * 2 + 10;
-+ bppy_breakpoints
-+ = (breakpoint_object **) xrealloc (bppy_breakpoints,
-+ (bppy_slots
-+ * sizeof (breakpoint_object *)));
-+ memset (&bppy_breakpoints[old], 0,
-+ (bppy_slots - old) * sizeof (PyObject *));
-+ }
-+
-+ ++bppy_live;
-+
-+ cleanup = ensure_python_env (get_current_arch (), current_language);
-+
-+ if (bppy_pending_object)
-+ {
-+ newbp = bppy_pending_object;
-+ bppy_pending_object = NULL;
-+ }
-+ else
-+ newbp = PyObject_New (breakpoint_object, &breakpoint_object_type);
-+ if (newbp)
-+ {
-+ // PyObject *hookfn;
-+
-+ newbp->number = num;
-+ newbp->bp = bp;
-+ bppy_breakpoints[num] = newbp;
-+
-+ // hookfn = gdbpy_get_hook_function ("new_breakpoint");
-+ // if (hookfn)
-+ // {
-+ // PyObject *result;
-+ // result = PyObject_CallFunctionObjArgs (hookfn, newbp, NULL);
-+ // if (result)
-+ // {
-+ // Py_DECREF (result);
-+ // }
-+ // Py_DECREF (hookfn);
-+ // }
-+ }
-+
-+ /* Just ignore errors here. */
-+ PyErr_Clear ();
-+
-+ do_cleanups (cleanup);
-+}
-+
-+/* Callback that is used when a breakpoint is deleted. This will
-+ invalidate the corresponding Python object. */
-+static void
-+gdbpy_breakpoint_deleted (int num)
-+{
-+ struct cleanup *cleanup;
-+
-+ cleanup = ensure_python_env (get_current_arch (), current_language);
-+ if (BPPY_VALID_P (num))
-+ {
-+ bppy_breakpoints[num]->bp = NULL;
-+ Py_DECREF (bppy_breakpoints[num]);
-+ bppy_breakpoints[num] = NULL;
-+ --bppy_live;
-+ }
-+ do_cleanups (cleanup);
-+}
-+
-+
-+
-+/* Initialize the Python breakpoint code. */
-+void
-+gdbpy_initialize_breakpoints (void)
-+{
-+ breakpoint_object_type.tp_new = bppy_new;
-+ 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);
-+}
-+
-+
-+
-+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 not thread-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},
-+// { "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."},
-+ { NULL } /* Sentinel. */
-+};
-+
-+static PyMethodDef breakpoint_object_methods[] =
-+{
-+ { "is_valid", bppy_is_valid, METH_NOARGS,
-+ "Return true if this breakpoint is valid, false if not." },
-+ { 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*/
-+ 0, /*tp_setattro*/
-+ 0, /*tp_as_buffer*/
-+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
-+ "GDB breakpoint object", /* tp_doc */
-+ 0, /* tp_traverse */
-+ 0, /* tp_clear */
-+ 0, /* tp_richcompare */
-+ 0, /* tp_weaklistoffset */
-+ 0, /* tp_iter */
-+ 0, /* tp_iternext */
-+ breakpoint_object_methods, /* tp_methods */
-+ 0, /* tp_members */
-+ breakpoint_object_getset /* tp_getset */
-+};
-diff --git a/python/python-internal.h b/python/python-internal.h
-index fbf8247..fa4a62b 100644
---- a/python/python-internal.h
-+++ b/python/python-internal.h
-@@ -69,6 +69,7 @@ extern PyTypeObject value_object_type;
-
- PyObject *gdbpy_history (PyObject *self, PyObject *args);
- PyObject *gdbpy_eval (PyObject *self, PyObject *args);
-+PyObject *gdbpy_breakpoints (PyObject *, PyObject *);
- PyObject *gdbpy_frame_stop_reason_string (PyObject *, PyObject *);
- PyObject *gdbpy_selected_frame (PyObject *self, PyObject *args);
- PyObject *gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw);
-@@ -84,6 +85,7 @@ struct value *convert_value_from_python (PyObject *obj);
- struct type *type_object_to_type (PyObject *obj);
-
- void gdbpy_initialize_values (void);
-+void gdbpy_initialize_breakpoints (void);
- void gdbpy_initialize_frames (void);
- void gdbpy_initialize_commands (void);
- void gdbpy_initialize_types (void);
-diff --git a/python/python.c b/python/python.c
-index c96fa29..006ce29 100644
---- a/python/python.c
-+++ b/python/python.c
-@@ -594,6 +594,7 @@ Enables or disables auto-loading of Python code when an object is opened."),
- PyModule_AddStringConstant (gdb_module, "TARGET_CONFIG", (char*) target_name);
-
- gdbpy_initialize_values ();
-+ gdbpy_initialize_breakpoints ();
- gdbpy_initialize_frames ();
- gdbpy_initialize_commands ();
- gdbpy_initialize_functions ();
-@@ -658,6 +659,9 @@ static PyMethodDef GdbMethods[] =
- { "parameter", gdbpy_parameter, METH_VARARGS,
- "Return a gdb parameter's value" },
-
-+ { "breakpoints", gdbpy_breakpoints, METH_NOARGS,
-+ "Return a tuple of all breakpoint objects" },
-+
- { "default_visualizer", gdbpy_default_visualizer, METH_VARARGS,
- "Find the default visualizer for a Value." },
-
View
57 patches/gdb-eval.patch
@@ -1,57 +0,0 @@
-diff --git a/python/py-value.c b/python/py-value.c
-index 0146593..8f8c610 100644
---- a/python/py-value.c
-+++ b/python/py-value.c
-@@ -972,6 +972,27 @@ gdbpy_history (PyObject *self, PyObject *args)
- return value_to_value_object (res_val);
- }
-
-+/* Returns value object for a given expression. */
-+PyObject *
-+gdbpy_eval (PyObject *self, PyObject *args)
-+{
-+ char *arg;
-+ struct value *res_val = NULL; /* Initialize to appease gcc warning. */
-+ volatile struct gdb_exception except;
-+
-+ if (! PyArg_ParseTuple (args, "s", &arg))
-+ return NULL;
-+
-+ TRY_CATCH (except, RETURN_MASK_ALL)
-+ {
-+ res_val = parse_and_eval (arg);
-+ }
-+ GDB_PY_HANDLE_EXCEPTION (except);
-+
-+ return value_to_value_object (res_val);
-+}
-+
-+
- void
- gdbpy_initialize_values (void)
- {
-diff --git a/python/python-internal.h b/python/python-internal.h
-index 67a78af..fbf8247 100644
---- a/python/python-internal.h
-+++ b/python/python-internal.h
-@@ -68,6 +68,7 @@ extern PyObject *gdb_module;
- extern PyTypeObject value_object_type;
-
- PyObject *gdbpy_history (PyObject *self, PyObject *args);
-+PyObject *gdbpy_eval (PyObject *self, PyObject *args);
- PyObject *gdbpy_frame_stop_reason_string (PyObject *, PyObject *);
- PyObject *gdbpy_selected_frame (PyObject *self, PyObject *args);
- PyObject *gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw);
-diff --git a/python/python.c b/python/python.c
-index 254bd28..c96fa29 100644
---- a/python/python.c
-+++ b/python/python.c
-@@ -651,6 +651,8 @@ static PyMethodDef GdbMethods[] =
- {
- { "history", gdbpy_history, METH_VARARGS,
- "Get a value from history" },
-+ { "eval", gdbpy_eval, METH_VARARGS,
-+ "Get a value of an expression" },
- { "execute", execute_gdb_command, METH_VARARGS,
- "Execute a gdb command" },
- { "parameter", gdbpy_parameter, METH_VARARGS,
View
102 patches/gdb-leak.patch
@@ -1,8 +1,8 @@
diff --git a/python/py-value.c b/python/py-value.c
-index 8f8c610..c3a6cbf 100644
+index 4445655..f3c6309 100644
--- a/python/py-value.c
+++ b/python/py-value.c
-@@ -139,7 +139,7 @@ valpy_new (PyTypeObject *subtype, PyObject *args, PyObject *keywords)
+@@ -150,7 +150,7 @@ valpy_new (PyTypeObject *subtype, PyObject *args, PyObject *keywords)
}
value_obj->value = value;
@@ -10,16 +10,8 @@ index 8f8c610..c3a6cbf 100644
+ release_value_or_incref (value);
value_obj->address = NULL;
value_obj->type = NULL;
- note_value (value_obj);
-@@ -263,6 +263,7 @@ valpy_cast (PyObject *self, PyObject *args)
- {
- PyObject *type_obj;
- struct type *type;
-+ PyObject *res_obj = NULL;
- struct value *res_val = NULL; /* Initialize to appease gcc warning. */
- volatile struct gdb_exception except;
-
-@@ -301,8 +302,10 @@ valpy_getitem (PyObject *self, PyObject *key)
+ value_obj->dynamic_type = NULL;
+@@ -445,8 +445,10 @@ valpy_getitem (PyObject *self, PyObject *key)
{
value_object *self_value = (value_object *) self;
char *field = NULL;
@@ -30,23 +22,24 @@ index 8f8c610..c3a6cbf 100644
if (gdbpy_is_string (key))
{
-@@ -340,9 +343,13 @@ valpy_getitem (PyObject *self, PyObject *key)
+@@ -486,9 +488,15 @@ valpy_getitem (PyObject *self, PyObject *key)
}
xfree (field);
-- GDB_PY_HANDLE_EXCEPTION (except);
-+ GDB_PY_HANDLE_EXCEPTION_AND_CLEANUP (except, mark);
-+
-+ if (res_val)
-+ res_obj = value_to_value_object (res_val);
++ if (except.reason < 0)
++ value_free_to_mark (mark);
+ GDB_PY_HANDLE_EXCEPTION (except);
- return res_val ? value_to_value_object (res_val) : NULL;
++ if (res_val)
++ res_obj = value_to_value_object (res_val);
++
+ value_free_to_mark (mark);
+ return res_obj;
}
static int
-@@ -423,8 +430,10 @@ enum valpy_opcode
+@@ -625,8 +633,10 @@ enum valpy_opcode
static PyObject *
valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other)
{
@@ -57,23 +50,25 @@ index 8f8c610..c3a6cbf 100644
TRY_CATCH (except, RETURN_MASK_ALL)
{
-@@ -515,9 +524,13 @@ valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other)
+@@ -717,9 +727,16 @@ valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other)
break;
}
}
-- GDB_PY_HANDLE_EXCEPTION (except);
-+ GDB_PY_HANDLE_EXCEPTION_AND_CLEANUP (except, mark);
+
-+ if (res_val)
-+ res_obj = value_to_value_object (res_val);
++ if (except.reason < 0)
++ value_free_to_mark (mark);
+ GDB_PY_HANDLE_EXCEPTION (except);
- return res_val ? value_to_value_object (res_val) : NULL;
++ if (res_val)
++ res_obj = value_to_value_object (res_val);
++
+ value_free_to_mark (mark);
+ return res_obj;
}
static PyObject *
-@@ -680,6 +693,7 @@ valpy_richcompare (PyObject *self, PyObject *other, int op)
+@@ -881,6 +898,7 @@ valpy_richcompare (PyObject *self, PyObject *other, int op)
int result = 0;
struct value *value_other;
volatile struct gdb_exception except;
@@ -81,7 +76,7 @@ index 8f8c610..c3a6cbf 100644
if (other == Py_None)
/* Comparing with None is special. From what I can tell, in Python
-@@ -738,6 +752,7 @@ valpy_richcompare (PyObject *self, PyObject *other, int op)
+@@ -939,6 +957,7 @@ valpy_richcompare (PyObject *self, PyObject *other, int op)
break;
}
}
@@ -89,7 +84,7 @@ index 8f8c610..c3a6cbf 100644
GDB_PY_HANDLE_EXCEPTION (except);
/* In this case, the Python exception has already been set. */
-@@ -858,7 +873,7 @@ value_to_value_object (struct value *val)
+@@ -1062,7 +1081,7 @@ value_to_value_object (struct value *val)
if (val_obj != NULL)
{
val_obj->value = val;
@@ -97,37 +92,18 @@ index 8f8c610..c3a6cbf 100644
+ release_value_or_incref (val);
val_obj->address = NULL;
val_obj->type = NULL;
- note_value (val_obj);
-diff --git a/python/python-internal.h b/python/python-internal.h
-index fa4a62b..bc9c8c0 100644
---- a/python/python-internal.h
-+++ b/python/python-internal.h
-@@ -103,11 +103,17 @@ extern const struct language_defn *python_language;
- /* Use this after a TRY_EXCEPT to throw the appropriate Python
- exception. */
- #define GDB_PY_HANDLE_EXCEPTION(Exception) \
-+ GDB_PY_HANDLE_EXCEPTION_AND_CLEANUP(Exception, NULL)
-+
-+#define GDB_PY_HANDLE_EXCEPTION_AND_CLEANUP(Exception, mark) \
- do { \
-- if (Exception.reason < 0) \
-+ if (Exception.reason < 0) { \
-+ if (mark) \
-+ value_free_to_mark (mark); \
- return PyErr_Format (Exception.reason == RETURN_QUIT \
- ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, \
- "%s", Exception.message); \
-+ } \
- } while (0)
-
-
+ val_obj->dynamic_type = NULL;
diff --git a/value.c b/value.c
-index 589e03b..59a0196 100644
+index 381318b..805dcf0 100644
--- a/value.c
+++ b/value.c
-@@ -675,7 +675,7 @@ free_all_values (void)
+@@ -737,9 +737,10 @@ free_value_chain (struct value *v)
+ }
+
/* Remove VAL from the chain all_values
- so it will not be freed automatically. */
+- so it will not be freed automatically. */
++ so it will not be freed automatically.
++ Result of 0 indicates the value was found and released. */
-void
+int
@@ -139,7 +115,7 @@ index 589e03b..59a0196 100644
{
all_values = val->next;
- return;
-+ return 1;
++ return 0;
}
for (v = all_values; v; v = v->next)
@@ -148,11 +124,11 @@ index 589e03b..59a0196 100644
{
v->next = val->next;
- break;
-+ return 1;
++ return 0;
}
}
+
-+ return 0;
++ return -1;
+}
+
+/* Release VAL or increment its reference count if
@@ -161,18 +137,22 @@ index 589e03b..59a0196 100644
+void
+release_value_or_incref (struct value *val)
+{
-+ if (release_value (val) == 0)
++ if (release_value (val) != 0)
+ value_incref (val);
}
/* Release all values up to mark */
++
+ struct value *
+ value_release_to_mark (struct value *mark)
+ {
diff --git a/value.h b/value.h
-index 51e6960..4760c4a 100644
+index 543290a..e7e00d2 100644
--- a/value.h
+++ b/value.h
-@@ -594,7 +594,9 @@ extern void value_free (struct value *val);
+@@ -641,7 +641,9 @@ extern void free_all_values (void);
- extern void free_all_values (void);
+ extern void free_value_chain (struct value *v);
-extern void release_value (struct value *val);
+extern int release_value (struct value *val);
View
52 scripts/ruby-gdb.py
@@ -40,7 +40,7 @@ def invoke (self, arg, from_tty):
def trace (self):
self.type = 'list'
self.curr = None
- self.main = gdb.eval('rb_main_thread')
+ self.main = gdb.parse_and_eval('rb_main_thread')
self.unwind = gdb.parameter('unwindonsignal')
gdb.execute('set unwindonsignal on')
@@ -53,7 +53,7 @@ def trace (self):
prev = None
while True:
gdb.execute('continue')
- curr = gdb.eval('rb_curr_thread')
+ curr = gdb.parse_and_eval('rb_curr_thread')
if curr == prev: break
self.print_thread(curr)
prev = curr
@@ -64,12 +64,12 @@ def trace (self):
gdb.execute('set unwindonsignal %s' % (self.unwind and 'on' or 'off'))
def show (self):
- self.main = gdb.eval('rb_main_thread')
- self.curr = gdb.eval('rb_curr_thread')
+ self.main = gdb.parse_and_eval('rb_main_thread')
+ self.curr = gdb.parse_and_eval('rb_curr_thread')
self.now = time.time()
try:
- gdb.eval('rb_thread_start_2')
+ gdb.parse_and_eval('rb_thread_start_2')
except RuntimeError:
self.is_heap_stack = False
else:
@@ -100,8 +100,8 @@ def print_thread (self, th):
if self.type == 'list': return
if th == self.curr:
- frame = gdb.eval('ruby_frame')
- node = gdb.eval('ruby_current_node')
+ frame = gdb.parse_and_eval('ruby_frame')
+ node = gdb.parse_and_eval('ruby_current_node')
else:
frame = th['frame']
node = frame['node']
@@ -127,20 +127,20 @@ def print_stack (self, th, frame, node):
stk_pos = th['stk_pos']
stk_ptr = th['stk_ptr']
stk_len = th['stk_len']
- addr = gdb.eval('(VALUE*)%s' % frame)
+ addr = gdb.parse_and_eval('(VALUE*)%s' % frame)
if not self.is_heap_stack and th != self.curr and stk_pos < addr and addr < (stk_pos+stk_len):
frame = (addr-stk_pos) + stk_ptr
- frame = gdb.eval('(struct FRAME *)%s' % frame)
+ frame = gdb.parse_and_eval('(struct FRAME *)%s' % frame)
node = frame['node']
file = node['nd_file'].string()
- line = gdb.eval('nd_line(%s)' % node)
- type = gdb.eval('(enum node_type) nd_type(%s)' % node)
+ line = gdb.parse_and_eval('nd_line(%s)' % node)
+ type = gdb.parse_and_eval('(enum node_type) nd_type(%s)' % node)
if frame['last_func']:
try:
- method = gdb.eval('rb_id2name(%s)' % frame['last_func']).string()
+ method = gdb.parse_and_eval('rb_id2name(%s)' % frame['last_func']).string()
except:
method = '(unknown)'
else:
@@ -171,7 +171,7 @@ def setup (self):
gdb.execute(c)
gdb.breakpoints()[-1].silent = True
- self.func = gdb.eval('$func')
+ self.func = gdb.parse_and_eval('$func')
self.unwind = gdb.parameter('unwindonsignal')
gdb.execute('set unwindonsignal on')
@@ -205,10 +205,10 @@ def invoke (self, arg, from_tty):
if frame.pc() != self.func:
raise KeyboardInterrupt
- node = gdb.eval('(NODE*) $rsi')
+ node = gdb.parse_and_eval('(NODE*) $rsi')
file = node['nd_file'].string()
- line = gdb.eval('nd_line(%s)' % node)
- method = gdb.eval('rb_id2name($rcx)')
+ line = gdb.parse_and_eval('nd_line(%s)' % node)
+ method = gdb.parse_and_eval('rb_id2name($rcx)')
method = method > 0 and method.string() or '(unknown)'
print "%s in %s:%d" % (method,file,line)
@@ -263,7 +263,7 @@ def print_nodes (self):
nodes[ (int(obj['as']['node']['flags']) >> 12) & 0xff ] += 1
for (node, num) in sorted(nodes.items(), key=lambda(k,v):(v,k)):
- print "% 8d %s" % (num, gdb.eval('(enum node_type) (%d)' % node))
+ print "% 8d %s" % (num, gdb.parse_and_eval('(enum node_type) (%d)' % node))
def print_classes (self):
classes = ZeroDict()
@@ -287,7 +287,7 @@ def print_classes (self):
classes[ int(klass) ] += 1
for (klass, num) in sorted(classes.items(), key=lambda(k,v):(v,k)):
- print "% 8d %s" % (num, gdb.eval('rb_class2name(%d)' % klass).string())
+ print "% 8d %s" % (num, gdb.parse_and_eval('rb_class2name(%d)' % klass).string())
def print_strings (self):
strings = ZeroDict()
@@ -385,11 +385,11 @@ def print_stats (self):
print
def all_objects (self):
- self.heaps_used = gdb.eval('heaps_used')
+ self.heaps_used = gdb.parse_and_eval('heaps_used')
for i in xrange(self.heaps_used):
- p = gdb.eval("(RVALUE*) heaps[%i].slot" % i)
- pend = p + gdb.eval("heaps[%i].limit" % i)
+ p = gdb.parse_and_eval("(RVALUE*) heaps[%i].slot" % i)
+ pend = p + gdb.parse_and_eval("heaps[%i].limit" % i)
while p < pend:
yield p, p['as']['basic']['flags']
@@ -409,15 +409,15 @@ def __init__ (self):
def invoke (self, arg, from_tty):
self.dont_repeat()
- cache = gdb.eval('cache')
+ cache = gdb.parse_and_eval('cache')
size = 0x800
empty = 0
for i in xrange(size):
entry = cache[i]
if entry['mid'] != 0:
- klass = gdb.eval('rb_class2name(%d)' % entry['klass'])
- method = gdb.eval('rb_id2name(%d)' % entry['mid'])
+ klass = gdb.parse_and_eval('rb_class2name(%d)' % entry['klass'])
+ method = gdb.parse_and_eval('rb_id2name(%d)' % entry['mid'])
print " %s#%s" % (klass and klass.string() or '(unknown)', method and method.string() or '(unknown)')
else:
empty += 1
@@ -433,7 +433,7 @@ def __init__ (self):
def invoke (self, arg, from_tty):
self.dont_repeat()
- type = int(gdb.eval("((struct RBasic *)(%d))->flags & 0x3f" % int(arg,0)))
+ type = int(gdb.parse_and_eval("((struct RBasic *)(%d))->flags & 0x3f" % int(arg,0)))
rtype = RubyObjects.TYPES.get(type, 'unknown')
if rtype == 'array':
@@ -450,7 +450,7 @@ def __init__ (self):
def invoke (self, arg, from_tty):
self.dont_repeat()
arg = arg.replace('\\', '\\\\').replace('"', '\\\"')
- print gdb.eval("((struct RString*)rb_eval_string_protect(\"begin; (%s).inspect; rescue Exception => e; e.inspect; end\", 0))->ptr" % arg).string()
+ print gdb.parse_and_eval("((struct RString*)rb_eval_string_protect(\"begin; (%s).inspect; rescue Exception => e; e.inspect; end\", 0))->ptr" % arg).string()
Ruby()
RubyThreads()
Please sign in to comment.
Something went wrong with that request. Please try again.