Add a flag to google_converter to keep Breakpad/PE/PDB files after conversion.

Change-Id: I8948e1aba598d42369d70ca1cc1168ce3841ab40
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/4038509
Reviewed-by: Zequan Wu <zequanwu@google.com>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
Nelson Billing 2022-11-18 10:55:30 -08:00
parent c7acbcef04
commit 4d0c21b9a5

View File

@ -304,7 +304,8 @@ static bool SafeToMakeExternalRequest(const MissingSymbolInfo& missing_info,
// Converter options derived from command line parameters.
struct ConverterOptions {
ConverterOptions() : report_fetch_failures(true), trace_symsrv(false) {}
ConverterOptions()
: report_fetch_failures(true), trace_symsrv(false), keep_files(false) {}
~ConverterOptions() {
}
@ -354,6 +355,9 @@ struct ConverterOptions {
// If set then SymSrv callbacks are logged to stderr.
bool trace_symsrv;
// If set then Breakpad/PE/PDB files won't be deleted after processing.
bool keep_files;
private:
// DISABLE_COPY_AND_ASSIGN
ConverterOptions(const ConverterOptions&);
@ -435,7 +439,8 @@ static void ConvertMissingSymbolFile(const MissingSymbolInfo& missing_info,
UploadSymbolFile(options.upload_symbols_url, options.api_key,
missing_info.debug_file, missing_info.debug_identifier,
converted_file, kSymbolUploadTypeBreakpad);
remove(converted_file.c_str());
if (!options.keep_files)
remove(converted_file.c_str());
// Upload PDB/PE if we have them
if (!symbol_file.empty()) {
@ -443,14 +448,16 @@ static void ConvertMissingSymbolFile(const MissingSymbolInfo& missing_info,
missing_info.debug_file,
missing_info.debug_identifier, symbol_file,
kSymbolUploadTypePDB);
remove(symbol_file.c_str());
if (!options.keep_files)
remove(symbol_file.c_str());
}
if (!pe_file.empty()) {
UploadSymbolFile(options.upload_symbols_url, options.api_key,
missing_info.code_file,
missing_info.debug_identifier, pe_file,
kSymbolUploadTypePE);
remove(pe_file.c_str());
if (!options.keep_files)
remove(pe_file.c_str());
}
// Note: this does leave some directories behind that could be
@ -541,20 +548,23 @@ static void ConvertMissingSymbolFile(const MissingSymbolInfo& missing_info,
UploadSymbolFile(options.upload_symbols_url, options.api_key,
missing_info.debug_file, missing_info.debug_identifier,
converted_file, kSymbolUploadTypeBreakpad);
remove(converted_file.c_str());
if (!options.keep_files)
remove(converted_file.c_str());
// Upload PDB/PE if we have them
if (!symbol_file.empty()) {
UploadSymbolFile(options.upload_symbols_url, options.api_key,
missing_info.debug_file, missing_info.debug_identifier,
symbol_file, kSymbolUploadTypePDB);
remove(symbol_file.c_str());
if (!options.keep_files)
remove(symbol_file.c_str());
}
if (!pe_file.empty()) {
UploadSymbolFile(options.upload_symbols_url, options.api_key,
missing_info.code_file, missing_info.debug_identifier,
pe_file, kSymbolUploadTypePE);
remove(pe_file.c_str());
if (!options.keep_files)
remove(pe_file.c_str());
}
// Note: this does leave some directories behind that could be
@ -732,6 +742,8 @@ static int usage(const char* program_name) {
" prevent external symbol requests\n"
" -tss If set then SymSrv callbacks will be\n"
" traced to stderr.\n"
" -keep-files If set then don't delete Breakpad/PE/\n"
" PDB files after conversion.\n"
" Note that any server specified by -f or -n that starts with \\filer\n"
" will be treated as internal, and all others as external.\n",
program_name);
@ -769,17 +781,21 @@ int main(int argc, char** argv) {
ConverterOptions options;
options.report_fetch_failures = true;
// All arguments are paired.
if (argc % 2 != 1) {
return usage(argv[0]);
}
string blacklist_regex_str;
bool have_any_msss_servers = false;
for (int argi = 1; argi < argc; argi += 2) {
for (int argi = 1; argi < argc; argi++) {
string option = argv[argi];
string value = argv[argi + 1];
if (option == "-tss") {
printf("Tracing SymSrv callbacks to stderr.\n");
options.trace_symsrv = true;
continue;
} else if (option == "-keep-files") {
printf("Keeping Breakpad/PE/PDB files after conversion.\n");
options.keep_files = true;
continue;
}
string value = argv[++argi];
if (option == "-f") {
AddServer(value,& options.full_internal_msss_servers,
& options.full_external_msss_servers);
@ -818,9 +834,6 @@ int main(int argc, char** argv) {
printf("Getting the list of missing symbols from a file. Fetch failures"
" will not be reported.\n");
options.report_fetch_failures = false;
} else if (option == "-tss") {
printf("Tracing SymSrv callbacks to stderr.\n");
options.trace_symsrv = true;
} else if (option == "-t") {
if (!WindowsStringUtils::safe_mbstowcs(
value,