diff --git a/ReactCommon/jsi/jsi/decorator.h b/ReactCommon/jsi/jsi/decorator.h index a2ce31a787f..2f2a4a915e5 100644 --- a/ReactCommon/jsi/jsi/decorator.h +++ b/ReactCommon/jsi/jsi/decorator.h @@ -337,6 +337,10 @@ class RuntimeDecorator : public Base, private jsi::Instrumentation { return plain().instrumentation().createSnapshotToFile(path, compact); } + bool createSnapshotToStream(std::ostream& os, bool compact) override { + return plain().instrumentation().createSnapshotToStream(os, compact); + } + void writeBridgeTrafficTraceToFile( const std::string& fileName) const override { const_cast(plain()).instrumentation().writeBridgeTrafficTraceToFile( diff --git a/ReactCommon/jsi/jsi/instrumentation.h b/ReactCommon/jsi/jsi/instrumentation.h index 595e6889c1c..3a602e6b15b 100644 --- a/ReactCommon/jsi/jsi/instrumentation.h +++ b/ReactCommon/jsi/jsi/instrumentation.h @@ -6,6 +6,7 @@ */ #pragma once +#include #include #include @@ -55,6 +56,15 @@ class Instrumentation { /// \return true iff the heap capture succeeded virtual bool createSnapshotToFile(const std::string& path, bool compact) = 0; + /// Captures the heap to an output stream + /// + /// \param os output stream to write to. + /// + /// \param compact Whether the JSON should be compact or pretty + /// + /// \return true iff the heap capture succeeded. + virtual bool createSnapshotToStream(std::ostream& os, bool compact) = 0; + /// Write a trace of bridge traffic to the given file name. virtual void writeBridgeTrafficTraceToFile( const std::string& fileName) const = 0; diff --git a/ReactCommon/jsi/jsi/jsi.cpp b/ReactCommon/jsi/jsi/jsi.cpp index 90ec784ef2e..408b321c542 100644 --- a/ReactCommon/jsi/jsi/jsi.cpp +++ b/ReactCommon/jsi/jsi/jsi.cpp @@ -81,6 +81,10 @@ Instrumentation& Runtime::instrumentation() { return false; } + bool createSnapshotToStream(std::ostream&, bool) override { + return false; + } + void writeBridgeTrafficTraceToFile(const std::string&) const override { std::abort(); }