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

Unified Diff: tools/crashpad_database_util.cc

Issue 1119783005: win: get tools/crashpad_database_util mostly working (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: fixes Created 5 years, 7 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 | « third_party/getopt/getopt.gyp ('k') | tools/tool_support.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/crashpad_database_util.cc
diff --git a/tools/crashpad_database_util.cc b/tools/crashpad_database_util.cc
index cd5a2195bd5b2146a1abb28ee0b3dabfea8c329b..bcb742c9f9c651837ed5384e1ea6086265ccc492 100644
--- a/tools/crashpad_database_util.cc
+++ b/tools/crashpad_database_util.cc
@@ -14,7 +14,6 @@
#include <errno.h>
#include <getopt.h>
-#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -25,10 +24,13 @@
#include <vector>
#include "base/basictypes.h"
-#include "base/logging.h"
#include "base/files/file_path.h"
+#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/numerics/safe_conversions.h"
+#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
+#include "build/build_config.h"
#include "client/crash_report_database.h"
#include "client/settings.h"
#include "tools/tool_support.h"
@@ -36,12 +38,22 @@
#include "util/file/file_reader.h"
#include "util/misc/uuid.h"
+#if defined(OS_POSIX)
+base::FilePath::StringType UTF8ToFilePathStringType(const char* path) {
+ return path;
+}
+#elif defined(OS_WIN)
+base::FilePath::StringType UTF8ToFilePathStringType(const char* path) {
+ return base::UTF8ToUTF16(path);
+}
+#endif
+
namespace crashpad {
namespace {
-void Usage(const std::string& me) {
+void Usage(const base::FilePath& me) {
fprintf(stderr,
-"Usage: %s [OPTION]... PID\n"
+"Usage: %" PRFilePath " [OPTION]... PID\n"
"Operate on Crashpad crash report databases.\n"
"\n"
" -d, --database=PATH operate on the crash report database at PATH\n"
@@ -60,7 +72,7 @@ void Usage(const std::string& me) {
" --utc show and set UTC times instead of local\n"
" --help display this help and exit\n"
" --version output version information and exit\n",
- me.c_str());
+ me.value().c_str());
ToolSupport::UsageTail(me);
}
@@ -104,14 +116,14 @@ bool StringToBool(const char* string, bool* boolean) {
};
for (size_t index = 0; index < arraysize(kFalseWords); ++index) {
- if (strcasecmp(string, kFalseWords[index]) == 0) {
+ if (base::strcasecmp(string, kFalseWords[index]) == 0) {
*boolean = false;
return true;
}
}
for (size_t index = 0; index < arraysize(kTrueWords); ++index) {
- if (strcasecmp(string, kTrueWords[index]) == 0) {
+ if (base::strcasecmp(string, kTrueWords[index]) == 0) {
*boolean = true;
return true;
}
@@ -133,7 +145,7 @@ std::string BoolToString(bool boolean) {
// when true, causes |string| to be interpreted as a UTC time rather than a
// local time when the time zone is ambiguous.
bool StringToTime(const char* string, time_t* time, bool utc) {
- if (strcasecmp(string, "never") == 0) {
+ if (base::strcasecmp(string, "never") == 0) {
*time = 0;
return true;
}
@@ -153,7 +165,7 @@ bool StringToTime(const char* string, time_t* time, bool utc) {
if (utc) {
*time = timegm(&time_tm);
} else {
- *time = timelocal(&time_tm);
+ *time = mktime(&time_tm);
}
return true;
@@ -172,7 +184,7 @@ bool StringToTime(const char* string, time_t* time, bool utc) {
return false;
}
-// Converst |time_tt| to a string, and returns it. |utc| determines whether the
+// Converts |time_tt| to a string, and returns it. |utc| determines whether the
// converted time will reference local time or UTC. If |time_tt| is 0, the
// string "never" will be returned as a special case.
std::string TimeToString(time_t time_tt, bool utc) {
@@ -203,7 +215,9 @@ void ShowReport(const CrashReportDatabase::Report& report,
bool utc) {
std::string spaces(space_count, ' ');
- printf("%sPath: %s\n", spaces.c_str(), report.file_path.value().c_str());
+ printf("%sPath: %" PRFilePath "\n",
+ spaces.c_str(),
+ report.file_path.value().c_str());
if (!report.id.empty()) {
printf("%sRemote ID: %s\n", spaces.c_str(), report.id.c_str());
}
@@ -239,7 +253,8 @@ void ShowReports(const std::vector<CrashReportDatabase::Report>& reports,
}
int DatabaseUtilMain(int argc, char* argv[]) {
- const std::string me(basename(argv[0]));
+ const base::FilePath me(
+ base::FilePath(UTF8ToFilePathStringType(argv[0])).BaseName());
enum OptionFlags {
// “Short” (single-character) options.
@@ -349,7 +364,8 @@ int DatabaseUtilMain(int argc, char* argv[]) {
break;
}
case kOptionNewReport: {
- options.new_report_paths.push_back(base::FilePath(optarg));
+ options.new_report_paths.push_back(
+ base::FilePath(UTF8ToFilePathStringType(optarg)));
break;
}
case kOptionUTC: {
@@ -408,8 +424,8 @@ int DatabaseUtilMain(int argc, char* argv[]) {
return EXIT_FAILURE;
}
- scoped_ptr<CrashReportDatabase> database(
- CrashReportDatabase::Initialize(base::FilePath(options.database)));
+ scoped_ptr<CrashReportDatabase> database(CrashReportDatabase::Initialize(
+ base::FilePath(UTF8ToFilePathStringType(options.database))));
if (!database) {
return EXIT_FAILURE;
}
@@ -453,7 +469,7 @@ int DatabaseUtilMain(int argc, char* argv[]) {
printf("%s%s (%ld)\n",
prefix,
TimeToString(last_upload_attempt_time, options.utc).c_str(),
- implicit_cast<long>(last_upload_attempt_time));
+ static_cast<long>(last_upload_attempt_time));
}
if (options.show_pending_reports) {
@@ -497,7 +513,8 @@ int DatabaseUtilMain(int argc, char* argv[]) {
// If only asked to do one thing, a failure to find the single requested
// report should result in a failure exit status.
if (show_operations + set_operations == 1) {
- fprintf(stderr, "%s: Report not found\n", me.c_str());
+ fprintf(
+ stderr, "%" PRFilePath ": Report not found\n", me.value().c_str());
return EXIT_FAILURE;
}
printf("Report %s not found\n", uuid.ToString().c_str());
@@ -562,6 +579,19 @@ int DatabaseUtilMain(int argc, char* argv[]) {
} // namespace
} // namespace crashpad
+#if defined(OS_POSIX)
int main(int argc, char* argv[]) {
return crashpad::DatabaseUtilMain(argc, argv);
}
+#elif defined(OS_WIN)
+int wmain(int argc, wchar_t* argv[]) {
+ scoped_ptr<char*[]> argv_as_utf8(new char*[argc]);
+ std::vector<std::string> storage;
+ storage.reserve(argc);
+ for (int i = 0; i < argc; ++i) {
+ storage.push_back(base::UTF16ToUTF8(argv[i]));
+ argv_as_utf8[i] = &storage[i][0];
+ }
+ return crashpad::DatabaseUtilMain(argc, argv_as_utf8.get());
+}
+#endif // OS_POSIX
« no previous file with comments | « third_party/getopt/getopt.gyp ('k') | tools/tool_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698