Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / utils / logWalker / HostProcess.h
blob4ea6a493c0b0e73afdde827984fac2ebca5c6835
1 // -*- C++ -*-
3 //
5 #ifndef LOG_WALKER_HOST_PROCESS_H
6 #define LOG_WALKER_HOST_PROCESS_H
7 #include "ace/SString.h"
8 #include "ace/Synch.h"
9 #include "ace/Containers.h"
10 #include "ace/Hash_Map_Manager.h"
11 #include "ace/RB_Tree.h"
12 #include "ace/Functor.h"
13 #include "Invocation.h"
14 #include "PeerProcess.h"
16 class Session;
17 class Thread;
21 * Peer node is an element of the connection list which associates peer
22 * processes to the host process by handle. The peer node does not own
23 * the reference to the peer process, and the specific peer process may
24 * change over time.
26 struct PeerNode
28 PeerNode (long h, PeerProcess *p);
29 long handle_;
30 PeerProcess *peer_;
33 typedef ACE_DLList<Thread> ThreadList;
34 typedef ACE_DLList<PeerNode> PeerArray;
35 typedef ACE_DLList<Endpoint> AddrList;
36 typedef ACE_RB_Tree<Endpoint, PeerProcess *, ACE_Less_Than<Endpoint>, ACE_Null_Mutex> PeerProcs;
39 * HostProcess encapsulates the state related a specific process instance
40 * described by a log file. There may be more than one HostProcess in a
41 * log file.
44 class HostProcess
46 public:
47 HostProcess (const ACE_CString &src, long pid);
48 ~HostProcess (void);
50 // set/get the name of the process. This is only provided by
51 // an alias supplied to the logWalker command line or manifest file.
52 void proc_name (const ACE_CString &name);
53 const ACE_CString &proc_name (void) const;
55 // Returns a thread instance based on thread id. Will create an instance
56 // as needed.
57 Thread * find_thread (long tid, size_t offset);
59 // Returns a thread that has a pending peer with the supplied address
60 Thread * find_thread_for_peer (const ACE_CString& addr);
62 // Returns a thread that had previously worked with handle h. May return
63 // a null pointer.
64 Thread * find_thread_for_handle (long h);
66 // Returns the process id.
67 long pid (void) const;
69 const ACE_Time_Value &start_time (void) const;
70 void start_time (const ACE_Time_Value &);
72 // Return true if the supplied endpoint has been visited before. This
73 // may be either a listen endpoint or a client endpoint used to connect
74 // to another peer.
75 bool has_endpoint (const Endpoint& addr, bool listen);
77 // adds a new endpoint to the list of listen endpoints. Client endpoints
78 // are added as part of the process to add a new peer process
79 void add_client_endpoint (const Endpoint& addr);
81 // adds a new endpoint to the list of listen endpoints. Client endpoints
82 // are added as part of the process to add a new peer process
83 void add_listen_endpoint (const Endpoint& addr);
85 // add a peer to the connection list. If the peer is not in the
86 // by_addr_ table, it will be added there too.
87 void add_peer (long handle, PeerProcess *peer);
89 // locate a peer process by handle or address
90 PeerProcess *find_peer (const ACE_CString& addr);
91 PeerProcess *find_peer (long handle);
93 void remove_peer (long handle);
95 // remove a peer by handle, noting the line.
96 void close_peer (long handle, size_t offset);
98 // various output methods
99 void dump_ident (ostream &strm, const char *extra);
100 void dump_summary (ostream &strm);
101 void dump_thread_summary (ostream &strm);
102 void split_thread_invocations (Session *session, const ACE_Time_Value& start);
103 void dump_thread_invocations (ostream &strm, const ACE_Time_Value& start);
104 void dump_peer_summary (ostream &strm);
105 void dump_object_detail (ostream &strm);
106 void split_peer_invocations (Session *session);
107 void dump_invocation_detail (ostream &strm);
109 // reconcile_peers gives an opportunity to resolve peer process names
110 // by matching the peer processes to other host processes in the session.
111 void reconcile_peers (Session *session);
113 private:
114 void iterate_peers (int group,
115 int operation,
116 ostream *strm = 0,
117 Session * session = 0);
119 long pid_;
120 ACE_CString logfile_name_;
121 ACE_CString proc_name_;
122 AddrList client_endpoints_;
123 AddrList listen_endpoints_;
124 ThreadList threads_;
126 PeerProcs by_addr_;
127 PeerArray by_handle_;
128 ACE_Time_Value start_time_;
131 #endif // LOG_WALKER_HOST_PROCESS_H