How to Debug native code using ndk-gdb - android

This is what I am getting after running ndk-gdb according to many tutorials when it links to you to (gdb) server you have to type continue but what after that how to debug the code there after. In my case it displays Continuing and remain like this. WHat i have to do further I am totally clueless.
Arathore#chd-arathore-AND /cygdrive/d/All_Work/All_ARathore/All_Workspace_Practice/ndkfoo
$ /cygdrive/d/All_Required_Stuff/Android/android-ndk-r8e/ndk-gdb --verbose --adb=/cygdrive/D/All_Required_Stuff/Android/android-sdk-windows/platform-tools/adb.exe
Android NDK installation path: /cygdrive/d/All_Required_Stuff/Android/android-ndk-r8e
Using specific adb command: /cygdrive/D/All_Required_Stuff/Android/android-sdk-windows/platform-tools/adb.exe
ADB version found: Android Debug Bridge version 1.0.31
Using ADB flags:
Using auto-detected project path: .
Found package name: com.example.ndkfoo
/cygdrive/d/All_Required_Stuff/Android/android-ndk-r8e/build/core/add-application.mk:128: Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 8 in /cygdrive/d/All_Work/All_ARathore/All_Workspace_Practice/ndkfoo/AndroidManifest.xml
ABIs targetted by application: armeabi
Device API Level: 17
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi
/cygdrive/d/All_Required_Stuff/Android/android-ndk-r8e/build/core/add-application.mk:128: Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 8 in /cygdrive/d/All_Work/All_ARathore/All_Workspace_Practice/ndkfoo/AndroidManifest.xml
Using gdb setup init: /cygdrive/d/All_Work/All_ARathore/All_Workspace_Practice/ndkfoo/libs/armeabi/gdb.setup
/cygdrive/d/All_Required_Stuff/Android/android-ndk-r8e/build/core/add-application.mk:128: Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 8 in /cygdrive/d/All_Work/All_ARathore/All_Workspace_Practice/ndkfoo/AndroidManifest.xml
Using toolchain prefix: /cygdrive/d/All_Required_Stuff/Android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-
/cygdrive/d/All_Required_Stuff/Android/android-ndk-r8e/build/core/add-application.mk:128: Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 8 in /cygdrive/d/All_Work/All_ARathore/All_Workspace_Practice/ndkfoo/AndroidManifest.xml
Using app out directory: ./obj/local/armeabi
Found debuggable flag: true
Found device gdbserver: /data/data/com.example.ndkfoo/lib/gdbserver
Found data directory: '/data/data/com.example.ndkfoo'
Found running PID: 1106
Launched gdbserver succesfully.
Setup network redirection
## COMMAND: adb_cmd shell run-as com.example.ndkfoo lib/gdbserver +debug-socket --attach 1106
## COMMAND: adb_cmd forward tcp:5039 localfilesystem:/data/data/com.example.ndkfoo/debug-socket
## COMMAND: adb_cmd pull /system/bin/app_process obj/local/armeabi/app_process
Attached; pid = 1106
Listening on Unix socket debug-socket
99 KB/s (9592 bytes in 0.093s)
Pulled app_process from device/emulator.
## COMMAND: adb_cmd pull /system/bin/linker obj/local/armeabi/linker
54 KB/s (63240 bytes in 1.140s)
Pulled linker from device/emulator.
## COMMAND: adb_cmd pull /system/lib/libc.so obj/local/armeabi/libc.so
75 KB/s (297604 bytes in 3.828s)
Pulled libc.so from device/emulator.
GNU gdb (GDB) 7.3.1-gg2
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i586-pc-mingw32msvc --target=arm-linux-android".
For bug reporting instructions, please see:
<http://source.android.com/source/report-bugs.html>.
Remote debugging from host 0.0.0.0
libthread_db:td_ta_new: Probing system for platform bug.
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1147/task/1147/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1106/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1109/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1111/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1112/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1113/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1114/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1115/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1116/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1117/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1118/status
libthread_db:td_ta_new: Victory: We can debug theads!
0x40037ebc in epoll_wait () from D:/All_Work/All_ARathore/All_Workspace_Practice/ndkfoo/obj/local/armeabi/libc.so
warning: Could not load shared library symbols for 72 libraries, e.g. libstdc++.so.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
warning: Breakpoint address adjusted from 0x40005a53 to 0x40005a52.
(gdb) continue
Continuing.
How to debug?
According to the ndk-Docs
You can set breakpoints with 'b <location>' and resume execution with 'c'
(for 'continue'). See the GDB manual for a list of commands.
How to make this happen.

The commands are the same as in gdb. A basic primer:
Set a breakpoint by entering b <function name> or b <file>:<line number>
step into functions by typing s
go to next line by typing n
continue execution with c
print a variable or expression value with print <exp>
repeat the last typed command by just hitting enter
You can find much more comprehensive gdb tutorials online. I personally have a gdb cheatsheet printed out and posted on my wall. This should be enough to get you started.

this tutorial will show you exactly how to debugging with ndk-gdb in eclipse.

Related

Unable to build Botan for Android on Windows

