//=========================================================================== Update_t CmdVersion (int nArgs) { TCHAR sText[ CONSOLE_WIDTH ]; unsigned int nVersion = DEBUGGER_VERSION; int nMajor; int nMinor; int nFixMajor; int nFixMinor; UnpackVersion( nVersion, nMajor, nMinor, nFixMajor, nFixMinor ); // wsprintf( sText, "Version" ); ConsoleBufferPush( sText ); wsprintf( sText, " Emulator: %s Debugger: %d.%d.%d.%d" , VERSIONSTRING , nMajor, nMinor, nFixMajor, nFixMinor ); ConsoleBufferPush( sText ); if (nArgs) { for (int iArg = 1; iArg <= nArgs; iArg++ ) { if (_tcscmp( g_aArgs[ iArg ].sArg, g_aParameters[ PARAM_WILDSTAR ].m_sName ) == 0) { wsprintf( sText, " Arg: %d bytes * %d = %d bytes", sizeof(Arg_t), MAX_ARGS, sizeof(g_aArgs) ); ConsoleBufferPush( sText ); wsprintf( sText, " Console: %d bytes * %d height = %d bytes", sizeof( g_aConsoleDisplay[0] ), CONSOLE_HEIGHT, sizeof(g_aConsoleDisplay) ); ConsoleBufferPush( sText ); wsprintf( sText, " Commands: %d (Aliased: %d) Params: %d", NUM_COMMANDS, NUM_COMMANDS_WITH_ALIASES, NUM_PARAMS ); ConsoleBufferPush( sText ); wsprintf( sText, " Cursor(%d) T: %04X C: %04X B: %04X %c D: %02X", // Top, Cur, Bot, Delta g_nDisasmCurLine, g_nDisasmTopAddress, g_nDisasmCurAddress, g_nDisasmBotAddress, g_bDisasmCurBad ? TEXT('*') : TEXT(' ') , g_nDisasmBotAddress - g_nDisasmTopAddress ); ConsoleBufferPush( sText ); CmdConfigGetFont( 0 ); break; } else return Help_Arg_1( CMD_VERSION ); } } return ConsoleUpdate(); }
//=========================================================================== Update_t _CmdSymbolsCommon ( int nArgs, int bSymbolTables ) { if (! nArgs) { return Help_Arg_1( g_iCommand ); } Update_t iUpdate = _CmdSymbolsUpdate( nArgs, bSymbolTables ); if (iUpdate != UPDATE_NOTHING) return iUpdate; TCHAR sText[ CONSOLE_WIDTH ]; int iArg = 0; while (iArg++ <= nArgs) { int iParam; int nParams = FindParam( g_aArgs[iArg].sArg, MATCH_EXACT, iParam ); // MATCH_FUZZY if (nParams) { if (iParam == PARAM_CLEAR) { int iTable = _GetSymbolTableFromFlag( bSymbolTables ); if (iTable != NUM_SYMBOL_TABLES) { Update_t iUpdate = _CmdSymbolsClear( (SymbolTable_Index_e) iTable ); sprintf( sText, TEXT(" Cleared symbol table: %s%s") , CHC_STRING, g_aSymbolTableNames[ iTable ] ); ConsolePrint( sText ); iUpdate |= ConsoleUpdate(); return iUpdate; } else { // Shouldn't have multiple symbol tables selected // nArgs = _Arg_1( eSymbolsTable ); ConsoleBufferPush( TEXT(" Error: Unknown Symbol Table Type") ); return ConsoleUpdate(); } } else if (iParam == PARAM_LOAD) { nArgs = _Arg_Shift( iArg, nArgs); Update_t bUpdate = CmdSymbolsLoad( nArgs ); int iTable = _GetSymbolTableFromFlag( bSymbolTables ); if (iTable != NUM_SYMBOL_TABLES) { if( bUpdate & UPDATE_SYMBOLS ) { //sprintf( sText, " Symbol Table: %s%s%s, %sloaded symbols: %s%d" // , CHC_STRING, g_aSymbolTableNames[ iTable ] // , CHC_DEFAULT, CHC_DEFAULT // , CHC_NUM_DEC, g_nSymbolsLoaded //); _CmdSymbolsInfoHeader( iTable, sText, g_nSymbolsLoaded ); ConsolePrint( sText ); } } else { ConsoleBufferPush( TEXT(" Error: Unknown Symbol Table Type") ); } return ConsoleUpdate(); } else if (iParam == PARAM_SAVE) { nArgs = _Arg_Shift( iArg, nArgs); return CmdSymbolsSave( nArgs ); } else if (iParam == PARAM_ON) { g_bDisplaySymbolTables |= bSymbolTables; int iTable = _GetSymbolTableFromFlag( bSymbolTables ); if (iTable != NUM_SYMBOL_TABLES) { _CmdSymbolsInfoHeader( iTable, sText ); ConsolePrint( sText ); } return ConsoleUpdate() | UPDATE_DISASM; } else if (iParam == PARAM_OFF) { g_bDisplaySymbolTables &= ~bSymbolTables; int iTable = _GetSymbolTableFromFlag( bSymbolTables ); if (iTable != NUM_SYMBOL_TABLES) { _CmdSymbolsInfoHeader( iTable, sText ); ConsolePrint( sText ); } return ConsoleUpdate() | UPDATE_DISASM; } } else { return _CmdSymbolsListTables( nArgs, bSymbolTables ); } } return ConsoleUpdate(); }
//=========================================================================== Update_t HelpLastCommand() { return Help_Arg_1( g_iCommand ); }
//=========================================================================== Update_t _CmdSymbolsListTables (int nArgs, int bSymbolTables ) { if (! nArgs) { return Help_Arg_1( CMD_SYMBOLS_LIST ); } /* Test Cases SYM 0 RESET FA6F $FA59 $0000 LOC0 $FA6F RESET $FA6F INITAN $FA59 OLDBRK SYM B SYMBOL B = $2000 SYM B */ TCHAR sText[ CONSOLE_WIDTH ] = ""; for( int iArgs = 1; iArgs <= nArgs; iArgs++ ) { WORD nAddress = g_aArgs[iArgs].nValue; LPCTSTR pSymbol = g_aArgs[iArgs].sArg; // Dump all symbols for this table if( g_aArgRaw[iArgs].eToken == TOKEN_STAR) { // int iWhichTable = (g_iCommand - CMD_SYMBOLS_MAIN); // bDisplaySymbolTables = (1 << iWhichTable); int iTable = 0; int bTable = 1; for( ; bTable <= bSymbolTables; iTable++, bTable <<= 1 ) { if( bTable & bSymbolTables ) { int nSymbols = g_aSymbols[iTable].size(); if (nSymbols) { SymbolTable_t :: iterator iSymbol = g_aSymbols[iTable].begin(); while (iSymbol != g_aSymbols[iTable].end()) { const char *pSymbol = iSymbol->second.c_str(); unsigned short nAddress = iSymbol->first; _CmdPrintSymbol( pSymbol, nAddress, iTable ); ++iSymbol; } } _CmdSymbolsInfoHeader( iTable, sText ); ConsolePrint( sText ); } } } else if (nAddress) { // Have address, do symbol lookup first if (! _CmdSymbolList_Symbol2Address( pSymbol, bSymbolTables )) { // nope, ok, try as address if (! _CmdSymbolList_Address2Symbol( nAddress, bSymbolTables)) { wsprintf( sText , TEXT(" Address not found: %s$%s%04X%s" ) , CHC_ARG_SEP , CHC_ADDRESS, nAddress, CHC_DEFAULT ); ConsolePrint( sText ); } } } else { // Have symbol, do address lookup if (! _CmdSymbolList_Symbol2Address( pSymbol, bSymbolTables )) { // nope, ok, try as address if (String2Address( pSymbol, nAddress )) { if (! _CmdSymbolList_Address2Symbol( nAddress, bSymbolTables )) { sprintf( sText , TEXT(" %sSymbol not found: %s%s%s") , CHC_ERROR, CHC_SYMBOL, pSymbol, CHC_DEFAULT ); ConsolePrint( sText ); } } else { sprintf( sText , TEXT(" %sSymbol not found: %s%s%s") , CHC_ERROR, CHC_SYMBOL, pSymbol, CHC_DEFAULT ); ConsolePrint( sText ); } } } } return ConsoleUpdate(); }