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

« back to all changes in this revision

Viewing changes to gdb/minsyms.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:
1
1
/* GDB routines for manipulating the minimal symbol tables.
2
2
   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
3
 
   2002, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
 
3
   2002, 2003, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4
4
   Contributed by Cygnus Support, using pieces from other GDB modules.
5
5
 
6
6
   This file is part of GDB.
216
216
       objfile = objfile->next)
217
217
    {
218
218
      if (objf == NULL || objf == objfile
219
 
          || objf->separate_debug_objfile == objfile)
 
219
          || objf == objfile->separate_debug_objfile_backlink)
220
220
        {
221
221
          /* Do two passes: the first over the ordinary hash table,
222
222
             and the second over the demangled hash table.  */
324
324
       objfile = objfile->next)
325
325
    {
326
326
      if (objf == NULL || objf == objfile
327
 
          || objf->separate_debug_objfile == objfile)
 
327
          || objf == objfile->separate_debug_objfile_backlink)
328
328
        {
329
329
          for (msymbol = objfile->msymbol_hash[hash];
330
330
               msymbol != NULL && found_symbol == NULL;
377
377
       objfile = objfile->next)
378
378
    {
379
379
      if (objf == NULL || objf == objfile
380
 
          || objf->separate_debug_objfile == objfile)
 
380
          || objf == objfile->separate_debug_objfile_backlink)
381
381
        {
382
382
          for (msymbol = objfile->msymbol_hash[hash];
383
383
               msymbol != NULL;
416
416
       objfile = objfile->next)
417
417
    {
418
418
      if (objf == NULL || objf == objfile
419
 
          || objf->separate_debug_objfile == objfile)
 
419
          || objf == objfile->separate_debug_objfile_backlink)
420
420
        {
421
421
          for (msymbol = objfile->msymbol_hash[hash];
422
422
               msymbol != NULL && found_symbol == NULL;
473
473
     no telling which one will have the minimal symbols.  */
474
474
 
475
475
  gdb_assert (section != NULL);
476
 
  objfile = section->objfile;
477
 
  if (objfile->separate_debug_objfile)
478
 
    objfile = objfile->separate_debug_objfile;
479
476
 
480
 
  for (; objfile != NULL; objfile = objfile->separate_debug_objfile_backlink)
 
477
  for (objfile = section->objfile;
 
478
       objfile != NULL;
 
479
       objfile = objfile_separate_debug_iterate (section->objfile, objfile))
481
480
    {
482
481
      /* If this objfile has a minimal symbol table, go search it using
483
482
         a binary search.  Note that a minimal symbol table always consists
694
693
{
695
694
  return lookup_minimal_symbol_by_pc_section (pc, NULL);
696
695
}
 
696
 
 
697
/* Find the minimal symbol named NAME, and return both the minsym
 
698
   struct and its objfile.  This only checks the linkage name.  Sets
 
699
   *OBJFILE_P and returns the minimal symbol, if it is found.  If it
 
700
   is not found, returns NULL.  */
 
701
 
 
702
struct minimal_symbol *
 
703
lookup_minimal_symbol_and_objfile (const char *name,
 
704
                                   struct objfile **objfile_p)
 
705
{
 
706
  struct objfile *objfile;
 
707
  unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
 
708
 
 
709
  ALL_OBJFILES (objfile)
 
710
    {
 
711
      struct minimal_symbol *msym;
 
712
 
 
713
      for (msym = objfile->msymbol_hash[hash];
 
714
           msym != NULL;
 
715
           msym = msym->hash_next)
 
716
        {
 
717
          if (strcmp (SYMBOL_LINKAGE_NAME (msym), name) == 0)
 
718
            {
 
719
              *objfile_p = objfile;
 
720
              return msym;
 
721
            }
 
722
        }
 
723
    }
 
724
 
 
725
  return 0;
 
726
}
697
727
 
698
728
 
699
729
/* Return leading symbol character for a BFD. If BFD is NULL,
757
787
   newly created.  */
758
788
 
759
789
struct minimal_symbol *
760
 
prim_record_minimal_symbol_and_info (const char *name, CORE_ADDR address,
761
 
                                     enum minimal_symbol_type ms_type,
762
 
                                     int section,
763
 
                                     asection *bfd_section,
764
 
                                     struct objfile *objfile)
 
790
prim_record_minimal_symbol_full (const char *name, int name_len, int copy_name,
 
791
                                 CORE_ADDR address,
 
792
                                 enum minimal_symbol_type ms_type,
 
793
                                 int section,
 
794
                                 asection *bfd_section,
 
795
                                 struct objfile *objfile)
765
796
{
766
797
  struct obj_section *obj_section;
767
798
  struct msym_bunch *new;
780
811
  /* It's safe to strip the leading char here once, since the name
781
812
     is also stored stripped in the minimal symbol table. */
782
813
  if (name[0] == get_symbol_leading_char (objfile->obfd))
783
 
    ++name;
 
814
    {
 
815
      ++name;
 
816
      --name_len;
 
817
    }
784
818
 
785
819
  if (ms_type == mst_file_text && strncmp (name, "__gnu_compiled", 14) == 0)
786
820
    return (NULL);
795
829
  msymbol = &msym_bunch->contents[msym_bunch_index];
796
830
  SYMBOL_INIT_LANGUAGE_SPECIFIC (msymbol, language_unknown);
797
831
  SYMBOL_LANGUAGE (msymbol) = language_auto;
798
 
  SYMBOL_SET_NAMES (msymbol, (char *)name, strlen (name), objfile);
 
832
  SYMBOL_SET_NAMES (msymbol, name, name_len, copy_name, objfile);
799
833
 
800
834
  SYMBOL_VALUE_ADDRESS (msymbol) = address;
801
835
  SYMBOL_SECTION (msymbol) = section;
828
862
  return msymbol;
829
863
}
830
864
 
 
865
/* Record a minimal symbol in the msym bunches.  Returns the symbol
 
866
   newly created.  */
 
867
 
 
868
struct minimal_symbol *
 
869
prim_record_minimal_symbol_and_info (const char *name, CORE_ADDR address,
 
870
                                     enum minimal_symbol_type ms_type,
 
871
                                     int section,
 
872
                                     asection *bfd_section,
 
873
                                     struct objfile *objfile)
 
874
{
 
875
  return prim_record_minimal_symbol_full (name, strlen (name), 1,
 
876
                                          address, ms_type, section,
 
877
                                          bfd_section, objfile);
 
878
}
 
879
 
831
880
/* Compare two minimal symbols by address and return a signed result based
832
881
   on unsigned comparisons, so that we sort into unsigned numeric order.  
833
882
   Within groups with the same address, sort by name.  */