I'm using Android Studio to debug a NativeActivity app written in C++
In my C++ code the first thing I do in android_main() is wait 10 seconds for the debugger to attach. In the 'Debug' window I see:
Now Launching Native Debug Session
and then after a few seconds
Debugger attached to process 28458
and then right after it attaches, the debugger is stopped with a signal:
Signal: 33 (signal SIG33)
I press 'Resume Program' and then I get the same signal again and again for 7-8 times. After that, the program continues as expected, debugger attached and I am able to stop it at breakpoints.
What's the meaning of that SIG33? how can I prevent it?
Signal 33 is used internally by bionic for the backtrace facilities.
See comment in __libc_current_sigrtmin.cpp.
// POSIX timers use __SIGRTMIN + 0.
// libbacktrace uses __SIGRTMIN + 1.
// libcore uses __SIGRTMIN + 2.
See definition of __SIGRTMIN for generic, arm, x86, and mips.
#define __SIGRTMIN 32
I think that SIG33 is caused by gdb and gdb is not correctly ignoring it.
Those can be ignored and/or silenced using below GDB command-line:
handle SIG33 nostop noprint
SIG33 is used to signal about "threading libraries" by LLDB.
Excerpt from LLDB source:
AddSignal (33, "SIG33", false, false, false, "threading library internal signal 2");
But I don't seem to understand the reason why your code is getting this. May be due to some minor dependency issues.
Related
I am building LineageOS 18.1 for tecno kd7. I have system, system_ext, product & vendor paritions. The rom port I built is having a boot loop.
Here is the last_kmsg
What is causing the boot loop?
I am suspecting these lines
[ 1.802608] (0)[354:apexd]apexd: This device does not support updatable APEX. Exiting
[ 2.352523] (0)[1:init]reboot: Restarting system with command 'boringssl-self-check-failed'
I just need direction on what I need to what is causing the phone to bootloop
I also faced the same issue. The boringssl-self-test binary is using incorrect libcrypto.so library.
You can run the boringssl-self-test with strace and check for the issue.
In file : external/boringssl/selftest/boringssl_self_test.rc
service boringssl_self_test64_vendor /system/bin/strace -tt /vendor/bin/boringssl_self_test64
setenv BORINGSSL_SELF_TEST_CREATE_FLAG true # Any nonempty value counts as true
#reboot_on_failure reboot,boringssl-self-check-failed
stdio_to_kmsg
seclabel u:r:vendor_boringssl_self_test:s0
Ok so first off,
Im brand new to android dev. This is my first attempt at any form of kernel anything. I have a limited knowledge of java and python, but no C.
I have a galaxy tab 4 sm-t330nu running 4.4.2. its running a qualcomm snapdragon 400 msm8226 cpu. im simply trying to do a test build with a vanilla kernel at this point. (also my build environment is the newest kali 1.1 and im loosely following the tutorial at https://github.com/offensive-security/kali-nethunter/wiki/Porting-Nethunter)
so i have all of the required dependencies (i hope), and ive downloaded my source from samsung opensource. unzipped and went through the available defconfigs. after finding "msm8226-sec_milletwifiue_defconfig" i decided it was the most likely candidate for my tablet. (when doing a custom recovery i remember it being "philz touch milletwifiue something)
Ive done my exports (arch= subarch= cross_compile=) and all seems well. When i run a build following exactly as the tutorial says (using the defconfig in their example as a test) i receive an error stating "must define variant_defconfig". So i instead do "make variant_defconfig=msm8974_sec_defconfig" and it builds great.
Now the issue:
When i change "msm8974_sec_defconfig" to my actual msm8226 i receive an error on every build that i cannot seem to workaround. (cut down for size)
CC arch/arm/kernel/armksyms.o
CC arch/arm/kernel/module.o
AS arch/arm/kernel/sleep.o
CC arch/arm/kernel/suspend.o
CC arch/arm/kernel/io.o
arch/arm/kernel/io.c: In function '_memcpy_fromio':
arch/arm/kernel/io.c:14:3: error: implicit declaration of function 'nop' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors
make[1]: *** [arch/arm/kernel/io.o] Error 1
make: *** [arch/arm/kernel] Error 2
My exact bash line reads
make VARIANT_DEFCONFIG=msm8226-sec_milletwifiue_defconfig
Any assistance on clearing this up would be great
edit
although im not familiar with c, it seems to me that '_memcpy_fromio' is where the error lies. and my google searches tell me that the error is that a function is used without being declared. however i dont know if memcpy is a function? or is the function within class memcpy (dont know if c has classes just closest equivalent that i know of) how do i debug this code and declare what needs to be declared (more importantly, if this is a stock kernel thats used by thousands of devices, how can it possibly have an undeclared function?
/edit
found the answer! needed
#import linux/modules.h
#import linux/kernel.h
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.
I'm porting some C++ code to Android using NDK and GCC. The code basically runs. At one point, when debugging in Eclipse, the call
Dabbler::Android::Factory* pFactory = new Dabbler::Android::Factory;
causes this error:
Thread [1] (Suspended: Signal 'SIGILL' received. Description: Illegal instruction.)
1 <symbol is not available> 0x812feb44
What does that mean? Has the compiler generated illegal code for some reason? I have a breakpoint in the constructor (which does nothing), and it's not hit. I have already done a full rebuild.
What could I be doing wrong to cause this problem?
Make sure that all functions with non-void return type have a return statement.
While some compilers automatically provide a default return value, others will send a SIGILL or SIGTRAP at runtime when trying to leave a function without a return value.
It means the CPU attempted to execute an instruction it didn't understand. This could be caused by corruption I guess, or maybe it's been compiled for the wrong architecture (in which case I would have thought the O/S would refuse to run the executable). Not entirely sure what the root issue is.
It could be some un-initialized function pointer, in particular if you have corrupted memory (then the bogus vtable of C++ bad pointers to invalid objects might give that).
BTW gdb watchpoints & tracepoints, and also valgrind might be useful (if available) to debug such issues. Or some address sanitizer.
LeetCode's online compiler and dev environment generates SIGILL errors for mistakes that do not generate the same error in my desktop IDE.
For example, array access with an out-of-bounds index:
["foo", "bar"][2]
LeetCode's compiler shows only the error:
Runtime Error
process exited with signal SIGILL
in a local Xcode playground this same code instead results in the error:
error: Execution was interrupted, reason: EXC_BREAKPOINT (code=1, subcode=0x18f2ea5d8).
The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.
Only in a full Xcode project compilation and run does it report the actual error:
Thread 1: Fatal error: Index out of range
I've setup my Eclipse to debug the Native side of my application using Eclipse & Seqoyah and added the appropriate C/C++ Application Debug Configuration.
The problem is it seems that Eclipse is trying to initiate a connection with the applications GDB server even before it launches it. I'm not to sure how to change the order in which Eclipse tries to do things with Debug Configurations. Any help would be appreciated (as always).
http://wiki.eclipse.org/Sequoyah/ndk_guide
31-gdb-set confirm off
31^done
(gdb)
32-gdb-set width 0
32^done
(gdb)
33-gdb-set height 0
33^done
(gdb)
34-interpreter-exec console echo
34^done
(gdb)
35-gdb-show prompt
35^done,value="(gdb) "
(gdb)
36-gdb-set auto-solib-add on
36^done
(gdb)
37-gdb-set stop-on-solib-events 0
37^done
(gdb)
38-gdb-set stop-on-solib-events 1
38^done
(gdb)
39-target-select remote localhost:5039
&"Remote communication error: Connection reset by peer.\n"
39^error,msg="Remote communication error: Connection reset by peer."
(gdb)
40-gdb-exit
40^exit
Remote communication error: Connection reset by peer.
I managed to solve this one.
There should be two Debug Configurations available to your Java / C++ Native project. The first is for the Java side of things and the second is for the C++ side of things.
Make sure you have setup your environment according to: http://wiki.eclipse.org/Sequoyah/ndk_guide
Set a breakpoint just after the JNI Shared library is added or in your Activities onCreate.
Debug your application using its default debug configuration.
In a shell navigate to your project directory and issue $NDK/ndk-gdb (where $NDK is the location of your Android Native Development Kit).
Debug your application using its Native debugger that you created in the Sequoyah guide.
If all goes well you should be able to step into JNI code and when your application crashes, see where in your source it crashed.
I've not yet found a way to setup through the actual source yet, if anyone does please post here.