mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-16 23:31:55 +00:00
Profiler: Port to LibMain :^)
This commit is contained in:
parent
f526325e24
commit
dfca0def63
Notes:
sideshowbarker
2024-07-18 00:45:44 +09:00
Author: https://github.com/awesomekling
Commit: dfca0def63
2 changed files with 9 additions and 7 deletions
|
@ -21,4 +21,4 @@ set(SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_app(Profiler ICON app-profiler)
|
serenity_app(Profiler ICON app-profiler)
|
||||||
target_link_libraries(Profiler LibGUI LibDesktop LibX86 LibSymbolication)
|
target_link_libraries(Profiler LibGUI LibDesktop LibX86 LibSymbolication LibMain)
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/ElapsedTimer.h>
|
#include <LibCore/ElapsedTimer.h>
|
||||||
#include <LibCore/ProcessStatisticsReader.h>
|
#include <LibCore/ProcessStatisticsReader.h>
|
||||||
|
#include <LibCore/System.h>
|
||||||
#include <LibCore/Timer.h>
|
#include <LibCore/Timer.h>
|
||||||
#include <LibDesktop/Launcher.h>
|
#include <LibDesktop/Launcher.h>
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
|
@ -33,6 +34,7 @@
|
||||||
#include <LibGUI/TableView.h>
|
#include <LibGUI/TableView.h>
|
||||||
#include <LibGUI/TreeView.h>
|
#include <LibGUI/TreeView.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
|
#include <LibMain/Main.h>
|
||||||
#include <serenity.h>
|
#include <serenity.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -40,21 +42,21 @@ using namespace Profiler;
|
||||||
|
|
||||||
static bool generate_profile(pid_t& pid);
|
static bool generate_profile(pid_t& pid);
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
int pid = 0;
|
int pid = 0;
|
||||||
const char* perfcore_file_arg = nullptr;
|
const char* perfcore_file_arg = nullptr;
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.add_option(pid, "PID to profile", "pid", 'p', "PID");
|
args_parser.add_option(pid, "PID to profile", "pid", 'p', "PID");
|
||||||
args_parser.add_positional_argument(perfcore_file_arg, "Path of perfcore file", "perfcore-file", Core::ArgsParser::Required::No);
|
args_parser.add_positional_argument(perfcore_file_arg, "Path of perfcore file", "perfcore-file", Core::ArgsParser::Required::No);
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
if (pid && perfcore_file_arg) {
|
if (pid && perfcore_file_arg) {
|
||||||
warnln("-p/--pid option and perfcore-file argument must not be used together!");
|
warnln("-p/--pid option and perfcore-file argument must not be used together!");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto app = GUI::Application::construct(argc, argv);
|
auto app = TRY(GUI::Application::try_create(arguments));
|
||||||
auto app_icon = GUI::Icon::default_icon("app-profiler");
|
auto app_icon = GUI::Icon::default_icon("app-profiler");
|
||||||
|
|
||||||
String perfcore_file;
|
String perfcore_file;
|
||||||
|
@ -74,7 +76,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto& profile = profile_or_error.value();
|
auto& profile = profile_or_error.value();
|
||||||
|
|
||||||
auto window = GUI::Window::construct();
|
auto window = TRY(GUI::Window::try_create());
|
||||||
|
|
||||||
if (!Desktop::Launcher::add_allowed_handler_with_only_specific_urls(
|
if (!Desktop::Launcher::add_allowed_handler_with_only_specific_urls(
|
||||||
"/bin/Help",
|
"/bin/Help",
|
||||||
|
@ -92,12 +94,12 @@ int main(int argc, char** argv)
|
||||||
main_widget.set_fill_with_background_color(true);
|
main_widget.set_fill_with_background_color(true);
|
||||||
main_widget.set_layout<GUI::VerticalBoxLayout>();
|
main_widget.set_layout<GUI::VerticalBoxLayout>();
|
||||||
|
|
||||||
auto timeline_header_container = GUI::Widget::construct();
|
auto timeline_header_container = TRY(GUI::Widget::try_create());
|
||||||
timeline_header_container->set_layout<GUI::VerticalBoxLayout>();
|
timeline_header_container->set_layout<GUI::VerticalBoxLayout>();
|
||||||
timeline_header_container->set_fill_with_background_color(true);
|
timeline_header_container->set_fill_with_background_color(true);
|
||||||
timeline_header_container->set_shrink_to_fit(true);
|
timeline_header_container->set_shrink_to_fit(true);
|
||||||
|
|
||||||
auto timeline_view = TimelineView::construct(*profile);
|
auto timeline_view = TRY(TimelineView::try_create(*profile));
|
||||||
for (auto& process : profile->processes()) {
|
for (auto& process : profile->processes()) {
|
||||||
bool matching_event_found = false;
|
bool matching_event_found = false;
|
||||||
for (auto& event : profile->events()) {
|
for (auto& event : profile->events()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue