* completer.c (location_completer): Fix typo in comment.
[deliverable/binutils-gdb.git] / gdb / solib-svr4.c
index 76bd87257f987fbb9698e84970c9139be87d2faa..0f70097e089d9f6c74c21a983e9be7119a38cb53 100644 (file)
@@ -1,7 +1,6 @@
 /* Handle SVR4 shared libraries for GDB, the GNU Debugger.
 
-   Copyright (C) 1990-1996, 1998-2001, 2003-2012 Free Software
-   Foundation, Inc.
+   Copyright (C) 1990-2013 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -155,12 +154,12 @@ lm_info_read (CORE_ADDR lm_addr)
   if (target_read_memory (lm_addr, lm, lmo->link_map_size) != 0)
     {
       warning (_("Error reading shared library list entry at %s"),
-              paddress (target_gdbarch, lm_addr)),
+              paddress (target_gdbarch (), lm_addr)),
       lm_info = NULL;
     }
   else
     {
-      struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+      struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
 
       lm_info = xzalloc (sizeof (*lm_info));
       lm_info->lm_addr = lm_addr;
@@ -264,7 +263,7 @@ lm_addr_check (struct so_list *so, bfd *abfd)
              if (info_verbose)
                printf_unfiltered (_("Using PIC (Position Independent Code) "
                                     "prelink displacement %s for \"%s\".\n"),
-                                  paddress (target_gdbarch, l_addr),
+                                  paddress (target_gdbarch (), l_addr),
                                   so->so_name);
            }
          else
@@ -363,7 +362,7 @@ static int match_main (const char *);
 static gdb_byte *
 read_program_header (int type, int *p_sect_size, int *p_arch_size)
 {
-  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
   CORE_ADDR at_phdr, at_phent, at_phnum, pt_phdr = 0;
   int arch_size, sect_size;
   CORE_ADDR sect_addr;
@@ -612,7 +611,7 @@ scan_dyntag (int dyntag, bfd *abfd, CORE_ADDR *ptr)
             gdb_byte ptr_buf[8];
             CORE_ADDR ptr_addr;
 
-            ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+            ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
             ptr_addr = dyn_addr + (buf - bufstart) + arch_size / 8;
             if (target_read_memory (ptr_addr, ptr_buf, arch_size / 8) == 0)
               dyn_ptr = extract_typed_address (ptr_buf, ptr_type);
@@ -632,7 +631,7 @@ scan_dyntag (int dyntag, bfd *abfd, CORE_ADDR *ptr)
 static int
 scan_dyntag_auxv (int dyntag, CORE_ADDR *ptr)
 {
-  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
   int sect_size, arch_size, step;
   long dyn_tag;
   CORE_ADDR dyn_ptr;
@@ -709,7 +708,7 @@ elf_locate_base (void)
   if (scan_dyntag (DT_MIPS_RLD_MAP, exec_bfd, &dyn_ptr)
       || scan_dyntag_auxv (DT_MIPS_RLD_MAP, &dyn_ptr))
     {
-      struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+      struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
       gdb_byte *pbuf;
       int pbuf_size = TYPE_LENGTH (ptr_type);
 
@@ -787,7 +786,7 @@ static CORE_ADDR
 solib_svr4_r_map (struct svr4_info *info)
 {
   struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
-  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+  struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
   CORE_ADDR addr = 0;
   volatile struct gdb_exception ex;
 
@@ -806,7 +805,7 @@ static CORE_ADDR
 solib_svr4_r_brk (struct svr4_info *info)
 {
   struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
-  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+  struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
 
   return read_memory_typed_address (info->debug_base + lmo->r_brk_offset,
                                    ptr_type);
@@ -819,8 +818,8 @@ static CORE_ADDR
 solib_svr4_r_ldsomap (struct svr4_info *info)
 {
   struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
-  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
-  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+  struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
   ULONGEST version;
 
   /* Check version, and return zero if `struct r_debug' doesn't have
@@ -849,7 +848,6 @@ svr4_keep_data_in_core (CORE_ADDR vaddr, unsigned long size)
   CORE_ADDR ldsomap;
   struct so_list *new;
   struct cleanup *old_chain;
-  struct link_map_offsets *lmo;
   CORE_ADDR name_lm;
 
   info = get_svr4_info ();
@@ -863,7 +861,6 @@ svr4_keep_data_in_core (CORE_ADDR vaddr, unsigned long size)
   if (!ldsomap)
     return 0;
 
-  lmo = svr4_fetch_link_map_offsets ();
   new = XZALLOC (struct so_list);
   old_chain = make_cleanup (xfree, new);
   new->lm_info = lm_info_read (ldsomap);
@@ -889,7 +886,7 @@ open_symbol_file_object (void *from_ttyp)
   int errcode;
   int from_tty = *(int *)from_ttyp;
   struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
-  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+  struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
   int l_name_size = TYPE_LENGTH (ptr_type);
   gdb_byte *l_name_buf = xmalloc (l_name_size);
   struct cleanup *cleanups = make_cleanup (xfree, l_name_buf);
@@ -980,7 +977,7 @@ svr4_free_library_list (void *p_list)
     {
       struct so_list *next = list->next;
 
-      svr4_free_so (list);
+      free_so (list);
       list = next;
     }
 }
@@ -1176,7 +1173,6 @@ svr4_read_so_list (CORE_ADDR lm, struct so_list ***link_ptr_ptr,
 
   for (; lm != 0; prev_lm = lm, lm = next_lm)
     {
-      struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
       struct so_list *new;
       struct cleanup *old_chain;
       int errcode;
@@ -1197,8 +1193,8 @@ svr4_read_so_list (CORE_ADDR lm, struct so_list ***link_ptr_ptr,
       if (new->lm_info->l_prev != prev_lm)
        {
          warning (_("Corrupted shared library list: %s != %s"),
-                  paddress (target_gdbarch, prev_lm),
-                  paddress (target_gdbarch, new->lm_info->l_prev));
+                  paddress (target_gdbarch (), prev_lm),
+                  paddress (target_gdbarch (), new->lm_info->l_prev));
          do_cleanups (old_chain);
          break;
        }
@@ -1388,6 +1384,8 @@ svr4_in_dynsym_resolve_code (CORE_ADDR pc)
 static CORE_ADDR
 exec_entry_point (struct bfd *abfd, struct target_ops *targ)
 {
+  CORE_ADDR addr;
+
   /* KevinB wrote ... for most targets, the address returned by
      bfd_get_start_address() is the entry point for the start
      function.  But, for some targets, bfd_get_start_address() returns
@@ -1396,9 +1394,10 @@ exec_entry_point (struct bfd *abfd, struct target_ops *targ)
      gdbarch_convert_from_func_ptr_addr().  The method
      gdbarch_convert_from_func_ptr_addr() is the merely the identify
      function for targets which don't use function descriptors.  */
