Commit 175fc49c authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

[debug] remove legacy implementation for break points.

R=herhut@chromium.org, jgruber@chromium.org

Bug: v8:7310, v8:5510
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Icefd10b6cc210e5bb2684d18b091179ead387326
Reviewed-on: https://chromium-review.googlesource.com/934445
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51552}
parent d504203e
...@@ -180,12 +180,10 @@ class DebugDelegate { ...@@ -180,12 +180,10 @@ class DebugDelegate {
bool is_blackboxed) {} bool is_blackboxed) {}
virtual void ScriptCompiled(v8::Local<Script> script, bool is_live_edited, virtual void ScriptCompiled(v8::Local<Script> script, bool is_live_edited,
bool has_compile_error) {} bool has_compile_error) {}
// |break_points_hit| contains installed by JS debug API breakpoint objects.
// |inspector_break_points_hit| contains id of breakpoints installed with // |inspector_break_points_hit| contains id of breakpoints installed with
// debug::Script::SetBreakpoint API. // debug::Script::SetBreakpoint API.
virtual void BreakProgramRequested( virtual void BreakProgramRequested(
v8::Local<v8::Context> paused_context, v8::Local<v8::Object> exec_state, v8::Local<v8::Context> paused_context, v8::Local<v8::Object> exec_state,
v8::Local<v8::Value> break_points_hit,
const std::vector<debug::BreakpointId>& inspector_break_points_hit) {} const std::vector<debug::BreakpointId>& inspector_break_points_hit) {}
virtual void ExceptionThrown(v8::Local<v8::Context> paused_context, virtual void ExceptionThrown(v8::Local<v8::Context> paused_context,
v8::Local<v8::Object> exec_state, v8::Local<v8::Object> exec_state,
......
This diff is collapsed.
...@@ -241,12 +241,11 @@ class Debug { ...@@ -241,12 +241,11 @@ class Debug {
// Break point handling. // Break point handling.
bool SetBreakPoint(Handle<JSFunction> function, bool SetBreakPoint(Handle<JSFunction> function,
Handle<Object> break_point_object, Handle<BreakPoint> break_point, int* source_position);
int* source_position);
bool SetBreakPointForScript(Handle<Script> script, bool SetBreakPointForScript(Handle<Script> script,
Handle<Object> break_point_object, Handle<BreakPoint> break_point,
int* source_position); int* source_position);
void ClearBreakPoint(Handle<Object> break_point_object); void ClearBreakPoint(Handle<BreakPoint> break_point);
void ChangeBreakOnException(ExceptionBreakType type, bool enable); void ChangeBreakOnException(ExceptionBreakType type, bool enable);
bool IsBreakOnException(ExceptionBreakType type); bool IsBreakOnException(ExceptionBreakType type);
...@@ -254,12 +253,11 @@ class Debug { ...@@ -254,12 +253,11 @@ class Debug {
int* offset, int* id); int* offset, int* id);
void RemoveBreakpoint(int id); void RemoveBreakpoint(int id);
// The parameter is either a BreakPointInfo object, or a FixedArray of // The parameter is either a BreakPoint object, or a FixedArray of
// BreakPointInfo objects. // BreakPoint objects.
// Returns an empty handle if no breakpoint is hit, or a FixedArray with all // Returns an empty handle if no breakpoint is hit, or a FixedArray with all
// hit breakpoints. // hit BreakPoint objects.
MaybeHandle<FixedArray> GetHitBreakPointObjects( MaybeHandle<FixedArray> GetHitBreakPoints(Handle<Object> break_points);
Handle<Object> break_point_objects);
// Stepping handling. // Stepping handling.
void PrepareStep(StepAction step_action); void PrepareStep(StepAction step_action);
...@@ -437,8 +435,6 @@ class Debug { ...@@ -437,8 +435,6 @@ class Debug {
// Constructors for debug event objects. // Constructors for debug event objects.
MUST_USE_RESULT MaybeHandle<Object> MakeExecutionState(); MUST_USE_RESULT MaybeHandle<Object> MakeExecutionState();
MUST_USE_RESULT MaybeHandle<Object> MakeBreakEvent(
Handle<Object> break_points_hit);
MUST_USE_RESULT MaybeHandle<Object> MakeExceptionEvent( MUST_USE_RESULT MaybeHandle<Object> MakeExceptionEvent(
Handle<Object> exception, Handle<Object> exception,
bool uncaught, bool uncaught,
...@@ -472,7 +468,7 @@ class Debug { ...@@ -472,7 +468,7 @@ class Debug {
BreakLocation* location, BreakLocation* location,
bool* has_break_points = nullptr); bool* has_break_points = nullptr);
bool IsMutedAtCurrentLocation(JavaScriptFrame* frame); bool IsMutedAtCurrentLocation(JavaScriptFrame* frame);
bool CheckBreakPoint(Handle<Object> break_point_object); bool CheckBreakPoint(Handle<BreakPoint> break_point);
MaybeHandle<Object> CallFunction(const char* name, int argc, MaybeHandle<Object> CallFunction(const char* name, int argc,
Handle<Object> args[], Handle<Object> args[],
bool catch_exceptions = true); bool catch_exceptions = true);
...@@ -604,7 +600,6 @@ class LegacyDebugDelegate : public v8::debug::DebugDelegate { ...@@ -604,7 +600,6 @@ class LegacyDebugDelegate : public v8::debug::DebugDelegate {
bool has_compile_error) override; bool has_compile_error) override;
void BreakProgramRequested(v8::Local<v8::Context> paused_context, void BreakProgramRequested(v8::Local<v8::Context> paused_context,
v8::Local<v8::Object> exec_state, v8::Local<v8::Object> exec_state,
v8::Local<v8::Value> break_points_hit,
const std::vector<debug::BreakpointId>&) override; const std::vector<debug::BreakpointId>&) override;
void ExceptionThrown(v8::Local<v8::Context> paused_context, void ExceptionThrown(v8::Local<v8::Context> paused_context,
v8::Local<v8::Object> exec_state, v8::Local<v8::Object> exec_state,
...@@ -626,20 +621,6 @@ class LegacyDebugDelegate : public v8::debug::DebugDelegate { ...@@ -626,20 +621,6 @@ class LegacyDebugDelegate : public v8::debug::DebugDelegate {
Handle<JSObject> exec_state) = 0; Handle<JSObject> exec_state) = 0;
}; };
class JavaScriptDebugDelegate : public LegacyDebugDelegate {
public:
JavaScriptDebugDelegate(Isolate* isolate, Handle<JSFunction> listener,
Handle<Object> data);
virtual ~JavaScriptDebugDelegate();
private:
void ProcessDebugEvent(v8::DebugEvent event, Handle<JSObject> event_data,
Handle<JSObject> exec_state) override;
Handle<JSFunction> listener_;
Handle<Object> data_;
};
class NativeDebugDelegate : public LegacyDebugDelegate { class NativeDebugDelegate : public LegacyDebugDelegate {
public: public:
NativeDebugDelegate(Isolate* isolate, v8::Debug::EventCallback callback, NativeDebugDelegate(Isolate* isolate, v8::Debug::EventCallback callback,
......
This diff is collapsed.
...@@ -2717,7 +2717,7 @@ Handle<BreakPointInfo> Factory::NewBreakPointInfo(int source_position) { ...@@ -2717,7 +2717,7 @@ Handle<BreakPointInfo> Factory::NewBreakPointInfo(int source_position) {
Handle<BreakPointInfo> new_break_point_info = Handle<BreakPointInfo> new_break_point_info =
Handle<BreakPointInfo>::cast(NewStruct(TUPLE2_TYPE, TENURED)); Handle<BreakPointInfo>::cast(NewStruct(TUPLE2_TYPE, TENURED));
new_break_point_info->set_source_position(source_position); new_break_point_info->set_source_position(source_position);
new_break_point_info->set_break_point_objects(*undefined_value()); new_break_point_info->set_break_points(*undefined_value());
return new_break_point_info; return new_break_point_info;
} }
......
...@@ -494,7 +494,6 @@ void V8Debugger::ScriptCompiled(v8::Local<v8::debug::Script> script, ...@@ -494,7 +494,6 @@ void V8Debugger::ScriptCompiled(v8::Local<v8::debug::Script> script,
void V8Debugger::BreakProgramRequested( void V8Debugger::BreakProgramRequested(
v8::Local<v8::Context> pausedContext, v8::Local<v8::Object>, v8::Local<v8::Context> pausedContext, v8::Local<v8::Object>,
v8::Local<v8::Value>,
const std::vector<v8::debug::BreakpointId>& break_points_hit) { const std::vector<v8::debug::BreakpointId>& break_points_hit) {
handleProgramBreak(pausedContext, v8::Local<v8::Value>(), break_points_hit); handleProgramBreak(pausedContext, v8::Local<v8::Value>(), break_points_hit);
} }
......
...@@ -169,7 +169,6 @@ class V8Debugger : public v8::debug::DebugDelegate { ...@@ -169,7 +169,6 @@ class V8Debugger : public v8::debug::DebugDelegate {
bool has_compile_error) override; bool has_compile_error) override;
void BreakProgramRequested( void BreakProgramRequested(
v8::Local<v8::Context> paused_context, v8::Local<v8::Object>, v8::Local<v8::Context> paused_context, v8::Local<v8::Object>,
v8::Local<v8::Value>,
const std::vector<v8::debug::BreakpointId>& break_points_hit) override; const std::vector<v8::debug::BreakpointId>& break_points_hit) override;
void ExceptionThrown(v8::Local<v8::Context> paused_context, void ExceptionThrown(v8::Local<v8::Context> paused_context,
v8::Local<v8::Object>, v8::Local<v8::Value> exception, v8::Local<v8::Object>, v8::Local<v8::Value> exception,
......
...@@ -28,7 +28,7 @@ ACCESSORS(DebugInfo, break_points, FixedArray, kBreakPointsStateOffset) ...@@ -28,7 +28,7 @@ ACCESSORS(DebugInfo, break_points, FixedArray, kBreakPointsStateOffset)
ACCESSORS(DebugInfo, coverage_info, Object, kCoverageInfoOffset) ACCESSORS(DebugInfo, coverage_info, Object, kCoverageInfoOffset)
SMI_ACCESSORS(BreakPointInfo, source_position, kSourcePositionOffset) SMI_ACCESSORS(BreakPointInfo, source_position, kSourcePositionOffset)
ACCESSORS(BreakPointInfo, break_point_objects, Object, kBreakPointObjectsOffset) ACCESSORS(BreakPointInfo, break_points, Object, kBreakPointsOffset)
SMI_ACCESSORS(BreakPoint, id, kIdOffset) SMI_ACCESSORS(BreakPoint, id, kIdOffset)
ACCESSORS(BreakPoint, condition, String, kConditionOffset) ACCESSORS(BreakPoint, condition, String, kConditionOffset)
......
This diff is collapsed.
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
class BreakPoint;
class BytecodeArray; class BytecodeArray;
// The DebugInfo class holds additional information for a function being // The DebugInfo class holds additional information for a function being
...@@ -69,15 +70,15 @@ class DebugInfo : public Struct { ...@@ -69,15 +70,15 @@ class DebugInfo : public Struct {
bool HasBreakPoint(int source_position); bool HasBreakPoint(int source_position);
// Attempt to clear a break point. Return true if successful. // Attempt to clear a break point. Return true if successful.
static bool ClearBreakPoint(Handle<DebugInfo> debug_info, static bool ClearBreakPoint(Handle<DebugInfo> debug_info,
Handle<Object> break_point_object); Handle<BreakPoint> break_point);
// Set a break point. // Set a break point.
static void SetBreakPoint(Handle<DebugInfo> debug_info, int source_position, static void SetBreakPoint(Handle<DebugInfo> debug_info, int source_position,
Handle<Object> break_point_object); Handle<BreakPoint> break_point);
// Get the break point objects for a source position. // Get the break point objects for a source position.
Handle<Object> GetBreakPointObjects(int source_position); Handle<Object> GetBreakPoints(int source_position);
// Find the break point info holding this break point object. // Find the break point info holding this break point object.
static Handle<Object> FindBreakPointInfo(Handle<DebugInfo> debug_info, static Handle<Object> FindBreakPointInfo(Handle<DebugInfo> debug_info,
Handle<Object> break_point_object); Handle<BreakPoint> break_point);
// Get the number of break points for this function. // Get the number of break points for this function.
int GetBreakPointCount(); int GetBreakPointCount();
...@@ -134,17 +135,17 @@ class BreakPointInfo : public Tuple2 { ...@@ -134,17 +135,17 @@ class BreakPointInfo : public Tuple2 {
// The position in the source for the break position. // The position in the source for the break position.
DECL_INT_ACCESSORS(source_position) DECL_INT_ACCESSORS(source_position)
// List of related JavaScript break points. // List of related JavaScript break points.
DECL_ACCESSORS(break_point_objects, Object) DECL_ACCESSORS(break_points, Object)
// Removes a break point. // Removes a break point.
static void ClearBreakPoint(Handle<BreakPointInfo> info, static void ClearBreakPoint(Handle<BreakPointInfo> info,
Handle<Object> break_point_object); Handle<BreakPoint> break_point);
// Set a break point. // Set a break point.
static void SetBreakPoint(Handle<BreakPointInfo> info, static void SetBreakPoint(Handle<BreakPointInfo> info,
Handle<Object> break_point_object); Handle<BreakPoint> break_point);
// Check if break point info has this break point object. // Check if break point info has this break point.
static bool HasBreakPointObject(Handle<BreakPointInfo> info, static bool HasBreakPoint(Handle<BreakPointInfo> info,
Handle<Object> break_point_object); Handle<BreakPoint> break_point);
// Get the number of break points for this code offset. // Get the number of break points for this code offset.
int GetBreakPointCount(); int GetBreakPointCount();
...@@ -153,7 +154,7 @@ class BreakPointInfo : public Tuple2 { ...@@ -153,7 +154,7 @@ class BreakPointInfo : public Tuple2 {
DECL_CAST(BreakPointInfo) DECL_CAST(BreakPointInfo)
static const int kSourcePositionOffset = kValue1Offset; static const int kSourcePositionOffset = kValue1Offset;
static const int kBreakPointObjectsOffset = kValue2Offset; static const int kBreakPointsOffset = kValue2Offset;
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(BreakPointInfo); DISALLOW_IMPLICIT_CONSTRUCTORS(BreakPointInfo);
......
...@@ -85,27 +85,6 @@ RUNTIME_FUNCTION(Runtime_HandleDebuggerStatement) { ...@@ -85,27 +85,6 @@ RUNTIME_FUNCTION(Runtime_HandleDebuggerStatement) {
} }
// Adds a JavaScript function as a debug event listener.
// args[0]: debug event listener function to set or null or undefined for
// clearing the event listener function
// args[1]: object supplied during callback
RUNTIME_FUNCTION(Runtime_SetDebugEventListener) {
SealHandleScope shs(isolate);
DCHECK_EQ(2, args.length());
CHECK(args[0]->IsJSFunction() || args[0]->IsNullOrUndefined(isolate));
CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, data, 1);
if (callback->IsJSFunction()) {
JavaScriptDebugDelegate* delegate = new JavaScriptDebugDelegate(
isolate, Handle<JSFunction>::cast(callback), data);
isolate->debug()->SetDebugDelegate(delegate, true);
} else {
isolate->debug()->SetDebugDelegate(nullptr, false);
}
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_ScheduleBreak) { RUNTIME_FUNCTION(Runtime_ScheduleBreak) {
SealHandleScope shs(isolate); SealHandleScope shs(isolate);
DCHECK_EQ(0, args.length()); DCHECK_EQ(0, args.length());
...@@ -1041,16 +1020,6 @@ RUNTIME_FUNCTION(Runtime_SetScopeVariableValue) { ...@@ -1041,16 +1020,6 @@ RUNTIME_FUNCTION(Runtime_SetScopeVariableValue) {
return isolate->heap()->ToBoolean(res); return isolate->heap()->ToBoolean(res);
} }
// Sets the disable break state
// args[0]: disable break state
RUNTIME_FUNCTION(Runtime_SetBreakPointsActive) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_BOOLEAN_ARG_CHECKED(active, 0);
isolate->debug()->set_break_points_active(active);
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_GetBreakLocations) { RUNTIME_FUNCTION(Runtime_GetBreakLocations) {
HandleScope scope(isolate); HandleScope scope(isolate);
...@@ -1070,71 +1039,6 @@ RUNTIME_FUNCTION(Runtime_GetBreakLocations) { ...@@ -1070,71 +1039,6 @@ RUNTIME_FUNCTION(Runtime_GetBreakLocations) {
} }
// Set a break point in a function.
// args[0]: function
// args[1]: number: break source position (within the function source)
// args[2]: number: break point object
RUNTIME_FUNCTION(Runtime_SetFunctionBreakPoint) {
HandleScope scope(isolate);
DCHECK_EQ(3, args.length());
CHECK(isolate->debug()->is_active());
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]);
CHECK(source_position >= function->shared()->start_position() &&
source_position <= function->shared()->end_position());
CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 2);
// Set break point.
CHECK(isolate->debug()->SetBreakPoint(function, break_point_object_arg,
&source_position));
return Smi::FromInt(source_position);
}
// Changes the state of a break point in a script and returns source position
// where break point was set. NOTE: Regarding performance see the NOTE for
// GetScriptFromScriptData.
// args[0]: script to set break point in
// args[1]: number: break source position (within the script source)
// args[2]: number: break point object
RUNTIME_FUNCTION(Runtime_SetScriptBreakPoint) {
HandleScope scope(isolate);
DCHECK_EQ(3, args.length());
CHECK(isolate->debug()->is_active());
CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0);
CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]);
CHECK_GE(source_position, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 2);
// Get the script from the script wrapper.
CHECK(wrapper->value()->IsScript());
Handle<Script> script(Script::cast(wrapper->value()));
// Set break point.
if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg,
&source_position)) {
return isolate->heap()->undefined_value();
}
return Smi::FromInt(source_position);
}
// Clear a break point
// args[0]: number: break point object
RUNTIME_FUNCTION(Runtime_ClearBreakPoint) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CHECK(isolate->debug()->is_active());
CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 0);
// Clear break point.
isolate->debug()->ClearBreakPoint(break_point_object_arg);
return isolate->heap()->undefined_value();
}
// Change the state of break on exceptions. // Change the state of break on exceptions.
// args[0]: Enum value indicating whether to affect caught/uncaught exceptions. // args[0]: Enum value indicating whether to affect caught/uncaught exceptions.
// args[1]: Boolean indicating on/off. // args[1]: Boolean indicating on/off.
...@@ -1720,44 +1624,6 @@ RUNTIME_FUNCTION(Runtime_ScriptPositionInfo2) { ...@@ -1720,44 +1624,6 @@ RUNTIME_FUNCTION(Runtime_ScriptPositionInfo2) {
return *GetJSPositionInfo(script, position, offset_flag, isolate); return *GetJSPositionInfo(script, position, offset_flag, isolate);
} }
// Returns the given line as a string, or null if line is out of bounds.
// The parameter line is expected to include the script's line offset.
// TODO(5530): Remove once uses in debug.js are gone.
RUNTIME_FUNCTION(Runtime_ScriptSourceLine) {
HandleScope scope(isolate);
DCHECK_EQ(2, args.length());
CONVERT_ARG_CHECKED(JSValue, script, 0);
CONVERT_NUMBER_CHECKED(int32_t, line, Int32, args[1]);
CHECK(script->value()->IsScript());
Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
if (script_handle->type() == Script::TYPE_WASM) {
// Return null for now; this function will disappear soon anyway.
return isolate->heap()->null_value();
}
Script::InitLineEnds(script_handle);
FixedArray* line_ends_array = FixedArray::cast(script_handle->line_ends());
const int line_count = line_ends_array->length();
line -= script_handle->line_offset();
if (line < 0 || line_count <= line) {
return isolate->heap()->null_value();
}
const int start =
(line == 0) ? 0 : Smi::ToInt(line_ends_array->get(line - 1)) + 1;
const int end = Smi::ToInt(line_ends_array->get(line));
Handle<String> source =
handle(String::cast(script_handle->source()), isolate);
Handle<String> str = isolate->factory()->NewSubString(source, start, end);
return *str;
}
// On function call, depending on circumstances, prepare for stepping in, // On function call, depending on circumstances, prepare for stepping in,
// or perform a side effect check. // or perform a side effect check.
RUNTIME_FUNCTION(Runtime_DebugOnFunctionCall) { RUNTIME_FUNCTION(Runtime_DebugOnFunctionCall) {
......
...@@ -128,7 +128,6 @@ namespace internal { ...@@ -128,7 +128,6 @@ namespace internal {
#define FOR_EACH_INTRINSIC_DEBUG(F) \ #define FOR_EACH_INTRINSIC_DEBUG(F) \
F(HandleDebuggerStatement, 0, 1) \ F(HandleDebuggerStatement, 0, 1) \
F(SetDebugEventListener, 2, 1) \
F(ScheduleBreak, 0, 1) \ F(ScheduleBreak, 0, 1) \
F(DebugGetInternalProperties, 1, 1) \ F(DebugGetInternalProperties, 1, 1) \
F(DebugGetPropertyDetails, 2, 1) \ F(DebugGetPropertyDetails, 2, 1) \
...@@ -146,11 +145,7 @@ namespace internal { ...@@ -146,11 +145,7 @@ namespace internal {
F(GetGeneratorScopeCount, 1, 1) \ F(GetGeneratorScopeCount, 1, 1) \
F(GetGeneratorScopeDetails, 2, 1) \ F(GetGeneratorScopeDetails, 2, 1) \
F(SetScopeVariableValue, 6, 1) \ F(SetScopeVariableValue, 6, 1) \
F(SetBreakPointsActive, 1, 1) \
F(GetBreakLocations, 1, 1) \ F(GetBreakLocations, 1, 1) \
F(SetFunctionBreakPoint, 3, 1) \
F(SetScriptBreakPoint, 3, 1) \
F(ClearBreakPoint, 1, 1) \
F(ChangeBreakOnException, 2, 1) \ F(ChangeBreakOnException, 2, 1) \
F(IsBreakOnException, 1, 1) \ F(IsBreakOnException, 1, 1) \
F(PrepareStep, 2, 1) \ F(PrepareStep, 2, 1) \
...@@ -173,7 +168,6 @@ namespace internal { ...@@ -173,7 +168,6 @@ namespace internal {
F(ScriptLocationFromLine2, 4, 1) \ F(ScriptLocationFromLine2, 4, 1) \
F(ScriptPositionInfo, 3, 1) \ F(ScriptPositionInfo, 3, 1) \
F(ScriptPositionInfo2, 3, 1) \ F(ScriptPositionInfo2, 3, 1) \
F(ScriptSourceLine, 2, 1) \
F(DebugOnFunctionCall, 1, 1) \ F(DebugOnFunctionCall, 1, 1) \
F(DebugPrepareStepInSuspendedGenerator, 0, 1) \ F(DebugPrepareStepInSuspendedGenerator, 0, 1) \
F(DebugPushPromise, 1, 1) \ F(DebugPushPromise, 1, 1) \
......
...@@ -1049,7 +1049,7 @@ int FindBreakpointInfoInsertPos(Isolate* isolate, ...@@ -1049,7 +1049,7 @@ int FindBreakpointInfoInsertPos(Isolate* isolate,
void WasmSharedModuleData::AddBreakpoint(Handle<WasmSharedModuleData> shared, void WasmSharedModuleData::AddBreakpoint(Handle<WasmSharedModuleData> shared,
int position, int position,
Handle<Object> break_point_object) { Handle<BreakPoint> break_point) {
Isolate* isolate = shared->GetIsolate(); Isolate* isolate = shared->GetIsolate();
Handle<FixedArray> breakpoint_infos; Handle<FixedArray> breakpoint_infos;
if (shared->has_breakpoint_infos()) { if (shared->has_breakpoint_infos()) {
...@@ -1069,7 +1069,7 @@ void WasmSharedModuleData::AddBreakpoint(Handle<WasmSharedModuleData> shared, ...@@ -1069,7 +1069,7 @@ void WasmSharedModuleData::AddBreakpoint(Handle<WasmSharedModuleData> shared,
position) { position) {
Handle<BreakPointInfo> old_info( Handle<BreakPointInfo> old_info(
BreakPointInfo::cast(breakpoint_infos->get(insert_pos)), isolate); BreakPointInfo::cast(breakpoint_infos->get(insert_pos)), isolate);
BreakPointInfo::SetBreakPoint(old_info, break_point_object); BreakPointInfo::SetBreakPoint(old_info, break_point);
return; return;
} }
...@@ -1096,7 +1096,7 @@ void WasmSharedModuleData::AddBreakpoint(Handle<WasmSharedModuleData> shared, ...@@ -1096,7 +1096,7 @@ void WasmSharedModuleData::AddBreakpoint(Handle<WasmSharedModuleData> shared,
// Generate new BreakpointInfo. // Generate new BreakpointInfo.
Handle<BreakPointInfo> breakpoint_info = Handle<BreakPointInfo> breakpoint_info =
isolate->factory()->NewBreakPointInfo(position); isolate->factory()->NewBreakPointInfo(position);
BreakPointInfo::SetBreakPoint(breakpoint_info, break_point_object); BreakPointInfo::SetBreakPoint(breakpoint_info, break_point);
// Now insert new position at insert_pos. // Now insert new position at insert_pos.
new_breakpoint_infos->set(insert_pos, *breakpoint_info); new_breakpoint_infos->set(insert_pos, *breakpoint_info);
...@@ -1368,9 +1368,8 @@ MaybeHandle<FixedArray> WasmSharedModuleData::CheckBreakPoints( ...@@ -1368,9 +1368,8 @@ MaybeHandle<FixedArray> WasmSharedModuleData::CheckBreakPoints(
Handle<BreakPointInfo>::cast(maybe_breakpoint_info); Handle<BreakPointInfo>::cast(maybe_breakpoint_info);
if (breakpoint_info->source_position() != position) return {}; if (breakpoint_info->source_position() != position) return {};
Handle<Object> breakpoint_objects(breakpoint_info->break_point_objects(), Handle<Object> break_points(breakpoint_info->break_points(), isolate);
isolate); return isolate->debug()->GetHitBreakPoints(break_points);
return isolate->debug()->GetHitBreakPointObjects(breakpoint_objects);
} }
Handle<WasmCompiledModule> WasmCompiledModule::New( Handle<WasmCompiledModule> WasmCompiledModule::New(
...@@ -1809,10 +1808,9 @@ bool WasmSharedModuleData::GetPositionInfo(uint32_t position, ...@@ -1809,10 +1808,9 @@ bool WasmSharedModuleData::GetPositionInfo(uint32_t position,
return true; return true;
} }
bool WasmCompiledModule::SetBreakPoint( bool WasmCompiledModule::SetBreakPoint(
Handle<WasmCompiledModule> compiled_module, int* position, Handle<WasmCompiledModule> compiled_module, int* position,
Handle<Object> break_point_object) { Handle<BreakPoint> break_point) {
Isolate* isolate = compiled_module->GetIsolate(); Isolate* isolate = compiled_module->GetIsolate();
Handle<WasmSharedModuleData> shared(compiled_module->shared(), isolate); Handle<WasmSharedModuleData> shared(compiled_module->shared(), isolate);
...@@ -1827,7 +1825,7 @@ bool WasmCompiledModule::SetBreakPoint( ...@@ -1827,7 +1825,7 @@ bool WasmCompiledModule::SetBreakPoint(
DCHECK(IsBreakablePosition(*shared, func_index, offset_in_func)); DCHECK(IsBreakablePosition(*shared, func_index, offset_in_func));
// Insert new break point into break_positions of shared module data. // Insert new break point into break_positions of shared module data.
WasmSharedModuleData::AddBreakpoint(shared, *position, break_point_object); WasmSharedModuleData::AddBreakpoint(shared, *position, break_point);
// Iterate over all instances of this module and tell them to set this new // Iterate over all instances of this module and tell them to set this new
// breakpoint. // breakpoint.
......
...@@ -337,7 +337,7 @@ class WasmSharedModuleData : public FixedArray { ...@@ -337,7 +337,7 @@ class WasmSharedModuleData : public FixedArray {
Handle<WasmSharedModuleData>); Handle<WasmSharedModuleData>);
static void AddBreakpoint(Handle<WasmSharedModuleData>, int position, static void AddBreakpoint(Handle<WasmSharedModuleData>, int position,
Handle<Object> break_point_object); Handle<BreakPoint> break_point);
static void SetBreakpointsOnNewInstance(Handle<WasmSharedModuleData>, static void SetBreakpointsOnNewInstance(Handle<WasmSharedModuleData>,
Handle<WasmInstanceObject>); Handle<WasmInstanceObject>);
...@@ -569,7 +569,7 @@ class WasmCompiledModule : public FixedArray { ...@@ -569,7 +569,7 @@ class WasmCompiledModule : public FixedArray {
// If it points outside a function, or behind the last breakable location, // If it points outside a function, or behind the last breakable location,
// this function returns false and does not set any breakpoint. // this function returns false and does not set any breakpoint.
static bool SetBreakPoint(Handle<WasmCompiledModule>, int* position, static bool SetBreakPoint(Handle<WasmCompiledModule>, int* position,
Handle<Object> break_point_object); Handle<BreakPoint> break_point);
inline void ReplaceCodeTableForTesting( inline void ReplaceCodeTableForTesting(
std::vector<wasm::WasmCode*>&& testing_table); std::vector<wasm::WasmCode*>&& testing_table);
......
...@@ -2971,7 +2971,6 @@ class CountBreakDebugDelegate : public v8::debug::DebugDelegate { ...@@ -2971,7 +2971,6 @@ class CountBreakDebugDelegate : public v8::debug::DebugDelegate {
public: public:
void BreakProgramRequested(v8::Local<v8::Context> paused_context, void BreakProgramRequested(v8::Local<v8::Context> paused_context,
v8::Local<v8::Object> exec_state, v8::Local<v8::Object> exec_state,
v8::Local<v8::Value> break_points_hit,
const std::vector<int>&) override { const std::vector<int>&) override {
debug_break_count++; debug_break_count++;
} }
......
This diff is collapsed.
...@@ -88,7 +88,6 @@ class BreakHandler : public debug::DebugDelegate { ...@@ -88,7 +88,6 @@ class BreakHandler : public debug::DebugDelegate {
void BreakProgramRequested(v8::Local<v8::Context> paused_context, void BreakProgramRequested(v8::Local<v8::Context> paused_context,
v8::Local<v8::Object> exec_state, v8::Local<v8::Object> exec_state,
v8::Local<v8::Value> break_points_hit,
const std::vector<int>&) override { const std::vector<int>&) override {
printf("Break #%d\n", count_); printf("Break #%d\n", count_);
CHECK_GT(expected_breaks_.size(), count_); CHECK_GT(expected_breaks_.size(), count_);
...@@ -114,26 +113,6 @@ class BreakHandler : public debug::DebugDelegate { ...@@ -114,26 +113,6 @@ class BreakHandler : public debug::DebugDelegate {
} }
}; };
Handle<JSObject> MakeFakeBreakpoint(Isolate* isolate, int position) {
Handle<JSObject> obj =
isolate->factory()->NewJSObject(isolate->object_function());
// Generate an "isTriggered" method that always returns true.
// This can/must be refactored once we remove remaining JS parts from the
// debugger (bug 5530).
Handle<String> source = isolate->factory()->NewStringFromStaticChars("true");
Handle<Context> context(isolate->context(), isolate);
Handle<JSFunction> triggered_fun =
Compiler::GetFunctionFromString(context, source, NO_PARSE_RESTRICTION,
kNoSourcePosition)
.ToHandleChecked();
PropertyDescriptor desc;
desc.set_value(triggered_fun);
Handle<String> name =
isolate->factory()->InternalizeUtf8String(CStrVector("isTriggered"));
CHECK(JSObject::DefineOwnProperty(isolate, obj, name, &desc, kDontThrow)
.FromMaybe(false));
return obj;
}
void SetBreakpoint(WasmRunnerBase& runner, int function_index, int byte_offset, void SetBreakpoint(WasmRunnerBase& runner, int function_index, int byte_offset,
int expected_set_byte_offset = -1) { int expected_set_byte_offset = -1) {
...@@ -143,10 +122,12 @@ void SetBreakpoint(WasmRunnerBase& runner, int function_index, int byte_offset, ...@@ -143,10 +122,12 @@ void SetBreakpoint(WasmRunnerBase& runner, int function_index, int byte_offset,
if (expected_set_byte_offset == -1) expected_set_byte_offset = byte_offset; if (expected_set_byte_offset == -1) expected_set_byte_offset = byte_offset;
Handle<WasmInstanceObject> instance = runner.builder().instance_object(); Handle<WasmInstanceObject> instance = runner.builder().instance_object();
Handle<WasmCompiledModule> compiled_module(instance->compiled_module()); Handle<WasmCompiledModule> compiled_module(instance->compiled_module());
Handle<JSObject> fake_breakpoint_object = static int break_index = 0;
MakeFakeBreakpoint(runner.main_isolate(), code_offset); Handle<BreakPoint> break_point =
runner.main_isolate()->factory()->NewBreakPoint(
break_index++, runner.main_isolate()->factory()->empty_string());
CHECK(WasmCompiledModule::SetBreakPoint(compiled_module, &code_offset, CHECK(WasmCompiledModule::SetBreakPoint(compiled_module, &code_offset,
fake_breakpoint_object)); break_point));
int set_byte_offset = code_offset - func_offset; int set_byte_offset = code_offset - func_offset;
CHECK_EQ(expected_set_byte_offset, set_byte_offset); CHECK_EQ(expected_set_byte_offset, set_byte_offset);
// Also set breakpoint on the debug info of the instance directly, since the // Also set breakpoint on the debug info of the instance directly, since the
...@@ -212,7 +193,6 @@ class CollectValuesBreakHandler : public debug::DebugDelegate { ...@@ -212,7 +193,6 @@ class CollectValuesBreakHandler : public debug::DebugDelegate {
void BreakProgramRequested(v8::Local<v8::Context> paused_context, void BreakProgramRequested(v8::Local<v8::Context> paused_context,
v8::Local<v8::Object> exec_state, v8::Local<v8::Object> exec_state,
v8::Local<v8::Value> break_points_hit,
const std::vector<int>&) override { const std::vector<int>&) override {
printf("Break #%d\n", count_); printf("Break #%d\n", count_);
CHECK_GT(expected_values_.size(), count_); CHECK_GT(expected_values_.size(), count_);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// Flags: --allow-natives-syntax --cache=code // Flags: --allow-natives-syntax --cache=code
// Test that script ids are unique and we found the correct ones. // Test that script ids are unique and we found the correct ones.
var Debug = %GetDebugContext().Debug; var Debug = debug.Debug;
Debug.setListener(function(){}); Debug.setListener(function(){});
var scripts = %DebugGetLoadedScripts(); var scripts = %DebugGetLoadedScripts();
......
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Test that setting break point works correctly when the debugger is
// activated late, which leads to duplicate shared function infos.
(function() {
var Debug = %GetDebugContext().Debug;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
assertTrue(/foo/.test(exec_state.frame(0).sourceLineText()));
break_count++;
} catch (e) {
exception = e;
}
}
for (var i = 0; i < 3; i++) {
var foo = function() { a = 1; }
var exception = null;
var break_count = 0;
Debug.setListener(listener);
if (i < 2) Debug.setBreakPoint(foo, 0, 0);
assertTrue(/\[B\d\]a = 1/.test(Debug.showBreakPoints(foo)));
foo();
assertEquals(1, break_count);
assertNull(exception);
}
Debug.setListener(null);
})();
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
try { } catch(e) { } try { } catch(e) { }
try { try { } catch (e) { } } catch(e) { } try { try { } catch (e) { } } catch(e) { }
try { try {
var Debug = %GetDebugContext().Debug; var Debug = debug.Debug;
Debug.setListener(function(){}); Debug.setListener(function(){});
} catch(e) { } } catch(e) { }
(function() { (function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment