Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: test/cctest/wasm/test-wasm-breakpoints.cc

Issue 2642253005: [debugger api] remove legacy JSON debug protocol. (Closed)
Patch Set: fix cctest Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/wasm/wasm-debug.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/debug/debug-interface.h" 5 #include "src/debug/debug-interface.h"
6 #include "src/property-descriptor.h" 6 #include "src/property-descriptor.h"
7 #include "src/wasm/wasm-macro-gen.h" 7 #include "src/wasm/wasm-macro-gen.h"
8 #include "src/wasm/wasm-objects.h" 8 #include "src/wasm/wasm-objects.h"
9 9
10 #include "test/cctest/cctest.h" 10 #include "test/cctest/cctest.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 std::vector<debug::Location> locations; 48 std::vector<debug::Location> locations;
49 bool success = 49 bool success =
50 compiled_module->GetPossibleBreakpoints(start, end, &locations); 50 compiled_module->GetPossibleBreakpoints(start, end, &locations);
51 CHECK(!success); 51 CHECK(!success);
52 } 52 }
53 53
54 class BreakHandler { 54 class BreakHandler {
55 public: 55 public:
56 explicit BreakHandler(Isolate* isolate) : isolate_(isolate) { 56 explicit BreakHandler(Isolate* isolate) : isolate_(isolate) {
57 current_handler = this; 57 current_handler = this;
58 isolate->debug()->SetMessageHandler(&HandleMessage); 58 v8::Debug::SetDebugEventListener(reinterpret_cast<v8::Isolate*>(isolate),
59 DebugEventListener);
59 } 60 }
60 ~BreakHandler() { 61 ~BreakHandler() {
61 CHECK_EQ(this, current_handler); 62 CHECK_EQ(this, current_handler);
62 current_handler = nullptr; 63 current_handler = nullptr;
63 isolate_->debug()->SetMessageHandler(nullptr); 64 v8::Debug::SetDebugEventListener(reinterpret_cast<v8::Isolate*>(isolate_),
65 nullptr);
64 } 66 }
65 67
66 int count() const { return count_; } 68 int count() const { return count_; }
67 69
68 private: 70 private:
69 Isolate* isolate_; 71 Isolate* isolate_;
70 int count_ = 0; 72 int count_ = 0;
71 73
72 static BreakHandler* current_handler; 74 static BreakHandler* current_handler;
73 75
74 static void HandleMessage(const v8::Debug::Message& message) { 76 static void DebugEventListener(const v8::Debug::EventDetails& event_details) {
75 // Ignore responses. 77 if (event_details.GetEvent() != v8::DebugEvent::Break) return;
76 if (!message.IsEvent()) return;
77 // Ignore everything except break events.
78 if (message.GetEvent() != v8::DebugEvent::Break) return;
79 78
80 printf("break!\n"); 79 printf("break!\n");
81 CHECK_NOT_NULL(current_handler); 80 CHECK_NOT_NULL(current_handler);
82 current_handler->count_ += 1; 81 current_handler->count_ += 1;
83 // Don't run into an endless loop. 82 // Don't run into an endless loop.
84 CHECK_GT(100, current_handler->count_); 83 CHECK_GT(100, current_handler->count_);
85
86 const char command[] = "{\"type\":\"request\", \"command\":\"continue\"}";
87 uint16_t command_u16[arraysize(command) - 1];
88 for (unsigned i = 0; i < arraysize(command) - 1; ++i) {
89 command_u16[i] = command[i];
90 }
91 current_handler->isolate_->debug()->EnqueueCommandMessage(
92 ArrayVector(command_u16), message.GetClientData());
93 } 84 }
94 }; 85 };
95 86
96 // static 87 // static
97 BreakHandler* BreakHandler::current_handler = nullptr; 88 BreakHandler* BreakHandler::current_handler = nullptr;
98 89
99 Handle<JSObject> MakeFakeBreakpoint(Isolate* isolate, int position) { 90 Handle<JSObject> MakeFakeBreakpoint(Isolate* isolate, int position) {
100 Handle<JSObject> obj = 91 Handle<JSObject> obj =
101 isolate->factory()->NewJSObject(isolate->object_function()); 92 isolate->factory()->NewJSObject(isolate->object_function());
102 // Generate an "isTriggered" method that always returns true. 93 // Generate an "isTriggered" method that always returns true.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 Handle<Object> global(isolate->context()->global_object(), isolate); 172 Handle<Object> global(isolate->context()->global_object(), isolate);
182 MaybeHandle<Object> retval = 173 MaybeHandle<Object> retval =
183 Execution::Call(isolate, main_fun_wrapper, global, 0, nullptr); 174 Execution::Call(isolate, main_fun_wrapper, global, 0, nullptr);
184 CHECK(!retval.is_null()); 175 CHECK(!retval.is_null());
185 int result; 176 int result;
186 CHECK(retval.ToHandleChecked()->ToInt32(&result)); 177 CHECK(retval.ToHandleChecked()->ToInt32(&result));
187 CHECK_EQ(14, result); 178 CHECK_EQ(14, result);
188 179
189 CHECK_EQ(1, count_breaks.count()); 180 CHECK_EQ(1, count_breaks.count());
190 } 181 }
OLDNEW
« no previous file with comments | « src/wasm/wasm-debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698