# # ############################## executable=$(which SecondoBDB) VALGRIND_STD_OPTIONS=" --num-callers=25 --suppressions=vgs.txt --error-limit=no --smc-check=all --track-origins=yes" if [ "$1" == "--valgrind" ]; then shift runner="valgrind $VALGRIND_STD_OPTIONS $executable" else if [ "$1" == "--valgrindlc" ]; then shift runner="valgrind $VALGRIND_STD_OPTIONS --leak-check=full $executable" else if [ "$1" == "--profile" ]; then shift runner="valgrind --tool=callgrind --dump-instr=yes --trace-jump=yes $executable" else runner=$executable fi fi fi # Redirecting stack trace output if mktemp exists if hash mktemp 2> /dev/null; then stacktrace_output=$(mktemp) echo "Redirecting stack trace to: $stacktrace_output" export SEGFAULT_OUTPUT_NAME=$stacktrace_output fi # Run SECONDO $runner $* # stacktrace_output was set, check content of the file if [ -n "$stacktrace_output" ] ; then # Print stack trace, if secondo has crashed if [ -s "$stacktrace_output" ] ; then echo -e "\n" echo "========" echo "SECONDO has crashed, printing stack trace...." echo "========" echo -e "\n" cat $stacktrace_output # Convert addresses to lines if addr2line is available if hash addr2line 2> /dev/null ; then lines="" echo -e "\n" echo "========" echo " Trying to decode the stacktrace..." echo "========" echo -e "\n" # Get relocation if available if [ $(cat $stacktrace_output | grep "Binary relocation:" | wc -l) -gt 0 ]; then binary_relocation=$(cat $stacktrace_output | grep "Binary relocation:" | cut -d ":" -f 2) else binary_relocation="0x0" fi # Extract and collect addresses stacktrace=$(cat $stacktrace_output | grep "0x") for line in $stacktrace; do if [ $(echo $line | grep "\[" | wc -l) -eq 0 ]; then continue fi addr=$(echo $line | cut -d "[" -f 2 | sed s/]//g) printf -v raddr "0x%X" $(($addr - $binary_relocation)) lines="$lines $raddr" done addr2line --demangle=auto -p -fs -e $runner $lines fi echo "========" fi rm $stacktrace_output fi