14 #include <linux/kernel.h> 56 for (i = 0; i < ARRAY_SIZE(fake_samples); i++) {
61 .hide_unresolved =
false,
64 sample.
cpumode = PERF_RECORD_MISC_USER;
65 sample.
cpu = fake_samples[i].
cpu;
66 sample.
pid = fake_samples[i].
pid;
67 sample.
tid = fake_samples[i].
pid;
68 sample.
ip = fake_samples[i].
ip;
80 fake_samples[i].
map = al.
map;
81 fake_samples[i].
sym = al.
sym;
87 pr_debug(
"Not enough memory for adding a hist entry\n");
94 struct rb_root *root_in;
95 struct rb_root *root_out;
105 while (!RB_EMPTY_ROOT(root_out)) {
106 node = rb_first(root_out);
108 he = rb_entry(node,
struct hist_entry, rb_node);
109 rb_erase(node, root_out);
117 #define COMM(he) (thread__comm_str(he->thread)) 118 #define DSO(he) (he->ms.map->dso->short_name) 119 #define SYM(he) (he->ms.sym->name) 120 #define CPU(he) (he->cpu) 121 #define PID(he) (he->thread->tid) 129 struct rb_root *
root;
130 struct rb_node *
node;
165 node = rb_first(root);
166 he = rb_entry(node,
struct hist_entry, rb_node);
168 !strcmp(
COMM(he),
"perf") && !strcmp(
DSO(he),
"perf") &&
171 node = rb_next(node);
172 he = rb_entry(node,
struct hist_entry, rb_node);
174 !strcmp(
COMM(he),
"bash") && !strcmp(
DSO(he),
"[kernel]") &&
177 node = rb_next(node);
178 he = rb_entry(node,
struct hist_entry, rb_node);
180 !strcmp(
COMM(he),
"bash") && !strcmp(
DSO(he),
"bash") &&
183 node = rb_next(node);
184 he = rb_entry(node,
struct hist_entry, rb_node);
186 !strcmp(
COMM(he),
"bash") && !strcmp(
DSO(he),
"bash") &&
189 node = rb_next(node);
190 he = rb_entry(node,
struct hist_entry, rb_node);
192 !strcmp(
COMM(he),
"perf") && !strcmp(
DSO(he),
"[kernel]") &&
195 node = rb_next(node);
196 he = rb_entry(node,
struct hist_entry, rb_node);
198 !strcmp(
COMM(he),
"perf") && !strcmp(
DSO(he),
"[kernel]") &&
201 node = rb_next(node);
202 he = rb_entry(node,
struct hist_entry, rb_node);
204 !strcmp(
COMM(he),
"perf") && !strcmp(
DSO(he),
"libc") &&
207 node = rb_next(node);
208 he = rb_entry(node,
struct hist_entry, rb_node);
210 !strcmp(
COMM(he),
"perf") && !strcmp(
DSO(he),
"libc") &&
213 node = rb_next(node);
214 he = rb_entry(node,
struct hist_entry, rb_node);
216 !strcmp(
COMM(he),
"perf") && !strcmp(
DSO(he),
"perf") &&
231 struct rb_root *
root;
232 struct rb_node *
node;
265 node = rb_first(root);
266 he = rb_entry(node,
struct hist_entry, rb_node);
270 node = rb_next(node);
271 he = rb_entry(node,
struct hist_entry, rb_node);
287 struct rb_root *
root;
288 struct rb_node *
node;
319 node = rb_first(root);
320 he = rb_entry(node,
struct hist_entry, rb_node);
322 !strcmp(
COMM(he),
"bash") && !strcmp(
DSO(he),
"bash") &&
325 node = rb_next(node);
326 he = rb_entry(node,
struct hist_entry, rb_node);
328 !strcmp(
COMM(he),
"bash") && !strcmp(
DSO(he),
"[kernel]") &&
331 node = rb_next(node);
332 he = rb_entry(node,
struct hist_entry, rb_node);
334 !strcmp(
COMM(he),
"perf") && !strcmp(
DSO(he),
"perf") &&
337 node = rb_next(node);
338 he = rb_entry(node,
struct hist_entry, rb_node);
340 !strcmp(
COMM(he),
"perf") && !strcmp(
DSO(he),
"[kernel]") &&
343 node = rb_next(node);
344 he = rb_entry(node,
struct hist_entry, rb_node);
346 !strcmp(
COMM(he),
"perf") && !strcmp(
DSO(he),
"libc") &&
361 struct rb_root *
root;
362 struct rb_node *
node;
397 node = rb_first(root);
398 he = rb_entry(node,
struct hist_entry, rb_node);
400 !strcmp(
DSO(he),
"perf") && !strcmp(
SYM(he),
"cmd_record") &&
403 node = rb_next(node);
404 he = rb_entry(node,
struct hist_entry, rb_node);
406 !strcmp(
DSO(he),
"libc") && !strcmp(
SYM(he),
"free") &&
409 node = rb_next(node);
410 he = rb_entry(node,
struct hist_entry, rb_node);
412 !strcmp(
DSO(he),
"bash") && !strcmp(
SYM(he),
"main") &&
415 node = rb_next(node);
416 he = rb_entry(node,
struct hist_entry, rb_node);
418 !strcmp(
DSO(he),
"perf") && !strcmp(
SYM(he),
"main") &&
421 node = rb_next(node);
422 he = rb_entry(node,
struct hist_entry, rb_node);
424 !strcmp(
DSO(he),
"libc") && !strcmp(
SYM(he),
"malloc") &&
427 node = rb_next(node);
428 he = rb_entry(node,
struct hist_entry, rb_node);
430 !strcmp(
DSO(he),
"[kernel]") && !strcmp(
SYM(he),
"page_fault") &&
433 node = rb_next(node);
434 he = rb_entry(node,
struct hist_entry, rb_node);
436 !strcmp(
DSO(he),
"[kernel]") && !strcmp(
SYM(he),
"page_fault") &&
439 node = rb_next(node);
440 he = rb_entry(node,
struct hist_entry, rb_node);
442 !strcmp(
DSO(he),
"[kernel]") && !strcmp(
SYM(he),
"schedule") &&
445 node = rb_next(node);
446 he = rb_entry(node,
struct hist_entry, rb_node);
448 !strcmp(
DSO(he),
"bash") && !strcmp(
SYM(he),
"xmalloc") &&
463 struct rb_root *
root;
464 struct rb_node *
node;
500 node = rb_first(root);
501 he = rb_entry(node,
struct hist_entry, rb_node);
504 CPU(he) == 0 &&
PID(he) == 100 &&
505 !strcmp(
COMM(he),
"perf") && !strcmp(
DSO(he),
"[kernel]") &&
508 node = rb_next(node);
509 he = rb_entry(node,
struct hist_entry, rb_node);
511 CPU(he) == 2 &&
PID(he) == 200 &&
512 !strcmp(
COMM(he),
"perf") && !strcmp(
DSO(he),
"[kernel]") &&
515 node = rb_next(node);
516 he = rb_entry(node,
struct hist_entry, rb_node);
518 CPU(he) == 1 &&
PID(he) == 300 &&
519 !strcmp(
COMM(he),
"bash") && !strcmp(
DSO(he),
"[kernel]") &&
522 node = rb_next(node);
523 he = rb_entry(node,
struct hist_entry, rb_node);
525 CPU(he) == 0 &&
PID(he) == 300 &&
526 !strcmp(
COMM(he),
"bash") && !strcmp(
DSO(he),
"bash") &&
529 node = rb_next(node);
530 he = rb_entry(node,
struct hist_entry, rb_node);
532 CPU(he) == 3 &&
PID(he) == 300 &&
533 !strcmp(
COMM(he),
"bash") && !strcmp(
DSO(he),
"bash") &&
536 node = rb_next(node);
537 he = rb_entry(node,
struct hist_entry, rb_node);
539 CPU(he) == 1 &&
PID(he) == 100 &&
540 !strcmp(
COMM(he),
"perf") && !strcmp(
DSO(he),
"libc") &&
543 node = rb_next(node);
544 he = rb_entry(node,
struct hist_entry, rb_node);
546 CPU(he) == 2 &&
PID(he) == 100 &&
547 !strcmp(
COMM(he),
"perf") && !strcmp(
DSO(he),
"libc") &&
550 node = rb_next(node);
551 he = rb_entry(node,
struct hist_entry, rb_node);
553 CPU(he) == 1 &&
PID(he) == 100 &&
554 !strcmp(
COMM(he),
"perf") && !strcmp(
DSO(he),
"perf") &&
557 node = rb_next(node);
558 he = rb_entry(node,
struct hist_entry, rb_node);
560 CPU(he) == 1 &&
PID(he) == 100 &&
561 !strcmp(
COMM(he),
"perf") && !strcmp(
DSO(he),
"perf") &&
564 node = rb_next(node);
565 he = rb_entry(node,
struct hist_entry, rb_node);
567 CPU(he) == 2 &&
PID(he) == 200 &&
568 !strcmp(
COMM(he),
"perf") && !strcmp(
DSO(he),
"perf") &&
612 for (i = 0; i < ARRAY_SIZE(testcases); i++) {
613 err = testcases[i](evsel, machine);
#define FAKE_IP_BASH_XMALLOC
static void setup_sorting(struct perf_sched *sched, const struct option *options, const char *const usage_msg[])
struct rb_root * entries_in
struct perf_sample * sample
void machines__exit(struct machines *machines)
int machine__resolve(struct machine *machine, struct addr_location *al, struct perf_sample *sample)
void reset_output_field(void)
static int test2(struct perf_evsel *evsel, struct machine *machine)
int hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
#define FAKE_IP_LIBC_MALLOC
#define TEST_ASSERT_VAL(text, cond)
void perf_evlist__delete(struct perf_evlist *evlist)
static struct hists * evsel__hists(struct perf_evsel *evsel)
int(* test_fn_t)(struct perf_evsel *, struct machine *)
int parse_events(struct perf_evlist *evlist, const char *str, struct parse_events_error *err)
int test__hists_output(struct test *test __maybe_unused, int subtest __maybe_unused)
static int test1(struct perf_evsel *evsel, struct machine *machine)
void addr_location__put(struct addr_location *al)
static struct perf_evsel * hists_to_evsel(struct hists *hists)
#define pr_debug(fmt,...)
#define FAKE_IP_PERF_MAIN
#define FAKE_IP_KERNEL_SCHEDULE
static int add_hist_entries(struct hists *hists, struct machine *machine)
static int test4(struct perf_evsel *evsel, struct machine *machine)
#define hists__has(__h, __f)
void hist_entry__delete(struct hist_entry *he)
#define FAKE_IP_PERF_CMD_RECORD
static int test5(struct perf_evsel *evsel, struct machine *machine)
struct rb_node rb_node_in
static struct sample fake_samples[]
const struct hist_iter_ops hist_iter_normal
static struct perf_evsel * perf_evlist__first(struct perf_evlist *evlist)
static int test3(struct perf_evsel *evsel, struct machine *machine)
void machines__init(struct machines *machines)
void print_hists_out(struct hists *hists)
#define FAKE_IP_BASH_MAIN
struct perf_evsel * evsel
static void del_hist_entries(struct hists *hists)
#define FAKE_IP_KERNEL_PAGE_FAULT
void perf_evsel__output_resort(struct perf_evsel *evsel, struct ui_progress *prog)
struct machine * setup_fake_machine(struct machines *machines)
struct rb_root entries_collapsed
int sysctl_perf_event_max_stack
#define FAKE_IP_LIBC_FREE
size_t machine__fprintf(struct machine *machine, FILE *fp)
struct perf_evlist * perf_evlist__new(void)
int hist_entry_iter__add(struct hist_entry_iter *iter, struct addr_location *al, int max_stack_depth, void *arg)