summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2021-11-24 19:52:34 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-24 22:56:39 +0100
commit2dd5c7d2cc3e5788eb7194a969520f18c6d13e4b (patch)
tree1c5ef33b7ed361fec4a5b8c9faeaadf6d9a1e2e8 /Userland/Utilities
parent33079c8ab91fdd63a07f0da8d598ce5bbbab787f (diff)
downloadserenity-2dd5c7d2cc3e5788eb7194a969520f18c6d13e4b.zip
strace: Implement dbgputstr syscall
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/strace.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/Userland/Utilities/strace.cpp b/Userland/Utilities/strace.cpp
index 8b300af937..7a48d44dbd 100644
--- a/Userland/Utilities/strace.cpp
+++ b/Userland/Utilities/strace.cpp
@@ -355,13 +355,16 @@ public:
add_argument("{}", forward<T>(arg));
}
- void add_string_argument(Syscall::StringArgument const& string_argument)
+ void add_string_argument(Syscall::StringArgument const& string_argument, StringView trim_by = {})
{
if (string_argument.characters == nullptr)
add_argument("null");
else {
- auto string = copy_from_process(string_argument.characters, string_argument.length);
- add_argument("\"{}\"", StringView(string.data(), string.size()));
+ auto string_buffer = copy_from_process(string_argument.characters, string_argument.length);
+ auto view = StringView(string_buffer);
+ if (!trim_by.is_empty())
+ view = view.trim(trim_by);
+ add_argument("\"{}\"", view);
}
}
@@ -659,6 +662,11 @@ static void format_clock_gettime(FormattedSyscallBuilder& builder, clockid_t clo
builder.add_arguments(clockid_name(clockid), copy_from_process(time));
}
+static void format_dbgputstr(FormattedSyscallBuilder& builder, char* characters, size_t size)
+{
+ builder.add_string_argument({ characters, size }, "\0\n"sv);
+}
+
static void format_syscall(FormattedSyscallBuilder& builder, Syscall::Function syscall_function, syscall_arg_t arg1, syscall_arg_t arg2, syscall_arg_t arg3, syscall_arg_t res)
{
enum ResultType {
@@ -736,6 +744,9 @@ static void format_syscall(FormattedSyscallBuilder& builder, Syscall::Function s
case SC_clock_gettime:
format_clock_gettime(builder, (clockid_t)arg1, (struct timespec*)arg2);
break;
+ case SC_dbgputstr:
+ format_dbgputstr(builder, (char*)arg1, (size_t)arg2);
+ break;
case SC_getuid:
case SC_geteuid:
case SC_getgid: