blob: 16d31c4813378e7d6cc12bb1b82a303f43f122dc [file] [log] [blame]
Greg Clayton198e8fe2010-10-04 02:33:45 +00001<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml">
3<head>
4<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5<link href="style.css" rel="stylesheet" type="text/css" />
6<title>LLDB Homepage</title>
7</head>
8
9<body>
10 <div class="www_title">
11 The <strong>LLDB</strong> Debugger
12 </div>
13
14<div id="container">
15 <div id="content">
16 <!--#include virtual="sidebar.incl"-->
17
18 <div id="middle">
19 <div class="post">
20 <h1 class ="postheader">Stack Frame and Thread Format</h1>
21 <div class="postcontent">
22 <p>LLDB was recently modified to allow users to define the
23 format of the information that generates the descriptions
24 for threads and stack frames. Typically when your program stops
25 at a breakpoint you will get a line that describes why
26 your thread stopped:</p>
27
28 <p><b><code>* thread #1: tid = 0x2e03, 0x0000000100000e85 a.out`main + 4, stop reason = breakpoint 1.1</code></b></p>
29
30 <p>Stack backtraces frames also have a similar information line:</p>
31
32 <p><code><b>(lldb)</b> thread backtrace
33 <br><b>thread #1: tid = 0x2e03, stop reason = breakpoint 1.1
34 <br>&nbsp;&nbsp;frame #0: 0x0000000100000e85 a.out`main + 4 at test.c:19
35 <br>&nbsp;&nbsp;frame #1: 0x0000000100000e40 a.out`start + 52
36 </code></b></p>
37
38 <p>The two format strings can currently be set using the <b>settings set</b> command:</p>
Jason Molendabc088c72011-08-25 02:46:44 +000039 <p><code><b>(lldb)</b> settings set frame-format STRING
40 <br><b>(lldb)</b> settings set thread-format STRING
Greg Clayton198e8fe2010-10-04 02:33:45 +000041 </p></code>
42
43 </div>
44 <div class="postfooter"></div>
45 </div>
46
47 <div class="post">
48 <h1 class ="postheader">Format Strings</h1>
49 <div class="postcontent">
50
51 <p>So what is the format of the format strings? Format strings can
52 contain plain text, control characters and variables that have access
53 to the current program state.</p>
54
55 <p>Normal characters are any text that doesn't contain a <code><b>'{'</b></code>, <code><b>'}'</b></code>, <code><b>'$'</b></code>,
56 or <code><b>'\'</b></code> character.</p>
57
58 <p>Variable names are found in between a <code><b>"${"</b></code> prefix, and
59 end with a <code><b>"}"</b></code> suffix. In other words, a variable looks like
60 <code>"<b>${frame.pc}</b>"</code>.</p>
61
62 </div>
63 <div class="postfooter"></div>
64 </div>
65
66 <div class="post">
67 <h1 class ="postheader">Variables</h1>
68 <div class="postcontent">
69
70 <p>A complete list of currently supported format string variables is listed below:</p>
71
72 <table border="1">
73 <tr valign=top><td><b>Variable Name</b></td><td><b>Description</b></td></tr>
74 <tr valign=top><td><b>file.basename</b></td><td>The current compile unit file basename for the current frame.</td></tr>
75 <tr valign=top><td><b>file.fullpath</b></td><td>The current compile unit file fullpath for the current frame.</td></tr>
76 <tr valign=top><td><b>frame.index</b></td><td>The frame index (0, 1, 2, 3...)</td></tr>
77 <tr valign=top><td><b>frame.pc</b></td><td>The generic frame register for the program counter.</td></tr>
78 <tr valign=top><td><b>frame.sp</b></td><td>The generic frame register for the stack pointer.</td></tr>
79 <tr valign=top><td><b>frame.fp</b></td><td>The generic frame register for the frame pointer.</td></tr>
80 <tr valign=top><td><b>frame.flags</b></td><td>The generic frame register for the flags register.</td></tr>
81 <tr valign=top><td><b>frame.reg.NAME</b></td><td>Access to any platform specific register by name (replace <b>NAME</b> with the name of the desired register).</td></tr>
Greg Clayton688082e2012-01-13 08:41:20 +000082 <tr valign=top><td><b>function.name</b></td><td>The name of the current function or symbol.</td></tr>
83 <tr valign=top><td><b>function.name-with-args</b></td><td>The name of the current function with arguments and values or the symbol name.</td></tr>
Greg Clayton198e8fe2010-10-04 02:33:45 +000084 <tr valign=top><td><b>function.pc-offset</b></td><td>The program counter offset within the current function or symbol</td></tr>
85 <tr valign=top><td><b>line.file.basename</b></td><td>The line table entry basename to the file for the current line entry in the current frame.</td></tr>
86 <tr valign=top><td><b>line.file.fullpath</b></td><td>The line table entry fullpath to the file for the current line entry in the current frame.</td></tr>
87 <tr valign=top><td><b>line.number</b></td><td>The line table entry line number for the current line entry in the current frame.</td></tr>
88 <tr valign=top><td><b>line.start-addr</b></td><td>The line table entry start address for the current line entry in the current frame.</td></tr>
89 <tr valign=top><td><b>line.end-addr</b></td><td>The line table entry end address for the current line entry in the current frame.</td></tr>
90 <tr valign=top><td><b>module.file.basename</b></td><td>The basename of the current module (shared library or executable)</td></tr>
91 <tr valign=top><td><b>module.file.fullpath</b></td><td>The basename of the current module (shared library or executable)</td></tr>
92 <tr valign=top><td><b>process.file.basename</b></td><td>The basename of the file for the process</td></tr>
93 <tr valign=top><td><b>process.file.fullpath</b></td><td>The fullname of the file for the process</td></tr>
94 <tr valign=top><td><b>process.id</b></td><td>The process ID native the the system on which the inferior runs.</td></tr>
95 <tr valign=top><td><b>process.name</b></td><td>The name of the process at runtime</td></tr>
96 <tr valign=top><td><b>thread.id</b></td><td>The thread identifier for the current thread</td></tr>
97 <tr valign=top><td><b>thread.index</b></td><td>The unique one based thread index ID which is guaranteed to be unique as threads come and go.</td></tr>
98 <tr valign=top><td><b>thread.name</b></td><td>The name of the thread if the target OS supports naming threads</td></tr>
99 <tr valign=top><td><b>thread.queue</b></td><td>The queue name of the thread if the target OS supports dispatch queues</td></tr>
100 <tr valign=top><td><b>thread.stop-reason</b></td><td>A textual reason each thread stopped</td></tr>
Jim Ingham1586d972011-12-17 01:35:57 +0000101 <tr valign=top><td><b>thread.return-value</b></td><td>The return value of the latest step operation (currently only for step-out.)</td></tr>
Greg Clayton198e8fe2010-10-04 02:33:45 +0000102 <tr valign=top><td><b>target.arch</b></td><td>The architecture of the current target</td></tr>
103 </table>
104
105 </div>
106 <div class="postfooter"></div>
107 </div>
108
109 <div class="post">
110 <h1 class ="postheader">Control Characters</h1>
111 <div class="postcontent">
112
113 <p>Control characters include <b><code>'{'</code></b>,
114 <b><code>'}'</code></b>, and <b><code>'\'</code></b>.</p>
115
116 <p>The '{' and '}' are used for scoping blocks, and the '\' character
117 allows you to desensitize control characters and also emit non-printable
118 characters.
119
120 </div>
121 <div class="postfooter"></div>
122 </div>
123
124 <div class="post">
125 <h1 class ="postheader">Desensitizing Characters in the format string</h1>
126 <div class="postcontent">
127 <p>The backslash control character allows your to enter the typical
128 <b><code>"\a"</code></b>, <b><code>"\b"</code></b>, <b><code>"\f"</code></b>, <b><code>"\n"</code></b>,
129 <b><code>"\r"</code></b>, <b><code>"\t"</code></b>, <b><code>"\v"</code></b>, <b><code>"\\"</code></b>, characters
130 and along with the standard octal representation <b><code>"\0123"</code></b>
131 and hex <b><code>"\xAB"</code></b> characters. This allows you to enter
132 escape characters into your format strings and will
133 allow colorized output for terminals that support color.
134
135 </div>
136 <div class="postfooter"></div>
137 </div>
138
139 <div class="post">
140 <h1 class ="postheader">Scoping</h1>
141 <div class="postcontent">
142 <p>Many times the information that you might have in your prompt might not be
143 available and you won't want it to print out if it isn't valid. To take care
144 of this you can enclose everything that <b>must</b> resolve into a scope. A scope
145 is starts with <code><b>'{'</code></b> and ends with
146 <code><b>'}'</code></b>. For example in order to only display
147 the current frame line table entry basename and line number when the information
148 is available for the current frame:
149
150 <p><b><code>"{ at {$line.file.basename}:${line.number}}"</code></b></p>
151
152 <p>Broken down this is:
153 <ul>
154 <li>The start the scope <p><b><code>"{"</code></b></p></li>
155 <li> format whose content will only be displayed if all information is available:
156 <p><b><code>"at {$line.file.basename}:${line.number}"</code></b></p></li>
157 <li>end the scope: <p><b><code>"}"</code></b></p></li>
158 </ul>
159
160 </div>
161 <div class="postfooter"></div>
162 </div>
163
164 <div class="post">
165 <h1 class ="postheader">Making the Frame Format</h1>
166 <div class="postcontent">
167 <p>The information that we see when stopped in a frame:
168
169 <p><b><code>frame #0: 0x0000000100000e85 a.out`main + 4 at test.c:19</code></b></p>
170
171 <p>can be displayed with the following format:</p>
172
173 <p><b><code>"frame #${frame.index}: ${frame.pc}{ ${module.file.basename}`${function.name}{${function.pc-offset}}}{ at ${line.file.basename}:${line.number}}\n"</code></b></p>
174
175 <p>This breaks down to:
176
177 <ul>
178 <li>Always print the frame index and frame PC:
179
180 <p><b><code>"frame #${frame.index}: ${frame.pc}"</code></b></p>
181
182 <li>only print the module followed by a tick if there is a valid
183 module for the current frame:
184
185 <p><b><code>"{ ${module.file.basename}`}"</code></b></p>
186
187 <li>print the function name with optional offset:</p>
188 <p><b><code>"{${function.name}{${function.pc-offset}}}"</code></b></p>
189
190 <li>print the line info if it is available:</p>
191
192 <p><b><code>"{ at ${line.file.basename}:${line.number}}"</code></b></p>
193
194 <li>then finish off with a newline:</p>
195
196 <p><b><code>"\n"</code></b></p>
197 </ul>
198
199 </div>
200 <div class="postfooter"></div>
201 </div>
202
203 <div class="post">
204 <h1 class ="postheader">Making Your Own Formats</h1>
205 <div class="postcontent">
206
207 <p>When modifying your own format strings, it is useful
208 to start with the default values for the frame and
209 thread format strings. These can be accessed with the
210 <b><code>"settings show"</code></b> command:
211
212 <p><b><code>(lldb)</b> settings show thread-format
213 <br>thread-format (string) = 'thread #${thread.index}: tid = ${thread.id}{, ${frame.pc}}{ ${module.file.basename}`${function.name}{${function.pc-offset}}}{, stop reason = ${thread.stop-reason}}{, name = ${thread.name}}{, queue = ${thread.queue}}\n'
214 <br><b>(lldb)</b> settings show frame-format
215 <br>frame-format (string) = 'frame #${frame.index}: ${frame.pc}{ ${module.file.basename}`${function.name}{${function.pc-offset}}}{ at ${line.file.basename}:${line.number}}\n'
216 </code></p>
217
218
Greg Clayton9d49e0e2010-10-04 03:06:05 +0000219 <p>When making thread formats, you will need surround any
220 of the information that comes from a stack frame with scopes (<b>{</b> <i>frame-content</i> <b>}</b>)
221 as the thread format doesn't always want to show frame information.
222 When displaying the backtrace for a thread, we don't need to duplicate
223 the information for frame zero in the thread information:
224
225 <p><code><b>(lldb)</b> thread backtrace
226 <br>thread #1: tid = 0x2e03, stop reason = breakpoint 1.1 2.1
227 <br>&nbsp;&nbsp;frame #0: 0x0000000100000e85 a.out`main + 4 at test.c:19
228 <br>&nbsp;&nbsp;frame #1: 0x0000000100000e40 a.out`start + 52
229 </code>
230 </p>
231
232 <p>The frame related variables are:
233 <ul>
234 <li><code><b>${file.*}</b></code></li>
235 <li><code><b>${frame.*}</b></code></li>
236 <li><code><b>${function.*}</b></code></li>
237 <li><code><b>${line.*}</b></code></li>
238 <li><code><b>${module.*}</b></code></li>
239 </ul>
240 </p>
241
242 <p>Looking at the default format for the thread, and underlining
243 the frame information:
244 <p><code>'thread #${thread.index}: tid = ${thread.id}<u><b>{</b>, ${frame.pc}<b>}{</b> ${module.file.basename}`${function.name}{${function.pc-offset}}<b>}</b></u>{, stop reason = ${thread.stop-reason}}{, name = ${thread.name}}{, queue = ${thread.queue}}\n'
245 </code></p>
246 <p>We can see that all frame information is contained in scopes so
247 that when the thread information is displayed in a context where
248 we only want to show thread information, we can do so.
249
Greg Clayton198e8fe2010-10-04 02:33:45 +0000250 </div>
251 <div class="postfooter"></div>
252 </div>
253
254 </div>
255 </div>
256</div>
257</body>
Greg Clayton688082e2012-01-13 08:41:20 +0000258</html>