???traceview??dmtracedump????Android????
???????????? ???????[ 2013/3/7 11:06:54 ] ????????
?????traceview??dmtracedump????Android????
??✿Android ??????????
????Google???????????????????????traceview ?? dmtracedump ??????????????????????????????bug?????????????traceview????????????????????dmtracedump??????????????????????google????dmtracedump????????????????????????????????????????????????
????✿????.trace???
????android.os.Debug???????????????????Debug.startMethodTracing()??Debug.stopMethodTracing()????????????????????.trace?????????Debug.startMethodTracing()???????Debug.stopMethodTracing()????????????е???ù????????.trace????У????????????????????е??????????
???????????????????????????????λ????????λ?á?
????Debug.startMethodTracing(“test”);
????Debug.stopMethodTracing();
????Debug.startMethodTracing(“test”);
????Debug.stopMethodTracing();
???????в???test?????????trace??????????test.trace?????·????/sdcard/test.trace?????????????/data/log/test??????????/data/log/test.trace??
????✿traceview
??????SDK????? ??
????./traceview test.trace
?????????????
????1.??????????????÷???????????????
????2.??????е??????Ч?????
????✿dmtracedump
????dmtracedump???????????????????ù??????????????????????????????????????????google????????????broken??????????????????????dmtracdump???-o??????????????????г????????????????traceview???????????????./dmtracedump –g test.png test.trace?????????
??????????????test.trace???????????????????????????????????????????????
??????????????????????????????dmtracedump????????????python?????????dot????????????python??????????????????????????????????????
????view plaincopy to clipboardprint?
????#!/usr/bin/env python
????"""
????turn the traceview data into a jpg pic?? showing methods call relationship
????"""
????import sys
????import os
????import struct
????import re
????###################################################
????######################## Global Variable ##########
????###################################################
????target_thread=1 #the thread that we want to track?? filt out other threads
????#all_actions = ["enter"??"exit"??"exception"??"reserved"]
????all_threads = {}
????all_methods = {}
????all_records = []
????parent_methods = {}
????child_methods = {}
????method_calls = {}
????#####################################################
????############################## Methods ##############
????#####################################################
????def add_one_thread(line):
????fields = line.split("/t")
????all_threads[int(fields[0]??10)]=fields
????def add_one_method(line):
????fields = line.split("/t")
????all_methods[int(fields[0]??16)]=fields
????def add_one_record(one):
????thread_id??=struct.unpack("B"??one[:1])
????if (thread_id == target_thread):
????tmp??=struct.unpack("L"??one[1:5])
????method_id= (tmp / 4) * 4;
????method_action= tmp % 4;
????time_offset??=struct.unpack("L"??one[5:])
????all_records.append([thread_id?? method_id?? method_action?? time_offset])
????def handle_one_call(parent_method_id??method_id):
????if not (parent_methods.has_key(parent_method_id)):
????parent_methods[parent_method_id]=1
????if not (child_methods.has_key(method_id)):
????child_methods[method_id]=1
????if method_calls.has_key(parent_method_id):
????if method_calls[parent_method_id].has_key(method_id):
????method_calls[parent_method_id][method_id]+=1
????else:
????method_calls[parent_method_id][method_id]=1
????else:
????method_calls[parent_method_id]={}
????method_calls[parent_method_id][method_id]=1
????def gen_funcname(method_id):
????r1=re.compile(r'[/{1}lt;>]')
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11