summaryrefslogtreecommitdiff
path: root/lowlevelilinstruction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lowlevelilinstruction.cpp')
-rw-r--r--lowlevelilinstruction.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/lowlevelilinstruction.cpp b/lowlevelilinstruction.cpp
index e0d5922d..17368662 100644
--- a/lowlevelilinstruction.cpp
+++ b/lowlevelilinstruction.cpp
@@ -3690,3 +3690,44 @@ ExprId LowLevelILFunction::FloatCompareUnordered(size_t size, ExprId a, ExprId b
{
return AddExprWithLocation(LLIL_FCMP_UO, loc, size, 0, a, b);
}
+
+
+fmt::format_context::iterator fmt::formatter<LowLevelILInstruction>::format(const LowLevelILInstruction& obj, format_context& ctx) const
+{
+ if (!obj.function)
+ return fmt::format_to(ctx.out(), "<uninit>");
+
+ vector<InstructionTextToken> tokens;
+#ifdef BINARYNINJACORE_LIBRARY
+ bool success = obj.function->GetExprText(obj.function->GetFunction(), obj.function->GetArchitecture(), obj, tokens);
+#else
+ bool success = obj.function->GetExprText(obj.function->GetArchitecture(), obj.exprIndex, tokens);
+#endif
+ if (success)
+ {
+ string text;
+ if (presentation == '?')
+ {
+ fmt::format_to(ctx.out(), "{} ", obj.operation);
+ fmt::format_to(ctx.out(), "@ {:#x} ", obj.address);
+ if (obj.exprIndex != BN_INVALID_EXPR && (obj.exprIndex & 0xffff000000000000) == 0)
+ {
+ fmt::format_to(ctx.out(), "[expr {}] ", obj.exprIndex);
+ }
+ if (obj.instructionIndex != BN_INVALID_EXPR && (obj.instructionIndex & 0xffff000000000000) == 0)
+ {
+ fmt::format_to(ctx.out(), "[instr {}] ", obj.instructionIndex);
+ }
+ }
+
+ for (auto& token: tokens)
+ {
+ fmt::format_to(ctx.out(), token.text);
+ }
+ }
+ else
+ {
+ fmt::format_to(ctx.out(), "???");
+ }
+ return ctx.out();
+}