Android NDK app cannot hit any breakpoint

I am using the https://www.youtube.com/watch?v=kjsC-lKUgM8 tutorial to try and debug a simple NDK application. I did everything as it is in the video, except:

  • I am using OS X 10.9.3 instead of Windows.
  • I do not use android:debuggable=true(because eclipse considers it to be an error) in AndroidManifest.xml instead I set the NDK path from Preferences->Android->NDKand to Project Properties -> C/C++ Buildunchecked Use default build commandand installed there ndk-build NDK_DEBUG=1 APP_OPTIM=debug.
  • I do not use x86 emulator, but a Samsung Duos Sdevice withAndroid 4.0.4

But the breakpoiin that is used in the video does not fall into my case. I am trying to debug a simple NDK test project already on the 4th day. We studied a lot of materials:

  • Android Native Development Kit Poker Book
  • A bunch of forums and guides
  • Video

But he can't get to any damned breakpoint. Please help if you can do this.

+4
source share
1 answer

Below is a snippet of a tutorial that I wrote for our internal Android development team. The bulk of which was derived from this blog: http://mhandroid.wordpress.com/

Important notes:

  • I am using a Linux environment (Ubuntu 12.04) to work with Android.
  • I used the ADT Bundle for Linux, Build: v22.2.1-833290 (Eclipse IDE + Extras).
  • These steps are for debugging from Java activity to a common JNI object.
  • , , . Android, JNI, Java.

  • .

    AndroidManifest.xml, "" Debuggable = true. , , .

  • . :

    ndk-build -B
    

    :

    Gdbserver: [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
    Gdbsetup: libs/armeabi/gdb.setup
    Compile ++ thumb: DebuggingTestJNI <= com_sample_test_DebuggingTestActivity.cpp StaticLibrary: libstd++. A SharedLibrary: libDebuggingTestJNI.so
    : libDebuggingTestJNI.so = > ​​libs/armeabi/libDebuggingTestJNI.so

  • . Eclipse " β†’ ". , / . , Eclipse .apk.

  • Java. Java.

    • Eclipse . " ...".
    • "Android-" . Android.
    • ":" "DebuggingTest Java Debug" , , DebuggingTest Java.
    • ":" "..." " ".
    • "", .
    • "".
    • Eclipse " ...".
    • "..."
    • "DebuggingTest Java Debug" "" .

      ​​ . , . "DebuggingTest Java Debug" .

        
  • ndk-gdb.

    • Eclipse "DebuggingTest Java Debug" . DebuggingTest.apk Android- .
    • DebuggingTest :

      -GDB

    , :

    GNU gdb 6.6   Copyright (C) 2006 Free Software Foundation, Inc.   GDB - , GNU General Public License,    / .    " ", .    GDB . " " .    GDB "-host = x86_64-linux-gnu -target = arm-elf-linux".   ( )   ...

    , :

    : PID /.      , ?      --start --launch = .    Android.mk $(info), :   cp: target ./obj/local/armeabi/gdb.setup' is not a directory /home/Dev/NDK/ndk-gdb: 639: cannot create start DebuggingTest/jni/Android.mk end DebuggingTest/jni/Android.mk ./obj/local/armeabi/gdb.setup: Directory nonexistent /home/Dev/NDK/ndk-gdb: 640: cannot create start DebuggingTest/jni/Android.mk end DebuggingTest/jni/Android.mk ./obj/local/armeabi/gdb.setup: Directory nonexistent start: invalid option: -x Try start --help ' .

    ndk-gdb , :

    : , Use -force, .

    , ERROR. ndk-gdb .

    ndk-gdb , , app_process, gdb.setup libc.so obj/local/armeabi/sub . .

  • .

    • CTRL + Z, ndk-gdb.
    • Eclipse Run β†’ Terminate.
  • C/++. C/++.

    • Eclipse "Debug Configurations...".
    • " C/++" . C/++.
    • ":" "DebuggingTest C CPP Debug", , DebuggingTest C/++.
    • "":
      • "..." "C/++ Application:". "/home/Test/testing/DebuggingTest/obj/local/armeabi/app_process" "" .
      • "..." ":".
      • "DebuggingTest" "OK" .
      • " ".
      • " GDB (DSF)... - ...". " ...".
      • " ".
      • "Standard Create Process Launcher" "OK" .
    • "":
      • ":" "gdbserver".
      • " :".
    • "":
      • "..." " GDB:".
      • "/home/Dev/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gdb" "" . Android NDK.
      • " GDB:" "/home/Test/testing/DebuggingTest/obj/local/armeabi/gdb2.setup". gdb2.setup , .
      • " ".
    • "":
      • ":" TCP
      • " :" 5039
      • "", .
    • ""
    • Eclipse " ...".
    • "..."
    • "DebuggingTest C CPP Debug" "OK" .

    ​​ . , . "DebuggingTest C CPP Debug" .

  • gdb2.setup. Eclipse "target remote: 5039" gdb, ( 5039 ). gdb.setup NDK, gdb2.setup Eclipse gdb2.setup( ).

    • "/home/Test/testing/DebuggingTest/obj/local/armeabi/".
    • "gdb.setup" . "gdb (copy).setup".
    • "gdb (copy).setup" "gdb2.setup".
    • gdb2.setup, .
    • "set solib-search-path./obj/local/armeabi" "set solib-search-path/home/Test/testing/DebuggingTest/obj/local/armeabi".
    • "./obj/local/armeabi/app_process" "file/home/Test/testing/DebuggingTest/obj/local/armeabi/app_process".
    • , "target remote: 5039".
    • .
  • ndk-gdb-eclipse. Eclipse. Eclipse gdb, gdb ndk-gdb. , -.

    • "/home/Dev/NDK".
    • ndk-gdb . "ndk-gdb (copy)".
    • "ndk-gdb (copy)" "ndk-gdb-eclipse".
    • ndk-gdb-eclipse, β†’ ...
    • , "$ GDBCLIENT -x native_path $GDBSETUP" (, ) , "#".
    • .

    Eclipse IDE ndk-gdb-eclipse ndk-gdb.. p >

/

  • Java-!

    • DebuggingTestActivity.java 20 (System.out.println( "hello world!" )).
    • . onCreate(), , .
    • DebuggingTest , "DebuggingTest Java Debug" .
    • " ". "", , Debug Perspective. .
    • , .

    : onCreate. . , onCreate System.loadLibrary( "DebuggingTestJNI" ). loadLibrary , onCreate, , , . , , !

  • C/++!

    • DebuggingTest :

      ndk-gdb-eclipse < - , 6

        
    • - .  
    • Eclipse C/++, "DebuggingTest C CPP Debug"   
    • .. , Eclipse, , ...  
    • Java-.  
    • Eclipse Java.  
    • DebuggingTest/jni/com_sample_test_DebuggingTestActivity.cpp  
    • JNI, .  
    • "" β†’ "" (F8)  
    • Perspective Switch, Outlook Debug.  

, !

!!!

, , , .

+4

Source: https://habr.com/ru/post/1542874/


All Articles