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

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: 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 unified diff | Download patch
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 24 matching lines...) Expand all
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_MACOSX) 41 #if defined(OS_MACOSX)
42 #include <libgen.h> 42 #include <libgen.h>
43 #endif // OS_MACOSX 43 #endif // OS_MACOSX
44 44
45 #if defined(OS_POSIX)
46 base::FilePath::StringType UTF8ToFilePathStringType(const char* path) {
47 return path;
48 }
49 #elif defined(OS_WIN)
50 base::FilePath::StringType UTF8ToFilePathStringType(const char* path) {
51 return base::UTF8ToUTF16(path);
52 }
53 #endif
54
55 namespace crashpad { 45 namespace crashpad {
56 namespace { 46 namespace {
57 47
58 void Usage(const base::FilePath& me) { 48 void Usage(const base::FilePath& me) {
59 fprintf(stderr, 49 fprintf(stderr,
60 "Usage: %" PRFilePath " [OPTION]... PID\n" 50 "Usage: %" PRFilePath " [OPTION]... PID\n"
61 "Operate on Crashpad crash report databases.\n" 51 "Operate on Crashpad crash report databases.\n"
62 "\n" 52 "\n"
63 " -d, --database=PATH operate on the crash report database at PATH\ n" 53 " -d, --database=PATH operate on the crash report database at PATH\ n"
64 " --show-client-id show the client ID\n" 54 " --show-client-id show the client ID\n"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 248
259 for (const CrashReportDatabase::Report& report : reports) { 249 for (const CrashReportDatabase::Report& report : reports) {
260 printf("%s%s%s\n", spaces.c_str(), report.uuid.ToString().c_str(), colon); 250 printf("%s%s%s\n", spaces.c_str(), report.uuid.ToString().c_str(), colon);
261 if (options.show_all_report_info) { 251 if (options.show_all_report_info) {
262 ShowReport(report, space_count + 2, options.utc); 252 ShowReport(report, space_count + 2, options.utc);
263 } 253 }
264 } 254 }
265 } 255 }
266 256
267 int DatabaseUtilMain(int argc, char* argv[]) { 257 int DatabaseUtilMain(int argc, char* argv[]) {
268 const base::FilePath me( 258 const base::FilePath argv0(
269 base::FilePath(UTF8ToFilePathStringType(argv[0])).BaseName()); 259 ToolSupport::CommandLineArgumentToFilePathStringType(argv[0]));
260 const base::FilePath me(argv0.BaseName());
270 261
271 enum OptionFlags { 262 enum OptionFlags {
272 // “Short” (single-character) options. 263 // “Short” (single-character) options.
273 kOptionDatabase = 'd', 264 kOptionDatabase = 'd',
274 265
275 // Long options without short equivalents. 266 // Long options without short equivalents.
276 kOptionLastChar = 255, 267 kOptionLastChar = 255,
277 kOptionShowClientID, 268 kOptionShowClientID,
278 kOptionShowUploadsEnabled, 269 kOptionShowUploadsEnabled,
279 kOptionShowLastUploadAttemptTime, 270 kOptionShowLastUploadAttemptTime,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 return EXIT_FAILURE; 361 return EXIT_FAILURE;
371 } 362 }
372 options.has_set_uploads_enabled = true; 363 options.has_set_uploads_enabled = true;
373 break; 364 break;
374 } 365 }
375 case kOptionSetLastUploadAttemptTime: { 366 case kOptionSetLastUploadAttemptTime: {
376 options.set_last_upload_attempt_time_string = optarg; 367 options.set_last_upload_attempt_time_string = optarg;
377 break; 368 break;
378 } 369 }
379 case kOptionNewReport: { 370 case kOptionNewReport: {
380 options.new_report_paths.push_back( 371 options.new_report_paths.push_back(base::FilePath(
381 base::FilePath(UTF8ToFilePathStringType(optarg))); 372 ToolSupport::CommandLineArgumentToFilePathStringType(optarg)));
382 break; 373 break;
383 } 374 }
384 case kOptionUTC: { 375 case kOptionUTC: {
385 options.utc = true; 376 options.utc = true;
386 break; 377 break;
387 } 378 }
388 case kOptionHelp: { 379 case kOptionHelp: {
389 Usage(me); 380 Usage(me);
390 return EXIT_SUCCESS; 381 return EXIT_SUCCESS;
391 } 382 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 const size_t set_operations = 422 const size_t set_operations =
432 options.has_set_uploads_enabled + 423 options.has_set_uploads_enabled +
433 (options.set_last_upload_attempt_time_string != nullptr); 424 (options.set_last_upload_attempt_time_string != nullptr);
434 425
435 if (show_operations + set_operations == 0) { 426 if (show_operations + set_operations == 0) {
436 ToolSupport::UsageHint(me, "nothing to do"); 427 ToolSupport::UsageHint(me, "nothing to do");
437 return EXIT_FAILURE; 428 return EXIT_FAILURE;
438 } 429 }
439 430
440 scoped_ptr<CrashReportDatabase> database(CrashReportDatabase::Initialize( 431 scoped_ptr<CrashReportDatabase> database(CrashReportDatabase::Initialize(
441 base::FilePath(UTF8ToFilePathStringType(options.database)))); 432 base::FilePath(ToolSupport::CommandLineArgumentToFilePathStringType(
433 options.database))));
442 if (!database) { 434 if (!database) {
443 return EXIT_FAILURE; 435 return EXIT_FAILURE;
444 } 436 }
445 437
446 Settings* settings = database->GetSettings(); 438 Settings* settings = database->GetSettings();
447 439
448 // Handle the “show” options before the “set” options so that when they’re 440 // Handle the “show” options before the “set” options so that when they’re
449 // specified together, the “show” option reflects the initial state. 441 // specified together, the “show” option reflects the initial state.
450 442
451 if (options.show_client_id) { 443 if (options.show_client_id) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 583
592 } // namespace 584 } // namespace
593 } // namespace crashpad 585 } // namespace crashpad
594 586
595 #if defined(OS_POSIX) 587 #if defined(OS_POSIX)
596 int main(int argc, char* argv[]) { 588 int main(int argc, char* argv[]) {
597 return crashpad::DatabaseUtilMain(argc, argv); 589 return crashpad::DatabaseUtilMain(argc, argv);
598 } 590 }
599 #elif defined(OS_WIN) 591 #elif defined(OS_WIN)
600 int wmain(int argc, wchar_t* argv[]) { 592 int wmain(int argc, wchar_t* argv[]) {
601 scoped_ptr<char*[]> argv_as_utf8(new char*[argc]); 593 return crashpad::ToolSupport::Wmain(argc, argv, crashpad::DatabaseUtilMain);
602 std::vector<std::string> storage;
603 storage.reserve(argc);
604 for (int i = 0; i < argc; ++i) {
605 storage.push_back(base::UTF16ToUTF8(argv[i]));
606 argv_as_utf8[i] = &storage[i][0];
607 }
608 return crashpad::DatabaseUtilMain(argc, argv_as_utf8.get());
609 } 594 }
610 #endif // OS_POSIX 595 #endif // OS_POSIX
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698