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