Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFC: proc-service -vs- multi-inferior
@ 2012-03-06 18:37 Tom Tromey
  2012-03-06 19:17 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2012-03-06 18:37 UTC (permalink / raw)
  To: gdb-patches

I'd appreciate comments on this patch.

I have been trying multi-inferior debugging quite a bit lately.
I've noticed this message a few times from gdb:

    Cannot find new threads: capability not available

Today I tracked this down.

The problem is that we can end up in thread_db_find_new_threads_2 with a
PTID argument that is not the same as current_inferior.  Then,
libthread_db calls our ps_pglobal_lookup, which tries to look up a
symbol against the wrong inferior.

This fixes the problem by setting the current program space before
calling lookup_minimal_symbol.

I have no idea how to construct a test case for this.  I could reproduce
it reasonably reliably by 'gdb /bin/sh', putting gdb into multi-inferior
mode, and then running dejagnu on part of our test suite.

Tom

2012-03-06  Tom Tromey  <tromey@redhat.com>

	* proc-service.c (ps_pglobal_lookup): Set the current program
	space.

diff --git a/gdb/proc-service.c b/gdb/proc-service.c
index e317414..a1f90a8 100644
--- a/gdb/proc-service.c
+++ b/gdb/proc-service.c
@@ -201,14 +201,24 @@ ps_pglobal_lookup (gdb_ps_prochandle_t ph, const char *obj,
 		   const char *name, psaddr_t *sym_addr)
 {
   struct minimal_symbol *ms;
+  struct cleanup *old_chain = save_current_program_space ();
+  struct inferior *inf = find_inferior_pid (ptid_get_pid (ph->ptid));
+  ps_err_e result;
+
+  set_current_program_space (inf->pspace);
 
   /* FIXME: kettenis/2000-09-03: What should we do with OBJ?  */
   ms = lookup_minimal_symbol (name, NULL, NULL);
   if (ms == NULL)
-    return PS_NOSYM;
+    result = PS_NOSYM;
+  else
+    {
+      *sym_addr = core_addr_to_ps_addr (SYMBOL_VALUE_ADDRESS (ms));
+      result = PS_OK;
+    }
 
-  *sym_addr = core_addr_to_ps_addr (SYMBOL_VALUE_ADDRESS (ms));
-  return PS_OK;
+  do_cleanups (old_chain);
+  return result;
 }
 
 /* Read SIZE bytes from the target process PH at address ADDR and copy


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RFC: proc-service -vs- multi-inferior
  2012-03-06 18:37 RFC: proc-service -vs- multi-inferior Tom Tromey
@ 2012-03-06 19:17 ` Pedro Alves
  2012-03-06 19:51   ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2012-03-06 19:17 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 03/06/2012 06:36 PM, Tom Tromey wrote:

> 2012-03-06  Tom Tromey  <tromey@redhat.com>
> 
> 	* proc-service.c (ps_pglobal_lookup): Set the current program
> 	space.


Looks good to me.  Might have been good to use
save_current_program_space/do_cleanups, but I don't know when can
minimal symbol lookup throw.

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RFC: proc-service -vs- multi-inferior
  2012-03-06 19:17 ` Pedro Alves
@ 2012-03-06 19:51   ` Tom Tromey
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2012-03-06 19:51 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> On 03/06/2012 06:36 PM, Tom Tromey wrote:
>> 2012-03-06  Tom Tromey  <tromey@redhat.com>
>> 
>> * proc-service.c (ps_pglobal_lookup): Set the current program
>> space.

Pedro> Looks good to me.

Thanks.  I'm going to check it in.

Tom


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-06 19:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-06 18:37 RFC: proc-service -vs- multi-inferior Tom Tromey
2012-03-06 19:17 ` Pedro Alves
2012-03-06 19:51   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox