156160Sru/* Inferior process information for the remote server for GDB. 2146515Sru Copyright (C) 1993-2020 Free Software Foundation, Inc. 321495Sjmacd 4146515Sru This file is part of GDB. 521495Sjmacd 621495Sjmacd This program is free software; you can redistribute it and/or modify 721495Sjmacd it under the terms of the GNU General Public License as published by 821495Sjmacd the Free Software Foundation; either version 3 of the License, or 921495Sjmacd (at your option) any later version. 1021495Sjmacd 1121495Sjmacd This program is distributed in the hope that it will be useful, 1221495Sjmacd but WITHOUT ANY WARRANTY; without even the implied warranty of 1321495Sjmacd MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1421495Sjmacd GNU General Public License for more details. 1521495Sjmacd 1621495Sjmacd You should have received a copy of the GNU General Public License 1721495Sjmacd along with this program. If not, see <http://www.gnu.org/licenses/>. */ 1821495Sjmacd 1921495Sjmacd#ifndef GDBSERVER_INFERIORS_H 2021495Sjmacd#define GDBSERVER_INFERIORS_H 2121495Sjmacd 2242660Smarkm#include "gdbsupport/gdb_vecs.h" 2342660Smarkm#include <list> 2421495Sjmacd 2521495Sjmacdstruct thread_info; 2621495Sjmacdstruct regcache; 2721495Sjmacdstruct target_desc; 2821495Sjmacdstruct sym_cache; 2921495Sjmacdstruct breakpoint; 3021495Sjmacdstruct raw_breakpoint; 31146515Srustruct fast_tracepoint_jump; 3221495Sjmacdstruct process_info_private; 3321495Sjmacd 3421495Sjmacdstruct process_info 35146515Sru{ 3621495Sjmacd process_info (int pid_, int attached_) 3721495Sjmacd : pid (pid_), attached (attached_) 3821495Sjmacd {} 3921495Sjmacd 4021495Sjmacd /* This process' pid. */ 4121495Sjmacd int pid; 4221495Sjmacd 4321495Sjmacd /* Nonzero if this child process was attached rather than 44146515Sru spawned. */ 4521495Sjmacd int attached; 4656160Sru 4756160Sru /* True if GDB asked us to detach from this process, but we remained 4856160Sru attached anyway. */ 49146515Sru int gdb_detached = 0; 5056160Sru 5121495Sjmacd /* The symbol cache. */ 5221495Sjmacd struct sym_cache *symbol_cache = NULL; 5321495Sjmacd 5421495Sjmacd /* The list of memory breakpoints. */ 55146515Sru struct breakpoint *breakpoints = NULL; 56146515Sru 5721495Sjmacd /* The list of raw memory breakpoints. */ 58146515Sru struct raw_breakpoint *raw_breakpoints = NULL; 59146515Sru 6021495Sjmacd /* The list of installed fast tracepoints. */ 61146515Sru struct fast_tracepoint_jump *fast_tracepoint_jumps = NULL; 62146515Sru 6321495Sjmacd /* The list of syscalls to report, or just a single element, ANY_SYSCALL, 6421495Sjmacd for unfiltered syscall reporting. */ 6521495Sjmacd std::vector<int> syscalls_to_catch; 66146515Sru 6721495Sjmacd const struct target_desc *tdesc = NULL; 6821495Sjmacd 6921495Sjmacd /* Private target data. */ 7021495Sjmacd struct process_info_private *priv = NULL; 7121495Sjmacd}; 7221495Sjmacd 7321495Sjmacd/* Get the pid of PROC. */ 74146515Sru 7521495Sjmacdstatic inline int 7656160Srupid_of (const process_info *proc) 77146515Sru{ 7856160Sru return proc->pid; 7921495Sjmacd} 8021495Sjmacd 8142660Smarkm/* Return a pointer to the process that corresponds to the current 8221495Sjmacd thread (current_thread). It is an error to call this if there is 8321495Sjmacd no current thread selected. */ 8421495Sjmacd 8521495Sjmacdstruct process_info *current_process (void); 8621495Sjmacdstruct process_info *get_thread_process (const struct thread_info *); 8721495Sjmacd 8821495Sjmacdextern std::list<process_info *> all_processes; 8921495Sjmacd 9021495Sjmacd/* Invoke FUNC for each process. */ 9121495Sjmacd 9242660Smarkmtemplate <typename Func> 93static void 94for_each_process (Func func) 95{ 96 std::list<process_info *>::iterator next, cur = all_processes.begin (); 97 98 while (cur != all_processes.end ()) 99 { 100 next = cur; 101 next++; 102 func (*cur); 103 cur = next; 104 } 105} 106 107/* Find the first process for which FUNC returns true. Return NULL if no 108 process satisfying FUNC is found. */ 109 110template <typename Func> 111static process_info * 112find_process (Func func) 113{ 114 std::list<process_info *>::iterator next, cur = all_processes.begin (); 115 116 while (cur != all_processes.end ()) 117 { 118 next = cur; 119 next++; 120 121 if (func (*cur)) 122 return *cur; 123 124 cur = next; 125 } 126 127 return NULL; 128} 129 130extern struct thread_info *current_thread; 131 132/* Return the first process in the processes list. */ 133struct process_info *get_first_process (void); 134 135struct process_info *add_process (int pid, int attached); 136void remove_process (struct process_info *process); 137struct process_info *find_process_pid (int pid); 138int have_started_inferiors_p (void); 139int have_attached_inferiors_p (void); 140 141/* Switch to a thread of PROC. */ 142void switch_to_process (process_info *proc); 143 144void clear_inferiors (void); 145 146void *thread_target_data (struct thread_info *); 147struct regcache *thread_regcache_data (struct thread_info *); 148void set_thread_regcache_data (struct thread_info *, struct regcache *); 149 150#endif /* GDBSERVER_INFERIORS_H */ 151