1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
|
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Copyright (c) 1993 Michael Haardt
.\" (michael@moria.de),
.\" Fri Apr 2 11:32:09 MET DST 1993
.\"
.\" changes Copyright 1999 Mike Coleman (mkc@acm.org)
.\" -- major revision to fully document ptrace semantics per recent Linux
.\" kernel (2.2.10) and glibc (2.1.2)
.\" Sun Nov 7 03:18:35 CST 1999
.\"
.\" This is free documentation; 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 2 of
.\" the License, or (at your option) any later version.
.\"
.\" The GNU General Public License's references to "object code"
.\" and "executables" are to be interpreted as the output of any
.\" document formatting or typesetting system, including
.\" intermediate and printed output.
.\"
.\" This manual 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 this manual; if not, write to the Free
.\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
.\" USA.
.\"
.\" Modified Fri Jul 23 23:47:18 1993 by Rik Faith <faith@cs.unc.edu>
.\" Modified Fri Jan 31 16:46:30 1997 by Eric S. Raymond <esr@thyrsus.com>
.\" Modified Thu Oct 7 17:28:49 1999 by Andries Brouwer <aeb@cwi.nl>
.\" Modified, 27 May 2004, Michael Kerrisk <mtk-manpages@gmx.net>
.\" Added notes on capability requirements
.\"
.\" Japanese Version Copyright (c) 1997-1999 HANATAKA Shinya
.\" all rights reserved.
.\" Translated Sat Nov 20 17:40:55 JST 1999
.\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated Sat Oct 11 JST 2003 by Kentaro Shirakata <argrath@ub32.org>
.\"
.\"WORD: child process ҥץ
.\"WORD: parent process ƥץ
.\"WORD: core image ꡦ
.\"WORD: break point ֥졼ݥ
.\"WORD: single step 롦ƥå¹
.\"WORD: trap flag ȥåסե饰
.\"WORD: attach ³
.\"WORD: detach ʬΥ
.\"WORD: process ID ץID
.\"
.TH PTRACE 2 2004-05-27 "Linux 2.6.6" "Linux Programmer's Manual"
.SH ̾
ptrace \- ץΥȥ졼
.SH
.B #include <sys/ptrace.h>
.sp
.BI "long ptrace(enum __ptrace_request " request ", pid_t " pid ", void *" addr ", void *" data );
.SH
.B ptrace
ƥॳϿƥץ (parent process) ̤Υץ
¹Ԥƻ뤷椷ꡢ (core image) 쥸
Ĵ٤ѹꤹʤ롣
.B ptrace
ϼ˥֥졼ݥȤˤǥХå䥷ƥॳΥȥ졼
ΤѤ롣
.LP
ȥ졼Ϥˤϡޤƥץ
.BR fork (2)
ƤӽФ줿ҥץ PTRACE_TRACEME Ԥʤ
³ (ŵŪˤ)
.BR exec (3)
Ԥʤ
̤ˡȤƤϡ
ƥץ¸ΥץФ PTRACE_ATTACH Ѥ
ȥ졼Ϥ롣
.LP
ȥ졼μ¹桢ҥץϥʥ뤬뤿Ӥˡ
ȤΥʥ뤬̵뤹٤ΤǤäƤߤ롣
(SIGKILL 㳰ǡ̾ɤθ̤⤿餹)
ƥץˤϼ
.BR wait (2)
Τ졢ߤƤ֤˻ҥץĴ٤꽤ꤹ뤳ȤǤ롣
ƿƥץϻҥץμ¹ԤƳ뤬줿
ʥ̵뤹뤳ȤǤ (뤤̤Υʥ
뤳ȤǤ)
.LP
ƥץȥ졼λݤˤϡ
PTRACE_KILL Ѥƻҥץ뤳ȤǤ뤷
PTRACE_DETACH Ѥ̾Ρȥ졼ʤΥ⡼ɤˤ
¹Ԥ³뤳ȤǤ롣
.LP
\fIrequest\fP ͤΥƥॳưꤹ:
.TP
PTRACE_TRACEME
Υץƥץˤäƥȥ졼뤳Ȥɽ
Υץ(SIGKILL )ʥ뤬ȡץ
ߤƥץ
.BR wait
̤Τ롣
ޤʸ夳Υץ
.B exec
ƤӽФ SIGTRAP 롣
ˤäơƥץ
ץब¹ԤϤ椹뤳ȤǤ롣
ƥץȥ졼ĤǤʤˤϡ
餯ץϤԤʤäƤϤʤʤ
(\fIpid\fP, \fIaddr\fP, \fIdata\fP ̵뤵롣)
.LP
嵭ϻҥץԤʤΤǤ롣
ĤϿƥץԤʤΤǤ롣
ʲǤϡ\fIpid\fP оݤȤʤ
ҥץꤹ롣
PTRACE_KILL Ԥʤˤ
ҥץߤƤʤФʤʤ
.TP
PTRACE_PEEKTEXT, PTRACE_PEEKDATA
ҥץΥ
.I addr
ΰ֤ 1 ɤɤ߽Фɤ߽Фɤ
.B ptrace
֤ͤȤ֤롣 Linux Ǥϥƥ (text) ȥǡ (data)
Ʊɥ쥹֤Ѥ뤿ᡢ 2 ĤϸߤΤȤ
ƱΤǤ롣 ( \fIdata\fP ̵뤵롣)
.TP
PTRACE_PEEKUSR
ҥץ
.B USER
ΰΥեå
.I addr
ΰ֤ 1 ɤɤ߹ࡣUSER ΰˤϤΥץ
쥸 (registers) ʤɤξݻƤ롣(<linux/user.h> <sys/user.h>
)ɤ߹ɤ
.B ptrace
η̤Ȥ֤롣
̾եåȤϥɶˤʤФʤʤ
ƥˤäƤɬפʤ
(\fIdata\fP ̵뤵롣 )
.TP
PTRACE_POKETEXT, PTRACE_POKEDATA
.IR data
ҥץΥ
.IR addr
ΰ֤إԡ롣ƱͤˡߤΤȤĤ
ƱΤǤ롣
.TP
PTRACE_POKEUSR
.I data
ҥץ
.B USER
ΰΥեå
.I addr
ΰ֤˥ԡ롣
Ʊͤˡ̾եåȤϥɶˤʤФʤʤ
ͥδ (integrity) ݻ뤿ᡢ
ѹƤˤäƤ
.B USER
ΰѹ϶ػߤƤ롣
.TP
PTRACE_GETREGS, PTRACE_GETFPREGS
줾졢ҥץѥ쥸ư쥸ƥץ
\fIdata\fP ΰ֤˥ԡ롣 data ν˴ؤƤ
<linux/user.h> Ȥ뤳ȡ(\fIaddr\fP ̵뤵롣)
.TP
PTRACE_SETREGS, PTRACE_SETFPREGS
줾졢ҥץѥ쥸ư쥸
ƥץ \fIdate\fP ΰ֤饳ԡ롣
PTRACE_POKEUSER Ʊͤˡѥ쥸ˤäƤ
ѹػߤƤ礬롣 (\fIaddr\fP ̵뤵롣)
.TP
PTRACE_CONT
ߤҥץμ¹ԤƳ롣⤷ \fIdata\fP Ǥʤ
SIGSTOP Ǥʤлҥץ륷ʥȲᤵ롣
SIGSTOP ξϥʥʤ
Ȥȡ㤨Сƥץ
ҥץ줿ʥºݤ뤫ɤ
椹뤳ȤǤ롣(\fIaddr\fP ̵뤵롣)
.TP
PTRACE_SYSCALL, PTRACE_SINGLESTEP
PTRACE_CONT ƱͤߤҥץƳ롣
PTRACE_SYSCALL ξϻҥץ
˥ƥॳ뤫ƥॳ뤫ȴ뤫ˡ
PTRACE_SINGLESTEP ξ 1 ̿ (instruction) ¹ԤȤ
ߤ褦ˤ롣
(̾ɤꡢҥץϥʥäˤߤ롣)
ƥץ鸫ȡҥץ SIGTRAP
ߤ褦˸롣Τᡢ㤨 PTRACE_SYSCALL Ȥȡ
1ܤߤǰĴ٤ PTRACE_SYSCALL ¹Ԥ
2ܤߤǥƥॳ֤ͤĴ٤롢
Ȥ褦ʤȤǤ롣(\fIaddr\fP ̵뤵롣)
.TP
PTRACE_KILL
ҥץ SIGKILL 꽪λ롣(\fIaddr\fP \fIdata\fP
̵뤵롣)
.TP
PTRACE_ATTACH
.I pid
ǻꤵ줿ץ³ (attach) ߤΥץ
ҥץȤƥȥ졼Ǥ褦ˤ롣ҥץ PTRACE_TRACEME
Τ褦˿ߤΥץϤΤۤȤɤŪˤơ
λҥץμºݤοƤˤʤ롣(㤨лҥץΥ٥Ȥ
ΤȤäꡢ
.BR ps (1)
ǿƤȤɽ줿ꤹ롣) ҥץ
.BR getppid (2)
¹Ԥˤϸοƥץ PID ֤롣
ҥץˤ SIGSTOP 뤬θƤӽФλޤǤ
ɬߤȤϸ¤ʤҥץߤԤĤˤ
.BR wait
Ѥ뤳ȡ(\fIaddr\fP \fIdata\fP ̵뤵롣)
.TP
PTRACE_DETACH
PTRACE_CONT ƱͤߤҥץƳ롣
ޤΥץʬΥ (detach) Ԥʤ
PTRACE_ATTACH ǤοƤڤ괹ˤ̤
PTRACE_TRACEME θ̤äտޤΤǤϤʤ
Linux Ǥϡȥ졼ƤҥץϤɤΤ褦ˡǥȥ졼
Ϥ줿ȤƤ⡢ˡʬΥ (detach) 뤳ȤǤ롣
(\fIaddr\fP ̵뤵롣)
.SH
.B ptrace
ΰϾΤ褦ʥץȥפ˴ŤƲᤵ뤬
GNU libc ǤϸߤΤȤ
.B ptrace
\fIrequest\fP βѰδؿȤƤ롣
ɬפʤлĤΰϾάǽǤ뤳Ȥ̣뤬
.BR gcc (1)
ʸƤʤưѤƤ뤳Ȥˤʤ롣
.LP
.BR init (8)
ʤ PID 1 Υץϥȥ졼뤳ȤǤʤ
.LP
USER ΰƤ֤ OS ȡƥ㤴Ȥ
ͭǤ롣
.LP
֥ (word) פ礭 OS ˤäƷޤ롣
(㤨С32 ӥåȤ Linux Ǥ 32 ӥåȤǤ롢ʤɡ)
.LP
ȥ졼뤳Ȥˤäƥȥ졼ץư˺٤ʰ㤤
뤳Ȥ롣㤨Сץ PTRACE_ATTACH ˤä³줿
ˤϡΥץߤǤοƤ
.BR wait
ȤäΤ뤳ȤǤʤƤΨ褯
Τˡʤ
.LP
Υޥ˥奢ϸߤ Linux ˤ
.B ptrace
ưˤĤƵҤƤ롣¾ Unix Ǥ
ưۤʤ롣
ʤ
.B ptrace
Ȥ OS 䥢ƥ˰¸Τˤʤ롣
.LP
SunOS Υޥ˥奢롦ڡˤ
.B ptrace
ϡäԲIJפȵҤƤꡢޤǤ롣
Solaris 2 Ǥ proc ١
ǥХåΥեȤ
.B ptrace
ξ̸ߴؿ졢궯ϤǰΤΤȤʤäƤ롣
.SH ֤
硢PTRACE_PEEK*ˤĤƤᤷǡ֤
ʳˤĤƤ 0 ֤
顼ξ \-1 ֤
.IR errno (3)
Ŭڤꤵ롣
PTRACE_PEEK* ֤ͤ⡡\-1 ˤʤ뤳Ȥ뤿ᡢ
Τ褦ξ硢ƤӽФ
.I errno
Ĵ١顼ȯΤɤȽǤʤФʤʤ
.SH 顼
.TP
.B EBUSY
(i386 Τ) ǥХå쥸γݤޤϲǥ顼ȯ
.TP
.B EFAULT
ƥץޤϻҥץΥΰɤ߽褦Ȥ
餯ΰ褬ޥåԥƤʤ
ΰؤΥƤʤǤ롣
ԱʤȤˡLinuxǤϤΤ褦ʥեȤξ
¿쾯ʤŪ EIO ֤ EFAULT ֤ꤹ롣
.TP
.B EIO
\fIrequest\fP Ǥ롣
ޤϡƥץޤϻҥץΥ
ΰɤ߽褦Ȥ
ޤϡɶȿä
ޤϡ¹ԺƳʥʥꤷ
.TP
.B EPERM
ꤷץȥ졼뤳ȤǤʤϿƥץ
ɬפʸ (ɬפʥѥӥƥ
.BR CAP_SYS_PTRACE )
äƤʤȤξ礬롣
ʬ䤹ͳʤ顢
롼ȤǤʤץϥʥʤץϥȥ졼Ǥʤ
setuid/setgid ץ¹ԤƤץϥȥ졼Ǥʤ
뤤ϡץϤǤ˥ȥ졼Ǥ롢
ޤ
.BR init (8)
ץ (pid 1) Ǥ롣
.TP
.B ESRCH
ꤷץ¸ߤʤ
ޤϡꤷץϸƤӽФץ
ߥȥ졼ƤҥץǤϤʤ
ޤϡꤷץߤƤʤ (ߤƤ뤳Ȥɬפξ)
.SH
SVr4, SVID EXT, AT&T, X/OPEN, BSD 4.3
.SH Ϣ
.BR gdb (1),
.BR strace (1),
.BR execve (2),
.BR fork (2),
.BR signal (2),
.BR wait (2),
.BR exec (3),
.BR capabilities (7)
|