Deleted Added
full compact
Target.cpp (360784) Target.cpp (367228)
1//===-- Target.cpp ----------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8

--- 2398 unchanged lines hidden (view full) ---

2407 }
2408 return true; // Keep iterating the ForEach
2409 });
2410 return address;
2411}
2412
2413llvm::Expected<lldb_private::Address> Target::GetEntryPointAddress() {
2414 Module *exe_module = GetExecutableModulePointer();
1//===-- Target.cpp ----------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8

--- 2398 unchanged lines hidden (view full) ---

2407 }
2408 return true; // Keep iterating the ForEach
2409 });
2410 return address;
2411}
2412
2413llvm::Expected<lldb_private::Address> Target::GetEntryPointAddress() {
2414 Module *exe_module = GetExecutableModulePointer();
2415 llvm::Error error = llvm::Error::success();
2416 assert(!error); // Check the success value when assertions are enabled.
2417
2415
2418 if (!exe_module || !exe_module->GetObjectFile()) {
2419 error = llvm::make_error<llvm::StringError>("No primary executable found",
2420 llvm::inconvertibleErrorCode());
2421 } else {
2416 // Try to find the entry point address in the primary executable.
2417 const bool has_primary_executable = exe_module && exe_module->GetObjectFile();
2418 if (has_primary_executable) {
2422 Address entry_addr = exe_module->GetObjectFile()->GetEntryPointAddress();
2423 if (entry_addr.IsValid())
2424 return entry_addr;
2419 Address entry_addr = exe_module->GetObjectFile()->GetEntryPointAddress();
2420 if (entry_addr.IsValid())
2421 return entry_addr;
2425
2426 error = llvm::make_error<llvm::StringError>(
2427 "Could not find entry point address for executable module \"" +
2428 exe_module->GetFileSpec().GetFilename().GetStringRef() + "\"",
2429 llvm::inconvertibleErrorCode());
2430 }
2431
2432 const ModuleList &modules = GetImages();
2433 const size_t num_images = modules.GetSize();
2434 for (size_t idx = 0; idx < num_images; ++idx) {
2435 ModuleSP module_sp(modules.GetModuleAtIndex(idx));
2436 if (!module_sp || !module_sp->GetObjectFile())
2437 continue;
2438
2439 Address entry_addr = module_sp->GetObjectFile()->GetEntryPointAddress();
2422 }
2423
2424 const ModuleList &modules = GetImages();
2425 const size_t num_images = modules.GetSize();
2426 for (size_t idx = 0; idx < num_images; ++idx) {
2427 ModuleSP module_sp(modules.GetModuleAtIndex(idx));
2428 if (!module_sp || !module_sp->GetObjectFile())
2429 continue;
2430
2431 Address entry_addr = module_sp->GetObjectFile()->GetEntryPointAddress();
2440 if (entry_addr.IsValid()) {
2441 // Discard the error.
2442 llvm::consumeError(std::move(error));
2432 if (entry_addr.IsValid())
2443 return entry_addr;
2433 return entry_addr;
2444 }
2445 }
2446
2434 }
2435
2447 return std::move(error);
2436 // We haven't found the entry point address. Return an appropriate error.
2437 if (!has_primary_executable)
2438 return llvm::make_error<llvm::StringError>(
2439 "No primary executable found and could not find entry point address in "
2440 "any executable module",
2441 llvm::inconvertibleErrorCode());
2442
2443 return llvm::make_error<llvm::StringError>(
2444 "Could not find entry point address for primary executable module \"" +
2445 exe_module->GetFileSpec().GetFilename().GetStringRef() + "\"",
2446 llvm::inconvertibleErrorCode());
2448}
2449
2450lldb::addr_t Target::GetCallableLoadAddress(lldb::addr_t load_addr,
2451 AddressClass addr_class) const {
2452 auto arch_plugin = GetArchitecturePlugin();
2453 return arch_plugin
2454 ? arch_plugin->GetCallableLoadAddress(load_addr, addr_class)
2455 : load_addr;

--- 1626 unchanged lines hidden ---
2447}
2448
2449lldb::addr_t Target::GetCallableLoadAddress(lldb::addr_t load_addr,
2450 AddressClass addr_class) const {
2451 auto arch_plugin = GetArchitecturePlugin();
2452 return arch_plugin
2453 ? arch_plugin->GetCallableLoadAddress(load_addr, addr_class)
2454 : load_addr;

--- 1626 unchanged lines hidden ---