~ubuntu-branches/debian/jessie/gdb/jessie

« back to all changes in this revision

Viewing changes to gdb/linespec.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Jacobowitz
  • Date: 2010-03-20 01:21:29 UTC
  • mfrom: (1.3.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100320012129-t7h25y8zgr8c2369
Tags: 7.1-1
* New upstream release, including:
  - PIE support (Closes: #346409).
  - C++ improvements, including static_cast<> et al, namespace imports,
    and bug fixes in printing virtual base classes.
  - Multi-program debugging.  One GDB can now debug multiple programs
    at the same time.
  - Python scripting improvements, including gdb.parse_and_eval.
  - Updated MIPS Linux signal frame layout (Closes: #570875).
  - No internal error stepping over _dl_debug_state (Closes: #569551).
* Update to Standards-Version: 3.8.4 (no changes required).
* Include more relevant (and smaller) docs in the gdbserver package
  (Closes: #571132).
* Do not duplicate documentation in gdb64, gdb-source, and libgdb-dev.
* Fix crash when switching into TUI mode (Closes: #568489).

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
   Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
4
4
   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008,
5
 
   2009 Free Software Foundation, Inc.
 
5
   2009, 2010 Free Software Foundation, Inc.
6
6
 
7
7
   This file is part of GDB.
8
8
 
30
30
#include "value.h"
31
31
#include "completer.h"
32
32
#include "cp-abi.h"
 
33
#include "cp-support.h"
33
34
#include "parser-defs.h"
34
35
#include "block.h"
35
36
#include "objc-lang.h"
185
186
  int count;
186
187
 
187
188
  CHECK_TYPEDEF (type);
188
 
  if (TYPE_CPLUS_SPECIFIC (type) == NULL)
 
189
  if (! HAVE_CPLUS_STRUCT (type))
189
190
    return 0;
190
191
  count = TYPE_NFN_FIELDS_TOTAL (type);
191
192
 
312
313
                                   NULL, VAR_DOMAIN,
313
314
                                   language,
314
315
                                   (int *) NULL);
315
 
      if (sym_arr[i1])
 
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))
316
320
        i1++;
317
321
      else
318
322
        {
697
701
  int is_quote_enclosed;
698
702
  int is_objc_method = 0;
699
703
  char *saved_arg = *argptr;
 
704
  /* If IS_QUOTED, the end of the quoted bit.  */
 
705
  char *end_quote = NULL;
700
706
 
701
707
  if (not_found_ptr)
702
708
    *not_found_ptr = 0;
716
722
  */
717
723
 
718
724
  set_flags (*argptr, &is_quoted, &paren_pointer);
 
725
  if (is_quoted)
 
726
    end_quote = skip_quoted (*argptr);
719
727
 
720
728
  /* Check to see if it's a multipart linespec (with colons or
721
729
     periods).  */
746
754
      return values;
747
755
  }
748
756
 
 
757
  if (is_quoted)
 
758
    *argptr = *argptr + 1;
 
759
 
749
760
  /* Does it look like there actually were two parts?  */
750
761
 
751
 
  if ((p[0] == ':' || p[0] == '.') && paren_pointer == NULL)
 
762
  if (p[0] == ':' || p[0] == '.')
752
763
    {
753
 
      if (is_quoted)
754
 
        *argptr = *argptr + 1;
755
 
      
756
764
      /* Is it a C++ or Java compound data structure?
757
765
         The check on p[1] == ':' is capturing the case of "::",
758
766
         since p[0]==':' was checked above.  
761
769
         can return now. */
762
770
        
763
771
      if (p[0] == '.' || p[1] == ':')
764
 
        return decode_compound (argptr, funfirstline, canonical,
765
 
                                saved_arg, p, not_found_ptr);
766
 
 
767
 
      /* No, the first part is a filename; set file_symtab to be that file's
768
 
         symtab.  Also, move argptr past the filename.  */
769
 
 
770
 
      file_symtab = symtab_from_filename (argptr, p, is_quote_enclosed, 
771
 
                                          not_found_ptr);
 
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
        }
772
796
    }
773
797
#if 0
774
798
  /* No one really seems to know why this was added. It certainly
828
852
    p = skip_quoted (*argptr + (((*argptr)[1] == '$') ? 2 : 1));
829
853
  else if (is_quoted)
830
854
    {
831
 
      p = skip_quoted (*argptr);
 
855
      p = end_quote;
832
856
      if (p[-1] != '\'')
833
857
        error (_("Unmatched single quote."));
834
858
    }
861
885
      copy[p - *argptr - 1] = '\0';
862
886
      copy++;
863
887
    }
 
888
  else if (is_quoted)
 
889
    copy[p - *argptr - 1] = '\0';
864
890
  while (*p == ' ' || *p == '\t')
865
891
    p++;
866
892
  *argptr = p;
1171
1197
        }
1172
1198
      else
1173
1199
        {
1174
 
          /* The only match was a non-debuggable symbol.  */
1175
 
          values.sals[0].symtab = NULL;
1176
 
          values.sals[0].line = 0;
1177
 
          values.sals[0].end = 0;
1178
 
          values.sals[0].pc = SYMBOL_VALUE_ADDRESS (sym_arr[0]);
 
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;
1179
1213
        }
1180
1214
      return values;
1181
1215
    }
1257
1291
      /* Move pointer ahead to next double-colon.  */
1258
1292
      while (*p && (p[0] != ' ') && (p[0] != '\t') && (p[0] != '\''))
1259
1293
        {
 
1294
          if (current_language->la_language == language_cplus)
 
1295
            p += cp_validate_operator (p);
 
1296
 
1260
1297
          if (p[0] == '<')
1261
1298
            {
1262
1299
              temp_end = find_template_name_end (p);
1334
1371
          while (*p && *p != ' ' && *p != '\t' && *p != ',' && *p != ':')
1335
1372
            p++;
1336
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
            }
1337
1383
        }
1338
1384
 
1339
1385
      /* Allocate our own copy of the substring between argptr and
1407
1453
{
1408
1454
  char *p1;
1409
1455
  char *copy;
 
1456
  struct symbol *sym;
1410
1457
 
1411
1458
  /* Extract the class name.  */
1412
1459
  p1 = p;
1425
1472
  /* At this point p1->"::inA::fun", p->"inA::fun" copy->"AAA",
1426
1473
     argptr->"inA::fun" */
1427
1474
 
1428
 
  return lookup_symbol (copy, 0, STRUCT_DOMAIN, 0);
 
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;
1429
1495
}
1430
1496
 
1431
1497
/* This finds the method COPY in the class whose type is T and whose
1474
1540
    }
1475
1541
  else
1476
1542
    {
1477
 
      char *tmp;
1478
 
 
1479
 
      if (is_operator_name (copy))
1480
 
        {
1481
 
          tmp = (char *) alloca (strlen (copy + 3) + 9);
1482
 
          strcpy (tmp, "operator ");
1483
 
          strcat (tmp, copy + 3);
1484
 
        }
1485
 
      else
1486
 
        tmp = copy;
1487
1543
      if (not_found_ptr)
1488
1544
        *not_found_ptr = 1;
1489
 
      if (tmp[0] == '~')
 
1545
      if (copy[0] == '~')
1490
1546
        cplusplus_error (saved_arg,
1491
1547
                         "the class `%s' does not have destructor defined\n",
1492
1548
                         SYMBOL_PRINT_NAME (sym_class));
1493
1549
      else
1494
1550
        cplusplus_error (saved_arg,
1495
1551
                         "the class %s does not have any method named %s\n",
1496
 
                         SYMBOL_PRINT_NAME (sym_class), tmp);
 
1552
                         SYMBOL_PRINT_NAME (sym_class), copy);
1497
1553
    }
1498
1554
}
1499
1555
 
1573
1629
 
1574
1630
  init_sal (&val);
1575
1631
 
 
1632
  val.pspace = current_program_space;
 
1633
 
1576
1634
  /* This is where we need to make sure that we have good defaults.
1577
1635
     We must guarantee that this section of code is never executed
1578
1636
     when we are called with just a function name, since
1624
1682
  if (val.symtab == 0)
1625
1683
    val.symtab = file_symtab;
1626
1684
 
 
1685
  val.pspace = SYMTAB_PSPACE (val.symtab);
1627
1686
  val.pc = 0;
1628
1687
  values.sals = (struct symtab_and_line *)
1629
1688
    xmalloc (sizeof (struct symtab_and_line));
1695
1754
  val.symtab = file_symtab ? file_symtab : default_symtab;
1696
1755
  val.line = valx;
1697
1756
  val.pc = 0;
 
1757
  val.pspace = current_program_space;
1698
1758
 
1699
1759
  values.sals = (struct symtab_and_line *) xmalloc (sizeof val);
1700
1760
  values.sals[0] = val;