Education Project/Effort/Math baseline alignment/Debuging starmath

From Apache OpenOffice Wiki
Jump to: navigation, search

Milestone

Current Build is m245

install it wherever ( Desktop is a good option on Mac OS X)


Debug

What is the problem ?

all libmath are stripped by default, and you'll have to add the symbols for debugging. Thus you'll have to rebuild starmath, and symlink with the new math libs.

The problem is, since sb71 integration, use symlinks with libs is just a workaround. See [issue 83548 for more information ]

A patch for linkoo

Waiting, the following patch (thanks to Kendy !! ) should allow linkoo to work as expected : [patch for linkoo]

Apply the patch

Just put it in the root dir ( the one containing all OpenOffice.org sources), and do :

1) fake application ( using --dry-run option )

patch --dry-run -p0 <fix-linkoo_new.diff

2) if nothing bad occurs (excepted some fuzz) apply it for true :

patch -p0 <fix-linkoo_new.diff


With this patch applied, linkoo should work as expected. Please note this is a workaround, to make linkoo work for debug purpose.

Process

1) Build adding rectangles (for baselines and co )

-> uncomment line 93 in node.cxx : all formulas will be drawn with colored lines giving all alignment information ( Top Bottom Baseline when existing ..etc ) -> See the screenshots below

2) Build starmath again using :

cd starmath

mv unxmacxi.pro unxmacxi.pro_backup /* adapt to your architecture / OS */ build, debug="something_but_not_empty"

3) if never done, run linkoo

Important: one time only !!

Method :

4) launch OpenOffice.org

Should work out of the box :)


5) find the processus number of soffice.bin

To find the correct processus number correponding to OpenOffice.org binary execution, just run the following command line in a terminal :

ps ax | grep soffice.bin | grep -v grep

For example:

ordinateur-de-eric-b-2:~ ericb$ ps ax | grep soffice.bin | grep -v grep 11666 ?? S 0:00.56 /Applications/OpenOffice.org 2.4.app/Contents/MacOS/soffice.bin -psn_0_51511297

-> the processus number is 11666


6) In a terminal, run gdb

ordinateur-de-eric-b-2:~ ericb$ gdb -q (gdb)

... and attach the process number corresponding to soffice.bin

(gdb) attach 11666
Attaching to process 11666.
Reading symbols for shared libraries . done
Reading symbols for shared libraries ............................................................................................................................................. done
0x90009bf7 in mach_msg_trap ()

Interesting breakpoints

SmRectangleNode::Arrange ( starmath/source/node.cxx, line 2329 )

SmSubSupNode::Arrange ( starmath/source/node.cxx, line 1437 )

SmMathSymbolNode::Arrange ( starmath/source/node.cxx, line 2731 )

SmBinVerNode::Arrange ( starmath/source/node.cxx, line 1087 )

gdb completion

As preliminary, don't forget to use gdb completion feature: it's great and very usefull when you have to choose between several possibilities, like the same but overloaded method ... etc.

Principle: write the first letters of the word you want to write, and when sure, hit TAB key ( hit it several times if needed )

- either there is only one solution, and the word will be simply completed (nice, isn't it ? ) - or several solution will be proposed, and you'll have to decide which one use ..


How to add breakpoints ?

A breakpoint is an extremely helpfull way to stop -repeatably and safely- the binary execution, and analyse what happens with the code, modify on the fly, test other values ..etc

Several possibilities can be used there, to add a breakpoint :

1) specify the line :

Insert a breakpoint line 1234 in node.cxx :

(gdb) b node.cxx:1234


2) specify the method:

Insert a breakpoint when a method is called :

(gdb) b 'SmBinVerNode::Arrange'

Note: when the same method is overloaded, you can add the arguments to be sure to hit the right method.


3) conditional break :


Insert a breakpoint when the condition is verified :

(gdb) b cond ( (thing == true) || (foo != 0) )


First try:

type an equation containing a^2 + b^2 , exit formula ( ESC twice ) then enter the word "text"

then create a new equation containing %tau a^2 + b^2 and notice the difference.


First breakpoint: parse.cxx:398

When entering whatever letter, you hit a breakpoint. Just trace after it, and compare the two equations (e.g.)

Entering %tau a^2 + b^2 , you'll see the line starmath/source/parse.cxx:770


  • FIXME* : verify what makes ( if (aTmpRes.TokenType & KParseType::IDENTNAME)) true

Screeenshots

Issue972 tested case05.jpg

Issue972 tested case21.jpg

Personal tools