aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-breakpoint.c12
-rw-r--r--gdb/python/py-finishbreakpoint.c14
-rw-r--r--gdb/python/python.c26
3 files changed, 31 insertions, 21 deletions
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 42a8596..30619dc 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -30,6 +30,7 @@
#include "ada-lang.h"
#include "arch-utils.h"
#include "language.h"
+#include "location.h"
/* Number of live breakpoints. */
static int bppy_live;
@@ -380,7 +381,7 @@ bppy_set_hit_count (PyObject *self, PyObject *newvalue, void *closure)
static PyObject *
bppy_get_location (PyObject *self, void *closure)
{
- char *str;
+ const char *str;
gdbpy_breakpoint_object *obj = (gdbpy_breakpoint_object *) self;
BPPY_REQUIRE_VALID (obj);
@@ -388,8 +389,7 @@ bppy_get_location (PyObject *self, void *closure)
if (obj->bp->type != bp_breakpoint)
Py_RETURN_NONE;
- str = obj->bp->addr_string;
-
+ str = event_location_to_string (obj->bp->location);
if (! str)
str = "";
return PyString_Decode (str, strlen (str), host_charset (), NULL);
@@ -670,8 +670,12 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
{
case bp_breakpoint:
{
+ struct event_location *location;
+
+ location = new_linespec_location (&copy);
+ make_cleanup_delete_event_location (location);
create_breakpoint (python_gdbarch,
- copy, NULL, -1, NULL,
+ location, NULL, -1, NULL,
0,
temporary_bp, bp_breakpoint,
0,
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index e3d4867..671fd23 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -29,6 +29,7 @@
#include "observer.h"
#include "inferior.h"
#include "block.h"
+#include "location.h"
/* Function that is called when a Python finish bp is found out of scope. */
static char * const outofscope_func = "out_of_scope";
@@ -169,7 +170,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
PyObject *internal = NULL;
int internal_bp = 0;
CORE_ADDR finish_pc, pc;
- char *addr_str, small_buf[100];
+ char small_buf[100], *p;
struct symbol *function;
if (!PyArg_ParseTupleAndKeywords (args, kwargs, "|OO", keywords,
@@ -296,13 +297,17 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
TRY
{
+ struct event_location *location;
+ struct cleanup *back_to;
+
/* Set a breakpoint on the return address. */
finish_pc = get_frame_pc (prev_frame);
xsnprintf (small_buf, sizeof (small_buf), "*%s", hex_string (finish_pc));
- addr_str = small_buf;
-
+ p = small_buf;
+ location = new_linespec_location (&p);
+ back_to = make_cleanup_delete_event_location (location);
create_breakpoint (python_gdbarch,
- addr_str, NULL, thread, NULL,
+ location, NULL, thread, NULL,
0,
1 /*temp_flag*/,
bp_breakpoint,
@@ -310,6 +315,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
AUTO_BOOLEAN_TRUE,
&bkpt_breakpoint_ops,
0, 1, internal_bp, 0);
+ do_cleanups (back_to);
}
CATCH (except, RETURN_MASK_ALL)
{
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 4f88b0e..c28f98b 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -34,6 +34,7 @@
#include "extension-priv.h"
#include "cli/cli-utils.h"
#include <ctype.h>
+#include "location.h"
/* Declared constants and enum for python stack printing. */
static const char python_excp_none[] = "none";
@@ -724,12 +725,12 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
struct symtabs_and_lines sals = { NULL, 0 }; /* Initialize to
appease gcc. */
struct symtab_and_line sal;
- const char *arg = NULL;
- char *copy_to_free = NULL, *copy = NULL;
+ char *arg = NULL;
struct cleanup *cleanups;
PyObject *result = NULL;
PyObject *return_result = NULL;
PyObject *unparsed = NULL;
+ struct event_location *location;
if (! PyArg_ParseTuple (args, "|s", &arg))
return NULL;
@@ -738,14 +739,16 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
sals.sals = NULL;
+ if (arg != NULL)
+ {
+ location = new_linespec_location (&arg);
+ make_cleanup_delete_event_location (location);
+ }
+
TRY
{
if (arg)
- {
- copy = xstrdup (arg);
- copy_to_free = copy;
- sals = decode_line_1 (&copy, 0, 0, 0);
- }
+ sals = decode_line_1 (location, 0, 0, 0);
else
{
set_default_source_symtab_and_line ();
@@ -761,10 +764,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
END_CATCH
if (sals.sals != NULL && sals.sals != &sal)
- {
- make_cleanup (xfree, copy_to_free);
- make_cleanup (xfree, sals.sals);
- }
+ make_cleanup (xfree, sals.sals);
if (except.reason < 0)
{
@@ -808,9 +808,9 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
goto error;
}
- if (copy && strlen (copy) > 0)
+ if (arg != NULL && strlen (arg) > 0)
{
- unparsed = PyString_FromString (copy);
+ unparsed = PyString_FromString (arg);
if (unparsed == NULL)
{
Py_DECREF (result);