1 /* Machine independent variables that describe the core file under GDB.
3 Copyright (C) 1986-2018 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 /* Interface routines for core, executable, etc. */
22 #if !defined (GDBCORE_H)
32 /* Nonzero if there is a core file. */
34 extern int have_core_file_p (void);
36 /* Report a memory error with error(). */
38 extern void memory_error (enum target_xfer_status status, CORE_ADDR memaddr);
40 /* The string 'memory_error' would use as exception message. */
42 extern std::string memory_error_message (enum target_xfer_status err,
43 struct gdbarch *gdbarch,
46 /* Like target_read_memory, but report an error if can't read. */
48 extern void read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
50 /* Like target_read_stack, but report an error if can't read. */
52 extern void read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
54 /* Like target_read_code, but report an error if can't read. */
56 extern void read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
58 /* Read an integer from debugged memory, given address and number of
61 extern LONGEST read_memory_integer (CORE_ADDR memaddr,
62 int len, enum bfd_endian byte_order);
63 extern int safe_read_memory_integer (CORE_ADDR memaddr, int len,
64 enum bfd_endian byte_order,
65 LONGEST *return_value);
67 /* Read an unsigned integer from debugged memory, given address and
70 extern ULONGEST read_memory_unsigned_integer (CORE_ADDR memaddr,
72 enum bfd_endian byte_order);
73 extern int safe_read_memory_unsigned_integer (CORE_ADDR memaddr, int len,
74 enum bfd_endian byte_order,
75 ULONGEST *return_value);
77 /* Read an integer from debugged code memory, given address,
78 number of bytes, and byte order for code. */
80 extern LONGEST read_code_integer (CORE_ADDR memaddr, int len,
81 enum bfd_endian byte_order);
83 /* Read an unsigned integer from debugged code memory, given address,
84 number of bytes, and byte order for code. */
86 extern ULONGEST read_code_unsigned_integer (CORE_ADDR memaddr,
88 enum bfd_endian byte_order);
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
94 extern void read_memory_string (CORE_ADDR, char *, int);
96 /* Read the pointer of type TYPE at ADDR, and return the address it
99 CORE_ADDR read_memory_typed_address (CORE_ADDR addr, struct type *type);
101 /* Same as target_write_memory, but report an error if can't
104 extern void write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
107 /* Same as write_memory, but notify 'memory_changed' observers. */
109 extern void write_memory_with_notification (CORE_ADDR memaddr,
110 const bfd_byte *myaddr,
113 /* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer. */
114 extern void write_memory_unsigned_integer (CORE_ADDR addr, int len,
115 enum bfd_endian byte_order,
118 /* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer. */
119 extern void write_memory_signed_integer (CORE_ADDR addr, int len,
120 enum bfd_endian byte_order,
123 /* Hook for `exec_file_command' command to call. */
125 extern void (*deprecated_exec_file_display_hook) (const char *filename);
127 /* Hook for "file_command", which is more useful than above
128 (because it is invoked AFTER symbols are read, not before). */
130 extern void (*deprecated_file_changed_hook) (const char *filename);
132 extern void specify_exec_file_hook (void (*hook) (const char *filename));
134 /* Binary File Diddler for the core file. */
136 #define core_bfd (current_program_space->cbfd)
138 /* corelow.c target. It is never NULL after GDB initialization. */
140 extern struct target_ops *the_core_target;
142 /* Whether to open exec and core files read-only or read-write. */
144 extern int write_files;
146 /* Open and set up the core file bfd. */
148 extern void core_target_open (const char *arg, int from_tty);
150 extern void core_file_command (const char *filename, int from_tty);
152 extern void exec_file_attach (const char *filename, int from_tty);
154 /* If the filename of the main executable is unknown, attempt to
155 determine it. If a filename is determined, proceed as though
156 it was just specified with the "file" command. Do nothing if
157 the filename of the main executable is already known.
158 DEFER_BP_RESET uses SYMFILE_DEFER_BP_RESET for the main symbol file. */
160 extern void exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty);
162 extern void validate_files (void);
164 /* The current default bfd target. */
166 extern char *gnutarget;
168 extern void set_gnutarget (const char *);
170 /* Structure to keep track of core register reading functions for
171 various core file types. */
176 /* BFD flavour that a core file handler is prepared to read. This
177 can be used by the handler's core tasting function as a first
178 level filter to reject BFD's that don't have the right
181 enum bfd_flavour core_flavour;
183 /* Core file handler function to call to recognize corefile
184 formats that BFD rejects. Some core file format just don't fit
185 into the BFD model, or may require other resources to identify
186 them, that simply aren't available to BFD (such as symbols from
187 another file). Returns nonzero if the handler recognizes the
188 format, zero otherwise. */
190 int (*check_format) (bfd *);
192 /* Core file handler function to call to ask if it can handle a
193 given core file format or not. Returns zero if it can't,
194 nonzero otherwise. */
196 int (*core_sniffer) (struct core_fns *, bfd *);
198 /* Extract the register values out of the core file and supply them
201 CORE_REG_SECT points to the register values themselves, read into
204 CORE_REG_SIZE is the size of that area.
206 WHICH says which set of registers we are handling:
207 0 --- integer registers
208 2 --- floating-point registers, on machines where they are
210 3 --- extended floating-point registers, on machines where
211 these are present in yet a third area. (GNU/Linux uses
212 this to get at the SSE registers.)
214 REG_ADDR is the offset from u.u_ar0 to the register values relative to
215 core_reg_sect. This is used with old-fashioned core files to locate the
216 registers in a large upage-plus-stack ".reg" section. Original upage
217 address X is at location core_reg_sect+x+reg_addr. */
219 void (*core_read_registers) (struct regcache *regcache,
221 unsigned core_reg_size,
222 int which, CORE_ADDR reg_addr);
224 /* Finds the next struct core_fns. They are allocated and
225 initialized in whatever module implements the functions pointed
226 to; an initializer calls deprecated_add_core_fns to add them to
229 struct core_fns *next;
233 /* Build either a single-thread or multi-threaded section name for
236 If ptid's lwp member is zero, we want to do the single-threaded
237 thing: look for a section named NAME (as passed to the
238 constructor). If ptid's lwp member is non-zero, we'll want do the
239 multi-threaded thing: look for a section named "NAME/LWP", where
240 LWP is the shortest ASCII decimal representation of ptid's lwp
243 class thread_section_name
246 /* NAME is the single-threaded section name. If PTID represents an
247 LWP, then the build section name is "NAME/LWP", otherwise it's
248 just "NAME" unmodified. */
249 thread_section_name (const char *name, ptid_t ptid)
253 m_storage = string_printf ("%s/%ld", name, ptid.lwp ());
254 m_section_name = m_storage.c_str ();
257 m_section_name = name;
260 /* Return the computed section name. The result is valid as long as
261 this thread_section_name object is live. */
262 const char *c_str () const
263 { return m_section_name; }
265 DISABLE_COPY_AND_ASSIGN (thread_section_name);
268 /* Either a pointer into M_STORAGE, or a pointer to the name passed
269 as parameter to the constructor. */
270 const char *m_section_name;
271 /* If we need to build a new section name, this is where we store
273 std::string m_storage;
276 /* NOTE: cagney/2004-04-05: Replaced by "regset.h" and
277 regset_from_core_section(). */
278 extern void deprecated_add_core_fns (struct core_fns *cf);
279 extern int default_core_sniffer (struct core_fns *cf, bfd * abfd);
280 extern int default_check_format (bfd * abfd);
282 #endif /* !defined (GDBCORE_H) */