@@ -2448,44 +2448,43 @@ lldb::addr_t Target::GetPersistentSymbol(ConstString name) {
2448
2448
return address;
2449
2449
}
2450
2450
2451
- lldb_private::Address Target::GetEntryPointAddress (Status &err) {
2452
- err.Clear ();
2453
- Address entry_addr;
2451
+ llvm::Expected<lldb_private::Address> Target::GetEntryPointAddress () {
2454
2452
Module *exe_module = GetExecutableModulePointer ();
2453
+ llvm::Error error = llvm::Error::success ();
2454
+ assert (!error); // Check the success value when assertions are enabled.
2455
2455
2456
2456
if (!exe_module || !exe_module->GetObjectFile ()) {
2457
- err.SetErrorStringWithFormat (" No primary executable found" );
2457
+ error = llvm::make_error<llvm::StringError>(" No primary executable found" ,
2458
+ llvm::inconvertibleErrorCode ());
2458
2459
} else {
2459
- entry_addr = exe_module->GetObjectFile ()->GetEntryPointAddress ();
2460
- if (!entry_addr.IsValid ()) {
2461
- err.SetErrorStringWithFormat (
2462
- " Could not find entry point address for executable module \" %s\" ." ,
2463
- exe_module->GetFileSpec ().GetFilename ().AsCString ());
2464
- }
2460
+ Address entry_addr = exe_module->GetObjectFile ()->GetEntryPointAddress ();
2461
+ if (entry_addr.IsValid ())
2462
+ return entry_addr;
2463
+
2464
+ error = llvm::make_error<llvm::StringError>(
2465
+ " Could not find entry point address for executable module \" " +
2466
+ exe_module->GetFileSpec ().GetFilename ().GetStringRef () + " \" " ,
2467
+ llvm::inconvertibleErrorCode ());
2465
2468
}
2466
2469
2467
- if (!entry_addr.IsValid ()) {
2468
2470
const ModuleList &modules = GetImages ();
2469
2471
const size_t num_images = modules.GetSize ();
2470
2472
for (size_t idx = 0 ; idx < num_images; ++idx) {
2471
2473
ModuleSP module_sp (modules.GetModuleAtIndex (idx));
2472
- if (module_sp && module_sp->GetObjectFile ()) {
2473
- entry_addr = module_sp->GetObjectFile ()->GetEntryPointAddress ();
2474
- if (entry_addr.IsValid ()) {
2475
- // Clear out any old error messages from the original
2476
- // main-executable-binary search; one of the other modules
2477
- // was able to provide an address.
2478
- err.Clear ();
2479
- break ;
2480
- }
2481
- }
2474
+ if (!module_sp || !module_sp->GetObjectFile ())
2475
+ continue ;
2476
+
2477
+ Address entry_addr = module_sp->GetObjectFile ()->GetEntryPointAddress ();
2478
+ if (entry_addr.IsValid ()) {
2479
+ // Discard the error.
2480
+ llvm::consumeError (std::move (error));
2481
+ return entry_addr;
2482
2482
}
2483
2483
}
2484
2484
2485
- return entry_addr ;
2485
+ return std::move (error) ;
2486
2486
}
2487
2487
2488
-
2489
2488
lldb::addr_t Target::GetCallableLoadAddress (lldb::addr_t load_addr,
2490
2489
AddressClass addr_class) const {
2491
2490
auto arch_plugin = GetArchitecturePlugin ();
0 commit comments