Skip to content

Commit 4858ec1

Browse files
committed
gdb: python: rename target_object to pytarget_object
GDB has since added a target_object enum that must be worked around.
1 parent bbd6aef commit 4858ec1

File tree

2 files changed

+37
-37
lines changed

2 files changed

+37
-37
lines changed

gdb/python/py-target.c

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
static PyObject *py_target_xfer_eof_error;
3030
static PyObject *py_target_xfer_unavailable_error;
3131

32-
extern PyTypeObject target_object_type
33-
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("target_object");
32+
extern PyTypeObject pytarget_object_type
33+
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("pytarget_object");
3434

3535
/* Require that Target operations are valid */
3636
#define THPY_REQUIRE_VALID_RETURN(Target, ret) \
@@ -96,16 +96,16 @@ extern PyTypeObject target_object_type
9696
* This gives us the opportunity to find our Python Object when we are called
9797
* from C code
9898
*/
99-
static target_object * target_ops_to_target_obj(struct target_ops *ops)
99+
static pytarget_object * target_ops_to_target_obj(struct target_ops *ops)
100100
{
101-
target_object *target_obj;
101+
pytarget_object *target_obj;
102102

103-
if (ops->to_data == &target_object_type) {
104-
target_obj = container_of(ops, target_object, python_ops);
103+
if (ops->to_data == &pytarget_object_type) {
104+
target_obj = container_of(ops, pytarget_object, python_ops);
105105
return target_obj;
106106
}
107107

108-
target_obj = PyObject_New (target_object, &target_object_type);
108+
target_obj = PyObject_New (pytarget_object, &pytarget_object_type);
109109
if (target_obj)
110110
target_obj->ops = ops;
111111

@@ -135,7 +135,7 @@ static const
135135
char *py_target_to_thread_name (struct target_ops *ops,
136136
struct thread_info *info)
137137
{
138-
target_object *target_obj = target_ops_to_target_obj (ops);
138+
pytarget_object *target_obj = target_ops_to_target_obj (ops);
139139
PyObject *self = (PyObject *) target_obj;
140140
PyObject *arglist = NULL;
141141
PyObject *result = NULL;
@@ -196,7 +196,7 @@ py_target_to_xfer_partial (struct target_ops *ops,
196196
gdb_byte *gdb_readbuf, const gdb_byte *gdb_writebuf,
197197
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
198198
{
199-
target_object *target_obj = target_ops_to_target_obj (ops);
199+
pytarget_object *target_obj = target_ops_to_target_obj (ops);
200200
PyObject *self = (PyObject *) target_obj;
201201
PyObject *callback = NULL;
202202
PyObject *readbuf = NULL;
@@ -306,7 +306,7 @@ static char *
306306
py_target_to_extra_thread_info (struct target_ops *ops, struct thread_info *info)
307307
{
308308
/* Note how we can obtain our Parent Python Object from the ops too */
309-
target_object *target_obj = target_ops_to_target_obj(ops);
309+
pytarget_object *target_obj = target_ops_to_target_obj(ops);
310310
PyObject * self = (PyObject *)target_obj;
311311

312312
struct cleanup *cleanup;
@@ -322,7 +322,7 @@ py_target_to_extra_thread_info (struct target_ops *ops, struct thread_info *info
322322
static void
323323
py_target_to_update_thread_list (struct target_ops *ops)
324324
{
325-
target_object *target_obj = target_ops_to_target_obj (ops);
325+
pytarget_object *target_obj = target_ops_to_target_obj (ops);
326326
PyObject * self = (PyObject *) target_obj;
327327
PyObject *callback = NULL;
328328
PyObject *arglist = NULL;
@@ -363,7 +363,7 @@ py_target_to_update_thread_list (struct target_ops *ops)
363363
static int
364364
py_target_to_thread_alive (struct target_ops *ops, ptid_t ptid)
365365
{
366-
target_object *target_obj = target_ops_to_target_obj (ops);
366+
pytarget_object *target_obj = target_ops_to_target_obj (ops);
367367
PyObject *self = (PyObject *) target_obj;
368368
PyObject *ptid_obj = NULL;
369369
PyObject *arglist = NULL;
@@ -421,7 +421,7 @@ py_target_to_thread_alive (struct target_ops *ops, ptid_t ptid)
421421
static char *py_target_to_pid_to_str(struct target_ops *ops, ptid_t ptid)
422422
{
423423
/* Note how we can obtain our Parent Python Object from the ops too */
424-
target_object *target_obj = target_ops_to_target_obj (ops);
424+
pytarget_object *target_obj = target_ops_to_target_obj (ops);
425425
PyObject *self = (PyObject *) target_obj;
426426
PyObject *ptid_obj = NULL;
427427
PyObject *arglist = NULL;
@@ -477,7 +477,7 @@ static char *py_target_to_pid_to_str(struct target_ops *ops, ptid_t ptid)
477477
static void py_target_to_fetch_registers (struct target_ops *ops,
478478
struct regcache *regcache, int reg)
479479
{
480-
target_object *target_obj = target_ops_to_target_obj (ops);
480+
pytarget_object *target_obj = target_ops_to_target_obj (ops);
481481
PyObject * self = (PyObject *) target_obj;
482482
PyObject *arglist = NULL;
483483
PyObject *result = NULL;
@@ -529,7 +529,7 @@ static void py_target_to_fetch_registers (struct target_ops *ops,
529529
static void py_target_to_prepare_to_store (struct target_ops *ops,
530530
struct regcache *regcache)
531531
{
532-
target_object *target_obj = target_ops_to_target_obj (ops);
532+
pytarget_object *target_obj = target_ops_to_target_obj (ops);
533533
PyObject * self = (PyObject *) target_obj;
534534
PyObject *arglist = NULL;
535535
PyObject *result = NULL;
@@ -574,7 +574,7 @@ static void py_target_to_prepare_to_store (struct target_ops *ops,
574574
static void py_target_to_store_registers (struct target_ops *ops,
575575
struct regcache *regcache, int reg)
576576
{
577-
target_object *target_obj = target_ops_to_target_obj (ops);
577+
pytarget_object *target_obj = target_ops_to_target_obj (ops);
578578
PyObject * self = (PyObject *) target_obj;
579579
PyObject *arglist = NULL;
580580
PyObject *result = NULL;
@@ -625,7 +625,7 @@ static void py_target_to_store_registers (struct target_ops *ops,
625625
static int
626626
py_target_to_has_execution (struct target_ops *ops, ptid_t ptid)
627627
{
628-
target_object *target_obj = target_ops_to_target_obj (ops);
628+
pytarget_object *target_obj = target_ops_to_target_obj (ops);
629629
PyObject * self = (PyObject *) target_obj;
630630
PyObject *arglist = NULL;
631631
PyObject *result = NULL;
@@ -712,7 +712,7 @@ static void py_target_register_ops(struct target_ops * ops)
712712

713713
ops->to_magic = OPS_MAGIC;
714714

715-
ops->to_data = &target_object_type;
715+
ops->to_data = &pytarget_object_type;
716716

717717
/* Install any remaining operations as delegators */
718718
complete_target_initialization (ops);
@@ -732,7 +732,7 @@ target_dealloc (PyObject *self)
732732
{
733733
ENTRY();
734734

735-
// Py_DECREF (((target_object *) self)->inf_obj);
735+
// Py_DECREF (((pytarget_object *) self)->inf_obj);
736736
// Decremement any references taken....
737737
Py_TYPE (self)->tp_free (self);
738738

@@ -748,8 +748,8 @@ enum target_names {
748748
static PyObject *
749749
tgt_py_get_name (PyObject *self, void * arg)
750750
{
751-
enum target_names target_string = (enum target_names) arg;
752-
target_object *target_obj = (target_object *) self;
751+
enum target_names target_string = (enum target_names) (unsigned long)arg;
752+
pytarget_object *target_obj = (pytarget_object *) self;
753753
struct target_ops *ops = target_obj->ops;
754754

755755
PyObject *name;
@@ -789,8 +789,8 @@ tgt_py_get_name (PyObject *self, void * arg)
789789
static int
790790
tgt_py_set_name (PyObject *self, PyObject *newvalue, void * arg)
791791
{
792-
enum target_names target_string = (enum target_names) arg;
793-
target_object *target_obj = (target_object *) self;
792+
enum target_names target_string = (enum target_names)(unsigned long) arg;
793+
pytarget_object *target_obj = (pytarget_object *) self;
794794
struct target_ops *ops = target_obj->ops;
795795
char *name = NULL;
796796

@@ -845,7 +845,7 @@ static PyObject *target_getconst(PyObject *_self, void *_value)
845845
#define CONST_GET(x) {#x, target_getconst, NULL, #x, (void*)x}
846846

847847

848-
static PyGetSetDef target_object_getset[] =
848+
static PyGetSetDef pytarget_object_getset[] =
849849
{
850850
{ "name", tgt_py_get_name, NULL,
851851
"The name of the target", (void*)TGT_NAME },
@@ -909,7 +909,7 @@ CONST_GET(TARGET_OBJECT_EXEC_FILE),
909909
static PyObject *
910910
tgtpy_default_to_thread_name (PyObject *self, PyObject *args)
911911
{
912-
target_object *target_obj = (target_object *) self;
912+
pytarget_object *target_obj = (pytarget_object *) self;
913913
PyObject * ThreadName;
914914

915915
ENTRY();
@@ -921,7 +921,7 @@ tgtpy_default_to_thread_name (PyObject *self, PyObject *args)
921921
return ThreadName;
922922
}
923923

924-
static PyMethodDef target_object_methods[] =
924+
static PyMethodDef pytarget_object_methods[] =
925925
{
926926
{ "to_thread_name_int", tgtpy_default_to_thread_name, METH_VARARGS | METH_KEYWORDS,
927927
"to_thread_name (thread_info) -> String.\n\
@@ -936,7 +936,7 @@ Return string name representation of the given thread." },
936936
static int
937937
target_init (PyObject *self, PyObject *args, PyObject *kw)
938938
{
939-
target_object *target_obj = (target_object *) self;
939+
pytarget_object *target_obj = (pytarget_object *) self;
940940

941941
ENTRY();
942942

@@ -971,9 +971,9 @@ gdbpy_initialize_target (void)
971971
ENTRY();
972972

973973
/* Allow us to create instantiations of this class ... */
974-
target_object_type.tp_new = PyType_GenericNew;
974+
pytarget_object_type.tp_new = PyType_GenericNew;
975975

976-
if (PyType_Ready (&target_object_type) < 0)
976+
if (PyType_Ready (&pytarget_object_type) < 0)
977977
return -1;
978978

979979
py_target_xfer_eof_error = PyErr_NewException ("gdb.TargetXferEOF",
@@ -998,7 +998,7 @@ gdbpy_initialize_target (void)
998998
EXIT ();
999999

10001000
return gdb_pymodule_addobject (gdb_module, "Target",
1001-
(PyObject *) &target_object_type);
1001+
(PyObject *) &pytarget_object_type);
10021002
fail:
10031003
gdbpy_print_stack();
10041004
EXIT ();
@@ -1010,11 +1010,11 @@ gdbpy_initialize_target (void)
10101010

10111011

10121012

1013-
PyTypeObject target_object_type =
1013+
PyTypeObject pytarget_object_type =
10141014
{
10151015
PyVarObject_HEAD_INIT (NULL, 0)
10161016
"gdb.Target", /*tp_name*/
1017-
sizeof (target_object), /*tp_basicsize*/
1017+
sizeof (pytarget_object), /*tp_basicsize*/
10181018
0, /*tp_itemsize*/
10191019
target_dealloc, /*tp_dealloc*/
10201020
0, /*tp_print*/
@@ -1039,9 +1039,9 @@ PyTypeObject target_object_type =
10391039
0, /* tp_weaklistoffset */
10401040
0, /* tp_iter */
10411041
0, /* tp_iternext */
1042-
target_object_methods, /* tp_methods */
1042+
pytarget_object_methods, /* tp_methods */
10431043
0, /* tp_members */
1044-
target_object_getset, /* tp_getset */
1044+
pytarget_object_getset, /* tp_getset */
10451045
0, /* tp_base */
10461046
0, /* tp_dict */
10471047
0, /* tp_descr_get */
@@ -1055,9 +1055,9 @@ PyObject *
10551055
gdbpy_current_target (PyObject *self, PyObject *args)
10561056
{
10571057
struct target_ops *ops = current_target.beneath;
1058-
target_object *obj = target_ops_to_target_obj(ops);
1058+
pytarget_object *obj = target_ops_to_target_obj(ops);
10591059

1060-
if (obj->ops->to_data == &target_object_type)
1060+
if (obj->ops->to_data == &pytarget_object_type)
10611061
Py_INCREF(obj);
10621062

10631063
return (PyObject *)obj;

gdb/python/py-target.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ typedef struct
3131

3232
struct target_ops python_ops;
3333

34-
} target_object;
34+
} pytarget_object;
3535

3636
#endif /* GDB_PY_TARGET_H */

0 commit comments

Comments
 (0)