Debugging and C++ name mangling
In the event that your ShiVa game crashes, you might receive a crash report with a call stack for debugging purposes. Unlike the nice and easy to follow Lua errors we show you in the editor, the backtrace will contain rather strange names and symbols that are not obvious Lua script users. Let’s take this report from an Android game for instance:
What does “_ZN7Pandora10EngineCore10AIInstance11CallHandlerEPKchPKNS0_10AIVariableEPN4S3DX10AIVariableE+16” mean?
The ShiVa Engine Core is written in C++. The long string above has been mangled by the C++ compiler. In modern compilers, name mangling is a technique used to solve various problems caused by the need to resolve unique names for programming entities. C++ compilers are the most widespread users of name mangling. Since ShiVa is a C++ engine at heart, error messages generated from its engine core will all carry mangled names in the backtrace.
Demangling the name, that means converting it back into a readable form, is relatively straight forward. The easiest way are websites like demangler.com which do all the work for you. If you put “_ZN7Pandora10EngineCore10AIInstance11CallHandlerEPKchPKNS0_10AIVariableEPN4S3DX10AIVariableE+16” into the demangler, you receive:
Pandora::EngineCore::AIInstance::CallHandler(char const*, unsigned char, Pandora::EngineCore::AIVariable const*, S3DX::AIVariable*)
“Pandora” is the internal codename and namespace for the ShiVa engine. From the signature of the function, you can see that the error occurred while calling an AI handler.
Every compiler has its own mangling scheme. ShiVa is either compiled with MSVC (Windows) or GCC/G++ (everything else), so the website mentioned above works well. Clang/LLVM can be used for your own libraries through XCode, but the engine core still relies on GCC.