[Sorting] capturing and analyzing Android test log files

Source: Internet
Author: User
Tags dmesg

1. Introduction to log file categories
Real-time printing mainly involves logcat main, logcat radio, logcat events, tcpdump, and qxdm logs on the Qualcomm platform.
The status information includes ADB shell CAT/proc/kmsg, ADB shell dmesg, ADB shell dumpstate, ADB shell dumpsys, ADB bugreport, and project mode.

2. Log Capture details
(1) Real-time Printing
ADB logcat-B Main-V time> app. Log print Application Log

ADB logcat-B radio-V time> radio. Log prints rf-related logs. Sim STK will also be in it, modem-related atcommand and so on, of course, it is far from qxdm.

ADB logcat-B events-V time prints logs of system events, such as touch-screen events...

Tcpdump is very useful and can be used for TCP/IP protocols. ADB shell tcpdump-s 10000-W/sdcard/capture. pcap, such as the UA profile during MMS download, the APN download Using proxy when browser is surfing the internet, and the streaming-related content including UA profile.

The last is the qxdm of the Qualcomm platform. Whether it is Android or not, as long as the Qualcomm chip is used, it will be very familiar with it. Of course, if it is not a Qualcomm chip, you don't need to mention it. I don't want to talk about it much. It's rich in content, such as RF, telephone, and Internet access. All the solutions provided by Qualcomm can be grasped. (For the log Capturing Method of qxdm, see the basic usage instructions and functions of qpst and qxdm)

(2) status information
Bugreport (command ADB bugreport> bugreport. Log ). The bread contains dmesg, dumpstate, and dumpsys.

Dumpstate is the system status information, which is comprehensive, including the current memory information, CPU information, logcat cache, and kernel cache of the mobile phone.

The ADB shell dumpsys command contains all the content about the system service. This command has more detailed usage. For example, ADB shell dumpsys meminfo system is used to view the memory information of the process of the system.

Kmsg capture
ADB shell CAT/proc/kmsg> kmsg.txt. Open it and check the msm_kgsl field.

Description: used to retrieve kernel messages generated by printk. At any time, only one Super User-authorized process can read the file. You can also use the system to call syslog To retrieve these messages. You can use the dmesg tool or the klogd daemon to retrieve these messages. Proc is a memory file system. Each time you read a file, kmsg is actually a circular buffer inside the kernel. After each read, the circular buffer is considered to have been processed (that is, it turns into invalid content), so it is normal for you to read it empty again. Why is it so much like this? The circular buffer size is limited, the kernel may write something into it at any time, so this process is normal. check whether/proc/kmsg information is associated with system logs. If yes, you can read log files.

Dmsg capture
ADB shell dmesg> dmesg.txt

Note: dmesg is used to display the boot information. The kernel stores the boot information in the ring buffer. You can use dmesg to view the information if you cannot view it at startup. Dmesg is the log of the kernel. Any problems related to the kernel, such as driver (camera, Bluetooth, USB, startup, etc.) are also stored in the/var/log directory, file named dmesg. More/var/log/dmesg

Capture logs in engineering mode
For the mobile phone number of Apollo, call * #8888 # *, and select the corresponding log. After the test is complete, export the log to the PC through the SD card.

3. Log Analysis
Get log from Android system

ADB bugreport> bugreport.txt

Copy bugreport to the current directory.

Bugreport contains various log information. Most logs can be directly obtained by running related programs.

The procedure is as follows:
(1) ADB Shell
(2) enter the directory of related tools and programs
(3) execute related programs
(4) obtain relevant information

The following uses the output process information as an example.
(1) ADB Shell
(2) Input PS-P
(3) view the process information.
 

Bytes --------------------------------------------------------------------------------------------------

Log archive analysis

1. bugreport
Bugreport records the log of the android startup process and the system status after startup, including the process list, memory information, Vm information, and so on.

2. bugreport Structure Analysis
(1) dumpstate

Memory info
Get the log: Read the file/proc/meminfo
System memory usage status

CPU info
Obtain the log: Run/system/bin/top-N 1-D 1-M 30-T
System CPU usage status

Procrank
Get the log: Run/system/bin/procrank
Run/system/xbin/procrank to view some memory usage status.

Virtual Memory stats
Get the log: Read the file/proc/vmstat
Virtual Memory Allocation

The memory applied for by vmalloc is located in vmalloc_start ~ There is no simple Conversion Relationship Between vmalloc_end and physical addresses. Although they are logically continuous, they do not require continuity physically.

Vmalloc info
Get the log: Read the file/proc/vmallocinfo
Virtual Memory Allocation

Slab info
Get the log: Read the file/proc/slabinfo
Slab is a memory distributor. some information about this distributor is output here.

Zoneinfo
Get the log: Read the file/proc/zoneinfo
Zone info

System log (analysis required)
Get the log: Run/system/bin/logcat-V Time-D *: V
Logs output in the program are used to analyze the current status of the system.

VM traces
Get the log: Read the file/data/ANR/traces.txt
Because every program runs in its own Vm, this log is actually some traces of their respective VMS.

Event Log tags
Get the log: Read the file/etc/event-log-tags.

Event Log
Get the log: Run/system/bin/logcat-B events-V Time-D *: V
Output logs of some events

Radio Log
Get the log: Run/system/bin/logcat-B radio-V Time-D *: V
Display the connection status of some wireless devices, such as GSM, phone, STK (Satellite Tool Kit )...

Network State
Obtain the log: Run/system/bin/netcfg to obtain the network connection status)
Get the log: Read the file/proc/NET/route (obtain the Route status)
Show network links and routes

System Properties
Obtain the log: see the code implementation.
Displays System attributes, such as version, services, network, and so on...

Kernel log
Get the log: Run/system/bin/dmesg
Display logs output by the android Kernel

Kernel wakelocks
Get the log: Read the file/proc/wakelocks
The kernel records the wake-up and sleep of some programs and services.

Kernel cpufreq
(Linux kernel cpufreq subsystem) Clock scaling allows you to change the clock speed of the CPUs on the fly.
This is a nice method to save battery power, because the lower the clock speed is, the less power the CPU consumes.

Processes
Get the log: Execute PS-P
Display current process

Processes and threads
Obtain the log: Execute PS-T-p.
Display current process and thread

Librank
Obtain the log: Run/system/xbin/librank.
Remove unnecessary Libraries

Binder failed transaction log
Get this log: Read the file/proc/binder/failed_transaction_log

Binder transaction log
Get the log: Read the file/proc/binder/transaction_log

Binder transactions
Get the log: Read the file/proc/binder/transactions

Binder stats
Get the log: Read the file/proc/binder/stats

Binder process state
Get the log: Read the file/proc/binder/proc /*
Bind-related statuses

Filesystems
Obtain the log: Run/system/bin/DF.
Usage Status of some major files (cache, SQLite, Dev ...)

Package settings
Get the log: Read the file/data/system/packages. xml
Status of the package in the system (access permission, path ...), Similar to some lnk files in windows.

Package uid errors
Get the log: Read the file/data/system/uiderrors.txt
Error Message

Kernel last kmsg log
Latest kernel Message Log

Last radio log
Latest radio log

Kernel panic console log
Kernel panic threads log
Console/thread Error Log

Backlights
Get this log: Get LCD brightness read/sys/class/LEDs/LCD-backlight/brightness
Get this log: get the button brightness read/sys/class/LEDs/button-backlight/brightness
Get this log: Get keyboard brightness read/sys/class/LEDs/keyboard-backlight/brightness
Get this log: Get the ALS mode read/sys/class/LEDs/LCD-backlight/als
Get this log: Get the LCD Driver registers read/sys/class/LEDs/LCD-backlight/registers
Obtain information about the brightness.

(2) Build. Prop
Version info output the following information
Current Time
Current kernel version: available for reading files (/proc/version)
Display the current command: it can be obtained by reading the folder (/proc/cmdline ).
Display some system build attributes: can be obtained by reading the file (/system/build. Prop)
Output System attributes
GSM. version. RIL-impl
GSM. version. baseband
GSM. IMEI
GSM. Sim. Operator. Numeric
GSM. Operator. Alpha

(3) dumpsys
Run/system/bin/dumpsys to obtain the log.
It is often found that the log output is incomplete, because the Code requires that the tool only execute 60 ms at most, and the log may not be completely output.
You can modify the time parameter to ensure full log output.
Information:
Currently running services
Dump of service services-Name (running)

Log Code Analysis
Site:. \ frameworks \ base \ cmds \ dumpstate \
The relevant log program code can be obtained from the above directory

Log analysis experience

Analysis Steps

1. view some version information
System Environment for problem confirmation
2. View CPU/memory usage
Check whether the memory is exhausted and the CPU usage is busy.
3. Analyze traces
Because traces is the thread stack information output after a system error, you can quickly locate the problem.
4. analyze the system log
System logs output various logs in detail, and relevant logs can be found for analysis one by one

Instance analysis

The following is an example of a test I wrote. an endless loop is made in oncreate, so that the main thread will be locked and ANR errors will occur after the hardware back is pressed.
The stack information of the program found in traces is as follows:
-- PID 20597 at 01:29:53 --
Cmd Line: COM. Android. Test
Dalvik threads:
"Main" PRIO = 5 tid = 3 timed_wait
| Group = "Main" scount = 1 dscount = 0 s = n OBJ = 0x2aac6240 self = 0xbda8
| Shard id = 20597 nice = 0 sched = 0/0 CRL = default handle = 1877232296
At java. Lang. vmthread. Sleep (native method)
At java. Lang. thread. Sleep (thread. Java: 1306)
At java. Lang. thread. Sleep (thread. Java: 1286)
At Android. OS. systemclock. Sleep (systemclock. Java: 114)
At com. Android. Test. Main. oncreate (main. Java: 20)
At Android. App. instrumentation. callactivityoncreate (instrumentation. Java: 1047)
At Android. App. activitythread. javasmlaunchactivity (activitythread. Java: 2459)
At Android. App. activitythread. handlelaunchactivity (activitythread. Java: 2512)
At Android. App. activitythread. Access $2200 (activitythread. Java: 119)
At Android. App. activitythread $ H. handlemessage (activitythread. Java: 1863)
At Android. OS. handler. dispatchmessage (handler. Java: 99)
At Android. OS. lorule. Loop (lorule. Java: 123)
At Android. App. activitythread. Main (activitythread. Java: 4363)
At java. Lang. Reflect. method. invokenative (native method)
At java. Lang. Reflect. method. Invoke (method. Java: 521)
At com. Android. Internal. OS. zygoteinit $ methodandargscaller. Run (zygoteinit. Java: 868)
At com. Android. Internal. OS. zygoteinit. Main (zygoteinit. Java: 626)
At Dalvik. system. nativestart. Main (native method)
"Binder thread #2" PRIO = 5 tid = 11 native
| Group = "Main" scount = 1 dscount = 0 s = n OBJ = 0x2fb7c260 self = 0 × 143860
| Shard id = 20601 nice = 0 sched = 0/0 CRL = default handle = 1211376
At Dalvik. system. nativestart. Run (native method)
"Binder thread #1" PRIO = 5 tid = 9 native
| Group = "Main" scount = 1 dscount = 0 s = n OBJ = 0x2fb7c1a0 self = 0x14c980
| Shard id = 20600 nice = 0 sched = 0/0 CRL = default handle = 1207920
At Dalvik. system. nativestart. Run (native method)
"Signal catcher" daemon PRIO = 5 tid = 7 runnable
| Group = "system" scount = 0 dscount = 0 s = n OBJ = 0x2fb7a1e8 self = 0x126cc0
| Shard id = 20599 nice = 0 sched = 0/0 CRL = default handle = 1269048
At Dalvik. system. nativestart. Run (native method)
"Heapworker" daemon PRIO = 5 tid = 5 vmwait
| Group = "system" scount = 1 dscount = 0 s = n OBJ = 0x2e31daf0 self = 0x135c08
| Shard id = 20598 nice = 0 sched = 0/0 CRL = default handle = 1268528
At Dalvik. system. nativestart. Run (native method)
-- End20597 --

Analyze the stack structure of the file from the bottom up
(1) stack bottom at Dalvik. system. nativestart. Run (native method)
The system starts a dedicated virtual machine for the current task (application ).
(2) At Android. App. activitythread. initialize mlaunchactivity (activitythread. Java: 2459)
Activity Services manages the activity in the background. It starts the activity in the test example.
(3) At com. Android. Test. Main. oncreate (main. Java: 20)
Start the test program
(4) stack top at java. Lang. vmthread. Sleep (native method)
The thread is sleep, so it cannot respond to the user and an ANR error occurs.

The above is an analysis of a very simple problem.

If you encounter complicated problems, you need to analyze the system log in detail.
1. For example, if a network exception occurs, you must use the network link information output in system log to determine the network status.
2. Analyze the activitymanager response time in system log for time-consuming operations such as data transmission and network connections.
3...

From: http://blog.tianya.cn/blogger/post_read.asp? Blogid = 3615546 & postid = 35799878

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.