diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/rocksdb/build_tools/ps_with_stack | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/rocksdb/build_tools/ps_with_stack')
-rwxr-xr-x | src/rocksdb/build_tools/ps_with_stack | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/rocksdb/build_tools/ps_with_stack b/src/rocksdb/build_tools/ps_with_stack new file mode 100755 index 000000000..ee4256965 --- /dev/null +++ b/src/rocksdb/build_tools/ps_with_stack @@ -0,0 +1,38 @@ +#!/usr/bin/env perl + +use strict; + +open(my $ps, "-|", "ps -wwf"); +my $cols_known = 0; +my $cmd_col = 0; +my $pid_col = 0; +while (<$ps>) { + print; + my @cols = split(/\s+/); + + if (!$cols_known && /CMD/) { + # Parse relevant ps column headers + for (my $i = 0; $i <= $#cols; $i++) { + if ($cols[$i] eq "CMD") { + $cmd_col = $i; + } + if ($cols[$i] eq "PID") { + $pid_col = $i; + } + } + $cols_known = 1; + } else { + my $pid = $cols[$pid_col]; + my $cmd = $cols[$cmd_col]; + # Match numeric PID and relative path command + # -> The intention is only to dump stack traces for hangs in code under + # test, which means we probably just built it and are executing by + # relative path (e.g. ./my_test or foo/bar_test) rather then by absolute + # path (e.g. /usr/bin/time) or PATH search (e.g. grep). + if ($pid =~ /^[0-9]+$/ && $cmd =~ /^[^\/ ]+[\/]/) { + print "Dumping stacks for $pid...\n"; + system("pstack $pid || gdb -batch -p $pid -ex 'thread apply all bt'"); + } + } +} +close $ps; |