| OLD | NEW | 
|---|
| 1 #!/bin/bash | 1 #!/bin/bash | 
| 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be | 
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. | 
| 5 | 5 | 
| 6 # Script to generate minidump symbols in the format required by | 6 # Script to generate minidump symbols in the format required by | 
| 7 # minidump_stackwalk to dump stack information. | 7 # minidump_stackwalk to dump stack information. | 
| 8 # | 8 # | 
| 9 # NOTE: This script must be run from the chromeos build chroot environment. | 9 # NOTE: This script must be run from the chromeos build chroot environment. | 
| 10 # | 10 # | 
| 11 | 11 | 
| 12 # Load common constants.  This should be the first executable line. | 12 # --- BEGIN COMMON.SH BOILERPLATE --- | 
| 13 # The path to common.sh should be relative to your script's location. | 13 # Load common CrOS utilities.  Inside the chroot this file is installed in | 
| 14 . "$(dirname "$0")/common.sh" | 14 # /usr/lib/crosutils.  Outside the chroot we find it relative to the script's | 
|  | 15 # location. | 
|  | 16 find_common_sh() { | 
|  | 17   local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) | 
|  | 18   local path | 
|  | 19 | 
|  | 20   SCRIPT_ROOT= | 
|  | 21   for path in "${common_paths[@]}"; do | 
|  | 22     if [ -r "${path}/common.sh" ]; then | 
|  | 23       SCRIPT_ROOT=${path} | 
|  | 24       break | 
|  | 25     fi | 
|  | 26   done | 
|  | 27 } | 
|  | 28 | 
|  | 29 find_common_sh | 
|  | 30 . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1) | 
|  | 31 # --- END COMMON.SH BOILERPLATE --- | 
| 15 | 32 | 
| 16 # Script must be run inside the chroot | 33 # Script must be run inside the chroot | 
| 17 restart_in_chroot_if_needed $* | 34 restart_in_chroot_if_needed "$@" | 
| 18 | 35 | 
| 19 get_default_board | 36 get_default_board | 
| 20 | 37 | 
| 21 # Flags | 38 # Flags | 
| 22 DEFINE_string board "$DEFAULT_BOARD" "The board to build packages for." | 39 DEFINE_string board "$DEFAULT_BOARD" "The board to build packages for." | 
| 23 DEFINE_string minidump_symbol_root "" \ | 40 DEFINE_string minidump_symbol_root "" \ | 
| 24   "Symbol root (defaults to /usr/lib/debug/breakpad for board)" | 41   "Symbol root (defaults to /usr/lib/debug/breakpad for board)" | 
| 25 DEFINE_boolean verbose ${FLAGS_FALSE} "Be verbose." | 42 DEFINE_boolean verbose ${FLAGS_FALSE} "Be verbose." | 
| 26 | 43 | 
| 27 DUMP_SYMS="dump_syms" | 44 DUMP_SYMS="dump_syms" | 
| 28 | 45 | 
| 29 CUMULATIVE_SIZE=0 | 46 CUMULATIVE_SIZE=0 | 
| 30 ANY_ERRORS=0 | 47 ANY_ERRORS=0 | 
| 31 | 48 | 
| 32 SYM_FILE=$(mktemp "/tmp/sym.XXXX") | 49 SYM_FILE=$(mktemp "/tmp/sym.XXXX") | 
| 33 ERR_FILE=$(mktemp "/tmp/err.XXXX") | 50 ERR_FILE=$(mktemp "/tmp/err.XXXX") | 
| 34 | 51 | 
| 35 function cleanup() { | 52 function cleanup() { | 
| 36   rm -f "${SYM_FILE}" "${ERR_FILE}" | 53   rm -f "${SYM_FILE}" "${ERR_FILE}" | 
| 37 } | 54 } | 
| 38 | 55 | 
| 39 # Given path to a debug file, return its text file | 56 # Given path to a debug file, return its text file | 
| 40 function get_text_for_debug() { | 57 function get_text_for_debug() { | 
| 41   local debug_file=$1 | 58   local debug_file=$1 | 
| 42   local text_dir=$(dirname ${debug_file#$DEBUG_ROOT}) | 59   local text_dir=$(dirname "${debug_file#$DEBUG_ROOT}") | 
| 43   local text_path=${SYSROOT}${text_dir}/$(basename "${debug_file}" .debug) | 60   local text_path=${SYSROOT}${text_dir}/$(basename "${debug_file}" .debug) | 
| 44   echo ${text_path} | 61   echo ${text_path} | 
| 45 } | 62 } | 
| 46 | 63 | 
| 47 # Given path to a text file, return its debug file | 64 # Given path to a text file, return its debug file | 
| 48 function get_debug_for_text() { | 65 function get_debug_for_text() { | 
| 49   local text_file=$1 | 66   local text_file=$1 | 
| 50   local text_path=${text_file#${SYSROOT}} | 67   local text_path=${text_file#${SYSROOT}} | 
| 51   local debug_path=${DEBUG_ROOT}${text_path}.debug | 68   local debug_path=${DEBUG_ROOT}${text_path}.debug | 
| 52   echo ${debug_path} | 69   echo ${debug_path} | 
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 198     done | 215     done | 
| 199   fi | 216   fi | 
| 200 | 217 | 
| 201   info "Generated ${CUMULATIVE_SIZE}B of debug information" | 218   info "Generated ${CUMULATIVE_SIZE}B of debug information" | 
| 202 | 219 | 
| 203   [ ${ANY_ERRORS} -ne 0 ] && die "Encountered problems" | 220   [ ${ANY_ERRORS} -ne 0 ] && die "Encountered problems" | 
| 204   return 0 | 221   return 0 | 
| 205 } | 222 } | 
| 206 | 223 | 
| 207 main "$@" | 224 main "$@" | 
| OLD | NEW | 
|---|