mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 11:34:53 +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);
|
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
|
// processes end threads
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
void onChangeLocalScope() override;
|
void onChangeLocalScope() override;
|
||||||
void onChangeSymbolPaths() override;
|
void onChangeSymbolPaths() override;
|
||||||
void onChangeBreakpoints() 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 onStartInput() override;
|
||||||
void onStopInput() override;
|
void onStopInput() override;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define PYKD_VERSION_MAJOR 0
|
#define PYKD_VERSION_MAJOR 0
|
||||||
#define PYKD_VERSION_MINOR 3
|
#define PYKD_VERSION_MINOR 3
|
||||||
#define PYKD_VERSION_SUBVERSION 4
|
#define PYKD_VERSION_SUBVERSION 4
|
||||||
#define PYKD_VERSION_BUILDNO 4
|
#define PYKD_VERSION_BUILDNO 5
|
||||||
|
|
||||||
#define __VER_STR2__(x) #x
|
#define __VER_STR2__(x) #x
|
||||||
#define __VER_STR1__(x) __VER_STR2__(x)
|
#define __VER_STR1__(x) __VER_STR2__(x)
|
||||||
|
@ -194,7 +194,10 @@ void pykd_init()
|
|||||||
"Return debug options" );
|
"Return debug options" );
|
||||||
python::def( "changeDebugOptions", pykd::changeDebugOptions,
|
python::def( "changeDebugOptions", pykd::changeDebugOptions,
|
||||||
"Change debug options" );
|
"Change debug options" );
|
||||||
|
python::def("getOutputMask", pykd::getOutputMask,
|
||||||
|
"Get output mask");
|
||||||
|
python::def("setOutputMask", pykd::setOutputMask,
|
||||||
|
"Set output mask");
|
||||||
|
|
||||||
python::def( "breakin", pykd::targetBreak,
|
python::def( "breakin", pykd::targetBreak,
|
||||||
"Break into debugger" );
|
"Break into debugger" );
|
||||||
@ -1437,6 +1440,21 @@ void pykd_init()
|
|||||||
.value("Execute", kdlib::Execute)
|
.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
|
// C++ exception translation to python
|
||||||
pykd::registerExceptions();
|
pykd::registerExceptions();
|
||||||
}
|
}
|
||||||
|
@ -17,3 +17,5 @@ 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_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=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 target
|
||||||
import pykd
|
import pykd
|
||||||
|
|
||||||
class handler( pykd.eventHandler ):
|
class OutHandler( pykd.eventHandler ):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pykd.eventHandler.__init__(self)
|
pykd.eventHandler.__init__(self)
|
||||||
self.counter=0
|
self.out_counter=0
|
||||||
|
self.verbose_counter = 0
|
||||||
|
|
||||||
def onException(self, param):
|
def onDebugOutput(self, text, mask):
|
||||||
self.counter += 1
|
if mask == pykd.outputFlag.Normal:
|
||||||
return pykd.DEBUG_STATUS_NO_CHANGE
|
self.out_counter += 1
|
||||||
|
elif mask == pykd.outputFlag.Verbose:
|
||||||
|
self.verbose_counter += 1
|
||||||
|
|
||||||
def onExecutionStatusChange(self,status):
|
class OutputHandlerTest( unittest.TestCase ):
|
||||||
print status
|
|
||||||
|
|
||||||
class EventTest( unittest.TestCase ):
|
def setUp(self):
|
||||||
|
self.oldMask = pykd.getOutputMask()
|
||||||
|
self.handler = OutHandler()
|
||||||
|
|
||||||
def testDebugBreak( self ):
|
def tearDown(self):
|
||||||
h = handler()
|
pykd.killAllProcesses()
|
||||||
pykd.go()
|
pykd.setOutputMask(self.oldMask)
|
||||||
pykd.go()
|
|
||||||
self.assertEqual( 2, h.counter )
|
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 taggedtest
|
||||||
import arm64dumptest
|
import arm64dumptest
|
||||||
import armdumptest
|
import armdumptest
|
||||||
|
import eventtest
|
||||||
|
|
||||||
pykd.initialize()
|
pykd.initialize()
|
||||||
|
|
||||||
@ -71,6 +72,7 @@ def getTestSuite( singleName = "" ):
|
|||||||
unittest.TestLoader().loadTestsFromTestCase( taggedtest.TaggedTest ),
|
unittest.TestLoader().loadTestsFromTestCase( taggedtest.TaggedTest ),
|
||||||
unittest.TestLoader().loadTestsFromTestCase( arm64dumptest.ARM64DumpTest ),
|
unittest.TestLoader().loadTestsFromTestCase( arm64dumptest.ARM64DumpTest ),
|
||||||
unittest.TestLoader().loadTestsFromTestCase( armdumptest.ARMDumpTest ),
|
unittest.TestLoader().loadTestsFromTestCase( armdumptest.ARMDumpTest ),
|
||||||
|
unittest.TestLoader().loadTestsFromTestCase( eventtest.OutputHandlerTest ),
|
||||||
|
|
||||||
#unittest.TestLoader().loadTestsFromTestCase( excepttest.ExceptionTest ),
|
#unittest.TestLoader().loadTestsFromTestCase( excepttest.ExceptionTest ),
|
||||||
] )
|
] )
|
||||||
|
Loading…
Reference in New Issue
Block a user