mirror of
https://github.com/markdavidlong/AppleSAWS.git
synced 2024-12-21 22:29:30 +00:00
Added first push of DisassemblerMetadata processing stuff
This commit is contained in:
parent
cb3f59af4e
commit
a5382655a3
@ -57,7 +57,10 @@ SOURCES += \
|
||||
src/ui/widgets/hexconverter.cpp \
|
||||
src/ui/viewers/viewerbase.cpp \
|
||||
src/ui/widgets/CharacterSetExplorer.cpp \
|
||||
src/ui/widgets/HiresScreenWidget.cpp
|
||||
src/ui/widgets/HiresScreenWidget.cpp \
|
||||
src/ui/widgets/DisassemblerMetadataDialog.cpp \
|
||||
src/binaryfile/EntryPointModel.cpp \
|
||||
src/ui/widgets/LocationInfoDialog.cpp
|
||||
|
||||
|
||||
HEADERS += \
|
||||
@ -97,7 +100,10 @@ HEADERS += \
|
||||
src/ui/viewers/viewerbase.h \
|
||||
src/ui/viewers/fileviewerinterface.h \
|
||||
src/ui/widgets/CharacterSetExplorer.h \
|
||||
src/ui/widgets/HiresScreenWidget.h
|
||||
src/ui/widgets/HiresScreenWidget.h \
|
||||
src/ui/widgets/DisassemblerMetadataDialog.h \
|
||||
src/binaryfile/EntryPointModel.h \
|
||||
src/ui/widgets/LocationInfoDialog.h
|
||||
|
||||
FORMS += \
|
||||
src/ui/catalogwidget.ui \
|
||||
@ -110,4 +116,6 @@ FORMS += \
|
||||
src/ui/widgets/hexconverter.ui \
|
||||
src/ui/widgets/hrcgcontrolsinfo.ui \
|
||||
src/ui/viewers/viewerbase.ui \
|
||||
src/ui/widgets/CharacterSetExplorer.ui
|
||||
src/ui/widgets/CharacterSetExplorer.ui \
|
||||
src/ui/widgets/DisassemblerMetadataDialog.ui \
|
||||
src/ui/widgets/LocationInfoDialog.ui
|
||||
|
155
src/binaryfile/EntryPointModel.cpp
Normal file
155
src/binaryfile/EntryPointModel.cpp
Normal file
@ -0,0 +1,155 @@
|
||||
#include "EntryPointModel.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
EntryPointModel::EntryPointModel(QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant EntryPointModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (orientation == Qt::Horizontal)
|
||||
{
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
if (section == 0)
|
||||
return "";
|
||||
|
||||
}
|
||||
}
|
||||
else // Orientation == Qt::Vertical
|
||||
{
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
return "0x"+uint16ToHex(m_entryPoints[section].address);
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
int EntryPointModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
// if (parent.isValid())
|
||||
return m_entryPoints.count();
|
||||
// else
|
||||
// return 0;
|
||||
}
|
||||
|
||||
int EntryPointModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
//if (parent.isValid())
|
||||
return 1;
|
||||
// else
|
||||
// return 0;
|
||||
}
|
||||
|
||||
QVariant EntryPointModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
EntryPoint ep = m_entryPoints[index.row()];
|
||||
if (index.column() == 0)
|
||||
{
|
||||
return ep.note;
|
||||
}
|
||||
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool EntryPointModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
|
||||
if (data(index, role) != value) {
|
||||
if (index.column() == 0)
|
||||
{
|
||||
m_entryPoints[index.row()].note = value.toString();
|
||||
}
|
||||
|
||||
emit dataChanged(index, index, QVector<int>() << role);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Qt::ItemFlags EntryPointModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
if (index.column() == 0)
|
||||
return Qt::ItemIsEditable | QAbstractTableModel::flags(index);
|
||||
else
|
||||
return QAbstractTableModel::flags(index);
|
||||
}
|
||||
|
||||
bool EntryPointModel::insertRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
beginInsertRows(parent, row, row + count - 1);
|
||||
// FIXME: Implement me!
|
||||
endInsertRows();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EntryPointModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
beginRemoveRows(parent, row, row + count - 1);
|
||||
for (int idx = 0; idx < count; idx++)
|
||||
{
|
||||
m_entryPoints.removeAt(row);
|
||||
}
|
||||
endRemoveRows();
|
||||
return false;
|
||||
}
|
||||
|
||||
void EntryPointModel::doTestData()
|
||||
{
|
||||
EntryPoint ep;
|
||||
ep.address = 0x0010;
|
||||
ep.note = "Test Entry Point 1";
|
||||
addEntryPoint(ep);
|
||||
ep.address = 0x0020;
|
||||
ep.note = "Test Entry Point 2";
|
||||
addEntryPoint(ep);
|
||||
ep.address = 0x0030;
|
||||
ep.note = "Test Entry Point 3";
|
||||
addEntryPoint(ep);
|
||||
|
||||
}
|
||||
|
||||
void EntryPointModel::addEntryPoint(EntryPoint ep)
|
||||
{
|
||||
if (!m_entryPoints.count())
|
||||
{
|
||||
m_entryPoints.append(ep);
|
||||
insertRows(m_entryPoints.count(),1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int idx = 0;
|
||||
for (; idx < m_entryPoints.count(); idx++)
|
||||
{
|
||||
if (ep.address < m_entryPoints[idx].address)
|
||||
break;
|
||||
}
|
||||
m_entryPoints.insert(idx,ep);
|
||||
insertRows(idx,1);
|
||||
}
|
||||
}
|
||||
|
||||
void EntryPointModel::removeSelection(QModelIndexList selection)
|
||||
{
|
||||
if (selection.count() > 1)
|
||||
{
|
||||
qWarning() << "Unexpected number of items to remove. Only removing the first.";
|
||||
}
|
||||
if (selection.count())
|
||||
{
|
||||
removeRow(selection[1].row());
|
||||
}
|
||||
}
|
||||
|
||||
|
50
src/binaryfile/EntryPointModel.h
Normal file
50
src/binaryfile/EntryPointModel.h
Normal file
@ -0,0 +1,50 @@
|
||||
#ifndef ENTRYPOINTMODEL_H
|
||||
#define ENTRYPOINTMODEL_H
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
struct EntryPoint {
|
||||
quint16 address;
|
||||
QString note;
|
||||
};
|
||||
|
||||
class EntryPointModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EntryPointModel(QObject *parent = 0);
|
||||
|
||||
// Header:
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;//DONE
|
||||
|
||||
// Basic functionality:
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override; //DONE
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;//DONE
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;//DONE
|
||||
|
||||
// Editable:
|
||||
bool setData(const QModelIndex &index, const QVariant &value,
|
||||
int role = Qt::EditRole) override;
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
|
||||
// Add data:
|
||||
bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
|
||||
// Remove data:
|
||||
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
|
||||
void doTestData();
|
||||
|
||||
void addEntryPoint(EntryPoint ep);
|
||||
|
||||
void removeSelection(QModelIndexList selection);
|
||||
|
||||
private:
|
||||
QList<EntryPoint> m_entryPoints;
|
||||
|
||||
};
|
||||
|
||||
#endif // ENTRYPOINTMODEL_H
|
@ -1,27 +1,44 @@
|
||||
#include "binaryfilemetadata.h"
|
||||
|
||||
BinaryFileMetadata::BinaryFileMetadata()
|
||||
BinaryFileMetadata::BinaryFileMetadata(QString filename)
|
||||
{
|
||||
|
||||
m_filename = filename;
|
||||
}
|
||||
|
||||
void BinaryFileMetadata::addEntryPoint(quint16 address)
|
||||
{
|
||||
if (!containsEntryPoint(address))
|
||||
{
|
||||
m_entryPoints.append(address);
|
||||
qSort(m_entryPoints);
|
||||
}
|
||||
}
|
||||
//void BinaryFileMetadata::setEntryPoint(quint16 address, QString note)
|
||||
//{
|
||||
// EntryPoint ep;
|
||||
// ep.address = address;
|
||||
// ep.note = note;
|
||||
// setEntryPoint(ep);
|
||||
//}
|
||||
|
||||
void BinaryFileMetadata::addDataRange(AddressRange range)
|
||||
{
|
||||
m_dataRanges.append(range);
|
||||
}
|
||||
//void BinaryFileMetadata::setEntryPoint(EntryPoint ep)
|
||||
//{
|
||||
// m_entryPoints.insert(ep.address,ep);
|
||||
//}
|
||||
|
||||
|
||||
//bool BinaryFileMetadata::hasEntryPointAtAddress(quint16 address)
|
||||
//{
|
||||
// return m_entryPoints.contains(address);
|
||||
//}
|
||||
|
||||
//void BinaryFileMetadata::removeEntryPoint(quint16 address)
|
||||
//{
|
||||
// if (hasEntryPointAtAddress(address))
|
||||
// {
|
||||
// m_entryPoints.remove(address);
|
||||
// }
|
||||
//}
|
||||
|
||||
bool BinaryFileMetadata::load()
|
||||
{
|
||||
return false;
|
||||
setSymbol(0x0000,"Test Symbol 1");
|
||||
setSymbol(0x0006,"Test Symbol 2");
|
||||
// setEntryPoint(0x0010,"Test Entry Point 1");
|
||||
// setEntryPoint(0x0020,"Test Entry Point 2");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BinaryFileMetadata::save()
|
||||
@ -29,15 +46,39 @@ bool BinaryFileMetadata::save()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BinaryFileMetadata::containsEntryPoint(quint16 address)
|
||||
void BinaryFileMetadata::setSymbol(quint16 address, QString name)
|
||||
{
|
||||
return m_entryPoints.contains(address);
|
||||
AssemSymbol symbol;
|
||||
symbol.address = address;
|
||||
symbol.name = name;
|
||||
setSymbol(symbol);
|
||||
}
|
||||
|
||||
void BinaryFileMetadata::removeEntryPoint(quint16 address)
|
||||
void BinaryFileMetadata::setSymbol(AssemSymbol symbol)
|
||||
{
|
||||
if (containsEntryPoint(address))
|
||||
m_symbols.insert(symbol.address, symbol);
|
||||
}
|
||||
|
||||
AssemSymbol BinaryFileMetadata::getSymbolAtAddress(quint16 address)
|
||||
{
|
||||
if (hasSymbolAtAddress(address))
|
||||
{
|
||||
m_entryPoints.removeAll(address);
|
||||
return m_symbols[address];
|
||||
}
|
||||
return AssemSymbol();
|
||||
}
|
||||
|
||||
void BinaryFileMetadata::removeSymbol(AssemSymbol symbol)
|
||||
{
|
||||
removeSymbol(symbol.address);
|
||||
}
|
||||
|
||||
void BinaryFileMetadata::removeSymbol(quint16 address)
|
||||
{
|
||||
if (hasSymbolAtAddress(address))
|
||||
{
|
||||
m_symbols.remove(address);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,50 +3,53 @@
|
||||
|
||||
#include <Qt>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
|
||||
|
||||
struct AddressRange
|
||||
{
|
||||
public:
|
||||
quint16 start;
|
||||
quint16 end;
|
||||
|
||||
quint16 length() { return end-start; }
|
||||
|
||||
bool contains(quint16 address) { return (address >= start && address <= end); }
|
||||
|
||||
struct AssemSymbol {
|
||||
quint16 address;
|
||||
QString name;
|
||||
};
|
||||
|
||||
class BinaryFileMetadata
|
||||
{
|
||||
public:
|
||||
enum UseType {
|
||||
UNKNOWN = 0x00,
|
||||
ROM = 0x01,
|
||||
IO = 0x02,
|
||||
BASIC = 0x04,
|
||||
OPCODE = 0x08,
|
||||
DATA = 0x10
|
||||
};
|
||||
|
||||
BinaryFileMetadata();
|
||||
BinaryFileMetadata(QString filename);
|
||||
|
||||
void addEntryPoint(quint16 address);
|
||||
void addDataRange(AddressRange range);
|
||||
void setFilename(QString filename) { m_filename = filename; }
|
||||
QString filename() const { return m_filename; }
|
||||
|
||||
bool load();
|
||||
bool save();
|
||||
|
||||
bool containsEntryPoint(quint16 address);
|
||||
void removeEntryPoint(quint16 address);
|
||||
// void setEntryPoint(quint16 address, QString note = "");
|
||||
// void setEntryPoint(EntryPoint ep);
|
||||
|
||||
QList<quint16> getEntryPoints() { return m_entryPoints; }
|
||||
QList<AddressRange> getDataRanges() { return m_dataRanges; }
|
||||
// bool hasEntryPointAtAddress(EntryPoint ep);
|
||||
// bool hasEntryPointAtAddress(quint16 address);
|
||||
|
||||
// void removeEntryPoint(quint16 address);
|
||||
|
||||
// QList<EntryPoint> getEntryPointList() const { return m_entryPoints.values(); }
|
||||
// QMap<quint16,EntryPoint> getEntryPointMap() const { return m_entryPoints; }
|
||||
|
||||
void setSymbol(quint16 address, QString name);
|
||||
void setSymbol(AssemSymbol symbol);
|
||||
bool hasSymbol(AssemSymbol symbol) const { return hasSymbolAtAddress(symbol.address); }
|
||||
bool hasSymbolAtAddress(quint16 address) const { return m_symbols.contains(address); }
|
||||
AssemSymbol getSymbolAtAddress(quint16 address);
|
||||
void removeSymbol(AssemSymbol symbol);
|
||||
void removeSymbol(quint16 address);
|
||||
|
||||
QList<AssemSymbol> getSymbolList() const { return m_symbols.values(); }
|
||||
QMap<quint16, AssemSymbol> getSymbolMap() const { return m_symbols; }
|
||||
|
||||
private:
|
||||
QList<quint16> m_entryPoints;
|
||||
QList<AddressRange> m_dataRanges;
|
||||
|
||||
QMap<quint16,AssemSymbol> m_symbols;
|
||||
QString m_filename;
|
||||
};
|
||||
|
||||
#endif // BINARYFILEMETADATA_H
|
||||
|
@ -15,6 +15,10 @@ DisassemblerViewer::DisassemblerViewer(QWidget *parent) :
|
||||
ui(new Ui::DisassemblerViewer)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_isRelo = false;
|
||||
m_dmd = Q_NULLPTR;
|
||||
m_wordWrapAction = Q_NULLPTR;
|
||||
m_showMetadataAction = Q_NULLPTR;
|
||||
|
||||
QString title = QString("Disassembly Viewer");
|
||||
setWindowTitle(title);
|
||||
@ -56,6 +60,7 @@ void DisassemblerViewer::toggleWordWrap(bool enabled)
|
||||
|
||||
void DisassemblerViewer::setFile(BinaryFile *file) {
|
||||
m_file = file;
|
||||
m_isRelo = false;
|
||||
|
||||
QString title = QString("Disassembler Viewer: %1").arg(m_file->filename());
|
||||
setWindowTitle(title);
|
||||
@ -91,7 +96,7 @@ void DisassemblerViewer::setFile(BinaryFile *file) {
|
||||
|
||||
void DisassemblerViewer::setFile(RelocatableFile *file) {
|
||||
m_file = file;
|
||||
|
||||
m_isRelo = true;
|
||||
QString title = QString("Disassembler Viewer: %1 (Relocatable)").arg(m_file->filename());
|
||||
setWindowTitle(title);
|
||||
|
||||
@ -130,7 +135,7 @@ void DisassemblerViewer::setFile(RelocatableFile *file) {
|
||||
QString DisassemblerViewer::getPotentialLabel(quint16 address) {
|
||||
QString retval = QString();
|
||||
|
||||
/* if (address == 0x0A) { retval = "ASBASIC_USRVEC0"; }
|
||||
/* if (address == 0x0A) { retval = "ASBASIC_USRVEC0"; }
|
||||
else if (address == 0x0B) { retval = "ASBASIC_USRVEC1"; }
|
||||
else if (address == 0x0C) { retval = "ASBASIC_USRVEC2"; }
|
||||
else if (address == 0x0D) { retval = "ASBASIC_GENPURPOSE0"; }
|
||||
@ -160,7 +165,7 @@ QString DisassemblerViewer::getPotentialLabel(quint16 address) {
|
||||
else if (address == 0x43) { retval = "DOS_BUFFER_ADDR_H"; }
|
||||
else if (address == 0x44) { retval = "DOS_NUMERIC_OPERAND_L"; }
|
||||
else if (address == 0x45) { retval = "DOS_NUMERIC_OPERAND_H"; }
|
||||
/*
|
||||
/*
|
||||
else if (address == 0x50) { retval = "ASBASIC_PTR_0L"; }
|
||||
else if (address == 0x51) { retval = "ASBASIC_PTR_0H"; }
|
||||
else if (address == 0x52) { retval = "ASBASIC_PTR_1L"; }
|
||||
@ -231,7 +236,7 @@ QString DisassemblerViewer::getPotentialLabel(quint16 address) {
|
||||
|
||||
else if (address == 0x83) { retval = "ASBASIC_LAST_VARVAL_L"; }
|
||||
else if (address == 0x84) { retval = "ASBASIC_LAST_VARVAL_H"; }
|
||||
/*
|
||||
/*
|
||||
else if (address == 0x85) { retval = "ASBASIC_GENPURPOSE10"; }
|
||||
else if (address == 0x86) { retval = "ASBASIC_GENPURPOSE11"; }
|
||||
else if (address == 0x87) { retval = "ASBASIC_GENPURPOSE12"; }
|
||||
@ -281,7 +286,7 @@ QString DisassemblerViewer::getPotentialLabel(quint16 address) {
|
||||
*/
|
||||
else if (address == 0xAF) { retval = "ASBASIC_PROGEND_L"; }
|
||||
else if (address == 0xB0) { retval = "ASBASIC_PROGEND_H"; }
|
||||
/*
|
||||
/*
|
||||
else if (address == 0xB1) { retval = "ASBASIC_CHRGET0"; }
|
||||
else if (address == 0xB2) { retval = "ASBASIC_CHRGET1"; }
|
||||
else if (address == 0xB3) { retval = "ASBASIC_CHRGET2"; }
|
||||
@ -322,7 +327,7 @@ QString DisassemblerViewer::getPotentialLabel(quint16 address) {
|
||||
*/
|
||||
|
||||
else if (address == 0xD6) { retval = "DOS_ASBASIC_PROG_PROT_FLAG"; }
|
||||
/*
|
||||
/*
|
||||
else if (address == 0xD8) { retval = "ASBASIC_ONERR_0L"; }
|
||||
else if (address == 0xD9) { retval = "ASBASIC_ONERR_0H"; }
|
||||
else if (address == 0xDA) { retval = "ASBASIC_ONERR_1L"; }
|
||||
@ -337,7 +342,7 @@ QString DisassemblerViewer::getPotentialLabel(quint16 address) {
|
||||
else if (address == 0xE2) { retval = "ASBASIC_HGR_YCOORD"; }
|
||||
|
||||
else if (address == 0xE4) { retval = "ASBASIC_HGR_COLORBYTE"; }
|
||||
/*
|
||||
/*
|
||||
else if (address == 0xE5) { retval = "ASBASIC_HGR_GENUSE0"; }
|
||||
else if (address == 0xE6) { retval = "ASBASIC_HGR_GENUSE1"; }
|
||||
else if (address == 0xE7) { retval = "ASBASIC_HGR_GENUSE2"; }
|
||||
@ -346,7 +351,7 @@ QString DisassemblerViewer::getPotentialLabel(quint16 address) {
|
||||
else if (address == 0xE9) { retval = "ASBASIC_SHAPETBL_H"; }
|
||||
|
||||
else if (address == 0xEA) { retval = "ASBASIC_HGR_COLLISION_CTR"; }
|
||||
/*
|
||||
/*
|
||||
else if (address == 0xF0) { retval = "ASBASIC_GENUSE_FLAGS3"; }
|
||||
else if (address == 0xF1) { retval = "ASBASIC_GENUSE_FLAGS4"; }
|
||||
else if (address == 0xF2) { retval = "ASBASIC_GENUSE_FLAGS5"; }
|
||||
@ -1416,15 +1421,35 @@ bool DisassemblerViewer::optionsMenuItems(QMenu *menu)
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
QAction *action = new QAction("&Word Wrap");
|
||||
action->setCheckable(true);
|
||||
action->setChecked(settings.value("DisassemblerViewer.WordWrap",true).toBool());
|
||||
connect(action, SIGNAL(toggled(bool)), SLOT(toggleWordWrap(bool)));
|
||||
menu->addAction(action);
|
||||
if (!m_wordWrapAction) {
|
||||
m_wordWrapAction = new QAction("&Word Wrap");
|
||||
m_wordWrapAction->setCheckable(true);
|
||||
m_wordWrapAction->setChecked(settings.value("DisassemblerViewer.WordWrap",true).toBool());
|
||||
connect(m_wordWrapAction, SIGNAL(toggled(bool)), SLOT(toggleWordWrap(bool)));
|
||||
}
|
||||
menu->addAction(m_wordWrapAction);
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
if (!m_showMetadataAction) {
|
||||
m_showMetadataAction = new QAction("&Dissassembler Metadata");
|
||||
connect(m_showMetadataAction, SIGNAL(triggered(bool)), SLOT(showMetadataDialog()));
|
||||
}
|
||||
menu->addAction(m_showMetadataAction);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DisassemblerViewer::showMetadataDialog()
|
||||
{
|
||||
if (!m_dmd) {
|
||||
m_dmd = new DisassemblerMetadataDialog(this);
|
||||
m_dmd->setRelocatable(m_isRelo);
|
||||
}
|
||||
m_dmd->show();
|
||||
m_dmd->raise();
|
||||
}
|
||||
|
||||
void DisassemblerViewer::setData(QByteArray data)
|
||||
{
|
||||
ui->textArea->setText(data);
|
||||
@ -1462,7 +1487,7 @@ void DisassemblerViewer::doExport()
|
||||
QDir savename = QDir(defaultPath).filePath(m_file->filename()+".txt");
|
||||
|
||||
QString saveName = QFileDialog::getSaveFileName(this,
|
||||
tr("Export Disassembly"), savename.path(), tr("Text Files (*.txt)"));
|
||||
tr("Export Disassembly"), savename.path(), tr("Text Files (*.txt)"));
|
||||
|
||||
if (saveName == "") return; // User cancelled
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "binaryfile.h"
|
||||
#include "relocatablefile.h"
|
||||
#include "fileviewerinterface.h"
|
||||
#include "DisassemblerMetadataDialog.h"
|
||||
|
||||
namespace Ui {
|
||||
class DisassemblerViewer;
|
||||
@ -36,10 +37,18 @@ public slots:
|
||||
|
||||
void doPrint();
|
||||
void doExport();
|
||||
protected slots:
|
||||
void showMetadataDialog();
|
||||
private:
|
||||
Ui::DisassemblerViewer *ui;
|
||||
|
||||
DisassemblerMetadataDialog *m_dmd;
|
||||
GenericFile *m_file;
|
||||
|
||||
QAction *m_wordWrapAction;
|
||||
QAction *m_showMetadataAction;
|
||||
|
||||
bool m_isRelo;
|
||||
};
|
||||
|
||||
#endif // DISASSEMBLERVIEWER_H
|
||||
|
110
src/ui/widgets/DisassemblerMetadataDialog.cpp
Normal file
110
src/ui/widgets/DisassemblerMetadataDialog.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
#include "DisassemblerMetadataDialog.h"
|
||||
#include "ui_DisassemblerMetadataDialog.h"
|
||||
#include "util.h"
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
DisassemblerMetadataDialog::DisassemblerMetadataDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DisassemblerMetadataDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setRelocatable(false);
|
||||
|
||||
m_bfm = new BinaryFileMetadata("Test");
|
||||
m_bfm->load();
|
||||
|
||||
m_epmodel = new EntryPointModel(this);
|
||||
|
||||
|
||||
processEntryPoints();
|
||||
processSymbols();
|
||||
|
||||
ui->entryTable->setModel(m_epmodel);
|
||||
|
||||
connect(ui->cancelButton, SIGNAL(clicked(bool)), SLOT(handleCancelButton()));
|
||||
connect(ui->exitButton,SIGNAL(clicked(bool)), SLOT(handleExitButton()));
|
||||
connect(ui->processButton, SIGNAL(clicked(bool)), SLOT(handleProcessButton()));
|
||||
|
||||
connect(ui->addEntryPointButton, SIGNAL(clicked(bool)), SLOT(handleAddEntryPointButton()));
|
||||
connect(ui->addSymbolButton, SIGNAL(clicked(bool)), SLOT(handleAddSymbolButton()));
|
||||
}
|
||||
|
||||
DisassemblerMetadataDialog::~DisassemblerMetadataDialog()
|
||||
{
|
||||
delete m_bfm;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DisassemblerMetadataDialog::setRelocatable(bool relocatable)
|
||||
{
|
||||
ui->reloAddrLabel->setVisible(relocatable);
|
||||
ui->reloAddrText->setVisible(relocatable);
|
||||
}
|
||||
|
||||
void DisassemblerMetadataDialog::handleCancelButton()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
void DisassemblerMetadataDialog::handleExitButton()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
void DisassemblerMetadataDialog::handleProcessButton()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DisassemblerMetadataDialog::handleAddEntryPointButton()
|
||||
{
|
||||
LocationInfoDialog lid(this);
|
||||
lid.setWindowTitle("Add Entry Point");
|
||||
if (lid.exec() == Accepted)
|
||||
{
|
||||
EntryPoint ep;
|
||||
ep.address = lid.getAddress();
|
||||
ep.note = lid.getInfo();
|
||||
m_epmodel->addEntryPoint(ep);
|
||||
}
|
||||
}
|
||||
|
||||
void DisassemblerMetadataDialog::handleRemoveEntryPointButton()
|
||||
{
|
||||
// QModelIndexList selection = ui->entryTable->selectedIndexes();
|
||||
// if (selection.count())
|
||||
// {
|
||||
// m_epmodel->removeSelection(selection);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
void DisassemblerMetadataDialog::handleAddSymbolButton()
|
||||
{
|
||||
LocationInfoDialog lid(this);
|
||||
lid.setInfoLabelString("Symbol");
|
||||
lid.setWindowTitle("Add Symbol");
|
||||
if (lid.exec() == Accepted)
|
||||
{
|
||||
qDebug() << "Accepted";
|
||||
}
|
||||
else qDebug()<<"Rejected";
|
||||
}
|
||||
|
||||
void DisassemblerMetadataDialog::handleRemoveSymbolButton()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DisassemblerMetadataDialog::processSymbols()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DisassemblerMetadataDialog::processEntryPoints()
|
||||
{
|
||||
m_epmodel->doTestData();
|
||||
}
|
50
src/ui/widgets/DisassemblerMetadataDialog.h
Normal file
50
src/ui/widgets/DisassemblerMetadataDialog.h
Normal file
@ -0,0 +1,50 @@
|
||||
#ifndef DISASSEMBLERMETADATADIALOG_H
|
||||
#define DISASSEMBLERMETADATADIALOG_H
|
||||
|
||||
#include "binaryfilemetadata.h"
|
||||
#include "EntryPointModel.h"
|
||||
#include "LocationInfoDialog.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class DisassemblerMetadataDialog;
|
||||
}
|
||||
|
||||
class DisassemblerMetadataDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DisassemblerMetadataDialog(QWidget *parent = 0);
|
||||
~DisassemblerMetadataDialog();
|
||||
|
||||
void setRelocatable(bool relocatable);
|
||||
|
||||
void processSymbols();
|
||||
void processEntryPoints();
|
||||
|
||||
protected slots:
|
||||
void handleCancelButton();
|
||||
void handleExitButton();
|
||||
void handleProcessButton();
|
||||
|
||||
void handleAddEntryPointButton();
|
||||
void handleRemoveEntryPointButton();
|
||||
|
||||
void handleAddSymbolButton();
|
||||
void handleRemoveSymbolButton();
|
||||
|
||||
|
||||
private:
|
||||
Ui::DisassemblerMetadataDialog *ui;
|
||||
|
||||
BinaryFileMetadata *m_bfm;
|
||||
|
||||
EntryPointModel *m_epmodel;
|
||||
|
||||
bool m_isRelocatable;
|
||||
};
|
||||
|
||||
|
||||
#endif // DISASSEMBLERMETADATADIALOG_H
|
229
src/ui/widgets/DisassemblerMetadataDialog.ui
Normal file
229
src/ui/widgets/DisassemblerMetadataDialog.ui
Normal file
@ -0,0 +1,229 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DisassemblerMetadataDialog</class>
|
||||
<widget class="QDialog" name="DisassemblerMetadataDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>796</width>
|
||||
<height>593</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4" rowstretch="2,3,0">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Entry Points</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>312</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QToolButton" name="addEntryPointButton">
|
||||
<property name="text">
|
||||
<string>+</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="removeEntryPointButton">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="QTableView" name="entryTable">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Symbols</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>311</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QToolButton" name="addSymbolButton">
|
||||
<property name="text">
|
||||
<string>+</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="removeSymbolButton">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="QTableView" name="symbolTable"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Usage</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5" stretch="10,1">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QPushButton" name="processButton">
|
||||
<property name="text">
|
||||
<string>&Process</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="outputLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>xxxxx</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="reloAddrLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reloc. Addr</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="reloAddrText">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTableView" name="metadataTable"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0,0,0">
|
||||
<item>
|
||||
<spacer name="hs2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cancelButton">
|
||||
<property name="text">
|
||||
<string>&Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="exitButton">
|
||||
<property name="text">
|
||||
<string>&Exit</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
29
src/ui/widgets/LocationInfoDialog.cpp
Normal file
29
src/ui/widgets/LocationInfoDialog.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include "LocationInfoDialog.h"
|
||||
#include "ui_LocationInfoDialog.h"
|
||||
|
||||
LocationInfoDialog::LocationInfoDialog(QWidget *parent) :
|
||||
QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowTitleHint ),
|
||||
ui(new Ui::LocationInfoDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
LocationInfoDialog::~LocationInfoDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void LocationInfoDialog::setInfoLabelString(QString label)
|
||||
{
|
||||
ui->infoLabel->setText(label);
|
||||
}
|
||||
|
||||
quint16 LocationInfoDialog::getAddress()
|
||||
{
|
||||
return ui->addressEdit->text().toInt(Q_NULLPTR,16);
|
||||
}
|
||||
|
||||
QString LocationInfoDialog::getInfo()
|
||||
{
|
||||
return ui->infoEdit->text();
|
||||
}
|
29
src/ui/widgets/LocationInfoDialog.h
Normal file
29
src/ui/widgets/LocationInfoDialog.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef LOCATIONINFODIALOG_H
|
||||
#define LOCATIONINFODIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
|
||||
namespace Ui {
|
||||
class LocationInfoDialog;
|
||||
}
|
||||
|
||||
class LocationInfoDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LocationInfoDialog(QWidget *parent = 0);
|
||||
~LocationInfoDialog();
|
||||
|
||||
void setInfoLabelString(QString label);
|
||||
quint16 getAddress();
|
||||
QString getInfo();
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
Ui::LocationInfoDialog *ui;
|
||||
};
|
||||
|
||||
#endif // LOCATIONINFODIALOG_H
|
98
src/ui/widgets/LocationInfoDialog.ui
Normal file
98
src/ui/widgets/LocationInfoDialog.ui
Normal file
@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LocationInfoDialog</class>
|
||||
<widget class="QDialog" name="LocationInfoDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>284</width>
|
||||
<height>99</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="addressLabel">
|
||||
<property name="text">
|
||||
<string>Address</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="addressEdit">
|
||||
<property name="inputMask">
|
||||
<string>HHHH</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="infoLabel">
|
||||
<property name="text">
|
||||
<string>Note</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="infoEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>LocationInfoDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>LocationInfoDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
Loading…
Reference in New Issue
Block a user