GithubHelp home page GithubHelp logo

923310233 / apptrace Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chenzhengxu/apptrace

0.0 0.0 0.0 1.34 MB

Objective C method tracing tool for iOS/macOS

License: MIT License

Shell 0.02% Ruby 0.04% C 0.29% Objective-C 0.20% HTML 99.45%

apptrace's Introduction

AppTrace

CI Status Version License Platform

Usage

用来追踪app运行期间所有调用的方法以及耗时时间,支持真机和模拟器,方便开发者对于app进行优化。如图:

sample

How it works

通过 fishhook 钩住 objc_msg_send 方法,在替代的方法中实现参数寄存器值的保存与恢复,从而在原始的 objc_msg_send 方法前后调用自定义方法,又不影响本身函数的调用,在 arm64 下的大致逻辑是:

保存寄存器x0 - x8,q0 - q7到栈上,
记录class,selector,startTime,lr
恢复寄存器x0 - x8,q0 - q7,
调用原始objc_msg_send,
保存寄存器x0 - x8,q0 - q7到栈上,
记录endTime,
恢复寄存器x0 - x8,q0 - q7,以及lr

最后产出物为 trace.json 文件,使用项目中的脚本 sh perf_file.sh 对文件进行处理,可打开网站 chrome://tracing 直接拖入 .json 文件展示,也可以使用脚本 sh generate_html.sh 输出稳定的html文件。

Sample

项目下的 Generate 有案例展示。

Quick start

AppTrace is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'AppTrace'

Import the framework header,then call start method.

#import "AppTrace.h"

// call it wherever you want, pefer to call in main.m like Example
[AppTrace startTrace];

Thanks

  1. Locus : https://github.com/hzfanfei/locus
  2. HookZz : https://github.com/jmpews/HookZz
  3. catapult : https://github.com/catapult-project/catapult
  4. AppleTrace : https://github.com/everettjf/AppleTrace
  5. fishhook : https://github.com/facebook/fishhook

License

AppTrace is available under the MIT license. See the LICENSE file for more info.

apptrace's People

Contributors

chenzhengxu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.