Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Process naming support
  • Loading branch information
djphoenix committed May 26, 2019
1 parent 77780aa commit 08a1f64
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/process/include/process.hpp
Expand Up @@ -31,6 +31,7 @@ class Process {
uintptr_t _aslrCode, _aslrStack, _syscallPage;
size_t _syscallNum;
void *iomap[2];
char *name;

public:
Process();
Expand All @@ -54,6 +55,9 @@ class Process {
void readData(void* dst, uintptr_t address, size_t size) const;
char* readString(uintptr_t address) const;

const char *getName() const;
void setName(const char *name);

void* getPhysicalAddress(uintptr_t ptr) const PURE;

static void print_stacktrace(uintptr_t base = 0, const Process *process = nullptr);
Expand Down
1 change: 1 addition & 0 deletions src/process/modules.cpp
Expand Up @@ -137,6 +137,7 @@ void ModuleManager::loadStream(Stream *stream) {
delete process;
break;
}
process->setName(mod.name);
if (bindRequirements(mod.requirements, process)) {
process->startup();
} else {
Expand Down
8 changes: 8 additions & 0 deletions src/process/process.cpp
Expand Up @@ -14,6 +14,7 @@ Process::Process() :
_aslrCode(RAND::get<uintptr_t>(0x80000000llu, 0x100000000llu) << 12),
_aslrStack(RAND::get<uintptr_t>(0x40000000llu, 0x80000000llu) << 12),
_syscallPage(0), _syscallNum(0),
name(nullptr),
pagetable(nullptr) {
iomap[0] = iomap[1] = nullptr;
}
Expand Down Expand Up @@ -64,6 +65,7 @@ Process::~Process() {
ProcessManager::getManager()->dequeueThread(threads[i]);
delete threads[i];
}
delete name;
}

PTE* Process::addPage(uintptr_t vaddr, void* paddr, uint8_t flags) {
Expand Down Expand Up @@ -339,6 +341,12 @@ void Process::exit(int code) {
delete this;
}

const char *Process::getName() const { return name; }
void Process::setName(const char *newname) {
delete name;
name = newname ? klib::strdup(newname) : nullptr;
}

void Process::print_stacktrace(uintptr_t base, const Process *process) {
struct stackframe {
struct stackframe* rbp;
Expand Down

0 comments on commit 08a1f64

Please sign in to comment.