From nobody Tue Dec 2 01:49:12 2025 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB71334D382 for ; Fri, 21 Nov 2025 09:54:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.165.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763718886; cv=none; b=Gqf95uYMTDIdeyCxdJ/EpicaJ8fFNHWVFc5PzVB3BfRLt/mwdS4HFCLxPFtGSisLq5YaaOENPES+ZZPP6N3T2JOrd01hjU5PEWwaG5CHJ0AYsgjxpyxX0z8qDhcDetCTu+xisZN96/ixTnOV17hK+ctKoRfE0Kflm7oJIyGvN+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763718886; c=relaxed/simple; bh=+r/2Hr+jrGYm50/IqRhI1RVGbgq/iE28DdKqzy4ujec=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m1q6UI46BHGwAYHUAvjBsZksjcdh7QRqz8KNTEhKx79xWDFoWspJnvTgT5WRcPxGAtVupvzdOwzsYuEc/Hznae8MGSvBzD3NP9bUHzzQ6Z+rXxnvwaZX2SJEytafdzD1rykiYYepfxHtVnePdw1hSyldkNpLfxxEaSimtVcvgLw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=lx5q02RN; arc=none smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="lx5q02RN" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5AL3WkBV021210; Fri, 21 Nov 2025 09:54:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=4puCA yG2mdzr3fE9NDstitoSNl84omIWbI3hFzgiGRk=; b=lx5q02RNpIDIiLqIJmJcg WMinJ3RiydMgqHtOzKYi3QnfqB9iBtWfFgBMOyC1pPFmXr2B0oiDdKDtJ2usmb02 fnCFKtA1yXh3tv6RNJUcIIiVmEGzLSdVruRuj3TguJ+1DLX+F6bxQ6X3th0jipuY EUk0kUfhTMjDbhkS/iGFjKLsHWVBUboI0hZrS//BDRYArMenMv9hO6zUtvx5bjvK kaDvrDXH/jXW2winVzMi2B2pz9R9yX91PR0qEvhiBNSLuDpjGyru4OGr7DyA9dHG RaLfz0Mb4NjvVQnhRRFFqWlnyOhOyvabUjd5DoP33fCImopDq+9p4Nv5MM/G7aEH Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4aej96atgh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Nov 2025 09:54:38 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 5AL7t9bR004348; Fri, 21 Nov 2025 09:54:37 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4aefyd4v1m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Nov 2025 09:54:37 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 5AL9rgV2021648; Fri, 21 Nov 2025 09:54:37 GMT Received: from laptop-dell-latitude7430.nl.oracle.com (dhcp-10-154-175-150.vpn.oracle.com [10.154.175.150]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4aefyd4ub2-30; Fri, 21 Nov 2025 09:54:36 +0000 From: Alexandre Chartre To: linux-kernel@vger.kernel.org, mingo@kernel.org, jpoimboe@kernel.org, peterz@infradead.org, david.laight.linux@gmail.com Cc: alexandre.chartre@oracle.com Subject: [PATCH v6 29/30] objtool: Add wide output for disassembly Date: Fri, 21 Nov 2025 10:53:39 +0100 Message-ID: <20251121095340.464045-30-alexandre.chartre@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20251121095340.464045-1-alexandre.chartre@oracle.com> References: <20251121095340.464045-1-alexandre.chartre@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-21_03,2025-11-20_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 mlxscore=0 bulkscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2510240000 definitions=main-2511210075 X-Authority-Analysis: v=2.4 cv=DYoaa/tW c=1 sm=1 tr=0 ts=692036de cx=c_pps a=XiAAW1AwiKB2Y8Wsi+sD2Q==:117 a=XiAAW1AwiKB2Y8Wsi+sD2Q==:17 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=L9MrgM4xBs1gnZH-f1IA:9 X-Proofpoint-GUID: aQuq9Cdv0swYADPPwX6FiXt8lsMchSup X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTE1MDAzMSBTYWx0ZWRfX1uzC6wuBe++y 5DINdzfOyWuQbj+3Zdc2/kpgsrM4ojwnTnpnJocwN9qgNU+AaEU5tVNJB5EU82ctdnVgIPjqItc 1wTa5mrizpK5jYFjhxPvL4kDKmHR+p8XyiyoQDvSap4CbfwK+2bpbyasGA5nMHJJudRdRjJof3M 0KEGnDfObFyagCp1nDc6PjBcFZcXrZcwiJrS9WWO3mJBMvle3bcSG/3nzVA4EX+TlFizvtozpk6 8VE/rW9QoeZamp7A+cXFXcLZWa/g/0ziWHjp0jwkOUxSbQdWxM2cRHba55jgQ6xVC4B4bQRMxad 9EKpG70C+EmbQArH40481DGg4bT5zxJkhWiyqwQqcaezdW99I6u9eNVjQf/MLFf1Le1umxGRPhs gOLBjGyN3uzLNFvJqX8mw7XrD6CTeQ== X-Proofpoint-ORIG-GUID: aQuq9Cdv0swYADPPwX6FiXt8lsMchSup Content-Type: text/plain; charset="utf-8" Add the --wide option to provide a wide output when disassembling. With this option, the disassembly of alternatives is displayed side-by-side instead of one above the other. Signed-off-by: Alexandre Chartre --- tools/objtool/builtin-check.c | 1 + tools/objtool/disas.c | 95 ++++++++++++++++++++++++- tools/objtool/include/objtool/builtin.h | 1 + 3 files changed, 96 insertions(+), 1 deletion(-) diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c index a0371312fe55a..b780df5137152 100644 --- a/tools/objtool/builtin-check.c +++ b/tools/objtool/builtin-check.c @@ -107,6 +107,7 @@ static const struct option check_options[] =3D { OPT_STRING(0, "trace", &opts.trace, "func", "trace function validation"= ), OPT_BOOLEAN('v', "verbose", &opts.verbose, "verbose warnings"), OPT_BOOLEAN(0, "werror", &opts.werror, "return error on warnings"), + OPT_BOOLEAN(0, "wide", &opts.wide, "wide output"), =20 OPT_END(), }; diff --git a/tools/objtool/disas.c b/tools/objtool/disas.c index a4f905eac4e63..f04bc14bef39e 100644 --- a/tools/objtool/disas.c +++ b/tools/objtool/disas.c @@ -856,6 +856,95 @@ static int disas_alt_default(struct disas_context *dct= x, struct disas_alt *dalt) return 1; } =20 +/* + * For each alternative, if there is an instruction at the specified + * offset then print this instruction, otherwise print a blank entry. + * The offset is an offset from the start of the alternative. + * + * Return the offset for the next instructions to print, or -1 if all + * instructions have been printed. + */ +static int disas_alt_print_insn(struct disas_alt *dalts, int alt_count, + int insn_count, int offset) +{ + struct disas_alt *dalt; + int offset_next; + char *str; + int i, j; + + offset_next =3D -1; + + for (i =3D 0; i < alt_count; i++) { + dalt =3D &dalts[i]; + j =3D dalt->insn_idx; + if (j =3D=3D -1) { + printf("| %-*s ", dalt->width, ""); + continue; + } + + if (dalt->insn[j].offset =3D=3D offset) { + str =3D dalt->insn[j].str; + printf("| %-*s ", dalt->width, str ?: ""); + if (++j < insn_count) { + dalt->insn_idx =3D j; + } else { + dalt->insn_idx =3D -1; + continue; + } + } else { + printf("| %-*s ", dalt->width, ""); + } + + if (dalt->insn[j].offset > 0 && + (offset_next =3D=3D -1 || + (dalt->insn[j].offset < offset_next))) + offset_next =3D dalt->insn[j].offset; + } + printf("\n"); + + return offset_next; +} + +/* + * Print all alternatives side-by-side. + */ +static void disas_alt_print_wide(char *alt_name, struct disas_alt *dalts, = int alt_count, + int insn_count) +{ + struct instruction *orig_insn; + int offset_next; + int offset; + int i; + + orig_insn =3D dalts[0].orig_insn; + + /* + * Print an header with the name of each alternative. + */ + disas_print_info(stdout, orig_insn, -2, NULL); + + if (strlen(alt_name) > dalts[0].width) + dalts[0].width =3D strlen(alt_name); + printf("| %-*s ", dalts[0].width, alt_name); + + for (i =3D 1; i < alt_count; i++) + printf("| %-*s ", dalts[i].width, dalts[i].name); + + printf("\n"); + + /* + * Print instructions for each alternative. + */ + offset_next =3D 0; + do { + offset =3D offset_next; + disas_print(stdout, orig_insn->sec, orig_insn->offset + offset, + -2, NULL); + offset_next =3D disas_alt_print_insn(dalts, alt_count, insn_count, + offset); + } while (offset_next > offset); +} + /* * Print all alternatives one above the other. */ @@ -993,7 +1082,11 @@ static void *disas_alt(struct disas_context *dctx, /* * Print default and non-default alternatives. */ - disas_alt_print_compact(alt_name, dalts, alt_count, insn_count); + + if (opts.wide) + disas_alt_print_wide(alt_name, dalts, alt_count, insn_count); + else + disas_alt_print_compact(alt_name, dalts, alt_count, insn_count); =20 last_insn =3D orig_insn->alt_group ? orig_insn->alt_group->last_insn : orig_insn; diff --git a/tools/objtool/include/objtool/builtin.h b/tools/objtool/includ= e/objtool/builtin.h index e3af664864f30..b9e229ed4dc05 100644 --- a/tools/objtool/include/objtool/builtin.h +++ b/tools/objtool/include/objtool/builtin.h @@ -45,6 +45,7 @@ struct opts { const char *trace; bool verbose; bool werror; + bool wide; }; =20 extern struct opts opts; --=20 2.43.5