OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [branches/] [oc/] [gdb-5.0/] [gdb/] [pyr-xdep.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 104 markom
/* OBSOLETE /* Low level Pyramid interface to ptrace, for GDB when running under Unix. */
2
/* OBSOLETE    Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc. */
3
/* OBSOLETE  */
4
/* OBSOLETE This file is part of GDB. */
5
/* OBSOLETE  */
6
/* OBSOLETE This program is free software; you can redistribute it and/or modify */
7
/* OBSOLETE it under the terms of the GNU General Public License as published by */
8
/* OBSOLETE the Free Software Foundation; either version 2 of the License, or */
9
/* OBSOLETE (at your option) any later version. */
10
/* OBSOLETE  */
11
/* OBSOLETE This program is distributed in the hope that it will be useful, */
12
/* OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of */
13
/* OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the */
14
/* OBSOLETE GNU General Public License for more details. */
15
/* OBSOLETE  */
16
/* OBSOLETE You should have received a copy of the GNU General Public License */
17
/* OBSOLETE along with this program; if not, write to the Free Software */
18
/* OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  *x/ */
19
/* OBSOLETE  */
20
/* OBSOLETE #include "defs.h" */
21
/* OBSOLETE #include "frame.h" */
22
/* OBSOLETE #include "inferior.h" */
23
/* OBSOLETE  */
24
/* OBSOLETE #include <sys/param.h> */
25
/* OBSOLETE #include <sys/dir.h> */
26
/* OBSOLETE #include <signal.h> */
27
/* OBSOLETE #include <sys/ioctl.h> */
28
/* OBSOLETE /* #include <fcntl.h>  Can we live without this?  *x/ */
29
/* OBSOLETE  */
30
/* OBSOLETE #include "gdbcore.h" */
31
/* OBSOLETE #include <sys/user.h>               /* After a.out.h  *x/ */
32
/* OBSOLETE #include <sys/file.h> */
33
/* OBSOLETE #include "gdb_stat.h" */
34
/* OBSOLETE  */
35
/* OBSOLETE  */
36
/* OBSOLETE void */
37
/* OBSOLETE fetch_inferior_registers (regno) */
38
/* OBSOLETE      int regno; */
39
/* OBSOLETE { */
40
/* OBSOLETE   register int datum; */
41
/* OBSOLETE   register unsigned int regaddr; */
42
/* OBSOLETE   int reg_buf[NUM_REGS+1]; */
43
/* OBSOLETE   struct user u; */
44
/* OBSOLETE   register int skipped_frames = 0; */
45
/* OBSOLETE  */
46
/* OBSOLETE   registers_fetched (); */
47
/* OBSOLETE    */
48
/* OBSOLETE   for (regno = 0; regno < 64; regno++) { */
49
/* OBSOLETE     reg_buf[regno] = ptrace (3, inferior_pid, (PTRACE_ARG3_TYPE) regno, 0); */
50
/* OBSOLETE      */
51
/* OBSOLETE #if defined(PYRAMID_CONTROL_FRAME_DEBUGGING) */
52
/* OBSOLETE     printf_unfiltered ("Fetching register %s, got %0x\n", */
53
/* OBSOLETE         REGISTER_NAME (regno), */
54
/* OBSOLETE         reg_buf[regno]); */
55
/* OBSOLETE #endif /* PYRAMID_CONTROL_FRAME_DEBUGGING *x/ */
56
/* OBSOLETE      */
57
/* OBSOLETE     if (reg_buf[regno] == -1 && errno == EIO) { */
58
/* OBSOLETE       printf_unfiltered("fetch_interior_registers: fetching register %s\n", */
59
/* OBSOLETE          REGISTER_NAME (regno)); */
60
/* OBSOLETE       errno = 0; */
61
/* OBSOLETE     } */
62
/* OBSOLETE     supply_register (regno, reg_buf+regno); */
63
/* OBSOLETE   } */
64
/* OBSOLETE   /* that leaves regs 64, 65, and 66 *x/ */
65
/* OBSOLETE   datum = ptrace (3, inferior_pid, */
66
/* OBSOLETE               (PTRACE_ARG3_TYPE) (((char *)&u.u_pcb.pcb_csp) - */
67
/* OBSOLETE               ((char *)&u)), 0); */
68
/* OBSOLETE    */
69
/* OBSOLETE    */
70
/* OBSOLETE    */
71
/* OBSOLETE   /* FIXME: Find the Current Frame Pointer (CFP). CFP is a global */
72
/* OBSOLETE      register (ie, NOT windowed), that gets saved in a frame iff */
73
/* OBSOLETE      the code for that frame has a prologue (ie, "adsf N").  If */
74
/* OBSOLETE      there is a prologue, the adsf insn saves the old cfp in */
75
/* OBSOLETE      pr13, cfp is set to sp, and N bytes of locals are allocated */
76
/* OBSOLETE      (sp is decremented by n). */
77
/* OBSOLETE      This makes finding CFP hard. I guess the right way to do it */
78
/* OBSOLETE      is:  */
79
/* OBSOLETE      - If this is the innermost frame, believe ptrace() or */
80
/* OBSOLETE      the core area. */
81
/* OBSOLETE      - Otherwise: */
82
/* OBSOLETE      Find the first insn of the current frame. */
83
/* OBSOLETE      - find the saved pc; */
84
/* OBSOLETE      - find the call insn that saved it; */
85
/* OBSOLETE      - figure out where the call is to; */
86
/* OBSOLETE      - if the first insn is an adsf, we got a frame */
87
/* OBSOLETE      pointer. *x/ */
88
/* OBSOLETE    */
89
/* OBSOLETE    */
90
/* OBSOLETE   /* Normal processors have separate stack pointers for user and */
91
/* OBSOLETE      kernel mode. Getting the last user mode frame on such */
92
/* OBSOLETE      machines is easy: the kernel context of the ptrace()'d */
93
/* OBSOLETE      process is on the kernel stack, and the USP points to what */
94
/* OBSOLETE      we want. But Pyramids only have a single cfp for both user and */
95
/* OBSOLETE      kernel mode.  And processes being ptrace()'d have some */
96
/* OBSOLETE      kernel-context control frames on their stack. */
97
/* OBSOLETE      To avoid tracing back into the kernel context of an inferior, */
98
/* OBSOLETE      we skip 0 or more contiguous control frames where the pc is */
99
/* OBSOLETE      in the kernel. *x/  */
100
/* OBSOLETE    */
101
/* OBSOLETE   while (1) { */
102
/* OBSOLETE     register int inferior_saved_pc; */
103
/* OBSOLETE     inferior_saved_pc = ptrace (1, inferior_pid, */
104
/* OBSOLETE                             (PTRACE_ARG3_TYPE) (datum+((32+15)*4)), 0); */
105
/* OBSOLETE     if (inferior_saved_pc > 0) break; */
106
/* OBSOLETE #if defined(PYRAMID_CONTROL_FRAME_DEBUGGING) */
107
/* OBSOLETE     printf_unfiltered("skipping kernel frame %08x, pc=%08x\n", datum, */
108
/* OBSOLETE        inferior_saved_pc); */
109
/* OBSOLETE #endif /* PYRAMID_CONTROL_FRAME_DEBUGGING *x/ */
110
/* OBSOLETE     skipped_frames++; */
111
/* OBSOLETE     datum -= CONTROL_STACK_FRAME_SIZE; */
112
/* OBSOLETE   } */
113
/* OBSOLETE    */
114
/* OBSOLETE   reg_buf[CSP_REGNUM] = datum; */
115
/* OBSOLETE   supply_register(CSP_REGNUM, reg_buf+CSP_REGNUM); */
116
/* OBSOLETE #ifdef  PYRAMID_CONTROL_FRAME_DEBUGGING */
117
/* OBSOLETE   if (skipped_frames) { */
118
/* OBSOLETE     fprintf_unfiltered (gdb_stderr, */
119
/* OBSOLETE          "skipped %d frames from %x to %x; cfp was %x, now %x\n", */
120
/* OBSOLETE          skipped_frames, reg_buf[CSP_REGNUM]); */
121
/* OBSOLETE   } */
122
/* OBSOLETE #endif /* PYRAMID_CONTROL_FRAME_DEBUGGING *x/ */
123
/* OBSOLETE } */
124
/* OBSOLETE  */
125
/* OBSOLETE /* Store our register values back into the inferior. */
126
/* OBSOLETE    If REGNO is -1, do this for all registers. */
127
/* OBSOLETE    Otherwise, REGNO specifies which register (so we can save time).  *x/ */
128
/* OBSOLETE  */
129
/* OBSOLETE void */
130
/* OBSOLETE store_inferior_registers (regno) */
131
/* OBSOLETE      int regno; */
132
/* OBSOLETE { */
133
/* OBSOLETE   register unsigned int regaddr; */
134
/* OBSOLETE   char buf[80]; */
135
/* OBSOLETE  */
136
/* OBSOLETE   if (regno >= 0) */
137
/* OBSOLETE     { */
138
/* OBSOLETE       if ((0 <= regno) && (regno < 64)) { */
139
/* OBSOLETE     /*regaddr = register_addr (regno, offset);*x/ */
140
/* OBSOLETE     regaddr = regno; */
141
/* OBSOLETE     errno = 0; */
142
/* OBSOLETE     ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, */
143
/* OBSOLETE             read_register (regno)); */
144
/* OBSOLETE     if (errno != 0) */
145
/* OBSOLETE       { */
146
/* OBSOLETE         sprintf (buf, "writing register number %d", regno); */
147
/* OBSOLETE         perror_with_name (buf); */
148
/* OBSOLETE       } */
149
/* OBSOLETE       } */
150
/* OBSOLETE     } */
151
/* OBSOLETE   else */
152
/* OBSOLETE     { */
153
/* OBSOLETE       for (regno = 0; regno < NUM_REGS; regno++) */
154
/* OBSOLETE     { */
155
/* OBSOLETE       /*regaddr = register_addr (regno, offset);*x/ */
156
/* OBSOLETE       regaddr = regno; */
157
/* OBSOLETE       errno = 0; */
158
/* OBSOLETE       ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, */
159
/* OBSOLETE               read_register (regno)); */
160
/* OBSOLETE       if (errno != 0) */
161
/* OBSOLETE         { */
162
/* OBSOLETE           sprintf (buf, "writing all regs, number %d", regno); */
163
/* OBSOLETE           perror_with_name (buf); */
164
/* OBSOLETE         } */
165
/* OBSOLETE     } */
166
/* OBSOLETE } */
167
/* OBSOLETE  */
168
/* OBSOLETE /*** Extensions to  core and dump files, for GDB. *x/ */
169
/* OBSOLETE  */
170
/* OBSOLETE extern unsigned int last_frame_offset; */
171
/* OBSOLETE  */
172
/* OBSOLETE #ifdef PYRAMID_CORE */
173
/* OBSOLETE  */
174
/* OBSOLETE /* Can't make definitions here static, since corefile.c needs them */
175
/* OBSOLETE    to do bounds checking on the core-file areas. O well. *x/ */
176
/* OBSOLETE  */
177
/* OBSOLETE /* have two stacks: one for data, one for register windows. *x/ */
178
/* OBSOLETE extern CORE_ADDR reg_stack_start; */
179
/* OBSOLETE extern CORE_ADDR reg_stack_end; */
180
/* OBSOLETE  */
181
/* OBSOLETE /* need this so we can find the global registers: they never get saved. *x/ */
182
/* OBSOLETE CORE_ADDR global_reg_offset; */
183
/* OBSOLETE static CORE_ADDR last_frame_address; */
184
/* OBSOLETE CORE_ADDR last_frame_offset; */
185
/* OBSOLETE  */
186
/* OBSOLETE  */
187
/* OBSOLETE /* Address in core file of start of register window stack area. */
188
/* OBSOLETE    Don't know if is this any of meaningful, useful or necessary.   *x/ */
189
/* OBSOLETE extern int reg_stack_offset; */
190
/* OBSOLETE  */
191
/* OBSOLETE #endif /* PYRAMID_CORE *x/   */
192
/* OBSOLETE  */
193
/* OBSOLETE  */
194
/* OBSOLETE /* Work with core dump and executable files, for GDB.  */
195
/* OBSOLETE    This code would be in corefile.c if it weren't machine-dependent. *x/ */
196
/* OBSOLETE  */
197
/* OBSOLETE void */
198
/* OBSOLETE core_file_command (filename, from_tty) */
199
/* OBSOLETE      char *filename; */
200
/* OBSOLETE      int from_tty; */
201
/* OBSOLETE { */
202
/* OBSOLETE   int val; */
203
/* OBSOLETE  */
204
/* OBSOLETE   /* Discard all vestiges of any previous core file */
205
/* OBSOLETE      and mark data and stack spaces as empty.  *x/ */
206
/* OBSOLETE  */
207
/* OBSOLETE   if (corefile) */
208
/* OBSOLETE     free (corefile); */
209
/* OBSOLETE   corefile = 0; */
210
/* OBSOLETE  */
211
/* OBSOLETE   if (corechan >= 0) */
212
/* OBSOLETE     close (corechan); */
213
/* OBSOLETE   corechan = -1; */
214
/* OBSOLETE  */
215
/* OBSOLETE   data_start = 0; */
216
/* OBSOLETE   data_end = 0; */
217
/* OBSOLETE   stack_start = STACK_END_ADDR; */
218
/* OBSOLETE   stack_end = STACK_END_ADDR; */
219
/* OBSOLETE  */
220
/* OBSOLETE #ifdef PYRAMID_CORE */
221
/* OBSOLETE   reg_stack_start = CONTROL_STACK_ADDR; */
222
/* OBSOLETE   reg_stack_end = CONTROL_STACK_ADDR;       /* this isn't strictly true...*x/ */
223
/* OBSOLETE #endif /* PYRAMID_CORE *x/ */
224
/* OBSOLETE  */
225
/* OBSOLETE   /* Now, if a new core file was specified, open it and digest it.  *x/ */
226
/* OBSOLETE  */
227
/* OBSOLETE   if (filename) */
228
/* OBSOLETE     { */
229
/* OBSOLETE       filename = tilde_expand (filename); */
230
/* OBSOLETE       make_cleanup (free, filename); */
231
/* OBSOLETE        */
232
/* OBSOLETE       if (have_inferior_p ()) */
233
/* OBSOLETE     error ("To look at a core file, you must kill the program with \"kill\"."); */
234
/* OBSOLETE       corechan = open (filename, O_RDONLY, 0); */
235
/* OBSOLETE       if (corechan < 0) */
236
/* OBSOLETE     perror_with_name (filename); */
237
/* OBSOLETE       /* 4.2-style (and perhaps also sysV-style) core dump file.  *x/ */
238
/* OBSOLETE       { */
239
/* OBSOLETE     struct user u; */
240
/* OBSOLETE  */
241
/* OBSOLETE     unsigned int reg_offset; */
242
/* OBSOLETE  */
243
/* OBSOLETE     val = myread (corechan, &u, sizeof u); */
244
/* OBSOLETE     if (val < 0) */
245
/* OBSOLETE       perror_with_name ("Not a core file: reading upage"); */
246
/* OBSOLETE     if (val != sizeof u) */
247
/* OBSOLETE       error ("Not a core file: could only read %d bytes", val); */
248
/* OBSOLETE     data_start = exec_data_start; */
249
/* OBSOLETE  */
250
/* OBSOLETE     data_end = data_start + NBPG * u.u_dsize; */
251
/* OBSOLETE     data_offset = NBPG * UPAGES; */
252
/* OBSOLETE     stack_offset = NBPG * (UPAGES + u.u_dsize); */
253
/* OBSOLETE  */
254
/* OBSOLETE     /* find registers in core file *x/ */
255
/* OBSOLETE #ifdef PYRAMID_PTRACE */
256
/* OBSOLETE     stack_start = stack_end - NBPG * u.u_ussize; */
257
/* OBSOLETE     reg_stack_offset = stack_offset + (NBPG *u.u_ussize); */
258
/* OBSOLETE     reg_stack_end = reg_stack_start + NBPG * u.u_cssize; */
259
/* OBSOLETE  */
260
/* OBSOLETE     last_frame_address = ((int) u.u_pcb.pcb_csp); */
261
/* OBSOLETE     last_frame_offset = reg_stack_offset + last_frame_address */
262
/* OBSOLETE             - CONTROL_STACK_ADDR ; */
263
/* OBSOLETE     global_reg_offset = (char *)&u - (char *)&u.u_pcb.pcb_gr0 ; */
264
/* OBSOLETE  */
265
/* OBSOLETE     /* skip any control-stack frames that were executed in the */
266
/* OBSOLETE        kernel. *x/ */
267
/* OBSOLETE  */
268
/* OBSOLETE     while (1) { */
269
/* OBSOLETE         char buf[4]; */
270
/* OBSOLETE         val = lseek (corechan, last_frame_offset+(47*4), 0); */
271
/* OBSOLETE         if (val < 0) */
272
/* OBSOLETE                 perror_with_name (filename); */
273
/* OBSOLETE         val = myread (corechan, buf, sizeof buf); */
274
/* OBSOLETE         if (val < 0) */
275
/* OBSOLETE                 perror_with_name (filename); */
276
/* OBSOLETE  */
277
/* OBSOLETE         if (*(int *)buf >= 0) */
278
/* OBSOLETE                 break; */
279
/* OBSOLETE         printf_unfiltered ("skipping frame %s\n", local_hex_string (last_frame_address)); */
280
/* OBSOLETE         last_frame_offset -= CONTROL_STACK_FRAME_SIZE; */
281
/* OBSOLETE         last_frame_address -= CONTROL_STACK_FRAME_SIZE; */
282
/* OBSOLETE     } */
283
/* OBSOLETE     reg_offset = last_frame_offset; */
284
/* OBSOLETE  */
285
/* OBSOLETE #if 1 || defined(PYRAMID_CONTROL_FRAME_DEBUGGING) */
286
/* OBSOLETE     printf_unfiltered ("Control stack pointer = %s\n", */
287
/* OBSOLETE             local_hex_string (u.u_pcb.pcb_csp)); */
288
/* OBSOLETE     printf_unfiltered ("offset to control stack %d outermost frame %d (%s)\n", */
289
/* OBSOLETE           reg_stack_offset, reg_offset, local_hex_string (last_frame_address)); */
290
/* OBSOLETE #endif /* PYRAMID_CONTROL_FRAME_DEBUGGING *x/ */
291
/* OBSOLETE  */
292
/* OBSOLETE #else /* not PYRAMID_CORE *x/ */
293
/* OBSOLETE     stack_start = stack_end - NBPG * u.u_ssize; */
294
/* OBSOLETE         reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR; */
295
/* OBSOLETE #endif /* not PYRAMID_CORE *x/ */
296
/* OBSOLETE  */
297
/* OBSOLETE #ifdef __not_on_pyr_yet */
298
/* OBSOLETE     /* Some machines put an absolute address in here and some put */
299
/* OBSOLETE        the offset in the upage of the regs.  *x/ */
300
/* OBSOLETE     reg_offset = (int) u.u_ar0; */
301
/* OBSOLETE     if (reg_offset > NBPG * UPAGES) */
302
/* OBSOLETE       reg_offset -= KERNEL_U_ADDR; */
303
/* OBSOLETE #endif */
304
/* OBSOLETE  */
305
/* OBSOLETE     /* I don't know where to find this info. */
306
/* OBSOLETE        So, for now, mark it as not available.  *x/ */
307
/* OBSOLETE     N_SET_MAGIC (core_aouthdr, 0); */
308
/* OBSOLETE  */
309
/* OBSOLETE     /* Read the register values out of the core file and store */
310
/* OBSOLETE        them where `read_register' will find them.  *x/ */
311
/* OBSOLETE  */
312
/* OBSOLETE     { */
313
/* OBSOLETE       register int regno; */
314
/* OBSOLETE  */
315
/* OBSOLETE       for (regno = 0; regno < 64; regno++) */
316
/* OBSOLETE         { */
317
/* OBSOLETE           char buf[MAX_REGISTER_RAW_SIZE]; */
318
/* OBSOLETE  */
319
/* OBSOLETE           val = lseek (corechan, register_addr (regno, reg_offset), 0); */
320
/* OBSOLETE           if (val < 0 */
321
/* OBSOLETE               || (val = myread (corechan, buf, sizeof buf)) < 0) */
322
/* OBSOLETE             { */
323
/* OBSOLETE               char * buffer = (char *) alloca (strlen (REGISTER_NAME (regno)) */
324
/* OBSOLETE                                                + 30); */
325
/* OBSOLETE               strcpy (buffer, "Reading register "); */
326
/* OBSOLETE               strcat (buffer, REGISTER_NAME (regno)); */
327
/* OBSOLETE                                                 */
328
/* OBSOLETE               perror_with_name (buffer); */
329
/* OBSOLETE             } */
330
/* OBSOLETE  */
331
/* OBSOLETE           if (val < 0) */
332
/* OBSOLETE             perror_with_name (filename); */
333
/* OBSOLETE #ifdef PYRAMID_CONTROL_FRAME_DEBUGGING */
334
/* OBSOLETE       printf_unfiltered ("[reg %s(%d), offset in file %s=0x%0x, addr =0x%0x, =%0x]\n", */
335
/* OBSOLETE           REGISTER_NAME (regno), regno, filename, */
336
/* OBSOLETE           register_addr(regno, reg_offset), */
337
/* OBSOLETE           regno * 4 + last_frame_address, */
338
/* OBSOLETE           *((int *)buf)); */
339
/* OBSOLETE #endif /* PYRAMID_CONTROL_FRAME_DEBUGGING *x/ */
340
/* OBSOLETE           supply_register (regno, buf); */
341
/* OBSOLETE         } */
342
/* OBSOLETE     } */
343
/* OBSOLETE       } */
344
/* OBSOLETE       if (filename[0] == '/') */
345
/* OBSOLETE     corefile = savestring (filename, strlen (filename)); */
346
/* OBSOLETE       else */
347
/* OBSOLETE     { */
348
/* OBSOLETE       corefile = concat (current_directory, "/", filename, NULL); */
349
/* OBSOLETE     } */
350
/* OBSOLETE  */
351
/* OBSOLETE #if 1 || defined(PYRAMID_CONTROL_FRAME_DEBUGGING) */
352
/* OBSOLETE       printf_unfiltered ("Providing CSP (%s) as nominal address of current frame.\n", */
353
/* OBSOLETE           local_hex_string(last_frame_address)); */
354
/* OBSOLETE #endif PYRAMID_CONTROL_FRAME_DEBUGGING */
355
/* OBSOLETE       /* FIXME: Which of the following is correct? *x/ */
356
/* OBSOLETE #if 0 */
357
/* OBSOLETE       set_current_frame ( create_new_frame (read_register (FP_REGNUM), */
358
/* OBSOLETE                                         read_pc ())); */
359
/* OBSOLETE #else */
360
/* OBSOLETE       set_current_frame ( create_new_frame (last_frame_address, */
361
/* OBSOLETE                                         read_pc ())); */
362
/* OBSOLETE #endif */
363
/* OBSOLETE  */
364
/* OBSOLETE       select_frame (get_current_frame (), 0); */
365
/* OBSOLETE       validate_files (); */
366
/* OBSOLETE     } */
367
/* OBSOLETE   else if (from_tty) */
368
/* OBSOLETE     printf_unfiltered ("No core file now.\n"); */
369
/* OBSOLETE } */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.