From 2cbaccb67e22c0b313a9785bfc65bcb4b25d0676 Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Sun, 14 Sep 2014 20:34:17 -0700 Subject: Avoid printing absolute addresses in oatdump - Added printing of OatClass offsets. - Added printing of OatMethod offsets. - Added bounds checks for code size size, code size, mapping table, gc map, vmap table. - Added sanity check of 100k for code size. - Added partial disassembly of questionable code. - Added --no-disassemble to disable disassembly. - Added --no-dump:vmap to disable vmap dumping. - Reordered OatMethod info to be in file order. Bug: 15567083 (cherry picked from commit 34fa79ece5b3a1940d412cd94dbdcc4225aae72f) Change-Id: I2c368f3b81af53b735149a866f3e491c9ac33fb8 --- disassembler/disassembler.h | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'disassembler/disassembler.h') diff --git a/disassembler/disassembler.h b/disassembler/disassembler.h index 183e692ff2..487f43315a 100644 --- a/disassembler/disassembler.h +++ b/disassembler/disassembler.h @@ -26,10 +26,31 @@ namespace art { +class DisassemblerOptions { + public: + // Should the disassembler print absolute or relative addresses. + const bool absolute_addresses_; + + // Base addess for calculating relative code offsets when absolute_addresses_ is false. + const uint8_t* const base_address_; + + DisassemblerOptions(bool absolute_addresses, const uint8_t* base_address) + : absolute_addresses_(absolute_addresses), base_address_(base_address) {} + + private: + DISALLOW_COPY_AND_ASSIGN(DisassemblerOptions); +}; + class Disassembler { public: - static Disassembler* Create(InstructionSet instruction_set); - virtual ~Disassembler() {} + // Creates a Disassembler for the given InstructionSet with the + // non-null DisassemblerOptions which become owned by the + // Disassembler. + static Disassembler* Create(InstructionSet instruction_set, DisassemblerOptions* options); + + virtual ~Disassembler() { + delete disassembler_options_; + } // Dump a single instruction returning the length of that instruction. virtual size_t Dump(std::ostream& os, const uint8_t* begin) = 0; @@ -37,9 +58,15 @@ class Disassembler { virtual void Dump(std::ostream& os, const uint8_t* begin, const uint8_t* end) = 0; protected: - Disassembler() {} + explicit Disassembler(DisassemblerOptions* disassembler_options) + : disassembler_options_(disassembler_options) { + CHECK(disassembler_options_ != nullptr); + } + + std::string FormatInstructionPointer(const uint8_t* begin); private: + DisassemblerOptions* disassembler_options_; DISALLOW_COPY_AND_ASSIGN(Disassembler); }; -- cgit v1.2.3-59-g8ed1b