summaryrefslogtreecommitdiff
path: root/Applications/Debugger/main.cpp
diff options
context:
space:
mode:
authorItamar <itamar8910@gmail.com>2020-05-23 22:10:26 +0300
committerAndreas Kling <kling@serenityos.org>2020-05-24 10:42:21 +0200
commitbedce69b2341bda4d4faef2fe20ca18bd3c9131b (patch)
tree4155da52e92f3e95bf7bd9b96d1fb37b73cf4c7a /Applications/Debugger/main.cpp
parent773ed930cbb0947ae6ec1236dcfb702f1d4fd755 (diff)
downloadserenity-bedce69b2341bda4d4faef2fe20ca18bd3c9131b.zip
Debugger: Use Core::ArgsParser
Diffstat (limited to 'Applications/Debugger/main.cpp')
-rw-r--r--Applications/Debugger/main.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/Applications/Debugger/main.cpp b/Applications/Debugger/main.cpp
index 893126d6e2..ded418d17a 100644
--- a/Applications/Debugger/main.cpp
+++ b/Applications/Debugger/main.cpp
@@ -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();
-
- StringBuilder command;
- command.append(argv[1]);
- for (int i = 2; i < argc; ++i) {
- command.appendf("%s ", argv[i]);
- }
+ 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);
- 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();