aboutsummaryrefslogtreecommitdiff
path: root/gdb/nto-procfs.c
diff options
context:
space:
mode:
authorAleksandar Ristovski <aristovski@qnx.com>2015-10-20 12:58:47 -0400
committerAleksandar Ristovski <aristovski@qnx.com>2015-10-20 13:02:33 -0400
commit8a6c0ccdd27188047da2be9c2a49544c27dcade3 (patch)
tree2bc08f13d9f6515b08bfe19a56c9ba79b971ffdd /gdb/nto-procfs.c
parent609c3040c2df944239d4d96644d736df605a6831 (diff)
downloadgdb-8a6c0ccdd27188047da2be9c2a49544c27dcade3.zip
gdb-8a6c0ccdd27188047da2be9c2a49544c27dcade3.tar.gz
gdb-8a6c0ccdd27188047da2be9c2a49544c27dcade3.tar.bz2
[nto] Implement TARGET_OBJECT_AUXV.
Fix 'info auxv' for nto. gdb/ChangeLog: * nto-procfs.c (sys/auxv.h): Include. (procfs_xfer_partial): Implement TARGET_OBJECT_AUXV. * nto-tdep.c (nto_read_auxv_from_initial_stack): New function. * nto-tdep.h (nto_read_auxv_from_initial_stack): New declaration.
Diffstat (limited to 'gdb/nto-procfs.c')
-rw-r--r--gdb/nto-procfs.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 264d88b..eb0f7be 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -30,6 +30,8 @@
#include <sys/syspage.h>
#include <dirent.h>
#include <sys/netmgr.h>
+#include <sys/auxv.h>
+
#include "gdbcore.h"
#include "inferior.h"
#include "target.h"
@@ -885,6 +887,38 @@ procfs_xfer_partial (struct target_ops *ops, enum target_object object,
{
case TARGET_OBJECT_MEMORY:
return procfs_xfer_memory (readbuf, writebuf, offset, len, xfered_len);
+ case TARGET_OBJECT_AUXV:
+ if (readbuf != NULL)
+ {
+ int err;
+ CORE_ADDR initial_stack;
+ debug_process_t procinfo;
+ /* For 32-bit architecture, size of auxv_t is 8 bytes. */
+ const unsigned int sizeof_auxv_t = sizeof (auxv_t);
+ const unsigned int sizeof_tempbuf = 20 * sizeof_auxv_t;
+ int tempread;
+ gdb_byte *const tempbuf = alloca (sizeof_tempbuf);
+
+ if (tempbuf == NULL)
+ return TARGET_XFER_E_IO;
+
+ err = devctl (ctl_fd, DCMD_PROC_INFO, &procinfo,
+ sizeof procinfo, 0);
+ if (err != EOK)
+ return TARGET_XFER_E_IO;
+
+ initial_stack = procinfo.initial_stack;
+
+ /* procfs is always 'self-hosted', no byte-order manipulation. */
+ tempread = nto_read_auxv_from_initial_stack (initial_stack, tempbuf,
+ sizeof_tempbuf,
+ sizeof (auxv_t));
+ tempread = min (tempread, len) - offset;
+ memcpy (readbuf, tempbuf + offset, tempread);
+ *xfered_len = tempread;
+ return tempread ? TARGET_XFER_OK : TARGET_XFER_EOF;
+ }
+ /* Fallthru */
default:
return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
readbuf, writebuf, offset, len,