]>
Commit | Line | Data |
---|---|---|
78c1db5e JB |
1 | From gdb-patches-return-33876-listarch-gdb-patches=sources dot redhat dot com at sources dot redhat dot com Wed Jun 16 08:34:43 2004 |
2 | Return-Path: <gdb-patches-return-33876-listarch-gdb-patches=sources dot redhat dot com at sources dot redhat dot com> | |
3 | Delivered-To: listarch-gdb-patches at sources dot redhat dot com | |
4 | Received: (qmail 1499 invoked by alias); 16 Jun 2004 08:34:41 -0000 | |
5 | Mailing-List: contact gdb-patches-help at sources dot redhat dot com; run by ezmlm | |
6 | Precedence: bulk | |
7 | List-Subscribe: <mailto:gdb-patches-subscribe at sources dot redhat dot com> | |
8 | List-Archive: <http://sources.redhat.com/ml/gdb-patches/> | |
9 | List-Post: <mailto:gdb-patches at sources dot redhat dot com> | |
10 | List-Help: <mailto:gdb-patches-help at sources dot redhat dot com>, <http://sources dot redhat dot com/ml/#faqs> | |
11 | Sender: gdb-patches-owner at sources dot redhat dot com | |
12 | Delivered-To: mailing list gdb-patches at sources dot redhat dot com | |
13 | Received: (qmail 1426 invoked from network); 16 Jun 2004 08:34:24 -0000 | |
14 | Received: from unknown (HELO nile.gnat.com) (205.232.38.5) | |
15 | by sourceware dot org with SMTP; 16 Jun 2004 08:34:24 -0000 | |
16 | Received: from localhost (localhost [127.0.0.1]) | |
17 | by nile dot gnat dot com (Postfix) with ESMTP id B2980F281F | |
18 | for <gdb-patches at sources dot redhat dot com>; Wed, 16 Jun 2004 04:34:23 -0400 (EDT) | |
19 | Received: from nile.gnat.com ([127.0.0.1]) | |
20 | by localhost (nile dot gnat dot com [127 dot 0 dot 0 dot 1]) (amavisd-new, port 10024) with LMTP | |
21 | id 22648-01-4 for <gdb-patches at sources dot redhat dot com>; | |
22 | Wed, 16 Jun 2004 04:34:22 -0400 (EDT) | |
23 | Received: by nile.gnat.com (Postfix, from userid 1345) | |
24 | id C3B5CF2C03; Wed, 16 Jun 2004 04:34:22 -0400 (EDT) | |
25 | From: Paul Hilfinger <hilfingr at gnat dot com> | |
26 | To: gdb-patches at sources dot redhat dot com | |
27 | Cc: | |
28 | In-reply-to: <vt2aczd8aah dot fsf at zenia dot home> (message from Jim Blandy on 09 Jun | |
29 | 2004 02:23:18 -0500) | |
30 | Subject: [PATCH]: Further updates to ada-* files | |
31 | References: <20040608090758.C59CAF2940@nile.gnat.com> <vt2aczd8aah.fsf@zenia.home> | |
32 | Message-Id: <20040616083422.C3B5CF2C03@nile.gnat.com> | |
33 | Date: Wed, 16 Jun 2004 04:34:22 -0400 (EDT) | |
34 | X-Virus-Scanned: by amavisd-new at nile.gnat.com | |
35 | ||
36 | ||
37 | I have committed the following patch to some Ada files, first to keep | |
38 | up-to-date with ACT's sources, and second to conditionalize out a | |
39 | bunch of source code that we are not yet using in the public version | |
40 | for the benefit of reviewers. | |
41 | ||
42 | Paul Hilfinger | |
43 | ACT, Inc. | |
44 | ||
45 | ||
46 | 2004-06-16 Paul N. Hilfinger <Hilfinger@gnat.com> | |
47 | ||
48 | * ada-tasks.c: Rename build_task_list to ada_build_task_list, and | |
49 | make it non-static. | |
50 | * ada-lang.h (task_control_block): declaration moved from ada-task.c | |
51 | to ada-lang.h; this is needed to be able to implement the kill command | |
52 | in multi-task mode. | |
53 | (task_ptid): Ditto. | |
54 | (task_entry): Ditto. | |
55 | (task_list): Ditto. | |
56 | (ada_build_task_list): Ditto. | |
57 | ||
58 | * ada-lang.c: Conditionalize routines and data structures related | |
59 | to breakpoints, exceptions, completion, and symbol caching on | |
60 | GNAT_GDB, since these are not yet used in the submitted public sources. | |
61 | (ada_main_name): Editorial: Move definition out of exception-related | |
62 | code. | |
63 | ||
64 | ||
65 | ||
66 | ||
67 | Index: gdb/ada-lang.c | |
68 | =================================================================== | |
69 | RCS file: /cvs/src/src/gdb/ada-lang.c,v | |
70 | retrieving revision 1.37 | |
71 | diff -u -p -r1.37 ada-lang.c | |
72 | --- gdb/ada-lang.c 8 Jun 2004 08:42:03 -0000 1.37 | |
73 | +++ gdb/ada-lang.c 16 Jun 2004 08:10:22 -0000 | |
74 | @@ -18,6 +18,19 @@ You should have received a copy of the G | |
75 | along with this program; if not, write to the Free Software | |
76 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
77 | ||
78 | + | |
79 | +/* Sections of code marked | |
80 | + | |
81 | + #ifdef GNAT_GDB | |
82 | + ... | |
83 | + #endif | |
84 | + | |
85 | + indicate sections that are used in sources distributed by | |
86 | + ACT, Inc., but not yet integrated into the public tree (where | |
87 | + GNAT_GDB is not defined). They are retained here nevertheless | |
88 | + to minimize the problems of maintaining different versions | |
89 | + of the source and to make the full source available. */ | |
90 | + | |
91 | #include "defs.h" | |
92 | #include <stdio.h> | |
93 | #include "gdb_string.h" | |
94 | @@ -62,6 +75,7 @@ Foundation, Inc., 675 Mass Ave, Cambridg | |
95 | #define TRUNCATION_TOWARDS_ZERO ((-5 / 2) == -2) | |
96 | #endif | |
97 | ||
98 | +#ifdef GNAT_GDB | |
99 | /* A structure that contains a vector of strings. | |
100 | The main purpose of this type is to group the vector and its | |
101 | associated parameters in one structure. This makes it easier | |
102 | @@ -76,6 +90,7 @@ struct string_vector | |
103 | ||
104 | static struct string_vector xnew_string_vector (int initial_size); | |
105 | static void string_vector_append (struct string_vector *sv, char *str); | |
106 | +#endif /* GNAT_GDB */ | |
107 | ||
108 | static const char *ada_unqualified_name (const char *decoded_name); | |
109 | static char *add_angle_brackets (const char *str); | |
110 | @@ -332,6 +347,8 @@ static struct obstack symbol_list_obstac | |
111 | ||
112 | /* Utilities */ | |
113 | ||
114 | +#ifdef GNAT_GDB | |
115 | + | |
116 | /* Create a new empty string_vector struct with an initial size of | |
117 | INITIAL_SIZE. */ | |
118 | ||
119 | @@ -392,6 +409,8 @@ add_angle_brackets (const char *str) | |
120 | return result; | |
121 | } | |
122 | ||
123 | +#endif /* GNAT_GDB */ | |
124 | + | |
125 | static char * | |
126 | ada_get_gdb_completer_word_break_characters (void) | |
127 | { | |
128 | @@ -705,6 +724,37 @@ ada_update_initial_language (enum langua | |
129 | ||
130 | return lang; | |
131 | } | |
132 | + | |
133 | +/* If the main procedure is written in Ada, then return its name. | |
134 | + The result is good until the next call. Return NULL if the main | |
135 | + procedure doesn't appear to be in Ada. */ | |
136 | + | |
137 | +char * | |
138 | +ada_main_name (void) | |
139 | +{ | |
140 | + struct minimal_symbol *msym; | |
141 | + CORE_ADDR main_program_name_addr; | |
142 | + static char main_program_name[1024]; | |
143 | + /* For Ada, the name of the main procedure is stored in a specific | |
144 | + string constant, generated by the binder. Look for that symbol, | |
145 | + extract its address, and then read that string. If we didn't find | |
146 | + that string, then most probably the main procedure is not written | |
147 | + in Ada. */ | |
148 | + msym = lookup_minimal_symbol (ADA_MAIN_PROGRAM_SYMBOL_NAME, NULL, NULL); | |
149 | + | |
150 | + if (msym != NULL) | |
151 | + { | |
152 | + main_program_name_addr = SYMBOL_VALUE_ADDRESS (msym); | |
153 | + if (main_program_name_addr == 0) | |
154 | + error ("Invalid address for Ada main program name."); | |
155 | + | |
156 | + extract_string (main_program_name_addr, main_program_name); | |
157 | + return main_program_name; | |
158 | + } | |
159 | + | |
160 | + /* The main procedure doesn't seem to be in Ada. */ | |
161 | + return NULL; | |
162 | +} | |
163 | \f | |
164 | /* Symbols */ | |
165 | ||
166 | @@ -3597,6 +3647,13 @@ ada_convert_actuals (struct value *func, | |
167 | \f | |
168 | /* Experimental Symbol Cache Module */ | |
169 | ||
170 | +/* This module may well have been OBE, due to improvements in the | |
171 | + symbol-table module. So until proven otherwise, it is disabled in | |
172 | + the submitted public code, and may be removed from all sources | |
173 | + in the future. */ | |
174 | + | |
175 | +#ifdef GNAT_GDB | |
176 | + | |
177 | /* This section implements a simple, fixed-sized hash table for those | |
178 | Ada-mode symbols that get looked up in the course of executing the user's | |
179 | commands. The size is fixed on the grounds that there are not | |
180 | @@ -3686,6 +3743,22 @@ cache_symbol (const char *name, domain_e | |
181 | e->symtab = symtab; | |
182 | e->block = block; | |
183 | } | |
184 | + | |
185 | +#else | |
186 | +static int | |
187 | +lookup_cached_symbol (const char *name, domain_enum namespace, | |
188 | + struct symbol **sym, struct block **block, | |
189 | + struct symtab **symtab) | |
190 | +{ | |
191 | + return 0; | |
192 | +} | |
193 | + | |
194 | +static void | |
195 | +cache_symbol (const char *name, domain_enum namespace, struct symbol *sym, | |
196 | + struct block *block, struct symtab *symtab) | |
197 | +{ | |
198 | +} | |
199 | +#endif /* GNAT_GDB */ | |
200 | \f | |
201 | /* Symbol Lookup */ | |
202 | ||
203 | @@ -3841,817 +3914,530 @@ defns_collected (struct obstack *obstack | |
204 | return (struct ada_symbol_info *) obstack_base (obstackp); | |
205 | } | |
206 | ||
207 | -/* If SYM_NAME is a completion candidate for TEXT, return this symbol | |
208 | - name in a form that's appropriate for the completion. The result | |
209 | - does not need to be deallocated, but is only good until the next call. | |
210 | - | |
211 | - TEXT_LEN is equal to the length of TEXT. | |
212 | - Perform a wild match if WILD_MATCH is set. | |
213 | - ENCODED should be set if TEXT represents the start of a symbol name | |
214 | - in its encoded form. */ | |
215 | +/* Look, in partial_symtab PST, for symbol NAME in given namespace. | |
216 | + Check the global symbols if GLOBAL, the static symbols if not. | |
217 | + Do wild-card match if WILD. */ | |
218 | ||
219 | -static const char * | |
220 | -symbol_completion_match (const char *sym_name, | |
221 | - const char *text, int text_len, | |
222 | - int wild_match, int encoded) | |
223 | +static struct partial_symbol * | |
224 | +ada_lookup_partial_symbol (struct partial_symtab *pst, const char *name, | |
225 | + int global, domain_enum namespace, int wild) | |
226 | { | |
227 | - char *result; | |
228 | - const int verbatim_match = (text[0] == '<'); | |
229 | - int match = 0; | |
230 | + struct partial_symbol **start; | |
231 | + int name_len = strlen (name); | |
232 | + int length = (global ? pst->n_global_syms : pst->n_static_syms); | |
233 | + int i; | |
234 | ||
235 | - if (verbatim_match) | |
236 | + if (length == 0) | |
237 | { | |
238 | - /* Strip the leading angle bracket. */ | |
239 | - text = text + 1; | |
240 | - text_len--; | |
241 | + return (NULL); | |
242 | } | |
243 | ||
244 | - /* First, test against the fully qualified name of the symbol. */ | |
245 | - | |
246 | - if (strncmp (sym_name, text, text_len) == 0) | |
247 | - match = 1; | |
248 | - | |
249 | - if (match && !encoded) | |
250 | - { | |
251 | - /* One needed check before declaring a positive match is to verify | |
252 | - that iff we are doing a verbatim match, the decoded version | |
253 | - of the symbol name starts with '<'. Otherwise, this symbol name | |
254 | - is not a suitable completion. */ | |
255 | - const char *sym_name_copy = sym_name; | |
256 | - int has_angle_bracket; | |
257 | - | |
258 | - sym_name = ada_decode (sym_name); | |
259 | - has_angle_bracket = (sym_name [0] == '<'); | |
260 | - match = (has_angle_bracket == verbatim_match); | |
261 | - sym_name = sym_name_copy; | |
262 | - } | |
263 | + start = (global ? | |
264 | + pst->objfile->global_psymbols.list + pst->globals_offset : | |
265 | + pst->objfile->static_psymbols.list + pst->statics_offset); | |
266 | ||
267 | - if (match && !verbatim_match) | |
268 | + if (wild) | |
269 | { | |
270 | - /* When doing non-verbatim match, another check that needs to | |
271 | - be done is to verify that the potentially matching symbol name | |
272 | - does not include capital letters, because the ada-mode would | |
273 | - not be able to understand these symbol names without the | |
274 | - angle bracket notation. */ | |
275 | - const char *tmp; | |
276 | + for (i = 0; i < length; i += 1) | |
277 | + { | |
278 | + struct partial_symbol *psym = start[i]; | |
279 | ||
280 | - for (tmp = sym_name; *tmp != '\0' && !isupper (*tmp); tmp++); | |
281 | - if (*tmp != '\0') | |
282 | - match = 0; | |
283 | + if (SYMBOL_DOMAIN (psym) == namespace && | |
284 | + wild_match (name, name_len, SYMBOL_LINKAGE_NAME (psym))) | |
285 | + return psym; | |
286 | + } | |
287 | + return NULL; | |
288 | } | |
289 | + else | |
290 | + { | |
291 | + if (global) | |
292 | + { | |
293 | + int U; | |
294 | + i = 0; | |
295 | + U = length - 1; | |
296 | + while (U - i > 4) | |
297 | + { | |
298 | + int M = (U + i) >> 1; | |
299 | + struct partial_symbol *psym = start[M]; | |
300 | + if (SYMBOL_LINKAGE_NAME (psym)[0] < name[0]) | |
301 | + i = M + 1; | |
302 | + else if (SYMBOL_LINKAGE_NAME (psym)[0] > name[0]) | |
303 | + U = M - 1; | |
304 | + else if (strcmp (SYMBOL_LINKAGE_NAME (psym), name) < 0) | |
305 | + i = M + 1; | |
306 | + else | |
307 | + U = M; | |
308 | + } | |
309 | + } | |
310 | + else | |
311 | + i = 0; | |
312 | ||
313 | - /* Second: Try wild matching... */ | |
314 | + while (i < length) | |
315 | + { | |
316 | + struct partial_symbol *psym = start[i]; | |
317 | ||
318 | - if (!match && wild_match) | |
319 | - { | |
320 | - /* Since we are doing wild matching, this means that TEXT | |
321 | - may represent an unqualified symbol name. We therefore must | |
322 | - also compare TEXT against the unqualified name of the symbol. */ | |
323 | - sym_name = ada_unqualified_name (ada_decode (sym_name)); | |
324 | + if (SYMBOL_DOMAIN (psym) == namespace) | |
325 | + { | |
326 | + int cmp = strncmp (name, SYMBOL_LINKAGE_NAME (psym), name_len); | |
327 | ||
328 | - if (strncmp (sym_name, text, text_len) == 0) | |
329 | - match = 1; | |
330 | - } | |
331 | + if (cmp < 0) | |
332 | + { | |
333 | + if (global) | |
334 | + break; | |
335 | + } | |
336 | + else if (cmp == 0 | |
337 | + && is_name_suffix (SYMBOL_LINKAGE_NAME (psym) | |
338 | + + name_len)) | |
339 | + return psym; | |
340 | + } | |
341 | + i += 1; | |
342 | + } | |
343 | ||
344 | - /* Finally: If we found a mach, prepare the result to return. */ | |
345 | + if (global) | |
346 | + { | |
347 | + int U; | |
348 | + i = 0; | |
349 | + U = length - 1; | |
350 | + while (U - i > 4) | |
351 | + { | |
352 | + int M = (U + i) >> 1; | |
353 | + struct partial_symbol *psym = start[M]; | |
354 | + if (SYMBOL_LINKAGE_NAME (psym)[0] < '_') | |
355 | + i = M + 1; | |
356 | + else if (SYMBOL_LINKAGE_NAME (psym)[0] > '_') | |
357 | + U = M - 1; | |
358 | + else if (strcmp (SYMBOL_LINKAGE_NAME (psym), "_ada_") < 0) | |
359 | + i = M + 1; | |
360 | + else | |
361 | + U = M; | |
362 | + } | |
363 | + } | |
364 | + else | |
365 | + i = 0; | |
366 | ||
367 | - if (!match) | |
368 | - return NULL; | |
369 | + while (i < length) | |
370 | + { | |
371 | + struct partial_symbol *psym = start[i]; | |
372 | ||
373 | - if (verbatim_match) | |
374 | - sym_name = add_angle_brackets (sym_name); | |
375 | + if (SYMBOL_DOMAIN (psym) == namespace) | |
376 | + { | |
377 | + int cmp; | |
378 | ||
379 | - if (!encoded) | |
380 | - sym_name = ada_decode (sym_name); | |
381 | + cmp = (int) '_' - (int) SYMBOL_LINKAGE_NAME (psym)[0]; | |
382 | + if (cmp == 0) | |
383 | + { | |
384 | + cmp = strncmp ("_ada_", SYMBOL_LINKAGE_NAME (psym), 5); | |
385 | + if (cmp == 0) | |
386 | + cmp = strncmp (name, SYMBOL_LINKAGE_NAME (psym) + 5, | |
387 | + name_len); | |
388 | + } | |
389 | ||
390 | - return sym_name; | |
391 | + if (cmp < 0) | |
392 | + { | |
393 | + if (global) | |
394 | + break; | |
395 | + } | |
396 | + else if (cmp == 0 | |
397 | + && is_name_suffix (SYMBOL_LINKAGE_NAME (psym) | |
398 | + + name_len + 5)) | |
399 | + return psym; | |
400 | + } | |
401 | + i += 1; | |
402 | + } | |
403 | + } | |
404 | + return NULL; | |
405 | } | |
406 | ||
407 | -/* A companion function to ada_make_symbol_completion_list(). | |
408 | - Check if SYM_NAME represents a symbol which name would be suitable | |
409 | - to complete TEXT (TEXT_LEN is the length of TEXT), in which case | |
410 | - it is appended at the end of the given string vector SV. | |
411 | +/* Find a symbol table containing symbol SYM or NULL if none. */ | |
412 | ||
413 | - ORIG_TEXT is the string original string from the user command | |
414 | - that needs to be completed. WORD is the entire command on which | |
415 | - completion should be performed. These two parameters are used to | |
416 | - determine which part of the symbol name should be added to the | |
417 | - completion vector. | |
418 | - if WILD_MATCH is set, then wild matching is performed. | |
419 | - ENCODED should be set if TEXT represents a symbol name in its | |
420 | - encoded formed (in which case the completion should also be | |
421 | - encoded). */ | |
422 | - | |
423 | -static void | |
424 | -symbol_completion_add (struct string_vector *sv, | |
425 | - const char *sym_name, | |
426 | - const char *text, int text_len, | |
427 | - const char *orig_text, const char *word, | |
428 | - int wild_match, int encoded) | |
429 | +static struct symtab * | |
430 | +symtab_for_sym (struct symbol *sym) | |
431 | { | |
432 | - const char *match = symbol_completion_match (sym_name, text, text_len, | |
433 | - wild_match, encoded); | |
434 | - char *completion; | |
435 | - | |
436 | - if (match == NULL) | |
437 | - return; | |
438 | - | |
439 | - /* We found a match, so add the appropriate completion to the given | |
440 | - string vector. */ | |
441 | - | |
442 | - if (word == orig_text) | |
443 | - { | |
444 | - completion = xmalloc (strlen (match) + 5); | |
445 | - strcpy (completion, match); | |
446 | - } | |
447 | - else if (word > orig_text) | |
448 | - { | |
449 | - /* Return some portion of sym_name. */ | |
450 | - completion = xmalloc (strlen (match) + 5); | |
451 | - strcpy (completion, match + (word - orig_text)); | |
452 | - } | |
453 | - else | |
454 | - { | |
455 | - /* Return some of ORIG_TEXT plus sym_name. */ | |
456 | - completion = xmalloc (strlen (match) + (orig_text - word) + 5); | |
457 | - strncpy (completion, word, orig_text - word); | |
458 | - completion[orig_text - word] = '\0'; | |
459 | - strcat (completion, match); | |
460 | - } | |
461 | + struct symtab *s; | |
462 | + struct objfile *objfile; | |
463 | + struct block *b; | |
464 | + struct symbol *tmp_sym; | |
465 | + struct dict_iterator iter; | |
466 | + int j; | |
467 | ||
468 | - string_vector_append (sv, completion); | |
469 | + ALL_SYMTABS (objfile, s) | |
470 | + { | |
471 | + switch (SYMBOL_CLASS (sym)) | |
472 | + { | |
473 | + case LOC_CONST: | |
474 | + case LOC_STATIC: | |
475 | + case LOC_TYPEDEF: | |
476 | + case LOC_REGISTER: | |
477 | + case LOC_LABEL: | |
478 | + case LOC_BLOCK: | |
479 | + case LOC_CONST_BYTES: | |
480 | + b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK); | |
481 | + ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym) | |
482 | + return s; | |
483 | + b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK); | |
484 | + ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym) | |
485 | + return s; | |
486 | + break; | |
487 | + default: | |
488 | + break; | |
489 | + } | |
490 | + switch (SYMBOL_CLASS (sym)) | |
491 | + { | |
492 | + case LOC_REGISTER: | |
493 | + case LOC_ARG: | |
494 | + case LOC_REF_ARG: | |
495 | + case LOC_REGPARM: | |
496 | + case LOC_REGPARM_ADDR: | |
497 | + case LOC_LOCAL: | |
498 | + case LOC_TYPEDEF: | |
499 | + case LOC_LOCAL_ARG: | |
500 | + case LOC_BASEREG: | |
501 | + case LOC_BASEREG_ARG: | |
502 | + case LOC_COMPUTED: | |
503 | + case LOC_COMPUTED_ARG: | |
504 | + for (j = FIRST_LOCAL_BLOCK; | |
505 | + j < BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (s)); j += 1) | |
506 | + { | |
507 | + b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), j); | |
508 | + ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym) | |
509 | + return s; | |
510 | + } | |
511 | + break; | |
512 | + default: | |
513 | + break; | |
514 | + } | |
515 | + } | |
516 | + return NULL; | |
517 | } | |
518 | ||
519 | -/* Return a list of possible symbol names completing TEXT0. The list | |
520 | - is NULL terminated. WORD is the entire command on which completion | |
521 | - is made. */ | |
522 | +/* Return a minimal symbol matching NAME according to Ada decoding | |
523 | + rules. Returns NULL if there is no such minimal symbol. Names | |
524 | + prefixed with "standard__" are handled specially: "standard__" is | |
525 | + first stripped off, and only static and global symbols are searched. */ | |
526 | ||
527 | -char ** | |
528 | -ada_make_symbol_completion_list (const char *text0, const char *word) | |
529 | +struct minimal_symbol * | |
530 | +ada_lookup_simple_minsym (const char *name) | |
531 | { | |
532 | - /* Note: This function is almost a copy of make_symbol_completion_list(), | |
533 | - except it has been adapted for Ada. It is somewhat of a shame to | |
534 | - duplicate so much code, but we don't really have the infrastructure | |
535 | - yet to develop a language-aware version of he symbol completer... */ | |
536 | - char *text; | |
537 | - int text_len; | |
538 | - int wild_match; | |
539 | - int encoded; | |
540 | - struct string_vector result = xnew_string_vector (128); | |
541 | - struct symbol *sym; | |
542 | - struct symtab *s; | |
543 | - struct partial_symtab *ps; | |
544 | - struct minimal_symbol *msymbol; | |
545 | struct objfile *objfile; | |
546 | - struct block *b, *surrounding_static_block = 0; | |
547 | - int i; | |
548 | - struct dict_iterator iter; | |
549 | + struct minimal_symbol *msymbol; | |
550 | + int wild_match; | |
551 | ||
552 | - if (text0[0] == '<') | |
553 | + if (strncmp (name, "standard__", sizeof ("standard__") - 1) == 0) | |
554 | { | |
555 | - text = xstrdup (text0); | |
556 | - make_cleanup (xfree, text); | |
557 | - text_len = strlen (text); | |
558 | + name += sizeof ("standard__") - 1; | |
559 | wild_match = 0; | |
560 | - encoded = 1; | |
561 | } | |
562 | else | |
563 | - { | |
564 | - text = xstrdup (ada_encode (text0)); | |
565 | - make_cleanup (xfree, text); | |
566 | - text_len = strlen (text); | |
567 | - for (i = 0; i < text_len; i++) | |
568 | - text[i] = tolower (text[i]); | |
569 | + wild_match = (strstr (name, "__") == NULL); | |
570 | ||
571 | - /* FIXME: brobecker/2003-09-17: When we get rid of ADA_RETAIN_DOTS, | |
572 | - we can restrict the wild_match check to searching "__" only. */ | |
573 | - wild_match = (strstr (text0, "__") == NULL | |
574 | - && strchr (text0, '.') == NULL); | |
575 | - encoded = (strstr (text0, "__") != NULL); | |
576 | - } | |
577 | + ALL_MSYMBOLS (objfile, msymbol) | |
578 | + { | |
579 | + if (ada_match_name (SYMBOL_LINKAGE_NAME (msymbol), name, wild_match) | |
580 | + && MSYMBOL_TYPE (msymbol) != mst_solib_trampoline) | |
581 | + return msymbol; | |
582 | + } | |
583 | ||
584 | - /* First, look at the partial symtab symbols. */ | |
585 | - ALL_PSYMTABS (objfile, ps) | |
586 | - { | |
587 | - struct partial_symbol **psym; | |
588 | + return NULL; | |
589 | +} | |
590 | ||
591 | - /* If the psymtab's been read in we'll get it when we search | |
592 | - through the blockvector. */ | |
593 | - if (ps->readin) | |
594 | - continue; | |
595 | +/* Return up minimal symbol for NAME, folded and encoded according to | |
596 | + Ada conventions, or NULL if none. The last two arguments are ignored. */ | |
597 | ||
598 | - for (psym = objfile->global_psymbols.list + ps->globals_offset; | |
599 | - psym < (objfile->global_psymbols.list + ps->globals_offset | |
600 | - + ps->n_global_syms); | |
601 | - psym++) | |
602 | - { | |
603 | - QUIT; | |
604 | - symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (*psym), | |
605 | - text, text_len, text0, word, | |
606 | - wild_match, encoded); | |
607 | - } | |
608 | +static struct minimal_symbol * | |
609 | +ada_lookup_minimal_symbol (const char *name, const char *sfile, | |
610 | + struct objfile *objf) | |
611 | +{ | |
612 | + return ada_lookup_simple_minsym (ada_encode (name)); | |
613 | +} | |
614 | ||
615 | - for (psym = objfile->static_psymbols.list + ps->statics_offset; | |
616 | - psym < (objfile->static_psymbols.list + ps->statics_offset | |
617 | - + ps->n_static_syms); | |
618 | - psym++) | |
619 | - { | |
620 | - QUIT; | |
621 | - symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (*psym), | |
622 | - text, text_len, text0, word, | |
623 | - wild_match, encoded); | |
624 | - } | |
625 | - } | |
626 | +/* For all subprograms that statically enclose the subprogram of the | |
627 | + selected frame, add symbols matching identifier NAME in DOMAIN | |
628 | + and their blocks to the list of data in OBSTACKP, as for | |
629 | + ada_add_block_symbols (q.v.). If WILD, treat as NAME with a | |
630 | + wildcard prefix. */ | |
631 | ||
632 | - /* At this point scan through the misc symbol vectors and add each | |
633 | - symbol you find to the list. Eventually we want to ignore | |
634 | - anything that isn't a text symbol (everything else will be | |
635 | - handled by the psymtab code above). */ | |
636 | +static void | |
637 | +add_symbols_from_enclosing_procs (struct obstack *obstackp, | |
638 | + const char *name, domain_enum namespace, | |
639 | + int wild_match) | |
640 | +{ | |
641 | +#ifdef HAVE_ADD_SYMBOLS_FROM_ENCLOSING_PROCS | |
642 | + /* Use a heuristic to find the frames of enclosing subprograms: treat the | |
643 | + pointer-sized value at location 0 from the local-variable base of a | |
644 | + frame as a static link, and then search up the call stack for a | |
645 | + frame with that same local-variable base. */ | |
646 | + static struct symbol static_link_sym; | |
647 | + static struct symbol *static_link; | |
648 | + struct value *target_link_val; | |
649 | ||
650 | - ALL_MSYMBOLS (objfile, msymbol) | |
651 | - { | |
652 | - QUIT; | |
653 | - symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (msymbol), | |
654 | - text, text_len, text0, word, | |
655 | - wild_match, encoded); | |
656 | - } | |
657 | + struct cleanup *old_chain = make_cleanup (null_cleanup, NULL); | |
658 | + struct frame_info *frame; | |
659 | ||
660 | - /* Search upwards from currently selected frame (so that we can | |
661 | - complete on local vars. */ | |
662 | + if (! target_has_stack) | |
663 | + return; | |
664 | ||
665 | - for (b = get_selected_block (0); b != NULL; b = BLOCK_SUPERBLOCK (b)) | |
666 | + if (static_link == NULL) | |
667 | { | |
668 | - if (!BLOCK_SUPERBLOCK (b)) | |
669 | - surrounding_static_block = b; /* For elmin of dups */ | |
670 | - | |
671 | - ALL_BLOCK_SYMBOLS (b, iter, sym) | |
672 | - { | |
673 | - symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (sym), | |
674 | - text, text_len, text0, word, | |
675 | - wild_match, encoded); | |
676 | - } | |
677 | + /* Initialize the local variable symbol that stands for the | |
678 | + static link (when there is one). */ | |
679 | + static_link = &static_link_sym; | |
680 | + SYMBOL_LINKAGE_NAME (static_link) = ""; | |
681 | + SYMBOL_LANGUAGE (static_link) = language_unknown; | |
682 | + SYMBOL_CLASS (static_link) = LOC_LOCAL; | |
683 | + SYMBOL_DOMAIN (static_link) = VAR_DOMAIN; | |
684 | + SYMBOL_TYPE (static_link) = lookup_pointer_type (builtin_type_void); | |
685 | + SYMBOL_VALUE (static_link) = | |
686 | + -(long) TYPE_LENGTH (SYMBOL_TYPE (static_link)); | |
687 | } | |
688 | ||
689 | - /* Go through the symtabs and check the externs and statics for | |
690 | - symbols which match. */ | |
691 | - | |
692 | - ALL_SYMTABS (objfile, s) | |
693 | - { | |
694 | - QUIT; | |
695 | - b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK); | |
696 | - ALL_BLOCK_SYMBOLS (b, iter, sym) | |
697 | - { | |
698 | - symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (sym), | |
699 | - text, text_len, text0, word, | |
700 | - wild_match, encoded); | |
701 | - } | |
702 | - } | |
703 | + frame = get_selected_frame (); | |
704 | + if (frame == NULL | |
705 | + || inside_main_func (get_frame_address_in_block (frame))) | |
706 | + return; | |
707 | ||
708 | - ALL_SYMTABS (objfile, s) | |
709 | - { | |
710 | - QUIT; | |
711 | - b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK); | |
712 | - /* Don't do this block twice. */ | |
713 | - if (b == surrounding_static_block) | |
714 | - continue; | |
715 | - ALL_BLOCK_SYMBOLS (b, iter, sym) | |
716 | - { | |
717 | - symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (sym), | |
718 | - text, text_len, text0, word, | |
719 | - wild_match, encoded); | |
720 | - } | |
721 | - } | |
722 | - | |
723 | - /* Append the closing NULL entry. */ | |
724 | - string_vector_append (&result, NULL); | |
725 | + target_link_val = read_var_value (static_link, frame); | |
726 | + while (target_link_val != NULL | |
727 | + && num_defns_collected (obstackp) == 0 | |
728 | + && frame_relative_level (frame) <= MAX_ENCLOSING_FRAME_LEVELS) | |
729 | + { | |
730 | + CORE_ADDR target_link = value_as_address (target_link_val); | |
731 | ||
732 | - return (result.array); | |
733 | -} | |
734 | + frame = get_prev_frame (frame); | |
735 | + if (frame == NULL) | |
736 | + break; | |
737 | ||
738 | -/* Look, in partial_symtab PST, for symbol NAME in given namespace. | |
739 | - Check the global symbols if GLOBAL, the static symbols if not. | |
740 | - Do wild-card match if WILD. */ | |
741 | + if (get_frame_locals_address (frame) == target_link) | |
742 | + { | |
743 | + struct block *block; | |
744 | + | |
745 | + QUIT; | |
746 | ||
747 | -static struct partial_symbol * | |
748 | -ada_lookup_partial_symbol (struct partial_symtab *pst, const char *name, | |
749 | - int global, domain_enum namespace, int wild) | |
750 | -{ | |
751 | - struct partial_symbol **start; | |
752 | - int name_len = strlen (name); | |
753 | - int length = (global ? pst->n_global_syms : pst->n_static_syms); | |
754 | - int i; | |
755 | + block = get_frame_block (frame, 0); | |
756 | + while (block != NULL && block_function (block) != NULL | |
757 | + && num_defns_collected (obstackp) == 0) | |
758 | + { | |
759 | + QUIT; | |
760 | ||
761 | - if (length == 0) | |
762 | - { | |
763 | - return (NULL); | |
764 | + ada_add_block_symbols (obstackp, block, name, namespace, | |
765 | + NULL, NULL, wild_match); | |
766 | + | |
767 | + block = BLOCK_SUPERBLOCK (block); | |
768 | + } | |
769 | + } | |
770 | } | |
771 | ||
772 | - start = (global ? | |
773 | - pst->objfile->global_psymbols.list + pst->globals_offset : | |
774 | - pst->objfile->static_psymbols.list + pst->statics_offset); | |
775 | - | |
776 | - if (wild) | |
777 | - { | |
778 | - for (i = 0; i < length; i += 1) | |
779 | - { | |
780 | - struct partial_symbol *psym = start[i]; | |
781 | + do_cleanups (old_chain); | |
782 | +#endif | |
783 | +} | |
784 | ||
785 | - if (SYMBOL_DOMAIN (psym) == namespace && | |
786 | - wild_match (name, name_len, SYMBOL_LINKAGE_NAME (psym))) | |
787 | - return psym; | |
788 | - } | |
789 | - return NULL; | |
790 | - } | |
791 | - else | |
792 | - { | |
793 | - if (global) | |
794 | - { | |
795 | - int U; | |
796 | - i = 0; | |
797 | - U = length - 1; | |
798 | - while (U - i > 4) | |
799 | - { | |
800 | - int M = (U + i) >> 1; | |
801 | - struct partial_symbol *psym = start[M]; | |
802 | - if (SYMBOL_LINKAGE_NAME (psym)[0] < name[0]) | |
803 | - i = M + 1; | |
804 | - else if (SYMBOL_LINKAGE_NAME (psym)[0] > name[0]) | |
805 | - U = M - 1; | |
806 | - else if (strcmp (SYMBOL_LINKAGE_NAME (psym), name) < 0) | |
807 | - i = M + 1; | |
808 | - else | |
809 | - U = M; | |
810 | - } | |
811 | - } | |
812 | - else | |
813 | - i = 0; | |
814 | +/* FIXME: The next two routines belong in symtab.c */ | |
815 | ||
816 | - while (i < length) | |
817 | - { | |
818 | - struct partial_symbol *psym = start[i]; | |
819 | +static void restore_language (void* lang) | |
820 | +{ | |
821 | + set_language ((enum language) lang); | |
822 | +} | |
823 | ||
824 | - if (SYMBOL_DOMAIN (psym) == namespace) | |
825 | - { | |
826 | - int cmp = strncmp (name, SYMBOL_LINKAGE_NAME (psym), name_len); | |
827 | +/* As for lookup_symbol, but performed as if the current language | |
828 | + were LANG. */ | |
829 | ||
830 | - if (cmp < 0) | |
831 | - { | |
832 | - if (global) | |
833 | - break; | |
834 | - } | |
835 | - else if (cmp == 0 | |
836 | - && is_name_suffix (SYMBOL_LINKAGE_NAME (psym) | |
837 | - + name_len)) | |
838 | - return psym; | |
839 | - } | |
840 | - i += 1; | |
841 | - } | |
842 | +struct symbol * | |
843 | +lookup_symbol_in_language (const char *name, const struct block *block, | |
844 | + domain_enum domain, enum language lang, | |
845 | + int *is_a_field_of_this, struct symtab **symtab) | |
846 | +{ | |
847 | + struct cleanup *old_chain | |
848 | + = make_cleanup (restore_language, (void*) current_language->la_language); | |
849 | + struct symbol *result; | |
850 | + set_language (lang); | |
851 | + result = lookup_symbol (name, block, domain, is_a_field_of_this, symtab); | |
852 | + do_cleanups (old_chain); | |
853 | + return result; | |
854 | +} | |
855 | ||
856 | - if (global) | |
857 | - { | |
858 | - int U; | |
859 | - i = 0; | |
860 | - U = length - 1; | |
861 | - while (U - i > 4) | |
862 | - { | |
863 | - int M = (U + i) >> 1; | |
864 | - struct partial_symbol *psym = start[M]; | |
865 | - if (SYMBOL_LINKAGE_NAME (psym)[0] < '_') | |
866 | - i = M + 1; | |
867 | - else if (SYMBOL_LINKAGE_NAME (psym)[0] > '_') | |
868 | - U = M - 1; | |
869 | - else if (strcmp (SYMBOL_LINKAGE_NAME (psym), "_ada_") < 0) | |
870 | - i = M + 1; | |
871 | - else | |
872 | - U = M; | |
873 | - } | |
874 | - } | |
875 | - else | |
876 | - i = 0; | |
877 | +/* True if TYPE is definitely an artificial type supplied to a symbol | |
878 | + for which no debugging information was given in the symbol file. */ | |
879 | ||
880 | - while (i < length) | |
881 | - { | |
882 | - struct partial_symbol *psym = start[i]; | |
883 | +static int | |
884 | +is_nondebugging_type (struct type *type) | |
885 | +{ | |
886 | + char *name = ada_type_name (type); | |
887 | + return (name != NULL && strcmp (name, "<variable, no debug info>") == 0); | |
888 | +} | |
889 | ||
890 | - if (SYMBOL_DOMAIN (psym) == namespace) | |
891 | - { | |
892 | - int cmp; | |
893 | +/* Remove any non-debugging symbols in SYMS[0 .. NSYMS-1] that definitely | |
894 | + duplicate other symbols in the list (The only case I know of where | |
895 | + this happens is when object files containing stabs-in-ecoff are | |
896 | + linked with files containing ordinary ecoff debugging symbols (or no | |
897 | + debugging symbols)). Modifies SYMS to squeeze out deleted entries. | |
898 | + Returns the number of items in the modified list. */ | |
899 | ||
900 | - cmp = (int) '_' - (int) SYMBOL_LINKAGE_NAME (psym)[0]; | |
901 | - if (cmp == 0) | |
902 | - { | |
903 | - cmp = strncmp ("_ada_", SYMBOL_LINKAGE_NAME (psym), 5); | |
904 | - if (cmp == 0) | |
905 | - cmp = strncmp (name, SYMBOL_LINKAGE_NAME (psym) + 5, | |
906 | - name_len); | |
907 | - } | |
908 | +static int | |
909 | +remove_extra_symbols (struct ada_symbol_info *syms, int nsyms) | |
910 | +{ | |
911 | + int i, j; | |
912 | ||
913 | - if (cmp < 0) | |
914 | + i = 0; | |
915 | + while (i < nsyms) | |
916 | + { | |
917 | + if (SYMBOL_LINKAGE_NAME (syms[i].sym) != NULL | |
918 | + && SYMBOL_CLASS (syms[i].sym) == LOC_STATIC | |
919 | + && is_nondebugging_type (SYMBOL_TYPE (syms[i].sym))) | |
920 | + { | |
921 | + for (j = 0; j < nsyms; j += 1) | |
922 | + { | |
923 | + if (i != j | |
924 | + && SYMBOL_LINKAGE_NAME (syms[j].sym) != NULL | |
925 | + && strcmp (SYMBOL_LINKAGE_NAME (syms[i].sym), | |
926 | + SYMBOL_LINKAGE_NAME (syms[j].sym)) == 0 | |
927 | + && SYMBOL_CLASS (syms[i].sym) == SYMBOL_CLASS (syms[j].sym) | |
928 | + && SYMBOL_VALUE_ADDRESS (syms[i].sym) | |
929 | + == SYMBOL_VALUE_ADDRESS (syms[j].sym)) | |
930 | { | |
931 | - if (global) | |
932 | - break; | |
933 | + int k; | |
934 | + for (k = i + 1; k < nsyms; k += 1) | |
935 | + syms[k - 1] = syms[k]; | |
936 | + nsyms -= 1; | |
937 | + goto NextSymbol; | |
938 | } | |
939 | - else if (cmp == 0 | |
940 | - && is_name_suffix (SYMBOL_LINKAGE_NAME (psym) | |
941 | - + name_len + 5)) | |
942 | - return psym; | |
943 | } | |
944 | - i += 1; | |
945 | } | |
946 | + i += 1; | |
947 | + NextSymbol: | |
948 | + ; | |
949 | } | |
950 | - return NULL; | |
951 | + return nsyms; | |
952 | } | |
953 | ||
954 | -/* Find a symbol table containing symbol SYM or NULL if none. */ | |
955 | +/* Given a type that corresponds to a renaming entity, use the type name | |
956 | + to extract the scope (package name or function name, fully qualified, | |
957 | + and following the GNAT encoding convention) where this renaming has been | |
958 | + defined. The string returned needs to be deallocated after use. */ | |
959 | ||
960 | -static struct symtab * | |
961 | -symtab_for_sym (struct symbol *sym) | |
962 | +static char * | |
963 | +xget_renaming_scope (struct type *renaming_type) | |
964 | { | |
965 | - struct symtab *s; | |
966 | - struct objfile *objfile; | |
967 | - struct block *b; | |
968 | - struct symbol *tmp_sym; | |
969 | - struct dict_iterator iter; | |
970 | - int j; | |
971 | + /* The renaming types adhere to the following convention: | |
972 | + <scope>__<rename>___<XR extension>. | |
973 | + So, to extract the scope, we search for the "___XR" extension, | |
974 | + and then backtrack until we find the first "__". */ | |
975 | + | |
976 | + const char *name = type_name_no_tag (renaming_type); | |
977 | + char *suffix = strstr (name, "___XR"); | |
978 | + char *last; | |
979 | + int scope_len; | |
980 | + char *scope; | |
981 | ||
982 | - ALL_SYMTABS (objfile, s) | |
983 | - { | |
984 | - switch (SYMBOL_CLASS (sym)) | |
985 | - { | |
986 | - case LOC_CONST: | |
987 | - case LOC_STATIC: | |
988 | - case LOC_TYPEDEF: | |
989 | - case LOC_REGISTER: | |
990 | - case LOC_LABEL: | |
991 | - case LOC_BLOCK: | |
992 | - case LOC_CONST_BYTES: | |
993 | - b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK); | |
994 | - ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym) | |
995 | - return s; | |
996 | - b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK); | |
997 | - ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym) | |
998 | - return s; | |
999 | - break; | |
1000 | - default: | |
1001 | - break; | |
1002 | - } | |
1003 | - switch (SYMBOL_CLASS (sym)) | |
1004 | - { | |
1005 | - case LOC_REGISTER: | |
1006 | - case LOC_ARG: | |
1007 | - case LOC_REF_ARG: | |
1008 | - case LOC_REGPARM: | |
1009 | - case LOC_REGPARM_ADDR: | |
1010 | - case LOC_LOCAL: | |
1011 | - case LOC_TYPEDEF: | |
1012 | - case LOC_LOCAL_ARG: | |
1013 | - case LOC_BASEREG: | |
1014 | - case LOC_BASEREG_ARG: | |
1015 | - case LOC_COMPUTED: | |
1016 | - case LOC_COMPUTED_ARG: | |
1017 | - for (j = FIRST_LOCAL_BLOCK; | |
1018 | - j < BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (s)); j += 1) | |
1019 | - { | |
1020 | - b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), j); | |
1021 | - ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym) | |
1022 | - return s; | |
1023 | - } | |
1024 | - break; | |
1025 | - default: | |
1026 | - break; | |
1027 | - } | |
1028 | - } | |
1029 | - return NULL; | |
1030 | -} | |
1031 | - | |
1032 | -/* Return a minimal symbol matching NAME according to Ada decoding | |
1033 | - rules. Returns NULL if there is no such minimal symbol. Names | |
1034 | - prefixed with "standard__" are handled specially: "standard__" is | |
1035 | - first stripped off, and only static and global symbols are searched. */ | |
1036 | - | |
1037 | -struct minimal_symbol * | |
1038 | -ada_lookup_simple_minsym (const char *name) | |
1039 | -{ | |
1040 | - struct objfile *objfile; | |
1041 | - struct minimal_symbol *msymbol; | |
1042 | - int wild_match; | |
1043 | - | |
1044 | - if (strncmp (name, "standard__", sizeof ("standard__") - 1) == 0) | |
1045 | - { | |
1046 | - name += sizeof ("standard__") - 1; | |
1047 | - wild_match = 0; | |
1048 | - } | |
1049 | - else | |
1050 | - wild_match = (strstr (name, "__") == NULL); | |
1051 | + /* Now, backtrack a bit until we find the first "__". Start looking | |
1052 | + at suffix - 3, as the <rename> part is at least one character long. */ | |
1053 | ||
1054 | - ALL_MSYMBOLS (objfile, msymbol) | |
1055 | - { | |
1056 | - if (ada_match_name (SYMBOL_LINKAGE_NAME (msymbol), name, wild_match) | |
1057 | - && MSYMBOL_TYPE (msymbol) != mst_solib_trampoline) | |
1058 | - return msymbol; | |
1059 | - } | |
1060 | + for (last = suffix - 3; last > name; last--) | |
1061 | + if (last[0] == '_' && last[1] == '_') | |
1062 | + break; | |
1063 | + | |
1064 | + /* Make a copy of scope and return it. */ | |
1065 | ||
1066 | - return NULL; | |
1067 | -} | |
1068 | + scope_len = last - name; | |
1069 | + scope = (char *) xmalloc ((scope_len + 1) * sizeof (char)); | |
1070 | ||
1071 | -/* Return up minimal symbol for NAME, folded and encoded according to | |
1072 | - Ada conventions, or NULL if none. The last two arguments are ignored. */ | |
1073 | + strncpy (scope, name, scope_len); | |
1074 | + scope[scope_len] = '\0'; | |
1075 | ||
1076 | -static struct minimal_symbol * | |
1077 | -ada_lookup_minimal_symbol (const char *name, const char *sfile, | |
1078 | - struct objfile *objf) | |
1079 | -{ | |
1080 | - return ada_lookup_simple_minsym (ada_encode (name)); | |
1081 | + return scope; | |
1082 | } | |
1083 | ||
1084 | -/* For all subprograms that statically enclose the subprogram of the | |
1085 | - selected frame, add symbols matching identifier NAME in DOMAIN | |
1086 | - and their blocks to the list of data in OBSTACKP, as for | |
1087 | - ada_add_block_symbols (q.v.). If WILD, treat as NAME with a | |
1088 | - wildcard prefix. */ | |
1089 | +/* Return nonzero if NAME corresponds to a package name. */ | |
1090 | ||
1091 | -static void | |
1092 | -add_symbols_from_enclosing_procs (struct obstack *obstackp, | |
1093 | - const char *name, domain_enum namespace, | |
1094 | - int wild_match) | |
1095 | +static int | |
1096 | +is_package_name (const char *name) | |
1097 | { | |
1098 | -#ifdef HAVE_ADD_SYMBOLS_FROM_ENCLOSING_PROCS | |
1099 | - /* Use a heuristic to find the frames of enclosing subprograms: treat the | |
1100 | - pointer-sized value at location 0 from the local-variable base of a | |
1101 | - frame as a static link, and then search up the call stack for a | |
1102 | - frame with that same local-variable base. */ | |
1103 | - static struct symbol static_link_sym; | |
1104 | - static struct symbol *static_link; | |
1105 | - struct value *target_link_val; | |
1106 | - | |
1107 | - struct cleanup *old_chain = make_cleanup (null_cleanup, NULL); | |
1108 | - struct frame_info *frame; | |
1109 | + /* Here, We take advantage of the fact that no symbols are generated | |
1110 | + for packages, while symbols are generated for each function. | |
1111 | + So the condition for NAME represent a package becomes equivalent | |
1112 | + to NAME not existing in our list of symbols. There is only one | |
1113 | + small complication with library-level functions (see below). */ | |
1114 | ||
1115 | - if (! target_has_stack) | |
1116 | - return; | |
1117 | + char *fun_name; | |
1118 | + | |
1119 | + /* If it is a function that has not been defined at library level, | |
1120 | + then we should be able to look it up in the symbols. */ | |
1121 | + if (standard_lookup (name, NULL, VAR_DOMAIN) != NULL) | |
1122 | + return 0; | |
1123 | ||
1124 | - if (static_link == NULL) | |
1125 | - { | |
1126 | - /* Initialize the local variable symbol that stands for the | |
1127 | - static link (when there is one). */ | |
1128 | - static_link = &static_link_sym; | |
1129 | - SYMBOL_LINKAGE_NAME (static_link) = ""; | |
1130 | - SYMBOL_LANGUAGE (static_link) = language_unknown; | |
1131 | - SYMBOL_CLASS (static_link) = LOC_LOCAL; | |
1132 | - SYMBOL_DOMAIN (static_link) = VAR_DOMAIN; | |
1133 | - SYMBOL_TYPE (static_link) = lookup_pointer_type (builtin_type_void); | |
1134 | - SYMBOL_VALUE (static_link) = | |
1135 | - -(long) TYPE_LENGTH (SYMBOL_TYPE (static_link)); | |
1136 | - } | |
1137 | + /* Library-level function names start with "_ada_". See if function | |
1138 | + "_ada_" followed by NAME can be found. */ | |
1139 | ||
1140 | - frame = get_selected_frame (); | |
1141 | - if (frame == NULL | |
1142 | - || inside_main_func (get_frame_address_in_block (frame))) | |
1143 | - return; | |
1144 | + /* Do a quick check that NAME does not contain "__", since library-level | |
1145 | + functions names can not contain "__" in them. */ | |
1146 | + if (strstr (name, "__") != NULL) | |
1147 | + return 0; | |
1148 | ||
1149 | - target_link_val = read_var_value (static_link, frame); | |
1150 | - while (target_link_val != NULL | |
1151 | - && num_defns_collected (obstackp) == 0 | |
1152 | - && frame_relative_level (frame) <= MAX_ENCLOSING_FRAME_LEVELS) | |
1153 | - { | |
1154 | - CORE_ADDR target_link = value_as_address (target_link_val); | |
1155 | + fun_name = (char *) alloca (strlen (name) + 5 + 1); | |
1156 | + xasprintf (&fun_name, "_ada_%s", name); | |
1157 | ||
1158 | - frame = get_prev_frame (frame); | |
1159 | - if (frame == NULL) | |
1160 | - break; | |
1161 | + return (standard_lookup (fun_name, NULL, VAR_DOMAIN) == NULL); | |
1162 | +} | |
1163 | ||
1164 | - if (get_frame_locals_address (frame) == target_link) | |
1165 | - { | |
1166 | - struct block *block; | |
1167 | - | |
1168 | - QUIT; | |
1169 | +/* Return nonzero if SYM corresponds to a renaming entity that is | |
1170 | + visible from FUNCTION_NAME. */ | |
1171 | ||
1172 | - block = get_frame_block (frame, 0); | |
1173 | - while (block != NULL && block_function (block) != NULL | |
1174 | - && num_defns_collected (obstackp) == 0) | |
1175 | - { | |
1176 | - QUIT; | |
1177 | +static int | |
1178 | +renaming_is_visible (const struct symbol *sym, char *function_name) | |
1179 | +{ | |
1180 | + char *scope = xget_renaming_scope (SYMBOL_TYPE (sym)); | |
1181 | ||
1182 | - ada_add_block_symbols (obstackp, block, name, namespace, | |
1183 | - NULL, NULL, wild_match); | |
1184 | - | |
1185 | - block = BLOCK_SUPERBLOCK (block); | |
1186 | - } | |
1187 | - } | |
1188 | - } | |
1189 | + make_cleanup (xfree, scope); | |
1190 | ||
1191 | - do_cleanups (old_chain); | |
1192 | -#endif | |
1193 | -} | |
1194 | + /* If the rename has been defined in a package, then it is visible. */ | |
1195 | + if (is_package_name (scope)) | |
1196 | + return 1; | |
1197 | ||
1198 | -/* FIXME: The next two routines belong in symtab.c */ | |
1199 | + /* Check that the rename is in the current function scope by checking | |
1200 | + that its name starts with SCOPE. */ | |
1201 | + | |
1202 | + /* If the function name starts with "_ada_", it means that it is | |
1203 | + a library-level function. Strip this prefix before doing the | |
1204 | + comparison, as the encoding for the renaming does not contain | |
1205 | + this prefix. */ | |
1206 | + if (strncmp (function_name, "_ada_", 5) == 0) | |
1207 | + function_name += 5; | |
1208 | ||
1209 | -static void restore_language (void* lang) | |
1210 | -{ | |
1211 | - set_language ((enum language) lang); | |
1212 | + return (strncmp (function_name, scope, strlen (scope)) == 0); | |
1213 | } | |
1214 | ||
1215 | -/* As for lookup_symbol, but performed as if the current language | |
1216 | - were LANG. */ | |
1217 | - | |
1218 | -struct symbol * | |
1219 | -lookup_symbol_in_language (const char *name, const struct block *block, | |
1220 | - domain_enum domain, enum language lang, | |
1221 | - int *is_a_field_of_this, struct symtab **symtab) | |
1222 | -{ | |
1223 | - struct cleanup *old_chain | |
1224 | - = make_cleanup (restore_language, (void*) current_language->la_language); | |
1225 | - struct symbol *result; | |
1226 | - set_language (lang); | |
1227 | - result = lookup_symbol (name, block, domain, is_a_field_of_this, symtab); | |
1228 | - do_cleanups (old_chain); | |
1229 | - return result; | |
1230 | -} | |
1231 | +/* Iterates over the SYMS list and remove any entry that corresponds to | |
1232 | + a renaming entity that is not visible from the function associated | |
1233 | + with CURRENT_BLOCK. | |
1234 | + | |
1235 | + Rationale: | |
1236 | + GNAT emits a type following a specified encoding for each renaming | |
1237 | + entity. Unfortunately, STABS currently does not support the definition | |
1238 | + of types that are local to a given lexical block, so all renamings types | |
1239 | + are emitted at library level. As a consequence, if an application | |
1240 | + contains two renaming entities using the same name, and a user tries to | |
1241 | + print the value of one of these entities, the result of the ada symbol | |
1242 | + lookup will also contain the wrong renaming type. | |
1243 | ||
1244 | -/* True if TYPE is definitely an artificial type supplied to a symbol | |
1245 | - for which no debugging information was given in the symbol file. */ | |
1246 | + This function partially covers for this limitation by attempting to | |
1247 | + remove from the SYMS list renaming symbols that should be visible | |
1248 | + from CURRENT_BLOCK. However, there does not seem be a 100% reliable | |
1249 | + method with the current information available. The implementation | |
1250 | + below has a couple of limitations (FIXME: brobecker-2003-05-12): | |
1251 | + | |
1252 | + - When the user tries to print a rename in a function while there | |
1253 | + is another rename entity defined in a package: Normally, the | |
1254 | + rename in the function has precedence over the rename in the | |
1255 | + package, so the latter should be removed from the list. This is | |
1256 | + currently not the case. | |
1257 | + | |
1258 | + - This function will incorrectly remove valid renames if | |
1259 | + the CURRENT_BLOCK corresponds to a function which symbol name | |
1260 | + has been changed by an "Export" pragma. As a consequence, | |
1261 | + the user will be unable to print such rename entities. */ | |
1262 | ||
1263 | static int | |
1264 | -is_nondebugging_type (struct type *type) | |
1265 | -{ | |
1266 | - char *name = ada_type_name (type); | |
1267 | - return (name != NULL && strcmp (name, "<variable, no debug info>") == 0); | |
1268 | -} | |
1269 | - | |
1270 | -/* Remove any non-debugging symbols in SYMS[0 .. NSYMS-1] that definitely | |
1271 | - duplicate other symbols in the list (The only case I know of where | |
1272 | - this happens is when object files containing stabs-in-ecoff are | |
1273 | - linked with files containing ordinary ecoff debugging symbols (or no | |
1274 | - debugging symbols)). Modifies SYMS to squeeze out deleted entries. | |
1275 | - Returns the number of items in the modified list. */ | |
1276 | - | |
1277 | -static int | |
1278 | -remove_extra_symbols (struct ada_symbol_info *syms, int nsyms) | |
1279 | -{ | |
1280 | - int i, j; | |
1281 | - | |
1282 | - i = 0; | |
1283 | - while (i < nsyms) | |
1284 | - { | |
1285 | - if (SYMBOL_LINKAGE_NAME (syms[i].sym) != NULL | |
1286 | - && SYMBOL_CLASS (syms[i].sym) == LOC_STATIC | |
1287 | - && is_nondebugging_type (SYMBOL_TYPE (syms[i].sym))) | |
1288 | - { | |
1289 | - for (j = 0; j < nsyms; j += 1) | |
1290 | - { | |
1291 | - if (i != j | |
1292 | - && SYMBOL_LINKAGE_NAME (syms[j].sym) != NULL | |
1293 | - && strcmp (SYMBOL_LINKAGE_NAME (syms[i].sym), | |
1294 | - SYMBOL_LINKAGE_NAME (syms[j].sym)) == 0 | |
1295 | - && SYMBOL_CLASS (syms[i].sym) == SYMBOL_CLASS (syms[j].sym) | |
1296 | - && SYMBOL_VALUE_ADDRESS (syms[i].sym) | |
1297 | - == SYMBOL_VALUE_ADDRESS (syms[j].sym)) | |
1298 | - { | |
1299 | - int k; | |
1300 | - for (k = i + 1; k < nsyms; k += 1) | |
1301 | - syms[k - 1] = syms[k]; | |
1302 | - nsyms -= 1; | |
1303 | - goto NextSymbol; | |
1304 | - } | |
1305 | - } | |
1306 | - } | |
1307 | - i += 1; | |
1308 | - NextSymbol: | |
1309 | - ; | |
1310 | - } | |
1311 | - return nsyms; | |
1312 | -} | |
1313 | - | |
1314 | -/* Given a type that corresponds to a renaming entity, use the type name | |
1315 | - to extract the scope (package name or function name, fully qualified, | |
1316 | - and following the GNAT encoding convention) where this renaming has been | |
1317 | - defined. The string returned needs to be deallocated after use. */ | |
1318 | - | |
1319 | -static char * | |
1320 | -xget_renaming_scope (struct type *renaming_type) | |
1321 | -{ | |
1322 | - /* The renaming types adhere to the following convention: | |
1323 | - <scope>__<rename>___<XR extension>. | |
1324 | - So, to extract the scope, we search for the "___XR" extension, | |
1325 | - and then backtrack until we find the first "__". */ | |
1326 | - | |
1327 | - const char *name = type_name_no_tag (renaming_type); | |
1328 | - char *suffix = strstr (name, "___XR"); | |
1329 | - char *last; | |
1330 | - int scope_len; | |
1331 | - char *scope; | |
1332 | - | |
1333 | - /* Now, backtrack a bit until we find the first "__". Start looking | |
1334 | - at suffix - 3, as the <rename> part is at least one character long. */ | |
1335 | - | |
1336 | - for (last = suffix - 3; last > name; last--) | |
1337 | - if (last[0] == '_' && last[1] == '_') | |
1338 | - break; | |
1339 | - | |
1340 | - /* Make a copy of scope and return it. */ | |
1341 | - | |
1342 | - scope_len = last - name; | |
1343 | - scope = (char *) xmalloc ((scope_len + 1) * sizeof (char)); | |
1344 | - | |
1345 | - strncpy (scope, name, scope_len); | |
1346 | - scope[scope_len] = '\0'; | |
1347 | - | |
1348 | - return scope; | |
1349 | -} | |
1350 | - | |
1351 | -/* Return nonzero if NAME corresponds to a package name. */ | |
1352 | - | |
1353 | -static int | |
1354 | -is_package_name (const char *name) | |
1355 | -{ | |
1356 | - /* Here, We take advantage of the fact that no symbols are generated | |
1357 | - for packages, while symbols are generated for each function. | |
1358 | - So the condition for NAME represent a package becomes equivalent | |
1359 | - to NAME not existing in our list of symbols. There is only one | |
1360 | - small complication with library-level functions (see below). */ | |
1361 | - | |
1362 | - char *fun_name; | |
1363 | - | |
1364 | - /* If it is a function that has not been defined at library level, | |
1365 | - then we should be able to look it up in the symbols. */ | |
1366 | - if (standard_lookup (name, NULL, VAR_DOMAIN) != NULL) | |
1367 | - return 0; | |
1368 | - | |
1369 | - /* Library-level function names start with "_ada_". See if function | |
1370 | - "_ada_" followed by NAME can be found. */ | |
1371 | - | |
1372 | - /* Do a quick check that NAME does not contain "__", since library-level | |
1373 | - functions names can not contain "__" in them. */ | |
1374 | - if (strstr (name, "__") != NULL) | |
1375 | - return 0; | |
1376 | - | |
1377 | - fun_name = (char *) alloca (strlen (name) + 5 + 1); | |
1378 | - xasprintf (&fun_name, "_ada_%s", name); | |
1379 | - | |
1380 | - return (standard_lookup (fun_name, NULL, VAR_DOMAIN) == NULL); | |
1381 | -} | |
1382 | - | |
1383 | -/* Return nonzero if SYM corresponds to a renaming entity that is | |
1384 | - visible from FUNCTION_NAME. */ | |
1385 | - | |
1386 | -static int | |
1387 | -renaming_is_visible (const struct symbol *sym, char *function_name) | |
1388 | -{ | |
1389 | - char *scope = xget_renaming_scope (SYMBOL_TYPE (sym)); | |
1390 | - | |
1391 | - make_cleanup (xfree, scope); | |
1392 | - | |
1393 | - /* If the rename has been defined in a package, then it is visible. */ | |
1394 | - if (is_package_name (scope)) | |
1395 | - return 1; | |
1396 | - | |
1397 | - /* Check that the rename is in the current function scope by checking | |
1398 | - that its name starts with SCOPE. */ | |
1399 | - | |
1400 | - /* If the function name starts with "_ada_", it means that it is | |
1401 | - a library-level function. Strip this prefix before doing the | |
1402 | - comparison, as the encoding for the renaming does not contain | |
1403 | - this prefix. */ | |
1404 | - if (strncmp (function_name, "_ada_", 5) == 0) | |
1405 | - function_name += 5; | |
1406 | - | |
1407 | - return (strncmp (function_name, scope, strlen (scope)) == 0); | |
1408 | -} | |
1409 | - | |
1410 | -/* Iterates over the SYMS list and remove any entry that corresponds to | |
1411 | - a renaming entity that is not visible from the function associated | |
1412 | - with CURRENT_BLOCK. | |
1413 | - | |
1414 | - Rationale: | |
1415 | - GNAT emits a type following a specified encoding for each renaming | |
1416 | - entity. Unfortunately, STABS currently does not support the definition | |
1417 | - of types that are local to a given lexical block, so all renamings types | |
1418 | - are emitted at library level. As a consequence, if an application | |
1419 | - contains two renaming entities using the same name, and a user tries to | |
1420 | - print the value of one of these entities, the result of the ada symbol | |
1421 | - lookup will also contain the wrong renaming type. | |
1422 | - | |
1423 | - This function partially covers for this limitation by attempting to | |
1424 | - remove from the SYMS list renaming symbols that should be visible | |
1425 | - from CURRENT_BLOCK. However, there does not seem be a 100% reliable | |
1426 | - method with the current information available. The implementation | |
1427 | - below has a couple of limitations (FIXME: brobecker-2003-05-12): | |
1428 | - | |
1429 | - - When the user tries to print a rename in a function while there | |
1430 | - is another rename entity defined in a package: Normally, the | |
1431 | - rename in the function has precedence over the rename in the | |
1432 | - package, so the latter should be removed from the list. This is | |
1433 | - currently not the case. | |
1434 | - | |
1435 | - - This function will incorrectly remove valid renames if | |
1436 | - the CURRENT_BLOCK corresponds to a function which symbol name | |
1437 | - has been changed by an "Export" pragma. As a consequence, | |
1438 | - the user will be unable to print such rename entities. */ | |
1439 | - | |
1440 | -static int | |
1441 | -remove_out_of_scope_renamings (struct ada_symbol_info *syms, | |
1442 | - int nsyms, | |
1443 | - struct block *current_block) | |
1444 | +remove_out_of_scope_renamings (struct ada_symbol_info *syms, | |
1445 | + int nsyms, | |
1446 | + struct block *current_block) | |
1447 | { | |
1448 | struct symbol *current_function; | |
1449 | char *current_function_name; | |
1450 | @@ -5179,166 +4965,460 @@ wild_match (const char *patn0, int patn_ | |
1451 | name += 1; | |
1452 | name_len -= 1; | |
1453 | } | |
1454 | - } | |
1455 | - | |
1456 | - return 0; | |
1457 | -} | |
1458 | + } | |
1459 | + | |
1460 | + return 0; | |
1461 | +} | |
1462 | + | |
1463 | + | |
1464 | +/* Add symbols from BLOCK matching identifier NAME in DOMAIN to | |
1465 | + vector *defn_symbols, updating the list of symbols in OBSTACKP | |
1466 | + (if necessary). If WILD, treat as NAME with a wildcard prefix. | |
1467 | + OBJFILE is the section containing BLOCK. | |
1468 | + SYMTAB is recorded with each symbol added. */ | |
1469 | + | |
1470 | +static void | |
1471 | +ada_add_block_symbols (struct obstack *obstackp, | |
1472 | + struct block *block, const char *name, | |
1473 | + domain_enum domain, struct objfile *objfile, | |
1474 | + struct symtab *symtab, int wild) | |
1475 | +{ | |
1476 | + struct dict_iterator iter; | |
1477 | + int name_len = strlen (name); | |
1478 | + /* A matching argument symbol, if any. */ | |
1479 | + struct symbol *arg_sym; | |
1480 | + /* Set true when we find a matching non-argument symbol. */ | |
1481 | + int found_sym; | |
1482 | + struct symbol *sym; | |
1483 | + | |
1484 | + arg_sym = NULL; | |
1485 | + found_sym = 0; | |
1486 | + if (wild) | |
1487 | + { | |
1488 | + struct symbol *sym; | |
1489 | + ALL_BLOCK_SYMBOLS (block, iter, sym) | |
1490 | + { | |
1491 | + if (SYMBOL_DOMAIN (sym) == domain && | |
1492 | + wild_match (name, name_len, SYMBOL_LINKAGE_NAME (sym))) | |
1493 | + { | |
1494 | + switch (SYMBOL_CLASS (sym)) | |
1495 | + { | |
1496 | + case LOC_ARG: | |
1497 | + case LOC_LOCAL_ARG: | |
1498 | + case LOC_REF_ARG: | |
1499 | + case LOC_REGPARM: | |
1500 | + case LOC_REGPARM_ADDR: | |
1501 | + case LOC_BASEREG_ARG: | |
1502 | + case LOC_COMPUTED_ARG: | |
1503 | + arg_sym = sym; | |
1504 | + break; | |
1505 | + case LOC_UNRESOLVED: | |
1506 | + continue; | |
1507 | + default: | |
1508 | + found_sym = 1; | |
1509 | + add_defn_to_vec (obstackp, | |
1510 | + fixup_symbol_section (sym, objfile), | |
1511 | + block, symtab); | |
1512 | + break; | |
1513 | + } | |
1514 | + } | |
1515 | + } | |
1516 | + } | |
1517 | + else | |
1518 | + { | |
1519 | + ALL_BLOCK_SYMBOLS (block, iter, sym) | |
1520 | + { | |
1521 | + if (SYMBOL_DOMAIN (sym) == domain) | |
1522 | + { | |
1523 | + int cmp = strncmp (name, SYMBOL_LINKAGE_NAME (sym), name_len); | |
1524 | + if (cmp == 0 | |
1525 | + && is_name_suffix (SYMBOL_LINKAGE_NAME (sym) + name_len)) | |
1526 | + { | |
1527 | + switch (SYMBOL_CLASS (sym)) | |
1528 | + { | |
1529 | + case LOC_ARG: | |
1530 | + case LOC_LOCAL_ARG: | |
1531 | + case LOC_REF_ARG: | |
1532 | + case LOC_REGPARM: | |
1533 | + case LOC_REGPARM_ADDR: | |
1534 | + case LOC_BASEREG_ARG: | |
1535 | + case LOC_COMPUTED_ARG: | |
1536 | + arg_sym = sym; | |
1537 | + break; | |
1538 | + case LOC_UNRESOLVED: | |
1539 | + break; | |
1540 | + default: | |
1541 | + found_sym = 1; | |
1542 | + add_defn_to_vec (obstackp, | |
1543 | + fixup_symbol_section (sym, objfile), | |
1544 | + block, symtab); | |
1545 | + break; | |
1546 | + } | |
1547 | + } | |
1548 | + } | |
1549 | + } | |
1550 | + } | |
1551 | + | |
1552 | + if (!found_sym && arg_sym != NULL) | |
1553 | + { | |
1554 | + add_defn_to_vec (obstackp, | |
1555 | + fixup_symbol_section (arg_sym, objfile), | |
1556 | + block, symtab); | |
1557 | + } | |
1558 | + | |
1559 | + if (!wild) | |
1560 | + { | |
1561 | + arg_sym = NULL; | |
1562 | + found_sym = 0; | |
1563 | + | |
1564 | + ALL_BLOCK_SYMBOLS (block, iter, sym) | |
1565 | + { | |
1566 | + if (SYMBOL_DOMAIN (sym) == domain) | |
1567 | + { | |
1568 | + int cmp; | |
1569 | + | |
1570 | + cmp = (int) '_' - (int) SYMBOL_LINKAGE_NAME (sym)[0]; | |
1571 | + if (cmp == 0) | |
1572 | + { | |
1573 | + cmp = strncmp ("_ada_", SYMBOL_LINKAGE_NAME (sym), 5); | |
1574 | + if (cmp == 0) | |
1575 | + cmp = strncmp (name, SYMBOL_LINKAGE_NAME (sym) + 5, | |
1576 | + name_len); | |
1577 | + } | |
1578 | + | |
1579 | + if (cmp == 0 | |
1580 | + && is_name_suffix (SYMBOL_LINKAGE_NAME (sym) + name_len + 5)) | |
1581 | + { | |
1582 | + switch (SYMBOL_CLASS (sym)) | |
1583 | + { | |
1584 | + case LOC_ARG: | |
1585 | + case LOC_LOCAL_ARG: | |
1586 | + case LOC_REF_ARG: | |
1587 | + case LOC_REGPARM: | |
1588 | + case LOC_REGPARM_ADDR: | |
1589 | + case LOC_BASEREG_ARG: | |
1590 | + case LOC_COMPUTED_ARG: | |
1591 | + arg_sym = sym; | |
1592 | + break; | |
1593 | + case LOC_UNRESOLVED: | |
1594 | + break; | |
1595 | + default: | |
1596 | + found_sym = 1; | |
1597 | + add_defn_to_vec (obstackp, | |
1598 | + fixup_symbol_section (sym, objfile), | |
1599 | + block, symtab); | |
1600 | + break; | |
1601 | + } | |
1602 | + } | |
1603 | + } | |
1604 | + end_loop2: ; | |
1605 | + } | |
1606 | + | |
1607 | + /* NOTE: This really shouldn't be needed for _ada_ symbols. | |
1608 | + They aren't parameters, right? */ | |
1609 | + if (!found_sym && arg_sym != NULL) | |
1610 | + { | |
1611 | + add_defn_to_vec (obstackp, | |
1612 | + fixup_symbol_section (arg_sym, objfile), | |
1613 | + block, symtab); | |
1614 | + } | |
1615 | + } | |
1616 | +} | |
1617 | +\f | |
1618 | +#ifdef GNAT_GDB | |
1619 | + | |
1620 | + /* Symbol Completion */ | |
1621 | + | |
1622 | +/* If SYM_NAME is a completion candidate for TEXT, return this symbol | |
1623 | + name in a form that's appropriate for the completion. The result | |
1624 | + does not need to be deallocated, but is only good until the next call. | |
1625 | + | |
1626 | + TEXT_LEN is equal to the length of TEXT. | |
1627 | + Perform a wild match if WILD_MATCH is set. | |
1628 | + ENCODED should be set if TEXT represents the start of a symbol name | |
1629 | + in its encoded form. */ | |
1630 | + | |
1631 | +static const char * | |
1632 | +symbol_completion_match (const char *sym_name, | |
1633 | + const char *text, int text_len, | |
1634 | + int wild_match, int encoded) | |
1635 | +{ | |
1636 | + char *result; | |
1637 | + const int verbatim_match = (text[0] == '<'); | |
1638 | + int match = 0; | |
1639 | + | |
1640 | + if (verbatim_match) | |
1641 | + { | |
1642 | + /* Strip the leading angle bracket. */ | |
1643 | + text = text + 1; | |
1644 | + text_len--; | |
1645 | + } | |
1646 | + | |
1647 | + /* First, test against the fully qualified name of the symbol. */ | |
1648 | + | |
1649 | + if (strncmp (sym_name, text, text_len) == 0) | |
1650 | + match = 1; | |
1651 | + | |
1652 | + if (match && !encoded) | |
1653 | + { | |
1654 | + /* One needed check before declaring a positive match is to verify | |
1655 | + that iff we are doing a verbatim match, the decoded version | |
1656 | + of the symbol name starts with '<'. Otherwise, this symbol name | |
1657 | + is not a suitable completion. */ | |
1658 | + const char *sym_name_copy = sym_name; | |
1659 | + int has_angle_bracket; | |
1660 | + | |
1661 | + sym_name = ada_decode (sym_name); | |
1662 | + has_angle_bracket = (sym_name [0] == '<'); | |
1663 | + match = (has_angle_bracket == verbatim_match); | |
1664 | + sym_name = sym_name_copy; | |
1665 | + } | |
1666 | + | |
1667 | + if (match && !verbatim_match) | |
1668 | + { | |
1669 | + /* When doing non-verbatim match, another check that needs to | |
1670 | + be done is to verify that the potentially matching symbol name | |
1671 | + does not include capital letters, because the ada-mode would | |
1672 | + not be able to understand these symbol names without the | |
1673 | + angle bracket notation. */ | |
1674 | + const char *tmp; | |
1675 | + | |
1676 | + for (tmp = sym_name; *tmp != '\0' && !isupper (*tmp); tmp++); | |
1677 | + if (*tmp != '\0') | |
1678 | + match = 0; | |
1679 | + } | |
1680 | + | |
1681 | + /* Second: Try wild matching... */ | |
1682 | + | |
1683 | + if (!match && wild_match) | |
1684 | + { | |
1685 | + /* Since we are doing wild matching, this means that TEXT | |
1686 | + may represent an unqualified symbol name. We therefore must | |
1687 | + also compare TEXT against the unqualified name of the symbol. */ | |
1688 | + sym_name = ada_unqualified_name (ada_decode (sym_name)); | |
1689 | + | |
1690 | + if (strncmp (sym_name, text, text_len) == 0) | |
1691 | + match = 1; | |
1692 | + } | |
1693 | + | |
1694 | + /* Finally: If we found a mach, prepare the result to return. */ | |
1695 | + | |
1696 | + if (!match) | |
1697 | + return NULL; | |
1698 | + | |
1699 | + if (verbatim_match) | |
1700 | + sym_name = add_angle_brackets (sym_name); | |
1701 | + | |
1702 | + if (!encoded) | |
1703 | + sym_name = ada_decode (sym_name); | |
1704 | + | |
1705 | + return sym_name; | |
1706 | +} | |
1707 | + | |
1708 | +/* A companion function to ada_make_symbol_completion_list(). | |
1709 | + Check if SYM_NAME represents a symbol which name would be suitable | |
1710 | + to complete TEXT (TEXT_LEN is the length of TEXT), in which case | |
1711 | + it is appended at the end of the given string vector SV. | |
1712 | + | |
1713 | + ORIG_TEXT is the string original string from the user command | |
1714 | + that needs to be completed. WORD is the entire command on which | |
1715 | + completion should be performed. These two parameters are used to | |
1716 | + determine which part of the symbol name should be added to the | |
1717 | + completion vector. | |
1718 | + if WILD_MATCH is set, then wild matching is performed. | |
1719 | + ENCODED should be set if TEXT represents a symbol name in its | |
1720 | + encoded formed (in which case the completion should also be | |
1721 | + encoded). */ | |
1722 | + | |
1723 | +static void | |
1724 | +symbol_completion_add (struct string_vector *sv, | |
1725 | + const char *sym_name, | |
1726 | + const char *text, int text_len, | |
1727 | + const char *orig_text, const char *word, | |
1728 | + int wild_match, int encoded) | |
1729 | +{ | |
1730 | + const char *match = symbol_completion_match (sym_name, text, text_len, | |
1731 | + wild_match, encoded); | |
1732 | + char *completion; | |
1733 | + | |
1734 | + if (match == NULL) | |
1735 | + return; | |
1736 | + | |
1737 | + /* We found a match, so add the appropriate completion to the given | |
1738 | + string vector. */ | |
1739 | + | |
1740 | + if (word == orig_text) | |
1741 | + { | |
1742 | + completion = xmalloc (strlen (match) + 5); | |
1743 | + strcpy (completion, match); | |
1744 | + } | |
1745 | + else if (word > orig_text) | |
1746 | + { | |
1747 | + /* Return some portion of sym_name. */ | |
1748 | + completion = xmalloc (strlen (match) + 5); | |
1749 | + strcpy (completion, match + (word - orig_text)); | |
1750 | + } | |
1751 | + else | |
1752 | + { | |
1753 | + /* Return some of ORIG_TEXT plus sym_name. */ | |
1754 | + completion = xmalloc (strlen (match) + (orig_text - word) + 5); | |
1755 | + strncpy (completion, word, orig_text - word); | |
1756 | + completion[orig_text - word] = '\0'; | |
1757 | + strcat (completion, match); | |
1758 | + } | |
1759 | + | |
1760 | + string_vector_append (sv, completion); | |
1761 | +} | |
1762 | + | |
1763 | +/* Return a list of possible symbol names completing TEXT0. The list | |
1764 | + is NULL terminated. WORD is the entire command on which completion | |
1765 | + is made. */ | |
1766 | + | |
1767 | +char ** | |
1768 | +ada_make_symbol_completion_list (const char *text0, const char *word) | |
1769 | +{ | |
1770 | + /* Note: This function is almost a copy of make_symbol_completion_list(), | |
1771 | + except it has been adapted for Ada. It is somewhat of a shame to | |
1772 | + duplicate so much code, but we don't really have the infrastructure | |
1773 | + yet to develop a language-aware version of he symbol completer... */ | |
1774 | + char *text; | |
1775 | + int text_len; | |
1776 | + int wild_match; | |
1777 | + int encoded; | |
1778 | + struct string_vector result = xnew_string_vector (128); | |
1779 | + struct symbol *sym; | |
1780 | + struct symtab *s; | |
1781 | + struct partial_symtab *ps; | |
1782 | + struct minimal_symbol *msymbol; | |
1783 | + struct objfile *objfile; | |
1784 | + struct block *b, *surrounding_static_block = 0; | |
1785 | + int i; | |
1786 | + struct dict_iterator iter; | |
1787 | + | |
1788 | + if (text0[0] == '<') | |
1789 | + { | |
1790 | + text = xstrdup (text0); | |
1791 | + make_cleanup (xfree, text); | |
1792 | + text_len = strlen (text); | |
1793 | + wild_match = 0; | |
1794 | + encoded = 1; | |
1795 | + } | |
1796 | + else | |
1797 | + { | |
1798 | + text = xstrdup (ada_encode (text0)); | |
1799 | + make_cleanup (xfree, text); | |
1800 | + text_len = strlen (text); | |
1801 | + for (i = 0; i < text_len; i++) | |
1802 | + text[i] = tolower (text[i]); | |
1803 | + | |
1804 | + /* FIXME: brobecker/2003-09-17: When we get rid of ADA_RETAIN_DOTS, | |
1805 | + we can restrict the wild_match check to searching "__" only. */ | |
1806 | + wild_match = (strstr (text0, "__") == NULL | |
1807 | + && strchr (text0, '.') == NULL); | |
1808 | + encoded = (strstr (text0, "__") != NULL); | |
1809 | + } | |
1810 | + | |
1811 | + /* First, look at the partial symtab symbols. */ | |
1812 | + ALL_PSYMTABS (objfile, ps) | |
1813 | + { | |
1814 | + struct partial_symbol **psym; | |
1815 | + | |
1816 | + /* If the psymtab's been read in we'll get it when we search | |
1817 | + through the blockvector. */ | |
1818 | + if (ps->readin) | |
1819 | + continue; | |
1820 | + | |
1821 | + for (psym = objfile->global_psymbols.list + ps->globals_offset; | |
1822 | + psym < (objfile->global_psymbols.list + ps->globals_offset | |
1823 | + + ps->n_global_syms); | |
1824 | + psym++) | |
1825 | + { | |
1826 | + QUIT; | |
1827 | + symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (*psym), | |
1828 | + text, text_len, text0, word, | |
1829 | + wild_match, encoded); | |
1830 | + } | |
1831 | + | |
1832 | + for (psym = objfile->static_psymbols.list + ps->statics_offset; | |
1833 | + psym < (objfile->static_psymbols.list + ps->statics_offset | |
1834 | + + ps->n_static_syms); | |
1835 | + psym++) | |
1836 | + { | |
1837 | + QUIT; | |
1838 | + symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (*psym), | |
1839 | + text, text_len, text0, word, | |
1840 | + wild_match, encoded); | |
1841 | + } | |
1842 | + } | |
1843 | ||
1844 | + /* At this point scan through the misc symbol vectors and add each | |
1845 | + symbol you find to the list. Eventually we want to ignore | |
1846 | + anything that isn't a text symbol (everything else will be | |
1847 | + handled by the psymtab code above). */ | |
1848 | ||
1849 | -/* Add symbols from BLOCK matching identifier NAME in DOMAIN to | |
1850 | - vector *defn_symbols, updating the list of symbols in OBSTACKP | |
1851 | - (if necessary). If WILD, treat as NAME with a wildcard prefix. | |
1852 | - OBJFILE is the section containing BLOCK. | |
1853 | - SYMTAB is recorded with each symbol added. */ | |
1854 | + ALL_MSYMBOLS (objfile, msymbol) | |
1855 | + { | |
1856 | + QUIT; | |
1857 | + symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (msymbol), | |
1858 | + text, text_len, text0, word, | |
1859 | + wild_match, encoded); | |
1860 | + } | |
1861 | ||
1862 | -static void | |
1863 | -ada_add_block_symbols (struct obstack *obstackp, | |
1864 | - struct block *block, const char *name, | |
1865 | - domain_enum domain, struct objfile *objfile, | |
1866 | - struct symtab *symtab, int wild) | |
1867 | -{ | |
1868 | - struct dict_iterator iter; | |
1869 | - int name_len = strlen (name); | |
1870 | - /* A matching argument symbol, if any. */ | |
1871 | - struct symbol *arg_sym; | |
1872 | - /* Set true when we find a matching non-argument symbol. */ | |
1873 | - int found_sym; | |
1874 | - struct symbol *sym; | |
1875 | + /* Search upwards from currently selected frame (so that we can | |
1876 | + complete on local vars. */ | |
1877 | ||
1878 | - arg_sym = NULL; | |
1879 | - found_sym = 0; | |
1880 | - if (wild) | |
1881 | - { | |
1882 | - struct symbol *sym; | |
1883 | - ALL_BLOCK_SYMBOLS (block, iter, sym) | |
1884 | - { | |
1885 | - if (SYMBOL_DOMAIN (sym) == domain && | |
1886 | - wild_match (name, name_len, SYMBOL_LINKAGE_NAME (sym))) | |
1887 | - { | |
1888 | - switch (SYMBOL_CLASS (sym)) | |
1889 | - { | |
1890 | - case LOC_ARG: | |
1891 | - case LOC_LOCAL_ARG: | |
1892 | - case LOC_REF_ARG: | |
1893 | - case LOC_REGPARM: | |
1894 | - case LOC_REGPARM_ADDR: | |
1895 | - case LOC_BASEREG_ARG: | |
1896 | - case LOC_COMPUTED_ARG: | |
1897 | - arg_sym = sym; | |
1898 | - break; | |
1899 | - case LOC_UNRESOLVED: | |
1900 | - continue; | |
1901 | - default: | |
1902 | - found_sym = 1; | |
1903 | - add_defn_to_vec (obstackp, | |
1904 | - fixup_symbol_section (sym, objfile), | |
1905 | - block, symtab); | |
1906 | - break; | |
1907 | - } | |
1908 | - } | |
1909 | - } | |
1910 | - } | |
1911 | - else | |
1912 | + for (b = get_selected_block (0); b != NULL; b = BLOCK_SUPERBLOCK (b)) | |
1913 | { | |
1914 | - ALL_BLOCK_SYMBOLS (block, iter, sym) | |
1915 | + if (!BLOCK_SUPERBLOCK (b)) | |
1916 | + surrounding_static_block = b; /* For elmin of dups */ | |
1917 | + | |
1918 | + ALL_BLOCK_SYMBOLS (b, iter, sym) | |
1919 | { | |
1920 | - if (SYMBOL_DOMAIN (sym) == domain) | |
1921 | - { | |
1922 | - int cmp = strncmp (name, SYMBOL_LINKAGE_NAME (sym), name_len); | |
1923 | - if (cmp == 0 | |
1924 | - && is_name_suffix (SYMBOL_LINKAGE_NAME (sym) + name_len)) | |
1925 | - { | |
1926 | - switch (SYMBOL_CLASS (sym)) | |
1927 | - { | |
1928 | - case LOC_ARG: | |
1929 | - case LOC_LOCAL_ARG: | |
1930 | - case LOC_REF_ARG: | |
1931 | - case LOC_REGPARM: | |
1932 | - case LOC_REGPARM_ADDR: | |
1933 | - case LOC_BASEREG_ARG: | |
1934 | - case LOC_COMPUTED_ARG: | |
1935 | - arg_sym = sym; | |
1936 | - break; | |
1937 | - case LOC_UNRESOLVED: | |
1938 | - break; | |
1939 | - default: | |
1940 | - found_sym = 1; | |
1941 | - add_defn_to_vec (obstackp, | |
1942 | - fixup_symbol_section (sym, objfile), | |
1943 | - block, symtab); | |
1944 | - break; | |
1945 | - } | |
1946 | - } | |
1947 | - } | |
1948 | + symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (sym), | |
1949 | + text, text_len, text0, word, | |
1950 | + wild_match, encoded); | |
1951 | } | |
1952 | } | |
1953 | ||
1954 | - if (!found_sym && arg_sym != NULL) | |
1955 | - { | |
1956 | - add_defn_to_vec (obstackp, | |
1957 | - fixup_symbol_section (arg_sym, objfile), | |
1958 | - block, symtab); | |
1959 | - } | |
1960 | - | |
1961 | - if (!wild) | |
1962 | - { | |
1963 | - arg_sym = NULL; | |
1964 | - found_sym = 0; | |
1965 | + /* Go through the symtabs and check the externs and statics for | |
1966 | + symbols which match. */ | |
1967 | ||
1968 | - ALL_BLOCK_SYMBOLS (block, iter, sym) | |
1969 | - { | |
1970 | - if (SYMBOL_DOMAIN (sym) == domain) | |
1971 | - { | |
1972 | - int cmp; | |
1973 | + ALL_SYMTABS (objfile, s) | |
1974 | + { | |
1975 | + QUIT; | |
1976 | + b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK); | |
1977 | + ALL_BLOCK_SYMBOLS (b, iter, sym) | |
1978 | + { | |
1979 | + symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (sym), | |
1980 | + text, text_len, text0, word, | |
1981 | + wild_match, encoded); | |
1982 | + } | |
1983 | + } | |
1984 | ||
1985 | - cmp = (int) '_' - (int) SYMBOL_LINKAGE_NAME (sym)[0]; | |
1986 | - if (cmp == 0) | |
1987 | - { | |
1988 | - cmp = strncmp ("_ada_", SYMBOL_LINKAGE_NAME (sym), 5); | |
1989 | - if (cmp == 0) | |
1990 | - cmp = strncmp (name, SYMBOL_LINKAGE_NAME (sym) + 5, | |
1991 | - name_len); | |
1992 | - } | |
1993 | + ALL_SYMTABS (objfile, s) | |
1994 | + { | |
1995 | + QUIT; | |
1996 | + b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK); | |
1997 | + /* Don't do this block twice. */ | |
1998 | + if (b == surrounding_static_block) | |
1999 | + continue; | |
2000 | + ALL_BLOCK_SYMBOLS (b, iter, sym) | |
2001 | + { | |
2002 | + symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (sym), | |
2003 | + text, text_len, text0, word, | |
2004 | + wild_match, encoded); | |
2005 | + } | |
2006 | + } | |
2007 | ||
2008 | - if (cmp == 0 | |
2009 | - && is_name_suffix (SYMBOL_LINKAGE_NAME (sym) + name_len + 5)) | |
2010 | - { | |
2011 | - switch (SYMBOL_CLASS (sym)) | |
2012 | - { | |
2013 | - case LOC_ARG: | |
2014 | - case LOC_LOCAL_ARG: | |
2015 | - case LOC_REF_ARG: | |
2016 | - case LOC_REGPARM: | |
2017 | - case LOC_REGPARM_ADDR: | |
2018 | - case LOC_BASEREG_ARG: | |
2019 | - case LOC_COMPUTED_ARG: | |
2020 | - arg_sym = sym; | |
2021 | - break; | |
2022 | - case LOC_UNRESOLVED: | |
2023 | - break; | |
2024 | - default: | |
2025 | - found_sym = 1; | |
2026 | - add_defn_to_vec (obstackp, | |
2027 | - fixup_symbol_section (sym, objfile), | |
2028 | - block, symtab); | |
2029 | - break; | |
2030 | - } | |
2031 | - } | |
2032 | - } | |
2033 | - end_loop2: ; | |
2034 | - } | |
2035 | + /* Append the closing NULL entry. */ | |
2036 | + string_vector_append (&result, NULL); | |
2037 | ||
2038 | - /* NOTE: This really shouldn't be needed for _ada_ symbols. | |
2039 | - They aren't parameters, right? */ | |
2040 | - if (!found_sym && arg_sym != NULL) | |
2041 | - { | |
2042 | - add_defn_to_vec (obstackp, | |
2043 | - fixup_symbol_section (arg_sym, objfile), | |
2044 | - block, symtab); | |
2045 | - } | |
2046 | - } | |
2047 | + return (result.array); | |
2048 | } | |
2049 | + | |
2050 | +#endif /* GNAT_GDB */ | |
2051 | \f | |
2052 | +#ifdef GNAT_GDB | |
2053 | /* Breakpoint-related */ | |
2054 | ||
2055 | /* Import message from symtab.c. */ | |
2056 | @@ -6041,37 +6121,6 @@ extended_canonical_line_spec (struct sym | |
2057 | return r; | |
2058 | } | |
2059 | ||
2060 | -/* If the main procedure is written in Ada, then return its name. | |
2061 | - The result is good until the next call. Return NULL if the main | |
2062 | - procedure doesn't appear to be in Ada. */ | |
2063 | - | |
2064 | -char * | |
2065 | -ada_main_name (void) | |
2066 | -{ | |
2067 | - struct minimal_symbol *msym; | |
2068 | - CORE_ADDR main_program_name_addr; | |
2069 | - static char main_program_name[1024]; | |
2070 | - /* For Ada, the name of the main procedure is stored in a specific | |
2071 | - string constant, generated by the binder. Look for that symbol, | |
2072 | - extract its address, and then read that string. If we didn't find | |
2073 | - that string, then most probably the main procedure is not written | |
2074 | - in Ada. */ | |
2075 | - msym = lookup_minimal_symbol (ADA_MAIN_PROGRAM_SYMBOL_NAME, NULL, NULL); | |
2076 | - | |
2077 | - if (msym != NULL) | |
2078 | - { | |
2079 | - main_program_name_addr = SYMBOL_VALUE_ADDRESS (msym); | |
2080 | - if (main_program_name_addr == 0) | |
2081 | - error ("Invalid address for Ada main program name."); | |
2082 | - | |
2083 | - extract_string (main_program_name_addr, main_program_name); | |
2084 | - return main_program_name; | |
2085 | - } | |
2086 | - | |
2087 | - /* The main procedure doesn't seem to be in Ada. */ | |
2088 | - return NULL; | |
2089 | -} | |
2090 | - | |
2091 | /* Return type of Ada breakpoint associated with bp_stat: | |
2092 | 0 if not an Ada-specific breakpoint, 1 for break on specific exception, | |
2093 | 2 for break on unhandled exception, 3 for assert. */ | |
2094 | @@ -6079,12 +6128,8 @@ ada_main_name (void) | |
2095 | static int | |
2096 | ada_exception_breakpoint_type (bpstat bs) | |
2097 | { | |
2098 | -#ifdef GNAT_GDB | |
2099 | return ((! bs || ! bs->breakpoint_at) ? 0 | |
2100 | : bs->breakpoint_at->break_on_exception); | |
2101 | -#else | |
2102 | - return 0; | |
2103 | -#endif | |
2104 | } | |
2105 | ||
2106 | /* True iff FRAME is very likely to be that of a function that is | |
2107 | @@ -6285,7 +6330,6 @@ exception_name_from_cond (const char *co | |
2108 | int | |
2109 | ada_print_exception_breakpoint_nontask (struct breakpoint *b) | |
2110 | { | |
2111 | -#ifdef GNAT_GDB | |
2112 | if (b->break_on_exception == 1) | |
2113 | { | |
2114 | if (b->cond_string) /* the breakpoint is on a specific exception. */ | |
2115 | @@ -6314,9 +6358,6 @@ ada_print_exception_breakpoint_nontask ( | |
2116 | else | |
2117 | return 0; | |
2118 | return 1; | |
2119 | -#else | |
2120 | - return 0; | |
2121 | -#endif | |
2122 | } | |
2123 | ||
2124 | /* Print task identifier for breakpoint B, if it is an Ada-specific | |
2125 | @@ -6325,13 +6366,11 @@ ada_print_exception_breakpoint_nontask ( | |
2126 | void | |
2127 | ada_print_exception_breakpoint_task (struct breakpoint *b) | |
2128 | { | |
2129 | -#ifdef GNAT_GDB | |
2130 | if (b->task != 0) | |
2131 | { | |
2132 | ui_out_text (uiout, " task "); | |
2133 | ui_out_field_int (uiout, "task", b->task); | |
2134 | } | |
2135 | -#endif | |
2136 | } | |
2137 | ||
2138 | int | |
2139 | @@ -6476,8 +6515,8 @@ ada_breakpoint_rewrite (char *arg, int * | |
2140 | } | |
2141 | return arg; | |
2142 | } | |
2143 | +#endif | |
2144 | \f | |
2145 | - | |
2146 | /* Field Access */ | |
2147 | ||
2148 | /* True if field number FIELD_NUM in struct or union type TYPE is supposed | |
2149 | @@ -10098,7 +10137,7 @@ const struct language_defn ada_language_ | |
2150 | #ifdef GNAT_GDB | |
2151 | ada_lookup_symbol, | |
2152 | ada_lookup_minimal_symbol, | |
2153 | -#endif | |
2154 | +#endif /* GNAT_GDB */ | |
2155 | &ada_exp_descriptor, | |
2156 | parse, | |
2157 | ada_error, | |
2158 | @@ -10134,7 +10173,7 @@ const struct language_defn ada_language_ | |
2159 | #ifdef GNAT_GDB | |
2160 | ada_translate_error_message, /* Substitute Ada-specific terminology | |
2161 | in errors and warnings. */ | |
2162 | -#endif | |
2163 | +#endif /* GNAT_GDB */ | |
2164 | LANG_MAGIC | |
2165 | }; | |
2166 | ||
2167 | @@ -10186,17 +10225,17 @@ _initialize_ada_language (void) | |
2168 | deprecated_register_gdbarch_swap (NULL, 0, build_ada_types); | |
2169 | add_language (&ada_language_defn); | |
2170 | ||
2171 | + varsize_limit = 65536; | |
2172 | #ifdef GNAT_GDB | |
2173 | add_show_from_set | |
2174 | (add_set_cmd ("varsize-limit", class_support, var_uinteger, | |
2175 | (char *) &varsize_limit, | |
2176 | "Set maximum bytes in dynamic-sized object.", | |
2177 | &setlist), &showlist); | |
2178 | -#endif | |
2179 | - varsize_limit = 65536; | |
2180 | + obstack_init (&cache_space); | |
2181 | +#endif /* GNAT_GDB */ | |
2182 | ||
2183 | obstack_init (&symbol_list_obstack); | |
2184 | - obstack_init (&cache_space); | |
2185 | ||
2186 | decoded_names_store = htab_create_alloc_ex | |
2187 | (256, htab_hash_string, (int (*) (const void *, const void *)) streq, | |
2188 | Index: gdb/ada-lang.h | |
2189 | =================================================================== | |
2190 | RCS file: /cvs/src/src/gdb/ada-lang.h,v | |
2191 | retrieving revision 1.8 | |
2192 | diff -u -p -r1.8 ada-lang.h | |
2193 | --- gdb/ada-lang.h 8 Jun 2004 08:42:04 -0000 1.8 | |
2194 | +++ gdb/ada-lang.h 16 Jun 2004 08:10:22 -0000 | |
2195 | @@ -124,6 +124,41 @@ struct ada_symbol_info { | |
2196 | struct symtab* symtab; | |
2197 | }; | |
2198 | ||
2199 | +/* Ada task structures. */ | |
2200 | + | |
2201 | +/* Ada task control block, as defined in the GNAT runt-time library. */ | |
2202 | + | |
2203 | +struct task_control_block | |
2204 | +{ | |
2205 | + char state; | |
2206 | + CORE_ADDR parent; | |
2207 | + int priority; | |
2208 | + char image [32]; | |
2209 | + int image_len; /* This field is not always present in the ATCB. */ | |
2210 | + CORE_ADDR call; | |
2211 | + CORE_ADDR thread; | |
2212 | + CORE_ADDR lwp; /* This field is not always present in the ATCB. */ | |
2213 | +}; | |
2214 | + | |
2215 | +struct task_ptid | |
2216 | +{ | |
2217 | + int pid; /* The Process id */ | |
2218 | + long lwp; /* The Light Weight Process id */ | |
2219 | + long tid; /* The Thread id */ | |
2220 | +}; | |
2221 | +typedef struct task_ptid task_ptid_t; | |
2222 | + | |
2223 | +struct task_entry | |
2224 | +{ | |
2225 | + CORE_ADDR task_id; | |
2226 | + struct task_control_block atcb; | |
2227 | + int task_num; | |
2228 | + int known_tasks_index; | |
2229 | + struct task_entry *next_task; | |
2230 | + task_ptid_t task_ptid; | |
2231 | + int stack_per; | |
2232 | +}; | |
2233 | + | |
2234 | extern struct type *builtin_type_ada_int; | |
2235 | extern struct type *builtin_type_ada_short; | |
2236 | extern struct type *builtin_type_ada_long; | |
2237 | @@ -136,9 +171,13 @@ extern struct type *builtin_type_ada_nat | |
2238 | extern struct type *builtin_type_ada_positive; | |
2239 | extern struct type *builtin_type_ada_system_address; | |
2240 | ||
2241 | -/* The maximum number of tasks known to the Ada runtime */ | |
2242 | +/* The maximum number of tasks known to the Ada runtime. */ | |
2243 | extern const int MAX_NUMBER_OF_KNOWN_TASKS; | |
2244 | ||
2245 | +/* task entry list. */ | |
2246 | +extern struct task_entry *task_list; | |
2247 | + | |
2248 | + | |
2249 | /* Assuming V points to an array of S objects, make sure that it contains at | |
2250 | least M objects, updating V and S as necessary. */ | |
2251 | ||
2252 | @@ -393,6 +432,8 @@ extern void ada_find_printable_frame (st | |
2253 | ||
2254 | extern void ada_reset_thread_registers (void); | |
2255 | ||
2256 | +extern int ada_build_task_list (void); | |
2257 | + | |
2258 | /* Look up a symbol by name using the search conventions of | |
2259 | a specific language (optional block, optional symtab). | |
2260 | FIXME: Should be symtab.h. */ | |
2261 | @@ -403,5 +444,4 @@ extern struct symbol *lookup_symbol_in_l | |
2262 | enum language, | |
2263 | int *, | |
2264 | struct symtab **); | |
2265 | - | |
2266 | #endif | |
2267 | Index: gdb/ada-tasks.c | |
2268 | =================================================================== | |
2269 | RCS file: /cvs/src/src/gdb/ada-tasks.c,v | |
2270 | retrieving revision 1.9 | |
2271 | diff -u -p -r1.9 ada-tasks.c | |
2272 | --- gdb/ada-tasks.c 2 Jun 2004 09:55:36 -0000 1.9 | |
2273 | +++ gdb/ada-tasks.c 16 Jun 2004 08:10:22 -0000 | |
2274 | @@ -62,18 +62,6 @@ enum task_states | |
2275 | Master_Phase_2_Sleep | |
2276 | }; | |
2277 | ||
2278 | -struct task_control_block | |
2279 | -{ | |
2280 | - char state; | |
2281 | - CORE_ADDR parent; | |
2282 | - int priority; | |
2283 | - char image [32]; | |
2284 | - int image_len; /* This field is not always present in the ATCB. */ | |
2285 | - CORE_ADDR call; | |
2286 | - CORE_ADDR thread; | |
2287 | - CORE_ADDR lwp; /* This field is not always present in the ATCB. */ | |
2288 | -}; | |
2289 | - | |
2290 | /* The index of certain important fields in the Ada Task Control Block | |
2291 | record and sub-records. */ | |
2292 | ||
2293 | @@ -102,25 +90,6 @@ struct tcb_fieldnos | |
2294 | #define TASK_LWP(atcb) extract_unsigned_integer (&(atcb).lwp, sizeof ((atcb).lwp)) | |
2295 | #endif | |
2296 | ||
2297 | -struct task_ptid | |
2298 | -{ | |
2299 | - int pid; /* The Process id */ | |
2300 | - long lwp; /* The Light Weight Process id */ | |
2301 | - long tid; /* The Thread id */ | |
2302 | -}; | |
2303 | -typedef struct task_ptid task_ptid_t; | |
2304 | - | |
2305 | -struct task_entry | |
2306 | -{ | |
2307 | - CORE_ADDR task_id; | |
2308 | - struct task_control_block atcb; | |
2309 | - int task_num; | |
2310 | - int known_tasks_index; | |
2311 | - struct task_entry *next_task; | |
2312 | - task_ptid_t task_ptid; | |
2313 | - int stack_per; | |
2314 | -}; | |
2315 | - | |
2316 | /* FIXME: move all this conditional compilation in description | |
2317 | files or in configure.in */ | |
2318 | ||
2319 | @@ -267,7 +236,6 @@ static void get_tcb_call_type_info (stru | |
2320 | int *atcb_call_self_fieldno); | |
2321 | static CORE_ADDR get_known_tasks_addr (void); | |
2322 | static int read_known_tasks_array (void); | |
2323 | -static int build_task_list (void); | |
2324 | static void value_as_string (char *dest, struct value *val, int length); | |
2325 | static struct task_control_block read_atcb (CORE_ADDR atcb_addr); | |
2326 | static CORE_ADDR read_caller (const CORE_ADDR call); | |
2327 | @@ -283,9 +251,9 @@ static void ada_tasks_attach_observers ( | |
2328 | ||
2329 | int ada__tasks_check_symbol_table = 1; | |
2330 | CORE_ADDR pthread_kern_addr = 0; | |
2331 | +struct task_entry *task_list = NULL; | |
2332 | ||
2333 | /* Local global variables. */ | |
2334 | -static struct task_entry *task_list = NULL; | |
2335 | ||
2336 | /* When non-zero, this flag indicates that the current task_list | |
2337 | is obsolete, and should be recomputed before it is accessed. */ | |
2338 | @@ -850,8 +818,8 @@ read_known_tasks_array (void) | |
2339 | the inferior. Prints an appropriate message and returns non-zero | |
2340 | if it failed to build this list. */ | |
2341 | ||
2342 | -static int | |
2343 | -build_task_list (void) | |
2344 | +int | |
2345 | +ada_build_task_list (void) | |
2346 | { | |
2347 | if (!target_has_stack) | |
2348 | error ("No stack"); | |
2349 | @@ -1306,7 +1274,7 @@ info_tasks (char *arg, int from_tty) | |
2350 | static void | |
2351 | info_tasks_command (char *arg, int from_tty) | |
2352 | { | |
2353 | - const int task_list_built = build_task_list (); | |
2354 | + const int task_list_built = ada_build_task_list (); | |
2355 | ||
2356 | if (!task_list_built) | |
2357 | return; | |
2358 | @@ -1358,13 +1326,10 @@ switch_to_task (struct task_entry *new_t | |
2359 | select_frame (get_current_frame ()); | |
2360 | return ret_code; | |
2361 | } | |
2362 | - else if (task_ptid_get_pid (new_task->task_ptid) != 0) /* ?? */ | |
2363 | - { | |
2364 | - switch_to_thread (task_ptid_get_ptid (new_task->task_ptid)); | |
2365 | - return 0; | |
2366 | - } | |
2367 | + | |
2368 | + switch_to_thread (task_ptid_get_ptid (new_task->task_ptid)); | |
2369 | #endif | |
2370 | - return -1; | |
2371 | + return 0; | |
2372 | } | |
2373 | ||
2374 | /* Print a message telling the user id of the current task. | |
2375 | @@ -1412,7 +1377,7 @@ task_command_1 (char *tidstr, int from_t | |
2376 | static void | |
2377 | task_command (char *tidstr, int from_tty) | |
2378 | { | |
2379 | - const int task_list_built = build_task_list (); | |
2380 | + const int task_list_built = ada_build_task_list (); | |
2381 | ||
2382 | if (!task_list_built) | |
2383 | return; | |
2384 |