1、 PID 进程ID(Process ID) PPID 父进程的进程ID(Parent Process id) VSZ 进程所使用的虚拟内存的大小(Virtual Size) RSS 进程使用的驻留集大小或者是实际内存的大小,Kbytes字节。 WCHAN 进程正在睡眠的内核函数名称;该函数的名称是从/root/system.map文件中获得的Exploring ProcessesYou can see the output of ps -x for a specific VM by selecting Device Show process status. in the menu bar.2、
2、 Dump device state菜单等效于执行 /system/bin/dumpstate /proc/self/fd/0等效于执行adb shell dumpstate命令To run dumpstate from Dalvik, select Device Dump device state. in the menu bar.3、 Dump app state菜单等效于执行adb shell dumpsys命令输出android服务状态信息,即输出服务中dump函数的log.4、 Dump radio state菜单等效于执行adb shell cat /data/logs/radio
3、命令 Examine Radio StateBy default, radio state is not output during a standard logcat (it is a lot of information). To see radio information, either click Device Dump radio state. or run logcat as described in Logging Radio Information. 5、 Run logcat菜单等效于执行adb logcat To run dumpsys (logcat) from Dalv
4、ik, select Device Run logcat. in the menu bar.总结:除了Run logcat菜单是实时输出设备中的log外,其他菜单都是输出设备中缓存的log三 Adb LogAndroid sdk文档中对adb的介绍见下:02 Android01_SDKGingerbread2.3docs-2.3_r01-linuxguidedevelopingtoolsadb.html在adb 1.0.26版本共有2条命令打印log,如下:adb logcat - View device logadb bugreport - return all information fr
5、om the device that should be included in a bug report.Adb logcat常用命令logcat -c 清除已有log信息logcat -b main 显示主缓冲区的loglogcat -b radio 显示无线缓冲区的loglogcat -b events 显示事件缓冲区的loglogcat -f filename 将log保存到指定的文件中,例如 logcat -b radio -f /data/radio.log比较常用的是显示时间:logcat -v time &logcat -g 查看缓冲区的大小logcat -g mainlogc
6、at -g radiologcat -g eventslogcat打印/dev/log设备下的三个文件 radio, events, main数据logcat默认是输出main缓冲区的log控制日志输出格式日志信息包括了许多元数据域包括标签和优先级。可以修改日志的输出格式,所以可以显示出特定的元数据域。可以通过 -v 选项得到格式化输出日志的相关信息.brief Display priority/tag and PID of originating process (the default format).process Display PID only.tag Display the pri
7、ority/tag only.thread Display process:thread and priority/tag only.raw Display the raw log message, with no other metadata fields.time Display the date, invocation time, priority/tag, and PID of the originating process.long Display all metadata fields and separate messages with a blank lines.当启动了log
8、cat ,你可以通过-v 选项来指定输出格式:adb logcat -v 此外,adb shell cmd, cmd为/system/bin目录下抓log的可执行程序,如dumpsys , dumpstate等Adb下的log命令:Adb logcatAdb bugreportAdb shell dumpsysAdb shell dumpstateAdb shell dmesg /导出当前缓存的kernel logAdb shell kmsgcat /实时查看kernel log其他查看系统当前信息命令Adb shell ps /查看系统进程信息,可以加很多有用信息Adb shell pm /
9、查看package相关信息Adb shell am /启动apk应用Adb shell setprop /设置系统属性Adb shell getprop /查看所有系统属性Adb shell rebootAdb shell kill /通过进程ID杀死指定的进程Adb shell top /查看当前运行进程信息Adb shell vmstat /查看虚拟机信息Adb shell bootanimation /播放开机动画Adb shell df /查看分区信息Adb shell monkey /跑自动化测试用例四 保存在手机的Log1、手机dropbox默认路径:/data/system/dr
10、opbox/ 实现机制:log文件什么场景产生?Log文件分析:2、手机anr日志默认路径:/data/anr/ 4、tombstones路径:/data/tombstones五 如何实现后台抓Log如:adb logcat -v time -r 1024 -n 16 -f /sdcard/bugreports/applogcat-log六 log执行程序实现机制1、LogcatLogCat是在文件system/core/logcat/logcat.cpp中实现的。从Logger设备驱动的实现知道,Log的读取是阻塞的操作,亦即,有数据可用,读出数据;否则,读操作会被BLOCK,相应的读进程也
11、会被挂起等待。下面看应用程序LogCat中如何实现读的,这可能需要不断回头与写操作和驱动实现结合来看。看具体实现之前,先看一个logcat中定义的重要的结构体log_device_t。其中的重要的成员在后面用到的时候再具体解释。 Android的Logcat命令详解的命令参数-b 知道,logcat是可以通过参数来指定对哪个buffer(main/radio/event)进行操作的。Logcat的b参数解析的地方,是通过传递进来的参数(main/radio/event)来创建了一个上面的结构变量,而这些结构通过log_device_t.next链接起来因为logcat可能会同时操作多个Buff
12、er,而read()会阻塞读取进程,对其他Buffer的读取就不能进行,所以这里用select()来判断可读取的Buffer。2、BugreportI:00_AndriodSourceandroid-gingerbread-srcframeworksbasecmdsbugreport#include cutils/sockets.hint main(int argc, char *argv) char buffer65536; int i, s; /* start the dumpstate service */ property_set(ctl.start, dumpstate);/启动du
13、mpstate服务 /* socket will not be available until service starts */ for (i = 0; i = 0) break; /* try again in 1 second */ sleep(1); if (s 0) fprintf(stderr, Failed to connect to dumpstate servicen exit(1); while (1) int length = read(s, buffer, sizeof(buffer); if (length 1) / first print a list of the
14、 current services aout Currently running services: endl; for (size_t i=0; iN; sp service = sm-checkService(servicesi); if (service != NULL) servicesi dump(STDOUT_FILENO, args);/调用每个service中的dump()方法输出log if (err != 0) aerr &LEVEL * Where level is either VERBOSE, DEBUG, INFO, WARN, ERROR, ASSERT, or
15、SUPPRESS. SUPRESS will * turn off all logging for your tag. You can also create a local.prop file that with the * following in it:log.tag.&=& * and place that in /data/local.prop. * param tag The tag to check. * param level The level to check. * return Whether or not that this is allowed to be logge
16、d. * throws IllegalArgumentException is thrown if the tag.length() 23. */public static native boolean isLoggable(String tag, int level);1. 查看当前堆栈1) 功能:在程序中加入代码,使可以在logcat中看到打印出的当前函数调用关系2) 方法: new Exception(“print trace”).printStackTrace();2. MethodTracing用于热点分析和性能优化,分析每个函数占用的CPU时间,调用次数,函数调用关系等a) 在程序
17、代码中加入追踪开关import android.os.Debug; android.os.Debug.startMethodTracing(“/data/tmp/test”); / 先建/data/tmp目录 / 被追踪的程序段 android.os.Debug.stopMethodTracing();b) 编译,运行后,设备端生成/data/tmp/test.trace文件c) 把trace文件复制到PC端$ adb pull /data/tmp/test.trace ./ d) 使用android自带工具分析trace文件$ $ANDROID_SRC/out/host/linux-x86/bin/traceview test.trace 此时可看到各个函数被调用的次数CPU占用率等信息e) 使用android自带工具分析生成调用关系类图$ apt-get install graphviz # 安装图片相关软件 $ANDROID_SRC/out/host/linux-x86/bin/dmtracedump -g test.png test.trace 此时目录下生成类图test.png3) 注意 trace文件生成与libdvm模块DEBUG版本相冲突,所以此方法只适用于对非DEBUG版本模拟器的调试,否则在分析trace文件时会报错3. HProf (Heap
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1