1 """
2 Cobra integration for remote debugging
3 """
4
5 import md5
6 import os
7 import socket
8
9 import vtrace
10 import cobra
11
12 callback_daemon = None
13
15 """
16 Return a TracerFactory proxy object from the remote server
17 """
18 return cobra.CobraProxy("cobra://%s:%d/TracerFactory" % (vtrace.remote, vtrace.port))
19
21 """
22 A "factory" object for creating tracers and
23 wrapping them up in a proxy instance to the
24 *local* server. This object is shared out
25 via the pyro server for vtrace clients.
26 """
28 trace = vtrace.getTrace()
29 host,port = cobra.getLocalInfo()
30 unique = md5.md5(os.urandom(20)).hexdigest()
31 vtrace.cobra_daemon.shareObject(trace, unique)
32 trace.proxy = cobra.CobraProxy("cobra://%s:%d/%s" % (host,port,unique))
33 return unique
34
36 """
37 When a remote system is done with a trace
38 and wants the server to clean him up, hand
39 the proxy object to this.
40 """
41 t = vtrace.cobra_daemon.unshareObject(proxy.__dict__.get("__cobra_name", None))
42 if t != None:
43 t.release()
44
46
48 cobra.CobraProxy.__init__(self, *args, **kwargs)
49 self.__dict__['_remote_released'] = False
50
53
56
60
62 if not self.__dict__['_remote_released']:
63 print 'RemoteTrace del w/o release()!'
64
66 """
67 Get a proxy object to reference *notifier* from the
68 perspective of *trace*. The trace is specified so
69 we may check on our side of the connected socket to
70 give him the best possible ip address...
71 """
72 global callback_daemon
73 port = getCallbackPort()
74 host, nothing = trace._cobra_getsock().getSockName()
75 unique = callback_daemon.getSharedName(notifier)
76 if unique == None:
77 unique = md5.md5(os.urandom(20)).hexdigest()
78 callback_daemon.shareObject(notifier, unique)
79 return cobra.CobraProxy("cobra://%s:%d/%s" % (host, port, unique))
80
91
96
101
104
114