简体   繁体   中英

How to print equivalent of #line #file #function in LLDB using Swift?

In source code, if I do:

print("\(#file) \(#line) \(#function)")

I get output like:

MyFile.swift 31 doFoo()

However, from a breakpoint in LLDB, if I do similar:

(lldb) po "\(#file) \(#function) \(#line)"

I get:

"<EXPR> $__lldb_expr(_:) 6"

Is there a way to get output like the former from the latter? I'm aware you can do:

(lldb) frame info
frame #0: 0x0000000102d92c46 MyApp `closure #2 in Client.fetchCart($0=(error_instance = 0x0000600000810be0 -> 0x0000000108e88cc0 (void *)0x0000000108e88ce8: __SwiftNativeNSError)) at Client+Cart.swift:21:23

... but that output is pretty messy. Is there a way to clean it up to just file, line and function?

You can set a custom format for displaying the frame info. For what you want, you can do:

settings set frame-format "${line.file.basename} ${line.number} ${function.name-without-args}\n"

And then try frame info . You'd get something like:

AppDelegate.swift 11 AppDelegate.application(_:didFinishLaunchingWithOptions:)

You can make this setting permanent by following this answer .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM