Question

Is it possible to call functions from math.h while using the lldb debugger?

I am trying to debug some math-related iOS code and am getting incorrect results from the Xcode5 debugger:

(lldb) p (double)pow(2., 2.)
(double) $0 = NaN

Another post mentioned that the debugger doesn't know the prototype of the pow function so I also tried casting the function to the correct type but it still didn't work:

(lldb) p ((double(*)(double, double))pow)(2., 2.)
(double) $0 = NaN

However it does work when called from my running Objective C code:

NSLog(@"Power is %f", pow(2., 2.));

2013-12-10 14:41:25.651 Foo[27481:70b] Power is 4.000000
Was it helpful?

Solution

What version of Xcode are you using when you're seeing this? Are you seeing this in Xcode 5.0? I'm using something a tiny bit newer and it looks fine debugging an iOS app on an armv7s device:

(lldb) p (double)pow(2.0,2.0)
(double) $0 = 4
(lldb) p (double)log(1.0)
(double) $1 = 0
(lldb) 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top