Update of /cvsroot/pywin32/pywin32/com/win32comext/axdebug
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv824
Modified Files:
__init__.py adb.py codecontainer.py contexts.py debugger.py
documents.py dump.py expressions.py gateways.py stackframe.py
util.py
Log Message:
convert tabs to spaces via reindent.py
Index: expressions.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axdebug/expressions.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** expressions.py 18 Jun 2006 13:09:36 -0000 1.4
--- expressions.py 18 Jun 2006 13:18:26 -0000 1.5
***************
*** 10,156 ****
# Given an object, return a nice string
def MakeNiceString(ob):
! stream = cStringIO.StringIO()
! pprint(ob, stream)
! return string.strip(stream.getvalue())
class ProvideExpressionContexts(gateways.ProvideExpressionContexts):
! pass
class ExpressionContext(gateways.DebugExpressionContext):
! def __init__(self, frame):
! self.frame = frame
! def ParseLanguageText(self, code, radix, delim, flags):
! return _wrap(Expression(self.frame, code, radix, delim, flags), axdebug.IID_IDebugExpression)
! def GetLanguageInfo(self):
! # print "GetLanguageInfo"
! return "Python", "{DF630910-1C1D-11d0-AE36-8C0F5E000000}"
!
class Expression(gateways.DebugExpression):
! def __init__(self, frame, code, radix, delim, flags):
! self.callback = None
! self.frame = frame
! self.code = code
! self.radix = radix
! self.delim = delim
! self.flags = flags
! self.isComplete = 0
! self.result=None
! self.hresult = winerror.E_UNEXPECTED
! def Start(self, callback):
! try:
! try:
! try:
! self.result = eval(self.code, self.frame.f_globals, self.frame.f_locals)
! except SyntaxError:
! exec self.code in self.frame.f_globals, self.frame.f_locals
! self.result = ""
! self.hresult = 0
! except:
! l = traceback.format_exception_only(sys.exc_info()[0], sys.exc_info()[1])
! # l is a list of strings with trailing "\n"
! self.result = string.join(map(lambda s:s[:-1], l), "\n")
! self.hresult = winerror.E_FAIL
! finally:
! self.isComplete = 1
! callback.onComplete()
! def Abort(self):
! print "** ABORT **"
!
! def QueryIsComplete(self):
! return self.isComplete
!
! def GetResultAsString(self):
! # print "GetStrAsResult returning", self.result
! return self.hresult, MakeNiceString(self.result)
!
! def GetResultAsDebugProperty(self):
! result = _wrap(DebugProperty(self.code, self.result, None, self.hresult), axdebug.IID_IDebugProperty)
! return self.hresult, result
def MakeEnumDebugProperty(object, dwFieldSpec, nRadix, iid, stackFrame = None):
! name_vals = []
! if hasattr(object, "has_key"): # If it is a dict.
! name_vals = object.items()
! dictionary = object
! elif hasattr(object, "__dict__"): #object with dictionary, module
! name_vals = object.__dict__.items()
! dictionary = object.__dict__
! infos = []
! for name, val in name_vals:
! infos.append(GetPropertyInfo(name, val, dwFieldSpec, nRadix, 0, dictionary, stackFrame))
! return _wrap(EnumDebugPropertyInfo(infos), axdebug.IID_IEnumDebugPropertyInfo)
def GetPropertyInfo(obname, obvalue, dwFieldSpec, nRadix, hresult=0, dictionary = None, stackFrame = None):
! # returns a tuple
! name = typ = value = fullname = attrib = dbgprop = None
! if dwFieldSpec & axdebug.DBGPROP_INFO_VALUE:
! value = MakeNiceString(obvalue)
! if dwFieldSpec & axdebug.DBGPROP_INFO_NAME:
! name = obname
! if dwFieldSpec & axdebug.DBGPROP_INFO_TYPE:
! if hresult:
! typ = "Error"
! else:
! try:
! typ = type(obvalue).__name__
! except AttributeError:
! typ = str(type(obvalue))
! if dwFieldSpec & axdebug.DBGPROP_INFO_FULLNAME:
! fullname = obname
! if dwFieldSpec & axdebug.DBGPROP_INFO_ATTRIBUTES:
! if hasattr(obvalue, "has_key") or hasattr(obvalue, "__dict__"): # If it is a dict or object
! attrib = axdebug.DBGPROP_ATTRIB_VALUE_IS_EXPANDABLE
! else:
! attrib = 0
! if dwFieldSpec & axdebug.DBGPROP_INFO_DEBUGPROP:
! dbgprop = _wrap(DebugProperty(name, obvalue, None, hresult, dictionary, stackFrame), axdebug.IID_IDebugProperty)
! return name, typ, value, fullname, attrib, dbgprop
from win32com.server.util import ListEnumeratorGateway
class EnumDebugPropertyInfo(ListEnumeratorGateway):
! """A class to expose a Python sequence as an EnumDebugCodeContexts
! Create an instance of this class passing a sequence (list, tuple, or
! any sequence protocol supporting object) and it will automatically
! support the EnumDebugCodeContexts interface for the object.
! """
! _public_methods_ = ListEnumeratorGateway._public_methods_ + ["GetCount"]
! _com_interfaces_ = [ axdebug.IID_IEnumDebugPropertyInfo]
! def GetCount(self):
! return len(self._list_)
! def _wrap(self, ob):
! return ob
class DebugProperty:
! _com_interfaces_ = [axdebug.IID_IDebugProperty]
! _public_methods_ = ['GetPropertyInfo', 'GetExtendedInfo', 'SetValueAsString',
! 'EnumMembers', 'GetParent'
! ]
! def __init__(self, name, value, parent = None, hresult = 0, dictionary = None, stackFrame = None):
! self.name = name
! self.value = value
! self.parent = parent
! self.hresult = hresult
! self.dictionary = dictionary
! self.stackFrame = stackFrame
! def GetPropertyInfo(self, dwFieldSpec, nRadix):
! return GetPropertyInfo(self.name, self.value, dwFieldSpec, nRadix, self.hresult, dictionary, stackFrame)
! def GetExtendedInfo(self): ### Note - not in the framework.
! RaiseNotImpl("DebugProperty::GetExtendedInfo")
! def SetValueAsString(self, value, radix):
! if self.stackFrame and self.dictionary:
! self.dictionary[self.name]= eval(value,self.stackFrame.f_globals, self.stackFrame.f_locals)
! else:
! RaiseNotImpl("DebugProperty::SetValueAsString")
! def EnumMembers(self, dwFieldSpec, nRadix, iid):
! # Returns IEnumDebugPropertyInfo
! return MakeEnumDebugProperty(self.value, dwFieldSpec, nRadix, iid, self.stackFrame)
! def GetParent(self):
! # return IDebugProperty
! RaiseNotImpl("DebugProperty::GetParent")
--- 10,156 ----
# Given an object, return a nice string
def MakeNiceString(ob):
! stream = cStringIO.StringIO()
! pprint(ob, stream)
! return string.strip(stream.getvalue())
class ProvideExpressionContexts(gateways.ProvideExpressionContexts):
! pass
class ExpressionContext(gateways.DebugExpressionContext):
! def __init__(self, frame):
! self.frame = frame
! def ParseLanguageText(self, code, radix, delim, flags):
! return _wrap(Expression(self.frame, code, radix, delim, flags), axdebug.IID_IDebugExpression)
! def GetLanguageInfo(self):
! # print "GetLanguageInfo"
! return "Python", "{DF630910-1C1D-11d0-AE36-8C0F5E000000}"
!
class Expression(gateways.DebugExpression):
! def __init__(self, frame, code, radix, delim, flags):
! self.callback = None
! self.frame = frame
! self.code = code
! self.radix = radix
! self.delim = delim
! self.flags = flags
! self.isComplete = 0
! self.result=None
! self.hresult = winerror.E_UNEXPECTED
! def Start(self, callback):
! try:
! try:
! try:
! self.result = eval(self.code, self.frame.f_globals, self.frame.f_locals)
! except SyntaxError:
! exec self.code in self.frame.f_globals, self.frame.f_locals
! self.result = ""
! self.hresult = 0
! except:
! l = traceback.format_exception_only(sys.exc_info()[0], sys.exc_info()[1])
! # l is a list of strings with trailing "\n"
! self.result = string.join(map(lambda s:s[:-1], l), "\n")
! self.hresult = winerror.E_FAIL
! finally:
! self.isComplete = 1
! callback.onComplete()
! def Abort(self):
! print "** ABORT **"
!
! def QueryIsComplete(self):
! return self.isComplete
!
! def GetResultAsString(self):
! # print "GetStrAsResult returning", self.result
! return self.hresult, MakeNiceString(self.result)
!
! def GetResultAsDebugProperty(self):
! result = _wrap(DebugProperty(self.code, self.result, None, self.hresult), axdebug.IID_IDebugProperty)
! return self.hresult, result
def MakeEnumDebugProperty(object, dwFieldSpec, nRadix, iid, stackFrame = None):
! name_vals = []
! if hasattr(object, "has_key"): # If it is a dict.
! name_vals = object.items()
! dictionary = object
! elif hasattr(object, "__dict__"): #object with dictionary, module
! name_vals = object.__dict__.items()
! dictionary = object.__dict__
! infos = []
! for name, val in name_vals:
! infos.append(GetPropertyInfo(name, val, dwFieldSpec, nRadix, 0, dictionary, stackFrame))
! return _wrap(EnumDebugPropertyInfo(infos), axdebug.IID_IEnumDebugPropertyInfo)
def GetPropertyInfo(obname, obvalue, dwFieldSpec, nRadix, hresult=0, dictionary = None, stackFrame = None):
! # returns a tuple
! name = typ = value = fullname = attrib = dbgprop = None
! if dwFieldSpec & axdebug.DBGPROP_INFO_VALUE:
! value = MakeNiceString(obvalue)
! if dwFieldSpec & axdebug.DBGPROP_INFO_NAME:
! name = obname
! if dwFieldSpec & axdebug.DBGPROP_INFO_TYPE:
! if hresult:
! typ = "Error"
! else:
! try:
! typ = type(obvalue).__name__
! except AttributeError:
! typ = str(type(obvalue))
! if dwFieldSpec & axdebug.DBGPROP_INFO_FULLNAME:
! fullname = obname
! if dwFieldSpec & axdebug.DBGPROP_INFO_ATTRIBUTES:
! if hasattr(obvalue, "has_key") or hasattr(obvalue, "__dict__"): # If it is a dict or object
! attrib = axdebug.DBGPROP_ATTRIB_VALUE_IS_EXPANDABLE
! else:
! attrib = 0
! if dwFieldSpec & axdebug.DBGPROP_INFO_DEBUGPROP:
! dbgprop = _wrap(DebugProperty(name, obvalue, None, hresult, dictionary, stackFrame), axdebug.IID_IDebugProperty)
! return name, typ, value, fullname, attrib, dbgprop
from win32com.server.util import ListEnumeratorGateway
class EnumDebugPropertyInfo(ListEnumeratorGateway):
! """A class to expose a Python sequence as an EnumDebugCodeContexts
! Create an instance of this class passing a sequence (list, tuple, or
! any sequence protocol supporting object) and it will automatically
! support the EnumDebugCodeContexts interface for the object.
! """
! _public_methods_ = ListEnumeratorGateway._public_methods_ + ["GetCount"]
! _com_interfaces_ = [ axdebug.IID_IEnumDebugPropertyInfo]
! def GetCount(self):
! return len(self._list_)
! def _wrap(self, ob):
! return ob
class DebugProperty:
! _com_interfaces_ = [axdebug.IID_IDebugProperty]
! _public_methods_ = ['GetPropertyInfo', 'GetExtendedInfo', 'SetValueAsString',
! 'EnumMembers', 'GetParent'
! ]
! def __init__(self, name, value, parent = None, hresult = 0, dictionary = None, stackFrame = None):
! self.name = name
! self.value = value
! self.parent = parent
! self.hresult = hresult
! self.dictionary = dictionary
! self.stackFrame = stackFrame
! def GetPropertyInfo(self, dwFieldSpec, nRadix):
! return GetPropertyInfo(self.name, self.value, dwFieldSpec, nRadix, self.hresult, dictionary, stackFrame)
! def GetExtendedInfo(self): ### Note - not in the framework.
! RaiseNotImpl("DebugProperty::GetExtendedInfo")
! def SetValueAsString(self, value, radix):
! if self.stackFrame and self.dictionary:
! self.dictionary[self.name]= eval(value,self.stackFrame.f_globals, self.stackFrame.f_locals)
! else:
! RaiseNotImpl("DebugProperty::SetValueAsString")
! def EnumMembers(self, dwFieldSpec, nRadix, iid):
! # Returns IEnumDebugPropertyInfo
! return MakeEnumDebugProperty(self.value, dwFieldSpec, nRadix, iid, self.stackFrame)
! def GetParent(self):
! # return IDebugProperty
! RaiseNotImpl("DebugProperty::GetParent")
Index: gateways.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axdebug/gateways.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** gateways.py 6 Jan 2000 04:45:44 -0000 1.2
--- gateways.py 18 Jun 2006 13:18:26 -0000 1.3
***************
*** 11,453 ****
class EnumDebugCodeContexts(ListEnumeratorGateway):
! """A class to expose a Python sequence as an EnumDebugCodeContexts
! Create an instance of this class passing a sequence (list, tuple, or
! any sequence protocol supporting object) and it will automatically
! support the EnumDebugCodeContexts interface for the object.
! """
! _com_interfaces_ = [ axdebug.IID_IEnumDebugCodeContexts ]
class EnumDebugStackFrames(ListEnumeratorGateway):
! """A class to expose a Python sequence as an EnumDebugStackFrames
! Create an instance of this class passing a sequence (list, tuple, or
! any sequence protocol supporting object) and it will automatically
! support the EnumDebugStackFrames interface for the object.
! """
! _com_interfaces_ = [ axdebug.IID_IEnumDebugStackFrames ]
class EnumDebugApplicationNodes(ListEnumeratorGateway):
! """A class to expose a Python sequence as an EnumDebugStackFrames
! Create an instance of this class passing a sequence (list, tuple, or
! any sequence protocol supporting object) and it will automatically
! support the EnumDebugApplicationNodes interface for the object.
! """
! _com_interfaces_ = [ axdebug.IID_IEnumDebugApplicationNodes ]
class EnumRemoteDebugApplications(ListEnumeratorGateway):
! _com_interfaces_ = [ axdebug.IID_IEnumRemoteDebugApplications ]
class EnumRemoteDebugApplicationThreads(ListEnumeratorGateway):
! _com_interfaces_ = [ axdebug.IID_IEnumRemoteDebugApplicationThreads ]
class DebugDocumentInfo:
! _public_methods_ = ["GetName", "GetDocumentClassId"]
! _com_interfaces_ = [axdebug.IID_IDebugDocumentInfo]
! def __init__(self):
! pass
! def GetName(self, dnt):
! """ Get the one of the name of the document
! dnt -- int DOCUMENTNAMETYPE
! """
! RaiseNotImpl("GetName")
! def GetDocumentClassId(self):
! """
! Result must be an IID object (or string representing one).
! """
! RaiseNotImpl("GetDocumentClassId")
!
class DebugDocumentProvider(DebugDocumentInfo):
! _public_methods_ = DebugDocumentInfo._public_methods_ + ["GetDocument"]
! _com_interfaces_ = DebugDocumentInfo._com_interfaces_ + [axdebug.IID_IDebugDocumentProvider]
! def GetDocument(self):
! RaiseNotImpl("GetDocument")
class DebugApplicationNode(DebugDocumentProvider):
! """Provides the functionality of IDebugDocumentProvider, plus a context within a project tree.
! """
! _public_methods_ = string.split("""EnumChildren GetParent SetDocumentProvider
! Close Attach Detach""") + \
! DebugDocumentProvider._public_methods_
! _com_interfaces_ = [axdebug.IID_IDebugDocumentProvider] + \
! DebugDocumentProvider._com_interfaces_
! def __init__(self):
! DebugDocumentProvider.__init__(self)
! def EnumChildren(self):
! # Result is type PyIEnumDebugApplicationNodes
! RaiseNotImpl("EnumChildren")
! def GetParent(self):
! # result is type PyIDebugApplicationNode
! RaiseNotImpl("GetParent")
! def SetDocumentProvider(self, pddp): # PyIDebugDocumentProvider pddp
! # void result.
! RaiseNotImpl("SetDocumentProvider")
! def Close(self):
! # void result.
! RaiseNotImpl("Close")
! def Attach(self, parent): # PyIDebugApplicationNode
! # void result.
! RaiseNotImpl("Attach")
! def Detach(self):
! # void result.
! RaiseNotImpl("Detach")
class DebugApplicationNodeEvents:
! """Event interface for DebugApplicationNode object.
! """
! _public_methods_ = string.split("onAddChild onRemoveChild onDetach")
! _com_interfaces_ = [axdebug.IID_IDebugApplicationNodeEvents]
! def __init__(self):
! pass
! def onAddChild(self, child): # PyIDebugApplicationNode
! # void result.
! RaiseNotImpl("onAddChild")
! def onRemoveChild(self, child): # PyIDebugApplicationNode
! # void result.
! RaiseNotImpl("onRemoveChild")
! def onDetach(self):
! # void result.
! RaiseNotImpl("onDetach")
! def onAttach(self, parent): # PyIDebugApplicationNode
! # void result.
! RaiseNotImpl("onAttach")
class DebugDocument(DebugDocumentInfo):
! """The base interface to all debug documents.
! """
! _public_methods_ = DebugDocumentInfo._public_methods_
! _com_interfaces_ = [axdebug.IID_IDebugDocument] + DebugDocumentInfo._com_interfaces_
class DebugDocumentText(DebugDocument):
! """The interface to a text only debug document.
! """
! _com_interfaces_ = [axdebug.IID_IDebugDocumentText] + \
! DebugDocument._com_interfaces_
! _public_methods_ = ["GetDocumentAttributes", "GetSize",
! "GetPositionOfLine", "GetLineOfPosition", "GetText",
! "GetPositionOfContext", "GetContextOfPosition"] + \
! DebugDocument._public_methods_
! def __init__(self):
! pass
! # IDebugDocumentText
! def GetDocumentAttributes(self):
! # Result is int (TEXT_DOC_ATTR)
! RaiseNotImpl("GetDocumentAttributes")
! def GetSize(self):
! # Result is (numLines, numChars)
! RaiseNotImpl("GetSize")
! def GetPositionOfLine(self, cLineNumber):
! # Result is int char position
! RaiseNotImpl("GetPositionOfLine")
! def GetLineOfPosition(self, charPos):
! # Result is int, int (lineNo, offset)
! RaiseNotImpl("GetLineOfPosition")
! def GetText(self, charPos, maxChars, wantAttr):
! """Params
! charPos -- integer
! maxChars -- integer
! wantAttr -- Should the function compute attributes.
! Return value must be (string, attribtues). attributes may be
! None if(not wantAttr)
! """
! RaiseNotImpl("GetText")
! def GetPositionOfContext(self, debugDocumentContext):
! """Params
! debugDocumentContext -- a PyIDebugDocumentContext object.
!
! Return value must be (charPos, numChars)
! """
! RaiseNotImpl("GetPositionOfContext")
! def GetContextOfPosition(self, charPos, maxChars):
! """Params are integers.
! Return value must be PyIDebugDocumentContext object
! """
! print self
! RaiseNotImpl("GetContextOfPosition")
class DebugDocumentTextExternalAuthor:
! """Allow external editors to edit file-based debugger documents, and to notify the document when the source file has been changed.
! """
! _public_methods_ = ["GetPathName", "GetFileName", "NotifyChanged"]
! _com_interfaces_ = [axdebug.IID_IDebugDocumentTextExternalAuthor]
! def __init__(self):
! pass
! def GetPathName(self):
! """Return the full path (including file name) to the document's source file.
!
! Result must be (filename, fIsOriginal), where
! - if fIsOriginalPath is TRUE if the path refers to the original file for the document.
! - if fIsOriginalPath is FALSE if the path refers to a newly created temporary file.
! raise Exception(winerror.E_FAIL) if no source file can be created/determined.
! """
! RaiseNotImpl("GetPathName")
!
! def GetFileName(self):
! """Return just the name of the document, with no path information. (Used for "Save As...")
! Result is a string
! """
! RaiseNotImpl("GetFileName")
!
! def NotifyChanged(self):
! """ Notify the host that the document's source file has been saved and
! that its contents should be refreshed.
! """
! RaiseNotImpl("NotifyChanged")
class DebugDocumentTextEvents:
! _public_methods_ = string.split("""onDestroy onInsertText onRemoveText
! onReplaceText onUpdateTextAttributes onUpdateDocumentAttributes""")
! _com_interfaces_ = [ axdebug.IID_IDebugDocumentTextEvents ]
! def __init__(self):
! pass
! def onDestroy(self):
! # Result is void.
! RaiseNotImpl("onDestroy")
! def onInsertText(self, cCharacterPosition, cNumToInsert):
! # Result is void.
! RaiseNotImpl("onInsertText")
! def onRemoveText(self, cCharacterPosition, cNumToRemove):
! # Result is void.
! RaiseNotImpl("onRemoveText")
! def onReplaceText(self, cCharacterPosition, cNumToReplace):
! # Result is void.
! RaiseNotImpl("onReplaceText")
! def onUpdateTextAttributes(self, cCharacterPosition, cNumToUpdate):
! # Result is void.
! RaiseNotImpl("onUpdateTextAttributes")
! def onUpdateDocumentAttributes(self,textdocattr): # TEXT_DOC_ATTR
! # Result is void.
! RaiseNotImpl("onUpdateDocumentAttributes")
class DebugDocumentContext:
! _public_methods_ = [ 'GetDocument', 'EnumCodeContexts']
! _com_interfaces_ = [ axdebug.IID_IDebugDocumentContext ]
! def __init__(self):
! pass
! def GetDocument(self):
! """Return value must be a PyIDebugDocument object
! """
! RaiseNotImpl("GetDocument")
! def EnumCodeContexts(self):
! """Return value must be a PyIEnumDebugCodeContexts object
! """
! RaiseNotImpl("EnumCodeContexts")
class DebugCodeContext:
! _public_methods_ = [ 'GetDocumentContext', 'SetBreakPoint']
! _com_interfaces_ = [ axdebug.IID_IDebugCodeContext ]
! def __init__(self):
! pass
! def GetDocumentContext(self):
! """Return value must be a PyIDebugDocumentContext object
! """
! RaiseNotImpl("GetDocumentContext")
! def SetBreakPoint(self, bps):
! """bps -- an integer with flags.
! """
! RaiseNotImpl("SetBreakPoint")
class DebugStackFrame:
! """Abstraction representing a logical stack frame on the stack of a thread."""
! _public_methods_ = [ 'GetCodeContext', 'GetDescriptionString', 'GetLanguageString', 'GetThread', 'GetDebugProperty']
! _com_interfaces_ = [ axdebug.IID_IDebugStackFrame ]
! def __init__(self):
! pass
! def GetCodeContext(self):
! """Returns the current code context associated with the stack frame.
! Return value must be a IDebugCodeContext object
! """
! RaiseNotImpl("GetCodeContext")
! def GetDescriptionString(self, fLong):
! """Returns a textual description of the stack frame.
!
! fLong -- A flag indicating if the long name is requested.
! """
! RaiseNotImpl("GetDescriptionString")
! def GetLanguageString(self):
! """Returns a short or long textual description of the language.
!
! fLong -- A flag indicating if the long name is requested.
! """
! RaiseNotImpl("GetLanguageString")
! def GetThread(self):
! """ Returns the thread associated with this stack frame.
! Result must be a IDebugApplicationThread
! """
! RaiseNotImpl("GetThread")
! def GetDebugProperty(self):
! RaiseNotImpl("GetDebugProperty")
class DebugDocumentHost:
! """The interface from the IDebugDocumentHelper back to
! the smart host or language engine. This interface
! exposes host specific functionality such as syntax coloring.
! """
! _public_methods_ = [ 'GetDeferredText', 'GetScriptTextAttributes', 'OnCreateDocumentContext', 'GetPathName', 'GetFileName', 'NotifyChanged']
! _com_interfaces_ = [ axdebug.IID_IDebugDocumentHost ]
! def __init__(self):
! pass
! def GetDeferredText(self, dwTextStartCookie, maxChars, bWantAttr):
! RaiseNotImpl("GetDeferredText")
!
! def GetScriptTextAttributes(self, codeText, delimterText, flags):
! # Result must be an attribute sequence of same "length" as the code.
! RaiseNotImpl("GetScriptTextAttributes")
!
! def OnCreateDocumentContext(self):
! # Result must be a PyIUnknown
! RaiseNotImpl("OnCreateDocumentContext")
!
! def GetPathName(self):
! # Result must be (string, int) where the int is a BOOL
! # - TRUE if the path refers to the original file for the document.
! # - FALSE if the path refers to a newly created temporary file.
! # - raise Exception(scode=E_FAIL) if no source file can be created/determined.
! RaiseNotImpl("GetPathName")
!
! def GetFileName(self):
! # Result is a string with just the name of the document, no path information.
! RaiseNotImpl("GetFileName")
!
! def NotifyChanged(self):
! RaiseNotImpl("NotifyChanged")
# Additional gateway related functions.
class DebugDocumentTextConnectServer:
! _public_methods_ = win32com.server.connect.IConnectionPointContainer_methods + win32com.server.connect.IConnectionPoint_methods
! _com_interfaces_ = [pythoncom.IID_IConnectionPoint, pythoncom.IID_IConnectionPointContainer]
! # IConnectionPoint interfaces
! def __init__(self):
! self.cookieNo = -1
! self.connections = {}
! def EnumConnections(self):
! RaiseNotImpl("EnumConnections")
! def GetConnectionInterface(self):
! RaiseNotImpl("GetConnectionInterface")
! def GetConnectionPointContainer(self):
! return _wrap(self)
! def Advise(self, pUnk):
! # Creates a connection to the client. Simply allocate a new cookie,
! # find the clients interface, and store it in a dictionary.
! interface = pUnk.QueryInterface(axdebug.IID_IDebugDocumentTextEvents,1)
! self.cookieNo = self.cookieNo + 1
! self.connections[self.cookieNo] = interface
! return self.cookieNo
! def Unadvise(self, cookie):
! # Destroy a connection - simply delete interface from the map.
! try:
! del self.connections[cookie]
! except KeyError:
! return Exception(scode=winerror.E_UNEXPECTED)
! # IConnectionPointContainer interfaces
! def EnumConnectionPoints(self):
! RaiseNotImpl("EnumConnectionPoints")
! def FindConnectionPoint(self, iid):
! # Find a connection we support. Only support the single event interface.
! if iid==axdebug.IID_IDebugDocumentTextEvents:
! return _wrap(self)
! raise Exception(scode=winerror.E_NOINTERFACE) # ??
class RemoteDebugApplicationEvents:
! _public_methods_ = ["OnConnectDebugger","OnDisconnectDebugger","OnSetName","OnDebugOutput","OnClose","OnEnterBreakPoint","OnLeaveBreakPoint","OnCreateThread","OnDestroyThread","OnBreakFlagChange"]
! _com_interfaces_ = [axdebug.IID_IRemoteDebugApplicationEvents]
! def OnConnectDebugger(self, appDebugger):
! """appDebugger -- a PyIApplicationDebugger
! """
! RaiseNotImpl("OnConnectDebugger")
! def OnDisconnectDebugger(self):
! RaiseNotImpl("OnDisconnectDebugger")
! def OnSetName(self, name):
! RaiseNotImpl("OnSetName")
! def OnDebugOutput(self, string):
! RaiseNotImpl("OnDebugOutput")
! def OnClose(self):
! RaiseNotImpl("OnClose")
! def OnEnterBreakPoint(self, rdat):
! """rdat -- PyIRemoteDebugApplicationThread
! """
! RaiseNotImpl("OnEnterBreakPoint")
! def OnLeaveBreakPoint(self, rdat):
! """rdat -- PyIRemoteDebugApplicationThread
! """
! RaiseNotImpl("OnLeaveBreakPoint")
! def OnCreateThread(self, rdat):
! """rdat -- PyIRemoteDebugApplicationThread
! """
! RaiseNotImpl("OnCreateThread")
! def OnDestroyThread(self, rdat):
! """rdat -- PyIRemoteDebugApplicationThread
! """
! RaiseNotImpl("OnDestroyThread")
! def OnBreakFlagChange(self, abf, rdat):
! """abf -- int - one of the axdebug.APPBREAKFLAGS constants
! rdat -- PyIRemoteDebugApplicationThread
! RaiseNotImpl("OnBreakFlagChange")
! """
class DebugExpressionContext:
! _public_methods_ = ["ParseLanguageText", "GetLanguageInfo"]
! _com_interfaces_ = [axdebug.IID_IDebugExpressionContext]
! def __init__(self):
! pass
! def ParseLanguageText(self, code, radix, delim, flags):
! """
! result is IDebugExpression
! """
! RaiseNotImpl("ParseLanguageText")
! def GetLanguageInfo(self):
! """
! result is (string langName, iid langId)
! """
! RaiseNotImpl("GetLanguageInfo")
class DebugExpression:
! _public_methods_ = ["Start", "Abort", "QueryIsComplete", "GetResultAsString", "GetResultAsDebugProperty"]
! _com_interfaces_ = [axdebug.IID_IDebugExpression]
! def Start(self, callback):
! """
! callback -- an IDebugExpressionCallback
!
! result - void
! """
! RaiseNotImpl("Start")
! def Abort(self):
! """
! no params
! result -- void
! """
! RaiseNotImpl("Abort")
! def QueryIsComplete(self):
! """
! no params
! result -- void
! """
! RaiseNotImpl("QueryIsComplete")
! def GetResultAsString(self):
! RaiseNotImpl("GetResultAsString")
! def GetResultAsDebugProperty(self):
! RaiseNotImpl("GetResultAsDebugProperty")
class ProvideExpressionContexts:
! _public_methods_ = ["EnumExpressionContexts"]
! _com_interfaces_ = [axdebug.IID_IProvideExpressionContexts]
! def EnumExpressionContexts(self):
! RaiseNotImpl("EnumExpressionContexts")
!
--- 11,452 ----
class EnumDebugCodeContexts(ListEnumeratorGateway):
! """A class to expose a Python sequence as an EnumDebugCodeContexts
! Create an instance of this class passing a sequence (list, tuple, or
! any sequence protocol supporting object) and it will automatically
! support the EnumDebugCodeContexts interface for the object.
! """
! _com_interfaces_ = [ axdebug.IID_IEnumDebugCodeContexts ]
class EnumDebugStackFrames(ListEnumeratorGateway):
! """A class to expose a Python sequence as an EnumDebugStackFrames
! Create an instance of this class passing a sequence (list, tuple, or
! any sequence protocol supporting object) and it will automatically
! support the EnumDebugStackFrames interface for the object.
! """
! _com_interfaces_ = [ axdebug.IID_IEnumDebugStackFrames ]
class EnumDebugApplicationNodes(ListEnumeratorGateway):
! """A class to expose a Python sequence as an EnumDebugStackFrames
! Create an instance of this class passing a sequence (list, tuple, or
! any sequence protocol supporting object) and it will automatically
! support the EnumDebugApplicationNodes interface for the object.
! """
! _com_interfaces_ = [ axdebug.IID_IEnumDebugApplicationNodes ]
class EnumRemoteDebugApplications(ListEnumeratorGateway):
! _com_interfaces_ = [ axdebug.IID_IEnumRemoteDebugApplications ]
class EnumRemoteDebugApplicationThreads(ListEnumeratorGateway):
! _com_interfaces_ = [ axdebug.IID_IEnumRemoteDebugApplicationThreads ]
class DebugDocumentInfo:
! _public_methods_ = ["GetName", "GetDocumentClassId"]
! _com_interfaces_ = [axdebug.IID_IDebugDocumentInfo]
! def __init__(self):
! pass
! def GetName(self, dnt):
! """ Get the one of the name of the document
! dnt -- int DOCUMENTNAMETYPE
! """
! RaiseNotImpl("GetName")
! def GetDocumentClassId(self):
! """
! Result must be an IID object (or string representing one).
! """
! RaiseNotImpl("GetDocumentClassId")
!
class DebugDocumentProvider(DebugDocumentInfo):
! _public_methods_ = DebugDocumentInfo._public_methods_ + ["GetDocument"]
! _com_interfaces_ = DebugDocumentInfo._com_interfaces_ + [axdebug.IID_IDebugDocumentProvider]
! def GetDocument(self):
! RaiseNotImpl("GetDocument")
class DebugApplicationNode(DebugDocumentProvider):
! """Provides the functionality of IDebugDocumentProvider, plus a context within a project tree.
! """
! _public_methods_ = string.split("""EnumChildren GetParent SetDocumentProvider
! Close Attach Detach""") + \
! DebugDocumentProvider._public_methods_
! _com_interfaces_ = [axdebug.IID_IDebugDocumentProvider] + \
! DebugDocumentProvider._com_interfaces_
! def __init__(self):
! DebugDocumentProvider.__init__(self)
! def EnumChildren(self):
! # Result is type PyIEnumDebugApplicationNodes
! RaiseNotImpl("EnumChildren")
! def GetParent(self):
! # result is type PyIDebugApplicationNode
! RaiseNotImpl("GetParent")
! def SetDocumentProvider(self, pddp): # PyIDebugDocumentProvider pddp
! # void result.
! RaiseNotImpl("SetDocumentProvider")
! def Close(self):
! # void result.
! RaiseNotImpl("Close")
! def Attach(self, parent): # PyIDebugApplicationNode
! # void result.
! RaiseNotImpl("Attach")
! def Detach(self):
! # void result.
! RaiseNotImpl("Detach")
class DebugApplicationNodeEvents:
! """Event interface for DebugApplicationNode object.
! """
! _public_methods_ = string.split("onAddChild onRemoveChild onDetach")
! _com_interfaces_ = [axdebug.IID_IDebugApplicationNodeEvents]
! def __init__(self):
! pass
! def onAddChild(self, child): # PyIDebugApplicationNode
! # void result.
! RaiseNotImpl("onAddChild")
! def onRemoveChild(self, child): # PyIDebugApplicationNode
! # void result.
! RaiseNotImpl("onRemoveChild")
! def onDetach(self):
! # void result.
! RaiseNotImpl("onDetach")
! def onAttach(self, parent): # PyIDebugApplicationNode
! # void result.
! RaiseNotImpl("onAttach")
class DebugDocument(DebugDocumentInfo):
! """The base interface to all debug documents.
! """
! _public_methods_ = DebugDocumentInfo._public_methods_
! _com_interfaces_ = [axdebug.IID_IDebugDocument] + DebugDocumentInfo._com_interfaces_
class DebugDocumentText(DebugDocument):
! """The interface to a text only debug document.
! """
! _com_interfaces_ = [axdebug.IID_IDebugDocumentText] + \
! DebugDocument._com_interfaces_
! _public_methods_ = ["GetDocumentAttributes", "GetSize",
! "GetPositionOfLine", "GetLineOfPosition", "GetText",
! "GetPositionOfContext", "GetContextOfPosition"] + \
! DebugDocument._public_methods_
! def __init__(self):
! pass
! # IDebugDocumentText
! def GetDocumentAttributes(self):
! # Result is int (TEXT_DOC_ATTR)
! RaiseNotImpl("GetDocumentAttributes")
! def GetSize(self):
! # Result is (numLines, numChars)
! RaiseNotImpl("GetSize")
! def GetPositionOfLine(self, cLineNumber):
! # Result is int char position
! RaiseNotImpl("GetPositionOfLine")
! def GetLineOfPosition(self, charPos):
! # Result is int, int (lineNo, offset)
! RaiseNotImpl("GetLineOfPosition")
! def GetText(self, charPos, maxChars, wantAttr):
! """Params
! charPos -- integer
! maxChars -- integer
! wantAttr -- Should the function compute attributes.
! Return value must be (string, attribtues). attributes may be
! None if(not wantAttr)
! """
! RaiseNotImpl("GetText")
! def GetPositionOfContext(self, debugDocumentContext):
! """Params
! debugDocumentContext -- a PyIDebugDocumentContext object.
!
! Return value must be (charPos, numChars)
! """
! RaiseNotImpl("GetPositionOfContext")
! def GetContextOfPosition(self, charPos, maxChars):
! """Params are integers.
! Return value must be PyIDebugDocumentContext object
! """
! print self
! RaiseNotImpl("GetContextOfPosition")
class DebugDocumentTextExternalAuthor:
! """Allow external editors to edit file-based debugger documents, and to notify the document when the source file has been changed.
! """
! _public_methods_ = ["GetPathName", "GetFileName", "NotifyChanged"]
! _com_interfaces_ = [axdebug.IID_IDebugDocumentTextExternalAuthor]
! def __init__(self):
! pass
! def GetPathName(self):
! """Return the full path (including file name) to the document's source file.
! Result must be (filename, fIsOriginal), where
! - if fIsOriginalPath is TRUE if the path refers to the original file for the document.
! - if fIsOriginalPath is FALSE if the path refers to a newly created temporary file.
! raise Exception(winerror.E_FAIL) if no source file can be created/determined.
! """
! RaiseNotImpl("GetPathName")
!
! def GetFileName(self):
! """Return just the name of the document, with no path information. (Used for "Save As...")
!
! Result is a string
! """
! RaiseNotImpl("GetFileName")
!
! def NotifyChanged(self):
! """ Notify the host that the document's source file has been saved and
! that its contents should be refreshed.
! """
! RaiseNotImpl("NotifyChanged")
class DebugDocumentTextEvents:
! _public_methods_ = string.split("""onDestroy onInsertText onRemoveText
! onReplaceText onUpdateTextAttributes onUpdateDocumentAttributes""")
! _com_interfaces_ = [ axdebug.IID_IDebugDocumentTextEvents ]
! def __init__(self):
! pass
! def onDestroy(self):
! # Result is void.
! RaiseNotImpl("onDestroy")
! def onInsertText(self, cCharacterPosition, cNumToInsert):
! # Result is void.
! RaiseNotImpl("onInsertText")
! def onRemoveText(self, cCharacterPosition, cNumToRemove):
! # Result is void.
! RaiseNotImpl("onRemoveText")
! def onReplaceText(self, cCharacterPosition, cNumToReplace):
! # Result is void.
! RaiseNotImpl("onReplaceText")
! def onUpdateTextAttributes(self, cCharacterPosition, cNumToUpdate):
! # Result is void.
! RaiseNotImpl("onUpdateTextAttributes")
! def onUpdateDocumentAttributes(self,textdocattr): # TEXT_DOC_ATTR
! # Result is void.
! RaiseNotImpl("onUpdateDocumentAttributes")
class DebugDocumentContext:
! _public_methods_ = [ 'GetDocument', 'EnumCodeContexts']
! _com_interfaces_ = [ axdebug.IID_IDebugDocumentContext ]
! def __init__(self):
! pass
! def GetDocument(self):
! """Return value must be a PyIDebugDocument object
! """
! RaiseNotImpl("GetDocument")
! def EnumCodeContexts(self):
! """Return value must be a PyIEnumDebugCodeContexts object
! """
! RaiseNotImpl("EnumCodeContexts")
class DebugCodeContext:
! _public_methods_ = [ 'GetDocumentContext', 'SetBreakPoint']
! _com_interfaces_ = [ axdebug.IID_IDebugCodeContext ]
! def __init__(self):
! pass
! def GetDocumentContext(self):
! """Return value must be a PyIDebugDocumentContext object
! """
! RaiseNotImpl("GetDocumentContext")
! def SetBreakPoint(self, bps):
! """bps -- an integer with flags.
! """
! RaiseNotImpl("SetBreakPoint")
class DebugStackFrame:
! """Abstraction representing a logical stack frame on the stack of a thread."""
! _public_methods_ = [ 'GetCodeContext', 'GetDescriptionString', 'GetLanguageString', 'GetThread', 'GetDebugProperty']
! _com_interfaces_ = [ axdebug.IID_IDebugStackFrame ]
! def __init__(self):
! pass
! def GetCodeContext(self):
! """Returns the current code context associated with the stack frame.
! Return value must be a IDebugCodeContext object
! """
! RaiseNotImpl("GetCodeContext")
! def GetDescriptionString(self, fLong):
! """Returns a textual description of the stack frame.
! fLong -- A flag indicating if the long name is requested.
! """
! RaiseNotImpl("GetDescriptionString")
! def GetLanguageString(self):
! """Returns a short or long textual description of the language.
!
! fLong -- A flag indicating if the long name is requested.
! """
! RaiseNotImpl("GetLanguageString")
! def GetThread(self):
! """ Returns the thread associated with this stack frame.
!
! Result must be a IDebugApplicationThread
! """
! RaiseNotImpl("GetThread")
! def GetDebugProperty(self):
! RaiseNotImpl("GetDebugProperty")
class DebugDocumentHost:
! """The interface from the IDebugDocumentHelper back to
! the smart host or language engine. This interface
! exposes host specific functionality such as syntax coloring.
! """
! _public_methods_ = [ 'GetDeferredText', 'GetScriptTextAttributes', 'OnCreateDocumentContext', 'GetPathName', 'GetFileName', 'NotifyChanged']
! _com_interfaces_ = [ axdebug.IID_IDebugDocumentHost ]
! def __init__(self):
! pass
! def GetDeferredText(self, dwTextStartCookie, maxChars, bWantAttr):
! RaiseNotImpl("GetDeferredText")
!
! def GetScriptTextAttributes(self, codeText, delimterText, flags):
! # Result must be an attribute sequence of same "length" as the code.
! RaiseNotImpl("GetScriptTextAttributes")
!
! def OnCreateDocumentContext(self):
! # Result must be a PyIUnknown
! RaiseNotImpl("OnCreateDocumentContext")
!
! def GetPathName(self):
! # Result must be (string, int) where the int is a BOOL
! # - TRUE if the path refers to the original file for the document.
! # - FALSE if the path refers to a newly created temporary file.
! # - raise Exception(scode=E_FAIL) if no source file can be created/determined.
! RaiseNotImpl("GetPathName")
!
! def GetFileName(self):
! # Result is a string with just the name of the document, no path information.
! RaiseNotImpl("GetFileName")
!
! def NotifyChanged(self):
! RaiseNotImpl("NotifyChanged")
# Additional gateway related functions.
class DebugDocumentTextConnectServer:
! _public_methods_ = win32com.server.connect.IConnectionPointContainer_methods + win32com.server.connect.IConnectionPoint_methods
! _com_interfaces_ = [pythoncom.IID_IConnectionPoint, pythoncom.IID_IConnectionPointContainer]
! # IConnectionPoint interfaces
! def __init__(self):
! self.cookieNo = -1
! self.connections = {}
! def EnumConnections(self):
! RaiseNotImpl("EnumConnections")
! def GetConnectionInterface(self):
! RaiseNotImpl("GetConnectionInterface")
! def GetConnectionPointContainer(self):
! return _wrap(self)
! def Advise(self, pUnk):
! # Creates a connection to the client. Simply allocate a new cookie,
! # find the clients interface, and store it in a dictionary.
! interface = pUnk.QueryInterface(axdebug.IID_IDebugDocumentTextEvents,1)
! self.cookieNo = self.cookieNo + 1
! self.connections[self.cookieNo] = interface
! return self.cookieNo
! def Unadvise(self, cookie):
! # Destroy a connection - simply delete interface from the map.
! try:
! del self.connections[cookie]
! except KeyError:
! return Exception(scode=winerror.E_UNEXPECTED)
! # IConnectionPointContainer interfaces
! def EnumConnectionPoints(self):
! RaiseNotImpl("EnumConnectionPoints")
! def FindConnectionPoint(self, iid):
! # Find a connection we support. Only support the single event interface.
! if iid==axdebug.IID_IDebugDocumentTextEvents:
! return _wrap(self)
! raise Exception(scode=winerror.E_NOINTERFACE) # ??
class RemoteDebugApplicationEvents:
! _public_methods_ = ["OnConnectDebugger","OnDisconnectDebugger","OnSetName","OnDebugOutput","OnClose","OnEnterBreakPoint","OnLeaveBreakPoint","OnCreateThread","OnDestroyThread","OnBreakFlagChange"]
! _com_interfaces_ = [axdebug.IID_IRemoteDebugApplicationEvents]
! def OnConnectDebugger(self, appDebugger):
! """appDebugger -- a PyIApplicationDebugger
! """
! RaiseNotImpl("OnConnectDebugger")
! def OnDisconnectDebugger(self):
! RaiseNotImpl("OnDisconnectDebugger")
! def OnSetName(self, name):
! RaiseNotImpl("OnSetName")
! def OnDebugOutput(self, string):
! RaiseNotImpl("OnDebugOutput")
! def OnClose(self):
! RaiseNotImpl("OnClose")
! def OnEnterBreakPoint(self, rdat):
! """rdat -- PyIRemoteDebugApplicationThread
! """
! RaiseNotImpl("OnEnterBreakPoint")
! def OnLeaveBreakPoint(self, rdat):
! """rdat -- PyIRemoteDebugApplicationThread
! """
! RaiseNotImpl("OnLeaveBreakPoint")
! def OnCreateThread(self, rdat):
! """rdat -- PyIRemoteDebugApplicationThread
! """
! RaiseNotImpl("OnCreateThread")
! def OnDestroyThread(self, rdat):
! """rdat -- PyIRemoteDebugApplicationThread
! """
! RaiseNotImpl("OnDestroyThread")
! def OnBreakFlagChange(self, abf, rdat):
! """abf -- int - one of the axdebug.APPBREAKFLAGS constants
! rdat -- PyIRemoteDebugApplicationThread
! RaiseNotImpl("OnBreakFlagChange")
! """
class DebugExpressionContext:
! _public_methods_ = ["ParseLanguageText", "GetLanguageInfo"]
! _com_interfaces_ = [axdebug.IID_IDebugExpressionContext]
! def __init__(self):
! pass
! def ParseLanguageText(self, code, radix, delim, flags):
! """
! result is IDebugExpression
! """
! RaiseNotImpl("ParseLanguageText")
! def GetLanguageInfo(self):
! """
! result is (string langName, iid langId)
! """
! RaiseNotImpl("GetLanguageInfo")
class DebugExpression:
! _public_methods_ = ["Start", "Abort", "QueryIsComplete", "GetResultAsString", "GetResultAsDebugProperty"]
! _com_interfaces_ = [axdebug.IID_IDebugExpression]
! def Start(self, callback):
! """
! callback -- an IDebugExpressionCallback
! result - void
! """
! RaiseNotImpl("Start")
! def Abort(self):
! """
! no params
! result -- void
! """
! RaiseNotImpl("Abort")
! def QueryIsComplete(self):
! """
! no params
! result -- void
! """
! RaiseNotImpl("QueryIsComplete")
! def GetResultAsString(self):
! RaiseNotImpl("GetResultAsString")
!
! def GetResultAsDebugProperty(self):
! RaiseNotImpl("GetResultAsDebugProperty")
class ProvideExpressionContexts:
! _public_methods_ = ["EnumExpressionContexts"]
! _com_interfaces_ = [axdebug.IID_IProvideExpressionContexts]
! def EnumExpressionContexts(self):
! RaiseNotImpl("EnumExpressionContexts")
Index: dump.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axdebug/dump.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** dump.py 1 Sep 1999 23:09:01 -0000 1.1
--- dump.py 18 Jun 2006 13:18:26 -0000 1.2
***************
*** 6,49 ****
def DumpDebugApplicationNode(node, level = 0):
! # Recursive dump of a DebugApplicationNode
! spacer = " " * level
! for desc, attr in [("Node Name", axdebug.DOCUMENTNAMETYPE_APPNODE),
! ("Title", axdebug.DOCUMENTNAMETYPE_TITLE),
! ("Filename", axdebug.DOCUMENTNAMETYPE_FILE_TAIL),
! ("URL", axdebug.DOCUMENTNAMETYPE_URL),
! ]:
! try:
! info = node.GetName(attr)
! except pythoncom.com_error:
! info = "<N/A>"
! print "%s%s: %s" % (spacer, desc, info)
! try:
! doc = node.GetDocument()
! except pythoncom.com_error:
! doc = None
! if doc:
! doctext = doc.QueryInterface(axdebug.IID_IDebugDocumentText)
! numLines, numChars = doctext.GetSize()
! # text, attr = doctext.GetText(0, 20, 1)
! text, attr = doctext.GetText(0, numChars, 1)
! print "%sText is %s, %d bytes long" % (spacer, repr(text[:40]+"..."), len(text))
! else:
! print "%s%s" % (spacer, "<No document available>")
!
! for child in Enumerator(node.EnumChildren()):
! DumpDebugApplicationNode(child, level+1)
!
def dumpall():
! dm=pythoncom.CoCreateInstance(axdebug.CLSID_MachineDebugManager,None,pythoncom.CLSCTX_ALL, axdebug.IID_IMachineDebugManager)
! e=Enumerator(dm.EnumApplications())
! for app in e:
! print "Application: %s" % app.GetName()
! node = app.GetRootNode() # of type PyIDebugApplicationNode->PyIDebugDocumentProvider->PyIDebugDocumentInfo
! DumpDebugApplicationNode(node)
if __name__=='__main__':
! try:
! dumpall()
! except:
! traceback.print_exc()
!
--- 6,48 ----
def DumpDebugApplicationNode(node, level = 0):
! # Recursive dump of a DebugApplicationNode
! spacer = " " * level
! for desc, attr in [("Node Name", axdebug.DOCUMENTNAMETYPE_APPNODE),
! ("Title", axdebug.DOCUMENTNAMETYPE_TITLE),
! ("Filename", axdebug.DOCUMENTNAMETYPE_FILE_TAIL),
! ("URL", axdebug.DOCUMENTNAMETYPE_URL),
! ]:
! try:
! info = node.GetName(attr)
! except pythoncom.com_error:
! info = "<N/A>"
! print "%s%s: %s" % (spacer, desc, info)
! try:
! doc = node.GetDocument()
! except pythoncom.com_error:
! doc = None
! if doc:
! doctext = doc.QueryInterface(axdebug.IID_IDebugDocumentText)
! numLines, numChars = doctext.GetSize()
! # text, attr = doctext.GetText(0, 20, 1)
! text, attr = doctext.GetText(0, numChars, 1)
! print "%sText is %s, %d bytes long" % (spacer, repr(text[:40]+"..."), len(text))
! else:
! print "%s%s" % (spacer, "<No document available>")
!
! for child in Enumerator(node.EnumChildren()):
! DumpDebugApplicationNode(child, level+1)
!
def dumpall():
! dm=pythoncom.CoCreateInstance(axdebug.CLSID_MachineDebugManager,None,pythoncom.CLSCTX_ALL, axdebug.IID_IMachineDebugManager)
! e=Enumerator(dm.EnumApplications())
! for app in e:
! print "Application: %s" % app.GetName()
! node = app.GetRootNode() # of type PyIDebugApplicationNode->PyIDebugDocumentProvider->PyIDebugDocumentInfo
! DumpDebugApplicationNode(node)
if __name__=='__main__':
! try:
! dumpall()
! except:
! traceback.print_exc()
Index: adb.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axdebug/adb.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** adb.py 11 Apr 2005 13:04:41 -0000 1.4
--- adb.py 18 Jun 2006 13:18:26 -0000 1.5
***************
*** 11,21 ****
def fnull(*args):
! pass
try:
! os.environ["DEBUG_AXDEBUG"]
! debugging = 1
except KeyError:
! debugging = 0
traceenter = fnull # trace enter of functions
--- 11,21 ----
def fnull(*args):
! pass
try:
! os.environ["DEBUG_AXDEBUG"]
! debugging = 1
except KeyError:
! debugging = 0
traceenter = fnull # trace enter of functions
***************
*** 23,416 ****
if debugging:
! traceenter = trace # trace enter of functions
! tracev = trace # verbose trace
class OutputReflector:
! def __init__(self, file, writefunc):
! self.writefunc = writefunc
! self.file = file
! def __getattr__(self,name):
! return getattr(self.file, name)
! def write(self,message):
! self.writefunc(message)
! self.file.write(message)
def _dumpf(frame):
! if frame is None:
! return "<None>"
! else:
! addn = "(with trace!)"
! if frame.f_trace is None:
! addn = " **No Trace Set **"
! return "Frame at %d, file %s, line: %d%s" % (id(frame), frame.f_code.co_filename, frame.f_lineno, addn)
g_adb = None
def OnSetBreakPoint(codeContext, breakPointState, lineNo):
! try:
! fileName = codeContext.codeContainer.GetFileName()
! # inject the code into linecache.
! import linecache
! linecache.cache[fileName] = 0, 0, codeContext.codeContainer.GetText(), fileName
! g_adb._OnSetBreakPoint(fileName, codeContext, breakPointState, lineNo+1)
! except:
! traceback.print_exc()
class Adb(bdb.Bdb,gateways.RemoteDebugApplicationEvents):
! def __init__(self):
! self.debugApplication = None
! self.debuggingThread = None
! self.debuggingThreadStateHandle = None
! self.stackSnifferCookie = self.stackSniffer = None
! self.codeContainerProvider = None
! self.debuggingThread = None
! self.breakFlags = None
! self.breakReason = None
! self.appDebugger = None
! self.appEventConnection = None
! self.logicalbotframe = None # Anything at this level or below does not exist!
! self.currentframe = None # The frame we are currently in.
! self.recursiveData = [] # Data saved for each reentery on this thread.
! bdb.Bdb.__init__(self)
! self._threadprotectlock = thread.allocate_lock()
! self.reset()
! def canonic(self, fname):
! if fname[0]=='<':
! return fname
! return bdb.Bdb.canonic(self, fname)
! def reset(self):
! traceenter("adb.reset")
! bdb.Bdb.reset(self)
!
! def __xxxxx__set_break(self, filename, lineno, cond = None):
! # As per standard one, except no linecache checking!
! if not self.breaks.has_key(filename):
! self.breaks[filename] = []
! list = self.breaks[filename]
! if lineno in list:
! return 'There is already a breakpoint there!'
! list.append(lineno)
! if cond is not None: self.cbreaks[filename, lineno]=cond
!
! def stop_here(self, frame):
! traceenter("stop_here", _dumpf(frame), _dumpf(self.stopframe))
! # As per bdb.stop_here, except for logicalbotframe
! ## if self.stopframe is None:
! ## return 1
! if frame is self.stopframe:
! return 1
!
! tracev("stop_here said 'No'!")
! return 0
!
! def break_here(self, frame):
! traceenter("break_here", self.breakFlags, _dumpf(frame))
! self.breakReason = None
! if self.breakFlags==axdebug.APPBREAKFLAG_DEBUGGER_HALT:
! self.breakReason = axdebug.BREAKREASON_DEBUGGER_HALT
! elif self.breakFlags==axdebug.APPBREAKFLAG_DEBUGGER_BLOCK:
! self.breakReason = axdebug.BREAKREASON_DEBUGGER_BLOCK
! elif self.breakFlags==axdebug.APPBREAKFLAG_STEP:
! self.breakReason = axdebug.BREAKREASON_STEP
! else:
! print "Calling base 'break_here' with", self.breaks
! if bdb.Bdb.break_here(self, frame):
! self.breakReason = axdebug.BREAKREASON_BREAKPOINT
! return self.breakReason is not None
!
! def break_anywhere(self, frame):
! traceenter("break_anywhere", _dumpf(frame))
! if self.breakFlags==axdebug.APPBREAKFLAG_DEBUGGER_HALT:
! self.breakReason = axdebug.BREAKREASON_DEBUGGER_HALT
! return 1
! rc = bdb.Bdb.break_anywhere(self, frame)
! tracev("break_anywhere",_dumpf(frame),"returning",rc)
! return rc
! def dispatch_return(self, frame, arg):
! traceenter("dispatch_return", _dumpf(frame), arg)
! if self.logicalbotframe is frame:
! # We dont want to debug parent frames.
! tracev("dispatch_return resetting sys.trace")
! sys.settrace(None)
! return
! # self.bSetTrace = 0
! self.currentframe = frame.f_back
! return bdb.Bdb.dispatch_return(self, frame, arg)
! def dispatch_line(self, frame):
! traceenter("dispatch_line", _dumpf(frame), _dumpf(self.botframe))
! # trace("logbotframe is", _dumpf(self.logicalbotframe), "botframe is", self.botframe)
! if frame is self.logicalbotframe:
! trace("dispatch_line", _dumpf(frame), "for bottom frame returing tracer")
! # The next code executed in the frame above may be a builtin (eg, apply())
! # in which sys.trace needs to be set.
! sys.settrace(self.trace_dispatch)
! # And return the tracer incase we are about to execute Python code,
! # in which case sys tracer is ignored!
! return self.trace_dispatch
!
! if self.codeContainerProvider.FromFileName(frame.f_code.co_filename) is None:
! trace("dispatch_line has no document for", _dumpf(frame), "- skipping trace!")
! return None
! self.currentframe = frame # So the stack sniffer knows our most recent, debuggable code.
! return bdb.Bdb.dispatch_line(self, frame)
!
! def dispatch_call(self, frame, arg):
! traceenter("dispatch_call",_dumpf(frame))
! frame.f_locals['__axstack_address__'] = axdebug.GetStackAddress()
! if frame is self.botframe:
! trace("dispatch_call is self.botframe - returning tracer")
! return self.trace_dispatch
! # Not our bottom frame. If we have a document for it,
! # then trace it, otherwise run at full speed.
! if self.codeContainerProvider.FromFileName(frame.f_code.co_filename) is None:
! trace("dispatch_call has no document for", _dumpf(frame), "- skipping trace!")
! ## sys.settrace(None)
! return None
! return self.trace_dispatch
!
! # rc = bdb.Bdb.dispatch_call(self, frame, arg)
! # trace("dispatch_call", _dumpf(frame),"returned",rc)
! # return rc
! def trace_dispatch(self, frame, event, arg):
! traceenter("trace_dispatch", _dumpf(frame), event, arg)
! if self.debugApplication is None:
! trace("trace_dispatch has no application!")
! return # None
! return bdb.Bdb.trace_dispatch(self, frame, event, arg)
! #
! # The user functions do bugger all!
! #
! # def user_call(self, frame, argument_list):
! # traceenter("user_call",_dumpf(frame))
! def user_line(self, frame):
! traceenter("user_line",_dumpf(frame))
! # Traces at line zero
! if frame.f_lineno!=0:
! breakReason = self.breakReason
! if breakReason is None:
! breakReason = axdebug.BREAKREASON_STEP
! self._HandleBreakPoint(frame, None, breakReason)
! def user_return(self, frame, return_value):
! # traceenter("user_return",_dumpf(frame),return_value)
! bdb.Bdb.user_return(self, frame, return_value)
!
! def user_exception(self, frame, (exc_type, exc_value, exc_traceback)):
! # traceenter("user_exception")
! bdb.Bdb.user_exception(self, frame, (exc_type, exc_value, exc_traceback))
!
! def _HandleBreakPoint(self, frame, tb, reason):
! traceenter("Calling HandleBreakPoint with reason", reason,"at frame", _dumpf(frame))
! traceenter(" Current frame is", _dumpf(self.currentframe))
! try:
! resumeAction = self.debugApplication.HandleBreakPoint(reason)
! tracev("HandleBreakPoint returned with ", resumeAction)
! except pythoncom.com_error, details:
! # Eeek - the debugger is dead, or something serious is happening.
! # Assume we should continue
! resumeAction = axdebug.BREAKRESUMEACTION_CONTINUE
! trace("HandleBreakPoint FAILED with", details)
!
! self.stack = []
! self.curindex = 0
! if resumeAction == axdebug.BREAKRESUMEACTION_ABORT:
! self.set_quit()
! elif resumeAction == axdebug.BREAKRESUMEACTION_CONTINUE:
! tracev("resume action is continue")
! self.set_continue()
! elif resumeAction == axdebug.BREAKRESUMEACTION_STEP_INTO:
! tracev("resume action is step")
! self.set_step()
! elif resumeAction == axdebug.BREAKRESUMEACTION_STEP_OVER:
! tracev("resume action is next")
! self.set_next(frame)
! elif resumeAction == axdebug.BREAKRESUMEACTION_STEP_OUT:
! tracev("resume action is stop out")
! self.set_return(frame)
! else:
! assert(0, "unknown resume action flags")
! self.breakReason = None
! def set_trace(self):
! self.breakReason = axdebug.BREAKREASON_LANGUAGE_INITIATED
! bdb.Bdb.set_trace(self)
! def CloseApp(self):
! traceenter("ClosingApp")
! self.reset()
! self.logicalbotframe = None
! if self.stackSnifferCookie is not None:
! try:
! self.debugApplication.RemoveStackFrameSniffer(self.stackSnifferCookie)
! except pythoncom.com_error:
! trace("*** Could not RemoveStackFrameSniffer %d" % (self.stackSnifferCookie))
! if self.stackSniffer:
! _wrap_remove(self.stackSniffer)
! self.stackSnifferCookie = self.stackSniffer = None
- if self.appEventConnection is not None:
- self.appEventConnection.Disconnect()
- self.appEventConnection = None
- self.debugApplication = None
- self.appDebugger = None
- if self.codeContainerProvider is not None:
- self.codeContainerProvider.Close()
- self.codeContainerProvider = None
-
- def AttachApp(self, debugApplication, codeContainerProvider):
- # traceenter("AttachApp", debugApplication, codeContainerProvider)
- self.codeContainerProvider = codeContainerProvider
- self.debugApplication = debugApplication
- self.stackSniffer = _wrap(stackframe.DebugStackFrameSniffer(self), axdebug.IID_IDebugStackFrameSniffer)
- self.stackSnifferCookie = debugApplication.AddStackFrameSniffer(self.stackSniffer)
- # trace("StackFrameSniffer added (%d)" % self.stackSnifferCookie)
-
- # Connect to the application events.
- self.appEventConnection = win32com.client.connect.SimpleCo...
[truncated message content] |