Suppressing LLDB verbiage when calling a function?

I am starting to link my functions now and have a lot of LLDB verbiage that I don't need to see, when all I need is the return value.

Is there a way to call a function but suppress it spitting anything out to the LLDB - essentially, I just want the resulting value, not the print statements.


I’m not sure what you’re referring to here. Could you perhaps post an example of what you’re seeing?

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

I think I've seen you on the Apple forums?

Imagine checking every change on a function that performs several actions, printing out values to the LLDB before and after changes to see if they worked, then you get a lot of verbiage.

Basically, I have too much verbiage and sometimes I'd just like to suppress it because it's confusing to keep track of a function's behaviour when linking to another just for the value you need:


func oldTest() -> Int {
print("20 lines of text")

func currentTest() {
var = oldTest()
print("all the text in this function")
//unfortunately all the 20 lines from the other function get printed too!

what I want

x20 of what I don't

the rest of what I want

Are you using LLDB from the command line? Or LLDB from within Xcode?

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

Hi eskimo, I meant within Xcode, just at the bottom.

Are you printing things for effect? For example, you’re building a command-line tool and this forms part of the output. Or is your printing just for debugging purposes?

If it’s the former I’d change how you write your code. I tend to build my tools so that I have core code that returns a description of what the results should be, and then I have separate code to print that. This has a bunch of advantages:

  • It separates concerns, which is always a good thing

  • It allows the core code to be reused in other environments, like in a GUI app.

  • It helps with testing.

  • My core code tends to be functional — that is, its output is predictable based on solely its input parameters — which means I can see everything in the debugger.

  • It means I don’t have to worry about this problem (-:

In contrast, if these print statements are purely for debugging, I’m going to recommend that you take a look at Xcode’s breakpoints. You can set up a breakpoint that prints some state and then automatically continues. The Xcode UI then makes it easy to enable and disable these breakpoints, and thus enable and disable your logging.

For some great examples of the power of Xcode breakpoints, check out WWDC 2018 Session 412 Advanced Debugging with Xcode and LLDB.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple