771a28e6374bdd924b0821c77dfa08208957024b
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
= 0;
57 static FILE *procfs_file
= NULL
;
58 static char *procfs_filename
= "procfs_trace";
61 prepare_to_trace (void)
63 if (procfs_trace
) /* if procfs tracing turned on */
64 if (procfs_file
== NULL
) /* if output file not yet open */
65 if (procfs_filename
!= NULL
) /* if output filename known */
66 procfs_file
= fopen (procfs_filename
, "a"); /* open output file */
70 set_procfs_trace_cmd (args
, from_tty
, c
)
73 struct cmd_list_element
*c
;
75 #if 0 /* not sure what I might actually need to do here, if anything */
82 set_procfs_file_cmd (args
, from_tty
, c
)
85 struct cmd_list_element
*c
;
87 /* Just changed the filename for procfs tracing.
88 If a file was already open, close it. */
97 static struct trans ioctl_table
[] = {
98 #ifdef PIOCACINFO /* irix */
99 { PIOCACINFO
, "PIOCACINFO", "get process account info" },
101 { PIOCACTION
, "PIOCACTION", "get signal action structs" },
102 #ifdef PIOCARGUMENTS /* osf */
103 { PIOCARGUMENTS
, "PIOCARGUMENTS", "command line args" },
105 #ifdef PIOCAUXV /* solaris aux vectors */
106 { PIOCAUXV
, "PIOCAUXV", "get aux vector" },
107 { PIOCNAUXV
, "PIOCNAUXV", "get number of aux vector entries" },
109 { PIOCCFAULT
, "PIOCCFAULT", "clear current fault" },
110 { PIOCCRED
, "PIOCCRED", "get process credentials" },
111 #ifdef PIOCENEVCTRS /* irix event counters */
112 { PIOCENEVCTRS
, "PIOCENEVCTRS", "acquire and start event counters" },
113 { PIOCGETEVCTRL
, "PIOCGETEVCTRL", "get control info of event counters" },
114 { PIOCGETEVCTRS
, "PIOCGETEVCTRS", "dump event counters" },
115 { PIOCGETPREVCTRS
, "PIOCGETPREVCTRS", "dump event counters & prusage info" },
116 { PIOCRELEVCTRS
, "PIOCRELEVCTRS", "release/stop event counters" },
117 { PIOCSETEVCTRL
, "PIOCSETEVCTRL", "set control info of event counters" },
118 { PIOCGETPTIMER
, "PIOCGETPTIMER", "get process timers" },
119 #endif /* irix event counters */
120 { PIOCGENTRY
, "PIOCGENTRY", "get traced syscall entry set" },
121 { PIOCGETPR
, "PIOCGETPR", "read struct proc" },
122 { PIOCGETU
, "PIOCGETU", "read user area" },
123 #if defined (PIOCGETUTK) && (defined(KERNEL) || defined(SHOW_UTT)) /* osf */
124 { PIOCGETUTK
, "PIOCGETUTK", "get the utask struct" },
126 { PIOCGEXIT
, "PIOCGEXIT", "get traced syscall exit set" },
127 { PIOCGFAULT
, "PIOCGFAULT", "get traced fault set" },
128 #ifdef PIOCGFPCR /* osf */
129 { PIOCGFPCR
, "PIOCGFPCR", "get FP control register" },
130 { PIOCSFPCR
, "PIOCSFPCR", "set FP conrtol register" },
132 { PIOCGFPREG
, "PIOCGFPREG", "get floating point registers" },
133 { PIOCGHOLD
, "PIOCGHOLD", "get held signal set" },
134 { PIOCGREG
, "PIOCGREG", "get general registers" },
135 { PIOCGROUPS
, "PIOCGROUPS", "get supplementary groups" },
136 #ifdef PIOCGSPCACT /* osf */
137 { PIOCGSPCACT
, "PIOCGSPCACT", "get special action" },
138 { PIOCSSPCACT
, "PIOCSSPCACT", "set special action" },
140 { PIOCGTRACE
, "PIOCGTRACE", "get traced signal set" },
141 #ifdef PIOCGWATCH /* irix watchpoints */
142 { PIOCGWATCH
, "PIOCGWATCH", "get watchpoint" },
143 { PIOCSWATCH
, "PIOCSWATCH", "set watchpoint" },
144 { PIOCNWATCH
, "PIOCNWATCH", "get number of watchpoints" },
145 #endif /* irix watchpoints */
146 #ifdef PIOCGWIN /* solaris sparc */
147 { PIOCGWIN
, "PIOCGWIN", "get gwindows_t" },
149 #ifdef PIOCGXREG /* solaris sparc extra regs */
150 { PIOCGXREGSIZE
, "PIOCXREGSIZE", "get extra register state size" },
151 { PIOCGXREG
, "PIOCGXREG", "get extra register state" },
152 { PIOCSXREG
, "PIOCSXREG", "set extra register state" },
154 { PIOCKILL
, "PIOCKILL", "send signal" },
155 #ifdef PIOCLDT /* solaris i386 */
156 { PIOCLDT
, "PIOCLDT", "get LDT" },
157 { PIOCNLDT
, "PIOCNLDT", "get number of LDT entries" },
159 #ifdef PIOCLSTATUS /* solaris and unixware */
160 { PIOCLSTATUS
, "PIOCLSTATUS", "get status of all lwps" },
161 { PIOCLUSAGE
, "PIOCLUSAGE", "get resource usage of all lwps" },
162 { PIOCOPENLWP
, "PIOCOPENLWP", "get lwp file descriptor" },
163 { PIOCLWPIDS
, "PIOCLWPIDS", "get lwp identifiers" },
165 { PIOCMAP
, "PIOCMAP", "get memory map information" },
166 { PIOCMAXSIG
, "PIOCMAXSIG", "get max signal number" },
167 { PIOCNICE
, "PIOCNICE", "set nice priority" },
168 { PIOCNMAP
, "PIOCNMAP", "get number of memory mappings" },
169 { PIOCOPENM
, "PIOCOPENM", "open mapped object for reading" },
170 #ifdef PIOCOPENMOBS /* osf */
171 { PIOCOPENMOBS
, "PIOCOPENMOBS", "open mapped object" },
173 #ifdef PIOCOPENPD /* solaris */
174 { PIOCOPENPD
, "PIOCOPENPD", "get page data file descriptor" },
176 { PIOCPSINFO
, "PIOCPSINFO", "get ps(1) information" },
177 { PIOCRESET
, "PIOCRESET", "reset process flags" },
178 { PIOCRFORK
, "PIOCRFORK", "reset inherit-on-fork flag" },
179 { PIOCRRLC
, "PIOCRRLC", "reset run-on-last-close flag" },
180 { PIOCRUN
, "PIOCRUN", "make process runnable" },
181 #ifdef PIOCSAVECCNTRS /* irix */
182 { PIOCSAVECCNTRS
, "PIOCSAVECCNTRS", "parent gets child cntrs" },
184 { PIOCSENTRY
, "PIOCSENTRY", "set traced syscall entry set" },
185 { PIOCSET
, "PIOCSET", "set process flags" },
186 { PIOCSEXIT
, "PIOCSEXIT", "set traced syscall exit set" },
187 { PIOCSFAULT
, "PIOCSFAULT", "set traced fault set" },
188 { PIOCSFORK
, "PIOCSFORK", "set inherit-on-fork flag" },
189 { PIOCSFPREG
, "PIOCSFPREG", "set floating point registers" },
190 { PIOCSHOLD
, "PIOCSHOLD", "set held signal set" },
191 { PIOCSREG
, "PIOCSREG", "set general registers" },
192 { PIOCSRLC
, "PIOCSRLC", "set run-on-last-close flag" },
193 { PIOCSSIG
, "PIOCSSIG", "set current signal" },
194 { PIOCSTATUS
, "PIOCSTATUS", "get process status" },
195 { PIOCSTOP
, "PIOCSTOP", "post stop request" },
196 { PIOCSTRACE
, "PIOCSTRACE", "set traced signal set" },
197 { PIOCUNKILL
, "PIOCUNKILL", "delete a signal" },
198 #ifdef PIOCUSAGE /* solaris */
199 { PIOCUSAGE
, "PIOCUSAGE", "get resource usage" },
201 { PIOCWSTOP
, "PIOCWSTOP", "wait for process to stop" },
203 #ifdef PIOCNTHR /* osf threads */
204 { PIOCNTHR
, "PIOCNTHR", "get thread count" },
205 { PIOCRTINH
, "PIOCRTINH", "reset inherit-on-thread-creation" },
206 { PIOCSTINH
, "PIOCSTINH", "set inherit-on-thread-creation" },
207 { PIOCTLIST
, "PIOCTLIST", "get thread ids" },
208 { PIOCXPTH
, "PIOCXPTH", "translate port to thread handle" },
209 { PIOCTRUN
, "PIOCTRUN", "make thread runnable" },
210 { PIOCTSTATUS
, "PIOCTSTATUS", "get thread status" },
211 { PIOCTSTOP
, "PIOCTSTOP", "stop a thread" },
212 /* ... TGTRACE TSTRACE TSSIG TKILL TUNKILL TCFAULT TGFAULT TSFAULT
213 TGFPREG TSFPREG TGREG TSREG TACTION TTERM TABRUN TGENTRY TSENTRY
214 TGEXIT TSEXIT TSHOLD ... thread functions */
215 #endif /* osf threads */
220 ioctl_with_trace (fd
, opcode
, ptr
, file
, line
)
233 for (i
= 0; ioctl_table
[i
].name
!= NULL
; i
++)
234 if (ioctl_table
[i
].value
== opcode
)
238 fprintf (procfs_file
? procfs_file
: stdout
,
239 "%s:%d -- ", file
, line
);
242 arg1
= ptr
? *(long *) ptr
: 0;
243 fprintf (procfs_file
? procfs_file
: stdout
,
244 "ioctl (PIOCSET, %s) %s\n",
245 arg1
== PR_FORK
? "PR_FORK" :
246 arg1
== PR_RLC
? "PR_RLC" :
248 arg1
== PR_ASYNC
? "PR_ASYNC" :
251 info_verbose
? ioctl_table
[i
].desc
: "");
254 arg1
= ptr
? *(long *) ptr
: 0;
255 fprintf (procfs_file
? procfs_file
: stdout
,
256 "ioctl (PIOCRESET, %s) %s\n",
257 arg1
== PR_FORK
? "PR_FORK" :
258 arg1
== PR_RLC
? "PR_RLC" :
260 arg1
== PR_ASYNC
? "PR_ASYNC" :
263 info_verbose
? ioctl_table
[i
].desc
: "");
266 fprintf (procfs_file
? procfs_file
: stdout
,
267 "ioctl (PIOCSTRACE) ");
268 proc_prettyfprint_signalset (procfs_file
? procfs_file
: stdout
,
269 (sigset_t
*) ptr
, 0);
272 fprintf (procfs_file
? procfs_file
: stdout
,
274 opcode
== PIOCSFAULT
? "PIOCSFAULT" : "PIOCGFAULT");
275 proc_prettyfprint_faultset (procfs_file
? procfs_file
: stdout
,
276 (fltset_t
*) ptr
, 0);
279 fprintf (procfs_file
? procfs_file
: stdout
,
281 opcode
== PIOCSENTRY
? "PIOCSENTRY" : "PIOCGENTRY");
282 proc_prettyfprint_syscalls (procfs_file
? procfs_file
: stdout
,
283 (sysset_t
*) ptr
, 0);
286 fprintf (procfs_file
? procfs_file
: stdout
,
288 opcode
== PIOCSEXIT
? "PIOCSEXIT" : "PIOCGEXIT");
289 proc_prettyfprint_syscalls (procfs_file
? procfs_file
: stdout
,
290 (sysset_t
*) ptr
, 0);
293 fprintf (procfs_file
? procfs_file
: stdout
,
295 opcode
== PIOCSHOLD
? "PIOCSHOLD" : "PIOCGHOLD");
296 proc_prettyfprint_signalset (procfs_file
? procfs_file
: stdout
,
297 (sigset_t
*) ptr
, 0);
300 fprintf (procfs_file
? procfs_file
: stdout
,
301 "ioctl (PIOCSSIG) ");
302 proc_prettyfprint_signal (procfs_file
? procfs_file
: stdout
,
303 ptr
? ((siginfo_t
*) ptr
)->si_signo
: 0,
305 fprintf (procfs_file
? procfs_file
: stdout
, "\n");
308 fprintf (procfs_file
? procfs_file
: stdout
,
311 arg1
= ptr
? *(long *) ptr
: 0;
313 fprintf (procfs_file
? procfs_file
: stdout
, "clearSig ");
315 fprintf (procfs_file
? procfs_file
: stdout
, "clearFlt ");
317 fprintf (procfs_file
? procfs_file
: stdout
, "setTrace ");
319 fprintf (procfs_file
? procfs_file
: stdout
, "setHold ");
321 fprintf (procfs_file
? procfs_file
: stdout
, "setFlt ");
323 fprintf (procfs_file
? procfs_file
: stdout
, "setVaddr ");
325 fprintf (procfs_file
? procfs_file
: stdout
, "step ");
327 fprintf (procfs_file
? procfs_file
: stdout
, "syscallAbort ");
329 fprintf (procfs_file
? procfs_file
: stdout
, "stopReq ");
331 fprintf (procfs_file
? procfs_file
: stdout
, "\n");
334 fprintf (procfs_file
? procfs_file
: stdout
,
335 "ioctl (PIOCKILL) ");
336 proc_prettyfprint_signal (procfs_file
? procfs_file
: stdout
,
337 ptr
? *(long *) ptr
: 0, 0);
338 fprintf (procfs_file
? procfs_file
: stdout
, "\n");
342 fprintf (procfs_file
? procfs_file
: stdout
,
343 "ioctl (PIOCSSPCACT) ");
344 arg1
= ptr
? *(long *) ptr
: 0;
345 if (arg1
& PRFS_STOPFORK
)
346 fprintf (procfs_file
? procfs_file
: stdout
, "stopFork ");
347 if (arg1
& PRFS_STOPEXEC
)
348 fprintf (procfs_file
? procfs_file
: stdout
, "stopExec ");
349 if (arg1
& PRFS_STOPTERM
)
350 fprintf (procfs_file
? procfs_file
: stdout
, "stopTerm ");
351 if (arg1
& PRFS_STOPTCR
)
352 fprintf (procfs_file
? procfs_file
: stdout
, "stopThreadCreate ");
353 if (arg1
& PRFS_STOPTTERM
)
354 fprintf (procfs_file
? procfs_file
: stdout
, "stopThreadTerm ");
355 if (arg1
& PRFS_KOLC
)
356 fprintf (procfs_file
? procfs_file
: stdout
, "killOnLastClose ");
357 fprintf (procfs_file
? procfs_file
: stdout
, "\n");
359 #endif /* PIOCSSPCACT */
361 if (ioctl_table
[i
].name
)
362 fprintf (procfs_file
? procfs_file
: stdout
,
365 info_verbose
? ioctl_table
[i
].desc
: "");
367 fprintf (procfs_file
? procfs_file
: stdout
,
368 "ioctl (<unknown %ld (0x%lx)) \n", opcode
, opcode
);
372 fflush (procfs_file
);
375 ret
= ioctl (fd
, opcode
, ptr
);
376 if (procfs_trace
&& ret
< 0)
378 fprintf (procfs_file
? procfs_file
: stdout
,
379 "[ioctl (%s) FAILED! (%s)]\n",
380 ioctl_table
[i
].name
!= NULL
?
381 ioctl_table
[i
].name
: "<unknown>",
382 safe_strerror (errno
));
384 fflush (procfs_file
);
390 #else /* NEW_PROC_API */
392 static struct trans rw_table
[] = {
393 #ifdef PCAGENT /* solaris */
394 { PCAGENT
, "PCAGENT", "create agent lwp with regs from argument" },
396 { PCCFAULT
, "PCCFAULT", "clear current fault" },
397 #ifdef PCCSIG /* solaris */
398 { PCCSIG
, "PCCSIG", "clear current signal" },
400 { PCDSTOP
, "PCDSTOP", "post stop request" },
401 { PCKILL
, "PCKILL", "post a signal" },
402 { PCNICE
, "PCNICE", "set nice priority" },
403 #ifdef PCREAD /* solaris */
404 { PCREAD
, "PCREAD", "read from the address space" },
405 { PCWRITE
, "PCWRITE", "write to the address space" },
407 #ifdef PCRESET /* unixware */
408 { PCRESET
, "PCRESET", "unset modes" },
410 { PCRUN
, "PCRUN", "make process/lwp runnable" },
411 #ifdef PCSASRS /* solaris 2.7 only */
412 { PCSASRS
, "PCSASRS", "set ancillary state registers" },
414 #ifdef PCSCRED /* solaris */
415 { PCSCRED
, "PCSCRED", "set process credentials" },
417 { PCSENTRY
, "PCSENTRY", "set traced syscall entry set" },
418 { PCSET
, "PCSET", "set modes" },
419 { PCSEXIT
, "PCSEXIT", "set traced syscall exit set" },
420 { PCSFAULT
, "PCSFAULT", "set traced fault set" },
421 { PCSFPREG
, "PCSFPREG", "set floating point registers" },
422 { PCSHOLD
, "PCSHOLD", "set signal mask" },
423 { PCSREG
, "PCSREG", "set general registers" },
424 { PCSSIG
, "PCSSIG", "set current signal" },
425 { PCSTOP
, "PCSTOP", "post stop request and wait" },
426 { PCSTRACE
, "PCSTRACE", "set traced signal set" },
427 #ifdef PCSVADDR /* solaris */
428 { PCSVADDR
, "PCSVADDR", "set pc virtual address" },
430 #ifdef PCSXREG /* solaris sparc only */
431 { PCSXREG
, "PCSXREG", "set extra registers" },
433 #ifdef PCTWSTOP /* solaris */
434 { PCTWSTOP
, "PCTWSTOP", "wait for stop, with timeout arg" },
436 { PCUNKILL
, "PCUNKILL", "delete a pending signal" },
437 #ifdef PCUNSET /* solaris */
438 { PCUNSET
, "PCUNSET", "unset modes" },
440 #ifdef PCWATCH /* solaris */
441 { PCWATCH
, "PCWATCH", "set/unset watched memory area" },
443 { PCWSTOP
, "PCWSTOP", "wait for process/lwp to stop, no timeout" },
447 static off_t lseek_offset
;
450 write_with_trace (fd
, varg
, len
, file
, line
)
459 long *arg
= (long *) varg
;
464 long opcode
= arg
[0];
465 for (i
= 0; rw_table
[i
].name
!= NULL
; i
++)
466 if (rw_table
[i
].value
== opcode
)
470 fprintf (procfs_file
? procfs_file
: stdout
,
471 "%s:%d -- ", file
, line
);
474 fprintf (procfs_file
? procfs_file
: stdout
,
475 "write (PCSET, %s) %s\n",
476 arg
[1] == PR_FORK
? "PR_FORK" :
477 arg
[1] == PR_RLC
? "PR_RLC" :
479 arg
[1] == PR_ASYNC
? "PR_ASYNC" :
482 info_verbose
? rw_table
[i
].desc
: "");
490 fprintf (procfs_file
? procfs_file
: stdout
,
491 "write (PCRESET, %s) %s\n",
492 arg
[1] == PR_FORK
? "PR_FORK" :
493 arg
[1] == PR_RLC
? "PR_RLC" :
495 arg
[1] == PR_ASYNC
? "PR_ASYNC" :
498 info_verbose
? rw_table
[i
].desc
: "");
501 fprintf (procfs_file
? procfs_file
: stdout
,
502 "write (PCSTRACE) ");
503 proc_prettyfprint_signalset (procfs_file
? procfs_file
: stdout
,
504 (sigset_t
*) &arg
[1], 0);
507 fprintf (procfs_file
? procfs_file
: stdout
,
508 "write (PCSFAULT) ");
509 proc_prettyfprint_faultset (procfs_file
? procfs_file
: stdout
,
510 (fltset_t
*) &arg
[1], 0);
513 fprintf (procfs_file
? procfs_file
: stdout
,
514 "write (PCSENTRY) ");
515 proc_prettyfprint_syscalls (procfs_file
? procfs_file
: stdout
,
516 (sysset_t
*) &arg
[1], 0);
519 fprintf (procfs_file
? procfs_file
: stdout
,
521 proc_prettyfprint_syscalls (procfs_file
? procfs_file
: stdout
,
522 (sysset_t
*) &arg
[1], 0);
525 fprintf (procfs_file
? procfs_file
: stdout
,
527 proc_prettyfprint_signalset (procfs_file
? procfs_file
: stdout
,
528 (sigset_t
*) &arg
[1], 0);
531 fprintf (procfs_file
? procfs_file
: stdout
,
533 proc_prettyfprint_signal (procfs_file
? procfs_file
: stdout
,
534 arg
[1] ? ((siginfo_t
*) &arg
[1])->si_signo
537 fprintf (procfs_file
? procfs_file
: stdout
, "\n");
540 fprintf (procfs_file
? procfs_file
: stdout
,
543 fprintf (procfs_file
? procfs_file
: stdout
, "clearSig ");
544 if (arg
[1] & PRCFAULT
)
545 fprintf (procfs_file
? procfs_file
: stdout
, "clearFlt ");
547 fprintf (procfs_file
? procfs_file
: stdout
, "step ");
548 if (arg
[1] & PRSABORT
)
549 fprintf (procfs_file
? procfs_file
: stdout
, "syscallAbort ");
551 fprintf (procfs_file
? procfs_file
: stdout
, "stopReq ");
553 fprintf (procfs_file
? procfs_file
: stdout
, "\n");
556 fprintf (procfs_file
? procfs_file
: stdout
,
558 proc_prettyfprint_signal (procfs_file
? procfs_file
: stdout
,
560 fprintf (procfs_file
? procfs_file
: stdout
, "\n");
564 static unsigned char break_insn
[] = BREAKPOINT
;
566 if (len
== sizeof (break_insn
) &&
567 memcmp (arg
, &break_insn
, len
) == 0)
568 fprintf (procfs_file
? procfs_file
: stdout
,
569 "write (<breakpoint at 0x%08lx>) \n",
570 (unsigned long) lseek_offset
);
571 else if (rw_table
[i
].name
)
572 fprintf (procfs_file
? procfs_file
: stdout
,
575 info_verbose
? rw_table
[i
].desc
: "");
578 if (lseek_offset
!= -1)
579 fprintf (procfs_file
? procfs_file
: stdout
,
580 "write (<unknown>, %lud bytes at 0x%08lx) \n",
581 (unsigned long) len
, (unsigned long) lseek_offset
);
583 fprintf (procfs_file
? procfs_file
: stdout
,
584 "write (<unknown>, %lud bytes) \n",
585 (unsigned long) len
);
591 fflush (procfs_file
);
594 ret
= write (fd
, (void *) arg
, len
);
595 if (procfs_trace
&& ret
!= len
)
597 fprintf (procfs_file
? procfs_file
: stdout
,
598 "[write (%s) FAILED! (%s)]\n",
599 rw_table
[i
].name
!= NULL
?
600 rw_table
[i
].name
: "<unknown>",
601 safe_strerror (errno
));
603 fflush (procfs_file
);
611 lseek_with_trace (fd
, offset
, whence
, file
, line
)
622 ret
= lseek (fd
, offset
, whence
);
624 if (procfs_trace
&& (ret
== -1 || errno
!= 0))
626 fprintf (procfs_file
? procfs_file
: stdout
,
627 "[lseek (0x%08lx) FAILED! (%s)]\n",
628 (unsigned long) offset
, safe_strerror (errno
));
630 fflush (procfs_file
);
636 #endif /* NEW_PROC_API */
639 open_with_trace (filename
, mode
, file
, line
)
649 ret
= open (filename
, mode
);
653 fprintf (procfs_file
? procfs_file
: stdout
,
654 "%s:%d -- ", file
, line
);
658 fprintf (procfs_file
? procfs_file
: stdout
,
659 "[open FAILED! (%s) line %d]\\n",
660 safe_strerror (errno
), line
);
664 fprintf (procfs_file
? procfs_file
: stdout
,
665 "%d = open (%s, ", ret
, filename
);
666 if (mode
== O_RDONLY
)
667 fprintf (procfs_file
? procfs_file
: stdout
, "O_RDONLY) %d\n",
669 else if (mode
== O_WRONLY
)
670 fprintf (procfs_file
? procfs_file
: stdout
, "O_WRONLY) %d\n",
672 else if (mode
== O_RDWR
)
673 fprintf (procfs_file
? procfs_file
: stdout
, "O_RDWR) %d\n",
677 fflush (procfs_file
);
684 close_with_trace (fd
, file
, line
)
697 fprintf (procfs_file
? procfs_file
: stdout
,
698 "%s:%d -- ", file
, line
);
700 fprintf (procfs_file
? procfs_file
: stdout
,
701 "[close FAILED! (%s)]\n", safe_strerror (errno
));
703 fprintf (procfs_file
? procfs_file
: stdout
,
704 "%d = close (%d)\n", ret
, fd
);
706 fflush (procfs_file
);
713 wait_with_trace (wstat
, file
, line
)
724 fprintf (procfs_file
? procfs_file
: stdout
,
725 "%s:%d -- ", file
, line
);
726 fprintf (procfs_file
? procfs_file
: stdout
,
727 "wait (line %d) ", line
);
729 fflush (procfs_file
);
736 fprintf (procfs_file
? procfs_file
: stdout
,
737 "[wait FAILED! (%s)]\n", safe_strerror (errno
));
739 fprintf (procfs_file
? procfs_file
: stdout
,
740 "returned pid %d, status 0x%x\n", ret
, lstat
);
742 fflush (procfs_file
);
751 procfs_note (msg
, file
, line
)
760 fprintf (procfs_file
? procfs_file
: stdout
,
761 "%s:%d -- ", file
, line
);
762 fprintf (procfs_file
? procfs_file
: stdout
, msg
);
764 fflush (procfs_file
);
769 proc_prettyfprint_status (flags
, why
, what
, thread
)
779 fprintf (procfs_file
? procfs_file
: stdout
,
780 "Thread %d: ", thread
);
782 proc_prettyfprint_flags (procfs_file
? procfs_file
: stdout
,
785 if (flags
& (PR_STOPPED
| PR_ISTOP
))
786 proc_prettyfprint_why (procfs_file
? procfs_file
: stdout
,
789 fflush (procfs_file
);
795 _initialize_proc_api ()
797 struct cmd_list_element
*c
;
799 c
= add_set_cmd ("procfs-trace", no_class
,
800 var_boolean
, (char *) &procfs_trace
,
801 "Set tracing for /proc api calls.\n", &setlist
);
803 add_show_from_set (c
, &showlist
);
804 c
->function
.sfunc
= set_procfs_trace_cmd
;
806 c
= add_set_cmd ("procfs-file", no_class
, var_filename
,
807 (char *) &procfs_filename
,
808 "Set filename for /proc tracefile.\n", &setlist
);
810 add_show_from_set (c
, &showlist
);
811 c
->function
.sfunc
= set_procfs_file_cmd
;
This page took 0.110762 seconds and 4 git commands to generate.