1999-04-16 01:35:26 +00:00
|
|
|
/* Multi-process/thread control defs for GDB, the GNU debugger.
|
2005-12-17 22:34:03 +00:00
|
|
|
Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1997, 1998, 1999,
|
2008-01-01 22:53:26 +00:00
|
|
|
2000, 2007, 2008 Free Software Foundation, Inc.
|
2001-03-06 08:22:02 +00:00
|
|
|
Contributed by Lynx Real-Time Systems, Inc. Los Gatos, CA.
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
This file is part of GDB.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-07-07 20:19:36 +00: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-23 18:08:50 +00:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
1999-07-07 20:19:36 +00:00
|
|
|
(at your option) any later version.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-07-07 20:19:36 +00: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 01:35:26 +00:00
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-23 18:08:50 +00:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
#ifndef GDBTHREAD_H
|
|
|
|
#define GDBTHREAD_H
|
|
|
|
|
2003-04-12 Andrew Cagney <cagney@redhat.com>
* gdbarch.sh: Add missing opaque declarations.
* gdbarch.h: Regnerate.
* symtab.h: Add missing opaque declarations.
* value.h, target.h, symfile.h, stabsread.h: Ditto.
* x86-64-tdep.h, xmodem.h, monitor.h, typeprint.h: Ditto.
* srec.h, solib-svr4.h, source.h, inferior.h: Ditto.
* ser-unix.h, serial.h, remote-utils.h, gdbcore.h: Ditto.
* ppc-tdep.h, ocd.h, mips-tdep.h, gdbtypes.h: Ditto.
* buildsym.h, builtin-regs.h, linespec.h, language.h: Ditto.
* i387-tdep.h, gdbthread.h, event-top.h, gdb.h: Ditto.
* dwarf2cfi.h, doublest.h, disasm.h, cp-abi.h: Ditto.
* cli-out.h, c-lang.h, ax-gdb.h, arch-utils.h: Ditto.
* ada-lang.h, config/nm-lynx.h, config/nm-linux.h: Ditto.
* config/sparc/tm-sp64.h, config/rs6000/tm-rs6000.h: Ditto.
* config/pa/tm-hppah.h, config/m68k/tm-delta68.h: Ditto.
* cli/cli-setshow.h, cli/cli-script.h: Ditto.
2003-04-12 17:41:26 +00:00
|
|
|
struct symtab;
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
#include "breakpoint.h"
|
2002-12-06 07:35:55 +00:00
|
|
|
#include "frame.h"
|
2008-03-15 13:53:25 +00:00
|
|
|
#include "ui-out.h"
|
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-09 22:30:46 +00:00
|
|
|
#include "inferior.h"
|
2008-03-15 13:53:25 +00:00
|
|
|
|
2000-01-11 03:07:37 +00:00
|
|
|
struct thread_info
|
|
|
|
{
|
|
|
|
struct thread_info *next;
|
2001-05-04 04:15:33 +00:00
|
|
|
ptid_t ptid; /* "Actual process id";
|
2000-01-11 03:07:37 +00:00
|
|
|
In fact, this may be overloaded with
|
|
|
|
kernel thread id, etc. */
|
|
|
|
int num; /* Convenient handle (GDB thread id) */
|
2008-07-09 22:16:15 +00:00
|
|
|
|
|
|
|
/* Non-zero means the thread is executing. Note: this is different
|
|
|
|
from saying that there is an active target and we are stopped at
|
|
|
|
a breakpoint, for instance. This is a real indicator whether the
|
|
|
|
thread is off and running. */
|
|
|
|
/* This field is internal to thread.c. Never access it directly,
|
|
|
|
use is_executing instead. */
|
|
|
|
int executing_;
|
|
|
|
|
Exited threads.
* thread.c (enum thread_state): New.
(thread_state main_thread_running): Delete, in favor of...
(thread_state main_thread_state): ... this. Update throughout.
(clear_thread_inferior_resources): New, split from free_thread.
(free_thread): Call clear_thread_inferior_resources.
(init_thread_list): Set main thread to stopped state.
(add_thread_silent): Take care of PTID reuses.
(delete_thread): If deleting inferior_ptid or a thread with
refcount > 0, mark it as exited, but still keep it in the list.
Only notify of thread exits, if we haven't done so yet.
(iterate_over_threads): Make it safe to delete threads while
iterating over them.
(do_captured_list_thread_ids): Don't account for exited threads.
(thread_alive): Check for the THREAD_EXITED state, and don't set
ptid to -1 on exited threads.
(set_running): Update to account for extra possible states.
(is_thread_state): New.
(is_stopped, is_exited): New.
(is_running): Implement in terms of is_thread_state.
(any_running): Update.
(print_thread_info): Update. Account for exited threads. Don't
warn about missed frame restoring here, its done in the cleanup.
(switch_to_thread): Don't read from a thread that has gone.
(restore_current_thread): In non-stop mode, do a full context
switch.
(restore_selected_frame): Add a frame_level argument. Rewrite.
(struct current_thread_cleanup): Add selected_frame_level and
was_stopped members.
(do_restore_current_thread_cleanup): Check if thread was stopped
and still is, and if the target has registers, stack and memory
before restoring the selected frame. Don't delete the cleanup
argument here.
(restore_current_thread_cleanup_dtor): New.
(make_cleanup_restore_current_thread): Remove all arguments.
Rewrite.
(thread_apply_all_command): Update. Prune threads.
(thread_apply_command): Update.
(thread_command): Account for currently selected exited thread.
(do_captured_thread_select): Check for a running thread. Prune
threads.
(_initialize_thread): Make "info threads", "thread", "thread
apply", and "thread apply all" appliable without a selected thread.
* gdbthread.h (struct thread_info): Replace running_ by state_.
Add refcount.
(is_exited, is_stopped): Declare.
(make_cleanup_restore_current_thread): Remove all arguments.
* infrun.c: Include "event-top.h".
(fetch_inferior_event): In non-stop mode, restore selected thread
and frame after handling the event and running breakpoint
commands. Display GDB prompt if needed.
(normal_stop): In non-stop mode, don't print thread switching
notice.
* cli/cli-decode.c (set_cmd_no_selected_thread_ok)
(get_cmd_no_selected_thread_ok): New.
* cli/cli-decode.h (CMD_NO_SELECTED_THREAD_OK): New.
(set_cmd_no_selected_thread_ok, get_cmd_no_selected_thread_ok):
Declare.
* cli/cli-cmds.c: Set "pwd", "help", "info", "show" as
no-selected-thread ok.
* top.c (execute_command): Check for non no-selected-thread-ok
commands.
* linux-nat.c (struct saved_ptids, threads_to_delete)
(record_dead_thread, prune_lwps): Delete.
(exit_lwp): Unconditionally delete thread.
(linux_nat_resume): Remove prune_lwps call.
* infcmd.c (proceed_thread_callback): Check if !is_stopped instead
of is_running. Adjust to make_cleanup_restore_current_thread
interface change.
* mi/mi-main.c (mi_cmd_execute): Only allow a few commands if the
selected thread has exited.
* inf-loop.c (inferior_event_handler): Don't display the prompt
here.
* varobj.c (c_value_of_root): Update.
* defs.h (make_cleanup_dtor): Declare.
* utils.c (make_cleanup_dtor): New.
* Makefile.in (infrun.o): Depend on $(event_top_h).
2008-07-11 11:07:39 +00:00
|
|
|
/* Frontend view of the thread state. Note that the RUNNING/STOPPED
|
|
|
|
states are different from EXECUTING. When the thread is stopped
|
|
|
|
internally while handling an internal event, like a software
|
|
|
|
single-step breakpoint, EXECUTING will be false, but running will
|
|
|
|
still be true. As a possible future extension, this could turn
|
|
|
|
into enum { stopped, exited, stepping, finishing, until(ling),
|
|
|
|
running ... } */
|
2008-07-09 22:16:15 +00:00
|
|
|
/* This field is internal to thread.c. Never access it directly,
|
|
|
|
use is_running instead. */
|
Exited threads.
* thread.c (enum thread_state): New.
(thread_state main_thread_running): Delete, in favor of...
(thread_state main_thread_state): ... this. Update throughout.
(clear_thread_inferior_resources): New, split from free_thread.
(free_thread): Call clear_thread_inferior_resources.
(init_thread_list): Set main thread to stopped state.
(add_thread_silent): Take care of PTID reuses.
(delete_thread): If deleting inferior_ptid or a thread with
refcount > 0, mark it as exited, but still keep it in the list.
Only notify of thread exits, if we haven't done so yet.
(iterate_over_threads): Make it safe to delete threads while
iterating over them.
(do_captured_list_thread_ids): Don't account for exited threads.
(thread_alive): Check for the THREAD_EXITED state, and don't set
ptid to -1 on exited threads.
(set_running): Update to account for extra possible states.
(is_thread_state): New.
(is_stopped, is_exited): New.
(is_running): Implement in terms of is_thread_state.
(any_running): Update.
(print_thread_info): Update. Account for exited threads. Don't
warn about missed frame restoring here, its done in the cleanup.
(switch_to_thread): Don't read from a thread that has gone.
(restore_current_thread): In non-stop mode, do a full context
switch.
(restore_selected_frame): Add a frame_level argument. Rewrite.
(struct current_thread_cleanup): Add selected_frame_level and
was_stopped members.
(do_restore_current_thread_cleanup): Check if thread was stopped
and still is, and if the target has registers, stack and memory
before restoring the selected frame. Don't delete the cleanup
argument here.
(restore_current_thread_cleanup_dtor): New.
(make_cleanup_restore_current_thread): Remove all arguments.
Rewrite.
(thread_apply_all_command): Update. Prune threads.
(thread_apply_command): Update.
(thread_command): Account for currently selected exited thread.
(do_captured_thread_select): Check for a running thread. Prune
threads.
(_initialize_thread): Make "info threads", "thread", "thread
apply", and "thread apply all" appliable without a selected thread.
* gdbthread.h (struct thread_info): Replace running_ by state_.
Add refcount.
(is_exited, is_stopped): Declare.
(make_cleanup_restore_current_thread): Remove all arguments.
* infrun.c: Include "event-top.h".
(fetch_inferior_event): In non-stop mode, restore selected thread
and frame after handling the event and running breakpoint
commands. Display GDB prompt if needed.
(normal_stop): In non-stop mode, don't print thread switching
notice.
* cli/cli-decode.c (set_cmd_no_selected_thread_ok)
(get_cmd_no_selected_thread_ok): New.
* cli/cli-decode.h (CMD_NO_SELECTED_THREAD_OK): New.
(set_cmd_no_selected_thread_ok, get_cmd_no_selected_thread_ok):
Declare.
* cli/cli-cmds.c: Set "pwd", "help", "info", "show" as
no-selected-thread ok.
* top.c (execute_command): Check for non no-selected-thread-ok
commands.
* linux-nat.c (struct saved_ptids, threads_to_delete)
(record_dead_thread, prune_lwps): Delete.
(exit_lwp): Unconditionally delete thread.
(linux_nat_resume): Remove prune_lwps call.
* infcmd.c (proceed_thread_callback): Check if !is_stopped instead
of is_running. Adjust to make_cleanup_restore_current_thread
interface change.
* mi/mi-main.c (mi_cmd_execute): Only allow a few commands if the
selected thread has exited.
* inf-loop.c (inferior_event_handler): Don't display the prompt
here.
* varobj.c (c_value_of_root): Update.
* defs.h (make_cleanup_dtor): Declare.
* utils.c (make_cleanup_dtor): New.
* Makefile.in (infrun.o): Depend on $(event_top_h).
2008-07-11 11:07:39 +00:00
|
|
|
int state_;
|
|
|
|
|
|
|
|
/* If this is > 0, then it means there's code out there that relies
|
|
|
|
on this thread being listed. Don't delete it from the lists even
|
|
|
|
if we detect it exiting. */
|
|
|
|
int refcount;
|
2008-07-09 22:16:15 +00:00
|
|
|
|
2000-01-11 03:07:37 +00:00
|
|
|
/* State from wait_for_inferior */
|
|
|
|
CORE_ADDR prev_pc;
|
|
|
|
struct breakpoint *step_resume_breakpoint;
|
|
|
|
CORE_ADDR step_range_start;
|
|
|
|
CORE_ADDR step_range_end;
|
2002-12-06 07:35:55 +00:00
|
|
|
struct frame_id step_frame_id;
|
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-13 22:56:16 +00:00
|
|
|
int current_line;
|
|
|
|
struct symtab *current_symtab;
|
2000-01-11 03:07:37 +00:00
|
|
|
int trap_expected;
|
2007-12-06 12:57:51 +00:00
|
|
|
int stepping_over_breakpoint;
|
2000-01-11 03:07:37 +00:00
|
|
|
|
|
|
|
/* This is set TRUE when a catchpoint of a shared library event
|
|
|
|
triggers. Since we don't wish to leave the inferior in the
|
|
|
|
solib hook when we report the event, we step the inferior
|
|
|
|
back to user code before stopping and reporting the event. */
|
|
|
|
int stepping_through_solib_after_catch;
|
|
|
|
|
|
|
|
/* When stepping_through_solib_after_catch is TRUE, this is a
|
|
|
|
list of the catchpoints that should be reported as triggering
|
|
|
|
when we finally do stop stepping. */
|
|
|
|
bpstat stepping_through_solib_catchpoints;
|
|
|
|
|
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-09 22:30:46 +00:00
|
|
|
/* The below are only per-thread in non-stop mode. */
|
|
|
|
/* Per-thread command support. */
|
|
|
|
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;
|
|
|
|
/* Used in continue_command to set the proceed count of the
|
|
|
|
breakpoint the thread stopped at. */
|
|
|
|
bpstat stop_bpstat;
|
|
|
|
|
2000-01-11 03:07:37 +00:00
|
|
|
/* Private data used by the target vector implementation. */
|
|
|
|
struct private_thread_info *private;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Create an empty thread list, or empty the existing one. */
|
|
|
|
extern void init_thread_list (void);
|
|
|
|
|
2008-01-23 11:26:29 +00:00
|
|
|
/* Add a thread to the thread list, print a message
|
|
|
|
that a new thread is found, and return the pointer to
|
|
|
|
the new thread. Caller my use this pointer to
|
|
|
|
initialize the private thread data. */
|
2001-05-04 04:15:33 +00:00
|
|
|
extern struct thread_info *add_thread (ptid_t ptid);
|
2000-01-11 03:07:37 +00:00
|
|
|
|
2008-01-23 11:26:29 +00:00
|
|
|
/* Same as add_thread, but does not print a message
|
|
|
|
about new thread. */
|
|
|
|
extern struct thread_info *add_thread_silent (ptid_t 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 15:44:53 +00:00
|
|
|
/* Same as add_thread, and sets the private info. */
|
|
|
|
extern struct thread_info *add_thread_with_info (ptid_t ptid,
|
|
|
|
struct private_thread_info *);
|
|
|
|
|
2000-01-11 03:07:37 +00:00
|
|
|
/* Delete an existing thread list entry. */
|
2001-05-04 04:15:33 +00:00
|
|
|
extern void delete_thread (ptid_t);
|
2000-01-11 03:07:37 +00:00
|
|
|
|
2008-07-09 10:58:41 +00:00
|
|
|
/* Delete an existing thread list entry, and be quiet about it. Used
|
|
|
|
after the process this thread having belonged to having already
|
|
|
|
exited, for example. */
|
|
|
|
extern void delete_thread_silent (ptid_t);
|
|
|
|
|
2001-06-02 00:36:20 +00:00
|
|
|
/* Delete a step_resume_breakpoint from the thread database. */
|
|
|
|
extern void delete_step_resume_breakpoint (void *);
|
|
|
|
|
2000-01-11 03:07:37 +00:00
|
|
|
/* Translate the integer thread id (GDB's homegrown id, not the system's)
|
|
|
|
into a "pid" (which may be overloaded with extra thread information). */
|
2001-05-04 04:15:33 +00:00
|
|
|
extern ptid_t thread_id_to_pid (int);
|
2000-01-11 03:07:37 +00:00
|
|
|
|
|
|
|
/* Translate a 'pid' (which may be overloaded with extra thread information)
|
|
|
|
into the integer thread id (GDB's homegrown id, not the system's). */
|
2001-05-04 04:15:33 +00:00
|
|
|
extern int pid_to_thread_id (ptid_t ptid);
|
2000-01-11 03:07:37 +00:00
|
|
|
|
|
|
|
/* Boolean test for an already-known pid (which may be overloaded with
|
|
|
|
extra thread information). */
|
2001-05-04 04:15:33 +00:00
|
|
|
extern int in_thread_list (ptid_t ptid);
|
2000-01-11 03:07:37 +00:00
|
|
|
|
|
|
|
/* Boolean test for an already-known thread id (GDB's homegrown id,
|
|
|
|
not the system's). */
|
|
|
|
extern int valid_thread_id (int thread);
|
|
|
|
|
|
|
|
/* Search function to lookup a thread by 'pid'. */
|
2001-05-04 04:15:33 +00:00
|
|
|
extern struct thread_info *find_thread_pid (ptid_t ptid);
|
2000-01-11 03:07:37 +00:00
|
|
|
|
2008-07-12 16:37:57 +00:00
|
|
|
/* Find thread by GDB user-visible thread number. */
|
|
|
|
struct thread_info *find_thread_id (int num);
|
|
|
|
|
2000-01-11 03:07:37 +00:00
|
|
|
/* Iterator function to call a user-provided callback function
|
|
|
|
once for each known thread. */
|
|
|
|
typedef int (*thread_callback_func) (struct thread_info *, void *);
|
|
|
|
extern struct thread_info *iterate_over_threads (thread_callback_func, void *);
|
|
|
|
|
2008-06-28 09:42:15 +00:00
|
|
|
extern int thread_count (void);
|
|
|
|
|
2000-01-11 03:07:37 +00:00
|
|
|
/* infrun context switch: save the debugger state for the given thread. */
|
2001-05-04 04:15:33 +00:00
|
|
|
extern void save_infrun_state (ptid_t ptid,
|
2000-01-11 03:07:37 +00:00
|
|
|
CORE_ADDR prev_pc,
|
|
|
|
int trap_expected,
|
|
|
|
struct breakpoint *step_resume_breakpoint,
|
|
|
|
CORE_ADDR step_range_start,
|
|
|
|
CORE_ADDR step_range_end,
|
2002-12-06 07:35:55 +00:00
|
|
|
const struct frame_id *step_frame_id,
|
2000-01-11 03:07:37 +00:00
|
|
|
int another_trap,
|
|
|
|
int stepping_through_solib_after_catch,
|
|
|
|
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-13 22:56:16 +00: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-09 22:30:46 +00: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);
|
2000-01-11 03:07:37 +00:00
|
|
|
|
|
|
|
/* infrun context switch: load the debugger state previously saved
|
|
|
|
for the given thread. */
|
2001-05-04 04:15:33 +00:00
|
|
|
extern void load_infrun_state (ptid_t ptid,
|
2000-01-11 03:07:37 +00:00
|
|
|
CORE_ADDR *prev_pc,
|
|
|
|
int *trap_expected,
|
|
|
|
struct breakpoint **step_resume_breakpoint,
|
|
|
|
CORE_ADDR *step_range_start,
|
|
|
|
CORE_ADDR *step_range_end,
|
2002-12-06 07:35:55 +00:00
|
|
|
struct frame_id *step_frame_id,
|
2000-01-11 03:07:37 +00:00
|
|
|
int *another_trap,
|
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-09 22:30:46 +00:00
|
|
|
int *stepping_through_solib_after_catch,
|
2000-01-11 03:07:37 +00: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-13 22:56:16 +00: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-09 22:30:46 +00: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 01:35:26 +00:00
|
|
|
|
2007-09-10 18:49:26 +00:00
|
|
|
/* Switch from one thread to another. */
|
|
|
|
extern void switch_to_thread (ptid_t ptid);
|
|
|
|
|
2008-06-10 10:23:54 +00:00
|
|
|
/* Marks thread PTID is running, or stopped.
|
|
|
|
If PIDGET (PTID) is -1, marks all threads. */
|
|
|
|
extern void set_running (ptid_t ptid, int running);
|
|
|
|
|
2008-07-09 22:16:15 +00:00
|
|
|
/* Reports if thread PTID is known to be running right now. */
|
2008-06-10 10:23:54 +00:00
|
|
|
extern int is_running (ptid_t ptid);
|
|
|
|
|
2008-07-09 22:16:15 +00:00
|
|
|
/* Reports if any thread is known to be running right now. */
|
|
|
|
extern int any_running (void);
|
|
|
|
|
Exited threads.
* thread.c (enum thread_state): New.
(thread_state main_thread_running): Delete, in favor of...
(thread_state main_thread_state): ... this. Update throughout.
(clear_thread_inferior_resources): New, split from free_thread.
(free_thread): Call clear_thread_inferior_resources.
(init_thread_list): Set main thread to stopped state.
(add_thread_silent): Take care of PTID reuses.
(delete_thread): If deleting inferior_ptid or a thread with
refcount > 0, mark it as exited, but still keep it in the list.
Only notify of thread exits, if we haven't done so yet.
(iterate_over_threads): Make it safe to delete threads while
iterating over them.
(do_captured_list_thread_ids): Don't account for exited threads.
(thread_alive): Check for the THREAD_EXITED state, and don't set
ptid to -1 on exited threads.
(set_running): Update to account for extra possible states.
(is_thread_state): New.
(is_stopped, is_exited): New.
(is_running): Implement in terms of is_thread_state.
(any_running): Update.
(print_thread_info): Update. Account for exited threads. Don't
warn about missed frame restoring here, its done in the cleanup.
(switch_to_thread): Don't read from a thread that has gone.
(restore_current_thread): In non-stop mode, do a full context
switch.
(restore_selected_frame): Add a frame_level argument. Rewrite.
(struct current_thread_cleanup): Add selected_frame_level and
was_stopped members.
(do_restore_current_thread_cleanup): Check if thread was stopped
and still is, and if the target has registers, stack and memory
before restoring the selected frame. Don't delete the cleanup
argument here.
(restore_current_thread_cleanup_dtor): New.
(make_cleanup_restore_current_thread): Remove all arguments.
Rewrite.
(thread_apply_all_command): Update. Prune threads.
(thread_apply_command): Update.
(thread_command): Account for currently selected exited thread.
(do_captured_thread_select): Check for a running thread. Prune
threads.
(_initialize_thread): Make "info threads", "thread", "thread
apply", and "thread apply all" appliable without a selected thread.
* gdbthread.h (struct thread_info): Replace running_ by state_.
Add refcount.
(is_exited, is_stopped): Declare.
(make_cleanup_restore_current_thread): Remove all arguments.
* infrun.c: Include "event-top.h".
(fetch_inferior_event): In non-stop mode, restore selected thread
and frame after handling the event and running breakpoint
commands. Display GDB prompt if needed.
(normal_stop): In non-stop mode, don't print thread switching
notice.
* cli/cli-decode.c (set_cmd_no_selected_thread_ok)
(get_cmd_no_selected_thread_ok): New.
* cli/cli-decode.h (CMD_NO_SELECTED_THREAD_OK): New.
(set_cmd_no_selected_thread_ok, get_cmd_no_selected_thread_ok):
Declare.
* cli/cli-cmds.c: Set "pwd", "help", "info", "show" as
no-selected-thread ok.
* top.c (execute_command): Check for non no-selected-thread-ok
commands.
* linux-nat.c (struct saved_ptids, threads_to_delete)
(record_dead_thread, prune_lwps): Delete.
(exit_lwp): Unconditionally delete thread.
(linux_nat_resume): Remove prune_lwps call.
* infcmd.c (proceed_thread_callback): Check if !is_stopped instead
of is_running. Adjust to make_cleanup_restore_current_thread
interface change.
* mi/mi-main.c (mi_cmd_execute): Only allow a few commands if the
selected thread has exited.
* inf-loop.c (inferior_event_handler): Don't display the prompt
here.
* varobj.c (c_value_of_root): Update.
* defs.h (make_cleanup_dtor): Declare.
* utils.c (make_cleanup_dtor): New.
* Makefile.in (infrun.o): Depend on $(event_top_h).
2008-07-11 11:07:39 +00:00
|
|
|
/* Is this thread listed, but known to have exited? We keep it listed
|
|
|
|
(but not visible) until it's safe to delete. */
|
|
|
|
extern int is_exited (ptid_t ptid);
|
|
|
|
|
|
|
|
/* Is this thread stopped? */
|
|
|
|
extern int is_stopped (ptid_t ptid);
|
|
|
|
|
2008-07-09 22:16:15 +00:00
|
|
|
/* Marks thread PTID as executing, or as stopped.
|
|
|
|
If PIDGET (PTID) is -1, marks all threads. */
|
|
|
|
extern void set_executing (ptid_t ptid, int executing);
|
|
|
|
|
|
|
|
/* Reports if thread PTID is executing. */
|
|
|
|
extern int is_executing (ptid_t ptid);
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
/* Commands with a prefix of `thread'. */
|
|
|
|
extern struct cmd_list_element *thread_cmd_list;
|
|
|
|
|
2008-01-23 11:26:29 +00:00
|
|
|
/* Print notices on thread events (attach, detach, etc.), set with
|
|
|
|
`set print thread-events'. */
|
|
|
|
extern int print_thread_events;
|
|
|
|
|
2008-03-15 13:53:25 +00:00
|
|
|
extern void print_thread_info (struct ui_out *uiout, int thread);
|
|
|
|
|
Exited threads.
* thread.c (enum thread_state): New.
(thread_state main_thread_running): Delete, in favor of...
(thread_state main_thread_state): ... this. Update throughout.
(clear_thread_inferior_resources): New, split from free_thread.
(free_thread): Call clear_thread_inferior_resources.
(init_thread_list): Set main thread to stopped state.
(add_thread_silent): Take care of PTID reuses.
(delete_thread): If deleting inferior_ptid or a thread with
refcount > 0, mark it as exited, but still keep it in the list.
Only notify of thread exits, if we haven't done so yet.
(iterate_over_threads): Make it safe to delete threads while
iterating over them.
(do_captured_list_thread_ids): Don't account for exited threads.
(thread_alive): Check for the THREAD_EXITED state, and don't set
ptid to -1 on exited threads.
(set_running): Update to account for extra possible states.
(is_thread_state): New.
(is_stopped, is_exited): New.
(is_running): Implement in terms of is_thread_state.
(any_running): Update.
(print_thread_info): Update. Account for exited threads. Don't
warn about missed frame restoring here, its done in the cleanup.
(switch_to_thread): Don't read from a thread that has gone.
(restore_current_thread): In non-stop mode, do a full context
switch.
(restore_selected_frame): Add a frame_level argument. Rewrite.
(struct current_thread_cleanup): Add selected_frame_level and
was_stopped members.
(do_restore_current_thread_cleanup): Check if thread was stopped
and still is, and if the target has registers, stack and memory
before restoring the selected frame. Don't delete the cleanup
argument here.
(restore_current_thread_cleanup_dtor): New.
(make_cleanup_restore_current_thread): Remove all arguments.
Rewrite.
(thread_apply_all_command): Update. Prune threads.
(thread_apply_command): Update.
(thread_command): Account for currently selected exited thread.
(do_captured_thread_select): Check for a running thread. Prune
threads.
(_initialize_thread): Make "info threads", "thread", "thread
apply", and "thread apply all" appliable without a selected thread.
* gdbthread.h (struct thread_info): Replace running_ by state_.
Add refcount.
(is_exited, is_stopped): Declare.
(make_cleanup_restore_current_thread): Remove all arguments.
* infrun.c: Include "event-top.h".
(fetch_inferior_event): In non-stop mode, restore selected thread
and frame after handling the event and running breakpoint
commands. Display GDB prompt if needed.
(normal_stop): In non-stop mode, don't print thread switching
notice.
* cli/cli-decode.c (set_cmd_no_selected_thread_ok)
(get_cmd_no_selected_thread_ok): New.
* cli/cli-decode.h (CMD_NO_SELECTED_THREAD_OK): New.
(set_cmd_no_selected_thread_ok, get_cmd_no_selected_thread_ok):
Declare.
* cli/cli-cmds.c: Set "pwd", "help", "info", "show" as
no-selected-thread ok.
* top.c (execute_command): Check for non no-selected-thread-ok
commands.
* linux-nat.c (struct saved_ptids, threads_to_delete)
(record_dead_thread, prune_lwps): Delete.
(exit_lwp): Unconditionally delete thread.
(linux_nat_resume): Remove prune_lwps call.
* infcmd.c (proceed_thread_callback): Check if !is_stopped instead
of is_running. Adjust to make_cleanup_restore_current_thread
interface change.
* mi/mi-main.c (mi_cmd_execute): Only allow a few commands if the
selected thread has exited.
* inf-loop.c (inferior_event_handler): Don't display the prompt
here.
* varobj.c (c_value_of_root): Update.
* defs.h (make_cleanup_dtor): Declare.
* utils.c (make_cleanup_dtor): New.
* Makefile.in (infrun.o): Depend on $(event_top_h).
2008-07-11 11:07:39 +00:00
|
|
|
extern struct cleanup *make_cleanup_restore_current_thread (void);
|
2008-03-23 09:53:52 +00:00
|
|
|
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
#endif /* GDBTHREAD_H */
|