/* Low level interface to ptrace, for GDB when running on the Intel 386.
Copyright (C) 1988, 1989 Free Software Foundation, Inc.
This file is part of GDB.
GDB is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
GDB is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GDB; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#define N_SET_MAGIC(exec, val) ((exec).magic = (val))
#define N_SET_MAGIC(exec, val) ((exec).a_magic = (val))
/* This function simply calls ptrace with the given arguments.
It exists so that all calls to ptrace are isolated in this
machine-dependent file. */
call_ptrace (request
, pid
, arg3
, arg4
)
int request
, pid
, arg3
, arg4
;
return ptrace (request
, pid
, arg3
, arg4
);
ptrace (8, inferior_pid
, 0, 0);
/* This is used when GDB is exiting. It gives less chance of error.*/
ptrace (8, inferior_pid
, 0, 0);
/* Resume execution of the inferior process.
If STEP is nonzero, single-step it.
If SIGNAL is nonzero, give it that signal. */
remote_resume (step
, signal
);
ptrace (step
? 9 : 7, inferior_pid
, 1, signal
);
perror_with_name ("ptrace");
fetch_inferior_registers ()
register unsigned int regaddr
;
char buf
[MAX_REGISTER_RAW_SIZE
];
unsigned int offset
= (char *) &u
.u_ar0
- (char *) &u
;
offset
= ptrace (3, inferior_pid
, offset
, 0) - KERNEL_U_ADDR
;
for (regno
= 0; regno
< NUM_REGS
; regno
++)
regaddr
= register_addr (regno
, offset
);
for (i
= 0; i
< REGISTER_RAW_SIZE (regno
); i
+= sizeof (int))
*(int *) &buf
[i
] = ptrace (3, inferior_pid
, regaddr
, 0);
supply_register (regno
, buf
);
/* Store our register values back into the inferior.
If REGNO is -1, do this for all registers.
Otherwise, REGNO specifies which register (so we can save time). */
store_inferior_registers (regno
)
register unsigned int regaddr
;
unsigned int offset
= (char *) &u
.u_ar0
- (char *) &u
;
offset
= ptrace (3, inferior_pid
, offset
, 0) - KERNEL_U_ADDR
;
regaddr
= register_addr (regno
, offset
);
ptrace (6, inferior_pid
, regaddr
, read_register (regno
));
sprintf (buf
, "writing register number %d", regno
);
else for (regno
= 0; regno
< NUM_REGS
; regno
++)
regaddr
= register_addr (regno
, offset
);
ptrace (6, inferior_pid
, regaddr
, read_register (regno
));
sprintf (buf
, "writing register number %d", regno
);
/* Copy LEN bytes from inferior's memory starting at MEMADDR
to debugger memory starting at MYADDR.
On failure (cannot read from inferior, usually because address is out
of bounds) returns the value of errno. */
read_inferior_memory (memaddr
, myaddr
, len
)
/* Round starting address down to longword boundary. */
register CORE_ADDR addr
= memaddr
& - sizeof (int);
/* Round ending address up; get number of longwords that makes. */
= (((memaddr
+ len
) - addr
) + sizeof (int) - 1) / sizeof (int);
/* Allocate buffer of that many longwords. */
register int *buffer
= (int *) alloca (count
* sizeof (int));
/* Read all the longwords */
for (i
= 0; i
< count
; i
++, addr
+= sizeof (int))
buffer
[i
] = remote_fetch_word (addr
);
buffer
[i
] = ptrace (1, inferior_pid
, addr
, 0);
/* Copy appropriate bytes out of the buffer. */
bcopy ((char *) buffer
+ (memaddr
& (sizeof (int) - 1)), myaddr
, len
);
/* Copy LEN bytes of data from debugger memory at MYADDR
to inferior's memory at MEMADDR.
On failure (cannot write the inferior)
returns the value of errno. */
write_inferior_memory (memaddr
, myaddr
, len
)
/* Round starting address down to longword boundary. */
register CORE_ADDR addr
= memaddr
& - sizeof (int);
/* Round ending address up; get number of longwords that makes. */
= (((memaddr
+ len
) - addr
) + sizeof (int) - 1) / sizeof (int);
/* Allocate buffer of that many longwords. */
register int *buffer
= (int *) alloca (count
* sizeof (int));
/* Fill start and end extra bytes of buffer with existing memory data. */
buffer
[0] = remote_fetch_word (addr
);
buffer
[0] = ptrace (1, inferior_pid
, addr
, 0);
= remote_fetch_word (addr
+ (count
- 1) * sizeof (int));
= ptrace (1, inferior_pid
,
addr
+ (count
- 1) * sizeof (int), 0);
/* Copy data to be written over corresponding part of buffer */
bcopy (myaddr
, (char *) buffer
+ (memaddr
& (sizeof (int) - 1)), len
);
/* Write the entire buffer. */
for (i
= 0; i
< count
; i
++, addr
+= sizeof (int))
remote_store_word (addr
, buffer
[i
]);
ptrace (4, inferior_pid
, addr
, buffer
[i
]);
/* Work with core dump and executable files, for GDB.
This code would be in core.c if it weren't machine-dependent. */
#endif /* no N_TXTADDR */
#define N_DATADDR(hdr) hdr.a_text
#endif /* no N_DATADDR */
/* Make COFF and non-COFF names for things a little more compatible
to reduce conditionals later. */
#define AOUTHDR struct exec
extern char *sys_siglist
[];
/* Hook for `exec_file_command' command to call. */
extern void (*exec_file_display_hook
) ();
/* File names of core file and executable file. */
/* Descriptors on which core file and executable file are open.
Note that the execchan is closed when an inferior is created
and reopened if the inferior dies or is killed. */
/* Last modification time of executable file.
Also used in source.c to compare against mtime of a source file. */
/* Virtual addresses of bounds of the two areas of memory in the core file. */
extern CORE_ADDR data_start
;
extern CORE_ADDR data_end
;
extern CORE_ADDR stack_start
;
extern CORE_ADDR stack_end
;
/* Virtual addresses of bounds of two areas of memory in the exec file.
Note that the data area in the exec file is used only when there is no core file. */
extern CORE_ADDR text_start
;
extern CORE_ADDR text_end
;
extern CORE_ADDR exec_data_start
;
extern CORE_ADDR exec_data_end
;
/* Address in executable file of start of text area data. */
/* Address in executable file of start of data area data. */
extern int exec_data_offset
;
/* Address in core file of start of data area data. */
/* Address in core file of start of stack area data. */
/* various coff data structures */
#endif /* not COFF_FORMAT */
/* a.out header saved in core file. */
extern AOUTHDR core_aouthdr
;
/* a.out header of exec file. */
extern AOUTHDR exec_aouthdr
;
extern void validate_files ();
core_file_command (filename
, from_tty
)
/* Discard all vestiges of any previous core file
and mark data and stack spaces as empty. */
stack_start
= STACK_END_ADDR
;
stack_end
= STACK_END_ADDR
;
/* Now, if a new core file was specified, open it and digest it. */
filename
= tilde_expand (filename
);
make_cleanup (free
, filename
);
error ("To look at a core file, you must kill the inferior with \"kill\".");
corechan
= open (filename
, O_RDONLY
, 0);
perror_with_name (filename
);
/* 4.2-style (and perhaps also sysV-style) core dump file. */
val
= myread (corechan
, &u
, sizeof u
);
perror_with_name (filename
);
data_start
= exec_data_start
;
data_end
= data_start
+ NBPG
* u
.u_dsize
;
stack_start
= stack_end
- NBPG
* u
.u_ssize
;
data_offset
= NBPG
* UPAGES
;
stack_offset
= NBPG
* (UPAGES
+ u
.u_dsize
);
reg_offset
= (int) u
.u_ar0
- KERNEL_U_ADDR
;
/* I don't know where to find this info.
So, for now, mark it as not available. */
/* N_SET_MAGIC (core_aouthdr, 0); */
bzero ((char *) &core_aouthdr
, sizeof core_aouthdr
);
/* Read the register values out of the core file and store
them where `read_register' will find them. */
for (regno
= 0; regno
< NUM_REGS
; regno
++)
char buf
[MAX_REGISTER_RAW_SIZE
];
val
= lseek (corechan
, register_addr (regno
, reg_offset
), 0);
perror_with_name (filename
);
val
= myread (corechan
, buf
, sizeof buf
);
perror_with_name (filename
);
supply_register (regno
, buf
);
corefile
= savestring (filename
, strlen (filename
));
corefile
= concat (current_directory
, "/", filename
);
set_current_frame ( create_new_frame (read_register (FP_REGNUM
),
select_frame (get_current_frame (), 0);
printf ("No core file now.\n");
exec_file_command (filename
, from_tty
)
/* Eliminate all traces of old exec file.
Mark text segment as empty. */
data_end
-= exec_data_start
;
/* Now open and digest the file the user requested, if any. */
filename
= tilde_expand (filename
);
make_cleanup (free
, filename
);
execchan
= openp (getenv ("PATH"), 1, filename
, O_RDONLY
, 0,
perror_with_name (filename
);
if (read_file_hdr (execchan
, &file_hdr
) < 0)
error ("\"%s\": not in executable format.", execfile
);
aout_hdrsize
= file_hdr
.f_opthdr
;
num_sections
= file_hdr
.f_nscns
;
if (read_aout_hdr (execchan
, &exec_aouthdr
, aout_hdrsize
) < 0)
error ("\"%s\": can't read optional aouthdr", execfile
);
if (read_section_hdr (execchan
, _TEXT
, &text_hdr
, num_sections
,
error ("\"%s\": can't read text section header", execfile
);
if (read_section_hdr (execchan
, _DATA
, &data_hdr
, num_sections
,
error ("\"%s\": can't read data section header", execfile
);
text_start
= exec_aouthdr
.text_start
;
text_end
= text_start
+ exec_aouthdr
.tsize
;
text_offset
= text_hdr
.s_scnptr
;
exec_data_start
= exec_aouthdr
.data_start
;
exec_data_end
= exec_data_start
+ exec_aouthdr
.dsize
;
exec_data_offset
= data_hdr
.s_scnptr
;
data_start
= exec_data_start
;
data_end
+= exec_data_start
;
exec_mtime
= file_hdr
.f_timdat
;
#else /* not COFF_FORMAT */
HEADER_SEEK_FD (execchan
);
val
= myread (execchan
, &exec_aouthdr
, sizeof (AOUTHDR
));
perror_with_name (filename
);
text_start
= N_TXTADDR (exec_aouthdr
);
exec_data_start
= N_DATADDR (exec_aouthdr
);
text_offset
= N_TXTOFF (exec_aouthdr
);
exec_data_offset
= N_TXTOFF (exec_aouthdr
) + exec_aouthdr
.a_text
;
text_end
= text_start
+ exec_aouthdr
.a_text
;
exec_data_end
= exec_data_start
+ exec_aouthdr
.a_data
;
data_start
= exec_data_start
;
data_end
+= exec_data_start
;
fstat (execchan
, &st_exec
);
exec_mtime
= st_exec
.st_mtime
;
#endif /* not COFF_FORMAT */
printf ("No exec file now.\n");
/* Tell display code (if any) about the changed file name. */
if (exec_file_display_hook
)
(*exec_file_display_hook
) (filename
);
/* helper functions for m-i386.h */
/* stdio style buffering to minimize calls to ptrace */
static CORE_ADDR codestream_next_addr
;
static CORE_ADDR codestream_addr
;
static unsigned char codestream_buf
[sizeof (int)];
static int codestream_off
;
static int codestream_cnt
;
#define codestream_tell() (codestream_addr + codestream_off)
#define codestream_peek() (codestream_cnt == 0 ? \
codestream_fill(1): codestream_buf[codestream_off])
#define codestream_get() (codestream_cnt-- == 0 ? \
codestream_fill(0) : codestream_buf[codestream_off++])
codestream_fill (peek_flag
)
codestream_addr
= codestream_next_addr
;
codestream_next_addr
+= sizeof (int);
codestream_cnt
= sizeof (int);
read_memory (codestream_addr
,
(unsigned char *)codestream_buf
,
return (codestream_peek());
return (codestream_get());
codestream_next_addr
= place
& -sizeof (int);
while (codestream_tell() != place
)
codestream_read (buf
, count
)
for (i
= 0; i
< count
; i
++)
*p
++ = codestream_get ();
/* next instruction is a jump, move to target */
pos
= codestream_tell ();
if (codestream_peek () == 0x66)
switch (codestream_get ())
/* relative jump: if data16 == 0, disp32, else disp16 */
codestream_read ((unsigned char *)&short_delta
, 2);
pos
+= short_delta
+ 3; /* include size of jmp inst */
codestream_read ((unsigned char *)&long_delta
, 4);
/* relative jump, disp8 (ignore data16) */
codestream_read ((unsigned char *)&byte_delta
, 1);
codestream_seek (pos
+ data16
);
* find & return amound a local space allocated, and advance codestream to
* first register push (if any)
* if entry sequence doesn't make sense, return -1, and leave
* codestream pointer random
i386_get_frame_setup (pc
)
if (op
== 0x58) /* popl %eax */
* this function must start with
* xchgl %eax, (%esp) 0x87 0x04 0x24
* or xchgl %eax, 0(%esp) 0x87 0x44 0x24 0x00
* (the system 5 compiler puts out the second xchg
* inst, and the assembler doesn't try to optimize it,
* so the 'sib' form gets generated)
* this sequence is used to get the address of the return
* buffer for a function that returns a structure
static unsigned char proto1
[3] = { 0x87,0x04,0x24 };
static unsigned char proto2
[4] = { 0x87,0x44,0x24,0x00 };
pos
= codestream_tell ();
codestream_read (buf
, 4);
if (bcmp (buf
, proto1
, 3) == 0)
else if (bcmp (buf
, proto2
, 4) == 0)
op
= codestream_get (); /* update next opcode */
if (op
== 0x55) /* pushl %esp */
/* check for movl %esp, %ebp - can be written two ways */
switch (codestream_get ())
if (codestream_get () != 0xec)
if (codestream_get () != 0xe5)
/* check for stack adjustment
* note: you can't subtract a 16 bit immediate
* from a 32 bit reg, so we don't have to worry
/* subl with 8 bit immed */
if (codestream_get () != 0xec)
/* subl with signed byte immediate
* (though it wouldn't make sense to be negative)
return (codestream_get());
/* subl with 32 bit immed */
if (codestream_get () != 0xec)
/* subl with 32 bit immediate */
codestream_read ((unsigned char *)&locals
, 4);
/* enter instruction: arg is 16 bit unsigned immed */
codestream_read ((unsigned char *)&slocals
, 2);
codestream_get (); /* flush final byte of enter instruction */
/* Return number of args passed to a frame.
Can return -1, meaning no way to tell. */
/* on the 386, the instruction following the call could be:
* addl $imm, %esp - imm/4 args; imm may be 8 or 32 bits
* anything else - zero args
pfi
= get_prev_frame_info ((fi
));
/* Note: this can happen if we are looking at the frame for
main, because FRAME_CHAIN_VALID won't let us go into
start. If we have debugging symbols, that's not really
a big deal; it just means it will only show as many arguments
to main as are declared. */
op
= read_memory_integer (retpc
, 1);
op
= read_memory_integer (retpc
+1, 1);
/* addl $<signed imm 8 bits>, %esp */
return (read_memory_integer (retpc
+2,1)&0xff)/4;
{ /* add with 32 bit immediate */
op
= read_memory_integer (retpc
+1, 1);
/* addl $<imm 32>, %esp */
return read_memory_integer (retpc
+2, 4) / 4;
* parse the first few instructions of the function to see
* what registers were stored.
* The startup sequence can be at the start of the function,
* or the function can start with a branch to startup code at the end.
* %ebp can be set up with either the 'enter' instruction, or
* 'pushl %ebp, movl %esp, %ebp' (enter is too slow to be useful,
* but was once used in the sys5 compiler)
* Local space is allocated just below the saved %ebp by either the
* 'enter' instruction, or by 'subl $<size>, %esp'. 'enter' has
* a 16 bit unsigned argument for space to allocate, and the
* 'addl' instruction could have either a signed byte, or
* Next, the registers used by this function are pushed. In
* the sys5 compiler they will always be in the order: %edi, %esi, %ebx
* (and sometimes a harmless bug causes it to also save but not restore %eax);
* however, the code below is willing to see the pushes in any order,
* and will handle up to 8 of them.
* If the setup sequence is at the end of the function, then the
* next instruction will be a branch back to the start.
i386_frame_find_saved_regs (fip
, fsrp
)
struct frame_saved_regs
*fsrp
;
bzero (fsrp
, sizeof *fsrp
);
/* if frame is the end of a dummy, compute where the
dummy_bottom
= fip
->frame
- 4 - NUM_REGS
*4 - CALL_DUMMY_LENGTH
;
/* check if the PC is in the stack, in a dummy frame */
if (dummy_bottom
<= fip
->pc
&& fip
->pc
<= fip
->frame
)
/* all regs were saved by push_call_dummy () */
for (i
= 0; i
< NUM_REGS
; i
++)
locals
= i386_get_frame_setup (get_pc_function_start (fip
->pc
));
adr
= fip
->frame
- 4 - locals
;
if (op
< 0x50 || op
> 0x57)
fsrp
->regs
[op
- 0x50] = adr
;
fsrp
->regs
[PC_REGNUM
] = fip
->frame
+ 4;
fsrp
->regs
[FP_REGNUM
] = fip
->frame
;
/* return pc of first real instruction */
if (i386_get_frame_setup (pc
) < 0)
/* found valid frame setup - codestream now points to
* start of push instructions for saving registers
/* skip over register saves */
/* break if not pushl inst */
if (op
< 0x50 || op
> 0x57)
return (codestream_tell ());
CORE_ADDR sp
= read_register (SP_REGNUM
);
sp
= push_word (sp
, read_register (PC_REGNUM
));
sp
= push_word (sp
, read_register (FP_REGNUM
));
write_register (FP_REGNUM
, sp
);
for (regnum
= 0; regnum
< NUM_REGS
; regnum
++)
sp
= push_word (sp
, read_register (regnum
));
write_register (SP_REGNUM
, sp
);
FRAME frame
= get_current_frame ();
struct frame_saved_regs fsr
;
fi
= get_frame_info (frame
);
get_frame_saved_regs (fi
, &fsr
);
for (regnum
= 0; regnum
< NUM_REGS
; regnum
++)
write_register (regnum
, read_memory_integer (adr
, 4));
write_register (FP_REGNUM
, read_memory_integer (fp
, 4));
write_register (PC_REGNUM
, read_memory_integer (fp
+ 4, 4));
write_register (SP_REGNUM
, fp
+ 8);
set_current_frame ( create_new_frame (read_register (FP_REGNUM
),
/* this table must line up with REGISTER_NAMES in m-i386.h */
/* symbols like 'EAX' come from <sys/reg.h> */
/* blockend is the value of u.u_ar0, and points to the
* place where GS is stored
i386_register_u_addr (blockend
, regnum
)
/* this will be needed if fp registers are reinstated */
/* for now, you can look at them with 'info float'
* sys5 wont let you change them with ptrace anyway
if (regnum
>= FP0_REGNUM
&& regnum
<= FP7_REGNUM
)
ubase
= blockend
+ 4 * (SS
+ 1) - KSTKSZ
;
fpstate
= ubase
+ ((char *)&u
.u_fpstate
- (char *)&u
);
return (fpstate
+ 0x1c + 10 * (regnum
- FP0_REGNUM
));
return (blockend
+ 4 * regmap
[regnum
]);
i387_to_double (from
, to
)
/* push extended mode on 387 stack, then pop in double mode
* first, set exception masks so no error is generated -
* number will be rounded to inf or 0, if necessary
asm ("pushl %eax"); /* grab a stack slot */
asm ("fstcw (%esp)"); /* get 387 control word */
asm ("movl (%esp),%eax"); /* save old value */
asm ("orl $0x3f,%eax"); /* mask all exceptions */
asm ("fldcw (%esp)"); /* load new value into 387 */
asm ("movl 8(%ebp),%eax");
asm ("fldt (%eax)"); /* push extended number on 387 stack */
asm ("movl 12(%ebp),%eax");
asm ("fstpl (%eax)"); /* pop double */
asm ("popl %eax"); /* flush modified control word */
asm ("fnclex"); /* clear exceptions */
asm ("fldcw (%esp)"); /* restore original control word */
asm ("popl %eax"); /* flush saved copy */
double_to_i387 (from
, to
)
/* push double mode on 387 stack, then pop in extended mode
* no errors are possible because every 64-bit pattern
* can be converted to an extended
asm ("movl 8(%ebp),%eax");
asm ("movl 12(%ebp),%eax");
unsigned short operand_seg
;
unsigned char regs
[8][10];
print_387_control_word (control
)
printf ("control 0x%04x: ", control
);
switch ((control
>> 8) & 3)
case 0: printf ("24 bits; "); break;
case 1: printf ("(bad); "); break;
case 2: printf ("53 bits; "); break;
case 3: printf ("64 bits; "); break;
switch ((control
>> 10) & 3)
case 0: printf ("NEAREST; "); break;
case 1: printf ("DOWN; "); break;
case 2: printf ("UP; "); break;
case 3: printf ("CHOP; "); break;
if (control
& 0x0001) printf (" INVALID");
if (control
& 0x0002) printf (" DENORM");
if (control
& 0x0004) printf (" DIVZ");
if (control
& 0x0008) printf (" OVERF");
if (control
& 0x0010) printf (" UNDERF");
if (control
& 0x0020) printf (" LOS");
if (control
& 0xe080) printf ("warning: reserved bits on 0x%x\n",
print_387_status_word (status
)
printf ("status 0x%04x: ", status
);
if (status
& 0x0001) printf (" INVALID");
if (status
& 0x0002) printf (" DENORM");
if (status
& 0x0004) printf (" DIVZ");
if (status
& 0x0008) printf (" OVERF");
if (status
& 0x0010) printf (" UNDERF");
if (status
& 0x0020) printf (" LOS");
if (status
& 0x0040) printf (" FPSTACK");
printf ("flags: %d%d%d%d; ",
printf ("top %d\n", (status
>> 11) & 7);
print_387_status (status
, ep
)
bothstatus
= ((status
!= 0) && (ep
->status
!= 0));
print_387_status_word (status
);
print_387_status_word (ep
->status
);
print_387_control_word (ep
->control
);
printf ("last exception: ");
printf ("opcode 0x%x; ", ep
->opcode
);
printf ("pc 0x%x:0x%x; ", ep
->code_seg
, ep
->eip
);
printf ("operand 0x%x:0x%x\n", ep
->operand_seg
, ep
->operand
);
top
= (ep
->status
>> 11) & 7;
printf ("regno tag msb lsb value\n");
for (fpreg
= 7; fpreg
>= 0; fpreg
--)
printf ("%s %d: ", fpreg
== top
? "=>" : " ", fpreg
);
switch ((ep
->tag
>> (fpreg
* 2)) & 3)
case 0: printf ("valid "); break;
case 1: printf ("zero "); break;
case 2: printf ("trap "); break;
case 3: printf ("empty "); break;
printf ("%02x", ep
->regs
[fpreg
][i
]);
i387_to_double (ep
->regs
[fpreg
], (char *)&val
);
printf ("warning: reserved0 is 0x%x\n", ep
->r0
);
printf ("warning: reserved1 is 0x%x\n", ep
->r1
);
printf ("warning: reserved2 is 0x%x\n", ep
->r2
);
printf ("warning: reserved3 is 0x%x\n", ep
->r3
);
#define U_FPSTATE(u) u.u_fpstate
struct user u
; /* just for address computations */
/* fpstate defined in <sys/user.h> */
struct fpstate
*fpstatep
;
char buf
[sizeof (struct fpstate
) + 2 * sizeof (int)];
unsigned int rounded_addr
;
unsigned int rounded_size
;
uaddr
= (char *)&u
.u_fpvalid
- (char *)&u
;
rounded_addr
= uaddr
& -sizeof (int);
data
= ptrace (3, inferior_pid
, rounded_addr
, 0);
mask
= 0xff << ((uaddr
- rounded_addr
) * 8);
fpvalid
= ((data
& mask
) != 0);
if (lseek (corechan
, uaddr
, 0) < 0)
perror ("seek on core file");
if (myread (corechan
, &fpvalid
, 1) < 0)
perror ("read on core file");
printf ("no floating point status saved\n");
uaddr
= (char *)&U_FPSTATE(u
) - (char *)&u
;
rounded_addr
= uaddr
& -sizeof (int);
rounded_size
= (((uaddr
+ sizeof (struct fpstate
)) - uaddr
) +
sizeof (int) - 1) / sizeof (int);
skip
= uaddr
- rounded_addr
;
for (i
= 0; i
< rounded_size
; i
++)
*ip
++ = ptrace (3, inferior_pid
, rounded_addr
, 0);
rounded_addr
+= sizeof (int);
if (lseek (corechan
, uaddr
, 0) < 0)
perror_with_name ("seek on core file");
if (myread (corechan
, buf
, sizeof (struct fpstate
)) < 0)
perror_with_name ("read from core file");
fpstatep
= (struct fpstate
*)(buf
+ skip
);
print_387_status (fpstatep
->status
, (struct env387
*)fpstatep
->state
);