2004-02-25 Roland McGrath <roland@redhat.com>
* target.h (struct target_ops): New member `read_auxv'. * server.c (handle_query): Handle qPart:auxv:read: query using that. * linux-low.c (linux_read_auxv): New function. (linux_target_ops): Initialize `read_auxv' member to that.
This commit is contained in:
parent
802188a76c
commit
aa691b87c2
@ -1381,6 +1381,32 @@ linux_send_signal (int signum)
|
||||
kill (signal_pid, signum);
|
||||
}
|
||||
|
||||
/* Copy LEN bytes from inferior's auxiliary vector starting at OFFSET
|
||||
to debugger memory starting at MYADDR. */
|
||||
|
||||
static int
|
||||
linux_read_auxv (CORE_ADDR offset, char *myaddr, unsigned int len)
|
||||
{
|
||||
char filename[PATH_MAX];
|
||||
int fd, n;
|
||||
|
||||
snprintf (filename, sizeof filename, "/proc/%d/auxv", inferior_pid);
|
||||
|
||||
fd = open (filename, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
|
||||
if (offset != (CORE_ADDR) 0
|
||||
&& lseek (fd, (off_t) offset, SEEK_SET) != (off_t) offset)
|
||||
n = -1;
|
||||
else
|
||||
n = read (fd, myaddr, len);
|
||||
|
||||
close (fd);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
static struct target_ops linux_target_ops = {
|
||||
linux_create_inferior,
|
||||
@ -1396,6 +1422,7 @@ static struct target_ops linux_target_ops = {
|
||||
linux_write_memory,
|
||||
linux_look_up_symbols,
|
||||
linux_send_signal,
|
||||
linux_read_auxv,
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -120,6 +120,26 @@ handle_query (char *own_buf)
|
||||
}
|
||||
}
|
||||
|
||||
if (the_target->read_auxv != NULL
|
||||
&& strncmp ("qPart:auxv:read::", own_buf, 17) == 0)
|
||||
{
|
||||
char data[(PBUFSIZ - 1) / 2];
|
||||
CORE_ADDR ofs;
|
||||
unsigned int len;
|
||||
int n;
|
||||
decode_m_packet (&own_buf[17], &ofs, &len); /* "OFS,LEN" */
|
||||
if (len > sizeof data)
|
||||
len = sizeof data;
|
||||
n = (*the_target->read_auxv) (ofs, data, len);
|
||||
if (n == 0)
|
||||
write_ok (own_buf);
|
||||
else if (n < 0)
|
||||
write_enn (own_buf);
|
||||
else
|
||||
convert_int_to_ascii (data, own_buf, n);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Otherwise we didn't know what packet it was. Say we didn't
|
||||
understand it. */
|
||||
own_buf[0] = 0;
|
||||
|
@ -125,6 +125,12 @@ struct target_ops
|
||||
|
||||
/* Send a signal to the inferior process, however is appropriate. */
|
||||
void (*send_signal) (int);
|
||||
|
||||
/* Read auxiliary vector data from the inferior process.
|
||||
|
||||
Read LEN bytes at OFFSET into a buffer at MYADDR. */
|
||||
|
||||
int (*read_auxv) (CORE_ADDR offset, char *myaddr, unsigned int len);
|
||||
};
|
||||
|
||||
extern struct target_ops *the_target;
|
||||
|
Loading…
x
Reference in New Issue
Block a user