| OLD | NEW |
| 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 18 matching lines...) Expand all Loading... |
| 29 trap "" EXIT USR1 # Avoid reentrancy. | 29 trap "" EXIT USR1 # Avoid reentrancy. |
| 30 | 30 |
| 31 local jobs=$(jobs -p) | 31 local jobs=$(jobs -p) |
| 32 if [ -n "$jobs" ]; then | 32 if [ -n "$jobs" ]; then |
| 33 echo -n "Killing outstanding index jobs..." | 33 echo -n "Killing outstanding index jobs..." |
| 34 kill -KILL $(jobs -p) | 34 kill -KILL $(jobs -p) |
| 35 wait | 35 wait |
| 36 echo "done" | 36 echo "done" |
| 37 fi | 37 fi |
| 38 | 38 |
| 39 if [ -f "$directory" ]; then | 39 if [ -d "$directory" ]; then |
| 40 echo -n "Removing temp directory $directory..." | 40 echo -n "Removing temp directory $directory..." |
| 41 rm -rf "$directory" | 41 rm -rf "$directory" |
| 42 echo done | 42 echo done |
| 43 fi | 43 fi |
| 44 } | 44 } |
| 45 | 45 |
| 46 # Add index to one binary. | 46 # Add index to one binary. |
| 47 function index_one_file { | 47 function index_one_file { |
| 48 local file=$1 | 48 local file=$1 |
| 49 local basename=$(basename "$file") | 49 local basename=$(basename "$file") |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 175 |
| 176 # Do a wait loop. Bash waits that terminate due a trap have an exit | 176 # Do a wait loop. Bash waits that terminate due a trap have an exit |
| 177 # code > 128. We also ensure that our subshell's "normal" exit occurs with | 177 # code > 128. We also ensure that our subshell's "normal" exit occurs with |
| 178 # an exit code > 128. This allows us to do consider a > 128 exit code as | 178 # an exit code > 128. This allows us to do consider a > 128 exit code as |
| 179 # an indication that the loop should continue. Unfortunately, it also means | 179 # an indication that the loop should continue. Unfortunately, it also means |
| 180 # we cannot use set -e since technically the "wait" is failing. | 180 # we cannot use set -e since technically the "wait" is failing. |
| 181 wait | 181 wait |
| 182 while (($? > 128)); do | 182 while (($? > 128)); do |
| 183 wait | 183 wait |
| 184 done | 184 done |
| OLD | NEW |