mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:37:45 +00:00
Strace: Add formatting for misc syscalls
These are exit, realpath and getrandom. This required a bit of extra infrastructure to deal with exit's void return type.
This commit is contained in:
parent
8125edfe79
commit
96a67d24e9
1 changed files with 42 additions and 1 deletions
|
@ -275,6 +275,11 @@ public:
|
||||||
m_builder.appendff(") = {}\n", res);
|
m_builder.appendff(") = {}\n", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void format_result()
|
||||||
|
{
|
||||||
|
m_builder.append(")\n");
|
||||||
|
}
|
||||||
|
|
||||||
StringView string_view()
|
StringView string_view()
|
||||||
{
|
{
|
||||||
return m_builder.string_view();
|
return m_builder.string_view();
|
||||||
|
@ -293,6 +298,28 @@ private:
|
||||||
bool m_first_arg { true };
|
bool m_first_arg { true };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void format_getrandom(FormattedSyscallBuilder& builder, void* buffer, size_t size, unsigned flags)
|
||||||
|
{
|
||||||
|
builder.add_arguments(buffer, size, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void format_realpath(FormattedSyscallBuilder& builder, Syscall::SC_realpath_params* params_p)
|
||||||
|
{
|
||||||
|
auto params = copy_from_process(params_p);
|
||||||
|
builder.add_string_argument(params.path);
|
||||||
|
if (params.buffer.size == 0)
|
||||||
|
builder.add_argument("null");
|
||||||
|
else {
|
||||||
|
auto buffer = copy_from_process(params.buffer.data, params.buffer.size);
|
||||||
|
builder.add_argument("\"{}\"", StringView { (const char*)buffer.data() });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void format_exit(FormattedSyscallBuilder& builder, int status)
|
||||||
|
{
|
||||||
|
builder.add_argument(status);
|
||||||
|
}
|
||||||
|
|
||||||
static void format_open(FormattedSyscallBuilder& builder, Syscall::SC_open_params* params_p)
|
static void format_open(FormattedSyscallBuilder& builder, Syscall::SC_open_params* params_p)
|
||||||
{
|
{
|
||||||
auto params = copy_from_process(params_p);
|
auto params = copy_from_process(params_p);
|
||||||
|
@ -537,11 +564,22 @@ static void format_syscall(FormattedSyscallBuilder& builder, Syscall::Function s
|
||||||
enum ResultType {
|
enum ResultType {
|
||||||
Int,
|
Int,
|
||||||
Ssize,
|
Ssize,
|
||||||
VoidP
|
VoidP,
|
||||||
|
Void
|
||||||
};
|
};
|
||||||
|
|
||||||
ResultType result_type { Int };
|
ResultType result_type { Int };
|
||||||
switch (syscall_function) {
|
switch (syscall_function) {
|
||||||
|
case SC_getrandom:
|
||||||
|
format_getrandom(builder, (void*)arg1, (size_t)arg2, (unsigned)arg3);
|
||||||
|
break;
|
||||||
|
case SC_realpath:
|
||||||
|
format_realpath(builder, (Syscall::SC_realpath_params*)arg1);
|
||||||
|
break;
|
||||||
|
case SC_exit:
|
||||||
|
format_exit(builder, (int)arg1);
|
||||||
|
result_type = Void;
|
||||||
|
break;
|
||||||
case SC_open:
|
case SC_open:
|
||||||
format_open(builder, (Syscall::SC_open_params*)arg1);
|
format_open(builder, (Syscall::SC_open_params*)arg1);
|
||||||
break;
|
break;
|
||||||
|
@ -607,6 +645,9 @@ static void format_syscall(FormattedSyscallBuilder& builder, Syscall::Function s
|
||||||
case VoidP:
|
case VoidP:
|
||||||
builder.format_result((void*)res);
|
builder.format_result((void*)res);
|
||||||
break;
|
break;
|
||||||
|
case Void:
|
||||||
|
builder.format_result();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue