aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/ptrace.h
Commit message (Collapse)AuthorAgeFilesLines
* Add ptrace op PT_GET_SC_RET.John Baldwin2019-07-151-0/+7
| | | | | | | | | | | | | | | | | | | | | | This ptrace operation returns a structure containing the error and return values from the current system call. It is only valid when a thread is stopped during a system call exit (PL_FLAG_SCX is set). The sr_error member holds the error value from the system call. Note that this error value is the native FreeBSD error value that has _not_ been translated to an ABI-specific error value similar to the values logged to ktrace. If sr_error is zero, then the return values of the system call will be set in sr_retval[0] and sr_retval[1]. Reviewed by: kib MFC after: 1 month Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D20901 Notes: svn path=/head/; revision=350017
* sys: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-0/+2
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326023
* Store a 32-bit PT_LWPINFO struct for 32-bit process core dumps.John Baldwin2017-06-291-0/+15
| | | | | | | | | | | | Process core notes for a 32-bit process running on a 64-bit host need to use 32-bit structures so that the note layout matches the layout of notes of a core dump of a 32-bit process under a 32-bit kernel. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D11407 Notes: svn path=/head/; revision=320481
* Add ptrace(PT_GET_SC_ARGS) command to return debuggee' current syscallKonstantin Belousov2017-06-121-0/+2
| | | | | | | | | | | | arguments. Reviewed by: jhb (previous version) Sponsored by: The FreeBSD Foundation MFC after: 3 weeks Differential revision: https://reviews.freebsd.org/D11080 Notes: svn path=/head/; revision=319875
* Renumber copyright clause 4Warner Losh2017-02-281-1/+1
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* Add PTRACE_VFORK to trace vfork events.John Baldwin2016-07-181-0/+3
| | | | | | | | | | | | | | | | First, PL_FLAG_FORKED events now also set a PL_FLAG_VFORKED flag when the new child was created via vfork() rather than fork(). Second, a new PL_FLAG_VFORK_DONE event can now be enabled via the PTRACE_VFORK event mask. This new stop is reported after the vfork parent resumes due to the child calling exit or exec. Debuggers can use this stop to reinsert breakpoints in the vfork parent process before it resumes. Reviewed by: kib MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D7045 Notes: svn path=/head/; revision=303001
* Add a mask of optional ptrace() events.John Baldwin2016-07-151-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ptrace() now stores a mask of optional events in p_ptevents. Currently this mask is a single integer, but it can be expanded into an array of integers in the future. Two new ptrace requests can be used to manipulate the event mask: PT_GET_EVENT_MASK fetches the current event mask and PT_SET_EVENT_MASK sets the current event mask. The current set of events include: - PTRACE_EXEC: trace calls to execve(). - PTRACE_SCE: trace system call entries. - PTRACE_SCX: trace syscam call exits. - PTRACE_FORK: trace forks and auto-attach to new child processes. - PTRACE_LWP: trace LWP events. The S_PT_SCX and S_PT_SCE events in the procfs p_stops flags have been replaced by PTRACE_SCE and PTRACE_SCX. PTRACE_FORK replaces P_FOLLOW_FORK and PTRACE_LWP replaces P2_LWP_EVENTS. The PT_FOLLOW_FORK and PT_LWP_EVENTS ptrace requests remain for compatibility but now simply toggle corresponding flags in the event mask. While here, document that PT_SYSCALL, PT_TO_SCE, and PT_TO_SCX both modify the event mask and continue the traced process. Reviewed by: kib MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D7044 Notes: svn path=/head/; revision=302902
* Add ptrace(2) reporting for LWP events.John Baldwin2015-12-291-0/+3
| | | | | | | | | | | Add two new LWPINFO flags: PL_FLAG_BORN and PL_FLAG_EXITED for reporting thread creation and destruction. Newly created threads will stop to report PL_FLAG_BORN before returning to userland and exiting threads will stop to report PL_FLAG_EXIT before exiting completely. Both of these events are only enabled and reported if PT_LWP_EVENTS is enabled on a process. Notes: svn path=/head/; revision=292894
* Add helper functions proc_readmem() and proc_writemem().Mark Johnston2015-12-071-0/+4
| | | | | | | | | | | | | | | | These helper functions can be used to read in or write a buffer from or to an arbitrary process' address space. Without them, this can only be done using proc_rwmem(), which requires the caller to fill out a uio. This is onerous and results in code duplication; the new functions provide a simpler interface which is sufficient for most existing callers of proc_rwmem(). This change also adds a manual page for proc_rwmem() and the new functions. Reviewed by: jhb, kib Differential Revision: https://reviews.freebsd.org/D4245 Notes: svn path=/head/; revision=291961
* Switch pl_child_pid from int to pid_t.John Baldwin2015-10-201-1/+1
| | | | | | | | | Reviewed by: emaste, kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D3857 Notes: svn path=/head/; revision=289636
* Export current system call code and argument count for system call entryJohn Baldwin2015-09-011-0/+2
| | | | | | | | | | | | | | | | | | and exit events. procfs stop events for system call tracing report these values (argument count for system call entry and code for system call exit), but ptrace() does not provide this information. (Note that while the system call code can be determined in an ABI-specific manner during system call entry, it is not generally available during system call exit.) The values are exported via new fields at the end of struct ptrace_lwpinfo available via PT_LWPINFO. Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D3536 Notes: svn path=/head/; revision=287386
* The PTRACESTOP() macro is used only once. Inline the only use and removeKonstantin Belousov2012-02-111-6/+0
| | | | | | | | | the macro. MFC after: 1 week Notes: svn path=/head/; revision=231521
* Mark the automatically attached child with PL_FLAG_CHILD in structKonstantin Belousov2012-02-101-0/+1
| | | | | | | | | | lwpinfo flags, for PT_FOLLOWFORK auto-attachment. In collaboration with: Dmitry Mikulin <dmitrym juniper net> MFC after: 1 week Notes: svn path=/head/; revision=231320
* Allow debugger to specify that children of the traced process should beKonstantin Belousov2011-01-251-0/+4
| | | | | | | | | | | automatically traced. Extend the ptrace(PL_LWPINFO) to report that child just forked. Reviewed by: davidxu, jhb MFC after: 2 weeks Notes: svn path=/head/; revision=217819
* Add the ability for GDB to printout the thread name along with otherAttilio Rao2010-11-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | | thread specific informations. In order to do that, and in order to avoid KBI breakage with existing infrastructure the following semantic is implemented: - For live programs, a new member to the PT_LWPINFO is added (pl_tdname) - For cores, a new ELF note is added (NT_THRMISC) that can be used for storing thread specific, miscellaneous, informations. Right now it is just popluated with a thread name. GDB, then, retrieves the correct informations from the corefile via the BFD interface, as it groks the ELF notes and create appropriate pseudo-sections. Sponsored by: Sandvine Incorporated Tested by: gianni Discussed with: dim, kan, kib MFC after: 2 weeks Notes: svn path=/head/; revision=215679
* Extend ptrace(PT_LWPINFO) to report siginfo for the signal that causedKonstantin Belousov2010-07-041-1/+3
| | | | | | | | | | debugee stop. The change should keep the ABI. Take care of compat32. Discussed with: davidxu, jhb MFC after: 2 weeks Notes: svn path=/head/; revision=209688
* Reorganize syscall entry and leave handling.Konstantin Belousov2010-05-231-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extend struct sysvec with three new elements: sv_fetch_syscall_args - the method to fetch syscall arguments from usermode into struct syscall_args. The structure is machine-depended (this might be reconsidered after all architectures are converted). sv_set_syscall_retval - the method to set a return value for usermode from the syscall. It is a generalization of cpu_set_syscall_retval(9) to allow ABIs to override the way to set a return value. sv_syscallnames - the table of syscall names. Use sv_set_syscall_retval in kern_sigsuspend() instead of hardcoding the call to cpu_set_syscall_retval(). The new functions syscallenter(9) and syscallret(9) are provided that use sv_*syscall* pointers and contain the common repeated code from the syscall() implementations for the architecture-specific syscall trap handlers. Syscallenter() fetches arguments, calls syscall implementation from ABI sysent table, and set up return frame. The end of syscall bookkeeping is done by syscallret(). Take advantage of single place for MI syscall handling code and implement ptrace_lwpinfo pl_flags PL_FLAG_SCE, PL_FLAG_SCX and PL_FLAG_EXEC. The SCE and SCX flags notify the debugger that the thread is stopped at syscall entry or return point respectively. The EXEC flag augments SCX and notifies debugger that the process address space was changed by one of exec(2)-family syscalls. The i386, amd64, sparc64, sun4v, powerpc and ia64 syscall()s are changed to use syscallenter()/syscallret(). MIPS and arm are not converted and use the mostly unchanged syscall() implementation. Reviewed by: jhb, marcel, marius, nwhitehorn, stas Tested by: marcel (ia64), marius (sparc64), nwhitehorn (powerpc), stas (mips) MFC after: 1 month Notes: svn path=/head/; revision=208453
* Provide groundwork for 32-bit binary compatibility on non-x86 platforms,Nathan Whitehorn2010-03-111-1/+2
| | | | | | | | | | | | for upcoming 64-bit PowerPC and MIPS support. This renames the COMPAT_IA32 option to COMPAT_FREEBSD32, removes some IA32-specific code from MI parts of the kernel and enhances the freebsd32 compatibility code to support big-endian platforms. Reviewed by: kib, jhb Notes: svn path=/head/; revision=205014
* o Add support for COMPAT_IA32.Marcel Moolenaar2010-02-111-7/+10
| | | | | | | | | | | | | o Incorporate review comments: - Properly reference and lock the map - Take into account that the VM map can change inbetween requests - Add the fileid and fsid attributes Credits: kib@ Reviewed by: kib@ Notes: svn path=/head/; revision=203783
* Add PT_VM_TIMESTAMP and PT_VM_ENTRY so that the tracing process canMarcel Moolenaar2010-02-091-0/+15
| | | | | | | | | | | obtain the memory map of the traced process. PT_VM_TIMESTAMP can be used to check if the memory map changed since the last time to avoid iterating over all the VM entries unnecesarily. MFC after: 1 month Notes: svn path=/head/; revision=203696
* Add members pl_sigmask and pl_siglist into ptrace_lwpinfo to get lwp'sDavid Xu2006-02-061-0/+4
| | | | | | | signal mask and pending signals. Notes: svn path=/head/; revision=155381
* Jumbo-commit to enhance 32 bit application support on 64 bit kernels.Peter Wemm2005-06-301-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is good enough to be able to run a RELENG_4 gdb binary against a RELENG_4 application, along with various other tools (eg: 4.x gcore). We use this at work. ia32_reg.[ch]: handle the 32 bit register file format, used by ptrace, procfs and core dumps. procfs_*regs.c: vary the format of proc/XXX/*regs depending on the client and target application. procfs_map.c: Don't print a 64 bit value to 32 bit consumers, or their sscanf fails. They expect an unsigned long. imgact_elf.c: produce a valid 32 bit coredump for 32 bit apps. sys_process.c: handle 32 bit consumers debugging 32 bit targets. Note that 64 bit consumers can still debug 32 bit targets. IA64 has got stubs for ia32_reg.c. Known limitations: a 5.x/6.x gdb uses get/setcontext(), which isn't implemented in the 32/64 wrapper yet. We also make a tiny patch to gdb pacify it over conflicting formats of ld-elf.so.1. Approved by: re Notes: svn path=/head/; revision=147692
* Add PROC_UNLOCK(p) to PTRACESTOP_SC(p, td, flag). This is necessaryColin Percival2005-04-291-0/+1
| | | | | | | | | | | due to a change made in revision 1.284 of sys/kern/kern_sig.c in August 2004 which made ptracestop() return with the process still locked. Submitted by: Mauritz Sundell MFC After: 3 days Notes: svn path=/head/; revision=145691
* Add pl_flags to ptrace_lwpinfo, two flags PL_FLAG_SA and PL_FLAG_BOUNDDavid Xu2004-08-081-0/+3
| | | | | | | | | | indicate that a thread is in UTS critical region. Reviewed by: deischen Approved by: marcel Notes: svn path=/head/; revision=133337
* Implement following commands: PT_CLEARSTEP, PT_SETSTEP, PT_SUSPENDDavid Xu2004-07-131-2/+8
| | | | | | | PT_RESUME, PT_GETNUMLWPS, PT_GETLWPLIST. Notes: svn path=/head/; revision=132089
* Implement the PT_LWPINFO request. This request can be used by theMarcel Moolenaar2004-07-121-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tracing process to obtain information about the LWP that caused the traced process to stop. Debuggers can use this information to select the thread currently running on the LWP as the current thread. The request has been made compatible with NetBSD for as much as possible. This implementation differs from NetBSD in the following ways: 1. The data argument is allowed to be smaller than the size of the ptrace_lwpinfo structure known to the kernel, but not 0. This is opposite to what NetBSD allows. The reason for this is that we can extend the structure without affecting older binaries. 2. On NetBSD the tracing process is to set the pl_lwpid field to the Id of the LWP it wants information of. We don't do that. Our ptrace interface allows passing the LWP Id instead of the PID. The tracing process is to set the PID to the LWP Id it wants information of. 3. When the PID is actually the PID of the tracing process, this request returns the information about the LWP that caused the process to stop. This was the whole purpose of the request in the first place. When the traced process has exited, this request will return the LWP Id 0, indicating that the process state is not the result of an event specific to a LWP. Notes: svn path=/head/; revision=132016
* Remove advertising clause from University of California Regent's license,Warner Losh2004-04-071-4/+0
| | | | | | | | | per letter dated July 22, 1999. Approved by: core Notes: svn path=/head/; revision=127976
* Implement preliminary support for the PT_SYSCALL command to ptrace(2).Robert Drehmel2003-10-091-0/+17
| | | | Notes: svn path=/head/; revision=120937
* Add or finish support for machine dependent ptrace requests. When weMarcel Moolenaar2003-08-151-0/+4
| | | | | | | | | | | | | | | | | | | | check for permissions, do it for all requests, not the known requests. Later when we actually service the request we deal with the invalid requests we previously caught earlier. This commit changes the behaviour of the ptrace(2) interface for boundary cases such as an unknown request without proper permissions. Previously we would return EINVAL. Now we return EBUSY or EPERM. Platforms need to define __HAVE_PTRACE_MACHDEP when they have MD requests. This makes the prototype of cpu_ptrace() visible and introduces a call to this function for all requests greater or equal to PT_FIRSTMACH. Silence on: audit Notes: svn path=/head/; revision=118932
* Implement PT_IO (read / write arbitrary amounts of data or text).Dag-Erling Smørgrav2002-03-161-0/+16
| | | | | | | | Submitted by: Artur Grabowski <art@{blahonga,openbsd}.org> Obtained from: OpenBSD Notes: svn path=/head/; revision=92395
* Move the definition of PT_[GS]ET{,DB,FP}REGS from the MD ptrace.h to theDag-Erling Smørgrav2002-03-161-1/+8
| | | | | | | | MI ptrace.h, since all platforms define them. Keep the MD ptrace.h around for FIX_SSTEP (which is currently only needed on Alpha). Notes: svn path=/head/; revision=92383
* Declare struct uio so consumers don't have to #include <sys/uio.h> unlessDag-Erling Smørgrav2001-11-031-0/+1
| | | | | | | they intend to call proc_rwmem(). Notes: svn path=/head/; revision=85941
* Move procfs_* from procfs_machdep.c into sys_process.c, and rename them toDag-Erling Smørgrav2001-10-211-7/+7
| | | | | | | | | proc_* in the process; procfs_machdep.c is no longer needed. Run-tested on i386, build-tested on Alpha, untested on other platforms. Notes: svn path=/head/; revision=85297
* Dissociate ptrace from procfs.Dag-Erling Smørgrav2001-10-071-3/+21
| | | | | | | | | | | | | | | | | | | | Until now, the ptrace syscall was implemented as a wrapper that called various functions in procfs depending on which ptrace operation was requested. Most of these functions were themselves wrappers around procfs_{read,write}_{,db,fp}regs(), with only some extra error checks, which weren't necessary in the ptrace case anyway. This commit moves procfs_rwmem() from procfs_mem.c into sys_process.c (renaming it to proc_rwmem() in the process), and implements ptrace() directly in terms of procfs_{read,write}_{,db,fp}regs() instead of having it fake up a struct uio and then call procfs_do{,db,fp}regs(). It also moves the prototypes for procfs_{read,write}_{,db,fp}regs() and proc_rwmem() from proc.h to ptrace.h, and marks all procfs files except procfs_machdep.c as "optional procfs" instead of "standard". Notes: svn path=/head/; revision=84637
* KSE Milestone 2Julian Elischer2001-09-121-2/+2
| | | | | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha Notes: svn path=/head/; revision=83366
* GC unused prototype of ptrace_write_u().John Baldwin2001-08-211-1/+0
| | | | | | | Forgotten by: peter Notes: svn path=/head/; revision=82060
* Zap 'ptrace(PT_READ_U, ...)' and 'ptrace(PT_WRITE_U, ...)' since theyPeter Wemm2001-08-081-2/+2
| | | | | | | | | | | | | | | are a really nasty interface that should have been killed long ago when 'ptrace(PT_[SG]ETREGS' etc came along. The entity that they operate on (struct user) will not be around much longer since it is part-per-process and part-per-thread in a post-KSE world. gdb does not actually use this except for the obscure 'info udot' command which does a hexdump of as much of the child's 'struct user' as it can get. It carries its own #defines so it doesn't break compiles. Notes: svn path=/head/; revision=81265
* - Move the prototype for proc_reparent from sys/ptrace.h to sys/proc.hJohn Baldwin2000-10-191-1/+0
| | | | | | | - Fix the sorting of function prototypes in sys/proc.h Notes: svn path=/head/; revision=67321
* Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL"Peter Wemm1999-12-291-3/+3
| | | | | | | | | is an application space macro and the applications are supposed to be free to use it as they please (but cannot). This is consistant with the other BSD's who made this change quite some time ago. More commits to come. Notes: svn path=/head/; revision=55205
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* This commit fixes various 64bit portability problems required forDoug Rabson1998-06-071-3/+3
| | | | | | | | | | | | | FreeBSD/alpha. The most significant item is to change the command argument to ioctl functions from int to u_long. This change brings us inline with various other BSD versions. Driver writers may like to use (__FreeBSD_version == 300003) to detect this change. The prototype FreeBSD/alpha machdep will follow in a couple of days time. Notes: svn path=/head/; revision=36735
* Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are notPeter Wemm1997-02-221-1/+1
| | | | | | | ready for it yet. Notes: svn path=/head/; revision=22975
* Make the long-awaited change from $Id$ to $FreeBSD$Jordan K. Hubbard1997-01-141-1/+1
| | | | | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise. Notes: svn path=/head/; revision=21673
* proc.h: Add PHOLD()/PRELE() macros to ensure the U area is not swappedPeter Wemm1996-01-241-3/+1
| | | | | | | | while doing ptrace/procfs in it. ptrace.h: uncomment PT_ATTACH/PT_DETACH, I am committing code to do this. Notes: svn path=/head/; revision=13606
* Add and move declarations to fix all of the warnings from `gcc -Wimplicit'Bruce Evans1995-03-161-1/+4
| | | | | | | | | (except in netccitt, netiso and netns) and most of the warnings from `gcc -Wnested-externs'. Fix all the bugs found. There were no serious ones. Notes: svn path=/head/; revision=7090
* Process tracing code. Written by Sean Eric Fagan.David Greenman1994-08-081-1/+4
| | | | | | | Submitted by: Sean Eric Fagan Notes: svn path=/head/; revision=1945
* Added $Id$David Greenman1994-08-021-0/+1
| | | | Notes: svn path=/head/; revision=1817
* BSD 4.4 Lite Kernel SourcesRodney W. Grimes1994-05-241-0/+67
Notes: svn path=/head/; revision=1541