Add product name metadata to converter and symupload.

Change-Id: Iefea0aea13deb86d71d663c8344a2d3c658caf4a
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3756171
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
This commit is contained in:
Nelson Billing 2022-08-10 13:01:24 -07:00
parent e085b3b50b
commit cb55d48154
6 changed files with 27 additions and 11 deletions

View File

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

View File

@ -48,6 +48,8 @@ namespace google_breakpad {
// "DSYM"
// "PDB"
// "SOURCE_MAP"
// If |product_name| is non-empty then it will be sent as part of the symbol
// metadata.
// 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,
@ -57,6 +59,7 @@ bool SymUploadV2ProtocolSend(const wchar_t* api_url,
const std::wstring& debug_id,
const std::wstring& symbol_filename,
const std::wstring& symbol_type,
const std::wstring& product_name,
bool force);
} // namespace google_breakpad

View File

@ -71,7 +71,8 @@ namespace google_breakpad {
const wstring& upload_key,
const wstring& debug_file,
const wstring& debug_id,
const wstring& type) {
const wstring& type,
const wstring& product_name) {
wstring url = api_url +
L"/v1/uploads/" + upload_key + L":complete"
L"?key=" + api_key;
@ -83,11 +84,18 @@ namespace google_breakpad {
L"debug_id: \"" +
debug_id +
L"\" "
L"}, "
L"symbol_upload_type: \"" +
type +
L"\", "
L"use_async_processing: true }";
L"}, ";
if (!product_name.empty()) {
body +=
L"metadata: {"
L"product_name: \"" +
product_name +
L"\""
L"},";
}
body += L"symbol_upload_type: \"" + type +
L"\", "
L"use_async_processing: true }";
wstring response;
int response_code;

View File

@ -75,7 +75,8 @@ namespace google_breakpad {
const wstring& upload_key,
const wstring& debug_file,
const wstring& debug_id,
const wstring& type);
const wstring& type,
const wstring& product_name);
// Returns whether or not a symbol file corresponding to the debug_file/
// debug_id pair is already present in symbol storage.

View File

@ -69,6 +69,7 @@ const char* kNoExeMSSSServer = "http://msdl.microsoft.com/download/symbols/";
const wchar_t* kSymbolUploadTypeBreakpad = L"BREAKPAD";
const wchar_t* kSymbolUploadTypePE = L"PE";
const wchar_t* kSymbolUploadTypePDB = L"PDB";
const wchar_t* kConverterProductName = L"WinSymConv";
// 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
@ -242,7 +243,7 @@ static bool UploadSymbolFile(const wstring& upload_symbol_url,
FprintfFlush(stderr, "Uploading %s\n", symbol_file.c_str());
if (!google_breakpad::SymUploadV2ProtocolSend(
upload_symbol_url.c_str(), api_key.c_str(), &timeout_ms, debug_file_w,
debug_id_w, symbol_file_w, symbol_type,
debug_id_w, symbol_file_w, symbol_type, kConverterProductName,
/*force=*/true)) {
FprintfFlush(stderr,
"UploadSymbolFile: HTTPUpload::SendRequest failed "
@ -647,7 +648,7 @@ static bool ReadFile(string file_name, string* contents) {
static bool ConvertMissingSymbolsList(const ConverterOptions& options) {
// Set param to indicate requesting for encoded response.
map<wstring, wstring> parameters;
parameters[L"product"] = L"WinSymConv";
parameters[L"product"] = kConverterProductName;
parameters[L"encoded"] = L"true";
// Get the missing symbol list.
string missing_symbol_list;

View File

@ -250,11 +250,12 @@ int wmain(int argc, wchar_t* argv[]) {
if (argc >= currentarg + 2) {
api_url = argv[currentarg++];
api_key = argv[currentarg++];
wstring product_name = product ? wstring(product) : L"";
success = google_breakpad::SymUploadV2ProtocolSend(
api_url, api_key, timeout == -1 ? nullptr : &timeout,
pdb_info.debug_file, pdb_info.debug_identifier, symbol_file,
kSymbolUploadTypeBreakpad, force);
kSymbolUploadTypeBreakpad, product_name, force);
} else {
printUsageAndExit();
}