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}
This commit is contained in:
sejunho 2015-03-03 03:03:41 -08:00 committed by Commit bot
parent 7611aace3e
commit a6f5fca5e6
5 changed files with 23 additions and 1 deletions

View File

@ -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>

View File

@ -356,6 +356,11 @@ bool OS::Remove(const char* path) {
}
bool OS::isDirectorySeparator(const char ch) {
return ch == '/';
}
FILE* OS::OpenTemporaryFile() {
return tmpfile();
}

View File

@ -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];

View File

@ -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();

View File

@ -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;
}
}