• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
<lambda>null2  * Copyright 2018 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package trebuchet.importers.ftrace.events
18 
19 import trebuchet.importers.ftrace.FtraceImporterState
20 
21 class WorkqueueExecuteStartEvent(val struct: String, val function: String) : FtraceEventDetails {
22     override fun import(event: FtraceEvent, state: FtraceImporterState) {
23         state.threadFor(event).slicesBuilder.beginSlice {
24             it.name = function
25             it.startTime = event.timestamp
26         }
27     }
28 }
29 
30 class WorkqueueExecuteEndEvent(val struct: String) : FtraceEventDetails {
importnull31     override fun import(event: FtraceEvent, state: FtraceImporterState) {
32         state.threadFor(event).slicesBuilder.endSlice {
33             it.endTime = event.timestamp
34         }
35     }
36 }
37 
38 object WorkqueueEvent {
39     private const val workqueueExecuteStartRE = """work struct (\w+): function (\S+)"""
40     private const val workqueueExecuteEndRE = """work struct (\w+)"""
41 
sharedStatenull42     val register: EventRegistryEntry = { sharedState ->
43         sharedState.onParseDetailsWithMatch("workqueue_execute_start", workqueueExecuteStartRE) {
44             WorkqueueExecuteStartEvent(string(1), string(2))
45         }
46         sharedState.onParseDetailsWithMatch("workqueue_execute_end", workqueueExecuteEndRE) {
47             WorkqueueExecuteEndEvent(string(1))
48         }
49     }
50 }