[rtems-tools commit] record: Fix thread name handling
Sebastian Huber
sebh at rtems.org
Thu Dec 1 12:14:23 UTC 2022
Module: rtems-tools
Branch: master
Commit: 66b81d6baf5e4ff1b4bb9ac50f885261aca381cb
Changeset: http://git.rtems.org/rtems-tools/commit/?id=66b81d6baf5e4ff1b4bb9ac50f885261aca381cb
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Nov 30 19:11:20 2022 +0100
record: Fix thread name handling
Reset the thread name at thread create and ID events.
---
trace/record/record-main-lttng.cc | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/trace/record/record-main-lttng.cc b/trace/record/record-main-lttng.cc
index faa762d..9993565 100644
--- a/trace/record/record-main-lttng.cc
+++ b/trace/record/record-main-lttng.cc
@@ -221,6 +221,8 @@ class LTTNGClient : public Client {
void WriteIRQHandlerExit(PerCPUContext* pcpu, const ClientItem& item);
+ void ResetThreadName(PerCPUContext* pcpu, const ClientItem& item);
+
void AddThreadName(PerCPUContext* pcpu, const ClientItem& item);
void PrintItem(const ClientItem& item);
@@ -437,6 +439,20 @@ void LTTNGClient::WriteIRQHandlerExit(PerCPUContext* pcpu,
std::fwrite(&ih, sizeof(ih), 1, pcpu->event_stream);
}
+void LTTNGClient::ResetThreadName(PerCPUContext* pcpu, const ClientItem& item) {
+ pcpu->thread_id = item.data;
+ pcpu->thread_ns = item.ns;
+ pcpu->thread_name_index = 0;
+
+ uint32_t api_index = GetAPIIndexOfID(pcpu->thread_id);
+ if (api_index >= THREAD_API_COUNT) {
+ return;
+ }
+
+ uint32_t obj_index = GetObjIndexOfID(pcpu->thread_id);
+ std::memset(&thread_names_[api_index][obj_index][0], 0, THREAD_NAME_SIZE);
+}
+
void LTTNGClient::AddThreadName(PerCPUContext* pcpu, const ClientItem& item) {
if (pcpu->thread_name_index >= THREAD_NAME_SIZE) {
return;
@@ -489,10 +505,9 @@ void LTTNGClient::PrintItem(const ClientItem& item) {
WriteSchedSwitch(&pcpu, item);
}
break;
+ case RTEMS_RECORD_THREAD_CREATE:
case RTEMS_RECORD_THREAD_ID:
- pcpu.thread_id = item.data;
- pcpu.thread_ns = item.ns;
- pcpu.thread_name_index = 0;
+ ResetThreadName(&pcpu, item);
break;
case RTEMS_RECORD_INTERRUPT_ENTRY:
WriteIRQHandlerEntry(&pcpu, item);
More information about the vc
mailing list