-  return gdbarch_convert_from_func_ptr_addr (target_gdbarch,
+  addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
                                             bfd_get_start_address (abfd),
                                             targ);
+  return gdbarch_addr_bits_remove (target_gdbarch (), addr);
 }
 
 /* Helper function for gdb_bfd_lookup_symbol.  */
@@ -1468,7 +1467,7 @@ enable_break (struct svr4_info *info, int from_tty)
       struct obj_section *os;
 
       sym_addr = gdbarch_addr_bits_remove
-       (target_gdbarch, gdbarch_convert_from_func_ptr_addr (target_gdbarch,
+       (target_gdbarch (), gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
                                                             sym_addr,
                                                             &current_target));
 
@@ -1501,7 +1500,7 @@ enable_break (struct svr4_info *info, int from_tty)
 
          tmp_bfd = os->objfile->obfd;
          load_addr = ANOFFSET (os->objfile->section_offsets,
-                               os->objfile->sect_index_text);
+                               SECT_OFF_TEXT (os->objfile));
 
          interp_sect = bfd_get_section_by_name (tmp_bfd, ".text");
          if (interp_sect)
@@ -1522,7 +1521,7 @@ enable_break (struct svr4_info *info, int from_tty)
                + bfd_section_size (tmp_bfd, interp_sect);
            }
 
