Difference between revisions of "Windows Debugging"

From GnuCash
Jump to: navigation, search
(Console output and exetype: Use URL templates in links)
(Exetype: remove references to MSYS and install.sh)
Line 4: Line 4:
 
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 [[Windows#Error messages, Trace file|here (Windows specific)]] and [[Tracefile|here (More generic)]].
 
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 [[Windows#Error messages, Trace file|here (Windows specific)]] and [[Tracefile|here (More generic)]].
  
== Console output and exetype ==
+
== Changing the Exetype to See Console Output ==
 
All executables and DLLs on Windows operate in one of a few different subsystems, most of them either in <tt>Console</tt> or <tt>GUI</tt> (also called <tt>Windows</tt>).  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, [{{ListURL}}/pipermail/gnucash-user/2007-April/020151.html] lists a few possible ways.  
 
All executables and DLLs on Windows operate in one of a few different subsystems, most of them either in <tt>Console</tt> or <tt>GUI</tt> (also called <tt>Windows</tt>).  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, [{{ListURL}}/pipermail/gnucash-user/2007-April/020151.html] 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 {{GitURL}}/gnucash-on-windows/blob/master/exetype.pl
+
The easiest option if you don't have any further build tools available is probably the third one from that mail:
and type
+
# Fetch {{GitURL}}/gnucash-on-windows/blob/master/exetype.pl
exetype.pl gnucash-bin.exe console
+
# [[Online_Quotes#Installing_Perl_on_Windows|Install Perl]], if not already done for [[Online Quotes]] and
 
+
# start cmd.exe type <syntaxhighlight lang="bat">
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"):
+
exetype.pl gnucash-bin.exe console
    qpushd $_INSTALL_UDIR/bin
+
</syntaxhighlight>
    exetype gnucash-bin.exe console
 
    qpopd
 
  
 
== Debugging with gdb ==
 
== Debugging with gdb ==

Revision as of 21:48, 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).

Changing the Exetype to See Console Output

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:

  1. Fetch https://github.com/Gnucash/gnucash-on-windows/blob/master/exetype.pl
  2. Install Perl, if not already done for Online Quotes and
  3. start cmd.exe type
    exetype.pl gnucash-bin.exe console
    

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.