/thirdparty/breakpad/client/linux/sender/google_crash_report_sender.cc

http://github.com/tomahawk-player/tomahawk · C++ · 104 lines · 66 code · 10 blank · 28 comment · 6 complexity · 8070709e17c02ef6f688dd9cca770b00 MD5 · raw file

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