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

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

Issue 15507004: Let debug target pick the debugger port (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 | « runtime/bin/dbg_connection_macos.cc ('k') | tests/standalone/debugger/debug_lib.dart » ('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 <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "include/dart_debugger_api.h" 10 #include "include/dart_debugger_api.h"
(...skipping 29 matching lines...) Expand all
40 // free'd. 40 // free'd.
41 static const char* breakpoint_at = NULL; 41 static const char* breakpoint_at = NULL;
42 42
43 43
44 // Global state that indicates whether we should open a connection 44 // Global state that indicates whether we should open a connection
45 // and listen for a debugger to connect. 45 // and listen for a debugger to connect.
46 static bool start_debugger = false; 46 static bool start_debugger = false;
47 static const int DEFAULT_DEBUG_PORT = 5858; 47 static const int DEFAULT_DEBUG_PORT = 5858;
48 static const char* DEFAULT_DEBUG_IP = "127.0.0.1"; 48 static const char* DEFAULT_DEBUG_IP = "127.0.0.1";
49 static const char* debug_ip = DEFAULT_DEBUG_IP; 49 static const char* debug_ip = DEFAULT_DEBUG_IP;
50 static int debug_port = 0; 50 static int debug_port = -1;
51 51
52 // Global state that defines the VmStats web server port and root directory. 52 // Global state that defines the VmStats web server port and root directory.
53 static int vmstats_port = -1; 53 static int vmstats_port = -1;
54 static const char* vmstats_root = ""; 54 static const char* vmstats_root = "";
55 55
56 // Value of the --package-root flag. 56 // Value of the --package-root flag.
57 // (This pointer points into an argv buffer and does not need to be 57 // (This pointer points into an argv buffer and does not need to be
58 // free'd.) 58 // free'd.)
59 static const char* package_root = NULL; 59 static const char* package_root = NULL;
60 60
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 141 }
142 has_check_function_fingerprints = true; 142 has_check_function_fingerprints = true;
143 return true; 143 return true;
144 } 144 }
145 145
146 146
147 static bool ProcessDebugOption(const char* port) { 147 static bool ProcessDebugOption(const char* port) {
148 // TODO(hausner): Add support for specifying an IP address on which 148 // TODO(hausner): Add support for specifying an IP address on which
149 // the debugger should listen. 149 // the debugger should listen.
150 ASSERT(port != NULL); 150 ASSERT(port != NULL);
151 debug_port = 0; 151 debug_port = -1;
152 if (*port == '\0') { 152 if (*port == '\0') {
153 debug_port = DEFAULT_DEBUG_PORT; 153 debug_port = DEFAULT_DEBUG_PORT;
154 } else { 154 } else {
155 if ((*port == '=') || (*port == ':')) { 155 if ((*port == '=') || (*port == ':')) {
156 debug_port = atoi(port + 1); 156 debug_port = atoi(port + 1);
157 } 157 }
158 } 158 }
159 if (debug_port == 0) { 159 if (debug_port < 0) {
160 Log::PrintErr("unrecognized --debug option syntax. " 160 Log::PrintErr("unrecognized --debug option syntax. "
161 "Use --debug[:<port number>]\n"); 161 "Use --debug[:<port number>]\n");
162 return false; 162 return false;
163 } 163 }
164 breakpoint_at = "main"; 164 breakpoint_at = "main";
165 start_debugger = true; 165 start_debugger = true;
166 return true; 166 return true;
167 } 167 }
168 168
169 169
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 DartUtils::CloseFile)) { 718 DartUtils::CloseFile)) {
719 fprintf(stderr, "%s", "VM initialization failed\n"); 719 fprintf(stderr, "%s", "VM initialization failed\n");
720 fflush(stderr); 720 fflush(stderr);
721 return kErrorExitCode; 721 return kErrorExitCode;
722 } 722 }
723 723
724 DartUtils::SetOriginalWorkingDirectory(); 724 DartUtils::SetOriginalWorkingDirectory();
725 725
726 // Start the debugger wire protocol handler if necessary. 726 // Start the debugger wire protocol handler if necessary.
727 if (start_debugger) { 727 if (start_debugger) {
728 ASSERT(debug_port != 0); 728 ASSERT(debug_port >= 0);
729 DebuggerConnectionHandler::StartHandler(debug_ip, debug_port); 729 bool print_msg = verbose_debug_seen || (debug_port == 0);
730 if (verbose_debug_seen) { 730 debug_port = DebuggerConnectionHandler::StartHandler(debug_ip, debug_port);
731 Log::Print("Debugger initialized\n"); 731 if (print_msg) {
732 Log::Print("Debugger listening on port %d\n", debug_port);
732 } 733 }
733 } 734 }
734 VmStats::Start(vmstats_port, vmstats_root, verbose_debug_seen); 735 VmStats::Start(vmstats_port, vmstats_root, verbose_debug_seen);
735 736
736 // Call CreateIsolateAndSetup which creates an isolate and loads up 737 // Call CreateIsolateAndSetup which creates an isolate and loads up
737 // the specified application script. 738 // the specified application script.
738 char* error = NULL; 739 char* error = NULL;
739 char* isolate_name = BuildIsolateName(script_name, "main"); 740 char* isolate_name = BuildIsolateName(script_name, "main");
740 Dart_Isolate isolate = CreateIsolateAndSetupHelper(script_name, 741 Dart_Isolate isolate = CreateIsolateAndSetupHelper(script_name,
741 "main", 742 "main",
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 848
848 return Process::GlobalExitCode(); 849 return Process::GlobalExitCode();
849 } 850 }
850 851
851 } // namespace bin 852 } // namespace bin
852 } // namespace dart 853 } // namespace dart
853 854
854 int main(int argc, char** argv) { 855 int main(int argc, char** argv) {
855 return dart::bin::main(argc, argv); 856 return dart::bin::main(argc, argv);
856 } 857 }
OLDNEW
« no previous file with comments | « runtime/bin/dbg_connection_macos.cc ('k') | tests/standalone/debugger/debug_lib.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698