2012-02-23 Yao Qi * inf-child.c (inf_child_use_agent): New. (inf_child_can_use_agent): New. (inf_child_target): Initialize fields `to_use_agent' and `to_can_use_agent'. * agent.c (agent_new_objfile): New. (_initialize_agent): Add agent_new_objfile to new_objfile observer. --- gdb/agent.c | 14 ++++++++++++++ gdb/inf-child.c | 20 ++++++++++++++++++++ 2 files changed, 34 insertions(+), 0 deletions(-) diff --git a/gdb/agent.c b/gdb/agent.c index c10ed89..bd537ea 100644 --- a/gdb/agent.c +++ b/gdb/agent.c @@ -51,9 +51,23 @@ set_can_use_agent (char *args, int from_tty, struct cmd_list_element *c) can_use_agent = can_use_agent_off; } +#include "observer.h" +#include "objfiles.h" + +static void +agent_new_objfile (struct objfile *objfile) +{ + if (objfile == NULL || agent_loaded_p ()) + return; + + agent_look_up_symbols (objfile); +} + void _initialize_agent (void) { + observer_attach_new_objfile (agent_new_objfile); + add_setshow_enum_cmd ("agent", class_run, can_use_agent_enum, &can_use_agent, _("\ diff --git a/gdb/inf-child.c b/gdb/inf-child.c index 96c1157..5531102 100644 --- a/gdb/inf-child.c +++ b/gdb/inf-child.c @@ -29,6 +29,7 @@ #include "gdb_stat.h" #include "inf-child.h" #include "gdb/fileio.h" +#include "agent.h" #ifdef HAVE_SYS_PARAM_H #include /* for MAXPATHLEN */ @@ -332,6 +333,23 @@ inf_child_fileio_readlink (const char *filename, int *target_errno) #endif } +static int +inf_child_use_agent (int use) +{ + if (agent_loaded_p ()) + { + use_agent = use; + return 1; + } + else + return 0; +} + +static int +inf_child_can_use_agent (void) +{ + return agent_loaded_p (); +} struct target_ops * inf_child_target (void) @@ -371,5 +389,7 @@ inf_child_target (void) t->to_fileio_unlink = inf_child_fileio_unlink; t->to_fileio_readlink = inf_child_fileio_readlink; t->to_magic = OPS_MAGIC; + t->to_use_agent = inf_child_use_agent; + t->to_can_use_agent = inf_child_can_use_agent; return t; } -- 1.7.0.4