… | |
… | |
87 | my ($cmd) = @_; |
87 | my ($cmd) = @_; |
88 | |
88 | |
89 | $cmd =~ s/[\012\015]$//; |
89 | $cmd =~ s/[\012\015]$//; |
90 | |
90 | |
91 | if ($cmd =~ /^ps/) { |
91 | if ($cmd =~ /^ps/) { |
92 | printf "%20s %s%s%s%s %4s %-20.20s %s\n", "pid", "R", "U", "N", "D", "RSS", "description", "where"; |
92 | printf "%20s %s%s %4s %-20.20s %s\n", "pid", "S", "S", "RSS", "description", "where"; |
93 | for my $coro (Coro::State::list) { |
93 | for my $coro (Coro::State::list) { |
94 | Coro::cede; |
94 | Coro::cede; |
95 | my @bt; |
95 | my @bt; |
96 | $coro->_eval (sub { |
96 | $coro->_eval (sub { |
97 | # we try to find *the* definite frame that gives msot useful info |
97 | # we try to find *the* definite frame that gives msot useful info |
… | |
… | |
100 | my @frame = caller $frame; |
100 | my @frame = caller $frame; |
101 | @bt = @frame if $frame[2]; |
101 | @bt = @frame if $frame[2]; |
102 | last unless $bt[0] =~ /^Coro/; |
102 | last unless $bt[0] =~ /^Coro/; |
103 | } |
103 | } |
104 | }); |
104 | }); |
105 | printf "%20s %s%s%s%s %4d %-20.20s %s\n", |
105 | printf "%20s %s%s %4d %-20.20s %s\n", |
106 | $coro+0, |
106 | $coro+0, |
107 | $coro->is_ready ? "R" : "-", |
107 | $coro->is_new ? "N" : $coro->is_running ? "U" : $coro->is_ready ? "R" : "-", |
108 | $coro->is_running ? "U" : "-", |
|
|
109 | $coro->is_new ? "N" : "-", |
|
|
110 | $coro->is_destroyed ? "D" : "-", |
108 | $coro->has_stack ? "S" : "-", |
111 | $coro->rss / 1024, |
109 | $coro->rss / 1024, |
112 | $coro->debug_desc, |
110 | $coro->debug_desc, |
113 | (@bt ? sprintf "[%s:%d]", $bt[1], $bt[2] : "-"); |
111 | (@bt ? sprintf "[%s:%d]", $bt[1], $bt[2] : "-"); |
114 | } |
112 | } |
115 | |
113 | |