Replace MemoryRegionInfoSP with values and cleanup related code

Differential Revision: https://reviews.llvm.org/D55472

llvm-svn: 349766
This commit is contained in:
Tatyana Krasnukha
2018-12-20 15:02:58 +00:00
parent b208255fe0
commit 36788bbb32
8 changed files with 61 additions and 48 deletions

View File

@@ -1358,18 +1358,14 @@ SBProcess::GetMemoryRegionInfo(lldb::addr_t load_addr,
SBMemoryRegionInfo &sb_region_info) {
lldb::SBError sb_error;
ProcessSP process_sp(GetSP());
MemoryRegionInfoSP region_info_sp =
std::make_shared<lldb_private::MemoryRegionInfo>();
if (process_sp) {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process_sp->GetRunLock())) {
std::lock_guard<std::recursive_mutex> guard(
process_sp->GetTarget().GetAPIMutex());
sb_error.ref() =
process_sp->GetMemoryRegionInfo(load_addr, *region_info_sp);
if (sb_error.Success()) {
sb_region_info.ref() = *region_info_sp;
}
process_sp->GetMemoryRegionInfo(load_addr, sb_region_info.ref());
} else {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (log)
@@ -1385,35 +1381,23 @@ SBProcess::GetMemoryRegionInfo(lldb::addr_t load_addr,
}
lldb::SBMemoryRegionInfoList SBProcess::GetMemoryRegions() {
lldb::SBError sb_error;
lldb::SBMemoryRegionInfoList sb_region_list;
ProcessSP process_sp(GetSP());
if (process_sp) {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process_sp->GetRunLock())) {
std::lock_guard<std::recursive_mutex> guard(
process_sp->GetTarget().GetAPIMutex());
std::vector<MemoryRegionInfoSP> region_list;
sb_error.ref() = process_sp->GetMemoryRegions(region_list);
if (sb_error.Success()) {
std::vector<MemoryRegionInfoSP>::iterator end = region_list.end();
for (std::vector<MemoryRegionInfoSP>::iterator it = region_list.begin();
it != end; it++) {
SBMemoryRegionInfo sb_region_info(it->get());
sb_region_list.Append(sb_region_info);
}
}
} else {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (log)
log->Printf(
"SBProcess(%p)::GetMemoryRegionInfo() => error: process is running",
static_cast<void *>(process_sp.get()));
sb_error.SetErrorString("process is running");
}
Process::StopLocker stop_locker;
if (process_sp && stop_locker.TryLock(&process_sp->GetRunLock())) {
std::lock_guard<std::recursive_mutex> guard(
process_sp->GetTarget().GetAPIMutex());
process_sp->GetMemoryRegions(sb_region_list.ref());
} else {
sb_error.SetErrorString("SBProcess is invalid");
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (log)
log->Printf(
"SBProcess(%p)::GetMemoryRegionInfo() => error: process is running",
static_cast<void *>(process_sp.get()));
}
return sb_region_list;
}