From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 81517 invoked by alias); 21 Sep 2015 14:54:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 81445 invoked by uid 89); 21 Sep 2015 14:54:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mga11.intel.com Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 21 Sep 2015 14:54:51 +0000 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 21 Sep 2015 07:54:48 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 21 Sep 2015 07:54:46 -0700 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t8LEskxp014487; Mon, 21 Sep 2015 15:54:46 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id t8LEsje5010513; Mon, 21 Sep 2015 16:54:45 +0200 Received: (from mmetzger@localhost) by ulvlx001.iul.intel.com with œ id t8LEsjUG010509; Mon, 21 Sep 2015 16:54:45 +0200 From: Markus Metzger To: palves@redhat.com, dje@google.com Cc: gdb-patches@sourceware.org Subject: [PATCH 6/6] btrace: use gdb_disassembly_vec and new source interleaving method Date: Mon, 21 Sep 2015 14:54:00 -0000 Message-Id: <1442847283-10200-7-git-send-email-markus.t.metzger@intel.com> In-Reply-To: <1442847283-10200-1-git-send-email-markus.t.metzger@intel.com> References: <1442847283-10200-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes X-SW-Source: 2015-09/txt/msg00507.txt.bz2 Use the new gdb_disassembly_vec interface for the "record instruction- history" command. Use the new source interleaving method. We stick to the /m modifier. The old version is broken and there's no point in keeping it as alternative to this new version. 2015-09-21 Markus Metzger gdb/ * record-btrace.c (btrace_insn_history): Call gdb_disassembly_vec instead of gdb_disassembly. Set DISASSEMBLY_SPECULATIVE. * record.c (get_insn_history_modifiers): Set DISASSEMBLY_SOURCE instead of DISASSEMBLY_SOURCE_DEPRECATED. --- gdb/record-btrace.c | 54 ++++++++++++++++++++++++++--------------------------- gdb/record.c | 2 +- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index d14e6cf..ecb8085 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -538,11 +538,17 @@ btrace_insn_history (struct ui_out *uiout, { struct gdbarch *gdbarch; struct btrace_insn_iterator it; + VEC (disas_insn_t) *insns; + struct cleanup *cleanups; DEBUG ("itrace (0x%x): [%u; %u)", flags, btrace_insn_number (begin), btrace_insn_number (end)); + flags |= DISASSEMBLY_SPECULATIVE; + gdbarch = target_gdbarch (); + insns = NULL; + cleanups = make_cleanup (VEC_cleanup (disas_insn_t), &insns); for (it = *begin; btrace_insn_cmp (&it, end) != 0; btrace_insn_next (&it, 1)) { @@ -560,42 +566,34 @@ btrace_insn_history (struct ui_out *uiout, /* We have trace so we must have a configuration. */ gdb_assert (conf != NULL); + /* Print the instructions we collected, so far, then the error. + + This will result in two disjoint "asm_insns" lists with a + stand-alone error in-between. It's better than what we had + before but still not OK for MI users. */ + gdb_disassembly_vec (gdbarch, uiout, flags, insns); + btrace_ui_out_decode_error (uiout, it.function->errcode, conf->format); + + /* Start over. */ + VEC_free (disas_insn_t, insns); } else { - char prefix[4]; - - /* We may add a speculation prefix later. We use the same space - that is used for the pc prefix. */ - if ((flags & DISASSEMBLY_OMIT_PC) == 0) - strncpy (prefix, pc_prefix (insn->pc), 3); - else - { - prefix[0] = ' '; - prefix[1] = ' '; - prefix[2] = ' '; - } - prefix[3] = 0; + struct disas_insn *dinsn; - /* Print the instruction index. */ - ui_out_field_uint (uiout, "index", btrace_insn_number (&it)); - ui_out_text (uiout, "\t"); - - /* Indicate speculative execution by a leading '?'. */ - if ((insn->flags & BTRACE_INSN_FLAG_SPECULATIVE) != 0) - prefix[0] = '?'; - - /* Print the prefix; we tell gdb_disassembly below to omit it. */ - ui_out_field_fmt (uiout, "prefix", "%s", prefix); - - /* Disassembly with '/m' flag may not produce the expected result. - See PR gdb/11833. */ - gdb_disassembly (gdbarch, uiout, NULL, flags | DISASSEMBLY_OMIT_PC, - 1, insn->pc, insn->pc + 1); + dinsn = VEC_safe_push (disas_insn_t, insns, NULL); + dinsn->addr = insn->pc; + dinsn->number = btrace_insn_number (&it); + dinsn->is_speculative = (insn->flags & BTRACE_INSN_FLAG_SPECULATIVE) != 0; } } + + /* Print the instructions we collected. */ + gdb_disassembly_vec (gdbarch, uiout, flags, insns); + + do_cleanups (cleanups); } /* The to_insn_history method of target record-btrace. */ diff --git a/gdb/record.c b/gdb/record.c index 71ef973..c17b199 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -458,7 +458,7 @@ get_insn_history_modifiers (char **arg) switch (*args) { case 'm': - modifiers |= DISASSEMBLY_SOURCE_DEPRECATED; + modifiers |= DISASSEMBLY_SOURCE; modifiers |= DISASSEMBLY_FILENAME; break; case 'r': -- 1.8.3.1