1/* Machine independent variables that describe the core file under GDB.
2   Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
3   1997, 1998, 1999, 2000, 2001 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 2 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, write to the Free Software
19   Foundation, Inc., 59 Temple Place - Suite 330,
20   Boston, MA 02111-1307, USA.  */
21
22/* Interface routines for core, executable, etc.  */
23
24#if !defined (GDBCORE_H)
25#define GDBCORE_H 1
26
27struct type;
28
29#include "bfd.h"
30
31/* Return the name of the executable file as a string.
32   ERR nonzero means get error if there is none specified;
33   otherwise return 0 in that case.  */
34
35extern char *get_exec_file (int err);
36
37/* Nonzero if there is a core file.  */
38
39extern int have_core_file_p (void);
40
41/* Read "memory data" from whatever target or inferior we have.
42   Returns zero if successful, errno value if not.  EIO is used for
43   address out of bounds.  If breakpoints are inserted, returns shadow
44   contents, not the breakpoints themselves.  From breakpoint.c.  */
45
46extern int read_memory_nobpt (CORE_ADDR memaddr, char *myaddr, unsigned len);
47
48/* Report a memory error with error().  */
49
50extern void memory_error (int status, CORE_ADDR memaddr);
51
52/* Like target_read_memory, but report an error if can't read.  */
53
54extern void read_memory (CORE_ADDR memaddr, char *myaddr, int len);
55
56/* Read an integer from debugged memory, given address and number of
57   bytes.  */
58
59extern LONGEST read_memory_integer (CORE_ADDR memaddr, int len);
60extern int safe_read_memory_integer (CORE_ADDR memaddr, int len, LONGEST *return_value);
61
62/* Read an unsigned integer from debugged memory, given address and
63   number of bytes.  */
64
65extern ULONGEST read_memory_unsigned_integer (CORE_ADDR memaddr, int len);
66
67/* Read a null-terminated string from the debuggee's memory, given address,
68 * a buffer into which to place the string, and the maximum available space */
69
70extern void read_memory_string (CORE_ADDR, char *, int);
71
72/* Read the pointer of type TYPE at ADDR, and return the address it
73   represents. */
74
75CORE_ADDR read_memory_typed_address (CORE_ADDR addr, struct type *type);
76
77/* This takes a char *, not void *.  This is probably right, because
78   passing in an int * or whatever is wrong with respect to
79   byteswapping, alignment, different sizes for host vs. target types,
80   etc.  */
81
82extern void write_memory (CORE_ADDR memaddr, char *myaddr, int len);
83
84/* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer.  */
85extern void write_memory_unsigned_integer (CORE_ADDR addr, int len,
86                                           ULONGEST value);
87
88/* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer.  */
89extern void write_memory_signed_integer (CORE_ADDR addr, int len,
90                                         LONGEST value);
91
92extern void generic_search (int len, char *data, char *mask,
93			    CORE_ADDR startaddr, int increment,
94			    CORE_ADDR lorange, CORE_ADDR hirange,
95			    CORE_ADDR * addr_found, char *data_found);
96
97/* Hook for `exec_file_command' command to call.  */
98
99extern void (*exec_file_display_hook) (char *filename);
100
101/* Hook for "file_command", which is more useful than above
102   (because it is invoked AFTER symbols are read, not before) */
103
104extern void (*file_changed_hook) (char *filename);
105
106extern void specify_exec_file_hook (void (*hook) (char *filename));
107
108/* Binary File Diddlers for the exec and core files */
109
110extern bfd *core_bfd;
111extern bfd *exec_bfd;
112
113/* Whether to open exec and core files read-only or read-write.  */
114
115extern int write_files;
116
117extern void core_file_command (char *filename, int from_tty);
118
119extern void exec_open (char *filename, int from_tty);
120
121extern void exec_file_attach (char *filename, int from_tty);
122
123extern void exec_file_clear (int from_tty);
124
125extern void validate_files (void);
126
127extern CORE_ADDR register_addr (int regno, CORE_ADDR blockend);
128
129#if !defined (KERNEL_U_ADDR)
130extern CORE_ADDR kernel_u_addr;
131#define KERNEL_U_ADDR kernel_u_addr
132#endif
133
134/* The target vector for core files. */
135
136extern struct target_ops core_ops;
137
138/* The current default bfd target.  */
139
140extern char *gnutarget;
141
142extern void set_gnutarget (char *);
143
144/* Structure to keep track of core register reading functions for
145   various core file types.  */
146
147struct core_fns
148  {
149
150    /* BFD flavour that a core file handler is prepared to read.  This
151       can be used by the handler's core tasting function as a first
152       level filter to reject BFD's that don't have the right
153       flavour. */
154
155    enum bfd_flavour core_flavour;
156
157    /* Core file handler function to call to recognize corefile
158       formats that BFD rejects.  Some core file format just don't fit
159       into the BFD model, or may require other resources to identify
160       them, that simply aren't available to BFD (such as symbols from
161       another file).  Returns nonzero if the handler recognizes the
162       format, zero otherwise. */
163
164    int (*check_format) (bfd *);
165
166    /* Core file handler function to call to ask if it can handle a
167       given core file format or not.  Returns zero if it can't,
168       nonzero otherwise. */
169
170    int (*core_sniffer) (struct core_fns *, bfd *);
171
172    /* Extract the register values out of the core file and store them where
173       `read_register' will find them.
174
175       CORE_REG_SECT points to the register values themselves, read into
176       memory.
177
178       CORE_REG_SIZE is the size of that area.
179
180       WHICH says which set of registers we are handling:
181         0 --- integer registers
182         2 --- floating-point registers, on machines where they are
183               discontiguous
184         3 --- extended floating-point registers, on machines where
185               these are present in yet a third area.  (GNU/Linux uses
186               this to get at the SSE registers.)
187
188       REG_ADDR is the offset from u.u_ar0 to the register values relative to
189       core_reg_sect.  This is used with old-fashioned core files to locate the
190       registers in a large upage-plus-stack ".reg" section.  Original upage
191       address X is at location core_reg_sect+x+reg_addr. */
192
193    void (*core_read_registers) (char *core_reg_sect,
194				 unsigned core_reg_size,
195				 int which, CORE_ADDR reg_addr);
196
197    /* Finds the next struct core_fns.  They are allocated and initialized
198       in whatever module implements the functions pointed to; an
199       initializer calls add_core_fns to add them to the global chain.  */
200
201    struct core_fns *next;
202
203  };
204
205extern void add_core_fns (struct core_fns *cf);
206extern int default_core_sniffer (struct core_fns *cf, bfd * abfd);
207extern int default_check_format (bfd * abfd);
208
209#endif /* !defined (GDBCORE_H) */
210