Obtain logs through Android debugging

Source: Internet
Author: User
Tags dmesg
1 Android log

I recently encountered some Log Capture tasks, many of which were shared by online experts. I would like to sum them up:

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

 

Use ADB logcat/BugreportYou can 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?

It can be executed through some scripts orProgramTo 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 );  //  Bluetoolth 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 determine whether/proc/apanic_console exists Sprintf (CMD, "  CP-R % S % s "  , From_dir, to_dir );System(CMD );  //  ANR log/data/ANR/ Sprintf (CMD, "  CP-R % S % s  "  , From_dir, to_dir );System(CMD );  //  Tombstones log/data/tombstones/Modem restart and reset Sprintf (CMD, "  CP-R % S % s  " , From_dir, to_dir );System(CMD );  //  Mdm log/data/tombstones/MDM/Modem restart Reset Sprintf (CMD, "  CP-R % S % 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.

CodeHow to execute these executable programs:

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.