2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright (c) 2012, Joyent, Inc. All rights reserved.
16 #
pragma D option strsize
=4k
17 #
pragma D option quiet
18 #
pragma D option destructive
21 * This test reads a JSON string from a USDT probe, roughly simulating the
22 * primary motivating use case for the json() subroutine: filtering
23 * JSON-formatted log messages from a logging subsystem like node-bunyan.
26 pid
$1:a
.out:waiting
:entry
28 this->value
= (int *)alloca(sizeof (int));
30 copyout(this->value
, arg0
, sizeof (int));
35 this->j
= copyinstr(arg0
);
39 /json(this->j
, "finished") == NULL
&& json(this->j
, "action") != "ignore"/
41 this->index
= strtoll(json(this->j
, "index"));
42 this->size
= json(this->j
, "sizes[2]");
43 this->odd
= json(this->j
, "facts.odd");
44 this->even
= json(this->j
, "facts.even");
45 printf("[%d] sz %s odd %s even %s\n", this->index
, this->size
,
46 this->odd
, this->even
);
50 /json(this->j
, "finished") != NULL
/
52 printf("FINISHED!\n");
58 printf("ERROR: Timed out before finish message!\n");