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

Unified 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: response to CR Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/add-index.sh
diff --git a/build/add-index.sh b/build/add-index.sh
new file mode 100755
index 0000000000000000000000000000000000000000..fa3e7265589b8f6c084b7fffc7ccf7d200788310
--- /dev/null
+++ b/build/add-index.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# Saves the gdb index for a given binary and its shared library dependencies.
+
+set -e
+
+if [[ ! $# == 1 ]]; then
+ echo "Usage: $0 path-to-binary"
+ exit 1
+fi
+
+FILENAME="$1"
+if [[ ! -f "$FILENAME" ]]; then
+ echo "Path $FILENAME does not exist."
+ exit 1
+fi
+
+# We're good to go! Create temp directory for index files.
+DIRECTORY=$(mktemp -d)
+echo "Made temp directory $DIRECTORY."
+
+# Always remove directory on exit.
+trap "{ echo -n Removing temp directory $DIRECTORY...;
+ rm -rf $DIRECTORY; echo done; }" EXIT
+
+# Grab all the chromium shared library files.
+so_files=$(ldd "$FILENAME" 2>/dev/null \
+ | grep $(pwd) \
+ | sed "s/.*[ \t]\(.*\) (.*/\1/")
+
+# Add index to binary and the shared library dependencies.
+for file in "$FILENAME" $so_files; do
+ basename=$(basename "$file")
+ echo -n "Adding index to $basename..."
+ readelf_out=$(readelf -S "$file")
+ if [[ $readelf_out =~ "gdb_index" ]]; then
+ echo "already contains index. Skipped."
+ else
+ gdb -batch "$file" -ex "save gdb-index $DIRECTORY" -ex "quit"
+ objcopy --add-section .gdb_index="$DIRECTORY"/$basename.gdb-index \
+ --set-section-flags .gdb_index=readonly "$file" "$file"
+ echo "done."
+ fi
+done
« 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