OSDN Git Service

ndk-gdb: fix to work properly with OS X's BSD awk
authorDavid 'Digit' Turner <digit@google.com>
Thu, 3 Jun 2010 18:57:49 +0000 (11:57 -0700)
committerDavid 'Digit' Turner <digit@google.com>
Fri, 4 Jun 2010 17:56:51 +0000 (10:56 -0700)
"gensub()" is a GNUAwk-ism that should not be used.

Change-Id: I2df89efc165c84034594b98327921f9461188a76

build/awk/extract-pid.awk
docs/CHANGES.TXT
ndk-gdb

index d646af7..9a5677c 100644 (file)
@@ -30,13 +30,20 @@ BEGIN {
     PID=0
     FS=" "
     # Need to escape the dots in the package name
-    REGEX=gensub("\\.","\\\\.","g",PACKAGE)
+    #
+    # The first argument is the regular expression '\.'
+    # corresponding to a single dot character. The second
+    # argument is the replacement string, which will be '\.'
+    # for every input dot. Finally, we need to escape each
+    # backslash in the Awk strings.
+    #
+    gsub("\\.","\\.",PACKAGE)
 }
 
 # We use the fact that the 9th column of the 'ps' output
 # contains the package name, while the 2nd one contains the pid
 #
-$9 ~ REGEX {
+$9 ~ PACKAGE {
     PID=$2
 }
 
index 949d3e0..f6669b2 100644 (file)
@@ -12,7 +12,8 @@ OTHER FIXES & CHANGES:
 
 - ndk-gdb: check the target device's API level, and dump an error message if
   it is not at least 8 (Android 2.2 a.k.a. Froyo). Fix script to properly
-  remove control characters like '\r' from adb shell's output.
+  remove control characters like '\r' from adb shell's output. Also fix
+  script to work properly with OS X's BSD awk.
 
 - ndk-build: Make AndroidManifest.xml optional. Now the build scripts will try
   to look for jni/Android.mk if no manifest is found. If you don't use this,
diff --git a/ndk-gdb b/ndk-gdb
index 6271290..3cd7be4 100755 (executable)
--- a/ndk-gdb
+++ b/ndk-gdb
@@ -340,6 +340,7 @@ if [ $? != 0 -o -z "$API_LEVEL" ] ; then
     echo "ndk-gdb will only work if your device is running Android 2.2 or higher."
     exit 1
 fi
+log "Device API Level: $API_LEVEL"
 if [ "$API_LEVEL" -lt "8" ] ; then
     echo "ERROR: ndk-gdb requires a target device running Android 2.2 (API level 8) or higher."
     echo "The target device is running API level $API_LEVEL !"