Commit Graph

373 Commits

Author SHA1 Message Date
des
6c6abb3ddc 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
bcr
6f33a79b0a 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
f046771b04 Simplify various code that allowed for sys_signame being lower case.
This was changed in r218285.
2011-03-06 19:50:47 +00:00
jhb
6190d8e2a6 Properly check for errors from waitpid().
Submitted by:	gcooper
MFC after:	1 week
2011-02-15 12:42:18 +00:00
jilles
dbecc33067 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
jh
6664a6800a 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
jh
2b1dea9bfc 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
e24538c770 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
bcr
2ea7523b1b s/sytem/system in comments, no functional changes.
Reviewed by:    alfred@
2010-10-13 20:08:02 +00:00
nwhitehorn
7ce28b7066 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
imp
c3a399c4ba 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
nwhitehorn
4652fc6f95 Teach truss and xlint how to operate on 64-bit PowerPC systems. 2010-07-12 00:54:41 +00:00
imp
9563548aa0 Fix copyright spelling.
PR:		139825
Submitted by:	Ruslan Mahmatkhanov
2010-03-10 20:31:30 +00:00
rrs
b3974c3946 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
9b380e30d4 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
a5cc24440b 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
a0fa5bcb40 Allow proper tracing of posix_openpt(2). 2009-12-23 15:22:50 +00:00
jh
34da792643 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
jh
2eaf7d742e 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
jh
05e68d005a 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
jh
d51d2e56fc 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
delphij
0842b7d53f Revert most part of 200420 as requested, as more review and polish is
needed.
2009-12-13 03:14:06 +00:00
delphij
b963db4652 Remove unneeded header includes from usr.bin/ except contributed code.
Tested with:	make universe
2009-12-11 23:35:38 +00:00
delphij
1e64043f43 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
delphij
09f0a4d580 Reduce diff against my local version: replace malloc+memset() cases to calloc(). 2009-05-15 19:41:10 +00:00
dds
07e8ac4814 Fix print_syscall_ret parameter order. 2009-05-13 13:00:52 +00:00
dds
51f76634a5 Fix compilation error introduced in r192025. 2009-05-13 12:43:37 +00:00
dds
bea63f2169 Add -c option to summarize number of calls, errors, and system time.
Reviewed by:	alfred
2009-05-12 20:42:12 +00:00
delphij
feaa2ee03c Don't exit until all truss children were exit. 2009-04-13 16:23:32 +00:00
delphij
882a2894c3 Correct a bug where pr_data should have been assigned. 2009-04-13 16:22:38 +00:00
imp
442a51fa71 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
trhodes
9e3e63a72b 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
des
99ec4c843d Try to make this code slightly less painful to read. 2008-07-31 17:15:21 +00:00
jhb
7617274408 Retire some stale alpha references. 2008-05-16 20:09:29 +00:00
jhb
697ba009c1 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
des
f7514f1316 Revert CLEANDEPFILES commit per ru@'s request; it does not really solve
the problem.  The correct fix will follow.
2008-02-05 08:52:36 +00:00
des
0e657b23ab Normally, when a header file is removed from the build (as i4b headers
were recently), a simple 'make cleandepend; make depend' is sufficient
to keep the tree buildable after a cvs update when doing incremental
builds.

However, kdump and truss use a script which searches for header files
that define ioctls, and generates C code that includes them.  This
script will usually not need updating when a header file is removed,
so the normal dependency mechanism will not realize that it needs to
be re-run.  One is therefore left with code that references dead files
but will only be removed by a full 'make clean', which defeats the
purpose of incremental builds.

To work around this, modify the cleandepend target in bsd.dep.mk to
also remove any files listed in a new variable named CLEANDEPFILES,
and modify kdump's and truss's Makefiles accordingly.

MFC after:	2 weeks
2008-02-03 11:34:56 +00:00
jasone
7719fcccbc The break() system call takes a pointer argument, not an integer. This
change fixes output for break() on LP64 systems.
2008-01-03 00:18:03 +00:00
marcel
8be873747a Print integer-typed arguments as integers. This makes sure that
on 64-bit platforms the result is more reliable. For example,
-1 was previously printed as 0xffffffff.

Approved by: re (kensmith)
2007-07-28 23:18:39 +00:00
marcel
aa233d32b1 Fix handling of Quad-type arguments. Previously, syscalls
containing 64-bit arguments would have explicit padding.
On 64-bit platforms there was no padding, so the dummy
argument was not covering anything. On 32-bit platforms
with weak alignment (i.e. i386) the 64-bit argument did
not need to be aligned, so there too an aditional argument
was introduced. On 32-bit platforms with strong alignment
(i.e. PowerPC) the dummy argument in fact cover the padding.
By elimininating the dummy argument, 64-bit platforms now
have 1 argument less. This also applies to 32-bit platforms
with weak alignment. On PowerPC this doesn't matter, because
the padding is still there. We just don't "name" it.
Deal with those 3 cases.

Approved by: re (kensmith)
2007-07-28 23:15:04 +00:00
marcel
0333870131 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
delphij
affd0ee004 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
ru
05dcdedaca Don't want a stray systrace_args.c in objdir. 2007-05-22 10:36:12 +00:00
keramida
2049c78bad Remove duplicate ' 2' manpage section number.
Submitted by:	 Rui Paulo
MFC after:	 3 days
2007-05-21 20:33:51 +00:00
delphij
70cda62de5 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
ru
164381741c Add missing markup bits. 2006-12-11 11:34:44 +00:00
ru
33e34aeeb5 Markup fixes. 2006-09-29 15:20:48 +00:00
ru
aa1113efea Remove alpha-specific stuff. 2006-08-23 12:12:56 +00:00
delphij
9328356917 Make sure that the sc pointer gets initialized. No functional change
should happen with this change.
2006-07-26 08:58:00 +00:00
pav
988c4b7d34 - Fix warning when compiling with -DDEBUG
Approved by:	alfred
2006-05-15 22:09:45 +00:00
pav
a233d0a2ec - 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
pav
cb83f3a7fe - Fix crash when hitting unknown syscall. Copied from i386-fbsd.c
Approved by:	alfred
2006-05-15 21:03:02 +00:00
grehan
263293937d 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
2a326134d0 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
140118d69d The kernel accepts sockaddrs with len set to zero for sockaddr_in
types, so refactor the code here to grab them when length is zero.
2005-10-15 06:17:29 +00:00
keramida
ac7c9f771d Fix all the spelling mistakes I could find in the man pages for words
that have at least 3 characters.

MFC after:	1 week
Thanks to:	Music band ``Chingon''
		for keeping me company while searching for these.
2005-07-31 03:30:48 +00:00
alfred
5f6df97a58 Decode chroot(2) args.
Approved by: re
2005-06-14 21:51:08 +00:00
alfred
67f16567dc decode utimes, lutimes, futimes, chflags, lchflags. 2005-05-26 22:49:06 +00:00
alfred
2754f60f30 decode mkdir args. 2005-05-26 20:06:57 +00:00
alfred
12a374aa60 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
9e2b623bb5 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
6d55822ad3 Change fix a bug where the length of data written by snprintf was
being mishandled by using accumulation (into an uninitialized
variable) instead of direct assignment.

Reviewed by: scottl
2005-03-03 17:20:36 +00:00
ru
5db2b9d5b3 For variables that are only checked with defined(), don't provide
any fake value.
2004-10-24 15:33:08 +00:00
dd
aa2f219ed3 Improve markup and language. 2004-09-07 13:22:28 +00:00
marcel
4ac7064824 Fix Quad handling on 64-bit architectures. On 64-bit machines, a Quad
also occupies a single slot. There's no need for any special handling
of Quads. While here, remove the silly make_quad() function. We have
the 2 longs on 32-bit machines already lined up in the argument array,
so we can fetch the Quad with a simple cast.

Before:
  lseek(1,0x123456789,0xd0d0d0d0d0d0d0d0) = 4886718345 (0x123456789)
After:
  lseek(1,0x123456789,SEEK_SET)           = 4886718345 (0x123456789)
2004-09-05 05:27:30 +00:00
alfred
3e2660877b Update doc dates.
Pointed out by: ru
2004-09-03 18:56:59 +00:00
alfred
ba1009e692 xref and give a hint as to what procctl can be used for. 2004-09-03 17:52:55 +00:00
alfred
46edc34b3d don't seg if the syscall is invalid for i386fbsd. 2004-08-08 23:29:36 +00:00
stefanf
7cdc27d942 Use the length modifier 'll' instead of 'q' to print long longs. 2004-07-28 16:03:13 +00:00
alfred
f770c48d15 Support readlink(2) better. Readlink does not nul terminate the
result buffer, so we need to format it ourselves.  The problem is
that the length is stored as the return value from readlink, so we
need to pass the return value from our syscall into print_arg.

