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

Unified Diff: runtime/vm/trace_buffer.h

Issue 50413003: TraceBuffer implementation with tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 | « no previous file | runtime/vm/trace_buffer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/trace_buffer.h
diff --git a/runtime/vm/trace_buffer.h b/runtime/vm/trace_buffer.h
new file mode 100644
index 0000000000000000000000000000000000000000..f8b1c78de406e15451c8fb8cefbb36dcf68dd095
--- /dev/null
+++ b/runtime/vm/trace_buffer.h
@@ -0,0 +1,61 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#ifndef VM_TRACE_BUFFER_H_
+#define VM_TRACE_BUFFER_H_
+
+#include "platform/assert.h"
+#include "platform/globals.h"
+#include "vm/json_stream.h"
+
+namespace dart {
+
+class JSONStream;
+
+struct TraceBufferEntry {
+ int64_t micros;
+ char* message;
+ bool empty() const {
+ return message == NULL;
+ }
+};
+
+class TraceBuffer {
+ public:
+ static const intptr_t kDefaultCapacity = 1024;
+
+ explicit TraceBuffer(intptr_t capacity = kDefaultCapacity);
+ ~TraceBuffer();
+
+ void Clear();
+
+ // Internally message is copied.
+ void Trace(int64_t micros, const char* message);
+ // Internally message is copied.
+ void Trace(const char* message);
+ void TraceF(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
+
+ void PrintToJSONStream(JSONStream* stream) const;
+
+ private:
+ void Init();
+ void Cleanup();
+ void Fill(TraceBufferEntry* entry, int64_t micros, char* msg);
+ void AppendTrace(int64_t micros, char* message);
+
+ TraceBufferEntry* ring_;
+ const intptr_t ring_capacity_;
+ intptr_t ring_cursor_;
+
+ intptr_t RingIndex(intptr_t i) const {
+ return i % ring_capacity_;
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(TraceBuffer);
+};
+
+
+} // namespace dart
+
+#endif // VM_TRACE_BUFFER_H_
« no previous file with comments | « no previous file | runtime/vm/trace_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698