1*7c478bd9Sstevel@tonic-gate#!/bin/sh 2*7c478bd9Sstevel@tonic-gate# 3*7c478bd9Sstevel@tonic-gate# CDDL HEADER START 4*7c478bd9Sstevel@tonic-gate# 5*7c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the 6*7c478bd9Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only 7*7c478bd9Sstevel@tonic-gate# (the "License"). You may not use this file except in compliance 8*7c478bd9Sstevel@tonic-gate# with the License. 9*7c478bd9Sstevel@tonic-gate# 10*7c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11*7c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 12*7c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions 13*7c478bd9Sstevel@tonic-gate# and limitations under the License. 14*7c478bd9Sstevel@tonic-gate# 15*7c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 16*7c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17*7c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 18*7c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 19*7c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 20*7c478bd9Sstevel@tonic-gate# 21*7c478bd9Sstevel@tonic-gate# CDDL HEADER END 22*7c478bd9Sstevel@tonic-gate# 23*7c478bd9Sstevel@tonic-gate# 24*7c478bd9Sstevel@tonic-gate# Copyright (c) 1998-2001 by Sun Microsystems, Inc. 25*7c478bd9Sstevel@tonic-gate# All rights reserved. 26*7c478bd9Sstevel@tonic-gate# 27*7c478bd9Sstevel@tonic-gate#ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gatemdb_lib=/net/mdb.eng/mdb/archives # Archive library path 30*7c478bd9Sstevel@tonic-gatemdb_ws=/net/mdb.eng/mdb/snapshot/latest # Snapshot of latest workspace 31*7c478bd9Sstevel@tonic-gatemdb_args= # Debugger argument string 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gateos_name='s81' # Default OS name prefix 34*7c478bd9Sstevel@tonic-gateos_rel='5.9' # Default OS release number 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gatemach=`/usr/bin/uname -p` # Machine type 37*7c478bd9Sstevel@tonic-gateunset mdb_exec build root # Local variables 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate# 40*7c478bd9Sstevel@tonic-gate# Attempt to locate a suitable mdb binary to execute, first on the local 41*7c478bd9Sstevel@tonic-gate# machine, then in the user's workspace, and finally on the MDB server. 42*7c478bd9Sstevel@tonic-gate# If we select the user's workspace, we also set $root to their proto area 43*7c478bd9Sstevel@tonic-gate# to force MDB to use shared libraries installed there as well. 44*7c478bd9Sstevel@tonic-gate# 45*7c478bd9Sstevel@tonic-gateif [ -n "$CODEMGR_WS" -a -x $CODEMGR_WS/proto/root_$mach/usr/bin/mdb ]; then 46*7c478bd9Sstevel@tonic-gate mdb_exec=$CODEMGR_WS/proto/root_$mach/usr/bin/mdb 47*7c478bd9Sstevel@tonic-gate root=$CODEMGR_WS/proto/root_$mach 48*7c478bd9Sstevel@tonic-gateelif [ -x /usr/bin/mdb -a ! -d /mdb ]; then 49*7c478bd9Sstevel@tonic-gate mdb_exec=/usr/bin/mdb 50*7c478bd9Sstevel@tonic-gate root=$mdb_lib/$mach/%R/%V 51*7c478bd9Sstevel@tonic-gateelif [ -x /usr/bin/mdb -a -d /mdb ]; then 52*7c478bd9Sstevel@tonic-gate for isa in `isalist`; do 53*7c478bd9Sstevel@tonic-gate if [ -x /usr/bin/$isa/mdb ]; then 54*7c478bd9Sstevel@tonic-gate mdb_exec=/usr/bin/$isa/mdb 55*7c478bd9Sstevel@tonic-gate break 56*7c478bd9Sstevel@tonic-gate fi 57*7c478bd9Sstevel@tonic-gate done 58*7c478bd9Sstevel@tonic-gate if [ -z "$mdb_exec" ]; then 59*7c478bd9Sstevel@tonic-gate echo "$0: cannot find mdb binary in ISA subdirectories" >& 2 60*7c478bd9Sstevel@tonic-gate exit 1 61*7c478bd9Sstevel@tonic-gate fi 62*7c478bd9Sstevel@tonic-gate root=$mdb_lib/$mach/%R/%V 63*7c478bd9Sstevel@tonic-gateelif [ -x $mdb_ws/proto/root_$mach/usr/bin/mdb ]; then 64*7c478bd9Sstevel@tonic-gate mdb_exec=$mdb_ws/proto/root_$mach/usr/bin/mdb 65*7c478bd9Sstevel@tonic-gate root=$mdb_lib/$mach/%R/%V 66*7c478bd9Sstevel@tonic-gatefi 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate# 69*7c478bd9Sstevel@tonic-gate# Abort if we were not able to locate a copy of mdb to execute. 70*7c478bd9Sstevel@tonic-gate# 71*7c478bd9Sstevel@tonic-gateif [ -z "$mdb_exec" ]; then 72*7c478bd9Sstevel@tonic-gate echo "$0: failed to locate mdb executable" >& 2 73*7c478bd9Sstevel@tonic-gate exit 1 74*7c478bd9Sstevel@tonic-gatefi 75*7c478bd9Sstevel@tonic-gate 76*7c478bd9Sstevel@tonic-gate# 77*7c478bd9Sstevel@tonic-gate# The wrapper script handles several special command-line arguments that are 78*7c478bd9Sstevel@tonic-gate# used to select a desired set of MDB macros, modules, and a libkvm binary. 79*7c478bd9Sstevel@tonic-gate# 80*7c478bd9Sstevel@tonic-gateif [ $# -gt 0 ]; then 81*7c478bd9Sstevel@tonic-gate case "$1" in 82*7c478bd9Sstevel@tonic-gate -s[0-9]*) 83*7c478bd9Sstevel@tonic-gate build=`echo "$1" | tr -d -` 84*7c478bd9Sstevel@tonic-gate shift 85*7c478bd9Sstevel@tonic-gate ;; 86*7c478bd9Sstevel@tonic-gate 87*7c478bd9Sstevel@tonic-gate -[0-9]|-[0-9][0-9]) 88*7c478bd9Sstevel@tonic-gate build=`echo "$1" | tr -d -` 89*7c478bd9Sstevel@tonic-gate if [ $build -lt 10 ]; then 90*7c478bd9Sstevel@tonic-gate build=${os_name}_0$build 91*7c478bd9Sstevel@tonic-gate else 92*7c478bd9Sstevel@tonic-gate build=${os_name}_$build 93*7c478bd9Sstevel@tonic-gate fi 94*7c478bd9Sstevel@tonic-gate shift 95*7c478bd9Sstevel@tonic-gate ;; 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate -[0-9][0-9]-|-[0-9][0-9][A-Za-z]) 98*7c478bd9Sstevel@tonic-gate build=${os_name}_`echo "$1" | cut -c2- | tr '[A-Z]' '[a-z]'` 99*7c478bd9Sstevel@tonic-gate shift 100*7c478bd9Sstevel@tonic-gate ;; 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate -B) build=$os_rel/Beta; shift ;; 103*7c478bd9Sstevel@tonic-gate -U) build=$os_rel/Beta_Update; shift ;; 104*7c478bd9Sstevel@tonic-gate -G) build=$os_rel/Generic; shift ;; 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate -\?) 107*7c478bd9Sstevel@tonic-gate echo "Usage: $0" \ 108*7c478bd9Sstevel@tonic-gate "[ -s<rel> | -s<bld> | -[0-9]+ | -B | -G | -U ] args ..." 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate echo "\t-s<rel> Use proto area for specified release" 111*7c478bd9Sstevel@tonic-gate echo "\t e.g. -${os_name}" 112*7c478bd9Sstevel@tonic-gate echo "\t-s<bld> Use proto area for specified build" 113*7c478bd9Sstevel@tonic-gate echo "\t e.g. -${os_name}_01" 114*7c478bd9Sstevel@tonic-gate echo "\t-[0-9]+ Use proto area for specified build of $os_name" 115*7c478bd9Sstevel@tonic-gate echo "\t-B Use proto area for $os_rel Beta build" 116*7c478bd9Sstevel@tonic-gate echo "\t-G Use proto area for $os_rel Generic build\n" 117*7c478bd9Sstevel@tonic-gate echo "\t-U Use proto area for $os_rel Beta_Update build" 118*7c478bd9Sstevel@tonic-gate ;; 119*7c478bd9Sstevel@tonic-gate esac 120*7c478bd9Sstevel@tonic-gatefi 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate# 123*7c478bd9Sstevel@tonic-gate# If a build was specified, using the corresponding proto area from $mdb_lib. 124*7c478bd9Sstevel@tonic-gate# Note that this will override the $root setting determined above. 125*7c478bd9Sstevel@tonic-gate# 126*7c478bd9Sstevel@tonic-gate[ -n "$build" ] && root=$mdb_lib/$mach/$build 127*7c478bd9Sstevel@tonic-gate 128*7c478bd9Sstevel@tonic-gate# 129*7c478bd9Sstevel@tonic-gate# If a proto area was set either by specifying a build number, or by using 130*7c478bd9Sstevel@tonic-gate# mdb from $CODEMGR_WS, set LD_LIBRARY_PATH accordingly. This allows mdb to 131*7c478bd9Sstevel@tonic-gate# pick up the appropriate libkvm.so to examine dumps from that build. 132*7c478bd9Sstevel@tonic-gate# We also add the -R flag to the mdb command line so that mdb will modify 133*7c478bd9Sstevel@tonic-gate# its default macro include and module library paths to use the build root. 134*7c478bd9Sstevel@tonic-gate# 135*7c478bd9Sstevel@tonic-gateif [ -n "$build" -o "$root" = "$CODEMGR_WS/proto/root_$mach" ]; then 136*7c478bd9Sstevel@tonic-gate if [ -n "$build" -a ! -d $root ]; then 137*7c478bd9Sstevel@tonic-gate echo "mdb: $root is missing or not a directory" >& 2 138*7c478bd9Sstevel@tonic-gate exit 1 139*7c478bd9Sstevel@tonic-gate fi 140*7c478bd9Sstevel@tonic-gate 141*7c478bd9Sstevel@tonic-gate [ -n "$LD_LIBRARY_PATH" ] && LD_LIBRARY_PATH=$LD_LIBRARY_PATH: 142*7c478bd9Sstevel@tonic-gate LD_LIBRARY_PATH="$LD_LIBRARY_PATH$root/usr/lib" 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate [ -n "$LD_LIBRARY_PATH_64" ] && LD_LIBRARY_PATH_64=$LD_LIBRARY_PATH_64: 145*7c478bd9Sstevel@tonic-gate LD_LIBRARY_PATH_64="$LD_LIBRARY_PATH_64$root/usr/lib/sparcv9" 146*7c478bd9Sstevel@tonic-gate 147*7c478bd9Sstevel@tonic-gate export LD_LIBRARY_PATH LD_LIBRARY_PATH_64 148*7c478bd9Sstevel@tonic-gate 149*7c478bd9Sstevel@tonic-gateelif [ $mdb_exec = $mdb_ws/proto/root_$mach/usr/bin/mdb ]; then 150*7c478bd9Sstevel@tonic-gate # 151*7c478bd9Sstevel@tonic-gate # We also need to set LD_LIBRARY_PATH if we're using mdb.eng's mdb 152*7c478bd9Sstevel@tonic-gate # binary -- it requires the new libproc.so to work properly. 153*7c478bd9Sstevel@tonic-gate # 154*7c478bd9Sstevel@tonic-gate usrlib=$mdb_ws/proto/root_$mach/usr/lib 155*7c478bd9Sstevel@tonic-gate 156*7c478bd9Sstevel@tonic-gate [ -n "$LD_LIBRARY_PATH" ] && LD_LIBRARY_PATH=$LD_LIBRARY_PATH: 157*7c478bd9Sstevel@tonic-gate LD_LIBRARY_PATH="$LD_LIBRARY_PATH$usrlib" 158*7c478bd9Sstevel@tonic-gate 159*7c478bd9Sstevel@tonic-gate [ -n "$LD_LIBRARY_PATH_64" ] && LD_LIBRARY_PATH_64=$LD_LIBRARY_PATH_64: 160*7c478bd9Sstevel@tonic-gate LD_LIBRARY_PATH_64="$LD_LIBRARY_PATH_64$usrlib/sparcv9" 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate export LD_LIBRARY_PATH LD_LIBRARY_PATH_64 163*7c478bd9Sstevel@tonic-gatefi 164*7c478bd9Sstevel@tonic-gate 165*7c478bd9Sstevel@tonic-gateexec $mdb_exec -R $root $mdb_args "$@" 166