You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/01/19 20:51:18 UTC

[GitHub] [tvm] tkonolige commented on a change in pull request #9872: Add colors and user-configurable backtrace limit

tkonolige commented on a change in pull request #9872:
URL: https://github.com/apache/tvm/pull/9872#discussion_r788124990



##########
File path: src/runtime/logging.cc
##########
@@ -120,7 +130,22 @@ int BacktraceFullCallback(void* data, uintptr_t pc, const char* filename, int li
 
 std::string Backtrace() {
   BacktraceInfo bt;
-  bt.max_size = 500;
+
+  // Limit backtrace length based on TVM_BACKTRACE_LIMIT env variable
+  auto user_limit_s = getenv("TVM_BACKTRACE_LIMIT");
+  const auto default_limit = 500;
+
+  if (user_limit_s == nullptr) {
+    bt.max_size = default_limit;
+  } else {
+    // Parse out the user-set backtrace limit
+    try {
+      bt.max_size = std::stoi(user_limit_s);
+    } catch (const std::invalid_argument& e) {
+      bt.max_size = default_limit;
+    }
+  }
+

Review comment:
       This should be a separate PR.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org