Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3344921rdb; Tue, 6 Feb 2024 15:05:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IGLR0GyAHJAssSIE7BjcMezn2bRn+g1NNvFLFN5WBKv01oAQh2SmrSBXwdxhUGIFh947PNt X-Received: by 2002:a05:6a20:12c3:b0:19c:9419:1f37 with SMTP id v3-20020a056a2012c300b0019c94191f37mr3518169pzg.13.1707260705623; Tue, 06 Feb 2024 15:05:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707260705; cv=pass; d=google.com; s=arc-20160816; b=DbGoGFssEelFwrHCjzpmq236pAXncCzSyOd6yV1qquZrmofoAZ/T1ijUaGxzenPHhB Fe4PT6UDAKekXuIz26veBk9T5rUAniikBgpOy//nswxDs35khfyX3pJK2D/Iu/DJEO7b sglAxMoI/CVoD88qmLwZEAyjvbD9wNKl3/wGFVXBJNl/5axkbIRaj64knu/HeI9ovYjJ JgnhgPARnaYdb2UTdHezgAxxeU3iK+ztTmaaxV2l+7STrBH6CEFmuVg772RVOlsMsokl RxJfkXNGy1a8ZnqckZdm+y6JE5oHKhG+TFf6e0JNnOLlQaICMX/arQg2p9eb9D3C/d71 rE3g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=XE3O5UKIKUsuneAmY5uurD5IR5hTBLYsMxi5qNrCvNs=; fh=Q4bRftjIduvgnwHhfwavXvSCR77qQe4Z4yZC69m9MkY=; b=WC3YZktnE0KqsNXls/qG4DTgupvCZc1fK+u339LU/Jk4VGOfP2sqB9ROvsQlQxMXkT 9IDSvZLGwfCfUz5bxyZ2KwgIk3wDpRPs/X8Ngscu092NPW62yArCU+BVpjPT7TDmKpLY JSUJe00m9KPozbT15BeOk6JOlvJ/r8NNi0q7R4h9E9vYwDMUVF9gBtw7lrP8c2HduxYl /MpZUM9Wzk+tboX0b81PPBtt5zMO0aRTo+YBA4EtgLboyDo83/gqe028SF+Lz8tOm4Jn axVPIU4AcRZVZ7JLgvCmvgSlPHhrbRduHu0s8xCnP4elXKPVl9L7QxMQZ+8FAGKjhDJJ Rnmw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55708-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55708-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXJshQtnPtjIFLiRrKw0N5Eq1y+XoGN+08ywSMA/bf69p2dYxwxVpVbevUDGpRVGoOs8nMW2zRs1h55oFyo148TnJ5OIzYa+48EF0Q5sQ== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b62-20020a633441000000b005dbee62c2a3si12668pga.228.2024.02.06.15.05.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 15:05:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55708-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; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55708-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55708-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 77B4EB220AD for ; Tue, 6 Feb 2024 23:05:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D2AE31C69C; Tue, 6 Feb 2024 23:04:51 +0000 (UTC) Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC6441CD19; Tue, 6 Feb 2024 23:04:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707260691; cv=none; b=aO0VG/nFXeVkK1t/Fby6grcRM6LgAru+pzjUn6G4dhnmw6O9uPxXlJMec+/EU0N5b7aEEI/HghMu/UZsZEMcFLFgySg3ZoIX9q5kAEwDVeCAHbiuwko8p/gdw5QHlp0sQ6CXkd3fx1V9BccExYT+fW1LGdVTtecrsD2OQ/PcLp0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707260691; c=relaxed/simple; bh=Bj7WtUHXfxhehFCeqs9x6LDb+Zbzpz0PHoSScUvtbLM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=N2SyhKKLJoqYEgNsKKQeR3mcUinznILv+ffGzSg6sNgTEjdAWZ0hDTFGEcT2FbUNZxbIRsM4YIYd2UVDcEIMG/2uQscL/NasDEN0iuSUKslamr2XlZ1OWbeUsRpkpuAMIziR1YvYzdDSYnfbWP+UR7TT2BtX+IFNN60JUKaGRfM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6e065abd351so37758b3a.3; Tue, 06 Feb 2024 15:04:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707260689; x=1707865489; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XE3O5UKIKUsuneAmY5uurD5IR5hTBLYsMxi5qNrCvNs=; b=aRuYa7Pjq11fb8ZSsj4ztTS0kz1v63EwRYlx3w5mgCedd//E1dy7io8fmdp5WXegJ7 wYRag++UkUqf5JhKNefsOSE0ocBigDRX8ZcJO1xx9vx9fhduyGvNgYPfv5k4fgefbGP9 +ddbmXR/dnhdp28Wq2WyyhL39EUy8+GtCZy14SWWSXRrl70M5aZJYlqasTk+LZQQ8Q+/ 6kEnaJ/lj3YIIXfytGoTfNCR55auaWhDoPBt9oMjbyn1hJJNtkDswVprI7hh1pvsqEvm LsI5n1FT3uu2UYeHQ/VGn8Qzpv74mMpng5mMTZ0zVxKbx58fyHGCAJAiB+4srsbtGQ6O lw1g== X-Gm-Message-State: AOJu0Yx87HauGVA7rPL76Dm2ECQTyWxXEUqhTxeN6tEVsdvOg8Ce0mMM gb3VWW+DbddOa9LRmvtac6Hfn0lHFSrQrL+8VmzJeezYDVOjlPYLDzwhTM3xSdStiPtyUrslbjf 1HmAnjyJ0dN5KB7Lxg+76ncdsNWc= X-Received: by 2002:a05:6a00:2283:b0:6e0:5ea0:d3bf with SMTP id f3-20020a056a00228300b006e05ea0d3bfmr1190550pfe.7.1707260689194; Tue, 06 Feb 2024 15:04:49 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240202220459.527138-1-namhyung@kernel.org> <20240202220459.527138-5-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Tue, 6 Feb 2024 15:04:37 -0800 Message-ID: Subject: Re: [PATCH 04/14] perf map: Add map__objdump_2rip() To: Ian Rogers Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Linus Torvalds , Stephane Eranian , Masami Hiramatsu , linux-toolchains@vger.kernel.org, linux-trace-devel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Ian, On Fri, Feb 2, 2024 at 5:42=E2=80=AFPM Ian Rogers wrot= e: > > On Fri, Feb 2, 2024 at 2:05=E2=80=AFPM Namhyung Kim = wrote: > > > > Sometimes we want to convert an address in objdump output to > > map-relative address to match with a sample data. Let's add > > map__objdump_2rip() for that. > > Hi Namhyung, > > I think the naming can be better here. Aren't the objdump addresses > DSO relative offsets? Is the relative IP relative to the map or the > DSO? AFAIK the objdump addresses are DSO-relative and rip is to map. They are mostly the same but sometimes different due to kASLR for the kernel. > > > Cc: Adrian Hunter > > Signed-off-by: Namhyung Kim > > --- > > tools/perf/util/map.c | 20 ++++++++++++++++++++ > > tools/perf/util/map.h | 3 +++ > > 2 files changed, 23 insertions(+) > > > > diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c > > index 54c67cb7ecef..66542864b7b5 100644 > > --- a/tools/perf/util/map.c > > +++ b/tools/perf/util/map.c > > @@ -594,6 +594,26 @@ u64 map__objdump_2mem(struct map *map, u64 ip) > > return ip + map__reloc(map); > > } > > > > +u64 map__objdump_2rip(struct map *map, u64 ip) > > +{ > > + const struct dso *dso =3D map__dso(map); > > + > > + if (!dso->adjust_symbols) > > + return ip; > > + > > + if (dso->rel) > > + return ip + map__pgoff(map); > > + > > + /* > > + * kernel modules also have DSO_TYPE_USER in dso->kernel, > > + * but all kernel modules are ET_REL, so won't get here. > > + */ Hmm.. This comment is not true anymore. Will remove in other places too. Thanks, Namhyung > > + if (dso->kernel =3D=3D DSO_SPACE__USER) > > + return ip - dso->text_offset; > > + > > + return map__map_ip(map, ip + map__reloc(map)); > > +} > > + > > bool map__contains_symbol(const struct map *map, const struct symbol *= sym) > > { > > u64 ip =3D map__unmap_ip(map, sym->start); > > diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h > > index 49756716cb13..65e2609fa1b1 100644 > > --- a/tools/perf/util/map.h > > +++ b/tools/perf/util/map.h > > @@ -132,6 +132,9 @@ u64 map__rip_2objdump(struct map *map, u64 rip); > > /* objdump address -> memory address */ > > u64 map__objdump_2mem(struct map *map, u64 ip); > > > > +/* objdump address -> rip */ > > +u64 map__objdump_2rip(struct map *map, u64 ip); > > + > > struct symbol; > > struct thread; > > > > -- > > 2.43.0.594.gd9cf4e227d-goog > >