perf tools: Finish the removal of 'self' arguments

They convey no information, perhaps I was bitten by some snake at some
point, complete the detox by naming the last of those arguments more
sensibly.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-u1r0dnjoro08dgztiy2g3t2q@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 714647bd
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
PyMODINIT_FUNC initperf_trace_context(void); PyMODINIT_FUNC initperf_trace_context(void);
static PyObject *perf_trace_context_common_pc(PyObject *self, PyObject *args) static PyObject *perf_trace_context_common_pc(PyObject *obj, PyObject *args)
{ {
static struct scripting_context *scripting_context; static struct scripting_context *scripting_context;
PyObject *context; PyObject *context;
...@@ -40,7 +40,7 @@ static PyObject *perf_trace_context_common_pc(PyObject *self, PyObject *args) ...@@ -40,7 +40,7 @@ static PyObject *perf_trace_context_common_pc(PyObject *self, PyObject *args)
return Py_BuildValue("i", retval); return Py_BuildValue("i", retval);
} }
static PyObject *perf_trace_context_common_flags(PyObject *self, static PyObject *perf_trace_context_common_flags(PyObject *obj,
PyObject *args) PyObject *args)
{ {
static struct scripting_context *scripting_context; static struct scripting_context *scripting_context;
...@@ -56,7 +56,7 @@ static PyObject *perf_trace_context_common_flags(PyObject *self, ...@@ -56,7 +56,7 @@ static PyObject *perf_trace_context_common_flags(PyObject *self,
return Py_BuildValue("i", retval); return Py_BuildValue("i", retval);
} }
static PyObject *perf_trace_context_common_lock_depth(PyObject *self, static PyObject *perf_trace_context_common_lock_depth(PyObject *obj,
PyObject *args) PyObject *args)
{ {
static struct scripting_context *scripting_context; static struct scripting_context *scripting_context;
......
...@@ -21,32 +21,32 @@ struct ui_browser { ...@@ -21,32 +21,32 @@ struct ui_browser {
void *priv; void *priv;
const char *title; const char *title;
char *helpline; char *helpline;
unsigned int (*refresh)(struct ui_browser *self); unsigned int (*refresh)(struct ui_browser *browser);
void (*write)(struct ui_browser *self, void *entry, int row); void (*write)(struct ui_browser *browser, void *entry, int row);
void (*seek)(struct ui_browser *self, off_t offset, int whence); void (*seek)(struct ui_browser *browser, off_t offset, int whence);
bool (*filter)(struct ui_browser *self, void *entry); bool (*filter)(struct ui_browser *browser, void *entry);
u32 nr_entries; u32 nr_entries;
bool navkeypressed; bool navkeypressed;
bool use_navkeypressed; bool use_navkeypressed;
}; };
int ui_browser__set_color(struct ui_browser *browser, int color); int ui_browser__set_color(struct ui_browser *browser, int color);
void ui_browser__set_percent_color(struct ui_browser *self, void ui_browser__set_percent_color(struct ui_browser *browser,
double percent, bool current); double percent, bool current);
bool ui_browser__is_current_entry(struct ui_browser *self, unsigned row); bool ui_browser__is_current_entry(struct ui_browser *browser, unsigned row);
void ui_browser__refresh_dimensions(struct ui_browser *self); void ui_browser__refresh_dimensions(struct ui_browser *browser);
void ui_browser__reset_index(struct ui_browser *self); void ui_browser__reset_index(struct ui_browser *browser);
void ui_browser__gotorc(struct ui_browser *self, int y, int x); void ui_browser__gotorc(struct ui_browser *browser, int y, int x);
void ui_browser__write_graph(struct ui_browser *browser, int graph); void ui_browser__write_graph(struct ui_browser *browser, int graph);
void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column, void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column,
u64 start, u64 end); u64 start, u64 end);
void __ui_browser__show_title(struct ui_browser *browser, const char *title); void __ui_browser__show_title(struct ui_browser *browser, const char *title);
void ui_browser__show_title(struct ui_browser *browser, const char *title); void ui_browser__show_title(struct ui_browser *browser, const char *title);
int ui_browser__show(struct ui_browser *self, const char *title, int ui_browser__show(struct ui_browser *browser, const char *title,
const char *helpline, ...); const char *helpline, ...);
void ui_browser__hide(struct ui_browser *self); void ui_browser__hide(struct ui_browser *browser);
int ui_browser__refresh(struct ui_browser *self); int ui_browser__refresh(struct ui_browser *browser);
int ui_browser__run(struct ui_browser *browser, int delay_secs); int ui_browser__run(struct ui_browser *browser, int delay_secs);
void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries); void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries);
void ui_browser__handle_resize(struct ui_browser *browser); void ui_browser__handle_resize(struct ui_browser *browser);
...@@ -63,11 +63,11 @@ int ui_browser__input_window(const char *title, const char *text, char *input, ...@@ -63,11 +63,11 @@ int ui_browser__input_window(const char *title, const char *text, char *input,
void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence); void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence);
unsigned int ui_browser__argv_refresh(struct ui_browser *browser); unsigned int ui_browser__argv_refresh(struct ui_browser *browser);
void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence); void ui_browser__rb_tree_seek(struct ui_browser *browser, off_t offset, int whence);
unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self); unsigned int ui_browser__rb_tree_refresh(struct ui_browser *browser);
void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whence); void ui_browser__list_head_seek(struct ui_browser *browser, off_t offset, int whence);
unsigned int ui_browser__list_head_refresh(struct ui_browser *self); unsigned int ui_browser__list_head_refresh(struct ui_browser *browser);
void ui_browser__init(void); void ui_browser__init(void);
void annotate_browser__init(void); void annotate_browser__init(void);
......
...@@ -1889,7 +1889,7 @@ static int perf_evsel_menu__run(struct perf_evsel_menu *menu, ...@@ -1889,7 +1889,7 @@ static int perf_evsel_menu__run(struct perf_evsel_menu *menu,
return key; return key;
} }
static bool filter_group_entries(struct ui_browser *self __maybe_unused, static bool filter_group_entries(struct ui_browser *browser __maybe_unused,
void *entry) void *entry)
{ {
struct perf_evsel *evsel = list_entry(entry, struct perf_evsel, node); struct perf_evsel *evsel = list_entry(entry, struct perf_evsel, node);
......
...@@ -18,30 +18,30 @@ struct map_browser { ...@@ -18,30 +18,30 @@ struct map_browser {
u8 addrlen; u8 addrlen;
}; };
static void map_browser__write(struct ui_browser *self, void *nd, int row) static void map_browser__write(struct ui_browser *browser, void *nd, int row)
{ {
struct symbol *sym = rb_entry(nd, struct symbol, rb_node); struct symbol *sym = rb_entry(nd, struct symbol, rb_node);
struct map_browser *mb = container_of(self, struct map_browser, b); struct map_browser *mb = container_of(browser, struct map_browser, b);
bool current_entry = ui_browser__is_current_entry(self, row); bool current_entry = ui_browser__is_current_entry(browser, row);
int width; int width;
ui_browser__set_percent_color(self, 0, current_entry); ui_browser__set_percent_color(browser, 0, current_entry);
slsmg_printf("%*" PRIx64 " %*" PRIx64 " %c ", slsmg_printf("%*" PRIx64 " %*" PRIx64 " %c ",
mb->addrlen, sym->start, mb->addrlen, sym->end, mb->addrlen, sym->start, mb->addrlen, sym->end,
sym->binding == STB_GLOBAL ? 'g' : sym->binding == STB_GLOBAL ? 'g' :
sym->binding == STB_LOCAL ? 'l' : 'w'); sym->binding == STB_LOCAL ? 'l' : 'w');
width = self->width - ((mb->addrlen * 2) + 4); width = browser->width - ((mb->addrlen * 2) + 4);
if (width > 0) if (width > 0)
slsmg_write_nstring(sym->name, width); slsmg_write_nstring(sym->name, width);
} }
/* FIXME uber-kludgy, see comment on cmd_report... */ /* FIXME uber-kludgy, see comment on cmd_report... */
static u32 *symbol__browser_index(struct symbol *self) static u32 *symbol__browser_index(struct symbol *browser)
{ {
return ((void *)self) - sizeof(struct rb_node) - sizeof(u32); return ((void *)browser) - sizeof(struct rb_node) - sizeof(u32);
} }
static int map_browser__search(struct map_browser *self) static int map_browser__search(struct map_browser *browser)
{ {
char target[512]; char target[512];
struct symbol *sym; struct symbol *sym;
...@@ -53,37 +53,37 @@ static int map_browser__search(struct map_browser *self) ...@@ -53,37 +53,37 @@ static int map_browser__search(struct map_browser *self)
if (target[0] == '0' && tolower(target[1]) == 'x') { if (target[0] == '0' && tolower(target[1]) == 'x') {
u64 addr = strtoull(target, NULL, 16); u64 addr = strtoull(target, NULL, 16);
sym = map__find_symbol(self->map, addr, NULL); sym = map__find_symbol(browser->map, addr, NULL);
} else } else
sym = map__find_symbol_by_name(self->map, target, NULL); sym = map__find_symbol_by_name(browser->map, target, NULL);
if (sym != NULL) { if (sym != NULL) {
u32 *idx = symbol__browser_index(sym); u32 *idx = symbol__browser_index(sym);
self->b.top = &sym->rb_node; browser->b.top = &sym->rb_node;
self->b.index = self->b.top_idx = *idx; browser->b.index = browser->b.top_idx = *idx;
} else } else
ui_helpline__fpush("%s not found!", target); ui_helpline__fpush("%s not found!", target);
return 0; return 0;
} }
static int map_browser__run(struct map_browser *self) static int map_browser__run(struct map_browser *browser)
{ {
int key; int key;
if (ui_browser__show(&self->b, self->map->dso->long_name, if (ui_browser__show(&browser->b, browser->map->dso->long_name,
"Press <- or ESC to exit, %s / to search", "Press <- or ESC to exit, %s / to search",
verbose ? "" : "restart with -v to use") < 0) verbose ? "" : "restart with -v to use") < 0)
return -1; return -1;
while (1) { while (1) {
key = ui_browser__run(&self->b, 0); key = ui_browser__run(&browser->b, 0);
switch (key) { switch (key) {
case '/': case '/':
if (verbose) if (verbose)
map_browser__search(self); map_browser__search(browser);
default: default:
break; break;
case K_LEFT: case K_LEFT:
...@@ -94,20 +94,20 @@ static int map_browser__run(struct map_browser *self) ...@@ -94,20 +94,20 @@ static int map_browser__run(struct map_browser *self)
} }
} }
out: out:
ui_browser__hide(&self->b); ui_browser__hide(&browser->b);
return key; return key;
} }
int map__browse(struct map *self) int map__browse(struct map *map)
{ {
struct map_browser mb = { struct map_browser mb = {
.b = { .b = {
.entries = &self->dso->symbols[self->type], .entries = &map->dso->symbols[map->type],
.refresh = ui_browser__rb_tree_refresh, .refresh = ui_browser__rb_tree_refresh,
.seek = ui_browser__rb_tree_seek, .seek = ui_browser__rb_tree_seek,
.write = map_browser__write, .write = map_browser__write,
}, },
.map = self, .map = map,
}; };
struct rb_node *nd; struct rb_node *nd;
char tmp[BITS_PER_LONG / 4]; char tmp[BITS_PER_LONG / 4];
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
#define _PERF_UI_MAP_BROWSER_H_ 1 #define _PERF_UI_MAP_BROWSER_H_ 1
struct map; struct map;
int map__browse(struct map *self); int map__browse(struct map *map);
#endif /* _PERF_UI_MAP_BROWSER_H_ */ #endif /* _PERF_UI_MAP_BROWSER_H_ */
...@@ -84,22 +84,22 @@ static void script_browser__write(struct ui_browser *browser, ...@@ -84,22 +84,22 @@ static void script_browser__write(struct ui_browser *browser,
slsmg_write_nstring(sline->line, browser->width); slsmg_write_nstring(sline->line, browser->width);
} }
static int script_browser__run(struct perf_script_browser *self) static int script_browser__run(struct perf_script_browser *browser)
{ {
int key; int key;
if (ui_browser__show(&self->b, self->script_name, if (ui_browser__show(&browser->b, browser->script_name,
"Press <- or ESC to exit") < 0) "Press <- or ESC to exit") < 0)
return -1; return -1;
while (1) { while (1) {
key = ui_browser__run(&self->b, 0); key = ui_browser__run(&browser->b, 0);
/* We can add some special key handling here if needed */ /* We can add some special key handling here if needed */
break; break;
} }
ui_browser__hide(&self->b); ui_browser__hide(&browser->b);
return key; return key;
} }
......
...@@ -213,20 +213,19 @@ static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root, ...@@ -213,20 +213,19 @@ static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root,
return ret; return ret;
} }
static size_t __callchain__fprintf_flat(FILE *fp, static size_t __callchain__fprintf_flat(FILE *fp, struct callchain_node *node,
struct callchain_node *self,
u64 total_samples) u64 total_samples)
{ {
struct callchain_list *chain; struct callchain_list *chain;
size_t ret = 0; size_t ret = 0;
if (!self) if (!node)
return 0; return 0;
ret += __callchain__fprintf_flat(fp, self->parent, total_samples); ret += __callchain__fprintf_flat(fp, node->parent, total_samples);
list_for_each_entry(chain, &self->val, list) { list_for_each_entry(chain, &node->val, list) {
if (chain->ip >= PERF_CONTEXT_MAX) if (chain->ip >= PERF_CONTEXT_MAX)
continue; continue;
if (chain->ms.sym) if (chain->ms.sym)
...@@ -239,15 +238,14 @@ static size_t __callchain__fprintf_flat(FILE *fp, ...@@ -239,15 +238,14 @@ static size_t __callchain__fprintf_flat(FILE *fp,
return ret; return ret;
} }
static size_t callchain__fprintf_flat(FILE *fp, struct rb_root *self, static size_t callchain__fprintf_flat(FILE *fp, struct rb_root *tree,
u64 total_samples) u64 total_samples)
{ {
size_t ret = 0; size_t ret = 0;
u32 entries_printed = 0; u32 entries_printed = 0;
struct rb_node *rb_node;
struct callchain_node *chain; struct callchain_node *chain;
struct rb_node *rb_node = rb_first(tree);
rb_node = rb_first(self);
while (rb_node) { while (rb_node) {
double percent; double percent;
......
...@@ -10,10 +10,9 @@ extern struct perf_tool build_id__mark_dso_hit_ops; ...@@ -10,10 +10,9 @@ extern struct perf_tool build_id__mark_dso_hit_ops;
struct dso; struct dso;
int build_id__sprintf(const u8 *build_id, int len, char *bf); int build_id__sprintf(const u8 *build_id, int len, char *bf);
char *dso__build_id_filename(struct dso *self, char *bf, size_t size); char *dso__build_id_filename(struct dso *dso, char *bf, size_t size);
int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event, int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event,
struct perf_sample *sample, struct perf_evsel *evsel, struct perf_sample *sample, struct perf_evsel *evsel,
struct machine *machine); struct machine *machine);
#endif #endif
...@@ -617,15 +617,15 @@ int perf_event__process(struct perf_tool *tool __maybe_unused, ...@@ -617,15 +617,15 @@ int perf_event__process(struct perf_tool *tool __maybe_unused,
return machine__process_event(machine, event, sample); return machine__process_event(machine, event, sample);
} }
void thread__find_addr_map(struct thread *self, void thread__find_addr_map(struct thread *thread,
struct machine *machine, u8 cpumode, struct machine *machine, u8 cpumode,
enum map_type type, u64 addr, enum map_type type, u64 addr,
struct addr_location *al) struct addr_location *al)
{ {
struct map_groups *mg = &self->mg; struct map_groups *mg = &thread->mg;
bool load_map = false; bool load_map = false;
al->thread = self; al->thread = thread;
al->addr = addr; al->addr = addr;
al->cpumode = cpumode; al->cpumode = cpumode;
al->filtered = false; al->filtered = false;
......
...@@ -251,7 +251,8 @@ int perf_event__process(struct perf_tool *tool, ...@@ -251,7 +251,8 @@ int perf_event__process(struct perf_tool *tool,
struct machine *machine); struct machine *machine);
struct addr_location; struct addr_location;
int perf_event__preprocess_sample(const union perf_event *self,
int perf_event__preprocess_sample(const union perf_event *event,
struct machine *machine, struct machine *machine,
struct addr_location *al, struct addr_location *al,
struct perf_sample *sample); struct perf_sample *sample);
......
...@@ -88,7 +88,7 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id); ...@@ -88,7 +88,7 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);
struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id); struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id);
union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx); union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx);
void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx); void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx);
......
...@@ -84,7 +84,7 @@ struct hists { ...@@ -84,7 +84,7 @@ struct hists {
u16 col_len[HISTC_NR_COLS]; u16 col_len[HISTC_NR_COLS];
}; };
struct hist_entry *__hists__add_entry(struct hists *self, struct hist_entry *__hists__add_entry(struct hists *hists,
struct addr_location *al, struct addr_location *al,
struct symbol *parent, struct symbol *parent,
struct branch_info *bi, struct branch_info *bi,
...@@ -93,34 +93,34 @@ struct hist_entry *__hists__add_entry(struct hists *self, ...@@ -93,34 +93,34 @@ struct hist_entry *__hists__add_entry(struct hists *self,
int64_t hist_entry__cmp(struct hist_entry *left, struct hist_entry *right); int64_t hist_entry__cmp(struct hist_entry *left, struct hist_entry *right);
int64_t hist_entry__collapse(struct hist_entry *left, struct hist_entry *right); int64_t hist_entry__collapse(struct hist_entry *left, struct hist_entry *right);
int hist_entry__transaction_len(void); int hist_entry__transaction_len(void);
int hist_entry__sort_snprintf(struct hist_entry *self, char *bf, size_t size, int hist_entry__sort_snprintf(struct hist_entry *he, char *bf, size_t size,
struct hists *hists); struct hists *hists);
void hist_entry__free(struct hist_entry *); void hist_entry__free(struct hist_entry *);
void hists__output_resort(struct hists *self); void hists__output_resort(struct hists *hists);
void hists__collapse_resort(struct hists *self, struct ui_progress *prog); void hists__collapse_resort(struct hists *hists, struct ui_progress *prog);
void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel); void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel);
void hists__output_recalc_col_len(struct hists *hists, int max_rows); void hists__output_recalc_col_len(struct hists *hists, int max_rows);
void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h); void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h);
void hists__inc_nr_events(struct hists *self, u32 type); void hists__inc_nr_events(struct hists *hists, u32 type);
void events_stats__inc(struct events_stats *stats, u32 type); void events_stats__inc(struct events_stats *stats, u32 type);
size_t events_stats__fprintf(struct events_stats *stats, FILE *fp); size_t events_stats__fprintf(struct events_stats *stats, FILE *fp);
size_t hists__fprintf(struct hists *self, bool show_header, int max_rows, size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
int max_cols, float min_pcnt, FILE *fp); int max_cols, float min_pcnt, FILE *fp);
int hist_entry__inc_addr_samples(struct hist_entry *self, int evidx, u64 addr); int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 addr);
int hist_entry__annotate(struct hist_entry *self, size_t privsize); int hist_entry__annotate(struct hist_entry *he, size_t privsize);
void hists__filter_by_dso(struct hists *hists); void hists__filter_by_dso(struct hists *hists);
void hists__filter_by_thread(struct hists *hists); void hists__filter_by_thread(struct hists *hists);
void hists__filter_by_symbol(struct hists *hists); void hists__filter_by_symbol(struct hists *hists);
u16 hists__col_len(struct hists *self, enum hist_column col); u16 hists__col_len(struct hists *hists, enum hist_column col);
void hists__set_col_len(struct hists *self, enum hist_column col, u16 len); void hists__set_col_len(struct hists *hists, enum hist_column col, u16 len);
bool hists__new_col_len(struct hists *self, enum hist_column col, u16 len); bool hists__new_col_len(struct hists *hists, enum hist_column col, u16 len);
void hists__reset_col_len(struct hists *hists); void hists__reset_col_len(struct hists *hists);
void hists__calc_col_len(struct hists *hists, struct hist_entry *he); void hists__calc_col_len(struct hists *hists, struct hist_entry *he);
...@@ -210,12 +210,9 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused, ...@@ -210,12 +210,9 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused,
return 0; return 0;
} }
static inline int hist_entry__tui_annotate(struct hist_entry *self static inline int hist_entry__tui_annotate(struct hist_entry *he __maybe_unused,
__maybe_unused, struct perf_evsel *evsel __maybe_unused,
struct perf_evsel *evsel struct hist_browser_timer *hbt __maybe_unused)
__maybe_unused,
struct hist_browser_timer *hbt
__maybe_unused)
{ {
return 0; return 0;
} }
...@@ -230,5 +227,5 @@ static inline int script_browse(const char *script_opt __maybe_unused) ...@@ -230,5 +227,5 @@ static inline int script_browse(const char *script_opt __maybe_unused)
#define K_SWITCH_INPUT_DATA -3000 #define K_SWITCH_INPUT_DATA -3000
#endif #endif
unsigned int hists__sort_list_width(struct hists *self); unsigned int hists__sort_list_width(struct hists *hists);
#endif /* __PERF_HIST_H */ #endif /* __PERF_HIST_H */
...@@ -115,7 +115,7 @@ static const Dwfl_Callbacks offline_callbacks = { ...@@ -115,7 +115,7 @@ static const Dwfl_Callbacks offline_callbacks = {
}; };
/* Get a Dwarf from offline image */ /* Get a Dwarf from offline image */
static int debuginfo__init_offline_dwarf(struct debuginfo *self, static int debuginfo__init_offline_dwarf(struct debuginfo *dbg,
const char *path) const char *path)
{ {
int fd; int fd;
...@@ -124,25 +124,25 @@ static int debuginfo__init_offline_dwarf(struct debuginfo *self, ...@@ -124,25 +124,25 @@ static int debuginfo__init_offline_dwarf(struct debuginfo *self,
if (fd < 0) if (fd < 0)
return fd; return fd;
self->dwfl = dwfl_begin(&offline_callbacks); dbg->dwfl = dwfl_begin(&offline_callbacks);
if (!self->dwfl) if (!dbg->dwfl)
goto error; goto error;
self->mod = dwfl_report_offline(self->dwfl, "", "", fd); dbg->mod = dwfl_report_offline(dbg->dwfl, "", "", fd);
if (!self->mod) if (!dbg->mod)
goto error; goto error;
self->dbg = dwfl_module_getdwarf(self->mod, &self->bias); dbg->dbg = dwfl_module_getdwarf(dbg->mod, &dbg->bias);
if (!self->dbg) if (!dbg->dbg)
goto error; goto error;
return 0; return 0;
error: error:
if (self->dwfl) if (dbg->dwfl)
dwfl_end(self->dwfl); dwfl_end(dbg->dwfl);
else else
close(fd); close(fd);
memset(self, 0, sizeof(*self)); memset(dbg, 0, sizeof(*dbg));
return -ENOENT; return -ENOENT;
} }
...@@ -180,24 +180,24 @@ static const Dwfl_Callbacks kernel_callbacks = { ...@@ -180,24 +180,24 @@ static const Dwfl_Callbacks kernel_callbacks = {
}; };
/* Get a Dwarf from live kernel image */ /* Get a Dwarf from live kernel image */
static int debuginfo__init_online_kernel_dwarf(struct debuginfo *self, static int debuginfo__init_online_kernel_dwarf(struct debuginfo *dbg,
Dwarf_Addr addr) Dwarf_Addr addr)
{ {
self->dwfl = dwfl_begin(&kernel_callbacks); dbg->dwfl = dwfl_begin(&kernel_callbacks);
if (!self->dwfl) if (!dbg->dwfl)
return -EINVAL; return -EINVAL;
/* Load the kernel dwarves: Don't care the result here */ /* Load the kernel dwarves: Don't care the result here */
dwfl_linux_kernel_report_kernel(self->dwfl); dwfl_linux_kernel_report_kernel(dbg->dwfl);
dwfl_linux_kernel_report_modules(self->dwfl); dwfl_linux_kernel_report_modules(dbg->dwfl);
self->dbg = dwfl_addrdwarf(self->dwfl, addr, &self->bias); dbg->dbg = dwfl_addrdwarf(dbg->dwfl, addr, &dbg->bias);
/* Here, check whether we could get a real dwarf */ /* Here, check whether we could get a real dwarf */
if (!self->dbg) { if (!dbg->dbg) {
pr_debug("Failed to find kernel dwarf at %lx\n", pr_debug("Failed to find kernel dwarf at %lx\n",
(unsigned long)addr); (unsigned long)addr);
dwfl_end(self->dwfl); dwfl_end(dbg->dwfl);
memset(self, 0, sizeof(*self)); memset(dbg, 0, sizeof(*dbg));
return -ENOENT; return -ENOENT;
} }
...@@ -205,7 +205,7 @@ static int debuginfo__init_online_kernel_dwarf(struct debuginfo *self, ...@@ -205,7 +205,7 @@ static int debuginfo__init_online_kernel_dwarf(struct debuginfo *self,
} }
#else #else
/* With older elfutils, this just support kernel module... */ /* With older elfutils, this just support kernel module... */
static int debuginfo__init_online_kernel_dwarf(struct debuginfo *self, static int debuginfo__init_online_kernel_dwarf(struct debuginfo *dbg,
Dwarf_Addr addr __maybe_unused) Dwarf_Addr addr __maybe_unused)
{ {
const char *path = kernel_get_module_path("kernel"); const char *path = kernel_get_module_path("kernel");
...@@ -216,44 +216,45 @@ static int debuginfo__init_online_kernel_dwarf(struct debuginfo *self, ...@@ -216,44 +216,45 @@ static int debuginfo__init_online_kernel_dwarf(struct debuginfo *self,
} }
pr_debug2("Use file %s for debuginfo\n", path); pr_debug2("Use file %s for debuginfo\n", path);
return debuginfo__init_offline_dwarf(self, path); return debuginfo__init_offline_dwarf(dbg, path);
} }
#endif #endif
struct debuginfo *debuginfo__new(const char *path) struct debuginfo *debuginfo__new(const char *path)
{ {
struct debuginfo *self = zalloc(sizeof(struct debuginfo)); struct debuginfo *dbg = zalloc(sizeof(*dbg));
if (!self) if (!dbg)
return NULL; return NULL;
if (debuginfo__init_offline_dwarf(self, path) < 0) { if (debuginfo__init_offline_dwarf(dbg, path) < 0) {
free(self); free(dbg);
self = NULL; dbg = NULL;
} }
return self; return dbg;
} }
struct debuginfo *debuginfo__new_online_kernel(unsigned long addr) struct debuginfo *debuginfo__new_online_kernel(unsigned long addr)
{ {
struct debuginfo *self = zalloc(sizeof(struct debuginfo)); struct debuginfo *dbg = zalloc(sizeof(*dbg));
if (!self)
if (!dbg)
return NULL; return NULL;
if (debuginfo__init_online_kernel_dwarf(self, (Dwarf_Addr)addr) < 0) { if (debuginfo__init_online_kernel_dwarf(dbg, (Dwarf_Addr)addr) < 0) {
free(self); free(dbg);
self = NULL; dbg = NULL;
} }
return self; return dbg;
} }
void debuginfo__delete(struct debuginfo *self) void debuginfo__delete(struct debuginfo *dbg)
{ {
if (self) { if (dbg) {
if (self->dwfl) if (dbg->dwfl)
dwfl_end(self->dwfl); dwfl_end(dbg->dwfl);
free(self); free(dbg);
} }
} }
...@@ -1083,7 +1084,7 @@ static int pubname_search_cb(Dwarf *dbg, Dwarf_Global *gl, void *data) ...@@ -1083,7 +1084,7 @@ static int pubname_search_cb(Dwarf *dbg, Dwarf_Global *gl, void *data)
} }
/* Find probe points from debuginfo */ /* Find probe points from debuginfo */
static int debuginfo__find_probes(struct debuginfo *self, static int debuginfo__find_probes(struct debuginfo *dbg,
struct probe_finder *pf) struct probe_finder *pf)
{ {
struct perf_probe_point *pp = &pf->pev->point; struct perf_probe_point *pp = &pf->pev->point;
...@@ -1094,7 +1095,7 @@ static int debuginfo__find_probes(struct debuginfo *self, ...@@ -1094,7 +1095,7 @@ static int debuginfo__find_probes(struct debuginfo *self,
#if _ELFUTILS_PREREQ(0, 142) #if _ELFUTILS_PREREQ(0, 142)
/* Get the call frame information from this dwarf */ /* Get the call frame information from this dwarf */
pf->cfi = dwarf_getcfi(self->dbg); pf->cfi = dwarf_getcfi(dbg->dbg);
#endif #endif
off = 0; off = 0;
...@@ -1113,7 +1114,7 @@ static int debuginfo__find_probes(struct debuginfo *self, ...@@ -1113,7 +1114,7 @@ static int debuginfo__find_probes(struct debuginfo *self,
.data = pf, .data = pf,
}; };
dwarf_getpubnames(self->dbg, pubname_search_cb, dwarf_getpubnames(dbg->dbg, pubname_search_cb,
&pubname_param, 0); &pubname_param, 0);
if (pubname_param.found) { if (pubname_param.found) {
ret = probe_point_search_cb(&pf->sp_die, &probe_param); ret = probe_point_search_cb(&pf->sp_die, &probe_param);
...@@ -1123,9 +1124,9 @@ static int debuginfo__find_probes(struct debuginfo *self, ...@@ -1123,9 +1124,9 @@ static int debuginfo__find_probes(struct debuginfo *self,
} }
/* Loop on CUs (Compilation Unit) */ /* Loop on CUs (Compilation Unit) */
while (!dwarf_nextcu(self->dbg, off, &noff, &cuhl, NULL, NULL, NULL)) { while (!dwarf_nextcu(dbg->dbg, off, &noff, &cuhl, NULL, NULL, NULL)) {
/* Get the DIE(Debugging Information Entry) of this CU */ /* Get the DIE(Debugging Information Entry) of this CU */
diep = dwarf_offdie(self->dbg, off + cuhl, &pf->cu_die); diep = dwarf_offdie(dbg->dbg, off + cuhl, &pf->cu_die);
if (!diep) if (!diep)
continue; continue;
...@@ -1281,13 +1282,13 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf) ...@@ -1281,13 +1282,13 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
} }
/* Find probe_trace_events specified by perf_probe_event from debuginfo */ /* Find probe_trace_events specified by perf_probe_event from debuginfo */
int debuginfo__find_trace_events(struct debuginfo *self, int debuginfo__find_trace_events(struct debuginfo *dbg,
struct perf_probe_event *pev, struct perf_probe_event *pev,
struct probe_trace_event **tevs, int max_tevs) struct probe_trace_event **tevs, int max_tevs)
{ {
struct trace_event_finder tf = { struct trace_event_finder tf = {
.pf = {.pev = pev, .callback = add_probe_trace_event}, .pf = {.pev = pev, .callback = add_probe_trace_event},
.mod = self->mod, .max_tevs = max_tevs}; .mod = dbg->mod, .max_tevs = max_tevs};
int ret; int ret;
/* Allocate result tevs array */ /* Allocate result tevs array */
...@@ -1298,7 +1299,7 @@ int debuginfo__find_trace_events(struct debuginfo *self, ...@@ -1298,7 +1299,7 @@ int debuginfo__find_trace_events(struct debuginfo *self,
tf.tevs = *tevs; tf.tevs = *tevs;
tf.ntevs = 0; tf.ntevs = 0;
ret = debuginfo__find_probes(self, &tf.pf); ret = debuginfo__find_probes(dbg, &tf.pf);
if (ret < 0) { if (ret < 0) {
free(*tevs); free(*tevs);
*tevs = NULL; *tevs = NULL;
...@@ -1389,14 +1390,14 @@ static int add_available_vars(Dwarf_Die *sc_die, struct probe_finder *pf) ...@@ -1389,14 +1390,14 @@ static int add_available_vars(Dwarf_Die *sc_die, struct probe_finder *pf)
} }
/* Find available variables at given probe point */ /* Find available variables at given probe point */
int debuginfo__find_available_vars_at(struct debuginfo *self, int debuginfo__find_available_vars_at(struct debuginfo *dbg,
struct perf_probe_event *pev, struct perf_probe_event *pev,
struct variable_list **vls, struct variable_list **vls,
int max_vls, bool externs) int max_vls, bool externs)
{ {
struct available_var_finder af = { struct available_var_finder af = {
.pf = {.pev = pev, .callback = add_available_vars}, .pf = {.pev = pev, .callback = add_available_vars},
.mod = self->mod, .mod = dbg->mod,
.max_vls = max_vls, .externs = externs}; .max_vls = max_vls, .externs = externs};
int ret; int ret;
...@@ -1408,7 +1409,7 @@ int debuginfo__find_available_vars_at(struct debuginfo *self, ...@@ -1408,7 +1409,7 @@ int debuginfo__find_available_vars_at(struct debuginfo *self,
af.vls = *vls; af.vls = *vls;
af.nvls = 0; af.nvls = 0;
ret = debuginfo__find_probes(self, &af.pf); ret = debuginfo__find_probes(dbg, &af.pf);
if (ret < 0) { if (ret < 0) {
/* Free vlist for error */ /* Free vlist for error */
while (af.nvls--) { while (af.nvls--) {
...@@ -1426,7 +1427,7 @@ int debuginfo__find_available_vars_at(struct debuginfo *self, ...@@ -1426,7 +1427,7 @@ int debuginfo__find_available_vars_at(struct debuginfo *self,
} }
/* Reverse search */ /* Reverse search */
int debuginfo__find_probe_point(struct debuginfo *self, unsigned long addr, int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
struct perf_probe_point *ppt) struct perf_probe_point *ppt)
{ {
Dwarf_Die cudie, spdie, indie; Dwarf_Die cudie, spdie, indie;
...@@ -1435,10 +1436,10 @@ int debuginfo__find_probe_point(struct debuginfo *self, unsigned long addr, ...@@ -1435,10 +1436,10 @@ int debuginfo__find_probe_point(struct debuginfo *self, unsigned long addr,
int baseline = 0, lineno = 0, ret = 0; int baseline = 0, lineno = 0, ret = 0;
/* Adjust address with bias */ /* Adjust address with bias */
addr += self->bias; addr += dbg->bias;
/* Find cu die */ /* Find cu die */
if (!dwarf_addrdie(self->dbg, (Dwarf_Addr)addr - self->bias, &cudie)) { if (!dwarf_addrdie(dbg->dbg, (Dwarf_Addr)addr - dbg->bias, &cudie)) {
pr_warning("Failed to find debug information for address %lx\n", pr_warning("Failed to find debug information for address %lx\n",
addr); addr);
ret = -EINVAL; ret = -EINVAL;
...@@ -1639,7 +1640,7 @@ static int find_line_range_by_func(struct line_finder *lf) ...@@ -1639,7 +1640,7 @@ static int find_line_range_by_func(struct line_finder *lf)
return param.retval; return param.retval;
} }
int debuginfo__find_line_range(struct debuginfo *self, struct line_range *lr) int debuginfo__find_line_range(struct debuginfo *dbg, struct line_range *lr)
{ {
struct line_finder lf = {.lr = lr, .found = 0}; struct line_finder lf = {.lr = lr, .found = 0};
int ret = 0; int ret = 0;
...@@ -1656,7 +1657,7 @@ int debuginfo__find_line_range(struct debuginfo *self, struct line_range *lr) ...@@ -1656,7 +1657,7 @@ int debuginfo__find_line_range(struct debuginfo *self, struct line_range *lr)
struct dwarf_callback_param line_range_param = { struct dwarf_callback_param line_range_param = {
.data = (void *)&lf, .retval = 0}; .data = (void *)&lf, .retval = 0};
dwarf_getpubnames(self->dbg, pubname_search_cb, dwarf_getpubnames(dbg->dbg, pubname_search_cb,
&pubname_param, 0); &pubname_param, 0);
if (pubname_param.found) { if (pubname_param.found) {
line_range_search_cb(&lf.sp_die, &line_range_param); line_range_search_cb(&lf.sp_die, &line_range_param);
...@@ -1667,12 +1668,12 @@ int debuginfo__find_line_range(struct debuginfo *self, struct line_range *lr) ...@@ -1667,12 +1668,12 @@ int debuginfo__find_line_range(struct debuginfo *self, struct line_range *lr)
/* Loop on CUs (Compilation Unit) */ /* Loop on CUs (Compilation Unit) */
while (!lf.found && ret >= 0) { while (!lf.found && ret >= 0) {
if (dwarf_nextcu(self->dbg, off, &noff, &cuhl, if (dwarf_nextcu(dbg->dbg, off, &noff, &cuhl,
NULL, NULL, NULL) != 0) NULL, NULL, NULL) != 0)
break; break;
/* Get the DIE(Debugging Information Entry) of this CU */ /* Get the DIE(Debugging Information Entry) of this CU */
diep = dwarf_offdie(self->dbg, off + cuhl, &lf.cu_die); diep = dwarf_offdie(dbg->dbg, off + cuhl, &lf.cu_die);
if (!diep) if (!diep)
continue; continue;
......
...@@ -31,25 +31,25 @@ struct debuginfo { ...@@ -31,25 +31,25 @@ struct debuginfo {
extern struct debuginfo *debuginfo__new(const char *path); extern struct debuginfo *debuginfo__new(const char *path);
extern struct debuginfo *debuginfo__new_online_kernel(unsigned long addr); extern struct debuginfo *debuginfo__new_online_kernel(unsigned long addr);
extern void debuginfo__delete(struct debuginfo *self); extern void debuginfo__delete(struct debuginfo *dbg);
/* Find probe_trace_events specified by perf_probe_event from debuginfo */ /* Find probe_trace_events specified by perf_probe_event from debuginfo */
extern int debuginfo__find_trace_events(struct debuginfo *self, extern int debuginfo__find_trace_events(struct debuginfo *dbg,
struct perf_probe_event *pev, struct perf_probe_event *pev,
struct probe_trace_event **tevs, struct probe_trace_event **tevs,
int max_tevs); int max_tevs);
/* Find a perf_probe_point from debuginfo */ /* Find a perf_probe_point from debuginfo */
extern int debuginfo__find_probe_point(struct debuginfo *self, extern int debuginfo__find_probe_point(struct debuginfo *dbg,
unsigned long addr, unsigned long addr,
struct perf_probe_point *ppt); struct perf_probe_point *ppt);
/* Find a line range */ /* Find a line range */
extern int debuginfo__find_line_range(struct debuginfo *self, extern int debuginfo__find_line_range(struct debuginfo *dbg,
struct line_range *lr); struct line_range *lr);
/* Find available variables */ /* Find available variables */
extern int debuginfo__find_available_vars_at(struct debuginfo *self, extern int debuginfo__find_available_vars_at(struct debuginfo *dbg,
struct perf_probe_event *pev, struct perf_probe_event *pev,
struct variable_list **vls, struct variable_list **vls,
int max_points, bool externs); int max_points, bool externs);
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
struct pstack; struct pstack;
struct pstack *pstack__new(unsigned short max_nr_entries); struct pstack *pstack__new(unsigned short max_nr_entries);
void pstack__delete(struct pstack *self); void pstack__delete(struct pstack *pstack);
bool pstack__empty(const struct pstack *self); bool pstack__empty(const struct pstack *pstack);
void pstack__remove(struct pstack *self, void *key); void pstack__remove(struct pstack *pstack, void *key);
void pstack__push(struct pstack *self, void *key); void pstack__push(struct pstack *pstack, void *key);
void *pstack__pop(struct pstack *self); void *pstack__pop(struct pstack *pstack);
#endif /* _PERF_PSTACK_ */ #endif /* _PERF_PSTACK_ */
...@@ -16,11 +16,11 @@ ...@@ -16,11 +16,11 @@
#include "perf_regs.h" #include "perf_regs.h"
#include "vdso.h" #include "vdso.h"
static int perf_session__open(struct perf_session *self) static int perf_session__open(struct perf_session *session)
{ {
struct perf_data_file *file = self->file; struct perf_data_file *file = session->file;
if (perf_session__read_header(self) < 0) { if (perf_session__read_header(session) < 0) {
pr_err("incompatible file format (rerun with -v to learn more)"); pr_err("incompatible file format (rerun with -v to learn more)");
return -1; return -1;
} }
...@@ -28,17 +28,17 @@ static int perf_session__open(struct perf_session *self) ...@@ -28,17 +28,17 @@ static int perf_session__open(struct perf_session *self)
if (perf_data_file__is_pipe(file)) if (perf_data_file__is_pipe(file))
return 0; return 0;
if (!perf_evlist__valid_sample_type(self->evlist)) { if (!perf_evlist__valid_sample_type(session->evlist)) {
pr_err("non matching sample_type"); pr_err("non matching sample_type");
return -1; return -1;
} }
if (!perf_evlist__valid_sample_id_all(self->evlist)) { if (!perf_evlist__valid_sample_id_all(session->evlist)) {
pr_err("non matching sample_id_all"); pr_err("non matching sample_id_all");
return -1; return -1;
} }
if (!perf_evlist__valid_read_format(self->evlist)) { if (!perf_evlist__valid_read_format(session->evlist)) {
pr_err("non matching read_format"); pr_err("non matching read_format");
return -1; return -1;
} }
...@@ -53,46 +53,45 @@ void perf_session__set_id_hdr_size(struct perf_session *session) ...@@ -53,46 +53,45 @@ void perf_session__set_id_hdr_size(struct perf_session *session)
machines__set_id_hdr_size(&session->machines, id_hdr_size); machines__set_id_hdr_size(&session->machines, id_hdr_size);
} }
int perf_session__create_kernel_maps(struct perf_session *self) int perf_session__create_kernel_maps(struct perf_session *session)
{ {
int ret = machine__create_kernel_maps(&self->machines.host); int ret = machine__create_kernel_maps(&session->machines.host);
if (ret >= 0) if (ret >= 0)
ret = machines__create_guest_kernel_maps(&self->machines); ret = machines__create_guest_kernel_maps(&session->machines);
return ret; return ret;
} }
static void perf_session__destroy_kernel_maps(struct perf_session *self) static void perf_session__destroy_kernel_maps(struct perf_session *session)
{ {
machines__destroy_kernel_maps(&self->machines); machines__destroy_kernel_maps(&session->machines);
} }
struct perf_session *perf_session__new(struct perf_data_file *file, struct perf_session *perf_session__new(struct perf_data_file *file,
bool repipe, struct perf_tool *tool) bool repipe, struct perf_tool *tool)
{ {
struct perf_session *self; struct perf_session *session = zalloc(sizeof(*session));
self = zalloc(sizeof(*self)); if (!session)
if (!self)
goto out; goto out;
self->repipe = repipe; session->repipe = repipe;
INIT_LIST_HEAD(&self->ordered_samples.samples); INIT_LIST_HEAD(&session->ordered_samples.samples);
INIT_LIST_HEAD(&self->ordered_samples.sample_cache); INIT_LIST_HEAD(&session->ordered_samples.sample_cache);
INIT_LIST_HEAD(&self->ordered_samples.to_free); INIT_LIST_HEAD(&session->ordered_samples.to_free);
machines__init(&self->machines); machines__init(&session->machines);
if (file) { if (file) {
if (perf_data_file__open(file)) if (perf_data_file__open(file))
goto out_delete; goto out_delete;
self->file = file; session->file = file;
if (perf_data_file__is_read(file)) { if (perf_data_file__is_read(file)) {
if (perf_session__open(self) < 0) if (perf_session__open(session) < 0)
goto out_close; goto out_close;
perf_session__set_id_hdr_size(self); perf_session__set_id_hdr_size(session);
} }
} }
...@@ -101,22 +100,22 @@ struct perf_session *perf_session__new(struct perf_data_file *file, ...@@ -101,22 +100,22 @@ struct perf_session *perf_session__new(struct perf_data_file *file,
* In O_RDONLY mode this will be performed when reading the * In O_RDONLY mode this will be performed when reading the
* kernel MMAP event, in perf_event__process_mmap(). * kernel MMAP event, in perf_event__process_mmap().
*/ */
if (perf_session__create_kernel_maps(self) < 0) if (perf_session__create_kernel_maps(session) < 0)
goto out_delete; goto out_delete;
} }
if (tool && tool->ordering_requires_timestamps && if (tool && tool->ordering_requires_timestamps &&
tool->ordered_samples && !perf_evlist__sample_id_all(self->evlist)) { tool->ordered_samples && !perf_evlist__sample_id_all(session->evlist)) {
dump_printf("WARNING: No sample_id_all support, falling back to unordered processing\n"); dump_printf("WARNING: No sample_id_all support, falling back to unordered processing\n");
tool->ordered_samples = false; tool->ordered_samples = false;
} }
return self; return session;
out_close: out_close:
perf_data_file__close(file); perf_data_file__close(file);
out_delete: out_delete:
perf_session__delete(self); perf_session__delete(session);
out: out:
return NULL; return NULL;
} }
...@@ -147,16 +146,16 @@ static void perf_session_env__delete(struct perf_session_env *env) ...@@ -147,16 +146,16 @@ static void perf_session_env__delete(struct perf_session_env *env)
free(env->pmu_mappings); free(env->pmu_mappings);
} }
void perf_session__delete(struct perf_session *self) void perf_session__delete(struct perf_session *session)
{ {
perf_session__destroy_kernel_maps(self); perf_session__destroy_kernel_maps(session);
perf_session__delete_dead_threads(self); perf_session__delete_dead_threads(session);
perf_session__delete_threads(self); perf_session__delete_threads(session);
perf_session_env__delete(&self->header.env); perf_session_env__delete(&session->header.env);
machines__exit(&self->machines); machines__exit(&session->machines);
if (self->file) if (session->file)
perf_data_file__close(self->file); perf_data_file__close(session->file);
free(self); free(session);
vdso__exit(); vdso__exit();
} }
...@@ -1084,11 +1083,11 @@ static int perf_session__process_event(struct perf_session *session, ...@@ -1084,11 +1083,11 @@ static int perf_session__process_event(struct perf_session *session,
file_offset); file_offset);
} }
void perf_event_header__bswap(struct perf_event_header *self) void perf_event_header__bswap(struct perf_event_header *hdr)
{ {
self->type = bswap_32(self->type); hdr->type = bswap_32(hdr->type);
self->misc = bswap_16(self->misc); hdr->misc = bswap_16(hdr->misc);
self->size = bswap_16(self->size); hdr->size = bswap_16(hdr->size);
} }
struct thread *perf_session__findnew(struct perf_session *session, pid_t pid) struct thread *perf_session__findnew(struct perf_session *session, pid_t pid)
...@@ -1096,9 +1095,9 @@ struct thread *perf_session__findnew(struct perf_session *session, pid_t pid) ...@@ -1096,9 +1095,9 @@ struct thread *perf_session__findnew(struct perf_session *session, pid_t pid)
return machine__findnew_thread(&session->machines.host, 0, pid); return machine__findnew_thread(&session->machines.host, 0, pid);
} }
static struct thread *perf_session__register_idle_thread(struct perf_session *self) static struct thread *perf_session__register_idle_thread(struct perf_session *session)
{ {
struct thread *thread = perf_session__findnew(self, 0); struct thread *thread = perf_session__findnew(session, 0);
if (thread == NULL || thread__set_comm(thread, "swapper", 0)) { if (thread == NULL || thread__set_comm(thread, "swapper", 0)) {
pr_err("problem inserting idle task.\n"); pr_err("problem inserting idle task.\n");
...@@ -1150,10 +1149,10 @@ static void perf_session__warn_about_errors(const struct perf_session *session, ...@@ -1150,10 +1149,10 @@ static void perf_session__warn_about_errors(const struct perf_session *session,
volatile int session_done; volatile int session_done;
static int __perf_session__process_pipe_events(struct perf_session *self, static int __perf_session__process_pipe_events(struct perf_session *session,
struct perf_tool *tool) struct perf_tool *tool)
{ {
int fd = perf_data_file__fd(self->file); int fd = perf_data_file__fd(session->file);
union perf_event *event; union perf_event *event;
uint32_t size, cur_size = 0; uint32_t size, cur_size = 0;
void *buf = NULL; void *buf = NULL;
...@@ -1181,7 +1180,7 @@ static int __perf_session__process_pipe_events(struct perf_session *self, ...@@ -1181,7 +1180,7 @@ static int __perf_session__process_pipe_events(struct perf_session *self,
goto out_err; goto out_err;
} }
if (self->header.needs_swap) if (session->header.needs_swap)
perf_event_header__bswap(&event->header); perf_event_header__bswap(&event->header);
size = event->header.size; size = event->header.size;
...@@ -1216,7 +1215,7 @@ static int __perf_session__process_pipe_events(struct perf_session *self, ...@@ -1216,7 +1215,7 @@ static int __perf_session__process_pipe_events(struct perf_session *self,
} }
} }
if ((skip = perf_session__process_event(self, event, tool, head)) < 0) { if ((skip = perf_session__process_event(session, event, tool, head)) < 0) {
pr_err("%#" PRIx64 " [%#x]: failed to process type: %d\n", pr_err("%#" PRIx64 " [%#x]: failed to process type: %d\n",
head, event->header.size, event->header.type); head, event->header.size, event->header.type);
err = -EINVAL; err = -EINVAL;
...@@ -1232,12 +1231,12 @@ static int __perf_session__process_pipe_events(struct perf_session *self, ...@@ -1232,12 +1231,12 @@ static int __perf_session__process_pipe_events(struct perf_session *self,
goto more; goto more;
done: done:
/* do the final flush for ordered samples */ /* do the final flush for ordered samples */
self->ordered_samples.next_flush = ULLONG_MAX; session->ordered_samples.next_flush = ULLONG_MAX;
err = flush_sample_queue(self, tool); err = flush_sample_queue(session, tool);
out_err: out_err:
free(buf); free(buf);
perf_session__warn_about_errors(self, tool); perf_session__warn_about_errors(session, tool);
perf_session_free_sample_buffers(self); perf_session_free_sample_buffers(session);
return err; return err;
} }
...@@ -1377,22 +1376,22 @@ int __perf_session__process_events(struct perf_session *session, ...@@ -1377,22 +1376,22 @@ int __perf_session__process_events(struct perf_session *session,
return err; return err;
} }
int perf_session__process_events(struct perf_session *self, int perf_session__process_events(struct perf_session *session,
struct perf_tool *tool) struct perf_tool *tool)
{ {
u64 size = perf_data_file__size(self->file); u64 size = perf_data_file__size(session->file);
int err; int err;
if (perf_session__register_idle_thread(self) == NULL) if (perf_session__register_idle_thread(session) == NULL)
return -ENOMEM; return -ENOMEM;
if (!perf_data_file__is_pipe(self->file)) if (!perf_data_file__is_pipe(session->file))
err = __perf_session__process_events(self, err = __perf_session__process_events(session,
self->header.data_offset, session->header.data_offset,
self->header.data_size, session->header.data_size,
size, tool); size, tool);
else else
err = __perf_session__process_pipe_events(self, tool); err = __perf_session__process_pipe_events(session, tool);
return err; return err;
} }
...@@ -1441,15 +1440,15 @@ int maps__set_kallsyms_ref_reloc_sym(struct map **maps, ...@@ -1441,15 +1440,15 @@ int maps__set_kallsyms_ref_reloc_sym(struct map **maps,
return 0; return 0;
} }
size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp) size_t perf_session__fprintf_dsos(struct perf_session *session, FILE *fp)
{ {
return machines__fprintf_dsos(&self->machines, fp); return machines__fprintf_dsos(&session->machines, fp);
} }
size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp, size_t perf_session__fprintf_dsos_buildid(struct perf_session *session, FILE *fp,
bool (skip)(struct dso *dso, int parm), int parm) bool (skip)(struct dso *dso, int parm), int parm)
{ {
return machines__fprintf_dsos_buildid(&self->machines, fp, skip, parm); return machines__fprintf_dsos_buildid(&session->machines, fp, skip, parm);
} }
size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp) size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp)
......
...@@ -51,12 +51,12 @@ struct perf_session *perf_session__new(struct perf_data_file *file, ...@@ -51,12 +51,12 @@ struct perf_session *perf_session__new(struct perf_data_file *file,
bool repipe, struct perf_tool *tool); bool repipe, struct perf_tool *tool);
void perf_session__delete(struct perf_session *session); void perf_session__delete(struct perf_session *session);
void perf_event_header__bswap(struct perf_event_header *self); void perf_event_header__bswap(struct perf_event_header *hdr);
int __perf_session__process_events(struct perf_session *self, int __perf_session__process_events(struct perf_session *session,
u64 data_offset, u64 data_size, u64 size, u64 data_offset, u64 data_size, u64 size,
struct perf_tool *tool); struct perf_tool *tool);
int perf_session__process_events(struct perf_session *self, int perf_session__process_events(struct perf_session *session,
struct perf_tool *tool); struct perf_tool *tool);
int perf_session_queue_event(struct perf_session *s, union perf_event *event, int perf_session_queue_event(struct perf_session *s, union perf_event *event,
...@@ -64,37 +64,38 @@ int perf_session_queue_event(struct perf_session *s, union perf_event *event, ...@@ -64,37 +64,38 @@ int perf_session_queue_event(struct perf_session *s, union perf_event *event,
void perf_tool__fill_defaults(struct perf_tool *tool); void perf_tool__fill_defaults(struct perf_tool *tool);
int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel *evsel, int perf_session__resolve_callchain(struct perf_session *session,
struct perf_evsel *evsel,
struct thread *thread, struct thread *thread,
struct ip_callchain *chain, struct ip_callchain *chain,
struct symbol **parent); struct symbol **parent);
bool perf_session__has_traces(struct perf_session *self, const char *msg); bool perf_session__has_traces(struct perf_session *session, const char *msg);
void mem_bswap_64(void *src, int byte_size); void mem_bswap_64(void *src, int byte_size);
void mem_bswap_32(void *src, int byte_size); void mem_bswap_32(void *src, int byte_size);
void perf_event__attr_swap(struct perf_event_attr *attr); void perf_event__attr_swap(struct perf_event_attr *attr);
int perf_session__create_kernel_maps(struct perf_session *self); int perf_session__create_kernel_maps(struct perf_session *session);
void perf_session__set_id_hdr_size(struct perf_session *session); void perf_session__set_id_hdr_size(struct perf_session *session);
static inline static inline
struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid) struct machine *perf_session__find_machine(struct perf_session *session, pid_t pid)
{ {
return machines__find(&self->machines, pid); return machines__find(&session->machines, pid);
} }
static inline static inline
struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t pid) struct machine *perf_session__findnew_machine(struct perf_session *session, pid_t pid)
{ {
return machines__findnew(&self->machines, pid); return machines__findnew(&session->machines, pid);
} }
struct thread *perf_session__findnew(struct perf_session *self, pid_t pid); struct thread *perf_session__findnew(struct perf_session *session, pid_t pid);
size_t perf_session__fprintf(struct perf_session *self, FILE *fp); size_t perf_session__fprintf(struct perf_session *session, FILE *fp);
size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp); size_t perf_session__fprintf_dsos(struct perf_session *session, FILE *fp);
size_t perf_session__fprintf_dsos_buildid(struct perf_session *session, FILE *fp, size_t perf_session__fprintf_dsos_buildid(struct perf_session *session, FILE *fp,
bool (fn)(struct dso *dso, int parm), int parm); bool (fn)(struct dso *dso, int parm), int parm);
......
...@@ -180,7 +180,7 @@ struct sort_entry { ...@@ -180,7 +180,7 @@ struct sort_entry {
int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *); int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *);
int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *); int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *);
int (*se_snprintf)(struct hist_entry *self, char *bf, size_t size, int (*se_snprintf)(struct hist_entry *he, char *bf, size_t size,
unsigned int width); unsigned int width);
u8 se_width_idx; u8 se_width_idx;
bool elide; bool elide;
......
...@@ -62,15 +62,15 @@ static struct strfilter_node *strfilter_node__alloc(const char *op, ...@@ -62,15 +62,15 @@ static struct strfilter_node *strfilter_node__alloc(const char *op,
struct strfilter_node *l, struct strfilter_node *l,
struct strfilter_node *r) struct strfilter_node *r)
{ {
struct strfilter_node *ret = zalloc(sizeof(struct strfilter_node)); struct strfilter_node *node = zalloc(sizeof(*node));
if (ret) { if (node) {
ret->p = op; node->p = op;
ret->l = l; node->l = l;
ret->r = r; node->r = r;
} }
return ret; return node;
} }
static struct strfilter_node *strfilter_node__new(const char *s, static struct strfilter_node *strfilter_node__new(const char *s,
...@@ -154,20 +154,20 @@ static struct strfilter_node *strfilter_node__new(const char *s, ...@@ -154,20 +154,20 @@ static struct strfilter_node *strfilter_node__new(const char *s,
*/ */
struct strfilter *strfilter__new(const char *rules, const char **err) struct strfilter *strfilter__new(const char *rules, const char **err)
{ {
struct strfilter *ret = zalloc(sizeof(struct strfilter)); struct strfilter *filter = zalloc(sizeof(*filter));
const char *ep = NULL; const char *ep = NULL;
if (ret) if (filter)
ret->root = strfilter_node__new(rules, &ep); filter->root = strfilter_node__new(rules, &ep);
if (!ret || !ret->root || *ep != '\0') { if (!filter || !filter->root || *ep != '\0') {
if (err) if (err)
*err = ep; *err = ep;
strfilter__delete(ret); strfilter__delete(filter);
ret = NULL; filter = NULL;
} }
return ret; return filter;
} }
static bool strfilter_node__compare(struct strfilter_node *node, static bool strfilter_node__compare(struct strfilter_node *node,
...@@ -191,9 +191,9 @@ static bool strfilter_node__compare(struct strfilter_node *node, ...@@ -191,9 +191,9 @@ static bool strfilter_node__compare(struct strfilter_node *node,
} }
/* Return true if STR matches the filter rules */ /* Return true if STR matches the filter rules */
bool strfilter__compare(struct strfilter *node, const char *str) bool strfilter__compare(struct strfilter *filter, const char *str)
{ {
if (!node) if (!filter)
return false; return false;
return strfilter_node__compare(node->root, str); return strfilter_node__compare(filter->root, str);
} }
...@@ -30,19 +30,19 @@ struct strfilter *strfilter__new(const char *rules, const char **err); ...@@ -30,19 +30,19 @@ struct strfilter *strfilter__new(const char *rules, const char **err);
/** /**
* strfilter__compare - compare given string and a string filter * strfilter__compare - compare given string and a string filter
* @self: String filter * @filter: String filter
* @str: target string * @str: target string
* *
* Compare @str and @self. Return true if the str match the rule * Compare @str and @filter. Return true if the str match the rule
*/ */
bool strfilter__compare(struct strfilter *self, const char *str); bool strfilter__compare(struct strfilter *filter, const char *str);
/** /**
* strfilter__delete - delete a string filter * strfilter__delete - delete a string filter
* @self: String filter to delete * @filter: String filter to delete
* *
* Delete @self. * Delete @filter.
*/ */
void strfilter__delete(struct strfilter *self); void strfilter__delete(struct strfilter *filter);
#endif #endif
...@@ -29,24 +29,24 @@ struct machine; ...@@ -29,24 +29,24 @@ struct machine;
struct comm; struct comm;
struct thread *thread__new(pid_t pid, pid_t tid); struct thread *thread__new(pid_t pid, pid_t tid);
void thread__delete(struct thread *self); void thread__delete(struct thread *thread);
static inline void thread__exited(struct thread *thread) static inline void thread__exited(struct thread *thread)
{ {
thread->dead = true; thread->dead = true;
} }
int thread__set_comm(struct thread *thread, const char *comm, u64 timestamp); int thread__set_comm(struct thread *thread, const char *comm, u64 timestamp);
int thread__comm_len(struct thread *self); int thread__comm_len(struct thread *thread);
struct comm *thread__comm(const struct thread *thread); struct comm *thread__comm(const struct thread *thread);
const char *thread__comm_str(const struct thread *thread); const char *thread__comm_str(const struct thread *thread);
void thread__insert_map(struct thread *self, struct map *map); void thread__insert_map(struct thread *thread, struct map *map);
int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp); int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp);
size_t thread__fprintf(struct thread *thread, FILE *fp); size_t thread__fprintf(struct thread *thread, FILE *fp);
static inline struct map *thread__find_map(struct thread *self, static inline struct map *thread__find_map(struct thread *thread,
enum map_type type, u64 addr) enum map_type type, u64 addr)
{ {
return self ? map_groups__find(&self->mg, type, addr) : NULL; return thread ? map_groups__find(&thread->mg, type, addr) : NULL;
} }
void thread__find_addr_map(struct thread *thread, struct machine *machine, void thread__find_addr_map(struct thread *thread, struct machine *machine,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment