From patchwork Fri Sep 27 18:42:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 98079 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 14EE7385DDCF for ; Fri, 27 Sep 2024 18:42:50 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by sourceware.org (Postfix) with ESMTPS id BD8983858D39 for ; Fri, 27 Sep 2024 18:42:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BD8983858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nefkom.net ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BD8983858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.18.0.10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727462545; cv=none; b=NUTxAHuhCVaL2o7HDBVRsY2K8h40f+PRFUWyrF7c+SstzCKw10guXYlLkZ0CrcQPfTMQXAwU3pqHpUuUyb7U38ABkfAh3OYXNUKzVYu/CYu3cT5eklNfBzkVHTYjoKQjxfQEzRv/0c2tGJnePa+/dzXggikVOPHmqz++WsIz6xA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727462545; c=relaxed/simple; bh=orr+ODMKixhYtRFGQMfR4kEgMRj7X8hlyFEOQqb2xaw=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=pQ6HaomrLp8ukcggdoAUu3lQPwLcDz6+W06u/mrQwqkHuWNLEo800Go+CFXKyJuk7q4ekD4ms3hgvD9/FxONVFH+M0pyKvaU7xU5T0k5WO0uYi42HsYJRfIrz/OlbpN2jvv0XQ5hUyKhVyb/AbQna1nzwkBiusQP/vs7gMH5X48= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4XFfTV5Pd5z1sCld for ; Fri, 27 Sep 2024 20:42:22 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 4XFfTV2RYYz1qqlW for ; Fri, 27 Sep 2024 20:42:22 +0200 (CEST) X-Virus-Scanned: amavis at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavis, port 10024) with ESMTP id SvEuWQahUjzd for ; Fri, 27 Sep 2024 20:42:21 +0200 (CEST) X-Auth-Info: T4d2JqjDSQzjgBseOHcqFbMPAkt4rVvzUiGzndBOIEJ+N2x9bRTxBjusCWUxRWSB Received: from igel.home (aftr-62-216-205-220.dynamic.mnet-online.de [62.216.205.220]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA for ; Fri, 27 Sep 2024 20:42:21 +0200 (CEST) Received: by igel.home (Postfix, from userid 1000) id 59F312C1EC5; Fri, 27 Sep 2024 20:42:21 +0200 (CEST) From: Andreas Schwab To: binutils@sourceware.org Subject: [PATCH] m68k: Support for jump visualization in disassembly X-Yow: A GRAM?? A BRAM... A GROOM... A BROOM... Oh, Yeh!! Wash the ROOM!! Date: Fri, 27 Sep 2024 20:42:21 +0200 Message-ID: <87h6a1ndki.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org opcodes/ * m68k-dis.c (m68k_opcode_to_insn_type): Define. (match_insn_m68k): Call it to set insn_type. (print_insn_arg) [case 'B']: Set branch target address. (print_insn_m68k): Set insn_info_valid. --- opcodes/m68k-dis.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/opcodes/m68k-dis.c b/opcodes/m68k-dis.c index bc2f82031c8..7e9b087951e 100644 --- a/opcodes/m68k-dis.c +++ b/opcodes/m68k-dis.c @@ -991,6 +991,8 @@ print_insn_arg (const char *d, else return PRINT_INSN_ARG_INVALID_OP_TABLE; + info->target = addr + disp; + (*info->print_address_func) (addr + disp, info); break; @@ -1442,6 +1444,27 @@ print_insn_arg (const char *d, return p - p0; } +/* Return the insn type determined from the opcode information. */ + +static enum dis_insn_type +m68k_opcode_to_insn_type (const struct m68k_opcode *opc) +{ + /* All branches have an operand in 'B' format (the 'B' place only comes + with the 'B' format). */ + if (strchr (opc->args, 'B') == NULL) + return dis_nonbranch; + + /* Most branches are conditional branches, detect the ones that aren't + from the opcode name. */ + if (strncmp (opc->name, "bra", 3) == 0) + return dis_branch; + + if (strncmp (opc->name, "bsr", 3) == 0) + return dis_jsr; + + return dis_condbranch; +} + /* Try to match the current instruction to best and if so, return the number of bytes consumed from the instruction stream, else zero. Return -1 on memory error. */ @@ -1573,6 +1596,7 @@ match_insn_m68k (bfd_vma memaddr, p = save_p; info->fprintf_styled_func = save_printer; info->print_address_func = save_print_address; + info->insn_type = m68k_opcode_to_insn_type (best); d = args; @@ -1730,6 +1754,7 @@ print_insn_m68k (bfd_vma memaddr, disassemble_info *info) bfd_byte *buffer = priv.the_buffer; + info->insn_info_valid = 1; info->private_data = & priv; /* Tell objdump to use two bytes per chunk and six bytes per line for displaying raw data. */ @@ -1761,6 +1786,8 @@ print_insn_m68k (bfd_vma memaddr, disassemble_info *info) info->fprintf_styled_func (info->stream, dis_style_text, " "); info->fprintf_styled_func (info->stream, dis_style_immediate, "0x%04x", (buffer[0] << 8) + buffer[1]); + + info->insn_type = dis_noninsn; } return val ? val : 2;