From 048becd504a38d91e8897c5cd4458117ec08cf53 Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Thu, 16 Aug 2012 15:31:51 +0000 Subject: [PATCH] [0.2.x] added : breakin routine git-svn-id: https://pykd.svn.codeplex.com/svn@78886 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/dbgengine.h | 1 + pykd/pymod.cpp | 3 +++ pykd/win/dbgeng.cpp | 15 +++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/pykd/dbgengine.h b/pykd/dbgengine.h index cb3b5a1..2e6d362 100644 --- a/pykd/dbgengine.h +++ b/pykd/dbgengine.h @@ -16,6 +16,7 @@ bool isDumpAnalyzing(); bool isKernelDebugging(); void debugGo(); +void debugBreak(); // debug output void dprint( const std::wstring &str, bool dml = false ); diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp index 841dc13..51eaf17 100644 --- a/pykd/pymod.cpp +++ b/pykd/pymod.cpp @@ -70,6 +70,9 @@ BOOST_PYTHON_MODULE( pykd ) python::def( "isKernelDebugging", &isKernelDebugging, "Check if kernel dubugging is running" ); + + python::def( "breakin", &debugBreak, + "Break into debugger" ); python::def( "go", &debugGo, "Go debugging" ); diff --git a/pykd/win/dbgeng.cpp b/pykd/win/dbgeng.cpp index 8bd6d66..9636243 100644 --- a/pykd/win/dbgeng.cpp +++ b/pykd/win/dbgeng.cpp @@ -168,6 +168,21 @@ void debugGo() } while( currentStatus != DEBUG_STATUS_BREAK && currentStatus != DEBUG_STATUS_NO_DEBUGGEE ); } +///////////////////////////////////////////////////////////////////////////////// + +void debugBreak() +{ + PyThreadState *pystate = PyEval_SaveThread(); + + HRESULT hres; + + hres = g_dbgEng->control->SetInterrupt( DEBUG_INTERRUPT_ACTIVE ); + + PyEval_RestoreThread( pystate ); + + if ( FAILED( hres ) ) + throw DbgException( "IDebugControl::SetInterrupt" ); +} /////////////////////////////////////////////////////////////////////////////////