146283Sdfr/* Multi-process/thread control defs for GDB, the GNU debugger.
298944Sobrien   Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1997, 1998, 1999,
398944Sobrien   2000
498944Sobrien   Free Software Foundation, Inc.
546283Sdfr   Contributed by Lynx Real-Time Systems, Inc.  Los Gatos, CA.
698944Sobrien
746283Sdfr
898944Sobrien   This file is part of GDB.
946283Sdfr
1098944Sobrien   This program is free software; you can redistribute it and/or modify
1198944Sobrien   it under the terms of the GNU General Public License as published by
1298944Sobrien   the Free Software Foundation; either version 2 of the License, or
1398944Sobrien   (at your option) any later version.
1446283Sdfr
1598944Sobrien   This program is distributed in the hope that it will be useful,
1698944Sobrien   but WITHOUT ANY WARRANTY; without even the implied warranty of
1798944Sobrien   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1898944Sobrien   GNU General Public License for more details.
1946283Sdfr
2098944Sobrien   You should have received a copy of the GNU General Public License
2198944Sobrien   along with this program; if not, write to the Free Software
2298944Sobrien   Foundation, Inc., 59 Temple Place - Suite 330,
2398944Sobrien   Boston, MA 02111-1307, USA.  */
2446283Sdfr
2546283Sdfr#ifndef GDBTHREAD_H
2646283Sdfr#define GDBTHREAD_H
2746283Sdfr
28130803Smarcelstruct breakpoint;
29130803Smarcelstruct frame_id;
30130803Smarcelstruct symtab;
31130803Smarcel
3246283Sdfr/* For bpstat */
3346283Sdfr#include "breakpoint.h"
3446283Sdfr
35130803Smarcel/* For struct frame_id.  */
36130803Smarcel#include "frame.h"
37130803Smarcel
3898944Sobrienstruct thread_info
3998944Sobrien{
4098944Sobrien  struct thread_info *next;
4198944Sobrien  ptid_t ptid;			/* "Actual process id";
4298944Sobrien				    In fact, this may be overloaded with
4398944Sobrien				    kernel thread id, etc.  */
4498944Sobrien  int num;			/* Convenient handle (GDB thread id) */
4598944Sobrien  /* State from wait_for_inferior */
4698944Sobrien  CORE_ADDR prev_pc;
4798944Sobrien  struct breakpoint *step_resume_breakpoint;
4898944Sobrien  struct breakpoint *through_sigtramp_breakpoint;
4998944Sobrien  CORE_ADDR step_range_start;
5098944Sobrien  CORE_ADDR step_range_end;
51130803Smarcel  struct frame_id step_frame_id;
5298944Sobrien  CORE_ADDR step_sp;
5398944Sobrien  int current_line;
5498944Sobrien  struct symtab *current_symtab;
5598944Sobrien  int trap_expected;
5698944Sobrien  int handling_longjmp;
5798944Sobrien  int another_trap;
5846283Sdfr
5998944Sobrien  /* This is set TRUE when a catchpoint of a shared library event
6098944Sobrien     triggers.  Since we don't wish to leave the inferior in the
6198944Sobrien     solib hook when we report the event, we step the inferior
6298944Sobrien     back to user code before stopping and reporting the event.  */
6398944Sobrien  int stepping_through_solib_after_catch;
6446283Sdfr
6598944Sobrien  /* When stepping_through_solib_after_catch is TRUE, this is a
6698944Sobrien     list of the catchpoints that should be reported as triggering
6798944Sobrien     when we finally do stop stepping.  */
6898944Sobrien  bpstat stepping_through_solib_catchpoints;
6946283Sdfr
7098944Sobrien  /* This is set to TRUE when this thread is in a signal handler
7198944Sobrien     trampoline and we're single-stepping through it.  */
7298944Sobrien  int stepping_through_sigtramp;
7346283Sdfr
7498944Sobrien  /* Private data used by the target vector implementation.  */
7598944Sobrien  struct private_thread_info *private;
7698944Sobrien};
7746283Sdfr
7898944Sobrien/* Create an empty thread list, or empty the existing one.  */
7998944Sobrienextern void init_thread_list (void);
8046283Sdfr
8198944Sobrien/* Add a thread to the thread list.
8298944Sobrien   Note that add_thread now returns the handle of the new thread,
8398944Sobrien   so that the caller may initialize the private thread data.  */
8498944Sobrienextern struct thread_info *add_thread (ptid_t ptid);
8546283Sdfr
8698944Sobrien/* Delete an existing thread list entry.  */
8798944Sobrienextern void delete_thread (ptid_t);
8846283Sdfr
8998944Sobrien/* Delete a step_resume_breakpoint from the thread database. */
9098944Sobrienextern void delete_step_resume_breakpoint (void *);
9146283Sdfr
9298944Sobrien/* Translate the integer thread id (GDB's homegrown id, not the system's)
9398944Sobrien   into a "pid" (which may be overloaded with extra thread information).  */
9498944Sobrienextern ptid_t thread_id_to_pid (int);
9546283Sdfr
9698944Sobrien/* Translate a 'pid' (which may be overloaded with extra thread information)
9798944Sobrien   into the integer thread id (GDB's homegrown id, not the system's).  */
9898944Sobrienextern int pid_to_thread_id (ptid_t ptid);
9946283Sdfr
10098944Sobrien/* Boolean test for an already-known pid (which may be overloaded with
10198944Sobrien   extra thread information).  */
10298944Sobrienextern int in_thread_list (ptid_t ptid);
10346283Sdfr
10498944Sobrien/* Boolean test for an already-known thread id (GDB's homegrown id,
10598944Sobrien   not the system's).  */
10698944Sobrienextern int valid_thread_id (int thread);
10746283Sdfr
10898944Sobrien/* Search function to lookup a thread by 'pid'.  */
10998944Sobrienextern struct thread_info *find_thread_pid (ptid_t ptid);
11046283Sdfr
11198944Sobrien/* Iterator function to call a user-provided callback function
11298944Sobrien   once for each known thread.  */
11398944Sobrientypedef int (*thread_callback_func) (struct thread_info *, void *);
11498944Sobrienextern struct thread_info *iterate_over_threads (thread_callback_func, void *);
11546283Sdfr
11698944Sobrien/* infrun context switch: save the debugger state for the given thread.  */
11798944Sobrienextern void save_infrun_state (ptid_t ptid,
11898944Sobrien			       CORE_ADDR prev_pc,
11998944Sobrien			       int       trap_expected,
12098944Sobrien			       struct breakpoint *step_resume_breakpoint,
12198944Sobrien			       struct breakpoint *through_sigtramp_breakpoint,
12298944Sobrien			       CORE_ADDR step_range_start,
12398944Sobrien			       CORE_ADDR step_range_end,
124130803Smarcel			       const struct frame_id *step_frame_id,
12598944Sobrien			       int       handling_longjmp,
12698944Sobrien			       int       another_trap,
12798944Sobrien			       int       stepping_through_solib_after_catch,
12898944Sobrien			       bpstat    stepping_through_solib_catchpoints,
12998944Sobrien			       int       stepping_through_sigtramp,
13098944Sobrien			       int       current_line,
13198944Sobrien			       struct symtab *current_symtab,
13298944Sobrien			       CORE_ADDR step_sp);
13346283Sdfr
13498944Sobrien/* infrun context switch: load the debugger state previously saved
13598944Sobrien   for the given thread.  */
13698944Sobrienextern void load_infrun_state (ptid_t ptid,
13798944Sobrien			       CORE_ADDR *prev_pc,
13898944Sobrien			       int       *trap_expected,
13998944Sobrien			       struct breakpoint **step_resume_breakpoint,
14098944Sobrien			       struct breakpoint **through_sigtramp_breakpoint,
14198944Sobrien			       CORE_ADDR *step_range_start,
14298944Sobrien			       CORE_ADDR *step_range_end,
143130803Smarcel			       struct frame_id *step_frame_id,
14498944Sobrien			       int       *handling_longjmp,
14598944Sobrien			       int       *another_trap,
14698944Sobrien			       int       *stepping_through_solib_affter_catch,
14798944Sobrien			       bpstat    *stepping_through_solib_catchpoints,
14898944Sobrien			       int       *stepping_through_sigtramp,
14998944Sobrien			       int       *current_line,
15098944Sobrien			       struct symtab **current_symtab,
15198944Sobrien			       CORE_ADDR *step_sp);
15246283Sdfr
15398944Sobrien/* Commands with a prefix of `thread'.  */
15498944Sobrienextern struct cmd_list_element *thread_cmd_list;
15546283Sdfr
15698944Sobrien#endif /* GDBTHREAD_H */
157