// Copyright 2015 The Crashpad Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include <errno.h> #include <getopt.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <sys/types.h> #include <time.h> #include <iterator> #include <memory> #include <string> #include <utility> #include <vector> #include "base/check_op.h" #include "base/files/file_path.h" #include "base/numerics/safe_conversions.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" #include "util/file/file_io.h" #include "util/file/file_reader.h" #include "util/misc/uuid.h" #include "util/stdlib/string_number_conversion.h" namespace crashpad { namespace { void Usage(const base::FilePath& me) { … } struct Options { … }; // Converts |string| to |boolean|, returning true if a conversion could be // performed, and false without setting |boolean| if no conversion could be // performed. Various string representations of a boolean are recognized // case-insensitively. bool StringToBool(const char* string, bool* boolean) { … } // Converts |boolean| to a string, either "true" or "false". std::string BoolToString(bool boolean) { … } // Converts |string| to |out_time|, returning true if a conversion could be // performed, and false without setting |boolean| if no conversion could be // performed. Various time formats are recognized, including several string // representations and a numeric time_t representation. The special |string| // "never" is recognized as converted to a |out_time| value of 0; "now" is // converted to the current time. |utc|, 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* out_time, bool utc) { … } // Converts |out_time| to a string, and returns it. |utc| determines whether the // converted time will reference local time or UTC. If |out_time| is 0, the // string "never" will be returned as a special case. std::string TimeToString(time_t out_time, bool utc) { … } // Shows information about a single |report|. |space_count| is the number of // spaces to print before each line that is printed. |utc| determines whether // times should be shown in UTC or the local time zone. void ShowReport(const CrashReportDatabase::Report& report, size_t space_count, bool utc) { … } // Shows information about a vector of |reports|. |space_count| is the number of // spaces to print before each line that is printed. |options| will be consulted // to determine whether to show expanded information // (options.show_all_report_info) and what time zone to use when showing // expanded information (options.utc). void ShowReports(const std::vector<CrashReportDatabase::Report>& reports, size_t space_count, const Options& options) { … } int DatabaseUtilMain(int argc, char* argv[]) { … } } // namespace } // namespace crashpad #if BUILDFLAG(IS_POSIX) int main(int argc, char* argv[]) { … } #elif BUILDFLAG(IS_WIN) int wmain(int argc, wchar_t* argv[]) { return crashpad::ToolSupport::Wmain(argc, argv, crashpad::DatabaseUtilMain); } #endif // BUILDFLAG(IS_POSIX)