1

I am trying to use ndk-stack command provided with the ndk.

Unfortunately when I run it, the script crashes.

The command I am running on windows is is...

ndk-stack.cmd -sym build/intermediates/cmake/debug/obj/armeabi-v7a -dump stack.txt

stack.txt file contains the the tombstone from logcat.

The error I am receiving is....

Traceback (most recent call last): File "C:\Android\android-ndk-r20\prebuilt\windows-x86_64\bin\ndk-stack.py", line 134, in main() File "C:\Android\android-ndk-r20\prebuilt\windows-x86_64\bin\ndk-stack.py", line 83, in main proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) File "C:\Android\android-ndk-r20\prebuilt\windows-x86_64\lib\python2.7/subprocess.py", line 711, in init errread, errwrite) File "C:\Android\android-ndk-r20\prebuilt\windows-x86_64\lib\python2.7/subprocess.py", line 948, in _execute_child startupinfo) WindowsError: [Error 2] The system cannot find the file specified [Finished in 0.1s]

Scorb
  • 1,654
  • 13
  • 70
  • 144

1 Answers1

4

cferris fixed this the other day: https://android-review.googlesource.com/c/platform/ndk/+/977970

here's the patch you'll need to apply locally (or wait for NDK r21):

diff --git a/ndk-stack.py b/ndk-stack.py
index 93aa0297..f1bb4cd6 100755
--- a/ndk-stack.py
+++ b/ndk-stack.py
@@ -32,6 +32,10 @@ def find_llvm_symbolizer():

     Returns: An absolute path to llvm-symbolizer(1)."""

+    llvm_symbolizer = 'llvm-symbolizer'
+    if os.name == 'nt':
+        # Windows has to include the exe or it won't be found.
+        llvm_symbolizer += '.exe'
     # ndk-stack is installed to $NDK/prebuilt/<platform>/bin, so from
     # `~/Downloads/android-ndk-r18/prebuilt/linux-x86_64/bin/ndk-stack`...
     # ...get `/usr/enh/Downloads/android-ndk-r18/`:
@@ -42,14 +46,14 @@ def find_llvm_symbolizer():
     # And from there construct the llvm-symbolizer path.
     llvm_bin = os.path.join(ndk_root, 'toolchains', 'llvm', 'prebuilt', arch,
                             'bin')
-    path = os.path.join(llvm_bin, 'llvm-symbolizer')
+    path = os.path.join(llvm_bin, llvm_symbolizer)
     if os.path.exists(path):
         return path

     # Okay, maybe we're a standalone toolchain? (https://github.com/android-ndk
/ndk/issues/931)
     # In that case, llvm-symbolizer and ndk-stack are conveniently in
     # the same directory...
-    return os.path.abspath(os.path.join(ndk_bin, 'llvm-symbolizer'))
+    return os.path.abspath(os.path.join(ndk_bin, llvm_symbolizer))


 def main():

basically "you need to add .exe to the two places where llvm-symbolizer is mentioned". (i introduced this bug because i didn't think you needed to explicitly say "blah.exe".)

  • that worked. But now it is only providing result for one stackframe deep, whereas the tombstone list many stack frames. I guess that is a separate issue outside the scope of this specific question though. – Scorb Jun 26 '19 at 20:47
  • I couldn't use the patch on Windows (it said error: corrupt patch at line 6), but manually applying the changes did help. – user3738870 Oct 27 '19 at 22:10
  • sorry it took so long, but NDK r21 beta 1 is out now, btw: https://github.com/android/ndk/wiki – Elliott Hughes Oct 28 '19 at 23:02