#include "unw_nto_internal.h"
#include "os-qnx.h"
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int unw_nto_access_mem (unw_addr_space_t as,
unw_word_t addr,
unw_word_t *valp,
int write,
void *arg)
{
int ret = -UNW_ENOINFO;
unw_nto_internal_t *uni = (unw_nto_internal_t *)arg;
int as_fd = unw_nto_procfs_open_as (uni->pid);
if (as_fd < 0)
{
Debug (0, "error %d opening as file: %s\n", errno, strerror (errno));
return ret;
}
if (lseek (as_fd, (off_t)addr, SEEK_SET) == -1)
{
Debug (0, "error %d in lseek(%" PRIxPTR "): %s\n", errno, addr, strerror (errno));
close (as_fd);
return ret;
}
if (!write)
{
ssize_t count = read (as_fd, valp, sizeof (*valp));
if (count != sizeof (*valp))
{
Debug (0, "error %d in read(%zu): %s\n", errno, sizeof (*valp), strerror (errno));
close (as_fd);
return ret;
}
ret = 0;
}
close (as_fd);
return ret;
}