Skip to content

Commit

Permalink
Assign event ids after creation from backends
Browse files Browse the repository at this point in the history
If we want to merge events coming from different sources (in the
future changes, files), we need to be able to label the events
uniquely across sources so assigning an ID right before an item is
added to the array makes more sense.
  • Loading branch information
llandwerlin-intel authored and mikesart committed Feb 18, 2020
1 parent 95ee1b5 commit 8331ab7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/gpuvis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,9 @@ int TraceEvents::new_event_cb( const trace_event_t &event )
// Add event to our m_events array
m_events.push_back( event );

// Assign an event id
m_events.back().id = m_events.size() - 1;

// If this is a sched_switch event, see if it has comm info we don't know about.
// This is the reason we're initializing events in two passes to collect all this data.
if ( event.is_sched_switch() )
Expand Down
3 changes: 0 additions & 3 deletions src/gpuvis_etl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,6 @@ class etl_parser_t
, mTraceInfo( trace_info )
, mCallback( cb )
, mReader( file, process_event_cb_proxy, this )
, mCurrentEventId( 0 )
, mStartTicks( 0 )
, mAdapterCount( 0 )
, mCrtcCount( 0 )
Expand Down Expand Up @@ -717,7 +716,6 @@ class etl_parser_t
EventCallback &mCallback;

etl_reader_t mReader;
uint32_t mCurrentEventId;
uint64_t mStartTicks;

std::unordered_map<uint64_t, int> mAdapterMap;
Expand Down Expand Up @@ -827,7 +825,6 @@ class etl_parser_t
}

event.pid = entry.tid;
event.id = mCurrentEventId++;
event.cpu = entry.cpu;
event.ts = ticks_to_relative_us( entry.ts );
event.comm = comm;
Expand Down
2 changes: 0 additions & 2 deletions src/trace-cmd/trace-read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,6 @@ class trace_data_t
trace_info_t &trace_info;
StrPool &strpool;

uint32_t events = 0;
const char *seqno_str;
const char *crtc_str;
const char *ip_str;
Expand Down Expand Up @@ -1648,7 +1647,6 @@ static int trace_enum_events( trace_data_t &trace_data, tracecmd_input_t *handle
trace_seq_init( &seq );

trace_event.pid = pid;
trace_event.id = trace_data.events++;
trace_event.cpu = record->cpu;
trace_event.ts = record->ts - trace_data.trace_info.min_file_ts;

Expand Down

0 comments on commit 8331ab7

Please sign in to comment.