summaryrefslogtreecommitdiffstats
path: root/usr.bin/truss/main.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2006-01-02 08:36:25 +0000
committerbrian <brian@FreeBSD.org>2006-01-02 08:36:25 +0000
commit2a326134d0e35fa054037847b1446e8c4b4d61df (patch)
treef225c3e75d0afc9fd39abffd240d054d382656bb /usr.bin/truss/main.c
parent0cacee70e6bb1e0af3e1d315cdcdad02bac4ba3c (diff)
downloadFreeBSD-src-2a326134d0e35fa054037847b1446e8c4b4d61df.zip
FreeBSD-src-2a326134d0e35fa054037847b1446e8c4b4d61df.tar.gz
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
Diffstat (limited to 'usr.bin/truss/main.c')
-rw-r--r--usr.bin/truss/main.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.bin/truss/main.c b/usr.bin/truss/main.c
index 9d289a7..6866e71 100644
--- a/usr.bin/truss/main.c
+++ b/usr.bin/truss/main.c
@@ -70,8 +70,8 @@ static void
usage(void)
{
fprintf(stderr, "%s\n%s\n",
- "usage: truss [-faedDS] [-o file] -p pid",
- " truss [-faedDS] [-o file] command [args]");
+ "usage: truss [-faedDS] [-o file] [-s strsize] -p pid",
+ " truss [-faedDS] [-o file] [-s strsize] command [args]");
exit(1);
}
@@ -181,8 +181,9 @@ main(int ac, char **av)
errx(1, "malloc() failed");
bzero(trussinfo, sizeof(struct trussinfo));
trussinfo->outfile = stderr;
+ trussinfo->strsize = 32;
- while ((c = getopt(ac, av, "p:o:faedDS")) != -1) {
+ while ((c = getopt(ac, av, "p:o:faedDs:S")) != -1) {
switch (c) {
case 'p': /* specified pid */
trussinfo->pid = atoi(optarg);
@@ -205,6 +206,9 @@ main(int ac, char **av)
case 'o': /* Specified output file */
fname = optarg;
break;
+ case 's': /* Specified string size */
+ trussinfo->strsize = atoi(optarg);
+ break;
case 'S': /* Don't trace signals */
trussinfo->flags |= NOSIGS;
break;
OpenPOWER on IntegriCloud