1 /* Low level interface to ptrace, for GDB when running under m68k SVR2 Unix
2 on Altos 3068. Report bugs to Jyrki Kuoppala <jkp@cs.hut.fi>
3 Copyright (C) 1989, 1991 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 2 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, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
26 #include <sys/types.h>
29 #include <sys/param.h>
32 #include <sys/ioctl.h>
43 #include <sys/user.h> /* After a.out.h */
48 /* Work with core dump and executable files, for GDB.
49 This code would be in core.c if it weren't machine-dependent. */
52 core_file_command (filename
, from_tty
)
57 extern char registers
[];
59 /* Discard all vestiges of any previous core file
60 and mark data and stack spaces as empty. */
72 stack_start
= STACK_END_ADDR
;
73 stack_end
= STACK_END_ADDR
;
75 /* Now, if a new core file was specified, open it and digest it. */
79 filename
= tilde_expand (filename
);
80 make_cleanup (free
, filename
);
82 if (have_inferior_p ())
83 error ("To look at a core file, you must kill the program with \"kill\".");
84 corechan
= open (filename
, O_RDONLY
, 0);
86 perror_with_name (filename
);
87 /* 4.2-style (and perhaps also sysV-style) core dump file. */
91 unsigned int reg_offset
;
93 val
= myread (corechan
, &u
, sizeof u
);
95 perror_with_name ("Not a core file: reading upage");
97 error ("Not a core file: could only read %d bytes", val
);
98 data_start
= exec_data_start
;
103 #if !defined (UPAGES)
107 data_end
= data_start
+ NBPG
* u
.u_dsize
;
108 stack_start
= stack_end
- NBPG
* u
.u_ssize
;
109 data_offset
= NBPG
* UPAGES
+ exec_data_start
% NBPG
/* Not sure about this //jkp */;
110 stack_offset
= NBPG
* (UPAGES
+ u
.u_dsize
);
112 /* Some machines put an absolute address in here and some put
113 the offset in the upage of the regs. */
114 reg_offset
= (int) u
.u_state
;
115 if (reg_offset
> NBPG
* UPAGES
)
116 reg_offset
-= KERNEL_U_ADDR
;
118 bcopy (&u
.u_exdata
, &core_aouthdr
, sizeof (AOUTHDR
));
119 printf ("Core file is from \"%s\".\n", u
.u_comm
);
121 /* I don't know where to find this info.
122 So, for now, mark it as not available. */
123 N_SET_MAGIC (core_aouthdr
, 0);
125 /* Read the register values out of the core file and store
126 them where `read_register' will find them. */
131 for (regno
= 0; regno
< NUM_REGS
; regno
++)
133 char buf
[MAX_REGISTER_RAW_SIZE
];
135 val
= lseek (corechan
, register_addr (regno
, reg_offset
), 0);
137 || (val
= myread (corechan
, buf
, sizeof buf
)) < 0)
139 char * buffer
= (char *) alloca (strlen (reg_names
[regno
])
141 strcpy (buffer
, "Reading register ");
142 strcat (buffer
, reg_names
[regno
]);
144 perror_with_name (buffer
);
147 supply_register (regno
, buf
);
151 if (filename
[0] == '/')
152 corefile
= savestring (filename
, strlen (filename
));
155 corefile
= concat (current_directory
, "/", filename
, NULL
);
158 set_current_frame ( create_new_frame (read_register (FP_REGNUM
),
160 select_frame (get_current_frame (), 0);
164 printf ("No core file now.\n");
This page took 0.031698 seconds and 4 git commands to generate.