morgancodes
morgancodes

Reputation: 25265

iPhone/iPad fatal error in C++ code produces no output in the log

I'm trying to move away from Objective-C to C++ for audio in my iPad programming, due to the a few reports I've heard of Objective-C selectors sometimes causing audio glitches. So I'm starting to use pure C++ files.

When a fatal error happens in one of the C++ files, I get no output from the log. The app just crashes.

For example, if I do this in my C++ file:

    env = new ADSR();
    cout << "setting env to null\n";
    env = NULL;
    env->setSustainLevel(1);
    cout << "called function on non-initialized env\n";

I get the following output:

setting env to null

After that, there's a method called on NULL, which apparently kills the app, but absolutely nothing to that effect is reported. What do I need to do to have useful information logged when there's an error in my C++ code?

Upvotes: 0

Views: 514

Answers (3)

morgancodes
morgancodes

Reputation: 25265

The mac's console app provides great information on why my crash happened. Thanks to Moshe for getting me most of the way there by suggesting I look at the console if I was running the app on a device.

Upvotes: 0

Moshe
Moshe

Reputation: 58097

There are a few things you can try.

  1. You can set NSZombie to enabled.

  2. Perhaps you can link your file against Foundation Framework and use NSLog to debug the crash.

  3. Also, if you compile to a device, you can check the Device Console and the Error Logs in Xcode's Organizer.

alt text alt text

Upvotes: 1

mysticboy59
mysticboy59

Reputation: 143

Have you tried using breakpoints and tracing the game flow using the Debugger? I think using these would definitely give some log!!

Upvotes: 1

Related Questions