Fix Mac symupload non-XCode builds.

Change-Id: Ic4924032faba83fc14f62feaac9a97bbfd0971ed
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2324311
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Nelson Billing 2020-07-29 16:28:25 -07:00
parent 28d7cbdd42
commit a740aa2625
17 changed files with 426 additions and 404 deletions

View file

@ -1,4 +1,4 @@
// Copyright (c) 2019, Google Inc.
// Copyright (c) 2020, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without

View file

@ -1,4 +1,4 @@
// Copyright (c) 2019, Google Inc.
// Copyright (c) 2020, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without

View file

@ -27,8 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
#import "HTTPRequest.h"

View file

@ -30,7 +30,7 @@
#import "HTTPMultipartUpload.h"
#import "GTMDefines.h"
#import "util.h"
#import "encoding_util.h"
@interface HTTPMultipartUpload (PrivateMethods)
- (NSString*)multipartBoundary;
@ -48,8 +48,8 @@
//=============================================================================
- (NSString*)multipartBoundary {
// The boundary has 27 '-' characters followed by 16 hex digits
return [NSString stringWithFormat:@"---------------------------%08X%08X",
rand(), rand()];
return [NSString
stringWithFormat:@"---------------------------%08X%08X", rand(), rand()];
}
//=============================================================================
@ -58,8 +58,7 @@
[self appendBoundaryData:data];
NSString* escaped = PercentEncodeNSString(key);
NSString *fmt =
@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n%@\r\n";
NSString* fmt = @"Content-Disposition: form-data; name=\"%@\"\r\n\r\n%@\r\n";
NSString* form = [NSString stringWithFormat:fmt, boundary_, escaped, value];
[data appendData:[form dataUsingEncoding:NSUTF8StringEncoding]];
@ -131,8 +130,8 @@
//=============================================================================
- (NSString*)contentType {
return [NSString stringWithFormat:@"multipart/form-data; boundary=%@",
boundary_];
return [NSString
stringWithFormat:@"multipart/form-data; boundary=%@", boundary_];
}
//=============================================================================

View file

@ -1,4 +1,4 @@
// Copyright (c) 2019, Google Inc.
// Copyright (c) 2020, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without

View file

@ -1,4 +1,4 @@
// Copyright (c) 2019, Google Inc.
// Copyright (c) 2020, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without

View file

@ -1,4 +1,4 @@
// Copyright (c) 2019, Google Inc.
// Copyright (c) 2020, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without

View file

@ -1,4 +1,4 @@
// Copyright (c) 2019, Google Inc.
// Copyright (c) 2020, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -29,7 +29,10 @@
#import "HTTPRequest.h"
#import "util.h"
#include <Availability.h>
#include <AvailabilityMacros.h>
#import "encoding_util.h"
// As -[NSURLConnection sendSynchronousRequest:returningResponse:error:] has
// been deprecated with iOS 9.0 / OS X 10.11 SDKs, this function re-implements
@ -47,15 +50,13 @@ MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11)
__block NSError* error = nil;
__block NSURLResponse* response = nil;
dispatch_semaphore_t waitSemaphone = dispatch_semaphore_create(0);
NSURLSessionConfiguration* config = [NSURLSessionConfiguration
defaultSessionConfiguration];
NSURLSessionConfiguration* config =
[NSURLSessionConfiguration defaultSessionConfiguration];
[config setTimeoutIntervalForRequest:240.0];
NSURLSession* session = [NSURLSession sessionWithConfiguration:config];
[[session
dataTaskWithRequest:req
completionHandler:^(NSData *data,
NSURLResponse *resp,
NSError *err) {
completionHandler:^(NSData* data, NSURLResponse* resp, NSError* err) {
if (outError)
error = [err retain];
if (outResponse)
@ -109,7 +110,8 @@ MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11)
//=============================================================================
- (NSString*)HTTPMethod {
@throw [NSException exceptionWithName:NSInternalInconsistencyException
@throw [NSException
exceptionWithName:NSInternalInconsistencyException
reason:[NSString stringWithFormat:@"You must"
"override %@ in a subclass",
NSStringFromSelector(_cmd)]
@ -128,8 +130,7 @@ MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11)
//=============================================================================
- (NSData*)send:(NSError**)withError {
NSMutableURLRequest *req =
[[NSMutableURLRequest alloc]
NSMutableURLRequest* req = [[NSMutableURLRequest alloc]
initWithURL:URL_
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
@ -163,8 +164,7 @@ MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11)
}
//=============================================================================
+ (NSData *)formDataForFileContents:(NSData *)contents
withName:(NSString *)name {
+ (NSData*)formDataForFileContents:(NSData*)contents withName:(NSString*)name {
NSMutableData* data = [NSMutableData data];
NSString* escaped = PercentEncodeNSString(name);
NSString* fmt = @"Content-Disposition: form-data; name=\"%@\"; "
@ -188,8 +188,7 @@ MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11)
//=============================================================================
+ (NSData*)formDataForKey:(NSString*)key value:(NSString*)value {
NSString* escaped = PercentEncodeNSString(key);
NSString *fmt =
@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n%@\r\n";
NSString* fmt = @"Content-Disposition: form-data; name=\"%@\"\r\n\r\n%@\r\n";
NSString* form = [NSString stringWithFormat:fmt, escaped, value];
return [form dataUsingEncoding:NSUTF8StringEncoding];

View file

@ -1,4 +1,4 @@
// Copyright (c) 2019, Google Inc.
// Copyright (c) 2020, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without

View file

@ -1,4 +1,4 @@
// Copyright (c) 2019, Google Inc.
// Copyright (c) 2020, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without

View file

@ -1,4 +1,4 @@
// Copyright (c) 2019, Google Inc.
// Copyright (c) 2020, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -32,7 +32,8 @@
NS_ASSUME_NONNULL_BEGIN
/**
Represents a response from a sym-upload-v2 server to a CreateUploadURL call.
Represents a response from a sym-upload-v2 server to a createUploadURLOnServer
call.
*/
@interface UploadURLResponse : NSObject {
@protected
@ -40,15 +41,15 @@ NS_ASSUME_NONNULL_BEGIN
NSString* uploadKey_;
}
- (id)initWithUploadURL:(NSString*)uploadURL
withUploadKey:(NSString*)uploadKey;
- (id)initWithUploadURL:(NSString*)uploadURL withUploadKey:(NSString*)uploadKey;
- (NSString*)uploadURL;
- (NSString*)uploadKey;
@end
/**
Possible return statuses from a sym-upload-v2 server to a CompleteUpload call.
Possible return statuses from a sym-upload-v2 server to a
completeUploadOnServer call.
*/
typedef NS_ENUM(NSInteger, CompleteUploadResult) {
CompleteUploadResultOk,
@ -57,8 +58,8 @@ typedef NS_ENUM(NSInteger, CompleteUploadResult) {
};
/**
Possible return statuses from a sym-upload-v2 server to a CheckSymbolStatus
call.
Possible return statuses from a sym-upload-v2 server to a
checkSymbolStatusOnServer call.
*/
typedef NS_ENUM(NSInteger, SymbolStatus) {
SymbolStatusFound,
@ -70,26 +71,27 @@ typedef NS_ENUM(NSInteger, SymbolStatus) {
Interface to help a client interact with a sym-upload-v2 server, over HTTP.
For details of the API and protocol, see :/docs/sym_upload_v2_protocol.md.
*/
@interface SymbolCollectorClient : NSObject;
@interface SymbolCollectorClient : NSObject
;
/**
Call the CheckSymbolstatus API on the server.
Calls the /v1/symbols/{debug_file}/{debug_id}:checkStatus API on the server.
*/
+ (SymbolStatus)CheckSymbolStatus:(NSString*)APIURL
+ (SymbolStatus)checkSymbolStatusOnServer:(NSString*)APIURL
withAPIKey:(NSString*)APIKey
withDebugFile:(NSString*)debugFile
withDebugID:(NSString*)debugID;
/**
Call the CreateUploadURL API on the server.
Calls the /v1/uploads:create API on the server.
*/
+ (UploadURLResponse*)CreateUploadURL:(NSString*)APIURL
+ (UploadURLResponse*)createUploadURLOnServer:(NSString*)APIURL
withAPIKey:(NSString*)APIKey;
/**
Call the CompleteUpload API on the server.
Calls the /v1/uploads/{key}:complete API on the server.
*/
+ (CompleteUploadResult)CompleteUpload:(NSString*)APIURL
+ (CompleteUploadResult)completeUploadOnServer:(NSString*)APIURL
withAPIKey:(NSString*)APIKey
withUploadKey:(NSString*)uploadKey
withDebugFile:(NSString*)debugFile

View file

@ -1,4 +1,4 @@
// Copyright (c) 2019, Google Inc.
// Copyright (c) 2020, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -66,17 +66,15 @@
@implementation SymbolCollectorClient
//=============================================================================
+ (SymbolStatus)CheckSymbolStatus:(NSString *)APIURL
+ (SymbolStatus)checkSymbolStatusOnServer:(NSString*)APIURL
withAPIKey:(NSString*)APIKey
withDebugFile:(NSString*)debugFile
withDebugID:(NSString*)debugID {
NSURL* URL = [NSURL URLWithString:[NSString stringWithFormat:
@"%@/v1/symbols/%@/%@:checkStatus"
NSURL* URL = [NSURL
URLWithString:[NSString
stringWithFormat:@"%@/v1/symbols/%@/%@:checkStatus"
@"?key=%@",
APIURL,
debugFile,
debugID,
APIKey]];
APIURL, debugFile, debugID, APIKey]];
HTTPGetRequest* getRequest = [[HTTPGetRequest alloc] initWithURL:URL];
NSError* error = nil;
@ -96,12 +94,11 @@
error = nil;
NSRegularExpression* statusRegex = [NSRegularExpression
regularExpressionWithPattern:
@"\"status\": \"([^\"]+)\""
regularExpressionWithPattern:@"\"status\": \"([^\"]+)\""
options:0
error:&error];
NSArray* matches = [statusRegex
matchesInString:result
NSArray* matches =
[statusRegex matchesInString:result
options:0
range:NSMakeRange(0, [result length])];
if ([matches count] != 1) {
@ -114,21 +111,19 @@
NSString* status = [result substringWithRange:[matches[0] rangeAtIndex:1]];
[result release];
return [status isEqualToString:@"FOUND"] ?
SymbolStatusFound :
SymbolStatusMissing;
return [status isEqualToString:@"FOUND"] ? SymbolStatusFound
: SymbolStatusMissing;
}
//=============================================================================
+ (UploadURLResponse *)CreateUploadURL:(NSString *)APIURL
+ (UploadURLResponse*)createUploadURLOnServer:(NSString*)APIURL
withAPIKey:(NSString*)APIKey {
NSURL* URL = [NSURL URLWithString:[NSString stringWithFormat:
@"%@/v1/uploads:create?key=%@",
APIURL,
APIKey]];
NSURL* URL = [NSURL
URLWithString:[NSString stringWithFormat:@"%@/v1/uploads:create?key=%@",
APIURL, APIKey]];
HTTPSimplePostRequest* postRequest = [[HTTPSimplePostRequest alloc]
initWithURL:URL];
HTTPSimplePostRequest* postRequest =
[[HTTPSimplePostRequest alloc] initWithURL:URL];
NSError* error = nil;
NSData* data = [postRequest send:&error];
NSString* result = [[NSString alloc] initWithData:data
@ -146,22 +141,20 @@
// Note camel-case rather than underscores.
NSRegularExpression* uploadURLRegex = [NSRegularExpression
regularExpressionWithPattern:
@"\"uploadUrl\": \"([^\"]+)\""
regularExpressionWithPattern:@"\"uploadUrl\": \"([^\"]+)\""
options:0
error:&error];
NSRegularExpression* uploadKeyRegex = [NSRegularExpression
regularExpressionWithPattern:
@"\"uploadKey\": \"([^\"]+)\""
regularExpressionWithPattern:@"\"uploadKey\": \"([^\"]+)\""
options:0
error:&error];
NSArray* uploadURLMatches = [uploadURLRegex
matchesInString:result
NSArray* uploadURLMatches =
[uploadURLRegex matchesInString:result
options:0
range:NSMakeRange(0, [result length])];
NSArray* uploadKeyMatches = [uploadKeyRegex
matchesInString:result
NSArray* uploadKeyMatches =
[uploadKeyRegex matchesInString:result
options:0
range:NSMakeRange(0, [result length])];
if ([uploadURLMatches count] != 1 || [uploadKeyMatches count] != 1) {
@ -170,35 +163,32 @@
fprintf(stdout, "%s\n", [result UTF8String]);
return nil;
}
NSString* uploadURL = [result
substringWithRange:[uploadURLMatches[0]
rangeAtIndex:1]];
NSString* uploadKey = [result
substringWithRange:[uploadKeyMatches[0]
rangeAtIndex:1]];
NSString* uploadURL =
[result substringWithRange:[uploadURLMatches[0] rangeAtIndex:1]];
NSString* uploadKey =
[result substringWithRange:[uploadKeyMatches[0] rangeAtIndex:1]];
return [[UploadURLResponse alloc] initWithUploadURL:uploadURL
withUploadKey:uploadKey];
}
//=============================================================================
+ (CompleteUploadResult)CompleteUpload:(NSString *)APIURL
+ (CompleteUploadResult)completeUploadOnServer:(NSString*)APIURL
withAPIKey:(NSString*)APIKey
withUploadKey:(NSString*)uploadKey
withDebugFile:(NSString*)debugFile
withDebugID:(NSString*)debugID {
NSURL* URL = [NSURL URLWithString:[NSString stringWithFormat:
@"%@/v1/uploads/%@:complete?key=%@",
APIURL,
uploadKey,
APIKey]];
NSString* body = [NSString stringWithFormat:
NSURL* URL = [NSURL
URLWithString:[NSString
stringWithFormat:@"%@/v1/uploads/%@:complete?key=%@",
APIURL, uploadKey, APIKey]];
NSString* body =
[NSString stringWithFormat:
@"{ symbol_id: { debug_file: \"%@\", debug_id: \"%@\" } }",
debugFile,
debugID];
debugFile, debugID];
HTTPSimplePostRequest* postRequest = [[HTTPSimplePostRequest alloc]
initWithURL:URL];
HTTPSimplePostRequest* postRequest =
[[HTTPSimplePostRequest alloc] initWithURL:URL];
[postRequest setBody:body];
[postRequest setContentType:@"application/json"];
@ -219,13 +209,12 @@
// Note camel-case rather than underscores.
NSRegularExpression* completeResultRegex = [NSRegularExpression
regularExpressionWithPattern:
@"\"result\": \"([^\"]+)\""
regularExpressionWithPattern:@"\"result\": \"([^\"]+)\""
options:0
error:&error];
NSArray* completeResultMatches = [completeResultRegex
matchesInString:result
NSArray* completeResultMatches =
[completeResultRegex matchesInString:result
options:0
range:NSMakeRange(0, [result length])];
@ -233,15 +222,14 @@
fprintf(stdout, "Failed to parse complete upload response.");
fprintf(stdout, "Response:\n");
fprintf(stdout, "%s\n", [result UTF8String]);
return nil;
return CompleteUploadResultError;
}
NSString* completeResult = [result
substringWithRange:[completeResultMatches[0]
rangeAtIndex:1]];
NSString* completeResult =
[result substringWithRange:[completeResultMatches[0] rangeAtIndex:1]];
[result release];
return ([completeResult isEqualToString:@"DUPLICATE_DATA"]) ?
CompleteUploadResultDuplicateData :
CompleteUploadResultOk;
return ([completeResult isEqualToString:@"DUPLICATE_DATA"])
? CompleteUploadResultDuplicateData
: CompleteUploadResultOk;
}
@end

View file

@ -1,4 +1,4 @@
// Copyright (c) 2019, Google Inc.
// Copyright (c) 2020, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -27,8 +27,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef util_h
#define util_h
#ifndef GOOGLE_BREAKPAD_COMMON_MAC_ENCODING_UTIL_H
#define GOOGLE_BREAKPAD_COMMON_MAC_ENCODING_UTIL_H
#import <Foundation/Foundation.h>
@ -36,17 +36,6 @@
// deprecated with iOS 9.0 / OS X 10.11 SDKs, this function re-implements it
// using -[NSString stringByAddingPercentEncodingWithAllowedCharacters:] when
// using those SDKs.
static NSString *PercentEncodeNSString(NSString *key) {
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && defined(__IPHONE_9_0) && \
__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0) || \
(defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \
defined(MAC_OS_X_VERSION_10_11) && \
MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11)
return [key stringByAddingPercentEncodingWithAllowedCharacters:
[NSCharacterSet URLQueryAllowedCharacterSet]];
#else
return [key stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
#endif
}
NSString* PercentEncodeNSString(NSString* key);
#endif /* util_h */
#endif // GOOGLE_BREAKPAD_COMMON_MAC_ENCODING_UTIL_H

View file

@ -0,0 +1,47 @@
// Copyright (c) 2020, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "encoding_util.h"
#include <Availability.h>
#include <AvailabilityMacros.h>
#import <Foundation/Foundation.h>
NSString* PercentEncodeNSString(NSString* key) {
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && defined(__IPHONE_9_0) && \
__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0) || \
(defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \
defined(MAC_OS_X_VERSION_10_11) && \
MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11)
return [key stringByAddingPercentEncodingWithAllowedCharacters:
[NSCharacterSet URLQueryAllowedCharacterSet]];
#else
return [key stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
#endif
}

View file

@ -77,11 +77,12 @@ static void Start(Options *options) {
}
//=============================================================================
static void
Usage(int argc, const char *argv[]) {
static void Usage(int argc, const char* argv[]) {
fprintf(stderr, "Submit minidump information.\n");
fprintf(stderr, "Usage: %s -p <product> -v <version> <minidump> "
"<upload-URL>\n", argv[0]);
fprintf(stderr,
"Usage: %s -p <product> -v <version> <minidump> "
"<upload-URL>\n",
argv[0]);
fprintf(stderr, "<minidump> should be a minidump.\n");
fprintf(stderr, "<upload-URL> is the destination for the upload\n");
@ -90,8 +91,7 @@ Usage(int argc, const char *argv[]) {
}
//=============================================================================
static void
SetupOptions(int argc, const char *argv[], Options *options) {
static void SetupOptions(int argc, const char* argv[], Options* options) {
extern int optind;
char ch;

View file

@ -48,10 +48,7 @@
#include "HTTPPutRequest.h"
#include "SymbolCollectorClient.h"
typedef enum {
SymUploadProtocolV1,
SymUploadProtocolV2
} SymUploadProtocol;
typedef enum { SymUploadProtocolV1, SymUploadProtocolV2 } SymUploadProtocol;
typedef struct {
NSString* symbolsPath;
@ -66,7 +63,8 @@ typedef struct {
static NSArray* ModuleDataForSymbolFile(NSString* file) {
NSFileHandle* fh = [NSFileHandle fileHandleForReadingAtPath:file];
NSData* data = [fh readDataOfLength:1024];
NSString *str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString* str = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
NSScanner* scanner = [NSScanner scannerWithString:str];
NSString* line;
NSMutableArray* parts = nil;
@ -118,8 +116,7 @@ static void StartSymUploadProtocolV1(Options* options,
for (int i = 0; i < count; ++i) {
NSString* key = [keys objectAtIndex:i];
NSString* value = [parameters objectForKey:key];
fprintf(stdout, "'%s' = '%s'\n", [key UTF8String],
[value UTF8String]);
fprintf(stdout, "'%s' = '%s'\n", [key UTF8String], [value UTF8String]);
}
// Add file
@ -132,11 +129,11 @@ static void StartSymUploadProtocolV1(Options* options,
encoding:NSUTF8StringEncoding];
int status = [[ul response] statusCode];
fprintf(stdout, "Send: %s\n", error ? [[error description] UTF8String] :
"No Error");
fprintf(stdout, "Send: %s\n",
error ? [[error description] UTF8String] : "No Error");
fprintf(stdout, "Response: %d\n", status);
fprintf(stdout, "Result: %lu bytes\n%s\n",
(unsigned long)[data length], [result UTF8String]);
fprintf(stdout, "Result: %lu bytes\n%s\n", (unsigned long)[data length],
[result UTF8String]);
[result release];
[ul release];
@ -145,18 +142,20 @@ static void StartSymUploadProtocolV1(Options* options,
//=============================================================================
static void StartSymUploadProtocolV2(Options* options,
NSString* debugFile,
NSArray* moduleParts,
NSString* debugID) {
options->success = NO;
NSString* debugFile = [moduleParts objectAtIndex:4];
if (!options->force) {
SymbolStatus symbolStatus = [SymbolCollectorClient
CheckSymbolStatus:options->uploadURLStr
SymbolStatus symbolStatus =
[SymbolCollectorClient checkSymbolStatusOnServer:options->uploadURLStr
withAPIKey:options->apiKey
withDebugFile:debugFile
withDebugID:debugID];
if (symbolStatus == SymbolStatusFound) {
fprintf(stdout, "Symbol file already exists, upload aborted."
" Use \"-f\" to overwrite.\n");
options->success = YES;
return;
} else if (symbolStatus == SymbolStatusUnknown) {
fprintf(stdout, "Failed to get check for existing symbol.\n");
@ -164,16 +163,15 @@ static void StartSymUploadProtocolV2(Options* options,
}
}
UploadURLResponse* URLResponse = [SymbolCollectorClient
CreateUploadURL:options->uploadURLStr
UploadURLResponse* URLResponse =
[SymbolCollectorClient createUploadURLOnServer:options->uploadURLStr
withAPIKey:options->apiKey];
if (URLResponse == nil) {
return;
}
NSURL* uploadURL = [NSURL URLWithString:[URLResponse uploadURL]];
HTTPPutRequest* putRequest = [[HTTPPutRequest alloc]
initWithURL:uploadURL];
HTTPPutRequest* putRequest = [[HTTPPutRequest alloc] initWithURL:uploadURL];
[putRequest setFile:options->symbolsPath];
NSError* error = nil;
@ -191,8 +189,8 @@ static void StartSymUploadProtocolV2(Options* options,
return;
}
CompleteUploadResult completeUploadResult = [SymbolCollectorClient
CompleteUpload:options->uploadURLStr
CompleteUploadResult completeUploadResult =
[SymbolCollectorClient completeUploadOnServer:options->uploadURLStr
withAPIKey:options->apiKey
withUploadKey:[URLResponse uploadKey]
withDebugFile:debugFile
@ -215,21 +213,20 @@ static void Start(Options *options) {
NSArray* moduleParts = ModuleDataForSymbolFile(options->symbolsPath);
NSMutableString* compactedID =
[NSMutableString stringWithString:[moduleParts objectAtIndex:3]];
[compactedID replaceOccurrencesOfString:@"-" withString:@"" options:0
[compactedID replaceOccurrencesOfString:@"-"
withString:@""
options:0
range:NSMakeRange(0, [compactedID length])];
if (options->symUploadProtocol == SymUploadProtocolV1) {
StartSymUploadProtocolV1(options, moduleParts, compactedID);
} else if (options->symUploadProtocol == SymUploadProtocolV2) {
StartSymUploadProtocolV2(options,
[moduleParts objectAtIndex:4],
compactedID);
StartSymUploadProtocolV2(options, moduleParts, compactedID);
}
}
//=============================================================================
static void
Usage(int argc, const char *argv[]) {
static void Usage(int argc, const char* argv[]) {
fprintf(stderr, "Submit symbol information.\n");
fprintf(stderr, "Usage: %s [options] <symbol-file> <upload-URL>\n", argv[0]);
fprintf(stderr, "<symbol-file> should be created by using the dump_syms "
@ -248,8 +245,7 @@ Usage(int argc, const char *argv[]) {
}
//=============================================================================
static void
SetupOptions(int argc, const char *argv[], Options *options) {
static void SetupOptions(int argc, const char* argv[], Options* options) {
// Set default value of symUploadProtocol.
options->symUploadProtocol = SymUploadProtocolV1;

View file

@ -12,6 +12,7 @@
5B6060C7222735E50015F0A0 /* HTTPGetRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B6060C6222735E50015F0A0 /* HTTPGetRequest.m */; };
5B6060CA2227374E0015F0A0 /* HTTPSimplePostRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B6060C92227374E0015F0A0 /* HTTPSimplePostRequest.m */; };
5B6060D022273BDA0015F0A0 /* SymbolCollectorClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B6060CF22273BDA0015F0A0 /* SymbolCollectorClient.m */; };
5B97447524D0AA5F000C71F5 /* encoding_util.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B97447424D0AA5F000C71F5 /* encoding_util.m */; };
8B31022C11F0CEBD00FCF3E4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; };
8DD76F9A0486AA7600D96B5E /* symupload.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* symupload.m */; settings = {ATTRIBUTES = (); }; };
8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; };
@ -37,17 +38,18 @@
/* Begin PBXFileReference section */
08FB7796FE84155DC02AAC07 /* symupload.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; path = symupload.m; sourceTree = "<group>"; tabWidth = 2; };
08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
5B6060BB222716FC0015F0A0 /* HTTPRequest.h */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.c.h; path = HTTPRequest.h; sourceTree = "<group>"; tabWidth = 2; };
5B6060BC222716FC0015F0A0 /* HTTPRequest.m */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; path = HTTPRequest.m; sourceTree = "<group>"; tabWidth = 2; };
5B6060BE2227201B0015F0A0 /* HTTPPutRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HTTPPutRequest.h; sourceTree = "<group>"; };
5B6060BF2227201B0015F0A0 /* HTTPPutRequest.m */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; path = HTTPPutRequest.m; sourceTree = "<group>"; tabWidth = 2; };
5B6060C22227303A0015F0A0 /* util.h */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.c.h; path = util.h; sourceTree = "<group>"; tabWidth = 2; };
5B6060C5222735E50015F0A0 /* HTTPGetRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HTTPGetRequest.h; sourceTree = "<group>"; };
5B6060C6222735E50015F0A0 /* HTTPGetRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HTTPGetRequest.m; sourceTree = "<group>"; };
5B6060C82227374E0015F0A0 /* HTTPSimplePostRequest.h */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.c.h; path = HTTPSimplePostRequest.h; sourceTree = "<group>"; tabWidth = 2; };
5B6060C92227374E0015F0A0 /* HTTPSimplePostRequest.m */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; path = HTTPSimplePostRequest.m; sourceTree = "<group>"; tabWidth = 2; };
5B6060CE22273BDA0015F0A0 /* SymbolCollectorClient.h */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.c.h; path = SymbolCollectorClient.h; sourceTree = "<group>"; tabWidth = 2; };
5B6060CF22273BDA0015F0A0 /* SymbolCollectorClient.m */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; path = SymbolCollectorClient.m; sourceTree = "<group>"; tabWidth = 2; };
5B6060BB222716FC0015F0A0 /* HTTPRequest.h */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = HTTPRequest.h; path = ../../../common/mac/HTTPRequest.h; sourceTree = "<group>"; tabWidth = 2; };
5B6060BC222716FC0015F0A0 /* HTTPRequest.m */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; name = HTTPRequest.m; path = ../../../common/mac/HTTPRequest.m; sourceTree = "<group>"; tabWidth = 2; };
5B6060BE2227201B0015F0A0 /* HTTPPutRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HTTPPutRequest.h; path = ../../../common/mac/HTTPPutRequest.h; sourceTree = "<group>"; };
5B6060BF2227201B0015F0A0 /* HTTPPutRequest.m */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; name = HTTPPutRequest.m; path = ../../../common/mac/HTTPPutRequest.m; sourceTree = "<group>"; tabWidth = 2; };
5B6060C22227303A0015F0A0 /* encoding_util.h */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = encoding_util.h; path = ../../../common/mac/encoding_util.h; sourceTree = "<group>"; tabWidth = 2; };
5B6060C5222735E50015F0A0 /* HTTPGetRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HTTPGetRequest.h; path = ../../../common/mac/HTTPGetRequest.h; sourceTree = "<group>"; };
5B6060C6222735E50015F0A0 /* HTTPGetRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = HTTPGetRequest.m; path = ../../../common/mac/HTTPGetRequest.m; sourceTree = "<group>"; };
5B6060C82227374E0015F0A0 /* HTTPSimplePostRequest.h */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = HTTPSimplePostRequest.h; path = ../../../common/mac/HTTPSimplePostRequest.h; sourceTree = "<group>"; tabWidth = 2; };
5B6060C92227374E0015F0A0 /* HTTPSimplePostRequest.m */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; name = HTTPSimplePostRequest.m; path = ../../../common/mac/HTTPSimplePostRequest.m; sourceTree = "<group>"; tabWidth = 2; };
5B6060CE22273BDA0015F0A0 /* SymbolCollectorClient.h */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = SymbolCollectorClient.h; path = ../../../common/mac/SymbolCollectorClient.h; sourceTree = "<group>"; tabWidth = 2; };
5B6060CF22273BDA0015F0A0 /* SymbolCollectorClient.m */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; name = SymbolCollectorClient.m; path = ../../../common/mac/SymbolCollectorClient.m; sourceTree = "<group>"; tabWidth = 2; };
5B97447424D0AA5F000C71F5 /* encoding_util.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = encoding_util.m; path = ../../../common/mac/encoding_util.m; sourceTree = "<group>"; };
8B31022B11F0CE6900FCF3E4 /* Breakpad.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Breakpad.xcconfig; path = ../../../common/mac/Breakpad.xcconfig; sourceTree = SOURCE_ROOT; };
8B3102B611F0D5CE00FCF3E4 /* BreakpadDebug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = BreakpadDebug.xcconfig; path = ../../../common/mac/BreakpadDebug.xcconfig; sourceTree = SOURCE_ROOT; };
8B3102B711F0D5CE00FCF3E4 /* BreakpadRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = BreakpadRelease.xcconfig; path = ../../../common/mac/BreakpadRelease.xcconfig; sourceTree = SOURCE_ROOT; };
@ -55,7 +57,7 @@
9BD833680B03E4080055103E /* HTTPMultipartUpload.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = HTTPMultipartUpload.h; path = ../../../common/mac/HTTPMultipartUpload.h; sourceTree = "<group>"; tabWidth = 2; };
9BD833690B03E4080055103E /* HTTPMultipartUpload.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; name = HTTPMultipartUpload.m; path = ../../../common/mac/HTTPMultipartUpload.m; sourceTree = "<group>"; tabWidth = 2; };
9BD835FB0B0544950055103E /* minidump_upload */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = minidump_upload; sourceTree = BUILT_PRODUCTS_DIR; };
9BD836000B0544BA0055103E /* minidump_upload.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = minidump_upload.m; sourceTree = "<group>"; };
9BD836000B0544BA0055103E /* minidump_upload.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = minidump_upload.m; path = ../../../common/mac/minidump_upload.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -87,7 +89,8 @@
5B6060C92227374E0015F0A0 /* HTTPSimplePostRequest.m */,
5B6060C5222735E50015F0A0 /* HTTPGetRequest.h */,
5B6060C6222735E50015F0A0 /* HTTPGetRequest.m */,
5B6060C22227303A0015F0A0 /* util.h */,
5B6060C22227303A0015F0A0 /* encoding_util.h */,
5B97447424D0AA5F000C71F5 /* encoding_util.m */,
5B6060BE2227201B0015F0A0 /* HTTPPutRequest.h */,
5B6060BF2227201B0015F0A0 /* HTTPPutRequest.m */,
5B6060BB222716FC0015F0A0 /* HTTPRequest.h */,
@ -194,6 +197,7 @@
5B6060C7222735E50015F0A0 /* HTTPGetRequest.m in Sources */,
5B6060C02227201B0015F0A0 /* HTTPPutRequest.m in Sources */,
5B6060BD222716FC0015F0A0 /* HTTPRequest.m in Sources */,
5B97447524D0AA5F000C71F5 /* encoding_util.m in Sources */,
9BD8336B0B03E4080055103E /* HTTPMultipartUpload.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;