← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Print stacktrace when SIGSEGV or SIGABRT appears

 

On 19/09/18 20:13, Thomas Pointhuber wrote:
> 
> I rewrote it to use wxDebugReport and wxHandleFatalExceptions. What I
> noticed (at least for my build setup), the stack-trace is unusable in
> this version for me because it lacks all kicad internals:

Hi Thomas,

I like a lot your idea of having a builtin crash reporter (especially
under Windows/OSX where people struggle to get a stack trace, Linux
users sooner or later are forced to figure out how to use a
debugger...). I also second Wayne's comment that it must work on all
platforms, so please no glibc-specific code.

wxDebugReport is IMHO a good starting point, but for some reasons that
are beyond my understanding, wxWidgets doesn't output raw addresses of
the functions in the call stack and if there's no symbols in the file
(and its dependent DLLs), the trace file is indeed useless.

Luckily wxStackFrame contains all the necessary information. The
function to blame is XmlStackWalker::OnStackFrame(...). A quick hack
like the one below can add raw addresses to the XML dump:

-- snip --

    if(func.empty())
    	func = wxT("<unknown>");

    nodeFrame->AddAttribute(wxT("function"), func);
    HexProperty(nodeFrame, wxT("offset"), frame.GetOffset());
    HexProperty(nodeFrame, wxT("address"), reinterpret_cast<long
unsigned int>(frame.GetAddress()));

-- snip --

Cheers,
Tom


Follow ups

References