Index: handler/win/crashy_test_program.cc |
diff --git a/util/thread/thread_win.cc b/handler/win/crashy_test_program.cc |
similarity index 51% |
copy from util/thread/thread_win.cc |
copy to handler/win/crashy_test_program.cc |
index c4ac1eb784d1f80bfcb066987a934c0c6df0eb67..07c9cf101278213f36b55e3025b8b1c88ece15a4 100644 |
--- a/util/thread/thread_win.cc |
+++ b/handler/win/crashy_test_program.cc |
@@ -12,31 +12,43 @@ |
// See the License for the specific language governing permissions and |
// limitations under the License. |
-#include "util/thread/thread.h" |
+#include "client/crashpad_client.h" |
#include "base/logging.h" |
+#include "tools/tool_support.h" |
namespace crashpad { |
+namespace { |
-void Thread::Start() { |
- DCHECK(!platform_thread_); |
- platform_thread_ = |
- CreateThread(nullptr, 0, ThreadEntryThunk, this, 0, nullptr); |
- PCHECK(platform_thread_); |
+void SomeCrashyFunction() { |
+ volatile int* foo = reinterpret_cast<volatile int*>(7); |
+ *foo = 42; |
} |
-void Thread::Join() { |
- DCHECK(platform_thread_); |
- DWORD result = WaitForSingleObject(platform_thread_, INFINITE); |
- PCHECK(WAIT_OBJECT_0 == result); |
- platform_thread_ = 0; |
-} |
+int CrashyMain(int argc, char* argv[]) { |
+ if (argc != 2) { |
+ fprintf(stderr, "Usage: %s <server_pipe_name>\n", argv[0]); |
+ return 1; |
+ } |
+ |
+ CrashpadClient client; |
+ if (!client.SetHandler(argv[1])) { |
+ LOG(ERROR) << "SetHandler"; |
+ return 1; |
+ } |
+ if (!client.UseHandler()) { |
+ LOG(ERROR) << "UseHandler"; |
+ return 1; |
+ } |
+ |
+ SomeCrashyFunction(); |
-// static |
-DWORD WINAPI Thread::ThreadEntryThunk(void* argument) { |
- Thread* self = reinterpret_cast<Thread*>(argument); |
- self->ThreadMain(); |
return 0; |
} |
+} // namespace |
} // namespace crashpad |
+ |
+int wmain(int argc, wchar_t* argv[]) { |
+ return crashpad::ToolSupport::Wmain(argc, argv, crashpad::CrashyMain); |
+} |