Commit a6f5fca5 authored by sejunho's avatar sejunho Committed by Commit bot

Fix preparing log file name.

Problem:
Excuting with flags as "--prof --logfile-per-isolate --logfile=/path/to/filename"
expected file name: /path/to/isolate-<isolate id>-filename
current result: isolate-<isolate id>-/path/to/filename

This patch makes the file name we expected.

Review URL: https://codereview.chromium.org/960813004

Cr-Commit-Position: refs/heads/master@{#26955}
parent 7611aace
......@@ -63,6 +63,7 @@ James Pike <g00gle@chilon.net>
Jianghua Yang <jianghua.yjh@alibaba-inc.com>
Joel Stanley <joel@jms.id.au>
Jonathan Liu <net147@gmail.com>
JunHo Seo <sejunho@gmail.com>
Kang-Hao (Kenny) Lu <kennyluck@csail.mit.edu>
Luis Reis <luis.m.reis@gmail.com>
Luke Zarko <lukezarko@gmail.com>
......
......@@ -356,6 +356,11 @@ bool OS::Remove(const char* path) {
}
bool OS::isDirectorySeparator(const char ch) {
return ch == '/';
}
FILE* OS::OpenTemporaryFile() {
return tmpfile();
}
......
......@@ -575,6 +575,11 @@ bool OS::Remove(const char* path) {
}
bool OS::isDirectorySeparator(const char ch) {
return ch == '/' || ch == '\\';
}
FILE* OS::OpenTemporaryFile() {
// tmpfile_s tries to use the root dir, don't use it.
char tempPathBuffer[MAX_PATH];
......
......@@ -142,6 +142,8 @@ class OS {
static FILE* FOpen(const char* path, const char* mode);
static bool Remove(const char* path);
static bool isDirectorySeparator(const char ch);
// Opens a temporary file, the file is auto removed on close.
static FILE* OpenTemporaryFile();
......
......@@ -1767,8 +1767,16 @@ static void AddIsolateIdIfNeeded(std::ostream& os, // NOLINT
static void PrepareLogFileName(std::ostream& os, // NOLINT
Isolate* isolate, const char* file_name) {
AddIsolateIdIfNeeded(os, isolate);
int dir_separator_count = 0;
for (const char* p = file_name; *p; p++) {
if (base::OS::isDirectorySeparator(*p)) dir_separator_count++;
}
for (const char* p = file_name; *p; p++) {
if (dir_separator_count == 0) {
AddIsolateIdIfNeeded(os, isolate);
dir_separator_count--;
}
if (*p == '%') {
p++;
switch (*p) {
......@@ -1794,6 +1802,7 @@ static void PrepareLogFileName(std::ostream& os, // NOLINT
break;
}
} else {
if (base::OS::isDirectorySeparator(*p)) dir_separator_count--;
os << *p;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment