From 8331ab74d1130d6445545595dbf1387025238cb3 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Fri, 20 Sep 2019 16:09:58 +0300 Subject: [PATCH] Assign event ids after creation from backends 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. --- src/gpuvis.cpp | 3 +++ src/gpuvis_etl.cpp | 3 --- src/trace-cmd/trace-read.cpp | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/gpuvis.cpp b/src/gpuvis.cpp index 49118904..59e7715a 100644 --- a/src/gpuvis.cpp +++ b/src/gpuvis.cpp @@ -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() ) diff --git a/src/gpuvis_etl.cpp b/src/gpuvis_etl.cpp index fcde068a..a2cb5f3b 100644 --- a/src/gpuvis_etl.cpp +++ b/src/gpuvis_etl.cpp @@ -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 ) @@ -717,7 +716,6 @@ class etl_parser_t EventCallback &mCallback; etl_reader_t mReader; - uint32_t mCurrentEventId; uint64_t mStartTicks; std::unordered_map mAdapterMap; @@ -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; diff --git a/src/trace-cmd/trace-read.cpp b/src/trace-cmd/trace-read.cpp index 1cb43722..499fb105 100644 --- a/src/trace-cmd/trace-read.cpp +++ b/src/trace-cmd/trace-read.cpp @@ -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; @@ -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;