remove pop_target
[deliverable/binutils-gdb.git] / gdb / target.c
index 1c0134fe23879ab964a5faba1fb5e12a1cceba23..e3dcb47f514cde025d5b0c5398989c7bd969be88 100644 (file)
@@ -153,7 +153,6 @@ static void debug_to_stop (ptid_t);
    array.  */
 struct target_ops **target_structs;
 unsigned target_struct_size;
-unsigned target_struct_index;
 unsigned target_struct_allocsize;
 #define        DEFAULT_ALLOCSIZE       10
 
@@ -382,16 +381,12 @@ target_has_execution_current (void)
   return target_has_execution_1 (inferior_ptid);
 }
 
-/* Add possible target architecture T to the list and add a new
-   command 'target T->to_shortname'.  Set COMPLETER as the command's
-   completer if not NULL.  */
+/* Complete initialization of T.  This ensures that various fields in
+   T are set, if needed by the target implementation.  */
 
 void
-add_target_with_completer (struct target_ops *t,
-                          completer_ftype *completer)
+complete_target_initialization (struct target_ops *t)
 {
-  struct cmd_list_element *c;
-
   /* Provide default values for all "must have" methods.  */
   if (t->to_xfer_partial == NULL)
     t->to_xfer_partial = default_xfer_partial;
@@ -410,6 +405,19 @@ add_target_with_completer (struct target_ops *t,
 
   if (t->to_has_execution == NULL)
     t->to_has_execution = (int (*) (struct target_ops *, ptid_t)) return_zero;
+}
+
+/* Add possible target architecture T to the list and add a new
+   command 'target T->to_shortname'.  Set COMPLETER as the command's
+   completer if not NULL.  */
+
+void
+add_target_with_completer (struct target_ops *t,
+                          completer_ftype *completer)
+{
+  struct cmd_list_element *c;
+
+  complete_target_initialization (t);
 
   if (!target_structs)
     {
@@ -731,6 +739,7 @@ update_current_target (void)
       INHERIT (to_traceframe_info, t);
       INHERIT (to_use_agent, t);
       INHERIT (to_can_use_agent, t);
+      INHERIT (to_augmented_libraries_svr4_read, t);
       INHERIT (to_magic, t);
       INHERIT (to_supports_evaluation_of_breakpoint_conditions, t);
       INHERIT (to_can_run_breakpoint_commands, t);
@@ -946,7 +955,7 @@ update_current_target (void)
            (void (*) (LONGEST))
            target_ignore);
   de_fault (to_set_trace_notes,
-           (int (*) (char *, char *, char *))
+           (int (*) (const char *, const char *, const char *))
            return_zero);
   de_fault (to_get_tib_address,
            (int (*) (ptid_t, CORE_ADDR *))
@@ -962,7 +971,7 @@ update_current_target (void)
            tcomplain);
   de_fault (to_traceframe_info,
            (struct traceframe_info * (*) (void))
-           tcomplain);
+           return_zero);
   de_fault (to_supports_evaluation_of_breakpoint_conditions,
            (int (*) (void))
            return_zero);
@@ -975,6 +984,9 @@ update_current_target (void)
   de_fault (to_can_use_agent,
            (int (*) (void))
            return_zero);
+  de_fault (to_augmented_libraries_svr4_read,
+           (int (*) (void))
+           return_zero);
   de_fault (to_execution_direction, default_execution_direction);
 
 #undef de_fault
@@ -1081,26 +1093,11 @@ unpush_target (struct target_ops *t)
   return 1;
 }
 
-void
-pop_target (void)
-{
-  target_close (target_stack);         /* Let it clean up.  */
-  if (unpush_target (target_stack) == 1)
-    return;
-
-  fprintf_unfiltered (gdb_stderr,
-                     "pop_target couldn't find target %s\n",
-                     current_target.to_shortname);
-  internal_error (__FILE__, __LINE__,
-                 _("failed internal consistency check"));
-}
-
 void
 pop_all_targets_above (enum strata above_stratum)
 {
   while ((int) (current_target.to_stratum) > (int) above_stratum)
     {
-      target_close (target_stack);
       if (!unpush_target (target_stack))
        {
          fprintf_unfiltered (gdb_stderr,
@@ -1393,7 +1390,8 @@ memory_xfer_live_readonly_partial (struct target_ops *ops,
 
   secp = target_section_by_addr (ops, memaddr);
   if (secp != NULL
-      && (bfd_get_section_flags (secp->bfd, secp->the_bfd_section)
+      && (bfd_get_section_flags (secp->the_bfd_section->owner,
+                                secp->the_bfd_section)
          & SEC_READONLY))
     {
       struct target_section *p;
@@ -1472,7 +1470,8 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
 
       secp = target_section_by_addr (ops, memaddr);
       if (secp != NULL
-         && (bfd_get_section_flags (secp->bfd, secp->the_bfd_section)
+         && (bfd_get_section_flags (secp->the_bfd_section->owner,
+                                    secp->the_bfd_section)
              & SEC_READONLY))
        {
          table = target_get_section_table (ops);
@@ -3624,30 +3623,6 @@ return_minus_one (void)
   return -1;
 }
 
-/* Find a single runnable target in the stack and return it.  If for
-   some reason there is more than one, return NULL.  */
-
-struct target_ops *
-find_run_target (void)
-{
-  struct target_ops **t;
-  struct target_ops *runable = NULL;
-  int count;
-
-  count = 0;
-
-  for (t = target_structs; t < target_structs + target_struct_size; ++t)
-    {
-      if ((*t)->to_can_run && target_can_run (*t))
-       {
-         runable = *t;
-         ++count;
-       }
-    }
-
-  return (count == 1 ? runable : NULL);
-}
-
 /*
  * Find the next target down the stack from the specified target.
  */
@@ -3791,6 +3766,8 @@ debug_to_open (char *args, int from_tty)
 void
 target_close (struct target_ops *targ)
 {
+  gdb_assert (!target_is_pushed (targ));
+
   if (targ->to_xclose != NULL)
     targ->to_xclose (targ);
   else if (targ->to_close != NULL)
@@ -3882,52 +3859,6 @@ debug_to_post_attach (int pid)
   fprintf_unfiltered (gdb_stdlog, "target_post_attach (%d)\n", pid);
 }
 
-/* Return a pretty printed form of target_waitstatus.
-   Space for the result is malloc'd, caller must free.  */
-
-char *
-target_waitstatus_to_string (const struct target_waitstatus *ws)
-{
-  const char *kind_str = "status->kind = ";
-
-  switch (ws->kind)
-    {
-    case TARGET_WAITKIND_EXITED:
-      return xstrprintf ("%sexited, status = %d",
-                        kind_str, ws->value.integer);
-    case TARGET_WAITKIND_STOPPED:
-      return xstrprintf ("%sstopped, signal = %s",
-                        kind_str, gdb_signal_to_name (ws->value.sig));
-    case TARGET_WAITKIND_SIGNALLED:
-      return xstrprintf ("%ssignalled, signal = %s",
-                        kind_str, gdb_signal_to_name (ws->value.sig));
-    case TARGET_WAITKIND_LOADED:
-      return xstrprintf ("%sloaded", kind_str);
-    case TARGET_WAITKIND_FORKED:
-      return xstrprintf ("%sforked", kind_str);
-    case TARGET_WAITKIND_VFORKED:
-      return xstrprintf ("%svforked", kind_str);
-    case TARGET_WAITKIND_EXECD:
-      return xstrprintf ("%sexecd", kind_str);
-    case TARGET_WAITKIND_VFORK_DONE:
-      return xstrprintf ("%svfork-done", kind_str);
-    case TARGET_WAITKIND_SYSCALL_ENTRY:
-      return xstrprintf ("%sentered syscall", kind_str);
-    case TARGET_WAITKIND_SYSCALL_RETURN:
-      return xstrprintf ("%sexited syscall", kind_str);
-    case TARGET_WAITKIND_SPURIOUS:
-      return xstrprintf ("%sspurious", kind_str);
-    case TARGET_WAITKIND_IGNORE:
-      return xstrprintf ("%signore", kind_str);
-    case TARGET_WAITKIND_NO_HISTORY:
-      return xstrprintf ("%sno-history", kind_str);
-    case TARGET_WAITKIND_NO_RESUMED:
-      return xstrprintf ("%sno-resumed", kind_str);
-    default:
-      return xstrprintf ("%sunknown???", kind_str);
-    }
-}
-
 /* Concatenate ELEM to LIST, a comma separate list, and return the
    result.  The LIST incoming argument is released.  */
 
This page took 0.040906 seconds and 4 git commands to generate.