Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"return" from method while stepping?

I would like to exit out the current method that I'm stepping through.

-(void)helloWorld {
    NSLog(@"Hello");
    // I would like to return here, so that "World" isn't printed.
    NSLog(@"World");  
}

I have tried the following, but without luck.

(lldb) expr return
<no result>

Is this possible with lldb?

like image 408
neoneye Avatar asked Oct 13 '12 10:10

neoneye


People also ask

How to go to previous line while debugging in Visual Studio?

So, if you've just taken a step in live debugging (F10 or F11), you can use the Step Backward button to quickly navigate to the previous step. This will automatically put Visual Studio in Historical debugging mode, at the line of code you've stepped back to.

How do you find the return value?

There are 2 places where we can see the method return value: In the Debugger Immediate window, using the $ReturnValue keyword. To open the Immediate window while debugging, choose Debug -> Windows -> Immediate (or press keyboard shortcut: Ctrl + Alt + I). In the Debugger Autos window.

How do I see return value in Visual Studio?

View return values for functions If the window is closed, use Debug > Windows > Autos to open the Autos window. In addition, you can enter functions in the Immediate window to view return values. (Open it using Debug > Windows > Immediate.)

What does step over do in Visual Studio?

If the current line contains a function call, Step Over runs the code and then suspends execution at the first line of code after the called function returns. Step Out continues running code and suspends execution when the current function returns. The debugger skips through the current function.


1 Answers

Unfortunately in Xcode 4.5.x there is no way to force an early return from a function. In the current lldb sources over at http://lldb.llvm.org/ there is a newly added command, thread return, which does what you want - it includes the ability to specify the return value of the function. This won't be in Xcode until the next major release, though.

like image 53
Jason Molenda Avatar answered Sep 18 '22 13:09

Jason Molenda