Skip to content

Commit 48a3226

Browse files
authored
Merge pull request #32 from sparcians/dev/bdutro/process-id-fixes
Properly handle ProcessIDExtRecord in STFWriter
2 parents 2c0770d + 1b339f1 commit 48a3226

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/stf_writer.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ namespace stf {
2222
vlen_config_ = STFRecord::make<VLenConfigRecord>(vlen);
2323
}
2424

25+
// cppcheck-suppress unusedFunction
26+
void STFWriter::setHeaderProcessID(uint32_t hw_thread_id, uint32_t pid, uint32_t tid) {
27+
initial_process_id_ = STFRecord::make<ProcessIDExtRecord>(hw_thread_id, pid, tid);
28+
}
29+
2530
void STFWriter::flushHeader() {
2631
stf_assert(!header_finalized_, "Cannot write anything else to the header after it has been finalized");
2732

@@ -69,6 +74,12 @@ namespace stf {
6974
trace_features_written_ = true;
7075
}
7176

77+
// Initial process ID is optional
78+
if(!initial_process_id_written_ && initial_process_id_) {
79+
*this << *initial_process_id_;
80+
initial_process_id_written_ = true;
81+
}
82+
7283
if(!initial_pc_written_ && initial_pc_) {
7384
stf_assert(isa_written_, "ISA record must come before FORCE_PC record");
7485
stf_assert(initial_iem_written_, "IEM record must come before FORCE_PC record");
@@ -156,6 +167,7 @@ namespace stf {
156167
((wrote_page_table_walk_ || wrote_reg_) && desc == descriptors::internal::Descriptor::STF_INST_PC_TARGET) ||
157168
(wrote_page_table_walk_ && desc == descriptors::internal::Descriptor::STF_INST_REG) ||
158169
(desc == descriptors::internal::Descriptor::STF_COMMENT) ||
170+
(desc == descriptors::internal::Descriptor::STF_PROCESS_ID_EXT) ||
159171
(desc == descriptors::internal::Descriptor::STF_FORCE_PC),
160172
"Attempted out of order write. " << desc << " should come before " << last_desc_);
161173
switch(desc) {
@@ -169,10 +181,10 @@ namespace stf {
169181
case descriptors::internal::Descriptor::STF_ISA:
170182
case descriptors::internal::Descriptor::STF_TRACE_INFO:
171183
case descriptors::internal::Descriptor::STF_TRACE_INFO_FEATURE:
172-
case descriptors::internal::Descriptor::STF_PROCESS_ID_EXT:
173184
case descriptors::internal::Descriptor::STF_VLEN_CONFIG:
174185
case descriptors::internal::Descriptor::STF_END_HEADER:
175186
stf_assert(!headerFinalized(), "Attempted to write " << desc << " record outside of the header"); //FALLTHRU
187+
case descriptors::internal::Descriptor::STF_PROCESS_ID_EXT:
176188
case descriptors::internal::Descriptor::STF_INST_IEM:
177189
case descriptors::internal::Descriptor::STF_FORCE_PC:
178190
stf_assert(headerStarted(), "Attempted to write " << desc << " before the header has started");

stf-inc/stf_writer.hpp

+12
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace stf {
1818
class ISARecord;
1919
class InstIEMRecord;
2020
class ForcePCRecord;
21+
class ProcessIDExtRecord;
2122
class VLenConfigRecord;
2223

2324
/**
@@ -38,6 +39,9 @@ namespace stf {
3839
STFRecord::Handle<ForcePCRecord> initial_pc_;
3940
bool initial_pc_written_ = false;
4041

42+
STFRecord::Handle<ProcessIDExtRecord> initial_process_id_;
43+
bool initial_process_id_written_ = false;
44+
4145
STFRecord::Handle<VLenConfigRecord> vlen_config_;
4246
bool vlen_config_written_ = false;
4347

@@ -83,6 +87,14 @@ namespace stf {
8387
*/
8488
void setHeaderPC(const uint64_t pc);
8589

90+
/**
91+
* Sets header PC
92+
* \param hw_thread_id Hardware thread/core ID
93+
* \param pid Process ID
94+
* \param tid Thread ID
95+
*/
96+
void setHeaderProcessID(const uint32_t hw_thread_id, const uint32_t pid, const uint32_t tid);
97+
8698
/**
8799
* Removes trace feature from header
88100
* \param trace_feature feature to remove

0 commit comments

Comments
 (0)