Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ class HermesRuntimeTargetDelegate::Impl final : public RuntimeTargetDelegate {
return &hermesStackTrace_;
}

const HermesStackTrace& operator*() const {
return hermesStackTrace_;
}

const HermesStackTrace* operator->() const {
return &hermesStackTrace_;
}

private:
HermesStackTrace hermesStackTrace_;
};
Expand Down Expand Up @@ -216,6 +224,16 @@ class HermesRuntimeTargetDelegate::Impl final : public RuntimeTargetDelegate {
return samplingProfileDelegate_->collectSamplingProfile();
}

std::optional<folly::dynamic> serializeStackTrace(
const StackTrace& stackTrace) override {
if (auto* hermesStackTraceWrapper =
dynamic_cast<const HermesStackTraceWrapper*>(&stackTrace)) {
return folly::parseJson(cdpDebugAPI_->serializeStackTraceToJsonStr(
**hermesStackTraceWrapper));
}
return std::nullopt;
}

private:
HermesRuntimeTargetDelegate& delegate_;
std::shared_ptr<HermesRuntime> runtime_;
Expand Down Expand Up @@ -311,6 +329,11 @@ HermesRuntimeTargetDelegate::collectSamplingProfile() {
return impl_->collectSamplingProfile();
}

std::optional<folly::dynamic> HermesRuntimeTargetDelegate::serializeStackTrace(
const StackTrace& stackTrace) {
return impl_->serializeStackTrace(stackTrace);
}

#ifdef HERMES_ENABLE_DEBUGGER
CDPDebugAPI& HermesRuntimeTargetDelegate::getCDPDebugAPI() {
return impl_->getCDPDebugAPI();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class HermesRuntimeTargetDelegate : public RuntimeTargetDelegate {

tracing::RuntimeSamplingProfile collectSamplingProfile() override;

std::optional<folly::dynamic> serializeStackTrace(
const StackTrace& stackTrace) override;

private:
// We use the private implementation idiom to ensure this class has the same
// layout regardless of whether HERMES_ENABLE_DEBUGGER is defined. The net
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,10 @@ FallbackRuntimeTargetDelegate::collectSamplingProfile() {
"Sampling Profiler capabilities are not supported for Runtime fallback");
}

std::optional<folly::dynamic>
FallbackRuntimeTargetDelegate::serializeStackTrace(
const StackTrace& /*stackTrace*/) {
return std::nullopt;
}

} // namespace facebook::react::jsinspector_modern
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class FallbackRuntimeTargetDelegate : public RuntimeTargetDelegate {

tracing::RuntimeSamplingProfile collectSamplingProfile() override;

std::optional<folly::dynamic> serializeStackTrace(
const StackTrace& stackTrace) override;

private:
std::string engineDescription_;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ class RuntimeTargetDelegate {
* Return recorded sampling profile for the previous sampling session.
*/
virtual tracing::RuntimeSamplingProfile collectSamplingProfile() = 0;

/**
* \returns a JSON representation of the given stack trace, conforming to the
* @cdp Runtime.StackTrace type, if the runtime supports it. Otherwise,
* returns std::nullopt.
*/
virtual std::optional<folly::dynamic> serializeStackTrace(
const StackTrace& stackTrace) = 0;
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class MockInspectorPackagerConnectionDelegate
executor_.add(callback);
}
}));
EXPECT_CALL(*this, scheduleCallback(_, _)).Times(AnyNumber());
}

// InspectorPackagerConnectionDelegate methods
Expand Down Expand Up @@ -168,6 +169,20 @@ class MockRuntimeTargetDelegate : public RuntimeTargetDelegate {
collectSamplingProfile,
(),
(override));
MOCK_METHOD(
std::optional<folly::dynamic>,
serializeStackTrace,
(const StackTrace& stackTrace),
(override));

inline MockRuntimeTargetDelegate() {
using namespace testing;

// Silence "uninteresting mock function call" warnings for methods that
// don't have side effects.

EXPECT_CALL(*this, supportsConsole()).Times(AnyNumber());
}
};

class MockRuntimeAgentDelegate : public RuntimeAgentDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class InspectorPackagerConnectionTestBase : public testing::Test {
socket->getDelegate().didOpen();
return std::move(socket);
});
EXPECT_CALL(*packagerConnectionDelegate(), connectWebSocket(_, _))
.Times(AnyNumber());
}

void TearDown() override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ class JsiIntegrationPortableTestBase : public ::testing::Test,
protected:
Executor executor_;

JsiIntegrationPortableTestBase()
: inspectorFlagsGuard_{EngineAdapter::getInspectorFlagOverrides()},
engineAdapter_{executor_} {}
JsiIntegrationPortableTestBase(InspectorFlagOverrides overrides = {})
: inspectorFlagsGuard_(overrides), engineAdapter_{executor_} {}

void SetUp() override {
// NOTE: Using SetUp() so we can call virtual methods like
Expand Down
Loading
Loading