#include <stdlib.h>
#include "include/v8-extension.h"
#include "include/v8-function.h"
#include "include/v8-json.h"
#include "include/v8-locker.h"
#include "src/api/api-inl.h"
#include "src/base/strings.h"
#include "src/codegen/compilation-cache.h"
#include "src/debug/debug-interface.h"
#include "src/debug/debug-scopes.h"
#include "src/debug/debug.h"
#include "src/deoptimizer/deoptimizer.h"
#include "src/execution/frames-inl.h"
#include "src/execution/microtask-queue.h"
#include "src/objects/objects-inl.h"
#include "src/utils/utils.h"
#include "test/cctest/cctest.h"
#include "test/cctest/heap/heap-utils.h"
DirectHandle;
Handle;
StepInto;
StepNone;
StepOut;
StepOver;
static v8::Local<v8::Function> CompileFunction(v8::Isolate* isolate,
const char* source,
const char* function_name) { … }
static v8::Local<v8::Function> CompileFunction(LocalContext* env,
const char* source,
const char* function_name) { … }
static bool HasBreakInfo(v8::Local<v8::Function> fun) { … }
static i::Handle<i::BreakPoint> SetBreakPoint(v8::Local<v8::Function> fun,
int position,
const char* condition = nullptr) { … }
static void ClearBreakPoint(i::DirectHandle<i::BreakPoint> break_point) { … }
static void ChangeBreakOnException(v8::Isolate* isolate, bool caught,
bool uncaught) { … }
static void PrepareStep(i::StepAction step_action) { … }
namespace v8 {
namespace internal {
Handle<FixedArray> GetDebuggedFunctions() { … }
void CheckDebuggerUnloaded() { … }
}
}
static void CheckDebuggerUnloaded() { … }
int break_point_hit_count = …;
int break_point_hit_count_deoptimize = …;
class DebugEventCounter : public v8::debug::DebugDelegate { … };
class DebugEventBreakPointCollectGarbage : public v8::debug::DebugDelegate { … };
class DebugEventBreak : public v8::debug::DebugDelegate { … };
v8::debug::BreakReasons break_right_now_reasons = …;
static void BreakRightNow(v8::Isolate* isolate, void*) { … }
int max_break_point_hit_count = …;
bool terminate_after_max_break_point_hit = …;
class DebugEventBreakMax : public v8::debug::DebugDelegate { … };
TEST(DebugInfo) { … }
TEST(BreakPointICStore) { … }
TEST(BreakPointCondition) { … }
TEST(BreakPointICLoad) { … }
TEST(BreakPointICCall) { … }
TEST(BreakPointICCallWithGC) { … }
TEST(BreakPointConstructCallWithGC) { … }
TEST(BreakPointBuiltin) { … }
TEST(BreakPointApiIntrinsics) { … }
TEST(BreakPointJSBuiltin) { … }
TEST(BreakPointBoundBuiltin) { … }
TEST(BreakPointConstructorBuiltin) { … }
TEST(BreakPointInlinedBuiltin) { … }
TEST(BreakPointInlineBoundBuiltin) { … }
TEST(BreakPointInlinedConstructorBuiltin) { … }
TEST(BreakPointBuiltinConcurrentOpt) { … }
TEST(BreakPointBuiltinTFOperator) { … }
TEST(BreakPointBuiltinNewContext) { … }
void NoOpFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { … }
TEST(BreakPointApiFunction) { … }
TEST(BreakPointApiConstructor) { … }
void GetWrapperCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { … }
TEST(BreakPointApiGetter) { … }
void SetWrapperCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { … }
TEST(BreakPointApiSetter) { … }
TEST(BreakPointApiAccessor) { … }
TEST(Regress1163547) { … }
TEST(BreakPointOnLazyAccessorInNewContexts) { … }
TEST(BreakPointInlineApiFunction) { … }
TEST(BreakPointConditionBuiltin) { … }
TEST(BreakPointInlining) { … }
static void CallWithBreakPoints(v8::Local<v8::Context> context,
v8::Local<v8::Object> recv,
v8::Local<v8::Function> f,
int break_point_count, int call_count) { … }
TEST(GCDuringBreakPointProcessing) { … }
static void CallAndGC(v8::Local<v8::Context> context,
v8::Local<v8::Object> recv, v8::Local<v8::Function> f) { … }
TEST(BreakPointSurviveGC) { … }
TEST(DebuggerStatement) { … }
TEST(DebuggerStatementBreakpoint) { … }
TEST(ConditionalBreakpointWithCodeGenerationDisallowed) { … }
TEST(DebugStepLinear) { … }
TEST(DebugCountLinear) { … }
TEST(DebugStepKeyedLoadLoop) { … }
TEST(DebugStepKeyedStoreLoop) { … }
TEST(DebugStepNamedLoadLoop) { … }
static void DoDebugStepNamedStoreLoop(int expected) { … }
TEST(DebugStepNamedStoreLoop) { … }
TEST(DebugStepLinearMixedICs) { … }
TEST(DebugCountLinearMixedICs) { … }
TEST(DebugStepDeclarations) { … }
TEST(DebugStepLocals) { … }
TEST(DebugStepIf) { … }
TEST(DebugStepSwitch) { … }
TEST(DebugStepWhile) { … }
TEST(DebugStepDoWhile) { … }
TEST(DebugStepFor) { … }
TEST(DebugStepForContinue) { … }
TEST(DebugStepForBreak) { … }
TEST(DebugStepForIn) { … }
TEST(DebugStepWith) { … }
TEST(DebugConditional) { … }
TEST(DebugStepNatives) { … }
TEST(DebugCountNatives) { … }
TEST(DebugStepFunctionApply) { … }
TEST(DebugCountFunctionApply) { … }
TEST(DebugStepFunctionCall) { … }
TEST(DebugCountFunctionCall) { … }
TEST(DebugStepFunctionCallApply) { … }
TEST(DebugCountFunctionCallApply) { … }
TEST(PauseInScript) { … }
int message_callback_count = …;
TEST(DebugBreak) { … }
class DebugScopingListener : public v8::debug::DebugDelegate { … };
TEST(DebugBreakInWrappedScript) { … }
static void EmptyHandler(const v8::FunctionCallbackInfo<v8::Value>& info) { … }
TEST(DebugScopeIteratorWithFunctionTemplate) { … }
TEST(DebugBreakWithoutJS) { … }
TEST(DisableBreak) { … }
TEST(DisableDebuggerStatement) { … }
static const char* kSimpleExtensionSource = …;
TEST(NoBreakWhenBootstrapping) { … }
TEST(SetDebugEventListenerOnUninitializedVM) { … }
TEST(DebuggerUnload) { … }
int event_listener_hit_count = …;
class EmptyExternalStringResource : public v8::String::ExternalStringResource { … };
TEST(DebugScriptLineEndsAreAscending) { … }
static v8::Global<v8::Context> expected_context_global;
static v8::Global<v8::Value> expected_context_data_global;
class ContextCheckEventListener : public v8::debug::DebugDelegate { … };
TEST(ContextData) { … }
TEST(EvalContextData) { … }
class ScriptCompiledDelegate : public v8::debug::DebugDelegate { … };
TEST(AfterCompileEventWhenEventListenerIsReset) { … }
TEST(SyntaxErrorEventOnSyntaxException) { … }
class ExceptionEventCounter : public v8::debug::DebugDelegate { … };
UNINITIALIZED_TEST(NoBreakOnStackOverflow) { … }
TEST(BreakEventWhenEventListenerIsReset) { … }
TEST(AfterCompileEventOnBindToContext) { … }
TEST(NoDebugBreakInAfterCompileEventListener) { … }
TEST(RepeatDebugBreak) { … }
static void TestDebugBreakInLoop(const char* loop_head,
const char** loop_bodies,
const char* loop_tail) { … }
static const char* loop_bodies_1[] = …;
static const char* loop_bodies_2[] = …;
void DebugBreakLoop(const char* loop_header, const char** loop_bodies,
const char* loop_footer) { … }
TEST(DebugBreakInWhileTrue1) { … }
TEST(DebugBreakInWhileTrue2) { … }
TEST(DebugBreakInWhileCondition1) { … }
TEST(DebugBreakInWhileCondition2) { … }
TEST(DebugBreakInDoWhileTrue1) { … }
TEST(DebugBreakInDoWhileTrue2) { … }
TEST(DebugBreakInDoWhileCondition1) { … }
TEST(DebugBreakInDoWhileCondition2) { … }
TEST(DebugBreakInFor1) { … }
TEST(DebugBreakInFor2) { … }
TEST(DebugBreakInForCondition1) { … }
TEST(DebugBreakInForCondition2) { … }
class DebugBreakInlineListener : public v8::debug::DebugDelegate { … };
TEST(DebugBreakInline) { … }
static void RunScriptInANewCFrame(const char* source) { … }
TEST(Regress131642) { … }
class DebugBreakStackTraceListener : public v8::debug::DebugDelegate { … };
static void AddDebugBreak(const v8::FunctionCallbackInfo<v8::Value>& info) { … }
TEST(DebugBreakStackTrace) { … }
v8::base::Semaphore terminate_requested_semaphore(0);
v8::base::Semaphore terminate_fired_semaphore(0);
class DebugBreakTriggerTerminate : public v8::debug::DebugDelegate { … };
class TerminationThread : public v8::base::Thread { … };
TEST(DebugBreakOffThreadTerminate) { … }
class ArchiveRestoreThread : public v8::base::Thread,
public v8::debug::DebugDelegate { … };
TEST(DebugArchiveRestore) { … }
namespace {
class ThreadJustUsingV8Locker : public v8::base::Thread { … };
}
UNINITIALIZED_TEST(Bug1511649UnlockerRestoreDebug) { … }
class DebugEventExpectNoException : public v8::debug::DebugDelegate { … };
static void TryCatchWrappedThrowCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { … }
TEST(DebugPromiseInterceptedByTryCatch) { … }
class NoInterruptsOnDebugEvent : public v8::debug::DebugDelegate { … };
TEST(NoInterruptsInDebugListener) { … }
TEST(BreakLocationIterator) { … }
class DebugStepOverFunctionWithCaughtExceptionListener
: public v8::debug::DebugDelegate { … };
TEST(DebugStepOverFunctionWithCaughtException) { … }
bool near_heap_limit_callback_called = …;
size_t NearHeapLimitCallback(void* data, size_t current_heap_limit,
size_t initial_heap_limit) { … }
UNINITIALIZED_TEST(DebugSetOutOfMemoryListener) { … }
TEST(DebugCoverage) { … }
namespace {
v8::debug::Coverage::ScriptData GetScriptDataAndDeleteCoverage(
v8::Isolate* isolate) { … }
}
TEST(DebugCoverageWithCoverageOutOfScope) { … }
namespace {
v8::debug::Coverage::FunctionData GetFunctionDataAndDeleteCoverage(
v8::Isolate* isolate) { … }
}
TEST(DebugCoverageWithScriptDataOutOfScope) { … }
TEST(DebugGetPossibleBreakpointsReturnLocations) { … }
TEST(DebugEvaluateNoSideEffect) { … }
TEST(DebugEvaluateGlobalSharedCrossOrigin) { … }
TEST(DebugEvaluateLocalSharedCrossOrigin) { … }
TEST(DebugEvaluateImportMetaInScript) { … }
static v8::MaybeLocal<v8::Module> UnexpectedModuleResolveCallback(
v8::Local<v8::Context> context, v8::Local<v8::String> specifier,
v8::Local<v8::FixedArray> import_assertions,
v8::Local<v8::Module> referrer) { … }
TEST(DebugEvaluateImportMetaInModule) { … }
namespace {
i::MaybeHandle<i::Script> FindScript(
i::Isolate* isolate, const std::vector<i::Handle<i::Script>>& scripts,
const char* name) { … }
}
UNINITIALIZED_TEST(LoadedAtStartupScripts) { … }
TEST(SourceInfo) { … }
namespace {
class SetBreakpointOnScriptCompiled : public v8::debug::DebugDelegate { … };
}
TEST(Regress517592) { … }
namespace {
std::string FromString(v8::Isolate* isolate, v8::Local<v8::String> str) { … }
}
TEST(GetPrivateFields) { … }
TEST(GetPrivateMethodsAndAccessors) { … }
TEST(GetPrivateStaticMethodsAndAccessors) { … }
TEST(GetPrivateStaticAndInstanceMethodsAndAccessors) { … }
TEST(GetPrivateAutoAccessors) { … }
namespace {
class SetTerminateOnResumeDelegate : public v8::debug::DebugDelegate { … };
}
TEST(TerminateOnResumeAtBreakpoint) { … }
namespace {
bool microtask_one_ran = …;
static void MicrotaskOne(const v8::FunctionCallbackInfo<v8::Value>& info) { … }
}
TEST(TerminateOnResumeRunMicrotaskAtBreakpoint) { … }
TEST(TerminateOnResumeRunJavaScriptAtBreakpoint) { … }
TEST(TerminateOnResumeAtException) { … }
TEST(TerminateOnResumeAtBreakOnEntry) { … }
TEST(TerminateOnResumeAtBreakOnEntryUserDefinedFunction) { … }
TEST(TerminateOnResumeAtUnhandledRejection) { … }
namespace {
void RejectPromiseThroughCppInternal(
const v8::FunctionCallbackInfo<v8::Value>& info, bool silent) { … }
void RejectPromiseThroughCpp(const v8::FunctionCallbackInfo<v8::Value>& info) { … }
void SilentRejectPromiseThroughCpp(
const v8::FunctionCallbackInfo<v8::Value>& info) { … }
}
TEST(TerminateOnResumeAtUnhandledRejectionCppImpl) { … }
TEST(NoTerminateOnResumeAtSilentUnhandledRejectionCppImpl) { … }
namespace {
static void UnreachableMicrotask(
const v8::FunctionCallbackInfo<v8::Value>& info) { … }
}
TEST(TerminateOnResumeFromMicrotask) { … }
class FutexInterruptionThread : public v8::base::Thread { … };
namespace {
class SemaphoreTriggerOnBreak : public v8::debug::DebugDelegate { … };
}
TEST(TerminateOnResumeFromOtherThread) { … }
namespace {
class InterruptionBreakRightNow : public v8::base::Thread { … };
}
TEST(TerminateOnResumeAtInterruptFromOtherThread) { … }
namespace {
class NoopDelegate : public v8::debug::DebugDelegate { … };
}
TEST(CreateMessageFromOldException) { … }
TEST(CreateMessageDoesNotInspectStack) { … }
namespace {
class ScopeListener : public v8::debug::DebugDelegate { … };
}
TEST(ScopeIteratorDoesNotCreateBlocklistForScriptScope) { … }
namespace {
class DebugEvaluateListener : public v8::debug::DebugDelegate { … };
}
TEST(DebugEvaluateInWrappedScript) { … }
namespace {
class ConditionListener : public v8::debug::DebugDelegate { … };
}
TEST(SuccessfulBreakpointConditionEvaluationEvent) { … }
TEST(FailedBreakpointConditoinEvaluationEvent) { … }
class ExceptionCatchPredictionChecker : public v8::debug::DebugDelegate { … };
void RunExceptionCatchPredictionTest(bool predict_uncaught, const char* code) { … }
class FunctionBlackboxedCheckCounter : public v8::debug::DebugDelegate { … };
void RunAndIgnore(v8::Local<v8::Script> script,
v8::Local<v8::Context> context) { … }
void RunExceptionBlackboxCheckTest(int functions_checked, const char* code) { … }
void RunExceptionOptimizedCallstackWalkTest(bool predict_uncaught,
int functions_checked,
const char* code) { … }
TEST(CatchPredictionWithLongStar) { … }
TEST(CatchPredictionInlineExceptionCaught) { … }
TEST(CatchPredictionInlineExceptionUncaught) { … }
TEST(CatchPredictionExceptionCaughtAsPromise) { … }
TEST(CatchPredictionExceptionCaughtAsPromiseInAsyncFunction) { … }
TEST(CatchPredictionExceptionCaughtAsPromiseInCatchingFunction) { … }
TEST(CatchPredictionTopLevelEval) { … }
TEST(CatchPredictionClosureCapture) { … }
TEST(CatchPredictionNestedContext) { … }
TEST(CatchPredictionWithContext) { … }