ramdump 是什么?简单来说就是把系统memory中的某一个时间点的的数据信息通过一定手段取出来保存起来的内存崩溃文件,属于ELF文件格式。
当系统发生致命错误无法恢复的时候,主动触发抓取ramdump把异常现场保留下来供离线分析定位问题是一种非常重要的高级调试手段。
高通的ramdump触发后可以连USB通过PC工具拉出来,都是一堆binary文件,需要使用特定的脚本工具进一步解析后才可以使用工具调试,如下简单描述如何使用脚本工具解析出 ramdump:
1、将下面的脚本内容保存到: ~/work/script/ramdump-parser.sh,
修改~/.bashrc,并添加到环境变量:export PATH=~/work/script/:$PATH
# ramdump-parser.sh
#! /bin/bash
echo ""
echo "Start ramdump parser.."
local_path=$PWD
ramdump=$local_path/
vmlinux=$local_path/vmlinux
out=$local_path/out
gdb=~/tools/gnu-tools/aarch64-linux-android-4.9/bin/aarch64-linux-android-gdb
nm=~/tools/gnu-tools/aarch64-linux-android-4.9/bin/aarch64-linux-android-nm
objdump=~/tools/gnu-tools/aarch64-linux-android-4.9/bin/aarch64-linux-android-objdump
# git clone git://codeaurora.org/quic/la/platform/vendor/qcom-opensource/tools
ramparse_dir=~/tools/ramdump/tools/linux-ramdump-parser-v2
########################################################################################
echo "cd $ramparse_dir"
cd $ramparse_dir
echo ""
echo -e "python ramparse.py -v $vmlinux -g $gdb -n $nm -j $objdump -a $ramdump -o $out -x"
echo ""
# python 2.7.5
python ramparse.py -v $vmlinux -g $gdb -n $nm -j $objdump -a $ramdump -o $out -x
cd $local_path
echo "out: $out"
echo ""
exit 0
2、从下面的地址取下高通解析工具:
android@ubuntu:~/tools/ramdump$ git clone git://codeaurora.org/quic/la/platform/vendor/qcom-opensource/tools
正克隆到 'tools'...
remote: Counting objects: 4698, done.
remote: Compressing objects: 100% (47/47), done.
remote: Total 4698 (delta 25), reused 0 (delta 0)
接收对象中: 100% (4698/4698), 753.66 KiB | 116.00 KiB/s, done.
处理 delta 中: 100% (3452/3452), done.
检查连接... 完成。
3、将gdb,nm,objdump和ramdump解析工具放到下面路径中,需要区分32/64位.
gdb=~/tools/gnu-tools/aarch64-linux-android-4.9/bin/aarch64-linux-android-gdb
nm=~/tools/gnu-tools/aarch64-linux-android-4.9/bin/aarch64-linux-android-nm
objdump=~/tools/gnu-tools/aarch64-linux-android-4.9/bin/aarch64-linux-android-objdump
ramparse_dir=~/tools/ramdump/tools/linux-ramdump-parser-v2
4、拿到ramdump+vmulinux,放到任意同一个目录中:
android@ubuntu:~/tmp/Port_COM6$ find ./ -iname "*"
./
./PMIC_RTC.BIN
./RST_STAT.BIN
./load.cmm
./DATARAM.BIN
./DDR_DATA.BIN
./PMIC_PON.BIN
./DDRCS0.BIN
./OCIMEM.BIN
./vmlinux
./CODERAM.BIN
./DDRCS1.BIN
./dump_info.txt
./MSGRAM.BIN
5、执行解析(需要python2.7.5):
android@ubuntu:~/tmp/Port_COM6$ ramdump-parser.sh
Start ramdump parser..
cd /home/android/tools/ramdump/tools/linux-ramdump-parser-v2
python ramparse.py -v /home/android/tmp/Port_COM6/vmlinux -g /home/android/tools/gnu-tools/aarch64-linux-android-4.9/bin/aarch64-linux-android-gdb -n /home/android/tools/gnu-tools/aarch64-linux-android-4.9/bin/aarch64-linux-android-nm -j /home/android/tools/gnu-tools/aarch64-linux-android-4.9/bin/aarch64-linux-android-objdump -a /home/android/tmp/Port_COM6/ -o /home/android/tmp/Port_COM6/out -x
!!! Out directory does not exist. Creating...
[1/32] --clock-dump ... 0.873911s
[2/32] --cpr3-info ... 0.135361s
[3/32] --cpr-info ... 1.103903s
[4/32] --cpu-state ... 0.098867s
[5/32] --ddr-compare ... 3.923111s
[6/32] --check-for-watchdog ... 0.011697s
[7/32] --parse-debug-image ...
...
等待约5-10分钟后解析完成,结果输出在 ${当前目录}/out中.
ls out/
arm_iommu_domain_00.txt dcc_regs.txt msm_iommu_domain_14.txt msm_rtb4.txt t32_startup_script.cmm
arm_iommu_domain_01.txt DDRCacheCompare.txt msm_iommu_domain_15.txt msm_rtb5.txt tasks_sched_stats0.txt
arm_iommu_domain_02.txt dmesg_TZ.txt msm_iommu_domain_16.txt msm_rtb6.txt tasks_sched_stats1.txt
arm_iommu_domain_03.txt kconfig.txt msm_iommu_domain_17.txt msm_rtb7.txt tasks_sched_stats2.txt
arm_iommu_domain_04.txt launch_t32.sh msm_iommu_domain_18.txt page_corruption_summary.txt tasks_sched_stats3.txt
arm_iommu_domain_05.txt lpm.txt msm_iommu_domain_19.txt page_frequency.txt tasks_sched_stats4.txt
arm_iommu_domain_06.txt memory.txt msm_iommu_domain_20.txt page_ranges.txt tasks_sched_stats5.txt
arm_iommu_domain_07.txt mem_stat.txt msm_iommu_domain_21.txt page_tables.txt tasks_sched_stats6.txt
arm_iommu_domain_08.txt MSM_DUMP_DATA_L1_DATA_CACHE_0x0 msm_iommu_domain_22.txt page_tracking.txt tasks_sched_stats7.txt
ClockDumps.txt MSM_DUMP_DATA_L1_DATA_CACHE_0x1 msm_iommu_domain_23.txt regs_panic.cmm tasks.txt
core0_regs.cmm MSM_DUMP_DATA_L1_DATA_CACHE_0x2 msm_iommu_domain_24.txt roareadiff.txt thermal_info.txt
core1_regs.cmm MSM_DUMP_DATA_L1_DATA_CACHE_0x3 msm_iommu_domain_25.txt secure_world_core0_regs.cmm timerlist.txt
core2_regs.cmm MSM_DUMP_DATA_L1_DATA_CACHE_0x4 msm_iommu_domain_26.txt secure_world_core1_regs.cmm tmc-etf.bin
core3_regs.cmm MSM_DUMP_DATA_L1_DATA_CACHE_0x6 msm_iommu_domain_27.txt secure_world_core2_regs.cmm tmc_etf.txt
core4_regs.cmm msm_iommu_domain_09.txt msm_iommu_domain_28.txt secure_world_core3_regs.cmm tmc-etr.bin
core6_regs.cmm msm_iommu_domain_10.txt msm_rtb0.txt secure_world_core4_regs.cmm tmc_etr.txt
cpr3_info.txt msm_iommu_domain_11.txt msm_rtb1.txt secure_world_core6_regs.cmm vmalloc.txt
cprinfo.txt msm_iommu_domain_12.txt msm_rtb2.txt spm.txt
dbgui.txt msm_iommu_domain_13.txt msm_rtb3.txt t32_config.t32
可以看到,里面内容很丰富.