From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@redhat.com>, Joel Brobecker <brobecker@adacore.com>
Subject: Re: [RFA/Python] Fix procfs.c build failure on 32bit solaris (_FILE_OFFSET_BITS)
Date: Tue, 23 Nov 2010 16:29:00 -0000 [thread overview]
Message-ID: <201011231628.33851.pedro@codesourcery.com> (raw)
In-Reply-To: <m3lj4k3w1m.fsf@fleche.redhat.com>
On Tuesday 23 November 2010 15:21:41, Tom Tromey wrote:
> >>>>> "Pedro" == Pedro Alves <pedro@codesourcery.com> writes:
> Pedro> Given that we only need to hold a pointer to this, thus the PyObject
> Pedro> need not be complete at this point, can we forward declare PyObject
> Pedro> instead somehow?
>
> Python defines it as a typedef for "struct _object *". Yuck -- I'd
> rather not copy that into our code.
I see that PyObject is an abstract base class, and that this particular
concrete class is struct breakpoint_object ...
> Pedro> If not, can we perhaps come up with a wrapper type that itself
> Pedro> can be forward declared? Or fallback to void* if nothing else
> Pedro> cleaner is possible?
>
> Either of these works for me.
... so we already have a wrapper type we can forward declare.
Here's a patch. We can move the PyObject fallback typedef from defs.h
to varobj.c again. I haven't looked to see if the PyObject pointers
in struct varobj have some other concrete type we could forward
declare instead. Or why don't we #ifdef out those fields if building
without python.
Tested by building gdb with and without --with-python=no.
--
Pedro Alves
2010-11-23 Pedro Alves <pedro@codesourcery.com>
gdb/
* breakpoint.h: No longer include python.h or python-internal.h.
(struct breakpoint_object): Forward declare.
* defs.h (PyObject) [!HAVE_PYTHON]: Don't define.
* varobj.c (PyObject) [!HAVE_PYTHON]: Define.
* python/py-breakpoint.c (build_bp_list): Cast py_bp_object to
PyObject pointer.
(gdbpy_breakpoint_created): Remove casts around py_bp_object
accesses.
---
gdb/breakpoint.h | 8 ++------
gdb/defs.h | 4 ----
gdb/python/py-breakpoint.c | 6 +++---
gdb/varobj.c | 2 ++
4 files changed, 7 insertions(+), 13 deletions(-)
Index: src/gdb/breakpoint.h
===================================================================
--- src.orig/gdb/breakpoint.h 2010-11-11 14:46:24.000000000 +0000
+++ src/gdb/breakpoint.h 2010-11-23 16:07:20.000000000 +0000
@@ -24,13 +24,9 @@
#include "value.h"
#include "vec.h"
-#if HAVE_PYTHON
-#include "python/python.h"
-#include "python/python-internal.h"
-#endif
-
struct value;
struct block;
+struct breakpoint_object;
/* This is the maximum number of bytes a breakpoint instruction can take.
Feel free to increase it. It's just used in a few places to size
@@ -568,7 +564,7 @@ struct breakpoint
This is always NULL for a GDB that is not script enabled. It
can sometimes be NULL for enabled GDBs as not all breakpoint
types are tracked by the Python scripting API. */
- PyObject *py_bp_object;
+ struct breakpoint_object *py_bp_object;
};
typedef struct breakpoint *breakpoint_p;
Index: src/gdb/defs.h
===================================================================
--- src.orig/gdb/defs.h 2010-11-11 14:46:24.000000000 +0000
+++ src/gdb/defs.h 2010-11-23 16:05:28.000000000 +0000
@@ -1240,8 +1240,4 @@ void dummy_obstack_deallocate (void *obj
extern void initialize_progspace (void);
extern void initialize_inferiors (void);
-#ifndef HAVE_PYTHON
-typedef int PyObject;
-#endif
-
#endif /* #ifndef DEFS_H */
Index: src/gdb/python/py-breakpoint.c
===================================================================
--- src.orig/gdb/python/py-breakpoint.c 2010-11-11 14:46:26.000000000 +0000
+++ src/gdb/python/py-breakpoint.c 2010-11-23 16:11:24.000000000 +0000
@@ -636,7 +636,7 @@ static int
build_bp_list (struct breakpoint *b, void *arg)
{
PyObject *list = arg;
- PyObject *bp = b->py_bp_object;
+ PyObject *bp = (PyObject *) b->py_bp_object;
int iserr = 0;
/* Not all breakpoints will have a companion Python object.
@@ -718,7 +718,7 @@ gdbpy_breakpoint_created (int num)
{
newbp->number = num;
newbp->bp = bp;
- newbp->bp->py_bp_object = (PyObject *) newbp;
+ newbp->bp->py_bp_object = newbp;
Py_INCREF (newbp);
++bppy_live;
}
@@ -746,7 +746,7 @@ gdbpy_breakpoint_deleted (int num)
if (! bp)
return;
- bp_obj = ((breakpoint_object *) bp->py_bp_object);
+ bp_obj = bp->py_bp_object;
if (bp_obj)
{
bp_obj->bp = NULL;
Index: src/gdb/varobj.c
===================================================================
--- src.orig/gdb/varobj.c 2010-11-19 16:49:24.000000000 +0000
+++ src/gdb/varobj.c 2010-11-23 16:23:17.000000000 +0000
@@ -39,6 +39,8 @@
#if HAVE_PYTHON
#include "python/python.h"
#include "python/python-internal.h"
+#else
+typedef int PyObject;
#endif
/* Non-zero if we want to see trace of varobj level stuff. */
next prev parent reply other threads:[~2010-11-23 16:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-23 1:14 Joel Brobecker
2010-11-23 3:25 ` Jan Kratochvil
2010-11-23 12:42 ` Pedro Alves
2010-11-23 15:22 ` Tom Tromey
2010-11-23 16:29 ` Pedro Alves [this message]
2010-11-23 17:23 ` Phil Muldoon
2010-11-23 17:47 ` Pedro Alves
2010-11-24 17:20 ` Joel Brobecker
2010-11-25 13:12 ` Pedro Alves
2010-11-24 18:25 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201011231628.33851.pedro@codesourcery.com \
--to=pedro@codesourcery.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox