Minor O_CLOEXEC optimization, "regression" fix
[deliverable/binutils-gdb.git] / gdb / common / agent.c
index 8fdc75ace1eac004796aeb74b87cb5f193e38c37..99cef4fcab354d67f18554ace50d709472881904 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-2013 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -28,6 +28,7 @@
 #include <string.h>
 #include <unistd.h>
 #include "agent.h"
+#include "filestuff.h"
 
 int debug_agent = 0;
 
@@ -125,7 +126,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 +169,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 +219,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)
@@ -236,11 +238,11 @@ agent_run_command (int pid, const char *cmd, int len)
 
   resume_info.thread = ptid;
   resume_info.kind = resume_continue;
-  resume_info.sig = TARGET_SIGNAL_0;
+  resume_info.sig = GDB_SIGNAL_0;
   (*the_target->resume) (&resume_info, 1);
 }
 #else
- target_resume (ptid, 0, TARGET_SIGNAL_0);
+ target_resume (ptid, 0, GDB_SIGNAL_0);
 #endif
 
   fd = gdb_connect_sync_socket (pid);
@@ -283,7 +285,7 @@ agent_run_command (int pid, const char *cmd, int len)
 
        resume_info.thread = ptid;
        resume_info.kind = resume_stop;
-       resume_info.sig = TARGET_SIGNAL_0;
+       resume_info.sig = GDB_SIGNAL_0;
        (*the_target->resume) (&resume_info, 1);
       }
 
@@ -332,7 +334,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.024929 seconds and 4 git commands to generate.