summaryrefslogtreecommitdiff
path: root/lowlevelilinstruction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lowlevelilinstruction.cpp')
-rw-r--r--lowlevelilinstruction.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/lowlevelilinstruction.cpp b/lowlevelilinstruction.cpp
index fe386e8d..b7277831 100644
--- a/lowlevelilinstruction.cpp
+++ b/lowlevelilinstruction.cpp
@@ -18,6 +18,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
+#include <string.h>
#ifdef BINARYNINJACORE_LIBRARY
#include "lowlevelilfunction.h"
#include "lowlevelilssafunction.h"
@@ -1744,6 +1745,38 @@ MediumLevelILInstruction LowLevelILInstructionBase::GetMappedMediumLevelIL() con
}
+char* LowLevelILInstructionBase::Dump() const
+{
+ vector<InstructionTextToken> tokens;
+#ifdef BINARYNINJACORE_LIBRARY
+ bool success = function->GetExprText(function->GetFunction(), function->GetArchitecture(), *this, tokens);
+#else
+ bool success = function->GetExprText(function->GetArchitecture(), exprIndex, tokens);
+#endif
+ if (success)
+ {
+ 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) + "] ";
+ }
+ for (auto& token: tokens)
+ {
+ text += token.text;
+ }
+ return strdup(text.c_str());
+ }
+ else
+ {
+ return strdup("???");
+ }
+}
+
+
void LowLevelILInstructionBase::Replace(ExprId expr)
{
function->ReplaceExpr(exprIndex, expr);