Commit Graph

60 Commits

Author SHA1 Message Date
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
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
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
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
0a6c71f8fa Fix copyright spelling.
PR:		139825
Submitted by:	Ruslan Mahmatkhanov
2010-03-10 20:31:30 +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
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
216fa4c607 Reduce diff against my local version: replace malloc+memset() cases to calloc(). 2009-05-15 19:41:10 +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
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
John Baldwin
8d0c1fa2be Retire some stale alpha references. 2008-05-16 20:09:29 +00:00
John Baldwin
9a55503ec1 Teach truss about 32-bit FreeBSD and Linux binaries on amd64. Some
additional work is needed to handle ABI-specific syscall argument parsing,
but this gets the basic tracing working.

MFC after:	1 week
2008-05-16 15:34:06 +00:00
Marcel Moolenaar
3e1b607837 Syscalls have at most 6 argument, not 5. See mmap(2) for example.
Previously the offset argument to mmap(2) would be bogus as we
weren't reading it in.

Approved by: re (kensmith)
2007-07-28 23:00:42 +00:00
Xin LI
ef29ac7f76 MFp4: Bugfixes for truss(1):
- Fix logic handling execve().  We will not be able to
   obtain information otherwise.
 - truss coredump [1].
 - truss does not work against itself [2].

PR:		bin/58970 [1], bin/45193 [2]
Submitted by:	Howard Su
Approved by:	re (kensmith)
2007-06-26 22:42:37 +00:00
Xin LI
5d2d083c92 Make use of ptrace(2) instead of procfs in truss(1), eliminating
yet another need of an available /proc/ mount.

Tested with:	make universe
Submitted by:	howardsu
Reviewed by:	alfred
2007-04-10 04:03:34 +00:00
Pav Lucistnik
081e5c4890 - Add decoding of kse_release, kevent, sigprocmask, unmount, socket, getrusage,
rename, __getcwd, shutdown, getrlimit, setrlimit, _umtx_lock, _umtx_unlock,
  pathconf, truncate, ftruncate, kill

- Decode more arguments of open, mprot, *stat, and fcntl.

- Convert all constant-macro and bitfield decoding to lookup tables; much
  cleaner than previous code.

- Print the timestamp of process exit and signal reception when -d or -D are in
  use

- Try six times with 1/2 second delay to debug the child

PR:		bin/52190 (updated)
Submitted by:	Dan Nelson <dnelson@allantgroup.com>
Approved by:	alfred
2006-05-15 21:18:28 +00:00
Peter Grehan
7fa9dc1c36 Add powerpc support for truss.
Initial work by:  Orlando Bassotto  < orlando at break net >
Modified by:	  grehan
2006-01-05 05:57:47 +00:00
Brian Somers
0cf21b4f58 Add a -s flag for the same functionality as strace. Introduce a Name
type which is a String type that has no -s limitations applied to it.
Change most Strings in the code to Names and add a few extra syscalls,
namely munmap, read, rename and symlink.  This was enough to facilitate
following file descriptor allocations in the code more easily and
getting a hint at what's being read/written from/to files.  More
syscalls should really be added.

While here, fix an off-by-one bug in the buffer truncation code and
add a fflush so that truss's output reflects the syscall that the
program is stuck in.

Sponsored by:	Sophos/Activestate
MFC after:	2 weeks
2006-01-02 08:36:25 +00:00
Alfred Perlstein
72aa911a29 When doing the initial open of the proc via procfs, complain if we are
unable to open the /proc/pid/mem file.  Otherwise doing a truss on
a nonexistant pid makes us return success even though no such process
exists.
2005-03-27 12:53:25 +00:00
Alfred Perlstein
5321ae8649 I've been working on this somewhat so I'm moving the
parts I'm touching to be as style(9) compliant as I can.
2005-03-27 12:47:04 +00:00
Alfred Perlstein
d75300bfa5 When reporting reciept of a signal, print the signal's name. 2004-07-17 19:19:36 +00:00
David Malone
a5d31d1631 A first stab at truss support for amd64, basically cogged from i386.
It seems to work in my limited tests.
2004-06-12 22:49:06 +00:00
Martin Cracauer
5cdf6a132b Fix signal behaviour.
In my last change I made sure that the signal as reported from a truss
exit is the same as if truss wasn't between parent and trussed
program.  I was smart enough to not have it coredump on SIGQUIT but it
didn't ocur to me SIGSEGV might cause a coredump, too :-)

So get rid of SIGQUIT extra hack and limit coredumpsize to zero
instead.

Tested: still works, correct signal reported.  No more codedumps from
SIGSEGV in the trussed proces.  This file compiles cleanly on AMD64
(sledge).

PR:
Submitted by:
Reviewed by:
Approved by:
Obtained from:
MFC after:
2003-12-28 01:20:03 +00:00
Marcel Moolenaar
1bcb5f5a96 Port truss(1) to 64-bit architectures:
o  Syscall return values do not fit in int on 64-bit architectures.
   Change the type of retval in <arch>_syscall_exit() to long and
   change the prototype of said function to return a long as well.
o  Change the prototype of print_syscall_ret() to take a long for
   the return address and change the format string accordingly.
