Changes

Jump to: navigation, search

Debugging OOo

16,691 bytes added, 13:48, 8 April 2009
no edit summary
== Lecture logs by Eric ==
= First Session One =
<pre>
1 : [11:54] <@ericb2> fardad: ok, let's go
412 : [13:31] <Kamots> thanks again, take care everyone
413 : [13:31] <@ericb2> thanks to all :-)
</pre>
= Second Session =
<pre>
1 : [12:04] <@ericb2> ok, let's start ?
2 : �01[12:04] <@fardad> we are ready (missing 3 students, but its their loss)
3 : [12:04] <@ericb2> ok
4 : [12:04] <@ericb2> Outline of the ClassRoom
5 : [12:04] <@ericb2> Prerequisites for the test
6 : [12:04] <@ericb2> Reminder about what happens when building in a module
7 : [12:04] <@ericb2> Add symbols in a library
8 : [12:04] <@ericb2> Introduction of gdb use
9 : [12:04] <@ericb2> Launch OOo using gdb
10 : [12:05] <@ericb2> Play with it (discovery)
11 : [12:05] <@ericb2> So today, we'll start playing with gdb + Ooo
12 : [12:06] <@ericb2> who does have a full OOo build at hand ?
13 : [12:06] <@ericb2> ok :)
14 : [12:06] <@ericb2> As pre-requisites , I'll suppose :
15 : [12:06] <@ericb2> - there is a complete build working already
16 : [12:06] <@ericb2> - there is a working installset , and we will launch it using the terminal
17 : [12:06] <@ericb2> Thus, if you want to redo at home, or later, you just have to read and try
18 : [12:06] <@ericb2> Reminder : what happens when something is built
19 : [12:07] <@ericb2> we'll use <module> for whatever subdir of the OOo tree, aka "module" most of the time
20 : [12:08] <@ericb2> <module>/prj/build.lst does contain the list of the subdirs containing a makefile
21 : [12:08] <@ericb2> Means: Every product is built in the output dir. e.g. : unxmacxi.pro on Mac Intel
22 : [12:08] <@ericb2> we have the same tree inside all the modules:
23 : [12:08] <@ericb2> unxmacxi.pro/bin
24 : [12:08] <@ericb2> unxmacxi.pro/lib
25 : [12:08] <@ericb2> unxmacxi.pro/inc
26 : [12:09] <@ericb2> ... and so on (look yourself )
27 : [12:09] <@ericb2> to rebuild a module, just remove this directory
28 : [12:09] <@ericb2> Once all the .o are build, the libs, and/or the binaries / resources / whatever are "delivered" from the unxmacxi.pro dir to the solver
29 : [12:11] <@ericb2> The information providing the list of what has to be delivered is always in : <module>/prj/d.lst
30 : [12:11] <@ericb2> these files are text files, using a "Windows" separator, but this is not a problem at all
31 : [12:13] <@ericb2> If we summarize : a normal build provides binaries like libraries, who are stripped when the are delivered. Between the unxmacxi.pro and their place in the "solver "
32 : [12:14] <@ericb2> Important: to be able to trace using gdb, we'll need to add symbols, lines of code and a lot of information inside the binaries
33 : [12:14] <@ericb2> Howto add symbols in a library ?
34 : [12:14] <@ericb2> 1) first approach
35 : [12:14] <@ericb2> -> look at configure extra option : --disable-strip-solver
36 : [12:15] <@ericb2> To verify by yourself, just place you at the root of the sources (since DEV300_m40, there is no longer config_office subdir)
37 : [12:15] <@ericb2> and do : ./configure --help | grep -4 solver
38 : [12:16] <@ericb2> you'll have several lines explaining the right option
39 : [12:16] <@ericb2> Tip : if you're familiar with configure, better read configure itself, more informative ;-)
40 : [12:17] <@ericb2> and if you know a bit of autoconf, you can even hack configure.in, and run autoconf to regenerate a new configure :)
41 : [12:18] <@ericb2> The first approach has a drawback : just a bit of information is inside the binary, and that's not enough most of the time, when you have a complex problem to solve
42 : [12:19] <@ericb2> 2) second approach
43 : [12:19] <@ericb2> consider only a part of the code, for tracing
44 : [12:20] <@ericb2> The method is equivalent to use --enable-debug at configure time, but nobody uses this option. the reason is simple : all libraries become huges, and OOo won't probably launch correctly.
45 : [12:21] <@ericb2> e.g. : the libsw (writer) becomes 660MB heavy
46 : �01[12:22] <@fardad> ericb2: when you say correctly, does it mean it will be too slow, or it will not function properly?
47 : [12:22] <Kamots> wow, that's a lot of extra weight
48 : [12:22] <@ericb2> fardad: yes, imagine 10 libs of 500MB every + some other 100MB and so on
49 : [12:23] <@ericb2> Kamots: I'll explain you how to proceed
50 : �01[12:23] <@fardad> wow, :o
51 : [12:24] <@ericb2> Other important information
52 : [12:24] <@ericb2> about assertions
53 : [12:24] <@ericb2> There is another option in configure
54 : [12:24] <@ericb2> --enable-dbgutil
55 : [12:25] <@ericb2> Include additional debugging utilities, such assertions, object counting, etc. Larger build.
56 : [12:25] <@ericb2> Independent from --enable-debug
57 : [12:25] <@ericb2> the *second one* does concern assertions in the code :
58 : [12:25] <@ericb2> DBG_ASSERT( !(rALR.flags & kATSGlyphInfoTerminatorGlyph),
59 : [12:25] <@ericb2> "ATSLayout::InitGIA(): terminator glyph not marked as deleted!" );
60 : [12:25] <@ericb2> -> if the condition is not verified -> boom .. and a window will appear, containing the message
61 : [12:26] <@ericb2> if --enable-dbgutil is not in the configure command line, assertions are not included
62 : [12:26] <@ericb2> As you understood, assertions are for development, not for end users ;-)
63 : [12:27] <@ericb2> So, we use to add symbols for debugging for some libs, in a given module only
64 : [12:27] <@ericb2> Counterpart : needs to rebuild the module
65 : [12:27] <@ericb2> The process is very simple :
66 : [12:28] <@ericb2> cd <module>
67 : [12:28] <@ericb2> mv unxmacxi.pro unxmacxi.pro_backup
68 : [12:28] <@ericb2> build debug=t
69 : [12:28] <@ericb2> Do *always* a backup of your build, because the binaries in the output tree, do match with stamps in the solver
70 : [12:29] <@ericb2> if you modify something, you'll have to redo a build, and a "deliver". Elser, the build can break at postprocess, or at then end, because the stamp between the solver and the module do not match
71 : [12:29] <@ericb2> that's just harmless, but if you are not aware, you can lose a while before someone explains you what happens
72 : [12:30] <@ericb2> As example, I'll rebuild a little lib , to show you the difference
73 : [12:31] <@ericb2> cd apple_remote/
74 : [12:31] <@ericb2> source ../MacOSXX86Env.Set.sh
75 : [12:31] <@ericb2> sorry, I forgot :-)
76 : [12:32] <@ericb2> mv unxmacxi.pro unxmacxi.pro_back
77 : [12:32] <@ericb2> build debug=t
78 : [12:32] <@ericb2> Important: whatever you put, will work
79 : [12:32] <@ericb2> t is one letter, but once the string is not empty, debug is true
80 : [12:33] <@ericb2> means all the code included between #ifdef DEBUG ... #endif or some other macros, will be included
81 : [12:34] <@ericb2> e.g. :
82 : [12:34] <@ericb2> #ifdef DEBUG
83 : [12:34] <@ericb2> // debug purpose
84 : [12:34] <@ericb2> NSLog(@"reset... (after listening to remote)");
85 : [12:34] <@ericb2> #endif
86 : [12:34] <@ericb2> -> in the terminal, I'll see the information
87 : [12:34] <@ericb2> NSLog is sort of cout
88 : �01[12:35] <@fardad> ic,
89 : [12:35] <@ericb2> After the rebuild :
90 : [12:35] <@ericb2> ls -l unxmacxi.pro/lib/libAppleRemotemxi.dylib
91 : [12:35] <@ericb2> -rwxr-xr-x 1 ericb ericb 159932 Feb 19 18:31 unxmacxi.pro/lib/libAppleRemotemxi.dylib
92 : [12:35] <@ericb2> ls -l unxmacxi.pro_back/lib/libAppleRemotemxi.dylib
93 : [12:35] <@ericb2> -rwxr-xr-x 1 ericb ericb 52436 Feb 12 14:31 unxmacxi.pro_back/lib/libAppleRemotemxi.dylib
94 : [12:36] <@ericb2> the first one does contain strings and a lot of other stuff
95 : [12:37] <@ericb2> Now .. Launch OOo in a terminal :)
96 : [12:37] <@ericb2> before, we'll copy the lib in the bundle
97 : [12:37] <IZBot> News from cws: native227: created
98 : [12:38] <@ericb2> For the rest, my bundle is in the Desktop/test_eraser folder (I'm on Mac OS X )
99 : [12:38] <@ericb2> Means, the Bundle is the dir : ~/Desktop/test_eraser/OpenOffice.org.app
100 : [12:38] <@ericb2> So, I'll open a terminal, and I'll do :
101 : [12:38] <@ericb2> cd ~/Desktop/test_eraser/OpenOffice.org.app/Contents/program
102 : [12:39] <@ericb2> the idea, is to start gdb form the directory containing soffice (the binary )
103 : [12:39] <@ericb2> and the command line is :
104 : [12:40] <@ericb2> gdb --args ~/Desktop/est.odp
105 : [12:40] <@ericb2> you'll see gdb tell you a lot of things. If you don't want to see that the next time, you can add -q (for quiet) option
106 : [12:41] <@ericb2> as you can see nothing happens :)
107 : [12:41] <@ericb2> the reason is: the binary is not "running"
108 : [12:42] <@ericb2> oops, sorry
109 : [12:42] <@ericb2> gdb --args soffice ~/Desktop/est.odp
110 : [12:42] <@ericb2> is the right command line
111 : [12:42] <@ericb2> to redo; just enter "q"
112 : [12:42] <@ericb2> and type the correct command
113 : [12:42] <@ericb2> now, type r ( shortcut for "run" )
114 : [12:43] <@ericb2> -> OOo will start
115 : [12:43] <@ericb2> and open the file
116 : [12:43] <@ericb2> in the terminal, you no longer have the control. To stop the execution, do "CTRL-C"
117 : [12:44] <@ericb2> Program received signal SIGINT, Interrupt.
118 : [12:44] <@ericb2> 0x90009cd7 in mach_msg_trap ()
119 : [12:44] <@ericb2> (gdb)
120 : [12:44] <@ericb2> OOo is stopped
121 : [12:44] <@ericb2> you can enter whatever command, like " info frame "
122 : [12:44] <@ericb2> to continue, type : c
123 : [12:45] <@ericb2> The result is : (gdb) c
124 : [12:45] <@ericb2> Continuing.
125 : [12:45] <@ericb2> and OOo is no longer stopped
126 : [12:45] <@ericb2> Add a breakpoint
127 : �01[12:45] <@fardad> amazing...
128 : [12:46] <@ericb2> fardad: I know this is difficult like that, but people will redo later, and ask whenever they want
129 : [12:46] <@ericb2> on the channel
130 : [12:46] <@ericb2> we'll explain them
131 : �01[12:46] <@fardad> I understand
132 : [12:46] <@ericb2> Let's add a breakpoint now
133 : [12:47] <@ericb2> to know whether breakpoints are set or not, the command is :
134 : [12:47] <@ericb2> info b
135 : [12:47] <@ericb2> (means info breakpoints)
136 : [12:47] <@ericb2> exactly :
137 : [12:47] <@ericb2> CTRL-C
138 : [12:47] <@ericb2> info b
139 : [12:48] <@ericb2> The result is :
140 : [12:48] <@ericb2> (gdb) info b
141 : [12:48] <@ericb2> No breakpoints or watchpoints.
142 : [12:48] <@ericb2> of course
143 : [12:48] <@ericb2> so let's set one
144 : [12:49] <@ericb2> Since only libAppleRemotemxi.dylib has symbols, I'll have to set one in whatever file included
145 : �01[12:52] <@fardad> oops
146 : �01[12:54] <@fardad> we lost eric!
147 : [12:54] <@ericb2> For instance :
148 : [12:54] <@ericb2> (gdb) l
149 : [12:54] <@ericb2> 113 #ifdef DEBUG
150 : [12:54] <@ericb2> 114 NSString* buttonName = nil;
151 : [12:54] <@ericb2> 115 #endif
152 : [12:54] <@ericb2> 116 if (pressedDown)
153 : [12:55] <@ericb2> 117 {
154 : [12:55] <@ericb2> 118 pressed = @"(pressed)";
155 : [12:55] <@ericb2> 119
156 : [12:55] <@ericb2> 120 #ifdef DEBUG
157 : [12:55] <@ericb2> 121 switch(buttonIdentifier)
158 : [12:55] <@ericb2> 122 {
159 : [12:55] <@ericb2> Current language: auto; currently objective-c
160 : [12:55] <@ericb2> (gdb)
161 : [12:55] <@ericb2> I can go up or continue
162 : [12:55] <@ericb2> and if I need info, I can check for the stack of frames
163 : [12:55] <@ericb2> (gdb) bt
164 : [12:56] <@ericb2> -> will return the frames, in *reverse* order. Means, the #0 is the last one, and #1 the one before .. and so on
165 : [12:56] <IZBot> no issue with number 1
166 : [12:56] <@ericb2> ooops :-)
167 : [12:56] <@ericb2> Lets choose "n" for next
168 : [12:57] <@ericb2> The result is :
169 : [12:57] <@ericb2> (gdb) n
170 : [12:57] <@ericb2> 121 switch(buttonIdentifier)
171 : [12:57] <@ericb2> IMPORTANT: the current line is NOT executed yet
172 : [12:57] <@ericb2> e.g. if you have a= 10;
173 : [12:57] <@ericb2> p a
174 : [12:57] <@ericb2> can return whatevert
175 : [12:58] <@ericb2> *only* n will validate the line. This is the context
176 : [12:58] <@ericb2> execution context
177 : [12:58] <@ericb2> n will continue ..
178 : [12:58] <@ericb2> (gdb) n
179 : [12:58] <@ericb2> 126 case kRemoteButtonPlay: buttonName = @"Play"; break; // MEDIA_COMMAND_PLAY
180 : [12:58] <@ericb2> and of course, we can check for the variable :
181 : [12:58] <@ericb2> (gdb) p buttonIdentifier
182 : [12:58] <@ericb2> $1 = kRemoteButtonPlay
183 : [12:59] <@ericb2> so, it means the slideshow will start ...
184 : [13:00] <@ericb2> Next instruction :
185 : [13:00] <@ericb2> (gdb) n
186 : [13:00] <@ericb2> 140 [ self postTheEvent:buttonIdentifier modifierFlags: 0 ];
187 : [13:00] <@ericb2> -> means the remote sent a "Play" and I'll inform the vcl there is an event, containing the "Play" information. vcl will forward to Impress, and the slideshow will start
188 : [13:01] <@ericb2> This is only the introduction (if people are intersted, we can do another workshop about gdb another day )
189 : [13:02] <@ericb2> To quit *cleanly*
190 : [13:02] <@ericb2> delete the brekapoints :
191 : [13:02] <@ericb2> d
192 : [13:02] <@ericb2> confirm with yest
193 : [13:02] <@ericb2> yes
194 : [13:02] <@ericb2> c
195 : [13:02] <@ericb2> to continue
196 : [13:02] <@ericb2> and then Quit OOo using CMD Q
197 : [13:03] <@ericb2> The result is :
198 : [13:03] <@ericb2> Program exited normally.
199 : [13:03] <@ericb2> (gdb)
200 : [13:03] <@ericb2> Then quit gdb :
201 : [13:03] <@ericb2> q
202 : [13:03] <@ericb2> -> will give you the normal prompt
203 : [13:03] <@ericb2> back
204 : [13:03] <@ericb2> Questions ?
205 : [13:04] <BartB> not at the moment, might have some later
206 : [13:04] <@ericb2> I forgot, to affect a value, the command is "set"
207 : [13:04] <@ericb2> e.g. :
208 : [13:04] <MrBraini> ericb2: last lecture you stated the notes from the lectures will be placed on the wiki? where can we find the notes in the wiki?
209 : [13:04] <@ericb2> (gdb) : set a=10
210 : [13:05] <daeseon_> not now may be later.
211 : [13:05] <@ericb2> MrBraini: I'll put them on the wiki, yes
212 : [13:05] <l_zahir> is there a y way so we can see multiple line before their execution?
213 : [13:05] <@ericb2> l_zahir: list ?
214 : [13:05] <@ericb2> l_zahir: l is the shortcut
215 : [13:06] <@ericb2> l_zahir: I forgot, there is another way to break, using conditional breakpoint
216 : [13:06] <l_zahir> oksu during debugging or before?
217 : [13:06] <@ericb2> l_zahir : you can go up and down in the frames
218 : [13:06] <@ericb2> l_zahir to retrieve a context
219 : [13:06] <l_zahir> ok , thanks
220 : [13:07] <@ericb2> l_zahir: I think, the best is to redo a workshop, with everything ready
221 : [13:07] <@ericb2> l_zahir: but nothing will replace the experiences
222 : [13:07] <l_zahir> sure
223 : [13:07] <l_zahir> I will
224 : [13:07] <@ericb2> l_zahir: no problem.
225 : [13:08] <@ericb2> BTW, I provided a patch for rhino and scripting
226 : [13:08] <l_zahir> Oh, good :)
227 : [13:08] <@ericb2> was my fault: two modules where concerned, and this is what caused some issues
228 : [13:08] <@ericb2> l_zahir: one minute, I'll retrive the URL
229 : [13:08] <l_zahir> thanks
230 : [13:08] <l_zahir> :)
231 : [13:09] <@ericb2> http://eric.bachard.free.fr/mac/aquavcl/patches/aqua_February2009/17th_february/complete_rhino_and_scripting_patch.diff
232 : [13:09] <@ericb2> l_zahir: this patch should apply cleanly on m40
233 : [13:09] <@ericb2> l_zahir: not sure it will work, I'm not a Java specialist ;)
234 : [13:09] <@ericb2> ok, I'll have to stop.
235 : [13:09] <l_zahir> I'll try
236 : [13:10] <@ericb2> If you have further questions, ask directly, and if I see them, I'll answer
237 : [13:11] <l_zahir> sure
238 : [13:11] <@ericb2> Other questions ?
239 : [13:12] <@ericb2> If you have no other questions, I'll stop for a while, but in ~2 hours max, I'll be back.
240 : [13:12] <@ericb2> The content of the classroom will be on the wiki
241 : [13:12] <achan66> okay
242 : [13:12] <daeseon_> ok.
243 : [13:12] <@ericb2> later
244 : [13:12] <l_zahir> no Qs
245 : [13:12] <MrBraini> okay thank you
246 : [13:12] <rmwang> Okay Thank you Eric!
247 : [13:13] <@ericb2> thansk to all for coming :)
248 : [13:13] <BartB> thank you Eric
249 : [13:13] <achan66> eric, would it be here?
250 : [13:13] <achan66> http://wiki.services.openoffice.org/wiki/Education_ClassRoom/Practice#SVN_use
251 : [13:13] <@ericb2> achan66: yes, not far
252 : [13:13] <achan66> thank you
253 : [13:13] <WFred___> Thanks Eric!
254 : [13:13] <achan66> = )
255 : [13:13] <@ericb2> achan66: just a tip : look at recent changes on the wiki, say in 2 or 3 hours ;-)
256 : [13:14] <achan66> affirm
257 : [13:14] <MrBraini> okay
258 : [13:14] <Kamots> thank you Eric
259 : [13:15] <daeseon_> thanks Eric
260 : �01[13:19] <@fardad> thanks eric
</pre>

Navigation menu