This is the mail archive of the gdb@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]

corelow and threads question


Hello,

Since: http://sourceware.org/ml/gdb-patches/2009-06/msg00101.html diverged from original intention, I would like to ask a question regarding core_ops and possible solution to my problem.

Right now, we are treating core_ops somewhat specially since we add threads before calling target_find_new_threads in core_open; but why don't we let target_find_new_threads add the threads instead of adding them in core_open?

Wouldn't that actually be the right solution?

(attached is diff for corelow.c that illustrates what I am talking about).



With corelow.c patched as proposed, on Neutrino I could do this:

For NTO, I "hijack" core_ops:
static void
init_nto_core_ops ()
{
  struct target_ops *core_ops;

core_ops = find_core_target ();
gdb_assert (core_ops && core_ops->to_shortname != NULL
&& !!"core_ops must be initialized first!");
original_core_ops = *core_ops;
core_ops->to_extra_thread_info = nto_target_extra_thread_info;
core_ops->to_open = nto_core_open;
core_ops->to_xfer_partial = nto_core_xfer_partial;
core_ops->to_pid_to_str = nto_pid_to_str;
}


I can provide to_find_new_threads there:

static void
nto_find_new_threads_in_core (void)
{
if (core_bfd)
bfd_map_over_sections (core_bfd, nto_core_add_thread_private_data, NULL);
}


where I add_thread and also add thread private data. All works well.


Thoughts?


--
Aleksandar Ristovski
QNX Software Systems
Index: gdb/corelow.c
===================================================================
RCS file: /cvs/src/src/gdb/corelow.c,v
retrieving revision 1.86
diff -u -p -r1.86 corelow.c
--- gdb/corelow.c	5 Jun 2009 18:08:53 -0000	1.86
+++ gdb/corelow.c	5 Jun 2009 18:51:03 -0000
@@ -395,12 +395,6 @@ core_open (char *filename, int from_tty)
      previous session, and the frame cache being stale.  */
   registers_changed ();
 
-  /* Build up thread list from BFD sections, and possibly set the
-     current thread to the .reg/NN section matching the .reg
-     section. */
-  bfd_map_over_sections (core_bfd, add_to_thread_list,
-			 bfd_get_section_by_name (core_bfd, ".reg"));
-
   post_create_inferior (&core_ops, from_tty);
 
   /* Now go through the target stack looking for threads since there
@@ -748,6 +742,13 @@ core_pid_to_str (struct target_ops *ops,
   return buf;
 }
 
+static void
+core_find_new_threads (struct target_ops *ops)
+{
+  if (core_bfd)
+    bfd_map_over_sections (core_bfd, add_to_thread_list, NULL);
+}
+
 /* Fill in core_ops with its defined operations and properties.  */
 
 static void
@@ -775,6 +776,7 @@ init_core_ops (void)
   core_ops.to_has_stack = 1;
   core_ops.to_has_registers = 1;
   core_ops.to_magic = OPS_MAGIC;
+  core_ops.to_find_new_threads = core_find_new_threads;
 }
 
 void

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