2002-04-09 Daniel Jacobowitz <drow@mvista.com>
* linux-low.c (linux_look_up_symbols): New hook. (linux_target_ops): Add linux_look_up_symbols. * remote-utils.c (decode_address): New function. (look_up_one_symbol): New function. * server.c (handle_query): Call target look_up_symbols hook. * server.h (look_up_one_symbol): Add prototype. * target.h (struct target_ops): Add look_up_symbols hook.
This commit is contained in:
parent
d64b884136
commit
2f2893d916
6 changed files with 85 additions and 7 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
2002-04-09 Daniel Jacobowitz <drow@mvista.com>
|
||||||
|
|
||||||
|
* linux-low.c (linux_look_up_symbols): New hook.
|
||||||
|
(linux_target_ops): Add linux_look_up_symbols.
|
||||||
|
* remote-utils.c (decode_address): New function.
|
||||||
|
(look_up_one_symbol): New function.
|
||||||
|
* server.c (handle_query): Call target look_up_symbols hook.
|
||||||
|
* server.h (look_up_one_symbol): Add prototype.
|
||||||
|
* target.h (struct target_ops): Add look_up_symbols hook.
|
||||||
|
|
||||||
2002-04-09 Daniel Jacobowitz <drow@mvista.com>
|
2002-04-09 Daniel Jacobowitz <drow@mvista.com>
|
||||||
|
|
||||||
* gdbserver/server.h: Include <string.h> if HAVE_STRING_H.
|
* gdbserver/server.h: Include <string.h> if HAVE_STRING_H.
|
||||||
|
|
|
@ -481,6 +481,13 @@ linux_write_memory (CORE_ADDR memaddr, char *myaddr, int len)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
linux_look_up_symbols (void)
|
||||||
|
{
|
||||||
|
/* Don't need to look up any symbols yet. */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct target_ops linux_target_ops = {
|
static struct target_ops linux_target_ops = {
|
||||||
linux_create_inferior,
|
linux_create_inferior,
|
||||||
|
@ -493,6 +500,7 @@ static struct target_ops linux_target_ops = {
|
||||||
linux_store_registers,
|
linux_store_registers,
|
||||||
linux_read_memory,
|
linux_read_memory,
|
||||||
linux_write_memory,
|
linux_write_memory,
|
||||||
|
linux_look_up_symbols,
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -205,6 +205,23 @@ unhexify (char *bin, const char *hex, int count)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
decode_address (CORE_ADDR *addrp, const char *start, int len)
|
||||||
|
{
|
||||||
|
CORE_ADDR addr;
|
||||||
|
char ch;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
addr = 0;
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
ch = start[i];
|
||||||
|
addr = addr << 4;
|
||||||
|
addr = addr | (fromhex (ch) & 0x0f);
|
||||||
|
}
|
||||||
|
*addrp = addr;
|
||||||
|
}
|
||||||
|
|
||||||
/* Convert number NIB to a hex digit. */
|
/* Convert number NIB to a hex digit. */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -581,3 +598,42 @@ decode_M_packet (char *from, CORE_ADDR *mem_addr_ptr, unsigned int *len_ptr,
|
||||||
|
|
||||||
convert_ascii_to_int (&from[i++], to, *len_ptr);
|
convert_ascii_to_int (&from[i++], to, *len_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
look_up_one_symbol (const char *name, CORE_ADDR *addrp)
|
||||||
|
{
|
||||||
|
char own_buf[266], *p, *q;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
/* Send the request. */
|
||||||
|
strcpy (own_buf, "qSymbol:");
|
||||||
|
hexify (own_buf + strlen ("qSymbol:"), name, strlen (name));
|
||||||
|
if (putpkt (own_buf) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* FIXME: Eventually add buffer overflow checking (to getpkt?) */
|
||||||
|
len = getpkt (own_buf);
|
||||||
|
if (len < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (strncmp (own_buf, "qSymbol:", strlen ("qSymbol:")) != 0)
|
||||||
|
{
|
||||||
|
/* Malformed response. */
|
||||||
|
if (remote_debug)
|
||||||
|
fprintf (stderr, "Malformed response to qSymbol, ignoring.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = own_buf + strlen ("qSymbol:");
|
||||||
|
q = p;
|
||||||
|
while (*q && *q != ':')
|
||||||
|
q++;
|
||||||
|
|
||||||
|
/* Make sure we found a value for the symbol. */
|
||||||
|
if (p == q || *q == '\0')
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
decode_address (addrp, p, q - p);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,13 +63,9 @@ handle_query (char *own_buf)
|
||||||
{
|
{
|
||||||
if (strcmp ("qSymbol::", own_buf) == 0)
|
if (strcmp ("qSymbol::", own_buf) == 0)
|
||||||
{
|
{
|
||||||
#if 0
|
if (the_target->look_up_symbols != NULL)
|
||||||
strcpy (own_buf, "qSymbol:");
|
(*the_target->look_up_symbols) ();
|
||||||
hexify (own_buf + strlen ("qSymbol:"), "main", 4);
|
|
||||||
putpkt (own_buf);
|
|
||||||
getpkt (own_buf);
|
|
||||||
fprintf (stderr, "Got %s", own_buf);
|
|
||||||
#endif
|
|
||||||
strcpy (own_buf, "OK");
|
strcpy (own_buf, "OK");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,7 @@ void decode_M_packet (char *from, CORE_ADDR * mem_addr_ptr,
|
||||||
int unhexify (char *bin, const char *hex, int count);
|
int unhexify (char *bin, const char *hex, int count);
|
||||||
int hexify (char *hex, const char *bin, int count);
|
int hexify (char *hex, const char *bin, int count);
|
||||||
|
|
||||||
|
int look_up_one_symbol (const char *name, CORE_ADDR *addrp);
|
||||||
|
|
||||||
/* Functions from ``signals.c''. */
|
/* Functions from ``signals.c''. */
|
||||||
enum target_signal target_signal_from_host (int hostsig);
|
enum target_signal target_signal_from_host (int hostsig);
|
||||||
|
|
|
@ -94,6 +94,13 @@ struct target_ops
|
||||||
Returns 0 on success and errno on failure. */
|
Returns 0 on success and errno on failure. */
|
||||||
|
|
||||||
int (*write_memory) (CORE_ADDR memaddr, char *myaddr, int len);
|
int (*write_memory) (CORE_ADDR memaddr, char *myaddr, int len);
|
||||||
|
|
||||||
|
/* Query GDB for the values of any symbols we're interested in.
|
||||||
|
This function is called whenever we receive a "qSymbols::"
|
||||||
|
query, which corresponds to every time more symbols (might)
|
||||||
|
become available. */
|
||||||
|
|
||||||
|
void (*look_up_symbols) (void);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct target_ops *the_target;
|
extern struct target_ops *the_target;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue