Git Product home page Git Product logo

Comments (10)

jfirebaugh avatar jfirebaugh commented on August 22, 2024

The next error I encounter is:

ERROR: Failed to find ndk binary path, should be at './host-tools/bin'

I can't find any directories named "host-tools" in the NDK tree, so I think this is another bug.

from ndk.

jmgao avatar jmgao commented on August 22, 2024

Oops, ndk-gdb.py wasn't updated for some paths moving around. I believe this patch should fix things:

diff --git a/ndk-gdb.py b/ndk-gdb.py
index 59071be..25268c6 100755
--- a/ndk-gdb.py
+++ b/ndk-gdb.py
@@ -182,11 +182,7 @@ def extract_launchable(xmlroot):


 def ndk_bin_path():
-    path = os.path.join(NDK_PATH, "host-tools", "bin")
-    if not os.path.exists(path):
-        error("Failed to find ndk binary path, should be at '{}'".format(path))
-
-    return path
+    return os.path.dirname(os.path.realpath(__file__))


 def handle_args():

from ndk.

jmgao avatar jmgao commented on August 22, 2024

Sorry, this as well:

diff --git a/ndk-gdb.py b/ndk-gdb.py
index 25268c6..555e665 100755
--- a/ndk-gdb.py
+++ b/ndk-gdb.py
@@ -32,8 +32,8 @@ import xml.etree.cElementTree as ElementTree
 import logging

 # Shared functions across gdbclient.py and ndk-gdb.py.
-# ndk-gdb is installed to $NDK/host-tools/bin
-NDK_PATH = os.path.normpath(os.path.join(os.path.dirname(__file__), '../..'))
+# ndk-gdb is installed to $NDK/prebuilt/<platform>/bin
+NDK_PATH = os.path.normpath(os.path.join(os.path.dirname(__file__), '../../..'))
 sys.path.append(os.path.join(NDK_PATH, "python-packages"))
 import gdbrunner


from ndk.

jfirebaugh avatar jfirebaugh commented on August 22, 2024

👍 Thanks, getting further with those patches.

from ndk.

jfirebaugh avatar jfirebaugh commented on August 22, 2024

Next issue is:

