RISC-V: Give stack slots same align as XLEN.
[external/binutils.git] / gdb / inf-child.h
1 /* Base/prototype target for default child (native) targets.
2
3    Copyright (C) 2004-2018 Free Software Foundation, Inc.
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 INF_CHILD_H
21 #define INF_CHILD_H
22
23 #include "target.h"
24
25 /* A prototype child target.  The client can override it with local
26    methods.  */
27
28 class inf_child_target
29   : public memory_breakpoint_target<target_ops>
30 {
31 public:
32   inf_child_target ();
33   ~inf_child_target () override = 0;
34
35   const target_info &info () const override;
36
37   void close () override;
38
39   void disconnect (const char *, int) override;
40
41   void fetch_registers (struct regcache *, int) override = 0;
42   void store_registers (struct regcache *, int) override = 0;
43
44   void prepare_to_store (struct regcache *) override;
45
46   bool supports_terminal_ours () override;
47   void terminal_init () override;
48   void terminal_inferior () override;
49   void terminal_save_inferior () override;
50   void terminal_ours_for_output () override;
51   void terminal_ours () override;
52   void terminal_info (const char *, int) override;
53
54   void interrupt () override;
55   void pass_ctrlc () override;
56
57   void post_startup_inferior (ptid_t) override;
58
59   void mourn_inferior () override;
60
61   bool can_run () override;
62
63   bool can_create_inferior () override;
64   void create_inferior (const char *, const std::string &,
65                         char **, int) override = 0;
66
67   bool can_attach () override;
68   void attach (const char *, int) override = 0;
69
70   void post_attach (int) override;
71
72   /* We must default these because they must be implemented by any
73      target that can run.  */
74   bool can_async_p ()  override { return false; }
75   bool supports_non_stop ()  override { return false; }
76   bool supports_disable_randomization () override { return false; }
77
78   char *pid_to_exec_file (int pid) override;
79
80   bool has_all_memory () override;
81   bool has_memory () override;
82   bool has_stack () override;
83   bool has_registers () override;
84   bool has_execution (ptid_t) override;
85
86   int fileio_open (struct inferior *inf, const char *filename,
87                    int flags, int mode, int warn_if_slow,
88                    int *target_errno) override;
89   int fileio_pwrite (int fd, const gdb_byte *write_buf, int len,
90                      ULONGEST offset, int *target_errno) override;
91   int fileio_pread (int fd, gdb_byte *read_buf, int len,
92                     ULONGEST offset, int *target_errno) override;
93   int fileio_fstat (int fd, struct stat *sb, int *target_errno) override;
94   int fileio_close (int fd, int *target_errno) override;
95   int fileio_unlink (struct inferior *inf,
96                      const char *filename,
97                      int *target_errno) override;
98   gdb::optional<std::string> fileio_readlink (struct inferior *inf,
99                                               const char *filename,
100                                               int *target_errno) override;
101   bool use_agent (bool use) override;
102
103   bool can_use_agent () override;
104
105 protected:
106   /* Unpush the target if it wasn't explicitly open with "target native"
107      and there are no live inferiors left.  Note: if calling this as a
108      result of a mourn or detach, the current inferior shall already
109      have its PID cleared, so it isn't counted as live.  That's usually
110      done by calling either generic_mourn_inferior or
111      detach_inferior.  */
112   void maybe_unpush_target ();
113 };
114
115 /* Functions for helping to write a native target.  */
116
117 /* This is for native targets which use a unix/POSIX-style waitstatus.  */
118 extern void store_waitstatus (struct target_waitstatus *, int);
119
120 /* Register TARGET as native target and set it up to respond to the
121    "target native" command.  */
122 extern void add_inf_child_target (inf_child_target *target);
123
124 /* target_open_ftype callback for inf-child targets.  Used by targets
125    that want to register an alternative target_info object.  Most
126    targets use add_inf_child_target instead.  */
127 extern void inf_child_open_target (const char *arg, int from_tty);
128
129 #endif