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

Unified Diff: runtime/vm/isolate.cc

Issue 9242035: Give isolates names to be used during debugging. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/isolate.cc
===================================================================
--- runtime/vm/isolate.cc (revision 3366)
+++ runtime/vm/isolate.cc (working copy)
@@ -28,7 +28,9 @@
namespace dart {
DEFINE_FLAG(bool, report_invocation_count, false,
- "Count function invocations and report.");
+ "Count function invocations and report.");
+DEFINE_FLAG(bool, trace_isolates, false,
+ "Trace isolate creation and shut down.");
DECLARE_FLAG(bool, generate_gdb_symbols);
@@ -37,6 +39,7 @@
message_queue_(NULL),
post_message_callback_(NULL),
close_port_callback_(NULL),
+ name_(NULL),
num_ports_(0),
live_ports_(0),
main_port_(0),
@@ -69,6 +72,7 @@
Isolate::~Isolate() {
+ delete [] name_;
delete message_queue_;
delete heap_;
delete object_store_;
@@ -107,7 +111,7 @@
}
-Isolate* Isolate::Init() {
+Isolate* Isolate::Init(const char* name_prefix) {
Isolate* result = new Isolate();
ASSERT(result != NULL);
@@ -133,14 +137,32 @@
// main thread.
result->SetStackLimitFromCurrentTOS(reinterpret_cast<uword>(&result));
result->set_main_port(PortMap::CreatePort());
+ result->BuildName(name_prefix);
result->debugger_ = new Debugger();
result->debugger_->Initialize(result);
-
+ if (FLAG_trace_isolates) {
+ if (strcmp(name_prefix, "vm-isolate") != 0) {
+ OS::Print("[+] Starting isolate:\n"
+ "\tisolate: %s\n", result->name());
+ }
+ }
return result;
}
+void Isolate::BuildName(const char* name_prefix) {
+ ASSERT(name_ == NULL);
+ if (name_prefix == NULL) {
+ name_prefix = "isolate";
+ }
+ const char* kFormat = "%s-%lld";
+ intptr_t len = OS::SNPrint(NULL, 0, kFormat, name_prefix, main_port()) + 1;
+ name_ = new char[len];
+ OS::SNPrint(name_, len, kFormat, name_prefix, main_port());
+}
+
+
// TODO(5411455): Use flag to override default value and Validate the
// stack size by querying OS.
uword Isolate::GetSpecifiedStackSize() {
@@ -256,7 +278,10 @@
if (FLAG_generate_gdb_symbols) {
DebugInfo::UnregisterAllSections();
}
-
+ if (FLAG_trace_isolates) {
+ OS::Print("[-] Stopping isolate:\n"
+ "\tisolate: %s\n", name());
+ }
// TODO(5411455): For now just make sure there are no current isolates
// as we are shutting down the isolate.
SetCurrent(NULL);

Powered by Google App Engine
This is Rietveld 408576698