xcode debugging - quickly step over assembly code back to my custom code

丶灬走出姿态 提交于 2020-01-12 09:13:51

问题


I'm still new to xcode. I have "show disassembly when debugging" UNCHECKED but I know that as I step through my own code that I will still regularly be thrown into assembly code when system methods are called.

My question is ...... Is there any way to quickly step over the assembly code to the NEXT line of my own custom code rather than endlessly hitting F6 or F8. I know that, in advance, I can set a new breakpoint at the next custom method to be called and press the run button, but when I quickly step through my code, I usually don't know in advance when the debugger will throw me into assembly code and when that happens it's then too late to be hitting the "run to next breakpoint" button. Any help appreciated.

EDIT - thx for the "continue to current line" suggestion but often when i try to do this i put cursor on a line of my own code and the "continue to current line" command under the debug menu is greyed out. also i usually dont know in advance where the code execution will reenter my own code so i could be putting the cursor in a spot which wont be called anyway. Basically im trying to learn the order of execution of my code by stepping thru line by line. Everytime i get "thrown" into dissassemby i dont know in advance where the order of execution will re-enter my own custom code (much of which might be other person's code) so pressing continue often takes me to the end of the build and im none the wiser to the path taken. The only option i see is to endlessly press Fn-F8 which is a right pain. Surely i must be missing something?

EDIT - thx @Jim for your suggestion. still no luck, ive tried your code (lldb) "break set -r .* -s MyBinary" substituting MyBinary with the name of the app im trying to set breakpoints on all methods in and all i get is "Breakpoint 2: no locations (pending). WARNING: Unable to resolve breakpoint to any actual locations. i did a google search on this to this page How to automatically set breakpoints on all methods in XCode? and that page indicates the words break set should be breakpoint set and there is no * after the . so i tried that and same error message appears and no breakpoints are set. any suggestions?


回答1:


One trick for tracing execution through the functions in one binary is to use a regular expression breakpoint to stop on all the functions in that binary, e.g.:

(lldb) break set -r .* -s MyBinary

Then you can just use "continue" to go from call to call in your code. You can provide the -s option more than once to set the breakpoint in multiple shared libraries.

lldb's execution doesn't slow down much even with tens of thousands of breakpoints, though initially setting them might take a bit particularly if you are debugging an iOS app. So this is a viable technique for medium sized libraries.

If you are trying to trace execution on just one thread, then use the -t option to break set to limit the breakpoint to that thread.

Also, remember that you can disable individual locations within this breakpoint. So if you hit a breakpoint on some function you don't care about, look at the PC banner in the source window on the LHS it will say something like "Thread 1: breakpoint 1.1", so just do:

(lldb) break dis 1.1

That way you can focus in on the functions you actually care about as you go.




回答2:


When you hit the assembly code, change to your code in the editor window and position the cursor on the line you which to jump. Next, hit ^⌘C on your keyboard and the debugger will run through to the current line in the editor. Under the Debug menu, ^⌘C is Continue to Current Line.



来源:https://stackoverflow.com/questions/19438031/xcode-debugging-quickly-step-over-assembly-code-back-to-my-custom-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!