summaryrefslogtreecommitdiffstats
path: root/doc/tdevelop/debugger.docbook
blob: 247d26ff5da70e51f4d0f40466e883b8efb75c59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<chapter id="debugger">
<title>The Debugger Interface</title>
<indexterm zone="debugger"><primary>debugger</primary></indexterm>

<para>
For C and C++, &tdevelop; contains an internal debugger that is directly
integrated with the editor. Technically, it is implemented as a frontend
that uses the portable &GNU; debugger <application>gdb</application> through
a pipe. The debugger can be started in several ways:
</para>

<itemizedlist>
<listitem>
<para>
With <menuchoice><guimenu>Debug</guimenu><guimenuitem>Start</guimenuitem></menuchoice>,
the main program of your project is loaded into the debugger.
</para>
</listitem>

<listitem>
<para>
Using <menuchoice><guimenu>Debug</guimenu>
<guimenuitem>Start (other)</guimenuitem>
<guimenuitem>Examine core file</guimenuitem></menuchoice> you load a core file
into memory, which is generated by the operating system kernel when the
program has crashed (The generation of core files may be switched off on your
system, see <application>ulimit(1)</application>). This is useful for a
post-mortem analysis of a program.
</para>
</listitem>

<listitem>
<para>
With <menuchoice><guimenu>Debug</guimenu>
<guimenuitem>Start (other)</guimenuitem>
<guimenuitem>Attach to process</guimenuitem></menuchoice> you invoke the
debugger on an already running program. You will be shown a
process list where you can select the process which the debugger
should take over.
</para>
</listitem>

<listitem>
<para>
Note that debugging is only possible if your project has been compiled with
debugging information enabled. It can be activated in the
<guibutton>Compiler options</guibutton> dialog. When this option is switched
on, the compiler generates additional data which allows the debugger to
associate file names and line numbers with addresses in the executable.
</para>
</listitem>
</itemizedlist>

<para>
The debugger frontend offers several views <quote>into</quote> the process:
</para>

<para>If you try to debug a project without debugging information, you get
the message <computeroutput>No source...</computeroutput> in the status
bar.If you try to set a breakpoint, it is shown as <computeroutput>Pending
(add)</computeroutput> in the breakpoint window (see below).
</para>

<variablelist>
<varlistentry>
<term>Variables</term>
<listitem>
<indexterm zone="debugger"><primary>watch variables</primary></indexterm>
<para>
This window lists the values of all local variables at the current execution
point of the program. It covers the variables in the complete call stack,
&ie;  the function where the process was interrupted, the function that called
this function, and so on up to <function>main()</function> function.
</para>

<para>
Another branch in the variables contains watch variables. You can configure
yourself which variables are shown here. Both local and global variables can
be watched. You can add variables either by clicking on the
<guibutton>Add</guibutton> button or pressing <keycap>Return</keycap> while
the <guilabel>Watch</guilabel> item is selected. They can be removed again
via the context menu.
</para>
</listitem>
</varlistentry>

<varlistentry>
<term>Frame Stack</term>
<listitem>
<indexterm zone="debugger"><primary>frame stack</primary></indexterm>
<para>
(... to be written ...)
</para>
</listitem>
</varlistentry>

<varlistentry>
<term>Breakpoints</term>
<listitem>
<indexterm zone="debugger"><primary>breakpoints</primary></indexterm>
<para>
This window allows you to see and manipulate the breakpoints.  Remember that
&tdevelop; uses <application>GDB</application>, so to fully understand the
&tdevelop; debugging features, you should know a little bit about the <ulink
url="http://www.gnu.org/software/gdb">GDB</ulink>.
</para>

<para>If you want to look at the source code, breakpoints are defined in
<filename>tdevelop/languages/cpp/debugger/breakpoint.h</filename>.
</para>

<para>At the left edge, the window has buttons to:</para>

<itemizedlist>
<listitem><para>Add an empty breakpoint</para></listitem>
<listitem><para>Edit the selected breakpoint</para></listitem>
 <listitem><para>Delete the selected breakpoint</para></listitem>
<listitem><para>Remove all breakpoints</para></listitem>
</itemizedlist>

<para>The main part of the window is a table with 7 columns.  Each line in
the table is a breakpoint.  The columns are:</para>

