Skip to content

Commit

Permalink
Move debug dump to CLI option, don't dump by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
DirtyHairy committed Aug 11, 2024
1 parent 76a9d84 commit 90da70a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
31 changes: 12 additions & 19 deletions src/emucore/CartELF.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
//============================================================================

#include <sstream>

#ifdef DUMP_ELF
#include <ofstream>
#endif
#include <fstream>

#include "System.hxx"
#include "ElfLinker.hxx"
Expand All @@ -31,16 +28,13 @@

#include "CartELF.hxx"

#define DUMP_ELF

using namespace elfEnvironment;

namespace {
constexpr size_t TRANSACTION_QUEUE_CAPACITY = 16384;
constexpr uInt32 ARM_RUNAHED_MIN = 3;
constexpr uInt32 ARM_RUNAHED_MAX = 6;

#ifdef DUMP_ELF
void dumpElf(const ElfFile& elf)
{
cout << "\nELF sections:\n\n";
Expand Down Expand Up @@ -174,7 +168,6 @@ namespace {

cout << "wrote executable image to " << IMAGE_FILE_NAME << '\n';
}
#endif

SystemType determineSystemType(const Properties* props)
{
Expand Down Expand Up @@ -470,15 +463,15 @@ inline uInt8 CartridgeELF::driveBus(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeELF::parseAndLinkElf()
{
const bool dump = mySettings.getBool("elf.dump");

try {
myElfParser.parse(myImage.get(), myImageSize);
} catch (ElfParser::ElfParseError& e) {
throw runtime_error("failed to initialize ELF: " + string(e.what()));
}

#ifdef DUMP_ELF
dumpElf(myElfParser);
#endif
if (dump) dumpElf(myElfParser);

myLinker = make_unique<ElfLinker>(ADDR_TEXT_BASE, ADDR_DATA_BASE, ADDR_RODATA_BASE, myElfParser);
try {
Expand All @@ -502,16 +495,16 @@ void CartridgeELF::parseAndLinkElf()
if (myLinker->getSegmentSize(ElfLinker::SegmentType::rodata) > RODATA_SIZE)
throw runtime_error("rodata segment too large");

#ifdef DUMP_ELF
dumpLinkage(myElfParser, *myLinker);
if (dump) {
dumpLinkage(myElfParser, *myLinker);

cout
<< "\nARM entrypoint: 0x"
<< std::hex << std::setw(8) << std::setfill('0') << myArmEntrypoint
<< std::dec << '\n';
cout
<< "\nARM entrypoint: 0x"
<< std::hex << std::setw(8) << std::setfill('0') << myArmEntrypoint
<< std::dec << '\n';

writeDebugBinary(*myLinker);
#endif
writeDebugBinary(*myLinker);
}
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down
5 changes: 4 additions & 1 deletion src/emucore/Settings.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ Settings::Settings()
setPermanent("dev.thumb.chiptype", "0"); // = LPC2103
setPermanent("dev.thumb.mammode", "2");
#endif

setTemporary("elf.dump", false);
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down Expand Up @@ -818,7 +820,8 @@ void Settings::usage()
<< " -dev.tia.pfscoreglitch <1|0> Enable PF score mode color glitch\n"
<< " -dev.tia.delaybkcolor <1|0> Enable extra delay cycle for background color\n"
<< " -dev.tia.delayplswap <1|0> Enable extra delay cycle for VDELP0/1 swap\n"
<< " -dev.tia.delayblswap <1|0> Enable extra delay cycle for VDELBL swap\n\n";
<< " -dev.tia.delayblswap <1|0> Enable extra delay cycle for VDELBL swap\n"
<< " -elf.dump <1|0> Dump ELF linkage information and write elf_executable_image.bin\n\n";

#ifdef BSPF_WINDOWS
// int height = 25;
Expand Down

0 comments on commit 90da70a

Please sign in to comment.