Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5561471pxu; Tue, 22 Dec 2020 22:41:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+KasQhgYu3w87J1kscOI0FlsMl+0tG/uBBRYoZrA/KBUXvRcdj6HMxDTOYMLt6WNX74rL X-Received: by 2002:a17:906:3c04:: with SMTP id h4mr22341218ejg.220.1608705719419; Tue, 22 Dec 2020 22:41:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608705719; cv=none; d=google.com; s=arc-20160816; b=ZBAPmR+m8kd5JdyIDA2UlwKC7X0VpD/oAmAY4gWmE8zdZlLWP8iXWX3DD74xYIu1Z8 6pGMTBif3/aaxJckA7AC+/8j7KAdeOMO6grEy3/gsESug3vupMpbM3eGNcDXkVLHx8Jp paA9XD3X3z4ejHMChRzp5s+KuIS6fFBp93ClL1YCe7VCHTLR36yQ2CE7GdqhsUZpZDW4 mhfQCRlsJleWHiGYZgpBvne3XTvm8qti3eJ2nwudscCHwVc5FJV+vYsKJvF3t+dIcNHq FUHfwtzsy1gocGo7IbDxinDUv1rSX/I+McfG9q8kBShqIhoPZOyWP2qfm6QNoE+1C3pn zGWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=J6uJ+kErWklNE/7gO57BMrhqrOWmHLQYq2mwzGxfa8Y=; b=CetkY/Zaegzzli21ClMwv+E7eJJHPDR/vvV6wb/IQbSaWDhrDWTSC/6ZBG0dPrgdyP ref6rUelvvXJz5PQdji7T6340u6T22f0BCW0Cviphg+d8a7iWhmRJydIqA+pr6pADiri s4Gua9C6/N4PbpNReiJVxkn0onZ9ChYXSAlRApVwokN5b3Nvqf/QguCRy2OtJ5u7Q6cx RqYHdtO2i11qJgko9yapDKsosKmUghkhX6FJVVbv4CbEEHJrVCrqL8RhlKqqTFTPtkOX +tKcy2TEl4wAnOs8gnUUDpS7Aqps0OZ3TPuaeIxrBtYBGvzm4/lx8Lsl7kBs88wbudfk d+mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PNLk4qHQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h4si3035784edf.490.2020.12.22.22.41.37; Tue, 22 Dec 2020 22:41:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PNLk4qHQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727377AbgLWGkg (ORCPT + 99 others); Wed, 23 Dec 2020 01:40:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726390AbgLWGkf (ORCPT ); Wed, 23 Dec 2020 01:40:35 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E17CC0613D6 for ; Tue, 22 Dec 2020 22:39:55 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id w1so653652pjc.0 for ; Tue, 22 Dec 2020 22:39:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=J6uJ+kErWklNE/7gO57BMrhqrOWmHLQYq2mwzGxfa8Y=; b=PNLk4qHQtyvRwY/OmJ+vez7yBo96Xg4JAC2HxGo9NwlQ7I7yJ1JvpiPKQ4IERJQYTq FEKC9ejA3T56V0ynXpcGwnPjQoxBZMgP8OOFS709tcheaKJLa2bkXGmJetgp9wrrsXqA AbyoF8CEs2hP33xV7O4Ui0KkSIVPhp88FfOgHPm61IEonKSw5FmV5+WoPaebtXlHUoW5 3DUoV7keG4zFcuCwqy76gtOE13KzxP02eCX/Bf8KZ7uQQ00m3DGeqFNuXmHdWL1pmMmr NyMiQV9L2VtAc7kfQRBwHHUVZ6ATalnRBM+GwL2Fz6pbqOpd4I7e0EPvIKRyKZwYlMMl bTnQ== 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; bh=J6uJ+kErWklNE/7gO57BMrhqrOWmHLQYq2mwzGxfa8Y=; b=TDvuvn5MsrhO1+Rf4ezy6W/mEqErd9z6E3sq5PqEX+pbpqhwfQUpJjphjVWWoeLNIz CoQEP7FSbS1pIcEsulBFMtdJJY1ZjrnpdClIy3I70xuheJ5PJrbUHY8rXBPQjYT6lpr1 gEh6EC8yp0ZEGcuRHK152m+tsU2Fnduh+gEE8GlLTjFrNN+Is8h/MPQKrWYLLEtlcZ69 Y9/5ifRXApLDf9fZhm2Vo6EhZ++vW/yDcdiPIH6yGqFmasDcrnMaGO0mFRXbK6vyF0UI CJRlmdoaLLlG8OFw4zbQkLE0JGWXyC1fpDri5kIyqZ/mmC5LG8ErGxfpmWGiHLgacz+x 8G5w== X-Gm-Message-State: AOAM532n9rNGeLNkupnU+wC3lpXAsDHEs2JJcC5ZqSluVfGUY5AbPfiu 4CtXZE4rhSUvvLAi7uGEfBVQdF3PDLbXvJxS X-Received: by 2002:a17:90b:1213:: with SMTP id gl19mr25581931pjb.232.1608705594570; Tue, 22 Dec 2020 22:39:54 -0800 (PST) Received: from localhost ([45.137.216.7]) by smtp.gmail.com with ESMTPSA id n4sm22242926pfu.150.2020.12.22.22.39.53 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Dec 2020 22:39:54 -0800 (PST) From: Leo Yan To: Arnaldo Carvalho de Melo , Will Deacon , John Garry , Mathieu Poirier , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Alexandre Truong , Masami Hiramatsu , He Zhe , Thomas Richter , Sumanth Korikkar , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v1 1/2] perf probe: Fixup Arm64 SDT arguments Date: Wed, 23 Dec 2020 14:39:04 +0800 Message-Id: <20201223063905.25784-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201223063905.25784-1-leo.yan@linaro.org> References: <20201223063905.25784-1-leo.yan@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Arm64 ELF section '.note.stapsdt' uses string format "-4@[sp, NUM]" if the probe is to access data in stack, e.g. below is an example for dumping Arm64 ELF file and shows the argument format: Arguments: -4@[sp, 12] -4@[sp, 8] -4@[sp, 4] Comparing against other archs' argument format, Arm64's argument introduces an extra space character in the middle of square brackets, due to argv_split() uses space as splitter, the argument is wrongly divided into two items. To support Arm64 SDT, this patch fixes up for this case, if any item contains sub string "[sp", concatenates the two continuous items. And adds the detailed explaination in comment. Signed-off-by: Leo Yan --- tools/perf/util/probe-file.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 064b63a6a3f3..60878c859e60 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c @@ -794,6 +794,8 @@ static char *synthesize_sdt_probe_command(struct sdt_note *note, char *ret = NULL, **args; int i, args_count, err; unsigned long long ref_ctr_offset; + char *arg; + int arg_idx = 0; if (strbuf_init(&buf, 32) < 0) return NULL; @@ -815,8 +817,34 @@ static char *synthesize_sdt_probe_command(struct sdt_note *note, if (note->args) { args = argv_split(note->args, &args_count); - for (i = 0; i < args_count; ++i) { - if (synthesize_sdt_probe_arg(&buf, i, args[i]) < 0) + for (i = 0; i < args_count; ) { + /* + * FIXUP: Arm64 ELF section '.note.stapsdt' uses string + * format "-4@[sp, NUM]" if a probe is to access data in + * the stack, e.g. below is an example for the SDT + * Arguments: + * + * Arguments: -4@[sp, 12] -4@[sp, 8] -4@[sp, 4] + * + * Since the string introduces an extra space character + * in the middle of square brackets, the argument is + * divided into two items. Fixup for this case, if an + * item contains sub string "[sp,", need to concatenate + * the two items. + */ + if (strstr(args[i], "[sp,") && (i+1) < args_count) { + arg = strcat(args[i], args[i+1]); + i += 2; + } else { + arg = strdup(args[i]); + i += 1; + } + + err = synthesize_sdt_probe_arg(&buf, arg_idx, arg); + free(arg); + arg_idx++; + + if (err < 0) goto error; } } -- 2.17.1