← Back to team overview

kicad-developers team mailing list archive

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

 

Hi Thomas,

I like this much better than your previous patch.  What platforms have
you tested this on?  Also, please fix the coding policy[1] issues in
your patch.  You can use uncrustify or clang-format if you don't want to
do it by hand.

Cheers,

Wayne

[1]:
http://docs.kicad-pcb.org/doxygen/md_Documentation_development_coding-style-policy.html

On 9/20/2018 5:49 AM, Thomas Pointhuber wrote:
> Hi Tom,
> 
> based on your proposal I fixed the Stack Walker (I think it should also
> be fixed upstream). I was required to duplicate quite some wx code and
> we probably need to add an additional copyright notice.
> 
> The stack now looks like this, and I verified that I can find the
> location of a crash using addr2line:
> ```
>   <stack>
>     <frame level="0" offset="0004752b" address="55aeb750c52b"
> module="pcbnew/pcbnew"/>
>     <frame level="1" offset="00045e37" address="55aeb750ae37"
> module="pcbnew/pcbnew"/>
>     <frame level="2" offset="000443dc" address="55aeb75093dc"
> module="pcbnew/pcbnew"/>
>     <frame level="3" offset="001c830c" address="7f60b12af30c"
> module="/usr/lib/libwx_baseu-3.1.so.1"/>
>     <frame level="4" offset="000123c0" address="7f60af51a3c0"
> module="/usr/lib/libpthread.so.0"/>
>     <frame level="5" function="__poll" offset="00000051"
> address="7f60af434bb1" module="/usr/lib/libc.so.6"/>
>     <frame level="6" offset="0006cee0" address="7f60ae795ee0"
> module="/usr/lib/libglib-2.0.so.0"/>
>     <frame level="7" function="g_main_loop_run" offset="000000d2"
> address="7f60ae796f62" module="/usr/lib/libglib-2.0.so.0"/>
>     <frame level="8" function="gtk_dialog_run" offset="0000015e"
> address="7f60aedb914e" module="/usr/lib/libgtk-x11-2.0.so.0"/>
>     <frame level="9" function="wxMessageDialog::ShowModal()"
> offset="00000083" address="7f60b1acc463"
> module="/usr/lib/libwx_gtk2u_core-3.1.so.1"/>
>     ...
> ```
> 
> the current code is more or less a minimal implementation. It would be a
> good idea to add the build parameters like displayed in about_config,
> configuration files, environment variables,... in the future as well.
> 
> Regards,
> Thomas
> 
> Am 19.09.18 um 20:36 schrieb Tomasz Wlostowski:
>> 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
>>
>>
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers
>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~kicad-developers
>> More help   : https://help.launchpad.net/ListHelp


Follow ups

References