David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (C) 2010 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | |
| 18 | # This wrapper script is used to launch a native debugging session |
| 19 | # on a given NDK application. The application must be debuggable, i.e. |
| 20 | # its android:debuggable attribute must be set to 'true' in the |
| 21 | # <application> element of its manifest. |
| 22 | # |
| 23 | # See docs/NDK-GDB.TXT for usage description. Essentially, you just |
| 24 | # need to launch ndk-gdb from your application project directory |
| 25 | # after doing ndk-build && ant install && <start-application-on-device> |
| 26 | # |
| 27 | . `dirname $0`/build/core/ndk-common.sh |
| 28 | |
| 29 | force_32bit_binaries |
| 30 | |
David 'Digit' Turner | db09243 | 2011-11-02 12:44:20 +0100 | [diff] [blame] | 31 | # Find if a given shell program is available. |
| 32 | # We need to take care of the fact that the 'which <foo>' command |
| 33 | # may return either an empty string (Linux) or something like |
| 34 | # "no <foo> in ..." (Darwin). Also, we need to redirect stderr |
| 35 | # to /dev/null for Cygwin |
| 36 | # |
| 37 | # $1: program name |
| 38 | # Out: program path, or empty string |
| 39 | # Return: 0 on success, != 0 on error |
| 40 | # |
| 41 | find_program () |
| 42 | { |
| 43 | local PROG RET |
| 44 | PROG=$(which "$1" 2>/dev/null) |
| 45 | RET=$? |
| 46 | if [ $RET != 0 ]; then |
| 47 | PROG= |
| 48 | fi |
| 49 | echo "$PROG" |
| 50 | return $RET |
| 51 | } |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 52 | |
David 'Digit' Turner | db09243 | 2011-11-02 12:44:20 +0100 | [diff] [blame] | 53 | quote_spaces () |
| 54 | { |
| 55 | echo "$@" | sed -e 's! !\ !g' |
| 56 | } |
| 57 | |
| 58 | # If ADB_CMD is not defined, try to find a program named 'adb' |
| 59 | # in our path. |
| 60 | ADB_CMD=${ADB_CMD:-$(find_program adb)} |
| 61 | ADB_FLAGS=${ADB_FLAGS:-} |
Andrew Hsieh | 20f4e7e | 2012-06-29 14:57:28 -0700 | [diff] [blame^] | 62 | DEVICE_SERIAL= |
David 'Digit' Turner | db09243 | 2011-11-02 12:44:20 +0100 | [diff] [blame] | 63 | |
| 64 | AWK_CMD=${AWK_CMD:-$(find_program awk)} |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 65 | |
| 66 | DEBUG_PORT=5039 |
| 67 | |
David 'Digit' Turner | 5b65625 | 2010-10-08 00:43:32 +0200 | [diff] [blame] | 68 | # Delay in seconds between launching the activity and attaching gdbserver on it. |
| 69 | # This is needed because there is no way to know when the activity has really |
| 70 | # started, and sometimes this takes a few seconds. |
| 71 | DELAY=2 |
| 72 | |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 73 | PARAMETERS= |
| 74 | OPTION_HELP=no |
| 75 | OPTION_PROJECT= |
| 76 | OPTION_FORCE=no |
| 77 | OPTION_ADB= |
| 78 | OPTION_EXEC= |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 79 | OPTION_START=no |
| 80 | OPTION_LAUNCH= |
| 81 | OPTION_LAUNCH_LIST=no |
David 'Digit' Turner | 5b65625 | 2010-10-08 00:43:32 +0200 | [diff] [blame] | 82 | OPTION_DELAY= |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 83 | |
| 84 | check_parameter () |
| 85 | { |
| 86 | if [ -z "$2" ]; then |
| 87 | echo "ERROR: Missing parameter after option '$1'" |
| 88 | exit 1 |
| 89 | fi |
| 90 | } |
| 91 | |
| 92 | check_adb_flags () |
| 93 | { |
| 94 | if [ -n "$ADB_FLAGS" ] ; then |
| 95 | echo "ERROR: Only one of -e, -d or -s <serial> can be used at the same time!" |
| 96 | exit 1 |
| 97 | fi |
| 98 | } |
| 99 | |
| 100 | get_build_var () |
| 101 | { |
| 102 | if [ -z "$GNUMAKE" ] ; then |
| 103 | GNUMAKE=make |
| 104 | fi |
| 105 | $GNUMAKE --no-print-dir -f $ANDROID_NDK_ROOT/build/core/build-local.mk -C $PROJECT DUMP_$1 |
| 106 | } |
| 107 | |
| 108 | get_build_var_for_abi () |
| 109 | { |
| 110 | if [ -z "$GNUMAKE" ] ; then |
| 111 | GNUMAKE=make |
| 112 | fi |
| 113 | $GNUMAKE --no-print-dir -f $ANDROID_NDK_ROOT/build/core/build-local.mk -C $PROJECT DUMP_$1 APP_ABI=$2 |
| 114 | } |
| 115 | |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 116 | # Used to run an awk script on the manifest |
| 117 | run_awk_manifest_script () |
| 118 | { |
| 119 | $AWK_CMD -f $AWK_SCRIPTS/$1 $PROJECT/$MANIFEST |
| 120 | } |
| 121 | |
David 'Digit' Turner | 47eff9f | 2010-06-03 11:57:49 -0700 | [diff] [blame] | 122 | if [ "$HOST_OS" = "cygwin" ] ; then |
| 123 | # Return native path representation from cygwin one |
| 124 | # $1: a cygwin-compatible path (e.g. /cygdrive/c/some/thing) |
| 125 | # Return: path in host windows representation, e.g. C:/some/thing |
| 126 | # |
| 127 | # We use mixed mode (i.e. / as the directory separator) because |
| 128 | # all the tools we use recognize it properly, and it avoids lots |
| 129 | # of escaping nonsense associated with "\" |
| 130 | # |
| 131 | native_path () |
| 132 | { |
| 133 | cygpath -m $1 |
| 134 | } |
| 135 | else # HOST_OS != windows |
| 136 | native_path () |
| 137 | { |
| 138 | echo "$1" |
| 139 | } |
| 140 | fi # HOST_OS != windows |
| 141 | |
David 'Digit' Turner | b2e3ee7 | 2011-03-23 15:03:31 +0100 | [diff] [blame] | 142 | # We need to ensure the ANDROID_NDK_ROOT is absolute, otherwise calls |
| 143 | # to get_build_var, get_build_var_for_abi and run_awk_manifest_script |
| 144 | # might fail, e.g. when invoked with: |
| 145 | # |
| 146 | # cd $NDKROOT |
| 147 | # ./ndk-gdb --project=/path/to/project |
| 148 | # |
| 149 | path_is_absolute () |
| 150 | { |
| 151 | local P P2 |
| 152 | P=$1 # copy path |
| 153 | P2=${P#/} # remove / prefix, if any |
| 154 | [ "$P" != "$P2" ] |
| 155 | } |
| 156 | |
| 157 | if ! path_is_absolute "$ANDROID_NDK_ROOT"; then |
| 158 | ANDROID_NDK_ROOT=$(pwd)/$ANDROID_NDK_ROOT |
| 159 | fi |
| 160 | |
| 161 | |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 162 | VERBOSE=no |
| 163 | while [ -n "$1" ]; do |
| 164 | opt="$1" |
| 165 | optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` |
| 166 | case "$opt" in |
| 167 | --help|-h|-\?) |
| 168 | OPTION_HELP=yes |
| 169 | ;; |
| 170 | --verbose) |
| 171 | VERBOSE=yes |
| 172 | ;; |
| 173 | -s) |
| 174 | check_parameter $1 $2 |
| 175 | check_adb_flags |
Andrew Hsieh | 20f4e7e | 2012-06-29 14:57:28 -0700 | [diff] [blame^] | 176 | ADB_FLAGS=" -s" |
| 177 | DEVICE_SERIAL=$2 |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 178 | shift |
| 179 | ;; |
| 180 | -s*) |
| 181 | check_adb_flags |
| 182 | optarg=`expr -- "$opt" : '-s\(.*\)'` |
Andrew Hsieh | 20f4e7e | 2012-06-29 14:57:28 -0700 | [diff] [blame^] | 183 | ADB_FLAGS=" -s" |
| 184 | DEVICE_SERIAL=$optarg |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 185 | ;; |
| 186 | -p) |
| 187 | check_parameter $1 $2 |
| 188 | OPTION_PROJECT="$2" |
| 189 | shift |
| 190 | ;; |
| 191 | -p*) |
| 192 | optarg=`expr -- "$opt" : '-p\(.*\)'` |
| 193 | OPTION_PROJECT="$optarg" |
| 194 | ;; |
| 195 | --exec=*) |
| 196 | OPTION_EXEC="$optarg" |
| 197 | ;; |
| 198 | -x) |
| 199 | check_parameter $1 $2 |
| 200 | OPTION_EXEC="$2" |
| 201 | shift |
| 202 | ;; |
| 203 | -x*) |
| 204 | optarg=`expr -- "$opt" : '-x\(.*\)'` |
| 205 | OPTION_EXEC="$optarg" |
| 206 | ;; |
| 207 | -e) |
| 208 | check_adb_flags |
| 209 | ADB_FLAGS=" -e" |
| 210 | ;; |
| 211 | -d) |
| 212 | check_adb_flags |
| 213 | ADB_FLAGS=" -d" |
| 214 | ;; |
| 215 | --adb=*) # specify ADB command |
| 216 | OPTION_ADB="$optarg" |
| 217 | ;; |
| 218 | --awk=*) |
| 219 | AWK_CMD="$optarg" |
| 220 | ;; |
| 221 | --project=*) |
| 222 | OPTION_PROJECT="$optarg" |
| 223 | ;; |
| 224 | --port=*) |
| 225 | DEBUG_PORT="$optarg" |
| 226 | ;; |
| 227 | --force) |
| 228 | OPTION_FORCE="yes" |
| 229 | ;; |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 230 | --launch-list) |
| 231 | OPTION_LAUNCH_LIST="yes" |
| 232 | ;; |
| 233 | --launch=*) |
| 234 | OPTION_LAUNCH="$optarg" |
| 235 | ;; |
| 236 | --start) |
| 237 | OPTION_START=yes |
| 238 | ;; |
David 'Digit' Turner | 5b65625 | 2010-10-08 00:43:32 +0200 | [diff] [blame] | 239 | --delay=*) |
| 240 | OPTION_DELAY="$optarg" |
| 241 | ;; |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 242 | -*) # unknown options |
| 243 | echo "ERROR: Unknown option '$opt', use --help for list of valid ones." |
| 244 | exit 1 |
| 245 | ;; |
| 246 | *) # Simply record parameter |
| 247 | if [ -z "$PARAMETERS" ] ; then |
| 248 | PARAMETERS="$opt" |
| 249 | else |
| 250 | PARAMETERS="$PARAMETERS $opt" |
| 251 | fi |
| 252 | ;; |
| 253 | esac |
| 254 | shift |
| 255 | done |
| 256 | |
| 257 | if [ "$OPTION_HELP" = "yes" ] ; then |
| 258 | echo "Usage: $PROGNAME [options]" |
| 259 | echo "" |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 260 | echo "Setup a gdb debugging session for your Android NDK application." |
| 261 | echo "Read $$NDK/docs/NDK-GDB.TXT for complete usage instructions." |
| 262 | echo "" |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 263 | echo "Valid options:" |
| 264 | echo "" |
| 265 | echo " --help|-h|-? Print this help" |
| 266 | echo " --verbose Enable verbose mode" |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 267 | echo " --force Kill existing debug session if it exists" |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 268 | echo " --start Launch application instead of attaching to existing one" |
| 269 | echo " --launch=<name> Same as --start, but specify activity name (see below)" |
| 270 | echo " --launch-list List all launchable activity names from manifest" |
David 'Digit' Turner | 5b65625 | 2010-10-08 00:43:32 +0200 | [diff] [blame] | 271 | echo " --delay=<secs> Delay in seconds between activity start and gdbserver attach." |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 272 | echo " --project=<path> Specify application project path" |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 273 | echo " -p <path> Same as --project=<path>" |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 274 | echo " --port=<port> Use tcp:localhost:<port> to communicate with gdbserver [$DEBUG_PORT]" |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 275 | echo " --exec=<file> Execute gdb initialization commands in <file> after connection" |
| 276 | echo " -x <file> Same as --exec=<file>" |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 277 | echo " --adb=<file> Use specific adb command [$ADB_CMD]" |
| 278 | echo " --awk=<file> Use specific awk command [$AWK_CMD]" |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 279 | echo " -e Connect to single emulator instance" |
| 280 | echo " -d Connect to single target device" |
| 281 | echo " -s <serial> Connect to specific emulator or device" |
| 282 | echo "" |
| 283 | exit 0 |
| 284 | fi |
| 285 | |
| 286 | log "Android NDK installation path: $ANDROID_NDK_ROOT" |
| 287 | |
| 288 | if [ -n "$OPTION_EXEC" ] ; then |
| 289 | if [ ! -f "$OPTION_EXEC" ]; then |
| 290 | echo "ERROR: Invalid initialization file: $OPTION_EXEC" |
| 291 | exit 1 |
| 292 | fi |
| 293 | fi |
| 294 | |
David 'Digit' Turner | 5b65625 | 2010-10-08 00:43:32 +0200 | [diff] [blame] | 295 | if [ -n "$OPTION_DELAY" ] ; then |
| 296 | DELAY="$OPTION_DELAY" |
| 297 | fi |
| 298 | |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 299 | # Check ADB tool version |
| 300 | if [ -n "$OPTION_ADB" ] ; then |
David 'Digit' Turner | db09243 | 2011-11-02 12:44:20 +0100 | [diff] [blame] | 301 | ADB_CMD=$OPTION_ADB |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 302 | log "Using specific adb command: $ADB_CMD" |
| 303 | else |
| 304 | if [ -z "$ADB_CMD" ] ; then |
| 305 | echo "ERROR: The 'adb' tool is not in your path." |
| 306 | echo " You can change your PATH variable, or use" |
| 307 | echo " --adb=<executable> to point to a valid one." |
| 308 | exit 1 |
| 309 | fi |
| 310 | log "Using default adb command: $ADB_CMD" |
| 311 | fi |
| 312 | |
David 'Digit' Turner | db09243 | 2011-11-02 12:44:20 +0100 | [diff] [blame] | 313 | ADB_CMD=$(quote_spaces $ADB_CMD) |
| 314 | ADB_VERSION=$("$ADB_CMD" version 2>/dev/null) |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 315 | if [ $? != 0 ] ; then |
| 316 | echo "ERROR: Could not run ADB with: $ADB_CMD" |
| 317 | exit 1 |
| 318 | fi |
| 319 | log "ADB version found: $ADB_VERSION" |
| 320 | |
Andrew Hsieh | 20f4e7e | 2012-06-29 14:57:28 -0700 | [diff] [blame^] | 321 | if [ "x$DEVICE_SERIAL" = "x" ]; then |
| 322 | log "Using ADB flags: $ADB_FLAGS" |
| 323 | else |
| 324 | log "Using ADB flags: $ADB_FLAGS" \"$DEVICE_SERIAL\" |
| 325 | fi |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 326 | |
Andrew Hsieh | 201486c | 2012-05-16 14:03:11 +0800 | [diff] [blame] | 327 | # Run an ADB command with the right ADB flags |
| 328 | # $1+: adb command parameter |
| 329 | adb_cmd () |
| 330 | { |
Andrew Hsieh | 20f4e7e | 2012-06-29 14:57:28 -0700 | [diff] [blame^] | 331 | if [ "x$DEVICE_SERIAL" = "x" ]; then |
| 332 | "$ADB_CMD" $ADB_FLAGS "$@" |
| 333 | else |
| 334 | # NOTE: We escape $ADB_CMD and $DEVICE_SERIAL in case they contains spaces. |
| 335 | "$ADB_CMD" $ADB_FLAGS "$DEVICE_SERIAL" "$@" |
| 336 | fi |
Andrew Hsieh | 201486c | 2012-05-16 14:03:11 +0800 | [diff] [blame] | 337 | } |
David 'Digit' Turner | e3cfafb | 2011-03-15 15:43:12 +0100 | [diff] [blame] | 338 | |
David 'Digit' Turner | b2e3ee7 | 2011-03-23 15:03:31 +0100 | [diff] [blame] | 339 | # Used internally by adb_var_shell and adb_var_shell2. |
| 340 | # $1: 1 to redirect stderr to $1, 0 otherwise. |
| 341 | # $2: Variable name that will contain the result |
| 342 | # $3+: Command options |
David 'Digit' Turner | e3cfafb | 2011-03-15 15:43:12 +0100 | [diff] [blame] | 343 | _adb_var_shell () |
David 'Digit' Turner | 4cff650 | 2010-06-01 14:40:11 -0700 | [diff] [blame] | 344 | { |
David 'Digit' Turner | e3cfafb | 2011-03-15 15:43:12 +0100 | [diff] [blame] | 345 | # We need a temporary file to store the output of our command |
David 'Digit' Turner | b2e3ee7 | 2011-03-23 15:03:31 +0100 | [diff] [blame] | 346 | local CMD_OUT RET OUTPUT VARNAME REDIRECT_STDERR |
| 347 | REDIRECT_STDERR=$1 |
| 348 | VARNAME=$2 |
| 349 | shift; shift; |
| 350 | CMD_OUT=`mktemp /tmp/ndk-gdb-cmdout-XXXXXX` |
David 'Digit' Turner | e3cfafb | 2011-03-15 15:43:12 +0100 | [diff] [blame] | 351 | # Run the command, while storing the standard output to CMD_OUT |
| 352 | # and appending the exit code as the last line. |
David 'Digit' Turner | b2e3ee7 | 2011-03-23 15:03:31 +0100 | [diff] [blame] | 353 | if [ "$REDIRECT_STDERR" != 0 ]; then |
Andrew Hsieh | 201486c | 2012-05-16 14:03:11 +0800 | [diff] [blame] | 354 | adb_cmd shell "$@" ";" echo \$? | sed -e 's![[:cntrl:]]!!g' > $CMD_OUT 2>&1 |
David 'Digit' Turner | b2e3ee7 | 2011-03-23 15:03:31 +0100 | [diff] [blame] | 355 | else |
Andrew Hsieh | 201486c | 2012-05-16 14:03:11 +0800 | [diff] [blame] | 356 | adb_cmd shell "$@" ";" echo \$? | sed -e 's![[:cntrl:]]!!g' > $CMD_OUT |
David 'Digit' Turner | b2e3ee7 | 2011-03-23 15:03:31 +0100 | [diff] [blame] | 357 | fi |
David 'Digit' Turner | e3cfafb | 2011-03-15 15:43:12 +0100 | [diff] [blame] | 358 | # Get last line in log, which contains the exit code from the command |
| 359 | RET=`sed -e '$!d' $CMD_OUT` |
| 360 | # Get output, which corresponds to everything except the last line |
| 361 | OUT=`sed -e '$d' $CMD_OUT` |
| 362 | rm -f $CMD_OUT |
| 363 | eval $VARNAME=\"\$OUT\" |
| 364 | return $RET |
| 365 | } |
| 366 | |
| 367 | # Run a command through 'adb shell' and captures its standard output |
| 368 | # into a variable. The function's exit code is the same than the command's. |
| 369 | # |
| 370 | # This is required because there is a bug where "adb shell" always returns |
| 371 | # 0 on the host, even if the command fails on the device. |
| 372 | # |
| 373 | # $1: Variable name (e.g. FOO) |
| 374 | # On exit, $FOO is set to the command's standard output |
| 375 | # |
| 376 | # The return status will be 0 (success) if the command succeeded |
| 377 | # or 1 (failure) otherwise. |
| 378 | adb_var_shell () |
| 379 | { |
David 'Digit' Turner | ec2b8dd | 2011-10-27 14:43:25 +0200 | [diff] [blame] | 380 | _adb_var_shell 0 "$@" |
David 'Digit' Turner | e3cfafb | 2011-03-15 15:43:12 +0100 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | # A variant of adb_var_shell that stores both stdout and stderr in the output |
| 384 | # $1: Variable name |
| 385 | adb_var_shell2 () |
| 386 | { |
David 'Digit' Turner | ec2b8dd | 2011-10-27 14:43:25 +0200 | [diff] [blame] | 387 | _adb_var_shell 1 "$@" |
David 'Digit' Turner | 4cff650 | 2010-06-01 14:40:11 -0700 | [diff] [blame] | 388 | } |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 389 | |
David 'Digit' Turner | 9c10d88 | 2011-10-27 13:10:58 +0200 | [diff] [blame] | 390 | # Return the PID of a given package or program, or 0 if it doesn't run |
| 391 | # $1: Package name ("com.example.hellojni") or program name ("/lib/gdbserver") |
| 392 | # Out: PID number, or 0 if not running |
| 393 | get_pid_of () |
| 394 | { |
Andrew Hsieh | 201486c | 2012-05-16 14:03:11 +0800 | [diff] [blame] | 395 | adb_cmd shell ps | $AWK_CMD -f $AWK_SCRIPTS/extract-pid.awk -v PACKAGE="$1" |
David 'Digit' Turner | 9c10d88 | 2011-10-27 13:10:58 +0200 | [diff] [blame] | 396 | } |
| 397 | |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 398 | # Check the awk tool |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 399 | AWK_SCRIPTS=$ANDROID_NDK_ROOT/build/awk |
| 400 | AWK_TEST=`$AWK_CMD -f $AWK_SCRIPTS/check-awk.awk` |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 401 | if [ $? != 0 ] ; then |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 402 | echo "ERROR: Could not run '$AWK_CMD' command. Do you have it installed properly?" |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 403 | exit 1 |
| 404 | fi |
| 405 | if [ "$AWK_TEST" != "Pass" ] ; then |
| 406 | echo "ERROR: Your version of 'awk' is obsolete. Please use --awk=<file> to point to Nawk or Gawk!" |
| 407 | exit 1 |
| 408 | fi |
| 409 | |
| 410 | # Name of the manifest file |
| 411 | MANIFEST=AndroidManifest.xml |
| 412 | |
| 413 | # Find the root of the application project. |
| 414 | if [ -n "$OPTION_PROJECT" ] ; then |
| 415 | PROJECT=$OPTION_PROJECT |
| 416 | log "Using specified project path: $PROJECT" |
| 417 | if [ ! -d "$PROJECT" ] ; then |
| 418 | echo "ERROR: Your --project option does not point to a directory!" |
| 419 | exit 1 |
| 420 | fi |
| 421 | if [ ! -f "$PROJECT/$MANIFEST" ] ; then |
| 422 | echo "ERROR: Your --project does not point to an Android project path!" |
| 423 | echo " It is missing a $MANIFEST file." |
| 424 | exit 1 |
| 425 | fi |
| 426 | else |
| 427 | # Assume we are in the project directory |
| 428 | if [ -f "$MANIFEST" ] ; then |
| 429 | PROJECT=. |
| 430 | else |
| 431 | PROJECT= |
| 432 | CURDIR=`pwd` |
| 433 | while [ "$CURDIR" != "/" ] ; do |
| 434 | if [ -f "$CURDIR/$MANIFEST" ] ; then |
| 435 | PROJECT="$CURDIR" |
| 436 | break |
| 437 | fi |
| 438 | CURDIR=`dirname $CURDIR` |
| 439 | done |
| 440 | if [ -z "$PROJECT" ] ; then |
| 441 | echo "ERROR: Launch this script from an application project directory, or use --project=<path>." |
| 442 | exit 1 |
| 443 | fi |
| 444 | fi |
| 445 | log "Using auto-detected project path: $PROJECT" |
| 446 | fi |
| 447 | |
| 448 | # Extract the package name from the manifest |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 449 | PACKAGE_NAME=`run_awk_manifest_script extract-package-name.awk` |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 450 | log "Found package name: $PACKAGE_NAME" |
| 451 | if [ $? != 0 -o "$PACKAGE_NAME" = "<none>" ] ; then |
| 452 | echo "ERROR: Could not extract package name from $PROJECT/$MANIFEST." |
| 453 | echo " Please check that the file is well-formed!" |
| 454 | exit 1 |
| 455 | fi |
| 456 | |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 457 | # If --launch-list is used, list all launchable activities, and be done with it |
| 458 | if [ "$OPTION_LAUNCH_LIST" = "yes" ] ; then |
| 459 | log "Extracting list of launchable activities from manifest:" |
| 460 | run_awk_manifest_script extract-launchable.awk |
| 461 | exit 0 |
| 462 | fi |
| 463 | |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 464 | APP_ABIS=`get_build_var APP_ABI` |
| 465 | log "ABIs targetted by application: $APP_ABIS" |
| 466 | |
| 467 | # Check the ADB command, and that we can connect to the device/emulator |
Andrew Hsieh | 201486c | 2012-05-16 14:03:11 +0800 | [diff] [blame] | 468 | ADB_TEST=`adb_cmd shell ls` |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 469 | if [ $? != 0 ] ; then |
| 470 | echo "ERROR: Could not connect to device or emulator!" |
| 471 | echo " Please check that an emulator is running or a device is connected" |
David 'Digit' Turner | 2e063fe | 2010-05-06 15:31:34 -0700 | [diff] [blame] | 472 | echo " through USB to this machine. You can use -e, -d and -s <serial>" |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 473 | echo " in case of multiple ones." |
| 474 | exit 1 |
| 475 | fi |
| 476 | |
David 'Digit' Turner | 4cff650 | 2010-06-01 14:40:11 -0700 | [diff] [blame] | 477 | # Check that the device is running Froyo (API Level 8) or higher |
| 478 | # |
David 'Digit' Turner | e3cfafb | 2011-03-15 15:43:12 +0100 | [diff] [blame] | 479 | adb_var_shell API_LEVEL getprop ro.build.version.sdk |
David 'Digit' Turner | 4cff650 | 2010-06-01 14:40:11 -0700 | [diff] [blame] | 480 | if [ $? != 0 -o -z "$API_LEVEL" ] ; then |
David 'Digit' Turner | fd20437 | 2010-09-14 15:10:38 +0200 | [diff] [blame] | 481 | echo "ERROR: Could not find target device's supported API level!" |
David 'Digit' Turner | 4cff650 | 2010-06-01 14:40:11 -0700 | [diff] [blame] | 482 | echo "ndk-gdb will only work if your device is running Android 2.2 or higher." |
| 483 | exit 1 |
| 484 | fi |
David 'Digit' Turner | 54be486 | 2010-06-03 11:57:49 -0700 | [diff] [blame] | 485 | log "Device API Level: $API_LEVEL" |
David 'Digit' Turner | 4cff650 | 2010-06-01 14:40:11 -0700 | [diff] [blame] | 486 | if [ "$API_LEVEL" -lt "8" ] ; then |
| 487 | echo "ERROR: ndk-gdb requires a target device running Android 2.2 (API level 8) or higher." |
David 'Digit' Turner | fd20437 | 2010-09-14 15:10:38 +0200 | [diff] [blame] | 488 | echo "The target device is running API level $API_LEVEL!" |
David 'Digit' Turner | 4cff650 | 2010-06-01 14:40:11 -0700 | [diff] [blame] | 489 | exit 1 |
| 490 | fi |
| 491 | |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 492 | # Get the target device's supported ABI(s) |
| 493 | # And check that they are supported by the application |
| 494 | # |
| 495 | COMPAT_ABI=none |
David 'Digit' Turner | e3cfafb | 2011-03-15 15:43:12 +0100 | [diff] [blame] | 496 | adb_var_shell CPU_ABI getprop ro.product.cpu.abi |
David 'Digit' Turner | 47eff9f | 2010-06-03 11:57:49 -0700 | [diff] [blame] | 497 | for ABI in $APP_ABIS; do |
| 498 | if [ "$ABI" = "$CPU_ABI" ] ; then |
| 499 | COMPAT_ABI=$CPU_ABI |
| 500 | break |
| 501 | fi |
| 502 | done |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 503 | |
David 'Digit' Turner | e3cfafb | 2011-03-15 15:43:12 +0100 | [diff] [blame] | 504 | adb_var_shell CPU_ABI2 getprop ro.product.cpu.abi2 |
| 505 | if [ $? != 0 -o -z "$CPU_ABI2" ] ; then |
| 506 | CPU_ABI2= |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 507 | log "Device CPU ABI: $CPU_ABI" |
| 508 | else |
| 509 | log "Device CPU ABIs: $CPU_ABI $CPU_ABI2" |
David 'Digit' Turner | 47eff9f | 2010-06-03 11:57:49 -0700 | [diff] [blame] | 510 | if [ "$COMPAT_ABI" = "none" ] ; then |
| 511 | for ABI in $APP_ABIS; do |
| 512 | if [ "$ABI" = "$CPU_ABI2" ] ; then |
| 513 | COMPAT_ABI=$CPU_ABI2 |
| 514 | break |
| 515 | fi |
| 516 | done |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 517 | fi |
| 518 | fi |
| 519 | if [ "$COMPAT_ABI" = none ] ; then |
| 520 | echo "ERROR: The device does not support the application's targetted CPU ABIs!" |
| 521 | if [ "$CPU_ABI2" = "$CPU_ABI" ] ; then |
| 522 | CPU_ABI2= |
| 523 | fi |
| 524 | echo " Device supports: $CPU_ABI $CPU_ABI2" |
| 525 | echo " Package supports: $APP_ABIS" |
| 526 | exit 1 |
| 527 | fi |
| 528 | log "Compatible device ABI: $COMPAT_ABI" |
| 529 | |
David 'Digit' Turner | ff7cd04 | 2012-02-14 02:43:52 +0100 | [diff] [blame] | 530 | # Get information from the build system |
| 531 | GDBSETUP_INIT=`get_build_var_for_abi NDK_APP_GDBSETUP $COMPAT_ABI` |
| 532 | log "Using gdb setup init: $GDBSETUP_INIT" |
| 533 | |
| 534 | TOOLCHAIN_PREFIX=`get_build_var_for_abi TOOLCHAIN_PREFIX $COMPAT_ABI` |
| 535 | log "Using toolchain prefix: $TOOLCHAIN_PREFIX" |
| 536 | |
| 537 | APP_OUT=`get_build_var_for_abi TARGET_OUT $COMPAT_ABI` |
| 538 | log "Using app out directory: $APP_OUT" |
| 539 | |
David 'Digit' Turner | fd20437 | 2010-09-14 15:10:38 +0200 | [diff] [blame] | 540 | # Check that the application is debuggable, or nothing will work |
| 541 | DEBUGGABLE=`run_awk_manifest_script extract-debuggable.awk` |
| 542 | log "Found debuggable flag: $DEBUGGABLE" |
| 543 | if [ $? != 0 -o "$DEBUGGABLE" != "true" ] ; then |
| 544 | # If gdbserver exists, then we built with 'ndk-build NDK_DEBUG=1' and it's |
| 545 | # ok to not have android:debuggable set to true in the original manifest. |
| 546 | # However, if this is not the case, then complain!! |
| 547 | if [ -f $PROJECT/libs/$COMPAT_ABI/gdbserver ] ; then |
| 548 | log "Found gdbserver under libs/$COMPAT_ABI, assuming app was built with NDK_DEBUG=1" |
| 549 | else |
| 550 | echo "ERROR: Package $PACKAGE_NAME is not debuggable ! You can fix that in two ways:" |
| 551 | echo "" |
| 552 | echo " - Rebuilt with the NDK_DEBUG=1 option when calling 'ndk-build'." |
| 553 | echo "" |
| 554 | echo " - Modify your manifest to set android:debuggable attribute to \"true\"," |
| 555 | echo " then rebuild normally." |
| 556 | echo "" |
| 557 | echo "After one of these, re-install to the device!" |
| 558 | exit 1 |
| 559 | fi |
| 560 | else |
| 561 | # DEBUGGABLE is true in the manifest. Let's check that the user didn't change the |
| 562 | # debuggable flag in the manifest without calling ndk-build afterwards. |
| 563 | if [ ! -f $PROJECT/libs/$COMPAT_ABI/gdbserver ] ; then |
| 564 | echo "ERROR: Could not find gdbserver binary under $PROJECT/libs/$COMPAT_ABI" |
| 565 | echo " This usually means you modified your AndroidManifest.xml to set" |
| 566 | echo " the android:debuggable flag to 'true' but did not rebuild the" |
| 567 | echo " native binaries. Please call 'ndk-build' to do so," |
| 568 | echo " *then* re-install to the device!" |
| 569 | exit 1 |
| 570 | fi |
David 'Digit' Turner | 2e063fe | 2010-05-06 15:31:34 -0700 | [diff] [blame] | 571 | fi |
| 572 | |
| 573 | # Let's check that 'gdbserver' is properly installed on the device too. If this |
| 574 | # is not the case, the user didn't install the proper package after rebuilding. |
| 575 | # |
David 'Digit' Turner | e3cfafb | 2011-03-15 15:43:12 +0100 | [diff] [blame] | 576 | adb_var_shell2 DEVICE_GDBSERVER ls /data/data/$PACKAGE_NAME/lib/gdbserver |
| 577 | if [ $? != 0 ]; then |
David 'Digit' Turner | 2e063fe | 2010-05-06 15:31:34 -0700 | [diff] [blame] | 578 | echo "ERROR: Non-debuggable application installed on the target device." |
David 'Digit' Turner | fd20437 | 2010-09-14 15:10:38 +0200 | [diff] [blame] | 579 | echo " Please re-install the debuggable version!" |
David 'Digit' Turner | 2e063fe | 2010-05-06 15:31:34 -0700 | [diff] [blame] | 580 | exit 1 |
| 581 | fi |
David 'Digit' Turner | e3cfafb | 2011-03-15 15:43:12 +0100 | [diff] [blame] | 582 | log "Found device gdbserver: $DEVICE_GDBSERVER" |
David 'Digit' Turner | 2e063fe | 2010-05-06 15:31:34 -0700 | [diff] [blame] | 583 | |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 584 | # Find the <dataDir> of the package on the device |
David 'Digit' Turner | e3cfafb | 2011-03-15 15:43:12 +0100 | [diff] [blame] | 585 | adb_var_shell2 DATA_DIR run-as $PACKAGE_NAME /system/bin/sh -c pwd |
David 'Digit' Turner | 4cff650 | 2010-06-01 14:40:11 -0700 | [diff] [blame] | 586 | if [ $? != 0 -o -z "$DATA_DIR" ] ; then |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 587 | echo "ERROR: Could not extract package's data directory. Are you sure that" |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 588 | echo " your installed application is debuggable?" |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 589 | exit 1 |
| 590 | fi |
David 'Digit' Turner | e3cfafb | 2011-03-15 15:43:12 +0100 | [diff] [blame] | 591 | log "Found data directory: '$DATA_DIR'" |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 592 | |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 593 | # Launch the activity if needed |
David 'Digit' Turner | 5b65625 | 2010-10-08 00:43:32 +0200 | [diff] [blame] | 594 | if [ "$OPTION_START" = "yes" ] ; then |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 595 | # If --launch is used, ignore --start, otherwise extract the first |
| 596 | # launchable activity name from the manifest and use it as if --launch=<name> |
| 597 | # was used instead. |
| 598 | # |
| 599 | if [ -z "$OPTION_LAUNCH" ] ; then |
| 600 | OPTION_LAUNCH=`run_awk_manifest_script extract-launchable.awk | sed 2q` |
| 601 | if [ $? != 0 ] ; then |
| 602 | echo "ERROR: Could not extract name of launchable activity from manifest!" |
| 603 | echo " Try to use --launch=<name> directly instead as a work-around." |
| 604 | exit 1 |
| 605 | fi |
| 606 | log "Found first launchable activity: $OPTION_LAUNCH" |
| 607 | if [ -z "$OPTION_LAUNCH" ] ; then |
| 608 | echo "ERROR: It seems that your Application does not have any launchable activity!" |
| 609 | echo " Please fix your manifest file and rebuild/re-install your application." |
| 610 | exit 1 |
| 611 | fi |
| 612 | fi |
| 613 | fi |
| 614 | |
| 615 | if [ -n "$OPTION_LAUNCH" ] ; then |
| 616 | log "Launching activity: $PACKAGE_NAME/$OPTION_LAUNCH" |
Andrew Hsieh | 201486c | 2012-05-16 14:03:11 +0800 | [diff] [blame] | 617 | run adb_cmd shell am start -n $PACKAGE_NAME/$OPTION_LAUNCH |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 618 | if [ $? != 0 ] ; then |
| 619 | echo "ERROR: Could not launch specified activity: $OPTION_LAUNCH" |
| 620 | echo " Use --launch-list to dump a list of valid values." |
| 621 | exit 1 |
| 622 | fi |
| 623 | # Sleep a bit, it sometimes take one second to start properly |
| 624 | # Note that we use the 'sleep' command on the device here. |
Andrew Hsieh | 201486c | 2012-05-16 14:03:11 +0800 | [diff] [blame] | 625 | run adb_cmd shell sleep $DELAY |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 626 | fi |
| 627 | |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 628 | # Find the PID of the application being run |
David 'Digit' Turner | 9c10d88 | 2011-10-27 13:10:58 +0200 | [diff] [blame] | 629 | PID=$(get_pid_of "$PACKAGE_NAME") |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 630 | log "Found running PID: $PID" |
| 631 | if [ $? != 0 -o "$PID" = "0" ] ; then |
| 632 | echo "ERROR: Could not extract PID of application on device/emulator." |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 633 | if [ -n "$OPTION_LAUNCH" ] ; then |
David 'Digit' Turner | 2e063fe | 2010-05-06 15:31:34 -0700 | [diff] [blame] | 634 | echo " Weird, this probably means one of these:" |
| 635 | echo "" |
| 636 | echo " - The installed package does not match your current manifest." |
| 637 | echo " - The application process was terminated." |
| 638 | echo "" |
| 639 | echo " Try using the --verbose option and look at its output for details." |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 640 | else |
| 641 | echo " Are you sure the application is already started?" |
| 642 | echo " Consider using --start or --launch=<name> if not." |
| 643 | fi |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 644 | exit 1 |
| 645 | fi |
| 646 | |
| 647 | # Check that there is no other instance of gdbserver running |
David 'Digit' Turner | 9c10d88 | 2011-10-27 13:10:58 +0200 | [diff] [blame] | 648 | GDBSERVER_PID=$(get_pid_of lib/gdbserver) |
| 649 | if [ "$GDBSERVER_PID" != "0" ]; then |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 650 | if [ "$OPTION_FORCE" = "no" ] ; then |
| 651 | echo "ERROR: Another debug session running, Use --force to kill it." |
| 652 | exit 1 |
| 653 | fi |
| 654 | log "Killing existing debugging session" |
Andrew Hsieh | 201486c | 2012-05-16 14:03:11 +0800 | [diff] [blame] | 655 | run adb_cmd shell kill -9 $GDBSERVER_PID |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 656 | fi |
| 657 | |
| 658 | # Launch gdbserver now |
| 659 | DEBUG_SOCKET=debug-socket |
Andrew Hsieh | 201486c | 2012-05-16 14:03:11 +0800 | [diff] [blame] | 660 | run adb_cmd shell run-as $PACKAGE_NAME lib/gdbserver +$DEBUG_SOCKET --attach $PID & |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 661 | if [ $? != 0 ] ; then |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 662 | echo "ERROR: Could not launch gdbserver on the device?" |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 663 | exit 1 |
| 664 | fi |
| 665 | log "Launched gdbserver succesfully." |
| 666 | |
| 667 | # Setup network redirection |
| 668 | log "Setup network redirection" |
Andrew Hsieh | 201486c | 2012-05-16 14:03:11 +0800 | [diff] [blame] | 669 | run adb_cmd forward tcp:$DEBUG_PORT localfilesystem:$DATA_DIR/$DEBUG_SOCKET |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 670 | if [ $? != 0 ] ; then |
David 'Digit' Turner | 0b2676b | 2010-04-27 12:33:46 -0700 | [diff] [blame] | 671 | echo "ERROR: Could not setup network redirection to gdbserver?" |
| 672 | echo " Maybe using --port=<port> to use a different TCP port might help?" |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 673 | exit 1 |
| 674 | fi |
| 675 | |
| 676 | # Get the app_server binary from the device |
| 677 | APP_PROCESS=$APP_OUT/app_process |
Andrew Hsieh | 201486c | 2012-05-16 14:03:11 +0800 | [diff] [blame] | 678 | run adb_cmd pull /system/bin/app_process `native_path $APP_PROCESS` |
David 'Digit' Turner | 5b65625 | 2010-10-08 00:43:32 +0200 | [diff] [blame] | 679 | log "Pulled app_process from device/emulator." |
| 680 | |
Andrew Hsieh | 201486c | 2012-05-16 14:03:11 +0800 | [diff] [blame] | 681 | run adb_cmd pull /system/lib/libc.so `native_path $APP_OUT/libc.so` |
David 'Digit' Turner | 5b65625 | 2010-10-08 00:43:32 +0200 | [diff] [blame] | 682 | log "Pulled libc.so from device/emulator." |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 683 | |
| 684 | # Now launch the appropriate gdb client with the right init commands |
| 685 | # |
| 686 | GDBCLIENT=${TOOLCHAIN_PREFIX}gdb |
| 687 | GDBSETUP=$APP_OUT/gdb.setup |
| 688 | cp -f $GDBSETUP_INIT $GDBSETUP |
David 'Digit' Turner | 5b65625 | 2010-10-08 00:43:32 +0200 | [diff] [blame] | 689 | #uncomment the following to debug the remote connection only |
| 690 | #echo "set debug remote 1" >> $GDBSETUP |
David 'Digit' Turner | caf0619 | 2010-10-18 12:39:51 +0200 | [diff] [blame] | 691 | echo "file `native_path $APP_PROCESS`" >> $GDBSETUP |
David 'Digit' Turner | a08d605 | 2010-04-16 12:45:33 -0700 | [diff] [blame] | 692 | echo "target remote :$DEBUG_PORT" >> $GDBSETUP |
| 693 | if [ -n "$OPTION_EXEC" ] ; then |
| 694 | cat $OPTION_EXEC >> $GDBSETUP |
| 695 | fi |
David 'Digit' Turner | caf0619 | 2010-10-18 12:39:51 +0200 | [diff] [blame] | 696 | $GDBCLIENT -x `native_path $GDBSETUP` |