1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:18:12 +00:00

Kernel: Use KBufferBuilder to build ProcFS files and backtraces

This is not perfect as it uses a lot of VM, but since the buffers are
supposed to be temporary it's not super terrible.

This could be improved by giving back the unused VM to the kernel's
RangeAllocator after finishing the buffer building.
This commit is contained in:
Andreas Kling 2019-08-07 21:52:43 +02:00
parent f6998b1817
commit 37ba2a7b65
3 changed files with 38 additions and 36 deletions

View file

@ -15,6 +15,7 @@
#include <Kernel/FileSystem/SharedMemory.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <Kernel/IO.h>
#include <Kernel/KBufferBuilder.h>
#include <Kernel/KSyms.h>
#include <Kernel/Multiboot.h>
#include <Kernel/Net/Socket.h>
@ -2838,15 +2839,15 @@ int Process::sys$dbgputstr(const u8* characters, int length)
return 0;
}
String Process::backtrace(ProcessInspectionHandle& handle) const
KBuffer Process::backtrace(ProcessInspectionHandle& handle) const
{
StringBuilder builder;
KBufferBuilder builder;
for_each_thread([&](Thread& thread) {
builder.appendf("Thread %d:\n", thread.tid());
builder.append(thread.backtrace(handle));
return IterationDecision::Continue;
});
return builder.to_string();
return builder.build();
}
int Process::sys$set_process_icon(int icon_id)