/* Functions specific to running gdb native on IA-64 running
GNU/Linux.
- Copyright (C) 1999-2014 Free Software Foundation, Inc.
+ Copyright (C) 1999-2015 Free Software Foundation, Inc.
This file is part of GDB.
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
-#include <string.h>
#include "inferior.h"
#include "target.h"
#include "gdbcore.h"
#include "linux-nat.h"
#include <signal.h>
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
#include "gdb_wait.h"
#ifdef HAVE_SYS_REG_H
#include <sys/reg.h>
{
if (object == TARGET_OBJECT_UNWIND_TABLE && readbuf != NULL)
{
- gdb_byte *tmp_buf = alloca (offset + len);
- ULONGEST xfered;
-
- xfered = syscall (__NR_getunwind, readbuf, offset + len);
- if (xfered <= 0)
+ static long gate_table_size;
+ gdb_byte *tmp_buf;
+ long res;
+
+ /* Probe for the table size once. */
+ if (gate_table_size == 0)
+ gate_table_size = syscall (__NR_getunwind, NULL, 0);
+ if (gate_table_size < 0)
return TARGET_XFER_E_IO;
- else if (xfered <= offset)
+
+ if (offset >= gate_table_size)
return TARGET_XFER_EOF;
- else
- {
- memcpy (readbuf, tmp_buf + offset, xfered - offset);
- *xfered_len = xfered - offset;
- return TARGET_XFER_OK;
- }
+
+ tmp_buf = alloca (gate_table_size);
+ res = syscall (__NR_getunwind, tmp_buf, gate_table_size);
+ if (res < 0)
+ return TARGET_XFER_E_IO;
+ gdb_assert (res == gate_table_size);
+
+ if (offset + len > gate_table_size)
+ len = gate_table_size - offset;
+
+ memcpy (readbuf, tmp_buf + offset, len);
+ *xfered_len = len;
+ return TARGET_XFER_OK;
}
return super_xfer_partial (ops, object, annex, readbuf, writebuf,