mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:37:34 +00:00
strace: Port to Core::Stream
This commit is contained in:
parent
4c3d2267db
commit
722879e2b9
1 changed files with 7 additions and 10 deletions
|
@ -12,7 +12,7 @@
|
|||
#include <Kernel/API/SyscallString.h>
|
||||
#include <LibC/sys/arch/i386/regs.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <errno.h>
|
||||
|
@ -239,7 +239,7 @@ static ErrorOr<ByteBuffer> copy_from_process(void const* source, size_t length)
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
static ErrorOr<T> copy_from_process(const T* source)
|
||||
static ErrorOr<T> copy_from_process(T const* source)
|
||||
{
|
||||
T value {};
|
||||
TRY(copy_from_process(source, Bytes { &value, sizeof(T) }));
|
||||
|
@ -812,12 +812,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
Vector<StringView> child_argv;
|
||||
|
||||
char const* output_filename = nullptr;
|
||||
StringView output_filename;
|
||||
char const* exclude_syscalls_option = nullptr;
|
||||
char const* include_syscalls_option = nullptr;
|
||||
HashTable<StringView> exclude_syscalls;
|
||||
HashTable<StringView> include_syscalls;
|
||||
auto trace_file = Core::File::standard_error();
|
||||
|
||||
Core::ArgsParser parser;
|
||||
parser.set_stop_on_first_non_option(true);
|
||||
|
@ -831,8 +830,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
parser.parse(arguments);
|
||||
|
||||
if (output_filename != nullptr)
|
||||
trace_file = TRY(Core::File::open(output_filename, Core::OpenMode::WriteOnly));
|
||||
auto trace_file = output_filename.is_empty()
|
||||
? TRY(Core::Stream::File::standard_error())
|
||||
: TRY(Core::Stream::File::open(output_filename, Core::Stream::OpenMode::Write));
|
||||
|
||||
auto parse_syscalls = [](char const* option, auto& hash_table) {
|
||||
if (option != nullptr) {
|
||||
|
@ -933,9 +933,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
FormattedSyscallBuilder builder(syscall_name);
|
||||
format_syscall(builder, syscall_function, arg1, arg2, arg3, res);
|
||||
|
||||
if (!trace_file->write(builder.string_view())) {
|
||||
warnln("write: {}", trace_file->error_string());
|
||||
return 1;
|
||||
}
|
||||
TRY(trace_file->write(builder.string_view().bytes()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue