Index: snapshot/win/crashpad_snapshot_test_crashing_child.cc |
diff --git a/handler/win/crashy_test_program.cc b/snapshot/win/crashpad_snapshot_test_crashing_child.cc |
similarity index 50% |
copy from handler/win/crashy_test_program.cc |
copy to snapshot/win/crashpad_snapshot_test_crashing_child.cc |
index 07c9cf101278213f36b55e3025b8b1c88ece15a4..d74f6a62bddc3ac1e16aa0090a8adf4d95009fbd 100644 |
--- a/handler/win/crashy_test_program.cc |
+++ b/snapshot/win/crashpad_snapshot_test_crashing_child.cc |
@@ -12,43 +12,32 @@ |
// See the License for the specific language governing permissions and |
// limitations under the License. |
-#include "client/crashpad_client.h" |
+#include <stdint.h> |
+#include <stdlib.h> |
+#include <windows.h> |
#include "base/logging.h" |
-#include "tools/tool_support.h" |
- |
-namespace crashpad { |
-namespace { |
+#include "client/crashpad_client.h" |
+#include "util/file/file_io.h" |
+#include "util/win/address_types.h" |
-void SomeCrashyFunction() { |
- volatile int* foo = reinterpret_cast<volatile int*>(7); |
- *foo = 42; |
+__declspec(noinline) crashpad::WinVMAddress CurrentAddress() { |
+ return reinterpret_cast<crashpad::WinVMAddress>(_ReturnAddress()); |
} |
-int CrashyMain(int argc, char* argv[]) { |
- if (argc != 2) { |
- fprintf(stderr, "Usage: %s <server_pipe_name>\n", argv[0]); |
- return 1; |
- } |
+int main(int argc, char* argv[]) { |
+ CHECK_EQ(argc, 2); |
- CrashpadClient client; |
- if (!client.SetHandler(argv[1])) { |
- LOG(ERROR) << "SetHandler"; |
- return 1; |
- } |
- if (!client.UseHandler()) { |
- LOG(ERROR) << "UseHandler"; |
- return 1; |
- } |
+ crashpad::CrashpadClient client; |
+ CHECK(client.SetHandler(argv[1])); |
+ CHECK(client.UseHandler()); |
- SomeCrashyFunction(); |
+ HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE); |
+ CHECK_NE(out, INVALID_HANDLE_VALUE); |
+ crashpad::WinVMAddress break_address = CurrentAddress(); |
+ crashpad::CheckedWriteFile(out, &break_address, sizeof(break_address)); |
- return 0; |
-} |
- |
-} // namespace |
-} // namespace crashpad |
+ __debugbreak(); |
-int wmain(int argc, wchar_t* argv[]) { |
- return crashpad::ToolSupport::Wmain(argc, argv, crashpad::CrashyMain); |
+ return 0; |
} |