*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / gdbserver / low-nbsd.c
CommitLineData
d6e9fb05 1/* Low level interface to ptrace, for the remote server for GDB.
db728ff7 2 Copyright 1986, 1987, 1993, 2000, 2001, 2002 Free Software Foundation, Inc.
d6e9fb05
JK
3
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
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
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
f29d9b6d 20#include "server.h"
d6e9fb05
JK
21#include <sys/types.h>
22#include <sys/wait.h>
23#include "frame.h"
24#include "inferior.h"
25
26#include <stdio.h>
27#include <errno.h>
28
29/***************Begin MY defs*********************/
d6e9fb05
JK
30static char my_registers[REGISTER_BYTES];
31char *registers = my_registers;
d6e9fb05
JK
32/***************End MY defs*********************/
33
34#include <sys/ptrace.h>
35#include <machine/reg.h>
36
9cebe72f
C
37#define RF(dst, src) \
38 memcpy(&registers[REGISTER_BYTE(dst)], &src, sizeof(src))
39
40#define RS(src, dst) \
41 memcpy(&dst, &registers[REGISTER_BYTE(src)], sizeof(dst))
42
43#ifdef __i386__
44struct env387
45 {
46 unsigned short control;
47 unsigned short r0;
48 unsigned short status;
49 unsigned short r1;
50 unsigned short tag;
51 unsigned short r2;
52 unsigned long eip;
53 unsigned short code_seg;
54 unsigned short opcode;
55 unsigned long operand;
56 unsigned short operand_seg;
57 unsigned short r3;
58 unsigned char regs[8][10];
59 };
60
d6e9fb05
JK
61/* i386_register_raw_size[i] is the number of bytes of storage in the
62 actual machine representation for register i. */
63int i386_register_raw_size[MAX_NUM_REGS] = {
64 4, 4, 4, 4,
65 4, 4, 4, 4,
66 4, 4, 4, 4,
67 4, 4, 4, 4,
68 10, 10, 10, 10,
69 10, 10, 10, 10,
70 4, 4, 4, 4,
71 4, 4, 4, 4,
72 16, 16, 16, 16,
73 16, 16, 16, 16,
74 4
75};
76
77int i386_register_byte[MAX_NUM_REGS];
78
79static void
fba45db2 80initialize_arch (void)
d6e9fb05
JK
81{
82 /* Initialize the table saying where each register starts in the
83 register file. */
84 {
85 int i, offset;
86
87 offset = 0;
88 for (i = 0; i < MAX_NUM_REGS; i++)
89 {
90 i386_register_byte[i] = offset;
91 offset += i386_register_raw_size[i];
92 }
93 }
94}
9cebe72f 95#endif /* !__i386__ */
d6e9fb05 96
bd2fa4f6
C
97#ifdef __m68k__
98static void
99initialize_arch (void)
100{
101}
102#endif /* !__m68k__ */
103
104#ifdef __ns32k__
105static void
106initialize_arch (void)
107{
108}
109#endif /* !__ns32k__ */
110
9cebe72f 111#ifdef __powerpc__
22c72081
C
112#include "ppc-tdep.h"
113
9cebe72f 114static void
fba45db2 115initialize_arch (void)
9cebe72f
C
116{
117}
118#endif /* !__powerpc__ */
d6e9fb05
JK
119
120
121/* Start an inferior process and returns its pid.
bd2fa4f6 122 ALLARGS is a vector of program-name and args. */
d6e9fb05
JK
123
124int
fba45db2 125create_inferior (char *program, char **allargs)
d6e9fb05
JK
126{
127 int pid;
128
129 pid = fork ();
130 if (pid < 0)
131 perror_with_name ("fork");
132
133 if (pid == 0)
134 {
135 ptrace (PT_TRACE_ME, 0, 0, 0);
136
137 execv (program, allargs);
138
139 fprintf (stderr, "Cannot exec %s: %s.\n", program,
140 errno < sys_nerr ? sys_errlist[errno] : "unknown error");
141 fflush (stderr);
142 _exit (0177);
143 }
144
145 return pid;
146}
147
45b7b345
DJ
148/* Attaching is not supported. */
149int
150myattach (int pid)
151{
152 return -1;
153}
154
d6e9fb05
JK
155/* Kill the inferior process. Make us have no inferior. */
156
157void
fba45db2 158kill_inferior (void)
d6e9fb05
JK
159{
160 if (inferior_pid == 0)
161 return;
162 ptrace (PT_KILL, inferior_pid, 0, 0);
163 wait (0);
164 /*************inferior_died ();****VK**************/
165}
166
167/* Return nonzero if the given thread is still alive. */
168int
fba45db2 169mythread_alive (int pid)
d6e9fb05
JK
170{
171 return 1;
172}
173
174/* Wait for process, returns status */
175
176unsigned char
fba45db2 177mywait (char *status)
d6e9fb05
JK
178{
179 int pid;
180 int w;
181
cf30a8e1
C
182 enable_async_io ();
183 pid = waitpid (inferior_pid, &w, 0);
184 disable_async_io ();
d6e9fb05
JK
185 if (pid != inferior_pid)
186 perror_with_name ("wait");
187
188 if (WIFEXITED (w))
189 {
190 fprintf (stderr, "\nChild exited with retcode = %x \n", WEXITSTATUS (w));
191 *status = 'W';
192 return ((unsigned char) WEXITSTATUS (w));
193 }
194 else if (!WIFSTOPPED (w))
195 {
196 fprintf (stderr, "\nChild terminated with signal = %x \n", WTERMSIG (w));
197 *status = 'X';
198 return ((unsigned char) WTERMSIG (w));
199 }
200
201 fetch_inferior_registers (0);
202
203 *status = 'T';
204 return ((unsigned char) WSTOPSIG (w));
205}
206
207/* Resume execution of the inferior process.
208 If STEP is nonzero, single-step it.
209 If SIGNAL is nonzero, give it that signal. */
210
211void
fba45db2 212myresume (int step, int signal)
d6e9fb05
JK
213{
214 errno = 0;
215 ptrace (step ? PT_STEP : PT_CONTINUE, inferior_pid,
216 (PTRACE_ARG3_TYPE) 1, signal);
217 if (errno)
218 perror_with_name ("ptrace");
219}
220
9cebe72f
C
221
222#ifdef __i386__
d6e9fb05
JK
223/* Fetch one or more registers from the inferior. REGNO == -1 to get
224 them all. We actually fetch more than requested, when convenient,
225 marking them as valid so we won't fetch them again. */
226
227void
fba45db2 228fetch_inferior_registers (int ignored)
d6e9fb05
JK
229{
230 struct reg inferior_registers;
9cebe72f 231 struct env387 inferior_fp_registers;
d6e9fb05
JK
232
233 ptrace (PT_GETREGS, inferior_pid,
234 (PTRACE_ARG3_TYPE) &inferior_registers, 0);
d6e9fb05
JK
235 ptrace (PT_GETFPREGS, inferior_pid,
236 (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0);
9cebe72f
C
237
238 RF ( 0, inferior_registers.r_eax);
239 RF ( 1, inferior_registers.r_ecx);
240 RF ( 2, inferior_registers.r_edx);
241 RF ( 3, inferior_registers.r_ebx);
242 RF ( 4, inferior_registers.r_esp);
243 RF ( 5, inferior_registers.r_ebp);
244 RF ( 6, inferior_registers.r_esi);
245 RF ( 7, inferior_registers.r_edi);
246 RF ( 8, inferior_registers.r_eip);
247 RF ( 9, inferior_registers.r_eflags);
248 RF (10, inferior_registers.r_cs);
249 RF (11, inferior_registers.r_ss);
250 RF (12, inferior_registers.r_ds);
251 RF (13, inferior_registers.r_es);
252 RF (14, inferior_registers.r_fs);
253 RF (15, inferior_registers.r_gs);
254
0c9f8a69
C
255 RF (FP0_REGNUM, inferior_fp_registers.regs[0]);
256 RF (FP0_REGNUM + 1, inferior_fp_registers.regs[1]);
257 RF (FP0_REGNUM + 2, inferior_fp_registers.regs[2]);
258 RF (FP0_REGNUM + 3, inferior_fp_registers.regs[3]);
259 RF (FP0_REGNUM + 4, inferior_fp_registers.regs[4]);
260 RF (FP0_REGNUM + 5, inferior_fp_registers.regs[5]);
261 RF (FP0_REGNUM + 6, inferior_fp_registers.regs[6]);
262 RF (FP0_REGNUM + 7, inferior_fp_registers.regs[7]);
9cebe72f 263
0c9f8a69
C
264 RF (FCTRL_REGNUM, inferior_fp_registers.control);
265 RF (FSTAT_REGNUM, inferior_fp_registers.status);
266 RF (FTAG_REGNUM, inferior_fp_registers.tag);
267 RF (FCS_REGNUM, inferior_fp_registers.code_seg);
268 RF (FCOFF_REGNUM, inferior_fp_registers.eip);
269 RF (FDS_REGNUM, inferior_fp_registers.operand_seg);
270 RF (FDOFF_REGNUM, inferior_fp_registers.operand);
271 RF (FOP_REGNUM, inferior_fp_registers.opcode);
d6e9fb05
JK
272}
273
274/* Store our register values back into the inferior.
275 If REGNO is -1, do this for all registers.
276 Otherwise, REGNO specifies which register (so we can save time). */
277
278void
fba45db2 279store_inferior_registers (int ignored)
d6e9fb05
JK
280{
281 struct reg inferior_registers;
9cebe72f
C
282 struct env387 inferior_fp_registers;
283
284 RS ( 0, inferior_registers.r_eax);
285 RS ( 1, inferior_registers.r_ecx);
286 RS ( 2, inferior_registers.r_edx);
287 RS ( 3, inferior_registers.r_ebx);
288 RS ( 4, inferior_registers.r_esp);
289 RS ( 5, inferior_registers.r_ebp);
290 RS ( 6, inferior_registers.r_esi);
291 RS ( 7, inferior_registers.r_edi);
292 RS ( 8, inferior_registers.r_eip);
293 RS ( 9, inferior_registers.r_eflags);
294 RS (10, inferior_registers.r_cs);
295 RS (11, inferior_registers.r_ss);
296 RS (12, inferior_registers.r_ds);
297 RS (13, inferior_registers.r_es);
298 RS (14, inferior_registers.r_fs);
299 RS (15, inferior_registers.r_gs);
300
0c9f8a69
C
301 RS (FP0_REGNUM, inferior_fp_registers.regs[0]);
302 RS (FP0_REGNUM + 1, inferior_fp_registers.regs[1]);
303 RS (FP0_REGNUM + 2, inferior_fp_registers.regs[2]);
304 RS (FP0_REGNUM + 3, inferior_fp_registers.regs[3]);
305 RS (FP0_REGNUM + 4, inferior_fp_registers.regs[4]);
306 RS (FP0_REGNUM + 5, inferior_fp_registers.regs[5]);
307 RS (FP0_REGNUM + 6, inferior_fp_registers.regs[6]);
308 RS (FP0_REGNUM + 7, inferior_fp_registers.regs[7]);
9cebe72f 309
0c9f8a69
C
310 RS (FCTRL_REGNUM, inferior_fp_registers.control);
311 RS (FSTAT_REGNUM, inferior_fp_registers.status);
312 RS (FTAG_REGNUM, inferior_fp_registers.tag);
313 RS (FCS_REGNUM, inferior_fp_registers.code_seg);
314 RS (FCOFF_REGNUM, inferior_fp_registers.eip);
315 RS (FDS_REGNUM, inferior_fp_registers.operand_seg);
316 RS (FDOFF_REGNUM, inferior_fp_registers.operand);
317 RS (FOP_REGNUM, inferior_fp_registers.opcode);
d6e9fb05 318
d6e9fb05
JK
319 ptrace (PT_SETREGS, inferior_pid,
320 (PTRACE_ARG3_TYPE) &inferior_registers, 0);
d6e9fb05
JK
321 ptrace (PT_SETFPREGS, inferior_pid,
322 (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0);
d6e9fb05 323}
9cebe72f
C
324#endif /* !__i386__ */
325
bd2fa4f6
C
326#ifdef __m68k__
327/* Fetch one or more registers from the inferior. REGNO == -1 to get
328 them all. We actually fetch more than requested, when convenient,
329 marking them as valid so we won't fetch them again. */
330
331void
332fetch_inferior_registers (int regno)
333{
334 struct reg inferior_registers;
335 struct fpreg inferior_fp_registers;
336
337 ptrace (PT_GETREGS, inferior_pid,
338 (PTRACE_ARG3_TYPE) & inferior_registers, 0);
339 memcpy (&registers[REGISTER_BYTE (0)], &inferior_registers,
340 sizeof (inferior_registers));
341
342 ptrace (PT_GETFPREGS, inferior_pid,
343 (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0);
344 memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers,
345 sizeof (inferior_fp_registers));
346}
347
348/* Store our register values back into the inferior.
349 If REGNO is -1, do this for all registers.
350 Otherwise, REGNO specifies which register (so we can save time). */
351
352void
353store_inferior_registers (int regno)
354{
355 struct reg inferior_registers;
356 struct fpreg inferior_fp_registers;
357
358 memcpy (&inferior_registers, &registers[REGISTER_BYTE (0)],
359 sizeof (inferior_registers));
360 ptrace (PT_SETREGS, inferior_pid,
361 (PTRACE_ARG3_TYPE) & inferior_registers, 0);
362
363 memcpy (&inferior_fp_registers, &registers[REGISTER_BYTE (FP0_REGNUM)],
364 sizeof (inferior_fp_registers));
365 ptrace (PT_SETFPREGS, inferior_pid,
366 (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0);
367}
368#endif /* !__m68k__ */
369
370
371#ifdef __ns32k__
372/* Fetch one or more registers from the inferior. REGNO == -1 to get
373 them all. We actually fetch more than requested, when convenient,
374 marking them as valid so we won't fetch them again. */
375
376void
377fetch_inferior_registers (int regno)
378{
379 struct reg inferior_registers;
380 struct fpreg inferior_fpregisters;
381
382 ptrace (PT_GETREGS, inferior_pid,
383 (PTRACE_ARG3_TYPE) & inferior_registers, 0);
384 ptrace (PT_GETFPREGS, inferior_pid,
385 (PTRACE_ARG3_TYPE) & inferior_fpregisters, 0);
386
387 RF (R0_REGNUM + 0, inferior_registers.r_r0);
388 RF (R0_REGNUM + 1, inferior_registers.r_r1);
389 RF (R0_REGNUM + 2, inferior_registers.r_r2);
390 RF (R0_REGNUM + 3, inferior_registers.r_r3);
391 RF (R0_REGNUM + 4, inferior_registers.r_r4);
392 RF (R0_REGNUM + 5, inferior_registers.r_r5);
393 RF (R0_REGNUM + 6, inferior_registers.r_r6);
394 RF (R0_REGNUM + 7, inferior_registers.r_r7);
395
396 RF (SP_REGNUM, inferior_registers.r_sp);
397 RF (FP_REGNUM, inferior_registers.r_fp);
398 RF (PC_REGNUM, inferior_registers.r_pc);
399 RF (PS_REGNUM, inferior_registers.r_psr);
400
401 RF (FPS_REGNUM, inferior_fpregisters.r_fsr);
402 RF (FP0_REGNUM + 0, inferior_fpregisters.r_freg[0]);
403 RF (FP0_REGNUM + 2, inferior_fpregisters.r_freg[2]);
404 RF (FP0_REGNUM + 4, inferior_fpregisters.r_freg[4]);
405 RF (FP0_REGNUM + 6, inferior_fpregisters.r_freg[6]);
406 RF (LP0_REGNUM + 1, inferior_fpregisters.r_freg[1]);
407 RF (LP0_REGNUM + 3, inferior_fpregisters.r_freg[3]);
408 RF (LP0_REGNUM + 5, inferior_fpregisters.r_freg[5]);
409 RF (LP0_REGNUM + 7, inferior_fpregisters.r_freg[7]);
410}
411
412/* Store our register values back into the inferior.
413 If REGNO is -1, do this for all registers.
414 Otherwise, REGNO specifies which register (so we can save time). */
415
416void
417store_inferior_registers (int regno)
418{
419 struct reg inferior_registers;
420 struct fpreg inferior_fpregisters;
421
422 RS (R0_REGNUM + 0, inferior_registers.r_r0);
423 RS (R0_REGNUM + 1, inferior_registers.r_r1);
424 RS (R0_REGNUM + 2, inferior_registers.r_r2);
425 RS (R0_REGNUM + 3, inferior_registers.r_r3);
426 RS (R0_REGNUM + 4, inferior_registers.r_r4);
427 RS (R0_REGNUM + 5, inferior_registers.r_r5);
428 RS (R0_REGNUM + 6, inferior_registers.r_r6);
429 RS (R0_REGNUM + 7, inferior_registers.r_r7);
430
431 RS (SP_REGNUM, inferior_registers.r_sp);
432 RS (FP_REGNUM, inferior_registers.r_fp);
433 RS (PC_REGNUM, inferior_registers.r_pc);
434 RS (PS_REGNUM, inferior_registers.r_psr);
435
436 RS (FPS_REGNUM, inferior_fpregisters.r_fsr);
437 RS (FP0_REGNUM + 0, inferior_fpregisters.r_freg[0]);
438 RS (FP0_REGNUM + 2, inferior_fpregisters.r_freg[2]);
439 RS (FP0_REGNUM + 4, inferior_fpregisters.r_freg[4]);
440 RS (FP0_REGNUM + 6, inferior_fpregisters.r_freg[6]);
441 RS (LP0_REGNUM + 1, inferior_fpregisters.r_freg[1]);
442 RS (LP0_REGNUM + 3, inferior_fpregisters.r_freg[3]);
443 RS (LP0_REGNUM + 5, inferior_fpregisters.r_freg[5]);
444 RS (LP0_REGNUM + 7, inferior_fpregisters.r_freg[7]);
445
446 ptrace (PT_SETREGS, inferior_pid,
447 (PTRACE_ARG3_TYPE) & inferior_registers, 0);
448 ptrace (PT_SETFPREGS, inferior_pid,
449 (PTRACE_ARG3_TYPE) & inferior_fpregisters, 0);
450
451}
452#endif /* !__ns32k__ */
453
9cebe72f
C
454#ifdef __powerpc__
455/* Fetch one or more registers from the inferior. REGNO == -1 to get
456 them all. We actually fetch more than requested, when convenient,
457 marking them as valid so we won't fetch them again. */
458
459void
fba45db2 460fetch_inferior_registers (int regno)
9cebe72f
C
461{
462 struct reg inferior_registers;
22c72081 463#ifdef PT_GETFPREGS
9cebe72f 464 struct fpreg inferior_fp_registers;
22c72081 465#endif
9cebe72f
C
466 int i;
467
468 ptrace (PT_GETREGS, inferior_pid,
469 (PTRACE_ARG3_TYPE) & inferior_registers, 0);
9cebe72f
C
470 for (i = 0; i < 32; i++)
471 RF (i, inferior_registers.fixreg[i]);
22c72081
C
472 RF (PPC_LR_REGNUM, inferior_registers.lr);
473 RF (PPC_CR_REGNUM, inferior_registers.cr);
474 RF (PPC_XER_REGNUM, inferior_registers.xer);
475 RF (PPC_CTR_REGNUM, inferior_registers.ctr);
9cebe72f
C
476 RF (PC_REGNUM, inferior_registers.pc);
477
22c72081
C
478#ifdef PT_GETFPREGS
479 ptrace (PT_GETFPREGS, inferior_pid,
480 (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0);
9cebe72f
C
481 for (i = 0; i < 32; i++)
482 RF (FP0_REGNUM + i, inferior_fp_registers.r_regs[i]);
22c72081 483#endif
9cebe72f
C
484}
485
486/* Store our register values back into the inferior.
487 If REGNO is -1, do this for all registers.
488 Otherwise, REGNO specifies which register (so we can save time). */
489
490void
fba45db2 491store_inferior_registers (int regno)
9cebe72f
C
492{
493 struct reg inferior_registers;
22c72081 494#ifdef PT_SETFPREGS
9cebe72f 495 struct fpreg inferior_fp_registers;
22c72081 496#endif
9cebe72f
C
497 int i;
498
499 for (i = 0; i < 32; i++)
500 RS (i, inferior_registers.fixreg[i]);
22c72081
C
501 RS (PPC_LR_REGNUM, inferior_registers.lr);
502 RS (PPC_CR_REGNUM, inferior_registers.cr);
503 RS (PPC_XER_REGNUM, inferior_registers.xer);
504 RS (PPC_CTR_REGNUM, inferior_registers.ctr);
9cebe72f 505 RS (PC_REGNUM, inferior_registers.pc);
22c72081
C
506 ptrace (PT_SETREGS, inferior_pid,
507 (PTRACE_ARG3_TYPE) & inferior_registers, 0);
9cebe72f 508
22c72081 509#ifdef PT_SETFPREGS
9cebe72f
C
510 for (i = 0; i < 32; i++)
511 RS (FP0_REGNUM + i, inferior_fp_registers.r_regs[i]);
9cebe72f
C
512 ptrace (PT_SETFPREGS, inferior_pid,
513 (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0);
22c72081 514#endif
9cebe72f
C
515}
516#endif /* !__powerpc__ */
d6e9fb05
JK
517
518/* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory
519 in the NEW_SUN_PTRACE case.
520 It ought to be straightforward. But it appears that writing did
521 not write the data that I specified. I cannot understand where
522 it got the data that it actually did write. */
523
524/* Copy LEN bytes from inferior's memory starting at MEMADDR
525 to debugger memory starting at MYADDR. */
526
af471f3c 527void
fba45db2 528read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
d6e9fb05
JK
529{
530 register int i;
531 /* Round starting address down to longword boundary. */
9f30d7f5 532 register CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (int);
d6e9fb05
JK
533 /* Round ending address up; get number of longwords that makes. */
534 register int count
535 = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
536 /* Allocate buffer of that many longwords. */
537 register int *buffer = (int *) alloca (count * sizeof (int));
538
539 /* Read all the longwords */
540 for (i = 0; i < count; i++, addr += sizeof (int))
541 {
542 buffer[i] = ptrace (PT_READ_D, inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
543 }
544
545 /* Copy appropriate bytes out of the buffer. */
546 memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
547}
548
549/* Copy LEN bytes of data from debugger memory at MYADDR
550 to inferior's memory at MEMADDR.
551 On failure (cannot write the inferior)
552 returns the value of errno. */
553
554int
fba45db2 555write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
d6e9fb05
JK
556{
557 register int i;
558 /* Round starting address down to longword boundary. */
9f30d7f5 559 register CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (int);
d6e9fb05
JK
560 /* Round ending address up; get number of longwords that makes. */
561 register int count
562 = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
563 /* Allocate buffer of that many longwords. */
564 register int *buffer = (int *) alloca (count * sizeof (int));
565 extern int errno;
566
567 /* Fill start and end extra bytes of buffer with existing memory data. */
568
569 buffer[0] = ptrace (PT_READ_D, inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
570
571 if (count > 1)
572 {
573 buffer[count - 1]
574 = ptrace (PT_READ_D, inferior_pid,
575 (PTRACE_ARG3_TYPE) addr + (count - 1) * sizeof (int), 0);
576 }
577
578 /* Copy data to be written over corresponding part of buffer */
579
580 memcpy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
581
582 /* Write the entire buffer. */
583
584 for (i = 0; i < count; i++, addr += sizeof (int))
585 {
586 errno = 0;
587 ptrace (PT_WRITE_D, inferior_pid, (PTRACE_ARG3_TYPE) addr, buffer[i]);
588 if (errno)
589 return errno;
590 }
591
592 return 0;
593}
594\f
595void
fba45db2 596initialize_low (void)
d6e9fb05
JK
597{
598 initialize_arch ();
599}
This page took 0.246461 seconds and 4 git commands to generate.