public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [gdb/build] Redo poisoning of PyObject_CallMethod
@ 2024-06-19 12:45 Tom de Vries
  2024-06-19 17:04 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2024-06-19 12:45 UTC (permalink / raw)
  To: gdb-patches

In commit 764af878259 ("[gdb/python] Add typesafe wrapper around
PyObject_CallMethod") I added poisoning of PyObject_CallMethod:
...
/* Poison PyObject_CallMethod.  The typesafe wrapper gdbpy_call_method should be
   used instead.  */
template<typename... Args>
PyObject *
PyObject_CallMethod (Args...);
...

The idea was that subsequent code would be forced to use gdbpy_call_method
instead of PyObject_CallMethod.

However, that caused build issues with gcc 14 and python 3.13:
...
/usr/bin/ld: python/py-disasm.o: in function `gdb::ref_ptr<_object, gdbpy_ref_policy<_object> > gdbpy_call_method<unsigned int, long long>(_object*, char const*, unsigned int, long long)':
/data/vries/gdb/src/gdb/python/python-internal.h:207:(.text+0x384f): undefined reference to `_object* PyObject_CallMethod<_object*, char*, char*, unsigned int, long long>(_object*, char*, char*, unsigned int, long long)'
/usr/bin/ld: python/py-tui.o: in function `gdb::ref_ptr<_object, gdbpy_ref_policy<_object> > gdbpy_call_method<int>(_object*, char const*, int)':
/data/vries/gdb/src/gdb/python/python-internal.h:207:(.text+0x1235): undefined reference to `_object* PyObject_CallMethod<_object*, char*, char*, int>(_object*, char*, char*, int)'
/usr/bin/ld: python/py-tui.o: in function `gdb::ref_ptr<_object, gdbpy_ref_policy<_object> > gdbpy_call_method<int, int, int>(_object*, char const*, int, int, int)':
/data/vries/gdb/src/gdb/python/python-internal.h:207:(.text+0x12b0): undefined reference to `_object* PyObject_CallMethod<_object*, char*, char*, int, int, int>(_object*, char*, char*, int, int, int)'
collect2: error: ld returned 1 exit status
...

Fix this by poisoning without using templates.

Tested on x86_64-linux.
---
 gdb/python/python-internal.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index f4c35babe46..a014cf8a724 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -219,9 +219,11 @@ gdbpy_call_method (const gdbpy_ref<> &o, const char *method, Args... args)
 /* Poison PyObject_CallMethod.  The typesafe wrapper gdbpy_call_method should be
    used instead.  */
 #undef PyObject_CallMethod
-template<typename... Args>
-PyObject *
-PyObject_CallMethod (Args...);
+#ifdef __GNUC__
+# pragma GCC poison PyObject_CallMethod
+#else
+# define PyObject_CallMethod POISONED_PyObject_CallMethod
+#endif
 
 /* The 'name' parameter of PyErr_NewException was missing the 'const'
    qualifier in Python <= 3.4.  Hence, we wrap it in a function to

base-commit: 5445d7819ba0c00249939d1316e344f01a403607
-- 
2.35.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] [gdb/build] Redo poisoning of PyObject_CallMethod
  2024-06-19 12:45 [PATCH] [gdb/build] Redo poisoning of PyObject_CallMethod Tom de Vries
@ 2024-06-19 17:04 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2024-06-19 17:04 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> Fix this by poisoning without using templates.

Tom> Tested on x86_64-linux.

Thank you, this is ok.
Approved-By: Tom Tromey <tom@tromey.com>

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-19 17:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-19 12:45 [PATCH] [gdb/build] Redo poisoning of PyObject_CallMethod Tom de Vries
2024-06-19 17:04 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).