This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 8/9] impl of use_agent and can_use_agent in linux-nat.


On 02/24/2012 06:11 AM, Pedro Alves wrote:
>> > +
>> > +  t->to_use_agent = linux_child_use_agent;
>> > +  t->to_can_use_agent = linux_child_can_use_agent;
>> >  }
> Are these ever going to be different on other native targets?  We could
> put them in inf-child.c instead, to get them all covered at once.
> 

No, they are the same on other native targets.  New target_ops hooks
functions are moved to inf-child.c.

>> > @@ -925,7 +926,10 @@ solib_add (char *pattern, int from_tty,
>> >  	}
>> >  
>> >      if (loaded_any_symbols)
>> > -      breakpoint_re_set ();
>> > +      {
>> > +	breakpoint_re_set ();
>> > +	agent_look_up_symbols ();
> The right place to do this is in a new new_objfile observer.
> 

Done.  Note that, in new_objfile observer, I pass OBJFILE to
agent_look_up_symbols as one parameter, so patch 1/9 will be updated.

-- 
Yao (éå)
2012-02-23  Yao Qi  <yao@codesourcery.com>

	* 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 <sys/param.h>		/* 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]