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

Unified Diff: src/log.cc

Issue 56064: Fixed numerous issues that were causing errors in profiler log processing (Closed)
Patch Set: Updated according to Soeren's comments Created 11 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/log.h ('k') | src/platform.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/log.cc
diff --git a/src/log.cc b/src/log.cc
index f3a0e8d74ac9727a670f7c1a950121a661d23153..d9e304d606ce61a9289f1bb8f38f22d6426633dd 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -299,6 +299,7 @@ class LogMessageBuilder BASE_EMBEDDED {
void AppendDetailed(String* str, bool show_impl_info);
void WriteToLogFile();
+ void WriteCStringToLogFile(const char* str);
private:
ScopedLock sl;
@@ -395,6 +396,14 @@ void LogMessageBuilder::WriteToLogFile() {
ASSERT(rv == static_cast<size_t>(pos_));
USE(rv);
}
+
+// Write a null-terminated string to to the log file currently opened.
+void LogMessageBuilder::WriteCStringToLogFile(const char* str) {
+ size_t len = strlen(str);
+ size_t rv = fwrite(str, 1, len, Logger::logfile_);
+ ASSERT(rv == len);
+ USE(rv);
+}
#endif
@@ -417,8 +426,7 @@ void Logger::Preamble(const char* content) {
#ifdef ENABLE_LOGGING_AND_PROFILING
if (logfile_ == NULL || !FLAG_log_code) return;
LogMessageBuilder msg;
- msg.Append("%s", content);
- msg.WriteToLogFile();
+ msg.WriteCStringToLogFile(content);
#endif
}
@@ -758,6 +766,20 @@ void Logger::CodeCreateEvent(const char* tag, Code* code, int args_count) {
}
+void Logger::RegExpCodeCreateEvent(Code* code, String* source) {
+#ifdef ENABLE_LOGGING_AND_PROFILING
+ if (logfile_ == NULL || !FLAG_log_code) return;
+ LogMessageBuilder msg;
+ msg.Append("code-creation,%s,0x%x,%d,\"", "RegExp",
+ reinterpret_cast<unsigned int>(code->address()),
+ code->ExecutableSize());
+ msg.AppendDetailed(source, false);
+ msg.Append("\"\n");
+ msg.WriteToLogFile();
+#endif
+}
+
+
void Logger::CodeAllocateEvent(Code* code, Assembler* assem) {
#ifdef ENABLE_LOGGING_AND_PROFILING
if (logfile_ == NULL || !FLAG_log_code) return;
@@ -1010,9 +1032,9 @@ bool Logger::Setup() {
}
}
SmartPointer<const char> expanded = stream.ToCString();
- logfile_ = OS::FOpen(*expanded, "w");
+ logfile_ = OS::FOpen(*expanded, OS::LogFileOpenMode);
} else {
- logfile_ = OS::FOpen(FLAG_logfile, "w");
+ logfile_ = OS::FOpen(FLAG_logfile, OS::LogFileOpenMode);
}
message_buffer_ = NewArray<char>(kMessageBufferSize);
mutex_ = OS::CreateMutex();
« no previous file with comments | « src/log.h ('k') | src/platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698