aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/remote-utils.c
diff options
context:
space:
mode:
authorMarcin Koƛcielnicki <koriakin@0x04.net>2016-03-12 14:03:26 +0100
committerMarcin Koƛcielnicki <koriakin@0x04.net>2016-03-30 01:51:06 +0200
commit28170b88cc8b40fdea2b065dafe6e1872a47ee4e (patch)
treecb05b89e30b424c98961d3e3eb13e63f29055484 /gdb/gdbserver/remote-utils.c
parenta08b52b5c45195c0b095215f19422d2ab67a3a8d (diff)
downloadfsf-binutils-gdb-28170b88cc8b40fdea2b065dafe6e1872a47ee4e.zip
fsf-binutils-gdb-28170b88cc8b40fdea2b065dafe6e1872a47ee4e.tar.gz
fsf-binutils-gdb-28170b88cc8b40fdea2b065dafe6e1872a47ee4e.tar.bz2
gdbserver: Handle 'v' packet while processing qSymbol.
On powerpc64, qSymbol query may require gdb to read a function descriptor, sending a vFile packet to gdbserver. Thus, we need to handle 'v' packet in look_up_one_symbol. vFile replies may be quite long, and require reallocating own_buf. Since handle_v_requests assumes the buffer is the static global own_buf from server.c and reallocates it, we need to make own_buf global and use it from look_up_one_symbol instead of using our own auto variable. I've also done the same change in relocate_instruction, just in case. On gdb side, in remote_check_symbols, rs->buf may be clobbered by vFile handling, yet we need its contents for the reply (the symbol name is stored there). Allocate a new buffer instead. This broke fast tracepoints on powerpc64, due to errors in reading IPA symbols. gdb/ChangeLog: * remote.c (remote_check_symbols): Allocate own buffer for reply. gdbserver/ChangeLog: * remote-utils.c (look_up_one_symbol): Remove own_buf, handle 'v' packets. (relocate_instruction): Remove own_buf. * server.c (own_buf): Make global. (handle_v_requests): Make global. * server.h (own_buf): New declaration. (handle_v_requests): New prototype.
Diffstat (limited to 'gdb/gdbserver/remote-utils.c')
-rw-r--r--gdb/gdbserver/remote-utils.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index e751473..768d2e9 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -1462,7 +1462,7 @@ clear_symbol_cache (struct sym_cache **symcache_p)
int
look_up_one_symbol (const char *name, CORE_ADDR *addrp, int may_ask_gdb)
{
- char own_buf[266], *p, *q;
+ char *p, *q;
int len;
struct sym_cache *sym;
struct process_info *proc;
@@ -1497,23 +1497,37 @@ look_up_one_symbol (const char *name, CORE_ADDR *addrp, int may_ask_gdb)
/* We ought to handle pretty much any packet at this point while we
wait for the qSymbol "response". That requires re-entering the
main loop. For now, this is an adequate approximation; allow
- GDB to read from memory while it figures out the address of the
- symbol. */
- while (own_buf[0] == 'm')
+ GDB to read from memory and handle 'v' packets (for vFile transfers)
+ while it figures out the address of the symbol. */
+ while (1)
{
- CORE_ADDR mem_addr;
- unsigned char *mem_buf;
- unsigned int mem_len;
+ if (own_buf[0] == 'm')
+ {
+ CORE_ADDR mem_addr;
+ unsigned char *mem_buf;
+ unsigned int mem_len;
- decode_m_packet (&own_buf[1], &mem_addr, &mem_len);
- mem_buf = (unsigned char *) xmalloc (mem_len);
- if (read_inferior_memory (mem_addr, mem_buf, mem_len) == 0)
- bin2hex (mem_buf, own_buf, mem_len);
+ decode_m_packet (&own_buf[1], &mem_addr, &mem_len);
+ mem_buf = (unsigned char *) xmalloc (mem_len);
+ if (read_inferior_memory (mem_addr, mem_buf, mem_len) == 0)
+ bin2hex (mem_buf, own_buf, mem_len);
+ else
+ write_enn (own_buf);
+ free (mem_buf);
+ if (putpkt (own_buf) < 0)
+ return -1;
+ }
+ else if (own_buf[0] == 'v')
+ {
+ int new_len = -1;
+ handle_v_requests (own_buf, len, &new_len);
+ if (new_len != -1)
+ putpkt_binary (own_buf, new_len);
+ else
+ putpkt (own_buf);
+ }
else
- write_enn (own_buf);
- free (mem_buf);
- if (putpkt (own_buf) < 0)
- return -1;
+ break;
len = getpkt (own_buf);
if (len < 0)
return -1;
@@ -1561,7 +1575,6 @@ look_up_one_symbol (const char *name, CORE_ADDR *addrp, int may_ask_gdb)
int
relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc)
{
- char own_buf[266];
int len;
ULONGEST written = 0;