Motivated by: truss garbage on my screen from reading /etc/malloc.conf.
2004-07-17 19:48:49 +00:00
alfred
4c16bbdae3 When reporting reciept of a signal, print the signal's name. 2004-07-17 19:19:36 +00:00
alfred
008c1be05d Decode the "wence" arg to lseek and linux_lseek. 2004-07-10 09:23:53 +00:00
bms
ccb6e3ba12 Fix unterminated RCSID.
Submitted by:	Liam J. Foy
2004-06-13 18:06:49 +00:00
dwmalone
cfc5f034d6 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
phk
542eb308da COMPAT_SUNOS is gone. 2004-06-11 11:58:07 +00:00
dwmalone
31968bcd59 Add support for decoding Timespec, Timeval, Itimerval, Pollfd,
Fd_set and Sigaction structures. Use these for printing the arguments
to sigaction(), nanosleep(), select(), poll(), gettimeofday(),
clock_gettime(), recvfrom(), getitimer() and setitimer().

This is based on Dan's patch from the PR but I've hacked it for
style and some other issues. While Dan has checked this patch, any
goofs are probably my fault.

(The PR also contains support for the dual return values of pipe().
These will follow once I've ported that support to platforms other
than i386.)

PR:		52190
Submitted by:	Dan Nelson <dnelson@allantgroup.com>
2004-03-23 12:37:02 +00:00
dwmalone
7a220808b3 Use pread to implement pread, rather than taking a detour throug stdio.
PR:		52190
Submitted by:	Dan Nelson <dnelson@allantgroup.com>
2004-03-23 12:29:17 +00:00
alfred
422a2ca6b4 decode mprotect args while i'm here. 2004-03-23 09:16:18 +00:00
alfred
5b22f04d6d decode fcntl and mmap arguments. 2004-03-23 09:04:06 +00:00
dwmalone
1bfb55e5d9 Move declarations of Procfd to a header file. 2004-01-07 14:29:45 +00:00
dwmalone
6da7a0d11d Fix a printf format warning. 2004-01-07 14:27:30 +00:00
cracauer
bbe09cbe06 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
2748750ba3 Do not ignore any possible errors that fseeko() may have. The fact
is that fseeko() fails in very predictable and frequent ways on ia64.
This is because the offset is actually an address in the process'
address space, which on ia64 can be larger than long (for lseek) or
off_t (for fseeko). The crux is the signedness. The register stack
and memory stack are in region 4 on ia64. This means that the sign bit
is 1. The large positive virtual address is wrongly interpreted as
a negative file offset.

There's no quick fix. Even if you get around the API by using a
SEEK_SET up to LONG_MAX and follow it up with a SEEK_CUR for the
remainder, the kernel simply cannot deal with it. and the second
seek will just fail.

Therefore, this change does not actually fix the root cause. It just
makes sure we're not spitting out all kinds of garbage or that the
get_struct() function in particular does not cause truss(1) to exit.
This, I might add, invariably happened way too soon for truss(1) to
be of any use on ia64...
2003-11-13 09:04:24 +00:00
marcel
3f532e652b 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
marcel
d270e076a6 Fix truss so that it doesn't abort/exit when a syscall has been given
a NULL-pointer for a sockaddr argument.
2003-10-27 06:50:57 +00:00
charnier
45cdaa9545 Add FBSDID. Do not \n terminate warnx() argument. fprint() -> warnx(). 2003-09-07 15:50:43 +00:00
des
c8cb809e68 send() and recv() are just wrappers, not actual syscalls. 2003-08-05 19:34:36 +00:00
des
1f50902a45 Add recv(2), recvfrom(2), send(2) and sendfrom(2). 2003-08-05 10:45:06 +00:00
marcel
07563cc68f Fix truss on ia64. The syscall arguments are written to the trap
frame, occupying scratch registers r16 and up. We don't have to
save any scratch registers for syscalls, so we have plenty of
room there. Consequently, when we fetch the registers from the
process, we automaticly have all the arguments and don't need
to read them seperately.
2003-08-02 22:29:10 +00:00
marcel
a7ad93e446 Use cat(1) instead of cp(1) so as not to break -DNOCLEAN builds
when the file permissions of source files don't allow writing.
2003-06-06 05:38:09 +00:00
marcel
5d3af2c5ab Revamp of the syscall path, exception and context handling. The
prime objectives are:
o  Implement a syscall path based on the epc inststruction (see
   sys/ia64/ia64/syscall.s).
o  Revisit the places were we need to save and restore registers
   and define those contexts in terms of the register sets (see
   sys/ia64/include/_regset.h).

Secundairy objectives:
o  Remove the requirement to use contigmalloc for kernel stacks.
o  Better handling of the high FP registers for SMP systems.
o  Switch to the new cpu_switch() and cpu_throw() semantics.
o  Add a good unwinder to reconstruct contexts for the rare
   cases we need to (see sys/contrib/ia64/libuwx)

Many files are affected by this change. Functionally it boils
down to:
o  The EPC syscall doesn't preserve registers it does not need
   to preserve and places the arguments differently on the stack.
   This affects libc and truss.
o  The address of the kernel page directory (kptdir) had to
   be unstaticized for use by the nested TLB fault handler.
   The name has been changed to ia64_kptdir to avoid conflicts.
   The renaming affects libkvm.
o  The trapframe only contains the special registers and the
   scratch registers. For syscalls using the EPC syscall path
   no scratch registers are saved. This affects all places where
   the trapframe is accessed. Most notably the unaligned access
   handler, the signal delivery code and the debugger.
o  Context switching only partly saves the special registers
   and the preserved registers. This affects cpu_switch() and
   triggered the move to the new semantics, which additionally
   affects cpu_throw().
o  The high FP registers are either in the PCB or on some
   CPU. context switching for them is done lazily. This affects
   trap().
o  The mcontext has room for all registers, but not all of them
   have to be defined in all cases. This mostly affects signal
   delivery code now. The *context syscalls are as of yet still
   unimplemented.

Many details went into the removal of the requirement to use
contigmalloc for kernel stacks. The details are mostly CPU
specific and limited to exception_save() and exception_restore().
The few places where we create, destroy or switch stacks were
mostly simplified by not having to construct physical addresses
and additionally saving the virtual addresses for later use.

Besides more efficient context saving and restoring, which of
course yields a noticable speedup, this also fixes the dreaded
SMP bootup problem as a side-effect. The details of which are
still not fully understood.

This change includes all the necessary backward compatibility
code to have it handle older userland binaries that use the
break instruction for syscalls. Support for break-based syscalls
has been pessimized in favor of a clean implementation. Due to
the overall better performance of the kernel, this will still
be notived as an improvement if it's noticed at all.

Approved by: re@ (jhb)
2003-05-16 21:26:42 +00:00
mdodd
ba18538620 Decode a few more syscalls. 2003-04-15 06:12:12 +00:00
ru
e4c356edeb Removed extra parentheses. 2003-02-20 15:09:52 +00:00
ru
b36c276cc5 Fixed comment. 2003-02-20 15:05:39 +00:00
ru
b67068895d mdoc(7) police: markup polishing.
Approved by:	re
2002-11-26 17:33:37 +00:00
marcel
9400cb3a69 Port to ia64. It builds, but usability is very limited. 2002-11-10 00:59:13 +00:00
dwmalone
24262691d4 Various cleanups of truss:
1) Missing include.
2) Constness.
3) ANSIfication.
4) Avoid some shadowing.
5) Add/clarify some error messages.
6) Some int functions were using return without a value.
7) Mark some parameters as unused.
8) Cast a value we know is non-negative to a size_t before comparing.
2002-11-09 22:46:51 +00:00
dwmalone
7fa8d22f67 Check if name is NULL before we strcmp the syscall name. This was
sometimes triggered if you began trussing a process while it was
in a syscall, as the name is filled in when the syscall is made.
2002-11-09 22:28:38 +00:00
mike
d72c913927 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
mdodd
582f479cac Remove an unnecessary cast. 2002-08-07 11:35:18 +00:00
mdodd
d20661ba22 - Use time.h not sys/time.h.
- Fix printf format errors.

