OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [linespec.c] - Blame information for rev 227

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
/* Parser for linespec for the GNU debugger, GDB.
2
 
3
   Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
4
   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008,
5
   2009, 2010 Free Software Foundation, Inc.
6
 
7
   This file is part of GDB.
8
 
9
   This program is free software; you can redistribute it and/or modify
10
   it under the terms of the GNU General Public License as published by
11
   the Free Software Foundation; either version 3 of the License, or
12
   (at your option) any later version.
13
 
14
   This program is distributed in the hope that it will be useful,
15
   but WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
   GNU General Public License for more details.
18
 
19
   You should have received a copy of the GNU General Public License
20
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
21
 
22
#include "defs.h"
23
#include "symtab.h"
24
#include "frame.h"
25
#include "command.h"
26
#include "symfile.h"
27
#include "objfiles.h"
28
#include "source.h"
29
#include "demangle.h"
30
#include "value.h"
31
#include "completer.h"
32
#include "cp-abi.h"
33
#include "cp-support.h"
34
#include "parser-defs.h"
35
#include "block.h"
36
#include "objc-lang.h"
37
#include "linespec.h"
38
#include "exceptions.h"
39
#include "language.h"
40
#include "interps.h"
41
#include "mi/mi-cmds.h"
42
#include "target.h"
43
 
44
/* We share this one with symtab.c, but it is not exported widely. */
45
 
46
extern char *operator_chars (char *, char **);
47
 
48
/* Prototypes for local functions */
49
 
50
static void initialize_defaults (struct symtab **default_symtab,
51
                                 int *default_line);
52
 
53
static void set_flags (char *arg, int *is_quoted, char **paren_pointer);
54
 
55
static struct symtabs_and_lines decode_indirect (char **argptr);
56
 
57
static char *locate_first_half (char **argptr, int *is_quote_enclosed);
58
 
59
static struct symtabs_and_lines decode_objc (char **argptr,
60
                                             int funfirstline,
61
                                             struct symtab *file_symtab,
62
                                             char ***canonical,
63
                                             char *saved_arg);
64
 
65
static struct symtabs_and_lines decode_compound (char **argptr,
66
                                                 int funfirstline,
67
                                                 char ***canonical,
68
                                                 char *saved_arg,
69
                                                 char *p,
70
                                                 int *not_found_ptr);
71
 
72
static struct symbol *lookup_prefix_sym (char **argptr, char *p);
73
 
74
static struct symtabs_and_lines find_method (int funfirstline,
75
                                             char ***canonical,
76
                                             char *saved_arg,
77
                                             char *copy,
78
                                             struct type *t,
79
                                             struct symbol *sym_class,
80
                                             int *not_found_ptr);
81
 
82
static NORETURN void cplusplus_error (const char *name,
83
                                      const char *fmt, ...)
84
     ATTR_NORETURN ATTR_FORMAT (printf, 2, 3);
85
 
86
static int total_number_of_methods (struct type *type);
87
 
88
static int find_methods (struct type *, char *,
89
                         enum language, struct symbol **);
90
 
91
static int add_matching_methods (int method_counter, struct type *t,
92
                                 enum language language,
93
                                 struct symbol **sym_arr);
94
 
95
static int add_constructors (int method_counter, struct type *t,
96
                             enum language language,
97
                             struct symbol **sym_arr);
98
 
99
static void build_canonical_line_spec (struct symtab_and_line *,
100
                                       char *, char ***);
101
 
102
static char *find_toplevel_char (char *s, char c);
103
 
104
static int is_objc_method_format (const char *s);
105
 
106
static struct symtabs_and_lines decode_line_2 (struct symbol *[],
107
                                               int, int, char ***);
108
 
109
static struct symtab *symtab_from_filename (char **argptr,
110
                                            char *p, int is_quote_enclosed,
111
                                            int *not_found_ptr);
112
 
113
static struct
114
symtabs_and_lines decode_all_digits (char **argptr,
115
                                     struct symtab *default_symtab,
116
                                     int default_line,
117
                                     char ***canonical,
118
                                     struct symtab *file_symtab,
119
                                     char *q);
120
 
121
static struct symtabs_and_lines decode_dollar (char *copy,
122
                                               int funfirstline,
123
                                               struct symtab *default_symtab,
124
                                               char ***canonical,
125
                                               struct symtab *file_symtab);
126
 
127
static struct symtabs_and_lines decode_variable (char *copy,
128
                                                 int funfirstline,
129
                                                 char ***canonical,
130
                                                 struct symtab *file_symtab,
131
                                                 int *not_found_ptr);
132
 
133
static struct
134
symtabs_and_lines symbol_found (int funfirstline,
135
                                char ***canonical,
136
                                char *copy,
137
                                struct symbol *sym,
138
                                struct symtab *file_symtab);
139
 
140
static struct
141
symtabs_and_lines minsym_found (int funfirstline,
142
                                struct minimal_symbol *msymbol);
143
 
144
/* Helper functions. */
145
 
146
/* Issue a helpful hint on using the command completion feature on
147
   single quoted demangled C++ symbols as part of the completion
148
   error.  */
149
 
150
static NORETURN void
151
cplusplus_error (const char *name, const char *fmt, ...)
152
{
153
  struct ui_file *tmp_stream;
154
  char *message;
155
  tmp_stream = mem_fileopen ();
156
  make_cleanup_ui_file_delete (tmp_stream);
157
 
158
  {
159
    va_list args;
160
    va_start (args, fmt);
161
    vfprintf_unfiltered (tmp_stream, fmt, args);
162
    va_end (args);
163
  }
164
 
165
  while (*name == '\'')
166
    name++;
167
  fprintf_unfiltered (tmp_stream,
168
                      ("Hint: try '%s<TAB> or '%s<ESC-?>\n"
169
                       "(Note leading single quote.)"),
170
                      name, name);
171
 
172
  message = ui_file_xstrdup (tmp_stream, NULL);
173
  make_cleanup (xfree, message);
174
  throw_error (NOT_FOUND_ERROR, "%s", message);
175
}
176
 
177
/* Return the number of methods described for TYPE, including the
178
   methods from types it derives from. This can't be done in the symbol
179
   reader because the type of the baseclass might still be stubbed
180
   when the definition of the derived class is parsed.  */
181
 
182
static int
183
total_number_of_methods (struct type *type)
184
{
185
  int n;
186
  int count;
187
 
188
  CHECK_TYPEDEF (type);
189
  if (! HAVE_CPLUS_STRUCT (type))
190
    return 0;
191
  count = TYPE_NFN_FIELDS_TOTAL (type);
192
 
193
  for (n = 0; n < TYPE_N_BASECLASSES (type); n++)
194
    count += total_number_of_methods (TYPE_BASECLASS (type, n));
195
 
196
  return count;
197
}
198
 
199
/* Recursive helper function for decode_line_1.
200
   Look for methods named NAME in type T.
201
   Return number of matches.
202
   Put matches in SYM_ARR, which should have been allocated with
203
   a size of total_number_of_methods (T) * sizeof (struct symbol *).
204
   Note that this function is g++ specific.  */
205
 
206
static int
207
find_methods (struct type *t, char *name, enum language language,
208
              struct symbol **sym_arr)
209
{
210
  int i1 = 0;
211
  int ibase;
212
  char *class_name = type_name_no_tag (t);
213
 
214
  /* Ignore this class if it doesn't have a name.  This is ugly, but
215
     unless we figure out how to get the physname without the name of
216
     the class, then the loop can't do any good.  */
217
  if (class_name
218
      && (lookup_symbol_in_language (class_name, (struct block *) NULL,
219
                         STRUCT_DOMAIN, language, (int *) NULL)))
220
    {
221
      int method_counter;
222
      int name_len = strlen (name);
223
 
224
      CHECK_TYPEDEF (t);
225
 
226
      /* Loop over each method name.  At this level, all overloads of a name
227
         are counted as a single name.  There is an inner loop which loops over
228
         each overload.  */
229
 
230
      for (method_counter = TYPE_NFN_FIELDS (t) - 1;
231
           method_counter >= 0;
232
           --method_counter)
233
        {
234
          char *method_name = TYPE_FN_FIELDLIST_NAME (t, method_counter);
235
          char dem_opname[64];
236
 
237
          if (strncmp (method_name, "__", 2) == 0 ||
238
              strncmp (method_name, "op", 2) == 0 ||
239
              strncmp (method_name, "type", 4) == 0)
240
            {
241
              if (cplus_demangle_opname (method_name, dem_opname, DMGL_ANSI))
242
                method_name = dem_opname;
243
              else if (cplus_demangle_opname (method_name, dem_opname, 0))
244
                method_name = dem_opname;
245
            }
246
 
247
          if (strcmp_iw (name, method_name) == 0)
248
            /* Find all the overloaded methods with that name.  */
249
            i1 += add_matching_methods (method_counter, t, language,
250
                                        sym_arr + i1);
251
          else if (strncmp (class_name, name, name_len) == 0
252
                   && (class_name[name_len] == '\0'
253
                       || class_name[name_len] == '<'))
254
            i1 += add_constructors (method_counter, t, language,
255
                                    sym_arr + i1);
256
        }
257
    }
258
 
259
  /* Only search baseclasses if there is no match yet, since names in
260
     derived classes override those in baseclasses.
261
 
262
     FIXME: The above is not true; it is only true of member functions
263
     if they have the same number of arguments (??? - section 13.1 of the
264
     ARM says the function members are not in the same scope but doesn't
265
     really spell out the rules in a way I understand.  In any case, if
266
     the number of arguments differ this is a case in which we can overload
267
     rather than hiding without any problem, and gcc 2.4.5 does overload
268
     rather than hiding in this case).  */
269
 
270
  if (i1 == 0)
271
    for (ibase = 0; ibase < TYPE_N_BASECLASSES (t); ibase++)
272
      i1 += find_methods (TYPE_BASECLASS (t, ibase), name,
273
                          language, sym_arr + i1);
274
 
275
  return i1;
276
}
277
 
278
/* Add the symbols associated to methods of the class whose type is T
279
   and whose name matches the method indexed by METHOD_COUNTER in the
280
   array SYM_ARR.  Return the number of methods added.  */
281
 
282
static int
283
add_matching_methods (int method_counter, struct type *t,
284
                      enum language language, struct symbol **sym_arr)
285
{
286
  int field_counter;
287
  int i1 = 0;
288
 
289
  for (field_counter = TYPE_FN_FIELDLIST_LENGTH (t, method_counter) - 1;
290
       field_counter >= 0;
291
       --field_counter)
292
    {
293
      struct fn_field *f;
294
      char *phys_name;
295
 
296
      f = TYPE_FN_FIELDLIST1 (t, method_counter);
297
 
298
      if (TYPE_FN_FIELD_STUB (f, field_counter))
299
        {
300
          char *tmp_name;
301
 
302
          tmp_name = gdb_mangle_name (t,
303
                                      method_counter,
304
                                      field_counter);
305
          phys_name = alloca (strlen (tmp_name) + 1);
306
          strcpy (phys_name, tmp_name);
307
          xfree (tmp_name);
308
        }
309
      else
310
        phys_name = TYPE_FN_FIELD_PHYSNAME (f, field_counter);
311
 
312
      sym_arr[i1] = lookup_symbol_in_language (phys_name,
313
                                   NULL, VAR_DOMAIN,
314
                                   language,
315
                                   (int *) NULL);
316
      /* See PR10966.  Remove check on symbol domain and class when
317
         we stop using (bad) linkage names on constructors.  */
318
      if (sym_arr[i1] && (SYMBOL_DOMAIN (sym_arr[i1]) == VAR_DOMAIN
319
                          && SYMBOL_CLASS (sym_arr[i1]) == LOC_BLOCK))
320
        i1++;
321
      else
322
        {
323
          /* This error message gets printed, but the method
324
             still seems to be found
325
             fputs_filtered("(Cannot find method ", gdb_stdout);
326
             fprintf_symbol_filtered (gdb_stdout, phys_name,
327
             language_cplus,
328
             DMGL_PARAMS | DMGL_ANSI);
329
             fputs_filtered(" - possibly inlined.)\n", gdb_stdout);
330
          */
331
        }
332
    }
333
 
334
  return i1;
335
}
336
 
337
/* Add the symbols associated to constructors of the class whose type
338
   is CLASS_TYPE and which are indexed by by METHOD_COUNTER to the
339
   array SYM_ARR.  Return the number of methods added.  */
340
 
341
static int
342
add_constructors (int method_counter, struct type *t,
343
                  enum language language, struct symbol **sym_arr)
344
{
345
  int field_counter;
346
  int i1 = 0;
347
 
348
  /* For GCC 3.x and stabs, constructors and destructors
349
     have names like __base_ctor and __complete_dtor.
350
     Check the physname for now if we're looking for a
351
     constructor.  */
352
  for (field_counter
353
         = TYPE_FN_FIELDLIST_LENGTH (t, method_counter) - 1;
354
       field_counter >= 0;
355
       --field_counter)
356
    {
357
      struct fn_field *f;
358
      char *phys_name;
359
 
360
      f = TYPE_FN_FIELDLIST1 (t, method_counter);
361
 
362
      /* GCC 3.x will never produce stabs stub methods, so
363
         we don't need to handle this case.  */
364
      if (TYPE_FN_FIELD_STUB (f, field_counter))
365
        continue;
366
      phys_name = TYPE_FN_FIELD_PHYSNAME (f, field_counter);
367
      if (! is_constructor_name (phys_name))
368
        continue;
369
 
370
      /* If this method is actually defined, include it in the
371
         list.  */
372
      sym_arr[i1] = lookup_symbol_in_language (phys_name,
373
                                   NULL, VAR_DOMAIN,
374
                                   language,
375
                                   (int *) NULL);
376
      if (sym_arr[i1])
377
        i1++;
378
    }
379
 
380
  return i1;
381
}
382
 
383
/* Helper function for decode_line_1.
384
   Build a canonical line spec in CANONICAL if it is non-NULL and if
385
   the SAL has a symtab.
386
   If SYMNAME is non-NULL the canonical line spec is `filename:symname'.
387
   If SYMNAME is NULL the line number from SAL is used and the canonical
388
   line spec is `filename:linenum'.  */
389
 
390
static void
391
build_canonical_line_spec (struct symtab_and_line *sal, char *symname,
392
                           char ***canonical)
393
{
394
  char **canonical_arr;
395
  char *canonical_name;
396
  char *filename;
397
  struct symtab *s = sal->symtab;
398
 
399
  if (s == (struct symtab *) NULL
400
      || s->filename == (char *) NULL
401
      || canonical == (char ***) NULL)
402
    return;
403
 
404
  canonical_arr = (char **) xmalloc (sizeof (char *));
405
  *canonical = canonical_arr;
406
 
407
  filename = s->filename;
408
  if (symname != NULL)
409
    {
410
      canonical_name = xmalloc (strlen (filename) + strlen (symname) + 2);
411
      sprintf (canonical_name, "%s:%s", filename, symname);
412
    }
413
  else
414
    {
415
      canonical_name = xmalloc (strlen (filename) + 30);
416
      sprintf (canonical_name, "%s:%d", filename, sal->line);
417
    }
418
  canonical_arr[0] = canonical_name;
419
}
420
 
421
 
422
 
423
/* Find an instance of the character C in the string S that is outside
424
   of all parenthesis pairs, single-quoted strings, and double-quoted
425
   strings.  Also, ignore the char within a template name, like a ','
426
   within foo<int, int>.  */
427
 
428
static char *
429
find_toplevel_char (char *s, char c)
430
{
431
  int quoted = 0;                /* zero if we're not in quotes;
432
                                   '"' if we're in a double-quoted string;
433
                                   '\'' if we're in a single-quoted string.  */
434
  int depth = 0;         /* Number of unclosed parens we've seen.  */
435
  char *scan;
436
 
437
  for (scan = s; *scan; scan++)
438
    {
439
      if (quoted)
440
        {
441
          if (*scan == quoted)
442
            quoted = 0;
443
          else if (*scan == '\\' && *(scan + 1))
444
            scan++;
445
        }
446
      else if (*scan == c && ! quoted && depth == 0)
447
        return scan;
448
      else if (*scan == '"' || *scan == '\'')
449
        quoted = *scan;
450
      else if (*scan == '(' || *scan == '<')
451
        depth++;
452
      else if ((*scan == ')' || *scan == '>') && depth > 0)
453
        depth--;
454
    }
455
 
456
  return 0;
457
}
458
 
459
/* Determines if the gives string corresponds to an Objective-C method
460
   representation, such as -[Foo bar:] or +[Foo bar]. Objective-C symbols
461
   are allowed to have spaces and parentheses in them.  */
462
 
463
static int
464
is_objc_method_format (const char *s)
465
{
466
  if (s == NULL || *s == '\0')
467
    return 0;
468
  /* Handle arguments with the format FILENAME:SYMBOL.  */
469
  if ((s[0] == ':') && (strchr ("+-", s[1]) != NULL)
470
      && (s[2] == '[') && strchr(s, ']'))
471
    return 1;
472
  /* Handle arguments that are just SYMBOL.  */
473
  else if ((strchr ("+-", s[0]) != NULL) && (s[1] == '[') && strchr(s, ']'))
474
    return 1;
475
  return 0;
476
}
477
 
478
/* Given a list of NELTS symbols in SYM_ARR, return a list of lines to
479
   operate on (ask user if necessary).
480
   If CANONICAL is non-NULL return a corresponding array of mangled names
481
   as canonical line specs there.  */
482
 
483
static struct symtabs_and_lines
484
decode_line_2 (struct symbol *sym_arr[], int nelts, int funfirstline,
485
               char ***canonical)
486
{
487
  struct symtabs_and_lines values, return_values;
488
  char *args, *arg1;
489
  int i;
490
  char *prompt;
491
  char *symname;
492
  struct cleanup *old_chain;
493
  char **canonical_arr = (char **) NULL;
494
  const char *select_mode = multiple_symbols_select_mode ();
495
 
496
  if (select_mode == multiple_symbols_cancel)
497
    error (_("\
498
canceled because the command is ambiguous\n\
499
See set/show multiple-symbol."));
500
 
501
  values.sals = (struct symtab_and_line *)
502
    alloca (nelts * sizeof (struct symtab_and_line));
503
  return_values.sals = (struct symtab_and_line *)
504
    xmalloc (nelts * sizeof (struct symtab_and_line));
505
  old_chain = make_cleanup (xfree, return_values.sals);
506
 
507
  if (canonical)
508
    {
509
      canonical_arr = (char **) xmalloc (nelts * sizeof (char *));
510
      make_cleanup (xfree, canonical_arr);
511
      memset (canonical_arr, 0, nelts * sizeof (char *));
512
      *canonical = canonical_arr;
513
    }
514
 
515
  i = 0;
516
  while (i < nelts)
517
    {
518
      init_sal (&return_values.sals[i]);        /* Initialize to zeroes.  */
519
      init_sal (&values.sals[i]);
520
      if (sym_arr[i] && SYMBOL_CLASS (sym_arr[i]) == LOC_BLOCK)
521
        values.sals[i] = find_function_start_sal (sym_arr[i], funfirstline);
522
      i++;
523
    }
524
 
525
  /* If select_mode is "all", then do not print the multiple-choice
526
     menu and act as if the user had chosen choice "1" (all).  */
527
  if (select_mode == multiple_symbols_all
528
      || ui_out_is_mi_like_p (interp_ui_out (top_level_interpreter ())))
529
    args = "1";
530
  else
531
    {
532
      i = 0;
533
      printf_unfiltered (_("[0] cancel\n[1] all\n"));
534
      while (i < nelts)
535
        {
536
          if (sym_arr[i] && SYMBOL_CLASS (sym_arr[i]) == LOC_BLOCK)
537
            {
538
              if (values.sals[i].symtab)
539
                printf_unfiltered ("[%d] %s at %s:%d\n",
540
                                   (i + 2),
541
                                   SYMBOL_PRINT_NAME (sym_arr[i]),
542
                                   values.sals[i].symtab->filename,
543
                                   values.sals[i].line);
544
              else
545
                printf_unfiltered (_("[%d] %s at ?FILE:%d [No symtab? Probably broken debug info...]\n"),
546
                                   (i + 2),
547
                                   SYMBOL_PRINT_NAME (sym_arr[i]),
548
                                   values.sals[i].line);
549
 
550
            }
551
          else
552
            printf_unfiltered (_("?HERE\n"));
553
          i++;
554
        }
555
 
556
      prompt = getenv ("PS2");
557
      if (prompt == NULL)
558
        {
559
          prompt = "> ";
560
        }
561
      args = command_line_input (prompt, 0, "overload-choice");
562
    }
563
 
564
  if (args == 0 || *args == 0)
565
    error_no_arg (_("one or more choice numbers"));
566
 
567
  i = 0;
568
  while (*args)
569
    {
570
      int num;
571
 
572
      arg1 = args;
573
      while (*arg1 >= '0' && *arg1 <= '9')
574
        arg1++;
575
      if (*arg1 && *arg1 != ' ' && *arg1 != '\t')
576
        error (_("Arguments must be choice numbers."));
577
 
578
      num = atoi (args);
579
 
580
      if (num == 0)
581
        error (_("canceled"));
582
      else if (num == 1)
583
        {
584
          if (canonical_arr)
585
            {
586
              for (i = 0; i < nelts; i++)
587
                {
588
                  if (canonical_arr[i] == NULL)
589
                    {
590
                      symname = SYMBOL_LINKAGE_NAME (sym_arr[i]);
591
                      canonical_arr[i] = xstrdup (symname);
592
                    }
593
                }
594
            }
595
          memcpy (return_values.sals, values.sals,
596
                  (nelts * sizeof (struct symtab_and_line)));
597
          return_values.nelts = nelts;
598
          discard_cleanups (old_chain);
599
          return return_values;
600
        }
601
 
602
      if (num >= nelts + 2)
603
        {
604
          printf_unfiltered (_("No choice number %d.\n"), num);
605
        }
606
      else
607
        {
608
          num -= 2;
609
          if (values.sals[num].pc)
610
            {
611
              if (canonical_arr)
612
                {
613
                  symname = SYMBOL_LINKAGE_NAME (sym_arr[num]);
614
                  make_cleanup (xfree, symname);
615
                  canonical_arr[i] = xstrdup (symname);
616
                }
617
              return_values.sals[i++] = values.sals[num];
618
              values.sals[num].pc = 0;
619
            }
620
          else
621
            {
622
              printf_unfiltered (_("duplicate request for %d ignored.\n"), num);
623
            }
624
        }
625
 
626
      args = arg1;
627
      while (*args == ' ' || *args == '\t')
628
        args++;
629
    }
630
  return_values.nelts = i;
631
  discard_cleanups (old_chain);
632
  return return_values;
633
}
634
 
635
/* The parser of linespec itself. */
636
 
637
/* Parse a string that specifies a line number.
638
   Pass the address of a char * variable; that variable will be
639
   advanced over the characters actually parsed.
640
 
641
   The string can be:
642
 
643
   LINENUM -- that line number in current file.  PC returned is 0.
644
   FILE:LINENUM -- that line in that file.  PC returned is 0.
645
   FUNCTION -- line number of openbrace of that function.
646
   PC returned is the start of the function.
647
   VARIABLE -- line number of definition of that variable.
648
   PC returned is 0.
649
   FILE:FUNCTION -- likewise, but prefer functions in that file.
650
   *EXPR -- line in which address EXPR appears.
651
 
652
   This may all be followed by an "if EXPR", which we ignore.
653
 
654
   FUNCTION may be an undebuggable function found in minimal symbol table.
655
 
656
   If the argument FUNFIRSTLINE is nonzero, we want the first line
657
   of real code inside a function when a function is specified, and it is
658
   not OK to specify a variable or type to get its line number.
659
 
660
   DEFAULT_SYMTAB specifies the file to use if none is specified.
661
   It defaults to current_source_symtab.
662
   DEFAULT_LINE specifies the line number to use for relative
663
   line numbers (that start with signs).  Defaults to current_source_line.
664
   If CANONICAL is non-NULL, store an array of strings containing the canonical
665
   line specs there if necessary. Currently overloaded member functions and
666
   line numbers or static functions without a filename yield a canonical
667
   line spec. The array and the line spec strings are allocated on the heap,
668
   it is the callers responsibility to free them.
669
 
670
   Note that it is possible to return zero for the symtab
671
   if no file is validly specified.  Callers must check that.
672
   Also, the line number returned may be invalid.
673
 
674
   If NOT_FOUND_PTR is not null, store a boolean true/false value at the location, based
675
   on whether or not failure occurs due to an unknown function or file.  In the case
676
   where failure does occur due to an unknown function or file, do not issue an error
677
   message.  */
678
 
679
/* We allow single quotes in various places.  This is a hideous
680
   kludge, which exists because the completer can't yet deal with the
681
   lack of single quotes.  FIXME: write a linespec_completer which we
682
   can use as appropriate instead of make_symbol_completion_list.  */
683
 
684
struct symtabs_and_lines
685
decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
686
               int default_line, char ***canonical, int *not_found_ptr)
687
{
688
  char *p;
689
  char *q;
690
  /* If a file name is specified, this is its symtab.  */
691
  struct symtab *file_symtab = NULL;
692
 
693
  char *copy;
694
  /* This is NULL if there are no parens in *ARGPTR, or a pointer to
695
     the closing parenthesis if there are parens.  */
696
  char *paren_pointer;
697
  /* This says whether or not something in *ARGPTR is quoted with
698
     completer_quotes (i.e. with single quotes).  */
699
  int is_quoted;
700
  /* Is part of *ARGPTR is enclosed in double quotes?  */
701
  int is_quote_enclosed;
702
  int is_objc_method = 0;
703
  char *saved_arg = *argptr;
704
  /* If IS_QUOTED, the end of the quoted bit.  */
705
  char *end_quote = NULL;
706
 
707
  if (not_found_ptr)
708
    *not_found_ptr = 0;
709
 
710
  /* Defaults have defaults.  */
711
 
712
  initialize_defaults (&default_symtab, &default_line);
713
 
714
  /* See if arg is *PC.  */
715
 
716
  if (**argptr == '*')
717
    return decode_indirect (argptr);
718
 
719
  /* Set various flags.  'paren_pointer' is important for overload
720
     checking, where we allow things like:
721
        (gdb) break c::f(int)
722
  */
723
 
724
  set_flags (*argptr, &is_quoted, &paren_pointer);
725
  if (is_quoted)
726
    end_quote = skip_quoted (*argptr);
727
 
728
  /* Check to see if it's a multipart linespec (with colons or
729
     periods).  */
730
 
731
  /* Locate the end of the first half of the linespec.
732
     After the call, for instance, if the argptr string is "foo.c:123"
733
     p will point at "123".  If there is only one part, like "foo", p
734
     will point to "". If this is a C++ name, like "A::B::foo", p will
735
     point to "::B::foo". Argptr is not changed by this call.  */
736
 
737
  p = locate_first_half (argptr, &is_quote_enclosed);
738
 
739
  /* Check if this is an Objective-C method (anything that starts with
740
     a '+' or '-' and a '[').  */
741
  if (is_objc_method_format (p))
742
    {
743
      is_objc_method = 1;
744
      paren_pointer  = NULL; /* Just a category name.  Ignore it.  */
745
    }
746
 
747
  /* Check if the symbol could be an Objective-C selector.  */
748
 
749
  {
750
    struct symtabs_and_lines values;
751
    values = decode_objc (argptr, funfirstline, NULL,
752
                          canonical, saved_arg);
753
    if (values.sals != NULL)
754
      return values;
755
  }
756
 
757
  if (is_quoted)
758
    *argptr = *argptr + 1;
759
 
760
  /* Does it look like there actually were two parts?  */
761
 
762
  if (p[0] == ':' || p[0] == '.')
763
    {
764
      /* Is it a C++ or Java compound data structure?
765
         The check on p[1] == ':' is capturing the case of "::",
766
         since p[0]==':' was checked above.
767
         Note that the call to decode_compound does everything
768
         for us, including the lookup on the symbol table, so we
769
         can return now. */
770
 
771
      if (p[0] == '.' || p[1] == ':')
772
        {
773
          if (paren_pointer == NULL)
774
            return decode_compound (argptr, funfirstline, canonical,
775
                                    saved_arg, p, not_found_ptr);
776
          /* Otherwise, fall through to decode_variable below.  */
777
        }
778
      else
779
        {
780
          /* No, the first part is a filename; set file_symtab to be that file's
781
             symtab.  Also, move argptr past the filename.  */
782
 
783
          file_symtab = symtab_from_filename (argptr, p, is_quote_enclosed,
784
                                              not_found_ptr);
785
 
786
          /* Check for single quotes on the non-filename part.  */
787
          if (!is_quoted)
788
            {
789
              is_quoted = (**argptr
790
                           && strchr (get_gdb_completer_quote_characters (),
791
                                      **argptr) != NULL);
792
              if (is_quoted)
793
                end_quote = skip_quoted (*argptr);
794
            }
795
        }
796
    }
797
#if 0
798
  /* No one really seems to know why this was added. It certainly
799
     breaks the command line, though, whenever the passed
800
     name is of the form ClassName::Method. This bit of code
801
     singles out the class name, and if funfirstline is set (for
802
     example, you are setting a breakpoint at this function),
803
     you get an error. This did not occur with earlier
804
     verions, so I am ifdef'ing this out. 3/29/99 */
805
  else
806
    {
807
      /* Check if what we have till now is a symbol name */
808
 
809
      /* We may be looking at a template instantiation such
810
         as "foo<int>".  Check here whether we know about it,
811
         instead of falling through to the code below which
812
         handles ordinary function names, because that code
813
         doesn't like seeing '<' and '>' in a name -- the
814
         skip_quoted call doesn't go past them.  So see if we
815
         can figure it out right now. */
816
 
817
      copy = (char *) alloca (p - *argptr + 1);
818
      memcpy (copy, *argptr, p - *argptr);
819
      copy[p - *argptr] = '\000';
820
      sym = lookup_symbol (copy, 0, VAR_DOMAIN, 0);
821
      if (sym)
822
        {
823
          *argptr = (*p == '\'') ? p + 1 : p;
824
          return symbol_found (funfirstline, canonical, copy, sym, NULL);
825
        }
826
      /* Otherwise fall out from here and go to file/line spec
827
         processing, etc. */
828
    }
829
#endif
830
 
831
  /* file_symtab is specified file's symtab, or 0 if no file specified.
832
     arg no longer contains the file name.  */
833
 
834
  /* Check whether arg is all digits (and sign).  */
835
 
836
  q = *argptr;
837
  if (*q == '-' || *q == '+')
838
    q++;
839
  while (*q >= '0' && *q <= '9')
840
    q++;
841
 
842
  if (q != *argptr && (*q == 0 || *q == ' ' || *q == '\t' || *q == ','))
843
    /* We found a token consisting of all digits -- at least one digit.  */
844
    return decode_all_digits (argptr, default_symtab, default_line,
845
                              canonical, file_symtab, q);
846
 
847
  /* Arg token is not digits => try it as a variable name
848
     Find the next token (everything up to end or next whitespace).  */
849
 
850
  if (**argptr == '$')          /* May be a convenience variable.  */
851
    /* One or two $ chars possible.  */
852
    p = skip_quoted (*argptr + (((*argptr)[1] == '$') ? 2 : 1));
853
  else if (is_quoted)
854
    {
855
      p = end_quote;
856
      if (p[-1] != '\'')
857
        error (_("Unmatched single quote."));
858
    }
859
  else if (is_objc_method)
860
    {
861
      /* allow word separators in method names for Obj-C */
862
      p = skip_quoted_chars (*argptr, NULL, "");
863
    }
864
  else if (paren_pointer != NULL)
865
    {
866
      p = paren_pointer + 1;
867
    }
868
  else
869
    {
870
      p = skip_quoted (*argptr);
871
    }
872
 
873
  /* Keep any template parameters */
874
  if (*p == '<')
875
    p = find_template_name_end (p);
876
 
877
  copy = (char *) alloca (p - *argptr + 1);
878
  memcpy (copy, *argptr, p - *argptr);
879
  copy[p - *argptr] = '\0';
880
  if (p != *argptr
881
      && copy[0]
882
      && copy[0] == copy[p - *argptr - 1]
883
      && strchr (get_gdb_completer_quote_characters (), copy[0]) != NULL)
884
    {
885
      copy[p - *argptr - 1] = '\0';
886
      copy++;
887
    }
888
  else if (is_quoted)
889
    copy[p - *argptr - 1] = '\0';
890
  while (*p == ' ' || *p == '\t')
891
    p++;
892
  *argptr = p;
893
 
894
  /* If it starts with $: may be a legitimate variable or routine name
895
     (e.g. HP-UX millicode routines such as $$dyncall), or it may
896
     be history value, or it may be a convenience variable.  */
897
 
898
  if (*copy == '$')
899
    return decode_dollar (copy, funfirstline, default_symtab,
900
                          canonical, file_symtab);
901
 
902
  /* Look up that token as a variable.
903
     If file specified, use that file's per-file block to start with.  */
904
 
905
  return decode_variable (copy, funfirstline, canonical,
906
                          file_symtab, not_found_ptr);
907
}
908
 
909
 
910
 
911
/* Now, more helper functions for decode_line_1.  Some conventions
912
   that these functions follow:
913
 
914
   Decode_line_1 typically passes along some of its arguments or local
915
   variables to the subfunctions.  It passes the variables by
916
   reference if they are modified by the subfunction, and by value
917
   otherwise.
918
 
919
   Some of the functions have side effects that don't arise from
920
   variables that are passed by reference.  In particular, if a
921
   function is passed ARGPTR as an argument, it modifies what ARGPTR
922
   points to; typically, it advances *ARGPTR past whatever substring
923
   it has just looked at.  (If it doesn't modify *ARGPTR, then the
924
   function gets passed *ARGPTR instead, which is then called ARG: see
925
   set_flags, for example.)  Also, functions that return a struct
926
   symtabs_and_lines may modify CANONICAL, as in the description of
927
   decode_line_1.
928
 
929
   If a function returns a struct symtabs_and_lines, then that struct
930
   will immediately make its way up the call chain to be returned by
931
   decode_line_1.  In particular, all of the functions decode_XXX
932
   calculate the appropriate struct symtabs_and_lines, under the
933
   assumption that their argument is of the form XXX.  */
934
 
935
/* First, some functions to initialize stuff at the beggining of the
936
   function.  */
937
 
938
static void
939
initialize_defaults (struct symtab **default_symtab, int *default_line)
940
{
941
  if (*default_symtab == 0)
942
    {
943
      /* Use whatever we have for the default source line.  We don't use
944
         get_current_or_default_symtab_and_line as it can recurse and call
945
         us back! */
946
      struct symtab_and_line cursal =
947
        get_current_source_symtab_and_line ();
948
 
949
      *default_symtab = cursal.symtab;
950
      *default_line = cursal.line;
951
    }
952
}
953
 
954
static void
955
set_flags (char *arg, int *is_quoted, char **paren_pointer)
956
{
957
  char *ii;
958
  int has_if = 0;
959
 
960
  /* 'has_if' is for the syntax:
961
        (gdb) break foo if (a==b)
962
  */
963
  if ((ii = strstr (arg, " if ")) != NULL ||
964
      (ii = strstr (arg, "\tif ")) != NULL ||
965
      (ii = strstr (arg, " if\t")) != NULL ||
966
      (ii = strstr (arg, "\tif\t")) != NULL ||
967
      (ii = strstr (arg, " if(")) != NULL ||
968
      (ii = strstr (arg, "\tif( ")) != NULL)
969
    has_if = 1;
970
  /* Temporarily zap out "if (condition)" to not confuse the
971
     parenthesis-checking code below.  This is undone below. Do not
972
     change ii!!  */
973
  if (has_if)
974
    {
975
      *ii = '\0';
976
    }
977
 
978
  *is_quoted = (*arg
979
                && strchr (get_gdb_completer_quote_characters (),
980
                           *arg) != NULL);
981
 
982
  *paren_pointer = strchr (arg, '(');
983
  if (*paren_pointer != NULL)
984
    *paren_pointer = strrchr (*paren_pointer, ')');
985
 
986
  /* Now that we're safely past the paren_pointer check, put back " if
987
     (condition)" so outer layers can see it.  */
988
  if (has_if)
989
    *ii = ' ';
990
}
991
 
992
 
993
 
994
/* Decode arg of the form *PC.  */
995
 
996
static struct symtabs_and_lines
997
decode_indirect (char **argptr)
998
{
999
  struct symtabs_and_lines values;
1000
  CORE_ADDR pc;
1001
 
1002
  (*argptr)++;
1003
  pc = parse_and_eval_address_1 (argptr);
1004
 
1005
  values.sals = (struct symtab_and_line *)
1006
    xmalloc (sizeof (struct symtab_and_line));
1007
 
1008
  values.nelts = 1;
1009
  values.sals[0] = find_pc_line (pc, 0);
1010
  values.sals[0].pc = pc;
1011
  values.sals[0].section = find_pc_overlay (pc);
1012
  values.sals[0].explicit_pc = 1;
1013
 
1014
  return values;
1015
}
1016
 
1017
 
1018
 
1019
/* Locate the first half of the linespec, ending in a colon, period,
1020
   or whitespace.  (More or less.)  Also, check to see if *ARGPTR is
1021
   enclosed in double quotes; if so, set is_quote_enclosed, advance
1022
   ARGPTR past that and zero out the trailing double quote.
1023
   If ARGPTR is just a simple name like "main", p will point to ""
1024
   at the end.  */
1025
 
1026
static char *
1027
locate_first_half (char **argptr, int *is_quote_enclosed)
1028
{
1029
  char *ii;
1030
  char *p, *p1;
1031
  int has_comma;
1032
 
1033
  /* Maybe we were called with a line range FILENAME:LINENUM,FILENAME:LINENUM
1034
     and we must isolate the first half.  Outer layers will call again later
1035
     for the second half.
1036
 
1037
     Don't count commas that appear in argument lists of overloaded
1038
     functions, or in quoted strings.  It's stupid to go to this much
1039
     trouble when the rest of the function is such an obvious roach hotel.  */
1040
  ii = find_toplevel_char (*argptr, ',');
1041
  has_comma = (ii != 0);
1042
 
1043
  /* Temporarily zap out second half to not confuse the code below.
1044
     This is undone below. Do not change ii!!  */
1045
  if (has_comma)
1046
    {
1047
      *ii = '\0';
1048
    }
1049
 
1050
  /* Maybe arg is FILE : LINENUM or FILE : FUNCTION.  May also be
1051
     CLASS::MEMBER, or NAMESPACE::NAME.  Look for ':', but ignore
1052
     inside of <>.  */
1053
 
1054
  p = *argptr;
1055
  if (p[0] == '"')
1056
    {
1057
      *is_quote_enclosed = 1;
1058
      (*argptr)++;
1059
      p++;
1060
    }
1061
  else
1062
    *is_quote_enclosed = 0;
1063
  for (; *p; p++)
1064
    {
1065
      if (p[0] == '<')
1066
        {
1067
          char *temp_end = find_template_name_end (p);
1068
          if (!temp_end)
1069
            error (_("malformed template specification in command"));
1070
          p = temp_end;
1071
        }
1072
      /* Check for a colon and a plus or minus and a [ (which
1073
         indicates an Objective-C method) */
1074
      if (is_objc_method_format (p))
1075
        {
1076
          break;
1077
        }
1078
      /* Check for the end of the first half of the linespec.  End of
1079
         line, a tab, a double colon or the last single colon, or a
1080
         space.  But if enclosed in double quotes we do not break on
1081
         enclosed spaces.  */
1082
      if (!*p
1083
          || p[0] == '\t'
1084
          || ((p[0] == ':')
1085
              && ((p[1] == ':') || (strchr (p + 1, ':') == NULL)))
1086
          || ((p[0] == ' ') && !*is_quote_enclosed))
1087
        break;
1088
      if (p[0] == '.' && strchr (p, ':') == NULL)
1089
        {
1090
          /* Java qualified method.  Find the *last* '.', since the
1091
             others are package qualifiers.  */
1092
          for (p1 = p; *p1; p1++)
1093
            {
1094
              if (*p1 == '.')
1095
                p = p1;
1096
            }
1097
          break;
1098
        }
1099
    }
1100
  while (p[0] == ' ' || p[0] == '\t')
1101
    p++;
1102
 
1103
  /* If the closing double quote was left at the end, remove it.  */
1104
  if (*is_quote_enclosed)
1105
    {
1106
      char *closing_quote = strchr (p - 1, '"');
1107
      if (closing_quote && closing_quote[1] == '\0')
1108
        *closing_quote = '\0';
1109
    }
1110
 
1111
  /* Now that we've safely parsed the first half, put back ',' so
1112
     outer layers can see it.  */
1113
  if (has_comma)
1114
    *ii = ',';
1115
 
1116
  return p;
1117
}
1118
 
1119
 
1120
 
1121
/* Here's where we recognise an Objective-C Selector.  An Objective C
1122
   selector may be implemented by more than one class, therefore it
1123
   may represent more than one method/function.  This gives us a
1124
   situation somewhat analogous to C++ overloading.  If there's more
1125
   than one method that could represent the selector, then use some of
1126
   the existing C++ code to let the user choose one.  */
1127
 
1128
struct symtabs_and_lines
1129
decode_objc (char **argptr, int funfirstline, struct symtab *file_symtab,
1130
             char ***canonical, char *saved_arg)
1131
{
1132
  struct symtabs_and_lines values;
1133
  struct symbol **sym_arr = NULL;
1134
  struct symbol *sym = NULL;
1135
  char *copy = NULL;
1136
  struct block *block = NULL;
1137
  unsigned i1 = 0;
1138
  unsigned i2 = 0;
1139
 
1140
  values.sals = NULL;
1141
  values.nelts = 0;
1142
 
1143
  if (file_symtab != NULL)
1144
    block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (file_symtab), STATIC_BLOCK);
1145
  else
1146
    {
1147
      enum language save_language;
1148
 
1149
      /* get_selected_block can change the current language when there is
1150
         no selected frame yet.  */
1151
      save_language = current_language->la_language;
1152
      block = get_selected_block (0);
1153
      set_language (save_language);
1154
    }
1155
 
1156
  copy = find_imps (file_symtab, block, *argptr, NULL, &i1, &i2);
1157
 
1158
  if (i1 > 0)
1159
    {
1160
      sym_arr = (struct symbol **) alloca ((i1 + 1) * sizeof (struct symbol *));
1161
      sym_arr[i1] = NULL;
1162
 
1163
      copy = find_imps (file_symtab, block, *argptr, sym_arr, &i1, &i2);
1164
      *argptr = copy;
1165
    }
1166
 
1167
  /* i1 now represents the TOTAL number of matches found.
1168
     i2 represents how many HIGH-LEVEL (struct symbol) matches,
1169
     which will come first in the sym_arr array.  Any low-level
1170
     (minimal_symbol) matches will follow those.  */
1171
 
1172
  if (i1 == 1)
1173
    {
1174
      if (i2 > 0)
1175
        {
1176
          /* Already a struct symbol.  */
1177
          sym = sym_arr[0];
1178
        }
1179
      else
1180
        {
1181
          sym = find_pc_function (SYMBOL_VALUE_ADDRESS (sym_arr[0]));
1182
          if ((sym != NULL) && strcmp (SYMBOL_LINKAGE_NAME (sym_arr[0]), SYMBOL_LINKAGE_NAME (sym)) != 0)
1183
            {
1184
              warning (_("debugging symbol \"%s\" does not match selector; ignoring"), SYMBOL_LINKAGE_NAME (sym));
1185
              sym = NULL;
1186
            }
1187
        }
1188
 
1189
      values.sals = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line));
1190
      values.nelts = 1;
1191
 
1192
      if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
1193
        {
1194
          /* Canonicalize this, so it remains resolved for dylib loads.  */
1195
          values.sals[0] = find_function_start_sal (sym, funfirstline);
1196
          build_canonical_line_spec (values.sals, SYMBOL_NATURAL_NAME (sym), canonical);
1197
        }
1198
      else
1199
        {
1200
          /* The only match was a non-debuggable symbol, which might point
1201
             to a function descriptor; resolve it to the actual code address
1202
             instead.  */
1203
          struct minimal_symbol *msymbol = (struct minimal_symbol *)sym_arr[0];
1204
          struct objfile *objfile = msymbol_objfile (msymbol);
1205
          struct gdbarch *gdbarch = get_objfile_arch (objfile);
1206
          CORE_ADDR pc = SYMBOL_VALUE_ADDRESS (msymbol);
1207
 
1208
          pc = gdbarch_convert_from_func_ptr_addr (gdbarch, pc,
1209
                                                   &current_target);
1210
 
1211
          init_sal (&values.sals[0]);
1212
          values.sals[0].pc = pc;
1213
        }
1214
      return values;
1215
    }
1216
 
1217
  if (i1 > 1)
1218
    {
1219
      /* More than one match. The user must choose one or more.  */
1220
      return decode_line_2 (sym_arr, i2, funfirstline, canonical);
1221
    }
1222
 
1223
  return values;
1224
}
1225
 
1226
/* This handles C++ and Java compound data structures.  P should point
1227
   at the first component separator, i.e. double-colon or period.  As
1228
   an example, on entrance to this function we could have ARGPTR
1229
   pointing to "AAA::inA::fun" and P pointing to "::inA::fun".  */
1230
 
1231
static struct symtabs_and_lines
1232
decode_compound (char **argptr, int funfirstline, char ***canonical,
1233
                 char *saved_arg, char *p, int *not_found_ptr)
1234
{
1235
  struct symtabs_and_lines values;
1236
  char *p2;
1237
  char *saved_arg2 = *argptr;
1238
  char *temp_end;
1239
  struct symbol *sym;
1240
  char *copy;
1241
  struct symbol *sym_class;
1242
  struct symbol **sym_arr;
1243
  struct type *t;
1244
 
1245
  /* First check for "global" namespace specification, of the form
1246
     "::foo".  If found, skip over the colons and jump to normal
1247
     symbol processing.  I.e. the whole line specification starts with
1248
     "::" (note the condition that *argptr == p). */
1249
  if (p[0] == ':'
1250
      && ((*argptr == p) || (p[-1] == ' ') || (p[-1] == '\t')))
1251
    saved_arg2 += 2;
1252
 
1253
  /* Given our example "AAA::inA::fun", we have two cases to consider:
1254
 
1255
     1) AAA::inA is the name of a class.  In that case, presumably it
1256
        has a method called "fun"; we then look up that method using
1257
        find_method.
1258
 
1259
     2) AAA::inA isn't the name of a class.  In that case, either the
1260
        user made a typo or AAA::inA is the name of a namespace.
1261
        Either way, we just look up AAA::inA::fun with lookup_symbol.
1262
 
1263
     Thus, our first task is to find everything before the last set of
1264
     double-colons and figure out if it's the name of a class.  So we
1265
     first loop through all of the double-colons.  */
1266
 
1267
  p2 = p;               /* Save for restart.  */
1268
 
1269
  /* This is very messy. Following the example above we have now the
1270
     following pointers:
1271
     p -> "::inA::fun"
1272
     argptr -> "AAA::inA::fun
1273
     saved_arg -> "AAA::inA::fun
1274
     saved_arg2 -> "AAA::inA::fun
1275
     p2 -> "::inA::fun". */
1276
 
1277
  /* In the loop below, with these strings, we'll make 2 passes, each
1278
     is marked in comments.*/
1279
 
1280
  while (1)
1281
    {
1282
      /* Move pointer up to next possible class/namespace token.  */
1283
 
1284
      p = p2 + 1;       /* Restart with old value +1.  */
1285
 
1286
      /* PASS1: at this point p2->"::inA::fun", so p->":inA::fun",
1287
         i.e. if there is a double-colon, p will now point to the
1288
         second colon. */
1289
      /* PASS2: p2->"::fun", p->":fun" */
1290
 
1291
      /* Move pointer ahead to next double-colon.  */
1292
      while (*p && (p[0] != ' ') && (p[0] != '\t') && (p[0] != '\''))
1293
        {
1294
          if (current_language->la_language == language_cplus)
1295
            p += cp_validate_operator (p);
1296
 
1297
          if (p[0] == '<')
1298
            {
1299
              temp_end = find_template_name_end (p);
1300
              if (!temp_end)
1301
                error (_("malformed template specification in command"));
1302
              p = temp_end;
1303
            }
1304
          /* Note that, since, at the start of this loop, p would be
1305
             pointing to the second colon in a double-colon, we only
1306
             satisfy the condition below if there is another
1307
             double-colon to the right (after). I.e. there is another
1308
             component that can be a class or a namespace. I.e, if at
1309
             the beginning of this loop (PASS1), we had
1310
             p->":inA::fun", we'll trigger this when p has been
1311
             advanced to point to "::fun".  */
1312
          /* PASS2: we will not trigger this. */
1313
          else if ((p[0] == ':') && (p[1] == ':'))
1314
            break;      /* Found double-colon.  */
1315
          else
1316
            /* PASS2: We'll keep getting here, until p->"", at which point
1317
               we exit this loop.  */
1318
            p++;
1319
        }
1320
 
1321
      if (*p != ':')
1322
        break;          /* Out of the while (1).  This would happen
1323
                           for instance if we have looked up
1324
                           unsuccessfully all the components of the
1325
                           string, and p->""(PASS2)  */
1326
 
1327
      /* We get here if p points to ' ', '\t', '\'', "::" or ""(i.e
1328
         string ended). */
1329
      /* Save restart for next time around.  */
1330
      p2 = p;
1331
      /* Restore argptr as it was on entry to this function.  */
1332
      *argptr = saved_arg2;
1333
      /* PASS1: at this point p->"::fun" argptr->"AAA::inA::fun",
1334
         p2->"::fun".  */
1335
 
1336
      /* All ready for next pass through the loop.  */
1337
    }                   /* while (1) */
1338
 
1339
 
1340
  /* Start of lookup in the symbol tables. */
1341
 
1342
  /* Lookup in the symbol table the substring between argptr and
1343
     p. Note, this call changes the value of argptr.  */
1344
  /* Before the call, argptr->"AAA::inA::fun",
1345
     p->"", p2->"::fun".  After the call: argptr->"fun", p, p2
1346
     unchanged.  */
1347
  sym_class = lookup_prefix_sym (argptr, p2);
1348
 
1349
  /* If sym_class has been found, and if "AAA::inA" is a class, then
1350
     we're in case 1 above.  So we look up "fun" as a method of that
1351
     class.  */
1352
  if (sym_class &&
1353
      (t = check_typedef (SYMBOL_TYPE (sym_class)),
1354
       (TYPE_CODE (t) == TYPE_CODE_STRUCT
1355
        || TYPE_CODE (t) == TYPE_CODE_UNION)))
1356
    {
1357
      /* Arg token is not digits => try it as a function name.
1358
         Find the next token (everything up to end or next
1359
         blank).  */
1360
      if (**argptr
1361
          && strchr (get_gdb_completer_quote_characters (),
1362
                     **argptr) != NULL)
1363
        {
1364
          p = skip_quoted (*argptr);
1365
          *argptr = *argptr + 1;
1366
        }
1367
      else
1368
        {
1369
          /* At this point argptr->"fun".  */
1370
          p = *argptr;
1371
          while (*p && *p != ' ' && *p != '\t' && *p != ',' && *p != ':')
1372
            p++;
1373
          /* At this point p->"".  String ended.  */
1374
          /* Nope, C++ operators could have spaces in them
1375
             ("foo::operator <" or "foo::operator delete []").
1376
             I apologize, this is a bit hacky...  */
1377
          if (current_language->la_language == language_cplus
1378
              && *p == ' ' && p - 8 - *argptr + 1 > 0)
1379
            {
1380
              /* The above loop has already swallowed "operator".  */
1381
              p += cp_validate_operator (p - 8) - 8;
1382
            }
1383
        }
1384
 
1385
      /* Allocate our own copy of the substring between argptr and
1386
         p. */
1387
      copy = (char *) alloca (p - *argptr + 1);
1388
      memcpy (copy, *argptr, p - *argptr);
1389
      copy[p - *argptr] = '\0';
1390
      if (p != *argptr
1391
          && copy[p - *argptr - 1]
1392
          && strchr (get_gdb_completer_quote_characters (),
1393
                     copy[p - *argptr - 1]) != NULL)
1394
        copy[p - *argptr - 1] = '\0';
1395
 
1396
      /* At this point copy->"fun", p->"" */
1397
 
1398
      /* No line number may be specified.  */
1399
      while (*p == ' ' || *p == '\t')
1400
        p++;
1401
      *argptr = p;
1402
      /* At this point arptr->"".  */
1403
 
1404
      /* Look for copy as a method of sym_class. */
1405
      /* At this point copy->"fun", sym_class is "AAA:inA",
1406
         saved_arg->"AAA::inA::fun".  This concludes the scanning of
1407
         the string for possible components matches.  If we find it
1408
         here, we return. If not, and we are at the and of the string,
1409
         we'll lookup the whole string in the symbol tables.  */
1410
 
1411
      return find_method (funfirstline, canonical, saved_arg,
1412
                          copy, t, sym_class, not_found_ptr);
1413
 
1414
    } /* End if symbol found */
1415
 
1416
 
1417
  /* We couldn't find a class, so we're in case 2 above.  We check the
1418
     entire name as a symbol instead.  */
1419
 
1420
  copy = (char *) alloca (p - saved_arg2 + 1);
1421
  memcpy (copy, saved_arg2, p - saved_arg2);
1422
  /* Note: if is_quoted should be true, we snuff out quote here
1423
     anyway.  */
1424
  copy[p - saved_arg2] = '\000';
1425
  /* Set argptr to skip over the name.  */
1426
  *argptr = (*p == '\'') ? p + 1 : p;
1427
 
1428
  /* Look up entire name */
1429
  sym = lookup_symbol (copy, 0, VAR_DOMAIN, 0);
1430
  if (sym)
1431
    return symbol_found (funfirstline, canonical, copy, sym, NULL);
1432
 
1433
  /* Couldn't find any interpretation as classes/namespaces, so give
1434
     up.  The quotes are important if copy is empty.  */
1435
  if (not_found_ptr)
1436
    *not_found_ptr = 1;
1437
  cplusplus_error (saved_arg,
1438
                   "Can't find member of namespace, class, struct, or union named \"%s\"\n",
1439
                   copy);
1440
}
1441
 
1442
/* Next come some helper functions for decode_compound.  */
1443
 
1444
/* Return the symbol corresponding to the substring of *ARGPTR ending
1445
   at P, allowing whitespace.  Also, advance *ARGPTR past the symbol
1446
   name in question, the compound object separator ("::" or "."), and
1447
   whitespace.  Note that *ARGPTR is changed whether or not the
1448
   lookup_symbol call finds anything (i.e we return NULL).  As an
1449
   example, say ARGPTR is "AAA::inA::fun" and P is "::inA::fun".  */
1450
 
1451
static struct symbol *
1452
lookup_prefix_sym (char **argptr, char *p)
1453
{
1454
  char *p1;
1455
  char *copy;
1456
  struct symbol *sym;
1457
 
1458
  /* Extract the class name.  */
1459
  p1 = p;
1460
  while (p != *argptr && p[-1] == ' ')
1461
    --p;
1462
  copy = (char *) alloca (p - *argptr + 1);
1463
  memcpy (copy, *argptr, p - *argptr);
1464
  copy[p - *argptr] = 0;
1465
 
1466
  /* Discard the class name from the argptr.  */
1467
  p = p1 + (p1[0] == ':' ? 2 : 1);
1468
  while (*p == ' ' || *p == '\t')
1469
    p++;
1470
  *argptr = p;
1471
 
1472
  /* At this point p1->"::inA::fun", p->"inA::fun" copy->"AAA",
1473
     argptr->"inA::fun" */
1474
 
1475
  sym = lookup_symbol (copy, 0, STRUCT_DOMAIN, 0);
1476
  if (sym == NULL)
1477
    {
1478
      /* Typedefs are in VAR_DOMAIN so the above symbol lookup will
1479
         fail when the user attempts to lookup a method of a class
1480
         via a typedef'd name (NOT via the class's name, which is already
1481
         handled in symbol_matches_domain).  So try the lookup again
1482
         using VAR_DOMAIN (where typedefs live) and double-check that we
1483
         found a struct/class type.  */
1484
      struct symbol *s = lookup_symbol (copy, 0, VAR_DOMAIN, 0);
1485
      if (s != NULL)
1486
        {
1487
          struct type *t = SYMBOL_TYPE (s);
1488
          CHECK_TYPEDEF (t);
1489
          if (TYPE_CODE (t) == TYPE_CODE_STRUCT)
1490
            return s;
1491
        }
1492
    }
1493
 
1494
  return sym;
1495
}
1496
 
1497
/* This finds the method COPY in the class whose type is T and whose
1498
   symbol is SYM_CLASS.  */
1499
 
1500
static struct symtabs_and_lines
1501
find_method (int funfirstline, char ***canonical, char *saved_arg,
1502
             char *copy, struct type *t, struct symbol *sym_class, int *not_found_ptr)
1503
{
1504
  struct symtabs_and_lines values;
1505
  struct symbol *sym = NULL;
1506
  int i1;       /*  Counter for the symbol array.  */
1507
  struct symbol **sym_arr =  alloca (total_number_of_methods (t)
1508
                                     * sizeof (struct symbol *));
1509
 
1510
  /* Find all methods with a matching name, and put them in
1511
     sym_arr.  */
1512
 
1513
  i1 = find_methods (t, copy, SYMBOL_LANGUAGE (sym_class), sym_arr);
1514
 
1515
  if (i1 == 1)
1516
    {
1517
      /* There is exactly one field with that name.  */
1518
      sym = sym_arr[0];
1519
 
1520
      if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
1521
        {
1522
          values.sals = (struct symtab_and_line *)
1523
            xmalloc (sizeof (struct symtab_and_line));
1524
          values.nelts = 1;
1525
          values.sals[0] = find_function_start_sal (sym,
1526
                                                    funfirstline);
1527
        }
1528
      else
1529
        {
1530
          values.sals = NULL;
1531
          values.nelts = 0;
1532
        }
1533
      return values;
1534
    }
1535
  if (i1 > 0)
1536
    {
1537
      /* There is more than one field with that name
1538
         (overloaded).  Ask the user which one to use.  */
1539
      return decode_line_2 (sym_arr, i1, funfirstline, canonical);
1540
    }
1541
  else
1542
    {
1543
      if (not_found_ptr)
1544
        *not_found_ptr = 1;
1545
      if (copy[0] == '~')
1546
        cplusplus_error (saved_arg,
1547
                         "the class `%s' does not have destructor defined\n",
1548
                         SYMBOL_PRINT_NAME (sym_class));
1549
      else
1550
        cplusplus_error (saved_arg,
1551
                         "the class %s does not have any method named %s\n",
1552
                         SYMBOL_PRINT_NAME (sym_class), copy);
1553
    }
1554
}
1555
 
1556
 
1557
 
1558
/* Return the symtab associated to the filename given by the substring
1559
   of *ARGPTR ending at P, and advance ARGPTR past that filename.  If
1560
   NOT_FOUND_PTR is not null and the source file is not found, store
1561
   boolean true at the location pointed to and do not issue an
1562
   error message.  */
1563
 
1564
static struct symtab *
1565
symtab_from_filename (char **argptr, char *p, int is_quote_enclosed,
1566
                      int *not_found_ptr)
1567
{
1568
  char *p1;
1569
  char *copy;
1570
  struct symtab *file_symtab;
1571
 
1572
  p1 = p;
1573
  while (p != *argptr && p[-1] == ' ')
1574
    --p;
1575
  if ((*p == '"') && is_quote_enclosed)
1576
    --p;
1577
  copy = (char *) alloca (p - *argptr + 1);
1578
  memcpy (copy, *argptr, p - *argptr);
1579
  /* It may have the ending quote right after the file name.  */
1580
  if (is_quote_enclosed && copy[p - *argptr - 1] == '"')
1581
    copy[p - *argptr - 1] = 0;
1582
  else
1583
    copy[p - *argptr] = 0;
1584
 
1585
  /* Find that file's data.  */
1586
  file_symtab = lookup_symtab (copy);
1587
  if (file_symtab == 0)
1588
    {
1589
      if (not_found_ptr)
1590
        *not_found_ptr = 1;
1591
      if (!have_full_symbols () && !have_partial_symbols ())
1592
        throw_error (NOT_FOUND_ERROR,
1593
                     _("No symbol table is loaded.  Use the \"file\" command."));
1594
      throw_error (NOT_FOUND_ERROR, _("No source file named %s."), copy);
1595
    }
1596
 
1597
  /* Discard the file name from the arg.  */
1598
  p = p1 + 1;
1599
  while (*p == ' ' || *p == '\t')
1600
    p++;
1601
  *argptr = p;
1602
 
1603
  return file_symtab;
1604
}
1605
 
1606
 
1607
 
1608
/* This decodes a line where the argument is all digits (possibly
1609
   preceded by a sign).  Q should point to the end of those digits;
1610
   the other arguments are as usual.  */
1611
 
1612
static struct symtabs_and_lines
1613
decode_all_digits (char **argptr, struct symtab *default_symtab,
1614
                   int default_line, char ***canonical,
1615
                   struct symtab *file_symtab, char *q)
1616
 
1617
{
1618
  struct symtabs_and_lines values;
1619
  struct symtab_and_line val;
1620
 
1621
  enum sign
1622
    {
1623
      none, plus, minus
1624
    }
1625
  sign = none;
1626
 
1627
  /* We might need a canonical line spec if no file was specified.  */
1628
  int need_canonical = (file_symtab == NULL) ? 1 : 0;
1629
 
1630
  init_sal (&val);
1631
 
1632
  val.pspace = current_program_space;
1633
 
1634
  /* This is where we need to make sure that we have good defaults.
1635
     We must guarantee that this section of code is never executed
1636
     when we are called with just a function name, since
1637
     set_default_source_symtab_and_line uses
1638
     select_source_symtab that calls us with such an argument.  */
1639
 
1640
  if (file_symtab == 0 && default_symtab == 0)
1641
    {
1642
      /* Make sure we have at least a default source file.  */
1643
      set_default_source_symtab_and_line ();
1644
      initialize_defaults (&default_symtab, &default_line);
1645
    }
1646
 
1647
  if (**argptr == '+')
1648
    sign = plus, (*argptr)++;
1649
  else if (**argptr == '-')
1650
    sign = minus, (*argptr)++;
1651
  val.line = atoi (*argptr);
1652
  switch (sign)
1653
    {
1654
    case plus:
1655
      if (q == *argptr)
1656
        val.line = 5;
1657
      if (file_symtab == 0)
1658
        val.line = default_line + val.line;
1659
      break;
1660
    case minus:
1661
      if (q == *argptr)
1662
        val.line = 15;
1663
      if (file_symtab == 0)
1664
        val.line = default_line - val.line;
1665
      else
1666
        val.line = 1;
1667
      break;
1668
    case none:
1669
      break;            /* No need to adjust val.line.  */
1670
    }
1671
 
1672
  while (*q == ' ' || *q == '\t')
1673
    q++;
1674
  *argptr = q;
1675
  if (file_symtab == 0)
1676
    file_symtab = default_symtab;
1677
 
1678
  /* It is possible that this source file has more than one symtab,
1679
     and that the new line number specification has moved us from the
1680
     default (in file_symtab) to a new one.  */
1681
  val.symtab = find_line_symtab (file_symtab, val.line, NULL, NULL);
1682
  if (val.symtab == 0)
1683
    val.symtab = file_symtab;
1684
 
1685
  val.pspace = SYMTAB_PSPACE (val.symtab);
1686
  val.pc = 0;
1687
  values.sals = (struct symtab_and_line *)
1688
    xmalloc (sizeof (struct symtab_and_line));
1689
  values.sals[0] = val;
1690
  values.nelts = 1;
1691
  if (need_canonical)
1692
    build_canonical_line_spec (values.sals, NULL, canonical);
1693
  values.sals[0].explicit_line = 1;
1694
  return values;
1695
}
1696
 
1697
 
1698
 
1699
/* Decode a linespec starting with a dollar sign.  */
1700
 
1701
static struct symtabs_and_lines
1702
decode_dollar (char *copy, int funfirstline, struct symtab *default_symtab,
1703
               char ***canonical, struct symtab *file_symtab)
1704
{
1705
  LONGEST valx;
1706
  int index = 0;
1707
  int need_canonical = 0;
1708
  struct symtabs_and_lines values;
1709
  struct symtab_and_line val;
1710
  char *p;
1711
  struct symbol *sym;
1712
  struct minimal_symbol *msymbol;
1713
 
1714
  p = (copy[1] == '$') ? copy + 2 : copy + 1;
1715
  while (*p >= '0' && *p <= '9')
1716
    p++;
1717
  if (!*p)              /* Reached end of token without hitting non-digit.  */
1718
    {
1719
      /* We have a value history reference.  */
1720
      struct value *val_history;
1721
      sscanf ((copy[1] == '$') ? copy + 2 : copy + 1, "%d", &index);
1722
      val_history = access_value_history ((copy[1] == '$') ? -index : index);
1723
      if (TYPE_CODE (value_type (val_history)) != TYPE_CODE_INT)
1724
        error (_("History values used in line specs must have integer values."));
1725
      valx = value_as_long (val_history);
1726
    }
1727
  else
1728
    {
1729
      /* Not all digits -- may be user variable/function or a
1730
         convenience variable.  */
1731
 
1732
      /* Look up entire name as a symbol first.  */
1733
      sym = lookup_symbol (copy, 0, VAR_DOMAIN, 0);
1734
      file_symtab = (struct symtab *) NULL;
1735
      need_canonical = 1;
1736
      /* Symbol was found --> jump to normal symbol processing.  */
1737
      if (sym)
1738
        return symbol_found (funfirstline, canonical, copy, sym, NULL);
1739
 
1740
      /* If symbol was not found, look in minimal symbol tables.  */
1741
      msymbol = lookup_minimal_symbol (copy, NULL, NULL);
1742
      /* Min symbol was found --> jump to minsym processing.  */
1743
      if (msymbol)
1744
        return minsym_found (funfirstline, msymbol);
1745
 
1746
      /* Not a user variable or function -- must be convenience variable.  */
1747
      if (!get_internalvar_integer (lookup_internalvar (copy + 1), &valx))
1748
        error (_("Convenience variables used in line specs must have integer values."));
1749
    }
1750
 
1751
  init_sal (&val);
1752
 
1753
  /* Either history value or convenience value from above, in valx.  */
1754
  val.symtab = file_symtab ? file_symtab : default_symtab;
1755
  val.line = valx;
1756
  val.pc = 0;
1757
  val.pspace = current_program_space;
1758
 
1759
  values.sals = (struct symtab_and_line *) xmalloc (sizeof val);
1760
  values.sals[0] = val;
1761
  values.nelts = 1;
1762
 
1763
  if (need_canonical)
1764
    build_canonical_line_spec (values.sals, NULL, canonical);
1765
 
1766
  return values;
1767
}
1768
 
1769
 
1770
 
1771
/* Decode a linespec that's a variable.  If FILE_SYMTAB is non-NULL,
1772
   look in that symtab's static variables first.  If NOT_FOUND_PTR is not NULL and
1773
   the function cannot be found, store boolean true in the location pointed to
1774
   and do not issue an error message.  */
1775
 
1776
static struct symtabs_and_lines
1777
decode_variable (char *copy, int funfirstline, char ***canonical,
1778
                 struct symtab *file_symtab, int *not_found_ptr)
1779
{
1780
  struct symbol *sym;
1781
 
1782
  struct minimal_symbol *msymbol;
1783
 
1784
  sym = lookup_symbol (copy,
1785
                       (file_symtab
1786
                        ? BLOCKVECTOR_BLOCK (BLOCKVECTOR (file_symtab),
1787
                                             STATIC_BLOCK)
1788
                        : get_selected_block (0)),
1789
                       VAR_DOMAIN, 0);
1790
 
1791
  if (sym != NULL)
1792
    return symbol_found (funfirstline, canonical, copy, sym, file_symtab);
1793
 
1794
  msymbol = lookup_minimal_symbol (copy, NULL, NULL);
1795
 
1796
  if (msymbol != NULL)
1797
    return minsym_found (funfirstline, msymbol);
1798
 
1799
  if (not_found_ptr)
1800
    *not_found_ptr = 1;
1801
 
1802
  if (!have_full_symbols ()
1803
      && !have_partial_symbols ()
1804
      && !have_minimal_symbols ())
1805
    throw_error (NOT_FOUND_ERROR,
1806
                 _("No symbol table is loaded.  Use the \"file\" command."));
1807
  throw_error (NOT_FOUND_ERROR, _("Function \"%s\" not defined."), copy);
1808
}
1809
 
1810
 
1811
 
1812
 
1813
/* Now come some functions that are called from multiple places within
1814
   decode_line_1.  */
1815
 
1816
/* We've found a symbol SYM to associate with our linespec; build a
1817
   corresponding struct symtabs_and_lines.  */
1818
 
1819
static struct symtabs_and_lines
1820
symbol_found (int funfirstline, char ***canonical, char *copy,
1821
              struct symbol *sym, struct symtab *file_symtab)
1822
{
1823
  struct symtabs_and_lines values;
1824
 
1825
  if (SYMBOL_CLASS (sym) == LOC_BLOCK)
1826
    {
1827
      /* Arg is the name of a function */
1828
      values.sals = (struct symtab_and_line *)
1829
        xmalloc (sizeof (struct symtab_and_line));
1830
      values.sals[0] = find_function_start_sal (sym, funfirstline);
1831
      values.nelts = 1;
1832
 
1833
      /* Don't use the SYMBOL_LINE; if used at all it points to
1834
         the line containing the parameters or thereabouts, not
1835
         the first line of code.  */
1836
 
1837
      /* We might need a canonical line spec if it is a static
1838
         function.  */
1839
      if (file_symtab == 0)
1840
        {
1841
          struct blockvector *bv = BLOCKVECTOR (SYMBOL_SYMTAB (sym));
1842
          struct block *b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
1843
          if (lookup_block_symbol (b, copy, NULL, VAR_DOMAIN) != NULL)
1844
            build_canonical_line_spec (values.sals, copy, canonical);
1845
        }
1846
      return values;
1847
    }
1848
  else
1849
    {
1850
      if (funfirstline)
1851
        error (_("\"%s\" is not a function"), copy);
1852
      else if (SYMBOL_LINE (sym) != 0)
1853
        {
1854
          /* We know its line number.  */
1855
          values.sals = (struct symtab_and_line *)
1856
            xmalloc (sizeof (struct symtab_and_line));
1857
          values.nelts = 1;
1858
          memset (&values.sals[0], 0, sizeof (values.sals[0]));
1859
          values.sals[0].symtab = SYMBOL_SYMTAB (sym);
1860
          values.sals[0].line = SYMBOL_LINE (sym);
1861
          return values;
1862
        }
1863
      else
1864
        /* This can happen if it is compiled with a compiler which doesn't
1865
           put out line numbers for variables.  */
1866
        /* FIXME: Shouldn't we just set .line and .symtab to zero
1867
           and return?  For example, "info line foo" could print
1868
           the address.  */
1869
        error (_("Line number not known for symbol \"%s\""), copy);
1870
    }
1871
}
1872
 
1873
/* We've found a minimal symbol MSYMBOL to associate with our
1874
   linespec; build a corresponding struct symtabs_and_lines.  */
1875
 
1876
static struct symtabs_and_lines
1877
minsym_found (int funfirstline, struct minimal_symbol *msymbol)
1878
{
1879
  struct objfile *objfile = msymbol_objfile (msymbol);
1880
  struct gdbarch *gdbarch = get_objfile_arch (objfile);
1881
  struct symtabs_and_lines values;
1882
  CORE_ADDR pc;
1883
 
1884
  values.sals = (struct symtab_and_line *)
1885
    xmalloc (sizeof (struct symtab_and_line));
1886
  values.sals[0] = find_pc_sect_line (SYMBOL_VALUE_ADDRESS (msymbol),
1887
                                      (struct obj_section *) 0, 0);
1888
  values.sals[0].section = SYMBOL_OBJ_SECTION (msymbol);
1889
 
1890
  /* The minimal symbol might point to a function descriptor;
1891
     resolve it to the actual code address instead.  */
1892
  pc = gdbarch_convert_from_func_ptr_addr (gdbarch,
1893
                                           values.sals[0].pc,
1894
                                           &current_target);
1895
  if (pc != values.sals[0].pc)
1896
    values.sals[0] = find_pc_sect_line (pc, NULL, 0);
1897
 
1898
  if (funfirstline)
1899
    {
1900
      struct symtab_and_line sal;
1901
 
1902
      values.sals[0].pc = find_function_start_pc (gdbarch,
1903
                                                  values.sals[0].pc,
1904
                                                  values.sals[0].section);
1905
 
1906
      sal = find_pc_sect_line (values.sals[0].pc, values.sals[0].section, 0);
1907
 
1908
      /* Check if SKIP_PROLOGUE left us in mid-line, and the next
1909
         line is still part of the same function.  If there is no
1910
         line information here, sal.pc will be the passed in PC.  */
1911
      if (sal.pc != values.sals[0].pc
1912
          && (lookup_minimal_symbol_by_pc_section (values.sals[0].pc,
1913
                                                   values.sals[0].section)
1914
              == lookup_minimal_symbol_by_pc_section (sal.end,
1915
                                                      values.sals[0].section)))
1916
        /* Recalculate the line number (might not be N+1).  */
1917
        values.sals[0] = find_pc_sect_line (sal.end, values.sals[0].section, 0);
1918
    }
1919
 
1920
  values.nelts = 1;
1921
  return values;
1922
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.