/* GNU/Linux native-dependent code common to multiple platforms.
- Copyright (C) 2001-2013 Free Software Foundation, Inc.
+ Copyright (C) 2001-2014 Free Software Foundation, Inc.
This file is part of GDB.
#include "gregset.h" /* for gregset */
#include "gdbcore.h" /* for get_exec_file */
#include <ctype.h> /* for isdigit */
-#include "gdbthread.h" /* for struct thread_info etc. */
-#include "gdb_stat.h" /* for struct stat */
+#include <sys/stat.h> /* for struct stat */
#include <fcntl.h> /* for O_RDONLY */
#include "inf-loop.h"
#include "event-loop.h"
#include "event-top.h"
#include <pwd.h>
#include <sys/types.h>
-#include "gdb_dirent.h"
+#include <dirent.h>
#include "xml-support.h"
#include "terminal.h"
#include <sys/vfs.h>
#include "agent.h"
#include "tracepoint.h"
#include "exceptions.h"
-#include "linux-ptrace.h"
#include "buffer.h"
#include "target-descriptions.h"
#include "filestuff.h"
/* The saved to_xfer_partial method, inherited from inf-ptrace.c.
Called by our to_xfer_partial. */
-static LONGEST (*super_xfer_partial) (struct target_ops *,
- enum target_object,
- const char *, gdb_byte *,
- const gdb_byte *,
- ULONGEST, LONGEST);
+static target_xfer_partial_ftype *super_xfer_partial;
static unsigned int debug_linux_nat;
static void
/* Put the signal number in ARGS so that inf_ptrace_detach will
pass it along with PTRACE_DETACH. */
tem = alloca (8);
- sprintf (tem, "%d", (int) WSTOPSIG (status));
+ xsnprintf (tem, 8, "%d", (int) WSTOPSIG (status));
args = tem;
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
struct gdbarch *gdbarch = get_regcache_arch (regcache);
CORE_ADDR pc;
- pc = regcache_read_pc (regcache) - gdbarch_decr_pc_after_break (gdbarch);
+ pc = regcache_read_pc (regcache) - target_decr_pc_after_break (gdbarch);
if (breakpoint_inserted_here_p (get_regcache_aspace (regcache), pc))
{
if (debug_linux_nat)
target_pid_to_str (lp->ptid));
/* Back up the PC if necessary. */
- if (gdbarch_decr_pc_after_break (gdbarch))
+ if (target_decr_pc_after_break (gdbarch))
regcache_write_pc (regcache, pc);
return 1;
static LONGEST
linux_xfer_siginfo (struct target_ops *ops, enum target_object object,
const char *annex, gdb_byte *readbuf,
- const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
+ const gdb_byte *writebuf, ULONGEST offset, ULONGEST len)
{
int pid;
siginfo_t siginfo;
linux_nat_xfer_partial (struct target_ops *ops, enum target_object object,
const char *annex, gdb_byte *readbuf,
const gdb_byte *writebuf,
- ULONGEST offset, LONGEST len)
+ ULONGEST offset, ULONGEST len)
{
struct cleanup *old_chain;
LONGEST xfer;
make_cleanup (xfree, name2);
memset (name2, 0, PATH_MAX);
- sprintf (name1, "/proc/%d/exe", pid);
+ xsnprintf (name1, PATH_MAX, "/proc/%d/exe", pid);
if (readlink (name1, name2, PATH_MAX - 1) > 0)
return name2;
else
/* We could keep this file open and cache it - possibly one per
thread. That requires some juggling, but is even faster. */
- sprintf (filename, "/proc/%d/mem", ptid_get_pid (inferior_ptid));
+ xsnprintf (filename, sizeof filename, "/proc/%d/mem",
+ ptid_get_pid (inferior_ptid));
fd = gdb_open_cloexec (filename, O_RDONLY | O_LARGEFILE, 0);
if (fd == -1)
return 0;
/* Enumerate spufs IDs for process PID. */
static LONGEST
-spu_enumerate_spu_ids (int pid, gdb_byte *buf, ULONGEST offset, LONGEST len)
+spu_enumerate_spu_ids (int pid, gdb_byte *buf, ULONGEST offset, ULONGEST len)
{
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
LONGEST pos = 0;
linux_proc_xfer_spu (struct target_ops *ops, enum target_object object,
const char *annex, gdb_byte *readbuf,
const gdb_byte *writebuf,
- ULONGEST offset, LONGEST len)
+ ULONGEST offset, ULONGEST len)
{
char buf[128];
int fd = 0;
sigemptyset (pending);
sigemptyset (blocked);
sigemptyset (ignored);
- sprintf (fname, "/proc/%d/status", pid);
+ xsnprintf (fname, sizeof fname, "/proc/%d/status", pid);
procfile = gdb_fopen_cloexec (fname, "r");
if (procfile == NULL)
error (_("Could not open %s"), fname);
static LONGEST
linux_nat_xfer_osdata (struct target_ops *ops, enum target_object object,
const char *annex, gdb_byte *readbuf,
- const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
+ const gdb_byte *writebuf, ULONGEST offset, ULONGEST len)
{
gdb_assert (object == TARGET_OBJECT_OSDATA);
static LONGEST
linux_xfer_partial (struct target_ops *ops, enum target_object object,
const char *annex, gdb_byte *readbuf,
- const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
+ const gdb_byte *writebuf, ULONGEST offset, ULONGEST len)
{
LONGEST xfer;