// Copyright 2015, ARM Limited // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // * Neither the name of ARM Limited nor the names of its contributors may be // used to endorse or promote products derived from this software without // specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
class Disassembler: public DecoderVisitor { public:
Disassembler();
Disassembler(char* text_buffer, int buffer_size); virtual ~Disassembler(); char* GetOutput();
// Default output functions. The functions below implement a default way of // printing elements in the disassembly. A sub-class can override these to // customize the disassembly output.
// Prints the name of a register. // TODO: This currently doesn't allow renaming of V registers. virtualvoid AppendRegisterNameToOutput(const Instruction* instr, const CPURegister& reg);
// Prints a PC-relative offset. This is used for example when disassembling // branches to immediate offsets. virtualvoid AppendPCRelativeOffsetToOutput(const Instruction* instr,
int64_t offset);
// Prints an address, in the general case. It can be code or data. This is // used for example to print the target address of an ADR instruction. virtualvoid AppendCodeRelativeAddressToOutput(const Instruction* instr, constvoid* addr);
// Prints the address of some code. // This is used for example to print the target address of a branch to an // immediate offset. // A sub-class can for example override this method to lookup the address and // print an appropriate name. virtualvoid AppendCodeRelativeCodeAddressToOutput(const Instruction* instr, constvoid* addr);
// Prints the address of some data. // This is used for example to print the source address of a load literal // instruction. virtualvoid AppendCodeRelativeDataAddressToOutput(const Instruction* instr, constvoid* addr);
// Same as the above, but for addresses that are not relative to the code // buffer. They are currently not used by VIXL. virtualvoid AppendAddressToOutput(const Instruction* instr, constvoid* addr); virtualvoid AppendCodeAddressToOutput(const Instruction* instr, constvoid* addr); virtualvoid AppendDataAddressToOutput(const Instruction* instr, constvoid* addr);
public: // Get/Set the offset that should be added to code addresses when printing // code-relative addresses in the AppendCodeRelative<Type>AddressToOutput() // helpers. // Below is an example of how a branch immediate instruction in memory at // address 0xb010200 would disassemble with different offsets. // Base address | Disassembly // 0x0 | 0xb010200: b #+0xcc (addr 0xb0102cc) // 0x10000 | 0xb000200: b #+0xcc (addr 0xb0002cc) // 0xb010200 | 0x0: b #+0xcc (addr 0xcc) void MapCodeAddress(int64_t base_address, const Instruction* instr_address);
int64_t CodeRelativeAddress(constvoid* instr);
private: void Format( const Instruction* instr, constchar* mnemonic, constchar* format); void Substitute(const Instruction* instr, constchar* string); int SubstituteField(const Instruction* instr, constchar* format); int SubstituteRegisterField(const Instruction* instr, constchar* format); int SubstituteImmediateField(const Instruction* instr, constchar* format); int SubstituteLiteralField(const Instruction* instr, constchar* format); int SubstituteBitfieldImmediateField( const Instruction* instr, constchar* format); int SubstituteShiftField(const Instruction* instr, constchar* format); int SubstituteExtendField(const Instruction* instr, constchar* format); int SubstituteConditionField(const Instruction* instr, constchar* format); int SubstitutePCRelAddressField(const Instruction* instr, constchar* format); int SubstituteBranchTargetField(const Instruction* instr, constchar* format); int SubstituteLSRegOffsetField(const Instruction* instr, constchar* format); int SubstitutePrefetchField(const Instruction* instr, constchar* format); int SubstituteBarrierField(const Instruction* instr, constchar* format); int SubstituteSysOpField(const Instruction* instr, constchar* format); int SubstituteCrField(const Instruction* instr, constchar* format); bool RdIsZROrSP(const Instruction* instr) const { return (instr->Rd() == kZeroRegCode);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.