forked from nanocurrency/nano-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
124421b
commit fc5977a
Showing
2 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,42 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
set -uo pipefail | ||
|
||
source "$(dirname "$BASH_SOURCE")/common.sh" | ||
|
||
# Ensure directory exists and is writable for core dumps | ||
CORE_DIR="/cores" | ||
sudo mkdir -p "${CORE_DIR}" | ||
sudo chmod a+w "${CORE_DIR}" | ||
|
||
# Enable core dumps | ||
ulimit -c unlimited | ||
echo "${CORE_DIR}/coredump-%e.%p" | sudo tee /proc/sys/kernel/core_pattern | ||
|
||
BUILD_DIR=${1-${PWD}} | ||
|
||
${BUILD_DIR}/core_test$(get_exec_extension) | ||
executable=${BUILD_DIR}/core_test$(get_exec_extension) | ||
"${executable}" | ||
|
||
status=$? | ||
if [ $status -ne 0 ]; then | ||
echo "Test failed" | ||
|
||
# Print location of core dump loaded from the system config | ||
echo "Core dump location: $(cat /proc/sys/kernel/core_pattern)" | ||
|
||
# List core dump files | ||
echo "Core dump files:" | ||
ls -l "${CORE_DIR}" | ||
|
||
# Find the most recent core dump | ||
core_dump=$(find "${CORE_DIR}" -name 'coredump-*' -printf "%T+ %p\n" | sort -r | head -n 1 | cut -d" " -f2-) | ||
|
||
if [ -n "$core_dump" ]; then | ||
echo "Analyzing core dump: $core_dump" | ||
|
||
# Use gdb to print the backtrace from the core dump | ||
gdb -quiet -batch -ex "thread apply all bt full" -ex "quit" "${executable}" "${core_dump}" | ||
else | ||
echo "No core dump file found." | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters