Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFC: allow syms_from_objfile to take a section offset table directly
@ 2002-11-25 13:17 Jim Blandy
  2002-11-25 13:27 ` Elena Zannoni
  0 siblings, 1 reply; 5+ messages in thread
From: Jim Blandy @ 2002-11-25 13:17 UTC (permalink / raw)
  To: gdb-patches


This change is useful when you don't have the section_addr_info
structs any more, but you do have the offset table from an existing
objfile --- say, when you're reloading symbols.

A patch that uses the new interface is forthcoming.

Comments welcome, of course.

2002-11-25  Jim Blandy  <jimb@redhat.com>

	* symfile.c: #include "gdb_assert.h".
	(syms_from_objfile): Add the ability to pass in a section offset
	table directly, as an alternative to the section_addr_info table.
	Document arguments better.
	(symbol_file_add): Pass extra arguments to syms_from_objfile.
	* symfile.h (syms_from_objfile): Update declaration.
	* rs6000-nat.c (objfile_symbol_add): Pass new arguments to
	syms_from_objfile.
	* Makefile.in (symfile.o): List dependency on $(gdb_assert_h).

Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.279
diff -c -r1.279 Makefile.in
*** gdb/Makefile.in	9 Nov 2002 03:14:11 -0000	1.279
--- gdb/Makefile.in	25 Nov 2002 20:32:25 -0000
***************
*** 2207,2213 ****
  	$(frame_h) $(target_h) $(value_h) $(symfile_h) $(objfiles_h) \
  	$(gdbcmd_h) $(breakpoint_h) $(language_h) $(complaints_h) \
  	$(demangle_h) $(inferior_h) $(gdb_stabs_h) $(gdb_obstack_h) \
! 	$(completer_h) $(bcache_h) $(gdb_string_h) $(gdb_stat_h) $(source_h)
  symm-nat.o: symm-nat.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_h) \
  	$(target_h) $(regcache_h) $(gdb_stat_h) $(gdbcore_h) $(gdbcore_h)
  symm-tdep.o: symm-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_h) \
--- 2207,2214 ----
  	$(frame_h) $(target_h) $(value_h) $(symfile_h) $(objfiles_h) \
  	$(gdbcmd_h) $(breakpoint_h) $(language_h) $(complaints_h) \
  	$(demangle_h) $(inferior_h) $(gdb_stabs_h) $(gdb_obstack_h) \
! 	$(completer_h) $(bcache_h) $(gdb_string_h) $(gdb_stat_h) $(source_h) \
! 	$(gdb_assert_h)
  symm-nat.o: symm-nat.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_h) \
  	$(target_h) $(regcache_h) $(gdb_stat_h) $(gdbcore_h) $(gdbcore_h)
  symm-tdep.o: symm-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_h) \
Index: gdb/rs6000-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-nat.c,v
retrieving revision 1.27
diff -c -r1.27 rs6000-nat.c
*** gdb/rs6000-nat.c	26 Jul 2002 23:12:59 -0000	1.27
--- gdb/rs6000-nat.c	25 Nov 2002 20:32:33 -0000
***************
*** 685,691 ****
  {
    struct objfile *obj = (struct objfile *) arg;
  
!   syms_from_objfile (obj, NULL, 0, 0);
    new_symfile_objfile (obj, 0, 0);
    return 1;
  }
--- 685,691 ----
  {
    struct objfile *obj = (struct objfile *) arg;
  
!   syms_from_objfile (obj, NULL, 0, 0, 0, 0);
    new_symfile_objfile (obj, 0, 0);
    return 1;
  }
Index: gdb/symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.73
diff -c -r1.73 symfile.c
*** gdb/symfile.c	25 Nov 2002 20:11:35 -0000	1.73
--- gdb/symfile.c	25 Nov 2002 20:32:35 -0000
***************
*** 42,47 ****
--- 42,48 ----
  #include "gdb_obstack.h"
  #include "completer.h"
  #include "bcache.h"
+ #include "gdb_assert.h"
  
  #include <sys/types.h>
  #include <fcntl.h>
***************
*** 561,568 ****
  
     OBJFILE is where the symbols are to be read from.
  
!    ADDR is the address where the text segment was loaded, unless the
!    objfile is the main symbol file, in which case it is zero.
  
     MAINLINE is nonzero if this is the main symbol file, or zero if
     it's an extra symbol file such as dynamically loaded code.
--- 562,587 ----
  
     OBJFILE is where the symbols are to be read from.
  
!    ADDRS is the list of section load addresses.  If the user has given
!    an 'add-symbol-file' command, then this is the list of offsets and
!    addresses he or she provided as arguments to the command; or, if
!    we're handling a shared library, these are the actual addresses the
!    sections are loaded at, according to the inferior's dynamic linker
!    (as gleaned by GDB's shared library code).  We convert each address
!    into an offset from the section VMA's as it appears in the object
!    file, and then call the file's sym_offsets function to convert this
!    into a format-specific offset table --- a `struct section_offsets'.
!    If ADDRS is non-zero, OFFSETS must be zero.
! 
!    OFFSETS is a table of section offsets already in the right
!    format-specific representation.  NUM_OFFSETS is the number of
!    elements present in OFFSETS->offsets.  If OFFSETS is non-zero, we
!    assume this is the proper table the call to sym_offsets described
!    above would produce.  Instead of calling sym_offsets, we just dump
!    it right into objfile->section_offsets.  (When we're re-reading
!    symbols from an objfile, we don't have the original load address
!    list any more; all we have is the section offset table.)  If
!    OFFSETS is non-zero, ADDRS must be zero.
  
     MAINLINE is nonzero if this is the main symbol file, or zero if
     it's an extra symbol file such as dynamically loaded code.
***************
*** 571,578 ****
     the symbol reading (and complaints can be more terse about it).  */
  
  void
! syms_from_objfile (struct objfile *objfile, struct section_addr_info *addrs,
! 		   int mainline, int verbo)
  {
    asection *lower_sect;
    asection *sect;
--- 590,601 ----
     the symbol reading (and complaints can be more terse about it).  */
  
  void
! syms_from_objfile (struct objfile *objfile,
!                    struct section_addr_info *addrs,
!                    struct section_offsets *offsets,
!                    int num_offsets,
! 		   int mainline,
!                    int verbo)
  {
    asection *lower_sect;
    asection *sect;
***************
*** 581,596 ****
    struct cleanup *old_chain;
    int i;
  
!   /* If ADDRS is NULL, initialize the local section_addr_info struct and
!      point ADDRS to it.  We now establish the convention that an addr of
!      zero means no load address was specified. */
  
!   if (addrs == NULL)
      {
        memset (&local_addr, 0, sizeof (local_addr));
        addrs = &local_addr;
      }
  
    init_entry_point_info (objfile);
    find_sym_fns (objfile);
  
--- 604,622 ----
    struct cleanup *old_chain;
    int i;
  
!   gdb_assert (! (addrs && offsets));
  
!   /* If ADDRS and OFFSETS are both NULL, put together a dummy address
!      list.  We now establish the convention that an addr of zero means
!      no load address was specified. */
!   if (! addrs && ! offsets)
      {
        memset (&local_addr, 0, sizeof (local_addr));
        addrs = &local_addr;
      }
  
+   /* Now either addrs or offsets is non-zero.  */
+ 
    init_entry_point_info (objfile);
    find_sym_fns (objfile);
  
***************
*** 663,692 ****
   	 this_offset = lower_offset = lower_addr - lower_orig_addr */
  
        /* Calculate offsets for sections. */
!       for (i=0 ; i < MAX_SECTIONS && addrs->other[i].name; i++)
! 	{
! 	  if (addrs->other[i].addr != 0)
!  	    {
!  	      sect = bfd_get_section_by_name (objfile->obfd,
!                                               addrs->other[i].name);
!  	      if (sect)
!  		{
!  		  addrs->other[i].addr
!                     -= bfd_section_vma (objfile->obfd, sect);
!  		  lower_offset = addrs->other[i].addr;
! 		  /* This is the index used by BFD. */
! 		  addrs->other[i].sectindex = sect->index ;
!  		}
!  	      else
! 		{
! 		  warning ("section %s not found in %s", addrs->other[i].name, 
! 			   objfile->name);
! 		  addrs->other[i].addr = 0;
! 		}
!  	    }
!  	  else
!  	    addrs->other[i].addr = lower_offset;
! 	}
      }
  
    /* Initialize symbol reading routines for this objfile, allow complaints to
--- 689,720 ----
   	 this_offset = lower_offset = lower_addr - lower_orig_addr */
  
        /* Calculate offsets for sections. */
!       if (addrs)
!         for (i=0 ; i < MAX_SECTIONS && addrs->other[i].name; i++)
!           {
!             if (addrs->other[i].addr != 0)
!               {
!                 sect = bfd_get_section_by_name (objfile->obfd,
!                                                 addrs->other[i].name);
!                 if (sect)
!                   {
!                     addrs->other[i].addr
!                       -= bfd_section_vma (objfile->obfd, sect);
!                     lower_offset = addrs->other[i].addr;
!                     /* This is the index used by BFD. */
!                     addrs->other[i].sectindex = sect->index ;
!                   }
!                 else
!                   {
!                     warning ("section %s not found in %s",
!                              addrs->other[i].name, 
!                              objfile->name);
!                     addrs->other[i].addr = 0;
!                   }
!               }
!             else
!               addrs->other[i].addr = lower_offset;
!           }
      }
  
    /* Initialize symbol reading routines for this objfile, allow complaints to
***************
*** 696,702 ****
    (*objfile->sf->sym_init) (objfile);
    clear_complaints (&symfile_complaints, 1, verbo);
  
!   (*objfile->sf->sym_offsets) (objfile, addrs);
  
  #ifndef IBM6000_TARGET
    /* This is a SVR4/SunOS specific hack, I think.  In any event, it
--- 724,744 ----
    (*objfile->sf->sym_init) (objfile);
    clear_complaints (&symfile_complaints, 1, verbo);
  
!   if (addrs)
!     (*objfile->sf->sym_offsets) (objfile, addrs);
!   else
!     {
!       size_t size = SIZEOF_N_SECTION_OFFSETS (num_offsets);
! 
!       /* Just copy in the offset table directly as given to us.  */
!       objfile->num_sections = num_offsets;
!       objfile->section_offsets
!         = ((struct section_offsets *)
!            obstack_alloc (&objfile->psymbol_obstack, size));
!       memcpy (objfile->section_offsets, offsets, size);
! 
!       init_objfile_sect_indices (objfile);
!     }
  
  #ifndef IBM6000_TARGET
    /* This is a SVR4/SunOS specific hack, I think.  In any event, it
***************
*** 877,883 ****
  	      gdb_flush (gdb_stdout);
  	    }
  	}
!       syms_from_objfile (objfile, addrs, mainline, from_tty);
      }
  
    /* We now have at least a partial symbol table.  Check to see if the
--- 919,925 ----
  	      gdb_flush (gdb_stdout);
  	    }
  	}
!       syms_from_objfile (objfile, addrs, 0, 0, mainline, from_tty);
      }
  
    /* We now have at least a partial symbol table.  Check to see if the
Index: gdb/symfile.h
===================================================================
RCS file: /cvs/src/src/gdb/symfile.h,v
retrieving revision 1.14
diff -c -r1.14 symfile.h
*** gdb/symfile.h	17 Oct 2002 21:16:12 -0000	1.14
--- gdb/symfile.h	25 Nov 2002 20:32:35 -0000
***************
*** 175,181 ****
  extern void init_entry_point_info (struct objfile *);
  
  extern void
! syms_from_objfile (struct objfile *, struct section_addr_info *, int, int);
  
  extern void new_symfile_objfile (struct objfile *, int, int);
  
--- 175,184 ----
  extern void init_entry_point_info (struct objfile *);
  
  extern void
! syms_from_objfile (struct objfile *,
!                    struct section_addr_info *, 
!                    struct section_offsets *, int,
!                    int, int);
  
  extern void new_symfile_objfile (struct objfile *, int, int);
  


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: RFC: allow syms_from_objfile to take a section offset table directly
  2002-11-25 13:17 RFC: allow syms_from_objfile to take a section offset table directly Jim Blandy
@ 2002-11-25 13:27 ` Elena Zannoni
  2002-11-25 18:28   ` Jim Blandy
  0 siblings, 1 reply; 5+ messages in thread
From: Elena Zannoni @ 2002-11-25 13:27 UTC (permalink / raw)
  To: Jim Blandy; +Cc: gdb-patches



I must confess, I have a problem. I can't read anything but unified diffs.
Jim, could you please please repost diff -u output?

Thanks
Elena


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: RFC: allow syms_from_objfile to take a section offset table directly
  2002-11-25 13:27 ` Elena Zannoni
@ 2002-11-25 18:28   ` Jim Blandy
  2002-12-23  1:22     ` Jim Blandy
  0 siblings, 1 reply; 5+ messages in thread
From: Jim Blandy @ 2002-11-25 18:28 UTC (permalink / raw)
  To: Elena Zannoni; +Cc: gdb-patches


Elena Zannoni <ezannoni@redhat.com> writes:
> I must confess, I have a problem. I can't read anything but unified diffs.
> Jim, could you please please repost diff -u output?

Sure:

2002-11-25  Jim Blandy  <jimb@redhat.com>

	* symfile.c: #include "gdb_assert.h".
	(syms_from_objfile): Add the ability to pass in a section offset
	table directly, as an alternative to the section_addr_info table.
	Document arguments better.
	(symbol_file_add): Pass extra arguments to syms_from_objfile.
	* symfile.h (syms_from_objfile): Update declaration.
	* rs6000-nat.c (objfile_symbol_add): Pass new arguments to
	syms_from_objfile.
	* Makefile.in (symfile.o): List dependency on $(gdb_assert_h).

Index: gdb/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.3502
diff -u -r1.3502 ChangeLog
--- gdb/ChangeLog	25 Nov 2002 21:00:51 -0000	1.3502
+++ gdb/ChangeLog	26 Nov 2002 02:25:44 -0000
@@ -1,5 +1,15 @@
 2002-11-25  Jim Blandy  <jimb@redhat.com>
 
+	* symfile.c: #include "gdb_assert.h".
+	(syms_from_objfile): Add the ability to pass in a section offset
+	table directly, as an alternative to the section_addr_info table.
+	Document arguments better.
+	(symbol_file_add): Pass extra arguments to syms_from_objfile.
+	* symfile.h (syms_from_objfile): Update declaration.
+	* rs6000-nat.c (objfile_symbol_add): Pass new arguments to
+	syms_from_objfile.
+	* Makefile.in (symfile.o): List dependency on $(gdb_assert_h).
+
 	* symfile.c (init_objfile_sect_indices): New function.
 	(default_symfile_offsets): Move the section-index-initializing
 	stuff into init_objfile_sect_indices, and call that.
Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.279
diff -u -r1.279 Makefile.in
--- gdb/Makefile.in	9 Nov 2002 03:14:11 -0000	1.279
+++ gdb/Makefile.in	26 Nov 2002 02:25:46 -0000
@@ -2207,7 +2207,8 @@
 	$(frame_h) $(target_h) $(value_h) $(symfile_h) $(objfiles_h) \
 	$(gdbcmd_h) $(breakpoint_h) $(language_h) $(complaints_h) \
 	$(demangle_h) $(inferior_h) $(gdb_stabs_h) $(gdb_obstack_h) \
-	$(completer_h) $(bcache_h) $(gdb_string_h) $(gdb_stat_h) $(source_h)
+	$(completer_h) $(bcache_h) $(gdb_string_h) $(gdb_stat_h) $(source_h) \
+	$(gdb_assert_h)
 symm-nat.o: symm-nat.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_h) \
 	$(target_h) $(regcache_h) $(gdb_stat_h) $(gdbcore_h) $(gdbcore_h)
 symm-tdep.o: symm-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_h) \
Index: gdb/rs6000-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-nat.c,v
retrieving revision 1.27
diff -u -r1.27 rs6000-nat.c
--- gdb/rs6000-nat.c	26 Jul 2002 23:12:59 -0000	1.27
+++ gdb/rs6000-nat.c	26 Nov 2002 02:25:54 -0000
@@ -685,7 +685,7 @@
 {
   struct objfile *obj = (struct objfile *) arg;
 
-  syms_from_objfile (obj, NULL, 0, 0);
+  syms_from_objfile (obj, NULL, 0, 0, 0, 0);
   new_symfile_objfile (obj, 0, 0);
   return 1;
 }
Index: gdb/symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.74
diff -u -r1.74 symfile.c
--- gdb/symfile.c	25 Nov 2002 21:00:51 -0000	1.74
+++ gdb/symfile.c	26 Nov 2002 02:25:56 -0000
@@ -42,6 +42,7 @@
 #include "gdb_obstack.h"
 #include "completer.h"
 #include "bcache.h"
+#include "gdb_assert.h"
 
 #include <sys/types.h>
 #include <fcntl.h>
@@ -571,8 +572,26 @@
 
    OBJFILE is where the symbols are to be read from.
 
-   ADDR is the address where the text segment was loaded, unless the
-   objfile is the main symbol file, in which case it is zero.
+   ADDRS is the list of section load addresses.  If the user has given
+   an 'add-symbol-file' command, then this is the list of offsets and
+   addresses he or she provided as arguments to the command; or, if
+   we're handling a shared library, these are the actual addresses the
+   sections are loaded at, according to the inferior's dynamic linker
+   (as gleaned by GDB's shared library code).  We convert each address
+   into an offset from the section VMA's as it appears in the object
+   file, and then call the file's sym_offsets function to convert this
+   into a format-specific offset table --- a `struct section_offsets'.
+   If ADDRS is non-zero, OFFSETS must be zero.
+
+   OFFSETS is a table of section offsets already in the right
+   format-specific representation.  NUM_OFFSETS is the number of
+   elements present in OFFSETS->offsets.  If OFFSETS is non-zero, we
+   assume this is the proper table the call to sym_offsets described
+   above would produce.  Instead of calling sym_offsets, we just dump
+   it right into objfile->section_offsets.  (When we're re-reading
+   symbols from an objfile, we don't have the original load address
+   list any more; all we have is the section offset table.)  If
+   OFFSETS is non-zero, ADDRS must be zero.
 
    MAINLINE is nonzero if this is the main symbol file, or zero if
    it's an extra symbol file such as dynamically loaded code.
@@ -581,8 +600,12 @@
    the symbol reading (and complaints can be more terse about it).  */
 
 void
-syms_from_objfile (struct objfile *objfile, struct section_addr_info *addrs,
-		   int mainline, int verbo)
+syms_from_objfile (struct objfile *objfile,
+                   struct section_addr_info *addrs,
+                   struct section_offsets *offsets,
+                   int num_offsets,
+		   int mainline,
+                   int verbo)
 {
   asection *lower_sect;
   asection *sect;
@@ -591,16 +614,19 @@
   struct cleanup *old_chain;
   int i;
 
-  /* If ADDRS is NULL, initialize the local section_addr_info struct and
-     point ADDRS to it.  We now establish the convention that an addr of
-     zero means no load address was specified. */
+  gdb_assert (! (addrs && offsets));
 
-  if (addrs == NULL)
+  /* If ADDRS and OFFSETS are both NULL, put together a dummy address
+     list.  We now establish the convention that an addr of zero means
+     no load address was specified. */
+  if (! addrs && ! offsets)
     {
       memset (&local_addr, 0, sizeof (local_addr));
       addrs = &local_addr;
     }
 
+  /* Now either addrs or offsets is non-zero.  */
+
   init_entry_point_info (objfile);
   find_sym_fns (objfile);
 
@@ -673,30 +699,32 @@
  	 this_offset = lower_offset = lower_addr - lower_orig_addr */
 
       /* Calculate offsets for sections. */
-      for (i=0 ; i < MAX_SECTIONS && addrs->other[i].name; i++)
-	{
-	  if (addrs->other[i].addr != 0)
- 	    {
- 	      sect = bfd_get_section_by_name (objfile->obfd,
-                                              addrs->other[i].name);
- 	      if (sect)
- 		{
- 		  addrs->other[i].addr
-                    -= bfd_section_vma (objfile->obfd, sect);
- 		  lower_offset = addrs->other[i].addr;
-		  /* This is the index used by BFD. */
-		  addrs->other[i].sectindex = sect->index ;
- 		}
- 	      else
-		{
-		  warning ("section %s not found in %s", addrs->other[i].name, 
-			   objfile->name);
-		  addrs->other[i].addr = 0;
-		}
- 	    }
- 	  else
- 	    addrs->other[i].addr = lower_offset;
-	}
+      if (addrs)
+        for (i=0 ; i < MAX_SECTIONS && addrs->other[i].name; i++)
+          {
+            if (addrs->other[i].addr != 0)
+              {
+                sect = bfd_get_section_by_name (objfile->obfd,
+                                                addrs->other[i].name);
+                if (sect)
+                  {
+                    addrs->other[i].addr
+                      -= bfd_section_vma (objfile->obfd, sect);
+                    lower_offset = addrs->other[i].addr;
+                    /* This is the index used by BFD. */
+                    addrs->other[i].sectindex = sect->index ;
+                  }
+                else
+                  {
+                    warning ("section %s not found in %s",
+                             addrs->other[i].name, 
+                             objfile->name);
+                    addrs->other[i].addr = 0;
+                  }
+              }
+            else
+              addrs->other[i].addr = lower_offset;
+          }
     }
 
   /* Initialize symbol reading routines for this objfile, allow complaints to
@@ -706,7 +734,21 @@
   (*objfile->sf->sym_init) (objfile);
   clear_complaints (&symfile_complaints, 1, verbo);
 
-  (*objfile->sf->sym_offsets) (objfile, addrs);
+  if (addrs)
+    (*objfile->sf->sym_offsets) (objfile, addrs);
+  else
+    {
+      size_t size = SIZEOF_N_SECTION_OFFSETS (num_offsets);
+
+      /* Just copy in the offset table directly as given to us.  */
+      objfile->num_sections = num_offsets;
+      objfile->section_offsets
+        = ((struct section_offsets *)
+           obstack_alloc (&objfile->psymbol_obstack, size));
+      memcpy (objfile->section_offsets, offsets, size);
+
+      init_objfile_sect_indices (objfile);
+    }
 
 #ifndef IBM6000_TARGET
   /* This is a SVR4/SunOS specific hack, I think.  In any event, it
@@ -887,7 +929,7 @@
 	      gdb_flush (gdb_stdout);
 	    }
 	}
-      syms_from_objfile (objfile, addrs, mainline, from_tty);
+      syms_from_objfile (objfile, addrs, 0, 0, mainline, from_tty);
     }
 
   /* We now have at least a partial symbol table.  Check to see if the
Index: gdb/symfile.h
===================================================================
RCS file: /cvs/src/src/gdb/symfile.h,v
retrieving revision 1.14
diff -u -r1.14 symfile.h
--- gdb/symfile.h	17 Oct 2002 21:16:12 -0000	1.14
+++ gdb/symfile.h	26 Nov 2002 02:25:56 -0000
@@ -175,7 +175,10 @@
 extern void init_entry_point_info (struct objfile *);
 
 extern void
-syms_from_objfile (struct objfile *, struct section_addr_info *, int, int);
+syms_from_objfile (struct objfile *,
+                   struct section_addr_info *, 
+                   struct section_offsets *, int,
+                   int, int);
 
 extern void new_symfile_objfile (struct objfile *, int, int);
 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: RFC: allow syms_from_objfile to take a section offset table directly
  2002-11-25 18:28   ` Jim Blandy
@ 2002-12-23  1:22     ` Jim Blandy
  2003-01-23 19:24       ` Jim Blandy
  0 siblings, 1 reply; 5+ messages in thread
From: Jim Blandy @ 2002-12-23  1:22 UTC (permalink / raw)
  To: gdb-patches


Here is a new version of this patch, updated to apply to the current
sources.  The meaningful content is just as before.

2002-12-23  Jim Blandy  <jimb@redhat.com>

	* symfile.c: #include "gdb_assert.h".
	(syms_from_objfile): Add the ability to pass in a section offset
	table directly, as an alternative to the section_addr_info table.
	Document arguments better.
	(symbol_file_add): Pass extra arguments to syms_from_objfile.
	* symfile.h (syms_from_objfile): Update declaration.
	* rs6000-nat.c (objfile_symbol_add): Pass new arguments to
	syms_from_objfile.
	* Makefile.in (symfile.o): List dependency on $(gdb_assert_h).

Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.297
diff -c -r1.297 Makefile.in
*** gdb/Makefile.in	21 Dec 2002 05:07:36 -0000	1.297
--- gdb/Makefile.in	23 Dec 2002 08:38:17 -0000
***************
*** 2247,2253 ****
  	$(gdbcmd_h) $(breakpoint_h) $(language_h) $(complaints_h) \
  	$(demangle_h) $(inferior_h) $(gdb_stabs_h) $(gdb_obstack_h) \
  	$(completer_h) $(bcache_h) $(gdb_string_h) $(gdb_stat_h) $(source_h) \
! 	$(readline_h)
  symm-nat.o: symm-nat.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_h) \
  	$(target_h) $(regcache_h) $(gdb_stat_h) $(gdbcore_h) $(gdbcore_h)
  symm-tdep.o: symm-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_h) \
--- 2247,2253 ----
  	$(gdbcmd_h) $(breakpoint_h) $(language_h) $(complaints_h) \
  	$(demangle_h) $(inferior_h) $(gdb_stabs_h) $(gdb_obstack_h) \
  	$(completer_h) $(bcache_h) $(gdb_string_h) $(gdb_stat_h) $(source_h) \
! 	$(gdb_assert_h) $(readline_h)
  symm-nat.o: symm-nat.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_h) \
  	$(target_h) $(regcache_h) $(gdb_stat_h) $(gdbcore_h) $(gdbcore_h)
  symm-tdep.o: symm-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_h) \
Index: gdb/rs6000-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-nat.c,v
retrieving revision 1.27
diff -c -r1.27 rs6000-nat.c
*** gdb/rs6000-nat.c	26 Jul 2002 23:12:59 -0000	1.27
--- gdb/rs6000-nat.c	23 Dec 2002 08:38:18 -0000
***************
*** 685,691 ****
  {
    struct objfile *obj = (struct objfile *) arg;
  
!   syms_from_objfile (obj, NULL, 0, 0);
    new_symfile_objfile (obj, 0, 0);
    return 1;
  }
--- 685,691 ----
  {
    struct objfile *obj = (struct objfile *) arg;
  
!   syms_from_objfile (obj, NULL, 0, 0, 0, 0);
    new_symfile_objfile (obj, 0, 0);
    return 1;
  }
Index: gdb/symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.75
diff -c -r1.75 symfile.c
*** gdb/symfile.c	9 Dec 2002 00:59:26 -0000	1.75
--- gdb/symfile.c	23 Dec 2002 08:38:20 -0000
***************
*** 43,48 ****
--- 43,49 ----
  #include "completer.h"
  #include "bcache.h"
  #include <readline/readline.h>
+ #include "gdb_assert.h"
  
  #include <sys/types.h>
  #include <fcntl.h>
***************
*** 572,579 ****
  
     OBJFILE is where the symbols are to be read from.
  
!    ADDR is the address where the text segment was loaded, unless the
!    objfile is the main symbol file, in which case it is zero.
  
     MAINLINE is nonzero if this is the main symbol file, or zero if
     it's an extra symbol file such as dynamically loaded code.
--- 573,598 ----
  
     OBJFILE is where the symbols are to be read from.
  
!    ADDRS is the list of section load addresses.  If the user has given
!    an 'add-symbol-file' command, then this is the list of offsets and
!    addresses he or she provided as arguments to the command; or, if
!    we're handling a shared library, these are the actual addresses the
!    sections are loaded at, according to the inferior's dynamic linker
!    (as gleaned by GDB's shared library code).  We convert each address
!    into an offset from the section VMA's as it appears in the object
!    file, and then call the file's sym_offsets function to convert this
!    into a format-specific offset table --- a `struct section_offsets'.
!    If ADDRS is non-zero, OFFSETS must be zero.
! 
!    OFFSETS is a table of section offsets already in the right
!    format-specific representation.  NUM_OFFSETS is the number of
!    elements present in OFFSETS->offsets.  If OFFSETS is non-zero, we
!    assume this is the proper table the call to sym_offsets described
!    above would produce.  Instead of calling sym_offsets, we just dump
!    it right into objfile->section_offsets.  (When we're re-reading
!    symbols from an objfile, we don't have the original load address
!    list any more; all we have is the section offset table.)  If
!    OFFSETS is non-zero, ADDRS must be zero.
  
     MAINLINE is nonzero if this is the main symbol file, or zero if
     it's an extra symbol file such as dynamically loaded code.
***************
*** 582,589 ****
     the symbol reading (and complaints can be more terse about it).  */
  
  void
! syms_from_objfile (struct objfile *objfile, struct section_addr_info *addrs,
! 		   int mainline, int verbo)
  {
    asection *lower_sect;
    asection *sect;
--- 601,612 ----
     the symbol reading (and complaints can be more terse about it).  */
  
  void
! syms_from_objfile (struct objfile *objfile,
!                    struct section_addr_info *addrs,
!                    struct section_offsets *offsets,
!                    int num_offsets,
! 		   int mainline,
!                    int verbo)
  {
    asection *lower_sect;
    asection *sect;
***************
*** 592,607 ****
    struct cleanup *old_chain;
    int i;
  
!   /* If ADDRS is NULL, initialize the local section_addr_info struct and
!      point ADDRS to it.  We now establish the convention that an addr of
!      zero means no load address was specified. */
  
!   if (addrs == NULL)
      {
        memset (&local_addr, 0, sizeof (local_addr));
        addrs = &local_addr;
      }
  
    init_entry_point_info (objfile);
    find_sym_fns (objfile);
  
--- 615,633 ----
    struct cleanup *old_chain;
    int i;
  
!   gdb_assert (! (addrs && offsets));
  
!   /* If ADDRS and OFFSETS are both NULL, put together a dummy address
!      list.  We now establish the convention that an addr of zero means
!      no load address was specified. */
!   if (! addrs && ! offsets)
      {
        memset (&local_addr, 0, sizeof (local_addr));
        addrs = &local_addr;
      }
  
+   /* Now either addrs or offsets is non-zero.  */
+ 
    init_entry_point_info (objfile);
    find_sym_fns (objfile);
  
***************
*** 674,703 ****
   	 this_offset = lower_offset = lower_addr - lower_orig_addr */
  
        /* Calculate offsets for sections. */
!       for (i=0 ; i < MAX_SECTIONS && addrs->other[i].name; i++)
! 	{
! 	  if (addrs->other[i].addr != 0)
!  	    {
!  	      sect = bfd_get_section_by_name (objfile->obfd,
!                                               addrs->other[i].name);
!  	      if (sect)
!  		{
!  		  addrs->other[i].addr
!                     -= bfd_section_vma (objfile->obfd, sect);
!  		  lower_offset = addrs->other[i].addr;
! 		  /* This is the index used by BFD. */
! 		  addrs->other[i].sectindex = sect->index ;
!  		}
!  	      else
! 		{
! 		  warning ("section %s not found in %s", addrs->other[i].name, 
! 			   objfile->name);
! 		  addrs->other[i].addr = 0;
! 		}
!  	    }
!  	  else
!  	    addrs->other[i].addr = lower_offset;
! 	}
      }
  
    /* Initialize symbol reading routines for this objfile, allow complaints to
--- 700,731 ----
   	 this_offset = lower_offset = lower_addr - lower_orig_addr */
  
        /* Calculate offsets for sections. */
!       if (addrs)
!         for (i=0 ; i < MAX_SECTIONS && addrs->other[i].name; i++)
!           {
!             if (addrs->other[i].addr != 0)
!               {
!                 sect = bfd_get_section_by_name (objfile->obfd,
!                                                 addrs->other[i].name);
!                 if (sect)
!                   {
!                     addrs->other[i].addr
!                       -= bfd_section_vma (objfile->obfd, sect);
!                     lower_offset = addrs->other[i].addr;
!                     /* This is the index used by BFD. */
!                     addrs->other[i].sectindex = sect->index ;
!                   }
!                 else
!                   {
!                     warning ("section %s not found in %s",
!                              addrs->other[i].name, 
!                              objfile->name);
!                     addrs->other[i].addr = 0;
!                   }
!               }
!             else
!               addrs->other[i].addr = lower_offset;
!           }
      }
  
    /* Initialize symbol reading routines for this objfile, allow complaints to
***************
*** 707,713 ****
    (*objfile->sf->sym_init) (objfile);
    clear_complaints (&symfile_complaints, 1, verbo);
  
!   (*objfile->sf->sym_offsets) (objfile, addrs);
  
  #ifndef IBM6000_TARGET
    /* This is a SVR4/SunOS specific hack, I think.  In any event, it
--- 735,755 ----
    (*objfile->sf->sym_init) (objfile);
    clear_complaints (&symfile_complaints, 1, verbo);
  
!   if (addrs)
!     (*objfile->sf->sym_offsets) (objfile, addrs);
!   else
!     {
!       size_t size = SIZEOF_N_SECTION_OFFSETS (num_offsets);
! 
!       /* Just copy in the offset table directly as given to us.  */
!       objfile->num_sections = num_offsets;
!       objfile->section_offsets
!         = ((struct section_offsets *)
!            obstack_alloc (&objfile->psymbol_obstack, size));
!       memcpy (objfile->section_offsets, offsets, size);
! 
!       init_objfile_sect_indices (objfile);
!     }
  
  #ifndef IBM6000_TARGET
    /* This is a SVR4/SunOS specific hack, I think.  In any event, it
***************
*** 888,894 ****
  	      gdb_flush (gdb_stdout);
  	    }
  	}
!       syms_from_objfile (objfile, addrs, mainline, from_tty);
      }
  
    /* We now have at least a partial symbol table.  Check to see if the
--- 930,936 ----
  	      gdb_flush (gdb_stdout);
  	    }
  	}
!       syms_from_objfile (objfile, addrs, 0, 0, mainline, from_tty);
      }
  
    /* We now have at least a partial symbol table.  Check to see if the
Index: gdb/symfile.h
===================================================================
RCS file: /cvs/src/src/gdb/symfile.h,v
retrieving revision 1.14
diff -c -r1.14 symfile.h
*** gdb/symfile.h	17 Oct 2002 21:16:12 -0000	1.14
--- gdb/symfile.h	23 Dec 2002 08:38:21 -0000
***************
*** 175,181 ****
  extern void init_entry_point_info (struct objfile *);
  
  extern void
! syms_from_objfile (struct objfile *, struct section_addr_info *, int, int);
  
  extern void new_symfile_objfile (struct objfile *, int, int);
  
--- 175,184 ----
  extern void init_entry_point_info (struct objfile *);
  
  extern void
! syms_from_objfile (struct objfile *,
!                    struct section_addr_info *, 
!                    struct section_offsets *, int,
!                    int, int);
  
  extern void new_symfile_objfile (struct objfile *, int, int);
  


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: RFC: allow syms_from_objfile to take a section offset table directly
  2002-12-23  1:22     ` Jim Blandy
@ 2003-01-23 19:24       ` Jim Blandy
  0 siblings, 0 replies; 5+ messages in thread
From: Jim Blandy @ 2003-01-23 19:24 UTC (permalink / raw)
  To: gdb-patches


I've committed this patch.  No user-visible change in behavior.

Jim Blandy <jimb@redhat.com> writes:

> Here is a new version of this patch, updated to apply to the current
> sources.  The meaningful content is just as before.
> 
> 2002-12-23  Jim Blandy  <jimb@redhat.com>
> 
> 	* symfile.c: #include "gdb_assert.h".
> 	(syms_from_objfile): Add the ability to pass in a section offset
> 	table directly, as an alternative to the section_addr_info table.
> 	Document arguments better.
> 	(symbol_file_add): Pass extra arguments to syms_from_objfile.
> 	* symfile.h (syms_from_objfile): Update declaration.
> 	* rs6000-nat.c (objfile_symbol_add): Pass new arguments to
> 	syms_from_objfile.
> 	* Makefile.in (symfile.o): List dependency on $(gdb_assert_h).


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-01-23 19:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-25 13:17 RFC: allow syms_from_objfile to take a section offset table directly Jim Blandy
2002-11-25 13:27 ` Elena Zannoni
2002-11-25 18:28   ` Jim Blandy
2002-12-23  1:22     ` Jim Blandy
2003-01-23 19:24       ` Jim Blandy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox