Sign in Join
Wiki copytemporary

Creating a Backtrace with GDB: what changed

Revision 1 to 2. 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+
121## Reasons to create a backtrace
222
323### Bug Reports
424
5-Backtraces can be very helpful when submitting bug reports. They will no doubt increase the chances of the bug getting fixed sooner.
25+Backtraces can be very helpful when submitting bug reports. They will no doubt increase the chances of the bug getting fixed sooner.
626
727### Help yourself find a problem
828
9-A backtrace can really take the pain out of finding a problem with your own program. Often exposing the problem immediately.
29+A backtrace can really take the pain out of finding a problem with your own program. Often exposing the problem immediately.
1030
1131### Just plain fun!!
1232
13-Okay this might be a stretch, but making backtraces is just plain fun!
33+Okay this might be a stretch, but making backtraces is just plain fun!
1434
15-Seriously though, if you can think of another reason to create a backtrace add it here.
35+Seriously though, if you can think of another reason to create a backtrace add it here.
1636
1737## Creating a Backtrace
1838
19-Note: **Mac users** should use *lldb* instead of *gdb*.
39+Note: **Mac users** should use _lldb_ instead of _gdb_.
2040
21-To create a backtrace with [[GDB]] (Gnu DeBugger):
41+To create a backtrace with [[GDB]] (Gnu DeBugger):
2242
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!
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!
2646
2747### Very short how-to
2848
29-Linux terminal:
30-
31-` $ cd program_folder`\
32-` $ gdb program_name`\
33-` run`
34-
35-Then AV happens. Type:
49+Linux terminal:
50+```
51+$ cd program_folder
52+ $ gdb program_name
53+ run
54+```
3655
37-` bt`
56+Then AV happens. Type:
57+```
58+bt
59+```
3860
3961### Directly from the Call Stack window
4062
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.
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.
4264
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.
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.
4971
5072### Windows Users
5173
52-1\. Open a MS-DOS prompt
53-
54-2\. Change to the drive you have your exe on:
55-
56-`C: {press enter}`
74+1\. Open a MS-DOS prompt
5775
58-3\. Change to the directory containing the exe:
76+2\. Change to the drive you have your exe on:
77+```
78+C: {press enter}
79+```
5980
60-`cd \myprograms\Project1 {press enter}`
81+3\. Change to the directory containing the exe:
82+```
83+cd \myprograms\Project1 {press enter}
84+```
6185
62-4\. Load your program with GDB:
86+4\. Load your program with GDB:
87+```
88+gdb Project1.exe {press enter}
89+```
6390
64-`gdb Project1.exe {press enter}`
91+
6592
6693### Linux/BSD Users
6794
68-1\. Open your favorite Terminal program
69-
70-2\. Change to the directory containing the executable:
71-
72-`cd $HOME/myprograms/project1 {press enter}`
95+1\. Open your favorite Terminal program
7396
74-3\. Load your program with GDB:
97+2\. Change to the directory containing the executable:
98+```
99+cd $HOME/myprograms/project1 {press enter}
100+```
75101
76-`gdb project1 {press enter}`
102+3\. Load your program with GDB:
103+```
104+gdb project1 {press enter}
105+```
77106
78107### macOS
79108
80109GDB is not available by default on macOS. You should use the macOS default [[Creating a Backtrace with lldb|lldb debugger]]
81110
82111#### macOS: Graphical application
83112
84-1\. If not already done: create the application bundle (Project / Project Options / Application / Create Application Bundle)
85-
86-2\. Open your favorite Terminal program
87-
88-3\. Change to the directory containing the application bundle / executable:
113+1\. If not already done: create the application bundle (Project / Project Options / Application / Create Application Bundle)
89114
90-`cd $HOME/myprograms/project1 {press enter}`
115+2\. Open your favorite Terminal program
91116
92-4\. Load your program with GDB:
117+3\. Change to the directory containing the application bundle / executable:
118+```
119+cd $HOME/myprograms/project1 {press enter}
120+```
93121
94-`gdb project1.app/Contents/MacOS/project1 {press enter}`
122+4\. Load your program with GDB:
123+```
124+gdb project1.app/Contents/MacOS/project1 {press enter}
125+```
95126
96127#### macOS: Non graphical application, command line program
97128
98-1\. Open your favorite Terminal program
99-
100-2\. Change to the directory containing the executable:
101-
102-`cd $HOME/myprograms/project1 {press enter}`
129+1\. Open your favorite Terminal program
103130
104-3\. Load your program with GDB:
131+2\. Change to the directory containing the executable:
132+```
133+cd $HOME/myprograms/project1 {press enter}
134+```
105135
106-`gdb project1 {press enter}`
136+3\. Load your program with GDB:
137+```
138+gdb project1 {press enter}
139+```
107140
108141### GDB ready to accept commands
109142
110-You should now see a prompt that looks something like this:
111-
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) _`
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+```
120154
121155**Let GDB stop when an exception is raised**
122-
123-`(gdb) break fpc_raiseexception {press enter}`
156+```
157+(gdb) break fpc_raiseexception {press enter}
158+```
124159
125160**Now, run your program:**
126-
127-`(gdb) run {press enter}`
128-
129-Your program will run normally, until it crashes or causes an error.
130-
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.
132-
133-Switch over to your MS-DOS window or Terminal and you should have a screen something like this:
161+```
162+(gdb) run {press enter}
163+```
134164
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) _`
165+Your program will run normally, until it crashes or causes an error.
139166
140-To create a backtrace now type:
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.
141168
142-`backtrace {press enter}`
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+```
143176
144-or
177+To create a backtrace now type:
178+```
179+backtrace {press enter}
180+```
145181
146-`bt {press enter}`
182+or
183+```
184+bt {press enter}
185+```
147186
148-You should now have a screen that looks something like this:
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+```
149211
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) _`
212+[![Note-icon.png](/wiki-images/b/be/Note-icon.png)](</File:Note-icon.png>)
171213
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
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
173215
174216The information displayed here has the sequence of events up to where the error occured. [[Creating a Backtrace with GDB|Understanding a Backtrace]]
175217
176-To exit GDB (and your program) you may now type:
177-
178-`quit {press enter}`
218+To exit GDB (and your program) you may now type:
219+```
220+quit {press enter}
221+```
179222
180-Or to continue running until the next exception type:
223+Or to continue running until the next exception type:
224+```
225+cont {press enter}
226+```
181227
182-`cont {press enter}`
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_
183229
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*
230+[![Note-icon.png](/wiki-images/b/be/Note-icon.png)](</File:Note-icon.png>)
185231
186-> **Note:** The use of an english keyboard layout can prevent problems with gdb (e.g. if you type special characters like ' \\ ').
232+**Note:** The use of an english keyboard layout can prevent problems with gdb (e.g. if you type special characters like ' \ ').
187233
188234## using lldb on Mac
189235
190-start lldb
191-
192-
193-lldb
236+start lldb
194237
195-load your project
238+ lldb
196239
197-
198-target create project1.app/MacOs/Contents/project1
240+load your project
199241
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
242+ target create project1.app/MacOs/Contents/project1
201243
202-
203-breakpoint set --func fpc_raiseexception
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
204245
205-run it
246+ breakpoint set --func fpc_raiseexception
206247
207-
208-r
248+run it
209249
210-when it stops, get the backtrace
250+ r
211251
212-
213-bt
252+when it stops, get the backtrace
214253
215-show locals for different frames (replace 1 in frame select, with different frames, e.g. top 3 or top 5)
254+ bt
216255
217-
218-frame select 1
256+show locals for different frames (replace 1 in frame select, with different frames, e.g. top 3 or top 5)
219257
220-frame variable -P 1
258+ frame select 1
259+ frame variable -P 1
221260
222261## Getting the Backtrace out of the terminal and into an email
223262
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:
225-
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:
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:
228264
229-`gdb project1 > output.txt`
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:
230267
231-Now you can open the file and copy/paste it into your email.
268+```
269+gdb project1 > output.txt
270+```
232271
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.
272+Now you can open the file and copy/paste it into your email.
234273
235-Exception: On Linux you can get around not being able to see with the following command:
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.
236275
237-`touch output.txt & tail output.txt -f & gdb project1 > output.txt`
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+```
238280
239281## Understanding a Backtrace
240282
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.
242-
243-TODO: Write Me :)
244-
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)`
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.
294284
295-This Backtrace was produced using this code:
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+```
296338
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;`
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+```
305350
306351## See Also
307352
308-- [[Creating a Backtrace with lldb]]
353+ * [[Creating a Backtrace with lldb]]
309354
310355---
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).*
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).*

Back to history