tools/perf/ui/browsers/annotate.c

Source file repositories/reference/linux-study-clean/tools/perf/ui/browsers/annotate.c

File Facts

System
Linux kernel
Corpus path
tools/perf/ui/browsers/annotate.c
Extension
.c
Size
35106 bytes
Lines
1270
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

struct annotate_browser {
	struct ui_browser	    b;
	struct rb_root		    entries;
	struct rb_node		   *curr_hot;
	struct annotation_line	   *selection;
	const struct arch	   *arch;
	/*
	 * perf top can delete hist_entry anytime.  Callers should make sure
	 * its lifetime.
	 */
	struct hist_entry	   *he;
	struct debuginfo	   *dbg;
	struct evsel		   *evsel;
	struct hashmap		   *type_hash;
	bool			    searching_backwards;
	char			    search_bf[128];
};

/* A copy of target hist_entry for perf top. */
static struct hist_entry annotate_he;

static size_t type_hash(long key, void *ctx __maybe_unused)
{
	return key;
}

static bool type_equal(long key1, long key2, void *ctx __maybe_unused)
{
	return key1 == key2;
}

static inline struct annotation *browser__annotation(struct ui_browser *browser)
{
	struct map_symbol *ms = browser->priv;
	return symbol__annotation(ms->sym);
}

static bool disasm_line__filter(struct ui_browser *browser __maybe_unused, void *entry)
{
	struct annotation_line *al = list_entry(entry, struct annotation_line, node);
	return annotation_line__filter(al);
}

static int ui_browser__jumps_percent_color(struct ui_browser *browser, int nr, bool current)
{
	struct annotation *notes = browser__annotation(browser);

	if (current && (!browser->use_navkeypressed || browser->navkeypressed))
		return HE_COLORSET_SELECTED;
	if (nr == notes->src->max_jump_sources)
		return HE_COLORSET_TOP;
	if (nr > 1)
		return HE_COLORSET_MEDIUM;
	return HE_COLORSET_NORMAL;
}

static int ui_browser__set_jumps_percent_color(void *browser, int nr, bool current)
{
	 int color = ui_browser__jumps_percent_color(browser, nr, current);
	 return ui_browser__set_color(browser, color);
}

static int annotate_browser__set_color(void *browser, int color)
{
	return ui_browser__set_color(browser, color);
}

static void annotate_browser__write_graph(void *browser, int graph)
{
	ui_browser__write_graph(browser, graph);
}

static void annotate_browser__set_percent_color(void *browser, double percent, bool current)
{
	ui_browser__set_percent_color(browser, percent, current);
}

static void annotate_browser__printf(void *browser, const char *fmt, ...)
{
	va_list args;

	va_start(args, fmt);
	ui_browser__vprintf(browser, fmt, args);
	va_end(args);
}

static void annotate_browser__write(struct ui_browser *browser, void *entry, int row)
{
	struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
	struct annotation *notes = browser__annotation(browser);

Annotation

Implementation Notes