From 5ff5708f6d7594b1515c6bbb9bc434b3d2a65e55 Mon Sep 17 00:00:00 2001 From: Songhao Jia Date: Fri, 28 Mar 2025 19:16:23 -0700 Subject: [PATCH] use kUnsetDebugHandle for unset debug handle in etdump delegation log (#9754) Summary: as title. See comments in code for better reason Differential Revision: D72095995 --- devtools/etdump/etdump_flatcc.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/devtools/etdump/etdump_flatcc.cpp b/devtools/etdump/etdump_flatcc.cpp index ef6bde94403..dadba0843b2 100644 --- a/devtools/etdump/etdump_flatcc.cpp +++ b/devtools/etdump/etdump_flatcc.cpp @@ -352,8 +352,21 @@ void ETDumpGen::log_intermediate_output_delegate_helper( const char* name, DebugHandle delegate_debug_index, const T& output) { + // Previously we compared delegate_debug_index to -1 to check if it is set, + // but this is not a good solution because delegate_debug_index is of + // DebugHandle type which is a uint32_t. Also we have a specific value for + // runtime::kUnsetDebugHandle to represent an unset debug handle. + // + // To maintain backward compatibility: + // 1. We keep the comparison with -1 (cast to DebugHandle) + // 2. We add comparison with runtime::kUnsetDebugHandle + // + // TODO(gasoonjia): In the future, we should remove the comparison with -1 and + // only compare with runtime::kUnsetDebugHandle. ET_CHECK_MSG( - (name == nullptr) ^ (delegate_debug_index == -1), + (name == nullptr) ^ + (delegate_debug_index == runtime::kUnsetDebugHandle || + delegate_debug_index == static_cast(-1)), "Only name or delegate_debug_index can be valid. Check DelegateMappingBuilder documentation for more details."); check_ready_to_add_events();