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

Side by Side Diff: runtime/vm/trace_buffer.h

Issue 328663008: Add support to trace warnings in TraceBuffer. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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
« no previous file with comments | « runtime/vm/parser.cc ('k') | runtime/vm/trace_buffer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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 #ifndef VM_TRACE_BUFFER_H_ 5 #ifndef VM_TRACE_BUFFER_H_
6 #define VM_TRACE_BUFFER_H_ 6 #define VM_TRACE_BUFFER_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "platform/globals.h" 9 #include "platform/globals.h"
10 #include "vm/json_stream.h" 10 #include "vm/json_stream.h"
11 11
12 namespace dart { 12 namespace dart {
13 13
14 class JSONStream; 14 class JSONStream;
15 class Script;
15 16
16 struct TraceBufferEntry { 17 struct TraceBufferEntry {
17 int64_t micros; 18 int64_t micros;
18 char* message; 19 char* message;
20 bool message_is_escaped;
19 bool empty() const { 21 bool empty() const {
20 return message == NULL; 22 return message == NULL;
21 } 23 }
22 }; 24 };
23 25
24 class TraceBuffer { 26 class TraceBuffer {
25 public: 27 public:
26 static const intptr_t kDefaultCapacity = 1024; 28 static const intptr_t kDefaultCapacity = 1024;
27 29
28 static void Init(Isolate* isolate, intptr_t capacity = kDefaultCapacity); 30 static void Init(Isolate* isolate, intptr_t capacity = kDefaultCapacity);
29 31
30 ~TraceBuffer(); 32 ~TraceBuffer();
31 33
32 void Clear(); 34 void Clear();
33 35
34 // Internally message is copied. 36 // Internally message is copied.
35 void Trace(int64_t micros, const char* message); 37 void Trace(int64_t micros, const char* msg, bool msg_is_escaped = false);
36 // Internally message is copied. 38 // Internally message is copied.
37 void Trace(const char* message); 39 void Trace(const char* msg, bool msg_is_escaped = false);
38 void TraceF(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); 40 void TraceF(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
39 41
40 void PrintToJSONStream(JSONStream* stream) const; 42 void PrintToJSONStream(JSONStream* stream) const;
41 43
44 // Accessors for testing.
45 TraceBufferEntry* At(intptr_t i) const { return &ring_[RingIndex(i)]; }
46 intptr_t Length() const { return ring_cursor_; }
47
42 private: 48 private:
43 TraceBuffer(Isolate* isolate, intptr_t capacity); 49 TraceBuffer(Isolate* isolate, intptr_t capacity);
44 void Cleanup(); 50 void Cleanup();
45 void Fill(TraceBufferEntry* entry, int64_t micros, char* msg); 51 void Fill(TraceBufferEntry* entry, int64_t micros,
46 void AppendTrace(int64_t micros, char* message); 52 char* msg, bool msg_is_escaped = false);
53 void AppendTrace(int64_t micros, char* msg, bool msg_is_escaped = false);
47 54
48 Isolate* isolate_; 55 Isolate* isolate_;
49 TraceBufferEntry* ring_; 56 TraceBufferEntry* ring_;
50 const intptr_t ring_capacity_; 57 const intptr_t ring_capacity_;
51 intptr_t ring_cursor_; 58 intptr_t ring_cursor_;
52 59
53 intptr_t RingIndex(intptr_t i) const { 60 intptr_t RingIndex(intptr_t i) const {
54 return i % ring_capacity_; 61 return i % ring_capacity_;
55 } 62 }
56 63
57 DISALLOW_COPY_AND_ASSIGN(TraceBuffer); 64 DISALLOW_COPY_AND_ASSIGN(TraceBuffer);
58 }; 65 };
59 66
60 67
61 } // namespace dart 68 } // namespace dart
62 69
63 #endif // VM_TRACE_BUFFER_H_ 70 #endif // VM_TRACE_BUFFER_H_
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | runtime/vm/trace_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698