mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-18 01:53:22 +08:00
added : getOutputMask
added : setOutputMask added : test for eventHanlder.onDebugOutput:
This commit is contained in:
parent
c6800333c3
commit
86e8383463
2
kdlibcpp
2
kdlibcpp
@ -1 +1 @@
|
||||
Subproject commit a281002c91a1d756075849b1144b4e5e81c2fe45
|
||||
Subproject commit e1708cdb932856042b13763daae3dfbf6ed5c87d
|
@ -133,6 +133,20 @@ void changeDebugOptions(kdlib::DebugOptionsSet &addOptions, kdlib::DebugOptionsS
|
||||
kdlib::changeDebugOptions(addOptions, removeOptions);
|
||||
}
|
||||
|
||||
inline
|
||||
kdlib::OutputFlagsSet getOutputMask()
|
||||
{
|
||||
AutoRestorePyState pystate;
|
||||
return kdlib::getOutputFlags();
|
||||
}
|
||||
|
||||
inline
|
||||
void setOutputMask(const kdlib::OutputFlagsSet& outputMask)
|
||||
{
|
||||
AutoRestorePyState pystate;
|
||||
kdlib::setOutputFlags(outputMask);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// processes end threads
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
void onChangeLocalScope() override;
|
||||
void onChangeSymbolPaths() override;
|
||||
void onChangeBreakpoints() override;
|
||||
void onDebugOutput(const std::wstring& text, kdlib::OutputFlag) override;
|
||||
void onDebugOutput(const std::wstring& text, kdlib::OutputFlag flag) override;
|
||||
void onStartInput() override;
|
||||
void onStopInput() override;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define PYKD_VERSION_MAJOR 0
|
||||
#define PYKD_VERSION_MINOR 3
|
||||
#define PYKD_VERSION_SUBVERSION 4
|
||||
#define PYKD_VERSION_BUILDNO 4
|
||||
#define PYKD_VERSION_BUILDNO 5
|
||||
|
||||
#define __VER_STR2__(x) #x
|
||||
#define __VER_STR1__(x) __VER_STR2__(x)
|
||||
|
@ -194,7 +194,10 @@ void pykd_init()
|
||||
"Return debug options" );
|
||||
python::def( "changeDebugOptions", pykd::changeDebugOptions,
|
||||
"Change debug options" );
|
||||
|
||||
python::def("getOutputMask", pykd::getOutputMask,
|
||||
"Get output mask");
|
||||
python::def("setOutputMask", pykd::setOutputMask,
|
||||
"Set output mask");
|
||||
|
||||
python::def( "breakin", pykd::targetBreak,
|
||||
"Break into debugger" );
|
||||
@ -1437,6 +1440,21 @@ void pykd_init()
|
||||
.value("Execute", kdlib::Execute)
|
||||
;
|
||||
|
||||
python::enum_<kdlib::OutputFlag>("outputFlag", "Set of output mask")
|
||||
.value("Normal", kdlib::Normal)
|
||||
.value("Error", kdlib::Error)
|
||||
.value("Warning", kdlib::Warning)
|
||||
.value("Verbose", kdlib::Verbose)
|
||||
.value("Prompt", kdlib::Prompt)
|
||||
.value("PromptRegister", kdlib::PromptRegister)
|
||||
.value("ExtensionWarning", kdlib::ExtensionWarning)
|
||||
.value("Debuggee", kdlib::Debuggee)
|
||||
.value("DebuggeePrompt", kdlib::DebuggeePrompt)
|
||||
.value("Symbols", kdlib::Symbols)
|
||||
.value("Status", kdlib::Status)
|
||||
.value("All", kdlib::All)
|
||||
;
|
||||
|
||||
// C++ exception translation to python
|
||||
pykd::registerExceptions();
|
||||
}
|
||||
|
@ -16,4 +16,6 @@ py -3.6 setup.py bdist_wheel --plat-name=win-amd64 --python-tag=cp36
|
||||
py -3.7 setup.py bdist_zip --plat-name=win32
|
||||
py -3.7 setup.py bdist_zip --plat-name=win-amd64
|
||||
py -3.7 setup.py bdist_wheel --plat-name=win32 --python-tag=cp37
|
||||
py -3.7 setup.py bdist_wheel --plat-name=win-amd64 --python-tag=cp37
|
||||
py -3.7 setup.py bdist_wheel --plat-name=win-amd64 --python-tag=cp37
|
||||
|
||||
py setup.py bdist_pdb
|
@ -3,23 +3,36 @@ import unittest
|
||||
import target
|
||||
import pykd
|
||||
|
||||
class handler( pykd.eventHandler ):
|
||||
class OutHandler( pykd.eventHandler ):
|
||||
|
||||
def __init__(self):
|
||||
pykd.eventHandler.__init__(self)
|
||||
self.counter=0
|
||||
|
||||
def onException(self, param):
|
||||
self.counter += 1
|
||||
return pykd.DEBUG_STATUS_NO_CHANGE
|
||||
self.out_counter=0
|
||||
self.verbose_counter = 0
|
||||
|
||||
def onExecutionStatusChange(self,status):
|
||||
print status
|
||||
def onDebugOutput(self, text, mask):
|
||||
if mask == pykd.outputFlag.Normal:
|
||||
self.out_counter += 1
|
||||
elif mask == pykd.outputFlag.Verbose:
|
||||
self.verbose_counter += 1
|
||||
|
||||
class EventTest( unittest.TestCase ):
|
||||
class OutputHandlerTest( unittest.TestCase ):
|
||||
|
||||
def testDebugBreak( self ):
|
||||
h = handler()
|
||||
pykd.go()
|
||||
pykd.go()
|
||||
self.assertEqual( 2, h.counter )
|
||||
def setUp(self):
|
||||
self.oldMask = pykd.getOutputMask()
|
||||
self.handler = OutHandler()
|
||||
|
||||
def tearDown(self):
|
||||
pykd.killAllProcesses()
|
||||
pykd.setOutputMask(self.oldMask)
|
||||
|
||||
def testDebugOutput(self):
|
||||
pykd.startProcess( target.appPath )
|
||||
self.assertTrue( 0 < self.handler.out_counter)
|
||||
self.assertFalse( 0 < self.handler.verbose_counter)
|
||||
|
||||
def testDebugOutputMask(self):
|
||||
pykd.setOutputMask(pykd.outputFlag.Normal | pykd.outputFlag.Verbose)
|
||||
pykd.startProcess( target.appPath )
|
||||
self.assertTrue( 0 < self.handler.out_counter)
|
||||
self.assertTrue( 0 < self.handler.verbose_counter)
|
@ -30,6 +30,7 @@ import synsymtest
|
||||
import taggedtest
|
||||
import arm64dumptest
|
||||
import armdumptest
|
||||
import eventtest
|
||||
|
||||
pykd.initialize()
|
||||
|
||||
@ -71,7 +72,8 @@ def getTestSuite( singleName = "" ):
|
||||
unittest.TestLoader().loadTestsFromTestCase( taggedtest.TaggedTest ),
|
||||
unittest.TestLoader().loadTestsFromTestCase( arm64dumptest.ARM64DumpTest ),
|
||||
unittest.TestLoader().loadTestsFromTestCase( armdumptest.ARMDumpTest ),
|
||||
|
||||
unittest.TestLoader().loadTestsFromTestCase( eventtest.OutputHandlerTest ),
|
||||
|
||||
#unittest.TestLoader().loadTestsFromTestCase( excepttest.ExceptionTest ),
|
||||
] )
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user