Skip to content

Commit a600bda

Browse files
committed
[debugserver] Clear memory allocations after exec
After an exec, the inferior is a new process and none of these memory regions are still allocated. Clear them out. Differential Revision: https://reviews.llvm.org/D140253 (cherry picked from commit 58def62)
1 parent c667a0a commit a600bda

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,6 +2285,7 @@ static bool mach_header_validity_test(uint32_t magic, uint32_t cputype) {
22852285
m_thread_list.Clear();
22862286
m_activities.Clear();
22872287
m_breakpoints.DisableAll();
2288+
m_task.ClearAllocations();
22882289
}
22892290

22902291
if (m_sent_interrupt_signo != 0) {

lldb/tools/debugserver/source/MacOSX/MachTask.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class MachTask {
6161

6262
nub_addr_t AllocateMemory(nub_size_t size, uint32_t permissions);
6363
nub_bool_t DeallocateMemory(nub_addr_t addr);
64+
void ClearAllocations();
6465

6566
mach_port_t ExceptionPort() const;
6667
bool ExceptionPortIsValid() const;

lldb/tools/debugserver/source/MacOSX/MachTask.mm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,13 @@ static void get_threads_profile_data(DNBProfileDataScanType scanType,
999999
return false;
10001000
}
10011001

1002+
//----------------------------------------------------------------------
1003+
// MachTask::ClearAllocations
1004+
//----------------------------------------------------------------------
1005+
void MachTask::ClearAllocations() {
1006+
m_allocations.clear();
1007+
}
1008+
10021009
void MachTask::TaskPortChanged(task_t task)
10031010
{
10041011
m_task = task;

0 commit comments

Comments
 (0)