Main class of the btf lib. It contains all necessary functions to import and export a BTF file. More...
#include <btf.h>
Public Types | |
enum class | TimeScales { pico_seconds , nano_seconds , micro_seconds , milli_seconds } |
Enum class which contains the possible time scales (pico-, nano-, micro- or milliseconds). More... | |
Public Member Functions | |
BtfFile (std::string path, TimeScales time_scale=TimeScales::nano_seconds, bool auto_suspend_parent_runnable=true, bool source_is_core=true, bool auto_generate_core_events=false, bool auto_wait_resume_os_events=false) | |
Constructs a BTF file in memory. More... | |
void | finish () |
Writes all BtfEntry instances to file. More... | |
void | importFromFile (const std::string &path, char delimiter=',') |
Appends the data from a BTF file. Currently only import into an empty BTF file is supported. More... | |
void | setStringHashMap (std::unordered_map< size_t, std::string > hash_map) |
Sets the ID to name translation map. This should only be used for traces that use ID based APIs (e.g. for naming of events). Be careful when using this with string based APIs. More... | |
ErrorCodes | coreEvent (uint64_t time, const std::string &core, Core::Events core_event) |
Emits a core event. See overloaded function for more information. More... | |
ErrorCodes | coreEvent (uint64_t time, size_t core_hash, Core::Events core_event) |
Emits a core event (source is a task). More... | |
ErrorCodes | osEvent (uint64_t time, const std::string &process, const std::string &os, OS::Events os_event) |
Emits an OS event (source is a core or a process depending on the value of the core_is_source parameter). See overloaded function for more information. More... | |
ErrorCodes | osEvent (uint64_t time, size_t core_hash, size_t os_hash, OS::Events os_event) |
Emits an OS event (source is a core or a process depending on the value of the core_is_source parameter). More... | |
ErrorCodes | taskMigrationEvent (uint64_t time, const std::string &source_core, const std::string &destination_core, const std::string &task, uint64_t task_instance_id) |
Emits a task migration event. See overloaded function for more information. More... | |
ErrorCodes | taskMigrationEvent (uint64_t time, size_t source_core_hash, size_t destination_core_hash, size_t task_hash, uint64_t task_instance_id) |
Emits a task migration event. More... | |
ErrorCodes | processEvent (uint64_t time, const std::string &source, const std::string &process, uint64_t process_instance_id, Process::Events process_event, bool is_isr=false) |
Emits a task event (except migration). See overloaded function for more information. More... | |
ErrorCodes | processEvent (uint64_t time, size_t source_hash, size_t process_hash, uint64_t process_instance_id, Process::Events process_event, bool is_isr=false) |
Emits a process event (except task migration). More... | |
ErrorCodes | runnableEvent (uint64_t time, const std::string &source, const std::string &runnable, Runnable::Events runnable_event) |
Emits a runnable event (source is a core or process depending on the value of the core_is_source parameter). See overloaded function for more information. More... | |
ErrorCodes | runnableEvent (uint64_t time, size_t core_hash, size_t process_hash, size_t runnable_hash, Runnable::Events runnable_event) |
Emits a runnable event (source is a core or process depending on the value of the core_is_source parameter). More... | |
ErrorCodes | semaphoreEvent (uint64_t time, const std::string &source, const std::string &target, Semaphore::Events semaphore_event, uint64_t note) |
Emits a semaphore event. See overloaded function for more information. More... | |
ErrorCodes | semaphoreEvent (uint64_t time, size_t semaphore_hash, Semaphore::Events semaphore_event, uint64_t note) |
Emits a semaphore event (source is a semaphore). More... | |
ErrorCodes | semaphoreEvent (uint64_t time, size_t core_hash, size_t semaphore_hash, Semaphore::Events semaphore_event, uint64_t note) |
Emits a semaphore event (source is a core or process depending on the value of the core_is_source parameter). More... | |
ErrorCodes | schedulerEvent (uint64_t time, const std::string &source, const std::string &scheduler, Scheduler::Events scheduler_event) |
Emits a scheduler event. See overloaded function for more information. More... | |
ErrorCodes | schedulerEvent (uint64_t time, size_t core_hash, size_t scheduler_hash, Scheduler::Events scheduler_event) |
Emits a scheduler event (source is a core or process depending on the value of the core_is_source parameter). More... | |
ErrorCodes | schedulerEvent (uint64_t time, size_t scheduler_hash, Scheduler::Events scheduler_event) |
Emits a scheduler event (source is a scheduler). More... | |
ErrorCodes | signalEvent (uint64_t time, const std::string &source, const std::string &signal, Signal::Events signal_event, const std::string &signal_value="") |
Emits a signal event (source is a core or process depending on the value of the core_is_source parameter). See overloaded function for more information. More... | |
ErrorCodes | signalEvent (uint64_t time, size_t core_hash, size_t signal_hash, Signal::Events signal_event, const std::string &signal_value="") |
Emits a signal event (source is a core or process depending on the value of the core_is_source parameter). More... | |
ErrorCodes | stimulusEvent (uint64_t time, const std::string &source, const std::string &target, Stimulus::Events stimulus_event) |
Emits a stimulus event. See overloaded function for more information. More... | |
ErrorCodes | stimulusEvent (uint64_t time, size_t stimulus_hash, Stimulus::Events stimulus_event) |
Emits a stimulus event. More... | |
std::list< std::list< BtfEntry >::iterator > | getEventsForEntity (const std::string &entity) |
std::list< std::list< BtfEntry >::iterator > | getEventsForEntity (size_t entity_hash) |
void | comment (const std::string &comment) |
Emits a comment. More... | |
void | headerEntry (const std::string &header_entry) |
Writes a custom entry to the header. More... | |
void | insertEvent (std::list< std::list< BtfEntry >::iterator >::iterator pos, const BtfEntry &entry) |
Inserts an event into the BTF trace. Warning: Use on own risk. No checks are performed and the insertion of a wrong event can lead to an invalid BTF file. More... | |
std::list< std::list< BtfEntry >::iterator > & | getEntityEvents (const std::string &entity) |
Gets the list of events for a entity. More... | |
std::list< BtfEntry > | getAllEvents () const |
Gets a list of all events. More... | |
size_t | getNumberOfAllEvents () const |
Gets the number of all events. More... | |
ErrorCodes | simulationEventProcessName (uint64_t time, const std::string &process, const std::string &name) |
Emits a process name event (e.g. name change or initial name). See overloaded function for more information. More... | |
ErrorCodes | simulationEventProcessName (uint64_t time, size_t process_hash, const std::string &name) |
Emits a process name event (e.g. name change or initial name). More... | |
ErrorCodes | simulationEventProcessCreation (uint64_t time, const std::string &process, uint64_t pid, uint64_t ppid) |
Emits a process creation event. See overloaded function for more information. More... | |
ErrorCodes | simulationEventProcessCreation (uint64_t time, size_t process_hash, uint64_t pid, uint64_t ppid) |
Emits a process creation event, e.g. PID and PPID mapping to a process. More... | |
ErrorCodes | simulationEventThreadName (uint64_t time, const std::string &thread, const std::string &name) |
Emits a thread name event (e.g. name change or initial name). See overloaded function for more information. More... | |
ErrorCodes | simulationEventThreadName (uint64_t time, size_t thread_hash, const std::string &name) |
Emits a thread name event (e.g. name change or initial name). More... | |
ErrorCodes | simulationEventThreadCreation (uint64_t time, const std::string &thread, uint64_t tid, uint64_t pid) |
Emits a thread creation event. See overloaded function for more information. More... | |
ErrorCodes | simulationEventThreadCreation (uint64_t time, size_t thread_hash, uint64_t tid, uint64_t pid) |
Emits a thread creation event, e.g. TID and PID mapping to a thread. More... | |
void | setIgnoreMultipleTaskReleases (bool value) |
Sets the option to ignore multiple releases on a waiting task. More... | |
Main class of the btf lib. It contains all necessary functions to import and export a BTF file.
|
strong |
|
explicit |
Constructs a BTF file in memory.
[in] | path | The path where the BTF file will be created. |
[in] | time_scale | The time unit in which the events are given. |
[in] | auto_suspend_parent_runnable | Boolean which, if true, causes parent runnables to automatically stop when a child runnable starts, and resume when the child runnable finishes. The default value is false. Note: This option is not defined in the specification. However, it is included in the btf library because it can later simplify the analysis of a btf trace with several child runnables. |
[in] | source_is_core | Boolean which, if true, causes the osEvent, runnableEvent, signalEvent, schedulerEvent and semaphore event to expect a core as source instead of a process (only relevant for event types for which a process is defined as the source in the specification). Otherwise, a process is expected as source. The default value is true. Note: This option is not defined in the specification. According to the specification the source of these events are processes. However, since many trace formats only display which event occured on which core this option is implemented to ease the conversion from other trace formats to BTF. |
[in] | auto_generate_core_events | Boolean which, if true, causes a core idle event to be automatically generated when no task is running and the core to resume when a task runs again. The default value is false. Note: This option is not defined in the specification. However, it is included in the btf library because it can later simplify the analysis of a btf trace with several child runnables. |
[in] | auto_wait_resume_os_events | Boolean which, if true, causes the task state to be automatically updated after an OS event and the corresponding task events to be generated. The default value is false. Note: This option is not defined in the specification. It is included for automation purposes. |
void btf::BtfFile::comment | ( | const std::string & | comment | ) |
Emits a comment.
[in] | comment | The comment in form of a string. The # at the beginning is added by this function. |
ErrorCodes btf::BtfFile::coreEvent | ( | uint64_t | time, |
const std::string & | core, | ||
Core::Events | core_event | ||
) |
Emits a core event. See overloaded function for more information.
ErrorCodes btf::BtfFile::coreEvent | ( | uint64_t | time, |
size_t | core_hash, | ||
Core::Events | core_event | ||
) |
Emits a core event (source is a task).
[in] | time | The timestamp of the event. |
[in] | core_hash | The ID of the core. |
[in] | core_event | The core event that occurred. |
void btf::BtfFile::finish | ( | ) |
std::list< BtfEntry > btf::BtfFile::getAllEvents | ( | ) | const |
Gets a list of all events.
std::list< std::list< BtfEntry >::iterator > & btf::BtfFile::getEntityEvents | ( | const std::string & | entity | ) |
Gets the list of events for a entity.
[in] | entity | The entity. |
std::list< std::list< BtfEntry >::iterator > btf::BtfFile::getEventsForEntity | ( | const std::string & | entity | ) |
std::list< std::list< BtfEntry >::iterator > btf::BtfFile::getEventsForEntity | ( | size_t | entity_hash | ) |
size_t btf::BtfFile::getNumberOfAllEvents | ( | ) | const |
Gets the number of all events.
void btf::BtfFile::headerEntry | ( | const std::string & | header_entry | ) |
Writes a custom entry to the header.
[in] | header_entry | The header entry. |
void btf::BtfFile::importFromFile | ( | const std::string & | path, |
char | delimiter = ',' |
||
) |
Appends the data from a BTF file. Currently only import into an empty BTF file is supported.
[in] | path | The path to the BTF file. |
[in] | delimiter | The delimiter used in the BTF file. |
void btf::BtfFile::insertEvent | ( | std::list< std::list< BtfEntry >::iterator >::iterator | pos, |
const BtfEntry & | entry | ||
) |
Inserts an event into the BTF trace.
Warning: Use on own risk. No checks are performed and the insertion of a wrong event can lead to an invalid BTF file.
[in] | pos | The event is inserted before this position. |
[in] | entry | The BTF entry to insert. |
ErrorCodes btf::BtfFile::osEvent | ( | uint64_t | time, |
const std::string & | process, | ||
const std::string & | os, | ||
OS::Events | os_event | ||
) |
Emits an OS event (source is a core or a process depending on the value of the core_is_source parameter). See overloaded function for more information.
ErrorCodes btf::BtfFile::osEvent | ( | uint64_t | time, |
size_t | core_hash, | ||
size_t | os_hash, | ||
OS::Events | os_event | ||
) |
Emits an OS event (source is a core or a process depending on the value of the core_is_source parameter).
[in] | time | The timestamp of the event. |
[in] | core_hash | The ID of the core on which the event occurred. |
[in] | os_hash | The ID of the OS instance that triggered the event. |
[in] | os_event | The OS event that occurred. |
ErrorCodes btf::BtfFile::processEvent | ( | uint64_t | time, |
const std::string & | source, | ||
const std::string & | process, | ||
uint64_t | process_instance_id, | ||
Process::Events | process_event, | ||
bool | is_isr = false |
||
) |
Emits a task event (except migration). See overloaded function for more information.
ErrorCodes btf::BtfFile::processEvent | ( | uint64_t | time, |
size_t | source_hash, | ||
size_t | process_hash, | ||
uint64_t | process_instance_id, | ||
Process::Events | process_event, | ||
bool | is_isr = false |
||
) |
Emits a process event (except task migration).
[in] | time | The timestamp of the event. |
[in] | source_hash | The ID of the source on which the event occurred. |
[in] | process_hash | The ID of the process. |
[in] | process_instance_id | The instance ID of the process. |
[in] | process_event | The process event that occurred. |
[in] | is_isr | Boolean value that is true if the process is an ISR. |
ErrorCodes btf::BtfFile::runnableEvent | ( | uint64_t | time, |
const std::string & | source, | ||
const std::string & | runnable, | ||
Runnable::Events | runnable_event | ||
) |
Emits a runnable event (source is a core or process depending on the value of the core_is_source parameter). See overloaded function for more information.
ErrorCodes btf::BtfFile::runnableEvent | ( | uint64_t | time, |
size_t | core_hash, | ||
size_t | process_hash, | ||
size_t | runnable_hash, | ||
Runnable::Events | runnable_event | ||
) |
Emits a runnable event (source is a core or process depending on the value of the core_is_source parameter).
[in] | time | The timestamp of the event. |
[in] | core_hash | The ID of the core on which the event occurred. |
[in] | process_hash | The ID of the process on which the event occurred. |
[in] | runnable_hash | The ID of the runnable. |
[in] | runnable_event | The runnable event that occurred. |
ErrorCodes btf::BtfFile::schedulerEvent | ( | uint64_t | time, |
const std::string & | source, | ||
const std::string & | scheduler, | ||
Scheduler::Events | scheduler_event | ||
) |
Emits a scheduler event. See overloaded function for more information.
ErrorCodes btf::BtfFile::schedulerEvent | ( | uint64_t | time, |
size_t | core_hash, | ||
size_t | scheduler_hash, | ||
Scheduler::Events | scheduler_event | ||
) |
Emits a scheduler event (source is a core or process depending on the value of the core_is_source parameter).
[in] | time | The timestamp of the event. |
[in] | core_hash | The ID of the core on which the event occurred. |
[in] | scheduler_hash | The ID of the scheduler. |
[in] | scheduler_event | The scheduler event that occurred. |
ErrorCodes btf::BtfFile::schedulerEvent | ( | uint64_t | time, |
size_t | scheduler_hash, | ||
Scheduler::Events | scheduler_event | ||
) |
Emits a scheduler event (source is a scheduler).
[in] | time | The timestamp of the event. |
[in] | scheduler_hash | The ID of the scheduler. |
[in] | scheduler_event | The scheduler event that occurred. |
ErrorCodes btf::BtfFile::semaphoreEvent | ( | uint64_t | time, |
const std::string & | source, | ||
const std::string & | target, | ||
Semaphore::Events | semaphore_event, | ||
uint64_t | note | ||
) |
Emits a semaphore event. See overloaded function for more information.
ErrorCodes btf::BtfFile::semaphoreEvent | ( | uint64_t | time, |
size_t | core_hash, | ||
size_t | semaphore_hash, | ||
Semaphore::Events | semaphore_event, | ||
uint64_t | note | ||
) |
Emits a semaphore event (source is a core or process depending on the value of the core_is_source parameter).
[in] | time | The timestamp of the event. |
[in] | core_hash | The ID of the core on which the event occurred. |
[in] | semaphore_hash | The ID of the semaphore. |
[in] | semaphore_event | The semaphore event that occurred. |
[in] | note | The amount of accesses on the semaphore. |
ErrorCodes btf::BtfFile::semaphoreEvent | ( | uint64_t | time, |
size_t | semaphore_hash, | ||
Semaphore::Events | semaphore_event, | ||
uint64_t | note | ||
) |
Emits a semaphore event (source is a semaphore).
[in] | time | The timestamp of the event. |
[in] | semaphore_hash | The ID of the semaphore. |
[in] | semaphore_event | The semaphore event that occurred. |
[in] | note | The amount of accesses on the semaphore. |
void btf::BtfFile::setIgnoreMultipleTaskReleases | ( | bool | value | ) |
Sets the option to ignore multiple releases on a waiting task.
[in] | value | If true ignore multiple releases on a waiting task, else consider them. |
void btf::BtfFile::setStringHashMap | ( | std::unordered_map< size_t, std::string > | hash_map | ) |
Sets the ID to name translation map. This should only be used for traces that use ID based APIs (e.g. for naming of events).
Be careful when using this with string based APIs.
[in] | hash_map | The ID to name translation map. |
ErrorCodes btf::BtfFile::signalEvent | ( | uint64_t | time, |
const std::string & | source, | ||
const std::string & | signal, | ||
Signal::Events | signal_event, | ||
const std::string & | signal_value = "" |
||
) |
Emits a signal event (source is a core or process depending on the value of the core_is_source parameter). See overloaded function for more information.
ErrorCodes btf::BtfFile::signalEvent | ( | uint64_t | time, |
size_t | core_hash, | ||
size_t | signal_hash, | ||
Signal::Events | signal_event, | ||
const std::string & | signal_value = "" |
||
) |
Emits a signal event (source is a core or process depending on the value of the core_is_source parameter).
[in] | time | The timestamp of the event. |
[in] | core_hash | The ID of the core on which the event occurred. |
[in] | signal_hash | The ID of the signal. |
[in] | signal_event | The signal event that occurred. |
[in] | signal_value | (optional) value of the signal. |
ErrorCodes btf::BtfFile::simulationEventProcessCreation | ( | uint64_t | time, |
const std::string & | process, | ||
uint64_t | pid, | ||
uint64_t | ppid | ||
) |
Emits a process creation event. See overloaded function for more information.
ErrorCodes btf::BtfFile::simulationEventProcessCreation | ( | uint64_t | time, |
size_t | process_hash, | ||
uint64_t | pid, | ||
uint64_t | ppid | ||
) |
Emits a process creation event, e.g. PID and PPID mapping to a process.
[in] | time | The timestamp of the event. |
[in] | process_hash | The ID of the process. |
[in] | pid | The process ID of the process. |
[in] | ppid | The parent process ID of the parent process. |
ErrorCodes btf::BtfFile::simulationEventProcessName | ( | uint64_t | time, |
const std::string & | process, | ||
const std::string & | name | ||
) |
Emits a process name event (e.g. name change or initial name). See overloaded function for more information.
ErrorCodes btf::BtfFile::simulationEventProcessName | ( | uint64_t | time, |
size_t | process_hash, | ||
const std::string & | name | ||
) |
Emits a process name event (e.g. name change or initial name).
[in] | time | The timestamp of the event. |
[in] | process_hash | The ID of the process. |
[in] | name | The name of the process. |
ErrorCodes btf::BtfFile::simulationEventThreadCreation | ( | uint64_t | time, |
const std::string & | thread, | ||
uint64_t | tid, | ||
uint64_t | pid | ||
) |
Emits a thread creation event. See overloaded function for more information.
ErrorCodes btf::BtfFile::simulationEventThreadCreation | ( | uint64_t | time, |
size_t | thread_hash, | ||
uint64_t | tid, | ||
uint64_t | pid | ||
) |
Emits a thread creation event, e.g. TID and PID mapping to a thread.
[in] | time | The timestamp of the event. |
[in] | thread_hash | The ID of the thread. |
[in] | tid | The Thread ID of the thread. |
[in] | pid | The Process ID of the thread. |
ErrorCodes btf::BtfFile::simulationEventThreadName | ( | uint64_t | time, |
const std::string & | thread, | ||
const std::string & | name | ||
) |
Emits a thread name event (e.g. name change or initial name). See overloaded function for more information.
ErrorCodes btf::BtfFile::simulationEventThreadName | ( | uint64_t | time, |
size_t | thread_hash, | ||
const std::string & | name | ||
) |
Emits a thread name event (e.g. name change or initial name).
[in] | time | The timestamp of the event. |
[in] | thread_hash | The ID of the thread. |
[in] | name | The name of the thread. |
ErrorCodes btf::BtfFile::stimulusEvent | ( | uint64_t | time, |
const std::string & | source, | ||
const std::string & | target, | ||
Stimulus::Events | stimulus_event | ||
) |
Emits a stimulus event. See overloaded function for more information.
ErrorCodes btf::BtfFile::stimulusEvent | ( | uint64_t | time, |
size_t | stimulus_hash, | ||
Stimulus::Events | stimulus_event | ||
) |
Emits a stimulus event.
[in] | time | The timestamp of the event. |
[in] | stimulus_hash | The ID of the stimulus that triggered the event. |
[in] | stimulus_event | The stimulus event that occurred. |
ErrorCodes btf::BtfFile::taskMigrationEvent | ( | uint64_t | time, |
const std::string & | source_core, | ||
const std::string & | destination_core, | ||
const std::string & | task, | ||
uint64_t | task_instance_id | ||
) |
Emits a task migration event. See overloaded function for more information.
ErrorCodes btf::BtfFile::taskMigrationEvent | ( | uint64_t | time, |
size_t | source_core_hash, | ||
size_t | destination_core_hash, | ||
size_t | task_hash, | ||
uint64_t | task_instance_id | ||
) |
Emits a task migration event.
[in] | time | The timestamp of the event. |
[in] | source_core_hash | The ID of the core, on which the task was running. |
[in] | destination_core_hash | The ID of the core, on which the task will run. |
[in] | task_hash | The ID of the task. |
[in] | task_instance_id | The instance ID of the task. |