added some ARM stats to CDF debug widget

This commit is contained in:
thrust26 2021-02-09 19:47:50 +01:00
parent 7199ab7feb
commit 3c188fbb9a
6 changed files with 79 additions and 18 deletions

View File

@ -17,6 +17,7 @@
#include "DataGridWidget.hxx" #include "DataGridWidget.hxx"
#include "PopUpWidget.hxx" #include "PopUpWidget.hxx"
#include "EditTextWidget.hxx"
#include "CartCDFWidget.hxx" #include "CartCDFWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -68,7 +69,7 @@ CartridgeCDFWidget::CartridgeCDFWidget(
// Datastream Pointers // Datastream Pointers
#define DS_X (HBORDER + _font.getStringWidth("xx ")) #define DS_X (HBORDER + _font.getStringWidth("xx "))
xpos = DS_X; xpos = DS_X;
ypos += myLineHeight + VGAP * 4; ypos += myLineHeight + VGAP * 3;
new StaticTextWidget(boss, _font, xpos, ypos, "Datastream Pointers"); new StaticTextWidget(boss, _font, xpos, ypos, "Datastream Pointers");
myDatastreamPointers = new DataGridWidget(boss, _nfont, DS_X, myDatastreamPointers = new DataGridWidget(boss, _nfont, DS_X,
@ -135,7 +136,7 @@ CartridgeCDFWidget::CartridgeCDFWidget(
Common::Base::Fmt::_16_2_2); Common::Base::Fmt::_16_2_2);
myJumpStreamIncrements->setTarget(this); myJumpStreamIncrements->setTarget(this);
myJumpStreamIncrements->setEditable(false); myJumpStreamIncrements->setEditable(false);
xpos = HBORDER; ypos += myLineHeight * 11 + VGAP * 4; xpos = HBORDER; ypos += myLineHeight * 11 + VGAP * 3;
lwidth = _font.getStringWidth("Waveform Sizes "); lwidth = _font.getStringWidth("Waveform Sizes ");
@ -198,6 +199,34 @@ CartridgeCDFWidget::CartridgeCDFWidget(
Common::Base::Fmt::_16_8); Common::Base::Fmt::_16_8);
mySamplePointer->setTarget(this); mySamplePointer->setTarget(this);
mySamplePointer->setEditable(false); mySamplePointer->setEditable(false);
xpos = HBORDER; ypos += myLineHeight + VGAP * 2;
new StaticTextWidget(boss, _font, xpos, ypos + 1, "Last ARM run stats:");
xpos = HBORDER + INDENT; ypos += myLineHeight + VGAP;
StaticTextWidget* s = new StaticTextWidget(boss, _font, xpos, ypos + 1, "Mem. cycles ");
myThumbMemCycles = new EditTextWidget(boss, _font, s->getRight(), ypos - 1,
EditTextWidget::calcWidth(_font, 6), myLineHeight, "");
myThumbMemCycles->setEditable(false);
myThumbMemCycles->setToolTip("Number of memory cycles of last ARM run.");
s = new StaticTextWidget(boss, _font, myThumbMemCycles->getRight() + _fontWidth * 2, ypos + 1, "Fetches ");
myThumbFetches = new EditTextWidget(boss, _font, s->getRight(), ypos - 1,
EditTextWidget::calcWidth(_font, 6), myLineHeight, "");
myThumbFetches->setEditable(false);
myThumbFetches->setToolTip("Number of fetches/instructions of last ARM run.");
ypos += myLineHeight + VGAP;
s = new StaticTextWidget(boss, _font, xpos, ypos + 1, "Reads ");
myThumbReads = new EditTextWidget(boss, _font, myThumbMemCycles->getLeft(), ypos - 1,
EditTextWidget::calcWidth(_font, 6), myLineHeight, "");
myThumbReads->setEditable(false);
myThumbReads->setToolTip("Number of reads of last ARM run.");
s = new StaticTextWidget(boss, _font, myThumbReads->getRight() + _fontWidth * 2, ypos + 1, "Writes ");
myThumbWrites = new EditTextWidget(boss, _font, myThumbFetches->getLeft(), ypos - 1,
EditTextWidget::calcWidth(_font, 6), myLineHeight, "");
myThumbWrites->setEditable(false);
myThumbWrites->setToolTip("Number of write of last ARM run.");
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -376,6 +405,16 @@ void CartridgeCDFWidget::loadConfig()
mySamplePointer->setCrossed(true); mySamplePointer->setCrossed(true);
} }
myThumbMemCycles->setText(Common::Base::toString(myCart.stats().fetches
+ myCart.stats().reads + myCart.stats().writes,
Common::Base::Fmt::_10_6));
myThumbFetches->setText(Common::Base::toString(myCart.stats().fetches,
Common::Base::Fmt::_10_6));
myThumbReads->setText(Common::Base::toString(myCart.stats().reads,
Common::Base::Fmt::_10_6));
myThumbWrites->setText(Common::Base::toString(myCart.stats().writes,
Common::Base::Fmt::_10_6));
CartDebugWidget::loadConfig(); CartDebugWidget::loadConfig();
} }

View File

@ -22,6 +22,7 @@ class PopUpWidget;
class CheckboxWidget; class CheckboxWidget;
class DataGridWidget; class DataGridWidget;
class StaticTextWidget; class StaticTextWidget;
class EditTextWidget;
#include "CartCDF.hxx" #include "CartCDF.hxx"
#include "CartDebugWidget.hxx" #include "CartDebugWidget.hxx"
@ -69,6 +70,11 @@ class CartridgeCDFWidget : public CartDebugWidget
CheckboxWidget* myFastFetch{nullptr}; CheckboxWidget* myFastFetch{nullptr};
CheckboxWidget* myDigitalSample{nullptr}; CheckboxWidget* myDigitalSample{nullptr};
EditTextWidget* myThumbMemCycles{nullptr};
EditTextWidget* myThumbFetches{nullptr};
EditTextWidget* myThumbReads{nullptr};
EditTextWidget* myThumbWrites{nullptr};
CartState myOldState; CartState myOldState;
enum { kBankChanged = 'bkCH' }; enum { kBankChanged = 'bkCH' };

View File

@ -827,3 +827,9 @@ uInt32 CartridgeCDF::romSize() const
return new CartridgeCDFInfoWidget(boss, lfont, nfont, x, y, w, h, *this); return new CartridgeCDFInfoWidget(boss, lfont, nfont, x, y, w, h, *this);
} }
#endif #endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Thumbulator::Stats& CartridgeCDF::stats() const
{
return myThumbEmulator->stats();
}

View File

