1 /* Native-dependent code for GNU/Linux x86.
3 Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
27 #include "gdb_assert.h"
28 #include <sys/ptrace.h>
30 #include <sys/procfs.h>
36 #ifdef HAVE_SYS_DEBUGREG_H
37 #include <sys/debugreg.h>
41 #define DR_FIRSTADDR 0
56 /* Prototypes for supply_gregset etc. */
59 /* Prototypes for i387_supply_fsave etc. */
60 #include "i387-tdep.h"
62 /* Defines for XMM0_REGNUM etc. */
63 #include "i386-tdep.h"
65 /* Defines I386_LINUX_ORIG_EAX_REGNUM. */
66 #include "i386-linux-tdep.h"
68 /* Prototypes for local functions. */
69 static void dummy_sse_values (void);
73 /* The register sets used in GNU/Linux ELF core-dumps are identical to
74 the register sets in `struct user' that is used for a.out
75 core-dumps, and is also used by `ptrace'. The corresponding types
76 are `elf_gregset_t' for the general-purpose registers (with
77 `elf_greg_t' the type of a single GP register) and `elf_fpregset_t'
78 for the floating-point registers.
80 Those types used to be available under the names `gregset_t' and
81 `fpregset_t' too, and this file used those names in the past. But
82 those names are now used for the register sets used in the
83 `mcontext_t' type, and have a different size and layout. */
85 /* Mapping between the general-purpose registers in `struct user'
86 format and GDB's register array layout. */
95 /* Which ptrace request retrieves which registers?
96 These apply to the corresponding SET requests as well. */
97 #define GETREGS_SUPPLIES(regno) \
98 ((0 <= (regno) && (regno) <= 15) || (regno) == I386_LINUX_ORIG_EAX_REGNUM)
99 #define GETFPREGS_SUPPLIES(regno) \
100 (FP0_REGNUM <= (regno) && (regno) <= LAST_FPU_CTRL_REGNUM)
101 #define GETFPXREGS_SUPPLIES(regno) \
102 (FP0_REGNUM <= (regno) && (regno) <= MXCSR_REGNUM)
104 /* Does the current host support the GETREGS request? */
105 int have_ptrace_getregs
=
106 #ifdef HAVE_PTRACE_GETREGS
113 /* Does the current host support the GETFPXREGS request? The header
114 file may or may not define it, and even if it is defined, the
115 kernel will return EIO if it's running on a pre-SSE processor.
117 My instinct is to attach this to some architecture- or
118 target-specific data structure, but really, a particular GDB
119 process can only run on top of one kernel at a time. So it's okay
120 for this to be a simple variable. */
121 int have_ptrace_getfpxregs
=
122 #ifdef HAVE_PTRACE_GETFPXREGS
130 /* Support for the user struct. */
132 /* Return the address of register REGNUM. BLOCKEND is the value of
133 u.u_ar0, which should point to the registers. */
136 register_u_addr (CORE_ADDR blockend
, int regnum
)
138 return (blockend
+ 4 * regmap
[regnum
]);
141 /* Return the size of the user struct. */
146 return (sizeof (struct user
));
150 /* Fetching registers directly from the U area, one at a time. */
152 /* FIXME: kettenis/2000-03-05: This duplicates code from `inptrace.c'.
153 The problem is that we define FETCH_INFERIOR_REGISTERS since we
154 want to use our own versions of {fetch,store}_inferior_registers
155 that use the GETREGS request. This means that the code in
156 `infptrace.c' is #ifdef'd out. But we need to fall back on that
157 code when GDB is running on top of a kernel that doesn't support
158 the GETREGS request. I want to avoid changing `infptrace.c' right
162 #define PT_READ_U PTRACE_PEEKUSR
165 #define PT_WRITE_U PTRACE_POKEUSR
168 /* Default the type of the ptrace transfer to int. */
169 #ifndef PTRACE_XFER_TYPE
170 #define PTRACE_XFER_TYPE int
173 /* Registers we shouldn't try to fetch. */
174 #define OLD_CANNOT_FETCH_REGISTER(regno) ((regno) >= I386_NUM_GREGS)
176 /* Fetch one register. */
179 fetch_register (int regno
)
181 /* This isn't really an address. But ptrace thinks of it as one. */
183 char mess
[128]; /* For messages */
185 unsigned int offset
; /* Offset of registers within the u area. */
186 char buf
[MAX_REGISTER_RAW_SIZE
];
189 if (OLD_CANNOT_FETCH_REGISTER (regno
))
191 memset (buf
, '\0', REGISTER_RAW_SIZE (regno
)); /* Supply zeroes */
192 supply_register (regno
, buf
);
196 /* Overload thread id onto process id */
197 if ((tid
= TIDGET (inferior_ptid
)) == 0)
198 tid
= PIDGET (inferior_ptid
); /* no thread id, just use process id */
200 offset
= U_REGS_OFFSET
;
202 regaddr
= register_addr (regno
, offset
);
203 for (i
= 0; i
< REGISTER_RAW_SIZE (regno
); i
+= sizeof (PTRACE_XFER_TYPE
))
206 *(PTRACE_XFER_TYPE
*) & buf
[i
] = ptrace (PT_READ_U
, tid
,
207 (PTRACE_ARG3_TYPE
) regaddr
, 0);
208 regaddr
+= sizeof (PTRACE_XFER_TYPE
);
211 sprintf (mess
, "reading register %s (#%d)",
212 REGISTER_NAME (regno
), regno
);
213 perror_with_name (mess
);
216 supply_register (regno
, buf
);
219 /* Fetch register values from the inferior.
220 If REGNO is negative, do this for all registers.
221 Otherwise, REGNO specifies which register (so we can save time). */
224 old_fetch_inferior_registers (int regno
)
228 fetch_register (regno
);
232 for (regno
= 0; regno
< NUM_REGS
; regno
++)
234 fetch_register (regno
);
239 /* Registers we shouldn't try to store. */
240 #define OLD_CANNOT_STORE_REGISTER(regno) ((regno) >= I386_NUM_GREGS)
242 /* Store one register. */
245 store_register (int regno
)
247 /* This isn't really an address. But ptrace thinks of it as one. */
249 char mess
[128]; /* For messages */
251 unsigned int offset
; /* Offset of registers within the u area. */
254 if (OLD_CANNOT_STORE_REGISTER (regno
))
259 /* Overload thread id onto process id */
260 if ((tid
= TIDGET (inferior_ptid
)) == 0)
261 tid
= PIDGET (inferior_ptid
); /* no thread id, just use process id */
263 offset
= U_REGS_OFFSET
;
265 regaddr
= register_addr (regno
, offset
);
266 for (i
= 0; i
< REGISTER_RAW_SIZE (regno
); i
+= sizeof (PTRACE_XFER_TYPE
))
269 ptrace (PT_WRITE_U
, tid
, (PTRACE_ARG3_TYPE
) regaddr
,
270 *(PTRACE_XFER_TYPE
*) & registers
[REGISTER_BYTE (regno
) + i
]);
271 regaddr
+= sizeof (PTRACE_XFER_TYPE
);
274 sprintf (mess
, "writing register %s (#%d)",
275 REGISTER_NAME (regno
), regno
);
276 perror_with_name (mess
);
281 /* Store our register values back into the inferior.
282 If REGNO is negative, do this for all registers.
283 Otherwise, REGNO specifies which register (so we can save time). */
286 old_store_inferior_registers (int regno
)
290 store_register (regno
);
294 for (regno
= 0; regno
< NUM_REGS
; regno
++)
296 store_register (regno
);
302 /* Transfering the general-purpose registers between GDB, inferiors
305 /* Fill GDB's register array with the general-purpose register values
309 supply_gregset (elf_gregset_t
*gregsetp
)
311 elf_greg_t
*regp
= (elf_greg_t
*) gregsetp
;
314 for (i
= 0; i
< I386_NUM_GREGS
; i
++)
315 supply_register (i
, (char *) (regp
+ regmap
[i
]));
317 if (I386_LINUX_ORIG_EAX_REGNUM
< NUM_REGS
)
318 supply_register (I386_LINUX_ORIG_EAX_REGNUM
, (char *) (regp
+ ORIG_EAX
));
321 /* Fill register REGNO (if it is a general-purpose register) in
322 *GREGSETPS with the value in GDB's register array. If REGNO is -1,
323 do this for all registers. */
326 fill_gregset (elf_gregset_t
*gregsetp
, int regno
)
328 elf_greg_t
*regp
= (elf_greg_t
*) gregsetp
;
331 for (i
= 0; i
< I386_NUM_GREGS
; i
++)
332 if (regno
== -1 || regno
== i
)
333 regcache_collect (i
, regp
+ regmap
[i
]);
335 if ((regno
== -1 || regno
== I386_LINUX_ORIG_EAX_REGNUM
)
336 && I386_LINUX_ORIG_EAX_REGNUM
< NUM_REGS
)
337 regcache_collect (I386_LINUX_ORIG_EAX_REGNUM
, regp
+ ORIG_EAX
);
340 #ifdef HAVE_PTRACE_GETREGS
342 /* Fetch all general-purpose registers from process/thread TID and
343 store their values in GDB's register array. */
350 if (ptrace (PTRACE_GETREGS
, tid
, 0, (int) ®s
) < 0)
354 /* The kernel we're running on doesn't support the GETREGS
355 request. Reset `have_ptrace_getregs'. */
356 have_ptrace_getregs
= 0;
360 perror_with_name ("Couldn't get registers");
363 supply_gregset (®s
);
366 /* Store all valid general-purpose registers in GDB's register array
367 into the process/thread specified by TID. */
370 store_regs (int tid
, int regno
)
374 if (ptrace (PTRACE_GETREGS
, tid
, 0, (int) ®s
) < 0)
375 perror_with_name ("Couldn't get registers");
377 fill_gregset (®s
, regno
);
379 if (ptrace (PTRACE_SETREGS
, tid
, 0, (int) ®s
) < 0)
380 perror_with_name ("Couldn't write registers");
385 static void fetch_regs (int tid
) {}
386 static void store_regs (int tid
, int regno
) {}
391 /* Transfering floating-point registers between GDB, inferiors and cores. */
393 /* Fill GDB's register array with the floating-point register values in
397 supply_fpregset (elf_fpregset_t
*fpregsetp
)
399 i387_supply_fsave ((char *) fpregsetp
);
403 /* Fill register REGNO (if it is a floating-point register) in
404 *FPREGSETP with the value in GDB's register array. If REGNO is -1,
405 do this for all registers. */
408 fill_fpregset (elf_fpregset_t
*fpregsetp
, int regno
)
410 i387_fill_fsave ((char *) fpregsetp
, regno
);
413 #ifdef HAVE_PTRACE_GETREGS
415 /* Fetch all floating-point registers from process/thread TID and store
416 thier values in GDB's register array. */
419 fetch_fpregs (int tid
)
421 elf_fpregset_t fpregs
;
423 if (ptrace (PTRACE_GETFPREGS
, tid
, 0, (int) &fpregs
) < 0)
424 perror_with_name ("Couldn't get floating point status");
426 supply_fpregset (&fpregs
);
429 /* Store all valid floating-point registers in GDB's register array
430 into the process/thread specified by TID. */
433 store_fpregs (int tid
, int regno
)
435 elf_fpregset_t fpregs
;
437 if (ptrace (PTRACE_GETFPREGS
, tid
, 0, (int) &fpregs
) < 0)
438 perror_with_name ("Couldn't get floating point status");
440 fill_fpregset (&fpregs
, regno
);
442 if (ptrace (PTRACE_SETFPREGS
, tid
, 0, (int) &fpregs
) < 0)
443 perror_with_name ("Couldn't write floating point status");
448 static void fetch_fpregs (int tid
) {}
449 static void store_fpregs (int tid
, int regno
) {}
454 /* Transfering floating-point and SSE registers to and from GDB. */
456 #ifdef HAVE_PTRACE_GETFPXREGS
458 /* Fill GDB's register array with the floating-point and SSE register
459 values in *FPXREGSETP. */
462 supply_fpxregset (elf_fpxregset_t
*fpxregsetp
)
464 i387_supply_fxsave ((char *) fpxregsetp
);
467 /* Fill register REGNO (if it is a floating-point or SSE register) in
468 *FPXREGSETP with the value in GDB's register array. If REGNO is
469 -1, do this for all registers. */
472 fill_fpxregset (elf_fpxregset_t
*fpxregsetp
, int regno
)
474 i387_fill_fxsave ((char *) fpxregsetp
, regno
);
477 /* Fetch all registers covered by the PTRACE_GETFPXREGS request from
478 process/thread TID and store their values in GDB's register array.
479 Return non-zero if successful, zero otherwise. */
482 fetch_fpxregs (int tid
)
484 elf_fpxregset_t fpxregs
;
486 if (! have_ptrace_getfpxregs
)
489 if (ptrace (PTRACE_GETFPXREGS
, tid
, 0, (int) &fpxregs
) < 0)
493 have_ptrace_getfpxregs
= 0;
497 perror_with_name ("Couldn't read floating-point and SSE registers");
500 supply_fpxregset (&fpxregs
);
504 /* Store all valid registers in GDB's register array covered by the
505 PTRACE_SETFPXREGS request into the process/thread specified by TID.
506 Return non-zero if successful, zero otherwise. */
509 store_fpxregs (int tid
, int regno
)
511 elf_fpxregset_t fpxregs
;
513 if (! have_ptrace_getfpxregs
)
516 if (ptrace (PTRACE_GETFPXREGS
, tid
, 0, &fpxregs
) == -1)
520 have_ptrace_getfpxregs
= 0;
524 perror_with_name ("Couldn't read floating-point and SSE registers");
527 fill_fpxregset (&fpxregs
, regno
);
529 if (ptrace (PTRACE_SETFPXREGS
, tid
, 0, &fpxregs
) == -1)
530 perror_with_name ("Couldn't write floating-point and SSE registers");
535 /* Fill the XMM registers in the register array with dummy values. For
536 cases where we don't have access to the XMM registers. I think
537 this is cleaner than printing a warning. For a cleaner solution,
538 we should gdbarchify the i386 family. */
541 dummy_sse_values (void)
543 /* C doesn't have a syntax for NaN's, so write it out as an array of
545 static long dummy
[4] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff };
546 static long mxcsr
= 0x1f80;
549 for (reg
= 0; reg
< 8; reg
++)
550 supply_register (XMM0_REGNUM
+ reg
, (char *) dummy
);
551 supply_register (MXCSR_REGNUM
, (char *) &mxcsr
);
556 static int fetch_fpxregs (int tid
) { return 0; }
557 static int store_fpxregs (int tid
, int regno
) { return 0; }
558 static void dummy_sse_values (void) {}
560 #endif /* HAVE_PTRACE_GETFPXREGS */
563 /* Transferring arbitrary registers between GDB and inferior. */
565 /* Check if register REGNO in the child process is accessible.
566 If we are accessing registers directly via the U area, only the
567 general-purpose registers are available.
568 All registers should be accessible if we have GETREGS support. */
571 cannot_fetch_register (int regno
)
573 if (! have_ptrace_getregs
)
574 return OLD_CANNOT_FETCH_REGISTER (regno
);
578 cannot_store_register (int regno
)
580 if (! have_ptrace_getregs
)
581 return OLD_CANNOT_STORE_REGISTER (regno
);
585 /* Fetch register REGNO from the child process. If REGNO is -1, do
586 this for all registers (including the floating point and SSE
590 fetch_inferior_registers (int regno
)
594 /* Use the old method of peeking around in `struct user' if the
595 GETREGS request isn't available. */
596 if (! have_ptrace_getregs
)
598 old_fetch_inferior_registers (regno
);
602 /* GNU/Linux LWP ID's are process ID's. */
603 if ((tid
= TIDGET (inferior_ptid
)) == 0)
604 tid
= PIDGET (inferior_ptid
); /* Not a threaded program. */
606 /* Use the PTRACE_GETFPXREGS request whenever possible, since it
607 transfers more registers in one system call, and we'll cache the
608 results. But remember that fetch_fpxregs can fail, and return
614 /* The call above might reset `have_ptrace_getregs'. */
615 if (! have_ptrace_getregs
)
617 old_fetch_inferior_registers (-1);
621 if (fetch_fpxregs (tid
))
627 if (GETREGS_SUPPLIES (regno
))
633 if (GETFPXREGS_SUPPLIES (regno
))
635 if (fetch_fpxregs (tid
))
638 /* Either our processor or our kernel doesn't support the SSE
639 registers, so read the FP registers in the traditional way,
640 and fill the SSE registers with dummy values. It would be
641 more graceful to handle differences in the register set using
642 gdbarch. Until then, this will at least make things work
648 internal_error (__FILE__
, __LINE__
,
649 "Got request for bad register number %d.", regno
);
652 /* Store register REGNO back into the child process. If REGNO is -1,
653 do this for all registers (including the floating point and SSE
656 store_inferior_registers (int regno
)
660 /* Use the old method of poking around in `struct user' if the
661 SETREGS request isn't available. */
662 if (! have_ptrace_getregs
)
664 old_store_inferior_registers (regno
);
668 /* GNU/Linux LWP ID's are process ID's. */
669 if ((tid
= TIDGET (inferior_ptid
)) == 0)
670 tid
= PIDGET (inferior_ptid
); /* Not a threaded program. */
672 /* Use the PTRACE_SETFPXREGS requests whenever possible, since it
673 transfers more registers in one system call. But remember that
674 store_fpxregs can fail, and return zero. */
677 store_regs (tid
, regno
);
678 if (store_fpxregs (tid
, regno
))
680 store_fpregs (tid
, regno
);
684 if (GETREGS_SUPPLIES (regno
))
686 store_regs (tid
, regno
);
690 if (GETFPXREGS_SUPPLIES (regno
))
692 if (store_fpxregs (tid
, regno
))
695 /* Either our processor or our kernel doesn't support the SSE
696 registers, so just write the FP registers in the traditional
698 store_fpregs (tid
, regno
);
702 internal_error (__FILE__
, __LINE__
,
703 "Got request to store bad register number %d.", regno
);
708 i386_linux_dr_get (int regnum
)
713 /* FIXME: kettenis/2001-01-29: It's not clear what we should do with
714 multi-threaded processes here. For now, pretend there is just
716 tid
= PIDGET (inferior_ptid
);
718 /* FIXME: kettenis/2001-03-27: Calling perror_with_name if the
719 ptrace call fails breaks debugging remote targets. The correct
720 way to fix this is to add the hardware breakpoint and watchpoint
721 stuff to the target vectore. For now, just return zero if the
722 ptrace call fails. */
724 value
= ptrace (PT_READ_U
, tid
,
725 offsetof (struct user
, u_debugreg
[regnum
]), 0);
728 perror_with_name ("Couldn't read debug register");
737 i386_linux_dr_set (int regnum
, unsigned long value
)
741 /* FIXME: kettenis/2001-01-29: It's not clear what we should do with
742 multi-threaded processes here. For now, pretend there is just
744 tid
= PIDGET (inferior_ptid
);
747 ptrace (PT_WRITE_U
, tid
,
748 offsetof (struct user
, u_debugreg
[regnum
]), value
);
750 perror_with_name ("Couldn't write debug register");
754 i386_linux_dr_set_control (unsigned long control
)
756 i386_linux_dr_set (DR_CONTROL
, control
);
760 i386_linux_dr_set_addr (int regnum
, CORE_ADDR addr
)
762 gdb_assert (regnum
>= 0 && regnum
<= DR_LASTADDR
- DR_FIRSTADDR
);
764 i386_linux_dr_set (DR_FIRSTADDR
+ regnum
, addr
);
768 i386_linux_dr_reset_addr (int regnum
)
770 gdb_assert (regnum
>= 0 && regnum
<= DR_LASTADDR
- DR_FIRSTADDR
);
772 i386_linux_dr_set (DR_FIRSTADDR
+ regnum
, 0L);
776 i386_linux_dr_get_status (void)
778 return i386_linux_dr_get (DR_STATUS
);
782 /* Interpreting register set info found in core files. */
784 /* Provide registers to GDB from a core file.
786 (We can't use the generic version of this function in
787 core-regset.c, because GNU/Linux has *three* different kinds of
788 register set notes. core-regset.c would have to call
789 supply_fpxregset, which most platforms don't have.)
791 CORE_REG_SECT points to an array of bytes, which are the contents
792 of a `note' from a core file which BFD thinks might contain
793 register contents. CORE_REG_SIZE is its size.
795 WHICH says which register set corelow suspects this is:
796 0 --- the general-purpose register set, in elf_gregset_t format
797 2 --- the floating-point register set, in elf_fpregset_t format
798 3 --- the extended floating-point register set, in elf_fpxregset_t format
800 REG_ADDR isn't used on GNU/Linux. */
803 fetch_core_registers (char *core_reg_sect
, unsigned core_reg_size
,
804 int which
, CORE_ADDR reg_addr
)
806 elf_gregset_t gregset
;
807 elf_fpregset_t fpregset
;
812 if (core_reg_size
!= sizeof (gregset
))
813 warning ("Wrong size gregset in core file.");
816 memcpy (&gregset
, core_reg_sect
, sizeof (gregset
));
817 supply_gregset (&gregset
);
822 if (core_reg_size
!= sizeof (fpregset
))
823 warning ("Wrong size fpregset in core file.");
826 memcpy (&fpregset
, core_reg_sect
, sizeof (fpregset
));
827 supply_fpregset (&fpregset
);
831 #ifdef HAVE_PTRACE_GETFPXREGS
833 elf_fpxregset_t fpxregset
;
836 if (core_reg_size
!= sizeof (fpxregset
))
837 warning ("Wrong size fpxregset in core file.");
840 memcpy (&fpxregset
, core_reg_sect
, sizeof (fpxregset
));
841 supply_fpxregset (&fpxregset
);
848 /* We've covered all the kinds of registers we know about here,
849 so this must be something we wouldn't know what to do with
850 anyway. Just ignore it. */
856 /* The instruction for a GNU/Linux system call is:
860 static const unsigned char linux_syscall
[] = { 0xcd, 0x80 };
862 #define LINUX_SYSCALL_LEN (sizeof linux_syscall)
864 /* The system call number is stored in the %eax register. */
865 #define LINUX_SYSCALL_REGNUM 0 /* %eax */
867 /* We are specifically interested in the sigreturn and rt_sigreturn
870 #ifndef SYS_sigreturn
871 #define SYS_sigreturn 0x77
873 #ifndef SYS_rt_sigreturn
874 #define SYS_rt_sigreturn 0xad
877 /* Offset to saved processor flags, from <asm/sigcontext.h>. */
878 #define LINUX_SIGCONTEXT_EFLAGS_OFFSET (64)
880 /* Resume execution of the inferior process.
881 If STEP is nonzero, single-step it.
882 If SIGNAL is nonzero, give it that signal. */
885 child_resume (ptid_t ptid
, int step
, enum target_signal signal
)
887 int pid
= PIDGET (ptid
);
889 int request
= PTRACE_CONT
;
892 /* Resume all threads. */
893 /* I think this only gets used in the non-threaded case, where "resume
894 all threads" and "resume inferior_ptid" are the same. */
895 pid
= PIDGET (inferior_ptid
);
899 CORE_ADDR pc
= read_pc_pid (pid_to_ptid (pid
));
900 unsigned char buf
[LINUX_SYSCALL_LEN
];
902 request
= PTRACE_SINGLESTEP
;
904 /* Returning from a signal trampoline is done by calling a
905 special system call (sigreturn or rt_sigreturn, see
906 i386-linux-tdep.c for more information). This system call
907 restores the registers that were saved when the signal was
908 raised, including %eflags. That means that single-stepping
909 won't work. Instead, we'll have to modify the signal context
910 that's about to be restored, and set the trace flag there. */
912 /* First check if PC is at a system call. */
913 if (read_memory_nobpt (pc
, (char *) buf
, LINUX_SYSCALL_LEN
) == 0
914 && memcmp (buf
, linux_syscall
, LINUX_SYSCALL_LEN
) == 0)
916 int syscall
= read_register_pid (LINUX_SYSCALL_REGNUM
,
919 /* Then check the system call number. */
920 if (syscall
== SYS_sigreturn
|| syscall
== SYS_rt_sigreturn
)
922 CORE_ADDR sp
= read_register (SP_REGNUM
);
924 unsigned long int eflags
;
926 if (syscall
== SYS_rt_sigreturn
)
927 addr
= read_memory_integer (sp
+ 8, 4) + 20;
929 /* Set the trace flag in the context that's about to be
931 addr
+= LINUX_SIGCONTEXT_EFLAGS_OFFSET
;
932 read_memory (addr
, (char *) &eflags
, 4);
934 write_memory (addr
, (char *) &eflags
, 4);
939 if (ptrace (request
, pid
, 0, target_signal_to_host (signal
)) == -1)
940 perror_with_name ("ptrace");
944 /* Register that we are able to handle GNU/Linux ELF core file
947 static struct core_fns linux_elf_core_fns
=
949 bfd_target_elf_flavour
, /* core_flavour */
950 default_check_format
, /* check_format */
951 default_core_sniffer
, /* core_sniffer */
952 fetch_core_registers
, /* core_read_registers */
957 _initialize_i386_linux_nat (void)
959 add_core_fns (&linux_elf_core_fns
);