[Diagnostics] WIP: Refactoring exception profiling and serialization.