import gdb-1999-09-28 snapshot
[deliverable/binutils-gdb.git] / gdb / target.c
index 9ba43fdfd6ccb39c13bf1fe92a2c8db35ffd3596..01e01c2b82ef2469e542465807429e33d9975d83 100644 (file)
@@ -444,11 +444,15 @@ cleanup_target (t)
   de_fault (to_thread_alive, (int (*)PARAMS ((int))) target_ignore);
   de_fault (to_stop, (void (*)PARAMS ((void))) target_ignore);
   de_fault (to_query, (int (*)PARAMS ((int /*char */ , char *, char *, int *))) target_ignore);
+  de_fault (to_rcmd, (void (*) (char *, struct gdb_file *)) tcomplain);
   de_fault (to_enable_exception_callback, (struct symtab_and_line * (*)PARAMS ((enum exception_event_kind, int))) nosupport_runtime);
   de_fault (to_get_current_exception_event, (struct exception_event_record * (*)PARAMS ((void))) nosupport_runtime);
 
   de_fault (to_pid_to_exec_file, (char *(*)PARAMS ((int))) return_zero);
   de_fault (to_core_file_to_sym_file, (char *(*)PARAMS ((char *))) return_zero);
+  de_fault (to_can_async_p, (int (*) (void)) return_zero);
+  de_fault (to_is_async_p, (int (*) (void)) return_zero);
+  de_fault (to_async, (void (*) (void (*) (int, void*, int), void*)) tcomplain);
 #undef de_fault
 }
 
@@ -527,6 +531,7 @@ update_current_target ()
       INHERIT (to_find_new_threads, t);
       INHERIT (to_stop, t);
       INHERIT (to_query, t);
+      INHERIT (to_rcmd, t);
       INHERIT (to_enable_exception_callback, t);
       INHERIT (to_get_current_exception_event, t);
       INHERIT (to_pid_to_exec_file, t);
@@ -539,9 +544,11 @@ update_current_target ()
       INHERIT (to_has_registers, t);
       INHERIT (to_has_execution, t);
       INHERIT (to_has_thread_control, t);
-      INHERIT (to_has_async_exec, t);
       INHERIT (to_sections, t);
       INHERIT (to_sections_end, t);
+      INHERIT (to_can_async_p, t);
+      INHERIT (to_is_async_p, t);
+      INHERIT (to_async, t);
       INHERIT (to_magic, t);
 
 #undef INHERIT
@@ -962,7 +969,8 @@ target_preopen (from_tty)
 
   if (target_has_execution)
     {
-      if (query ("A program is being debugged already.  Kill it? "))
+      if (!from_tty
+          || query ("A program is being debugged already.  Kill it? "))
        target_kill ();
       else
        error ("Program not killed.");
@@ -1110,6 +1118,56 @@ return_one ()
   return 1;
 }
 
+/*
+ * Resize the to_sections pointer.  Also make sure that anyone that
+ * was holding on to an old value of it gets updated.
+ * Returns the old size.
+ */
+
+int
+target_resize_to_sections (struct target_ops *target, int num_added)
+{
+  struct target_ops **t;
+  struct section_table *old_value;
+  int old_count;
+
+  old_value = target->to_sections;
+
+  if (target->to_sections)
+    {
+      old_count = target->to_sections_end - target->to_sections;
+      target->to_sections = (struct section_table *)
+       xrealloc ((char *) target->to_sections,
+                 (sizeof (struct section_table)) * (num_added + old_count));
+    }
+  else
+    {
+      old_count = 0;
+      target->to_sections = (struct section_table *)
+       xmalloc ((sizeof (struct section_table)) * num_added);
+    }
+  target->to_sections_end = target->to_sections + (num_added + old_count);
+
+  /* Check to see if anyone else was pointing to this structure.
+     If old_value was null, then no one was. */
+     
+  if (old_value)
+    {
+      for (t = target_structs; t < target_structs + target_struct_size;
+          ++t)
+       {
+         if ((*t)->to_sections == old_value)
+           {
+             (*t)->to_sections = target->to_sections;
+             (*t)->to_sections_end = target->to_sections_end;
+           }
+       }
+    }
+  
+  return old_count;
+
+}
+
 /* Find a single runnable target in the stack and return it.  If for
    some reason there is more than one, return NULL.  */
 
