Android: How to get kernel logs after kernel panic?

给你一囗甜甜゛ 提交于 2019-11-27 17:44:42

As for me,

cat /proc/last_kmsg 

after reboot (caused by the kernel panic during insmod) does list messages relevant to the crash, like

[  424.909515] Kernel panic - not syncing: Fatal exception
[  424.909606] Backtrace: 
[  424.909790] [<c005a5ec>] (dump_backtrace+0x0/0x10c) from [<c05f38dc>] (dump_stack+0x18/0x1c)
[  424.909973]  r6:c5cccf00 r5:00000000 r4:c08505a0 r3:00000000

So you can at least try. I am working with Linux 3.0.31-g4f6d371 on Galaxy Nexus.

Weilin Luo

How about /data/dontpanic folder? After kernel panic happens, you can connect USB cable with your Android device and check the files in that folder through ADB.

I found this folder contains some apanic files after a kernel panic happens. For example, if a kernel panic just happened and you go check the folder, you might find these two files:

apanic_console

apanic_threads

You can find out in apanic_threads which thread / process is running when the kernel panic happens. In apanic_console you might find out more information such as the stack trace and values of some critical registers: PC, LR, etc.
They will help you get your debugging started.

It seems at Android-7.0 or above, the last_kmesg log is moved to: /sys/fs/pstore/console-ramoops, so try:

cat /sys/fs/pstore/console-ramoops

it works well for me on nexus-5x

Android creates a RAM console and attempts to save the last kernel message buffer for you in RAM (assuming the power doesn't go out). You can access this file through the proc interface and on my system it is world readable:

cat /proc/last_kmsg

For more information see the kernel code @ drivers/staging/android/ram_console.c

Pavan Manjunath

I faced a similar issue of collecting shutdown logs in Android. I had posted this question long back and it has 2 approaches. I use the 2nd one as the 1st one doesn't work for me. Here is the question

Where does Android store shutdown logs?

Hope this helps.

The Linux kernel log can be accessed with dmesg command. You can read about the Android Logging System here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!