stack trace of native threads

1,916 views
Skip to first unread message

Ubuntu guy

unread,
Jun 1, 2010, 4:36:09 PM6/1/10
to android-platform
Hi,

I had observed that the traces file usually has the stack traces of
only java threads and not native threads. Upon looking into the code,
it seems that the SIGNAL_QUIT is handled by the dalvik vm and it
suspends threads and logs the stack traces.

I need to have a look at the stack traces of the native threads for
an issue. Is there anyway to capture the stack traces of native
threads and native process like mediaserver?

fadden

unread,
Jun 1, 2010, 5:24:36 PM6/1/10
to android-platform
On Jun 1, 1:36 pm, Ubuntu guy <sam_...@yahoo.co.in> wrote:
>   I need to have a look at the stack traces of the native threads for
> an issue. Is there anyway to capture the stack traces of native
> threads and native process like mediaserver?

You can cause the thread to crash by hitting it twice with a fatal
signal; that'll show you a debuggerd crash dump in the log. Decoding
the dump is a separate step.

Generally your best bet is gdb/gdbserver.

http://pdk.android.com/online-pdk/guide/debugging_gdb.html

Ubuntu guy

unread,
Jun 1, 2010, 8:38:49 PM6/1/10
to android-platform
Could you let me know as to how to hit a process/thread with fatal
signal?
and by debuggerd crash dump, do you mean I/DEBUG logs of logcat?

Anthony

unread,
Jun 1, 2010, 4:45:29 PM6/1/10
to android-...@googlegroups.com
You can attach to the process with gdb and grab backtraces for all the threads.


--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.


viol...@gmail.com

unread,
Jun 2, 2010, 2:32:54 AM6/2/10
to android-platform
I want to know how to hit processes with fatal signal and trigger
debuggerd crash dump, too.
Thanks in advance.

fadden

unread,
Jun 2, 2010, 7:11:04 PM6/2/10
to android-platform
On Jun 1, 5:38 pm, Ubuntu guy <sam_...@yahoo.co.in> wrote:
> Could you let me know as to how to hit a process/thread with fatal
> signal?

% adb shell kill -6 <pid>
% adb shell kill -6 <pid>

That sends a pair of abort signals to your process of choice. "adb
shell ps -t" will show the process / thread IDs.

This assumes you can execute shell commands as root, or at least as
the same UID as the process you want to kill.

On relatively recent versions of Android, you can call
dalvik.system.VMDebug.crash():

/**
* Crashes the VM. Seriously. Dumps the interpreter stack trace
for
* the current thread and then aborts the VM so you can see the
native
* stack trace. Useful for figuring out how you got somewhere
when
* lots of native code is involved.
*
* @hide
*/
public static native void crash();

Note this isn't a public API in the SDK.

Ubuntu guy

unread,
Jun 4, 2010, 9:12:43 PM6/4/10
to android-platform
Hi,

I tried this and it does log the stack trace of the main thread of
the process.
However, i'm looking to capture the stack trace of all native threads
of all process just like how anr/traces.txt captures the trace of all
threads and all process executed by dalvik vm.
Is there any option?

Ben Cheng

unread,
Jun 6, 2010, 2:01:56 AM6/6/10
to android-...@googlegroups.com
Check out the /data/tombstones directory and look for a tombstone_xx file. The native stack traces of all the threads belonging to that pid will be logged in the tombstone file.

-Ben

Ubuntu guy

unread,
Jun 7, 2010, 12:49:32 PM6/7/10
to android-platform
Thanks Ben, that worked for me. :-)
> > android-platfo...@googlegroups.com<android-platform%2Bunsubscrib­e...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/android-platform?hl=en.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages