OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 static void Close(); | 107 static void Close(); |
108 | 108 |
109 // See description in include/v8.h. | 109 // See description in include/v8.h. |
110 static int GetLogLines(int from_pos, char* dest_buf, int max_size); | 110 static int GetLogLines(int from_pos, char* dest_buf, int max_size); |
111 | 111 |
112 // Returns whether logging is enabled. | 112 // Returns whether logging is enabled. |
113 static bool IsEnabled() { | 113 static bool IsEnabled() { |
114 return !is_stopped_ && (output_handle_ != NULL || output_buffer_ != NULL); | 114 return !is_stopped_ && (output_handle_ != NULL || output_buffer_ != NULL); |
115 } | 115 } |
116 | 116 |
| 117 // Size of buffer used for formatting log messages. |
| 118 static const int kMessageBufferSize = 2048; |
| 119 |
117 private: | 120 private: |
118 typedef int (*WritePtr)(const char* msg, int length); | 121 typedef int (*WritePtr)(const char* msg, int length); |
119 | 122 |
120 // Initialization function called from Open... functions. | 123 // Initialization function called from Open... functions. |
121 static void Init(); | 124 static void Init(); |
122 | 125 |
123 // Write functions assume that mutex_ is acquired by the caller. | 126 // Write functions assume that mutex_ is acquired by the caller. |
124 static WritePtr Write; | 127 static WritePtr Write; |
125 | 128 |
126 // Implementation of writing to a log file. | 129 // Implementation of writing to a log file. |
(...skipping 28 matching lines...) Expand all Loading... |
155 // Maximum size of dynamic buffer. | 158 // Maximum size of dynamic buffer. |
156 static const int kMaxDynamicBufferSize = 50 * 1024 * 1024; | 159 static const int kMaxDynamicBufferSize = 50 * 1024 * 1024; |
157 | 160 |
158 // Message to "seal" dynamic buffer with. | 161 // Message to "seal" dynamic buffer with. |
159 static const char* kDynamicBufferSeal; | 162 static const char* kDynamicBufferSeal; |
160 | 163 |
161 // mutex_ is a Mutex used for enforcing exclusive | 164 // mutex_ is a Mutex used for enforcing exclusive |
162 // access to the formatting buffer and the log file or log memory buffer. | 165 // access to the formatting buffer and the log file or log memory buffer. |
163 static Mutex* mutex_; | 166 static Mutex* mutex_; |
164 | 167 |
165 // Size of buffer used for formatting log messages. | |
166 static const int kMessageBufferSize = 2048; | |
167 | |
168 // Buffer used for formatting log messages. This is a singleton buffer and | 168 // Buffer used for formatting log messages. This is a singleton buffer and |
169 // mutex_ should be acquired before using it. | 169 // mutex_ should be acquired before using it. |
170 static char* message_buffer_; | 170 static char* message_buffer_; |
171 | 171 |
172 friend class LogMessageBuilder; | 172 friend class LogMessageBuilder; |
173 friend class LogRecordCompressor; | 173 friend class LogRecordCompressor; |
174 }; | 174 }; |
175 | 175 |
176 | 176 |
177 // An utility class for performing backward reference compression | 177 // An utility class for performing backward reference compression |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 240 |
241 // Appends an address, compressing it if needed by offsetting | 241 // Appends an address, compressing it if needed by offsetting |
242 // from Logger::last_address_. | 242 // from Logger::last_address_. |
243 void AppendAddress(Address addr); | 243 void AppendAddress(Address addr); |
244 | 244 |
245 // Appends an address, compressing it if needed. | 245 // Appends an address, compressing it if needed. |
246 void AppendAddress(Address addr, Address bias); | 246 void AppendAddress(Address addr, Address bias); |
247 | 247 |
248 void AppendDetailed(String* str, bool show_impl_info); | 248 void AppendDetailed(String* str, bool show_impl_info); |
249 | 249 |
| 250 // Append a portion of a string. |
| 251 void AppendStringPart(const char* str, int len); |
| 252 |
250 // Stores log message into compressor, returns true if the message | 253 // Stores log message into compressor, returns true if the message |
251 // was stored (i.e. doesn't repeat the previous one). | 254 // was stored (i.e. doesn't repeat the previous one). |
252 bool StoreInCompressor(LogRecordCompressor* compressor); | 255 bool StoreInCompressor(LogRecordCompressor* compressor); |
253 | 256 |
254 // Sets log message to a previous version of compressed message. | 257 // Sets log message to a previous version of compressed message. |
255 // Returns false, if there is no previous message. | 258 // Returns false, if there is no previous message. |
256 bool RetrieveCompressedPrevious(LogRecordCompressor* compressor) { | 259 bool RetrieveCompressedPrevious(LogRecordCompressor* compressor) { |
257 return RetrieveCompressedPrevious(compressor, ""); | 260 return RetrieveCompressedPrevious(compressor, ""); |
258 } | 261 } |
259 | 262 |
(...skipping 19 matching lines...) Expand all Loading... |
279 | 282 |
280 ScopedLock sl; | 283 ScopedLock sl; |
281 int pos_; | 284 int pos_; |
282 }; | 285 }; |
283 | 286 |
284 #endif // ENABLE_LOGGING_AND_PROFILING | 287 #endif // ENABLE_LOGGING_AND_PROFILING |
285 | 288 |
286 } } // namespace v8::internal | 289 } } // namespace v8::internal |
287 | 290 |
288 #endif // V8_LOG_UTILS_H_ | 291 #endif // V8_LOG_UTILS_H_ |
OLD | NEW |