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