summaryrefslogtreecommitdiff
path: root/gdb/gdbserver/remote-utils.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <dan@debian.org>2004-10-16 17:42:00 +0000
committerDaniel Jacobowitz <dan@debian.org>2004-10-16 17:42:00 +0000
commitbb0816c9930c5320030569b54f763ca58c80ef07 (patch)
tree0c18ab99fd24cef8b6f475ae80484cdc502c3520 /gdb/gdbserver/remote-utils.c
parent5236a8d8aeb0d9de4aa78d5487be625e4a419741 (diff)
downloadgdb-bb0816c9930c5320030569b54f763ca58c80ef07.tar.gz
* linux-i386-low.c (ps_get_thread_area): New.
* linux-x86-64-low.c (ps_get_thread_area): New. * linux-low.c: Include <sys/syscall.h>. (linux_kill_one_process): Don't kill the first thread here. (linux_kill): Kill the first thread here. (kill_lwp): New function. (send_sigstop, linux_send_signal): Use it. * proc-service.c: Clean up #ifdefs. (fpregset_info): Delete. (ps_lgetregs): Update and enable implementation. (ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Remove disabled implementations. * remote-utils.c (struct sym_cache, symbol_cache): New. (input_interrupt): Print a clearer message. (async_io_enabled): New variable. (enable_async_io, disable_async_io): Use it. Update comments. (look_up_one_symbol): Use the symbol cache. * thread-db.c (thread_db_look_up_symbols): New function. (thread_db_init): Update comments. Call thread_db_look_up_symbols.
Diffstat (limited to 'gdb/gdbserver/remote-utils.c')
-rw-r--r--gdb/gdbserver/remote-utils.c54
1 files changed, 51 insertions, 3 deletions
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 26b267a3aaf..0d2bdef06a0 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -37,6 +37,17 @@
#include <unistd.h>
#include <arpa/inet.h>
+/* A cache entry for a successfully looked-up symbol. */
+struct sym_cache
+{
+ const char *name;
+ CORE_ADDR addr;
+ struct sym_cache *next;
+};
+
+/* The symbol cache. */
+static struct sym_cache *symbol_cache;
+
int remote_debug = 0;
struct ui_file *gdb_stdlog;
@@ -353,13 +364,14 @@ input_interrupt (int unused)
if (select (remote_desc + 1, &readset, 0, 0, &immediate) > 0)
{
int cc;
- char c;
+ char c = 0;
cc = read (remote_desc, &c, 1);
if (cc != 1 || c != '\003')
{
- fprintf (stderr, "input_interrupt, cc = %d c = %d\n", cc, c);
+ fprintf (stderr, "input_interrupt, count = %d c = %d ('%c')\n",
+ cc, c, c);
return;
}
@@ -385,16 +397,33 @@ unblock_async_io (void)
sigprocmask (SIG_UNBLOCK, &sigio_set, NULL);
}
+/* Asynchronous I/O support. SIGIO must be enabled when waiting, in order to
+ accept Control-C from the client, and must be disabled when talking to
+ the client. */
+
+/* Current state of asynchronous I/O. */
+static int async_io_enabled;
+
+/* Enable asynchronous I/O. */
void
enable_async_io (void)
{
+ if (async_io_enabled)
+ return;
+
signal (SIGIO, input_interrupt);
+ async_io_enabled = 1;
}
+/* Disable asynchronous I/O. */
void
disable_async_io (void)
{
+ if (!async_io_enabled)
+ return;
+
signal (SIGIO, SIG_IGN);
+ async_io_enabled = 0;
}
/* Returns next char from remote GDB. -1 if error. */
@@ -692,11 +721,23 @@ decode_M_packet (char *from, CORE_ADDR *mem_addr_ptr, unsigned int *len_ptr,
convert_ascii_to_int (&from[i++], to, *len_ptr);
}
+/* Ask GDB for the address of NAME, and return it in ADDRP if found.
+ Returns 1 if the symbol is found, 0 if it is not, -1 on error. */
+
int
look_up_one_symbol (const char *name, CORE_ADDR *addrp)
{
char own_buf[266], *p, *q;
int len;
+ struct sym_cache *sym;
+
+ /* Check the cache first. */
+ for (sym = symbol_cache; sym; sym = sym->next)
+ if (strcmp (name, sym->name) == 0)
+ {
+ *addrp = sym->addr;
+ return 1;
+ }
/* Send the request. */
strcpy (own_buf, "qSymbol:");
@@ -731,6 +772,13 @@ look_up_one_symbol (const char *name, CORE_ADDR *addrp)
return 0;
decode_address (addrp, p, q - p);
+
+ /* Save the symbol in our cache. */
+ sym = malloc (sizeof (*sym));
+ sym->name = strdup (name);
+ sym->addr = *addrp;
+ sym->next = symbol_cache;
+ symbol_cache = sym;
+
return 1;
}
-