Skip to content

Commit 1eb9546

Browse files
[#9971] Gracefully error out in ETDump for set_debug_buffer (#10130)
## Summary Following #9971 Start with a relatively simple method. Update set_debug_bugffer. Use ET_CHECK_OR_RETURN_ERROR instead. If unable to pass error, update the return type as Result Note: Not sure if InvalidArgument is a good one ( maybe memory not allocated?). Please feel free to comment. ##Test test/run_oss_cpp_tests.sh @Gasoonjia @zhenyan-zhang-meta Thanks
1 parent d711ec1 commit 1eb9546

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

devtools/etdump/etdump_flatcc.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -536,15 +536,17 @@ ETDumpResult ETDumpGen::get_etdump_data() {
536536
return result;
537537
}
538538

539-
void ETDumpGen::set_debug_buffer(Span<uint8_t> buffer) {
539+
Result<bool> ETDumpGen::set_debug_buffer(Span<uint8_t> buffer) {
540540
Result<BufferDataSink> bds_ret = BufferDataSink::create(buffer);
541-
ET_CHECK_MSG(
541+
ET_CHECK_OR_RETURN_ERROR(
542542
bds_ret.ok(),
543+
InvalidArgument,
543544
"Failed to create data sink from debug buffer with error 0x%" PRIx32,
544545
static_cast<uint32_t>(bds_ret.error()));
545546

546547
buffer_data_sink_ = std::move(bds_ret.get());
547548
data_sink_ = &buffer_data_sink_;
549+
return true;
548550
}
549551

550552
void ETDumpGen::set_data_sink(DataSinkBase* data_sink) {

devtools/etdump/etdump_flatcc.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class ETDumpGen : public ::executorch::runtime::EventTracer {
154154
virtual void set_delegation_intermediate_output_filter(
155155
EventTracerFilterBase* event_tracer_filter) override;
156156

157-
void set_debug_buffer(::executorch::runtime::Span<uint8_t> buffer);
157+
Result<bool> set_debug_buffer(::executorch::runtime::Span<uint8_t> buffer);
158158
void set_data_sink(DataSinkBase* data_sink);
159159
ETDumpResult get_etdump_data();
160160
size_t get_num_blocks();

0 commit comments

Comments
 (0)