]> Git Repo - binutils.git/blame - gdb/umax-xdep.c
One step closer.
[binutils.git] / gdb / umax-xdep.c
CommitLineData
dd3b648e
RP
1/* umax host stuff.
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
RP
19
20#include <stdio.h>
21#include "defs.h"
dd3b648e
RP
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
42void
43core_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 {
58ae87f6 128 corefile = concat (current_directory, "/", filename, NULL);
dd3b648e
RP
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.099241 seconds and 4 git commands to generate.