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

Side by Side Diff: tools/crashpad_database_util.cc

Issue 1120383003: Get generate_dump compiling on Windows (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@tools
Patch Set: fix mac; no implicit conversion to std::string for StringPiece 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 unified diff | Download patch
« no previous file with comments | « minidump/minidump_system_info_writer.cc ('k') | tools/generate_dump.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Crashpad Authors. All rights reserved. 1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 20 matching lines...) Expand all
31 #include "base/strings/string_util.h" 31 #include "base/strings/string_util.h"
32 #include "base/strings/utf_string_conversions.h" 32 #include "base/strings/utf_string_conversions.h"
33 #include "build/build_config.h" 33 #include "build/build_config.h"
34 #include "client/crash_report_database.h" 34 #include "client/crash_report_database.h"
35 #include "client/settings.h" 35 #include "client/settings.h"
36 #include "tools/tool_support.h" 36 #include "tools/tool_support.h"
37 #include "util/file/file_io.h" 37 #include "util/file/file_io.h"
38 #include "util/file/file_reader.h" 38 #include "util/file/file_reader.h"
39 #include "util/misc/uuid.h" 39 #include "util/misc/uuid.h"
40 40
41 #if defined(OS_POSIX)
42 base::FilePath::StringType UTF8ToFilePathStringType(const char* path) {
43 return path;
44 }
45 #elif defined(OS_WIN)
46 base::FilePath::StringType UTF8ToFilePathStringType(const char* path) {
47 return base::UTF8ToUTF16(path);
48 }
49 #endif
50
51 namespace crashpad { 41 namespace crashpad {
52 namespace { 42 namespace {
53 43
54 void Usage(const base::FilePath& me) { 44 void Usage(const base::FilePath& me) {
55 fprintf(stderr, 45 fprintf(stderr,
56 "Usage: %" PRFilePath " [OPTION]... PID\n" 46 "Usage: %" PRFilePath " [OPTION]... PID\n"
57 "Operate on Crashpad crash report databases.\n" 47 "Operate on Crashpad crash report databases.\n"
58 "\n" 48 "\n"
59 " -d, --database=PATH operate on the crash report database at PATH\ n" 49 " -d, --database=PATH operate on the crash report database at PATH\ n"
60 " --show-client-id show the client ID\n" 50 " --show-client-id show the client ID\n"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 236
247 for (const CrashReportDatabase::Report& report : reports) { 237 for (const CrashReportDatabase::Report& report : reports) {
248 printf("%s%s%s\n", spaces.c_str(), report.uuid.ToString().c_str(), colon); 238 printf("%s%s%s\n", spaces.c_str(), report.uuid.ToString().c_str(), colon);
249 if (options.show_all_report_info) { 239 if (options.show_all_report_info) {
250 ShowReport(report, space_count + 2, options.utc); 240 ShowReport(report, space_count + 2, options.utc);
251 } 241 }
252 } 242 }
253 } 243 }
254 244
255 int DatabaseUtilMain(int argc, char* argv[]) { 245 int DatabaseUtilMain(int argc, char* argv[]) {
256 const base::FilePath me( 246 const base::FilePath argv0(
257 base::FilePath(UTF8ToFilePathStringType(argv[0])).BaseName()); 247 ToolSupport::CommandLineArgumentToFilePathStringType(argv[0]));
248 const base::FilePath me(argv0.BaseName());
258 249
259 enum OptionFlags { 250 enum OptionFlags {
260 // “Short” (single-character) options. 251 // “Short” (single-character) options.
261 kOptionDatabase = 'd', 252 kOptionDatabase = 'd',
262 253
263 // Long options without short equivalents. 254 // Long options without short equivalents.
264 kOptionLastChar = 255, 255 kOptionLastChar = 255,
265 kOptionShowClientID, 256 kOptionShowClientID,
266 kOptionShowUploadsEnabled, 257 kOptionShowUploadsEnabled,
267 kOptionShowLastUploadAttemptTime, 258 kOptionShowLastUploadAttemptTime,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 return EXIT_FAILURE; 348 return EXIT_FAILURE;
358 } 349 }
359 options.has_set_uploads_enabled = true; 350 options.has_set_uploads_enabled = true;
360 break; 351 break;
361 } 352 }
362 case kOptionSetLastUploadAttemptTime: { 353 case kOptionSetLastUploadAttemptTime: {
363 options.set_last_upload_attempt_time_string = optarg; 354 options.set_last_upload_attempt_time_string = optarg;
364 break; 355 break;
365 } 356 }
366 case kOptionNewReport: { 357 case kOptionNewReport: {
367 options.new_report_paths.push_back( 358 options.new_report_paths.push_back(base::FilePath(
368 base::FilePath(UTF8ToFilePathStringType(optarg))); 359 ToolSupport::CommandLineArgumentToFilePathStringType(optarg)));
369 break; 360 break;
370 } 361 }
371 case kOptionUTC: { 362 case kOptionUTC: {
372 options.utc = true; 363 options.utc = true;
373 break; 364 break;
374 } 365 }
375 case kOptionHelp: { 366 case kOptionHelp: {
376 Usage(me); 367 Usage(me);
377 return EXIT_SUCCESS; 368 return EXIT_SUCCESS;
378 } 369 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 const size_t set_operations = 409 const size_t set_operations =
419 options.has_set_uploads_enabled + 410 options.has_set_uploads_enabled +
420 (options.set_last_upload_attempt_time_string != nullptr); 411 (options.set_last_upload_attempt_time_string != nullptr);
421 412
422 if (show_operations + set_operations == 0) { 413 if (show_operations + set_operations == 0) {
423 ToolSupport::UsageHint(me, "nothing to do"); 414 ToolSupport::UsageHint(me, "nothing to do");
424 return EXIT_FAILURE; 415 return EXIT_FAILURE;
425 } 416 }
426 417
427 scoped_ptr<CrashReportDatabase> database(CrashReportDatabase::Initialize( 418 scoped_ptr<CrashReportDatabase> database(CrashReportDatabase::Initialize(
428 base::FilePath(UTF8ToFilePathStringType(options.database)))); 419 base::FilePath(ToolSupport::CommandLineArgumentToFilePathStringType(
420 options.database))));
429 if (!database) { 421 if (!database) {
430 return EXIT_FAILURE; 422 return EXIT_FAILURE;
431 } 423 }
432 424
433 Settings* settings = database->GetSettings(); 425 Settings* settings = database->GetSettings();
434 426
435 // Handle the “show” options before the “set” options so that when they’re 427 // Handle the “show” options before the “set” options so that when they’re
436 // specified together, the “show” option reflects the initial state. 428 // specified together, the “show” option reflects the initial state.
437 429
438 if (options.show_client_id) { 430 if (options.show_client_id) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 570
579 } // namespace 571 } // namespace
580 } // namespace crashpad 572 } // namespace crashpad
581 573
582 #if defined(OS_POSIX) 574 #if defined(OS_POSIX)
583 int main(int argc, char* argv[]) { 575 int main(int argc, char* argv[]) {
584 return crashpad::DatabaseUtilMain(argc, argv); 576 return crashpad::DatabaseUtilMain(argc, argv);
585 } 577 }
586 #elif defined(OS_WIN) 578 #elif defined(OS_WIN)
587 int wmain(int argc, wchar_t* argv[]) { 579 int wmain(int argc, wchar_t* argv[]) {
588 scoped_ptr<char*[]> argv_as_utf8(new char*[argc]); 580 return crashpad::ToolSupport::Wmain(argc, argv, crashpad::DatabaseUtilMain);
589 std::vector<std::string> storage;
590 storage.reserve(argc);
591 for (int i = 0; i < argc; ++i) {
592 storage.push_back(base::UTF16ToUTF8(argv[i]));
593 argv_as_utf8[i] = &storage[i][0];
594 }
595 return crashpad::DatabaseUtilMain(argc, argv_as_utf8.get());
596 } 581 }
597 #endif // OS_POSIX 582 #endif // OS_POSIX
OLDNEW
« no previous file with comments | « minidump/minidump_system_info_writer.cc ('k') | tools/generate_dump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698