mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-24 18:44:20 +08:00
python: Implement btrace Python bindings for record history.
This patch implements the gdb.Record Python object methods and fields for record target btrace. Also, implement a stub for record target full. Signed-off-by: Tim Wiederhake <tim.wiederhake@intel.com> gdb/ChangeLog: * Makefile.in (SUBDIR_PYTHON_OBS): Add py-record-btrace.o, py-record-full.o. (SUBDIR_PYTHON_SRCS): Add py-record-btrace.c, py-record-full.c. * python/py-record-btrace.c, python/py-record-btrace.h, python/py-record-full.c, python/py-record-full.h: New file. * python/py-record.c: Add include for py-record-btrace.h and py-record-full.h. (recpy_method, recpy_format, recpy_goto, recpy_replay_position, recpy_instruction_history, recpy_function_call_history, recpy_begin, recpy_end): Use functions from py-record-btrace.c and py-record-full.c. * python/python-internal.h (PyInt_FromSsize_t, PyInt_AsSsize_t): New definition. (gdbpy_initialize_btrace): New export. * python/python.c (_initialize_python): Add gdbpy_initialize_btrace. Change-Id: I8bd893672ffc7e619cc1386767897249e125973a
This commit is contained in:
parent
4726b2d82c
commit
75c0bdf484
@ -461,6 +461,8 @@ SUBDIR_PYTHON_OBS = \
|
||||
py-prettyprint.o \
|
||||
py-progspace.o \
|
||||
py-record.o \
|
||||
py-record-btrace.o \
|
||||
py-record-full.o \
|
||||
py-signalevent.o \
|
||||
py-stopevent.o \
|
||||
py-symbol.o \
|
||||
@ -502,6 +504,8 @@ SUBDIR_PYTHON_SRCS = \
|
||||
python/py-prettyprint.c \
|
||||
python/py-progspace.c \
|
||||
python/py-record.c \
|
||||
python/py-record-btrace.c \
|
||||
python/py-record-full.c \
|
||||
python/py-signalevent.c \
|
||||
python/py-stopevent.c \
|
||||
python/py-symbol.c \
|
||||
|
1001
gdb/python/py-record-btrace.c
Normal file
1001
gdb/python/py-record-btrace.c
Normal file
File diff suppressed because it is too large
Load Diff
49
gdb/python/py-record-btrace.h
Normal file
49
gdb/python/py-record-btrace.h
Normal file
@ -0,0 +1,49 @@
|
||||
/* Python interface to btrace record targets.
|
||||
|
||||
Copyright 2016-2017 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/>. */
|
||||
|
||||
#ifndef GDB_PY_RECORD_BTRACE_H
|
||||
#define GDB_PY_RECORD_BTRACE_H
|
||||
|
||||
#include "python-internal.h"
|
||||
|
||||
/* Implementation of record.method [str]. */
|
||||
extern PyObject *recpy_bt_method (PyObject *self, void *closure);
|
||||
|
||||
/* Implementation of record.format [str]. */
|
||||
extern PyObject *recpy_bt_format (PyObject *self, void *closure);
|
||||
|
||||
/* Implementation of record.goto (instruction) -> None. */
|
||||
extern PyObject *recpy_bt_goto (PyObject *self, PyObject *value);
|
||||
|
||||
/* Implementation of record.instruction_history [list]. */
|
||||
extern PyObject *recpy_bt_instruction_history (PyObject *self, void *closure);
|
||||
|
||||
/* Implementation of record.function_call_history [list]. */
|
||||
extern PyObject *recpy_bt_function_call_history (PyObject *self, void *closure);
|
||||
|
||||
/* Implementation of record.replay_position [instruction]. */
|
||||
extern PyObject *recpy_bt_replay_position (PyObject *self, void *closure);
|
||||
|
||||
/* Implementation of record.begin [instruction]. */
|
||||
extern PyObject *recpy_bt_begin (PyObject *self, void *closure);
|
||||
|
||||
/* Implementation of record.end [instruction]. */
|
||||
extern PyObject *recpy_bt_end (PyObject *self, void *closure);
|
||||
|
||||
#endif /* GDB_PY_RECORD_BTRACE_H */
|
39
gdb/python/py-record-full.c
Normal file
39
gdb/python/py-record-full.c
Normal file
@ -0,0 +1,39 @@
|
||||
/* Python interface to btrace instruction history.
|
||||
|
||||
Copyright 2016-2017 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 "py-record-full.h"
|
||||
|
||||
/* Implementation of
|
||||
BtraceRecord.method [str]. */
|
||||
|
||||
PyObject *
|
||||
recpy_full_method (PyObject *self, void *closure)
|
||||
{
|
||||
return PyString_FromString ("full");
|
||||
}
|
||||
|
||||
/* Implementation of
|
||||
BtraceRecord.format [str]. */
|
||||
|
||||
PyObject *
|
||||
recpy_full_format (PyObject *self, void *closure)
|
||||
{
|
||||
return PyString_FromString ("full");
|
||||
}
|
31
gdb/python/py-record-full.h
Normal file
31
gdb/python/py-record-full.h
Normal file
@ -0,0 +1,31 @@
|
||||
/* Python interface to full record targets.
|
||||
|
||||
Copyright 2016-2017 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/>. */
|
||||
|
||||
#ifndef GDB_PY_RECORD_FULL_H
|
||||
#define GDB_PY_RECORD_FULL_H
|
||||
|
||||
#include "python-internal.h"
|
||||
|
||||
/* Implementation of record.method [str]. */
|
||||
extern PyObject *recpy_full_method (PyObject *self, void *value);
|
||||
|
||||
/* Implementation of record.format [str]. */
|
||||
extern PyObject *recpy_full_format (PyObject *self, void *value);
|
||||
|
||||
#endif /* GDB_PY_RECORD_FULL_H */
|
@ -21,6 +21,8 @@
|
||||
#include "inferior.h"
|
||||
#include "record.h"
|
||||
#include "python-internal.h"
|
||||
#include "py-record-btrace.h"
|
||||
#include "py-record-full.h"
|
||||
#include "target.h"
|
||||
|
||||
/* Python Record object. */
|
||||
@ -57,6 +59,14 @@ recpy_ptid (PyObject *self, void* closure)
|
||||
static PyObject *
|
||||
recpy_method (PyObject *self, void* closure)
|
||||
{
|
||||
const recpy_record_object * const obj = (recpy_record_object *) self;
|
||||
|
||||
if (obj->method == RECORD_METHOD_FULL)
|
||||
return recpy_full_method (self, closure);
|
||||
|
||||
if (obj->method == RECORD_METHOD_BTRACE)
|
||||
return recpy_bt_method (self, closure);
|
||||
|
||||
return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
|
||||
}
|
||||
|
||||
@ -65,6 +75,14 @@ recpy_method (PyObject *self, void* closure)
|
||||
static PyObject *
|
||||
recpy_format (PyObject *self, void* closure)
|
||||
{
|
||||
const recpy_record_object * const obj = (recpy_record_object *) self;
|
||||
|
||||
if (obj->method == RECORD_METHOD_FULL)
|
||||
return recpy_full_format (self, closure);
|
||||
|
||||
if (obj->method == RECORD_METHOD_BTRACE)
|
||||
return recpy_bt_format (self, closure);
|
||||
|
||||
return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
|
||||
}
|
||||
|
||||
@ -73,6 +91,11 @@ recpy_format (PyObject *self, void* closure)
|
||||
static PyObject *
|
||||
recpy_goto (PyObject *self, PyObject *value)
|
||||
{
|
||||
const recpy_record_object * const obj = (recpy_record_object *) self;
|
||||
|
||||
if (obj->method == RECORD_METHOD_BTRACE)
|
||||
return recpy_bt_goto (self, value);
|
||||
|
||||
return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
|
||||
}
|
||||
|
||||
@ -81,6 +104,11 @@ recpy_goto (PyObject *self, PyObject *value)
|
||||
static PyObject *
|
||||
recpy_replay_position (PyObject *self, void *closure)
|
||||
{
|
||||
const recpy_record_object * const obj = (recpy_record_object *) self;
|
||||
|
||||
if (obj->method == RECORD_METHOD_BTRACE)
|
||||
return recpy_bt_replay_position (self, closure);
|
||||
|
||||
return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
|
||||
}
|
||||
|
||||
@ -89,6 +117,11 @@ recpy_replay_position (PyObject *self, void *closure)
|
||||
static PyObject *
|
||||
recpy_instruction_history (PyObject *self, void* closure)
|
||||
{
|
||||
const recpy_record_object * const obj = (recpy_record_object *) self;
|
||||
|
||||
if (obj->method == RECORD_METHOD_BTRACE)
|
||||
return recpy_bt_instruction_history (self, closure);
|
||||
|
||||
return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
|
||||
}
|
||||
|
||||
@ -97,6 +130,11 @@ recpy_instruction_history (PyObject *self, void* closure)
|
||||
static PyObject *
|
||||
recpy_function_call_history (PyObject *self, void* closure)
|
||||
{
|
||||
const recpy_record_object * const obj = (recpy_record_object *) self;
|
||||
|
||||
if (obj->method == RECORD_METHOD_BTRACE)
|
||||
return recpy_bt_function_call_history (self, closure);
|
||||
|
||||
return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
|
||||
}
|
||||
|
||||
@ -105,6 +143,11 @@ recpy_function_call_history (PyObject *self, void* closure)
|
||||
static PyObject *
|
||||
recpy_begin (PyObject *self, void* closure)
|
||||
{
|
||||
const recpy_record_object * const obj = (recpy_record_object *) self;
|
||||
|
||||
if (obj->method == RECORD_METHOD_BTRACE)
|
||||
return recpy_bt_begin (self, closure);
|
||||
|
||||
return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
|
||||
}
|
||||
|
||||
@ -113,6 +156,11 @@ recpy_begin (PyObject *self, void* closure)
|
||||
static PyObject *
|
||||
recpy_end (PyObject *self, void* closure)
|
||||
{
|
||||
const recpy_record_object * const obj = (recpy_record_object *) self;
|
||||
|
||||
if (obj->method == RECORD_METHOD_BTRACE)
|
||||
return recpy_bt_end (self, closure);
|
||||
|
||||
return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,9 @@
|
||||
|
||||
#define PyInt_Check PyLong_Check
|
||||
#define PyInt_FromLong PyLong_FromLong
|
||||
#define PyInt_FromSsize_t PyLong_FromSsize_t
|
||||
#define PyInt_AsLong PyLong_AsLong
|
||||
#define PyInt_AsSsize_t PyLong_AsSsize_t
|
||||
|
||||
#define PyString_FromString PyUnicode_FromString
|
||||
#define PyString_Decode PyUnicode_Decode
|
||||
@ -439,6 +441,8 @@ int gdbpy_initialize_values (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_frames (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_btrace (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_record (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_symtabs (void)
|
||||
|
@ -1629,6 +1629,7 @@ do_start_initialization ()
|
||||
|| gdbpy_initialize_frames () < 0
|
||||
|| gdbpy_initialize_commands () < 0
|
||||
|| gdbpy_initialize_record () < 0
|
||||
|| gdbpy_initialize_btrace () < 0
|
||||
|| gdbpy_initialize_symbols () < 0
|
||||
|| gdbpy_initialize_symtabs () < 0
|
||||
|| gdbpy_initialize_blocks () < 0
|
||||
|
Loading…
Reference in New Issue
Block a user