-         create_solib_event_breakpoint (target_gdbarch, sym_addr);
+         create_solib_event_breakpoint (target_gdbarch (), sym_addr);
          return 1;
        }
     }
@@ -1585,7 +1584,7 @@ enable_break (struct svr4_info *info, int from_tty)
       if (!load_addr_found)
         if (target_auxv_search (&current_target, AT_BASE, &load_addr) > 0)
          {
-           int addr_bit = gdbarch_addr_bit (target_gdbarch);
+           int addr_bit = gdbarch_addr_bit (target_gdbarch ());
 
            /* Ensure LOAD_ADDR has proper sign in its possible upper bits so
               that `+ load_addr' will overflow CORE_ADDR width not creating
@@ -1621,7 +1620,7 @@ enable_break (struct svr4_info *info, int from_tty)
       if (!load_addr_found)
        {
          struct regcache *regcache
-           = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
+           = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
 
          load_addr = (regcache_read_pc (regcache)
                       - exec_entry_point (tmp_bfd, tmp_bfd_target));
@@ -1669,7 +1668,7 @@ enable_break (struct svr4_info *info, int from_tty)
        /* Convert 'sym_addr' from a function pointer to an address.
           Because we pass tmp_bfd_target instead of the current
           target, this will always produce an unrelocated value.  */
-       sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch,
+       sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
                                                       sym_addr,
                                                       tmp_bfd_target);
 
@@ -1680,7 +1679,7 @@ enable_break (struct svr4_info *info, int from_tty)
 
       if (sym_addr != 0)
        {
-         create_solib_event_breakpoint (target_gdbarch, load_addr + sym_addr);
+         create_solib_event_breakpoint (target_gdbarch (), load_addr + sym_addr);
          xfree (interp_name);
          return 1;
        }
@@ -1703,10 +1702,10 @@ enable_break (struct svr4_info *info, int from_tty)
       if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
        {
          sym_addr = SYMBOL_VALUE_ADDRESS (msymbol);
-         sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch,
+         sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
                                                         sym_addr,
                                                         &current_target);
-         create_solib_event_breakpoint (target_gdbarch, sym_addr);
+         create_solib_event_breakpoint (target_gdbarch (), sym_addr);
          return 1;
        }
     }
@@ -1719,10 +1718,10 @@ enable_break (struct svr4_info *info, int from_tty)
          if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
            {
              sym_addr = SYMBOL_VALUE_ADDRESS (msymbol);
-             sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch,
+             sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
                                                             sym_addr,
                                                             &current_target);
-             create_solib_event_breakpoint (target_gdbarch, sym_addr);
+             create_solib_event_breakpoint (target_gdbarch (), sym_addr);
              return 1;
            }
        }
