android 系统启动过程中加入tcpdump和logcat

一、android 系统启动过程中加入tcpdump ,分析开机启动后,系统与服务器端的消息交互。


1. init.rc 中的修改
1)在init.rc 中加上tcpdump service.


service tcpdump /system/xbin/tcpdump -s 0 -w/data/test/test_1.pcap
    class core
    
2)在init.rc 中启动tcpdump service
start tcpdump




/*
service:service <name> <parthname> [ <argument> ]*。pathname代表启动service时用到的命令。
其实就是要执行tcpdump -s 0 -w/data/test/test_1.pcap 命令


 -w file
-s     Snarf snaplen bytes of data from each packet rather than the default  of
              65535  bytes.Setting snaplen to 0 sets it to the  default  of  65535
*/    


2.制作新的boot.img.   boot.img包含 kernel和randisk
cd android/out/target/product/vender/
mkbootfs root | minigzip > ramdisk.img

mkbootimg --kernel kernel --ramdisk ramdisk.img --output boot.img




二、在系统启动中加入logcat debug
------------------------------------------------------------------------------------------------------------
1.在/system/bin目录下添加执行logcat的脚本
   mount -o remount,rw /system
   echo "logcat -v time > /data/system_boot.log" > /system/bin/logcat.sh




2.在init.rc中添加执行logcat.sh的启动命令
   vi init.rc,把下面的语句放到最后,放在前面会有问题


    service logcat  /system/bin/sh /system/bin/logcat.sh
    class core


    start logcat


3.重新编译boot.img,并升级
cd android/out/target/product/vender/
mkbootfs root | minigzip > ramdisk.img
mkbootimg --kernel kernel --ramdisk ramdisk.img --output boot.img




4.系统启动后,会将所有的log保持在/data/system_boot.log中

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值