1 /* Machine independent support for SVR4 /proc (process file system) for GDB.
2 Copyright 1999 Free Software Foundation, Inc.
3 Written by Michael Snyder at Cygnus Solutions.
4 Based on work by Fred Fish, Stu Grossman, Geoff Noer, and others.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software Foundation,
20 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 * Pretty-print trace of api calls to the /proc api
24 * (ioctl or read/write calls).
31 #if defined (NEW_PROC_API)
32 #define _STRUCTURED_PROC 1
36 #include <sys/types.h>
37 #include <sys/procfs.h>
38 #include <sys/proc.h> /* for struct proc */
39 #include <sys/user.h> /* for struct user */
40 #include <fcntl.h> /* for O_RDWR etc. */
43 #include "proc-utils.h"
45 /* Much of the information used in the /proc interface, particularly for
46 printing status information, is kept as tables of structures of the
47 following form. These tables can be used to map numeric values to
48 their symbolic names and to a string that describes their specific use. */
51 long value
; /* The numeric value */
52 char *name
; /* The equivalent symbolic value */
53 char *desc
; /* Short description of value */
56 static int procfs_trace
= 1;
57 /*static int info_verbose = 1;*/ /* kludge */
58 static FILE *procfs_file
= NULL
;
59 static char *procfs_filename
= "procfs_trace";
62 set_procfs_trace_cmd (args
, from_tty
, c
)
65 struct cmd_list_element
*c
;
67 #if 0 /* not sure what I might actually need to do here, if anything */
74 set_procfs_file_cmd (args
, from_tty
, c
)
77 struct cmd_list_element
*c
;
79 /* Just changed the filename for procfs tracing.
80 If a file was already open, close it. */
89 static struct trans ioctl_table
[] = {
90 #ifdef PIOCACINFO /* irix */
91 { PIOCACINFO
, "PIOCACINFO", "get process account info" },
93 { PIOCACTION
, "PIOCACTION", "get signal action structs" },
94 #ifdef PIOCARGUMENTS /* osf */
95 { PIOCARGUMENTS
, "PIOCARGUMENTS", "command line args" },
97 #ifdef PIOCAUXV /* solaris aux vectors */
98 { PIOCAUXV
, "PIOCAUXV", "get aux vector" },
99 { PIOCNAUXV
, "PIOCNAUXV", "get number of aux vector entries" },
101 { PIOCCFAULT
, "PIOCCFAULT", "clear current fault" },
102 { PIOCCRED
, "PIOCCRED", "get process credentials" },
103 #ifdef PIOCENEVCTRS /* irix event counters */
104 { PIOCENEVCTRS
, "PIOCENEVCTRS", "acquire and start event counters" },
105 { PIOCGETEVCTRL
, "PIOCGETEVCTRL", "get control info of event counters" },
106 { PIOCGETEVCTRS
, "PIOCGETEVCTRS", "dump event counters" },
107 { PIOCGETPREVCTRS
, "PIOCGETPREVCTRS", "dump event counters & prusage info" },
108 { PIOCRELEVCTRS
, "PIOCRELEVCTRS", "release/stop event counters" },
109 { PIOCSETEVCTRL
, "PIOCSETEVCTRL", "set control info of event counters" },
110 { PIOCGETPTIMER
, "PIOCGETPTIMER", "get process timers" },
111 #endif /* irix event counters */
112 { PIOCGENTRY
, "PIOCGENTRY", "get traced syscall entry set" },
113 { PIOCGETPR
, "PIOCGETPR", "read struct proc" },
114 { PIOCGETU
, "PIOCGETU", "read user area" },
115 #if defined (PIOCGETUTK) && (defined(KERNEL) || defined(SHOW_UTT)) /* osf */
116 { PIOCGETUTK
, "PIOCGETUTK", "get the utask struct" },
118 { PIOCGEXIT
, "PIOCGEXIT", "get traced syscall exit set" },
119 { PIOCGFAULT
, "PIOCGFAULT", "get traced fault set" },
120 #ifdef PIOCGFPCR /* osf */
121 { PIOCGFPCR
, "PIOCGFPCR", "get FP control register" },
122 { PIOCSFPCR
, "PIOCSFPCR", "set FP conrtol register" },
124 { PIOCGFPREG
, "PIOCGFPREG", "get floating point registers" },
125 { PIOCGHOLD
, "PIOCGHOLD", "get held signal set" },
126 { PIOCGREG
, "PIOCGREG", "get general registers" },
127 { PIOCGROUPS
, "PIOCGROUPS", "get supplementary groups" },
128 #ifdef PIOCGSPCACT /* osf */
129 { PIOCGSPCACT
, "PIOCGSPCACT", "get special action" },
130 { PIOCSSPCACT
, "PIOCSSPCACT", "set special action" },
132 { PIOCGTRACE
, "PIOCGTRACE", "get traced signal set" },
133 #ifdef PIOCGWATCH /* irix watchpoints */
134 { PIOCGWATCH
, "PIOCGWATCH", "get watchpoint" },
135 { PIOCSWATCH
, "PIOCSWATCH", "set watchpoint" },
136 { PIOCNWATCH
, "PIOCNWATCH", "get number of watchpoints" },
137 #endif /* irix watchpoints */
138 #ifdef PIOCGWIN /* solaris sparc */
139 { PIOCGWIN
, "PIOCGWIN", "get gwindows_t" },
141 #ifdef PIOCGXREG /* solaris sparc extra regs */
142 { PIOCGXREGSIZE
, "PIOCXREGSIZE", "get extra register state size" },
143 { PIOCGXREG
, "PIOCGXREG", "get extra register state" },
144 { PIOCSXREG
, "PIOCSXREG", "set extra register state" },
146 { PIOCKILL
, "PIOCKILL", "send signal" },
147 #ifdef PIOCLDT /* solaris i386 */
148 { PIOCLDT
, "PIOCLDT", "get LDT" },
149 { PIOCNLDT
, "PIOCNLDT", "get number of LDT entries" },
151 #ifdef PIOCLSTATUS /* solaris and unixware */
152 { PIOCLSTATUS
, "PIOCLSTATUS", "get status of all lwps" },
153 { PIOCLUSAGE
, "PIOCLUSAGE", "get resource usage of all lwps" },
154 { PIOCOPENLWP
, "PIOCOPENLWP", "get lwp file descriptor" },
155 { PIOCLWPIDS
, "PIOCLWPIDS", "get lwp identifiers" },
157 { PIOCMAP
, "PIOCMAP", "get memory map information" },
158 { PIOCMAXSIG
, "PIOCMAXSIG", "get max signal number" },
159 { PIOCNICE
, "PIOCNICE", "set nice priority" },
160 { PIOCNMAP
, "PIOCNMAP", "get number of memory mappings" },
161 { PIOCOPENM
, "PIOCOPENM", "open mapped object for reading" },
162 #ifdef PIOCOPENMOBS /* osf */
163 { PIOCOPENMOBS
, "PIOCOPENMOBS", "open mapped object" },
165 #ifdef PIOCOPENPD /* solaris */
166 { PIOCOPENPD
, "PIOCOPENPD", "get page data file descriptor" },
168 { PIOCPSINFO
, "PIOCPSINFO", "get ps(1) information" },
169 { PIOCRESET
, "PIOCRESET", "reset process flags" },
170 { PIOCRFORK
, "PIOCRFORK", "reset inherit-on-fork flag" },
171 { PIOCRRLC
, "PIOCRRLC", "reset run-on-last-close flag" },
172 { PIOCRUN
, "PIOCRUN", "make process runnable" },
173 #ifdef PIOCSAVECCNTRS /* irix */
174 { PIOCSAVECCNTRS
, "PIOCSAVECCNTRS", "parent gets child cntrs" },
176 { PIOCSENTRY
, "PIOCSENTRY", "set traced syscall entry set" },
177 { PIOCSET
, "PIOCSET", "set process flags" },
178 { PIOCSEXIT
, "PIOCSEXIT", "set traced syscall exit set" },
179 { PIOCSFAULT
, "PIOCSFAULT", "set traced fault set" },
180 { PIOCSFORK
, "PIOCSFORK", "set inherit-on-fork flag" },
181 { PIOCSFPREG
, "PIOCSFPREG", "set floating point registers" },
182 { PIOCSHOLD
, "PIOCSHOLD", "set held signal set" },
183 { PIOCSREG
, "PIOCSREG", "set general registers" },
184 { PIOCSRLC
, "PIOCSRLC", "set run-on-last-close flag" },
185 { PIOCSSIG
, "PIOCSSIG", "set current signal" },
186 { PIOCSTATUS
, "PIOCSTATUS", "get process status" },
187 { PIOCSTOP
, "PIOCSTOP", "post stop request" },
188 { PIOCSTRACE
, "PIOCSTRACE", "set traced signal set" },
189 { PIOCUNKILL
, "PIOCUNKILL", "delete a signal" },
190 #ifdef PIOCUSAGE /* solaris */
191 { PIOCUSAGE
, "PIOCUSAGE", "get resource usage" },
193 { PIOCWSTOP
, "PIOCWSTOP", "wait for process to stop" },
195 #ifdef PIOCNTHR /* osf threads */
196 { PIOCNTHR
, "PIOCNTHR", "get thread count" },
197 { PIOCRTINH
, "PIOCRTINH", "reset inherit-on-thread-creation" },
198 { PIOCSTINH
, "PIOCSTINH", "set inherit-on-thread-creation" },
199 { PIOCTLIST
, "PIOCTLIST", "get thread ids" },
200 { PIOCXPTH
, "PIOCXPTH", "translate port to thread handle" },
201 { PIOCTRUN
, "PIOCTRUN", "make thread runnable" },
202 { PIOCTSTATUS
, "PIOCTSTATUS", "get thread status" },
203 { PIOCTSTOP
, "PIOCTSTOP", "stop a thread" },
204 /* ... TGTRACE TSTRACE TSSIG TKILL TUNKILL TCFAULT TGFAULT TSFAULT
205 TGFPREG TSFPREG TGREG TSREG TACTION TTERM TABRUN TGENTRY TSENTRY
206 TGEXIT TSEXIT TSHOLD ... thread functions */
207 #endif /* osf threads */
212 ioctl_with_trace (fd
, opcode
, ptr
, file
, line
)
223 if (procfs_file
== NULL
&& procfs_filename
!= NULL
)
224 procfs_file
= fopen (procfs_filename
, "a");
226 for (i
= 0; ioctl_table
[i
].name
!= NULL
; i
++)
227 if (ioctl_table
[i
].value
== opcode
)
231 fprintf (procfs_file
? procfs_file
: stdout
,
232 "%s:%d -- ", file
, line
);
235 arg1
= ptr
? *(long *) ptr
: 0;
236 fprintf (procfs_file
? procfs_file
: stdout
,
237 "ioctl (PIOCSET, %s) %s\n",
238 arg1
== PR_FORK
? "PR_FORK" :
239 arg1
== PR_RLC
? "PR_RLC" :
241 arg1
== PR_ASYNC
? "PR_ASYNC" :
244 info_verbose
? ioctl_table
[i
].desc
: "");
247 arg1
= ptr
? *(long *) ptr
: 0;
248 fprintf (procfs_file
? procfs_file
: stdout
,
249 "ioctl (PIOCRESET, %s) %s\n",
250 arg1
== PR_FORK
? "PR_FORK" :
251 arg1
== PR_RLC
? "PR_RLC" :
253 arg1
== PR_ASYNC
? "PR_ASYNC" :
256 info_verbose
? ioctl_table
[i
].desc
: "");
259 fprintf (procfs_file
? procfs_file
: stdout
,
260 "ioctl (PIOCSTRACE) ");
261 proc_prettyfprint_signalset (procfs_file
? procfs_file
: stdout
,
262 (sigset_t
*) ptr
, 0);
265 fprintf (procfs_file
? procfs_file
: stdout
,
267 opcode
== PIOCSFAULT
? "PIOCSFAULT" : "PIOCGFAULT");
268 proc_prettyfprint_faultset (procfs_file
? procfs_file
: stdout
,
269 (fltset_t
*) ptr
, 0);
272 fprintf (procfs_file
? procfs_file
: stdout
,
274 opcode
== PIOCSENTRY
? "PIOCSENTRY" : "PIOCGENTRY");
275 proc_prettyfprint_syscalls (procfs_file
? procfs_file
: stdout
,
276 (sysset_t
*) ptr
, 0);
279 fprintf (procfs_file
? procfs_file
: stdout
,
281 opcode
== PIOCSEXIT
? "PIOCSEXIT" : "PIOCGEXIT");
282 proc_prettyfprint_syscalls (procfs_file
? procfs_file
: stdout
,
283 (sysset_t
*) ptr
, 0);
286 fprintf (procfs_file
? procfs_file
: stdout
,
288 opcode
== PIOCSHOLD
? "PIOCSHOLD" : "PIOCGHOLD");
289 proc_prettyfprint_signalset (procfs_file
? procfs_file
: stdout
,
290 (sigset_t
*) ptr
, 0);
293 fprintf (procfs_file
? procfs_file
: stdout
,
294 "ioctl (PIOCSSIG) ");
295 proc_prettyfprint_signal (procfs_file
? procfs_file
: stdout
,
296 ptr
? ((siginfo_t
*) ptr
)->si_signo
: 0,
298 fprintf (procfs_file
? procfs_file
: stdout
, "\n");
301 fprintf (procfs_file
? procfs_file
: stdout
,
304 arg1
= ptr
? *(long *) ptr
: 0;
306 fprintf (procfs_file
? procfs_file
: stdout
, "clearSig ");
308 fprintf (procfs_file
? procfs_file
: stdout
, "clearFlt ");
310 fprintf (procfs_file
? procfs_file
: stdout
, "setTrace ");
312 fprintf (procfs_file
? procfs_file
: stdout
, "setHold ");
314 fprintf (procfs_file
? procfs_file
: stdout
, "setFlt ");
316 fprintf (procfs_file
? procfs_file
: stdout
, "setVaddr ");
318 fprintf (procfs_file
? procfs_file
: stdout
, "step ");
320 fprintf (procfs_file
? procfs_file
: stdout
, "syscallAbort ");
322 fprintf (procfs_file
? procfs_file
: stdout
, "stopReq ");
324 fprintf (procfs_file
? procfs_file
: stdout
, "\n");
327 fprintf (procfs_file
? procfs_file
: stdout
,
328 "ioctl (PIOCKILL) ");
329 proc_prettyfprint_signal (procfs_file
? procfs_file
: stdout
,
330 ptr
? *(long *) ptr
: 0, 0);
331 fprintf (procfs_file
? procfs_file
: stdout
, "\n");
335 fprintf (procfs_file
? procfs_file
: stdout
,
336 "ioctl (PIOCSSPCACT) ");
337 arg1
= ptr
? *(long *) ptr
: 0;
338 if (arg1
& PRFS_STOPFORK
)
339 fprintf (procfs_file
? procfs_file
: stdout
, "stopFork ");
340 if (arg1
& PRFS_STOPEXEC
)
341 fprintf (procfs_file
? procfs_file
: stdout
, "stopExec ");
342 if (arg1
& PRFS_STOPTERM
)
343 fprintf (procfs_file
? procfs_file
: stdout
, "stopTerm ");
344 if (arg1
& PRFS_STOPTCR
)
345 fprintf (procfs_file
? procfs_file
: stdout
, "stopThreadCreate ");
346 if (arg1
& PRFS_STOPTTERM
)
347 fprintf (procfs_file
? procfs_file
: stdout
, "stopThreadTerm ");
348 if (arg1
& PRFS_KOLC
)
349 fprintf (procfs_file
? procfs_file
: stdout
, "killOnLastClose ");
350 fprintf (procfs_file
? procfs_file
: stdout
, "\n");
352 #endif /* PIOCSSPCACT */
354 if (ioctl_table
[i
].name
)
355 fprintf (procfs_file
? procfs_file
: stdout
,
358 info_verbose
? ioctl_table
[i
].desc
: "");
360 fprintf (procfs_file
? procfs_file
: stdout
,
361 "ioctl (<unknown %ld (0x%lx)) \n", opcode
, opcode
);
365 fflush (procfs_file
);
367 ret
= ioctl (fd
, opcode
, ptr
);
368 if (procfs_trace
&& ret
< 0)
370 fprintf (procfs_file
? procfs_file
: stdout
,
371 "[ioctl (%s) FAILED!]\n",
372 ioctl_table
[i
].name
!= NULL
?
373 ioctl_table
[i
].name
: "<unknown>");
375 fflush (procfs_file
);
381 #else /* NEW_PROC_API */
383 static struct trans rw_table
[] = {
384 #ifdef PCAGENT /* solaris */
385 { PCAGENT
, "PCAGENT", "create agent lwp with regs from argument" },
387 { PCCFAULT
, "PCCFAULT", "clear current fault" },
388 #ifdef PCCSIG /* solaris */
389 { PCCSIG
, "PCCSIG", "clear current signal" },
391 { PCDSTOP
, "PCDSTOP", "post stop request" },
392 { PCKILL
, "PCKILL", "post a signal" },
393 { PCNICE
, "PCNICE", "set nice priority" },
394 #ifdef PCREAD /* solaris */
395 { PCREAD
, "PCREAD", "read from the address space" },
396 { PCWRITE
, "PCWRITE", "write to the address space" },
398 #ifdef PCRESET /* unixware */
399 { PCRESET
, "PCRESET", "unset modes" },
401 { PCRUN
, "PCRUN", "make process/lwp runnable" },
402 #ifdef PCSASRS /* solaris 2.7 only */
403 { PCSASRS
, "PCSASRS", "set ancillary state registers" },
405 #ifdef PCSCRED /* solaris */
406 { PCSCRED
, "PCSCRED", "set process credentials" },
408 { PCSENTRY
, "PCSENTRY", "set traced syscall entry set" },
409 { PCSET
, "PCSET", "set modes" },
410 { PCSEXIT
, "PCSEXIT", "set traced syscall exit set" },
411 { PCSFAULT
, "PCSFAULT", "set traced fault set" },
412 { PCSFPREG
, "PCSFPREG", "set floating point registers" },
413 { PCSHOLD
, "PCSHOLD", "set signal mask" },
414 { PCSREG
, "PCSREG", "set general registers" },
415 { PCSSIG
, "PCSSIG", "set current signal" },
416 { PCSTOP
, "PCSTOP", "post stop request and wait" },
417 { PCSTRACE
, "PCSTRACE", "set traced signal set" },
418 #ifdef PCSVADDR /* solaris */
419 { PCSVADDR
, "PCSVADDR", "set pc virtual address" },
421 #ifdef PCSXREG /* solaris sparc only */
422 { PCSXREG
, "PCSXREG", "set extra registers" },
424 #ifdef PCTWSTOP /* solaris */
425 { PCTWSTOP
, "PCTWSTOP", "wait for stop, with timeout arg" },
427 { PCUNKILL
, "PCUNKILL", "delete a pending signal" },
428 #ifdef PCUNSET /* solaris */
429 { PCUNSET
, "PCUNSET", "unset modes" },
431 #ifdef PCWATCH /* solaris */
432 { PCWATCH
, "PCWATCH", "set/unset watched memory area" },
434 { PCWSTOP
, "PCWSTOP", "wait for process/lwp to stop, no timeout" },
438 static off_t lseek_offset
;
441 write_with_trace (fd
, arg
, len
, file
, line
)
449 long opcode
= arg
[0];
454 if (procfs_file
== NULL
&& procfs_filename
!= NULL
)
455 procfs_file
= fopen (procfs_filename
, "a");
457 for (i
= 0; rw_table
[i
].name
!= NULL
; i
++)
458 if (rw_table
[i
].value
== opcode
)
462 fprintf (procfs_file
? procfs_file
: stdout
,
463 "%s:%d -- ", file
, line
);
466 fprintf (procfs_file
? procfs_file
: stdout
,
467 "write (PCSET, %s) %s\n",
468 arg
[1] == PR_FORK
? "PR_FORK" :
469 arg
[1] == PR_RLC
? "PR_RLC" :
471 arg
[1] == PR_ASYNC
? "PR_ASYNC" :
474 info_verbose
? rw_table
[i
].desc
: "");
482 fprintf (procfs_file
? procfs_file
: stdout
,
483 "write (PCRESET, %s) %s\n",
484 arg
[1] == PR_FORK
? "PR_FORK" :
485 arg
[1] == PR_RLC
? "PR_RLC" :
487 arg
[1] == PR_ASYNC
? "PR_ASYNC" :
490 info_verbose
? rw_table
[i
].desc
: "");
493 fprintf (procfs_file
? procfs_file
: stdout
,
494 "write (PCSTRACE) ");
495 proc_prettyfprint_signalset (procfs_file
? procfs_file
: stdout
,
496 (sigset_t
*) &arg
[1], 0);
499 fprintf (procfs_file
? procfs_file
: stdout
,
500 "write (PCSFAULT) ");
501 proc_prettyfprint_faultset (procfs_file
? procfs_file
: stdout
,
502 (fltset_t
*) &arg
[1], 0);
505 fprintf (procfs_file
? procfs_file
: stdout
,
506 "write (PCSENTRY) ");
507 proc_prettyfprint_syscalls (procfs_file
? procfs_file
: stdout
,
508 (sysset_t
*) &arg
[1], 0);
511 fprintf (procfs_file
? procfs_file
: stdout
,
513 proc_prettyfprint_syscalls (procfs_file
? procfs_file
: stdout
,
514 (sysset_t
*) &arg
[1], 0);
517 fprintf (procfs_file
? procfs_file
: stdout
,
519 proc_prettyfprint_signalset (procfs_file
? procfs_file
: stdout
,
520 (sigset_t
*) &arg
[1], 0);
523 fprintf (procfs_file
? procfs_file
: stdout
,
525 proc_prettyfprint_signal (procfs_file
? procfs_file
: stdout
,
526 arg
[1] ? ((siginfo_t
*) &arg
[1])->si_signo
529 fprintf (procfs_file
? procfs_file
: stdout
, "\n");
532 fprintf (procfs_file
? procfs_file
: stdout
,
535 fprintf (procfs_file
? procfs_file
: stdout
, "clearSig ");
536 if (arg
[1] & PRCFAULT
)
537 fprintf (procfs_file
? procfs_file
: stdout
, "clearFlt ");
539 fprintf (procfs_file
? procfs_file
: stdout
, "step ");
540 if (arg
[1] & PRSABORT
)
541 fprintf (procfs_file
? procfs_file
: stdout
, "syscallAbort ");
543 fprintf (procfs_file
? procfs_file
: stdout
, "stopReq ");
545 fprintf (procfs_file
? procfs_file
: stdout
, "\n");
548 fprintf (procfs_file
? procfs_file
: stdout
,
550 proc_prettyfprint_signal (procfs_file
? procfs_file
: stdout
,
552 fprintf (procfs_file
? procfs_file
: stdout
, "\n");
556 static unsigned char break_insn
[] = BREAKPOINT
;
558 if (len
== sizeof (break_insn
) &&
559 memcmp (arg
, &break_insn
, len
) == 0)
560 fprintf (procfs_file
? procfs_file
: stdout
,
561 "write (<breakpoint at 0x%08x>) \n", lseek_offset
);
562 else if (rw_table
[i
].name
)
563 fprintf (procfs_file
? procfs_file
: stdout
,
566 info_verbose
? rw_table
[i
].desc
: "");
569 if (lseek_offset
!= -1)
570 fprintf (procfs_file
? procfs_file
: stdout
,
571 "write (<unknown>, %d bytes at 0x%08x) \n",
574 fprintf (procfs_file
? procfs_file
: stdout
,
575 "write (<unknown>, %d bytes) \n", len
);
581 fflush (procfs_file
);
583 ret
= write (fd
, arg
, len
);
584 if (procfs_trace
&& ret
!= len
)
586 fprintf (procfs_file
? procfs_file
: stdout
,
587 "[write (%s) FAILED!\n",
588 rw_table
[i
].name
!= NULL
?
589 rw_table
[i
].name
: "<unknown>");
591 fflush (procfs_file
);
599 lseek_with_trace (fd
, offset
, whence
, file
, line
)
608 #if 0 /* don't need output, just need address */
611 if (procfs_file
== NULL
&& procfs_filename
!= NULL
)
612 procfs_file
= fopen (procfs_filename
, "a");
615 fprintf (procfs_file
? procfs_file
: stdout
,
616 "%s:%d -- ", file
, line
);
617 fprintf (procfs_file
? procfs_file
: stdout
,
618 "lseek (0x%08x, %s) \n", offset
,
619 whence
== SEEK_SET
? "SEEK_SET" :
620 whence
== SEEK_CUR
? "SEEK_CUR" :
621 whence
== SEEK_END
? "SEEK_END" :
624 fflush (procfs_file
);
627 ret
= lseek (fd
, offset
, whence
);
629 if (procfs_trace
&& ret
== -1)
631 if (procfs_file
== NULL
&& procfs_filename
!= NULL
)
632 procfs_file
= fopen (procfs_filename
, "a");
634 fprintf (procfs_file
? procfs_file
: stdout
,
635 "[lseek (0x%08x) FAILED!\n", offset
);
637 fflush (procfs_file
);
643 #endif /* NEW_PROC_API */
646 open_with_trace (filename
, mode
, file
, line
)
652 int ret
= open (filename
, mode
);
656 if (procfs_file
== NULL
&& procfs_filename
!= NULL
)
657 procfs_file
= fopen (procfs_filename
, "a");
660 fprintf (procfs_file
? procfs_file
: stdout
,
661 "%s:%d -- ", file
, line
);
662 fprintf (procfs_file
? procfs_file
: stdout
,
663 "%d = open (%s, ", ret
, filename
);
664 if (mode
== O_RDONLY
)
665 fprintf (procfs_file
? procfs_file
: stdout
, "O_RDONLY) %d\n", line
);
666 else if (mode
== O_WRONLY
)
667 fprintf (procfs_file
? procfs_file
: stdout
, "O_WRONLY) %d\n", line
);
668 else if (mode
== O_RDWR
)
669 fprintf (procfs_file
? procfs_file
: stdout
, "O_RDWR) %d\n", line
);
671 fflush (procfs_file
);
678 close_with_trace (fd
, file
, line
)
683 int ret
= close (fd
);
687 if (procfs_file
== NULL
&& procfs_filename
!= NULL
)
688 procfs_file
= fopen (procfs_filename
, "a");
691 fprintf (procfs_file
? procfs_file
: stdout
,
692 "%s:%d -- ", file
, line
);
693 fprintf (procfs_file
? procfs_file
: stdout
,
694 "%d = close (%d)\n", ret
, fd
);
696 fflush (procfs_file
);
703 wait_with_trace (wstat
, file
, line
)
712 if (procfs_file
== NULL
&& procfs_filename
!= NULL
)
713 procfs_file
= fopen (procfs_filename
, "a");
716 fprintf (procfs_file
? procfs_file
: stdout
,
717 "%s:%d -- ", file
, line
);
718 fprintf (procfs_file
? procfs_file
: stdout
,
719 "wait (line %d) ", line
);
721 fflush (procfs_file
);
726 fprintf (procfs_file
? procfs_file
: stdout
,
727 "returned pid %d, status 0x%x\n", ret
, lstat
);
729 fflush (procfs_file
);
738 procfs_note (msg
, file
, line
)
745 if (procfs_file
== NULL
&& procfs_filename
!= NULL
)
746 procfs_file
= fopen (procfs_filename
, "a");
749 fprintf (procfs_file
? procfs_file
: stdout
,
750 "%s:%d -- ", file
, line
);
751 fprintf (procfs_file
? procfs_file
: stdout
, msg
);
753 fflush (procfs_file
);
758 proc_prettyfprint_status (flags
, why
, what
, thread
)
766 if (procfs_file
== NULL
&& procfs_filename
!= NULL
)
767 procfs_file
= fopen (procfs_filename
, "a");
770 fprintf (procfs_file
? procfs_file
: stdout
,
771 "Thread %d: ", thread
);
773 proc_prettyfprint_flags (procfs_file
? procfs_file
: stdout
,
776 if (flags
& (PR_STOPPED
| PR_ISTOP
))
777 proc_prettyfprint_why (procfs_file
? procfs_file
: stdout
,
780 fflush (procfs_file
);
786 _initialize_proc_api ()
788 struct cmd_list_element
*c
;
790 c
= add_set_cmd ("procfs-trace", no_class
,
791 var_boolean
, (char *) &procfs_trace
,
792 "Set tracing for /proc ioctl calls.\n", &setlist
);
794 add_show_from_set (c
, &showlist
);
795 c
->function
.sfunc
= set_procfs_trace_cmd
;
797 c
= add_set_cmd ("procfs-file", no_class
, var_filename
,
798 (char *) &procfs_filename
,
799 "Set filename for /proc tracefile.\n", &setlist
);
801 add_show_from_set (c
, &showlist
);
802 c
->function
.sfunc
= set_procfs_file_cmd
;
805 if (procfs_file
== NULL
&& procfs_filename
!= NULL
)
806 procfs_file
= fopen (procfs_filename
, "a");
This page took 0.046325 seconds and 4 git commands to generate.