1#!/usr/bin/ksh 2# 3# 4# This file and its contents are supplied under the terms of the 5# Common Development and Distribution License ("CDDL"), version 1.0. 6# You may only use this file in accordance with the terms of version 7# 1.0 of the CDDL. 8# 9# A full copy of the text of the CDDL should have accompanied this 10# source. A copy of the CDDL is also available via the Internet at 11# http://www.illumos.org/license/CDDL. 12# 13 14# 15# Copyright 2022 Oxide Computer Company 16# 17 18# 19# This test acts as a series of regression tests in DTrace around 20# printing bitfields that are byte sized at non-byte aligned offsets and 21# around printing fields that are less than a byte in size, but due to their 22# offset, cross a byte boundary (e.g. a 5-bit bitfield that starts at 23# bit 6). 24# 25# The DTrace implementation has two different general paths for this: 26# 27# o The D compiler compiling a dereference into DIF code to be executed 28# in probe context to extract a bitfield value. 29# o The print() action which grabs the larger chunk of memory and then 30# processes it all in userland. 31# 32 33if [ $# != 1 ]; then 34 echo expected one argument: '<'dtrace-path'>' 35 exit 2 36fi 37 38dtrace=$1 39exe="tst.bitfields.exe" 40 41elfdump "./$exe" | grep -q '.SUNW_ctf' 42if (( $? != 0 )); then 43 echo "CTF does not exist in $exe, that's a bug" >&2 44 exit 1 45fi 46 47$dtrace -qs /dev/stdin -c "./$exe 0xe417 0x9391d7db" <<EOF 48pid\$target::mumble:entry 49{ 50 print(*args[1]); 51 printf("\n"); 52 print(*args[2]); 53 printf("\n"); 54 trace(args[2]->b); 55 printf("\n0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", args[2]->a, args[2]->b, 56 args[2]->c, args[2]->d, args[2]->e, args[2]->f); 57 trace(args[1]->i); 58 printf("\n0x%x 0x%x 0x%x 0x%x\n", args[1]->g, args[1]->h, args[1]->i, 59 args[1]->j); 60} 61EOF 62 63exit $rc 64