diff options
Diffstat (limited to 'source/Target/Memory.cpp')
-rw-r--r-- | source/Target/Memory.cpp | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/source/Target/Memory.cpp b/source/Target/Memory.cpp index 190c5057e881..31a378069cec 100644 --- a/source/Target/Memory.cpp +++ b/source/Target/Memory.cpp @@ -1,34 +1,31 @@ //===-- Memory.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/Target/Memory.h" -#include <inttypes.h> -#include "lldb/Core/RangeMap.h" #include "lldb/Target/Process.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RangeMap.h" #include "lldb/Utility/State.h" +#include <cinttypes> +#include <memory> + using namespace lldb; using namespace lldb_private; -//---------------------------------------------------------------------- // MemoryCache constructor -//---------------------------------------------------------------------- MemoryCache::MemoryCache(Process &process) : m_mutex(), m_L1_cache(), m_L2_cache(), m_invalid_ranges(), m_process(process), m_L2_cache_line_byte_size(process.GetMemoryCacheLineSize()) {} -//---------------------------------------------------------------------- // Destructor -//---------------------------------------------------------------------- MemoryCache::~MemoryCache() {} void MemoryCache::Clear(bool clear_invalid_ranges) { @@ -145,7 +142,7 @@ size_t MemoryCache::Read(addr_t addr, void *dst, size_t dst_len, } AddrRange chunk_range(pos->first, pos->second->GetByteSize()); if (chunk_range.Contains(read_range)) { - memcpy(dst, pos->second->GetBytes() + addr - chunk_range.GetRangeBase(), + memcpy(dst, pos->second->GetBytes() + (addr - chunk_range.GetRangeBase()), dst_len); return dst_len; } @@ -227,17 +224,17 @@ size_t MemoryCache::Read(addr_t addr, void *dst, size_t dst_len, if (bytes_left > 0) { assert((curr_addr % cache_line_byte_size) == 0); - std::unique_ptr<DataBufferHeap> data_buffer_heap_ap( + std::unique_ptr<DataBufferHeap> data_buffer_heap_up( new DataBufferHeap(cache_line_byte_size, 0)); size_t process_bytes_read = m_process.ReadMemoryFromInferior( - curr_addr, data_buffer_heap_ap->GetBytes(), - data_buffer_heap_ap->GetByteSize(), error); + curr_addr, data_buffer_heap_up->GetBytes(), + data_buffer_heap_up->GetByteSize(), error); if (process_bytes_read == 0) return dst_len - bytes_left; if (process_bytes_read != cache_line_byte_size) - data_buffer_heap_ap->SetByteSize(process_bytes_read); - m_L2_cache[curr_addr] = DataBufferSP(data_buffer_heap_ap.release()); + data_buffer_heap_up->SetByteSize(process_bytes_read); + m_L2_cache[curr_addr] = DataBufferSP(data_buffer_heap_up.release()); // We have read data and put it into the cache, continue through the // loop again to get the data out of the cache... } @@ -358,8 +355,8 @@ AllocatedMemoryCache::AllocatePage(uint32_t byte_size, uint32_t permissions, } if (addr != LLDB_INVALID_ADDRESS) { - block_sp.reset( - new AllocatedBlock(addr, page_byte_size, permissions, chunk_size)); + block_sp = std::make_shared<AllocatedBlock>(addr, page_byte_size, + permissions, chunk_size); m_memory_map.insert(std::make_pair(permissions, block_sp)); } return block_sp; |