gdb/python: fix invalid use disassemble_info::stream

After this commit:

  commit 81384924cd
  Date:   Tue Apr 5 11:06:16 2022 +0100

      gdb: have gdb_disassemble_info carry 'this' in its stream pointer

The disassemble_info::stream field will no longer be a ui_file*.  That
commit failed to update one location in py-disasm.c though.

While running some tests using the Python disassembler API, I
triggered a call to gdbpy_disassembler::print_address_func, and, as I
had compiled GDB with the undefined behaviour sanitizer, GDB crashed
as the code currently (incorrectly) casts the stream field to be a
ui_file*.

In this commit I fix this error.

In order to test this case I had to tweak the existing test case a
little.  I also spotted some debug printf statements in py-disasm.py,
which I have removed.
This commit is contained in:
Andrew Burgess 2022-07-20 13:57:08 +01:00
parent 554128418b
commit 23aa2befce
4 changed files with 22 additions and 13 deletions

View file

@ -626,7 +626,7 @@ gdbpy_disassembler::print_address_func (bfd_vma addr,
{
gdbpy_disassembler *dis
= static_cast<gdbpy_disassembler *> (info->application_data);
print_address (dis->arch (), addr, (struct ui_file *) info->stream);
print_address (dis->arch (), addr, dis->stream ());
}
/* constructor. */