@@ -1269,6 +1327,7 @@ static struct {
   {"SIG62", "Real-time event 62"},
   {"SIG63", "Real-time event 63"},
   {"SIGCANCEL", "LWP internal signal"},
+  {"SIG32", "Real-time event 32"},
 
 #if defined(MACH) || defined(__MACH__)
   /* Mach exceptions */
@@ -1568,8 +1627,16 @@ target_signal_from_host (hostsig)
 
 #if defined (REALTIME_LO)
   if (hostsig >= REALTIME_LO && hostsig < REALTIME_HI)
-    return (enum target_signal)
-      (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
+    {
+      /* This block of TARGET_SIGNAL_REALTIME value is in order.  */
+      if (33 <= hostsig && hostsig <= 63)
+       return (enum target_signal)
+         (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
+      else if (hostsig == 32)
+       return TARGET_SIGNAL_REALTIME_32;
+      else
+       error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
+    }
 #endif
   return TARGET_SIGNAL_UNKNOWN;
 }
@@ -1768,6 +1835,8 @@ target_signal_to_host (oursig)
       return SIGPRIO;
 #endif
 
+    case TARGET_SIGNAL_REALTIME_32: return 32; /* by definition */ 
+
       /* Mach exceptions.  Assumes that the values for EXC_ are positive! */
 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
     case TARGET_EXC_BAD_ACCESS:
@@ -1882,9 +1951,9 @@ normal_pid_to_str (pid)
   static char buf[30];
 
   if (STREQ (current_target.to_shortname, "remote"))
-    sprintf (buf, "thread %d\0", pid);
+    sprintf (buf, "thread %d", pid);
   else
-    sprintf (buf, "process %d\0", pid);
+    sprintf (buf, "process %d", pid);
 
   return buf;
 }
@@ -1936,7 +2005,7 @@ debug_to_open (args, from_tty)
 {
   debug_target.to_open (args, from_tty);
 
-  fprintf_unfiltered (gdb_stderr, "target_open (%s, %d)\n", args, from_tty);
+  fprintf_unfiltered (gdb_stdlog, "target_open (%s, %d)\n", args, from_tty);
 }
 
 static void
@@ -1945,7 +2014,7 @@ debug_to_close (quitting)
 {
   debug_target.to_close (quitting);
 
-  fprintf_unfiltered (gdb_stderr, "target_close (%d)\n", quitting);
+  fprintf_unfiltered (gdb_stdlog, "target_close (%d)\n", quitting);
 }
 
 static void
@@ -1955,7 +2024,7 @@ debug_to_attach (args, from_tty)
 {
   debug_target.to_attach (args, from_tty);
 
-  fprintf_unfiltered (gdb_stderr, "target_attach (%s, %d)\n", args, from_tty);
+  fprintf_unfiltered (gdb_stdlog, "target_attach (%s, %d)\n", args, from_tty);
 }
 
 
@@ -1965,7 +2034,7 @@ debug_to_post_attach (pid)
 {
   debug_target.to_post_attach (pid);
 
-  fprintf_unfiltered (gdb_stderr, "target_post_attach (%d)\n", pid);
+  fprintf_unfiltered (gdb_stdlog, "target_post_attach (%d)\n", pid);
 }
 
 static void
@@ -1975,7 +2044,7 @@ debug_to_require_attach (args, from_tty)
 {
   debug_target.to_require_attach (args, from_tty);
 
-  fprintf_unfiltered (gdb_stderr,
+  fprintf_unfiltered (gdb_stdlog,
                      "target_require_attach (%s, %d)\n", args, from_tty);
 }
 
@@ -1986,7 +2055,7 @@ debug_to_detach (args, from_tty)
 {
   debug_target.to_detach (args, from_tty);
 
-  fprintf_unfiltered (gdb_stderr, "target_detach (%s, %d)\n", args, from_tty);
+  fprintf_unfiltered (gdb_stdlog, "target_detach (%s, %d)\n", args, from_tty);
 }
 
 static void
@@ -1997,7 +2066,7 @@ debug_to_require_detach (pid, args, from_tty)
 {
   debug_target.to_require_detach (pid, args, from_tty);
 
-  fprintf_unfiltered (gdb_stderr,
+  fprintf_unfiltered (gdb_stdlog,
               "target_require_detach (%d, %s, %d)\n", pid, args, from_tty);
 }
 
@@ -2009,7 +2078,7 @@ debug_to_resume (pid, step, siggnal)
 {
   debug_target.to_resume (pid, step, siggnal);
 
-  fprintf_unfiltered (gdb_stderr, "target_resume (%d, %s, %s)\n", pid,
+  fprintf_unfiltered (gdb_stdlog, "target_resume (%d, %s, %s)\n", pid,
                      step ? "step" : "continue",
                      target_signal_to_name (siggnal));
 }
@@ -2023,40 +2092,40 @@ debug_to_wait (pid, status)
 
   retval = debug_target.to_wait (pid, status);
 
-  fprintf_unfiltered (gdb_stderr,
+  fprintf_unfiltered (gdb_stdlog,
                      "target_wait (%d, status) = %d,   ", pid, retval);
-  fprintf_unfiltered (gdb_stderr, "status->kind = ");
+  fprintf_unfiltered (gdb_stdlog, "status->kind = ");
   switch (status->kind)
     {
     case TARGET_WAITKIND_EXITED:
-      fprintf_unfiltered (gdb_stderr, "exited, status = %d\n",
+      fprintf_unfiltered (gdb_stdlog, "exited, status = %d\n",
                          status->value.integer);
       break;
     case TARGET_WAITKIND_STOPPED:
-      fprintf_unfiltered (gdb_stderr, "stopped, signal = %s\n",
+      fprintf_unfiltered (gdb_stdlog, "stopped, signal = %s\n",
                          target_signal_to_name (status->value.sig));
       break;
     case TARGET_WAITKIND_SIGNALLED:
-      fprintf_unfiltered (gdb_stderr, "signalled, signal = %s\n",
+      fprintf_unfiltered (gdb_stdlog, "signalled, signal = %s\n",
                          target_signal_to_name (status->value.sig));
       break;
     case TARGET_WAITKIND_LOADED:
-      fprintf_unfiltered (gdb_stderr, "loaded\n");
+      fprintf_unfiltered (gdb_stdlog, "loaded\n");
       break;
     case TARGET_WAITKIND_FORKED:
-      fprintf_unfiltered (gdb_stderr, "forked\n");
+      fprintf_unfiltered (gdb_stdlog, "forked\n");
       break;
     case TARGET_WAITKIND_VFORKED:
-      fprintf_unfiltered (gdb_stderr, "vforked\n");
+      fprintf_unfiltered (gdb_stdlog, "vforked\n");
       break;
     case TARGET_WAITKIND_EXECD:
-      fprintf_unfiltered (gdb_stderr, "execd\n");
+      fprintf_unfiltered (gdb_stdlog, "execd\n");
       break;
     case TARGET_WAITKIND_SPURIOUS:
-      fprintf_unfiltered (gdb_stderr, "spurious\n");
+      fprintf_unfiltered (gdb_stdlog, "spurious\n");
       break;
     default:
-      fprintf_unfiltered (gdb_stderr, "unknown???\n");
+      fprintf_unfiltered (gdb_stdlog, "unknown???\n");
       break;
     }
 
@@ -2070,7 +2139,7 @@ debug_to_post_wait (pid, status)
 {
   debug_target.to_post_wait (pid, status);
 
-  fprintf_unfiltered (gdb_stderr, "target_post_wait (%d, %d)\n",
+  fprintf_unfiltered (gdb_stdlog, "target_post_wait (%d, %d)\n",
                      pid, status);
 }
 
@@ -2080,13 +2149,13 @@ debug_to_fetch_registers (regno)
 {
   debug_target.to_fetch_registers (regno);
 
-  fprintf_unfiltered (gdb_stderr, "target_fetch_registers (%s)",
+  fprintf_unfiltered (gdb_stdlog, "target_fetch_registers (%s)",
                      regno != -1 ? REGISTER_NAME (regno) : "-1");
   if (regno != -1)
-    fprintf_unfiltered (gdb_stderr, " = 0x%x %d",
+    fprintf_unfiltered (gdb_stdlog, " = 0x%lx %ld",
                        (unsigned long) read_register (regno),
-                       read_register (regno));
-  fprintf_unfiltered (gdb_stderr, "\n");
+                       (unsigned long) read_register (regno));
+  fprintf_unfiltered (gdb_stdlog, "\n");
 }
 
 static void
@@ -2096,12 +2165,12 @@ debug_to_store_registers (regno)
   debug_target.to_store_registers (regno);
 
   if (regno >= 0 && regno < NUM_REGS)
-    fprintf_unfiltered (gdb_stderr, "target_store_registers (%s) = 0x%x %d\n",
+    fprintf_unfiltered (gdb_stdlog, "target_store_registers (%s) = 0x%lx %ld\n",
                        REGISTER_NAME (regno),
                        (unsigned long) read_register (regno),
                        (unsigned long) read_register (regno));
   else
-    fprintf_unfiltered (gdb_stderr, "target_store_registers (%d)\n", regno);
+    fprintf_unfiltered (gdb_stdlog, "target_store_registers (%d)\n", regno);
 }
 
 static void
@@ -2109,7 +2178,7 @@ debug_to_prepare_to_store ()
 {
   debug_target.to_prepare_to_store ();
 
-  fprintf_unfiltered (gdb_stderr, "target_prepare_to_store ()\n");
+  fprintf_unfiltered (gdb_stdlog, "target_prepare_to_store ()\n");
 }
 
 static int
@@ -2124,7 +2193,7 @@ debug_to_xfer_memory (memaddr, myaddr, len, write, target)
 
   retval = debug_target.to_xfer_memory (memaddr, myaddr, len, write, target);
 
-  fprintf_unfiltered (gdb_stderr,
+  fprintf_unfiltered (gdb_stdlog,
                      "target_xfer_memory (0x%x, xxx, %d, %s, xxx) = %d",
                      (unsigned int) memaddr,   /* possable truncate long long */
                      len, write ? "write" : "read", retval);
@@ -2135,16 +2204,16 @@ debug_to_xfer_memory (memaddr, myaddr, len, write, target)
     {
       int i;
 
-      fputs_unfiltered (", bytes =", gdb_stderr);
+      fputs_unfiltered (", bytes =", gdb_stdlog);
       for (i = 0; i < retval; i++)
        {
          if ((((long) &(myaddr[i])) & 0xf) == 0)
-           fprintf_unfiltered (gdb_stderr, "\n");
-         fprintf_unfiltered (gdb_stderr, " %02x", myaddr[i] & 0xff);
+           fprintf_unfiltered (gdb_stdlog, "\n");
+         fprintf_unfiltered (gdb_stdlog, " %02x", myaddr[i] & 0xff);
        }
     }
 
-  fputc_unfiltered ('\n', gdb_stderr);
+  fputc_unfiltered ('\n', gdb_stdlog);
 
   return retval;
 }
@@ -2155,7 +2224,7 @@ debug_to_files_info (target)
 {
   debug_target.to_files_info (target);
 
-  fprintf_unfiltered (gdb_stderr, "target_files_info (xxx)\n");
+  fprintf_unfiltered (gdb_stdlog, "target_files_info (xxx)\n");
 }
 
 static int
@@ -2167,9 +2236,10 @@ debug_to_insert_breakpoint (addr, save)
 
   retval = debug_target.to_insert_breakpoint (addr, save);
 
-  fprintf_unfiltered (gdb_stderr,
-                     "target_insert_breakpoint (0x%x, xxx) = %d\n",
-                     (unsigned long) addr, retval);
+  fprintf_unfiltered (gdb_stdlog,
+                     "target_insert_breakpoint (0x%lx, xxx) = %ld\n",
+                     (unsigned long) addr,
+                     (unsigned long) retval);
   return retval;
 }
 
@@ -2182,9 +2252,10 @@ debug_to_remove_breakpoint (addr, save)
 
   retval = debug_target.to_remove_breakpoint (addr, save);
 
-  fprintf_unfiltered (gdb_stderr,
-                     "target_remove_breakpoint (0x%x, xxx) = %d\n",
-                     (unsigned long) addr, retval);
+  fprintf_unfiltered (gdb_stdlog,
+                     "target_remove_breakpoint (0x%lx, xxx) = %ld\n",
+                     (unsigned long) addr,
+                     (unsigned long) retval);
   return retval;
 }
 
@@ -2193,7 +2264,7 @@ debug_to_terminal_init ()
 {
   debug_target.to_terminal_init ();
 
-  fprintf_unfiltered (gdb_stderr, "target_terminal_init ()\n");
+  fprintf_unfiltered (gdb_stdlog, "target_terminal_init ()\n");
 }
 
 static void
@@ -2201,7 +2272,7 @@ debug_to_terminal_inferior ()
 {
   debug_target.to_terminal_inferior ();
 
-  fprintf_unfiltered (gdb_stderr, "target_terminal_inferior ()\n");
+  fprintf_unfiltered (gdb_stdlog, "target_terminal_inferior ()\n");
 }
 
 static void
@@ -2209,7 +2280,7 @@ debug_to_terminal_ours_for_output ()
 {
   debug_target.to_terminal_ours_for_output ();
 
-  fprintf_unfiltered (gdb_stderr, "target_terminal_ours_for_output ()\n");
+  fprintf_unfiltered (gdb_stdlog, "target_terminal_ours_for_output ()\n");
 }
 
 static void
@@ -2217,7 +2288,7 @@ debug_to_terminal_ours ()
 {
   debug_target.to_terminal_ours ();
 
-  fprintf_unfiltered (gdb_stderr, "target_terminal_ours ()\n");
+  fprintf_unfiltered (gdb_stdlog, "target_terminal_ours ()\n");
 }
 
 static void
@@ -2227,7 +2298,7 @@ debug_to_terminal_info (arg, from_tty)
 {
   debug_target.to_terminal_info (arg, from_tty);
 
-  fprintf_unfiltered (gdb_stderr, "target_terminal_info (%s, %d)\n", arg,
+  fprintf_unfiltered (gdb_stdlog, "target_terminal_info (%s, %d)\n", arg,
                      from_tty);
 }
 
@@ -2236,7 +2307,7 @@ debug_to_kill ()
 {
   debug_target.to_kill ();
 
-  fprintf_unfiltered (gdb_stderr, "target_kill ()\n");
+  fprintf_unfiltered (gdb_stdlog, "target_kill ()\n");
 }
 
 static void
@@ -2246,7 +2317,7 @@ debug_to_load (args, from_tty)
 {
   debug_target.to_load (args, from_tty);
 
-  fprintf_unfiltered (gdb_stderr, "target_load (%s, %d)\n", args, from_tty);
+  fprintf_unfiltered (gdb_stdlog, "target_load (%s, %d)\n", args, from_tty);
 }
 
 static int
@@ -2258,7 +2329,7 @@ debug_to_lookup_symbol (name, addrp)
 
   retval = debug_target.to_lookup_symbol (name, addrp);
 
-  fprintf_unfiltered (gdb_stderr, "target_lookup_symbol (%s, xxx)\n", name);
+  fprintf_unfiltered (gdb_stdlog, "target_lookup_symbol (%s, xxx)\n", name);
 
   return retval;
 }
@@ -2271,7 +2342,7 @@ debug_to_create_inferior (exec_file, args, env)
 {
   debug_target.to_create_inferior (exec_file, args, env);
 
-  fprintf_unfiltered (gdb_stderr, "target_create_inferior (%s, %s, xxx)\n",
+  fprintf_unfiltered (gdb_stdlog, "target_create_inferior (%s, %s, xxx)\n",
                      exec_file, args);
 }
 
@@ -2281,7 +2352,7 @@ debug_to_post_startup_inferior (pid)
 {
   debug_target.to_post_startup_inferior (pid);
 
-  fprintf_unfiltered (gdb_stderr, "target_post_startup_inferior (%d)\n",
+  fprintf_unfiltered (gdb_stdlog, "target_post_startup_inferior (%d)\n",
                      pid);
 }
 
@@ -2291,7 +2362,7 @@ debug_to_acknowledge_created_inferior (pid)
 {
   debug_target.to_acknowledge_created_inferior (pid);
 
-  fprintf_unfiltered (gdb_stderr, "target_acknowledge_created_inferior (%d)\n",
+  fprintf_unfiltered (gdb_stdlog, "target_acknowledge_created_inferior (%d)\n",
                      pid);
 }
 
@@ -2302,7 +2373,7 @@ debug_to_clone_and_follow_inferior (child_pid, followed_child)
 {
   debug_target.to_clone_and_follow_inferior (child_pid, followed_child);
 
-  fprintf_unfiltered (gdb_stderr,
+  fprintf_unfiltered (gdb_stdlog,
                      "target_clone_and_follow_inferior (%d, %d)\n",
                      child_pid, *followed_child);
 }
@@ -2312,7 +2383,7 @@ debug_to_post_follow_inferior_by_clone ()
 {
   debug_target.to_post_follow_inferior_by_clone ();
 
-  fprintf_unfiltered (gdb_stderr, "target_post_follow_inferior_by_clone ()\n");
+  fprintf_unfiltered (gdb_stdlog, "target_post_follow_inferior_by_clone ()\n");
 }
 
 static int
@@ -2323,7 +2394,7 @@ debug_to_insert_fork_catchpoint (pid)
 
   retval = debug_target.to_insert_fork_catchpoint (pid);
 
-  fprintf_unfiltered (gdb_stderr, "target_insert_fork_catchpoint (%d) = %d\n",
+  fprintf_unfiltered (gdb_stdlog, "target_insert_fork_catchpoint (%d) = %d\n",
                      pid, retval);
 
   return retval;
@@ -2337,7 +2408,7 @@ debug_to_remove_fork_catchpoint (pid)
 
   retval = debug_target.to_remove_fork_catchpoint (pid);
 
-  fprintf_unfiltered (gdb_stderr, "target_remove_fork_catchpoint (%d) = %d\n",
+  fprintf_unfiltered (gdb_stdlog, "target_remove_fork_catchpoint (%d) = %d\n",
                      pid, retval);
 
   return retval;
@@ -2351,7 +2422,7 @@ debug_to_insert_vfork_catchpoint (pid)
 
   retval = debug_target.to_insert_vfork_catchpoint (pid);
 
-  fprintf_unfiltered (gdb_stderr, "target_insert_vfork_catchpoint (%d)= %d\n",
+  fprintf_unfiltered (gdb_stdlog, "target_insert_vfork_catchpoint (%d)= %d\n",
                      pid, retval);
 
   return retval;
@@ -2365,7 +2436,7 @@ debug_to_remove_vfork_catchpoint (pid)
 
   retval = debug_target.to_remove_vfork_catchpoint (pid);
 
-  fprintf_unfiltered (gdb_stderr, "target_remove_vfork_catchpoint (%d) = %d\n",
+  fprintf_unfiltered (gdb_stdlog, "target_remove_vfork_catchpoint (%d) = %d\n",
                      pid, retval);
 
   return retval;
@@ -2380,7 +2451,7 @@ debug_to_has_forked (pid, child_pid)
 
   has_forked = debug_target.to_has_forked (pid, child_pid);
 
-  fprintf_unfiltered (gdb_stderr, "target_has_forked (%d, %d) = %d\n",
+  fprintf_unfiltered (gdb_stdlog, "target_has_forked (%d, %d) = %d\n",
                      pid, *child_pid, has_forked);
 
   return has_forked;
@@ -2395,7 +2466,7 @@ debug_to_has_vforked (pid, child_pid)
 
   has_vforked = debug_target.to_has_vforked (pid, child_pid);
 
-  fprintf_unfiltered (gdb_stderr, "target_has_vforked (%d, %d) = %d\n",
+  fprintf_unfiltered (gdb_stdlog, "target_has_vforked (%d, %d) = %d\n",
                      pid, *child_pid, has_vforked);
 
   return has_vforked;
@@ -2408,7 +2479,7 @@ debug_to_can_follow_vfork_prior_to_exec ()
 
   can_immediately_follow_vfork = debug_target.to_can_follow_vfork_prior_to_exec ();
 
-  fprintf_unfiltered (gdb_stderr, "target_can_follow_vfork_prior_to_exec () = %d\n",
+  fprintf_unfiltered (gdb_stdlog, "target_can_follow_vfork_prior_to_exec () = %d\n",
                      can_immediately_follow_vfork);
 
   return can_immediately_follow_vfork;
@@ -2423,7 +2494,7 @@ debug_to_post_follow_vfork (parent_pid, followed_parent, child_pid, followed_chi
 {
   debug_target.to_post_follow_vfork (parent_pid, followed_parent, child_pid, followed_child);
 
-  fprintf_unfiltered (gdb_stderr,
+  fprintf_unfiltered (gdb_stdlog,
                      "target_post_follow_vfork (%d, %d, %d, %d)\n",
                    parent_pid, followed_parent, child_pid, followed_child);
 }
@@ -2436,7 +2507,7 @@ debug_to_insert_exec_catchpoint (pid)
 
   retval = debug_target.to_insert_exec_catchpoint (pid);
 
-  fprintf_unfiltered (gdb_stderr, "target_insert_exec_catchpoint (%d) = %d\n",
+  fprintf_unfiltered (gdb_stdlog, "target_insert_exec_catchpoint (%d) = %d\n",
                      pid, retval);
 
   return retval;
@@ -2450,7 +2521,7 @@ debug_to_remove_exec_catchpoint (pid)
 
   retval = debug_target.to_remove_exec_catchpoint (pid);
 
-  fprintf_unfiltered (gdb_stderr, "target_remove_exec_catchpoint (%d) = %d\n",
+  fprintf_unfiltered (gdb_stdlog, "target_remove_exec_catchpoint (%d) = %d\n",
                      pid, retval);
 
   return retval;
@@ -2465,7 +2536,7 @@ debug_to_has_execd (pid, execd_pathname)
 
   has_execd = debug_target.to_has_execd (pid, execd_pathname);
 
-  fprintf_unfiltered (gdb_stderr, "target_has_execd (%d, %s) = %d\n",
+  fprintf_unfiltered (gdb_stdlog, "target_has_execd (%d, %s) = %d\n",
                      pid, (*execd_pathname ? *execd_pathname : "<NULL>"),
                      has_execd);
 
@@ -2479,7 +2550,7 @@ debug_to_reported_exec_events_per_exec_call ()
 
   reported_exec_events = debug_target.to_reported_exec_events_per_exec_call ();
 
-  fprintf_unfiltered (gdb_stderr,
+  fprintf_unfiltered (gdb_stdlog,
                      "target_reported_exec_events_per_exec_call () = %d\n",
                      reported_exec_events);
 
@@ -2511,7 +2582,7 @@ debug_to_has_syscall_event (pid, kind, syscall_id)
        }
     }
 
-  fprintf_unfiltered (gdb_stderr,
+  fprintf_unfiltered (gdb_stdlog,
                      "target_has_syscall_event (%d, %s, %d) = %d\n",
                      pid, kind_spelling, *syscall_id, has_syscall_event);
 
@@ -2528,7 +2599,7 @@ debug_to_has_exited (pid, wait_status, exit_status)
 
   has_exited = debug_target.to_has_exited (pid, wait_status, exit_status);
 
-  fprintf_unfiltered (gdb_stderr, "target_has_exited (%d, %d, %d) = %d\n",
+  fprintf_unfiltered (gdb_stdlog, "target_has_exited (%d, %d, %d) = %d\n",
                      pid, wait_status, *exit_status, has_exited);
 
   return has_exited;
@@ -2539,7 +2610,7 @@ debug_to_mourn_inferior ()
 {
   debug_target.to_mourn_inferior ();
 
-  fprintf_unfiltered (gdb_stderr, "target_mourn_inferior ()\n");
+  fprintf_unfiltered (gdb_stdlog, "target_mourn_inferior ()\n");
 }
 
 static int
@@ -2549,7 +2620,7 @@ debug_to_can_run ()
 
   retval = debug_target.to_can_run ();
 
-  fprintf_unfiltered (gdb_stderr, "target_can_run () = %d\n", retval);
+  fprintf_unfiltered (gdb_stdlog, "target_can_run () = %d\n", retval);
 
   return retval;
 }
@@ -2560,7 +2631,7 @@ debug_to_notice_signals (pid)
 {
   debug_target.to_notice_signals (pid);
 
-  fprintf_unfiltered (gdb_stderr, "target_notice_signals (%d)\n", pid);
+  fprintf_unfiltered (gdb_stdlog, "target_notice_signals (%d)\n", pid);
 }
 
 static int
@@ -2571,7 +2642,7 @@ debug_to_thread_alive (pid)
 
   retval = debug_target.to_thread_alive (pid);
 
-  fprintf_unfiltered (gdb_stderr, "target_thread_alive (%d) = %d\n",
+  fprintf_unfiltered (gdb_stdlog, "target_thread_alive (%d) = %d\n",
                      pid, retval);
 
   return retval;
@@ -2582,7 +2653,7 @@ debug_to_stop ()
 {
   debug_target.to_stop ();
 
-  fprintf_unfiltered (gdb_stderr, "target_stop ()\n");
+  fprintf_unfiltered (gdb_stdlog, "target_stop ()\n");
 }
 
 static int
@@ -2596,11 +2667,19 @@ debug_to_query (type, req, resp, siz)
 
   retval = debug_target.to_query (type, req, resp, siz);
 
-  fprintf_unfiltered (gdb_stderr, "target_query (%c, %s, %s,  %d) = %d\n", type, req, resp, *siz, retval);
+  fprintf_unfiltered (gdb_stdlog, "target_query (%c, %s, %s,  %d) = %d\n", type, req, resp, *siz, retval);
 
   return retval;
 }
 
+static void
+debug_to_rcmd (char *command,
+              struct gdb_file *outbuf)
+{
+  debug_target.to_rcmd (command, outbuf);
+  fprintf_unfiltered (gdb_stdlog, "target_rcmd (%s, ...)\n", command);
+}
+
 static struct symtab_and_line *
 debug_to_enable_exception_callback (kind, enable)
      enum exception_event_kind kind;
@@ -2608,7 +2687,7 @@ debug_to_enable_exception_callback (kind, enable)
 {
   struct symtab_and_line *result;
   result = debug_target.to_enable_exception_callback (kind, enable);
-  fprintf_unfiltered (gdb_stderr,
+  fprintf_unfiltered (gdb_stdlog,
                      "target get_exception_callback_sal (%d, %d)\n",
                      kind, enable);
   return result;
@@ -2619,7 +2698,7 @@ debug_to_get_current_exception_event ()
 {
   struct exception_event_record *result;
   result = debug_target.to_get_current_exception_event ();
-  fprintf_unfiltered (gdb_stderr, "target get_current_exception_event ()\n");
+  fprintf_unfiltered (gdb_stdlog, "target get_current_exception_event ()\n");
   return result;
 }
 
@@ -2631,7 +2710,7 @@ debug_to_pid_to_exec_file (pid)
 
   exec_file = debug_target.to_pid_to_exec_file (pid);
 
-  fprintf_unfiltered (gdb_stderr, "target_pid_to_exec_file (%d) = %s\n",
+  fprintf_unfiltered (gdb_stdlog, "target_pid_to_exec_file (%d) = %s\n",
                      pid, exec_file);
 
   return exec_file;
@@ -2645,7 +2724,7 @@ debug_to_core_file_to_sym_file (core)
 
   sym_file = debug_target.to_core_file_to_sym_file (core);
 
-  fprintf_unfiltered (gdb_stderr, "target_core_file_to_sym_file (%s) = %s\n",
+  fprintf_unfiltered (gdb_stdlog, "target_core_file_to_sym_file (%s) = %s\n",
                      core, sym_file);
 
   return sym_file;
@@ -2706,6 +2785,7 @@ setup_target_debug ()
   current_target.to_thread_alive = debug_to_thread_alive;
   current_target.to_stop = debug_to_stop;
   current_target.to_query = debug_to_query;
+  current_target.to_rcmd = debug_to_rcmd;
   current_target.to_enable_exception_callback = debug_to_enable_exception_callback;
   current_target.to_get_current_exception_event = debug_to_get_current_exception_event;
   current_target.to_pid_to_exec_file = debug_to_pid_to_exec_file;
@@ -2719,6 +2799,19 @@ static char targ_desc[] =
 Shows the entire stack of targets currently in use (including the exec-file,\n\
 core-file, and process, if any), as well as the symbol file name.";
 
+static void
+do_monitor_command (char *cmd,
+                int from_tty)
+{
+  if ((current_target.to_rcmd == (void*) tcomplain)
+      || (current_target.to_rcmd == debug_to_rcmd
+         && (debug_target.to_rcmd == (void*) tcomplain)))
+    {
+      error ("\"monitor\" command not supported by this target.\n");
+    }
+  target_rcmd (cmd, gdb_stdtarg);
+}
+
 void
 initialize_targets ()
 {
@@ -2735,6 +2828,10 @@ initialize_targets ()
 When non-zero, target debugging is enabled.", &setlist),
                      &showlist);
 
+
+  add_com ("monitor", class_obscure, do_monitor_command,
+          "Send a command to the remote monitor (remote targets only).");
+
   if (!STREQ (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC"))
     abort ();
 }
This page took 0.036664 seconds and 4 git commands to generate.