GDB (xrefs)
/tmp/gdb-7.10/gdb/gdbcore.h
Go to the documentation of this file.
1 /* Machine independent variables that describe the core file under GDB.
2 
3  Copyright (C) 1986-2015 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 /* Interface routines for core, executable, etc. */
21 
22 #if !defined (GDBCORE_H)
23 #define GDBCORE_H 1
24 
25 struct type;
26 struct regcache;
27 
28 #include "bfd.h"
29 #include "exec.h"
30 #include "target.h"
31 
32 /* Return the name of the executable file as a string.
33  ERR nonzero means get error if there is none specified;
34  otherwise return 0 in that case. */
35 
36 extern char *get_exec_file (int err);
37 
38 /* Nonzero if there is a core file. */
39 
40 extern int have_core_file_p (void);
41 
42 /* Report a memory error with error(). */
43 
44 extern void memory_error (enum target_xfer_status status, CORE_ADDR memaddr);
45 
46 /* The string 'memory_error' would use as exception message. Space
47  for the result is malloc'd, caller must free. */
48 
50  struct gdbarch *gdbarch, CORE_ADDR memaddr);
51 
52 /* Like target_read_memory, but report an error if can't read. */
53 
54 extern void read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
55 
56 /* Like target_read_stack, but report an error if can't read. */
57 
58 extern void read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
59 
60 /* Like target_read_code, but report an error if can't read. */
61 
62 extern void read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
63 
64 /* Read an integer from debugged memory, given address and number of
65  bytes. */
66 
67 extern LONGEST read_memory_integer (CORE_ADDR memaddr,
68  int len, enum bfd_endian byte_order);
69 extern int safe_read_memory_integer (CORE_ADDR memaddr, int len,
70  enum bfd_endian byte_order,
71  LONGEST *return_value);
72 
73 /* Read an unsigned integer from debugged memory, given address and
74  number of bytes. */
75 
77  int len,
78  enum bfd_endian byte_order);
79 
80 /* Read an integer from debugged code memory, given address,
81  number of bytes, and byte order for code. */
82 
83 extern LONGEST read_code_integer (CORE_ADDR memaddr, int len,
84  enum bfd_endian byte_order);
85 
86 /* Read an unsigned integer from debugged code memory, given address,
87  number of bytes, and byte order for code. */
88 
90  int len,
91  enum bfd_endian byte_order);
92 
93 /* Read a null-terminated string from the debuggee's memory, given
94  address, a buffer into which to place the string, and the maximum
95  available space. */
96 
97 extern void read_memory_string (CORE_ADDR, char *, int);
98 
99 /* Read the pointer of type TYPE at ADDR, and return the address it
100  represents. */
101 
103 
104 /* Same as target_write_memory, but report an error if can't
105  write. */
106 
107 extern void write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
108  ssize_t len);
109 
110 /* Same as write_memory, but notify 'memory_changed' observers. */
111 
112 extern void write_memory_with_notification (CORE_ADDR memaddr,
113  const bfd_byte *myaddr,
114  ssize_t len);
115 
116 /* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer. */
117 extern void write_memory_unsigned_integer (CORE_ADDR addr, int len,
118  enum bfd_endian byte_order,
119  ULONGEST value);
120 
121 /* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer. */
122 extern void write_memory_signed_integer (CORE_ADDR addr, int len,
123  enum bfd_endian byte_order,
124  LONGEST value);
125 
126 /* Hook for `exec_file_command' command to call. */
127 
128 extern void (*deprecated_exec_file_display_hook) (const char *filename);
129 
130 /* Hook for "file_command", which is more useful than above
131  (because it is invoked AFTER symbols are read, not before). */
132 
133 extern void (*deprecated_file_changed_hook) (char *filename);
134 
135 extern void specify_exec_file_hook (void (*hook) (const char *filename));
136 
137 /* Binary File Diddler for the core file. */
138 
139 extern bfd *core_bfd;
140 
141 extern struct target_ops *core_target;
142 
143 /* Whether to open exec and core files read-only or read-write. */
144 
145 extern int write_files;
146 
147 extern void core_file_command (char *filename, int from_tty);
148 
149 extern void exec_file_attach (const char *filename, int from_tty);
150 
151 /* If the filename of the main executable is unknown, attempt to
152  determine it. If a filename is determined, proceed as though
153  it was just specified with the "file" command. Do nothing if
154  the filename of the main executable is already known. */
155 
156 extern void exec_file_locate_attach (int pid, int from_tty);
157 
158 extern void exec_file_clear (int from_tty);
159 
160 extern void validate_files (void);
161 
162 /* The current default bfd target. */
163 
164 extern char *gnutarget;
165 
166 extern void set_gnutarget (char *);
167 
168 /* Structure to keep track of core register reading functions for
169  various core file types. */
170 
171 struct core_fns
172  {
173 
174  /* BFD flavour that a core file handler is prepared to read. This
175  can be used by the handler's core tasting function as a first
176  level filter to reject BFD's that don't have the right
177  flavour. */
178 
179  enum bfd_flavour core_flavour;
180 
181  /* Core file handler function to call to recognize corefile
182  formats that BFD rejects. Some core file format just don't fit
183  into the BFD model, or may require other resources to identify
184  them, that simply aren't available to BFD (such as symbols from
185  another file). Returns nonzero if the handler recognizes the
186  format, zero otherwise. */
187 
188  int (*check_format) (bfd *);
189 
190  /* Core file handler function to call to ask if it can handle a
191  given core file format or not. Returns zero if it can't,
192  nonzero otherwise. */
193 
194  int (*core_sniffer) (struct core_fns *, bfd *);
195 
196  /* Extract the register values out of the core file and supply them
197  into REGCACHE.
198 
199  CORE_REG_SECT points to the register values themselves, read into
200  memory.
201 
202  CORE_REG_SIZE is the size of that area.
203 
204  WHICH says which set of registers we are handling:
205  0 --- integer registers
206  2 --- floating-point registers, on machines where they are
207  discontiguous
208  3 --- extended floating-point registers, on machines where
209  these are present in yet a third area. (GNU/Linux uses
210  this to get at the SSE registers.)
211 
212  REG_ADDR is the offset from u.u_ar0 to the register values relative to
213  core_reg_sect. This is used with old-fashioned core files to locate the
214  registers in a large upage-plus-stack ".reg" section. Original upage
215  address X is at location core_reg_sect+x+reg_addr. */
216 
218  char *core_reg_sect,
219  unsigned core_reg_size,
220  int which, CORE_ADDR reg_addr);
221 
222  /* Finds the next struct core_fns. They are allocated and
223  initialized in whatever module implements the functions pointed
224  to; an initializer calls deprecated_add_core_fns to add them to
225  the global chain. */
226 
227  struct core_fns *next;
228 
229  };
230 
231 /* NOTE: cagney/2004-04-05: Replaced by "regset.h" and
232  regset_from_core_section(). */
233 extern void deprecated_add_core_fns (struct core_fns *cf);
234 extern int default_core_sniffer (struct core_fns *cf, bfd * abfd);
235 extern int default_check_format (bfd * abfd);
236 
237 #endif /* !defined (GDBCORE_H) */
void read_code(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition: corefile.c:283
void set_gnutarget(char *)
Definition: corefile.c:494
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition: corefile.c:244
void deprecated_add_core_fns(struct core_fns *cf)
Definition: corelow.c:104
void(* core_read_registers)(struct regcache *regcache, char *core_reg_sect, unsigned core_reg_size, int which, CORE_ADDR reg_addr)
Definition: gdbcore.h:217
int default_check_format(bfd *abfd)
Definition: corelow.c:164
bfd_vma CORE_ADDR
Definition: common-types.h:41
LONGEST read_memory_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
Definition: corefile.c:311
void exec_file_locate_attach(int pid, int from_tty)
Definition: exec.c:141
char * memory_error_message(enum target_xfer_status err, struct gdbarch *gdbarch, CORE_ADDR memaddr)
Definition: corefile.c:193
struct core_fns * next
Definition: gdbcore.h:227
struct target_ops * core_target
Definition: corefile.c:62
void read_stack(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition: corefile.c:271
int write_files
Definition: exec.c:67
LONGEST read_code_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
Definition: corefile.c:331
void write_memory(CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
Definition: corefile.c:389
void exec_file_clear(int from_tty)
Definition: exec.c:129
void core_file_command(char *filename, int from_tty)
Definition: corefile.c:68
bfd * core_bfd
Definition: corefile.c:58
void memory_error(enum target_xfer_status status, CORE_ADDR memaddr)
Definition: corefile.c:217
void(* deprecated_file_changed_hook)(char *filename)
Definition: exec.c:47
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t err
Definition: gnu-nat.c:1816
ULONGEST read_memory_unsigned_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
Definition: corefile.c:321
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int status
Definition: gnu-nat.c:1816
int(* core_sniffer)(struct core_fns *, bfd *)
Definition: gdbcore.h:194
target_xfer_status
Definition: target.h:219
Definition: gdbtypes.h:749
void read_memory_string(CORE_ADDR, char *, int)
Definition: corefile.c:351
void validate_files(void)
Definition: corefile.c:163
int(* check_format)(bfd *)
Definition: gdbcore.h:188
Definition: value.c:172
void write_memory_signed_integer(CORE_ADDR addr, int len, enum bfd_endian byte_order, LONGEST value)
Definition: corefile.c:425
const char const char int
Definition: command.h:229
bfd_byte gdb_byte
Definition: common-types.h:38
ULONGEST read_code_unsigned_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
Definition: corefile.c:341
char * get_exec_file(int err)
Definition: corefile.c:179
enum bfd_flavour core_flavour
Definition: gdbcore.h:179
void(* deprecated_exec_file_display_hook)(const char *filename)
Definition: corefile.c:51
CORE_ADDR read_memory_typed_address(CORE_ADDR addr, struct type *type)
Definition: corefile.c:378
void specify_exec_file_hook(void(*hook)(const char *filename))
void write_memory_with_notification(CORE_ADDR memaddr, const bfd_byte *myaddr, ssize_t len)
Definition: corefile.c:402
unsigned long long ULONGEST
Definition: common-types.h:53
int have_core_file_p(void)
int default_core_sniffer(struct core_fns *cf, bfd *abfd)
Definition: corelow.c:115
void exec_file_attach(const char *filename, int from_tty)
Definition: exec.c:195
char * gnutarget
Definition: corefile.c:437
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int int rusage_t pid_t pid
Definition: gnu-nat.c:1818
long long LONGEST
Definition: common-types.h:52
int safe_read_memory_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order, LONGEST *return_value)
Definition: corefile.c:297
void write_memory_unsigned_integer(CORE_ADDR addr, int len, enum bfd_endian byte_order, ULONGEST value)
Definition: corefile.c:412
const ULONGEST const LONGEST len
Definition: target.h:309