OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Crashpad Authors. All rights reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (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 |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" |
| 17 #include "build/build_config.h" |
| 18 #include "handler/handler_main.h" |
| 19 #include "minidump/test/minidump_user_extension_stream_util.h" |
| 20 #include "tools/tool_support.h" |
| 21 |
| 22 #if defined(OS_WIN) |
| 23 #include <windows.h> |
| 24 #endif |
| 25 |
| 26 namespace { |
| 27 |
| 28 class TestUserStreamDataSource : public crashpad::UserStreamDataSource { |
| 29 public: |
| 30 TestUserStreamDataSource() {} |
| 31 |
| 32 std::unique_ptr<crashpad::MinidumpUserExtensionStreamDataSource> |
| 33 ProduceStreamData(crashpad::ProcessSnapshot* process_snapshot) override; |
| 34 |
| 35 private: |
| 36 DISALLOW_COPY_AND_ASSIGN(TestUserStreamDataSource); |
| 37 }; |
| 38 |
| 39 std::unique_ptr<crashpad::MinidumpUserExtensionStreamDataSource> |
| 40 TestUserStreamDataSource::ProduceStreamData( |
| 41 crashpad::ProcessSnapshot* process_snapshot) { |
| 42 static const char kTestData[] = "Injected extension stream!"; |
| 43 |
| 44 return base::WrapUnique(new crashpad::test::BufferExtensionStreamDataSource( |
| 45 0xCAFEBABE, kTestData, sizeof(kTestData))); |
| 46 } |
| 47 |
| 48 int ExtendedHandlerMain(int argc, char* argv[]) { |
| 49 crashpad::UserStreamDataSources user_stream_data_sources; |
| 50 user_stream_data_sources.push_back( |
| 51 base::WrapUnique(new TestUserStreamDataSource())); |
| 52 |
| 53 return crashpad::HandlerMain(argc, argv, &user_stream_data_sources); |
| 54 } |
| 55 |
| 56 } // namespace |
| 57 |
| 58 #if defined(OS_MACOSX) |
| 59 |
| 60 int main(int argc, char* argv[]) { |
| 61 return ExtendedHandlerMain(argc, argv); |
| 62 } |
| 63 |
| 64 #elif defined(OS_WIN) |
| 65 |
| 66 int wmain(int argc, wchar_t* argv[]) { |
| 67 return crashpad::ToolSupport::Wmain(argc, argv, &ExtendedHandlerMain); |
| 68 } |
| 69 |
| 70 #endif // OS_MACOSX |
OLD | NEW |