mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-08 05:26:58 +02:00
Currently, the scripts in src/scripts have multiple implementations for handling when common.sh fails to load, some of which are buggy. To simplify the boilerplate, these scripts now just exit if common.sh fails to load. The shell itself will print the following message if common.sh is not found: /usr/lib/crosutils/common.sh: No such file or directory BUG=chromium-os:32442 TEST=Run these scripts with and without common.sh installed. Change-Id: Ie54420b6c649774f9cb039c14c80f4cf6c6ebc07 Reviewed-on: https://gerrit.chromium.org/gerrit/27058 Reviewed-by: David James <davidjames@chromium.org> Tested-by: David James <davidjames@chromium.org> Commit-Ready: David James <davidjames@chromium.org>
79 lines
1.8 KiB
Bash
Executable File
79 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
# Script to generate stackdumps from BVT failures.
|
|
|
|
# This can only run inside the chroot since we need minidump_stackwalk.
|
|
. "$(dirname $0)/common.sh" || exit 1
|
|
assert_inside_chroot "$@"
|
|
|
|
usage() {
|
|
echo "Usage: $0 url_or_path_to_debug_tgz url_to_bvt_test_results"
|
|
}
|
|
|
|
if [ -z "$1" ] ; then
|
|
usage
|
|
die_notrace "The URL or path to symbols tarball (debug.tgz) is required"
|
|
fi
|
|
|
|
if [ -z "$2" ] ; then
|
|
usage
|
|
die_notrace "The URL to BVT test results is required"
|
|
fi
|
|
|
|
# Die on any errors.
|
|
switch_to_strict_mode
|
|
|
|
BREAKPAD_DIR="debug/breakpad"
|
|
STACKS_GENERATED=""
|
|
OUTPUT_DIR="$(mktemp -d)"
|
|
|
|
extract_tarball() {
|
|
info "Extracting breakpad symbols from $1..."
|
|
tar zxf "$1" -C "${OUTPUT_DIR}" "${BREAKPAD_DIR}"
|
|
}
|
|
|
|
generate_stacktrace() {
|
|
echo "$1.txt"
|
|
minidump_stackwalk "$1" "${OUTPUT_DIR}/${BREAKPAD_DIR}" \
|
|
>"$1.txt" 2>/dev/null
|
|
}
|
|
|
|
find_and_generate_stacktraces() {
|
|
find "${OUTPUT_DIR}" -name "*.dmp" |
|
|
while read filename ; do
|
|
generate_stacktrace "${filename}"
|
|
done
|
|
}
|
|
|
|
cleanup() {
|
|
if [ -n "${OUTPUT_DIR}" -a -z "${STACKS_GENERATED}" ] ; then
|
|
rm -rf "${OUTPUT_DIR}"
|
|
fi
|
|
}
|
|
|
|
trap cleanup INT TERM EXIT
|
|
|
|
info "Downloading minidumps from $2..."
|
|
wget -q -nv -r -l 10 -np -A "*.dmp" -P "${OUTPUT_DIR}" $2
|
|
if [[ -z "$(find "${OUTPUT_DIR}" -name "*.dmp")" ]] ; then
|
|
die "No minidumps found"
|
|
fi
|
|
|
|
if [[ -f "$1" ]] ; then
|
|
extract_tarball "$1"
|
|
else
|
|
info "Downloading symbols tarball from $1..."
|
|
wget -P "${OUTPUT_DIR}" "$1"
|
|
TARBALL="${OUTPUT_DIR}/$(basename $1)"
|
|
extract_tarball "$TARBALL"
|
|
rm -f "$TARBALL"
|
|
fi
|
|
|
|
info "Generating stack traces..."
|
|
STACKS_GENERATED=$(find_and_generate_stacktraces)
|
|
echo $STACKS_GENERATED
|