• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <string>
32 #include <iostream>
33 #include <gflags/gflags.h>
34 #include <glog/logging.h>
35 
36 #include "common/using_std_string.h"
37 
38 DEFINE_string(crash_server, "https://clients2.google.com/cr",
39               "The crash server to upload minidumps to.");
40 DEFINE_string(product_name, "",
41               "The product name that the minidump corresponds to.");
42 DEFINE_string(product_version, "",
43               "The version of the product that produced the minidump.");
44 DEFINE_string(client_id, "",
45               "The client GUID");
46 DEFINE_string(minidump_path, "",
47               "The path of the minidump file.");
48 DEFINE_string(ptime, "",
49               "The process uptime in milliseconds.");
50 DEFINE_string(ctime, "",
51               "The cumulative process uptime in milliseconds.");
52 DEFINE_string(email, "",
53               "The user's email address.");
54 DEFINE_string(comments, "",
55               "Extra user comments");
56 DEFINE_string(proxy_host, "",
57               "Proxy host");
58 DEFINE_string(proxy_userpasswd, "",
59               "Proxy username/password in user:pass format.");
60 
61 
CheckForRequiredFlagsOrDie()62 bool CheckForRequiredFlagsOrDie() {
63   string error_text = "";
64   if (FLAGS_product_name.empty()) {
65     error_text.append("\nProduct name must be specified.");
66   }
67 
68   if (FLAGS_product_version.empty()) {
69     error_text.append("\nProduct version must be specified.");
70   }
71 
72   if (FLAGS_client_id.empty()) {
73     error_text.append("\nClient ID must be specified.");
74   }
75 
76   if (FLAGS_minidump_path.empty()) {
77     error_text.append("\nMinidump pathname must be specified.");
78   }
79 
80   if (!error_text.empty()) {
81     std::cout << error_text;
82     return false;
83   }
84   return true;
85 }
86 
main(int argc,char * argv[])87 int main(int argc, char *argv[]) {
88   google::InitGoogleLogging(argv[0]);
89   google::ParseCommandLineFlags(&argc, &argv, true);
90   if (!CheckForRequiredFlagsOrDie()) {
91     return 1;
92   }
93   google_breakpad::GoogleCrashdumpUploader g(FLAGS_product_name,
94                                              FLAGS_product_version,
95                                              FLAGS_client_id,
96                                              FLAGS_ptime,
97                                              FLAGS_ctime,
98                                              FLAGS_email,
99                                              FLAGS_comments,
100                                              FLAGS_minidump_path,
101                                              FLAGS_crash_server,
102                                              FLAGS_proxy_host,
103                                              FLAGS_proxy_userpasswd);
104   g.Upload(NULL, NULL, NULL);
105 }
106