aboutsummaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorNelson Billing <nbilling@google.com>2020-02-27 14:04:01 -0800
committerNelson Billing <nbilling@google.com>2020-02-27 22:04:31 +0000
commitc7522272ffafa9b162f135aaee5d02a8895fcb0b (patch)
treea13d99c2cbefd9f6f78a8e128957ae2873bcf34d /src/tools
parentMake LibcurlWrapper support static linking. (diff)
downloadbreakpad-c7522272ffafa9b162f135aaee5d02a8895fcb0b.tar.xz
Add "type" option to sym_upload sym-upload-v2 mode.
- "sym-upload-v2" protocol now supports specifying a symbol file "type". - Known types are "breakpad" (default option, previously this was only effectively the only option), "elf", "pe", "macho", "debug_only", "dwp", "pdb", and "dsym". - When type other than breakpad is specified, sym_upload tool requires the code_file and debug_id value (that it otherwise would have gotten from the text of the Breakpad symbol file). - This ultimately means that sym_upload can be used to upload native symbol files now, in addition to Breakpad symbol files. Change-Id: I3a331ba16f199d1d0025df735716ba5de298f522 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2078670 Reviewed-by: Mark Mentovai <mark@chromium.org>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/linux/symupload/sym_upload.cc73
1 files changed, 68 insertions, 5 deletions
diff --git a/src/tools/linux/symupload/sym_upload.cc b/src/tools/linux/symupload/sym_upload.cc
index a9b9175b..f155eb95 100644
--- a/src/tools/linux/symupload/sym_upload.cc
+++ b/src/tools/linux/symupload/sym_upload.cc
@@ -44,11 +44,23 @@
#include <string.h>
#include <unistd.h>
+#include <locale>
+
#include "common/linux/symbol_upload.h"
using google_breakpad::sym_upload::UploadProtocol;
using google_breakpad::sym_upload::Options;
+static void StrToUpper(std::string* str) {
+ if (str == nullptr) {
+ fprintf(stderr, "nullptr passed to StrToUpper.\n");
+ exit(1);
+ }
+ for (size_t i = 0; i < str->length(); i++) {
+ (*str)[i] = std::toupper((*str)[i], std::locale::classic());
+ }
+}
+
//=============================================================================
static void
Usage(int argc, const char *argv[]) {
@@ -61,23 +73,39 @@ Usage(int argc, const char *argv[]) {
fprintf(stderr, "<upload-URL> is the destination for the upload\n");
fprintf(stderr, "-p:\t <protocol> One of ['sym-upload-v1',"
" 'sym-upload-v2'], defaults to 'sym-upload-v1'.\n");
- fprintf(stderr, "-k:\t <API-key> A secret used to authenticate with the"
- " API [Only supported when using 'sym-upload-v2' protocol].\n");
- fprintf(stderr, "-f:\t Force symbol upload if already exists [Only"
- " supported when using 'sym-upload-v2' protocol].\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");
fprintf(stderr, "\n");
+ fprintf(stderr, "These options only work with 'sym-upload-v2' protocol:\n");
+ fprintf(stderr, "-k:\t <API-key> A secret used to authenticate with the"
+ " API.\n");
+ fprintf(stderr, "-f:\t Force symbol upload if already exists.\n");
+ fprintf(stderr, "-t:\t <symbol-type> Explicitly set symbol upload type ("
+ "default is 'breakpad').\n"
+ "\t One of ['breakpad', 'elf', 'pe', 'macho', 'debug_only', 'dwp', "
+ "'dsym', 'pdb'].\n"
+ "\t Note: When this flag is set to anything other than 'breakpad', then "
+ "the '-c' and '-i' flags must also be set.\n");
+ fprintf(stderr, "-c:\t <code-file> Explicitly set 'code_file' for symbol "
+ "upload (basename of executable).\n");
+ fprintf(stderr, "-i:\t <debug-id> Explicitly set 'debug_id' for symbol "
+ "upload (typically build ID of executable).\n");
+ fprintf(stderr, "\n");
fprintf(stderr, "Examples:\n");
fprintf(stderr, " With 'sym-upload-v1':\n");
fprintf(stderr, " %s path/to/symbol_file http://myuploadserver\n",
argv[0]);
fprintf(stderr, " With 'sym-upload-v2':\n");
+ fprintf(stderr, " [Defaulting to symbol type 'BREAKPAD']\n");
fprintf(stderr, " %s -p sym-upload-v2 -k mysecret123! "
"path/to/symbol_file http://myuploadserver\n", argv[0]);
+ fprintf(stderr, " [Explicitly set symbol type to 'elf']\n");
+ fprintf(stderr, " %s -p sym-upload-v2 -k mysecret123! -t elf "
+ "-c app -i 11111111BBBB3333DDDD555555555555F "
+ "path/to/symbol_file http://myuploadserver\n", argv[0]);
}
//=============================================================================
@@ -85,8 +113,9 @@ static void
SetupOptions(int argc, const char *argv[], Options *options) {
extern int optind;
int ch;
+ constexpr char flag_pattern[] = "u:v:x:p:k:t:c:i:hf?";
- while ((ch = getopt(argc, (char * const *)argv, "u:v:x:p:k:hf?")) != -1) {
+ while ((ch = getopt(argc, (char * const *)argv, flag_pattern)) != -1) {
switch (ch) {
case 'h':
case '?':
@@ -116,6 +145,19 @@ SetupOptions(int argc, const char *argv[], Options *options) {
case 'k':
options->api_key = optarg;
break;
+ case 't': {
+ // This is really an enum, so treat as upper-case for consistency with
+ // enum naming convention on server-side.
+ options->type = optarg;
+ StrToUpper(&(options->type));
+ break;
+ }
+ case 'c':
+ options->code_file = optarg;
+ break;
+ case 'i':
+ options->debug_id = optarg;
+ break;
case 'f':
options->force = true;
break;
@@ -134,6 +176,27 @@ SetupOptions(int argc, const char *argv[], Options *options) {
exit(1);
}
+ bool is_breakpad_upload = options->type.empty() ||
+ options->type == google_breakpad::sym_upload::kBreakpadSymbolType;
+ bool has_code_file = !options->code_file.empty();
+ bool has_debug_id = !options->debug_id.empty();
+ if (is_breakpad_upload && (has_code_file || has_debug_id)) {
+ fprintf(stderr, "\n");
+ fprintf(stderr, "%s: -c and -i should only be specified for non-breakpad "
+ "symbol upload types.\n", argv[0]);
+ fprintf(stderr, "\n");
+ Usage(argc, argv);
+ exit(1);
+ }
+ if (!is_breakpad_upload && (!has_code_file || !has_debug_id)) {
+ fprintf(stderr, "\n");
+ fprintf(stderr, "%s: -c and -i must be specified for non-breakpad "
+ "symbol upload types.\n", argv[0]);
+ fprintf(stderr, "\n");
+ Usage(argc, argv);
+ exit(1);
+ }
+
options->symbolsPath = argv[optind];
options->uploadURLStr = argv[optind + 1];
}