MacOSX Debug OpenOffice.org using XCode
Pre conditions : a complete Aqua build see AquaBuild
Contents
Prepare libvcl
rebuild vcl using debug="not_empty_string"
then do :
cd vcl touch aqua/source/gdi/salbmp.cxx build
Use Pavel's. script be sure you can use aqua double clicking on the bundle
Supposing the AquaBuild sources are located in ~/SRC680_m202 ( adapt to your tree ) , do : cd <install_dir>/Openoffice.org\ 2.2.app/Contents/program
rm -f libvcl* ln -s <AquaBuild_dir>/vcl/unxmacxi.pro/lib/libvcl* .
Note : don't forget the dot !!
Start Xcode
Create a new project
select empty project
Add existing Files
choose e.g. aquavcl_debug in home dir
then right click on aquavcl_debug icon (on top left) and select "add existing files"
choose <AquaBuild_dir/vcl> folder click on add
be sure to check "Create Folder References for any added folders"
vcl directory should appear as subfolder of aquavcl_debug
Add New Executables
now right click on Executables (on left ) and choose Add ->New custom executable
Fill the fields as follow :
Executable name : OpenOffice.org
Executable Path : <install_dir>/OpenOffice.org 2.2.app (you will edit this later - in XCode 2.4 it must have a value to enable finish)
Click on finish when done
Just after, a window should appear : "Executable OpenOffice.org Info"
Executable path should be <install_dir>/OpenOffice.org 2.2.app/Contents/program/soffice_bin (rename soffice.bin to soffice_bin)
Check Custom Custom Directory and put :
<install_dir>/OpenOffice.org 2.2.app/Contents/program
On menubar, run debugger and enjoy debugging :)
Change Debugging preferences
Xcode seems to have problems with breakpoints in not yet loaded libraries. To change this malbehavior go to Preferences -> Debugging and make sure that "Load symbols lazily" is unchecked.
Links
On the wiki : Debugging OpenOffice.org
Xemacs : Michael Sicotte wrote a very usefull blog entry about debugging OOo with XEmacs and GDB on Mac OS X
FAQ
Is it possible to build the complete set with symbols included ?
Currently not possible, and not advised.
is it possible to build some modules with symbols ?
Yes, and that's the simplest way to proceed. Some modules, like sal and vcl can be rebuilt using debug.
Example:
To rebuild sal with symbols included, do:
[bash,N]
cd sal
rm -rf unxmacxp.pro
build debug=true
and recopy the libs into the bundle. gdb will display the symbols, and make your life easier.
Note: debug string is tested, and DEBUG is active when debug string is not empty. So debug=t works too.
How change gdb options, and use e.g. -g -ggdb or -gdwarf-2 ?
To rebuild the module, you just have to modify the option in solenv/inc/unxmacx.mk, replacing -g with -ggdb
Known issues
Sometimes a build error, or a runtime error, may be seen in the normal build, but the error goes away when --enable-debug is used or if the module is compiled with debug=true.
The DEBUG build turns off optimisation, so this is a hint that compiler optimisation causes the error.
The error might be due to incorrect code or a compiler fault. Such errors might not be seen on all platforms,
and might not be seen in different compiler versions on one platform.
If the code can not be fixed there is a workaround using NOOPTFILES to build specified files with no optimisation.
Example:
jvmfwk on Mac OS X: build jvmfwk in m183 on Mac OS X Intel leads to Bus Error when javaldx is run.
Solution: use trial and error to rebuild individual files with debug=true. This proves the problem lies with vendorbase.cxx
Have a look in sc/source/core/data/makefile.mk for an example to use NOOPTFILES
To solve our problem: just add: NOOPTFILES= $(SLO)$/vendorbase.obj in the corresponding makefile.
Take care in case some .IF is needed to prevent interference with other platforms.
There's some additional information around debugging on Christians Page User:CL#2006-09-03