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

Unified Diff: src/runtime.cc

Issue 48009: Add thread information to the debugger (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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 | « src/runtime.h ('k') | src/v8threads.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
===================================================================
--- src/runtime.cc (revision 1518)
+++ src/runtime.cc (working copy)
@@ -5771,6 +5771,78 @@
}
+static Object* Runtime_GetThreadCount(Arguments args) {
+ HandleScope scope;
+ ASSERT(args.length() == 1);
+
+ // Check arguments.
Erik Corry 2009/03/17 09:44:13 Wrong comment
Søren Thygesen Gjesse 2009/03/17 09:54:29 The comment is correct. All debugger runtime calls
+ Object* result = Runtime_CheckExecutionState(args);
+ if (result->IsFailure()) return result;
+
+ // Count all archived V8 threads.
+ int n = 0;
+ for (ThreadState* thread = ThreadState::FirstInUse();
+ thread != NULL;
+ thread = thread->Next()) {
+ n++;
+ }
+
+ // Total number of threads is current thread and archived threads.
+ return Smi::FromInt(n + 1);
+}
+
+
+static const int kThreadDetailsCurrentThreadIndex = 0;
+static const int kThreadDetailsThreadIdIndex = 1;
+static const int kThreadDetailsSize = 2;
+
+// Return an array with thread details
+// args[0]: number: break id
+// args[1]: number: thread index
+//
+// The array returned contains the following information:
+// 0: Is current thread?
+// 1: Thread id
+static Object* Runtime_GetThreadDetails(Arguments args) {
+ HandleScope scope;
+ ASSERT(args.length() == 2);
+
+ // Check arguments.
+ Object* check = Runtime_CheckExecutionState(args);
+ if (check->IsFailure()) return check;
+ CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]);
+
+ // Allocate array for result.
+ Handle<FixedArray> details = Factory::NewFixedArray(kThreadDetailsSize);
+
+ // Thread index 0 is current thread.
+ if (index == 0) {
+ // Fill the details.
+ details->set(kThreadDetailsCurrentThreadIndex, Heap::true_value());
+ details->set(kThreadDetailsThreadIdIndex,
+ Smi::FromInt(ThreadManager::CurrentId()));
+ } else {
+ // Find the thread with the requested index.
+ int n = 1;
+ ThreadState* thread = ThreadState::FirstInUse();
+ while (index != n && thread != NULL) {
+ thread = thread->Next();
+ n++;
+ }
+ if (thread == NULL) {
+ return Heap::undefined_value();
+ }
+
+ // Fill the details.
+ details->set(kThreadDetailsCurrentThreadIndex, Heap::false_value());
+ details->set(kThreadDetailsThreadIdIndex, Smi::FromInt(thread->id()));
+ }
+
+ // Convert to JS array and return.
+ return *Factory::NewJSArrayWithElements(details);
+}
+
+
static Object* Runtime_GetBreakLocations(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
« no previous file with comments | « src/runtime.h ('k') | src/v8threads.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698