Add support for product_name in Mac sym_upload v2

Change-Id: I6fab9f62434fd19eb7aea4a66f0dd809af57e595
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3436859
Reviewed-by: Nelson Billing <nbilling@google.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Nathan Scoglio 2022-02-04 14:24:50 -08:00 committed by Nelson Billing
parent 3123f102ff
commit 7685201906
3 changed files with 28 additions and 15 deletions

View file

@ -96,7 +96,8 @@ typedef NS_ENUM(NSInteger, SymbolStatus) {
withUploadKey:(NSString*)uploadKey withUploadKey:(NSString*)uploadKey
withDebugFile:(NSString*)debugFile withDebugFile:(NSString*)debugFile
withDebugID:(NSString*)debugID withDebugID:(NSString*)debugID
withType:(NSString*)type; withType:(NSString*)type
withProductName:(NSString*)productName;
@end @end

View file

@ -190,18 +190,22 @@
withUploadKey:(NSString*)uploadKey withUploadKey:(NSString*)uploadKey
withDebugFile:(NSString*)debugFile withDebugFile:(NSString*)debugFile
withDebugID:(NSString*)debugID withDebugID:(NSString*)debugID
withType:(NSString*)type { withType:(NSString*)type
withProductName:(NSString*)productName {
NSURL* URL = [NSURL NSURL* URL = [NSURL
URLWithString:[NSString URLWithString:[NSString
stringWithFormat:@"%@/v1/uploads/%@:complete?key=%@", stringWithFormat:@"%@/v1/uploads/%@:complete?key=%@",
APIURL, uploadKey, APIKey]]; APIURL, uploadKey, APIKey]];
NSDictionary* symbolIdDictionary = NSMutableDictionary* jsonDictionary = [@{
[NSDictionary dictionaryWithObjectsAndKeys:debugFile, @"debug_file", @"symbol_id" : @{@"debug_file" : debugFile, @"debug_id" : debugID},
debugID, @"debug_id", nil]; @"symbol_upload_type" : type
NSDictionary* jsonDictionary = [NSDictionary } mutableCopy];
dictionaryWithObjectsAndKeys:symbolIdDictionary, @"symbol_id", type,
@"symbol_upload_type", nil]; if (productName != nil) {
jsonDictionary[@"metadata"] = @{@"product_name": productName};
}
NSError* error = nil; NSError* error = nil;
NSData* jsonData = NSData* jsonData =
[NSJSONSerialization dataWithJSONObject:jsonDictionary [NSJSONSerialization dataWithJSONObject:jsonDictionary

View file

@ -73,6 +73,7 @@ typedef struct {
NSString* type; NSString* type;
NSString* codeFile; NSString* codeFile;
NSString* debugID; NSString* debugID;
NSString* productName;
} Options; } Options;
//============================================================================= //=============================================================================
@ -212,7 +213,8 @@ static void StartSymUploadProtocolV2(Options* options,
withUploadKey:[URLResponse uploadKey] withUploadKey:[URLResponse uploadKey]
withDebugFile:debugFile withDebugFile:debugFile
withDebugID:debugID withDebugID:debugID
withType:options->type]; withType:options->type
withProductName:options->productName];
[URLResponse release]; [URLResponse release];
if (completeUploadResult == CompleteUploadResultError) { if (completeUploadResult == CompleteUploadResultError) {
fprintf(stdout, "Failed to complete upload.\n"); fprintf(stdout, "Failed to complete upload.\n");
@ -271,18 +273,20 @@ static void Usage(int argc, const char* argv[]) {
"[Only in sym-upload-v2 protocol mode]\n"); "[Only in sym-upload-v2 protocol mode]\n");
fprintf( fprintf(
stderr, stderr,
"-t:\t <symbol-type> Explicitly set symbol upload type (" "\t-t: <symbol-type> Explicitly set symbol upload type ("
"default is 'breakpad').\n" "default is 'breakpad').\n"
"\t One of ['breakpad', 'elf', 'pe', 'macho', 'debug_only', 'dwp', " "\t One of ['breakpad', 'elf', 'pe', 'macho', 'debug_only', 'dwp', "
"'dsym', 'pdb'].\n" "'dsym', 'pdb'].\n"
"\t Note: When this flag is set to anything other than 'breakpad', then " "\t Note: When this flag is set to anything other than 'breakpad', then "
"the '-c' and '-i' flags must also be set.\n"); "the '-c' and '-i' flags must also be set.\n");
fprintf(stderr, "-c:\t <code-file> Explicitly set 'code_file' for symbol " fprintf(stderr, "\t-c: <code-file> Explicitly set 'code_file' for symbol "
"upload (basename of executable).\n"); "upload (basename of executable).\n");
fprintf(stderr, "-i:\t <debug-id> Explicitly set 'debug_id' for symbol " fprintf(stderr, "\t-i: <debug-id> Explicitly set 'debug_id' for symbol "
"upload (typically build ID of executable). The debug-id for " "upload (typically build ID of executable). The debug-id for "
"symbol-types 'dsym' and 'macho' will be determined " "symbol-types 'dsym' and 'macho' will be determined "
"automatically. \n"); "automatically. \n");
fprintf(stderr, "\t-n: <product-name> Optionally set 'product_name' for "
"symbol upload\n");
fprintf(stderr, "\t-h: Usage\n"); fprintf(stderr, "\t-h: Usage\n");
fprintf(stderr, "\t-?: Usage\n"); fprintf(stderr, "\t-?: Usage\n");
fprintf(stderr, "\n"); fprintf(stderr, "\n");
@ -329,11 +333,12 @@ static void SetupOptions(int argc, const char* argv[], Options* options) {
options->codeFile = nil; options->codeFile = nil;
options->debugID = nil; options->debugID = nil;
options->force = NO; options->force = NO;
options->productName = nil;
extern int optind; extern int optind;
int ch; int ch;
while ((ch = getopt(argc, (char* const*)argv, "p:k:t:c:i:hf?")) != -1) { while ((ch = getopt(argc, (char* const*)argv, "p:k:t:c:i:n:hf?")) != -1) {
switch (ch) { switch (ch) {
case 'p': case 'p':
if (strcmp(optarg, "sym-upload-v2") == 0) { if (strcmp(optarg, "sym-upload-v2") == 0) {
@ -362,12 +367,15 @@ static void SetupOptions(int argc, const char* argv[], Options* options) {
case 'c': case 'c':
options->codeFile = [NSString stringWithCString:optarg options->codeFile = [NSString stringWithCString:optarg
encoding:NSASCIIStringEncoding]; encoding:NSASCIIStringEncoding];
;
break; break;
case 'i': case 'i':
options->debugID = [NSString stringWithCString:optarg options->debugID = [NSString stringWithCString:optarg
encoding:NSASCIIStringEncoding]; encoding:NSASCIIStringEncoding];
; break;
case 'n':
options->productName =
[NSString stringWithCString:optarg
encoding:NSASCIIStringEncoding];
break; break;
case 'f': case 'f':
options->force = YES; options->force = YES;