* dvp-opc.c (parse_vif_unpackloc,insert_vif_unpackloc): Delete.
[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 17along with this program; if not, write to the Free Software
6c9638b4 18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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>
2b576293 34#include "gdb_stat.h"
1ab3bf1b 35
dd3b648e
RP
36\f
37/* Work with core dump and executable files, for GDB.
1738bcd3 38 This code would be in corefile.c if it weren't machine-dependent. */
dd3b648e
RP
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
16726dd1 124 flush_cached_frames ();
dd3b648e
RP
125 select_frame (get_current_frame (), 0);
126 validate_files ();
127 }
128 else if (from_tty)
129 printf ("No core file now.\n");
130}
This page took 0.309641 seconds and 4 git commands to generate.