[Bf-blender-cvs] [ec2c1e54ed1] functions: print with stacktrace from IR

Jacques Lucke noreply at git.blender.org
Mon May 13 10:16:48 CEST 2019


Commit: ec2c1e54ed1ec0f6fc382be55a885e13e01123b5
Author: Jacques Lucke
Date:   Thu May 9 13:20:29 2019 +0200
Branches: functions
https://developer.blender.org/rBec2c1e54ed1ec0f6fc382be55a885e13e01123b5

print with stacktrace from IR

===================================================================

M	source/blender/functions/backends/llvm/builder.cpp
M	source/blender/functions/backends/llvm/builder.hpp

===================================================================

diff --git a/source/blender/functions/backends/llvm/builder.cpp b/source/blender/functions/backends/llvm/builder.cpp
index 9db78fef568..847f34c2cdc 100644
--- a/source/blender/functions/backends/llvm/builder.cpp
+++ b/source/blender/functions/backends/llvm/builder.cpp
@@ -1,6 +1,7 @@
 #include "builder.hpp"
 #include "BLI_string.h"
 #include "llvm/IR/TypeBuilder.h"
+#include "FN_tuple_call.hpp"
 
 namespace FN {
 
@@ -113,10 +114,25 @@ void CodeBuilder::CreatePrintf(const char *format, const LLVMValues &values)
     }
     args.append(passed_arg);
   }
-  args.extend(values);
   m_builder.CreateCall(printf_func, to_llvm_array_ref(args));
 }
 
+void print_stacktrace(ExecutionContext *context)
+{
+  context->stack().print_traceback();
+}
+
+void CodeBuilder::CreatePrintfWithStacktrace(llvm::Value *context_ptr,
+                                             const char *format,
+                                             const LLVMValues &values)
+{
+  this->CreateCallPointer(
+      (void *)print_stacktrace, {context_ptr}, this->getVoidTy(), "Print Stacktrace");
+  this->CreatePrintf("-> ");
+  this->CreatePrintf(format, values);
+  this->CreatePrintf("\n");
+}
+
 /* For Loop
  ******************************************/
 
diff --git a/source/blender/functions/backends/llvm/builder.hpp b/source/blender/functions/backends/llvm/builder.hpp
index 6144ef7d321..9ed18ae4a15 100644
--- a/source/blender/functions/backends/llvm/builder.hpp
+++ b/source/blender/functions/backends/llvm/builder.hpp
@@ -425,7 +425,10 @@ class CodeBuilder {
   /* Print
    **************************************/
 
-  void CreatePrintf(const char *format, const LLVMValues &values);
+  void CreatePrintf(const char *format, const LLVMValues &values = {});
+  void CreatePrintfWithStacktrace(llvm::Value *context_ptr,
+                                  const char *format,
+                                  const LLVMValues &values);
 
   /* Control Flow Construction
    **************************************/



More information about the Bf-blender-cvs mailing list