Submitted by:	 bde
2002-08-06 12:46:14 +00:00
mdodd
e46b84ca00 Remove extra space in output. 2002-08-05 14:56:20 +00:00
mdodd
a4b3e13b54 Diff reduction. 2002-08-05 13:23:41 +00:00
mdodd
2ba9baa8d3 Use timespec not timeval. 2002-08-05 12:22:55 +00:00
jake
38c44f7803 Ported to sparc64. 2002-08-04 17:57:01 +00:00
bde
4418f4740b 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
mdodd
c3ab10b179 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
mdodd
b4aa304f72 Add a "FreeBSD ELF32" entry to ex_types[]. 2002-08-04 02:20:06 +00:00
mdodd
ca2c836450 Terminate the output line when a non-returning syscall is printed. 2002-08-04 01:28:13 +00:00
mdodd
3cb287247d 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
mdodd
65f8611398 Allow tracking fork()ed children.
PR:		 bin/25587 (in part)
MFC after:	3 weeks
2002-08-04 01:02:52 +00:00
mdodd
357fc6060d Parameterize globals.
PR:		bin/25587 (in part)
MFC after:	3 weeks
2002-08-04 00:46:48 +00:00
markm
7b9c43466d s/inline/__inline/ 2002-07-19 13:49:37 +00:00
peter
7fc284ffb7 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
peter
22e8a6eda2 Do not bother with #include <machine/psl.h> since it is just a stub file
that says something like "/* Not used on Alpha */".
2002-05-01 06:23:48 +00:00
dwmalone
4c92f1efea Use fseeko and uintptr_t to make sure that we get a sensible offset
when trying to read from the stack.

PR:		37104
Submitted by:	Thomas Quinot <thomas@cuivre.fr.eu.org>
MFC after:	3 weeks
2002-04-21 19:04:26 +00:00
charnier
ad8a79e6a5 Use `The .Nm utility' 2002-04-20 12:18:28 +00:00
ru
ff35a38e49 I now don't seem to be able to reproduce the -DNOCLEAN buildworld
breakage with ioctl.c.  The .depend file should track dependencies
just fine, and the worst we can have is to miss new ioctls.

But I still think it's a good idea to have -DNOCLEAN build produce
the same ioctl.c as it would without -DNOCLEAN.

Prodded for a long time by:	bde
2002-04-11 14:49:32 +00:00
markm
31d81e4fbc Remove NO_WERRORs and WARNS=n's. To be revisited after GCC3. 2002-02-08 23:07:37 +00:00
des
3592b29f5e 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
alfred
275bf1142e Print open(2) flags in hex instread of decimal for clarity. 2001-12-30 23:11:52 +00:00
markm
87c4eaeeed Partial WARNS=1 fizes with NO_WERROR set to prevent world breakage.
Use __FBSDID().
2001-12-11 23:34:02 +00:00
des
69c40b2704 Print the correct return code for successful Linux syscalls.
Submitted by:	Vitezslav Novy <vita@fio.cz>
PR:		32036
MFC after:	1 week
2001-11-17 17:18:36 +00:00
green
b9c07fd74b Add missing include for <ctype.h>
Make sockaddr printing code unbad.

Always copy in sizeof(sockaddr_un) bytes for an AF_UNIX sockaddr,
despite what the length may be.
2001-11-06 19:26:51 +00:00
des
7a633d0499 Back out part of previous commit: remove #include <sys/proc.h>. 2001-10-22 15:32:12 +00:00
des
18f9515264 #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
des
90be41ff5d Teach truss(1) to display sockaddrs. It currently knows about AF_INET,
AF_INET6 and AF_UNIX sockaddrs, and will recognize accept(), bind(),
connect(), getpeername() and getsockname() as syscalls taking sockaddr
arguments.  Some enterprising soul might want to add (and test) support
for the send() / recv() family of syscalls as well.

MFC after:	1 week
2001-10-21 21:57:10 +00:00
joerg
c9d495ceb8 In get_string(), 0-terminate the contents of buf ``just in case'';
otherwise, if the very first fgetc() already yielded EOF, the returned
string won't get terminated at all.

MFC after:	1 day
2001-08-28 21:27:36 +00:00
peter
abfe61de7f Initialize outfile in main() 2001-08-13 21:59:04 +00:00
dd
911ca14c87 Remove whitespace at EOL. 2001-07-15 08:06:20 +00:00
ru
36f138439b mdoc(7) police: removed HISTORY info from the .Os call. 2001-07-10 14:16:33 +00:00
ru
e6cfc0711d Prepare for mdoc(7)NG. 2000-12-19 16:00:12 +00:00
ru
ee79097019 mdoc(7) police: use canonical form of .Dd macro. 2000-12-11 15:47:53 +00:00
ru
0d1334ca0c mdoc(7) police: use the new features of the Nm macro. 2000-11-20 19:21:22 +00:00
jkh
eeb064d69c cc -O -pipe -I/usr/src/usr.bin/kdump/../ktrace -I/usr/src/usr.bin/kdump/../.. Fix ioctl.c creation to deal with the depend case more properly.
Submitted by:   Ruslan Ermilov <ru@sunbay.com>
2000-09-14 18:53:08 +00:00
jkh
2a8c03de9e remove .PHONY to avoid gratuitous rebuild of ioctl.c each time.
Approved by:	sef
2000-09-14 06:20:19 +00:00
ru
1b4cdf40dc Make auto-generated ioctl.c to be always considered out of date
since it could potentially depend on any ${DESTDIR}/usr/include
preprocessor file.  This fixes the broken -DNOCLEAN world build
I experienced yesterday.
2000-08-01 10:21:13 +00:00
sef
855f88c9ee Change the output of truss to more closely resemble SysV's. (Yes, it
really is much nicer looking.)

Submitted by:	"Matthew N. Dodd" <winter@jurai.net>
2000-03-18 08:49:41 +00:00
sef
0446e158ad Fix a leak. (Thanks Bruce, this was a bonehead mistake on my part :).)
Submitted by:	Bruce Evans
2000-02-15 20:25:47 +00:00
mpp
8efad4996b Fxi various man pages to stop abusing the .Bx macro to generate
the string "FreeBSD".  Use the .Fx macro instead.  Also did some
minor re-wording/formatting to work around a deficiency with
the .Fx macro when it comes to puncuation characters other than
periods and commas.
2000-01-23 01:48:16 +00:00
sef
31b9ca1819 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
marcel
5d3899446e Fix for the new usage of mkioctls 1999-12-03 17:35:34 +00:00
marcel
17ed6e05da ${MACHINE} -> ${MACHINE_ARCH}
All Makefiles now use MACHINE_ARCH for the target architecture.
Unification is required for cross-building.

Tags added to:
	sys/boot/Makefile
	sys/boot/arc/loader/Makefile
	sys/kern/Makefile
	usr.bin/cpp/Makefile
	usr.bin/gcore/Makefile
	usr.bin/truss/Makefile

usr.bin/gcore/Makefile:
	fixed typo: MACHINDE -> MACHINE_ARCH
1999-11-14 13:54:44 +00:00
mpp
59a037c52b Add $FreeBSD$ lines to man pages that are missing them to make it
easier for translation teams.

PR:		docs/13418
Submitted by:	Alexey Zelkin <phantom@cris.net>
1999-08-28 23:23:38 +00:00
peter
3b842d34e8 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
des
6b0342e396 Teach truss to print symbolic signal names (e.g. SIGHUP instead of 0x01). 1999-08-10 16:57:37 +00:00
des
4df48d07f1 Add access(2) to the list of recognized syscalls. 1999-08-05 12:03:50 +00:00
msmith
131312c0d6 Flush the output file before exiting; short-lived programs don't even fill
the stdio buffer.
1998-12-21 06:34:50 +00:00
sef
9e0aee1ff0 Add lstat() as a known system call. 1998-10-15 04:31:44 +00:00
des
3ca80efd3a Calls one or more of malloc(), warn(), err(), syslog(), execlp() or
execvp() in the child branch of a vfork(). Changed to use fork()
instead.

Some of these (mv, find, apply, xargs) might benefit greatly from
being rewritten to use vfork() properly.

PR:		Loosely related to bin/8252
Approved by:	jkh and bde
1998-10-13 14:52:33 +00:00
kato
4df6ab63be Use MACHINE_ARCH instead of MACHINE to detect x86 arch.
Pointed out by:	Akio Morita <amorita@meadow.scphys.kyoto-u.ac.jp>
1998-10-07 13:46:09 +00:00
sef
74b596d2ae Make it compile -Wall cleanly.
Submitted by:	Alex Nash <nash@mcs.net>
1998-10-03 18:02:03 +00:00
sef
8c873c0b15 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
sef
82ccb4c632 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
cracauer
f3d290b0b5 When exiting on SIGINT, exit with signal status 1998-08-24 10:17:20 +00:00
bde
0609531ab6 Fixed printf format errors. 1998-07-06 21:01:54 +00:00
jb
fbf068fe64 Add a sysmk -> /dev/null definition ready for a coming change to
makesyscalls.sh.
1998-01-25 09:09:48 +00:00
sef
a20e740c7d Revert the changes yet again, after some email from Bruce. Sorry. 1998-01-09 09:31:42 +00:00
sef
6624495c00 Proper way to do the previous mis-commit. Still not quite right, because
some header files (e.g., <err.h>) include <machine/something.h>, and this
will not pick up the right header files, so it may be removed eventually
anyway.  But some people who are not willing to build the right way
apparantly want this, so this is for them.
1998-01-09 00:39:10 +00:00
sef
9a6b147880 Get rid of the bogus include -- it is incomplete (as it doesn't handle
anything other than <sys/*.h>), and unnecessary in most cases.  (The
situations where it is necesary can be dealt with by manually-made symlinks,
which is acceptable since they should only occur during testing.  Remember:
the tree does not compile well if you do not have matching header files
installed.  Half-baked -I directives don't cover enough of the cases.)
1998-01-09 00:22:50 +00:00
jmg
07395e5a81 include sys so it builds on 2.2.x
also, fix misspelling of -1 (as EOF for getopt)
1998-01-07 06:19:50 +00:00
charnier
50a2f19faf Sort Xrefs. Use err(3). Remove uneeded #include.
Correct usage: one of {-p pid, command} is required.
Open output file when command line is fully analyzed: incorrect `truss -o f'
command does not create an empty file anymore.
1998-01-05 07:30:26 +00:00
sef
297bd47472 Add some copyright and license terms, at Jordan's request. Note that
syscall.h just refers to another file for the copyright notice.
1997-12-20 18:40:43 +00:00
sef
f13ddbc865 Change the ioctls for procfs around a bit; in particular, whever possible,
change from

	ioctl(fd, PIOC<foo>, &i);

