Skip to content

zhangkn/AppleTrace

 
 

Repository files navigation

AppleTrace

Trace tool for iOS/macOS

AppleTrace is developed for analyzing app's performance on iOS/macOS.

logo

Let's talk in Gitter 或者页面最下方的微信群

appletrace

Feature

  1. User-defined trace section.
  2. [arm64 under debugger only] Trace all Objective C methods.

FAQ

Go to Wiki

Clone

git clone --recursive https://github.com/everettjf/AppleTrace.git

or

git clone git@github.com:everettjf/AppleTrace.git
cd AppleTrace
git submodule update --init --recursive

For stable release , please refer to Releases

Usage

  1. Produce trace data.
  2. Copy from app's sandbox directory.
  3. Merge (all) trace data files into one file trace.json. (There may be more than 1 trace file.)
  4. Generate trace.html based on trace.json.

See below for more detail.

1. Produce

Until now , there are 2 ways for generating trace data.

(1) Manual set section.

Call APTBeginSection at the beginning of method ,and APTEndSection at the end of method. For Objective C method (whether instance method or class method), there are APTBegin and APTEnd macro for easy coding.

void anyKindsOfMethod{
    APTBeginSection("process");
    // some code
    APTEndSection("process");
}

- (void)anyObjectiveCMethod{
    APTBegin;
    // some code
    APTEnd;
}

Sample app is sample/ManualSectionDemo.

(2) Dynamic library hooking all objc_msgSend.

Hooking all objc_msgSend methods (based on HookZz). This only support arm64 under debugger ( lldb).

Sample app is sample/TraceAllMsgDemo.

2. Copy

Using any kinds of method, copy <app's sandbox>/Library/appletracedata out of Simulator/RealDevice.

appletracedata

3. Merge

Merge/Preprocess the appletracedata.

python merge.py -d <appletracedata directory>

This will produce trace.json in appletracedata directory.

4. Generate

Generate trace.html using catapult.

python catapult/tracing/bin/trace2html appletracedata/trace.json --output=appletracedata/trace.html

open trace.html

trace.html only support Chrome

SampleData

Open sampledata/trace.html using Chrome.

Dependencies

  1. catapult
  2. HookZz

Develop Plan

  1. dtrace as data source.
  2. frida-trace as data source.
  3. llvm clang plugin for injecting code.

Group

  1. Gitter
  2. 微信群(若过期请先加微信 everettjf ,备注AppleTrace)

wechatgroup

About

Objective C message tracing tool for iOS/macOS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C++ 34.0%
  • Objective-C 30.8%
  • C 20.4%
  • Python 6.6%
  • Logos 4.3%
  • Shell 3.9%