From b15607dc351bd7787b85751bce9bbddc0a705461 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Tue, 7 Jun 2022 21:51:27 -0400 Subject: Add Dump() to *LILInstruction --- highlevelilinstruction.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'highlevelilinstruction.cpp') diff --git a/highlevelilinstruction.cpp b/highlevelilinstruction.cpp index 5f8777e1..ecec3869 100644 --- a/highlevelilinstruction.cpp +++ b/highlevelilinstruction.cpp @@ -18,6 +18,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. +#include #ifdef BINARYNINJACORE_LIBRARY #include "highlevelilfunction.h" #include "highlevelilssafunction.h" @@ -883,6 +884,47 @@ MediumLevelILInstruction HighLevelILInstructionBase::GetMediumLevelILSSAForm() c } +char* HighLevelILInstructionBase::Dump() const +{ + if (!function) + return strdup(""); + + vector tokens; + vector lines = function->GetExprText(*this, new DisassemblySettings()); + if (!lines.empty()) + { + string text; + if (exprIndex != BN_INVALID_EXPR && (exprIndex & 0xffff000000000000) == 0) + { + text += "[expr " + to_string(exprIndex) + "] "; + } + if (instructionIndex != BN_INVALID_EXPR && (instructionIndex & 0xffff000000000000) == 0) + { + text += "[instr " + to_string(instructionIndex) + "] "; + } + Ref type = GetType(); + if (type) + { + text += "[type: " + type->GetString() + "] "; + } + + for (auto& line: lines) + { + for (auto& token: line.tokens) + { + text += token.text; + } + text += " ; "; + } + return strdup(text.c_str()); + } + else + { + return strdup("???"); + } +} + + void HighLevelILInstructionBase::Replace(ExprId expr) { function->ReplaceExpr(exprIndex, expr); -- cgit v1.3.1