Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: build/gdb-add-index

Issue 828373003: Made gdb-add-index respect TOOLCHAIN_PREFIX settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium 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 # Saves the gdb index for a given binary and its shared library dependencies. 6 # Saves the gdb index for a given binary and its shared library dependencies.
7 # 7 #
8 # This will run gdb index in parallel on a number of binaries using SIGUSR1 8 # This will run gdb index in parallel on a number of binaries using SIGUSR1
9 # as the communication mechanism to simulate a semaphore. Because of the 9 # as the communication mechanism to simulate a semaphore. Because of the
10 # nature of this technique, using "set -e" is very difficult. The SIGUSR1 10 # nature of this technique, using "set -e" is very difficult. The SIGUSR1
(...skipping 20 matching lines...) Expand all
31 echo done 31 echo done
32 fi 32 fi
33 } 33 }
34 34
35 # Add index to one binary. 35 # Add index to one binary.
36 function index_one_file { 36 function index_one_file {
37 local file=$1 37 local file=$1
38 local basename=$(basename "$file") 38 local basename=$(basename "$file")
39 local should_index="${SHOULD_INDEX}" 39 local should_index="${SHOULD_INDEX}"
40 40
41 local readelf_out=$(readelf -S "$file") 41 local readelf_out=$(${TOOLCHAIN_PREFIX}readelf -S "$file")
42 if [[ $readelf_out =~ "gdb_index" ]]; then 42 if [[ $readelf_out =~ "gdb_index" ]]; then
43 if [ "${REMOVE_INDEX}" = 1 ]; then 43 if [ "${REMOVE_INDEX}" = 1 ]; then
44 objcopy --remove-section .gdb_index "$file" 44 ${TOOLCHAIN_PREFIX}objcopy --remove-section .gdb_index "$file"
45 echo "Removed index from $basename." 45 echo "Removed index from $basename."
46 else 46 else
47 echo "Skipped $basename -- already contains index." 47 echo "Skipped $basename -- already contains index."
48 should_index=0 48 should_index=0
49 fi 49 fi
50 fi 50 fi
51 51
52 if [ "${should_index}" = 1 ]; then 52 if [ "${should_index}" = 1 ]; then
53 local start=$(date +"%s%N") 53 local start=$(date +"%s%N")
54 echo "Adding index to $basename..." 54 echo "Adding index to $basename..."
55 55
56 gdb -batch "$file" -ex "save gdb-index $DIRECTORY" -ex "quit" 56 ${TOOLCHAIN_PREFIX}gdb -batch "$file" -ex "save gdb-index $DIRECTORY" \
57 -ex "quit"
57 local index_file="$DIRECTORY/$basename.gdb-index" 58 local index_file="$DIRECTORY/$basename.gdb-index"
58 if [ -f "$index_file" ]; then 59 if [ -f "$index_file" ]; then
59 objcopy --add-section .gdb_index="$index_file" \ 60 ${TOOLCHAIN_PREFIX}objcopy --add-section .gdb_index="$index_file" \
60 --set-section-flags .gdb_index=readonly "$file" "$file" 61 --set-section-flags .gdb_index=readonly "$file" "$file"
61 local finish=$(date +"%s%N") 62 local finish=$(date +"%s%N")
62 local elappsed=$(((finish - start)/1000000)) 63 local elapsed=$(((finish - start)/1000000))
63 echo " ...$basename indexed. [${elappsed}ms]" 64 echo " ...$basename indexed. [${elapsed}ms]"
64 else 65 else
65 echo " ...$basename unindexable." 66 echo " ...$basename unindexable."
66 fi 67 fi
67 fi 68 fi
68 } 69 }
69 70
70 # Functions that when combined, concurrently index all files in FILES_TO_INDEX 71 # Functions that when combined, concurrently index all files in FILES_TO_INDEX
71 # array. The global FILES_TO_INDEX is declared in the main body of the script. 72 # array. The global FILES_TO_INDEX is declared in the main body of the script.
72 function async_index { 73 function async_index {
73 # Start a background subshell to run the index command. 74 # Start a background subshell to run the index command.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 153
153 # Do a wait loop. Bash waits that terminate due a trap have an exit 154 # Do a wait loop. Bash waits that terminate due a trap have an exit
154 # code > 128. We also ensure that our subshell's "normal" exit occurs with 155 # code > 128. We also ensure that our subshell's "normal" exit occurs with
155 # an exit code > 128. This allows us to do consider a > 128 exit code as 156 # an exit code > 128. This allows us to do consider a > 128 exit code as
156 # an indication that the loop should continue. Unfortunately, it also means 157 # an indication that the loop should continue. Unfortunately, it also means
157 # we cannot use set -e since technically the "wait" is failing. 158 # we cannot use set -e since technically the "wait" is failing.
158 wait 159 wait
159 while (( $? > 128 )); do 160 while (( $? > 128 )); do
160 wait 161 wait
161 done 162 done
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698