diff options
author | Yao Qi <yao@codesourcery.com> | 2011-08-14 13:03:13 +0000 |
---|---|---|
committer | Yao Qi <yao@codesourcery.com> | 2011-08-14 13:03:13 +0000 |
commit | 78d8519916ea5cc108bb6280779e0384978fa6d2 (patch) | |
tree | de5d8d9878253d714752940a83cb776510b7acd4 /gdb/gdbserver | |
parent | d3e3fa9393077d57b41b07f96be95e1035dcda48 (diff) | |
download | gdb-78d8519916ea5cc108bb6280779e0384978fa6d2.zip gdb-78d8519916ea5cc108bb6280779e0384978fa6d2.tar.gz gdb-78d8519916ea5cc108bb6280779e0384978fa6d2.tar.bz2 |
gdb/
* remote.c (PACKET_qXfer_fdpic): New enum value.
(remote_protocol_features): Add qXfer:fdpic:read packet.
(remote_xfer_partial): Support TARGET_OBJECT_FDPIC.
(_initialize_remote): Add set/show remote read-fdpic-loadmap command.
* target.h (enum target_object): Add TARGET_OBJECT_FDPIC.
gdb/gdbserver:
* target.h (struct target_ops): Add read_loadmap.
* linux-low.c (struct target_loadseg): New type.
(struct target_loadmap): New type.
(linux_read_loadmap): New function.
(linux_target_ops): Add linux_read_loadmap.
* server.c (handle_query): Support qXfer:fdpic:read packet.
* win32-low.c (win32_target_ops): Initialize field `read_loadmap' to NULL.
gdb/doc/
* gdb.texinfo : Document qXfer:fdpic:read packet.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 11 | ||||
-rw-r--r-- | gdb/gdbserver/linux-low.c | 65 | ||||
-rw-r--r-- | gdb/gdbserver/server.c | 19 | ||||
-rw-r--r-- | gdb/gdbserver/target.h | 4 | ||||
-rw-r--r-- | gdb/gdbserver/win32-low.c | 1 |
5 files changed, 100 insertions, 0 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index c8512f4..7b2b165 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,14 @@ +2011-08-14 Andrew Stubbs <ams@codesourcery.com> + Yao Qi <yao@codesourcery.com> + + * target.h (struct target_ops): Add read_loadmap. + * linux-low.c (struct target_loadseg): New type. + (struct target_loadmap): New type. + (linux_read_loadmap): New function. + (linux_target_ops): Add linux_read_loadmap. + * server.c (handle_query): Support qXfer:fdpic:read packet. + * win32-low.c (win32_target_ops): Initialize field `read_loadmap' to NULL. + 2011-08-05 Eli Zaretskii <eliz@gnu.org> * win32-low.c: Include <stdint.h>. diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index a9cdaca..999ca92 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -4654,6 +4654,66 @@ linux_qxfer_spu (const char *annex, unsigned char *readbuf, return ret; } +#if defined PT_GETDSBT +struct target_loadseg +{ + /* Core address to which the segment is mapped. */ + Elf32_Addr addr; + /* VMA recorded in the program header. */ + Elf32_Addr p_vaddr; + /* Size of this segment in memory. */ + Elf32_Word p_memsz; +}; + +struct target_loadmap +{ + /* Protocol version number, must be zero. */ + Elf32_Word version; + /* Pointer to the DSBT table, its size, and the DSBT index. */ + unsigned *dsbt_table; + unsigned dsbt_size, dsbt_index; + /* Number of segments in this map. */ + Elf32_Word nsegs; + /* The actual memory map. */ + struct target_loadseg segs[/*nsegs*/]; +}; +#endif + +#if defined PT_GETDSBT +static int +linux_read_loadmap (const char *annex, CORE_ADDR offset, + unsigned char *myaddr, unsigned int len) +{ + int pid = lwpid_of (get_thread_lwp (current_inferior)); + int addr = -1; + struct target_loadmap *data = NULL; + unsigned int actual_length, copy_length; + + if (strcmp (annex, "exec") == 0) + addr= (int) PTRACE_GETDSBT_EXEC; + else if (strcmp (annex, "interp") == 0) + addr = (int) PTRACE_GETDSBT_INTERP; + else + return -1; + + if (ptrace (PT_GETDSBT, pid, addr, &data) != 0) + return -1; + + if (data == NULL) + return -1; + + actual_length = sizeof (struct target_loadmap) + + sizeof (struct target_loadseg) * data->nsegs; + + if (offset < 0 || offset > actual_length) + return -1; + + copy_length = actual_length - offset < len ? actual_length - offset : len; + memcpy (myaddr, (char *) data + offset, copy_length); + return copy_length; +} +#endif /* defined PT_GETDSBT */ + static void linux_process_qsupported (const char *query) { @@ -4802,6 +4862,11 @@ static struct target_ops linux_target_ops = { NULL, #endif linux_common_core_of_thread, +#if defined PT_GETDSBT + linux_read_loadmap, +#else + NULL, +#endif linux_process_qsupported, linux_supports_tracepoints, linux_read_pc, diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index a87aef5..a97bf86 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -1171,9 +1171,25 @@ handle_qxfer_traceframe_info (const char *annex, return len; } +/* Handle qXfer:fdpic:read. */ + +static int +handle_qxfer_fdpic (const char *annex, gdb_byte *readbuf, + const gdb_byte *writebuf, ULONGEST offset, LONGEST len) +{ + if (the_target->read_loadmap == NULL) + return -2; + + if (!target_running ()) + return -1; + + return (*the_target->read_loadmap) (annex, offset, readbuf, len); +} + static const struct qxfer qxfer_packets[] = { { "auxv", handle_qxfer_auxv }, + { "fdpic", handle_qxfer_fdpic}, { "features", handle_qxfer_features }, { "libraries", handle_qxfer_libraries }, { "osdata", handle_qxfer_osdata }, @@ -1509,6 +1525,9 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p) if (the_target->qxfer_siginfo != NULL) strcat (own_buf, ";qXfer:siginfo:read+;qXfer:siginfo:write+"); + if (the_target->read_loadmap != NULL) + strcat (own_buf, ";qXfer:fdpic:read+"); + /* We always report qXfer:features:read, as targets may install XML files on a subsequent call to arch_setup. If we reported to GDB on startup that we don't support diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h index 00214db..3a823a1 100644 --- a/gdb/gdbserver/target.h +++ b/gdb/gdbserver/target.h @@ -311,6 +311,10 @@ struct target_ops /* Returns the core given a thread, or -1 if not known. */ int (*core_of_thread) (ptid_t); + /* Read loadmaps. Read LEN bytes at OFFSET into a buffer at MYADDR. */ + int (*read_loadmap) (const char *annex, CORE_ADDR offset, + unsigned char *myaddr, unsigned int len); + /* Target specific qSupported support. */ void (*process_qsupported) (const char *); diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c index cc4e23d..728af50 100644 --- a/gdb/gdbserver/win32-low.c +++ b/gdb/gdbserver/win32-low.c @@ -1811,6 +1811,7 @@ static struct target_ops win32_target_ops = { NULL, /* supports_multi_process */ NULL, /* handle_monitor_command */ NULL, /* core_of_thread */ + NULL, /* read_fdpic_loadmap */ NULL, /* process_qsupported */ NULL, /* supports_tracepoints */ NULL, /* read_pc */ |