1 /* Parser for linespec for the GNU debugger, GDB.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
3 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
32 #include "completer.h"
34 #include "parser-defs.h"
36 #include "objc-lang.h"
39 /* We share this one with symtab.c, but it is not exported widely. */
41 extern char *operator_chars (char *, char **);
43 /* Prototypes for local functions */
45 static void initialize_defaults (struct symtab
**default_symtab
,
48 static void set_flags (char *arg
, int *is_quoted
, char **paren_pointer
);
50 static struct symtabs_and_lines
decode_indirect (char **argptr
);
52 static char *locate_first_half (char **argptr
, int *is_quote_enclosed
);
54 static struct symtabs_and_lines
decode_objc (char **argptr
,
56 struct symtab
*file_symtab
,
60 static struct symtabs_and_lines
decode_compound (char **argptr
,
66 static struct symbol
*lookup_prefix_sym (char **argptr
, char *p
);
68 static struct symtabs_and_lines
find_method (int funfirstline
,
73 struct symbol
*sym_class
);
75 static int collect_methods (char *copy
, struct type
*t
,
76 struct symbol
**sym_arr
);
78 static NORETURN
void cplusplus_error (const char *name
,
80 ATTR_NORETURN
ATTR_FORMAT (printf
, 2, 3);
82 static int total_number_of_methods (struct type
*type
);
84 static int find_methods (struct type
*, char *, struct symbol
**);
86 static int add_matching_methods (int method_counter
, struct type
*t
,
87 struct symbol
**sym_arr
);
89 static int add_constructors (int method_counter
, struct type
*t
,
90 struct symbol
**sym_arr
);
92 static void build_canonical_line_spec (struct symtab_and_line
*,
95 static char *find_toplevel_char (char *s
, char c
);
97 static int is_objc_method_format (const char *s
);
99 static struct symtabs_and_lines
decode_line_2 (struct symbol
*[],
102 static struct symtab
*symtab_from_filename (char **argptr
,
103 char *p
, int is_quote_enclosed
);
106 symtabs_and_lines
decode_all_digits (char **argptr
,
107 struct symtab
*default_symtab
,
110 struct symtab
*file_symtab
,
113 static struct symtabs_and_lines
decode_dollar (char *copy
,
115 struct symtab
*default_symtab
,
117 struct symtab
*file_symtab
);
119 static struct symtabs_and_lines
decode_variable (char *copy
,
122 struct symtab
*file_symtab
);
125 symtabs_and_lines
symbol_found (int funfirstline
,
129 struct symtab
*file_symtab
,
130 struct symtab
*sym_symtab
);
133 symtabs_and_lines
minsym_found (int funfirstline
,
134 struct minimal_symbol
*msymbol
);
136 /* Helper functions. */
138 /* Issue a helpful hint on using the command completion feature on
139 single quoted demangled C++ symbols as part of the completion
143 cplusplus_error (const char *name
, const char *fmt
, ...)
145 struct ui_file
*tmp_stream
;
146 tmp_stream
= mem_fileopen ();
147 make_cleanup_ui_file_delete (tmp_stream
);
151 va_start (args
, fmt
);
152 vfprintf_unfiltered (tmp_stream
, fmt
, args
);
156 while (*name
== '\'')
158 fprintf_unfiltered (tmp_stream
,
159 ("Hint: try '%s<TAB> or '%s<ESC-?>\n"
160 "(Note leading single quote.)"),
162 error_stream (tmp_stream
);
165 /* Return the number of methods described for TYPE, including the
166 methods from types it derives from. This can't be done in the symbol
167 reader because the type of the baseclass might still be stubbed
168 when the definition of the derived class is parsed. */
171 total_number_of_methods (struct type
*type
)
176 CHECK_TYPEDEF (type
);
177 if (TYPE_CPLUS_SPECIFIC (type
) == NULL
)
179 count
= TYPE_NFN_FIELDS_TOTAL (type
);
181 for (n
= 0; n
< TYPE_N_BASECLASSES (type
); n
++)
182 count
+= total_number_of_methods (TYPE_BASECLASS (type
, n
));
187 /* Recursive helper function for decode_line_1.
188 Look for methods named NAME in type T.
189 Return number of matches.
190 Put matches in SYM_ARR, which should have been allocated with
191 a size of total_number_of_methods (T) * sizeof (struct symbol *).
192 Note that this function is g++ specific. */
195 find_methods (struct type
*t
, char *name
, struct symbol
**sym_arr
)
199 char *class_name
= type_name_no_tag (t
);
201 /* Ignore this class if it doesn't have a name. This is ugly, but
202 unless we figure out how to get the physname without the name of
203 the class, then the loop can't do any good. */
205 && (lookup_symbol (class_name
, (struct block
*) NULL
,
206 STRUCT_DOMAIN
, (int *) NULL
,
207 (struct symtab
**) NULL
)))
210 int name_len
= strlen (name
);
214 /* Loop over each method name. At this level, all overloads of a name
215 are counted as a single name. There is an inner loop which loops over
218 for (method_counter
= TYPE_NFN_FIELDS (t
) - 1;
222 char *method_name
= TYPE_FN_FIELDLIST_NAME (t
, method_counter
);
225 if (strncmp (method_name
, "__", 2) == 0 ||
226 strncmp (method_name
, "op", 2) == 0 ||
227 strncmp (method_name
, "type", 4) == 0)
229 if (cplus_demangle_opname (method_name
, dem_opname
, DMGL_ANSI
))
230 method_name
= dem_opname
;
231 else if (cplus_demangle_opname (method_name
, dem_opname
, 0))
232 method_name
= dem_opname
;
235 if (strcmp_iw (name
, method_name
) == 0)
236 /* Find all the overloaded methods with that name. */
237 i1
+= add_matching_methods (method_counter
, t
,
239 else if (strncmp (class_name
, name
, name_len
) == 0
240 && (class_name
[name_len
] == '\0'
241 || class_name
[name_len
] == '<'))
242 i1
+= add_constructors (method_counter
, t
,
247 /* Only search baseclasses if there is no match yet, since names in
248 derived classes override those in baseclasses.
250 FIXME: The above is not true; it is only true of member functions
251 if they have the same number of arguments (??? - section 13.1 of the
252 ARM says the function members are not in the same scope but doesn't
253 really spell out the rules in a way I understand. In any case, if
254 the number of arguments differ this is a case in which we can overload
255 rather than hiding without any problem, and gcc 2.4.5 does overload
256 rather than hiding in this case). */
259 for (ibase
= 0; ibase
< TYPE_N_BASECLASSES (t
); ibase
++)
260 i1
+= find_methods (TYPE_BASECLASS (t
, ibase
), name
, sym_arr
+ i1
);
265 /* Add the symbols associated to methods of the class whose type is T
266 and whose name matches the method indexed by METHOD_COUNTER in the
267 array SYM_ARR. Return the number of methods added. */
270 add_matching_methods (int method_counter
, struct type
*t
,
271 struct symbol
**sym_arr
)
276 for (field_counter
= TYPE_FN_FIELDLIST_LENGTH (t
, method_counter
) - 1;
283 f
= TYPE_FN_FIELDLIST1 (t
, method_counter
);
285 if (TYPE_FN_FIELD_STUB (f
, field_counter
))
289 tmp_name
= gdb_mangle_name (t
,
292 phys_name
= alloca (strlen (tmp_name
) + 1);
293 strcpy (phys_name
, tmp_name
);
297 phys_name
= TYPE_FN_FIELD_PHYSNAME (f
, field_counter
);
299 /* Destructor is handled by caller, don't add it to
301 if (is_destructor_name (phys_name
) != 0)
304 sym_arr
[i1
] = lookup_symbol (phys_name
,
307 (struct symtab
**) NULL
);
312 /* This error message gets printed, but the method
313 still seems to be found
314 fputs_filtered("(Cannot find method ", gdb_stdout);
315 fprintf_symbol_filtered (gdb_stdout, phys_name,
317 DMGL_PARAMS | DMGL_ANSI);
318 fputs_filtered(" - possibly inlined.)\n", gdb_stdout);
326 /* Add the symbols associated to constructors of the class whose type
327 is CLASS_TYPE and which are indexed by by METHOD_COUNTER to the
328 array SYM_ARR. Return the number of methods added. */
331 add_constructors (int method_counter
, struct type
*t
,
332 struct symbol
**sym_arr
)
337 /* For GCC 3.x and stabs, constructors and destructors
338 have names like __base_ctor and __complete_dtor.
339 Check the physname for now if we're looking for a
342 = TYPE_FN_FIELDLIST_LENGTH (t
, method_counter
) - 1;
349 f
= TYPE_FN_FIELDLIST1 (t
, method_counter
);
351 /* GCC 3.x will never produce stabs stub methods, so
352 we don't need to handle this case. */
353 if (TYPE_FN_FIELD_STUB (f
, field_counter
))
355 phys_name
= TYPE_FN_FIELD_PHYSNAME (f
, field_counter
);
356 if (! is_constructor_name (phys_name
))
359 /* If this method is actually defined, include it in the
361 sym_arr
[i1
] = lookup_symbol (phys_name
,
364 (struct symtab
**) NULL
);
372 /* Helper function for decode_line_1.
373 Build a canonical line spec in CANONICAL if it is non-NULL and if
374 the SAL has a symtab.
375 If SYMNAME is non-NULL the canonical line spec is `filename:symname'.
376 If SYMNAME is NULL the line number from SAL is used and the canonical
377 line spec is `filename:linenum'. */
380 build_canonical_line_spec (struct symtab_and_line
*sal
, char *symname
,
383 char **canonical_arr
;
384 char *canonical_name
;
386 struct symtab
*s
= sal
->symtab
;
388 if (s
== (struct symtab
*) NULL
389 || s
->filename
== (char *) NULL
390 || canonical
== (char ***) NULL
)
393 canonical_arr
= (char **) xmalloc (sizeof (char *));
394 *canonical
= canonical_arr
;
396 filename
= s
->filename
;
399 canonical_name
= xmalloc (strlen (filename
) + strlen (symname
) + 2);
400 sprintf (canonical_name
, "%s:%s", filename
, symname
);
404 canonical_name
= xmalloc (strlen (filename
) + 30);
405 sprintf (canonical_name
, "%s:%d", filename
, sal
->line
);
407 canonical_arr
[0] = canonical_name
;
412 /* Find an instance of the character C in the string S that is outside
413 of all parenthesis pairs, single-quoted strings, and double-quoted
414 strings. Also, ignore the char within a template name, like a ','
415 within foo<int, int>. */
418 find_toplevel_char (char *s
, char c
)
420 int quoted
= 0; /* zero if we're not in quotes;
421 '"' if we're in a double-quoted string;
422 '\'' if we're in a single-quoted string. */
423 int depth
= 0; /* Number of unclosed parens we've seen. */
426 for (scan
= s
; *scan
; scan
++)
432 else if (*scan
== '\\' && *(scan
+ 1))
435 else if (*scan
== c
&& ! quoted
&& depth
== 0)
437 else if (*scan
== '"' || *scan
== '\'')
439 else if (*scan
== '(' || *scan
== '<')
441 else if ((*scan
== ')' || *scan
== '>') && depth
> 0)
448 /* Determines if the gives string corresponds to an Objective-C method
449 representation, such as -[Foo bar:] or +[Foo bar]. Objective-C symbols
450 are allowed to have spaces and parentheses in them. */
453 is_objc_method_format (const char *s
)
455 if (s
== NULL
|| *s
== '\0')
457 /* Handle arguments with the format FILENAME:SYMBOL. */
458 if ((s
[0] == ':') && (strchr ("+-", s
[1]) != NULL
)
459 && (s
[2] == '[') && strchr(s
, ']'))
461 /* Handle arguments that are just SYMBOL. */
462 else if ((strchr ("+-", s
[0]) != NULL
) && (s
[1] == '[') && strchr(s
, ']'))
467 /* Given a list of NELTS symbols in SYM_ARR, return a list of lines to
468 operate on (ask user if necessary).
469 If CANONICAL is non-NULL return a corresponding array of mangled names
470 as canonical line specs there. */
472 static struct symtabs_and_lines
473 decode_line_2 (struct symbol
*sym_arr
[], int nelts
, int funfirstline
,
476 struct symtabs_and_lines values
, return_values
;
481 struct cleanup
*old_chain
;
482 char **canonical_arr
= (char **) NULL
;
484 values
.sals
= (struct symtab_and_line
*)
485 alloca (nelts
* sizeof (struct symtab_and_line
));
486 return_values
.sals
= (struct symtab_and_line
*)
487 xmalloc (nelts
* sizeof (struct symtab_and_line
));
488 old_chain
= make_cleanup (xfree
, return_values
.sals
);
492 canonical_arr
= (char **) xmalloc (nelts
* sizeof (char *));
493 make_cleanup (xfree
, canonical_arr
);
494 memset (canonical_arr
, 0, nelts
* sizeof (char *));
495 *canonical
= canonical_arr
;
499 printf_unfiltered ("[0] cancel\n[1] all\n");
502 init_sal (&return_values
.sals
[i
]); /* Initialize to zeroes. */
503 init_sal (&values
.sals
[i
]);
504 if (sym_arr
[i
] && SYMBOL_CLASS (sym_arr
[i
]) == LOC_BLOCK
)
506 values
.sals
[i
] = find_function_start_sal (sym_arr
[i
], funfirstline
);
507 if (values
.sals
[i
].symtab
)
508 printf_unfiltered ("[%d] %s at %s:%d\n",
510 SYMBOL_PRINT_NAME (sym_arr
[i
]),
511 values
.sals
[i
].symtab
->filename
,
512 values
.sals
[i
].line
);
514 printf_unfiltered ("[%d] %s at ?FILE:%d [No symtab? Probably broken debug info...]\n",
516 SYMBOL_PRINT_NAME (sym_arr
[i
]),
517 values
.sals
[i
].line
);
521 printf_unfiltered ("?HERE\n");
525 prompt
= getenv ("PS2");
530 args
= command_line_input (prompt
, 0, "overload-choice");
532 if (args
== 0 || *args
== 0)
533 error_no_arg ("one or more choice numbers");
541 while (*arg1
>= '0' && *arg1
<= '9')
543 if (*arg1
&& *arg1
!= ' ' && *arg1
!= '\t')
544 error ("Arguments must be choice numbers.");
554 for (i
= 0; i
< nelts
; i
++)
556 if (canonical_arr
[i
] == NULL
)
558 symname
= DEPRECATED_SYMBOL_NAME (sym_arr
[i
]);
559 canonical_arr
[i
] = savestring (symname
, strlen (symname
));
563 memcpy (return_values
.sals
, values
.sals
,
564 (nelts
* sizeof (struct symtab_and_line
)));
565 return_values
.nelts
= nelts
;
566 discard_cleanups (old_chain
);
567 return return_values
;
570 if (num
>= nelts
+ 2)
572 printf_unfiltered ("No choice number %d.\n", num
);
577 if (values
.sals
[num
].pc
)
581 symname
= DEPRECATED_SYMBOL_NAME (sym_arr
[num
]);
582 make_cleanup (xfree
, symname
);
583 canonical_arr
[i
] = savestring (symname
, strlen (symname
));
585 return_values
.sals
[i
++] = values
.sals
[num
];
586 values
.sals
[num
].pc
= 0;
590 printf_unfiltered ("duplicate request for %d ignored.\n", num
);
595 while (*args
== ' ' || *args
== '\t')
598 return_values
.nelts
= i
;
599 discard_cleanups (old_chain
);
600 return return_values
;
603 /* The parser of linespec itself. */
605 /* Parse a string that specifies a line number.
606 Pass the address of a char * variable; that variable will be
607 advanced over the characters actually parsed.
611 LINENUM -- that line number in current file. PC returned is 0.
612 FILE:LINENUM -- that line in that file. PC returned is 0.
613 FUNCTION -- line number of openbrace of that function.
614 PC returned is the start of the function.
615 VARIABLE -- line number of definition of that variable.
617 FILE:FUNCTION -- likewise, but prefer functions in that file.
618 *EXPR -- line in which address EXPR appears.
620 This may all be followed by an "if EXPR", which we ignore.
622 FUNCTION may be an undebuggable function found in minimal symbol table.
624 If the argument FUNFIRSTLINE is nonzero, we want the first line
625 of real code inside a function when a function is specified, and it is
626 not OK to specify a variable or type to get its line number.
628 DEFAULT_SYMTAB specifies the file to use if none is specified.
629 It defaults to current_source_symtab.
630 DEFAULT_LINE specifies the line number to use for relative
631 line numbers (that start with signs). Defaults to current_source_line.
632 If CANONICAL is non-NULL, store an array of strings containing the canonical
633 line specs there if necessary. Currently overloaded member functions and
634 line numbers or static functions without a filename yield a canonical
635 line spec. The array and the line spec strings are allocated on the heap,
636 it is the callers responsibility to free them.
638 Note that it is possible to return zero for the symtab
639 if no file is validly specified. Callers must check that.
640 Also, the line number returned may be invalid. */
642 /* We allow single quotes in various places. This is a hideous
643 kludge, which exists because the completer can't yet deal with the
644 lack of single quotes. FIXME: write a linespec_completer which we
645 can use as appropriate instead of make_symbol_completion_list. */
647 struct symtabs_and_lines
648 decode_line_1 (char **argptr
, int funfirstline
, struct symtab
*default_symtab
,
649 int default_line
, char ***canonical
)
653 /* If a file name is specified, this is its symtab. */
654 struct symtab
*file_symtab
= NULL
;
657 /* This is NULL if there are no parens in *ARGPTR, or a pointer to
658 the closing parenthesis if there are parens. */
660 /* This says whether or not something in *ARGPTR is quoted with
661 completer_quotes (i.e. with single quotes). */
663 /* Is part of *ARGPTR is enclosed in double quotes? */
664 int is_quote_enclosed
;
665 int is_objc_method
= 0;
666 char *saved_arg
= *argptr
;
668 /* Defaults have defaults. */
670 initialize_defaults (&default_symtab
, &default_line
);
672 /* See if arg is *PC. */
675 return decode_indirect (argptr
);
677 /* Set various flags. 'paren_pointer' is important for overload
678 checking, where we allow things like:
679 (gdb) break c::f(int)
682 set_flags (*argptr
, &is_quoted
, &paren_pointer
);
684 /* Check to see if it's a multipart linespec (with colons or
687 /* Locate the end of the first half of the linespec. */
689 p
= locate_first_half (argptr
, &is_quote_enclosed
);
691 /* Check if this is an Objective-C method (anything that starts with
692 a '+' or '-' and a '['). */
693 if (is_objc_method_format (p
))
696 paren_pointer
= NULL
; /* Just a category name. Ignore it. */
699 /* Check if the symbol could be an Objective-C selector. */
702 struct symtabs_and_lines values
;
703 values
= decode_objc (argptr
, funfirstline
, NULL
,
704 canonical
, saved_arg
);
705 if (values
.sals
!= NULL
)
709 /* Does it look like there actually were two parts? */
711 if ((p
[0] == ':' || p
[0] == '.') && paren_pointer
== NULL
)
714 *argptr
= *argptr
+ 1;
716 /* Is it a C++ or Java compound data structure? */
718 if (p
[0] == '.' || p
[1] == ':')
719 return decode_compound (argptr
, funfirstline
, canonical
,
722 /* No, the first part is a filename; set s to be that file's
723 symtab. Also, move argptr past the filename. */
725 file_symtab
= symtab_from_filename (argptr
, p
, is_quote_enclosed
);
728 /* No one really seems to know why this was added. It certainly
729 breaks the command line, though, whenever the passed
730 name is of the form ClassName::Method. This bit of code
731 singles out the class name, and if funfirstline is set (for
732 example, you are setting a breakpoint at this function),
733 you get an error. This did not occur with earlier
734 verions, so I am ifdef'ing this out. 3/29/99 */
737 /* Check if what we have till now is a symbol name */
739 /* We may be looking at a template instantiation such
740 as "foo<int>". Check here whether we know about it,
741 instead of falling through to the code below which
742 handles ordinary function names, because that code
743 doesn't like seeing '<' and '>' in a name -- the
744 skip_quoted call doesn't go past them. So see if we
745 can figure it out right now. */
747 copy
= (char *) alloca (p
- *argptr
+ 1);
748 memcpy (copy
, *argptr
, p
- *argptr
);
749 copy
[p
- *argptr
] = '\000';
750 sym
= lookup_symbol (copy
, 0, VAR_DOMAIN
, 0, &sym_symtab
);
753 *argptr
= (*p
== '\'') ? p
+ 1 : p
;
754 return symbol_found (funfirstline
, canonical
, copy
, sym
,
757 /* Otherwise fall out from here and go to file/line spec
762 /* S is specified file's symtab, or 0 if no file specified.
763 arg no longer contains the file name. */
765 /* Check whether arg is all digits (and sign). */
768 if (*q
== '-' || *q
== '+')
770 while (*q
>= '0' && *q
<= '9')
773 if (q
!= *argptr
&& (*q
== 0 || *q
== ' ' || *q
== '\t' || *q
== ','))
774 /* We found a token consisting of all digits -- at least one digit. */
775 return decode_all_digits (argptr
, default_symtab
, default_line
,
776 canonical
, file_symtab
, q
);
778 /* Arg token is not digits => try it as a variable name
779 Find the next token (everything up to end or next whitespace). */
781 if (**argptr
== '$') /* May be a convenience variable. */
782 /* One or two $ chars possible. */
783 p
= skip_quoted (*argptr
+ (((*argptr
)[1] == '$') ? 2 : 1));
786 p
= skip_quoted (*argptr
);
788 error ("Unmatched single quote.");
790 else if (is_objc_method
)
792 /* allow word separators in method names for Obj-C */
793 p
= skip_quoted_chars (*argptr
, NULL
, "");
795 else if (paren_pointer
!= NULL
)
797 p
= paren_pointer
+ 1;
801 p
= skip_quoted (*argptr
);
804 copy
= (char *) alloca (p
- *argptr
+ 1);
805 memcpy (copy
, *argptr
, p
- *argptr
);
806 copy
[p
- *argptr
] = '\0';
809 && copy
[0] == copy
[p
- *argptr
- 1]
810 && strchr (get_gdb_completer_quote_characters (), copy
[0]) != NULL
)
812 copy
[p
- *argptr
- 1] = '\0';
815 while (*p
== ' ' || *p
== '\t')
819 /* If it starts with $: may be a legitimate variable or routine name
820 (e.g. HP-UX millicode routines such as $$dyncall), or it may
821 be history value, or it may be a convenience variable. */
824 return decode_dollar (copy
, funfirstline
, default_symtab
,
825 canonical
, file_symtab
);
827 /* Look up that token as a variable.
828 If file specified, use that file's per-file block to start with. */
830 return decode_variable (copy
, funfirstline
, canonical
, file_symtab
);
835 /* Now, more helper functions for decode_line_1. Some conventions
836 that these functions follow:
838 Decode_line_1 typically passes along some of its arguments or local
839 variables to the subfunctions. It passes the variables by
840 reference if they are modified by the subfunction, and by value
843 Some of the functions have side effects that don't arise from
844 variables that are passed by reference. In particular, if a
845 function is passed ARGPTR as an argument, it modifies what ARGPTR
846 points to; typically, it advances *ARGPTR past whatever substring
847 it has just looked at. (If it doesn't modify *ARGPTR, then the
848 function gets passed *ARGPTR instead, which is then called ARG: see
849 set_flags, for example.) Also, functions that return a struct
850 symtabs_and_lines may modify CANONICAL, as in the description of
853 If a function returns a struct symtabs_and_lines, then that struct
854 will immediately make its way up the call chain to be returned by
855 decode_line_1. In particular, all of the functions decode_XXX
856 calculate the appropriate struct symtabs_and_lines, under the
857 assumption that their argument is of the form XXX. */
859 /* First, some functions to initialize stuff at the beggining of the
863 initialize_defaults (struct symtab
**default_symtab
, int *default_line
)
865 if (*default_symtab
== 0)
867 /* Use whatever we have for the default source line. We don't use
868 get_current_or_default_symtab_and_line as it can recurse and call
870 struct symtab_and_line cursal
=
871 get_current_source_symtab_and_line ();
873 *default_symtab
= cursal
.symtab
;
874 *default_line
= cursal
.line
;
879 set_flags (char *arg
, int *is_quoted
, char **paren_pointer
)
884 /* 'has_if' is for the syntax:
885 (gdb) break foo if (a==b)
887 if ((ii
= strstr (arg
, " if ")) != NULL
||
888 (ii
= strstr (arg
, "\tif ")) != NULL
||
889 (ii
= strstr (arg
, " if\t")) != NULL
||
890 (ii
= strstr (arg
, "\tif\t")) != NULL
||
891 (ii
= strstr (arg
, " if(")) != NULL
||
892 (ii
= strstr (arg
, "\tif( ")) != NULL
)
894 /* Temporarily zap out "if (condition)" to not confuse the
895 parenthesis-checking code below. This is undone below. Do not
903 && strchr (get_gdb_completer_quote_characters (),
906 *paren_pointer
= strchr (arg
, '(');
907 if (*paren_pointer
!= NULL
)
908 *paren_pointer
= strrchr (*paren_pointer
, ')');
910 /* Now that we're safely past the paren_pointer check, put back " if
911 (condition)" so outer layers can see it. */
918 /* Decode arg of the form *PC. */
920 static struct symtabs_and_lines
921 decode_indirect (char **argptr
)
923 struct symtabs_and_lines values
;
927 pc
= parse_and_eval_address_1 (argptr
);
929 values
.sals
= (struct symtab_and_line
*)
930 xmalloc (sizeof (struct symtab_and_line
));
933 values
.sals
[0] = find_pc_line (pc
, 0);
934 values
.sals
[0].pc
= pc
;
935 values
.sals
[0].section
= find_pc_overlay (pc
);
942 /* Locate the first half of the linespec, ending in a colon, period,
943 or whitespace. (More or less.) Also, check to see if *ARGPTR is
944 enclosed in double quotes; if so, set is_quote_enclosed, advance
945 ARGPTR past that and zero out the trailing double quote. */
948 locate_first_half (char **argptr
, int *is_quote_enclosed
)
954 /* Maybe we were called with a line range FILENAME:LINENUM,FILENAME:LINENUM
955 and we must isolate the first half. Outer layers will call again later
958 Don't count commas that appear in argument lists of overloaded
959 functions, or in quoted strings. It's stupid to go to this much
960 trouble when the rest of the function is such an obvious roach hotel. */
961 ii
= find_toplevel_char (*argptr
, ',');
962 has_comma
= (ii
!= 0);
964 /* Temporarily zap out second half to not confuse the code below.
965 This is undone below. Do not change ii!! */
971 /* Maybe arg is FILE : LINENUM or FILE : FUNCTION. May also be
972 CLASS::MEMBER, or NAMESPACE::NAME. Look for ':', but ignore
978 *is_quote_enclosed
= 1;
983 *is_quote_enclosed
= 0;
988 char *temp_end
= find_template_name_end (p
);
990 error ("malformed template specification in command");
993 /* Check for a colon and a plus or minus and a [ (which
994 indicates an Objective-C method) */
995 if (is_objc_method_format (p
))
999 /* Check for the end of the first half of the linespec. End of
1000 line, a tab, a double colon or the last single colon, or a
1001 space. But if enclosed in double quotes we do not break on
1006 && ((p
[1] == ':') || (strchr (p
+ 1, ':') == NULL
)))
1007 || ((p
[0] == ' ') && !*is_quote_enclosed
))
1009 if (p
[0] == '.' && strchr (p
, ':') == NULL
)
1011 /* Java qualified method. Find the *last* '.', since the
1012 others are package qualifiers. */
1013 for (p1
= p
; *p1
; p1
++)
1021 while (p
[0] == ' ' || p
[0] == '\t')
1024 /* If the closing double quote was left at the end, remove it. */
1025 if (*is_quote_enclosed
)
1027 char *closing_quote
= strchr (p
- 1, '"');
1028 if (closing_quote
&& closing_quote
[1] == '\0')
1029 *closing_quote
= '\0';
1032 /* Now that we've safely parsed the first half, put back ',' so
1033 outer layers can see it. */
1042 /* Here's where we recognise an Objective-C Selector. An Objective C
1043 selector may be implemented by more than one class, therefore it
1044 may represent more than one method/function. This gives us a
1045 situation somewhat analogous to C++ overloading. If there's more
1046 than one method that could represent the selector, then use some of
1047 the existing C++ code to let the user choose one. */
1049 struct symtabs_and_lines
1050 decode_objc (char **argptr
, int funfirstline
, struct symtab
*file_symtab
,
1051 char ***canonical
, char *saved_arg
)
1053 struct symtabs_and_lines values
;
1054 struct symbol
**sym_arr
= NULL
;
1055 struct symbol
*sym
= NULL
;
1057 struct block
*block
= NULL
;
1064 if (file_symtab
!= NULL
)
1065 block
= BLOCKVECTOR_BLOCK (BLOCKVECTOR (file_symtab
), STATIC_BLOCK
);
1067 block
= get_selected_block (0);
1069 copy
= find_imps (file_symtab
, block
, *argptr
, NULL
, &i1
, &i2
);
1073 sym_arr
= (struct symbol
**) alloca ((i1
+ 1) * sizeof (struct symbol
*));
1076 copy
= find_imps (file_symtab
, block
, *argptr
, sym_arr
, &i1
, &i2
);
1080 /* i1 now represents the TOTAL number of matches found.
1081 i2 represents how many HIGH-LEVEL (struct symbol) matches,
1082 which will come first in the sym_arr array. Any low-level
1083 (minimal_symbol) matches will follow those. */
1089 /* Already a struct symbol. */
1094 sym
= find_pc_function (SYMBOL_VALUE_ADDRESS (sym_arr
[0]));
1095 if ((sym
!= NULL
) && strcmp (SYMBOL_LINKAGE_NAME (sym_arr
[0]), SYMBOL_LINKAGE_NAME (sym
)) != 0)
1097 warning ("debugging symbol \"%s\" does not match selector; ignoring", SYMBOL_LINKAGE_NAME (sym
));
1102 values
.sals
= (struct symtab_and_line
*) xmalloc (sizeof (struct symtab_and_line
));
1105 if (sym
&& SYMBOL_CLASS (sym
) == LOC_BLOCK
)
1107 /* Canonicalize this, so it remains resolved for dylib loads. */
1108 values
.sals
[0] = find_function_start_sal (sym
, funfirstline
);
1109 build_canonical_line_spec (values
.sals
, SYMBOL_NATURAL_NAME (sym
), canonical
);
1113 /* The only match was a non-debuggable symbol. */
1114 values
.sals
[0].symtab
= 0;
1115 values
.sals
[0].line
= 0;
1116 values
.sals
[0].end
= 0;
1117 values
.sals
[0].pc
= SYMBOL_VALUE_ADDRESS (sym_arr
[0]);
1124 /* More than one match. The user must choose one or more. */
1125 return decode_line_2 (sym_arr
, i2
, funfirstline
, canonical
);
1131 /* This handles C++ and Java compound data structures. P should point
1132 at the first component separator, i.e. double-colon or period. */
1134 static struct symtabs_and_lines
1135 decode_compound (char **argptr
, int funfirstline
, char ***canonical
,
1136 char *saved_arg
, char *p
)
1138 struct symtabs_and_lines values
;
1143 char *saved_arg2
= *argptr
;
1146 /* The symtab that SYM was found in. */
1147 struct symtab
*sym_symtab
;
1149 struct symbol
*sym_class
;
1150 struct symbol
**sym_arr
;
1153 /* First check for "global" namespace specification,
1154 of the form "::foo". If found, skip over the colons
1155 and jump to normal symbol processing. */
1157 && ((*argptr
== p
) || (p
[-1] == ' ') || (p
[-1] == '\t')))
1160 /* We have what looks like a class or namespace
1161 scope specification (A::B), possibly with many
1162 levels of namespaces or classes (A::B::C::D).
1164 Some versions of the HP ANSI C++ compiler (as also possibly
1165 other compilers) generate class/function/member names with
1166 embedded double-colons if they are inside namespaces. To
1167 handle this, we loop a few times, considering larger and
1168 larger prefixes of the string as though they were single
1169 symbols. So, if the initially supplied string is
1170 A::B::C::D::foo, we have to look up "A", then "A::B",
1171 then "A::B::C", then "A::B::C::D", and finally
1172 "A::B::C::D::foo" as single, monolithic symbols, because
1173 A, B, C or D may be namespaces.
1175 Note that namespaces can nest only inside other
1176 namespaces, and not inside classes. So we need only
1177 consider *prefixes* of the string; there is no need to look up
1178 "B::C" separately as a symbol in the previous example. */
1180 p2
= p
; /* Save for restart. */
1183 sym_class
= lookup_prefix_sym (argptr
, p
);
1186 (t
= check_typedef (SYMBOL_TYPE (sym_class
)),
1187 (TYPE_CODE (t
) == TYPE_CODE_STRUCT
1188 || TYPE_CODE (t
) == TYPE_CODE_UNION
)))
1190 /* Arg token is not digits => try it as a function name.
1191 Find the next token (everything up to end or next
1194 && strchr (get_gdb_completer_quote_characters (),
1197 p
= skip_quoted (*argptr
);
1198 *argptr
= *argptr
+ 1;
1203 while (*p
&& *p
!= ' ' && *p
!= '\t' && *p
!= ',' && *p
!= ':')
1207 q = operator_chars (*argptr, &q1);
1211 char *tmp = alloca (q1 - q + 1);
1212 memcpy (tmp, q, q1 - q);
1214 opname = cplus_mangle_opname (tmp, DMGL_ANSI);
1217 cplusplus_error (saved_arg, "no mangling for \"%s\"\n", tmp);
1219 copy = (char*) alloca (3 + strlen(opname));
1220 sprintf (copy, "__%s", opname);
1226 copy
= (char *) alloca (p
- *argptr
+ 1);
1227 memcpy (copy
, *argptr
, p
- *argptr
);
1228 copy
[p
- *argptr
] = '\0';
1230 && copy
[p
- *argptr
- 1]
1231 && strchr (get_gdb_completer_quote_characters (),
1232 copy
[p
- *argptr
- 1]) != NULL
)
1233 copy
[p
- *argptr
- 1] = '\0';
1236 /* No line number may be specified. */
1237 while (*p
== ' ' || *p
== '\t')
1241 return find_method (funfirstline
, canonical
, saved_arg
,
1242 copy
, t
, sym_class
);
1245 /* Move pointer up to next possible class/namespace token. */
1246 p
= p2
+ 1; /* Restart with old value +1. */
1247 /* Move pointer ahead to next double-colon. */
1248 while (*p
&& (p
[0] != ' ') && (p
[0] != '\t') && (p
[0] != '\''))
1252 temp_end
= find_template_name_end (p
);
1254 error ("malformed template specification in command");
1257 else if ((p
[0] == ':') && (p
[1] == ':'))
1258 break; /* Found double-colon. */
1264 break; /* Out of the while (1). */
1266 p2
= p
; /* Save restart for next time around. */
1267 *argptr
= saved_arg2
; /* Restore argptr. */
1270 /* Last chance attempt -- check entire name as a symbol. Use "copy"
1271 in preparation for jumping out of this block, to be consistent
1272 with usage following the jump target. */
1273 copy
= (char *) alloca (p
- saved_arg2
+ 1);
1274 memcpy (copy
, saved_arg2
, p
- saved_arg2
);
1275 /* Note: if is_quoted should be true, we snuff out quote here
1277 copy
[p
- saved_arg2
] = '\000';
1278 /* Set argptr to skip over the name. */
1279 *argptr
= (*p
== '\'') ? p
+ 1 : p
;
1280 /* Look up entire name */
1281 sym
= lookup_symbol (copy
, 0, VAR_DOMAIN
, 0, &sym_symtab
);
1283 return symbol_found (funfirstline
, canonical
, copy
, sym
,
1286 /* Couldn't find any interpretation as classes/namespaces, so give
1287 up. The quotes are important if copy is empty. */
1288 cplusplus_error (saved_arg
,
1289 "Can't find member of namespace, class, struct, or union named \"%s\"\n",
1293 /* Next come some helper functions for decode_compound. */
1295 /* Return the symbol corresponding to the substring of *ARGPTR ending
1296 at P, allowing whitespace. Also, advance *ARGPTR past the symbol
1297 name in question, the compound object separator ("::" or "."), and
1300 static struct symbol
*
1301 lookup_prefix_sym (char **argptr
, char *p
)
1306 /* Extract the class name. */
1308 while (p
!= *argptr
&& p
[-1] == ' ')
1310 copy
= (char *) alloca (p
- *argptr
+ 1);
1311 memcpy (copy
, *argptr
, p
- *argptr
);
1312 copy
[p
- *argptr
] = 0;
1314 /* Discard the class name from the arg. */
1315 p
= p1
+ (p1
[0] == ':' ? 2 : 1);
1316 while (*p
== ' ' || *p
== '\t')
1320 return lookup_symbol (copy
, 0, STRUCT_DOMAIN
, 0,
1321 (struct symtab
**) NULL
);
1324 /* This finds the method COPY in the class whose type is T and whose
1325 symbol is SYM_CLASS. */
1327 static struct symtabs_and_lines
1328 find_method (int funfirstline
, char ***canonical
, char *saved_arg
,
1329 char *copy
, struct type
*t
, struct symbol
*sym_class
)
1331 struct symtabs_and_lines values
;
1332 struct symbol
*sym
= 0;
1333 int i1
; /* Counter for the symbol array. */
1334 struct symbol
**sym_arr
= alloca (total_number_of_methods (t
)
1335 * sizeof (struct symbol
*));
1337 /* Find all methods with a matching name, and put them in
1340 i1
= collect_methods (copy
, t
, sym_arr
);
1344 /* There is exactly one field with that name. */
1347 if (sym
&& SYMBOL_CLASS (sym
) == LOC_BLOCK
)
1349 values
.sals
= (struct symtab_and_line
*)
1350 xmalloc (sizeof (struct symtab_and_line
));
1352 values
.sals
[0] = find_function_start_sal (sym
,
1363 /* There is more than one field with that name
1364 (overloaded). Ask the user which one to use. */
1365 return decode_line_2 (sym_arr
, i1
, funfirstline
, canonical
);
1371 if (is_operator_name (copy
))
1373 tmp
= (char *) alloca (strlen (copy
+ 3) + 9);
1374 strcpy (tmp
, "operator ");
1375 strcat (tmp
, copy
+ 3);
1380 cplusplus_error (saved_arg
,
1381 "the class `%s' does not have destructor defined\n",
1382 SYMBOL_PRINT_NAME (sym_class
));
1384 cplusplus_error (saved_arg
,
1385 "the class %s does not have any method named %s\n",
1386 SYMBOL_PRINT_NAME (sym_class
), tmp
);
1390 /* Find all methods named COPY in the class whose type is T, and put
1391 them in SYM_ARR. Return the number of methods found. */
1394 collect_methods (char *copy
, struct type
*t
,
1395 struct symbol
**sym_arr
)
1397 int i1
= 0; /* Counter for the symbol array. */
1399 if (destructor_name_p (copy
, t
))
1401 /* Destructors are a special case. */
1402 int m_index
, f_index
;
1404 if (get_destructor_fn_field (t
, &m_index
, &f_index
))
1406 struct fn_field
*f
= TYPE_FN_FIELDLIST1 (t
, m_index
);
1409 lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f
, f_index
),
1410 NULL
, VAR_DOMAIN
, (int *) NULL
,
1411 (struct symtab
**) NULL
);
1417 i1
= find_methods (t
, copy
, sym_arr
);
1424 /* Return the symtab associated to the filename given by the substring
1425 of *ARGPTR ending at P, and advance ARGPTR past that filename. */
1427 static struct symtab
*
1428 symtab_from_filename (char **argptr
, char *p
, int is_quote_enclosed
)
1432 struct symtab
*file_symtab
;
1435 while (p
!= *argptr
&& p
[-1] == ' ')
1437 if ((*p
== '"') && is_quote_enclosed
)
1439 copy
= (char *) alloca (p
- *argptr
+ 1);
1440 memcpy (copy
, *argptr
, p
- *argptr
);
1441 /* It may have the ending quote right after the file name. */
1442 if (is_quote_enclosed
&& copy
[p
- *argptr
- 1] == '"')
1443 copy
[p
- *argptr
- 1] = 0;
1445 copy
[p
- *argptr
] = 0;
1447 /* Find that file's data. */
1448 file_symtab
= lookup_symtab (copy
);
1449 if (file_symtab
== 0)
1451 if (!have_full_symbols () && !have_partial_symbols ())
1452 error ("No symbol table is loaded. Use the \"file\" command.");
1453 error ("No source file named %s.", copy
);
1456 /* Discard the file name from the arg. */
1458 while (*p
== ' ' || *p
== '\t')
1467 /* This decodes a line where the argument is all digits (possibly
1468 preceded by a sign). Q should point to the end of those digits;
1469 the other arguments are as usual. */
1471 static struct symtabs_and_lines
1472 decode_all_digits (char **argptr
, struct symtab
*default_symtab
,
1473 int default_line
, char ***canonical
,
1474 struct symtab
*file_symtab
, char *q
)
1477 struct symtabs_and_lines values
;
1478 struct symtab_and_line val
;
1486 /* We might need a canonical line spec if no file was specified. */
1487 int need_canonical
= (file_symtab
== 0) ? 1 : 0;
1491 /* This is where we need to make sure that we have good defaults.
1492 We must guarantee that this section of code is never executed
1493 when we are called with just a function name, since
1494 set_default_source_symtab_and_line uses
1495 select_source_symtab that calls us with such an argument. */
1497 if (file_symtab
== 0 && default_symtab
== 0)
1499 /* Make sure we have at least a default source file. */
1500 set_default_source_symtab_and_line ();
1501 initialize_defaults (&default_symtab
, &default_line
);
1504 if (**argptr
== '+')
1505 sign
= plus
, (*argptr
)++;
1506 else if (**argptr
== '-')
1507 sign
= minus
, (*argptr
)++;
1508 val
.line
= atoi (*argptr
);
1514 if (file_symtab
== 0)
1515 val
.line
= default_line
+ val
.line
;
1520 if (file_symtab
== 0)
1521 val
.line
= default_line
- val
.line
;
1526 break; /* No need to adjust val.line. */
1529 while (*q
== ' ' || *q
== '\t')
1532 if (file_symtab
== 0)
1533 file_symtab
= default_symtab
;
1535 /* It is possible that this source file has more than one symtab,
1536 and that the new line number specification has moved us from the
1537 default (in file_symtab) to a new one. */
1538 val
.symtab
= find_line_symtab (file_symtab
, val
.line
, NULL
, NULL
);
1539 if (val
.symtab
== 0)
1540 val
.symtab
= file_symtab
;
1543 values
.sals
= (struct symtab_and_line
*)
1544 xmalloc (sizeof (struct symtab_and_line
));
1545 values
.sals
[0] = val
;
1548 build_canonical_line_spec (values
.sals
, NULL
, canonical
);
1554 /* Decode a linespec starting with a dollar sign. */
1556 static struct symtabs_and_lines
1557 decode_dollar (char *copy
, int funfirstline
, struct symtab
*default_symtab
,
1558 char ***canonical
, struct symtab
*file_symtab
)
1562 int need_canonical
= 0;
1563 struct symtabs_and_lines values
;
1564 struct symtab_and_line val
;
1567 /* The symtab that SYM was found in. */
1568 struct symtab
*sym_symtab
;
1569 struct minimal_symbol
*msymbol
;
1571 p
= (copy
[1] == '$') ? copy
+ 2 : copy
+ 1;
1572 while (*p
>= '0' && *p
<= '9')
1574 if (!*p
) /* Reached end of token without hitting non-digit. */
1576 /* We have a value history reference. */
1577 sscanf ((copy
[1] == '$') ? copy
+ 2 : copy
+ 1, "%d", &index
);
1578 valx
= access_value_history ((copy
[1] == '$') ? -index
: index
);
1579 if (TYPE_CODE (VALUE_TYPE (valx
)) != TYPE_CODE_INT
)
1580 error ("History values used in line specs must have integer values.");
1584 /* Not all digits -- may be user variable/function or a
1585 convenience variable. */
1587 /* Look up entire name as a symbol first. */
1588 sym
= lookup_symbol (copy
, 0, VAR_DOMAIN
, 0, &sym_symtab
);
1589 file_symtab
= (struct symtab
*) 0;
1591 /* Symbol was found --> jump to normal symbol processing. */
1593 return symbol_found (funfirstline
, canonical
, copy
, sym
,
1596 /* If symbol was not found, look in minimal symbol tables. */
1597 msymbol
= lookup_minimal_symbol (copy
, NULL
, NULL
);
1598 /* Min symbol was found --> jump to minsym processing. */
1600 return minsym_found (funfirstline
, msymbol
);
1602 /* Not a user variable or function -- must be convenience variable. */
1603 need_canonical
= (file_symtab
== 0) ? 1 : 0;
1604 valx
= value_of_internalvar (lookup_internalvar (copy
+ 1));
1605 if (TYPE_CODE (VALUE_TYPE (valx
)) != TYPE_CODE_INT
)
1606 error ("Convenience variables used in line specs must have integer values.");
1611 /* Either history value or convenience value from above, in valx. */
1612 val
.symtab
= file_symtab
? file_symtab
: default_symtab
;
1613 val
.line
= value_as_long (valx
);
1616 values
.sals
= (struct symtab_and_line
*) xmalloc (sizeof val
);
1617 values
.sals
[0] = val
;
1621 build_canonical_line_spec (values
.sals
, NULL
, canonical
);
1628 /* Decode a linespec that's a variable. If FILE_SYMTAB is non-NULL,
1629 look in that symtab's static variables first. */
1631 static struct symtabs_and_lines
1632 decode_variable (char *copy
, int funfirstline
, char ***canonical
,
1633 struct symtab
*file_symtab
)
1636 /* The symtab that SYM was found in. */
1637 struct symtab
*sym_symtab
;
1639 struct minimal_symbol
*msymbol
;
1641 sym
= lookup_symbol (copy
,
1643 ? BLOCKVECTOR_BLOCK (BLOCKVECTOR (file_symtab
),
1645 : get_selected_block (0)),
1646 VAR_DOMAIN
, 0, &sym_symtab
);
1649 return symbol_found (funfirstline
, canonical
, copy
, sym
,
1650 file_symtab
, sym_symtab
);
1652 msymbol
= lookup_minimal_symbol (copy
, NULL
, NULL
);
1654 if (msymbol
!= NULL
)
1655 return minsym_found (funfirstline
, msymbol
);
1657 if (!have_full_symbols () &&
1658 !have_partial_symbols () && !have_minimal_symbols ())
1659 error ("No symbol table is loaded. Use the \"file\" command.");
1661 error ("Function \"%s\" not defined.", copy
);
1667 /* Now come some functions that are called from multiple places within
1670 /* We've found a symbol SYM to associate with our linespec; build a
1671 corresponding struct symtabs_and_lines. */
1673 static struct symtabs_and_lines
1674 symbol_found (int funfirstline
, char ***canonical
, char *copy
,
1675 struct symbol
*sym
, struct symtab
*file_symtab
,
1676 struct symtab
*sym_symtab
)
1678 struct symtabs_and_lines values
;
1680 if (SYMBOL_CLASS (sym
) == LOC_BLOCK
)
1682 /* Arg is the name of a function */
1683 values
.sals
= (struct symtab_and_line
*)
1684 xmalloc (sizeof (struct symtab_and_line
));
1685 values
.sals
[0] = find_function_start_sal (sym
, funfirstline
);
1688 /* Don't use the SYMBOL_LINE; if used at all it points to
1689 the line containing the parameters or thereabouts, not
1690 the first line of code. */
1692 /* We might need a canonical line spec if it is a static
1694 if (file_symtab
== 0)
1696 struct blockvector
*bv
= BLOCKVECTOR (sym_symtab
);
1697 struct block
*b
= BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
);
1698 if (lookup_block_symbol (b
, copy
, NULL
, VAR_DOMAIN
) != NULL
)
1699 build_canonical_line_spec (values
.sals
, copy
, canonical
);
1706 error ("\"%s\" is not a function", copy
);
1707 else if (SYMBOL_LINE (sym
) != 0)
1709 /* We know its line number. */
1710 values
.sals
= (struct symtab_and_line
*)
1711 xmalloc (sizeof (struct symtab_and_line
));
1713 memset (&values
.sals
[0], 0, sizeof (values
.sals
[0]));
1714 values
.sals
[0].symtab
= sym_symtab
;
1715 values
.sals
[0].line
= SYMBOL_LINE (sym
);
1719 /* This can happen if it is compiled with a compiler which doesn't
1720 put out line numbers for variables. */
1721 /* FIXME: Shouldn't we just set .line and .symtab to zero
1722 and return? For example, "info line foo" could print
1724 error ("Line number not known for symbol \"%s\"", copy
);
1728 /* We've found a minimal symbol MSYMBOL to associate with our
1729 linespec; build a corresponding struct symtabs_and_lines. */
1731 static struct symtabs_and_lines
1732 minsym_found (int funfirstline
, struct minimal_symbol
*msymbol
)
1734 struct symtabs_and_lines values
;
1736 values
.sals
= (struct symtab_and_line
*)
1737 xmalloc (sizeof (struct symtab_and_line
));
1738 values
.sals
[0] = find_pc_sect_line (SYMBOL_VALUE_ADDRESS (msymbol
),
1739 (struct sec
*) 0, 0);
1740 values
.sals
[0].section
= SYMBOL_BFD_SECTION (msymbol
);
1743 values
.sals
[0].pc
+= FUNCTION_START_OFFSET
;
1744 values
.sals
[0].pc
= SKIP_PROLOGUE (values
.sals
[0].pc
);
This page took 0.064286 seconds and 4 git commands to generate.