public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/31845] New: [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test
@ 2024-06-05  9:41 vries at gcc dot gnu.org
  2024-06-05  9:44 ` [Bug python/31845] " vries at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2024-06-05  9:41 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31845

            Bug ID: 31845
           Summary: [gdb/python, arm] FAIL: gdb.python/py-disasm.exp:
                    global_disassembler=ShowInfoRepr: disassemble test
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: python
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

I ran test-case gdb.python/py-disasm.exp on arm-linux, getting 26 unexpected
failures.

The first fail I ran into was:
...
disassemble test^M
Dump of assembler code for function test:^M
   0x004004d8 <+0>:     push    {r11}           @ (str r11, [sp, #-4]!)^M
   0x004004dc <+4>:     add     r11, sp, #0^M
   0x004004e0 <+8>:     nop     {0}^M
=> 0x004004e4 <+12>:    nop     {0}^M
   0x004004e8 <+16>:    nop     {0}^M
   0x004004ec <+20>:    mov     r3, #0^M
   0x004004f0 <+24>:    mov     r0, r3^M
   0x004004f4 <+28>:    add     sp, r11, #0^M
   0x004004f8 <+32>:    pop     {r11}           @ (ldr r11, [sp], #4)^M
   0x004004fc <+36>:    bx      lr^M
End of assembler dump.^M
(gdb) FAIL: gdb.python/py-disasm.exp: global_disassembler=: disassemble test
...

Easily fixed by:
...
diff --git a/gdb/testsuite/gdb.python/py-disasm.exp
b/gdb/testsuite/gdb.python/py-disasm.exp
index 7c6f972a7e7..5d7d9221169 100644
--- a/gdb/testsuite/gdb.python/py-disasm.exp
+++ b/gdb/testsuite/gdb.python/py-disasm.exp
@@ -65,7 +65,7 @@ proc py_remove_all_disassemblers {} {
 #
 # Each different disassembler tests some different feature of the
 # Python disassembler API.
-set nop "(nop|nop\t0)"
+set nop "(nop|nop\t0|[string_to_regexp nop\t{0}])"
 set unknown_error_pattern "unknown disassembler error \\(error = -1\\)"
 set addr_pattern "\r\n=> ${curr_pc_pattern} <\[^>\]+>:\\s+"
 set base_pattern "${addr_pattern}${nop}"
...
which brings down the unexpected failures to 21.

New first failure is:
...
disassemble test^M
Dump of assembler code for function test:^M
   0x004004d8 <+0>:     push    {r11}           @ (str r11, [sp, #-4]!)^M
   0x004004dc <+4>:     add     r11, sp, #0^M
   0x004004e0 <+8>:     nop     {0}^M
=> 0x004004e4 <+12>:    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: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr:
disassemble test
...

Fixed by:
...
diff --git a/gdb/python/py-disasm.c b/gdb/python/py-disasm.c
index 2d8ce44a065..0c11c2112b2 100644
--- a/gdb/python/py-disasm.c
+++ b/gdb/python/py-disasm.c
@@ -855,7 +882,7 @@ gdbpy_disassembler::read_memory_func (bfd_vma memaddr,
gdb_byte *buff,
      overridden by the user.  */
   gdbpy_ref<> result_obj (PyObject_CallMethod ((PyObject *) obj,
                                               "read_memory",
-                                              "KL", len, offset));
+                                              "IL", len, offset));

   /* Handle any exceptions.  */
   if (result_obj == nullptr)
...
which brings down the unexpected failures to 1.

FTR, remaining failure:
...
(gdb) PASS: gdb.python/py-disasm.exp: memory source api: disassemble test
python analyzing_disassembler.find_replacement_candidate()^M
no nop was found^M
(gdb) FAIL: gdb.python/py-disasm.exp: memory source api: python
analyzing_disassembler.find_replacement_candidate()
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug python/31845] [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test
  2024-06-05  9:41 [Bug python/31845] New: [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test vries at gcc dot gnu.org
@ 2024-06-05  9:44 ` vries at gcc dot gnu.org
  2024-06-07  6:37 ` vries at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2024-06-05  9:44 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31845

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #0)
> FTR, remaining failure:
> ...
> (gdb) PASS: gdb.python/py-disasm.exp: memory source api: disassemble test
> python analyzing_disassembler.find_replacement_candidate()^M
> no nop was found^M
> (gdb) FAIL: gdb.python/py-disasm.exp: memory source api: python
> analyzing_disassembler.find_replacement_candidate()
> ...


Fixed by:
...
index c09eae811ee..2741fdb6c19 100644
--- a/gdb/testsuite/gdb.python/py-disasm.py
+++ b/gdb/testsuite/gdb.python/py-disasm.py
@@ -46,7 +46,7 @@ def check_building_disassemble_result():


 def is_nop(s):
-    return s == "nop" or s == "nop\t0"
+    return s == "nop" or s == "nop\t0" or s == "nop\t{0}"


 # Remove all currently registered disassemblers.
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug python/31845] [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test
  2024-06-05  9:41 [Bug python/31845] New: [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test vries at gcc dot gnu.org
  2024-06-05  9:44 ` [Bug python/31845] " vries at gcc dot gnu.org
@ 2024-06-07  6:37 ` vries at gcc dot gnu.org
  2024-06-10 15:52 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2024-06-07  6:37 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31845

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
https://sourceware.org/pipermail/gdb-patches/2024-June/209735.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug python/31845] [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test
  2024-06-05  9:41 [Bug python/31845] New: [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test vries at gcc dot gnu.org
  2024-06-05  9:44 ` [Bug python/31845] " vries at gcc dot gnu.org
  2024-06-07  6:37 ` vries at gcc dot gnu.org
@ 2024-06-10 15:52 ` cvs-commit at gcc dot gnu.org
  2024-06-10 15:53 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-10 15:52 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31845

--- Comment #3 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4cd214dce4579f86a85a96c882e0fc8c4d94601c

commit 4cd214dce4579f86a85a96c882e0fc8c4d94601c
Author: Tom de Vries <tdevries@suse.de>
Date:   Mon Jun 10 17:53:30 2024 +0200

    [gdb/python] Fix gdb.python/py-disasm.exp on arm-linux

    After fixing test-case gdb.python/py-disasm.exp to recognize the arm nop:
    ...
            nop     {0}
    ...
    we run into:
    ...
    disassemble test^M
    Dump of assembler code for function test:^M
       0x004004d8 <+0>:     push    {r11}           @ (str r11, [sp, #-4]!)^M
       0x004004dc <+4>:     add     r11, sp, #0^M
       0x004004e0 <+8>:     nop     {0}^M
    => 0x004004e4 <+12>:    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: global_disassembler=ShowInfoRepr: disassemble test
    ...

    This is caused by this code in gdbpy_disassembler::read_memory_func:
    ...
      gdbpy_ref<> result_obj (PyObject_CallMethod ((PyObject *) obj,
                                                  "read_memory",
                                                  "KL", len, offset));
    ...
    where len has type "unsigned int", while "K" means "unsigned long long"
[1].

    Fix this by using "I" instead, meaning "unsigned int".

    Also, offset has type LONGEST, which is typedef'ed to int64_t, while "L"
means
    "long long".

    Fix this by using type gdb_py_longest for offset, in combination with
format
    character "GDB_PY_LL_ARG".  Likewise in disasmpy_info_read_memory.

    Tested on arm-linux.

    Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
    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

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug python/31845] [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test
  2024-06-05  9:41 [Bug python/31845] New: [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-06-10 15:52 ` cvs-commit at gcc dot gnu.org
@ 2024-06-10 15:53 ` cvs-commit at gcc dot gnu.org
  2024-06-10 15:53 ` vries at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-10 15:53 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31845

--- Comment #4 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=58a628530ee68fe705b443947643037319e7d44e

commit 58a628530ee68fe705b443947643037319e7d44e
Author: Tom de Vries <tdevries@suse.de>
Date:   Mon Jun 10 17:53:30 2024 +0200

    [gdb/python] Fix GDB_PY_{LL,LLU}_ARG on platform without long long

    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

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug python/31845] [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test
  2024-06-05  9:41 [Bug python/31845] New: [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test vries at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-06-10 15:53 ` cvs-commit at gcc dot gnu.org
@ 2024-06-10 15:53 ` vries at gcc dot gnu.org
  2024-06-14 14:08 ` vries at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2024-06-10 15:53 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31845

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |16.1

--- Comment #5 from Tom de Vries <vries at gcc dot gnu.org> ---
Fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug python/31845] [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test
  2024-06-05  9:41 [Bug python/31845] New: [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test vries at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2024-06-10 15:53 ` vries at gcc dot gnu.org
@ 2024-06-14 14:08 ` vries at gcc dot gnu.org
  2024-06-14 14:12 ` vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2024-06-14 14:08 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31845

--- Comment #6 from Tom de Vries <vries at gcc dot gnu.org> ---
*** Bug 31296 has been marked as a duplicate of this bug. ***

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug python/31845] [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test
  2024-06-05  9:41 [Bug python/31845] New: [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test vries at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2024-06-14 14:08 ` vries at gcc dot gnu.org
@ 2024-06-14 14:12 ` vries at gcc dot gnu.org
  2024-06-20 13:53 ` cvs-commit at gcc dot gnu.org
  2024-06-20 13:53 ` vries at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2024-06-14 14:12 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31845

--- Comment #7 from Tom de Vries <vries at gcc dot gnu.org> ---
*** Bug 30518 has been marked as a duplicate of this bug. ***

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug python/31845] [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test
  2024-06-05  9:41 [Bug python/31845] New: [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test vries at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2024-06-14 14:12 ` vries at gcc dot gnu.org
@ 2024-06-20 13:53 ` cvs-commit at gcc dot gnu.org
  2024-06-20 13:53 ` vries at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-20 13:53 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31845

--- Comment #8 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The gdb-15-branch branch has been updated by Tom de Vries
<vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1aa3b72f07269a0a678ba2de2481d84c74f1c117

commit 1aa3b72f07269a0a678ba2de2481d84c74f1c117
Author: Tom de Vries <tdevries@suse.de>
Date:   Thu Jun 20 15:54:16 2024 +0200

    [gdb/python] Fix gdb.python/py-disasm.exp on arm-linux

    After fixing test-case gdb.python/py-disasm.exp to recognize the arm nop:
    ...
            nop     {0}
    ...
    we run into:
    ...
    disassemble test^M
    Dump of assembler code for function test:^M
       0x004004d8 <+0>:     push    {r11}           @ (str r11, [sp, #-4]!)^M
       0x004004dc <+4>:     add     r11, sp, #0^M
       0x004004e0 <+8>:     nop     {0}^M
    => 0x004004e4 <+12>:    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: global_disassembler=ShowInfoRepr: disassemble test
    ...

    This is caused by this code in gdbpy_disassembler::read_memory_func:
    ...
      gdbpy_ref<> result_obj (PyObject_CallMethod ((PyObject *) obj,
                                                  "read_memory",
                                                  "KL", len, offset));
    ...
    where len has type "unsigned int", while "K" means "unsigned long long"
[1].

    Fix this by using "I" instead, meaning "unsigned int".

    Also, offset has type LONGEST, which is typedef'ed to int64_t, while "L"
means
    "long long".

    Fix this by using type gdb_py_longest for offset, in combination with
format
    character "GDB_PY_LL_ARG".  Likewise in disasmpy_info_read_memory.

    Tested on arm-linux.

    Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
    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

    (cherry picked from commit 4cd214dce4579f86a85a96c882e0fc8c4d94601c)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug python/31845] [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test
  2024-06-05  9:41 [Bug python/31845] New: [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test vries at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2024-06-20 13:53 ` cvs-commit at gcc dot gnu.org
@ 2024-06-20 13:53 ` vries at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2024-06-20 13:53 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31845

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|16.1                        |15.1

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2024-06-20 13:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-05  9:41 [Bug python/31845] New: [gdb/python, arm] FAIL: gdb.python/py-disasm.exp: global_disassembler=ShowInfoRepr: disassemble test vries at gcc dot gnu.org
2024-06-05  9:44 ` [Bug python/31845] " vries at gcc dot gnu.org
2024-06-07  6:37 ` vries at gcc dot gnu.org
2024-06-10 15:52 ` cvs-commit at gcc dot gnu.org
2024-06-10 15:53 ` cvs-commit at gcc dot gnu.org
2024-06-10 15:53 ` vries at gcc dot gnu.org
2024-06-14 14:08 ` vries at gcc dot gnu.org
2024-06-14 14:12 ` vries at gcc dot gnu.org
2024-06-20 13:53 ` cvs-commit at gcc dot gnu.org
2024-06-20 13:53 ` vries at gcc dot gnu.org

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).