Commit Graph

246 Commits

Author SHA1 Message Date
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