From 24557e30a905d2e99e17c70c7b80634a22a8da90 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Tue, 25 Nov 2003 23:31:40 +0000 Subject: [PATCH] 2003-11-25 Andrew Cagney * thread-db.c (enable_thread_event): New function. Ensure that BP is a code address. (enable_thread_event_reporting): Use enable_thread_event. --- gdb/ChangeLog | 6 ++++++ gdb/thread-db.c | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4356b148a43..402c5cae3cc 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2003-11-25 Andrew Cagney + + * thread-db.c (enable_thread_event): New function. Ensure that BP + is a code address. + (enable_thread_event_reporting): Use enable_thread_event. + 2003-11-25 Michael Snyder * mips-tdep.c (mips_o64_extract_return_value): Correct for diff --git a/gdb/thread-db.c b/gdb/thread-db.c index efd0d33b45f..d1fb4528173 100644 --- a/gdb/thread-db.c +++ b/gdb/thread-db.c @@ -465,6 +465,26 @@ thread_db_load (void) return 1; } +static int +enable_thread_event (td_thragent_t *thread_agent, int event, CORE_ADDR *bp) +{ + td_notify_t notify; + int err; + + /* Get the breakpoint address for thread EVENT. */ + err = td_ta_event_addr_p (thread_agent, event, ¬ify); + if (err != TD_OK) + return 0; + + /* 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 1; +} + static void enable_thread_event_reporting (void) { @@ -498,32 +518,24 @@ 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); - if (err != TD_OK) + /* Set up the thread creation event. */ + if (!enable_thread_event (thread_agent, TD_CREATE, &td_create_bp_addr)) { warning ("Unable to get location for thread creation breakpoint: %s", thread_db_err_str (err)); 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); - if (err != TD_OK) + /* Set up the thread death event. */ + if (!enable_thread_event (thread_agent, TD_DEATH, &td_death_bp_addr)) { 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 -- 2.30.2