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