示例#1
0
def stubtest():
	global look, stackref, tstate, t
	t = stackless.taskoutlet(lambda:None)()
	look = get_stack(t)
	stackref = t.frame.cstack.startaddr
	tstate = stackless._peek(t.frame)
	view_main()
示例#2
0
 def get_loadadr(self):
     # after the initial analysis, we have the
     # offset of stackless._peek (hopefully),
     # and we get its absolute address by calling it with None.
     peek_ofs = self.functions["__peek/stacklessmodule"].ofs
     peek_adr = stackless._peek(None)
     self.peek_ofs = peek_ofs
     self.loadadr = peek_adr - peek_ofs
示例#3
0
 def get_loadadr(self):
     # after the initial analysis, we have the
     # offset of stackless._peek (hopefully),
     # and we get its absolute address by calling it with None.
     peek_ofs = self.functions["__peek/stacklessmodule"].ofs
     peek_adr = stackless._peek(None)
     self.peek_ofs = peek_ofs
     self.loadadr = peek_adr - peek_ofs
示例#4
0
def test(func):
	global look, stackref, tstate, t
	c = simpletest(func, 1)
	t = c.queue
	look = get_stack(t)
	stackref = t.frame.cstack.startaddr
	tstate = stackless._peek(t.frame)
	view_main()
	c.send(0)
示例#5
0
def view_main():
	g = id(globals())
	baseadr = stackless._peek(None) - ccall_map.peek_ofs
	tstate = stackless._peek(sys._getframe())
	stackend = stackref-4*len(look)
	context = ''
	callee = ''
	codetype = type(sys._getframe().f_code)
	for i in range(len(look)-1,-1,-1):
		data = look[i]
		call = ccall_map.CallMap.get(data-baseadr)
		if call:
			(funcname, modname, srcname, lineno, lng, callee) = call
			if lng:
				# a function call
				s = "*%s line %d call %s +%d   file %s" % (funcname, lineno, callee, lng, srcname)
				s += "\n"+ 60*"-"
			else:
				s = "%s line %d entry   file %s" % (funcname, lineno, srcname)
		elif data == g:
			s = "--globals--"
		elif data == tstate:
			s = "--tstate--"
		elif data < stackref and data >= stackend:
			#print "stackref %d data %d" % (stackref, data)
			sp = (data-stackend)/4
			s = "-->STACK[%d]" % sp
		else:
			x = stackless._peek(data)
			if x is data:
				if x > 256:
					s = "0x%08x" % x
				else:
					s = repr(x)
			else:
				s = repr(x)[:299]
				if s[0] <> "<":
					# add type info
					tname = str(type(x)).split("'")[1]
					s = "%s %s" % (tname, repr(x)[:200])
		print "%-18s [%3d] %s" % (context, i, s)
		if callee:
			context = callee
示例#6
0
def maintest():
	ch.receive()
	global look, stackref, tstate
	t = stackless.getmain()
	look = get_stack(t)
	stackref = t.frame.cstack.startaddr
	try:
		tstate = stackless._peek(t.frame)
	except AttributeError:
		tstate = None