Skip to content

Commit 32d4d40

Browse files
authored
Merge pull request #6669 from bulbazord/5.9-cherry-pick-exec-failure
[LLDB][5.9] Cherry-pick changes to fix TestExec.py
2 parents c997c7d + 71173d2 commit 32d4d40

File tree

9 files changed

+18
-21
lines changed

9 files changed

+18
-21
lines changed

lldb/include/lldb/Target/Memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class AllocatedMemoryCache {
118118

119119
~AllocatedMemoryCache();
120120

121-
void Clear();
121+
void Clear(bool deallocate_memory);
122122

123123
lldb::addr_t AllocateMemory(size_t byte_size, uint32_t permissions,
124124
Status &error);

lldb/source/Target/Memory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,9 @@ AllocatedMemoryCache::AllocatedMemoryCache(Process &process)
346346

347347
AllocatedMemoryCache::~AllocatedMemoryCache() = default;
348348

349-
void AllocatedMemoryCache::Clear() {
349+
void AllocatedMemoryCache::Clear(bool deallocate_memory) {
350350
std::lock_guard<std::recursive_mutex> guard(m_mutex);
351-
if (m_process.IsAlive()) {
351+
if (m_process.IsAlive() && deallocate_memory) {
352352
PermissionsToBlockMap::iterator pos, end = m_memory_map.end();
353353
for (pos = m_memory_map.begin(); pos != end; ++pos)
354354
m_process.DoDeallocateMemory(pos->second->GetBaseAddress());

lldb/source/Target/Process.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ void Process::Finalize() {
555555
m_notifications.swap(empty_notifications);
556556
m_image_tokens.clear();
557557
m_memory_cache.Clear();
558-
m_allocated_memory_cache.Clear();
558+
m_allocated_memory_cache.Clear(/*deallocate_memory=*/true);
559559
{
560560
std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
561561
m_language_runtimes.clear();
@@ -5838,7 +5838,9 @@ void Process::DidExec() {
58385838
m_dyld_up.reset();
58395839
m_jit_loaders_up.reset();
58405840
m_image_tokens.clear();
5841-
m_allocated_memory_cache.Clear();
5841+
// After an exec, the inferior is a new process and these memory regions are
5842+
// no longer allocated.
5843+
m_allocated_memory_cache.Clear(/*deallocte_memory=*/false);
58425844
{
58435845
std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
58445846
m_language_runtimes.clear();

lldb/source/Target/Target.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2543,10 +2543,8 @@ Target::GetScratchTypeSystems(bool create_on_demand) {
25432543
if (auto ts = *type_system_or_err)
25442544
scratch_type_systems.push_back(ts);
25452545
}
2546-
std::sort(scratch_type_systems.begin(), scratch_type_systems.end(),
2547-
[](lldb::TypeSystemSP a, lldb::TypeSystemSP b) {
2548-
return a.get() <= b.get();
2549-
});
2546+
2547+
std::sort(scratch_type_systems.begin(), scratch_type_systems.end());
25502548
scratch_type_systems.erase(
25512549
std::unique(scratch_type_systems.begin(), scratch_type_systems.end()),
25522550
scratch_type_systems.end());

lldb/test/Shell/Register/x86-64-write.test

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
# xfail with system debugserver until the fix for
2-
# https://reviews.llvm.org/D123269 in
3-
# lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
4-
# has made it into released tools.
5-
# XFAIL: system-debugserver
6-
71
# XFAIL: system-windows
82
# REQUIRES: native && target-x86_64
93
# RUN: %clangxx_host %p/Inputs/x86-64-write.cpp -o %t

lldb/test/Shell/Register/x86-64-ymm-write.test

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
# xfail with system debugserver until the fix for
2-
# https://reviews.llvm.org/D123269 in
3-
# lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
4-
# has made it into released tools.
5-
# XFAIL: system-debugserver
6-
71
# XFAIL: system-windows
82
# REQUIRES: native && target-x86_64 && native-cpu-avx
93
# RUN: %clangxx_host %p/Inputs/x86-ymm-write.cpp -o %t

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)