* dwarf2read.c (dwarf2_get_pc_bounds): Check DW_AT_high_pc form to
[deliverable/binutils-gdb.git] / gdb / inf-child.c
index 0dda33151876d82e2d9e426cdf34b11171cd0c51..5531102314bcc15ff3caf22973eb63136828abbf 100644 (file)
 #include "target.h"
 #include "inferior.h"
 #include "gdb_string.h"
+#include "gdb_stat.h"
 #include "inf-child.h"
 #include "gdb/fileio.h"
+#include "agent.h"
 
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>         /* for MAXPATHLEN */
+#endif
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
 
@@ -299,6 +303,53 @@ inf_child_fileio_unlink (const char *filename, int *target_errno)
   return ret;
 }
 
+/* Read value of symbolic link FILENAME on the target.  Return a
+   null-terminated string allocated via xmalloc, or NULL if an error
+   occurs (and set *TARGET_ERRNO).  */
+static char *
+inf_child_fileio_readlink (const char *filename, int *target_errno)
+{
+  /* We support readlink only on systems that also provide a compile-time
+     maximum path length (MAXPATHLEN), at least for now.  */
+#if defined (HAVE_READLINK) && defined (MAXPATHLEN)
+  char buf[MAXPATHLEN];
+  int len;
+  char *ret;
+
+  len = readlink (filename, buf, sizeof buf);
+  if (len < 0)
+    {
+      *target_errno = inf_child_errno_to_fileio_error (errno);
+      return NULL;
+    }
+
+  ret = xmalloc (len + 1);
+  memcpy (ret, buf, len);
+  ret[len] = '\0';
+  return ret;
+#else
+  *target_errno = FILEIO_ENOSYS;
+  return NULL;
+#endif
+}
+
+static int
+inf_child_use_agent (int use)
+{
+  if (agent_loaded_p ())
+    {
+      use_agent = use;
+      return 1;
+    }
+  else
+    return 0;
+}
+
+static int
+inf_child_can_use_agent (void)
+{
+  return agent_loaded_p ();
+}
 
 struct target_ops *
 inf_child_target (void)
@@ -336,6 +387,9 @@ inf_child_target (void)
   t->to_fileio_pread = inf_child_fileio_pread;
   t->to_fileio_close = inf_child_fileio_close;
   t->to_fileio_unlink = inf_child_fileio_unlink;
+  t->to_fileio_readlink = inf_child_fileio_readlink;
   t->to_magic = OPS_MAGIC;
+  t->to_use_agent = inf_child_use_agent;
+  t->to_can_use_agent = inf_child_can_use_agent;
   return t;
 }
This page took 0.023999 seconds and 4 git commands to generate.