| 1 | /* Support for dumping and reloading various pieces of GDB's internal state. |
| 2 | Copyright 1992 Free Software Foundation, Inc. |
| 3 | Contributed by Cygnus Support, using pieces from other GDB modules. |
| 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
| 20 | |
| 21 | /* This file provides definitions used for reading and writing gdb |
| 22 | state files. State files have a fairly simple form which is intended |
| 23 | to be easily extensible. See state.c for further documentation. */ |
| 24 | |
| 25 | #if !defined (_STATE_H) |
| 26 | #define _STATE_H |
| 27 | |
| 28 | /* State file-header */ |
| 29 | |
| 30 | typedef struct { |
| 31 | unsigned char sf_mag0; /* Magic number byte 0 */ |
| 32 | unsigned char sf_mag1; /* Magic number byte 1 */ |
| 33 | unsigned char sf_mag2; /* Magic number byte 2 */ |
| 34 | unsigned char sf_mag3; /* Magic number byte 3 */ |
| 35 | unsigned long sf_ftoff; /* File offset to start of form-tree */ |
| 36 | unsigned long sf_ftsize; /* Size of the form-tree, in bytes */ |
| 37 | } sf_hdr; |
| 38 | |
| 39 | |
| 40 | #define SF_MAG0 'g' /* Magic number byte 0 value */ |
| 41 | #define SF_MAG1 'd' /* Magic number byte 1 value */ |
| 42 | #define SF_MAG2 'b' /* Magic number byte 2 value */ |
| 43 | #define SF_MAG3 '\000' /* Magic number byte 3 value */ |
| 44 | |
| 45 | #define SF_GOOD_MAGIC(asfd) ((asfd) -> hdr.sf_mag0 == SF_MAG0 && \ |
| 46 | (asfd) -> hdr.sf_mag1 == SF_MAG1 && \ |
| 47 | (asfd) -> hdr.sf_mag2 == SF_MAG2 && \ |
| 48 | (asfd) -> hdr.sf_mag3 == SF_MAG3) |
| 49 | |
| 50 | /* The internal form-tree is formed from nodes that contain pointers |
| 51 | to the first sibling, the first child, a backpointer to the parent, |
| 52 | and a pointer to the actual data for the node. This allows all |
| 53 | tree nodes to have the same sized structure, but support variable |
| 54 | numbers of child nodes per parent node. The backpointer for the |
| 55 | parent is required for simplier tree walks. */ |
| 56 | |
| 57 | struct formnode |
| 58 | { |
| 59 | struct formnode *sibling; /* Pointer to first sibling */ |
| 60 | struct formnode *child; /* Pointer to first child */ |
| 61 | struct formnode *parent; /* Backpointer to parent */ |
| 62 | char *nodedata; /* Pointer to the nodes data */ |
| 63 | unsigned long treesize; /* Size of subtree rooted here */ |
| 64 | }; |
| 65 | |
| 66 | /* A state file descriptor is defined by the following structure. */ |
| 67 | |
| 68 | typedef struct |
| 69 | { |
| 70 | char *filename; /* Full pathname of the state file */ |
| 71 | FILE *fp; /* Open file pointer for the state file */ |
| 72 | sf_hdr hdr; /* Copy of the state file-header */ |
| 73 | char *formtree; /* Pointer to in-memory copy of form-tree */ |
| 74 | } sfd; |
| 75 | |
| 76 | extern sfd * |
| 77 | sfd_fopen PARAMS ((char *, char *)); |
| 78 | |
| 79 | extern void |
| 80 | sfd_fclose PARAMS ((sfd *)); |
| 81 | |
| 82 | extern struct objfile * |
| 83 | objfile_from_statefile PARAMS ((sfd *)); |
| 84 | |
| 85 | #endif /* !defined (_STATE_H) */ |