gnucash/HACKING

201 lines
8.0 KiB
Plaintext
Raw Normal View History

Hacking Guidelines
==================
This document is an introduction to hacking on GnuCash.
Related Documents
-----------------
In addition to this file, you should read the README file, which
2021-11-13 04:17:12 -06:00
explains the details of getting the git source, building GnuCash,
and creating patches for submission.
The src/doc/design directory contains a preliminary design document
which you should read as well. You should also feel free to hack on
the design document.
Coding Style Conventions
------------------------
Please refer to https://wiki.gnucash.org/wiki/CodingStandard.
==============
TIPS AND HINTS
==============
Building GnuCash in-tree
------------------------
This is generally discouraged. You should always use a separate build directory,
preferably outside of the source directory. If you really want a build directory
inside your source directory, make it a hidden one (starting with a '.'), to
keep intltool from incorrectly picking up translatable strings from the build directory.
Starting GnuCash from the build tree
------------------------------------
This should mostly work, but there may be corner cases where it behaves differently from
running gnucash from the target installation directory. You can tell cmake which
install directory to use via the command line switch '-DCMAKE_INSTALL_PREFIX='
Don't use '/usr' or '/usr/local' unless you're a package maintainer for a distro.
Instead choose /opt/gnc/git/ or even $HOME/gnc/git (or something similar).
Getting Trace Messages From GnuCash
-----------------------------------
See the doxygen comments in libgnucash/engine/qoflog.h (and .c)
Starting GnuCash in GDB
-----------------------
To run gdb on an installed version of gnucash (installed in /opt/gnc/unstable:)
% gdb /opt/gnc/unstable/bin/gnucash
You'll also probably want to know about these:
gdb> catch fork
gdb> set follow-fork-mode child
-----
It may be the case that running GDB from within emacs doesn't work for you,
with the following error:
[C-u M-x gdb /opt/gnucash-cvs/bin/gnucash
...in buffer *gud-gdb*:]
(gdb) attach <pid>
jsled needed to re-define a gud.el function as such:
(defun gud-gdb-massage-args (file args)
(let ((l (copy-list args)))
(nconc l (list "-cd" (expand-file-name default-directory) "-fullname"))))
jsled does not need the above with emacs-22, thankfully. It was getting quite tiresome.
Using Electric Fence with GnuCash
---------------------------------
There are currently no rules in our build system to build and run gnucash
or unit tests with Electric Fence.
2018-03-10 12:39:20 -06:00
It should probably be relatively straightforward to add this as all it
needs is to link with libefence.so (-lefence).
Fedora 27 ships an ElectricFence package containing that library and also
an executable 'ef' to run an arbitrary program with Electric Fence
guarding enabled. I have given it a quick spin on gnucash but it immediately
crashes. I haven't investigated whether this is because I should first have
linked gnucash with -lefence or because a real problem in GnuCash code.
Using Valgrind with GnuCash
---------------------------
-- run ${prefix}/bin/gnucash-valgrind
However, I did not find valgrind to be useful. It reported a bunch of
guile bugs, some g_hash_table bugs, and then the program exited prematurely
for no apparent reason. :-(
For the moment, gnucash-valgrind uses the suppressions in
src/debug/valgrind/valgrind-*.supp
2004-03-07 Joshua Sled <jsled@asynchronous.org> * HACKING: Added instructions about running under valgrind. * lib/gnucash_valgrind.supp: Added a large set of valgrind suppressions for both guile and gnucash. * src/register/ledger-core/gnc-ledger-display.c (gnc_ledger_display_template_gl): Change the reg_type to SEARCH_LEDGER so all the 'action' types appear. Bug#108833. * src/gnome/glade/sched-xact.glade: Remove unused 'ledger_status' widget. Bug#102269. * src/gnome-utils/gnc-dense-cal.c (gnc_dense_cal_draw_to_buffer): At least be consistent about the background coloring of the month labels, even if we're still not using GTK themeage correctly. * src/gnome-utils/gnc-dense-cal.c (gnc_dense_cal_destroy): Destroy the transient window when the widget is destroyed. Bug#103910. * src/gnome/dialog-scheduledxaction.c (gnc_ui_scheduled_xaction_editor_dialog_create): Make the advance and remind spin-buttons editable [Bug#94963]. * src/gnome/glade/sched-xact.glade: Change the upper bound on the advance and remind spins to 365 [days], with a page-size of 30 [days]. * src/gnome/dialog-sx-from-trans.c (gnc_sx_create_from_trans): Disallow the Scheduling of being-editing transactions in the Register, preventing a class of unbalacned SX template transactions from being entered and propogated through the system. See Bug#130330. * src/engine/FreqSpec.c (xaccFreqSpecGetFreqStr): Fix nasty memory-corruption issue; insufficent bounds checking on array index. Bug#125600. * src/gnome/dialog-sxsincelast.c (create_each_transaction_helper): Better handling of various error cases in transaction-creation. Bug#120311; Bug#130330. 2004-03-01 Joshua Sled <jsled@asynchronous.org> * src/gnome/dialog-scheduledxaction.c (gnc_sxed_check_consistent): Fix for part of Bug#121740 -- only allow auto-create SXes which have splits to be created. 2004-02-07 Joshua Sled <jsled@asynchronous.org> * src/gnome/dialog-scheduledxaction.c (editor_ok_button_clicked): * src/gnome-utils/gnc-frequency.c (gnc_frequency_save_state): * src/backend/file/gnc-freqspec-xml-v2.c (fs_none_handler): * src/engine/FreqSpec.c (xaccFreqSpecGetFreqStr): Adding "NONE" as an allowable FreqSpec [Bug#103968]. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9858 57a11ea4-9604-0410-9ed3-97b8803252fd
2004-03-10 19:17:14 -06:00
For valgrind-gnucash.supp, this comment was made (but is perhaps outdated
by now ?):
2004-03-07 Joshua Sled <jsled@asynchronous.org> * HACKING: Added instructions about running under valgrind. * lib/gnucash_valgrind.supp: Added a large set of valgrind suppressions for both guile and gnucash. * src/register/ledger-core/gnc-ledger-display.c (gnc_ledger_display_template_gl): Change the reg_type to SEARCH_LEDGER so all the 'action' types appear. Bug#108833. * src/gnome/glade/sched-xact.glade: Remove unused 'ledger_status' widget. Bug#102269. * src/gnome-utils/gnc-dense-cal.c (gnc_dense_cal_draw_to_buffer): At least be consistent about the background coloring of the month labels, even if we're still not using GTK themeage correctly. * src/gnome-utils/gnc-dense-cal.c (gnc_dense_cal_destroy): Destroy the transient window when the widget is destroyed. Bug#103910. * src/gnome/dialog-scheduledxaction.c (gnc_ui_scheduled_xaction_editor_dialog_create): Make the advance and remind spin-buttons editable [Bug#94963]. * src/gnome/glade/sched-xact.glade: Change the upper bound on the advance and remind spins to 365 [days], with a page-size of 30 [days]. * src/gnome/dialog-sx-from-trans.c (gnc_sx_create_from_trans): Disallow the Scheduling of being-editing transactions in the Register, preventing a class of unbalacned SX template transactions from being entered and propogated through the system. See Bug#130330. * src/engine/FreqSpec.c (xaccFreqSpecGetFreqStr): Fix nasty memory-corruption issue; insufficent bounds checking on array index. Bug#125600. * src/gnome/dialog-sxsincelast.c (create_each_transaction_helper): Better handling of various error cases in transaction-creation. Bug#120311; Bug#130330. 2004-03-01 Joshua Sled <jsled@asynchronous.org> * src/gnome/dialog-scheduledxaction.c (gnc_sxed_check_consistent): Fix for part of Bug#121740 -- only allow auto-create SXes which have splits to be created. 2004-02-07 Joshua Sled <jsled@asynchronous.org> * src/gnome/dialog-scheduledxaction.c (editor_ok_button_clicked): * src/gnome-utils/gnc-frequency.c (gnc_frequency_save_state): * src/backend/file/gnc-freqspec-xml-v2.c (fs_none_handler): * src/engine/FreqSpec.c (xaccFreqSpecGetFreqStr): Adding "NONE" as an allowable FreqSpec [Bug#103968]. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9858 57a11ea4-9604-0410-9ed3-97b8803252fd
2004-03-10 19:17:14 -06:00
This file needs to be cleaned up in two ways:
1/ There are a bunch of duplicate suppressions in the file.
* The suppressions in place were auto-generated by valgrind itself
2004-03-07 Joshua Sled <jsled@asynchronous.org> * HACKING: Added instructions about running under valgrind. * lib/gnucash_valgrind.supp: Added a large set of valgrind suppressions for both guile and gnucash. * src/register/ledger-core/gnc-ledger-display.c (gnc_ledger_display_template_gl): Change the reg_type to SEARCH_LEDGER so all the 'action' types appear. Bug#108833. * src/gnome/glade/sched-xact.glade: Remove unused 'ledger_status' widget. Bug#102269. * src/gnome-utils/gnc-dense-cal.c (gnc_dense_cal_draw_to_buffer): At least be consistent about the background coloring of the month labels, even if we're still not using GTK themeage correctly. * src/gnome-utils/gnc-dense-cal.c (gnc_dense_cal_destroy): Destroy the transient window when the widget is destroyed. Bug#103910. * src/gnome/dialog-scheduledxaction.c (gnc_ui_scheduled_xaction_editor_dialog_create): Make the advance and remind spin-buttons editable [Bug#94963]. * src/gnome/glade/sched-xact.glade: Change the upper bound on the advance and remind spins to 365 [days], with a page-size of 30 [days]. * src/gnome/dialog-sx-from-trans.c (gnc_sx_create_from_trans): Disallow the Scheduling of being-editing transactions in the Register, preventing a class of unbalacned SX template transactions from being entered and propogated through the system. See Bug#130330. * src/engine/FreqSpec.c (xaccFreqSpecGetFreqStr): Fix nasty memory-corruption issue; insufficent bounds checking on array index. Bug#125600. * src/gnome/dialog-sxsincelast.c (create_each_transaction_helper): Better handling of various error cases in transaction-creation. Bug#120311; Bug#130330. 2004-03-01 Joshua Sled <jsled@asynchronous.org> * src/gnome/dialog-scheduledxaction.c (gnc_sxed_check_consistent): Fix for part of Bug#121740 -- only allow auto-create SXes which have splits to be created. 2004-02-07 Joshua Sled <jsled@asynchronous.org> * src/gnome/dialog-scheduledxaction.c (editor_ok_button_clicked): * src/gnome-utils/gnc-frequency.c (gnc_frequency_save_state): * src/backend/file/gnc-freqspec-xml-v2.c (fs_none_handler): * src/engine/FreqSpec.c (xaccFreqSpecGetFreqStr): Adding "NONE" as an allowable FreqSpec [Bug#103968]. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9858 57a11ea4-9604-0410-9ed3-97b8803252fd
2004-03-10 19:17:14 -06:00
[--gen-suppressions=yes], and it makes no effort to output the
suppression only once.
2/ There are a bunch of suppressions which need to not be suppressions, but
2004-03-07 Joshua Sled <jsled@asynchronous.org> * HACKING: Added instructions about running under valgrind. * lib/gnucash_valgrind.supp: Added a large set of valgrind suppressions for both guile and gnucash. * src/register/ledger-core/gnc-ledger-display.c (gnc_ledger_display_template_gl): Change the reg_type to SEARCH_LEDGER so all the 'action' types appear. Bug#108833. * src/gnome/glade/sched-xact.glade: Remove unused 'ledger_status' widget. Bug#102269. * src/gnome-utils/gnc-dense-cal.c (gnc_dense_cal_draw_to_buffer): At least be consistent about the background coloring of the month labels, even if we're still not using GTK themeage correctly. * src/gnome-utils/gnc-dense-cal.c (gnc_dense_cal_destroy): Destroy the transient window when the widget is destroyed. Bug#103910. * src/gnome/dialog-scheduledxaction.c (gnc_ui_scheduled_xaction_editor_dialog_create): Make the advance and remind spin-buttons editable [Bug#94963]. * src/gnome/glade/sched-xact.glade: Change the upper bound on the advance and remind spins to 365 [days], with a page-size of 30 [days]. * src/gnome/dialog-sx-from-trans.c (gnc_sx_create_from_trans): Disallow the Scheduling of being-editing transactions in the Register, preventing a class of unbalacned SX template transactions from being entered and propogated through the system. See Bug#130330. * src/engine/FreqSpec.c (xaccFreqSpecGetFreqStr): Fix nasty memory-corruption issue; insufficent bounds checking on array index. Bug#125600. * src/gnome/dialog-sxsincelast.c (create_each_transaction_helper): Better handling of various error cases in transaction-creation. Bug#120311; Bug#130330. 2004-03-01 Joshua Sled <jsled@asynchronous.org> * src/gnome/dialog-scheduledxaction.c (gnc_sxed_check_consistent): Fix for part of Bug#121740 -- only allow auto-create SXes which have splits to be created. 2004-02-07 Joshua Sled <jsled@asynchronous.org> * src/gnome/dialog-scheduledxaction.c (editor_ok_button_clicked): * src/gnome-utils/gnc-frequency.c (gnc_frequency_save_state): * src/backend/file/gnc-freqspec-xml-v2.c (fs_none_handler): * src/engine/FreqSpec.c (xaccFreqSpecGetFreqStr): Adding "NONE" as an allowable FreqSpec [Bug#103968]. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9858 57a11ea4-9604-0410-9ed3-97b8803252fd
2004-03-10 19:17:14 -06:00
instead just not be generated by valgrind.
Look up exported and imported symbols
-------------------------------------
These commands may be useful to find out the library that actually
exported a particular symbol, and to check which import symbol one
particular library depends upon and where they are imported
from. Run these from the top-level of the build tree.
Note "lib64" below should be "lib" for a 32-bit build.
# Create a table of all exported symbols and where they come from
nm -A `find . -name '*.so'` | grep ' T ' | \
sed 's/^\([^:]*\).* \([^ ]*\)$/\1: \2/' > exportedsymbols
# For a particular library, check symbol import requirements,
# listing all symbols (needs the file from above)
A=lib64/libgnc-module.so && echo "$A requirements:" \
&& nm $A | grep ' U ' | sed 's/^.* \([^ ]*\)$/\1/' | \
grep -wFf- exportedsymbols
# For a particular library, check import requirements,
# summarized by library
A=lib64/libgnc-module.so && echo "$A requirements:" \
&& nm $A | grep ' U ' | sed 's/^.* \([^ ]*\)$/\1/' | \
grep -wFf- exportedsymbols | cut -d: -f1 | sort | uniq
# For a particular library, check import requirements,
# summarized by library, formatted for a cmake TARGET_LINK_LIBRARIES command
A=lib64/libgnc-gnome.so && echo "$A target link libraries:" \
&& nm $A | grep ' U ' | sed 's/^.* \([^ ]*\)$/\1/' | \
grep -wFf- exportedsymbols | cut -d: -f1 | sort | uniq | \
sed 's!.*/lib! !' | sed 's/.so$//'
# List all import requirements summarized by library for a full
# recursive directory tree
for A in `find lib64 -name '*.so'`; do \
echo -e "\n##$A requirements:" && nm $A | grep ' U ' | \
sed 's/^.* \([^ ]*\)$/\1/' | grep -wFf- exportedsymbols | \
cut -d: -f1 | sort | uniq; done
2014-02-20 00:11:22 -06:00
XCode project
-------------
There is an XCode project available in gnucash.xcodeproj at the root of the
source tree. This project can be used with XCode on a Macintosh to debug
GnuCash. It is not set up to build GnuCash, but only to debug it. Building must
be done using the normal command line tools.
Note this XCode project has not been updated since the big directory restructuring
preceding the 2.7.1 release. So it will currently not find source files where
it's expecting them.
2014-02-20 00:11:22 -06:00
This project is designed to be used with the X Window version of GnuCash, not
the native Quartz version. To use it you must build and install GnuCash into
directories "build" and "install" parallel to the source directory. Furthermore
the architecture dependent parts of the install are put in a subdirectory
"install/darwin".
To build, then, if the source directory is somewhere/gnucash you must create the
directories somewhere/build/darwin and somewhere/install/darwin/bin, cd into
somewhere/build/darwin and execute
../../gnucash/configure --prefix=../../install \
--exec-prefix=../../install/bin \
--enable-debug \
...other options...
make
make install
This will build and install a copy of GnuCash that can be debugged using the
XCode project.
The debug target in the project is set with a build tool of /usr/bin/true so
building in XCode won't hurt anything, it just won't do much. It is also set to
not launch GnuCash automatically, but rather to wait for it to be launched
manually. This lets you run it from a command prompt and see the console output
which can often be useful. Hence to initiate a debugging session in XCode, tell
XCode to run GnuCash then go to a terminal window and launch install/darwin/bin/gnucash
with whatever options you want. XCode will notice that it has been launched and
attach to the process.
Since there seems to be no way to make the path to the executable a relative
path, you must make one change to the debug scheme before you can run gnucash
under XCode. In XCode 5 (other versions may be different) go to
Product->Scheme->Edit Scheme and select the "info" tab of the "Run gnucash"
pane. Select "Other..." in the "Executable" menu and select the installed binary
for gnucash in the resulting file open dialog. This should be
install/darwin/bin/gnucash as described above. This, and the act of opening the
project in XCode, will change some of the files in the XCode project directory.
You can, or course, commit these locally, but please don't push them upstream.