diff options
author | Nelson Billing <nbilling@google.com> | 2020-02-27 14:04:01 -0800 |
---|---|---|
committer | Nelson Billing <nbilling@google.com> | 2020-02-27 22:04:31 +0000 |
commit | c7522272ffafa9b162f135aaee5d02a8895fcb0b (patch) | |
tree | a13d99c2cbefd9f6f78a8e128957ae2873bcf34d /src/common | |
parent | Make LibcurlWrapper support static linking. (diff) | |
download | breakpad-c7522272ffafa9b162f135aaee5d02a8895fcb0b.tar.xz |
Add "type" option to sym_upload sym-upload-v2 mode.
- "sym-upload-v2" protocol now supports specifying a symbol file "type".
- Known types are "breakpad" (default option, previously this was only
effectively the only option), "elf", "pe", "macho", "debug_only", "dwp",
"pdb", and "dsym".
- When type other than breakpad is specified, sym_upload tool requires
the code_file and debug_id value (that it otherwise would have gotten
from the text of the Breakpad symbol file).
- This ultimately means that sym_upload can be used to upload native
symbol files now, in addition to Breakpad symbol files.
Change-Id: I3a331ba16f199d1d0025df735716ba5de298f522
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2078670
Reviewed-by: Mark Mentovai <mark@chromium.org>
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/linux/symbol_collector_client.cc | 6 | ||||
-rw-r--r-- | src/common/linux/symbol_collector_client.h | 3 | ||||
-rw-r--r-- | src/common/linux/symbol_upload.cc | 58 | ||||
-rw-r--r-- | src/common/linux/symbol_upload.h | 7 |
4 files changed, 51 insertions, 23 deletions
diff --git a/src/common/linux/symbol_collector_client.cc b/src/common/linux/symbol_collector_client.cc index ea995c4b..92b25ddb 100644 --- a/src/common/linux/symbol_collector_client.cc +++ b/src/common/linux/symbol_collector_client.cc @@ -102,7 +102,8 @@ CompleteUploadResult SymbolCollectorClient::CompleteUpload( const string& api_key, const string& upload_key, const string& debug_file, - const string& debug_id) { + const string& debug_id, + const string& type) { string header, response; long response_code; @@ -113,7 +114,8 @@ CompleteUploadResult SymbolCollectorClient::CompleteUpload( string body = "{ symbol_id: {" "debug_file: \"" + debug_file + "\", " - "debug_id: \"" + debug_id + "\" } }"; + "debug_id: \"" + debug_id + "\" }, " + "symbol_upload_type: \"" + type + "\" }"; if (!libcurl_wrapper->SendSimplePostRequest(url, body, diff --git a/src/common/linux/symbol_collector_client.h b/src/common/linux/symbol_collector_client.h index 5f811de4..0e23242a 100644 --- a/src/common/linux/symbol_collector_client.h +++ b/src/common/linux/symbol_collector_client.h @@ -71,7 +71,8 @@ class SymbolCollectorClient { const string& api_key, const string& upload_key, const string& debug_file, - const string& debug_id); + const string& debug_id, + const string& type); static SymbolStatus CheckSymbolStatus( LibcurlWrapper* libcurl_wrapper, diff --git a/src/common/linux/symbol_upload.cc b/src/common/linux/symbol_upload.cc index 99750fd1..87741a0a 100644 --- a/src/common/linux/symbol_upload.cc +++ b/src/common/linux/symbol_upload.cc @@ -155,17 +155,15 @@ bool SymUploadV1Start( } // |options| describes the current sym_upload options. -// |module_parts| contains the strings parsed from the MODULE entry of the -// Breakpad symbol file being uploaded. -// |compacted_id| is the debug_id from the MODULE entry of the Breakpad symbol -// file being uploaded, with all hyphens removed. +// |code_id| is the basename of the module for which symbols are being +// uploaded. +// |debug_id| is the debug_id of the module for which symbols are being +// uploaded. bool SymUploadV2Start( const Options& options, - std::vector<string> module_parts, - const string& compacted_id) { - string debug_file = module_parts[4]; - string debug_id = compacted_id; - + const string& code_file, + const string& debug_id, + const string& type) { google_breakpad::LibcurlWrapper libcurl_wrapper; if (!libcurl_wrapper.Init()) { printf("Failed to init google_breakpad::LibcurlWrapper.\n"); @@ -177,7 +175,7 @@ bool SymUploadV2Start( &libcurl_wrapper, options.uploadURLStr, options.api_key, - debug_file, + code_file, debug_id); if (symbolStatus == SymbolStatus::Found) { printf("Symbol file already exists, upload aborted." @@ -230,8 +228,9 @@ bool SymUploadV2Start( options.uploadURLStr, options.api_key, upload_key, - debug_file, - debug_id); + code_file, + debug_id, + type); if (completeUploadResult == CompleteUploadResult::Error) { printf("Failed to complete upload.\n"); return false; @@ -247,17 +246,36 @@ bool SymUploadV2Start( //============================================================================= void Start(Options* options) { - std::vector<string> module_parts; - if (!ModuleDataForSymbolFile(options->symbolsPath, &module_parts)) { - fprintf(stderr, "Failed to parse symbol file!\n"); - return; - } + if (options->upload_protocol == UploadProtocol::SYM_UPLOAD_V2) { + string code_file; + string debug_id; + string type; - const string compacted_id = CompactIdentifier(module_parts[3]); + if (options->type.empty() || options->type == kBreakpadSymbolType) { + // Breakpad upload so read these from input file. + std::vector<string> module_parts; + if (!ModuleDataForSymbolFile(options->symbolsPath, &module_parts)) { + fprintf(stderr, "Failed to parse symbol file!\n"); + return; + } + code_file = module_parts[4]; + debug_id = CompactIdentifier(module_parts[3]); + type = kBreakpadSymbolType; + } else { + // Native upload so these must be explicitly set. + code_file = options->code_file; + debug_id = options->debug_id; + type = options->type; + } - if (options->upload_protocol == UploadProtocol::SYM_UPLOAD_V2) { - options->success = SymUploadV2Start(*options, module_parts, compacted_id); + options->success = SymUploadV2Start(*options, code_file, debug_id, type); } else { + std::vector<string> module_parts; + if (!ModuleDataForSymbolFile(options->symbolsPath, &module_parts)) { + fprintf(stderr, "Failed to parse symbol file!\n"); + return; + } + const string compacted_id = CompactIdentifier(module_parts[3]); options->success = SymUploadV1Start(*options, module_parts, compacted_id); } } diff --git a/src/common/linux/symbol_upload.h b/src/common/linux/symbol_upload.h index 040e980f..9033152b 100644 --- a/src/common/linux/symbol_upload.h +++ b/src/common/linux/symbol_upload.h @@ -46,6 +46,8 @@ enum class UploadProtocol { SYM_UPLOAD_V2, }; +constexpr char kBreakpadSymbolType[] = "BREAKPAD"; + struct Options { Options() : upload_protocol(UploadProtocol::SYM_UPLOAD_V1), force(false) {} @@ -58,6 +60,11 @@ struct Options { UploadProtocol upload_protocol; bool force; string api_key; + + // These only need to be set for native symbol uploads. + string code_file; + string debug_id; + string type; }; // Starts upload to symbol server with options. |