Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 #ifndef VM_TRACE_BUFFER_H_ | |
| 6 #define VM_TRACE_BUFFER_H_ | |
| 7 | |
| 8 #include "platform/assert.h" | |
| 9 #include "platform/globals.h" | |
| 10 #include "vm/json_stream.h" | |
| 11 | |
| 12 namespace dart { | |
| 13 | |
| 14 class JSONStream; | |
| 15 | |
| 16 struct TraceBufferEntry { | |
| 17 double seconds; | |
| 18 char* message; | |
| 19 }; | |
| 20 | |
| 21 class TraceBuffer { | |
| 22 public: | |
| 23 static const intptr_t kDefaultCapacity = 1024; | |
| 24 | |
| 25 explicit TraceBuffer(intptr_t capacity = kDefaultCapacity); | |
| 26 ~TraceBuffer(); | |
| 27 | |
| 28 void Clear(); | |
| 29 | |
| 30 // Internally message is copied. | |
| 31 void Trace(int64_t time, const char* message); | |
| 32 // Internally message is copied. | |
| 33 void Trace(const char* message); | |
| 34 void TraceF(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); | |
| 35 | |
| 36 void PrintToJSONStream(JSONStream* stream) const; | |
| 37 | |
| 38 private: | |
| 39 void Init(); | |
| 40 void Cleanup(); | |
| 41 void Fill(TraceBufferEntry* entry, double seconds, char* msg); | |
| 42 void AppendTrace(int64_t time, char* message); | |
| 43 | |
| 44 TraceBufferEntry* ring_; | |
| 45 intptr_t ring_capacity_; | |
|
srdjan
2013/11/07 22:53:00
const?
Cutch
2013/11/13 17:33:14
Done.
| |
| 46 intptr_t ring_start_; | |
|
Ivan Posva
2013/11/07 22:36:28
Single index should suffice.
Cutch
2013/11/13 17:33:14
Done.
| |
| 47 intptr_t ring_size_; | |
| 48 | |
| 49 intptr_t RingIndex(intptr_t i) const { | |
| 50 return i % ring_capacity_; | |
| 51 } | |
| 52 | |
| 53 DISALLOW_COPY_AND_ASSIGN(TraceBuffer); | |
| 54 }; | |
| 55 | |
| 56 | |
| 57 } // namespace dart | |
| 58 | |
| 59 #endif // VM_TRACE_BUFFER_H_ | |
| OLD | NEW |