Sign in Join
Wiki copytemporary

Creating a Backtrace with GDB: what changed

Revision 3 to 4. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Reasons to create a backtrace
22
33### Bug Reports
44
55Backtraces can be very helpful when submitting bug reports. They will no doubt increase the chances of the bug getting fixed sooner.
66
77### Help yourself find a problem
88
99A backtrace can really take the pain out of finding a problem with your own program. Often exposing the problem immediately.
1010
1111### Just plain fun!!
1212
1313Okay this might be a stretch, but making backtraces is just plain fun!
1414
1515Seriously though, if you can think of another reason to create a backtrace add it here.
1616
1717## Creating a Backtrace
1818
1919Note: **Mac users** should use *lldb* instead of *gdb*.
2020
2121To create a backtrace with [[GDB]] (Gnu DeBugger):
2222
23231. You must have the program [GDB](http://www.gnu.org/software/gdb/gdb.html). It is available on most *nix installations. If you downloaded the Windows version of fpc or Lazarus, GDB is already included in the installation. In Lazarus it is set up as the default debugger. Look in Tools -\> Options -\> Debugger -\> General Tab. Default path for GDB on Windows is c:\lazarus\mingw\bin\gdb.exe.
24242. GDB must be in the PATH environment variable. If it's not under windows, from the command prompt type (example): set PATH=%PATH%;c:\lazarus\mingw\bin\\
25253. The program you wish to debug MUST have debugging info included in the executable. If you have used "strip", "upx", compiled with "Xs" or used some other exe shrinker/compressor this won't work!
2626
2727### Very short how-to
2828
2929Linux terminal:
3030
31-` $ cd program_folder`\
32-` $ gdb program_name`\
33-` run`
31+```text
32+ $ cd program_folder
33+ $ gdb program_name
34+ run
35+```
3436
3537Then AV happens. Type:
3638
37-` bt`
39+```text
40+ bt
41+```
3842
3943### Directly from the Call Stack window
4044
4145To capture a Backtrace from within Lazarus, make sure you compile the program including both options "Generate debug info for GDB" and "Display line numbers in run-time error backtraces (-gl)" and you have properly setup GDB in Debugger Options.
4246
43471. Run your application until the problem appear
44482. If a dialog should appear alerting about a problem showing a couple of buttons: "Break" and "Continue", click the "Break" button.
45493. Open the Call Stack window (Menu View-\>Debug Windows-\>Call Stack
46504. Look a the list of Calls, if necessary press "(+)More"
47515. Press the "Copy All" button.
48526. The Backtrace is now in your clipboard and ready for pasting it.
4953
5054### Windows Users
5155
52561\. Open a MS-DOS prompt
5357
54582\. Change to the drive you have your exe on:
5559
56-`C: {press enter}`
60+```text
61+C: {press enter}
62+```
5763
58643\. Change to the directory containing the exe:
5965
60-`cd \myprograms\Project1 {press enter}`
66+```text
67+cd \myprograms\Project1 {press enter}
68+```
6169
62704\. Load your program with GDB:
6371
64-`gdb Project1.exe {press enter}`
72+```text
73+gdb Project1.exe {press enter}
74+```
6575
6676### Linux/BSD Users
6777
68781\. Open your favorite Terminal program
6979
70802\. Change to the directory containing the executable:
7181
72-`cd $HOME/myprograms/project1 {press enter}`
82+```text
83+cd $HOME/myprograms/project1 {press enter}
84+```
7385
74863\. Load your program with GDB:
7587
76-`gdb project1 {press enter}`
88+```text
89+gdb project1 {press enter}
90+```
7791
7892### macOS
7993
8094GDB is not available by default on macOS. You should use the macOS default [[Creating a Backtrace with lldb|lldb debugger]]
8195
8296#### macOS: Graphical application
8397
84981\. If not already done: create the application bundle (Project / Project Options / Application / Create Application Bundle)
8599
861002\. Open your favorite Terminal program
87101
881023\. Change to the directory containing the application bundle / executable:
89103
90-`cd $HOME/myprograms/project1 {press enter}`
104+```text
105+cd $HOME/myprograms/project1 {press enter}
106+```
91107
921084\. Load your program with GDB:
93109
94-`gdb project1.app/Contents/MacOS/project1 {press enter}`
110+```text
111+gdb project1.app/Contents/MacOS/project1 {press enter}
112+```
95113
96114#### macOS: Non graphical application, command line program
97115
981161\. Open your favorite Terminal program
99117
1001182\. Change to the directory containing the executable:
101119
102-`cd $HOME/myprograms/project1 {press enter}`
120+```text
121+cd $HOME/myprograms/project1 {press enter}
122+```
103123
1041243\. Load your program with GDB:
105125
106-`gdb project1 {press enter}`
126+```text
127+gdb project1 {press enter}
128+```
107129
108130### GDB ready to accept commands
109131
110132You should now see a prompt that looks something like this:
111133
112-`GNU gdb 6.3.50.20050217-cvs`\
113-`Copyright 2004 Free Software Foundation, Inc.`\
114-`GDB is free software, covered by the GNU General Public License, and you are`\
115-`welcome to change it and/or distribute copies of it under certain conditions.`\
116-`Type "show copying" to see the conditions.`\
117-`There is absolutely no warranty for GDB.  Type "show warranty" for details.`\
118-`This GDB was configured as "i686-pc-linux-gnu".`\
119-`(gdb) _`
134+``` pascal
135+GNU gdb 6.3.50.20050217-cvs
136+Copyright 2004 Free Software Foundation, Inc.
137+GDB is free software, covered by the GNU General Public License, and you are
138+welcome to change it and/or distribute copies of it under certain conditions.
139+Type "show copying" to see the conditions.
140+There is absolutely no warranty for GDB. Type "show warranty" for details.
141+This GDB was configured as "i686-pc-linux-gnu".
142+(gdb) _
143+```
120144
121145**Let GDB stop when an exception is raised**
122146
123-`(gdb) break fpc_raiseexception {press enter}`
147+```text
148+(gdb) break fpc_raiseexception {press enter}
149+```
124150
125151**Now, run your program:**
126152
127-`(gdb) run {press enter}`
153+```text
154+(gdb) run {press enter}
155+```
128156
129157Your program will run normally, until it crashes or causes an error.
130158
131159When your program crashes instead of the usual error "Access Violation" or "Division by Zero" your program will just seem to stop, not respond and not repaint itself. This is because gdb has caught the error and is waiting for you to tell it what to do.
132160
133161Switch over to your MS-DOS window or Terminal and you should have a screen something like this:
134162
135-`Program received signal SIGFPE, Arithmetic exception.`\
136-`0x080733aa in TFORM1__BUTTON1CLICK (SENDER=0x403d8bd8, this=0x403d77d8) at unit1.pas:36`\
137-`Current language:  auto; currently pascal`\
138-`(gdb) _`
163+``` pascal
164+Program received signal SIGFPE, Arithmetic exception.
165+0x080733aa in TFORM1__BUTTON1CLICK (SENDER=0x403d8bd8, this=0x403d77d8) at unit1.pas:36
166+Current language: auto; currently pascal
167+(gdb) _
168+```
139169
140170To create a backtrace now type:
141171
142-`backtrace {press enter}`
172+```text
173+backtrace {press enter}
174+```
143175
144176or
145177
146-`bt {press enter}`
178+```text
179+bt {press enter}
180+```
147181
148182You should now have a screen that looks something like this:
149183
150-`#0  0x080733aa in TFORM1__BUTTON1CLICK (SENDER=0x403d8bd8, this=0x403d77d8) at unit1.pas:36`\
151-`#1  0x080ecd78 in TCONTROL__CLICK (this=0x403d8bd8) at control.inc:1768`\
152-`#2  0x081274bd in TBUTTONCONTROL__CLICK (this=0x403d8bd8) at buttoncontrol.inc:57`\
153-`#3  0x08129171 in TCUSTOMBUTTON__CLICK (this=0x403d8bd8) at buttons.inc:186`\
154-`#4  0x08129198 in TCUSTOMBUTTON__WMDEFAULTCLICKED (MESSAGE={MSG = 1031, WPARAM = `\
155-`        136821192, LPARAM = -1073747812, RESULT = 1075866658, WPARAMLO = 47560, `\
156-`        WPARAMHI = 2087, LPARAMLO = 59548, LPARAMHI = 49151, RESULTLO = 27682, RESULTHI = 16416}, `\
157-`        this=0x403d8bd8) at buttons.inc:198`\
158-`#5  0x0805bbf7 in SYSTEM_TOBJECT_$__DISPATCH$formal ()`\
159-`#6  0x080ec6e0 in TCONTROL__WNDPROC (THEMESSAGE={MSG = 1031, WPARAM = 136821192, `\
160-`        LPARAM = -1073747812, RESULT = 1075866658, WPARAMLO = 47560, WPARAMHI = 2087, `\
161-`        LPARAMLO = 59548,  PARAMHI = 49151, RESULTLO = 27682, RESULTHI = 16416}, `\
162-`        this=0x403d8bd8) at control.inc:1447 `\
163-`#7  0x080e4ed9 in TWINCONTROL__WNDPROC (MESSAGE={MSG = 1031, WPARAM = 136821192, `\
164-`        LPARAM = -1073747812, RESULT = 1075866658, WPARAMLO = 47560, WPARAMHI = 2087, `\
165-`        LPARAMLO = 59548,  PARAMHI = 49151, RESULTLO = 27682, RESULTHI = 16416}, `\
166-`        this=0x403d8bd8) at wincontrol.inc:2154`\
167-`#8  0x08161955 in DELIVERMESSAGE (TARGET=0x403d8bd8, AMESSAGE=void) at gtkproc.inc:3242`\
168-`#9  0x0818897c in GTKWSBUTTON_CLICKED (AWIDGET=0x8285380, AINFO=0x40453794) at gtkwsbuttons.pp:112`\
169-`... { Truncated for simplicity} Complete listing `[[Creating a Backtrace with GDB\Backtrace|here]]\
170-`(gdb) _`
184+```text
185+#0 0x080733aa in TFORM1__BUTTON1CLICK (SENDER=0x403d8bd8, this=0x403d77d8) at unit1.pas:36
186+#1 0x080ecd78 in TCONTROL__CLICK (this=0x403d8bd8) at control.inc:1768
187+#2 0x081274bd in TBUTTONCONTROL__CLICK (this=0x403d8bd8) at buttoncontrol.inc:57
188+#3 0x08129171 in TCUSTOMBUTTON__CLICK (this=0x403d8bd8) at buttons.inc:186
189+#4 0x08129198 in TCUSTOMBUTTON__WMDEFAULTCLICKED (MESSAGE={MSG = 1031, WPARAM =
190+ 136821192, LPARAM = -1073747812, RESULT = 1075866658, WPARAMLO = 47560,
191+ WPARAMHI = 2087, LPARAMLO = 59548, LPARAMHI = 49151, RESULTLO = 27682, RESULTHI = 16416},
192+ this=0x403d8bd8) at buttons.inc:198
193+#5 0x0805bbf7 in SYSTEM_TOBJECT_$__DISPATCH$formal ()
194+#6 0x080ec6e0 in TCONTROL__WNDPROC (THEMESSAGE={MSG = 1031, WPARAM = 136821192,
195+ LPARAM = -1073747812, RESULT = 1075866658, WPARAMLO = 47560, WPARAMHI = 2087,
196+ LPARAMLO = 59548, PARAMHI = 49151, RESULTLO = 27682, RESULTHI = 16416},
197+ this=0x403d8bd8) at control.inc:1447
198+#7 0x080e4ed9 in TWINCONTROL__WNDPROC (MESSAGE={MSG = 1031, WPARAM = 136821192,
199+ LPARAM = -1073747812, RESULT = 1075866658, WPARAMLO = 47560, WPARAMHI = 2087,
200+ LPARAMLO = 59548, PARAMHI = 49151, RESULTLO = 27682, RESULTHI = 16416},
201+ this=0x403d8bd8) at wincontrol.inc:2154
202+#8 0x08161955 in DELIVERMESSAGE (TARGET=0x403d8bd8, AMESSAGE=void) at gtkproc.inc:3242
203+#9 0x0818897c in GTKWSBUTTON_CLICKED (AWIDGET=0x8285380, AINFO=0x40453794) at gtkwsbuttons.pp:112
204+... { Truncated for simplicity} Complete listing here
205+(gdb) _
206+```
171207
172208> **Note:** If the backtrace is too long you will be prompted to press enter for the next page of the backtrace until it is complete
173209
174210The information displayed here has the sequence of events up to where the error occured. [[Creating a Backtrace with GDB|Understanding a Backtrace]]
175211
176212To exit GDB (and your program) you may now type:
177213
178-`quit {press enter}`
214+```text
215+quit {press enter}
216+```
179217
180218Or to continue running until the next exception type:
181219
182-`cont {press enter}`
220+```text
221+cont {press enter}
222+```
183223
184224*Hint: At any time while your program is running you may press Ctrl+C (from the Terminal or MS-DOS prompt) to get a "(gdb) _" prompt*
185225
186226> **Note:** The use of an english keyboard layout can prevent problems with gdb (e.g. if you type special characters like ' \\ ').
187227
188228## using lldb on Mac
189229
190230start lldb
191231
192232
193233lldb
194234
195235load your project
196236
197237
198238target create project1.app/MacOs/Contents/project1
199239
200240set a breakpoint You may skip this, if the project crashes, rather than raising an fpc exception) If there are expected exceptions, that will be handled by try except, then use "c" to continue
201241
202242
203243breakpoint set --func fpc_raiseexception
204244
205245run it
206246
207247
208248r
209249
210250when it stops, get the backtrace
211251
212252
213253bt
214254
215255show locals for different frames (replace 1 in frame select, with different frames, e.g. top 3 or top 5)
216256
217257
218258frame select 1
219259
220260frame variable -P 1
221261
222262## Getting the Backtrace out of the terminal and into an email
223263
224264Currently we have made a backtrace and seen it in the Terminal(or MS-DOS prompt) but how do I get it into an email? There are two ways that I know of:
225265
2262661. Use the copy/paste functionality of your Terminal(or MS-DOS prompt)
2272672. Redirect the output of gdb to a file like so:
228268
229-`gdb project1 > output.txt`
269+```text
270+gdb project1 > output.txt
271+```
230272
231273Now you can open the file and copy/paste it into your email.
232274
233275Caveat: The second method requires that you type blindly. So you would type "run" to start the program and "backtrace" to make a backtrace like normal but nothing would show up on the screen.
234276
235277Exception: On Linux you can get around not being able to see with the following command:
236278
237-`touch output.txt & tail output.txt -f & gdb project1 > output.txt`
279+```text
280+touch output.txt & tail output.txt -f & gdb project1 > output.txt
281+```
238282
239283## Understanding a Backtrace
240284
241285The stack contains all calls at the moment when the division by zero error occured. At position \#0 is the latest call "button1-click()". subproc-call \#37 is the first call of main() of the whole app.
242286
243287TODO: Write Me :)
244288
245-`(gdb) bt`\
246-`#0  0x080733aa in TFORM1__BUTTON1CLICK (SENDER=0x403d8bd8, this=0x403d77d8) at unit1.pas:36`\
247-`#1  0x080ecd78 in TCONTROL__CLICK (this=0x403d8bd8) at control.inc:1768`\
248-`#2  0x081274bd in TBUTTONCONTROL__CLICK (this=0x403d8bd8) at buttoncontrol.inc:57`\
249-`#3  0x08129171 in TCUSTOMBUTTON__CLICK (this=0x403d8bd8) at buttons.inc:186`\
250-`#4  0x08129198 in TCUSTOMBUTTON__WMDEFAULTCLICKED (MESSAGE={MSG = 1031, WPARAM = 136821192, `\
251-`        LPARAM = -1073747812, RESULT = 1075866658, WPARAMLO = 47560, WPARAMHI = 2087, `\
252-`        LPARAMLO = 59548, LPARAMHI = 49151, RESULTLO = 27682, RESULTHI = 16416}, `\
253-`        this=0x403d8bd8) at buttons.inc:198`\
254-`#5  0x0805bbf7 in SYSTEM_TOBJECT_$__DISPATCH$formal ()`\
255-`#6  0x080ec6e0 in TCONTROL__WNDPROC (THEMESSAGE={MSG = 1031, WPARAM = 136821192, `\
256-`        LPARAM = -1073747812, RESULT = 1075866658, WPARAMLO = 47560, WPARAMHI = 2087, `\
257-`        LPARAMLO = 59548, LPARAMHI = 49151, RESULTLO = 27682, RESULTHI = 16416}, `\
258-`        this=0x403d8bd8) at control.inc:1447`\
259-`#7  0x080e4ed9 in TWINCONTROL__WNDPROC (MESSAGE={MSG = 1031, WPARAM = 136821192, `\
260-`        LPARAM = -1073747812, RESULT = 1075866658, WPARAMLO = 47560, WPARAMHI = 2087, `\
261-`        LPARAMLO = 59548, LPARAMHI = 49151, RESULTLO = 27682, RESULTHI =   16416},`\
262-`        this=0x403d8bd8) at wincontrol.inc:2154`\
263-`#8  0x08161955 in DELIVERMESSAGE (TARGET=0x403d8bd8, AMESSAGE=void) at gtkproc.inc:3242`\
264-`#9  0x0818897c in GTKWSBUTTON_CLICKED (AWIDGET=0x8285380, AINFO=0x40453794) at gtkwsbuttons.pp:112`\
265-`#10 0x401d7877 in gtk_marshal_NONE__NONE () from /usr/lib/libgtk-1.2.so.0`\
266-`#11 0x40206e5a in gtk_signal_remove_emission_hook () from /usr/lib/libgtk-1.2.so.0`\
267-`#12 0x4020616a in gtk_signal_set_funcs () from /usr/lib/libgtk-1.2.so.0`\
268-`#13 0x40204234 in gtk_signal_emit () from /usr/lib/libgtk-1.2.so.0`\
269-`#14 0x40176e1c in gtk_button_clicked () from /usr/lib/libgtk-1.2.so.0`\
270-`#15 0x4017838a in gtk_button_get_relief () from /usr/lib/libgtk-1.2.so.0`\
271-`#16 0x401d7877 in gtk_marshal_NONE__NONE () from /usr/lib/libgtk-1.2.so.0`\
272-`#17 0x4020607b in gtk_signal_set_funcs () from /usr/lib/libgtk-1.2.so.0`\
273-`#18 0x40204234 in gtk_signal_emit () from /usr/lib/libgtk-1.2.so.0`\
274-`#19 0x40176d60 in gtk_button_released () from /usr/lib/libgtk-1.2.so.0`\
275-`#20 0x40177d26 in gtk_button_get_relief () from /usr/lib/libgtk-1.2.so.0`\
276-`#21 0x401d764d in gtk_marshal_BOOL__POINTER () from /usr/lib/libgtk-1.2.so.0`\
277-`#22 0x4020619f in gtk_signal_set_funcs () from /usr/lib/libgtk-1.2.so.0`\
278-`#23 0x40204234 in gtk_signal_emit () from /usr/lib/libgtk-1.2.so.0`\
279-`#24 0x40239fd9 in gtk_widget_event () from /usr/lib/libgtk-1.2.so.0`\
280-`#25 0x401d74d0 in gtk_propagate_event () from /usr/lib/libgtk-1.2.so.0`\
281-`#26 0x401d65c1 in gtk_main_do_event () from /usr/lib/libgtk-1.2.so.0`\
282-`#27 0x40065b44 in gdk_wm_protocols_filter () from /usr/lib/libgdk-1.2.so.0`\
283-`#28 0x4003de75 in g_get_current_time () from /usr/lib/libglib-1.2.so.0`\
284-`#29 0x4003e32c in g_get_current_time () from /usr/lib/libglib-1.2.so.0`\
285-`#30 0x4003e4f5 in g_main_iteration () from /usr/lib/libglib-1.2.so.0`\
286-`#31 0x401d6388 in gtk_main_iteration_do () from /usr/lib/libgtk-1.2.so.0`\
287-`#32 0x080b4d26 in TGTKWIDGETSET__WAITMESSAGE (this=0x40473014) at gtkobject.inc:1427`\
288-`#33 0x08070073 in TAPPLICATION__IDLE (this=0x4045b014) at application.inc:319`\
289-`#34 0x08070ffb in TAPPLICATION__HANDLEMESSAGE (this=0x4045b014) at application.inc:827`\
290-`#35 0x08071380 in RUNMESSAGE (parentfp=0xbffff5a4) at application.inc:933`\
291-`#36 0x080712d7 in TAPPLICATION__RUN (this=0x4045b014) at application.inc:944`\
292-`#37 0x080531c3 in main () at project1.lpr:13`\
293-`(gdb)`
289+```text
290+(gdb) bt
291+#0 0x080733aa in TFORM1__BUTTON1CLICK (SENDER=0x403d8bd8, this=0x403d77d8) at unit1.pas:36
292+#1 0x080ecd78 in TCONTROL__CLICK (this=0x403d8bd8) at control.inc:1768
293+#2 0x081274bd in TBUTTONCONTROL__CLICK (this=0x403d8bd8) at buttoncontrol.inc:57
294+#3 0x08129171 in TCUSTOMBUTTON__CLICK (this=0x403d8bd8) at buttons.inc:186
295+#4 0x08129198 in TCUSTOMBUTTON__WMDEFAULTCLICKED (MESSAGE={MSG = 1031, WPARAM = 136821192,
296+ LPARAM = -1073747812, RESULT = 1075866658, WPARAMLO = 47560, WPARAMHI = 2087,
297+ LPARAMLO = 59548, LPARAMHI = 49151, RESULTLO = 27682, RESULTHI = 16416},
298+ this=0x403d8bd8) at buttons.inc:198
299+#5 0x0805bbf7 in SYSTEM_TOBJECT_$__DISPATCH$formal ()
300+#6 0x080ec6e0 in TCONTROL__WNDPROC (THEMESSAGE={MSG = 1031, WPARAM = 136821192,
301+ LPARAM = -1073747812, RESULT = 1075866658, WPARAMLO = 47560, WPARAMHI = 2087,
302+ LPARAMLO = 59548, LPARAMHI = 49151, RESULTLO = 27682, RESULTHI = 16416},
303+ this=0x403d8bd8) at control.inc:1447
304+#7 0x080e4ed9 in TWINCONTROL__WNDPROC (MESSAGE={MSG = 1031, WPARAM = 136821192,
305+ LPARAM = -1073747812, RESULT = 1075866658, WPARAMLO = 47560, WPARAMHI = 2087,
306+ LPARAMLO = 59548, LPARAMHI = 49151, RESULTLO = 27682, RESULTHI = 16416},
307+ this=0x403d8bd8) at wincontrol.inc:2154
308+#8 0x08161955 in DELIVERMESSAGE (TARGET=0x403d8bd8, AMESSAGE=void) at gtkproc.inc:3242
309+#9 0x0818897c in GTKWSBUTTON_CLICKED (AWIDGET=0x8285380, AINFO=0x40453794) at gtkwsbuttons.pp:112
310+#10 0x401d7877 in gtk_marshal_NONE__NONE () from /usr/lib/libgtk-1.2.so.0
311+#11 0x40206e5a in gtk_signal_remove_emission_hook () from /usr/lib/libgtk-1.2.so.0
312+#12 0x4020616a in gtk_signal_set_funcs () from /usr/lib/libgtk-1.2.so.0
313+#13 0x40204234 in gtk_signal_emit () from /usr/lib/libgtk-1.2.so.0
314+#14 0x40176e1c in gtk_button_clicked () from /usr/lib/libgtk-1.2.so.0
315+#15 0x4017838a in gtk_button_get_relief () from /usr/lib/libgtk-1.2.so.0
316+#16 0x401d7877 in gtk_marshal_NONE__NONE () from /usr/lib/libgtk-1.2.so.0
317+#17 0x4020607b in gtk_signal_set_funcs () from /usr/lib/libgtk-1.2.so.0
318+#18 0x40204234 in gtk_signal_emit () from /usr/lib/libgtk-1.2.so.0
319+#19 0x40176d60 in gtk_button_released () from /usr/lib/libgtk-1.2.so.0
320+#20 0x40177d26 in gtk_button_get_relief () from /usr/lib/libgtk-1.2.so.0
321+#21 0x401d764d in gtk_marshal_BOOL__POINTER () from /usr/lib/libgtk-1.2.so.0
322+#22 0x4020619f in gtk_signal_set_funcs () from /usr/lib/libgtk-1.2.so.0
323+#23 0x40204234 in gtk_signal_emit () from /usr/lib/libgtk-1.2.so.0
324+#24 0x40239fd9 in gtk_widget_event () from /usr/lib/libgtk-1.2.so.0
325+#25 0x401d74d0 in gtk_propagate_event () from /usr/lib/libgtk-1.2.so.0
326+#26 0x401d65c1 in gtk_main_do_event () from /usr/lib/libgtk-1.2.so.0
327+#27 0x40065b44 in gdk_wm_protocols_filter () from /usr/lib/libgdk-1.2.so.0
328+#28 0x4003de75 in g_get_current_time () from /usr/lib/libglib-1.2.so.0
329+#29 0x4003e32c in g_get_current_time () from /usr/lib/libglib-1.2.so.0
330+#30 0x4003e4f5 in g_main_iteration () from /usr/lib/libglib-1.2.so.0
331+#31 0x401d6388 in gtk_main_iteration_do () from /usr/lib/libgtk-1.2.so.0
332+#32 0x080b4d26 in TGTKWIDGETSET__WAITMESSAGE (this=0x40473014) at gtkobject.inc:1427
333+#33 0x08070073 in TAPPLICATION__IDLE (this=0x4045b014) at application.inc:319
334+#34 0x08070ffb in TAPPLICATION__HANDLEMESSAGE (this=0x4045b014) at application.inc:827
335+#35 0x08071380 in RUNMESSAGE (parentfp=0xbffff5a4) at application.inc:933
336+#36 0x080712d7 in TAPPLICATION__RUN (this=0x4045b014) at application.inc:944
337+#37 0x080531c3 in main () at project1.lpr:13
338+(gdb)
339+```
294340
295341This Backtrace was produced using this code:
296342
297-`30. procedure TForm1.Button1Click(Sender: TObject);`\
298-`31. var`\
299-`32.  X, Y, Z: Integer;`\
300-`33. begin`\
301-`34.   X := 0;`\
302-`35.   Y := 0;`\
303-`36.   Z := X div Y;   //   division by zero error`\
304-`37. end;`
343+``` pascal
344+30. procedure TForm1.Button1Click(Sender: TObject);
345+31. var
346+32. X, Y, Z: Integer;
347+33. begin
348+34. X := 0;
349+35. Y := 0;
350+36. Z := X div Y; // division by zero error
351+37. end;
352+```
305353
306354## See Also
307355
308356- [[Creating a Backtrace with lldb]]
309357
310358---
311359*From the Free Pascal wiki, page "Creating a Backtrace with GDB", as it stood on 2019-12-22 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history