While debugging, how can I jump to a function, execute it and return from where I left off?

StackOverflow https://stackoverflow.com/questions/23297105

  •  09-07-2023
  •  | 
  •  

문제

Say function A consists of 10 lines. I set a breakpoint at line 5, when I hit it, I want to Execute function B, before returning to A. On return, Id like the flow to continue at line 5.

도움이 되었습니까?

해결책

The lldb expr command evaluates a C/ObjC/C++ expression in the current program context, using user defined variables and variables currently in scope.

Examples:

expr -- functionB(17)
expr -- [self methodB]

Sometimes it is necessary to specify the return value explicitly, for example

expr -- (void)functionB(17)

If the function returns an Objective-C object then you can use po as an alias for expression -O --, in that case lldb prints the description of the return value.

You can also add the debugger command as an "Action" to the breakpoint, to have it executed automatically when the breakpoint is hit:

enter image description here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top