Introduce show_debug_regs
[deliverable/binutils-gdb.git] / gdb / common / agent.c
index 43f1b65e78145ac4a6c42257d5eab24c8d5d0152..2963917641c10b2147d7f4c647ec6c4d333dbf38 100644 (file)
@@ -1,6 +1,6 @@
 /* Shared utility routines for GDB to interact with agent.
 
-   Copyright (C) 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2009-2014 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #else
 #include "defs.h"
 #include "target.h"
-#include "inferior.h" /* for non_stop */
+#include "infrun.h"
+#include "objfiles.h"
 #endif
-
-#include <string.h>
 #include <unistd.h>
 #include "agent.h"
+#include "filestuff.h"
 
 int debug_agent = 0;
 
-#ifdef GDBSERVER
-#define DEBUG_AGENT(fmt, args...)      \
-  if (debug_agent)                     \
-    fprintf (stderr, fmt, ##args);
-#else
-#define DEBUG_AGENT(fmt, args...)      \
-  if (debug_agent)                     \
-    fprintf_unfiltered (gdb_stdlog, fmt, ##args);
-#endif
+/* A stdarg wrapper for debug_vprintf.  */
+
+static void ATTRIBUTE_PRINTF (1, 2)
+debug_agent_printf (const char *fmt, ...)
+{
+  va_list ap;
+
+  if (!debug_agent)
+    return;
+  va_start (ap, fmt);
+  debug_vprintf (fmt, ap);
+  va_end (ap);
+}
+
+#define DEBUG_AGENT debug_agent_printf
 
 /* Global flag to determine using agent or not.  */
 int use_agent = 0;
@@ -97,12 +103,12 @@ agent_look_up_symbols (void *arg)
 
       if (look_up_one_symbol (symbol_list[i].name, addrp, 1) == 0)
 #else
-      struct minimal_symbol *sym =
+      struct bound_minimal_symbol sym =
        lookup_minimal_symbol (symbol_list[i].name, NULL,
                               (struct objfile *) arg);
 
-      if (sym != NULL)
-       *addrp = SYMBOL_VALUE_ADDRESS (sym);
+      if (sym.minsym != NULL)
+       *addrp = BMSYMBOL_VALUE_ADDRESS (sym);
       else
 #endif
        {
@@ -125,7 +131,7 @@ agent_get_helper_thread_id (void)
                                (unsigned char *) &helper_thread_id,
                                sizeof helper_thread_id))
 #else
-      enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+      enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
       gdb_byte buf[4];
 
       if (target_read_memory (ipa_sym_addrs.addr_helper_thread_id,
@@ -168,7 +174,7 @@ gdb_connect_sync_socket (int pid)
   if (res >= UNIX_PATH_MAX)
     return -1;
 
-  res = fd = socket (PF_UNIX, SOCK_STREAM, 0);
+  res = fd = gdb_socket_cloexec (PF_UNIX, SOCK_STREAM, 0);
   if (res == -1)
     {
       warning (_("error opening sync socket: %s"), strerror (errno));
@@ -218,7 +224,8 @@ agent_run_command (int pid, const char *cmd, int len)
   int ret = write_inferior_memory (ipa_sym_addrs.addr_cmd_buf,
                                   (const unsigned char *) cmd, len);
 #else
-  int ret = target_write_memory (ipa_sym_addrs.addr_cmd_buf, cmd, len);
+  int ret = target_write_memory (ipa_sym_addrs.addr_cmd_buf,
+                                (gdb_byte *) cmd, len);
 #endif
 
   if (ret != 0)
@@ -332,7 +339,7 @@ agent_capability_check (enum agent_capa agent_capa)
                                (unsigned char *) &agent_capability,
                                sizeof agent_capability))
 #else
-      enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+      enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
       gdb_byte buf[4];
 
       if (target_read_memory (ipa_sym_addrs.addr_capability,
This page took 0.024622 seconds and 4 git commands to generate.