GNU Binutils with patches for OS216
Revisión | 9733ab3f56072534b447188f48d3d5bc9911189e (tree) |
---|---|
Tiempo | 1999-04-16 10:34:49 |
Autor | Stan Shebs <shebs@code...> |
Commiter | Stan Shebs |
Initial creation of sourceware repository
@@ -0,0 +1,2796 @@ | ||
1 | + | |
2 | +/* A Bison parser, made from c-exp.y | |
3 | + by GNU Bison version 1.25 | |
4 | + */ | |
5 | + | |
6 | +#define YYBISON 1 /* Identify Bison output. */ | |
7 | + | |
8 | +#define INT 258 | |
9 | +#define FLOAT 259 | |
10 | +#define STRING 260 | |
11 | +#define NAME 261 | |
12 | +#define TYPENAME 262 | |
13 | +#define NAME_OR_INT 263 | |
14 | +#define STRUCT 264 | |
15 | +#define CLASS 265 | |
16 | +#define UNION 266 | |
17 | +#define ENUM 267 | |
18 | +#define SIZEOF 268 | |
19 | +#define UNSIGNED 269 | |
20 | +#define COLONCOLON 270 | |
21 | +#define TEMPLATE 271 | |
22 | +#define ERROR 272 | |
23 | +#define SIGNED_KEYWORD 273 | |
24 | +#define LONG 274 | |
25 | +#define SHORT 275 | |
26 | +#define INT_KEYWORD 276 | |
27 | +#define CONST_KEYWORD 277 | |
28 | +#define VOLATILE_KEYWORD 278 | |
29 | +#define DOUBLE_KEYWORD 279 | |
30 | +#define VARIABLE 280 | |
31 | +#define ASSIGN_MODIFY 281 | |
32 | +#define THIS 282 | |
33 | +#define TRUEKEYWORD 283 | |
34 | +#define FALSEKEYWORD 284 | |
35 | +#define ABOVE_COMMA 285 | |
36 | +#define OROR 286 | |
37 | +#define ANDAND 287 | |
38 | +#define EQUAL 288 | |
39 | +#define NOTEQUAL 289 | |
40 | +#define LEQ 290 | |
41 | +#define GEQ 291 | |
42 | +#define LSH 292 | |
43 | +#define RSH 293 | |
44 | +#define UNARY 294 | |
45 | +#define INCREMENT 295 | |
46 | +#define DECREMENT 296 | |
47 | +#define ARROW 297 | |
48 | +#define BLOCKNAME 298 | |
49 | +#define FILENAME 299 | |
50 | + | |
51 | +#line 38 "c-exp.y" | |
52 | + | |
53 | + | |
54 | +#include "defs.h" | |
55 | +#include "gdb_string.h" | |
56 | +#include <ctype.h> | |
57 | +#include "expression.h" | |
58 | +#include "value.h" | |
59 | +#include "parser-defs.h" | |
60 | +#include "language.h" | |
61 | +#include "c-lang.h" | |
62 | +#include "bfd.h" /* Required by objfiles.h. */ | |
63 | +#include "symfile.h" /* Required by objfiles.h. */ | |
64 | +#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */ | |
65 | + | |
66 | +/* Flag indicating we're dealing with HP-compiled objects */ | |
67 | +extern int hp_som_som_object_present; | |
68 | + | |
69 | +/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), | |
70 | + as well as gratuitiously global symbol names, so we can have multiple | |
71 | + yacc generated parsers in gdb. Note that these are only the variables | |
72 | + produced by yacc. If other parser generators (bison, byacc, etc) produce | |
73 | + additional global names that conflict at link time, then those parser | |
74 | + generators need to be fixed instead of adding those names to this list. */ | |
75 | + | |
76 | +#define yymaxdepth c_maxdepth | |
77 | +#define yyparse c_parse | |
78 | +#define yylex c_lex | |
79 | +#define yyerror c_error | |
80 | +#define yylval c_lval | |
81 | +#define yychar c_char | |
82 | +#define yydebug c_debug | |
83 | +#define yypact c_pact | |
84 | +#define yyr1 c_r1 | |
85 | +#define yyr2 c_r2 | |
86 | +#define yydef c_def | |
87 | +#define yychk c_chk | |
88 | +#define yypgo c_pgo | |
89 | +#define yyact c_act | |
90 | +#define yyexca c_exca | |
91 | +#define yyerrflag c_errflag | |
92 | +#define yynerrs c_nerrs | |
93 | +#define yyps c_ps | |
94 | +#define yypv c_pv | |
95 | +#define yys c_s | |
96 | +#define yy_yys c_yys | |
97 | +#define yystate c_state | |
98 | +#define yytmp c_tmp | |
99 | +#define yyv c_v | |
100 | +#define yy_yyv c_yyv | |
101 | +#define yyval c_val | |
102 | +#define yylloc c_lloc | |
103 | +#define yyreds c_reds /* With YYDEBUG defined */ | |
104 | +#define yytoks c_toks /* With YYDEBUG defined */ | |
105 | +#define yylhs c_yylhs | |
106 | +#define yylen c_yylen | |
107 | +#define yydefred c_yydefred | |
108 | +#define yydgoto c_yydgoto | |
109 | +#define yysindex c_yysindex | |
110 | +#define yyrindex c_yyrindex | |
111 | +#define yygindex c_yygindex | |
112 | +#define yytable c_yytable | |
113 | +#define yycheck c_yycheck | |
114 | + | |
115 | +#ifndef YYDEBUG | |
116 | +#define YYDEBUG 0 /* Default to no yydebug support */ | |
117 | +#endif | |
118 | + | |
119 | +int | |
120 | +yyparse PARAMS ((void)); | |
121 | + | |
122 | +static int | |
123 | +yylex PARAMS ((void)); | |
124 | + | |
125 | +void | |
126 | +yyerror PARAMS ((char *)); | |
127 | + | |
128 | + | |
129 | +#line 120 "c-exp.y" | |
130 | +typedef union | |
131 | + { | |
132 | + LONGEST lval; | |
133 | + struct { | |
134 | + LONGEST val; | |
135 | + struct type *type; | |
136 | + } typed_val_int; | |
137 | + struct { | |
138 | + DOUBLEST dval; | |
139 | + struct type *type; | |
140 | + } typed_val_float; | |
141 | + struct symbol *sym; | |
142 | + struct type *tval; | |
143 | + struct stoken sval; | |
144 | + struct ttype tsym; | |
145 | + struct symtoken ssym; | |
146 | + int voidval; | |
147 | + struct block *bval; | |
148 | + enum exp_opcode opcode; | |
149 | + struct internalvar *ivar; | |
150 | + | |
151 | + struct type **tvec; | |
152 | + int *ivec; | |
153 | + } YYSTYPE; | |
154 | +#line 145 "c-exp.y" | |
155 | + | |
156 | +/* YYSTYPE gets defined by %union */ | |
157 | +static int | |
158 | +parse_number PARAMS ((char *, int, int, YYSTYPE *)); | |
159 | +#include <stdio.h> | |
160 | + | |
161 | +#ifndef __cplusplus | |
162 | +#ifndef __STDC__ | |
163 | +#define const | |
164 | +#endif | |
165 | +#endif | |
166 | + | |
167 | + | |
168 | + | |
169 | +#define YYFINAL 214 | |
170 | +#define YYFLAG -32768 | |
171 | +#define YYNTBASE 69 | |
172 | + | |
173 | +#define YYTRANSLATE(x) ((unsigned)(x) <= 299 ? yytranslate[x] : 91) | |
174 | + | |
175 | +static const char yytranslate[] = { 0, | |
176 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
177 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
178 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
179 | + 2, 2, 62, 2, 2, 2, 52, 38, 2, 59, | |
180 | + 65, 50, 48, 30, 49, 57, 51, 2, 2, 2, | |
181 | + 2, 2, 2, 2, 2, 2, 2, 68, 2, 41, | |
182 | + 32, 42, 33, 47, 2, 2, 2, 2, 2, 2, | |
183 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
184 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
185 | + 58, 2, 64, 37, 2, 2, 2, 2, 2, 2, | |
186 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
187 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
188 | + 2, 2, 66, 36, 67, 63, 2, 2, 2, 2, | |
189 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
190 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
191 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
192 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
193 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
194 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
195 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
196 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
197 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
198 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
199 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
200 | + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
201 | + 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, | |
202 | + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, | |
203 | + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, | |
204 | + 26, 27, 28, 29, 31, 34, 35, 39, 40, 43, | |
205 | + 44, 45, 46, 53, 54, 55, 56, 60, 61 | |
206 | +}; | |
207 | + | |
208 | +#if YYDEBUG != 0 | |
209 | +static const short yyprhs[] = { 0, | |
210 | + 0, 2, 4, 6, 8, 12, 15, 18, 21, 24, | |
211 | + 27, 30, 33, 36, 39, 42, 46, 50, 55, 59, | |
212 | + 63, 68, 73, 74, 80, 82, 83, 85, 89, 91, | |
213 | + 95, 100, 105, 109, 113, 117, 121, 125, 129, 133, | |
214 | + 137, 141, 145, 149, 153, 157, 161, 165, 169, 173, | |
215 | + 177, 181, 185, 191, 195, 199, 201, 203, 205, 207, | |
216 | + 209, 214, 216, 218, 220, 222, 224, 226, 230, 234, | |
217 | + 238, 243, 245, 248, 250, 252, 255, 258, 261, 265, | |
218 | + 269, 271, 274, 276, 279, 281, 285, 288, 290, 293, | |
219 | + 295, 298, 302, 305, 309, 311, 315, 317, 319, 321, | |
220 | + 323, 326, 330, 333, 337, 341, 346, 349, 353, 355, | |
221 | + 358, 361, 364, 367, 370, 373, 375, 378, 380, 386, | |
222 | + 389, 392, 394, 396, 398, 400, 402, 406, 408, 410, | |
223 | + 412, 414, 416 | |
224 | +}; | |
225 | + | |
226 | +static const short yyrhs[] = { 71, | |
227 | + 0, 70, 0, 85, 0, 72, 0, 71, 30, 72, | |
228 | + 0, 50, 72, 0, 38, 72, 0, 49, 72, 0, | |
229 | + 62, 72, 0, 63, 72, 0, 54, 72, 0, 55, | |
230 | + 72, 0, 72, 54, 0, 72, 55, 0, 13, 72, | |
231 | + 0, 72, 56, 89, 0, 72, 56, 79, 0, 72, | |
232 | + 56, 50, 72, 0, 72, 57, 89, 0, 72, 57, | |
233 | + 79, 0, 72, 57, 50, 72, 0, 72, 58, 71, | |
234 | + 64, 0, 0, 72, 59, 73, 75, 65, 0, 66, | |
235 | + 0, 0, 72, 0, 75, 30, 72, 0, 67, 0, | |
236 | + 74, 75, 76, 0, 74, 85, 76, 72, 0, 59, | |
237 | + 85, 65, 72, 0, 59, 71, 65, 0, 72, 47, | |
238 | + 72, 0, 72, 50, 72, 0, 72, 51, 72, 0, | |
239 | + 72, 52, 72, 0, 72, 48, 72, 0, 72, 49, | |
240 | + 72, 0, 72, 45, 72, 0, 72, 46, 72, 0, | |
241 | + 72, 39, 72, 0, 72, 40, 72, 0, 72, 43, | |
242 | + 72, 0, 72, 44, 72, 0, 72, 41, 72, 0, | |
243 | + 72, 42, 72, 0, 72, 38, 72, 0, 72, 37, | |
244 | + 72, 0, 72, 36, 72, 0, 72, 35, 72, 0, | |
245 | + 72, 34, 72, 0, 72, 33, 72, 68, 72, 0, | |
246 | + 72, 32, 72, 0, 72, 26, 72, 0, 3, 0, | |
247 | + 8, 0, 4, 0, 78, 0, 25, 0, 13, 59, | |
248 | + 85, 65, 0, 5, 0, 27, 0, 28, 0, 29, | |
249 | + 0, 60, 0, 61, 0, 77, 15, 89, 0, 77, | |
250 | + 15, 89, 0, 86, 15, 89, 0, 86, 15, 63, | |
251 | + 89, 0, 79, 0, 15, 89, 0, 90, 0, 86, | |
252 | + 0, 86, 22, 0, 86, 23, 0, 86, 81, 0, | |
253 | + 86, 22, 81, 0, 86, 23, 81, 0, 50, 0, | |
254 | + 50, 81, 0, 38, 0, 38, 81, 0, 82, 0, | |
255 | + 59, 81, 65, 0, 82, 83, 0, 83, 0, 82, | |
256 | + 84, 0, 84, 0, 58, 64, 0, 58, 3, 64, | |
257 | + 0, 59, 65, 0, 59, 88, 65, 0, 80, 0, | |
258 | + 86, 15, 50, 0, 7, 0, 21, 0, 19, 0, | |
259 | + 20, 0, 19, 21, 0, 14, 19, 21, 0, 19, | |
260 | + 19, 0, 19, 19, 21, 0, 14, 19, 19, 0, | |
261 | + 14, 19, 19, 21, 0, 20, 21, 0, 14, 20, | |
262 | + 21, 0, 24, 0, 19, 24, 0, 9, 89, 0, | |
263 | + 10, 89, 0, 11, 89, 0, 12, 89, 0, 14, | |
264 | + 87, 0, 14, 0, 18, 87, 0, 18, 0, 16, | |
265 | + 89, 41, 85, 42, 0, 22, 86, 0, 23, 86, | |
266 | + 0, 7, 0, 21, 0, 19, 0, 20, 0, 85, | |
267 | + 0, 88, 30, 85, 0, 6, 0, 60, 0, 7, | |
268 | + 0, 8, 0, 6, 0, 60, 0 | |
269 | +}; | |
270 | + | |
271 | +#endif | |
272 | + | |
273 | +#if YYDEBUG != 0 | |
274 | +static const short yyrline[] = { 0, | |
275 | + 230, 231, 234, 241, 242, 247, 250, 253, 257, 261, | |
276 | + 265, 269, 273, 277, 281, 285, 291, 299, 303, 309, | |
277 | + 317, 321, 325, 329, 335, 339, 342, 346, 350, 353, | |
278 | + 360, 366, 372, 378, 382, 386, 390, 394, 398, 402, | |
279 | + 406, 410, 414, 418, 422, 426, 430, 434, 438, 442, | |
280 | + 446, 450, 454, 458, 462, 468, 475, 486, 493, 496, | |
281 | + 500, 508, 533, 538, 545, 554, 562, 568, 579, 595, | |
282 | + 608, 632, 633, 667, 725, 731, 732, 733, 735, 737, | |
283 | + 741, 743, 745, 747, 749, 752, 754, 759, 766, 768, | |
284 | + 772, 774, 778, 780, 792, 793, 798, 800, 802, 804, | |
285 | + 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, | |
286 | + 826, 829, 832, 835, 838, 840, 842, 844, 849, 856, | |
287 | + 857, 860, 861, 867, 873, 882, 887, 894, 895, 896, | |
288 | + 897, 900, 901 | |
289 | +}; | |
290 | +#endif | |
291 | + | |
292 | + | |
293 | +#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) | |
294 | + | |
295 | +static const char * const yytname[] = { "$","error","$undefined.","INT","FLOAT", | |
296 | +"STRING","NAME","TYPENAME","NAME_OR_INT","STRUCT","CLASS","UNION","ENUM","SIZEOF", | |
297 | +"UNSIGNED","COLONCOLON","TEMPLATE","ERROR","SIGNED_KEYWORD","LONG","SHORT","INT_KEYWORD", | |
298 | +"CONST_KEYWORD","VOLATILE_KEYWORD","DOUBLE_KEYWORD","VARIABLE","ASSIGN_MODIFY", | |
299 | +"THIS","TRUEKEYWORD","FALSEKEYWORD","','","ABOVE_COMMA","'='","'?'","OROR","ANDAND", | |
300 | +"'|'","'^'","'&'","EQUAL","NOTEQUAL","'<'","'>'","LEQ","GEQ","LSH","RSH","'@'", | |
301 | +"'+'","'-'","'*'","'/'","'%'","UNARY","INCREMENT","DECREMENT","ARROW","'.'", | |
302 | +"'['","'('","BLOCKNAME","FILENAME","'!'","'~'","']'","')'","'{'","'}'","':'", | |
303 | +"start","type_exp","exp1","exp","@1","lcurly","arglist","rcurly","block","variable", | |
304 | +"qualified_name","ptype","abs_decl","direct_abs_decl","array_mod","func_mod", | |
305 | +"type","typebase","typename","nonempty_typelist","name","name_not_typename", NULL | |
306 | +}; | |
307 | +#endif | |
308 | + | |
309 | +static const short yyr1[] = { 0, | |
310 | + 69, 69, 70, 71, 71, 72, 72, 72, 72, 72, | |
311 | + 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, | |
312 | + 72, 72, 73, 72, 74, 75, 75, 75, 76, 72, | |
313 | + 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, | |
314 | + 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, | |
315 | + 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, | |
316 | + 72, 72, 72, 72, 72, 77, 77, 77, 78, 79, | |
317 | + 79, 78, 78, 78, 80, 80, 80, 80, 80, 80, | |
318 | + 81, 81, 81, 81, 81, 82, 82, 82, 82, 82, | |
319 | + 83, 83, 84, 84, 85, 85, 86, 86, 86, 86, | |
320 | + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, | |
321 | + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, | |
322 | + 86, 87, 87, 87, 87, 88, 88, 89, 89, 89, | |
323 | + 89, 90, 90 | |
324 | +}; | |
325 | + | |
326 | +static const short yyr2[] = { 0, | |
327 | + 1, 1, 1, 1, 3, 2, 2, 2, 2, 2, | |
328 | + 2, 2, 2, 2, 2, 3, 3, 4, 3, 3, | |
329 | + 4, 4, 0, 5, 1, 0, 1, 3, 1, 3, | |
330 | + 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, | |
331 | + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, | |
332 | + 3, 3, 5, 3, 3, 1, 1, 1, 1, 1, | |
333 | + 4, 1, 1, 1, 1, 1, 1, 3, 3, 3, | |
334 | + 4, 1, 2, 1, 1, 2, 2, 2, 3, 3, | |
335 | + 1, 2, 1, 2, 1, 3, 2, 1, 2, 1, | |
336 | + 2, 3, 2, 3, 1, 3, 1, 1, 1, 1, | |
337 | + 2, 3, 2, 3, 3, 4, 2, 3, 1, 2, | |
338 | + 2, 2, 2, 2, 2, 1, 2, 1, 5, 2, | |
339 | + 2, 1, 1, 1, 1, 1, 3, 1, 1, 1, | |
340 | + 1, 1, 1 | |
341 | +}; | |
342 | + | |
343 | +static const short yydefact[] = { 0, | |
344 | + 56, 58, 62, 132, 97, 57, 0, 0, 0, 0, | |
345 | + 0, 116, 0, 0, 118, 99, 100, 98, 0, 0, | |
346 | + 109, 60, 63, 64, 65, 0, 0, 0, 0, 0, | |
347 | + 0, 133, 67, 0, 0, 25, 2, 1, 4, 26, | |
348 | + 0, 59, 72, 95, 3, 75, 74, 128, 130, 131, | |
349 | + 129, 111, 112, 113, 114, 0, 15, 0, 122, 124, | |
350 | + 125, 123, 115, 73, 0, 124, 125, 117, 103, 101, | |
351 | + 110, 107, 120, 121, 7, 8, 6, 11, 12, 0, | |
352 | + 0, 9, 10, 0, 0, 0, 0, 0, 0, 0, | |
353 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
354 | + 0, 0, 0, 0, 0, 0, 13, 14, 0, 0, | |
355 | + 0, 23, 27, 0, 0, 0, 0, 76, 77, 83, | |
356 | + 81, 0, 0, 78, 85, 88, 90, 0, 0, 105, | |
357 | + 102, 108, 0, 104, 33, 0, 5, 55, 54, 0, | |
358 | + 52, 51, 50, 49, 48, 42, 43, 46, 47, 44, | |
359 | + 45, 40, 41, 34, 38, 39, 35, 36, 37, 130, | |
360 | + 0, 17, 16, 0, 20, 19, 0, 26, 0, 29, | |
361 | + 30, 0, 69, 96, 0, 70, 79, 80, 84, 82, | |
362 | + 0, 91, 93, 0, 126, 75, 0, 0, 87, 89, | |
363 | + 61, 106, 0, 32, 0, 18, 21, 22, 0, 28, | |
364 | + 31, 71, 92, 86, 0, 0, 94, 119, 53, 24, | |
365 | + 127, 0, 0, 0 | |
366 | +}; | |
367 | + | |
368 | +static const short yydefgoto[] = { 212, | |
369 | + 37, 80, 39, 168, 40, 114, 171, 41, 42, 43, | |
370 | + 44, 124, 125, 126, 127, 185, 58, 63, 187, 176, | |
371 | + 47 | |
372 | +}; | |
373 | + | |
374 | +static const short yypact[] = { 205, | |
375 | +-32768,-32768,-32768,-32768,-32768,-32768, 46, 46, 46, 46, | |
376 | + 269, 57, 46, 46, 100, 134, -14,-32768, 228, 228, | |
377 | +-32768,-32768,-32768,-32768,-32768, 205, 205, 205, 205, 205, | |
378 | + 205, 21,-32768, 205, 205,-32768,-32768, -16, 504, 205, | |
379 | + 22,-32768,-32768,-32768,-32768, 107,-32768,-32768,-32768,-32768, | |
380 | +-32768,-32768,-32768,-32768,-32768, 205, 14, 23,-32768, 7, | |
381 | + 24,-32768,-32768,-32768, 10,-32768,-32768,-32768, 34,-32768, | |
382 | +-32768,-32768,-32768,-32768, 14, 14, 14, 14, 14, -26, | |
383 | + -21, 14, 14, 205, 205, 205, 205, 205, 205, 205, | |
384 | + 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, | |
385 | + 205, 205, 205, 205, 205, 205,-32768,-32768, 419, 438, | |
386 | + 205,-32768, 504, -25, -2, 46, 53, 8, 8, 8, | |
387 | + 8, -1, 359,-32768, -41,-32768,-32768, 9, 42, 54, | |
388 | +-32768,-32768, 228,-32768,-32768, 205, 504, 504, 504, 467, | |
389 | + 556, 580, 603, 625, 646, 665, 665, 254, 254, 254, | |
390 | + 254, 124, 124, 356, 416, 416, 14, 14, 14, 89, | |
391 | + 205,-32768,-32768, 205,-32768,-32768, -17, 205, 205,-32768, | |
392 | +-32768, 205, 93,-32768, 46,-32768,-32768,-32768,-32768,-32768, | |
393 | + 45,-32768,-32768, 50,-32768, 146, -22, 128,-32768,-32768, | |
394 | + 333,-32768, 68, 14, 205, 14, 14,-32768, -3, 504, | |
395 | + 14,-32768,-32768,-32768, 67, 228,-32768,-32768, 531,-32768, | |
396 | +-32768, 125, 126,-32768 | |
397 | +}; | |
398 | + | |
399 | +static const short yypgoto[] = {-32768, | |
400 | +-32768, 3, -5,-32768,-32768, -44, 12,-32768,-32768, -76, | |
401 | +-32768, 79,-32768, 11, 16, 1, 0, 113,-32768, 2, | |
402 | +-32768 | |
403 | +}; | |
404 | + | |
405 | + | |
406 | +#define YYLAST 724 | |
407 | + | |
408 | + | |
409 | +static const short yytable[] = { 46, | |
410 | + 45, 181, 38, 84, 169, 57, 72, 206, 52, 53, | |
411 | + 54, 55, 84, 84, 64, 65, 122, 188, 73, 74, | |
412 | + 75, 76, 77, 78, 79, 130, 169, 131, 82, 83, | |
413 | + 46, 81, 162, 165, 113, -66, 116, 129, 135, 46, | |
414 | + 115, 170, 207, 136, 132, 120, 198, 48, 49, 50, | |
415 | + 133, 48, 49, 50, 134, 46, 128, 121, 48, 49, | |
416 | + 50, 210, 182, 59, 170, 122, 123, 107, 108, 109, | |
417 | + 110, 111, 112, 191, 192, 60, 61, 62, 137, 138, | |
418 | + 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, | |
419 | + 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, | |
420 | + 159, 51, 174, -97, 175, 51, 59, -68, 203, 208, | |
421 | + 163, 166, 51, 167, 204, 175, 174, 173, 66, 67, | |
422 | + 62, 117, 186, 199, 213, 214, 172, 68, 118, 119, | |
423 | + 194, 0, 186, 193, 5, 189, 7, 8, 9, 10, | |
424 | + 190, 12, 0, 14, 120, 15, 16, 17, 18, 19, | |
425 | + 20, 21, 69, 0, 70, 196, 121, 71, 197, 0, | |
426 | + 205, 0, 113, 200, 122, 123, 201, 118, 119, 0, | |
427 | + 101, 102, 103, 104, 105, 106, 202, 107, 108, 109, | |
428 | + 110, 111, 112, 120, 0, 194, 0, 186, 0, 209, | |
429 | + 0, 0, 183, 0, 0, 121, 177, 178, 179, 180, | |
430 | + 0, 184, 0, 122, 123, 186, 211, 1, 2, 3, | |
431 | + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, | |
432 | + 14, 0, 15, 16, 17, 18, 19, 20, 21, 22, | |
433 | + 0, 23, 24, 25, 5, 0, 7, 8, 9, 10, | |
434 | + 0, 12, 26, 14, 0, 15, 16, 17, 18, 19, | |
435 | + 20, 21, 0, 27, 28, 0, 0, 0, 29, 30, | |
436 | + 0, 0, 0, 31, 32, 33, 34, 35, 0, 0, | |
437 | + 36, 1, 2, 3, 4, 5, 6, 7, 8, 9, | |
438 | + 10, 11, 12, 13, 14, 0, 15, 16, 17, 18, | |
439 | + 19, 20, 21, 22, 0, 23, 24, 25, 99, 100, | |
440 | + 101, 102, 103, 104, 105, 106, 26, 107, 108, 109, | |
441 | + 110, 111, 112, 0, 0, 0, 0, 27, 28, 0, | |
442 | + 0, 0, 29, 30, 0, 0, 0, 56, 32, 33, | |
443 | + 34, 35, 0, 0, 36, 1, 2, 3, 4, 5, | |
444 | + 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, | |
445 | + 15, 16, 17, 18, 19, 20, 21, 22, 0, 23, | |
446 | + 24, 25, 0, 0, 0, 5, 0, 7, 8, 9, | |
447 | + 10, 0, 12, 0, 14, 0, 15, 16, 17, 18, | |
448 | + 19, 20, 21, 0, 0, 0, 29, 30, 0, 0, | |
449 | + 0, 31, 32, 33, 34, 35, 120, 0, 36, 0, | |
450 | + 0, 0, 0, 102, 103, 104, 105, 106, 121, 107, | |
451 | + 108, 109, 110, 111, 112, 0, 122, 123, 0, 0, | |
452 | + 0, 0, 0, 183, 48, 160, 50, 7, 8, 9, | |
453 | + 10, 0, 12, 0, 14, 0, 15, 16, 17, 18, | |
454 | + 19, 20, 21, 48, 160, 50, 7, 8, 9, 10, | |
455 | + 0, 12, 0, 14, 0, 15, 16, 17, 18, 19, | |
456 | + 20, 21, 0, 0, 0, 104, 105, 106, 161, 107, | |
457 | + 108, 109, 110, 111, 112, 0, 0, 0, 51, 0, | |
458 | + 0, 0, 0, 0, 0, 0, 0, 164, 0, 0, | |
459 | + 0, 0, 85, 0, 0, 0, 0, 51, 86, 87, | |
460 | + 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, | |
461 | + 98, 99, 100, 101, 102, 103, 104, 105, 106, 0, | |
462 | + 107, 108, 109, 110, 111, 112, 0, 0, 0, 85, | |
463 | + 0, 0, 0, 0, 195, 86, 87, 88, 89, 90, | |
464 | + 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, | |
465 | + 101, 102, 103, 104, 105, 106, 0, 107, 108, 109, | |
466 | + 110, 111, 112, 87, 88, 89, 90, 91, 92, 93, | |
467 | + 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, | |
468 | + 104, 105, 106, 0, 107, 108, 109, 110, 111, 112, | |
469 | + 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, | |
470 | + 99, 100, 101, 102, 103, 104, 105, 106, 0, 107, | |
471 | + 108, 109, 110, 111, 112, 90, 91, 92, 93, 94, | |
472 | + 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, | |
473 | + 105, 106, 0, 107, 108, 109, 110, 111, 112, 91, | |
474 | + 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, | |
475 | + 102, 103, 104, 105, 106, 0, 107, 108, 109, 110, | |
476 | + 111, 112, 92, 93, 94, 95, 96, 97, 98, 99, | |
477 | + 100, 101, 102, 103, 104, 105, 106, 0, 107, 108, | |
478 | + 109, 110, 111, 112, 93, 94, 95, 96, 97, 98, | |
479 | + 99, 100, 101, 102, 103, 104, 105, 106, 0, 107, | |
480 | + 108, 109, 110, 111, 112, 95, 96, 97, 98, 99, | |
481 | + 100, 101, 102, 103, 104, 105, 106, 0, 107, 108, | |
482 | + 109, 110, 111, 112 | |
483 | +}; | |
484 | + | |
485 | +static const short yycheck[] = { 0, | |
486 | + 0, 3, 0, 30, 30, 11, 21, 30, 7, 8, | |
487 | + 9, 10, 30, 30, 13, 14, 58, 59, 19, 20, | |
488 | + 26, 27, 28, 29, 30, 19, 30, 21, 34, 35, | |
489 | + 31, 31, 109, 110, 40, 15, 15, 15, 65, 40, | |
490 | + 40, 67, 65, 65, 21, 38, 64, 6, 7, 8, | |
491 | + 41, 6, 7, 8, 21, 56, 56, 50, 6, 7, | |
492 | + 8, 65, 64, 7, 67, 58, 59, 54, 55, 56, | |
493 | + 57, 58, 59, 65, 21, 19, 20, 21, 84, 85, | |
494 | + 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, | |
495 | + 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, | |
496 | + 106, 60, 50, 15, 63, 60, 7, 15, 64, 42, | |
497 | + 109, 110, 60, 111, 65, 63, 50, 116, 19, 20, | |
498 | + 21, 15, 123, 168, 0, 0, 115, 15, 22, 23, | |
499 | + 136, -1, 133, 133, 7, 125, 9, 10, 11, 12, | |
500 | + 125, 14, -1, 16, 38, 18, 19, 20, 21, 22, | |
501 | + 23, 24, 19, -1, 21, 161, 50, 24, 164, -1, | |
502 | + 15, -1, 168, 169, 58, 59, 172, 22, 23, -1, | |
503 | + 47, 48, 49, 50, 51, 52, 175, 54, 55, 56, | |
504 | + 57, 58, 59, 38, -1, 191, -1, 188, -1, 195, | |
505 | + -1, -1, 65, -1, -1, 50, 118, 119, 120, 121, | |
506 | + -1, 123, -1, 58, 59, 206, 206, 3, 4, 5, | |
507 | + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, | |
508 | + 16, -1, 18, 19, 20, 21, 22, 23, 24, 25, | |
509 | + -1, 27, 28, 29, 7, -1, 9, 10, 11, 12, | |
510 | + -1, 14, 38, 16, -1, 18, 19, 20, 21, 22, | |
511 | + 23, 24, -1, 49, 50, -1, -1, -1, 54, 55, | |
512 | + -1, -1, -1, 59, 60, 61, 62, 63, -1, -1, | |
513 | + 66, 3, 4, 5, 6, 7, 8, 9, 10, 11, | |
514 | + 12, 13, 14, 15, 16, -1, 18, 19, 20, 21, | |
515 | + 22, 23, 24, 25, -1, 27, 28, 29, 45, 46, | |
516 | + 47, 48, 49, 50, 51, 52, 38, 54, 55, 56, | |
517 | + 57, 58, 59, -1, -1, -1, -1, 49, 50, -1, | |
518 | + -1, -1, 54, 55, -1, -1, -1, 59, 60, 61, | |
519 | + 62, 63, -1, -1, 66, 3, 4, 5, 6, 7, | |
520 | + 8, 9, 10, 11, 12, 13, 14, 15, 16, -1, | |
521 | + 18, 19, 20, 21, 22, 23, 24, 25, -1, 27, | |
522 | + 28, 29, -1, -1, -1, 7, -1, 9, 10, 11, | |
523 | + 12, -1, 14, -1, 16, -1, 18, 19, 20, 21, | |
524 | + 22, 23, 24, -1, -1, -1, 54, 55, -1, -1, | |
525 | + -1, 59, 60, 61, 62, 63, 38, -1, 66, -1, | |
526 | + -1, -1, -1, 48, 49, 50, 51, 52, 50, 54, | |
527 | + 55, 56, 57, 58, 59, -1, 58, 59, -1, -1, | |
528 | + -1, -1, -1, 65, 6, 7, 8, 9, 10, 11, | |
529 | + 12, -1, 14, -1, 16, -1, 18, 19, 20, 21, | |
530 | + 22, 23, 24, 6, 7, 8, 9, 10, 11, 12, | |
531 | + -1, 14, -1, 16, -1, 18, 19, 20, 21, 22, | |
532 | + 23, 24, -1, -1, -1, 50, 51, 52, 50, 54, | |
533 | + 55, 56, 57, 58, 59, -1, -1, -1, 60, -1, | |
534 | + -1, -1, -1, -1, -1, -1, -1, 50, -1, -1, | |
535 | + -1, -1, 26, -1, -1, -1, -1, 60, 32, 33, | |
536 | + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, | |
537 | + 44, 45, 46, 47, 48, 49, 50, 51, 52, -1, | |
538 | + 54, 55, 56, 57, 58, 59, -1, -1, -1, 26, | |
539 | + -1, -1, -1, -1, 68, 32, 33, 34, 35, 36, | |
540 | + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, | |
541 | + 47, 48, 49, 50, 51, 52, -1, 54, 55, 56, | |
542 | + 57, 58, 59, 33, 34, 35, 36, 37, 38, 39, | |
543 | + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, | |
544 | + 50, 51, 52, -1, 54, 55, 56, 57, 58, 59, | |
545 | + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, | |
546 | + 45, 46, 47, 48, 49, 50, 51, 52, -1, 54, | |
547 | + 55, 56, 57, 58, 59, 36, 37, 38, 39, 40, | |
548 | + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, | |
549 | + 51, 52, -1, 54, 55, 56, 57, 58, 59, 37, | |
550 | + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, | |
551 | + 48, 49, 50, 51, 52, -1, 54, 55, 56, 57, | |
552 | + 58, 59, 38, 39, 40, 41, 42, 43, 44, 45, | |
553 | + 46, 47, 48, 49, 50, 51, 52, -1, 54, 55, | |
554 | + 56, 57, 58, 59, 39, 40, 41, 42, 43, 44, | |
555 | + 45, 46, 47, 48, 49, 50, 51, 52, -1, 54, | |
556 | + 55, 56, 57, 58, 59, 41, 42, 43, 44, 45, | |
557 | + 46, 47, 48, 49, 50, 51, 52, -1, 54, 55, | |
558 | + 56, 57, 58, 59 | |
559 | +}; | |
560 | +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ | |
561 | +#line 3 "/stone/jimb/main-98r2/share/bison.simple" | |
562 | + | |
563 | +/* Skeleton output parser for bison, | |
564 | + Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. | |
565 | + | |
566 | + This program is free software; you can redistribute it and/or modify | |
567 | + it under the terms of the GNU General Public License as published by | |
568 | + the Free Software Foundation; either version 2, or (at your option) | |
569 | + any later version. | |
570 | + | |
571 | + This program is distributed in the hope that it will be useful, | |
572 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
573 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
574 | + GNU General Public License for more details. | |
575 | + | |
576 | + You should have received a copy of the GNU General Public License | |
577 | + along with this program; if not, write to the Free Software | |
578 | + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
579 | + | |
580 | +/* As a special exception, when this file is copied by Bison into a | |
581 | + Bison output file, you may use that output file without restriction. | |
582 | + This special exception was added by the Free Software Foundation | |
583 | + in version 1.24 of Bison. */ | |
584 | + | |
585 | +#ifndef alloca | |
586 | +#ifdef __GNUC__ | |
587 | +#define alloca __builtin_alloca | |
588 | +#else /* not GNU C. */ | |
589 | +#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) | |
590 | +#include <alloca.h> | |
591 | +#else /* not sparc */ | |
592 | +#if defined (MSDOS) && !defined (__TURBOC__) | |
593 | +#else /* not MSDOS, or __TURBOC__ */ | |
594 | +#if defined(_AIX) | |
595 | + #pragma alloca | |
596 | +#else /* not MSDOS, __TURBOC__, or _AIX */ | |
597 | +#ifdef __hpux | |
598 | +#ifdef __cplusplus | |
599 | +extern "C" { | |
600 | +void *alloca (unsigned int); | |
601 | +}; | |
602 | +#else /* not __cplusplus */ | |
603 | +void *alloca (); | |
604 | +#endif /* not __cplusplus */ | |
605 | +#endif /* __hpux */ | |
606 | +#endif /* not _AIX */ | |
607 | +#endif /* not MSDOS, or __TURBOC__ */ | |
608 | +#endif /* not sparc. */ | |
609 | +#endif /* not GNU C. */ | |
610 | +#endif /* alloca not defined. */ | |
611 | + | |
612 | +/* This is the parser code that is written into each bison parser | |
613 | + when the %semantic_parser declaration is not specified in the grammar. | |
614 | + It was written by Richard Stallman by simplifying the hairy parser | |
615 | + used when %semantic_parser is specified. */ | |
616 | + | |
617 | +/* Note: there must be only one dollar sign in this file. | |
618 | + It is replaced by the list of actions, each action | |
619 | + as one case of the switch. */ | |
620 | + | |
621 | +#define yyerrok (yyerrstatus = 0) | |
622 | +#define yyclearin (yychar = YYEMPTY) | |
623 | +#define YYEMPTY -2 | |
624 | +#define YYEOF 0 | |
625 | +#define YYACCEPT return(0) | |
626 | +#define YYABORT return(1) | |
627 | +#define YYERROR goto yyerrlab1 | |
628 | +/* Like YYERROR except do call yyerror. | |
629 | + This remains here temporarily to ease the | |
630 | + transition to the new meaning of YYERROR, for GCC. | |
631 | + Once GCC version 2 has supplanted version 1, this can go. */ | |
632 | +#define YYFAIL goto yyerrlab | |
633 | +#define YYRECOVERING() (!!yyerrstatus) | |
634 | +#define YYBACKUP(token, value) \ | |
635 | +do \ | |
636 | + if (yychar == YYEMPTY && yylen == 1) \ | |
637 | + { yychar = (token), yylval = (value); \ | |
638 | + yychar1 = YYTRANSLATE (yychar); \ | |
639 | + YYPOPSTACK; \ | |
640 | + goto yybackup; \ | |
641 | + } \ | |
642 | + else \ | |
643 | + { yyerror ("syntax error: cannot back up"); YYERROR; } \ | |
644 | +while (0) | |
645 | + | |
646 | +#define YYTERROR 1 | |
647 | +#define YYERRCODE 256 | |
648 | + | |
649 | +#ifndef YYPURE | |
650 | +#define YYLEX yylex() | |
651 | +#endif | |
652 | + | |
653 | +#ifdef YYPURE | |
654 | +#ifdef YYLSP_NEEDED | |
655 | +#ifdef YYLEX_PARAM | |
656 | +#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) | |
657 | +#else | |
658 | +#define YYLEX yylex(&yylval, &yylloc) | |
659 | +#endif | |
660 | +#else /* not YYLSP_NEEDED */ | |
661 | +#ifdef YYLEX_PARAM | |
662 | +#define YYLEX yylex(&yylval, YYLEX_PARAM) | |
663 | +#else | |
664 | +#define YYLEX yylex(&yylval) | |
665 | +#endif | |
666 | +#endif /* not YYLSP_NEEDED */ | |
667 | +#endif | |
668 | + | |
669 | +/* If nonreentrant, generate the variables here */ | |
670 | + | |
671 | +#ifndef YYPURE | |
672 | + | |
673 | +int yychar; /* the lookahead symbol */ | |
674 | +YYSTYPE yylval; /* the semantic value of the */ | |
675 | + /* lookahead symbol */ | |
676 | + | |
677 | +#ifdef YYLSP_NEEDED | |
678 | +YYLTYPE yylloc; /* location data for the lookahead */ | |
679 | + /* symbol */ | |
680 | +#endif | |
681 | + | |
682 | +int yynerrs; /* number of parse errors so far */ | |
683 | +#endif /* not YYPURE */ | |
684 | + | |
685 | +#if YYDEBUG != 0 | |
686 | +int yydebug; /* nonzero means print parse trace */ | |
687 | +/* Since this is uninitialized, it does not stop multiple parsers | |
688 | + from coexisting. */ | |
689 | +#endif | |
690 | + | |
691 | +/* YYINITDEPTH indicates the initial size of the parser's stacks */ | |
692 | + | |
693 | +#ifndef YYINITDEPTH | |
694 | +#define YYINITDEPTH 200 | |
695 | +#endif | |
696 | + | |
697 | +/* YYMAXDEPTH is the maximum size the stacks can grow to | |
698 | + (effective only if the built-in stack extension method is used). */ | |
699 | + | |
700 | +#if YYMAXDEPTH == 0 | |
701 | +#undef YYMAXDEPTH | |
702 | +#endif | |
703 | + | |
704 | +#ifndef YYMAXDEPTH | |
705 | +#define YYMAXDEPTH 10000 | |
706 | +#endif | |
707 | + | |
708 | +/* Prevent warning if -Wstrict-prototypes. */ | |
709 | +#ifdef __GNUC__ | |
710 | +int yyparse (void); | |
711 | +#endif | |
712 | + | |
713 | +#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ | |
714 | +#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) | |
715 | +#else /* not GNU C or C++ */ | |
716 | +#ifndef __cplusplus | |
717 | + | |
718 | +/* This is the most reliable way to avoid incompatibilities | |
719 | + in available built-in functions on various systems. */ | |
720 | +static void | |
721 | +__yy_memcpy (to, from, count) | |
722 | + char *to; | |
723 | + char *from; | |
724 | + int count; | |
725 | +{ | |
726 | + register char *f = from; | |
727 | + register char *t = to; | |
728 | + register int i = count; | |
729 | + | |
730 | + while (i-- > 0) | |
731 | + *t++ = *f++; | |
732 | +} | |
733 | + | |
734 | +#else /* __cplusplus */ | |
735 | + | |
736 | +/* This is the most reliable way to avoid incompatibilities | |
737 | + in available built-in functions on various systems. */ | |
738 | +static void | |
739 | +__yy_memcpy (char *to, char *from, int count) | |
740 | +{ | |
741 | + register char *f = from; | |
742 | + register char *t = to; | |
743 | + register int i = count; | |
744 | + | |
745 | + while (i-- > 0) | |
746 | + *t++ = *f++; | |
747 | +} | |
748 | + | |
749 | +#endif | |
750 | +#endif | |
751 | + | |
752 | +#line 196 "/stone/jimb/main-98r2/share/bison.simple" | |
753 | + | |
754 | +/* The user can define YYPARSE_PARAM as the name of an argument to be passed | |
755 | + into yyparse. The argument should have type void *. | |
756 | + It should actually point to an object. | |
757 | + Grammar actions can access the variable by casting it | |
758 | + to the proper pointer type. */ | |
759 | + | |
760 | +#ifdef YYPARSE_PARAM | |
761 | +#ifdef __cplusplus | |
762 | +#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM | |
763 | +#define YYPARSE_PARAM_DECL | |
764 | +#else /* not __cplusplus */ | |
765 | +#define YYPARSE_PARAM_ARG YYPARSE_PARAM | |
766 | +#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; | |
767 | +#endif /* not __cplusplus */ | |
768 | +#else /* not YYPARSE_PARAM */ | |
769 | +#define YYPARSE_PARAM_ARG | |
770 | +#define YYPARSE_PARAM_DECL | |
771 | +#endif /* not YYPARSE_PARAM */ | |
772 | + | |
773 | +int | |
774 | +yyparse(YYPARSE_PARAM_ARG) | |
775 | + YYPARSE_PARAM_DECL | |
776 | +{ | |
777 | + register int yystate; | |
778 | + register int yyn; | |
779 | + register short *yyssp; | |
780 | + register YYSTYPE *yyvsp; | |
781 | + int yyerrstatus; /* number of tokens to shift before error messages enabled */ | |
782 | + int yychar1 = 0; /* lookahead token as an internal (translated) token number */ | |
783 | + | |
784 | + short yyssa[YYINITDEPTH]; /* the state stack */ | |
785 | + YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ | |
786 | + | |
787 | + short *yyss = yyssa; /* refer to the stacks thru separate pointers */ | |
788 | + YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to xreallocate them elsewhere */ | |
789 | + | |
790 | +#ifdef YYLSP_NEEDED | |
791 | + YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ | |
792 | + YYLTYPE *yyls = yylsa; | |
793 | + YYLTYPE *yylsp; | |
794 | + | |
795 | +#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) | |
796 | +#else | |
797 | +#define YYPOPSTACK (yyvsp--, yyssp--) | |
798 | +#endif | |
799 | + | |
800 | + int yystacksize = YYINITDEPTH; | |
801 | + | |
802 | +#ifdef YYPURE | |
803 | + int yychar; | |
804 | + YYSTYPE yylval; | |
805 | + int yynerrs; | |
806 | +#ifdef YYLSP_NEEDED | |
807 | + YYLTYPE yylloc; | |
808 | +#endif | |
809 | +#endif | |
810 | + | |
811 | + YYSTYPE yyval; /* the variable used to return */ | |
812 | + /* semantic values from the action */ | |
813 | + /* routines */ | |
814 | + | |
815 | + int yylen; | |
816 | + | |
817 | +#if YYDEBUG != 0 | |
818 | + if (yydebug) | |
819 | + fprintf(stderr, "Starting parse\n"); | |
820 | +#endif | |
821 | + | |
822 | + yystate = 0; | |
823 | + yyerrstatus = 0; | |
824 | + yynerrs = 0; | |
825 | + yychar = YYEMPTY; /* Cause a token to be read. */ | |
826 | + | |
827 | + /* Initialize stack pointers. | |
828 | + Waste one element of value and location stack | |
829 | + so that they stay on the same level as the state stack. | |
830 | + The wasted elements are never initialized. */ | |
831 | + | |
832 | + yyssp = yyss - 1; | |
833 | + yyvsp = yyvs; | |
834 | +#ifdef YYLSP_NEEDED | |
835 | + yylsp = yyls; | |
836 | +#endif | |
837 | + | |
838 | +/* Push a new state, which is found in yystate . */ | |
839 | +/* In all cases, when you get here, the value and location stacks | |
840 | + have just been pushed. so pushing a state here evens the stacks. */ | |
841 | +yynewstate: | |
842 | + | |
843 | + *++yyssp = yystate; | |
844 | + | |
845 | + if (yyssp >= yyss + yystacksize - 1) | |
846 | + { | |
847 | + /* Give user a chance to xreallocate the stack */ | |
848 | + /* Use copies of these so that the &'s don't force the real ones into memory. */ | |
849 | + YYSTYPE *yyvs1 = yyvs; | |
850 | + short *yyss1 = yyss; | |
851 | +#ifdef YYLSP_NEEDED | |
852 | + YYLTYPE *yyls1 = yyls; | |
853 | +#endif | |
854 | + | |
855 | + /* Get the current used size of the three stacks, in elements. */ | |
856 | + int size = yyssp - yyss + 1; | |
857 | + | |
858 | +#ifdef yyoverflow | |
859 | + /* Each stack pointer address is followed by the size of | |
860 | + the data in use in that stack, in bytes. */ | |
861 | +#ifdef YYLSP_NEEDED | |
862 | + /* This used to be a conditional around just the two extra args, | |
863 | + but that might be undefined if yyoverflow is a macro. */ | |
864 | + yyoverflow("parser stack overflow", | |
865 | + &yyss1, size * sizeof (*yyssp), | |
866 | + &yyvs1, size * sizeof (*yyvsp), | |
867 | + &yyls1, size * sizeof (*yylsp), | |
868 | + &yystacksize); | |
869 | +#else | |
870 | + yyoverflow("parser stack overflow", | |
871 | + &yyss1, size * sizeof (*yyssp), | |
872 | + &yyvs1, size * sizeof (*yyvsp), | |
873 | + &yystacksize); | |
874 | +#endif | |
875 | + | |
876 | + yyss = yyss1; yyvs = yyvs1; | |
877 | +#ifdef YYLSP_NEEDED | |
878 | + yyls = yyls1; | |
879 | +#endif | |
880 | +#else /* no yyoverflow */ | |
881 | + /* Extend the stack our own way. */ | |
882 | + if (yystacksize >= YYMAXDEPTH) | |
883 | + { | |
884 | + yyerror("parser stack overflow"); | |
885 | + return 2; | |
886 | + } | |
887 | + yystacksize *= 2; | |
888 | + if (yystacksize > YYMAXDEPTH) | |
889 | + yystacksize = YYMAXDEPTH; | |
890 | + yyss = (short *) alloca (yystacksize * sizeof (*yyssp)); | |
891 | + __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp)); | |
892 | + yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp)); | |
893 | + __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp)); | |
894 | +#ifdef YYLSP_NEEDED | |
895 | + yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp)); | |
896 | + __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp)); | |
897 | +#endif | |
898 | +#endif /* no yyoverflow */ | |
899 | + | |
900 | + yyssp = yyss + size - 1; | |
901 | + yyvsp = yyvs + size - 1; | |
902 | +#ifdef YYLSP_NEEDED | |
903 | + yylsp = yyls + size - 1; | |
904 | +#endif | |
905 | + | |
906 | +#if YYDEBUG != 0 | |
907 | + if (yydebug) | |
908 | + fprintf(stderr, "Stack size increased to %d\n", yystacksize); | |
909 | +#endif | |
910 | + | |
911 | + if (yyssp >= yyss + yystacksize - 1) | |
912 | + YYABORT; | |
913 | + } | |
914 | + | |
915 | +#if YYDEBUG != 0 | |
916 | + if (yydebug) | |
917 | + fprintf(stderr, "Entering state %d\n", yystate); | |
918 | +#endif | |
919 | + | |
920 | + goto yybackup; | |
921 | + yybackup: | |
922 | + | |
923 | +/* Do appropriate processing given the current state. */ | |
924 | +/* Read a lookahead token if we need one and don't already have one. */ | |
925 | +/* yyresume: */ | |
926 | + | |
927 | + /* First try to decide what to do without reference to lookahead token. */ | |
928 | + | |
929 | + yyn = yypact[yystate]; | |
930 | + if (yyn == YYFLAG) | |
931 | + goto yydefault; | |
932 | + | |
933 | + /* Not known => get a lookahead token if don't already have one. */ | |
934 | + | |
935 | + /* yychar is either YYEMPTY or YYEOF | |
936 | + or a valid token in external form. */ | |
937 | + | |
938 | + if (yychar == YYEMPTY) | |
939 | + { | |
940 | +#if YYDEBUG != 0 | |
941 | + if (yydebug) | |
942 | + fprintf(stderr, "Reading a token: "); | |
943 | +#endif | |
944 | + yychar = YYLEX; | |
945 | + } | |
946 | + | |
947 | + /* Convert token to internal form (in yychar1) for indexing tables with */ | |
948 | + | |
949 | + if (yychar <= 0) /* This means end of input. */ | |
950 | + { | |
951 | + yychar1 = 0; | |
952 | + yychar = YYEOF; /* Don't call YYLEX any more */ | |
953 | + | |
954 | +#if YYDEBUG != 0 | |
955 | + if (yydebug) | |
956 | + fprintf(stderr, "Now at end of input.\n"); | |
957 | +#endif | |
958 | + } | |
959 | + else | |
960 | + { | |
961 | + yychar1 = YYTRANSLATE(yychar); | |
962 | + | |
963 | +#if YYDEBUG != 0 | |
964 | + if (yydebug) | |
965 | + { | |
966 | + fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); | |
967 | + /* Give the individual parser a way to print the precise meaning | |
968 | + of a token, for further debugging info. */ | |
969 | +#ifdef YYPRINT | |
970 | + YYPRINT (stderr, yychar, yylval); | |
971 | +#endif | |
972 | + fprintf (stderr, ")\n"); | |
973 | + } | |
974 | +#endif | |
975 | + } | |
976 | + | |
977 | + yyn += yychar1; | |
978 | + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) | |
979 | + goto yydefault; | |
980 | + | |
981 | + yyn = yytable[yyn]; | |
982 | + | |
983 | + /* yyn is what to do for this token type in this state. | |
984 | + Negative => reduce, -yyn is rule number. | |
985 | + Positive => shift, yyn is new state. | |
986 | + New state is final state => don't bother to shift, | |
987 | + just return success. | |
988 | + 0, or most negative number => error. */ | |
989 | + | |
990 | + if (yyn < 0) | |
991 | + { | |
992 | + if (yyn == YYFLAG) | |
993 | + goto yyerrlab; | |
994 | + yyn = -yyn; | |
995 | + goto yyreduce; | |
996 | + } | |
997 | + else if (yyn == 0) | |
998 | + goto yyerrlab; | |
999 | + | |
1000 | + if (yyn == YYFINAL) | |
1001 | + YYACCEPT; | |
1002 | + | |
1003 | + /* Shift the lookahead token. */ | |
1004 | + | |
1005 | +#if YYDEBUG != 0 | |
1006 | + if (yydebug) | |
1007 | + fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); | |
1008 | +#endif | |
1009 | + | |
1010 | + /* Discard the token being shifted unless it is eof. */ | |
1011 | + if (yychar != YYEOF) | |
1012 | + yychar = YYEMPTY; | |
1013 | + | |
1014 | + *++yyvsp = yylval; | |
1015 | +#ifdef YYLSP_NEEDED | |
1016 | + *++yylsp = yylloc; | |
1017 | +#endif | |
1018 | + | |
1019 | + /* count tokens shifted since error; after three, turn off error status. */ | |
1020 | + if (yyerrstatus) yyerrstatus--; | |
1021 | + | |
1022 | + yystate = yyn; | |
1023 | + goto yynewstate; | |
1024 | + | |
1025 | +/* Do the default action for the current state. */ | |
1026 | +yydefault: | |
1027 | + | |
1028 | + yyn = yydefact[yystate]; | |
1029 | + if (yyn == 0) | |
1030 | + goto yyerrlab; | |
1031 | + | |
1032 | +/* Do a reduction. yyn is the number of a rule to reduce with. */ | |
1033 | +yyreduce: | |
1034 | + yylen = yyr2[yyn]; | |
1035 | + if (yylen > 0) | |
1036 | + yyval = yyvsp[1-yylen]; /* implement default value of the action */ | |
1037 | + | |
1038 | +#if YYDEBUG != 0 | |
1039 | + if (yydebug) | |
1040 | + { | |
1041 | + int i; | |
1042 | + | |
1043 | + fprintf (stderr, "Reducing via rule %d (line %d), ", | |
1044 | + yyn, yyrline[yyn]); | |
1045 | + | |
1046 | + /* Print the symbols being reduced, and their result. */ | |
1047 | + for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) | |
1048 | + fprintf (stderr, "%s ", yytname[yyrhs[i]]); | |
1049 | + fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); | |
1050 | + } | |
1051 | +#endif | |
1052 | + | |
1053 | + | |
1054 | + switch (yyn) { | |
1055 | + | |
1056 | +case 3: | |
1057 | +#line 235 "c-exp.y" | |
1058 | +{ write_exp_elt_opcode(OP_TYPE); | |
1059 | + write_exp_elt_type(yyvsp[0].tval); | |
1060 | + write_exp_elt_opcode(OP_TYPE);; | |
1061 | + break;} | |
1062 | +case 5: | |
1063 | +#line 243 "c-exp.y" | |
1064 | +{ write_exp_elt_opcode (BINOP_COMMA); ; | |
1065 | + break;} | |
1066 | +case 6: | |
1067 | +#line 248 "c-exp.y" | |
1068 | +{ write_exp_elt_opcode (UNOP_IND); ; | |
1069 | + break;} | |
1070 | +case 7: | |
1071 | +#line 251 "c-exp.y" | |
1072 | +{ write_exp_elt_opcode (UNOP_ADDR); ; | |
1073 | + break;} | |
1074 | +case 8: | |
1075 | +#line 254 "c-exp.y" | |
1076 | +{ write_exp_elt_opcode (UNOP_NEG); ; | |
1077 | + break;} | |
1078 | +case 9: | |
1079 | +#line 258 "c-exp.y" | |
1080 | +{ write_exp_elt_opcode (UNOP_LOGICAL_NOT); ; | |
1081 | + break;} | |
1082 | +case 10: | |
1083 | +#line 262 "c-exp.y" | |
1084 | +{ write_exp_elt_opcode (UNOP_COMPLEMENT); ; | |
1085 | + break;} | |
1086 | +case 11: | |
1087 | +#line 266 "c-exp.y" | |
1088 | +{ write_exp_elt_opcode (UNOP_PREINCREMENT); ; | |
1089 | + break;} | |
1090 | +case 12: | |
1091 | +#line 270 "c-exp.y" | |
1092 | +{ write_exp_elt_opcode (UNOP_PREDECREMENT); ; | |
1093 | + break;} | |
1094 | +case 13: | |
1095 | +#line 274 "c-exp.y" | |
1096 | +{ write_exp_elt_opcode (UNOP_POSTINCREMENT); ; | |
1097 | + break;} | |
1098 | +case 14: | |
1099 | +#line 278 "c-exp.y" | |
1100 | +{ write_exp_elt_opcode (UNOP_POSTDECREMENT); ; | |
1101 | + break;} | |
1102 | +case 15: | |
1103 | +#line 282 "c-exp.y" | |
1104 | +{ write_exp_elt_opcode (UNOP_SIZEOF); ; | |
1105 | + break;} | |
1106 | +case 16: | |
1107 | +#line 286 "c-exp.y" | |
1108 | +{ write_exp_elt_opcode (STRUCTOP_PTR); | |
1109 | + write_exp_string (yyvsp[0].sval); | |
1110 | + write_exp_elt_opcode (STRUCTOP_PTR); ; | |
1111 | + break;} | |
1112 | +case 17: | |
1113 | +#line 292 "c-exp.y" | |
1114 | +{ /* exp->type::name becomes exp->*(&type::name) */ | |
1115 | + /* Note: this doesn't work if name is a | |
1116 | + static member! FIXME */ | |
1117 | + write_exp_elt_opcode (UNOP_ADDR); | |
1118 | + write_exp_elt_opcode (STRUCTOP_MPTR); ; | |
1119 | + break;} | |
1120 | +case 18: | |
1121 | +#line 300 "c-exp.y" | |
1122 | +{ write_exp_elt_opcode (STRUCTOP_MPTR); ; | |
1123 | + break;} | |
1124 | +case 19: | |
1125 | +#line 304 "c-exp.y" | |
1126 | +{ write_exp_elt_opcode (STRUCTOP_STRUCT); | |
1127 | + write_exp_string (yyvsp[0].sval); | |
1128 | + write_exp_elt_opcode (STRUCTOP_STRUCT); ; | |
1129 | + break;} | |
1130 | +case 20: | |
1131 | +#line 310 "c-exp.y" | |
1132 | +{ /* exp.type::name becomes exp.*(&type::name) */ | |
1133 | + /* Note: this doesn't work if name is a | |
1134 | + static member! FIXME */ | |
1135 | + write_exp_elt_opcode (UNOP_ADDR); | |
1136 | + write_exp_elt_opcode (STRUCTOP_MEMBER); ; | |
1137 | + break;} | |
1138 | +case 21: | |
1139 | +#line 318 "c-exp.y" | |
1140 | +{ write_exp_elt_opcode (STRUCTOP_MEMBER); ; | |
1141 | + break;} | |
1142 | +case 22: | |
1143 | +#line 322 "c-exp.y" | |
1144 | +{ write_exp_elt_opcode (BINOP_SUBSCRIPT); ; | |
1145 | + break;} | |
1146 | +case 23: | |
1147 | +#line 328 "c-exp.y" | |
1148 | +{ start_arglist (); ; | |
1149 | + break;} | |
1150 | +case 24: | |
1151 | +#line 330 "c-exp.y" | |
1152 | +{ write_exp_elt_opcode (OP_FUNCALL); | |
1153 | + write_exp_elt_longcst ((LONGEST) end_arglist ()); | |
1154 | + write_exp_elt_opcode (OP_FUNCALL); ; | |
1155 | + break;} | |
1156 | +case 25: | |
1157 | +#line 336 "c-exp.y" | |
1158 | +{ start_arglist (); ; | |
1159 | + break;} | |
1160 | +case 27: | |
1161 | +#line 343 "c-exp.y" | |
1162 | +{ arglist_len = 1; ; | |
1163 | + break;} | |
1164 | +case 28: | |
1165 | +#line 347 "c-exp.y" | |
1166 | +{ arglist_len++; ; | |
1167 | + break;} | |
1168 | +case 29: | |
1169 | +#line 351 "c-exp.y" | |
1170 | +{ yyval.lval = end_arglist () - 1; ; | |
1171 | + break;} | |
1172 | +case 30: | |
1173 | +#line 354 "c-exp.y" | |
1174 | +{ write_exp_elt_opcode (OP_ARRAY); | |
1175 | + write_exp_elt_longcst ((LONGEST) 0); | |
1176 | + write_exp_elt_longcst ((LONGEST) yyvsp[0].lval); | |
1177 | + write_exp_elt_opcode (OP_ARRAY); ; | |
1178 | + break;} | |
1179 | +case 31: | |
1180 | +#line 361 "c-exp.y" | |
1181 | +{ write_exp_elt_opcode (UNOP_MEMVAL); | |
1182 | + write_exp_elt_type (yyvsp[-2].tval); | |
1183 | + write_exp_elt_opcode (UNOP_MEMVAL); ; | |
1184 | + break;} | |
1185 | +case 32: | |
1186 | +#line 367 "c-exp.y" | |
1187 | +{ write_exp_elt_opcode (UNOP_CAST); | |
1188 | + write_exp_elt_type (yyvsp[-2].tval); | |
1189 | + write_exp_elt_opcode (UNOP_CAST); ; | |
1190 | + break;} | |
1191 | +case 33: | |
1192 | +#line 373 "c-exp.y" | |
1193 | +{ ; | |
1194 | + break;} | |
1195 | +case 34: | |
1196 | +#line 379 "c-exp.y" | |
1197 | +{ write_exp_elt_opcode (BINOP_REPEAT); ; | |
1198 | + break;} | |
1199 | +case 35: | |
1200 | +#line 383 "c-exp.y" | |
1201 | +{ write_exp_elt_opcode (BINOP_MUL); ; | |
1202 | + break;} | |
1203 | +case 36: | |
1204 | +#line 387 "c-exp.y" | |
1205 | +{ write_exp_elt_opcode (BINOP_DIV); ; | |
1206 | + break;} | |
1207 | +case 37: | |
1208 | +#line 391 "c-exp.y" | |
1209 | +{ write_exp_elt_opcode (BINOP_REM); ; | |
1210 | + break;} | |
1211 | +case 38: | |
1212 | +#line 395 "c-exp.y" | |
1213 | +{ write_exp_elt_opcode (BINOP_ADD); ; | |
1214 | + break;} | |
1215 | +case 39: | |
1216 | +#line 399 "c-exp.y" | |
1217 | +{ write_exp_elt_opcode (BINOP_SUB); ; | |
1218 | + break;} | |
1219 | +case 40: | |
1220 | +#line 403 "c-exp.y" | |
1221 | +{ write_exp_elt_opcode (BINOP_LSH); ; | |
1222 | + break;} | |
1223 | +case 41: | |
1224 | +#line 407 "c-exp.y" | |
1225 | +{ write_exp_elt_opcode (BINOP_RSH); ; | |
1226 | + break;} | |
1227 | +case 42: | |
1228 | +#line 411 "c-exp.y" | |
1229 | +{ write_exp_elt_opcode (BINOP_EQUAL); ; | |
1230 | + break;} | |
1231 | +case 43: | |
1232 | +#line 415 "c-exp.y" | |
1233 | +{ write_exp_elt_opcode (BINOP_NOTEQUAL); ; | |
1234 | + break;} | |
1235 | +case 44: | |
1236 | +#line 419 "c-exp.y" | |
1237 | +{ write_exp_elt_opcode (BINOP_LEQ); ; | |
1238 | + break;} | |
1239 | +case 45: | |
1240 | +#line 423 "c-exp.y" | |
1241 | +{ write_exp_elt_opcode (BINOP_GEQ); ; | |
1242 | + break;} | |
1243 | +case 46: | |
1244 | +#line 427 "c-exp.y" | |
1245 | +{ write_exp_elt_opcode (BINOP_LESS); ; | |
1246 | + break;} | |
1247 | +case 47: | |
1248 | +#line 431 "c-exp.y" | |
1249 | +{ write_exp_elt_opcode (BINOP_GTR); ; | |
1250 | + break;} | |
1251 | +case 48: | |
1252 | +#line 435 "c-exp.y" | |
1253 | +{ write_exp_elt_opcode (BINOP_BITWISE_AND); ; | |
1254 | + break;} | |
1255 | +case 49: | |
1256 | +#line 439 "c-exp.y" | |
1257 | +{ write_exp_elt_opcode (BINOP_BITWISE_XOR); ; | |
1258 | + break;} | |
1259 | +case 50: | |
1260 | +#line 443 "c-exp.y" | |
1261 | +{ write_exp_elt_opcode (BINOP_BITWISE_IOR); ; | |
1262 | + break;} | |
1263 | +case 51: | |
1264 | +#line 447 "c-exp.y" | |
1265 | +{ write_exp_elt_opcode (BINOP_LOGICAL_AND); ; | |
1266 | + break;} | |
1267 | +case 52: | |
1268 | +#line 451 "c-exp.y" | |
1269 | +{ write_exp_elt_opcode (BINOP_LOGICAL_OR); ; | |
1270 | + break;} | |
1271 | +case 53: | |
1272 | +#line 455 "c-exp.y" | |
1273 | +{ write_exp_elt_opcode (TERNOP_COND); ; | |
1274 | + break;} | |
1275 | +case 54: | |
1276 | +#line 459 "c-exp.y" | |
1277 | +{ write_exp_elt_opcode (BINOP_ASSIGN); ; | |
1278 | + break;} | |
1279 | +case 55: | |
1280 | +#line 463 "c-exp.y" | |
1281 | +{ write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); | |
1282 | + write_exp_elt_opcode (yyvsp[-1].opcode); | |
1283 | + write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); ; | |
1284 | + break;} | |
1285 | +case 56: | |
1286 | +#line 469 "c-exp.y" | |
1287 | +{ write_exp_elt_opcode (OP_LONG); | |
1288 | + write_exp_elt_type (yyvsp[0].typed_val_int.type); | |
1289 | + write_exp_elt_longcst ((LONGEST)(yyvsp[0].typed_val_int.val)); | |
1290 | + write_exp_elt_opcode (OP_LONG); ; | |
1291 | + break;} | |
1292 | +case 57: | |
1293 | +#line 476 "c-exp.y" | |
1294 | +{ YYSTYPE val; | |
1295 | + parse_number (yyvsp[0].ssym.stoken.ptr, yyvsp[0].ssym.stoken.length, 0, &val); | |
1296 | + write_exp_elt_opcode (OP_LONG); | |
1297 | + write_exp_elt_type (val.typed_val_int.type); | |
1298 | + write_exp_elt_longcst ((LONGEST)val.typed_val_int.val); | |
1299 | + write_exp_elt_opcode (OP_LONG); | |
1300 | + ; | |
1301 | + break;} | |
1302 | +case 58: | |
1303 | +#line 487 "c-exp.y" | |
1304 | +{ write_exp_elt_opcode (OP_DOUBLE); | |
1305 | + write_exp_elt_type (yyvsp[0].typed_val_float.type); | |
1306 | + write_exp_elt_dblcst (yyvsp[0].typed_val_float.dval); | |
1307 | + write_exp_elt_opcode (OP_DOUBLE); ; | |
1308 | + break;} | |
1309 | +case 61: | |
1310 | +#line 501 "c-exp.y" | |
1311 | +{ write_exp_elt_opcode (OP_LONG); | |
1312 | + write_exp_elt_type (builtin_type_int); | |
1313 | + CHECK_TYPEDEF (yyvsp[-1].tval); | |
1314 | + write_exp_elt_longcst ((LONGEST) TYPE_LENGTH (yyvsp[-1].tval)); | |
1315 | + write_exp_elt_opcode (OP_LONG); ; | |
1316 | + break;} | |
1317 | +case 62: | |
1318 | +#line 509 "c-exp.y" | |
1319 | +{ /* C strings are converted into array constants with | |
1320 | + an explicit null byte added at the end. Thus | |
1321 | + the array upper bound is the string length. | |
1322 | + There is no such thing in C as a completely empty | |
1323 | + string. */ | |
1324 | + char *sp = yyvsp[0].sval.ptr; int count = yyvsp[0].sval.length; | |
1325 | + while (count-- > 0) | |
1326 | + { | |
1327 | + write_exp_elt_opcode (OP_LONG); | |
1328 | + write_exp_elt_type (builtin_type_char); | |
1329 | + write_exp_elt_longcst ((LONGEST)(*sp++)); | |
1330 | + write_exp_elt_opcode (OP_LONG); | |
1331 | + } | |
1332 | + write_exp_elt_opcode (OP_LONG); | |
1333 | + write_exp_elt_type (builtin_type_char); | |
1334 | + write_exp_elt_longcst ((LONGEST)'\0'); | |
1335 | + write_exp_elt_opcode (OP_LONG); | |
1336 | + write_exp_elt_opcode (OP_ARRAY); | |
1337 | + write_exp_elt_longcst ((LONGEST) 0); | |
1338 | + write_exp_elt_longcst ((LONGEST) (yyvsp[0].sval.length)); | |
1339 | + write_exp_elt_opcode (OP_ARRAY); ; | |
1340 | + break;} | |
1341 | +case 63: | |
1342 | +#line 534 "c-exp.y" | |
1343 | +{ write_exp_elt_opcode (OP_THIS); | |
1344 | + write_exp_elt_opcode (OP_THIS); ; | |
1345 | + break;} | |
1346 | +case 64: | |
1347 | +#line 539 "c-exp.y" | |
1348 | +{ write_exp_elt_opcode (OP_LONG); | |
1349 | + write_exp_elt_type (builtin_type_bool); | |
1350 | + write_exp_elt_longcst ((LONGEST) 1); | |
1351 | + write_exp_elt_opcode (OP_LONG); ; | |
1352 | + break;} | |
1353 | +case 65: | |
1354 | +#line 546 "c-exp.y" | |
1355 | +{ write_exp_elt_opcode (OP_LONG); | |
1356 | + write_exp_elt_type (builtin_type_bool); | |
1357 | + write_exp_elt_longcst ((LONGEST) 0); | |
1358 | + write_exp_elt_opcode (OP_LONG); ; | |
1359 | + break;} | |
1360 | +case 66: | |
1361 | +#line 555 "c-exp.y" | |
1362 | +{ | |
1363 | + if (yyvsp[0].ssym.sym) | |
1364 | + yyval.bval = SYMBOL_BLOCK_VALUE (yyvsp[0].ssym.sym); | |
1365 | + else | |
1366 | + error ("No file or function \"%s\".", | |
1367 | + copy_name (yyvsp[0].ssym.stoken)); | |
1368 | + ; | |
1369 | + break;} | |
1370 | +case 67: | |
1371 | +#line 563 "c-exp.y" | |
1372 | +{ | |
1373 | + yyval.bval = yyvsp[0].bval; | |
1374 | + ; | |
1375 | + break;} | |
1376 | +case 68: | |
1377 | +#line 569 "c-exp.y" | |
1378 | +{ struct symbol *tem | |
1379 | + = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval, | |
1380 | + VAR_NAMESPACE, (int *) NULL, | |
1381 | + (struct symtab **) NULL); | |
1382 | + if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK) | |
1383 | + error ("No function \"%s\" in specified context.", | |
1384 | + copy_name (yyvsp[0].sval)); | |
1385 | + yyval.bval = SYMBOL_BLOCK_VALUE (tem); ; | |
1386 | + break;} | |
1387 | +case 69: | |
1388 | +#line 580 "c-exp.y" | |
1389 | +{ struct symbol *sym; | |
1390 | + sym = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval, | |
1391 | + VAR_NAMESPACE, (int *) NULL, | |
1392 | + (struct symtab **) NULL); | |
1393 | + if (sym == 0) | |
1394 | + error ("No symbol \"%s\" in specified context.", | |
1395 | + copy_name (yyvsp[0].sval)); | |
1396 | + | |
1397 | + write_exp_elt_opcode (OP_VAR_VALUE); | |
1398 | + /* block_found is set by lookup_symbol. */ | |
1399 | + write_exp_elt_block (block_found); | |
1400 | + write_exp_elt_sym (sym); | |
1401 | + write_exp_elt_opcode (OP_VAR_VALUE); ; | |
1402 | + break;} | |
1403 | +case 70: | |
1404 | +#line 596 "c-exp.y" | |
1405 | +{ | |
1406 | + struct type *type = yyvsp[-2].tval; | |
1407 | + if (TYPE_CODE (type) != TYPE_CODE_STRUCT | |
1408 | + && TYPE_CODE (type) != TYPE_CODE_UNION) | |
1409 | + error ("`%s' is not defined as an aggregate type.", | |
1410 | + TYPE_NAME (type)); | |
1411 | + | |
1412 | + write_exp_elt_opcode (OP_SCOPE); | |
1413 | + write_exp_elt_type (type); | |
1414 | + write_exp_string (yyvsp[0].sval); | |
1415 | + write_exp_elt_opcode (OP_SCOPE); | |
1416 | + ; | |
1417 | + break;} | |
1418 | +case 71: | |
1419 | +#line 609 "c-exp.y" | |
1420 | +{ | |
1421 | + struct type *type = yyvsp[-3].tval; | |
1422 | + struct stoken tmp_token; | |
1423 | + if (TYPE_CODE (type) != TYPE_CODE_STRUCT | |
1424 | + && TYPE_CODE (type) != TYPE_CODE_UNION) | |
1425 | + error ("`%s' is not defined as an aggregate type.", | |
1426 | + TYPE_NAME (type)); | |
1427 | + | |
1428 | + tmp_token.ptr = (char*) alloca (yyvsp[0].sval.length + 2); | |
1429 | + tmp_token.length = yyvsp[0].sval.length + 1; | |
1430 | + tmp_token.ptr[0] = '~'; | |
1431 | + memcpy (tmp_token.ptr+1, yyvsp[0].sval.ptr, yyvsp[0].sval.length); | |
1432 | + tmp_token.ptr[tmp_token.length] = 0; | |
1433 | + | |
1434 | + /* Check for valid destructor name. */ | |
1435 | + destructor_name_p (tmp_token.ptr, type); | |
1436 | + write_exp_elt_opcode (OP_SCOPE); | |
1437 | + write_exp_elt_type (type); | |
1438 | + write_exp_string (tmp_token); | |
1439 | + write_exp_elt_opcode (OP_SCOPE); | |
1440 | + ; | |
1441 | + break;} | |
1442 | +case 73: | |
1443 | +#line 634 "c-exp.y" | |
1444 | +{ | |
1445 | + char *name = copy_name (yyvsp[0].sval); | |
1446 | + struct symbol *sym; | |
1447 | + struct minimal_symbol *msymbol; | |
1448 | + | |
1449 | + sym = | |
1450 | + lookup_symbol (name, (const struct block *) NULL, | |
1451 | + VAR_NAMESPACE, (int *) NULL, | |
1452 | + (struct symtab **) NULL); | |
1453 | + if (sym) | |
1454 | + { | |
1455 | + write_exp_elt_opcode (OP_VAR_VALUE); | |
1456 | + write_exp_elt_block (NULL); | |
1457 | + write_exp_elt_sym (sym); | |
1458 | + write_exp_elt_opcode (OP_VAR_VALUE); | |
1459 | + break; | |
1460 | + } | |
1461 | + | |
1462 | + msymbol = lookup_minimal_symbol (name, NULL, NULL); | |
1463 | + if (msymbol != NULL) | |
1464 | + { | |
1465 | + write_exp_msymbol (msymbol, | |
1466 | + lookup_function_type (builtin_type_int), | |
1467 | + builtin_type_int); | |
1468 | + } | |
1469 | + else | |
1470 | + if (!have_full_symbols () && !have_partial_symbols ()) | |
1471 | + error ("No symbol table is loaded. Use the \"file\" command."); | |
1472 | + else | |
1473 | + error ("No symbol \"%s\" in current context.", name); | |
1474 | + ; | |
1475 | + break;} | |
1476 | +case 74: | |
1477 | +#line 668 "c-exp.y" | |
1478 | +{ struct symbol *sym = yyvsp[0].ssym.sym; | |
1479 | + | |
1480 | + if (sym) | |
1481 | + { | |
1482 | + if (symbol_read_needs_frame (sym)) | |
1483 | + { | |
1484 | + if (innermost_block == 0 || | |
1485 | + contained_in (block_found, | |
1486 | + innermost_block)) | |
1487 | + innermost_block = block_found; | |
1488 | + } | |
1489 | + | |
1490 | + write_exp_elt_opcode (OP_VAR_VALUE); | |
1491 | + /* We want to use the selected frame, not | |
1492 | + another more inner frame which happens to | |
1493 | + be in the same block. */ | |
1494 | + write_exp_elt_block (NULL); | |
1495 | + write_exp_elt_sym (sym); | |
1496 | + write_exp_elt_opcode (OP_VAR_VALUE); | |
1497 | + } | |
1498 | + else if (yyvsp[0].ssym.is_a_field_of_this) | |
1499 | + { | |
1500 | + /* C++: it hangs off of `this'. Must | |
1501 | + not inadvertently convert from a method call | |
1502 | + to data ref. */ | |
1503 | + if (innermost_block == 0 || | |
1504 | + contained_in (block_found, innermost_block)) | |
1505 | + innermost_block = block_found; | |
1506 | + write_exp_elt_opcode (OP_THIS); | |
1507 | + write_exp_elt_opcode (OP_THIS); | |
1508 | + write_exp_elt_opcode (STRUCTOP_PTR); | |
1509 | + write_exp_string (yyvsp[0].ssym.stoken); | |
1510 | + write_exp_elt_opcode (STRUCTOP_PTR); | |
1511 | + } | |
1512 | + else | |
1513 | + { | |
1514 | + struct minimal_symbol *msymbol; | |
1515 | + register char *arg = copy_name (yyvsp[0].ssym.stoken); | |
1516 | + | |
1517 | + msymbol = | |
1518 | + lookup_minimal_symbol (arg, NULL, NULL); | |
1519 | + if (msymbol != NULL) | |
1520 | + { | |
1521 | + write_exp_msymbol (msymbol, | |
1522 | + lookup_function_type (builtin_type_int), | |
1523 | + builtin_type_int); | |
1524 | + } | |
1525 | + else if (!have_full_symbols () && !have_partial_symbols ()) | |
1526 | + error ("No symbol table is loaded. Use the \"file\" command."); | |
1527 | + else | |
1528 | + error ("No symbol \"%s\" in current context.", | |
1529 | + copy_name (yyvsp[0].ssym.stoken)); | |
1530 | + } | |
1531 | + ; | |
1532 | + break;} | |
1533 | +case 78: | |
1534 | +#line 734 "c-exp.y" | |
1535 | +{ yyval.tval = follow_types (yyvsp[-1].tval); ; | |
1536 | + break;} | |
1537 | +case 79: | |
1538 | +#line 736 "c-exp.y" | |
1539 | +{ yyval.tval = follow_types (yyvsp[-2].tval); ; | |
1540 | + break;} | |
1541 | +case 80: | |
1542 | +#line 738 "c-exp.y" | |
1543 | +{ yyval.tval = follow_types (yyvsp[-2].tval); ; | |
1544 | + break;} | |
1545 | +case 81: | |
1546 | +#line 742 "c-exp.y" | |
1547 | +{ push_type (tp_pointer); yyval.voidval = 0; ; | |
1548 | + break;} | |
1549 | +case 82: | |
1550 | +#line 744 "c-exp.y" | |
1551 | +{ push_type (tp_pointer); yyval.voidval = yyvsp[0].voidval; ; | |
1552 | + break;} | |
1553 | +case 83: | |
1554 | +#line 746 "c-exp.y" | |
1555 | +{ push_type (tp_reference); yyval.voidval = 0; ; | |
1556 | + break;} | |
1557 | +case 84: | |
1558 | +#line 748 "c-exp.y" | |
1559 | +{ push_type (tp_reference); yyval.voidval = yyvsp[0].voidval; ; | |
1560 | + break;} | |
1561 | +case 86: | |
1562 | +#line 753 "c-exp.y" | |
1563 | +{ yyval.voidval = yyvsp[-1].voidval; ; | |
1564 | + break;} | |
1565 | +case 87: | |
1566 | +#line 755 "c-exp.y" | |
1567 | +{ | |
1568 | + push_type_int (yyvsp[0].lval); | |
1569 | + push_type (tp_array); | |
1570 | + ; | |
1571 | + break;} | |
1572 | +case 88: | |
1573 | +#line 760 "c-exp.y" | |
1574 | +{ | |
1575 | + push_type_int (yyvsp[0].lval); | |
1576 | + push_type (tp_array); | |
1577 | + yyval.voidval = 0; | |
1578 | + ; | |
1579 | + break;} | |
1580 | +case 89: | |
1581 | +#line 767 "c-exp.y" | |
1582 | +{ push_type (tp_function); ; | |
1583 | + break;} | |
1584 | +case 90: | |
1585 | +#line 769 "c-exp.y" | |
1586 | +{ push_type (tp_function); ; | |
1587 | + break;} | |
1588 | +case 91: | |
1589 | +#line 773 "c-exp.y" | |
1590 | +{ yyval.lval = -1; ; | |
1591 | + break;} | |
1592 | +case 92: | |
1593 | +#line 775 "c-exp.y" | |
1594 | +{ yyval.lval = yyvsp[-1].typed_val_int.val; ; | |
1595 | + break;} | |
1596 | +case 93: | |
1597 | +#line 779 "c-exp.y" | |
1598 | +{ yyval.voidval = 0; ; | |
1599 | + break;} | |
1600 | +case 94: | |
1601 | +#line 781 "c-exp.y" | |
1602 | +{ free ((PTR)yyvsp[-1].tvec); yyval.voidval = 0; ; | |
1603 | + break;} | |
1604 | +case 96: | |
1605 | +#line 794 "c-exp.y" | |
1606 | +{ yyval.tval = lookup_member_type (builtin_type_int, yyvsp[-2].tval); ; | |
1607 | + break;} | |
1608 | +case 97: | |
1609 | +#line 799 "c-exp.y" | |
1610 | +{ yyval.tval = yyvsp[0].tsym.type; ; | |
1611 | + break;} | |
1612 | +case 98: | |
1613 | +#line 801 "c-exp.y" | |
1614 | +{ yyval.tval = builtin_type_int; ; | |
1615 | + break;} | |
1616 | +case 99: | |
1617 | +#line 803 "c-exp.y" | |
1618 | +{ yyval.tval = builtin_type_long; ; | |
1619 | + break;} | |
1620 | +case 100: | |
1621 | +#line 805 "c-exp.y" | |
1622 | +{ yyval.tval = builtin_type_short; ; | |
1623 | + break;} | |
1624 | +case 101: | |
1625 | +#line 807 "c-exp.y" | |
1626 | +{ yyval.tval = builtin_type_long; ; | |
1627 | + break;} | |
1628 | +case 102: | |
1629 | +#line 809 "c-exp.y" | |
1630 | +{ yyval.tval = builtin_type_unsigned_long; ; | |
1631 | + break;} | |
1632 | +case 103: | |
1633 | +#line 811 "c-exp.y" | |
1634 | +{ yyval.tval = builtin_type_long_long; ; | |
1635 | + break;} | |
1636 | +case 104: | |
1637 | +#line 813 "c-exp.y" | |
1638 | +{ yyval.tval = builtin_type_long_long; ; | |
1639 | + break;} | |
1640 | +case 105: | |
1641 | +#line 815 "c-exp.y" | |
1642 | +{ yyval.tval = builtin_type_unsigned_long_long; ; | |
1643 | + break;} | |
1644 | +case 106: | |
1645 | +#line 817 "c-exp.y" | |
1646 | +{ yyval.tval = builtin_type_unsigned_long_long; ; | |
1647 | + break;} | |
1648 | +case 107: | |
1649 | +#line 819 "c-exp.y" | |
1650 | +{ yyval.tval = builtin_type_short; ; | |
1651 | + break;} | |
1652 | +case 108: | |
1653 | +#line 821 "c-exp.y" | |
1654 | +{ yyval.tval = builtin_type_unsigned_short; ; | |
1655 | + break;} | |
1656 | +case 109: | |
1657 | +#line 823 "c-exp.y" | |
1658 | +{ yyval.tval = builtin_type_double; ; | |
1659 | + break;} | |
1660 | +case 110: | |
1661 | +#line 825 "c-exp.y" | |
1662 | +{ yyval.tval = builtin_type_long_double; ; | |
1663 | + break;} | |
1664 | +case 111: | |
1665 | +#line 827 "c-exp.y" | |
1666 | +{ yyval.tval = lookup_struct (copy_name (yyvsp[0].sval), | |
1667 | + expression_context_block); ; | |
1668 | + break;} | |
1669 | +case 112: | |
1670 | +#line 830 "c-exp.y" | |
1671 | +{ yyval.tval = lookup_struct (copy_name (yyvsp[0].sval), | |
1672 | + expression_context_block); ; | |
1673 | + break;} | |
1674 | +case 113: | |
1675 | +#line 833 "c-exp.y" | |
1676 | +{ yyval.tval = lookup_union (copy_name (yyvsp[0].sval), | |
1677 | + expression_context_block); ; | |
1678 | + break;} | |
1679 | +case 114: | |
1680 | +#line 836 "c-exp.y" | |
1681 | +{ yyval.tval = lookup_enum (copy_name (yyvsp[0].sval), | |
1682 | + expression_context_block); ; | |
1683 | + break;} | |
1684 | +case 115: | |
1685 | +#line 839 "c-exp.y" | |
1686 | +{ yyval.tval = lookup_unsigned_typename (TYPE_NAME(yyvsp[0].tsym.type)); ; | |
1687 | + break;} | |
1688 | +case 116: | |
1689 | +#line 841 "c-exp.y" | |
1690 | +{ yyval.tval = builtin_type_unsigned_int; ; | |
1691 | + break;} | |
1692 | +case 117: | |
1693 | +#line 843 "c-exp.y" | |
1694 | +{ yyval.tval = lookup_signed_typename (TYPE_NAME(yyvsp[0].tsym.type)); ; | |
1695 | + break;} | |
1696 | +case 118: | |
1697 | +#line 845 "c-exp.y" | |
1698 | +{ yyval.tval = builtin_type_int; ; | |
1699 | + break;} | |
1700 | +case 119: | |
1701 | +#line 850 "c-exp.y" | |
1702 | +{ yyval.tval = lookup_template_type(copy_name(yyvsp[-3].sval), yyvsp[-1].tval, | |
1703 | + expression_context_block); | |
1704 | + ; | |
1705 | + break;} | |
1706 | +case 120: | |
1707 | +#line 856 "c-exp.y" | |
1708 | +{ yyval.tval = yyvsp[0].tval; ; | |
1709 | + break;} | |
1710 | +case 121: | |
1711 | +#line 857 "c-exp.y" | |
1712 | +{ yyval.tval = yyvsp[0].tval; ; | |
1713 | + break;} | |
1714 | +case 123: | |
1715 | +#line 862 "c-exp.y" | |
1716 | +{ | |
1717 | + yyval.tsym.stoken.ptr = "int"; | |
1718 | + yyval.tsym.stoken.length = 3; | |
1719 | + yyval.tsym.type = builtin_type_int; | |
1720 | + ; | |
1721 | + break;} | |
1722 | +case 124: | |
1723 | +#line 868 "c-exp.y" | |
1724 | +{ | |
1725 | + yyval.tsym.stoken.ptr = "long"; | |
1726 | + yyval.tsym.stoken.length = 4; | |
1727 | + yyval.tsym.type = builtin_type_long; | |
1728 | + ; | |
1729 | + break;} | |
1730 | +case 125: | |
1731 | +#line 874 "c-exp.y" | |
1732 | +{ | |
1733 | + yyval.tsym.stoken.ptr = "short"; | |
1734 | + yyval.tsym.stoken.length = 5; | |
1735 | + yyval.tsym.type = builtin_type_short; | |
1736 | + ; | |
1737 | + break;} | |
1738 | +case 126: | |
1739 | +#line 883 "c-exp.y" | |
1740 | +{ yyval.tvec = (struct type **) xmalloc (sizeof (struct type *) * 2); | |
1741 | + yyval.ivec[0] = 1; /* Number of types in vector */ | |
1742 | + yyval.tvec[1] = yyvsp[0].tval; | |
1743 | + ; | |
1744 | + break;} | |
1745 | +case 127: | |
1746 | +#line 888 "c-exp.y" | |
1747 | +{ int len = sizeof (struct type *) * (++(yyvsp[-2].ivec[0]) + 1); | |
1748 | + yyval.tvec = (struct type **) xrealloc ((char *) yyvsp[-2].tvec, len); | |
1749 | + yyval.tvec[yyval.ivec[0]] = yyvsp[0].tval; | |
1750 | + ; | |
1751 | + break;} | |
1752 | +case 128: | |
1753 | +#line 894 "c-exp.y" | |
1754 | +{ yyval.sval = yyvsp[0].ssym.stoken; ; | |
1755 | + break;} | |
1756 | +case 129: | |
1757 | +#line 895 "c-exp.y" | |
1758 | +{ yyval.sval = yyvsp[0].ssym.stoken; ; | |
1759 | + break;} | |
1760 | +case 130: | |
1761 | +#line 896 "c-exp.y" | |
1762 | +{ yyval.sval = yyvsp[0].tsym.stoken; ; | |
1763 | + break;} | |
1764 | +case 131: | |
1765 | +#line 897 "c-exp.y" | |
1766 | +{ yyval.sval = yyvsp[0].ssym.stoken; ; | |
1767 | + break;} | |
1768 | +} | |
1769 | + /* the action file gets copied in in place of this dollarsign */ | |
1770 | +#line 498 "/stone/jimb/main-98r2/share/bison.simple" | |
1771 | + | |
1772 | + yyvsp -= yylen; | |
1773 | + yyssp -= yylen; | |
1774 | +#ifdef YYLSP_NEEDED | |
1775 | + yylsp -= yylen; | |
1776 | +#endif | |
1777 | + | |
1778 | +#if YYDEBUG != 0 | |
1779 | + if (yydebug) | |
1780 | + { | |
1781 | + short *ssp1 = yyss - 1; | |
1782 | + fprintf (stderr, "state stack now"); | |
1783 | + while (ssp1 != yyssp) | |
1784 | + fprintf (stderr, " %d", *++ssp1); | |
1785 | + fprintf (stderr, "\n"); | |
1786 | + } | |
1787 | +#endif | |
1788 | + | |
1789 | + *++yyvsp = yyval; | |
1790 | + | |
1791 | +#ifdef YYLSP_NEEDED | |
1792 | + yylsp++; | |
1793 | + if (yylen == 0) | |
1794 | + { | |
1795 | + yylsp->first_line = yylloc.first_line; | |
1796 | + yylsp->first_column = yylloc.first_column; | |
1797 | + yylsp->last_line = (yylsp-1)->last_line; | |
1798 | + yylsp->last_column = (yylsp-1)->last_column; | |
1799 | + yylsp->text = 0; | |
1800 | + } | |
1801 | + else | |
1802 | + { | |
1803 | + yylsp->last_line = (yylsp+yylen-1)->last_line; | |
1804 | + yylsp->last_column = (yylsp+yylen-1)->last_column; | |
1805 | + } | |
1806 | +#endif | |
1807 | + | |
1808 | + /* Now "shift" the result of the reduction. | |
1809 | + Determine what state that goes to, | |
1810 | + based on the state we popped back to | |
1811 | + and the rule number reduced by. */ | |
1812 | + | |
1813 | + yyn = yyr1[yyn]; | |
1814 | + | |
1815 | + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; | |
1816 | + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) | |
1817 | + yystate = yytable[yystate]; | |
1818 | + else | |
1819 | + yystate = yydefgoto[yyn - YYNTBASE]; | |
1820 | + | |
1821 | + goto yynewstate; | |
1822 | + | |
1823 | +yyerrlab: /* here on detecting error */ | |
1824 | + | |
1825 | + if (! yyerrstatus) | |
1826 | + /* If not already recovering from an error, report this error. */ | |
1827 | + { | |
1828 | + ++yynerrs; | |
1829 | + | |
1830 | +#ifdef YYERROR_VERBOSE | |
1831 | + yyn = yypact[yystate]; | |
1832 | + | |
1833 | + if (yyn > YYFLAG && yyn < YYLAST) | |
1834 | + { | |
1835 | + int size = 0; | |
1836 | + char *msg; | |
1837 | + int x, count; | |
1838 | + | |
1839 | + count = 0; | |
1840 | + /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ | |
1841 | + for (x = (yyn < 0 ? -yyn : 0); | |
1842 | + x < (sizeof(yytname) / sizeof(char *)); x++) | |
1843 | + if (yycheck[x + yyn] == x) | |
1844 | + size += strlen(yytname[x]) + 15, count++; | |
1845 | + msg = (char *) xmalloc(size + 15); | |
1846 | + if (msg != 0) | |
1847 | + { | |
1848 | + strcpy(msg, "parse error"); | |
1849 | + | |
1850 | + if (count < 5) | |
1851 | + { | |
1852 | + count = 0; | |
1853 | + for (x = (yyn < 0 ? -yyn : 0); | |
1854 | + x < (sizeof(yytname) / sizeof(char *)); x++) | |
1855 | + if (yycheck[x + yyn] == x) | |
1856 | + { | |
1857 | + strcat(msg, count == 0 ? ", expecting `" : " or `"); | |
1858 | + strcat(msg, yytname[x]); | |
1859 | + strcat(msg, "'"); | |
1860 | + count++; | |
1861 | + } | |
1862 | + } | |
1863 | + yyerror(msg); | |
1864 | + free(msg); | |
1865 | + } | |
1866 | + else | |
1867 | + yyerror ("parse error; also virtual memory exceeded"); | |
1868 | + } | |
1869 | + else | |
1870 | +#endif /* YYERROR_VERBOSE */ | |
1871 | + yyerror("parse error"); | |
1872 | + } | |
1873 | + | |
1874 | + goto yyerrlab1; | |
1875 | +yyerrlab1: /* here on error raised explicitly by an action */ | |
1876 | + | |
1877 | + if (yyerrstatus == 3) | |
1878 | + { | |
1879 | + /* if just tried and failed to reuse lookahead token after an error, discard it. */ | |
1880 | + | |
1881 | + /* return failure if at end of input */ | |
1882 | + if (yychar == YYEOF) | |
1883 | + YYABORT; | |
1884 | + | |
1885 | +#if YYDEBUG != 0 | |
1886 | + if (yydebug) | |
1887 | + fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); | |
1888 | +#endif | |
1889 | + | |
1890 | + yychar = YYEMPTY; | |
1891 | + } | |
1892 | + | |
1893 | + /* Else will try to reuse lookahead token | |
1894 | + after shifting the error token. */ | |
1895 | + | |
1896 | + yyerrstatus = 3; /* Each real token shifted decrements this */ | |
1897 | + | |
1898 | + goto yyerrhandle; | |
1899 | + | |
1900 | +yyerrdefault: /* current state does not do anything special for the error token. */ | |
1901 | + | |
1902 | +#if 0 | |
1903 | + /* This is wrong; only states that explicitly want error tokens | |
1904 | + should shift them. */ | |
1905 | + yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ | |
1906 | + if (yyn) goto yydefault; | |
1907 | +#endif | |
1908 | + | |
1909 | +yyerrpop: /* pop the current state because it cannot handle the error token */ | |
1910 | + | |
1911 | + if (yyssp == yyss) YYABORT; | |
1912 | + yyvsp--; | |
1913 | + yystate = *--yyssp; | |
1914 | +#ifdef YYLSP_NEEDED | |
1915 | + yylsp--; | |
1916 | +#endif | |
1917 | + | |
1918 | +#if YYDEBUG != 0 | |
1919 | + if (yydebug) | |
1920 | + { | |
1921 | + short *ssp1 = yyss - 1; | |
1922 | + fprintf (stderr, "Error: state stack now"); | |
1923 | + while (ssp1 != yyssp) | |
1924 | + fprintf (stderr, " %d", *++ssp1); | |
1925 | + fprintf (stderr, "\n"); | |
1926 | + } | |
1927 | +#endif | |
1928 | + | |
1929 | +yyerrhandle: | |
1930 | + | |
1931 | + yyn = yypact[yystate]; | |
1932 | + if (yyn == YYFLAG) | |
1933 | + goto yyerrdefault; | |
1934 | + | |
1935 | + yyn += YYTERROR; | |
1936 | + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) | |
1937 | + goto yyerrdefault; | |
1938 | + | |
1939 | + yyn = yytable[yyn]; | |
1940 | + if (yyn < 0) | |
1941 | + { | |
1942 | + if (yyn == YYFLAG) | |
1943 | + goto yyerrpop; | |
1944 | + yyn = -yyn; | |
1945 | + goto yyreduce; | |
1946 | + } | |
1947 | + else if (yyn == 0) | |
1948 | + goto yyerrpop; | |
1949 | + | |
1950 | + if (yyn == YYFINAL) | |
1951 | + YYACCEPT; | |
1952 | + | |
1953 | +#if YYDEBUG != 0 | |
1954 | + if (yydebug) | |
1955 | + fprintf(stderr, "Shifting error token, "); | |
1956 | +#endif | |
1957 | + | |
1958 | + *++yyvsp = yylval; | |
1959 | +#ifdef YYLSP_NEEDED | |
1960 | + *++yylsp = yylloc; | |
1961 | +#endif | |
1962 | + | |
1963 | + yystate = yyn; | |
1964 | + goto yynewstate; | |
1965 | +} | |
1966 | +#line 911 "c-exp.y" | |
1967 | + | |
1968 | + | |
1969 | +/* Take care of parsing a number (anything that starts with a digit). | |
1970 | + Set yylval and return the token type; update lexptr. | |
1971 | + LEN is the number of characters in it. */ | |
1972 | + | |
1973 | +/*** Needs some error checking for the float case ***/ | |
1974 | + | |
1975 | +static int | |
1976 | +parse_number (p, len, parsed_float, putithere) | |
1977 | + register char *p; | |
1978 | + register int len; | |
1979 | + int parsed_float; | |
1980 | + YYSTYPE *putithere; | |
1981 | +{ | |
1982 | + /* FIXME: Shouldn't these be unsigned? We don't deal with negative values | |
1983 | + here, and we do kind of silly things like cast to unsigned. */ | |
1984 | + register LONGEST n = 0; | |
1985 | + register LONGEST prevn = 0; | |
1986 | + ULONGEST un; | |
1987 | + | |
1988 | + register int i = 0; | |
1989 | + register int c; | |
1990 | + register int base = input_radix; | |
1991 | + int unsigned_p = 0; | |
1992 | + | |
1993 | + /* Number of "L" suffixes encountered. */ | |
1994 | + int long_p = 0; | |
1995 | + | |
1996 | + /* We have found a "L" or "U" suffix. */ | |
1997 | + int found_suffix = 0; | |
1998 | + | |
1999 | + ULONGEST high_bit; | |
2000 | + struct type *signed_type; | |
2001 | + struct type *unsigned_type; | |
2002 | + | |
2003 | + if (parsed_float) | |
2004 | + { | |
2005 | + /* It's a float since it contains a point or an exponent. */ | |
2006 | + char c; | |
2007 | + int num = 0; /* number of tokens scanned by scanf */ | |
2008 | + char saved_char = p[len]; | |
2009 | + | |
2010 | + p[len] = 0; /* null-terminate the token */ | |
2011 | + if (sizeof (putithere->typed_val_float.dval) <= sizeof (float)) | |
2012 | + num = sscanf (p, "%g%c", (float *) &putithere->typed_val_float.dval,&c); | |
2013 | + else if (sizeof (putithere->typed_val_float.dval) <= sizeof (double)) | |
2014 | + num = sscanf (p, "%lg%c", (double *) &putithere->typed_val_float.dval,&c); | |
2015 | + else | |
2016 | + { | |
2017 | +#ifdef SCANF_HAS_LONG_DOUBLE | |
2018 | + num = sscanf (p, "%Lg%c", &putithere->typed_val_float.dval,&c); | |
2019 | +#else | |
2020 | + /* Scan it into a double, then assign it to the long double. | |
2021 | + This at least wins with values representable in the range | |
2022 | + of doubles. */ | |
2023 | + double temp; | |
2024 | + num = sscanf (p, "%lg%c", &temp,&c); | |
2025 | + putithere->typed_val_float.dval = temp; | |
2026 | +#endif | |
2027 | + } | |
2028 | + p[len] = saved_char; /* restore the input stream */ | |
2029 | + if (num != 1) /* check scanf found ONLY a float ... */ | |
2030 | + return ERROR; | |
2031 | + /* See if it has `f' or `l' suffix (float or long double). */ | |
2032 | + | |
2033 | + c = tolower (p[len - 1]); | |
2034 | + | |
2035 | + if (c == 'f') | |
2036 | + putithere->typed_val_float.type = builtin_type_float; | |
2037 | + else if (c == 'l') | |
2038 | + putithere->typed_val_float.type = builtin_type_long_double; | |
2039 | + else if (isdigit (c) || c == '.') | |
2040 | + putithere->typed_val_float.type = builtin_type_double; | |
2041 | + else | |
2042 | + return ERROR; | |
2043 | + | |
2044 | + return FLOAT; | |
2045 | + } | |
2046 | + | |
2047 | + /* Handle base-switching prefixes 0x, 0t, 0d, 0 */ | |
2048 | + if (p[0] == '0') | |
2049 | + switch (p[1]) | |
2050 | + { | |
2051 | + case 'x': | |
2052 | + case 'X': | |
2053 | + if (len >= 3) | |
2054 | + { | |
2055 | + p += 2; | |
2056 | + base = 16; | |
2057 | + len -= 2; | |
2058 | + } | |
2059 | + break; | |
2060 | + | |
2061 | + case 't': | |
2062 | + case 'T': | |
2063 | + case 'd': | |
2064 | + case 'D': | |
2065 | + if (len >= 3) | |
2066 | + { | |
2067 | + p += 2; | |
2068 | + base = 10; | |
2069 | + len -= 2; | |
2070 | + } | |
2071 | + break; | |
2072 | + | |
2073 | + default: | |
2074 | + base = 8; | |
2075 | + break; | |
2076 | + } | |
2077 | + | |
2078 | + while (len-- > 0) | |
2079 | + { | |
2080 | + c = *p++; | |
2081 | + if (c >= 'A' && c <= 'Z') | |
2082 | + c += 'a' - 'A'; | |
2083 | + if (c != 'l' && c != 'u') | |
2084 | + n *= base; | |
2085 | + if (c >= '0' && c <= '9') | |
2086 | + { | |
2087 | + if (found_suffix) | |
2088 | + return ERROR; | |
2089 | + n += i = c - '0'; | |
2090 | + } | |
2091 | + else | |
2092 | + { | |
2093 | + if (base > 10 && c >= 'a' && c <= 'f') | |
2094 | + { | |
2095 | + if (found_suffix) | |
2096 | + return ERROR; | |
2097 | + n += i = c - 'a' + 10; | |
2098 | + } | |
2099 | + else if (c == 'l') | |
2100 | + { | |
2101 | + ++long_p; | |
2102 | + found_suffix = 1; | |
2103 | + } | |
2104 | + else if (c == 'u') | |
2105 | + { | |
2106 | + unsigned_p = 1; | |
2107 | + found_suffix = 1; | |
2108 | + } | |
2109 | + else | |
2110 | + return ERROR; /* Char not a digit */ | |
2111 | + } | |
2112 | + if (i >= base) | |
2113 | + return ERROR; /* Invalid digit in this base */ | |
2114 | + | |
2115 | + /* Portably test for overflow (only works for nonzero values, so make | |
2116 | + a second check for zero). FIXME: Can't we just make n and prevn | |
2117 | + unsigned and avoid this? */ | |
2118 | + if (c != 'l' && c != 'u' && (prevn >= n) && n != 0) | |
2119 | + unsigned_p = 1; /* Try something unsigned */ | |
2120 | + | |
2121 | + /* Portably test for unsigned overflow. | |
2122 | + FIXME: This check is wrong; for example it doesn't find overflow | |
2123 | + on 0x123456789 when LONGEST is 32 bits. */ | |
2124 | + if (c != 'l' && c != 'u' && n != 0) | |
2125 | + { | |
2126 | + if ((unsigned_p && (ULONGEST) prevn >= (ULONGEST) n)) | |
2127 | + error ("Numeric constant too large."); | |
2128 | + } | |
2129 | + prevn = n; | |
2130 | + } | |
2131 | + | |
2132 | + /* An integer constant is an int, a long, or a long long. An L | |
2133 | + suffix forces it to be long; an LL suffix forces it to be long | |
2134 | + long. If not forced to a larger size, it gets the first type of | |
2135 | + the above that it fits in. To figure out whether it fits, we | |
2136 | + shift it right and see whether anything remains. Note that we | |
2137 | + can't shift sizeof (LONGEST) * HOST_CHAR_BIT bits or more in one | |
2138 | + operation, because many compilers will warn about such a shift | |
2139 | + (which always produces a zero result). Sometimes TARGET_INT_BIT | |
2140 | + or TARGET_LONG_BIT will be that big, sometimes not. To deal with | |
2141 | + the case where it is we just always shift the value more than | |
2142 | + once, with fewer bits each time. */ | |
2143 | + | |
2144 | + un = (ULONGEST)n >> 2; | |
2145 | + if (long_p == 0 | |
2146 | + && (un >> (TARGET_INT_BIT - 2)) == 0) | |
2147 | + { | |
2148 | + high_bit = ((ULONGEST)1) << (TARGET_INT_BIT-1); | |
2149 | + | |
2150 | + /* A large decimal (not hex or octal) constant (between INT_MAX | |
2151 | + and UINT_MAX) is a long or unsigned long, according to ANSI, | |
2152 | + never an unsigned int, but this code treats it as unsigned | |
2153 | + int. This probably should be fixed. GCC gives a warning on | |
2154 | + such constants. */ | |
2155 | + | |
2156 | + unsigned_type = builtin_type_unsigned_int; | |
2157 | + signed_type = builtin_type_int; | |
2158 | + } | |
2159 | + else if (long_p <= 1 | |
2160 | + && (un >> (TARGET_LONG_BIT - 2)) == 0) | |
2161 | + { | |
2162 | + high_bit = ((ULONGEST)1) << (TARGET_LONG_BIT-1); | |
2163 | + unsigned_type = builtin_type_unsigned_long; | |
2164 | + signed_type = builtin_type_long; | |
2165 | + } | |
2166 | + else | |
2167 | + { | |
2168 | + int shift; | |
2169 | + if (sizeof (ULONGEST) * HOST_CHAR_BIT < TARGET_LONG_LONG_BIT) | |
2170 | + /* A long long does not fit in a LONGEST. */ | |
2171 | + shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1); | |
2172 | + else | |
2173 | + shift = (TARGET_LONG_LONG_BIT - 1); | |
2174 | + high_bit = (ULONGEST) 1 << shift; | |
2175 | + unsigned_type = builtin_type_unsigned_long_long; | |
2176 | + signed_type = builtin_type_long_long; | |
2177 | + } | |
2178 | + | |
2179 | + putithere->typed_val_int.val = n; | |
2180 | + | |
2181 | + /* If the high bit of the worked out type is set then this number | |
2182 | + has to be unsigned. */ | |
2183 | + | |
2184 | + if (unsigned_p || (n & high_bit)) | |
2185 | + { | |
2186 | + putithere->typed_val_int.type = unsigned_type; | |
2187 | + } | |
2188 | + else | |
2189 | + { | |
2190 | + putithere->typed_val_int.type = signed_type; | |
2191 | + } | |
2192 | + | |
2193 | + return INT; | |
2194 | +} | |
2195 | + | |
2196 | +struct token | |
2197 | +{ | |
2198 | + char *operator; | |
2199 | + int token; | |
2200 | + enum exp_opcode opcode; | |
2201 | +}; | |
2202 | + | |
2203 | +static const struct token tokentab3[] = | |
2204 | + { | |
2205 | + {">>=", ASSIGN_MODIFY, BINOP_RSH}, | |
2206 | + {"<<=", ASSIGN_MODIFY, BINOP_LSH} | |
2207 | + }; | |
2208 | + | |
2209 | +static const struct token tokentab2[] = | |
2210 | + { | |
2211 | + {"+=", ASSIGN_MODIFY, BINOP_ADD}, | |
2212 | + {"-=", ASSIGN_MODIFY, BINOP_SUB}, | |
2213 | + {"*=", ASSIGN_MODIFY, BINOP_MUL}, | |
2214 | + {"/=", ASSIGN_MODIFY, BINOP_DIV}, | |
2215 | + {"%=", ASSIGN_MODIFY, BINOP_REM}, | |
2216 | + {"|=", ASSIGN_MODIFY, BINOP_BITWISE_IOR}, | |
2217 | + {"&=", ASSIGN_MODIFY, BINOP_BITWISE_AND}, | |
2218 | + {"^=", ASSIGN_MODIFY, BINOP_BITWISE_XOR}, | |
2219 | + {"++", INCREMENT, BINOP_END}, | |
2220 | + {"--", DECREMENT, BINOP_END}, | |
2221 | + {"->", ARROW, BINOP_END}, | |
2222 | + {"&&", ANDAND, BINOP_END}, | |
2223 | + {"||", OROR, BINOP_END}, | |
2224 | + {"::", COLONCOLON, BINOP_END}, | |
2225 | + {"<<", LSH, BINOP_END}, | |
2226 | + {">>", RSH, BINOP_END}, | |
2227 | + {"==", EQUAL, BINOP_END}, | |
2228 | + {"!=", NOTEQUAL, BINOP_END}, | |
2229 | + {"<=", LEQ, BINOP_END}, | |
2230 | + {">=", GEQ, BINOP_END} | |
2231 | + }; | |
2232 | + | |
2233 | +/* Read one token, getting characters through lexptr. */ | |
2234 | + | |
2235 | +static int | |
2236 | +yylex () | |
2237 | +{ | |
2238 | + int c; | |
2239 | + int namelen; | |
2240 | + unsigned int i; | |
2241 | + char *tokstart; | |
2242 | + char *tokptr; | |
2243 | + int tempbufindex; | |
2244 | + static char *tempbuf; | |
2245 | + static int tempbufsize; | |
2246 | + struct symbol * sym_class = NULL; | |
2247 | + char * token_string = NULL; | |
2248 | + int class_prefix = 0; | |
2249 | + int unquoted_expr; | |
2250 | + | |
2251 | + retry: | |
2252 | + | |
2253 | + unquoted_expr = 1; | |
2254 | + | |
2255 | + tokstart = lexptr; | |
2256 | + /* See if it is a special token of length 3. */ | |
2257 | + for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++) | |
2258 | + if (STREQN (tokstart, tokentab3[i].operator, 3)) | |
2259 | + { | |
2260 | + lexptr += 3; | |
2261 | + yylval.opcode = tokentab3[i].opcode; | |
2262 | + return tokentab3[i].token; | |
2263 | + } | |
2264 | + | |
2265 | + /* See if it is a special token of length 2. */ | |
2266 | + for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++) | |
2267 | + if (STREQN (tokstart, tokentab2[i].operator, 2)) | |
2268 | + { | |
2269 | + lexptr += 2; | |
2270 | + yylval.opcode = tokentab2[i].opcode; | |
2271 | + return tokentab2[i].token; | |
2272 | + } | |
2273 | + | |
2274 | + switch (c = *tokstart) | |
2275 | + { | |
2276 | + case 0: | |
2277 | + return 0; | |
2278 | + | |
2279 | + case ' ': | |
2280 | + case '\t': | |
2281 | + case '\n': | |
2282 | + lexptr++; | |
2283 | + goto retry; | |
2284 | + | |
2285 | + case '\'': | |
2286 | + /* We either have a character constant ('0' or '\177' for example) | |
2287 | + or we have a quoted symbol reference ('foo(int,int)' in C++ | |
2288 | + for example). */ | |
2289 | + lexptr++; | |
2290 | + c = *lexptr++; | |
2291 | + if (c == '\\') | |
2292 | + c = parse_escape (&lexptr); | |
2293 | + else if (c == '\'') | |
2294 | + error ("Empty character constant."); | |
2295 | + | |
2296 | + yylval.typed_val_int.val = c; | |
2297 | + yylval.typed_val_int.type = builtin_type_char; | |
2298 | + | |
2299 | + c = *lexptr++; | |
2300 | + if (c != '\'') | |
2301 | + { | |
2302 | + namelen = skip_quoted (tokstart) - tokstart; | |
2303 | + if (namelen > 2) | |
2304 | + { | |
2305 | + lexptr = tokstart + namelen; | |
2306 | + unquoted_expr = 0; | |
2307 | + if (lexptr[-1] != '\'') | |
2308 | + error ("Unmatched single quote."); | |
2309 | + namelen -= 2; | |
2310 | + tokstart++; | |
2311 | + goto tryname; | |
2312 | + } | |
2313 | + error ("Invalid character constant."); | |
2314 | + } | |
2315 | + return INT; | |
2316 | + | |
2317 | + case '(': | |
2318 | + paren_depth++; | |
2319 | + lexptr++; | |
2320 | + return c; | |
2321 | + | |
2322 | + case ')': | |
2323 | + if (paren_depth == 0) | |
2324 | + return 0; | |
2325 | + paren_depth--; | |
2326 | + lexptr++; | |
2327 | + return c; | |
2328 | + | |
2329 | + case ',': | |
2330 | + if (comma_terminates && paren_depth == 0) | |
2331 | + return 0; | |
2332 | + lexptr++; | |
2333 | + return c; | |
2334 | + | |
2335 | + case '.': | |
2336 | + /* Might be a floating point number. */ | |
2337 | + if (lexptr[1] < '0' || lexptr[1] > '9') | |
2338 | + goto symbol; /* Nope, must be a symbol. */ | |
2339 | + /* FALL THRU into number case. */ | |
2340 | + | |
2341 | + case '0': | |
2342 | + case '1': | |
2343 | + case '2': | |
2344 | + case '3': | |
2345 | + case '4': | |
2346 | + case '5': | |
2347 | + case '6': | |
2348 | + case '7': | |
2349 | + case '8': | |
2350 | + case '9': | |
2351 | + { | |
2352 | + /* It's a number. */ | |
2353 | + int got_dot = 0, got_e = 0, toktype; | |
2354 | + register char *p = tokstart; | |
2355 | + int hex = input_radix > 10; | |
2356 | + | |
2357 | + if (c == '0' && (p[1] == 'x' || p[1] == 'X')) | |
2358 | + { | |
2359 | + p += 2; | |
2360 | + hex = 1; | |
2361 | + } | |
2362 | + else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D')) | |
2363 | + { | |
2364 | + p += 2; | |
2365 | + hex = 0; | |
2366 | + } | |
2367 | + | |
2368 | + for (;; ++p) | |
2369 | + { | |
2370 | + /* This test includes !hex because 'e' is a valid hex digit | |
2371 | + and thus does not indicate a floating point number when | |
2372 | + the radix is hex. */ | |
2373 | + if (!hex && !got_e && (*p == 'e' || *p == 'E')) | |
2374 | + got_dot = got_e = 1; | |
2375 | + /* This test does not include !hex, because a '.' always indicates | |
2376 | + a decimal floating point number regardless of the radix. */ | |
2377 | + else if (!got_dot && *p == '.') | |
2378 | + got_dot = 1; | |
2379 | + else if (got_e && (p[-1] == 'e' || p[-1] == 'E') | |
2380 | + && (*p == '-' || *p == '+')) | |
2381 | + /* This is the sign of the exponent, not the end of the | |
2382 | + number. */ | |
2383 | + continue; | |
2384 | + /* We will take any letters or digits. parse_number will | |
2385 | + complain if past the radix, or if L or U are not final. */ | |
2386 | + else if ((*p < '0' || *p > '9') | |
2387 | + && ((*p < 'a' || *p > 'z') | |
2388 | + && (*p < 'A' || *p > 'Z'))) | |
2389 | + break; | |
2390 | + } | |
2391 | + toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval); | |
2392 | + if (toktype == ERROR) | |
2393 | + { | |
2394 | + char *err_copy = (char *) alloca (p - tokstart + 1); | |
2395 | + | |
2396 | + memcpy (err_copy, tokstart, p - tokstart); | |
2397 | + err_copy[p - tokstart] = 0; | |
2398 | + error ("Invalid number \"%s\".", err_copy); | |
2399 | + } | |
2400 | + lexptr = p; | |
2401 | + return toktype; | |
2402 | + } | |
2403 | + | |
2404 | + case '+': | |
2405 | + case '-': | |
2406 | + case '*': | |
2407 | + case '/': | |
2408 | + case '%': | |
2409 | + case '|': | |
2410 | + case '&': | |
2411 | + case '^': | |
2412 | + case '~': | |
2413 | + case '!': | |
2414 | + case '@': | |
2415 | + case '<': | |
2416 | + case '>': | |
2417 | + case '[': | |
2418 | + case ']': | |
2419 | + case '?': | |
2420 | + case ':': | |
2421 | + case '=': | |
2422 | + case '{': | |
2423 | + case '}': | |
2424 | + symbol: | |
2425 | + lexptr++; | |
2426 | + return c; | |
2427 | + | |
2428 | + case '"': | |
2429 | + | |
2430 | + /* Build the gdb internal form of the input string in tempbuf, | |
2431 | + translating any standard C escape forms seen. Note that the | |
2432 | + buffer is null byte terminated *only* for the convenience of | |
2433 | + debugging gdb itself and printing the buffer contents when | |
2434 | + the buffer contains no embedded nulls. Gdb does not depend | |
2435 | + upon the buffer being null byte terminated, it uses the length | |
2436 | + string instead. This allows gdb to handle C strings (as well | |
2437 | + as strings in other languages) with embedded null bytes */ | |
2438 | + | |
2439 | + tokptr = ++tokstart; | |
2440 | + tempbufindex = 0; | |
2441 | + | |
2442 | + do { | |
2443 | + /* Grow the static temp buffer if necessary, including allocating | |
2444 | + the first one on demand. */ | |
2445 | + if (tempbufindex + 1 >= tempbufsize) | |
2446 | + { | |
2447 | + tempbuf = (char *) xrealloc (tempbuf, tempbufsize += 64); | |
2448 | + } | |
2449 | + switch (*tokptr) | |
2450 | + { | |
2451 | + case '\0': | |
2452 | + case '"': | |
2453 | + /* Do nothing, loop will terminate. */ | |
2454 | + break; | |
2455 | + case '\\': | |
2456 | + tokptr++; | |
2457 | + c = parse_escape (&tokptr); | |
2458 | + if (c == -1) | |
2459 | + { | |
2460 | + continue; | |
2461 | + } | |
2462 | + tempbuf[tempbufindex++] = c; | |
2463 | + break; | |
2464 | + default: | |
2465 | + tempbuf[tempbufindex++] = *tokptr++; | |
2466 | + break; | |
2467 | + } | |
2468 | + } while ((*tokptr != '"') && (*tokptr != '\0')); | |
2469 | + if (*tokptr++ != '"') | |
2470 | + { | |
2471 | + error ("Unterminated string in expression."); | |
2472 | + } | |
2473 | + tempbuf[tempbufindex] = '\0'; /* See note above */ | |
2474 | + yylval.sval.ptr = tempbuf; | |
2475 | + yylval.sval.length = tempbufindex; | |
2476 | + lexptr = tokptr; | |
2477 | + return (STRING); | |
2478 | + } | |
2479 | + | |
2480 | + if (!(c == '_' || c == '$' | |
2481 | + || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) | |
2482 | + /* We must have come across a bad character (e.g. ';'). */ | |
2483 | + error ("Invalid character '%c' in expression.", c); | |
2484 | + | |
2485 | + /* It's a name. See how long it is. */ | |
2486 | + namelen = 0; | |
2487 | + for (c = tokstart[namelen]; | |
2488 | + (c == '_' || c == '$' || (c >= '0' && c <= '9') | |
2489 | + || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '<');) | |
2490 | + { | |
2491 | + /* Template parameter lists are part of the name. | |
2492 | + FIXME: This mishandles `print $a<4&&$a>3'. */ | |
2493 | + | |
2494 | + if (c == '<') | |
2495 | + { | |
2496 | + if (hp_som_som_object_present) | |
2497 | + { | |
2498 | + /* Scan ahead to get rest of the template specification. Note | |
2499 | + that we look ahead only when the '<' adjoins non-whitespace | |
2500 | + characters; for comparison expressions, e.g. "a < b > c", | |
2501 | + there must be spaces before the '<', etc. */ | |
2502 | + | |
2503 | + char * p = find_template_name_end (tokstart + namelen); | |
2504 | + if (p) | |
2505 | + namelen = p - tokstart; | |
2506 | + break; | |
2507 | + } | |
2508 | + else | |
2509 | + { | |
2510 | + int i = namelen; | |
2511 | + int nesting_level = 1; | |
2512 | + while (tokstart[++i]) | |
2513 | + { | |
2514 | + if (tokstart[i] == '<') | |
2515 | + nesting_level++; | |
2516 | + else if (tokstart[i] == '>') | |
2517 | + { | |
2518 | + if (--nesting_level == 0) | |
2519 | + break; | |
2520 | + } | |
2521 | + } | |
2522 | + if (tokstart[i] == '>') | |
2523 | + namelen = i; | |
2524 | + else | |
2525 | + break; | |
2526 | + } | |
2527 | + } | |
2528 | + c = tokstart[++namelen]; | |
2529 | + } | |
2530 | + | |
2531 | + /* The token "if" terminates the expression and is NOT | |
2532 | + removed from the input stream. */ | |
2533 | + if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f') | |
2534 | + { | |
2535 | + return 0; | |
2536 | + } | |
2537 | + | |
2538 | + lexptr += namelen; | |
2539 | + | |
2540 | + tryname: | |
2541 | + | |
2542 | + /* Catch specific keywords. Should be done with a data structure. */ | |
2543 | + switch (namelen) | |
2544 | + { | |
2545 | + case 8: | |
2546 | + if (STREQN (tokstart, "unsigned", 8)) | |
2547 | + return UNSIGNED; | |
2548 | + if (current_language->la_language == language_cplus | |
2549 | + && STREQN (tokstart, "template", 8)) | |
2550 | + return TEMPLATE; | |
2551 | + if (STREQN (tokstart, "volatile", 8)) | |
2552 | + return VOLATILE_KEYWORD; | |
2553 | + break; | |
2554 | + case 6: | |
2555 | + if (STREQN (tokstart, "struct", 6)) | |
2556 | + return STRUCT; | |
2557 | + if (STREQN (tokstart, "signed", 6)) | |
2558 | + return SIGNED_KEYWORD; | |
2559 | + if (STREQN (tokstart, "sizeof", 6)) | |
2560 | + return SIZEOF; | |
2561 | + if (STREQN (tokstart, "double", 6)) | |
2562 | + return DOUBLE_KEYWORD; | |
2563 | + break; | |
2564 | + case 5: | |
2565 | + if (current_language->la_language == language_cplus) | |
2566 | + { | |
2567 | + if (STREQN (tokstart, "false", 5)) | |
2568 | + return FALSEKEYWORD; | |
2569 | + if (STREQN (tokstart, "class", 5)) | |
2570 | + return CLASS; | |
2571 | + } | |
2572 | + if (STREQN (tokstart, "union", 5)) | |
2573 | + return UNION; | |
2574 | + if (STREQN (tokstart, "short", 5)) | |
2575 | + return SHORT; | |
2576 | + if (STREQN (tokstart, "const", 5)) | |
2577 | + return CONST_KEYWORD; | |
2578 | + break; | |
2579 | + case 4: | |
2580 | + if (STREQN (tokstart, "enum", 4)) | |
2581 | + return ENUM; | |
2582 | + if (STREQN (tokstart, "long", 4)) | |
2583 | + return LONG; | |
2584 | + if (current_language->la_language == language_cplus) | |
2585 | + { | |
2586 | + if (STREQN (tokstart, "true", 4)) | |
2587 | + return TRUEKEYWORD; | |
2588 | + | |
2589 | + if (STREQN (tokstart, "this", 4)) | |
2590 | + { | |
2591 | + static const char this_name[] = | |
2592 | + { CPLUS_MARKER, 't', 'h', 'i', 's', '\0' }; | |
2593 | + | |
2594 | + if (lookup_symbol (this_name, expression_context_block, | |
2595 | + VAR_NAMESPACE, (int *) NULL, | |
2596 | + (struct symtab **) NULL)) | |
2597 | + return THIS; | |
2598 | + } | |
2599 | + } | |
2600 | + break; | |
2601 | + case 3: | |
2602 | + if (STREQN (tokstart, "int", 3)) | |
2603 | + return INT_KEYWORD; | |
2604 | + break; | |
2605 | + default: | |
2606 | + break; | |
2607 | + } | |
2608 | + | |
2609 | + yylval.sval.ptr = tokstart; | |
2610 | + yylval.sval.length = namelen; | |
2611 | + | |
2612 | + if (*tokstart == '$') | |
2613 | + { | |
2614 | + write_dollar_variable (yylval.sval); | |
2615 | + return VARIABLE; | |
2616 | + } | |
2617 | + | |
2618 | + /* Look ahead and see if we can consume more of the input | |
2619 | + string to get a reasonable class/namespace spec or a | |
2620 | + fully-qualified name. This is a kludge to get around the | |
2621 | + HP aCC compiler's generation of symbol names with embedded | |
2622 | + colons for namespace and nested classes. */ | |
2623 | + if (unquoted_expr) | |
2624 | + { | |
2625 | + /* Only do it if not inside single quotes */ | |
2626 | + sym_class = parse_nested_classes_for_hpacc (yylval.sval.ptr, yylval.sval.length, | |
2627 | + &token_string, &class_prefix, &lexptr); | |
2628 | + if (sym_class) | |
2629 | + { | |
2630 | + /* Replace the current token with the bigger one we found */ | |
2631 | + yylval.sval.ptr = token_string; | |
2632 | + yylval.sval.length = strlen (token_string); | |
2633 | + } | |
2634 | + } | |
2635 | + | |
2636 | + /* Use token-type BLOCKNAME for symbols that happen to be defined as | |
2637 | + functions or symtabs. If this is not so, then ... | |
2638 | + Use token-type TYPENAME for symbols that happen to be defined | |
2639 | + currently as names of types; NAME for other symbols. | |
2640 | + The caller is not constrained to care about the distinction. */ | |
2641 | + { | |
2642 | + char *tmp = copy_name (yylval.sval); | |
2643 | + struct symbol *sym; | |
2644 | + int is_a_field_of_this = 0; | |
2645 | + int hextype; | |
2646 | + | |
2647 | + sym = lookup_symbol (tmp, expression_context_block, | |
2648 | + VAR_NAMESPACE, | |
2649 | + current_language->la_language == language_cplus | |
2650 | + ? &is_a_field_of_this : (int *) NULL, | |
2651 | + (struct symtab **) NULL); | |
2652 | + /* Call lookup_symtab, not lookup_partial_symtab, in case there are | |
2653 | + no psymtabs (coff, xcoff, or some future change to blow away the | |
2654 | + psymtabs once once symbols are read). */ | |
2655 | + if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK) | |
2656 | + { | |
2657 | + yylval.ssym.sym = sym; | |
2658 | + yylval.ssym.is_a_field_of_this = is_a_field_of_this; | |
2659 | + return BLOCKNAME; | |
2660 | + } | |
2661 | + else if (!sym) | |
2662 | + { /* See if it's a file name. */ | |
2663 | + struct symtab *symtab; | |
2664 | + | |
2665 | + symtab = lookup_symtab (tmp); | |
2666 | + | |
2667 | + if (symtab) | |
2668 | + { | |
2669 | + yylval.bval = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK); | |
2670 | + return FILENAME; | |
2671 | + } | |
2672 | + } | |
2673 | + | |
2674 | + if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF) | |
2675 | + { | |
2676 | +#if 1 | |
2677 | + /* Despite the following flaw, we need to keep this code enabled. | |
2678 | + Because we can get called from check_stub_method, if we don't | |
2679 | + handle nested types then it screws many operations in any | |
2680 | + program which uses nested types. */ | |
2681 | + /* In "A::x", if x is a member function of A and there happens | |
2682 | + to be a type (nested or not, since the stabs don't make that | |
2683 | + distinction) named x, then this code incorrectly thinks we | |
2684 | + are dealing with nested types rather than a member function. */ | |
2685 | + | |
2686 | + char *p; | |
2687 | + char *namestart; | |
2688 | + struct symbol *best_sym; | |
2689 | + | |
2690 | + /* Look ahead to detect nested types. This probably should be | |
2691 | + done in the grammar, but trying seemed to introduce a lot | |
2692 | + of shift/reduce and reduce/reduce conflicts. It's possible | |
2693 | + that it could be done, though. Or perhaps a non-grammar, but | |
2694 | + less ad hoc, approach would work well. */ | |
2695 | + | |
2696 | + /* Since we do not currently have any way of distinguishing | |
2697 | + a nested type from a non-nested one (the stabs don't tell | |
2698 | + us whether a type is nested), we just ignore the | |
2699 | + containing type. */ | |
2700 | + | |
2701 | + p = lexptr; | |
2702 | + best_sym = sym; | |
2703 | + while (1) | |
2704 | + { | |
2705 | + /* Skip whitespace. */ | |
2706 | + while (*p == ' ' || *p == '\t' || *p == '\n') | |
2707 | + ++p; | |
2708 | + if (*p == ':' && p[1] == ':') | |
2709 | + { | |
2710 | + /* Skip the `::'. */ | |
2711 | + p += 2; | |
2712 | + /* Skip whitespace. */ | |
2713 | + while (*p == ' ' || *p == '\t' || *p == '\n') | |
2714 | + ++p; | |
2715 | + namestart = p; | |
2716 | + while (*p == '_' || *p == '$' || (*p >= '0' && *p <= '9') | |
2717 | + || (*p >= 'a' && *p <= 'z') | |
2718 | + || (*p >= 'A' && *p <= 'Z')) | |
2719 | + ++p; | |
2720 | + if (p != namestart) | |
2721 | + { | |
2722 | + struct symbol *cur_sym; | |
2723 | + /* As big as the whole rest of the expression, which is | |
2724 | + at least big enough. */ | |
2725 | + char *ncopy = alloca (strlen (tmp)+strlen (namestart)+3); | |
2726 | + char *tmp1; | |
2727 | + | |
2728 | + tmp1 = ncopy; | |
2729 | + memcpy (tmp1, tmp, strlen (tmp)); | |
2730 | + tmp1 += strlen (tmp); | |
2731 | + memcpy (tmp1, "::", 2); | |
2732 | + tmp1 += 2; | |
2733 | + memcpy (tmp1, namestart, p - namestart); | |
2734 | + tmp1[p - namestart] = '\0'; | |
2735 | + cur_sym = lookup_symbol (ncopy, expression_context_block, | |
2736 | + VAR_NAMESPACE, (int *) NULL, | |
2737 | + (struct symtab **) NULL); | |
2738 | + if (cur_sym) | |
2739 | + { | |
2740 | + if (SYMBOL_CLASS (cur_sym) == LOC_TYPEDEF) | |
2741 | + { | |
2742 | + best_sym = cur_sym; | |
2743 | + lexptr = p; | |
2744 | + } | |
2745 | + else | |
2746 | + break; | |
2747 | + } | |
2748 | + else | |
2749 | + break; | |
2750 | + } | |
2751 | + else | |
2752 | + break; | |
2753 | + } | |
2754 | + else | |
2755 | + break; | |
2756 | + } | |
2757 | + | |
2758 | + yylval.tsym.type = SYMBOL_TYPE (best_sym); | |
2759 | +#else /* not 0 */ | |
2760 | + yylval.tsym.type = SYMBOL_TYPE (sym); | |
2761 | +#endif /* not 0 */ | |
2762 | + return TYPENAME; | |
2763 | + } | |
2764 | + if ((yylval.tsym.type = lookup_primitive_typename (tmp)) != 0) | |
2765 | + return TYPENAME; | |
2766 | + | |
2767 | + /* Input names that aren't symbols but ARE valid hex numbers, | |
2768 | + when the input radix permits them, can be names or numbers | |
2769 | + depending on the parse. Note we support radixes > 16 here. */ | |
2770 | + if (!sym && | |
2771 | + ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) || | |
2772 | + (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10))) | |
2773 | + { | |
2774 | + YYSTYPE newlval; /* Its value is ignored. */ | |
2775 | + hextype = parse_number (tokstart, namelen, 0, &newlval); | |
2776 | + if (hextype == INT) | |
2777 | + { | |
2778 | + yylval.ssym.sym = sym; | |
2779 | + yylval.ssym.is_a_field_of_this = is_a_field_of_this; | |
2780 | + return NAME_OR_INT; | |
2781 | + } | |
2782 | + } | |
2783 | + | |
2784 | + /* Any other kind of symbol */ | |
2785 | + yylval.ssym.sym = sym; | |
2786 | + yylval.ssym.is_a_field_of_this = is_a_field_of_this; | |
2787 | + return NAME; | |
2788 | + } | |
2789 | +} | |
2790 | + | |
2791 | +void | |
2792 | +yyerror (msg) | |
2793 | + char *msg; | |
2794 | +{ | |
2795 | + error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr); | |
2796 | +} |
@@ -0,0 +1,17 @@ | ||
1 | +# gdbwin.o and ser-win32s.c have to be named because they have | |
2 | +# _initialize functions that need to be found by init.c | |
3 | +# gui.ores has to be named, or else msvc won't link it in. | |
4 | +XDEPFILES = \ | |
5 | + mswin/gdbwin.o \ | |
6 | + mswin/ser-win32s.o \ | |
7 | + mswin/gui.ores \ | |
8 | + mswin/libwingdb.a | |
9 | + | |
10 | +$(XDEPFILES): | |
11 | + rootme=`pwd` ; export rootme ; \ | |
12 | + ( cd mswin ; \ | |
13 | + $(MAKE) $(FLAGS_TO_PASS) all ) | |
14 | + | |
15 | +XM_FILE=xm-windows.h | |
16 | +MMALLOC= | |
17 | +SER_HARDWIRE = |
@@ -0,0 +1 @@ | ||
1 | +@set GDBVN 4.18 |
@@ -0,0 +1,230 @@ | ||
1 | +This is Info file ./gdb.info, produced by Makeinfo version 1.68 from | |
2 | +the input file gdb.texinfo. | |
3 | + | |
4 | +START-INFO-DIR-ENTRY | |
5 | +* Gdb: (gdb). The GNU debugger. | |
6 | +END-INFO-DIR-ENTRY | |
7 | + This file documents the GNU debugger GDB. | |
8 | + | |
9 | + This is the Seventh Edition, February 1999, of `Debugging with GDB: | |
10 | +the GNU Source-Level Debugger' for GDB Version 4.18. | |
11 | + | |
12 | + Copyright (C) 1988-1999 Free Software Foundation, Inc. | |
13 | + | |
14 | + Permission is granted to make and distribute verbatim copies of this | |
15 | +manual provided the copyright notice and this permission notice are | |
16 | +preserved on all copies. | |
17 | + | |
18 | + Permission is granted to copy and distribute modified versions of | |
19 | +this manual under the conditions for verbatim copying, provided also | |
20 | +that the entire resulting derived work is distributed under the terms | |
21 | +of a permission notice identical to this one. | |
22 | + | |
23 | + Permission is granted to copy and distribute translations of this | |
24 | +manual into another language, under the above conditions for modified | |
25 | +versions. | |
26 | + | |
27 | + | |
28 | +Indirect: | |
29 | +gdb.info-1: 991 | |
30 | +gdb.info-2: 48295 | |
31 | +gdb.info-3: 96814 | |
32 | +gdb.info-4: 145217 | |
33 | +gdb.info-5: 193677 | |
34 | +gdb.info-6: 235496 | |
35 | +gdb.info-7: 284239 | |
36 | +gdb.info-8: 332485 | |
37 | +gdb.info-9: 381855 | |
38 | +gdb.info-10: 404259 | |
39 | + | |
40 | +Tag Table: | |
41 | +(Indirect) | |
42 | +Node: Top991 | |
43 | +Node: Summary9590 | |
44 | +Node: Free Software11196 | |
45 | +Node: Contributors11950 | |
46 | +Node: Sample Session17994 | |
47 | +Node: Invocation24864 | |
48 | +Node: Invoking GDB25337 | |
49 | +Node: File Options27232 | |
50 | +Node: Mode Options30398 | |
51 | +Node: Quitting GDB32594 | |
52 | +Node: Shell Commands33460 | |
53 | +Node: Commands34202 | |
54 | +Node: Command Syntax34839 | |
55 | +Node: Completion36719 | |
56 | +Node: Help41039 | |
57 | +Node: Running45347 | |
58 | +Node: Compilation46483 | |
59 | +Node: Starting48295 | |
60 | +Node: Arguments51468 | |
61 | +Node: Environment52472 | |
62 | +Node: Working Directory55568 | |
63 | +Node: Input/Output56308 | |
64 | +Node: Attach57913 | |
65 | +Node: Kill Process60341 | |
66 | +Node: Process Information61311 | |
67 | +Node: Threads62643 | |
68 | +Node: Processes67288 | |
69 | +Node: Stopping68520 | |
70 | +Node: Breakpoints69669 | |
71 | +Node: Set Breaks72514 | |
72 | +Node: Set Watchpoints81021 | |
73 | +Node: Set Catchpoints84382 | |
74 | +Node: Delete Breaks87850 | |
75 | +Node: Disabling89517 | |
76 | +Node: Conditions92204 | |
77 | +Node: Break Commands96814 | |
78 | +Node: Breakpoint Menus99690 | |
79 | +Node: Continuing and Stepping101366 | |
80 | +Node: Signals108708 | |
81 | +Node: Thread Stops112376 | |
82 | +Node: Stack115697 | |
83 | +Node: Frames117250 | |
84 | +Node: Backtrace119981 | |
85 | +Node: Selection121713 | |
86 | +Node: Frame Info124449 | |
87 | +Node: Alpha/MIPS Stack126745 | |
88 | +Node: Source127800 | |
89 | +Node: List128749 | |
90 | +Node: Search132289 | |
91 | +Node: Source Path133092 | |
92 | +Node: Machine Code135773 | |
93 | +Node: Data138692 | |
94 | +Node: Expressions140567 | |
95 | +Node: Variables142512 | |
96 | +Node: Arrays145217 | |
97 | +Node: Output Formats147742 | |
98 | +Node: Memory149813 | |
99 | +Node: Auto Display154077 | |
100 | +Node: Print Settings157832 | |
101 | +Node: Value History167759 | |
102 | +Node: Convenience Vars170170 | |
103 | +Node: Registers172953 | |
104 | +Node: Floating Point Hardware177655 | |
105 | +Node: Languages178158 | |
106 | +Node: Setting179262 | |
107 | +Node: Filenames180870 | |
108 | +Node: Manually181624 | |
109 | +Node: Automatically182822 | |
110 | +Node: Show183873 | |
111 | +Node: Checks185171 | |
112 | +Node: Type Checking186527 | |
113 | +Node: Range Checking189239 | |
114 | +Node: Support191580 | |
115 | +Node: C192520 | |
116 | +Node: C Operators193677 | |
117 | +Node: C Constants197758 | |
118 | +Node: Cplus expressions199745 | |
119 | +Node: C Defaults202223 | |
120 | +Node: C Checks202885 | |
121 | +Node: Debugging C203602 | |
122 | +Node: Debugging C plus plus204107 | |
123 | +Node: Modula-2206105 | |
124 | +Node: M2 Operators206992 | |
125 | +Node: Built-In Func/Proc210005 | |
126 | +Node: M2 Constants212744 | |
127 | +Node: M2 Defaults214333 | |
128 | +Node: Deviations214928 | |
129 | +Node: M2 Checks216015 | |
130 | +Node: M2 Scope216815 | |
131 | +Node: GDB/M2217824 | |
132 | +Node: Symbols218763 | |
133 | +Node: Altering225625 | |
134 | +Node: Assignment226593 | |
135 | +Node: Jumping228720 | |
136 | +Node: Signaling230853 | |
137 | +Node: Returning231975 | |
138 | +Node: Calling233167 | |
139 | +Node: Patching233961 | |
140 | +Node: GDB Files235031 | |
141 | +Node: Files235496 | |
142 | +Node: Symbol Errors245168 | |
143 | +Node: Targets248747 | |
144 | +Node: Active Targets249697 | |
145 | +Node: Target Commands251285 | |
146 | +Node: Byte Order259363 | |
147 | +Node: Remote260347 | |
148 | +Node: Remote Serial261803 | |
149 | +Node: Stub Contents264411 | |
150 | +Node: Bootstrapping266512 | |
151 | +Node: Debug Session270308 | |
152 | +Node: Protocol273453 | |
153 | +Node: Server276726 | |
154 | +Node: NetWare280772 | |
155 | +Node: i960-Nindy Remote282734 | |
156 | +Node: Nindy Startup283554 | |
157 | +Node: Nindy Options284239 | |
158 | +Node: Nindy Reset285853 | |
159 | +Node: UDI29K Remote286237 | |
160 | +Node: EB29K Remote287142 | |
161 | +Node: Comms (EB29K)287960 | |
162 | +Node: gdb-EB29K291139 | |
163 | +Node: Remote Log292505 | |
164 | +Node: ST2000 Remote292980 | |
165 | +Node: VxWorks Remote294448 | |
166 | +Node: VxWorks Connection296408 | |
167 | +Node: VxWorks Download297334 | |
168 | +Node: VxWorks Attach299063 | |
169 | +Node: Sparclet Remote299453 | |
170 | +Node: Sparclet File300901 | |
171 | +Node: Sparclet Connection301773 | |
172 | +Node: Sparclet Download302243 | |
173 | +Node: Sparclet Execution303281 | |
174 | +Node: Hitachi Remote303864 | |
175 | +Node: Hitachi Boards304792 | |
176 | +Node: Hitachi ICE305855 | |
177 | +Node: Hitachi Special306643 | |
178 | +Node: MIPS Remote307369 | |
179 | +Node: Simulator311666 | |
180 | +Node: Controlling GDB313222 | |
181 | +Node: Prompt313833 | |
182 | +Node: Editing314631 | |
183 | +Node: History315400 | |
184 | +Node: Screen Size318099 | |
185 | +Node: Numbers319497 | |
186 | +Node: Messages/Warnings320899 | |
187 | +Node: Sequences322907 | |
188 | +Node: Define323487 | |
189 | +Node: Hooks326671 | |
190 | +Node: Command Files328069 | |
191 | +Node: Output330078 | |
192 | +Node: Emacs332485 | |
193 | +Node: GDB Bugs338431 | |
194 | +Node: Bug Criteria339153 | |
195 | +Node: Bug Reporting340040 | |
196 | +Node: Command Line Editing347326 | |
197 | +Node: Introduction and Notation347991 | |
198 | +Node: Readline Interaction349025 | |
199 | +Node: Readline Bare Essentials350213 | |
200 | +Node: Readline Movement Commands351749 | |
201 | +Node: Readline Killing Commands352710 | |
202 | +Node: Readline Arguments354421 | |
203 | +Node: Searching355391 | |
204 | +Node: Readline Init File356969 | |
205 | +Node: Readline Init File Syntax358011 | |
206 | +Node: Conditional Init Constructs366872 | |
207 | +Node: Sample Init File369306 | |
208 | +Node: Bindable Readline Commands372471 | |
209 | +Node: Commands For Moving373217 | |
210 | +Node: Commands For History374060 | |
211 | +Node: Commands For Text376807 | |
212 | +Node: Commands For Killing378588 | |
213 | +Node: Numeric Arguments380733 | |
214 | +Node: Commands For Completion381855 | |
215 | +Node: Keyboard Macros383336 | |
216 | +Node: Miscellaneous Commands383890 | |
217 | +Node: Readline vi Mode386689 | |
218 | +Node: Using History Interactively387532 | |
219 | +Node: History Interaction387887 | |
220 | +Node: Event Designators388839 | |
221 | +Node: Word Designators389484 | |
222 | +Node: Modifiers390392 | |
223 | +Node: Formatting Documentation391062 | |
224 | +Node: Installing GDB394433 | |
225 | +Node: Separate Objdir397915 | |
226 | +Node: Config Names400485 | |
227 | +Node: Configure Options401927 | |
228 | +Node: Index404259 | |
229 | + | |
230 | +End Tag Table |
@@ -0,0 +1,1319 @@ | ||
1 | +This is Info file ./gdb.info, produced by Makeinfo version 1.68 from | |
2 | +the input file gdb.texinfo. | |
3 | + | |
4 | +START-INFO-DIR-ENTRY | |
5 | +* Gdb: (gdb). The GNU debugger. | |
6 | +END-INFO-DIR-ENTRY | |
7 | + This file documents the GNU debugger GDB. | |
8 | + | |
9 | + This is the Seventh Edition, February 1999, of `Debugging with GDB: | |
10 | +the GNU Source-Level Debugger' for GDB Version 4.18. | |
11 | + | |
12 | + Copyright (C) 1988-1999 Free Software Foundation, Inc. | |
13 | + | |
14 | + Permission is granted to make and distribute verbatim copies of this | |
15 | +manual provided the copyright notice and this permission notice are | |
16 | +preserved on all copies. | |
17 | + | |
18 | + Permission is granted to copy and distribute modified versions of | |
19 | +this manual under the conditions for verbatim copying, provided also | |
20 | +that the entire resulting derived work is distributed under the terms | |
21 | +of a permission notice identical to this one. | |
22 | + | |
23 | + Permission is granted to copy and distribute translations of this | |
24 | +manual into another language, under the above conditions for modified | |
25 | +versions. | |
26 | + | |
27 | + | |
28 | +File: gdb.info, Node: Top, Next: Summary, Prev: (dir), Up: (dir) | |
29 | + | |
30 | +Debugging with GDB | |
31 | +****************** | |
32 | + | |
33 | + This file describes GDB, the GNU symbolic debugger. | |
34 | + | |
35 | + This is the Seventh Edition, February 1999, for GDB Version 4.18. | |
36 | + | |
37 | + Copyright (C) 1988-1999 Free Software Foundation, Inc. | |
38 | + | |
39 | +* Menu: | |
40 | + | |
41 | +* Summary:: Summary of GDB | |
42 | + | |
43 | +* Sample Session:: A sample GDB session | |
44 | + | |
45 | +* Invocation:: Getting in and out of GDB | |
46 | +* Commands:: GDB commands | |
47 | +* Running:: Running programs under GDB | |
48 | +* Stopping:: Stopping and continuing | |
49 | +* Stack:: Examining the stack | |
50 | +* Source:: Examining source files | |
51 | +* Data:: Examining data | |
52 | + | |
53 | +* Languages:: Using GDB with different languages | |
54 | + | |
55 | + | |
56 | +* Symbols:: Examining the symbol table | |
57 | +* Altering:: Altering execution | |
58 | +* GDB Files:: GDB files | |
59 | +* Targets:: Specifying a debugging target | |
60 | +* Controlling GDB:: Controlling GDB | |
61 | +* Sequences:: Canned sequences of commands | |
62 | + | |
63 | +* Emacs:: Using GDB under GNU Emacs | |
64 | + | |
65 | +* GDB Bugs:: Reporting bugs in GDB | |
66 | + | |
67 | + | |
68 | + | |
69 | +* Formatting Documentation:: How to format and print GDB documentation | |
70 | + | |
71 | + | |
72 | +* Command Line Editing:: Command Line Editing | |
73 | +* Using History Interactively:: Using History Interactively | |
74 | +* Installing GDB:: Installing GDB | |
75 | +* Index:: Index | |
76 | + | |
77 | + -- The Detailed Node Listing -- | |
78 | + | |
79 | +Summary of GDB | |
80 | + | |
81 | +* Free Software:: Freely redistributable software | |
82 | +* Contributors:: Contributors to GDB | |
83 | + | |
84 | +Getting In and Out of GDB | |
85 | + | |
86 | +* Invoking GDB:: How to start GDB | |
87 | +* Quitting GDB:: How to quit GDB | |
88 | +* Shell Commands:: How to use shell commands inside GDB | |
89 | + | |
90 | +Invoking GDB | |
91 | + | |
92 | +* File Options:: Choosing files | |
93 | +* Mode Options:: Choosing modes | |
94 | + | |
95 | +GDB Commands | |
96 | + | |
97 | +* Command Syntax:: How to give commands to GDB | |
98 | +* Completion:: Command completion | |
99 | +* Help:: How to ask GDB for help | |
100 | + | |
101 | +Running Programs Under GDB | |
102 | + | |
103 | +* Compilation:: Compiling for debugging | |
104 | +* Starting:: Starting your program | |
105 | + | |
106 | +* Arguments:: Your program's arguments | |
107 | +* Environment:: Your program's environment | |
108 | + | |
109 | +* Working Directory:: Your program's working directory | |
110 | +* Input/Output:: Your program's input and output | |
111 | +* Attach:: Debugging an already-running process | |
112 | +* Kill Process:: Killing the child process | |
113 | + | |
114 | +* Process Information:: Additional process information | |
115 | + | |
116 | +* Threads:: Debugging programs with multiple threads | |
117 | +* Processes:: Debugging programs with multiple processes | |
118 | + | |
119 | +Stopping and Continuing | |
120 | + | |
121 | +* Breakpoints:: Breakpoints, watchpoints, and catchpoints | |
122 | +* Continuing and Stepping:: Resuming execution | |
123 | + | |
124 | +* Signals:: Signals | |
125 | + | |
126 | +* Thread Stops:: Stopping and starting multi-thread programs | |
127 | + | |
128 | +Breakpoints and watchpoints | |
129 | + | |
130 | +* Set Breaks:: Setting breakpoints | |
131 | +* Set Watchpoints:: Setting watchpoints | |
132 | +* Set Catchpoints:: Setting catchpoints | |
133 | +* Delete Breaks:: Deleting breakpoints | |
134 | +* Disabling:: Disabling breakpoints | |
135 | +* Conditions:: Break conditions | |
136 | +* Break Commands:: Breakpoint command lists | |
137 | + | |
138 | +* Breakpoint Menus:: Breakpoint menus | |
139 | + | |
140 | +Examining the Stack | |
141 | + | |
142 | +* Frames:: Stack frames | |
143 | +* Backtrace:: Backtraces | |
144 | +* Selection:: Selecting a frame | |
145 | +* Frame Info:: Information on a frame | |
146 | +* Alpha/MIPS Stack:: Alpha and MIPS machines and the function stack | |
147 | + | |
148 | +Examining Source Files | |
149 | + | |
150 | +* List:: Printing source lines | |
151 | + | |
152 | +* Search:: Searching source files | |
153 | +* Source Path:: Specifying source directories | |
154 | +* Machine Code:: Source and machine code | |
155 | + | |
156 | +Examining Data | |
157 | + | |
158 | +* Expressions:: Expressions | |
159 | +* Variables:: Program variables | |
160 | +* Arrays:: Artificial arrays | |
161 | +* Output Formats:: Output formats | |
162 | +* Memory:: Examining memory | |
163 | +* Auto Display:: Automatic display | |
164 | +* Print Settings:: Print settings | |
165 | +* Value History:: Value history | |
166 | +* Convenience Vars:: Convenience variables | |
167 | +* Registers:: Registers | |
168 | + | |
169 | +* Floating Point Hardware:: Floating point hardware | |
170 | + | |
171 | +Using GDB with Different Languages | |
172 | + | |
173 | +* Setting:: Switching between source languages | |
174 | +* Show:: Displaying the language | |
175 | + | |
176 | +* Checks:: Type and range checks | |
177 | + | |
178 | +* Support:: Supported languages | |
179 | + | |
180 | +Switching between source languages | |
181 | + | |
182 | +* Filenames:: Filename extensions and languages. | |
183 | +* Manually:: Setting the working language manually | |
184 | +* Automatically:: Having GDB infer the source language | |
185 | + | |
186 | + | |
187 | +Type and range checking | |
188 | + | |
189 | +* Type Checking:: An overview of type checking | |
190 | +* Range Checking:: An overview of range checking | |
191 | + | |
192 | +Supported languages | |
193 | + | |
194 | + | |
195 | +* C:: C and C++ | |
196 | + | |
197 | +C Language Support | |
198 | + | |
199 | +* C Operators:: C operators | |
200 | + | |
201 | +C Language Support | |
202 | + | |
203 | +* C Operators:: C and C++ operators | |
204 | +* C Constants:: C and C++ constants | |
205 | +* Cplus expressions:: C++ expressions | |
206 | +* C Defaults:: Default settings for C and C++ | |
207 | + | |
208 | +* C Checks:: C and C++ type and range checks | |
209 | +* Debugging C:: GDB and C | |
210 | +* Debugging C plus plus:: GDB features for C++ | |
211 | + | |
212 | + | |
213 | +Modula-2 | |
214 | + | |
215 | +* M2 Operators:: Built-in operators | |
216 | +* Built-In Func/Proc:: Built-in functions and procedures | |
217 | +* M2 Constants:: Modula-2 constants | |
218 | +* M2 Defaults:: Default settings for Modula-2 | |
219 | +* Deviations:: Deviations from standard Modula-2 | |
220 | +* M2 Checks:: Modula-2 type and range checks | |
221 | +* M2 Scope:: The scope operators `::' and `.' | |
222 | +* GDB/M2:: GDB and Modula-2 | |
223 | + | |
224 | +Altering Execution | |
225 | + | |
226 | +* Assignment:: Assignment to variables | |
227 | +* Jumping:: Continuing at a different address | |
228 | + | |
229 | +* Signaling:: Giving your program a signal | |
230 | +* Returning:: Returning from a function | |
231 | +* Calling:: Calling your program's functions | |
232 | +* Patching:: Patching your program | |
233 | + | |
234 | +GDB Files | |
235 | + | |
236 | +* Files:: Commands to specify files | |
237 | +* Symbol Errors:: Errors reading symbol files | |
238 | + | |
239 | +Specifying a Debugging Target | |
240 | + | |
241 | +* Active Targets:: Active targets | |
242 | +* Target Commands:: Commands for managing targets | |
243 | + | |
244 | +* Byte Order:: Choosing target byte order | |
245 | +* Remote:: Remote debugging | |
246 | + | |
247 | +Remote debugging | |
248 | + | |
249 | + | |
250 | +* Remote Serial:: GDB remote serial protocol | |
251 | + | |
252 | + | |
253 | +* i960-Nindy Remote:: GDB with a remote i960 (Nindy) | |
254 | + | |
255 | + | |
256 | +* UDI29K Remote:: The UDI protocol for AMD29K | |
257 | +* EB29K Remote:: The EBMON protocol for AMD29K | |
258 | + | |
259 | + | |
260 | +* VxWorks Remote:: GDB and VxWorks | |
261 | + | |
262 | + | |
263 | +* ST2000 Remote:: GDB with a Tandem ST2000 | |
264 | + | |
265 | + | |
266 | +* Hitachi Remote:: GDB and Hitachi Microprocessors | |
267 | + | |
268 | + | |
269 | +* MIPS Remote:: GDB and MIPS boards | |
270 | + | |
271 | + | |
272 | +* Simulator:: Simulated CPU target | |
273 | + | |
274 | +Controlling GDB | |
275 | + | |
276 | +* Prompt:: Prompt | |
277 | +* Editing:: Command editing | |
278 | +* History:: Command history | |
279 | +* Screen Size:: Screen size | |
280 | +* Numbers:: Numbers | |
281 | +* Messages/Warnings:: Optional warnings and messages | |
282 | + | |
283 | +Canned Sequences of Commands | |
284 | + | |
285 | +* Define:: User-defined commands | |
286 | +* Hooks:: User-defined command hooks | |
287 | +* Command Files:: Command files | |
288 | +* Output:: Commands for controlled output | |
289 | + | |
290 | +Reporting Bugs in GDB | |
291 | + | |
292 | +* Bug Criteria:: Have you found a bug? | |
293 | +* Bug Reporting:: How to report bugs | |
294 | + | |
295 | +Installing GDB | |
296 | + | |
297 | +* Separate Objdir:: Compiling GDB in another directory | |
298 | +* Config Names:: Specifying names for hosts and targets | |
299 | +* Configure Options:: Summary of options for configure | |
300 | + | |
301 | + | |
302 | +File: gdb.info, Node: Summary, Next: Sample Session, Prev: Top, Up: Top | |
303 | + | |
304 | +Summary of GDB | |
305 | +************** | |
306 | + | |
307 | + The purpose of a debugger such as GDB is to allow you to see what is | |
308 | +going on "inside" another program while it executes--or what another | |
309 | +program was doing at the moment it crashed. | |
310 | + | |
311 | + GDB can do four main kinds of things (plus other things in support of | |
312 | +these) to help you catch bugs in the act: | |
313 | + | |
314 | + * Start your program, specifying anything that might affect its | |
315 | + behavior. | |
316 | + | |
317 | + * Make your program stop on specified conditions. | |
318 | + | |
319 | + * Examine what has happened, when your program has stopped. | |
320 | + | |
321 | + * Change things in your program, so you can experiment with | |
322 | + correcting the effects of one bug and go on to learn about another. | |
323 | + | |
324 | + You can use GDB to debug programs written in C or C++. For more | |
325 | +information, see *Note C and C++: C. | |
326 | + | |
327 | + Support for Modula-2 and Chill is partial. For information on | |
328 | +Modula-2, see *Note Modula-2: Modula-2. There is no further | |
329 | +documentation on Chill yet. | |
330 | + | |
331 | + Debugging Pascal programs which use sets, subranges, file variables, | |
332 | +or nested functions does not currently work. GDB does not support | |
333 | +entering expressions, printing values, or similar features using Pascal | |
334 | +syntax. | |
335 | + | |
336 | + GDB can be used to debug programs written in Fortran, although it | |
337 | +does not yet support entering expressions, printing values, or similar | |
338 | +features using Fortran syntax. It may be necessary to refer to some | |
339 | +variables with a trailing underscore. | |
340 | + | |
341 | +* Menu: | |
342 | + | |
343 | +* Free Software:: Freely redistributable software | |
344 | +* Contributors:: Contributors to GDB | |
345 | + | |
346 | + | |
347 | +File: gdb.info, Node: Free Software, Next: Contributors, Prev: Summary, Up: Summary | |
348 | + | |
349 | +Free software | |
350 | +============= | |
351 | + | |
352 | + GDB is "free software", protected by the GNU General Public License | |
353 | +(GPL). The GPL gives you the freedom to copy or adapt a licensed | |
354 | +program--but every person getting a copy also gets with it the freedom | |
355 | +to modify that copy (which means that they must get access to the | |
356 | +source code), and the freedom to distribute further copies. Typical | |
357 | +software companies use copyrights to limit your freedoms; the Free | |
358 | +Software Foundation uses the GPL to preserve these freedoms. | |
359 | + | |
360 | + Fundamentally, the General Public License is a license which says | |
361 | +that you have these freedoms and that you cannot take these freedoms | |
362 | +away from anyone else. | |
363 | + | |
364 | + | |
365 | +File: gdb.info, Node: Contributors, Prev: Free Software, Up: Summary | |
366 | + | |
367 | +Contributors to GDB | |
368 | +=================== | |
369 | + | |
370 | + Richard Stallman was the original author of GDB, and of many other | |
371 | +GNU programs. Many others have contributed to its development. This | |
372 | +section attempts to credit major contributors. One of the virtues of | |
373 | +free software is that everyone is free to contribute to it; with | |
374 | +regret, we cannot actually acknowledge everyone here. The file | |
375 | +`ChangeLog' in the GDB distribution approximates a blow-by-blow account. | |
376 | + | |
377 | + Changes much prior to version 2.0 are lost in the mists of time. | |
378 | + | |
379 | + *Plea:* Additions to this section are particularly welcome. If you | |
380 | + or your friends (or enemies, to be evenhanded) have been unfairly | |
381 | + omitted from this list, we would like to add your names! | |
382 | + | |
383 | + So that they may not regard their many labors as thankless, we | |
384 | +particularly thank those who shepherded GDB through major releases: Jim | |
385 | +Blandy (release 4.18); Jason Molenda (release 4.17); Stan Shebs | |
386 | +(release 4.14); Fred Fish (releases 4.16, 4.15, 4.13, 4.12, 4.11, 4.10, | |
387 | +and 4.9); Stu Grossman and John Gilmore (releases 4.8, 4.7, 4.6, 4.5, | |
388 | +and 4.4); John Gilmore (releases 4.3, 4.2, 4.1, 4.0, and 3.9); Jim | |
389 | +Kingdon (releases 3.5, 3.4, and 3.3); and Randy Smith (releases 3.2, | |
390 | +3.1, and 3.0). | |
391 | + | |
392 | + Richard Stallman, assisted at various times by Peter TerMaat, Chris | |
393 | +Hanson, and Richard Mlynarik, handled releases through 2.8. | |
394 | + | |
395 | + Michael Tiemann is the author of most of the GNU C++ support in GDB, | |
396 | +with significant additional contributions from Per Bothner. James | |
397 | +Clark wrote the GNU C++ demangler. Early work on C++ was by Peter | |
398 | +TerMaat (who also did much general update work leading to release 3.0). | |
399 | + | |
400 | + GDB 4 uses the BFD subroutine library to examine multiple | |
401 | +object-file formats; BFD was a joint project of David V. | |
402 | +Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore. | |
403 | + | |
404 | + David Johnson wrote the original COFF support; Pace Willison did the | |
405 | +original support for encapsulated COFF. | |
406 | + | |
407 | + Brent Benson of Harris Computer Systems contributed DWARF 2 support. | |
408 | + | |
409 | + Adam de Boor and Bradley Davis contributed the ISI Optimum V support. | |
410 | +Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS | |
411 | +support. Jean-Daniel Fekete contributed Sun 386i support. Chris | |
412 | +Hanson improved the HP9000 support. Noboyuki Hikichi and Tomoyuki | |
413 | +Hasei contributed Sony/News OS 3 support. David Johnson contributed | |
414 | +Encore Umax support. Jyrki Kuoppala contributed Altos 3068 support. | |
415 | +Jeff Law contributed HP PA and SOM support. Keith Packard contributed | |
416 | +NS32K support. Doug Rabson contributed Acorn Risc Machine support. | |
417 | +Bob Rusk contributed Harris Nighthawk CX-UX support. Chris Smith | |
418 | +contributed Convex support (and Fortran debugging). Jonathan Stone | |
419 | +contributed Pyramid support. Michael Tiemann contributed SPARC support. | |
420 | +Tim Tucker contributed support for the Gould NP1 and Gould Powernode. | |
421 | +Pace Willison contributed Intel 386 support. Jay Vosburgh contributed | |
422 | +Symmetry support. | |
423 | + | |
424 | + Andreas Schwab contributed M68K Linux support. | |
425 | + | |
426 | + Rich Schaefer and Peter Schauer helped with support of SunOS shared | |
427 | +libraries. | |
428 | + | |
429 | + Jay Fenlason and Roland McGrath ensured that GDB and GAS agree about | |
430 | +several machine instruction sets. | |
431 | + | |
432 | + Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped | |
433 | +develop remote debugging. Intel Corporation, Wind River Systems, AMD, | |
434 | +and ARM contributed remote debugging modules for the i960, VxWorks, | |
435 | +A29K UDI, and RDI targets, respectively. | |
436 | + | |
437 | + Brian Fox is the author of the readline libraries providing | |
438 | +command-line editing and command history. | |
439 | + | |
440 | + Andrew Beers of SUNY Buffalo wrote the language-switching code, the | |
441 | +Modula-2 support, and contributed the Languages chapter of this manual. | |
442 | + | |
443 | + Fred Fish wrote most of the support for Unix System Vr4. He also | |
444 | +enhanced the command-completion support to cover C++ overloaded symbols. | |
445 | + | |
446 | + Hitachi America, Ltd. sponsored the support for H8/300, H8/500, and | |
447 | +Super-H processors. | |
448 | + | |
449 | + NEC sponsored the support for the v850, Vr4xxx, and Vr5xxx | |
450 | +processors. | |
451 | + | |
452 | + Mitsubishi sponsored the support for D10V, D30V, and M32R/D | |
453 | +processors. | |
454 | + | |
455 | + Toshiba sponsored the support for the TX39 Mips processor. | |
456 | + | |
457 | + Matsushita sponsored the support for the MN10200 and MN10300 | |
458 | +processors. | |
459 | + | |
460 | + Fujitsu sponsored the support for SPARClite and FR30 processors | |
461 | + | |
462 | + Kung Hsu, Jeff Law, and Rick Sladkey added support for hardware | |
463 | +watchpoints. | |
464 | + | |
465 | + Michael Snyder added support for tracepoints. | |
466 | + | |
467 | + Stu Grossman wrote gdbserver. | |
468 | + | |
469 | + Jim Kingdon, Peter Schauer, Ian Taylor, and Stu Grossman made nearly | |
470 | +innumerable bug fixes and cleanups throughout GDB. | |
471 | + | |
472 | + The following people at the Hewlett-Packard Company contributed | |
473 | +support for the PA-RISC 2.0 architecture, HP-UX 10.20, 10.30, and 11.0 | |
474 | +(narrow mode), HP's implementation of kernel threads, HP's aC++ | |
475 | +compiler, and the terminal user interface: Ben Krepp, Richard Title, | |
476 | +John Bishop, Susan Macchia, Kathy Mann, Satish Pai, India Paul, Steve | |
477 | +Rehrauer, and Elena Zannoni. Kim Haase provided HP-specific | |
478 | +information in this manual. | |
479 | + | |
480 | + Cygnus Solutions has sponsored GDB maintenance and much of its | |
481 | +development since 1991. Cygnus engineers who have worked on GDB | |
482 | +fulltime include Mark Alexander, Jim Blandy, Per Bothner, Edith Epstein, | |
483 | +Chris Faylor, Fred Fish, Martin Hunt, Jim Ingham, John Gilmore, Stu | |
484 | +Grossman, Kung Hsu, Jim Kingdon, John Metzler, Fernando Nasser, Geoffrey | |
485 | +Noer, Dawn Perchik, Rich Pixley, Zdenek Radouch, Keith Seitz, Stan | |
486 | +Shebs, David Taylor, and Elena Zannoni. In addition, Dave Brolley, Ian | |
487 | +Carmichael, Steve Chamberlain, Nick Clifton, JT Conklin, Stan Cox, DJ | |
488 | +Delorie, Ulrich Drepper, Frank Eigler, Doug Evans, Sean Fagan, David | |
489 | +Henkel-Wallace, Richard Henderson, Jeff Holcomb, Jeff Law, Jim Lemke, | |
490 | +Tom Lord, Bob Manson, Michael Meissner, Jason Merrill, Catherine Moore, | |
491 | +Drew Moseley, Ken Raeburn, Gavin Romig-Koch, Rob Savoye, Jamie Smith, | |
492 | +Mike Stump, Ian Taylor, Angela Thomas, Michael Tiemann, Tom Tromey, Ron | |
493 | +Unrau, Jim Wilson, and David Zuhn have made contributions both large | |
494 | +and small. | |
495 | + | |
496 | + | |
497 | +File: gdb.info, Node: Sample Session, Next: Invocation, Prev: Summary, Up: Top | |
498 | + | |
499 | +A Sample GDB Session | |
500 | +******************** | |
501 | + | |
502 | + You can use this manual at your leisure to read all about GDB. | |
503 | +However, a handful of commands are enough to get started using the | |
504 | +debugger. This chapter illustrates those commands. | |
505 | + | |
506 | + One of the preliminary versions of GNU `m4' (a generic macro | |
507 | +processor) exhibits the following bug: sometimes, when we change its | |
508 | +quote strings from the default, the commands used to capture one macro | |
509 | +definition within another stop working. In the following short `m4' | |
510 | +session, we define a macro `foo' which expands to `0000'; we then use | |
511 | +the `m4' built-in `defn' to define `bar' as the same thing. However, | |
512 | +when we change the open quote string to `<QUOTE>' and the close quote | |
513 | +string to `<UNQUOTE>', the same procedure fails to define a new synonym | |
514 | +`baz': | |
515 | + | |
516 | + $ cd gnu/m4 | |
517 | + $ ./m4 | |
518 | + define(foo,0000) | |
519 | + | |
520 | + foo | |
521 | + 0000 | |
522 | + define(bar,defn(`foo')) | |
523 | + | |
524 | + bar | |
525 | + 0000 | |
526 | + changequote(<QUOTE>,<UNQUOTE>) | |
527 | + | |
528 | + define(baz,defn(<QUOTE>foo<UNQUOTE>)) | |
529 | + baz | |
530 | + C-d | |
531 | + m4: End of input: 0: fatal error: EOF in string | |
532 | + | |
533 | +Let us use GDB to try to see what is going on. | |
534 | + | |
535 | + $ gdb m4 | |
536 | + GDB is free software and you are welcome to distribute copies | |
537 | + of it under certain conditions; type "show copying" to see | |
538 | + the conditions. | |
539 | + There is absolutely no warranty for GDB; type "show warranty" | |
540 | + for details. | |
541 | + | |
542 | + GDB 4.18, Copyright 1999 Free Software Foundation, Inc... | |
543 | + (gdb) | |
544 | + | |
545 | +GDB reads only enough symbol data to know where to find the rest when | |
546 | +needed; as a result, the first prompt comes up very quickly. We now | |
547 | +tell GDB to use a narrower display width than usual, so that examples | |
548 | +fit in this manual. | |
549 | + | |
550 | + (gdb) set width 70 | |
551 | + | |
552 | +We need to see how the `m4' built-in `changequote' works. Having | |
553 | +looked at the source, we know the relevant subroutine is | |
554 | +`m4_changequote', so we set a breakpoint there with the GDB `break' | |
555 | +command. | |
556 | + | |
557 | + (gdb) break m4_changequote | |
558 | + Breakpoint 1 at 0x62f4: file builtin.c, line 879. | |
559 | + | |
560 | +Using the `run' command, we start `m4' running under GDB control; as | |
561 | +long as control does not reach the `m4_changequote' subroutine, the | |
562 | +program runs as usual: | |
563 | + | |
564 | + (gdb) run | |
565 | + Starting program: /work/Editorial/gdb/gnu/m4/m4 | |
566 | + define(foo,0000) | |
567 | + | |
568 | + foo | |
569 | + 0000 | |
570 | + | |
571 | +To trigger the breakpoint, we call `changequote'. GDB suspends | |
572 | +execution of `m4', displaying information about the context where it | |
573 | +stops. | |
574 | + | |
575 | + changequote(<QUOTE>,<UNQUOTE>) | |
576 | + | |
577 | + Breakpoint 1, m4_changequote (argc=3, argv=0x33c70) | |
578 | + at builtin.c:879 | |
579 | + 879 if (bad_argc(TOKEN_DATA_TEXT(argv[0]),argc,1,3)) | |
580 | + | |
581 | +Now we use the command `n' (`next') to advance execution to the next | |
582 | +line of the current function. | |
583 | + | |
584 | + (gdb) n | |
585 | + 882 set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1])\ | |
586 | + : nil, | |
587 | + | |
588 | +`set_quotes' looks like a promising subroutine. We can go into it by | |
589 | +using the command `s' (`step') instead of `next'. `step' goes to the | |
590 | +next line to be executed in *any* subroutine, so it steps into | |
591 | +`set_quotes'. | |
592 | + | |
593 | + (gdb) s | |
594 | + set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>") | |
595 | + at input.c:530 | |
596 | + 530 if (lquote != def_lquote) | |
597 | + | |
598 | +The display that shows the subroutine where `m4' is now suspended (and | |
599 | +its arguments) is called a stack frame display. It shows a summary of | |
600 | +the stack. We can use the `backtrace' command (which can also be | |
601 | +spelled `bt'), to see where we are in the stack as a whole: the | |
602 | +`backtrace' command displays a stack frame for each active subroutine. | |
603 | + | |
604 | + (gdb) bt | |
605 | + #0 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>") | |
606 | + at input.c:530 | |
607 | + #1 0x6344 in m4_changequote (argc=3, argv=0x33c70) | |
608 | + at builtin.c:882 | |
609 | + #2 0x8174 in expand_macro (sym=0x33320) at macro.c:242 | |
610 | + #3 0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30) | |
611 | + at macro.c:71 | |
612 | + #4 0x79dc in expand_input () at macro.c:40 | |
613 | + #5 0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195 | |
614 | + | |
615 | +We step through a few more lines to see what happens. The first two | |
616 | +times, we can use `s'; the next two times we use `n' to avoid falling | |
617 | +into the `xstrdup' subroutine. | |
618 | + | |
619 | + (gdb) s | |
620 | + 0x3b5c 532 if (rquote != def_rquote) | |
621 | + (gdb) s | |
622 | + 0x3b80 535 lquote = (lq == nil || *lq == '\0') ? \ | |
623 | + def_lquote : xstrdup(lq); | |
624 | + (gdb) n | |
625 | + 536 rquote = (rq == nil || *rq == '\0') ? def_rquote\ | |
626 | + : xstrdup(rq); | |
627 | + (gdb) n | |
628 | + 538 len_lquote = strlen(rquote); | |
629 | + | |
630 | +The last line displayed looks a little odd; we can examine the variables | |
631 | +`lquote' and `rquote' to see if they are in fact the new left and right | |
632 | +quotes we specified. We use the command `p' (`print') to see their | |
633 | +values. | |
634 | + | |
635 | + (gdb) p lquote | |
636 | + $1 = 0x35d40 "<QUOTE>" | |
637 | + (gdb) p rquote | |
638 | + $2 = 0x35d50 "<UNQUOTE>" | |
639 | + | |
640 | +`lquote' and `rquote' are indeed the new left and right quotes. To | |
641 | +look at some context, we can display ten lines of source surrounding | |
642 | +the current line with the `l' (`list') command. | |
643 | + | |
644 | + (gdb) l | |
645 | + 533 xfree(rquote); | |
646 | + 534 | |
647 | + 535 lquote = (lq == nil || *lq == '\0') ? def_lquote\ | |
648 | + : xstrdup (lq); | |
649 | + 536 rquote = (rq == nil || *rq == '\0') ? def_rquote\ | |
650 | + : xstrdup (rq); | |
651 | + 537 | |
652 | + 538 len_lquote = strlen(rquote); | |
653 | + 539 len_rquote = strlen(lquote); | |
654 | + 540 } | |
655 | + 541 | |
656 | + 542 void | |
657 | + | |
658 | +Let us step past the two lines that set `len_lquote' and `len_rquote', | |
659 | +and then examine the values of those variables. | |
660 | + | |
661 | + (gdb) n | |
662 | + 539 len_rquote = strlen(lquote); | |
663 | + (gdb) n | |
664 | + 540 } | |
665 | + (gdb) p len_lquote | |
666 | + $3 = 9 | |
667 | + (gdb) p len_rquote | |
668 | + $4 = 7 | |
669 | + | |
670 | +That certainly looks wrong, assuming `len_lquote' and `len_rquote' are | |
671 | +meant to be the lengths of `lquote' and `rquote' respectively. We can | |
672 | +set them to better values using the `p' command, since it can print the | |
673 | +value of any expression--and that expression can include subroutine | |
674 | +calls and assignments. | |
675 | + | |
676 | + (gdb) p len_lquote=strlen(lquote) | |
677 | + $5 = 7 | |
678 | + (gdb) p len_rquote=strlen(rquote) | |
679 | + $6 = 9 | |
680 | + | |
681 | +Is that enough to fix the problem of using the new quotes with the `m4' | |
682 | +built-in `defn'? We can allow `m4' to continue executing with the `c' | |
683 | +(`continue') command, and then try the example that caused trouble | |
684 | +initially: | |
685 | + | |
686 | + (gdb) c | |
687 | + Continuing. | |
688 | + | |
689 | + define(baz,defn(<QUOTE>foo<UNQUOTE>)) | |
690 | + | |
691 | + baz | |
692 | + 0000 | |
693 | + | |
694 | +Success! The new quotes now work just as well as the default ones. The | |
695 | +problem seems to have been just the two typos defining the wrong | |
696 | +lengths. We allow `m4' exit by giving it an EOF as input: | |
697 | + | |
698 | + C-d | |
699 | + Program exited normally. | |
700 | + | |
701 | +The message `Program exited normally.' is from GDB; it indicates `m4' | |
702 | +has finished executing. We can end our GDB session with the GDB `quit' | |
703 | +command. | |
704 | + | |
705 | + (gdb) quit | |
706 | + | |
707 | + | |
708 | +File: gdb.info, Node: Invocation, Next: Commands, Prev: Sample Session, Up: Top | |
709 | + | |
710 | +Getting In and Out of GDB | |
711 | +************************* | |
712 | + | |
713 | + This chapter discusses how to start GDB, and how to get out of it. | |
714 | +The essentials are: | |
715 | + * type `gdb' to start GDB. | |
716 | + | |
717 | + * type `quit' or `C-d' to exit. | |
718 | + | |
719 | +* Menu: | |
720 | + | |
721 | +* Invoking GDB:: How to start GDB | |
722 | +* Quitting GDB:: How to quit GDB | |
723 | +* Shell Commands:: How to use shell commands inside GDB | |
724 | + | |
725 | + | |
726 | +File: gdb.info, Node: Invoking GDB, Next: Quitting GDB, Prev: Invocation, Up: Invocation | |
727 | + | |
728 | +Invoking GDB | |
729 | +============ | |
730 | + | |
731 | + Invoke GDB by running the program `gdb'. Once started, GDB reads | |
732 | +commands from the terminal until you tell it to exit. | |
733 | + | |
734 | + You can also run `gdb' with a variety of arguments and options, to | |
735 | +specify more of your debugging environment at the outset. | |
736 | + | |
737 | + The command-line options described here are designed to cover a | |
738 | +variety of situations; in some environments, some of these options may | |
739 | +effectively be unavailable. | |
740 | + | |
741 | + The most usual way to start GDB is with one argument, specifying an | |
742 | +executable program: | |
743 | + | |
744 | + gdb PROGRAM | |
745 | + | |
746 | +You can also start with both an executable program and a core file | |
747 | +specified: | |
748 | + | |
749 | + gdb PROGRAM CORE | |
750 | + | |
751 | + You can, instead, specify a process ID as a second argument, if you | |
752 | +want to debug a running process: | |
753 | + | |
754 | + gdb PROGRAM 1234 | |
755 | + | |
756 | +would attach GDB to process `1234' (unless you also have a file named | |
757 | +`1234'; GDB does check for a core file first). | |
758 | + | |
759 | + Taking advantage of the second command-line argument requires a | |
760 | +fairly complete operating system; when you use GDB as a remote debugger | |
761 | +attached to a bare board, there may not be any notion of "process", and | |
762 | +there is often no way to get a core dump. | |
763 | + | |
764 | + You can run `gdb' without printing the front material, which | |
765 | +describes GDB's non-warranty, by specifying `-silent': | |
766 | + | |
767 | + gdb -silent | |
768 | + | |
769 | +You can further control how GDB starts up by using command-line | |
770 | +options. GDB itself can remind you of the options available. | |
771 | + | |
772 | +Type | |
773 | + | |
774 | + gdb -help | |
775 | + | |
776 | +to display all available options and briefly describe their use (`gdb | |
777 | +-h' is a shorter equivalent). | |
778 | + | |
779 | + All options and command line arguments you give are processed in | |
780 | +sequential order. The order makes a difference when the `-x' option is | |
781 | +used. | |
782 | + | |
783 | +* Menu: | |
784 | + | |
785 | + | |
786 | +* File Options:: Choosing files | |
787 | +* Mode Options:: Choosing modes | |
788 | + | |
789 | + | |
790 | +File: gdb.info, Node: File Options, Next: Mode Options, Up: Invoking GDB | |
791 | + | |
792 | +Choosing files | |
793 | +-------------- | |
794 | + | |
795 | + When GDB starts, it reads any arguments other than options as | |
796 | +specifying an executable file and core file (or process ID). This is | |
797 | +the same as if the arguments were specified by the `-se' and `-c' | |
798 | +options respectively. (GDB reads the first argument that does not have | |
799 | +an associated option flag as equivalent to the `-se' option followed by | |
800 | +that argument; and the second argument that does not have an associated | |
801 | +option flag, if any, as equivalent to the `-c' option followed by that | |
802 | +argument.) | |
803 | + | |
804 | + Many options have both long and short forms; both are shown in the | |
805 | +following list. GDB also recognizes the long forms if you truncate | |
806 | +them, so long as enough of the option is present to be unambiguous. | |
807 | +(If you prefer, you can flag option arguments with `--' rather than | |
808 | +`-', though we illustrate the more usual convention.) | |
809 | + | |
810 | +`-symbols FILE' | |
811 | +`-s FILE' | |
812 | + Read symbol table from file FILE. | |
813 | + | |
814 | +`-exec FILE' | |
815 | +`-e FILE' | |
816 | + Use file FILE as the executable file to execute when appropriate, | |
817 | + and for examining pure data in conjunction with a core dump. | |
818 | + | |
819 | +`-se FILE' | |
820 | + Read symbol table from file FILE and use it as the executable file. | |
821 | + | |
822 | +`-core FILE' | |
823 | +`-c FILE' | |
824 | + Use file FILE as a core dump to examine. | |
825 | + | |
826 | +`-c NUMBER' | |
827 | + Connect to process ID NUMBER, as with the `attach' command (unless | |
828 | + there is a file in core-dump format named NUMBER, in which case | |
829 | + `-c' specifies that file as a core dump to read). | |
830 | + | |
831 | +`-command FILE' | |
832 | +`-x FILE' | |
833 | + Execute GDB commands from file FILE. *Note Command files: Command | |
834 | + Files. | |
835 | + | |
836 | +`-directory DIRECTORY' | |
837 | +`-d DIRECTORY' | |
838 | + Add DIRECTORY to the path to search for source files. | |
839 | + | |
840 | +`-m' | |
841 | +`-mapped' | |
842 | + *Warning: this option depends on operating system facilities that | |
843 | + are not supported on all systems.* | |
844 | + If memory-mapped files are available on your system through the | |
845 | + `mmap' system call, you can use this option to have GDB write the | |
846 | + symbols from your program into a reusable file in the current | |
847 | + directory. If the program you are debugging is called | |
848 | + `/tmp/fred', the mapped symbol file is `./fred.syms'. Future GDB | |
849 | + debugging sessions notice the presence of this file, and can | |
850 | + quickly map in symbol information from it, rather than reading the | |
851 | + symbol table from the executable program. | |
852 | + | |
853 | + The `.syms' file is specific to the host machine where GDB is run. | |
854 | + It holds an exact image of the internal GDB symbol table. It | |
855 | + cannot be shared across multiple host platforms. | |
856 | + | |
857 | +`-r' | |
858 | +`-readnow' | |
859 | + Read each symbol file's entire symbol table immediately, rather | |
860 | + than the default, which is to read it incrementally as it is | |
861 | + needed. This makes startup slower, but makes future operations | |
862 | + faster. | |
863 | + | |
864 | + The `-mapped' and `-readnow' options are typically combined in order | |
865 | +to build a `.syms' file that contains complete symbol information. | |
866 | +(*Note Commands to specify files: Files, for information on `.syms' | |
867 | +files.) A simple GDB invocation to do nothing but build a `.syms' file | |
868 | +for future use is: | |
869 | + | |
870 | + gdb -batch -nx -mapped -readnow programname | |
871 | + | |
872 | + | |
873 | +File: gdb.info, Node: Mode Options, Prev: File Options, Up: Invoking GDB | |
874 | + | |
875 | +Choosing modes | |
876 | +-------------- | |
877 | + | |
878 | + You can run GDB in various alternative modes--for example, in batch | |
879 | +mode or quiet mode. | |
880 | + | |
881 | +`-nx' | |
882 | +`-n' | |
883 | + Do not execute commands from any initialization files (normally | |
884 | + called `.gdbinit', or `gdb.ini' on PCs). Normally, the commands in | |
885 | + these files are executed after all the command options and | |
886 | + arguments have been processed. *Note Command files: Command Files. | |
887 | + | |
888 | +`-quiet' | |
889 | +`-q' | |
890 | + "Quiet". Do not print the introductory and copyright messages. | |
891 | + These messages are also suppressed in batch mode. | |
892 | + | |
893 | +`-batch' | |
894 | + Run in batch mode. Exit with status `0' after processing all the | |
895 | + command files specified with `-x' (and all commands from | |
896 | + initialization files, if not inhibited with `-n'). Exit with | |
897 | + nonzero status if an error occurs in executing the GDB commands in | |
898 | + the command files. | |
899 | + | |
900 | + Batch mode may be useful for running GDB as a filter, for example | |
901 | + to download and run a program on another computer; in order to | |
902 | + make this more useful, the message | |
903 | + | |
904 | + Program exited normally. | |
905 | + | |
906 | + (which is ordinarily issued whenever a program running under GDB | |
907 | + control terminates) is not issued when running in batch mode. | |
908 | + | |
909 | +`-cd DIRECTORY' | |
910 | + Run GDB using DIRECTORY as its working directory, instead of the | |
911 | + current directory. | |
912 | + | |
913 | +`-fullname' | |
914 | +`-f' | |
915 | + GNU Emacs sets this option when it runs GDB as a subprocess. It | |
916 | + tells GDB to output the full file name and line number in a | |
917 | + standard, recognizable fashion each time a stack frame is | |
918 | + displayed (which includes each time your program stops). This | |
919 | + recognizable format looks like two `\032' characters, followed by | |
920 | + the file name, line number and character position separated by | |
921 | + colons, and a newline. The Emacs-to-GDB interface program uses | |
922 | + the two `\032' characters as a signal to display the source code | |
923 | + for the frame. | |
924 | + | |
925 | +`-b BPS' | |
926 | + Set the line speed (baud rate or bits per second) of any serial | |
927 | + interface used by GDB for remote debugging. | |
928 | + | |
929 | +`-tty DEVICE' | |
930 | + Run using DEVICE for your program's standard input and output. | |
931 | + | |
932 | + | |
933 | +File: gdb.info, Node: Quitting GDB, Next: Shell Commands, Prev: Invoking GDB, Up: Invocation | |
934 | + | |
935 | +Quitting GDB | |
936 | +============ | |
937 | + | |
938 | +`quit' | |
939 | + To exit GDB, use the `quit' command (abbreviated `q'), or type an | |
940 | + end-of-file character (usually `C-d'). If you do not supply | |
941 | + EXPRESSION, GDB will terminate normally; otherwise it will | |
942 | + terminate using the result of EXPRESSION as the error code. | |
943 | + | |
944 | + An interrupt (often `C-c') does not exit from GDB, but rather | |
945 | +terminates the action of any GDB command that is in progress and | |
946 | +returns to GDB command level. It is safe to type the interrupt | |
947 | +character at any time because GDB does not allow it to take effect | |
948 | +until a time when it is safe. | |
949 | + | |
950 | + If you have been using GDB to control an attached process or device, | |
951 | +you can release it with the `detach' command (*note Debugging an | |
952 | +already-running process: Attach.). | |
953 | + | |
954 | + | |
955 | +File: gdb.info, Node: Shell Commands, Prev: Quitting GDB, Up: Invocation | |
956 | + | |
957 | +Shell commands | |
958 | +============== | |
959 | + | |
960 | + If you need to execute occasional shell commands during your | |
961 | +debugging session, there is no need to leave or suspend GDB; you can | |
962 | +just use the `shell' command. | |
963 | + | |
964 | +`shell COMMAND STRING' | |
965 | + Invoke a standard shell to execute COMMAND STRING. If it exists, | |
966 | + the environment variable `SHELL' determines which shell to run. | |
967 | + Otherwise GDB uses `/bin/sh'. | |
968 | + | |
969 | + The utility `make' is often needed in development environments. You | |
970 | +do not have to use the `shell' command for this purpose in GDB: | |
971 | + | |
972 | +`make MAKE-ARGS' | |
973 | + Execute the `make' program with the specified arguments. This is | |
974 | + equivalent to `shell make MAKE-ARGS'. | |
975 | + | |
976 | + | |
977 | +File: gdb.info, Node: Commands, Next: Running, Prev: Invocation, Up: Top | |
978 | + | |
979 | +GDB Commands | |
980 | +************ | |
981 | + | |
982 | + You can abbreviate a GDB command to the first few letters of the | |
983 | +command name, if that abbreviation is unambiguous; and you can repeat | |
984 | +certain GDB commands by typing just <RET>. You can also use the <TAB> | |
985 | +key to get GDB to fill out the rest of a word in a command (or to show | |
986 | +you the alternatives available, if there is more than one possibility). | |
987 | + | |
988 | +* Menu: | |
989 | + | |
990 | +* Command Syntax:: How to give commands to GDB | |
991 | +* Completion:: Command completion | |
992 | +* Help:: How to ask GDB for help | |
993 | + | |
994 | + | |
995 | +File: gdb.info, Node: Command Syntax, Next: Completion, Prev: Commands, Up: Commands | |
996 | + | |
997 | +Command syntax | |
998 | +============== | |
999 | + | |
1000 | + A GDB command is a single line of input. There is no limit on how | |
1001 | +long it can be. It starts with a command name, which is followed by | |
1002 | +arguments whose meaning depends on the command name. For example, the | |
1003 | +command `step' accepts an argument which is the number of times to | |
1004 | +step, as in `step 5'. You can also use the `step' command with no | |
1005 | +arguments. Some command names do not allow any arguments. | |
1006 | + | |
1007 | + GDB command names may always be truncated if that abbreviation is | |
1008 | +unambiguous. Other possible command abbreviations are listed in the | |
1009 | +documentation for individual commands. In some cases, even ambiguous | |
1010 | +abbreviations are allowed; for example, `s' is specially defined as | |
1011 | +equivalent to `step' even though there are other commands whose names | |
1012 | +start with `s'. You can test abbreviations by using them as arguments | |
1013 | +to the `help' command. | |
1014 | + | |
1015 | + A blank line as input to GDB (typing just <RET>) means to repeat the | |
1016 | +previous command. Certain commands (for example, `run') will not repeat | |
1017 | +this way; these are commands whose unintentional repetition might cause | |
1018 | +trouble and which you are unlikely to want to repeat. | |
1019 | + | |
1020 | + The `list' and `x' commands, when you repeat them with <RET>, | |
1021 | +construct new arguments rather than repeating exactly as typed. This | |
1022 | +permits easy scanning of source or memory. | |
1023 | + | |
1024 | + GDB can also use <RET> in another way: to partition lengthy output, | |
1025 | +in a way similar to the common utility `more' (*note Screen size: | |
1026 | +Screen Size.). Since it is easy to press one <RET> too many in this | |
1027 | +situation, GDB disables command repetition after any command that | |
1028 | +generates this sort of display. | |
1029 | + | |
1030 | + Any text from a `#' to the end of the line is a comment; it does | |
1031 | +nothing. This is useful mainly in command files (*note Command files: | |
1032 | +Command Files.). | |
1033 | + | |
1034 | + | |
1035 | +File: gdb.info, Node: Completion, Next: Help, Prev: Command Syntax, Up: Commands | |
1036 | + | |
1037 | +Command completion | |
1038 | +================== | |
1039 | + | |
1040 | + GDB can fill in the rest of a word in a command for you, if there is | |
1041 | +only one possibility; it can also show you what the valid possibilities | |
1042 | +are for the next word in a command, at any time. This works for GDB | |
1043 | +commands, GDB subcommands, and the names of symbols in your program. | |
1044 | + | |
1045 | + Press the <TAB> key whenever you want GDB to fill out the rest of a | |
1046 | +word. If there is only one possibility, GDB fills in the word, and | |
1047 | +waits for you to finish the command (or press <RET> to enter it). For | |
1048 | +example, if you type | |
1049 | + | |
1050 | + (gdb) info bre <TAB> | |
1051 | + | |
1052 | +GDB fills in the rest of the word `breakpoints', since that is the only | |
1053 | +`info' subcommand beginning with `bre': | |
1054 | + | |
1055 | + (gdb) info breakpoints | |
1056 | + | |
1057 | +You can either press <RET> at this point, to run the `info breakpoints' | |
1058 | +command, or backspace and enter something else, if `breakpoints' does | |
1059 | +not look like the command you expected. (If you were sure you wanted | |
1060 | +`info breakpoints' in the first place, you might as well just type | |
1061 | +<RET> immediately after `info bre', to exploit command abbreviations | |
1062 | +rather than command completion). | |
1063 | + | |
1064 | + If there is more than one possibility for the next word when you | |
1065 | +press <TAB>, GDB sounds a bell. You can either supply more characters | |
1066 | +and try again, or just press <TAB> a second time; GDB displays all the | |
1067 | +possible completions for that word. For example, you might want to set | |
1068 | +a breakpoint on a subroutine whose name begins with `make_', but when | |
1069 | +you type `b make_<TAB>' GDB just sounds the bell. Typing <TAB> again | |
1070 | +displays all the function names in your program that begin with those | |
1071 | +characters, for example: | |
1072 | + | |
1073 | + (gdb) b make_ <TAB> | |
1074 | +GDB sounds bell; press <TAB> again, to see: | |
1075 | + make_a_section_from_file make_environ | |
1076 | + make_abs_section make_function_type | |
1077 | + make_blockvector make_pointer_type | |
1078 | + make_cleanup make_reference_type | |
1079 | + make_command make_symbol_completion_list | |
1080 | + (gdb) b make_ | |
1081 | + | |
1082 | +After displaying the available possibilities, GDB copies your partial | |
1083 | +input (`b make_' in the example) so you can finish the command. | |
1084 | + | |
1085 | + If you just want to see the list of alternatives in the first place, | |
1086 | +you can press `M-?' rather than pressing <TAB> twice. `M-?' means | |
1087 | +`<META> ?'. You can type this either by holding down a key designated | |
1088 | +as the <META> shift on your keyboard (if there is one) while typing | |
1089 | +`?', or as <ESC> followed by `?'. | |
1090 | + | |
1091 | + Sometimes the string you need, while logically a "word", may contain | |
1092 | +parentheses or other characters that GDB normally excludes from its | |
1093 | +notion of a word. To permit word completion to work in this situation, | |
1094 | +you may enclose words in `'' (single quote marks) in GDB commands. | |
1095 | + | |
1096 | + The most likely situation where you might need this is in typing the | |
1097 | +name of a C++ function. This is because C++ allows function overloading | |
1098 | +(multiple definitions of the same function, distinguished by argument | |
1099 | +type). For example, when you want to set a breakpoint you may need to | |
1100 | +distinguish whether you mean the version of `name' that takes an `int' | |
1101 | +parameter, `name(int)', or the version that takes a `float' parameter, | |
1102 | +`name(float)'. To use the word-completion facilities in this | |
1103 | +situation, type a single quote `'' at the beginning of the function | |
1104 | +name. This alerts GDB that it may need to consider more information | |
1105 | +than usual when you press <TAB> or `M-?' to request word completion: | |
1106 | + | |
1107 | + (gdb) b 'bubble( <M-?> | |
1108 | + bubble(double,double) bubble(int,int) | |
1109 | + (gdb) b 'bubble( | |
1110 | + | |
1111 | + In some cases, GDB can tell that completing a name requires using | |
1112 | +quotes. When this happens, GDB inserts the quote for you (while | |
1113 | +completing as much as it can) if you do not type the quote in the first | |
1114 | +place: | |
1115 | + | |
1116 | + (gdb) b bub <TAB> | |
1117 | +GDB alters your input line to the following, and rings a bell: | |
1118 | + (gdb) b 'bubble( | |
1119 | + | |
1120 | +In general, GDB can tell that a quote is needed (and inserts it) if you | |
1121 | +have not yet started typing the argument list when you ask for | |
1122 | +completion on an overloaded symbol. | |
1123 | + | |
1124 | + For more information about overloaded functions, *note C++ | |
1125 | +expressions: Cplus expressions.. You can use the command `set | |
1126 | +overload-resolution off' to disable overload resolution; *note GDB | |
1127 | +features for C++: Debugging C plus plus.. | |
1128 | + | |
1129 | + | |
1130 | +File: gdb.info, Node: Help, Prev: Completion, Up: Commands | |
1131 | + | |
1132 | +Getting help | |
1133 | +============ | |
1134 | + | |
1135 | + You can always ask GDB itself for information on its commands, using | |
1136 | +the command `help'. | |
1137 | + | |
1138 | +`help' | |
1139 | +`h' | |
1140 | + You can use `help' (abbreviated `h') with no arguments to display | |
1141 | + a short list of named classes of commands: | |
1142 | + | |
1143 | + (gdb) help | |
1144 | + List of classes of commands: | |
1145 | + | |
1146 | + running -- Running the program | |
1147 | + stack -- Examining the stack | |
1148 | + data -- Examining data | |
1149 | + breakpoints -- Making program stop at certain points | |
1150 | + files -- Specifying and examining files | |
1151 | + status -- Status inquiries | |
1152 | + support -- Support facilities | |
1153 | + user-defined -- User-defined commands | |
1154 | + aliases -- Aliases of other commands | |
1155 | + obscure -- Obscure features | |
1156 | + | |
1157 | + Type "help" followed by a class name for a list of | |
1158 | + commands in that class. | |
1159 | + Type "help" followed by command name for full | |
1160 | + documentation. | |
1161 | + Command name abbreviations are allowed if unambiguous. | |
1162 | + (gdb) | |
1163 | + | |
1164 | +`help CLASS' | |
1165 | + Using one of the general help classes as an argument, you can get a | |
1166 | + list of the individual commands in that class. For example, here | |
1167 | + is the help display for the class `status': | |
1168 | + | |
1169 | + (gdb) help status | |
1170 | + Status inquiries. | |
1171 | + | |
1172 | + List of commands: | |
1173 | + | |
1174 | + show -- Generic command for showing things set | |
1175 | + with "set" | |
1176 | + info -- Generic command for printing status | |
1177 | + | |
1178 | + Type "help" followed by command name for full | |
1179 | + documentation. | |
1180 | + Command name abbreviations are allowed if unambiguous. | |
1181 | + (gdb) | |
1182 | + | |
1183 | +`help COMMAND' | |
1184 | + With a command name as `help' argument, GDB displays a short | |
1185 | + paragraph on how to use that command. | |
1186 | + | |
1187 | +`complete ARGS' | |
1188 | + The `complete ARGS' command lists all the possible completions for | |
1189 | + the beginning of a command. Use ARGS to specify the beginning of | |
1190 | + the command you want completed. For example: | |
1191 | + | |
1192 | + complete i | |
1193 | + | |
1194 | + results in: | |
1195 | + | |
1196 | + info | |
1197 | + inspect | |
1198 | + ignore | |
1199 | + | |
1200 | + This is intended for use by GNU Emacs. | |
1201 | + | |
1202 | + In addition to `help', you can use the GDB commands `info' and | |
1203 | +`show' to inquire about the state of your program, or the state of GDB | |
1204 | +itself. Each command supports many topics of inquiry; this manual | |
1205 | +introduces each of them in the appropriate context. The listings under | |
1206 | +`info' and under `show' in the Index point to all the sub-commands. | |
1207 | +*Note Index::. | |
1208 | + | |
1209 | +`info' | |
1210 | + This command (abbreviated `i') is for describing the state of your | |
1211 | + program. For example, you can list the arguments given to your | |
1212 | + program with `info args', list the registers currently in use with | |
1213 | + `info registers', or list the breakpoints you have set with `info | |
1214 | + breakpoints'. You can get a complete list of the `info' | |
1215 | + sub-commands with `help info'. | |
1216 | + | |
1217 | +`set' | |
1218 | + You can assign the result of an expression to an environment | |
1219 | + variable with `set'. For example, you can set the GDB prompt to a | |
1220 | + $-sign with `set prompt $'. | |
1221 | + | |
1222 | +`show' | |
1223 | + In contrast to `info', `show' is for describing the state of GDB | |
1224 | + itself. You can change most of the things you can `show', by | |
1225 | + using the related command `set'; for example, you can control what | |
1226 | + number system is used for displays with `set radix', or simply | |
1227 | + inquire which is currently in use with `show radix'. | |
1228 | + | |
1229 | + To display all the settable parameters and their current values, | |
1230 | + you can use `show' with no arguments; you may also use `info set'. | |
1231 | + Both commands produce the same display. | |
1232 | + | |
1233 | + Here are three miscellaneous `show' subcommands, all of which are | |
1234 | +exceptional in lacking corresponding `set' commands: | |
1235 | + | |
1236 | +`show version' | |
1237 | + Show what version of GDB is running. You should include this | |
1238 | + information in GDB bug-reports. If multiple versions of GDB are in | |
1239 | + use at your site, you may occasionally want to determine which | |
1240 | + version of GDB you are running; as GDB evolves, new commands are | |
1241 | + introduced, and old ones may wither away. The version number is | |
1242 | + also announced when you start GDB. | |
1243 | + | |
1244 | +`show copying' | |
1245 | + Display information about permission for copying GDB. | |
1246 | + | |
1247 | +`show warranty' | |
1248 | + Display the GNU "NO WARRANTY" statement. | |
1249 | + | |
1250 | + | |
1251 | +File: gdb.info, Node: Running, Next: Stopping, Prev: Commands, Up: Top | |
1252 | + | |
1253 | +Running Programs Under GDB | |
1254 | +************************** | |
1255 | + | |
1256 | + When you run a program under GDB, you must first generate debugging | |
1257 | +information when you compile it. You may start GDB with its arguments, | |
1258 | +if any, in an environment of your choice. You may redirect your | |
1259 | +program's input and output, debug an already running process, or kill a | |
1260 | +child process. | |
1261 | + | |
1262 | +* Menu: | |
1263 | + | |
1264 | +* Compilation:: Compiling for debugging | |
1265 | +* Starting:: Starting your program | |
1266 | + | |
1267 | +* Arguments:: Your program's arguments | |
1268 | +* Environment:: Your program's environment | |
1269 | + | |
1270 | +* Working Directory:: Your program's working directory | |
1271 | +* Input/Output:: Your program's input and output | |
1272 | +* Attach:: Debugging an already-running process | |
1273 | +* Kill Process:: Killing the child process | |
1274 | + | |
1275 | +* Process Information:: Additional process information | |
1276 | + | |
1277 | +* Threads:: Debugging programs with multiple threads | |
1278 | +* Processes:: Debugging programs with multiple processes | |
1279 | + | |
1280 | + | |
1281 | +File: gdb.info, Node: Compilation, Next: Starting, Prev: Running, Up: Running | |
1282 | + | |
1283 | +Compiling for debugging | |
1284 | +======================= | |
1285 | + | |
1286 | + In order to debug a program effectively, you need to generate | |
1287 | +debugging information when you compile it. This debugging information | |
1288 | +is stored in the object file; it describes the data type of each | |
1289 | +variable or function and the correspondence between source line numbers | |
1290 | +and addresses in the executable code. | |
1291 | + | |
1292 | + To request debugging information, specify the `-g' option when you | |
1293 | +run the compiler. | |
1294 | + | |
1295 | + Many C compilers are unable to handle the `-g' and `-O' options | |
1296 | +together. Using those compilers, you cannot generate optimized | |
1297 | +executables containing debugging information. | |
1298 | + | |
1299 | + GCC, the GNU C compiler, supports `-g' with or without `-O', making | |
1300 | +it possible to debug optimized code. We recommend that you *always* | |
1301 | +use `-g' whenever you compile a program. You may think your program is | |
1302 | +correct, but there is no sense in pushing your luck. | |
1303 | + | |
1304 | + When you debug a program compiled with `-g -O', remember that the | |
1305 | +optimizer is rearranging your code; the debugger shows you what is | |
1306 | +really there. Do not be too surprised when the execution path does not | |
1307 | +exactly match your source file! An extreme example: if you define a | |
1308 | +variable, but never use it, GDB never sees that variable--because the | |
1309 | +compiler optimizes it out of existence. | |
1310 | + | |
1311 | + Some things do not work as well with `-g -O' as with just `-g', | |
1312 | +particularly on machines with instruction scheduling. If in doubt, | |
1313 | +recompile with `-g' alone, and if this fixes the problem, please report | |
1314 | +it to us as a bug (including a test case!). | |
1315 | + | |
1316 | + Older versions of the GNU C compiler permitted a variant option | |
1317 | +`-gg' for debugging information. GDB no longer supports this format; | |
1318 | +if your GNU C compiler has this option, do not use it. | |
1319 | + |
@@ -0,0 +1,775 @@ | ||
1 | +This is Info file ./gdb.info, produced by Makeinfo version 1.68 from | |
2 | +the input file gdb.texinfo. | |
3 | + | |
4 | +START-INFO-DIR-ENTRY | |
5 | +* Gdb: (gdb). The GNU debugger. | |
6 | +END-INFO-DIR-ENTRY | |
7 | + This file documents the GNU debugger GDB. | |
8 | + | |
9 | + This is the Seventh Edition, February 1999, of `Debugging with GDB: | |
10 | +the GNU Source-Level Debugger' for GDB Version 4.18. | |
11 | + | |
12 | + Copyright (C) 1988-1999 Free Software Foundation, Inc. | |
13 | + | |
14 | + Permission is granted to make and distribute verbatim copies of this | |
15 | +manual provided the copyright notice and this permission notice are | |
16 | +preserved on all copies. | |
17 | + | |
18 | + Permission is granted to copy and distribute modified versions of | |
19 | +this manual under the conditions for verbatim copying, provided also | |
20 | +that the entire resulting derived work is distributed under the terms | |
21 | +of a permission notice identical to this one. | |
22 | + | |
23 | + Permission is granted to copy and distribute translations of this | |
24 | +manual into another language, under the above conditions for modified | |
25 | +versions. | |
26 | + | |
27 | + | |
28 | +File: gdb.info, Node: Index, Prev: Installing GDB, Up: Top | |
29 | + | |
30 | +Index | |
31 | +***** | |
32 | + | |
33 | +* Menu: | |
34 | + | |
35 | +* #: Command Syntax. | |
36 | +* # in Modula-2: GDB/M2. | |
37 | +* $: Value History. | |
38 | +* $$: Value History. | |
39 | +* $_: Convenience Vars. | |
40 | +* $_ and info breakpoints: Set Breaks. | |
41 | +* $_ and info line: Machine Code. | |
42 | +* $_, $__, and value history: Memory. | |
43 | +* $__: Convenience Vars. | |
44 | +* $_exitcode: Convenience Vars. | |
45 | +* $bpnum: Set Breaks. | |
46 | +* $cdir: Source Path. | |
47 | +* $cwd: Source Path. | |
48 | +* .: M2 Scope. | |
49 | +* .esgdbinit: Command Files. | |
50 | +* .gdbinit: Command Files. | |
51 | +* .os68gdbinit: Command Files. | |
52 | +* .vxgdbinit: Command Files. | |
53 | +* /proc: Process Information. | |
54 | +* @: Arrays. | |
55 | +* a.out and C++: Cplus expressions. | |
56 | +* abbreviation: Command Syntax. | |
57 | +* active targets: Active Targets. | |
58 | +* add-shared-symbol-file: Files. | |
59 | +* add-symbol-file: Files. | |
60 | +* Alpha stack: Alpha/MIPS Stack. | |
61 | +* AMD 29K register stack: Registers. | |
62 | +* AMD EB29K: Target Commands. | |
63 | +* AMD29K via UDI: UDI29K Remote. | |
64 | +* arguments (to your program): Arguments. | |
65 | +* artificial array: Arrays. | |
66 | +* assembly instructions: Machine Code. | |
67 | +* assignment: Assignment. | |
68 | +* attach: Attach. | |
69 | +* automatic display: Auto Display. | |
70 | +* automatic thread selection: Threads. | |
71 | +* awatch: Set Watchpoints. | |
72 | +* b: Set Breaks. | |
73 | +* backtrace: Backtrace. | |
74 | +* backtraces: Backtrace. | |
75 | +* bell-style: Readline Init File Syntax. | |
76 | +* break: Set Breaks. | |
77 | +* break ... thread THREADNO: Thread Stops. | |
78 | +* break in overloaded functions: Debugging C plus plus. | |
79 | +* breakpoint commands: Break Commands. | |
80 | +* breakpoint conditions: Conditions. | |
81 | +* breakpoint numbers: Breakpoints. | |
82 | +* breakpoint on events: Breakpoints. | |
83 | +* breakpoint on memory address: Breakpoints. | |
84 | +* breakpoint on variable modification: Breakpoints. | |
85 | +* breakpoint subroutine, remote: Stub Contents. | |
86 | +* breakpoints: Breakpoints. | |
87 | +* breakpoints and threads: Thread Stops. | |
88 | +* bt: Backtrace. | |
89 | +* bug criteria: Bug Criteria. | |
90 | +* bug reports: Bug Reporting. | |
91 | +* bugs in GDB: GDB Bugs. | |
92 | +* c: Continuing and Stepping. | |
93 | +* C and C++: C. | |
94 | +* C and C++ checks: C Checks. | |
95 | +* C and C++ constants: C Constants. | |
96 | +* C and C++ defaults: C Defaults. | |
97 | +* C and C++ operators: C. | |
98 | +* C++: C. | |
99 | +* C++ and object formats: Cplus expressions. | |
100 | +* C++ exception handling: Debugging C plus plus. | |
101 | +* C++ scope resolution: Variables. | |
102 | +* C++ support, not in COFF: Cplus expressions. | |
103 | +* C++ symbol decoding style: Print Settings. | |
104 | +* C++ symbol display: Debugging C plus plus. | |
105 | +* call: Calling. | |
106 | +* call overloaded functions: Cplus expressions. | |
107 | +* call stack: Stack. | |
108 | +* calling functions: Calling. | |
109 | +* calling make: Shell Commands. | |
110 | +* casts, to view memory: Expressions. | |
111 | +* catch: Set Catchpoints. | |
112 | +* catch catch: Set Catchpoints. | |
113 | +* catch exceptions: Frame Info. | |
114 | +* catch exec: Set Catchpoints. | |
115 | +* catch fork: Set Catchpoints. | |
116 | +* catch load: Set Catchpoints. | |
117 | +* catch throw: Set Catchpoints. | |
118 | +* catch unload: Set Catchpoints. | |
119 | +* catch vfork: Set Catchpoints. | |
120 | +* catchpoints <1>: Set Catchpoints. | |
121 | +* catchpoints: Breakpoints. | |
122 | +* cd: Working Directory. | |
123 | +* cdir: Source Path. | |
124 | +* checks, range: Type Checking. | |
125 | +* checks, type: Checks. | |
126 | +* checksum, for GDB remote: Protocol. | |
127 | +* choosing target byte order: Byte Order. | |
128 | +* clear: Delete Breaks. | |
129 | +* clearing breakpoints, watchpoints, catchpoints: Delete Breaks. | |
130 | +* COFF versus C++: Cplus expressions. | |
131 | +* colon, doubled as scope operator: M2 Scope. | |
132 | +* colon-colon <1>: Variables. | |
133 | +* colon-colon: M2 Scope. | |
134 | +* command editing: Readline Bare Essentials. | |
135 | +* command files <1>: Hooks. | |
136 | +* command files: Command Files. | |
137 | +* command line editing: Editing. | |
138 | +* commands: Break Commands. | |
139 | +* commands for C++: Debugging C plus plus. | |
140 | +* commands to STDBUG (ST2000): ST2000 Remote. | |
141 | +* comment: Command Syntax. | |
142 | +* comment-begin: Readline Init File Syntax. | |
143 | +* compilation directory: Source Path. | |
144 | +* Compiling: Sparclet Remote. | |
145 | +* complete: Help. | |
146 | +* completion: Completion. | |
147 | +* completion of quoted strings: Completion. | |
148 | +* completion-query-items: Readline Init File Syntax. | |
149 | +* condition: Conditions. | |
150 | +* conditional breakpoints: Conditions. | |
151 | +* configuring GDB: Installing GDB. | |
152 | +* confirmation: Messages/Warnings. | |
153 | +* connect (to STDBUG): ST2000 Remote. | |
154 | +* continue: Continuing and Stepping. | |
155 | +* continuing: Continuing and Stepping. | |
156 | +* continuing threads: Thread Stops. | |
157 | +* control C, and remote debugging: Bootstrapping. | |
158 | +* controlling terminal: Input/Output. | |
159 | +* convenience variables: Convenience Vars. | |
160 | +* convert-meta: Readline Init File Syntax. | |
161 | +* core: Files. | |
162 | +* core dump file: Files. | |
163 | +* core-file: Files. | |
164 | +* CPU simulator: Simulator. | |
165 | +* crash of debugger: Bug Criteria. | |
166 | +* current directory: Source Path. | |
167 | +* current thread: Threads. | |
168 | +* cwd: Source Path. | |
169 | +* d: Delete Breaks. | |
170 | +* debugger crash: Bug Criteria. | |
171 | +* debugging optimized code: Compilation. | |
172 | +* debugging stub, example: Protocol. | |
173 | +* debugging target: Targets. | |
174 | +* define: Define. | |
175 | +* delete: Delete Breaks. | |
176 | +* delete breakpoints: Delete Breaks. | |
177 | +* delete display: Auto Display. | |
178 | +* deleting breakpoints, watchpoints, catchpoints: Delete Breaks. | |
179 | +* demangling: Print Settings. | |
180 | +* detach: Attach. | |
181 | +* device: Hitachi Boards. | |
182 | +* dir: Source Path. | |
183 | +* directories for source files: Source Path. | |
184 | +* directory: Source Path. | |
185 | +* directory, compilation: Source Path. | |
186 | +* directory, current: Source Path. | |
187 | +* dis: Disabling. | |
188 | +* disable: Disabling. | |
189 | +* disable breakpoints: Disabling. | |
190 | +* disable display: Auto Display. | |
191 | +* disable-completion: Readline Init File Syntax. | |
192 | +* disassemble: Machine Code. | |
193 | +* display: Auto Display. | |
194 | +* display of expressions: Auto Display. | |
195 | +* do: Selection. | |
196 | +* document: Define. | |
197 | +* documentation: Formatting Documentation. | |
198 | +* down: Selection. | |
199 | +* down-silently: Selection. | |
200 | +* download to H8/300 or H8/500: Target Commands. | |
201 | +* download to Hitachi SH: Target Commands. | |
202 | +* download to Nindy-960: Target Commands. | |
203 | +* download to Sparclet: Sparclet Download. | |
204 | +* download to VxWorks: VxWorks Download. | |
205 | +* dynamic linking: Files. | |
206 | +* eb.log: Remote Log. | |
207 | +* EB29K board: EB29K Remote. | |
208 | +* EBMON: Comms (EB29K). | |
209 | +* echo: Output. | |
210 | +* ECOFF and C++: Cplus expressions. | |
211 | +* editing: Editing. | |
212 | +* editing command lines: Readline Bare Essentials. | |
213 | +* editing-mode: Readline Init File Syntax. | |
214 | +* ELF/DWARF and C++: Cplus expressions. | |
215 | +* ELF/stabs and C++: Cplus expressions. | |
216 | +* else: Define. | |
217 | +* Emacs: Emacs. | |
218 | +* enable: Disabling. | |
219 | +* enable breakpoints: Disabling. | |
220 | +* enable display: Auto Display. | |
221 | +* enable-keypad: Readline Init File Syntax. | |
222 | +* end: Break Commands. | |
223 | +* entering numbers: Numbers. | |
224 | +* environment (of your program): Environment. | |
225 | +* error on valid input: Bug Criteria. | |
226 | +* event designators: Event Designators. | |
227 | +* event handling: Set Catchpoints. | |
228 | +* examining data: Data. | |
229 | +* examining memory: Memory. | |
230 | +* exception handlers <1>: Frame Info. | |
231 | +* exception handlers: Set Catchpoints. | |
232 | +* exceptionHandler: Bootstrapping. | |
233 | +* exec-file: Files. | |
234 | +* executable file: Files. | |
235 | +* exiting GDB: Quitting GDB. | |
236 | +* expand-tilde: Readline Init File Syntax. | |
237 | +* expansion: History Interaction. | |
238 | +* expressions: Expressions. | |
239 | +* expressions in C or C++: C. | |
240 | +* expressions in C++: Cplus expressions. | |
241 | +* expressions in Modula-2: Modula-2. | |
242 | +* f: Selection. | |
243 | +* fatal signal: Bug Criteria. | |
244 | +* fatal signals: Signals. | |
245 | +* fg: Continuing and Stepping. | |
246 | +* file: Files. | |
247 | +* finish: Continuing and Stepping. | |
248 | +* flinching: Messages/Warnings. | |
249 | +* floating point: Floating Point Hardware. | |
250 | +* floating point registers: Registers. | |
251 | +* floating point, MIPS remote: MIPS Remote. | |
252 | +* flush_i_cache: Bootstrapping. | |
253 | +* focus of debugging: Threads. | |
254 | +* foo: Symbol Errors. | |
255 | +* fork, debugging programs which call: Processes. | |
256 | +* format options: Print Settings. | |
257 | +* formatted output: Output Formats. | |
258 | +* Fortran: Summary. | |
259 | +* forward-search: Search. | |
260 | +* frame <1>: Selection. | |
261 | +* frame: Frames. | |
262 | +* frame number: Frames. | |
263 | +* frame pointer: Frames. | |
264 | +* frameless execution: Frames. | |
265 | +* Fujitsu: Remote Serial. | |
266 | +* g++: C. | |
267 | +* GDB bugs, reporting: Bug Reporting. | |
268 | +* GDB reference card: Formatting Documentation. | |
269 | +* GDBHISTFILE: History. | |
270 | +* gdbserve.nlm: NetWare. | |
271 | +* gdbserver: Server. | |
272 | +* getDebugChar: Bootstrapping. | |
273 | +* GNU C++: C. | |
274 | +* GNU Emacs: Emacs. | |
275 | +* h: Help. | |
276 | +* H8/300 or H8/500 download: Target Commands. | |
277 | +* H8/300 or H8/500 simulator: Simulator. | |
278 | +* handle: Signals. | |
279 | +* handle_exception: Stub Contents. | |
280 | +* handling signals: Signals. | |
281 | +* hardware watchpoints: Set Watchpoints. | |
282 | +* hbreak: Set Breaks. | |
283 | +* help: Help. | |
284 | +* help target: Target Commands. | |
285 | +* help user-defined: Define. | |
286 | +* heuristic-fence-post (Alpha,MIPS): Alpha/MIPS Stack. | |
287 | +* history expansion: History. | |
288 | +* history file: History. | |
289 | +* history number: Value History. | |
290 | +* history save: History. | |
291 | +* history size: History. | |
292 | +* history substitution: History. | |
293 | +* Hitachi: Remote Serial. | |
294 | +* Hitachi SH download: Target Commands. | |
295 | +* Hitachi SH simulator: Simulator. | |
296 | +* horizontal-scroll-mode: Readline Init File Syntax. | |
297 | +* i: Help. | |
298 | +* i/o: Input/Output. | |
299 | +* i386: Remote Serial. | |
300 | +* i386-stub.c: Remote Serial. | |
301 | +* i960: i960-Nindy Remote. | |
302 | +* if: Define. | |
303 | +* ignore: Conditions. | |
304 | +* ignore count (of breakpoint): Conditions. | |
305 | +* INCLUDE_RDB: VxWorks Remote. | |
306 | +* info: Help. | |
307 | +* info address: Symbols. | |
308 | +* info all-registers: Registers. | |
309 | +* info args: Frame Info. | |
310 | +* info breakpoints: Set Breaks. | |
311 | +* info catch: Frame Info. | |
312 | +* info display: Auto Display. | |
313 | +* info extensions: Show. | |
314 | +* info f: Frame Info. | |
315 | +* info files: Files. | |
316 | +* info float: Floating Point Hardware. | |
317 | +* info frame <1>: Frame Info. | |
318 | +* info frame: Show. | |
319 | +* info functions: Symbols. | |
320 | +* info line: Machine Code. | |
321 | +* info locals: Frame Info. | |
322 | +* info proc: Process Information. | |
323 | +* info proc id: Process Information. | |
324 | +* info proc mappings: Process Information. | |
325 | +* info proc status: Process Information. | |
326 | +* info proc times: Process Information. | |
327 | +* info program: Stopping. | |
328 | +* info registers: Registers. | |
329 | +* info s: Backtrace. | |
330 | +* info set: Help. | |
331 | +* info share: Files. | |
332 | +* info sharedlibrary: Files. | |
333 | +* info signals: Signals. | |
334 | +* info source <1>: Symbols. | |
335 | +* info source: Show. | |
336 | +* info sources: Symbols. | |
337 | +* info stack: Backtrace. | |
338 | +* info target: Files. | |
339 | +* info terminal: Input/Output. | |
340 | +* info threads: Threads. | |
341 | +* info types: Symbols. | |
342 | +* info variables: Symbols. | |
343 | +* info watchpoints: Set Watchpoints. | |
344 | +* inheritance: Debugging C plus plus. | |
345 | +* init file: Command Files. | |
346 | +* init file name: Command Files. | |
347 | +* initial frame: Frames. | |
348 | +* initialization file, readline: Readline Init File. | |
349 | +* innermost frame: Frames. | |
350 | +* input-meta: Readline Init File Syntax. | |
351 | +* inspect: Data. | |
352 | +* installation: Installing GDB. | |
353 | +* instructions, assembly: Machine Code. | |
354 | +* Intel: Remote Serial. | |
355 | +* interaction, readline: Readline Interaction. | |
356 | +* internal GDB breakpoints: Set Breaks. | |
357 | +* interrupt: Quitting GDB. | |
358 | +* interrupting remote programs: Debug Session. | |
359 | +* interrupting remote targets: Bootstrapping. | |
360 | +* invalid input: Bug Criteria. | |
361 | +* jump: Jumping. | |
362 | +* keymap: Readline Init File Syntax. | |
363 | +* kill: Kill Process. | |
364 | +* kill ring: Readline Killing Commands. | |
365 | +* killing text: Readline Killing Commands. | |
366 | +* l: List. | |
367 | +* languages: Languages. | |
368 | +* latest breakpoint: Set Breaks. | |
369 | +* leaving GDB: Quitting GDB. | |
370 | +* linespec: List. | |
371 | +* list: List. | |
372 | +* listing machine instructions: Machine Code. | |
373 | +* load FILENAME: Target Commands. | |
374 | +* log file for EB29K: Remote Log. | |
375 | +* m680x0: Remote Serial. | |
376 | +* m68k-stub.c: Remote Serial. | |
377 | +* machine instructions: Machine Code. | |
378 | +* maint info breakpoints: Set Breaks. | |
379 | +* maint print psymbols: Symbols. | |
380 | +* maint print symbols: Symbols. | |
381 | +* make: Shell Commands. | |
382 | +* mapped: Files. | |
383 | +* mark-modified-lines: Readline Init File Syntax. | |
384 | +* member functions: Cplus expressions. | |
385 | +* memory models, H8/500: Hitachi Special. | |
386 | +* memory tracing: Breakpoints. | |
387 | +* memory, viewing as typed object: Expressions. | |
388 | +* memory-mapped symbol file: Files. | |
389 | +* memset: Bootstrapping. | |
390 | +* meta-flag: Readline Init File Syntax. | |
391 | +* MIPS boards: MIPS Remote. | |
392 | +* MIPS remote floating point: MIPS Remote. | |
393 | +* MIPS remotedebug protocol: MIPS Remote. | |
394 | +* MIPS stack: Alpha/MIPS Stack. | |
395 | +* Modula-2: Modula-2. | |
396 | +* Modula-2 built-ins: M2 Operators. | |
397 | +* Modula-2 checks: M2 Checks. | |
398 | +* Modula-2 constants: Built-In Func/Proc. | |
399 | +* Modula-2 defaults: M2 Defaults. | |
400 | +* Modula-2 operators: M2 Operators. | |
401 | +* Modula-2, deviations from: Deviations. | |
402 | +* Motorola 680x0: Remote Serial. | |
403 | +* multiple processes: Processes. | |
404 | +* multiple targets: Active Targets. | |
405 | +* multiple threads: Threads. | |
406 | +* n: Continuing and Stepping. | |
407 | +* names of symbols: Symbols. | |
408 | +* namespace in C++: Cplus expressions. | |
409 | +* negative breakpoint numbers: Set Breaks. | |
410 | +* New SYSTAG: Threads. | |
411 | +* next: Continuing and Stepping. | |
412 | +* nexti: Continuing and Stepping. | |
413 | +* ni: Continuing and Stepping. | |
414 | +* Nindy: i960-Nindy Remote. | |
415 | +* notation, readline: Readline Bare Essentials. | |
416 | +* number representation: Numbers. | |
417 | +* numbers for breakpoints: Breakpoints. | |
418 | +* object formats and C++: Cplus expressions. | |
419 | +* online documentation: Help. | |
420 | +* optimized code, debugging: Compilation. | |
421 | +* outermost frame: Frames. | |
422 | +* output: Output. | |
423 | +* output formats: Output Formats. | |
424 | +* output-meta: Readline Init File Syntax. | |
425 | +* overloading: Breakpoint Menus. | |
426 | +* overloading in C++: Debugging C plus plus. | |
427 | +* packets, reporting on stdout: Protocol. | |
428 | +* partial symbol dump: Symbols. | |
429 | +* patching binaries: Patching. | |
430 | +* path: Environment. | |
431 | +* pauses in output: Screen Size. | |
432 | +* pipes: Starting. | |
433 | +* pointer, finding referent: Print Settings. | |
434 | +* print: Data. | |
435 | +* print settings: Print Settings. | |
436 | +* printf: Output. | |
437 | +* printing data: Data. | |
438 | +* process image: Process Information. | |
439 | +* processes, multiple: Processes. | |
440 | +* prompt: Prompt. | |
441 | +* protocol, GDB remote serial: Protocol. | |
442 | +* ptype: Symbols. | |
443 | +* putDebugChar: Bootstrapping. | |
444 | +* pwd: Working Directory. | |
445 | +* q: Quitting GDB. | |
446 | +* quit [EXPRESSION]: Quitting GDB. | |
447 | +* quotes in commands: Completion. | |
448 | +* quoting names: Symbols. | |
449 | +* raise exceptions: Set Catchpoints. | |
450 | +* range checking: Type Checking. | |
451 | +* rbreak: Set Breaks. | |
452 | +* reading symbols immediately: Files. | |
453 | +* readline: Editing. | |
454 | +* readnow: Files. | |
455 | +* redirection: Input/Output. | |
456 | +* reference card: Formatting Documentation. | |
457 | +* reference declarations: Cplus expressions. | |
458 | +* register stack, AMD29K: Registers. | |
459 | +* registers: Registers. | |
460 | +* regular expression: Set Breaks. | |
461 | +* reloading symbols: Symbols. | |
462 | +* remote connection without stubs: Server. | |
463 | +* remote debugging: Remote. | |
464 | +* remote programs, interrupting: Debug Session. | |
465 | +* remote serial debugging summary: Debug Session. | |
466 | +* remote serial debugging, overview: Remote Serial. | |
467 | +* remote serial protocol: Protocol. | |
468 | +* remote serial stub: Stub Contents. | |
469 | +* remote serial stub list: Remote Serial. | |
470 | +* remote serial stub, initialization: Stub Contents. | |
471 | +* remote serial stub, main routine: Stub Contents. | |
472 | +* remote stub, example: Protocol. | |
473 | +* remote stub, support routines: Bootstrapping. | |
474 | +* remotedebug, MIPS protocol: MIPS Remote. | |
475 | +* remotetimeout: Sparclet Remote. | |
476 | +* repeating commands: Command Syntax. | |
477 | +* reporting bugs in GDB: GDB Bugs. | |
478 | +* reset: Nindy Reset. | |
479 | +* response time, MIPS debugging: Alpha/MIPS Stack. | |
480 | +* resuming execution: Continuing and Stepping. | |
481 | +* RET: Command Syntax. | |
482 | +* retransmit-timeout, MIPS protocol: MIPS Remote. | |
483 | +* return: Returning. | |
484 | +* returning from a function: Returning. | |
485 | +* reverse-search: Search. | |
486 | +* run: Starting. | |
487 | +* running: Starting. | |
488 | +* Running: Sparclet Remote. | |
489 | +* running 29K programs: EB29K Remote. | |
490 | +* running and debugging Sparclet programs: Sparclet Execution. | |
491 | +* running VxWorks tasks: VxWorks Attach. | |
492 | +* rwatch: Set Watchpoints. | |
493 | +* s: Continuing and Stepping. | |
494 | +* saving symbol table: Files. | |
495 | +* scope: M2 Scope. | |
496 | +* search: Search. | |
497 | +* searching: Search. | |
498 | +* section: Files. | |
499 | +* select-frame: Frames. | |
500 | +* selected frame: Stack. | |
501 | +* serial connections, debugging: Protocol. | |
502 | +* serial device, Hitachi micros: Hitachi Boards. | |
503 | +* serial line speed, Hitachi micros: Hitachi Boards. | |
504 | +* serial line, target remote: Debug Session. | |
505 | +* serial protocol, GDB remote: Protocol. | |
506 | +* set: Help. | |
507 | +* set args: Arguments. | |
508 | +* set assembly-language: Machine Code. | |
509 | +* set check <1>: Type Checking. | |
510 | +* set check: Range Checking. | |
511 | +* set check range: Range Checking. | |
512 | +* set check type: Type Checking. | |
513 | +* set complaints: Messages/Warnings. | |
514 | +* set confirm: Messages/Warnings. | |
515 | +* set demangle-style: Print Settings. | |
516 | +* set editing: Editing. | |
517 | +* set endian auto: Byte Order. | |
518 | +* set endian big: Byte Order. | |
519 | +* set endian little: Byte Order. | |
520 | +* set environment: Environment. | |
521 | +* set extension-language: Show. | |
522 | +* set gnutarget: Target Commands. | |
523 | +* set height: Screen Size. | |
524 | +* set history expansion: History. | |
525 | +* set history filename: History. | |
526 | +* set history save: History. | |
527 | +* set history size: History. | |
528 | +* set input-radix: Numbers. | |
529 | +* set language: Manually. | |
530 | +* set listsize: List. | |
531 | +* set machine: Hitachi Special. | |
532 | +* set memory MOD: Hitachi Special. | |
533 | +* set mipsfpu: MIPS Remote. | |
534 | +* set output-radix: Numbers. | |
535 | +* set print address: Print Settings. | |
536 | +* set print array: Print Settings. | |
537 | +* set print asm-demangle: Print Settings. | |
538 | +* set print demangle: Print Settings. | |
539 | +* set print elements: Print Settings. | |
540 | +* set print max-symbolic-offset: Print Settings. | |
541 | +* set print null-stop: Print Settings. | |
542 | +* set print object: Print Settings. | |
543 | +* set print pretty: Print Settings. | |
544 | +* set print sevenbit-strings: Print Settings. | |
545 | +* set print static-members: Print Settings. | |
546 | +* set print symbol-filename: Print Settings. | |
547 | +* set print union: Print Settings. | |
548 | +* set print vtbl: Print Settings. | |
549 | +* set processor ARGS: MIPS Remote. | |
550 | +* set prompt: Prompt. | |
551 | +* set remotedebug <1>: Protocol. | |
552 | +* set remotedebug: MIPS Remote. | |
553 | +* set retransmit-timeout: MIPS Remote. | |
554 | +* set rstack_high_address: Registers. | |
555 | +* set symbol-reloading: Symbols. | |
556 | +* set timeout: MIPS Remote. | |
557 | +* set variable: Assignment. | |
558 | +* set verbose: Messages/Warnings. | |
559 | +* set width: Screen Size. | |
560 | +* set write: Patching. | |
561 | +* set_debug_traps: Stub Contents. | |
562 | +* setting variables: Assignment. | |
563 | +* setting watchpoints: Set Watchpoints. | |
564 | +* SH: Remote Serial. | |
565 | +* sh-stub.c: Remote Serial. | |
566 | +* share: Files. | |
567 | +* shared libraries: Files. | |
568 | +* sharedlibrary: Files. | |
569 | +* shell: Shell Commands. | |
570 | +* shell escape: Shell Commands. | |
571 | +* show: Help. | |
572 | +* show args: Arguments. | |
573 | +* show check range: Range Checking. | |
574 | +* show check type: Type Checking. | |
575 | +* show commands: History. | |
576 | +* show complaints: Messages/Warnings. | |
577 | +* show confirm: Messages/Warnings. | |
578 | +* show convenience: Convenience Vars. | |
579 | +* show copying: Help. | |
580 | +* show demangle-style: Print Settings. | |
581 | +* show directories: Source Path. | |
582 | +* show editing: Editing. | |
583 | +* show endian: Byte Order. | |
584 | +* show environment: Environment. | |
585 | +* show gnutarget: Target Commands. | |
586 | +* show height: Screen Size. | |
587 | +* show history: History. | |
588 | +* show input-radix: Numbers. | |
589 | +* show language: Show. | |
590 | +* show listsize: List. | |
591 | +* show machine: Hitachi Special. | |
592 | +* show mipsfpu: MIPS Remote. | |
593 | +* show output-radix: Numbers. | |
594 | +* show paths: Environment. | |
595 | +* show print address: Print Settings. | |
596 | +* show print array: Print Settings. | |
597 | +* show print asm-demangle: Print Settings. | |
598 | +* show print demangle: Print Settings. | |
599 | +* show print elements: Print Settings. | |
600 | +* show print max-symbolic-offset: Print Settings. | |
601 | +* show print object: Print Settings. | |
602 | +* show print pretty: Print Settings. | |
603 | +* show print sevenbit-strings: Print Settings. | |
604 | +* show print static-members: Print Settings. | |
605 | +* show print symbol-filename: Print Settings. | |
606 | +* show print union: Print Settings. | |
607 | +* show print vtbl: Print Settings. | |
608 | +* show processor: MIPS Remote. | |
609 | +* show prompt: Prompt. | |
610 | +* show remotedebug <1>: MIPS Remote. | |
611 | +* show remotedebug: Protocol. | |
612 | +* show retransmit-timeout: MIPS Remote. | |
613 | +* show rstack_high_address: Registers. | |
614 | +* show symbol-reloading: Symbols. | |
615 | +* show timeout: MIPS Remote. | |
616 | +* show user: Define. | |
617 | +* show values: Value History. | |
618 | +* show verbose: Messages/Warnings. | |
619 | +* show version: Help. | |
620 | +* show warranty: Help. | |
621 | +* show width: Screen Size. | |
622 | +* show write: Patching. | |
623 | +* show-all-if-ambiguous: Readline Init File Syntax. | |
624 | +* si: Continuing and Stepping. | |
625 | +* signal: Signaling. | |
626 | +* signals: Signals. | |
627 | +* silent: Break Commands. | |
628 | +* sim: Simulator. | |
629 | +* simulator: Simulator. | |
630 | +* simulator, H8/300 or H8/500: Simulator. | |
631 | +* simulator, Hitachi SH: Simulator. | |
632 | +* simulator, Z8000: Simulator. | |
633 | +* size of screen: Screen Size. | |
634 | +* software watchpoints: Set Watchpoints. | |
635 | +* source: Command Files. | |
636 | +* source path: Source Path. | |
637 | +* Sparc: Remote Serial. | |
638 | +* sparc-stub.c: Remote Serial. | |
639 | +* sparcl-stub.c: Remote Serial. | |
640 | +* Sparclet: Sparclet Remote. | |
641 | +* SparcLite: Remote Serial. | |
642 | +* speed: Hitachi Boards. | |
643 | +* ST2000 auxiliary commands: ST2000 Remote. | |
644 | +* st2000 CMD: ST2000 Remote. | |
645 | +* stack frame: Frames. | |
646 | +* stack on Alpha: Alpha/MIPS Stack. | |
647 | +* stack on MIPS: Alpha/MIPS Stack. | |
648 | +* stack traces: Backtrace. | |
649 | +* stacking targets: Active Targets. | |
650 | +* starting: Starting. | |
651 | +* STDBUG commands (ST2000): ST2000 Remote. | |
652 | +* step: Continuing and Stepping. | |
653 | +* stepi: Continuing and Stepping. | |
654 | +* stepping: Continuing and Stepping. | |
655 | +* stopped threads: Thread Stops. | |
656 | +* stub example, remote debugging: Protocol. | |
657 | +* stupid questions: Messages/Warnings. | |
658 | +* switching threads: Threads. | |
659 | +* switching threads automatically: Threads. | |
660 | +* symbol decoding style, C++: Print Settings. | |
661 | +* symbol dump: Symbols. | |
662 | +* symbol names: Symbols. | |
663 | +* symbol overloading: Breakpoint Menus. | |
664 | +* symbol table: Files. | |
665 | +* symbol-file: Files. | |
666 | +* symbols, reading immediately: Files. | |
667 | +* target: Targets. | |
668 | +* target abug: Target Commands. | |
669 | +* target adapt: Target Commands. | |
670 | +* target amd-eb: Target Commands. | |
671 | +* target array: Target Commands. | |
672 | +* target bug: Target Commands. | |
673 | +* target byte order: Byte Order. | |
674 | +* target core: Target Commands. | |
675 | +* target cpu32bug: Target Commands. | |
676 | +* target dbug: Target Commands. | |
677 | +* target ddb: Target Commands. | |
678 | +* target ddb PORT: MIPS Remote. | |
679 | +* target dink32: Target Commands. | |
680 | +* target e7000 <1>: Hitachi ICE. | |
681 | +* target e7000: Target Commands. | |
682 | +* target es1800: Target Commands. | |
683 | +* target est: Target Commands. | |
684 | +* target exec: Target Commands. | |
685 | +* target hms: Target Commands. | |
686 | +* target lsi: Target Commands. | |
687 | +* target lsi PORT: MIPS Remote. | |
688 | +* target m32r: Target Commands. | |
689 | +* target mips: Target Commands. | |
690 | +* target mips PORT: MIPS Remote. | |
691 | +* target mon960: Target Commands. | |
692 | +* target nindy: Target Commands. | |
693 | +* target nrom: Target Commands. | |
694 | +* target op50n: Target Commands. | |
695 | +* target pmon: Target Commands. | |
696 | +* target pmon PORT: MIPS Remote. | |
697 | +* target ppcbug: Target Commands. | |
698 | +* target ppcbug1: Target Commands. | |
699 | +* target r3900: Target Commands. | |
700 | +* target rdi: Target Commands. | |
701 | +* target rdp: Target Commands. | |
702 | +* target remote: Target Commands. | |
703 | +* target rom68k: Target Commands. | |
704 | +* target rombug: Target Commands. | |
705 | +* target sds: Target Commands. | |
706 | +* target sh3: Target Commands. | |
707 | +* target sh3e: Target Commands. | |
708 | +* target sim <1>: Target Commands. | |
709 | +* target sim: Simulator. | |
710 | +* target sparclite: Target Commands. | |
711 | +* target st2000: Target Commands. | |
712 | +* target udi: Target Commands. | |
713 | +* target vxworks: Target Commands. | |
714 | +* target w89k: Target Commands. | |
715 | +* tbreak: Set Breaks. | |
716 | +* TCP port, target remote: Debug Session. | |
717 | +* terminal: Input/Output. | |
718 | +* thbreak: Set Breaks. | |
719 | +* this: Cplus expressions. | |
720 | +* thread apply: Threads. | |
721 | +* thread breakpoints: Thread Stops. | |
722 | +* thread identifier (GDB): Threads. | |
723 | +* thread identifier (system): Threads. | |
724 | +* thread number: Threads. | |
725 | +* thread THREADNO: Threads. | |
726 | +* threads and watchpoints: Set Watchpoints. | |
727 | +* threads of execution: Threads. | |
728 | +* threads, automatic switching: Threads. | |
729 | +* threads, continuing: Thread Stops. | |
730 | +* threads, stopped: Thread Stops. | |
731 | +* timeout, MIPS protocol: MIPS Remote. | |
732 | +* tracebacks: Backtrace. | |
733 | +* tty: Input/Output. | |
734 | +* type casting memory: Expressions. | |
735 | +* type checking: Checks. | |
736 | +* type conversions in C++: Cplus expressions. | |
737 | +* u: Continuing and Stepping. | |
738 | +* UDI: UDI29K Remote. | |
739 | +* udi: UDI29K Remote. | |
740 | +* undisplay: Auto Display. | |
741 | +* unknown address, locating: Output Formats. | |
742 | +* unset environment: Environment. | |
743 | +* until: Continuing and Stepping. | |
744 | +* up: Selection. | |
745 | +* up-silently: Selection. | |
746 | +* user-defined command: Define. | |
747 | +* value history: Value History. | |
748 | +* variable name conflict: Variables. | |
749 | +* variable values, wrong: Variables. | |
750 | +* variables, setting: Assignment. | |
751 | +* version number: Help. | |
752 | +* visible-stats: Readline Init File Syntax. | |
753 | +* VxWorks: VxWorks Remote. | |
754 | +* vxworks-timeout: VxWorks Remote. | |
755 | +* watch: Set Watchpoints. | |
756 | +* watchpoints: Breakpoints. | |
757 | +* watchpoints and threads: Set Watchpoints. | |
758 | +* whatis: Symbols. | |
759 | +* where: Backtrace. | |
760 | +* while: Define. | |
761 | +* wild pointer, interpreting: Print Settings. | |
762 | +* word completion: Completion. | |
763 | +* working directory: Source Path. | |
764 | +* working directory (of your program): Working Directory. | |
765 | +* working language: Languages. | |
766 | +* writing into corefiles: Patching. | |
767 | +* writing into executables: Patching. | |
768 | +* wrong values: Variables. | |
769 | +* x: Memory. | |
770 | +* XCOFF and C++: Cplus expressions. | |
771 | +* yanking text: Readline Killing Commands. | |
772 | +* Z8000 simulator: Simulator. | |
773 | +* {TYPE}: Expressions. | |
774 | + | |
775 | + |
@@ -0,0 +1,1161 @@ | ||
1 | +This is Info file ./gdb.info, produced by Makeinfo version 1.68 from | |
2 | +the input file gdb.texinfo. | |
3 | + | |
4 | +START-INFO-DIR-ENTRY | |
5 | +* Gdb: (gdb). The GNU debugger. | |
6 | +END-INFO-DIR-ENTRY | |
7 | + This file documents the GNU debugger GDB. | |
8 | + | |
9 | + This is the Seventh Edition, February 1999, of `Debugging with GDB: | |
10 | +the GNU Source-Level Debugger' for GDB Version 4.18. | |
11 | + | |
12 | + Copyright (C) 1988-1999 Free Software Foundation, Inc. | |
13 | + | |
14 | + Permission is granted to make and distribute verbatim copies of this | |
15 | +manual provided the copyright notice and this permission notice are | |
16 | +preserved on all copies. | |
17 | + | |
18 | + Permission is granted to copy and distribute modified versions of | |
19 | +this manual under the conditions for verbatim copying, provided also | |
20 | +that the entire resulting derived work is distributed under the terms | |
21 | +of a permission notice identical to this one. | |
22 | + | |
23 | + Permission is granted to copy and distribute translations of this | |
24 | +manual into another language, under the above conditions for modified | |
25 | +versions. | |
26 | + | |
27 | + | |
28 | +File: gdb.info, Node: Starting, Next: Arguments, Prev: Compilation, Up: Running | |
29 | + | |
30 | +Starting your program | |
31 | +===================== | |
32 | + | |
33 | +`run' | |
34 | +`r' | |
35 | + Use the `run' command to start your program under GDB. You must | |
36 | + first specify the program name (except on VxWorks) with an | |
37 | + argument to GDB (*note Getting In and Out of GDB: Invocation.), or | |
38 | + by using the `file' or `exec-file' command (*note Commands to | |
39 | + specify files: Files.). | |
40 | + | |
41 | + If you are running your program in an execution environment that | |
42 | +supports processes, `run' creates an inferior process and makes that | |
43 | +process run your program. (In environments without processes, `run' | |
44 | +jumps to the start of your program.) | |
45 | + | |
46 | + The execution of a program is affected by certain information it | |
47 | +receives from its superior. GDB provides ways to specify this | |
48 | +information, which you must do *before* starting your program. (You | |
49 | +can change it after starting your program, but such changes only affect | |
50 | +your program the next time you start it.) This information may be | |
51 | +divided into four categories: | |
52 | + | |
53 | +The *arguments.* | |
54 | + Specify the arguments to give your program as the arguments of the | |
55 | + `run' command. If a shell is available on your target, the shell | |
56 | + is used to pass the arguments, so that you may use normal | |
57 | + conventions (such as wildcard expansion or variable substitution) | |
58 | + in describing the arguments. In Unix systems, you can control | |
59 | + which shell is used with the `SHELL' environment variable. *Note | |
60 | + Your program's arguments: Arguments. | |
61 | + | |
62 | +The *environment.* | |
63 | + Your program normally inherits its environment from GDB, but you | |
64 | + can use the GDB commands `set environment' and `unset environment' | |
65 | + to change parts of the environment that affect your program. | |
66 | + *Note Your program's environment: Environment. | |
67 | + | |
68 | +The *working directory.* | |
69 | + Your program inherits its working directory from GDB. You can set | |
70 | + the GDB working directory with the `cd' command in GDB. *Note | |
71 | + Your program's working directory: Working Directory. | |
72 | + | |
73 | +The *standard input and output.* | |
74 | + Your program normally uses the same device for standard input and | |
75 | + standard output as GDB is using. You can redirect input and output | |
76 | + in the `run' command line, or you can use the `tty' command to set | |
77 | + a different device for your program. *Note Your program's input | |
78 | + and output: Input/Output. | |
79 | + | |
80 | + *Warning:* While input and output redirection work, you cannot use | |
81 | + pipes to pass the output of the program you are debugging to | |
82 | + another program; if you attempt this, GDB is likely to wind up | |
83 | + debugging the wrong program. | |
84 | + | |
85 | + When you issue the `run' command, your program begins to execute | |
86 | +immediately. *Note Stopping and continuing: Stopping, for discussion | |
87 | +of how to arrange for your program to stop. Once your program has | |
88 | +stopped, you may call functions in your program, using the `print' or | |
89 | +`call' commands. *Note Examining Data: Data. | |
90 | + | |
91 | + If the modification time of your symbol file has changed since the | |
92 | +last time GDB read its symbols, GDB discards its symbol table, and | |
93 | +reads it again. When it does this, GDB tries to retain your current | |
94 | +breakpoints. | |
95 | + | |
96 | + | |
97 | +File: gdb.info, Node: Arguments, Next: Environment, Prev: Starting, Up: Running | |
98 | + | |
99 | +Your program's arguments | |
100 | +======================== | |
101 | + | |
102 | + The arguments to your program can be specified by the arguments of | |
103 | +the `run' command. They are passed to a shell, which expands wildcard | |
104 | +characters and performs redirection of I/O, and thence to your program. | |
105 | +Your `SHELL' environment variable (if it exists) specifies what shell | |
106 | +GDB uses. If you do not define `SHELL', GDB uses `/bin/sh'. | |
107 | + | |
108 | + `run' with no arguments uses the same arguments used by the previous | |
109 | +`run', or those set by the `set args' command. | |
110 | + | |
111 | +`set args' | |
112 | + Specify the arguments to be used the next time your program is | |
113 | + run. If `set args' has no arguments, `run' executes your program | |
114 | + with no arguments. Once you have run your program with arguments, | |
115 | + using `set args' before the next `run' is the only way to run it | |
116 | + again without arguments. | |
117 | + | |
118 | +`show args' | |
119 | + Show the arguments to give your program when it is started. | |
120 | + | |
121 | + | |
122 | +File: gdb.info, Node: Environment, Next: Working Directory, Prev: Arguments, Up: Running | |
123 | + | |
124 | +Your program's environment | |
125 | +========================== | |
126 | + | |
127 | + The "environment" consists of a set of environment variables and | |
128 | +their values. Environment variables conventionally record such things | |
129 | +as your user name, your home directory, your terminal type, and your | |
130 | +search path for programs to run. Usually you set up environment | |
131 | +variables with the shell and they are inherited by all the other | |
132 | +programs you run. When debugging, it can be useful to try running your | |
133 | +program with a modified environment without having to start GDB over | |
134 | +again. | |
135 | + | |
136 | +`path DIRECTORY' | |
137 | + Add DIRECTORY to the front of the `PATH' environment variable (the | |
138 | + search path for executables), for both GDB and your program. You | |
139 | + may specify several directory names, separated by `:' or | |
140 | + whitespace. If DIRECTORY is already in the path, it is moved to | |
141 | + the front, so it is searched sooner. | |
142 | + | |
143 | + You can use the string `$cwd' to refer to whatever is the current | |
144 | + working directory at the time GDB searches the path. If you use | |
145 | + `.' instead, it refers to the directory where you executed the | |
146 | + `path' command. GDB replaces `.' in the DIRECTORY argument (with | |
147 | + the current path) before adding DIRECTORY to the search path. | |
148 | + | |
149 | +`show paths' | |
150 | + Display the list of search paths for executables (the `PATH' | |
151 | + environment variable). | |
152 | + | |
153 | +`show environment [VARNAME]' | |
154 | + Print the value of environment variable VARNAME to be given to | |
155 | + your program when it starts. If you do not supply VARNAME, print | |
156 | + the names and values of all environment variables to be given to | |
157 | + your program. You can abbreviate `environment' as `env'. | |
158 | + | |
159 | +`set environment VARNAME [=] VALUE' | |
160 | + Set environment variable VARNAME to VALUE. The value changes for | |
161 | + your program only, not for GDB itself. VALUE may be any string; | |
162 | + the values of environment variables are just strings, and any | |
163 | + interpretation is supplied by your program itself. The VALUE | |
164 | + parameter is optional; if it is eliminated, the variable is set to | |
165 | + a null value. | |
166 | + | |
167 | + For example, this command: | |
168 | + | |
169 | + set env USER = foo | |
170 | + | |
171 | + tells a Unix program, when subsequently run, that its user is named | |
172 | + `foo'. (The spaces around `=' are used for clarity here; they are | |
173 | + not actually required.) | |
174 | + | |
175 | +`unset environment VARNAME' | |
176 | + Remove variable VARNAME from the environment to be passed to your | |
177 | + program. This is different from `set env VARNAME ='; `unset | |
178 | + environment' removes the variable from the environment, rather | |
179 | + than assigning it an empty value. | |
180 | + | |
181 | + *Warning:* GDB runs your program using the shell indicated by your | |
182 | +`SHELL' environment variable if it exists (or `/bin/sh' if not). If | |
183 | +your `SHELL' variable names a shell that runs an initialization | |
184 | +file--such as `.cshrc' for C-shell, or `.bashrc' for BASH--any | |
185 | +variables you set in that file affect your program. You may wish to | |
186 | +move setting of environment variables to files that are only run when | |
187 | +you sign on, such as `.login' or `.profile'. | |
188 | + | |
189 | + | |
190 | +File: gdb.info, Node: Working Directory, Next: Input/Output, Prev: Environment, Up: Running | |
191 | + | |
192 | +Your program's working directory | |
193 | +================================ | |
194 | + | |
195 | + Each time you start your program with `run', it inherits its working | |
196 | +directory from the current working directory of GDB. The GDB working | |
197 | +directory is initially whatever it inherited from its parent process | |
198 | +(typically the shell), but you can specify a new working directory in | |
199 | +GDB with the `cd' command. | |
200 | + | |
201 | + The GDB working directory also serves as a default for the commands | |
202 | +that specify files for GDB to operate on. *Note Commands to specify | |
203 | +files: Files. | |
204 | + | |
205 | +`cd DIRECTORY' | |
206 | + Set the GDB working directory to DIRECTORY. | |
207 | + | |
208 | +`pwd' | |
209 | + Print the GDB working directory. | |
210 | + | |
211 | + | |
212 | +File: gdb.info, Node: Input/Output, Next: Attach, Prev: Working Directory, Up: Running | |
213 | + | |
214 | +Your program's input and output | |
215 | +=============================== | |
216 | + | |
217 | + By default, the program you run under GDB does input and output to | |
218 | +the same terminal that GDB uses. GDB switches the terminal to its own | |
219 | +terminal modes to interact with you, but it records the terminal modes | |
220 | +your program was using and switches back to them when you continue | |
221 | +running your program. | |
222 | + | |
223 | +`info terminal' | |
224 | + Displays information recorded by GDB about the terminal modes your | |
225 | + program is using. | |
226 | + | |
227 | + You can redirect your program's input and/or output using shell | |
228 | +redirection with the `run' command. For example, | |
229 | + | |
230 | + run > outfile | |
231 | + | |
232 | +starts your program, diverting its output to the file `outfile'. | |
233 | + | |
234 | + Another way to specify where your program should do input and output | |
235 | +is with the `tty' command. This command accepts a file name as | |
236 | +argument, and causes this file to be the default for future `run' | |
237 | +commands. It also resets the controlling terminal for the child | |
238 | +process, for future `run' commands. For example, | |
239 | + | |
240 | + tty /dev/ttyb | |
241 | + | |
242 | +directs that processes started with subsequent `run' commands default | |
243 | +to do input and output on the terminal `/dev/ttyb' and have that as | |
244 | +their controlling terminal. | |
245 | + | |
246 | + An explicit redirection in `run' overrides the `tty' command's | |
247 | +effect on the input/output device, but not its effect on the controlling | |
248 | +terminal. | |
249 | + | |
250 | + When you use the `tty' command or redirect input in the `run' | |
251 | +command, only the input *for your program* is affected. The input for | |
252 | +GDB still comes from your terminal. | |
253 | + | |
254 | + | |
255 | +File: gdb.info, Node: Attach, Next: Kill Process, Prev: Input/Output, Up: Running | |
256 | + | |
257 | +Debugging an already-running process | |
258 | +==================================== | |
259 | + | |
260 | +`attach PROCESS-ID' | |
261 | + This command attaches to a running process--one that was started | |
262 | + outside GDB. (`info files' shows your active targets.) The | |
263 | + command takes as argument a process ID. The usual way to find out | |
264 | + the process-id of a Unix process is with the `ps' utility, or with | |
265 | + the `jobs -l' shell command. | |
266 | + | |
267 | + `attach' does not repeat if you press <RET> a second time after | |
268 | + executing the command. | |
269 | + | |
270 | + To use `attach', your program must be running in an environment | |
271 | +which supports processes; for example, `attach' does not work for | |
272 | +programs on bare-board targets that lack an operating system. You must | |
273 | +also have permission to send the process a signal. | |
274 | + | |
275 | + When you use `attach', the debugger finds the program running in the | |
276 | +process first by looking in the current working directory, then (if the | |
277 | +program is not found) by using the source file search path (*note | |
278 | +Specifying source directories: Source Path.). You can also use the | |
279 | +`file' command to load the program. *Note Commands to Specify Files: | |
280 | +Files. | |
281 | + | |
282 | + The first thing GDB does after arranging to debug the specified | |
283 | +process is to stop it. You can examine and modify an attached process | |
284 | +with all the GDB commands that are ordinarily available when you start | |
285 | +processes with `run'. You can insert breakpoints; you can step and | |
286 | +continue; you can modify storage. If you would rather the process | |
287 | +continue running, you may use the `continue' command after attaching | |
288 | +GDB to the process. | |
289 | + | |
290 | +`detach' | |
291 | + When you have finished debugging the attached process, you can use | |
292 | + the `detach' command to release it from GDB control. Detaching | |
293 | + the process continues its execution. After the `detach' command, | |
294 | + that process and GDB become completely independent once more, and | |
295 | + you are ready to `attach' another process or start one with `run'. | |
296 | + `detach' does not repeat if you press <RET> again after executing | |
297 | + the command. | |
298 | + | |
299 | + If you exit GDB or use the `run' command while you have an attached | |
300 | +process, you kill that process. By default, GDB asks for confirmation | |
301 | +if you try to do either of these things; you can control whether or not | |
302 | +you need to confirm by using the `set confirm' command (*note Optional | |
303 | +warnings and messages: Messages/Warnings.). | |
304 | + | |
305 | + | |
306 | +File: gdb.info, Node: Kill Process, Next: Process Information, Prev: Attach, Up: Running | |
307 | + | |
308 | +Killing the child process | |
309 | +========================= | |
310 | + | |
311 | +`kill' | |
312 | + Kill the child process in which your program is running under GDB. | |
313 | + | |
314 | + This command is useful if you wish to debug a core dump instead of a | |
315 | +running process. GDB ignores any core dump file while your program is | |
316 | +running. | |
317 | + | |
318 | + On some operating systems, a program cannot be executed outside GDB | |
319 | +while you have breakpoints set on it inside GDB. You can use the | |
320 | +`kill' command in this situation to permit running your program outside | |
321 | +the debugger. | |
322 | + | |
323 | + The `kill' command is also useful if you wish to recompile and | |
324 | +relink your program, since on many systems it is impossible to modify an | |
325 | +executable file while it is running in a process. In this case, when | |
326 | +you next type `run', GDB notices that the file has changed, and reads | |
327 | +the symbol table again (while trying to preserve your current | |
328 | +breakpoint settings). | |
329 | + | |
330 | + | |
331 | +File: gdb.info, Node: Process Information, Next: Threads, Prev: Kill Process, Up: Running | |
332 | + | |
333 | +Additional process information | |
334 | +============================== | |
335 | + | |
336 | + Some operating systems provide a facility called `/proc' that can be | |
337 | +used to examine the image of a running process using file-system | |
338 | +subroutines. If GDB is configured for an operating system with this | |
339 | +facility, the command `info proc' is available to report on several | |
340 | +kinds of information about the process running your program. `info | |
341 | +proc' works only on SVR4 systems that support `procfs'. | |
342 | + | |
343 | +`info proc' | |
344 | + Summarize available information about the process. | |
345 | + | |
346 | +`info proc mappings' | |
347 | + Report on the address ranges accessible in the program, with | |
348 | + information on whether your program may read, write, or execute | |
349 | + each range. | |
350 | + | |
351 | +`info proc times' | |
352 | + Starting time, user CPU time, and system CPU time for your program | |
353 | + and its children. | |
354 | + | |
355 | +`info proc id' | |
356 | + Report on the process IDs related to your program: its own process | |
357 | + ID, the ID of its parent, the process group ID, and the session ID. | |
358 | + | |
359 | +`info proc status' | |
360 | + General information on the state of the process. If the process is | |
361 | + stopped, this report includes the reason for stopping, and any | |
362 | + signal received. | |
363 | + | |
364 | +`info proc all' | |
365 | + Show all the above information about the process. | |
366 | + | |
367 | + | |
368 | +File: gdb.info, Node: Threads, Next: Processes, Prev: Process Information, Up: Running | |
369 | + | |
370 | +Debugging programs with multiple threads | |
371 | +======================================== | |
372 | + | |
373 | + In some operating systems, such as HP-UX and Solaris, a single | |
374 | +program may have more than one "thread" of execution. The precise | |
375 | +semantics of threads differ from one operating system to another, but | |
376 | +in general the threads of a single program are akin to multiple | |
377 | +processes--except that they share one address space (that is, they can | |
378 | +all examine and modify the same variables). On the other hand, each | |
379 | +thread has its own registers and execution stack, and perhaps private | |
380 | +memory. | |
381 | + | |
382 | + GDB provides these facilities for debugging multi-thread programs: | |
383 | + | |
384 | + * automatic notification of new threads | |
385 | + | |
386 | + * `thread THREADNO', a command to switch among threads | |
387 | + | |
388 | + * `info threads', a command to inquire about existing threads | |
389 | + | |
390 | + * `thread apply [THREADNO] [ALL] ARGS', a command to apply a command | |
391 | + to a list of threads | |
392 | + | |
393 | + * thread-specific breakpoints | |
394 | + | |
395 | + *Warning:* These facilities are not yet available on every GDB | |
396 | + configuration where the operating system supports threads. If | |
397 | + your GDB does not support threads, these commands have no effect. | |
398 | + For example, a system without thread support shows no output from | |
399 | + `info threads', and always rejects the `thread' command, like this: | |
400 | + | |
401 | + (gdb) info threads | |
402 | + (gdb) thread 1 | |
403 | + Thread ID 1 not known. Use the "info threads" command to | |
404 | + see the IDs of currently known threads. | |
405 | + | |
406 | + The GDB thread debugging facility allows you to observe all threads | |
407 | +while your program runs--but whenever GDB takes control, one thread in | |
408 | +particular is always the focus of debugging. This thread is called the | |
409 | +"current thread". Debugging commands show program information from the | |
410 | +perspective of the current thread. | |
411 | + | |
412 | + Whenever GDB detects a new thread in your program, it displays the | |
413 | +target system's identification for the thread with a message in the | |
414 | +form `[New SYSTAG]'. SYSTAG is a thread identifier whose form varies | |
415 | +depending on the particular system. For example, on LynxOS, you might | |
416 | +see | |
417 | + | |
418 | + [New process 35 thread 27] | |
419 | + | |
420 | +when GDB notices a new thread. In contrast, on an SGI system, the | |
421 | +SYSTAG is simply something like `process 368', with no further | |
422 | +qualifier. | |
423 | + | |
424 | + For debugging purposes, GDB associates its own thread number--always | |
425 | +a single integer--with each thread in your program. | |
426 | + | |
427 | +`info threads' | |
428 | + Display a summary of all threads currently in your program. GDB | |
429 | + displays for each thread (in this order): | |
430 | + | |
431 | + 1. the thread number assigned by GDB | |
432 | + | |
433 | + 2. the target system's thread identifier (SYSTAG) | |
434 | + | |
435 | + 3. the current stack frame summary for that thread | |
436 | + | |
437 | + An asterisk `*' to the left of the GDB thread number indicates the | |
438 | + current thread. | |
439 | + | |
440 | + For example, | |
441 | + | |
442 | + (gdb) info threads | |
443 | + 3 process 35 thread 27 0x34e5 in sigpause () | |
444 | + 2 process 35 thread 23 0x34e5 in sigpause () | |
445 | + * 1 process 35 thread 13 main (argc=1, argv=0x7ffffff8) | |
446 | + at threadtest.c:68 | |
447 | + | |
448 | +`thread THREADNO' | |
449 | + Make thread number THREADNO the current thread. The command | |
450 | + argument THREADNO is the internal GDB thread number, as shown in | |
451 | + the first field of the `info threads' display. GDB responds by | |
452 | + displaying the system identifier of the thread you selected, and | |
453 | + its current stack frame summary: | |
454 | + | |
455 | + (gdb) thread 2 | |
456 | + [Switching to process 35 thread 23] | |
457 | + 0x34e5 in sigpause () | |
458 | + | |
459 | + As with the `[New ...]' message, the form of the text after | |
460 | + `Switching to' depends on your system's conventions for identifying | |
461 | + threads. | |
462 | + | |
463 | +`thread apply [THREADNO] [ALL] ARGS' | |
464 | + The `thread apply' command allows you to apply a command to one or | |
465 | + more threads. Specify the numbers of the threads that you want | |
466 | + affected with the command argument THREADNO. THREADNO is the | |
467 | + internal GDB thread number, as shown in the first field of the | |
468 | + `info threads' display. To apply a command to all threads, use | |
469 | + `thread apply all' ARGS. | |
470 | + | |
471 | + Whenever GDB stops your program, due to a breakpoint or a signal, it | |
472 | +automatically selects the thread where that breakpoint or signal | |
473 | +happened. GDB alerts you to the context switch with a message of the | |
474 | +form `[Switching to SYSTAG]' to identify the thread. | |
475 | + | |
476 | + *Note Stopping and starting multi-thread programs: Thread Stops, for | |
477 | +more information about how GDB behaves when you stop and start programs | |
478 | +with multiple threads. | |
479 | + | |
480 | + *Note Setting watchpoints: Set Watchpoints, for information about | |
481 | +watchpoints in programs with multiple threads. | |
482 | + | |
483 | + | |
484 | +File: gdb.info, Node: Processes, Prev: Threads, Up: Running | |
485 | + | |
486 | +Debugging programs with multiple processes | |
487 | +========================================== | |
488 | + | |
489 | + GDB has no special support for debugging programs which create | |
490 | +additional processes using the `fork' function. When a program forks, | |
491 | +GDB will continue to debug the parent process and the child process | |
492 | +will run unimpeded. If you have set a breakpoint in any code which the | |
493 | +child then executes, the child will get a `SIGTRAP' signal which | |
494 | +(unless it catches the signal) will cause it to terminate. | |
495 | + | |
496 | + However, if you want to debug the child process there is a workaround | |
497 | +which isn't too painful. Put a call to `sleep' in the code which the | |
498 | +child process executes after the fork. It may be useful to sleep only | |
499 | +if a certain environment variable is set, or a certain file exists, so | |
500 | +that the delay need not occur when you don't want to run GDB on the | |
501 | +child. While the child is sleeping, use the `ps' program to get its | |
502 | +process ID. Then tell GDB (a new invocation of GDB if you are also | |
503 | +debugging the parent process) to attach to the child process (see *Note | |
504 | +Attach::). From that point on you can debug the child process just | |
505 | +like any other process which you attached to. | |
506 | + | |
507 | + | |
508 | +File: gdb.info, Node: Stopping, Next: Stack, Prev: Running, Up: Top | |
509 | + | |
510 | +Stopping and Continuing | |
511 | +*********************** | |
512 | + | |
513 | + The principal purposes of using a debugger are so that you can stop | |
514 | +your program before it terminates; or so that, if your program runs into | |
515 | +trouble, you can investigate and find out why. | |
516 | + | |
517 | + Inside GDB, your program may stop for any of several reasons, such as | |
518 | +a signal, a breakpoint, or reaching a new line after a GDB command such | |
519 | +as `step'. You may then examine and change variables, set new | |
520 | +breakpoints or remove old ones, and then continue execution. Usually, | |
521 | +the messages shown by GDB provide ample explanation of the status of | |
522 | +your program--but you can also explicitly request this information at | |
523 | +any time. | |
524 | + | |
525 | +`info program' | |
526 | + Display information about the status of your program: whether it is | |
527 | + running or not, what process it is, and why it stopped. | |
528 | + | |
529 | +* Menu: | |
530 | + | |
531 | +* Breakpoints:: Breakpoints, watchpoints, and catchpoints | |
532 | +* Continuing and Stepping:: Resuming execution | |
533 | + | |
534 | +* Signals:: Signals | |
535 | + | |
536 | + | |
537 | +* Thread Stops:: Stopping and starting multi-thread programs | |
538 | + | |
539 | + | |
540 | +File: gdb.info, Node: Breakpoints, Next: Continuing and Stepping, Prev: Stopping, Up: Stopping | |
541 | + | |
542 | +Breakpoints, watchpoints, and catchpoints | |
543 | +========================================= | |
544 | + | |
545 | + A "breakpoint" makes your program stop whenever a certain point in | |
546 | +the program is reached. For each breakpoint, you can add conditions to | |
547 | +control in finer detail whether your program stops. You can set | |
548 | +breakpoints with the `break' command and its variants (*note Setting | |
549 | +breakpoints: Set Breaks.), to specify the place where your program | |
550 | +should stop by line number, function name or exact address in the | |
551 | +program. | |
552 | + | |
553 | + In HP-UX, SunOS 4.x, SVR4, and Alpha OSF/1 configurations, you can | |
554 | +set breakpoints in shared libraries before the executable is run. | |
555 | +There is a minor limitation on HP-UX systems: you must wait until the | |
556 | +executable is run in order to set breakpoints in shared library | |
557 | +routines that are not called directly by the program (for example, | |
558 | +routines that are arguments in a `pthread_create' call). | |
559 | + | |
560 | + A "watchpoint" is a special breakpoint that stops your program when | |
561 | +the value of an expression changes. You must use a different command | |
562 | +to set watchpoints (*note Setting watchpoints: Set Watchpoints.), but | |
563 | +aside from that, you can manage a watchpoint like any other breakpoint: | |
564 | +you enable, disable, and delete both breakpoints and watchpoints using | |
565 | +the same commands. | |
566 | + | |
567 | + You can arrange to have values from your program displayed | |
568 | +automatically whenever GDB stops at a breakpoint. *Note Automatic | |
569 | +display: Auto Display. | |
570 | + | |
571 | + A "catchpoint" is another special breakpoint that stops your program | |
572 | +when a certain kind of event occurs, such as the throwing of a C++ | |
573 | +exception or the loading of a library. As with watchpoints, you use a | |
574 | +different command to set a catchpoint (*note Setting catchpoints: Set | |
575 | +Catchpoints.), but aside from that, you can manage a catchpoint like any | |
576 | +other breakpoint. (To stop when your program receives a signal, use the | |
577 | +`handle' command; *note Signals: Signals..) | |
578 | + | |
579 | + GDB assigns a number to each breakpoint, watchpoint, or catchpoint | |
580 | +when you create it; these numbers are successive integers starting with | |
581 | +one. In many of the commands for controlling various features of | |
582 | +breakpoints you use the breakpoint number to say which breakpoint you | |
583 | +want to change. Each breakpoint may be "enabled" or "disabled"; if | |
584 | +disabled, it has no effect on your program until you enable it again. | |
585 | + | |
586 | +* Menu: | |
587 | + | |
588 | +* Set Breaks:: Setting breakpoints | |
589 | +* Set Watchpoints:: Setting watchpoints | |
590 | +* Set Catchpoints:: Setting catchpoints | |
591 | +* Delete Breaks:: Deleting breakpoints | |
592 | +* Disabling:: Disabling breakpoints | |
593 | +* Conditions:: Break conditions | |
594 | +* Break Commands:: Breakpoint command lists | |
595 | + | |
596 | +* Breakpoint Menus:: Breakpoint menus | |
597 | + | |
598 | + | |
599 | +File: gdb.info, Node: Set Breaks, Next: Set Watchpoints, Prev: Breakpoints, Up: Breakpoints | |
600 | + | |
601 | +Setting breakpoints | |
602 | +------------------- | |
603 | + | |
604 | + Breakpoints are set with the `break' command (abbreviated `b'). The | |
605 | +debugger convenience variable `$bpnum' records the number of the | |
606 | +breakpoints you've set most recently; see *Note Convenience variables: | |
607 | +Convenience Vars, for a discussion of what you can do with convenience | |
608 | +variables. | |
609 | + | |
610 | + You have several ways to say where the breakpoint should go. | |
611 | + | |
612 | +`break FUNCTION' | |
613 | + Set a breakpoint at entry to function FUNCTION. When using source | |
614 | + languages that permit overloading of symbols, such as C++, | |
615 | + FUNCTION may refer to more than one possible place to break. | |
616 | + *Note Breakpoint menus: Breakpoint Menus, for a discussion of that | |
617 | + situation. | |
618 | + | |
619 | +`break +OFFSET' | |
620 | +`break -OFFSET' | |
621 | + Set a breakpoint some number of lines forward or back from the | |
622 | + position at which execution stopped in the currently selected | |
623 | + frame. | |
624 | + | |
625 | +`break LINENUM' | |
626 | + Set a breakpoint at line LINENUM in the current source file. That | |
627 | + file is the last file whose source text was printed. This | |
628 | + breakpoint stops your program just before it executes any of the | |
629 | + code on that line. | |
630 | + | |
631 | +`break FILENAME:LINENUM' | |
632 | + Set a breakpoint at line LINENUM in source file FILENAME. | |
633 | + | |
634 | +`break FILENAME:FUNCTION' | |
635 | + Set a breakpoint at entry to function FUNCTION found in file | |
636 | + FILENAME. Specifying a file name as well as a function name is | |
637 | + superfluous except when multiple files contain similarly named | |
638 | + functions. | |
639 | + | |
640 | +`break *ADDRESS' | |
641 | + Set a breakpoint at address ADDRESS. You can use this to set | |
642 | + breakpoints in parts of your program which do not have debugging | |
643 | + information or source files. | |
644 | + | |
645 | +`break' | |
646 | + When called without any arguments, `break' sets a breakpoint at | |
647 | + the next instruction to be executed in the selected stack frame | |
648 | + (*note Examining the Stack: Stack.). In any selected frame but the | |
649 | + innermost, this makes your program stop as soon as control returns | |
650 | + to that frame. This is similar to the effect of a `finish' | |
651 | + command in the frame inside the selected frame--except that | |
652 | + `finish' does not leave an active breakpoint. If you use `break' | |
653 | + without an argument in the innermost frame, GDB stops the next | |
654 | + time it reaches the current location; this may be useful inside | |
655 | + loops. | |
656 | + | |
657 | + GDB normally ignores breakpoints when it resumes execution, until | |
658 | + at least one instruction has been executed. If it did not do | |
659 | + this, you would be unable to proceed past a breakpoint without | |
660 | + first disabling the breakpoint. This rule applies whether or not | |
661 | + the breakpoint already existed when your program stopped. | |
662 | + | |
663 | +`break ... if COND' | |
664 | + Set a breakpoint with condition COND; evaluate the expression COND | |
665 | + each time the breakpoint is reached, and stop only if the value is | |
666 | + nonzero--that is, if COND evaluates as true. `...' stands for one | |
667 | + of the possible arguments described above (or no argument) | |
668 | + specifying where to break. *Note Break conditions: Conditions, | |
669 | + for more information on breakpoint conditions. | |
670 | + | |
671 | +`tbreak ARGS' | |
672 | + Set a breakpoint enabled only for one stop. ARGS are the same as | |
673 | + for the `break' command, and the breakpoint is set in the same | |
674 | + way, but the breakpoint is automatically deleted after the first | |
675 | + time your program stops there. *Note Disabling breakpoints: | |
676 | + Disabling. | |
677 | + | |
678 | +`hbreak ARGS' | |
679 | + Set a hardware-assisted breakpoint. ARGS are the same as for the | |
680 | + `break' command and the breakpoint is set in the same way, but the | |
681 | + breakpoint requires hardware support and some target hardware may | |
682 | + not have this support. The main purpose of this is EPROM/ROM code | |
683 | + debugging, so you can set a breakpoint at an instruction without | |
684 | + changing the instruction. This can be used with the new | |
685 | + trap-generation provided by SPARClite DSU. DSU will generate | |
686 | + traps when a program accesses some data or instruction address | |
687 | + that is assigned to the debug registers. However the hardware | |
688 | + breakpoint registers can only take two data breakpoints, and GDB | |
689 | + will reject this command if more than two are used. Delete or | |
690 | + disable unused hardware breakpoints before setting new ones. | |
691 | + *Note Break conditions: Conditions. | |
692 | + | |
693 | +`thbreak ARGS' | |
694 | + Set a hardware-assisted breakpoint enabled only for one stop. ARGS | |
695 | + are the same as for the `hbreak' command and the breakpoint is set | |
696 | + in the same way. However, like the `tbreak' command, the | |
697 | + breakpoint is automatically deleted after the first time your | |
698 | + program stops there. Also, like the `hbreak' command, the | |
699 | + breakpoint requires hardware support and some target hardware may | |
700 | + not have this support. *Note Disabling breakpoints: Disabling. | |
701 | + Also *Note Break conditions: Conditions. | |
702 | + | |
703 | +`rbreak REGEX' | |
704 | + Set breakpoints on all functions matching the regular expression | |
705 | + REGEX. This command sets an unconditional breakpoint on all | |
706 | + matches, printing a list of all breakpoints it set. Once these | |
707 | + breakpoints are set, they are treated just like the breakpoints | |
708 | + set with the `break' command. You can delete them, disable them, | |
709 | + or make them conditional the same way as any other breakpoint. | |
710 | + | |
711 | + When debugging C++ programs, `rbreak' is useful for setting | |
712 | + breakpoints on overloaded functions that are not members of any | |
713 | + special classes. | |
714 | + | |
715 | +`info breakpoints [N]' | |
716 | +`info break [N]' | |
717 | +`info watchpoints [N]' | |
718 | + Print a table of all breakpoints, watchpoints, and catchpoints set | |
719 | + and not deleted, with the following columns for each breakpoint: | |
720 | + | |
721 | + *Breakpoint Numbers* | |
722 | + | |
723 | + *Type* | |
724 | + Breakpoint, watchpoint, or catchpoint. | |
725 | + | |
726 | + *Disposition* | |
727 | + Whether the breakpoint is marked to be disabled or deleted | |
728 | + when hit. | |
729 | + | |
730 | + *Enabled or Disabled* | |
731 | + Enabled breakpoints are marked with `y'. `n' marks | |
732 | + breakpoints that are not enabled. | |
733 | + | |
734 | + *Address* | |
735 | + Where the breakpoint is in your program, as a memory address | |
736 | + | |
737 | + *What* | |
738 | + Where the breakpoint is in the source for your program, as a | |
739 | + file and line number. | |
740 | + | |
741 | + If a breakpoint is conditional, `info break' shows the condition on | |
742 | + the line following the affected breakpoint; breakpoint commands, | |
743 | + if any, are listed after that. | |
744 | + | |
745 | + `info break' with a breakpoint number N as argument lists only | |
746 | + that breakpoint. The convenience variable `$_' and the default | |
747 | + examining-address for the `x' command are set to the address of | |
748 | + the last breakpoint listed (*note Examining memory: Memory.). | |
749 | + | |
750 | + `info break' displays a count of the number of times the breakpoint | |
751 | + has been hit. This is especially useful in conjunction with the | |
752 | + `ignore' command. You can ignore a large number of breakpoint | |
753 | + hits, look at the breakpoint info to see how many times the | |
754 | + breakpoint was hit, and then run again, ignoring one less than | |
755 | + that number. This will get you quickly to the last hit of that | |
756 | + breakpoint. | |
757 | + | |
758 | + GDB allows you to set any number of breakpoints at the same place in | |
759 | +your program. There is nothing silly or meaningless about this. When | |
760 | +the breakpoints are conditional, this is even useful (*note Break | |
761 | +conditions: Conditions.). | |
762 | + | |
763 | + GDB itself sometimes sets breakpoints in your program for special | |
764 | +purposes, such as proper handling of `longjmp' (in C programs). These | |
765 | +internal breakpoints are assigned negative numbers, starting with `-1'; | |
766 | +`info breakpoints' does not display them. | |
767 | + | |
768 | + You can see these breakpoints with the GDB maintenance command | |
769 | +`maint info breakpoints'. | |
770 | + | |
771 | +`maint info breakpoints' | |
772 | + Using the same format as `info breakpoints', display both the | |
773 | + breakpoints you've set explicitly, and those GDB is using for | |
774 | + internal purposes. Internal breakpoints are shown with negative | |
775 | + breakpoint numbers. The type column identifies what kind of | |
776 | + breakpoint is shown: | |
777 | + | |
778 | + `breakpoint' | |
779 | + Normal, explicitly set breakpoint. | |
780 | + | |
781 | + `watchpoint' | |
782 | + Normal, explicitly set watchpoint. | |
783 | + | |
784 | + `longjmp' | |
785 | + Internal breakpoint, used to handle correctly stepping through | |
786 | + `longjmp' calls. | |
787 | + | |
788 | + `longjmp resume' | |
789 | + Internal breakpoint at the target of a `longjmp'. | |
790 | + | |
791 | + `until' | |
792 | + Temporary internal breakpoint used by the GDB `until' command. | |
793 | + | |
794 | + `finish' | |
795 | + Temporary internal breakpoint used by the GDB `finish' | |
796 | + command. | |
797 | + | |
798 | + | |
799 | +File: gdb.info, Node: Set Watchpoints, Next: Set Catchpoints, Prev: Set Breaks, Up: Breakpoints | |
800 | + | |
801 | +Setting watchpoints | |
802 | +------------------- | |
803 | + | |
804 | + You can use a watchpoint to stop execution whenever the value of an | |
805 | +expression changes, without having to predict a particular place where | |
806 | +this may happen. | |
807 | + | |
808 | + Depending on your system, watchpoints may be implemented in software | |
809 | +or hardware. GDB does software watchpointing by single-stepping your | |
810 | +program and testing the variable's value each time, which is hundreds of | |
811 | +times slower than normal execution. (But this may still be worth it, to | |
812 | +catch errors where you have no clue what part of your program is the | |
813 | +culprit.) | |
814 | + | |
815 | + On some systems, such as HP-UX and Linux, GDB includes support for | |
816 | +hardware watchpoints, which do not slow down the running of your | |
817 | +program. | |
818 | + | |
819 | +`watch EXPR' | |
820 | + Set a watchpoint for an expression. GDB will break when EXPR is | |
821 | + written into by the program and its value changes. | |
822 | + | |
823 | +`rwatch EXPR' | |
824 | + Set a watchpoint that will break when watch EXPR is read by the | |
825 | + program. If you use both watchpoints, both must be set with the | |
826 | + `rwatch' command. | |
827 | + | |
828 | +`awatch EXPR' | |
829 | + Set a watchpoint that will break when ARGS is read and written into | |
830 | + by the program. If you use both watchpoints, both must be set | |
831 | + with the `awatch' command. | |
832 | + | |
833 | +`info watchpoints' | |
834 | + This command prints a list of watchpoints, breakpoints, and | |
835 | + catchpoints; it is the same as `info break'. | |
836 | + | |
837 | + GDB sets a "hardware watchpoint" if possible. Hardware watchpoints | |
838 | +execute very quickly, and the debugger reports a change in value at the | |
839 | +exact instruction where the change occurs. If GDB cannot set a | |
840 | +hardware watchpoint, it sets a software watchpoint, which executes more | |
841 | +slowly and reports the change in value at the next statement, not the | |
842 | +instruction, after the change occurs. | |
843 | + | |
844 | + When you issue the `watch' command, GDB reports | |
845 | + | |
846 | + Hardware watchpoint NUM: EXPR | |
847 | + | |
848 | +if it was able to set a hardware watchpoint. | |
849 | + | |
850 | + The SPARClite DSU will generate traps when a program accesses some | |
851 | +data or instruction address that is assigned to the debug registers. | |
852 | +For the data addresses, DSU facilitates the `watch' command. However | |
853 | +the hardware breakpoint registers can only take two data watchpoints, | |
854 | +and both watchpoints must be the same kind. For example, you can set | |
855 | +two watchpoints with `watch' commands, two with `rwatch' commands, *or* | |
856 | +two with `awatch' commands, but you cannot set one watchpoint with one | |
857 | +command and the other with a different command. GDB will reject the | |
858 | +command if you try to mix watchpoints. Delete or disable unused | |
859 | +watchpoint commands before setting new ones. | |
860 | + | |
861 | + If you call a function interactively using `print' or `call', any | |
862 | +watchpoints you have set will be inactive until GDB reaches another | |
863 | +kind of breakpoint or the call completes. | |
864 | + | |
865 | + *Warning:* In multi-thread programs, watchpoints have only limited | |
866 | + usefulness. With the current watchpoint implementation, GDB can | |
867 | + only watch the value of an expression *in a single thread*. If | |
868 | + you are confident that the expression can only change due to the | |
869 | + current thread's activity (and if you are also confident that no | |
870 | + other thread can become current), then you can use watchpoints as | |
871 | + usual. However, GDB may not notice when a non-current thread's | |
872 | + activity changes the expression. | |
873 | + | |
874 | + | |
875 | +File: gdb.info, Node: Set Catchpoints, Next: Delete Breaks, Prev: Set Watchpoints, Up: Breakpoints | |
876 | + | |
877 | +Setting catchpoints | |
878 | +------------------- | |
879 | + | |
880 | + You can use "catchpoints" to cause the debugger to stop for certain | |
881 | +kinds of program events, such as C++ exceptions or the loading of a | |
882 | +shared library. Use the `catch' command to set a catchpoint. | |
883 | + | |
884 | +`catch EVENT' | |
885 | + Stop when EVENT occurs. EVENT can be any of the following: | |
886 | + `throw' | |
887 | + The throwing of a C++ exception. | |
888 | + | |
889 | + `catch' | |
890 | + The catching of a C++ exception. | |
891 | + | |
892 | + `exec' | |
893 | + A call to `exec'. This is currently only available for HP-UX. | |
894 | + | |
895 | + `fork' | |
896 | + A call to `fork'. This is currently only available for HP-UX. | |
897 | + | |
898 | + `vfork' | |
899 | + A call to `vfork'. This is currently only available for | |
900 | + HP-UX. | |
901 | + | |
902 | + `load' | |
903 | + `load LIBNAME' | |
904 | + The dynamic loading of any shared library, or the loading of | |
905 | + the library LIBNAME. This is currently only available for | |
906 | + HP-UX. | |
907 | + | |
908 | + `unload' | |
909 | + `unload LIBNAME' | |
910 | + The unloading of any dynamically loaded shared library, or | |
911 | + the unloading of the library LIBNAME. This is currently only | |
912 | + available for HP-UX. | |
913 | + | |
914 | +`tcatch EVENT' | |
915 | + Set a catchpoint that is enabled only for one stop. The | |
916 | + catchpoint is automatically deleted after the first time the event | |
917 | + is caught. | |
918 | + | |
919 | + Use the `info break' command to list the current catchpoints. | |
920 | + | |
921 | + There are currently some limitations to C++ exception handling | |
922 | +(`catch throw' and `catch catch') in GDB: | |
923 | + | |
924 | + * If you call a function interactively, GDB normally returns control | |
925 | + to you when the function has finished executing. If the call | |
926 | + raises an exception, however, the call may bypass the mechanism | |
927 | + that returns control to you and cause your program either to abort | |
928 | + or to simply continue running until it hits a breakpoint, catches | |
929 | + a signal that GDB is listening for, or exits. This is the case | |
930 | + even if you set a catchpoint for the exception; catchpoints on | |
931 | + exceptions are disabled within interactive calls. | |
932 | + | |
933 | + * You cannot raise an exception interactively. | |
934 | + | |
935 | + * You cannot install an exception handler interactively. | |
936 | + | |
937 | + Sometimes `catch' is not the best way to debug exception handling: | |
938 | +if you need to know exactly where an exception is raised, it is better | |
939 | +to stop *before* the exception handler is called, since that way you | |
940 | +can see the stack before any unwinding takes place. If you set a | |
941 | +breakpoint in an exception handler instead, it may not be easy to find | |
942 | +out where the exception was raised. | |
943 | + | |
944 | + To stop just before an exception handler is called, you need some | |
945 | +knowledge of the implementation. In the case of GNU C++, exceptions are | |
946 | +raised by calling a library function named `__raise_exception' which | |
947 | +has the following ANSI C interface: | |
948 | + | |
949 | + /* ADDR is where the exception identifier is stored. | |
950 | + ID is the exception identifier. */ | |
951 | + void __raise_exception (void **ADDR, void *ID); | |
952 | + | |
953 | +To make the debugger catch all exceptions before any stack unwinding | |
954 | +takes place, set a breakpoint on `__raise_exception' (*note | |
955 | +Breakpoints; watchpoints; and exceptions: Breakpoints.). | |
956 | + | |
957 | + With a conditional breakpoint (*note Break conditions: Conditions.) | |
958 | +that depends on the value of ID, you can stop your program when a | |
959 | +specific exception is raised. You can use multiple conditional | |
960 | +breakpoints to stop your program when any of a number of exceptions are | |
961 | +raised. | |
962 | + | |
963 | + | |
964 | +File: gdb.info, Node: Delete Breaks, Next: Disabling, Prev: Set Catchpoints, Up: Breakpoints | |
965 | + | |
966 | +Deleting breakpoints | |
967 | +-------------------- | |
968 | + | |
969 | + It is often necessary to eliminate a breakpoint, watchpoint, or | |
970 | +catchpoint once it has done its job and you no longer want your program | |
971 | +to stop there. This is called "deleting" the breakpoint. A breakpoint | |
972 | +that has been deleted no longer exists; it is forgotten. | |
973 | + | |
974 | + With the `clear' command you can delete breakpoints according to | |
975 | +where they are in your program. With the `delete' command you can | |
976 | +delete individual breakpoints, watchpoints, or catchpoints by specifying | |
977 | +their breakpoint numbers. | |
978 | + | |
979 | + It is not necessary to delete a breakpoint to proceed past it. GDB | |
980 | +automatically ignores breakpoints on the first instruction to be | |
981 | +executed when you continue execution without changing the execution | |
982 | +address. | |
983 | + | |
984 | +`clear' | |
985 | + Delete any breakpoints at the next instruction to be executed in | |
986 | + the selected stack frame (*note Selecting a frame: Selection.). | |
987 | + When the innermost frame is selected, this is a good way to delete | |
988 | + a breakpoint where your program just stopped. | |
989 | + | |
990 | +`clear FUNCTION' | |
991 | +`clear FILENAME:FUNCTION' | |
992 | + Delete any breakpoints set at entry to the function FUNCTION. | |
993 | + | |
994 | +`clear LINENUM' | |
995 | +`clear FILENAME:LINENUM' | |
996 | + Delete any breakpoints set at or within the code of the specified | |
997 | + line. | |
998 | + | |
999 | +`delete [breakpoints] [BNUMS...]' | |
1000 | + Delete the breakpoints, watchpoints, or catchpoints of the numbers | |
1001 | + specified as arguments. If no argument is specified, delete all | |
1002 | + breakpoints (GDB asks confirmation, unless you have `set confirm | |
1003 | + off'). You can abbreviate this command as `d'. | |
1004 | + | |
1005 | + | |
1006 | +File: gdb.info, Node: Disabling, Next: Conditions, Prev: Delete Breaks, Up: Breakpoints | |
1007 | + | |
1008 | +Disabling breakpoints | |
1009 | +--------------------- | |
1010 | + | |
1011 | + Rather than deleting a breakpoint, watchpoint, or catchpoint, you | |
1012 | +might prefer to "disable" it. This makes the breakpoint inoperative as | |
1013 | +if it had been deleted, but remembers the information on the breakpoint | |
1014 | +so that you can "enable" it again later. | |
1015 | + | |
1016 | + You disable and enable breakpoints, watchpoints, and catchpoints with | |
1017 | +the `enable' and `disable' commands, optionally specifying one or more | |
1018 | +breakpoint numbers as arguments. Use `info break' or `info watch' to | |
1019 | +print a list of breakpoints, watchpoints, and catchpoints if you do not | |
1020 | +know which numbers to use. | |
1021 | + | |
1022 | + A breakpoint, watchpoint, or catchpoint can have any of four | |
1023 | +different states of enablement: | |
1024 | + | |
1025 | + * Enabled. The breakpoint stops your program. A breakpoint set | |
1026 | + with the `break' command starts out in this state. | |
1027 | + | |
1028 | + * Disabled. The breakpoint has no effect on your program. | |
1029 | + | |
1030 | + * Enabled once. The breakpoint stops your program, but then becomes | |
1031 | + disabled. A breakpoint set with the `tbreak' command starts out in | |
1032 | + this state. | |
1033 | + | |
1034 | + * Enabled for deletion. The breakpoint stops your program, but | |
1035 | + immediately after it does so it is deleted permanently. | |
1036 | + | |
1037 | + You can use the following commands to enable or disable breakpoints, | |
1038 | +watchpoints, and catchpoints: | |
1039 | + | |
1040 | +`disable [breakpoints] [BNUMS...]' | |
1041 | + Disable the specified breakpoints--or all breakpoints, if none are | |
1042 | + listed. A disabled breakpoint has no effect but is not forgotten. | |
1043 | + All options such as ignore-counts, conditions and commands are | |
1044 | + remembered in case the breakpoint is enabled again later. You may | |
1045 | + abbreviate `disable' as `dis'. | |
1046 | + | |
1047 | +`enable [breakpoints] [BNUMS...]' | |
1048 | + Enable the specified breakpoints (or all defined breakpoints). | |
1049 | + They become effective once again in stopping your program. | |
1050 | + | |
1051 | +`enable [breakpoints] once BNUMS...' | |
1052 | + Enable the specified breakpoints temporarily. GDB disables any of | |
1053 | + these breakpoints immediately after stopping your program. | |
1054 | + | |
1055 | +`enable [breakpoints] delete BNUMS...' | |
1056 | + Enable the specified breakpoints to work once, then die. GDB | |
1057 | + deletes any of these breakpoints as soon as your program stops | |
1058 | + there. | |
1059 | + | |
1060 | + Except for a breakpoint set with `tbreak' (*note Setting | |
1061 | +breakpoints: Set Breaks.), breakpoints that you set are initially | |
1062 | +enabled; subsequently, they become disabled or enabled only when you | |
1063 | +use one of the commands above. (The command `until' can set and delete | |
1064 | +a breakpoint of its own, but it does not change the state of your other | |
1065 | +breakpoints; see *Note Continuing and stepping: Continuing and | |
1066 | +Stepping.) | |
1067 | + | |
1068 | + | |
1069 | +File: gdb.info, Node: Conditions, Next: Break Commands, Prev: Disabling, Up: Breakpoints | |
1070 | + | |
1071 | +Break conditions | |
1072 | +---------------- | |
1073 | + | |
1074 | + The simplest sort of breakpoint breaks every time your program | |
1075 | +reaches a specified place. You can also specify a "condition" for a | |
1076 | +breakpoint. A condition is just a Boolean expression in your | |
1077 | +programming language (*note Expressions: Expressions.). A breakpoint | |
1078 | +with a condition evaluates the expression each time your program | |
1079 | +reaches it, and your program stops only if the condition is *true*. | |
1080 | + | |
1081 | + This is the converse of using assertions for program validation; in | |
1082 | +that situation, you want to stop when the assertion is violated--that | |
1083 | +is, when the condition is false. In C, if you want to test an | |
1084 | +assertion expressed by the condition ASSERT, you should set the | |
1085 | +condition `! ASSERT' on the appropriate breakpoint. | |
1086 | + | |
1087 | + Conditions are also accepted for watchpoints; you may not need them, | |
1088 | +since a watchpoint is inspecting the value of an expression anyhow--but | |
1089 | +it might be simpler, say, to just set a watchpoint on a variable name, | |
1090 | +and specify a condition that tests whether the new value is an | |
1091 | +interesting one. | |
1092 | + | |
1093 | + Break conditions can have side effects, and may even call functions | |
1094 | +in your program. This can be useful, for example, to activate functions | |
1095 | +that log program progress, or to use your own print functions to format | |
1096 | +special data structures. The effects are completely predictable unless | |
1097 | +there is another enabled breakpoint at the same address. (In that | |
1098 | +case, GDB might see the other breakpoint first and stop your program | |
1099 | +without checking the condition of this one.) Note that breakpoint | |
1100 | +commands are usually more convenient and flexible for the purpose of | |
1101 | +performing side effects when a breakpoint is reached (*note Breakpoint | |
1102 | +command lists: Break Commands.). | |
1103 | + | |
1104 | + Break conditions can be specified when a breakpoint is set, by using | |
1105 | +`if' in the arguments to the `break' command. *Note Setting | |
1106 | +breakpoints: Set Breaks. They can also be changed at any time with the | |
1107 | +`condition' command. The `watch' command does not recognize the `if' | |
1108 | +keyword; `condition' is the only way to impose a further condition on a | |
1109 | +watchpoint. | |
1110 | + | |
1111 | +`condition BNUM EXPRESSION' | |
1112 | + Specify EXPRESSION as the break condition for breakpoint, | |
1113 | + watchpoint, or catchpoint number BNUM. After you set a condition, | |
1114 | + breakpoint BNUM stops your program only if the value of EXPRESSION | |
1115 | + is true (nonzero, in C). When you use `condition', GDB checks | |
1116 | + EXPRESSION immediately for syntactic correctness, and to determine | |
1117 | + whether symbols in it have referents in the context of your | |
1118 | + breakpoint. GDB does not actually evaluate EXPRESSION at the time | |
1119 | + the `condition' command is given, however. *Note Expressions: | |
1120 | + Expressions. | |
1121 | + | |
1122 | +`condition BNUM' | |
1123 | + Remove the condition from breakpoint number BNUM. It becomes an | |
1124 | + ordinary unconditional breakpoint. | |
1125 | + | |
1126 | + A special case of a breakpoint condition is to stop only when the | |
1127 | +breakpoint has been reached a certain number of times. This is so | |
1128 | +useful that there is a special way to do it, using the "ignore count" | |
1129 | +of the breakpoint. Every breakpoint has an ignore count, which is an | |
1130 | +integer. Most of the time, the ignore count is zero, and therefore has | |
1131 | +no effect. But if your program reaches a breakpoint whose ignore count | |
1132 | +is positive, then instead of stopping, it just decrements the ignore | |
1133 | +count by one and continues. As a result, if the ignore count value is | |
1134 | +N, the breakpoint does not stop the next N times your program reaches | |
1135 | +it. | |
1136 | + | |
1137 | +`ignore BNUM COUNT' | |
1138 | + Set the ignore count of breakpoint number BNUM to COUNT. The next | |
1139 | + COUNT times the breakpoint is reached, your program's execution | |
1140 | + does not stop; other than to decrement the ignore count, GDB takes | |
1141 | + no action. | |
1142 | + | |
1143 | + To make the breakpoint stop the next time it is reached, specify a | |
1144 | + count of zero. | |
1145 | + | |
1146 | + When you use `continue' to resume execution of your program from a | |
1147 | + breakpoint, you can specify an ignore count directly as an | |
1148 | + argument to `continue', rather than using `ignore'. *Note | |
1149 | + Continuing and stepping: Continuing and Stepping. | |
1150 | + | |
1151 | + If a breakpoint has a positive ignore count and a condition, the | |
1152 | + condition is not checked. Once the ignore count reaches zero, GDB | |
1153 | + resumes checking the condition. | |
1154 | + | |
1155 | + You could achieve the effect of the ignore count with a condition | |
1156 | + such as `$foo-- <= 0' using a debugger convenience variable that | |
1157 | + is decremented each time. *Note Convenience variables: | |
1158 | + Convenience Vars. | |
1159 | + | |
1160 | + Ignore counts apply to breakpoints, watchpoints, and catchpoints. | |
1161 | + |
@@ -0,0 +1,1224 @@ | ||
1 | +This is Info file ./gdb.info, produced by Makeinfo version 1.68 from | |
2 | +the input file gdb.texinfo. | |
3 | + | |
4 | +START-INFO-DIR-ENTRY | |
5 | +* Gdb: (gdb). The GNU debugger. | |
6 | +END-INFO-DIR-ENTRY | |
7 | + This file documents the GNU debugger GDB. | |
8 | + | |
9 | + This is the Seventh Edition, February 1999, of `Debugging with GDB: | |
10 | +the GNU Source-Level Debugger' for GDB Version 4.18. | |
11 | + | |
12 | + Copyright (C) 1988-1999 Free Software Foundation, Inc. | |
13 | + | |
14 | + Permission is granted to make and distribute verbatim copies of this | |
15 | +manual provided the copyright notice and this permission notice are | |
16 | +preserved on all copies. | |
17 | + | |
18 | + Permission is granted to copy and distribute modified versions of | |
19 | +this manual under the conditions for verbatim copying, provided also | |
20 | +that the entire resulting derived work is distributed under the terms | |
21 | +of a permission notice identical to this one. | |
22 | + | |
23 | + Permission is granted to copy and distribute translations of this | |
24 | +manual into another language, under the above conditions for modified | |
25 | +versions. | |
26 | + | |
27 | + | |
28 | +File: gdb.info, Node: Break Commands, Next: Breakpoint Menus, Prev: Conditions, Up: Breakpoints | |
29 | + | |
30 | +Breakpoint command lists | |
31 | +------------------------ | |
32 | + | |
33 | + You can give any breakpoint (or watchpoint or catchpoint) a series of | |
34 | +commands to execute when your program stops due to that breakpoint. For | |
35 | +example, you might want to print the values of certain expressions, or | |
36 | +enable other breakpoints. | |
37 | + | |
38 | +`commands [BNUM]' | |
39 | +`... COMMAND-LIST ...' | |
40 | +`end' | |
41 | + Specify a list of commands for breakpoint number BNUM. The | |
42 | + commands themselves appear on the following lines. Type a line | |
43 | + containing just `end' to terminate the commands. | |
44 | + | |
45 | + To remove all commands from a breakpoint, type `commands' and | |
46 | + follow it immediately with `end'; that is, give no commands. | |
47 | + | |
48 | + With no BNUM argument, `commands' refers to the last breakpoint, | |
49 | + watchpoint, or catchpoint set (not to the breakpoint most recently | |
50 | + encountered). | |
51 | + | |
52 | + Pressing <RET> as a means of repeating the last GDB command is | |
53 | +disabled within a COMMAND-LIST. | |
54 | + | |
55 | + You can use breakpoint commands to start your program up again. | |
56 | +Simply use the `continue' command, or `step', or any other command that | |
57 | +resumes execution. | |
58 | + | |
59 | + Any other commands in the command list, after a command that resumes | |
60 | +execution, are ignored. This is because any time you resume execution | |
61 | +(even with a simple `next' or `step'), you may encounter another | |
62 | +breakpoint--which could have its own command list, leading to | |
63 | +ambiguities about which list to execute. | |
64 | + | |
65 | + If the first command you specify in a command list is `silent', the | |
66 | +usual message about stopping at a breakpoint is not printed. This may | |
67 | +be desirable for breakpoints that are to print a specific message and | |
68 | +then continue. If none of the remaining commands print anything, you | |
69 | +see no sign that the breakpoint was reached. `silent' is meaningful | |
70 | +only at the beginning of a breakpoint command list. | |
71 | + | |
72 | + The commands `echo', `output', and `printf' allow you to print | |
73 | +precisely controlled output, and are often useful in silent | |
74 | +breakpoints. *Note Commands for controlled output: Output. | |
75 | + | |
76 | + For example, here is how you could use breakpoint commands to print | |
77 | +the value of `x' at entry to `foo' whenever `x' is positive. | |
78 | + | |
79 | + break foo if x>0 | |
80 | + commands | |
81 | + silent | |
82 | + printf "x is %d\n",x | |
83 | + cont | |
84 | + end | |
85 | + | |
86 | + One application for breakpoint commands is to compensate for one bug | |
87 | +so you can test for another. Put a breakpoint just after the erroneous | |
88 | +line of code, give it a condition to detect the case in which something | |
89 | +erroneous has been done, and give it commands to assign correct values | |
90 | +to any variables that need them. End with the `continue' command so | |
91 | +that your program does not stop, and start with the `silent' command so | |
92 | +that no output is produced. Here is an example: | |
93 | + | |
94 | + break 403 | |
95 | + commands | |
96 | + silent | |
97 | + set x = y + 4 | |
98 | + cont | |
99 | + end | |
100 | + | |
101 | + | |
102 | +File: gdb.info, Node: Breakpoint Menus, Prev: Break Commands, Up: Breakpoints | |
103 | + | |
104 | +Breakpoint menus | |
105 | +---------------- | |
106 | + | |
107 | + Some programming languages (notably C++) permit a single function | |
108 | +name to be defined several times, for application in different contexts. | |
109 | +This is called "overloading". When a function name is overloaded, | |
110 | +`break FUNCTION' is not enough to tell GDB where you want a breakpoint. | |
111 | +If you realize this is a problem, you can use something like `break | |
112 | +FUNCTION(TYPES)' to specify which particular version of the function | |
113 | +you want. Otherwise, GDB offers you a menu of numbered choices for | |
114 | +different possible breakpoints, and waits for your selection with the | |
115 | +prompt `>'. The first two options are always `[0] cancel' and `[1] | |
116 | +all'. Typing `1' sets a breakpoint at each definition of FUNCTION, and | |
117 | +typing `0' aborts the `break' command without setting any new | |
118 | +breakpoints. | |
119 | + | |
120 | + For example, the following session excerpt shows an attempt to set a | |
121 | +breakpoint at the overloaded symbol `String::after'. We choose three | |
122 | +particular definitions of that function name: | |
123 | + | |
124 | + (gdb) b String::after | |
125 | + [0] cancel | |
126 | + [1] all | |
127 | + [2] file:String.cc; line number:867 | |
128 | + [3] file:String.cc; line number:860 | |
129 | + [4] file:String.cc; line number:875 | |
130 | + [5] file:String.cc; line number:853 | |
131 | + [6] file:String.cc; line number:846 | |
132 | + [7] file:String.cc; line number:735 | |
133 | + > 2 4 6 | |
134 | + Breakpoint 1 at 0xb26c: file String.cc, line 867. | |
135 | + Breakpoint 2 at 0xb344: file String.cc, line 875. | |
136 | + Breakpoint 3 at 0xafcc: file String.cc, line 846. | |
137 | + Multiple breakpoints were set. | |
138 | + Use the "delete" command to delete unwanted | |
139 | + breakpoints. | |
140 | + (gdb) | |
141 | + | |
142 | + | |
143 | +File: gdb.info, Node: Continuing and Stepping, Next: Signals, Prev: Breakpoints, Up: Stopping | |
144 | + | |
145 | +Continuing and stepping | |
146 | +======================= | |
147 | + | |
148 | + "Continuing" means resuming program execution until your program | |
149 | +completes normally. In contrast, "stepping" means executing just one | |
150 | +more "step" of your program, where "step" may mean either one line of | |
151 | +source code, or one machine instruction (depending on what particular | |
152 | +command you use). Either when continuing or when stepping, your | |
153 | +program may stop even sooner, due to a breakpoint or a signal. (If due | |
154 | +to a signal, you may want to use `handle', or use `signal 0' to resume | |
155 | +execution. *Note Signals: Signals.) | |
156 | + | |
157 | +`continue [IGNORE-COUNT]' | |
158 | +`c [IGNORE-COUNT]' | |
159 | +`fg [IGNORE-COUNT]' | |
160 | + Resume program execution, at the address where your program last | |
161 | + stopped; any breakpoints set at that address are bypassed. The | |
162 | + optional argument IGNORE-COUNT allows you to specify a further | |
163 | + number of times to ignore a breakpoint at this location; its | |
164 | + effect is like that of `ignore' (*note Break conditions: | |
165 | + Conditions.). | |
166 | + | |
167 | + The argument IGNORE-COUNT is meaningful only when your program | |
168 | + stopped due to a breakpoint. At other times, the argument to | |
169 | + `continue' is ignored. | |
170 | + | |
171 | + The synonyms `c' and `fg' are provided purely for convenience, and | |
172 | + have exactly the same behavior as `continue'. | |
173 | + | |
174 | + To resume execution at a different place, you can use `return' | |
175 | +(*note Returning from a function: Returning.) to go back to the calling | |
176 | +function; or `jump' (*note Continuing at a different address: Jumping.) | |
177 | +to go to an arbitrary location in your program. | |
178 | + | |
179 | + A typical technique for using stepping is to set a breakpoint (*note | |
180 | +Breakpoints; watchpoints; and catchpoints: Breakpoints.) at the | |
181 | +beginning of the function or the section of your program where a problem | |
182 | +is believed to lie, run your program until it stops at that breakpoint, | |
183 | +and then step through the suspect area, examining the variables that are | |
184 | +interesting, until you see the problem happen. | |
185 | + | |
186 | +`step' | |
187 | + Continue running your program until control reaches a different | |
188 | + source line, then stop it and return control to GDB. This command | |
189 | + is abbreviated `s'. | |
190 | + | |
191 | + *Warning:* If you use the `step' command while control is | |
192 | + within a function that was compiled without debugging | |
193 | + information, execution proceeds until control reaches a | |
194 | + function that does have debugging information. Likewise, it | |
195 | + will not step into a function which is compiled without | |
196 | + debugging information. To step through functions without | |
197 | + debugging information, use the `stepi' command, described | |
198 | + below. | |
199 | + | |
200 | + The `step' command now only stops at the first instruction of a | |
201 | + source line. This prevents the multiple stops that used to occur | |
202 | + in switch statements, for loops, etc. `step' continues to stop if | |
203 | + a function that has debugging information is called within the | |
204 | + line. | |
205 | + | |
206 | + Also, the `step' command now only enters a subroutine if there is | |
207 | + line number information for the subroutine. Otherwise it acts | |
208 | + like the `next' command. This avoids problems when using `cc -gl' | |
209 | + on MIPS machines. Previously, `step' entered subroutines if there | |
210 | + was any debugging information about the routine. | |
211 | + | |
212 | +`step COUNT' | |
213 | + Continue running as in `step', but do so COUNT times. If a | |
214 | + breakpoint is reached, or a signal not related to stepping occurs | |
215 | + before COUNT steps, stepping stops right away. | |
216 | + | |
217 | +`next [COUNT]' | |
218 | + Continue to the next source line in the current (innermost) stack | |
219 | + frame. This is similar to `step', but function calls that appear | |
220 | + within the line of code are executed without stopping. Execution | |
221 | + stops when control reaches a different line of code at the | |
222 | + original stack level that was executing when you gave the `next' | |
223 | + command. This command is abbreviated `n'. | |
224 | + | |
225 | + An argument COUNT is a repeat count, as for `step'. | |
226 | + | |
227 | + The `next' command now only stops at the first instruction of a | |
228 | + source line. This prevents the multiple stops that used to occur | |
229 | + in switch statements, for loops, etc. | |
230 | + | |
231 | +`finish' | |
232 | + Continue running until just after function in the selected stack | |
233 | + frame returns. Print the returned value (if any). | |
234 | + | |
235 | + Contrast this with the `return' command (*note Returning from a | |
236 | + function: Returning.). | |
237 | + | |
238 | +`until' | |
239 | +`u' | |
240 | + Continue running until a source line past the current line, in the | |
241 | + current stack frame, is reached. This command is used to avoid | |
242 | + single stepping through a loop more than once. It is like the | |
243 | + `next' command, except that when `until' encounters a jump, it | |
244 | + automatically continues execution until the program counter is | |
245 | + greater than the address of the jump. | |
246 | + | |
247 | + This means that when you reach the end of a loop after single | |
248 | + stepping though it, `until' makes your program continue execution | |
249 | + until it exits the loop. In contrast, a `next' command at the end | |
250 | + of a loop simply steps back to the beginning of the loop, which | |
251 | + forces you to step through the next iteration. | |
252 | + | |
253 | + `until' always stops your program if it attempts to exit the | |
254 | + current stack frame. | |
255 | + | |
256 | + `until' may produce somewhat counterintuitive results if the order | |
257 | + of machine code does not match the order of the source lines. For | |
258 | + example, in the following excerpt from a debugging session, the `f' | |
259 | + (`frame') command shows that execution is stopped at line `206'; | |
260 | + yet when we use `until', we get to line `195': | |
261 | + | |
262 | + (gdb) f | |
263 | + #0 main (argc=4, argv=0xf7fffae8) at m4.c:206 | |
264 | + 206 expand_input(); | |
265 | + (gdb) until | |
266 | + 195 for ( ; argc > 0; NEXTARG) { | |
267 | + | |
268 | + This happened because, for execution efficiency, the compiler had | |
269 | + generated code for the loop closure test at the end, rather than | |
270 | + the start, of the loop--even though the test in a C `for'-loop is | |
271 | + written before the body of the loop. The `until' command appeared | |
272 | + to step back to the beginning of the loop when it advanced to this | |
273 | + expression; however, it has not really gone to an earlier | |
274 | + statement--not in terms of the actual machine code. | |
275 | + | |
276 | + `until' with no argument works by means of single instruction | |
277 | + stepping, and hence is slower than `until' with an argument. | |
278 | + | |
279 | +`until LOCATION' | |
280 | +`u LOCATION' | |
281 | + Continue running your program until either the specified location | |
282 | + is reached, or the current stack frame returns. LOCATION is any of | |
283 | + the forms of argument acceptable to `break' (*note Setting | |
284 | + breakpoints: Set Breaks.). This form of the command uses | |
285 | + breakpoints, and hence is quicker than `until' without an argument. | |
286 | + | |
287 | +`stepi' | |
288 | +`si' | |
289 | + Execute one machine instruction, then stop and return to the | |
290 | + debugger. | |
291 | + | |
292 | + It is often useful to do `display/i $pc' when stepping by machine | |
293 | + instructions. This makes GDB automatically display the next | |
294 | + instruction to be executed, each time your program stops. *Note | |
295 | + Automatic display: Auto Display. | |
296 | + | |
297 | + An argument is a repeat count, as in `step'. | |
298 | + | |
299 | +`nexti' | |
300 | +`ni' | |
301 | + Execute one machine instruction, but if it is a function call, | |
302 | + proceed until the function returns. | |
303 | + | |
304 | + An argument is a repeat count, as in `next'. | |
305 | + | |
306 | + | |
307 | +File: gdb.info, Node: Signals, Next: Thread Stops, Prev: Continuing and Stepping, Up: Stopping | |
308 | + | |
309 | +Signals | |
310 | +======= | |
311 | + | |
312 | + A signal is an asynchronous event that can happen in a program. The | |
313 | +operating system defines the possible kinds of signals, and gives each | |
314 | +kind a name and a number. For example, in Unix `SIGINT' is the signal | |
315 | +a program gets when you type an interrupt (often `C-c'); `SIGSEGV' is | |
316 | +the signal a program gets from referencing a place in memory far away | |
317 | +from all the areas in use; `SIGALRM' occurs when the alarm clock timer | |
318 | +goes off (which happens only if your program has requested an alarm). | |
319 | + | |
320 | + Some signals, including `SIGALRM', are a normal part of the | |
321 | +functioning of your program. Others, such as `SIGSEGV', indicate | |
322 | +errors; these signals are "fatal" (kill your program immediately) if the | |
323 | +program has not specified in advance some other way to handle the | |
324 | +signal. `SIGINT' does not indicate an error in your program, but it is | |
325 | +normally fatal so it can carry out the purpose of the interrupt: to | |
326 | +kill the program. | |
327 | + | |
328 | + GDB has the ability to detect any occurrence of a signal in your | |
329 | +program. You can tell GDB in advance what to do for each kind of | |
330 | +signal. | |
331 | + | |
332 | + Normally, GDB is set up to ignore non-erroneous signals like | |
333 | +`SIGALRM' (so as not to interfere with their role in the functioning of | |
334 | +your program) but to stop your program immediately whenever an error | |
335 | +signal happens. You can change these settings with the `handle' | |
336 | +command. | |
337 | + | |
338 | +`info signals' | |
339 | + Print a table of all the kinds of signals and how GDB has been | |
340 | + told to handle each one. You can use this to see the signal | |
341 | + numbers of all the defined types of signals. | |
342 | + | |
343 | + `info handle' is the new alias for `info signals'. | |
344 | + | |
345 | +`handle SIGNAL KEYWORDS...' | |
346 | + Change the way GDB handles signal SIGNAL. SIGNAL can be the | |
347 | + number of a signal or its name (with or without the `SIG' at the | |
348 | + beginning). The KEYWORDS say what change to make. | |
349 | + | |
350 | + The keywords allowed by the `handle' command can be abbreviated. | |
351 | +Their full names are: | |
352 | + | |
353 | +`nostop' | |
354 | + GDB should not stop your program when this signal happens. It may | |
355 | + still print a message telling you that the signal has come in. | |
356 | + | |
357 | +`stop' | |
358 | + GDB should stop your program when this signal happens. This | |
359 | + implies the `print' keyword as well. | |
360 | + | |
361 | +`print' | |
362 | + GDB should print a message when this signal happens. | |
363 | + | |
364 | +`noprint' | |
365 | + GDB should not mention the occurrence of the signal at all. This | |
366 | + implies the `nostop' keyword as well. | |
367 | + | |
368 | +`pass' | |
369 | + GDB should allow your program to see this signal; your program can | |
370 | + handle the signal, or else it may terminate if the signal is fatal | |
371 | + and not handled. | |
372 | + | |
373 | +`nopass' | |
374 | + GDB should not allow your program to see this signal. | |
375 | + | |
376 | + When a signal stops your program, the signal is not visible until you | |
377 | +continue. Your program sees the signal then, if `pass' is in effect | |
378 | +for the signal in question *at that time*. In other words, after GDB | |
379 | +reports a signal, you can use the `handle' command with `pass' or | |
380 | +`nopass' to control whether your program sees that signal when you | |
381 | +continue. | |
382 | + | |
383 | + You can also use the `signal' command to prevent your program from | |
384 | +seeing a signal, or cause it to see a signal it normally would not see, | |
385 | +or to give it any signal at any time. For example, if your program | |
386 | +stopped due to some sort of memory reference error, you might store | |
387 | +correct values into the erroneous variables and continue, hoping to see | |
388 | +more execution; but your program would probably terminate immediately as | |
389 | +a result of the fatal signal once it saw the signal. To prevent this, | |
390 | +you can continue with `signal 0'. *Note Giving your program a signal: | |
391 | +Signaling. | |
392 | + | |
393 | + | |
394 | +File: gdb.info, Node: Thread Stops, Prev: Signals, Up: Stopping | |
395 | + | |
396 | +Stopping and starting multi-thread programs | |
397 | +=========================================== | |
398 | + | |
399 | + When your program has multiple threads (*note Debugging programs | |
400 | +with multiple threads: Threads.), you can choose whether to set | |
401 | +breakpoints on all threads, or on a particular thread. | |
402 | + | |
403 | +`break LINESPEC thread THREADNO' | |
404 | +`break LINESPEC thread THREADNO if ...' | |
405 | + LINESPEC specifies source lines; there are several ways of writing | |
406 | + them, but the effect is always to specify some source line. | |
407 | + | |
408 | + Use the qualifier `thread THREADNO' with a breakpoint command to | |
409 | + specify that you only want GDB to stop the program when a | |
410 | + particular thread reaches this breakpoint. THREADNO is one of the | |
411 | + numeric thread identifiers assigned by GDB, shown in the first | |
412 | + column of the `info threads' display. | |
413 | + | |
414 | + If you do not specify `thread THREADNO' when you set a breakpoint, | |
415 | + the breakpoint applies to *all* threads of your program. | |
416 | + | |
417 | + You can use the `thread' qualifier on conditional breakpoints as | |
418 | + well; in this case, place `thread THREADNO' before the breakpoint | |
419 | + condition, like this: | |
420 | + | |
421 | + (gdb) break frik.c:13 thread 28 if bartab > lim | |
422 | + | |
423 | + Whenever your program stops under GDB for any reason, *all* threads | |
424 | +of execution stop, not just the current thread. This allows you to | |
425 | +examine the overall state of the program, including switching between | |
426 | +threads, without worrying that things may change underfoot. | |
427 | + | |
428 | + Conversely, whenever you restart the program, *all* threads start | |
429 | +executing. *This is true even when single-stepping* with commands like | |
430 | +`step' or `next'. | |
431 | + | |
432 | + In particular, GDB cannot single-step all threads in lockstep. | |
433 | +Since thread scheduling is up to your debugging target's operating | |
434 | +system (not controlled by GDB), other threads may execute more than one | |
435 | +statement while the current thread completes a single step. Moreover, | |
436 | +in general other threads stop in the middle of a statement, rather than | |
437 | +at a clean statement boundary, when the program stops. | |
438 | + | |
439 | + You might even find your program stopped in another thread after | |
440 | +continuing or even single-stepping. This happens whenever some other | |
441 | +thread runs into a breakpoint, a signal, or an exception before the | |
442 | +first thread completes whatever you requested. | |
443 | + | |
444 | + On some OSes, you can lock the OS scheduler and thus allow only a | |
445 | +single thread to run. | |
446 | + | |
447 | +`set scheduler-locking MODE' | |
448 | + Set the scheduler locking mode. If it is `off', then there is no | |
449 | + locking and any thread may run at any time. If `on', then only the | |
450 | + current thread may run when the inferior is resumed. The `step' | |
451 | + mode optimizes for single-stepping. It stops other threads from | |
452 | + "seizing the prompt" by preempting the current thread while you are | |
453 | + stepping. Other threads will only rarely (or never) get a chance | |
454 | + to run when you step. They are more likely to run when you "next" | |
455 | + over a function call, and they are completely free to run when you | |
456 | + use commands like "continue", "until", or "finish". However, | |
457 | + unless another thread hits a breakpoint during its timeslice, they | |
458 | + will never steal the GDB prompt away from the thread that you are | |
459 | + debugging. | |
460 | + | |
461 | +`show scheduler-locking' | |
462 | + Display the current scheduler locking mode. | |
463 | + | |
464 | + | |
465 | +File: gdb.info, Node: Stack, Next: Source, Prev: Stopping, Up: Top | |
466 | + | |
467 | +Examining the Stack | |
468 | +******************* | |
469 | + | |
470 | + When your program has stopped, the first thing you need to know is | |
471 | +where it stopped and how it got there. | |
472 | + | |
473 | + Each time your program performs a function call, information about | |
474 | +the call is generated. That information includes the location of the | |
475 | +call in your program, the arguments of the call, and the local | |
476 | +variables of the function being called. The information is saved in a | |
477 | +block of data called a "stack frame". The stack frames are allocated | |
478 | +in a region of memory called the "call stack". | |
479 | + | |
480 | + When your program stops, the GDB commands for examining the stack | |
481 | +allow you to see all of this information. | |
482 | + | |
483 | + One of the stack frames is "selected" by GDB and many GDB commands | |
484 | +refer implicitly to the selected frame. In particular, whenever you | |
485 | +ask GDB for the value of a variable in your program, the value is found | |
486 | +in the selected frame. There are special GDB commands to select | |
487 | +whichever frame you are interested in. *Note Selecting a frame: | |
488 | +Selection. | |
489 | + | |
490 | + When your program stops, GDB automatically selects the currently | |
491 | +executing frame and describes it briefly, similar to the `frame' | |
492 | +command (*note Information about a frame: Frame Info.). | |
493 | + | |
494 | +* Menu: | |
495 | + | |
496 | +* Frames:: Stack frames | |
497 | +* Backtrace:: Backtraces | |
498 | +* Selection:: Selecting a frame | |
499 | +* Frame Info:: Information on a frame | |
500 | +* Alpha/MIPS Stack:: Alpha and MIPS machines and the function stack | |
501 | + | |
502 | + | |
503 | +File: gdb.info, Node: Frames, Next: Backtrace, Prev: Stack, Up: Stack | |
504 | + | |
505 | +Stack frames | |
506 | +============ | |
507 | + | |
508 | + The call stack is divided up into contiguous pieces called "stack | |
509 | +frames", or "frames" for short; each frame is the data associated with | |
510 | +one call to one function. The frame contains the arguments given to | |
511 | +the function, the function's local variables, and the address at which | |
512 | +the function is executing. | |
513 | + | |
514 | + When your program is started, the stack has only one frame, that of | |
515 | +the function `main'. This is called the "initial" frame or the | |
516 | +"outermost" frame. Each time a function is called, a new frame is | |
517 | +made. Each time a function returns, the frame for that function | |
518 | +invocation is eliminated. If a function is recursive, there can be | |
519 | +many frames for the same function. The frame for the function in which | |
520 | +execution is actually occurring is called the "innermost" frame. This | |
521 | +is the most recently created of all the stack frames that still exist. | |
522 | + | |
523 | + Inside your program, stack frames are identified by their addresses. | |
524 | +A stack frame consists of many bytes, each of which has its own | |
525 | +address; each kind of computer has a convention for choosing one byte | |
526 | +whose address serves as the address of the frame. Usually this address | |
527 | +is kept in a register called the "frame pointer register" while | |
528 | +execution is going on in that frame. | |
529 | + | |
530 | + GDB assigns numbers to all existing stack frames, starting with zero | |
531 | +for the innermost frame, one for the frame that called it, and so on | |
532 | +upward. These numbers do not really exist in your program; they are | |
533 | +assigned by GDB to give you a way of designating stack frames in GDB | |
534 | +commands. | |
535 | + | |
536 | + Some compilers provide a way to compile functions so that they | |
537 | +operate without stack frames. (For example, the `gcc' option | |
538 | +`-fomit-frame-pointer' generates functions without a frame.) This is | |
539 | +occasionally done with heavily used library functions to save the frame | |
540 | +setup time. GDB has limited facilities for dealing with these function | |
541 | +invocations. If the innermost function invocation has no stack frame, | |
542 | +GDB nevertheless regards it as though it had a separate frame, which is | |
543 | +numbered zero as usual, allowing correct tracing of the function call | |
544 | +chain. However, GDB has no provision for frameless functions elsewhere | |
545 | +in the stack. | |
546 | + | |
547 | +`frame ARGS' | |
548 | + The `frame' command allows you to move from one stack frame to | |
549 | + another, and to print the stack frame you select. ARGS may be | |
550 | + either the address of the frame or the stack frame number. | |
551 | + Without an argument, `frame' prints the current stack frame. | |
552 | + | |
553 | +`select-frame' | |
554 | + The `select-frame' command allows you to move from one stack frame | |
555 | + to another without printing the frame. This is the silent version | |
556 | + of `frame'. | |
557 | + | |
558 | + | |
559 | +File: gdb.info, Node: Backtrace, Next: Selection, Prev: Frames, Up: Stack | |
560 | + | |
561 | +Backtraces | |
562 | +========== | |
563 | + | |
564 | + A backtrace is a summary of how your program got where it is. It | |
565 | +shows one line per frame, for many frames, starting with the currently | |
566 | +executing frame (frame zero), followed by its caller (frame one), and | |
567 | +on up the stack. | |
568 | + | |
569 | +`backtrace' | |
570 | +`bt' | |
571 | + Print a backtrace of the entire stack: one line per frame for all | |
572 | + frames in the stack. | |
573 | + | |
574 | + You can stop the backtrace at any time by typing the system | |
575 | + interrupt character, normally `C-c'. | |
576 | + | |
577 | +`backtrace N' | |
578 | +`bt N' | |
579 | + Similar, but print only the innermost N frames. | |
580 | + | |
581 | +`backtrace -N' | |
582 | +`bt -N' | |
583 | + Similar, but print only the outermost N frames. | |
584 | + | |
585 | + The names `where' and `info stack' (abbreviated `info s') are | |
586 | +additional aliases for `backtrace'. | |
587 | + | |
588 | + Each line in the backtrace shows the frame number and the function | |
589 | +name. The program counter value is also shown--unless you use `set | |
590 | +print address off'. The backtrace also shows the source file name and | |
591 | +line number, as well as the arguments to the function. The program | |
592 | +counter value is omitted if it is at the beginning of the code for that | |
593 | +line number. | |
594 | + | |
595 | + Here is an example of a backtrace. It was made with the command `bt | |
596 | +3', so it shows the innermost three frames. | |
597 | + | |
598 | + #0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8) | |
599 | + at builtin.c:993 | |
600 | + #1 0x6e38 in expand_macro (sym=0x2b600) at macro.c:242 | |
601 | + #2 0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08) | |
602 | + at macro.c:71 | |
603 | + (More stack frames follow...) | |
604 | + | |
605 | +The display for frame zero does not begin with a program counter value, | |
606 | +indicating that your program has stopped at the beginning of the code | |
607 | +for line `993' of `builtin.c'. | |
608 | + | |
609 | + | |
610 | +File: gdb.info, Node: Selection, Next: Frame Info, Prev: Backtrace, Up: Stack | |
611 | + | |
612 | +Selecting a frame | |
613 | +================= | |
614 | + | |
615 | + Most commands for examining the stack and other data in your program | |
616 | +work on whichever stack frame is selected at the moment. Here are the | |
617 | +commands for selecting a stack frame; all of them finish by printing a | |
618 | +brief description of the stack frame just selected. | |
619 | + | |
620 | +`frame N' | |
621 | +`f N' | |
622 | + Select frame number N. Recall that frame zero is the innermost | |
623 | + (currently executing) frame, frame one is the frame that called the | |
624 | + innermost one, and so on. The highest-numbered frame is the one | |
625 | + for `main'. | |
626 | + | |
627 | +`frame ADDR' | |
628 | +`f ADDR' | |
629 | + Select the frame at address ADDR. This is useful mainly if the | |
630 | + chaining of stack frames has been damaged by a bug, making it | |
631 | + impossible for GDB to assign numbers properly to all frames. In | |
632 | + addition, this can be useful when your program has multiple stacks | |
633 | + and switches between them. | |
634 | + | |
635 | + On the SPARC architecture, `frame' needs two addresses to select | |
636 | + an arbitrary frame: a frame pointer and a stack pointer. | |
637 | + | |
638 | + On the MIPS and Alpha architecture, it needs two addresses: a stack | |
639 | + pointer and a program counter. | |
640 | + | |
641 | + On the 29k architecture, it needs three addresses: a register stack | |
642 | + pointer, a program counter, and a memory stack pointer. | |
643 | + | |
644 | +`up N' | |
645 | + Move N frames up the stack. For positive numbers N, this advances | |
646 | + toward the outermost frame, to higher frame numbers, to frames | |
647 | + that have existed longer. N defaults to one. | |
648 | + | |
649 | +`down N' | |
650 | + Move N frames down the stack. For positive numbers N, this | |
651 | + advances toward the innermost frame, to lower frame numbers, to | |
652 | + frames that were created more recently. N defaults to one. You | |
653 | + may abbreviate `down' as `do'. | |
654 | + | |
655 | + All of these commands end by printing two lines of output describing | |
656 | +the frame. The first line shows the frame number, the function name, | |
657 | +the arguments, and the source file and line number of execution in that | |
658 | +frame. The second line shows the text of that source line. | |
659 | + | |
660 | + For example: | |
661 | + | |
662 | + (gdb) up | |
663 | + #1 0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc) | |
664 | + at env.c:10 | |
665 | + 10 read_input_file (argv[i]); | |
666 | + | |
667 | + After such a printout, the `list' command with no arguments prints | |
668 | +ten lines centered on the point of execution in the frame. *Note | |
669 | +Printing source lines: List. | |
670 | + | |
671 | +`up-silently N' | |
672 | +`down-silently N' | |
673 | + These two commands are variants of `up' and `down', respectively; | |
674 | + they differ in that they do their work silently, without causing | |
675 | + display of the new frame. They are intended primarily for use in | |
676 | + GDB command scripts, where the output might be unnecessary and | |
677 | + distracting. | |
678 | + | |
679 | + | |
680 | +File: gdb.info, Node: Frame Info, Next: Alpha/MIPS Stack, Prev: Selection, Up: Stack | |
681 | + | |
682 | +Information about a frame | |
683 | +========================= | |
684 | + | |
685 | + There are several other commands to print information about the | |
686 | +selected stack frame. | |
687 | + | |
688 | +`frame' | |
689 | +`f' | |
690 | + When used without any argument, this command does not change which | |
691 | + frame is selected, but prints a brief description of the currently | |
692 | + selected stack frame. It can be abbreviated `f'. With an | |
693 | + argument, this command is used to select a stack frame. *Note | |
694 | + Selecting a frame: Selection. | |
695 | + | |
696 | +`info frame' | |
697 | +`info f' | |
698 | + This command prints a verbose description of the selected stack | |
699 | + frame, including: | |
700 | + | |
701 | + * the address of the frame | |
702 | + | |
703 | + * the address of the next frame down (called by this frame) | |
704 | + | |
705 | + * the address of the next frame up (caller of this frame) | |
706 | + | |
707 | + * the language in which the source code corresponding to this | |
708 | + frame is written | |
709 | + | |
710 | + * the address of the frame's arguments | |
711 | + | |
712 | + * the program counter saved in it (the address of execution in | |
713 | + the caller frame) | |
714 | + | |
715 | + * which registers were saved in the frame | |
716 | + | |
717 | + The verbose description is useful when something has gone wrong | |
718 | + that has made the stack format fail to fit the usual conventions. | |
719 | + | |
720 | +`info frame ADDR' | |
721 | +`info f ADDR' | |
722 | + Print a verbose description of the frame at address ADDR, without | |
723 | + selecting that frame. The selected frame remains unchanged by this | |
724 | + command. This requires the same kind of address (more than one | |
725 | + for some architectures) that you specify in the `frame' command. | |
726 | + *Note Selecting a frame: Selection. | |
727 | + | |
728 | +`info args' | |
729 | + Print the arguments of the selected frame, each on a separate line. | |
730 | + | |
731 | +`info locals' | |
732 | + Print the local variables of the selected frame, each on a separate | |
733 | + line. These are all variables (declared either static or | |
734 | + automatic) accessible at the point of execution of the selected | |
735 | + frame. | |
736 | + | |
737 | +`info catch' | |
738 | + Print a list of all the exception handlers that are active in the | |
739 | + current stack frame at the current point of execution. To see | |
740 | + other exception handlers, visit the associated frame (using the | |
741 | + `up', `down', or `frame' commands); then type `info catch'. *Note | |
742 | + Setting catchpoints: Set Catchpoints. | |
743 | + | |
744 | + | |
745 | +File: gdb.info, Node: Alpha/MIPS Stack, Prev: Frame Info, Up: Stack | |
746 | + | |
747 | +MIPS/Alpha machines and the function stack | |
748 | +========================================== | |
749 | + | |
750 | + Alpha- and MIPS-based computers use an unusual stack frame, which | |
751 | +sometimes requires GDB to search backward in the object code to find | |
752 | +the beginning of a function. | |
753 | + | |
754 | + To improve response time (especially for embedded applications, where | |
755 | +GDB may be restricted to a slow serial line for this search) you may | |
756 | +want to limit the size of this search, using one of these commands: | |
757 | + | |
758 | +`set heuristic-fence-post LIMIT' | |
759 | + Restrict GDB to examining at most LIMIT bytes in its search for | |
760 | + the beginning of a function. A value of 0 (the default) means | |
761 | + there is no limit. However, except for 0, the larger the limit | |
762 | + the more bytes `heuristic-fence-post' must search and therefore | |
763 | + the longer it takes to run. | |
764 | + | |
765 | +`show heuristic-fence-post' | |
766 | + Display the current limit. | |
767 | + | |
768 | +These commands are available *only* when GDB is configured for | |
769 | +debugging programs on Alpha or MIPS processors. | |
770 | + | |
771 | + | |
772 | +File: gdb.info, Node: Source, Next: Data, Prev: Stack, Up: Top | |
773 | + | |
774 | +Examining Source Files | |
775 | +********************** | |
776 | + | |
777 | + GDB can print parts of your program's source, since the debugging | |
778 | +information recorded in the program tells GDB what source files were | |
779 | +used to build it. When your program stops, GDB spontaneously prints | |
780 | +the line where it stopped. Likewise, when you select a stack frame | |
781 | +(*note Selecting a frame: Selection.), GDB prints the line where | |
782 | +execution in that frame has stopped. You can print other portions of | |
783 | +source files by explicit command. | |
784 | + | |
785 | + If you use GDB through its GNU Emacs interface, you may prefer to use | |
786 | +Emacs facilities to view source; *note Using GDB under GNU Emacs: | |
787 | +Emacs.. | |
788 | + | |
789 | +* Menu: | |
790 | + | |
791 | +* List:: Printing source lines | |
792 | + | |
793 | +* Search:: Searching source files | |
794 | + | |
795 | +* Source Path:: Specifying source directories | |
796 | +* Machine Code:: Source and machine code | |
797 | + | |
798 | + | |
799 | +File: gdb.info, Node: List, Next: Search, Prev: Source, Up: Source | |
800 | + | |
801 | +Printing source lines | |
802 | +===================== | |
803 | + | |
804 | + To print lines from a source file, use the `list' command | |
805 | +(abbreviated `l'). By default, ten lines are printed. There are | |
806 | +several ways to specify what part of the file you want to print. | |
807 | + | |
808 | + Here are the forms of the `list' command most commonly used: | |
809 | + | |
810 | +`list LINENUM' | |
811 | + Print lines centered around line number LINENUM in the current | |
812 | + source file. | |
813 | + | |
814 | +`list FUNCTION' | |
815 | + Print lines centered around the beginning of function FUNCTION. | |
816 | + | |
817 | +`list' | |
818 | + Print more lines. If the last lines printed were printed with a | |
819 | + `list' command, this prints lines following the last lines | |
820 | + printed; however, if the last line printed was a solitary line | |
821 | + printed as part of displaying a stack frame (*note Examining the | |
822 | + Stack: Stack.), this prints lines centered around that line. | |
823 | + | |
824 | +`list -' | |
825 | + Print lines just before the lines last printed. | |
826 | + | |
827 | + By default, GDB prints ten source lines with any of these forms of | |
828 | +the `list' command. You can change this using `set listsize': | |
829 | + | |
830 | +`set listsize COUNT' | |
831 | + Make the `list' command display COUNT source lines (unless the | |
832 | + `list' argument explicitly specifies some other number). | |
833 | + | |
834 | +`show listsize' | |
835 | + Display the number of lines that `list' prints. | |
836 | + | |
837 | + Repeating a `list' command with <RET> discards the argument, so it | |
838 | +is equivalent to typing just `list'. This is more useful than listing | |
839 | +the same lines again. An exception is made for an argument of `-'; | |
840 | +that argument is preserved in repetition so that each repetition moves | |
841 | +up in the source file. | |
842 | + | |
843 | + In general, the `list' command expects you to supply zero, one or two | |
844 | +"linespecs". Linespecs specify source lines; there are several ways of | |
845 | +writing them but the effect is always to specify some source line. | |
846 | +Here is a complete description of the possible arguments for `list': | |
847 | + | |
848 | +`list LINESPEC' | |
849 | + Print lines centered around the line specified by LINESPEC. | |
850 | + | |
851 | +`list FIRST,LAST' | |
852 | + Print lines from FIRST to LAST. Both arguments are linespecs. | |
853 | + | |
854 | +`list ,LAST' | |
855 | + Print lines ending with LAST. | |
856 | + | |
857 | +`list FIRST,' | |
858 | + Print lines starting with FIRST. | |
859 | + | |
860 | +`list +' | |
861 | + Print lines just after the lines last printed. | |
862 | + | |
863 | +`list -' | |
864 | + Print lines just before the lines last printed. | |
865 | + | |
866 | +`list' | |
867 | + As described in the preceding table. | |
868 | + | |
869 | + Here are the ways of specifying a single source line--all the kinds | |
870 | +of linespec. | |
871 | + | |
872 | +`NUMBER' | |
873 | + Specifies line NUMBER of the current source file. When a `list' | |
874 | + command has two linespecs, this refers to the same source file as | |
875 | + the first linespec. | |
876 | + | |
877 | +`+OFFSET' | |
878 | + Specifies the line OFFSET lines after the last line printed. When | |
879 | + used as the second linespec in a `list' command that has two, this | |
880 | + specifies the line OFFSET lines down from the first linespec. | |
881 | + | |
882 | +`-OFFSET' | |
883 | + Specifies the line OFFSET lines before the last line printed. | |
884 | + | |
885 | +`FILENAME:NUMBER' | |
886 | + Specifies line NUMBER in the source file FILENAME. | |
887 | + | |
888 | +`FUNCTION' | |
889 | + Specifies the line that begins the body of the function FUNCTION. | |
890 | + For example: in C, this is the line with the open brace. | |
891 | + | |
892 | +`FILENAME:FUNCTION' | |
893 | + Specifies the line of the open-brace that begins the body of the | |
894 | + function FUNCTION in the file FILENAME. You only need the file | |
895 | + name with a function name to avoid ambiguity when there are | |
896 | + identically named functions in different source files. | |
897 | + | |
898 | +`*ADDRESS' | |
899 | + Specifies the line containing the program address ADDRESS. | |
900 | + ADDRESS may be any expression. | |
901 | + | |
902 | + | |
903 | +File: gdb.info, Node: Search, Next: Source Path, Prev: List, Up: Source | |
904 | + | |
905 | +Searching source files | |
906 | +====================== | |
907 | + | |
908 | + There are two commands for searching through the current source file | |
909 | +for a regular expression. | |
910 | + | |
911 | +`forward-search REGEXP' | |
912 | +`search REGEXP' | |
913 | + The command `forward-search REGEXP' checks each line, starting | |
914 | + with the one following the last line listed, for a match for | |
915 | + REGEXP. It lists the line that is found. You can use the synonym | |
916 | + `search REGEXP' or abbreviate the command name as `fo'. | |
917 | + | |
918 | +`reverse-search REGEXP' | |
919 | + The command `reverse-search REGEXP' checks each line, starting | |
920 | + with the one before the last line listed and going backward, for a | |
921 | + match for REGEXP. It lists the line that is found. You can | |
922 | + abbreviate this command as `rev'. | |
923 | + | |
924 | + | |
925 | +File: gdb.info, Node: Source Path, Next: Machine Code, Prev: Search, Up: Source | |
926 | + | |
927 | +Specifying source directories | |
928 | +============================= | |
929 | + | |
930 | + Executable programs sometimes do not record the directories of the | |
931 | +source files from which they were compiled, just the names. Even when | |
932 | +they do, the directories could be moved between the compilation and | |
933 | +your debugging session. GDB has a list of directories to search for | |
934 | +source files; this is called the "source path". Each time GDB wants a | |
935 | +source file, it tries all the directories in the list, in the order | |
936 | +they are present in the list, until it finds a file with the desired | |
937 | +name. Note that the executable search path is *not* used for this | |
938 | +purpose. Neither is the current working directory, unless it happens | |
939 | +to be in the source path. | |
940 | + | |
941 | + If GDB cannot find a source file in the source path, and the object | |
942 | +program records a directory, GDB tries that directory too. If the | |
943 | +source path is empty, and there is no record of the compilation | |
944 | +directory, GDB looks in the current directory as a last resort. | |
945 | + | |
946 | + Whenever you reset or rearrange the source path, GDB clears out any | |
947 | +information it has cached about where source files are found and where | |
948 | +each line is in the file. | |
949 | + | |
950 | + When you start GDB, its source path is empty. To add other | |
951 | +directories, use the `directory' command. | |
952 | + | |
953 | +`directory DIRNAME ...' | |
954 | + | |
955 | +`dir DIRNAME ...' | |
956 | + Add directory DIRNAME to the front of the source path. Several | |
957 | + directory names may be given to this command, separated by `:' or | |
958 | + whitespace. You may specify a directory that is already in the | |
959 | + source path; this moves it forward, so GDB searches it sooner. | |
960 | + | |
961 | + You can use the string `$cdir' to refer to the compilation | |
962 | + directory (if one is recorded), and `$cwd' to refer to the current | |
963 | + working directory. `$cwd' is not the same as `.'--the former | |
964 | + tracks the current working directory as it changes during your GDB | |
965 | + session, while the latter is immediately expanded to the current | |
966 | + directory at the time you add an entry to the source path. | |
967 | + | |
968 | +`directory' | |
969 | + Reset the source path to empty again. This requires confirmation. | |
970 | + | |
971 | +`show directories' | |
972 | + Print the source path: show which directories it contains. | |
973 | + | |
974 | + If your source path is cluttered with directories that are no longer | |
975 | +of interest, GDB may sometimes cause confusion by finding the wrong | |
976 | +versions of source. You can correct the situation as follows: | |
977 | + | |
978 | + 1. Use `directory' with no argument to reset the source path to empty. | |
979 | + | |
980 | + 2. Use `directory' with suitable arguments to reinstall the | |
981 | + directories you want in the source path. You can add all the | |
982 | + directories in one command. | |
983 | + | |
984 | + | |
985 | +File: gdb.info, Node: Machine Code, Prev: Source Path, Up: Source | |
986 | + | |
987 | +Source and machine code | |
988 | +======================= | |
989 | + | |
990 | + You can use the command `info line' to map source lines to program | |
991 | +addresses (and vice versa), and the command `disassemble' to display a | |
992 | +range of addresses as machine instructions. When run under GNU Emacs | |
993 | +mode, the `info line' command now causes the arrow to point to the line | |
994 | +specified. Also, `info line' prints addresses in symbolic form as well | |
995 | +as hex. | |
996 | + | |
997 | +`info line LINESPEC' | |
998 | + Print the starting and ending addresses of the compiled code for | |
999 | + source line LINESPEC. You can specify source lines in any of the | |
1000 | + ways understood by the `list' command (*note Printing source | |
1001 | + lines: List.). | |
1002 | + | |
1003 | + For example, we can use `info line' to discover the location of the | |
1004 | +object code for the first line of function `m4_changequote': | |
1005 | + | |
1006 | + (gdb) info line m4_changecom | |
1007 | + Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350. | |
1008 | + | |
1009 | +We can also inquire (using `*ADDR' as the form for LINESPEC) what | |
1010 | +source line covers a particular address: | |
1011 | + (gdb) info line *0x63ff | |
1012 | + Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404. | |
1013 | + | |
1014 | + After `info line', the default address for the `x' command is | |
1015 | +changed to the starting address of the line, so that `x/i' is | |
1016 | +sufficient to begin examining the machine code (*note Examining memory: | |
1017 | +Memory.). Also, this address is saved as the value of the convenience | |
1018 | +variable `$_' (*note Convenience variables: Convenience Vars.). | |
1019 | + | |
1020 | +`disassemble' | |
1021 | + This specialized command dumps a range of memory as machine | |
1022 | + instructions. The default memory range is the function | |
1023 | + surrounding the program counter of the selected frame. A single | |
1024 | + argument to this command is a program counter value; GDB dumps the | |
1025 | + function surrounding this value. Two arguments specify a range of | |
1026 | + addresses (first inclusive, second exclusive) to dump. | |
1027 | + | |
1028 | + The following example shows the disassembly of a range of addresses | |
1029 | +of HP PA-RISC 2.0 code: | |
1030 | + | |
1031 | + (gdb) disas 0x32c4 0x32e4 | |
1032 | + Dump of assembler code from 0x32c4 to 0x32e4: | |
1033 | + 0x32c4 <main+204>: addil 0,dp | |
1034 | + 0x32c8 <main+208>: ldw 0x22c(sr0,r1),r26 | |
1035 | + 0x32cc <main+212>: ldil 0x3000,r31 | |
1036 | + 0x32d0 <main+216>: ble 0x3f8(sr4,r31) | |
1037 | + 0x32d4 <main+220>: ldo 0(r31),rp | |
1038 | + 0x32d8 <main+224>: addil -0x800,dp | |
1039 | + 0x32dc <main+228>: ldo 0x588(r1),r26 | |
1040 | + 0x32e0 <main+232>: ldil 0x3000,r31 | |
1041 | + End of assembler dump. | |
1042 | + | |
1043 | + Some architectures have more than one commonly-used set of | |
1044 | +instruction mnemonics or other syntax. | |
1045 | + | |
1046 | +`set assembly-language INSTRUCTION-SET' | |
1047 | + Select the instruction set to use when disassembling the program | |
1048 | + via the `disassemble' or `x/i' commands. | |
1049 | + | |
1050 | + Currently this command is only defined for the Intel x86 family. | |
1051 | + You can set INSTRUCTION-SET to either `i386' or `i8086'. The | |
1052 | + default is `i386'. | |
1053 | + | |
1054 | + | |
1055 | +File: gdb.info, Node: Data, Next: Languages, Prev: Source, Up: Top | |
1056 | + | |
1057 | +Examining Data | |
1058 | +************** | |
1059 | + | |
1060 | + The usual way to examine data in your program is with the `print' | |
1061 | +command (abbreviated `p'), or its synonym `inspect'. It evaluates and | |
1062 | +prints the value of an expression of the language your program is | |
1063 | +written in (*note Using GDB with Different Languages: Languages.). | |
1064 | + | |
1065 | +`print EXP' | |
1066 | +`print /F EXP' | |
1067 | + EXP is an expression (in the source language). By default the | |
1068 | + value of EXP is printed in a format appropriate to its data type; | |
1069 | + you can choose a different format by specifying `/F', where F is a | |
1070 | + letter specifying the format; *note Output formats: Output | |
1071 | + Formats.. | |
1072 | + | |
1073 | +`print' | |
1074 | +`print /F' | |
1075 | + If you omit EXP, GDB displays the last value again (from the | |
1076 | + "value history"; *note Value history: Value History.). This | |
1077 | + allows you to conveniently inspect the same value in an | |
1078 | + alternative format. | |
1079 | + | |
1080 | + A more low-level way of examining data is with the `x' command. It | |
1081 | +examines data in memory at a specified address and prints it in a | |
1082 | +specified format. *Note Examining memory: Memory. | |
1083 | + | |
1084 | + If you are interested in information about types, or about how the | |
1085 | +fields of a struct or class are declared, use the `ptype EXP' command | |
1086 | +rather than `print'. *Note Examining the Symbol Table: Symbols. | |
1087 | + | |
1088 | +* Menu: | |
1089 | + | |
1090 | +* Expressions:: Expressions | |
1091 | +* Variables:: Program variables | |
1092 | +* Arrays:: Artificial arrays | |
1093 | +* Output Formats:: Output formats | |
1094 | +* Memory:: Examining memory | |
1095 | +* Auto Display:: Automatic display | |
1096 | +* Print Settings:: Print settings | |
1097 | +* Value History:: Value history | |
1098 | +* Convenience Vars:: Convenience variables | |
1099 | +* Registers:: Registers | |
1100 | + | |
1101 | +* Floating Point Hardware:: Floating point hardware | |
1102 | + | |
1103 | + | |
1104 | +File: gdb.info, Node: Expressions, Next: Variables, Prev: Data, Up: Data | |
1105 | + | |
1106 | +Expressions | |
1107 | +=========== | |
1108 | + | |
1109 | + `print' and many other GDB commands accept an expression and compute | |
1110 | +its value. Any kind of constant, variable or operator defined by the | |
1111 | +programming language you are using is valid in an expression in GDB. | |
1112 | +This includes conditional expressions, function calls, casts and string | |
1113 | +constants. It unfortunately does not include symbols defined by | |
1114 | +preprocessor `#define' commands. | |
1115 | + | |
1116 | + GDB now supports array constants in expressions input by the user. | |
1117 | +The syntax is {ELEMENT, ELEMENT...}. For example, you can now use the | |
1118 | +command `print {1, 2, 3}' to build up an array in memory that is | |
1119 | +malloc'd in the target program. | |
1120 | + | |
1121 | + Because C is so widespread, most of the expressions shown in | |
1122 | +examples in this manual are in C. *Note Using GDB with Different | |
1123 | +Languages: Languages, for information on how to use expressions in other | |
1124 | +languages. | |
1125 | + | |
1126 | + In this section, we discuss operators that you can use in GDB | |
1127 | +expressions regardless of your programming language. | |
1128 | + | |
1129 | + Casts are supported in all languages, not just in C, because it is so | |
1130 | +useful to cast a number into a pointer in order to examine a structure | |
1131 | +at that address in memory. | |
1132 | + | |
1133 | + GDB supports these operators, in addition to those common to | |
1134 | +programming languages: | |
1135 | + | |
1136 | +`@' | |
1137 | + `@' is a binary operator for treating parts of memory as arrays. | |
1138 | + *Note Artificial arrays: Arrays, for more information. | |
1139 | + | |
1140 | +`::' | |
1141 | + `::' allows you to specify a variable in terms of the file or | |
1142 | + function where it is defined. *Note Program variables: Variables. | |
1143 | + | |
1144 | +`{TYPE} ADDR' | |
1145 | + Refers to an object of type TYPE stored at address ADDR in memory. | |
1146 | + ADDR may be any expression whose value is an integer or pointer | |
1147 | + (but parentheses are required around binary operators, just as in | |
1148 | + a cast). This construct is allowed regardless of what kind of | |
1149 | + data is normally supposed to reside at ADDR. | |
1150 | + | |
1151 | + | |
1152 | +File: gdb.info, Node: Variables, Next: Arrays, Prev: Expressions, Up: Data | |
1153 | + | |
1154 | +Program variables | |
1155 | +================= | |
1156 | + | |
1157 | + The most common kind of expression to use is the name of a variable | |
1158 | +in your program. | |
1159 | + | |
1160 | + Variables in expressions are understood in the selected stack frame | |
1161 | +(*note Selecting a frame: Selection.); they must be either: | |
1162 | + | |
1163 | + * global (or file-static) | |
1164 | + | |
1165 | +or | |
1166 | + | |
1167 | + * visible according to the scope rules of the programming language | |
1168 | + from the point of execution in that frame | |
1169 | + | |
1170 | +This means that in the function | |
1171 | + | |
1172 | + foo (a) | |
1173 | + int a; | |
1174 | + { | |
1175 | + bar (a); | |
1176 | + { | |
1177 | + int b = test (); | |
1178 | + bar (b); | |
1179 | + } | |
1180 | + } | |
1181 | + | |
1182 | +you can examine and use the variable `a' whenever your program is | |
1183 | +executing within the function `foo', but you can only use or examine | |
1184 | +the variable `b' while your program is executing inside the block where | |
1185 | +`b' is declared. | |
1186 | + | |
1187 | + There is an exception: you can refer to a variable or function whose | |
1188 | +scope is a single source file even if the current execution point is not | |
1189 | +in this file. But it is possible to have more than one such variable or | |
1190 | +function with the same name (in different source files). If that | |
1191 | +happens, referring to that name has unpredictable effects. If you wish, | |
1192 | +you can specify a static variable in a particular function or file, | |
1193 | +using the colon-colon notation: | |
1194 | + | |
1195 | + FILE::VARIABLE | |
1196 | + FUNCTION::VARIABLE | |
1197 | + | |
1198 | +Here FILE or FUNCTION is the name of the context for the static | |
1199 | +VARIABLE. In the case of file names, you can use quotes to make sure | |
1200 | +GDB parses the file name as a single word--for example, to print a | |
1201 | +global value of `x' defined in `f2.c': | |
1202 | + | |
1203 | + (gdb) p 'f2.c'::x | |
1204 | + | |
1205 | + This use of `::' is very rarely in conflict with the very similar | |
1206 | +use of the same notation in C++. GDB also supports use of the C++ | |
1207 | +scope resolution operator in GDB expressions. | |
1208 | + | |
1209 | + *Warning:* Occasionally, a local variable may appear to have the | |
1210 | + wrong value at certain points in a function--just after entry to a | |
1211 | + new scope, and just before exit. | |
1212 | + You may see this problem when you are stepping by machine | |
1213 | +instructions. This is because, on most machines, it takes more than | |
1214 | +one instruction to set up a stack frame (including local variable | |
1215 | +definitions); if you are stepping by machine instructions, variables | |
1216 | +may appear to have the wrong values until the stack frame is completely | |
1217 | +built. On exit, it usually also takes more than one machine | |
1218 | +instruction to destroy a stack frame; after you begin stepping through | |
1219 | +that group of instructions, local variable definitions may be gone. | |
1220 | + | |
1221 | + This may also happen when the compiler does significant | |
1222 | +optimizations. To be sure of always seeing accurate values, turn off | |
1223 | +all optimization when compiling. | |
1224 | + |
@@ -0,0 +1,1279 @@ | ||
1 | +This is Info file ./gdb.info, produced by Makeinfo version 1.68 from | |
2 | +the input file gdb.texinfo. | |
3 | + | |
4 | +START-INFO-DIR-ENTRY | |
5 | +* Gdb: (gdb). The GNU debugger. | |
6 | +END-INFO-DIR-ENTRY | |
7 | + This file documents the GNU debugger GDB. | |
8 | + | |
9 | + This is the Seventh Edition, February 1999, of `Debugging with GDB: | |
10 | +the GNU Source-Level Debugger' for GDB Version 4.18. | |
11 | + | |
12 | + Copyright (C) 1988-1999 Free Software Foundation, Inc. | |
13 | + | |
14 | + Permission is granted to make and distribute verbatim copies of this | |
15 | +manual provided the copyright notice and this permission notice are | |
16 | +preserved on all copies. | |
17 | + | |
18 | + Permission is granted to copy and distribute modified versions of | |
19 | +this manual under the conditions for verbatim copying, provided also | |
20 | +that the entire resulting derived work is distributed under the terms | |
21 | +of a permission notice identical to this one. | |
22 | + | |
23 | + Permission is granted to copy and distribute translations of this | |
24 | +manual into another language, under the above conditions for modified | |
25 | +versions. | |
26 | + | |
27 | + | |
28 | +File: gdb.info, Node: Arrays, Next: Output Formats, Prev: Variables, Up: Data | |
29 | + | |
30 | +Artificial arrays | |
31 | +================= | |
32 | + | |
33 | + It is often useful to print out several successive objects of the | |
34 | +same type in memory; a section of an array, or an array of dynamically | |
35 | +determined size for which only a pointer exists in the program. | |
36 | + | |
37 | + You can do this by referring to a contiguous span of memory as an | |
38 | +"artificial array", using the binary operator `@'. The left operand of | |
39 | +`@' should be the first element of the desired array and be an | |
40 | +individual object. The right operand should be the desired length of | |
41 | +the array. The result is an array value whose elements are all of the | |
42 | +type of the left argument. The first element is actually the left | |
43 | +argument; the second element comes from bytes of memory immediately | |
44 | +following those that hold the first element, and so on. Here is an | |
45 | +example. If a program says | |
46 | + | |
47 | + int *array = (int *) malloc (len * sizeof (int)); | |
48 | + | |
49 | +you can print the contents of `array' with | |
50 | + | |
51 | + p *array@len | |
52 | + | |
53 | + The left operand of `@' must reside in memory. Array values made | |
54 | +with `@' in this way behave just like other arrays in terms of | |
55 | +subscripting, and are coerced to pointers when used in expressions. | |
56 | +Artificial arrays most often appear in expressions via the value history | |
57 | +(*note Value history: Value History.), after printing one out. | |
58 | + | |
59 | + Another way to create an artificial array is to use a cast. This | |
60 | +re-interprets a value as if it were an array. The value need not be in | |
61 | +memory: | |
62 | + (gdb) p/x (short[2])0x12345678 | |
63 | + $1 = {0x1234, 0x5678} | |
64 | + | |
65 | + As a convenience, if you leave the array length out (as in | |
66 | +`(TYPE)[])VALUE') gdb calculates the size to fill the value (as | |
67 | +`sizeof(VALUE)/sizeof(TYPE)': | |
68 | + (gdb) p/x (short[])0x12345678 | |
69 | + $2 = {0x1234, 0x5678} | |
70 | + | |
71 | + Sometimes the artificial array mechanism is not quite enough; in | |
72 | +moderately complex data structures, the elements of interest may not | |
73 | +actually be adjacent--for example, if you are interested in the values | |
74 | +of pointers in an array. One useful work-around in this situation is | |
75 | +to use a convenience variable (*note Convenience variables: Convenience | |
76 | +Vars.) as a counter in an expression that prints the first interesting | |
77 | +value, and then repeat that expression via <RET>. For instance, | |
78 | +suppose you have an array `dtab' of pointers to structures, and you are | |
79 | +interested in the values of a field `fv' in each structure. Here is an | |
80 | +example of what you might type: | |
81 | + | |
82 | + set $i = 0 | |
83 | + p dtab[$i++]->fv | |
84 | + <RET> | |
85 | + <RET> | |
86 | + ... | |
87 | + | |
88 | + | |
89 | +File: gdb.info, Node: Output Formats, Next: Memory, Prev: Arrays, Up: Data | |
90 | + | |
91 | +Output formats | |
92 | +============== | |
93 | + | |
94 | + By default, GDB prints a value according to its data type. Sometimes | |
95 | +this is not what you want. For example, you might want to print a | |
96 | +number in hex, or a pointer in decimal. Or you might want to view data | |
97 | +in memory at a certain address as a character string or as an | |
98 | +instruction. To do these things, specify an "output format" when you | |
99 | +print a value. | |
100 | + | |
101 | + The simplest use of output formats is to say how to print a value | |
102 | +already computed. This is done by starting the arguments of the | |
103 | +`print' command with a slash and a format letter. The format letters | |
104 | +supported are: | |
105 | + | |
106 | +`x' | |
107 | + Regard the bits of the value as an integer, and print the integer | |
108 | + in hexadecimal. | |
109 | + | |
110 | +`d' | |
111 | + Print as integer in signed decimal. | |
112 | + | |
113 | +`u' | |
114 | + Print as integer in unsigned decimal. | |
115 | + | |
116 | +`o' | |
117 | + Print as integer in octal. | |
118 | + | |
119 | +`t' | |
120 | + Print as integer in binary. The letter `t' stands for "two". (1) | |
121 | + | |
122 | +`a' | |
123 | + Print as an address, both absolute in hexadecimal and as an offset | |
124 | + from the nearest preceding symbol. You can use this format used | |
125 | + to discover where (in what function) an unknown address is located: | |
126 | + | |
127 | + (gdb) p/a 0x54320 | |
128 | + $3 = 0x54320 <_initialize_vx+396> | |
129 | + | |
130 | +`c' | |
131 | + Regard as an integer and print it as a character constant. | |
132 | + | |
133 | +`f' | |
134 | + Regard the bits of the value as a floating point number and print | |
135 | + using typical floating point syntax. | |
136 | + | |
137 | + For example, to print the program counter in hex (*note | |
138 | +Registers::.), type | |
139 | + | |
140 | + p/x $pc | |
141 | + | |
142 | +Note that no space is required before the slash; this is because command | |
143 | +names in GDB cannot contain a slash. | |
144 | + | |
145 | + To reprint the last value in the value history with a different | |
146 | +format, you can use the `print' command with just a format and no | |
147 | +expression. For example, `p/x' reprints the last value in hex. | |
148 | + | |
149 | + ---------- Footnotes ---------- | |
150 | + | |
151 | + (1) `b' cannot be used because these format letters are also used | |
152 | +with the `x' command, where `b' stands for "byte"; *note Examining | |
153 | +memory: Memory.. | |
154 | + | |
155 | + | |
156 | +File: gdb.info, Node: Memory, Next: Auto Display, Prev: Output Formats, Up: Data | |
157 | + | |
158 | +Examining memory | |
159 | +================ | |
160 | + | |
161 | + You can use the command `x' (for "examine") to examine memory in any | |
162 | +of several formats, independently of your program's data types. | |
163 | + | |
164 | +`x/NFU ADDR' | |
165 | +`x ADDR' | |
166 | +`x' | |
167 | + Use the `x' command to examine memory. | |
168 | + | |
169 | + N, F, and U are all optional parameters that specify how much memory | |
170 | +to display and how to format it; ADDR is an expression giving the | |
171 | +address where you want to start displaying memory. If you use defaults | |
172 | +for NFU, you need not type the slash `/'. Several commands set | |
173 | +convenient defaults for ADDR. | |
174 | + | |
175 | +N, the repeat count | |
176 | + The repeat count is a decimal integer; the default is 1. It | |
177 | + specifies how much memory (counting by units U) to display. | |
178 | + | |
179 | +F, the display format | |
180 | + The display format is one of the formats used by `print', `s' | |
181 | + (null-terminated string), or `i' (machine instruction). The | |
182 | + default is `x' (hexadecimal) initially. The default changes each | |
183 | + time you use either `x' or `print'. | |
184 | + | |
185 | +U, the unit size | |
186 | + The unit size is any of | |
187 | + | |
188 | + `b' | |
189 | + Bytes. | |
190 | + | |
191 | + `h' | |
192 | + Halfwords (two bytes). | |
193 | + | |
194 | + `w' | |
195 | + Words (four bytes). This is the initial default. | |
196 | + | |
197 | + `g' | |
198 | + Giant words (eight bytes). | |
199 | + | |
200 | + Each time you specify a unit size with `x', that size becomes the | |
201 | + default unit the next time you use `x'. (For the `s' and `i' | |
202 | + formats, the unit size is ignored and is normally not written.) | |
203 | + | |
204 | +ADDR, starting display address | |
205 | + ADDR is the address where you want GDB to begin displaying memory. | |
206 | + The expression need not have a pointer value (though it may); it | |
207 | + is always interpreted as an integer address of a byte of memory. | |
208 | + *Note Expressions: Expressions, for more information on | |
209 | + expressions. The default for ADDR is usually just after the last | |
210 | + address examined--but several other commands also set the default | |
211 | + address: `info breakpoints' (to the address of the last breakpoint | |
212 | + listed), `info line' (to the starting address of a line), and | |
213 | + `print' (if you use it to display a value from memory). | |
214 | + | |
215 | + For example, `x/3uh 0x54320' is a request to display three halfwords | |
216 | +(`h') of memory, formatted as unsigned decimal integers (`u'), starting | |
217 | +at address `0x54320'. `x/4xw $sp' prints the four words (`w') of | |
218 | +memory above the stack pointer (here, `$sp'; *note Registers::.) in | |
219 | +hexadecimal (`x'). | |
220 | + | |
221 | + Since the letters indicating unit sizes are all distinct from the | |
222 | +letters specifying output formats, you do not have to remember whether | |
223 | +unit size or format comes first; either order works. The output | |
224 | +specifications `4xw' and `4wx' mean exactly the same thing. (However, | |
225 | +the count N must come first; `wx4' does not work.) | |
226 | + | |
227 | + Even though the unit size U is ignored for the formats `s' and `i', | |
228 | +you might still want to use a count N; for example, `3i' specifies that | |
229 | +you want to see three machine instructions, including any operands. | |
230 | +The command `disassemble' gives an alternative way of inspecting | |
231 | +machine instructions; *note Source and machine code: Machine Code.. | |
232 | + | |
233 | + All the defaults for the arguments to `x' are designed to make it | |
234 | +easy to continue scanning memory with minimal specifications each time | |
235 | +you use `x'. For example, after you have inspected three machine | |
236 | +instructions with `x/3i ADDR', you can inspect the next seven with just | |
237 | +`x/7'. If you use <RET> to repeat the `x' command, the repeat count N | |
238 | +is used again; the other arguments default as for successive uses of | |
239 | +`x'. | |
240 | + | |
241 | + The addresses and contents printed by the `x' command are not saved | |
242 | +in the value history because there is often too much of them and they | |
243 | +would get in the way. Instead, GDB makes these values available for | |
244 | +subsequent use in expressions as values of the convenience variables | |
245 | +`$_' and `$__'. After an `x' command, the last address examined is | |
246 | +available for use in expressions in the convenience variable `$_'. The | |
247 | +contents of that address, as examined, are available in the convenience | |
248 | +variable `$__'. | |
249 | + | |
250 | + If the `x' command has a repeat count, the address and contents saved | |
251 | +are from the last memory unit printed; this is not the same as the last | |
252 | +address printed if several units were printed on the last line of | |
253 | +output. | |
254 | + | |
255 | + | |
256 | +File: gdb.info, Node: Auto Display, Next: Print Settings, Prev: Memory, Up: Data | |
257 | + | |
258 | +Automatic display | |
259 | +================= | |
260 | + | |
261 | + If you find that you want to print the value of an expression | |
262 | +frequently (to see how it changes), you might want to add it to the | |
263 | +"automatic display list" so that GDB prints its value each time your | |
264 | +program stops. Each expression added to the list is given a number to | |
265 | +identify it; to remove an expression from the list, you specify that | |
266 | +number. The automatic display looks like this: | |
267 | + | |
268 | + 2: foo = 38 | |
269 | + 3: bar[5] = (struct hack *) 0x3804 | |
270 | + | |
271 | +This display shows item numbers, expressions and their current values. | |
272 | +As with displays you request manually using `x' or `print', you can | |
273 | +specify the output format you prefer; in fact, `display' decides | |
274 | +whether to use `print' or `x' depending on how elaborate your format | |
275 | +specification is--it uses `x' if you specify a unit size, or one of the | |
276 | +two formats (`i' and `s') that are only supported by `x'; otherwise it | |
277 | +uses `print'. | |
278 | + | |
279 | +`display EXP' | |
280 | + Add the expression EXP to the list of expressions to display each | |
281 | + time your program stops. *Note Expressions: Expressions. | |
282 | + | |
283 | + `display' does not repeat if you press <RET> again after using it. | |
284 | + | |
285 | +`display/FMT EXP' | |
286 | + For FMT specifying only a display format and not a size or count, | |
287 | + add the expression EXP to the auto-display list but arrange to | |
288 | + display it each time in the specified format FMT. *Note Output | |
289 | + formats: Output Formats. | |
290 | + | |
291 | +`display/FMT ADDR' | |
292 | + For FMT `i' or `s', or including a unit-size or a number of units, | |
293 | + add the expression ADDR as a memory address to be examined each | |
294 | + time your program stops. Examining means in effect doing `x/FMT | |
295 | + ADDR'. *Note Examining memory: Memory. | |
296 | + | |
297 | + For example, `display/i $pc' can be helpful, to see the machine | |
298 | +instruction about to be executed each time execution stops (`$pc' is a | |
299 | +common name for the program counter; *note Registers::.). | |
300 | + | |
301 | +`undisplay DNUMS...' | |
302 | +`delete display DNUMS...' | |
303 | + Remove item numbers DNUMS from the list of expressions to display. | |
304 | + | |
305 | + `undisplay' does not repeat if you press <RET> after using it. | |
306 | + (Otherwise you would just get the error `No display number ...'.) | |
307 | + | |
308 | +`disable display DNUMS...' | |
309 | + Disable the display of item numbers DNUMS. A disabled display | |
310 | + item is not printed automatically, but is not forgotten. It may be | |
311 | + enabled again later. | |
312 | + | |
313 | +`enable display DNUMS...' | |
314 | + Enable display of item numbers DNUMS. It becomes effective once | |
315 | + again in auto display of its expression, until you specify | |
316 | + otherwise. | |
317 | + | |
318 | +`display' | |
319 | + Display the current values of the expressions on the list, just as | |
320 | + is done when your program stops. | |
321 | + | |
322 | +`info display' | |
323 | + Print the list of expressions previously set up to display | |
324 | + automatically, each one with its item number, but without showing | |
325 | + the values. This includes disabled expressions, which are marked | |
326 | + as such. It also includes expressions which would not be | |
327 | + displayed right now because they refer to automatic variables not | |
328 | + currently available. | |
329 | + | |
330 | + If a display expression refers to local variables, then it does not | |
331 | +make sense outside the lexical context for which it was set up. Such an | |
332 | +expression is disabled when execution enters a context where one of its | |
333 | +variables is not defined. For example, if you give the command | |
334 | +`display last_char' while inside a function with an argument | |
335 | +`last_char', GDB displays this argument while your program continues to | |
336 | +stop inside that function. When it stops elsewhere--where there is no | |
337 | +variable `last_char'--the display is disabled automatically. The next | |
338 | +time your program stops where `last_char' is meaningful, you can enable | |
339 | +the display expression once again. | |
340 | + | |
341 | + | |
342 | +File: gdb.info, Node: Print Settings, Next: Value History, Prev: Auto Display, Up: Data | |
343 | + | |
344 | +Print settings | |
345 | +============== | |
346 | + | |
347 | + GDB provides the following ways to control how arrays, structures, | |
348 | +and symbols are printed. | |
349 | + | |
350 | +These settings are useful for debugging programs in any language: | |
351 | + | |
352 | +`set print address' | |
353 | +`set print address on' | |
354 | + GDB prints memory addresses showing the location of stack traces, | |
355 | + structure values, pointer values, breakpoints, and so forth, even | |
356 | + when it also displays the contents of those addresses. The default | |
357 | + is `on'. For example, this is what a stack frame display looks | |
358 | + like with `set print address on': | |
359 | + | |
360 | + (gdb) f | |
361 | + #0 set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>") | |
362 | + at input.c:530 | |
363 | + 530 if (lquote != def_lquote) | |
364 | + | |
365 | +`set print address off' | |
366 | + Do not print addresses when displaying their contents. For | |
367 | + example, this is the same stack frame displayed with `set print | |
368 | + address off': | |
369 | + | |
370 | + (gdb) set print addr off | |
371 | + (gdb) f | |
372 | + #0 set_quotes (lq="<<", rq=">>") at input.c:530 | |
373 | + 530 if (lquote != def_lquote) | |
374 | + | |
375 | + You can use `set print address off' to eliminate all machine | |
376 | + dependent displays from the GDB interface. For example, with | |
377 | + `print address off', you should get the same text for backtraces on | |
378 | + all machines--whether or not they involve pointer arguments. | |
379 | + | |
380 | +`show print address' | |
381 | + Show whether or not addresses are to be printed. | |
382 | + | |
383 | + When GDB prints a symbolic address, it normally prints the closest | |
384 | +earlier symbol plus an offset. If that symbol does not uniquely | |
385 | +identify the address (for example, it is a name whose scope is a single | |
386 | +source file), you may need to clarify. One way to do this is with | |
387 | +`info line', for example `info line *0x4537'. Alternately, you can set | |
388 | +GDB to print the source file and line number when it prints a symbolic | |
389 | +address: | |
390 | + | |
391 | +`set print symbol-filename on' | |
392 | + Tell GDB to print the source file name and line number of a symbol | |
393 | + in the symbolic form of an address. | |
394 | + | |
395 | +`set print symbol-filename off' | |
396 | + Do not print source file name and line number of a symbol. This | |
397 | + is the default. | |
398 | + | |
399 | +`show print symbol-filename' | |
400 | + Show whether or not GDB will print the source file name and line | |
401 | + number of a symbol in the symbolic form of an address. | |
402 | + | |
403 | + Another situation where it is helpful to show symbol filenames and | |
404 | +line numbers is when disassembling code; GDB shows you the line number | |
405 | +and source file that corresponds to each instruction. | |
406 | + | |
407 | + Also, you may wish to see the symbolic form only if the address being | |
408 | +printed is reasonably close to the closest earlier symbol: | |
409 | + | |
410 | +`set print max-symbolic-offset MAX-OFFSET' | |
411 | + Tell GDB to only display the symbolic form of an address if the | |
412 | + offset between the closest earlier symbol and the address is less | |
413 | + than MAX-OFFSET. The default is 0, which tells GDB to always | |
414 | + print the symbolic form of an address if any symbol precedes it. | |
415 | + | |
416 | +`show print max-symbolic-offset' | |
417 | + Ask how large the maximum offset is that GDB prints in a symbolic | |
418 | + address. | |
419 | + | |
420 | + If you have a pointer and you are not sure where it points, try `set | |
421 | +print symbol-filename on'. Then you can determine the name and source | |
422 | +file location of the variable where it points, using `p/a POINTER'. | |
423 | +This interprets the address in symbolic form. For example, here GDB | |
424 | +shows that a variable `ptt' points at another variable `t', defined in | |
425 | +`hi2.c': | |
426 | + | |
427 | + (gdb) set print symbol-filename on | |
428 | + (gdb) p/a ptt | |
429 | + $4 = 0xe008 <t in hi2.c> | |
430 | + | |
431 | + *Warning:* For pointers that point to a local variable, `p/a' does | |
432 | + not show the symbol name and filename of the referent, even with | |
433 | + the appropriate `set print' options turned on. | |
434 | + | |
435 | + Other settings control how different kinds of objects are printed: | |
436 | + | |
437 | +`set print array' | |
438 | +`set print array on' | |
439 | + Pretty print arrays. This format is more convenient to read, but | |
440 | + uses more space. The default is off. | |
441 | + | |
442 | +`set print array off' | |
443 | + Return to compressed format for arrays. | |
444 | + | |
445 | +`show print array' | |
446 | + Show whether compressed or pretty format is selected for displaying | |
447 | + arrays. | |
448 | + | |
449 | +`set print elements NUMBER-OF-ELEMENTS' | |
450 | + Set a limit on how many elements of an array GDB will print. If | |
451 | + GDB is printing a large array, it stops printing after it has | |
452 | + printed the number of elements set by the `set print elements' | |
453 | + command. This limit also applies to the display of strings. | |
454 | + Setting NUMBER-OF-ELEMENTS to zero means that the printing is | |
455 | + unlimited. | |
456 | + | |
457 | +`show print elements' | |
458 | + Display the number of elements of a large array that GDB will | |
459 | + print. If the number is 0, then the printing is unlimited. | |
460 | + | |
461 | +`set print null-stop' | |
462 | + Cause GDB to stop printing the characters of an array when the | |
463 | + first NULL is encountered. This is useful when large arrays | |
464 | + actually contain only short strings. | |
465 | + | |
466 | +`set print pretty on' | |
467 | + Cause GDB to print structures in an indented format with one member | |
468 | + per line, like this: | |
469 | + | |
470 | + $1 = { | |
471 | + next = 0x0, | |
472 | + flags = { | |
473 | + sweet = 1, | |
474 | + sour = 1 | |
475 | + }, | |
476 | + meat = 0x54 "Pork" | |
477 | + } | |
478 | + | |
479 | +`set print pretty off' | |
480 | + Cause GDB to print structures in a compact format, like this: | |
481 | + | |
482 | + $1 = {next = 0x0, flags = {sweet = 1, sour = 1}, \ | |
483 | + meat = 0x54 "Pork"} | |
484 | + | |
485 | + This is the default format. | |
486 | + | |
487 | +`show print pretty' | |
488 | + Show which format GDB is using to print structures. | |
489 | + | |
490 | +`set print sevenbit-strings on' | |
491 | + Print using only seven-bit characters; if this option is set, GDB | |
492 | + displays any eight-bit characters (in strings or character values) | |
493 | + using the notation `\'NNN. This setting is best if you are | |
494 | + working in English (ASCII) and you use the high-order bit of | |
495 | + characters as a marker or "meta" bit. | |
496 | + | |
497 | +`set print sevenbit-strings off' | |
498 | + Print full eight-bit characters. This allows the use of more | |
499 | + international character sets, and is the default. | |
500 | + | |
501 | +`show print sevenbit-strings' | |
502 | + Show whether or not GDB is printing only seven-bit characters. | |
503 | + | |
504 | +`set print union on' | |
505 | + Tell GDB to print unions which are contained in structures. This | |
506 | + is the default setting. | |
507 | + | |
508 | +`set print union off' | |
509 | + Tell GDB not to print unions which are contained in structures. | |
510 | + | |
511 | +`show print union' | |
512 | + Ask GDB whether or not it will print unions which are contained in | |
513 | + structures. | |
514 | + | |
515 | + For example, given the declarations | |
516 | + | |
517 | + typedef enum {Tree, Bug} Species; | |
518 | + typedef enum {Big_tree, Acorn, Seedling} Tree_forms; | |
519 | + typedef enum {Caterpillar, Cocoon, Butterfly} | |
520 | + Bug_forms; | |
521 | + | |
522 | + struct thing { | |
523 | + Species it; | |
524 | + union { | |
525 | + Tree_forms tree; | |
526 | + Bug_forms bug; | |
527 | + } form; | |
528 | + }; | |
529 | + | |
530 | + struct thing foo = {Tree, {Acorn}}; | |
531 | + | |
532 | + with `set print union on' in effect `p foo' would print | |
533 | + | |
534 | + $1 = {it = Tree, form = {tree = Acorn, bug = Cocoon}} | |
535 | + | |
536 | + and with `set print union off' in effect it would print | |
537 | + | |
538 | + $1 = {it = Tree, form = {...}} | |
539 | + | |
540 | +These settings are of interest when debugging C++ programs: | |
541 | + | |
542 | +`set print demangle' | |
543 | +`set print demangle on' | |
544 | + Print C++ names in their source form rather than in the encoded | |
545 | + ("mangled") form passed to the assembler and linker for type-safe | |
546 | + linkage. The default is `on'. | |
547 | + | |
548 | +`show print demangle' | |
549 | + Show whether C++ names are printed in mangled or demangled form. | |
550 | + | |
551 | +`set print asm-demangle' | |
552 | +`set print asm-demangle on' | |
553 | + Print C++ names in their source form rather than their mangled | |
554 | + form, even in assembler code printouts such as instruction | |
555 | + disassemblies. The default is off. | |
556 | + | |
557 | +`show print asm-demangle' | |
558 | + Show whether C++ names in assembly listings are printed in mangled | |
559 | + or demangled form. | |
560 | + | |
561 | +`set demangle-style STYLE' | |
562 | + Choose among several encoding schemes used by different compilers | |
563 | + to represent C++ names. The choices for STYLE are currently: | |
564 | + | |
565 | + `auto' | |
566 | + Allow GDB to choose a decoding style by inspecting your | |
567 | + program. | |
568 | + | |
569 | + `gnu' | |
570 | + Decode based on the GNU C++ compiler (`g++') encoding | |
571 | + algorithm. This is the default. | |
572 | + | |
573 | + `hp' | |
574 | + Decode based on the HP ANSI C++ (`aCC') encoding algorithm. | |
575 | + | |
576 | + `lucid' | |
577 | + Decode based on the Lucid C++ compiler (`lcc') encoding | |
578 | + algorithm. | |
579 | + | |
580 | + `arm' | |
581 | + Decode using the algorithm in the `C++ Annotated Reference | |
582 | + Manual'. *Warning:* this setting alone is not sufficient to | |
583 | + allow debugging `cfront'-generated executables. GDB would | |
584 | + require further enhancement to permit that. | |
585 | + | |
586 | + If you omit STYLE, you will see a list of possible formats. | |
587 | + | |
588 | +`show demangle-style' | |
589 | + Display the encoding style currently in use for decoding C++ | |
590 | + symbols. | |
591 | + | |
592 | +`set print object' | |
593 | +`set print object on' | |
594 | + When displaying a pointer to an object, identify the *actual* | |
595 | + (derived) type of the object rather than the *declared* type, using | |
596 | + the virtual function table. | |
597 | + | |
598 | +`set print object off' | |
599 | + Display only the declared type of objects, without reference to the | |
600 | + virtual function table. This is the default setting. | |
601 | + | |
602 | +`show print object' | |
603 | + Show whether actual, or declared, object types are displayed. | |
604 | + | |
605 | +`set print static-members' | |
606 | +`set print static-members on' | |
607 | + Print static members when displaying a C++ object. The default is | |
608 | + on. | |
609 | + | |
610 | +`set print static-members off' | |
611 | + Do not print static members when displaying a C++ object. | |
612 | + | |
613 | +`show print static-members' | |
614 | + Show whether C++ static members are printed, or not. | |
615 | + | |
616 | +`set print vtbl' | |
617 | +`set print vtbl on' | |
618 | + Pretty print C++ virtual function tables. The default is off. | |
619 | + | |
620 | +`set print vtbl off' | |
621 | + Do not pretty print C++ virtual function tables. | |
622 | + | |
623 | +`show print vtbl' | |
624 | + Show whether C++ virtual function tables are pretty printed, or | |
625 | + not. | |
626 | + | |
627 | + | |
628 | +File: gdb.info, Node: Value History, Next: Convenience Vars, Prev: Print Settings, Up: Data | |
629 | + | |
630 | +Value history | |
631 | +============= | |
632 | + | |
633 | + Values printed by the `print' command are saved in the GDB "value | |
634 | +history". This allows you to refer to them in other expressions. | |
635 | +Values are kept until the symbol table is re-read or discarded (for | |
636 | +example with the `file' or `symbol-file' commands). When the symbol | |
637 | +table changes, the value history is discarded, since the values may | |
638 | +contain pointers back to the types defined in the symbol table. | |
639 | + | |
640 | + The values printed are given "history numbers" by which you can | |
641 | +refer to them. These are successive integers starting with one. | |
642 | +`print' shows you the history number assigned to a value by printing | |
643 | +`$NUM = ' before the value; here NUM is the history number. | |
644 | + | |
645 | + To refer to any previous value, use `$' followed by the value's | |
646 | +history number. The way `print' labels its output is designed to | |
647 | +remind you of this. Just `$' refers to the most recent value in the | |
648 | +history, and `$$' refers to the value before that. `$$N' refers to the | |
649 | +Nth value from the end; `$$2' is the value just prior to `$$', `$$1' is | |
650 | +equivalent to `$$', and `$$0' is equivalent to `$'. | |
651 | + | |
652 | + For example, suppose you have just printed a pointer to a structure | |
653 | +and want to see the contents of the structure. It suffices to type | |
654 | + | |
655 | + p *$ | |
656 | + | |
657 | + If you have a chain of structures where the component `next' points | |
658 | +to the next one, you can print the contents of the next one with this: | |
659 | + | |
660 | + p *$.next | |
661 | + | |
662 | +You can print successive links in the chain by repeating this | |
663 | +command--which you can do by just typing <RET>. | |
664 | + | |
665 | + Note that the history records values, not expressions. If the value | |
666 | +of `x' is 4 and you type these commands: | |
667 | + | |
668 | + print x | |
669 | + set x=5 | |
670 | + | |
671 | +then the value recorded in the value history by the `print' command | |
672 | +remains 4 even though the value of `x' has changed. | |
673 | + | |
674 | +`show values' | |
675 | + Print the last ten values in the value history, with their item | |
676 | + numbers. This is like `p $$9' repeated ten times, except that | |
677 | + `show values' does not change the history. | |
678 | + | |
679 | +`show values N' | |
680 | + Print ten history values centered on history item number N. | |
681 | + | |
682 | +`show values +' | |
683 | + Print ten history values just after the values last printed. If | |
684 | + no more values are available, `show values +' produces no display. | |
685 | + | |
686 | + Pressing <RET> to repeat `show values N' has exactly the same effect | |
687 | +as `show values +'. | |
688 | + | |
689 | + | |
690 | +File: gdb.info, Node: Convenience Vars, Next: Registers, Prev: Value History, Up: Data | |
691 | + | |
692 | +Convenience variables | |
693 | +===================== | |
694 | + | |
695 | + GDB provides "convenience variables" that you can use within GDB to | |
696 | +hold on to a value and refer to it later. These variables exist | |
697 | +entirely within GDB; they are not part of your program, and setting a | |
698 | +convenience variable has no direct effect on further execution of your | |
699 | +program. That is why you can use them freely. | |
700 | + | |
701 | + Convenience variables are prefixed with `$'. Any name preceded by | |
702 | +`$' can be used for a convenience variable, unless it is one of the | |
703 | +predefined machine-specific register names (*note Registers::.). | |
704 | +(Value history references, in contrast, are *numbers* preceded by `$'. | |
705 | +*Note Value history: Value History.) | |
706 | + | |
707 | + You can save a value in a convenience variable with an assignment | |
708 | +expression, just as you would set a variable in your program. For | |
709 | +example: | |
710 | + | |
711 | + set $foo = *object_ptr | |
712 | + | |
713 | +would save in `$foo' the value contained in the object pointed to by | |
714 | +`object_ptr'. | |
715 | + | |
716 | + Using a convenience variable for the first time creates it, but its | |
717 | +value is `void' until you assign a new value. You can alter the value | |
718 | +with another assignment at any time. | |
719 | + | |
720 | + Convenience variables have no fixed types. You can assign a | |
721 | +convenience variable any type of value, including structures and | |
722 | +arrays, even if that variable already has a value of a different type. | |
723 | +The convenience variable, when used as an expression, has the type of | |
724 | +its current value. | |
725 | + | |
726 | +`show convenience' | |
727 | + Print a list of convenience variables used so far, and their | |
728 | + values. Abbreviated `show con'. | |
729 | + | |
730 | + One of the ways to use a convenience variable is as a counter to be | |
731 | +incremented or a pointer to be advanced. For example, to print a field | |
732 | +from successive elements of an array of structures: | |
733 | + | |
734 | + set $i = 0 | |
735 | + print bar[$i++]->contents | |
736 | + | |
737 | +Repeat that command by typing <RET>. | |
738 | + | |
739 | + Some convenience variables are created automatically by GDB and given | |
740 | +values likely to be useful. | |
741 | + | |
742 | +`$_' | |
743 | + The variable `$_' is automatically set by the `x' command to the | |
744 | + last address examined (*note Examining memory: Memory.). Other | |
745 | + commands which provide a default address for `x' to examine also | |
746 | + set `$_' to that address; these commands include `info line' and | |
747 | + `info breakpoint'. The type of `$_' is `void *' except when set | |
748 | + by the `x' command, in which case it is a pointer to the type of | |
749 | + `$__'. | |
750 | + | |
751 | +`$__' | |
752 | + The variable `$__' is automatically set by the `x' command to the | |
753 | + value found in the last address examined. Its type is chosen to | |
754 | + match the format in which the data was printed. | |
755 | + | |
756 | +`$_exitcode' | |
757 | + The variable `$_exitcode' is automatically set to the exit code | |
758 | + when the program being debugged terminates. | |
759 | + | |
760 | + | |
761 | +File: gdb.info, Node: Registers, Next: Floating Point Hardware, Prev: Convenience Vars, Up: Data | |
762 | + | |
763 | +Registers | |
764 | +========= | |
765 | + | |
766 | + You can refer to machine register contents, in expressions, as | |
767 | +variables with names starting with `$'. The names of registers are | |
768 | +different for each machine; use `info registers' to see the names used | |
769 | +on your machine. | |
770 | + | |
771 | +`info registers' | |
772 | + Print the names and values of all registers except floating-point | |
773 | + registers (in the selected stack frame). | |
774 | + | |
775 | +`info all-registers' | |
776 | + Print the names and values of all registers, including | |
777 | + floating-point registers. | |
778 | + | |
779 | +`info registers REGNAME ...' | |
780 | + Print the "relativized" value of each specified register REGNAME. | |
781 | + As discussed in detail below, register values are normally | |
782 | + relative to the selected stack frame. REGNAME may be any register | |
783 | + name valid on the machine you are using, with or without the | |
784 | + initial `$'. | |
785 | + | |
786 | + GDB has four "standard" register names that are available (in | |
787 | +expressions) on most machines--whenever they do not conflict with an | |
788 | +architecture's canonical mnemonics for registers. The register names | |
789 | +`$pc' and `$sp' are used for the program counter register and the stack | |
790 | +pointer. `$fp' is used for a register that contains a pointer to the | |
791 | +current stack frame, and `$ps' is used for a register that contains the | |
792 | +processor status. For example, you could print the program counter in | |
793 | +hex with | |
794 | + | |
795 | + p/x $pc | |
796 | + | |
797 | +or print the instruction to be executed next with | |
798 | + | |
799 | + x/i $pc | |
800 | + | |
801 | +or add four to the stack pointer(1) with | |
802 | + | |
803 | + set $sp += 4 | |
804 | + | |
805 | + Whenever possible, these four standard register names are available | |
806 | +on your machine even though the machine has different canonical | |
807 | +mnemonics, so long as there is no conflict. The `info registers' | |
808 | +command shows the canonical names. For example, on the SPARC, `info | |
809 | +registers' displays the processor status register as `$psr' but you can | |
810 | +also refer to it as `$ps'. | |
811 | + | |
812 | + GDB always considers the contents of an ordinary register as an | |
813 | +integer when the register is examined in this way. Some machines have | |
814 | +special registers which can hold nothing but floating point; these | |
815 | +registers are considered to have floating point values. There is no way | |
816 | +to refer to the contents of an ordinary register as floating point value | |
817 | +(although you can *print* it as a floating point value with `print/f | |
818 | +$REGNAME'). | |
819 | + | |
820 | + Some registers have distinct "raw" and "virtual" data formats. This | |
821 | +means that the data format in which the register contents are saved by | |
822 | +the operating system is not the same one that your program normally | |
823 | +sees. For example, the registers of the 68881 floating point | |
824 | +coprocessor are always saved in "extended" (raw) format, but all C | |
825 | +programs expect to work with "double" (virtual) format. In such cases, | |
826 | +GDB normally works with the virtual format only (the format that makes | |
827 | +sense for your program), but the `info registers' command prints the | |
828 | +data in both formats. | |
829 | + | |
830 | + Normally, register values are relative to the selected stack frame | |
831 | +(*note Selecting a frame: Selection.). This means that you get the | |
832 | +value that the register would contain if all stack frames farther in | |
833 | +were exited and their saved registers restored. In order to see the | |
834 | +true contents of hardware registers, you must select the innermost | |
835 | +frame (with `frame 0'). | |
836 | + | |
837 | + However, GDB must deduce where registers are saved, from the machine | |
838 | +code generated by your compiler. If some registers are not saved, or if | |
839 | +GDB is unable to locate the saved registers, the selected stack frame | |
840 | +makes no difference. | |
841 | + | |
842 | +`set rstack_high_address ADDRESS' | |
843 | + On AMD 29000 family processors, registers are saved in a separate | |
844 | + "register stack". There is no way for GDB to determine the extent | |
845 | + of this stack. Normally, GDB just assumes that the stack is "large | |
846 | + enough". This may result in GDB referencing memory locations that | |
847 | + do not exist. If necessary, you can get around this problem by | |
848 | + specifying the ending address of the register stack with the `set | |
849 | + rstack_high_address' command. The argument should be an address, | |
850 | + which you probably want to precede with `0x' to specify in | |
851 | + hexadecimal. | |
852 | + | |
853 | +`show rstack_high_address' | |
854 | + Display the current limit of the register stack, on AMD 29000 | |
855 | + family processors. | |
856 | + | |
857 | + ---------- Footnotes ---------- | |
858 | + | |
859 | + (1) This is a way of removing one word from the stack, on machines | |
860 | +where stacks grow downward in memory (most machines, nowadays). This | |
861 | +assumes that the innermost stack frame is selected; setting `$sp' is | |
862 | +not allowed when other stack frames are selected. To pop entire frames | |
863 | +off the stack, regardless of machine architecture, use `return'; *note | |
864 | +Returning from a function: Returning.. | |
865 | + | |
866 | + | |
867 | +File: gdb.info, Node: Floating Point Hardware, Prev: Registers, Up: Data | |
868 | + | |
869 | +Floating point hardware | |
870 | +======================= | |
871 | + | |
872 | + Depending on the configuration, GDB may be able to give you more | |
873 | +information about the status of the floating point hardware. | |
874 | + | |
875 | +`info float' | |
876 | + Display hardware-dependent information about the floating point | |
877 | + unit. The exact contents and layout vary depending on the | |
878 | + floating point chip. Currently, `info float' is supported on the | |
879 | + ARM and x86 machines. | |
880 | + | |
881 | + | |
882 | +File: gdb.info, Node: Languages, Next: Symbols, Prev: Data, Up: Top | |
883 | + | |
884 | +Using GDB with Different Languages | |
885 | +********************************** | |
886 | + | |
887 | + Although programming languages generally have common aspects, they | |
888 | +are rarely expressed in the same manner. For instance, in ANSI C, | |
889 | +dereferencing a pointer `p' is accomplished by `*p', but in Modula-2, | |
890 | +it is accomplished by `p^'. Values can also be represented (and | |
891 | +displayed) differently. Hex numbers in C appear as `0x1ae', while in | |
892 | +Modula-2 they appear as `1AEH'. | |
893 | + | |
894 | + Language-specific information is built into GDB for some languages, | |
895 | +allowing you to express operations like the above in your program's | |
896 | +native language, and allowing GDB to output values in a manner | |
897 | +consistent with the syntax of your program's native language. The | |
898 | +language you use to build expressions is called the "working language". | |
899 | + | |
900 | +* Menu: | |
901 | + | |
902 | +* Setting:: Switching between source languages | |
903 | +* Show:: Displaying the language | |
904 | + | |
905 | +* Checks:: Type and range checks | |
906 | + | |
907 | +* Support:: Supported languages | |
908 | + | |
909 | + | |
910 | +File: gdb.info, Node: Setting, Next: Show, Prev: Languages, Up: Languages | |
911 | + | |
912 | +Switching between source languages | |
913 | +================================== | |
914 | + | |
915 | + There are two ways to control the working language--either have GDB | |
916 | +set it automatically, or select it manually yourself. You can use the | |
917 | +`set language' command for either purpose. On startup, GDB defaults to | |
918 | +setting the language automatically. The working language is used to | |
919 | +determine how expressions you type are interpreted, how values are | |
920 | +printed, etc. | |
921 | + | |
922 | + In addition to the working language, every source file that GDB | |
923 | +knows about has its own working language. For some object file | |
924 | +formats, the compiler might indicate which language a particular source | |
925 | +file is in. However, most of the time GDB infers the language from the | |
926 | +name of the file. The language of a source file controls whether C++ | |
927 | +names are demangled--this way `backtrace' can show each frame | |
928 | +appropriately for its own language. There is no way to set the | |
929 | +language of a source file from within GDB. | |
930 | + | |
931 | + This is most commonly a problem when you use a program, such as | |
932 | +`cfront' or `f2c', that generates C but is written in another language. | |
933 | +In that case, make the program use `#line' directives in its C output; | |
934 | +that way GDB will know the correct language of the source code of the | |
935 | +original program, and will display that source code, not the generated | |
936 | +C code. | |
937 | + | |
938 | +* Menu: | |
939 | + | |
940 | +* Filenames:: Filename extensions and languages. | |
941 | +* Manually:: Setting the working language manually | |
942 | +* Automatically:: Having GDB infer the source language | |
943 | + | |
944 | + | |
945 | +File: gdb.info, Node: Filenames, Next: Manually, Prev: Setting, Up: Setting | |
946 | + | |
947 | +List of filename extensions and languages | |
948 | +----------------------------------------- | |
949 | + | |
950 | + If a source file name ends in one of the following extensions, then | |
951 | +GDB infers that its language is the one indicated. | |
952 | + | |
953 | +`.c' | |
954 | + C source file | |
955 | + | |
956 | +`.C' | |
957 | +`.cc' | |
958 | +`.cp' | |
959 | +`.cpp' | |
960 | +`.cxx' | |
961 | +`.c++' | |
962 | + C++ source file | |
963 | + | |
964 | +`.f' | |
965 | +`.F' | |
966 | + Fortran source file | |
967 | + | |
968 | +`.ch' | |
969 | +`.c186' | |
970 | +`.c286' | |
971 | + CHILL source file. | |
972 | + | |
973 | +`.mod' | |
974 | + Modula-2 source file | |
975 | + | |
976 | +`.s' | |
977 | +`.S' | |
978 | + Assembler source file. This actually behaves almost like C, but | |
979 | + GDB does not skip over function prologues when stepping. | |
980 | + | |
981 | + In addition, you may set the language associated with a filename | |
982 | +extension. *Note Displaying the language: Show. | |
983 | + | |
984 | + | |
985 | +File: gdb.info, Node: Manually, Next: Automatically, Prev: Filenames, Up: Setting | |
986 | + | |
987 | +Setting the working language | |
988 | +---------------------------- | |
989 | + | |
990 | + If you allow GDB to set the language automatically, expressions are | |
991 | +interpreted the same way in your debugging session and your program. | |
992 | + | |
993 | + If you wish, you may set the language manually. To do this, issue | |
994 | +the command `set language LANG', where LANG is the name of a language, | |
995 | +such as `c' or `modula-2'. For a list of the supported languages, type | |
996 | +`set language'. | |
997 | + | |
998 | + Setting the language manually prevents GDB from updating the working | |
999 | +language automatically. This can lead to confusion if you try to debug | |
1000 | +a program when the working language is not the same as the source | |
1001 | +language, when an expression is acceptable to both languages--but means | |
1002 | +different things. For instance, if the current source file were | |
1003 | +written in C, and GDB was parsing Modula-2, a command such as: | |
1004 | + | |
1005 | + print a = b + c | |
1006 | + | |
1007 | +might not have the effect you intended. In C, this means to add `b' | |
1008 | +and `c' and place the result in `a'. The result printed would be the | |
1009 | +value of `a'. In Modula-2, this means to compare `a' to the result of | |
1010 | +`b+c', yielding a `BOOLEAN' value. | |
1011 | + | |
1012 | + | |
1013 | +File: gdb.info, Node: Automatically, Prev: Manually, Up: Setting | |
1014 | + | |
1015 | +Having GDB infer the source language | |
1016 | +------------------------------------ | |
1017 | + | |
1018 | + To have GDB set the working language automatically, use `set | |
1019 | +language local' or `set language auto'. GDB then infers the working | |
1020 | +language. That is, when your program stops in a frame (usually by | |
1021 | +encountering a breakpoint), GDB sets the working language to the | |
1022 | +language recorded for the function in that frame. If the language for | |
1023 | +a frame is unknown (that is, if the function or block corresponding to | |
1024 | +the frame was defined in a source file that does not have a recognized | |
1025 | +extension), the current working language is not changed, and GDB issues | |
1026 | +a warning. | |
1027 | + | |
1028 | + This may not seem necessary for most programs, which are written | |
1029 | +entirely in one source language. However, program modules and libraries | |
1030 | +written in one source language can be used by a main program written in | |
1031 | +a different source language. Using `set language auto' in this case | |
1032 | +frees you from having to set the working language manually. | |
1033 | + | |
1034 | + | |
1035 | +File: gdb.info, Node: Show, Next: Checks, Prev: Setting, Up: Languages | |
1036 | + | |
1037 | +Displaying the language | |
1038 | +======================= | |
1039 | + | |
1040 | + The following commands help you find out which language is the | |
1041 | +working language, and also what language source files were written in. | |
1042 | + | |
1043 | +`show language' | |
1044 | + Display the current working language. This is the language you | |
1045 | + can use with commands such as `print' to build and compute | |
1046 | + expressions that may involve variables in your program. | |
1047 | + | |
1048 | +`info frame' | |
1049 | + Display the source language for this frame. This language becomes | |
1050 | + the working language if you use an identifier from this frame. | |
1051 | + *Note Information about a frame: Frame Info, to identify the other | |
1052 | + information listed here. | |
1053 | + | |
1054 | +`info source' | |
1055 | + Display the source language of this source file. *Note Examining | |
1056 | + the Symbol Table: Symbols, to identify the other information | |
1057 | + listed here. | |
1058 | + | |
1059 | + In unusual circumstances, you may have source files with extensions | |
1060 | +not in the standard list. You can then set the extension associated | |
1061 | +with a language explicitly: | |
1062 | + | |
1063 | +`set extension-language .EXT LANGUAGE' | |
1064 | + Set source files with extension .EXT to be assumed to be in the | |
1065 | + source language LANGUAGE. | |
1066 | + | |
1067 | +`info extensions' | |
1068 | + List all the filename extensions and the associated languages. | |
1069 | + | |
1070 | + | |
1071 | +File: gdb.info, Node: Checks, Next: Support, Prev: Show, Up: Languages | |
1072 | + | |
1073 | +Type and range checking | |
1074 | +======================= | |
1075 | + | |
1076 | + *Warning:* In this release, the GDB commands for type and range | |
1077 | + checking are included, but they do not yet have any effect. This | |
1078 | + section documents the intended facilities. | |
1079 | + | |
1080 | + Some languages are designed to guard you against making seemingly | |
1081 | +common errors through a series of compile- and run-time checks. These | |
1082 | +include checking the type of arguments to functions and operators, and | |
1083 | +making sure mathematical overflows are caught at run time. Checks such | |
1084 | +as these help to ensure a program's correctness once it has been | |
1085 | +compiled by eliminating type mismatches, and providing active checks | |
1086 | +for range errors when your program is running. | |
1087 | + | |
1088 | + GDB can check for conditions like the above if you wish. Although | |
1089 | +GDB does not check the statements in your program, it can check | |
1090 | +expressions entered directly into GDB for evaluation via the `print' | |
1091 | +command, for example. As with the working language, GDB can also | |
1092 | +decide whether or not to check automatically based on your program's | |
1093 | +source language. *Note Supported languages: Support, for the default | |
1094 | +settings of supported languages. | |
1095 | + | |
1096 | +* Menu: | |
1097 | + | |
1098 | +* Type Checking:: An overview of type checking | |
1099 | +* Range Checking:: An overview of range checking | |
1100 | + | |
1101 | + | |
1102 | +File: gdb.info, Node: Type Checking, Next: Range Checking, Prev: Checks, Up: Checks | |
1103 | + | |
1104 | +An overview of type checking | |
1105 | +---------------------------- | |
1106 | + | |
1107 | + Some languages, such as Modula-2, are strongly typed, meaning that | |
1108 | +the arguments to operators and functions have to be of the correct type, | |
1109 | +otherwise an error occurs. These checks prevent type mismatch errors | |
1110 | +from ever causing any run-time problems. For example, | |
1111 | + | |
1112 | + 1 + 2 => 3 | |
1113 | +but | |
1114 | + error--> 1 + 2.3 | |
1115 | + | |
1116 | + The second example fails because the `CARDINAL' 1 is not | |
1117 | +type-compatible with the `REAL' 2.3. | |
1118 | + | |
1119 | + For the expressions you use in GDB commands, you can tell the GDB | |
1120 | +type checker to skip checking; to treat any mismatches as errors and | |
1121 | +abandon the expression; or to only issue warnings when type mismatches | |
1122 | +occur, but evaluate the expression anyway. When you choose the last of | |
1123 | +these, GDB evaluates expressions like the second example above, but | |
1124 | +also issues a warning. | |
1125 | + | |
1126 | + Even if you turn type checking off, there may be other reasons | |
1127 | +related to type that prevent GDB from evaluating an expression. For | |
1128 | +instance, GDB does not know how to add an `int' and a `struct foo'. | |
1129 | +These particular type errors have nothing to do with the language in | |
1130 | +use, and usually arise from expressions, such as the one described | |
1131 | +above, which make little sense to evaluate anyway. | |
1132 | + | |
1133 | + Each language defines to what degree it is strict about type. For | |
1134 | +instance, both Modula-2 and C require the arguments to arithmetical | |
1135 | +operators to be numbers. In C, enumerated types and pointers can be | |
1136 | +represented as numbers, so that they are valid arguments to mathematical | |
1137 | +operators. *Note Supported languages: Support, for further details on | |
1138 | +specific languages. | |
1139 | + | |
1140 | + GDB provides some additional commands for controlling the type | |
1141 | +checker: | |
1142 | + | |
1143 | +`set check type auto' | |
1144 | + Set type checking on or off based on the current working language. | |
1145 | + *Note Supported languages: Support, for the default settings for | |
1146 | + each language. | |
1147 | + | |
1148 | +`set check type on' | |
1149 | +`set check type off' | |
1150 | + Set type checking on or off, overriding the default setting for the | |
1151 | + current working language. Issue a warning if the setting does not | |
1152 | + match the language default. If any type mismatches occur in | |
1153 | + evaluating an expression while typechecking is on, GDB prints a | |
1154 | + message and aborts evaluation of the expression. | |
1155 | + | |
1156 | +`set check type warn' | |
1157 | + Cause the type checker to issue warnings, but to always attempt to | |
1158 | + evaluate the expression. Evaluating the expression may still be | |
1159 | + impossible for other reasons. For example, GDB cannot add numbers | |
1160 | + and structures. | |
1161 | + | |
1162 | +`show type' | |
1163 | + Show the current setting of the type checker, and whether or not | |
1164 | + GDB is setting it automatically. | |
1165 | + | |
1166 | + | |
1167 | +File: gdb.info, Node: Range Checking, Prev: Type Checking, Up: Checks | |
1168 | + | |
1169 | +An overview of range checking | |
1170 | +----------------------------- | |
1171 | + | |
1172 | + In some languages (such as Modula-2), it is an error to exceed the | |
1173 | +bounds of a type; this is enforced with run-time checks. Such range | |
1174 | +checking is meant to ensure program correctness by making sure | |
1175 | +computations do not overflow, or indices on an array element access do | |
1176 | +not exceed the bounds of the array. | |
1177 | + | |
1178 | + For expressions you use in GDB commands, you can tell GDB to treat | |
1179 | +range errors in one of three ways: ignore them, always treat them as | |
1180 | +errors and abandon the expression, or issue warnings but evaluate the | |
1181 | +expression anyway. | |
1182 | + | |
1183 | + A range error can result from numerical overflow, from exceeding an | |
1184 | +array index bound, or when you type a constant that is not a member of | |
1185 | +any type. Some languages, however, do not treat overflows as an error. | |
1186 | +In many implementations of C, mathematical overflow causes the result | |
1187 | +to "wrap around" to lower values--for example, if M is the largest | |
1188 | +integer value, and S is the smallest, then | |
1189 | + | |
1190 | + M + 1 => S | |
1191 | + | |
1192 | + This, too, is specific to individual languages, and in some cases | |
1193 | +specific to individual compilers or machines. *Note Supported | |
1194 | +languages: Support, for further details on specific languages. | |
1195 | + | |
1196 | + GDB provides some additional commands for controlling the range | |
1197 | +checker: | |
1198 | + | |
1199 | +`set check range auto' | |
1200 | + Set range checking on or off based on the current working language. | |
1201 | + *Note Supported languages: Support, for the default settings for | |
1202 | + each language. | |
1203 | + | |
1204 | +`set check range on' | |
1205 | +`set check range off' | |
1206 | + Set range checking on or off, overriding the default setting for | |
1207 | + the current working language. A warning is issued if the setting | |
1208 | + does not match the language default. If a range error occurs, | |
1209 | + then a message is printed and evaluation of the expression is | |
1210 | + aborted. | |
1211 | + | |
1212 | +`set check range warn' | |
1213 | + Output messages when the GDB range checker detects a range error, | |
1214 | + but attempt to evaluate the expression anyway. Evaluating the | |
1215 | + expression may still be impossible for other reasons, such as | |
1216 | + accessing memory that the process does not own (a typical example | |
1217 | + from many Unix systems). | |
1218 | + | |
1219 | +`show range' | |
1220 | + Show the current setting of the range checker, and whether or not | |
1221 | + it is being set automatically by GDB. | |
1222 | + | |
1223 | + | |
1224 | +File: gdb.info, Node: Support, Prev: Checks, Up: Languages | |
1225 | + | |
1226 | +Supported languages | |
1227 | +=================== | |
1228 | + | |
1229 | + GDB supports C, C++, Fortran, Chill, assembly, and Modula-2. Some | |
1230 | +GDB features may be used in expressions regardless of the language you | |
1231 | +use: the GDB `@' and `::' operators, and the `{type}addr' construct | |
1232 | +(*note Expressions: Expressions.) can be used with the constructs of | |
1233 | +any supported language. | |
1234 | + | |
1235 | + The following sections detail to what degree each source language is | |
1236 | +supported by GDB. These sections are not meant to be language | |
1237 | +tutorials or references, but serve only as a reference guide to what the | |
1238 | +GDB expression parser accepts, and what input and output formats should | |
1239 | +look like for different languages. There are many good books written | |
1240 | +on each of these languages; please look to these for a language | |
1241 | +reference or tutorial. | |
1242 | + | |
1243 | +* Menu: | |
1244 | + | |
1245 | +* C:: C and C++ | |
1246 | +* Modula-2:: Modula-2 | |
1247 | + | |
1248 | + | |
1249 | +File: gdb.info, Node: C, Next: Modula-2, Up: Support | |
1250 | + | |
1251 | +C and C++ | |
1252 | +--------- | |
1253 | + | |
1254 | + Since C and C++ are so closely related, many features of GDB apply | |
1255 | +to both languages. Whenever this is the case, we discuss those | |
1256 | +languages together. | |
1257 | + | |
1258 | + The C++ debugging facilities are jointly implemented by the C++ | |
1259 | +compiler and GDB. Therefore, to debug your C++ code effectively, you | |
1260 | +must compile your C++ programs with a supported C++ compiler, such as | |
1261 | +GNU `g++', or the HP ANSI C++ compiler (`aCC'). | |
1262 | + | |
1263 | + For best results when using GNU C++, use the stabs debugging format. | |
1264 | +You can select that format explicitly with the `g++' command-line | |
1265 | +options `-gstabs' or `-gstabs+'. See *Note Options for Debugging Your | |
1266 | +Program or GNU CC: (gcc.info)Debugging Options, for more information. | |
1267 | + | |
1268 | +* Menu: | |
1269 | + | |
1270 | +* C Operators:: C and C++ operators | |
1271 | +* C Constants:: C and C++ constants | |
1272 | +* Cplus expressions:: C++ expressions | |
1273 | +* C Defaults:: Default settings for C and C++ | |
1274 | + | |
1275 | +* C Checks:: C and C++ type and range checks | |
1276 | + | |
1277 | +* Debugging C:: GDB and C | |
1278 | +* Debugging C plus plus:: GDB features for C++ | |
1279 | + |
@@ -0,0 +1,1185 @@ | ||
1 | +This is Info file ./gdb.info, produced by Makeinfo version 1.68 from | |
2 | +the input file gdb.texinfo. | |
3 | + | |
4 | +START-INFO-DIR-ENTRY | |
5 | +* Gdb: (gdb). The GNU debugger. | |
6 | +END-INFO-DIR-ENTRY | |
7 | + This file documents the GNU debugger GDB. | |
8 | + | |
9 | + This is the Seventh Edition, February 1999, of `Debugging with GDB: | |
10 | +the GNU Source-Level Debugger' for GDB Version 4.18. | |
11 | + | |
12 | + Copyright (C) 1988-1999 Free Software Foundation, Inc. | |
13 | + | |
14 | + Permission is granted to make and distribute verbatim copies of this | |
15 | +manual provided the copyright notice and this permission notice are | |
16 | +preserved on all copies. | |
17 | + | |
18 | + Permission is granted to copy and distribute modified versions of | |
19 | +this manual under the conditions for verbatim copying, provided also | |
20 | +that the entire resulting derived work is distributed under the terms | |
21 | +of a permission notice identical to this one. | |
22 | + | |
23 | + Permission is granted to copy and distribute translations of this | |
24 | +manual into another language, under the above conditions for modified | |
25 | +versions. | |
26 | + | |
27 | + | |
28 | +File: gdb.info, Node: C Operators, Next: C Constants, Up: C | |
29 | + | |
30 | +C and C++ operators | |
31 | +................... | |
32 | + | |
33 | + Operators must be defined on values of specific types. For instance, | |
34 | +`+' is defined on numbers, but not on structures. Operators are often | |
35 | +defined on groups of types. | |
36 | + | |
37 | + For the purposes of C and C++, the following definitions hold: | |
38 | + | |
39 | + * *Integral types* include `int' with any of its storage-class | |
40 | + specifiers; `char'; and `enum'. | |
41 | + | |
42 | + * *Floating-point types* include `float' and `double'. | |
43 | + | |
44 | + * *Pointer types* include all types defined as `(TYPE *)'. | |
45 | + | |
46 | + * *Scalar types* include all of the above. | |
47 | + | |
48 | +The following operators are supported. They are listed here in order | |
49 | +of increasing precedence: | |
50 | + | |
51 | +`,' | |
52 | + The comma or sequencing operator. Expressions in a | |
53 | + comma-separated list are evaluated from left to right, with the | |
54 | + result of the entire expression being the last expression | |
55 | + evaluated. | |
56 | + | |
57 | +`=' | |
58 | + Assignment. The value of an assignment expression is the value | |
59 | + assigned. Defined on scalar types. | |
60 | + | |
61 | +`OP=' | |
62 | + Used in an expression of the form `A OP= B', and translated to | |
63 | + `A = A OP B'. `OP=' and `=' have the same precendence. OP is any | |
64 | + one of the operators `|', `^', `&', `<<', `>>', `+', `-', `*', | |
65 | + `/', `%'. | |
66 | + | |
67 | +`?:' | |
68 | + The ternary operator. `A ? B : C' can be thought of as: if A | |
69 | + then B else C. A should be of an integral type. | |
70 | + | |
71 | +`||' | |
72 | + Logical OR. Defined on integral types. | |
73 | + | |
74 | +`&&' | |
75 | + Logical AND. Defined on integral types. | |
76 | + | |
77 | +`|' | |
78 | + Bitwise OR. Defined on integral types. | |
79 | + | |
80 | +`^' | |
81 | + Bitwise exclusive-OR. Defined on integral types. | |
82 | + | |
83 | +`&' | |
84 | + Bitwise AND. Defined on integral types. | |
85 | + | |
86 | +`==, !=' | |
87 | + Equality and inequality. Defined on scalar types. The value of | |
88 | + these expressions is 0 for false and non-zero for true. | |
89 | + | |
90 | +`<, >, <=, >=' | |
91 | + Less than, greater than, less than or equal, greater than or equal. | |
92 | + Defined on scalar types. The value of these expressions is 0 for | |
93 | + false and non-zero for true. | |
94 | + | |
95 | +`<<, >>' | |
96 | + left shift, and right shift. Defined on integral types. | |
97 | + | |
98 | +`@' | |
99 | + The GDB "artificial array" operator (*note Expressions: | |
100 | + Expressions.). | |
101 | + | |
102 | +`+, -' | |
103 | + Addition and subtraction. Defined on integral types, | |
104 | + floating-point types and pointer types. | |
105 | + | |
106 | +`*, /, %' | |
107 | + Multiplication, division, and modulus. Multiplication and | |
108 | + division are defined on integral and floating-point types. | |
109 | + Modulus is defined on integral types. | |
110 | + | |
111 | +`++, --' | |
112 | + Increment and decrement. When appearing before a variable, the | |
113 | + operation is performed before the variable is used in an | |
114 | + expression; when appearing after it, the variable's value is used | |
115 | + before the operation takes place. | |
116 | + | |
117 | +`*' | |
118 | + Pointer dereferencing. Defined on pointer types. Same precedence | |
119 | + as `++'. | |
120 | + | |
121 | +`&' | |
122 | + Address operator. Defined on variables. Same precedence as `++'. | |
123 | + | |
124 | + For debugging C++, GDB implements a use of `&' beyond what is | |
125 | + allowed in the C++ language itself: you can use `&(&REF)' (or, if | |
126 | + you prefer, simply `&&REF') to examine the address where a C++ | |
127 | + reference variable (declared with `&REF') is stored. | |
128 | + | |
129 | +`-' | |
130 | + Negative. Defined on integral and floating-point types. Same | |
131 | + precedence as `++'. | |
132 | + | |
133 | +`!' | |
134 | + Logical negation. Defined on integral types. Same precedence as | |
135 | + `++'. | |
136 | + | |
137 | +`~' | |
138 | + Bitwise complement operator. Defined on integral types. Same | |
139 | + precedence as `++'. | |
140 | + | |
141 | +`., ->' | |
142 | + Structure member, and pointer-to-structure member. For | |
143 | + convenience, GDB regards the two as equivalent, choosing whether | |
144 | + to dereference a pointer based on the stored type information. | |
145 | + Defined on `struct' and `union' data. | |
146 | + | |
147 | +`[]' | |
148 | + Array indexing. `A[I]' is defined as `*(A+I)'. Same precedence | |
149 | + as `->'. | |
150 | + | |
151 | +`()' | |
152 | + Function parameter list. Same precedence as `->'. | |
153 | + | |
154 | +`::' | |
155 | + C++ scope resolution operator. Defined on `struct', `union', and | |
156 | + `class' types. | |
157 | + | |
158 | +`::' | |
159 | + Doubled colons also represent the GDB scope operator (*note | |
160 | + Expressions: Expressions.). Same precedence as `::', above. | |
161 | + | |
162 | +* Menu: | |
163 | + | |
164 | +* C Constants:: | |
165 | + | |
166 | + | |
167 | +File: gdb.info, Node: C Constants, Next: Cplus expressions, Prev: C Operators, Up: C | |
168 | + | |
169 | +C and C++ constants | |
170 | +................... | |
171 | + | |
172 | + GDB allows you to express the constants of C and C++ in the | |
173 | +following ways: | |
174 | + | |
175 | + * Integer constants are a sequence of digits. Octal constants are | |
176 | + specified by a leading `0' (i.e. zero), and hexadecimal constants | |
177 | + by a leading `0x' or `0X'. Constants may also end with a letter | |
178 | + `l', specifying that the constant should be treated as a `long' | |
179 | + value. | |
180 | + | |
181 | + * Floating point constants are a sequence of digits, followed by a | |
182 | + decimal point, followed by a sequence of digits, and optionally | |
183 | + followed by an exponent. An exponent is of the form: | |
184 | + `e[[+]|-]NNN', where NNN is another sequence of digits. The `+' | |
185 | + is optional for positive exponents. | |
186 | + | |
187 | + * Enumerated constants consist of enumerated identifiers, or their | |
188 | + integral equivalents. | |
189 | + | |
190 | + * Character constants are a single character surrounded by single | |
191 | + quotes (`''), or a number--the ordinal value of the corresponding | |
192 | + character (usually its ASCII value). Within quotes, the single | |
193 | + character may be represented by a letter or by "escape sequences", | |
194 | + which are of the form `\NNN', where NNN is the octal representation | |
195 | + of the character's ordinal value; or of the form `\X', where `X' | |
196 | + is a predefined special character--for example, `\n' for newline. | |
197 | + | |
198 | + * String constants are a sequence of character constants surrounded | |
199 | + by double quotes (`"'). | |
200 | + | |
201 | + * Pointer constants are an integral value. You can also write | |
202 | + pointers to constants using the C operator `&'. | |
203 | + | |
204 | + * Array constants are comma-separated lists surrounded by braces `{' | |
205 | + and `}'; for example, `{1,2,3}' is a three-element array of | |
206 | + integers, `{{1,2}, {3,4}, {5,6}}' is a three-by-two array, and | |
207 | + `{&"hi", &"there", &"fred"}' is a three-element array of pointers. | |
208 | + | |
209 | +* Menu: | |
210 | + | |
211 | +* Cplus expressions:: | |
212 | +* C Defaults:: | |
213 | + | |
214 | +* C Checks:: | |
215 | + | |
216 | +* Debugging C:: | |
217 | + | |
218 | + | |
219 | +File: gdb.info, Node: Cplus expressions, Next: C Defaults, Prev: C Constants, Up: C | |
220 | + | |
221 | +C++ expressions | |
222 | +............... | |
223 | + | |
224 | + GDB expression handling can interpret most C++ expressions. | |
225 | + | |
226 | + *Warning:* GDB can only debug C++ code if you use the proper | |
227 | + compiler. Typically, C++ debugging depends on the use of | |
228 | + additional debugging information in the symbol table, and thus | |
229 | + requires special support. In particular, if your compiler | |
230 | + generates a.out, MIPS ECOFF, RS/6000 XCOFF, or ELF with stabs | |
231 | + extensions to the symbol table, these facilities are all | |
232 | + available. (With GNU CC, you can use the `-gstabs' option to | |
233 | + request stabs debugging extensions explicitly.) Where the object | |
234 | + code format is standard COFF or DWARF in ELF, on the other hand, | |
235 | + most of the C++ support in GDB does *not* work. | |
236 | + | |
237 | + 1. Member function calls are allowed; you can use expressions like | |
238 | + | |
239 | + count = aml->GetOriginal(x, y) | |
240 | + | |
241 | + 2. While a member function is active (in the selected stack frame), | |
242 | + your expressions have the same namespace available as the member | |
243 | + function; that is, GDB allows implicit references to the class | |
244 | + instance pointer `this' following the same rules as C++. | |
245 | + | |
246 | + 3. You can call overloaded functions; GDB resolves the function call | |
247 | + to the right definition, with one restriction--you must use | |
248 | + arguments of the type required by the function that you want to | |
249 | + call. GDB does not perform conversions requiring constructors or | |
250 | + user-defined type operators. | |
251 | + | |
252 | + 4. GDB understands variables declared as C++ references; you can use | |
253 | + them in expressions just as you do in C++ source--they are | |
254 | + automatically dereferenced. | |
255 | + | |
256 | + In the parameter list shown when GDB displays a frame, the values | |
257 | + of reference variables are not displayed (unlike other variables); | |
258 | + this avoids clutter, since references are often used for large | |
259 | + structures. The *address* of a reference variable is always | |
260 | + shown, unless you have specified `set print address off'. | |
261 | + | |
262 | + 5. GDB supports the C++ name resolution operator `::'--your | |
263 | + expressions can use it just as expressions in your program do. | |
264 | + Since one scope may be defined in another, you can use `::' | |
265 | + repeatedly if necessary, for example in an expression like | |
266 | + `SCOPE1::SCOPE2::NAME'. GDB also allows resolving name scope by | |
267 | + reference to source files, in both C and C++ debugging (*note | |
268 | + Program variables: Variables.). | |
269 | + | |
270 | + | |
271 | +File: gdb.info, Node: C Defaults, Next: C Checks, Prev: Cplus expressions, Up: C | |
272 | + | |
273 | +C and C++ defaults | |
274 | +.................. | |
275 | + | |
276 | + If you allow GDB to set type and range checking automatically, they | |
277 | +both default to `off' whenever the working language changes to C or | |
278 | +C++. This happens regardless of whether you or GDB selects the working | |
279 | +language. | |
280 | + | |
281 | + If you allow GDB to set the language automatically, it recognizes | |
282 | +source files whose names end with `.c', `.C', or `.cc', etc, and when | |
283 | +GDB enters code compiled from one of these files, it sets the working | |
284 | +language to C or C++. *Note Having GDB infer the source language: | |
285 | +Automatically, for further details. | |
286 | + | |
287 | + | |
288 | +File: gdb.info, Node: C Checks, Next: Debugging C, Prev: C Defaults, Up: C Constants | |
289 | + | |
290 | +C and C++ type and range checks | |
291 | +............................... | |
292 | + | |
293 | + By default, when GDB parses C or C++ expressions, type checking is | |
294 | +not used. However, if you turn type checking on, GDB considers two | |
295 | +variables type equivalent if: | |
296 | + | |
297 | + * The two variables are structured and have the same structure, | |
298 | + union, or enumerated tag. | |
299 | + | |
300 | + * The two variables have the same type name, or types that have been | |
301 | + declared equivalent through `typedef'. | |
302 | + | |
303 | + Range checking, if turned on, is done on mathematical operations. | |
304 | +Array indices are not checked, since they are often used to index a | |
305 | +pointer that is not itself an array. | |
306 | + | |
307 | + | |
308 | +File: gdb.info, Node: Debugging C, Next: Debugging C plus plus, Prev: C Checks, Up: C | |
309 | + | |
310 | +GDB and C | |
311 | +......... | |
312 | + | |
313 | + The `set print union' and `show print union' commands apply to the | |
314 | +`union' type. When set to `on', any `union' that is inside a `struct' | |
315 | +or `class' is also printed. Otherwise, it appears as `{...}'. | |
316 | + | |
317 | + The `@' operator aids in the debugging of dynamic arrays, formed | |
318 | +with pointers and a memory allocation function. *Note Expressions: | |
319 | +Expressions. | |
320 | + | |
321 | +* Menu: | |
322 | + | |
323 | +* Debugging C plus plus:: | |
324 | + | |
325 | + | |
326 | +File: gdb.info, Node: Debugging C plus plus, Prev: Debugging C, Up: C | |
327 | + | |
328 | +GDB features for C++ | |
329 | +.................... | |
330 | + | |
331 | + Some GDB commands are particularly useful with C++, and some are | |
332 | +designed specifically for use with C++. Here is a summary: | |
333 | + | |
334 | +`breakpoint menus' | |
335 | + When you want a breakpoint in a function whose name is overloaded, | |
336 | + GDB breakpoint menus help you specify which function definition | |
337 | + you want. *Note Breakpoint menus: Breakpoint Menus. | |
338 | + | |
339 | +`rbreak REGEX' | |
340 | + Setting breakpoints using regular expressions is helpful for | |
341 | + setting breakpoints on overloaded functions that are not members | |
342 | + of any special classes. *Note Setting breakpoints: Set Breaks. | |
343 | + | |
344 | +`catch throw' | |
345 | +`catch catch' | |
346 | + Debug C++ exception handling using these commands. *Note Setting | |
347 | + catchpoints: Set Catchpoints. | |
348 | + | |
349 | +`ptype TYPENAME' | |
350 | + Print inheritance relationships as well as other information for | |
351 | + type TYPENAME. *Note Examining the Symbol Table: Symbols. | |
352 | + | |
353 | +`set print demangle' | |
354 | +`show print demangle' | |
355 | +`set print asm-demangle' | |
356 | +`show print asm-demangle' | |
357 | + Control whether C++ symbols display in their source form, both when | |
358 | + displaying code as C++ source and when displaying disassemblies. | |
359 | + *Note Print settings: Print Settings. | |
360 | + | |
361 | +`set print object' | |
362 | +`show print object' | |
363 | + Choose whether to print derived (actual) or declared types of | |
364 | + objects. *Note Print settings: Print Settings. | |
365 | + | |
366 | +`set print vtbl' | |
367 | +`show print vtbl' | |
368 | + Control the format for printing virtual function tables. *Note | |
369 | + Print settings: Print Settings. | |
370 | + | |
371 | +`Overloaded symbol names' | |
372 | + You can specify a particular definition of an overloaded symbol, | |
373 | + using the same notation that is used to declare such symbols in | |
374 | + C++: type `SYMBOL(TYPES)' rather than just SYMBOL. You can also | |
375 | + use the GDB command-line word completion facilities to list the | |
376 | + available choices, or to finish the type list for you. *Note | |
377 | + Command completion: Completion, for details on how to do this. | |
378 | + | |
379 | + | |
380 | +File: gdb.info, Node: Modula-2, Prev: C, Up: Support | |
381 | + | |
382 | +Modula-2 | |
383 | +-------- | |
384 | + | |
385 | + The extensions made to GDB to support Modula-2 only support output | |
386 | +from the GNU Modula-2 compiler (which is currently being developed). | |
387 | +Other Modula-2 compilers are not currently supported, and attempting to | |
388 | +debug executables produced by them is most likely to give an error as | |
389 | +GDB reads in the executable's symbol table. | |
390 | + | |
391 | +* Menu: | |
392 | + | |
393 | +* M2 Operators:: Built-in operators | |
394 | +* Built-In Func/Proc:: Built-in functions and procedures | |
395 | +* M2 Constants:: Modula-2 constants | |
396 | +* M2 Defaults:: Default settings for Modula-2 | |
397 | +* Deviations:: Deviations from standard Modula-2 | |
398 | +* M2 Checks:: Modula-2 type and range checks | |
399 | +* M2 Scope:: The scope operators `::' and `.' | |
400 | +* GDB/M2:: GDB and Modula-2 | |
401 | + | |
402 | + | |
403 | +File: gdb.info, Node: M2 Operators, Next: Built-In Func/Proc, Prev: Modula-2, Up: Modula-2 | |
404 | + | |
405 | +Operators | |
406 | +......... | |
407 | + | |
408 | + Operators must be defined on values of specific types. For instance, | |
409 | +`+' is defined on numbers, but not on structures. Operators are often | |
410 | +defined on groups of types. For the purposes of Modula-2, the | |
411 | +following definitions hold: | |
412 | + | |
413 | + * *Integral types* consist of `INTEGER', `CARDINAL', and their | |
414 | + subranges. | |
415 | + | |
416 | + * *Character types* consist of `CHAR' and its subranges. | |
417 | + | |
418 | + * *Floating-point types* consist of `REAL'. | |
419 | + | |
420 | + * *Pointer types* consist of anything declared as `POINTER TO TYPE'. | |
421 | + | |
422 | + * *Scalar types* consist of all of the above. | |
423 | + | |
424 | + * *Set types* consist of `SET' and `BITSET' types. | |
425 | + | |
426 | + * *Boolean types* consist of `BOOLEAN'. | |
427 | + | |
428 | +The following operators are supported, and appear in order of | |
429 | +increasing precedence: | |
430 | + | |
431 | +`,' | |
432 | + Function argument or array index separator. | |
433 | + | |
434 | +`:=' | |
435 | + Assignment. The value of VAR `:=' VALUE is VALUE. | |
436 | + | |
437 | +`<, >' | |
438 | + Less than, greater than on integral, floating-point, or enumerated | |
439 | + types. | |
440 | + | |
441 | +`<=, >=' | |
442 | + Less than, greater than, less than or equal to, greater than or | |
443 | + equal to on integral, floating-point and enumerated types, or set | |
444 | + inclusion on set types. Same precedence as `<'. | |
445 | + | |
446 | +`=, <>, #' | |
447 | + Equality and two ways of expressing inequality, valid on scalar | |
448 | + types. Same precedence as `<'. In GDB scripts, only `<>' is | |
449 | + available for inequality, since `#' conflicts with the script | |
450 | + comment character. | |
451 | + | |
452 | +`IN' | |
453 | + Set membership. Defined on set types and the types of their | |
454 | + members. Same precedence as `<'. | |
455 | + | |
456 | +`OR' | |
457 | + Boolean disjunction. Defined on boolean types. | |
458 | + | |
459 | +`AND, &' | |
460 | + Boolean conjuction. Defined on boolean types. | |
461 | + | |
462 | +`@' | |
463 | + The GDB "artificial array" operator (*note Expressions: | |
464 | + Expressions.). | |
465 | + | |
466 | +`+, -' | |
467 | + Addition and subtraction on integral and floating-point types, or | |
468 | + union and difference on set types. | |
469 | + | |
470 | +`*' | |
471 | + Multiplication on integral and floating-point types, or set | |
472 | + intersection on set types. | |
473 | + | |
474 | +`/' | |
475 | + Division on floating-point types, or symmetric set difference on | |
476 | + set types. Same precedence as `*'. | |
477 | + | |
478 | +`DIV, MOD' | |
479 | + Integer division and remainder. Defined on integral types. Same | |
480 | + precedence as `*'. | |
481 | + | |
482 | +`-' | |
483 | + Negative. Defined on `INTEGER' and `REAL' data. | |
484 | + | |
485 | +`^' | |
486 | + Pointer dereferencing. Defined on pointer types. | |
487 | + | |
488 | +`NOT' | |
489 | + Boolean negation. Defined on boolean types. Same precedence as | |
490 | + `^'. | |
491 | + | |
492 | +`.' | |
493 | + `RECORD' field selector. Defined on `RECORD' data. Same | |
494 | + precedence as `^'. | |
495 | + | |
496 | +`[]' | |
497 | + Array indexing. Defined on `ARRAY' data. Same precedence as `^'. | |
498 | + | |
499 | +`()' | |
500 | + Procedure argument list. Defined on `PROCEDURE' objects. Same | |
501 | + precedence as `^'. | |
502 | + | |
503 | +`::, .' | |
504 | + GDB and Modula-2 scope operators. | |
505 | + | |
506 | + *Warning:* Sets and their operations are not yet supported, so GDB | |
507 | + treats the use of the operator `IN', or the use of operators `+', | |
508 | + `-', `*', `/', `=', , `<>', `#', `<=', and `>=' on sets as an | |
509 | + error. | |
510 | + | |
511 | + | |
512 | +File: gdb.info, Node: Built-In Func/Proc, Next: M2 Constants, Prev: M2 Operators, Up: Modula-2 | |
513 | + | |
514 | +Built-in functions and procedures | |
515 | +................................. | |
516 | + | |
517 | + Modula-2 also makes available several built-in procedures and | |
518 | +functions. In describing these, the following metavariables are used: | |
519 | + | |
520 | +A | |
521 | + represents an `ARRAY' variable. | |
522 | + | |
523 | +C | |
524 | + represents a `CHAR' constant or variable. | |
525 | + | |
526 | +I | |
527 | + represents a variable or constant of integral type. | |
528 | + | |
529 | +M | |
530 | + represents an identifier that belongs to a set. Generally used in | |
531 | + the same function with the metavariable S. The type of S should | |
532 | + be `SET OF MTYPE' (where MTYPE is the type of M). | |
533 | + | |
534 | +N | |
535 | + represents a variable or constant of integral or floating-point | |
536 | + type. | |
537 | + | |
538 | +R | |
539 | + represents a variable or constant of floating-point type. | |
540 | + | |
541 | +T | |
542 | + represents a type. | |
543 | + | |
544 | +V | |
545 | + represents a variable. | |
546 | + | |
547 | +X | |
548 | + represents a variable or constant of one of many types. See the | |
549 | + explanation of the function for details. | |
550 | + | |
551 | + All Modula-2 built-in procedures also return a result, described | |
552 | +below. | |
553 | + | |
554 | +`ABS(N)' | |
555 | + Returns the absolute value of N. | |
556 | + | |
557 | +`CAP(C)' | |
558 | + If C is a lower case letter, it returns its upper case equivalent, | |
559 | + otherwise it returns its argument | |
560 | + | |
561 | +`CHR(I)' | |
562 | + Returns the character whose ordinal value is I. | |
563 | + | |
564 | +`DEC(V)' | |
565 | + Decrements the value in the variable V. Returns the new value. | |
566 | + | |
567 | +`DEC(V,I)' | |
568 | + Decrements the value in the variable V by I. Returns the new | |
569 | + value. | |
570 | + | |
571 | +`EXCL(M,S)' | |
572 | + Removes the element M from the set S. Returns the new set. | |
573 | + | |
574 | +`FLOAT(I)' | |
575 | + Returns the floating point equivalent of the integer I. | |
576 | + | |
577 | +`HIGH(A)' | |
578 | + Returns the index of the last member of A. | |
579 | + | |
580 | +`INC(V)' | |
581 | + Increments the value in the variable V. Returns the new value. | |
582 | + | |
583 | +`INC(V,I)' | |
584 | + Increments the value in the variable V by I. Returns the new | |
585 | + value. | |
586 | + | |
587 | +`INCL(M,S)' | |
588 | + Adds the element M to the set S if it is not already there. | |
589 | + Returns the new set. | |
590 | + | |
591 | +`MAX(T)' | |
592 | + Returns the maximum value of the type T. | |
593 | + | |
594 | +`MIN(T)' | |
595 | + Returns the minimum value of the type T. | |
596 | + | |
597 | +`ODD(I)' | |
598 | + Returns boolean TRUE if I is an odd number. | |
599 | + | |
600 | +`ORD(X)' | |
601 | + Returns the ordinal value of its argument. For example, the | |
602 | + ordinal value of a character is its ASCII value (on machines | |
603 | + supporting the ASCII character set). X must be of an ordered | |
604 | + type, which include integral, character and enumerated types. | |
605 | + | |
606 | +`SIZE(X)' | |
607 | + Returns the size of its argument. X can be a variable or a type. | |
608 | + | |
609 | +`TRUNC(R)' | |
610 | + Returns the integral part of R. | |
611 | + | |
612 | +`VAL(T,I)' | |
613 | + Returns the member of the type T whose ordinal value is I. | |
614 | + | |
615 | + *Warning:* Sets and their operations are not yet supported, so | |
616 | + GDB treats the use of procedures `INCL' and `EXCL' as an error. | |
617 | + | |
618 | + | |
619 | +File: gdb.info, Node: M2 Constants, Next: M2 Defaults, Prev: Built-In Func/Proc, Up: Modula-2 | |
620 | + | |
621 | +Constants | |
622 | +......... | |
623 | + | |
624 | + GDB allows you to express the constants of Modula-2 in the following | |
625 | +ways: | |
626 | + | |
627 | + * Integer constants are simply a sequence of digits. When used in an | |
628 | + expression, a constant is interpreted to be type-compatible with | |
629 | + the rest of the expression. Hexadecimal integers are specified by | |
630 | + a trailing `H', and octal integers by a trailing `B'. | |
631 | + | |
632 | + * Floating point constants appear as a sequence of digits, followed | |
633 | + by a decimal point and another sequence of digits. An optional | |
634 | + exponent can then be specified, in the form `E[+|-]NNN', where | |
635 | + `[+|-]NNN' is the desired exponent. All of the digits of the | |
636 | + floating point constant must be valid decimal (base 10) digits. | |
637 | + | |
638 | + * Character constants consist of a single character enclosed by a | |
639 | + pair of like quotes, either single (`'') or double (`"'). They may | |
640 | + also be expressed by their ordinal value (their ASCII value, | |
641 | + usually) followed by a `C'. | |
642 | + | |
643 | + * String constants consist of a sequence of characters enclosed by a | |
644 | + pair of like quotes, either single (`'') or double (`"'). Escape | |
645 | + sequences in the style of C are also allowed. *Note C and C++ | |
646 | + constants: C Constants, for a brief explanation of escape | |
647 | + sequences. | |
648 | + | |
649 | + * Enumerated constants consist of an enumerated identifier. | |
650 | + | |
651 | + * Boolean constants consist of the identifiers `TRUE' and `FALSE'. | |
652 | + | |
653 | + * Pointer constants consist of integral values only. | |
654 | + | |
655 | + * Set constants are not yet supported. | |
656 | + | |
657 | + | |
658 | +File: gdb.info, Node: M2 Defaults, Next: Deviations, Prev: M2 Constants, Up: Modula-2 | |
659 | + | |
660 | +Modula-2 defaults | |
661 | +................. | |
662 | + | |
663 | + If type and range checking are set automatically by GDB, they both | |
664 | +default to `on' whenever the working language changes to Modula-2. | |
665 | +This happens regardless of whether you, or GDB, selected the working | |
666 | +language. | |
667 | + | |
668 | + If you allow GDB to set the language automatically, then entering | |
669 | +code compiled from a file whose name ends with `.mod' sets the working | |
670 | +language to Modula-2. *Note Having GDB set the language automatically: | |
671 | +Automatically, for further details. | |
672 | + | |
673 | + | |
674 | +File: gdb.info, Node: Deviations, Next: M2 Checks, Prev: M2 Defaults, Up: Modula-2 | |
675 | + | |
676 | +Deviations from standard Modula-2 | |
677 | +................................. | |
678 | + | |
679 | + A few changes have been made to make Modula-2 programs easier to | |
680 | +debug. This is done primarily via loosening its type strictness: | |
681 | + | |
682 | + * Unlike in standard Modula-2, pointer constants can be formed by | |
683 | + integers. This allows you to modify pointer variables during | |
684 | + debugging. (In standard Modula-2, the actual address contained in | |
685 | + a pointer variable is hidden from you; it can only be modified | |
686 | + through direct assignment to another pointer variable or | |
687 | + expression that returned a pointer.) | |
688 | + | |
689 | + * C escape sequences can be used in strings and characters to | |
690 | + represent non-printable characters. GDB prints out strings with | |
691 | + these escape sequences embedded. Single non-printable characters | |
692 | + are printed using the `CHR(NNN)' format. | |
693 | + | |
694 | + * The assignment operator (`:=') returns the value of its right-hand | |
695 | + argument. | |
696 | + | |
697 | + * All built-in procedures both modify *and* return their argument. | |
698 | + | |
699 | + | |
700 | +File: gdb.info, Node: M2 Checks, Next: M2 Scope, Prev: Deviations, Up: Modula-2 | |
701 | + | |
702 | +Modula-2 type and range checks | |
703 | +.............................. | |
704 | + | |
705 | + *Warning:* in this release, GDB does not yet perform type or range | |
706 | + checking. | |
707 | + | |
708 | + GDB considers two Modula-2 variables type equivalent if: | |
709 | + | |
710 | + * They are of types that have been declared equivalent via a `TYPE | |
711 | + T1 = T2' statement | |
712 | + | |
713 | + * They have been declared on the same line. (Note: This is true of | |
714 | + the GNU Modula-2 compiler, but it may not be true of other | |
715 | + compilers.) | |
716 | + | |
717 | + As long as type checking is enabled, any attempt to combine variables | |
718 | +whose types are not equivalent is an error. | |
719 | + | |
720 | + Range checking is done on all mathematical operations, assignment, | |
721 | +array index bounds, and all built-in functions and procedures. | |
722 | + | |
723 | + | |
724 | +File: gdb.info, Node: M2 Scope, Next: GDB/M2, Prev: M2 Checks, Up: Modula-2 | |
725 | + | |
726 | +The scope operators `::' and `.' | |
727 | +................................ | |
728 | + | |
729 | + There are a few subtle differences between the Modula-2 scope | |
730 | +operator (`.') and the GDB scope operator (`::'). The two have similar | |
731 | +syntax: | |
732 | + | |
733 | + | |
734 | + MODULE . ID | |
735 | + SCOPE :: ID | |
736 | + | |
737 | +where SCOPE is the name of a module or a procedure, MODULE the name of | |
738 | +a module, and ID is any declared identifier within your program, except | |
739 | +another module. | |
740 | + | |
741 | + Using the `::' operator makes GDB search the scope specified by | |
742 | +SCOPE for the identifier ID. If it is not found in the specified | |
743 | +scope, then GDB searches all scopes enclosing the one specified by | |
744 | +SCOPE. | |
745 | + | |
746 | + Using the `.' operator makes GDB search the current scope for the | |
747 | +identifier specified by ID that was imported from the definition module | |
748 | +specified by MODULE. With this operator, it is an error if the | |
749 | +identifier ID was not imported from definition module MODULE, or if ID | |
750 | +is not an identifier in MODULE. | |
751 | + | |
752 | + | |
753 | +File: gdb.info, Node: GDB/M2, Prev: M2 Scope, Up: Modula-2 | |
754 | + | |
755 | +GDB and Modula-2 | |
756 | +................ | |
757 | + | |
758 | + Some GDB commands have little use when debugging Modula-2 programs. | |
759 | +Five subcommands of `set print' and `show print' apply specifically to | |
760 | +C and C++: `vtbl', `demangle', `asm-demangle', `object', and `union'. | |
761 | +The first four apply to C++, and the last to the C `union' type, which | |
762 | +has no direct analogue in Modula-2. | |
763 | + | |
764 | + The `@' operator (*note Expressions: Expressions.), while available | |
765 | +while using any language, is not useful with Modula-2. Its intent is | |
766 | +to aid the debugging of "dynamic arrays", which cannot be created in | |
767 | +Modula-2 as they can in C or C++. However, because an address can be | |
768 | +specified by an integral constant, the construct `{TYPE}ADREXP' is | |
769 | +still useful. (*note Expressions: Expressions.) | |
770 | + | |
771 | + In GDB scripts, the Modula-2 inequality operator `#' is interpreted | |
772 | +as the beginning of a comment. Use `<>' instead. | |
773 | + | |
774 | + | |
775 | +File: gdb.info, Node: Symbols, Next: Altering, Prev: Languages, Up: Top | |
776 | + | |
777 | +Examining the Symbol Table | |
778 | +************************** | |
779 | + | |
780 | + The commands described in this section allow you to inquire about the | |
781 | +symbols (names of variables, functions and types) defined in your | |
782 | +program. This information is inherent in the text of your program and | |
783 | +does not change as your program executes. GDB finds it in your | |
784 | +program's symbol table, in the file indicated when you started GDB | |
785 | +(*note Choosing files: File Options.), or by one of the file-management | |
786 | +commands (*note Commands to specify files: Files.). | |
787 | + | |
788 | + Occasionally, you may need to refer to symbols that contain unusual | |
789 | +characters, which GDB ordinarily treats as word delimiters. The most | |
790 | +frequent case is in referring to static variables in other source files | |
791 | +(*note Program variables: Variables.). File names are recorded in | |
792 | +object files as debugging symbols, but GDB would ordinarily parse a | |
793 | +typical file name, like `foo.c', as the three words `foo' `.' `c'. To | |
794 | +allow GDB to recognize `foo.c' as a single symbol, enclose it in single | |
795 | +quotes; for example, | |
796 | + | |
797 | + p 'foo.c'::x | |
798 | + | |
799 | +looks up the value of `x' in the scope of the file `foo.c'. | |
800 | + | |
801 | +`info address SYMBOL' | |
802 | + Describe where the data for SYMBOL is stored. For a register | |
803 | + variable, this says which register it is kept in. For a | |
804 | + non-register local variable, this prints the stack-frame offset at | |
805 | + which the variable is always stored. | |
806 | + | |
807 | + Note the contrast with `print &SYMBOL', which does not work at all | |
808 | + for a register variable, and for a stack local variable prints the | |
809 | + exact address of the current instantiation of the variable. | |
810 | + | |
811 | +`whatis EXP' | |
812 | + Print the data type of expression EXP. EXP is not actually | |
813 | + evaluated, and any side-effecting operations (such as assignments | |
814 | + or function calls) inside it do not take place. *Note | |
815 | + Expressions: Expressions. | |
816 | + | |
817 | +`whatis' | |
818 | + Print the data type of `$', the last value in the value history. | |
819 | + | |
820 | +`ptype TYPENAME' | |
821 | + Print a description of data type TYPENAME. TYPENAME may be the | |
822 | + name of a type, or for C code it may have the form `class | |
823 | + CLASS-NAME', `struct STRUCT-TAG', `union UNION-TAG' or `enum | |
824 | + ENUM-TAG'. | |
825 | + | |
826 | +`ptype EXP' | |
827 | +`ptype' | |
828 | + Print a description of the type of expression EXP. `ptype' | |
829 | + differs from `whatis' by printing a detailed description, instead | |
830 | + of just the name of the type. | |
831 | + | |
832 | + For example, for this variable declaration: | |
833 | + | |
834 | + struct complex {double real; double imag;} v; | |
835 | + | |
836 | + the two commands give this output: | |
837 | + | |
838 | + (gdb) whatis v | |
839 | + type = struct complex | |
840 | + (gdb) ptype v | |
841 | + type = struct complex { | |
842 | + double real; | |
843 | + double imag; | |
844 | + } | |
845 | + | |
846 | + As with `whatis', using `ptype' without an argument refers to the | |
847 | + type of `$', the last value in the value history. | |
848 | + | |
849 | +`info types REGEXP' | |
850 | +`info types' | |
851 | + Print a brief description of all types whose name matches REGEXP | |
852 | + (or all types in your program, if you supply no argument). Each | |
853 | + complete typename is matched as though it were a complete line; | |
854 | + thus, `i type value' gives information on all types in your | |
855 | + program whose name includes the string `value', but `i type | |
856 | + ^value$' gives information only on types whose complete name is | |
857 | + `value'. | |
858 | + | |
859 | + This command differs from `ptype' in two ways: first, like | |
860 | + `whatis', it does not print a detailed description; second, it | |
861 | + lists all source files where a type is defined. | |
862 | + | |
863 | +`info source' | |
864 | + Show the name of the current source file--that is, the source file | |
865 | + for the function containing the current point of execution--and | |
866 | + the language it was written in. | |
867 | + | |
868 | +`info sources' | |
869 | + Print the names of all source files in your program for which | |
870 | + there is debugging information, organized into two lists: files | |
871 | + whose symbols have already been read, and files whose symbols will | |
872 | + be read when needed. | |
873 | + | |
874 | +`info functions' | |
875 | + Print the names and data types of all defined functions. | |
876 | + | |
877 | +`info functions REGEXP' | |
878 | + Print the names and data types of all defined functions whose | |
879 | + names contain a match for regular expression REGEXP. Thus, `info | |
880 | + fun step' finds all functions whose names include `step'; `info | |
881 | + fun ^step' finds those whose names start with `step'. | |
882 | + | |
883 | +`info variables' | |
884 | + Print the names and data types of all variables that are declared | |
885 | + outside of functions (i.e., excluding local variables). | |
886 | + | |
887 | +`info variables REGEXP' | |
888 | + Print the names and data types of all variables (except for local | |
889 | + variables) whose names contain a match for regular expression | |
890 | + REGEXP. | |
891 | + | |
892 | + Some systems allow individual object files that make up your | |
893 | + program to be replaced without stopping and restarting your | |
894 | + program. For example, in VxWorks you can simply recompile a | |
895 | + defective object file and keep on running. If you are running on | |
896 | + one of these systems, you can allow GDB to reload the symbols for | |
897 | + automatically relinked modules: | |
898 | + | |
899 | + `set symbol-reloading on' | |
900 | + Replace symbol definitions for the corresponding source file | |
901 | + when an object file with a particular name is seen again. | |
902 | + | |
903 | + `set symbol-reloading off' | |
904 | + Do not replace symbol definitions when re-encountering object | |
905 | + files of the same name. This is the default state; if you | |
906 | + are not running on a system that permits automatically | |
907 | + relinking modules, you should leave `symbol-reloading' off, | |
908 | + since otherwise GDB may discard symbols when linking large | |
909 | + programs, that may contain several modules (from different | |
910 | + directories or libraries) with the same name. | |
911 | + | |
912 | + `show symbol-reloading' | |
913 | + Show the current `on' or `off' setting. | |
914 | + | |
915 | +`maint print symbols FILENAME' | |
916 | +`maint print psymbols FILENAME' | |
917 | +`maint print msymbols FILENAME' | |
918 | + Write a dump of debugging symbol data into the file FILENAME. | |
919 | + These commands are used to debug the GDB symbol-reading code. Only | |
920 | + symbols with debugging data are included. If you use `maint print | |
921 | + symbols', GDB includes all the symbols for which it has already | |
922 | + collected full details: that is, FILENAME reflects symbols for | |
923 | + only those files whose symbols GDB has read. You can use the | |
924 | + command `info sources' to find out which files these are. If you | |
925 | + use `maint print psymbols' instead, the dump shows information | |
926 | + about symbols that GDB only knows partially--that is, symbols | |
927 | + defined in files that GDB has skimmed, but not yet read | |
928 | + completely. Finally, `maint print msymbols' dumps just the | |
929 | + minimal symbol information required for each object file from | |
930 | + which GDB has read some symbols. *Note Commands to specify files: | |
931 | + Files, for a discussion of how GDB reads symbols (in the | |
932 | + description of `symbol-file'). | |
933 | + | |
934 | + | |
935 | +File: gdb.info, Node: Altering, Next: GDB Files, Prev: Symbols, Up: Top | |
936 | + | |
937 | +Altering Execution | |
938 | +****************** | |
939 | + | |
940 | + Once you think you have found an error in your program, you might | |
941 | +want to find out for certain whether correcting the apparent error | |
942 | +would lead to correct results in the rest of the run. You can find the | |
943 | +answer by experiment, using the GDB features for altering execution of | |
944 | +the program. | |
945 | + | |
946 | + For example, you can store new values into variables or memory | |
947 | +locations, give your program a signal, restart it at a different | |
948 | +address, or even return prematurely from a function. | |
949 | + | |
950 | +* Menu: | |
951 | + | |
952 | +* Assignment:: Assignment to variables | |
953 | +* Jumping:: Continuing at a different address | |
954 | + | |
955 | +* Signaling:: Giving your program a signal | |
956 | + | |
957 | +* Returning:: Returning from a function | |
958 | +* Calling:: Calling your program's functions | |
959 | +* Patching:: Patching your program | |
960 | + | |
961 | + | |
962 | +File: gdb.info, Node: Assignment, Next: Jumping, Prev: Altering, Up: Altering | |
963 | + | |
964 | +Assignment to variables | |
965 | +======================= | |
966 | + | |
967 | + To alter the value of a variable, evaluate an assignment expression. | |
968 | +*Note Expressions: Expressions. For example, | |
969 | + | |
970 | + print x=4 | |
971 | + | |
972 | +stores the value 4 into the variable `x', and then prints the value of | |
973 | +the assignment expression (which is 4). *Note Using GDB with Different | |
974 | +Languages: Languages, for more information on operators in supported | |
975 | +languages. | |
976 | + | |
977 | + If you are not interested in seeing the value of the assignment, use | |
978 | +the `set' command instead of the `print' command. `set' is really the | |
979 | +same as `print' except that the expression's value is not printed and | |
980 | +is not put in the value history (*note Value history: Value History.). | |
981 | +The expression is evaluated only for its effects. | |
982 | + | |
983 | + If the beginning of the argument string of the `set' command appears | |
984 | +identical to a `set' subcommand, use the `set variable' command instead | |
985 | +of just `set'. This command is identical to `set' except for its lack | |
986 | +of subcommands. For example, if your program has a variable `width', | |
987 | +you get an error if you try to set a new value with just `set | |
988 | +width=13', because GDB has the command `set width': | |
989 | + | |
990 | + (gdb) whatis width | |
991 | + type = double | |
992 | + (gdb) p width | |
993 | + $4 = 13 | |
994 | + (gdb) set width=47 | |
995 | + Invalid syntax in expression. | |
996 | + | |
997 | +The invalid expression, of course, is `=47'. In order to actually set | |
998 | +the program's variable `width', use | |
999 | + | |
1000 | + (gdb) set var width=47 | |
1001 | + | |
1002 | + GDB allows more implicit conversions in assignments than C; you can | |
1003 | +freely store an integer value into a pointer variable or vice versa, | |
1004 | +and you can convert any structure to any other structure that is the | |
1005 | +same length or shorter. | |
1006 | + | |
1007 | + To store values into arbitrary places in memory, use the `{...}' | |
1008 | +construct to generate a value of specified type at a specified address | |
1009 | +(*note Expressions: Expressions.). For example, `{int}0x83040' refers | |
1010 | +to memory location `0x83040' as an integer (which implies a certain size | |
1011 | +and representation in memory), and | |
1012 | + | |
1013 | + set {int}0x83040 = 4 | |
1014 | + | |
1015 | +stores the value 4 into that memory location. | |
1016 | + | |
1017 | + | |
1018 | +File: gdb.info, Node: Jumping, Next: Signaling, Prev: Assignment, Up: Altering | |
1019 | + | |
1020 | +Continuing at a different address | |
1021 | +================================= | |
1022 | + | |
1023 | + Ordinarily, when you continue your program, you do so at the place | |
1024 | +where it stopped, with the `continue' command. You can instead | |
1025 | +continue at an address of your own choosing, with the following | |
1026 | +commands: | |
1027 | + | |
1028 | +`jump LINESPEC' | |
1029 | + Resume execution at line LINESPEC. Execution stops again | |
1030 | + immediately if there is a breakpoint there. *Note Printing source | |
1031 | + lines: List, for a description of the different forms of LINESPEC. | |
1032 | + It is common practice to use the `tbreak' command in conjunction | |
1033 | + with `jump'. *Note Setting breakpoints: Set Breaks. | |
1034 | + | |
1035 | + The `jump' command does not change the current stack frame, or the | |
1036 | + stack pointer, or the contents of any memory location or any | |
1037 | + register other than the program counter. If line LINESPEC is in a | |
1038 | + different function from the one currently executing, the results | |
1039 | + may be bizarre if the two functions expect different patterns of | |
1040 | + arguments or of local variables. For this reason, the `jump' | |
1041 | + command requests confirmation if the specified line is not in the | |
1042 | + function currently executing. However, even bizarre results are | |
1043 | + predictable if you are well acquainted with the machine-language | |
1044 | + code of your program. | |
1045 | + | |
1046 | +`jump *ADDRESS' | |
1047 | + Resume execution at the instruction at address ADDRESS. | |
1048 | + | |
1049 | + You can get much the same effect as the `jump' command by storing a | |
1050 | +new value into the register `$pc'. The difference is that this does | |
1051 | +not start your program running; it only changes the address of where it | |
1052 | +*will* run when you continue. For example, | |
1053 | + | |
1054 | + set $pc = 0x485 | |
1055 | + | |
1056 | +makes the next `continue' command or stepping command execute at | |
1057 | +address `0x485', rather than at the address where your program stopped. | |
1058 | +*Note Continuing and stepping: Continuing and Stepping. | |
1059 | + | |
1060 | + The most common occasion to use the `jump' command is to back | |
1061 | +up--perhaps with more breakpoints set--over a portion of a program that | |
1062 | +has already executed, in order to examine its execution in more detail. | |
1063 | + | |
1064 | + | |
1065 | +File: gdb.info, Node: Signaling, Next: Returning, Prev: Jumping, Up: Altering | |
1066 | + | |
1067 | +Giving your program a signal | |
1068 | +============================ | |
1069 | + | |
1070 | +`signal SIGNAL' | |
1071 | + Resume execution where your program stopped, but immediately give | |
1072 | + it the signal SIGNAL. SIGNAL can be the name or the number of a | |
1073 | + signal. For example, on many systems `signal 2' and `signal | |
1074 | + SIGINT' are both ways of sending an interrupt signal. | |
1075 | + | |
1076 | + Alternatively, if SIGNAL is zero, continue execution without | |
1077 | + giving a signal. This is useful when your program stopped on | |
1078 | + account of a signal and would ordinary see the signal when resumed | |
1079 | + with the `continue' command; `signal 0' causes it to resume | |
1080 | + without a signal. | |
1081 | + | |
1082 | + `signal' does not repeat when you press <RET> a second time after | |
1083 | + executing the command. | |
1084 | + | |
1085 | + Invoking the `signal' command is not the same as invoking the `kill' | |
1086 | +utility from the shell. Sending a signal with `kill' causes GDB to | |
1087 | +decide what to do with the signal depending on the signal handling | |
1088 | +tables (*note Signals::.). The `signal' command passes the signal | |
1089 | +directly to your program. | |
1090 | + | |
1091 | + | |
1092 | +File: gdb.info, Node: Returning, Next: Calling, Prev: Signaling, Up: Altering | |
1093 | + | |
1094 | +Returning from a function | |
1095 | +========================= | |
1096 | + | |
1097 | +`return' | |
1098 | +`return EXPRESSION' | |
1099 | + You can cancel execution of a function call with the `return' | |
1100 | + command. If you give an EXPRESSION argument, its value is used as | |
1101 | + the function's return value. | |
1102 | + | |
1103 | + When you use `return', GDB discards the selected stack frame (and | |
1104 | +all frames within it). You can think of this as making the discarded | |
1105 | +frame return prematurely. If you wish to specify a value to be | |
1106 | +returned, give that value as the argument to `return'. | |
1107 | + | |
1108 | + This pops the selected stack frame (*note Selecting a frame: | |
1109 | +Selection.), and any other frames inside of it, leaving its caller as | |
1110 | +the innermost remaining frame. That frame becomes selected. The | |
1111 | +specified value is stored in the registers used for returning values of | |
1112 | +functions. | |
1113 | + | |
1114 | + The `return' command does not resume execution; it leaves the | |
1115 | +program stopped in the state that would exist if the function had just | |
1116 | +returned. In contrast, the `finish' command (*note Continuing and | |
1117 | +stepping: Continuing and Stepping.) resumes execution until the | |
1118 | +selected stack frame returns naturally. | |
1119 | + | |
1120 | + | |
1121 | +File: gdb.info, Node: Calling, Next: Patching, Prev: Returning, Up: Altering | |
1122 | + | |
1123 | +Calling program functions | |
1124 | +========================= | |
1125 | + | |
1126 | +`call EXPR' | |
1127 | + Evaluate the expression EXPR without displaying `void' returned | |
1128 | + values. | |
1129 | + | |
1130 | + You can use this variant of the `print' command if you want to | |
1131 | +execute a function from your program, but without cluttering the output | |
1132 | +with `void' returned values. If the result is not void, it is printed | |
1133 | +and saved in the value history. | |
1134 | + | |
1135 | + For the A29K, a user-controlled variable `call_scratch_address', | |
1136 | +specifies the location of a scratch area to be used when GDB calls a | |
1137 | +function in the target. This is necessary because the usual method of | |
1138 | +putting the scratch area on the stack does not work in systems that | |
1139 | +have separate instruction and data spaces. | |
1140 | + | |
1141 | + | |
1142 | +File: gdb.info, Node: Patching, Prev: Calling, Up: Altering | |
1143 | + | |
1144 | +Patching programs | |
1145 | +================= | |
1146 | + | |
1147 | + By default, GDB opens the file containing your program's executable | |
1148 | +code (or the corefile) read-only. This prevents accidental alterations | |
1149 | +to machine code; but it also prevents you from intentionally patching | |
1150 | +your program's binary. | |
1151 | + | |
1152 | + If you'd like to be able to patch the binary, you can specify that | |
1153 | +explicitly with the `set write' command. For example, you might want | |
1154 | +to turn on internal debugging flags, or even to make emergency repairs. | |
1155 | + | |
1156 | +`set write on' | |
1157 | +`set write off' | |
1158 | + If you specify `set write on', GDB opens executable and core files | |
1159 | + for both reading and writing; if you specify `set write off' (the | |
1160 | + default), GDB opens them read-only. | |
1161 | + | |
1162 | + If you have already loaded a file, you must load it again (using | |
1163 | + the `exec-file' or `core-file' command) after changing `set | |
1164 | + write', for your new setting to take effect. | |
1165 | + | |
1166 | +`show write' | |
1167 | + Display whether executable files and core files are opened for | |
1168 | + writing as well as reading. | |
1169 | + | |
1170 | + | |
1171 | +File: gdb.info, Node: GDB Files, Next: Targets, Prev: Altering, Up: Top | |
1172 | + | |
1173 | +GDB Files | |
1174 | +********* | |
1175 | + | |
1176 | + GDB needs to know the file name of the program to be debugged, both | |
1177 | +in order to read its symbol table and in order to start your program. | |
1178 | +To debug a core dump of a previous run, you must also tell GDB the name | |
1179 | +of the core dump file. | |
1180 | + | |
1181 | +* Menu: | |
1182 | + | |
1183 | +* Files:: Commands to specify files | |
1184 | +* Symbol Errors:: Errors reading symbol files | |
1185 | + |
@@ -0,0 +1,1226 @@ | ||
1 | +This is Info file ./gdb.info, produced by Makeinfo version 1.68 from | |
2 | +the input file gdb.texinfo. | |
3 | + | |
4 | +START-INFO-DIR-ENTRY | |
5 | +* Gdb: (gdb). The GNU debugger. | |
6 | +END-INFO-DIR-ENTRY | |
7 | + This file documents the GNU debugger GDB. | |
8 | + | |
9 | + This is the Seventh Edition, February 1999, of `Debugging with GDB: | |
10 | +the GNU Source-Level Debugger' for GDB Version 4.18. | |
11 | + | |
12 | + Copyright (C) 1988-1999 Free Software Foundation, Inc. | |
13 | + | |
14 | + Permission is granted to make and distribute verbatim copies of this | |
15 | +manual provided the copyright notice and this permission notice are | |
16 | +preserved on all copies. | |
17 | + | |
18 | + Permission is granted to copy and distribute modified versions of | |
19 | +this manual under the conditions for verbatim copying, provided also | |
20 | +that the entire resulting derived work is distributed under the terms | |
21 | +of a permission notice identical to this one. | |
22 | + | |
23 | + Permission is granted to copy and distribute translations of this | |
24 | +manual into another language, under the above conditions for modified | |
25 | +versions. | |
26 | + | |
27 | + | |
28 | +File: gdb.info, Node: Files, Next: Symbol Errors, Prev: GDB Files, Up: GDB Files | |
29 | + | |
30 | +Commands to specify files | |
31 | +========================= | |
32 | + | |
33 | + You may want to specify executable and core dump file names. The | |
34 | +usual way to do this is at start-up time, using the arguments to GDB's | |
35 | +start-up commands (*note Getting In and Out of GDB: Invocation.). | |
36 | + | |
37 | + Occasionally it is necessary to change to a different file during a | |
38 | +GDB session. Or you may run GDB and forget to specify a file you want | |
39 | +to use. In these situations the GDB commands to specify new files are | |
40 | +useful. | |
41 | + | |
42 | +`file FILENAME' | |
43 | + Use FILENAME as the program to be debugged. It is read for its | |
44 | + symbols and for the contents of pure memory. It is also the | |
45 | + program executed when you use the `run' command. If you do not | |
46 | + specify a directory and the file is not found in the GDB working | |
47 | + directory, GDB uses the environment variable `PATH' as a list of | |
48 | + directories to search, just as the shell does when looking for a | |
49 | + program to run. You can change the value of this variable, for | |
50 | + both GDB and your program, using the `path' command. | |
51 | + | |
52 | + On systems with memory-mapped files, an auxiliary file | |
53 | + `FILENAME.syms' may hold symbol table information for FILENAME. | |
54 | + If so, GDB maps in the symbol table from `FILENAME.syms', starting | |
55 | + up more quickly. See the descriptions of the file options | |
56 | + `-mapped' and `-readnow' (available on the command line, and with | |
57 | + the commands `file', `symbol-file', or `add-symbol-file', | |
58 | + described below), for more information. | |
59 | + | |
60 | +`file' | |
61 | + `file' with no argument makes GDB discard any information it has | |
62 | + on both executable file and the symbol table. | |
63 | + | |
64 | +`exec-file [ FILENAME ]' | |
65 | + Specify that the program to be run (but not the symbol table) is | |
66 | + found in FILENAME. GDB searches the environment variable `PATH' | |
67 | + if necessary to locate your program. Omitting FILENAME means to | |
68 | + discard information on the executable file. | |
69 | + | |
70 | +`symbol-file [ FILENAME ]' | |
71 | + Read symbol table information from file FILENAME. `PATH' is | |
72 | + searched when necessary. Use the `file' command to get both symbol | |
73 | + table and program to run from the same file. | |
74 | + | |
75 | + `symbol-file' with no argument clears out GDB information on your | |
76 | + program's symbol table. | |
77 | + | |
78 | + The `symbol-file' command causes GDB to forget the contents of its | |
79 | + convenience variables, the value history, and all breakpoints and | |
80 | + auto-display expressions. This is because they may contain | |
81 | + pointers to the internal data recording symbols and data types, | |
82 | + which are part of the old symbol table data being discarded inside | |
83 | + GDB. | |
84 | + | |
85 | + `symbol-file' does not repeat if you press <RET> again after | |
86 | + executing it once. | |
87 | + | |
88 | + When GDB is configured for a particular environment, it | |
89 | + understands debugging information in whatever format is the | |
90 | + standard generated for that environment; you may use either a GNU | |
91 | + compiler, or other compilers that adhere to the local conventions. | |
92 | + Best results are usually obtained from GNU compilers; for example, | |
93 | + using `gcc' you can generate debugging information for optimized | |
94 | + code. | |
95 | + | |
96 | + For most kinds of object files, with the exception of old SVR3 | |
97 | + systems using COFF, the `symbol-file' command does not normally | |
98 | + read the symbol table in full right away. Instead, it scans the | |
99 | + symbol table quickly to find which source files and which symbols | |
100 | + are present. The details are read later, one source file at a | |
101 | + time, as they are needed. | |
102 | + | |
103 | + The purpose of this two-stage reading strategy is to make GDB | |
104 | + start up faster. For the most part, it is invisible except for | |
105 | + occasional pauses while the symbol table details for a particular | |
106 | + source file are being read. (The `set verbose' command can turn | |
107 | + these pauses into messages if desired. *Note Optional warnings | |
108 | + and messages: Messages/Warnings.) | |
109 | + | |
110 | + We have not implemented the two-stage strategy for COFF yet. When | |
111 | + the symbol table is stored in COFF format, `symbol-file' reads the | |
112 | + symbol table data in full right away. Note that "stabs-in-COFF" | |
113 | + still does the two-stage strategy, since the debug info is actually | |
114 | + in stabs format. | |
115 | + | |
116 | +`symbol-file FILENAME [ -readnow ] [ -mapped ]' | |
117 | +`file FILENAME [ -readnow ] [ -mapped ]' | |
118 | + You can override the GDB two-stage strategy for reading symbol | |
119 | + tables by using the `-readnow' option with any of the commands that | |
120 | + load symbol table information, if you want to be sure GDB has the | |
121 | + entire symbol table available. | |
122 | + | |
123 | + If memory-mapped files are available on your system through the | |
124 | + `mmap' system call, you can use another option, `-mapped', to | |
125 | + cause GDB to write the symbols for your program into a reusable | |
126 | + file. Future GDB debugging sessions map in symbol information | |
127 | + from this auxiliary symbol file (if the program has not changed), | |
128 | + rather than spending time reading the symbol table from the | |
129 | + executable program. Using the `-mapped' option has the same | |
130 | + effect as starting GDB with the `-mapped' command-line option. | |
131 | + | |
132 | + You can use both options together, to make sure the auxiliary | |
133 | + symbol file has all the symbol information for your program. | |
134 | + | |
135 | + The auxiliary symbol file for a program called MYPROG is called | |
136 | + `MYPROG.syms'. Once this file exists (so long as it is newer than | |
137 | + the corresponding executable), GDB always attempts to use it when | |
138 | + you debug MYPROG; no special options or commands are needed. | |
139 | + | |
140 | + The `.syms' file is specific to the host machine where you run | |
141 | + GDB. It holds an exact image of the internal GDB symbol table. | |
142 | + It cannot be shared across multiple host platforms. | |
143 | + | |
144 | +`core-file [ FILENAME ]' | |
145 | + Specify the whereabouts of a core dump file to be used as the | |
146 | + "contents of memory". Traditionally, core files contain only some | |
147 | + parts of the address space of the process that generated them; GDB | |
148 | + can access the executable file itself for other parts. | |
149 | + | |
150 | + `core-file' with no argument specifies that no core file is to be | |
151 | + used. | |
152 | + | |
153 | + Note that the core file is ignored when your program is actually | |
154 | + running under GDB. So, if you have been running your program and | |
155 | + you wish to debug a core file instead, you must kill the | |
156 | + subprocess in which the program is running. To do this, use the | |
157 | + `kill' command (*note Killing the child process: Kill Process.). | |
158 | + | |
159 | +`add-symbol-file FILENAME ADDRESS' | |
160 | +`add-symbol-file FILENAME ADDRESS [ -readnow ] [ -mapped ]' | |
161 | + The `add-symbol-file' command reads additional symbol table | |
162 | + information from the file FILENAME. You would use this command | |
163 | + when FILENAME has been dynamically loaded (by some other means) | |
164 | + into the program that is running. ADDRESS should be the memory | |
165 | + address at which the file has been loaded; GDB cannot figure this | |
166 | + out for itself. You can specify ADDRESS as an expression. | |
167 | + | |
168 | + The symbol table of the file FILENAME is added to the symbol table | |
169 | + originally read with the `symbol-file' command. You can use the | |
170 | + `add-symbol-file' command any number of times; the new symbol data | |
171 | + thus read keeps adding to the old. To discard all old symbol data | |
172 | + instead, use the `symbol-file' command. | |
173 | + | |
174 | + `add-symbol-file' does not repeat if you press <RET> after using | |
175 | + it. | |
176 | + | |
177 | + You can use the `-mapped' and `-readnow' options just as with the | |
178 | + `symbol-file' command, to change how GDB manages the symbol table | |
179 | + information for FILENAME. | |
180 | + | |
181 | +`add-shared-symbol-file' | |
182 | + The `add-shared-symbol-file' command can be used only under | |
183 | + Harris' CXUX operating system for the Motorola 88k. GDB | |
184 | + automatically looks for shared libraries, however if GDB does not | |
185 | + find yours, you can run `add-shared-symbol-file'. It takes no | |
186 | + arguments. | |
187 | + | |
188 | +`section' | |
189 | + The `section' command changes the base address of section SECTION | |
190 | + of the exec file to ADDR. This can be used if the exec file does | |
191 | + not contain section addresses, (such as in the a.out format), or | |
192 | + when the addresses specified in the file itself are wrong. Each | |
193 | + section must be changed separately. The "info files" command | |
194 | + lists all the sections and their addresses. | |
195 | + | |
196 | +`info files' | |
197 | +`info target' | |
198 | + `info files' and `info target' are synonymous; both print the | |
199 | + current target (*note Specifying a Debugging Target: Targets.), | |
200 | + including the names of the executable and core dump files | |
201 | + currently in use by GDB, and the files from which symbols were | |
202 | + loaded. The command `help target' lists all possible targets | |
203 | + rather than current ones. | |
204 | + | |
205 | + All file-specifying commands allow both absolute and relative file | |
206 | +names as arguments. GDB always converts the file name to an absolute | |
207 | +file name and remembers it that way. | |
208 | + | |
209 | + GDB supports HP-UX, SunOS, SVr4, Irix 5, and IBM RS/6000 shared | |
210 | +libraries. GDB automatically loads symbol definitions from shared | |
211 | +libraries when you use the `run' command, or when you examine a core | |
212 | +file. (Before you issue the `run' command, GDB does not understand | |
213 | +references to a function in a shared library, however--unless you are | |
214 | +debugging a core file). | |
215 | + | |
216 | +`info share' | |
217 | +`info sharedlibrary' | |
218 | + Print the names of the shared libraries which are currently loaded. | |
219 | + | |
220 | +`sharedlibrary REGEX' | |
221 | +`share REGEX' | |
222 | + Load shared object library symbols for files matching a Unix | |
223 | + regular expression. As with files loaded automatically, it only | |
224 | + loads shared libraries required by your program for a core file or | |
225 | + after typing `run'. If REGEX is omitted all shared libraries | |
226 | + required by your program are loaded. | |
227 | + | |
228 | + | |
229 | +File: gdb.info, Node: Symbol Errors, Prev: Files, Up: GDB Files | |
230 | + | |
231 | +Errors reading symbol files | |
232 | +=========================== | |
233 | + | |
234 | + While reading a symbol file, GDB occasionally encounters problems, | |
235 | +such as symbol types it does not recognize, or known bugs in compiler | |
236 | +output. By default, GDB does not notify you of such problems, since | |
237 | +they are relatively common and primarily of interest to people | |
238 | +debugging compilers. If you are interested in seeing information about | |
239 | +ill-constructed symbol tables, you can either ask GDB to print only one | |
240 | +message about each such type of problem, no matter how many times the | |
241 | +problem occurs; or you can ask GDB to print more messages, to see how | |
242 | +many times the problems occur, with the `set complaints' command (*note | |
243 | +Optional warnings and messages: Messages/Warnings.). | |
244 | + | |
245 | + The messages currently printed, and their meanings, include: | |
246 | + | |
247 | +`inner block not inside outer block in SYMBOL' | |
248 | + The symbol information shows where symbol scopes begin and end | |
249 | + (such as at the start of a function or a block of statements). | |
250 | + This error indicates that an inner scope block is not fully | |
251 | + contained in its outer scope blocks. | |
252 | + | |
253 | + GDB circumvents the problem by treating the inner block as if it | |
254 | + had the same scope as the outer block. In the error message, | |
255 | + SYMBOL may be shown as "`(don't know)'" if the outer block is not a | |
256 | + function. | |
257 | + | |
258 | +`block at ADDRESS out of order' | |
259 | + The symbol information for symbol scope blocks should occur in | |
260 | + order of increasing addresses. This error indicates that it does | |
261 | + not do so. | |
262 | + | |
263 | + GDB does not circumvent this problem, and has trouble locating | |
264 | + symbols in the source file whose symbols it is reading. (You can | |
265 | + often determine what source file is affected by specifying `set | |
266 | + verbose on'. *Note Optional warnings and messages: | |
267 | + Messages/Warnings.) | |
268 | + | |
269 | +`bad block start address patched' | |
270 | + The symbol information for a symbol scope block has a start address | |
271 | + smaller than the address of the preceding source line. This is | |
272 | + known to occur in the SunOS 4.1.1 (and earlier) C compiler. | |
273 | + | |
274 | + GDB circumvents the problem by treating the symbol scope block as | |
275 | + starting on the previous source line. | |
276 | + | |
277 | +`bad string table offset in symbol N' | |
278 | + Symbol number N contains a pointer into the string table which is | |
279 | + larger than the size of the string table. | |
280 | + | |
281 | + GDB circumvents the problem by considering the symbol to have the | |
282 | + name `foo', which may cause other problems if many symbols end up | |
283 | + with this name. | |
284 | + | |
285 | +`unknown symbol type `0xNN'' | |
286 | + The symbol information contains new data types that GDB does not | |
287 | + yet know how to read. `0xNN' is the symbol type of the | |
288 | + misunderstood information, in hexadecimal. | |
289 | + | |
290 | + GDB circumvents the error by ignoring this symbol information. | |
291 | + This usually allows you to debug your program, though certain | |
292 | + symbols are not accessible. If you encounter such a problem and | |
293 | + feel like debugging it, you can debug `gdb' with itself, | |
294 | + breakpoint on `complain', then go up to the function | |
295 | + `read_dbx_symtab' and examine `*bufp' to see the symbol. | |
296 | + | |
297 | +`stub type has NULL name' | |
298 | + GDB could not find the full definition for a struct or class. | |
299 | + | |
300 | +`const/volatile indicator missing (ok if using g++ v1.x), got...' | |
301 | + The symbol information for a C++ member function is missing some | |
302 | + information that recent versions of the compiler should have output | |
303 | + for it. | |
304 | + | |
305 | +`info mismatch between compiler and debugger' | |
306 | + GDB could not parse a type specification output by the compiler. | |
307 | + | |
308 | + | |
309 | +File: gdb.info, Node: Targets, Next: Controlling GDB, Prev: GDB Files, Up: Top | |
310 | + | |
311 | +Specifying a Debugging Target | |
312 | +***************************** | |
313 | + | |
314 | + A "target" is the execution environment occupied by your program. | |
315 | +Often, GDB runs in the same host environment as your program; in that | |
316 | +case, the debugging target is specified as a side effect when you use | |
317 | +the `file' or `core' commands. When you need more flexibility--for | |
318 | +example, running GDB on a physically separate host, or controlling a | |
319 | +standalone system over a serial port or a realtime system over a TCP/IP | |
320 | +connection--you can use the `target' command to specify one of the | |
321 | +target types configured for GDB (*note Commands for managing targets: | |
322 | +Target Commands.). | |
323 | + | |
324 | +* Menu: | |
325 | + | |
326 | +* Active Targets:: Active targets | |
327 | +* Target Commands:: Commands for managing targets | |
328 | + | |
329 | +* Byte Order:: Choosing target byte order | |
330 | +* Remote:: Remote debugging | |
331 | + | |
332 | + | |
333 | +File: gdb.info, Node: Active Targets, Next: Target Commands, Prev: Targets, Up: Targets | |
334 | + | |
335 | +Active targets | |
336 | +============== | |
337 | + | |
338 | + There are three classes of targets: processes, core files, and | |
339 | +executable files. GDB can work concurrently on up to three active | |
340 | +targets, one in each class. This allows you to (for example) start a | |
341 | +process and inspect its activity without abandoning your work on a core | |
342 | +file. | |
343 | + | |
344 | + For example, if you execute `gdb a.out', then the executable file | |
345 | +`a.out' is the only active target. If you designate a core file as | |
346 | +well--presumably from a prior run that crashed and coredumped--then GDB | |
347 | +has two active targets and uses them in tandem, looking first in the | |
348 | +corefile target, then in the executable file, to satisfy requests for | |
349 | +memory addresses. (Typically, these two classes of target are | |
350 | +complementary, since core files contain only a program's read-write | |
351 | +memory--variables and so on--plus machine status, while executable | |
352 | +files contain only the program text and initialized data.) | |
353 | + | |
354 | + When you type `run', your executable file becomes an active process | |
355 | +target as well. When a process target is active, all GDB commands | |
356 | +requesting memory addresses refer to that target; addresses in an | |
357 | +active core file or executable file target are obscured while the | |
358 | +process target is active. | |
359 | + | |
360 | + Use the `core-file' and `exec-file' commands to select a new core | |
361 | +file or executable target (*note Commands to specify files: Files.). | |
362 | +To specify as a target a process that is already running, use the | |
363 | +`attach' command (*note Debugging an already-running process: Attach.). | |
364 | + | |
365 | + | |
366 | +File: gdb.info, Node: Target Commands, Next: Byte Order, Prev: Active Targets, Up: Targets | |
367 | + | |
368 | +Commands for managing targets | |
369 | +============================= | |
370 | + | |
371 | +`target TYPE PARAMETERS' | |
372 | + Connects the GDB host environment to a target machine or process. | |
373 | + A target is typically a protocol for talking to debugging | |
374 | + facilities. You use the argument TYPE to specify the type or | |
375 | + protocol of the target machine. | |
376 | + | |
377 | + Further PARAMETERS are interpreted by the target protocol, but | |
378 | + typically include things like device names or host names to connect | |
379 | + with, process numbers, and baud rates. | |
380 | + | |
381 | + The `target' command does not repeat if you press <RET> again | |
382 | + after executing the command. | |
383 | + | |
384 | +`help target' | |
385 | + Displays the names of all targets available. To display targets | |
386 | + currently selected, use either `info target' or `info files' | |
387 | + (*note Commands to specify files: Files.). | |
388 | + | |
389 | +`help target NAME' | |
390 | + Describe a particular target, including any parameters necessary to | |
391 | + select it. | |
392 | + | |
393 | +`set gnutarget ARGS' | |
394 | + GDB uses its own library BFD to read your files. GDB knows | |
395 | + whether it is reading an "executable", a "core", or a ".o" file; | |
396 | + however, you can specify the file format with the `set gnutarget' | |
397 | + command. Unlike most `target' commands, with `gnutarget' the | |
398 | + `target' refers to a program, not a machine. | |
399 | + | |
400 | + *Warning:* To specify a file format with `set gnutarget', you must | |
401 | + know the actual BFD name. | |
402 | + | |
403 | + *Note Commands to specify files: Files. | |
404 | + | |
405 | +`show gnutarget' | |
406 | + Use the `show gnutarget' command to display what file format | |
407 | + `gnutarget' is set to read. If you have not set `gnutarget', GDB | |
408 | + will determine the file format for each file automatically, and | |
409 | + `show gnutarget' displays `The current BDF target is "auto"'. | |
410 | + | |
411 | + Here are some common targets (available, or not, depending on the GDB | |
412 | +configuration): | |
413 | + | |
414 | +`target exec PROGRAM' | |
415 | + An executable file. `target exec PROGRAM' is the same as | |
416 | + `exec-file PROGRAM'. | |
417 | + | |
418 | +`target core FILENAME' | |
419 | + A core dump file. `target core FILENAME' is the same as | |
420 | + `core-file FILENAME'. | |
421 | + | |
422 | +`target remote DEV' | |
423 | + Remote serial target in GDB-specific protocol. The argument DEV | |
424 | + specifies what serial device to use for the connection (e.g. | |
425 | + `/dev/ttya'). *Note Remote debugging: Remote. `target remote' now | |
426 | + supports the `load' command. This is only useful if you have some | |
427 | + other way of getting the stub to the target system, and you can put | |
428 | + it somewhere in memory where it won't get clobbered by the | |
429 | + download. | |
430 | + | |
431 | +`target sim' | |
432 | + CPU simulator. *Note Simulated CPU Target: Simulator. | |
433 | + | |
434 | + The following targets are all CPU-specific, and only available for | |
435 | +specific configurations. | |
436 | + | |
437 | +`target abug DEV' | |
438 | + ABug ROM monitor for M68K. | |
439 | + | |
440 | +`target adapt DEV' | |
441 | + Adapt monitor for A29K. | |
442 | + | |
443 | +`target amd-eb DEV SPEED PROG' | |
444 | + Remote PC-resident AMD EB29K board, attached over serial lines. | |
445 | + DEV is the serial device, as for `target remote'; SPEED allows you | |
446 | + to specify the linespeed; and PROG is the name of the program to | |
447 | + be debugged, as it appears to DOS on the PC. *Note The EBMON | |
448 | + protocol for AMD29K: EB29K Remote. | |
449 | + | |
450 | +`target array DEV' | |
451 | + Array Tech LSI33K RAID controller board. | |
452 | + | |
453 | +`target bug DEV' | |
454 | + BUG monitor, running on a MVME187 (m88k) board. | |
455 | + | |
456 | +`target cpu32bug DEV' | |
457 | + CPU32BUG monitor, running on a CPU32 (M68K) board. | |
458 | + | |
459 | +`target dbug DEV' | |
460 | + dBUG ROM monitor for Motorola ColdFire. | |
461 | + | |
462 | +`target ddb DEV' | |
463 | + NEC's DDB monitor for Mips Vr4300. | |
464 | + | |
465 | +`target dink32 DEV' | |
466 | + DINK32 ROM monitor for PowerPC. | |
467 | + | |
468 | +`target e7000 DEV' | |
469 | + E7000 emulator for Hitachi H8 and SH. | |
470 | + | |
471 | +`target es1800 DEV' | |
472 | + ES-1800 emulator for M68K. | |
473 | + | |
474 | +`target est DEV' | |
475 | + EST-300 ICE monitor, running on a CPU32 (M68K) board. | |
476 | + | |
477 | +`target hms DEV' | |
478 | + A Hitachi SH, H8/300, or H8/500 board, attached via serial line to | |
479 | + your host. Use special commands `device' and `speed' to control | |
480 | + the serial line and the communications speed used. *Note GDB and | |
481 | + Hitachi Microprocessors: Hitachi Remote. | |
482 | + | |
483 | +`target lsi DEV' | |
484 | + LSI ROM monitor for Mips. | |
485 | + | |
486 | +`target m32r DEV' | |
487 | + Mitsubishi M32R/D ROM monitor. | |
488 | + | |
489 | +`target mips DEV' | |
490 | + IDT/SIM ROM monitor for Mips. | |
491 | + | |
492 | +`target mon960 DEV' | |
493 | + MON960 monitor for Intel i960. | |
494 | + | |
495 | +`target nindy DEVICENAME' | |
496 | + An Intel 960 board controlled by a Nindy Monitor. DEVICENAME is | |
497 | + the name of the serial device to use for the connection, e.g. | |
498 | + `/dev/ttya'. *Note GDB with a remote i960 (Nindy): i960-Nindy | |
499 | + Remote. | |
500 | + | |
501 | +`target nrom DEV' | |
502 | + NetROM ROM emulator. This target only supports downloading. | |
503 | + | |
504 | +`target op50n DEV' | |
505 | + OP50N monitor, running on an OKI HPPA board. | |
506 | + | |
507 | +`target pmon DEV' | |
508 | + PMON ROM monitor for Mips. | |
509 | + | |
510 | +`target ppcbug DEV' | |
511 | + | |
512 | +`target ppcbug1 DEV' | |
513 | + PPCBUG ROM monitor for PowerPC. | |
514 | + | |
515 | +`target r3900 DEV' | |
516 | + Densan DVE-R3900 ROM monitor for Toshiba R3900 Mips. | |
517 | + | |
518 | +`target rdi DEV' | |
519 | + ARM Angel monitor, via RDI library interface. | |
520 | + | |
521 | +`target rdp DEV' | |
522 | + ARM Demon monitor. | |
523 | + | |
524 | +`target rom68k DEV' | |
525 | + ROM 68K monitor, running on an M68K IDP board. | |
526 | + | |
527 | +`target rombug DEV' | |
528 | + ROMBUG ROM monitor for OS/9000. | |
529 | + | |
530 | +`target sds DEV' | |
531 | + SDS monitor, running on a PowerPC board (such as Motorola's ADS). | |
532 | + | |
533 | +`target sparclite DEV' | |
534 | + Fujitsu sparclite boards, used only for the purpose of loading. | |
535 | + You must use an additional command to debug the program. For | |
536 | + example: target remote DEV using GDB standard remote protocol. | |
537 | + | |
538 | +`target sh3 DEV' | |
539 | + | |
540 | +`target sh3e DEV' | |
541 | + Hitachi SH-3 and SH-3E target systems. | |
542 | + | |
543 | +`target st2000 DEV SPEED' | |
544 | + A Tandem ST2000 phone switch, running Tandem's STDBUG protocol. | |
545 | + DEV is the name of the device attached to the ST2000 serial line; | |
546 | + SPEED is the communication line speed. The arguments are not used | |
547 | + if GDB is configured to connect to the ST2000 using TCP or Telnet. | |
548 | + *Note GDB with a Tandem ST2000: ST2000 Remote. | |
549 | + | |
550 | +`target udi KEYWORD' | |
551 | + Remote AMD29K target, using the AMD UDI protocol. The KEYWORD | |
552 | + argument specifies which 29K board or simulator to use. *Note The | |
553 | + UDI protocol for AMD29K: UDI29K Remote. | |
554 | + | |
555 | +`target vxworks MACHINENAME' | |
556 | + A VxWorks system, attached via TCP/IP. The argument MACHINENAME | |
557 | + is the target system's machine name or IP address. *Note GDB and | |
558 | + VxWorks: VxWorks Remote. | |
559 | + | |
560 | +`target w89k DEV' | |
561 | + W89K monitor, running on a Winbond HPPA board. | |
562 | + | |
563 | + Different targets are available on different configurations of GDB; | |
564 | +your configuration may have more or fewer targets. | |
565 | + | |
566 | + Many remote targets require you to download the executable's code | |
567 | +once you've successfully established a connection. | |
568 | + | |
569 | +`load FILENAME' | |
570 | + Depending on what remote debugging facilities are configured into | |
571 | + GDB, the `load' command may be available. Where it exists, it is | |
572 | + meant to make FILENAME (an executable) available for debugging on | |
573 | + the remote system--by downloading, or dynamic linking, for example. | |
574 | + `load' also records the FILENAME symbol table in GDB, like the | |
575 | + `add-symbol-file' command. | |
576 | + | |
577 | + If your GDB does not have a `load' command, attempting to execute | |
578 | + it gets the error message "`You can't do that when your target is | |
579 | + ...'" | |
580 | + | |
581 | + The file is loaded at whatever address is specified in the | |
582 | + executable. For some object file formats, you can specify the | |
583 | + load address when you link the program; for other formats, like | |
584 | + a.out, the object file format specifies a fixed address. | |
585 | + | |
586 | + On VxWorks, `load' links FILENAME dynamically on the current | |
587 | + target system as well as adding its symbols in GDB. | |
588 | + | |
589 | + With the Nindy interface to an Intel 960 board, `load' downloads | |
590 | + FILENAME to the 960 as well as adding its symbols in GDB. | |
591 | + | |
592 | + When you select remote debugging to a Hitachi SH, H8/300, or | |
593 | + H8/500 board (*note GDB and Hitachi Microprocessors: Hitachi | |
594 | + Remote.), the `load' command downloads your program to the Hitachi | |
595 | + board and also opens it as the current executable target for GDB | |
596 | + on your host (like the `file' command). | |
597 | + | |
598 | + `load' does not repeat if you press <RET> again after using it. | |
599 | + | |
600 | + | |
601 | +File: gdb.info, Node: Byte Order, Next: Remote, Prev: Target Commands, Up: Targets | |
602 | + | |
603 | +Choosing target byte order | |
604 | +========================== | |
605 | + | |
606 | + Some types of processors, such as the MIPS, PowerPC, and Hitachi SH, | |
607 | +offer the ability to run either big-endian or little-endian byte | |
608 | +orders. Usually the executable or symbol will include a bit to | |
609 | +designate the endian-ness, and you will not need to worry about which | |
610 | +to use. However, you may still find it useful to adjust GDB's idea of | |
611 | +processor endian-ness manually. | |
612 | + | |
613 | +`set endian big' | |
614 | + Instruct GDB to assume the target is big-endian. | |
615 | + | |
616 | +`set endian little' | |
617 | + Instruct GDB to assume the target is little-endian. | |
618 | + | |
619 | +`set endian auto' | |
620 | + Instruct GDB to use the byte order associated with the executable. | |
621 | + | |
622 | +`show endian' | |
623 | + Display GDB's current idea of the target byte order. | |
624 | + | |
625 | + Note that these commands merely adjust interpretation of symbolic | |
626 | +data on the host, and that they have absolutely no effect on the target | |
627 | +system. | |
628 | + | |
629 | + | |
630 | +File: gdb.info, Node: Remote, Prev: Byte Order, Up: Targets | |
631 | + | |
632 | +Remote debugging | |
633 | +================ | |
634 | + | |
635 | + If you are trying to debug a program running on a machine that | |
636 | +cannot run GDB in the usual way, it is often useful to use remote | |
637 | +debugging. For example, you might use remote debugging on an operating | |
638 | +system kernel, or on a small system which does not have a general | |
639 | +purpose operating system powerful enough to run a full-featured | |
640 | +debugger. | |
641 | + | |
642 | + Some configurations of GDB have special serial or TCP/IP interfaces | |
643 | +to make this work with particular debugging targets. In addition, GDB | |
644 | +comes with a generic serial protocol (specific to GDB, but not specific | |
645 | +to any particular target system) which you can use if you write the | |
646 | +remote stubs--the code that runs on the remote system to communicate | |
647 | +with GDB. | |
648 | + | |
649 | + Other remote targets may be available in your configuration of GDB; | |
650 | +use `help target' to list them. | |
651 | + | |
652 | +* Menu: | |
653 | + | |
654 | + | |
655 | +* Remote Serial:: GDB remote serial protocol | |
656 | + | |
657 | +* i960-Nindy Remote:: GDB with a remote i960 (Nindy) | |
658 | + | |
659 | +* UDI29K Remote:: The UDI protocol for AMD29K | |
660 | +* EB29K Remote:: The EBMON protocol for AMD29K | |
661 | + | |
662 | +* VxWorks Remote:: GDB and VxWorks | |
663 | + | |
664 | +* ST2000 Remote:: GDB with a Tandem ST2000 | |
665 | + | |
666 | +* Hitachi Remote:: GDB and Hitachi Microprocessors | |
667 | + | |
668 | +* MIPS Remote:: GDB and MIPS boards | |
669 | + | |
670 | +* Sparclet Remote:: GDB and Sparclet boards | |
671 | + | |
672 | +* Simulator:: Simulated CPU target | |
673 | + | |
674 | + | |
675 | +File: gdb.info, Node: Remote Serial, Next: i960-Nindy Remote, Up: Remote | |
676 | + | |
677 | +The GDB remote serial protocol | |
678 | +------------------------------ | |
679 | + | |
680 | + To debug a program running on another machine (the debugging | |
681 | +"target" machine), you must first arrange for all the usual | |
682 | +prerequisites for the program to run by itself. For example, for a C | |
683 | +program, you need: | |
684 | + | |
685 | + 1. A startup routine to set up the C runtime environment; these | |
686 | + usually have a name like `crt0'. The startup routine may be | |
687 | + supplied by your hardware supplier, or you may have to write your | |
688 | + own. | |
689 | + | |
690 | + 2. You probably need a C subroutine library to support your program's | |
691 | + subroutine calls, notably managing input and output. | |
692 | + | |
693 | + 3. A way of getting your program to the other machine--for example, a | |
694 | + download program. These are often supplied by the hardware | |
695 | + manufacturer, but you may have to write your own from hardware | |
696 | + documentation. | |
697 | + | |
698 | + The next step is to arrange for your program to use a serial port to | |
699 | +communicate with the machine where GDB is running (the "host" machine). | |
700 | +In general terms, the scheme looks like this: | |
701 | + | |
702 | +*On the host,* | |
703 | + GDB already understands how to use this protocol; when everything | |
704 | + else is set up, you can simply use the `target remote' command | |
705 | + (*note Specifying a Debugging Target: Targets.). | |
706 | + | |
707 | +*On the target,* | |
708 | + you must link with your program a few special-purpose subroutines | |
709 | + that implement the GDB remote serial protocol. The file | |
710 | + containing these subroutines is called a "debugging stub". | |
711 | + | |
712 | + On certain remote targets, you can use an auxiliary program | |
713 | + `gdbserver' instead of linking a stub into your program. *Note | |
714 | + Using the `gdbserver' program: Server, for details. | |
715 | + | |
716 | + The debugging stub is specific to the architecture of the remote | |
717 | +machine; for example, use `sparc-stub.c' to debug programs on SPARC | |
718 | +boards. | |
719 | + | |
720 | + These working remote stubs are distributed with GDB: | |
721 | + | |
722 | +`i386-stub.c' | |
723 | + For Intel 386 and compatible architectures. | |
724 | + | |
725 | +`m68k-stub.c' | |
726 | + For Motorola 680x0 architectures. | |
727 | + | |
728 | +`sh-stub.c' | |
729 | + For Hitachi SH architectures. | |
730 | + | |
731 | +`sparc-stub.c' | |
732 | + For SPARC architectures. | |
733 | + | |
734 | +`sparcl-stub.c' | |
735 | + For Fujitsu SPARCLITE architectures. | |
736 | + | |
737 | + The `README' file in the GDB distribution may list other recently | |
738 | +added stubs. | |
739 | + | |
740 | +* Menu: | |
741 | + | |
742 | +* Stub Contents:: What the stub can do for you | |
743 | +* Bootstrapping:: What you must do for the stub | |
744 | +* Debug Session:: Putting it all together | |
745 | +* Protocol:: Outline of the communication protocol | |
746 | + | |
747 | +* Server:: Using the `gdbserver' program | |
748 | + | |
749 | +* NetWare:: Using the `gdbserve.nlm' program | |
750 | + | |
751 | + | |
752 | +File: gdb.info, Node: Stub Contents, Next: Bootstrapping, Up: Remote Serial | |
753 | + | |
754 | +What the stub can do for you | |
755 | +............................ | |
756 | + | |
757 | + The debugging stub for your architecture supplies these three | |
758 | +subroutines: | |
759 | + | |
760 | +`set_debug_traps' | |
761 | + This routine arranges for `handle_exception' to run when your | |
762 | + program stops. You must call this subroutine explicitly near the | |
763 | + beginning of your program. | |
764 | + | |
765 | +`handle_exception' | |
766 | + This is the central workhorse, but your program never calls it | |
767 | + explicitly--the setup code arranges for `handle_exception' to run | |
768 | + when a trap is triggered. | |
769 | + | |
770 | + `handle_exception' takes control when your program stops during | |
771 | + execution (for example, on a breakpoint), and mediates | |
772 | + communications with GDB on the host machine. This is where the | |
773 | + communications protocol is implemented; `handle_exception' acts as | |
774 | + the GDB representative on the target machine; it begins by sending | |
775 | + summary information on the state of your program, then continues | |
776 | + to execute, retrieving and transmitting any information GDB needs, | |
777 | + until you execute a GDB command that makes your program resume; at | |
778 | + that point, `handle_exception' returns control to your own code on | |
779 | + the target machine. | |
780 | + | |
781 | +`breakpoint' | |
782 | + Use this auxiliary subroutine to make your program contain a | |
783 | + breakpoint. Depending on the particular situation, this may be | |
784 | + the only way for GDB to get control. For instance, if your target | |
785 | + machine has some sort of interrupt button, you won't need to call | |
786 | + this; pressing the interrupt button transfers control to | |
787 | + `handle_exception'--in effect, to GDB. On some machines, simply | |
788 | + receiving characters on the serial port may also trigger a trap; | |
789 | + again, in that situation, you don't need to call `breakpoint' from | |
790 | + your own program--simply running `target remote' from the host GDB | |
791 | + session gets control. | |
792 | + | |
793 | + Call `breakpoint' if none of these is true, or if you simply want | |
794 | + to make certain your program stops at a predetermined point for the | |
795 | + start of your debugging session. | |
796 | + | |
797 | + | |
798 | +File: gdb.info, Node: Bootstrapping, Next: Debug Session, Prev: Stub Contents, Up: Remote Serial | |
799 | + | |
800 | +What you must do for the stub | |
801 | +............................. | |
802 | + | |
803 | + The debugging stubs that come with GDB are set up for a particular | |
804 | +chip architecture, but they have no information about the rest of your | |
805 | +debugging target machine. | |
806 | + | |
807 | + First of all you need to tell the stub how to communicate with the | |
808 | +serial port. | |
809 | + | |
810 | +`int getDebugChar()' | |
811 | + Write this subroutine to read a single character from the serial | |
812 | + port. It may be identical to `getchar' for your target system; a | |
813 | + different name is used to allow you to distinguish the two if you | |
814 | + wish. | |
815 | + | |
816 | +`void putDebugChar(int)' | |
817 | + Write this subroutine to write a single character to the serial | |
818 | + port. It may be identical to `putchar' for your target system; a | |
819 | + different name is used to allow you to distinguish the two if you | |
820 | + wish. | |
821 | + | |
822 | + If you want GDB to be able to stop your program while it is running, | |
823 | +you need to use an interrupt-driven serial driver, and arrange for it | |
824 | +to stop when it receives a `^C' (`\003', the control-C character). | |
825 | +That is the character which GDB uses to tell the remote system to stop. | |
826 | + | |
827 | + Getting the debugging target to return the proper status to GDB | |
828 | +probably requires changes to the standard stub; one quick and dirty way | |
829 | +is to just execute a breakpoint instruction (the "dirty" part is that | |
830 | +GDB reports a `SIGTRAP' instead of a `SIGINT'). | |
831 | + | |
832 | + Other routines you need to supply are: | |
833 | + | |
834 | +`void exceptionHandler (int EXCEPTION_NUMBER, void *EXCEPTION_ADDRESS)' | |
835 | + Write this function to install EXCEPTION_ADDRESS in the exception | |
836 | + handling tables. You need to do this because the stub does not | |
837 | + have any way of knowing what the exception handling tables on your | |
838 | + target system are like (for example, the processor's table might | |
839 | + be in ROM, containing entries which point to a table in RAM). | |
840 | + EXCEPTION_NUMBER is the exception number which should be changed; | |
841 | + its meaning is architecture-dependent (for example, different | |
842 | + numbers might represent divide by zero, misaligned access, etc). | |
843 | + When this exception occurs, control should be transferred directly | |
844 | + to EXCEPTION_ADDRESS, and the processor state (stack, registers, | |
845 | + and so on) should be just as it is when a processor exception | |
846 | + occurs. So if you want to use a jump instruction to reach | |
847 | + EXCEPTION_ADDRESS, it should be a simple jump, not a jump to | |
848 | + subroutine. | |
849 | + | |
850 | + For the 386, EXCEPTION_ADDRESS should be installed as an interrupt | |
851 | + gate so that interrupts are masked while the handler runs. The | |
852 | + gate should be at privilege level 0 (the most privileged level). | |
853 | + The SPARC and 68k stubs are able to mask interrup themselves | |
854 | + without help from `exceptionHandler'. | |
855 | + | |
856 | +`void flush_i_cache()' | |
857 | + (sparc and sparclite only) Write this subroutine to flush the | |
858 | + instruction cache, if any, on your target machine. If there is no | |
859 | + instruction cache, this subroutine may be a no-op. | |
860 | + | |
861 | + On target machines that have instruction caches, GDB requires this | |
862 | + function to make certain that the state of your program is stable. | |
863 | + | |
864 | +You must also make sure this library routine is available: | |
865 | + | |
866 | +`void *memset(void *, int, int)' | |
867 | + This is the standard library function `memset' that sets an area of | |
868 | + memory to a known value. If you have one of the free versions of | |
869 | + `libc.a', `memset' can be found there; otherwise, you must either | |
870 | + obtain it from your hardware manufacturer, or write your own. | |
871 | + | |
872 | + If you do not use the GNU C compiler, you may need other standard | |
873 | +library subroutines as well; this varies from one stub to another, but | |
874 | +in general the stubs are likely to use any of the common library | |
875 | +subroutines which `gcc' generates as inline code. | |
876 | + | |
877 | + | |
878 | +File: gdb.info, Node: Debug Session, Next: Protocol, Prev: Bootstrapping, Up: Remote Serial | |
879 | + | |
880 | +Putting it all together | |
881 | +....................... | |
882 | + | |
883 | + In summary, when your program is ready to debug, you must follow | |
884 | +these steps. | |
885 | + | |
886 | + 1. Make sure you have the supporting low-level routines (*note What | |
887 | + you must do for the stub: Bootstrapping.): | |
888 | + `getDebugChar', `putDebugChar', | |
889 | + `flush_i_cache', `memset', `exceptionHandler'. | |
890 | + | |
891 | + 2. Insert these lines near the top of your program: | |
892 | + | |
893 | + set_debug_traps(); | |
894 | + breakpoint(); | |
895 | + | |
896 | + 3. For the 680x0 stub only, you need to provide a variable called | |
897 | + `exceptionHook'. Normally you just use: | |
898 | + | |
899 | + void (*exceptionHook)() = 0; | |
900 | + | |
901 | + but if before calling `set_debug_traps', you set it to point to a | |
902 | + function in your program, that function is called when `GDB' | |
903 | + continues after stopping on a trap (for example, bus error). The | |
904 | + function indicated by `exceptionHook' is called with one | |
905 | + parameter: an `int' which is the exception number. | |
906 | + | |
907 | + 4. Compile and link together: your program, the GDB debugging stub for | |
908 | + your target architecture, and the supporting subroutines. | |
909 | + | |
910 | + 5. Make sure you have a serial connection between your target machine | |
911 | + and the GDB host, and identify the serial port on the host. | |
912 | + | |
913 | + 6. Download your program to your target machine (or get it there by | |
914 | + whatever means the manufacturer provides), and start it. | |
915 | + | |
916 | + 7. To start remote debugging, run GDB on the host machine, and specify | |
917 | + as an executable file the program that is running in the remote | |
918 | + machine. This tells GDB how to find your program's symbols and | |
919 | + the contents of its pure text. | |
920 | + | |
921 | + Then establish communication using the `target remote' command. | |
922 | + Its argument specifies how to communicate with the target | |
923 | + machine--either via a devicename attached to a direct serial line, | |
924 | + or a TCP port (usually to a terminal server which in turn has a | |
925 | + serial line to the target). For example, to use a serial line | |
926 | + connected to the device named `/dev/ttyb': | |
927 | + | |
928 | + target remote /dev/ttyb | |
929 | + | |
930 | + To use a TCP connection, use an argument of the form `HOST:port'. | |
931 | + For example, to connect to port 2828 on a terminal server named | |
932 | + `manyfarms': | |
933 | + | |
934 | + target remote manyfarms:2828 | |
935 | + | |
936 | + Now you can use all the usual commands to examine and change data | |
937 | +and to step and continue the remote program. | |
938 | + | |
939 | + To resume the remote program and stop debugging it, use the `detach' | |
940 | +command. | |
941 | + | |
942 | + Whenever GDB is waiting for the remote program, if you type the | |
943 | +interrupt character (often <C-C>), GDB attempts to stop the program. | |
944 | +This may or may not succeed, depending in part on the hardware and the | |
945 | +serial drivers the remote system uses. If you type the interrupt | |
946 | +character once again, GDB displays this prompt: | |
947 | + | |
948 | + Interrupted while waiting for the program. | |
949 | + Give up (and stop debugging it)? (y or n) | |
950 | + | |
951 | + If you type `y', GDB abandons the remote debugging session. (If you | |
952 | +decide you want to try again later, you can use `target remote' again | |
953 | +to connect once more.) If you type `n', GDB goes back to waiting. | |
954 | + | |
955 | + | |
956 | +File: gdb.info, Node: Protocol, Next: Server, Prev: Debug Session, Up: Remote Serial | |
957 | + | |
958 | +Communication protocol | |
959 | +...................... | |
960 | + | |
961 | + The stub files provided with GDB implement the target side of the | |
962 | +communication protocol, and the GDB side is implemented in the GDB | |
963 | +source file `remote.c'. Normally, you can simply allow these | |
964 | +subroutines to communicate, and ignore the details. (If you're | |
965 | +implementing your own stub file, you can still ignore the details: start | |
966 | +with one of the existing stub files. `sparc-stub.c' is the best | |
967 | +organized, and therefore the easiest to read.) | |
968 | + | |
969 | + However, there may be occasions when you need to know something about | |
970 | +the protocol--for example, if there is only one serial port to your | |
971 | +target machine, you might want your program to do something special if | |
972 | +it recognizes a packet meant for GDB. | |
973 | + | |
974 | + All GDB commands and responses (other than acknowledgements, which | |
975 | +are single characters) are sent as a packet which includes a checksum. | |
976 | +A packet is introduced with the character `$', and ends with the | |
977 | +character `#' followed by a two-digit checksum: | |
978 | + | |
979 | + $PACKET INFO#CHECKSUM | |
980 | + | |
981 | +CHECKSUM is computed as the modulo 256 sum of the PACKET INFO | |
982 | +characters. | |
983 | + | |
984 | + When either the host or the target machine receives a packet, the | |
985 | +first response expected is an acknowledgement: a single character, | |
986 | +either `+' (to indicate the package was received correctly) or `-' (to | |
987 | +request retransmission). | |
988 | + | |
989 | + The host (GDB) sends commands, and the target (the debugging stub | |
990 | +incorporated in your program) sends data in response. The target also | |
991 | +sends data when your program stops. | |
992 | + | |
993 | + Command packets are distinguished by their first character, which | |
994 | +identifies the kind of command. | |
995 | + | |
996 | + These are some of the commands currently supported (for a complete | |
997 | +list of commands, look in `gdb/remote.c.'): | |
998 | + | |
999 | +`g' | |
1000 | + Requests the values of CPU registers. | |
1001 | + | |
1002 | +`G' | |
1003 | + Sets the values of CPU registers. | |
1004 | + | |
1005 | +`mADDR,COUNT' | |
1006 | + Read COUNT bytes at location ADDR. | |
1007 | + | |
1008 | +`MADDR,COUNT:...' | |
1009 | + Write COUNT bytes at location ADDR. | |
1010 | + | |
1011 | +`c' | |
1012 | +`cADDR' | |
1013 | + Resume execution at the current address (or at ADDR if supplied). | |
1014 | + | |
1015 | +`s' | |
1016 | +`sADDR' | |
1017 | + Step the target program for one instruction, from either the | |
1018 | + current program counter or from ADDR if supplied. | |
1019 | + | |
1020 | +`k' | |
1021 | + Kill the target program. | |
1022 | + | |
1023 | +`?' | |
1024 | + Report the most recent signal. To allow you to take advantage of | |
1025 | + the GDB signal handling commands, one of the functions of the | |
1026 | + debugging stub is to report CPU traps as the corresponding POSIX | |
1027 | + signal values. | |
1028 | + | |
1029 | +`T' | |
1030 | + Allows the remote stub to send only the registers that GDB needs | |
1031 | + to make a quick decision about single-stepping or conditional | |
1032 | + breakpoints. This eliminates the need to fetch the entire | |
1033 | + register set for each instruction being stepped through. | |
1034 | + | |
1035 | + GDB now implements a write-through cache for registers and only | |
1036 | + re-reads the registers if the target has run. | |
1037 | + | |
1038 | + If you have trouble with the serial connection, you can use the | |
1039 | +command `set remotedebug'. This makes GDB report on all packets sent | |
1040 | +back and forth across the serial line to the remote machine. The | |
1041 | +packet-debugging information is printed on the GDB standard output | |
1042 | +stream. `set remotedebug off' turns it off, and `show remotedebug' | |
1043 | +shows you its current state. | |
1044 | + | |
1045 | + | |
1046 | +File: gdb.info, Node: Server, Next: NetWare, Prev: Protocol, Up: Remote Serial | |
1047 | + | |
1048 | +Using the `gdbserver' program | |
1049 | +............................. | |
1050 | + | |
1051 | + `gdbserver' is a control program for Unix-like systems, which allows | |
1052 | +you to connect your program with a remote GDB via `target remote'--but | |
1053 | +without linking in the usual debugging stub. | |
1054 | + | |
1055 | + `gdbserver' is not a complete replacement for the debugging stubs, | |
1056 | +because it requires essentially the same operating-system facilities | |
1057 | +that GDB itself does. In fact, a system that can run `gdbserver' to | |
1058 | +connect to a remote GDB could also run GDB locally! `gdbserver' is | |
1059 | +sometimes useful nevertheless, because it is a much smaller program | |
1060 | +than GDB itself. It is also easier to port than all of GDB, so you may | |
1061 | +be able to get started more quickly on a new system by using | |
1062 | +`gdbserver'. Finally, if you develop code for real-time systems, you | |
1063 | +may find that the tradeoffs involved in real-time operation make it | |
1064 | +more convenient to do as much development work as possible on another | |
1065 | +system, for example by cross-compiling. You can use `gdbserver' to | |
1066 | +make a similar choice for debugging. | |
1067 | + | |
1068 | + GDB and `gdbserver' communicate via either a serial line or a TCP | |
1069 | +connection, using the standard GDB remote serial protocol. | |
1070 | + | |
1071 | +*On the target machine,* | |
1072 | + you need to have a copy of the program you want to debug. | |
1073 | + `gdbserver' does not need your program's symbol table, so you can | |
1074 | + strip the program if necessary to save space. GDB on the host | |
1075 | + system does all the symbol handling. | |
1076 | + | |
1077 | + To use the server, you must tell it how to communicate with GDB; | |
1078 | + the name of your program; and the arguments for your program. The | |
1079 | + syntax is: | |
1080 | + | |
1081 | + target> gdbserver COMM PROGRAM [ ARGS ... ] | |
1082 | + | |
1083 | + COMM is either a device name (to use a serial line) or a TCP | |
1084 | + hostname and portnumber. For example, to debug Emacs with the | |
1085 | + argument `foo.txt' and communicate with GDB over the serial port | |
1086 | + `/dev/com1': | |
1087 | + | |
1088 | + target> gdbserver /dev/com1 emacs foo.txt | |
1089 | + | |
1090 | + `gdbserver' waits passively for the host GDB to communicate with | |
1091 | + it. | |
1092 | + | |
1093 | + To use a TCP connection instead of a serial line: | |
1094 | + | |
1095 | + target> gdbserver host:2345 emacs foo.txt | |
1096 | + | |
1097 | + The only difference from the previous example is the first | |
1098 | + argument, specifying that you are communicating with the host GDB | |
1099 | + via TCP. The `host:2345' argument means that `gdbserver' is to | |
1100 | + expect a TCP connection from machine `host' to local TCP port 2345. | |
1101 | + (Currently, the `host' part is ignored.) You can choose any number | |
1102 | + you want for the port number as long as it does not conflict with | |
1103 | + any TCP ports already in use on the target system (for example, | |
1104 | + `23' is reserved for `telnet').(1) You must use the same port | |
1105 | + number with the host GDB `target remote' command. | |
1106 | + | |
1107 | +*On the GDB host machine,* | |
1108 | + you need an unstripped copy of your program, since GDB needs | |
1109 | + symbols and debugging information. Start up GDB as usual, using | |
1110 | + the name of the local copy of your program as the first argument. | |
1111 | + (You may also need the `--baud' option if the serial line is | |
1112 | + running at anything other than 9600 bps.) After that, use `target | |
1113 | + remote' to establish communications with `gdbserver'. Its argument | |
1114 | + is either a device name (usually a serial device, like | |
1115 | + `/dev/ttyb'), or a TCP port descriptor in the form `HOST:PORT'. | |
1116 | + For example: | |
1117 | + | |
1118 | + (gdb) target remote /dev/ttyb | |
1119 | + | |
1120 | + communicates with the server via serial line `/dev/ttyb', and | |
1121 | + | |
1122 | + (gdb) target remote the-target:2345 | |
1123 | + | |
1124 | + communicates via a TCP connection to port 2345 on host | |
1125 | + `the-target'. For TCP connections, you must start up `gdbserver' | |
1126 | + prior to using the `target remote' command. Otherwise you may get | |
1127 | + an error whose text depends on the host system, but which usually | |
1128 | + looks something like `Connection refused'. | |
1129 | + | |
1130 | + ---------- Footnotes ---------- | |
1131 | + | |
1132 | + (1) If you choose a port number that conflicts with another service, | |
1133 | +`gdbserver' prints an error message and exits. | |
1134 | + | |
1135 | + | |
1136 | +File: gdb.info, Node: NetWare, Prev: Server, Up: Remote Serial | |
1137 | + | |
1138 | +Using the `gdbserve.nlm' program | |
1139 | +................................ | |
1140 | + | |
1141 | + `gdbserve.nlm' is a control program for NetWare systems, which | |
1142 | +allows you to connect your program with a remote GDB via `target | |
1143 | +remote'. | |
1144 | + | |
1145 | + GDB and `gdbserve.nlm' communicate via a serial line, using the | |
1146 | +standard GDB remote serial protocol. | |
1147 | + | |
1148 | +*On the target machine,* | |
1149 | + you need to have a copy of the program you want to debug. | |
1150 | + `gdbserve.nlm' does not need your program's symbol table, so you | |
1151 | + can strip the program if necessary to save space. GDB on the host | |
1152 | + system does all the symbol handling. | |
1153 | + | |
1154 | + To use the server, you must tell it how to communicate with GDB; | |
1155 | + the name of your program; and the arguments for your program. The | |
1156 | + syntax is: | |
1157 | + | |
1158 | + load gdbserve [ BOARD=BOARD ] [ PORT=PORT ] | |
1159 | + [ BAUD=BAUD ] PROGRAM [ ARGS ... ] | |
1160 | + | |
1161 | + BOARD and PORT specify the serial line; BAUD specifies the baud | |
1162 | + rate used by the connection. PORT and NODE default to 0, BAUD | |
1163 | + defaults to 9600 bps. | |
1164 | + | |
1165 | + For example, to debug Emacs with the argument `foo.txt'and | |
1166 | + communicate with GDB over serial port number 2 or board 1 using a | |
1167 | + 19200 bps connection: | |
1168 | + | |
1169 | + load gdbserve BOARD=1 PORT=2 BAUD=19200 emacs foo.txt | |
1170 | + | |
1171 | +*On the GDB host machine,* | |
1172 | + you need an unstripped copy of your program, since GDB needs | |
1173 | + symbols and debugging information. Start up GDB as usual, using | |
1174 | + the name of the local copy of your program as the first argument. | |
1175 | + (You may also need the `--baud' option if the serial line is | |
1176 | + running at anything other than 9600 bps. After that, use `target | |
1177 | + remote' to establish communications with `gdbserve.nlm'. Its | |
1178 | + argument is a device name (usually a serial device, like | |
1179 | + `/dev/ttyb'). For example: | |
1180 | + | |
1181 | + (gdb) target remote /dev/ttyb | |
1182 | + | |
1183 | + communications with the server via serial line `/dev/ttyb'. | |
1184 | + | |
1185 | + | |
1186 | +File: gdb.info, Node: i960-Nindy Remote, Next: UDI29K Remote, Prev: Remote Serial, Up: Remote | |
1187 | + | |
1188 | +GDB with a remote i960 (Nindy) | |
1189 | +------------------------------ | |
1190 | + | |
1191 | + "Nindy" is a ROM Monitor program for Intel 960 target systems. When | |
1192 | +GDB is configured to control a remote Intel 960 using Nindy, you can | |
1193 | +tell GDB how to connect to the 960 in several ways: | |
1194 | + | |
1195 | + * Through command line options specifying serial port, version of the | |
1196 | + Nindy protocol, and communications speed; | |
1197 | + | |
1198 | + * By responding to a prompt on startup; | |
1199 | + | |
1200 | + * By using the `target' command at any point during your GDB | |
1201 | + session. *Note Commands for managing targets: Target Commands. | |
1202 | + | |
1203 | +* Menu: | |
1204 | + | |
1205 | +* Nindy Startup:: Startup with Nindy | |
1206 | +* Nindy Options:: Options for Nindy | |
1207 | +* Nindy Reset:: Nindy reset command | |
1208 | + | |
1209 | + | |
1210 | +File: gdb.info, Node: Nindy Startup, Next: Nindy Options, Up: i960-Nindy Remote | |
1211 | + | |
1212 | +Startup with Nindy | |
1213 | +.................. | |
1214 | + | |
1215 | + If you simply start `gdb' without using any command-line options, | |
1216 | +you are prompted for what serial port to use, *before* you reach the | |
1217 | +ordinary GDB prompt: | |
1218 | + | |
1219 | + Attach /dev/ttyNN -- specify NN, or "quit" to quit: | |
1220 | + | |
1221 | +Respond to the prompt with whatever suffix (after `/dev/tty') | |
1222 | +identifies the serial port you want to use. You can, if you choose, | |
1223 | +simply start up with no Nindy connection by responding to the prompt | |
1224 | +with an empty line. If you do this and later wish to attach to Nindy, | |
1225 | +use `target' (*note Commands for managing targets: Target Commands.). | |
1226 | + |
@@ -0,0 +1,1302 @@ | ||
1 | +This is Info file ./gdb.info, produced by Makeinfo version 1.68 from | |
2 | +the input file gdb.texinfo. | |
3 | + | |
4 | +START-INFO-DIR-ENTRY | |
5 | +* Gdb: (gdb). The GNU debugger. | |
6 | +END-INFO-DIR-ENTRY | |
7 | + This file documents the GNU debugger GDB. | |
8 | + | |
9 | + This is the Seventh Edition, February 1999, of `Debugging with GDB: | |
10 | +the GNU Source-Level Debugger' for GDB Version 4.18. | |
11 | + | |
12 | + Copyright (C) 1988-1999 Free Software Foundation, Inc. | |
13 | + | |
14 | + Permission is granted to make and distribute verbatim copies of this | |
15 | +manual provided the copyright notice and this permission notice are | |
16 | +preserved on all copies. | |
17 | + | |
18 | + Permission is granted to copy and distribute modified versions of | |
19 | +this manual under the conditions for verbatim copying, provided also | |
20 | +that the entire resulting derived work is distributed under the terms | |
21 | +of a permission notice identical to this one. | |
22 | + | |
23 | + Permission is granted to copy and distribute translations of this | |
24 | +manual into another language, under the above conditions for modified | |
25 | +versions. | |
26 | + | |
27 | + | |
28 | +File: gdb.info, Node: Nindy Options, Next: Nindy Reset, Prev: Nindy Startup, Up: i960-Nindy Remote | |
29 | + | |
30 | +Options for Nindy | |
31 | +................. | |
32 | + | |
33 | + These are the startup options for beginning your GDB session with a | |
34 | +Nindy-960 board attached: | |
35 | + | |
36 | +`-r PORT' | |
37 | + Specify the serial port name of a serial interface to be used to | |
38 | + connect to the target system. This option is only available when | |
39 | + GDB is configured for the Intel 960 target architecture. You may | |
40 | + specify PORT as any of: a full pathname (e.g. `-r /dev/ttya'), a | |
41 | + device name in `/dev' (e.g. `-r ttya'), or simply the unique | |
42 | + suffix for a specific `tty' (e.g. `-r a'). | |
43 | + | |
44 | +`-O' | |
45 | + (An uppercase letter "O", not a zero.) Specify that GDB should use | |
46 | + the "old" Nindy monitor protocol to connect to the target system. | |
47 | + This option is only available when GDB is configured for the Intel | |
48 | + 960 target architecture. | |
49 | + | |
50 | + *Warning:* if you specify `-O', but are actually trying to | |
51 | + connect to a target system that expects the newer protocol, | |
52 | + the connection fails, appearing to be a speed mismatch. GDB | |
53 | + repeatedly attempts to reconnect at several different line | |
54 | + speeds. You can abort this process with an interrupt. | |
55 | + | |
56 | +`-brk' | |
57 | + Specify that GDB should first send a `BREAK' signal to the target | |
58 | + system, in an attempt to reset it, before connecting to a Nindy | |
59 | + target. | |
60 | + | |
61 | + *Warning:* Many target systems do not have the hardware that | |
62 | + this requires; it only works with a few boards. | |
63 | + | |
64 | + The standard `-b' option controls the line speed used on the serial | |
65 | +port. | |
66 | + | |
67 | + | |
68 | +File: gdb.info, Node: Nindy Reset, Prev: Nindy Options, Up: i960-Nindy Remote | |
69 | + | |
70 | +Nindy reset command | |
71 | +................... | |
72 | + | |
73 | +`reset' | |
74 | + For a Nindy target, this command sends a "break" to the remote | |
75 | + target system; this is only useful if the target has been equipped | |
76 | + with a circuit to perform a hard reset (or some other interesting | |
77 | + action) when a break is detected. | |
78 | + | |
79 | + | |
80 | +File: gdb.info, Node: UDI29K Remote, Next: EB29K Remote, Prev: i960-Nindy Remote, Up: Remote | |
81 | + | |
82 | +The UDI protocol for AMD29K | |
83 | +--------------------------- | |
84 | + | |
85 | + GDB supports AMD's UDI ("Universal Debugger Interface") protocol for | |
86 | +debugging the a29k processor family. To use this configuration with | |
87 | +AMD targets running the MiniMON monitor, you need the program `MONTIP', | |
88 | +available from AMD at no charge. You can also use GDB with the | |
89 | +UDI-conformant a29k simulator program `ISSTIP', also available from AMD. | |
90 | + | |
91 | +`target udi KEYWORD' | |
92 | + Select the UDI interface to a remote a29k board or simulator, where | |
93 | + KEYWORD is an entry in the AMD configuration file `udi_soc'. This | |
94 | + file contains keyword entries which specify parameters used to | |
95 | + connect to a29k targets. If the `udi_soc' file is not in your | |
96 | + working directory, you must set the environment variable `UDICONF' | |
97 | + to its pathname. | |
98 | + | |
99 | + | |
100 | +File: gdb.info, Node: EB29K Remote, Next: VxWorks Remote, Prev: UDI29K Remote, Up: Remote | |
101 | + | |
102 | +The EBMON protocol for AMD29K | |
103 | +----------------------------- | |
104 | + | |
105 | + AMD distributes a 29K development board meant to fit in a PC, | |
106 | +together with a DOS-hosted monitor program called `EBMON'. As a | |
107 | +shorthand term, this development system is called the "EB29K". To use | |
108 | +GDB from a Unix system to run programs on the EB29K board, you must | |
109 | +first connect a serial cable between the PC (which hosts the EB29K | |
110 | +board) and a serial port on the Unix system. In the following, we | |
111 | +assume you've hooked the cable between the PC's `COM1' port and | |
112 | +`/dev/ttya' on the Unix system. | |
113 | + | |
114 | +* Menu: | |
115 | + | |
116 | +* Comms (EB29K):: Communications setup | |
117 | +* gdb-EB29K:: EB29K cross-debugging | |
118 | +* Remote Log:: Remote log | |
119 | + | |
120 | + | |
121 | +File: gdb.info, Node: Comms (EB29K), Next: gdb-EB29K, Up: EB29K Remote | |
122 | + | |
123 | +Communications setup | |
124 | +.................... | |
125 | + | |
126 | + The next step is to set up the PC's port, by doing something like | |
127 | +this in DOS on the PC: | |
128 | + | |
129 | + C:\> MODE com1:9600,n,8,1,none | |
130 | + | |
131 | +This example--run on an MS DOS 4.0 system--sets the PC port to 9600 | |
132 | +bps, no parity, eight data bits, one stop bit, and no "retry" action; | |
133 | +you must match the communications parameters when establishing the Unix | |
134 | +end of the connection as well. | |
135 | + | |
136 | + To give control of the PC to the Unix side of the serial line, type | |
137 | +the following at the DOS console: | |
138 | + | |
139 | + C:\> CTTY com1 | |
140 | + | |
141 | +(Later, if you wish to return control to the DOS console, you can use | |
142 | +the command `CTTY con'--but you must send it over the device that had | |
143 | +control, in our example over the `COM1' serial line). | |
144 | + | |
145 | + From the Unix host, use a communications program such as `tip' or | |
146 | +`cu' to communicate with the PC; for example, | |
147 | + | |
148 | + cu -s 9600 -l /dev/ttya | |
149 | + | |
150 | +The `cu' options shown specify, respectively, the linespeed and the | |
151 | +serial port to use. If you use `tip' instead, your command line may | |
152 | +look something like the following: | |
153 | + | |
154 | + tip -9600 /dev/ttya | |
155 | + | |
156 | +Your system may require a different name where we show `/dev/ttya' as | |
157 | +the argument to `tip'. The communications parameters, including which | |
158 | +port to use, are associated with the `tip' argument in the "remote" | |
159 | +descriptions file--normally the system table `/etc/remote'. | |
160 | + | |
161 | + Using the `tip' or `cu' connection, change the DOS working directory | |
162 | +to the directory containing a copy of your 29K program, then start the | |
163 | +PC program `EBMON' (an EB29K control program supplied with your board | |
164 | +by AMD). You should see an initial display from `EBMON' similar to the | |
165 | +one that follows, ending with the `EBMON' prompt `#'-- | |
166 | + | |
167 | + C:\> G: | |
168 | + | |
169 | + G:\> CD \usr\joe\work29k | |
170 | + | |
171 | + G:\USR\JOE\WORK29K> EBMON | |
172 | + Am29000 PC Coprocessor Board Monitor, version 3.0-18 | |
173 | + Copyright 1990 Advanced Micro Devices, Inc. | |
174 | + Written by Gibbons and Associates, Inc. | |
175 | + | |
176 | + Enter '?' or 'H' for help | |
177 | + | |
178 | + PC Coprocessor Type = EB29K | |
179 | + I/O Base = 0x208 | |
180 | + Memory Base = 0xd0000 | |
181 | + | |
182 | + Data Memory Size = 2048KB | |
183 | + Available I-RAM Range = 0x8000 to 0x1fffff | |
184 | + Available D-RAM Range = 0x80002000 to 0x801fffff | |
185 | + | |
186 | + PageSize = 0x400 | |
187 | + Register Stack Size = 0x800 | |
188 | + Memory Stack Size = 0x1800 | |
189 | + | |
190 | + CPU PRL = 0x3 | |
191 | + Am29027 Available = No | |
192 | + Byte Write Available = Yes | |
193 | + | |
194 | + # ~. | |
195 | + | |
196 | + Then exit the `cu' or `tip' program (done in the example by typing | |
197 | +`~.' at the `EBMON' prompt). `EBMON' keeps running, ready for GDB to | |
198 | +take over. | |
199 | + | |
200 | + For this example, we've assumed what is probably the most convenient | |
201 | +way to make sure the same 29K program is on both the PC and the Unix | |
202 | +system: a PC/NFS connection that establishes "drive `G:'" on the PC as | |
203 | +a file system on the Unix host. If you do not have PC/NFS or something | |
204 | +similar connecting the two systems, you must arrange some other | |
205 | +way--perhaps floppy-disk transfer--of getting the 29K program from the | |
206 | +Unix system to the PC; GDB does *not* download it over the serial line. | |
207 | + | |
208 | + | |
209 | +File: gdb.info, Node: gdb-EB29K, Next: Remote Log, Prev: Comms (EB29K), Up: EB29K Remote | |
210 | + | |
211 | +EB29K cross-debugging | |
212 | +..................... | |
213 | + | |
214 | + Finally, `cd' to the directory containing an image of your 29K | |
215 | +program on the Unix system, and start GDB--specifying as argument the | |
216 | +name of your 29K program: | |
217 | + | |
218 | + cd /usr/joe/work29k | |
219 | + gdb myfoo | |
220 | + | |
221 | + Now you can use the `target' command: | |
222 | + | |
223 | + target amd-eb /dev/ttya 9600 MYFOO | |
224 | + | |
225 | +In this example, we've assumed your program is in a file called | |
226 | +`myfoo'. Note that the filename given as the last argument to `target | |
227 | +amd-eb' should be the name of the program as it appears to DOS. In our | |
228 | +example this is simply `MYFOO', but in general it can include a DOS | |
229 | +path, and depending on your transfer mechanism may not resemble the | |
230 | +name on the Unix side. | |
231 | + | |
232 | + At this point, you can set any breakpoints you wish; when you are | |
233 | +ready to see your program run on the 29K board, use the GDB command | |
234 | +`run'. | |
235 | + | |
236 | + To stop debugging the remote program, use the GDB `detach' command. | |
237 | + | |
238 | + To return control of the PC to its console, use `tip' or `cu' once | |
239 | +again, after your GDB session has concluded, to attach to `EBMON'. You | |
240 | +can then type the command `q' to shut down `EBMON', returning control | |
241 | +to the DOS command-line interpreter. Type `CTTY con' to return command | |
242 | +input to the main DOS console, and type `~.' to leave `tip' or `cu'. | |
243 | + | |
244 | + | |
245 | +File: gdb.info, Node: Remote Log, Prev: gdb-EB29K, Up: EB29K Remote | |
246 | + | |
247 | +Remote log | |
248 | +.......... | |
249 | + | |
250 | + The `target amd-eb' command creates a file `eb.log' in the current | |
251 | +working directory, to help debug problems with the connection. | |
252 | +`eb.log' records all the output from `EBMON', including echoes of the | |
253 | +commands sent to it. Running `tail -f' on this file in another window | |
254 | +often helps to understand trouble with `EBMON', or unexpected events on | |
255 | +the PC side of the connection. | |
256 | + | |
257 | + | |
258 | +File: gdb.info, Node: ST2000 Remote, Next: Hitachi Remote, Prev: VxWorks Remote, Up: Remote | |
259 | + | |
260 | +GDB with a Tandem ST2000 | |
261 | +------------------------ | |
262 | + | |
263 | + To connect your ST2000 to the host system, see the manufacturer's | |
264 | +manual. Once the ST2000 is physically attached, you can run: | |
265 | + | |
266 | + target st2000 DEV SPEED | |
267 | + | |
268 | +to establish it as your debugging environment. DEV is normally the | |
269 | +name of a serial device, such as `/dev/ttya', connected to the ST2000 | |
270 | +via a serial line. You can instead specify DEV as a TCP connection | |
271 | +(for example, to a serial line attached via a terminal concentrator) | |
272 | +using the syntax `HOSTNAME:PORTNUMBER'. | |
273 | + | |
274 | + The `load' and `attach' commands are *not* defined for this target; | |
275 | +you must load your program into the ST2000 as you normally would for | |
276 | +standalone operation. GDB reads debugging information (such as | |
277 | +symbols) from a separate, debugging version of the program available on | |
278 | +your host computer. | |
279 | + | |
280 | + These auxiliary GDB commands are available to help you with the | |
281 | +ST2000 environment: | |
282 | + | |
283 | +`st2000 COMMAND' | |
284 | + Send a COMMAND to the STDBUG monitor. See the manufacturer's | |
285 | + manual for available commands. | |
286 | + | |
287 | +`connect' | |
288 | + Connect the controlling terminal to the STDBUG command monitor. | |
289 | + When you are done interacting with STDBUG, typing either of two | |
290 | + character sequences gets you back to the GDB command prompt: | |
291 | + `<RET>~.' (Return, followed by tilde and period) or `<RET>~<C-d>' | |
292 | + (Return, followed by tilde and control-D). | |
293 | + | |
294 | + | |
295 | +File: gdb.info, Node: VxWorks Remote, Next: ST2000 Remote, Prev: EB29K Remote, Up: Remote | |
296 | + | |
297 | +GDB and VxWorks | |
298 | +--------------- | |
299 | + | |
300 | + GDB enables developers to spawn and debug tasks running on networked | |
301 | +VxWorks targets from a Unix host. Already-running tasks spawned from | |
302 | +the VxWorks shell can also be debugged. GDB uses code that runs on | |
303 | +both the Unix host and on the VxWorks target. The program `gdb' is | |
304 | +installed and executed on the Unix host. (It may be installed with the | |
305 | +name `vxgdb', to distinguish it from a GDB for debugging programs on | |
306 | +the host itself.) | |
307 | + | |
308 | +`VxWorks-timeout ARGS' | |
309 | + All VxWorks-based targets now support the option `vxworks-timeout'. | |
310 | + This option is set by the user, and ARGS represents the number of | |
311 | + seconds GDB waits for responses to rpc's. You might use this if | |
312 | + your VxWorks target is a slow software simulator or is on the far | |
313 | + side of a thin network line. | |
314 | + | |
315 | + The following information on connecting to VxWorks was current when | |
316 | +this manual was produced; newer releases of VxWorks may use revised | |
317 | +procedures. | |
318 | + | |
319 | + To use GDB with VxWorks, you must rebuild your VxWorks kernel to | |
320 | +include the remote debugging interface routines in the VxWorks library | |
321 | +`rdb.a'. To do this, define `INCLUDE_RDB' in the VxWorks configuration | |
322 | +file `configAll.h' and rebuild your VxWorks kernel. The resulting | |
323 | +kernel contains `rdb.a', and spawns the source debugging task | |
324 | +`tRdbTask' when VxWorks is booted. For more information on configuring | |
325 | +and remaking VxWorks, see the manufacturer's manual. | |
326 | + | |
327 | + Once you have included `rdb.a' in your VxWorks system image and set | |
328 | +your Unix execution search path to find GDB, you are ready to run GDB. | |
329 | +From your Unix host, run `gdb' (or `vxgdb', depending on your | |
330 | +installation). | |
331 | + | |
332 | + GDB comes up showing the prompt: | |
333 | + | |
334 | + (vxgdb) | |
335 | + | |
336 | +* Menu: | |
337 | + | |
338 | +* VxWorks Connection:: Connecting to VxWorks | |
339 | +* VxWorks Download:: VxWorks download | |
340 | +* VxWorks Attach:: Running tasks | |
341 | + | |
342 | + | |
343 | +File: gdb.info, Node: VxWorks Connection, Next: VxWorks Download, Up: VxWorks Remote | |
344 | + | |
345 | +Connecting to VxWorks | |
346 | +..................... | |
347 | + | |
348 | + The GDB command `target' lets you connect to a VxWorks target on the | |
349 | +network. To connect to a target whose host name is "`tt'", type: | |
350 | + | |
351 | + (vxgdb) target vxworks tt | |
352 | + | |
353 | + GDB displays messages like these: | |
354 | + | |
355 | + Attaching remote machine across net... | |
356 | + Connected to tt. | |
357 | + | |
358 | + GDB then attempts to read the symbol tables of any object modules | |
359 | +loaded into the VxWorks target since it was last booted. GDB locates | |
360 | +these files by searching the directories listed in the command search | |
361 | +path (*note Your program's environment: Environment.); if it fails to | |
362 | +find an object file, it displays a message such as: | |
363 | + | |
364 | + prog.o: No such file or directory. | |
365 | + | |
366 | + When this happens, add the appropriate directory to the search path | |
367 | +with the GDB command `path', and execute the `target' command again. | |
368 | + | |
369 | + | |
370 | +File: gdb.info, Node: VxWorks Download, Next: VxWorks Attach, Prev: VxWorks Connection, Up: VxWorks Remote | |
371 | + | |
372 | +VxWorks download | |
373 | +................ | |
374 | + | |
375 | + If you have connected to the VxWorks target and you want to debug an | |
376 | +object that has not yet been loaded, you can use the GDB `load' command | |
377 | +to download a file from Unix to VxWorks incrementally. The object file | |
378 | +given as an argument to the `load' command is actually opened twice: | |
379 | +first by the VxWorks target in order to download the code, then by GDB | |
380 | +in order to read the symbol table. This can lead to problems if the | |
381 | +current working directories on the two systems differ. If both systems | |
382 | +have NFS mounted the same filesystems, you can avoid these problems by | |
383 | +using absolute paths. Otherwise, it is simplest to set the working | |
384 | +directory on both systems to the directory in which the object file | |
385 | +resides, and then to reference the file by its name, without any path. | |
386 | +For instance, a program `prog.o' may reside in `VXPATH/vw/demo/rdb' in | |
387 | +VxWorks and in `HOSTPATH/vw/demo/rdb' on the host. To load this | |
388 | +program, type this on VxWorks: | |
389 | + | |
390 | + -> cd "VXPATH/vw/demo/rdb" | |
391 | + v Then, in GDB, type: | |
392 | + | |
393 | + (vxgdb) cd HOSTPATH/vw/demo/rdb | |
394 | + (vxgdb) load prog.o | |
395 | + | |
396 | + GDB displays a response similar to this: | |
397 | + | |
398 | + Reading symbol data from wherever/vw/demo/rdb/prog.o... done. | |
399 | + | |
400 | + You can also use the `load' command to reload an object module after | |
401 | +editing and recompiling the corresponding source file. Note that this | |
402 | +makes GDB delete all currently-defined breakpoints, auto-displays, and | |
403 | +convenience variables, and to clear the value history. (This is | |
404 | +necessary in order to preserve the integrity of debugger data | |
405 | +structures that reference the target system's symbol table.) | |
406 | + | |
407 | + | |
408 | +File: gdb.info, Node: VxWorks Attach, Prev: VxWorks Download, Up: VxWorks Remote | |
409 | + | |
410 | +Running tasks | |
411 | +............. | |
412 | + | |
413 | + You can also attach to an existing task using the `attach' command as | |
414 | +follows: | |
415 | + | |
416 | + (vxgdb) attach TASK | |
417 | + | |
418 | +where TASK is the VxWorks hexadecimal task ID. The task can be running | |
419 | +or suspended when you attach to it. Running tasks are suspended at the | |
420 | +time of attachment. | |
421 | + | |
422 | + | |
423 | +File: gdb.info, Node: Sparclet Remote, Next: Simulator, Prev: MIPS Remote, Up: Remote | |
424 | + | |
425 | +GDB and Sparclet | |
426 | +---------------- | |
427 | + | |
428 | + GDB enables developers to debug tasks running on Sparclet targets | |
429 | +from a Unix host. GDB uses code that runs on both the Unix host and on | |
430 | +the Sparclet target. The program `gdb' is installed and executed on | |
431 | +the Unix host. | |
432 | + | |
433 | +`timeout ARGS' | |
434 | + GDB now supports the option `remotetimeout'. This option is set | |
435 | + by the user, and ARGS represents the number of seconds GDB waits | |
436 | + for responses. | |
437 | + | |
438 | + When compiling for debugging, include the options "-g" to get debug | |
439 | +information and "-Ttext" to relocate the program to where you wish to | |
440 | +load it on the target. You may also want to add the options "-n" or | |
441 | +"-N" in order to reduce the size of the sections. | |
442 | + | |
443 | + sparclet-aout-gcc prog.c -Ttext 0x12010000 -g -o prog -N | |
444 | + | |
445 | + You can use objdump to verify that the addresses are what you | |
446 | +intended. | |
447 | + | |
448 | + sparclet-aout-objdump --headers --syms prog | |
449 | + | |
450 | + Once you have set your Unix execution search path to find GDB, you | |
451 | +are ready to run GDB. From your Unix host, run `gdb' (or | |
452 | +`sparclet-aout-gdb', depending on your installation). | |
453 | + | |
454 | + GDB comes up showing the prompt: | |
455 | + | |
456 | + (gdbslet) | |
457 | + | |
458 | +* Menu: | |
459 | + | |
460 | +* Sparclet File:: Setting the file to debug | |
461 | +* Sparclet Connection:: Connecting to Sparclet | |
462 | +* Sparclet Download:: Sparclet download | |
463 | +* Sparclet Execution:: Running and debugging | |
464 | + | |
465 | + | |
466 | +File: gdb.info, Node: Sparclet File, Next: Sparclet Connection, Up: Sparclet Remote | |
467 | + | |
468 | +Setting file to debug | |
469 | +..................... | |
470 | + | |
471 | + The GDB command `file' lets you choose with program to debug. | |
472 | + | |
473 | + (gdbslet) file prog | |
474 | + | |
475 | + GDB then attempts to read the symbol table of `prog'. GDB locates | |
476 | +the file by searching the directories listed in the command search path. | |
477 | +If the file was compiled with debug information (option "-g"), source | |
478 | +files will be searched as well. GDB locates the source files by | |
479 | +searching the directories listed in the directory search path (*note | |
480 | +Your program's environment: Environment.). If it fails to find a file, | |
481 | +it displays a message such as: | |
482 | + | |
483 | + prog: No such file or directory. | |
484 | + | |
485 | + When this happens, add the appropriate directories to the search | |
486 | +paths with the GDB commands `path' and `dir', and execute the `target' | |
487 | +command again. | |
488 | + | |
489 | + | |
490 | +File: gdb.info, Node: Sparclet Connection, Next: Sparclet Download, Prev: Sparclet File, Up: Sparclet Remote | |
491 | + | |
492 | +Connecting to Sparclet | |
493 | +...................... | |
494 | + | |
495 | + The GDB command `target' lets you connect to a Sparclet target. To | |
496 | +connect to a target on serial port "`ttya'", type: | |
497 | + | |
498 | + (gdbslet) target sparclet /dev/ttya | |
499 | + Remote target sparclet connected to /dev/ttya | |
500 | + main () at ../prog.c:3 | |
501 | + | |
502 | + GDB displays messages like these: | |
503 | + | |
504 | + Connected to ttya. | |
505 | + | |
506 | + | |
507 | +File: gdb.info, Node: Sparclet Download, Next: Sparclet Execution, Prev: Sparclet Connection, Up: Sparclet Remote | |
508 | + | |
509 | +Sparclet download | |
510 | +................. | |
511 | + | |
512 | + Once connected to the Sparclet target, you can use the GDB `load' | |
513 | +command to download the file from the host to the target. The file | |
514 | +name and load offset should be given as arguments to the `load' command. | |
515 | +Since the file format is aout, the program must be loaded to the | |
516 | +starting address. You can use objdump to find out what this value is. | |
517 | +The load offset is an offset which is added to the VMA (virtual memory | |
518 | +address) of each of the file's sections. For instance, if the program | |
519 | +`prog' was linked to text address 0x1201000, with data at 0x12010160 | |
520 | +and bss at 0x12010170, in GDB, type: | |
521 | + | |
522 | + (gdbslet) load prog 0x12010000 | |
523 | + Loading section .text, size 0xdb0 vma 0x12010000 | |
524 | + | |
525 | + If the code is loaded at a different address then what the program | |
526 | +was linked to, you may need to use the `section' and `add-symbol-file' | |
527 | +commands to tell GDB where to map the symbol table. | |
528 | + | |
529 | + | |
530 | +File: gdb.info, Node: Sparclet Execution, Prev: Sparclet Download, Up: Sparclet Remote | |
531 | + | |
532 | +Running and debugging | |
533 | +..................... | |
534 | + | |
535 | + You can now begin debugging the task using GDB's execution control | |
536 | +commands, `b', `step', `run', etc. See the GDB manual for the list of | |
537 | +commands. | |
538 | + | |
539 | + (gdbslet) b main | |
540 | + Breakpoint 1 at 0x12010000: file prog.c, line 3. | |
541 | + (gdbslet) run | |
542 | + Starting program: prog | |
543 | + Breakpoint 1, main (argc=1, argv=0xeffff21c) at prog.c:3 | |
544 | + 3 char *symarg = 0; | |
545 | + (gdbslet) step | |
546 | + 4 char *execarg = "hello!"; | |
547 | + (gdbslet) | |
548 | + | |
549 | + | |
550 | +File: gdb.info, Node: Hitachi Remote, Next: MIPS Remote, Prev: ST2000 Remote, Up: Remote | |
551 | + | |
552 | +GDB and Hitachi microprocessors | |
553 | +------------------------------- | |
554 | + | |
555 | + GDB needs to know these things to talk to your Hitachi SH, H8/300, | |
556 | +or H8/500: | |
557 | + | |
558 | + 1. that you want to use `target hms', the remote debugging interface | |
559 | + for Hitachi microprocessors, or `target e7000', the in-circuit | |
560 | + emulator for the Hitachi SH and the Hitachi 300H. (`target hms' is | |
561 | + the default when GDB is configured specifically for the Hitachi SH, | |
562 | + H8/300, or H8/500.) | |
563 | + | |
564 | + 2. what serial device connects your host to your Hitachi board (the | |
565 | + first serial device available on your host is the default). | |
566 | + | |
567 | + 3. what speed to use over the serial device. | |
568 | + | |
569 | +* Menu: | |
570 | + | |
571 | +* Hitachi Boards:: Connecting to Hitachi boards. | |
572 | +* Hitachi ICE:: Using the E7000 In-Circuit Emulator. | |
573 | +* Hitachi Special:: Special GDB commands for Hitachi micros. | |
574 | + | |
575 | + | |
576 | +File: gdb.info, Node: Hitachi Boards, Next: Hitachi ICE, Up: Hitachi Remote | |
577 | + | |
578 | +Connecting to Hitachi boards | |
579 | +............................ | |
580 | + | |
581 | + Use the special `gdb' command `device PORT' if you need to | |
582 | +explicitly set the serial device. The default PORT is the first | |
583 | +available port on your host. This is only necessary on Unix hosts, | |
584 | +where it is typically something like `/dev/ttya'. | |
585 | + | |
586 | + `gdb' has another special command to set the communications speed: | |
587 | +`speed BPS'. This command also is only used from Unix hosts; on DOS | |
588 | +hosts, set the line speed as usual from outside GDB with the DOS `mode' | |
589 | +command (for instance, `mode com2:9600,n,8,1,p' for a 9600 bps | |
590 | +connection). | |
591 | + | |
592 | + The `device' and `speed' commands are available only when you use a | |
593 | +Unix host to debug your Hitachi microprocessor programs. If you use a | |
594 | +DOS host, GDB depends on an auxiliary terminate-and-stay-resident | |
595 | +program called `asynctsr' to communicate with the development board | |
596 | +through a PC serial port. You must also use the DOS `mode' command to | |
597 | +set up the serial port on the DOS side. | |
598 | + | |
599 | + | |
600 | +File: gdb.info, Node: Hitachi ICE, Next: Hitachi Special, Prev: Hitachi Boards, Up: Hitachi Remote | |
601 | + | |
602 | +Using the E7000 in-circuit emulator | |
603 | +................................... | |
604 | + | |
605 | + You can use the E7000 in-circuit emulator to develop code for either | |
606 | +the Hitachi SH or the H8/300H. Use one of these forms of the `target | |
607 | +e7000' command to connect GDB to your E7000: | |
608 | + | |
609 | +`target e7000 PORT SPEED' | |
610 | + Use this form if your E7000 is connected to a serial port. The | |
611 | + PORT argument identifies what serial port to use (for example, | |
612 | + `com2'). The third argument is the line speed in bits per second | |
613 | + (for example, `9600'). | |
614 | + | |
615 | +`target e7000 HOSTNAME' | |
616 | + If your E7000 is installed as a host on a TCP/IP network, you can | |
617 | + just specify its hostname; GDB uses `telnet' to connect. | |
618 | + | |
619 | + | |
620 | +File: gdb.info, Node: Hitachi Special, Prev: Hitachi ICE, Up: Hitachi Remote | |
621 | + | |
622 | +Special GDB commands for Hitachi micros | |
623 | +....................................... | |
624 | + | |
625 | + Some GDB commands are available only on the H8/300 or the H8/500 | |
626 | +configurations: | |
627 | + | |
628 | +`set machine h8300' | |
629 | +`set machine h8300h' | |
630 | + Condition GDB for one of the two variants of the H8/300 | |
631 | + architecture with `set machine'. You can use `show machine' to | |
632 | + check which variant is currently in effect. | |
633 | + | |
634 | +`set memory MOD' | |
635 | +`show memory' | |
636 | + Specify which H8/500 memory model (MOD) you are using with `set | |
637 | + memory'; check which memory model is in effect with `show memory'. | |
638 | + The accepted values for MOD are `small', `big', `medium', and | |
639 | + `compact'. | |
640 | + | |
641 | + | |
642 | +File: gdb.info, Node: MIPS Remote, Next: Sparclet Remote, Prev: Hitachi Remote, Up: Remote | |
643 | + | |
644 | +GDB and remote MIPS boards | |
645 | +-------------------------- | |
646 | + | |
647 | + GDB can use the MIPS remote debugging protocol to talk to a MIPS | |
648 | +board attached to a serial line. This is available when you configure | |
649 | +GDB with `--target=mips-idt-ecoff'. | |
650 | + | |
651 | + Use these GDB commands to specify the connection to your target | |
652 | +board: | |
653 | + | |
654 | +`target mips PORT' | |
655 | + To run a program on the board, start up `gdb' with the name of | |
656 | + your program as the argument. To connect to the board, use the | |
657 | + command `target mips PORT', where PORT is the name of the serial | |
658 | + port connected to the board. If the program has not already been | |
659 | + downloaded to the board, you may use the `load' command to | |
660 | + download it. You can then use all the usual GDB commands. | |
661 | + | |
662 | + For example, this sequence connects to the target board through a | |
663 | + serial port, and loads and runs a program called PROG through the | |
664 | + debugger: | |
665 | + | |
666 | + host$ gdb PROG | |
667 | + GDB is free software and ... | |
668 | + (gdb) target mips /dev/ttyb | |
669 | + (gdb) load PROG | |
670 | + (gdb) run | |
671 | + | |
672 | +`target mips HOSTNAME:PORTNUMBER' | |
673 | + On some GDB host configurations, you can specify a TCP connection | |
674 | + (for instance, to a serial line managed by a terminal | |
675 | + concentrator) instead of a serial port, using the syntax | |
676 | + `HOSTNAME:PORTNUMBER'. | |
677 | + | |
678 | +`target pmon PORT' | |
679 | + | |
680 | +`target ddb PORT' | |
681 | + | |
682 | +`target lsi PORT' | |
683 | +GDB also supports these special commands for MIPS targets: | |
684 | + | |
685 | +`set processor ARGS' | |
686 | +`show processor' | |
687 | + Use the `set processor' command to set the type of MIPS processor | |
688 | + when you want to access processor-type-specific registers. For | |
689 | + example, `set processor R3041' tells GDB to use the CPO registers | |
690 | + appropriate for the 3041 chip. Use the `show processor' command | |
691 | + to see what MIPS processor GDB is using. Use the `info reg' | |
692 | + command to see what registers GDB is using. | |
693 | + | |
694 | +`set mipsfpu double' | |
695 | +`set mipsfpu single' | |
696 | +`set mipsfpu none' | |
697 | +`show mipsfpu' | |
698 | + If your target board does not support the MIPS floating point | |
699 | + coprocessor, you should use the command `set mipsfpu none' (if you | |
700 | + need this, you may wish to put the command in your {No Value For | |
701 | + "GDBINIT"} file). This tells GDB how to find the return value of | |
702 | + functions which return floating point values. It also allows GDB | |
703 | + to avoid saving the floating point registers when calling | |
704 | + functions on the board. If you are using a floating point | |
705 | + coprocessor with only single precision floating point support, as | |
706 | + on the R4650 processor, use the command `set mipsfpu single'. The | |
707 | + default double precision floating point coprocessor may be | |
708 | + selected using `set mipsfpu double'. | |
709 | + | |
710 | + In previous versions the only choices were double precision or no | |
711 | + floating point, so `set mipsfpu on' will select double precision | |
712 | + and `set mipsfpu off' will select no floating point. | |
713 | + | |
714 | + As usual, you can inquire about the `mipsfpu' variable with `show | |
715 | + mipsfpu'. | |
716 | + | |
717 | +`set remotedebug N' | |
718 | +`show remotedebug' | |
719 | + You can see some debugging information about communications with | |
720 | + the board by setting the `remotedebug' variable. If you set it to | |
721 | + `1' using `set remotedebug 1', every packet is displayed. If you | |
722 | + set it to `2', every character is displayed. You can check the | |
723 | + current value at any time with the command `show remotedebug'. | |
724 | + | |
725 | +`set timeout SECONDS' | |
726 | +`set retransmit-timeout SECONDS' | |
727 | +`show timeout' | |
728 | +`show retransmit-timeout' | |
729 | + You can control the timeout used while waiting for a packet, in | |
730 | + the MIPS remote protocol, with the `set timeout SECONDS' command. | |
731 | + The default is 5 seconds. Similarly, you can control the timeout | |
732 | + used while waiting for an acknowledgement of a packet with the `set | |
733 | + retransmit-timeout SECONDS' command. The default is 3 seconds. | |
734 | + You can inspect both values with `show timeout' and `show | |
735 | + retransmit-timeout'. (These commands are *only* available when | |
736 | + GDB is configured for `--target=mips-idt-ecoff'.) | |
737 | + | |
738 | + The timeout set by `set timeout' does not apply when GDB is | |
739 | + waiting for your program to stop. In that case, GDB waits forever | |
740 | + because it has no way of knowing how long the program is going to | |
741 | + run before stopping. | |
742 | + | |
743 | + | |
744 | +File: gdb.info, Node: Simulator, Prev: Sparclet Remote, Up: Remote | |
745 | + | |
746 | +Simulated CPU target | |
747 | +-------------------- | |
748 | + | |
749 | + For some configurations, GDB includes a CPU simulator that you can | |
750 | +use instead of a hardware CPU to debug your programs. Currently, | |
751 | +simulators are available for ARM, D10V, D30V, FR30, H8/300, H8/500, | |
752 | +i960, M32R, MIPS, MN10200, MN10300, PowerPC, SH, Sparc, V850, W65, and | |
753 | +Z8000. | |
754 | + | |
755 | + For the Z8000 family, `target sim' simulates either the Z8002 (the | |
756 | +unsegmented variant of the Z8000 architecture) or the Z8001 (the | |
757 | +segmented variant). The simulator recognizes which architecture is | |
758 | +appropriate by inspecting the object code. | |
759 | + | |
760 | +`target sim ARGS' | |
761 | + Debug programs on a simulated CPU. If the simulator supports setup | |
762 | + options, specify them via ARGS. | |
763 | + | |
764 | +After specifying this target, you can debug programs for the simulated | |
765 | +CPU in the same style as programs for your host computer; use the | |
766 | +`file' command to load a new program image, the `run' command to run | |
767 | +your program, and so on. | |
768 | + | |
769 | + As well as making available all the usual machine registers (see | |
770 | +`info reg'), the Z8000 simulator provides three additional items of | |
771 | +information as specially named registers: | |
772 | + | |
773 | +`cycles' | |
774 | + Counts clock-ticks in the simulator. | |
775 | + | |
776 | +`insts' | |
777 | + Counts instructions run in the simulator. | |
778 | + | |
779 | +`time' | |
780 | + Execution time in 60ths of a second. | |
781 | + | |
782 | + You can refer to these values in GDB expressions with the usual | |
783 | +conventions; for example, `b fputc if $cycles>5000' sets a conditional | |
784 | +breakpoint that suspends only after at least 5000 simulated clock ticks. | |
785 | + | |
786 | + | |
787 | +File: gdb.info, Node: Controlling GDB, Next: Sequences, Prev: Targets, Up: Top | |
788 | + | |
789 | +Controlling GDB | |
790 | +*************** | |
791 | + | |
792 | + You can alter the way GDB interacts with you by using the `set' | |
793 | +command. For commands controlling how GDB displays data, *note Print | |
794 | +settings: Print Settings.; other settings are described here. | |
795 | + | |
796 | +* Menu: | |
797 | + | |
798 | +* Prompt:: Prompt | |
799 | +* Editing:: Command editing | |
800 | +* History:: Command history | |
801 | +* Screen Size:: Screen size | |
802 | +* Numbers:: Numbers | |
803 | +* Messages/Warnings:: Optional warnings and messages | |
804 | + | |
805 | + | |
806 | +File: gdb.info, Node: Prompt, Next: Editing, Prev: Controlling GDB, Up: Controlling GDB | |
807 | + | |
808 | +Prompt | |
809 | +====== | |
810 | + | |
811 | + GDB indicates its readiness to read a command by printing a string | |
812 | +called the "prompt". This string is normally `(gdb)'. You can change | |
813 | +the prompt string with the `set prompt' command. For instance, when | |
814 | +debugging GDB with GDB, it is useful to change the prompt in one of the | |
815 | +GDB sessions so that you can always tell which one you are talking to. | |
816 | + | |
817 | + *Note:* `set prompt' no longer adds a space for you after the | |
818 | +prompt you set. This allows you to set a prompt which ends in a space | |
819 | +or a prompt that does not. | |
820 | + | |
821 | +`set prompt NEWPROMPT' | |
822 | + Directs GDB to use NEWPROMPT as its prompt string henceforth. | |
823 | + | |
824 | +`show prompt' | |
825 | + Prints a line of the form: `Gdb's prompt is: YOUR-PROMPT' | |
826 | + | |
827 | + | |
828 | +File: gdb.info, Node: Editing, Next: History, Prev: Prompt, Up: Controlling GDB | |
829 | + | |
830 | +Command editing | |
831 | +=============== | |
832 | + | |
833 | + GDB reads its input commands via the "readline" interface. This GNU | |
834 | +library provides consistent behavior for programs which provide a | |
835 | +command line interface to the user. Advantages are GNU Emacs-style or | |
836 | +"vi"-style inline editing of commands, `csh'-like history substitution, | |
837 | +and a storage and recall of command history across debugging sessions. | |
838 | + | |
839 | + You may control the behavior of command line editing in GDB with the | |
840 | +command `set'. | |
841 | + | |
842 | +`set editing' | |
843 | +`set editing on' | |
844 | + Enable command line editing (enabled by default). | |
845 | + | |
846 | +`set editing off' | |
847 | + Disable command line editing. | |
848 | + | |
849 | +`show editing' | |
850 | + Show whether command line editing is enabled. | |
851 | + | |
852 | + | |
853 | +File: gdb.info, Node: History, Next: Screen Size, Prev: Editing, Up: Controlling GDB | |
854 | + | |
855 | +Command history | |
856 | +=============== | |
857 | + | |
858 | + GDB can keep track of the commands you type during your debugging | |
859 | +sessions, so that you can be certain of precisely what happened. Use | |
860 | +these commands to manage the GDB command history facility. | |
861 | + | |
862 | +`set history filename FNAME' | |
863 | + Set the name of the GDB command history file to FNAME. This is | |
864 | + the file where GDB reads an initial command history list, and | |
865 | + where it writes the command history from this session when it | |
866 | + exits. You can access this list through history expansion or | |
867 | + through the history command editing characters listed below. This | |
868 | + file defaults to the value of the environment variable | |
869 | + `GDBHISTFILE', or to `./.gdb_history' if this variable is not set. | |
870 | + | |
871 | +`set history save' | |
872 | +`set history save on' | |
873 | + Record command history in a file, whose name may be specified with | |
874 | + the `set history filename' command. By default, this option is | |
875 | + disabled. | |
876 | + | |
877 | +`set history save off' | |
878 | + Stop recording command history in a file. | |
879 | + | |
880 | +`set history size SIZE' | |
881 | + Set the number of commands which GDB keeps in its history list. | |
882 | + This defaults to the value of the environment variable `HISTSIZE', | |
883 | + or to 256 if this variable is not set. | |
884 | + | |
885 | + History expansion assigns special meaning to the character `!'. | |
886 | + | |
887 | + Since `!' is also the logical not operator in C, history expansion | |
888 | +is off by default. If you decide to enable history expansion with the | |
889 | +`set history expansion on' command, you may sometimes need to follow | |
890 | +`!' (when it is used as logical not, in an expression) with a space or | |
891 | +a tab to prevent it from being expanded. The readline history | |
892 | +facilities do not attempt substitution on the strings `!=' and `!(', | |
893 | +even when history expansion is enabled. | |
894 | + | |
895 | + The commands to control history expansion are: | |
896 | + | |
897 | +`set history expansion on' | |
898 | +`set history expansion' | |
899 | + Enable history expansion. History expansion is off by default. | |
900 | + | |
901 | +`set history expansion off' | |
902 | + Disable history expansion. | |
903 | + | |
904 | + The readline code comes with more complete documentation of | |
905 | + editing and history expansion features. Users unfamiliar with GNU | |
906 | + Emacs or `vi' may wish to read it. | |
907 | + | |
908 | +`show history' | |
909 | +`show history filename' | |
910 | +`show history save' | |
911 | +`show history size' | |
912 | +`show history expansion' | |
913 | + These commands display the state of the GDB history parameters. | |
914 | + `show history' by itself displays all four states. | |
915 | + | |
916 | +`show commands' | |
917 | + Display the last ten commands in the command history. | |
918 | + | |
919 | +`show commands N' | |
920 | + Print ten commands centered on command number N. | |
921 | + | |
922 | +`show commands +' | |
923 | + Print ten commands just after the commands last printed. | |
924 | + | |
925 | + | |
926 | +File: gdb.info, Node: Screen Size, Next: Numbers, Prev: History, Up: Controlling GDB | |
927 | + | |
928 | +Screen size | |
929 | +=========== | |
930 | + | |
931 | + Certain commands to GDB may produce large amounts of information | |
932 | +output to the screen. To help you read all of it, GDB pauses and asks | |
933 | +you for input at the end of each page of output. Type <RET> when you | |
934 | +want to continue the output, or `q' to discard the remaining output. | |
935 | +Also, the screen width setting determines when to wrap lines of output. | |
936 | +Depending on what is being printed, GDB tries to break the line at a | |
937 | +readable place, rather than simply letting it overflow onto the | |
938 | +following line. | |
939 | + | |
940 | + Normally GDB knows the size of the screen from the termcap data base | |
941 | +together with the value of the `TERM' environment variable and the | |
942 | +`stty rows' and `stty cols' settings. If this is not correct, you can | |
943 | +override it with the `set height' and `set width' commands: | |
944 | + | |
945 | +`set height LPP' | |
946 | +`show height' | |
947 | +`set width CPL' | |
948 | +`show width' | |
949 | + These `set' commands specify a screen height of LPP lines and a | |
950 | + screen width of CPL characters. The associated `show' commands | |
951 | + display the current settings. | |
952 | + | |
953 | + If you specify a height of zero lines, GDB does not pause during | |
954 | + output no matter how long the output is. This is useful if output | |
955 | + is to a file or to an editor buffer. | |
956 | + | |
957 | + Likewise, you can specify `set width 0' to prevent GDB from | |
958 | + wrapping its output. | |
959 | + | |
960 | + | |
961 | +File: gdb.info, Node: Numbers, Next: Messages/Warnings, Prev: Screen Size, Up: Controlling GDB | |
962 | + | |
963 | +Numbers | |
964 | +======= | |
965 | + | |
966 | + You can always enter numbers in octal, decimal, or hexadecimal in | |
967 | +GDB by the usual conventions: octal numbers begin with `0', decimal | |
968 | +numbers end with `.', and hexadecimal numbers begin with `0x'. Numbers | |
969 | +that begin with none of these are, by default, entered in base 10; | |
970 | +likewise, the default display for numbers--when no particular format is | |
971 | +specified--is base 10. You can change the default base for both input | |
972 | +and output with the `set radix' command. | |
973 | + | |
974 | +`set input-radix BASE' | |
975 | + Set the default base for numeric input. Supported choices for | |
976 | + BASE are decimal 8, 10, or 16. BASE must itself be specified | |
977 | + either unambiguously or using the current default radix; for | |
978 | + example, any of | |
979 | + | |
980 | + set radix 012 | |
981 | + set radix 10. | |
982 | + set radix 0xa | |
983 | + | |
984 | + sets the base to decimal. On the other hand, `set radix 10' | |
985 | + leaves the radix unchanged no matter what it was. | |
986 | + | |
987 | +`set output-radix BASE' | |
988 | + Set the default base for numeric display. Supported choices for | |
989 | + BASE are decimal 8, 10, or 16. BASE must itself be specified | |
990 | + either unambiguously or using the current default radix. | |
991 | + | |
992 | +`show input-radix' | |
993 | + Display the current default base for numeric input. | |
994 | + | |
995 | +`show output-radix' | |
996 | + Display the current default base for numeric display. | |
997 | + | |
998 | + | |
999 | +File: gdb.info, Node: Messages/Warnings, Prev: Numbers, Up: Controlling GDB | |
1000 | + | |
1001 | +Optional warnings and messages | |
1002 | +============================== | |
1003 | + | |
1004 | + By default, GDB is silent about its inner workings. If you are | |
1005 | +running on a slow machine, you may want to use the `set verbose' | |
1006 | +command. This makes GDB tell you when it does a lengthy internal | |
1007 | +operation, so you will not think it has crashed. | |
1008 | + | |
1009 | + Currently, the messages controlled by `set verbose' are those which | |
1010 | +announce that the symbol table for a source file is being read; see | |
1011 | +`symbol-file' in *Note Commands to specify files: Files. | |
1012 | + | |
1013 | +`set verbose on' | |
1014 | + Enables GDB output of certain informational messages. | |
1015 | + | |
1016 | +`set verbose off' | |
1017 | + Disables GDB output of certain informational messages. | |
1018 | + | |
1019 | +`show verbose' | |
1020 | + Displays whether `set verbose' is on or off. | |
1021 | + | |
1022 | + By default, if GDB encounters bugs in the symbol table of an object | |
1023 | +file, it is silent; but if you are debugging a compiler, you may find | |
1024 | +this information useful (*note Errors reading symbol files: Symbol | |
1025 | +Errors.). | |
1026 | + | |
1027 | +`set complaints LIMIT' | |
1028 | + Permits GDB to output LIMIT complaints about each type of unusual | |
1029 | + symbols before becoming silent about the problem. Set LIMIT to | |
1030 | + zero to suppress all complaints; set it to a large number to | |
1031 | + prevent complaints from being suppressed. | |
1032 | + | |
1033 | +`show complaints' | |
1034 | + Displays how many symbol complaints GDB is permitted to produce. | |
1035 | + | |
1036 | + By default, GDB is cautious, and asks what sometimes seems to be a | |
1037 | +lot of stupid questions to confirm certain commands. For example, if | |
1038 | +you try to run a program which is already running: | |
1039 | + | |
1040 | + (gdb) run | |
1041 | + The program being debugged has been started already. | |
1042 | + Start it from the beginning? (y or n) | |
1043 | + | |
1044 | + If you are willing to unflinchingly face the consequences of your own | |
1045 | +commands, you can disable this "feature": | |
1046 | + | |
1047 | +`set confirm off' | |
1048 | + Disables confirmation requests. | |
1049 | + | |
1050 | +`set confirm on' | |
1051 | + Enables confirmation requests (the default). | |
1052 | + | |
1053 | +`show confirm' | |
1054 | + Displays state of confirmation requests. | |
1055 | + | |
1056 | + | |
1057 | +File: gdb.info, Node: Sequences, Next: Emacs, Prev: Controlling GDB, Up: Top | |
1058 | + | |
1059 | +Canned Sequences of Commands | |
1060 | +**************************** | |
1061 | + | |
1062 | + Aside from breakpoint commands (*note Breakpoint command lists: | |
1063 | +Break Commands.), GDB provides two ways to store sequences of commands | |
1064 | +for execution as a unit: user-defined commands and command files. | |
1065 | + | |
1066 | +* Menu: | |
1067 | + | |
1068 | +* Define:: User-defined commands | |
1069 | +* Hooks:: User-defined command hooks | |
1070 | +* Command Files:: Command files | |
1071 | +* Output:: Commands for controlled output | |
1072 | + | |
1073 | + | |
1074 | +File: gdb.info, Node: Define, Next: Hooks, Prev: Sequences, Up: Sequences | |
1075 | + | |
1076 | +User-defined commands | |
1077 | +===================== | |
1078 | + | |
1079 | + A "user-defined command" is a sequence of GDB commands to which you | |
1080 | +assign a new name as a command. This is done with the `define' | |
1081 | +command. User commands may accept up to 10 arguments separated by | |
1082 | +whitespace. Arguments are accessed within the user command via | |
1083 | +$ARG0...$ARG9. A trivial example: | |
1084 | + | |
1085 | + define adder | |
1086 | + print $arg0 + $arg1 + $arg2 | |
1087 | + | |
1088 | +To execute the command use: | |
1089 | + | |
1090 | + adder 1 2 3 | |
1091 | + | |
1092 | +This defines the command `adder', which prints the sum of its three | |
1093 | +arguments. Note the arguments are text substitutions, so they may | |
1094 | +reference variables, use complex expressions, or even perform inferior | |
1095 | +functions calls. | |
1096 | + | |
1097 | +`define COMMANDNAME' | |
1098 | + Define a command named COMMANDNAME. If there is already a command | |
1099 | + by that name, you are asked to confirm that you want to redefine | |
1100 | + it. | |
1101 | + | |
1102 | + The definition of the command is made up of other GDB command | |
1103 | + lines, which are given following the `define' command. The end of | |
1104 | + these commands is marked by a line containing `end'. | |
1105 | + | |
1106 | +`if' | |
1107 | + Takes a single argument, which is an expression to evaluate. It | |
1108 | + is followed by a series of commands that are executed only if the | |
1109 | + expression is true (nonzero). There can then optionally be a line | |
1110 | + `else', followed by a series of commands that are only executed if | |
1111 | + the expression was false. The end of the list is marked by a line | |
1112 | + containing `end'. | |
1113 | + | |
1114 | +`while' | |
1115 | + The syntax is similar to `if': the command takes a single argument, | |
1116 | + which is an expression to evaluate, and must be followed by the | |
1117 | + commands to execute, one per line, terminated by an `end'. The | |
1118 | + commands are executed repeatedly as long as the expression | |
1119 | + evaluates to true. | |
1120 | + | |
1121 | +`document COMMANDNAME' | |
1122 | + Document the user-defined command COMMANDNAME, so that it can be | |
1123 | + accessed by `help'. The command COMMANDNAME must already be | |
1124 | + defined. This command reads lines of documentation just as | |
1125 | + `define' reads the lines of the command definition, ending with | |
1126 | + `end'. After the `document' command is finished, `help' on command | |
1127 | + COMMANDNAME displays the documentation you have written. | |
1128 | + | |
1129 | + You may use the `document' command again to change the | |
1130 | + documentation of a command. Redefining the command with `define' | |
1131 | + does not change the documentation. | |
1132 | + | |
1133 | +`help user-defined' | |
1134 | + List all user-defined commands, with the first line of the | |
1135 | + documentation (if any) for each. | |
1136 | + | |
1137 | +`show user' | |
1138 | +`show user COMMANDNAME' | |
1139 | + Display the GDB commands used to define COMMANDNAME (but not its | |
1140 | + documentation). If no COMMANDNAME is given, display the | |
1141 | + definitions for all user-defined commands. | |
1142 | + | |
1143 | + When user-defined commands are executed, the commands of the | |
1144 | +definition are not printed. An error in any command stops execution of | |
1145 | +the user-defined command. | |
1146 | + | |
1147 | + If used interactively, commands that would ask for confirmation | |
1148 | +proceed without asking when used inside a user-defined command. Many | |
1149 | +GDB commands that normally print messages to say what they are doing | |
1150 | +omit the messages when used in a user-defined command. | |
1151 | + | |
1152 | + | |
1153 | +File: gdb.info, Node: Hooks, Next: Command Files, Prev: Define, Up: Sequences | |
1154 | + | |
1155 | +User-defined command hooks | |
1156 | +========================== | |
1157 | + | |
1158 | + You may define *hooks*, which are a special kind of user-defined | |
1159 | +command. Whenever you run the command `foo', if the user-defined | |
1160 | +command `hook-foo' exists, it is executed (with no arguments) before | |
1161 | +that command. | |
1162 | + | |
1163 | + In addition, a pseudo-command, `stop' exists. Defining | |
1164 | +(`hook-stop') makes the associated commands execute every time | |
1165 | +execution stops in your program: before breakpoint commands are run, | |
1166 | +displays are printed, or the stack frame is printed. | |
1167 | + | |
1168 | + For example, to ignore `SIGALRM' signals while single-stepping, but | |
1169 | +treat them normally during normal execution, you could define: | |
1170 | + | |
1171 | + define hook-stop | |
1172 | + handle SIGALRM nopass | |
1173 | + end | |
1174 | + | |
1175 | + define hook-run | |
1176 | + handle SIGALRM pass | |
1177 | + end | |
1178 | + | |
1179 | + define hook-continue | |
1180 | + handle SIGLARM pass | |
1181 | + end | |
1182 | + | |
1183 | + You can define a hook for any single-word command in GDB, but not | |
1184 | +for command aliases; you should define a hook for the basic command | |
1185 | +name, e.g. `backtrace' rather than `bt'. If an error occurs during | |
1186 | +the execution of your hook, execution of GDB commands stops and GDB | |
1187 | +issues a prompt (before the command that you actually typed had a | |
1188 | +chance to run). | |
1189 | + | |
1190 | + If you try to define a hook which does not match any known command, | |
1191 | +you get a warning from the `define' command. | |
1192 | + | |
1193 | + | |
1194 | +File: gdb.info, Node: Command Files, Next: Output, Prev: Hooks, Up: Sequences | |
1195 | + | |
1196 | +Command files | |
1197 | +============= | |
1198 | + | |
1199 | + A command file for GDB is a file of lines that are GDB commands. | |
1200 | +Comments (lines starting with `#') may also be included. An empty line | |
1201 | +in a command file does nothing; it does not mean to repeat the last | |
1202 | +command, as it would from the terminal. | |
1203 | + | |
1204 | + When you start GDB, it automatically executes commands from its | |
1205 | +"init files". These are files named `.gdbinit' on Unix, or `gdb.ini' | |
1206 | +on DOS/Windows. GDB reads the init file (if any) in your home | |
1207 | +directory, then processes command line options and operands, and then | |
1208 | +reads the init file (if any) in the current working directory. This is | |
1209 | +so the init file in your home directory can set options (such as `set | |
1210 | +complaints') which affect the processing of the command line options | |
1211 | +and operands. The init files are not executed if you use the `-nx' | |
1212 | +option; *note Choosing modes: Mode Options.. | |
1213 | + | |
1214 | + On some configurations of GDB, the init file is known by a different | |
1215 | +name (these are typically environments where a specialized form of GDB | |
1216 | +may need to coexist with other forms, hence a different name for the | |
1217 | +specialized version's init file). These are the environments with | |
1218 | +special init file names: | |
1219 | + | |
1220 | + * VxWorks (Wind River Systems real-time OS): `.vxgdbinit' | |
1221 | + | |
1222 | + * OS68K (Enea Data Systems real-time OS): `.os68gdbinit' | |
1223 | + | |
1224 | + * ES-1800 (Ericsson Telecom AB M68000 emulator): `.esgdbinit' | |
1225 | + | |
1226 | + You can also request the execution of a command file with the | |
1227 | +`source' command: | |
1228 | + | |
1229 | +`source FILENAME' | |
1230 | + Execute the command file FILENAME. | |
1231 | + | |
1232 | + The lines in a command file are executed sequentially. They are not | |
1233 | +printed as they are executed. An error in any command terminates | |
1234 | +execution of the command file. | |
1235 | + | |
1236 | + Commands that would ask for confirmation if used interactively | |
1237 | +proceed without asking when used in a command file. Many GDB commands | |
1238 | +that normally print messages to say what they are doing omit the | |
1239 | +messages when called from command files. | |
1240 | + | |
1241 | + | |
1242 | +File: gdb.info, Node: Output, Prev: Command Files, Up: Sequences | |
1243 | + | |
1244 | +Commands for controlled output | |
1245 | +============================== | |
1246 | + | |
1247 | + During the execution of a command file or a user-defined command, | |
1248 | +normal GDB output is suppressed; the only output that appears is what is | |
1249 | +explicitly printed by the commands in the definition. This section | |
1250 | +describes three commands useful for generating exactly the output you | |
1251 | +want. | |
1252 | + | |
1253 | +`echo TEXT' | |
1254 | + Print TEXT. Nonprinting characters can be included in TEXT using | |
1255 | + C escape sequences, such as `\n' to print a newline. *No newline | |
1256 | + is printed unless you specify one.* In addition to the standard C | |
1257 | + escape sequences, a backslash followed by a space stands for a | |
1258 | + space. This is useful for displaying a string with spaces at the | |
1259 | + beginning or the end, since leading and trailing spaces are | |
1260 | + otherwise trimmed from all arguments. To print ` and foo = ', use | |
1261 | + the command `echo \ and foo = \ '. | |
1262 | + | |
1263 | + A backslash at the end of TEXT can be used, as in C, to continue | |
1264 | + the command onto subsequent lines. For example, | |
1265 | + | |
1266 | + echo This is some text\n\ | |
1267 | + which is continued\n\ | |
1268 | + onto several lines.\n | |
1269 | + | |
1270 | + produces the same output as | |
1271 | + | |
1272 | + echo This is some text\n | |
1273 | + echo which is continued\n | |
1274 | + echo onto several lines.\n | |
1275 | + | |
1276 | +`output EXPRESSION' | |
1277 | + Print the value of EXPRESSION and nothing but that value: no | |
1278 | + newlines, no `$NN = '. The value is not entered in the value | |
1279 | + history either. *Note Expressions: Expressions, for more | |
1280 | + information on expressions. | |
1281 | + | |
1282 | +`output/FMT EXPRESSION' | |
1283 | + Print the value of EXPRESSION in format FMT. You can use the same | |
1284 | + formats as for `print'. *Note Output formats: Output Formats, for | |
1285 | + more information. | |
1286 | + | |
1287 | +`printf STRING, EXPRESSIONS...' | |
1288 | + Print the values of the EXPRESSIONS under the control of STRING. | |
1289 | + The EXPRESSIONS are separated by commas and may be either numbers | |
1290 | + or pointers. Their values are printed as specified by STRING, | |
1291 | + exactly as if your program were to execute the C subroutine | |
1292 | + | |
1293 | + printf (STRING, EXPRESSIONS...); | |
1294 | + | |
1295 | + For example, you can print two values in hex like this: | |
1296 | + | |
1297 | + printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo | |
1298 | + | |
1299 | + The only backslash-escape sequences that you can use in the format | |
1300 | + string are the simple ones that consist of backslash followed by a | |
1301 | + letter. | |
1302 | + |
@@ -0,0 +1,1308 @@ | ||
1 | +This is Info file ./gdb.info, produced by Makeinfo version 1.68 from | |
2 | +the input file gdb.texinfo. | |
3 | + | |
4 | +START-INFO-DIR-ENTRY | |
5 | +* Gdb: (gdb). The GNU debugger. | |
6 | +END-INFO-DIR-ENTRY | |
7 | + This file documents the GNU debugger GDB. | |
8 | + | |
9 | + This is the Seventh Edition, February 1999, of `Debugging with GDB: | |
10 | +the GNU Source-Level Debugger' for GDB Version 4.18. | |
11 | + | |
12 | + Copyright (C) 1988-1999 Free Software Foundation, Inc. | |
13 | + | |
14 | + Permission is granted to make and distribute verbatim copies of this | |
15 | +manual provided the copyright notice and this permission notice are | |
16 | +preserved on all copies. | |
17 | + | |
18 | + Permission is granted to copy and distribute modified versions of | |
19 | +this manual under the conditions for verbatim copying, provided also | |
20 | +that the entire resulting derived work is distributed under the terms | |
21 | +of a permission notice identical to this one. | |
22 | + | |
23 | + Permission is granted to copy and distribute translations of this | |
24 | +manual into another language, under the above conditions for modified | |
25 | +versions. | |
26 | + | |
27 | + | |
28 | +File: gdb.info, Node: Emacs, Next: GDB Bugs, Prev: Sequences, Up: Top | |
29 | + | |
30 | +Using GDB under GNU Emacs | |
31 | +************************* | |
32 | + | |
33 | + A special interface allows you to use GNU Emacs to view (and edit) | |
34 | +the source files for the program you are debugging with GDB. | |
35 | + | |
36 | + To use this interface, use the command `M-x gdb' in Emacs. Give the | |
37 | +executable file you want to debug as an argument. This command starts | |
38 | +GDB as a subprocess of Emacs, with input and output through a newly | |
39 | +created Emacs buffer. | |
40 | + | |
41 | + Using GDB under Emacs is just like using GDB normally except for two | |
42 | +things: | |
43 | + | |
44 | + * All "terminal" input and output goes through the Emacs buffer. | |
45 | + | |
46 | + This applies both to GDB commands and their output, and to the input | |
47 | +and output done by the program you are debugging. | |
48 | + | |
49 | + This is useful because it means that you can copy the text of | |
50 | +previous commands and input them again; you can even use parts of the | |
51 | +output in this way. | |
52 | + | |
53 | + All the facilities of Emacs' Shell mode are available for interacting | |
54 | +with your program. In particular, you can send signals the usual | |
55 | +way--for example, `C-c C-c' for an interrupt, `C-c C-z' for a stop. | |
56 | + | |
57 | + * GDB displays source code through Emacs. | |
58 | + | |
59 | + Each time GDB displays a stack frame, Emacs automatically finds the | |
60 | +source file for that frame and puts an arrow (`=>') at the left margin | |
61 | +of the current line. Emacs uses a separate buffer for source display, | |
62 | +and splits the screen to show both your GDB session and the source. | |
63 | + | |
64 | + Explicit GDB `list' or search commands still produce output as | |
65 | +usual, but you probably have no reason to use them from Emacs. | |
66 | + | |
67 | + *Warning:* If the directory where your program resides is not your | |
68 | + current directory, it can be easy to confuse Emacs about the | |
69 | + location of the source files, in which case the auxiliary display | |
70 | + buffer does not appear to show your source. GDB can find programs | |
71 | + by searching your environment's `PATH' variable, so the GDB input | |
72 | + and output session proceeds normally; but Emacs does not get | |
73 | + enough information back from GDB to locate the source files in | |
74 | + this situation. To avoid this problem, either start GDB mode from | |
75 | + the directory where your program resides, or specify an absolute | |
76 | + file name when prompted for the `M-x gdb' argument. | |
77 | + | |
78 | + A similar confusion can result if you use the GDB `file' command to | |
79 | + switch to debugging a program in some other location, from an | |
80 | + existing GDB buffer in Emacs. | |
81 | + | |
82 | + By default, `M-x gdb' calls the program called `gdb'. If you need | |
83 | +to call GDB by a different name (for example, if you keep several | |
84 | +configurations around, with different names) you can set the Emacs | |
85 | +variable `gdb-command-name'; for example, | |
86 | + | |
87 | + (setq gdb-command-name "mygdb") | |
88 | + | |
89 | +(preceded by `ESC ESC', or typed in the `*scratch*' buffer, or in your | |
90 | +`.emacs' file) makes Emacs call the program named "`mygdb'" instead. | |
91 | + | |
92 | + In the GDB I/O buffer, you can use these special Emacs commands in | |
93 | +addition to the standard Shell mode commands: | |
94 | + | |
95 | +`C-h m' | |
96 | + Describe the features of Emacs' GDB Mode. | |
97 | + | |
98 | +`M-s' | |
99 | + Execute to another source line, like the GDB `step' command; also | |
100 | + update the display window to show the current file and location. | |
101 | + | |
102 | +`M-n' | |
103 | + Execute to next source line in this function, skipping all function | |
104 | + calls, like the GDB `next' command. Then update the display window | |
105 | + to show the current file and location. | |
106 | + | |
107 | +`M-i' | |
108 | + Execute one instruction, like the GDB `stepi' command; update | |
109 | + display window accordingly. | |
110 | + | |
111 | +`M-x gdb-nexti' | |
112 | + Execute to next instruction, using the GDB `nexti' command; update | |
113 | + display window accordingly. | |
114 | + | |
115 | +`C-c C-f' | |
116 | + Execute until exit from the selected stack frame, like the GDB | |
117 | + `finish' command. | |
118 | + | |
119 | +`M-c' | |
120 | + Continue execution of your program, like the GDB `continue' | |
121 | + command. | |
122 | + | |
123 | + *Warning:* In Emacs v19, this command is `C-c C-p'. | |
124 | + | |
125 | +`M-u' | |
126 | + Go up the number of frames indicated by the numeric argument | |
127 | + (*note Numeric Arguments: (Emacs)Arguments.), like the GDB `up' | |
128 | + command. | |
129 | + | |
130 | + *Warning:* In Emacs v19, this command is `C-c C-u'. | |
131 | + | |
132 | +`M-d' | |
133 | + Go down the number of frames indicated by the numeric argument, | |
134 | + like the GDB `down' command. | |
135 | + | |
136 | + *Warning:* In Emacs v19, this command is `C-c C-d'. | |
137 | + | |
138 | +`C-x &' | |
139 | + Read the number where the cursor is positioned, and insert it at | |
140 | + the end of the GDB I/O buffer. For example, if you wish to | |
141 | + disassemble code around an address that was displayed earlier, | |
142 | + type `disassemble'; then move the cursor to the address display, | |
143 | + and pick up the argument for `disassemble' by typing `C-x &'. | |
144 | + | |
145 | + You can customize this further by defining elements of the list | |
146 | + `gdb-print-command'; once it is defined, you can format or | |
147 | + otherwise process numbers picked up by `C-x &' before they are | |
148 | + inserted. A numeric argument to `C-x &' indicates that you wish | |
149 | + special formatting, and also acts as an index to pick an element | |
150 | + of the list. If the list element is a string, the number to be | |
151 | + inserted is formatted using the Emacs function `format'; otherwise | |
152 | + the number is passed as an argument to the corresponding list | |
153 | + element. | |
154 | + | |
155 | + In any source file, the Emacs command `C-x SPC' (`gdb-break') tells | |
156 | +GDB to set a breakpoint on the source line point is on. | |
157 | + | |
158 | + If you accidentally delete the source-display buffer, an easy way to | |
159 | +get it back is to type the command `f' in the GDB buffer, to request a | |
160 | +frame display; when you run under Emacs, this recreates the source | |
161 | +buffer if necessary to show you the context of the current frame. | |
162 | + | |
163 | + The source files displayed in Emacs are in ordinary Emacs buffers | |
164 | +which are visiting the source files in the usual way. You can edit the | |
165 | +files with these buffers if you wish; but keep in mind that GDB | |
166 | +communicates with Emacs in terms of line numbers. If you add or delete | |
167 | +lines from the text, the line numbers that GDB knows cease to | |
168 | +correspond properly with the code. | |
169 | + | |
170 | + | |
171 | +File: gdb.info, Node: GDB Bugs, Next: Formatting Documentation, Prev: Emacs, Up: Top | |
172 | + | |
173 | +Reporting Bugs in GDB | |
174 | +********************* | |
175 | + | |
176 | + Your bug reports play an essential role in making GDB reliable. | |
177 | + | |
178 | + Reporting a bug may help you by bringing a solution to your problem, | |
179 | +or it may not. But in any case the principal function of a bug report | |
180 | +is to help the entire community by making the next version of GDB work | |
181 | +better. Bug reports are your contribution to the maintenance of GDB. | |
182 | + | |
183 | + In order for a bug report to serve its purpose, you must include the | |
184 | +information that enables us to fix the bug. | |
185 | + | |
186 | +* Menu: | |
187 | + | |
188 | +* Bug Criteria:: Have you found a bug? | |
189 | +* Bug Reporting:: How to report bugs | |
190 | + | |
191 | + | |
192 | +File: gdb.info, Node: Bug Criteria, Next: Bug Reporting, Prev: GDB Bugs, Up: GDB Bugs | |
193 | + | |
194 | +Have you found a bug? | |
195 | +===================== | |
196 | + | |
197 | + If you are not sure whether you have found a bug, here are some | |
198 | +guidelines: | |
199 | + | |
200 | + * If the debugger gets a fatal signal, for any input whatever, that | |
201 | + is a GDB bug. Reliable debuggers never crash. | |
202 | + | |
203 | + * If GDB produces an error message for valid input, that is a bug. | |
204 | + (Note that if you're cross debugging, the problem may also be | |
205 | + somewhere in the connection to the target.) | |
206 | + | |
207 | + * If GDB does not produce an error message for invalid input, that | |
208 | + is a bug. However, you should note that your idea of "invalid | |
209 | + input" might be our idea of "an extension" or "support for | |
210 | + traditional practice". | |
211 | + | |
212 | + * If you are an experienced user of debugging tools, your suggestions | |
213 | + for improvement of GDB are welcome in any case. | |
214 | + | |
215 | + | |
216 | +File: gdb.info, Node: Bug Reporting, Prev: Bug Criteria, Up: GDB Bugs | |
217 | + | |
218 | +How to report bugs | |
219 | +================== | |
220 | + | |
221 | + A number of companies and individuals offer support for GNU products. | |
222 | +If you obtained GDB from a support organization, we recommend you | |
223 | +contact that organization first. | |
224 | + | |
225 | + You can find contact information for many support companies and | |
226 | +individuals in the file `etc/SERVICE' in the GNU Emacs distribution. | |
227 | + | |
228 | + In any event, we also recommend that you send bug reports for GDB to | |
229 | +this addresses: | |
230 | + | |
231 | + bug-gdb@prep.ai.mit.edu | |
232 | + | |
233 | + *Do not send bug reports to `info-gdb', or to `help-gdb', or to any | |
234 | +newsgroups.* Most users of GDB do not want to receive bug reports. | |
235 | +Those that do have arranged to receive `bug-gdb'. | |
236 | + | |
237 | + The mailing list `bug-gdb' has a newsgroup `gnu.gdb.bug' which | |
238 | +serves as a repeater. The mailing list and the newsgroup carry exactly | |
239 | +the same messages. Often people think of posting bug reports to the | |
240 | +newsgroup instead of mailing them. This appears to work, but it has one | |
241 | +problem which can be crucial: a newsgroup posting often lacks a mail | |
242 | +path back to the sender. Thus, if we need to ask for more information, | |
243 | +we may be unable to reach you. For this reason, it is better to send | |
244 | +bug reports to the mailing list. | |
245 | + | |
246 | + As a last resort, send bug reports on paper to: | |
247 | + | |
248 | + GNU Debugger Bugs | |
249 | + Free Software Foundation Inc. | |
250 | + 59 Temple Place - Suite 330 | |
251 | + Boston, MA 02111-1307 | |
252 | + USA | |
253 | + | |
254 | + The fundamental principle of reporting bugs usefully is this: | |
255 | +*report all the facts*. If you are not sure whether to state a fact or | |
256 | +leave it out, state it! | |
257 | + | |
258 | + Often people omit facts because they think they know what causes the | |
259 | +problem and assume that some details do not matter. Thus, you might | |
260 | +assume that the name of the variable you use in an example does not | |
261 | +matter. Well, probably it does not, but one cannot be sure. Perhaps | |
262 | +the bug is a stray memory reference which happens to fetch from the | |
263 | +location where that name is stored in memory; perhaps, if the name were | |
264 | +different, the contents of that location would fool the debugger into | |
265 | +doing the right thing despite the bug. Play it safe and give a | |
266 | +specific, complete example. That is the easiest thing for you to do, | |
267 | +and the most helpful. | |
268 | + | |
269 | + Keep in mind that the purpose of a bug report is to enable us to fix | |
270 | +the bug. It may be that the bug has been reported previously, but | |
271 | +neither you nor we can know that unless your bug report is complete and | |
272 | +self-contained. | |
273 | + | |
274 | + Sometimes people give a few sketchy facts and ask, "Does this ring a | |
275 | +bell?" Those bug reports are useless, and we urge everyone to *refuse | |
276 | +to respond to them* except to chide the sender to report bugs properly. | |
277 | + | |
278 | + To enable us to fix the bug, you should include all these things: | |
279 | + | |
280 | + * The version of GDB. GDB announces it if you start with no | |
281 | + arguments; you can also print it at any time using `show version'. | |
282 | + | |
283 | + Without this, we will not know whether there is any point in | |
284 | + looking for the bug in the current version of GDB. | |
285 | + | |
286 | + * The type of machine you are using, and the operating system name | |
287 | + and version number. | |
288 | + | |
289 | + 1. What compiler (and its version) was used to compile GDB--e.g. | |
290 | + "gcc-2.8.1". | |
291 | + | |
292 | + * What compiler (and its version) was used to compile the program | |
293 | + you are debugging--e.g. "gcc-2.8.1", or "HP92453-01 A.10.32.03 HP | |
294 | + C Compiler". For GCC, you can say `gcc --version' to get this | |
295 | + information; for other compilers, see the documentation for those | |
296 | + compilers. | |
297 | + | |
298 | + * The command arguments you gave the compiler to compile your | |
299 | + example and observe the bug. For example, did you use `-O'? To | |
300 | + guarantee you will not omit something important, list them all. A | |
301 | + copy of the Makefile (or the output from make) is sufficient. | |
302 | + | |
303 | + If we were to try to guess the arguments, we would probably guess | |
304 | + wrong and then we might not encounter the bug. | |
305 | + | |
306 | + * A complete input script, and all necessary source files, that will | |
307 | + reproduce the bug. | |
308 | + | |
309 | + * A description of what behavior you observe that you believe is | |
310 | + incorrect. For example, "It gets a fatal signal." | |
311 | + | |
312 | + Of course, if the bug is that GDB gets a fatal signal, then we | |
313 | + will certainly notice it. But if the bug is incorrect output, we | |
314 | + might not notice unless it is glaringly wrong. You might as well | |
315 | + not give us a chance to make a mistake. | |
316 | + | |
317 | + Even if the problem you experience is a fatal signal, you should | |
318 | + still say so explicitly. Suppose something strange is going on, | |
319 | + such as, your copy of GDB is out of synch, or you have encountered | |
320 | + a bug in the C library on your system. (This has happened!) Your | |
321 | + copy might crash and ours would not. If you told us to expect a | |
322 | + crash, then when ours fails to crash, we would know that the bug | |
323 | + was not happening for us. If you had not told us to expect a | |
324 | + crash, then we would not be able to draw any conclusion from our | |
325 | + observations. | |
326 | + | |
327 | + 2. If you wish to suggest changes to the GDB source, send us context | |
328 | + diffs. If you even discuss something in the GDB source, refer to | |
329 | + it by context, not by line number. | |
330 | + | |
331 | + The line numbers in our development sources will not match those | |
332 | + in your sources. Your line numbers would convey no useful | |
333 | + information to us. | |
334 | + | |
335 | + Here are some things that are not necessary: | |
336 | + | |
337 | + * A description of the envelope of the bug. | |
338 | + | |
339 | + Often people who encounter a bug spend a lot of time investigating | |
340 | + which changes to the input file will make the bug go away and which | |
341 | + changes will not affect it. | |
342 | + | |
343 | + This is often time consuming and not very useful, because the way | |
344 | + we will find the bug is by running a single example under the | |
345 | + debugger with breakpoints, not by pure deduction from a series of | |
346 | + examples. We recommend that you save your time for something else. | |
347 | + | |
348 | + Of course, if you can find a simpler example to report *instead* | |
349 | + of the original one, that is a convenience for us. Errors in the | |
350 | + output will be easier to spot, running under the debugger will take | |
351 | + less time, and so on. | |
352 | + | |
353 | + However, simplification is not vital; if you do not want to do | |
354 | + this, report the bug anyway and send us the entire test case you | |
355 | + used. | |
356 | + | |
357 | + * A patch for the bug. | |
358 | + | |
359 | + A patch for the bug does help us if it is a good one. But do not | |
360 | + omit the necessary information, such as the test case, on the | |
361 | + assumption that a patch is all we need. We might see problems | |
362 | + with your patch and decide to fix the problem another way, or we | |
363 | + might not understand it at all. | |
364 | + | |
365 | + Sometimes with a program as complicated as GDB it is very hard to | |
366 | + construct an example that will make the program follow a certain | |
367 | + path through the code. If you do not send us the example, we will | |
368 | + not be able to construct one, so we will not be able to verify | |
369 | + that the bug is fixed. | |
370 | + | |
371 | + And if we cannot understand what bug you are trying to fix, or why | |
372 | + your patch should be an improvement, we will not install it. A | |
373 | + test case will help us to understand. | |
374 | + | |
375 | + * A guess about what the bug is or what it depends on. | |
376 | + | |
377 | + Such guesses are usually wrong. Even we cannot guess right about | |
378 | + such things without first using the debugger to find the facts. | |
379 | + | |
380 | + | |
381 | +File: gdb.info, Node: Command Line Editing, Next: Using History Interactively, Prev: Formatting Documentation, Up: Top | |
382 | + | |
383 | +Command Line Editing | |
384 | +******************** | |
385 | + | |
386 | + This chapter describes the basic features of the GNU command line | |
387 | +editing interface. | |
388 | + | |
389 | +* Menu: | |
390 | + | |
391 | +* Introduction and Notation:: Notation used in this text. | |
392 | +* Readline Interaction:: The minimum set of commands for editing a line. | |
393 | +* Readline Init File:: Customizing Readline from a user's view. | |
394 | +* Bindable Readline Commands:: A description of most of the Readline commands | |
395 | + available for binding | |
396 | +* Readline vi Mode:: A short description of how to make Readline | |
397 | + behave like the vi editor. | |
398 | + | |
399 | + | |
400 | +File: gdb.info, Node: Introduction and Notation, Next: Readline Interaction, Up: Command Line Editing | |
401 | + | |
402 | +Introduction to Line Editing | |
403 | +============================ | |
404 | + | |
405 | + The following paragraphs describe the notation used to represent | |
406 | +keystrokes. | |
407 | + | |
408 | + The text <C-k> is read as `Control-K' and describes the character | |
409 | +produced when the <k> key is pressed while the Control key is depressed. | |
410 | + | |
411 | + The text <M-k> is read as `Meta-K' and describes the character | |
412 | +produced when the meta key (if you have one) is depressed, and the <k> | |
413 | +key is pressed. If you do not have a meta key, the identical keystroke | |
414 | +can be generated by typing <ESC> first, and then typing <k>. Either | |
415 | +process is known as "metafying" the <k> key. | |
416 | + | |
417 | + The text <M-C-k> is read as `Meta-Control-k' and describes the | |
418 | +character produced by "metafying" <C-k>. | |
419 | + | |
420 | + In addition, several keys have their own names. Specifically, | |
421 | +<DEL>, <ESC>, <LFD>, <SPC>, <RET>, and <TAB> all stand for themselves | |
422 | +when seen in this text, or in an init file (*note Readline Init | |
423 | +File::.). | |
424 | + | |
425 | + | |
426 | +File: gdb.info, Node: Readline Interaction, Next: Readline Init File, Prev: Introduction and Notation, Up: Command Line Editing | |
427 | + | |
428 | +Readline Interaction | |
429 | +==================== | |
430 | + | |
431 | + Often during an interactive session you type in a long line of text, | |
432 | +only to notice that the first word on the line is misspelled. The | |
433 | +Readline library gives you a set of commands for manipulating the text | |
434 | +as you type it in, allowing you to just fix your typo, and not forcing | |
435 | +you to retype the majority of the line. Using these editing commands, | |
436 | +you move the cursor to the place that needs correction, and delete or | |
437 | +insert the text of the corrections. Then, when you are satisfied with | |
438 | +the line, you simply press <RETURN>. You do not have to be at the end | |
439 | +of the line to press <RETURN>; the entire line is accepted regardless | |
440 | +of the location of the cursor within the line. | |
441 | + | |
442 | +* Menu: | |
443 | + | |
444 | +* Readline Bare Essentials:: The least you need to know about Readline. | |
445 | +* Readline Movement Commands:: Moving about the input line. | |
446 | +* Readline Killing Commands:: How to delete text, and how to get it back! | |
447 | +* Readline Arguments:: Giving numeric arguments to commands. | |
448 | +* Searching:: Searching through previous lines. | |
449 | + | |
450 | + | |
451 | +File: gdb.info, Node: Readline Bare Essentials, Next: Readline Movement Commands, Up: Readline Interaction | |
452 | + | |
453 | +Readline Bare Essentials | |
454 | +------------------------ | |
455 | + | |
456 | + In order to enter characters into the line, simply type them. The | |
457 | +typed character appears where the cursor was, and then the cursor moves | |
458 | +one space to the right. If you mistype a character, you can use your | |
459 | +erase character to back up and delete the mistyped character. | |
460 | + | |
461 | + Sometimes you may miss typing a character that you wanted to type, | |
462 | +and not notice your error until you have typed several other | |
463 | +characters. In that case, you can type <C-b> to move the cursor to the | |
464 | +left, and then correct your mistake. Afterwards, you can move the | |
465 | +cursor to the right with <C-f>. | |
466 | + | |
467 | + When you add text in the middle of a line, you will notice that | |
468 | +characters to the right of the cursor are `pushed over' to make room | |
469 | +for the text that you have inserted. Likewise, when you delete text | |
470 | +behind the cursor, characters to the right of the cursor are `pulled | |
471 | +back' to fill in the blank space created by the removal of the text. A | |
472 | +list of the basic bare essentials for editing the text of an input line | |
473 | +follows. | |
474 | + | |
475 | +<C-b> | |
476 | + Move back one character. | |
477 | + | |
478 | +<C-f> | |
479 | + Move forward one character. | |
480 | + | |
481 | +<DEL> | |
482 | + Delete the character to the left of the cursor. | |
483 | + | |
484 | +<C-d> | |
485 | + Delete the character underneath the cursor. | |
486 | + | |
487 | +Printing characters | |
488 | + Insert the character into the line at the cursor. | |
489 | + | |
490 | +<C-_> | |
491 | + Undo the last editing command. You can undo all the way back to an | |
492 | + empty line. | |
493 | + | |
494 | + | |
495 | +File: gdb.info, Node: Readline Movement Commands, Next: Readline Killing Commands, Prev: Readline Bare Essentials, Up: Readline Interaction | |
496 | + | |
497 | +Readline Movement Commands | |
498 | +-------------------------- | |
499 | + | |
500 | + The above table describes the most basic possible keystrokes that | |
501 | +you need in order to do editing of the input line. For your | |
502 | +convenience, many other commands have been added in addition to <C-b>, | |
503 | +<C-f>, <C-d>, and <DEL>. Here are some commands for moving more rapidly | |
504 | +about the line. | |
505 | + | |
506 | +<C-a> | |
507 | + Move to the start of the line. | |
508 | + | |
509 | +<C-e> | |
510 | + Move to the end of the line. | |
511 | + | |
512 | +<M-f> | |
513 | + Move forward a word, where a word is composed of letters and | |
514 | + digits. | |
515 | + | |
516 | +<M-b> | |
517 | + Move backward a word. | |
518 | + | |
519 | +<C-l> | |
520 | + Clear the screen, reprinting the current line at the top. | |
521 | + | |
522 | + Notice how <C-f> moves forward a character, while <M-f> moves | |
523 | +forward a word. It is a loose convention that control keystrokes | |
524 | +operate on characters while meta keystrokes operate on words. | |
525 | + | |
526 | + | |
527 | +File: gdb.info, Node: Readline Killing Commands, Next: Readline Arguments, Prev: Readline Movement Commands, Up: Readline Interaction | |
528 | + | |
529 | +Readline Killing Commands | |
530 | +------------------------- | |
531 | + | |
532 | + "Killing" text means to delete the text from the line, but to save | |
533 | +it away for later use, usually by "yanking" (re-inserting) it back into | |
534 | +the line. If the description for a command says that it `kills' text, | |
535 | +then you can be sure that you can get the text back in a different (or | |
536 | +the same) place later. | |
537 | + | |
538 | + When you use a kill command, the text is saved in a "kill-ring". | |
539 | +Any number of consecutive kills save all of the killed text together, so | |
540 | +that when you yank it back, you get it all. The kill ring is not line | |
541 | +specific; the text that you killed on a previously typed line is | |
542 | +available to be yanked back later, when you are typing another line. | |
543 | + | |
544 | + Here is the list of commands for killing text. | |
545 | + | |
546 | +<C-k> | |
547 | + Kill the text from the current cursor position to the end of the | |
548 | + line. | |
549 | + | |
550 | +<M-d> | |
551 | + Kill from the cursor to the end of the current word, or if between | |
552 | + words, to the end of the next word. | |
553 | + | |
554 | +<M-DEL> | |
555 | + Kill from the cursor the start of the previous word, or if between | |
556 | + words, to the start of the previous word. | |
557 | + | |
558 | +<C-w> | |
559 | + Kill from the cursor to the previous whitespace. This is | |
560 | + different than <M-DEL> because the word boundaries differ. | |
561 | + | |
562 | + Here is how to "yank" the text back into the line. Yanking means to | |
563 | +copy the most-recently-killed text from the kill buffer. | |
564 | + | |
565 | +<C-y> | |
566 | + Yank the most recently killed text back into the buffer at the | |
567 | + cursor. | |
568 | + | |
569 | +<M-y> | |
570 | + Rotate the kill-ring, and yank the new top. You can only do this | |
571 | + if the prior command is <C-y> or <M-y>. | |
572 | + | |
573 | + | |
574 | +File: gdb.info, Node: Readline Arguments, Next: Searching, Prev: Readline Killing Commands, Up: Readline Interaction | |
575 | + | |
576 | +Readline Arguments | |
577 | +------------------ | |
578 | + | |
579 | + You can pass numeric arguments to Readline commands. Sometimes the | |
580 | +argument acts as a repeat count, other times it is the sign of the | |
581 | +argument that is significant. If you pass a negative argument to a | |
582 | +command which normally acts in a forward direction, that command will | |
583 | +act in a backward direction. For example, to kill text back to the | |
584 | +start of the line, you might type `M-- C-k'. | |
585 | + | |
586 | + The general way to pass numeric arguments to a command is to type | |
587 | +meta digits before the command. If the first `digit' typed is a minus | |
588 | +sign (<->), then the sign of the argument will be negative. Once you | |
589 | +have typed one meta digit to get the argument started, you can type the | |
590 | +remainder of the digits, and then the command. For example, to give | |
591 | +the <C-d> command an argument of 10, you could type `M-1 0 C-d'. | |
592 | + | |
593 | + | |
594 | +File: gdb.info, Node: Searching, Prev: Readline Arguments, Up: Readline Interaction | |
595 | + | |
596 | +Searching for Commands in the History | |
597 | +------------------------------------- | |
598 | + | |
599 | + Readline provides commands for searching through the command history | |
600 | +for lines containing a specified string. There are two search modes: | |
601 | +INCREMENTAL and NON-INCREMENTAL. | |
602 | + | |
603 | + Incremental searches begin before the user has finished typing the | |
604 | +search string. As each character of the search string is typed, | |
605 | +Readline displays the next entry from the history matching the string | |
606 | +typed so far. An incremental search requires only as many characters | |
607 | +as needed to find the desired history entry. The <ESC> character is | |
608 | +used to terminate an incremental search. <C-j> will also terminate the | |
609 | +search. <C-g> will abort an incremental search and restore the | |
610 | +original line. When the search is terminated, the history entry | |
611 | +containing the search string becomes the current line. To find other | |
612 | +matching entries in the history list, type <C-s> or <C-r> as | |
613 | +appropriate. This will search backward or forward in the history for | |
614 | +the next entry matching the search string typed so far. Any other key | |
615 | +sequence bound to a Readline command will terminate the search and | |
616 | +execute that command. For instance, a <RET> will terminate the search | |
617 | +and accept the line, thereby executing the command from the history | |
618 | +list. | |
619 | + | |
620 | + Non-incremental searches read the entire search string before | |
621 | +starting to search for matching history lines. The search string may be | |
622 | +typed by the user or be part of the contents of the current line. | |
623 | + | |
624 | + | |
625 | +File: gdb.info, Node: Readline Init File, Next: Bindable Readline Commands, Prev: Readline Interaction, Up: Command Line Editing | |
626 | + | |
627 | +Readline Init File | |
628 | +================== | |
629 | + | |
630 | + Although the Readline library comes with a set of `emacs'-like | |
631 | +keybindings installed by default, it is possible to use a different set | |
632 | +of keybindings. Any user can customize programs that use Readline by | |
633 | +putting commands in an "inputrc" file in his home directory. The name | |
634 | +of this file is taken from the value of the environment variable | |
635 | +`INPUTRC'. If that variable is unset, the default is `~/.inputrc'. | |
636 | + | |
637 | + When a program which uses the Readline library starts up, the init | |
638 | +file is read, and the key bindings are set. | |
639 | + | |
640 | + In addition, the `C-x C-r' command re-reads this init file, thus | |
641 | +incorporating any changes that you might have made to it. | |
642 | + | |
643 | +* Menu: | |
644 | + | |
645 | +* Readline Init File Syntax:: Syntax for the commands in the inputrc file. | |
646 | + | |
647 | +* Conditional Init Constructs:: Conditional key bindings in the inputrc file. | |
648 | + | |
649 | +* Sample Init File:: An example inputrc file. | |
650 | + | |
651 | + | |
652 | +File: gdb.info, Node: Readline Init File Syntax, Next: Conditional Init Constructs, Up: Readline Init File | |
653 | + | |
654 | +Readline Init File Syntax | |
655 | +------------------------- | |
656 | + | |
657 | + There are only a few basic constructs allowed in the Readline init | |
658 | +file. Blank lines are ignored. Lines beginning with a `#' are | |
659 | +comments. Lines beginning with a `$' indicate conditional constructs | |
660 | +(*note Conditional Init Constructs::.). Other lines denote variable | |
661 | +settings and key bindings. | |
662 | + | |
663 | +Variable Settings | |
664 | + You can modify the run-time behavior of Readline by altering the | |
665 | + values of variables in Readline using the `set' command within the | |
666 | + init file. Here is how to change from the default Emacs-like key | |
667 | + binding to use `vi' line editing commands: | |
668 | + | |
669 | + set editing-mode vi | |
670 | + | |
671 | + A great deal of run-time behavior is changeable with the following | |
672 | + variables. | |
673 | + | |
674 | + `bell-style' | |
675 | + Controls what happens when Readline wants to ring the | |
676 | + terminal bell. If set to `none', Readline never rings the | |
677 | + bell. If set to `visible', Readline uses a visible bell if | |
678 | + one is available. If set to `audible' (the default), | |
679 | + Readline attempts to ring the terminal's bell. | |
680 | + | |
681 | + `comment-begin' | |
682 | + The string to insert at the beginning of the line when the | |
683 | + `insert-comment' command is executed. The default value is | |
684 | + `"#"'. | |
685 | + | |
686 | + `completion-ignore-case' | |
687 | + If set to `on', Readline performs filename matching and | |
688 | + completion in a case-insensitive fashion. The default value | |
689 | + is `off'. | |
690 | + | |
691 | + `completion-query-items' | |
692 | + The number of possible completions that determines when the | |
693 | + user is asked whether he wants to see the list of | |
694 | + possibilities. If the number of possible completions is | |
695 | + greater than this value, Readline will ask the user whether | |
696 | + or not he wishes to view them; otherwise, they are simply | |
697 | + listed. The default limit is `100'. | |
698 | + | |
699 | + `convert-meta' | |
700 | + If set to `on', Readline will convert characters with the | |
701 | + eighth bit set to an ASCII key sequence by stripping the | |
702 | + eighth bit and prepending an <ESC> character, converting them | |
703 | + to a meta-prefixed key sequence. The default value is `on'. | |
704 | + | |
705 | + `disable-completion' | |
706 | + If set to `On', Readline will inhibit word completion. | |
707 | + Completion characters will be inserted into the line as if | |
708 | + they had been mapped to `self-insert'. The default is `off'. | |
709 | + | |
710 | + `editing-mode' | |
711 | + The `editing-mode' variable controls which default set of key | |
712 | + bindings is used. By default, Readline starts up in Emacs | |
713 | + editing mode, where the keystrokes are most similar to Emacs. | |
714 | + This variable can be set to either `emacs' or `vi'. | |
715 | + | |
716 | + `enable-keypad' | |
717 | + When set to `on', Readline will try to enable the application | |
718 | + keypad when it is called. Some systems need this to enable | |
719 | + the arrow keys. The default is `off'. | |
720 | + | |
721 | + `expand-tilde' | |
722 | + If set to `on', tilde expansion is performed when Readline | |
723 | + attempts word completion. The default is `off'. | |
724 | + | |
725 | + `horizontal-scroll-mode' | |
726 | + This variable can be set to either `on' or `off'. Setting it | |
727 | + to `on' means that the text of the lines being edited will | |
728 | + scroll horizontally on a single screen line when they are | |
729 | + longer than the width of the screen, instead of wrapping onto | |
730 | + a new screen line. By default, this variable is set to `off'. | |
731 | + | |
732 | + `keymap' | |
733 | + Sets Readline's idea of the current keymap for key binding | |
734 | + commands. Acceptable `keymap' names are `emacs', | |
735 | + `emacs-standard', `emacs-meta', `emacs-ctlx', `vi', | |
736 | + `vi-command', and `vi-insert'. `vi' is equivalent to | |
737 | + `vi-command'; `emacs' is equivalent to `emacs-standard'. The | |
738 | + default value is `emacs'. The value of the `editing-mode' | |
739 | + variable also affects the default keymap. | |
740 | + | |
741 | + `mark-directories' | |
742 | + If set to `on', completed directory names have a slash | |
743 | + appended. The default is `on'. | |
744 | + | |
745 | + `mark-modified-lines' | |
746 | + This variable, when set to `on', causes Readline to display an | |
747 | + asterisk (`*') at the start of history lines which have been | |
748 | + modified. This variable is `off' by default. | |
749 | + | |
750 | + `input-meta' | |
751 | + If set to `on', Readline will enable eight-bit input (it will | |
752 | + not strip the eighth bit from the characters it reads), | |
753 | + regardless of what the terminal claims it can support. The | |
754 | + default value is `off'. The name `meta-flag' is a synonym | |
755 | + for this variable. | |
756 | + | |
757 | + `output-meta' | |
758 | + If set to `on', Readline will display characters with the | |
759 | + eighth bit set directly rather than as a meta-prefixed escape | |
760 | + sequence. The default is `off'. | |
761 | + | |
762 | + `print-completions-horizontally' | |
763 | + If set to `on', Readline will display completions with matches | |
764 | + sorted horizontally in alphabetical order, rather than down | |
765 | + the screen. The default is `off'. | |
766 | + | |
767 | + `show-all-if-ambiguous' | |
768 | + This alters the default behavior of the completion functions. | |
769 | + If set to `on', words which have more than one possible | |
770 | + completion cause the matches to be listed immediately instead | |
771 | + of ringing the bell. The default value is `off'. | |
772 | + | |
773 | + `visible-stats' | |
774 | + If set to `on', a character denoting a file's type is | |
775 | + appended to the filename when listing possible completions. | |
776 | + The default is `off'. | |
777 | + | |
778 | +Key Bindings | |
779 | + The syntax for controlling key bindings in the init file is | |
780 | + simple. First you have to know the name of the command that you | |
781 | + want to change. The following sections contain tables of the | |
782 | + command name, the default keybinding, if any, and a short | |
783 | + description of what the command does. | |
784 | + | |
785 | + Once you know the name of the command, simply place the name of | |
786 | + the key you wish to bind the command to, a colon, and then the | |
787 | + name of the command on a line in the init file. The name of the | |
788 | + key can be expressed in different ways, depending on which is most | |
789 | + comfortable for you. | |
790 | + | |
791 | + KEYNAME: FUNCTION-NAME or MACRO | |
792 | + KEYNAME is the name of a key spelled out in English. For | |
793 | + example: | |
794 | + Control-u: universal-argument | |
795 | + Meta-Rubout: backward-kill-word | |
796 | + Control-o: "> output" | |
797 | + | |
798 | + In the above example, <C-u> is bound to the function | |
799 | + `universal-argument', and <C-o> is bound to run the macro | |
800 | + expressed on the right hand side (that is, to insert the text | |
801 | + `> output' into the line). | |
802 | + | |
803 | + "KEYSEQ": FUNCTION-NAME or MACRO | |
804 | + KEYSEQ differs from KEYNAME above in that strings denoting an | |
805 | + entire key sequence can be specified, by placing the key | |
806 | + sequence in double quotes. Some GNU Emacs style key escapes | |
807 | + can be used, as in the following example, but the special | |
808 | + character names are not recognized. | |
809 | + | |
810 | + "\C-u": universal-argument | |
811 | + "\C-x\C-r": re-read-init-file | |
812 | + "\e[11~": "Function Key 1" | |
813 | + | |
814 | + In the above example, <C-u> is bound to the function | |
815 | + `universal-argument' (just as it was in the first example), | |
816 | + `<C-x> <C-r>' is bound to the function `re-read-init-file', | |
817 | + and `<ESC> <[> <1> <1> <~>' is bound to insert the text | |
818 | + `Function Key 1'. | |
819 | + | |
820 | + The following GNU Emacs style escape sequences are available when | |
821 | + specifying key sequences: | |
822 | + | |
823 | + `\C-' | |
824 | + control prefix | |
825 | + | |
826 | + `\M-' | |
827 | + meta prefix | |
828 | + | |
829 | + `\e' | |
830 | + an escape character | |
831 | + | |
832 | + `\\' | |
833 | + backslash | |
834 | + | |
835 | + `\"' | |
836 | + <"> | |
837 | + | |
838 | + `\'' | |
839 | + <'> | |
840 | + | |
841 | + In addition to the GNU Emacs style escape sequences, a second set | |
842 | + of backslash escapes is available: | |
843 | + | |
844 | + `\a' | |
845 | + alert (bell) | |
846 | + | |
847 | + `\b' | |
848 | + backspace | |
849 | + | |
850 | + `\d' | |
851 | + delete | |
852 | + | |
853 | + `\f' | |
854 | + form feed | |
855 | + | |
856 | + `\n' | |
857 | + newline | |
858 | + | |
859 | + `\r' | |
860 | + carriage return | |
861 | + | |
862 | + `\t' | |
863 | + horizontal tab | |
864 | + | |
865 | + `\v' | |
866 | + vertical tab | |
867 | + | |
868 | + `\NNN' | |
869 | + the character whose ASCII code is the octal value NNN (one to | |
870 | + three digits) | |
871 | + | |
872 | + `\xNNN' | |
873 | + the character whose ASCII code is the hexadecimal value NNN | |
874 | + (one to three digits) | |
875 | + | |
876 | + When entering the text of a macro, single or double quotes must be | |
877 | + used to indicate a macro definition. Unquoted text is assumed to | |
878 | + be a function name. In the macro body, the backslash escapes | |
879 | + described above are expanded. Backslash will quote any other | |
880 | + character in the macro text, including `"' and `''. For example, | |
881 | + the following binding will make `C-x \' insert a single `\' into | |
882 | + the line: | |
883 | + "\C-x\\": "\\" | |
884 | + | |
885 | + | |
886 | +File: gdb.info, Node: Conditional Init Constructs, Next: Sample Init File, Prev: Readline Init File Syntax, Up: Readline Init File | |
887 | + | |
888 | +Conditional Init Constructs | |
889 | +--------------------------- | |
890 | + | |
891 | + Readline implements a facility similar in spirit to the conditional | |
892 | +compilation features of the C preprocessor which allows key bindings | |
893 | +and variable settings to be performed as the result of tests. There | |
894 | +are four parser directives used. | |
895 | + | |
896 | +`$if' | |
897 | + The `$if' construct allows bindings to be made based on the | |
898 | + editing mode, the terminal being used, or the application using | |
899 | + Readline. The text of the test extends to the end of the line; no | |
900 | + characters are required to isolate it. | |
901 | + | |
902 | + `mode' | |
903 | + The `mode=' form of the `$if' directive is used to test | |
904 | + whether Readline is in `emacs' or `vi' mode. This may be | |
905 | + used in conjunction with the `set keymap' command, for | |
906 | + instance, to set bindings in the `emacs-standard' and | |
907 | + `emacs-ctlx' keymaps only if Readline is starting out in | |
908 | + `emacs' mode. | |
909 | + | |
910 | + `term' | |
911 | + The `term=' form may be used to include terminal-specific key | |
912 | + bindings, perhaps to bind the key sequences output by the | |
913 | + terminal's function keys. The word on the right side of the | |
914 | + `=' is tested against both the full name of the terminal and | |
915 | + the portion of the terminal name before the first `-'. This | |
916 | + allows `sun' to match both `sun' and `sun-cmd', for instance. | |
917 | + | |
918 | + `application' | |
919 | + The APPLICATION construct is used to include | |
920 | + application-specific settings. Each program using the | |
921 | + Readline library sets the APPLICATION NAME, and you can test | |
922 | + for it. This could be used to bind key sequences to | |
923 | + functions useful for a specific program. For instance, the | |
924 | + following command adds a key sequence that quotes the current | |
925 | + or previous word in Bash: | |
926 | + $if Bash | |
927 | + # Quote the current or previous word | |
928 | + "\C-xq": "\eb\"\ef\"" | |
929 | + $endif | |
930 | + | |
931 | +`$endif' | |
932 | + This command, as seen in the previous example, terminates an `$if' | |
933 | + command. | |
934 | + | |
935 | +`$else' | |
936 | + Commands in this branch of the `$if' directive are executed if the | |
937 | + test fails. | |
938 | + | |
939 | +`$include' | |
940 | + This directive take |
Part of diff was cut off due to size limit. Use your local client to view the full diff.