f334103ff72cbd7b41d9bf8be3f973cbacaffc44
[deliverable/tracecompass.git] / org.eclipse.linuxtools.btf.core / src / org / eclipse / linuxtools / btf / core / event / BTFPayload.java
1 /*******************************************************************************
2 * Copyright (c) 2014 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 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.btf.core.event;
14
15 import java.util.Map;
16
17 import org.eclipse.linuxtools.btf.core.Messages;
18 import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
19
20 import com.google.common.collect.ImmutableMap;
21 import com.google.common.collect.ImmutableMap.Builder;
22
23 /**
24 * BTF event information (Table 7 and 8 from the spec)
25 *
26 * @author Matthew Khouzam
27 */
28 public class BTFPayload {
29
30 private static final Map<String, String> EVENT_DESCRIPTIONS;
31 private static final String EMPTY = "TBA"; //$NON-NLS-1$
32 private static final Map<String, TmfEventField[]> FIELDS;
33 private static final TmfEventField[] TBA_FIELD = new TmfEventField[] { new TmfEventField(EMPTY, EMPTY, new TmfEventField[] { new TmfEventField(EMPTY, EMPTY, null) }) };
34
35 static {
36 ImmutableMap.Builder<String, String> builder = new Builder<>();
37 builder.put("activate", Messages.BTFPayload_Activate); //$NON-NLS-1$
38 builder.put("start", Messages.BTFPayload_Start); //$NON-NLS-1$
39 builder.put("preempt", Messages.BTFPayload_Preempt); //$NON-NLS-1$
40 builder.put("resume", Messages.BTFPayload_Resume); //$NON-NLS-1$
41 builder.put("terminate", Messages.BTFPayload_Terminate); //$NON-NLS-1$
42 builder.put("poll", Messages.BTFPayload_Poll); //$NON-NLS-1$
43 builder.put("run", Messages.BTFPayload_Run); //$NON-NLS-1$
44 builder.put("park", Messages.BTFPayload_Park); //$NON-NLS-1$
45 builder.put("poll_parking", Messages.BTFPayload_PollParking); //$NON-NLS-1$
46 builder.put("release_parking", Messages.BTFPayload_ReleaseParking); //$NON-NLS-1$
47 builder.put("wait", Messages.BTFPayload_Wait); //$NON-NLS-1$
48 builder.put("release", Messages.BTFPayload_Release); //$NON-NLS-1$
49 builder.put("deadline", EMPTY); //$NON-NLS-1$
50 builder.put("mpalimitexceeded", Messages.BTFPayload_MapLimitExceeded); //$NON-NLS-1$
51 builder.put("boundedmigration", Messages.BTFPayload_BoundedMigration); //$NON-NLS-1$
52 builder.put("phasemigration", Messages.BTFPayload_PhaseMigration); //$NON-NLS-1$
53 builder.put("fullmigration", Messages.BTFPayload_FullMigration); //$NON-NLS-1$
54 builder.put("enforcedmigration", Messages.BTFPayload_EnforcedMigration); //$NON-NLS-1$
55 // not yet defined
56 builder.put("execute_idle", EMPTY); //$NON-NLS-1$
57 builder.put("processterminate", EMPTY); //$NON-NLS-1$
58 builder.put("idle", EMPTY); //$NON-NLS-1$
59 builder.put("schedule", EMPTY); //$NON-NLS-1$
60 builder.put("trigger", EMPTY); //$NON-NLS-1$
61 builder.put("schedulepoint", EMPTY); //$NON-NLS-1$
62 builder.put("requestsemaphore", EMPTY); //$NON-NLS-1$
63 builder.put("queued", EMPTY); //$NON-NLS-1$
64 builder.put("lock", EMPTY); //$NON-NLS-1$
65 builder.put("assigned", EMPTY); //$NON-NLS-1$
66 builder.put("unlock", EMPTY); //$NON-NLS-1$
67 builder.put("released", EMPTY); //$NON-NLS-1$
68 builder.put("ready", EMPTY); //$NON-NLS-1$
69 builder.put("free", EMPTY); //$NON-NLS-1$
70 builder.put("set_frequence", EMPTY); //$NON-NLS-1$
71 builder.put("processactivate", EMPTY); //$NON-NLS-1$
72 builder.put("execute", EMPTY); //$NON-NLS-1$
73 builder.put("idle_execution", EMPTY); //$NON-NLS-1$
74 builder.put("suspend", EMPTY); //$NON-NLS-1$
75 builder.put("read", EMPTY); //$NON-NLS-1$
76 builder.put("write", EMPTY); //$NON-NLS-1$
77 builder.put("processpolling", EMPTY); //$NON-NLS-1$
78 builder.put("execute_waiting", EMPTY); //$NON-NLS-1$
79 builder.put("wait_postexecution", EMPTY); //$NON-NLS-1$
80 builder.put("waiting", EMPTY); //$NON-NLS-1$
81 builder.put("overfull", EMPTY); //$NON-NLS-1$
82 builder.put("full", EMPTY); //$NON-NLS-1$
83
84 EVENT_DESCRIPTIONS = builder.build();
85 ImmutableMap.Builder<String, TmfEventField[]> fieldBuilder = new Builder<>();
86 for (String key : EVENT_DESCRIPTIONS.keySet()) {
87 fieldBuilder.put(key, new TmfEventField[] { new TmfEventField("description", EVENT_DESCRIPTIONS.get(key), null) }); //$NON-NLS-1$
88 }
89 FIELDS = fieldBuilder.build();
90 }
91
92 /**
93 * gets the description of a field
94 *
95 * @param key
96 * the field name
97 * @return the description
98 */
99 public static TmfEventField[] getFieldDescription(String key) {
100 String shortKey = key.split(",", 2)[0]; //$NON-NLS-1$
101 TmfEventField[] retVal = FIELDS.get(shortKey);
102 return (retVal == null) ? TBA_FIELD : retVal;
103 }
104
105 }
This page took 0.042483 seconds and 4 git commands to generate.