[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Implement Xfer:auxv:read in gdb stub
From: |
Bhushan Attarde |
Subject: |
[Qemu-devel] Implement Xfer:auxv:read in gdb stub |
Date: |
Wed, 24 Jun 2015 06:34:45 +0000 |
This patch implements support for "Xfer:auxv:read" to provide auxiliary vector
information to clients which relies on it.
For example: AT_ENTRY in auxiliary vector provides the entry point information.
Client can use this information to compare it with entry point mentioned in
executable to calculate load offset and then update the load addresses
accordingly.
Signed-off-by: Bhushan Attarde <address@hidden>
---
diff --git a/gdbstub.c b/gdbstub.c
index cea2a84..e7db84a 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1153,6 +1153,7 @@ static int gdb_handle_packet(GDBState *s, const char
*line_buf)
if (cc->gdb_core_xml_file != NULL) {
pstrcat(buf, sizeof(buf), ";qXfer:features:read+");
}
+ pstrcat(buf, sizeof(buf), ";qXfer:auxv:read+");
put_packet(s, buf);
break;
}
@@ -1199,6 +1200,50 @@ static int gdb_handle_packet(GDBState *s, const char
*line_buf)
put_packet_binary(s, buf, len + 1);
break;
}
+#ifdef CONFIG_USER_ONLY
+ if (strncmp(p, "Xfer:auxv:read:", 15) == 0) {
+ TaskState *ts = s->c_cpu->opaque;
+ target_ulong auxv = ts->info->saved_auxv;
+ target_ulong auxv_len = ts->info->auxv_len;
+ char *ptr;
+
+ p += 15;
+ while (*p && *p != ':') {
+ p++;
+ }
+ p++;
+
+ addr = strtoul(p, (char **)&p, 16);
+ if (*p == ',') {
+ p++;
+ }
+ len = strtoul(p, (char **)&p, 16);
+
+ ptr = lock_user(VERIFY_READ, auxv, auxv_len, 0);
+ if (ptr == NULL) {
+ break;
+ }
+
+ if (addr > len) {
+ snprintf(buf, sizeof(buf), "E00");
+ put_packet(s, buf);
+ break;
+ }
+ if (len > (MAX_PACKET_LENGTH - 5) / 2) {
+ len = (MAX_PACKET_LENGTH - 5) / 2;
+ }
+ if (len < auxv_len - addr) {
+ buf[0] = 'm';
+ len = memtox(buf + 1, ptr + addr, len);
+ } else {
+ buf[0] = 'l';
+ len = memtox(buf + 1, ptr + addr, auxv_len - addr);
+ }
+ put_packet_binary(s, buf, len + 1);
+ unlock_user(ptr, auxv, len);
+ break;
+ }
+#endif /* !CONFIG_USER_ONLY */
if (is_query_packet(p, "Attached", ':')) {
put_packet(s, GDB_ATTACHED);
break;
- [Qemu-devel] Implement Xfer:auxv:read in gdb stub,
Bhushan Attarde <=