119370Spst/* Machine independent variables that describe the core file under GDB.
298944Sobrien   Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
398944Sobrien   1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
419370Spst
598944Sobrien   This file is part of GDB.
619370Spst
798944Sobrien   This program is free software; you can redistribute it and/or modify
898944Sobrien   it under the terms of the GNU General Public License as published by
998944Sobrien   the Free Software Foundation; either version 2 of the License, or
1098944Sobrien   (at your option) any later version.
1119370Spst
1298944Sobrien   This program is distributed in the hope that it will be useful,
1398944Sobrien   but WITHOUT ANY WARRANTY; without even the implied warranty of
1498944Sobrien   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1598944Sobrien   GNU General Public License for more details.
1619370Spst
1798944Sobrien   You should have received a copy of the GNU General Public License
1898944Sobrien   along with this program; if not, write to the Free Software
1998944Sobrien   Foundation, Inc., 59 Temple Place - Suite 330,
2098944Sobrien   Boston, MA 02111-1307, USA.  */
2119370Spst
2219370Spst/* Interface routines for core, executable, etc.  */
2319370Spst
2419370Spst#if !defined (GDBCORE_H)
2519370Spst#define GDBCORE_H 1
2619370Spst
27130803Smarcelstruct type;
28130803Smarcel
2919370Spst#include "bfd.h"
3019370Spst
3119370Spst/* Return the name of the executable file as a string.
3219370Spst   ERR nonzero means get error if there is none specified;
3319370Spst   otherwise return 0 in that case.  */
3419370Spst
3598944Sobrienextern char *get_exec_file (int err);
3619370Spst
3719370Spst/* Nonzero if there is a core file.  */
3819370Spst
3998944Sobrienextern int have_core_file_p (void);
4019370Spst
4119370Spst/* Read "memory data" from whatever target or inferior we have.
4219370Spst   Returns zero if successful, errno value if not.  EIO is used for
4319370Spst   address out of bounds.  If breakpoints are inserted, returns shadow
4419370Spst   contents, not the breakpoints themselves.  From breakpoint.c.  */
4519370Spst
4698944Sobrienextern int read_memory_nobpt (CORE_ADDR memaddr, char *myaddr, unsigned len);
4719370Spst
4819370Spst/* Report a memory error with error().  */
4919370Spst
5098944Sobrienextern void memory_error (int status, CORE_ADDR memaddr);
5119370Spst
5219370Spst/* Like target_read_memory, but report an error if can't read.  */
5319370Spst
5498944Sobrienextern void read_memory (CORE_ADDR memaddr, char *myaddr, int len);
5519370Spst
5619370Spst/* Read an integer from debugged memory, given address and number of
5719370Spst   bytes.  */
5819370Spst
5998944Sobrienextern LONGEST read_memory_integer (CORE_ADDR memaddr, int len);
6098944Sobrienextern int safe_read_memory_integer (CORE_ADDR memaddr, int len, LONGEST *return_value);
6119370Spst
6219370Spst/* Read an unsigned integer from debugged memory, given address and
6319370Spst   number of bytes.  */
6419370Spst
6598944Sobrienextern ULONGEST read_memory_unsigned_integer (CORE_ADDR memaddr, int len);
6619370Spst
6746283Sdfr/* Read a null-terminated string from the debuggee's memory, given address,
6898944Sobrien * a buffer into which to place the string, and the maximum available space */
69130803Smarcel
7098944Sobrienextern void read_memory_string (CORE_ADDR, char *, int);
7146283Sdfr
72130803Smarcel/* Read the pointer of type TYPE at ADDR, and return the address it
73130803Smarcel   represents. */
74130803Smarcel
75130803SmarcelCORE_ADDR read_memory_typed_address (CORE_ADDR addr, struct type *type);
76130803Smarcel
7719370Spst/* This takes a char *, not void *.  This is probably right, because
7819370Spst   passing in an int * or whatever is wrong with respect to
7919370Spst   byteswapping, alignment, different sizes for host vs. target types,
8019370Spst   etc.  */
8119370Spst
8298944Sobrienextern void write_memory (CORE_ADDR memaddr, char *myaddr, int len);
8319370Spst
8498944Sobrien/* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer.  */
8598944Sobrienextern void write_memory_unsigned_integer (CORE_ADDR addr, int len,
8698944Sobrien                                           ULONGEST value);
8798944Sobrien
8898944Sobrien/* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer.  */
8998944Sobrienextern void write_memory_signed_integer (CORE_ADDR addr, int len,
9098944Sobrien                                         LONGEST value);
9198944Sobrien
9298944Sobrienextern void generic_search (int len, char *data, char *mask,
9398944Sobrien			    CORE_ADDR startaddr, int increment,
9498944Sobrien			    CORE_ADDR lorange, CORE_ADDR hirange,
9598944Sobrien			    CORE_ADDR * addr_found, char *data_found);
9619370Spst
9719370Spst/* Hook for `exec_file_command' command to call.  */
9819370Spst
9998944Sobrienextern void (*exec_file_display_hook) (char *filename);
10046283Sdfr
10146283Sdfr/* Hook for "file_command", which is more useful than above
10246283Sdfr   (because it is invoked AFTER symbols are read, not before) */
10346283Sdfr
10498944Sobrienextern void (*file_changed_hook) (char *filename);
10546283Sdfr
10698944Sobrienextern void specify_exec_file_hook (void (*hook) (char *filename));
10719370Spst
10819370Spst/* Binary File Diddlers for the exec and core files */
10919370Spst
11019370Spstextern bfd *core_bfd;
11119370Spstextern bfd *exec_bfd;
11219370Spst
11319370Spst/* Whether to open exec and core files read-only or read-write.  */
11419370Spst
11519370Spstextern int write_files;
11619370Spst
11798944Sobrienextern void core_file_command (char *filename, int from_tty);
11819370Spst
11998944Sobrienextern void exec_open (char *filename, int from_tty);
12046283Sdfr
12198944Sobrienextern void exec_file_attach (char *filename, int from_tty);
12219370Spst
12398944Sobrienextern void exec_file_clear (int from_tty);
12419370Spst
12598944Sobrienextern void validate_files (void);
12619370Spst
12798944Sobrienextern CORE_ADDR register_addr (int regno, CORE_ADDR blockend);
12819370Spst
12919370Spst#if !defined (KERNEL_U_ADDR)
13019370Spstextern CORE_ADDR kernel_u_addr;
13119370Spst#define KERNEL_U_ADDR kernel_u_addr
13219370Spst#endif
13319370Spst
13419370Spst/* The target vector for core files. */
13519370Spst
13619370Spstextern struct target_ops core_ops;
13719370Spst
13819370Spst/* The current default bfd target.  */
13919370Spst
14019370Spstextern char *gnutarget;
14119370Spst
14298944Sobrienextern void set_gnutarget (char *);
14319370Spst
14419370Spst/* Structure to keep track of core register reading functions for
14519370Spst   various core file types.  */
14619370Spst
14798944Sobrienstruct core_fns
14898944Sobrien  {
14919370Spst
15098944Sobrien    /* BFD flavour that a core file handler is prepared to read.  This
15198944Sobrien       can be used by the handler's core tasting function as a first
15298944Sobrien       level filter to reject BFD's that don't have the right
15398944Sobrien       flavour. */
15419370Spst
15598944Sobrien    enum bfd_flavour core_flavour;
15619370Spst
15798944Sobrien    /* Core file handler function to call to recognize corefile
15898944Sobrien       formats that BFD rejects.  Some core file format just don't fit
15998944Sobrien       into the BFD model, or may require other resources to identify
16098944Sobrien       them, that simply aren't available to BFD (such as symbols from
16198944Sobrien       another file).  Returns nonzero if the handler recognizes the
16298944Sobrien       format, zero otherwise. */
16319370Spst
16498944Sobrien    int (*check_format) (bfd *);
16519370Spst
16698944Sobrien    /* Core file handler function to call to ask if it can handle a
16798944Sobrien       given core file format or not.  Returns zero if it can't,
16898944Sobrien       nonzero otherwise. */
16919370Spst
17098944Sobrien    int (*core_sniffer) (struct core_fns *, bfd *);
17119370Spst
17298944Sobrien    /* Extract the register values out of the core file and store them where
17398944Sobrien       `read_register' will find them.
17419370Spst
17598944Sobrien       CORE_REG_SECT points to the register values themselves, read into
17698944Sobrien       memory.
17719370Spst
17898944Sobrien       CORE_REG_SIZE is the size of that area.
17919370Spst
18098944Sobrien       WHICH says which set of registers we are handling:
18198944Sobrien         0 --- integer registers
18298944Sobrien         2 --- floating-point registers, on machines where they are
18398944Sobrien               discontiguous
18498944Sobrien         3 --- extended floating-point registers, on machines where
18598944Sobrien               these are present in yet a third area.  (GNU/Linux uses
18698944Sobrien               this to get at the SSE registers.)
18719370Spst
18898944Sobrien       REG_ADDR is the offset from u.u_ar0 to the register values relative to
18998944Sobrien       core_reg_sect.  This is used with old-fashioned core files to locate the
19098944Sobrien       registers in a large upage-plus-stack ".reg" section.  Original upage
19198944Sobrien       address X is at location core_reg_sect+x+reg_addr. */
19219370Spst
19398944Sobrien    void (*core_read_registers) (char *core_reg_sect,
19498944Sobrien				 unsigned core_reg_size,
19598944Sobrien				 int which, CORE_ADDR reg_addr);
19619370Spst
19798944Sobrien    /* Finds the next struct core_fns.  They are allocated and initialized
19898944Sobrien       in whatever module implements the functions pointed to; an
19998944Sobrien       initializer calls add_core_fns to add them to the global chain.  */
20098944Sobrien
20198944Sobrien    struct core_fns *next;
20298944Sobrien
20398944Sobrien  };
20498944Sobrien
20598944Sobrienextern void add_core_fns (struct core_fns *cf);
20698944Sobrienextern int default_core_sniffer (struct core_fns *cf, bfd * abfd);
20798944Sobrienextern int default_check_format (bfd * abfd);
20898944Sobrien
20998944Sobrien#endif /* !defined (GDBCORE_H) */
210