@@ -836,7 +836,7 @@ bool PerfDataConverter::Sample(const PerfDataHandler::SampleContext& sample) {
836
836
// LBR callstacks include only user call chains. If this is an LBR sample,
837
837
// we get the kernel callstack from the sample's callchain, and the user
838
838
// callstack from the sample's branch_stack.
839
- const bool lbr_sample = !sample.branch_stack .empty ();
839
+ const bool lbr_sample = !sample.branch_stack .empty () && !sample. spe . is_spe ;
840
840
bool skipped_dup = false ;
841
841
for (const auto & frame : sample.callchain ) {
842
842
if (lbr_sample && frame.ip == quipper::PERF_CONTEXT_USER) {
@@ -875,23 +875,28 @@ bool PerfDataConverter::Sample(const PerfDataHandler::SampleContext& sample) {
875
875
AddOrGetLocation (event_pid, frame.ip - 1 , frame.mapping , builder));
876
876
IncBuildIdStats (event_pid, frame.mapping );
877
877
}
878
- for (const auto & frame : sample.branch_stack ) {
879
- // branch_stack entries are pairs of <from, to> locations corresponding to
880
- // addresses of call instructions and target addresses of those calls.
881
- // We need only the addresses of the function call instructions, stored in
882
- // the 'from' field, to recover the call chains.
883
- if (frame.from .mapping == nullptr ) {
884
- continue ;
885
- }
886
- // An LBR entry includes the address of the call instruction, so we don't
887
- // have to do any adjustments.
888
- if (frame.from .ip < frame.from .mapping ->start ) {
889
- continue ;
878
+
879
+ // Only add the frame from branch_stack if it is an LBR sample.
880
+ if (lbr_sample) {
881
+ for (const auto & frame : sample.branch_stack ) {
882
+ // branch_stack entries are pairs of <from, to> locations corresponding to
883
+ // addresses of call instructions and target addresses of those calls. We
884
+ // need only the addresses of the function call instructions, stored in
885
+ // the 'from' field, to recover the call chains.
886
+ if (frame.from .mapping == nullptr ) {
887
+ continue ;
888
+ }
889
+ // An LBR entry includes the address of the call instruction, so we don't
890
+ // have to do any adjustments.
891
+ if (frame.from .ip < frame.from .mapping ->start ) {
892
+ continue ;
893
+ }
894
+ sample_key.stack .push_back (AddOrGetLocation (event_pid, frame.from .ip ,
895
+ frame.from .mapping , builder));
896
+ IncBuildIdStats (event_pid, frame.from .mapping );
890
897
}
891
- sample_key.stack .push_back (AddOrGetLocation (event_pid, frame.from .ip ,
892
- frame.from .mapping , builder));
893
- IncBuildIdStats (event_pid, frame.from .mapping );
894
898
}
899
+
895
900
AddOrUpdateSample (sample, event_pid, sample_key, builder);
896
901
return true ;
897
902
}
0 commit comments