This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Fix "maintenance selftest" printing stray instructions
- From: Pedro Alves <palves at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 2 Feb 2017 23:36:45 -0000
- Subject: [binutils-gdb] Fix "maintenance selftest" printing stray instructions
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9b6da501bff22325867d8afe42fa01d4704e72f8
commit 9b6da501bff22325867d8afe42fa01d4704e72f8
Author: Pedro Alves <palves@redhat.com>
Date: Thu Feb 2 23:36:29 2017 +0000
Fix "maintenance selftest" printing stray instructions
The "maintenance selftest" command is printing odd bits of stray
instructions like:
~~~
brkwarning: A handler for the OS ABI "GNU/Linux" is not built into this configuration
of GDB. Attempting to continue with the default HS settings.
brkmov r0, #0mov r0, #0mov r0, #0mov r0, #0mov r0, #0mov r0, #0mov r0, #0mov r0, #0mov r0, #0mov r0, #0mov r0, #0mov r0, #0mov r0, #0mov r0, #0mov r0, #0breakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakM3.L = 0xffff;/* ( -1) M3=0x0xffff(65535) */break 8break 8warning: A handler for the OS ABI "GNU/Linux" is not built into this configuration
of GDB. Attempting to continue with the default cris:common_v10_v32 settings.
~~~
etc. Those appear because here:
class gdb_disassembler_test : public gdb_disassembler
{
public:
const bool verbose = false;
explicit gdb_disassembler_test (struct gdbarch *gdbarch,
const gdb_byte *insn,
size_t len)
: gdb_disassembler (gdbarch,
(verbose ? gdb_stdout : &null_stream),
gdb_disassembler_test::read_memory),
specifically in this line:
(verbose ? gdb_stdout : &null_stream),
"verbose" has not been initialized yet, because the order of
initialization is base classes first, then members. I.e. "verbose" is
only initialized after the base constructor is called. Since the
gdb_disassembler_test object is created on the stack, "verbose" has
garbage at that point. If the gargage is non-zero, then we end up
with the gdb_disassembler_test's stream incorrectly pointing to
gdb_stdout.
gdb/ChangeLog:
2017-02-02 Pedro Alves <palves@redhat.com>
* disasm-selftests.c (print_one_insn_test): Move the "verbose"
field out of gdb_disassembler_test and make it static.
Diff:
---
gdb/ChangeLog | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 95dfd00..202c90c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2017-02-02 Pedro Alves <palves@redhat.com>
+ * disasm-selftests.c (print_one_insn_test): Move the "verbose"
+ field out of gdb_disassembler_test and make it static.
+
+2017-02-02 Pedro Alves <palves@redhat.com>
+
* mi/mi-common.h (struct mi_interp): Delete the mi2_interp,
mi1_interp and mi_interp fields.