@@ -186,6 +186,7 @@ constexpr const char* kWineSyscallDispatcherFunctionName = "__wine_syscall_dispa
186186constexpr std::string_view kGgpVlkModulePathSubstring = " ggpvlk.so" ;
187187const TimeRange kDefaultTimeRange =
188188 TimeRange (std::numeric_limits<uint64_t >::min(), std::numeric_limits<uint64_t >::max());
189+ const CallstackData kEmptyCallstackData ;
189190
190191orbit_data_views::PresetLoadState GetPresetLoadStateForProcess (const PresetFile& preset,
191192 const ProcessData* process) {
@@ -435,10 +436,13 @@ Future<void> OrbitApp::OnCaptureComplete() {
435436 std::move (post_processed_sampling_data));
436437 RefreshCaptureView ();
437438
438- SetSamplingReport (&GetCaptureData ().GetCallstackData (),
439- &GetCaptureData ().post_processed_sampling_data ());
440- SetTopDownView (GetCaptureData ().post_processed_sampling_data ());
441- SetBottomUpView (GetCaptureData ().post_processed_sampling_data ());
439+ full_capture_selection_ = std::make_unique<SelectionData>(
440+ *module_manager_, GetCaptureData (), GetCaptureData ().post_processed_sampling_data (),
441+ &GetCaptureData ().GetCallstackData ());
442+ SetSamplingReport (&full_capture_selection_->GetCallstackData (),
443+ &full_capture_selection_->GetPostProcessedSamplingData ());
444+ main_window_->SetTopDownView (full_capture_selection_->GetTopDownView ());
445+ main_window_->SetBottomUpView (full_capture_selection_->GetBottomUpView ());
442446
443447 ORBIT_CHECK (capture_stopped_callback_);
444448 capture_stopped_callback_ ();
@@ -2249,7 +2253,6 @@ void OrbitApp::SetCaptureDataSelectionFields(
22492253}
22502254
22512255void OrbitApp::SelectCallstackEvents (absl::Span<const CallstackEvent> selected_callstack_events) {
2252- main_window_->ClearCallstackInspection ();
22532256 SetCaptureDataSelectionFields (selected_callstack_events);
22542257 SetSelectionTopDownView (GetCaptureData ().selection_post_processed_sampling_data (),
22552258 GetCaptureData ());
@@ -2261,16 +2264,13 @@ void OrbitApp::SelectCallstackEvents(absl::Span<const CallstackEvent> selected_c
22612264}
22622265
22632266void OrbitApp::InspectCallstackEvents (absl::Span<const CallstackEvent> selected_callstack_events) {
2264- SetCaptureDataSelectionFields (selected_callstack_events);
2265- main_window_->SetCallstackInspection (
2266- CallTreeView::CreateTopDownViewFromPostProcessedSamplingData (
2267- GetCaptureData ().selection_post_processed_sampling_data (), *module_manager_,
2268- GetCaptureData ()),
2269- CallTreeView::CreateBottomUpViewFromPostProcessedSamplingData (
2270- GetCaptureData ().selection_post_processed_sampling_data (), *module_manager_,
2271- GetCaptureData ()),
2272- GetOrCreateSelectionCallstackDataView (), &GetCaptureData ().selection_callstack_data (),
2273- &GetCaptureData ().selection_post_processed_sampling_data ());
2267+ auto selection = std::make_unique<SelectionData>(*module_manager_, GetCaptureData (),
2268+ selected_callstack_events);
2269+ main_window_->SetCallstackInspection (selection->GetTopDownView (), selection->GetBottomUpView (),
2270+ GetOrCreateDataView (DataViewType::kCallstack ),
2271+ &selection->GetCallstackData (),
2272+ &selection->GetPostProcessedSamplingData ());
2273+ inspection_selection_ = std::move (selection);
22742274 FireRefreshCallbacks ();
22752275}
22762276
@@ -2281,8 +2281,8 @@ void OrbitApp::ClearSelectionTabs() {
22812281}
22822282
22832283void OrbitApp::ClearInspection () {
2284- SetCaptureDataSelectionFields (std::vector<CallstackEvent>());
22852284 main_window_->ClearCallstackInspection ();
2285+ inspection_selection_.reset ();
22862286 FireRefreshCallbacks ();
22872287}
22882288
@@ -2297,10 +2297,18 @@ void OrbitApp::UpdateAfterSymbolLoading() {
22972297 orbit_client_model::CreatePostProcessedSamplingData (capture_data.GetCallstackData (),
22982298 capture_data, *module_manager_);
22992299 GetMutableCaptureData ().set_post_processed_sampling_data (post_processed_sampling_data);
2300- main_window_->UpdateSamplingReport (&capture_data.GetCallstackData (),
2301- &capture_data.post_processed_sampling_data ());
2302- SetTopDownView (capture_data.post_processed_sampling_data ());
2303- SetBottomUpView (capture_data.post_processed_sampling_data ());
2300+ auto selection = std::make_unique<SelectionData>(*module_manager_, GetCaptureData (),
2301+ GetCaptureData ().post_processed_sampling_data (),
2302+ &GetCaptureData ().GetCallstackData ());
2303+ main_window_->SetTopDownView (selection->GetTopDownView ());
2304+ main_window_->SetBottomUpView (selection->GetBottomUpView ());
2305+ main_window_->UpdateSamplingReport (&selection->GetCallstackData (),
2306+ &selection->GetPostProcessedSamplingData ());
2307+ full_capture_selection_ = std::move (selection);
2308+
2309+ main_window_->ClearCallstackInspection ();
2310+ inspection_selection_.reset ();
2311+ time_range_thread_selection_.reset ();
23042312
23052313 PostProcessedSamplingData selection_post_processed_sampling_data =
23062314 orbit_client_model::CreatePostProcessedSamplingData (capture_data.selection_callstack_data (),
@@ -2788,12 +2796,12 @@ void OrbitApp::ClearTimeRangeSelection() {
27882796}
27892797
27902798void OrbitApp::ClearThreadAndTimeRangeSelection () {
2791- SetCaptureDataSelectionFields (std::vector<CallstackEvent>());
27922799 main_window_->SetLiveTabScopeStatsCollection (GetCaptureData ().GetAllScopeStatsCollection ());
2793- SetTopDownView (GetCaptureData ().post_processed_sampling_data ());
2794- SetBottomUpView (GetCaptureData ().post_processed_sampling_data ());
2795- SetSamplingReport (&GetCaptureData ().GetCallstackData (),
2796- &GetCaptureData ().post_processed_sampling_data ());
2800+ main_window_->SetTopDownView (full_capture_selection_->GetTopDownView ());
2801+ main_window_->SetBottomUpView (full_capture_selection_->GetBottomUpView ());
2802+ SetSamplingReport (&full_capture_selection_->GetCallstackData (),
2803+ &full_capture_selection_->GetPostProcessedSamplingData ());
2804+ time_range_thread_selection_.reset ();
27972805
27982806 FireRefreshCallbacks ();
27992807}
@@ -2803,6 +2811,7 @@ void OrbitApp::OnThreadOrTimeRangeSelectionChange() {
28032811 if (!HasCaptureData () || !absl::GetFlag (FLAGS_time_range_selection)) return ;
28042812
28052813 main_window_->ClearCallstackInspection ();
2814+ inspection_selection_.reset ();
28062815
28072816 uint32_t thread_id = data_manager_->selected_thread_id ();
28082817 bool has_time_range = data_manager_->GetSelectionTimeRange ().has_value ();
@@ -2813,21 +2822,35 @@ void OrbitApp::OnThreadOrTimeRangeSelectionChange() {
28132822
28142823 TimeRange time_range =
28152824 has_time_range ? data_manager_->GetSelectionTimeRange ().value () : kDefaultTimeRange ;
2825+ std::vector<CallstackEvent> callstack_events;
28162826 if (thread_id == kAllProcessThreadsTid ) {
2817- SetCaptureDataSelectionFields ( GetCaptureData ().GetCallstackData ().GetCallstackEventsInTimeRange (
2818- time_range.start , time_range.end )) ;
2827+ callstack_events = GetCaptureData ().GetCallstackData ().GetCallstackEventsInTimeRange (
2828+ time_range.start , time_range.end );
28192829 } else {
2820- SetCaptureDataSelectionFields (
2821- GetCaptureData ().GetCallstackData ().GetCallstackEventsOfTidInTimeRange (
2822- thread_id, time_range.start , time_range.end ));
2830+ callstack_events = GetCaptureData ().GetCallstackData ().GetCallstackEventsOfTidInTimeRange (
2831+ thread_id, time_range.start , time_range.end );
28232832 }
2824-
2833+ auto selection =
2834+ std::make_unique<SelectionData>(*module_manager_, GetCaptureData (), callstack_events);
28252835 main_window_->SetLiveTabScopeStatsCollection (
28262836 GetCaptureData ().CreateScopeStatsCollection (thread_id, time_range.start , time_range.end ));
2827- SetTopDownView (GetCaptureData (). selection_post_processed_sampling_data ());
2828- SetBottomUpView (GetCaptureData (). selection_post_processed_sampling_data ());
2829- SetSamplingReport (&GetCaptureData (). selection_callstack_data (),
2830- & GetCaptureData (). selection_post_processed_sampling_data () );
2837+ main_window_-> SetTopDownView (selection-> GetTopDownView ());
2838+ main_window_-> SetBottomUpView (selection-> GetBottomUpView ());
2839+ SetSamplingReport (&selection-> GetCallstackData (), &selection-> GetPostProcessedSamplingData ());
2840+ time_range_thread_selection_ = std::move (selection );
28312841
28322842 FireRefreshCallbacks ();
2843+ }
2844+
2845+ const CallstackData& OrbitApp::GetSelectedCallstackData () const {
2846+ if (absl::GetFlag (FLAGS_time_range_selection)) {
2847+ if (inspection_selection_ != nullptr ) {
2848+ return inspection_selection_->GetCallstackData ();
2849+ }
2850+ if (time_range_thread_selection_ != nullptr ) {
2851+ return time_range_thread_selection_->GetCallstackData ();
2852+ }
2853+ return kEmptyCallstackData ;
2854+ }
2855+ return GetCaptureData ().selection_callstack_data ();
28332856}
0 commit comments