to

	ioctl(fd, PIOC<foo>, i);

This is going from the _IOW to _IO ioctl macro.  The kernel, procctl, and
truss must be in synch for it all to work (not doing so will get errors about
inappropriate ioctl's, fortunately).  Hopefully I didn't forget anything :).
1997-12-13 03:13:49 +00:00
peter
279e69b9ff s/ps/truss/ 1997-12-07 08:19:13 +00:00
sef
d1f6ae4ce3 Use the new PF_LINGER flag -- when this is set in a process' proc structure,
said process will not have its event mask cleared (and be restarted) on
the last close of a procfs/mem file for that pid.  This reduces the chance
that a truss-monitored process will be left hanging with these bits set
and nobody looking for it.

This is the least-tested change of all of these, I'm afraid.
1997-12-07 04:08:48 +00:00
sef
48a1f82a2e Complain about empty command lines. 1997-12-06 17:13:54 +00:00
peter
3ab5048d88 err(3) already includes strerror(errno) and a trailing \n 1997-12-06 14:42:58 +00:00
peter
9f0d9f2754 recognize "FreeBSD ELF" as an executable type
close() takes a fd, not a char * :-)
1997-12-06 14:41:41 +00:00
peter
bb664e8a40 #include <unistd.h> to get it to compile
Submitted by: Andreas Klemm <andreas@klemm.gtn.com>
1997-12-06 14:39:30 +00:00
sef
999cc45d0b Set the close-on-exec flag in the child; otherwise, it eats up a
file descriptor that it shouldn't.
1997-12-06 08:01:00 +00:00
sef
40d07bddd6 First cut at printing out ioctl names intelligently. Note that this doesn't
handle linux ioctls (yet?).  This uses the mkioctl script from kdump,
bless its little heart.

Reviewed by:	Mike Smith
1997-12-06 06:51:14 +00:00
sef
9e9a114f06 Truss program. Requires procfs. 1997-12-06 05:23:12 +00:00