You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by tq...@apache.org on 2025/04/21 23:17:14 UTC
(tvm) 06/06: [FFI] improve traceback
This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch refactor-s2
in repository https://gitbox.apache.org/repos/asf/tvm.git
commit 7fa778caec303416a34d174efea97a3661fadc96
Author: tqchen <ti...@gmail.com>
AuthorDate: Mon Apr 21 19:15:11 2025 -0400
[FFI] improve traceback
---
ffi/src/ffi/traceback.cc | 3 +++
ffi/src/ffi/traceback.h | 22 ++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/ffi/src/ffi/traceback.cc b/ffi/src/ffi/traceback.cc
index 897b054d29..7cebc37774 100644
--- a/ffi/src/ffi/traceback.cc
+++ b/ffi/src/ffi/traceback.cc
@@ -99,6 +99,9 @@ int BacktraceFullCallback(void* data, uintptr_t pc, const char* filename, int li
if (stack_trace->ExceedTracebackLimit()) {
return 1;
}
+ if (ShouldStopTraceback(filename, symbol)) {
+ return 1;
+ }
if (ShouldExcludeFrame(filename, symbol)) {
return 0;
}
diff --git a/ffi/src/ffi/traceback.h b/ffi/src/ffi/traceback.h
index 0d1c104bf1..c42bd9ca48 100644
--- a/ffi/src/ffi/traceback.h
+++ b/ffi/src/ffi/traceback.h
@@ -103,6 +103,25 @@ inline bool ShouldExcludeFrame(const char* filename, const char* symbol) {
return false;
}
+/**
+ * \brief List frames that should stop the traceback.
+ * \param filename The filename of the frame.
+ * \param symbol The symbol name of the frame.
+ * \return true if the frame should stop the traceback.
+ * \note We stop traceback at the FFI boundary.
+ */
+inline bool ShouldStopTraceback(const char* filename, const char* symbol) {
+ if (symbol != nullptr) {
+ if (strncmp(symbol, "TVMFFIFuncCall", 14) == 0) {
+ return true;
+ }
+ if (strncmp(symbol, "TVMFuncCall", 11) == 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
/*!
* \brief storage to store traceback
*/
@@ -115,6 +134,9 @@ struct TracebackStorage {
// skip frames with empty filename
if (filename == nullptr) {
if (func != nullptr) {
+ if (strncmp(func, "0x0", 3) == 0) {
+ return;
+ }
filename = "<unknown>";
} else {
return;