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

Side by Side Diff: runtime/bin/dbg_connection.cc

Issue 10869063: Add attributions so printf like functions can have their arguments checked. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebased Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/bin/eventhandler_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/dartutils.h" 6 #include "bin/dartutils.h"
7 #include "bin/socket.h" 7 #include "bin/socket.h"
8 #include "bin/thread.h" 8 #include "bin/thread.h"
9 #include "bin/utils.h" 9 #include "bin/utils.h"
10 10
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 if (Dart_IsInteger(object)) { 450 if (Dart_IsInteger(object)) {
451 buf->Printf("\"kind\":\"integer\","); 451 buf->Printf("\"kind\":\"integer\",");
452 } else if (Dart_IsString(object)) { 452 } else if (Dart_IsString(object)) {
453 buf->Printf("\"kind\":\"string\","); 453 buf->Printf("\"kind\":\"string\",");
454 } else if (Dart_IsBoolean(object)) { 454 } else if (Dart_IsBoolean(object)) {
455 buf->Printf("\"kind\":\"boolean\","); 455 buf->Printf("\"kind\":\"boolean\",");
456 } else if (Dart_IsList(object)) { 456 } else if (Dart_IsList(object)) {
457 intptr_t len = 0; 457 intptr_t len = 0;
458 Dart_Handle res = Dart_ListLength(object, &len); 458 Dart_Handle res = Dart_ListLength(object, &len);
459 ASSERT_NOT_ERROR(res); 459 ASSERT_NOT_ERROR(res);
460 buf->Printf("\"kind\":\"list\",\"length\":%d,", len); 460 buf->Printf("\"kind\":\"list\",\"length\":%"Pd",", len);
461 } else { 461 } else {
462 buf->Printf("\"kind\":\"object\","); 462 buf->Printf("\"kind\":\"object\",");
463 } 463 }
464 FormatTextualValue(buf, object); 464 FormatTextualValue(buf, object);
465 } 465 }
466 466
467 467
468 static void FormatValueObj(dart::TextBuffer* buf, Dart_Handle object) { 468 static void FormatValueObj(dart::TextBuffer* buf, Dart_Handle object) {
469 buf->Printf("{"); 469 buf->Printf("{");
470 FormatValue(buf, object); 470 FormatValue(buf, object);
471 buf->Printf("}"); 471 buf->Printf("}");
472 } 472 }
473 473
474 474
475 static void FormatRemoteObj(dart::TextBuffer* buf, Dart_Handle object) { 475 static void FormatRemoteObj(dart::TextBuffer* buf, Dart_Handle object) {
476 intptr_t obj_id = Dart_CacheObject(object); 476 intptr_t obj_id = Dart_CacheObject(object);
477 ASSERT(obj_id >= 0); 477 ASSERT(obj_id >= 0);
478 buf->Printf("{\"objectId\":%d,", obj_id); 478 buf->Printf("{\"objectId\":%"Pd",", obj_id);
479 FormatValue(buf, object); 479 FormatValue(buf, object);
480 buf->Printf("}"); 480 buf->Printf("}");
481 } 481 }
482 482
483 483
484 static void FormatNamedValue(dart::TextBuffer* buf, 484 static void FormatNamedValue(dart::TextBuffer* buf,
485 Dart_Handle object_name, 485 Dart_Handle object_name,
486 Dart_Handle object) { 486 Dart_Handle object) {
487 ASSERT(Dart_IsString(object_name)); 487 ASSERT(Dart_IsString(object_name));
488 buf->Printf("{\"name\":\"%s\",", GetStringChars(object_name)); 488 buf->Printf("{\"name\":\"%s\",", GetStringChars(object_name));
(...skipping 29 matching lines...) Expand all
518 intptr_t cls_id) { 518 intptr_t cls_id) {
519 Dart_Handle name, static_fields; 519 Dart_Handle name, static_fields;
520 intptr_t super_id = -1; 520 intptr_t super_id = -1;
521 intptr_t library_id = -1; 521 intptr_t library_id = -1;
522 Dart_Handle res = 522 Dart_Handle res =
523 Dart_GetClassInfo(cls_id, &name, &library_id, &super_id, &static_fields); 523 Dart_GetClassInfo(cls_id, &name, &library_id, &super_id, &static_fields);
524 RETURN_IF_ERROR(res); 524 RETURN_IF_ERROR(res);
525 RETURN_IF_ERROR(name); 525 RETURN_IF_ERROR(name);
526 buf->Printf("{\"name\":\"%s\",", GetStringChars(name)); 526 buf->Printf("{\"name\":\"%s\",", GetStringChars(name));
527 if (super_id > 0) { 527 if (super_id > 0) {
528 buf->Printf("\"superclassId\":%d,", super_id); 528 buf->Printf("\"superclassId\":%"Pd",", super_id);
529 } 529 }
530 buf->Printf("\"libraryId\":%d,", library_id); 530 buf->Printf("\"libraryId\":%"Pd",", library_id);
531 RETURN_IF_ERROR(static_fields); 531 RETURN_IF_ERROR(static_fields);
532 buf->Printf("\"fields\":"); 532 buf->Printf("\"fields\":");
533 FormatNamedValueList(buf, static_fields); 533 FormatNamedValueList(buf, static_fields);
534 buf->Printf("}"); 534 buf->Printf("}");
535 return NULL; 535 return NULL;
536 } 536 }
537 537
538 538
539 static const char* FormatLibraryProps(dart::TextBuffer* buf, 539 static const char* FormatLibraryProps(dart::TextBuffer* buf,
540 intptr_t lib_id) { 540 intptr_t lib_id) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 584
585 static const char* FormatObjProps(dart::TextBuffer* buf, 585 static const char* FormatObjProps(dart::TextBuffer* buf,
586 Dart_Handle object) { 586 Dart_Handle object) {
587 intptr_t class_id; 587 intptr_t class_id;
588 if (Dart_IsNull(object)) { 588 if (Dart_IsNull(object)) {
589 buf->Printf("{\"classId\":-1,\"fields\":[]}"); 589 buf->Printf("{\"classId\":-1,\"fields\":[]}");
590 return NULL; 590 return NULL;
591 } 591 }
592 Dart_Handle res = Dart_GetObjClassId(object, &class_id); 592 Dart_Handle res = Dart_GetObjClassId(object, &class_id);
593 RETURN_IF_ERROR(res); 593 RETURN_IF_ERROR(res);
594 buf->Printf("{\"classId\": %d,", class_id); 594 buf->Printf("{\"classId\": %"Pd",", class_id);
595 buf->Printf("\"kind\":\"object\",\"fields\":"); 595 buf->Printf("\"kind\":\"object\",\"fields\":");
596 Dart_Handle fields = Dart_GetInstanceFields(object); 596 Dart_Handle fields = Dart_GetInstanceFields(object);
597 RETURN_IF_ERROR(fields); 597 RETURN_IF_ERROR(fields);
598 FormatNamedValueList(buf, fields); 598 FormatNamedValueList(buf, fields);
599 buf->Printf("}"); 599 buf->Printf("}");
600 return NULL; 600 return NULL;
601 } 601 }
602 602
603 603
604 static const char* FormatListSlice(dart::TextBuffer* buf, 604 static const char* FormatListSlice(dart::TextBuffer* buf,
605 Dart_Handle list, 605 Dart_Handle list,
606 intptr_t list_length, 606 intptr_t list_length,
607 intptr_t index, 607 intptr_t index,
608 intptr_t slice_length) { 608 intptr_t slice_length) {
609 intptr_t end_index = index + slice_length; 609 intptr_t end_index = index + slice_length;
610 ASSERT(end_index <= list_length); 610 ASSERT(end_index <= list_length);
611 buf->Printf("{\"index\":%d,", index); 611 buf->Printf("{\"index\":%"Pd",", index);
612 buf->Printf("\"length\":%d,", slice_length); 612 buf->Printf("\"length\":%"Pd",", slice_length);
613 buf->Printf("\"elements\":["); 613 buf->Printf("\"elements\":[");
614 for (intptr_t i = index; i < end_index; i++) { 614 for (intptr_t i = index; i < end_index; i++) {
615 Dart_Handle value = Dart_ListGetAt(list, i); 615 Dart_Handle value = Dart_ListGetAt(list, i);
616 if (i > index) { 616 if (i > index) {
617 buf->Printf(","); 617 buf->Printf(",");
618 } 618 }
619 FormatValueObj(buf, value); 619 FormatValueObj(buf, value);
620 } 620 }
621 buf->Printf("]}"); 621 buf->Printf("]}");
622 return NULL; 622 return NULL;
(...skipping 12 matching lines...) Expand all
635 Dart_Handle func_name; 635 Dart_Handle func_name;
636 Dart_Handle script_url; 636 Dart_Handle script_url;
637 intptr_t line_number = 0; 637 intptr_t line_number = 0;
638 intptr_t library_id = 0; 638 intptr_t library_id = 0;
639 res = Dart_ActivationFrameInfo( 639 res = Dart_ActivationFrameInfo(
640 frame, &func_name, &script_url, &line_number, &library_id); 640 frame, &func_name, &script_url, &line_number, &library_id);
641 ASSERT_NOT_ERROR(res); 641 ASSERT_NOT_ERROR(res);
642 ASSERT(Dart_IsString(func_name)); 642 ASSERT(Dart_IsString(func_name));
643 msg->Printf("%s{\"functionName\":", (i > 0) ? "," : ""); 643 msg->Printf("%s{\"functionName\":", (i > 0) ? "," : "");
644 FormatEncodedString(msg, func_name); 644 FormatEncodedString(msg, func_name);
645 msg->Printf(",\"libraryId\": %d,", library_id); 645 msg->Printf(",\"libraryId\": %"Pd",", library_id);
646 646
647 ASSERT(Dart_IsString(script_url)); 647 ASSERT(Dart_IsString(script_url));
648 msg->Printf("\"location\": { \"url\":"); 648 msg->Printf("\"location\": { \"url\":");
649 FormatEncodedString(msg, script_url); 649 FormatEncodedString(msg, script_url);
650 msg->Printf(",\"lineNumber\":%d},", line_number); 650 msg->Printf(",\"lineNumber\":%"Pd"},", line_number);
651 651
652 Dart_Handle locals = Dart_GetLocalVariables(frame); 652 Dart_Handle locals = Dart_GetLocalVariables(frame);
653 ASSERT_NOT_ERROR(locals); 653 ASSERT_NOT_ERROR(locals);
654 msg->Printf("\"locals\":"); 654 msg->Printf("\"locals\":");
655 FormatNamedValueList(msg, locals); 655 FormatNamedValueList(msg, locals);
656 msg->Printf("}"); 656 msg->Printf("}");
657 } 657 }
658 msg->Printf("]"); 658 msg->Printf("]");
659 } 659 }
660 660
(...skipping 23 matching lines...) Expand all
684 Dart_Handle bp_id = Dart_SetBreakpoint(url, line_number); 684 Dart_Handle bp_id = Dart_SetBreakpoint(url, line_number);
685 if (Dart_IsError(bp_id)) { 685 if (Dart_IsError(bp_id)) {
686 SendError(msg_id, Dart_GetError(bp_id)); 686 SendError(msg_id, Dart_GetError(bp_id));
687 return; 687 return;
688 } 688 }
689 ASSERT(Dart_IsInteger(bp_id)); 689 ASSERT(Dart_IsInteger(bp_id));
690 uint64_t bp_id_value; 690 uint64_t bp_id_value;
691 Dart_Handle res = Dart_IntegerToUint64(bp_id, &bp_id_value); 691 Dart_Handle res = Dart_IntegerToUint64(bp_id, &bp_id_value);
692 ASSERT_NOT_ERROR(res); 692 ASSERT_NOT_ERROR(res);
693 dart::TextBuffer msg(64); 693 dart::TextBuffer msg(64);
694 msg.Printf("{ \"id\": %d, \"result\": { \"breakpointId\": %d }}", 694 msg.Printf("{ \"id\": %d, \"result\": { \"breakpointId\": %"Pu64" }}",
695 msg_id, bp_id_value); 695 msg_id, bp_id_value);
696 SendMsg(&msg); 696 SendMsg(&msg);
697 } 697 }
698 698
699 699
700 void DebuggerConnectionHandler::HandlePauseOnExcCmd(const char* json_msg) { 700 void DebuggerConnectionHandler::HandlePauseOnExcCmd(const char* json_msg) {
701 int msg_id = msgbuf_->MessageId(); 701 int msg_id = msgbuf_->MessageId();
702 char* exc_chars = msgbuf_->GetStringParam("exceptions"); 702 char* exc_chars = msgbuf_->GetStringParam("exceptions");
703 Dart_ExceptionPauseInfo info = kNoPauseOnExceptions; 703 Dart_ExceptionPauseInfo info = kNoPauseOnExceptions;
704 if (strcmp(exc_chars, "none") == 0) { 704 if (strcmp(exc_chars, "none") == 0) {
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 Dart_ExitScope(); 1015 Dart_ExitScope();
1016 } 1016 }
1017 1017
1018 1018
1019 void DebuggerConnectionHandler::BptResolvedHandler(intptr_t bp_id, 1019 void DebuggerConnectionHandler::BptResolvedHandler(intptr_t bp_id,
1020 Dart_Handle url, 1020 Dart_Handle url,
1021 intptr_t line_number) { 1021 intptr_t line_number) {
1022 Dart_EnterScope(); 1022 Dart_EnterScope();
1023 dart::TextBuffer msg(128); 1023 dart::TextBuffer msg(128);
1024 msg.Printf("{ \"event\": \"breakpointResolved\", \"params\": {"); 1024 msg.Printf("{ \"event\": \"breakpointResolved\", \"params\": {");
1025 msg.Printf("\"breakpointId\": %d, \"url\":", bp_id); 1025 msg.Printf("\"breakpointId\": %"Pd", \"url\":", bp_id);
1026 FormatEncodedString(&msg, url); 1026 FormatEncodedString(&msg, url);
1027 msg.Printf(",\"line\": %d }}", line_number); 1027 msg.Printf(",\"line\": %"Pd" }}", line_number);
1028 QueueMsg(&msg); 1028 QueueMsg(&msg);
1029 Dart_ExitScope(); 1029 Dart_ExitScope();
1030 } 1030 }
1031 1031
1032 1032
1033 void DebuggerConnectionHandler::AcceptDbgConnection(int debugger_fd) { 1033 void DebuggerConnectionHandler::AcceptDbgConnection(int debugger_fd) {
1034 debugger_fd_ = debugger_fd; 1034 debugger_fd_ = debugger_fd;
1035 ASSERT(msgbuf_ == NULL); 1035 ASSERT(msgbuf_ == NULL);
1036 msgbuf_ = new MessageBuffer(debugger_fd_); 1036 msgbuf_ = new MessageBuffer(debugger_fd_);
1037 { 1037 {
(...skipping 28 matching lines...) Expand all
1066 DebuggerConnectionImpl::StartHandler(port_number); 1066 DebuggerConnectionImpl::StartHandler(port_number);
1067 Dart_SetBreakpointHandler(BreakpointHandler); 1067 Dart_SetBreakpointHandler(BreakpointHandler);
1068 Dart_SetBreakpointResolvedHandler(BptResolvedHandler); 1068 Dart_SetBreakpointResolvedHandler(BptResolvedHandler);
1069 Dart_SetExceptionThrownHandler(ExceptionThrownHandler); 1069 Dart_SetExceptionThrownHandler(ExceptionThrownHandler);
1070 } 1070 }
1071 1071
1072 1072
1073 DebuggerConnectionHandler::~DebuggerConnectionHandler() { 1073 DebuggerConnectionHandler::~DebuggerConnectionHandler() {
1074 CloseDbgConnection(); 1074 CloseDbgConnection();
1075 } 1075 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/eventhandler_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698