blob: ba95931f6a998655b0f7540242a8439c7f74ef32 [file] [log] [blame]
David 'Digit' Turnera08d6052010-04-16 12:45:33 -07001#!/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#
Andrew Hsieh2c1bb7c2012-09-20 17:52:00 -070027PROGDIR=`dirname $0`
Andrew Hsiehd8276e92013-11-12 14:33:49 +080028PROGDIR=`cd $PROGDIR && pwd -P`
Andrew Hsieh2c1bb7c2012-09-20 17:52:00 -070029
30# Check if absolute NDK path contain space
31#
32case $PROGDIR in
33 *\ *) echo "ERROR: NDK path cannot contain space"
34 exit 1
35 ;;
36esac
37
Cole Wang65f49a52013-11-14 11:44:27 +080038NDK_BUILDTOOLS_PATH=$PROGDIR/build/tools
39. $PROGDIR/build/tools/prebuilt-common.sh
David 'Digit' Turnerbd7544d2013-06-10 10:17:33 +020040. $PROGDIR/build/tools/ndk-common.sh
David 'Digit' Turnera08d6052010-04-16 12:45:33 -070041
42force_32bit_binaries
43
David 'Digit' Turnerdb092432011-11-02 12:44:20 +010044# Find if a given shell program is available.
45# We need to take care of the fact that the 'which <foo>' command
46# may return either an empty string (Linux) or something like
47# "no <foo> in ..." (Darwin). Also, we need to redirect stderr
48# to /dev/null for Cygwin
49#
50# $1: program name
51# Out: program path, or empty string
52# Return: 0 on success, != 0 on error
53#
54find_program ()
55{
56 local PROG RET
57 PROG=$(which "$1" 2>/dev/null)
58 RET=$?
59 if [ $RET != 0 ]; then
60 PROG=
61 fi
62 echo "$PROG"
63 return $RET
64}
David 'Digit' Turnera08d6052010-04-16 12:45:33 -070065
David 'Digit' Turnerdb092432011-11-02 12:44:20 +010066quote_spaces ()
67{
68 echo "$@" | sed -e 's! !\ !g'
69}
70
71# If ADB_CMD is not defined, try to find a program named 'adb'
72# in our path.
73ADB_CMD=${ADB_CMD:-$(find_program adb)}
74ADB_FLAGS=${ADB_FLAGS:-}
Andrew Hsieh20f4e7e2012-06-29 14:57:28 -070075DEVICE_SERIAL=
David 'Digit' Turnerdb092432011-11-02 12:44:20 +010076
Ryan V. Bissell5cbc03f2012-12-11 18:05:12 -060077JDB_CMD=${JDB_CMD:-$(find_program jdb)}
78
David 'Digit' Turnerdb092432011-11-02 12:44:20 +010079AWK_CMD=${AWK_CMD:-$(find_program awk)}
David 'Digit' Turnera08d6052010-04-16 12:45:33 -070080
81DEBUG_PORT=5039
Ryan V. Bissell5cbc03f2012-12-11 18:05:12 -060082JDB_PORT=65534
David 'Digit' Turnera08d6052010-04-16 12:45:33 -070083
Cole Wang65f49a52013-11-14 11:44:27 +080084UNKNOWN_ABI=$(find_ndk_unknown_archs)
85
David 'Digit' Turner5b656252010-10-08 00:43:32 +020086# Delay in seconds between launching the activity and attaching gdbserver on it.
87# This is needed because there is no way to know when the activity has really
88# started, and sometimes this takes a few seconds.
89DELAY=2
90
David 'Digit' Turnera08d6052010-04-16 12:45:33 -070091PARAMETERS=
92OPTION_HELP=no
93OPTION_PROJECT=
94OPTION_FORCE=no
95OPTION_ADB=
96OPTION_EXEC=
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -070097OPTION_START=no
98OPTION_LAUNCH=
99OPTION_LAUNCH_LIST=no
David 'Digit' Turner5b656252010-10-08 00:43:32 +0200100OPTION_DELAY=
Ryan V. Bissell5cbc03f2012-12-11 18:05:12 -0600101OPTION_WAIT="-D"
Yu Xiaoleie146cc12014-12-09 20:53:09 +0800102OPTION_PACKAGE_NAME=
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700103
104check_parameter ()
105{
106 if [ -z "$2" ]; then
107 echo "ERROR: Missing parameter after option '$1'"
108 exit 1
109 fi
110}
111
112check_adb_flags ()
113{
114 if [ -n "$ADB_FLAGS" ] ; then
115 echo "ERROR: Only one of -e, -d or -s <serial> can be used at the same time!"
116 exit 1
117 fi
118}
119
120get_build_var ()
121{
122 if [ -z "$GNUMAKE" ] ; then
123 GNUMAKE=make
124 fi
David 'Digit' Turner7bbc2112012-08-27 14:23:19 +0200125 $GNUMAKE --no-print-dir -f $ANDROID_NDK_ROOT/build/core/build-local.mk -C $PROJECT DUMP_$1 | tail -1
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700126}
127
128get_build_var_for_abi ()
129{
130 if [ -z "$GNUMAKE" ] ; then
131 GNUMAKE=make
132 fi
David 'Digit' Turner7bbc2112012-08-27 14:23:19 +0200133 $GNUMAKE --no-print-dir -f $ANDROID_NDK_ROOT/build/core/build-local.mk -C $PROJECT DUMP_$1 APP_ABI=$2 | tail -1
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700134}
135
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700136# Used to run an awk script on the manifest
137run_awk_manifest_script ()
138{
139 $AWK_CMD -f $AWK_SCRIPTS/$1 $PROJECT/$MANIFEST
140}
141
David 'Digit' Turner47eff9f2010-06-03 11:57:49 -0700142if [ "$HOST_OS" = "cygwin" ] ; then
143# Return native path representation from cygwin one
144# $1: a cygwin-compatible path (e.g. /cygdrive/c/some/thing)
145# Return: path in host windows representation, e.g. C:/some/thing
146#
147# We use mixed mode (i.e. / as the directory separator) because
148# all the tools we use recognize it properly, and it avoids lots
149# of escaping nonsense associated with "\"
150#
151native_path ()
152{
153 cygpath -m $1
154}
155else # HOST_OS != windows
156native_path ()
157{
158 echo "$1"
159}
160fi # HOST_OS != windows
161
David 'Digit' Turnerb2e3ee72011-03-23 15:03:31 +0100162# We need to ensure the ANDROID_NDK_ROOT is absolute, otherwise calls
163# to get_build_var, get_build_var_for_abi and run_awk_manifest_script
164# might fail, e.g. when invoked with:
165#
166# cd $NDKROOT
167# ./ndk-gdb --project=/path/to/project
168#
169path_is_absolute ()
170{
171 local P P2
172 P=$1 # copy path
173 P2=${P#/} # remove / prefix, if any
174 [ "$P" != "$P2" ]
175}
176
177if ! path_is_absolute "$ANDROID_NDK_ROOT"; then
178 ANDROID_NDK_ROOT=$(pwd)/$ANDROID_NDK_ROOT
179fi
180
181
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700182VERBOSE=no
183while [ -n "$1" ]; do
184 opt="$1"
185 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
186 case "$opt" in
187 --help|-h|-\?)
188 OPTION_HELP=yes
189 ;;
190 --verbose)
191 VERBOSE=yes
192 ;;
193 -s)
194 check_parameter $1 $2
195 check_adb_flags
Andrew Hsieh20f4e7e2012-06-29 14:57:28 -0700196 ADB_FLAGS=" -s"
197 DEVICE_SERIAL=$2
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700198 shift
199 ;;
200 -s*)
201 check_adb_flags
202 optarg=`expr -- "$opt" : '-s\(.*\)'`
Andrew Hsieh20f4e7e2012-06-29 14:57:28 -0700203 ADB_FLAGS=" -s"
204 DEVICE_SERIAL=$optarg
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700205 ;;
206 -p)
207 check_parameter $1 $2
208 OPTION_PROJECT="$2"
209 shift
210 ;;
211 -p*)
212 optarg=`expr -- "$opt" : '-p\(.*\)'`
213 OPTION_PROJECT="$optarg"
214 ;;
215 --exec=*)
216 OPTION_EXEC="$optarg"
217 ;;
218 -x)
219 check_parameter $1 $2
220 OPTION_EXEC="$2"
221 shift
222 ;;
223 -x*)
224 optarg=`expr -- "$opt" : '-x\(.*\)'`
225 OPTION_EXEC="$optarg"
226 ;;
227 -e)
228 check_adb_flags
229 ADB_FLAGS=" -e"
230 ;;
231 -d)
232 check_adb_flags
233 ADB_FLAGS=" -d"
234 ;;
235 --adb=*) # specify ADB command
236 OPTION_ADB="$optarg"
237 ;;
238 --awk=*)
239 AWK_CMD="$optarg"
240 ;;
241 --project=*)
242 OPTION_PROJECT="$optarg"
243 ;;
244 --port=*)
245 DEBUG_PORT="$optarg"
246 ;;
247 --force)
248 OPTION_FORCE="yes"
249 ;;
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700250 --launch-list)
251 OPTION_LAUNCH_LIST="yes"
252 ;;
253 --launch=*)
254 OPTION_LAUNCH="$optarg"
255 ;;
256 --start)
257 OPTION_START=yes
258 ;;
David 'Digit' Turner5b656252010-10-08 00:43:32 +0200259 --delay=*)
260 OPTION_DELAY="$optarg"
261 ;;
Ryan V. Bissell5cbc03f2012-12-11 18:05:12 -0600262 --nowait)
263 JDB_PORT=
264 OPTION_WAIT=
265 ;;
Yu Xiaoleie146cc12014-12-09 20:53:09 +0800266 --package=*)
267 OPTION_PACKAGE_NAME="$optarg"
268 ;;
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700269 -*) # unknown options
270 echo "ERROR: Unknown option '$opt', use --help for list of valid ones."
271 exit 1
272 ;;
273 *) # Simply record parameter
274 if [ -z "$PARAMETERS" ] ; then
275 PARAMETERS="$opt"
276 else
277 PARAMETERS="$PARAMETERS $opt"
278 fi
279 ;;
280 esac
281 shift
282done
283
Ryan V. Bissell5cbc03f2012-12-11 18:05:12 -0600284if [ -z "$JDB_CMD" ] && [ -n "$OPTION_WAIT" ]; then
285 echo "ERROR: 'jdb' not found; you must either install the JDK, or specify --nowait"
286 exit 1
287fi
288if [ -n "$JDB_PORT" ] && [ "$JDB_PORT" = "$DEBUG_PORT" ]; then
289 echo "ERROR: --port specified cannot be $JDB_PORT without --nowait"
290 exit 1
291fi
292
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700293if [ "$OPTION_HELP" = "yes" ] ; then
294 echo "Usage: $PROGNAME [options]"
295 echo ""
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700296 echo "Setup a gdb debugging session for your Android NDK application."
297 echo "Read $$NDK/docs/NDK-GDB.TXT for complete usage instructions."
298 echo ""
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700299 echo "Valid options:"
300 echo ""
301 echo " --help|-h|-? Print this help"
302 echo " --verbose Enable verbose mode"
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700303 echo " --force Kill existing debug session if it exists"
Ryan V. Bissell5cbc03f2012-12-11 18:05:12 -0600304 echo " --nowait Don't have application wait for debugger to attach"
305 echo " (This might cause you to miss some early JNI breakpoints)"
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700306 echo " --start Launch application instead of attaching to existing one"
307 echo " --launch=<name> Same as --start, but specify activity name (see below)"
308 echo " --launch-list List all launchable activity names from manifest"
David 'Digit' Turner5b656252010-10-08 00:43:32 +0200309 echo " --delay=<secs> Delay in seconds between activity start and gdbserver attach."
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700310 echo " --project=<path> Specify application project path"
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700311 echo " -p <path> Same as --project=<path>"
Yu Xiaoleie146cc12014-12-09 20:53:09 +0800312 echo " --package=<name> Specify package name"
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700313 echo " --port=<port> Use tcp:localhost:<port> to communicate with gdbserver [$DEBUG_PORT]"
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700314 echo " --exec=<file> Execute gdb initialization commands in <file> after connection"
315 echo " -x <file> Same as --exec=<file>"
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700316 echo " --adb=<file> Use specific adb command [$ADB_CMD]"
317 echo " --awk=<file> Use specific awk command [$AWK_CMD]"
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700318 echo " -e Connect to single emulator instance"
319 echo " -d Connect to single target device"
320 echo " -s <serial> Connect to specific emulator or device"
321 echo ""
322 exit 0
323fi
324
325log "Android NDK installation path: $ANDROID_NDK_ROOT"
326
327if [ -n "$OPTION_EXEC" ] ; then
328 if [ ! -f "$OPTION_EXEC" ]; then
329 echo "ERROR: Invalid initialization file: $OPTION_EXEC"
330 exit 1
331 fi
332fi
333
David 'Digit' Turner5b656252010-10-08 00:43:32 +0200334if [ -n "$OPTION_DELAY" ] ; then
335 DELAY="$OPTION_DELAY"
336fi
337
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700338# Check ADB tool version
339if [ -n "$OPTION_ADB" ] ; then
David 'Digit' Turnerdb092432011-11-02 12:44:20 +0100340 ADB_CMD=$OPTION_ADB
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700341 log "Using specific adb command: $ADB_CMD"
342else
343 if [ -z "$ADB_CMD" ] ; then
344 echo "ERROR: The 'adb' tool is not in your path."
345 echo " You can change your PATH variable, or use"
346 echo " --adb=<executable> to point to a valid one."
347 exit 1
348 fi
349 log "Using default adb command: $ADB_CMD"
350fi
351
David 'Digit' Turnerdb092432011-11-02 12:44:20 +0100352ADB_CMD=$(quote_spaces $ADB_CMD)
353ADB_VERSION=$("$ADB_CMD" version 2>/dev/null)
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700354if [ $? != 0 ] ; then
355 echo "ERROR: Could not run ADB with: $ADB_CMD"
356 exit 1
357fi
358log "ADB version found: $ADB_VERSION"
359
Andrew Hsieh20f4e7e2012-06-29 14:57:28 -0700360if [ "x$DEVICE_SERIAL" = "x" ]; then
361 log "Using ADB flags: $ADB_FLAGS"
362else
363 log "Using ADB flags: $ADB_FLAGS" \"$DEVICE_SERIAL\"
364fi
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700365
Ryan V. Bissell5cbc03f2012-12-11 18:05:12 -0600366JDB_CMD=$(quote_spaces $JDB_CMD)
367log "Using JDB command: $JDB_CMD"
368
Andrew Hsieh201486c2012-05-16 14:03:11 +0800369# Run an ADB command with the right ADB flags
370# $1+: adb command parameter
371adb_cmd ()
372{
Andrew Hsieh20f4e7e2012-06-29 14:57:28 -0700373 if [ "x$DEVICE_SERIAL" = "x" ]; then
374 "$ADB_CMD" $ADB_FLAGS "$@"
375 else
376 # NOTE: We escape $ADB_CMD and $DEVICE_SERIAL in case they contains spaces.
377 "$ADB_CMD" $ADB_FLAGS "$DEVICE_SERIAL" "$@"
378 fi
Andrew Hsieh201486c2012-05-16 14:03:11 +0800379}
David 'Digit' Turnere3cfafb2011-03-15 15:43:12 +0100380
David 'Digit' Turnerb2e3ee72011-03-23 15:03:31 +0100381# Used internally by adb_var_shell and adb_var_shell2.
382# $1: 1 to redirect stderr to $1, 0 otherwise.
383# $2: Variable name that will contain the result
384# $3+: Command options
David 'Digit' Turnere3cfafb2011-03-15 15:43:12 +0100385_adb_var_shell ()
David 'Digit' Turner4cff6502010-06-01 14:40:11 -0700386{
David 'Digit' Turnere3cfafb2011-03-15 15:43:12 +0100387 # We need a temporary file to store the output of our command
David 'Digit' Turnerb2e3ee72011-03-23 15:03:31 +0100388 local CMD_OUT RET OUTPUT VARNAME REDIRECT_STDERR
389 REDIRECT_STDERR=$1
390 VARNAME=$2
391 shift; shift;
392 CMD_OUT=`mktemp /tmp/ndk-gdb-cmdout-XXXXXX`
David 'Digit' Turnere3cfafb2011-03-15 15:43:12 +0100393 # Run the command, while storing the standard output to CMD_OUT
394 # and appending the exit code as the last line.
David 'Digit' Turnerb2e3ee72011-03-23 15:03:31 +0100395 if [ "$REDIRECT_STDERR" != 0 ]; then
Andrew Hsieh201486c2012-05-16 14:03:11 +0800396 adb_cmd shell "$@" ";" echo \$? | sed -e 's![[:cntrl:]]!!g' > $CMD_OUT 2>&1
David 'Digit' Turnerb2e3ee72011-03-23 15:03:31 +0100397 else
Andrew Hsieh201486c2012-05-16 14:03:11 +0800398 adb_cmd shell "$@" ";" echo \$? | sed -e 's![[:cntrl:]]!!g' > $CMD_OUT
David 'Digit' Turnerb2e3ee72011-03-23 15:03:31 +0100399 fi
David 'Digit' Turnere3cfafb2011-03-15 15:43:12 +0100400 # Get last line in log, which contains the exit code from the command
401 RET=`sed -e '$!d' $CMD_OUT`
402 # Get output, which corresponds to everything except the last line
403 OUT=`sed -e '$d' $CMD_OUT`
404 rm -f $CMD_OUT
405 eval $VARNAME=\"\$OUT\"
406 return $RET
407}
408
409# Run a command through 'adb shell' and captures its standard output
410# into a variable. The function's exit code is the same than the command's.
411#
412# This is required because there is a bug where "adb shell" always returns
413# 0 on the host, even if the command fails on the device.
414#
415# $1: Variable name (e.g. FOO)
416# On exit, $FOO is set to the command's standard output
417#
418# The return status will be 0 (success) if the command succeeded
419# or 1 (failure) otherwise.
420adb_var_shell ()
421{
David 'Digit' Turnerec2b8dd2011-10-27 14:43:25 +0200422 _adb_var_shell 0 "$@"
David 'Digit' Turnere3cfafb2011-03-15 15:43:12 +0100423}
424
425# A variant of adb_var_shell that stores both stdout and stderr in the output
426# $1: Variable name
427adb_var_shell2 ()
428{
David 'Digit' Turnerec2b8dd2011-10-27 14:43:25 +0200429 _adb_var_shell 1 "$@"
David 'Digit' Turner4cff6502010-06-01 14:40:11 -0700430}
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700431
David 'Digit' Turner9c10d882011-10-27 13:10:58 +0200432# Return the PID of a given package or program, or 0 if it doesn't run
433# $1: Package name ("com.example.hellojni") or program name ("/lib/gdbserver")
434# Out: PID number, or 0 if not running
435get_pid_of ()
436{
Andrew Hsieh201486c2012-05-16 14:03:11 +0800437 adb_cmd shell ps | $AWK_CMD -f $AWK_SCRIPTS/extract-pid.awk -v PACKAGE="$1"
David 'Digit' Turner9c10d882011-10-27 13:10:58 +0200438}
439
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700440# Check the awk tool
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700441AWK_SCRIPTS=$ANDROID_NDK_ROOT/build/awk
442AWK_TEST=`$AWK_CMD -f $AWK_SCRIPTS/check-awk.awk`
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700443if [ $? != 0 ] ; then
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700444 echo "ERROR: Could not run '$AWK_CMD' command. Do you have it installed properly?"
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700445 exit 1
446fi
447if [ "$AWK_TEST" != "Pass" ] ; then
448 echo "ERROR: Your version of 'awk' is obsolete. Please use --awk=<file> to point to Nawk or Gawk!"
449 exit 1
450fi
451
452# Name of the manifest file
453MANIFEST=AndroidManifest.xml
454
455# Find the root of the application project.
456if [ -n "$OPTION_PROJECT" ] ; then
457 PROJECT=$OPTION_PROJECT
458 log "Using specified project path: $PROJECT"
459 if [ ! -d "$PROJECT" ] ; then
460 echo "ERROR: Your --project option does not point to a directory!"
461 exit 1
462 fi
463 if [ ! -f "$PROJECT/$MANIFEST" ] ; then
464 echo "ERROR: Your --project does not point to an Android project path!"
465 echo " It is missing a $MANIFEST file."
466 exit 1
467 fi
468else
469 # Assume we are in the project directory
470 if [ -f "$MANIFEST" ] ; then
471 PROJECT=.
472 else
473 PROJECT=
474 CURDIR=`pwd`
475 while [ "$CURDIR" != "/" ] ; do
476 if [ -f "$CURDIR/$MANIFEST" ] ; then
477 PROJECT="$CURDIR"
478 break
479 fi
480 CURDIR=`dirname $CURDIR`
481 done
482 if [ -z "$PROJECT" ] ; then
483 echo "ERROR: Launch this script from an application project directory, or use --project=<path>."
484 exit 1
485 fi
486 fi
487 log "Using auto-detected project path: $PROJECT"
488fi
489
Yu Xiaoleie146cc12014-12-09 20:53:09 +0800490if [ ! -z "$OPTION_PACKAGE_NAME" ]; then
491 PACKAGE_NAME="$OPTION_PACKAGE_NAME"
492 log "Using package name: $PACKAGE_NAME"
493else
494 # Extract the package name from the manifest
495 PACKAGE_NAME=`run_awk_manifest_script extract-package-name.awk`
Yu Xiaoleie146cc12014-12-09 20:53:09 +0800496 if [ $? != 0 -o "$PACKAGE_NAME" = "<none>" ] ; then
497 echo "ERROR: Could not extract package name from $PROJECT/$MANIFEST."
498 echo " Please check that the file is well-formed!"
499 exit 1
500 fi
Andrew Hsiehedda08c2015-02-13 16:10:38 +0800501 log "Found package name: $PACKAGE_NAME"
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700502fi
503
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700504# If --launch-list is used, list all launchable activities, and be done with it
505if [ "$OPTION_LAUNCH_LIST" = "yes" ] ; then
506 log "Extracting list of launchable activities from manifest:"
507 run_awk_manifest_script extract-launchable.awk
508 exit 0
509fi
510
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700511APP_ABIS=`get_build_var APP_ABI`
Andrew Hsieh3c3ce152012-08-03 10:44:09 -0700512if [ "$APP_ABIS" != "${APP_ABIS%%all*}" ] ; then
513# replace first "all" with all available ABIs
514 ALL_ABIS=`get_build_var NDK_ALL_ABIS`
515 APP_ABIS_FRONT="${APP_ABIS%%all*}"
516 APP_ABIS_BACK="${APP_ABIS#*all}"
517 APP_ABIS="${APP_ABIS_FRONT}${ALL_ABIS}${APP_ABIS_BACK}"
518fi
Andrew Hsieh748416e2014-01-22 18:21:18 -0800519# replace "armeabi-v7a-hard" with "armeabi-v7a"
520APP_ABIS=`echo $APP_ABIS | sed -e 's/armeabi-v7a-hard/armeabi-v7a/g'`
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700521log "ABIs targetted by application: $APP_ABIS"
522
523# Check the ADB command, and that we can connect to the device/emulator
Andrew Hsieh201486c2012-05-16 14:03:11 +0800524ADB_TEST=`adb_cmd shell ls`
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700525if [ $? != 0 ] ; then
526 echo "ERROR: Could not connect to device or emulator!"
527 echo " Please check that an emulator is running or a device is connected"
David 'Digit' Turner2e063fe2010-05-06 15:31:34 -0700528 echo " through USB to this machine. You can use -e, -d and -s <serial>"
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700529 echo " in case of multiple ones."
530 exit 1
531fi
532
David 'Digit' Turner4cff6502010-06-01 14:40:11 -0700533# Check that the device is running Froyo (API Level 8) or higher
534#
David 'Digit' Turnere3cfafb2011-03-15 15:43:12 +0100535adb_var_shell API_LEVEL getprop ro.build.version.sdk
David 'Digit' Turner4cff6502010-06-01 14:40:11 -0700536if [ $? != 0 -o -z "$API_LEVEL" ] ; then
David 'Digit' Turnerfd204372010-09-14 15:10:38 +0200537 echo "ERROR: Could not find target device's supported API level!"
David 'Digit' Turner4cff6502010-06-01 14:40:11 -0700538 echo "ndk-gdb will only work if your device is running Android 2.2 or higher."
539 exit 1
540fi
David 'Digit' Turner54be4862010-06-03 11:57:49 -0700541log "Device API Level: $API_LEVEL"
David 'Digit' Turner4cff6502010-06-01 14:40:11 -0700542if [ "$API_LEVEL" -lt "8" ] ; then
543 echo "ERROR: ndk-gdb requires a target device running Android 2.2 (API level 8) or higher."
David 'Digit' Turnerfd204372010-09-14 15:10:38 +0200544 echo "The target device is running API level $API_LEVEL!"
David 'Digit' Turner4cff6502010-06-01 14:40:11 -0700545 exit 1
546fi
547
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700548# Get the target device's supported ABI(s)
549# And check that they are supported by the application
550#
551COMPAT_ABI=none
Andrew Hsieh3c3ce152012-08-03 10:44:09 -0700552
Alexander Ivchenkof91d44c2015-01-14 15:54:00 +0300553# All modern Android images must support ro.product.cpu.abilist32
554# and ro.product.cpu.abilist64. Otherwise fall back to obsolete
555# ro.product.cpu.abi and ro.product.cpu.abi2
556adb_var_shell CPU_ABILIST64 getprop ro.product.cpu.abilist64
557adb_var_shell CPU_ABILIST32 getprop ro.product.cpu.abilist32
558CPU_ABIS="$CPU_ABILIST64,$CPU_ABILIST32"
559if [ -z "$CPU_ABILIST64" ] && [ -z "$CPU_ABILIST32" ] ; then
560 adb_var_shell CPU_ABI1 getprop ro.product.cpu.abi
561 adb_var_shell CPU_ABI2 getprop ro.product.cpu.abi2
562 CPU_ABIS="$CPU_ABI1,$CPU_ABI2"
563fi
564
565# Replace all ',' with space and add trailing space to
566# ease whole-word matching of APP_ABI
567CPU_ABILIST64=$(echo $CPU_ABILIST64 | tr ',' ' ')
568CPU_ABILIST32=$(echo $CPU_ABILIST32 | tr ',' ' ')
Andrew Hsieh3c3ce152012-08-03 10:44:09 -0700569CPU_ABIS=$(echo $CPU_ABIS | tr ',' ' ')
570log "Device CPU ABIs: $CPU_ABIS"
571
Andrew Hsieh5f2f1102013-04-08 14:22:19 +0800572APP_ABIS=$APP_ABIS" "
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700573
Cole Wang65f49a52013-11-14 11:44:27 +0800574adb_var_shell BCFILES run-as $PACKAGE_NAME /system/bin/sh -c "ls lib/*.bc"
Andrew Hsiehfc114052014-11-12 09:24:27 +0800575if [ $? = 0 ]; then
Cole Wang65f49a52013-11-14 11:44:27 +0800576 COMPAT_ABI="$UNKNOWN_ABI"
577else
Alexander Ivchenkof91d44c2015-01-14 15:54:00 +0300578 # Assume that compatible ABI is 32-bit
579 COMPAT_ABI_BITS=32
580 # First look compatible ABI in the list of 64-bit ABIs
581 if [ -n "$CPU_ABILIST64" ] ; then
582 for CPU_ABI64 in $CPU_ABILIST64; do
583 if [ "$APP_ABIS" != "${APP_ABIS%$CPU_ABI64 *}" ] ; then
584 COMPAT_ABI=$CPU_ABI64
585 COMPAT_ABI_BITS=64
586 break
587 fi
588 done
589 fi
590 # If we found nothing - look among 32-bit ABIs
591 if [ "$COMPAT_ABI" = none ] && [ -n "$CPU_ABILIST32" ] ; then
592 for CPU_ABI32 in $CPU_ABILIST32; do
593 if [ "$APP_ABIS" != "${APP_ABIS%$CPU_ABI32 *}" ] ; then
594 COMPAT_ABI=$CPU_ABI32
595 break
596 fi
597 done
598 fi
599 # Lastly, lets check ro.product.cpu.abi and ro.product.cpu.abi2
600 if [ "$COMPAT_ABI" = none ] && [ -z "$CPU_ABILIST64" ] && [ -z "$CPU_ABILIST32" ]; then
601 for CPU_ABI in $CPU_ABIS; do
602 if [ "$APP_ABIS" != "${APP_ABIS%$CPU_ABI *}" ] ; then
603 COMPAT_ABI=$CPU_ABI
604 break
605 fi
606 done
607 fi
Cole Wang65f49a52013-11-14 11:44:27 +0800608fi
Alexander Ivchenkof91d44c2015-01-14 15:54:00 +0300609
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700610if [ "$COMPAT_ABI" = none ] ; then
611 echo "ERROR: The device does not support the application's targetted CPU ABIs!"
Andrew Hsieh3c3ce152012-08-03 10:44:09 -0700612 echo " Device supports: $CPU_ABIS"
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700613 echo " Package supports: $APP_ABIS"
614 exit 1
615fi
616log "Compatible device ABI: $COMPAT_ABI"
617
David 'Digit' Turnerff7cd042012-02-14 02:43:52 +0100618# Get information from the build system
619GDBSETUP_INIT=`get_build_var_for_abi NDK_APP_GDBSETUP $COMPAT_ABI`
620log "Using gdb setup init: $GDBSETUP_INIT"
621
Cole Wang65f49a52013-11-14 11:44:27 +0800622# Find the prefix for gdb-client
623if [ "$COMPAT_ABI" != "$UNKNOWN_ABI" ]; then
624 TOOLCHAIN_PREFIX=`get_build_var_for_abi TOOLCHAIN_PREFIX $COMPAT_ABI`
625else
626 TOOLCHAIN_ABI=$(echo $CPU_ABIS | awk '{print $NF}')
627 TOOLCHAIN_PREFIX=`get_build_var_for_abi TOOLCHAIN_PREFIX $TOOLCHAIN_ABI`
628fi
David 'Digit' Turnerff7cd042012-02-14 02:43:52 +0100629log "Using toolchain prefix: $TOOLCHAIN_PREFIX"
630
631APP_OUT=`get_build_var_for_abi TARGET_OUT $COMPAT_ABI`
632log "Using app out directory: $APP_OUT"
633
David 'Digit' Turnerfd204372010-09-14 15:10:38 +0200634# Check that the application is debuggable, or nothing will work
635DEBUGGABLE=`run_awk_manifest_script extract-debuggable.awk`
Andrew Hsiehedda08c2015-02-13 16:10:38 +0800636RET=$?
David 'Digit' Turnerfd204372010-09-14 15:10:38 +0200637log "Found debuggable flag: $DEBUGGABLE"
Andrew Hsiehedda08c2015-02-13 16:10:38 +0800638if [ "$RET" != 0 -o "$DEBUGGABLE" != "true" ] ; then
Cole Wanga02bea02013-10-31 14:11:30 +0800639 # If gdb.setup exists, then we built with 'ndk-build NDK_DEBUG=1' and it's
David 'Digit' Turnerfd204372010-09-14 15:10:38 +0200640 # ok to not have android:debuggable set to true in the original manifest.
641 # However, if this is not the case, then complain!!
Cole Wanga02bea02013-10-31 14:11:30 +0800642 if [ -f $PROJECT/libs/$COMPAT_ABI/gdb.setup ] ; then
643 log "Found gdb.setup under libs/$COMPAT_ABI, assuming app was built with NDK_DEBUG=1"
David 'Digit' Turnerfd204372010-09-14 15:10:38 +0200644 else
645 echo "ERROR: Package $PACKAGE_NAME is not debuggable ! You can fix that in two ways:"
646 echo ""
647 echo " - Rebuilt with the NDK_DEBUG=1 option when calling 'ndk-build'."
648 echo ""
649 echo " - Modify your manifest to set android:debuggable attribute to \"true\","
650 echo " then rebuild normally."
651 echo ""
652 echo "After one of these, re-install to the device!"
653 exit 1
654 fi
655else
656 # DEBUGGABLE is true in the manifest. Let's check that the user didn't change the
657 # debuggable flag in the manifest without calling ndk-build afterwards.
Cole Wanga02bea02013-10-31 14:11:30 +0800658 if [ ! -f $PROJECT/libs/$COMPAT_ABI/gdb.setup ] ; then
659 echo "ERROR: Could not find gdb.setup under $PROJECT/libs/$COMPAT_ABI"
David 'Digit' Turnerfd204372010-09-14 15:10:38 +0200660 echo " This usually means you modified your AndroidManifest.xml to set"
661 echo " the android:debuggable flag to 'true' but did not rebuild the"
662 echo " native binaries. Please call 'ndk-build' to do so,"
663 echo " *then* re-install to the device!"
664 exit 1
665 fi
David 'Digit' Turner2e063fe2010-05-06 15:31:34 -0700666fi
667
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700668# Find the <dataDir> of the package on the device
David 'Digit' Turnere3cfafb2011-03-15 15:43:12 +0100669adb_var_shell2 DATA_DIR run-as $PACKAGE_NAME /system/bin/sh -c pwd
David 'Digit' Turner4cff6502010-06-01 14:40:11 -0700670if [ $? != 0 -o -z "$DATA_DIR" ] ; then
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700671 echo "ERROR: Could not extract package's data directory. Are you sure that"
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700672 echo " your installed application is debuggable?"
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700673 exit 1
674fi
David 'Digit' Turnere3cfafb2011-03-15 15:43:12 +0100675log "Found data directory: '$DATA_DIR'"
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700676
Cole Wanga02bea02013-10-31 14:11:30 +0800677# Let's check that 'gdbserver' is properly installed on the device too. If 'gdbserver'
678# is not there, push 'gdbserver' found in prebuilt.
679#
680DEVICE_GDBSERVER=$DATA_DIR/lib/gdbserver
681adb_var_shell2 GDBSERVER_RESULT ls $DEVICE_GDBSERVER
682if [ $? != 0 ]; then
683
684 # Figure out what's the target-arch and find gdbserver in prebuilt.
685 TARGET_ARCH=none
686
687 for ANDROID_ARCH in $ANDROID_NDK_ROOT/prebuilt/android-*; do
Alexander Ivchenkof91d44c2015-01-14 15:54:00 +0300688 ANDROID_ARCH=${ANDROID_ARCH#$ANDROID_NDK_ROOT/prebuilt/android-}
689 if [ "$COMPAT_ABI" = "$ANDROID_ARCH" ]; then
Cole Wanga02bea02013-10-31 14:11:30 +0800690 TARGET_ARCH=$ANDROID_ARCH
691 break;
692 fi
693 done
694
695 if [ $TARGET_ARCH != "none" ]; then
696 DEVICE_GDBSERVER=/data/local/tmp/gdbserver
697
698 adb shell mkdir -p /data/local/tmp
699 adb push ${ANDROID_NDK_ROOT}/prebuilt/android-${TARGET_ARCH}/gdbserver/gdbserver \
700 $DEVICE_GDBSERVER
701 log "Push gdbserver in device"
702 else
703 echo "ERROR: Non-debuggable application installed on the target device."
704 echo " Please re-install the debuggable version!"
705 exit 1
706 fi
707fi
708log "Found device gdbserver: $DEVICE_GDBSERVER"
709
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700710# Launch the activity if needed
David 'Digit' Turner5b656252010-10-08 00:43:32 +0200711if [ "$OPTION_START" = "yes" ] ; then
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700712 # If --launch is used, ignore --start, otherwise extract the first
713 # launchable activity name from the manifest and use it as if --launch=<name>
714 # was used instead.
715 #
716 if [ -z "$OPTION_LAUNCH" ] ; then
717 OPTION_LAUNCH=`run_awk_manifest_script extract-launchable.awk | sed 2q`
718 if [ $? != 0 ] ; then
719 echo "ERROR: Could not extract name of launchable activity from manifest!"
720 echo " Try to use --launch=<name> directly instead as a work-around."
721 exit 1
722 fi
723 log "Found first launchable activity: $OPTION_LAUNCH"
724 if [ -z "$OPTION_LAUNCH" ] ; then
725 echo "ERROR: It seems that your Application does not have any launchable activity!"
726 echo " Please fix your manifest file and rebuild/re-install your application."
727 exit 1
728 fi
729 fi
730fi
731
732if [ -n "$OPTION_LAUNCH" ] ; then
733 log "Launching activity: $PACKAGE_NAME/$OPTION_LAUNCH"
Andrew Hsiehedda08c2015-02-13 16:10:38 +0800734 adb_var_shell2 DUMMY am start $OPTION_WAIT -n $PACKAGE_NAME/$OPTION_LAUNCH
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700735 if [ $? != 0 ] ; then
736 echo "ERROR: Could not launch specified activity: $OPTION_LAUNCH"
737 echo " Use --launch-list to dump a list of valid values."
738 exit 1
739 fi
740 # Sleep a bit, it sometimes take one second to start properly
741 # Note that we use the 'sleep' command on the device here.
Andrew Hsieh201486c2012-05-16 14:03:11 +0800742 run adb_cmd shell sleep $DELAY
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700743fi
744
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700745# Find the PID of the application being run
David 'Digit' Turner9c10d882011-10-27 13:10:58 +0200746PID=$(get_pid_of "$PACKAGE_NAME")
Andrew Hsiehedda08c2015-02-13 16:10:38 +0800747RET=$?
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700748log "Found running PID: $PID"
Andrew Hsiehedda08c2015-02-13 16:10:38 +0800749if [ "$RET" != 0 -o "$PID" = "0" ] ; then
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700750 echo "ERROR: Could not extract PID of application on device/emulator."
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700751 if [ -n "$OPTION_LAUNCH" ] ; then
David 'Digit' Turner2e063fe2010-05-06 15:31:34 -0700752 echo " Weird, this probably means one of these:"
753 echo ""
754 echo " - The installed package does not match your current manifest."
755 echo " - The application process was terminated."
756 echo ""
757 echo " Try using the --verbose option and look at its output for details."
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700758 else
759 echo " Are you sure the application is already started?"
760 echo " Consider using --start or --launch=<name> if not."
761 fi
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700762 exit 1
763fi
764
765# Check that there is no other instance of gdbserver running
David 'Digit' Turner9c10d882011-10-27 13:10:58 +0200766GDBSERVER_PID=$(get_pid_of lib/gdbserver)
767if [ "$GDBSERVER_PID" != "0" ]; then
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700768 if [ "$OPTION_FORCE" = "no" ] ; then
769 echo "ERROR: Another debug session running, Use --force to kill it."
770 exit 1
771 fi
772 log "Killing existing debugging session"
Andrew Hsieh201486c2012-05-16 14:03:11 +0800773 run adb_cmd shell kill -9 $GDBSERVER_PID
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700774fi
775
776# Launch gdbserver now
777DEBUG_SOCKET=debug-socket
Andrew Hsiehedda08c2015-02-13 16:10:38 +0800778adb_var_shell2 DUMMY run-as $PACKAGE_NAME $DEVICE_GDBSERVER +$DEBUG_SOCKET --attach $PID &
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700779if [ $? != 0 ] ; then
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700780 echo "ERROR: Could not launch gdbserver on the device?"
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700781 exit 1
782fi
783log "Launched gdbserver succesfully."
784
785# Setup network redirection
786log "Setup network redirection"
Andrew Hsieh201486c2012-05-16 14:03:11 +0800787run adb_cmd forward tcp:$DEBUG_PORT localfilesystem:$DATA_DIR/$DEBUG_SOCKET
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700788if [ $? != 0 ] ; then
David 'Digit' Turner0b2676b2010-04-27 12:33:46 -0700789 echo "ERROR: Could not setup network redirection to gdbserver?"
790 echo " Maybe using --port=<port> to use a different TCP port might help?"
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700791 exit 1
792fi
793
Alexander Ivchenko94b323a2015-01-22 16:12:36 +0300794# If we are debugging 64-bit app, then we need to pull linker64,
795# app_process64 and libc.so from lib64 directory
Alexander Ivchenkof91d44c2015-01-14 15:54:00 +0300796LINKER_NAME=linker
797LIBDIR_NAME=lib
Alexander Ivchenko94b323a2015-01-22 16:12:36 +0300798APP_PROCESS_NAME=app_process32
Alexander Ivchenkof91d44c2015-01-14 15:54:00 +0300799if [ "$COMPAT_ABI_BITS" = 64 ] ; then
800 LINKER_NAME=linker64
801 LIBDIR_NAME=lib64
Alexander Ivchenko94b323a2015-01-22 16:12:36 +0300802 APP_PROCESS_NAME=app_process64
803else
804 # Old 32-bit devices do not have app_process32. Pull
805 # app_process in this case
Andrew Hsiehedda08c2015-02-13 16:10:38 +0800806 adb_var_shell2 DUMMY test -e /system/bin/$APP_PROCESS_NAME
Alexander Ivchenko94b323a2015-01-22 16:12:36 +0300807 if [ $? != 0 ] ; then
808 APP_PROCESS_NAME=app_process
809 fi
Alexander Ivchenkof91d44c2015-01-14 15:54:00 +0300810fi
811
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700812# Get the app_server binary from the device
Alexander Ivchenko94b323a2015-01-22 16:12:36 +0300813APP_PROCESS=$APP_OUT/app_process
Alexander Ivchenkof91d44c2015-01-14 15:54:00 +0300814run adb_cmd pull /system/bin/$APP_PROCESS_NAME `native_path $APP_PROCESS`
815log "Pulled $APP_PROCESS_NAME from device/emulator."
David 'Digit' Turner5b656252010-10-08 00:43:32 +0200816
Alexander Ivchenko94b323a2015-01-22 16:12:36 +0300817run adb_cmd pull /system/bin/$LINKER_NAME `native_path $APP_OUT/$LINKER_NAME`
Alexander Ivchenkof91d44c2015-01-14 15:54:00 +0300818log "Pulled $LINKER_NAME from device/emulator."
Andrew Hsieh07a6a662012-07-02 16:38:19 -0700819
Alexander Ivchenkof91d44c2015-01-14 15:54:00 +0300820run adb_cmd pull /system/$LIBDIR_NAME/libc.so `native_path $APP_OUT/libc.so`
821log "Pulled /system/$LIBDIR_NAME/libc.so from device/emulator."
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700822
Ryan V. Bissell5cbc03f2012-12-11 18:05:12 -0600823# Setup JDB connection, for --start or --launch
824if [ "$OPTION_START" = "yes" ] || [ -n "$OPTION_LAUNCH" ] ; then
825 if [ -n "$JDB_PORT" ]; then
826 log "Setup JDB connection"
827 run adb_cmd forward tcp:$JDB_PORT jdwp:$PID
828 sleep 1
829 $JDB_CMD -connect com.sun.jdi.SocketAttach:hostname=localhost,port=$JDB_PORT &
830 sleep 1
831 fi
832fi
833
Cole Wang65f49a52013-11-14 11:44:27 +0800834# If we are debugging UNKNOWN_ABI, download compiled *.so from device.
835#
Andrew Hsiehfc114052014-11-12 09:24:27 +0800836if [ "$COMPAT_ABI" = "$UNKNOWN_ABI" ]; then
Cole Wang65f49a52013-11-14 11:44:27 +0800837 for bc in $BCFILES; do
838 log "Pulled $(basename $bc .bc).so from device/emulator."
839 adb pull $DATA_DIR/lib/$(basename $bc .bc).so $PROJECT/obj/local/$UNKNOWN_ABI/
840 done
841fi
842
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700843# Now launch the appropriate gdb client with the right init commands
844#
845GDBCLIENT=${TOOLCHAIN_PREFIX}gdb
846GDBSETUP=$APP_OUT/gdb.setup
847cp -f $GDBSETUP_INIT $GDBSETUP
David 'Digit' Turner5b656252010-10-08 00:43:32 +0200848#uncomment the following to debug the remote connection only
849#echo "set debug remote 1" >> $GDBSETUP
David 'Digit' Turnercaf06192010-10-18 12:39:51 +0200850echo "file `native_path $APP_PROCESS`" >> $GDBSETUP
David 'Digit' Turnera08d6052010-04-16 12:45:33 -0700851echo "target remote :$DEBUG_PORT" >> $GDBSETUP
852if [ -n "$OPTION_EXEC" ] ; then
853 cat $OPTION_EXEC >> $GDBSETUP
854fi
David 'Digit' Turnercaf06192010-10-18 12:39:51 +0200855$GDBCLIENT -x `native_path $GDBSETUP`