lldb

Is it possible to debug a gcc-compiled program using lldb, or debug a clang-compiled program using gdb?

别说谁变了你拦得住时间么 提交于 2019-11-27 11:06:52
问题 (Preface: I'm pretty new to C/C++ and I don't really know how debugging in native code actually works.) Some sources say that gdb and lldb can debug any program compiled to machine code. Others say that to debug with gdb you must compile in gcc with the -g flag. The documentation for gcc itself suggests this is optional, and that in fact if you use it, it can cause problems for debuggers other than gdb. Clang also has a -g flag and the documentation basically just says "Generate debug

How to get parameters using symbolic breakpoints in Objective-C

烈酒焚心 提交于 2019-11-27 11:03:50
问题 I have a breakpoint that looks like this -[UITableViewCell setSelected:] and it works, but I cannot figure out how to get the value that is being passed in. I have tried -[UITableViewCell setSelected:(BOOL)what] and -[UITableViewCell setSelected:what] which do not work at all. How can I access the parameters? If this doesn't work, I'll have to make a DebugUITableViewCell just to see what's going on, which is a hassle and touches a lot of code. 回答1: If you debug your code on the device the

How do I set an lldb watchpoint on a property of self.view?

廉价感情. 提交于 2019-11-27 09:38:54
问题 I want to trace when something changes the size of self.view. What's the correct format? (lldb) po self.view (UIView *) $1 = 0x0a8aba20 <UIView: 0xa8aba20; frame = (0 0; 480 864); autoresize = W+TM+BM; layer = <CALayer: 0xa8aba50>> (lldb) watch set variable self.view.frame.size.width error: "self" is a pointer and . was used to attempt to access "view". Did you mean "self->view.frame.size.width"? (lldb) watch set variable self->view error: "view" is not a member of "(PlayViewController *)

LLDB equivalent to GDB's “info malloc-history <address>” command?

社会主义新天地 提交于 2019-11-27 09:21:59
问题 I am trying to resolve a "message sent to deallocated instance " error in iOS. 回答1: See the LLDB-GDB command map (http://lldb.llvm.org/lldb-gdb.html) - you have to import a script, and the command is named malloc_info now. Obviously, malloc stack logging still needs to be turned on in the scheme options. (lldb) script import lldb.macosx.heap (lldb) malloc_info --stack-history 0x10010d680 Unfortunately, it doesn't show dealloc's - didn't GDBs malloc-history show that as well? 回答2: Use

`gdb` unable to unwind a stack

倾然丶 夕夏残阳落幕 提交于 2019-11-27 08:27:38
问题 Consider following (broken) code: #include <iostream> #include <memory> using namespace std; class Test { public: unique_ptr<string> s; Test() : s(NULL) { } void update(string& st) { s = unique_ptr<string>(&(st)); } }; void update(Test& t) { string s("Hello to you"); t.update(s); } int main() { Test t; update(t); cout << *t.s << endl; } Here we have error in method Test::update() we do not make a uniq copy of an object. So when the program is run under macOS, you'll get: $ ./test Hello t��E]�

Xcode 4.3-4.4 crashes with breakpoints using LLDB, breakpoints useless with GDB

流过昼夜 提交于 2019-11-27 08:13:52
问题 Every time I try to run my target when Breakpoints using the LLDB Debugger, Xcode crashes. My colleague has no trouble using LLDB, and we're both running 4.4 (I've had the problem since 4.3) Furthermore, since I have to use GDB, there's a problem with that too. Randomly, when I hit some breakpoints in GDB, I'll get a Previous frame inner to this frame (gdb could not unwind past this frame) message, and can't really see anything useful without blindly typing in po iVar like commands. Overall

View array in LLDB: equivalent of GDB's '@' operator in Xcode 4.1

江枫思渺然 提交于 2019-11-27 05:59:28
I would like to view an array of elements pointed to by a pointer. In GDB this can be done by treating the pointed memory as an artificial array of a given length using the operator '@' as *pointer @ length where length is the number of elements I want to view. The above syntax does not work in LLDB supplied with Xcode 4.1. Is there any way how to accomplish the above in LLDB? Actually there is a simple way to do it, by casting the pointer to a pointer-to-array. For example, if you have a int* ptr , and you want to view it as an array of ten integers, you can do p *(int(*)[10])ptr Because it

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

允我心安 提交于 2019-11-27 05:48:14
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? 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] [-d ] [-u ] -- expression -G <gdb-format> ( --gdb-format <gdb-format> ) Specify a format using a GDB

GDB errors on macOS Mojave

╄→гoц情女王★ 提交于 2019-11-27 04:48:32
问题 Environment: Mac/Mojave and GDB 8.2.1 (via homebrew). I worked through instructions https://forward-in-code.blogspot.com/2018/11/mojave-vs-gdb.html i.e.: latest GDB via brew, which solves the executable format issue sign GDB with new entitlements Additionally, I've also modified SIP to allow debugging (in Recovery OS terminal: csrutil enable --without debug ). However, I still can’t get gdb to work: (gdb) file main Reading symbols from main...done. (gdb) run Starting program: /Users

LLDB equivalent of gdb “directory” command for specifying source search path?

送分小仙女□ 提交于 2019-11-27 03:59:35
Looking for the lldb equivalent of the gdb " directory " command to add search paths for finding missing source code (or possibly similar functionality within xcode)? Thanks in advance! The target.source-map setting allows you define a series of a => b path remappings in the debug session. It's not identical to the gdb dir command, which is a list of directories to search for source files by base name, but you can solve the same problems with source-map . Here's an example where I move a source file to a hidden directory after compiling: % cd /tmp % echo 'int main () { }' > a.c % clang -g a.c