1999-04-16 09:35:26 +08:00
|
|
|
/* Multi-process/thread control defs for GDB, the GNU debugger.
|
2005-12-18 06:34:03 +08:00
|
|
|
Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1997, 1998, 1999,
|
2008-01-02 06:53:26 +08:00
|
|
|
2000, 2007, 2008 Free Software Foundation, Inc.
|
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
|
|
|
|
|
|
|
#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-13 01:41:26 +08:00
|
|
|
struct breakpoint;
|
|
|
|
struct frame_id;
|
|
|
|
struct symtab;
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
/* For bpstat */
|
|
|
|
#include "breakpoint.h"
|
|
|
|
|
2002-12-06 15:35:55 +08:00
|
|
|
/* For struct frame_id. */
|
|
|
|
#include "frame.h"
|
|
|
|
|
2008-03-15 21:53:25 +08:00
|
|
|
#include "ui-out.h"
|
|
|
|
|
2000-01-11 11:07:37 +08:00
|
|
|
struct thread_info
|
|
|
|
{
|
|
|
|
struct thread_info *next;
|
2001-05-04 12:15:33 +08:00
|
|
|
ptid_t ptid; /* "Actual process id";
|
2000-01-11 11:07:37 +08:00
|
|
|
In fact, this may be overloaded with
|
|
|
|
kernel thread id, etc. */
|
|
|
|
int num; /* Convenient handle (GDB thread id) */
|
2008-07-10 06:16:15 +08: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_;
|
|
|
|
|
|
|
|
/* Frontend view of the running state. Note that this is 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, stepping, finishing, until(ling), ... } */
|
|
|
|
/* This field is internal to thread.c. Never access it directly,
|
|
|
|
use is_running instead. */
|
|
|
|
int running_;
|
|
|
|
|
2000-01-11 11:07:37 +08: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 15:35:55 +08: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-14 06:56:16 +08:00
|
|
|
int current_line;
|
|
|
|
struct symtab *current_symtab;
|
2000-01-11 11:07:37 +08:00
|
|
|
int trap_expected;
|
2007-12-06 20:57:51 +08:00
|
|
|
int stepping_over_breakpoint;
|
2000-01-11 11:07:37 +08: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;
|
|
|
|
|
|
|
|
/* 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 19:26:29 +08: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 12:15:33 +08:00
|
|
|
extern struct thread_info *add_thread (ptid_t ptid);
|
2000-01-11 11:07:37 +08:00
|
|
|
|
2008-01-23 19:26:29 +08: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 23:44:53 +08: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 11:07:37 +08:00
|
|
|
/* Delete an existing thread list entry. */
|
2001-05-04 12:15:33 +08:00
|
|
|
extern void delete_thread (ptid_t);
|
2000-01-11 11:07:37 +08:00
|
|
|
|
2008-07-09 18:58:41 +08: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 08:36:20 +08:00
|
|
|
/* Delete a step_resume_breakpoint from the thread database. */
|
|
|
|
extern void delete_step_resume_breakpoint (void *);
|
|
|
|
|
2000-01-11 11:07:37 +08: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 12:15:33 +08:00
|
|
|
extern ptid_t thread_id_to_pid (int);
|
2000-01-11 11:07:37 +08: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 12:15:33 +08:00
|
|
|
extern int pid_to_thread_id (ptid_t ptid);
|
2000-01-11 11:07:37 +08:00
|
|
|
|
|
|
|
/* Boolean test for an already-known pid (which may be overloaded with
|
|
|
|
extra thread information). */
|
2001-05-04 12:15:33 +08:00
|
|
|
extern int in_thread_list (ptid_t ptid);
|
2000-01-11 11:07:37 +08: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 12:15:33 +08:00
|
|
|
extern struct thread_info *find_thread_pid (ptid_t ptid);
|
2000-01-11 11:07:37 +08: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 17:42:15 +08:00
|
|
|
extern int thread_count (void);
|
|
|
|
|
2000-01-11 11:07:37 +08:00
|
|
|
/* infrun context switch: save the debugger state for the given thread. */
|
2001-05-04 12:15:33 +08:00
|
|
|
extern void save_infrun_state (ptid_t ptid,
|
2000-01-11 11:07:37 +08: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 15:35:55 +08:00
|
|
|
const struct frame_id *step_frame_id,
|
2000-01-11 11:07:37 +08: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-14 06:56:16 +08:00
|
|
|
int current_line,
|
2004-05-13 06:19:02 +08:00
|
|
|
struct symtab *current_symtab);
|
2000-01-11 11:07:37 +08:00
|
|
|
|
|
|
|
/* infrun context switch: load the debugger state previously saved
|
|
|
|
for the given thread. */
|
2001-05-04 12:15:33 +08:00
|
|
|
extern void load_infrun_state (ptid_t ptid,
|
2000-01-11 11:07:37 +08: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 15:35:55 +08:00
|
|
|
struct frame_id *step_frame_id,
|
2000-01-11 11:07:37 +08:00
|
|
|
int *another_trap,
|
|
|
|
int *stepping_through_solib_affter_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-14 06:56:16 +08:00
|
|
|
int *current_line,
|
2004-05-13 06:19:02 +08:00
|
|
|
struct symtab **current_symtab);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2007-09-11 02:49:26 +08:00
|
|
|
/* Switch from one thread to another. */
|
|
|
|
extern void switch_to_thread (ptid_t ptid);
|
|
|
|
|
2008-06-10 18:23:54 +08: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-10 06:16:15 +08:00
|
|
|
/* Reports if thread PTID is known to be running right now. */
|
2008-06-10 18:23:54 +08:00
|
|
|
extern int is_running (ptid_t ptid);
|
|
|
|
|
2008-07-10 06:16:15 +08:00
|
|
|
/* Reports if any thread is known to be running right now. */
|
|
|
|
extern int any_running (void);
|
|
|
|
|
|
|
|
/* 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 09:35:26 +08:00
|
|
|
/* Commands with a prefix of `thread'. */
|
|
|
|
extern struct cmd_list_element *thread_cmd_list;
|
|
|
|
|
2008-01-23 19:26:29 +08:00
|
|
|
/* Print notices on thread events (attach, detach, etc.), set with
|
|
|
|
`set print thread-events'. */
|
|
|
|
extern int print_thread_events;
|
|
|
|
|
2008-03-15 21:53:25 +08:00
|
|
|
extern void print_thread_info (struct ui_out *uiout, int thread);
|
|
|
|
|
2008-03-23 17:53:52 +08:00
|
|
|
extern struct cleanup *make_cleanup_restore_current_thread (ptid_t,
|
|
|
|
struct frame_id);
|
|
|
|
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
#endif /* GDBTHREAD_H */
|