mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-28 23:39:02 +00:00
Free physical pages allocated for a process's page directory on exit.
Also use a ProcessPagingScope instead of region aliasing to implement create-process ELF loading.
This commit is contained in:
parent
c70afd045e
commit
90ddbca127
Notes:
sideshowbarker
2024-07-19 18:34:37 +09:00
Author: https://github.com/awesomekling
Commit: 90ddbca127
8 changed files with 113 additions and 55 deletions
|
@ -49,13 +49,20 @@ static byte parseHexDigit(char nibble)
|
|||
return 10 + (nibble - 'a');
|
||||
}
|
||||
|
||||
#ifdef KSYMS
|
||||
static Vector<KSym, KmallocEternalAllocator>* s_ksyms;
|
||||
static bool s_ksyms_ready;
|
||||
|
||||
Vector<KSym, KmallocEternalAllocator>& ksyms()
|
||||
{
|
||||
return *s_ksyms;
|
||||
}
|
||||
|
||||
volatile bool ksyms_ready()
|
||||
{
|
||||
return s_ksyms_ready;
|
||||
}
|
||||
|
||||
const KSym* ksymbolicate(dword address)
|
||||
{
|
||||
if (address < ksyms().first().address || address > ksyms().last().address)
|
||||
|
@ -90,8 +97,38 @@ static void loadKsyms(const ByteBuffer& buffer)
|
|||
ksyms().append({ address, String(startOfName, bufptr - startOfName) });
|
||||
++bufptr;
|
||||
}
|
||||
s_ksyms_ready = true;
|
||||
}
|
||||
|
||||
void dump_backtrace()
|
||||
{
|
||||
if (!current)
|
||||
return;
|
||||
extern volatile bool ksyms_ready();
|
||||
if (!ksyms_ready())
|
||||
return;
|
||||
dword stack_variable;
|
||||
struct RecognizedSymbol {
|
||||
dword address;
|
||||
const KSym* ksym;
|
||||
};
|
||||
Vector<RecognizedSymbol> recognizedSymbols;
|
||||
for (dword* stackPtr = &stack_variable; current->isValidAddressForKernel(LinearAddress((dword)stackPtr)); stackPtr = (dword*)*stackPtr) {
|
||||
dword retaddr = stackPtr[1];
|
||||
if (auto* ksym = ksymbolicate(retaddr))
|
||||
recognizedSymbols.append({ retaddr, ksym });
|
||||
}
|
||||
size_t bytesNeeded = 0;
|
||||
for (auto& symbol : recognizedSymbols) {
|
||||
bytesNeeded += symbol.ksym->name.length() + 8 + 16;
|
||||
}
|
||||
for (auto& symbol : recognizedSymbols) {
|
||||
unsigned offset = symbol.address - symbol.ksym->address;
|
||||
dbgprintf("%p %s +%u\n", symbol.address, symbol.ksym->name.characters(), offset);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void undertaker_main() NORETURN;
|
||||
static void undertaker_main()
|
||||
{
|
||||
|
@ -109,8 +146,8 @@ static void spawn_stress()
|
|||
for (unsigned i = 0; i < 10000; ++i) {
|
||||
int error;
|
||||
Process::createUserProcess("/bin/id", (uid_t)100, (gid_t)100, (pid_t)0, error, nullptr, tty0);
|
||||
kprintf("malloc stats: alloc:%u free:%u page_aligned:%u eternal:%u\n", sum_alloc, sum_free, kmalloc_page_aligned, kmalloc_sum_eternal);
|
||||
kprintf("delta:%u\n", sum_alloc - lastAlloc);
|
||||
// kprintf("malloc stats: alloc:%u free:%u page_aligned:%u eternal:%u\n", sum_alloc, sum_free, kmalloc_page_aligned, kmalloc_sum_eternal);
|
||||
// kprintf("delta:%u\n", sum_alloc - lastAlloc);
|
||||
lastAlloc = sum_alloc;
|
||||
sleep(60);
|
||||
}
|
||||
|
@ -223,6 +260,11 @@ void init()
|
|||
{
|
||||
cli();
|
||||
|
||||
#ifdef KSYMS
|
||||
s_ksyms = nullptr;
|
||||
s_ksyms_ready = false;
|
||||
#endif
|
||||
|
||||
kmalloc_init();
|
||||
vga_init();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue