1999-04-16 09:35:26 +08:00
|
|
|
/* Multi-process/thread control for GDB, the GNU debugger.
|
2002-01-18 06:15:18 +08:00
|
|
|
|
2007-01-10 01:59:20 +08:00
|
|
|
Copyright (C) 1986, 1987, 1988, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
2008-01-02 06:53:26 +08:00
|
|
|
2000, 2001, 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
|
2002-01-18 06:15:18 +08:00
|
|
|
|
2001-03-06 16:22:02 +08:00
|
|
|
Contributed by Lynx Real-Time Systems, Inc. Los Gatos, CA.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
This file is part of GDB.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-24 02:08:50 +08:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
1999-07-08 04:19:36 +08:00
|
|
|
(at your option) any later version.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-24 02:08:50 +08:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "symtab.h"
|
|
|
|
#include "frame.h"
|
|
|
|
#include "inferior.h"
|
|
|
|
#include "environ.h"
|
|
|
|
#include "value.h"
|
|
|
|
#include "target.h"
|
|
|
|
#include "gdbthread.h"
|
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (enum return_reason, RETURN_MASK)
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL)
(return_mask, throw_exception, catch_exceptions_ftype)
(catch_exceptions_with_msg, catch_errors_ftype, catch_errors)
(catch_command_errors_ftype, catch_command_errors): Move to
exceptions.h.
* exceptions.c, exceptions.h: New files.
* top.c: Do not include <setjmp.h>.
(SIGJMP_BUF, SIGSETJMP, SIGLONGJMP, catch_return)
(throw_exception, catcher, catch_exceptions)
(catch_exceptions_with_msg, struct catch_errors_args)
(do_catch_errors, catch_errors, struct captured_command_args)
(do_captured_command, catch_command_errors): Move to exceptions.c.
* wrapper.c, wince.c, win32-nat.c, utils.c: Include "exceptions.h".
* tui/tui-interp.c, top.c, thread.c, symmisc.c: Ditto.
* symfile-mem.c, stack.c, solib.c, rs6000-nat.c: Ditto.
* remote-sds.c, remote-mips.c, remote-fileio.c: Ditto.
* remote-e7000.c, objc-lang.c, ocd.c: Ditto.
* remote.c, nto-procfs.c, monitor.c, mi/mi-main.c: Ditto.
* main.c, m32r-rom.c, infrun.c, inf-loop.c: Ditto.
* hppa-hpux-tdep.c, frame.c, event-top.c, event-loop.c: Ditto.
* corelow.c, corefile.c, cli/cli-interp.c, breakpoint.c: Ditto.
* ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (HFILES_NO_SRCDIR, COMMON_OBS): Add exceptions.h and
exceptions.o. Update all dependencies.
2005-01-13 02:31:35 +08:00
|
|
|
#include "exceptions.h"
|
1999-04-16 09:35:26 +08:00
|
|
|
#include "command.h"
|
|
|
|
#include "gdbcmd.h"
|
2001-03-01 09:39:22 +08:00
|
|
|
#include "regcache.h"
|
2001-07-29 03:48:15 +08:00
|
|
|
#include "gdb.h"
|
2002-08-03 04:51:21 +08:00
|
|
|
#include "gdb_string.h"
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <signal.h>
|
2000-02-03 12:14:45 +08:00
|
|
|
#include "ui-out.h"
|
2008-03-15 01:21:08 +08:00
|
|
|
#include "observer.h"
|
2008-05-21 05:05:07 +08:00
|
|
|
#include "annotate.h"
|
1999-04-16 09:35:26 +08:00
|
|
|
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
#include "cli/cli-decode.h"
|
|
|
|
|
2000-01-11 11:07:37 +08:00
|
|
|
/* Definition of struct thread_info exported to gdbthread.h */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
/* Prototypes for exported functions. */
|
|
|
|
|
2000-05-28 09:12:42 +08:00
|
|
|
void _initialize_thread (void);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
/* Prototypes for local functions. */
|
|
|
|
|
|
|
|
static struct thread_info *thread_list = NULL;
|
|
|
|
static int highest_thread_num;
|
|
|
|
|
2000-05-28 09:12:42 +08:00
|
|
|
static struct thread_info *find_thread_id (int num);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2000-05-28 09:12:42 +08:00
|
|
|
static void thread_command (char *tidstr, int from_tty);
|
|
|
|
static void thread_apply_all_command (char *, int);
|
|
|
|
static int thread_alive (struct thread_info *);
|
|
|
|
static void info_threads_command (char *, int);
|
|
|
|
static void thread_apply_command (char *, int);
|
2001-05-04 12:15:33 +08:00
|
|
|
static void restore_current_thread (ptid_t);
|
2000-05-28 09:12:42 +08:00
|
|
|
static void prune_threads (void);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2008-07-10 06:16:15 +08:00
|
|
|
static int main_thread_running = 0;
|
|
|
|
static int main_thread_executing = 0;
|
|
|
|
|
2001-06-02 08:36:20 +08:00
|
|
|
void
|
|
|
|
delete_step_resume_breakpoint (void *arg)
|
|
|
|
{
|
|
|
|
struct breakpoint **breakpointp = (struct breakpoint **) arg;
|
|
|
|
struct thread_info *tp;
|
|
|
|
|
|
|
|
if (*breakpointp != NULL)
|
|
|
|
{
|
|
|
|
delete_breakpoint (*breakpointp);
|
|
|
|
for (tp = thread_list; tp; tp = tp->next)
|
|
|
|
if (tp->step_resume_breakpoint == *breakpointp)
|
|
|
|
tp->step_resume_breakpoint = NULL;
|
|
|
|
|
|
|
|
*breakpointp = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-07-20 05:03:06 +08:00
|
|
|
static void
|
|
|
|
free_thread (struct thread_info *tp)
|
|
|
|
{
|
|
|
|
/* NOTE: this will take care of any left-over step_resume breakpoints,
|
2007-09-11 05:27:23 +08:00
|
|
|
but not any user-specified thread-specific breakpoints. We can not
|
|
|
|
delete the breakpoint straight-off, because the inferior might not
|
|
|
|
be stopped at the moment. */
|
2000-07-20 05:03:06 +08:00
|
|
|
if (tp->step_resume_breakpoint)
|
2007-09-11 05:27:23 +08:00
|
|
|
tp->step_resume_breakpoint->disposition = disp_del_at_next_stop;
|
2000-07-20 05:03:06 +08:00
|
|
|
|
Per-thread commands.
* gdbthread.h: Remove unneeded forward declarations.
Include "inferior.h".
(struct thread_info): Add continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi and stop_signal members.
(save_infrun_state): Add continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat parameters.
(load_infrun_state): Add continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat parameters.
* thread.c (load_infrun_state): In non-stop mode, load
continuations, intermediate_continuations, proceed_to_finish,
step_over_calls, stop_step, step_multi and stop_signal.
(save_infrun_state): Store continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat.
(save_infrun_state): Store continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat.
(free_thread): Clear The thread's stop_bpstat.
* inferior.h (context_switch_to): Declare.
* infrun.c (ecss): New global.
(context_switch): Context switch continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat.
(wait_for_inferior): Use global ecss.
(async_ecss, async_ecs): Delete.
(fetch_inferior_event): Use global ecss.
(context_switch_to): New.
* top.c (execute_command): In non-stop, only check if the current
thread is running, in all-stop, check if there's any thread
running.
* breakpoint.c (bpstat_remove_breakpoint): New.
(bpstat_remove_breakpoint_callback): New.
(delete_breakpoint): Clear the stop_bpstats of all threads.
* mi/mi-main.c (mi_cmd_execute): In non-stop, only check if the
current thread is running, in all-stop, check if there's any
thread running.
* Makefile.in (gdbthread_h): Depend on $(inferior_h).
2008-07-10 06:30:46 +08:00
|
|
|
bpstat_clear (&tp->stop_bpstat);
|
|
|
|
|
2000-07-20 05:03:06 +08:00
|
|
|
/* FIXME: do I ever need to call the back-end to give it a
|
|
|
|
chance at this private data before deleting the thread? */
|
|
|
|
if (tp->private)
|
2000-12-15 09:01:51 +08:00
|
|
|
xfree (tp->private);
|
2000-07-20 05:03:06 +08:00
|
|
|
|
2000-12-15 09:01:51 +08:00
|
|
|
xfree (tp);
|
2000-07-20 05:03:06 +08:00
|
|
|
}
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
void
|
2000-07-30 09:48:28 +08:00
|
|
|
init_thread_list (void)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
struct thread_info *tp, *tpnext;
|
|
|
|
|
2000-07-20 05:03:06 +08:00
|
|
|
highest_thread_num = 0;
|
2008-07-10 06:16:15 +08:00
|
|
|
main_thread_running = 0;
|
|
|
|
main_thread_executing = 0;
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
if (!thread_list)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (tp = thread_list; tp; tp = tpnext)
|
|
|
|
{
|
|
|
|
tpnext = tp->next;
|
2000-07-20 05:03:06 +08:00
|
|
|
free_thread (tp);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
thread_list = NULL;
|
|
|
|
}
|
|
|
|
|
2000-01-11 11:07:37 +08:00
|
|
|
struct thread_info *
|
2008-01-23 19:26:29 +08:00
|
|
|
add_thread_silent (ptid_t ptid)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
|
|
|
|
2001-06-13 Michael Snyder <msnyder@redhat.com>
* gdbthread.h (struct thread_info): Add new fields:
current_line, current_symtab, step_sp, for saved infrun state.
* thread.c (save_infrun_state, load_infrun_state): Save and
restore current_line, current_symtab, and step_sp.
(add_thread): Rather than adding assignments to initialize
the new fields, just use memset (tp, 0, sizeof (*tp).
This way future new fields will not be overlooked.
* infrun.c (handle_inferior_event): Save and restore save_sp,
current_line, and current_symtab when switching threads.
2001-06-14 06:56:16 +08:00
|
|
|
tp = (struct thread_info *) xmalloc (sizeof (*tp));
|
|
|
|
memset (tp, 0, sizeof (*tp));
|
2001-05-04 12:15:33 +08:00
|
|
|
tp->ptid = ptid;
|
1999-04-16 09:35:26 +08:00
|
|
|
tp->num = ++highest_thread_num;
|
|
|
|
tp->next = thread_list;
|
|
|
|
thread_list = tp;
|
2008-05-01 22:27:39 +08:00
|
|
|
|
|
|
|
observer_notify_new_thread (tp);
|
|
|
|
|
2000-01-11 11:07:37 +08:00
|
|
|
return tp;
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
2008-01-23 19:26:29 +08:00
|
|
|
struct thread_info *
|
2008-03-21 Daniel Jacobowitz <dan@codesourcery.com>
* gdbthread.h (add_thread_with_info): New.
* linux-thread-db.c: Add some documentation.
(GET_LWP, GET_PID, GET_THREAD, is_lwp, is_thread, BUILD_LWP): Delete.
(struct private_thread_info): Remove th_valid and ti_valid.
Replace ti with tid.
(thread_get_info_callback): Do not add TID to the new ptid. Do
not cache th or ti.
(thread_db_map_id2thr, lwp_from_thread): Delete functions.
(thread_from_lwp): Assert that the LWP is set. Do not add TID to the
new PTID.
(attach_thread): Handle an already-existing thread. Use
add_thread_with_info. Cache the th and tid.
(detach_thread): Verify that private was set. Remove verbose
argument and printing. Update caller.
(thread_db_detach): Do not adjust inferior_ptid.
(clear_lwpid_callback, thread_db_resume, thread_db_kill): Delete.
(check_event, find_new_threads_callback): Do not add TID to the new PTID.
(thread_db_wait): Do not use lwp_from_thread.
(thread_db_pid_to_str): Use the cached TID.
(thread_db_extra_thread_info): Check that private is set.
(same_ptid_callback): Delete.
(thread_db_get_thread_local_address): Do not use it or check
is_thread. Check that private is set. Assume that the thread
handle is already cached.
(init_thread_db_ops): Remove to_resume and to_kill.
* thread.c (add_thread_with_info): New.
(add_thread): Use it.
* linux-nat.c (find_thread_from_lwp): Delete.
(exit_lwp): Do not use it. Check print_thread_events. Print before
deleting the thread.
(GET_PID, GET_LWP, BUILD_LWP, is_lwp): Move to...
* linux-nat.h (GET_PID, GET_LWP, BUILD_LWP, is_lwp): ...here.
* inf-ttrace.c (inf_ttrace_wait): Use print_thread_events and
printf_unfiltered for thread exits.
* procfs.c (procfs_wait): Likewise.
2008-03-21 Pedro Alves <pedro@codesourcery.com>
* gdb.threads/fork-child-threads.exp: Test next over fork.
2008-03-21 23:44:53 +08:00
|
|
|
add_thread_with_info (ptid_t ptid, struct private_thread_info *private)
|
2008-01-23 19:26:29 +08:00
|
|
|
{
|
|
|
|
struct thread_info *result = add_thread_silent (ptid);
|
|
|
|
|
2008-03-21 Daniel Jacobowitz <dan@codesourcery.com>
* gdbthread.h (add_thread_with_info): New.
* linux-thread-db.c: Add some documentation.
(GET_LWP, GET_PID, GET_THREAD, is_lwp, is_thread, BUILD_LWP): Delete.
(struct private_thread_info): Remove th_valid and ti_valid.
Replace ti with tid.
(thread_get_info_callback): Do not add TID to the new ptid. Do
not cache th or ti.
(thread_db_map_id2thr, lwp_from_thread): Delete functions.
(thread_from_lwp): Assert that the LWP is set. Do not add TID to the
new PTID.
(attach_thread): Handle an already-existing thread. Use
add_thread_with_info. Cache the th and tid.
(detach_thread): Verify that private was set. Remove verbose
argument and printing. Update caller.
(thread_db_detach): Do not adjust inferior_ptid.
(clear_lwpid_callback, thread_db_resume, thread_db_kill): Delete.
(check_event, find_new_threads_callback): Do not add TID to the new PTID.
(thread_db_wait): Do not use lwp_from_thread.
(thread_db_pid_to_str): Use the cached TID.
(thread_db_extra_thread_info): Check that private is set.
(same_ptid_callback): Delete.
(thread_db_get_thread_local_address): Do not use it or check
is_thread. Check that private is set. Assume that the thread
handle is already cached.
(init_thread_db_ops): Remove to_resume and to_kill.
* thread.c (add_thread_with_info): New.
(add_thread): Use it.
* linux-nat.c (find_thread_from_lwp): Delete.
(exit_lwp): Do not use it. Check print_thread_events. Print before
deleting the thread.
(GET_PID, GET_LWP, BUILD_LWP, is_lwp): Move to...
* linux-nat.h (GET_PID, GET_LWP, BUILD_LWP, is_lwp): ...here.
* inf-ttrace.c (inf_ttrace_wait): Use print_thread_events and
printf_unfiltered for thread exits.
* procfs.c (procfs_wait): Likewise.
2008-03-21 Pedro Alves <pedro@codesourcery.com>
* gdb.threads/fork-child-threads.exp: Test next over fork.
2008-03-21 23:44:53 +08:00
|
|
|
result->private = private;
|
|
|
|
|
2008-01-23 19:26:29 +08:00
|
|
|
if (print_thread_events)
|
2008-03-13 06:10:55 +08:00
|
|
|
printf_unfiltered (_("[New %s]\n"), target_pid_to_str (ptid));
|
2008-05-21 05:05:07 +08:00
|
|
|
|
|
|
|
annotate_new_thread ();
|
2008-01-23 19:26:29 +08:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2008-03-21 Daniel Jacobowitz <dan@codesourcery.com>
* gdbthread.h (add_thread_with_info): New.
* linux-thread-db.c: Add some documentation.
(GET_LWP, GET_PID, GET_THREAD, is_lwp, is_thread, BUILD_LWP): Delete.
(struct private_thread_info): Remove th_valid and ti_valid.
Replace ti with tid.
(thread_get_info_callback): Do not add TID to the new ptid. Do
not cache th or ti.
(thread_db_map_id2thr, lwp_from_thread): Delete functions.
(thread_from_lwp): Assert that the LWP is set. Do not add TID to the
new PTID.
(attach_thread): Handle an already-existing thread. Use
add_thread_with_info. Cache the th and tid.
(detach_thread): Verify that private was set. Remove verbose
argument and printing. Update caller.
(thread_db_detach): Do not adjust inferior_ptid.
(clear_lwpid_callback, thread_db_resume, thread_db_kill): Delete.
(check_event, find_new_threads_callback): Do not add TID to the new PTID.
(thread_db_wait): Do not use lwp_from_thread.
(thread_db_pid_to_str): Use the cached TID.
(thread_db_extra_thread_info): Check that private is set.
(same_ptid_callback): Delete.
(thread_db_get_thread_local_address): Do not use it or check
is_thread. Check that private is set. Assume that the thread
handle is already cached.
(init_thread_db_ops): Remove to_resume and to_kill.
* thread.c (add_thread_with_info): New.
(add_thread): Use it.
* linux-nat.c (find_thread_from_lwp): Delete.
(exit_lwp): Do not use it. Check print_thread_events. Print before
deleting the thread.
(GET_PID, GET_LWP, BUILD_LWP, is_lwp): Move to...
* linux-nat.h (GET_PID, GET_LWP, BUILD_LWP, is_lwp): ...here.
* inf-ttrace.c (inf_ttrace_wait): Use print_thread_events and
printf_unfiltered for thread exits.
* procfs.c (procfs_wait): Likewise.
2008-03-21 Pedro Alves <pedro@codesourcery.com>
* gdb.threads/fork-child-threads.exp: Test next over fork.
2008-03-21 23:44:53 +08:00
|
|
|
struct thread_info *
|
|
|
|
add_thread (ptid_t ptid)
|
|
|
|
{
|
|
|
|
return add_thread_with_info (ptid, NULL);
|
|
|
|
}
|
|
|
|
|
2008-07-09 18:58:41 +08:00
|
|
|
/* Delete thread PTID. If SILENT, don't notify the observer of this
|
|
|
|
exit. */
|
|
|
|
static void
|
|
|
|
delete_thread_1 (ptid_t ptid, int silent)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
struct thread_info *tp, *tpprev;
|
|
|
|
|
|
|
|
tpprev = NULL;
|
|
|
|
|
|
|
|
for (tp = thread_list; tp; tpprev = tp, tp = tp->next)
|
2001-05-04 12:15:33 +08:00
|
|
|
if (ptid_equal (tp->ptid, ptid))
|
1999-04-16 09:35:26 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (!tp)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (tpprev)
|
|
|
|
tpprev->next = tp->next;
|
|
|
|
else
|
|
|
|
thread_list = tp->next;
|
|
|
|
|
2008-07-09 18:58:41 +08:00
|
|
|
if (!silent)
|
|
|
|
observer_notify_thread_exit (tp);
|
2008-05-03 23:10:42 +08:00
|
|
|
|
2000-07-20 05:03:06 +08:00
|
|
|
free_thread (tp);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
2008-07-09 18:58:41 +08:00
|
|
|
void
|
|
|
|
delete_thread (ptid_t ptid)
|
|
|
|
{
|
|
|
|
delete_thread_1 (ptid, 0 /* not silent */);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
delete_thread_silent (ptid_t ptid)
|
|
|
|
{
|
|
|
|
delete_thread_1 (ptid, 1 /* silent */);
|
|
|
|
}
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
static struct thread_info *
|
2000-07-30 09:48:28 +08:00
|
|
|
find_thread_id (int num)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
|
|
|
|
|
|
|
for (tp = thread_list; tp; tp = tp->next)
|
|
|
|
if (tp->num == num)
|
|
|
|
return tp;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-05-04 12:15:33 +08:00
|
|
|
/* Find a thread_info by matching PTID. */
|
2000-01-11 11:07:37 +08:00
|
|
|
struct thread_info *
|
2001-05-04 12:15:33 +08:00
|
|
|
find_thread_pid (ptid_t ptid)
|
2000-01-11 11:07:37 +08:00
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
|
|
|
|
|
|
|
for (tp = thread_list; tp; tp = tp->next)
|
2001-05-04 12:15:33 +08:00
|
|
|
if (ptid_equal (tp->ptid, ptid))
|
2000-01-11 11:07:37 +08:00
|
|
|
return tp;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Thread iterator function.
|
|
|
|
*
|
|
|
|
* Calls a callback function once for each thread, so long as
|
|
|
|
* the callback function returns false. If the callback function
|
|
|
|
* returns true, the iteration will end and the current thread
|
|
|
|
* will be returned. This can be useful for implementing a
|
|
|
|
* search for a thread with arbitrary attributes, or for applying
|
|
|
|
* some operation to every thread.
|
|
|
|
*
|
|
|
|
* FIXME: some of the existing functionality, such as
|
|
|
|
* "Thread apply all", might be rewritten using this functionality.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct thread_info *
|
2000-10-29 06:15:09 +08:00
|
|
|
iterate_over_threads (int (*callback) (struct thread_info *, void *),
|
|
|
|
void *data)
|
2000-01-11 11:07:37 +08:00
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
|
|
|
|
|
|
|
for (tp = thread_list; tp; tp = tp->next)
|
|
|
|
if ((*callback) (tp, data))
|
|
|
|
return tp;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-06-28 17:42:15 +08:00
|
|
|
int
|
|
|
|
thread_count (void)
|
|
|
|
{
|
|
|
|
int result = 0;
|
|
|
|
struct thread_info *tp;
|
|
|
|
|
|
|
|
for (tp = thread_list; tp; tp = tp->next)
|
|
|
|
++result;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
int
|
2000-07-30 09:48:28 +08:00
|
|
|
valid_thread_id (int num)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
|
|
|
|
|
|
|
for (tp = thread_list; tp; tp = tp->next)
|
|
|
|
if (tp->num == num)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-05-04 12:15:33 +08:00
|
|
|
pid_to_thread_id (ptid_t ptid)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
|
|
|
|
|
|
|
for (tp = thread_list; tp; tp = tp->next)
|
2001-05-04 12:15:33 +08:00
|
|
|
if (ptid_equal (tp->ptid, ptid))
|
1999-04-16 09:35:26 +08:00
|
|
|
return tp->num;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-05-04 12:15:33 +08:00
|
|
|
ptid_t
|
2000-07-30 09:48:28 +08:00
|
|
|
thread_id_to_pid (int num)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
struct thread_info *thread = find_thread_id (num);
|
|
|
|
if (thread)
|
2001-05-04 12:15:33 +08:00
|
|
|
return thread->ptid;
|
1999-04-16 09:35:26 +08:00
|
|
|
else
|
2001-05-04 12:15:33 +08:00
|
|
|
return pid_to_ptid (-1);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-05-04 12:15:33 +08:00
|
|
|
in_thread_list (ptid_t ptid)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
|
|
|
|
|
|
|
for (tp = thread_list; tp; tp = tp->next)
|
2001-05-04 12:15:33 +08:00
|
|
|
if (ptid_equal (tp->ptid, ptid))
|
1999-04-16 09:35:26 +08:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0; /* Never heard of 'im */
|
|
|
|
}
|
2002-01-18 06:15:18 +08:00
|
|
|
|
2000-02-03 12:14:45 +08:00
|
|
|
/* Print a list of thread ids currently known, and the total number of
|
|
|
|
threads. To be used from within catch_errors. */
|
2003-03-29 05:42:41 +08:00
|
|
|
static int
|
|
|
|
do_captured_list_thread_ids (struct ui_out *uiout, void *arg)
|
2000-02-03 12:14:45 +08:00
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
|
|
|
int num = 0;
|
2003-02-02 Elena Zannoni <ezannoni@redhat.com>
Fix PR gdb/742 gdb/743
* disasm.c (dump_insns): Use make_cleanup_ui_out_tuple_begin_end.
(do_mixed_source_and_assembly): Use
make_cleanup_ui_out_tuple_begin_end and
make_cleanup_ui_out_tuple_begin_end.
(do_mixed_source_and_assembly): Ditto.
* thread.c (do_captured_list_thread_ids): Ditto.
* ui-out.h (ui_out_table_begin, ui_out_list_begin,
ui_out_tuple_begin, ui_out_table_end, ui_out_list_end,
ui_out_tuple_end): Delete prototypes.
* ui-out.c (ui_out_list_begin, ui_out_tuple_begin,
ui_out_list_end, ui_out_tuple_end): Delete.
From Kevin Buettner <kevinb@redhat.com>:
* ui-out.h (make_cleanup_ui_out_table_begin_end): New function.
* ui-out.c (make_cleanup_ui_out_table_begin_end)
(do_cleanup_table_end): New functions.
* breakpoint.c (print_it_typical, print_one_breakpoint, mention):
Use cleanups to invoke_ui_out_tuple_end().
(breakpoint_1): Use cleanup to invoke ui_out_table_end().
* cli/cli-setshow.c (cmd_show_list): Use
make_cleanup_ui_out_tuple_begin_end.
2003-02-03 09:18:37 +08:00
|
|
|
struct cleanup *cleanup_chain;
|
2000-02-03 12:14:45 +08:00
|
|
|
|
2002-12-20 11:37:33 +08:00
|
|
|
prune_threads ();
|
|
|
|
target_find_new_threads ();
|
|
|
|
|
2003-02-02 Elena Zannoni <ezannoni@redhat.com>
Fix PR gdb/742 gdb/743
* disasm.c (dump_insns): Use make_cleanup_ui_out_tuple_begin_end.
(do_mixed_source_and_assembly): Use
make_cleanup_ui_out_tuple_begin_end and
make_cleanup_ui_out_tuple_begin_end.
(do_mixed_source_and_assembly): Ditto.
* thread.c (do_captured_list_thread_ids): Ditto.
* ui-out.h (ui_out_table_begin, ui_out_list_begin,
ui_out_tuple_begin, ui_out_table_end, ui_out_list_end,
ui_out_tuple_end): Delete prototypes.
* ui-out.c (ui_out_list_begin, ui_out_tuple_begin,
ui_out_list_end, ui_out_tuple_end): Delete.
From Kevin Buettner <kevinb@redhat.com>:
* ui-out.h (make_cleanup_ui_out_table_begin_end): New function.
* ui-out.c (make_cleanup_ui_out_table_begin_end)
(do_cleanup_table_end): New functions.
* breakpoint.c (print_it_typical, print_one_breakpoint, mention):
Use cleanups to invoke_ui_out_tuple_end().
(breakpoint_1): Use cleanup to invoke ui_out_table_end().
* cli/cli-setshow.c (cmd_show_list): Use
make_cleanup_ui_out_tuple_begin_end.
2003-02-03 09:18:37 +08:00
|
|
|
cleanup_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "thread-ids");
|
2000-02-03 12:14:45 +08:00
|
|
|
|
|
|
|
for (tp = thread_list; tp; tp = tp->next)
|
|
|
|
{
|
|
|
|
num++;
|
|
|
|
ui_out_field_int (uiout, "thread-id", tp->num);
|
|
|
|
}
|
|
|
|
|
2003-02-02 Elena Zannoni <ezannoni@redhat.com>
Fix PR gdb/742 gdb/743
* disasm.c (dump_insns): Use make_cleanup_ui_out_tuple_begin_end.
(do_mixed_source_and_assembly): Use
make_cleanup_ui_out_tuple_begin_end and
make_cleanup_ui_out_tuple_begin_end.
(do_mixed_source_and_assembly): Ditto.
* thread.c (do_captured_list_thread_ids): Ditto.
* ui-out.h (ui_out_table_begin, ui_out_list_begin,
ui_out_tuple_begin, ui_out_table_end, ui_out_list_end,
ui_out_tuple_end): Delete prototypes.
* ui-out.c (ui_out_list_begin, ui_out_tuple_begin,
ui_out_list_end, ui_out_tuple_end): Delete.
From Kevin Buettner <kevinb@redhat.com>:
* ui-out.h (make_cleanup_ui_out_table_begin_end): New function.
* ui-out.c (make_cleanup_ui_out_table_begin_end)
(do_cleanup_table_end): New functions.
* breakpoint.c (print_it_typical, print_one_breakpoint, mention):
Use cleanups to invoke_ui_out_tuple_end().
(breakpoint_1): Use cleanup to invoke ui_out_table_end().
* cli/cli-setshow.c (cmd_show_list): Use
make_cleanup_ui_out_tuple_begin_end.
2003-02-03 09:18:37 +08:00
|
|
|
do_cleanups (cleanup_chain);
|
2000-02-03 12:14:45 +08:00
|
|
|
ui_out_field_int (uiout, "number-of-threads", num);
|
|
|
|
return GDB_RC_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Official gdblib interface function to get a list of thread ids and
|
|
|
|
the total number. */
|
|
|
|
enum gdb_rc
|
2005-01-14 06:08:27 +08:00
|
|
|
gdb_list_thread_ids (struct ui_out *uiout, char **error_message)
|
2000-02-03 12:14:45 +08:00
|
|
|
{
|
2007-04-10 22:53:46 +08:00
|
|
|
if (catch_exceptions_with_msg (uiout, do_captured_list_thread_ids, NULL,
|
|
|
|
error_message, RETURN_MASK_ALL) < 0)
|
|
|
|
return GDB_RC_FAIL;
|
|
|
|
return GDB_RC_OK;
|
2000-02-03 12:14:45 +08:00
|
|
|
}
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
/* Load infrun state for the thread PID. */
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
void
|
2003-03-29 05:42:41 +08:00
|
|
|
load_infrun_state (ptid_t ptid,
|
|
|
|
CORE_ADDR *prev_pc,
|
2001-06-13 Michael Snyder <msnyder@redhat.com>
* gdbthread.h (struct thread_info): Add new fields:
current_line, current_symtab, step_sp, for saved infrun state.
* thread.c (save_infrun_state, load_infrun_state): Save and
restore current_line, current_symtab, and step_sp.
(add_thread): Rather than adding assignments to initialize
the new fields, just use memset (tp, 0, sizeof (*tp).
This way future new fields will not be overlooked.
* infrun.c (handle_inferior_event): Save and restore save_sp,
current_line, and current_symtab when switching threads.
2001-06-14 06:56:16 +08:00
|
|
|
int *trap_expected,
|
2000-07-30 09:48:28 +08:00
|
|
|
struct breakpoint **step_resume_breakpoint,
|
2003-03-29 05:42:41 +08:00
|
|
|
CORE_ADDR *step_range_start,
|
2001-06-13 Michael Snyder <msnyder@redhat.com>
* gdbthread.h (struct thread_info): Add new fields:
current_line, current_symtab, step_sp, for saved infrun state.
* thread.c (save_infrun_state, load_infrun_state): Save and
restore current_line, current_symtab, and step_sp.
(add_thread): Rather than adding assignments to initialize
the new fields, just use memset (tp, 0, sizeof (*tp).
This way future new fields will not be overlooked.
* infrun.c (handle_inferior_event): Save and restore save_sp,
current_line, and current_symtab when switching threads.
2001-06-14 06:56:16 +08:00
|
|
|
CORE_ADDR *step_range_end,
|
2003-03-29 05:42:41 +08:00
|
|
|
struct frame_id *step_frame_id,
|
2007-12-06 20:57:51 +08:00
|
|
|
int *stepping_over_breakpoint,
|
2001-06-13 Michael Snyder <msnyder@redhat.com>
* gdbthread.h (struct thread_info): Add new fields:
current_line, current_symtab, step_sp, for saved infrun state.
* thread.c (save_infrun_state, load_infrun_state): Save and
restore current_line, current_symtab, and step_sp.
(add_thread): Rather than adding assignments to initialize
the new fields, just use memset (tp, 0, sizeof (*tp).
This way future new fields will not be overlooked.
* infrun.c (handle_inferior_event): Save and restore save_sp,
current_line, and current_symtab when switching threads.
2001-06-14 06:56:16 +08:00
|
|
|
int *stepping_through_solib_after_catch,
|
2000-07-30 09:48:28 +08:00
|
|
|
bpstat *stepping_through_solib_catchpoints,
|
2003-03-29 05:42:41 +08:00
|
|
|
int *current_line,
|
Per-thread commands.
* gdbthread.h: Remove unneeded forward declarations.
Include "inferior.h".
(struct thread_info): Add continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi and stop_signal members.
(save_infrun_state): Add continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat parameters.
(load_infrun_state): Add continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat parameters.
* thread.c (load_infrun_state): In non-stop mode, load
continuations, intermediate_continuations, proceed_to_finish,
step_over_calls, stop_step, step_multi and stop_signal.
(save_infrun_state): Store continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat.
(save_infrun_state): Store continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat.
(free_thread): Clear The thread's stop_bpstat.
* inferior.h (context_switch_to): Declare.
* infrun.c (ecss): New global.
(context_switch): Context switch continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat.
(wait_for_inferior): Use global ecss.
(async_ecss, async_ecs): Delete.
(fetch_inferior_event): Use global ecss.
(context_switch_to): New.
* top.c (execute_command): In non-stop, only check if the current
thread is running, in all-stop, check if there's any thread
running.
* breakpoint.c (bpstat_remove_breakpoint): New.
(bpstat_remove_breakpoint_callback): New.
(delete_breakpoint): Clear the stop_bpstats of all threads.
* mi/mi-main.c (mi_cmd_execute): In non-stop, only check if the
current thread is running, in all-stop, check if there's any
thread running.
* Makefile.in (gdbthread_h): Depend on $(inferior_h).
2008-07-10 06:30:46 +08:00
|
|
|
struct symtab **current_symtab,
|
|
|
|
struct continuation **continuations,
|
|
|
|
struct continuation **intermediate_continuations,
|
|
|
|
int *proceed_to_finish,
|
|
|
|
enum step_over_calls_kind *step_over_calls,
|
|
|
|
int *stop_step,
|
|
|
|
int *step_multi,
|
|
|
|
enum target_signal *stop_signal,
|
|
|
|
bpstat *stop_bpstat)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
|
|
|
|
|
|
|
/* If we can't find the thread, then we're debugging a single threaded
|
|
|
|
process. No need to do anything in that case. */
|
2001-05-04 12:15:33 +08:00
|
|
|
tp = find_thread_id (pid_to_thread_id (ptid));
|
1999-04-16 09:35:26 +08:00
|
|
|
if (tp == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
*prev_pc = tp->prev_pc;
|
2001-06-13 Michael Snyder <msnyder@redhat.com>
* gdbthread.h (struct thread_info): Add new fields:
current_line, current_symtab, step_sp, for saved infrun state.
* thread.c (save_infrun_state, load_infrun_state): Save and
restore current_line, current_symtab, and step_sp.
(add_thread): Rather than adding assignments to initialize
the new fields, just use memset (tp, 0, sizeof (*tp).
This way future new fields will not be overlooked.
* infrun.c (handle_inferior_event): Save and restore save_sp,
current_line, and current_symtab when switching threads.
2001-06-14 06:56:16 +08:00
|
|
|
*trap_expected = tp->trap_expected;
|
1999-04-16 09:35:26 +08:00
|
|
|
*step_resume_breakpoint = tp->step_resume_breakpoint;
|
|
|
|
*step_range_start = tp->step_range_start;
|
|
|
|
*step_range_end = tp->step_range_end;
|
2002-12-06 15:35:55 +08:00
|
|
|
*step_frame_id = tp->step_frame_id;
|
2007-12-06 20:57:51 +08:00
|
|
|
*stepping_over_breakpoint = tp->stepping_over_breakpoint;
|
2003-03-29 05:42:41 +08:00
|
|
|
*stepping_through_solib_after_catch =
|
|
|
|
tp->stepping_through_solib_after_catch;
|
|
|
|
*stepping_through_solib_catchpoints =
|
|
|
|
tp->stepping_through_solib_catchpoints;
|
2001-06-13 Michael Snyder <msnyder@redhat.com>
* gdbthread.h (struct thread_info): Add new fields:
current_line, current_symtab, step_sp, for saved infrun state.
* thread.c (save_infrun_state, load_infrun_state): Save and
restore current_line, current_symtab, and step_sp.
(add_thread): Rather than adding assignments to initialize
the new fields, just use memset (tp, 0, sizeof (*tp).
This way future new fields will not be overlooked.
* infrun.c (handle_inferior_event): Save and restore save_sp,
current_line, and current_symtab when switching threads.
2001-06-14 06:56:16 +08:00
|
|
|
*current_line = tp->current_line;
|
|
|
|
*current_symtab = tp->current_symtab;
|
Per-thread commands.
* gdbthread.h: Remove unneeded forward declarations.
Include "inferior.h".
(struct thread_info): Add continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi and stop_signal members.
(save_infrun_state): Add continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat parameters.
(load_infrun_state): Add continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat parameters.
* thread.c (load_infrun_state): In non-stop mode, load
continuations, intermediate_continuations, proceed_to_finish,
step_over_calls, stop_step, step_multi and stop_signal.
(save_infrun_state): Store continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat.
(save_infrun_state): Store continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat.
(free_thread): Clear The thread's stop_bpstat.
* inferior.h (context_switch_to): Declare.
* infrun.c (ecss): New global.
(context_switch): Context switch continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat.
(wait_for_inferior): Use global ecss.
(async_ecss, async_ecs): Delete.
(fetch_inferior_event): Use global ecss.
(context_switch_to): New.
* top.c (execute_command): In non-stop, only check if the current
thread is running, in all-stop, check if there's any thread
running.
* breakpoint.c (bpstat_remove_breakpoint): New.
(bpstat_remove_breakpoint_callback): New.
(delete_breakpoint): Clear the stop_bpstats of all threads.
* mi/mi-main.c (mi_cmd_execute): In non-stop, only check if the
current thread is running, in all-stop, check if there's any
thread running.
* Makefile.in (gdbthread_h): Depend on $(inferior_h).
2008-07-10 06:30:46 +08:00
|
|
|
|
|
|
|
/* In all-stop mode, these are global state, while in non-stop mode,
|
|
|
|
they are per thread. */
|
|
|
|
if (non_stop)
|
|
|
|
{
|
|
|
|
*continuations = tp->continuations;
|
|
|
|
tp->continuations = NULL;
|
|
|
|
*intermediate_continuations = tp->intermediate_continuations;
|
|
|
|
tp->intermediate_continuations = NULL;
|
|
|
|
*proceed_to_finish = tp->proceed_to_finish;
|
|
|
|
*step_over_calls = tp->step_over_calls;
|
|
|
|
*stop_step = tp->stop_step;
|
|
|
|
*step_multi = tp->step_multi;
|
|
|
|
*stop_signal = tp->stop_signal;
|
|
|
|
|
|
|
|
/* Swap instead of copy, so we only have to update one of
|
|
|
|
them. */
|
|
|
|
*stop_bpstat = tp->stop_bpstat;
|
|
|
|
tp->stop_bpstat = 0;
|
|
|
|
}
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Save infrun state for the thread PID. */
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
void
|
2003-03-29 05:42:41 +08:00
|
|
|
save_infrun_state (ptid_t ptid,
|
|
|
|
CORE_ADDR prev_pc,
|
2001-06-13 Michael Snyder <msnyder@redhat.com>
* gdbthread.h (struct thread_info): Add new fields:
current_line, current_symtab, step_sp, for saved infrun state.
* thread.c (save_infrun_state, load_infrun_state): Save and
restore current_line, current_symtab, and step_sp.
(add_thread): Rather than adding assignments to initialize
the new fields, just use memset (tp, 0, sizeof (*tp).
This way future new fields will not be overlooked.
* infrun.c (handle_inferior_event): Save and restore save_sp,
current_line, and current_symtab when switching threads.
2001-06-14 06:56:16 +08:00
|
|
|
int trap_expected,
|
2000-07-30 09:48:28 +08:00
|
|
|
struct breakpoint *step_resume_breakpoint,
|
2003-03-29 05:42:41 +08:00
|
|
|
CORE_ADDR step_range_start,
|
2001-06-13 Michael Snyder <msnyder@redhat.com>
* gdbthread.h (struct thread_info): Add new fields:
current_line, current_symtab, step_sp, for saved infrun state.
* thread.c (save_infrun_state, load_infrun_state): Save and
restore current_line, current_symtab, and step_sp.
(add_thread): Rather than adding assignments to initialize
the new fields, just use memset (tp, 0, sizeof (*tp).
This way future new fields will not be overlooked.
* infrun.c (handle_inferior_event): Save and restore save_sp,
current_line, and current_symtab when switching threads.
2001-06-14 06:56:16 +08:00
|
|
|
CORE_ADDR step_range_end,
|
2003-03-29 05:42:41 +08:00
|
|
|
const struct frame_id *step_frame_id,
|
2007-12-06 20:57:51 +08:00
|
|
|
int stepping_over_breakpoint,
|
2001-06-13 Michael Snyder <msnyder@redhat.com>
* gdbthread.h (struct thread_info): Add new fields:
current_line, current_symtab, step_sp, for saved infrun state.
* thread.c (save_infrun_state, load_infrun_state): Save and
restore current_line, current_symtab, and step_sp.
(add_thread): Rather than adding assignments to initialize
the new fields, just use memset (tp, 0, sizeof (*tp).
This way future new fields will not be overlooked.
* infrun.c (handle_inferior_event): Save and restore save_sp,
current_line, and current_symtab when switching threads.
2001-06-14 06:56:16 +08:00
|
|
|
int stepping_through_solib_after_catch,
|
2000-07-30 09:48:28 +08:00
|
|
|
bpstat stepping_through_solib_catchpoints,
|
2001-06-13 Michael Snyder <msnyder@redhat.com>
* gdbthread.h (struct thread_info): Add new fields:
current_line, current_symtab, step_sp, for saved infrun state.
* thread.c (save_infrun_state, load_infrun_state): Save and
restore current_line, current_symtab, and step_sp.
(add_thread): Rather than adding assignments to initialize
the new fields, just use memset (tp, 0, sizeof (*tp).
This way future new fields will not be overlooked.
* infrun.c (handle_inferior_event): Save and restore save_sp,
current_line, and current_symtab when switching threads.
2001-06-14 06:56:16 +08:00
|
|
|
int current_line,
|
Per-thread commands.
* gdbthread.h: Remove unneeded forward declarations.
Include "inferior.h".
(struct thread_info): Add continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi and stop_signal members.
(save_infrun_state): Add continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat parameters.
(load_infrun_state): Add continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat parameters.
* thread.c (load_infrun_state): In non-stop mode, load
continuations, intermediate_continuations, proceed_to_finish,
step_over_calls, stop_step, step_multi and stop_signal.
(save_infrun_state): Store continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat.
(save_infrun_state): Store continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat.
(free_thread): Clear The thread's stop_bpstat.
* inferior.h (context_switch_to): Declare.
* infrun.c (ecss): New global.
(context_switch): Context switch continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat.
(wait_for_inferior): Use global ecss.
(async_ecss, async_ecs): Delete.
(fetch_inferior_event): Use global ecss.
(context_switch_to): New.
* top.c (execute_command): In non-stop, only check if the current
thread is running, in all-stop, check if there's any thread
running.
* breakpoint.c (bpstat_remove_breakpoint): New.
(bpstat_remove_breakpoint_callback): New.
(delete_breakpoint): Clear the stop_bpstats of all threads.
* mi/mi-main.c (mi_cmd_execute): In non-stop, only check if the
current thread is running, in all-stop, check if there's any
thread running.
* Makefile.in (gdbthread_h): Depend on $(inferior_h).
2008-07-10 06:30:46 +08:00
|
|
|
struct symtab *current_symtab,
|
|
|
|
struct continuation *continuations,
|
|
|
|
struct continuation *intermediate_continuations,
|
|
|
|
int proceed_to_finish,
|
|
|
|
enum step_over_calls_kind step_over_calls,
|
|
|
|
int stop_step,
|
|
|
|
int step_multi,
|
|
|
|
enum target_signal stop_signal,
|
|
|
|
bpstat stop_bpstat)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
|
|
|
|
|
|
|
/* If we can't find the thread, then we're debugging a single-threaded
|
|
|
|
process. Nothing to do in that case. */
|
2001-05-04 12:15:33 +08:00
|
|
|
tp = find_thread_id (pid_to_thread_id (ptid));
|
1999-04-16 09:35:26 +08:00
|
|
|
if (tp == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tp->prev_pc = prev_pc;
|
2001-06-13 Michael Snyder <msnyder@redhat.com>
* gdbthread.h (struct thread_info): Add new fields:
current_line, current_symtab, step_sp, for saved infrun state.
* thread.c (save_infrun_state, load_infrun_state): Save and
restore current_line, current_symtab, and step_sp.
(add_thread): Rather than adding assignments to initialize
the new fields, just use memset (tp, 0, sizeof (*tp).
This way future new fields will not be overlooked.
* infrun.c (handle_inferior_event): Save and restore save_sp,
current_line, and current_symtab when switching threads.
2001-06-14 06:56:16 +08:00
|
|
|
tp->trap_expected = trap_expected;
|
1999-04-16 09:35:26 +08:00
|
|
|
tp->step_resume_breakpoint = step_resume_breakpoint;
|
|
|
|
tp->step_range_start = step_range_start;
|
|
|
|
tp->step_range_end = step_range_end;
|
2002-12-06 15:35:55 +08:00
|
|
|
tp->step_frame_id = (*step_frame_id);
|
2007-12-06 20:57:51 +08:00
|
|
|
tp->stepping_over_breakpoint = stepping_over_breakpoint;
|
1999-04-16 09:35:26 +08:00
|
|
|
tp->stepping_through_solib_after_catch = stepping_through_solib_after_catch;
|
|
|
|
tp->stepping_through_solib_catchpoints = stepping_through_solib_catchpoints;
|
2001-06-13 Michael Snyder <msnyder@redhat.com>
* gdbthread.h (struct thread_info): Add new fields:
current_line, current_symtab, step_sp, for saved infrun state.
* thread.c (save_infrun_state, load_infrun_state): Save and
restore current_line, current_symtab, and step_sp.
(add_thread): Rather than adding assignments to initialize
the new fields, just use memset (tp, 0, sizeof (*tp).
This way future new fields will not be overlooked.
* infrun.c (handle_inferior_event): Save and restore save_sp,
current_line, and current_symtab when switching threads.
2001-06-14 06:56:16 +08:00
|
|
|
tp->current_line = current_line;
|
|
|
|
tp->current_symtab = current_symtab;
|
Per-thread commands.
* gdbthread.h: Remove unneeded forward declarations.
Include "inferior.h".
(struct thread_info): Add continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi and stop_signal members.
(save_infrun_state): Add continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat parameters.
(load_infrun_state): Add continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat parameters.
* thread.c (load_infrun_state): In non-stop mode, load
continuations, intermediate_continuations, proceed_to_finish,
step_over_calls, stop_step, step_multi and stop_signal.
(save_infrun_state): Store continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat.
(save_infrun_state): Store continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat.
(free_thread): Clear The thread's stop_bpstat.
* inferior.h (context_switch_to): Declare.
* infrun.c (ecss): New global.
(context_switch): Context switch continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat.
(wait_for_inferior): Use global ecss.
(async_ecss, async_ecs): Delete.
(fetch_inferior_event): Use global ecss.
(context_switch_to): New.
* top.c (execute_command): In non-stop, only check if the current
thread is running, in all-stop, check if there's any thread
running.
* breakpoint.c (bpstat_remove_breakpoint): New.
(bpstat_remove_breakpoint_callback): New.
(delete_breakpoint): Clear the stop_bpstats of all threads.
* mi/mi-main.c (mi_cmd_execute): In non-stop, only check if the
current thread is running, in all-stop, check if there's any
thread running.
* Makefile.in (gdbthread_h): Depend on $(inferior_h).
2008-07-10 06:30:46 +08:00
|
|
|
|
|
|
|
/* In all-stop mode, these are global state, while in non-stop mode,
|
|
|
|
they are per thread. */
|
|
|
|
if (non_stop)
|
|
|
|
{
|
|
|
|
tp->continuations = continuations;
|
|
|
|
tp->intermediate_continuations = intermediate_continuations;
|
|
|
|
tp->proceed_to_finish = proceed_to_finish;
|
|
|
|
tp->step_over_calls = step_over_calls;
|
|
|
|
tp->stop_step = stop_step;
|
|
|
|
tp->step_multi = step_multi;
|
|
|
|
tp->stop_signal = stop_signal;
|
|
|
|
tp->stop_bpstat = stop_bpstat;
|
|
|
|
}
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return true if TP is an active thread. */
|
|
|
|
static int
|
2000-07-30 09:48:28 +08:00
|
|
|
thread_alive (struct thread_info *tp)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
2001-05-04 12:15:33 +08:00
|
|
|
if (PIDGET (tp->ptid) == -1)
|
1999-04-16 09:35:26 +08:00
|
|
|
return 0;
|
2001-05-04 12:15:33 +08:00
|
|
|
if (!target_thread_alive (tp->ptid))
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
2001-05-04 12:15:33 +08:00
|
|
|
tp->ptid = pid_to_ptid (-1); /* Mark it as dead */
|
1999-04-16 09:35:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-07-30 09:48:28 +08:00
|
|
|
prune_threads (void)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
1999-09-09 08:02:17 +08:00
|
|
|
struct thread_info *tp, *next;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
for (tp = thread_list; tp; tp = next)
|
|
|
|
{
|
|
|
|
next = tp->next;
|
|
|
|
if (!thread_alive (tp))
|
2001-05-04 12:15:33 +08:00
|
|
|
delete_thread (tp->ptid);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-10 18:23:54 +08:00
|
|
|
void
|
|
|
|
set_running (ptid_t ptid, int running)
|
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
|
|
|
|
|
|
|
if (!thread_list)
|
|
|
|
{
|
|
|
|
/* This is one of the targets that does not add main
|
|
|
|
thread to the thread list. Just use a single
|
|
|
|
global flag to indicate that a thread is running.
|
|
|
|
|
|
|
|
This problem is unique to ST programs. For MT programs,
|
|
|
|
the main thread is always present in the thread list. If it's
|
|
|
|
not, the first call to context_switch will mess up GDB internal
|
|
|
|
state. */
|
2008-06-14 04:19:19 +08:00
|
|
|
if (running && !main_thread_running && !suppress_resume_observer)
|
2008-06-10 18:23:54 +08:00
|
|
|
observer_notify_target_resumed (ptid);
|
|
|
|
main_thread_running = running;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We try not to notify the observer if no thread has actually changed
|
|
|
|
the running state -- merely to reduce the number of messages to
|
|
|
|
frontend. Frontend is supposed to handle multiple *running just fine. */
|
|
|
|
if (PIDGET (ptid) == -1)
|
|
|
|
{
|
|
|
|
int any_started = 0;
|
|
|
|
for (tp = thread_list; tp; tp = tp->next)
|
|
|
|
{
|
|
|
|
if (running && !tp->running_)
|
|
|
|
any_started = 1;
|
|
|
|
tp->running_ = running;
|
|
|
|
}
|
2008-06-14 04:19:19 +08:00
|
|
|
if (any_started && !suppress_resume_observer)
|
2008-06-10 18:23:54 +08:00
|
|
|
observer_notify_target_resumed (ptid);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tp = find_thread_pid (ptid);
|
|
|
|
gdb_assert (tp);
|
2008-06-14 04:19:19 +08:00
|
|
|
if (running && !tp->running_ && !suppress_resume_observer)
|
2008-06-10 18:23:54 +08:00
|
|
|
observer_notify_target_resumed (ptid);
|
|
|
|
tp->running_ = running;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
is_running (ptid_t ptid)
|
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
|
|
|
|
2008-07-10 06:16:15 +08:00
|
|
|
if (!target_has_execution)
|
|
|
|
return 0;
|
|
|
|
|
2008-06-10 18:23:54 +08:00
|
|
|
if (!thread_list)
|
|
|
|
return main_thread_running;
|
|
|
|
|
|
|
|
tp = find_thread_pid (ptid);
|
|
|
|
gdb_assert (tp);
|
|
|
|
return tp->running_;
|
|
|
|
}
|
|
|
|
|
2008-07-10 06:16:15 +08:00
|
|
|
int
|
|
|
|
any_running (void)
|
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
|
|
|
|
|
|
|
if (!target_has_execution)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!thread_list)
|
|
|
|
return main_thread_running;
|
|
|
|
|
|
|
|
for (tp = thread_list; tp; tp = tp->next)
|
|
|
|
if (tp->running_)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
is_executing (ptid_t ptid)
|
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
|
|
|
|
|
|
|
if (!target_has_execution)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!thread_list)
|
|
|
|
return main_thread_executing;
|
|
|
|
|
|
|
|
tp = find_thread_pid (ptid);
|
|
|
|
gdb_assert (tp);
|
|
|
|
return tp->executing_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_executing (ptid_t ptid, int executing)
|
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
|
|
|
|
|
|
|
if (!thread_list)
|
|
|
|
{
|
|
|
|
/* This target does not add the main thread to the thread list.
|
|
|
|
Use a global flag to indicate that the thread is
|
|
|
|
executing. */
|
|
|
|
main_thread_executing = executing;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PIDGET (ptid) == -1)
|
|
|
|
{
|
|
|
|
for (tp = thread_list; tp; tp = tp->next)
|
|
|
|
tp->executing_ = executing;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tp = find_thread_pid (ptid);
|
|
|
|
gdb_assert (tp);
|
|
|
|
tp->executing_ = executing;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-15 21:53:25 +08:00
|
|
|
/* Prints the list of threads and their details on UIOUT.
|
|
|
|
This is a version of 'info_thread_command' suitable for
|
|
|
|
use from MI.
|
|
|
|
If REQESTED_THREAD is not -1, it's the GDB id of the thread
|
|
|
|
that should be printed. Otherwise, all threads are
|
|
|
|
printed. */
|
|
|
|
void
|
|
|
|
print_thread_info (struct ui_out *uiout, int requested_thread)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
2001-05-04 12:15:33 +08:00
|
|
|
ptid_t current_ptid;
|
1999-07-08 04:19:36 +08:00
|
|
|
struct frame_info *cur_frame;
|
2007-02-02 20:18:37 +08:00
|
|
|
struct cleanup *old_chain;
|
|
|
|
struct frame_id saved_frame_id;
|
2000-01-11 11:07:37 +08:00
|
|
|
char *extra_info;
|
2008-03-15 21:53:25 +08:00
|
|
|
int current_thread = -1;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2007-02-02 20:18:37 +08:00
|
|
|
/* Backup current thread and selected frame. */
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
if (!is_running (inferior_ptid))
|
|
|
|
saved_frame_id = get_frame_id (get_selected_frame (NULL));
|
|
|
|
else
|
|
|
|
saved_frame_id = null_frame_id;
|
2007-02-02 20:18:37 +08:00
|
|
|
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
old_chain = make_cleanup_restore_current_thread (inferior_ptid, saved_frame_id);
|
2008-03-15 21:53:25 +08:00
|
|
|
make_cleanup_ui_out_list_begin_end (uiout, "threads");
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
prune_threads ();
|
1999-05-05 22:45:51 +08:00
|
|
|
target_find_new_threads ();
|
2001-05-04 12:15:33 +08:00
|
|
|
current_ptid = inferior_ptid;
|
1999-04-16 09:35:26 +08:00
|
|
|
for (tp = thread_list; tp; tp = tp->next)
|
|
|
|
{
|
2008-03-15 21:53:25 +08:00
|
|
|
struct cleanup *chain2;
|
|
|
|
|
|
|
|
if (requested_thread != -1 && tp->num != requested_thread)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
chain2 = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
|
|
|
|
|
2001-05-04 12:15:33 +08:00
|
|
|
if (ptid_equal (tp->ptid, current_ptid))
|
2008-03-15 21:53:25 +08:00
|
|
|
{
|
|
|
|
current_thread = tp->num;
|
|
|
|
ui_out_text (uiout, "* ");
|
|
|
|
}
|
1999-04-16 09:35:26 +08:00
|
|
|
else
|
2008-03-15 21:53:25 +08:00
|
|
|
ui_out_text (uiout, " ");
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2008-03-15 21:53:25 +08:00
|
|
|
ui_out_field_int (uiout, "id", tp->num);
|
|
|
|
ui_out_text (uiout, " ");
|
|
|
|
ui_out_field_string (uiout, "target-id", target_tid_to_str (tp->ptid));
|
2000-01-11 11:07:37 +08:00
|
|
|
|
|
|
|
extra_info = target_extra_thread_info (tp);
|
|
|
|
if (extra_info)
|
2008-03-15 21:53:25 +08:00
|
|
|
{
|
|
|
|
ui_out_text (uiout, " (");
|
|
|
|
ui_out_field_string (uiout, "details", extra_info);
|
|
|
|
ui_out_text (uiout, ")");
|
|
|
|
}
|
|
|
|
ui_out_text (uiout, " ");
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
if (tp->running_)
|
|
|
|
ui_out_text (uiout, "(running)\n");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* The switch below puts us at the top of the stack (leaf
|
|
|
|
frame). */
|
|
|
|
switch_to_thread (tp->ptid);
|
|
|
|
print_stack_frame (get_selected_frame (NULL),
|
|
|
|
/* For MI output, print frame level. */
|
|
|
|
ui_out_is_mi_like_p (uiout),
|
|
|
|
LOCATION);
|
|
|
|
}
|
2008-03-15 21:53:25 +08:00
|
|
|
|
|
|
|
do_cleanups (chain2);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
2007-02-02 20:18:37 +08:00
|
|
|
/* Restores the current thread and the frame selected before
|
|
|
|
the "info threads" command. */
|
|
|
|
do_cleanups (old_chain);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2008-03-15 21:53:25 +08:00
|
|
|
if (requested_thread == -1)
|
|
|
|
{
|
2008-03-18 02:41:29 +08:00
|
|
|
gdb_assert (current_thread != -1 || !thread_list);
|
|
|
|
if (current_thread != -1 && ui_out_is_mi_like_p (uiout))
|
2008-03-15 21:53:25 +08:00
|
|
|
ui_out_field_int (uiout, "current-thread-id", current_thread);
|
|
|
|
}
|
|
|
|
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
if (is_running (inferior_ptid))
|
|
|
|
return;
|
|
|
|
|
2007-02-02 20:18:37 +08:00
|
|
|
/* If case we were not able to find the original frame, print the
|
|
|
|
new selected frame. */
|
|
|
|
if (frame_find_by_id (saved_frame_id) == NULL)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
warning (_("Couldn't restore frame in current thread, at frame 0"));
|
2008-03-15 21:53:25 +08:00
|
|
|
/* For MI, we should probably have a notification about
|
|
|
|
current frame change. But this error is not very likely, so
|
|
|
|
don't bother for now. */
|
|
|
|
if (!ui_out_is_mi_like_p (uiout))
|
|
|
|
print_stack_frame (get_selected_frame (NULL), 0, LOCATION);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-15 21:53:25 +08:00
|
|
|
|
|
|
|
/* Print information about currently known threads
|
|
|
|
|
|
|
|
* Note: this has the drawback that it _really_ switches
|
|
|
|
* threads, which frees the frame cache. A no-side
|
|
|
|
* effects info-threads command would be nicer.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
info_threads_command (char *arg, int from_tty)
|
|
|
|
{
|
|
|
|
print_thread_info (uiout, -1);
|
|
|
|
}
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
/* Switch from one thread to another. */
|
|
|
|
|
2007-09-11 02:49:26 +08:00
|
|
|
void
|
2001-05-04 12:15:33 +08:00
|
|
|
switch_to_thread (ptid_t ptid)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
2001-05-04 12:15:33 +08:00
|
|
|
if (ptid_equal (ptid, inferior_ptid))
|
1999-04-16 09:35:26 +08:00
|
|
|
return;
|
|
|
|
|
2001-05-04 12:15:33 +08:00
|
|
|
inferior_ptid = ptid;
|
2007-03-01 01:35:01 +08:00
|
|
|
reinit_frame_cache ();
|
1999-04-16 09:35:26 +08:00
|
|
|
registers_changed ();
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
|
|
|
|
if (!is_executing (ptid))
|
|
|
|
stop_pc = read_pc ();
|
|
|
|
else
|
|
|
|
stop_pc = ~(CORE_ADDR) 0;
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-05-04 12:15:33 +08:00
|
|
|
restore_current_thread (ptid_t ptid)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
2003-03-29 05:42:41 +08:00
|
|
|
if (!ptid_equal (ptid, inferior_ptid))
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
2001-05-04 12:15:33 +08:00
|
|
|
switch_to_thread (ptid);
|
2007-02-02 20:18:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
restore_selected_frame (struct frame_id a_frame_id)
|
|
|
|
{
|
|
|
|
struct frame_info *selected_frame_info = NULL;
|
|
|
|
|
|
|
|
if (frame_id_eq (a_frame_id, null_frame_id))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((selected_frame_info = frame_find_by_id (a_frame_id)) != NULL)
|
|
|
|
{
|
|
|
|
select_frame (selected_frame_info);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-06-07 12:43:30 +08:00
|
|
|
struct current_thread_cleanup
|
|
|
|
{
|
2001-05-04 12:15:33 +08:00
|
|
|
ptid_t inferior_ptid;
|
2007-02-02 20:18:37 +08:00
|
|
|
struct frame_id selected_frame_id;
|
2000-06-07 12:43:30 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_restore_current_thread_cleanup (void *arg)
|
|
|
|
{
|
|
|
|
struct current_thread_cleanup *old = arg;
|
2001-05-04 12:15:33 +08:00
|
|
|
restore_current_thread (old->inferior_ptid);
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
|
|
|
|
/* A command like 'thread apply all $exec_command&' may change the
|
|
|
|
running state of the originally selected thread, so we have to
|
|
|
|
recheck it here. */
|
|
|
|
if (!is_running (old->inferior_ptid))
|
|
|
|
restore_selected_frame (old->selected_frame_id);
|
2000-12-15 09:01:51 +08:00
|
|
|
xfree (old);
|
2000-06-07 12:43:30 +08:00
|
|
|
}
|
|
|
|
|
2008-03-23 17:53:52 +08:00
|
|
|
struct cleanup *
|
2007-02-02 20:18:37 +08:00
|
|
|
make_cleanup_restore_current_thread (ptid_t inferior_ptid,
|
|
|
|
struct frame_id a_frame_id)
|
2000-06-07 12:43:30 +08:00
|
|
|
{
|
|
|
|
struct current_thread_cleanup *old
|
|
|
|
= xmalloc (sizeof (struct current_thread_cleanup));
|
2001-05-04 12:15:33 +08:00
|
|
|
old->inferior_ptid = inferior_ptid;
|
2007-02-02 20:18:37 +08:00
|
|
|
old->selected_frame_id = a_frame_id;
|
2000-06-07 12:43:30 +08:00
|
|
|
return make_cleanup (do_restore_current_thread_cleanup, old);
|
|
|
|
}
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
/* Apply a GDB command to a list of threads. List syntax is a whitespace
|
|
|
|
seperated list of numbers, or ranges, or the keyword `all'. Ranges consist
|
|
|
|
of two numbers seperated by a hyphen. Examples:
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
thread apply 1 2 7 4 backtrace Apply backtrace cmd to threads 1,2,7,4
|
|
|
|
thread apply 2-7 9 p foo(1) Apply p foo(1) cmd to threads 2->7 & 9
|
|
|
|
thread apply all p x/i $pc Apply x/i $pc cmd to all threads
|
|
|
|
*/
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
static void
|
2000-07-30 09:48:28 +08:00
|
|
|
thread_apply_all_command (char *cmd, int from_tty)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
struct cleanup *old_chain = make_cleanup (null_cleanup, 0);
|
2000-11-17 11:49:41 +08:00
|
|
|
char *saved_cmd;
|
2007-02-02 20:18:37 +08:00
|
|
|
struct frame_id saved_frame_id;
|
|
|
|
ptid_t current_ptid;
|
|
|
|
int thread_has_changed = 0;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
if (cmd == NULL || *cmd == '\000')
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
error (_("Please specify a command following the thread ID list"));
|
2007-02-02 20:18:37 +08:00
|
|
|
|
|
|
|
current_ptid = inferior_ptid;
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
|
|
|
|
if (!is_running (inferior_ptid))
|
|
|
|
saved_frame_id = get_frame_id (get_selected_frame (NULL));
|
|
|
|
else
|
|
|
|
saved_frame_id = null_frame_id;
|
|
|
|
make_cleanup_restore_current_thread (inferior_ptid, saved_frame_id);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2000-07-22 08:15:30 +08:00
|
|
|
/* It is safe to update the thread list now, before
|
|
|
|
traversing it for "thread apply all". MVS */
|
|
|
|
target_find_new_threads ();
|
|
|
|
|
2000-11-17 11:49:41 +08:00
|
|
|
/* Save a copy of the command in case it is clobbered by
|
|
|
|
execute_command */
|
2001-01-27 03:47:23 +08:00
|
|
|
saved_cmd = xstrdup (cmd);
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
make_cleanup (xfree, saved_cmd);
|
1999-04-16 09:35:26 +08:00
|
|
|
for (tp = thread_list; tp; tp = tp->next)
|
|
|
|
if (thread_alive (tp))
|
|
|
|
{
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
if (non_stop)
|
|
|
|
context_switch_to (tp->ptid);
|
|
|
|
else
|
|
|
|
switch_to_thread (tp->ptid);
|
|
|
|
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up some of printf_filtered and printf_unfiltered.
* ada-lang.c, annotate.c, arch-utils.c, breakpoint.c: Update.
* corelow.c, cp-namespace.c, cp-support.c, dcache.c: Update.
* demangle.c, dsrec.c, dwarf2read.c, dwarfread.c: Update.
* event-loop.c, event-top.c, exec.c, f-valprint.c: Update.
* gdbtypes.c, inf-loop.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcmd.c, inflow.c, infrun.c, inftarg.c, language.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, maint.c: Update.
* mdebugread.c, memattr.c, monitor.c, objc-lang.c: Update.
* ocd.c, osabi.c, printcmd.c, procfs.c, regcache.c: Update.
* remote.c, solib-som.c, solib.c, somsolib.c, source.c: Update.
* stack.c, symfile.c, symmisc.c, target.c, thread.c: Update.
* top.c, utils.c, valprint.c, value.c, cli/cli-cmds.c: Update.
* cli/cli-dump.c, cli/cli-logging.c, tui/tui-hooks.c: Update.
* tui/tui-regs.c, tui/tui-win.c: Update.
2005-02-12 08:39:24 +08:00
|
|
|
printf_filtered (_("\nThread %d (%s):\n"),
|
2003-03-29 05:42:41 +08:00
|
|
|
tp->num, target_tid_to_str (inferior_ptid));
|
1999-04-16 09:35:26 +08:00
|
|
|
execute_command (cmd, from_tty);
|
2003-03-29 05:42:41 +08:00
|
|
|
strcpy (cmd, saved_cmd); /* Restore exact command used previously */
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
2000-06-07 12:43:30 +08:00
|
|
|
|
2007-02-02 20:18:37 +08:00
|
|
|
if (!ptid_equal (current_ptid, inferior_ptid))
|
|
|
|
thread_has_changed = 1;
|
|
|
|
|
2000-06-07 12:43:30 +08:00
|
|
|
do_cleanups (old_chain);
|
2007-02-02 20:18:37 +08:00
|
|
|
/* Print stack frame only if we changed thread. */
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
if (thread_has_changed && !is_running (inferior_ptid))
|
2007-02-02 20:18:37 +08:00
|
|
|
print_stack_frame (get_current_frame (), 1, SRC_LINE);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-07-30 09:48:28 +08:00
|
|
|
thread_apply_command (char *tidlist, int from_tty)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
char *cmd;
|
|
|
|
char *p;
|
|
|
|
struct cleanup *old_chain;
|
2000-11-17 11:49:41 +08:00
|
|
|
struct cleanup *saved_cmd_cleanup_chain;
|
|
|
|
char *saved_cmd;
|
2007-02-02 20:18:37 +08:00
|
|
|
struct frame_id saved_frame_id;
|
|
|
|
ptid_t current_ptid;
|
|
|
|
int thread_has_changed = 0;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
if (tidlist == NULL || *tidlist == '\000')
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
error (_("Please specify a thread ID list"));
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
for (cmd = tidlist; *cmd != '\000' && !isalpha (*cmd); cmd++);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
if (*cmd == '\000')
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
error (_("Please specify a command following the thread ID list"));
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2007-02-02 20:18:37 +08:00
|
|
|
current_ptid = inferior_ptid;
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
|
|
|
|
if (!is_running (inferior_ptid))
|
|
|
|
saved_frame_id = get_frame_id (get_selected_frame (NULL));
|
|
|
|
else
|
|
|
|
saved_frame_id = null_frame_id;
|
2007-02-02 20:18:37 +08:00
|
|
|
old_chain = make_cleanup_restore_current_thread (inferior_ptid, saved_frame_id);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2000-11-17 11:49:41 +08:00
|
|
|
/* Save a copy of the command in case it is clobbered by
|
|
|
|
execute_command */
|
2001-01-27 03:47:23 +08:00
|
|
|
saved_cmd = xstrdup (cmd);
|
2000-12-15 09:01:51 +08:00
|
|
|
saved_cmd_cleanup_chain = make_cleanup (xfree, (void *) saved_cmd);
|
1999-04-16 09:35:26 +08:00
|
|
|
while (tidlist < cmd)
|
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
|
|
|
int start, end;
|
|
|
|
|
|
|
|
start = strtol (tidlist, &p, 10);
|
|
|
|
if (p == tidlist)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
error (_("Error parsing %s"), tidlist);
|
1999-04-16 09:35:26 +08:00
|
|
|
tidlist = p;
|
|
|
|
|
|
|
|
while (*tidlist == ' ' || *tidlist == '\t')
|
|
|
|
tidlist++;
|
|
|
|
|
|
|
|
if (*tidlist == '-') /* Got a range of IDs? */
|
|
|
|
{
|
1999-07-08 04:19:36 +08:00
|
|
|
tidlist++; /* Skip the - */
|
1999-04-16 09:35:26 +08:00
|
|
|
end = strtol (tidlist, &p, 10);
|
|
|
|
if (p == tidlist)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
error (_("Error parsing %s"), tidlist);
|
1999-04-16 09:35:26 +08:00
|
|
|
tidlist = p;
|
|
|
|
|
|
|
|
while (*tidlist == ' ' || *tidlist == '\t')
|
|
|
|
tidlist++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
end = start;
|
|
|
|
|
|
|
|
for (; start <= end; start++)
|
|
|
|
{
|
|
|
|
tp = find_thread_id (start);
|
|
|
|
|
|
|
|
if (!tp)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
warning (_("Unknown thread %d."), start);
|
1999-04-16 09:35:26 +08:00
|
|
|
else if (!thread_alive (tp))
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
warning (_("Thread %d has terminated."), start);
|
1999-04-16 09:35:26 +08:00
|
|
|
else
|
|
|
|
{
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
if (non_stop)
|
|
|
|
context_switch_to (tp->ptid);
|
|
|
|
else
|
|
|
|
switch_to_thread (tp->ptid);
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up some of printf_filtered and printf_unfiltered.
* ada-lang.c, annotate.c, arch-utils.c, breakpoint.c: Update.
* corelow.c, cp-namespace.c, cp-support.c, dcache.c: Update.
* demangle.c, dsrec.c, dwarf2read.c, dwarfread.c: Update.
* event-loop.c, event-top.c, exec.c, f-valprint.c: Update.
* gdbtypes.c, inf-loop.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcmd.c, inflow.c, infrun.c, inftarg.c, language.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, maint.c: Update.
* mdebugread.c, memattr.c, monitor.c, objc-lang.c: Update.
* ocd.c, osabi.c, printcmd.c, procfs.c, regcache.c: Update.
* remote.c, solib-som.c, solib.c, somsolib.c, source.c: Update.
* stack.c, symfile.c, symmisc.c, target.c, thread.c: Update.
* top.c, utils.c, valprint.c, value.c, cli/cli-cmds.c: Update.
* cli/cli-dump.c, cli/cli-logging.c, tui/tui-hooks.c: Update.
* tui/tui-regs.c, tui/tui-win.c: Update.
2005-02-12 08:39:24 +08:00
|
|
|
printf_filtered (_("\nThread %d (%s):\n"), tp->num,
|
2001-05-04 12:15:33 +08:00
|
|
|
target_tid_to_str (inferior_ptid));
|
1999-04-16 09:35:26 +08:00
|
|
|
execute_command (cmd, from_tty);
|
2000-11-17 11:49:41 +08:00
|
|
|
strcpy (cmd, saved_cmd); /* Restore exact command used previously */
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-06-07 12:43:30 +08:00
|
|
|
|
2007-02-02 20:18:37 +08:00
|
|
|
if (!ptid_equal (current_ptid, inferior_ptid))
|
|
|
|
thread_has_changed = 1;
|
|
|
|
|
2000-11-17 11:49:41 +08:00
|
|
|
do_cleanups (saved_cmd_cleanup_chain);
|
2000-06-07 12:43:30 +08:00
|
|
|
do_cleanups (old_chain);
|
2007-02-02 20:18:37 +08:00
|
|
|
/* Print stack frame only if we changed thread. */
|
|
|
|
if (thread_has_changed)
|
|
|
|
print_stack_frame (get_current_frame (), 1, SRC_LINE);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Switch to the specified thread. Will dispatch off to thread_apply_command
|
|
|
|
if prefix of arg is `apply'. */
|
|
|
|
|
|
|
|
static void
|
2000-07-30 09:48:28 +08:00
|
|
|
thread_command (char *tidstr, int from_tty)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
if (!tidstr)
|
|
|
|
{
|
|
|
|
/* Don't generate an error, just say which thread is current. */
|
|
|
|
if (target_has_stack)
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up some of printf_filtered and printf_unfiltered.
* ada-lang.c, annotate.c, arch-utils.c, breakpoint.c: Update.
* corelow.c, cp-namespace.c, cp-support.c, dcache.c: Update.
* demangle.c, dsrec.c, dwarf2read.c, dwarfread.c: Update.
* event-loop.c, event-top.c, exec.c, f-valprint.c: Update.
* gdbtypes.c, inf-loop.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcmd.c, inflow.c, infrun.c, inftarg.c, language.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, maint.c: Update.
* mdebugread.c, memattr.c, monitor.c, objc-lang.c: Update.
* ocd.c, osabi.c, printcmd.c, procfs.c, regcache.c: Update.
* remote.c, solib-som.c, solib.c, somsolib.c, source.c: Update.
* stack.c, symfile.c, symmisc.c, target.c, thread.c: Update.
* top.c, utils.c, valprint.c, value.c, cli/cli-cmds.c: Update.
* cli/cli-dump.c, cli/cli-logging.c, tui/tui-hooks.c: Update.
* tui/tui-regs.c, tui/tui-win.c: Update.
2005-02-12 08:39:24 +08:00
|
|
|
printf_filtered (_("[Current thread is %d (%s)]\n"),
|
2001-05-04 12:15:33 +08:00
|
|
|
pid_to_thread_id (inferior_ptid),
|
2004-05-25 11:59:29 +08:00
|
|
|
target_tid_to_str (inferior_ptid));
|
1999-04-16 09:35:26 +08:00
|
|
|
else
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
error (_("No stack."));
|
1999-04-16 09:35:26 +08:00
|
|
|
return;
|
|
|
|
}
|
2000-01-18 08:55:13 +08:00
|
|
|
|
2008-06-06 08:33:52 +08:00
|
|
|
annotate_thread_changed ();
|
2005-01-14 06:08:27 +08:00
|
|
|
gdb_thread_select (uiout, tidstr, NULL);
|
2000-01-18 08:55:13 +08:00
|
|
|
}
|
|
|
|
|
2008-01-23 19:26:29 +08:00
|
|
|
/* Print notices when new threads are attached and detached. */
|
|
|
|
int print_thread_events = 1;
|
|
|
|
static void
|
|
|
|
show_print_thread_events (struct ui_file *file, int from_tty,
|
|
|
|
struct cmd_list_element *c, const char *value)
|
|
|
|
{
|
|
|
|
fprintf_filtered (file, _("\
|
|
|
|
Printing of thread events is %s.\n"),
|
|
|
|
value);
|
|
|
|
}
|
|
|
|
|
2000-01-18 08:55:13 +08:00
|
|
|
static int
|
2003-03-29 05:42:41 +08:00
|
|
|
do_captured_thread_select (struct ui_out *uiout, void *tidstr)
|
2000-01-18 08:55:13 +08:00
|
|
|
{
|
|
|
|
int num;
|
|
|
|
struct thread_info *tp;
|
|
|
|
|
2001-04-18 03:01:35 +08:00
|
|
|
num = value_as_long (parse_and_eval (tidstr));
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
tp = find_thread_id (num);
|
|
|
|
|
2000-02-03 12:14:45 +08:00
|
|
|
if (!tp)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
error (_("Thread ID %d not known."), num);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
if (!thread_alive (tp))
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
error (_("Thread ID %d has terminated."), num);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
if (non_stop)
|
|
|
|
context_switch_to (tp->ptid);
|
|
|
|
else
|
|
|
|
switch_to_thread (tp->ptid);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2000-02-03 12:14:45 +08:00
|
|
|
ui_out_text (uiout, "[Switching to thread ");
|
2001-05-04 12:15:33 +08:00
|
|
|
ui_out_field_int (uiout, "new-thread-id", pid_to_thread_id (inferior_ptid));
|
2000-02-03 12:14:45 +08:00
|
|
|
ui_out_text (uiout, " (");
|
2001-05-04 12:15:33 +08:00
|
|
|
ui_out_text (uiout, target_tid_to_str (inferior_ptid));
|
2000-02-03 12:14:45 +08:00
|
|
|
ui_out_text (uiout, ")]");
|
2000-01-18 08:55:13 +08:00
|
|
|
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
if (!tp->running_)
|
|
|
|
print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
|
|
|
|
else
|
|
|
|
ui_out_text (uiout, "(running)\n");
|
|
|
|
|
2000-01-18 08:55:13 +08:00
|
|
|
return GDB_RC_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum gdb_rc
|
2005-01-14 06:08:27 +08:00
|
|
|
gdb_thread_select (struct ui_out *uiout, char *tidstr, char **error_message)
|
2000-01-18 08:55:13 +08:00
|
|
|
{
|
2007-04-10 22:53:46 +08:00
|
|
|
if (catch_exceptions_with_msg (uiout, do_captured_thread_select, tidstr,
|
|
|
|
error_message, RETURN_MASK_ALL) < 0)
|
|
|
|
return GDB_RC_FAIL;
|
|
|
|
return GDB_RC_OK;
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Commands with a prefix of `thread'. */
|
|
|
|
struct cmd_list_element *thread_cmd_list = NULL;
|
|
|
|
|
|
|
|
void
|
2000-07-30 09:48:28 +08:00
|
|
|
_initialize_thread (void)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
static struct cmd_list_element *thread_apply_list = NULL;
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
struct cmd_list_element *c;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
c = add_info ("threads", info_threads_command,
|
|
|
|
_("IDs of currently known threads."));
|
|
|
|
set_cmd_async_ok (c);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
c = add_prefix_cmd ("thread", class_run, thread_command, _("\
|
2005-02-15 Andrew Cagney <cagney@gnu.org>
Mark up add_com, add_info and add_prefix_cmd.
* breakpoint.c, cp-support.c, dcache.c, dwarf2read.c: Update.
* exec.c, f-valprint.c, frame.c, gcore.c, gnu-nat.c: Update.
* go32-nat.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* kod.c, language.c, linux-nat.c, m32r-rom.c, macrocmd.c: Update.
* maint.c, memattr.c, mips-tdep.c, nto-procfs.c, objc-lang.c: Update.
* ocd.c, pa64solib.c, printcmd.c, procfs.c, regcache.c: Update.
* remote-e7000.c, remote-m32r-sdi.c, remote-mips.c: Update.
* remote-sds.c, remote-sim.c, remote-st.c, remote-utils.c: Update.
* remote.c, rs6000-tdep.c, ser-go32.c, serial.c: Update.
* sh-tdep.c, solib.c, somsolib.c, source.c, stack.c: Update.
* symfile.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, typeprint.c, utils.c, valprint.c: Update.
* win32-nat.c, xcoffsolib.c, cli/cli-cmds.c, cli/cli-dump.c: Update.
* cli/cli-logging.c, tui/tui-layout.c, tui/tui-regs.c: Update.
* tui/tui-stack.c, tui/tui-win.c: Update.
2005-02-15 23:49:28 +08:00
|
|
|
Use this command to switch between threads.\n\
|
|
|
|
The new thread ID must be currently known."),
|
Non-stop inferior control.
* infrun.c (resume): In non-stop mode, always resume just one
thread.
(proceed): Don't call prepare_to_proceed in non-stop mode.
(fetch_inferior_event): In non-stop mode, switch context before
handling the event.
(error_is_running, ensure_not_running): New.
(handle_inferior_event): In non-stop mode: Mark only the event
thread as stopped. Require that the target module manages adding
threads to the thread list. Assert that there isn't a
deferred_step_ptid set. Don't switch to infwait_thread_hop_state.
(normal_stop): Only mark not-running if inferior hasn't exited.
In non-stop mode, only mark the event thread.
* thread.c:Include "cli/cli-decode.h".
(print_thread_info): Don't read from a running thread.
Output "(running)" if thread is running.
(switch_to_thread): Don't read stop_pc if thread is executing.
(do_restore_current_thread_cleanup): Don't write to a running
thread.
(thread_apply_all_command): Don't read from a running thread. In
non-stop mode, do a full context-switch instead of just switching
threads.
(thread_apply_command): In non-stop mode, do a full context-switch
instead of just switching threads.
(do_captured_thread_select): Likewise. Inform user if selected
thread is running.
(_initialize_thread): Mark "info threads" and "thread" and
async_ok.
* inf-loop.c (inferior_event_handler): In non-stop mode, don't
unregister the target from the event loop.
* infcmd.c (continue_command, step_1, jump_command)
(signal_command): Ensure the selected thread isn't running.
(interrupt_target_command): In non-stop mode, interrupt only the
selected thread.
* inferior.h (error_is_running, ensure_not_running): Declare.
* target.h (struct target_ops): Add ptid argument to the to_stop
member.
(target_stop): Add ptid_t argument.
* target.c (update_current_target): Add ptid argument to to_stop's
type.
(debug_to_stop): Add ptid_t argument.
(debug_to_rcmd): Set to_stop_ptid.
* remote.c (remote_stop): Add ptid_t argument.
(async_remote_interrupt): Add inferior_ptid to target_stop.
* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.
* Makefile.in (thread.o): Depend on $(cli_decode_h).
2008-07-10 06:42:43 +08:00
|
|
|
&thread_cmd_list, "thread ", 1, &cmdlist);
|
|
|
|
set_cmd_async_ok (c);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
add_prefix_cmd ("apply", class_run, thread_apply_command,
|
2005-02-15 Andrew Cagney <cagney@gnu.org>
Mark up add_com, add_info and add_prefix_cmd.
* breakpoint.c, cp-support.c, dcache.c, dwarf2read.c: Update.
* exec.c, f-valprint.c, frame.c, gcore.c, gnu-nat.c: Update.
* go32-nat.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* kod.c, language.c, linux-nat.c, m32r-rom.c, macrocmd.c: Update.
* maint.c, memattr.c, mips-tdep.c, nto-procfs.c, objc-lang.c: Update.
* ocd.c, pa64solib.c, printcmd.c, procfs.c, regcache.c: Update.
* remote-e7000.c, remote-m32r-sdi.c, remote-mips.c: Update.
* remote-sds.c, remote-sim.c, remote-st.c, remote-utils.c: Update.
* remote.c, rs6000-tdep.c, ser-go32.c, serial.c: Update.
* sh-tdep.c, solib.c, somsolib.c, source.c, stack.c: Update.
* symfile.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, typeprint.c, utils.c, valprint.c: Update.
* win32-nat.c, xcoffsolib.c, cli/cli-cmds.c, cli/cli-dump.c: Update.
* cli/cli-logging.c, tui/tui-layout.c, tui/tui-regs.c: Update.
* tui/tui-stack.c, tui/tui-win.c: Update.
2005-02-15 23:49:28 +08:00
|
|
|
_("Apply a command to a list of threads."),
|
2005-11-15 01:03:25 +08:00
|
|
|
&thread_apply_list, "thread apply ", 1, &thread_cmd_list);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
add_cmd ("all", class_run, thread_apply_all_command,
|
2005-02-14 Andrew Cagney <cagney@gnu.org>
Mark up add_cmd.
* arch-utils.c, avr-tdep.c, breakpoint.c, corefile.c: Update.
* cp-abi.c, cp-namespace.c, cp-support.c, dummy-frame.c: Update.
* exec.c, gnu-nat.c, go32-nat.c, hppa-tdep.c, infcmd.c: Update.
* infrun.c, interps.c, macrocmd.c, maint.c, memattr.c: Update.
* mips-tdep.c, ocd.c, osabi.c, printcmd.c, regcache.c: Update.
* reggroups.c, remote-fileio.c, remote-rdi.c, remote.c: Update.
* sol-thread.c, source.c, stack.c, symfile-mem.c: Update.
* symfile.c, thread.c, tracepoint.c, valprint.c, value.c: Update.
* win32-nat.c, cli/cli-cmds.c, cli/cli-dump.c: Update.
* cli/cli-logging.c, tui/tui-regs.c: Update.
2005-02-15 02:10:11 +08:00
|
|
|
_("Apply a command to all threads."), &thread_apply_list);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
if (!xdb_commands)
|
|
|
|
add_com_alias ("t", "thread", class_run, 1);
|
2008-01-23 19:26:29 +08:00
|
|
|
|
|
|
|
add_setshow_boolean_cmd ("thread-events", no_class,
|
|
|
|
&print_thread_events, _("\
|
2008-05-09 16:14:47 +08:00
|
|
|
Set printing of thread events (such as thread start and exit)."), _("\
|
|
|
|
Show printing of thread events (such as thread start and exit)."), NULL,
|
2008-01-23 19:26:29 +08:00
|
|
|
NULL,
|
|
|
|
show_print_thread_events,
|
|
|
|
&setprintlist, &showprintlist);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|