diff options
Diffstat (limited to 'gdb/thread-db.c')
-rw-r--r-- | gdb/thread-db.c | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/gdb/thread-db.c b/gdb/thread-db.c index efd0d33..b135c39 100644 --- a/gdb/thread-db.c +++ b/gdb/thread-db.c @@ -240,7 +240,7 @@ thread_db_state_str (td_thr_state_e state) } /* A callback function for td_ta_thr_iter, which we use to map all - threads to LWPs. + threads to LWPs. THP is a handle to the current thread; if INFOP is not NULL, the struct thread_info associated with this thread is returned in @@ -465,6 +465,26 @@ thread_db_load (void) return 1; } +static td_err_e +enable_thread_event (td_thragent_t *thread_agent, int event, CORE_ADDR *bp) +{ + td_notify_t notify; + td_err_e err; + + /* Get the breakpoint address for thread EVENT. */ + err = td_ta_event_addr_p (thread_agent, event, ¬ify); + if (err != TD_OK) + return err; + + /* Set up the breakpoint. */ + (*bp) = gdbarch_convert_from_func_ptr_addr (current_gdbarch, + (CORE_ADDR) notify.u.bptaddr, + ¤t_target); + create_thread_event_breakpoint ((*bp)); + + return TD_OK; +} + static void enable_thread_event_reporting (void) { @@ -498,9 +518,11 @@ enable_thread_event_reporting (void) /* Delete previous thread event breakpoints, if any. */ remove_thread_event_breakpoints (); + td_create_bp_addr = 0; + td_death_bp_addr = 0; - /* Get address for thread creation breakpoint. */ - err = td_ta_event_addr_p (thread_agent, TD_CREATE, ¬ify); + /* Set up the thread creation event. */ + err = enable_thread_event (thread_agent, TD_CREATE, &td_create_bp_addr); if (err != TD_OK) { warning ("Unable to get location for thread creation breakpoint: %s", @@ -508,22 +530,14 @@ enable_thread_event_reporting (void) return; } - /* Set up the breakpoint. */ - td_create_bp_addr = (CORE_ADDR) notify.u.bptaddr; - create_thread_event_breakpoint (td_create_bp_addr); - - /* Get address for thread death breakpoint. */ - err = td_ta_event_addr_p (thread_agent, TD_DEATH, ¬ify); + /* Set up the thread death event. */ + err = enable_thread_event (thread_agent, TD_DEATH, &td_death_bp_addr); if (err != TD_OK) { warning ("Unable to get location for thread death breakpoint: %s", thread_db_err_str (err)); return; } - - /* Set up the breakpoint. */ - td_death_bp_addr = (CORE_ADDR) notify.u.bptaddr; - create_thread_event_breakpoint (td_death_bp_addr); } static void @@ -821,10 +835,10 @@ check_event (ptid_t ptid) was created and cannot specifically locate the event message for it. We have to call td_ta_event_getmsg() to get the latest message. Since we have no way of correlating whether - the event message we get back corresponds to our breakpoint, we must + the event message we get back corresponds to our breakpoint, we must loop and read all event messages, processing them appropriately. - This guarantees we will process the correct message before continuing - from the breakpoint. + This guarantees we will process the correct message before continuing + from the breakpoint. Currently, death events are not enabled. If they are enabled, the death event can use the td_thr_event_getmsg() interface to |