2011-12-23 17:06:16 +00:00
|
|
|
/* Python interface to finish breakpoints
|
|
|
|
|
2015-01-01 09:32:14 +00:00
|
|
|
Copyright (C) 2011-2015 Free Software Foundation, Inc.
|
2011-12-23 17:06:16 +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 "python-internal.h"
|
|
|
|
#include "breakpoint.h"
|
|
|
|
#include "frame.h"
|
|
|
|
#include "gdbthread.h"
|
|
|
|
#include "arch-utils.h"
|
|
|
|
#include "language.h"
|
|
|
|
#include "observer.h"
|
|
|
|
#include "inferior.h"
|
2012-05-16 14:35:09 +00:00
|
|
|
#include "block.h"
|
2011-12-23 17:06:16 +00:00
|
|
|
|
|
|
|
/* Function that is called when a Python finish bp is found out of scope. */
|
|
|
|
static char * const outofscope_func = "out_of_scope";
|
|
|
|
|
|
|
|
/* struct implementing the gdb.FinishBreakpoint object by extending
|
|
|
|
the gdb.Breakpoint class. */
|
|
|
|
struct finish_breakpoint_object
|
|
|
|
{
|
|
|
|
/* gdb.Breakpoint base class. */
|
2013-11-28 22:54:32 +00:00
|
|
|
gdbpy_breakpoint_object py_bp;
|
2011-12-23 17:06:16 +00:00
|
|
|
/* gdb.Type object of the value return by the breakpointed function.
|
|
|
|
May be NULL if no debug information was available or return type
|
|
|
|
was VOID. */
|
|
|
|
PyObject *return_type;
|
2012-05-16 14:35:09 +00:00
|
|
|
/* gdb.Value object of the function finished by this breakpoint. Will be
|
2011-12-23 17:06:16 +00:00
|
|
|
NULL if return_type is NULL. */
|
2012-05-16 14:35:09 +00:00
|
|
|
PyObject *function_value;
|
2011-12-23 17:06:16 +00:00
|
|
|
/* When stopped at this FinishBreakpoint, gdb.Value object returned by
|
|
|
|
the function; Py_None if the value is not computable; NULL if GDB is
|
|
|
|
not stopped at a FinishBreakpoint. */
|
|
|
|
PyObject *return_value;
|
|
|
|
};
|
|
|
|
|
Fix redefinition errors in C++ mode
In C, we can forward declare static structure instances. That doesn't
work in C++ though. C++ treats these as definitions. So then the
compiler complains about symbol redefinition, like:
src/gdb/elfread.c:1569:29: error: redefinition of ‘const sym_fns elf_sym_fns_lazy_psyms’
src/gdb/elfread.c:53:29: error: ‘const sym_fns elf_sym_fns_lazy_psyms’ previously declared here
The intent of static here is naturally to avoid making these objects
visible outside the compilation unit. The equivalent in C++ would be
to instead define the objects in the anonymous namespace. But given
that it's desirable to leave the codebase compiling as both C and C++
for a while, this just makes the objects extern.
(base_breakpoint_ops is already declared in breakpoint.h, so we can
just remove the forward declare from breakpoint.c)
gdb/ChangeLog:
2015-02-11 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* breakpoint.c (base_breakpoint_ops): Delete.
* dwarf2loc.c (dwarf_expr_ctx_funcs): Make extern.
* elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_lazy_psyms): Make extern.
* guile/guile.c (guile_extension_script_ops, guile_extension_ops): Make extern.
* ppcnbsd-tdep.c (ppcnbsd2_sigtramp): Make extern.
* python/py-arch.c (arch_object_type): Make extern.
* python/py-block.c (block_syms_iterator_object_type): Make extern.
* python/py-bpevent.c (breakpoint_event_object_type): Make extern.
* python/py-cmd.c (cmdpy_object_type): Make extern.
* python/py-continueevent.c (continue_event_object_type)
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Remove 'qual'
parameter. Update all callers.
* python/py-evtregistry.c (eventregistry_object_type): Make extern.
* python/py-exitedevent.c (exited_event_object_type): Make extern.
* python/py-finishbreakpoint.c (finish_breakpoint_object_type): Make extern.
* python/py-function.c (fnpy_object_type): Make extern.
* python/py-inferior.c (inferior_object_type, membuf_object_type): Make extern.
* python/py-infevents.c (call_pre_event_object_type)
(inferior_call_post_event_object_type).
(memory_changed_event_object_type): Make extern.
* python/py-infthread.c (thread_object_type): Make extern.
* python/py-lazy-string.c (lazy_string_object_type): Make extern.
* python/py-linetable.c (linetable_entry_object_type)
(linetable_object_type, ltpy_iterator_object_type): Make extern.
* python/py-newobjfileevent.c (new_objfile_event_object_type)
(clear_objfiles_event_object_type): Make extern.
* python/py-objfile.c (objfile_object_type): Make extern.
* python/py-param.c (parmpy_object_type): Make extern.
* python/py-progspace.c (pspace_object_type): Make extern.
* python/py-signalevent.c (signal_event_object_type): Make extern.
* python/py-symtab.c (symtab_object_type, sal_object_type): Make extern.
* python/py-type.c (type_object_type, field_object_type)
(type_iterator_object_type): Make extern.
* python/python.c (python_extension_script_ops)
(python_extension_ops): Make extern.
* stap-probe.c (stap_probe_ops): Make extern.
2015-02-11 11:20:21 +00:00
|
|
|
extern PyTypeObject finish_breakpoint_object_type
|
2013-05-20 20:09:01 +00:00
|
|
|
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("finish_breakpoint_object");
|
|
|
|
|
2011-12-23 17:06:16 +00:00
|
|
|
/* Python function to get the 'return_value' attribute of
|
|
|
|
FinishBreakpoint. */
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
bpfinishpy_get_returnvalue (PyObject *self, void *closure)
|
|
|
|
{
|
|
|
|
struct finish_breakpoint_object *self_finishbp =
|
|
|
|
(struct finish_breakpoint_object *) self;
|
|
|
|
|
|
|
|
if (!self_finishbp->return_value)
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
|
|
|
Py_INCREF (self_finishbp->return_value);
|
|
|
|
return self_finishbp->return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Deallocate FinishBreakpoint object. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
bpfinishpy_dealloc (PyObject *self)
|
|
|
|
{
|
|
|
|
struct finish_breakpoint_object *self_bpfinish =
|
|
|
|
(struct finish_breakpoint_object *) self;
|
|
|
|
|
2012-05-16 14:35:09 +00:00
|
|
|
Py_XDECREF (self_bpfinish->function_value);
|
2011-12-23 17:06:16 +00:00
|
|
|
Py_XDECREF (self_bpfinish->return_type);
|
|
|
|
Py_XDECREF (self_bpfinish->return_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Triggered when gdbpy_should_stop is about to execute the `stop' callback
|
|
|
|
of the gdb.FinishBreakpoint object BP_OBJ. Will compute and cache the
|
|
|
|
`return_value', if possible. */
|
|
|
|
|
|
|
|
void
|
2013-11-28 22:54:32 +00:00
|
|
|
bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj)
|
2011-12-23 17:06:16 +00:00
|
|
|
{
|
|
|
|
struct finish_breakpoint_object *self_finishbp =
|
|
|
|
(struct finish_breakpoint_object *) bp_obj;
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
|
|
|
/* Can compute return_value only once. */
|
|
|
|
gdb_assert (!self_finishbp->return_value);
|
|
|
|
|
|
|
|
if (!self_finishbp->return_type)
|
|
|
|
return;
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
{
|
2012-05-16 14:35:09 +00:00
|
|
|
struct value *function =
|
|
|
|
value_object_to_value (self_finishbp->function_value);
|
|
|
|
struct type *value_type =
|
|
|
|
type_object_to_type (self_finishbp->return_type);
|
|
|
|
struct value *ret = get_return_value (function, value_type);
|
2011-12-23 17:06:16 +00:00
|
|
|
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
self_finishbp->return_value = value_to_value_object (ret);
|
|
|
|
if (!self_finishbp->return_value)
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Py_INCREF (Py_None);
|
|
|
|
self_finishbp->return_value = Py_None;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (except.reason < 0)
|
|
|
|
{
|
|
|
|
gdbpy_convert_exception (except);
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Triggered when gdbpy_should_stop has triggered the `stop' callback
|
|
|
|
of the gdb.FinishBreakpoint object BP_OBJ. */
|
|
|
|
|
|
|
|
void
|
2013-11-28 22:54:32 +00:00
|
|
|
bpfinishpy_post_stop_hook (struct gdbpy_breakpoint_object *bp_obj)
|
2011-12-23 17:06:16 +00:00
|
|
|
{
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
{
|
|
|
|
/* Can't delete it here, but it will be removed at the next stop. */
|
|
|
|
disable_breakpoint (bp_obj->bp);
|
|
|
|
gdb_assert (bp_obj->bp->disposition == disp_del);
|
|
|
|
}
|
|
|
|
if (except.reason < 0)
|
|
|
|
{
|
|
|
|
gdbpy_convert_exception (except);
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Python function to create a new breakpoint. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
static char *keywords[] = { "frame", "internal", NULL };
|
|
|
|
struct finish_breakpoint_object *self_bpfinish =
|
|
|
|
(struct finish_breakpoint_object *) self;
|
|
|
|
int type = bp_breakpoint;
|
|
|
|
PyObject *frame_obj = NULL;
|
|
|
|
int thread;
|
2013-02-28 20:01:10 +00:00
|
|
|
struct frame_info *frame = NULL; /* init for gcc -Wall */
|
|
|
|
struct frame_info *prev_frame = NULL;
|
2011-12-23 17:06:16 +00:00
|
|
|
struct frame_id frame_id;
|
|
|
|
PyObject *internal = NULL;
|
|
|
|
int internal_bp = 0;
|
|
|
|
CORE_ADDR finish_pc, pc;
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
char *addr_str, small_buf[100];
|
|
|
|
struct symbol *function;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords (args, kwargs, "|OO", keywords,
|
|
|
|
&frame_obj, &internal))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
{
|
2013-02-28 19:21:44 +00:00
|
|
|
/* Default frame to newest frame if necessary. */
|
|
|
|
if (frame_obj == NULL)
|
|
|
|
frame = get_current_frame ();
|
2011-12-23 17:06:16 +00:00
|
|
|
else
|
2013-02-28 19:21:44 +00:00
|
|
|
frame = frame_object_to_frame_info (frame_obj);
|
|
|
|
|
|
|
|
if (frame == NULL)
|
|
|
|
{
|
2013-11-29 20:00:47 +00:00
|
|
|
PyErr_SetString (PyExc_ValueError,
|
2013-02-28 19:21:44 +00:00
|
|
|
_("Invalid ID for the `frame' object."));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
prev_frame = get_prev_frame (frame);
|
|
|
|
if (prev_frame == 0)
|
|
|
|
{
|
|
|
|
PyErr_SetString (PyExc_ValueError,
|
|
|
|
_("\"FinishBreakpoint\" not "
|
|
|
|
"meaningful in the outermost "
|
|
|
|
"frame."));
|
|
|
|
}
|
|
|
|
else if (get_frame_type (prev_frame) == DUMMY_FRAME)
|
|
|
|
{
|
|
|
|
PyErr_SetString (PyExc_ValueError,
|
|
|
|
_("\"FinishBreakpoint\" cannot "
|
|
|
|
"be set on a dummy frame."));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
frame_id = get_frame_id (prev_frame);
|
|
|
|
if (frame_id_eq (frame_id, null_frame_id))
|
|
|
|
PyErr_SetString (PyExc_ValueError,
|
|
|
|
_("Invalid ID for the `frame' object."));
|
|
|
|
}
|
|
|
|
}
|
2011-12-23 17:06:16 +00:00
|
|
|
}
|
|
|
|
if (except.reason < 0)
|
|
|
|
{
|
|
|
|
gdbpy_convert_exception (except);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else if (PyErr_Occurred ())
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
thread = pid_to_thread_id (inferior_ptid);
|
|
|
|
if (thread == 0)
|
|
|
|
{
|
|
|
|
PyErr_SetString (PyExc_ValueError,
|
|
|
|
_("No thread currently selected."));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (internal)
|
|
|
|
{
|
|
|
|
internal_bp = PyObject_IsTrue (internal);
|
2013-11-29 20:00:47 +00:00
|
|
|
if (internal_bp == -1)
|
2011-12-23 17:06:16 +00:00
|
|
|
{
|
2013-11-29 20:00:47 +00:00
|
|
|
PyErr_SetString (PyExc_ValueError,
|
2011-12-23 17:06:16 +00:00
|
|
|
_("The value of `internal' must be a boolean."));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find the function we will return from. */
|
|
|
|
self_bpfinish->return_type = NULL;
|
2012-05-16 14:35:09 +00:00
|
|
|
self_bpfinish->function_value = NULL;
|
2011-12-23 17:06:16 +00:00
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
{
|
|
|
|
if (get_frame_pc_if_available (frame, &pc))
|
|
|
|
{
|
|
|
|
function = find_pc_function (pc);
|
|
|
|
if (function != NULL)
|
|
|
|
{
|
|
|
|
struct type *ret_type =
|
|
|
|
TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
|
|
|
|
|
|
|
|
/* Remember only non-void return types. */
|
|
|
|
if (TYPE_CODE (ret_type) != TYPE_CODE_VOID)
|
|
|
|
{
|
2012-05-16 14:35:09 +00:00
|
|
|
struct value *func_value;
|
|
|
|
|
2011-12-23 17:06:16 +00:00
|
|
|
/* Ignore Python errors at this stage. */
|
|
|
|
self_bpfinish->return_type = type_to_type_object (ret_type);
|
|
|
|
PyErr_Clear ();
|
2012-05-16 14:35:09 +00:00
|
|
|
func_value = read_var_value (function, frame);
|
|
|
|
self_bpfinish->function_value =
|
|
|
|
value_to_value_object (func_value);
|
2011-12-23 17:06:16 +00:00
|
|
|
PyErr_Clear ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (except.reason < 0
|
2012-05-16 14:35:09 +00:00
|
|
|
|| !self_bpfinish->return_type || !self_bpfinish->function_value)
|
2011-12-23 17:06:16 +00:00
|
|
|
{
|
|
|
|
/* Won't be able to compute return value. */
|
|
|
|
Py_XDECREF (self_bpfinish->return_type);
|
2012-05-16 14:35:09 +00:00
|
|
|
Py_XDECREF (self_bpfinish->function_value);
|
2011-12-23 17:06:16 +00:00
|
|
|
|
|
|
|
self_bpfinish->return_type = NULL;
|
2012-05-16 14:35:09 +00:00
|
|
|
self_bpfinish->function_value = NULL;
|
2011-12-23 17:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bppy_pending_object = &self_bpfinish->py_bp;
|
|
|
|
bppy_pending_object->number = -1;
|
|
|
|
bppy_pending_object->bp = NULL;
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
{
|
|
|
|
/* Set a breakpoint on the return address. */
|
|
|
|
finish_pc = get_frame_pc (prev_frame);
|
2011-12-27 04:12:10 +00:00
|
|
|
xsnprintf (small_buf, sizeof (small_buf), "*%s", hex_string (finish_pc));
|
2011-12-23 17:06:16 +00:00
|
|
|
addr_str = small_buf;
|
|
|
|
|
|
|
|
create_breakpoint (python_gdbarch,
|
2012-05-14 15:38:41 +00:00
|
|
|
addr_str, NULL, thread, NULL,
|
2011-12-23 17:06:16 +00:00
|
|
|
0,
|
|
|
|
1 /*temp_flag*/,
|
|
|
|
bp_breakpoint,
|
|
|
|
0,
|
|
|
|
AUTO_BOOLEAN_TRUE,
|
|
|
|
&bkpt_breakpoint_ops,
|
2012-03-13 13:30:42 +00:00
|
|
|
0, 1, internal_bp, 0);
|
2011-12-23 17:06:16 +00:00
|
|
|
}
|
|
|
|
GDB_PY_SET_HANDLE_EXCEPTION (except);
|
2013-11-29 20:00:47 +00:00
|
|
|
|
2011-12-23 17:06:16 +00:00
|
|
|
self_bpfinish->py_bp.bp->frame_id = frame_id;
|
|
|
|
self_bpfinish->py_bp.is_finish_bp = 1;
|
2013-11-29 20:00:47 +00:00
|
|
|
|
2011-12-23 17:06:16 +00:00
|
|
|
/* Bind the breakpoint with the current program space. */
|
|
|
|
self_bpfinish->py_bp.bp->pspace = current_program_space;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Called when GDB notices that the finish breakpoint BP_OBJ is out of
|
|
|
|
the current callstack. Triggers the method OUT_OF_SCOPE if implemented,
|
|
|
|
then delete the breakpoint. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
bpfinishpy_out_of_scope (struct finish_breakpoint_object *bpfinish_obj)
|
|
|
|
{
|
2013-11-28 22:54:32 +00:00
|
|
|
gdbpy_breakpoint_object *bp_obj = (gdbpy_breakpoint_object *) bpfinish_obj;
|
2011-12-23 17:06:16 +00:00
|
|
|
PyObject *py_obj = (PyObject *) bp_obj;
|
|
|
|
|
|
|
|
if (bpfinish_obj->py_bp.bp->enable_state == bp_enabled
|
|
|
|
&& PyObject_HasAttrString (py_obj, outofscope_func))
|
|
|
|
{
|
2013-05-20 20:27:44 +00:00
|
|
|
PyObject *meth_result;
|
|
|
|
|
|
|
|
meth_result = PyObject_CallMethod (py_obj, outofscope_func, NULL);
|
|
|
|
if (meth_result == NULL)
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
Py_XDECREF (meth_result);
|
2011-12-23 17:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
delete_breakpoint (bpfinish_obj->py_bp.bp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Callback for `bpfinishpy_detect_out_scope'. Triggers Python's
|
|
|
|
`B->out_of_scope' function if B is a FinishBreakpoint out of its scope. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
bpfinishpy_detect_out_scope_cb (struct breakpoint *b, void *args)
|
|
|
|
{
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
struct breakpoint *bp_stopped = (struct breakpoint *) args;
|
|
|
|
PyObject *py_bp = (PyObject *) b->py_bp_object;
|
|
|
|
struct gdbarch *garch = b->gdbarch ? b->gdbarch : get_current_arch ();
|
2013-11-29 20:00:47 +00:00
|
|
|
|
2011-12-23 17:06:16 +00:00
|
|
|
/* Trigger out_of_scope if this is a FinishBreakpoint and its frame is
|
|
|
|
not anymore in the current callstack. */
|
|
|
|
if (py_bp != NULL && b->py_bp_object->is_finish_bp)
|
|
|
|
{
|
|
|
|
struct finish_breakpoint_object *finish_bp =
|
|
|
|
(struct finish_breakpoint_object *) py_bp;
|
|
|
|
|
|
|
|
/* Check scope if not currently stopped at the FinishBreakpoint. */
|
|
|
|
if (b != bp_stopped)
|
|
|
|
{
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
{
|
|
|
|
if (b->pspace == current_inferior ()->pspace
|
|
|
|
&& (!target_has_registers
|
|
|
|
|| frame_find_by_id (b->frame_id) == NULL))
|
|
|
|
bpfinishpy_out_of_scope (finish_bp);
|
|
|
|
}
|
|
|
|
if (except.reason < 0)
|
|
|
|
{
|
|
|
|
gdbpy_convert_exception (except);
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Attached to `stop' notifications, check if the execution has run
|
|
|
|
out of the scope of any FinishBreakpoint before it has been hit. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
bpfinishpy_handle_stop (struct bpstats *bs, int print_frame)
|
|
|
|
{
|
|
|
|
struct cleanup *cleanup = ensure_python_env (get_current_arch (),
|
|
|
|
current_language);
|
|
|
|
|
|
|
|
iterate_over_breakpoints (bpfinishpy_detect_out_scope_cb,
|
|
|
|
bs == NULL ? NULL : bs->breakpoint_at);
|
|
|
|
|
|
|
|
do_cleanups (cleanup);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Attached to `exit' notifications, triggers all the necessary out of
|
|
|
|
scope notifications. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
bpfinishpy_handle_exit (struct inferior *inf)
|
|
|
|
{
|
* gdbarch.sh (target_gdbarch): Remove macro.
(get_target_gdbarch): Rename to target_gdbarch.
* gdbarch.c, gdbarch.h: Rebuild.
* ada-tasks.c, aix-thread.c, amd64-linux-nat.c, arch-utils.c,
arm-tdep.c, auxv.c, breakpoint.c, bsd-uthread.c, corefile.c,
darwin-nat-info.c, dcache.c, dsrec.c, exec.c, fbsd-nat.c,
filesystem.c, gcore.c, gnu-nat.c, i386-darwin-nat.c, i386-nat.c,
ia64-vms-tdep.c, inf-ptrace.c, infcmd.c, jit.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, m32r-rom.c, memattr.c,
mep-tdep.c, microblaze-tdep.c, mips-linux-nat.c,
mips-linux-tdep.c, mips-tdep.c, monitor.c, moxie-tdep.c,
nto-procfs.c, nto-tdep.c, ppc-linux-nat.c, proc-service.c,
procfs.c, progspace.c, ravenscar-thread.c, record.c,
remote-m32r-sdi.c, remote-mips.c, remote-sim.c, remote.c,
rl78-tdep.c, rs6000-nat.c, rx-tdep.c, s390-nat.c, sol-thread.c,
solib-darwin.c, solib-dsbt.c, solib-frv.c, solib-ia64-hpux.c,
solib-irix.c, solib-pa64.c, solib-som.c, solib-spu.c,
solib-sunos.c, solib-svr4.c, solib.c, spu-linux-nat.c,
spu-multiarch.c, spu-tdep.c, symfile-mem.c, symfile.c, symtab.c,
target-descriptions.c, target.c, target.h, tracepoint.c,
windows-nat.c, windows-tdep.c, xcoffsolib.c, cli/cli-dump.c,
common/agent.c, mi/mi-interp.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/python.c: Update.
2012-11-09 19:58:03 +00:00
|
|
|
struct cleanup *cleanup = ensure_python_env (target_gdbarch (),
|
2011-12-23 17:06:16 +00:00
|
|
|
current_language);
|
|
|
|
|
|
|
|
iterate_over_breakpoints (bpfinishpy_detect_out_scope_cb, NULL);
|
|
|
|
|
|
|
|
do_cleanups (cleanup);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the Python finish breakpoint code. */
|
|
|
|
|
* python/py-arch.c (gdbpy_initialize_arch): Return 'int'.
Check errors.
* python/py-auto-load.c (gdbpy_initialize_auto_load): Return 'int'.
* python/py-block.c (gdbpy_initialize_blocks): Return 'int'.
Check errors.
* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Return 'int'.
Check errors.
* python/py-cmd.c (gdbpy_initialize_commands): Return 'int'.
Check errors.
* python/py-event.c (gdbpy_initialize_event): Return 'int'.
Check errors.
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Change generated
init function to return 'int'.
* python/py-evtregistry.c (gdbpy_initialize_eventregistry):
Return 'int'. Check errors.
* python/py-evts.c (gdbpy_initialize_py_events): Return 'int'.
Check errors.
* python/py-finishbreakpoint.c (gdbpy_initialize_finishbreakpoints):
Return 'int'. Check errors.
* python/py-frame.c (gdbpy_initialize_frames): Return 'int'.
Check errors.
* python/py-function.c (gdbpy_initialize_functions): Return 'int'.
Check errors.
* python/py-gdb-readline.c (gdbpy_initialize_gdb_readline):
Check errors.
* python/py-inferior.c (gdbpy_initialize_inferior): Return 'int'.
Check errors.
* python/py-infthread.c (gdbpy_initialize_thread): Return 'int'.
Check errors.
* python/py-lazy-string.c (gdbpy_initialize_lazy_string): Return 'int'.
Check errors.
* python/py-objfile.c (gdbpy_initialize_objfile): Return 'int'.
Check errors.
* python/py-param.c (gdbpy_initialize_parameters): Return 'int'.
Check errors.
* python/py-progspace.c (gdbpy_initialize_pspace): Return 'int'.
Check errors.
* python/py-symbol.c (gdbpy_initialize_symbols): Return 'int'.
Check errors.
* python/py-symtab.c (gdbpy_initialize_symtabs): Return 'int'.
Check errors.
* python/py-type.c (gdbpy_initialize_types): Return 'int'.
Check errors.
* python/py-value.c (gdbpy_initialize_values): Return 'int'.
Check errors.
* python/python-internal.h (gdbpy_initialize_auto_load,
gdbpy_initialize_values, gdbpy_initialize_frames,
gdbpy_initialize_symtabs, gdbpy_initialize_commands,
gdbpy_initialize_symbols, gdbpy_initialize_symtabs,
gdbpy_initialize_blocks, gdbpy_initialize_types,
gdbpy_initialize_functions, gdbpy_initialize_pspace,
gdbpy_initialize_objfile, gdbpy_initialize_breakpoints,
gdbpy_initialize_finishbreakpoints,
gdbpy_initialize_lazy_string, gdbpy_initialize_parameters,
gdbpy_initialize_thread, gdbpy_initialize_inferior,
gdbpy_initialize_eventregistry, gdbpy_initialize_event,
gdbpy_initialize_py_events, gdbpy_initialize_stop_event,
gdbpy_initialize_signal_event,
gdbpy_initialize_breakpoint_event,
gdbpy_initialize_continue_event,
gdbpy_initialize_exited_event, gdbpy_initialize_thread_event,
gdbpy_initialize_new_objfile_event, gdbpy_initialize_arch):
Update. Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION.
* python/python.c (gdb_python_initialized): New global.
(gdbpy_initialize_events): Return 'int'. Check errors.
(_initialize_python): Check errors. Set
gdb_python_initialized.
2013-05-20 20:28:52 +00:00
|
|
|
int
|
2011-12-23 17:06:16 +00:00
|
|
|
gdbpy_initialize_finishbreakpoints (void)
|
|
|
|
{
|
|
|
|
if (PyType_Ready (&finish_breakpoint_object_type) < 0)
|
* python/py-arch.c (gdbpy_initialize_arch): Return 'int'.
Check errors.
* python/py-auto-load.c (gdbpy_initialize_auto_load): Return 'int'.
* python/py-block.c (gdbpy_initialize_blocks): Return 'int'.
Check errors.
* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Return 'int'.
Check errors.
* python/py-cmd.c (gdbpy_initialize_commands): Return 'int'.
Check errors.
* python/py-event.c (gdbpy_initialize_event): Return 'int'.
Check errors.
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Change generated
init function to return 'int'.
* python/py-evtregistry.c (gdbpy_initialize_eventregistry):
Return 'int'. Check errors.
* python/py-evts.c (gdbpy_initialize_py_events): Return 'int'.
Check errors.
* python/py-finishbreakpoint.c (gdbpy_initialize_finishbreakpoints):
Return 'int'. Check errors.
* python/py-frame.c (gdbpy_initialize_frames): Return 'int'.
Check errors.
* python/py-function.c (gdbpy_initialize_functions): Return 'int'.
Check errors.
* python/py-gdb-readline.c (gdbpy_initialize_gdb_readline):
Check errors.
* python/py-inferior.c (gdbpy_initialize_inferior): Return 'int'.
Check errors.
* python/py-infthread.c (gdbpy_initialize_thread): Return 'int'.
Check errors.
* python/py-lazy-string.c (gdbpy_initialize_lazy_string): Return 'int'.
Check errors.
* python/py-objfile.c (gdbpy_initialize_objfile): Return 'int'.
Check errors.
* python/py-param.c (gdbpy_initialize_parameters): Return 'int'.
Check errors.
* python/py-progspace.c (gdbpy_initialize_pspace): Return 'int'.
Check errors.
* python/py-symbol.c (gdbpy_initialize_symbols): Return 'int'.
Check errors.
* python/py-symtab.c (gdbpy_initialize_symtabs): Return 'int'.
Check errors.
* python/py-type.c (gdbpy_initialize_types): Return 'int'.
Check errors.
* python/py-value.c (gdbpy_initialize_values): Return 'int'.
Check errors.
* python/python-internal.h (gdbpy_initialize_auto_load,
gdbpy_initialize_values, gdbpy_initialize_frames,
gdbpy_initialize_symtabs, gdbpy_initialize_commands,
gdbpy_initialize_symbols, gdbpy_initialize_symtabs,
gdbpy_initialize_blocks, gdbpy_initialize_types,
gdbpy_initialize_functions, gdbpy_initialize_pspace,
gdbpy_initialize_objfile, gdbpy_initialize_breakpoints,
gdbpy_initialize_finishbreakpoints,
gdbpy_initialize_lazy_string, gdbpy_initialize_parameters,
gdbpy_initialize_thread, gdbpy_initialize_inferior,
gdbpy_initialize_eventregistry, gdbpy_initialize_event,
gdbpy_initialize_py_events, gdbpy_initialize_stop_event,
gdbpy_initialize_signal_event,
gdbpy_initialize_breakpoint_event,
gdbpy_initialize_continue_event,
gdbpy_initialize_exited_event, gdbpy_initialize_thread_event,
gdbpy_initialize_new_objfile_event, gdbpy_initialize_arch):
Update. Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION.
* python/python.c (gdb_python_initialized): New global.
(gdbpy_initialize_events): Return 'int'. Check errors.
(_initialize_python): Check errors. Set
gdb_python_initialized.
2013-05-20 20:28:52 +00:00
|
|
|
return -1;
|
2013-11-29 20:00:47 +00:00
|
|
|
|
2013-05-20 20:36:19 +00:00
|
|
|
if (gdb_pymodule_addobject (gdb_module, "FinishBreakpoint",
|
|
|
|
(PyObject *) &finish_breakpoint_object_type) < 0)
|
* python/py-arch.c (gdbpy_initialize_arch): Return 'int'.
Check errors.
* python/py-auto-load.c (gdbpy_initialize_auto_load): Return 'int'.
* python/py-block.c (gdbpy_initialize_blocks): Return 'int'.
Check errors.
* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Return 'int'.
Check errors.
* python/py-cmd.c (gdbpy_initialize_commands): Return 'int'.
Check errors.
* python/py-event.c (gdbpy_initialize_event): Return 'int'.
Check errors.
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Change generated
init function to return 'int'.
* python/py-evtregistry.c (gdbpy_initialize_eventregistry):
Return 'int'. Check errors.
* python/py-evts.c (gdbpy_initialize_py_events): Return 'int'.
Check errors.
* python/py-finishbreakpoint.c (gdbpy_initialize_finishbreakpoints):
Return 'int'. Check errors.
* python/py-frame.c (gdbpy_initialize_frames): Return 'int'.
Check errors.
* python/py-function.c (gdbpy_initialize_functions): Return 'int'.
Check errors.
* python/py-gdb-readline.c (gdbpy_initialize_gdb_readline):
Check errors.
* python/py-inferior.c (gdbpy_initialize_inferior): Return 'int'.
Check errors.
* python/py-infthread.c (gdbpy_initialize_thread): Return 'int'.
Check errors.
* python/py-lazy-string.c (gdbpy_initialize_lazy_string): Return 'int'.
Check errors.
* python/py-objfile.c (gdbpy_initialize_objfile): Return 'int'.
Check errors.
* python/py-param.c (gdbpy_initialize_parameters): Return 'int'.
Check errors.
* python/py-progspace.c (gdbpy_initialize_pspace): Return 'int'.
Check errors.
* python/py-symbol.c (gdbpy_initialize_symbols): Return 'int'.
Check errors.
* python/py-symtab.c (gdbpy_initialize_symtabs): Return 'int'.
Check errors.
* python/py-type.c (gdbpy_initialize_types): Return 'int'.
Check errors.
* python/py-value.c (gdbpy_initialize_values): Return 'int'.
Check errors.
* python/python-internal.h (gdbpy_initialize_auto_load,
gdbpy_initialize_values, gdbpy_initialize_frames,
gdbpy_initialize_symtabs, gdbpy_initialize_commands,
gdbpy_initialize_symbols, gdbpy_initialize_symtabs,
gdbpy_initialize_blocks, gdbpy_initialize_types,
gdbpy_initialize_functions, gdbpy_initialize_pspace,
gdbpy_initialize_objfile, gdbpy_initialize_breakpoints,
gdbpy_initialize_finishbreakpoints,
gdbpy_initialize_lazy_string, gdbpy_initialize_parameters,
gdbpy_initialize_thread, gdbpy_initialize_inferior,
gdbpy_initialize_eventregistry, gdbpy_initialize_event,
gdbpy_initialize_py_events, gdbpy_initialize_stop_event,
gdbpy_initialize_signal_event,
gdbpy_initialize_breakpoint_event,
gdbpy_initialize_continue_event,
gdbpy_initialize_exited_event, gdbpy_initialize_thread_event,
gdbpy_initialize_new_objfile_event, gdbpy_initialize_arch):
Update. Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION.
* python/python.c (gdb_python_initialized): New global.
(gdbpy_initialize_events): Return 'int'. Check errors.
(_initialize_python): Check errors. Set
gdb_python_initialized.
2013-05-20 20:28:52 +00:00
|
|
|
return -1;
|
2013-11-29 20:00:47 +00:00
|
|
|
|
2011-12-23 17:06:16 +00:00
|
|
|
observer_attach_normal_stop (bpfinishpy_handle_stop);
|
|
|
|
observer_attach_inferior_exit (bpfinishpy_handle_exit);
|
* python/py-arch.c (gdbpy_initialize_arch): Return 'int'.
Check errors.
* python/py-auto-load.c (gdbpy_initialize_auto_load): Return 'int'.
* python/py-block.c (gdbpy_initialize_blocks): Return 'int'.
Check errors.
* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Return 'int'.
Check errors.
* python/py-cmd.c (gdbpy_initialize_commands): Return 'int'.
Check errors.
* python/py-event.c (gdbpy_initialize_event): Return 'int'.
Check errors.
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Change generated
init function to return 'int'.
* python/py-evtregistry.c (gdbpy_initialize_eventregistry):
Return 'int'. Check errors.
* python/py-evts.c (gdbpy_initialize_py_events): Return 'int'.
Check errors.
* python/py-finishbreakpoint.c (gdbpy_initialize_finishbreakpoints):
Return 'int'. Check errors.
* python/py-frame.c (gdbpy_initialize_frames): Return 'int'.
Check errors.
* python/py-function.c (gdbpy_initialize_functions): Return 'int'.
Check errors.
* python/py-gdb-readline.c (gdbpy_initialize_gdb_readline):
Check errors.
* python/py-inferior.c (gdbpy_initialize_inferior): Return 'int'.
Check errors.
* python/py-infthread.c (gdbpy_initialize_thread): Return 'int'.
Check errors.
* python/py-lazy-string.c (gdbpy_initialize_lazy_string): Return 'int'.
Check errors.
* python/py-objfile.c (gdbpy_initialize_objfile): Return 'int'.
Check errors.
* python/py-param.c (gdbpy_initialize_parameters): Return 'int'.
Check errors.
* python/py-progspace.c (gdbpy_initialize_pspace): Return 'int'.
Check errors.
* python/py-symbol.c (gdbpy_initialize_symbols): Return 'int'.
Check errors.
* python/py-symtab.c (gdbpy_initialize_symtabs): Return 'int'.
Check errors.
* python/py-type.c (gdbpy_initialize_types): Return 'int'.
Check errors.
* python/py-value.c (gdbpy_initialize_values): Return 'int'.
Check errors.
* python/python-internal.h (gdbpy_initialize_auto_load,
gdbpy_initialize_values, gdbpy_initialize_frames,
gdbpy_initialize_symtabs, gdbpy_initialize_commands,
gdbpy_initialize_symbols, gdbpy_initialize_symtabs,
gdbpy_initialize_blocks, gdbpy_initialize_types,
gdbpy_initialize_functions, gdbpy_initialize_pspace,
gdbpy_initialize_objfile, gdbpy_initialize_breakpoints,
gdbpy_initialize_finishbreakpoints,
gdbpy_initialize_lazy_string, gdbpy_initialize_parameters,
gdbpy_initialize_thread, gdbpy_initialize_inferior,
gdbpy_initialize_eventregistry, gdbpy_initialize_event,
gdbpy_initialize_py_events, gdbpy_initialize_stop_event,
gdbpy_initialize_signal_event,
gdbpy_initialize_breakpoint_event,
gdbpy_initialize_continue_event,
gdbpy_initialize_exited_event, gdbpy_initialize_thread_event,
gdbpy_initialize_new_objfile_event, gdbpy_initialize_arch):
Update. Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION.
* python/python.c (gdb_python_initialized): New global.
(gdbpy_initialize_events): Return 'int'. Check errors.
(_initialize_python): Check errors. Set
gdb_python_initialized.
2013-05-20 20:28:52 +00:00
|
|
|
|
|
|
|
return 0;
|
2011-12-23 17:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyGetSetDef finish_breakpoint_object_getset[] = {
|
|
|
|
{ "return_value", bpfinishpy_get_returnvalue, NULL,
|
|
|
|
"gdb.Value object representing the return value, if any. \
|
|
|
|
None otherwise.", NULL },
|
|
|
|
{ NULL } /* Sentinel. */
|
|
|
|
};
|
|
|
|
|
Fix redefinition errors in C++ mode
In C, we can forward declare static structure instances. That doesn't
work in C++ though. C++ treats these as definitions. So then the
compiler complains about symbol redefinition, like:
src/gdb/elfread.c:1569:29: error: redefinition of ‘const sym_fns elf_sym_fns_lazy_psyms’
src/gdb/elfread.c:53:29: error: ‘const sym_fns elf_sym_fns_lazy_psyms’ previously declared here
The intent of static here is naturally to avoid making these objects
visible outside the compilation unit. The equivalent in C++ would be
to instead define the objects in the anonymous namespace. But given
that it's desirable to leave the codebase compiling as both C and C++
for a while, this just makes the objects extern.
(base_breakpoint_ops is already declared in breakpoint.h, so we can
just remove the forward declare from breakpoint.c)
gdb/ChangeLog:
2015-02-11 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* breakpoint.c (base_breakpoint_ops): Delete.
* dwarf2loc.c (dwarf_expr_ctx_funcs): Make extern.
* elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_lazy_psyms): Make extern.
* guile/guile.c (guile_extension_script_ops, guile_extension_ops): Make extern.
* ppcnbsd-tdep.c (ppcnbsd2_sigtramp): Make extern.
* python/py-arch.c (arch_object_type): Make extern.
* python/py-block.c (block_syms_iterator_object_type): Make extern.
* python/py-bpevent.c (breakpoint_event_object_type): Make extern.
* python/py-cmd.c (cmdpy_object_type): Make extern.
* python/py-continueevent.c (continue_event_object_type)
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Remove 'qual'
parameter. Update all callers.
* python/py-evtregistry.c (eventregistry_object_type): Make extern.
* python/py-exitedevent.c (exited_event_object_type): Make extern.
* python/py-finishbreakpoint.c (finish_breakpoint_object_type): Make extern.
* python/py-function.c (fnpy_object_type): Make extern.
* python/py-inferior.c (inferior_object_type, membuf_object_type): Make extern.
* python/py-infevents.c (call_pre_event_object_type)
(inferior_call_post_event_object_type).
(memory_changed_event_object_type): Make extern.
* python/py-infthread.c (thread_object_type): Make extern.
* python/py-lazy-string.c (lazy_string_object_type): Make extern.
* python/py-linetable.c (linetable_entry_object_type)
(linetable_object_type, ltpy_iterator_object_type): Make extern.
* python/py-newobjfileevent.c (new_objfile_event_object_type)
(clear_objfiles_event_object_type): Make extern.
* python/py-objfile.c (objfile_object_type): Make extern.
* python/py-param.c (parmpy_object_type): Make extern.
* python/py-progspace.c (pspace_object_type): Make extern.
* python/py-signalevent.c (signal_event_object_type): Make extern.
* python/py-symtab.c (symtab_object_type, sal_object_type): Make extern.
* python/py-type.c (type_object_type, field_object_type)
(type_iterator_object_type): Make extern.
* python/python.c (python_extension_script_ops)
(python_extension_ops): Make extern.
* stap-probe.c (stap_probe_ops): Make extern.
2015-02-11 11:20:21 +00:00
|
|
|
PyTypeObject finish_breakpoint_object_type =
|
2011-12-23 17:06:16 +00:00
|
|
|
{
|
2012-12-12 16:47:30 +00:00
|
|
|
PyVarObject_HEAD_INIT (NULL, 0)
|
2011-12-23 17:06:16 +00:00
|
|
|
"gdb.FinishBreakpoint", /*tp_name*/
|
|
|
|
sizeof (struct finish_breakpoint_object), /*tp_basicsize*/
|
|
|
|
0, /*tp_itemsize*/
|
|
|
|
bpfinishpy_dealloc, /*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 | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
|
|
|
"GDB finish breakpoint object", /* tp_doc */
|
|
|
|
0, /* tp_traverse */
|
|
|
|
0, /* tp_clear */
|
|
|
|
0, /* tp_richcompare */
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
0, /* tp_iter */
|
|
|
|
0, /* tp_iternext */
|
|
|
|
0, /* tp_methods */
|
|
|
|
0, /* tp_members */
|
|
|
|
finish_breakpoint_object_getset,/* tp_getset */
|
|
|
|
&breakpoint_object_type, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
|
|
|
0, /* tp_descr_get */
|
|
|
|
0, /* tp_descr_set */
|
|
|
|
0, /* tp_dictoffset */
|
|
|
|
bpfinishpy_init, /* tp_init */
|
|
|
|
0, /* tp_alloc */
|
|
|
|
0 /* tp_new */
|
|
|
|
};
|