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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [arm-xdep.c] - Blame information for rev 104

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 104 markom
/* OBSOLETE /* Acorn Risc Machine host machine support. */
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, */
19
/* OBSOLETE    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 #include "opcode/arm.h" */
25
/* OBSOLETE  */
26
/* OBSOLETE #include <sys/param.h> */
27
/* OBSOLETE #include <sys/dir.h> */
28
/* OBSOLETE #include <signal.h> */
29
/* OBSOLETE #include <sys/ioctl.h> */
30
/* OBSOLETE #include <sys/ptrace.h> */
31
/* OBSOLETE #include <machine/reg.h> */
32
/* OBSOLETE  */
33
/* OBSOLETE #define N_TXTADDR(hdr) 0x8000 */
34
/* OBSOLETE #define N_DATADDR(hdr) (hdr.a_text + 0x8000) */
35
/* OBSOLETE  */
36
/* OBSOLETE #include "gdbcore.h" */
37
/* OBSOLETE  */
38
/* OBSOLETE #include <sys/user.h>               /* After a.out.h  *x/ */
39
/* OBSOLETE #include <sys/file.h> */
40
/* OBSOLETE #include "gdb_stat.h" */
41
/* OBSOLETE  */
42
/* OBSOLETE #include <errno.h> */
43
/* OBSOLETE  */
44
/* OBSOLETE void */
45
/* OBSOLETE fetch_inferior_registers (regno) */
46
/* OBSOLETE      int regno;                     /* Original value discarded *x/ */
47
/* OBSOLETE { */
48
/* OBSOLETE   register unsigned int regaddr; */
49
/* OBSOLETE   char buf[MAX_REGISTER_RAW_SIZE]; */
50
/* OBSOLETE   register int i; */
51
/* OBSOLETE  */
52
/* OBSOLETE   struct user u; */
53
/* OBSOLETE   unsigned int offset = (char *) &u.u_ar0 - (char *) &u; */
54
/* OBSOLETE   offset = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0) */
55
/* OBSOLETE     - KERNEL_U_ADDR; */
56
/* OBSOLETE  */
57
/* OBSOLETE   registers_fetched (); */
58
/* OBSOLETE  */
59
/* OBSOLETE   for (regno = 0; regno < 16; regno++) */
60
/* OBSOLETE     { */
61
/* OBSOLETE       regaddr = offset + regno * 4; */
62
/* OBSOLETE       *(int *) &buf[0] = ptrace (PT_READ_U, inferior_pid, */
63
/* OBSOLETE                              (PTRACE_ARG3_TYPE) regaddr, 0); */
64
/* OBSOLETE       if (regno == PC_REGNUM) */
65
/* OBSOLETE     *(int *) &buf[0] = GET_PC_PART (*(int *) &buf[0]); */
66
/* OBSOLETE       supply_register (regno, buf); */
67
/* OBSOLETE     } */
68
/* OBSOLETE   *(int *) &buf[0] = ptrace (PT_READ_U, inferior_pid, */
69
/* OBSOLETE                          (PTRACE_ARG3_TYPE) (offset + PC * 4), 0); */
70
/* OBSOLETE   supply_register (PS_REGNUM, buf); /* set virtual register ps same as pc *x/ */
71
/* OBSOLETE  */
72
/* OBSOLETE   /* read the floating point registers *x/ */
73
/* OBSOLETE   offset = (char *) &u.u_fp_regs - (char *) &u; */
74
/* OBSOLETE   *(int *) buf = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0); */
75
/* OBSOLETE   supply_register (FPS_REGNUM, buf); */
76
/* OBSOLETE   for (regno = 16; regno < 24; regno++) */
77
/* OBSOLETE     { */
78
/* OBSOLETE       regaddr = offset + 4 + 12 * (regno - 16); */
79
/* OBSOLETE       for (i = 0; i < 12; i += sizeof (int)) */
80
/* OBSOLETE      *(int *) &buf[i] = ptrace (PT_READ_U, inferior_pid, */
81
/* OBSOLETE                                   (PTRACE_ARG3_TYPE) (regaddr + i), 0); */
82
/* OBSOLETE       supply_register (regno, buf); */
83
/* OBSOLETE     } */
84
/* OBSOLETE } */
85
/* OBSOLETE  */
86
/* OBSOLETE /* Store our register values back into the inferior. */
87
/* OBSOLETE    If REGNO is -1, do this for all registers. */
88
/* OBSOLETE    Otherwise, REGNO specifies which register (so we can save time).  *x/ */
89
/* OBSOLETE  */
90
/* OBSOLETE void */
91
/* OBSOLETE store_inferior_registers (regno) */
92
/* OBSOLETE      int regno; */
93
/* OBSOLETE { */
94
/* OBSOLETE   register unsigned int regaddr; */
95
/* OBSOLETE   char buf[80]; */
96
/* OBSOLETE  */
97
/* OBSOLETE   struct user u; */
98
/* OBSOLETE   unsigned long value; */
99
/* OBSOLETE   unsigned int offset = (char *) &u.u_ar0 - (char *) &u; */
100
/* OBSOLETE   offset = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0) */
101
/* OBSOLETE     - KERNEL_U_ADDR; */
102
/* OBSOLETE  */
103
/* OBSOLETE   if (regno >= 0) */
104
/* OBSOLETE     { */
105
/* OBSOLETE       if (regno >= 16) */
106
/* OBSOLETE     return; */
107
/* OBSOLETE       regaddr = offset + 4 * regno; */
108
/* OBSOLETE       errno = 0; */
109
/* OBSOLETE       value = read_register (regno); */
110
/* OBSOLETE       if (regno == PC_REGNUM) */
111
/* OBSOLETE     value = SET_PC_PART (read_register (PS_REGNUM), value); */
112
/* OBSOLETE       ptrace (PT_WRITE_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, value); */
113
/* OBSOLETE       if (errno != 0) */
114
/* OBSOLETE     { */
115
/* OBSOLETE       sprintf (buf, "writing register number %d", regno); */
116
/* OBSOLETE       perror_with_name (buf); */
117
/* OBSOLETE     } */
118
/* OBSOLETE     } */
119
/* OBSOLETE   else */
120
/* OBSOLETE     for (regno = 0; regno < 15; regno++) */
121
/* OBSOLETE       { */
122
/* OBSOLETE     regaddr = offset + regno * 4; */
123
/* OBSOLETE     errno = 0; */
124
/* OBSOLETE     value = read_register (regno); */
125
/* OBSOLETE     if (regno == PC_REGNUM) */
126
/* OBSOLETE       value = SET_PC_PART (read_register (PS_REGNUM), value); */
127
/* OBSOLETE     ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, value); */
128
/* OBSOLETE     if (errno != 0) */
129
/* OBSOLETE       { */
130
/* OBSOLETE         sprintf (buf, "writing all regs, number %d", regno); */
131
/* OBSOLETE         perror_with_name (buf); */
132
/* OBSOLETE       } */
133
/* OBSOLETE       } */
134
/* OBSOLETE } */
135
/* OBSOLETE  */
136
/* OBSOLETE /* Work with core dump and executable files, for GDB.  */
137
/* OBSOLETE    This code would be in corefile.c if it weren't machine-dependent. *x/ */
138
/* OBSOLETE  */
139
/* OBSOLETE /* Structure to describe the chain of shared libraries used */
140
/* OBSOLETE    by the execfile. */
141
/* OBSOLETE    e.g. prog shares Xt which shares X11 which shares c. *x/ */
142
/* OBSOLETE  */
143
/* OBSOLETE struct shared_library */
144
/* OBSOLETE { */
145
/* OBSOLETE   struct exec_header header; */
146
/* OBSOLETE   char name[SHLIBLEN]; */
147
/* OBSOLETE   CORE_ADDR text_start;             /* CORE_ADDR of 1st byte of text, this file *x/ */
148
/* OBSOLETE   long data_offset;         /* offset of data section in file *x/ */
149
/* OBSOLETE   int chan;                 /* file descriptor for the file *x/ */
150
/* OBSOLETE   struct shared_library *shares;    /* library this one shares *x/ */
151
/* OBSOLETE }; */
152
/* OBSOLETE static struct shared_library *shlib = 0; */
153
/* OBSOLETE  */
154
/* OBSOLETE /* Hook for `exec_file_command' command to call.  *x/ */
155
/* OBSOLETE  */
156
/* OBSOLETE extern void (*exec_file_display_hook) (); */
157
/* OBSOLETE  */
158
/* OBSOLETE static CORE_ADDR unshared_text_start; */
159
/* OBSOLETE  */
160
/* OBSOLETE /* extended header from exec file (for shared library info) *x/ */
161
/* OBSOLETE  */
162
/* OBSOLETE static struct exec_header exec_header; */
163
/* OBSOLETE  */
164
/* OBSOLETE void */
165
/* OBSOLETE core_file_command (filename, from_tty) */
166
/* OBSOLETE      char *filename; */
167
/* OBSOLETE      int from_tty; */
168
/* OBSOLETE { */
169
/* OBSOLETE   int val; */
170
/* OBSOLETE  */
171
/* OBSOLETE   /* Discard all vestiges of any previous core file */
172
/* OBSOLETE      and mark data and stack spaces as empty.  *x/ */
173
/* OBSOLETE  */
174
/* OBSOLETE   if (corefile) */
175
/* OBSOLETE     free (corefile); */
176
/* OBSOLETE   corefile = 0; */
177
/* OBSOLETE  */
178
/* OBSOLETE   if (corechan >= 0) */
179
/* OBSOLETE     close (corechan); */
180
/* OBSOLETE   corechan = -1; */
181
/* OBSOLETE  */
182
/* OBSOLETE   data_start = 0; */
183
/* OBSOLETE   data_end = 0; */
184
/* OBSOLETE   stack_start = STACK_END_ADDR; */
185
/* OBSOLETE   stack_end = STACK_END_ADDR; */
186
/* OBSOLETE  */
187
/* OBSOLETE   /* Now, if a new core file was specified, open it and digest it.  *x/ */
188
/* OBSOLETE  */
189
/* OBSOLETE   if (filename) */
190
/* OBSOLETE     { */
191
/* OBSOLETE       filename = tilde_expand (filename); */
192
/* OBSOLETE       make_cleanup (free, filename); */
193
/* OBSOLETE  */
194
/* OBSOLETE       if (have_inferior_p ()) */
195
/* OBSOLETE     error ("To look at a core file, you must kill the program with \"kill\"."); */
196
/* OBSOLETE       corechan = open (filename, O_RDONLY, 0); */
197
/* OBSOLETE       if (corechan < 0) */
198
/* OBSOLETE     perror_with_name (filename); */
199
/* OBSOLETE       /* 4.2-style (and perhaps also sysV-style) core dump file.  *x/ */
200
/* OBSOLETE       { */
201
/* OBSOLETE     struct user u; */
202
/* OBSOLETE  */
203
/* OBSOLETE     unsigned int reg_offset, fp_reg_offset; */
204
/* OBSOLETE  */
205
/* OBSOLETE     val = myread (corechan, &u, sizeof u); */
206
/* OBSOLETE     if (val < 0) */
207
/* OBSOLETE       perror_with_name ("Not a core file: reading upage"); */
208
/* OBSOLETE     if (val != sizeof u) */
209
/* OBSOLETE       error ("Not a core file: could only read %d bytes", val); */
210
/* OBSOLETE  */
211
/* OBSOLETE     /* We are depending on exec_file_command having been called */
212
/* OBSOLETE        previously to set exec_data_start.  Since the executable */
213
/* OBSOLETE        and the core file share the same text segment, the address */
214
/* OBSOLETE        of the data segment will be the same in both.  *x/ */
215
/* OBSOLETE     data_start = exec_data_start; */
216
/* OBSOLETE  */
217
/* OBSOLETE     data_end = data_start + NBPG * u.u_dsize; */
218
/* OBSOLETE     stack_start = stack_end - NBPG * u.u_ssize; */
219
/* OBSOLETE     data_offset = NBPG * UPAGES; */
220
/* OBSOLETE     stack_offset = NBPG * (UPAGES + u.u_dsize); */
221
/* OBSOLETE  */
222
/* OBSOLETE     /* Some machines put an absolute address in here and some put */
223
/* OBSOLETE        the offset in the upage of the regs.  *x/ */
224
/* OBSOLETE     reg_offset = (int) u.u_ar0; */
225
/* OBSOLETE     if (reg_offset > NBPG * UPAGES) */
226
/* OBSOLETE       reg_offset -= KERNEL_U_ADDR; */
227
/* OBSOLETE     fp_reg_offset = (char *) &u.u_fp_regs - (char *) &u; */
228
/* OBSOLETE  */
229
/* OBSOLETE     /* I don't know where to find this info. */
230
/* OBSOLETE        So, for now, mark it as not available.  *x/ */
231
/* OBSOLETE     N_SET_MAGIC (core_aouthdr, 0); */
232
/* OBSOLETE  */
233
/* OBSOLETE     /* Read the register values out of the core file and store */
234
/* OBSOLETE        them where `read_register' will find them.  *x/ */
235
/* OBSOLETE  */
236
/* OBSOLETE     { */
237
/* OBSOLETE       register int regno; */
238
/* OBSOLETE  */
239
/* OBSOLETE       for (regno = 0; regno < NUM_REGS; regno++) */
240
/* OBSOLETE         { */
241
/* OBSOLETE           char buf[MAX_REGISTER_RAW_SIZE]; */
242
/* OBSOLETE  */
243
/* OBSOLETE           if (regno < 16) */
244
/* OBSOLETE             val = lseek (corechan, reg_offset + 4 * regno, 0); */
245
/* OBSOLETE           else if (regno < 24) */
246
/* OBSOLETE             val = lseek (corechan, fp_reg_offset + 4 + 12 * (regno - 24), 0); */
247
/* OBSOLETE           else if (regno == 24) */
248
/* OBSOLETE             val = lseek (corechan, fp_reg_offset, 0); */
249
/* OBSOLETE           else if (regno == 25) */
250
/* OBSOLETE             val = lseek (corechan, reg_offset + 4 * PC, 0); */
251
/* OBSOLETE           if (val < 0 */
252
/* OBSOLETE               || (val = myread (corechan, buf, sizeof buf)) < 0) */
253
/* OBSOLETE             { */
254
/* OBSOLETE               char *buffer = (char *) alloca (strlen (REGISTER_NAME (regno)) */
255
/* OBSOLETE                                               + 30); */
256
/* OBSOLETE               strcpy (buffer, "Reading register "); */
257
/* OBSOLETE               strcat (buffer, REGISTER_NAME (regno)); */
258
/* OBSOLETE  */
259
/* OBSOLETE               perror_with_name (buffer); */
260
/* OBSOLETE             } */
261
/* OBSOLETE  */
262
/* OBSOLETE           if (regno == PC_REGNUM) */
263
/* OBSOLETE             *(int *) buf = GET_PC_PART (*(int *) buf); */
264
/* OBSOLETE           supply_register (regno, buf); */
265
/* OBSOLETE         } */
266
/* OBSOLETE     } */
267
/* OBSOLETE       } */
268
/* OBSOLETE       if (filename[0] == '/') */
269
/* OBSOLETE     corefile = savestring (filename, strlen (filename)); */
270
/* OBSOLETE       else */
271
/* OBSOLETE     { */
272
/* OBSOLETE       corefile = concat (current_directory, "/", filename, NULL); */
273
/* OBSOLETE     } */
274
/* OBSOLETE  */
275
/* OBSOLETE       flush_cached_frames (); */
276
/* OBSOLETE       select_frame (get_current_frame (), 0); */
277
/* OBSOLETE       validate_files (); */
278
/* OBSOLETE     } */
279
/* OBSOLETE   else if (from_tty) */
280
/* OBSOLETE     printf ("No core file now.\n"); */
281
/* OBSOLETE } */
282
/* OBSOLETE  */
283
/* OBSOLETE #if 0 */
284
/* OBSOLETE /* Work with core dump and executable files, for GDB.  */
285
/* OBSOLETE    This code would be in corefile.c if it weren't machine-dependent. *x/ */
286
/* OBSOLETE  */
287
/* OBSOLETE /* Structure to describe the chain of shared libraries used */
288
/* OBSOLETE    by the execfile. */
289
/* OBSOLETE    e.g. prog shares Xt which shares X11 which shares c. *x/ */
290
/* OBSOLETE  */
291
/* OBSOLETE struct shared_library */
292
/* OBSOLETE { */
293
/* OBSOLETE   struct exec_header header; */
294
/* OBSOLETE   char name[SHLIBLEN]; */
295
/* OBSOLETE   CORE_ADDR text_start;             /* CORE_ADDR of 1st byte of text, this file *x/ */
296
/* OBSOLETE   long data_offset;         /* offset of data section in file *x/ */
297
/* OBSOLETE   int chan;                 /* file descriptor for the file *x/ */
298
/* OBSOLETE   struct shared_library *shares;    /* library this one shares *x/ */
299
/* OBSOLETE }; */
300
/* OBSOLETE static struct shared_library *shlib = 0; */
301
/* OBSOLETE  */
302
/* OBSOLETE /* Hook for `exec_file_command' command to call.  *x/ */
303
/* OBSOLETE  */
304
/* OBSOLETE extern void (*exec_file_display_hook) (); */
305
/* OBSOLETE  */
306
/* OBSOLETE static CORE_ADDR unshared_text_start; */
307
/* OBSOLETE  */
308
/* OBSOLETE /* extended header from exec file (for shared library info) *x/ */
309
/* OBSOLETE  */
310
/* OBSOLETE static struct exec_header exec_header; */
311
/* OBSOLETE  */
312
/* OBSOLETE void */
313
/* OBSOLETE exec_file_command (filename, from_tty) */
314
/* OBSOLETE      char *filename; */
315
/* OBSOLETE      int from_tty; */
316
/* OBSOLETE { */
317
/* OBSOLETE   int val; */
318
/* OBSOLETE  */
319
/* OBSOLETE   /* Eliminate all traces of old exec file. */
320
/* OBSOLETE      Mark text segment as empty.  *x/ */
321
/* OBSOLETE  */
322
/* OBSOLETE   if (execfile) */
323
/* OBSOLETE     free (execfile); */
324
/* OBSOLETE   execfile = 0; */
325
/* OBSOLETE   data_start = 0; */
326
/* OBSOLETE   data_end -= exec_data_start; */
327
/* OBSOLETE   text_start = 0; */
328
/* OBSOLETE   unshared_text_start = 0; */
329
/* OBSOLETE   text_end = 0; */
330
/* OBSOLETE   exec_data_start = 0; */
331
/* OBSOLETE   exec_data_end = 0; */
332
/* OBSOLETE   if (execchan >= 0) */
333
/* OBSOLETE     close (execchan); */
334
/* OBSOLETE   execchan = -1; */
335
/* OBSOLETE   if (shlib) */
336
/* OBSOLETE     { */
337
/* OBSOLETE       close_shared_library (shlib); */
338
/* OBSOLETE       shlib = 0; */
339
/* OBSOLETE     } */
340
/* OBSOLETE  */
341
/* OBSOLETE   /* Now open and digest the file the user requested, if any.  *x/ */
342
/* OBSOLETE  */
343
/* OBSOLETE   if (filename) */
344
/* OBSOLETE     { */
345
/* OBSOLETE       filename = tilde_expand (filename); */
346
/* OBSOLETE       make_cleanup (free, filename); */
347
/* OBSOLETE  */
348
/* OBSOLETE       execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, */
349
/* OBSOLETE                     &execfile); */
350
/* OBSOLETE       if (execchan < 0) */
351
/* OBSOLETE     perror_with_name (filename); */
352
/* OBSOLETE  */
353
/* OBSOLETE       { */
354
/* OBSOLETE     struct stat st_exec; */
355
/* OBSOLETE  */
356
/* OBSOLETE #ifdef HEADER_SEEK_FD */
357
/* OBSOLETE     HEADER_SEEK_FD (execchan); */
358
/* OBSOLETE #endif */
359
/* OBSOLETE  */
360
/* OBSOLETE     val = myread (execchan, &exec_header, sizeof exec_header); */
361
/* OBSOLETE     exec_aouthdr = exec_header.a_exec; */
362
/* OBSOLETE  */
363
/* OBSOLETE     if (val < 0) */
364
/* OBSOLETE       perror_with_name (filename); */
365
/* OBSOLETE  */
366
/* OBSOLETE     text_start = 0x8000; */
367
/* OBSOLETE  */
368
/* OBSOLETE     /* Look for shared library if needed *x/ */
369
/* OBSOLETE     if (exec_header.a_exec.a_magic & MF_USES_SL) */
370
/* OBSOLETE       shlib = open_shared_library (exec_header.a_shlibname, text_start); */
371
/* OBSOLETE  */
372
/* OBSOLETE     text_offset = N_TXTOFF (exec_aouthdr); */
373
/* OBSOLETE     exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text; */
374
/* OBSOLETE  */
375
/* OBSOLETE     if (shlib) */
376
/* OBSOLETE       { */
377
/* OBSOLETE         unshared_text_start = shared_text_end (shlib) & ~0x7fff; */
378
/* OBSOLETE         stack_start = shlib->header.a_exec.a_sldatabase; */
379
/* OBSOLETE         stack_end = STACK_END_ADDR; */
380
/* OBSOLETE       } */
381
/* OBSOLETE     else */
382
/* OBSOLETE       unshared_text_start = 0x8000; */
383
/* OBSOLETE     text_end = unshared_text_start + exec_aouthdr.a_text; */
384
/* OBSOLETE  */
385
/* OBSOLETE     exec_data_start = unshared_text_start + exec_aouthdr.a_text; */
386
/* OBSOLETE     exec_data_end = exec_data_start + exec_aouthdr.a_data; */
387
/* OBSOLETE  */
388
/* OBSOLETE     data_start = exec_data_start; */
389
/* OBSOLETE     data_end += exec_data_start; */
390
/* OBSOLETE  */
391
/* OBSOLETE     fstat (execchan, &st_exec); */
392
/* OBSOLETE     exec_mtime = st_exec.st_mtime; */
393
/* OBSOLETE       } */
394
/* OBSOLETE  */
395
/* OBSOLETE       validate_files (); */
396
/* OBSOLETE     } */
397
/* OBSOLETE   else if (from_tty) */
398
/* OBSOLETE     printf ("No executable file now.\n"); */
399
/* OBSOLETE  */
400
/* OBSOLETE   /* Tell display code (if any) about the changed file name.  *x/ */
401
/* OBSOLETE   if (exec_file_display_hook) */
402
/* OBSOLETE     (*exec_file_display_hook) (filename); */
403
/* OBSOLETE } */
404
/* OBSOLETE #endif */
405
/* OBSOLETE  */
406
/* OBSOLETE #if 0 */
407
/* OBSOLETE /* Read from the program's memory (except for inferior processes). */
408
/* OBSOLETE    This function is misnamed, since it only reads, never writes; and */
409
/* OBSOLETE    since it will use the core file and/or executable file as necessary. */
410
/* OBSOLETE  */
411
/* OBSOLETE    It should be extended to write as well as read, FIXME, for patching files. */
412
/* OBSOLETE  */
413
/* OBSOLETE    Return 0 if address could be read, EIO if addresss out of bounds.  *x/ */
414
/* OBSOLETE  */
415
/* OBSOLETE int */
416
/* OBSOLETE xfer_core_file (memaddr, myaddr, len) */
417
/* OBSOLETE      CORE_ADDR memaddr; */
418
/* OBSOLETE      char *myaddr; */
419
/* OBSOLETE      int len; */
420
/* OBSOLETE { */
421
/* OBSOLETE   register int i; */
422
/* OBSOLETE   register int val; */
423
/* OBSOLETE   int xferchan; */
424
/* OBSOLETE   char **xferfile; */
425
/* OBSOLETE   int fileptr; */
426
/* OBSOLETE   int returnval = 0; */
427
/* OBSOLETE  */
428
/* OBSOLETE   while (len > 0) */
429
/* OBSOLETE     { */
430
/* OBSOLETE       xferfile = 0; */
431
/* OBSOLETE       xferchan = 0; */
432
/* OBSOLETE  */
433
/* OBSOLETE       /* Determine which file the next bunch of addresses reside in, */
434
/* OBSOLETE          and where in the file.  Set the file's read/write pointer */
435
/* OBSOLETE          to point at the proper place for the desired address */
436
/* OBSOLETE          and set xferfile and xferchan for the correct file. */
437
/* OBSOLETE  */
438
/* OBSOLETE          If desired address is nonexistent, leave them zero. */
439
/* OBSOLETE  */
440
/* OBSOLETE          i is set to the number of bytes that can be handled */
441
/* OBSOLETE          along with the next address. */
442
/* OBSOLETE  */
443
/* OBSOLETE          We put the most likely tests first for efficiency.  *x/ */
444
/* OBSOLETE  */
445
/* OBSOLETE       /* Note that if there is no core file */
446
/* OBSOLETE          data_start and data_end are equal.  *x/ */
447
/* OBSOLETE       if (memaddr >= data_start && memaddr < data_end) */
448
/* OBSOLETE     { */
449
/* OBSOLETE       i = min (len, data_end - memaddr); */
450
/* OBSOLETE       fileptr = memaddr - data_start + data_offset; */
451
/* OBSOLETE       xferfile = &corefile; */
452
/* OBSOLETE       xferchan = corechan; */
453
/* OBSOLETE     } */
454
/* OBSOLETE       /* Note that if there is no core file */
455
/* OBSOLETE          stack_start and stack_end define the shared library data.  *x/ */
456
/* OBSOLETE       else if (memaddr >= stack_start && memaddr < stack_end) */
457
/* OBSOLETE     { */
458
/* OBSOLETE       if (corechan < 0) */
459
/* OBSOLETE         { */
460
/* OBSOLETE           struct shared_library *lib; */
461
/* OBSOLETE           for (lib = shlib; lib; lib = lib->shares) */
462
/* OBSOLETE             if (memaddr >= lib->header.a_exec.a_sldatabase && */
463
/* OBSOLETE                 memaddr < lib->header.a_exec.a_sldatabase + */
464
/* OBSOLETE                 lib->header.a_exec.a_data) */
465
/* OBSOLETE               break; */
466
/* OBSOLETE           if (lib) */
467
/* OBSOLETE             { */
468
/* OBSOLETE               i = min (len, lib->header.a_exec.a_sldatabase + */
469
/* OBSOLETE                        lib->header.a_exec.a_data - memaddr); */
470
/* OBSOLETE               fileptr = lib->data_offset + memaddr - */
471
/* OBSOLETE                 lib->header.a_exec.a_sldatabase; */
472
/* OBSOLETE               xferfile = execfile; */
473
/* OBSOLETE               xferchan = lib->chan; */
474
/* OBSOLETE             } */
475
/* OBSOLETE         } */
476
/* OBSOLETE       else */
477
/* OBSOLETE         { */
478
/* OBSOLETE           i = min (len, stack_end - memaddr); */
479
/* OBSOLETE           fileptr = memaddr - stack_start + stack_offset; */
480
/* OBSOLETE           xferfile = &corefile; */
481
/* OBSOLETE           xferchan = corechan; */
482
/* OBSOLETE         } */
483
/* OBSOLETE     } */
484
/* OBSOLETE       else if (corechan < 0 */
485
/* OBSOLETE            && memaddr >= exec_data_start && memaddr < exec_data_end) */
486
/* OBSOLETE     { */
487
/* OBSOLETE       i = min (len, exec_data_end - memaddr); */
488
/* OBSOLETE       fileptr = memaddr - exec_data_start + exec_data_offset; */
489
/* OBSOLETE       xferfile = &execfile; */
490
/* OBSOLETE       xferchan = execchan; */
491
/* OBSOLETE     } */
492
/* OBSOLETE       else if (memaddr >= text_start && memaddr < text_end) */
493
/* OBSOLETE     { */
494
/* OBSOLETE       struct shared_library *lib; */
495
/* OBSOLETE       for (lib = shlib; lib; lib = lib->shares) */
496
/* OBSOLETE         if (memaddr >= lib->text_start && */
497
/* OBSOLETE             memaddr < lib->text_start + lib->header.a_exec.a_text) */
498
/* OBSOLETE           break; */
499
/* OBSOLETE       if (lib) */
500
/* OBSOLETE         { */
501
/* OBSOLETE           i = min (len, lib->header.a_exec.a_text + */
502
/* OBSOLETE                    lib->text_start - memaddr); */
503
/* OBSOLETE           fileptr = memaddr - lib->text_start + text_offset; */
504
/* OBSOLETE           xferfile = &execfile; */
505
/* OBSOLETE           xferchan = lib->chan; */
506
/* OBSOLETE         } */
507
/* OBSOLETE       else */
508
/* OBSOLETE         { */
509
/* OBSOLETE           i = min (len, text_end - memaddr); */
510
/* OBSOLETE           fileptr = memaddr - unshared_text_start + text_offset; */
511
/* OBSOLETE           xferfile = &execfile; */
512
/* OBSOLETE           xferchan = execchan; */
513
/* OBSOLETE         } */
514
/* OBSOLETE     } */
515
/* OBSOLETE       else if (memaddr < text_start) */
516
/* OBSOLETE     { */
517
/* OBSOLETE       i = min (len, text_start - memaddr); */
518
/* OBSOLETE     } */
519
/* OBSOLETE       else if (memaddr >= text_end */
520
/* OBSOLETE            && memaddr < (corechan >= 0 ? data_start : exec_data_start)) */
521
/* OBSOLETE     { */
522
/* OBSOLETE       i = min (len, data_start - memaddr); */
523
/* OBSOLETE     } */
524
/* OBSOLETE       else if (corechan >= 0 */
525
/* OBSOLETE            && memaddr >= data_end && memaddr < stack_start) */
526
/* OBSOLETE     { */
527
/* OBSOLETE       i = min (len, stack_start - memaddr); */
528
/* OBSOLETE     } */
529
/* OBSOLETE       else if (corechan < 0 && memaddr >= exec_data_end) */
530
/* OBSOLETE     { */
531
/* OBSOLETE       i = min (len, -memaddr); */
532
/* OBSOLETE     } */
533
/* OBSOLETE       else if (memaddr >= stack_end && stack_end != 0) */
534
/* OBSOLETE     { */
535
/* OBSOLETE       i = min (len, -memaddr); */
536
/* OBSOLETE     } */
537
/* OBSOLETE       else */
538
/* OBSOLETE     { */
539
/* OBSOLETE       /* Address did not classify into one of the known ranges. */
540
/* OBSOLETE          This shouldn't happen; we catch the endpoints.  *x/ */
541
/* OBSOLETE       internal_error ("Bad case logic in xfer_core_file."); */
542
/* OBSOLETE     } */
543
/* OBSOLETE  */
544
/* OBSOLETE       /* Now we know which file to use. */
545
/* OBSOLETE          Set up its pointer and transfer the data.  *x/ */
546
/* OBSOLETE       if (xferfile) */
547
/* OBSOLETE     { */
548
/* OBSOLETE       if (*xferfile == 0) */
549
/* OBSOLETE         if (xferfile == &execfile) */
550
/* OBSOLETE           error ("No program file to examine."); */
551
/* OBSOLETE         else */
552
/* OBSOLETE           error ("No core dump file or running program to examine."); */
553
/* OBSOLETE       val = lseek (xferchan, fileptr, 0); */
554
/* OBSOLETE       if (val < 0) */
555
/* OBSOLETE         perror_with_name (*xferfile); */
556
/* OBSOLETE       val = myread (xferchan, myaddr, i); */
557
/* OBSOLETE       if (val < 0) */
558
/* OBSOLETE         perror_with_name (*xferfile); */
559
/* OBSOLETE     } */
560
/* OBSOLETE       /* If this address is for nonexistent memory, */
561
/* OBSOLETE          read zeros if reading, or do nothing if writing. */
562
/* OBSOLETE          Actually, we never right.  *x/ */
563
/* OBSOLETE       else */
564
/* OBSOLETE     { */
565
/* OBSOLETE       memset (myaddr, '\0', i); */
566
/* OBSOLETE       returnval = EIO; */
567
/* OBSOLETE     } */
568
/* OBSOLETE  */
569
/* OBSOLETE       memaddr += i; */
570
/* OBSOLETE       myaddr += i; */
571
/* OBSOLETE       len -= i; */
572
/* OBSOLETE     } */
573
/* OBSOLETE   return returnval; */
574
/* OBSOLETE } */
575
/* OBSOLETE #endif */

powered by: WebSVN 2.1.0

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