Deleted Added
full compact
setup.c (288424) setup.c (288832)
1/*-
2 * Copyright 1997 Sean Eric Fagan
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 16 unchanged lines hidden (view full) ---

25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#include <sys/cdefs.h>
1/*-
2 * Copyright 1997 Sean Eric Fagan
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 16 unchanged lines hidden (view full) ---

25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/usr.bin/truss/setup.c 288424 2015-09-30 19:13:32Z jhb $");
33__FBSDID("$FreeBSD: head/usr.bin/truss/setup.c 288832 2015-10-05 18:08:35Z bdrewery $");
34
35/*
36 * Various setup functions for truss. Not the cleanest-written code,
37 * I'm afraid.
38 */
39
40#include <sys/ptrace.h>
41#include <sys/sysctl.h>

--- 294 unchanged lines hidden (view full) ---

336 }
337
338 if (t->cs.number >= 0 && t->cs.number < t->proc->abi->nsyscalls)
339 t->cs.name = t->proc->abi->syscallnames[t->cs.number];
340 if (t->cs.name == NULL)
341 fprintf(info->outfile, "-- UNKNOWN %s SYSCALL %d --\n",
342 t->proc->abi->type, t->cs.number);
343
34
35/*
36 * Various setup functions for truss. Not the cleanest-written code,
37 * I'm afraid.
38 */
39
40#include <sys/ptrace.h>
41#include <sys/sysctl.h>

--- 294 unchanged lines hidden (view full) ---

336 }
337
338 if (t->cs.number >= 0 && t->cs.number < t->proc->abi->nsyscalls)
339 t->cs.name = t->proc->abi->syscallnames[t->cs.number];
340 if (t->cs.name == NULL)
341 fprintf(info->outfile, "-- UNKNOWN %s SYSCALL %d --\n",
342 t->proc->abi->type, t->cs.number);
343
344 sc = get_syscall(t->cs.name);
345 if (sc) {
346 t->cs.nargs = sc->nargs;
347 assert(sc->nargs <= nitems(t->cs.s_args));
348 } else {
349#if DEBUG
350 fprintf(stderr, "unknown syscall %s -- setting "
351 "args to %d\n", t->cs.name, t->cs.nargs);
352#endif
353 t->cs.nargs = narg;
354 }
344 sc = get_syscall(t->cs.name, narg);
345 t->cs.nargs = sc->nargs;
346 assert(sc->nargs <= nitems(t->cs.s_args));
355
356 t->cs.sc = sc;
357
358 /*
359 * At this point, we set up the system call arguments.
360 * We ignore any OUT ones, however -- those are arguments that
361 * are set by the system call, and so are probably meaningless
362 * now. This doesn't currently support arguments that are

--- 4 unchanged lines hidden (view full) ---

367 fprintf(stderr, "syscall %s(", t->cs.name);
368#endif
369 for (i = 0; i < t->cs.nargs; i++) {
370#if DEBUG
371 fprintf(stderr, "0x%lx%s", sc ?
372 t->cs.args[sc->args[i].offset] : t->cs.args[i],
373 i < (t->cs.nargs - 1) ? "," : "");
374#endif
347
348 t->cs.sc = sc;
349
350 /*
351 * At this point, we set up the system call arguments.
352 * We ignore any OUT ones, however -- those are arguments that
353 * are set by the system call, and so are probably meaningless
354 * now. This doesn't currently support arguments that are

--- 4 unchanged lines hidden (view full) ---

359 fprintf(stderr, "syscall %s(", t->cs.name);
360#endif
361 for (i = 0; i < t->cs.nargs; i++) {
362#if DEBUG
363 fprintf(stderr, "0x%lx%s", sc ?
364 t->cs.args[sc->args[i].offset] : t->cs.args[i],
365 i < (t->cs.nargs - 1) ? "," : "");
366#endif
375 if (sc && !(sc->args[i].type & OUT)) {
367 if (!(sc->args[i].type & OUT)) {
376 t->cs.s_args[i] = print_arg(&sc->args[i],
377 t->cs.args, 0, info);
378 }
379 }
380#if DEBUG
381 fprintf(stderr, ")\n");
382#endif
383 }

--- 18 unchanged lines hidden (view full) ---

402 clock_gettime(CLOCK_REALTIME, &t->after);
403 p = t->proc;
404 if (p->abi->fetch_retval(info, retval, &errorp) < 0) {
405 free_syscall(t);
406 return;
407 }
408
409 sc = t->cs.sc;
368 t->cs.s_args[i] = print_arg(&sc->args[i],
369 t->cs.args, 0, info);
370 }
371 }
372#if DEBUG
373 fprintf(stderr, ")\n");
374#endif
375 }

--- 18 unchanged lines hidden (view full) ---

394 clock_gettime(CLOCK_REALTIME, &t->after);
395 p = t->proc;
396 if (p->abi->fetch_retval(info, retval, &errorp) < 0) {
397 free_syscall(t);
398 return;
399 }
400
401 sc = t->cs.sc;
410 if (sc == NULL) {
411 for (i = 0; i < t->cs.nargs; i++)
412 asprintf(&t->cs.s_args[i], "0x%lx", t->cs.args[i]);
413 } else {
414 /*
415 * Here, we only look for arguments that have OUT masked in --
416 * otherwise, they were handled in enter_syscall().
417 */
418 for (i = 0; i < sc->nargs; i++) {
419 char *temp;
402 /*
403 * Here, we only look for arguments that have OUT masked in --
404 * otherwise, they were handled in enter_syscall().
405 */
406 for (i = 0; i < sc->nargs; i++) {
407 char *temp;
420
408
421 if (sc->args[i].type & OUT) {
422 /*
423 * If an error occurred, then don't bother
424 * getting the data; it may not be valid.
425 */
426 if (errorp) {
427 asprintf(&temp, "0x%lx",
428 t->cs.args[sc->args[i].offset]);
429 } else {
430 temp = print_arg(&sc->args[i],
431 t->cs.args, retval, info);
432 }
433 t->cs.s_args[i] = temp;
409 if (sc->args[i].type & OUT) {
410 /*
411 * If an error occurred, then don't bother
412 * getting the data; it may not be valid.
413 */
414 if (errorp) {
415 asprintf(&temp, "0x%lx",
416 t->cs.args[sc->args[i].offset]);
417 } else {
418 temp = print_arg(&sc->args[i],
419 t->cs.args, retval, info);
434 }
420 }
421 t->cs.s_args[i] = temp;
435 }
436 }
437
438 print_syscall_ret(info, t->cs.name, t->cs.nargs, t->cs.s_args,
439 errorp, retval, sc);
440 free_syscall(t);
441
442 /*

--- 166 unchanged lines hidden ---
422 }
423 }
424
425 print_syscall_ret(info, t->cs.name, t->cs.nargs, t->cs.s_args,
426 errorp, retval, sc);
427 free_syscall(t);
428
429 /*

--- 166 unchanged lines hidden ---