* target.h (struct target_ops) <to_has_execution>: Add ptid_t

parameter.
	(target_has_execution_1): Update.
	(target_has_execution_current): Declare.
	(target_has_execution): Call target_has_execution_current.
	(default_child_has_execution): Update.
	* target.c (default_child_has_execution): Add 'the_ptid'
	parameter.
	(target_has_execution_1): Likewise.
	(target_has_execution_current): New function.
	(add_target): Update.
	(init_dummy_target): Update.
	* remote-m32r-sdi.c (m32r_has_execution): New function.
	(init_m32r_ops): Use it.
	* record.c (record_core_has_execution): Now static.  Add
	'the_ptid' parameter.
	* inferior.c (have_live_inferiors): Don't save current thread.
	Use target_has_execution_1.
This commit is contained in:
Tom Tromey
2011-03-07 15:58:13 +00:00
parent 08e1408309
commit aeaec16283
6 changed files with 57 additions and 25 deletions

View File

@ -1,3 +1,24 @@
2011-03-07 Tom Tromey <tromey@redhat.com>
* target.h (struct target_ops) <to_has_execution>: Add ptid_t
parameter.
(target_has_execution_1): Update.
(target_has_execution_current): Declare.
(target_has_execution): Call target_has_execution_current.
(default_child_has_execution): Update.
* target.c (default_child_has_execution): Add 'the_ptid'
parameter.
(target_has_execution_1): Likewise.
(target_has_execution_current): New function.
(add_target): Update.
(init_dummy_target): Update.
* remote-m32r-sdi.c (m32r_has_execution): New function.
(init_m32r_ops): Use it.
* record.c (record_core_has_execution): Now static. Add
'the_ptid' parameter.
* inferior.c (have_live_inferiors): Don't save current thread.
Use target_has_execution_1.
2011-03-07 Yao Qi <yao@codesourcery.com> 2011-03-07 Yao Qi <yao@codesourcery.com>
* Makefile.in (aclocal_m4_deps): Remove gnulib/m4/memcmp.m4. * Makefile.in (aclocal_m4_deps): Remove gnulib/m4/memcmp.m4.

View File

@ -462,28 +462,18 @@ have_inferiors (void)
int int
have_live_inferiors (void) have_live_inferiors (void)
{ {
struct cleanup *old_chain;
struct inferior *inf; struct inferior *inf;
old_chain = make_cleanup_restore_current_thread ();
for (inf = inferior_list; inf; inf = inf->next) for (inf = inferior_list; inf; inf = inf->next)
if (inf->pid != 0) if (inf->pid != 0)
{ {
struct thread_info *tp; struct thread_info *tp;
tp = any_thread_of_process (inf->pid); tp = any_thread_of_process (inf->pid);
if (tp) if (tp && target_has_execution_1 (tp->ptid))
{ break;
switch_to_thread (tp->ptid);
if (target_has_execution)
break;
}
} }
do_cleanups (old_chain);
return inf != NULL; return inf != NULL;
} }

View File

@ -1923,8 +1923,8 @@ record_core_remove_breakpoint (struct gdbarch *gdbarch,
/* "to_has_execution" method for prec over corefile. */ /* "to_has_execution" method for prec over corefile. */
int static int
record_core_has_execution (struct target_ops *ops) record_core_has_execution (struct target_ops *ops, ptid_t the_ptid)
{ {
return 1; return 1;
} }

View File

@ -1610,6 +1610,14 @@ m32r_return_one (struct target_ops *target)
return 1; return 1;
} }
/* Implementation of the to_has_execution method. */
static int
m32r_has_execution (struct target_ops *target, ptid_t the_ptid)
{
return 1;
}
/* Define the target subroutine names. */ /* Define the target subroutine names. */
struct target_ops m32r_ops; struct target_ops m32r_ops;
@ -1650,7 +1658,7 @@ init_m32r_ops (void)
m32r_ops.to_has_memory = m32r_return_one; m32r_ops.to_has_memory = m32r_return_one;
m32r_ops.to_has_stack = m32r_return_one; m32r_ops.to_has_stack = m32r_return_one;
m32r_ops.to_has_registers = m32r_return_one; m32r_ops.to_has_registers = m32r_return_one;
m32r_ops.to_has_execution = m32r_return_one; m32r_ops.to_has_execution = m32r_has_execution;
m32r_ops.to_magic = OPS_MAGIC; m32r_ops.to_magic = OPS_MAGIC;
}; };

View File

@ -314,11 +314,11 @@ default_child_has_registers (struct target_ops *ops)
} }
int int
default_child_has_execution (struct target_ops *ops) default_child_has_execution (struct target_ops *ops, ptid_t the_ptid)
{ {
/* If there's no thread selected, then we can't make it run through /* If there's no thread selected, then we can't make it run through
hoops. */ hoops. */
if (ptid_equal (inferior_ptid, null_ptid)) if (ptid_equal (the_ptid, null_ptid))
return 0; return 0;
return 1; return 1;
@ -374,17 +374,23 @@ target_has_registers_1 (void)
} }
int int
target_has_execution_1 (void) target_has_execution_1 (ptid_t the_ptid)
{ {
struct target_ops *t; struct target_ops *t;
for (t = current_target.beneath; t != NULL; t = t->beneath) for (t = current_target.beneath; t != NULL; t = t->beneath)
if (t->to_has_execution (t)) if (t->to_has_execution (t, the_ptid))
return 1; return 1;
return 0; return 0;
} }
int
target_has_execution_current (void)
{
return target_has_execution_1 (inferior_ptid);
}
/* Add a possible target architecture to the list. */ /* Add a possible target architecture to the list. */
void void
@ -407,7 +413,7 @@ add_target (struct target_ops *t)
t->to_has_registers = (int (*) (struct target_ops *)) return_zero; t->to_has_registers = (int (*) (struct target_ops *)) return_zero;
if (t->to_has_execution == NULL) if (t->to_has_execution == NULL)
t->to_has_execution = (int (*) (struct target_ops *)) return_zero; t->to_has_execution = (int (*) (struct target_ops *, ptid_t)) return_zero;
if (!target_structs) if (!target_structs)
{ {
@ -3218,7 +3224,8 @@ init_dummy_target (void)
dummy_target.to_has_memory = (int (*) (struct target_ops *)) return_zero; dummy_target.to_has_memory = (int (*) (struct target_ops *)) return_zero;
dummy_target.to_has_stack = (int (*) (struct target_ops *)) return_zero; dummy_target.to_has_stack = (int (*) (struct target_ops *)) return_zero;
dummy_target.to_has_registers = (int (*) (struct target_ops *)) return_zero; dummy_target.to_has_registers = (int (*) (struct target_ops *)) return_zero;
dummy_target.to_has_execution = (int (*) (struct target_ops *)) return_zero; dummy_target.to_has_execution
= (int (*) (struct target_ops *, ptid_t)) return_zero;
dummy_target.to_stopped_by_watchpoint = return_zero; dummy_target.to_stopped_by_watchpoint = return_zero;
dummy_target.to_stopped_data_address = dummy_target.to_stopped_data_address =
(int (*) (struct target_ops *, CORE_ADDR *)) return_zero; (int (*) (struct target_ops *, CORE_ADDR *)) return_zero;

View File

@ -510,7 +510,7 @@ struct target_ops
int (*to_has_memory) (struct target_ops *); int (*to_has_memory) (struct target_ops *);
int (*to_has_stack) (struct target_ops *); int (*to_has_stack) (struct target_ops *);
int (*to_has_registers) (struct target_ops *); int (*to_has_registers) (struct target_ops *);
int (*to_has_execution) (struct target_ops *); int (*to_has_execution) (struct target_ops *, ptid_t);
int to_has_thread_control; /* control thread execution */ int to_has_thread_control; /* control thread execution */
int to_attach_no_wait; int to_attach_no_wait;
/* ASYNC target controls */ /* ASYNC target controls */
@ -1189,8 +1189,13 @@ extern int target_has_registers_1 (void);
case this will become true after target_create_inferior or case this will become true after target_create_inferior or
target_attach. */ target_attach. */
extern int target_has_execution_1 (void); extern int target_has_execution_1 (ptid_t);
#define target_has_execution target_has_execution_1 ()
/* Like target_has_execution_1, but always passes inferior_ptid. */
extern int target_has_execution_current (void);
#define target_has_execution target_has_execution_current ()
/* Default implementations for process_stratum targets. Return true /* Default implementations for process_stratum targets. Return true
if there's a selected inferior, false otherwise. */ if there's a selected inferior, false otherwise. */
@ -1199,7 +1204,8 @@ extern int default_child_has_all_memory (struct target_ops *ops);
extern int default_child_has_memory (struct target_ops *ops); extern int default_child_has_memory (struct target_ops *ops);
extern int default_child_has_stack (struct target_ops *ops); extern int default_child_has_stack (struct target_ops *ops);
extern int default_child_has_registers (struct target_ops *ops); extern int default_child_has_registers (struct target_ops *ops);
extern int default_child_has_execution (struct target_ops *ops); extern int default_child_has_execution (struct target_ops *ops,
ptid_t the_ptid);
/* Can the target support the debugger control of thread execution? /* Can the target support the debugger control of thread execution?
Can it lock the thread scheduler? */ Can it lock the thread scheduler? */