Get Log for debugging in Android-summary)

Source: Internet
Author: User
Tags dmesg

Log files are classified into two types: Real-Time printing and status information.

Real-time printing mainly includes: logcat main, logcat radio, logcat events, tcpdump, and QXDM Log

The status information includes adb shell dmesg, adb shell dumpstate, adb shell dumpsys, and adb bugreport.

Real-time log:

Adb logcat-BEvents-V time: prints System Event Logs, such as touch screen events.

  TcpdumpIt is very useful. You can use this for TCP/IP protocols,

Adb shell tcpdump-s 10000-w/sdcard/capture. pcap,

For example, you can capture the UA profile during mms download, use the proxy's APN to download when the browser is surfing the internet, and streaming-related content includes UA profile.

Status log:

In fact, one is enough, that is, bugreport (command adb bugreport> bugreport. log ).

Contains dmesg, dumpstate, and dumpsys;

Dmesg(Command adb shell dmesg> ldmesg_kernel.log) is the log of the kernel. Any problems related to the kernel, such as driver (camera, Bluetooth, usb, startup, etc)

DumpstateIt is the system status information, which is comprehensive, including the current memory information, cpu information, logcat cache, and kernel cache of the mobile phone;

DumpsysThis is about the Process of all processes in the system. The adb shell dumpsys command has more detailed usage,

For example, adb shell dumpsys meminfo system is used to view the memory information of the process of system.

Dumpsys [options]

Meminfo Display memory information

CPU info displays CPU Information

Account displays accounts information

Activity displays information about all activities.

Window displays the relationship between the keyboard, window, and them.

Wifi display wifi Information

You can use adb logcat/bugreport to view system logs and system status information in real time;

How can I store logs and save the running status of the system at that time?

Some scripts or executable programs can be used to save log information for analysis;

2. capture real-time logs
Int main (int argc, char * argv []) {…… // Capture main log char path [] = "/xxx/app_main.log"; sprintf (cmd, "logcat-v time> % s", path ); fd = open (path, O_WRONLY | O_TRUNC | O_CREAT, 0777 );System(Cmd); // radio log ...... Sprintf (cmd, "logcat-B radio-v time> % s", path );System(Cmd); // kernel ...... Sprintf (cmd, "cat/proc/kmsg> % s", path );System(Cmd); // restore lth log sprintf (cmd, "hcidump-w % s", "/data/bt. log ");System(Cmd );......}

3. Capture status logs
Int main (int argc, char * argv []) {// panic log needs to judge whether/proc/apanic_console has sprintf (cmd, "cp-R % s ", from_dir, to_dir );System(Cmd); // anr log/data/anr/sprintf (cmd, "cp-R % s", from_dir, to_dir );System(Cmd); // tombstones log/data/tombstones/Modem restart and resetSprintf (cmd, "cp-R % s", from_dir, to_dir );System(Cmd); // mdm log/data/tombstones/mdm/Modem restart ResetSprintf (cmd, "cp-R % s", from_dir, to_dir );System(Cmd );......}

Panic log:

It indicates that Linux kernel has gone through a situation where it does not know how to proceed to the next step,

Http://wenku.baidu.com/view/519c8009844769eae009ed50

Tombstone log:

When the system has tombstone, the kernel first reports a serious warning signal (signal). After receiving the signal from the upper layer,

The process debugging tool saves the call stack in the process at that time, and writes the process information in case of exceptions to the data/tombstones directory created by the system,

Developers need to analyze the entire call process through the call stack to find out the problem.

Http://www.eoeandroid.com/thread-206358-1-1.html

4. Runtime executable program

Compile the program into an executable program. Of course, some control parameters are required in actual use.

How to execute these executable programs in the Code:

At the underlying layer, you can use system ();

Runtime.getruntime(cmd.exe c ();

For example:

String BIN_PATH = "/system/bin/catch_log ";

Runtime.getruntime(cmd.exe c (BIN_PATH + "-x 1 ");

Runtime.getruntime(cmd.exe c ("/system/bin/cat" + path );

Runtime.getruntime(cmd.exe c ("su-c chmod 777/data/glad.txt ");

Runtime.getruntime(cmd.exe c ("/system/bin/sh/data/test. sh ");

Android Runtime makes it possible to directly call executable programs or scripts in underlying Linux

For example, write a test tool in Linux and call it through Runtime in the apk after compilation.

Or write a script and call it directly in the apk, saving the middle layer or JNI;

Reference: http://blog.csdn.net/zmyde2010/article/details/6123987

5 diag_mdlog

This is what Qualcomm provides to capture qxdm logs.

It includes both AP and back-end, or is related to the selected port. The 80-64 AP and modem ports are independent;

Code path: \ vendor \ qcom \ proprietary \ diag \ mdlog \

Use the executable program diag_mdlog to capture logs.

You need to configure the filtering items in the Diag. cfg file and select the required Log information. A Diag. cfg file must be placed before use.

The Diag. cfg file can be generated using QXDM; The Diag. cfg file can be generated using F12, Filtered View/Config.

This program can only execute one task at a time. You can use the kill-9 PID to force it to end.

6 capture apsaradb for memory dump

Qualcomm qpst tool Memory Dump App

To be in downloader Mode

Nv items to be modified:

905 0

4399 1

Or use emmc to enter the downloader mode.

Open the Connection Phone, Get Regions, select the Regin to be saved, SaveTo select a folder, and click OK.

Note: The path must be in English and cannot contain Chinese characters.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.