Change the stream argument to _filtered to GDB_FILE *.
[deliverable/binutils-gdb.git] / gdb / altos-xdep.c
CommitLineData
dd3b648e
RP
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.
4
5This file is part of GDB.
6
99a7de40 7This program is free software; you can redistribute it and/or modify
dd3b648e 8it under the terms of the GNU General Public License as published by
99a7de40
JG
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
dd3b648e 11
99a7de40 12This program is distributed in the hope that it will be useful,
dd3b648e
RP
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
99a7de40
JG
18along with this program; if not, write to the Free Software
19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
dd3b648e 20
dd3b648e 21#include "defs.h"
dd3b648e
RP
22#include "frame.h"
23#include "inferior.h"
24
25#ifdef USG
26#include <sys/types.h>
27#endif
28
29#include <sys/param.h>
30#include <sys/dir.h>
31#include <signal.h>
32#include <sys/ioctl.h>
33#include <fcntl.h>
34#ifdef USG
35#include <sys/page.h>
36#ifdef ALTOS
37#include <sys/net.h>
38#include <errno.h>
39#endif
40#endif
41
42#include "gdbcore.h"
43#include <sys/user.h> /* After a.out.h */
44#include <sys/file.h>
45#include <sys/stat.h>
1ab3bf1b 46
dd3b648e
RP
47\f
48/* Work with core dump and executable files, for GDB.
49 This code would be in core.c if it weren't machine-dependent. */
50
51void
52core_file_command (filename, from_tty)
53 char *filename;
54 int from_tty;
55{
56 int val;
57 extern char registers[];
58
59 /* Discard all vestiges of any previous core file
60 and mark data and stack spaces as empty. */
61
62 if (corefile)
63 free (corefile);
64 corefile = 0;
65
66 if (corechan >= 0)
67 close (corechan);
68 corechan = -1;
69
70 data_start = 0;
71 data_end = 0;
72 stack_start = STACK_END_ADDR;
73 stack_end = STACK_END_ADDR;
74
75 /* Now, if a new core file was specified, open it and digest it. */
76
77 if (filename)
78 {
79 filename = tilde_expand (filename);
80 make_cleanup (free, filename);
81
82 if (have_inferior_p ())
6fe90fc8 83 error ("To look at a core file, you must kill the program with \"kill\".");
dd3b648e
RP
84 corechan = open (filename, O_RDONLY, 0);
85 if (corechan < 0)
86 perror_with_name (filename);
87 /* 4.2-style (and perhaps also sysV-style) core dump file. */
88 {
89 struct user u;
90
91 unsigned int reg_offset;
92
93 val = myread (corechan, &u, sizeof u);
94 if (val < 0)
95 perror_with_name ("Not a core file: reading upage");
96 if (val != sizeof u)
97 error ("Not a core file: could only read %d bytes", val);
98 data_start = exec_data_start;
99
100#if !defined (NBPG)
101#define NBPG NBPP
102#endif
103#if !defined (UPAGES)
104#define UPAGES USIZE
105#endif
106
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);
111
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;
117
ade40d31 118 memcpy (&core_aouthdr, &u.u_exdata, sizeof (AOUTHDR));
199b2450 119 printf_unfiltered ("Core file is from \"%s\".\n", u.u_comm);
dd3b648e
RP
120
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);
124
125 /* Read the register values out of the core file and store
126 them where `read_register' will find them. */
127
128 {
129 register int regno;
130
131 for (regno = 0; regno < NUM_REGS; regno++)
132 {
133 char buf[MAX_REGISTER_RAW_SIZE];
134
135 val = lseek (corechan, register_addr (regno, reg_offset), 0);
136 if (val < 0
137 || (val = myread (corechan, buf, sizeof buf)) < 0)
138 {
139 char * buffer = (char *) alloca (strlen (reg_names[regno])
140 + 30);
141 strcpy (buffer, "Reading register ");
142 strcat (buffer, reg_names[regno]);
143
144 perror_with_name (buffer);
145 }
146
147 supply_register (regno, buf);
148 }
149 }
150 }
151 if (filename[0] == '/')
152 corefile = savestring (filename, strlen (filename));
153 else
154 {
58ae87f6 155 corefile = concat (current_directory, "/", filename, NULL);
dd3b648e
RP
156 }
157
158 set_current_frame ( create_new_frame (read_register (FP_REGNUM),
159 read_pc ()));
160 select_frame (get_current_frame (), 0);
161 validate_files ();
162 }
163 else if (from_tty)
199b2450 164 printf_unfiltered ("No core file now.\n");
dd3b648e 165}
This page took 0.135752 seconds and 4 git commands to generate.