make: ./build/core/build-local.mk: No such file or directory
make: *** No rule to make target `./build/core/build-local.mk'.  Stop.

Relevant code is:

    make_args = [args.make_cmd, "--no-print-dir", "-f",
                 os.path.join(NDK_PATH, "build/core/build-local.mk"),
                 "-C", args.project, "DUMP_{}".format(variable)]

It looks like this error is due to the fact that NDK_PATH is a relative path, and ./build/core/build-local.mk is therefore interpreted by make as relative to the project directory given as the -C option.

from ndk.

DanAlbert avatar DanAlbert commented on August 22, 2024

Since the thing that caused this issue was the move from the package root into prebuilts/, does it all work if you undo those patches and just move the script up to the top level?

from ndk.

jmgao avatar jmgao commented on August 22, 2024

Fixed a couple of these bugs, here's are the current differences between master and the r11 release:

diff --git a/ndk-gdb.py b/ndk-gdb.py
index 59071be..c8cf560 100755
--- a/ndk-gdb.py
+++ b/ndk-gdb.py
@@ -32,8 +32,8 @@ import xml.etree.cElementTree as ElementTree
 import logging

 # Shared functions across gdbclient.py and ndk-gdb.py.
-# ndk-gdb is installed to $NDK/host-tools/bin
-NDK_PATH = os.path.normpath(os.path.join(os.path.dirname(__file__), '../..'))
+# ndk-gdb is installed to $NDK/prebuilt/<platform>/bin
+NDK_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../..'))
 sys.path.append(os.path.join(NDK_PATH, "python-packages"))
 import gdbrunner

@@ -116,7 +116,7 @@ class ArgumentParser(gdbrunner.ArgumentParser):
             "--stdcxx-py-pr", dest="stdcxxpypr",
             help="Use C++ library pretty-printer",
             choices=["auto", "none", "gnustl", "stlport"],
-            default="none")
+            default="auto")


 def extract_package_name(xmlroot):
@@ -182,11 +182,7 @@ def extract_launchable(xmlroot):


 def ndk_bin_path():
-    path = os.path.join(NDK_PATH, "host-tools", "bin")
-    if not os.path.exists(path):
-        error("Failed to find ndk binary path, should be at '{}'".format(path))
-
-    return path
+    return os.path.dirname(os.path.realpath(__file__))


 def handle_args():
@@ -235,7 +231,7 @@ def find_project(args):
     manifest_name = "AndroidManifest.xml"
     if args.project is not None:
         log("Using project directory: {}".format(args.project))
-        args.project = os.path.realpath(args.project)
+        args.project = os.path.realpath(os.path.expanduser(args.project))
         if not os.path.exists(os.path.join(args.project, manifest_name)):
             msg = "could not find AndroidManifest.xml in '{}'"
             error(msg.format(args.project))
@@ -421,7 +417,7 @@ def get_gdbserver_path(args, package_name, app_data_dir, arch):

     # We need to upload our gdbserver
     log("App gdbserver not found at {}, uploading.".format(app_gdbserver_path))
-    local_path = "{}/gdbserver/{}/gdbserver"
+    local_path = "{}/prebuilt/android-{}/gdbserver/gdbserver"
     local_path = local_path.format(NDK_PATH, arch)
     remote_path = "/data/local/tmp/{}-gdbserver".format(arch)
     args.device.push(local_path, remote_path)
@@ -447,15 +443,15 @@ def get_gdbserver_path(args, package_name, app_data_dir, arch):
     return remote_path


-def pull_binaries(device, out_dir, is64bit):
+def pull_binaries(device, out_dir, app_64bit):
     required_files = []
     libraries = ["libc.so", "libm.so", "libdl.so"]

-    if is64bit:
+    if app_64bit:
         required_files = ["/system/bin/app_process64", "/system/bin/linker64"]
         library_path = "/system/lib64"
     else:
-        required_files = ["/system/bin/app_process", "/system/bin/linker"]
+        required_files = ["/system/bin/linker"]
         library_path = "/system/lib"

     for library in libraries:
@@ -470,12 +466,21 @@ def pull_binaries(device, out_dir, is64bit):
         log("Pulling '{}' to '{}'".format(required_file, local_path))
         device.pull(required_file, local_path)

+    # /system/bin/app_process is 32-bit on 32-bit devices, but a symlink to
+    # app_process64 on 64-bit. If we need the 32-bit version, try to pull
+    # app_process32, and if that fails, pull app_process.
+    if not app_64bit:
+        destination = os.path.realpath(out_dir + "/system/bin/app_process")
+        try:
+            device.pull("/system/bin/app_process32", destination)
+        except:
+            device.pull("/system/bin/app_process", destination)

-def generate_gdb_script(args, sysroot, binary_path, is64bit, connect_timeout=5):
+def generate_gdb_script(args, sysroot, binary_path, app_64bit, connect_timeout=5):
     gdb_commands = "file '{}'\n".format(binary_path)

     solib_search_path = [sysroot, "{}/system/bin".format(sysroot)]
-    if is64bit:
+    if app_64bit:
         solib_search_path.append("{}/system/lib64".format(sysroot))
     else:
         solib_search_path.append("{}/system/lib".format(sysroot))
@@ -560,7 +565,7 @@ def find_pretty_printer(pretty_printer):
         path = os.path.join("stlport", "stlport")
         function = "register_stlport_printers"
     pp_path = os.path.join(
-        NDK_PATH, "host-tools", "share", "pretty-printers", path)
+        ndk_bin_path(), "..", "share", "pretty-printers", path)
     return pp_path, function


@@ -636,9 +641,9 @@ def main():
     pid = pids[0]

     # Pull the linker, zygote, and notable system libraries
-    is64bit = "64" in abi
-    pull_binaries(device, out_dir, is64bit)
-    if is64bit:
+    app_64bit = "64" in abi
+    pull_binaries(device, out_dir, app_64bit)
+    if app_64bit:
         zygote_path = os.path.join(out_dir, "system", "bin", "app_process64")
     else:
         zygote_path = os.path.join(out_dir, "system", "bin", "app_process")
@@ -660,6 +665,9 @@ def main():
         def start_jdb():
             log("Starting jdb to unblock application.")

+            # Give gdbserver some time to attach.
+            time.sleep(0.5)
+
             # Do setup stuff to keep ^C in the parent from killing us.
             signal.signal(signal.SIGINT, signal.SIG_IGN)
             windows = sys.platform.startswith("win")
@@ -686,7 +694,7 @@ def main():


     # Start gdb.
-    gdb_commands = generate_gdb_script(args, out_dir, zygote_path, is64bit)
+    gdb_commands = generate_gdb_script(args, out_dir, zygote_path, app_64bit)
     gdb_flags = []
     if args.tui:
         gdb_flags.append("--tui")

from ndk.

mitchell-johnson avatar mitchell-johnson commented on August 22, 2024

I was experiencing the same issues as @jfirebaugh and have been resolved with the patch above when applied to a fresh download of the ndk. (OS X 64bit)

from ndk.

jmgao avatar jmgao commented on August 22, 2024

Fixed in r11b.

from ndk.

DanAlbert avatar DanAlbert commented on August 22, 2024

r11b is live: http://developer.android.com/ndk/downloads/index.html#download

from ndk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.