Commit Graph

189 Commits

Author SHA1 Message Date
Mateusz Guzik
8f99c21f94 truss: recognize O_DIRECTORY, O_EXEC, O_TTY_INIT and O_CLOEXEC
MFC after:	3 days
2013-06-30 13:14:46 +00:00
Olivier Houchard
57fb38ba93 Add arm bits to truss. 2013-03-07 23:44:35 +00:00
Xin LI
d9dcc46365 Revert r247300 for now. I'll post a new changeset for review. 2013-02-26 19:46:59 +00:00
Xin LI
285a4c7c59 Expose timespec and timeval macros when __BSD_VISIBLE is defined. This
allows userland application to use the following macros:

	timespecclear, timespecisset, timespeccmp, timespecadd,
	timespecsub;

	timevalclear, timevalisset, timevalcmp.

MFC after:	1 month
2013-02-26 02:13:02 +00:00
Mateusz Guzik
c2b51d4457 truss: use 'e' flag for fopen instead of fcntl(.., FD_CLOEXEC) 2013-01-27 03:17:35 +00:00
Mateusz Guzik
8ff44cbb80 truss: if file requested with -o flag could not be opened print the reason
MFC after:	3 days
2013-01-27 03:14:54 +00:00
Andrey Zonov
5695afded4 - Make truss thread-aware.
Approved by:	kib (mentor)
MFC after:	2 weeks
2012-09-16 14:38:01 +00:00
Andrey Zonov
896fc4638a - Fix detaching under some circumstances.
When truss is detaching from very active process it is possible to
  hang on waitpid(2) in restore_proc() forever, because
  ptrace(PT_SYSCALL) must be called before detaching, to allow the
  debugging process to continue execution.  Also when truss called with
  '-c' argument, it does not print anything after detach, because it
  immediately exits from restore_proc().

  To fix these two problems make detaching deferred, but then it is
  impossible to detach from a process which does not do any system call.
  To fix this issue use sigaction(2) instead of signal(3) to disable
  SA_RESTART flag for waitpid(2) that makes it non-restartable.  Remove
  global variable child_pid, because now detaching is handled in context
  where child's pid is known.

Reported by:	mjg
Tested by:	mjg, swills
Approved by:	kib (mentor)
MFC after:	2 weeks
2012-09-12 13:06:57 +00:00
Andrey Zonov
310da894b7 - Remove unused variables.
- Remove redundant return after err(3) call.

Approved by:	kib (mentor)
2012-09-11 16:30:26 +00:00
Andrey Zonov
94355cfdfd - Style(9) cleanup.
Approved by:	kib (mentor)
2012-09-02 11:03:18 +00:00
Andrey Zonov
46448452c0 - Remove unused variables.
- Fix warnings about comparing signed and unsigned ints.

Approved by:	kib (mentor)
2012-08-30 08:54:13 +00:00
Andrey Zonov
3ff6b7162e - Put arguments for print_syscall_ret() function in proper order.
Bug was introduced in r192025.

Approved by:	kib (mentor)
2012-08-23 12:20:29 +00:00
Andrey Zonov
be305c9c9f - Use pid_t type instead of just int.
Approved by:	kib (mentor)
2012-08-21 14:58:51 +00:00
Dimitry Andric
085e2c2102 Since truss also uses kdump's mkioctls script, pass the value of ${CPP}
there too, similar to r234058.

MFC after:	1 week
2012-04-09 15:34:22 +00:00
Ed Schouten
a02c83afc5 Add more static keywords to truss(1) source code.
There are some tables in the source code that are only used by the
individual source files themselves. Therefore there is no need to export
them.
2011-12-10 18:27:55 +00:00
Konstantin Belousov
97695ad4cd Use explicit information from the kernel to detect the traps due to
syscall entry and leave.

