fxos/fxos/library.cpp

50 lines
958 B
C++

#include "fxos-cli.h"
#include <fxos/target.h>
#include <fxos/util.h>
using namespace FxOS;
/* Print the details of a single target on standard output */
void show_target(std::string name, TargetDescription const &tgt)
{
printf(" %s:", name.c_str());
for(TargetDescription::Binding const &b: tgt.bindings)
{
MemoryRegion const &reg = b.first;
if(reg.name != "")
printf(" %s", reg.name.c_str());
else
printf(" %08x(%x)", reg.start, reg.size());
}
printf("\n");
}
void show_library(FxOS::Library &library, bool targets, bool asmtables)
{
if(targets)
{
printf("Targets:\n");
for(auto &pair: library.targets())
{
show_target(pair.first, pair.second);
}
}
if(asmtables)
{
printf("Assembly tables:\n");
for(auto const &pair: library.asm_tables())
{
std::string const &name = pair.first;
int instruction_count = pair.second;
printf(" %s (%d instructions)\n", name.c_str(),
instruction_count);
}
}
}