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