1 |
104 |
markom |
/* OBSOLETE /* Low level interface to ptrace, for GDB when running under m68k SVR2 Unix */
|
2 |
|
|
/* OBSOLETE on Altos 3068. Report bugs to Jyrki Kuoppala <jkp@cs.hut.fi> */
|
3 |
|
|
/* OBSOLETE Copyright (C) 1989, 1991 Free Software Foundation, Inc. */
|
4 |
|
|
/* OBSOLETE */
|
5 |
|
|
/* OBSOLETE This file is part of GDB. */
|
6 |
|
|
/* OBSOLETE */
|
7 |
|
|
/* OBSOLETE This program is free software; you can redistribute it and/or modify */
|
8 |
|
|
/* OBSOLETE it under the terms of the GNU General Public License as published by */
|
9 |
|
|
/* OBSOLETE the Free Software Foundation; either version 2 of the License, or */
|
10 |
|
|
/* OBSOLETE (at your option) any later version. */
|
11 |
|
|
/* OBSOLETE */
|
12 |
|
|
/* OBSOLETE This program is distributed in the hope that it will be useful, */
|
13 |
|
|
/* OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
14 |
|
|
/* OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
15 |
|
|
/* OBSOLETE GNU General Public License for more details. */
|
16 |
|
|
/* OBSOLETE */
|
17 |
|
|
/* OBSOLETE You should have received a copy of the GNU General Public License */
|
18 |
|
|
/* OBSOLETE along with this program; if not, write to the Free Software */
|
19 |
|
|
/* OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *x/ */
|
20 |
|
|
/* OBSOLETE */
|
21 |
|
|
/* OBSOLETE #include "defs.h" */
|
22 |
|
|
/* OBSOLETE #include "frame.h" */
|
23 |
|
|
/* OBSOLETE #include "inferior.h" */
|
24 |
|
|
/* OBSOLETE */
|
25 |
|
|
/* OBSOLETE #ifdef USG */
|
26 |
|
|
/* OBSOLETE #include <sys/types.h> */
|
27 |
|
|
/* OBSOLETE #endif */
|
28 |
|
|
/* OBSOLETE */
|
29 |
|
|
/* OBSOLETE #include <sys/param.h> */
|
30 |
|
|
/* OBSOLETE #include <sys/dir.h> */
|
31 |
|
|
/* OBSOLETE #include <signal.h> */
|
32 |
|
|
/* OBSOLETE #include <sys/ioctl.h> */
|
33 |
|
|
/* OBSOLETE #include <fcntl.h> */
|
34 |
|
|
/* OBSOLETE #ifdef USG */
|
35 |
|
|
/* OBSOLETE #include <sys/page.h> */
|
36 |
|
|
/* OBSOLETE #ifdef ALTOS */
|
37 |
|
|
/* OBSOLETE #include <sys/net.h> */
|
38 |
|
|
/* OBSOLETE #include <errno.h> */
|
39 |
|
|
/* OBSOLETE #endif */
|
40 |
|
|
/* OBSOLETE #endif */
|
41 |
|
|
/* OBSOLETE */
|
42 |
|
|
/* OBSOLETE #include "gdbcore.h" */
|
43 |
|
|
/* OBSOLETE #include <sys/user.h> /* After a.out.h *x/ */
|
44 |
|
|
/* OBSOLETE #include <sys/file.h> */
|
45 |
|
|
/* OBSOLETE #include "gdb_stat.h" */
|
46 |
|
|
/* OBSOLETE */
|
47 |
|
|
/* OBSOLETE */
|
48 |
|
|
/* OBSOLETE /* Work with core dump and executable files, for GDB. */
|
49 |
|
|
/* OBSOLETE This code would be in corefile.c if it weren't machine-dependent. *x/ */
|
50 |
|
|
/* OBSOLETE */
|
51 |
|
|
/* OBSOLETE void */
|
52 |
|
|
/* OBSOLETE core_file_command (filename, from_tty) */
|
53 |
|
|
/* OBSOLETE char *filename; */
|
54 |
|
|
/* OBSOLETE int from_tty; */
|
55 |
|
|
/* OBSOLETE { */
|
56 |
|
|
/* OBSOLETE int val; */
|
57 |
|
|
/* OBSOLETE */
|
58 |
|
|
/* OBSOLETE /* Discard all vestiges of any previous core file */
|
59 |
|
|
/* OBSOLETE and mark data and stack spaces as empty. *x/ */
|
60 |
|
|
/* OBSOLETE */
|
61 |
|
|
/* OBSOLETE if (corefile) */
|
62 |
|
|
/* OBSOLETE free (corefile); */
|
63 |
|
|
/* OBSOLETE corefile = 0; */
|
64 |
|
|
/* OBSOLETE */
|
65 |
|
|
/* OBSOLETE if (corechan >= 0) */
|
66 |
|
|
/* OBSOLETE close (corechan); */
|
67 |
|
|
/* OBSOLETE corechan = -1; */
|
68 |
|
|
/* OBSOLETE */
|
69 |
|
|
/* OBSOLETE data_start = 0; */
|
70 |
|
|
/* OBSOLETE data_end = 0; */
|
71 |
|
|
/* OBSOLETE stack_start = STACK_END_ADDR; */
|
72 |
|
|
/* OBSOLETE stack_end = STACK_END_ADDR; */
|
73 |
|
|
/* OBSOLETE */
|
74 |
|
|
/* OBSOLETE /* Now, if a new core file was specified, open it and digest it. *x/ */
|
75 |
|
|
/* OBSOLETE */
|
76 |
|
|
/* OBSOLETE if (filename) */
|
77 |
|
|
/* OBSOLETE { */
|
78 |
|
|
/* OBSOLETE filename = tilde_expand (filename); */
|
79 |
|
|
/* OBSOLETE make_cleanup (free, filename); */
|
80 |
|
|
/* OBSOLETE */
|
81 |
|
|
/* OBSOLETE if (have_inferior_p ()) */
|
82 |
|
|
/* OBSOLETE error ("To look at a core file, you must kill the program with \"kill\"."); */
|
83 |
|
|
/* OBSOLETE corechan = open (filename, O_RDONLY, 0); */
|
84 |
|
|
/* OBSOLETE if (corechan < 0) */
|
85 |
|
|
/* OBSOLETE perror_with_name (filename); */
|
86 |
|
|
/* OBSOLETE /* 4.2-style (and perhaps also sysV-style) core dump file. *x/ */
|
87 |
|
|
/* OBSOLETE { */
|
88 |
|
|
/* OBSOLETE struct user u; */
|
89 |
|
|
/* OBSOLETE */
|
90 |
|
|
/* OBSOLETE unsigned int reg_offset; */
|
91 |
|
|
/* OBSOLETE */
|
92 |
|
|
/* OBSOLETE val = myread (corechan, &u, sizeof u); */
|
93 |
|
|
/* OBSOLETE if (val < 0) */
|
94 |
|
|
/* OBSOLETE perror_with_name ("Not a core file: reading upage"); */
|
95 |
|
|
/* OBSOLETE if (val != sizeof u) */
|
96 |
|
|
/* OBSOLETE error ("Not a core file: could only read %d bytes", val); */
|
97 |
|
|
/* OBSOLETE data_start = exec_data_start; */
|
98 |
|
|
/* OBSOLETE */
|
99 |
|
|
/* OBSOLETE #if !defined (NBPG) */
|
100 |
|
|
/* OBSOLETE #define NBPG NBPP */
|
101 |
|
|
/* OBSOLETE #endif */
|
102 |
|
|
/* OBSOLETE #if !defined (UPAGES) */
|
103 |
|
|
/* OBSOLETE #define UPAGES USIZE */
|
104 |
|
|
/* OBSOLETE #endif */
|
105 |
|
|
/* OBSOLETE */
|
106 |
|
|
/* OBSOLETE data_end = data_start + NBPG * u.u_dsize; */
|
107 |
|
|
/* OBSOLETE stack_start = stack_end - NBPG * u.u_ssize; */
|
108 |
|
|
/* OBSOLETE data_offset = NBPG * UPAGES + exec_data_start % NBPG /* Not sure about this //jkp *x/; */
|
109 |
|
|
/* OBSOLETE stack_offset = NBPG * (UPAGES + u.u_dsize); */
|
110 |
|
|
/* OBSOLETE */
|
111 |
|
|
/* OBSOLETE /* Some machines put an absolute address in here and some put */
|
112 |
|
|
/* OBSOLETE the offset in the upage of the regs. *x/ */
|
113 |
|
|
/* OBSOLETE reg_offset = (int) u.u_state; */
|
114 |
|
|
/* OBSOLETE if (reg_offset > NBPG * UPAGES) */
|
115 |
|
|
/* OBSOLETE reg_offset -= KERNEL_U_ADDR; */
|
116 |
|
|
/* OBSOLETE */
|
117 |
|
|
/* OBSOLETE memcpy (&core_aouthdr, &u.u_exdata, sizeof (AOUTHDR)); */
|
118 |
|
|
/* OBSOLETE printf_unfiltered ("Core file is from \"%s\".\n", u.u_comm); */
|
119 |
|
|
/* OBSOLETE */
|
120 |
|
|
/* OBSOLETE /* I don't know where to find this info. */
|
121 |
|
|
/* OBSOLETE So, for now, mark it as not available. *x/ */
|
122 |
|
|
/* OBSOLETE N_SET_MAGIC (core_aouthdr, 0); */
|
123 |
|
|
/* OBSOLETE */
|
124 |
|
|
/* OBSOLETE /* Read the register values out of the core file and store */
|
125 |
|
|
/* OBSOLETE them where `read_register' will find them. *x/ */
|
126 |
|
|
/* OBSOLETE */
|
127 |
|
|
/* OBSOLETE { */
|
128 |
|
|
/* OBSOLETE register int regno; */
|
129 |
|
|
/* OBSOLETE */
|
130 |
|
|
/* OBSOLETE for (regno = 0; regno < NUM_REGS; regno++) */
|
131 |
|
|
/* OBSOLETE { */
|
132 |
|
|
/* OBSOLETE char buf[MAX_REGISTER_RAW_SIZE]; */
|
133 |
|
|
/* OBSOLETE */
|
134 |
|
|
/* OBSOLETE val = lseek (corechan, register_addr (regno, reg_offset), 0); */
|
135 |
|
|
/* OBSOLETE if (val < 0 */
|
136 |
|
|
/* OBSOLETE || (val = myread (corechan, buf, sizeof buf)) < 0) */
|
137 |
|
|
/* OBSOLETE { */
|
138 |
|
|
/* OBSOLETE char * buffer = (char *) alloca (strlen (REGISTER_NAME (regno)) */
|
139 |
|
|
/* OBSOLETE + 30); */
|
140 |
|
|
/* OBSOLETE strcpy (buffer, "Reading register "); */
|
141 |
|
|
/* OBSOLETE strcat (buffer, REGISTER_NAME (regno)); */
|
142 |
|
|
/* OBSOLETE */
|
143 |
|
|
/* OBSOLETE perror_with_name (buffer); */
|
144 |
|
|
/* OBSOLETE } */
|
145 |
|
|
/* OBSOLETE */
|
146 |
|
|
/* OBSOLETE supply_register (regno, buf); */
|
147 |
|
|
/* OBSOLETE } */
|
148 |
|
|
/* OBSOLETE } */
|
149 |
|
|
/* OBSOLETE } */
|
150 |
|
|
/* OBSOLETE if (filename[0] == '/') */
|
151 |
|
|
/* OBSOLETE corefile = savestring (filename, strlen (filename)); */
|
152 |
|
|
/* OBSOLETE else */
|
153 |
|
|
/* OBSOLETE { */
|
154 |
|
|
/* OBSOLETE corefile = concat (current_directory, "/", filename, NULL); */
|
155 |
|
|
/* OBSOLETE } */
|
156 |
|
|
/* OBSOLETE */
|
157 |
|
|
/* OBSOLETE flush_cached_frames (); */
|
158 |
|
|
/* OBSOLETE select_frame (get_current_frame (), 0); */
|
159 |
|
|
/* OBSOLETE validate_files (); */
|
160 |
|
|
/* OBSOLETE } */
|
161 |
|
|
/* OBSOLETE else if (from_tty) */
|
162 |
|
|
/* OBSOLETE printf_unfiltered ("No core file now.\n"); */
|
163 |
|
|
/* OBSOLETE } */
|