سؤال

The iOS SDK is giving me warnings about some code (possibly some 3rd party API I'm using) that is making CG calls with a nil context.

So I want to set up a symbolic breakpoint on one of these calls, and have it break when the passed context is nil. For example, if CGContextSetBlendMode(context, mode) is called with a nil context.

I've created a Symbolic breakpoint with a condition of context == nil, but the debugger keeps telling me it's an invalid condition.

Has anyone used breakpoints and conditions to stop of C functions calls? How did you specify the condition?

هل كانت مفيدة؟

المحلول 2

You should just create symbolic breakpoint on CGPostError.

See this question

نصائح أخرى

One slightly non-obvious thing about the debug information that most compilers generate (including gcc & clang) is that the only generate debug information for functions at the point where the function is defined, not in all the modules where it it used. This is just to keep the debug information from becoming unmanageably large.

That means that even though your code includes CoreGraphics headers that define CGContextSetBlendMode , you still don't have debug information for the function CGContextSetBlendMode. The debugger can see the symbol name from the information the dynamic linker uses to bind up calls, and so it can set a breakpoint on it, but it has no idea what "context" means. That's why your condition wasn't valid, it referred to an unknown name.

If you still want to break on CGContextSetBlendMode when the first argument is nil, you need to figure out where the first argument to the function is stored when the function is called. If it is stored in a register (true for ARM and x86_64, but not i386) then lldb has convenience variables: $arg1, $arg2, etc. which are aliases for the first few argument passing registers. So for ARM, you should be able to use the condition:

$arg1 == nil

Note that the argument passing registers will generally only hold the actual argument values at the beginning of the function. Don't try to use them in the middle of the function, as these registers have quite likely been reused by that time.

Yes, you can set a conditional breakpoint based on the result of a C function. However, it sounds like you want to find ANY Core Graphics call with a nil context. Conditional breakpoints only work when you set a breakpoint on a specific line of your code.

The other poster's suggestion of a symbolic breakpoint on CGPostError sounds like the way to go.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top