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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 corefile.c if it weren't machine-dependent. */
52 core_file_command (filename
, from_tty
)
58 /* Discard all vestiges of any previous core file
59 and mark data and stack spaces as empty. */
71 stack_start
= STACK_END_ADDR
;
72 stack_end
= STACK_END_ADDR
;
74 /* Now, if a new core file was specified, open it and digest it. */
78 filename
= tilde_expand (filename
);
79 make_cleanup (free
, filename
);
81 if (have_inferior_p ())
82 error ("To look at a core file, you must kill the program with \"kill\".");
83 corechan
= open (filename
, O_RDONLY
, 0);
85 perror_with_name (filename
);
86 /* 4.2-style (and perhaps also sysV-style) core dump file. */
90 unsigned int reg_offset
;
92 val
= myread (corechan
, &u
, sizeof u
);
94 perror_with_name ("Not a core file: reading upage");
96 error ("Not a core file: could only read %d bytes", val
);
97 data_start
= exec_data_start
;
102 #if !defined (UPAGES)
106 data_end
= data_start
+ NBPG
* u
.u_dsize
;
107 stack_start
= stack_end
- NBPG
* u
.u_ssize
;
108 data_offset
= NBPG
* UPAGES
+ exec_data_start
% NBPG
/* Not sure about this //jkp */;
109 stack_offset
= NBPG
* (UPAGES
+ u
.u_dsize
);
111 /* Some machines put an absolute address in here and some put
112 the offset in the upage of the regs. */
113 reg_offset
= (int) u
.u_state
;
114 if (reg_offset
> NBPG
* UPAGES
)
115 reg_offset
-= KERNEL_U_ADDR
;
117 memcpy (&core_aouthdr
, &u
.u_exdata
, sizeof (AOUTHDR
));
118 printf_unfiltered ("Core file is from \"%s\".\n", u
.u_comm
);
120 /* I don't know where to find this info.
121 So, for now, mark it as not available. */
122 N_SET_MAGIC (core_aouthdr
, 0);
124 /* Read the register values out of the core file and store
125 them where `read_register' will find them. */
130 for (regno
= 0; regno
< NUM_REGS
; regno
++)
132 char buf
[MAX_REGISTER_RAW_SIZE
];
134 val
= lseek (corechan
, register_addr (regno
, reg_offset
), 0);
136 || (val
= myread (corechan
, buf
, sizeof buf
)) < 0)
138 char * buffer
= (char *) alloca (strlen (REGISTER_NAME (regno
))
140 strcpy (buffer
, "Reading register ");
141 strcat (buffer
, REGISTER_NAME (regno
));
143 perror_with_name (buffer
);
146 supply_register (regno
, buf
);
150 if (filename
[0] == '/')
151 corefile
= savestring (filename
, strlen (filename
));
154 corefile
= concat (current_directory
, "/", filename
, NULL
);
157 flush_cached_frames ();
158 select_frame (get_current_frame (), 0);
162 printf_unfiltered ("No core file now.\n");
This page took 0.035486 seconds and 5 git commands to generate.