mirror of https://github.com/stella-emu/stella.git
DASM listfile loading. The listing is produced by DASM's -l option,
and contains the entire asm source, plus line number/file and address for each line. Currently, you can either "loadlist file.lst" or else name your listing file "romname.lst" (e.g. "dasm foo.asm -ofoo.bin -sfoo.sym -lfoo.lst"). Once loaded, you can say "list myAddress" and see that address's source plus a few lines before & after for context. This is a long way from true source-level debugging, but it's a start. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@681 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
98b1d0be24
commit
1694cff72d
|
@ -13,11 +13,13 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Debugger.cxx,v 1.70 2005-07-19 17:59:57 stephena Exp $
|
||||
// $Id: Debugger.cxx,v 1.71 2005-07-20 04:28:13 urchlay Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "bspf.hxx"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "Version.hxx"
|
||||
|
@ -134,6 +136,7 @@ void Debugger::setConsole(Console* console)
|
|||
myTiaDebug = new TIADebug(this, myConsole);
|
||||
|
||||
autoLoadSymbols(myOSystem->romFile());
|
||||
loadListFile();
|
||||
|
||||
saveOldState();
|
||||
}
|
||||
|
@ -164,6 +167,81 @@ void Debugger::autoLoadSymbols(string fileName) {
|
|||
// cerr << "loading syms from file " << file << ": " << ret << endl;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string Debugger::loadListFile(string f) {
|
||||
char buffer[255];
|
||||
|
||||
if(f == "") {
|
||||
f = myOSystem->romFile();
|
||||
|
||||
string::size_type pos;
|
||||
if( (pos = f.find_last_of('.')) != string::npos ) {
|
||||
f.replace(pos, f.size(), ".lst");
|
||||
} else {
|
||||
f += ".lst";
|
||||
}
|
||||
}
|
||||
|
||||
ifstream in(f.c_str());
|
||||
if(!in.is_open())
|
||||
return "Unable to read listing from " + f;
|
||||
|
||||
sourceLines.clear();
|
||||
int count = 0;
|
||||
while( !in.eof() ) {
|
||||
if(!in.getline(buffer, 255))
|
||||
break;
|
||||
|
||||
if( strlen(buffer) >= 14 &&
|
||||
buffer[0] == ' ' &&
|
||||
buffer[7] == ' ' &&
|
||||
buffer[8] == ' ' &&
|
||||
isxdigit(buffer[9]) &&
|
||||
isxdigit(buffer[12]) &&
|
||||
isblank(buffer[13]))
|
||||
{
|
||||
count++;
|
||||
char addr[5];
|
||||
for(int i=0; i<4; i++)
|
||||
addr[i] = buffer[9+i];
|
||||
|
||||
for(char *c = buffer; *c != '\0'; c++)
|
||||
if(*c == '\t') *c = ' ';
|
||||
|
||||
addr[4] = '\0';
|
||||
string a = addr;
|
||||
string b = buffer;
|
||||
sourceLines.insert(make_pair(a, b));
|
||||
}
|
||||
}
|
||||
|
||||
in.close();
|
||||
|
||||
return valueToString(count) + " lines loaded from " + f;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const string Debugger::getSourceLines(int addr) {
|
||||
if(sourceLines.size() == 0)
|
||||
return "no list file loaded (try \"loadlst file.lst\")";
|
||||
|
||||
string ret;
|
||||
string want = to_hex_16(addr);
|
||||
|
||||
bool found = false;
|
||||
pair<ListIter, ListIter> lines = sourceLines.equal_range(want);
|
||||
for(ListIter i = lines.first; i != lines.second; i++) {
|
||||
found = true;
|
||||
ret += i->second;
|
||||
ret += "\n";
|
||||
}
|
||||
|
||||
if(found)
|
||||
return ret;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::autoExec() {
|
||||
string file = myOSystem->romFile();
|
||||
|
|
|
@ -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.57 2005-07-19 17:59:58 stephena Exp $
|
||||
// $Id: Debugger.hxx,v 1.58 2005-07-20 04:28:13 urchlay Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef DEBUGGER_HXX
|
||||
|
@ -27,6 +27,8 @@ class RamDebug;
|
|||
class TIADebug;
|
||||
class TiaOutputWidget;
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "Array.hxx"
|
||||
#include "DialogContainer.hxx"
|
||||
#include "M6502.hxx"
|
||||
|
@ -37,6 +39,9 @@ class TiaOutputWidget;
|
|||
#include "Rect.hxx"
|
||||
#include "bspf.hxx"
|
||||
|
||||
typedef multimap<string,string> ListFile;
|
||||
typedef ListFile::const_iterator ListIter;
|
||||
|
||||
enum {
|
||||
kDebuggerWidth = 639,
|
||||
kDebuggerLineHeight = 12, // based on the height of the console font
|
||||
|
@ -65,7 +70,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.57 2005-07-19 17:59:58 stephena Exp $
|
||||
@version $Id: Debugger.hxx,v 1.58 2005-07-20 04:28:13 urchlay Exp $
|
||||
*/
|
||||
class Debugger : public DialogContainer
|
||||
{
|
||||
|
@ -237,6 +242,9 @@ class Debugger : public DialogContainer
|
|||
int getBank();
|
||||
int bankCount();
|
||||
|
||||
string loadListFile(string f = "");
|
||||
const string getSourceLines(int addr);
|
||||
|
||||
private:
|
||||
/**
|
||||
Save state of each debugger subsystem
|
||||
|
@ -326,6 +334,8 @@ class Debugger : public DialogContainer
|
|||
PackedBitArray *writeTraps;
|
||||
PromptWidget *myPrompt;
|
||||
|
||||
ListFile sourceLines;
|
||||
|
||||
static Debugger* myStaticDebugger;
|
||||
};
|
||||
|
||||
|
|
|
@ -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: DebuggerParser.cxx,v 1.66 2005-07-19 01:31:36 urchlay Exp $
|
||||
// $Id: DebuggerParser.cxx,v 1.67 2005-07-20 04:28:13 urchlay Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "bspf.hxx"
|
||||
|
@ -189,6 +189,14 @@ Command DebuggerParser::commands[] = {
|
|||
&DebuggerParser::executeHelp
|
||||
},
|
||||
|
||||
{
|
||||
"list",
|
||||
"List source (if loaded with loadlst)",
|
||||
false,
|
||||
{ kARG_WORD, kARG_END_ARGS },
|
||||
&DebuggerParser::executeList
|
||||
},
|
||||
|
||||
{
|
||||
"listbreaks",
|
||||
"List breakpoints",
|
||||
|
@ -221,6 +229,14 @@ Command DebuggerParser::commands[] = {
|
|||
&DebuggerParser::executeLoadstate
|
||||
},
|
||||
|
||||
{
|
||||
"loadlst",
|
||||
"Load DASM listing file",
|
||||
true,
|
||||
{ kARG_FILE, kARG_END_ARGS },
|
||||
&DebuggerParser::executeLoadlist
|
||||
},
|
||||
|
||||
{
|
||||
"loadsym",
|
||||
"Load symbol file",
|
||||
|
@ -1295,6 +1311,12 @@ void DebuggerParser::executeFrame() {
|
|||
if(count != 1) commandResult += "s";
|
||||
}
|
||||
|
||||
// "list"
|
||||
void DebuggerParser::executeList() {
|
||||
for(int i=args[0] - 2; i<args[0] + 3; i++)
|
||||
commandResult += debugger->getSourceLines(i);
|
||||
}
|
||||
|
||||
// "listbreaks"
|
||||
void DebuggerParser::executeListbreaks() {
|
||||
commandResult = listBreaks();
|
||||
|
@ -1321,6 +1343,11 @@ void DebuggerParser::executeLoadstate() {
|
|||
}
|
||||
}
|
||||
|
||||
// "loadlist"
|
||||
void DebuggerParser::executeLoadlist() {
|
||||
commandResult = debugger->loadListFile(argStrings[0]);
|
||||
}
|
||||
|
||||
// "loadsym"
|
||||
void DebuggerParser::executeLoadsym() {
|
||||
commandResult = debugger->equateList->loadFile(argStrings[0]);
|
||||
|
|
|
@ -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: DebuggerParser.hxx,v 1.35 2005-07-18 02:03:40 urchlay Exp $
|
||||
// $Id: DebuggerParser.hxx,v 1.36 2005-07-20 04:28:13 urchlay Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef DEBUGGER_PARSER_HXX
|
||||
|
@ -112,9 +112,11 @@ class DebuggerParser
|
|||
void executeFrame();
|
||||
void executeHeight();
|
||||
void executeHelp();
|
||||
void executeList();
|
||||
void executeListbreaks();
|
||||
void executeListtraps();
|
||||
void executeListwatches();
|
||||
void executeLoadlist();
|
||||
void executeLoadsym();
|
||||
void executeLoadstate();
|
||||
void executeN();
|
||||
|
|
Loading…
Reference in New Issue