mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-29 20:03:33 +08:00
[0.3.x] added : removeBp routine ( Remove breakpoint by index )
git-svn-id: https://pykd.svn.codeplex.com/svn@90875 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
2bc893d25b
commit
1d25e61d02
@ -690,6 +690,16 @@ Breakpoint* Breakpoint::getBreakpointByIndex(unsigned long index)
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void Breakpoint::removeBreakpointByIndex(unsigned long index)
|
||||||
|
{
|
||||||
|
AutoRestorePyState pystate;
|
||||||
|
kdlib::BreakpointPtr bp;
|
||||||
|
bp = kdlib::getBreakpointByIndex(index);
|
||||||
|
bp->remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // end namespace pykd
|
} // end namespace pykd
|
||||||
|
@ -64,6 +64,8 @@ public:
|
|||||||
|
|
||||||
static Breakpoint* getBreakpointByIndex(unsigned long index);
|
static Breakpoint* getBreakpointByIndex(unsigned long index);
|
||||||
|
|
||||||
|
static void removeBreakpointByIndex(unsigned long index);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit Breakpoint(kdlib::BreakpointPtr bp, bool weakbp = true);
|
explicit Breakpoint(kdlib::BreakpointPtr bp, bool weakbp = true);
|
||||||
|
@ -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 0
|
#define PYKD_VERSION_SUBVERSION 0
|
||||||
#define PYKD_VERSION_BUILDNO 34
|
#define PYKD_VERSION_BUILDNO 35
|
||||||
|
|
||||||
#define __VER_STR2__(x) #x
|
#define __VER_STR2__(x) #x
|
||||||
#define __VER_STR1__(x) __VER_STR2__(x)
|
#define __VER_STR1__(x) __VER_STR2__(x)
|
||||||
|
@ -393,6 +393,8 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Return number of breakpoints in the current process" );
|
"Return number of breakpoints in the current process" );
|
||||||
python::def( "getBp", &Breakpoint::getBreakpointByIndex, python::return_value_policy<python::manage_new_object>(),
|
python::def( "getBp", &Breakpoint::getBreakpointByIndex, python::return_value_policy<python::manage_new_object>(),
|
||||||
"Return breakpoint object by index");
|
"Return breakpoint object by index");
|
||||||
|
python::def("removeBp", &Breakpoint::removeBreakpointByIndex,
|
||||||
|
"Remove breakpoint by index");
|
||||||
|
|
||||||
// processes and threads
|
// processes and threads
|
||||||
python::def ( "getNumberProcesses", pykd::getNumberProcesses,
|
python::def ( "getNumberProcesses", pykd::getNumberProcesses,
|
||||||
|
@ -5,19 +5,26 @@ from optparse import OptionParser
|
|||||||
from fnmatch import fnmatch
|
from fnmatch import fnmatch
|
||||||
import traceback
|
import traceback
|
||||||
import sys
|
import sys
|
||||||
|
import datetime
|
||||||
|
|
||||||
nt = None
|
nt = None
|
||||||
EPROCESS = None
|
EPROCESS = None
|
||||||
ETHREAD = None
|
ETHREAD = None
|
||||||
|
Tick = None
|
||||||
|
|
||||||
def setupGlobalObject():
|
def setupGlobalObject():
|
||||||
|
|
||||||
global nt, EPROCESS, ETHREAD
|
global nt, EPROCESS, ETHREAD, Tick
|
||||||
|
|
||||||
try:
|
try:
|
||||||
nt = module("nt")
|
nt = module("nt")
|
||||||
EPROCESS = nt.type("_EPROCESS")
|
EPROCESS = nt.type("_EPROCESS")
|
||||||
ETHREAD = nt.type("_ETHREAD")
|
ETHREAD = nt.type("_ETHREAD")
|
||||||
|
if is64bitSystem():
|
||||||
|
Tick = int(typedVar("nt!_LARGE_INTEGER", 0xFFFFF78000000320).QuadPart)
|
||||||
|
else:
|
||||||
|
Tick = int(ptrDWord(nt.KeTickCount))
|
||||||
|
|
||||||
except DbgException:
|
except DbgException:
|
||||||
dprintln("check symbol paths")
|
dprintln("check symbol paths")
|
||||||
|
|
||||||
@ -27,7 +34,7 @@ class PrintOptions:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.ignoreNotActiveThread = True
|
self.ignoreNotActiveThread = True
|
||||||
self.ignoreNotActiveProcess = True
|
self.ignoreNotActiveProcess = True
|
||||||
self.showWow64stack = is64bitSystem()
|
self.showWow64stack = False
|
||||||
self.showIP = True
|
self.showIP = True
|
||||||
self.showSP = True
|
self.showSP = True
|
||||||
self.showUnique = False
|
self.showUnique = False
|
||||||
@ -80,15 +87,30 @@ def getStackSymbols(stk):
|
|||||||
symbols.append(sym)
|
symbols.append(sym)
|
||||||
return symbols
|
return symbols
|
||||||
|
|
||||||
|
def isWow64Process(process):
|
||||||
|
result = False
|
||||||
|
if is64bitSystem() == False:
|
||||||
|
return result
|
||||||
|
try:
|
||||||
|
if hasattr(process, "WoW64Process"):
|
||||||
|
return process.WoW64Process != 0
|
||||||
|
elif hasattr(process, "Wow64Process"):
|
||||||
|
return process.Wow64Process != 0
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def printThread(thread, process):
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def printThread(thread, process, ticks):
|
||||||
dprintln("")
|
dprintln("")
|
||||||
dprintln( "Thread %x, Process: %s (%x)" % ( thread, loadCStr( process.ImageFileName ), process ) )
|
dprintln( "<link cmd=\".process %x;.thread %x\">Thread %x</link>, Process: %s (%x), Ticks: %d" % ( process, thread, thread, loadCStr( process.ImageFileName ), process, ticks ), True )
|
||||||
|
|
||||||
|
|
||||||
def printProcess(process,processFilter,threadFilter,moduleFilter,funcFilter,printopt):
|
def printProcess(process,processFilter,threadFilter,moduleFilter,funcFilter,printopt):
|
||||||
|
|
||||||
processName = loadCStr( process.ImageFileName )
|
processName = loadCStr( process.ImageFileName )
|
||||||
|
processWow64 = isWow64Process(process)
|
||||||
|
|
||||||
if processFilter and not processFilter(process, process.UniqueProcessId, processName ):
|
if processFilter and not processFilter(process, process.UniqueProcessId, processName ):
|
||||||
return
|
return
|
||||||
@ -111,7 +133,8 @@ def printProcess(process,processFilter,threadFilter,moduleFilter,funcFilter,prin
|
|||||||
|
|
||||||
for thread in threadLst:
|
for thread in threadLst:
|
||||||
|
|
||||||
if threadFilter and not threadFilter( thread.Tcb, thread.Cid.UniqueThread ):
|
ticks = Tick - thread.Tcb.WaitTime
|
||||||
|
if threadFilter and not threadFilter( thread.Tcb, thread.Cid.UniqueThread, ticks ):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -121,7 +144,7 @@ def printProcess(process,processFilter,threadFilter,moduleFilter,funcFilter,prin
|
|||||||
stkNative = getStack()
|
stkNative = getStack()
|
||||||
stkWow64 = []
|
stkWow64 = []
|
||||||
|
|
||||||
if printopt.showWow64stack == True:
|
if processWow64 and printopt.showWow64stack == True:
|
||||||
try:
|
try:
|
||||||
|
|
||||||
switchCPUMode();
|
switchCPUMode();
|
||||||
@ -178,14 +201,14 @@ def printProcess(process,processFilter,threadFilter,moduleFilter,funcFilter,prin
|
|||||||
if not match:
|
if not match:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
printThread( thread, process )
|
printThread( thread, process, ticks )
|
||||||
|
|
||||||
for frame in stk:
|
for frame in stk:
|
||||||
printFrame(frame, printopt)
|
printFrame(frame, printopt)
|
||||||
|
|
||||||
except DbgException:
|
except DbgException:
|
||||||
|
|
||||||
printThread( thread, process )
|
printThread( thread, process, ticks )
|
||||||
dprintln( "Failed to get stack")
|
dprintln( "Failed to get stack")
|
||||||
|
|
||||||
|
|
||||||
@ -219,8 +242,8 @@ def main():
|
|||||||
parser.add_option("-u", "--unique", action="store_true", dest="uniquestack",
|
parser.add_option("-u", "--unique", action="store_true", dest="uniquestack",
|
||||||
help="show only unique stacks" )
|
help="show only unique stacks" )
|
||||||
parser.add_option("-d", "--dump", dest="dumpname",
|
parser.add_option("-d", "--dump", dest="dumpname",
|
||||||
help="open crach dump" )
|
help="open crash dump" )
|
||||||
parser.add_option("-w", "--wow64", dest="wow64",
|
parser.add_option("-w", "--wow64", action="store_true", dest="wow64",
|
||||||
help="show WOW64 stacks")
|
help="show WOW64 stacks")
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
@ -255,13 +278,13 @@ def main():
|
|||||||
funcFilter = lambda name: eval( options.funcfilter)
|
funcFilter = lambda name: eval( options.funcfilter)
|
||||||
|
|
||||||
if options.threadfilter:
|
if options.threadfilter:
|
||||||
threadFilter = lambda thread, tid: eval( options.threadfilter)
|
threadFilter = lambda thread, tid, ticks: eval( options.threadfilter)
|
||||||
|
|
||||||
printopt = PrintOptions()
|
printopt = PrintOptions()
|
||||||
printopt.showUnique = True if options.uniquestack else False
|
printopt.showUnique = True if options.uniquestack else False
|
||||||
|
|
||||||
if options.wow64 != None:
|
if options.wow64 == True and is64bitSystem():
|
||||||
printopt.showWow64stack = options.wow64.lower() == 'true'
|
printopt.showWow64stack = True
|
||||||
|
|
||||||
|
|
||||||
processLst = nt.typedVarList( nt.PsActiveProcessHead, "_EPROCESS", "ActiveProcessLinks.Flink")
|
processLst = nt.typedVarList( nt.PsActiveProcessHead, "_EPROCESS", "ActiveProcessLinks.Flink")
|
||||||
|
@ -44,6 +44,12 @@ class BreakpointTest( unittest.TestCase ):
|
|||||||
bp.remove()
|
bp.remove()
|
||||||
self.assertEqual( pykd.executionStatus.NoDebuggee, pykd.go() )
|
self.assertEqual( pykd.executionStatus.NoDebuggee, pykd.go() )
|
||||||
|
|
||||||
|
def testRemoveByIndex(self):
|
||||||
|
bp1 = pykd.setBp( self.targetModule.CdeclFunc )
|
||||||
|
bp2 = pykd.getBp(0)
|
||||||
|
bp2.remove()
|
||||||
|
self.assertEqual( pykd.executionStatus.NoDebuggee, pykd.go() )
|
||||||
|
|
||||||
def disable_testDeleteBp(self):
|
def disable_testDeleteBp(self):
|
||||||
bp = pykd.setBp( self.targetModule.CdeclFunc )
|
bp = pykd.setBp( self.targetModule.CdeclFunc )
|
||||||
del bp
|
del bp
|
||||||
|
@ -108,11 +108,7 @@ class TypedVarTest( unittest.TestCase ):
|
|||||||
self.assertEqual( 3, tv.m_noArrayField )
|
self.assertEqual( 3, tv.m_noArrayField )
|
||||||
self.assertNotEqual( -1, tv.m_arrayField[0] )
|
self.assertNotEqual( -1, tv.m_arrayField[0] )
|
||||||
self.assertNotEqual( 0, tv.m_noArrayField )
|
self.assertNotEqual( 0, tv.m_noArrayField )
|
||||||
try:
|
tv.m_arrayField[len(tv.m_arrayField)]
|
||||||
tv.m_arrayField[len(tv.m_arrayField)]
|
|
||||||
self.assertTrue(False)
|
|
||||||
except IndexError:
|
|
||||||
self.assertTrue(True)
|
|
||||||
|
|
||||||
#def testArrayFieldSlice(self):
|
#def testArrayFieldSlice(self):
|
||||||
# tv = target.module.typedVar( "g_structWithArray" )
|
# tv = target.module.typedVar( "g_structWithArray" )
|
||||||
|
Loading…
Reference in New Issue
Block a user