gdb/gdbserver/inferiors.h - gdb

Data types defined

Macros defined

Source code

  1. /* Inferior process information for the remote server for GDB.
  2.    Copyright (C) 1993-2015 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 INFERIORS_H
  15. #define INFERIORS_H

  16. /* Generic information for tracking a list of ``inferiors'' - threads,
  17.    processes, etc.  */
  18. struct inferior_list
  19. {
  20.   struct inferior_list_entry *head;
  21.   struct inferior_list_entry *tail;
  22. };
  23. struct inferior_list_entry
  24. {
  25.   ptid_t id;
  26.   struct inferior_list_entry *next;
  27. };

  28. struct thread_info;
  29. struct target_desc;
  30. struct sym_cache;
  31. struct breakpoint;
  32. struct raw_breakpoint;
  33. struct fast_tracepoint_jump;
  34. struct process_info_private;

  35. struct process_info
  36. {
  37.   /* This must appear first.
  38.      The list iterator functions assume it.  */
  39.   struct inferior_list_entry entry;

  40.   /* Nonzero if this child process was attached rather than
  41.      spawned.  */
  42.   int attached;

  43.   /* True if GDB asked us to detach from this process, but we remained
  44.      attached anyway.  */
  45.   int gdb_detached;

  46.   /* The symbol cache.  */
  47.   struct sym_cache *symbol_cache;

  48.   /* The list of memory breakpoints.  */
  49.   struct breakpoint *breakpoints;

  50.   /* The list of raw memory breakpoints.  */
  51.   struct raw_breakpoint *raw_breakpoints;

  52.   /* The list of installed fast tracepoints.  */
  53.   struct fast_tracepoint_jump *fast_tracepoint_jumps;

  54.   const struct target_desc *tdesc;

  55.   /* Private target data.  */
  56.   struct process_info_private *private;
  57. };

  58. #define ptid_of(inf) ((inf)->entry.id)
  59. #define pid_of(inf) ptid_get_pid ((inf)->entry.id)
  60. #define lwpid_of(inf) ptid_get_lwp ((inf)->entry.id)

  61. /* Return a pointer to the process that corresponds to the current
  62.    thread (current_thread).  It is an error to call this if there is
  63.    no current thread selected.  */

  64. struct process_info *current_process (void);
  65. struct process_info *get_thread_process (struct thread_info *);

  66. extern struct inferior_list all_processes;

  67. void add_inferior_to_list (struct inferior_list *list,
  68.                            struct inferior_list_entry *new_inferior);
  69. void for_each_inferior (struct inferior_list *list,
  70.                         void (*action) (struct inferior_list_entry *));

  71. void for_each_inferior_with_data
  72.   (struct inferior_list *list,
  73.    void (*action) (struct inferior_list_entry *, void *),
  74.    void *data);

  75. void clear_inferior_list (struct inferior_list *list);

  76. int one_inferior_p (struct inferior_list *list);

  77. /* Helper for ALL_INFERIORS_TYPE.  Gets the next element starting at
  78.    CUR, if CUR is not NULL.  */
  79. #define A_I_NEXT(type, list, cur)                                        \
  80.   ((cur) != NULL                                                        \
  81.    ? (type *) ((struct inferior_list_entry *) cur)->next                \
  82.    : NULL)

  83. /* Iterate over all inferiors of type TYPE in LIST, open loop
  84.    style.  */
  85. #define ALL_INFERIORS_TYPE(type, list, cur, tmp)                                \
  86.   for ((cur) = (type *) (list)->head, (tmp) = A_I_NEXT (type, list, cur); \
  87.        (cur) != NULL;                                                        \
  88.        (cur) = (tmp), (tmp) = A_I_NEXT (type, list, cur))

  89. /* Iterate over all inferiors in LIST, open loop style.  */
  90. #define ALL_INFERIORS(list, cur, tmp)                                \
  91.   ALL_INFERIORS_TYPE (struct inferior_list_entry, list, cur, tmp)

  92. /* Iterate over all processes, open loop style.  */
  93. #define ALL_PROCESSES(cur, tmp)                                        \
  94.   ALL_INFERIORS_TYPE (struct process_info, &all_processes, cur, tmp)

  95. extern struct thread_info *current_thread;
  96. void remove_inferior (struct inferior_list *list,
  97.                       struct inferior_list_entry *entry);

  98. struct inferior_list_entry *get_first_inferior (struct inferior_list *list);

  99. struct process_info *add_process (int pid, int attached);
  100. void remove_process (struct process_info *process);
  101. struct process_info *find_process_pid (int pid);
  102. int have_started_inferiors_p (void);
  103. int have_attached_inferiors_p (void);

  104. ptid_t thread_to_gdb_id (struct thread_info *);
  105. ptid_t gdb_id_to_thread_id (ptid_t);

  106. void clear_inferiors (void);
  107. struct inferior_list_entry *find_inferior
  108.      (struct inferior_list *,
  109.       int (*func) (struct inferior_list_entry *,
  110.                    void *),
  111.       void *arg);
  112. struct inferior_list_entry *find_inferior_id (struct inferior_list *list,
  113.                                               ptid_t id);

  114. void *inferior_target_data (struct thread_info *);
  115. void set_inferior_target_data (struct thread_info *, void *);
  116. void *inferior_regcache_data (struct thread_info *);
  117. void set_inferior_regcache_data (struct thread_info *, void *);

  118. #endif /* INFERIORS_H */