I cannot understand how to build Botan for android, according on the instruction here:
$ export CXX=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang++
$ ./configure.py --os=android --cc=clang --cpu=arm64
i cannot understand how to use this commands on Windows, also reading previous issues did not help me, can you tell me how did you build this library on windows step-by-step, just your command examples?
I used --cc-bin option of configure.py to specify the path to the compiler, it is considered a solution for windows, but what i have is:
D:\Programming\Libraries\botanAndroid\botan-master>python configure.py --cc-bin=D:\Android\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64\bin\armv7a-linux-androideabi28-clang++ --os=android --cc=clang --cpu=armv7
INFO: configure.py invoked with options "--cc-bin=D:\Android\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64\bin\armv7a-linux-androideabi28-clang++ --os=android --cc=clang --cpu=armv7"
INFO: Configuring to build Botan 2.14.0 (revision unknown)
INFO: Running under 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)]
INFO: Autodetected platform information: OS="Windows" machine="AMD64" proc="Intel64 Family 6 Model 142 Stepping 10, GenuineIntel"
INFO: Canonicalized CPU target armv7 to arm32
WARNING: Could not execute ['D:\Android\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64\bin\armv7a-linux-androideabi28-clang++', '-E', 'src\build-data\detect_version.cpp']: [WinError 193] %1 is not an application of Win32
WARNING: Tried to get clang version, but output '0.0' does not match expected version format
WARNING: Could not execute ['D:\Android\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64\bin\armv7a-linux-androideabi28-clang++', '-E', '-fstack-protector', '-pthread', 'src\build-data\detect_arch.cpp']: [WinError 193] %1 is not an application of Win32
WARNING: Unable to detect target architecture via compiler macro checks
INFO: Target is clang:0.0-android-arm32
INFO: Assuming target arm32 is little endian
INFO: Skipping (dependency failure): asio certstor_sqlite3 rdrand sessions_sqlite3
INFO: Skipping (incompatible CPU): aes_armv8 aes_ni aes_power8 chacha_avx2 clmul_cpu clmul_ssse3 idea_sse2 p9_darn rdrand_rng rdseed serpent_avx2 sha1_armv8 sha1_sse2 sha1_x86 sha2_32_armv8 sha2_32_bmi2 sha2_32_x86 sha2_64_bmi2 sha3_bmi2 shacal2_avx2 shacal2_x86 simd_avx2 sm4_armv8 threefish_512_avx2
INFO: Skipping (incompatible OS): certstor_system_macos certstor_system_windows commoncrypto getentropy proc_walk win32_stats
INFO: Skipping (no enabled compression schemes): compression
INFO: Skipping (requires external dependency): boost bzip2 lzma openssl sqlite3 tpm zlib
INFO: Loading modules: adler32 aead aes aes_vperm aont argon2 aria asn1 auto_rng base base32 base58 base64 bcrypt bcrypt_pbkdf bigint blake2 block blowfish camellia cascade cast128 cast256 cbc cbc_mac ccm cecpq1 certstor_flatfile certstor_sql certstor_system cfb chacha chacha20poly1305 chacha_rng chacha_simd32 checksum cmac comb4p cpuid crc24 crc32 cryptobox ctr curve25519 des dev_random dh dl_algo dl_group dlies dsa dyn_load eax ec_group ecc_key ecdh ecdsa ecgdsa ecies eckcdsa ed25519 elgamal eme_oaep eme_pkcs1 eme_raw emsa1 emsa_pkcs1 emsa_pssr emsa_raw emsa_x931 entropy fd_unix ffi filters fpe_fe1 gcm gmac gost_28147 gost_3410 gost_3411 hash hash_id hex hkdf hmac hmac_drbg hotp http_util idea iso9796 kasumi kdf kdf1 kdf1_iso18033 kdf2 keccak keypair lion locking_allocator mac mce mceies md4 md5 mdx_hash mem_pool mgf1 misty1 mode_pad modes mp newhope nist_keywrap noekeon noekeon_simd numbertheory ocb ofb par_hash passhash9 pbes2 pbkdf pbkdf1 pbkdf2 pem pgp_s2k pk_pad pkcs11 poly1305 poly_dbl prf_tls prf_x942 psk_db pubkey rc4 rfc3394 rfc6979 rmd160 rng roughtime rsa salsa20 scrypt seed serpent serpent_simd sessions_sql sha1 sha2_32 sha2_64 sha3 shacal2 shacal2_simd shake shake_cipher simd siphash siv skein sm2 sm3 sm4 socket sodium sp800_108 sp800_56a sp800_56c srp6 stateful_rng stream streebog system_rng thread_utils threefish_512 tiger tls tls_10 tls_cbc tss twofish utils uuid whirlpool x509 x919_mac xmss xtea xts
INFO: Using hardlink to link files into build dir (use --link-method to change)
INFO: Botan 2.14.0 (revision unknown) (unreleased undated) build setup is complete
Now i'm currently using VisualStudio 2017 native tool command prompt, or calling vcvarsall.bat, to set up the environment.
It seems Botan support for building Android binaries on Windows hosts is limited. You will have to use dark magic to make this work.
The build process consists of two phases, the configuration phase and the make phase.
The Android-specific instructions in the documentation you linked do not cover the whole build process, only the configuration phase. For the make phase, you then have to follow the Windows-specific instructions (link).
Configuration phase:
You will need the following binaries, adjust the paths to your machine:
clang++ (note the .cmd at the end): C:\Development\android-ndk-r19c-windows-x86_64\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64\bin\armv7a-linux-androideabi28-clang++.cmd
ar: C:\Development\android-ndk-r19c-windows-x86_64\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ar.exe
In the Botan folder, run the configure command:
python.exe .\configure.py --cc-bin=C:\Development\android-ndk-r19c-windows-x86_64\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64\bin\armv7a-linux-androideabi28-clang++.cmd --ar-command=C:\Development\android-ndk-r19c-windows-x86_64\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ar.exe --os=android --cpu=armv7 --verbose
Make phase
The configuration phase generates a Makefile in the Botan folder. You will have to make some adjustments to this file:
In the line all: libs cli tests docs remove docs
Reason: Additional tools are needed for building the documentation files. If you really need the documentation, you could also try to install these tools, but I have not tested this.
Replace the occurrences of ln -fs with copy.
Reason: On Linux ln -fs would create a symbolic link from the second file in the parameter list to the first. This command is not available, so changing it to copying the first file to the second seems like a pragmatic work-around to me. You could also change it to the appropriate command for creating a link on Windows, but then you might have to adjust it again when deploying to your Android target.
In the lines starting with LIBOBJS =, CLIOBJS = and TESTOBJS =, replace all occurrences of \ with /. In the whole file, replace occurrences of .\ with ./. Reason: Using the Windows-style path separator \ seems to cause problems in some places.
Find the block with # Executable targets and # Library targets. Insert #<< ... << around the parameter lists (known as the nmake inline file feature, based on this answer), to make it look like this:
# Executable targets
$(CLI): $(LIBRARIES) $(CLIOBJS)
$(EXE_LINK_CMD) #<<
$(ABI_FLAGS) $(CLIOBJS) $(EXE_LINKS_TO) $(LDFLAGS) -o $#
<<
$(TEST): $(LIBRARIES) $(TESTOBJS)
$(EXE_LINK_CMD) #<<
$(ABI_FLAGS) $(TESTOBJS) $(EXE_LINKS_TO) $(LDFLAGS) -o $#
<<
# Library targets
./libbotan-2.a: $(LIBOBJS)
$(AR) #<<
$(AR_OPTIONS) $# $(LIBOBJS)
<<
./libbotan-2.so.13: $(LIBOBJS)
$(CXX) #<<
-shared -fPIC -Wl,-soname,libbotan-2.so.13 $(ABI_FLAGS) $(LDFLAGS) $(LIBOBJS) $(LIB_LINKS_TO) -o $#
<<
Reason: Without this change, I got an error about the parameter list being too long.
You will need nmake (part of Visual Studio). On my machine it is installed in C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\Hostx64\x64\nmake.exe
In the Botan folder, run nmake.exe. Afterwards, your Botan folder should contain the binaries botan, botan-test and libraries libbotan-2....

Android source code compile error: "Try increasing heap size with java option '-Xmx<size>'"

Error happens when I try to compile Android source code(Sourcecode-version: 6.0.1; RAM: 6G; host system: ubuntu 14.04),log is below:
including ./system/netd/Android.mk ...
including ./system/security/keystore-engine/Android.mk ...
including ./system/security/keystore/Android.mk ...
including ./system/security/softkeymaster/Android.mk ...
including ./system/tools/aidl/Android.mk ...
including ./system/update_engine/Android.mk ...
including ./system/vold/Android.mk ...
including ./system/weaved/Android.mk ...
including ./system/webservd/Android.mk ...
including ./tools/external/fat32lib/Android.mk ...
Starting build with ninja
ninja: Entering directory `.'
[ 0% 1/21275] Ensure Jack server is installed and started
Jack server already installed in "/home/eddy/.jack-server"
Launching Jack server java -Djava.io.tmpdir=/tmp -Dfile.encoding=UTF-8 -XX:+TieredCompilation -cp /home/eddy/.jack-server/launcher.jar com.android.jack.launcher.ServerLauncher
[ 0% 17/21275] host Java: conscrypt-host (out/host/common/obj/JAVA_LIBRARIES/conscrypt-host_intermediates/classes)
warning: [options] bootstrap class path not set in conjunction with -source 1.7
external/conscrypt/src/openjdk/java/org/conscrypt/Platform.java:39: warning: AlgorithmId is internal proprietary API and may be removed in a future release
import sun.security.x509.AlgorithmId;
^
external/conscrypt/src/openjdk/java/org/conscrypt/Platform.java:243: warning: AlgorithmId is internal proprietary API and may be removed in a future release
return AlgorithmId.get(oid).getName();
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 warnings
[ 0% 18/21275] host Java: signapk (out/host/common/obj/JAVA_LIBRARIES/signapk_intermediates/classes)
warning: [options] bootstrap class path not set in conjunction with -source 1.7
1 warning
[ 0% 73/21275] Building with Jack: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex
FAILED: /bin/bash out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex.rsp
GC overhead limit exceeded
Try increasing heap size with java option '-Xmx<size>'
Warning: This may have produced partial or corrupted output.
ninja: build stopped: subcommand failed.
make: *** [ninja_wrapper] Error 1
#### make failed to build some targets (14:09 (mm:ss)) ####
eddy#eddy-OptiPlex-390:~/WORKING_DIRECTORY$
Anyone can tell me why the compiling failed?
I had the same problem. So I've tried to set JACK_SERVER_VM_ARGUMENTS to include -Xmx=4g, but when building again the log output showed that this was not included in the startup. I don't know why, it seems like the env vars do not get passed to the build script correctly.
Solution
Before starting a clean android build set the JACK_SERVER_VM_ARGUMENTS to include -Xmx=4g, then stop and start the jack server manually. Given you're in the main source tree of AOSP run the following:
export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g"
./prebuilts/sdk/tools/jack-admin kill-server
./prebuilts/sdk/tools/jack-admin start-server
for cm you can use
export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g"
jack-admin kill-server && jack-admin start-server
This resolved the issue for me.
The current way to set Xmx for jack is:
export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4096m"
out/host/linux-x86/bin/jack-admin kill-server
out/host/linux-x86/bin/jack-admin start-server
I also had this problem after updating to 6.0 My computer is an i7 laptop with 8GB of ram. It worked fine with v5.x and below.
The reason is not enough memory as the error message states. In the v6.x build, more Jack is used. In my case, reducing the number of Jacks to 1 resolved the issue.
I can now continue compiling with 8GB of ram.
$HOME/.jack-server/config.properties
jack.server.max-service=1
[100% 19740/19740]
#### make completed successfully (11:55:27 (hh:mm:ss)) ####
Android build (tested with 7.1.2) uses its own, private version of Jack (there could be a Jack toolchain installed elsewhere on the system), so you have to use Android-specific variables.
From https://android.googlesource.com/platform/prebuilts/sdk/+/master/tools/README-jack-server.md:
(search for "If you experience Jack compilations failing on Out of memory error.:")
To summarize:
$ # Stop the Jack server
$ jack-admin stop-server
$ # apply the new setting
$ export ANDROID_JACK_VM_ARGS="-Xmx2g -Dfile.encoding=UTF-8 -XX:+TieredCompilation"
$ Finally, restart the build (do not manually start the Jack server!)
$ m # or any other build command
The build system should pick up the change and output the line:
Environment variable ANDROID_JACK_VM_ARGS was set, regenerating...
or (after a subsequent change):
Environment variable ANDROID_JACK_VM_ARGS was modified (-Xmx2g -Dfile.encoding=UTF-8 -XX:+TieredCompilation => -Xmx4g -Dfile.encoding=UTF-8 -XX:+TieredCompilation), regenerating...
I found this article:
Building AOSP 7.x Nougat with only 8 GiB RAM
on an 8 GiB machine, Max Heap size is less than 2 GiB:
$ java -XshowSettings 2>&1 | grep Heap
Max. Heap Size (Estimated): 1.71G
The solution
Once I understood the problem, it was just a question of changing the default heap size when jack-server is launched. To fix it, you need to edit
~/.jack-settings, and add this line
JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4096m"
Then, restart jack-server – otherwise if it is running in the background it will continue to use the old Xmx value:
$ prebuilts/sdk/tools/jack-admin kill-server
$ prebuilts/sdk/tools/jack-admin start-server
Launching Jack server java -XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=/tmp -Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4096m
-cp /home/chris/.jack-server/launcher.jar com.android.jack.launcher.ServerLauncher
This was also my problem: the java default Xmx setting was already close to 4GB (precisely: 4011MB) so the issue was rather the number of concurrent jack servers running. My machine had 8 CPUs but only 16GB of RAM, but would have required 32GB (8*4=32).
My (slightly more dynamic) solution:
MAX=$(($(free -g | awk '/^Mem:/{print $NF}') / 4))
if [ $MAX -le 0 ]; then
MAX=1
fi
echo "SERVER_NB_COMPILE=$MAX" >> ~/.jack
mkdir -p ~/.jack-server
echo "jack.server.max-service=$MAX" >> ~/.jack-server/config.properties
It adds the MAX number of jack server to both the old-location and new-location based on the android official doc:
Jack Troubleshooting: If your computer becomes unresponsive during compilation or if you experience Jack compilations failing on “Out of memory error”, you can improve the situation by reducing the number of Jack simultaneous compilations by editing your $HOME/.jack and changing SERVER_NB_COMPILE to a lower value. https://source.android.com/source/jack.html

Custom Android kernel - unable to load kernel modules

I'm having issues loading kernel modules on Android, the kernel has been crosscompiled from a 64bit linux box. Kernel boots fine, it just wont load any modules (even bcm4329.ko for wifi)
The kernel and modules are flashed onto the device (HTC Desire) using CWM "install from zip" feature in recovery.
root#android:/data # uname -a
Linux localhost 2.6.38.8-dtbaker2-ics+ #3 PREEMPT Sun May 5 18:50:10 EST 2013 armv7l GNU/Linux
trying to load module manually:
root#android:/system/lib/modules/dtbaker2-ics # ls -l
-rw-rw-rw- root root 287308 2013-05-05 08:50 bcm4329.ko
root#android:/system/lib/modules/dtbaker2-ics # depmod -a
root#android:/system/lib/modules/dtbaker2-ics # modprobe bcm4329
modprobe: 'dtbaker2-ics/bcm4329.ko': unknown symbol in module or invalid parameter
root#android:/system/lib/modules/dtbaker2-ics # insmod bcm4329.ko
insmod: init_module 'bcm4329.ko' failed (No such file or directory)
root#android:/system/lib/modules/dtbaker2-ics # modinfo bcm4329.ko
filename: bcm4329.ko
license: GPL v2
alias: sdio:c*v02D0d4319*
alias: sdio:c*v02D0d4329*
alias: sdio:c*v02D0d0493*
alias: sdio:c*v02D0d0492*
alias: sdio:c*v02D0d0000*
depends:
vermagic: 2.6.38.8-dtbaker2-ics+ preempt mod_unload ARMv7
parm: dhd_oob_gpio_num:DHD oob gpio number
parm: clockoverride:SDIO card clock override
dmesg output after modprobe or insmod:
[ 1525.047424] bcm4329: Unknown symbol _GLOBAL_OFFSET_TABLE_ (err 0)
The /proc/config.gz output from my custom built kernel is identical to the output from a fresh install of this ICS ROM (bar the date).
A couple of forum posts mentioned SLAB/SLUB and module loading issues, so I even tried to rebuild the initial SLAB kernel (dtbaker-ics) with the SLUB option (dtbaker2-ics) and the identical problem exists.
Could this be a 64bit cross compilation issue? Is it weird that the kernel works fine but modules are not loaded?
Ah! "Unknown symbol _GLOBAL_OFFSET_TABLE_" error: https://groups.google.com/forum/?fromgroups=#!topic/android-kernel/dzEIOVuxtEo
I remembered early on I swapped to using prebuilt toolchain arm-linux-androideabi-4.4.3 instead of arm-eabi-4.4.0 because arm-eabi-4.4.0 did not work for me on 64bit ubuntu ( shrug )
As per the above google groups post, modified my kernel Makefile from this:
MODFLAGS        = -DMODULE -march=armv7-a -mfpu=vfpv3 -ftree-vectorize
to this:
MODFLAGS        = -DMODULE -march=armv7-a -mfpu=vfpv3 -ftree-vectorize -fno-pic
Then re-built the kernel modules:
make clean
make modules
and copied my new module back over to android, away she goes!

android NDK: gdb crashes when connecting

As a followup to this (I got gdbserver starting properly): Android NDK debugging: armeabi-v7a not working
NDK 8c, Eclipse & Cygwin, NativeActivity.
I set a breakpoint in the while loop here:
void android_main( android_app* state )
{
int stop = 0;
int x = 5;
while( stop == 0 )
{
x++;
}
... but gdb crashes when connecting! It does "stuff" for about 10 seconds, then crashes. There is some output.
Here's the gdbserver output:
Android NDK installation path: /cygdrive/e/uppercut/sdks/android-ndk
Using default adb command: /cygdrive/e/uppercut/sdks/android-sdk/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.31
Using ADB flags:
Using auto-detected project path: .
Found package name: com.example.radgame
ABIs targetted by application: armeabi-v7a
Device API Level: 15
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi-v7a
Using gdb setup init: ./libs/armeabi-v7a/gdb.setup
Using toolchain prefix: /cygdrive/e/uppercut/sdks/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-
Using app out directory: ./obj/local/armeabi-v7a
Found debuggable flag: true
Found device gdbserver: /data/data/com.example.radgame/lib/gdbserver
Found data directory: '/data/data/com.example.radgame'
Found running PID: 3218
Launched gdbserver succesfully.
Setup network redirection
## COMMAND: adb_cmd shell run-as com.example.radgame lib/gdbserver +debug-socket --attach 3218
## COMMAND: adb_cmd forward tcp:5039 localfilesystem:/data/data/com.example.radgame/debug-socket
Attached; pid = 3218
Listening on Unix socket debug-socket
## COMMAND: adb_cmd pull /system/bin/app_process obj/local/armeabi-v7a/app_process
3204 KB/s (9848 bytes in 0.003s)
Pulled app_process from device/emulator.
## COMMAND: adb_cmd pull /system/bin/linker obj/local/armeabi-v7a/linker
7732 KB/s (39592 bytes in 0.005s)
Pulled linker from device/emulator.
## COMMAND: adb_cmd pull /system/lib/libc.so obj/local/armeabi-v7a/libc.so
6994 KB/s (286536 bytes in 0.040s)
Pulled libc.so from device/emulator.
<waits while gdb connects...>
Remote debugging from host 0.0.0.0
libthread_db:td_ta_new: Probing system for platform bug.
<lots of repetitive lines...>
libthread_db:td_ta_new: Victory: We can debug theads!
readchar: Got EOF
Remote side has terminated connection. GDBserver will reopen the connection.
Listening on Unix socket debug-socket
The last several lines are its response to gdb connecting and crashing.
Here's the gdb output:
Reading symbols from E:\uppercut\prototype\build\code\androidp4\radgame\obj\local\armeabi-v7a\app_process...done.
WARNING: no debugging symbols found in E:\uppercut\prototype\build\code\androidp4\radgame\obj\local\armeabi-v7a\app_process.
Either the binary was compiled without debugging information
or the debugging information was removed (e.g., with strip or strip -g).
Debugger capabilities will be very limited.
For further information: http://wiki/Main/GdbFaq#No_debugging_symbols_found
89-gdb-set confirm off
(gdb)
89^done
(gdb)
90-gdb-set width 0
90^done
(gdb)
91-gdb-set height 0
91^done
(gdb)
92-interpreter-exec console echo
92^done
(gdb)
93-gdb-show prompt
93^done,value="(gdb) "
(gdb)
94-gdb-set target-async 0
94^done
(gdb)
95-gdb-set auto-solib-add on
95^done
(gdb)
96-gdb-set stop-on-solib-events 0
96^done
(gdb)
97-gdb-set stop-on-solib-events 1
97^done
(gdb)
98-target-select remote localhost:5039
=thread-group-started,id="i1",pid="42000"
=thread-created,id="1",group-id="i1"
&"warning: while parsing target library list (at line 2): No segment defined for com.example.radgame\n"
warning: while parsing target library list (at line 2): No segment defined for com.example.radgame
=library-loaded,id="/system/bin/linker",target-name="/system/bin/linker",host-name="E:\\uppercut\\prototype\\build\\code\\androidp4\\radgame/./obj/local/armeabi-v7a/linker",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libc.so",target-name="libc.so",host-name="E:\\uppercut\\prototype\\build\\code\\androidp4\\radgame/./obj/local/armeabi-v7a/libc.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libstdc++.so",target-name="libstdc++.so",host-name="libstdc++.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libm.so",target-name="libm.so",host-name="libm.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="liblog.so",target-name="liblog.so",host-name="liblog.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libcutils.so",target-name="libcutils.so",host-name="libcutils.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libz.so",target-name="libz.so",host-name="libz.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libtime_genoff.so",target-name="libtime_genoff.so",host-name="libtime_genoff.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libutils.so",target-name="libutils.so",host-name="libutils.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libbinder.so",target-name="libbinder.so",host-name="libbinder.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libexpat.so",target-name="libexpat.so",host-name="libexpat.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libcrypto.so",target-name="libcrypto.so",host-name="libcrypto.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libgabi++.so",target-name="libgabi++.so",host-name="libgabi++.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libicuuc.so",target-name="libicuuc.so",host-name="libicuuc.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libicui18n.so",target-name="libicui18n.so",host-name="libicui18n.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libssl.so",target-name="libssl.so",host-name="libssl.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libstlport.so",target-name="libstlport.so",host-name="libstlport.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libnativehelper.so",target-name="libnativehelper.so",host-name="libnativehelper.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libnetutils.so",target-name="libnetutils.so",host-name="libnetutils.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libGLESv2_dbg.so",target-name="libGLESv2_dbg.so",host-name="libGLESv2_dbg.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libEGL.so",target-name="libEGL.so",host-name="libEGL.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libwpa_client.so",target-name="libwpa_client.so",host-name="libwpa_client.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libhardware_legacy.so",target-name="libhardware_legacy.so",host-name="libhardware_legacy.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libpixelflinger.so",target-name="libpixelflinger.so",host-name="libpixelflinger.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libhardware.so",target-name="libhardware.so",host-name="libhardware.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libemoji.so",target-name="libemoji.so",host-name="libemoji.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libjpeg.so",target-name="libjpeg.so",host-name="libjpeg.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libsecnativefeature.so",target-name="libsecnativefeature.so",host-name="libsecnativefeature.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libharfbuzz.so",target-name="libharfbuzz.so",host-name="libharfbuzz.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libquramimagecodec.so",target-name="libquramimagecodec.so",host-name="libquramimagecodec.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libskia.so",target-name="libskia.so",host-name="libskia.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libui.so",target-name="libui.so",host-name="libui.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libGLESv2.so",target-name="libGLESv2.so",host-name="libGLESv2.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libmemalloc.so",target-name="libmemalloc.so",host-name="libmemalloc.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libQcomUI.so",target-name="libQcomUI.so",host-name="libQcomUI.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libremotedesktop_client.so",target-name="libremotedesktop_client.so",host-name="libremotedesktop_client.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libgui.so",target-name="libgui.so",host-name="libgui.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libcamera_client.so",target-name="libcamera_client.so",host-name="libcamera_client.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libsqlite.so",target-name="libsqlite.so",host-name="libsqlite.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libqc-opt.so",target-name="libqc-opt.so",host-name="libqc-opt.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libdvm.so",target-name="libdvm.so",host-name="libdvm.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libGLESv1_CM.so",target-name="libGLESv1_CM.so",host-name="libGLESv1_CM.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libETC1.so",target-name="libETC1.so",host-name="libETC1.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libsisodrm.so",target-name="libsisodrm.so",host-name="libsisodrm.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libsonivox.so",target-name="libsonivox.so",host-name="libsonivox.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libstagefright_foundation.so",target-name="libstagefright_foundation.so",host-name="libstagefright_foundation.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libmedia.so",target-name="libmedia.so",host-name="libmedia.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libQmageDecoder.so",target-name="libQmageDecoder.so",host-name="libQmageDecoder.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libnfc_ndef.so",target-name="libnfc_ndef.so",host-name="libnfc_ndef.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libusbhost.so",target-name="libusbhost.so",host-name="libusbhost.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libhwui.so",target-name="libhwui.so",host-name="libhwui.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libtilerenderer.so",target-name="libtilerenderer.so",host-name="libtilerenderer.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libbluedroid.so",target-name="libbluedroid.so",host-name="libbluedroid.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libdbus.so",target-name="libdbus.so",host-name="libdbus.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libandroid_runtime.so",target-name="libandroid_runtime.so",host-name="libandroid_runtime.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libvorbisidec.so",target-name="libvorbisidec.so",host-name="libvorbisidec.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libstagefright_yuv.so",target-name="libstagefright_yuv.so",host-name="libstagefright_yuv.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libdrmframework.so",target-name="libdrmframework.so",host-name="libdrmframework.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libpowermanager.so",target-name="libpowermanager.so",host-name="libpowermanager.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libdiag.so",target-name="libdiag.so",host-name="libdiag.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libaudcal.so",target-name="libaudcal.so",host-name="libaudcal.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libacdbloader.so",target-name="libacdbloader.so",host-name="libacdbloader.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libalsa-intf.so",target-name="libalsa-intf.so",host-name="libalsa-intf.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libchromium_net.so",target-name="libchromium_net.so",host-name="libchromium_net.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libstagefright_amrnb_common.so",target-name="libstagefright_amrnb_common.so",host-name="libstagefright_amrnb_common.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libstagefright_enc_common.so",target-name="libstagefright_enc_common.so",host-name="libstagefright_enc_common.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libstagefright_avc_common.so",target-name="libstagefright_avc_common.so",host-name="libstagefright_avc_common.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libsavscmn.so",target-name="libsavscmn.so",host-name="libsavscmn.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libsavsff.so",target-name="libsavsff.so",host-name="libsavsff.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libsurfaceflinger_client.so",target-name="libsurfaceflinger_client.so",host-name="libsurfaceflinger_client.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libtvoutinterface.so",target-name="libtvoutinterface.so",host-name="libtvoutinterface.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libtvoutservice.so",target-name="libtvoutservice.so",host-name="libtvoutservice.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libmm-abl-oem.so",target-name="libmm-abl-oem.so",host-name="libmm-abl-oem.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libmm-abl.so",target-name="libmm-abl.so",host-name="libmm-abl.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libstagefright.so",target-name="libstagefright.so",host-name="libstagefright.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libmtp.so",target-name="libmtp.so",host-name="libmtp.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libexif.so",target-name="libexif.so",host-name="libexif.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libmedia_jni.so",target-name="libmedia_jni.so",host-name="libmedia_jni.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libbcc.so",target-name="libbcc.so",host-name="libbcc.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libbcinfo.so",target-name="libbcinfo.so",host-name="libbcinfo.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libRS.so",target-name="libRS.so",host-name="libRS.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="librs_jni.so",target-name="librs_jni.so",host-name="librs_jni.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libandroid.so",target-name="libandroid.so",host-name="libandroid.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libv8.so",target-name="libv8.so",host-name="libv8.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libwebcore.so",target-name="libwebcore.so",host-name="libwebcore.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libradgame.so",target-name="libradgame.so",host-name="E:\\uppercut\\prototype\\build\\code\\androidp4\\radgame/./obj/local/armeabi-v7a/libradgame.so",symbols-loaded="0",thread-group="i1"
&"warning: Could not load shared library symbols for 83 libraries, e.g. libstdc++.so.\nUse the \"info sharedlibrary\" command to see the complete listing.\nDo you need \"set solib-search-path\" or \"set sysroot\"?"
&"\n"
warning: Could not load shared library symbols for 83 libraries, e.g. libstdc++.so.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
&"warning: Breakpoint address adjusted from 0xb00056f5 to 0xb00056f4.\n"
warning: Breakpoint address adjusted from 0xb00056f5 to 0xb00056f4.
*stopped,frame={addr="0x4004d738",func="__futex_syscall3",args=[],from="E:\\uppercut\\prototype\\build\\code\\androidp4\\radgame/./obj/local/armeabi-v7a/libc.so"},thread-id="1",stopped-threads="all",core="0"
98^connected
(gdb)
99 info proc
&"info proc\n"
&"Undefined info command: \"proc\". Try \"help info\".\n"
99^error,msg="Undefined info command: \"proc\". Try \"help info\"."
(gdb)
100-environment-cd E:\\uppercut\\prototype\\build\\code\\androidp4\\radgame
100^done
(gdb)
101 info program
&"info program\n"
~"Debugging a target over a serial line.\n"
~"Program stopped at 0x4004d738.\n"
~"It stopped with signal SIGTRAP, Trace/breakpoint trap.\n"
~"Type \"info stack\" or \"info registers\" for more information.\n"
101^done
(gdb)
102 info threads
&"info threads\n"
=thread-created,id="2",group-id="i1"
~"[New Thread 3219]\n"
=thread-created,id="3",group-id="i1"
~"[New Thread 3223]\n"
=thread-created,id="4",group-id="i1"
~"[New Thread 3224]\n"
=thread-created,id="5",group-id="i1"
~"[New Thread 3225]\n"
=thread-created,id="6",group-id="i1"
~"[New Thread 3226]\n"
=thread-created,id="7",group-id="i1"
~"[New Thread 3229]\n"
=thread-created,id="8",group-id="i1"
~"[New Thread 3230]\n"
=thread-created,id="9",group-id="i1"
~"[New Thread 3231]\n"
=thread-created,id="10",group-id="i1"
~"[New Thread 3233]\n"
=thread-created,id="11",group-id="i1"
~"[New Thread 3317]\n"
=thread-created,id="12",group-id="i1"
~"[New Thread 3320]\n"
~" Id Target Id Frame \n"
~" 12 Thread 3320 0x4004c7fc in __ioctl () from E:\\uppercut\\prototype\\build\\code\\androidp4\\radgame/./obj/local/armeabi-v7a/libc.so\n"
I have had debugging working before with gdb, with a Java entry point and 'armeabi'. After switching to C++ entry point (android_main) and 'armeabi-v7a', gdb crashes. I don't know if either is related...
For what it's worth, gdb also crashes any other time I connect (I remove the infinite while loop on startup). For example I'm having thread issues, so my app hangs for no apparent reason. If I connect when it's hung, then gdb crashes in the same way.
This was due to one or both of these GCC compiler flags, which I had added while switching to armeabi-v7a, and then forgot about.
-gstabs+ -g
The version of gdb that comes with the NDK must not like those flags.

Not able to hit the break point in ndk-gdb in Android

Development Environment:
NDK: r7
SDK & Tools: r15
AVD: GB2.3.3, API Level 10
I wrote a test application in which thread will be launched in the native. I Kept a break point in the thread. (Intially when i tried on Galaxy S2 i was getting an error, "Thread debugging not supported in this Platform". So i created an AVD 2.3.3 Level 10).
After this i was getting an error like this
#0 0xafd0c51c in epoll_wait () from /Volumes/SecureCode/webos/rta/android/obj/local/armeabi/libc.so
#1 0xa81216a6 in ?? ()
I googled and found this Solution (Link Here).
I followed the guide lines there
$ adb pull /system/lib lib
$ ndk-gdb
...
(gdb) set solib-search-path lib
But after this also I am not able to hit the break point. I am still getting stuck at this poll_wait() and not moving forward.
D:\EclipseTestWorkspace\CallbackJava>sh
sh-4.1$ ndk-gdb --force --start --verbose
Android NDK installation path: /cygdrive/c/Android/android-ndk
Using default adb command: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.29
Using final ADB command: '/cygdrive/c/Android/android-sdk-windows/platform-tools/adb'
Using auto-detected project path: .
Found package name: com.callback
ABIs targetted by application: armeabi
Device API Level: 10
Device CPU ABI: armeabi
Compatible device ABI: armeabi
Found debuggable flag: true
Found device gdbserver: /data/data/com.callback/lib/gdbserver
Using gdb setup init: ./libs/armeabi/gdb.setup
Using toolchain prefix: /cygdrive/c/Android/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-
Using app out directory: ./obj/local/armeabi
Found data directory: '/data/data/com.callback'
Found first launchable activity: .CallbackJavaActivity
Launching activity: com.callback/.CallbackJavaActivity
## COMMAND: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb shell am start -n com.callback/.CallbackJavaActivity
Starting: Intent { cmp=com.callback/.CallbackJavaActivity }
## COMMAND: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb shell sleep 2
Found running PID: 352
Launched gdbserver succesfully.
## COMMAND: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb shell run-as com.callback lib/gdbserver +debug-socket --attach 352
Setup network redirection
## COMMAND: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb forward tcp:5039 localfilesystem:/data/data/com.callback/debug-socket
## COMMAND: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb pull /system/bin/app_process obj/local/armeabi/app_process
Attached; pid = 352
Listening on sockaddr socket debug-socket
19 KB/s (5660 bytes in 0.281s)
Pulled app_process from device/emulator.
## COMMAND: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb pull /system/lib/libc.so obj/local/armeabi/libc.so
80 KB/s (273868 bytes in 3.325s)
Pulled libc.so from device/emulator.
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i586-mingw32msvc --target=arm-elf-linux".
(no debugging symbols found)
Error while mapping shared library sections:
/system/bin/linker: No such file or directory.
----- So many similar errors -----
Error while mapping shared library sections:
gralloc.default.so: No such file or directory.
(no debugging symbols found)
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
warning: shared library handler failed to enable breakpoint
0xafd0c51c in epoll_wait () from D:/EclipseTestWorkspace/CallbackJava/obj/local/armeabi/libc.so
(gdb) set solib-search-path lib
Error while mapping shared library sections:
/system/bin/linker: No such file or directory.
Error while mapping shared library sections:
gralloc.default.so: No such file or directory.
Symbol file not found for /system/bin/linker
Reading symbols from D:\EclipseTestWorkspace\CallbackJava/lib/libc.so...(no debugging symbols found)...done.
Loaded symbols for D:\EclipseTestWorkspace\CallbackJava/lib/libc.so
----- So many similar errors -----
Loaded symbols for D:\EclipseTestWorkspace\CallbackJava/lib/libwebcore.so
Symbol file not found for gralloc.default.so
(gdb) file ./libs/armeabi/libcallbacks.so
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from D:\EclipseTestWorkspace\CallbackJava/./libs/armeabi/libcallbacks.so...(no debugging symbols found)...done.
(gdb) file ./obj/local/armeabi/libcallbacks.so
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from D:\EclipseTestWorkspace\CallbackJava/./obj/local/armeabi/libcallbacks.so...done.
(gdb) break callbacks_java.cpp:appcallback_register
Breakpoint 1 at 0x1a64: file D:/EclipseTestWorkspace/CallbackJava/jni/callbacks_java.cpp, line 419.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x00001a64 in appcallback_register at D:/EclipseTestWorkspace/CallbackJava/jni/callbacks_java.cpp:419
(gdb) where
#0 0xafd0c51c in epoll_wait () from D:\EclipseTestWorkspace\CallbackJava/lib/libc.so
#1 0xa81211b4 in android::Looper::pollInner () from D:\EclipseTestWorkspace\CallbackJava/lib/libutils.so
#2 0x00000000 in ?? ()
(gdb) where
#0 0xafd0c51c in epoll_wait () from D:\EclipseTestWorkspace\CallbackJava/lib/libc.so
#1 0xa81211b4 in android::Looper::pollInner () from D:\EclipseTestWorkspace\CallbackJava/lib/libutils.so
#2 0x00000000 in ?? ()
(gdb) c
Continuing.
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0x1a64: Input/output error.
(gdb)
Which i would like to concentrate on main part as
(gdb) file ./libs/armeabi/libcallbacks.so
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from D:\EclipseTestWorkspace\CallbackJava/./libs/armeabi/libcallbacks.so...(no debugging symbols found)...done.
(gdb) file ./obj/local/armeabi/libcallbacks.so
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from D:\EclipseTestWorkspace\CallbackJava/./obj/local/armeabi/libcallbacks.so...done.
(gdb) break callbacks_java.cpp:appcallback_register
Breakpoint 1 at 0x1a64: file D:/EclipseTestWorkspace/CallbackJava/jni/callbacks_java.cpp, line 419.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x00001a64 in appcallback_register at D:/EclipseTestWorkspace/CallbackJava/jni/callbacks_java.cpp:419
(gdb) where
#0 0xafd0c51c in epoll_wait () from D:\EclipseTestWorkspace\CallbackJava/lib/libc.so
#1 0xa81211b4 in android::Looper::pollInner () from D:\EclipseTestWorkspace\CallbackJava/lib/libutils.so
#2 0x00000000 in ?? ()
(gdb) where
#0 0xafd0c51c in epoll_wait () from D:\EclipseTestWorkspace\CallbackJava/lib/libc.so
#1 0xa81211b4 in android::Looper::pollInner () from D:\EclipseTestWorkspace\CallbackJava/lib/libutils.so
#2 0x00000000 in ?? ()
(gdb) c
Continuing.
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0x1a64: Input/output error.
(gdb)
So from the last error what i understand is its considering the absolute address 0x1a64. Its not considering the relative address (runtime address), so not able to hit the break point. and also its getting stuck at the epoll_wait () , not moving further.
Will any one please help me how can I proceed further?
Thanks & Regards,
SSuman185
You could try debugging in Eclipse with DS-5 CE plugin. Tutorial how to install and setup it you can find here http://forums.arm.com/index.php?/topic/15575-arm-ds-5-tutorial-for-android/ (last post is how to make it work on SGS2).
I know that is not an exact answer to your question, but if you need NDK debugging on SGS2 you might want to try it, also it's for Eclipse, not a command line gdb (but who could ever prefer command-line debugging instead of debugging in IDE??)
PS. DS-5 CE is a first NDK debugging tool that worked for me with SGS2 (it's not perfect - possibly because of bugs/limitations in SGS2 - but at least works).

Categories

Resources