]> www.infradead.org Git - users/hch/misc.git/commitdiff
perf annotate: Show warning when debuginfo is not available
authorNamhyung Kim <namhyung@kernel.org>
Sat, 16 Aug 2025 03:16:32 +0000 (20:16 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 28 Aug 2025 15:35:12 +0000 (12:35 -0300)
When user requests data-type annotation but no DWARF info is available,
show a warning message about it.

  Warning:
  DWARF debuginfo not found.

  Data-type in this DSO will not be displayed.
  Please make sure to have debug information.

  Press any key...

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250816031635.25318-10-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/ui/browsers/annotate.c
tools/perf/util/dso.h

index dfe869c20e35da774cc6c9d5eaa86862d215eaeb..e3e7004f32251666faa50c5a4e6ccd7e4a24a6f6 100644 (file)
@@ -812,6 +812,20 @@ static int annotate__scnprintf_title(struct hists *hists, char *bf, size_t size)
        return printed;
 }
 
+static void annotate_browser__debuginfo_warning(struct annotate_browser *browser)
+{
+       struct map_symbol *ms = browser->b.priv;
+       struct dso *dso = map__dso(ms->map);
+
+       if (browser->dbg == NULL && annotate_opts.code_with_type &&
+           !dso__debuginfo_warned(dso)) {
+               ui__warning("DWARF debuginfo not found.\n\n"
+                           "Data-type in this DSO will not be displayed.\n"
+                           "Please make sure to have debug information.");
+               dso__set_debuginfo_warned(dso);
+       }
+}
+
 static int annotate_browser__run(struct annotate_browser *browser,
                                 struct evsel *evsel,
                                 struct hist_browser_timer *hbt)
@@ -842,6 +856,8 @@ static int annotate_browser__run(struct annotate_browser *browser,
 
        annotation_br_cntr_abbr_list(&br_cntr_text, evsel, false);
 
+       annotate_browser__debuginfo_warning(browser);
+
        while (1) {
                key = ui_browser__run(&browser->b, delay_secs);
 
@@ -1036,6 +1052,7 @@ show_sup_ins:
                        if (browser->dbg == NULL)
                                browser->dbg = debuginfo__new(dso__long_name(map__dso(ms->map)));
                        annotate_browser__show(&browser->b, title, help);
+                       annotate_browser__debuginfo_warning(browser);
                        continue;
                case K_LEFT:
                case '<':
index 3457d713d3c56df62e9f7b8db4a8c91f518d7e3e..7df1673f08d3ddb4258124e61f7dcdbd1ec94077 100644 (file)
@@ -299,6 +299,7 @@ DECLARE_RC_STRUCT(dso) {
        u8               hit:1;
        u8               annotate_warned:1;
        u8               auxtrace_warned:1;
+       u8               debuginfo_warned:1;
        u8               short_name_allocated:1;
        u8               long_name_allocated:1;
        u8               is_64_bit:1;
@@ -362,6 +363,16 @@ static inline void dso__set_annotate_warned(struct dso *dso)
        RC_CHK_ACCESS(dso)->annotate_warned = 1;
 }
 
+static inline bool dso__debuginfo_warned(const struct dso *dso)
+{
+       return RC_CHK_ACCESS(dso)->debuginfo_warned;
+}
+
+static inline void dso__set_debuginfo_warned(struct dso *dso)
+{
+       RC_CHK_ACCESS(dso)->debuginfo_warned = 1;
+}
+
 static inline bool dso__auxtrace_warned(const struct dso *dso)
 {
        return RC_CHK_ACCESS(dso)->auxtrace_warned;