Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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/log.h" | 5 #include "vm/log.h" |
| 6 | 6 |
| 7 #include "vm/flags.h" | 7 #include "vm/flags.h" |
| 8 #include "vm/thread.h" | 8 #include "vm/thread.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 if (buffer_.is_empty()) { | 68 if (buffer_.is_empty()) { |
| 69 return; | 69 return; |
| 70 } | 70 } |
| 71 if (buffer_.length() <= cursor) { | 71 if (buffer_.length() <= cursor) { |
| 72 return; | 72 return; |
| 73 } | 73 } |
| 74 TerminateString(); | 74 TerminateString(); |
| 75 const char* str = &buffer_[cursor]; | 75 const char* str = &buffer_[cursor]; |
| 76 ASSERT(str != NULL); | 76 ASSERT(str != NULL); |
| 77 printer_("%s", str); | 77 printer_("%s", str); |
| 78 buffer_.TruncateTo(cursor); | 78 buffer_.TruncateTo(cursor); |
|
Ivan Posva
2015/09/08 21:22:21
As far as I can tell this is broken as the string
koda
2015/09/09 00:26:57
The design does *not* assume buffer_ is '\0'-termi
Ivan Posva
2015/09/09 19:56:24
Thanks for pointing that out. Sneaky!
koda
2015/09/09 22:22:57
Acknowledged.
| |
| 79 } | 79 } |
| 80 | 80 |
| 81 | 81 |
| 82 void Log::Clear() { | 82 void Log::Clear() { |
| 83 if (this == NoOpLog()) { | 83 if (this == NoOpLog()) { |
| 84 return; | 84 return; |
| 85 } | 85 } |
| 86 buffer_.TruncateTo(0); | 86 buffer_.TruncateTo(0); |
| 87 } | 87 } |
| 88 | 88 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 110 | 110 |
| 111 void Log::DisableManualFlush() { | 111 void Log::DisableManualFlush() { |
| 112 manual_flush_--; | 112 manual_flush_--; |
| 113 ASSERT(manual_flush_ >= 0); | 113 ASSERT(manual_flush_ >= 0); |
| 114 if (manual_flush_ == 0) { | 114 if (manual_flush_ == 0) { |
| 115 Flush(); | 115 Flush(); |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 | 119 |
| 120 LogBlock::LogBlock(Thread* thread, Log* log) | |
| 121 : StackResource(thread), | |
| 122 log_(log), cursor_(log->cursor()) { | |
| 123 CommonConstructor(); | |
| 124 } | |
| 125 | |
| 126 | |
| 127 LogBlock::LogBlock(Isolate* isolate) | |
| 128 : StackResource(isolate), | |
| 129 log_(isolate->Log()), cursor_(isolate->Log()->cursor()) { | |
| 130 CommonConstructor(); | |
| 131 } | |
| 132 | |
| 133 | |
| 134 LogBlock::LogBlock(Thread* thread) | 120 LogBlock::LogBlock(Thread* thread) |
| 135 : StackResource(thread), | 121 : StackResource(thread), |
| 136 log_(thread->isolate()->Log()), | 122 log_(thread->Log()), |
| 137 cursor_(thread->isolate()->Log()->cursor()) { | 123 cursor_(thread->Log()->cursor()) { |
| 138 CommonConstructor(); | 124 CommonConstructor(); |
|
Ivan Posva
2015/09/08 21:22:21
How about changing CommonConstructor() to Initiali
koda
2015/09/09 00:26:57
Done (although it prevents the cursor_ field from
Ivan Posva
2015/09/09 19:56:24
Actually, I am fine with duplicating the code and
koda
2015/09/09 22:22:57
Done.
| |
| 139 } | 125 } |
| 140 | 126 |
| 141 } // namespace dart | 127 } // namespace dart |
| OLD | NEW |