Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp393650rdb; Tue, 16 Jan 2024 03:52:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGV4n2FDJs14EmtiDPAitK78clLVB8ufFi4jT1ALz1RYzQ8wATdt4dzdFR1ufnzxItNZXW0 X-Received: by 2002:a17:902:dac3:b0:1d4:55e0:bd0e with SMTP id q3-20020a170902dac300b001d455e0bd0emr4141710plx.18.1705405962978; Tue, 16 Jan 2024 03:52:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705405962; cv=none; d=google.com; s=arc-20160816; b=KnQMkbuU3W4KKEXGwtZbkAYrGrw9dAK0A1YAkmWzZORViaiQ0xSsdHWBDEx8AabhIS NU8TAgrjYz5AlAwOmeiBjPpMR5wVqQwdJp3VrPThJRjvs6P275xmLRVUWuPLOxztXHBV 33zHo2qJ6afGO4rScsUUXD77H7iI2OMPDkBA5OgCqefLl9Wk+rFnK9FUDW9+q+FF5sZn jsWkA2RmVbiOFP0PFu6X2TKFSNonHMxZJobeYc7aBag22SFJ5rnbum5XOFU37xD03NZO Aiteaic6hPxKHHb4p7L6PNzl93r6FTwtdAswhYVKNmtU7OKgvMdnYJCkE/KQktkaCIDx Kmhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=9fceR00Nf+RgGnHLr/m9Q3z9HLtFTHUBE01exFEmNUU=; fh=wjLkt+hbOkIreNMlyAPJ/U4E0ReWqRTqN/ROQ2ik91w=; b=HBCa39JCV4f/qRQXoxsTCWpiRyhaQGkGuo6YcgWYbXWaqR1CptnffJGNdpkjhr/fR2 lsg3iSTlfVNvQaWHyIj5g2TmWNCFFFJB6g+rAETMPFeu4Kd1+XaQcIsFB3jTevLFOR+T NCE03g/hsI2TYVcZJvIDo0GLyOGqhW6i+X/sEglLwEhPTmFl5MewCUlhhnw11ZR37Ox5 fZ9FNZvHnA/Woi4hYGZ1DU2vrdCyLehtVEfFv8HbVDVRMVQEF/YZ191JB29O3qsTJArq VdqQ2AzIRb2/qwsxc6iYVLv6AzCUo/jxB5JkXp9ubtSTn87a6a6MBmhRVwMdDuGnKVxk BmnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-27349-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27349-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q17-20020a170902789100b001d56d45ebbesi10940066pll.611.2024.01.16.03.52.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 03:52:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27349-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-27349-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27349-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 591AB28560F for ; Tue, 16 Jan 2024 11:52:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A34BB1B95E; Tue, 16 Jan 2024 11:52:36 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 1881A1B94D; Tue, 16 Jan 2024 11:52:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TDn391dhMz1xmFr; Tue, 16 Jan 2024 19:34:13 +0800 (CST) Received: from kwepemd100002.china.huawei.com (unknown [7.221.188.184]) by mail.maildlp.com (Postfix) with ESMTPS id 11B1A1A016B; Tue, 16 Jan 2024 19:34:57 +0800 (CST) Received: from M910t.huawei.com (10.110.54.157) by kwepemd100002.china.huawei.com (7.221.188.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.28; Tue, 16 Jan 2024 19:34:55 +0800 From: Changbin Du To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo CC: Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , , , Changbin Du Subject: [PATCH 0/3] perf: script: Intro capstone disasm engine to show instruction trace Date: Tue, 16 Jan 2024 19:34:34 +0800 Message-ID: <20240116113437.1507537-1-changbin.du@huawei.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemd100002.china.huawei.com (7.221.188.184) This series introduces capstone disassembler engine to print instructions of Intel PT trace, which was printed via the XED tool. The advantages compared to XED tool: * Support arm, arm64, x86-32, x86_64 (more could be supported), xed only for x86_64. * More friendly to read. Immediate address operands are shown as symbol+offs. Before: $ sudo perf record --event intel_pt//u -- ls $ sudo perf script --insn-trace perf 17423 [000] 423271.557970005: 7f2d95f16217 __GI___ioctl+0x7 (/lib/x86_64-linux-gnu/libc-2.27.so) insn: 48 3d 01 f0 ff ff perf 17423 [000] 423271.557970005: 7f2d95f1621d __GI___ioctl+0xd (/lib/x86_64-linux-gnu/libc-2.27.so) insn: 73 01 perf 17423 [000] 423271.557970338: 7f2d95f1621f __GI___ioctl+0xf (/lib/x86_64-linux-gnu/libc-2.27.so) insn: c3 perf 17423 [000] 423271.557970338: 5593ad3346d7 perf_evsel__enable_cpu+0x97 (/work/linux/tools/perf/perf) insn: 85 c0 perf 17423 [000] 423271.557970338: 5593ad3346d9 perf_evsel__enable_cpu+0x99 (/work/linux/tools/perf/perf) insn: 75 12 perf 17423 [000] 423271.557970338: 5593ad3346db perf_evsel__enable_cpu+0x9b (/work/linux/tools/perf/perf) insn: 49 8b 84 24 a8 00 00 00 perf 17423 [000] 423271.557970338: 5593ad3346e3 perf_evsel__enable_cpu+0xa3 (/work/linux/tools/perf/perf) insn: 48 8b 50 20 After: $ sudo perf script --insn-trace perf 17423 [000] 423271.557970005: 7f2d95f16217 __GI___ioctl+0x7 (/lib/x86_64-linux-gnu/libc-2.27.so) insn: cmpq $-0xfff, %rax perf 17423 [000] 423271.557970005: 7f2d95f1621d __GI___ioctl+0xd (/lib/x86_64-linux-gnu/libc-2.27.so) insn: jae __GI___ioctl+0x10 perf 17423 [000] 423271.557970338: 7f2d95f1621f __GI___ioctl+0xf (/lib/x86_64-linux-gnu/libc-2.27.so) insn: retq perf 17423 [000] 423271.557970338: 5593ad3346d7 perf_evsel__enable_cpu+0x97 (/work/linux/tools/perf/perf) insn: testl %eax, %eax perf 17423 [000] 423271.557970338: 5593ad3346d9 perf_evsel__enable_cpu+0x99 (/work/linux/tools/perf/perf) insn: jne perf_evsel__enable_cpu+0xad perf 17423 [000] 423271.557970338: 5593ad3346db perf_evsel__enable_cpu+0x9b (/work/linux/tools/perf/perf) insn: movq 0xa8(%r12), %rax perf 17423 [000] 423271.557970338: 5593ad3346e3 perf_evsel__enable_cpu+0xa3 (/work/linux/tools/perf/perf) insn: movq 0x20(%rax), %rdx perf 17423 [000] 423271.557970338: 5593ad3346e7 perf_evsel__enable_cpu+0xa7 (/work/linux/tools/perf/perf) insn: cmpl %edx, %ebx perf 17423 [000] 423271.557970338: 5593ad3346e9 perf_evsel__enable_cpu+0xa9 (/work/linux/tools/perf/perf) insn: jl perf_evsel__enable_cpu+0x60 perf 17423 [000] 423271.557970338: 5593ad3346eb perf_evsel__enable_cpu+0xab (/work/linux/tools/perf/perf) insn: xorl %eax, %eax Changbin Du (3): perf: build: introduce the libcapstone perf: script: use capstone disasm engine to show assembly instructions perf: script: deprecate the '--xed' option tools/build/Makefile.feature | 2 + tools/build/feature/Makefile | 4 + tools/build/feature/test-all.c | 4 + tools/build/feature/test-libcapstone.c | 11 ++ tools/perf/Documentation/build-xed.txt | 19 ---- tools/perf/Documentation/perf-intel-pt.txt | 17 +-- tools/perf/Documentation/perf-script.txt | 5 +- tools/perf/Documentation/tips.txt | 2 +- tools/perf/Makefile.config | 21 ++++ tools/perf/Makefile.perf | 3 + tools/perf/builtin-script.c | 15 +-- tools/perf/ui/browsers/res_sample.c | 2 +- tools/perf/ui/browsers/scripts.c | 4 +- tools/perf/util/Build | 1 + tools/perf/util/print_insn.c | 118 +++++++++++++++++++++ tools/perf/util/print_insn.h | 14 +++ 16 files changed, 194 insertions(+), 48 deletions(-) create mode 100644 tools/build/feature/test-libcapstone.c delete mode 100644 tools/perf/Documentation/build-xed.txt create mode 100644 tools/perf/util/print_insn.c create mode 100644 tools/perf/util/print_insn.h -- 2.25.1