1 /* Native-dependent code for FreeBSD/i386.
2 Copyright 2001 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
25 #include <sys/types.h>
26 #include <sys/ptrace.h>
27 #include <sys/sysctl.h>
29 /* Prevent warning from -Wmissing-prototypes. */
30 void _initialize_i386fbsd_nat (void);
32 /* Resume execution of the inferior process.
33 If STEP is nonzero, single-step it.
34 If SIGNAL is nonzero, give it that signal. */
37 child_resume (ptid_t ptid
, int step
, enum target_signal signal
)
39 pid_t pid
= ptid_get_pid (ptid
);
40 int request
= PT_STEP
;
43 /* Resume all threads. This only gets used in the non-threaded
44 case, where "resume all threads" and "resume inferior_ptid" are
46 pid
= ptid_get_pid (inferior_ptid
);
52 /* Workaround for a bug in FreeBSD. Make sure that the trace
53 flag is off when doing a continue. There is a code path
54 through the kernel which leaves the flag set when it should
55 have been cleared. If a process has a signal pending (such
56 as SIGALRM) and we do a PT_STEP, the process never really has
57 a chance to run because the kernel needs to notify the
58 debugger that a signal is being sent. Therefore, the process
59 never goes through the kernel's trap() function which would
62 eflags
= read_register (PS_REGNUM
);
64 write_register (PS_REGNUM
, eflags
& ~0x0100);
66 request
= PT_CONTINUE
;
69 /* An addres of (caddr_t) 1 tells ptrace to continue from where it
70 was. (If GDB wanted it to start some other way, we have already
71 written a new PC value to the child.) */
72 if (ptrace (request
, pid
, (caddr_t
) 1,
73 target_signal_to_host (signal
)) == -1)
74 perror_with_name ("ptrace");
78 _initialize_i386fbsd_nat (void)
80 /* FreeBSD provides a kern.ps_strings sysctl that we can use to
81 locate the sigtramp. That way we can still recognize a sigtramp
82 if it's location is changed in a new kernel. Of course this is
83 still based on the assumption that the sigtramp is placed
84 directly under the location where the program arguments and
85 environment can be found. */
86 #ifdef KERN_PS_STRINGS
93 mib
[1] = KERN_PS_STRINGS
;
94 len
= sizeof (ps_strings
);
95 if (sysctl (mib
, 2, &ps_strings
, &len
, NULL
, 0) == 0)
97 i386bsd_sigtramp_start
= ps_strings
- 128;
98 i386bsd_sigtramp_end
= ps_strings
;
This page took 0.031525 seconds and 4 git commands to generate.