<orderedlist>
<listitem><para>Selection checkbox</para></listitem>
<listitem><para>Type: one of: Invalid, File:Line, Watchpoint, Address, Function</para></listitem>
<listitem><para>Status. Values are:</para>
<itemizedlist>
  <listitem><para>Active</para></listitem>
  <listitem><para>Disabled: Each breakpoint may be <quote>enabled</quote> or
  <quote>disabled</quote>; if disabled, it has no effect on your program until
  you enable it again.</para></listitem>
  <listitem><para>Pending (add): a breakpoint is marked like this if no
  debugging information is available. From GDB Info page:
  <blockquote><para>If a specified breakpoint location cannot be found, it may be due to
  the fact that the location is in a shared library that is yet to be
  loaded.  In such a case, you may want GDB to create a special
  breakpoint (known as a <quote>pending breakpoint</quote>) that attempts to resolve
  itself in the future when an appropriate shared library gets loaded.</para>
  </blockquote>
  </para></listitem>
</itemizedlist>
</listitem>
<listitem><para>Pending (clear)</para></listitem>
<listitem><para>Pending (modify)</para></listitem>
<listitem><para>Location in the format filename:linenumber</para></listitem>
<listitem><para>Condition</para></listitem>
<listitem><para>Ignore Count: If this is a number <varname>COUNT</varname>
greater than zero, the next <varname>COUNT</varname> times the breakpoint is
reached, your program's execution does not stop; other than to decrement the
ignore count, <application>gdb</application> takes no action.</para></listitem>
<listitem><para>Hits: counts how many times a breakopint has been hit.</para></listitem>
</orderedlist>


</listitem>
</varlistentry>

<varlistentry>
<term>Disassemble</term>
<listitem>
<indexterm zone="debugger"><primary>disassemble</primary></indexterm>
<para>(... to be written ...)</para>

</listitem>
</varlistentry>
</variablelist>


<sect1 id="settingbreakpoints">
<title>Setting Breakpoints</title>

<para>
(... to be written ...)
</para>

</sect1> <!-- settingbreakpoints -->

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<sect1 id ="debuggeroptions">
<title>Options</title>

<variablelist>
<varlistentry>
<term>Display Mangled Names</term>
<listitem>
<indexterm zone="debugger"><primary>name mangling</primary></indexterm>
<indexterm zone="debugger"><primary>mangling</primary><secondary>name</secondary></indexterm>

<para>
In C++, function names in the executable are <quote>mangled</quote>, &ie;
the function names include information about the argument types. This is
necessary in order to support overloading of functions. The mangling
algorithm is not standardized and differs even between different versions of
the &GNU; C++ compiler.
</para>

<para>
In the disassembling window, normally unmangled names are displayed, so
function signatures appear in the similar way as in the source code, so
they are easily readable. Alternatively, you can decide to see mangled names.
</para>
</listitem>
</varlistentry>

<varlistentry>
<term>Try Setting Breakpoints on Lib Load</term>
<listitem>
<indexterm zone="debugger"><primary>lazy breakpoints</primary></indexterm>
<indexterm zone="debugger"><primary>breakpoints</primary><secondary>lazy</secondary></indexterm>

<para>
The debugger backend <application>gdb</application> does not allow to set
breakpoints within code that is not currently loaded. In a highly modular
application, where often code is only loaded on demand as a plugin (using
the libc function <function>dlopen(3)</function>), this can be inconvenient.
Therefore, &tdevelop; rolls its own support for breakpoints in shared
libraries. If you set this option, it allows you to set breakpoints in
libraries which are not loaded. Then, whenever <application>gdb</application>
notifies that a library is loaded, &tdevelop; tries to set the pending
breakpoints.
</para>
</listitem>
</varlistentry>

<varlistentry>
<term>Enable Floating Toolbar</term>
<listitem>
<indexterm zone="debugger"><primary>debugger toolbar</primary></indexterm>
<indexterm zone="debugger"><primary>toolbar</primary><secondary>debugger</secondary></indexterm>

<para>
(... to be written ...)
</para>
</listitem>
</varlistentry>
</variablelist>

</sect1> <!-- debuggeroptions -->

</chapter> <!-- debugger -->