1 //===-- DynamicLoaderPOSIX.h ------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // C Includes 11 // C++ Includes 12 // Other libraries and framework includes 13 #include "lldb/Core/PluginManager.h" 14 #include "lldb/Core/Log.h" 15 #include "lldb/Core/Module.h" 16 #include "lldb/Core/ModuleSpec.h" 17 #include "lldb/Core/Section.h" 18 #include "lldb/Symbol/ObjectFile.h" 19 #include "lldb/Target/Process.h" 20 #include "lldb/Target/Target.h" 21 #include "lldb/Target/Thread.h" 22 #include "lldb/Target/ThreadPlanRunToAddress.h" 23 #include "lldb/Breakpoint/BreakpointLocation.h" 24 25 #include "AuxVector.h" 26 #include "DynamicLoaderPOSIXDYLD.h" 27 28 using namespace lldb; 29 using namespace lldb_private; 30 31 void 32 DynamicLoaderPOSIXDYLD::Initialize() 33 { 34 PluginManager::RegisterPlugin(GetPluginNameStatic(), 35 GetPluginDescriptionStatic(), 36 CreateInstance); 37 } 38 39 void 40 DynamicLoaderPOSIXDYLD::Terminate() 41 { 42 } 43 44 lldb_private::ConstString 45 DynamicLoaderPOSIXDYLD::GetPluginName() 46 { 47 return GetPluginNameStatic(); 48 } 49 50 lldb_private::ConstString 51 DynamicLoaderPOSIXDYLD::GetPluginNameStatic() 52 { 53 static ConstString g_name("linux-dyld"); 54 return g_name; 55 } 56 57 const char * 58 DynamicLoaderPOSIXDYLD::GetPluginDescriptionStatic() 59 { 60 return "Dynamic loader plug-in that watches for shared library " 61 "loads/unloads in POSIX processes."; 62 } 63 64 void 65 DynamicLoaderPOSIXDYLD::GetPluginCommandHelp(const char *command, Stream *strm) 66 { 67 } 68 69 uint32_t 70 DynamicLoaderPOSIXDYLD::GetPluginVersion() 71 { 72 return 1; 73 } 74 75 DynamicLoader * 76 DynamicLoaderPOSIXDYLD::CreateInstance(Process *process, bool force) 77 { 78 bool create = force; 79 if (!create) 80 { 81 const llvm::Triple &triple_ref = process->GetTarget().GetArchitecture().GetTriple(); 82 if (triple_ref.getOS() == llvm::Triple::Linux || 83 triple_ref.getOS() == llvm::Triple::FreeBSD) 84 create = true; 85 } 86 87 if (create) 88 return new DynamicLoaderPOSIXDYLD (process); 89 return NULL; 90 } 91 92 DynamicLoaderPOSIXDYLD::DynamicLoaderPOSIXDYLD(Process *process) 93 : DynamicLoader(process), 94 m_rendezvous(process), 95 m_load_offset(LLDB_INVALID_ADDRESS), 96 m_entry_point(LLDB_INVALID_ADDRESS), 97 m_auxv(), 98 m_dyld_bid(LLDB_INVALID_BREAK_ID) 99 { 100 } 101 102 DynamicLoaderPOSIXDYLD::~DynamicLoaderPOSIXDYLD() 103 { 104 if (m_dyld_bid != LLDB_INVALID_BREAK_ID) 105 { 106 m_process->GetTarget().RemoveBreakpointByID (m_dyld_bid); 107 m_dyld_bid = LLDB_INVALID_BREAK_ID; 108 } 109 } 110 111 void 112 DynamicLoaderPOSIXDYLD::DidAttach() 113 { 114 Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); 115 ModuleSP executable_sp; 116 addr_t load_offset; 117 118 if (log) 119 log->Printf ("DynamicLoaderPOSIXDYLD::%s() pid %" PRIu64, __FUNCTION__, m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID); 120 121 m_auxv.reset(new AuxVector(m_process)); 122 if (log) 123 log->Printf ("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " reloaded auxv data", __FUNCTION__, m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID); 124 125 executable_sp = GetTargetExecutable(); 126 load_offset = ComputeLoadOffset(); 127 if (log) 128 log->Printf ("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " executable '%s', load_offset 0x%" PRIx64, __FUNCTION__, m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID, executable_sp ? executable_sp->GetFileSpec().GetPath().c_str () : "<null executable>", load_offset); 129 130 131 if (executable_sp && load_offset != LLDB_INVALID_ADDRESS) 132 { 133 ModuleList module_list; 134 135 module_list.Append(executable_sp); 136 if (log) 137 log->Printf ("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " added executable '%s' to module load list", 138 __FUNCTION__, 139 m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID, 140 executable_sp->GetFileSpec().GetPath().c_str ()); 141 142 UpdateLoadedSections(executable_sp, LLDB_INVALID_ADDRESS, load_offset); 143 144 // When attaching to a target, there are two possible states: 145 // (1) We already crossed the entry point and therefore the rendezvous 146 // structure is ready to be used and we can load the list of modules 147 // and place the rendezvous breakpoint. 148 // (2) We didn't cross the entry point yet, so these structures are not 149 // ready; we should behave as if we just launched the target and 150 // call ProbeEntry(). This will place a breakpoint on the entry 151 // point which itself will be hit after the rendezvous structure is 152 // set up and will perform actions described in (1). 153 if (m_rendezvous.Resolve()) 154 { 155 if (log) 156 log->Printf ("DynamicLoaderPOSIXDYLD::%s() pid %" PRIu64 " rendezvous could resolve: attach assuming dynamic loader info is available now", __FUNCTION__, m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID); 157 LoadAllCurrentModules(); 158 SetRendezvousBreakpoint(); 159 } 160 else 161 { 162 if (log) 163 log->Printf ("DynamicLoaderPOSIXDYLD::%s() pid %" PRIu64 " rendezvous could not yet resolve: adding breakpoint to catch future rendezvous setup", __FUNCTION__, m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID); 164 ProbeEntry(); 165 } 166 167 m_process->GetTarget().ModulesDidLoad(module_list); 168 if (log) 169 { 170 log->Printf ("DynamicLoaderPOSIXDYLD::%s told the target about the modules that loaded:", __FUNCTION__); 171 for (auto module_sp : module_list.Modules ()) 172 { 173 log->Printf ("-- [module] %s (pid %" PRIu64 ")", 174 module_sp ? module_sp->GetFileSpec().GetPath().c_str () : "<null>", 175 m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID); 176 } 177 } 178 } 179 } 180 181 void 182 DynamicLoaderPOSIXDYLD::DidLaunch() 183 { 184 Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); 185 if (log) 186 log->Printf ("DynamicLoaderPOSIXDYLD::%s()", __FUNCTION__); 187 188 ModuleSP executable; 189 addr_t load_offset; 190 191 m_auxv.reset(new AuxVector(m_process)); 192 193 executable = GetTargetExecutable(); 194 load_offset = ComputeLoadOffset(); 195 196 if (executable.get() && load_offset != LLDB_INVALID_ADDRESS) 197 { 198 ModuleList module_list; 199 module_list.Append(executable); 200 UpdateLoadedSections(executable, LLDB_INVALID_ADDRESS, load_offset); 201 202 if (log) 203 log->Printf ("DynamicLoaderPOSIXDYLD::%s about to call ProbeEntry()", __FUNCTION__); 204 ProbeEntry(); 205 206 m_process->GetTarget().ModulesDidLoad(module_list); 207 } 208 } 209 210 Error 211 DynamicLoaderPOSIXDYLD::ExecutePluginCommand(Args &command, Stream *strm) 212 { 213 return Error(); 214 } 215 216 Log * 217 DynamicLoaderPOSIXDYLD::EnablePluginLogging(Stream *strm, Args &command) 218 { 219 return NULL; 220 } 221 222 Error 223 DynamicLoaderPOSIXDYLD::CanLoadImage() 224 { 225 return Error(); 226 } 227 228 void 229 DynamicLoaderPOSIXDYLD::UpdateLoadedSections(ModuleSP module, addr_t link_map_addr, addr_t base_addr) 230 { 231 m_loaded_modules[module] = link_map_addr; 232 233 UpdateLoadedSectionsCommon(module, base_addr); 234 } 235 236 void 237 DynamicLoaderPOSIXDYLD::UnloadSections(const ModuleSP module) 238 { 239 m_loaded_modules.erase(module); 240 241 UnloadSectionsCommon(module); 242 } 243 244 void 245 DynamicLoaderPOSIXDYLD::ProbeEntry() 246 { 247 Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); 248 249 const addr_t entry = GetEntryPoint(); 250 if (entry == LLDB_INVALID_ADDRESS) 251 { 252 if (log) 253 log->Printf ("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " GetEntryPoint() returned no address, not setting entry breakpoint", __FUNCTION__, m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID); 254 return; 255 } 256 257 if (log) 258 log->Printf ("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " GetEntryPoint() returned address 0x%" PRIx64 ", setting entry breakpoint", __FUNCTION__, m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID, entry); 259 260 261 Breakpoint *const entry_break = m_process->GetTarget().CreateBreakpoint(entry, true, false).get(); 262 entry_break->SetCallback(EntryBreakpointHit, this, true); 263 entry_break->SetBreakpointKind("shared-library-event"); 264 265 // Shoudn't hit this more than once. 266 entry_break->SetOneShot (true); 267 } 268 269 // The runtime linker has run and initialized the rendezvous structure once the 270 // process has hit its entry point. When we hit the corresponding breakpoint we 271 // interrogate the rendezvous structure to get the load addresses of all 272 // dependent modules for the process. Similarly, we can discover the runtime 273 // linker function and setup a breakpoint to notify us of any dynamically loaded 274 // modules (via dlopen). 275 bool 276 DynamicLoaderPOSIXDYLD::EntryBreakpointHit(void *baton, 277 StoppointCallbackContext *context, 278 user_id_t break_id, 279 user_id_t break_loc_id) 280 { 281 assert(baton && "null baton"); 282 if (!baton) 283 return false; 284 285 Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); 286 DynamicLoaderPOSIXDYLD *const dyld_instance = static_cast<DynamicLoaderPOSIXDYLD*>(baton); 287 if (log) 288 log->Printf ("DynamicLoaderPOSIXDYLD::%s called for pid %" PRIu64, __FUNCTION__, dyld_instance->m_process ? dyld_instance->m_process->GetID () : LLDB_INVALID_PROCESS_ID); 289 290 // Disable the breakpoint --- if a stop happens right after this, which we've seen on occasion, we don't 291 // want the breakpoint stepping thread-plan logic to show a breakpoint instruction at the disassembled 292 // entry point to the program. Disabling it prevents it. (One-shot is not enough - one-shot removal logic 293 // only happens after the breakpoint goes public, which wasn't happening in our scenario). 294 if (dyld_instance->m_process) 295 { 296 BreakpointSP breakpoint_sp = dyld_instance->m_process->GetTarget().GetBreakpointByID (break_id); 297 if (breakpoint_sp) 298 { 299 if (log) 300 log->Printf ("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " disabling breakpoint id %" PRIu64, __FUNCTION__, dyld_instance->m_process->GetID (), break_id); 301 breakpoint_sp->SetEnabled (false); 302 } 303 else 304 { 305 if (log) 306 log->Printf ("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " failed to find breakpoint for breakpoint id %" PRIu64, __FUNCTION__, dyld_instance->m_process->GetID (), break_id); 307 } 308 } 309 else 310 { 311 if (log) 312 log->Printf ("DynamicLoaderPOSIXDYLD::%s breakpoint id %" PRIu64 " no Process instance! Cannot disable breakpoint", __FUNCTION__, break_id); 313 } 314 315 dyld_instance->LoadAllCurrentModules(); 316 dyld_instance->SetRendezvousBreakpoint(); 317 return false; // Continue running. 318 } 319 320 void 321 DynamicLoaderPOSIXDYLD::SetRendezvousBreakpoint() 322 { 323 Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); 324 325 addr_t break_addr = m_rendezvous.GetBreakAddress(); 326 Target &target = m_process->GetTarget(); 327 328 if (m_dyld_bid == LLDB_INVALID_BREAK_ID) 329 { 330 if (log) 331 log->Printf ("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " setting rendezvous break address at 0x%" PRIx64, __FUNCTION__, m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID, break_addr); 332 Breakpoint *dyld_break = target.CreateBreakpoint (break_addr, true, false).get(); 333 dyld_break->SetCallback(RendezvousBreakpointHit, this, true); 334 dyld_break->SetBreakpointKind ("shared-library-event"); 335 m_dyld_bid = dyld_break->GetID(); 336 } 337 else 338 { 339 if (log) 340 log->Printf ("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " reusing break id %" PRIu32 ", address at 0x%" PRIx64, __FUNCTION__, m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID, m_dyld_bid, break_addr); 341 } 342 343 // Make sure our breakpoint is at the right address. 344 assert (target.GetBreakpointByID(m_dyld_bid)->FindLocationByAddress(break_addr)->GetBreakpoint().GetID() == m_dyld_bid); 345 } 346 347 bool 348 DynamicLoaderPOSIXDYLD::RendezvousBreakpointHit(void *baton, 349 StoppointCallbackContext *context, 350 user_id_t break_id, 351 user_id_t break_loc_id) 352 { 353 assert (baton && "null baton"); 354 if (!baton) 355 return false; 356 357 Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); 358 DynamicLoaderPOSIXDYLD *const dyld_instance = static_cast<DynamicLoaderPOSIXDYLD*>(baton); 359 if (log) 360 log->Printf ("DynamicLoaderPOSIXDYLD::%s called for pid %" PRIu64, __FUNCTION__, dyld_instance->m_process ? dyld_instance->m_process->GetID () : LLDB_INVALID_PROCESS_ID); 361 362 dyld_instance->RefreshModules(); 363 364 // Return true to stop the target, false to just let the target run. 365 const bool stop_when_images_change = dyld_instance->GetStopWhenImagesChange(); 366 if (log) 367 log->Printf ("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " stop_when_images_change=%s", __FUNCTION__, dyld_instance->m_process ? dyld_instance->m_process->GetID () : LLDB_INVALID_PROCESS_ID, stop_when_images_change ? "true" : "false"); 368 return stop_when_images_change; 369 } 370 371 void 372 DynamicLoaderPOSIXDYLD::RefreshModules() 373 { 374 if (!m_rendezvous.Resolve()) 375 return; 376 377 DYLDRendezvous::iterator I; 378 DYLDRendezvous::iterator E; 379 380 ModuleList &loaded_modules = m_process->GetTarget().GetImages(); 381 382 if (m_rendezvous.ModulesDidLoad()) 383 { 384 ModuleList new_modules; 385 386 E = m_rendezvous.loaded_end(); 387 for (I = m_rendezvous.loaded_begin(); I != E; ++I) 388 { 389 FileSpec file(I->path.c_str(), true); 390 ModuleSP module_sp = LoadModuleAtAddress(file, I->link_addr, I->base_addr); 391 if (module_sp.get()) 392 { 393 loaded_modules.AppendIfNeeded(module_sp); 394 new_modules.Append(module_sp); 395 } 396 } 397 m_process->GetTarget().ModulesDidLoad(new_modules); 398 } 399 400 if (m_rendezvous.ModulesDidUnload()) 401 { 402 ModuleList old_modules; 403 404 E = m_rendezvous.unloaded_end(); 405 for (I = m_rendezvous.unloaded_begin(); I != E; ++I) 406 { 407 FileSpec file(I->path.c_str(), true); 408 ModuleSpec module_spec (file); 409 ModuleSP module_sp = 410 loaded_modules.FindFirstModule (module_spec); 411 412 if (module_sp.get()) 413 { 414 old_modules.Append(module_sp); 415 UnloadSections(module_sp); 416 } 417 } 418 loaded_modules.Remove(old_modules); 419 m_process->GetTarget().ModulesDidUnload(old_modules, false); 420 } 421 } 422 423 ThreadPlanSP 424 DynamicLoaderPOSIXDYLD::GetStepThroughTrampolinePlan(Thread &thread, bool stop) 425 { 426 ThreadPlanSP thread_plan_sp; 427 428 StackFrame *frame = thread.GetStackFrameAtIndex(0).get(); 429 const SymbolContext &context = frame->GetSymbolContext(eSymbolContextSymbol); 430 Symbol *sym = context.symbol; 431 432 if (sym == NULL || !sym->IsTrampoline()) 433 return thread_plan_sp; 434 435 const ConstString &sym_name = sym->GetMangled().GetName(Mangled::ePreferMangled); 436 if (!sym_name) 437 return thread_plan_sp; 438 439 SymbolContextList target_symbols; 440 Target &target = thread.GetProcess()->GetTarget(); 441 const ModuleList &images = target.GetImages(); 442 443 images.FindSymbolsWithNameAndType(sym_name, eSymbolTypeCode, target_symbols); 444 size_t num_targets = target_symbols.GetSize(); 445 if (!num_targets) 446 return thread_plan_sp; 447 448 typedef std::vector<lldb::addr_t> AddressVector; 449 AddressVector addrs; 450 for (size_t i = 0; i < num_targets; ++i) 451 { 452 SymbolContext context; 453 AddressRange range; 454 if (target_symbols.GetContextAtIndex(i, context)) 455 { 456 context.GetAddressRange(eSymbolContextEverything, 0, false, range); 457 lldb::addr_t addr = range.GetBaseAddress().GetLoadAddress(&target); 458 if (addr != LLDB_INVALID_ADDRESS) 459 addrs.push_back(addr); 460 } 461 } 462 463 if (addrs.size() > 0) 464 { 465 AddressVector::iterator start = addrs.begin(); 466 AddressVector::iterator end = addrs.end(); 467 468 std::sort(start, end); 469 addrs.erase(std::unique(start, end), end); 470 thread_plan_sp.reset(new ThreadPlanRunToAddress(thread, addrs, stop)); 471 } 472 473 return thread_plan_sp; 474 } 475 476 void 477 DynamicLoaderPOSIXDYLD::LoadAllCurrentModules() 478 { 479 DYLDRendezvous::iterator I; 480 DYLDRendezvous::iterator E; 481 ModuleList module_list; 482 483 if (!m_rendezvous.Resolve()) 484 { 485 Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); 486 if (log) 487 log->Printf("DynamicLoaderPOSIXDYLD::%s unable to resolve POSIX DYLD rendezvous address", 488 __FUNCTION__); 489 return; 490 } 491 492 // The rendezvous class doesn't enumerate the main module, so track 493 // that ourselves here. 494 ModuleSP executable = GetTargetExecutable(); 495 m_loaded_modules[executable] = m_rendezvous.GetLinkMapAddress(); 496 497 498 for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I) 499 { 500 const char *module_path = I->path.c_str(); 501 FileSpec file(module_path, false); 502 ModuleSP module_sp = LoadModuleAtAddress(file, I->link_addr, I->base_addr); 503 if (module_sp.get()) 504 { 505 module_list.Append(module_sp); 506 } 507 else 508 { 509 Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); 510 if (log) 511 log->Printf("DynamicLoaderPOSIXDYLD::%s failed loading module %s at 0x%" PRIx64, 512 __FUNCTION__, module_path, I->base_addr); 513 } 514 } 515 516 m_process->GetTarget().ModulesDidLoad(module_list); 517 } 518 519 addr_t 520 DynamicLoaderPOSIXDYLD::ComputeLoadOffset() 521 { 522 addr_t virt_entry; 523 524 if (m_load_offset != LLDB_INVALID_ADDRESS) 525 return m_load_offset; 526 527 if ((virt_entry = GetEntryPoint()) == LLDB_INVALID_ADDRESS) 528 return LLDB_INVALID_ADDRESS; 529 530 ModuleSP module = m_process->GetTarget().GetExecutableModule(); 531 if (!module) 532 return LLDB_INVALID_ADDRESS; 533 534 ObjectFile *exe = module->GetObjectFile(); 535 Address file_entry = exe->GetEntryPointAddress(); 536 537 if (!file_entry.IsValid()) 538 return LLDB_INVALID_ADDRESS; 539 540 m_load_offset = virt_entry - file_entry.GetFileAddress(); 541 return m_load_offset; 542 } 543 544 addr_t 545 DynamicLoaderPOSIXDYLD::GetEntryPoint() 546 { 547 if (m_entry_point != LLDB_INVALID_ADDRESS) 548 return m_entry_point; 549 550 if (m_auxv.get() == NULL) 551 return LLDB_INVALID_ADDRESS; 552 553 AuxVector::iterator I = m_auxv->FindEntry(AuxVector::AT_ENTRY); 554 555 if (I == m_auxv->end()) 556 return LLDB_INVALID_ADDRESS; 557 558 m_entry_point = static_cast<addr_t>(I->value); 559 return m_entry_point; 560 } 561 562 lldb::addr_t 563 DynamicLoaderPOSIXDYLD::GetThreadLocalData (const lldb::ModuleSP module, const lldb::ThreadSP thread) 564 { 565 auto it = m_loaded_modules.find (module); 566 if (it == m_loaded_modules.end()) 567 return LLDB_INVALID_ADDRESS; 568 569 addr_t link_map = it->second; 570 if (link_map == LLDB_INVALID_ADDRESS) 571 return LLDB_INVALID_ADDRESS; 572 573 const DYLDRendezvous::ThreadInfo &metadata = m_rendezvous.GetThreadInfo(); 574 if (!metadata.valid) 575 return LLDB_INVALID_ADDRESS; 576 577 // Get the thread pointer. 578 addr_t tp = thread->GetThreadPointer (); 579 if (tp == LLDB_INVALID_ADDRESS) 580 return LLDB_INVALID_ADDRESS; 581 582 // Find the module's modid. 583 int modid_size = 4; // FIXME(spucci): This isn't right for big-endian 64-bit 584 int64_t modid = ReadUnsignedIntWithSizeInBytes (link_map + metadata.modid_offset, modid_size); 585 if (modid == -1) 586 return LLDB_INVALID_ADDRESS; 587 588 // Lookup the DTV structure for this thread. 589 addr_t dtv_ptr = tp + metadata.dtv_offset; 590 addr_t dtv = ReadPointer (dtv_ptr); 591 if (dtv == LLDB_INVALID_ADDRESS) 592 return LLDB_INVALID_ADDRESS; 593 594 // Find the TLS block for this module. 595 addr_t dtv_slot = dtv + metadata.dtv_slot_size*modid; 596 addr_t tls_block = ReadPointer (dtv_slot + metadata.tls_offset); 597 598 Module *mod = module.get(); 599 Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); 600 if (log) 601 log->Printf("DynamicLoaderPOSIXDYLD::Performed TLS lookup: " 602 "module=%s, link_map=0x%" PRIx64 ", tp=0x%" PRIx64 ", modid=%" PRId64 ", tls_block=0x%" PRIx64 "\n", 603 mod->GetObjectName().AsCString(""), link_map, tp, (int64_t)modid, tls_block); 604 605 return tls_block; 606 } 607