[gdb/testsuite] Fix gdb.base/coredump-filter-build-id.exp with older eu-unstrip
[deliverable/binutils-gdb.git] / gdb / process-stratum-target.h
CommitLineData
3b3dac9b
PA
1/* Abstract base class inherited by all process_stratum targets
2
3666a048 3 Copyright (C) 2018-2021 Free Software Foundation, Inc.
3b3dac9b
PA
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#ifndef PROCESS_STRATUM_TARGET_H
21#define PROCESS_STRATUM_TARGET_H
22
23#include "target.h"
d890404b 24#include <set>
3b3dac9b
PA
25
26/* Abstract base class inherited by all process_stratum targets. */
27
28class process_stratum_target : public target_ops
29{
30public:
3b3dac9b
PA
31 ~process_stratum_target () override = 0;
32
dc34c897 33 strata stratum () const final override { return process_stratum; }
66b4deae 34
121b3efd
PA
35 /* Return a string representation of this target's open connection.
36 This string is used to distinguish different instances of a given
37 target type. For example, when remote debugging, the target is
38 called "remote", but since we may have more than one remote
39 target open, connection_string() returns the connection serial
40 connection name, e.g., "localhost:10001", "192.168.0.1:20000",
41 etc. This string is shown in several places, e.g., in "info
42 connections" and "info inferiors". */
43 virtual const char *connection_string () { return nullptr; }
44
3b3dac9b
PA
45 /* We must default these because they must be implemented by any
46 target that can run. */
47 bool can_async_p () override { return false; }
48 bool supports_non_stop () override { return false; }
49 bool supports_disable_randomization () override { return false; }
50
51 /* This default implementation returns the inferior's address
52 space. */
53 struct address_space *thread_address_space (ptid_t ptid) override;
54
55 /* This default implementation always returns target_gdbarch (). */
56 struct gdbarch *thread_architecture (ptid_t ptid) override;
f3d11a9a
PA
57
58 /* Default implementations for process_stratum targets. Return true
59 if there's a selected inferior, false otherwise. */
60 bool has_all_memory () override;
61 bool has_memory () override;
62 bool has_stack () override;
63 bool has_registers () override;
5018ce90 64 bool has_execution (inferior *inf) override;
5b6d1e4f 65
294c36eb
SM
66 /* Default implementation of follow_exec.
67
68 If the current inferior and FOLLOW_INF are different (execution continues
69 in a new inferior), push this process target to FOLLOW_INF's target stack
70 and add an initial thread to FOLLOW_INF. */
71 void follow_exec (inferior *follow_inf, ptid_t ptid,
72 const char *execd_pathname) override;
73
5b6d1e4f
PA
74 /* True if any thread is, or may be executing. We need to track
75 this separately because until we fully sync the thread list, we
76 won't know whether the target is fully stopped, even if we see
77 stop events for all known threads, because any of those threads
78 may have spawned new threads we haven't heard of yet. */
79 bool threads_executing = false;
121b3efd
PA
80
81 /* The connection number. Visible in "info connections". */
82 int connection_number = 0;
1192f124
SM
83
84 /* Whether resumed threads must be committed to the target.
85
86 When true, resumed threads must be committed to the execution
87 target.
88
89 When false, the target may leave resumed threads stopped when
90 it's convenient or efficient to do so. When the core requires
91 resumed threads to be committed again, this is set back to true
92 and calls the `commit_resumed` method to allow the target to do
93 so.
94
95 To simplify the implementation of targets, the following methods
96 are guaranteed to be called with COMMIT_RESUMED_STATE set to
97 false:
98
99 - resume
100 - stop
101 - wait
102
103 Knowing this, the target doesn't need to implement different
104 behaviors depending on the COMMIT_RESUMED_STATE, and can simply
105 assume that it is false.
106
107 Targets can take advantage of this to batch resumption requests,
108 for example. In that case, the target doesn't actually resume in
109 its `resume` implementation. Instead, it takes note of the
110 resumption intent in `resume` and defers the actual resumption to
111 `commit_resumed`. For example, the remote target uses this to
112 coalesce multiple resumption requests in a single vCont
113 packet. */
114 bool commit_resumed_state = false;
3b3dac9b
PA
115};
116
5b6d1e4f
PA
117/* Downcast TARGET to process_stratum_target. */
118
119static inline process_stratum_target *
120as_process_stratum_target (target_ops *target)
121{
122 gdb_assert (target->stratum () == process_stratum);
123 return static_cast<process_stratum_target *> (target);
124}
125
d890404b
TBA
126/* Return a collection of targets that have non-exited inferiors. */
127
128extern std::set<process_stratum_target *> all_non_exited_process_targets ();
129
130/* Switch to the first inferior (and program space) of TARGET, and
131 switch to no thread selected. */
132
133extern void switch_to_target_no_thread (process_stratum_target *target);
134
3b3dac9b 135#endif /* !defined (PROCESS_STRATUM_TARGET_H) */
This page took 0.325726 seconds and 4 git commands to generate.