[process] Update architecture upon exec

This commit is contained in:
Ariel Abreu 2023-03-14 11:19:17 -04:00
parent 0a58b40d68
commit b4e67c25a0
No known key found for this signature in database
GPG Key ID: 5B88AAAF4280706F
2 changed files with 14 additions and 1 deletions

View File

@ -56,6 +56,16 @@ namespace DarlingServer {
ARM64 = dserver_rpc_architecture_arm64,
};
static constexpr const char* architectureToString(Architecture architecture) {
switch (architecture) {
case Architecture::i386: return "i386";
case Architecture::x86_64: return "x86_64";
case Architecture::ARM32: return "ARM32";
case Architecture::ARM64: return "ARM64";
default: return "Unknown";
}
}
struct MemoryInfo {
uint64_t virtualSize;
uint64_t residentSize;

View File

@ -275,7 +275,7 @@ void DarlingServer::Process::notifyCheckin(Architecture architecture) {
if (didExec) {
// exec case
processLog.info() << *this << ": replacing process with a new task" << processLog.endLog;
processLog.info() << *this << ": replacing process with a new task (with architecture \"" << architectureToString(architecture) << "\")" << processLog.endLog;
// clear all threads except the main thread
std::shared_ptr<Thread> mainThread = nullptr;
@ -299,6 +299,9 @@ void DarlingServer::Process::notifyCheckin(Architecture architecture) {
}
_threads[mainThread->nsid()] = mainThread;
// update the process architecture
_architecture = architecture;
// replace the old task with a new task that inherits from it
auto oldTask = _dtapeTask;
auto newTask = dtape_task_create(oldTask, _nspid, this, static_cast<dserver_rpc_architecture_t>(_architecture));