Blame extras/identify-hangs.sh

Packit Service a90fdc
#!/bin/bash
Packit Service a90fdc
function get_statedump_fnames_without_timestamps
Packit Service a90fdc
{
Packit Service a90fdc
    ls | grep -E "[.]dump[.][0-9][0-9]*" | cut -f1-3 -d'.' | sort -u
Packit Service a90fdc
}
Packit Service a90fdc
Packit Service a90fdc
function get_non_uniq_fields
Packit Service a90fdc
{
Packit Service a90fdc
    local statedump_fname_prefix=$1
Packit Service a90fdc
    print_stack_lkowner_unique_in_one_line "$statedump_fname_prefix" | sort | uniq -c | grep -vE "^\s*1 " | awk '{$1="repeats="$1; print $0}'
Packit Service a90fdc
}
Packit Service a90fdc
Packit Service a90fdc
function print_stack_lkowner_unique_in_one_line
Packit Service a90fdc
{
Packit Service a90fdc
    local statedump_fname_prefix=$1
Packit Service a90fdc
    sed -e '/./{H;$!d;}' -e 'x;/unique=/!d;/stack=/!d;/lk-owner=/!d;/pid=/!d;' "${statedump_fname_prefix}"* | grep -E "(stack|lk-owner|unique|pid)=" | paste -d " " - - - -
Packit Service a90fdc
}
Packit Service a90fdc
Packit Service a90fdc
function get_stacks_that_appear_in_multiple_statedumps
Packit Service a90fdc
{
Packit Service a90fdc
    #If a stack with same 'unique/lk-owner/stack' appears in multiple statedumps
Packit Service a90fdc
    #print the stack
Packit Service a90fdc
    local statedump_fname_prefix=$1
Packit Service a90fdc
    while read -r non_uniq_stack;
Packit Service a90fdc
    do
Packit Service a90fdc
        if [ -z "$printed" ];
Packit Service a90fdc
        then
Packit Service a90fdc
            printed="1"
Packit Service a90fdc
        fi
Packit Service a90fdc
        echo "$statedump_fname_prefix" "$non_uniq_stack"
Packit Service a90fdc
    done < <(get_non_uniq_fields "$statedump_fname_prefix")
Packit Service a90fdc
}
Packit Service a90fdc
Packit Service a90fdc
statedumpdir=${1}
Packit Service a90fdc
if [ -z "$statedumpdir" ];
Packit Service a90fdc
then
Packit Service a90fdc
    echo "Usage: $0 <statedump-dir>"
Packit Service a90fdc
    exit 1
Packit Service a90fdc
fi
Packit Service a90fdc
Packit Service a90fdc
if [ ! -d "$statedumpdir" ];
Packit Service a90fdc
then
Packit Service a90fdc
    echo "$statedumpdir: Is not a directory"
Packit Service a90fdc
    echo "Usage: $0 <statedump-dir>"
Packit Service a90fdc
    exit 1
Packit Service a90fdc
fi
Packit Service a90fdc
Packit Service a90fdc
cd "$statedumpdir" || exit 1
Packit Service a90fdc
for statedump_fname_prefix in $(get_statedump_fnames_without_timestamps);
Packit Service a90fdc
do
Packit Service a90fdc
    get_stacks_that_appear_in_multiple_statedumps "$statedump_fname_prefix"
Packit Service a90fdc
done | column -t
Packit Service a90fdc
echo "NOTE: stacks with lk-owner=\"\"/lk-owner=0000000000000000/unique=0 may not be hung frames and need further inspection" >&2