===========================================================================
| 757 | |
| 758 | //=========================================================================== |
| 759 | Update_t CmdSymbolsLoad (int nArgs) |
| 760 | { |
| 761 | std::string sFileName = g_sProgramDir; |
| 762 | |
| 763 | int iSymbolTable = GetSymbolTableFromCommand(); |
| 764 | if ((iSymbolTable < 0) || (iSymbolTable >= NUM_SYMBOL_TABLES)) |
| 765 | { |
| 766 | return _PrintSymbolInvalidTable(); |
| 767 | } |
| 768 | |
| 769 | int nSymbols = 0; |
| 770 | |
| 771 | // Debugger will call us with 0 args on startup as a way to pre-load symbol tables |
| 772 | if (! nArgs) |
| 773 | { |
| 774 | sFileName = g_sProgramDir + g_sFileNameSymbols[ iSymbolTable ]; |
| 775 | |
| 776 | // if ".sym2" extension then RUN since we need support for DB, DA, etc. |
| 777 | // TODO: Use Util_GetFileNameExtension() |
| 778 | const size_t nLength = sFileName.length(); |
| 779 | const size_t iExtension = sFileName.rfind( '.', nLength ); |
| 780 | const std::string sExt = (iExtension != std::string::npos) |
| 781 | ? sFileName.substr( iExtension, nLength ) |
| 782 | : std::string("") |
| 783 | ; |
| 784 | |
| 785 | bool bSymbolFormat2 = (sExt == std::string( ".SYM2")); |
| 786 | if (bSymbolFormat2) |
| 787 | { |
| 788 | // We could hijack: |
| 789 | // CmdOutputRun( -1 ); |
| 790 | // But we would need to futz around with arguments |
| 791 | // strncpy(g_aArgs[0].sArg, sFileName.c_str(), sizeof(g_aArgs[0].sArg)); |
| 792 | |
| 793 | MemoryTextFile_t script; |
| 794 | if (script.Read( sFileName )) |
| 795 | { |
| 796 | int nLine = script.GetNumLines(); |
| 797 | Update_t bUpdateDisplay = UPDATE_NOTHING; // not used |
| 798 | |
| 799 | for ( int iLine = 0; iLine < nLine; iLine++ ) |
| 800 | { |
| 801 | script.GetLine( iLine, g_pConsoleInput, CONSOLE_WIDTH-2 ); |
| 802 | g_nConsoleInputChars = (int) strlen( g_pConsoleInput ); |
| 803 | bUpdateDisplay |= DebuggerProcessCommand( false ); |
| 804 | } |
| 805 | } |
| 806 | |
| 807 | } |
| 808 | else |
| 809 | { |
| 810 | nSymbols = ParseSymbolTable( sFileName, (SymbolTable_Index_e) iSymbolTable ); |
| 811 | } |
| 812 | |
| 813 | // Try optional alternate location |
| 814 | if ((nSymbols == 0) && !g_sBuiltinSymbolsDir.empty()) |
| 815 | { |
| 816 | sFileName = g_sBuiltinSymbolsDir + g_sFileNameSymbols[ iSymbolTable ]; |
no test coverage detected