Skip to content

Commit

Permalink
Kernel: Add (expensive) but valuable userspace symbols to stacks.
Browse files Browse the repository at this point in the history
This is expensive because we have to page in the entire executable for every
process up front for this to work. This is due to the page fault code not
being strong enough to run while another process is active.

Note that we already had userspace symbols in *crash* stacks. This patch
adds them generally, so they show up in /proc, Process Manager, etc.

There's room for improvement here, but the debugging benefits way overshadow
the performance penalty right now. :^)
  • Loading branch information
awesomekling committed Jul 27, 2019
1 parent 7cd2e73 commit a79d8d8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions Kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ CXXFLAGS += -nostdlib -nostdinc -nostdinc++
CXXFLAGS += -I../Toolchain/Local/i686-pc-serenity/include/c++/8.3.0/
CXXFLAGS += -I../Toolchain/Local/i686-pc-serenity/include/c++/8.3.0/i686-pc-serenity/
DEFINES += -DKERNEL
DEFINES += -DEXPENSIVE_USERSPACE_STACKS
LDFLAGS += -Ttext 0x10000 -Wl,-T linker.ld -nostdlib

all: $(KERNEL) kernel.map
Expand Down
5 changes: 5 additions & 0 deletions Kernel/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,11 @@ int Process::do_exec(String path, Vector<String> arguments, Vector<String> envir
bool success = region->page_in();
ASSERT(success);
}

#ifdef EXPENSIVE_USERSPACE_STACKS
region->page_in();
#endif

OwnPtr<ELFLoader> loader;
{
// Okay, here comes the sleight of hand, pay close attention..
Expand Down
8 changes: 7 additions & 1 deletion Kernel/Thread.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <AK/ELF/ELFLoader.h>
#include <AK/StringBuilder.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/Process.h>
Expand Down Expand Up @@ -570,7 +571,12 @@ String Thread::backtrace(ProcessInspectionHandle&) const
if (!symbol.address)
break;
if (!symbol.ksym) {
builder.appendf("%p\n", symbol.address);
#ifdef EXPENSIVE_USERSPACE_STACKS
if (!Scheduler::is_active() && process.elf_loader() && process.elf_loader()->has_symbols())
builder.appendf("%p %s\n", symbol.address, process.elf_loader()->symbolicate(symbol.address).characters());
else
#endif
builder.appendf("%p\n", symbol.address);
continue;
}
unsigned offset = symbol.address - symbol.ksym->address;
Expand Down

0 comments on commit a79d8d8

Please sign in to comment.