@ -19,9 +19,9 @@
#define CARTRIDGE_CDF_HXX #define CARTRIDGE_CDF_HXX
class System; class System;
class Thumbulator;
#include "bspf.hxx" #include "bspf.hxx"
#include "Thumbulator.hxx"
#include "Cart.hxx" #include "Cart.hxx"
/** /**
@ -264,6 +264,9 @@ class CartridgeCDF : public Cartridge
uInt32 getSample(); uInt32 getSample();
void setupVersion(); void setupVersion();
// Get number of instructions of last ARM run.
const Thumbulator::Stats& CartridgeCDF::stats() const;
private: private:
// The ROM image of the cartridge // The ROM image of the cartridge
ByteBuffer myImage{nullptr}; ByteBuffer myImage{nullptr};

View File

@ -158,11 +158,13 @@ inline int Thumbulator::fatalError(const char* opcode, uInt32 v1, uInt32 v2,
void Thumbulator::dump_counters() void Thumbulator::dump_counters()
{ {
cout << endl << endl cout << endl << endl
<< "instructions " << instructions << endl << "instructions " << instructions << endl;
<< "fetches " << fetches << endl #ifndef NO_THUMB_STATS
<< "reads " << reads << endl cout << "fetches " << _stats.fetches << endl
<< "writes " << writes << endl << "reads " << _stats.reads << endl
<< "memcycles " << (fetches+reads+writes) << endl; << "writes " << _stats.writes << endl
<< "memcycles " << (_stats.fetches + _stats.reads + _stats.writes) << endl;
#endif
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -186,7 +188,7 @@ void Thumbulator::dump_regs()
uInt32 Thumbulator::fetch16(uInt32 addr) uInt32 Thumbulator::fetch16(uInt32 addr)
{ {
#ifndef NO_THUMB_STATS #ifndef NO_THUMB_STATS
++fetches; ++_stats.fetches;
#endif #endif
#ifndef UNSAFE_OPTIMIZATIONS #ifndef UNSAFE_OPTIMIZATIONS
@ -230,7 +232,7 @@ void Thumbulator::write16(uInt32 addr, uInt32 data)
fatalError("write16", addr, "abort - misaligned"); fatalError("write16", addr, "abort - misaligned");
#endif #endif
#ifndef NO_THUMB_STATS #ifndef NO_THUMB_STATS
++writes; ++_stats.writes;
#endif #endif
DO_DBUG(statusMsg << "write16(" << Base::HEX8 << addr << "," << Base::HEX8 << data << ")" << endl); DO_DBUG(statusMsg << "write16(" << Base::HEX8 << addr << "," << Base::HEX8 << data << ")" << endl);
@ -404,7 +406,7 @@ uInt32 Thumbulator::read16(uInt32 addr)
fatalError("read16", addr, "abort - misaligned"); fatalError("read16", addr, "abort - misaligned");
#endif #endif
#ifndef NO_THUMB_STATS #ifndef NO_THUMB_STATS
++reads; ++_stats.reads;
#endif #endif
switch(addr & 0xF0000000) switch(addr & 0xF0000000)
@ -2546,7 +2548,7 @@ int Thumbulator::reset()
statusMsg.str(""); statusMsg.str("");
#endif #endif
#ifndef NO_THUMB_STATS #ifndef NO_THUMB_STATS
fetches = reads = writes = 0; _stats.fetches = _stats.reads = _stats.writes = 0;
#endif #endif
return 0; return 0;

View File

@ -60,6 +60,12 @@ class Thumbulator
DPCplus // cartridges of type DPC+ DPCplus // cartridges of type DPC+
}; };
struct Stats {
#ifndef NO_THUMB_STATS
uInt32 fetches{0}, reads{0}, writes{0};
#endif
};
Thumbulator(const uInt16* rom_ptr, uInt16* ram_ptr, uInt32 rom_size, Thumbulator(const uInt16* rom_ptr, uInt16* ram_ptr, uInt32 rom_size,
const uInt32 c_base, const uInt32 c_start, const uInt32 c_stack, const uInt32 c_base, const uInt32 c_start, const uInt32 c_stack,
bool traponfatal, Thumbulator::ConfigureFor configurefor, bool traponfatal, Thumbulator::ConfigureFor configurefor,
@ -75,6 +81,7 @@ class Thumbulator
*/ */
string run(); string run();
string run(uInt32 cycles); string run(uInt32 cycles);
const Stats& stats() const { return _stats; }
#ifndef UNSAFE_OPTIMIZATIONS #ifndef UNSAFE_OPTIMIZATIONS
/** /**
@ -198,12 +205,10 @@ class Thumbulator
uInt32 cpsr{0}, mamcr{0}; uInt32 cpsr{0}, mamcr{0};
bool handler_mode{false}; bool handler_mode{false};
uInt32 systick_ctrl{0}, systick_reload{0}, systick_count{0}, systick_calibrate{0}; uInt32 systick_ctrl{0}, systick_reload{0}, systick_count{0}, systick_calibrate{0};
#ifndef UNSAFE_OPTIMIZATIONS #ifndef UNSAFE_OPTIMIZATIONS
uInt64 instructions{0}; uInt32 instructions{0};
#endif #endif
#ifndef NO_THUMB_STATS Stats _stats;
uInt64 fetches{0}, reads{0}, writes{0};
#endif
// For emulation of LPC2103's timer 1, used for NTSC/PAL/SECAM detection. // For emulation of LPC2103's timer 1, used for NTSC/PAL/SECAM detection.
// Register names from documentation: // Register names from documentation: