I have learned that both trace and Statistical Profiling Extension(SPE) can measure performance and output profiling information like PC, performance register values, etc. Compared to trace, SPE records more detailed performance information. What's the relationship between trace and SPE? Is it possible to extend the performance information recorded by Trace to achieve the corresponding functionality of SPE?
These are very different use cases - instruction trace gives a complete history of execution, used for debug and code-coverage tasks mainly. SPE data can be accessed by software, and is used primarily as a profiling solution, such as perf or Arm Streamline:
https://community.arm.com/arm-community-blogs/b/tools-software-ides-blog/posts/introduction-to-statistical-profiling-support-in-streamline