Commit | Line | Data |
---|---|---|
5d10d135 ASL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009, 2010 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | package org.eclipse.linuxtools.lttng.state.evProcessor.state; | |
13 | ||
14 | import java.util.HashMap; | |
15 | import java.util.Map; | |
16 | ||
17 | import org.eclipse.linuxtools.lttng.state.StateStrings; | |
18 | import org.eclipse.linuxtools.lttng.state.evProcessor.AbsEventToHandlerResolver; | |
19 | import org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor; | |
20 | ||
21 | /** | |
22 | * Builds a Map from string event name to a processing handler object, the | |
23 | * processors implement the same interface to facilitate transparent methods | |
24 | * call, | |
25 | * | |
26 | * The map key STring is the entry point of the raw events, using a hash speeds | |
27 | * up the resolution of the appropriate processor | |
28 | * | |
29 | * @author alvaro | |
30 | * | |
31 | */ | |
32 | public class StateEventToHandlerFactory extends AbsEventToHandlerResolver { | |
33 | // ======================================================================== | |
34 | // Data | |
35 | // ======================================================================= | |
36 | private final Map<String, ILttngEventProcessor> eventNametoStateProcessor = new HashMap<String, ILttngEventProcessor>(); | |
37 | private final static StateEventToHandlerFactory instance = new StateEventToHandlerFactory(); | |
38 | private StateUpdateHandlers instantiateHandler = new StateUpdateHandlers(); | |
39 | ||
40 | // ======================================================================== | |
41 | // Constructors | |
42 | // ======================================================================= | |
43 | protected StateEventToHandlerFactory() { | |
44 | //create one instance of each individual event handler and add the instance to the map | |
45 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_SYSCALL_ENTRY | |
46 | .getInName(), instantiateHandler.getSyscallEntryHandler()); | |
47 | ||
48 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_SYSCALL_EXIT | |
49 | .getInName(), instantiateHandler.getsySyscallExitHandler()); | |
50 | ||
51 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_ENTRY | |
52 | .getInName(), instantiateHandler.getTrapEntryHandler()); | |
53 | ||
54 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_EXIT | |
55 | .getInName(), instantiateHandler.getTrapExitHandler()); | |
56 | ||
57 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_ENTRY | |
58 | .getInName(), instantiateHandler.getTrapEntryHandler()); | |
59 | ||
60 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_EXIT | |
61 | .getInName(), instantiateHandler.getTrapExitHandler()); | |
62 | ||
63 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_ENTRY | |
64 | .getInName(), instantiateHandler.getTrapEntryHandler()); | |
65 | ||
66 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_EXIT | |
67 | .getInName(), instantiateHandler.getTrapExitHandler()); | |
68 | ||
69 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_ENTRY | |
70 | .getInName(), instantiateHandler.getIrqEntryHandler()); | |
71 | ||
72 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_EXIT | |
73 | .getInName(), instantiateHandler.getIrqExitHandler()); | |
74 | ||
75 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_RAISE | |
76 | .getInName(), instantiateHandler.getSoftIrqRaiseHandler()); | |
77 | ||
78 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_ENTRY | |
79 | .getInName(), instantiateHandler.getSoftIrqEntryHandler()); | |
80 | ||
81 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_EXIT | |
82 | .getInName(), instantiateHandler.getSoftIrqExitHandler()); | |
83 | ||
84 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_LIST_INTERRUPT | |
85 | .getInName(), instantiateHandler.getEnumInterruptHandler()); | |
86 | ||
87 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_REQUEST_ISSUE | |
88 | .getInName(), instantiateHandler.getBdevRequestIssueHandler()); | |
89 | ||
90 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_REQUEST_COMPLETE | |
91 | .getInName(), instantiateHandler.getBdevRequestCompleteHandler()); | |
92 | ||
93 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_FUNCTION_ENTRY | |
94 | .getInName(), instantiateHandler.getFunctionEntryHandler()); | |
95 | ||
96 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_FUNCTION_EXIT | |
97 | .getInName(), instantiateHandler.getFunctionExitHandler()); | |
98 | ||
99 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_SYS_CALL_TABLE | |
100 | .getInName(), instantiateHandler.getDumpSyscallHandler()); | |
101 | ||
102 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_KPROBE_TABLE | |
103 | .getInName(), instantiateHandler.getDumpKprobeHandler()); | |
104 | ||
105 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_SOFTIRQ_VEC | |
106 | .getInName(), instantiateHandler.getDumpSoftIrqHandler()); | |
107 | ||
108 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE | |
109 | .getInName(), instantiateHandler.getSchedChangeHandler()); | |
110 | ||
111 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_FORK | |
112 | .getInName(), instantiateHandler.getProcessForkHandler()); | |
113 | ||
114 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_KTHREAD_CREATE | |
115 | .getInName(), instantiateHandler.getProcessKernelThreadHandler()); | |
116 | ||
117 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_EXIT | |
118 | .getInName(), instantiateHandler.getProcessExitHandler()); | |
119 | ||
120 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_FREE | |
121 | .getInName(), instantiateHandler.getProcessFreeHandler()); | |
122 | ||
123 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_EXEC | |
124 | .getInName(), instantiateHandler.getProcessExecHandler()); | |
125 | ||
126 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_THREAD_BRAND | |
127 | .getInName(), instantiateHandler.GetThreadBrandHandler()); | |
128 | ||
129 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_STATEDUMP_END | |
130 | .getInName(), instantiateHandler.getStateDumpEndHandler()); | |
131 | ||
132 | eventNametoStateProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_STATE | |
133 | .getInName(), instantiateHandler.getEnumProcessStateHandler()); | |
134 | ||
135 | ||
136 | } | |
137 | ||
138 | // ======================================================================== | |
139 | // Public methods | |
140 | // ======================================================================= | |
141 | /** | |
142 | * The event processors are common to all traces an multiple instances will | |
143 | * use more memory unnecessarily | |
144 | * | |
145 | * @return | |
146 | */ | |
147 | public static AbsEventToHandlerResolver getInstance() { | |
148 | return instance; | |
149 | } | |
150 | ||
151 | ||
152 | /* (non-Javadoc) | |
153 | * @see org.eclipse.linuxtools.lttng.state.evProcessor.AbsEventProcessorFactory#getAfterProcessor(java.lang.String) | |
154 | */ | |
155 | @Override | |
156 | public ILttngEventProcessor getAfterProcessor(String eventType) { | |
157 | return null; | |
158 | } | |
159 | ||
160 | /* (non-Javadoc) | |
161 | * @see org.eclipse.linuxtools.lttng.state.evProcessor.AbsEventProcessorFactory#getBeforeProcessor(java.lang.String) | |
162 | */ | |
163 | @Override | |
164 | public ILttngEventProcessor getBeforeProcessor(String eventType) { | |
165 | return null; | |
166 | } | |
167 | ||
168 | /** | |
169 | * This is the only event handler to update the State provider | |
170 | * @return | |
171 | * | |
172 | */ | |
173 | @Override | |
174 | public ILttngEventProcessor getStateUpdaterProcessor(String eventType) { | |
175 | return eventNametoStateProcessor.get(eventType); | |
176 | } | |
177 | ||
178 | @Override | |
179 | public ILttngEventProcessor getfinishProcessor() { | |
180 | // No finishing processor used | |
181 | return null; | |
182 | } | |
183 | ||
184 | } |