@@ -1863,7 +1862,7 @@ svr4_exec_displacement (CORE_ADDR *displacementp)
       buf2 = read_program_headers_from_bfd (exec_bfd, &phdrs2_size);
       if (buf != NULL && buf2 != NULL)
        {
-         enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+         enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
 
          /* We are dealing with three different addresses.  EXEC_BFD
             represents current address in on-disk file.  target memory content
@@ -2118,7 +2117,7 @@ svr4_exec_displacement (CORE_ADDR *displacementp)
 
       printf_unfiltered (_("Using PIE (Position Independent Executable) "
                           "displacement %s for \"%s\".\n"),
-                        paddress (target_gdbarch, displacement),
+                        paddress (target_gdbarch (), displacement),
                         bfd_get_filename (exec_bfd));
     }
 
@@ -2209,25 +2208,11 @@ svr4_relocate_main_executable (void)
 
    This function is responsible for discovering those names and
    addresses, and saving sufficient information about them to allow
-   their symbols to be read at a later time.
-
-   FIXME
-
-   Between enable_break() and disable_break(), this code does not
-   properly handle hitting breakpoints which the user might have
-   set in the startup code or in the dynamic linker itself.  Proper
-   handling will probably have to wait until the implementation is
-   changed to use the "breakpoint handler function" method.
-
-   Also, what if child has exit()ed?  Must exit loop somehow.  */
+   their symbols to be read at a later time.  */
 
 static void
 svr4_solib_create_inferior_hook (int from_tty)
 {
-#if defined(_SCO_DS)
-  struct inferior *inf;
-  struct thread_info *tp;
-#endif /* defined(_SCO_DS) */
   struct svr4_info *info;
 
   info = get_svr4_info ();
@@ -2245,31 +2230,6 @@ svr4_solib_create_inferior_hook (int from_tty)
 
   if (!enable_break (info, from_tty))
     return;
-
-#if defined(_SCO_DS)
-  /* SCO needs the loop below, other systems should be using the
-     special shared library breakpoints and the shared library breakpoint
-     service routine.
-
-     Now run the target.  It will eventually hit the breakpoint, at
-     which point all of the libraries will have been mapped in and we
-     can go groveling around in the dynamic linker structures to find
-     out what we need to know about them.  */
-
-  inf = current_inferior ();
-  tp = inferior_thread ();
-
-  clear_proceed_status ();
-  inf->control.stop_soon = STOP_QUIETLY;
-  tp->suspend.stop_signal = GDB_SIGNAL_0;
-  do
-    {
-      target_resume (pid_to_ptid (-1), 0, tp->suspend.stop_signal);
-      wait_for_inferior ();
-    }
-  while (tp->suspend.stop_signal != GDB_SIGNAL_TRAP);
-  inf->control.stop_soon = NO_STOP_QUIETLY;
-#endif /* defined(_SCO_DS) */
 }
 
 static void
@@ -2301,12 +2261,12 @@ svr4_clear_solib (void)
 static CORE_ADDR
 svr4_truncate_ptr (CORE_ADDR addr)
 {
-  if (gdbarch_ptr_bit (target_gdbarch) == sizeof (CORE_ADDR) * 8)
+  if (gdbarch_ptr_bit (target_gdbarch ()) == sizeof (CORE_ADDR) * 8)
     /* We don't need to truncate anything, and the bit twiddling below
        will fail due to overflow problems.  */
     return addr;
   else
-    return addr & (((CORE_ADDR) 1 << gdbarch_ptr_bit (target_gdbarch)) - 1);
+    return addr & (((CORE_ADDR) 1 << gdbarch_ptr_bit (target_gdbarch ())) - 1);
 }
 
 
@@ -2364,7 +2324,7 @@ set_solib_svr4_fetch_link_map_offsets (struct gdbarch *gdbarch,
 static struct link_map_offsets *
 svr4_fetch_link_map_offsets (void)
 {
-  struct solib_svr4_ops *ops = gdbarch_data (target_gdbarch, solib_svr4_data);
+  struct solib_svr4_ops *ops = gdbarch_data (target_gdbarch (), solib_svr4_data);
 
   gdb_assert (ops->fetch_link_map_offsets);
   return ops->fetch_link_map_offsets ();
@@ -2375,7 +2335,7 @@ svr4_fetch_link_map_offsets (void)
 static int
 svr4_have_link_map_offsets (void)
 {
-  struct solib_svr4_ops *ops = gdbarch_data (target_gdbarch, solib_svr4_data);
+  struct solib_svr4_ops *ops = gdbarch_data (target_gdbarch (), solib_svr4_data);
 
   return (ops->fetch_link_map_offsets != NULL);
 }
@@ -2484,7 +2444,7 @@ _initialize_svr4_solib (void)
 {
   solib_svr4_data = gdbarch_data_register_pre_init (solib_svr4_init);
   solib_svr4_pspace_data
-    = register_program_space_data_with_cleanup (svr4_pspace_data_cleanup);
+    = register_program_space_data_with_cleanup (NULL, svr4_pspace_data_cleanup);
 
   svr4_so_ops.relocate_section_addresses = svr4_relocate_section_addresses;
   svr4_so_ops.free_so = svr4_free_so;
This page took 0.030951 seconds and 4 git commands to generate.