Based on submision by:	Dan Nelson <dnelson allantgroup com>
MFC after:	1 month
2011-12-04 18:43:09 +00:00
Dag-Erling Smørgrav
c04743dac1 It turns out that truss also used kdump's mkioctls script, and expected
ioctlname() to return a pointer to the name rather than print it.  This did
not show up in testing because truss had its own prototype for ioctlname(),
so it would build fine and run fine as long as the program being traced did
not issue an ioctl.

Teach mkioctls to generate different versions of ioctlname() based on its
first command-line argument.

Pointed out by:	Garrett Cooper <yanegomi@gmail.com>
2011-10-21 11:08:25 +00:00
Benedict Reuschling
b2bf146e3e Fix typos in comments, no functional changes.
Found by:       codespell
Reviewed by:    alfred
MFC after:      1 week
2011-05-19 20:35:40 +00:00
Jilles Tjoelker
de55508483 Simplify various code that allowed for sys_signame being lower case.
This was changed in r218285.
2011-03-06 19:50:47 +00:00
John Baldwin
ad01891403 Properly check for errors from waitpid().
Submitted by:	gcooper
MFC after:	1 week
2011-02-15 12:42:18 +00:00
Jilles Tjoelker
12dacf622b Make sys_signame upper case.
This matches the constants from <signal.h> with 'SIG' removed, which POSIX
requires kill and trap to accept and 'kill -l' to write.

'kill -l', 'trap', 'trap -l' output is now upper case.

In Turkish locales, signal names with an upper case 'I' are now accepted,
while signal names with a lower case 'i' are no longer accepted, and the
output of 'killall -l' now contains proper capital 'I' without dot instead
of a dotted capital 'I'.
2011-02-04 16:40:50 +00:00
Jaakko Heinonen
cdfc719c2e Don't write the terminating NUL past end of buffer.
PR:		bin/152345
Submitted by:	Mateusz Guzik
2010-12-06 09:18:11 +00:00
Jaakko Heinonen
e04c378683 Set FD_CLOEXEC for the output file only when the file has been specified
with the -o option. Setting the flag for stderr (the default) could
cause the traced process to redirect stderr to a random file.

PR:		bin/152151
Submitted by:	ashish
MFC after:	5 days
2010-11-13 09:28:49 +00:00
Ed Schouten
a2995e0d9b Remove setpgid() call before executing child process.
Using a separate process group here is bad, since (for example) job
control in the TTY layer prevents interaction with the TTY, causing the
child process to hang.

Mentioned on:	current@
MFC after:	2 weeks
2010-10-20 09:35:20 +00:00
Benedict Reuschling
05844c563e s/sytem/system in comments, no functional changes.
Reviewed by:    alfred@
2010-10-13 20:08:02 +00:00
Nathan Whitehorn
4e5833219a Fix breakage introduced in r211725 and improve functionality of truss on
64-bit powerpc by adding 32-bit compatibility features.
2010-08-28 15:04:53 +00:00
Warner Losh
25faff346c MFtbemd:
Prefer MACHNE_CPUARCH to MACHINE_ARCH in most contexts where you want
to test of all the CPUs of a given family conform.
2010-08-23 22:24:11 +00:00
Nathan Whitehorn
e6d0d807bf Teach truss and xlint how to operate on 64-bit PowerPC systems. 2010-07-12 00:54:41 +00:00
Warner Losh
0a6c71f8fa Fix copyright spelling.
PR:		139825
Submitted by:	Ruslan Mahmatkhanov
2010-03-10 20:31:30 +00:00
Randall Stewart
586df59eed This fix makes it so the args are malloc'd before
we use them (always a good idea ;-0)

This was found and fixed by JC

Obtained from:	JC (c.jayachandran@gmail.com)
2010-02-03 13:03:47 +00:00
Ed Schouten
b7946da96b Build usr.bin/ with WARNS=6 by default.
Also add some missing $FreeBSD$ to keep svn happy.
2010-01-02 10:27:05 +00:00
Brooks Davis
a6fffd6cb0 The devices that supported EVFILT_NETDEV kqueue filters were removed in
r195175.  Remove all definitions, documentation, and usage.

fifo_misc.c:
	Remove all kqueue tests as fifo_io.c performs all those that
	would have remained.

