Exemplo n.º 1
0
    def __call__(self, *args, **kwargs):

        g_callers = callgraph.get_callers()
        g_frames = callgraph.get_frames()

        # find the caller frame, and add self as a child node
        caller_frame_id = None

        fullstack = inspect.stack()

        if (self._verbose):
            logging.debug("full stack: %s" % str(fullstack))

        if len(fullstack) > 2:
            caller_frame_id = id(fullstack[2][0])
            if (self._verbose):
                logging.debug("caller frame: %s %s" %
                              (caller_frame_id, fullstack[2]))

        this_frame_id = id(fullstack[0][0])
        if (self._verbose):
            logging.info("this frame: %s %s" % (this_frame_id, fullstack[0]))

        if this_frame_id not in g_frames:
            g_frames.append(fullstack[0][0])

        if this_frame_id not in g_callers.keys():
            g_callers[this_frame_id] = node_data(args, kwargs,
                                                 self.wrapped.__name__, None,
                                                 [])

        edgeinfo = None
        if caller_frame_id:
            edgeinfo = [this_frame_id, callgraph.get_counter()]
            g_callers[caller_frame_id].child_methods.append(edgeinfo)
            callgraph.increment()

        # invoke wraped
        ret = self.wrapped(*args, **kwargs)

        if (self._verbose):
            logging.debug('unwinding frame id: %s' % this_frame_id)

        if edgeinfo:
            edgeinfo.append(callgraph.get_unwindcounter())
            callgraph.increment_unwind()

        g_callers[this_frame_id].ret = copy.deepcopy(ret)

        return ret
Exemplo n.º 2
0
	def __call__(self, *args, **kwargs):

		g_callers = callgraph.get_callers()
		g_frames  = callgraph.get_frames()

		# find the caller frame, and add self as a child node
		caller_frame_id = None

		fullstack = inspect.stack()

		if (self._verbose):
			logging.debug("full stack: %s" % str(fullstack))

		if len (fullstack) > 2:
			caller_frame_id = id(fullstack[2][0])
			if ( self._verbose ):
				logging.debug("caller frame: %s %s" % (caller_frame_id, fullstack[2]))

		this_frame_id = id(fullstack[0][0])
		if (self._verbose):
			logging.info("this frame: %s %s" % (this_frame_id, fullstack[0]))

		if this_frame_id not in g_frames:
			g_frames.append( fullstack[0][0] )

		if  this_frame_id not in g_callers.keys():
			g_callers[this_frame_id] = node_data(args, kwargs, self.wrapped.__name__, None, [])

		edgeinfo = None
		if caller_frame_id:
			edgeinfo = [this_frame_id, callgraph.get_counter()]
			g_callers[caller_frame_id].child_methods.append( edgeinfo )
			callgraph.increment()

		# invoke wraped
		ret = self.wrapped(*args, **kwargs)

		if (self._verbose):
			logging.debug('unwinding frame id: %s' % this_frame_id)

		if edgeinfo:
			edgeinfo.append( callgraph.get_unwindcounter() )
			callgraph.increment_unwind()

		g_callers[this_frame_id].ret = copy.deepcopy(ret)

		return ret
Exemplo n.º 3
0
 def track(self, **kwargs):
     call_frame_id = id(inspect.stack()[2][0])
     g_callers = callgraph.get_callers()
     node = g_callers.get(call_frame_id)
     if node:
         node.auxdata.update(copy.deepcopy(kwargs))
Exemplo n.º 4
0
	def track(self, **kwargs):
		call_frame_id = id(inspect.stack()[2][0])
		g_callers = callgraph.get_callers()
		node = g_callers.get(call_frame_id)
		if node:
			node.auxdata.update( copy.deepcopy(kwargs) )