Difference between revisions of "Windows Debugging"
(Move Console output up; remove install.sh) |
m (→Debugging with gdb: 2.4.0 before 2.2.9) |
||
Line 19: | Line 19: | ||
In addition to [[Stack Trace]], here are a few instructions on how to run gnucash under gdb on Windows: | In addition to [[Stack Trace]], here are a few instructions on how to run gnucash under gdb on Windows: | ||
* Install "gdb" from mingw.org [http://downloads.sourceforge.net/mingw/gdb-6.3-1.exe] | * Install "gdb" from mingw.org [http://downloads.sourceforge.net/mingw/gdb-6.3-1.exe] | ||
+ | *'''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. | ||
* '''GnuCash 2.2.9 and older''' | * '''GnuCash 2.2.9 and older''' | ||
:* Modify the installed "bin\gnucash.cmd" script by inserting one and changing one line. It should end like | :* Modify the installed "bin\gnucash.cmd" script by inserting one and changing one line. It should end like | ||
Line 25: | Line 30: | ||
::Be careful to use the actual paths in which you have installed gdb.exe | ::Be careful to use the actual paths in which you have installed gdb.exe | ||
:* Then start gnucash as usual | :* Then start gnucash as usual | ||
− | |||
− | |||
− | |||
− | |||
− | |||
*'''For all versions''': this will open a gdb prompt | *'''For all versions''': this will open a gdb prompt | ||
* Type <tt>run</tt> at the gdb prompt. | * Type <tt>run</tt> at the gdb prompt. |
Revision as of 18:59, 19 December 2019
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).
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, [1] 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
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 [2]
- 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.
- 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
- 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.