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

Unified Diff: build/gdb-add-index

Issue 10700022: Add in support for components build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nits Created 8 years, 6 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/gdb-add-index
diff --git a/build/gdb-add-index b/build/gdb-add-index
index 8dd72c43647d97f8a143bdb3f57c63e7086f86d5..4eadaec6841f9c289e7ed5dc092a62918685fc68 100755
--- a/build/gdb-add-index
+++ b/build/gdb-add-index
@@ -1,7 +1,9 @@
#!/bin/sh
-# Add a .gdb_index section to a file.
-
+# 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.
+#
# Copyright (C) 2010 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,15 +18,46 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-file="$1"
-dir="${file%/*}"
+# This is a modification of gdb-add-index that recursively adds an index
+# to the shared libraries dependencies from the same build.
+
+target="$1"
+target_dir="${target%/*}"
+
+OLDIFS=$IFS
+IFS=$'\n'
+
+shared_libraries=$(
+ ldd -d "$target" | grep "$target_dir" | cut -d '>' -f2 | cut -d ' ' -f2
+ )
+
+# This function is basically the RedHat's gdb-add-index script and is why
+# we have the FSF copyright above.
+function index_one_file {
+ local file="$1"
+ local dir="${file%/*}"
+
+ # We don't care if gdb gives an error.
+ gdb -nx --batch-silent -ex "file $file" -ex "save gdb-index $dir"
-# We don't care if gdb gives an error.
-gdb -nx --batch-silent -ex "file $file" -ex "save gdb-index $dir"
+ if test -f "${file}.gdb-index"; then
+ objcopy --add-section .gdb_index="${file}.gdb-index" --set-section-flags \
+ .gdb_index=readonly "$file" "$file"
+ rm -f "${file}.gdb-index"
+ fi
+}
-if test -f "${file}.gdb-index"; then
- objcopy --add-section .gdb_index="${file}.gdb-index" --set-section-flags .gdb_index=readonly "$file" "$file"
- rm -f "${file}.gdb-index"
-fi
+function maybe_index {
+ readelf -e "$1" | grep '.gdb_index' > /dev/null 2>&1
+ if [[ "$?" != 0 ]]; then
+ echo "Adding .gdb_index to $1"
+ index_one_file "$1"
+ else
+ echo "Skipping $1 (already has .gdb_index)"
+ fi
+}
-exit 0
+maybe_index "$target"
+for lib in $shared_libraries; do
+ maybe_index "$lib"
+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