nm: Add --quiet to suppress "no symbols" diagnostic
[binutils-gdb.git] / gdb / process-stratum-target.c
blob719167803fff47f8b9cbf31c49ea5451f6a1db9f
1 /* Abstract base class inherited by all process_stratum targets
3 Copyright (C) 2018-2021 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
20 #include "defs.h"
21 #include "process-stratum-target.h"
22 #include "inferior.h"
24 process_stratum_target::~process_stratum_target ()
28 struct address_space *
29 process_stratum_target::thread_address_space (ptid_t ptid)
31 /* Fall-back to the "main" address space of the inferior. */
32 inferior *inf = find_inferior_ptid (this, ptid);
34 if (inf == NULL || inf->aspace == NULL)
35 internal_error (__FILE__, __LINE__,
36 _("Can't determine the current "
37 "address space of thread %s\n"),
38 target_pid_to_str (ptid).c_str ());
40 return inf->aspace;
43 struct gdbarch *
44 process_stratum_target::thread_architecture (ptid_t ptid)
46 inferior *inf = find_inferior_ptid (this, ptid);
47 gdb_assert (inf != NULL);
48 return inf->gdbarch;
51 bool
52 process_stratum_target::has_all_memory ()
54 /* If no inferior selected, then we can't read memory here. */
55 return inferior_ptid != null_ptid;
58 bool
59 process_stratum_target::has_memory ()
61 /* If no inferior selected, then we can't read memory here. */
62 return inferior_ptid != null_ptid;
65 bool
66 process_stratum_target::has_stack ()
68 /* If no inferior selected, there's no stack. */
69 return inferior_ptid != null_ptid;
72 bool
73 process_stratum_target::has_registers ()
75 /* Can't read registers from no inferior. */
76 return inferior_ptid != null_ptid;
79 bool
80 process_stratum_target::has_execution (inferior *inf)
82 /* If there's a process running already, we can't make it run
83 through hoops. */
84 return inf->pid != 0;
87 /* See process-stratum-target.h. */
89 std::set<process_stratum_target *>
90 all_non_exited_process_targets ()
92 /* Inferiors may share targets. To eliminate duplicates, use a set. */
93 std::set<process_stratum_target *> targets;
94 for (inferior *inf : all_non_exited_inferiors ())
95 targets.insert (inf->process_target ());
97 return targets;
100 /* See process-stratum-target.h. */
102 void
103 switch_to_target_no_thread (process_stratum_target *target)
105 for (inferior *inf : all_inferiors (target))
107 switch_to_inferior_no_thread (inf);
108 break;