欢迎来到冰豆网! | 帮助中心 分享价值,成长自我!
冰豆网
全部分类
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • 党团工作>
  • ImageVerifierCode 换一换
    首页 冰豆网 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    5AndroidLog大全.docx

    • 资源ID:23716173       资源大小:23KB        全文页数:17页
    • 资源格式: DOCX        下载积分:10金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要10金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    5AndroidLog大全.docx

    1、5AndroidLog大全Android log系统 Android 系统log抓取,实现原理分析一概述本文档主要是供Android开发人员使用,特别是Framework开发。因为Framework中95%以上的问题都是靠分析log解决的,所以开发人员必须对android整个log系统十分清楚。什么问题抓什么log, 使用什么工具抓Log,如何分析log,如何在代码中添加log.二DDMS log关于ddms是如何工作的和ddms的详细功能,见下面android sdk中文档详细介绍:F:02 Android01_SDKGingerbread2.3docs-2.3_r01-linuxguide

    2、developingtoolsddms.htmlDdms 工具中打印log的几个菜单如下:Device - Show process statusDevice - Dump device stateDevice - Dump app stateDevice - Dump radio stateDevice - Run logcat1、 Show process status菜单等效于在adb shell下执行adb shell ps x 命令,该命令打印出进程的详细信息,如下:USER PID PPID VSIZE RSS WCHAN PC NAMEroot 1 0 268 180 c009b

    3、74c 0000875c S /init (u:2, s:371)root 2 0 0 0 c004e72c 00000000 S kthreadd (u:0, s:1)root 3 2 0 0 c003fdc8 00000000 S ksoftirqd/0 (u:0, s:0)root 4 2 0 0 c004b2c4 00000000 S events/0 (u:0, s:39)root 5 2 0 0 c004b2c4 00000000 S khelper (u:0, s:0)root 6 2 0 0 c004b2c4 00000000 S suspend (u:0, s:0)USER

    4、用户名,即用户所在组 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 DeviceShow process status. in the me

    5、nu bar.2、 Dump device state菜单等效于执行 /system/bin/dumpstate /proc/self/fd/0等效于执行adb shell dumpstate命令To run dumpstate from Dalvik, select DeviceDump device state. in the menu bar.3、 Dump app state菜单等效于执行adb shell dumpsys命令输出android服务状态信息,即输出服务中dump函数的log.4、 Dump radiostate菜单等效于执行adb shell cat /data/log

    6、s/radio命令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 DeviceDump radio state. or run logcat as described in Logging Radio Information. 5、 Run logcat菜单等效于执行adb logcat To run dumpsys (logcat) from

    7、 Dalvik, select DeviceRun logcat. in the menu bar.总结:除了Run logcat菜单是实时输出设备中的log外,其他菜单都是输出设备中缓存的log三 Adb LogAndroid sdk文档中对adb的介绍见下:F:02 Android01_SDKGingerbread2.3docs-2.3_r01-linuxguidedevelopingtoolsadb.html在adb 1.0.26版本共有2条命令打印log,如下:adb logcat - View device logadb bugreport - return all informat

    8、ion from 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 ma

    9、inlogcat -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 t

    10、he priority/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.当

    11、启动了logcat ,你可以通过-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 shel

    12、l pm /查看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/syst

    13、em/dropbox/实现机制:log文件什么场景产生?Log文件分析:2、手机anr日志默认路径:/data/anr/实现机制:log文件什么场景产生?Log文件分析: 4、tombstones路径:/data/tombstoneslog文件什么场景产生? Log文件分析: 五如何实现后台抓Log如:adb logcat -v time -r 1024 -n 16 -f /sdcard/bugreports/applogcat-log六 log执行程序实现机制1、LogcatLogCat是在文件system/core/logcat/logcat.cpp中实现的。从Logger设备驱动的实现知

    14、道,Log的读取是阻塞的操作,亦即,有数据可用,读出数据;否则,读操作会被BLOCK,相应的读进程也会被挂起等待。下面看应用程序LogCat中如何实现读的,这可能需要不断回头与写操作和驱动实现结合来看。看具体实现之前,先看一个logcat中定义的重要的结构体log_device_t。其中的重要的成员在后面用到的时候再具体解释。Android的Logcat命令详解的命令参数-b 知道,logcat是可以通过参数来指定对哪个buffer(main/radio/event)进行操作的。Logcat的b参数解析的地方,是通过传递进来的参数(main/radio/event)来创建了一个上面的结构变量,

    15、而这些结构通过log_device_t.next链接起来因为logcat可能会同时操作多个Buffer,而read()会阻塞读取进程,对其他Buffer的读取就不能进行,所以这里用select()来判断可读取的Buffer。2、BugreportI:00_AndriodSourceandroid-gingerbread-srcframeworksbasecmdsbugreport#include #include int main(int argc, char *argv) char buffer65536; int i, s; /* start the dumpstate service *

    16、/ property_set(ctl.start, dumpstate);/启动dumpstate服务 /* 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

    17、); if (length 1) / first print a list of the current services aout Currently running services: endl; for (size_t i=0; iN; i+) sp service = sm-checkService(servicesi); if (service != NULL) aout servicesi endl; for (size_t i=0; iN; i+) sp service = sm-checkService(servicesi); if (service != NULL) if (

    18、N 1) aout - - endl; aout DUMP OF SERVICE servicesi : dump(STDOUT_FILENO, args);/调用每个service中的dump()方法输出log if (err != 0) aerr Error dumping service info: ( strerror(err) ) servicesi endl; else aerr Cant find service: servicesi <LEVEL * Where level is either VERBOSE, DEBUG, INFO, WARN, ERROR, ASSE

    19、RT, or 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.<YOUR_LOG_TAG=<LEVEL * and place that in /data/local.prop. * * param tag The tag to check. * param level The level to check. * return Whether or n

    20、ot that this is allowed to be logged. * 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. MethodTracing1) 功能:用于热点

    21、分析和性能优化,分析每个函数占用的CPU时间,调用次数,函数调用关系等2) 方法:a) 在程序代码中加入追踪开关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) 使用androi

    22、d自带工具分析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 Profile)1) 功能:用于java层面的内存分析,显示详细的内存占用信息,指出可疑的内存泄漏对象


    注意事项

    本文(5AndroidLog大全.docx)为本站会员主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2022 冰点文档网站版权所有

    经营许可证编号:鄂ICP备2022015515号-1

    收起
    展开