OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 std::string dump_path; | 42 std::string dump_path; |
43 pid_t pid; | 43 pid_t pid; |
44 bool suspend; | 44 bool suspend; |
45 }; | 45 }; |
46 | 46 |
47 void Usage(const std::string& me) { | 47 void Usage(const std::string& me) { |
48 fprintf(stderr, | 48 fprintf(stderr, |
49 "Usage: %s [OPTION]... PID\n" | 49 "Usage: %s [OPTION]... PID\n" |
50 "Generate a minidump file containing a snapshot of a running process.\n" | 50 "Generate a minidump file containing a snapshot of a running process.\n" |
51 "\n" | 51 "\n" |
52 " -r, --no_suspend don't suspend the target process during dump generation\n" | 52 " -r, --no-suspend don't suspend the target process during dump generation\n" |
53 " -o, --output=FILE write the minidump to FILE instead of minidump.PID\n" | 53 " -o, --output=FILE write the minidump to FILE instead of minidump.PID\n" |
54 " --help display this help and exit\n" | 54 " --help display this help and exit\n" |
55 " --version output version information and exit\n", | 55 " --version output version information and exit\n", |
56 me.c_str()); | 56 me.c_str()); |
57 ToolSupport::UsageTail(me); | 57 ToolSupport::UsageTail(me); |
58 } | 58 } |
59 | 59 |
60 int GenerateDumpMain(int argc, char* argv[]) { | 60 int GenerateDumpMain(int argc, char* argv[]) { |
61 const std::string me(basename(argv[0])); | 61 const std::string me(basename(argv[0])); |
62 | 62 |
63 enum OptionFlags { | 63 enum OptionFlags { |
64 // “Short” (single-character) options. | 64 // “Short” (single-character) options. |
65 kOptionOutput = 'o', | 65 kOptionOutput = 'o', |
66 kOptionNoSuspend = 'r', | 66 kOptionNoSuspend = 'r', |
67 | 67 |
68 // Long options without short equivalents. | 68 // Long options without short equivalents. |
69 kOptionLastChar = 255, | 69 kOptionLastChar = 255, |
70 | 70 |
71 // Standard options. | 71 // Standard options. |
72 kOptionHelp = -2, | 72 kOptionHelp = -2, |
73 kOptionVersion = -3, | 73 kOptionVersion = -3, |
74 }; | 74 }; |
75 | 75 |
76 Options options = {}; | 76 Options options = {}; |
77 options.suspend = true; | 77 options.suspend = true; |
78 | 78 |
79 const struct option long_options[] = { | 79 const struct option long_options[] = { |
80 {"no_suspend", no_argument, nullptr, kOptionNoSuspend}, | 80 {"no-suspend", no_argument, nullptr, kOptionNoSuspend}, |
81 {"output", required_argument, nullptr, kOptionOutput}, | 81 {"output", required_argument, nullptr, kOptionOutput}, |
82 {"help", no_argument, nullptr, kOptionHelp}, | 82 {"help", no_argument, nullptr, kOptionHelp}, |
83 {"version", no_argument, nullptr, kOptionVersion}, | 83 {"version", no_argument, nullptr, kOptionVersion}, |
84 {nullptr, 0, nullptr, 0}, | 84 {nullptr, 0, nullptr, 0}, |
85 }; | 85 }; |
86 | 86 |
87 int opt; | 87 int opt; |
88 while ((opt = getopt_long(argc, argv, "o:r", long_options, nullptr)) != -1) { | 88 while ((opt = getopt_long(argc, argv, "o:r", long_options, nullptr)) != -1) { |
89 switch (opt) { | 89 switch (opt) { |
90 case kOptionOutput: | 90 case kOptionOutput: |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 return EXIT_SUCCESS; | 170 return EXIT_SUCCESS; |
171 } | 171 } |
172 | 172 |
173 } // namespace | 173 } // namespace |
174 } // namespace crashpad | 174 } // namespace crashpad |
175 | 175 |
176 int main(int argc, char* argv[]) { | 176 int main(int argc, char* argv[]) { |
177 return crashpad::GenerateDumpMain(argc, argv); | 177 return crashpad::GenerateDumpMain(argc, argv); |
178 } | 178 } |
OLD | NEW |