OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 |
| 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. |
| 6 |
| 7 # Debug a 32 bit binary on 64 bit linux. Can be run from inside or outside |
| 8 # the chroot. If inside, then the 32 bit gdb from the chroot is used, otherwise |
| 9 # the system's 64 bit gdb is used. |
| 10 |
| 11 . "$(dirname "$0")/common.sh" |
| 12 |
| 13 # Command line options |
| 14 DEFINE_string chroot "$DEFAULT_CHROOT_DIR" "Location of chroot" |
| 15 |
| 16 # Parse command line and update positional args |
| 17 FLAGS "$@" || exit 1 |
| 18 eval set -- "${FLAGS_ARGV}" |
| 19 |
| 20 # Die on any errors |
| 21 set -e |
| 22 |
| 23 if [ -z "$SYSROOT" ]; then |
| 24 if [ $INSIDE_CHROOT == 1 ]; then |
| 25 SYSROOT=/build/x86-generic |
| 26 else |
| 27 SYSROOT=$FLAGS_chroot/build/x86-generic |
| 28 fi |
| 29 fi |
| 30 |
| 31 if [ -z "$CHOST" ]; then |
| 32 CHOST="x86-generic" |
| 33 fi |
| 34 |
| 35 SYSROOT="$FLAGS_chroot/build/$CHOST" |
| 36 LIB_PATHS="/lib32:/usr/lib32:$LIB_PATHS:$SYSROOT/usr/lib:$SYSROOT/lib:." |
| 37 LIB_PATHS="$LIB_PATHS:$SYSROOT/opt/google/chrome/chromeos" |
| 38 |
| 39 if [ $INSIDE_CHROOT == 1 ]; then |
| 40 # if we're inside the chroot, the we'll be running a 32 bit gdb, so we'll |
| 41 # need the same library path as the target |
| 42 export LD_LIBRARY_PATH=$LIB_PATHS |
| 43 GDB="$SYSROOT/usr/bin/gdb" |
| 44 else |
| 45 GDB="gdb" |
| 46 fi |
| 47 |
| 48 exec $GDB \ |
| 49 --eval-command "set environment LD_LIBRARY_PATH=$LIB_PATHS" \ |
| 50 --eval-command "set sysroot $SYSROOT " \ |
| 51 --eval-command "set prompt (cros-gdb) " \ |
| 52 --args "$@" |
OLD | NEW |