简体   繁体   中英

How do I debug Android native lib in eclipse with ARM DS-5 without going crazy?

I summon the Android NDK debugging Ninjas here!

I've tried so many tutorials about debugging Android native code, so I can't remember them all. Now I'm trying to get ARM DS-5 work. I've made it work with the Android NDK samples, where the main Activity loads the library. Laggy, but works.

But my project is a little bit complicated. My Main Activity has a button, when I tap it, SubActivity is launched, and it loads native lib. When I just try to use the DS-5 debugger, when Main Activity is loaded, I suppose debugger tries to connect to lib, but fails, saying:

Execution stopped at: 0xAFD0C52C
Connected to unknown platform
0xAFD0C52C   POP      {r4,r7}
file "D:\workspace\Project\bin\app_process"
WARNING(IMG53): app_process has no line debug information 
add-symbol-file "D:\workspace\Project\bin\libc.so"
Loading library symbols: libc.so
WARNING(IMG53): libc.so has no line debug information 
Execution stopped at: 0xAFD0C748
In thread 2 (OS thread id 7606)
In __futex_syscall3 (no debug info)
add-symbol-file "D:\workspace\Project\obj\local\armeabi\libName.so"
Execution stopped at: 0xAFD0C748
In thread 3 (OS thread id 7607)
Execution stopped at: 0xAFD0BFFC
In thread 4 (OS thread id 7608)
In __rt_sigtimedwait (no debug info)
Execution stopped at: 0xAFD0B854
In thread 5 (OS thread id 7609)
In select (no debug info)
Execution stopped at: 0xAFD0C748
In thread 6 (OS thread id 7610)
In __futex_syscall3 (no debug info)
Execution stopped at: 0xAFD0B70C
In thread 7 (OS thread id 7611)
In __ioctl (no debug info)
Execution stopped at: 0xAFD0B70C
In thread 8 (OS thread id 7612)
Execution stopped at: 0xAFD0C52C
In thread 1 (OS thread id 7605)
In epoll_wait (no debug info)
0xAFD0C52C   POP      {r4,r7}
WARNING(CMD454): The shared library D:\workspace\Project\obj\local\armeabi\libName.so is currently not loaded by the application so the request has been pended
cd "D:\workspace"
Working directory "D:\workspace"
directory "D:\workspace\Project"
Source directories searched: D:\workspace\Project;$cdir;$cwd;$idir
break -d -p "D:\workspace\Project\jni\Name.cpp":525
WARNING(CMD452-COR167): 
! Breakpoint 1 has been pended
! No compilation unit matching "D:/workspace/Project/jni/Name.cpp" was found
condition 1 
break-script 1 ""
ignore 1 0
break-stop-on-threads 1 
unsilence 1
Breakpoint 1 unsilenced

I think that it tries to connect to native lib when Main Activity starts. But library is loaded later!

What I tried:

  • Setting Java breakpoint in SubActivity, after native lib was loaded, then attaching DS-5 debugger. But I get various errors from Eclipse saying about timeouts, whatever.
  • In the debug config settings I can't select the activity, which should trigger debugging of native code, there's combobox, but it's disabled:

The question itself: if my lib is not loaded by main Activity, how do I make DS-5 wait for lib to load?

在此输入图像描述

Do you really need to have exact behaviour between debug and release version ? If not, load the library in the main activity, too in debug version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM