1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:07:35 +00:00

Profiler: Add source code view

This adds a new view mode to profiler which displays source lines and
samples that occured at those lines. This view can be opened via the
menu or by pressing CTRL-S.

It does this by mapping file names from DWARF to "/usr/src/serenity/..."
i.e. source code should be copied to /usr/src/serenity/Userland and
/usr/src/serenity/Kernel to be visible in this mode.

Currently *all* files contributing to the selected function are loaded
completely which could be a lot of data when dealing with lots of
inlined code.
This commit is contained in:
Stephan Unverwerth 2021-12-27 01:25:58 +01:00 committed by Andreas Kling
parent e6df1c9988
commit cf8427b7b4
6 changed files with 315 additions and 0 deletions

View file

@ -8,6 +8,7 @@
#include "DisassemblyModel.h"
#include "ProfileModel.h"
#include "SamplesModel.h"
#include "SourceModel.h"
#include <AK/HashTable.h>
#include <AK/LexicalPath.h>
#include <AK/NonnullOwnPtrVector.h>
@ -554,6 +555,23 @@ GUI::Model* Profile::disassembly_model()
return m_disassembly_model;
}
void Profile::set_source_index(GUI::ModelIndex const& index)
{
if (m_source_index == index)
return;
m_source_index = index;
auto* node = static_cast<ProfileNode*>(index.internal_data());
if (!node)
m_source_model = nullptr;
else
m_source_model = SourceModel::create(*this, *node);
}
GUI::Model* Profile::source_model()
{
return m_source_model;
}
ProfileNode::ProfileNode(Process const& process)
: m_root(true)
, m_process(process)