From 5f3ab7979f5a69b958dfe3971089a47b902a4eee Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 1 Feb 2015 11:38:16 -0800 Subject: [PATCH] --break_on_debugbreak --- src/alloy/alloy-private.h | 1 + src/alloy/alloy.cc | 1 + src/alloy/backend/x64/x64_emitter.cc | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/alloy/alloy-private.h b/src/alloy/alloy-private.h index 3efde3d21..e20e04806 100644 --- a/src/alloy/alloy-private.h +++ b/src/alloy/alloy-private.h @@ -19,5 +19,6 @@ DECLARE_bool(validate_hir); DECLARE_uint64(break_on_instruction); DECLARE_uint64(break_on_memory); +DECLARE_bool(break_on_debugbreak); #endif // ALLOY_ALLOY_PRIVATE_H_ diff --git a/src/alloy/alloy.cc b/src/alloy/alloy.cc index 2f6d095f3..3435a4950 100644 --- a/src/alloy/alloy.cc +++ b/src/alloy/alloy.cc @@ -32,3 +32,4 @@ DEFINE_uint64(break_on_instruction, 0, "int3 before the given guest address is executed."); DEFINE_uint64(break_on_memory, 0, "int3 on read/write to the given memory address."); +DEFINE_bool(break_on_debugbreak, true, "int3 on JITed __debugbreak requests."); diff --git a/src/alloy/backend/x64/x64_emitter.cc b/src/alloy/backend/x64/x64_emitter.cc index a404f52fc..77a661eda 100644 --- a/src/alloy/backend/x64/x64_emitter.cc +++ b/src/alloy/backend/x64/x64_emitter.cc @@ -9,6 +9,7 @@ #include "alloy/backend/x64/x64_emitter.h" +#include "alloy/alloy-private.h" #include "alloy/backend/x64/x64_backend.h" #include "alloy/backend/x64/x64_code_cache.h" #include "alloy/backend/x64/x64_function.h" @@ -371,7 +372,9 @@ void X64Emitter::Trap(uint16_t trap_type) { case 22: // Always trap? // TODO(benvanik): post software interrupt to debugger. - db(0xCC); + if (FLAGS_break_on_debugbreak) { + db(0xCC); + } break; default: PLOGW("Unknown trap type %d", trap_type);