1*a386cc11SRobert Mustacchi#! /usr/bin/ksh 2*a386cc11SRobert Mustacchi# 3*a386cc11SRobert Mustacchi# 4*a386cc11SRobert Mustacchi# This file and its contents are supplied under the terms of the 5*a386cc11SRobert Mustacchi# Common Development and Distribution License ("CDDL"), version 1.0. 6*a386cc11SRobert Mustacchi# You may only use this file in accordance with the terms of version 7*a386cc11SRobert Mustacchi# 1.0 of the CDDL. 8*a386cc11SRobert Mustacchi# 9*a386cc11SRobert Mustacchi# A full copy of the text of the CDDL should have accompanied this 10*a386cc11SRobert Mustacchi# source. A copy of the CDDL is also available via the Internet at 11*a386cc11SRobert Mustacchi# http://www.illumos.org/license/CDDL. 12*a386cc11SRobert Mustacchi# 13*a386cc11SRobert Mustacchi 14*a386cc11SRobert Mustacchi# 15*a386cc11SRobert Mustacchi# Copyright (c) 2013 Joyent, Inc. All rights reserved. 16*a386cc11SRobert Mustacchi# 17*a386cc11SRobert Mustacchi 18*a386cc11SRobert Mustacchi# 19*a386cc11SRobert Mustacchi# This test is checking that we can read members and that pointers inside 20*a386cc11SRobert Mustacchi# members point to valid data that is intelligible, eg. strings. 21*a386cc11SRobert Mustacchi# 22*a386cc11SRobert Mustacchi 23*a386cc11SRobert Mustacchiif [ $# != 1 ]; then 24*a386cc11SRobert Mustacchi echo expected one argument: '<'dtrace-path'>' 25*a386cc11SRobert Mustacchi exit 2 26*a386cc11SRobert Mustacchifi 27*a386cc11SRobert Mustacchi 28*a386cc11SRobert Mustacchidtrace=$1 29*a386cc11SRobert Mustacchiexe="tst.chasestrings.exe" 30*a386cc11SRobert Mustacchi 31*a386cc11SRobert Mustacchielfdump "./$exe" | grep -q '.SUNW_ctf' 32*a386cc11SRobert Mustacchiif [[ $? -ne 0 ]]; then 33*a386cc11SRobert Mustacchi echo "CTF does not exist in $exe, that's a bug" >&2 34*a386cc11SRobert Mustacchi exit 1 35*a386cc11SRobert Mustacchifi 36*a386cc11SRobert Mustacchi 37*a386cc11SRobert Mustacchi./$exe & 38*a386cc11SRobert Mustacchipid=$! 39*a386cc11SRobert Mustacchi 40*a386cc11SRobert Mustacchi$dtrace -qs /dev/stdin <<EOF 41*a386cc11SRobert Mustacchipid$pid::has_princess:entry 42*a386cc11SRobert Mustacchi/next == 0/ 43*a386cc11SRobert Mustacchi{ 44*a386cc11SRobert Mustacchi printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", 45*a386cc11SRobert Mustacchi stringof(args[0]->zi_gamename), args[0]->zi_ndungeons, 46*a386cc11SRobert Mustacchi stringof(args[0]->zi_villain), args[0]->zi_haszelda); 47*a386cc11SRobert Mustacchi next = 1; 48*a386cc11SRobert Mustacchi} 49*a386cc11SRobert Mustacchi 50*a386cc11SRobert Mustacchipid$pid::has_dungeons:entry 51*a386cc11SRobert Mustacchi/next == 1/ 52*a386cc11SRobert Mustacchi{ 53*a386cc11SRobert Mustacchi printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", 54*a386cc11SRobert Mustacchi stringof(args[0]->zi_gamename), args[0]->zi_ndungeons, 55*a386cc11SRobert Mustacchi stringof(args[0]->zi_villain), args[0]->zi_haszelda); 56*a386cc11SRobert Mustacchi next = 2; 57*a386cc11SRobert Mustacchi} 58*a386cc11SRobert Mustacchi 59*a386cc11SRobert Mustacchipid$pid::has_villain:entry 60*a386cc11SRobert Mustacchi/next == 2/ 61*a386cc11SRobert Mustacchi{ 62*a386cc11SRobert Mustacchi printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", 63*a386cc11SRobert Mustacchi stringof(args[0]->zi_gamename), args[0]->zi_ndungeons, 64*a386cc11SRobert Mustacchi stringof(args[0]->zi_villain), args[0]->zi_haszelda); 65*a386cc11SRobert Mustacchi exit(0); 66*a386cc11SRobert Mustacchi} 67*a386cc11SRobert MustacchiEOF 68*a386cc11SRobert Mustacchirc=$? 69*a386cc11SRobert Mustacchi 70*a386cc11SRobert Mustacchikill -9 $pid 71*a386cc11SRobert Mustacchi 72*a386cc11SRobert Mustacchiexit $rc 73