From nobody Wed Oct 29 11:33:34 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1525563882270790.3864465321876; Sat, 5 May 2018 16:44:42 -0700 (PDT) Received: from localhost ([::1]:40298 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fF6qz-0001Ei-Vz for importer@patchew.org; Sat, 05 May 2018 19:44:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fF6jo-0003x2-Mw for qemu-devel@nongnu.org; Sat, 05 May 2018 19:37:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fF6jn-0003eC-OF for qemu-devel@nongnu.org; Sat, 05 May 2018 19:37:12 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:35777) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fF6jn-0003dd-Ht for qemu-devel@nongnu.org; Sat, 05 May 2018 19:37:11 -0400 Received: by mail-pf0-x242.google.com with SMTP id x9so931662pfm.2 for ; Sat, 05 May 2018 16:37:11 -0700 (PDT) Received: from localhost.localdomain (122-58-167-38-fibre.bb.spark.co.nz. [122.58.167.38]) by smtp.gmail.com with ESMTPSA id x8sm47297094pfa.173.2018.05.05.16.37.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 05 May 2018 16:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o4u1Mx5dnZ0Apg6CJjtZuFr4mVKeQJvJ0KHDvX8wHGI=; b=O0JVEBd6E4SJmLiJCTusqhXAXx5wqKWo50gkIAWEU/KlxUY4l+z9YWG0ezNTOHF/BM +YZoqirE1p8O86CULi0wzjUlfKSkLaIIsPhUMQwXWn53gocATPgOniw607IZ3zd6FQkX AbvH/mBqd4fmtAZm6o78wHIvkVa7VGG39eyxcjhfYzNpY/C7xZFuM6jo9emLza+txPam XA24y74iRbFdim+151lq+GdO6Cq3ljwEmip6eXBgwr/ABKgyoWGlimaiD4Rj5hed/9zu +TdQIerT9RaHjSV4fuRQDLlttlAsUalXELFxV5KBq3PYfdVgHv1KMa2DPz/ThlxbGiNF CKfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o4u1Mx5dnZ0Apg6CJjtZuFr4mVKeQJvJ0KHDvX8wHGI=; b=NFambce0GK3/Rwobzm+P/8d9LZvs5s1HNw0ANGVwbUZLFMg5ST6YeX3iag+oj8fXOp D0VRzn6/eq7dxsiN8+lFohsknsvDMZ873hViE7wwZ4sXHzBChfhm+eZjzSgvoAf+SFOt ZTZn9ZYObkAwOJK70dsoUHxx3TB1mJajIj3xJNP/VBn32E37AJU31R1S8IerU9aXuxK7 eD5zYwnvnw+beNFld3akIVdd2LunWyIN1tVMN/fcoRFlwNjVHjugz0lqEsETCuCc5BWR QTFuswVIZNbMI2RFKAcWAZLbodET+mBOgwP9tnpJG8IEr45fID1Q2kVU2TnlyqSk9EdZ 2o6w== X-Gm-Message-State: ALQs6tB/M+UIqkqdJKWtbCxZFWfjBS2mtNkxvLVuc7LUAYEMfAJEUyDW MqRQ0QP95Ks6ZNVfhxr2/cMR0/NuiRM= X-Google-Smtp-Source: AB8JxZrBa1fWJCL2Pu9BHijJTo3m8Oypk9IMcWL1SKbt4cMwxpAna6cWOxwfoe+SdriDO0uqGWzkbQ== X-Received: by 2002:a63:b642:: with SMTP id v2-v6mr26452058pgt.158.1525563430572; Sat, 05 May 2018 16:37:10 -0700 (PDT) From: Michael Clark To: qemu-devel@nongnu.org Date: Sun, 6 May 2018 11:35:11 +1200 Message-Id: <1525563325-62963-7-git-send-email-mjc@sifive.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1525563325-62963-1-git-send-email-mjc@sifive.com> References: <1525563325-62963-1-git-send-email-mjc@sifive.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PULL 06/20] RISC-V: Include instruction hex in disassembly X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: patches@groups.riscv.org, Michael Clark , Palmer Dabbelt , Sagar Karandikar , Bastian Koppelmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 This was added to help debug issues using -d in_asm. It is useful to see the instruction bytes, as one can detect if one is trying to execute ASCII or device-tree magic. Cc: Sagar Karandikar Cc: Bastian Koppelmann Signed-off-by: Michael Clark Signed-off-by: Palmer Dabbelt Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis --- disas/riscv.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/disas/riscv.c b/disas/riscv.c index 74ad16eacdd3..2cecf0d8558d 100644 --- a/disas/riscv.c +++ b/disas/riscv.c @@ -2769,25 +2769,6 @@ static void format_inst(char *buf, size_t buflen, si= ze_t tab, rv_decode *dec) char tmp[64]; const char *fmt; =20 - if (dec->op =3D=3D rv_op_illegal) { - size_t len =3D inst_length(dec->inst); - switch (len) { - case 2: - snprintf(buf, buflen, "(0x%04" PRIx64 ")", dec->inst); - break; - case 4: - snprintf(buf, buflen, "(0x%08" PRIx64 ")", dec->inst); - break; - case 6: - snprintf(buf, buflen, "(0x%012" PRIx64 ")", dec->inst); - break; - default: - snprintf(buf, buflen, "(0x%016" PRIx64 ")", dec->inst); - break; - } - return; - } - fmt =3D opcode_data[dec->op].format; while (*fmt) { switch (*fmt) { @@ -3004,6 +2985,11 @@ disasm_inst(char *buf, size_t buflen, rv_isa isa, ui= nt64_t pc, rv_inst inst) format_inst(buf, buflen, 16, &dec); } =20 +#define INST_FMT_2 "%04" PRIx64 " " +#define INST_FMT_4 "%08" PRIx64 " " +#define INST_FMT_6 "%012" PRIx64 " " +#define INST_FMT_8 "%016" PRIx64 " " + static int print_insn_riscv(bfd_vma memaddr, struct disassemble_info *info, rv_isa is= a) { @@ -3031,6 +3017,21 @@ print_insn_riscv(bfd_vma memaddr, struct disassemble= _info *info, rv_isa isa) } } =20 + switch (len) { + case 2: + (*info->fprintf_func)(info->stream, INST_FMT_2, inst); + break; + case 4: + (*info->fprintf_func)(info->stream, INST_FMT_4, inst); + break; + case 6: + (*info->fprintf_func)(info->stream, INST_FMT_6, inst); + break; + default: + (*info->fprintf_func)(info->stream, INST_FMT_8, inst); + break; + } + disasm_inst(buf, sizeof(buf), isa, memaddr, inst); (*info->fprintf_func)(info->stream, "%s", buf); =20 --=20 2.7.0