Skip to content

Commit

Permalink
Expose HERMES_DEBUGGER_ENABLED via HermesInternal.getRuntimeProperties
Browse files Browse the repository at this point in the history
Summary:
Expose the build flag `HERMES_DEBUGGER_ENABLED` at runtime via the
"Debugger Enabled" prop on `HermesInternal.getRuntimeProperties`.

`HERMES_DEBUGGER_ENABLED` is typically set for `dev` and `dbg`
builds of Hermes, as well as profile builds of apps, but it may be
specifically overridden so I don't know of a reliable way to infer
it when diagnosing a prebuilt app.

Reviewed By: avp

Differential Revision: D55871440

fbshipit-source-id: a0ddb9e525f0f3efc4b96a5a23745dcb8a68b547
  • Loading branch information
robhogan authored and facebook-github-bot committed Apr 9, 2024
1 parent c8655e9 commit c2f7dcd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions lib/VM/JSLib/HermesInternal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,21 @@ hermesInternalGetRuntimeProperties(void *, Runtime &runtime, NativeArgs args) {
}
#endif

const bool debuggerEnabled =
#ifdef HERMES_ENABLE_DEBUGGER
true
#else
false
#endif
;

tmpHandle = HermesValue::encodeBoolValue(debuggerEnabled);
if (LLVM_UNLIKELY(
addProperty(tmpHandle, "Debugger Enabled") ==
ExecutionStatus::EXCEPTION)) {
return ExecutionStatus::EXCEPTION;
}

const char *cjsModuleMode = getCJSModuleModeDescription(runtime);
auto cjsModuleModeRes =
StringPrimitive::create(runtime, createASCIIRef(cjsModuleMode));
Expand Down
2 changes: 1 addition & 1 deletion tools/fuzzers/fuzzilli/profile/HermesProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ let hermesProfile = Profile(
"HermesInternal.enablePromiseRejectionTracker" : .function([.plain(.anything)] => .anything),
"HermesInternal.getEpilogues" : .function([] => .iterable),
"HermesInternal.getInstrumentedStats" : .function([] => .object(ofGroup: "Object", withProperties: ["js_VMExperiments", "js_numGCs", "js_gcCPUTime", "js_gcTime", "js_totalAllocatedBytes", "js_allocatedBytes", "js_heapSize", "js_mallocSizeEstimate", "js_vaSize", "js_markStackOverflows"])),
"HermesInternal.getRuntimeProperties" : .function([] => .object(ofGroup: "Object", withProperties: ["Snapshot VM", "Bytecode Version", "Builtins Frozen", "VM Experiments", "Build", "GC", "OSS Release Version", "CommonJS Modules"])),
"HermesInternal.getRuntimeProperties" : .function([] => .object(ofGroup: "Object", withProperties: ["Snapshot VM", "Bytecode Version", "Builtins Frozen", "VM Experiments", "Build", "GC", "OSS Release Version", "Debugger Enabled", "CommonJS Modules"])),
"HermesInternal.ttiReached" : .function([] => .undefined),
"HermesInternal.getFunctionLocation" : .function([.plain(.function())] => .object(ofGroup: "Object", withProperties: ["isNative", "lineNumber", "columnNumber", "fileName"])),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ let w2cProfile = Profile(
"HermesInternal.enablePromiseRejectionTracker" : .function([.plain(.anything)] => .anything),
"HermesInternal.getEpilogues" : .function([] => .iterable),
"HermesInternal.getInstrumentedStats" : .function([] => .object(ofGroup: "Object", withProperties: ["js_VMExperiments", "js_numGCs", "js_gcCPUTime", "js_gcTime", "js_totalAllocatedBytes", "js_allocatedBytes", "js_heapSize", "js_mallocSizeEstimate", "js_vaSize", "js_markStackOverflows"])),
"HermesInternal.getRuntimeProperties" : .function([] => .object(ofGroup: "Object", withProperties: ["Snapshot VM", "Bytecode Version", "Builtins Frozen", "VM Experiments", "Build", "GC", "OSS Release Version", "CommonJS Modules"])),
"HermesInternal.getRuntimeProperties" : .function([] => .object(ofGroup: "Object", withProperties: ["Snapshot VM", "Bytecode Version", "Builtins Frozen", "VM Experiments", "Build", "GC", "OSS Release Version", "Debugger Enabled", "CommonJS Modules"])),
"HermesInternal.ttiReached" : .function([] => .undefined),
"HermesInternal.getFunctionLocation" : .function([.plain(.function())] => .object(ofGroup: "Object", withProperties: ["isNative", "lineNumber", "columnNumber", "fileName"])),

Expand Down
2 changes: 1 addition & 1 deletion tools/fuzzers/fuzzilli/profile/SparkARProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ let sparkARProfile = Profile(
"HermesInternal.enablePromiseRejectionTracker" : .function([.plain(.anything)] => .anything),
"HermesInternal.getEpilogues" : .function([] => .iterable),
"HermesInternal.getInstrumentedStats" : .function([] => .object(ofGroup: "Object", withProperties: ["js_VMExperiments", "js_numGCs", "js_gcCPUTime", "js_gcTime", "js_totalAllocatedBytes", "js_allocatedBytes", "js_heapSize", "js_mallocSizeEstimate", "js_vaSize", "js_markStackOverflows"])),
"HermesInternal.getRuntimeProperties" : .function([] => .object(ofGroup: "Object", withProperties: ["Snapshot VM", "Bytecode Version", "Builtins Frozen", "VM Experiments", "Build", "GC", "OSS Release Version", "CommonJS Modules"])),
"HermesInternal.getRuntimeProperties" : .function([] => .object(ofGroup: "Object", withProperties: ["Snapshot VM", "Bytecode Version", "Builtins Frozen", "VM Experiments", "Build", "GC", "OSS Release Version", "Debugger Enabled", "CommonJS Modules"])),
"HermesInternal.ttiReached" : .function([] => .undefined),
"HermesInternal.getFunctionLocation" : .function([.plain(.function())] => .object(ofGroup: "Object", withProperties: ["isNative", "lineNumber", "columnNumber", "fileName"])),

Expand Down

0 comments on commit c2f7dcd

Please sign in to comment.