Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp226851lqp; Thu, 4 Apr 2024 11:17:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVg/T2gYVGzvVjCzhkVUmSNj6o3p6VSJDp9vBqVqEHT/DYedgEk3c+mVjkHQkHnYhuAjawzwax3aUTYnW0o0wY0N0eJPp0W7ddQJ950WQ== X-Google-Smtp-Source: AGHT+IEI8V1qc8Mt1SsIY35swwDSy/19gTE/whxRGU7pIJumW0+1SmLfaGoKo4A6d0IKGFcUjoH5 X-Received: by 2002:a05:6a00:4b0b:b0:6ec:df4e:96f2 with SMTP id kq11-20020a056a004b0b00b006ecdf4e96f2mr3338837pfb.12.1712254642060; Thu, 04 Apr 2024 11:17:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712254642; cv=pass; d=google.com; s=arc-20160816; b=AnS1+BQUL4Z728fWJDGPE7TxMZA6eqPlmVHqP1GlIraXax8uffYpX49jxY+gh5Wonq 3BBARyoKJakOu7gQeH8TzV0KWbTKMDdiw1fA3wap52q8Cys8GUWGy2Rxrx12+aBgMvzr ZNguvp2poredecRHbE5CYJNHBnWAth84u/dwc4AFP8eoXihgcbzvIylgc8KUqqRAROJp 5Cw6DXmHRslwOFadBzWZPghgC42Crr0HIo3caCigix0GhSH5I55ts11KvTVpNvDE7fa5 1bifRRNdmoj3aE5f2rnOyXmXcESE+nhWL7r6XiV8WDtbR+qqtCQDBP9YE8sy0NSZP2Z0 GeVg== ARC-Message-Signature: i=2; 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=x2T30z9Wzb15YnhzeTVrkO+79NfSASUVNkQJ3KBRWKg=; fh=fHhbvXgCev/wpffLVpfaAi8pPyv7hrTyhVPgsZ7HNrs=; b=wjfOvgAXDQOIk96Vnq9BxJuu9ThM9Lp4IAdBxGtxqF1FEFtU6ei4LplaYKPIrXD2N+ aPg/fxCSwMW2VsKUSaFDx+echVymz2KNk1A5Nm/quD34NSmSKP0oI13DuwYg5x9ZB17K Y1XtCRmhOzDucXgRJMFTT1/Vrk/deUqULbve9rJ/X0GNlm/Mg9DnlgaRRZfCZN0AQRtQ YHZz8LUyA/hf0fR0VYgMygpMwizwbBgDPoeugEzW5AyszjIPZ9EoBR/ssv4iLKPUy5QQ Z7h9lfLBfTwmWEeM/rcQ2s2ULuS95Za79DG6SMmOgREyUcmi3YTjcNP2HYlTJOyawKP5 lEjg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IapbwqgI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-131919-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131919-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d22-20020a634f16000000b005d8c50790d7si15250782pgb.447.2024.04.04.11.17.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 11:17:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131919-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IapbwqgI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-131919-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131919-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 4B52EB26F05 for ; Thu, 4 Apr 2024 17:57:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A0087130A53; Thu, 4 Apr 2024 17:57:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IapbwqgI" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C037512F5BC; Thu, 4 Apr 2024 17:57:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712253439; cv=none; b=nxNJ9oFzgE0pgKYJuiqS5Y/HaBihE6AcTSRSdVYUAaUsYpTcAyFuNF3BoeYXjtFRjMxPal359OeFZLJ8jYn1B656ABFlpizVl9uY0Y9HcLRt4aNGATaY6B9lfYeAak1VDVTUr0CTZMGwnk51vDuM8TG7Uq2oWWNXjA/6vPMa/gg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712253439; c=relaxed/simple; bh=GpzHHadLf3YosmcJ25cQdas5aywqFNxjfnYY+ULKu6U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pq2o6m3vGRjflWdjxiBLUSw2rVlw3oPImnAcweTj/B8Mw12Jg9j+FXfJMBIr3ILFJCL4K562eRKr/jK6l+xgJ/oUK8ZQCYUZFw6KKAqp+jlpRWJMJKMtyMfsgaDHucF4cjggkibKSOyvvcQmGDKeIwQ4JTFSPIXKAw0RhGE7dRc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IapbwqgI; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4F7DC433B1; Thu, 4 Apr 2024 17:57:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712253439; bh=GpzHHadLf3YosmcJ25cQdas5aywqFNxjfnYY+ULKu6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IapbwqgIG6nVtU4XbjbiafvS0yiobNrsyYLPd0Fl0YCdfNlToQymVKTID/Bve+jT6 dKvHnyqPeO+O8g8VpT5YzO2W3Jo6YsdoyM3g1IrdxLGKec2/9jlTjisCbMSzywNVY7 0MkPtZFruKk6SXi3faO6IjNmv8YvvzQIfaonX66dnVFe/AVQ3OMnBA3IU3RCX7kQNf l8rneWG4zQE3eeU6E4vQAD8bcg//22oulCv1DFDB632PVmD0XheOSdTKH86qzfjbhP 3YAKTEHYm4ZtZaQObn6w+RvK49GdLrr4/cd2WdaMhIdHM+C3IXVRcmc3kX5Bu18QvE pJVi+CdxCBy9Q== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH 1/9] perf annotate: Fix annotation_calc_lines() Date: Thu, 4 Apr 2024 10:57:08 -0700 Message-ID: <20240404175716.1225482-2-namhyung@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog In-Reply-To: <20240404175716.1225482-1-namhyung@kernel.org> References: <20240404175716.1225482-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit It should pass a proper address (i.e. suitable for objdump or addr2line) to get_srcline() in order to work correctly. It used to pass an address with map__rip_2objdump() as the second argument but later it's changed to use notes->start. It's ok in normal cases but it can be changed when annotate_opts.full_addr is set. So let's convert the address directly instead of using the notes->start. Also the last argument is an IP to print symbol offset if requested. So it should pass symbol-relative address. Fixes: 7d18a824b5e5 ("perf annotate: Toggle full address <-> offset display") Signed-off-by: Namhyung Kim --- tools/perf/util/annotate.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 35235147b111..a330e92c2552 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1440,7 +1440,7 @@ void annotation__toggle_full_addr(struct annotation *notes, struct map_symbol *m annotation__update_column_widths(notes); } -static void annotation__calc_lines(struct annotation *notes, struct map *map, +static void annotation__calc_lines(struct annotation *notes, struct map_symbol *ms, struct rb_root *root) { struct annotation_line *al; @@ -1448,6 +1448,7 @@ static void annotation__calc_lines(struct annotation *notes, struct map *map, list_for_each_entry(al, ¬es->src->source, node) { double percent_max = 0.0; + u64 addr; int i; for (i = 0; i < al->data_nr; i++) { @@ -1463,8 +1464,9 @@ static void annotation__calc_lines(struct annotation *notes, struct map *map, if (percent_max <= 0.5) continue; - al->path = get_srcline(map__dso(map), notes->start + al->offset, NULL, - false, true, notes->start + al->offset); + addr = map__rip_2objdump(ms->map, ms->sym->start); + al->path = get_srcline(map__dso(ms->map), addr + al->offset, NULL, + false, true, ms->sym->start + al->offset); insert_source_line(&tmp_root, al); } @@ -1475,7 +1477,7 @@ static void symbol__calc_lines(struct map_symbol *ms, struct rb_root *root) { struct annotation *notes = symbol__annotation(ms->sym); - annotation__calc_lines(notes, ms->map, root); + annotation__calc_lines(notes, ms, root); } int symbol__tty_annotate2(struct map_symbol *ms, struct evsel *evsel) -- 2.44.0.478.gd926399ef9-goog