Skip to content

Commit fedda0c

Browse files
committed
Refactor task OS-name setting
Task::copy_state sets the OS name of a task in the same fashion that persistent checkpointing sets name. Refactored this functionality into Task::set_name. Also removed the unnecessary `update_prname` from Task::copy_state. update_prname is not a "write to tracee"-operation but a "read from tracee"-operation; and since we already know what name we want to set Task::prname to, we skip this reading from the tracee in Task::copy_state and just set it to the parameter passed in to Task::set_name
1 parent 6c803d4 commit fedda0c

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/ReplaySession.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,11 +2209,11 @@ void ReplaySession::load_checkpoint(
22092209
Task* child = Task::os_clone(Task::SESSION_CLONE_LEADER, this, remote,
22102210
taskInfo.getRecTid(), taskInfo.getSerial(),
22112211
SIGCHLD, nullptr);
2212-
cloned_leaders.push_back((ReplayTask*)child);
2212+
cloned_leaders.push_back(static_cast<ReplayTask*>(child));
22132213
}
22142214

22152215
auto clone_leader_index = 0;
2216-
2216+
LOG(debug) << "Restoring " << addr_spaces.size() << " clone leaders";
22172217
for (const auto& as : addr_spaces) {
22182218
ReplayTask* leader = cloned_leaders[clone_leader_index++];
22192219
const auto proc_space = as.getProcessSpace();
@@ -2324,9 +2324,7 @@ void ReplaySession::load_checkpoint(
23242324
auto index = original_exe_name.rfind('/');
23252325
auto name = "rr:" + original_exe_name.substr(
23262326
index == std::string::npos ? 0 : index + 1);
2327-
AutoRestoreMem mem(remote, name.c_str());
2328-
remote.infallible_syscall(syscall_number_for_prctl(leader->arch()),
2329-
PR_SET_NAME, mem.get());
2327+
leader->set_name(remote, name);
23302328
}
23312329

23322330
ASSERT(leader, scratch_mem != nullptr)

src/Task.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,10 @@ class Task {
460460
*/
461461
virtual std::string name() const;
462462

463+
/**
464+
* Sets the OS-name of this task by injecting system call for PR_SET_NAME.
465+
* Also updates |prname| to |name|.
466+
*/
463467
virtual void set_name(AutoRemoteSyscalls& remote, const std::string& name);
464468

465469
/**

0 commit comments

Comments
 (0)