美文网首页
iOS调试——Chisel

iOS调试——Chisel

作者: coderanger | 来源:发表于2017-04-21 13:43 被阅读0次

Chisel是facebook开源的辅助xcode进行iOS开发调试的工具,包含一系列更加有用的lldb命令,而且Chisel还支持添加本地以及自定义命令。本文从工具介绍开始,带大家认识并使用这一强大工具。

Chisel 简介

github地址

安装

直接按照官方文档进行:

  1. 安装Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  1. 安装Chisel
brew update
brew install chisel
  1. 更新.lldbinit
    .lldbinit文件是lldb启动之前加载的文件,用于lldb的初始化,每次lldb启动都会加载。安装chisel成功之后,终端会打印如下提示,按照提示,将启动chisel的命令复制到.lldbinit文件中。


    chisel安装.png

    我是通过如下命令直接将上面的命令写入文件中(>>表示追加到文件尾,如果你已经添加过则无需再次添加)

echo command script import /usr/local/opt/chisel/libexec/fblldb.py >> ~/.lldbinit
  1. 重启xcode并check
    check方法有两种,第一种是打开终端依次输入:llbd<enter>,help<enter>;第二种方法是打开xcode,打断点并执行到断点处,输入help命令。滚动help的结果,当找到Current user-defined commands:一行,即表示安装成功。


    chisel安装check.png

Chisel常用命令简介

  • pmethods
    print the class and instance methods of a class.

  • pclass
    Print the inheritance starting from an instance of any class.

  • poobjc
    Print the expression result, with the expression run in an ObjC++ context. (Shortcut for "expression -O -l ObjC++ -- " ).

  • pviews
    Print the recursion description of <aView>.

  • pcells
    Print the visible cells of the highest table view in the hierarchy.

  • pblock
    Print the block`s implementation address and signature.

  • mask
    Add a transparent rectangle to the window to reveal a possibly obscured or hidden view or layer's bounds

  • border
    Draws a border around <viewOrLayer>. Color and width can be optionally provided. Additionally depth can be provided in order to recursively border subviews.

  • show
    Show a view or layer.

添加本地及自定义命令

参考官方文档,这里整理出基本步骤如下:

  1. 开发命令脚本
    官方文档提供了一个example(源码贴在下面方便大家阅读)
  2. 更新.lldbinit
    同Chisel安装完成后的步骤一样,需要将初始化的命令同步到.lldbinit文件中。
  3. check命令
    同check Chisel是否安装成功的方法一样。
#!/usr/bin/python
# Example file with custom commands, located at /magical/commands/example.py

import lldb
import fblldbbase as fb

def lldbcommands():
  return [ PrintKeyWindowLevel() ]
  
class PrintKeyWindowLevel(fb.FBCommand):
  def name(self):
    return 'pkeywinlevel'
    
  def description(self):
    return 'An incredibly contrived command that prints the window level of the key window.'
    
  def run(self, arguments, options):
    # It's a good habit to explicitly cast the type of all return
    # values and arguments. LLDB can't always find them on its own.
    lldb.debugger.HandleCommand('p (CGFloat)[(id)[(id)[UIApplication sharedApplication] keyWindow] windowLevel]')

最后,Enjoy yourself!

相关文章

  • iOS调试之chisel

    iOS调试之chisel Chisel 是一个 LLDB 指令集合,用户辅助 iOS 应用差错。 安装 chise...

  • Chisel的安装以及使用

    iOS调试之chisel Chisel 是一个 LLDB 指令集合,用户辅助 iOS 应用差错。 安装 1.chi...

  • iOS之LLDB常用调试命令

    iOS之LLDB常用调试命令熟练使用 LLDB,让你调试事半功倍使用facebook开源的Chisel调试Home...

  • iOS调试——Chisel

    Chisel是facebook开源的辅助xcode进行iOS开发调试的工具,包含一系列更加有用的lldb命令,而且...

  • iOS调试-Chisel

    马上就要国庆了,提前祝大家国庆快乐!! 前两天在gitHub上面发现了一个调试的三方框架,Chisel,由face...

  • LLDB 调试学习

    LLDB调试必看:与调试器共舞 - LLDB 的华尔兹Facebook/Chisel 安装chisel: Alte...

  • 教你如何使用Chisel增强LLDB调试

    如果你想快速高效调试IOS程序不妨学习下LLDB插件-Chisel,如果你使用过po,p等调试命令,是否觉得它们还...

  • iOS - Chisel的安装

    Chisel简介 Github地址:ChiselChisel是帮助iOS开发者更方便的调试应用的拓展工具, Chi...

  • iOS 调试-Chisel-LLDB命令插件

    Chisel 调试工具,Facebook开源的一款lldb调试工具-->GitHub 安装Chisel 1.安装h...

  • UI 调试利器 Chisel 的使用

    参考文章1: 调试器的妙用LLDB调试器和GDB调试器命令映射表 1 什么是 Chisel Chisel 是一个 ...

网友评论

      本文标题:iOS调试——Chisel

      本文链接:https://www.haomeiwen.com/subject/vgxqattx.html