This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH]: Symbol origin patch, with changelog


SYmbol origin patch again, with changelog this time.
I made the small change Eli requested to the documentation as well.
I know it needs apporoval from jim blandy, and fernando, but even after
looking at the maintainers file, i'm a bit confused as to who else i need
approval from, since i'm not sure what domain  some of these files are
considered part of.
So, I know it's a cop out, but if you think part of this falls under your
maintainership, feel free to approve/reject that part.  Any overlap that
occurs should be straightened out anyway.

2001-01-05  Daniel Berlin  <dberlin@redhat.com>

	* breakpoint.c (print_one_breakpoint): Add origin of symbol, if
	requested.

	* c-exp.y (top level): Add struct objfile variable to keep track
	of where user is trying to get symbol from.
	Add OBJFILE token.
	(block): Also let them specify an objfile as context.
	(variable): Same here.
	(yylex): Handle checking to see if user typed an objfile.

	* defs.h : Add print_symbol_origin variable, general_symbol_info
	forward declaration, prefix_symbol_origin declaration.

	* linespec.c (decode_line_2): Add SYMFILE:FUNCTION to accepted
	syntax in comment. 
	(decode_line_1): Handle user specifying object file as part of
	name of symbol.

	* printcmd.c: Add print_symbol_origin variable to control printing
	of symbol origin.
	(prefix_symbol_origin): New function, prefixes symbol passed in
	with origin, if requested by user.
	(build_address_symbolic): Call function to prefix symbol origin.
	Add origin variable to set/show print list.

	* stack.c (print_frame): Call function to prefix symbol origin.
	(frame_info): Ditto.

	* symtab.c (print_symbol_info): Add new argument to specify component.
	(lookup_objfile): New function. Given a name, return the object
	file with that name.
	(lookup_symbol_objfile): New function. Find definition of symbol
	in a given object file.

	* symtab.h: Add definitions of lookup_symbol_objfile,
	lookup_objfile.

	(doc/gdb.texinfo): Add documentation for the new symbol origin
	stuff.

	
Index: breakpoint.c 
=================================================================== 
RCS file: /cvs/src/src/gdb/breakpoint.c,v 
retrieving revision 1.21 
diff -c -3 -p -r1.21 breakpoint.c 
*** breakpoint.c        2000/12/01 00:41:27     1.21 
--- breakpoint.c        2000/12/14 16:43:58 
*************** print_one_breakpoint (struct breakpoint 
*** 3347,3353 **** 
--- 3347,3358 ---- 
          sym = find_pc_sect_function (b->address, b->section); 
          if (sym) 
            { 
+             const char* origin; 
+ 
+             origin = prefix_symbol_origin (&sym->ginfo); 
+             
              fputs_filtered ("in ", gdb_stdout); 
+             fputs_filtered (origin, gdb_stdout); 
              fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout); 
              wrap_here (wrap_indent); 
              fputs_filtered (" at ", gdb_stdout); 
Index: c-exp.y 
=================================================================== 
RCS file: /cvs/src/src/gdb/c-exp.y,v 
retrieving revision 1.3 
diff -c -3 -p -r1.3 c-exp.y 
*** c-exp.y     2000/06/05 20:49:53     1.3 
--- c-exp.y     2000/12/14 16:43:59 
*************** void yyerror (char *); 
*** 132,137 **** 
--- 132,138 ---- 
      struct symtoken ssym; 
      int voidval; 
      struct block *bval; 
+     struct objfile* ofile; 
      enum exp_opcode opcode; 
      struct internalvar *ivar; 
  
*************** static int parse_number (char *, int, in 
*** 217,222 **** 
--- 218,224 ---- 
  %right ARROW '.' '[' '(' 
  %token <ssym> BLOCKNAME 
  %token <bval> FILENAME 
+ %token <ofile> OBJFILE 
  %type <bval> block 
  %left COLONCOLON 
  
*************** block   :       block COLONCOLON name 
*** 569,575 **** 
                          if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK) 
                            error ("No function \"%s\" in specified context.", 
                                   copy_name ($3)); 
!                         $$ = SYMBOL_BLOCK_VALUE (tem); } 
        ; 
  
  variable:     block COLONCOLON name 
--- 571,588 ---- 
                          if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK) 
                            error ("No function \"%s\" in specified context.", 
                                   copy_name ($3)); 
!                         $$ = SYMBOL_BLOCK_VALUE (tem); 
!                       } 
!       |       OBJFILE ':' name 
!                       { struct symbol* tem 
!                           = lookup_symbol_objfile (copy_name ($3), $1, 
!                                            VAR_NAMESPACE, (int *) NULL, 
!                                            (struct symtab **) NULL); 
!                         if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK) 
!                           error ("No function \"%s\" in specified context.", 
!                                  copy_name ($3)); 
!                         $$ = SYMBOL_BLOCK_VALUE (tem); 
!                       } 
        ; 
  
  variable:     block COLONCOLON name 
*************** variable:       block COLONCOLON name 
*** 586,591 **** 
--- 599,618 ---- 
                          write_exp_elt_block (block_found); 
                          write_exp_elt_sym (sym); 
                          write_exp_elt_opcode (OP_VAR_VALUE); } 
+       |       OBJFILE ':' name 
+                       { struct symbol* sym 
+                           = lookup_symbol_objfile (copy_name ($3), $1, 
+                                            VAR_NAMESPACE, (int *) NULL, 
+                                            (struct symtab **) NULL); 
+                         if (!sym || SYMBOL_CLASS (sym) != LOC_BLOCK) 
+                           error ("No symbol \"%s\" in specified context.", 
+                                  copy_name ($3)); 
+                         write_exp_elt_opcode (OP_VAR_VALUE); 
+                         /* block_found is set by lookup_symbol.  */ 
+                         write_exp_elt_block (block_found); 
+                         write_exp_elt_sym (sym); 
+                         write_exp_elt_opcode (OP_VAR_VALUE); 
+                       } 
        ; 
  
  qualified_name:       typebase COLONCOLON name 
*************** yylex () 
*** 1586,1591 **** 
--- 1613,1631 ---- 
          { 
            yylval.bval = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK); 
            return FILENAME; 
+         } 
+       } 
+ 
+     /* See if it's a symbol file name.  */ 
+     if (!sym) 
+       { 
+       struct objfile *objfile; 
+ 
+       objfile = lookup_objfile (tmp); 
+       if (objfile) 
+         { 
+           yylval.ofile = objfile; 
+           return OBJFILE; 
          } 
        } 
  
Index: defs.h 
=================================================================== 
RCS file: /cvs/src/src/gdb/defs.h,v 
retrieving revision 1.32 
diff -c -3 -p -r1.32 defs.h 
*** defs.h      2000/11/20 02:06:18     1.32 
--- defs.h      2000/12/14 16:43:59 
*************** extern int info_verbose; 
*** 545,550 **** 
--- 545,555 ---- 
  
  extern void set_next_address (CORE_ADDR); 
  
+ extern int print_symbol_origin; 
+ 
+ struct general_symbol_info; 
+ extern const char* prefix_symbol_origin (struct general_symbol_info* sym); 
+ 
  extern void print_address_symbolic (CORE_ADDR, struct ui_file *, int, 
                                    char *); 
  
Index: linespec.c 
=================================================================== 
RCS file: /cvs/src/src/gdb/linespec.c,v 
retrieving revision 1.3 
diff -c -3 -p -r1.3 linespec.c 
*** linespec.c  2000/12/01 00:41:27     1.3 
--- linespec.c  2000/12/14 16:43:59 
*************** decode_line_2 (struct symbol *sym_arr[], 
*** 428,433 **** 
--- 428,434 ---- 
     VARIABLE -- line number of definition of that variable. 
     PC returned is 0. 
     FILE:FUNCTION -- likewise, but prefer functions in that file. 
+    SYMFILE:FUNCTION -- likewise, but the file is the symbol/exec file name. 
     *EXPR -- line in which address EXPR appears. 
  
     This may all be followed by an "if EXPR", which we ignore. 
*************** decode_line_1 (char **argptr, int funfir 
*** 517,522 **** 
--- 518,524 ---- 
    struct type *t; 
    char *saved_arg = *argptr; 
    extern char *gdb_completer_quote_characters; 
+   struct objfile* objfile = 0; 
  
    INIT_SAL (&val);           /* initialize to zeroes */ 
  
*************** decode_line_1 (char **argptr, int funfir 
*** 939,944 **** 
--- 941,960 ---- 
        s = lookup_symtab (copy); 
        if (s == 0) 
        { 
+         q = *argptr; 
+         if (*q == '-' || *q == '+') 
+           q++; 
+         while (*q >= '0' && *q <= '9') 
+           q++; 
+ 
+         /* Find that symbol file's (or exec file's) data.  */ 
+         if (q == *argptr 
+             || !(*q == 0 || *q == ' ' || *q == '\t' || *q == ',')) 
+           objfile = lookup_objfile (copy); 
+       } 
+       
+       if (s == 0 && objfile == 0) 
+       { 
          if (!have_full_symbols () && !have_partial_symbols ()) 
            error ("No symbol table is loaded.  Use the \"file\" command."); 
          error ("No source file named %s.", copy); 
*************** decode_line_1 (char **argptr, int funfir 
*** 1135,1142 **** 
          /* Not all digits -- may be user variable/function or a 
             convenience variable */ 
  
!         /* Look up entire name as a symbol first */ 
!         sym = lookup_symbol (copy, 0, VAR_NAMESPACE, 0, &sym_symtab); 
          s = (struct symtab *) 0; 
          need_canonical = 1; 
          /* Symbol was found --> jump to normal symbol processing. 
--- 1151,1167 ---- 
          /* Not all digits -- may be user variable/function or a 
             convenience variable */ 
  
!         if (objfile) 
!           { 
!             /* Look up in the specified object file.  */ 
!             sym = lookup_symbol_objfile (copy, objfile, VAR_NAMESPACE, 
!                                          0, &sym_symtab); 
!           } 
!         else 
!           { 
!             /* Look up entire name as a symbol first */ 
!             sym = lookup_symbol (copy, 0, VAR_NAMESPACE, 0, &sym_symtab); 
!           } 
          s = (struct symtab *) 0; 
          need_canonical = 1; 
          /* Symbol was found --> jump to normal symbol processing. 
*************** decode_line_1 (char **argptr, int funfir 
*** 1179,1188 **** 
    /* Look up that token as a variable. 
       If file specified, use that file's per-file block to start with.  */ 
  
!   sym = lookup_symbol (copy, 
!                      (s ? BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK) 
!                       : get_selected_block ()), 
!                      VAR_NAMESPACE, 0, &sym_symtab); 
  
  symbol_found:                 /* We also jump here from inside the C++ class/namespace 
                                   code on finding a symbol of the form "A::B::C" */ 
--- 1204,1216 ---- 
    /* Look up that token as a variable. 
       If file specified, use that file's per-file block to start with.  */ 
  
!   if (objfile) 
!     sym = lookup_symbol_objfile (copy, objfile, VAR_NAMESPACE, 0, &sym_symtab); 
!   else 
!     sym = lookup_symbol (copy, 
!                        (s ? BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK) 
!                         : get_selected_block ()), 
!                        VAR_NAMESPACE, 0, &sym_symtab); 
  
  symbol_found:                 /* We also jump here from inside the C++ class/namespace 
                                   code on finding a symbol of the form "A::B::C" */ 
*************** symbol_found:                   /* We also jump here fro 
*** 1237,1243 **** 
        } 
      } 
  
!   msymbol = lookup_minimal_symbol (copy, NULL, NULL); 
  
  minimal_symbol_found:         /* We also jump here from the case for variables 
                                   that begin with '$' */ 
--- 1265,1274 ---- 
        } 
      } 
  
!   if (objfile) 
!     msymbol = lookup_minimal_symbol (copy, 0, objfile); 
!   else 
!     msymbol = lookup_minimal_symbol (copy, NULL, NULL); 
  
  minimal_symbol_found:         /* We also jump here from the case for variables 
                                   that begin with '$' */ 
Index: printcmd.c 
=================================================================== 
RCS file: /cvs/src/src/gdb/printcmd.c,v 
retrieving revision 1.13 
diff -c -3 -p -r1.13 printcmd.c 
*** printcmd.c  2000/08/25 20:51:19     1.13 
--- printcmd.c  2000/12/14 16:44:00 
*************** static unsigned int max_symbolic_offset 
*** 85,90 **** 
--- 85,95 ---- 
     printing a symbolic value as `<symbol at filename:linenum>' if set.  */ 
  static int print_symbol_filename = 0; 
  
+ /* When set, print the basename of the symbol file which owns a given 
+    symbol.  Note that this is not the source file name but the executable 
+    or global symbol file (and there may be several).  */ 
+ static int print_symbol_origin = 0; 
+ 
  /* Number of auto-display expression currently being displayed. 
     So that we can disable it if we get an error or a signal within it. 
     -1 when not doing one.  */ 
*************** set_next_address (CORE_ADDR addr) 
*** 526,531 **** 
--- 531,570 ---- 
                                       addr)); 
  } 
  
+ /* Build a string representing the origin of 
+    the symbol.  Such string is printed before each symbol name when 
+    'prefix_symbol_origin' is set.  Otherwise, returns an empty string.  */ 
+ const char* 
+ prefix_symbol_origin (struct general_symbol_info* sym) 
+ { 
+   asection* sect; 
+   const char* file_name; 
+   char* p; 
+   
+   static char buf[256]; 
+ 
+   buf[0] = 0; 
+   if (sym == 0 || print_symbol_origin == 0) 
+     return buf; 
+   
+   sect = sym->bfd_section; 
+   file_name = sect->owner->filename; 
+   p = strrchr (file_name, SLASH_CHAR); 
+   if (p == 0) 
+     p = (char*) file_name; 
+   else 
+     p++; 
+   
+   strncpy (buf, p, sizeof (buf) - 1); 
+   p = strrchr (buf, '.'); 
+   if (p) 
+     *p = 0; 
+   
+   strcat (buf, ":"); 
+   return buf; 
+ } 
+ 
+ 
  /* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM, 
     after LEADIN.  Print nothing if no symbolic name is found nearby. 
     Optionally also print source file and line number, if available. 
*************** build_address_symbolic (CORE_ADDR addr, 
*** 601,606 **** 
--- 640,646 ---- 
    CORE_ADDR name_location = 0; 
    asection *section = 0; 
    char *name_temp = ""; 
+   const char* origin; 
    
    /* Let's say it is unmapped. */ 
    *unmapped = 0; 
*************** build_address_symbolic (CORE_ADDR addr, 
*** 647,652 **** 
--- 687,697 ---- 
        name_temp = SYMBOL_LINKAGE_NAME (symbol); 
      } 
  
+   if (msymbol) 
+     origin = prefix_symbol_origin (&msymbol->ginfo); 
+   else 
+     origin = ""; 
+ 
    if (msymbol != NULL) 
      { 
        if (SYMBOL_VALUE_ADDRESS (msymbol) > name_location || symbol == NULL) 
*************** build_address_symbolic (CORE_ADDR addr, 
*** 686,692 **** 
  
    *offset = addr - name_location; 
  
!   *name = xstrdup (name_temp); 
  
    if (print_symbol_filename) 
      { 
--- 731,739 ---- 
  
    *offset = addr - name_location; 
  
!   *name = xmalloc (strlen (origin) + strlen (name_temp) + 1); 
!   strcpy (*name, origin); 
!   strcat (*name, name_temp); 
  
    if (print_symbol_filename) 
      { 
*************** environment, the value is printed in its 
*** 2609,2614 **** 
--- 2656,2668 ---- 
                      add_set_cmd ("symbol-filename", no_class, var_boolean, 
                                   (char *) &print_symbol_filename, 
           "Set printing of source filename and line number with <symbol>.", 
+                                  &setprintlist), 
+                     &showprintlist); 
+ 
+   add_show_from_set ( 
+                     add_set_cmd ("origin", no_class, var_boolean, 
+                                  (char *) &print_symbol_origin, 
+    "Set printing of a short form of the symbol file name with <symbol>.", 
                                   &setprintlist), 
                      &showprintlist); 
  
Index: stack.c 
=================================================================== 
RCS file: /cvs/src/src/gdb/stack.c,v 
retrieving revision 1.9 
diff -c -3 -p -r1.9 stack.c 
*** stack.c     2000/11/06 20:25:36     1.9 
--- stack.c     2000/12/14 16:44:00 
*************** print_frame (struct frame_info *fi, 
*** 445,450 **** 
--- 445,451 ---- 
    struct symbol *func; 
    register char *funname = 0; 
    enum language funlang = language_unknown; 
+   const char* origin = ""; 
  #ifdef UI_OUT 
    struct ui_stream *stb; 
    struct cleanup *old_chain; 
*************** print_frame (struct frame_info *fi, 
*** 473,478 **** 
--- 474,482 ---- 
           create a find_pc_minimal_function or some such).  */ 
  
        struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (fi->pc); 
+       if (msymbol) 
+       origin = prefix_symbol_origin (&msymbol->ginfo); 
+ 
        if (msymbol != NULL 
          && (SYMBOL_VALUE_ADDRESS (msymbol) 
              > BLOCK_START (SYMBOL_BLOCK_VALUE (func)))) 
*************** print_frame (struct frame_info *fi, 
*** 558,563 **** 
--- 562,568 ---- 
        printf_filtered (" in "); 
  #endif 
        } 
+   fprintf_filtered (gdb_stdout, origin);  
    annotate_frame_function_name (); 
  #ifdef UI_OUT 
    fprintf_symbol_filtered (stb->stream, funname ? funname : "??", funlang, 
*************** frame_info (char *addr_exp, int from_tty 
*** 839,844 **** 
--- 844,850 ---- 
    int i, count, numregs; 
    char *funname = 0; 
    enum language funlang = language_unknown; 
+   const char* origin = ""; 
  
    if (!target_has_stack) 
      error ("No stack."); 
*************** frame_info (char *addr_exp, int from_tty 
*** 889,894 **** 
--- 895,901 ---- 
        { 
          funname = SYMBOL_NAME (msymbol); 
          funlang = SYMBOL_LANGUAGE (msymbol); 
+         origin = prefix_symbol_origin (&msymbol->ginfo); 
        } 
      } 
    calling_frame_info = get_prev_frame (fi); 
Index: symtab.c 
=================================================================== 
RCS file: /cvs/src/src/gdb/symtab.c,v 
retrieving revision 1.24 
diff -c -3 -p -r1.24 symtab.c 
*** symtab.c    2000/12/01 00:41:27     1.24 
--- symtab.c    2000/12/14 16:44:01 
*************** static void fixup_section (struct genera 
*** 96,102 **** 
  static int file_matches (char *, char **, int); 
  
  static void print_symbol_info (namespace_enum, 
!                              struct symtab *, struct symbol *, int, char *); 
  
  static void print_msymbol_info (struct minimal_symbol *); 
  
--- 96,103 ---- 
  static int file_matches (char *, char **, int); 
  
  static void print_symbol_info (namespace_enum, 
!                              struct symtab *, struct symbol *, int, char *, 
!                              char*); 
  
  static void print_msymbol_info (struct minimal_symbol *); 
  
*************** cplusplus_hint (char *name) 
*** 130,135 **** 
--- 131,189 ---- 
    printf_filtered ("(Note leading single quote.)\n"); 
  } 
  
+ /* Find the object file matching the name.  If there is no '/', a matching 
+    tail is returned.  Object file name extension may be ignored.  */ 
+ 
+ struct objfile * 
+ lookup_objfile (const char *name) 
+ { 
+   register char *slash; 
+   register struct objfile *objfile; 
+   register struct objfile *result; 
+ 
+   /* First, search for an exact match */ 
+ 
+   ALL_OBJFILES (objfile) 
+     if (STREQ (name, objfile->name)) 
+       return objfile; 
+ 
+   slash = strchr (name, '/'); 
+ 
+   /* Now, search for a matching tail (only if name doesn't have any dirs). 
+      If there is no match, try to ignore a possible extension and keep 
+      track of such possible match.  This 'ignore-extension' match will 
+      be returned if we have not an exact tail match.  */ 
+   result = NULL; 
+   if (!slash) 
+     ALL_OBJFILES (objfile) 
+     { 
+       char *p = objfile->name; 
+       char *tail = strrchr (p, '/'); 
+       char *q; 
+ 
+       if (tail) 
+       p = tail + 1; 
+ 
+       if (STREQ (p, name)) 
+       return objfile; 
+ 
+       if (result) 
+       continue; 
+ 
+       /* Look for a possible match if we ignore the object file extension.  */ 
+       q = strrchr (p, '.'); 
+       if (q) 
+       { 
+         size_t len = (size_t) (q - p); 
+         
+         if (strncmp (p, name, len) == 0 && name[len] == 0) 
+           result = objfile; 
+       } 
+     } 
+ 
+   return result; 
+ } 
+ 
  /* Check for a symtab of a specific name; first in symtabs, then in 
     psymtabs.  *If* there is no '/' in the name, a match after a '/' 
     in the symtab filename will also work.  */ 
*************** fixup_psymbol_section (struct partial_sy 
*** 534,539 **** 
--- 588,659 ---- 
    return psym; 
  } 
  
+ /* Find the definition for a symbol in a specific object file.  */ 
+ struct symbol * 
+ lookup_symbol_objfile (const char *name, const struct objfile *objfile, 
+                      const namespace_enum namespace, 
+                      int *is_a_field_of_this, struct symtab **symtab) 
+ { 
+   struct symbol* sym = 0; 
+   struct symtab* s = 0; 
+   struct minimal_symbol* msymbol; 
+   struct blockvector* bv; 
+   struct block* block=0; 
+         
+   msymbol = lookup_minimal_symbol (name, 0, (struct objfile *)objfile); 
+   if (msymbol != NULL) 
+     { 
+       s = find_pc_sect_symtab (SYMBOL_VALUE_ADDRESS (msymbol), 
+                              SYMBOL_BFD_SECTION (msymbol)); 
+       if (s != NULL) 
+       { 
+         /* This is a function which has a symtab for its address.  */ 
+         bv = BLOCKVECTOR (s); 
+         block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); 
+         sym = lookup_block_symbol (block, SYMBOL_NAME (msymbol), 
+                                    namespace); 
+         /* We kept static functions in minimal symbol table as well as 
+            in static scope. We want to find them in the symbol table. */ 
+         if (!sym) 
+           { 
+             block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); 
+             sym = lookup_block_symbol (block, SYMBOL_NAME (msymbol), 
+                                        namespace); 
+           } 
+ 
+         /* sym == 0 if symbol was found in the minimal symbol table 
+            but not in the symtab. 
+            Return 0 to use the msymbol definition of "foo_". 
+ 
+            This happens for Fortran  "foo_" symbols, 
+            which are "foo" in the symtab. 
+ 
+            This can also happen if "asm" is used to make a 
+            regular symbol but not a debugging symbol, e.g. 
+            asm(".globl _main"); 
+            asm("_main:"); 
+            */ 
+ 
+         if (symtab != NULL) 
+           *symtab = s; 
+         return fixup_symbol_section (sym, (struct objfile *)objfile); 
+       } 
+       else if (MSYMBOL_TYPE (msymbol) != mst_text 
+              && MSYMBOL_TYPE (msymbol) != mst_file_text 
+              && !STREQ (name, SYMBOL_NAME (msymbol))) 
+       { 
+         /* This is a mangled variable, look it up by its 
+            mangled name.  */ 
+         return lookup_symbol (SYMBOL_NAME (msymbol), block, 
+                               namespace, is_a_field_of_this, symtab); 
+       } 
+       /* There are no debug symbols for this file, or we are looking 
+        for an unmangled variable. 
+        Try to find a matching static symbol below. */ 
+     } 
+   return 0; 
+ } 
+ 
  /* Find the definition for a specified symbol name NAME 
     in namespace NAMESPACE, visible from lexical block BLOCK. 
     Returns the struct symbol pointer, or zero if no symbol is found. 
*************** search_symbols (char *regexp, namespace_ 
*** 2589,2596 **** 
   */ 
  static void 
  print_symbol_info (namespace_enum kind, struct symtab *s, struct symbol *sym, 
!                  int block, char *last) 
  { 
    if (last == NULL || strcmp (last, s->filename) != 0) 
      { 
        fputs_filtered ("\nFile ", gdb_stdout); 
--- 2710,2724 ---- 
   */ 
  static void 
  print_symbol_info (namespace_enum kind, struct symtab *s, struct symbol *sym, 
!                  int block, char *last, char *last_component) 
  { 
+   if (last_component == NULL 
+       || strcmp (last_component, s->objfile->name) != 0) 
+     { 
+       fputs_filtered ("\nComponent ", gdb_stdout); 
+       fputs_filtered (s->objfile->name, gdb_stdout); 
+       fputs_filtered (":\n", gdb_stdout); 
+     } 
    if (last == NULL || strcmp (last, s->filename) != 0) 
      { 
        fputs_filtered ("\nFile ", gdb_stdout); 
*************** symtab_symbol_info (char *regexp, namesp 
*** 2669,2674 **** 
--- 2797,2803 ---- 
    struct symbol_search *p; 
    struct cleanup *old_chain; 
    char *last_filename = NULL; 
+   char *last_component = NULL; 
    int first = 1; 
  
    /* must make sure that if we're interrupted, symbols gets freed */ 
*************** symtab_symbol_info (char *regexp, namesp 
*** 2695,2706 **** 
        } 
        else 
        { 
          print_symbol_info (kind, 
                             p->symtab, 
                             p->symbol, 
                             p->block, 
!                            last_filename); 
          last_filename = p->symtab->filename; 
        } 
      } 
  
--- 2824,2841 ---- 
        } 
        else 
        { 
+         if (last_component == 0 
+             || strcmp (last_component, p->symtab->objfile->name) != 0) 
+           { 
+             last_filename = 0; 
+           } 
          print_symbol_info (kind, 
                             p->symtab, 
                             p->symbol, 
                             p->block, 
!                            last_filename, last_component); 
          last_filename = p->symtab->filename; 
+         last_component = p->symtab->objfile->name; 
        } 
      } 
  
*************** rbreak_command (char *regexp, int from_t 
*** 2769,2775 **** 
                             p->symtab, 
                             p->symbol, 
                             p->block, 
!                            p->symtab->filename); 
        } 
        else 
        { 
--- 2904,2911 ---- 
                             p->symtab, 
                             p->symbol, 
                             p->block, 
!                            p->symtab->filename, 
!                            p->symtab->objfile->name); 
        } 
        else 
        { 
Index: symtab.h 
=================================================================== 
RCS file: /cvs/src/src/gdb/symtab.h,v 
retrieving revision 1.16 
diff -c -3 -p -r1.16 symtab.h 
*** symtab.h    2000/11/10 23:02:56     1.16 
--- symtab.h    2000/12/14 16:44:01 
*************** extern struct symtab *lookup_symtab (cha 
*** 1101,1106 **** 
--- 1113,1129 ---- 
  extern struct symbol *lookup_symbol (const char *, const struct block *, 
                                     const namespace_enum, int *, 
                                     struct symtab **); 
+ 
+ /* lookup a symbol by name in a given object file 
+    (optional block, optional symtab) */ 
+ 
+ extern struct symbol * 
+   lookup_symbol_objfile PARAMS ((const char *, const struct objfile *, 
+                        const namespace_enum, int *, struct symtab **)); 
+ 
+ /* lookup the object file matching a name.  */ 
+ 
+ extern struct objfile* lookup_objfile (const char*); 
  
  /* lookup a symbol by name, within a specified block */ 
  
Index: doc/gdb.texinfo 
=================================================================== 
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v 
retrieving revision 1.30 
diff -c -3 -p -r1.30 gdb.texinfo 
*** gdb.texinfo 2000/11/19 06:31:39     1.30 
--- gdb.texinfo 2000/12/14 16:44:04 
*************** you can set @value{GDBN} to print the so 
*** 4927,4932 **** 
--- 4927,4947 ---- 
  it prints a symbolic address: 
  
  @table @code 
+ @kindex set print origin 
+ @item set print origin on 
+ Tell @value{GDBN} to prefix the symbol names it prints with their origin 
+ (object file they came from). 
+ 
+ @item set print origin off 
+ Do not print the origin of a symbol when printing a symbol name.  This 
+ is the default. 
+ 
+ @item show print origin 
+ Show whether or not @value{GDBN} will print the origin of a symbol when 
+ printing a symbol name. 
+ @end table 
+ 
+ @table @code 
  @kindex set print symbol-filename 
  @item set print symbol-filename on 
  Tell @value{GDBN} to print the source file name and line number of a 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]