1266989Smarkj#! /usr/bin/ksh 2266989Smarkj# 3266989Smarkj# 4266989Smarkj# This file and its contents are supplied under the terms of the 5266989Smarkj# Common Development and Distribution License ("CDDL"), version 1.0. 6266989Smarkj# You may only use this file in accordance with the terms of version 7266989Smarkj# 1.0 of the CDDL. 8266989Smarkj# 9266989Smarkj# A full copy of the text of the CDDL should have accompanied this 10266989Smarkj# source. A copy of the CDDL is also available via the Internet at 11266989Smarkj# http://www.illumos.org/license/CDDL. 12266989Smarkj# 13266989Smarkj 14266989Smarkj# 15266989Smarkj# Copyright (c) 2013 Joyent, Inc. All rights reserved. 16266989Smarkj# 17266989Smarkj 18266989Smarkj# 19266989Smarkj# Simple test that if we manually use the userland keyword that it 20266989Smarkj# works. 21266989Smarkj# 22266989Smarkj 23266989Smarkjif [ $# != 1 ]; then 24266989Smarkj echo expected one argument: '<'dtrace-path'>' 25266989Smarkj exit 2 26266989Smarkjfi 27266989Smarkj 28266989Smarkjdtrace=$1 29266989Smarkjt="zelda_info_t" 30266989Smarkjexe="tst.chasestrings.exe" 31266989Smarkj 32271693Smarkjelfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' 33266989Smarkjif [[ $? -ne 0 ]]; then 34266989Smarkj echo "CTF does not exist in $exe, that's a bug" >&2 35266989Smarkj exit 1 36266989Smarkjfi 37266989Smarkj 38266989Smarkj./$exe & 39266989Smarkjpid=$! 40266989Smarkj 41272488Smarkj$dtrace -qs /dev/stdin <<EOF 42266989Smarkjtypedef struct info { 43266989Smarkj char *zi_gamename; 44266989Smarkj int zi_ndungeons; 45266989Smarkj char *zi_villain; 46266989Smarkj int zi_haszelda; 47266989Smarkj} info_t; 48266989Smarkj 49266989Smarkjpid$pid::has_princess:entry 50266989Smarkj/next == 0/ 51266989Smarkj{ 52266989Smarkj this->t = (userland info_t *)arg0; 53266989Smarkj printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", 54266989Smarkj stringof(this->t->zi_gamename), this->t->zi_ndungeons, 55266989Smarkj stringof(this->t->zi_villain), this->t->zi_haszelda); 56266989Smarkj next = 1; 57266989Smarkj} 58266989Smarkj 59266989Smarkjpid$pid::has_dungeons:entry 60266989Smarkj/next == 1/ 61266989Smarkj{ 62266989Smarkj this->t = (userland info_t *)arg0; 63266989Smarkj printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", 64266989Smarkj stringof(this->t->zi_gamename), this->t->zi_ndungeons, 65266989Smarkj stringof(this->t->zi_villain), this->t->zi_haszelda); 66266989Smarkj next = 2; 67266989Smarkj} 68266989Smarkj 69266989Smarkjpid$pid::has_villain:entry 70266989Smarkj/next == 2/ 71266989Smarkj{ 72266989Smarkj this->t = (userland info_t *)arg0; 73266989Smarkj printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", 74266989Smarkj stringof(this->t->zi_gamename), this->t->zi_ndungeons, 75266989Smarkj stringof(this->t->zi_villain), this->t->zi_haszelda); 76266989Smarkj exit(0); 77266989Smarkj} 78266989SmarkjEOF 79266989Smarkjrc=$? 80266989Smarkj 81266989Smarkjkill -9 $pid 82266989Smarkj 83266989Smarkjexit $rc 84