<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openoffice.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ef</id>
	<title>Apache OpenOffice Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openoffice.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ef"/>
	<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/wiki/Special:Contributions/Ef"/>
	<updated>2026-11-23T20:23:10Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Debugging&amp;diff=20159</id>
		<title>Debugging</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Debugging&amp;diff=20159"/>
		<updated>2006-11-09T12:00:09Z</updated>

		<summary type="html">&lt;p&gt;Ef: /* dbglevel commandline variable for build */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This section assumes use of [[wikipedia:GNU Debugger|gdb]], from the console. There are also specific notes on [[Windows Debugging]] and hints on [[Debug Build Problems|Build Problems Debugging]]&lt;br /&gt;
&lt;br /&gt;
== Building with debugging symbols ==&lt;br /&gt;
&lt;br /&gt;
OO.o includes a way to add debugging code in per module, via&lt;br /&gt;
the &amp;lt;code&amp;gt;build debug=true&amp;lt;/code&amp;gt; command in each module.&lt;br /&gt;
This also adds lots of runtime assertions,&lt;br /&gt;
churning warnings etc. in addition to debug symbols - which&lt;br /&gt;
can be useful. To do just a plain build with debug symbols&lt;br /&gt;
though use &amp;lt;code&amp;gt;build debug=true dbg_build_only=true&amp;lt;/code&amp;gt;&lt;br /&gt;
or in later versions use &amp;lt;code&amp;gt;build debug=true dbglevel=2&amp;lt;/code&amp;gt; for max&lt;br /&gt;
output and dbglevel=1 or 0 for less output.&lt;br /&gt;
&lt;br /&gt;
You can also configure OO.o with --enable-symbols to build with symbolic generation.&lt;br /&gt;
&lt;br /&gt;
== gdb invocation ==&lt;br /&gt;
&lt;br /&gt;
If you debug with gdb, you may find that execution stops due to signals at inappropiate locations, especially if running against libgcj and need to debug ignoring its [http://gcc.gnu.org/java/gdb.html garbage-collection]. Best invocation is...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gdb ./soffice.bin&lt;br /&gt;
(gdb) handle SIGPWR nostop noprint&lt;br /&gt;
(gdb) handle SIGXCPU nostop noprint&lt;br /&gt;
(gdb) handle SIG33 nostop noprint&lt;br /&gt;
(gdb) run -norestore -writer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
replace -writer with -draw/-impress/-calc/... as appropiate. The -norestore option prevents display of the crash reporter (as one frequently kills office during debugging).&lt;br /&gt;
&lt;br /&gt;
== Starting at the beginning ==&lt;br /&gt;
&lt;br /&gt;
We start in &amp;#039;main&amp;#039; with a sal wrapper, that calls&lt;br /&gt;
vcl/source/app/svmain.cxx (SVMain). It invokes Main on&lt;br /&gt;
pSVData-&amp;amp;gt;mpApp; but pSVData is an in-line local. To&lt;br /&gt;
debug this use the pImplSVData global variable. eg:&lt;br /&gt;
&lt;br /&gt;
      p pImplSVData-&amp;amp;gt;maAppData&lt;br /&gt;
&lt;br /&gt;
This &amp;#039;Main&amp;#039; method is typically: &amp;lt;code&amp;gt;desktop/source/app/app.cxx (Main).&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examining strings ==&lt;br /&gt;
&lt;br /&gt;
We have [[Hacking#Can_I_get_a_char_.2A.2C_please.3F|already]] seen that OO.o has&lt;br /&gt;
it&amp;#039;s own set of string classes, none of which gdb understands.&lt;br /&gt;
You need to use:&lt;br /&gt;
&amp;lt;code&amp;gt;(gdb) print dbg_dump(sWhatEver)&amp;lt;/code&amp;gt; to print the contents&lt;br /&gt;
of a UniString/ByteString/rtl::OUString/rtl::OString regardless&lt;br /&gt;
of the type when debugging C++ code. See Caolan&amp;#039;s &lt;br /&gt;
[http://www.skynet.ie/~caolan/TechTexts/GdbUnicodePrinting.html write-up]&lt;br /&gt;
for details.&lt;br /&gt;
&lt;br /&gt;
== Getting the build order right ==&lt;br /&gt;
&lt;br /&gt;
The build dependencies of the modules are clearly crucial to&lt;br /&gt;
getting a clean build. When you type &amp;#039;build&amp;#039; in a module, first&lt;br /&gt;
build examines prj/build.list, eg.&amp;lt;code&amp;gt;neon/prj/build.lst&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
        xh      neon  :  soltools external expat NULL&lt;br /&gt;
&lt;br /&gt;
this specifies that &amp;#039;soltools&amp;#039;, &amp;#039;external&amp;#039; and &amp;#039;expat&amp;#039; have to&lt;br /&gt;
be satisfactorily built and delivered before neon can be built.&lt;br /&gt;
Occasionally these rules get broken, and people don&amp;#039;t notice for&lt;br /&gt;
a while.&lt;br /&gt;
&lt;br /&gt;
== It crashes, but only in gdb ==&lt;br /&gt;
&lt;br /&gt;
What fun &amp;amp;mdash; you symlinked desktop/unxlngi4.pro/bin/soffice to&lt;br /&gt;
soffice.bin in your install tree didn&amp;#039;t you. That works fine&lt;br /&gt;
if you just run it, but it seems gdb unpacks the symlink and&lt;br /&gt;
passes a fully qualified path as argv[0], which defeats the&lt;br /&gt;
hunting for the binary in the path, so it assigns the program&lt;br /&gt;
base path as &amp;lt;code&amp;gt;/opt/OpenOffice/OOO_STABLE_1/desktop/unxlngi4.pro/bin&amp;lt;/code&amp;gt;&lt;br /&gt;
and starts looking for (eg. applicat.rdb) in there. Of course&lt;br /&gt;
when it fails to find any setup information, it silently&lt;br /&gt;
crashes somewhere else yards away from the original problem.&lt;br /&gt;
&lt;br /&gt;
== It crashes, but doesn&amp;#039;t crash ==&lt;br /&gt;
&lt;br /&gt;
For various reasons signal handlers are trapped and life&lt;br /&gt;
can get rather confusing; thus it&amp;#039;s best for builders to&lt;br /&gt;
apply something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- sal/osl/unx/signal.c&lt;br /&gt;
+++ sal/osl/unx/signal.c&lt;br /&gt;
@@ -188,6 +188,8 @@ static sal_Bool InitSignal()&lt;br /&gt;
             bSetILLHandler = sal_True;&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
+       bSetSEGVHandler = bSetWINCHHandler = bSetILLHandler = bDoHardKill = sal_False;&lt;br /&gt;
+&lt;br /&gt;
        SignalListMutex = osl_createMutex();&lt;br /&gt;
 &lt;br /&gt;
        act.sa_handler = SignalHandlerFunction;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== I can&amp;#039;t find the code from the trace ==&lt;br /&gt;
&lt;br /&gt;
Some methods, are described as having a special linkage, such that&lt;br /&gt;
they can be used in callbacks; these typically have a prefix:&lt;br /&gt;
&amp;#039;LinkStub&amp;#039;, so search for the latter part of the identifier in a&lt;br /&gt;
freetext search. eg.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      IMPL_LINK( Window, ImplHandlePaintHdl, void*, EMPTYARG )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
builds the &amp;#039;LinkStubImplHandlePaintHdl&amp;#039; method.&lt;br /&gt;
&lt;br /&gt;
== How can I re-build just the files I see in the trace ==&lt;br /&gt;
&lt;br /&gt;
Often when you run gdb on a build without debugging symbols, you get&lt;br /&gt;
an unhelpful gdb trace, but yet you can&amp;#039;t afford the time/space to&lt;br /&gt;
recompile all of OO.o with debugging symbols. Thus we have created&lt;br /&gt;
a small perl helper, which will hunt for &amp;amp;amp; touch files containing&lt;br /&gt;
the symbols from your trace. This sub-set can then be re-built with&lt;br /&gt;
debugging enabled for a better trace next time around:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    gdb ./soffice.bin&lt;br /&gt;
    ...&lt;br /&gt;
    bt&lt;br /&gt;
#0  0x40b4e0a1 in kill () from /lib/libc.so.6&lt;br /&gt;
#1  0x409acfe6 in raise () from /lib/libpthread.so.0&lt;br /&gt;
#2  0x447bcdbd in SfxMedium::DownLoad(Link const&amp;amp;amp;) () from ./libsfx641li.so&lt;br /&gt;
#3  0x447be151 in SfxMedium::SfxMedium(String const&amp;amp;amp;, unsigned short, unsigned char, SfxFilter const*, SfxItemSet*) ()&lt;br /&gt;
   from ./libsfx641li.so&lt;br /&gt;
#4  0x448339d3 in getCppuType(com::sun::star::uno::Reference&amp;lt;com::sun::star::document::XImporter&amp;gt; const*) () from ./libsfx641li.so&lt;br /&gt;
...&lt;br /&gt;
    quit&lt;br /&gt;
    cd base/OOO_STABLE_1/sfx2&lt;br /&gt;
    ootouch SfxMedium&lt;br /&gt;
    build debug=true&lt;br /&gt;
    &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus, all files referencing / implementing anything with&lt;br /&gt;
SfxMedium will be touched, and hence rebuilt with debugging&lt;br /&gt;
symbols.&lt;br /&gt;
&lt;br /&gt;
== How can I re-build all the files in one source directory ==&lt;br /&gt;
&lt;br /&gt;
If you want to recompile the code in just your current directory, you can&lt;br /&gt;
use the killobj dmake target to remove the object files:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    dmake killobj&lt;br /&gt;
    dmake&lt;br /&gt;
    &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== It always crashes in sal_XErrorHdl ==&lt;br /&gt;
&lt;br /&gt;
You are a victim of asynchronous X error reporting;&lt;br /&gt;
&amp;lt;code&amp;gt;export SAL_SYNCHRONIZE=1&amp;lt;/code&amp;gt; will make all the X traffic&lt;br /&gt;
synchronous, and report the error by the method that caused it,&lt;br /&gt;
it&amp;#039;ll also make OO.o far slower, and the timing different.&lt;br /&gt;
&lt;br /&gt;
== It silently fails to load my word file ==&lt;br /&gt;
&lt;br /&gt;
Caolan suggests: put breakpoints in ww8par.cxx top and tail of&lt;br /&gt;
SwWW8ImplReader::LoadDoc, and confirm that the document gets as far&lt;br /&gt;
as the import filter.&lt;br /&gt;
&lt;br /&gt;
A handy human place to put a breakpoint is in &lt;br /&gt;
SwWW8ImplReader::ReadPlainChars, you can see chunks of text as&lt;br /&gt;
they are read in. Alternatively SwWW8ImplReader::AppendTxtNode as&lt;br /&gt;
each paragraph is inserted.&lt;br /&gt;
&lt;br /&gt;
== How do I use the debug console ? ==&lt;br /&gt;
&lt;br /&gt;
So OO.o contains some hefty debugging infrastructure; pictured&lt;br /&gt;
[http://go-oo.org/images/debug-window.png here]&lt;br /&gt;
&lt;br /&gt;
Enabling it is pretty easy - what you need is a so-called [[Non_Product_Build|Non-Product Build]].&lt;br /&gt;
&lt;br /&gt;
By default, an OpenOffice.org build is a Product Build, i.e. ready for release after completion. If you specifiy the &amp;lt;code&amp;gt;--enable-dbgutil&amp;lt;/code&amp;gt; switch during &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt;, then your environment will be prepared for a [[Non_Product_Build|Non-Product Build]] - with lots of additional diagnostic tools.&lt;br /&gt;
&lt;br /&gt;
Note that libraries from product and non-product builds are usually incompatible, so don&amp;#039;t mix them in the same installation.&lt;br /&gt;
&lt;br /&gt;
For available tools in non-product builds, have a look at the various &amp;lt;code&amp;gt;DBG_foo&amp;lt;/code&amp;gt; macros in &amp;lt;code&amp;gt;tools/debug.hxx&amp;lt;/code&amp;gt;, or, if you already are knowledgeable about this, let others participate by writing your knowledge down here.&lt;br /&gt;
&lt;br /&gt;
To actually fire up the debug settings dialog, press &amp;lt;ctrl&amp;gt;&amp;lt;alt&amp;gt;&amp;lt;shift&amp;gt;-D.&lt;br /&gt;
&lt;br /&gt;
== Excel Interop debugging ==&lt;br /&gt;
&lt;br /&gt;
This is fairly easy; edit sc/source/filter/inc/biffdump.hxx,&lt;br /&gt;
define EXC_INCL_DUMPER to 1, and re-build &amp;#039;sc&amp;#039;. Also, copy&lt;br /&gt;
sc/source/filter/excel/biffrecdumper.ini to ~. Then run&lt;br /&gt;
&amp;lt;code&amp;gt;soffice.bin foo.xls&amp;lt;/code&amp;gt; and you should get a&lt;br /&gt;
foo.txt with the debug data in it.&lt;br /&gt;
&lt;br /&gt;
== The trace shows a crash in &amp;#039;poll&amp;#039; ==&lt;br /&gt;
&lt;br /&gt;
OO.o is a fairly threaded program, you&amp;#039;re prolly just looking&lt;br /&gt;
at the wrong thread: there are not likely to be bugs in poll.&lt;br /&gt;
Use &amp;lt;code&amp;gt;thread apply all backtrace&amp;lt;/code&amp;gt; to get a backtrace&lt;br /&gt;
of all threads - this will most likely fail. When it does do:&lt;br /&gt;
&amp;lt;code&amp;gt;thread 1&amp;lt;/code&amp;gt; then &amp;lt;code&amp;gt;bt&amp;lt;/code&amp;gt; - most crashers&lt;br /&gt;
occur in the &amp;#039;main&amp;#039; thread.&lt;br /&gt;
&lt;br /&gt;
== What does this trace mean ? ==&lt;br /&gt;
&lt;br /&gt;
There are several typical stack-traces that come up again&lt;br /&gt;
and again, one would be:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;pre&amp;gt;#15 0x4164a501 in raise () from /lib/tls/libc.so.6&lt;br /&gt;
#16 0x4164bcd9 in abort () from /lib/tls/libc.so.6&lt;br /&gt;
#17 0x415fb5a5 in std::set_unexpected ()&lt;br /&gt;
   from /home/mnagashree/m72install/program/libstdc++.so.5&lt;br /&gt;
#18 0x415fb5e2 in std::terminate ()&lt;br /&gt;
   from /home/mnagashree/m72install/program/libstdc++.so.5&lt;br /&gt;
#19 0x415fb69c in __cxa_rethrow ()&lt;br /&gt;
    &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This section of trace means (essentially) that an&lt;br /&gt;
exception was thrown - but there was no-one trying to&lt;br /&gt;
catch it. Often this means there was a missing&lt;br /&gt;
&amp;#039;try {} catch()&amp;#039; clause in one of the calling frames.&lt;br /&gt;
&lt;br /&gt;
A great way to debug exceptions is to add a breakpoint&lt;br /&gt;
in catch/throw, do this with &amp;lt;code&amp;gt;catch throw&amp;lt;/code&amp;gt; or &lt;br /&gt;
&amp;lt;code&amp;gt;catch catch&amp;lt;/code&amp;gt; in gdb.&lt;br /&gt;
&lt;br /&gt;
== STLport and checking iterators ==&lt;br /&gt;
&lt;br /&gt;
The STL is a powerful tool but it also makes it easy - in the grand old C/C++ tradition - to shoot one selves in the foot, as we all know. STL containers and algorithms are now pervasive in OOo, so there is a need to validate the use of STL constructs in OO.o to find hidden problems.&lt;br /&gt;
&lt;br /&gt;
Fortunately the [http://www.stlport.org/ STLport library] - the default STL implementation for OO.o - has a powerful debug mode, and it&amp;#039;s easy to use. Since SRC680 m128 it is possible to use the environment variable &amp;lt;code&amp;gt;USE_STLP_DEBUG&amp;lt;/code&amp;gt; to switch on the STLport debug mode, since SRC680 m150 it works for Windows, too&lt;br /&gt;
&lt;br /&gt;
The most useful part of the STLport debug mode is iterator checking. Doing the OO.o smoke test and some little additional random testing we already found a number of questionable STL constructs.&lt;br /&gt;
&lt;br /&gt;
Only code paths which are exercised will be tested by the STLport debug mode, though. If STLport finds a questionable STL usage it will throw an assertion and terminate. It is usually quite easy to extract a precise stack trace.&lt;br /&gt;
&lt;br /&gt;
Some notes:&lt;br /&gt;
* STLport debug mode iterators are no pointers! We&amp;#039;ve cleaned up all occurrences of the lazy - and wrong - usages of iterators as pointers in SRC680 m128/m150, but maybe something new has already crept in. This clean up also helps with other STL implementations, like the one which comes with gcc-4.x&lt;br /&gt;
* A complete recompile is necessary, the debug modes renders all objects with STL constructs binary incompatible&lt;br /&gt;
* The STLport debug mode breaks the complexity assertions of the STL. Theoretically some operations should be much slower in debug mode than in product mode. In practice I didn&amp;#039;t notice a real slowdown of OO.o.&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Ef</name></author>
	</entry>
</feed>