3 # SPDX-FileCopyrightText: 2018 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
5 # SPDX-License-Identifier: GPL-2.0-or-later
9 # Add the file passed as $1 to the list of files to collect.
11 # If that file is a symlink, follow it and collect the target, recursively.
12 function collect_recursive
16 if [ -f "$file_to_collect" ]; then
17 echo "$file_to_collect" >> "$file_list"
19 if [ -L "$file_to_collect" ]; then
20 collect_recursive
"$(readlink "$file_to_collect")"
26 file_list
=$
(mktemp
-t "postbuild_file_list.XXXXXX")
29 # WORKSPACE is normally set by Jenkins. Use the current directory otherwise,
30 # like when testing this script manually.
31 WORKSPACE
=${WORKSPACE:-$PWD}
33 lttng_processes
="$(pgrep -l 'lttng|gen-ust-.+')" || true
34 if [ -n "$lttng_processes" ]; then
36 echo "The following LTTng processes were detected running on the system and will be aborted:"
37 echo "$lttng_processes"
39 # Build the pids array
42 done < <(cut
-d ' ' -f 1 <<< "$lttng_processes")
44 # Abort the leftover processes to generate core files
45 kill -SIGSTOP "${pids[@]}"
46 kill -SIGABRT "${pids[@]}"
47 kill -SIGCONT "${pids[@]}"
49 # Exit with failure when leftover processes are found
53 # For each core file...
54 while read -r core_file
; do
57 # Make sure the coredump is finished using fuser
58 while fuser
"$core_file"; do
62 # Skip the core file if it takes more than 30 seconds
63 if [ "$sleep_count" -ge 30 ]; then
68 # Print a full backtrace of all threads
69 if command -v gdb
>/dev
/null
2>&1; then
70 gdb
-nh -c "$core_file" -ex "thread apply all bt full" -ex q
73 # Collect everything in the core file that looks like a reference to a
75 strings "$core_file" |
grep '^/.*\.so.*' |
while read -r str
; do
76 collect_recursive
"$str"
79 echo "$core_file" >> "$file_list"
81 # Exit with failure when core files are found
83 done < <(find "/tmp" -maxdepth 1 -name "core\.[0-9]*" -type f
2>/dev
/null
)
85 # If we recorded some files to collect, pack them up.
86 if [ -s "$file_list" ]; then
87 mkdir
-p "${WORKSPACE}/build"
88 tar cJfh
"${WORKSPACE}/build/core.tar.xz" -T <(sort "$file_list" |
uniq)
92 find "/tmp" -maxdepth 1 -name "core\.[0-9]*" -type f
-delete || true
This page took 0.030153 seconds and 4 git commands to generate.