#!/bin/sh ############################################################################### # # Copyright (C) 2009-2014 Nintendo. All rights reserved. # # These coded instructions, statements, and computer programs contain # proprietary information of Nintendo of America Inc. and/or Nintendo # Company Ltd., and are protected by Federal copyright law. They may # not be disclosed to third parties or copied or duplicated in any form, # in whole or in part, without the prior written consent of Nintendo. # ############################################################################### MULTI_ARG="core" MAKECORE_DIR=. DBG_SRC_ROOT=$CAFE_ROOT/system/ DO_MAKECORE=1 LAUNCH_MULTI=1 DISPLAY_HELP=0 ERROR=0 MIN_VER0=5 MIN_VER1=3 MIN_VER2=21 MIN_VER="$MIN_VER0.$MIN_VER1.$MIN_VER2" PATCH="Core0 BETA" VER_TOO_OLD=0 if [ -z $GHS_ROOT ] ; then echo "Error: GHS_ROOT not defined. Exiting viewcore" exit 1 fi MULTI_DOS_PATH=`cygpath -d $GHS_ROOT/multi.exe` VERSION=`$GHS_ROOT/gversion -quiet $MULTI_DOS_PATH | cut -d',' -f 2` VER0=${VERSION:8:1} VER1=${VERSION:10:1} VER2=${VERSION:12:2} CORE=${VERSION:24:4} CORENUM=${VERSION:28:1} BETA=${VERSION:30:4} if [ $VER0 -lt 5 ] ; then VER_TOO_OLD=1 fi if [ $VER1 -lt 3 ] ; then VER_TOO_OLD=1 fi if [ $VER2 -lt 21 ] ; then VER_TOO_OLD=1 fi if [ $VER2 -eq 21 ] ; then if [ "$CORE" != "Core" ] ; then VER_TOO_OLD=1 CORE="" CORENUM="" else if [ "$CORENUM" -lt 0 ] ; then VER_TOO_OLD=1 fi fi if [ "$BETA" != "BETA" ] ; then VER_TOO_OLD=1 BETA="" fi fi if [ $VER2 -ge 22 ] ; then if [ "$CORE" != "Core" ] ; then CORE="" CORENUM="" fi if [ "$BETA" != "BETA" ] ; then BETA="" fi fi if [ $VER_TOO_OLD -eq 1 ] ; then echo "Error: MULTI version $MIN_VER $PATCH or later is needed. Current Version is $VER0.$VER1.$VER2 $CORE$CORENUM $BETA" exit 1 fi while [ $# -ge 1 ]; do case $1 in -o) shift; MULTI_ARG=$1 ;; -i) shift; DO_MAKECORE=0; MULTI_ARG=$1;; -d) shift; DBG_SRC_ROOT=$1 ;; -a) DBG_SRC_ROOT="" ;; -x) AGE_OLD_DUMPS=1;; -h) DISPLAY_HELP=1; DO_MAKECORE=0; LAUNCH_MULTI=0;; -help) DISPLAY_HELP=1; DO_MAKECORE=0; LAUNCH_MULTI=0;; -*) echo "Error: $1 unrecognized options"; DISPLAY_HELP=1; DO_MAKECORE=0; LAUNCH_MULTI=0; ERROR=1;; *) MAKECORE_DIR=$1;; esac shift done if [ -n "$AGE_OLD_DUMPS" ] ; then if [ ${CAFE_CRASH_DUMP_LIMIT:=5} -gt 0 ] ; then for old_dump in `ls -1rt ${MAKECORE_DIR}/.. | head -n -${CAFE_CRASH_DUMP_LIMIT}`; do rm -r ${MAKECORE_DIR}/../$old_dump done fi fi if [ $DO_MAKECORE -ne 0 ]; then if [ -n "${CAFE_CRASH_DUMP_NOMULTI}" ] ; then if [ ${CAFE_CRASH_DUMP_NOMULTI} -ne 0 ] ; then echo "Making a core dump file, but NOT automatically launching GHS MULTI!" LAUNCH_MULTI=0 fi fi fi if [ -z "$DBG_SRC_ROOT" ] ; then echo "Message: Use absolute path for all rpl" else DBG_SRC_ROOT_DOS_PATH=`cygpath -d $DBG_SRC_ROOT` DBG_SRC_ROOT="-d $DBG_SRC_ROOT_DOS_PATH" fi MAKECORE_ARG=`find $MAKECORE_DIR -maxdepth 1 -name "BLK*_A*_SZ*.bin"` MAKECORE_ARG=`cygpath -m $MAKECORE_ARG 2>/dev/null` if [ $DO_MAKECORE -eq 1 ] ; then if [ -z "$MAKECORE_ARG" ] ; then echo "Error: No memory blocks found in $MAKECORE_DIR. Exiting viewcore." 1>&2 DISPLAY_HELP=1 ERROR=1 else if [ -z "$MULTI_ARG" ] ; then echo "Error: missing argument with option -o. Exiting viewcore." 1>&2 DISPLAY_HELP=1 ERROR=1 else echo "Running makecore to process the following memory blocks:" echo "$MAKECORE_ARG" if makecore $MAKECORE_ARG -o $MULTI_ARG $DBG_SRC_ROOT; then if [ ! $LAUNCH_MULTI == 0 ]; then echo "MULTI v$VER0.$VER1.$VER2 $CORE$CORENUM $BETA is launching $MULTI_ARG" 1>&2 MULTI_ARG_DOS_PATH=`cygpath -d $MULTI_ARG` $GHS_ROOT/multi $MULTI_ARG_DOS_PATH fi else echo "Error: MULTI v$VER0.$VER1.$VER2 $CORE$CORENUM $BETA is not launched due to makecore error." 1>&2 DISPLAY_HELP=1 ERROR=1 fi fi fi else if [ $LAUNCH_MULTI -eq 1 ] ; then if [ -z "$MULTI_ARG" ] ; then echo "Error: missing argument with option -i. Exiting viewcore." DISPLAY_HELP=1 ERROR=1 else MULTI_ARG_COPY=$MULTI_ARG MULTI_ARG_DOS_PATH=`cygpath -d $MULTI_ARG` MULTI_ARG=`find $MULTI_ARG_DOS_PATH -maxdepth 0 -type f` if [ -z "$MULTI_ARG" ] ; then echo "Error: $MULTI_ARG_COPY not found, or is a directory. Exiting viewcore." DISPLAY_HELP=1 ERROR=1 else echo "MULTI v$VER0.$VER1.$VER2 $CORE$CORENUM $BETA is launching $MULTI_ARG" 1>&2 $GHS_ROOT/multi $MULTI_ARG_DOS_PATH fi fi fi fi if [ $DISPLAY_HELP -eq 1 ]; then echo "" echo "viewcore" echo " Usage: viewcore [-o ] [-i ] [-d ] [-a] [-h] []" echo " Options:" echo " -o Specify output core dump file name. If unspecified," echo " \"core\" is used." echo " -i View core dump file \"file\". No memory" echo " block files will be processed" echo " -d Debug source root \"dir\". If unspecified," echo " \"$CAFE_ROOT/system\" is used" echo " -a Treat path info stored in RPLs as absolute path. Use this option to process and view RPLs built before SDK2.11.02. " echo " -h Print this menu" echo " Look for memory block files in to be parsed" echo " If unspecified, current working directory is used." fi if [ $ERROR -eq 1 ]; then exit 1 else exit 0 fi