//--- // fxos.disasm-passes.print: Concrete program printer // // This pass prints the program and some to all of its annotations, depending // on the specified parameters. //--- #ifndef LIBFXOS_DISASM_PASSES_PRINT_H #define LIBFXOS_DISASM_PASSES_PRINT_H #include #include #include namespace FxOS { class PrintPass: public InstructionDisassemblyPass { public: PrintPass(Disassembly &disasm, std::vector const &symtables); void analyze(uint32_t pc, ConcreteInstruction &inst) override; //--- // Print pass parameters //--- /* Promotion parameters. Default is always to append. */ enum Promotion { /* Never promote */ Never=1, /* Promote but keep the lower-level information */ Append=0, /* Promote and hide the lower-level information */ Promote=2, }; /** In the following, promote_x always means promote *to x* **/ /* In jumps, promote "pc+" to the target address */ int promote_pcjump_loc; /* In a PC-relative mov, promote "@(,pc)" to computed address */ int promote_pcrel_loc; /* In a PC-relative mov, promote address to pointed value */ int promote_pcrel_value; /* Promote an integer to a syscall number */ int promote_syscall; /* Promote a syscall number to a syscall name */ int promote_syscallname; /* Promote an integer to a symbol */ int promote_symbol; /* In a mova, promote "pc+" to the computed address */ int promote_pcaddr_loc; /* TODO: More print pass parameters */ private: /* Symbol tables to look up names */ std::vector const &m_symtables; /* Query symbol tables, most recent first */ std::optional symquery(Symbol::Type type, uint32_t value); /* OS for the target, to mark syscalls before instructions */ std::unique_ptr m_os; /* Last printed address (for ellipses) */ uint32_t m_last_address; /** Internal promotion tree printers **/ void queue(std::string, bool = false); void queue_flush(); std::vector m_messages; void pcjumploc(ConcreteInstructionArg const &); void pcrelloc(ConcreteInstructionArg const &); void pcrelval(ConcreteInstructionArg const &); void syscall(ConcreteInstructionArg const &); void syscallname(ConcreteInstructionArg const &); void symbol(ConcreteInstructionArg const &); void pcaddrloc(ConcreteInstructionArg const &); }; } /* namespace FxOS */ #endif /* LIBFXOS_DISASM_PASSES_PRINT_H */