Finishing Android test log file crawl and analysis-top

Source: Internet
Author: User
Tags system log dmesg

http://blog.csdn.net/ameyume/article/details/7667574

1.log File Classification Introduction
The main real-time printing is: Logcat main,logcat radio,logcat Events,tcpdump, there will also be a high-pass platform QXDM Log
Status information: adb shell cat/proc/kmsg, adb shell dmesg,adb shell dumpstate,adb Shell dumpsys,adb Bugreport, engineering mode, etc.


2.LOG Crawl Explanation
(1) Real-time printing
ADB logcat-b main-v time>app.log print application's log

ADB logcat-b radio-v time> radio.log print RF related LOG,SIM STK will also be inside, modem related atcommand and so on, of course, with QXDM is far from the difference.

ADB logcat-b events-v Time Print system event log, such as touch-screen event ...

Tcpdump is useful for TCP/IP protocol-related can use this to catch, adb shell tcpdump-s 10000-w/sdcard/capture.pcap, such as the capture MMS download when the UA profile, Browser The Internet, the use of proxy APN download, streaming related content including UA profile.

Finally, Qualcomm platform QXDM, whether it is not Android, as long as the use of high-pass chip, will be familiar with it, of course, not Qualcomm chip will not have to mention it. This is not much to say, rich content, radio frequency, telephone, Internet, ... All Qualcomm offers the solution, this can be caught. (QXDM log Crawl method, please refer to Qpst, QXDM basic instructions and functions of use)

(2) Status information
Bugreport (command adb bugreport>bugreport.log). It contains Dmesg,dumpstate and Dumpsys.

Dumpstate is the System state information, which is more complete, including the current memory information of the cell phone, CPU information, Logcat cache, kernel cache and so on.

ADB Shell Dumpsys This is what the system service is all about, and this command has a more detailed usage, such as the ADB shell Dumpsys meminfo System is the memory information for the process of viewing system.

Kmsg Crawl
adb shell cat/proc/kmsg > kmsg.txt, open to check Msm_kgsl field

Description: Used to retrieve kernel messages generated with PRINTK. Only one process with superuser privileges can read this file at any time. These messages can also be retrieved using System invoke syslog. These messages are typically retrieved using the tool DMESG or daemon klogd. Proc is a memory file system, each read file kmsg is actually a loop buffer inside the kernel, after each read, the loop buffer thing is considered to have been processed (that is, to become invalid content), so you read again empty is very normal why this process, the loop buffer size is limited, The kernel can write to it at any time, so it's normal to handle it. You go find out if/proc/kmsg's information is associated with the system log, and if so, you can read the log file.

Dmsg Crawl
adb shell DMESG > Dmesg.txt

Note: DMESG is used to display the boot information, kernel will store the boot information in the ring buffer. If you are too late to view the information, you can use DMESG to view it. DMESG is kernel log, usually with kernel related, such as driver out of the problem (camera, Bluetooth, USB, boot, etc.) boot information is also saved in the/var/log directory, the name is DMESG file. More/var/log/dmesg

Log fetching in engineering mode
For the Apollo phone, call *#* #8888 #*#* and tick the corresponding log. After the test is finished, export log to PC via SD card.


3.Log Analysis
Get Log from Android System

ADB bugreport > Bugreport.txt

Copy Bugreport to the current directory.

Bugreport contains a variety of log information, most of the log can also be directly run by the relevant program directly to obtain.

The steps are as follows:
(1) ADB shell
(2) Enter the directory of the relevant tool program
(3) Execute the relevant program
(4) Get the relevant information

The following is an example of the output process information
(1) ADB shell
(2) Input ps-p
(3) You can see the relevant process information
 

--------------------------------------------------------------------------------------------------

Log Archive Analysis

1.bugreport
Bugreport records the log of the Android boot process, as well as the system status after startup, including the process list, memory information, VM information, etc. wait until.

2.bugreport Structural Analysis
(1) dumpstate

MEMORY INFO
Get the log: Read file/proc/meminfo
System memory Usage Status

CPU INFO
Get the log: Execute/system/bin/top-n 1-d 1-m 30-t
System CPU Usage Status

Procrank
Get the log: Execute/system/bin/procrank
Results of output after executing/system/xbin/procrank, view some memory usage status

VIRTUAL MEMORY STATS
Get the log: Read file/proc/vmstat
Virtual Memory allocation Status

Vmalloc application memory is located between Vmalloc_start~vmalloc_end, there is no simple conversion relationship with physical address, although they are also logically contiguous, but physically they do not require continuous.

Vmalloc INFO
Get the log: Read file/proc/vmallocinfo
Virtual Memory allocation Status

SLAB INFO
Get the log: Read file/proc/slabinfo
Slab is a memory allocator. Here is some information about the output of this allocator

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

SYSTEM LOG (need to focus on analysis)
Get the log: Execute/system/bin/logcat-v time-d *:v
Outputs the log output in the program to analyze the current state of the system

VM traces
Get the log: Read file/data/anr/traces.txt
Because each program is running in its own VM, this log is some of the traces of the actual VMS

EVENT LOG TAGS
Get the log: Read file/etc/event-log-tags

EVENT LOG
Get the log: Execute/system/bin/logcat-b events-v time-d *:v
Output log of some event

RADIO LOG
Get the log: Execute/system/bin/logcat-b radio-v time-d *:v
Shows the link states of some wireless devices, such as GSM,PHONE,STK (satellite Tool Kit) ...

NETWORK State
Get the log: Execute/system/bin/netcfg (Get network link status)
Get the log: Read file/proc/net/route (get routing status)
Show Network links and routes

SYSTEM PROPERTIES
Get the log: reference code implementation
Displays some system properties, such as version,services,network ...

KERNEL LOG
Get the log: Execute/SYSTEM/BIN/DMESG
Log that shows Android kernel output

KERNEL Wakelocks
Get the log: Read file/proc/wakelocks
Some records of the kernel waking and hibernating some programs and services

KERNEL CPUFREQ
(Linux kernel CPUfreq subsystem) Clock scaling allows the clock speed of the CPUs on the fly.
This was a nice method to save battery power, because the lower the clock speed is and the less power the CPU consumes.

PROCESSES
Get the log: Execute ps-p
Show Current process

PROCESSES and THREADS
Get the log: Execute ps-t-p-p
Show current processes and threads

Librank
Get the log: Execute/system/xbin/librank
Eliminate unnecessary library

BINDER FAILED TRANSACTION LOG
Get the log: Read file/proc/binder/failed_transaction_log

BINDER TRANSACTION LOG
Get the log: Read file/proc/binder/transaction_log

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

BINDER STATS
Get the log: Read file/proc/binder/stats

BINDER PROCESS State
Get the log: Read file/proc/binder/proc/*
Some states related to bind

Filesystems
Get the log: Execute/SYSTEM/BIN/DF
Some capacity usage status for primary files (Cache,sqlite,dev ...)

Package SETTINGS
Get the log: Read file/data/system/packages.xml
Some of the status of the package in the system (access rights, paths ...), similar to some LNK files in Windows.

Package UID ERRORS
Get the log: Read 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 messages log

Backlights
Get the log: Get LCD brightness Read/sys/class/leds/lcd-backlight/brightness
Get the log: Get button brightness Read/sys/class/leds/button-backlight/brightness
Get the log: Get keyboard brightness Read/sys/class/leds/keyboard-backlight/brightness
Get the log: Get ALS mode read/sys/class/leds/lcd-backlight/als
Get the log: Get LCD driver Registers read/sys/class/leds/lcd-backlight/registers
Get some information about the relative brightness

(2) Build.prop
VERSION Info outputs the following information
Current time
Current kernel version: can read files (/proc/version) get
Show current command: can read folder (/proc/cmdline) get
Displays some properties of the system build: can read files (/system/build.prop) get
Output system Some properties
Gsm.version.ril-impl
Gsm.version.baseband
Gsm.imei
Gsm.sim.operator.numeric
Gsm.operator.alpha

(3) Dumpsys
This log can be obtained after executing the/system/bin/dumpsys.
It is often found that the log output is incomplete because it requires the tool to execute at most 60ms, which may cause log to not be fully output.
You can ensure that the log is fully output by modifying the time parameters.
Information:
Currently running services
DUMP of SERVICE Services-name (running)

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

Log Analysis Experience

Analysis steps

1. View some version information
Identify the system environment for the problem
2. View the usage status of Cpu/memory
See if there is memory exhaustion and the CPU is busy in such a background situation.
3. Analysis Traces
Because traces is some thread stack information that is output after a system error, you can quickly pinpoint where the problem is.
4. Analyze System LOG
System log verbose output log, you can find the relevant log to analyze each


Example analysis

The following analysis I wrote a test example, in the OnCreate to do a dead loop, so that the main thread will be locked, after pressing the hardware back, there will be a ANR error.
The stack information for the program is found in traces as follows:
-–pid 20597 at 2010-03-15 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
| systid=20597 nice=0 sched=0/0 Cgrp=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.performLaunchActivity (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.Looper.loop (looper.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=0x143860
| systid=20601 nice=0 sched=0/0 Cgrp=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
| systid=20600 nice=0 sched=0/0 Cgrp=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
| systid=20599 nice=0 sched=0/0 Cgrp=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
| systid=20598 nice=0 sched=0/0 Cgrp=default handle=1268528
At Dalvik.system.NativeStart.run (Native Method)
-–end 20597-–

The stack structure of the file is analyzed from bottom to top
(1) Bottom stack at Dalvik.system.NativeStart.run (Native Method)
The system launches a dedicated virtual machine for the current task (application)
(2) at android.app.ActivityThread.performLaunchActivity (activitythread.java:2459)
Activity Services is responsible for managing activity in the background, and it starts the activity of the test example at this time
(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 was dropped by sleep, so it was unable to respond to the user and a ANR error occurred.


The above is an analysis of a very simple question.


If you encounter more complex problems, you need to analyze the system LOG in detail.
1. For example, network anomaly, to determine the network status through the network link information output in the system log
2. Data transfer, network links and other time-consuming operations need to analyze the response time of the Activitymanager inside the system log
3 ...

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.