Using KiCad gdb on Windows

I have been asked to use gdb on Windows to debug a crash. I have never used gdb on this OS.

When I run gdb from the command line in …\KiCad\bin\ I get:

Could not find platform independent libraries
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to [:<exec_prefix>]
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named ‘encodings’

Current thread 0x000024dc (most recent call first):

How do I make gdb usable?

Try just double clicking gdb.exe, it may open in a window.

I found an interesting alternative, not for full debugging but it should be easy inspector for crashed mingw programs: drmingw. I just haven’t had an opportunity and time to test it yet.

Debugging mingw programs doesn’t seem to be so easy, microsoft tools don’t read them because the debugging information in the compiled program is different.

Double clicking gdb gives the same error as in the first post

drmingw is interesting, but will it work in this case, when the error is not “sample.exe has stopped working” but is just a frozen window, that generates a window not responding message if you try to close the schematic window?

I’m trying to test drmingw but now I need a KiCad which crashes. Unfortuntely it doesn’t happen when you need it :slight_smile: Does someone remember a way to crash some KiCad version which is right now available?

gdb.exe works for me but I can’t do anything useful with it.

attach [PID NUMBER]
backtrace

Reading symbols from C:\Program Files\KiCad\bin\kicad.exe…(no debugging symbol
s found)…done.
(gdb) bt
Python Exception <class ‘NameError’> Installation error: gdb.execute_unwinders f
unction is missing:
Python Exception <class ‘NameError’> Installation error: gdb.execute_unwinders f
unction is missing:
Python Exception <class ‘ModuleNotFoundError’> No module named ‘gdb’:
#0 0x0000000076e2b1d1 in ntdll!DbgBreakPoint ()
from C:\Windows\SYSTEM32\ntdll.dll
#1 0x0000000076eb93c8 in ntdll!DbgUiRemoteBreakin ()
from C:\Windows\SYSTEM32\ntdll.dll
Python Exception <class ‘NameError’> Installation error: gdb.execute_unwinders f
unction is missing:
#2 0x0000000076bb59cd in KERNEL32!BaseThreadInitThunk ()
from C:\Windows\system32\kernel32.dll
Python Exception <class ‘NameError’> Installation error: gdb.execute_unwinders f
unction is missing:
#3 0x0000000076e1385d in ntdll!RtlUserThreadStart ()
from C:\Windows\SYSTEM32\ntdll.dll
Python Exception <class ‘NameError’> Installation error: gdb.execute_unwinders f
unction is missing:
#4 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb)

I just removed the last version, installed the latest, started KICad and changed project, opened the schematic and then selected the pcb icon. Result was a freeze. Closing KiCad made the not responding, force close dialog. Unfortunately drmingw did not get called.

Did you first install it from command line? You have to open a command shell as administrator, go to drmingw directory and run “drmingw.exe -i”. Only then it will be called automatically.

Before using gdb you have to compile the executables (KiCAD etc.) with debug symbols enabled. This is typically not done with an executable deemed for release because the file size will become huge.

I know that, but don’t know the details on Windows. I just hoped the nightly builds would have some information built in. What’s the reason to bundle the debugger if it can’t be used with the binaries? For reference, the suggestion came from @nickoe here: https://bugs.launchpad.net/kicad/+bug/1814053.

I would like to have debugging information in the nightly builds instead of huge component libraries.

EDIT: yes, I use nightly builds on Windows, not stable releases. I compile on Linux but not on Windows.

gdb on windows hasn’t been used or tested much see comment #7 in #1750993 discussion

Yes, installed as administrator and got a message that drmingw was the default debugger

You might have a look at http://docs.kicad.org/doxygen/md_Documentation_development_compiling.html, chapter “Building KiCad on Windows”.

To enable debugging with gdb, you will need to generate a debug build, similar as you were doing when using Linux.

All this building of KiCad is done within the MSYS2 shell, that provides you a Linux like environment, with bash, gcc, gdb etc under Windows.

I want to avoid building myself on windows. Technically it’s not impossible but in this case the result, namely getting the crash and backtrace, is not guaranteed and according to my experience KiCad’s winbuilder is slow and heavy to use, and I don’t know how to configure it for my needs. I can’t practically use it at work where I need the packages. If the crash was repeatable I would be willing to do it, but not under these circumstances.

I would not do that either. But then gdb is useless.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.