Change the stream argument to _filtered to GDB_FILE *.
[deliverable/binutils-gdb.git] / gdb / gould-xdep.c
CommitLineData
dd3b648e
RP
1/* Low level interface to ptrace, for GDB when running under Unix.
2 Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
3
4This file is part of GDB.
5
99a7de40 6This program is free software; you can redistribute it and/or modify
dd3b648e 7it under the terms of the GNU General Public License as published by
99a7de40
JG
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
dd3b648e 10
99a7de40 11This program is distributed in the hope that it will be useful,
dd3b648e
RP
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
99a7de40
JG
17along with this program; if not, write to the Free Software
18Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
dd3b648e 19
dd3b648e 20#include "defs.h"
dd3b648e
RP
21#include "frame.h"
22#include "inferior.h"
23
24#include <sys/param.h>
25#include <sys/dir.h>
26#include <signal.h>
27#include <sys/user.h>
28#include <sys/ioctl.h>
29#include <fcntl.h>
30
31#include "gdbcore.h"
32
33#include <sys/file.h>
34#include <sys/stat.h>
1ab3bf1b 35
dd3b648e
RP
36\f
37/* Work with core dump and executable files, for GDB.
38 This code would be in core.c if it weren't machine-dependent. */
39
40void
41core_file_command (filename, from_tty)
42 char *filename;
43 int from_tty;
44{
45 int val;
46 extern char registers[];
47
48 /* Discard all vestiges of any previous core file
49 and mark data and stack spaces as empty. */
50
51 if (corefile)
52 free (corefile);
53 corefile = 0;
54
55 if (corechan >= 0)
56 close (corechan);
57 corechan = -1;
58
59 data_start = 0;
60 data_end = 0;
61 stack_start = STACK_END_ADDR;
62 stack_end = STACK_END_ADDR;
63
64 /* Now, if a new core file was specified, open it and digest it. */
65
66 if (filename)
67 {
68 filename = tilde_expand (filename);
69 make_cleanup (free, filename);
70
71 if (have_inferior_p ())
6fe90fc8 72 error ("To look at a core file, you must kill the program with \"kill\".");
dd3b648e
RP
73 corechan = open (filename, O_RDONLY, 0);
74 if (corechan < 0)
75 perror_with_name (filename);
76 /* 4.2-style (and perhaps also sysV-style) core dump file. */
77 {
78 struct user u;
79 int reg_offset;
80
81 val = myread (corechan, &u, sizeof u);
82 if (val < 0)
83 perror_with_name (filename);
84 data_start = exec_data_start;
85
86 data_end = data_start + NBPG * u.u_dsize;
87 stack_start = stack_end - NBPG * u.u_ssize;
88 data_offset = NBPG * UPAGES;
89 stack_offset = NBPG * (UPAGES + u.u_dsize);
90 reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR;
91
92 /* I don't know where to find this info.
93 So, for now, mark it as not available. */
94 core_aouthdr.a_magic = 0;
95
96 /* Read the register values out of the core file and store
97 them where `read_register' will find them. */
98
99 {
100 register int regno;
101
102 for (regno = 0; regno < NUM_REGS; regno++)
103 {
104 char buf[MAX_REGISTER_RAW_SIZE];
105
106 val = lseek (corechan, register_addr (regno, reg_offset), 0);
107 if (val < 0)
108 perror_with_name (filename);
109
110 val = myread (corechan, buf, sizeof buf);
111 if (val < 0)
112 perror_with_name (filename);
113 supply_register (regno, buf);
114 }
115 }
116 }
117 if (filename[0] == '/')
118 corefile = savestring (filename, strlen (filename));
119 else
120 {
58ae87f6 121 corefile = concat (current_directory, "/", filename, NULL);
dd3b648e
RP
122 }
123
124 set_current_frame ( create_new_frame (read_register (FP_REGNUM),
125 read_pc ()));
126 select_frame (get_current_frame (), 0);
127 validate_files ();
128 }
129 else if (from_tty)
130 printf ("No core file now.\n");
131}
This page took 0.152603 seconds and 4 git commands to generate.