* [PATCH 0/2] perf script: Refine printing of dso offset (dsoff)
@ 2023-04-24 5:51 Adrian Hunter
2023-04-24 5:51 ` [PATCH 1/2] perf dso: Declare dso const as needed Adrian Hunter
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Adrian Hunter @ 2023-04-24 5:51 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Jiri Olsa, Namhyung Kim, Ian Rogers, linux-kernel,
linux-perf-users, Changbin Du
Hi
Here is a refinement to patches from Changbin Du <changbin.du@huawei.com>
that add dsoff:
https://lore.kernel.org/linux-perf-users/20230418031825.1262579-1-changbin.du@huawei.com/T/#t
Adrian Hunter (2):
perf dso: Declare dso const as needed
perf script: Refine printing of dso offset
tools/perf/util/dso.c | 33 +++++++++++++++++++++++++++++++++
tools/perf/util/dso.h | 8 +++++---
tools/perf/util/map.c | 23 +++++++++++++++++++----
3 files changed, 57 insertions(+), 7 deletions(-)
Regards
Adrian
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] perf dso: Declare dso const as needed
2023-04-24 5:51 [PATCH 0/2] perf script: Refine printing of dso offset (dsoff) Adrian Hunter
@ 2023-04-24 5:51 ` Adrian Hunter
2023-04-24 5:51 ` [PATCH 2/2] perf script: Refine printing of dso offset (dsoff) Adrian Hunter
2023-04-29 1:56 ` [PATCH 0/2] " Arnaldo Carvalho de Melo
2 siblings, 0 replies; 4+ messages in thread
From: Adrian Hunter @ 2023-04-24 5:51 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Jiri Olsa, Namhyung Kim, Ian Rogers, linux-kernel,
linux-perf-users, Changbin Du
Declare dso const, so that functions can be called with const struct *dso.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/util/dso.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 0b7c7633b9f6..dfc4cf3de7a8 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -379,19 +379,19 @@ void dso__reset_find_symbol_cache(struct dso *dso);
size_t dso__fprintf_symbols_by_name(struct dso *dso, FILE *fp);
size_t dso__fprintf(struct dso *dso, FILE *fp);
-static inline bool dso__is_vmlinux(struct dso *dso)
+static inline bool dso__is_vmlinux(const struct dso *dso)
{
return dso->binary_type == DSO_BINARY_TYPE__VMLINUX ||
dso->binary_type == DSO_BINARY_TYPE__GUEST_VMLINUX;
}
-static inline bool dso__is_kcore(struct dso *dso)
+static inline bool dso__is_kcore(const struct dso *dso)
{
return dso->binary_type == DSO_BINARY_TYPE__KCORE ||
dso->binary_type == DSO_BINARY_TYPE__GUEST_KCORE;
}
-static inline bool dso__is_kallsyms(struct dso *dso)
+static inline bool dso__is_kallsyms(const struct dso *dso)
{
return dso->kernel && dso->long_name[0] != '/';
}
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] perf script: Refine printing of dso offset (dsoff)
2023-04-24 5:51 [PATCH 0/2] perf script: Refine printing of dso offset (dsoff) Adrian Hunter
2023-04-24 5:51 ` [PATCH 1/2] perf dso: Declare dso const as needed Adrian Hunter
@ 2023-04-24 5:51 ` Adrian Hunter
2023-04-29 1:56 ` [PATCH 0/2] " Arnaldo Carvalho de Melo
2 siblings, 0 replies; 4+ messages in thread
From: Adrian Hunter @ 2023-04-24 5:51 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Jiri Olsa, Namhyung Kim, Ian Rogers, linux-kernel,
linux-perf-users, Changbin Du
Print dso offset only for object files, and in those cases force using the
dso->long_name if the dso->name starts with '[' or the dso is kcore, in
order to avoid special names such as [vdso], or mixing up kcore with
vmlinux.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/util/dso.c | 33 +++++++++++++++++++++++++++++++++
tools/perf/util/dso.h | 2 ++
tools/perf/util/map.c | 23 +++++++++++++++++++----
3 files changed, 54 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index a86614599269..046fbfcfdaab 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -67,6 +67,39 @@ char dso__symtab_origin(const struct dso *dso)
return origin[dso->symtab_type];
}
+bool dso__is_object_file(const struct dso *dso)
+{
+ switch (dso->binary_type) {
+ case DSO_BINARY_TYPE__KALLSYMS:
+ case DSO_BINARY_TYPE__GUEST_KALLSYMS:
+ case DSO_BINARY_TYPE__JAVA_JIT:
+ case DSO_BINARY_TYPE__BPF_PROG_INFO:
+ case DSO_BINARY_TYPE__BPF_IMAGE:
+ case DSO_BINARY_TYPE__OOL:
+ return false;
+ case DSO_BINARY_TYPE__VMLINUX:
+ case DSO_BINARY_TYPE__GUEST_VMLINUX:
+ case DSO_BINARY_TYPE__DEBUGLINK:
+ case DSO_BINARY_TYPE__BUILD_ID_CACHE:
+ case DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO:
+ case DSO_BINARY_TYPE__FEDORA_DEBUGINFO:
+ case DSO_BINARY_TYPE__UBUNTU_DEBUGINFO:
+ case DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO:
+ case DSO_BINARY_TYPE__BUILDID_DEBUGINFO:
+ case DSO_BINARY_TYPE__SYSTEM_PATH_DSO:
+ case DSO_BINARY_TYPE__GUEST_KMODULE:
+ case DSO_BINARY_TYPE__GUEST_KMODULE_COMP:
+ case DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE:
+ case DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP:
+ case DSO_BINARY_TYPE__KCORE:
+ case DSO_BINARY_TYPE__GUEST_KCORE:
+ case DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO:
+ case DSO_BINARY_TYPE__NOT_FOUND:
+ default:
+ return true;
+ }
+}
+
int dso__read_binary_type_filename(const struct dso *dso,
enum dso_binary_type type,
char *root_dir, char *filename, size_t size)
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index dfc4cf3de7a8..b23a157c914d 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -396,6 +396,8 @@ static inline bool dso__is_kallsyms(const struct dso *dso)
return dso->kernel && dso->long_name[0] != '/';
}
+bool dso__is_object_file(const struct dso *dso);
+
void dso__free_a2l(struct dso *dso);
enum dso_type dso__type(struct dso *dso, struct machine *machine);
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 8c96ce6bfc51..4d9944bbf5e4 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -431,14 +431,21 @@ size_t map__fprintf(struct map *map, FILE *fp)
map__start(map), map__end(map), map__pgoff(map), dso->name);
}
-size_t map__fprintf_dsoname(struct map *map, FILE *fp)
+static bool prefer_dso_long_name(const struct dso *dso, bool print_off)
+{
+ return dso->long_name &&
+ (symbol_conf.show_kernel_path ||
+ (print_off && (dso->name[0] == '[' || dso__is_kcore(dso))));
+}
+
+static size_t __map__fprintf_dsoname(struct map *map, bool print_off, FILE *fp)
{
char buf[symbol_conf.pad_output_len_dso + 1];
const char *dsoname = "[unknown]";
const struct dso *dso = map ? map__dso(map) : NULL;
if (dso) {
- if (symbol_conf.show_kernel_path && dso->long_name)
+ if (prefer_dso_long_name(dso, print_off))
dsoname = dso->long_name;
else
dsoname = dso->name;
@@ -452,13 +459,21 @@ size_t map__fprintf_dsoname(struct map *map, FILE *fp)
return fprintf(fp, "%s", dsoname);
}
+size_t map__fprintf_dsoname(struct map *map, FILE *fp)
+{
+ return __map__fprintf_dsoname(map, false, fp);
+}
+
size_t map__fprintf_dsoname_dsoff(struct map *map, bool print_off, u64 addr, FILE *fp)
{
+ const struct dso *dso = map ? map__dso(map) : NULL;
int printed = 0;
+ if (print_off && (!dso || !dso__is_object_file(dso)))
+ print_off = false;
printed += fprintf(fp, " (");
- printed += map__fprintf_dsoname(map, fp);
- if (print_off && map && map__dso(map) && !map__dso(map)->kernel)
+ printed += __map__fprintf_dsoname(map, print_off, fp);
+ if (print_off)
printed += fprintf(fp, "+0x%" PRIx64, addr);
printed += fprintf(fp, ")");
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] perf script: Refine printing of dso offset (dsoff)
2023-04-24 5:51 [PATCH 0/2] perf script: Refine printing of dso offset (dsoff) Adrian Hunter
2023-04-24 5:51 ` [PATCH 1/2] perf dso: Declare dso const as needed Adrian Hunter
2023-04-24 5:51 ` [PATCH 2/2] perf script: Refine printing of dso offset (dsoff) Adrian Hunter
@ 2023-04-29 1:56 ` Arnaldo Carvalho de Melo
2 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-04-29 1:56 UTC (permalink / raw)
To: Adrian Hunter
Cc: Jiri Olsa, Namhyung Kim, Ian Rogers, linux-kernel,
linux-perf-users, Changbin Du
Em Mon, Apr 24, 2023 at 08:51:05AM +0300, Adrian Hunter escreveu:
> Hi
>
> Here is a refinement to patches from Changbin Du <changbin.du@huawei.com>
> that add dsoff:
>
> https://lore.kernel.org/linux-perf-users/20230418031825.1262579-1-changbin.du@huawei.com/T/#t
>
Thanks, applied.
- Arnaldo
> Adrian Hunter (2):
> perf dso: Declare dso const as needed
> perf script: Refine printing of dso offset
>
> tools/perf/util/dso.c | 33 +++++++++++++++++++++++++++++++++
> tools/perf/util/dso.h | 8 +++++---
> tools/perf/util/map.c | 23 +++++++++++++++++++----
> 3 files changed, 57 insertions(+), 7 deletions(-)
>
>
> Regards
> Adrian
--
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-29 1:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-24 5:51 [PATCH 0/2] perf script: Refine printing of dso offset (dsoff) Adrian Hunter
2023-04-24 5:51 ` [PATCH 1/2] perf dso: Declare dso const as needed Adrian Hunter
2023-04-24 5:51 ` [PATCH 2/2] perf script: Refine printing of dso offset (dsoff) Adrian Hunter
2023-04-29 1:56 ` [PATCH 0/2] " Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).