| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bin/dbg_connection.h" | 5 #include "bin/dbg_connection.h" |
| 6 #include "bin/dbg_message.h" | 6 #include "bin/dbg_message.h" |
| 7 #include "bin/dartutils.h" | 7 #include "bin/dartutils.h" |
| 8 #include "bin/thread.h" | 8 #include "bin/thread.h" |
| 9 #include "bin/utils.h" | 9 #include "bin/utils.h" |
| 10 | 10 |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 Dart_StackTrace trace) { | 393 Dart_StackTrace trace) { |
| 394 intptr_t trace_len = 0; | 394 intptr_t trace_len = 0; |
| 395 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); | 395 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); |
| 396 ASSERT_NOT_ERROR(res); | 396 ASSERT_NOT_ERROR(res); |
| 397 Dart_ActivationFrame frame; | 397 Dart_ActivationFrame frame; |
| 398 res = Dart_GetActivationFrame(trace, 0, &frame); | 398 res = Dart_GetActivationFrame(trace, 0, &frame); |
| 399 ASSERT_NOT_ERROR(res); | 399 ASSERT_NOT_ERROR(res); |
| 400 Dart_Handle script_url; | 400 Dart_Handle script_url; |
| 401 intptr_t token_number = 0; | 401 intptr_t token_number = 0; |
| 402 intptr_t line_number = 0; | 402 intptr_t line_number = 0; |
| 403 intptr_t library_id = 0; |
| 404 // TODO(hausner): Remove this call and line_number once Editor no |
| 405 // longer depends on line number info. |
| 403 res = Dart_ActivationFrameInfo(frame, NULL, NULL, &line_number, NULL); | 406 res = Dart_ActivationFrameInfo(frame, NULL, NULL, &line_number, NULL); |
| 404 ASSERT_NOT_ERROR(res); | 407 ASSERT_NOT_ERROR(res); |
| 405 res = Dart_ActivationFrameGetLocation(frame, &script_url, &token_number); | 408 res = Dart_ActivationFrameGetLocation( |
| 409 frame, &script_url, &library_id, &token_number); |
| 406 ASSERT_NOT_ERROR(res); | 410 ASSERT_NOT_ERROR(res); |
| 407 if (!Dart_IsNull(script_url)) { | 411 if (!Dart_IsNull(script_url)) { |
| 408 ASSERT(Dart_IsString(script_url)); | 412 ASSERT(Dart_IsString(script_url)); |
| 409 msg->Printf("\"location\": { \"url\":"); | 413 msg->Printf("\"location\": { \"url\":"); |
| 410 FormatEncodedString(msg, script_url); | 414 FormatEncodedString(msg, script_url); |
| 415 msg->Printf("\"libraryId\":%"Pd"},", library_id); |
| 411 msg->Printf(",\"tokenOffset\":%"Pd",", token_number); | 416 msg->Printf(",\"tokenOffset\":%"Pd",", token_number); |
| 412 msg->Printf("\"lineNumber\":%"Pd"},", line_number); | 417 msg->Printf("\"lineNumber\":%"Pd"},", line_number); |
| 413 } | 418 } |
| 414 } | 419 } |
| 415 | 420 |
| 416 | 421 |
| 417 static void FormatCallFrames(dart::TextBuffer* msg, Dart_StackTrace trace) { | 422 static void FormatCallFrames(dart::TextBuffer* msg, Dart_StackTrace trace) { |
| 418 intptr_t trace_len = 0; | 423 intptr_t trace_len = 0; |
| 419 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); | 424 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); |
| 420 ASSERT_NOT_ERROR(res); | 425 ASSERT_NOT_ERROR(res); |
| 421 msg->Printf("\"callFrames\" : [ "); | 426 msg->Printf("\"callFrames\" : [ "); |
| 422 for (int i = 0; i < trace_len; i++) { | 427 for (int i = 0; i < trace_len; i++) { |
| 423 Dart_ActivationFrame frame; | 428 Dart_ActivationFrame frame; |
| 424 res = Dart_GetActivationFrame(trace, i, &frame); | 429 res = Dart_GetActivationFrame(trace, i, &frame); |
| 425 ASSERT_NOT_ERROR(res); | 430 ASSERT_NOT_ERROR(res); |
| 426 Dart_Handle func_name; | 431 Dart_Handle func_name; |
| 427 Dart_Handle script_url; | 432 Dart_Handle script_url; |
| 428 intptr_t line_number = 0; | 433 intptr_t line_number = 0; |
| 429 intptr_t token_number = 0; | 434 intptr_t token_number = 0; |
| 430 intptr_t library_id = 0; | 435 intptr_t library_id = 0; |
| 431 res = Dart_ActivationFrameInfo( | 436 res = Dart_ActivationFrameInfo( |
| 432 frame, &func_name, NULL, &line_number, &library_id); | 437 frame, &func_name, NULL, &line_number, &library_id); |
| 433 ASSERT_NOT_ERROR(res); | 438 ASSERT_NOT_ERROR(res); |
| 434 | 439 |
| 435 ASSERT(Dart_IsString(func_name)); | 440 ASSERT(Dart_IsString(func_name)); |
| 436 msg->Printf("%s{\"functionName\":", (i > 0) ? "," : ""); | 441 msg->Printf("%s{\"functionName\":", (i > 0) ? "," : ""); |
| 437 FormatEncodedString(msg, func_name); | 442 FormatEncodedString(msg, func_name); |
| 443 // TODO(hausner): Remove this libraryId field when Editor |
| 444 // no longer depends on it. |
| 438 msg->Printf(",\"libraryId\": %"Pd",", library_id); | 445 msg->Printf(",\"libraryId\": %"Pd",", library_id); |
| 439 | 446 |
| 440 res = Dart_ActivationFrameGetLocation(frame, &script_url, &token_number); | 447 res = Dart_ActivationFrameGetLocation( |
| 448 frame, &script_url, NULL, &token_number); |
| 441 ASSERT_NOT_ERROR(res); | 449 ASSERT_NOT_ERROR(res); |
| 442 if (!Dart_IsNull(script_url)) { | 450 if (!Dart_IsNull(script_url)) { |
| 443 ASSERT(Dart_IsString(script_url)); | 451 ASSERT(Dart_IsString(script_url)); |
| 444 msg->Printf("\"location\": { \"url\":"); | 452 msg->Printf("\"location\": { \"url\":"); |
| 445 FormatEncodedString(msg, script_url); | 453 FormatEncodedString(msg, script_url); |
| 454 msg->Printf(",\"libraryId\": %"Pd",", library_id); |
| 446 msg->Printf(",\"tokenOffset\":%"Pd",", token_number); | 455 msg->Printf(",\"tokenOffset\":%"Pd",", token_number); |
| 447 msg->Printf("\"lineNumber\":%"Pd"},", line_number); | 456 msg->Printf("\"lineNumber\":%"Pd"},", line_number); |
| 448 } | 457 } |
| 449 | 458 |
| 450 Dart_Handle locals = Dart_GetLocalVariables(frame); | 459 Dart_Handle locals = Dart_GetLocalVariables(frame); |
| 451 ASSERT_NOT_ERROR(locals); | 460 ASSERT_NOT_ERROR(locals); |
| 452 msg->Printf("\"locals\":"); | 461 msg->Printf("\"locals\":"); |
| 453 FormatNamedValueList(msg, locals); | 462 FormatNamedValueList(msg, locals); |
| 454 msg->Printf("}"); | 463 msg->Printf("}"); |
| 455 } | 464 } |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1227 msg_queue->SendIsolateEvent(isolate_id, kind); | 1236 msg_queue->SendIsolateEvent(isolate_id, kind); |
| 1228 if (kind == kInterrupted) { | 1237 if (kind == kInterrupted) { |
| 1229 msg_queue->HandleMessages(); | 1238 msg_queue->HandleMessages(); |
| 1230 } else { | 1239 } else { |
| 1231 ASSERT(kind == kShutdown); | 1240 ASSERT(kind == kShutdown); |
| 1232 RemoveIsolateMsgQueue(isolate_id); | 1241 RemoveIsolateMsgQueue(isolate_id); |
| 1233 } | 1242 } |
| 1234 } | 1243 } |
| 1235 Dart_ExitScope(); | 1244 Dart_ExitScope(); |
| 1236 } | 1245 } |
| OLD | NEW |