mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 02:03:06 -05:00
Debugger: Use Core::ArgsParser
This commit is contained in:
parent
773ed930cb
commit
bedce69b23
Notes:
sideshowbarker
2024-07-19 06:11:18 +09:00
Author: https://github.com/itamar8910 Commit: https://github.com/SerenityOS/serenity/commit/bedce69b234 Pull-request: https://github.com/SerenityOS/serenity/pull/2345 Reviewed-by: https://github.com/awesomekling
1 changed files with 9 additions and 16 deletions
|
@ -31,6 +31,7 @@
|
|||
#include <AK/StringBuilder.h>
|
||||
#include <AK/kmalloc.h>
|
||||
#include <LibC/sys/arch/i386/regs.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibDebug/DebugInfo.h>
|
||||
#include <LibDebug/DebugSession.h>
|
||||
|
@ -45,12 +46,6 @@
|
|||
|
||||
static Line::Editor editor {};
|
||||
|
||||
static int usage()
|
||||
{
|
||||
printf("usage: sdb [command...]\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
OwnPtr<DebugSession> g_debug_session;
|
||||
|
||||
static void handle_sigint(int)
|
||||
|
@ -183,18 +178,16 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (argc == 1)
|
||||
return usage();
|
||||
const char* command = nullptr;
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_positional_argument(command,
|
||||
"The program to be debugged, along with its arguments",
|
||||
"program", Core::ArgsParser::Required::Yes);
|
||||
args_parser.parse(argc, argv);
|
||||
|
||||
StringBuilder command;
|
||||
command.append(argv[1]);
|
||||
for (int i = 2; i < argc; ++i) {
|
||||
command.appendf("%s ", argv[i]);
|
||||
}
|
||||
|
||||
auto result = DebugSession::exec_and_attach(command.to_string());
|
||||
auto result = DebugSession::exec_and_attach(command);
|
||||
if (!result) {
|
||||
fprintf(stderr, "Failed to start debugging session for: \"%s\"\n", command.to_string().characters());
|
||||
fprintf(stderr, "Failed to start debugging session for: \"%s\"\n", command);
|
||||
exit(1);
|
||||
}
|
||||
g_debug_session = result.release_nonnull();
|
||||
|
|
Loading…
Add table
Reference in a new issue