inferiors.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /* Inferior process information for the remote server for GDB.
  2. Copyright (C) 1993-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef GDBSERVER_INFERIORS_H
  15. #define GDBSERVER_INFERIORS_H
  16. #include "gdbsupport/gdb_vecs.h"
  17. #include "dll.h"
  18. #include <list>
  19. struct thread_info;
  20. struct regcache;
  21. struct target_desc;
  22. struct sym_cache;
  23. struct breakpoint;
  24. struct raw_breakpoint;
  25. struct fast_tracepoint_jump;
  26. struct process_info_private;
  27. struct process_info
  28. {
  29. process_info (int pid_, int attached_)
  30. : pid (pid_), attached (attached_)
  31. {}
  32. /* This process' pid. */
  33. int pid;
  34. /* Nonzero if this child process was attached rather than
  35. spawned. */
  36. int attached;
  37. /* True if GDB asked us to detach from this process, but we remained
  38. attached anyway. */
  39. int gdb_detached = 0;
  40. /* The symbol cache. */
  41. struct sym_cache *symbol_cache = NULL;
  42. /* The list of memory breakpoints. */
  43. struct breakpoint *breakpoints = NULL;
  44. /* The list of raw memory breakpoints. */
  45. struct raw_breakpoint *raw_breakpoints = NULL;
  46. /* The list of installed fast tracepoints. */
  47. struct fast_tracepoint_jump *fast_tracepoint_jumps = NULL;
  48. /* The list of syscalls to report, or just a single element, ANY_SYSCALL,
  49. for unfiltered syscall reporting. */
  50. std::vector<int> syscalls_to_catch;
  51. const struct target_desc *tdesc = NULL;
  52. /* Private target data. */
  53. struct process_info_private *priv = NULL;
  54. /* DLLs thats are loaded for this proc. */
  55. std::list<dll_info> all_dlls;
  56. /* Flag to mark that the DLL list has changed. */
  57. bool dlls_changed = false;
  58. };
  59. /* Get the pid of PROC. */
  60. static inline int
  61. pid_of (const process_info *proc)
  62. {
  63. return proc->pid;
  64. }
  65. /* Return a pointer to the process that corresponds to the current
  66. thread (current_thread). It is an error to call this if there is
  67. no current thread selected. */
  68. struct process_info *current_process (void);
  69. struct process_info *get_thread_process (const struct thread_info *);
  70. extern std::list<process_info *> all_processes;
  71. /* Invoke FUNC for each process. */
  72. template <typename Func>
  73. static void
  74. for_each_process (Func func)
  75. {
  76. std::list<process_info *>::iterator next, cur = all_processes.begin ();
  77. while (cur != all_processes.end ())
  78. {
  79. next = cur;
  80. next++;
  81. func (*cur);
  82. cur = next;
  83. }
  84. }
  85. /* Find the first process for which FUNC returns true. Return NULL if no
  86. process satisfying FUNC is found. */
  87. template <typename Func>
  88. static process_info *
  89. find_process (Func func)
  90. {
  91. std::list<process_info *>::iterator next, cur = all_processes.begin ();
  92. while (cur != all_processes.end ())
  93. {
  94. next = cur;
  95. next++;
  96. if (func (*cur))
  97. return *cur;
  98. cur = next;
  99. }
  100. return NULL;
  101. }
  102. extern struct thread_info *current_thread;
  103. /* Return the first process in the processes list. */
  104. struct process_info *get_first_process (void);
  105. struct process_info *add_process (int pid, int attached);
  106. void remove_process (struct process_info *process);
  107. struct process_info *find_process_pid (int pid);
  108. int have_started_inferiors_p (void);
  109. int have_attached_inferiors_p (void);
  110. /* Switch to a thread of PROC. */
  111. void switch_to_process (process_info *proc);
  112. void clear_inferiors (void);
  113. void *thread_target_data (struct thread_info *);
  114. struct regcache *thread_regcache_data (struct thread_info *);
  115. void set_thread_regcache_data (struct thread_info *, struct regcache *);
  116. /* Set the inferior current working directory. If CWD is empty, unset
  117. the directory. */
  118. void set_inferior_cwd (std::string cwd);
  119. #endif /* GDBSERVER_INFERIORS_H */