From 568713ee45a85e4d71f610a77febd176ec571968 Mon Sep 17 00:00:00 2001 From: stephena Date: Tue, 11 Oct 2005 17:14:35 +0000 Subject: [PATCH] Fixed 'delete last word' in PromptWidget. Removed an ifdef from PromptWidget, and placed it in bspf.hxx. Implemented showing the currently defined symbol for PC address in CpuWidget. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@824 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/debugger/Debugger.hxx | 6 +- stella/src/debugger/EquateList.cxx | 334 ++++++++++-------- stella/src/debugger/gui/CpuWidget.cxx | 6 +- stella/src/debugger/gui/PromptWidget.cxx | 10 +- stella/src/debugger/gui/PromptWidget.hxx | 4 +- .../src/emucore/m6502/src/bspf/src/bspf.hxx | 6 +- 6 files changed, 207 insertions(+), 159 deletions(-) diff --git a/stella/src/debugger/Debugger.hxx b/stella/src/debugger/Debugger.hxx index fbaa85c3c..7bc632f23 100644 --- a/stella/src/debugger/Debugger.hxx +++ b/stella/src/debugger/Debugger.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Debugger.hxx,v 1.78 2005-09-25 20:18:46 urchlay Exp $ +// $Id: Debugger.hxx,v 1.79 2005-10-11 17:14:34 stephena Exp $ //============================================================================ #ifndef DEBUGGER_HXX @@ -64,7 +64,7 @@ enum { }; /* - // These will probably turn out to be unneeded, left for reference for now +// These will probably turn out to be unneeded, left for reference for now // pointer types for Debugger instance methods typedef uInt8 (Debugger::*DEBUGGER_BYTE_METHOD)(); typedef uInt16 (Debugger::*DEBUGGER_WORD_METHOD)(); @@ -79,7 +79,7 @@ typedef uInt16 (Debugger::*DEBUGGER_WORD_METHOD)(); for all debugging operations in Stella (parser, 6502 debugger, etc). @author Stephen Anthony - @version $Id: Debugger.hxx,v 1.78 2005-09-25 20:18:46 urchlay Exp $ + @version $Id: Debugger.hxx,v 1.79 2005-10-11 17:14:34 stephena Exp $ */ class Debugger : public DialogContainer { diff --git a/stella/src/debugger/EquateList.cxx b/stella/src/debugger/EquateList.cxx index 922b6ef53..f37f8e829 100644 --- a/stella/src/debugger/EquateList.cxx +++ b/stella/src/debugger/EquateList.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: EquateList.cxx,v 1.18 2005-07-14 15:28:51 urchlay Exp $ +// $Id: EquateList.cxx,v 1.19 2005-10-11 17:14:34 stephena Exp $ //============================================================================ #include @@ -98,204 +98,252 @@ static Equate hardCodedEquates[] = { { "TIM1024T", 0x0297 } }; -EquateList::EquateList() { - int size = sizeof(hardCodedEquates)/sizeof(struct Equate); +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +EquateList::EquateList() +{ + int size = sizeof(hardCodedEquates)/sizeof(struct Equate); - for(int i=0; isecond; +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +const string& EquateList::getLabel(int addr) +{ + static string nothing = ""; + addrToLabel::const_iterator iter = myRevMap.find(addr); + + if(iter == myRevMap.end()) + return nothing; + else + return iter->second; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // returns either the label, or a formatted hex string // if no label found. -const char *EquateList::getFormatted(int addr, int places) { - static char fmt[10], buf[255]; - string res = getLabel(addr); - if(res != "") - return res.c_str(); +const char *EquateList::getFormatted(int addr, int places) +{ + static char fmt[10], buf[255]; + string res = getLabel(addr); + if(res != "") + return res.c_str(); - sprintf(fmt, "$%%0%dx", places); - //cerr << addr << ", " << fmt << ", " << places << endl; - sprintf(buf, fmt, addr); - return buf; + sprintf(fmt, "$%%0%dx", places); + //cerr << addr << ", " << fmt << ", " << places << endl; + sprintf(buf, fmt, addr); + + return buf; } -int EquateList::getAddress(const string& label) { - labelToAddr::const_iterator iter = myFwdMap.find(label); - if(iter == myFwdMap.end()) - return -1; - else - return iter->second; +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int EquateList::getAddress(const string& label) +{ + labelToAddr::const_iterator iter = myFwdMap.find(label); + if(iter == myFwdMap.end()) + return -1; + else + return iter->second; } -bool EquateList::undefine(string& label) { - labelToAddr::iterator iter = myFwdMap.find(label); - if(iter == myFwdMap.end()) { - return false; - } else { - myRevMap.erase( myRevMap.find(iter->second) ); // FIXME: error check? - myFwdMap.erase(iter); - return true; - } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool EquateList::undefine(string& label) +{ + labelToAddr::iterator iter = myFwdMap.find(label); + if(iter == myFwdMap.end()) + { + return false; + } + else + { + myRevMap.erase( myRevMap.find(iter->second) ); // FIXME: error check? + myFwdMap.erase(iter); + return true; + } } -bool EquateList::saveFile(string file) { - char buf[256]; +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool EquateList::saveFile(string file) +{ + char buf[256]; - ofstream out(file.c_str()); - if(!out.is_open()) - return false; + ofstream out(file.c_str()); + if(!out.is_open()) + return false; - out << "--- Symbol List (sorted by symbol)" << endl; + out << "--- Symbol List (sorted by symbol)" << endl; - labelToAddr::iterator iter; - for(iter = myFwdMap.begin(); iter != myFwdMap.end(); iter++) { - sprintf(buf, "%-24s %04x \n", iter->first.c_str(), iter->second); - out << buf; - } + labelToAddr::iterator iter; + for(iter = myFwdMap.begin(); iter != myFwdMap.end(); iter++) + { + sprintf(buf, "%-24s %04x \n", iter->first.c_str(), iter->second); + out << buf; + } - out << "--- End of Symbol List." << endl; - return true; + out << "--- End of Symbol List." << endl; + + return true; } -string EquateList::loadFile(string file) { - int lines = 0; - string curLabel; - int curVal; - char buffer[256]; // FIXME: static buffers suck +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string EquateList::loadFile(string file) +{ + int lines = 0, curVal; + string curLabel; + char buffer[256]; // FIXME: static buffers suck - ifstream in(file.c_str()); - if(!in.is_open()) - return "Unable to read symbols from " + file; + ifstream in(file.c_str()); + if(!in.is_open()) + return "Unable to read symbols from " + file; - myFwdMap.clear(); - myRevMap.clear(); + myFwdMap.clear(); + myRevMap.clear(); - while( !in.eof() ) { - curVal = 0; - curLabel = ""; + while( !in.eof() ) + { + curVal = 0; + curLabel = ""; - if(!in.getline(buffer, 255)) - break; + if(!in.getline(buffer, 255)) + break; - if(buffer[0] != '-') { - curLabel = extractLabel(buffer); - if((curVal = extractValue(buffer)) < 0) - return "invalid symbol file"; + if(buffer[0] != '-') + { + curLabel = extractLabel(buffer); + if((curVal = extractValue(buffer)) < 0) + return "invalid symbol file"; - addEquate(curLabel, curVal); + addEquate(curLabel, curVal); - lines++; - } - } - in.close(); + lines++; + } + } + in.close(); - calcSize(); + calcSize(); - return "loaded " + file + " OK"; + return "loaded " + file + " OK"; } -void EquateList::addEquate(string label, int address) { - undefine(label); - myFwdMap.insert(make_pair(label, address)); - myRevMap.insert(make_pair(address, label)); +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void EquateList::addEquate(string label, int address) +{ + undefine(label); + myFwdMap.insert(make_pair(label, address)); + myRevMap.insert(make_pair(address, label)); } -int EquateList::parse4hex(char *c) { - int ret = 0; - for(int i=0; i<4; i++) { - if(*c >= '0' && *c <= '9') - ret = (ret << 4) + (*c) - '0'; - else if(*c >= 'a' && *c <= 'f') - ret = (ret << 4) + (*c) - 'a' + 10; - else - return -1; - c++; - } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int EquateList::parse4hex(char *c) +{ + int ret = 0; + for(int i=0; i<4; i++) + { + if(*c >= '0' && *c <= '9') + ret = (ret << 4) + (*c) - '0'; + else if(*c >= 'a' && *c <= 'f') + ret = (ret << 4) + (*c) - 'a' + 10; + else + return -1; + c++; + } - return ret; + return ret; } -int EquateList::extractValue(char *c) { - while(*c != ' ') { - if(*c == '\0') - return -1; - c++; - } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int EquateList::extractValue(char *c) +{ + while(*c != ' ') + { + if(*c == '\0') + return -1; + c++; + } - while(*c == ' ') { - if(*c == '\0') - return -1; - c++; - } + while(*c == ' ') + { + if(*c == '\0') + return -1; + c++; + } - return parse4hex(c); + return parse4hex(c); } -string EquateList::extractLabel(char *c) { - string l = ""; - while(*c != ' ') - l += *c++; +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string EquateList::extractLabel(char *c) +{ + string l = ""; + while(*c != ' ') + l += *c++; - return l; + return l; } -int EquateList::countCompletions(const char *in) { - int count = 0; - completions = compPrefix = ""; +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int EquateList::countCompletions(const char *in) +{ + int count = 0; + completions = compPrefix = ""; - labelToAddr::iterator iter; - for(iter = myFwdMap.begin(); iter != myFwdMap.end(); iter++) { - const char *l = iter->first.c_str(); + labelToAddr::iterator iter; + for(iter = myFwdMap.begin(); iter != myFwdMap.end(); iter++) + { + const char *l = iter->first.c_str(); - if(STR_N_CASE_CMP(l, in, strlen(in)) == 0) { - if(compPrefix == "") - compPrefix += l; - else { - int nonMatch = 0; - const char *c = compPrefix.c_str(); - while(*c != '\0' && tolower(*c) == tolower(l[nonMatch])) { - c++; - nonMatch++; - } - compPrefix.erase(nonMatch, compPrefix.length()); - } + if(STR_N_CASE_CMP(l, in, strlen(in)) == 0) + { + if(compPrefix == "") + compPrefix += l; + else + { + int nonMatch = 0; + const char *c = compPrefix.c_str(); + while(*c != '\0' && tolower(*c) == tolower(l[nonMatch])) + { + c++; + nonMatch++; + } + compPrefix.erase(nonMatch, compPrefix.length()); + } - if(count++) completions += " "; - completions += l; - } - } - return count; + if(count++) completions += " "; + completions += l; + } + } + + return count; } -const char *EquateList::getCompletions() { - return completions.c_str(); +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +const char *EquateList::getCompletions() +{ + return completions.c_str(); } -const char *EquateList::getCompletionPrefix() { - return compPrefix.c_str(); +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +const char *EquateList::getCompletionPrefix() +{ + return compPrefix.c_str(); } diff --git a/stella/src/debugger/gui/CpuWidget.cxx b/stella/src/debugger/gui/CpuWidget.cxx index fc02889e5..4bc290867 100644 --- a/stella/src/debugger/gui/CpuWidget.cxx +++ b/stella/src/debugger/gui/CpuWidget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CpuWidget.cxx,v 1.1 2005-08-30 17:51:26 stephena Exp $ +// $Id: CpuWidget.cxx,v 1.2 2005-10-11 17:14:35 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -238,7 +238,8 @@ void CpuWidget::fillGrid() // We push the enumerated items as addresses, and deal with the real // address in the callback (handleCommand) - CpuDebug& cpu = instance()->debugger().cpuDebug(); + Debugger& dbg = instance()->debugger(); + CpuDebug& cpu = dbg.cpuDebug(); CpuState state = (CpuState&) cpu.getState(); CpuState oldstate = (CpuState&) cpu.getOldState(); @@ -277,4 +278,5 @@ void CpuWidget::fillGrid() changed.push_back(state.PSbits[i] != oldstate.PSbits[i]); myPSRegister->setState(state.PSbits, changed); + myPCLabel->setEditString(dbg.equates()->getLabel(state.PC)); } diff --git a/stella/src/debugger/gui/PromptWidget.cxx b/stella/src/debugger/gui/PromptWidget.cxx index b97a6cba4..85f37b66a 100644 --- a/stella/src/debugger/gui/PromptWidget.cxx +++ b/stella/src/debugger/gui/PromptWidget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: PromptWidget.cxx,v 1.3 2005-09-30 22:12:18 stephena Exp $ +// $Id: PromptWidget.cxx,v 1.4 2005-10-11 17:14:35 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -618,7 +618,7 @@ void PromptWidget::killLastWord() bool space = true; while (_currentPos > _promptStartPos) { - if (buffer(_currentPos - 1) == ' ') + if ((buffer(_currentPos - 1) & 0xff) == ' ') { if (!space) break; @@ -768,12 +768,8 @@ int PromptWidget::printf(const char *format, ...) int PromptWidget::vprintf(const char *format, va_list argptr) { char buf[2048]; + int count = VSNPRINTF(buf, sizeof(buf), format, argptr); -#if defined(WIN32) - int count = _vsnprintf(buf, sizeof(buf), format, argptr); -#else - int count = vsnprintf(buf, sizeof(buf), format, argptr); -#endif print(buf); return count; } diff --git a/stella/src/debugger/gui/PromptWidget.hxx b/stella/src/debugger/gui/PromptWidget.hxx index d1c99f40e..86b5259da 100644 --- a/stella/src/debugger/gui/PromptWidget.hxx +++ b/stella/src/debugger/gui/PromptWidget.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: PromptWidget.hxx,v 1.2 2005-09-30 22:12:18 stephena Exp $ +// $Id: PromptWidget.hxx,v 1.3 2005-10-11 17:14:35 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -85,7 +85,7 @@ class PromptWidget : public Widget, public CommandSender void loadConfig(); protected: - int _buffer[kBufferSize]; + int _buffer[kBufferSize]; int _linesInBuffer; int _lineWidth; diff --git a/stella/src/emucore/m6502/src/bspf/src/bspf.hxx b/stella/src/emucore/m6502/src/bspf/src/bspf.hxx index c56948fb1..a321b193d 100644 --- a/stella/src/emucore/m6502/src/bspf/src/bspf.hxx +++ b/stella/src/emucore/m6502/src/bspf/src/bspf.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: bspf.hxx,v 1.11 2005-10-09 17:31:47 stephena Exp $ +// $Id: bspf.hxx,v 1.12 2005-10-11 17:14:35 stephena Exp $ //============================================================================ #ifndef BSPF_HXX @@ -24,7 +24,7 @@ that need to be defined for different operating systems. @author Bradford W. Mott - @version $Id: bspf.hxx,v 1.11 2005-10-09 17:31:47 stephena Exp $ + @version $Id: bspf.hxx,v 1.12 2005-10-11 17:14:35 stephena Exp $ */ // Types for 8-bit signed and unsigned integers @@ -76,10 +76,12 @@ typedef unsigned int uInt32; #define STR_CASE_CMP stricmp #define STR_N_CASE_CMP strnicmp #define IS_BLANK(c) ((c == ' ') || (c == '\t')) + #define VSNPRINTF _vsnprintf #else #define STR_CASE_CMP strcasecmp #define STR_N_CASE_CMP strncasecmp #define IS_BLANK(c) isblank(c) + #define VSNPRINTF vsnprintf #endif