Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 288737
b: refs/heads/master
c: 24bff2d
h: refs/heads/master
i:
  288735: 373226b
v: v3
  • Loading branch information
Stephane Eranian authored and Ingo Molnar committed Mar 12, 2012
1 parent 916ec8d commit 1ec8023
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8bcd65fd29e9abfb633bfd6eedaf24b22e211f3a
refs/heads/master: 24bff2dc0f77b1f186b7bdf30060caf3df191a68
38 changes: 31 additions & 7 deletions trunk/tools/perf/util/ui/browsers/hists.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,16 @@ static int hists__browser_title(struct hists *self, char *bf, size_t size,
return printed;
}

static inline void free_popup_options(char **options, int n)
{
int i;

for (i = 0; i < n; ++i) {
free(options[i]);
options[i] = NULL;
}
}

static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
const char *helpline, const char *ev_name,
bool left_exits,
Expand All @@ -866,6 +876,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
struct hist_browser *browser = hist_browser__new(self);
struct branch_info *bi;
struct pstack *fstack;
char *options[16];
int nr_options = 0;
int key = -1;

if (browser == NULL)
Expand All @@ -877,14 +889,17 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,

ui_helpline__push(helpline);

memset(options, 0, sizeof(options));

while (1) {
const struct thread *thread = NULL;
const struct dso *dso = NULL;
char *options[16];
int nr_options = 0, choice = 0, i,
int choice = 0,
annotate = -2, zoom_dso = -2, zoom_thread = -2,
annotate_f = -2, annotate_t = -2, browse_map = -2;

nr_options = 0;

key = hist_browser__run(browser, ev_name, timer, arg, delay_secs);

if (browser->he_selection != NULL) {
Expand Down Expand Up @@ -1023,17 +1038,16 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
browse_map = nr_options++;
add_exit_option:
options[nr_options++] = (char *)"Exit";

retry_popup_menu:
choice = ui__popup_menu(nr_options, options);

for (i = 0; i < nr_options - 1; ++i)
free(options[i]);

if (choice == nr_options - 1)
break;

if (choice == -1)
if (choice == -1) {
free_popup_options(options, nr_options - 1);
continue;
}

if (choice == annotate || choice == annotate_t || choice == annotate_f) {
struct hist_entry *he;
Expand Down Expand Up @@ -1064,9 +1078,18 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
err = hist_entry__tui_annotate(he, evsel->idx,
timer, arg, delay_secs);
he->used = false;
/*
* offer option to annotate the other branch source or target
* (if they exists) when returning from annotate
*/
if ((err == 'q' || err == CTRL('c'))
&& annotate_t != -2 && annotate_f != -2)
goto retry_popup_menu;

ui_browser__update_nr_entries(&browser->b, browser->hists->nr_entries);
if (err)
ui_browser__handle_resize(&browser->b);

} else if (choice == browse_map)
map__browse(browser->selection->map);
else if (choice == zoom_dso) {
Expand Down Expand Up @@ -1112,6 +1135,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
pstack__delete(fstack);
out:
hist_browser__delete(browser);
free_popup_options(options, nr_options - 1);
return key;
}

Expand Down

0 comments on commit 1ec8023

Please sign in to comment.