o  Replace the code sequence
	tmp = malloc(X);
	sprintf(tmp, format, ...);
   with X by definition too small on 64-bit platforms by
        asprintf(&tmp, format, ...);

With these changes the output makes sense again, although it does
mess up the tabulation on ia64. Go widescreen...

Not tested on: alpha, sparc64.
2003-11-09 03:48:13 +00:00
Philippe Charnier
b956c13cfe Add FBSDID. Do not \n terminate warnx() argument. fprint() -> warnx(). 2003-09-07 15:50:43 +00:00
Marcel Moolenaar
a3e32192a5 Port to ia64. It builds, but usability is very limited. 2002-11-10 00:59:13 +00:00
Mike Barcroft
1d631f7ef1 Don't depend on <signal.h> to include <sys/time.h>, instead include
<sys/time.h> directly.  This is mostly bogus since CLOCK_REALTIME
should be defined in <time.h>, which these files already include.
2002-10-06 21:46:04 +00:00
Matthew N. Dodd
37169f9446 - Use time.h not sys/time.h.
- Fix printf format errors.

Submitted by:	 bde
2002-08-06 12:46:14 +00:00
Matthew N. Dodd
203098d816 Use timespec not timeval. 2002-08-05 12:22:55 +00:00
Jake Burkholder
f84c971a6f Ported to sparc64. 2002-08-04 17:57:01 +00:00
Bruce Evans
c69d844294 Include <sys/time.h> for the declaration of struct timeval. Do not
depend on namespace pollution in <signal.h>.  (truss shouldn't be
using timevals anyway, since it was implemented long after timevals
were obsoleted by timespecs.)
2002-08-04 10:57:41 +00:00
Matthew N. Dodd
9897b20356 Add options to print the argument and environment string parameters to
execve().

This could be done in a more general manner but it still wouldn't
be very pretty.

MFC after:	 3 weeks
2002-08-04 02:24:21 +00:00
Matthew N. Dodd
0629483c41 Add a "FreeBSD ELF32" entry to ex_types[]. 2002-08-04 02:20:06 +00:00
Matthew N. Dodd
0d0bd00edd Add options to print absolute and relative timestamps.
PR:		 bin/25587 (in part)
MFC after:	 3 weeks
2002-08-04 01:27:31 +00:00
Matthew N. Dodd
c03bfcc871 Allow tracking fork()ed children.
PR:		 bin/25587 (in part)
MFC after:	3 weeks
2002-08-04 01:02:52 +00:00
Matthew N. Dodd
ec0bed25ba Parameterize globals.
PR:		bin/25587 (in part)
MFC after:	3 weeks
2002-08-04 00:46:48 +00:00
Mark Murray
bfc3d86a24 s/inline/__inline/ 2002-07-19 13:49:37 +00:00
Peter Wemm
f81e3ffe10 OOPS! rev 1.16 accidently changed the default outfile from stderr to
stdout.  Unfortunately, DES mfc'ed this change in 1.15.2.1 (this
part probably should not have been) so it is broken there too.
truss is documented to use stderr, and other implementations use stderr.

Submitted by:	Arne Dag Fidjestøl <adf@idi.ntnu.no>
2002-05-16 21:58:57 +00:00
Dag-Erling Smørgrav
4525f3a803 Fix the code that selects the default binary type if the actual type can't
be determined.

PR:		bin/34698
Submitted by:	(in part) Stefan Farfeleder <e0026813@stud3.tuwien.ac.at>
MFC after:	1 weeks
2002-02-08 12:42:55 +00:00
Mark Murray
1be5d70444 Partial WARNS=1 fizes with NO_WERROR set to prevent world breakage.
Use __FBSDID().
2001-12-11 23:34:02 +00:00
Dag-Erling Smørgrav
6303ee4e2a Back out part of previous commit: remove #include <sys/proc.h>. 2001-10-22 15:32:12 +00:00
Dag-Erling Smørgrav
580e0a2b7a #include <sys/proc.h> where needed (for the stop event definitions) and
reorder includes everywhere to conform to style(9).
2001-10-22 02:02:00 +00:00
Peter Wemm
9a2e7f1520 Initialize outfile in main() 2001-08-13 21:59:04 +00:00
Sean Eric Fagan
893618352c Handle the case where we truss an SUGID program -- in particular, we need
to wake up any processes waiting via PIOCWAIT on process exit, and truss
needs to be more aware that a process may actually disappear while it's
waiting.

Reviewed by:	Paul Saab <ps@yahoo-inc.com>
2000-01-10 04:09:05 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Mike Smith
dcbdc0b9b5 Flush the output file before exiting; short-lived programs don't even fill
the stdio buffer.
1998-12-21 06:34:50 +00:00
Sean Eric Fagan
50cc4492c6 Alpha support for truss. I tested this on both bento and beast (thanks,
Jordan, for pointing me at beast!).  There should be no change for the
i386 version.
1998-10-03 00:43:05 +00:00
Sean Eric Fagan
3625b5147c Use a default execution type if none of the listed ones match. This
uses the first type listed in the array as the default type.  This isn't
perfect, but I thought it would be better than nothing.
1998-09-07 05:49:43 +00:00