1
1
/*
2
2
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
3
+ * Copyright (c) 2022, the SerenityOS developers.
3
4
*
4
5
* SPDX-License-Identifier: BSD-2-Clause
5
6
*/
9
10
#include < AK/OwnPtr.h>
10
11
#include < AK/Platform.h>
11
12
#include < AK/StringBuilder.h>
13
+ #include < AK/Try.h>
12
14
#include < LibC/sys/arch/i386/regs.h>
13
15
#include < LibCore/ArgsParser.h>
16
+ #include < LibCore/System.h>
14
17
#include < LibDebug/DebugInfo.h>
15
18
#include < LibDebug/DebugSession.h>
16
19
#include < LibLine/Editor.h>
20
+ #include < LibMain/Main.h>
17
21
#include < LibX86/Disassembler.h>
18
22
#include < LibX86/Instruction.h>
19
23
#include < signal.h>
@@ -204,21 +208,18 @@ static void print_help()
204
208
" x <address> - examine dword in memory\n " );
205
209
}
206
210
207
- int main ( int argc, char ** argv )
211
+ ErrorOr< int > serenity_main (Main::Arguments arguments )
208
212
{
209
213
editor = Line::Editor::construct ();
210
214
211
- if (pledge (" stdio proc ptrace exec rpath tty sigaction cpath unix" , nullptr ) < 0 ) {
212
- perror (" pledge" );
213
- return 1 ;
214
- }
215
+ TRY (Core::System::pledge (" stdio proc ptrace exec rpath tty sigaction cpath unix" , nullptr ));
215
216
216
217
const char * command = nullptr ;
217
218
Core::ArgsParser args_parser;
218
219
args_parser.add_positional_argument (command,
219
220
" The program to be debugged, along with its arguments" ,
220
221
" program" , Core::ArgsParser::Required::Yes);
221
- args_parser.parse (argc, argv );
222
+ args_parser.parse (arguments );
222
223
223
224
auto result = Debug::DebugSession::exec_and_attach (command);
224
225
if (!result) {
@@ -230,7 +231,7 @@ int main(int argc, char** argv)
230
231
struct sigaction sa {
231
232
};
232
233
sa.sa_handler = handle_sigint;
233
- sigaction (SIGINT, &sa, nullptr );
234
+ TRY ( Core::System:: sigaction (SIGINT, &sa, nullptr ) );
234
235
235
236
Debug::DebugInfo::SourcePosition previous_source_position;
236
237
bool in_step_line = false ;
@@ -331,4 +332,6 @@ int main(int argc, char** argv)
331
332
return decision.value ();
332
333
}
333
334
});
335
+
336
+ return 0 ;
334
337
}
0 commit comments