Reviewed by:	rwatson
MFC after:	3 weeks
X-MFC note:	don't change vlan_link_state() function signature
2009-12-31 20:29:58 +00:00
Ed Schouten
2b6d81c176 Allow proper tracing of posix_openpt(2). 2009-12-23 15:22:50 +00:00
Jaakko Heinonen
55a8d2bb22 Cast time_t values to intmax_t and use %jd with printf.
OK'ed by:	delphij
Approved by:	trasz (mentor)
2009-12-21 17:41:57 +00:00
Jaakko Heinonen
c059fa2e24 Remove non-working special case for pipe(2) from amd64-fbsd32.c and
i386-fbsd.c. Add pipe(2) to syscall table to decode it's pointer
argument properly and re-add special handling for pipe(2) return value
to print_syscall_ret().

PR:		bin/120870
Approved by:	trasz (mentor)
2009-12-21 17:38:13 +00:00
Jaakko Heinonen
ecbb6d348f Avoid sharing the file descriptor of the output file with traced
processes by setting the FD_CLOEXEC flag for the output file.

PR:		bin/140493
Submitted by:	Erik Lax
OK'ed by:	delphij
Approved by:	trasz (mentor)
2009-12-20 11:00:53 +00:00
Jaakko Heinonen
76de696d6a Add fork(2), getegid(2), geteuid(2), getgid(2), getpid(2), getpgid(2),
getpgrp(2), getppid(2), getsid(2) and getuid(2) to syscall table to
decode their arguments correctly.

OK'ed by:	delphij
Approved by:	trasz (mentor)
2009-12-20 10:58:34 +00:00
Xin LI
821df508e8 Revert most part of 200420 as requested, as more review and polish is
needed.
2009-12-13 03:14:06 +00:00
Xin LI
6f2d322192 Remove unneeded header includes from usr.bin/ except contributed code.
Tested with:	make universe
2009-12-11 23:35:38 +00:00
Xin LI
948c1a68c6 Correct off-by-one issue in truss(1) which happens when system call number
is nsyscalls.

PR:		bin/134916
Submitted by:	Steven Hartland <steven hartland multiplay co uk>
MFC after:	2 weeks
2009-05-28 00:38:24 +00:00
Xin LI
216fa4c607 Reduce diff against my local version: replace malloc+memset() cases to calloc(). 2009-05-15 19:41:10 +00:00
Diomidis Spinellis
1de3b2ff03 Fix print_syscall_ret parameter order. 2009-05-13 13:00:52 +00:00
Diomidis Spinellis
b53ae7114c Fix compilation error introduced in r192025. 2009-05-13 12:43:37 +00:00
Diomidis Spinellis
ee3b0f6e2e Add -c option to summarize number of calls, errors, and system time.
Reviewed by:	alfred
2009-05-12 20:42:12 +00:00
Xin LI
d5303c8027 Don't exit until all truss children were exit. 2009-04-13 16:23:32 +00:00
Xin LI
f0bcd5c3fa Correct a bug where pr_data should have been assigned. 2009-04-13 16:22:38 +00:00
Warner Losh
89fe547f2a Add preliminary support for truss on MIPS. It compiles, but has not
been extensively tested.  And the ELF64 stuff likely is not quite
right...

# There's a lot of cut-n-paste code here that could easily be
# refactored, at least for FreeBSD syscalls.
2009-02-15 01:26:49 +00:00
Tom Rhodes
a88e970c56 Attaching to the init process returns EINVAL,
so give an example that is more likely to work.
Stolen from the ktrace(1) manual page.

PR:		128222
Submitted by:	Mateusz Guzik <mjguzik@gmail.com>
2009-01-23 00:58:14 +00:00
Dag-Erling Smørgrav
d8984f48cb Try to make this code slightly less painful to read. 2008-07-31 17:15:21 +00:00
John Baldwin
8d0c1fa2be Retire some stale alpha references. 2008-05-16 20:09:29 +00:00