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

Side by Side Diff: runtime/vm/debugger.cc

Issue 12221022: Initial prototype of vmstats support, based on Dart VM Stats draft design doc. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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
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 "vm/debugger.h" 5 #include "vm/debugger.h"
6 6
7 #include <string>
8
7 #include "include/dart_api.h" 9 #include "include/dart_api.h"
8 10
9 #include "vm/code_generator.h" 11 #include "vm/code_generator.h"
10 #include "vm/code_patcher.h" 12 #include "vm/code_patcher.h"
11 #include "vm/compiler.h" 13 #include "vm/compiler.h"
14 #include "vm/dart_api_impl.h"
12 #include "vm/dart_entry.h" 15 #include "vm/dart_entry.h"
13 #include "vm/flags.h" 16 #include "vm/flags.h"
14 #include "vm/globals.h" 17 #include "vm/globals.h"
18 #include "vm/isolate.h"
15 #include "vm/longjump.h" 19 #include "vm/longjump.h"
16 #include "vm/object.h" 20 #include "vm/object.h"
17 #include "vm/object_store.h" 21 #include "vm/object_store.h"
18 #include "vm/os.h" 22 #include "vm/os.h"
19 #include "vm/port.h" 23 #include "vm/port.h"
20 #include "vm/stack_frame.h" 24 #include "vm/stack_frame.h"
21 #include "vm/stub_code.h" 25 #include "vm/stub_code.h"
22 #include "vm/symbols.h" 26 #include "vm/symbols.h"
23 #include "vm/visitor.h" 27 #include "vm/visitor.h"
24 28
(...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 src_breakpoints_ = bpt; 1731 src_breakpoints_ = bpt;
1728 } 1732 }
1729 1733
1730 1734
1731 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 1735 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
1732 ASSERT(bpt->next() == NULL); 1736 ASSERT(bpt->next() == NULL);
1733 bpt->set_next(code_breakpoints_); 1737 bpt->set_next(code_breakpoints_);
1734 code_breakpoints_ = bpt; 1738 code_breakpoints_ = bpt;
1735 } 1739 }
1736 1740
1741
1742 // Global static pointer used to ensure a single instance of the class.
1743 VmStatusService* VmStatusService::instance_ = NULL;
1744
1745
1746 void VmStatusService::InitOnce() {
1747 VmStatusService::instance_ = new VmStatusService();
1748
1749 // Register built-in status plug-ins. RegisterPlugin is not used because
1750 // this isn't called within an isolate, and because parameter checking
1751 // isn't necessary.
1752 VmStatusService::instance_->service_map_["isolate"] = &Isolate::GetStatus;
1753
1754 // TODO(tball): dynamically load any additional plug-ins.
1755 }
1756
1757
1758 Dart_Handle VmStatusService::RegisterPlugin(
1759 const char* status_type, Dart_VmStatusCallback callback) {
siva 2013/02/11 19:14:55 Do you expect multiple threads to register plugins
1760 if (status_type == NULL) {
1761 return Api::NewError("status_type not specified");
1762 }
1763 if (callback == NULL) {
1764 return Api::NewError("callback not specified");
1765 }
1766 VmStatusService::instance_->service_map_[status_type] = callback;
1767 return Api::True(Isolate::Current());
1768 }
1769
1770
1771 char* VmStatusService::Dart_GetVmStatus(const char* request) {
1772 // Extract service type from beginning of string.
1773 char* start = const_cast<char*>(request);
1774 if (*start == '/') {
1775 start++;
1776 }
1777 size_t n = 0;
1778 while (*(start + n) != '\0' && *(start + n) != '/') {
1779 n++;
1780 }
1781 ASSERT(n != 0);
1782 char* status_type = strndup(start, n);
1783 ServiceMap* map = &VmStatusService::instance_->service_map_;
1784 ServiceMap::iterator itr = map->find(status_type);
1785 if (itr == map->end()) {
1786 return strdup(""); // No status available for this status type.
1787 }
1788 Dart_VmStatusCallback callback = itr->second;
1789 free(status_type);
1790 return (callback)(request);
1791 }
1792
1737 } // namespace dart 1793 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698