mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +00:00
Profiler: Add some implied auto qualifiers
This commit is contained in:
parent
d001f8ba70
commit
39a4c0e6ce
11 changed files with 40 additions and 40 deletions
|
@ -67,8 +67,8 @@ DisassemblyModel::DisassemblyModel(Profile& profile, ProfileNode& node)
|
|||
g_kernel_debug_info = make<Debug::DebugInfo>(g_kernel_debuginfo_object->elf, String::empty(), base_address);
|
||||
debug_info = g_kernel_debug_info.ptr();
|
||||
} else {
|
||||
auto& process = node.process();
|
||||
auto library_data = process.library_metadata.library_containing(node.address());
|
||||
auto const& process = node.process();
|
||||
auto const* library_data = process.library_metadata.library_containing(node.address());
|
||||
if (!library_data) {
|
||||
dbgln("no library data for address {:p}", node.address());
|
||||
return;
|
||||
|
@ -114,7 +114,7 @@ DisassemblyModel::DisassemblyModel(Profile& profile, ProfileNode& node)
|
|||
FlatPtr last_instruction_offset = 0;
|
||||
if (!is_function_address) {
|
||||
FlatPtr last_instruction_address = 0;
|
||||
for (auto& event : node.events_per_address())
|
||||
for (auto const& event : node.events_per_address())
|
||||
last_instruction_address = max(event.key, last_instruction_address);
|
||||
last_instruction_offset = last_instruction_address - node.address();
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ static Optional<ColorPair> color_pair_for(const InstructionData& insn)
|
|||
|
||||
GUI::Variant DisassemblyModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
|
||||
{
|
||||
auto& insn = m_instructions[index.row()];
|
||||
auto const& insn = m_instructions[index.row()];
|
||||
|
||||
if (role == GUI::ModelRole::BackgroundColor) {
|
||||
auto colors = color_pair_for(insn);
|
||||
|
@ -228,7 +228,7 @@ GUI::Variant DisassemblyModel::data(const GUI::ModelIndex& index, GUI::ModelRole
|
|||
if (index.column() == Column::SourceLocation) {
|
||||
StringBuilder builder;
|
||||
auto first = true;
|
||||
for (auto& entry : insn.source_position_with_inlines.inline_chain) {
|
||||
for (auto const& entry : insn.source_position_with_inlines.inline_chain) {
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
|
@ -238,7 +238,7 @@ GUI::Variant DisassemblyModel::data(const GUI::ModelIndex& index, GUI::ModelRole
|
|||
if (insn.source_position_with_inlines.source_position.has_value()) {
|
||||
if (!first)
|
||||
builder.append(" => ");
|
||||
auto& entry = insn.source_position_with_inlines.source_position.value();
|
||||
auto const& entry = insn.source_position_with_inlines.source_position.value();
|
||||
builder.appendff("{}:{}", entry.file_path, entry.line_number);
|
||||
}
|
||||
return builder.build();
|
||||
|
|
|
@ -186,12 +186,12 @@ void FlameGraphView::layout_children(GUI::ModelIndex& index, int depth, int left
|
|||
if (!index.is_valid()) {
|
||||
// We're at the root, so calculate the event count across all roots
|
||||
for (auto i = 0; i < m_model.row_count(index); ++i) {
|
||||
auto& root = *static_cast<ProfileNode*>(m_model.index(i).internal_data());
|
||||
auto const& root = *static_cast<ProfileNode const*>(m_model.index(i).internal_data());
|
||||
node_event_count += root.event_count();
|
||||
}
|
||||
m_bars.append({ {}, { left, y, available_width, bar_height }, false });
|
||||
} else {
|
||||
auto node = static_cast<ProfileNode*>(index.internal_data());
|
||||
auto const* node = static_cast<ProfileNode const*>(index.internal_data());
|
||||
|
||||
bool selected = !selected_nodes.is_empty();
|
||||
if (selected) {
|
||||
|
@ -220,7 +220,7 @@ void FlameGraphView::layout_children(GUI::ModelIndex& index, int depth, int left
|
|||
return;
|
||||
}
|
||||
|
||||
auto child = static_cast<ProfileNode*>(child_index.internal_data());
|
||||
auto const* child = static_cast<ProfileNode const*>(child_index.internal_data());
|
||||
float child_width = width_per_sample * child->event_count();
|
||||
layout_children(child_index, depth + 1, static_cast<int>(new_left), static_cast<int>(new_left + child_width), selected_nodes);
|
||||
new_left += child_width;
|
||||
|
|
|
@ -23,7 +23,7 @@ IndividualSampleModel::~IndividualSampleModel()
|
|||
|
||||
int IndividualSampleModel::row_count(const GUI::ModelIndex&) const
|
||||
{
|
||||
auto& event = m_profile.events().at(m_event_index);
|
||||
auto const& event = m_profile.events().at(m_event_index);
|
||||
return event.frames.size();
|
||||
}
|
||||
|
||||
|
@ -48,8 +48,8 @@ String IndividualSampleModel::column_name(int column) const
|
|||
|
||||
GUI::Variant IndividualSampleModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
|
||||
{
|
||||
auto& event = m_profile.events().at(m_event_index);
|
||||
auto& frame = event.frames[event.frames.size() - index.row() - 1];
|
||||
auto const& event = m_profile.events().at(m_event_index);
|
||||
auto const& frame = event.frames[event.frames.size() - index.row() - 1];
|
||||
|
||||
if (role == GUI::ModelRole::Display) {
|
||||
if (index.column() == Column::Address)
|
||||
|
|
|
@ -71,7 +71,7 @@ void Profile::rebuild_tree()
|
|||
Vector<NonnullRefPtr<ProfileNode>> roots;
|
||||
|
||||
auto find_or_create_process_node = [this, &roots](pid_t pid, EventSerialNumber serial) -> ProfileNode& {
|
||||
auto* process = find_process(pid, serial);
|
||||
auto const* process = find_process(pid, serial);
|
||||
if (!process) {
|
||||
dbgln("Profile contains event for unknown process with pid={}, serial={}", pid, serial.to_number());
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -145,10 +145,10 @@ void Profile::rebuild_tree()
|
|||
auto& process_node = find_or_create_process_node(event.pid, event.serial);
|
||||
process_node.increment_event_count();
|
||||
for_each_frame([&](const Frame& frame, bool is_innermost_frame) {
|
||||
auto& object_name = frame.object_name;
|
||||
auto& symbol = frame.symbol;
|
||||
auto& address = frame.address;
|
||||
auto& offset = frame.offset;
|
||||
auto const& object_name = frame.object_name;
|
||||
auto const& symbol = frame.symbol;
|
||||
auto const& address = frame.address;
|
||||
auto const& offset = frame.offset;
|
||||
|
||||
if (symbol.is_empty())
|
||||
return IterationDecision::Break;
|
||||
|
@ -223,7 +223,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
|
|||
if (json.is_error() || !json.value().is_object())
|
||||
return Error::from_string_literal("Invalid perfcore format (not a JSON object)"sv);
|
||||
|
||||
auto& object = json.value().as_object();
|
||||
auto const& object = json.value().as_object();
|
||||
|
||||
if (!g_kernel_debuginfo_object.has_value()) {
|
||||
auto debuginfo_file_or_error = Core::MappedFile::map("/boot/Kernel.debug");
|
||||
|
@ -234,29 +234,29 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
|
|||
}
|
||||
}
|
||||
|
||||
auto strings_value = object.get_ptr("strings"sv);
|
||||
auto const* strings_value = object.get_ptr("strings"sv);
|
||||
if (!strings_value || !strings_value->is_array())
|
||||
return Error::from_string_literal("Malformed profile (strings is not an array)"sv);
|
||||
|
||||
HashMap<FlatPtr, String> profile_strings;
|
||||
for (FlatPtr string_id = 0; string_id < strings_value->as_array().size(); ++string_id) {
|
||||
auto& value = strings_value->as_array().at(string_id);
|
||||
auto const& value = strings_value->as_array().at(string_id);
|
||||
profile_strings.set(string_id, value.to_string());
|
||||
}
|
||||
|
||||
auto events_value = object.get_ptr("events");
|
||||
auto const* events_value = object.get_ptr("events");
|
||||
if (!events_value || !events_value->is_array())
|
||||
return Error::from_string_literal("Malformed profile (events is not an array)"sv);
|
||||
|
||||
auto& perf_events = events_value->as_array();
|
||||
auto const& perf_events = events_value->as_array();
|
||||
|
||||
NonnullOwnPtrVector<Process> all_processes;
|
||||
HashMap<pid_t, Process*> current_processes;
|
||||
Vector<Event> events;
|
||||
EventSerialNumber next_serial;
|
||||
|
||||
for (auto& perf_event_value : perf_events.values()) {
|
||||
auto& perf_event = perf_event_value.as_object();
|
||||
for (auto const& perf_event_value : perf_events.values()) {
|
||||
auto const& perf_event = perf_event_value.as_object();
|
||||
|
||||
Event event;
|
||||
|
||||
|
@ -332,7 +332,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
|
|||
.executable = executable,
|
||||
};
|
||||
|
||||
auto old_process = current_processes.get(event.pid).value();
|
||||
auto* old_process = current_processes.get(event.pid).value();
|
||||
old_process->end_valid = event.serial;
|
||||
|
||||
current_processes.remove(event.pid);
|
||||
|
@ -349,7 +349,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
|
|||
all_processes.append(move(sampled_process));
|
||||
continue;
|
||||
} else if (type_string == "process_exit"sv) {
|
||||
auto old_process = current_processes.get(event.pid).value();
|
||||
auto* old_process = current_processes.get(event.pid).value();
|
||||
old_process->end_valid = event.serial;
|
||||
|
||||
current_processes.remove(event.pid);
|
||||
|
@ -375,11 +375,11 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
|
|||
|
||||
auto maybe_kernel_base = Symbolication::kernel_base();
|
||||
|
||||
auto* stack = perf_event.get_ptr("stack");
|
||||
auto const* stack = perf_event.get_ptr("stack");
|
||||
VERIFY(stack);
|
||||
auto& stack_array = stack->as_array();
|
||||
auto const& stack_array = stack->as_array();
|
||||
for (ssize_t i = stack_array.values().size() - 1; i >= 0; --i) {
|
||||
auto& frame = stack_array.at(i);
|
||||
auto const& frame = stack_array.at(i);
|
||||
auto ptr = frame.to_number<u64>();
|
||||
u32 offset = 0;
|
||||
FlyString object_name;
|
||||
|
@ -397,7 +397,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
|
|||
LibraryMetadata* library_metadata {};
|
||||
if (it != current_processes.end())
|
||||
library_metadata = &it->value->library_metadata;
|
||||
if (auto* library = library_metadata ? library_metadata->library_containing(ptr) : nullptr) {
|
||||
if (auto const* library = library_metadata ? library_metadata->library_containing(ptr) : nullptr) {
|
||||
object_name = library->name;
|
||||
symbol = library->symbolicate(ptr, &offset);
|
||||
} else {
|
||||
|
|
|
@ -266,7 +266,7 @@ public:
|
|||
void for_each_signpost(Callback callback) const
|
||||
{
|
||||
for (auto index : m_signpost_indices) {
|
||||
auto& event = m_events[index];
|
||||
auto const& event = m_events[index];
|
||||
if (callback(event) == IterationDecision::Break)
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ GUI::Variant ProfileModel::data(const GUI::ModelIndex& index, GUI::ModelRole rol
|
|||
if (index.column() == Column::SymbolAddress) {
|
||||
if (node->is_root())
|
||||
return "";
|
||||
auto library = node->process().library_metadata.library_containing(node->address());
|
||||
auto const* library = node->process().library_metadata.library_containing(node->address());
|
||||
if (!library)
|
||||
return "";
|
||||
return String::formatted("{:p} (offset {:p})", node->address(), node->address() - library->base);
|
||||
|
|
|
@ -56,7 +56,7 @@ String SamplesModel::column_name(int column) const
|
|||
GUI::Variant SamplesModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
|
||||
{
|
||||
u32 event_index = m_profile.filtered_event_indices()[index.row()];
|
||||
auto& event = m_profile.events().at(event_index);
|
||||
auto const& event = m_profile.events().at(event_index);
|
||||
|
||||
if (role == GUI::ModelRole::Custom) {
|
||||
return event_index;
|
||||
|
@ -73,7 +73,7 @@ GUI::Variant SamplesModel::data(const GUI::ModelIndex& index, GUI::ModelRole rol
|
|||
return event.tid;
|
||||
|
||||
if (index.column() == Column::ExecutableName) {
|
||||
if (auto* process = m_profile.find_process(event.pid, event.serial))
|
||||
if (auto const* process = m_profile.find_process(event.pid, event.serial))
|
||||
return process->executable;
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ String SignpostsModel::column_name(int column) const
|
|||
GUI::Variant SignpostsModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
|
||||
{
|
||||
u32 event_index = m_profile.filtered_signpost_indices()[index.row()];
|
||||
auto& event = m_profile.events().at(event_index);
|
||||
auto const& event = m_profile.events().at(event_index);
|
||||
|
||||
if (role == GUI::ModelRole::Custom) {
|
||||
return event_index;
|
||||
|
@ -71,7 +71,7 @@ GUI::Variant SignpostsModel::data(const GUI::ModelIndex& index, GUI::ModelRole r
|
|||
return event.tid;
|
||||
|
||||
if (index.column() == Column::ExecutableName) {
|
||||
if (auto* process = m_profile.find_process(event.pid, event.serial))
|
||||
if (auto const* process = m_profile.find_process(event.pid, event.serial))
|
||||
return process->executable;
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ void TimelineHeader::paint_event(GUI::PaintEvent& event)
|
|||
};
|
||||
text_rect.center_vertically_within(frame_inner_rect());
|
||||
|
||||
auto& font = m_selected ? painter.font().bold_variant() : painter.font();
|
||||
auto const& font = m_selected ? painter.font().bold_variant() : painter.font();
|
||||
auto color = m_selected ? palette().selection_text() : palette().button_text();
|
||||
painter.draw_text(text_rect, m_text, font, Gfx::TextAlignment::CenterLeft, color);
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ void TimelineTrack::recompute_histograms_if_needed(HistogramInputs const& inputs
|
|||
m_kernel_histogram = Histogram { inputs.start, inputs.end, inputs.columns };
|
||||
m_user_histogram = Histogram { inputs.start, inputs.end, inputs.columns };
|
||||
|
||||
for (auto& event : m_profile.events()) {
|
||||
for (auto const& event : m_profile.events()) {
|
||||
if (event.pid != m_process.pid)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -96,9 +96,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
timeline_header_container->set_shrink_to_fit(true);
|
||||
|
||||
auto timeline_view = TRY(TimelineView::try_create(*profile));
|
||||
for (auto& process : profile->processes()) {
|
||||
for (auto const& process : profile->processes()) {
|
||||
bool matching_event_found = false;
|
||||
for (auto& event : profile->events()) {
|
||||
for (auto const& event : profile->events()) {
|
||||
if (event.pid == process.pid && process.valid_at(event.serial)) {
|
||||
matching_event_found = true;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue