* Makefile.in (gencode): Provide explicit path to gencode.c.
[deliverable/binutils-gdb.git] / gdb / somsolib.c
index 892cbc9bea49bd5fe3aff7a26a92bf5198043610..fe188ca460a0f8a314653b34f0af233f36f4b0df 100644 (file)
@@ -1,5 +1,6 @@
 /* Handle HP SOM shared libraries for GDB, the GNU Debugger.
-   Copyright 1993, 1996, 1999 Free Software Foundation, Inc.
+   Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -39,6 +40,7 @@
 #include "gdbcmd.h"
 #include "assert.h"
 #include "language.h"
+#include "regcache.h"
 
 #include <fcntl.h>
 
@@ -230,7 +232,7 @@ som_solib_sizeof_symbol_table (char *filename)
   if (!abfd)
     {
       close (desc);
-      make_cleanup (free, filename);
+      make_cleanup (xfree, filename);
       error ("\"%s\": can't open to read symbols: %s.", filename,
             bfd_errmsg (bfd_get_error ()));
     }
@@ -238,7 +240,7 @@ som_solib_sizeof_symbol_table (char *filename)
   if (!bfd_check_format (abfd, bfd_object))    /* Reads in section info */
     {
       bfd_close (abfd);                /* This also closes desc */
-      make_cleanup (free, filename);
+      make_cleanup (xfree, filename);
       error ("\"%s\": can't read symbols: %s.", filename,
             bfd_errmsg (bfd_get_error ()));
     }
@@ -256,7 +258,7 @@ som_solib_sizeof_symbol_table (char *filename)
     st_size += (LONGEST) bfd_section_size (abfd, sect);
 
   bfd_close (abfd);            /* This also closes desc */
-  free (filename);
+  xfree (filename);
 
   /* Unfortunately, just summing the sizes of various debug info
      sections isn't a very accurate measurement of how much heap
@@ -283,14 +285,30 @@ som_solib_add_solib_objfile (struct so_list *so, char *name, int from_tty,
                             CORE_ADDR text_addr)
 {
   obj_private_data_t *obj_private;
-  struct section_addr_info section_addrs;
+  struct obj_section *s;
 
-  memset (&section_addrs, 0, sizeof (section_addrs));
-  section_addrs.other[0].name = ".text";
-  section_addrs.other[0].addr = text_addr;
-  so->objfile = symbol_file_add (name, from_tty, &section_addrs, 0, OBJF_SHARED);
+  so->objfile = symbol_file_add (name, from_tty, NULL, 0, OBJF_SHARED);
   so->abfd = so->objfile->obfd;
 
+  /* syms_from_objfile has bizarre section offset code,
+     so I do my own right here.  */
+  for (s = so->objfile->sections; s < so->objfile->sections_end; s++)
+    {
+      flagword aflag = bfd_get_section_flags(so->abfd, s->the_bfd_section);
+      if (aflag & SEC_CODE)
+       {
+         s->addr    += so->som_solib.text_addr - so->som_solib.text_link_addr;
+         s->endaddr += so->som_solib.text_addr - so->som_solib.text_link_addr;
+       }
+      else if (aflag & SEC_DATA)
+       {
+         s->addr    += so->som_solib.data_start;
+         s->endaddr += so->som_solib.data_start;
+       }
+      else
+       ;
+    }
+   
   /* Mark this as a shared library and save private data.
    */
   so->objfile->flags |= OBJF_SHARED;
@@ -860,7 +878,7 @@ som_solib_create_inferior_hook (void)
     }
 
   anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
-  store_unsigned_integer (buf, 4, inferior_pid);
+  store_unsigned_integer (buf, 4, PIDGET (inferior_ptid));
   status = target_write_memory (anaddr, buf, 4);
   if (status != 0)
     {
@@ -1007,20 +1025,12 @@ keep_going:
       struct so_list *temp;
 
       temp = so_list_head;
-      free (so_list_head);
+      xfree (so_list_head);
       so_list_head = temp->next;
     }
   clear_symtab_users ();
 }
 
-
-static void
-reset_inferior_pid (int saved_inferior_pid)
-{
-  inferior_pid = saved_inferior_pid;
-}
-
-
 /* This operation removes the "hook" between GDB and the dynamic linker,
    which causes the dld to notify GDB of shared library events.
 
@@ -1039,11 +1049,10 @@ som_solib_remove_inferior_hook (int pid)
   int status;
   char dld_flags_buffer[TARGET_INT_BIT / TARGET_CHAR_BIT];
   unsigned int dld_flags_value;
-  int saved_inferior_pid = inferior_pid;
-  struct cleanup *old_cleanups = make_cleanup (reset_inferior_pid, saved_inferior_pid);
+  struct cleanup *old_cleanups = save_inferior_ptid ();
 
   /* Ensure that we're really operating on the specified process. */
-  inferior_pid = pid;
+  inferior_ptid = pid_to_ptid (pid);
 
   /* We won't bother to remove the solib breakpoints from this process.
 
@@ -1500,7 +1509,7 @@ som_solib_restart (void)
   while (sl)
     {
       struct so_list *next_sl = sl->next;
-      free (sl);
+      xfree (sl);
       sl = next_sl;
     }
   so_list_head = NULL;
This page took 0.025785 seconds and 4 git commands to generate.