lldb

How to view value of Swift “let” constant in Xcode 6 debugger

落爺英雄遲暮 提交于 2019-12-18 16:54:34
问题 When I'm stopped in the debugger in Xcode 6, how can I view the value of a local Swift constant declared with let ? If I create a brand new Swift project in Xcode 6 and add the following two lines to application(_:didFinishLaunchingWithOptions:) in the app delegate: let someConstant = 5 var someVariable = 6 …then run the app and break immediately after these lines, this is what I see in the variables view of the debugger: Why does the variable display its value, while the constant does not?

Is it possible to set watchpoints on Swift properties?

匆匆过客 提交于 2019-12-18 14:48:15
问题 In Objective-C, I would sometimes set watchpoints in LLDB to let me know when instance variables had changed. Can I do this with Swift properties too? Right now, the only way I can achieve this is: adding a didSet handler to the property and setting a breakpoint inside (but this requires stopping the program and recompiling, which kind of defeats the purpose) adding a symbolic breakpoint on [setPropertyName:] but this only works if the class happens to support Objective-C bridging Do I have

Convert Objective-C enum constants to string names

我是研究僧i 提交于 2019-12-18 08:57:42
问题 Previously, this was impossible (you have to write it all out by hand / create a static array / put all the values into a dictionary and read them back ... etc) But I've noticed that the latest Xcode's lldb (4.6, maybe earlier versions too) is automatically converting enum-constants to strings. My problem is that we use a lot of libraries - including Apple's own! - which use annoying public enums with no "value-to-string" method offered. So I end up having to (many, many times over) do the

Xcode debugger (lldb) get object description from memory address

喜你入骨 提交于 2019-12-18 07:12:54
问题 Little-known fact: It is now possible, in Xcode, while paused in the debugger, to introspect the notification center to learn what objects are registered to receive what notifications: (lldb) po NotificationCenter.default <NSNotificationCenter:0x6040000d40b0> Name, Object, Observer, Options com.apple.accessibility.reduce.motion.status, 0x10b126190, 0x7fc795700140, 1001 com.apple.accessibility.asst.scanner.status, 0x10b126190, 0x7fc795700140, 1001 // ... etc. ... Very nice, but how do I get

How can I find the address of a stack trace in LLDB for iOS

随声附和 提交于 2019-12-18 02:42:41
问题 When I get a crash report, the offending part of my code will sometimes look like this, instead of showing me the actual line number, even though the crash report is symbolicated: -[ViewController myMethod:] + 47 In order to debug this, I need to know what line of my code this represents so that I can visually inspect it, set a breakpoint, etc. What is a good way to get the address of a method plus offset, as shown above, using LLDB? NOTE: this question is NOT a duplicate of how to read a

lldb error: variable not available

纵饮孤独 提交于 2019-12-17 22:45:47
问题 Here are my two lines of code: NSString *frontFilePath = [[NSBundle mainBundle] pathForResource:[self.bookendFileNames objectAtIndex:self.randomIndex] ofType:@"caf"]; NSLog(@"frontFilePath = %@", frontFilePath ); I put a break point on the second line and when there, I try to print it: (lldb) po frontFilePath But I get the following error: error: variable not available I'm confused because if I step over the NSLog statement, the variable does indeed print to the console. For what it's worth,

iOS App crashing before entering main() with Xcode 4.2 & iOS 5

人走茶凉 提交于 2019-12-17 19:34:02
问题 Background After upgrading xcode4.1/ios4 to xcode4.2/ios5 I am experiencing crashes while the App is loading and before it even enters main() . I have set a break point in main() but it is never reached. Compiling the project in Xcode 4.1 with a Base SDK of 4.3 works fine on iOS 4.x and iOS 5. Compiling the same project in Xcode 4.2 with a Base SDK of 5.0 works fine on 4.x but crashes in iOS 5, both on the simulator and on a device. Simulator Crash Crashes with EXC_BAD_ACCESS List of calls,

How to change variables value while debugging with LLVM in Xcode?

China☆狼群 提交于 2019-12-17 07:58:29
问题 In Xcode, GDB allows you to change local variables while debugging (see how to change NSString value while debugging in XCode?). Does LLDB offer a similar functionality? If so, how can we use it? 回答1: expr myString = @"Foo" (lldb) help expr Evaluate a C/ObjC/C++ expression in the current program context, using variables currently in scope. This command takes 'raw' input (no need to quote stuff). Syntax: expression -- Command Options Usage: expression [-f ] [-G ] [-d ] [-u ] -- expression [-o]

iOS——调试工具LLDB学习

送分小仙女□ 提交于 2019-12-17 01:17:23
一、前言   LLDB是个开源的内置于XCode的具有REPL(read-eval-print-loop)特征的Debugger,其可以安装C++或者Python插件。在日常的开发和调试过程中给开发人员带来了非常多的帮助。了解并熟练掌握LLDB的使用是非常有必要的。这篇文章将会带着大家一起了解在iOS开发中LLDB调试器的使用。 二、LLDB基础 2.1 LLDB基本语法   LLDB的基本语法如下 <command> [<subcommand> [<subcommand>...]] <action> [-options [option-value]] [argument [argument...]] <command>(命令)和<subcommand>(子命令):LLDB调试命令的名称。命令和子命令按层级结构来排列:一个命令对象为跟随其的子命令对象创建一个上下文,子命令又为其子命令创建一个上下文,依此类推。 <action>:执行命令的操作 <options>:命令选项 <arguement>:命令的参数 []:表示命令是可选的,可以有也可以没有    举个例子,假设我们给main方法设置一个断点,我们使用下面的命令:   这个命令对应到上面的语法就是: 1. command: breakpoint 表示断点命令 2. action: set 表示设置断点 3. option:

How can I see printf output when evaluating an expression using the `expr` command in lldb?

依然范特西╮ 提交于 2019-12-14 01:26:08
问题 Let us say that I have a function in a C program test.c like this: #include <stdio.h> char* foo = "test"; void print_foo(void) { printf("%s", foo); } main() { } I compile and run test.c like this: gcc -g -o test test.c chmod 755 test && lldb -s <(echo "b main\nr") test However, if I then run expr print_foo() no string output occurs: (lldb) expr print_foo() (lldb) 回答1: STDOUT is line buffered. You haven't emitted a newline yet. Try calling (lldb) expr (void) fflush(0) and you should see the