Fri Jul 24 11:34:03 2009 UTC ()
Delay emulation record output, to be processed after the current
syscall; to avoid picking syscall name from the wrong emulation table.


(njoly)
diff -r1.35 -r1.36 src/usr.bin/ktruss/dump.c

cvs diff -r1.35 -r1.36 src/usr.bin/ktruss/dump.c (expand / switch to unified diff)

--- src/usr.bin/ktruss/dump.c 2009/05/02 21:01:01 1.35
+++ src/usr.bin/ktruss/dump.c 2009/07/24 11:34:03 1.36
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: dump.c,v 1.35 2009/05/02 21:01:01 mlelstv Exp $ */ 1/* $NetBSD: dump.c,v 1.36 2009/07/24 11:34:03 njoly Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1988, 1993 4 * Copyright (c) 1988, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34__COPYRIGHT("@(#) Copyright (c) 1988, 1993\ 34__COPYRIGHT("@(#) Copyright (c) 1988, 1993\
35 The Regents of the University of California. All rights reserved."); 35 The Regents of the University of California. All rights reserved.");
36#endif /* not lint */ 36#endif /* not lint */
37 37
38#ifndef lint 38#ifndef lint
39#if 0 39#if 0
40static char sccsid[] = "@(#)kdump.c 8.4 (Berkeley) 4/28/95"; 40static char sccsid[] = "@(#)kdump.c 8.4 (Berkeley) 4/28/95";
41#endif 41#endif
42__RCSID("$NetBSD: dump.c,v 1.35 2009/05/02 21:01:01 mlelstv Exp $"); 42__RCSID("$NetBSD: dump.c,v 1.36 2009/07/24 11:34:03 njoly Exp $");
43#endif /* not lint */ 43#endif /* not lint */
44 44
45#include <sys/param.h> 45#include <sys/param.h>
46#define _KERNEL 46#define _KERNEL
47#include <sys/errno.h> 47#include <sys/errno.h>
48#undef _KERNEL 48#undef _KERNEL
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <sys/uio.h> 51#include <sys/uio.h>
52#include <sys/ktrace.h> 52#include <sys/ktrace.h>
53#include <sys/ptrace.h> 53#include <sys/ptrace.h>
54#include <sys/queue.h> 54#include <sys/queue.h>
55 55
@@ -278,27 +278,27 @@ dumprecord(int trpoints, FILE *fp) @@ -278,27 +278,27 @@ dumprecord(int trpoints, FILE *fp)
278 case KTR_NAMEI: 278 case KTR_NAMEI:
279 putpendq(kte); 279 putpendq(kte);
280 break; 280 break;
281 case KTR_GENIO: 281 case KTR_GENIO:
282 putpendq(kte); 282 putpendq(kte);
283 break; 283 break;
284 case KTR_PSIG: 284 case KTR_PSIG:
285 ktrpsig(kte); 285 ktrpsig(kte);
286 break; 286 break;
287 case KTR_CSW: 287 case KTR_CSW:
288 ktrcsw(kte); 288 ktrcsw(kte);
289 break; 289 break;
290 case KTR_EMUL: 290 case KTR_EMUL:
291 ktremul(kte); 291 putpendq(kte);
292 break; 292 break;
293 default: 293 default:
294 /* 294 /*
295 * XXX: Other types added recently. 295 * XXX: Other types added recently.
296 */ 296 */
297 free(kte); 297 free(kte);
298 break; 298 break;
299 } 299 }
300 newline(); 300 newline();
301 301
302out: 302out:
303 return (1); 303 return (1);
304} 304}
@@ -639,26 +639,27 @@ sysretprint(struct ktr_header *kth) @@ -639,26 +639,27 @@ sysretprint(struct ktr_header *kth)
639 wprintf(" = %ld", (long)ret); 639 wprintf(" = %ld", (long)ret);
640 if (kth->ktr_len > (int)offsetof(struct ktr_sysret, 640 if (kth->ktr_len > (int)offsetof(struct ktr_sysret,
641 ktr_retval_1) && ktr->ktr_retval_1 != 0) 641 ktr_retval_1) && ktr->ktr_retval_1 != 0)
642 wprintf(", %ld", (long)ktr->ktr_retval_1); 642 wprintf(", %ld", (long)ktr->ktr_retval_1);
643 break; 643 break;
644 } 644 }
645} 645}
646 646
647void 647void
648ktrsysret(struct ktr_entry *kte) 648ktrsysret(struct ktr_entry *kte)
649{ 649{
650 struct ktr_header *kth = &kte->kte_kth; 650 struct ktr_header *kth = &kte->kte_kth;
651 struct ktr_sysret *ktr = (struct ktr_sysret *)(kth + 1); 651 struct ktr_sysret *ktr = (struct ktr_sysret *)(kth + 1);
 652 struct ktr_entry *emul;
652 struct ktr_entry *genio; 653 struct ktr_entry *genio;
653 struct ktr_entry *syscall_ent; 654 struct ktr_entry *syscall_ent;
654 655
655 dumpheader(kth); 656 dumpheader(kth);
656 657
657 /* Print syscall name and arguments. */ 658 /* Print syscall name and arguments. */
658 syscall_ent = getpendq(kth, KTR_SYSCALL, NULL); 659 syscall_ent = getpendq(kth, KTR_SYSCALL, NULL);
659 if (syscall_ent == NULL) { 660 if (syscall_ent == NULL) {
660 /* 661 /*
661 * Possibilly a child of fork/vfork, or tracing of 662 * Possibilly a child of fork/vfork, or tracing of
662 * process started during system call. 663 * process started during system call.
663 */ 664 */
664 syscallnameprint(ktr->ktr_code); 665 syscallnameprint(ktr->ktr_code);
@@ -666,26 +667,32 @@ ktrsysret(struct ktr_entry *kte) @@ -666,26 +667,32 @@ ktrsysret(struct ktr_entry *kte)
666 syscallprint(&syscall_ent->kte_kth); 667 syscallprint(&syscall_ent->kte_kth);
667 free(syscall_ent); 668 free(syscall_ent);
668 } 669 }
669 670
670 /* Print return value and an error if any. */ 671 /* Print return value and an error if any. */
671 sysretprint(kth); 672 sysretprint(kth);
672 673
673 genio = getpendq(kth, KTR_GENIO, NULL); 674 genio = getpendq(kth, KTR_GENIO, NULL);
674 if (genio != NULL) { 675 if (genio != NULL) {
675 genioprint(&genio->kte_kth); 676 genioprint(&genio->kte_kth);
676 free(genio); 677 free(genio);
677 } 678 }
678 679
 680 emul = getpendq(kth, KTR_EMUL, NULL);
 681 if (emul != NULL) {
 682 newline();
 683 ktremul(emul);
 684 }
 685
679 flushpendq(kte); 686 flushpendq(kte);
680 free(kte); 687 free(kte);
681} 688}
682 689
683void 690void
684nameiprint(struct ktr_header *kth) 691nameiprint(struct ktr_header *kth)
685{ 692{
686 693
687 wprintf("\"%.*s\"", kth->ktr_len, (char *)(kth + 1)); 694 wprintf("\"%.*s\"", kth->ktr_len, (char *)(kth + 1));
688} 695}
689 696
690#ifdef notused 697#ifdef notused
691void 698void