3 # Copyright (c) 2021 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 echo "---> jjb/scripts/post_build_deploy_archives.sh"
18 set +e # Do not affect the build result if some part of archiving fails.
19 WS_ARCHIVES_DIR="$WORKSPACE/archives"
20 BUILD_ENV_LOG="$WS_ARCHIVES_DIR/_build-enviroment-variables.log"
22 # Generate gdb-command script to output vpp stack traceback from core files.
23 gdb_cmdfile="/tmp/gdb-commands"
24 cat >$gdb_cmdfile <<'__END__'
26 # gdb $BINFILE $CORE -ex 'source -v gdb-commands' -ex quit
41 thread apply all printstack
48 # Returns stacktrace filename in STACKTRACE
49 generate_vpp_stacktrace_and_delete_core() {
51 echo "Uncompressing core file $file"
53 corefile="${corefile::(-3)}"
54 if grep -qe 'debug' <<< "$WORKSPACE" ; then
55 local binfile="$WORKSPACE/build-root/install-vpp_debug-native/vpp/bin/vpp"
57 local binfile="$WORKSPACE/build-root/install-vpp-native/vpp/bin/vpp"
60 echo "Generating stack trace from core file: $corefile"
61 STACKTRACE="${corefile}.stacktrace"
62 gdb "$binfile" $corefile -ex 'source -v /tmp/gdb-commands' -ex quit > $STACKTRACE
63 # remove the core to save space
64 echo "Removing core file: $corefile"
66 # Dump stacktrace to console log
67 if [ -f "$STACKTRACE" ] ; then
68 echo -e "\n=====[ $STACKTRACE ]=====\n$(cat $STACKTRACE)\n=====[ $STACKTRACE ]=====\n"
71 echo "Stacktrace file not generated!"
76 mkdir -p "$WS_ARCHIVES_DIR"
78 # generate stack trace for VPP core files for upload instead of core file.
79 if [ -d "$WORKSPACE/build-root" ] ; then
80 for file in $(find $WS_ARCHIVES_DIR -type f -name 'core*.gz') ; do
81 generate_vpp_stacktrace_and_delete_core $file
85 # Remove any socket files in archive
86 find $WS_ARCHIVES_DIR -type s -exec rm -rf {} \;
88 echo "Workspace archived artifacts:"
89 ls -alR $WS_ARCHIVES_DIR