Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169633
b: refs/heads/master
c: 3b6ed98
h: refs/heads/master
i:
  169631: b5d4487
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo authored and Ingo Molnar committed Nov 17, 2009
1 parent 0574b21 commit a29e2b3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 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: dc79c0fc08a94b857aed446bfb47cdfde529400c
refs/heads/master: 3b6ed98895b0fccd8c387f3fc44016fb922c0658
42 changes: 41 additions & 1 deletion trunk/tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static int system_wide = 0;
static int default_interval = 0;

static int count_filter = 5;
static int print_entries = 15;
static int print_entries;

static int target_pid = -1;
static int inherit = 0;
Expand Down Expand Up @@ -115,6 +115,36 @@ struct sym_entry {
* Source functions
*/

/* most GUI terminals set LINES (although some don't export it) */
static int term_rows(void)
{
char *lines_string = getenv("LINES");
int n_lines;

if (lines_string && (n_lines = atoi(lines_string)) > 0)
return n_lines;
#ifdef TIOCGWINSZ
else {
struct winsize ws;
if (!ioctl(1, TIOCGWINSZ, &ws) && ws.ws_row)
return ws.ws_row;
}
#endif
return 25;
}

static void update_print_entries(void)
{
print_entries = term_rows();
if (print_entries > 9)
print_entries -= 9;
}

static void sig_winch_handler(int sig __used)
{
update_print_entries();
}

static void parse_source(struct sym_entry *syme)
{
struct symbol *sym;
Expand Down Expand Up @@ -668,6 +698,11 @@ static void handle_keypress(int c)
break;
case 'e':
prompt_integer(&print_entries, "Enter display entries (lines)");
if (print_entries == 0) {
update_print_entries();
signal(SIGWINCH, sig_winch_handler);
} else
signal(SIGWINCH, SIG_DFL);
break;
case 'E':
if (nr_counters > 1) {
Expand Down Expand Up @@ -1228,5 +1263,10 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
if (target_pid != -1 || profile_cpu != -1)
nr_cpus = 1;

if (print_entries == 0) {
update_print_entries();
signal(SIGWINCH, sig_winch_handler);
}

return __cmd_top();
}

0 comments on commit a29e2b3

Please sign in to comment.