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

Side by Side Diff: build/add-index.sh

Issue 10843037: Rewrite the script to add gdb index to binary files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 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 | Annotate | Revision Log
« 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
(Empty)
1 #!/bin/bash
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
4 # found in the LICENSE file.
5 #
6 # Saves the gdb index for a given binary and its shared library dependencies.
7
8 set -e
9
10 if [[ ! $# == 1 ]]; then
11 echo "Usage: $0 path-to-binary"
12 exit
13 fi
14
15 FILENAME="$1"
16 if [[ ! -f "$FILENAME" ]]; then
17 echo "Path $FILENAME does not exist."
18 exit
19 fi
20
21 # Check to make sure ldd and gdb exist.
22 command -v ldd &>/dev/null
23 if [[ $? -gt 0 ]]; then
24 echo "ldd not found."
25 exit
Ami GONE FROM CHROMIUM 2012/08/02 23:01:15 each of the error exits here and below should exit
vrk (LEFT CHROMIUM) 2012/08/02 23:24:55 Done.
26 fi
27 command -v gdb &>/dev/null
28 if [[ $? -gt 0 ]]; then
29 echo "gdb not found."
30 exit
31 fi
32
33 # GDB version check.
34 gdb_version_string=$(gdb --version \
35 | head -n 1 \
36 | sed "s/.*GDB) \([0-9]*\)\.\([0-9]*\).*/\1 \2/")
37 gdb_version=($gdb_version_string)
38
39 if [[ ${gdb_version[0]} -lt 7 ]] || [[ ${gdb_version[1]} -lt 3 ]]; then
40 echo "Needs gdb version 7.3 or higher to use gdb_index.";
41 exit
Ami GONE FROM CHROMIUM 2012/08/02 23:01:15 You're checking ldd & gdb, but assuming readelf an
vrk (LEFT CHROMIUM) 2012/08/02 23:24:55 Done.
42 fi
43
44 # We're good to go! Create temp directory for index files.
45 DIRECTORY=$(mktemp -d)
46 echo "Made temp directory $DIRECTORY."
47
48 # Always remove directory on exit.
49 trap "{ echo -n Removing temp directory $DIRECTORY...;
50 rm -rf $DIRECTORY; echo done; }" EXIT
51
52 # Grab all the chromium shared library files.
53 so_files=$(ldd "$FILENAME" 2>/dev/null \
54 | grep $(pwd) \
55 | sed "s/.*[ \t]\(.*\) (.*/\1/")
56
57 # Add index to binary and the shared library dependencies.
58 for file in "$FILENAME" $so_files; do
59 basename=$(basename "$file")
60 echo -n "Adding index to $basename..."
61 readelf_out=$(readelf -S "$file")
62 if [[ $readelf_out =~ "gdb_index" ]]; then
63 echo "already contains index. Skipped."
64 else
65 gdb -batch "$file" -ex "save gdb-index $DIRECTORY" -ex "quit"
66 objcopy --add-section .gdb_index="$DIRECTORY"/$basename.gdb-index \
67 --set-section-flags .gdb_index=readonly "$file" "$file"
68 echo "done."
69 fi
70 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