Inform about new thread in a single place.

* thread.c (add_thread_silent): Renamed
        from add_thread.
        (print_thread_events): New variable definition.
        (show_print_thread_events): New function.
        (_initialize_thread): Add "set print thread-events" and
        "show print thread-events" commands.
        (add_thread): Announce new thread.
        * gdbthread.h (add_thread_silent): Declare.
        (print_thread_events): New variable declaration.
        * inf-ttrace.c (inf_ttrace_wait): Don't
        inform about new thread, as add_thread is always
        called too, and will take care of that.
        * infrun.c (handle_inferior_event): Likewise.
        * procfs.c (procfs_wait): Likewise.
        * remote.c (remote_currthread): Likewise.
        * sol-thread.c (sol_thread_wait): Likewise.
        * win32-nat.c (get_win32_debug_event): Likewise.
        * linux-thread-db.c (attach_thread): Likewise.
        Remove the verbose parameter.
        (check_event): Make detach_thread be verbose
        only if print_thread_events is set.
        * linux-nat.c (lin_lwp_attach_lwp): Don't inform
        about new thread.  This is called only from
        linux-thread-db.c:attach_thread, which will take care.
        Remove the verbose parameter.
        * linux-nat.h (lin_lwp_attach_lwp): Adjust prototype.
This commit is contained in:
Vladimir Prus
2008-01-23 11:26:29 +00:00
parent 73f4030dfa
commit 93815fbfa5
19 changed files with 327 additions and 62 deletions

View File

@ -118,7 +118,7 @@ static CORE_ADDR td_death_bp_addr;
/* Prototypes for local functions. */
static void thread_db_find_new_threads (void);
static void attach_thread (ptid_t ptid, const td_thrhandle_t *th_p,
const td_thrinfo_t *ti_p, int verbose);
const td_thrinfo_t *ti_p);
static void detach_thread (ptid_t ptid, int verbose);
@ -279,7 +279,7 @@ thread_get_info_callback (const td_thrhandle_t *thp, void *infop)
if (thread_info == NULL)
{
/* New thread. Attach to it now (why wait?). */
attach_thread (thread_ptid, thp, &ti, 1);
attach_thread (thread_ptid, thp, &ti);
thread_info = find_thread_pid (thread_ptid);
gdb_assert (thread_info != NULL);
}
@ -670,7 +670,7 @@ thread_db_new_objfile (struct objfile *objfile)
static void
attach_thread (ptid_t ptid, const td_thrhandle_t *th_p,
const td_thrinfo_t *ti_p, int verbose)
const td_thrinfo_t *ti_p)
{
struct thread_info *tp;
td_err_e err;
@ -702,7 +702,7 @@ attach_thread (ptid_t ptid, const td_thrhandle_t *th_p,
return; /* A zombie thread -- do not attach. */
/* Under GNU/Linux, we have to attach to each and every thread. */
if (lin_lwp_attach_lwp (BUILD_LWP (ti_p->ti_lid, GET_PID (ptid)), 0) < 0)
if (lin_lwp_attach_lwp (BUILD_LWP (ti_p->ti_lid, GET_PID (ptid))) < 0)
return;
/* Add the thread to GDB's thread list. */
@ -710,9 +710,6 @@ attach_thread (ptid_t ptid, const td_thrhandle_t *th_p,
tp->private = xmalloc (sizeof (struct private_thread_info));
memset (tp->private, 0, sizeof (struct private_thread_info));
if (verbose)
printf_unfiltered (_("[New %s]\n"), target_pid_to_str (ptid));
/* Enable thread event reporting for this thread. */
err = td_thr_event_enable_p (th_p, 1);
if (err != TD_OK)
@ -843,7 +840,7 @@ check_event (ptid_t ptid)
case TD_CREATE:
/* Call attach_thread whether or not we already know about a
thread with this thread ID. */
attach_thread (ptid, msg.th_p, &ti, 1);
attach_thread (ptid, msg.th_p, &ti);
break;
@ -852,7 +849,7 @@ check_event (ptid_t ptid)
if (!in_thread_list (ptid))
error (_("Spurious thread death event."));
detach_thread (ptid, 1);
detach_thread (ptid, print_thread_events);
break;
@ -976,7 +973,7 @@ find_new_threads_callback (const td_thrhandle_t *th_p, void *data)
}
if (!in_thread_list (ptid))
attach_thread (ptid, th_p, &ti, 1);
attach_thread (ptid, th_p, &ti);
return 0;
}