Copyright . MediaTek Inc. All rights reserved.
Android mtk log&debug
2012/08/13
MTK Support
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 1
Outline
.MTK Log Overview
.MTK logging tool
–Target side
.Mobilelog logger
.Modemlog logger
.Network Diagnose Tool
–PC side
.GAT
–GDB
–Ftrace
.Cachter
.Hyper terminal tool
.抓取eService Log
.NE
–Gnu toolchainMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 2
Android log system overview (1/2)
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 3
Android log system overview (2/2)
.Logger device and kernel buffer
–Character device
–Buffer size and meaning
.Main (64KB in previous/128KB in MTK, 256KB in android3.0)
–Main application log
.Events (128KB in previous, 256KB in android3.0)
–System event information
.Radio (64KB in previous, 256KB in android3.0)
–Radio and phone-related information
.System (64KB in previous, 256KB in android3.0)
–Low-level system messages and debuggingMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 4
MTK log system overview
.Android Log
–Android java layer log and native layer log
.Kernel Log
–Linux kernel log for kernel layer and drivers
.Catcher Log
–Modem log and use this tool to modify IMEI
.Exception Database
–System/exception info when fatal(kernel exception and system
server exception)occur
.Kernel Panic Log
–The log for kernel panic/oopsMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 5
AEE Introduction (1/2)
.What is AEE?
–Android Exception Engine (AEE) Feature is an exception catching
and debugging information generation mechanism.
.Basic terminology & definition
–Exceptions are typically used to signal that something went wrong
or abnormal (e.g. a division by zero occurred, memory access
violation, undefined instruction). We consider those exceptions
crashing the system
.DB position
–mnt/sdcard/mtklog/aee_exp (sdcard is mounted)
–data/aee_exp (sdcard is unmount)
.View DB
–GAT log viewMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
AEE Introduction (2/2)
JEMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE AEE Introduction (2/2)
JEMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
AEE
Java Exception
Native Exception
Kernel Exception
Kernel Panic
Memory usage
analysis &
debugging
Performance
bugs analysis &
debugging
Debugger
External Exception
NE
KE
Exception Handling
Analysis & Debugging Mechanisms/Tools
Copyright . MediaTek Inc. All rights reserved. 2012/8/30 6
2012/8/30 Copyright . MediaTek Inc. All rights reserved 7
Outline
.MTK Log Overview
.MTK logging tool
–Target side
.Mobilelog logger
.Modemlog logger
.Network Diagnose Tool
–PC side
.GAT
–GDB
–Ftrace
.Cachter
.Hyper terminal tool
.抓取eService Log
.NE
–Gnu toolchainMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 8
Android Logging Tool
.Target side (System log tool)
–Mobilelog logger (Built-in Engineer Mode)
.Apk on target, dump android log and kernel log to NAND or SD card(default) on target
–Modemlog logger (Built-in Engineer Mode)
.Apk on target, dump modem log to SD card(default) or send to PC side via USB port
.PC side
–GAT(GUI-based debug info Analyzer Tool)
.PC side tool, dump android log and kernel log to PC side via USB port
–Catcher
.PC side tool, dump modem log to PC side via USB port
–Hyper terminal tool
.Get Linux kernel log via UART4 port
仅GB版本可保持在手机上
Android Log
kernel
Panic Log
Modem Log
Exception DB
GAT
Mobile Log
Modem Log
Catcher
Hyper terminal
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Inc. 9
System logging Tool
. Enter engineer mode by dialing *#*#3646633#*#*” .SystemLog
. Systemlog .Common UI
–快速开关log (modem log, mobile log, network test)
在拨号界面输入
选择“SystemLog”
Network运行标志
Modem log运行标志
Mobile log运行标志
下拉
点击
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Mobilelog logger (1/2)
.
SystemLog .
Mobile log
.
This is a tool which could get AP
Log(Main/Radio/BT/Event/Kernel log)
. Steps of start the mobile log ICS版本只能保存在SD卡上
–
The default position=mnt/sdcard/mtklog/mobilelog
. /data/mobilelog
–
Type the log size, default is 300MB (The total log size)
–
Configure or disable auto run
–
Click the start button
.
Then you can leave the process and it will run on background
.
Notifications on the top bar indicate the status of mobile log
Mobile log运行标志
.
Which kind of Log we should not use MobileLog?
–
In fact, any tool has its limitations, there are some cases which they
can not record logs
Phone hang
Can record nothing
Copyright .
Suspend log
Can.t record suspend log
Boot up Log Depends on the number of logs, it may loose the beginning log
Shutdown Log Can.t record all shutdown log
UMS Can.t work if the mounted sdcard is used to store Log
MobileLog
停止时可以清除log,强烈建
议在验证问题前清除log
2012/8/30 Copyright . MediaTek Inc. All rights reserved 11
Mobilelog logger (2/2)
. User build不能通过usb抓取kernel log
.当kernel异常无法重启时无法获取kernel panic log
.不同类型的log的时间戳不一致?
– log开始的时间戳不一致(MobileLog use a rotate mechanism. The oldest Log might be overwrite
by new arrived)
. To control the Log size, Log files recorded by MobileLog are limited to 5 files at maximum, and the
size of each file is computed by total size and how many Log type should be record
. If one log file reach its size, then rename it to “*.1”, and original “*.1” turn to “*.2”, and so on. The
original “*.4” will be deleted
– log结束的时间戳不一致(最后的log丢失)
. It may be the case that user does not stop the tool, there are still some logs in buffer and did not
flush to sdcard
. “main_log.boot”和“main_log.4”时间戳差很大?
– main_log.boot is a independent file which record the log during boot up, it will not be overwritten
like main_log.4
.如何知道log已经停止录制?
– If the user did not stop MobileLog and pull log directly, the size of all *_log will seem to be 1KB or
very close to the integer multiples of 64KB, which is the buffer size of MobileLog
. Log有乱码?
– This case may be happen if there suffer some Sdcard issues
. Content of other files appear in log file
. There a lot of wrong characters in log file (may be content of binary file or image)
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 12
Modemlog logger (1/2)
.Modem Log为Modem端产生的Log,即FP里的Cather
Log
–Modem log是binary格式的log,不能直接打开看,需要MTK
的catcher工具查看
.It support 2 ways of logging: SD logging and USB
logging
–In SD logging mode, it records modem logs in SD card
files
–In USB logging mode, it relays modem logs to PC Catcher
via USB connection
.Steps of start the modem log
–position=mnt/sdcard/mtklog/mdlog
–Type the log size: 1GB/600MB/stop until sd full (The total
log size)
–Configure or disable auto run
–Click the start button
.Notifications on the top bar indicate the status of
modem log
.如何处于idle状态
–进入modem log,取消开机自动启动,重启手机
.Users can open .dmp files by Catcher
只有在idle状态下
才可以切换模式
Modem log运行标志
Uart1 logging at 921600
bps will be disabled
6种logMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 13
Modemlog logger (2/2)
. Log folder
–每次开机或是MDLogger pause又resume后, 就会开一个新的folder
– Log size大的原因: telephony 问题方面的共性,当发现问题时,可能出现问题的时间点已经过去了很久了,一个典型
的案例就是register network reject 问题,当网络reject 掉的时候,可能出现在三更半夜,而当您早上起来无法注册网
络的时候,LOG 早就已经被刷掉了
– Memory Dump
. Name such as Memory_PS_2010_0916_171003.bin
. After memory dump is done, a dialog will be popped up to inform users that memory dump is finished (Click “OK” would
reset Modem and MDLogger)
. Recycling
– MDLogger每30秒会去检查目前size
.若剩下空间小于5MB就会启动删log机制
.每次刪log的标准是要清出大于10MB的空间
.优先删除所有非Modem log Folder –> 删除没有EE的Folder(但如果bin文件会保留bin和catcher需要的db文件) -> 删除正
在记录的folder里一些log文件(会有所保留) –> 删除EE(保留db和bin)-> 删除EE folder
– Note
.设置了600M或1G模式,但如果SD Card内存剩余空间不够那么多,SD Card先满了Modem工具还是会先停止,不会因
SD Card满而去删除Modem Log
. Filter file
– Modem need a filter file to output specific log:
. So “catcher_filter.bin”(后面介绍生成方法) is must for SD mode
– ModemLog will search the filter file in the following path in order:
. /sdcard/mtklog/mdlog/catcher_filter.bin
. /system/etc/firmware/catcher_filter.bin (default in load)
– Set custom filter
. push the filter file into the folder: /sdcard/mtklog/mdlog/
. Please reboot the target if catcher_filter.bin is updated by adb pushMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 14
Network Diagnose Tool
. Objective
– Since many networking issues are difficult to reproduce. When the issue happens, This
tool can get enough networking information for resolving networking issue
. This tool can get so many networking information
– Networking information in proc folder
– NIC information
– the default routing and dns server
– tcpdump Log
– ping Log
. Log position
– mnt/sdcard/mtklog/netlog
. This UI as shown:
– This tool .s main functions divided into 5 parts:
. Start tcpdump
. Stop tcpdump
. Run shell command
. Stop running shell command
. Clear log
It will cost long time after you stop the tool,
because the tool will auto full test , so Please wait.
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 15
Log tool customization
.Path: mediatek/source/external/xlog/tools
–mtklog-config-eng.prop is for eng build
–mtklog-config-user.prop is for user build
.Content of mtk-config-<eng/user>.prop
–mobile for MobileLog/modem for ModemLog/net for NetLog
–persist.sys.log2sd.defaultpath
.Default path for Log, eg, /data, /mnt/sdcard or /mnt/sdcard2
–com.mediatek.log.<mobile/modem/net>.enable
.If the tool should auto-start after first download
–com.mediatek.log.<mobile/modem/net>.maxsize (Unit: MB)
.Log Tool will set log size as default value if you set it as 0
–MobileLog:300/ModemLog:600/NetLog:200MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Get Logs out of SD-Card
.Log path
–Mobile log tool: mnt/sdcard/mtklog/mobilelog
–Modem log tool: mnt/sdcard/mtklog/mdlog
–Net log tool: mnt/sdcard/mtklog/netlog
–AEE DB: mnt/sdcard/mtklog/aee_exp (sdcard is mounted)
–AEE DB: data/aee_exp(sdcard is unmount)
.There are 3 ways for you to pull logs from SD-Card to PC, and the following 3 pages will tell you some
details
–Mount to PC(UMS) and run copy/paste
–Through adb pull commond
–Through file explorer in DDMS/GAT
.Mount to PC and run copy/paste
–UMS (USB Mass Storage)
.This way is safe but should notice the limitation of Log tool (做UMS时无法抓取log).
–MTP (Media Transfer Protocol) (Do not use this!)
.This way is not safe because there is a big file sync issue
–happen
–
–with
Before this,
please stopped
log tool first!
Tool can detect
this error and
show messagesMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 17
GAT
.Overview
.Main UI
.Mediatek Extended functionality
–Online part
.Log Recorder
.Process Information
.Debug Configuration Setting
.DB Puller
.Profile
–Cpu time
–App launch
–ftrace
–Offline part
.Logview
.FAQMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 18
Overview
.GAT is a GUI-based debug info analyzer (designed by Mediatek)
and provides a GUI that all utilities are integrated into for improving
efficiency of development and debugging
–Base on DDMS UI and add more features for debugging more effectively.
–Can diagnose whole system status automatically and help QA/RD to
figure out owner(Expert System)
–Support windows and linux
GAT online part
Android/kernel log
recorder
Support ALE XLOG Setting
Debug
Debug
Configurati
on
adb window
Process
Information
Thread
Back trace
Puller
DB Puller
GAT offline part
Log View Diagnose Script Plug in
Autodiagnose.j
ar
Backtrace.py
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 19
Main UI -GAT
.GUI-based debug info analyzer
点击打开cmd,
一般用于adb命令
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Log Recorder (1/4)
2012/8/30 Copyright . MediaTek Inc. All rights reserved. 20
. Get kernel log and android log via USB port or UART port
and can save to PC
– Support ALE feature
– Support XLOG Setting
. Android Log
. Kernel Log
– Get the kernel log via USB
– Get the kernel log via UART
. Step by step
– Choose RIGHT COM port for your device
– Click “UART” button
. Note
– Log level is invalid because Linux kernel doesn.t output kernel log level by default.
– Note: this UART kernel log is only supported for windows OS
Codebase没有开启MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Log Recorder (2/4)
.Save log
2012/8/30 Copyright . MediaTek Inc. All rights reserved. 21
点击保存log
点击保存logMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Log Recorder (3/4)
2012/8/30 Copyright . MediaTek Inc. All rights reserved. 22
.Add DDMS Filter
.XLog Filter
–Logs filtered by xlog will
never appear in android log
buffer, which means xlog is a
pre-filter.
–Logs filtered by DDMS are
still in log buffer while does
not be shown. DDMS is a
post-filter
点击添加
随便取一个名字
选择过滤条件
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Log Recorder (4/4)
也可以用adb shell配置xlog
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Process Information
. “Process” Panel
Copyrigh
Before click “Backtrace”,
set symbol path
include following parts:
a. basic information of process
b. kernel space back trace
c. native layer back trace. This item
does not exist for kernel threads.
d. java layer back trace. This item
does not exist for non java processes.
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
GDB Debug
.右击进程
.设置symbols和
source路径
.程序自动通过adb
连接,启动gdb
debug对应的进
程
2012/8/30 Copyright . MediaTek Inc. All rights reserved. 25MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
GDB manual setup
. Debug the program
– On the device, launch a new command
. #gdbserver :1234 /system/bin/<executable>
– or attach to an existing process
. #gdbserver :1234 –attach <pid>
. On the host, forward port to the device with adb
– #adb forward tcp:1234 tcp:1234
. Connect to target
– cd alps/
– file ./out/target/product/$project/symbols/system/bin/xxx
– set solib-search-
path ./out/target/product/$project/symbols/system/lib
– set solib-absolute-prefix ./out/target/product/$project/symbols
– target remote:1234
2012/8/30 Copyright . MediaTek Inc. All rights reserved. 26
adb shell
You can use “ps” command to
find out the process ID
The version of arm-eabi-gdb*
and gdbserver must matchMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
GDB command
GDB command
.
– http://sourceware.org/gdb/current/onlinedocs/gdb/
– UI gdb debugger: http://www.gnu.org/software/ddd
Command Abbreviation Description
attach at Attaches to a running process You can use gdb
command “help
backtrace bt Prints a stack trace [command] if you want
break b Sets a break point to know how to use itcontinue c Allows the program to continue executing
delete Clears a break point by number
detach
Detaches from the currently attached process
display
Displays the value of an expression every time execution stops
finish
Runs to the end of the function and displays return values of that function
jump
Jumps to an address and continues the execution there
listl
l
Lists the next 10 lines
next
n
Steps to the next machine language instruction
p
Prints the value of an expression
run
r
Runs the current program from the start
Changes the value of a variable
Copyright . set
step
s
Steps the program instruction by instruction
MTK bug report
.will produce a zip file
(mtk_bugreport_xxxxxx_xxxxxx.zip) in the Temp
directory
.This zip file is used to the Mediatek feedback bugs.
2012/8/30 Copyright . MediaTek Inc. All rights reserved. 28
一次性将手机里的log捞
出,方便客户提供debug
资料给MTKMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Debug Configuration Setting
2012/8/30 Copyright . MediaTek Inc. All rights reserved. 29
.Feature
–Clear AEE DB
.Android Exception Engine: an exception catching and debugging
information generation mechanism.
.Db folder:
–sdcard\mtklog\aee_exp
–data\aee_exp (if sdcard is not Available)
–Manual Dump DB
–Clear Red ScreenMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
DB puller
2012 Copyright . MediaTek Inc. All rights reserved.
.Feature
–Can list db files in phone and SD card and pull these to PC
(and launch GAT offline part)
Offline logview稍后会讲
用此工具解开DBMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Profile
.If you want to use this feature, it is recommended that
click the below button to save the target CPU time.
.Profile feature (only eng build)
–CPU time
–APP Launch
2012/8/30 Copyright . MediaTek Inc. All rights reserved. 31MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
CPU time (1/2)
.Manual mode
.Auto mode
201Copyright . MediaTek Inc. All rights reserved.
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
CPU time (2/2)
. adb shell cputime [……]
– e.g.
. cputime –e 100 // enable cputime monitor, and stop after 100 seconds. Then show process
cputime.
. cputime -start // start the CPU time monitor.
. cputime –stop // stop the CPU time monitor and show result
. cputime –e 300 –m 10 // start cputime monitor about 300 seconds. Show top 10 thread
. cputime –m 10 –p // show top 10 process
. cputime –m 5 –s isr_c // show top 5 isr count
– Arg
. -start start cpu time monitor.
. -stop stop cpu time monitor.
. -n num updates to show before exiting.
. -d num seconds to wait between updates.
. -m num Maximum number of information to display.
. -e num Enable CPU time monitor and stop monitor after “time” seconds. If no this parameter will show
last cputime monitor data.
. -p show process instead of thread. If no this parameter default will show thread information.
. -s col column to sort by time/user/kernel/id/isr_c/isr_t(cputime /user time/kernel
time/id/isr_count/isr_time), If no this parameter default will sort by cputime.
. -i id show sir information of thread id.
cputime –m 5 –s isr_cMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
APP Launch
. If you have done “Enable APP launch” on one device,
the menu will be disable. Or you need first do this, then
the phone will reboot.
2012/8/30 ediaTek Inc. All rights reserved. 34
准备好要进入app的界面,比
如这边要测量setting的启动过
程,准备好后按确定
等进入画面后按
确定,停止测量
Logged by
cputime
Logged by
ftraceMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Ftrace –Kernel Function Tracer
. Used to trace the kernel function at beginning
– It.s now an infrastructure that can be used for debugging or
analyzing latencies and performance issues in the kernel
. What this tool can help?
– Tracing kernel function, timing, context switch, interrupt latency,
events etc…
. Ftrace is framework for different tracers
– Auto inserted by compiler: Uses gcc .-pg. option
– Inserts call to .mcount. in each function prologue
. ARM platform implement in <arch/arm/kernel/entry-common.S>
. mcount must be called with a consistent stack frame and frame pointer. You can.t use “-fomit-
frame-pointers“ compiler option on ARM
– Compiler disables some optimizations automatically
– Can be used for debugging and profiling system behavior
. What.s the limitation?
– Enable it will add system overhead
– Basically, it.s a debugging tool, not a monitoring tool
2012/8/30 Copyright . MediaTek Inc. All rights reserved. 35MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Usage Scenario
. Ftrace has many tracers
– The most used “sched_switch“ tracer is default enabled on alps 2.3 (engineer mode)
. The “sched_switch“ tracer can be used for system behavior and performance
issue analysis
. Some possible scenario:
– Boot time analysis
– APP launch time analysis
– User scenario analysis
– Use the “sched_switch“ tracer to see the process flow based on time, and check if any
thing is blocked or taking too long to complete
. Start tracing
– adb shell “echo nop > /sys/kernel/debug/tracing/current_tracer“
– adb shell “echo 8192 > sys/kernel/debug/tracing/buffer_size_kb”
– adb shell “echo sched_switch > /sys/kernel/debug/tracing/current_tracer”
– adb shell “echo 1 > /sys/kernel/debug/tracing/tracing_enabled”
. Stop tracing and get the trace data
– adb shell “echo 0 > /sys/kernel/debug/tracing/tracing_enabled”
– adb pull /sys/kernel/debug/tracing/trace .
2012/8/30 Copyright . MediaTek Inc. All rights reserved. 36
修改buffer szie
开始trace
切换为sched_switch tracer
切换为sched_switch tracer
停止traceMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Output Format
.The format
–Context switches:
.Previous task Next Task
.<pid>:<prio>:<state> ==> <pid>:<prio>:<state>
–Wake ups:
.Current task Task waking up
.<pid>:<prio>:<state> + <pid>:<prio>:<state>
.<prio> is the internal kernel priority
–Kernel priority: 0 to 99 => user RT priority 99 to 0
–Kernel priority: 100 to 139 => user nice -20 to 19
–Kernel priority: 140 => idle task priority
.<state>
–R –running : wants to run, may not actually be running
–S –sleep : process is waiting to be woken up (handles signals)
–D -disk sleep (uninterruptible sleep) : process must be woken up
–T –stopped: process suspended
–t -traced : process is being traced (with something like gdb)
–Z –zombie : process waiting to be cleaned up
2012/8/30 Copyright . MediaTek Inc. All rights reserved. 37MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
LogView
2012/8/30 Copyright . MediaTek Inc. All rights reserved. 38
.How do you check the AEE db?
.How do you check the android log?
–UltraEditor、Source Insight、vi、
emacs
.LogView
–android log & kernel log timestamp
sync
.Plug-in Script
–Backtrace decoder script
–Diagnose script
.Key feature
–Drop open AEE DB
.Backtrace decoder
–Drop open mtklog folder
–Drop open mobilelog folder
.View feels like DDMS
.Sync main/events/radio log
.Drop the DB file to GAT
–The offline of GAT will be open
–The DB file will be decrypted automaticMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Drop *.dbg/mtklog/mobilelog
1
2MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
AEE parsing Plug-in
. Running Plug-in after extract DB
– Support jar/exe/bat/py/pyc (Built In Python2.7.2 runtime)
. Installation
– .\gat-win32-2.0\plugin-scripts
. Plug-in command line parameters
– Extracted DB path
– Parser output file path
– Symbol Path (default is “null”)
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Tips
.Auto Integrate
–main_log.1
–Main_log
.Open
–by UltraEdit-32
–Containing Folder
.Text Editor
–Show Line Numbers
–Find as Eclipse
.Support regular exp
–New Editor
.View layout
–Reset layoutMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
GAT FAQ
GAT
GAT FAQ
GAT
–
In fact, any tool has its limitations, so do GAT, there are some cases
which they can not record logs
. GAT抓不到任何log
–
If you use GAT to record log, please kindly remember to click the device
line in “DDMS control” panel, or you will record nothing
.同时使用GAT/mobile log会丢失大部分kernel log
–
do not use MobileLog and GAT(via USB mode) together! Or you will find
logs are divided by the two tools
.
MobileLog and GAT are both get Kernel Log through reading /proc/kmsg, which
is only support one reader
.
GAT说明文档
–和flash tools一起release
–在DCC上搜索:GAT_User_Guide(Customer).docx
.
Ftrace说明文档
–在DCC上搜索:Ftrace_user_guide.pptx
. GAT无法抓取的log
PhonehangCanrecordnothingexcept you use
UART4mode
Boot up Log It begin to record after adb is ready, it
will loose the beginning
Shutdown Log Cannot record all shutdown log
UMS Can record Logs
Click here to select mode: via UART or USB
Copyright . MediaTek Inc. All rights reserved 2012/8/30 42
Catcher
ADB
Relayer
Catcher
L1
PS
Command
Target
Socket
Shared Memory PCMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE Catcher
ADB
Relayer
Catcher
L1
PS
Command
Target
Socket
Shared Memory PCMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE . For USB Logging, you need Catcher
. Select “USB Logging Mode” and then click “Start”
Copyright . MediaTek Inc. All rights reserved
2012/8/30
Connect to PC
.Cather: Enter Logging Mode
.ADB Relayer : Connect to target (auto connect when step 4)
.After connecting to target, users can set filter from Catcher
and see logs shown on Catcher views
1. Enter Logging Mode
2. Set MD Database path
3. Set Connection Mode : Smart Phone Logging
4. Connect, then the ADB Relayer will popup
Database路径
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Copyrigh 45
Generate catcher_filter.bin
. Use Catcher to generate catcher_filter.bin
– Enter logging mode, set DB
– Press “Connect”
– Press “Filter” -> select filter -> Export
– Choose “Export to *.bin”, then click OK.
. Put catcher_filter.bin into sdcard/mtklog/mdlog/catcher_filter.bin
– Adb push
– Please reboot the target if catcher_filter.bin is updated by adb pushMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 46
Open *.dmp file on catcher
.Select the database
–Config->Set Database Path
.Get into the logging mode
–Controls->Mode->Logging
.Open the dump file
–Controls->Open dump FileMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Inc.
Hyper Terminal
. mt6577默认关闭UART console (log太多)
–开机log到xlog启动前还是有uart log,之后才关闭
–开启方法: adb shell aee –k 8
. Step
– Connect the device.s UART4 to PC with UART4
– Open Terminal server (开始>-程序>-附件>-通讯>-超级终
端)
– set correct port and Baud rate as 921600
– get and save log in terminal server
随便取一个名字
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Copyrigh
Log Tool Using Scenarios (1/2)
.Mobile log tool和GAT的使用场合
–从下图可以看到mobile log tool(device)和GAT(PC)抓的是同种
类型的log。简而言之,因为mobile log受到系统的限制无法抓到
一些异常场合的log(如Hang机前一刻,非android环境如factory
mode),这种情况下需要GAT从PC side来补充
–Mobile log tool的特点是运行在手机端,方便使用(按start启动
即可),局限是手机空间有限
–mobile log tool后来又加入了BTlog,GAT不能抓到Btlog
.GAT额外功能
–可以dump mobile log到PC端
–Offline分析log和dbMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Log Tool Using Scenarios (2/2) MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE Log Tool Using Scenarios (2/2) MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE ONLYCharacteristic When to Use
SystemL
og
Mobile Log Tool
(Device.
1.抓取Log类型全面,
AP/Modem/Network Log
均可以使甠
2.直接存储于手机端
(SD Card),不依赖于
PC和Cable,可随时随地使甠
3.Andrdoid系统正常启动时可以正常使甠
4.一般对于SD Card/EMMC有依赖性(若
Log存
储在SD Card/EMMC中.
1.Daily Use
2.Free Test
3.没有PC/Cable可甠
Modem Log Tool
(Device.
Network Log
Tool(Device.
Hyper Terminal(PC.
1。PC端抓取Kernel Log,可以随时抓取
Log
(Power on/off.
BSP类Feature基本均要求提供
GAT(GUI-based Analyzer
Tool)(PC.
1.Log Catch/Debug集于一体,
RD/QA均可使甠
2.风格与DDMS一致,便于掌揑
3.Exception DB Pull/Location功能整后
4.PC端工具,USB/Uart连接
1.进行专项测试
2.可用PC/Cable
3.Catch Exception Info and
Pull
4.边抓Log边分析
5.也可以连接UART4抓取kernel
log(同Hyper Terminal)
Catcher Tool(PC.
1.工具更稳定,经过长时间使用验证
2.针对Modem抓取Log
3.设置Filter方便
4.UART/USB均可用
连接PC进行Modem相关测试
2012/8/30 Copyright . MediaTek Inc. All rights reserved 50
Outline
.MTK Log Overview
.MTK logging tool
–Target side
.Mobilelog logger
.Modemlog logger
.Network Diagnose Tool
–PC side
.GAT
–GDB
–Ftrace
.Cachter
.Hyper terminal tool
.抓取eService Log
.NE
–Gnu toolchainMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
抓取eService Log (1/3)
.
验证前请注意保存对应的out/target/product/$project/symbols目录和
kernel/out/vmlinux,因为这两个是NE(native exception)/KE(kernel
panic)需要的东西
.
开启log
–开启Mobile Log
.开启前先清除老的log, 将最大空间设置为
300M 或者更大, 设置成开机自启动
–如果是测试电话与数据服务相关问题,请打开
Modem log以及Network Log
.
开启前先清除老的log
.
复现操作
–发现问题!!!
.
死机重启, 进程无响应(ANR), 进程意外停止, 不能打电话, 花屏, hang 机,机器卡住,
其他问题
–
问题记录要点
.
记录操作的过程/手法, 出现问题的时间, 地点, 清楚的描述问题场景,能够截图就截
图, 如果问题难于描述,请录制视频
.
尝试多次再次复现,看是否是必现, 如果不是, 记录测试的次数, 复现的次数
.
关闭log: 按照前面的开启的log的方式分别进入对应的界面关闭log
.
抓取log和关键数据
–
GAT bug report按钮抓取
(必须能连adb)
–
将右边图片的文字保存成MTK_PULL_ALL.bat,然后双击抓取
(必须能连
adb)
清除老的log,开启log
用户操作复现问题并记录
停止log
抓取log和关键数据
Copyright . MediaTek Inc. All rights reserved 2012/8/30 51
2012/8/30 Copyright . MediaTek Inc. All rights reserved 52
抓取eService Log (2/3)
.特殊情况
–T卡不存在或无挂载(此时mobile log/modem log/network log无法正常工作)
.GAT抓取log (必须能连adb)
.UART4链接, 然后输入logcat -v time 来抓取log (进行USB插拔操作)
.发现问题之后,把抓到的log,以及MTK_PULL_ALL.bat 抓出数据一同提交
–Hang机问题
.确认Hang机类型
–通过usb/uart4连接手机,如果有拉出uart4最好是uart4
.Uart4: ps
.USB: adb shell ps
–如果Uart4 有log吐出,则kernel正常,如果uart4/usb都能进行命令操作,即上层屏幕hang住,
否则就是整个系统hang 住
.上层Hang住
–是首先dump出系统的状态
.adb shell dumpsys > dumpsys.txt
.adb shell dumpstate > dumpstate.txt
–然后使用MTK_PULL_ALL.bat抓出数据后一同提交
–最重要一点,插入USB,保留好现场,插入USB是为手机继续通电,没电了就不能保留现场
.底层Hang住(77有external WDT,所以不会出现hang死)
–提交当时UART4抓到的log,如果没有抓到,那么请在Hang住3分钟之后拔掉电池重启(可能
log还在记录),然后使用UART4 + main log的方式再次复现
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 53
抓取eService Log (3/3)
. Modem异常(发生了EE)
–需要额外附上的log
. Modem log (一定要附上)
– Catcher log & Modem database
. Ex: MDLog_PS_2012_0106_231841.dmp
.放在sdcard下的mtklog/mdlog目录里
. Ex: BPLGUInfoCustomAppSrcP_xxxx
.一般放在mediatek/custom/common/modem/$modem目录下(其中$modem值为ProjectConfig.mk
里的CUSTOM_MODEM)
– Memory dump bin & Modem ELF
. Ex: Memory_PS_2012_0106_232402.bin
. Ex: xxx13_TD_PCB01_tdd128hspa_MT6573_S01.elf
.在modem代码包里的build/xxx/目录下
.必须和modem.img是同时编译生成的
. Mobile(AP) log
– Kernel log (Needed)
– AEE db.xx log (Needed if without Kernel log)
– Remainder
. If you don.t know how to get modem ELF file, please refer to the latest
MP_ReleaseNote_xxx.xls(build_configure_modem) which can be got from
your S/W manager
这个就是database
这个必须和modem代码包里
的build目录下的ELF是同一次
编译生成的,建议将ELF一起
复制到此目录以备分析问题用
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 54
Provide Log when exception
①When do testing, suggest to attach the Video for issues which repeat ratio is Always/above 50%; Seldom/below
50% issues, strongly suggest to attach videos if you can
②When find a issue using multimedia file or application/tool, please make sure the related test material is
attached
③Modem/RIL related: Telephony features, e.g. GPRS, Call, SIM…/ Interrupt or concurrency with these featuresMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 55
Outline
.MTK Log Overview
.MTK logging tool
–Target side
.Mobilelog logger
.Modemlog logger
.Network Diagnose Tool
–PC side
.GAT
–GDB
–Ftrace
.Cachter
.Hyper terminal tool
.抓取eService Log
.NE
–Gnu toolchainMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 56
Gnu toolchain
.了解和使用gnu toolchain可以在debug时更加方便
.工具目录:prebuilt/linux-x86/toolchain/arm-linux-
androideabi-4.4.x/bin
–Just for arm
.可以将目录添加到环境变量中
–可以在任何地方使用工具MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 57
addr2line (1/2)
.arm-linux-androideabi-addr2line [option(s)] [addr(s)]
–将地址转换为地址所在的文件及行数(显示所在函数)
–参数(常用)
.-e –exe=<executable>: 设置要查询地址的文件(默认: a.out)
–一般是*.so/*.a和可执行程序
–此文件必须带有debug信息,在android codebase里是放在
out/target/product/$project/symbols目录下
.-f –functions:显示地址所在的函数名
.-C –demangle[=style]:反重整函数名为可读方式
–自动识别格式
–C++函数才需要此参数
.-h –help
–例子
.1
.2
.3
经过重整的函
数名很难读懂
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 ediaTek Inc. rights reserved
addr2line (2/2)
.arm-linux-androideabi-addr2line [option(s)] [addr(s)]
–什么情况下需要用到?
.应用程序发生死机(NE)后,会生成tombstones/tombstones_xx文件
或aee_exp里的db解开之后的__exp_main.txt,里面有backtrace信
息,就可以通过addr2line分析出哪个文件哪行哪个函数(注意用-e
载入的文件必须和手机的bin档同一次编译生成,否则地址和符号可
能不一致)
.也不一定非得用addr2line,也可以用trace32,或objdump -S
$name > xx.txt来分析(objdump后面会介绍)
1.点击这里
2.选择CPU:
75:A9,77:A9MPcore
3.选择up
4.点击这
里加载so
或程序
5.点击这里
6.填入地址
7. 点击这里
8. 状态栏可以看到哪个函数
9. 蓝色的数字表示在文件的哪一行
说明这个地址所在
的文件是test.c第8
行,所在函数是
bbbbbMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Copyright . MediaTek Inc. All
objdump
.arm-linux-androideabi-objdump.exe <option(s)> <file(s)>
–查看对象文件(*.so/*.a或应用程序)的内容信息
–参数(常用)
.至少需要一个以下的参数
–-a, –archive-headers:显示库(*.a)成员信息
–-f, –file-headers:显示obj中每个文件的整体头部摘要信息
–-h, –[section-]headers:显示目标文件各个section的头部摘要信息
–-x, –all-headers:显示所有头部摘要信息
–-d, –disassemble:反汇编代码段
–-D, –disassemble-all: 反汇编所有段
–-S, –source:反汇编出源代码,额外有debug信息,隐含-d,如果编译时有-g,效果更明显
–-t, –syms: 显示符号表
–-r, –reloc: 显示重定位记录
.-C, –demangle[=STYLE]反重整符号为可读方式
–自动识别格式
.-H, –help
–例子
–什么情况下需要用到?
.当发生NE后,拿到backtrace查看对应地址的汇编代码
地址
指令
对应的代码
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 60
c++filt
.arm-linux-androideabi-c++filt.exe <function name>
–反重整C++符号为可读方式
–参数(常用)
.-h, –help
–例子
–什么情况下需要用到?
.通过GAT解开db后(输入symbols目录),如果是NE的话,可以查看
解开的C++的对应的symbols是否和c++filt的一样,不一样则
symbols目录和手机bin档不匹配
以下函数和c++filt不匹配
MEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
2012/8/30 Copyright . MediaTek Inc. All rights reserved 61
Reference
.eCourse (http://online.mediatek.com)
–请看Android _Debug_Basic视频
.文档(请到DCC上搜索)
–Logging_SOP_customer_MT6577.pptx
–SmartPhone MobileLog user manual.docx
–SmartPhone ModemLog user manual.ppt
–Debugger_User Guide_MT6577_4.0.docx
–System_Debugging_Customer_MT6577_4.0.docx
–GAT_User_Guide(Customer).docx
–Ftrace_user_guide.pptx
–Catcher user manual
.FAQ (http://online.mediatek.com)
–请看SW/ALPS/下的System-Debugger,Debugging和Framework-
Tool&DebugMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE
Copyright . MediaTek Inc. All rights reserved.
www.mediatek.comMEDIATEK CONFIDENTIALFOR yuqing.zhang@ ck-telecom.com USE