1 // Copyright (c) 2009, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 #include "common/linux/google_crashdump_uploader.h"
31 #include "third_party/linux/include/gflags/gflags.h"
32 #include <string>
33 #include <iostream>
34
35 #include "common/using_std_string.h"
36
37 DEFINE_string(crash_server, "https://clients2.google.com/cr",
38 "The crash server to upload minidumps to.");
39 DEFINE_string(product_name, "",
40 "The product name that the minidump corresponds to.");
41 DEFINE_string(product_version, "",
42 "The version of the product that produced the minidump.");
43 DEFINE_string(client_id, "",
44 "The client GUID");
45 DEFINE_string(minidump_path, "",
46 "The path of the minidump file.");
47 DEFINE_string(ptime, "",
48 "The process uptime in milliseconds.");
49 DEFINE_string(ctime, "",
50 "The cumulative process uptime in milliseconds.");
51 DEFINE_string(email, "",
52 "The user's email address.");
53 DEFINE_string(comments, "",
54 "Extra user comments");
55 DEFINE_string(proxy_host, "",
56 "Proxy host");
57 DEFINE_string(proxy_userpasswd, "",
58 "Proxy username/password in user:pass format.");
59
60
CheckForRequiredFlagsOrDie()61 bool CheckForRequiredFlagsOrDie() {
62 string error_text = "";
63 if (FLAGS_product_name.empty()) {
64 error_text.append("\nProduct name must be specified.");
65 }
66
67 if (FLAGS_product_version.empty()) {
68 error_text.append("\nProduct version must be specified.");
69 }
70
71 if (FLAGS_client_id.empty()) {
72 error_text.append("\nClient ID must be specified.");
73 }
74
75 if (FLAGS_minidump_path.empty()) {
76 error_text.append("\nMinidump pathname must be specified.");
77 }
78
79 if (!error_text.empty()) {
80 std::cout << error_text;
81 return false;
82 }
83 return true;
84 }
85
main(int argc,char * argv[])86 int main(int argc, char *argv[]) {
87 google::InitGoogleLogging(argv[0]);
88 google::ParseCommandLineFlags(&argc, &argv, true);
89 if (!CheckForRequiredFlagsOrDie()) {
90 return 1;
91 }
92 google_breakpad::GoogleCrashdumpUploader g(FLAGS_product_name,
93 FLAGS_product_version,
94 FLAGS_client_id,
95 FLAGS_ptime,
96 FLAGS_ctime,
97 FLAGS_email,
98 FLAGS_comments,
99 FLAGS_minidump_path,
100 FLAGS_crash_server,
101 FLAGS_proxy_host,
102 FLAGS_proxy_userpasswd);
103 g.Upload(NULL, NULL, NULL);
104 }
105