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

Unified Diff: runtime/bin/dbg_connection.cc

Issue 10537065: Debugger break on TypeError, AssertionError (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/dbg_connection.h ('k') | runtime/include/dart_debugger_api.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/dbg_connection.cc
===================================================================
--- runtime/bin/dbg_connection.cc (revision 8456)
+++ runtime/bin/dbg_connection.cc (working copy)
@@ -409,14 +409,10 @@
}
-static void FormatField(dart::TextBuffer* buf,
- Dart_Handle object_name,
- Dart_Handle object) {
- ASSERT(Dart_IsString(object_name));
- buf->Printf("{\"name\":\"%s\",", GetStringChars(object_name));
+static void FormatRemoteObj(dart::TextBuffer* buf, Dart_Handle object) {
intptr_t obj_id = Dart_CacheObject(object);
ASSERT(obj_id >= 0);
- buf->Printf("\"value\":{\"objectId\":%d,", obj_id);
+ buf->Printf("{\"objectId\":%d,", obj_id);
const char* kind = "object";
if (Dart_IsInteger(object)) {
kind = "integer";
@@ -440,10 +436,21 @@
} else {
FormatEncodedString(buf, text);
}
- buf->Printf("}}");
+ buf->Printf("}");
}
+static void FormatField(dart::TextBuffer* buf,
+ Dart_Handle object_name,
+ Dart_Handle object) {
+ ASSERT(Dart_IsString(object_name));
+ buf->Printf("{\"name\":\"%s\",", GetStringChars(object_name));
+ buf->Printf("\"value\":");
+ FormatRemoteObj(buf, object);
+ buf->Printf("}");
+}
+
+
static void FormatFieldList(dart::TextBuffer* buf,
Dart_Handle obj_list) {
ASSERT(Dart_IsList(obj_list));
@@ -748,10 +755,20 @@
}
-void DebuggerConnectionHandler::SendBreakpointEvent(Dart_Breakpoint bpt,
- Dart_StackTrace trace) {
+void DebuggerConnectionHandler::WaitForConnection() {
+ MonitorLocker ml(&is_connected_);
+ while (!IsConnected()) {
+ printf("Waiting for debugger connection...\n");
+ dart::Monitor::WaitResult res = ml.Wait(dart::Monitor::kNoTimeout);
+ ASSERT(res == dart::Monitor::kNotified);
+ }
+}
+
+
+void DebuggerConnectionHandler::SendBreakpointEvent(Dart_StackTrace trace) {
dart::TextBuffer msg(128);
msg.Printf("{ \"event\": \"paused\", \"params\": { ");
+ msg.Printf("\"reason\": \"breakpoint\", ");
FormatCallFrames(&msg, trace);
msg.Printf("}}");
SendMsg(&msg);
@@ -760,17 +777,42 @@
void DebuggerConnectionHandler::BreakpointHandler(Dart_Breakpoint bpt,
Dart_StackTrace trace) {
- {
- MonitorLocker ml(&is_connected_);
- while (!IsConnected()) {
- printf("Waiting for debugger connection...\n");
- dart::Monitor::WaitResult res = ml.Wait(dart::Monitor::kNoTimeout);
- ASSERT(res == dart::Monitor::kNotified);
- }
+ WaitForConnection();
+ Dart_EnterScope();
+ SendQueuedMsgs();
+ SendBreakpointEvent(trace);
+ HandleMessages();
+ if (!msgbuf_->Alive()) {
+ CloseDbgConnection();
}
+ Dart_ExitScope();
+}
+
+
+void DebuggerConnectionHandler::SendExceptionEvent(
+ Dart_Handle exception,
+ Dart_StackTrace stack_trace) {
+ intptr_t exception_id = Dart_CacheObject(exception);
+ ASSERT(exception_id >= 0);
+ dart::TextBuffer msg(128);
+ msg.Printf("{ \"event\": \"paused\", \"params\": {");
+ msg.Printf("\"reason\": \"exception\", ");
+ msg.Printf("\"exception\":");
+ FormatRemoteObj(&msg, exception);
+ msg.Printf(", ");
+ FormatCallFrames(&msg, stack_trace);
+ msg.Printf("}}");
+ SendMsg(&msg);
+}
+
+
+void DebuggerConnectionHandler::ExceptionThrownHandler(
+ Dart_Handle exception,
+ Dart_StackTrace stack_trace) {
+ WaitForConnection();
Dart_EnterScope();
SendQueuedMsgs();
- SendBreakpointEvent(bpt, trace);
+ SendExceptionEvent(exception, stack_trace);
HandleMessages();
if (!msgbuf_->Alive()) {
CloseDbgConnection();
@@ -829,6 +871,7 @@
DebuggerConnectionImpl::StartHandler(port_number);
Dart_SetBreakpointHandler(BreakpointHandler);
Dart_SetBreakpointResolvedHandler(BptResolvedHandler);
+ Dart_SetExceptionThrownHandler(ExceptionThrownHandler);
}
« no previous file with comments | « runtime/bin/dbg_connection.h ('k') | runtime/include/dart_debugger_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698