aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorivan.penkov@gmail.com <ivan.penkov@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2013-04-23 21:04:31 +0000
committerivan.penkov@gmail.com <ivan.penkov@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2013-04-23 21:04:31 +0000
commitfb22e8022954a06c9d738d4a5d231db67ce1ebf4 (patch)
treec5d5d953b42b01f00c326c4e5b584e5f55121a32 /src
parentAllow option for efficient and safe opt out of in-proc dump generation for Wi... (diff)
downloadbreakpad-fb22e8022954a06c9d738d4a5d231db67ce1ebf4.tar.xz
This change allows compiling sym_upload.cc and minidump_upload.cc using a global ::string class instead of std::string. For more details take a look at common/using_std_string.h
A few other fixes: - getopt() returns (int)(-1) when options are exhausted. This was already sent out for code review by mattdr but only for sym_upload.cc (https://breakpad.appspot.com/561002/). I'm applying the fix for both files. - Fixed a couple of lint warning about improper usage of white-spaces. Thanks, -Ivan Review URL: https://breakpad.appspot.com/567002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1158 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src')
-rw-r--r--src/tools/linux/symupload/minidump_upload.cc28
-rw-r--r--src/tools/linux/symupload/sym_upload.cc52
2 files changed, 42 insertions, 38 deletions
diff --git a/src/tools/linux/symupload/minidump_upload.cc b/src/tools/linux/symupload/minidump_upload.cc
index 144c8bf6..94c3492c 100644
--- a/src/tools/linux/symupload/minidump_upload.cc
+++ b/src/tools/linux/symupload/minidump_upload.cc
@@ -41,28 +41,29 @@
#include <string>
#include "common/linux/http_upload.h"
+#include "common/using_std_string.h"
using google_breakpad::HTTPUpload;
struct Options {
- std::string minidumpPath;
- std::string uploadURLStr;
- std::string product;
- std::string version;
- std::string proxy;
- std::string proxy_user_pwd;
+ string minidumpPath;
+ string uploadURLStr;
+ string product;
+ string version;
+ string proxy;
+ string proxy_user_pwd;
bool success;
};
//=============================================================================
static void Start(Options *options) {
- std::map<std::string, std::string> parameters;
+ std::map<string, string> parameters;
// Add parameters
parameters["prod"] = options->product;
parameters["ver"] = options->version;
// Send it
- std::string response, error;
+ string response, error;
bool success = HTTPUpload::SendRequest(options->uploadURLStr,
parameters,
options->minidumpPath,
@@ -78,9 +79,9 @@ static void Start(Options *options) {
printf("Successfully sent the minidump file.\n");
} else {
printf("Failed to send minidump: %s\n", error.c_str());
- printf("Response:\n");
- printf("%s\n", response.c_str());
}
+ printf("Response:\n");
+ printf("%s\n", response.c_str());
options->success = success;
}
@@ -106,7 +107,7 @@ Usage(int argc, const char *argv[]) {
static void
SetupOptions(int argc, const char *argv[], Options *options) {
extern int optind;
- char ch;
+ int ch;
while ((ch = getopt(argc, (char * const *)argv, "p:u:v:x:h?")) != -1) {
switch (ch) {
@@ -124,8 +125,9 @@ SetupOptions(int argc, const char *argv[], Options *options) {
break;
default:
+ fprintf(stderr, "Invalid option '%c'\n", ch);
Usage(argc, argv);
- exit(0);
+ exit(1);
break;
}
}
@@ -141,7 +143,7 @@ SetupOptions(int argc, const char *argv[], Options *options) {
}
//=============================================================================
-int main (int argc, const char * argv[]) {
+int main(int argc, const char* argv[]) {
Options options;
SetupOptions(argc, argv, &options);
Start(&options);
diff --git a/src/tools/linux/symupload/sym_upload.cc b/src/tools/linux/symupload/sym_upload.cc
index 5b1ee6f6..75ad206a 100644
--- a/src/tools/linux/symupload/sym_upload.cc
+++ b/src/tools/linux/symupload/sym_upload.cc
@@ -50,23 +50,24 @@
#include <vector>
#include "common/linux/http_upload.h"
+#include "common/using_std_string.h"
using google_breakpad::HTTPUpload;
typedef struct {
- std::string symbolsPath;
- std::string uploadURLStr;
- std::string proxy;
- std::string proxy_user_pwd;
- std::string version;
+ string symbolsPath;
+ string uploadURLStr;
+ string proxy;
+ string proxy_user_pwd;
+ string version;
bool success;
} Options;
-static void TokenizeByChar(const std::string &source_string,
- int c, std::vector<std::string> *results) {
+static void TokenizeByChar(const string &source_string,
+ int c, std::vector<string> *results) {
assert(results);
- std::string::size_type cur_pos = 0, next_pos = 0;
- while ((next_pos = source_string.find(c, cur_pos)) != std::string::npos) {
+ string::size_type cur_pos = 0, next_pos = 0;
+ while ((next_pos = source_string.find(c, cur_pos)) != string::npos) {
if (next_pos != cur_pos)
results->push_back(source_string.substr(cur_pos, next_pos - cur_pos));
cur_pos = next_pos + 1;
@@ -78,17 +79,17 @@ static void TokenizeByChar(const std::string &source_string,
//=============================================================================
// Parse out the module line which have 5 parts.
// MODULE <os> <cpu> <uuid> <module-name>
-static bool ModuleDataForSymbolFile(const std::string &file,
- std::vector<std::string> *module_parts) {
+static bool ModuleDataForSymbolFile(const string &file,
+ std::vector<string> *module_parts) {
assert(module_parts);
const size_t kModulePartNumber = 5;
- FILE *fp = fopen(file.c_str(), "r");
+ FILE* fp = fopen(file.c_str(), "r");
if (fp) {
char buffer[1024];
if (fgets(buffer, sizeof(buffer), fp)) {
- std::string line(buffer);
- std::string::size_type line_break_pos = line.find_first_of('\n');
- if (line_break_pos == std::string::npos) {
+ string line(buffer);
+ string::size_type line_break_pos = line.find_first_of('\n');
+ if (line_break_pos == string::npos) {
assert(0 && "The file is invalid!");
fclose(fp);
return false;
@@ -106,10 +107,10 @@ static bool ModuleDataForSymbolFile(const std::string &file,
}
//=============================================================================
-static std::string CompactIdentifier(const std::string &uuid) {
- std::vector<std::string> components;
+static string CompactIdentifier(const string &uuid) {
+ std::vector<string> components;
TokenizeByChar(uuid, '-', &components);
- std::string result;
+ string result;
for (size_t i = 0; i < components.size(); ++i)
result += components[i];
return result;
@@ -117,15 +118,15 @@ static std::string CompactIdentifier(const std::string &uuid) {
//=============================================================================
static void Start(Options *options) {
- std::map<std::string, std::string> parameters;
+ std::map<string, string> parameters;
options->success = false;
- std::vector<std::string> module_parts;
+ std::vector<string> module_parts;
if (!ModuleDataForSymbolFile(options->symbolsPath, &module_parts)) {
fprintf(stderr, "Failed to parse symbol file!\n");
return;
}
- std::string compacted_id = CompactIdentifier(module_parts[3]);
+ string compacted_id = CompactIdentifier(module_parts[3]);
// Add parameters
if (!options->version.empty())
@@ -138,7 +139,7 @@ static void Start(Options *options) {
parameters["debug_file"] = module_parts[4];
parameters["code_file"] = module_parts[4];
parameters["debug_identifier"] = compacted_id;
- std::string response, error;
+ string response, error;
long response_code;
bool success = HTTPUpload::SendRequest(options->uploadURLStr,
parameters,
@@ -186,7 +187,7 @@ Usage(int argc, const char *argv[]) {
static void
SetupOptions(int argc, const char *argv[], Options *options) {
extern int optind;
- char ch;
+ int ch;
while ((ch = getopt(argc, (char * const *)argv, "u:v:x:h?")) != -1) {
switch (ch) {
@@ -201,8 +202,9 @@ SetupOptions(int argc, const char *argv[], Options *options) {
break;
default:
+ fprintf(stderr, "Invalid option '%c'\n", ch);
Usage(argc, argv);
- exit(0);
+ exit(1);
break;
}
}
@@ -218,7 +220,7 @@ SetupOptions(int argc, const char *argv[], Options *options) {
}
//=============================================================================
-int main (int argc, const char * argv[]) {
+int main(int argc, const char* argv[]) {
Options options;
SetupOptions(argc, argv, &options);
Start(&options);