Chromium Code Reviews| Index: src/common/linux/symbol_upload.cc |
| diff --git a/src/tools/linux/symupload/sym_upload.cc b/src/common/linux/symbol_upload.cc |
| similarity index 62% |
| copy from src/tools/linux/symupload/sym_upload.cc |
| copy to src/common/linux/symbol_upload.cc |
| index 2f9a73c39f8b6e2e8866e6462de264bb88c7605a..e7177d1982baaaf56d1e1d0ddd5b403a393fe208 100644 |
| --- a/src/tools/linux/symupload/sym_upload.cc |
| +++ b/src/common/linux/symbol_upload.cc |
| @@ -1,4 +1,4 @@ |
| -// Copyright (c) 2006, Google Inc. |
| +// Copyright (c) 2011 Google Inc. |
| // All rights reserved. |
| // |
| // Redistribution and use in source and binary forms, with or without |
| @@ -27,43 +27,22 @@ |
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| -// symupload.cc: Upload a symbol file to a HTTP server. The upload is sent as |
| -// a multipart/form-data POST request with the following parameters: |
| -// code_file: the basename of the module, e.g. "app" |
| -// debug_file: the basename of the debugging file, e.g. "app" |
| -// debug_identifier: the debug file's identifier, usually consisting of |
| -// the guid and age embedded in the pdb, e.g. |
| -// "11111111BBBB3333DDDD555555555555F" |
| -// version: the file version of the module, e.g. "1.2.3.4" |
| -// os: the operating system that the module was built for |
| -// cpu: the CPU that the module was built for |
| -// symbol_file: the contents of the breakpad-format symbol file |
| +// symbol_upload.cc: implemented google_breakpad::sym_upload::Start, a helper |
| +// function for linux symbol upload tool. |
| + |
| +#include "common/linux/http_upload.h" |
| +#include "common/linux/symbol_upload.h" |
| #include <assert.h> |
| #include <stdio.h> |
| -#include <stdlib.h> |
| -#include <unistd.h> |
| #include <functional> |
| -#include <iostream> |
| -#include <string> |
| #include <vector> |
| -#include "common/linux/http_upload.h" |
| -#include "common/using_std_string.h" |
| - |
| -using google_breakpad::HTTPUpload; |
| - |
| -typedef struct { |
| - string symbolsPath; |
| - string uploadURLStr; |
| - string proxy; |
| - string proxy_user_pwd; |
| - string version; |
| - bool success; |
| -} Options; |
| +namespace google_breakpad { |
| +namespace sym_upload { |
| -static void TokenizeByChar(const string &source_string, |
| +void TokenizeByChar(const string &source_string, |
| int c, std::vector<string> *results) { |
|
mmandlis
2016/03/30 18:34:40
nit, please, fix indentation.
|
| assert(results); |
| string::size_type cur_pos = 0, next_pos = 0; |
| @@ -79,7 +58,7 @@ static void TokenizeByChar(const string &source_string, |
| //============================================================================= |
| // Parse out the module line which have 5 parts. |
| // MODULE <os> <cpu> <uuid> <module-name> |
| -static bool ModuleDataForSymbolFile(const string &file, |
| +bool ModuleDataForSymbolFile(const string &file, |
| std::vector<string> *module_parts) { |
|
mmandlis
2016/03/30 18:34:40
nit, please, fix indentation.
|
| assert(module_parts); |
| const size_t kModulePartNumber = 5; |
| @@ -107,7 +86,7 @@ static bool ModuleDataForSymbolFile(const string &file, |
| } |
| //============================================================================= |
| -static string CompactIdentifier(const string &uuid) { |
| +string CompactIdentifier(const string &uuid) { |
| std::vector<string> components; |
| TokenizeByChar(uuid, '-', &components); |
| string result; |
| @@ -117,7 +96,7 @@ static string CompactIdentifier(const string &uuid) { |
| } |
| //============================================================================= |
| -static void Start(Options *options) { |
| +void Start(Options *options) { |
| std::map<string, string> parameters; |
| options->success = false; |
| std::vector<string> module_parts; |
| @@ -172,66 +151,5 @@ static void Start(Options *options) { |
| options->success = success; |
| } |
| -//============================================================================= |
| -static void |
| -Usage(int argc, const char *argv[]) { |
| - fprintf(stderr, "Submit symbol information.\n"); |
| - fprintf(stderr, "Usage: %s [options...] <symbols> <upload-URL>\n", argv[0]); |
| - fprintf(stderr, "Options:\n"); |
| - fprintf(stderr, "<symbols> should be created by using the dump_syms tool.\n"); |
| - fprintf(stderr, "<upload-URL> is the destination for the upload\n"); |
| - fprintf(stderr, "-v:\t Version information (e.g., 1.2.3.4)\n"); |
| - fprintf(stderr, "-x:\t <host[:port]> Use HTTP proxy on given port\n"); |
| - fprintf(stderr, "-u:\t <user[:password]> Set proxy user and password\n"); |
| - fprintf(stderr, "-h:\t Usage\n"); |
| - fprintf(stderr, "-?:\t Usage\n"); |
| -} |
| - |
| -//============================================================================= |
| -static void |
| -SetupOptions(int argc, const char *argv[], Options *options) { |
| - extern int optind; |
| - int ch; |
| - |
| - while ((ch = getopt(argc, (char * const *)argv, "u:v:x:h?")) != -1) { |
| - switch (ch) { |
| - case 'h': |
| - case '?': |
| - Usage(argc, argv); |
| - exit(0); |
| - break; |
| - case 'u': |
| - options->proxy_user_pwd = optarg; |
| - break; |
| - case 'v': |
| - options->version = optarg; |
| - break; |
| - case 'x': |
| - options->proxy = optarg; |
| - break; |
| - |
| - default: |
| - fprintf(stderr, "Invalid option '%c'\n", ch); |
| - Usage(argc, argv); |
| - exit(1); |
| - break; |
| - } |
| - } |
| - |
| - if ((argc - optind) != 2) { |
| - fprintf(stderr, "%s: Missing symbols file and/or upload-URL\n", argv[0]); |
| - Usage(argc, argv); |
| - exit(1); |
| - } |
| - |
| - options->symbolsPath = argv[optind]; |
| - options->uploadURLStr = argv[optind + 1]; |
| -} |
| - |
| -//============================================================================= |
| -int main(int argc, const char* argv[]) { |
| - Options options; |
| - SetupOptions(argc, argv, &options); |
| - Start(&options); |
| - return options.success ? 0 : 1; |
| -} |
| +} // namespace sym_upload |
| +} // namespace google_breakpad |