Output hex with local_hex_string for Modula-2 support.
[deliverable/binutils-gdb.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"
22#include "param.h"
23#include "frame.h"
24#include "inferior.h"
25
26#include <sys/param.h>
27#include <sys/dir.h>
28#include <signal.h>
29#include <sys/ioctl.h>
30#include <fcntl.h>
31
32#include "gdbcore.h"
33#include <sys/ptrace.h>
34#define PTRACE_ATTACH PT_ATTACH
35#define PTRACE_DETACH PT_FREEPROC
36
37#include <sys/file.h>
38#include <sys/stat.h>
39
40/* Work with core dump and executable files, for GDB.
41 This code would be in core.c if it weren't machine-dependent. */
42
43void
44core_file_command (filename, from_tty)
45 char *filename;
46 int from_tty;
47{
48 int val;
49 extern char registers[];
50
51 /* Discard all vestiges of any previous core file
52 and mark data and stack spaces as empty. */
53
54 if (corefile)
55 free (corefile);
56 corefile = 0;
57
58 if (corechan >= 0)
59 close (corechan);
60 corechan = -1;
61
62 data_start = 0;
63 data_end = 0;
64 stack_start = STACK_END_ADDR;
65 stack_end = STACK_END_ADDR;
66
67 /* Now, if a new core file was specified, open it and digest it. */
68
69 if (filename)
70 {
71 filename = tilde_expand (filename);
72 make_cleanup (free, filename);
73
74 if (have_inferior_p ())
75 error ("To look at a core file, you must kill the inferior with \"kill\".");
76 corechan = open (filename, O_RDONLY, 0);
77 if (corechan < 0)
78 perror_with_name (filename);
79 /* 4.2-style (and perhaps also sysV-style) core dump file. */
80 {
81 struct ptrace_user u;
82 int reg_offset;
83
84 val = myread (corechan, &u, sizeof u);
85 if (val < 0)
86 perror_with_name (filename);
87 data_start = exec_data_start;
88
89 data_end = data_start + u.pt_dsize;
90 stack_start = stack_end - u.pt_ssize;
91 data_offset = sizeof u;
92 stack_offset = data_offset + u.pt_dsize;
93 reg_offset = 0;
94
95 bcopy (&u.pt_aouthdr, &core_aouthdr, sizeof (AOUTHDR));
96 printf ("Core file is from \"%s\".\n", u.pt_comm);
97 if (u.pt_signal > 0)
98 printf ("Program terminated with signal %d, %s.\n",
99 u.pt_signal,
100 u.pt_signal < NSIG
101 ? sys_siglist[u.pt_signal]
102 : "(undocumented)");
103
104 /* Read the register values out of the core file and store
105 them where `read_register' will find them. */
106
107 {
108 register int regno;
109
110 for (regno = 0; regno < NUM_REGS; regno++)
111 {
112 char buf[MAX_REGISTER_RAW_SIZE];
113
114 val = lseek (corechan, register_addr (regno, reg_offset), 0);
115 if (val < 0)
116 perror_with_name (filename);
117
118 val = myread (corechan, buf, sizeof buf);
119 if (val < 0)
120 perror_with_name (filename);
121 supply_register (regno, buf);
122 }
123 }
124 }
125 if (filename[0] == '/')
126 corefile = savestring (filename, strlen (filename));
127 else
128 {
129 corefile = concat (current_directory, "/", filename);
130 }
131
132 set_current_frame ( create_new_frame (read_register (FP_REGNUM),
133 read_pc ()));
134 select_frame (get_current_frame (), 0);
135 validate_files ();
136 }
137 else if (from_tty)
138 printf ("No core file now.\n");
139}
This page took 0.052633 seconds and 4 git commands to generate.