Disambiguate info_print_options
[deliverable/binutils-gdb.git] / gdb / gdbcore.h
CommitLineData
c906108c 1/* Machine independent variables that describe the core file under GDB.
00e32a35 2
b811d2c2 3 Copyright (C) 1986-2020 Free Software Foundation, Inc.
c906108c 4
c5aa993b 5 This file is part of GDB.
c906108c 6
c5aa993b
JM
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
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
c5aa993b 10 (at your option) any later version.
c906108c 11
c5aa993b
JM
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.
c906108c 16
c5aa993b 17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
19
20/* Interface routines for core, executable, etc. */
21
22#if !defined (GDBCORE_H)
23#define GDBCORE_H 1
24
da3331ec 25struct type;
9eefc95f 26struct regcache;
da3331ec 27
c906108c 28#include "bfd.h"
6c95b8df 29#include "exec.h"
578d3588 30#include "target.h"
c906108c 31
c906108c
SS
32/* Nonzero if there is a core file. */
33
a14ed312 34extern int have_core_file_p (void);
c906108c 35
c906108c
SS
36/* Report a memory error with error(). */
37
9b409511 38extern void memory_error (enum target_xfer_status status, CORE_ADDR memaddr);
578d3588 39
1ccbe998 40/* The string 'memory_error' would use as exception message. */
578d3588 41
1ccbe998
TT
42extern std::string memory_error_message (enum target_xfer_status err,
43 struct gdbarch *gdbarch,
44 CORE_ADDR memaddr);
c906108c
SS
45
46/* Like target_read_memory, but report an error if can't read. */
47
45aa4659 48extern void read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
c906108c 49
4e5d721f
DE
50/* Like target_read_stack, but report an error if can't read. */
51
45aa4659 52extern void read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
4e5d721f 53
0865b04a
YQ
54/* Like target_read_code, but report an error if can't read. */
55
56extern void read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
57
c906108c
SS
58/* Read an integer from debugged memory, given address and number of
59 bytes. */
60
e17a4113
UW
61extern LONGEST read_memory_integer (CORE_ADDR memaddr,
62 int len, enum bfd_endian byte_order);
63extern int safe_read_memory_integer (CORE_ADDR memaddr, int len,
3e43a32a
MS
64 enum bfd_endian byte_order,
65 LONGEST *return_value);
c906108c
SS
66
67/* Read an unsigned integer from debugged memory, given address and
68 number of bytes. */
69
e17a4113 70extern ULONGEST read_memory_unsigned_integer (CORE_ADDR memaddr,
3e43a32a
MS
71 int len,
72 enum bfd_endian byte_order);
cc2c4da8
MK
73extern int safe_read_memory_unsigned_integer (CORE_ADDR memaddr, int len,
74 enum bfd_endian byte_order,
75 ULONGEST *return_value);
c906108c 76
0865b04a
YQ
77/* Read an integer from debugged code memory, given address,
78 number of bytes, and byte order for code. */
79
80extern LONGEST read_code_integer (CORE_ADDR memaddr, int len,
81 enum bfd_endian byte_order);
82
83/* Read an unsigned integer from debugged code memory, given address,
84 number of bytes, and byte order for code. */
85
86extern ULONGEST read_code_unsigned_integer (CORE_ADDR memaddr,
87 int len,
88 enum bfd_endian byte_order);
89
0963b4bd
MS
90/* Read a null-terminated string from the debuggee's memory, given
91 address, a buffer into which to place the string, and the maximum
92 available space. */
0d540cdf 93
a14ed312 94extern void read_memory_string (CORE_ADDR, char *, int);
c906108c 95
0d540cdf 96/* Read the pointer of type TYPE at ADDR, and return the address it
0963b4bd 97 represents. */
0d540cdf 98
570b8f7c 99CORE_ADDR read_memory_typed_address (CORE_ADDR addr, struct type *type);
0d540cdf 100
cb6f16cf
SM
101/* Same as target_write_memory, but report an error if can't
102 write. */
c906108c 103
45aa4659
JK
104extern void write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
105 ssize_t len);
c906108c 106
972daa01
YQ
107/* Same as write_memory, but notify 'memory_changed' observers. */
108
109extern void write_memory_with_notification (CORE_ADDR memaddr,
110 const bfd_byte *myaddr,
111 ssize_t len);
112
c26e4683
JB
113/* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer. */
114extern void write_memory_unsigned_integer (CORE_ADDR addr, int len,
e17a4113
UW
115 enum bfd_endian byte_order,
116 ULONGEST value);
c26e4683
JB
117
118/* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer. */
119extern void write_memory_signed_integer (CORE_ADDR addr, int len,
e17a4113 120 enum bfd_endian byte_order,
c26e4683 121 LONGEST value);
c906108c
SS
122\f
123/* Hook for `exec_file_command' command to call. */
124
5f08566b 125extern void (*deprecated_exec_file_display_hook) (const char *filename);
c906108c
SS
126
127/* Hook for "file_command", which is more useful than above
3a9a986f 128 (because it is invoked AFTER symbols are read, not before). */
c906108c 129
1d8b34a7 130extern void (*deprecated_file_changed_hook) (const char *filename);
c906108c 131
5f08566b 132extern void specify_exec_file_hook (void (*hook) (const char *filename));
c906108c 133
6c95b8df 134/* Binary File Diddler for the core file. */
c906108c 135
06333fea 136#define core_bfd (current_program_space->cbfd.get ())
c04ea773 137
c906108c
SS
138/* Whether to open exec and core files read-only or read-write. */
139
491144b5 140extern bool write_files;
c906108c 141
d9f719f1
PA
142/* Open and set up the core file bfd. */
143
144extern void core_target_open (const char *arg, int from_tty);
145
d64097b1 146extern void core_file_command (const char *filename, int from_tty);
c906108c 147
5f08566b 148extern void exec_file_attach (const char *filename, int from_tty);
c906108c 149
a10de604
GB
150/* If the filename of the main executable is unknown, attempt to
151 determine it. If a filename is determined, proceed as though
152 it was just specified with the "file" command. Do nothing if
bb805577
JK
153 the filename of the main executable is already known.
154 DEFER_BP_RESET uses SYMFILE_DEFER_BP_RESET for the main symbol file. */
a10de604 155
bb805577 156extern void exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty);
a10de604 157
a14ed312 158extern void validate_files (void);
c906108c 159
a2fedca9
PW
160/* Give the user a message if the current exec file does not match the exec
161 file determined from the target. In case of mismatch, ask the user
162 if the exec file determined from target must be loaded. */
163extern void validate_exec_file (int from_tty);
164
c906108c
SS
165/* The current default bfd target. */
166
167extern char *gnutarget;
168
a121b7c1 169extern void set_gnutarget (const char *);
c906108c
SS
170
171/* Structure to keep track of core register reading functions for
172 various core file types. */
173
c5aa993b
JM
174struct core_fns
175 {
c906108c 176
2acceee2
JM
177 /* BFD flavour that a core file handler is prepared to read. This
178 can be used by the handler's core tasting function as a first
179 level filter to reject BFD's that don't have the right
0963b4bd 180 flavour. */
c906108c 181
c5aa993b 182 enum bfd_flavour core_flavour;
c906108c 183
2acceee2
JM
184 /* Core file handler function to call to recognize corefile
185 formats that BFD rejects. Some core file format just don't fit
186 into the BFD model, or may require other resources to identify
187 them, that simply aren't available to BFD (such as symbols from
188 another file). Returns nonzero if the handler recognizes the
0963b4bd 189 format, zero otherwise. */
2acceee2 190
507f3c78 191 int (*check_format) (bfd *);
2acceee2
JM
192
193 /* Core file handler function to call to ask if it can handle a
194 given core file format or not. Returns zero if it can't,
0963b4bd 195 nonzero otherwise. */
2acceee2 196
507f3c78 197 int (*core_sniffer) (struct core_fns *, bfd *);
2acceee2 198
9eefc95f
UW
199 /* Extract the register values out of the core file and supply them
200 into REGCACHE.
c906108c 201
c5aa993b
JM
202 CORE_REG_SECT points to the register values themselves, read into
203 memory.
c906108c 204
c5aa993b 205 CORE_REG_SIZE is the size of that area.
c906108c 206
de57eccd
JM
207 WHICH says which set of registers we are handling:
208 0 --- integer registers
209 2 --- floating-point registers, on machines where they are
210 discontiguous
211 3 --- extended floating-point registers, on machines where
212 these are present in yet a third area. (GNU/Linux uses
213 this to get at the SSE registers.)
c906108c 214
c5aa993b
JM
215 REG_ADDR is the offset from u.u_ar0 to the register values relative to
216 core_reg_sect. This is used with old-fashioned core files to locate the
217 registers in a large upage-plus-stack ".reg" section. Original upage
0963b4bd 218 address X is at location core_reg_sect+x+reg_addr. */
c906108c 219
9eefc95f 220 void (*core_read_registers) (struct regcache *regcache,
0cac9354 221 gdb_byte *core_reg_sect,
507f3c78
KB
222 unsigned core_reg_size,
223 int which, CORE_ADDR reg_addr);
c906108c 224
00e32a35
AC
225 /* Finds the next struct core_fns. They are allocated and
226 initialized in whatever module implements the functions pointed
227 to; an initializer calls deprecated_add_core_fns to add them to
228 the global chain. */
c906108c 229
c5aa993b 230 struct core_fns *next;
c906108c 231
c5aa993b 232 };
c906108c 233
6e5eab33
JB
234/* Build either a single-thread or multi-threaded section name for
235 PTID.
236
237 If ptid's lwp member is zero, we want to do the single-threaded
238 thing: look for a section named NAME (as passed to the
239 constructor). If ptid's lwp member is non-zero, we'll want do the
240 multi-threaded thing: look for a section named "NAME/LWP", where
241 LWP is the shortest ASCII decimal representation of ptid's lwp
242 member. */
243
244class thread_section_name
245{
246public:
247 /* NAME is the single-threaded section name. If PTID represents an
248 LWP, then the build section name is "NAME/LWP", otherwise it's
249 just "NAME" unmodified. */
250 thread_section_name (const char *name, ptid_t ptid)
251 {
252 if (ptid.lwp_p ())
253 {
254 m_storage = string_printf ("%s/%ld", name, ptid.lwp ());
255 m_section_name = m_storage.c_str ();
256 }
257 else
258 m_section_name = name;
259 }
260
261 /* Return the computed section name. The result is valid as long as
262 this thread_section_name object is live. */
263 const char *c_str () const
264 { return m_section_name; }
265
d6541620 266 DISABLE_COPY_AND_ASSIGN (thread_section_name);
6e5eab33
JB
267
268private:
269 /* Either a pointer into M_STORAGE, or a pointer to the name passed
270 as parameter to the constructor. */
271 const char *m_section_name;
272 /* If we need to build a new section name, this is where we store
273 it. */
274 std::string m_storage;
275};
276
89203d40 277/* Replaced by the "iterate_over_regset_sections" gdbarch method. */
00e32a35 278extern void deprecated_add_core_fns (struct core_fns *cf);
a14ed312
KB
279extern int default_core_sniffer (struct core_fns *cf, bfd * abfd);
280extern int default_check_format (bfd * abfd);
c906108c 281
c5aa993b 282#endif /* !defined (GDBCORE_H) */
This page took 1.520658 seconds and 4 git commands to generate.