1e93f7393Sniklas /* Multi-process/thread control defs for GDB, the GNU debugger. 2b725ae77Skettenis Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1997, 1998, 1999, 3b725ae77Skettenis 2000 4e93f7393Sniklas Free Software Foundation, Inc. 5b725ae77Skettenis Contributed by Lynx Real-Time Systems, Inc. Los Gatos, CA. 6b725ae77Skettenis 7e93f7393Sniklas 8e93f7393Sniklas This file is part of GDB. 9e93f7393Sniklas 10e93f7393Sniklas This program is free software; you can redistribute it and/or modify 11e93f7393Sniklas it under the terms of the GNU General Public License as published by 12e93f7393Sniklas the Free Software Foundation; either version 2 of the License, or 13e93f7393Sniklas (at your option) any later version. 14e93f7393Sniklas 15e93f7393Sniklas This program is distributed in the hope that it will be useful, 16e93f7393Sniklas but WITHOUT ANY WARRANTY; without even the implied warranty of 17e93f7393Sniklas MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18e93f7393Sniklas GNU General Public License for more details. 19e93f7393Sniklas 20e93f7393Sniklas You should have received a copy of the GNU General Public License 21e93f7393Sniklas along with this program; if not, write to the Free Software 22b725ae77Skettenis Foundation, Inc., 59 Temple Place - Suite 330, 23b725ae77Skettenis Boston, MA 02111-1307, USA. */ 24e93f7393Sniklas 25e93f7393Sniklas #ifndef GDBTHREAD_H 26e93f7393Sniklas #define GDBTHREAD_H 27e93f7393Sniklas 28b725ae77Skettenis struct breakpoint; 29b725ae77Skettenis struct frame_id; 30b725ae77Skettenis struct symtab; 31e93f7393Sniklas 32b725ae77Skettenis /* For bpstat */ 33b725ae77Skettenis #include "breakpoint.h" 34e93f7393Sniklas 35b725ae77Skettenis /* For struct frame_id. */ 36b725ae77Skettenis #include "frame.h" 37e93f7393Sniklas 38b725ae77Skettenis struct thread_info 39b725ae77Skettenis { 40b725ae77Skettenis struct thread_info *next; 41b725ae77Skettenis ptid_t ptid; /* "Actual process id"; 42b725ae77Skettenis In fact, this may be overloaded with 43b725ae77Skettenis kernel thread id, etc. */ 44b725ae77Skettenis int num; /* Convenient handle (GDB thread id) */ 45b725ae77Skettenis /* State from wait_for_inferior */ 46b725ae77Skettenis CORE_ADDR prev_pc; 47b725ae77Skettenis struct breakpoint *step_resume_breakpoint; 48b725ae77Skettenis CORE_ADDR step_range_start; 49b725ae77Skettenis CORE_ADDR step_range_end; 50b725ae77Skettenis struct frame_id step_frame_id; 51b725ae77Skettenis int current_line; 52b725ae77Skettenis struct symtab *current_symtab; 53b725ae77Skettenis int trap_expected; 54b725ae77Skettenis int handling_longjmp; 55b725ae77Skettenis int another_trap; 56e93f7393Sniklas 57b725ae77Skettenis /* This is set TRUE when a catchpoint of a shared library event 58b725ae77Skettenis triggers. Since we don't wish to leave the inferior in the 59b725ae77Skettenis solib hook when we report the event, we step the inferior 60b725ae77Skettenis back to user code before stopping and reporting the event. */ 61b725ae77Skettenis int stepping_through_solib_after_catch; 62e93f7393Sniklas 63b725ae77Skettenis /* When stepping_through_solib_after_catch is TRUE, this is a 64b725ae77Skettenis list of the catchpoints that should be reported as triggering 65b725ae77Skettenis when we finally do stop stepping. */ 66b725ae77Skettenis bpstat stepping_through_solib_catchpoints; 67e93f7393Sniklas 68b725ae77Skettenis /* Private data used by the target vector implementation. */ 69b725ae77Skettenis struct private_thread_info *private; 70b725ae77Skettenis }; 71b725ae77Skettenis 72b725ae77Skettenis /* Create an empty thread list, or empty the existing one. */ 73b725ae77Skettenis extern void init_thread_list (void); 74b725ae77Skettenis 75b725ae77Skettenis /* Add a thread to the thread list. 76b725ae77Skettenis Note that add_thread now returns the handle of the new thread, 77b725ae77Skettenis so that the caller may initialize the private thread data. */ 78b725ae77Skettenis extern struct thread_info *add_thread (ptid_t ptid); 79b725ae77Skettenis 80b725ae77Skettenis /* Delete an existing thread list entry. */ 81b725ae77Skettenis extern void delete_thread (ptid_t); 82b725ae77Skettenis 83b725ae77Skettenis /* Delete a step_resume_breakpoint from the thread database. */ 84b725ae77Skettenis extern void delete_step_resume_breakpoint (void *); 85b725ae77Skettenis 86b725ae77Skettenis /* Translate the integer thread id (GDB's homegrown id, not the system's) 87b725ae77Skettenis into a "pid" (which may be overloaded with extra thread information). */ 88b725ae77Skettenis extern ptid_t thread_id_to_pid (int); 89b725ae77Skettenis 90b725ae77Skettenis /* Translate a 'pid' (which may be overloaded with extra thread information) 91b725ae77Skettenis into the integer thread id (GDB's homegrown id, not the system's). */ 92b725ae77Skettenis extern int pid_to_thread_id (ptid_t ptid); 93b725ae77Skettenis 94b725ae77Skettenis /* Boolean test for an already-known pid (which may be overloaded with 95b725ae77Skettenis extra thread information). */ 96b725ae77Skettenis extern int in_thread_list (ptid_t ptid); 97b725ae77Skettenis 98b725ae77Skettenis /* Boolean test for an already-known thread id (GDB's homegrown id, 99b725ae77Skettenis not the system's). */ 100b725ae77Skettenis extern int valid_thread_id (int thread); 101b725ae77Skettenis 102b725ae77Skettenis /* Search function to lookup a thread by 'pid'. */ 103b725ae77Skettenis extern struct thread_info *find_thread_pid (ptid_t ptid); 104b725ae77Skettenis 105b725ae77Skettenis /* Iterator function to call a user-provided callback function 106b725ae77Skettenis once for each known thread. */ 107b725ae77Skettenis typedef int (*thread_callback_func) (struct thread_info *, void *); 108b725ae77Skettenis extern struct thread_info *iterate_over_threads (thread_callback_func, void *); 109b725ae77Skettenis 110b725ae77Skettenis /* infrun context switch: save the debugger state for the given thread. */ 111b725ae77Skettenis extern void save_infrun_state (ptid_t ptid, 112b725ae77Skettenis CORE_ADDR prev_pc, 113b725ae77Skettenis int trap_expected, 114b725ae77Skettenis struct breakpoint *step_resume_breakpoint, 115b725ae77Skettenis CORE_ADDR step_range_start, 116b725ae77Skettenis CORE_ADDR step_range_end, 117b725ae77Skettenis const struct frame_id *step_frame_id, 118b725ae77Skettenis int handling_longjmp, 119b725ae77Skettenis int another_trap, 120b725ae77Skettenis int stepping_through_solib_after_catch, 121b725ae77Skettenis bpstat stepping_through_solib_catchpoints, 122b725ae77Skettenis int current_line, 123*63addd46Skettenis struct symtab *current_symtab); 124b725ae77Skettenis 125b725ae77Skettenis /* infrun context switch: load the debugger state previously saved 126b725ae77Skettenis for the given thread. */ 127b725ae77Skettenis extern void load_infrun_state (ptid_t ptid, 128b725ae77Skettenis CORE_ADDR *prev_pc, 129b725ae77Skettenis int *trap_expected, 130b725ae77Skettenis struct breakpoint **step_resume_breakpoint, 131b725ae77Skettenis CORE_ADDR *step_range_start, 132b725ae77Skettenis CORE_ADDR *step_range_end, 133b725ae77Skettenis struct frame_id *step_frame_id, 134b725ae77Skettenis int *handling_longjmp, 135b725ae77Skettenis int *another_trap, 136b725ae77Skettenis int *stepping_through_solib_affter_catch, 137b725ae77Skettenis bpstat *stepping_through_solib_catchpoints, 138b725ae77Skettenis int *current_line, 139*63addd46Skettenis struct symtab **current_symtab); 140b725ae77Skettenis 141b725ae77Skettenis /* Commands with a prefix of `thread'. */ 142b725ae77Skettenis extern struct cmd_list_element *thread_cmd_list; 143e93f7393Sniklas 144e93f7393Sniklas #endif /* GDBTHREAD_H */ 145