⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ptrace.2

📁 UNIX v6源代码 这几乎是最经典的unix版本 unix操作系统设计和莱昂氏unix源代码分析都是用的该版
💻 2
字号:
.th PTRACE II 1/25/75.sh NAMEptrace  \*-  process trace.sh SYNOPSIS.nf(ptrace = 26.; not in assembler)(data in r0).ft Bsys	ptrace; pid; addr; request.ft R.br(value in r0).ft B.s3ptrace(request, pid, addr, data);.ft R.fi.sh DESCRIPTION.it Ptraceprovides a means by which a parent processmay control the execution of a child process,and examine and change its core image.Its primary use is for the implementation of breakpoint debugging,but it should be adaptable for simulation of non-UNIX environments.There are four arguments whose interpretationdepends on a.it requestargument.Generally,.it pidis the process ID of the traced process,which must be a child (no more distant descendant)of the tracing process.A process being tracedbehaves normally until it encounters some signal whether internally generatedlike ``illegal instruction'' or externally generated like ``interrupt.''See signal (II) for the list.Then the traced process enters a stopped stateand its parent is notified via.it wait(II).When the child is in the stopped state,its core image can be examined and modifiedusing.it ptrace.If desired, another.it ptracerequest can then cause the child either to terminateor to continue, possibly ignoring the signal..s3The value of the.it requestargument determines the preciseaction of the call:.s3.lp +4 40	This request is the only one used by the child process;it declares that the process is to be traced by its parent.All the other arguments are ignored.Peculiar results will ensueif the parent does not expect to trace the child..s3.lp +4 41,2	Theword in the child process's address spaceat.it addris returned (in r0).Request 1 indicates the data space (normally used);2 indicates the instruction space (when I and D space are separated)..it addrmust be even.The child must be stopped.The input.it datais ignored..s3.lp +4 43	The wordof the system's per-process data area corresponding to.it addris returned..it Addrmust be even and less than 512.This space contains the registers and other information aboutthe process;its layout corresponds to the.it userstructure in the system..s3.lp +4 44,5	Thegiven.it datais written at the word in the process's address space corresponding to.it addr,which must be even.No useful value is returned.Request 4 specifies data space (normally used), 5 specifiesinstruction space.Attempts to write in pure procedure result in termination of thechild, instead of going through or causing an error for the parent..s3.lp +4 46	The process's system data is written,as it is read with request 3.Only a few locations can be written in this way:the general registers,the floating point status and registers,and certain bits of the processor status word..s3.lp +4 47	The.it dataargument is taken as a signal numberand the child's execution continuesas if it had incurred that signal.Normally the signal number will beeither 0 to indicate that the signal which caused the stopshould be ignored,or that value fetched out of theprocess's image indicating which signal causedthe stop..s3.lp +4 48	The traced process terminates..s3.i0As indicated,these calls(except for request 0)can be used only when the subject process has stopped.The.it waitcall is used to determinewhen a process stops;in such a case the ``termination'' statusreturned by.it waithas the value 0177 to indicate stoppage ratherthan genuine termination..s3To forestall possible fraud,.it ptraceinhibits the set-user-id facilityon subsequent.it exec(II) calls..sh "SEE ALSO"wait (II), signal (II), cdb (I).sh DIAGNOSTICSFrom assembler, the c-bit (error bit) is set on errors;from C, \-1 is returned and.it errnohas the error code..sh BUGSThe request 0 call should be able to specifysignals which are to be treated normally and not cause a stop.In this way, for example,programs with simulated floating point (whichuse ``illegal instruction'' signals at a very high rate)could be efficiently debugged..s3Also, it should be possible to stop a process on occurrence of a systemcall;in this way a completely controlled environment couldbe provided.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -