MCPcopy Create free account
hub / github.com/Vector35/debugger / AddBreakpoint

Method AddBreakpoint

core/adapters/dbgengadapter.cpp:783–814  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

781
782
783DebugBreakpoint DbgEngAdapter::AddBreakpoint(const std::uintptr_t address, unsigned long breakpoint_flags)
784{
785 IDebugBreakpoint2* debug_breakpoint {};
786
787 /* attempt to read at breakpoint location to confirm its valid */
788 /* DbgEng won't tell us if its valid until continue/go so this is a hacky fix */
789 /* Note we cannot write to it if we are replaying TTD trace */
790 auto val = this->ReadMemory(address, 1);
791 if (val.GetLength() != 1)
792 return {};
793
794 if (const auto result =
795 this->m_debugControl->AddBreakpoint2(DEBUG_BREAKPOINT_CODE, DEBUG_ANY_ID, &debug_breakpoint);
796 result != S_OK)
797 return {};
798
799 /* these will all work even on invalid addresses hence the previous checks */
800 unsigned long id {};
801 if (debug_breakpoint->GetId(&id) != S_OK)
802 return {};
803
804 if (debug_breakpoint->SetOffset(address) != S_OK)
805 return {};
806
807 if (debug_breakpoint->SetFlags(DEBUG_BREAKPOINT_ENABLED | breakpoint_flags) != S_OK)
808 return {};
809
810 const auto new_breakpoint = DebugBreakpoint(address, id, true);
811 this->m_debug_breakpoints.push_back(new_breakpoint);
812
813 return new_breakpoint;
814}
815
816static std::string EscapeModuleName(const std::string& name)
817{

Callers

nothing calls this directly

Calls 3

ReadMemoryMethod · 0.95
EscapeModuleNameFunction · 0.85
DebugBreakpointClass · 0.50

Tested by

no test coverage detected