Sign in Join
Wiki copytemporary

Creating a Backtrace with GDB: what changed

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

OldNewLine
1-## Contents
2-
3- * 1 Reasons to create a backtrace
4- * 1.1 Bug Reports
5- * 1.2 Help yourself find a problem
6- * 1.3 Just plain fun!!
7- * 2 Creating a Backtrace
8- * 2.1 Very short how-to
9- * 2.2 Directly from the Call Stack window
10- * 2.3 Windows Users
11- * 2.4 Linux/BSD Users
12- * 2.5 macOS
13- * 2.5.1 macOS: Graphical application
14- * 2.5.2 macOS: Non graphical application, command line program
15- * 2.6 GDB ready to accept commands
16- * 3 using lldb on Mac
17- * 4 Getting the Backtrace out of the terminal and into an email
18- * 5 Understanding a Backtrace
19- * 6 See Also
20-
211## Reasons to create a backtrace
222
233### Bug Reports
244
25-Backtraces can be very helpful when submitting bug reports. They will no doubt increase the chances of the bug getting fixed sooner.
5+Backtraces can be very helpful when submitting bug reports. They will no doubt increase the chances of the bug getting fixed sooner.
266
277### Help yourself find a problem
288
29-A backtrace can really take the pain out of finding a problem with your own program. Often exposing the problem immediately.
9+A backtrace can really take the pain out of finding a problem with your own program. Often exposing the problem immediately.
3010
3111### Just plain fun!!
3212
33-Okay this might be a stretch, but making backtraces is just plain fun!
13+Okay this might be a stretch, but making backtraces is just plain fun!
3414
35-Seriously though, if you can think of another reason to create a backtrace add it here.
15+Seriously though, if you can think of another reason to create a backtrace add it here.
3616
3717## Creating a Backtrace
3818
39-Note: **Mac users** should use _lldb_ instead of _gdb_.
19+Note: **Mac users** should use *lldb* instead of *gdb*.
4020
41-To create a backtrace with [[GDB]] (Gnu DeBugger):
21+To create a backtrace with [[GDB]] (Gnu DeBugger):
4222
43- 1. 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.
44- 2. 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\
45- 3. 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!
23+1. 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.
24+2. 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\\
25+3. 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!
4626
4727### Very short how-to
4828
49-Linux terminal:
50-```
51-$ cd program_folder
52- $ gdb program_name
53- run
54-```
29+Linux terminal:
5530
56-Then AV happens. Type:
57-```
58-bt
59-```
31+` $ cd program_folder`\
32+` $ gdb program_name`\
33+` run`
6034
35+Then AV happens. Type:
36+
37+` bt`
38+
6139### Directly from the Call Stack window
6240
63-To 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.
41+To 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.
6442
65- 1. Run your application until the problem appear
66- 2. If a dialog should appear alerting about a problem showing a couple of buttons: "Break" and "Continue", click the "Break" button.
67- 3. Open the Call Stack window (Menu View->Debug Windows->Call Stack
68- 4. Look a the list of Calls, if necessary press "(+)More"
69- 5. Press the "Copy All" button.
70- 6. The Backtrace is now in your clipboard and ready for pasting it.
43+1. Run your application until the problem appear
44+2. If a dialog should appear alerting about a problem showing a couple of buttons: "Break" and "Continue", click the "Break" button.
45+3. Open the Call Stack window (Menu View-\>Debug Windows-\>Call Stack
46+4. Look a the list of Calls, if necessary press "(+)More"
47+5. Press the "Copy All" button.
48+6. The Backtrace is now in your clipboard and ready for pasting it.
7149
7250### Windows Users
7351
74-1\. Open a MS-DOS prompt
52+1\. Open a MS-DOS prompt
7553
76-2\. Change to the drive you have your exe on:
77-```
78-C: {press enter}
79-```
54+2\. Change to the drive you have your exe on:
8055
81-3\. Change to the directory containing the exe:
82-```
83-cd \myprograms\Project1 {press enter}
84-```
56+`C: {press enter}`
8557
86-4\. Load your program with GDB:
87-```
88-gdb Project1.exe {press enter}
89-```
58+3\. Change to the directory containing the exe:
9059
91-
60+`cd \myprograms\Project1 {press enter}`
9261
62+4\. Load your program with GDB:
63+
64+`gdb Project1.exe {press enter}`
65+
9366### Linux/BSD Users
9467
95-1\. Open your favorite Terminal program
68+1\. Open your favorite Terminal program
9669
97-2\. Change to the directory containing the executable:
98-```
99-cd $HOME/myprograms/project1 {press enter}
100-```
70+2\. Change to the directory containing the executable:
10171
102-3\. Load your program with GDB:
103-```
104-gdb project1 {press enter}
105-```
72+`cd $HOME/myprograms/project1 {press enter}`
10673
74+3\. Load your program with GDB:
75+
76+`gdb project1 {press enter}`
77+
10778### macOS
10879
10980GDB is not available by default on macOS. You should use the macOS default [[Creating a Backtrace with lldb|lldb debugger]]
11081
11182#### macOS: Graphical application
11283
113-1\. If not already done: create the application bundle (Project / Project Options / Application / Create Application Bundle)
84+1\. If not already done: create the application bundle (Project / Project Options / Application / Create Application Bundle)
11485
115-2\. Open your favorite Terminal program
86+2\. Open your favorite Terminal program
11687
117-3\. Change to the directory containing the application bundle / executable:
118-```
119-cd $HOME/myprograms/project1 {press enter}
120-```
88+3\. Change to the directory containing the application bundle / executable:
12189
122-4\. Load your program with GDB:
123-```
124-gdb project1.app/Contents/MacOS/project1 {press enter}
125-```
90+`cd $HOME/myprograms/project1 {press enter}`
12691
92+4\. Load your program with GDB:
93+
94+`gdb project1.app/Contents/MacOS/project1 {press enter}`
95+
12796#### macOS: Non graphical application, command line program
12897
129-1\. Open your favorite Terminal program
98+1\. Open your favorite Terminal program
13099
131-2\. Change to the directory containing the executable:
132-```
133-cd $HOME/myprograms/project1 {press enter}
134-```
100+2\. Change to the directory containing the executable:
135101
136-3\. Load your program with GDB:
137-```
138-gdb project1 {press enter}
139-```
102+`cd $HOME/myprograms/project1 {press enter}`
140103
104+3\. Load your program with GDB:
105+
106+`gdb project1 {press enter}`
107+
141108### GDB ready to accept commands
142109
143-You should now see a prompt that looks something like this:
144-```
145-GNU gdb 6.3.50.20050217-cvs
146- Copyright 2004 Free Software Foundation, Inc.
147- GDB is free software, covered by the GNU General Public License, and you are
148- welcome to change it and/or distribute copies of it under certain conditions.
149- Type "show copying" to see the conditions.
150- There is absolutely no warranty for GDB. Type "show warranty" for details.
151- This GDB was configured as "i686-pc-linux-gnu".
152- (gdb) _
153-```
110+You should now see a prompt that looks something like this:
154111
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) _`
120+
155121**Let GDB stop when an exception is raised**
156-```
157-(gdb) break fpc_raiseexception {press enter}
158-```
159122
123+`(gdb) break fpc_raiseexception {press enter}`
124+
160125**Now, run your program:**
161-```
162-(gdb) run {press enter}
163-```
164126
165-Your program will run normally, until it crashes or causes an error.
127+`(gdb) run {press enter}`
166128
167-When 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.
129+Your program will run normally, until it crashes or causes an error.
168130
169-Switch over to your MS-DOS window or Terminal and you should have a screen something like this:
170-```
171-Program received signal SIGFPE, Arithmetic exception.
172- 0x080733aa in TFORM1__BUTTON1CLICK (SENDER=0x403d8bd8, this=0x403d77d8) at unit1.pas:36
173- Current language: auto; currently pascal
174- (gdb) _
175-```
131+When 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.
176132
177-To create a backtrace now type:
178-```
179-backtrace {press enter}
180-```
133+Switch over to your MS-DOS window or Terminal and you should have a screen something like this:
181134
182-or
183-```
184-bt {press enter}
185-```
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) _`
186139
187-You should now have a screen that looks something like this:
188-```
189-#0 0x080733aa in TFORM1__BUTTON1CLICK (SENDER=0x403d8bd8, this=0x403d77d8) at unit1.pas:36
190- #1 0x080ecd78 in TCONTROL__CLICK (this=0x403d8bd8) at control.inc:1768
191- #2 0x081274bd in TBUTTONCONTROL__CLICK (this=0x403d8bd8) at buttoncontrol.inc:57
192- #3 0x08129171 in TCUSTOMBUTTON__CLICK (this=0x403d8bd8) at buttons.inc:186
193- #4 0x08129198 in TCUSTOMBUTTON__WMDEFAULTCLICKED (MESSAGE={MSG = 1031, WPARAM =
194- 136821192, LPARAM = -1073747812, RESULT = 1075866658, WPARAMLO = 47560,
195- WPARAMHI = 2087, LPARAMLO = 59548, LPARAMHI = 49151, RESULTLO = 27682, RESULTHI = 16416},
196- this=0x403d8bd8) at buttons.inc:198
197- #5 0x0805bbf7 in SYSTEM_TOBJECT_$__DISPATCH$formal ()
198- #6 0x080ec6e0 in TCONTROL__WNDPROC (THEMESSAGE={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 control.inc:1447
202- #7 0x080e4ed9 in TWINCONTROL__WNDPROC (MESSAGE={MSG = 1031, WPARAM = 136821192,
203- LPARAM = -1073747812, RESULT = 1075866658, WPARAMLO = 47560, WPARAMHI = 2087,
204- LPARAMLO = 59548, PARAMHI = 49151, RESULTLO = 27682, RESULTHI = 16416},
205- this=0x403d8bd8) at wincontrol.inc:2154
206- #8 0x08161955 in DELIVERMESSAGE (TARGET=0x403d8bd8, AMESSAGE=void) at gtkproc.inc:3242
207- #9 0x0818897c in GTKWSBUTTON_CLICKED (AWIDGET=0x8285380, AINFO=0x40453794) at gtkwsbuttons.pp:112
208- ... { Truncated for simplicity} Complete listing [[Creating a Backtrace with GDB\Backtrace|here]]
209- (gdb) _
210-```
140+To create a backtrace now type:
211141
212-[![Note-icon.png](/wiki-images/b/be/Note-icon.png)](</File:Note-icon.png>)
142+`backtrace {press enter}`
213143
214-**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
144+or
215145
146+`bt {press enter}`
147+
148+You should now have a screen that looks something like this:
149+
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) _`
171+
172+> **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
173+
216174The information displayed here has the sequence of events up to where the error occured. [[Creating a Backtrace with GDB|Understanding a Backtrace]]
217175
218-To exit GDB (and your program) you may now type:
219-```
220-quit {press enter}
221-```
176+To exit GDB (and your program) you may now type:
222177
223-Or to continue running until the next exception type:
224-```
225-cont {press enter}
226-```
178+`quit {press enter}`
227179
228-_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_
180+Or to continue running until the next exception type:
229181
230-[![Note-icon.png](/wiki-images/b/be/Note-icon.png)](</File:Note-icon.png>)
182+`cont {press enter}`
231183
232-**Note:** The use of an english keyboard layout can prevent problems with gdb (e.g. if you type special characters like ' \ ').
184+*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*
233185
186+> **Note:** The use of an english keyboard layout can prevent problems with gdb (e.g. if you type special characters like ' \\ ').
187+
234188## using lldb on Mac
235189
236-start lldb
190+start lldb
237191
238- lldb
192+
193+lldb
239194
240-load your project
195+load your project
241196
242- target create project1.app/MacOs/Contents/project1
197+
198+target create project1.app/MacOs/Contents/project1
243199
244-set 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
200+set 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
245201
246- breakpoint set --func fpc_raiseexception
202+
203+breakpoint set --func fpc_raiseexception
247204
248-run it
205+run it
249206
250- r
207+
208+r
251209
252-when it stops, get the backtrace
210+when it stops, get the backtrace
253211
254- bt
212+
213+bt
255214
256-show locals for different frames (replace 1 in frame select, with different frames, e.g. top 3 or top 5)
215+show locals for different frames (replace 1 in frame select, with different frames, e.g. top 3 or top 5)
257216
258- frame select 1
259- frame variable -P 1
217+
218+frame select 1
260219
220+frame variable -P 1
221+
261222## Getting the Backtrace out of the terminal and into an email
262223
263-Currently 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:
224+Currently 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:
264225
265- 1. Use the copy/paste functionality of your Terminal(or MS-DOS prompt)
266- 2. Redirect the output of gdb to a file like so:
226+1. Use the copy/paste functionality of your Terminal(or MS-DOS prompt)
227+2. Redirect the output of gdb to a file like so:
267228
268-```
269-gdb project1 > output.txt
270-```
229+`gdb project1 > output.txt`
271230
272-Now you can open the file and copy/paste it into your email.
231+Now you can open the file and copy/paste it into your email.
273232
274-Caveat: 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.
233+Caveat: 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.
275234
276-Exception: On Linux you can get around not being able to see with the following command:
277-```
278-touch output.txt & tail output.txt -f & gdb project1 > output.txt
279-```
235+Exception: On Linux you can get around not being able to see with the following command:
280236
237+`touch output.txt & tail output.txt -f & gdb project1 > output.txt`
238+
281239## Understanding a Backtrace
282240
283-The 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.
241+The 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.
284242
285-
286-TODO: Write Me :)
287-```
288-(gdb) bt
289- #0 0x080733aa in TFORM1__BUTTON1CLICK (SENDER=0x403d8bd8, this=0x403d77d8) at unit1.pas:36
290- #1 0x080ecd78 in TCONTROL__CLICK (this=0x403d8bd8) at control.inc:1768
291- #2 0x081274bd in TBUTTONCONTROL__CLICK (this=0x403d8bd8) at buttoncontrol.inc:57
292- #3 0x08129171 in TCUSTOMBUTTON__CLICK (this=0x403d8bd8) at buttons.inc:186
293- #4 0x08129198 in TCUSTOMBUTTON__WMDEFAULTCLICKED (MESSAGE={MSG = 1031, WPARAM = 136821192,
294- LPARAM = -1073747812, RESULT = 1075866658, WPARAMLO = 47560, WPARAMHI = 2087,
295- LPARAMLO = 59548, LPARAMHI = 49151, RESULTLO = 27682, RESULTHI = 16416},
296- this=0x403d8bd8) at buttons.inc:198
297- #5 0x0805bbf7 in SYSTEM_TOBJECT_$__DISPATCH$formal ()
298- #6 0x080ec6e0 in TCONTROL__WNDPROC (THEMESSAGE={MSG = 1031, WPARAM = 136821192,
299- LPARAM = -1073747812, RESULT = 1075866658, WPARAMLO = 47560, WPARAMHI = 2087,
300- LPARAMLO = 59548, LPARAMHI = 49151, RESULTLO = 27682, RESULTHI = 16416},
301- this=0x403d8bd8) at control.inc:1447
302- #7 0x080e4ed9 in TWINCONTROL__WNDPROC (MESSAGE={MSG = 1031, WPARAM = 136821192,
303- LPARAM = -1073747812, RESULT = 1075866658, WPARAMLO = 47560, WPARAMHI = 2087,
304- LPARAMLO = 59548, LPARAMHI = 49151, RESULTLO = 27682, RESULTHI = 16416},
305- this=0x403d8bd8) at wincontrol.inc:2154
306- #8 0x08161955 in DELIVERMESSAGE (TARGET=0x403d8bd8, AMESSAGE=void) at gtkproc.inc:3242
307- #9 0x0818897c in GTKWSBUTTON_CLICKED (AWIDGET=0x8285380, AINFO=0x40453794) at gtkwsbuttons.pp:112
308- #10 0x401d7877 in gtk_marshal_NONE__NONE () from /usr/lib/libgtk-1.2.so.0
309- #11 0x40206e5a in gtk_signal_remove_emission_hook () from /usr/lib/libgtk-1.2.so.0
310- #12 0x4020616a in gtk_signal_set_funcs () from /usr/lib/libgtk-1.2.so.0
311- #13 0x40204234 in gtk_signal_emit () from /usr/lib/libgtk-1.2.so.0
312- #14 0x40176e1c in gtk_button_clicked () from /usr/lib/libgtk-1.2.so.0
313- #15 0x4017838a in gtk_button_get_relief () from /usr/lib/libgtk-1.2.so.0
314- #16 0x401d7877 in gtk_marshal_NONE__NONE () from /usr/lib/libgtk-1.2.so.0
315- #17 0x4020607b in gtk_signal_set_funcs () from /usr/lib/libgtk-1.2.so.0
316- #18 0x40204234 in gtk_signal_emit () from /usr/lib/libgtk-1.2.so.0
317- #19 0x40176d60 in gtk_button_released () from /usr/lib/libgtk-1.2.so.0
318- #20 0x40177d26 in gtk_button_get_relief () from /usr/lib/libgtk-1.2.so.0
319- #21 0x401d764d in gtk_marshal_BOOL__POINTER () from /usr/lib/libgtk-1.2.so.0
320- #22 0x4020619f in gtk_signal_set_funcs () from /usr/lib/libgtk-1.2.so.0
321- #23 0x40204234 in gtk_signal_emit () from /usr/lib/libgtk-1.2.so.0
322- #24 0x40239fd9 in gtk_widget_event () from /usr/lib/libgtk-1.2.so.0
323- #25 0x401d74d0 in gtk_propagate_event () from /usr/lib/libgtk-1.2.so.0
324- #26 0x401d65c1 in gtk_main_do_event () from /usr/lib/libgtk-1.2.so.0
325- #27 0x40065b44 in gdk_wm_protocols_filter () from /usr/lib/libgdk-1.2.so.0
326- #28 0x4003de75 in g_get_current_time () from /usr/lib/libglib-1.2.so.0
327- #29 0x4003e32c in g_get_current_time () from /usr/lib/libglib-1.2.so.0
328- #30 0x4003e4f5 in g_main_iteration () from /usr/lib/libglib-1.2.so.0
329- #31 0x401d6388 in gtk_main_iteration_do () from /usr/lib/libgtk-1.2.so.0
330- #32 0x080b4d26 in TGTKWIDGETSET__WAITMESSAGE (this=0x40473014) at gtkobject.inc:1427
331- #33 0x08070073 in TAPPLICATION__IDLE (this=0x4045b014) at application.inc:319
332- #34 0x08070ffb in TAPPLICATION__HANDLEMESSAGE (this=0x4045b014) at application.inc:827
333- #35 0x08071380 in RUNMESSAGE (parentfp=0xbffff5a4) at application.inc:933
334- #36 0x080712d7 in TAPPLICATION__RUN (this=0x4045b014) at application.inc:944
335- #37 0x080531c3 in main () at project1.lpr:13
336- (gdb)
337-```
243+TODO: Write Me :)
338244
339-This Backtrace was produced using this code:
340-```
341-30. procedure TForm1.Button1Click(Sender: TObject);
342- 31. var
343- 32. X, Y, Z: Integer;
344- 33. begin
345- 34. X := 0;
346- 35. Y := 0;
347- 36. Z := X div Y; // division by zero error
348- 37. end;
349-```
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)`
350294
295+This Backtrace was produced using this code:
296+
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;`
305+
351306## See Also
352307
353- * [[Creating a Backtrace with lldb]]
308+- [[Creating a Backtrace with lldb]]
354309
355310---
356-*From the Free Pascal wiki, page "Creating a Backtrace with GDB", as the Internet Archive kept it on 2022-08-10. 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).*
311+*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