<安全攻防之LLDB调试>

断点

  • 设置断点
$breakpoint set -n xxx 
set 是子命令
-n 是选项 是--name的缩写
或者
$b xxx

* 查看断点列表
$breakpoint list 

* 删除
$breakpoint delete 组号

* 禁用/启用
$breakpoint disable 禁用
$breakpoint enable  启用

* 遍历整个项目中满足Hello:这个字符的所有方法
$breakpoint set --selector Hello:
$breakpoint set -r Hello:
$breakpoint set --file xxx文件xxx --selector xxx方法名xxx

E:在某一个文件(ViewController.m)中满足Hello:的所有方法
$breakpoint set --file ViewController.m --selector Hello:
$breakpoint  
// 查看断点命令下所有的命令
     Commands for operating on breakpoints (see 'help b' for shorthand.)

Syntax: breakpoint <subcommand> [<command-options>]

The following subcommands are supported:
      // 清除或者废除匹配的特定的资源文件和哪一行的断点
      clear   -- Delete or disable breakpoints matching the specified source
                 file and line. 
      // 当断点触发时,添加.移除或者监听LLDB控制执行 
      command -- Commands for adding, removing and listing LLDB commands
                 executed when a breakpoint is hit. 
      //  删除特定的断点,如果没匹配到,删除所有断点
      delete  -- Delete the specified breakpoint(s).  If no breakpoints are
                 specified, delete them all. 
      // 使断点失效
      disable -- Disable the specified breakpoint(s) without deleting them.  If
                 none are specified, disable all breakpoints. 
      // 使断点有效
      enable  -- Enable the specified disabled breakpoint(s). If no breakpoints
                 are specified, enable all of them. 
      // 查看所有的断点
      list    -- List some or all breakpoints at configurable levels of detail. 
      // 修改
      modify  -- Modify the options on a breakpoint or set of breakpoints in
                 the executable.  If no breakpoint is specified, acts on the
                 last created breakpoint.  With the exception of -e, -d and -i,
                 passing an empty argument clears the modification. 
      name    -- Commands to manage name tags for breakpoints 
      read    -- Read and set the breakpoints previously saved to a file with
                 "breakpoint write".  
      // 设置
      set     -- Sets a breakpoint or set of breakpoints in the executable. 
      write   -- Write the breakpoints listed to a file that can be read in
                 with "breakpoint read".  If given no arguments, writes all
                 breakpoints.

流程控制

* 继续执行
$continue c 
* 单步运行,将子函数当做整体一步执行
$n next
* 单步运行,遇到子函数会进去
$s 

执行代码

  • help xxx 查看帮助文档 (E: help p)
// 这三个命令是相同的
(lldb) expression self.view.subviews
(__NSArray0 *) $6 = 0x00000001cde73400 @"0 elements"
(lldb) p self.view.subviews
(__NSArray0 *) $7 = 0x00000001cde73400 @"0 elements"
(lldb) e self.view.subviews
(__NSArray0 *) $8 = 0x00000001cde73400 @"0 elements"
(lldb) 

p 插入自己写的代码
p self.view.backgroundColor = [UIColor yellowColor]

查看堆栈信息

$bt
$frame select xx 查看某个Frame的信息
$frame variable 查看某个frame的参数信息

内存断点

// 对某个对象的某个属性设置内存断点(E:对p的name属性设置内存断点)
$watchpoint set variable p->_name
// 通过内存地址设置断点
$watchpoint set expression xxx地址

其他指令

// 崩溃信息中通过地址信息查找崩溃原因
$image lookup -a xxx
$image lookup -t xxx对象 查看对象的成员变量
$image list 查看所有的库列表

常用指令

$x (memory read xxx地址) 查看内存
$register read xxx (寄存器查看)
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 你是否曾经苦恼于理解你的代码,而去尝试打印一个变量的值? NSLog(@"%@", whatIsInsideThi...
    木易林1阅读 965评论 0 4
  • 前言 今天花了一天的时间终于把iOS的几种常见的调试方法给学习了一下,在这里给大家分享一下LLDB的使用,同时也是...
    Peak_One阅读 11,073评论 5 33
  • 接下来上今天的干货LLDB调试部分。日常的正向开发,Xcode提供了多种快捷键以及快捷方式方便我们开发者进行LLD...
    溪浣双鲤阅读 919评论 0 1
  •   LLDB的Xcode默认的调试器,它与LLVM编译器一起,带给我们更丰富的流程控制和数据检测的调试功能。平时用...
    Thinkdifferents阅读 1,647评论 1 4
  • 引言: 本篇文章主要总结了一些javascript中特别基础的内容,主要涉及到DOM0级和DOM2级事件,事件流,...
    IOneStar阅读 393评论 1 2