Windows Debugging

From GnuCash
Revision as of 18:49, 19 December 2019 by Fell (talk | contribs) (Abstract; Recover Notes section which was removed in https://wiki.gnucash.org/wiki/index.php?title=Building_on_Windows&oldid=12617)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Troubleshooting under Windows is slightly different from POSIX conform operating systems. The differences are handled here.

Error messages, Trace file

When running into problems when running GnuCash, the trace file is usually your first stop to look for errors. You will find more details on this file here (Windows specific) and here (More generic).

Debugging with gdb

In addition to Stack Trace, here are a few instructions on how to run gnucash under gdb on Windows:

  • Install "gdb" from mingw.org [1]
  • GnuCash 2.2.9 and older
  • Modify the installed "bin\gnucash.cmd" script by inserting one and changing one line. It should end like
    set PATH=C:\Program Files\gdb\bin;%PATH%
    start gdb --args gnucash-bin %*
Be careful to use the actual paths in which you have installed gdb.exe
  • Then start gnucash as usual
  • GnuCash 2.4.0 and more recent
  • Open a Windows command prompt and type:
    set PATH=C:\Program Files\gdb\bin;%PATH%
    gdb "C:\Program Files\gnucash\bin\gnucash"
Be careful to use the actual paths in which you have installed gdb and gnucash respectively.
  • For all versions: this will open a gdb prompt
  • Type run at the gdb prompt.
  • Then provoke the crash and type backtrace or shorthand bt at the gdb prompt to obtain the backtrace, as explained on Stack Trace as well.

(2.2.9 and older only)If you are working in a MinGW shell, you may want to change and call the bin\gnucash script instead and use exec start gdb --args gnucash-bin "$@" to make Ctrl-C actually work.

If you build gnucash with the help of install.sh, make sure you export DISABLE_OPTIMIZATIONS=yes in packaging/win32/custom.sh to include debugging symbols and avoid optimizations that complicate debugging.

You can provide even better stack traces if you tell gdb where in memory dynamically loaded modules got mapped to, because otherwise function calls into those are only written as '??'. See here and here for a way to do this.

To enter [ and ], use set editing off.

install.sh

  • To debug install.sh, change set -e to set -ex at the top of it.

Console output and exetype

All executables and DLLs on Windows operate in one of a few different subsystems, most of them either in Console or GUI (also called Windows). Basically, executables in Console always start up in a new console window and print output for stdout und stderr to it, whereas ones in GUI do not open windows and are pretty quiet, even in console windows. If you want to change that subsystem type, because you want to see debugging output or hide unnecessary console windows, [2] lists a few possible ways.

The easiest option if you don't have any further build tools available is probably the third one from that mail: Install the MSYS program (needed for building GnuCash) from the pointer at the top section of this page, fetch https://github.com/Gnucash/gnucash-on-windows/blob/master/exetype.pl and type

exetype.pl gnucash-bin.exe console

If you are building gnucash with install.sh, you might want to automate this step. To do so, just add the following lines to the function make_install in your local install.sh (after "make install"):

   qpushd $_INSTALL_UDIR/bin
   	exetype gnucash-bin.exe console
   qpopd