]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/python] Fix GDB_PY_{LL,LLU}_ARG on platform without long long
authorTom de Vries <tdevries@suse.de>
Mon, 10 Jun 2024 15:53:30 +0000 (17:53 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 10 Jun 2024 15:53:30 +0000 (17:53 +0200)
If in gdb/python/python-internal.h, we pretend to have a platform that doesn't
support long long:
...
-#ifdef HAVE_LONG_LONG
+#if 0
...
I get on arm-linux:
...
(gdb) placement_candidate()
disassemble test^M
Dump of assembler code for function test:^M
   0x004004d8 <+0>:     push    {r11}           @ (str r11, [sp, #-4]!)^M
   0x004004dc <+4>:     Python Exception <class 'ValueError'>: \
     Buffer returned from read_memory is sized 0 instead of the expected 4^M
^M
unknown disassembler error (error = -1)^M
(gdb) FAIL: $exp: memory source api: second disassembler pass
...

The problem is that gdb_py_longest is typedef-ed to long, but the
corresponding format character GDB_PY_LL_ARG is defined to "L", meaning
"long long" [1].

Fix this by using "l", meaning long instead.  Likewise for GDB_PY_LLU_ARG.

Tested on arm-linux.

Approved-By: Tom Tromey <tom@tromey.com>
PR python/31845
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31845

[1] https://docs.python.org/3/c-api/arg.html

gdb/python/python-internal.h

index 3c450560b9f96e63c3ad85412cf8e928de3c06ab..d07f239ca655815a7f383c429731324143885879 100644 (file)
@@ -125,8 +125,8 @@ typedef unsigned PY_LONG_LONG gdb_py_ulongest;
 
 #else /* HAVE_LONG_LONG */
 
-#define GDB_PY_LL_ARG "L"
-#define GDB_PY_LLU_ARG "K"
+#define GDB_PY_LL_ARG "l"
+#define GDB_PY_LLU_ARG "k"
 typedef long gdb_py_longest;
 typedef unsigned long gdb_py_ulongest;
 #define gdb_py_long_as_ulongest PyLong_AsUnsignedLong