Make required events a set

This commit is contained in:
Christophe Bedard 2019-12-31 13:19:31 -05:00
parent 938cc263d5
commit e374419665
4 changed files with 18 additions and 17 deletions

View file

@ -138,14 +138,14 @@ class EventHandler(Dependant):
return None return None
@staticmethod @staticmethod
def required_events() -> List[str]: def required_events() -> Set[str]:
""" """
Get the list of events required by this EventHandler. Get the set of events required by this EventHandler.
Without these events, the EventHandler would be invalid/useless. Inheriting classes can Without these events, the EventHandler would be invalid/useless. Inheriting classes can
decide not to declare that they require specific events. decide not to declare that they require specific events.
""" """
return [] return {}
def register_processor(self, processor: 'Processor') -> None: def register_processor(self, processor: 'Processor') -> None:
"""Register processor with this `EventHandler` so that it can query other handlers.""" """Register processor with this `EventHandler` so that it can query other handlers."""

View file

@ -15,7 +15,7 @@
"""Module for CPU time events processing.""" """Module for CPU time events processing."""
from typing import Dict from typing import Dict
from typing import List from typing import Set
from tracetools_read import get_field from tracetools_read import get_field
@ -53,10 +53,10 @@ class CpuTimeHandler(EventHandler):
self._cpu_start: Dict[int, int] = {} self._cpu_start: Dict[int, int] = {}
@staticmethod @staticmethod
def required_events() -> List[str]: def required_events() -> Set[str]:
return [ return {
'sched_switch', 'sched_switch',
] }
@property @property
def data(self) -> CpuTimeDataModel: def data(self) -> CpuTimeDataModel:

View file

@ -15,7 +15,7 @@
"""Module for memory usage events processing.""" """Module for memory usage events processing."""
from typing import Dict from typing import Dict
from typing import List from typing import Set
from tracetools_read import get_field from tracetools_read import get_field
@ -98,11 +98,11 @@ class UserspaceMemoryUsageHandler(MemoryUsageHandler):
self._memory: Dict[int, int] = {} self._memory: Dict[int, int] = {}
@staticmethod @staticmethod
def required_events() -> List[str]: def required_events() -> Set[str]:
return [ return {
'lttng_ust_libc:malloc', 'lttng_ust_libc:malloc',
'lttng_ust_libc:free', 'lttng_ust_libc:free',
] }
def _handle_malloc( def _handle_malloc(
self, event: Dict, metadata: EventMetadata self, event: Dict, metadata: EventMetadata
@ -209,11 +209,11 @@ class KernelMemoryUsageHandler(MemoryUsageHandler):
) )
@staticmethod @staticmethod
def required_events() -> List[str]: def required_events() -> Set[str]:
return [ return {
'kmem_mm_page_alloc', 'kmem_mm_page_alloc',
'kmem_mm_page_free', 'kmem_mm_page_free',
] }
def _handle_malloc( def _handle_malloc(
self, event: Dict, metadata: EventMetadata self, event: Dict, metadata: EventMetadata

View file

@ -17,6 +17,7 @@
from collections import defaultdict from collections import defaultdict
from typing import Dict from typing import Dict
from typing import List from typing import List
from typing import Set
from typing import Union from typing import Union
from tracetools_read import get_field from tracetools_read import get_field
@ -87,12 +88,12 @@ class ProfileHandler(EventHandler):
self._current_funcs: Dict[int, List[List[Union[str, int]]]] = defaultdict(list) self._current_funcs: Dict[int, List[List[Union[str, int]]]] = defaultdict(list)
@staticmethod @staticmethod
def required_events() -> List[str]: def required_events() -> Set[str]:
return [ return {
'lttng_ust_cyg_profile_fast:func_entry', 'lttng_ust_cyg_profile_fast:func_entry',
'lttng_ust_cyg_profile_fast:func_exit', 'lttng_ust_cyg_profile_fast:func_exit',
'sched_switch', 'sched_switch',
] }
@staticmethod @staticmethod
def addr_to_int(addr: Union[int, str]) -> int: def addr_to_int(addr: Union[int, str]) -> int: