Deleted Added
sdiff udiff text old ( 288424 ) new ( 288832 )
full compact
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 $");
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 }
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
375 if (sc && !(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;
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;
420
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;
434 }
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 ---