mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 17:27:34 +00:00
LibX86: Add a way for Instruction::to_string() to symbolicate addresses
This patch adds a pure virtual X86::SymbolProvider that can be passed to Instruction::to_string(). If the instruction contains what appears to be a program address, stringification will try to symbolicate that address via the SymbolProvider. This makes it possible (and very flexible) to add symbolication to clients of the disassembler. :^)
This commit is contained in:
parent
5390d53a80
commit
e880e4c2d2
2 changed files with 29 additions and 9 deletions
|
@ -34,6 +34,11 @@ namespace X86 {
|
|||
class Instruction;
|
||||
struct InstructionDescriptor;
|
||||
|
||||
class SymbolProvider {
|
||||
public:
|
||||
virtual String symbolicate(FlatPtr, u32* offset = nullptr) const = 0;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct MakeUnsigned {
|
||||
typedef T type;
|
||||
|
@ -333,12 +338,12 @@ public:
|
|||
|
||||
u8 cc() const { return m_has_sub_op ? m_sub_op & 0xf : m_op & 0xf; }
|
||||
|
||||
String to_string(u32 origin, bool x32 = true) const;
|
||||
String to_string(u32 origin, const SymbolProvider* = nullptr, bool x32 = true) const;
|
||||
|
||||
private:
|
||||
Instruction(InstructionStream&, bool o32, bool a32);
|
||||
|
||||
String to_string_internal(u32 origin, bool x32) const;
|
||||
String to_string_internal(u32 origin, const SymbolProvider*, bool x32) const;
|
||||
|
||||
const char* reg8_name() const;
|
||||
const char* reg16_name() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue