Skip to content

Instantly share code, notes, and snippets.

@h1romas4
Last active September 9, 2021 12:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h1romas4/5f6579fcaad77cab3413ff437188a2f2 to your computer and use it in GitHub Desktop.
Save h1romas4/5f6579fcaad77cab3413ff437188a2f2 to your computer and use it in GitHub Desktop.
openmsx-debugger で z88dk の -m 形式の .map symbol を読ませる hack + Ubuntu 20.04 LTS Qt 5.12 Obsolete fix
diff --git a/src/DebuggerForm.cpp b/src/DebuggerForm.cpp
index 9283c94..be463e8 100644
--- a/src/DebuggerForm.cpp
+++ b/src/DebuggerForm.cpp
@@ -621,7 +621,7 @@ void DebuggerForm::createForm()
// add widgets
for (int i = 0; i < list.size(); ++i) {
- QStringList s = list.at(i).split(" ", Qt::SkipEmptyParts);
+ QStringList s = list.at(i).split(" ", QString::SplitBehavior::SkipEmptyParts);
// get widget
if ((dw = dockMan.findDockableWidget(s.at(0)))) {
if (s.at(1) == "D") {
@@ -1451,7 +1451,7 @@ void DebuggerForm::setDebuggables(const QString& list)
debuggables.clear();
// process result string
- QStringList l = list.split(" ", Qt::SkipEmptyParts);
+ QStringList l = list.split(" ", QString::SplitBehavior::SkipEmptyParts);
for (int i = 0; i < l.size(); ++i) {
QString d = l[i];
// combine multiple words
diff --git a/src/SymbolManager.cpp b/src/SymbolManager.cpp
index c037c0c..1dae827 100644
--- a/src/SymbolManager.cpp
+++ b/src/SymbolManager.cpp
@@ -126,6 +126,7 @@ void SymbolManager::addFile()
<< "tniASM 1.x symbol files (*.sym)"
<< "asMSX 0.x symbol files (*.sym)"
<< "HiTech C symbol files (*.sym)"
+ << "Z88DK map files (*.map)"
<< "HiTech C link map files (*.map)"
<< "pasmo symbol files (*.symbol *.publics *.sys)";
d->setNameFilters(types);
@@ -147,6 +148,8 @@ void SymbolManager::addFile()
read = symTable.readFile(n, SymbolTable::ASMSX_FILE);
} else if (f.startsWith("HiTech C symbol")) {
read = symTable.readFile(n, SymbolTable::HTC_FILE);
+ } else if (f.startsWith("Z88DK map")) {
+ read = symTable.readFile(n, SymbolTable::Z88DK_FILE);
} else if (f.startsWith("HiTech C link")) {
read = symTable.readFile(n, SymbolTable::LINKMAP_FILE);
} else if (f.startsWith("pasmo")) {
diff --git a/src/SymbolTable.cpp b/src/SymbolTable.cpp
index 2b7cf16..bcf8811 100644
--- a/src/SymbolTable.cpp
+++ b/src/SymbolTable.cpp
@@ -184,7 +184,9 @@ bool SymbolTable::readFile(const QString& filename, FileType type)
if (type == DETECT_FILE) {
if (filename.toLower().endsWith(".map")) {
// HiTech link map file
- type = LINKMAP_FILE;
+ // TODO: Z88DK hack
+ // type = LINKMAP_FILE;
+ type = Z88DK_FILE;
} else if (filename.toLower().endsWith(".sym")) {
// auto detect which sym file
QFile file(filename);
@@ -229,6 +231,8 @@ bool SymbolTable::readFile(const QString& filename, FileType type)
return readASMSXFile(filename);
case HTC_FILE:
return readHTCFile(filename);
+ case Z88DK_FILE:
+ return readZ88DKFile(filename);
case LINKMAP_FILE:
return readLinkMapFile(filename);
case PASMO_FILE:
@@ -392,6 +396,32 @@ bool SymbolTable::readHTCFile(const QString& filename)
return true;
}
+bool SymbolTable::readZ88DKFile(const QString& filename)
+{
+ QFile file(filename);
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ return false;
+ }
+
+ appendFile(filename, Z88DK_FILE);
+ QTextStream in(&file);
+ while (!in.atEnd()) {
+ QString line = in.readLine();
+ QStringList l = line.split(QRegExp("(\t+)|( +)"));
+ if (l.size() < 3) continue;
+ int value;
+ // ex. $0001
+ // printf("@@@ %s", l.at(2).mid(1, 4).toStdString().c_str());
+ if (!parseValue("0x" + l.at(2).mid(1, 4), value)) continue;
+ // hack ex. $FFFFFFFFFFFF03B6
+ if (value == 0xffff) continue;
+ auto* sym = new Symbol(l.at(0), value);
+ sym->setSource(&symbolFiles.back().fileName);
+ add(sym);
+ }
+ return true;
+}
+
bool SymbolTable::readLinkMapFile(const QString& filename)
{
const QString magic("Machine type");
diff --git a/src/SymbolTable.h b/src/SymbolTable.h
index 1b7e761..b2d2e1e 100644
--- a/src/SymbolTable.h
+++ b/src/SymbolTable.h
@@ -81,6 +81,7 @@ public:
ASMSX_FILE,
LINKMAP_FILE,
HTC_FILE,
+ Z88DK_FILE,
PASMO_FILE
};
@@ -127,6 +128,7 @@ private:
bool readASMSXFile(const QString& filename);
bool readSJASMFile(const QString& filename);
bool readHTCFile(const QString& filename);
+ bool readZ88DKFile(const QString& filename);
bool readLinkMapFile(const QString& filename);
bool readPASMOFile(const QString& filename);
@h1romas4
Copy link
Author

h1romas4 commented Sep 7, 2021

add zcc compile option -m (create map).

image

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment