public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: sergiodj+buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] Add back gdb_pretty_print_insn
Date: Thu, 02 Feb 2017 11:42:00 -0000	[thread overview]
Message-ID: <187808b04f61df1c38fda0921e2d9eeb53e332ee@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT 187808b04f61df1c38fda0921e2d9eeb53e332ee ***

Author: Pedro Alves <palves@redhat.com>
Branch: master
Commit: 187808b04f61df1c38fda0921e2d9eeb53e332ee

Add back gdb_pretty_print_insn

ui_file_rewind is a ui_file method that only really works with mem
buffer files, and is a nop on other ui_file types.  It'd be desirable
to eliminate it from the base ui_file interface, and move it to the
"mem_fileopen" subclass of ui_file instead.  A following patch does
just that.

Unfortunately, there are a couple references to ui_file_rewind inside
gdb_disassembler::pretty_print_insn that were made harder to eliminate
with the recent addition of the gdb_disassembler wrapper.

Before the gdb_disassembler wrapper was added, in commit
e47ad6c0bd7aa3 ("Refactor disassembly code"), gdb_pretty_print_insn
used to be passed a ui_file pointer as argument, and it was simple to
adjust that pointer be a "mem_fileopen" ui_file pointer instead, since
there's only one gdb_pretty_print_insn caller.

That commit made gdb_pretty_print_insn be a method of
gdb_disassembler, and removed the method's ui_file parameter at the
same time, replaced by referencing the gdb_disassembler's stream
instead.  The trouble is that a gdb_disassembler can be instantiated
with a pointer any kind of ui_file.  Casting the gdb_disassembler's
stream to a mem_fileopen ui_file inside
gdb_disassembler::pretty_print_insn in order to call the reset method
would be gross hack.

The fix here is to:

 - make gdb_disassembler::pretty_print_insn a be free function again
   instead of a method of gdb_disassembler.  I.e., bring back
   gdb_pretty_print_insn.

 - but, don't add back the ui_file * parameter.  Instead, move the
   mem_fileopen allocation inside.  That is a better interface, given
   that the ui_file is only ever used as temporary scratch buffer as
   an implementation detail of gdb_pretty_print_insn.  The function's
   real "where to send output" parameter is the ui_out pointer.  (A
   following patch will add back buffer reuse across invocations
   differently).

 - don't add back a disassemble_info pointer either.  That used to be
   necessary for this bit:

	  err = m_di.read_memory_func (pc, &data, 1, &m_di);
	  if (err != 0)
	    m_di.memory_error_func (err, pc, &m_di);

   ... but AFAIK, it's not really necessary.  We can replace those
   three lines with a call to read_code.  This seems to fix a
   regression even, because before commit d8b49cf0c891d0 ("Don't throw
   exception in dis_asm_memory_error"), that memory_error_func call
   would throw an error/exception, but now it only records the error
   in the gdb_disassembler's m_err_memaddr field.  (read_code throws
   on error.)

With all these, gdb_pretty_print_insn is completely layered on top of
gdb_disassembler only using the latter's public API.

gdb/ChangeLog:
2017-02-02  Pedro Alves  <palves@redhat.com>

	* disasm.c (gdb_disassembler::pretty_print_insn): Rename to...
	(gdb_pretty_print_insn): ... this.  Now a free function.  Add back
	a 'gdbarch' parameter.  Allocate a mem_fileopen stream here.
	Adjust to call gdb_print_insn instead of
	gdb_disassembler::print_insn.
	(dump_insns, do_mixed_source_and_assembly_deprecated)
	(do_mixed_source_and_assembly, do_assembly_only): Add back a
	'gdbarch' parameter.  Remove gdb_disassembler parameter.
	(gdb_disassembly): Don't allocate a gdb_disassembler here.
	* disasm.h (gdb_disassembler::pretty_print_insn): Delete
	declaration.
	(gdb_pretty_print_insn): Re-add declaration.
	* record-btrace.c (btrace_insn_history): Don't allocate a
	gdb_disassembler here.  Adjust to call gdb_pretty_print_insn.


             reply	other threads:[~2017-02-02 11:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-02 11:42 sergiodj+buildbot [this message]
2017-02-02 11:42 ` Failures on Fedora-s390x-m64, branch master sergiodj+buildbot
2017-02-02 11:42 ` Failures on Debian-s390x-native-extended-gdbserver-m64, " sergiodj+buildbot
2017-02-02 11:55 ` Failures on Debian-s390x-native-gdbserver-m64, " sergiodj+buildbot
2017-02-02 12:12 ` Failures on Debian-s390x-m64, " sergiodj+buildbot
2017-02-02 22:46 ` Failures on Fedora-ppc64be-native-gdbserver-m64, " sergiodj+buildbot
2017-02-02 23:36 ` Failures on Fedora-ppc64be-native-extended-gdbserver-m64, " sergiodj+buildbot
2017-02-03  0:15 ` Failures on Fedora-ppc64be-cc-with-index, " sergiodj+buildbot
2017-02-03  4:48 ` Failures on Fedora-ppc64le-native-gdbserver-m64, " sergiodj+buildbot
2017-02-03  6:59 ` Failures on Fedora-ppc64le-native-extended-gdbserver-m64, " sergiodj+buildbot
2017-02-03  7:53 ` Failures on Fedora-ppc64le-cc-with-index, " sergiodj+buildbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=187808b04f61df1c38fda0921e2d9eeb53e332ee@gdb-build \
    --to=sergiodj+buildbot@sergiodj.net \
    --cc=gdb-testers@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).