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