Now we can import module
(lldb) expr @import UIKit
What's the meaning of this import
? What happen to debugger when we import a module.
Can we use this to import some private header file in a static lib, and how?
The example code and commands below illustrate some of Jim's answer:
Framework
This framework is called rusty_nails
. It is shipped inside of my iOS app.
class Hello{
static func world() {
print("hello from a static method")
}
}
debugger commands
Connect to your iOS app with lldb.
(lldb) po Hello()
error: use of undeclared identifier 'Hello'
(lldb) exp import rusty_nails
error: unknown type name 'import'
(lldb) settings set target.language swift
(lldb) exp import rusty_nails
(lldb) po Hello()
<Hello: 0x60000001a630>
(lldb) po Hello.world()
hello from a static method
Import syntax for lldb
(lldb) expr @import <stdbool.h> // C and Objective-C
(lldb) exp import UIKit // Swift
Help LLDB ( when project has Swift, Obj-C and C )
(lldb) po bool $foo = true;
error: <EXPR>:3:5: error: consecutive statements on a line must be separated by ';'
(lldb) settings set target.language objc
(lldb) expr @import <stdbool.h>
(lldb) po bool $foo = true;
(lldb) po $foo
true
Running @import <Framework>
in the debugger does pretty much what it does in your source code, makes the types & method signatures available to the compiler that implements the lldb expression parser.
It doesn't make the code from the framework available, just the types, and it doesn't work for a random set of headers, only for a clang module with a proper module map.
If you want to introduce a few internal types into the debugger's expression parser, you can use the expression prefix setting target.expr-prefix
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With