LLDB 和Chisel 使用例子
打印变量
打印数字
(lldb) p/d 16
16
16 进制格式
(lldb) p/x 16
0x10
2 进制格式
(lldb) p/t 16
0b00000000000000000000000000010000
(lldb) p/t (char)16
0b00010000
声明变量
(lldb) e int $a = 2
(lldb) p $a * 19
38
(lldb) e NSArray *$array = @[ @"Saturday", @"Sunday", @"Monday" ]
(lldb) p [$array count]
2
流程控制
- continue
continue或c - step over,执行一行代码
next或n - step into
step或s - step out
thread step-out或finish - 从当前函数返回
thread return
管理断点
查看所有断点
(lldb) br list
Current breakpoints:
1: file = '/testStringIndex/testStringIndex/ViewController.m', line = 73, exact_match = 0, locations = 1, resolved = 1, hit count = 1 1.1: where = testStringIndex`-[ViewController configureSections] + 261 at ViewController.m:73, address = 0x000000010de75515, resolved, hit count = 1 2: file = '/testStringIndex/testStringIndex/ViewController.m', line = 31, exact_match = 0, locations = 1, resolved = 1, hit count = 1 2.1: where = testStringIndex`-[ViewController viewDidLoad] + 701 at ViewController.m:31, address = 0x000000010de74f3d, resolved, hit count = 1
disable 断点
(lldb) br disable 2.1
1 breakpoints disabled.
删除断点
(lldb) br delete 1.1
0 breakpoints deleted; 1 breakpoint locations disabled.
打断点
指定文件指定行数打断点
(lldb) br set -f ViewController.m -l 76
Breakpoint 2: where = testStringIndex`-[ViewController configureSections] + 451 at ViewController.m:77, address = 0x000000010eff15d3
(lldb) b ViewController.m:79
Breakpoint 3: where = testStringIndex`-[ViewController configureSections] + 526 at ViewController.m:79, address = 0x000000010eff161e
在符号(C语言函数)上打断点
(lldb) b isEven
Breakpoint 3: where = DebuggerDance`isEven + 16 at main.m:4, address = 0x000000010a3f6d00
(lldb) br s -F isEven
Breakpoint 4: where = DebuggerDance`isEven + 16 at main.m:4, address = 0x000000010a3f6d00
在 OC 函数上打断点
(lldb) breakpoint set -F "-[NSArray objectAtIndex:]" Breakpoint 4: where = CoreFoundation`-[NSArray objectAtIndex:], address = 0x000000010fbb7570
Breakpoint 5: where = CoreFoundation`-[NSArray objectAtIndex:], address = 0x000000010fbb7570
(lldb) b -[NSArray objectAtIndex:] Breakpoint 6: where = CoreFoundation`-[NSArray objectAtIndex:], address = 0x000000010fbb7570
Breakpoint 7: where = CoreFoundation`-[NSArray objectAtIndex:], address = 0x000000010fbb7570
(lldb) breakpoint set -F "+[NSSet setWithObject:]" Breakpoint 8: where = CoreFoundation`+[NSSet setWithObject:], address = 0x000000010fadd5d0
Breakpoint 9: where = CoreFoundation`+[NSSet setWithObject:], address = 0x000000010fadd5d0
(lldb) b +[NSSet setWithObject:] Breakpoint 10: where = CoreFoundation`+[NSSet setWithObject:], address = 0x000000010fadd5d0
Breakpoint 11: where = CoreFoundation`+[NSSet setWithObject:], address = 0x000000010fadd5d0
更新界面
在 Chisel 中有一个命令,叫做 caflush,来渲染。
(lldb) e (void)[$myView setBackgroundColor:[UIColor blueColor]]
(lldb) e (void)[CATransaction flush] //渲染
Chisel 的命令
非重写方法的符号断点
(lldb) bmessage -[MyViewController viewDidAppear:]
Setting a breakpoint at -[UIViewController viewDidAppear:] with condition (void*)object_getClass((id)$rdi) == 0x000000010e2f4d28
Breakpoint 1: where = UIKit`-[UIViewController viewDidAppear:], address = 0x000000010e11533c
MyViewController并没有实现这个方法。(lldb) help bmessage
For more information run 'help bmessage' Expects 'raw' input (see 'help
raw-input'.)Syntax: bmessage
Set a breakpoint for a selector on a class, even if the class itself doesn't
override that selector. It walks the hierarchy until it finds a class that does
implement the selector and sets a conditional breakpoint there.Arguments:
; Type: string; Expression to set a breakpoint on, e.g. "-[MyView
setFrame:]", "+[MyView awesomeClassMethod]" or "-[0xabcd1234 setFrame:]"打印内部变量
(lldb) pinternals self
(ViewController) $14 = {
_allStrings = 0x000060800005cec0 @"15 elements"
_tableView = 0x00007fd27901fe00
_sectionsArray = nil
_collation = nil
}
打印继承关系
(lldb) pclass self
ViewController
| UIViewController
| | UIResponder
| | | NSObject
其他
当前行数和源码
(lldb) frame info
frame #0: 0x000000010704e515 testStringIndex`-[ViewController configureSections](self=0x00007fb3c8006160, _cmd="configureSections") at ViewController.m:73
查看内存
(lldb) x/4c $str
0x7fd04a900040: monk
LLDB 和Chisel 使用例子的更多相关文章
- iOS开发——测试篇&breakpoints、lldb 和 chisel 的详解
breakpoints.lldb 和 chisel 的详解 Breakpoints BreakPoint分类 breakpoint也是有分类的,我这里的文章内大致按使用的方式分为了 Normal Br ...
- breakpoints、lldb 和 chisel 的使用
http://www.cocoachina.com/ios/20150803/12805.html Breakpoints BreakPoint分类 breakpoint也是有分类的,我这里的文章内大 ...
- (转)Xcode调试技巧
转自http://www.apkbus.com/android-140340-1-1.html 这篇文章给大家带来的是一些Xcode实用技巧,比如: • 摆脱NSlog打印输出,使用断点日志. • 摆 ...
- 关于Xcode调试的帖子,感觉不错,转来看看
http://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1 http://www.raywenderlich.com/10505 ...
- 调试工具Chisel-LLDB插件
Chisel-LLDB命令插件 相信每个人或多或少都在用LLDB来调试,比如po一个对象.LLDB的是非常强大的,且有内建的,完整的 Python 支持.今天我们主要介绍一个 facebook 开源的 ...
- Chisel-LLDB命令插件,让调试更Easy
http://blog.cnbluebox.com/blog/2015/03/05/chisel/ LLDB 是一个有着 REPL 的特性和 C++ ,Python 插件的开源调试器.LLDB 绑定在 ...
- 说说XcodeLLDB调试的那些事儿
使用场景之一,接收他人的项目,快速理清其层次结构,可以打标识符断点,如下图 每一个VC,都加了个在viewDidLoad方法处的断点,这样运行程序时,逐步断点,便可以理清层次, 但是,需要手动不断的继 ...
- breakpoints && lldb  && chisel 的使用
Breakpoints BreakPoint分类 breakpoint也是有分类的.我这里的文章内大致按使用的方式分为了 Normal Breakpoint,Exception Breakpoint, ...
- [转] 与调试器共舞 - LLDB 的华尔兹
你是否曾经苦恼于理解你的代码,而去尝试打印一个变量的值? NSLog(@"%@", whatIsInsideThisThing); 或者跳过一个函数调用来简化程序的行为? NSNu ...
随机推荐
- 创建和运行Java项目
---------siwuxie095 首先在左侧的工程管理面板 Package Explorer 中,右键->New->Java Project ...
- rabbitmq的延迟消息队列实现
第一部分:延迟消息的实现原理和知识点 使用RabbitMQ来实现延迟任务必须先了解RabbitMQ的两个概念:消息的TTL和死信Exchange,通过这两者的组合来实现上述需求. 消息的TTL(Tim ...
- TLB与内存寻址,内存读取,虚拟内存的相关原理
TLB(Translation Lookaside Buffer)转换检测缓冲区是一个内存管理单元,用于改进虚拟地址到物理地址转换速度的缓存. TLB是一个小的,虚拟寻址的缓存,其中每一行都保存着一个 ...
- 浅析JavaScript访问对象属性和方法及区别
属性是一个变量,用来表示一个对象的特征,如颜色.大小.重量等:方法是一个函数,用来表示对象的操作,如奔跑.呼吸.跳跃等. 在JavaScript中通常使用”."运算符来存取对象的属性的值.或 ...
- PHP开启页面报错的代码
PHP开启页面报错的方法很简单,在<?php内加入下面的代码就可以了: <?php ini_set("display_errors", "On"); ...
- c++ template 判断是否为类类型
/* The following code example is taken from the book * "C++ Templates - The Complete Guide" ...
- 判断字符串是否为回文 python
回文正序和逆序一样的字符串,例如abccba 方法一 def is_palindrome1(text): l = list(text) l.reverse() t1 = ''.join(l) if t ...
- guestfish修改镜像内容
1.安装guestfish yum install libguestfs-tools 注意,如果要修改windows镜像需要安装 yum install libguestfs-winsupport 2 ...
- C++ 数据封装和抽象
C++ 数据抽象 数据抽象是指,只向外界提供关键信息,并隐藏其后台的实现细节,即只表现必要的信息而不呈现细节. 数据抽象是一种依赖于接口和实现分离的编程(设计)技术. 让我们举一个现实生活中的真实例子 ...
- windows下Apache的虚拟主机配置
1.Apache虚拟主机: 在Apache上有关于虚拟主机的具体说明,具体可以参考Apache手册,这里简单的说一下虚拟主机主要分为两种: 1.基于主机名的虚拟主机(一个IP地址,多个网站) 2.基于 ...