Add symbol type option to SymUploadV2ProtocolSend.

Change-Id: Ia2eadae56c7f879ddb2212e4018024a5c04634aa
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3670054
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
This commit is contained in:
Nelson Billing 2022-05-31 14:04:53 -07:00
parent bee636cea4
commit 678d69cd78
6 changed files with 41 additions and 15 deletions

View File

@ -20,6 +20,7 @@ static bool SymUploadV2ProtocolSend(const wchar_t* api_url,
const wstring& debug_file,
const wstring& debug_id,
const wstring& symbol_filename,
const wstring& symbol_type,
bool force) {
wstring url(api_url);
wstring key(api_key);
@ -69,7 +70,7 @@ static bool SymUploadV2ProtocolSend(const wchar_t* api_url,
CompleteUploadResult completeUploadResult =
SymbolCollectorClient::CompleteUpload(url, key, timeout_ms, upload_key,
debug_file, debug_id);
debug_file, debug_id, symbol_type);
if (completeUploadResult == CompleteUploadResult::Error) {
wprintf(L"Failed to complete upload.\n");
return false;

View File

@ -37,14 +37,26 @@ namespace google_breakpad {
// Sends file at |symbol_filename| using the sym-upload-v2 protocol to
// |api_url| using key |api_key|, and using identifiers |debug_file| and
// |debug_id|. |timeout_ms| is the number of milliseconds to wait before
// terminating the upload attempt. If |force| is set then it will overwrite an
// existing file with the same |debug_file| and |debug_id| in the store.
// terminating the upload attempt. |symbol_type| is the type of the symbol
// file, which is one of:
// "BREAKPAD"
// "ELF"
// "PE"
// "MACHO"
// "DEBUG_ONLY"
// "DWP"
// "DSYM"
// "PDB"
// "SOURCE_MAP"
// If |force| is set then it will overwrite an existing file with the
// same |debug_file| and |debug_id| in the store.
bool SymUploadV2ProtocolSend(const wchar_t* api_url,
const wchar_t* api_key,
int* timeout_ms,
const std::wstring& debug_file,
const std::wstring& debug_id,
const std::wstring& symbol_filename,
const std::wstring& symbol_type,
bool force);
} // namespace google_breakpad

View File

@ -70,15 +70,23 @@ namespace google_breakpad {
int* timeout_ms,
const wstring& upload_key,
const wstring& debug_file,
const wstring& debug_id) {
const wstring& debug_id,
const wstring& type) {
wstring url = api_url +
L"/v1/uploads/" + upload_key + L":complete"
L"?key=" + api_key;
wstring body =
L"{ symbol_id: {"
L"debug_file: \"" + debug_file + L"\", "
L"debug_id: \"" + debug_id + L"\" "
L"debug_file: \"" +
debug_file +
L"\", "
L"debug_id: \"" +
debug_id +
L"\" "
L"}, "
L"symbol_upload_type: \"" +
type +
L"\", "
L"use_async_processing: true }";
wstring response;
int response_code;

View File

@ -69,13 +69,13 @@ namespace google_breakpad {
// Notify the API that symbol file upload is finished and its contents
// are ready to be read and/or used for further processing.
static CompleteUploadResult CompleteUpload(
wstring& api_url,
wstring& api_key,
int* timeout_ms,
const wstring& upload_key,
const wstring& debug_file,
const wstring& debug_id);
static CompleteUploadResult CompleteUpload(wstring& api_url,
wstring& api_key,
int* timeout_ms,
const wstring& upload_key,
const wstring& debug_file,
const wstring& debug_id,
const wstring& type);
// Returns whether or not a symbol file corresponding to the debug_file/
// debug_id pair is already present in symbol storage.

View File

@ -66,6 +66,7 @@ using google_breakpad::WindowsStringUtils;
const char* kMissingStringDelimiters = "|";
const char* kLocalCachePath = "c:\\symbols";
const char* kNoExeMSSSServer = "http://msdl.microsoft.com/download/symbols/";
const wchar_t* kSymbolUploadTypeBreakpad = L"BREAKPAD";
// Windows stdio doesn't do line buffering. Use this function to flush after
// writing to stdout and stderr so that a log will be available if the
@ -239,7 +240,8 @@ static bool UploadSymbolFile(const wstring& upload_symbol_url,
FprintfFlush(stderr, "Uploading %s\n", converted_file.c_str());
if (!google_breakpad::SymUploadV2ProtocolSend(
upload_symbol_url.c_str(), api_key.c_str(), &timeout_ms, debug_file_w,
debug_id_w, converted_file_w, true)) {
debug_id_w, converted_file_w, kSymbolUploadTypeBreakpad,
/*force=*/true)) {
FprintfFlush(stderr, "UploadSymbolFile: HTTPUpload::SendRequest failed "
"for %s %s %s\n",
missing_info.debug_file.c_str(),

View File

@ -68,6 +68,8 @@ using std::string;
using std::vector;
using std::wstring;
const wchar_t* kSymbolUploadTypeBreakpad = L"BREAKPAD";
// Extracts the file version information for the given filename,
// as a string, for example, "1.2.3.4". Returns true on success.
static bool GetFileVersionString(const wchar_t* filename, wstring* version) {
@ -251,7 +253,8 @@ int wmain(int argc, wchar_t* argv[]) {
success = google_breakpad::SymUploadV2ProtocolSend(
api_url, api_key, timeout == -1 ? nullptr : &timeout,
pdb_info.debug_file, pdb_info.debug_identifier, symbol_file, force);
pdb_info.debug_file, pdb_info.debug_identifier, symbol_file,
kSymbolUploadTypeBreakpad, force);
} else {
printUsageAndExit();
}