1 //===-- SBTarget.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 9 #include "lldb/API/SBTarget.h" 10 #include "SBReproducerPrivate.h" 11 12 #include "lldb/lldb-public.h" 13 14 #include "lldb/API/SBBreakpoint.h" 15 #include "lldb/API/SBDebugger.h" 16 #include "lldb/API/SBEvent.h" 17 #include "lldb/API/SBExpressionOptions.h" 18 #include "lldb/API/SBFileSpec.h" 19 #include "lldb/API/SBListener.h" 20 #include "lldb/API/SBModule.h" 21 #include "lldb/API/SBModuleSpec.h" 22 #include "lldb/API/SBProcess.h" 23 #include "lldb/API/SBSourceManager.h" 24 #include "lldb/API/SBStream.h" 25 #include "lldb/API/SBStringList.h" 26 #include "lldb/API/SBStructuredData.h" 27 #include "lldb/API/SBSymbolContextList.h" 28 #include "lldb/Breakpoint/BreakpointID.h" 29 #include "lldb/Breakpoint/BreakpointIDList.h" 30 #include "lldb/Breakpoint/BreakpointList.h" 31 #include "lldb/Breakpoint/BreakpointLocation.h" 32 #include "lldb/Core/Address.h" 33 #include "lldb/Core/AddressResolver.h" 34 #include "lldb/Core/AddressResolverName.h" 35 #include "lldb/Core/Debugger.h" 36 #include "lldb/Core/Disassembler.h" 37 #include "lldb/Core/Module.h" 38 #include "lldb/Core/ModuleSpec.h" 39 #include "lldb/Core/STLUtils.h" 40 #include "lldb/Core/SearchFilter.h" 41 #include "lldb/Core/Section.h" 42 #include "lldb/Core/StructuredDataImpl.h" 43 #include "lldb/Core/ValueObjectConstResult.h" 44 #include "lldb/Core/ValueObjectList.h" 45 #include "lldb/Core/ValueObjectVariable.h" 46 #include "lldb/Host/Host.h" 47 #include "lldb/Symbol/ClangASTContext.h" 48 #include "lldb/Symbol/DeclVendor.h" 49 #include "lldb/Symbol/ObjectFile.h" 50 #include "lldb/Symbol/SymbolFile.h" 51 #include "lldb/Symbol/SymbolVendor.h" 52 #include "lldb/Symbol/VariableList.h" 53 #include "lldb/Target/ABI.h" 54 #include "lldb/Target/Language.h" 55 #include "lldb/Target/LanguageRuntime.h" 56 #include "lldb/Target/ObjCLanguageRuntime.h" 57 #include "lldb/Target/Process.h" 58 #include "lldb/Target/StackFrame.h" 59 #include "lldb/Target/Target.h" 60 #include "lldb/Target/TargetList.h" 61 #include "lldb/Utility/ArchSpec.h" 62 #include "lldb/Utility/Args.h" 63 #include "lldb/Utility/FileSpec.h" 64 #include "lldb/Utility/ProcessInfo.h" 65 #include "lldb/Utility/RegularExpression.h" 66 67 #include "Commands/CommandObjectBreakpoint.h" 68 #include "lldb/Interpreter/CommandReturnObject.h" 69 #include "llvm/Support/PrettyStackTrace.h" 70 #include "llvm/Support/Regex.h" 71 72 using namespace lldb; 73 using namespace lldb_private; 74 75 #define DEFAULT_DISASM_BYTE_SIZE 32 76 77 namespace { 78 79 Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target) { 80 std::lock_guard<std::recursive_mutex> guard(target.GetAPIMutex()); 81 82 auto process_sp = target.GetProcessSP(); 83 if (process_sp) { 84 const auto state = process_sp->GetState(); 85 if (process_sp->IsAlive() && state == eStateConnected) { 86 // If we are already connected, then we have already specified the 87 // listener, so if a valid listener is supplied, we need to error out to 88 // let the client know. 89 if (attach_info.GetListener()) 90 return Status("process is connected and already has a listener, pass " 91 "empty listener"); 92 } 93 } 94 95 return target.Attach(attach_info, nullptr); 96 } 97 98 } // namespace 99 100 // SBTarget constructor 101 SBTarget::SBTarget() : m_opaque_sp() { 102 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTarget); 103 } 104 105 SBTarget::SBTarget(const SBTarget &rhs) : m_opaque_sp(rhs.m_opaque_sp) { 106 LLDB_RECORD_CONSTRUCTOR(SBTarget, (const lldb::SBTarget &), rhs); 107 } 108 109 SBTarget::SBTarget(const TargetSP &target_sp) : m_opaque_sp(target_sp) { 110 LLDB_RECORD_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &), target_sp); 111 } 112 113 const SBTarget &SBTarget::operator=(const SBTarget &rhs) { 114 LLDB_RECORD_METHOD(const lldb::SBTarget &, 115 SBTarget, operator=,(const lldb::SBTarget &), rhs); 116 117 if (this != &rhs) 118 m_opaque_sp = rhs.m_opaque_sp; 119 return LLDB_RECORD_RESULT(*this); 120 } 121 122 // Destructor 123 SBTarget::~SBTarget() {} 124 125 bool SBTarget::EventIsTargetEvent(const SBEvent &event) { 126 LLDB_RECORD_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent, 127 (const lldb::SBEvent &), event); 128 129 return Target::TargetEventData::GetEventDataFromEvent(event.get()) != NULL; 130 } 131 132 SBTarget SBTarget::GetTargetFromEvent(const SBEvent &event) { 133 LLDB_RECORD_STATIC_METHOD(lldb::SBTarget, SBTarget, GetTargetFromEvent, 134 (const lldb::SBEvent &), event); 135 136 return LLDB_RECORD_RESULT( 137 Target::TargetEventData::GetTargetFromEvent(event.get())); 138 } 139 140 uint32_t SBTarget::GetNumModulesFromEvent(const SBEvent &event) { 141 LLDB_RECORD_STATIC_METHOD(uint32_t, SBTarget, GetNumModulesFromEvent, 142 (const lldb::SBEvent &), event); 143 144 const ModuleList module_list = 145 Target::TargetEventData::GetModuleListFromEvent(event.get()); 146 return module_list.GetSize(); 147 } 148 149 SBModule SBTarget::GetModuleAtIndexFromEvent(const uint32_t idx, 150 const SBEvent &event) { 151 LLDB_RECORD_STATIC_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndexFromEvent, 152 (const uint32_t, const lldb::SBEvent &), idx, 153 event); 154 155 const ModuleList module_list = 156 Target::TargetEventData::GetModuleListFromEvent(event.get()); 157 return LLDB_RECORD_RESULT(SBModule(module_list.GetModuleAtIndex(idx))); 158 } 159 160 const char *SBTarget::GetBroadcasterClassName() { 161 LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBTarget, 162 GetBroadcasterClassName); 163 164 return Target::GetStaticBroadcasterClass().AsCString(); 165 } 166 167 bool SBTarget::IsValid() const { 168 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, IsValid); 169 return this->operator bool(); 170 } 171 SBTarget::operator bool() const { 172 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, operator bool); 173 174 return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid(); 175 } 176 177 SBProcess SBTarget::GetProcess() { 178 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBTarget, GetProcess); 179 180 SBProcess sb_process; 181 ProcessSP process_sp; 182 TargetSP target_sp(GetSP()); 183 if (target_sp) { 184 process_sp = target_sp->GetProcessSP(); 185 sb_process.SetSP(process_sp); 186 } 187 188 return LLDB_RECORD_RESULT(sb_process); 189 } 190 191 SBPlatform SBTarget::GetPlatform() { 192 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBPlatform, SBTarget, GetPlatform); 193 194 TargetSP target_sp(GetSP()); 195 if (!target_sp) 196 return LLDB_RECORD_RESULT(SBPlatform()); 197 198 SBPlatform platform; 199 platform.m_opaque_sp = target_sp->GetPlatform(); 200 201 return LLDB_RECORD_RESULT(platform); 202 } 203 204 SBDebugger SBTarget::GetDebugger() const { 205 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBDebugger, SBTarget, GetDebugger); 206 207 SBDebugger debugger; 208 TargetSP target_sp(GetSP()); 209 if (target_sp) 210 debugger.reset(target_sp->GetDebugger().shared_from_this()); 211 return LLDB_RECORD_RESULT(debugger); 212 } 213 214 SBStructuredData SBTarget::GetStatistics() { 215 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStructuredData, SBTarget, GetStatistics); 216 217 SBStructuredData data; 218 TargetSP target_sp(GetSP()); 219 if (!target_sp) 220 return LLDB_RECORD_RESULT(data); 221 222 auto stats_up = llvm::make_unique<StructuredData::Dictionary>(); 223 int i = 0; 224 for (auto &Entry : target_sp->GetStatistics()) { 225 std::string Desc = lldb_private::GetStatDescription( 226 static_cast<lldb_private::StatisticKind>(i)); 227 stats_up->AddIntegerItem(Desc, Entry); 228 i += 1; 229 } 230 231 data.m_impl_up->SetObjectSP(std::move(stats_up)); 232 return LLDB_RECORD_RESULT(data); 233 } 234 235 void SBTarget::SetCollectingStats(bool v) { 236 LLDB_RECORD_METHOD(void, SBTarget, SetCollectingStats, (bool), v); 237 238 TargetSP target_sp(GetSP()); 239 if (!target_sp) 240 return; 241 return target_sp->SetCollectingStats(v); 242 } 243 244 bool SBTarget::GetCollectingStats() { 245 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, GetCollectingStats); 246 247 TargetSP target_sp(GetSP()); 248 if (!target_sp) 249 return false; 250 return target_sp->GetCollectingStats(); 251 } 252 253 SBProcess SBTarget::LoadCore(const char *core_file) { 254 LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LoadCore, (const char *), 255 core_file); 256 257 lldb::SBError error; // Ignored 258 return LLDB_RECORD_RESULT(LoadCore(core_file, error)); 259 } 260 261 SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) { 262 LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LoadCore, 263 (const char *, lldb::SBError &), core_file, error); 264 265 SBProcess sb_process; 266 TargetSP target_sp(GetSP()); 267 if (target_sp) { 268 FileSpec filespec(core_file); 269 FileSystem::Instance().Resolve(filespec); 270 ProcessSP process_sp(target_sp->CreateProcess( 271 target_sp->GetDebugger().GetListener(), "", &filespec)); 272 if (process_sp) { 273 error.SetError(process_sp->LoadCore()); 274 if (error.Success()) 275 sb_process.SetSP(process_sp); 276 } else { 277 error.SetErrorString("Failed to create the process"); 278 } 279 } else { 280 error.SetErrorString("SBTarget is invalid"); 281 } 282 return LLDB_RECORD_RESULT(sb_process); 283 } 284 285 SBProcess SBTarget::LaunchSimple(char const **argv, char const **envp, 286 const char *working_directory) { 287 LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LaunchSimple, 288 (const char **, const char **, const char *), argv, envp, 289 working_directory); 290 291 char *stdin_path = NULL; 292 char *stdout_path = NULL; 293 char *stderr_path = NULL; 294 uint32_t launch_flags = 0; 295 bool stop_at_entry = false; 296 SBError error; 297 SBListener listener = GetDebugger().GetListener(); 298 return LLDB_RECORD_RESULT(Launch(listener, argv, envp, stdin_path, 299 stdout_path, stderr_path, working_directory, 300 launch_flags, stop_at_entry, error)); 301 } 302 303 SBError SBTarget::Install() { 304 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBTarget, Install); 305 306 SBError sb_error; 307 TargetSP target_sp(GetSP()); 308 if (target_sp) { 309 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 310 sb_error.ref() = target_sp->Install(NULL); 311 } 312 return LLDB_RECORD_RESULT(sb_error); 313 } 314 315 SBProcess SBTarget::Launch(SBListener &listener, char const **argv, 316 char const **envp, const char *stdin_path, 317 const char *stdout_path, const char *stderr_path, 318 const char *working_directory, 319 uint32_t launch_flags, // See LaunchFlags 320 bool stop_at_entry, lldb::SBError &error) { 321 LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Launch, 322 (lldb::SBListener &, const char **, const char **, 323 const char *, const char *, const char *, const char *, 324 uint32_t, bool, lldb::SBError &), 325 listener, argv, envp, stdin_path, stdout_path, stderr_path, 326 working_directory, launch_flags, stop_at_entry, error); 327 328 SBProcess sb_process; 329 ProcessSP process_sp; 330 TargetSP target_sp(GetSP()); 331 332 if (target_sp) { 333 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 334 335 if (stop_at_entry) 336 launch_flags |= eLaunchFlagStopAtEntry; 337 338 if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR")) 339 launch_flags |= eLaunchFlagDisableASLR; 340 341 StateType state = eStateInvalid; 342 process_sp = target_sp->GetProcessSP(); 343 if (process_sp) { 344 state = process_sp->GetState(); 345 346 if (process_sp->IsAlive() && state != eStateConnected) { 347 if (state == eStateAttaching) 348 error.SetErrorString("process attach is in progress"); 349 else 350 error.SetErrorString("a process is already being debugged"); 351 return LLDB_RECORD_RESULT(sb_process); 352 } 353 } 354 355 if (state == eStateConnected) { 356 // If we are already connected, then we have already specified the 357 // listener, so if a valid listener is supplied, we need to error out to 358 // let the client know. 359 if (listener.IsValid()) { 360 error.SetErrorString("process is connected and already has a listener, " 361 "pass empty listener"); 362 return LLDB_RECORD_RESULT(sb_process); 363 } 364 } 365 366 if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO")) 367 launch_flags |= eLaunchFlagDisableSTDIO; 368 369 ProcessLaunchInfo launch_info(FileSpec(stdin_path), FileSpec(stdout_path), 370 FileSpec(stderr_path), 371 FileSpec(working_directory), launch_flags); 372 373 Module *exe_module = target_sp->GetExecutableModulePointer(); 374 if (exe_module) 375 launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); 376 if (argv) 377 launch_info.GetArguments().AppendArguments(argv); 378 if (envp) 379 launch_info.GetEnvironment() = Environment(envp); 380 381 if (listener.IsValid()) 382 launch_info.SetListener(listener.GetSP()); 383 384 error.SetError(target_sp->Launch(launch_info, NULL)); 385 386 sb_process.SetSP(target_sp->GetProcessSP()); 387 } else { 388 error.SetErrorString("SBTarget is invalid"); 389 } 390 391 return LLDB_RECORD_RESULT(sb_process); 392 } 393 394 SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) { 395 LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Launch, 396 (lldb::SBLaunchInfo &, lldb::SBError &), sb_launch_info, 397 error); 398 399 400 SBProcess sb_process; 401 TargetSP target_sp(GetSP()); 402 403 if (target_sp) { 404 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 405 StateType state = eStateInvalid; 406 { 407 ProcessSP process_sp = target_sp->GetProcessSP(); 408 if (process_sp) { 409 state = process_sp->GetState(); 410 411 if (process_sp->IsAlive() && state != eStateConnected) { 412 if (state == eStateAttaching) 413 error.SetErrorString("process attach is in progress"); 414 else 415 error.SetErrorString("a process is already being debugged"); 416 return LLDB_RECORD_RESULT(sb_process); 417 } 418 } 419 } 420 421 lldb_private::ProcessLaunchInfo launch_info = sb_launch_info.ref(); 422 423 if (!launch_info.GetExecutableFile()) { 424 Module *exe_module = target_sp->GetExecutableModulePointer(); 425 if (exe_module) 426 launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); 427 } 428 429 const ArchSpec &arch_spec = target_sp->GetArchitecture(); 430 if (arch_spec.IsValid()) 431 launch_info.GetArchitecture() = arch_spec; 432 433 error.SetError(target_sp->Launch(launch_info, NULL)); 434 sb_launch_info.set_ref(launch_info); 435 sb_process.SetSP(target_sp->GetProcessSP()); 436 } else { 437 error.SetErrorString("SBTarget is invalid"); 438 } 439 440 return LLDB_RECORD_RESULT(sb_process); 441 } 442 443 lldb::SBProcess SBTarget::Attach(SBAttachInfo &sb_attach_info, SBError &error) { 444 LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Attach, 445 (lldb::SBAttachInfo &, lldb::SBError &), sb_attach_info, 446 error); 447 448 SBProcess sb_process; 449 TargetSP target_sp(GetSP()); 450 451 if (target_sp) { 452 ProcessAttachInfo &attach_info = sb_attach_info.ref(); 453 if (attach_info.ProcessIDIsValid() && !attach_info.UserIDIsValid()) { 454 PlatformSP platform_sp = target_sp->GetPlatform(); 455 // See if we can pre-verify if a process exists or not 456 if (platform_sp && platform_sp->IsConnected()) { 457 lldb::pid_t attach_pid = attach_info.GetProcessID(); 458 ProcessInstanceInfo instance_info; 459 if (platform_sp->GetProcessInfo(attach_pid, instance_info)) { 460 attach_info.SetUserID(instance_info.GetEffectiveUserID()); 461 } else { 462 error.ref().SetErrorStringWithFormat( 463 "no process found with process ID %" PRIu64, attach_pid); 464 return LLDB_RECORD_RESULT(sb_process); 465 } 466 } 467 } 468 error.SetError(AttachToProcess(attach_info, *target_sp)); 469 if (error.Success()) 470 sb_process.SetSP(target_sp->GetProcessSP()); 471 } else { 472 error.SetErrorString("SBTarget is invalid"); 473 } 474 475 return LLDB_RECORD_RESULT(sb_process); 476 } 477 478 lldb::SBProcess SBTarget::AttachToProcessWithID( 479 SBListener &listener, 480 lldb::pid_t pid, // The process ID to attach to 481 SBError &error // An error explaining what went wrong if attach fails 482 ) { 483 LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithID, 484 (lldb::SBListener &, lldb::pid_t, lldb::SBError &), 485 listener, pid, error); 486 487 SBProcess sb_process; 488 TargetSP target_sp(GetSP()); 489 490 if (target_sp) { 491 ProcessAttachInfo attach_info; 492 attach_info.SetProcessID(pid); 493 if (listener.IsValid()) 494 attach_info.SetListener(listener.GetSP()); 495 496 ProcessInstanceInfo instance_info; 497 if (target_sp->GetPlatform()->GetProcessInfo(pid, instance_info)) 498 attach_info.SetUserID(instance_info.GetEffectiveUserID()); 499 500 error.SetError(AttachToProcess(attach_info, *target_sp)); 501 if (error.Success()) 502 sb_process.SetSP(target_sp->GetProcessSP()); 503 } else 504 error.SetErrorString("SBTarget is invalid"); 505 506 return LLDB_RECORD_RESULT(sb_process); 507 } 508 509 lldb::SBProcess SBTarget::AttachToProcessWithName( 510 SBListener &listener, 511 const char *name, // basename of process to attach to 512 bool wait_for, // if true wait for a new instance of "name" to be launched 513 SBError &error // An error explaining what went wrong if attach fails 514 ) { 515 LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithName, 516 (lldb::SBListener &, const char *, bool, lldb::SBError &), 517 listener, name, wait_for, error); 518 519 SBProcess sb_process; 520 TargetSP target_sp(GetSP()); 521 522 if (name && target_sp) { 523 ProcessAttachInfo attach_info; 524 attach_info.GetExecutableFile().SetFile(name, FileSpec::Style::native); 525 attach_info.SetWaitForLaunch(wait_for); 526 if (listener.IsValid()) 527 attach_info.SetListener(listener.GetSP()); 528 529 error.SetError(AttachToProcess(attach_info, *target_sp)); 530 if (error.Success()) 531 sb_process.SetSP(target_sp->GetProcessSP()); 532 } else 533 error.SetErrorString("SBTarget is invalid"); 534 535 return LLDB_RECORD_RESULT(sb_process); 536 } 537 538 lldb::SBProcess SBTarget::ConnectRemote(SBListener &listener, const char *url, 539 const char *plugin_name, 540 SBError &error) { 541 LLDB_RECORD_METHOD( 542 lldb::SBProcess, SBTarget, ConnectRemote, 543 (lldb::SBListener &, const char *, const char *, lldb::SBError &), 544 listener, url, plugin_name, error); 545 546 SBProcess sb_process; 547 ProcessSP process_sp; 548 TargetSP target_sp(GetSP()); 549 550 if (target_sp) { 551 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 552 if (listener.IsValid()) 553 process_sp = 554 target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, NULL); 555 else 556 process_sp = target_sp->CreateProcess( 557 target_sp->GetDebugger().GetListener(), plugin_name, NULL); 558 559 if (process_sp) { 560 sb_process.SetSP(process_sp); 561 error.SetError(process_sp->ConnectRemote(NULL, url)); 562 } else { 563 error.SetErrorString("unable to create lldb_private::Process"); 564 } 565 } else { 566 error.SetErrorString("SBTarget is invalid"); 567 } 568 569 return LLDB_RECORD_RESULT(sb_process); 570 } 571 572 SBFileSpec SBTarget::GetExecutable() { 573 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBTarget, GetExecutable); 574 575 SBFileSpec exe_file_spec; 576 TargetSP target_sp(GetSP()); 577 if (target_sp) { 578 Module *exe_module = target_sp->GetExecutableModulePointer(); 579 if (exe_module) 580 exe_file_spec.SetFileSpec(exe_module->GetFileSpec()); 581 } 582 583 return LLDB_RECORD_RESULT(exe_file_spec); 584 } 585 586 bool SBTarget::operator==(const SBTarget &rhs) const { 587 LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator==,(const lldb::SBTarget &), 588 rhs); 589 590 return m_opaque_sp.get() == rhs.m_opaque_sp.get(); 591 } 592 593 bool SBTarget::operator!=(const SBTarget &rhs) const { 594 LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator!=,(const lldb::SBTarget &), 595 rhs); 596 597 return m_opaque_sp.get() != rhs.m_opaque_sp.get(); 598 } 599 600 lldb::TargetSP SBTarget::GetSP() const { return m_opaque_sp; } 601 602 void SBTarget::SetSP(const lldb::TargetSP &target_sp) { 603 m_opaque_sp = target_sp; 604 } 605 606 lldb::SBAddress SBTarget::ResolveLoadAddress(lldb::addr_t vm_addr) { 607 LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolveLoadAddress, 608 (lldb::addr_t), vm_addr); 609 610 lldb::SBAddress sb_addr; 611 Address &addr = sb_addr.ref(); 612 TargetSP target_sp(GetSP()); 613 if (target_sp) { 614 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 615 if (target_sp->ResolveLoadAddress(vm_addr, addr)) 616 return LLDB_RECORD_RESULT(sb_addr); 617 } 618 619 // We have a load address that isn't in a section, just return an address 620 // with the offset filled in (the address) and the section set to NULL 621 addr.SetRawAddress(vm_addr); 622 return LLDB_RECORD_RESULT(sb_addr); 623 } 624 625 lldb::SBAddress SBTarget::ResolveFileAddress(lldb::addr_t file_addr) { 626 LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolveFileAddress, 627 (lldb::addr_t), file_addr); 628 629 lldb::SBAddress sb_addr; 630 Address &addr = sb_addr.ref(); 631 TargetSP target_sp(GetSP()); 632 if (target_sp) { 633 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 634 if (target_sp->ResolveFileAddress(file_addr, addr)) 635 return LLDB_RECORD_RESULT(sb_addr); 636 } 637 638 addr.SetRawAddress(file_addr); 639 return LLDB_RECORD_RESULT(sb_addr); 640 } 641 642 lldb::SBAddress SBTarget::ResolvePastLoadAddress(uint32_t stop_id, 643 lldb::addr_t vm_addr) { 644 LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolvePastLoadAddress, 645 (uint32_t, lldb::addr_t), stop_id, vm_addr); 646 647 lldb::SBAddress sb_addr; 648 Address &addr = sb_addr.ref(); 649 TargetSP target_sp(GetSP()); 650 if (target_sp) { 651 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 652 if (target_sp->ResolveLoadAddress(vm_addr, addr)) 653 return LLDB_RECORD_RESULT(sb_addr); 654 } 655 656 // We have a load address that isn't in a section, just return an address 657 // with the offset filled in (the address) and the section set to NULL 658 addr.SetRawAddress(vm_addr); 659 return LLDB_RECORD_RESULT(sb_addr); 660 } 661 662 SBSymbolContext 663 SBTarget::ResolveSymbolContextForAddress(const SBAddress &addr, 664 uint32_t resolve_scope) { 665 LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBTarget, 666 ResolveSymbolContextForAddress, 667 (const lldb::SBAddress &, uint32_t), addr, resolve_scope); 668 669 SBSymbolContext sc; 670 SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope); 671 if (addr.IsValid()) { 672 TargetSP target_sp(GetSP()); 673 if (target_sp) 674 target_sp->GetImages().ResolveSymbolContextForAddress(addr.ref(), scope, 675 sc.ref()); 676 } 677 return LLDB_RECORD_RESULT(sc); 678 } 679 680 size_t SBTarget::ReadMemory(const SBAddress addr, void *buf, size_t size, 681 lldb::SBError &error) { 682 LLDB_RECORD_DUMMY(size_t, SBTarget, ReadMemory, 683 (const lldb::SBAddress, void *, size_t, lldb::SBError &), 684 addr, buf, size, error); 685 686 SBError sb_error; 687 size_t bytes_read = 0; 688 TargetSP target_sp(GetSP()); 689 if (target_sp) { 690 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 691 bytes_read = 692 target_sp->ReadMemory(addr.ref(), false, buf, size, sb_error.ref()); 693 } else { 694 sb_error.SetErrorString("invalid target"); 695 } 696 697 return bytes_read; 698 } 699 700 SBBreakpoint SBTarget::BreakpointCreateByLocation(const char *file, 701 uint32_t line) { 702 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, 703 (const char *, uint32_t), file, line); 704 705 return LLDB_RECORD_RESULT( 706 SBBreakpoint(BreakpointCreateByLocation(SBFileSpec(file, false), line))); 707 } 708 709 SBBreakpoint 710 SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec, 711 uint32_t line) { 712 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, 713 (const lldb::SBFileSpec &, uint32_t), sb_file_spec, line); 714 715 return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0)); 716 } 717 718 SBBreakpoint 719 SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec, 720 uint32_t line, lldb::addr_t offset) { 721 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, 722 (const lldb::SBFileSpec &, uint32_t, lldb::addr_t), 723 sb_file_spec, line, offset); 724 725 SBFileSpecList empty_list; 726 return LLDB_RECORD_RESULT( 727 BreakpointCreateByLocation(sb_file_spec, line, offset, empty_list)); 728 } 729 730 SBBreakpoint 731 SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec, 732 uint32_t line, lldb::addr_t offset, 733 SBFileSpecList &sb_module_list) { 734 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, 735 (const lldb::SBFileSpec &, uint32_t, lldb::addr_t, 736 lldb::SBFileSpecList &), 737 sb_file_spec, line, offset, sb_module_list); 738 739 return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0, 740 offset, sb_module_list)); 741 } 742 743 SBBreakpoint SBTarget::BreakpointCreateByLocation( 744 const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column, 745 lldb::addr_t offset, SBFileSpecList &sb_module_list) { 746 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, 747 (const lldb::SBFileSpec &, uint32_t, uint32_t, 748 lldb::addr_t, lldb::SBFileSpecList &), 749 sb_file_spec, line, column, offset, sb_module_list); 750 751 SBBreakpoint sb_bp; 752 TargetSP target_sp(GetSP()); 753 if (target_sp && line != 0) { 754 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 755 756 const LazyBool check_inlines = eLazyBoolCalculate; 757 const LazyBool skip_prologue = eLazyBoolCalculate; 758 const bool internal = false; 759 const bool hardware = false; 760 const LazyBool move_to_nearest_code = eLazyBoolCalculate; 761 const FileSpecList *module_list = nullptr; 762 if (sb_module_list.GetSize() > 0) { 763 module_list = sb_module_list.get(); 764 } 765 sb_bp = target_sp->CreateBreakpoint( 766 module_list, *sb_file_spec, line, column, offset, check_inlines, 767 skip_prologue, internal, hardware, move_to_nearest_code); 768 } 769 770 return LLDB_RECORD_RESULT(sb_bp); 771 } 772 773 SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name, 774 const char *module_name) { 775 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, 776 (const char *, const char *), symbol_name, module_name); 777 778 SBBreakpoint sb_bp; 779 TargetSP target_sp(GetSP()); 780 if (target_sp.get()) { 781 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 782 783 const bool internal = false; 784 const bool hardware = false; 785 const LazyBool skip_prologue = eLazyBoolCalculate; 786 const lldb::addr_t offset = 0; 787 if (module_name && module_name[0]) { 788 FileSpecList module_spec_list; 789 module_spec_list.Append(FileSpec(module_name)); 790 sb_bp = target_sp->CreateBreakpoint( 791 &module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, 792 eLanguageTypeUnknown, offset, skip_prologue, internal, hardware); 793 } else { 794 sb_bp = target_sp->CreateBreakpoint( 795 NULL, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, 796 offset, skip_prologue, internal, hardware); 797 } 798 } 799 800 return LLDB_RECORD_RESULT(sb_bp); 801 } 802 803 lldb::SBBreakpoint 804 SBTarget::BreakpointCreateByName(const char *symbol_name, 805 const SBFileSpecList &module_list, 806 const SBFileSpecList &comp_unit_list) { 807 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, 808 (const char *, const lldb::SBFileSpecList &, 809 const lldb::SBFileSpecList &), 810 symbol_name, module_list, comp_unit_list); 811 812 lldb::FunctionNameType name_type_mask = eFunctionNameTypeAuto; 813 return LLDB_RECORD_RESULT( 814 BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown, 815 module_list, comp_unit_list)); 816 } 817 818 lldb::SBBreakpoint SBTarget::BreakpointCreateByName( 819 const char *symbol_name, uint32_t name_type_mask, 820 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { 821 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, 822 (const char *, uint32_t, const lldb::SBFileSpecList &, 823 const lldb::SBFileSpecList &), 824 symbol_name, name_type_mask, module_list, comp_unit_list); 825 826 return LLDB_RECORD_RESULT( 827 BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown, 828 module_list, comp_unit_list)); 829 } 830 831 lldb::SBBreakpoint SBTarget::BreakpointCreateByName( 832 const char *symbol_name, uint32_t name_type_mask, 833 LanguageType symbol_language, const SBFileSpecList &module_list, 834 const SBFileSpecList &comp_unit_list) { 835 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, 836 (const char *, uint32_t, lldb::LanguageType, 837 const lldb::SBFileSpecList &, 838 const lldb::SBFileSpecList &), 839 symbol_name, name_type_mask, symbol_language, module_list, 840 comp_unit_list); 841 842 SBBreakpoint sb_bp; 843 TargetSP target_sp(GetSP()); 844 if (target_sp && symbol_name && symbol_name[0]) { 845 const bool internal = false; 846 const bool hardware = false; 847 const LazyBool skip_prologue = eLazyBoolCalculate; 848 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 849 FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask); 850 sb_bp = target_sp->CreateBreakpoint(module_list.get(), comp_unit_list.get(), 851 symbol_name, mask, symbol_language, 0, 852 skip_prologue, internal, hardware); 853 } 854 855 return LLDB_RECORD_RESULT(sb_bp); 856 } 857 858 lldb::SBBreakpoint SBTarget::BreakpointCreateByNames( 859 const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask, 860 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { 861 LLDB_RECORD_METHOD( 862 lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, 863 (const char **, uint32_t, uint32_t, const lldb::SBFileSpecList &, 864 const lldb::SBFileSpecList &), 865 symbol_names, num_names, name_type_mask, module_list, comp_unit_list); 866 867 return LLDB_RECORD_RESULT(BreakpointCreateByNames( 868 symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, 869 module_list, comp_unit_list)); 870 } 871 872 lldb::SBBreakpoint SBTarget::BreakpointCreateByNames( 873 const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask, 874 LanguageType symbol_language, const SBFileSpecList &module_list, 875 const SBFileSpecList &comp_unit_list) { 876 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, 877 (const char **, uint32_t, uint32_t, lldb::LanguageType, 878 const lldb::SBFileSpecList &, 879 const lldb::SBFileSpecList &), 880 symbol_names, num_names, name_type_mask, symbol_language, 881 module_list, comp_unit_list); 882 883 return LLDB_RECORD_RESULT(BreakpointCreateByNames( 884 symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, 0, 885 module_list, comp_unit_list)); 886 } 887 888 lldb::SBBreakpoint SBTarget::BreakpointCreateByNames( 889 const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask, 890 LanguageType symbol_language, lldb::addr_t offset, 891 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { 892 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, 893 (const char **, uint32_t, uint32_t, lldb::LanguageType, 894 lldb::addr_t, const lldb::SBFileSpecList &, 895 const lldb::SBFileSpecList &), 896 symbol_names, num_names, name_type_mask, symbol_language, 897 offset, module_list, comp_unit_list); 898 899 SBBreakpoint sb_bp; 900 TargetSP target_sp(GetSP()); 901 if (target_sp && num_names > 0) { 902 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 903 const bool internal = false; 904 const bool hardware = false; 905 FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask); 906 const LazyBool skip_prologue = eLazyBoolCalculate; 907 sb_bp = target_sp->CreateBreakpoint( 908 module_list.get(), comp_unit_list.get(), symbol_names, num_names, mask, 909 symbol_language, offset, skip_prologue, internal, hardware); 910 } 911 912 return LLDB_RECORD_RESULT(sb_bp); 913 } 914 915 SBBreakpoint SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex, 916 const char *module_name) { 917 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, 918 (const char *, const char *), symbol_name_regex, 919 module_name); 920 921 SBFileSpecList module_spec_list; 922 SBFileSpecList comp_unit_list; 923 if (module_name && module_name[0]) { 924 module_spec_list.Append(FileSpec(module_name)); 925 } 926 return LLDB_RECORD_RESULT( 927 BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown, 928 module_spec_list, comp_unit_list)); 929 } 930 931 lldb::SBBreakpoint 932 SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex, 933 const SBFileSpecList &module_list, 934 const SBFileSpecList &comp_unit_list) { 935 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, 936 (const char *, const lldb::SBFileSpecList &, 937 const lldb::SBFileSpecList &), 938 symbol_name_regex, module_list, comp_unit_list); 939 940 return LLDB_RECORD_RESULT(BreakpointCreateByRegex( 941 symbol_name_regex, eLanguageTypeUnknown, module_list, comp_unit_list)); 942 } 943 944 lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex( 945 const char *symbol_name_regex, LanguageType symbol_language, 946 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { 947 LLDB_RECORD_METHOD( 948 lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, 949 (const char *, lldb::LanguageType, const lldb::SBFileSpecList &, 950 const lldb::SBFileSpecList &), 951 symbol_name_regex, symbol_language, module_list, comp_unit_list); 952 953 954 SBBreakpoint sb_bp; 955 TargetSP target_sp(GetSP()); 956 if (target_sp && symbol_name_regex && symbol_name_regex[0]) { 957 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 958 RegularExpression regexp((llvm::StringRef(symbol_name_regex))); 959 const bool internal = false; 960 const bool hardware = false; 961 const LazyBool skip_prologue = eLazyBoolCalculate; 962 963 sb_bp = target_sp->CreateFuncRegexBreakpoint( 964 module_list.get(), comp_unit_list.get(), regexp, symbol_language, 965 skip_prologue, internal, hardware); 966 } 967 968 return LLDB_RECORD_RESULT(sb_bp); 969 } 970 971 SBBreakpoint SBTarget::BreakpointCreateByAddress(addr_t address) { 972 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByAddress, 973 (lldb::addr_t), address); 974 975 SBBreakpoint sb_bp; 976 TargetSP target_sp(GetSP()); 977 if (target_sp) { 978 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 979 const bool hardware = false; 980 sb_bp = target_sp->CreateBreakpoint(address, false, hardware); 981 } 982 983 return LLDB_RECORD_RESULT(sb_bp); 984 } 985 986 SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) { 987 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateBySBAddress, 988 (lldb::SBAddress &), sb_address); 989 990 SBBreakpoint sb_bp; 991 TargetSP target_sp(GetSP()); 992 if (!sb_address.IsValid()) { 993 return LLDB_RECORD_RESULT(sb_bp); 994 } 995 996 if (target_sp) { 997 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 998 const bool hardware = false; 999 sb_bp = target_sp->CreateBreakpoint(sb_address.ref(), false, hardware); 1000 } 1001 1002 return LLDB_RECORD_RESULT(sb_bp); 1003 } 1004 1005 lldb::SBBreakpoint 1006 SBTarget::BreakpointCreateBySourceRegex(const char *source_regex, 1007 const lldb::SBFileSpec &source_file, 1008 const char *module_name) { 1009 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, 1010 BreakpointCreateBySourceRegex, 1011 (const char *, const lldb::SBFileSpec &, const char *), 1012 source_regex, source_file, module_name); 1013 1014 SBFileSpecList module_spec_list; 1015 1016 if (module_name && module_name[0]) { 1017 module_spec_list.Append(FileSpec(module_name)); 1018 } 1019 1020 SBFileSpecList source_file_list; 1021 if (source_file.IsValid()) { 1022 source_file_list.Append(source_file); 1023 } 1024 1025 return LLDB_RECORD_RESULT(BreakpointCreateBySourceRegex( 1026 source_regex, module_spec_list, source_file_list)); 1027 } 1028 1029 lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex( 1030 const char *source_regex, const SBFileSpecList &module_list, 1031 const lldb::SBFileSpecList &source_file_list) { 1032 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, 1033 BreakpointCreateBySourceRegex, 1034 (const char *, const lldb::SBFileSpecList &, 1035 const lldb::SBFileSpecList &), 1036 source_regex, module_list, source_file_list); 1037 1038 return LLDB_RECORD_RESULT(BreakpointCreateBySourceRegex( 1039 source_regex, module_list, source_file_list, SBStringList())); 1040 } 1041 1042 lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex( 1043 const char *source_regex, const SBFileSpecList &module_list, 1044 const lldb::SBFileSpecList &source_file_list, 1045 const SBStringList &func_names) { 1046 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, 1047 BreakpointCreateBySourceRegex, 1048 (const char *, const lldb::SBFileSpecList &, 1049 const lldb::SBFileSpecList &, const lldb::SBStringList &), 1050 source_regex, module_list, source_file_list, func_names); 1051 1052 SBBreakpoint sb_bp; 1053 TargetSP target_sp(GetSP()); 1054 if (target_sp && source_regex && source_regex[0]) { 1055 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1056 const bool hardware = false; 1057 const LazyBool move_to_nearest_code = eLazyBoolCalculate; 1058 RegularExpression regexp((llvm::StringRef(source_regex))); 1059 std::unordered_set<std::string> func_names_set; 1060 for (size_t i = 0; i < func_names.GetSize(); i++) { 1061 func_names_set.insert(func_names.GetStringAtIndex(i)); 1062 } 1063 1064 sb_bp = target_sp->CreateSourceRegexBreakpoint( 1065 module_list.get(), source_file_list.get(), func_names_set, regexp, 1066 false, hardware, move_to_nearest_code); 1067 } 1068 1069 return LLDB_RECORD_RESULT(sb_bp); 1070 } 1071 1072 lldb::SBBreakpoint 1073 SBTarget::BreakpointCreateForException(lldb::LanguageType language, 1074 bool catch_bp, bool throw_bp) { 1075 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateForException, 1076 (lldb::LanguageType, bool, bool), language, catch_bp, 1077 throw_bp); 1078 1079 SBBreakpoint sb_bp; 1080 TargetSP target_sp(GetSP()); 1081 if (target_sp) { 1082 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1083 const bool hardware = false; 1084 sb_bp = target_sp->CreateExceptionBreakpoint(language, catch_bp, throw_bp, 1085 hardware); 1086 } 1087 1088 return LLDB_RECORD_RESULT(sb_bp); 1089 } 1090 1091 lldb::SBBreakpoint SBTarget::BreakpointCreateFromScript( 1092 const char *class_name, SBStructuredData &extra_args, 1093 const SBFileSpecList &module_list, const SBFileSpecList &file_list, 1094 bool request_hardware) { 1095 LLDB_RECORD_METHOD( 1096 lldb::SBBreakpoint, SBTarget, BreakpointCreateFromScript, 1097 (const char *, lldb::SBStructuredData &, const lldb::SBFileSpecList &, 1098 const lldb::SBFileSpecList &, bool), 1099 class_name, extra_args, module_list, file_list, request_hardware); 1100 1101 SBBreakpoint sb_bp; 1102 TargetSP target_sp(GetSP()); 1103 if (target_sp) { 1104 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1105 Status error; 1106 1107 StructuredData::ObjectSP obj_sp = extra_args.m_impl_up->GetObjectSP(); 1108 sb_bp = 1109 target_sp->CreateScriptedBreakpoint(class_name, 1110 module_list.get(), 1111 file_list.get(), 1112 false, /* internal */ 1113 request_hardware, 1114 obj_sp, 1115 &error); 1116 } 1117 1118 return LLDB_RECORD_RESULT(sb_bp); 1119 } 1120 1121 uint32_t SBTarget::GetNumBreakpoints() const { 1122 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumBreakpoints); 1123 1124 TargetSP target_sp(GetSP()); 1125 if (target_sp) { 1126 // The breakpoint list is thread safe, no need to lock 1127 return target_sp->GetBreakpointList().GetSize(); 1128 } 1129 return 0; 1130 } 1131 1132 SBBreakpoint SBTarget::GetBreakpointAtIndex(uint32_t idx) const { 1133 LLDB_RECORD_METHOD_CONST(lldb::SBBreakpoint, SBTarget, GetBreakpointAtIndex, 1134 (uint32_t), idx); 1135 1136 SBBreakpoint sb_breakpoint; 1137 TargetSP target_sp(GetSP()); 1138 if (target_sp) { 1139 // The breakpoint list is thread safe, no need to lock 1140 sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx); 1141 } 1142 return LLDB_RECORD_RESULT(sb_breakpoint); 1143 } 1144 1145 bool SBTarget::BreakpointDelete(break_id_t bp_id) { 1146 LLDB_RECORD_METHOD(bool, SBTarget, BreakpointDelete, (lldb::break_id_t), 1147 bp_id); 1148 1149 bool result = false; 1150 TargetSP target_sp(GetSP()); 1151 if (target_sp) { 1152 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1153 result = target_sp->RemoveBreakpointByID(bp_id); 1154 } 1155 1156 return result; 1157 } 1158 1159 SBBreakpoint SBTarget::FindBreakpointByID(break_id_t bp_id) { 1160 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, FindBreakpointByID, 1161 (lldb::break_id_t), bp_id); 1162 1163 SBBreakpoint sb_breakpoint; 1164 TargetSP target_sp(GetSP()); 1165 if (target_sp && bp_id != LLDB_INVALID_BREAK_ID) { 1166 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1167 sb_breakpoint = target_sp->GetBreakpointByID(bp_id); 1168 } 1169 1170 return LLDB_RECORD_RESULT(sb_breakpoint); 1171 } 1172 1173 bool SBTarget::FindBreakpointsByName(const char *name, 1174 SBBreakpointList &bkpts) { 1175 LLDB_RECORD_METHOD(bool, SBTarget, FindBreakpointsByName, 1176 (const char *, lldb::SBBreakpointList &), name, bkpts); 1177 1178 TargetSP target_sp(GetSP()); 1179 if (target_sp) { 1180 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1181 BreakpointList bkpt_list(false); 1182 bool is_valid = 1183 target_sp->GetBreakpointList().FindBreakpointsByName(name, bkpt_list); 1184 if (!is_valid) 1185 return false; 1186 for (BreakpointSP bkpt_sp : bkpt_list.Breakpoints()) { 1187 bkpts.AppendByID(bkpt_sp->GetID()); 1188 } 1189 } 1190 return true; 1191 } 1192 1193 void SBTarget::GetBreakpointNames(SBStringList &names) { 1194 LLDB_RECORD_METHOD(void, SBTarget, GetBreakpointNames, (lldb::SBStringList &), 1195 names); 1196 1197 names.Clear(); 1198 1199 TargetSP target_sp(GetSP()); 1200 if (target_sp) { 1201 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1202 1203 std::vector<std::string> name_vec; 1204 target_sp->GetBreakpointNames(name_vec); 1205 for (auto name : name_vec) 1206 names.AppendString(name.c_str()); 1207 } 1208 } 1209 1210 void SBTarget::DeleteBreakpointName(const char *name) { 1211 LLDB_RECORD_METHOD(void, SBTarget, DeleteBreakpointName, (const char *), 1212 name); 1213 1214 TargetSP target_sp(GetSP()); 1215 if (target_sp) { 1216 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1217 target_sp->DeleteBreakpointName(ConstString(name)); 1218 } 1219 } 1220 1221 bool SBTarget::EnableAllBreakpoints() { 1222 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, EnableAllBreakpoints); 1223 1224 TargetSP target_sp(GetSP()); 1225 if (target_sp) { 1226 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1227 target_sp->EnableAllowedBreakpoints(); 1228 return true; 1229 } 1230 return false; 1231 } 1232 1233 bool SBTarget::DisableAllBreakpoints() { 1234 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DisableAllBreakpoints); 1235 1236 TargetSP target_sp(GetSP()); 1237 if (target_sp) { 1238 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1239 target_sp->DisableAllowedBreakpoints(); 1240 return true; 1241 } 1242 return false; 1243 } 1244 1245 bool SBTarget::DeleteAllBreakpoints() { 1246 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DeleteAllBreakpoints); 1247 1248 TargetSP target_sp(GetSP()); 1249 if (target_sp) { 1250 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1251 target_sp->RemoveAllowedBreakpoints(); 1252 return true; 1253 } 1254 return false; 1255 } 1256 1257 lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file, 1258 SBBreakpointList &new_bps) { 1259 LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsCreateFromFile, 1260 (lldb::SBFileSpec &, lldb::SBBreakpointList &), 1261 source_file, new_bps); 1262 1263 SBStringList empty_name_list; 1264 return LLDB_RECORD_RESULT( 1265 BreakpointsCreateFromFile(source_file, empty_name_list, new_bps)); 1266 } 1267 1268 lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file, 1269 SBStringList &matching_names, 1270 SBBreakpointList &new_bps) { 1271 LLDB_RECORD_METHOD( 1272 lldb::SBError, SBTarget, BreakpointsCreateFromFile, 1273 (lldb::SBFileSpec &, lldb::SBStringList &, lldb::SBBreakpointList &), 1274 source_file, matching_names, new_bps); 1275 1276 SBError sberr; 1277 TargetSP target_sp(GetSP()); 1278 if (!target_sp) { 1279 sberr.SetErrorString( 1280 "BreakpointCreateFromFile called with invalid target."); 1281 return LLDB_RECORD_RESULT(sberr); 1282 } 1283 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1284 1285 BreakpointIDList bp_ids; 1286 1287 std::vector<std::string> name_vector; 1288 size_t num_names = matching_names.GetSize(); 1289 for (size_t i = 0; i < num_names; i++) 1290 name_vector.push_back(matching_names.GetStringAtIndex(i)); 1291 1292 sberr.ref() = target_sp->CreateBreakpointsFromFile(source_file.ref(), 1293 name_vector, bp_ids); 1294 if (sberr.Fail()) 1295 return LLDB_RECORD_RESULT(sberr); 1296 1297 size_t num_bkpts = bp_ids.GetSize(); 1298 for (size_t i = 0; i < num_bkpts; i++) { 1299 BreakpointID bp_id = bp_ids.GetBreakpointIDAtIndex(i); 1300 new_bps.AppendByID(bp_id.GetBreakpointID()); 1301 } 1302 return LLDB_RECORD_RESULT(sberr); 1303 } 1304 1305 lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file) { 1306 LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile, 1307 (lldb::SBFileSpec &), dest_file); 1308 1309 SBError sberr; 1310 TargetSP target_sp(GetSP()); 1311 if (!target_sp) { 1312 sberr.SetErrorString("BreakpointWriteToFile called with invalid target."); 1313 return LLDB_RECORD_RESULT(sberr); 1314 } 1315 SBBreakpointList bkpt_list(*this); 1316 return LLDB_RECORD_RESULT(BreakpointsWriteToFile(dest_file, bkpt_list)); 1317 } 1318 1319 lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file, 1320 SBBreakpointList &bkpt_list, 1321 bool append) { 1322 LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile, 1323 (lldb::SBFileSpec &, lldb::SBBreakpointList &, bool), 1324 dest_file, bkpt_list, append); 1325 1326 SBError sberr; 1327 TargetSP target_sp(GetSP()); 1328 if (!target_sp) { 1329 sberr.SetErrorString("BreakpointWriteToFile called with invalid target."); 1330 return LLDB_RECORD_RESULT(sberr); 1331 } 1332 1333 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1334 BreakpointIDList bp_id_list; 1335 bkpt_list.CopyToBreakpointIDList(bp_id_list); 1336 sberr.ref() = target_sp->SerializeBreakpointsToFile(dest_file.ref(), 1337 bp_id_list, append); 1338 return LLDB_RECORD_RESULT(sberr); 1339 } 1340 1341 uint32_t SBTarget::GetNumWatchpoints() const { 1342 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumWatchpoints); 1343 1344 TargetSP target_sp(GetSP()); 1345 if (target_sp) { 1346 // The watchpoint list is thread safe, no need to lock 1347 return target_sp->GetWatchpointList().GetSize(); 1348 } 1349 return 0; 1350 } 1351 1352 SBWatchpoint SBTarget::GetWatchpointAtIndex(uint32_t idx) const { 1353 LLDB_RECORD_METHOD_CONST(lldb::SBWatchpoint, SBTarget, GetWatchpointAtIndex, 1354 (uint32_t), idx); 1355 1356 SBWatchpoint sb_watchpoint; 1357 TargetSP target_sp(GetSP()); 1358 if (target_sp) { 1359 // The watchpoint list is thread safe, no need to lock 1360 sb_watchpoint.SetSP(target_sp->GetWatchpointList().GetByIndex(idx)); 1361 } 1362 return LLDB_RECORD_RESULT(sb_watchpoint); 1363 } 1364 1365 bool SBTarget::DeleteWatchpoint(watch_id_t wp_id) { 1366 LLDB_RECORD_METHOD(bool, SBTarget, DeleteWatchpoint, (lldb::watch_id_t), 1367 wp_id); 1368 1369 1370 bool result = false; 1371 TargetSP target_sp(GetSP()); 1372 if (target_sp) { 1373 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1374 std::unique_lock<std::recursive_mutex> lock; 1375 target_sp->GetWatchpointList().GetListMutex(lock); 1376 result = target_sp->RemoveWatchpointByID(wp_id); 1377 } 1378 1379 return result; 1380 } 1381 1382 SBWatchpoint SBTarget::FindWatchpointByID(lldb::watch_id_t wp_id) { 1383 LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBTarget, FindWatchpointByID, 1384 (lldb::watch_id_t), wp_id); 1385 1386 1387 SBWatchpoint sb_watchpoint; 1388 lldb::WatchpointSP watchpoint_sp; 1389 TargetSP target_sp(GetSP()); 1390 if (target_sp && wp_id != LLDB_INVALID_WATCH_ID) { 1391 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1392 std::unique_lock<std::recursive_mutex> lock; 1393 target_sp->GetWatchpointList().GetListMutex(lock); 1394 watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id); 1395 sb_watchpoint.SetSP(watchpoint_sp); 1396 } 1397 1398 return LLDB_RECORD_RESULT(sb_watchpoint); 1399 } 1400 1401 lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size, 1402 bool read, bool write, 1403 SBError &error) { 1404 LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBTarget, WatchAddress, 1405 (lldb::addr_t, size_t, bool, bool, lldb::SBError &), addr, 1406 size, read, write, error); 1407 1408 SBWatchpoint sb_watchpoint; 1409 lldb::WatchpointSP watchpoint_sp; 1410 TargetSP target_sp(GetSP()); 1411 if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS && 1412 size > 0) { 1413 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1414 uint32_t watch_type = 0; 1415 if (read) 1416 watch_type |= LLDB_WATCH_TYPE_READ; 1417 if (write) 1418 watch_type |= LLDB_WATCH_TYPE_WRITE; 1419 if (watch_type == 0) { 1420 error.SetErrorString( 1421 "Can't create a watchpoint that is neither read nor write."); 1422 return LLDB_RECORD_RESULT(sb_watchpoint); 1423 } 1424 1425 // Target::CreateWatchpoint() is thread safe. 1426 Status cw_error; 1427 // This API doesn't take in a type, so we can't figure out what it is. 1428 CompilerType *type = NULL; 1429 watchpoint_sp = 1430 target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error); 1431 error.SetError(cw_error); 1432 sb_watchpoint.SetSP(watchpoint_sp); 1433 } 1434 1435 return LLDB_RECORD_RESULT(sb_watchpoint); 1436 } 1437 1438 bool SBTarget::EnableAllWatchpoints() { 1439 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, EnableAllWatchpoints); 1440 1441 TargetSP target_sp(GetSP()); 1442 if (target_sp) { 1443 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1444 std::unique_lock<std::recursive_mutex> lock; 1445 target_sp->GetWatchpointList().GetListMutex(lock); 1446 target_sp->EnableAllWatchpoints(); 1447 return true; 1448 } 1449 return false; 1450 } 1451 1452 bool SBTarget::DisableAllWatchpoints() { 1453 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DisableAllWatchpoints); 1454 1455 TargetSP target_sp(GetSP()); 1456 if (target_sp) { 1457 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1458 std::unique_lock<std::recursive_mutex> lock; 1459 target_sp->GetWatchpointList().GetListMutex(lock); 1460 target_sp->DisableAllWatchpoints(); 1461 return true; 1462 } 1463 return false; 1464 } 1465 1466 SBValue SBTarget::CreateValueFromAddress(const char *name, SBAddress addr, 1467 SBType type) { 1468 LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromAddress, 1469 (const char *, lldb::SBAddress, lldb::SBType), name, addr, 1470 type); 1471 1472 SBValue sb_value; 1473 lldb::ValueObjectSP new_value_sp; 1474 if (IsValid() && name && *name && addr.IsValid() && type.IsValid()) { 1475 lldb::addr_t load_addr(addr.GetLoadAddress(*this)); 1476 ExecutionContext exe_ctx( 1477 ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false))); 1478 CompilerType ast_type(type.GetSP()->GetCompilerType(true)); 1479 new_value_sp = ValueObject::CreateValueObjectFromAddress(name, load_addr, 1480 exe_ctx, ast_type); 1481 } 1482 sb_value.SetSP(new_value_sp); 1483 return LLDB_RECORD_RESULT(sb_value); 1484 } 1485 1486 lldb::SBValue SBTarget::CreateValueFromData(const char *name, lldb::SBData data, 1487 lldb::SBType type) { 1488 LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromData, 1489 (const char *, lldb::SBData, lldb::SBType), name, data, 1490 type); 1491 1492 SBValue sb_value; 1493 lldb::ValueObjectSP new_value_sp; 1494 if (IsValid() && name && *name && data.IsValid() && type.IsValid()) { 1495 DataExtractorSP extractor(*data); 1496 ExecutionContext exe_ctx( 1497 ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false))); 1498 CompilerType ast_type(type.GetSP()->GetCompilerType(true)); 1499 new_value_sp = ValueObject::CreateValueObjectFromData(name, *extractor, 1500 exe_ctx, ast_type); 1501 } 1502 sb_value.SetSP(new_value_sp); 1503 return LLDB_RECORD_RESULT(sb_value); 1504 } 1505 1506 lldb::SBValue SBTarget::CreateValueFromExpression(const char *name, 1507 const char *expr) { 1508 LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromExpression, 1509 (const char *, const char *), name, expr); 1510 1511 SBValue sb_value; 1512 lldb::ValueObjectSP new_value_sp; 1513 if (IsValid() && name && *name && expr && *expr) { 1514 ExecutionContext exe_ctx( 1515 ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false))); 1516 new_value_sp = 1517 ValueObject::CreateValueObjectFromExpression(name, expr, exe_ctx); 1518 } 1519 sb_value.SetSP(new_value_sp); 1520 return LLDB_RECORD_RESULT(sb_value); 1521 } 1522 1523 bool SBTarget::DeleteAllWatchpoints() { 1524 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DeleteAllWatchpoints); 1525 1526 TargetSP target_sp(GetSP()); 1527 if (target_sp) { 1528 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 1529 std::unique_lock<std::recursive_mutex> lock; 1530 target_sp->GetWatchpointList().GetListMutex(lock); 1531 target_sp->RemoveAllWatchpoints(); 1532 return true; 1533 } 1534 return false; 1535 } 1536 1537 void SBTarget::AppendImageSearchPath(const char *from, const char *to, 1538 lldb::SBError &error) { 1539 LLDB_RECORD_METHOD(void, SBTarget, AppendImageSearchPath, 1540 (const char *, const char *, lldb::SBError &), from, to, 1541 error); 1542 1543 TargetSP target_sp(GetSP()); 1544 if (!target_sp) 1545 return error.SetErrorString("invalid target"); 1546 1547 const ConstString csFrom(from), csTo(to); 1548 if (!csFrom) 1549 return error.SetErrorString("<from> path can't be empty"); 1550 if (!csTo) 1551 return error.SetErrorString("<to> path can't be empty"); 1552 1553 target_sp->GetImageSearchPathList().Append(csFrom, csTo, true); 1554 } 1555 1556 lldb::SBModule SBTarget::AddModule(const char *path, const char *triple, 1557 const char *uuid_cstr) { 1558 LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule, 1559 (const char *, const char *, const char *), path, triple, 1560 uuid_cstr); 1561 1562 return LLDB_RECORD_RESULT(AddModule(path, triple, uuid_cstr, NULL)); 1563 } 1564 1565 lldb::SBModule SBTarget::AddModule(const char *path, const char *triple, 1566 const char *uuid_cstr, const char *symfile) { 1567 LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule, 1568 (const char *, const char *, const char *, const char *), 1569 path, triple, uuid_cstr, symfile); 1570 1571 lldb::SBModule sb_module; 1572 TargetSP target_sp(GetSP()); 1573 if (target_sp) { 1574 ModuleSpec module_spec; 1575 if (path) 1576 module_spec.GetFileSpec().SetFile(path, FileSpec::Style::native); 1577 1578 if (uuid_cstr) 1579 module_spec.GetUUID().SetFromStringRef(uuid_cstr); 1580 1581 if (triple) 1582 module_spec.GetArchitecture() = Platform::GetAugmentedArchSpec( 1583 target_sp->GetPlatform().get(), triple); 1584 else 1585 module_spec.GetArchitecture() = target_sp->GetArchitecture(); 1586 1587 if (symfile) 1588 module_spec.GetSymbolFileSpec().SetFile(symfile, FileSpec::Style::native); 1589 1590 sb_module.SetSP(target_sp->GetOrCreateModule(module_spec, true /* notify */)); 1591 } 1592 return LLDB_RECORD_RESULT(sb_module); 1593 } 1594 1595 lldb::SBModule SBTarget::AddModule(const SBModuleSpec &module_spec) { 1596 LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule, 1597 (const lldb::SBModuleSpec &), module_spec); 1598 1599 lldb::SBModule sb_module; 1600 TargetSP target_sp(GetSP()); 1601 if (target_sp) 1602 sb_module.SetSP(target_sp->GetOrCreateModule(*module_spec.m_opaque_up, 1603 true /* notify */)); 1604 return LLDB_RECORD_RESULT(sb_module); 1605 } 1606 1607 bool SBTarget::AddModule(lldb::SBModule &module) { 1608 LLDB_RECORD_METHOD(bool, SBTarget, AddModule, (lldb::SBModule &), module); 1609 1610 TargetSP target_sp(GetSP()); 1611 if (target_sp) { 1612 target_sp->GetImages().AppendIfNeeded(module.GetSP()); 1613 return true; 1614 } 1615 return false; 1616 } 1617 1618 uint32_t SBTarget::GetNumModules() const { 1619 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumModules); 1620 1621 uint32_t num = 0; 1622 TargetSP target_sp(GetSP()); 1623 if (target_sp) { 1624 // The module list is thread safe, no need to lock 1625 num = target_sp->GetImages().GetSize(); 1626 } 1627 1628 return num; 1629 } 1630 1631 void SBTarget::Clear() { 1632 LLDB_RECORD_METHOD_NO_ARGS(void, SBTarget, Clear); 1633 1634 m_opaque_sp.reset(); 1635 } 1636 1637 SBModule SBTarget::FindModule(const SBFileSpec &sb_file_spec) { 1638 LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, FindModule, 1639 (const lldb::SBFileSpec &), sb_file_spec); 1640 1641 SBModule sb_module; 1642 TargetSP target_sp(GetSP()); 1643 if (target_sp && sb_file_spec.IsValid()) { 1644 ModuleSpec module_spec(*sb_file_spec); 1645 // The module list is thread safe, no need to lock 1646 sb_module.SetSP(target_sp->GetImages().FindFirstModule(module_spec)); 1647 } 1648 return LLDB_RECORD_RESULT(sb_module); 1649 } 1650 1651 SBSymbolContextList SBTarget::FindCompileUnits(const SBFileSpec &sb_file_spec) { 1652 LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindCompileUnits, 1653 (const lldb::SBFileSpec &), sb_file_spec); 1654 1655 SBSymbolContextList sb_sc_list; 1656 const TargetSP target_sp(GetSP()); 1657 if (target_sp && sb_file_spec.IsValid()) { 1658 const bool append = true; 1659 target_sp->GetImages().FindCompileUnits(*sb_file_spec, 1660 append, *sb_sc_list); 1661 } 1662 return LLDB_RECORD_RESULT(sb_sc_list); 1663 } 1664 1665 lldb::ByteOrder SBTarget::GetByteOrder() { 1666 LLDB_RECORD_METHOD_NO_ARGS(lldb::ByteOrder, SBTarget, GetByteOrder); 1667 1668 TargetSP target_sp(GetSP()); 1669 if (target_sp) 1670 return target_sp->GetArchitecture().GetByteOrder(); 1671 return eByteOrderInvalid; 1672 } 1673 1674 const char *SBTarget::GetTriple() { 1675 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTarget, GetTriple); 1676 1677 TargetSP target_sp(GetSP()); 1678 if (target_sp) { 1679 std::string triple(target_sp->GetArchitecture().GetTriple().str()); 1680 // Unique the string so we don't run into ownership issues since the const 1681 // strings put the string into the string pool once and the strings never 1682 // comes out 1683 ConstString const_triple(triple.c_str()); 1684 return const_triple.GetCString(); 1685 } 1686 return NULL; 1687 } 1688 1689 uint32_t SBTarget::GetDataByteSize() { 1690 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetDataByteSize); 1691 1692 TargetSP target_sp(GetSP()); 1693 if (target_sp) { 1694 return target_sp->GetArchitecture().GetDataByteSize(); 1695 } 1696 return 0; 1697 } 1698 1699 uint32_t SBTarget::GetCodeByteSize() { 1700 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetCodeByteSize); 1701 1702 TargetSP target_sp(GetSP()); 1703 if (target_sp) { 1704 return target_sp->GetArchitecture().GetCodeByteSize(); 1705 } 1706 return 0; 1707 } 1708 1709 uint32_t SBTarget::GetAddressByteSize() { 1710 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetAddressByteSize); 1711 1712 TargetSP target_sp(GetSP()); 1713 if (target_sp) 1714 return target_sp->GetArchitecture().GetAddressByteSize(); 1715 return sizeof(void *); 1716 } 1717 1718 SBModule SBTarget::GetModuleAtIndex(uint32_t idx) { 1719 LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndex, (uint32_t), 1720 idx); 1721 1722 SBModule sb_module; 1723 ModuleSP module_sp; 1724 TargetSP target_sp(GetSP()); 1725 if (target_sp) { 1726 // The module list is thread safe, no need to lock 1727 module_sp = target_sp->GetImages().GetModuleAtIndex(idx); 1728 sb_module.SetSP(module_sp); 1729 } 1730 1731 return LLDB_RECORD_RESULT(sb_module); 1732 } 1733 1734 bool SBTarget::RemoveModule(lldb::SBModule module) { 1735 LLDB_RECORD_METHOD(bool, SBTarget, RemoveModule, (lldb::SBModule), module); 1736 1737 TargetSP target_sp(GetSP()); 1738 if (target_sp) 1739 return target_sp->GetImages().Remove(module.GetSP()); 1740 return false; 1741 } 1742 1743 SBBroadcaster SBTarget::GetBroadcaster() const { 1744 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBroadcaster, SBTarget, 1745 GetBroadcaster); 1746 1747 1748 TargetSP target_sp(GetSP()); 1749 SBBroadcaster broadcaster(target_sp.get(), false); 1750 1751 1752 return LLDB_RECORD_RESULT(broadcaster); 1753 } 1754 1755 bool SBTarget::GetDescription(SBStream &description, 1756 lldb::DescriptionLevel description_level) { 1757 LLDB_RECORD_METHOD(bool, SBTarget, GetDescription, 1758 (lldb::SBStream &, lldb::DescriptionLevel), description, 1759 description_level); 1760 1761 Stream &strm = description.ref(); 1762 1763 TargetSP target_sp(GetSP()); 1764 if (target_sp) { 1765 target_sp->Dump(&strm, description_level); 1766 } else 1767 strm.PutCString("No value"); 1768 1769 return true; 1770 } 1771 1772 lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name, 1773 uint32_t name_type_mask) { 1774 LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindFunctions, 1775 (const char *, uint32_t), name, name_type_mask); 1776 1777 lldb::SBSymbolContextList sb_sc_list; 1778 if (!name | !name[0]) 1779 return LLDB_RECORD_RESULT(sb_sc_list); 1780 1781 TargetSP target_sp(GetSP()); 1782 if (!target_sp) 1783 return LLDB_RECORD_RESULT(sb_sc_list); 1784 1785 const bool symbols_ok = true; 1786 const bool inlines_ok = true; 1787 const bool append = true; 1788 FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask); 1789 target_sp->GetImages().FindFunctions(ConstString(name), mask, symbols_ok, 1790 inlines_ok, append, *sb_sc_list); 1791 return LLDB_RECORD_RESULT(sb_sc_list); 1792 } 1793 1794 lldb::SBSymbolContextList SBTarget::FindGlobalFunctions(const char *name, 1795 uint32_t max_matches, 1796 MatchType matchtype) { 1797 LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindGlobalFunctions, 1798 (const char *, uint32_t, lldb::MatchType), name, 1799 max_matches, matchtype); 1800 1801 lldb::SBSymbolContextList sb_sc_list; 1802 if (name && name[0]) { 1803 llvm::StringRef name_ref(name); 1804 TargetSP target_sp(GetSP()); 1805 if (target_sp) { 1806 std::string regexstr; 1807 switch (matchtype) { 1808 case eMatchTypeRegex: 1809 target_sp->GetImages().FindFunctions(RegularExpression(name_ref), true, 1810 true, true, *sb_sc_list); 1811 break; 1812 case eMatchTypeStartsWith: 1813 regexstr = llvm::Regex::escape(name) + ".*"; 1814 target_sp->GetImages().FindFunctions(RegularExpression(regexstr), true, 1815 true, true, *sb_sc_list); 1816 break; 1817 default: 1818 target_sp->GetImages().FindFunctions(ConstString(name), 1819 eFunctionNameTypeAny, true, true, 1820 true, *sb_sc_list); 1821 break; 1822 } 1823 } 1824 } 1825 return LLDB_RECORD_RESULT(sb_sc_list); 1826 } 1827 1828 lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) { 1829 LLDB_RECORD_METHOD(lldb::SBType, SBTarget, FindFirstType, (const char *), 1830 typename_cstr); 1831 1832 TargetSP target_sp(GetSP()); 1833 if (typename_cstr && typename_cstr[0] && target_sp) { 1834 ConstString const_typename(typename_cstr); 1835 SymbolContext sc; 1836 const bool exact_match = false; 1837 1838 const ModuleList &module_list = target_sp->GetImages(); 1839 size_t count = module_list.GetSize(); 1840 for (size_t idx = 0; idx < count; idx++) { 1841 ModuleSP module_sp(module_list.GetModuleAtIndex(idx)); 1842 if (module_sp) { 1843 TypeSP type_sp( 1844 module_sp->FindFirstType(sc, const_typename, exact_match)); 1845 if (type_sp) 1846 return LLDB_RECORD_RESULT(SBType(type_sp)); 1847 } 1848 } 1849 1850 // Didn't find the type in the symbols; try the Objective-C runtime if one 1851 // is installed 1852 1853 ProcessSP process_sp(target_sp->GetProcessSP()); 1854 1855 if (process_sp) { 1856 ObjCLanguageRuntime *objc_language_runtime = 1857 process_sp->GetObjCLanguageRuntime(); 1858 1859 if (objc_language_runtime) { 1860 DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor(); 1861 1862 if (objc_decl_vendor) { 1863 std::vector<clang::NamedDecl *> decls; 1864 1865 if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) { 1866 if (CompilerType type = ClangASTContext::GetTypeForDecl(decls[0])) { 1867 return LLDB_RECORD_RESULT(SBType(type)); 1868 } 1869 } 1870 } 1871 } 1872 } 1873 1874 // No matches, search for basic typename matches 1875 ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext(); 1876 if (clang_ast) 1877 return LLDB_RECORD_RESULT(SBType(ClangASTContext::GetBasicType( 1878 clang_ast->getASTContext(), const_typename))); 1879 } 1880 return LLDB_RECORD_RESULT(SBType()); 1881 } 1882 1883 SBType SBTarget::GetBasicType(lldb::BasicType type) { 1884 LLDB_RECORD_METHOD(lldb::SBType, SBTarget, GetBasicType, (lldb::BasicType), 1885 type); 1886 1887 TargetSP target_sp(GetSP()); 1888 if (target_sp) { 1889 ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext(); 1890 if (clang_ast) 1891 return LLDB_RECORD_RESULT(SBType( 1892 ClangASTContext::GetBasicType(clang_ast->getASTContext(), type))); 1893 } 1894 return LLDB_RECORD_RESULT(SBType()); 1895 } 1896 1897 lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) { 1898 LLDB_RECORD_METHOD(lldb::SBTypeList, SBTarget, FindTypes, (const char *), 1899 typename_cstr); 1900 1901 SBTypeList sb_type_list; 1902 TargetSP target_sp(GetSP()); 1903 if (typename_cstr && typename_cstr[0] && target_sp) { 1904 ModuleList &images = target_sp->GetImages(); 1905 ConstString const_typename(typename_cstr); 1906 bool exact_match = false; 1907 TypeList type_list; 1908 llvm::DenseSet<SymbolFile *> searched_symbol_files; 1909 uint32_t num_matches = 1910 images.FindTypes(nullptr, const_typename, exact_match, UINT32_MAX, 1911 searched_symbol_files, type_list); 1912 1913 if (num_matches > 0) { 1914 for (size_t idx = 0; idx < num_matches; idx++) { 1915 TypeSP type_sp(type_list.GetTypeAtIndex(idx)); 1916 if (type_sp) 1917 sb_type_list.Append(SBType(type_sp)); 1918 } 1919 } 1920 1921 // Try the Objective-C runtime if one is installed 1922 1923 ProcessSP process_sp(target_sp->GetProcessSP()); 1924 1925 if (process_sp) { 1926 ObjCLanguageRuntime *objc_language_runtime = 1927 process_sp->GetObjCLanguageRuntime(); 1928 1929 if (objc_language_runtime) { 1930 DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor(); 1931 1932 if (objc_decl_vendor) { 1933 std::vector<clang::NamedDecl *> decls; 1934 1935 if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) { 1936 for (clang::NamedDecl *decl : decls) { 1937 if (CompilerType type = ClangASTContext::GetTypeForDecl(decl)) { 1938 sb_type_list.Append(SBType(type)); 1939 } 1940 } 1941 } 1942 } 1943 } 1944 } 1945 1946 if (sb_type_list.GetSize() == 0) { 1947 // No matches, search for basic typename matches 1948 ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext(); 1949 if (clang_ast) 1950 sb_type_list.Append(SBType(ClangASTContext::GetBasicType( 1951 clang_ast->getASTContext(), const_typename))); 1952 } 1953 } 1954 return LLDB_RECORD_RESULT(sb_type_list); 1955 } 1956 1957 SBValueList SBTarget::FindGlobalVariables(const char *name, 1958 uint32_t max_matches) { 1959 LLDB_RECORD_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables, 1960 (const char *, uint32_t), name, max_matches); 1961 1962 SBValueList sb_value_list; 1963 1964 TargetSP target_sp(GetSP()); 1965 if (name && target_sp) { 1966 VariableList variable_list; 1967 const uint32_t match_count = target_sp->GetImages().FindGlobalVariables( 1968 ConstString(name), max_matches, variable_list); 1969 1970 if (match_count > 0) { 1971 ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get(); 1972 if (exe_scope == NULL) 1973 exe_scope = target_sp.get(); 1974 for (uint32_t i = 0; i < match_count; ++i) { 1975 lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create( 1976 exe_scope, variable_list.GetVariableAtIndex(i))); 1977 if (valobj_sp) 1978 sb_value_list.Append(SBValue(valobj_sp)); 1979 } 1980 } 1981 } 1982 1983 return LLDB_RECORD_RESULT(sb_value_list); 1984 } 1985 1986 SBValueList SBTarget::FindGlobalVariables(const char *name, 1987 uint32_t max_matches, 1988 MatchType matchtype) { 1989 LLDB_RECORD_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables, 1990 (const char *, uint32_t, lldb::MatchType), name, 1991 max_matches, matchtype); 1992 1993 SBValueList sb_value_list; 1994 1995 TargetSP target_sp(GetSP()); 1996 if (name && target_sp) { 1997 llvm::StringRef name_ref(name); 1998 VariableList variable_list; 1999 2000 std::string regexstr; 2001 uint32_t match_count; 2002 switch (matchtype) { 2003 case eMatchTypeNormal: 2004 match_count = target_sp->GetImages().FindGlobalVariables( 2005 ConstString(name), max_matches, variable_list); 2006 break; 2007 case eMatchTypeRegex: 2008 match_count = target_sp->GetImages().FindGlobalVariables( 2009 RegularExpression(name_ref), max_matches, variable_list); 2010 break; 2011 case eMatchTypeStartsWith: 2012 regexstr = llvm::Regex::escape(name) + ".*"; 2013 match_count = target_sp->GetImages().FindGlobalVariables( 2014 RegularExpression(regexstr), max_matches, variable_list); 2015 break; 2016 } 2017 2018 if (match_count > 0) { 2019 ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get(); 2020 if (exe_scope == NULL) 2021 exe_scope = target_sp.get(); 2022 for (uint32_t i = 0; i < match_count; ++i) { 2023 lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create( 2024 exe_scope, variable_list.GetVariableAtIndex(i))); 2025 if (valobj_sp) 2026 sb_value_list.Append(SBValue(valobj_sp)); 2027 } 2028 } 2029 } 2030 2031 return LLDB_RECORD_RESULT(sb_value_list); 2032 } 2033 2034 lldb::SBValue SBTarget::FindFirstGlobalVariable(const char *name) { 2035 LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, FindFirstGlobalVariable, 2036 (const char *), name); 2037 2038 SBValueList sb_value_list(FindGlobalVariables(name, 1)); 2039 if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0) 2040 return LLDB_RECORD_RESULT(sb_value_list.GetValueAtIndex(0)); 2041 return LLDB_RECORD_RESULT(SBValue()); 2042 } 2043 2044 SBSourceManager SBTarget::GetSourceManager() { 2045 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSourceManager, SBTarget, GetSourceManager); 2046 2047 SBSourceManager source_manager(*this); 2048 return LLDB_RECORD_RESULT(source_manager); 2049 } 2050 2051 lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr, 2052 uint32_t count) { 2053 LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions, 2054 (lldb::SBAddress, uint32_t), base_addr, count); 2055 2056 return LLDB_RECORD_RESULT(ReadInstructions(base_addr, count, NULL)); 2057 } 2058 2059 lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr, 2060 uint32_t count, 2061 const char *flavor_string) { 2062 LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions, 2063 (lldb::SBAddress, uint32_t, const char *), base_addr, 2064 count, flavor_string); 2065 2066 SBInstructionList sb_instructions; 2067 2068 TargetSP target_sp(GetSP()); 2069 if (target_sp) { 2070 Address *addr_ptr = base_addr.get(); 2071 2072 if (addr_ptr) { 2073 DataBufferHeap data( 2074 target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0); 2075 bool prefer_file_cache = false; 2076 lldb_private::Status error; 2077 lldb::addr_t load_addr = LLDB_INVALID_ADDRESS; 2078 const size_t bytes_read = 2079 target_sp->ReadMemory(*addr_ptr, prefer_file_cache, data.GetBytes(), 2080 data.GetByteSize(), error, &load_addr); 2081 const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS; 2082 sb_instructions.SetDisassembler(Disassembler::DisassembleBytes( 2083 target_sp->GetArchitecture(), NULL, flavor_string, *addr_ptr, 2084 data.GetBytes(), bytes_read, count, data_from_file)); 2085 } 2086 } 2087 2088 return LLDB_RECORD_RESULT(sb_instructions); 2089 } 2090 2091 lldb::SBInstructionList SBTarget::GetInstructions(lldb::SBAddress base_addr, 2092 const void *buf, 2093 size_t size) { 2094 LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions, 2095 (lldb::SBAddress, const void *, size_t), base_addr, buf, 2096 size); 2097 2098 return GetInstructionsWithFlavor(base_addr, NULL, buf, size); 2099 } 2100 2101 lldb::SBInstructionList 2102 SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr, 2103 const char *flavor_string, const void *buf, 2104 size_t size) { 2105 LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, 2106 GetInstructionsWithFlavor, 2107 (lldb::SBAddress, const char *, const void *, size_t), 2108 base_addr, flavor_string, buf, size); 2109 2110 SBInstructionList sb_instructions; 2111 2112 TargetSP target_sp(GetSP()); 2113 if (target_sp) { 2114 Address addr; 2115 2116 if (base_addr.get()) 2117 addr = *base_addr.get(); 2118 2119 const bool data_from_file = true; 2120 2121 sb_instructions.SetDisassembler(Disassembler::DisassembleBytes( 2122 target_sp->GetArchitecture(), NULL, flavor_string, addr, buf, size, 2123 UINT32_MAX, data_from_file)); 2124 } 2125 2126 return sb_instructions; 2127 } 2128 2129 lldb::SBInstructionList SBTarget::GetInstructions(lldb::addr_t base_addr, 2130 const void *buf, 2131 size_t size) { 2132 LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions, 2133 (lldb::addr_t, const void *, size_t), base_addr, buf, size); 2134 2135 return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), NULL, buf, 2136 size); 2137 } 2138 2139 lldb::SBInstructionList 2140 SBTarget::GetInstructionsWithFlavor(lldb::addr_t base_addr, 2141 const char *flavor_string, const void *buf, 2142 size_t size) { 2143 LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, 2144 GetInstructionsWithFlavor, 2145 (lldb::addr_t, const char *, const void *, size_t), 2146 base_addr, flavor_string, buf, size); 2147 2148 return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), flavor_string, 2149 buf, size); 2150 } 2151 2152 SBError SBTarget::SetSectionLoadAddress(lldb::SBSection section, 2153 lldb::addr_t section_base_addr) { 2154 LLDB_RECORD_METHOD(lldb::SBError, SBTarget, SetSectionLoadAddress, 2155 (lldb::SBSection, lldb::addr_t), section, 2156 section_base_addr); 2157 2158 SBError sb_error; 2159 TargetSP target_sp(GetSP()); 2160 if (target_sp) { 2161 if (!section.IsValid()) { 2162 sb_error.SetErrorStringWithFormat("invalid section"); 2163 } else { 2164 SectionSP section_sp(section.GetSP()); 2165 if (section_sp) { 2166 if (section_sp->IsThreadSpecific()) { 2167 sb_error.SetErrorString( 2168 "thread specific sections are not yet supported"); 2169 } else { 2170 ProcessSP process_sp(target_sp->GetProcessSP()); 2171 if (target_sp->SetSectionLoadAddress(section_sp, section_base_addr)) { 2172 ModuleSP module_sp(section_sp->GetModule()); 2173 if (module_sp) { 2174 ModuleList module_list; 2175 module_list.Append(module_sp); 2176 target_sp->ModulesDidLoad(module_list); 2177 } 2178 // Flush info in the process (stack frames, etc) 2179 if (process_sp) 2180 process_sp->Flush(); 2181 } 2182 } 2183 } 2184 } 2185 } else { 2186 sb_error.SetErrorString("invalid target"); 2187 } 2188 return LLDB_RECORD_RESULT(sb_error); 2189 } 2190 2191 SBError SBTarget::ClearSectionLoadAddress(lldb::SBSection section) { 2192 LLDB_RECORD_METHOD(lldb::SBError, SBTarget, ClearSectionLoadAddress, 2193 (lldb::SBSection), section); 2194 2195 SBError sb_error; 2196 2197 TargetSP target_sp(GetSP()); 2198 if (target_sp) { 2199 if (!section.IsValid()) { 2200 sb_error.SetErrorStringWithFormat("invalid section"); 2201 } else { 2202 SectionSP section_sp(section.GetSP()); 2203 if (section_sp) { 2204 ProcessSP process_sp(target_sp->GetProcessSP()); 2205 if (target_sp->SetSectionUnloaded(section_sp)) { 2206 ModuleSP module_sp(section_sp->GetModule()); 2207 if (module_sp) { 2208 ModuleList module_list; 2209 module_list.Append(module_sp); 2210 target_sp->ModulesDidUnload(module_list, false); 2211 } 2212 // Flush info in the process (stack frames, etc) 2213 if (process_sp) 2214 process_sp->Flush(); 2215 } 2216 } else { 2217 sb_error.SetErrorStringWithFormat("invalid section"); 2218 } 2219 } 2220 } else { 2221 sb_error.SetErrorStringWithFormat("invalid target"); 2222 } 2223 return LLDB_RECORD_RESULT(sb_error); 2224 } 2225 2226 SBError SBTarget::SetModuleLoadAddress(lldb::SBModule module, 2227 int64_t slide_offset) { 2228 LLDB_RECORD_METHOD(lldb::SBError, SBTarget, SetModuleLoadAddress, 2229 (lldb::SBModule, int64_t), module, slide_offset); 2230 2231 SBError sb_error; 2232 2233 TargetSP target_sp(GetSP()); 2234 if (target_sp) { 2235 ModuleSP module_sp(module.GetSP()); 2236 if (module_sp) { 2237 bool changed = false; 2238 if (module_sp->SetLoadAddress(*target_sp, slide_offset, true, changed)) { 2239 // The load was successful, make sure that at least some sections 2240 // changed before we notify that our module was loaded. 2241 if (changed) { 2242 ModuleList module_list; 2243 module_list.Append(module_sp); 2244 target_sp->ModulesDidLoad(module_list); 2245 // Flush info in the process (stack frames, etc) 2246 ProcessSP process_sp(target_sp->GetProcessSP()); 2247 if (process_sp) 2248 process_sp->Flush(); 2249 } 2250 } 2251 } else { 2252 sb_error.SetErrorStringWithFormat("invalid module"); 2253 } 2254 2255 } else { 2256 sb_error.SetErrorStringWithFormat("invalid target"); 2257 } 2258 return LLDB_RECORD_RESULT(sb_error); 2259 } 2260 2261 SBError SBTarget::ClearModuleLoadAddress(lldb::SBModule module) { 2262 LLDB_RECORD_METHOD(lldb::SBError, SBTarget, ClearModuleLoadAddress, 2263 (lldb::SBModule), module); 2264 2265 SBError sb_error; 2266 2267 char path[PATH_MAX]; 2268 TargetSP target_sp(GetSP()); 2269 if (target_sp) { 2270 ModuleSP module_sp(module.GetSP()); 2271 if (module_sp) { 2272 ObjectFile *objfile = module_sp->GetObjectFile(); 2273 if (objfile) { 2274 SectionList *section_list = objfile->GetSectionList(); 2275 if (section_list) { 2276 ProcessSP process_sp(target_sp->GetProcessSP()); 2277 2278 bool changed = false; 2279 const size_t num_sections = section_list->GetSize(); 2280 for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) { 2281 SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx)); 2282 if (section_sp) 2283 changed |= target_sp->SetSectionUnloaded(section_sp); 2284 } 2285 if (changed) { 2286 ModuleList module_list; 2287 module_list.Append(module_sp); 2288 target_sp->ModulesDidUnload(module_list, false); 2289 // Flush info in the process (stack frames, etc) 2290 ProcessSP process_sp(target_sp->GetProcessSP()); 2291 if (process_sp) 2292 process_sp->Flush(); 2293 } 2294 } else { 2295 module_sp->GetFileSpec().GetPath(path, sizeof(path)); 2296 sb_error.SetErrorStringWithFormat("no sections in object file '%s'", 2297 path); 2298 } 2299 } else { 2300 module_sp->GetFileSpec().GetPath(path, sizeof(path)); 2301 sb_error.SetErrorStringWithFormat("no object file for module '%s'", 2302 path); 2303 } 2304 } else { 2305 sb_error.SetErrorStringWithFormat("invalid module"); 2306 } 2307 } else { 2308 sb_error.SetErrorStringWithFormat("invalid target"); 2309 } 2310 return LLDB_RECORD_RESULT(sb_error); 2311 } 2312 2313 lldb::SBSymbolContextList SBTarget::FindSymbols(const char *name, 2314 lldb::SymbolType symbol_type) { 2315 LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindSymbols, 2316 (const char *, lldb::SymbolType), name, symbol_type); 2317 2318 SBSymbolContextList sb_sc_list; 2319 if (name && name[0]) { 2320 TargetSP target_sp(GetSP()); 2321 if (target_sp) { 2322 bool append = true; 2323 target_sp->GetImages().FindSymbolsWithNameAndType( 2324 ConstString(name), symbol_type, *sb_sc_list, append); 2325 } 2326 } 2327 return LLDB_RECORD_RESULT(sb_sc_list); 2328 } 2329 2330 lldb::SBValue SBTarget::EvaluateExpression(const char *expr) { 2331 LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, EvaluateExpression, 2332 (const char *), expr); 2333 2334 TargetSP target_sp(GetSP()); 2335 if (!target_sp) 2336 return LLDB_RECORD_RESULT(SBValue()); 2337 2338 SBExpressionOptions options; 2339 lldb::DynamicValueType fetch_dynamic_value = 2340 target_sp->GetPreferDynamicValue(); 2341 options.SetFetchDynamicValue(fetch_dynamic_value); 2342 options.SetUnwindOnError(true); 2343 return LLDB_RECORD_RESULT(EvaluateExpression(expr, options)); 2344 } 2345 2346 lldb::SBValue SBTarget::EvaluateExpression(const char *expr, 2347 const SBExpressionOptions &options) { 2348 LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, EvaluateExpression, 2349 (const char *, const lldb::SBExpressionOptions &), expr, 2350 options); 2351 2352 Log *expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); 2353 SBValue expr_result; 2354 ValueObjectSP expr_value_sp; 2355 TargetSP target_sp(GetSP()); 2356 StackFrame *frame = NULL; 2357 if (target_sp) { 2358 if (expr == NULL || expr[0] == '\0') { 2359 return LLDB_RECORD_RESULT(expr_result); 2360 } 2361 2362 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 2363 ExecutionContext exe_ctx(m_opaque_sp.get()); 2364 2365 2366 frame = exe_ctx.GetFramePtr(); 2367 Target *target = exe_ctx.GetTargetPtr(); 2368 2369 if (target) { 2370 #ifdef LLDB_CONFIGURATION_DEBUG 2371 StreamString frame_description; 2372 if (frame) 2373 frame->DumpUsingSettingsFormat(&frame_description); 2374 llvm::PrettyStackTraceFormat stack_trace( 2375 "SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = " 2376 "%u) %s", 2377 expr, options.GetFetchDynamicValue(), 2378 frame_description.GetString().str().c_str()); 2379 #endif 2380 target->EvaluateExpression(expr, frame, expr_value_sp, options.ref()); 2381 2382 expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue()); 2383 } 2384 } 2385 if (expr_log) 2386 expr_log->Printf("** [SBTarget::EvaluateExpression] Expression result is " 2387 "%s, summary %s **", 2388 expr_result.GetValue(), expr_result.GetSummary()); 2389 return LLDB_RECORD_RESULT(expr_result); 2390 } 2391 2392 lldb::addr_t SBTarget::GetStackRedZoneSize() { 2393 LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBTarget, GetStackRedZoneSize); 2394 2395 TargetSP target_sp(GetSP()); 2396 if (target_sp) { 2397 ABISP abi_sp; 2398 ProcessSP process_sp(target_sp->GetProcessSP()); 2399 if (process_sp) 2400 abi_sp = process_sp->GetABI(); 2401 else 2402 abi_sp = ABI::FindPlugin(ProcessSP(), target_sp->GetArchitecture()); 2403 if (abi_sp) 2404 return abi_sp->GetRedZoneSize(); 2405 } 2406 return 0; 2407 } 2408 2409 lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const { 2410 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo); 2411 2412 lldb::SBLaunchInfo launch_info(NULL); 2413 TargetSP target_sp(GetSP()); 2414 if (target_sp) 2415 launch_info.set_ref(m_opaque_sp->GetProcessLaunchInfo()); 2416 return LLDB_RECORD_RESULT(launch_info); 2417 } 2418 2419 void SBTarget::SetLaunchInfo(const lldb::SBLaunchInfo &launch_info) { 2420 LLDB_RECORD_METHOD(void, SBTarget, SetLaunchInfo, 2421 (const lldb::SBLaunchInfo &), launch_info); 2422 2423 TargetSP target_sp(GetSP()); 2424 if (target_sp) 2425 m_opaque_sp->SetProcessLaunchInfo(launch_info.ref()); 2426 } 2427 2428 namespace lldb_private { 2429 namespace repro { 2430 2431 template <> 2432 void RegisterMethods<SBTarget>(Registry &R) { 2433 LLDB_REGISTER_CONSTRUCTOR(SBTarget, ()); 2434 LLDB_REGISTER_CONSTRUCTOR(SBTarget, (const lldb::SBTarget &)); 2435 LLDB_REGISTER_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &)); 2436 LLDB_REGISTER_METHOD(const lldb::SBTarget &, 2437 SBTarget, operator=,(const lldb::SBTarget &)); 2438 LLDB_REGISTER_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent, 2439 (const lldb::SBEvent &)); 2440 LLDB_REGISTER_STATIC_METHOD(lldb::SBTarget, SBTarget, GetTargetFromEvent, 2441 (const lldb::SBEvent &)); 2442 LLDB_REGISTER_STATIC_METHOD(uint32_t, SBTarget, GetNumModulesFromEvent, 2443 (const lldb::SBEvent &)); 2444 LLDB_REGISTER_STATIC_METHOD(lldb::SBModule, SBTarget, 2445 GetModuleAtIndexFromEvent, 2446 (const uint32_t, const lldb::SBEvent &)); 2447 LLDB_REGISTER_STATIC_METHOD(const char *, SBTarget, GetBroadcasterClassName, 2448 ()); 2449 LLDB_REGISTER_METHOD_CONST(bool, SBTarget, IsValid, ()); 2450 LLDB_REGISTER_METHOD_CONST(bool, SBTarget, operator bool, ()); 2451 LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, GetProcess, ()); 2452 LLDB_REGISTER_METHOD(lldb::SBPlatform, SBTarget, GetPlatform, ()); 2453 LLDB_REGISTER_METHOD_CONST(lldb::SBDebugger, SBTarget, GetDebugger, ()); 2454 LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBTarget, GetStatistics, ()); 2455 LLDB_REGISTER_METHOD(void, SBTarget, SetCollectingStats, (bool)); 2456 LLDB_REGISTER_METHOD(bool, SBTarget, GetCollectingStats, ()); 2457 LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LoadCore, (const char *)); 2458 LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LoadCore, 2459 (const char *, lldb::SBError &)); 2460 LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LaunchSimple, 2461 (const char **, const char **, const char *)); 2462 LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, Install, ()); 2463 LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Launch, 2464 (lldb::SBListener &, const char **, const char **, 2465 const char *, const char *, const char *, 2466 const char *, uint32_t, bool, lldb::SBError &)); 2467 LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Launch, 2468 (lldb::SBLaunchInfo &, lldb::SBError &)); 2469 LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Attach, 2470 (lldb::SBAttachInfo &, lldb::SBError &)); 2471 LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithID, 2472 (lldb::SBListener &, lldb::pid_t, lldb::SBError &)); 2473 LLDB_REGISTER_METHOD( 2474 lldb::SBProcess, SBTarget, AttachToProcessWithName, 2475 (lldb::SBListener &, const char *, bool, lldb::SBError &)); 2476 LLDB_REGISTER_METHOD( 2477 lldb::SBProcess, SBTarget, ConnectRemote, 2478 (lldb::SBListener &, const char *, const char *, lldb::SBError &)); 2479 LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBTarget, GetExecutable, ()); 2480 LLDB_REGISTER_METHOD_CONST(bool, 2481 SBTarget, operator==,(const lldb::SBTarget &)); 2482 LLDB_REGISTER_METHOD_CONST(bool, 2483 SBTarget, operator!=,(const lldb::SBTarget &)); 2484 LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolveLoadAddress, 2485 (lldb::addr_t)); 2486 LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolveFileAddress, 2487 (lldb::addr_t)); 2488 LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolvePastLoadAddress, 2489 (uint32_t, lldb::addr_t)); 2490 LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBTarget, 2491 ResolveSymbolContextForAddress, 2492 (const lldb::SBAddress &, uint32_t)); 2493 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, 2494 BreakpointCreateByLocation, (const char *, uint32_t)); 2495 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, 2496 BreakpointCreateByLocation, 2497 (const lldb::SBFileSpec &, uint32_t)); 2498 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, 2499 BreakpointCreateByLocation, 2500 (const lldb::SBFileSpec &, uint32_t, lldb::addr_t)); 2501 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, 2502 BreakpointCreateByLocation, 2503 (const lldb::SBFileSpec &, uint32_t, lldb::addr_t, 2504 lldb::SBFileSpecList &)); 2505 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, 2506 BreakpointCreateByLocation, 2507 (const lldb::SBFileSpec &, uint32_t, uint32_t, 2508 lldb::addr_t, lldb::SBFileSpecList &)); 2509 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, 2510 (const char *, const char *)); 2511 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, 2512 (const char *, const lldb::SBFileSpecList &, 2513 const lldb::SBFileSpecList &)); 2514 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, 2515 (const char *, uint32_t, const lldb::SBFileSpecList &, 2516 const lldb::SBFileSpecList &)); 2517 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, 2518 (const char *, uint32_t, lldb::LanguageType, 2519 const lldb::SBFileSpecList &, 2520 const lldb::SBFileSpecList &)); 2521 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, 2522 (const char **, uint32_t, uint32_t, 2523 const lldb::SBFileSpecList &, 2524 const lldb::SBFileSpecList &)); 2525 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, 2526 (const char **, uint32_t, uint32_t, lldb::LanguageType, 2527 const lldb::SBFileSpecList &, 2528 const lldb::SBFileSpecList &)); 2529 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, 2530 (const char **, uint32_t, uint32_t, lldb::LanguageType, 2531 lldb::addr_t, const lldb::SBFileSpecList &, 2532 const lldb::SBFileSpecList &)); 2533 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, 2534 (const char *, const char *)); 2535 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, 2536 (const char *, const lldb::SBFileSpecList &, 2537 const lldb::SBFileSpecList &)); 2538 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, 2539 (const char *, lldb::LanguageType, 2540 const lldb::SBFileSpecList &, 2541 const lldb::SBFileSpecList &)); 2542 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, 2543 BreakpointCreateByAddress, (lldb::addr_t)); 2544 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, 2545 BreakpointCreateBySBAddress, (lldb::SBAddress &)); 2546 LLDB_REGISTER_METHOD( 2547 lldb::SBBreakpoint, SBTarget, BreakpointCreateBySourceRegex, 2548 (const char *, const lldb::SBFileSpec &, const char *)); 2549 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, 2550 BreakpointCreateBySourceRegex, 2551 (const char *, const lldb::SBFileSpecList &, 2552 const lldb::SBFileSpecList &)); 2553 LLDB_REGISTER_METHOD( 2554 lldb::SBBreakpoint, SBTarget, BreakpointCreateBySourceRegex, 2555 (const char *, const lldb::SBFileSpecList &, 2556 const lldb::SBFileSpecList &, const lldb::SBStringList &)); 2557 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, 2558 BreakpointCreateForException, 2559 (lldb::LanguageType, bool, bool)); 2560 LLDB_REGISTER_METHOD( 2561 lldb::SBBreakpoint, SBTarget, BreakpointCreateFromScript, 2562 (const char *, lldb::SBStructuredData &, const lldb::SBFileSpecList &, 2563 const lldb::SBFileSpecList &, bool)); 2564 LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumBreakpoints, ()); 2565 LLDB_REGISTER_METHOD_CONST(lldb::SBBreakpoint, SBTarget, 2566 GetBreakpointAtIndex, (uint32_t)); 2567 LLDB_REGISTER_METHOD(bool, SBTarget, BreakpointDelete, (lldb::break_id_t)); 2568 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, FindBreakpointByID, 2569 (lldb::break_id_t)); 2570 LLDB_REGISTER_METHOD(bool, SBTarget, FindBreakpointsByName, 2571 (const char *, lldb::SBBreakpointList &)); 2572 LLDB_REGISTER_METHOD(void, SBTarget, GetBreakpointNames, 2573 (lldb::SBStringList &)); 2574 LLDB_REGISTER_METHOD(void, SBTarget, DeleteBreakpointName, (const char *)); 2575 LLDB_REGISTER_METHOD(bool, SBTarget, EnableAllBreakpoints, ()); 2576 LLDB_REGISTER_METHOD(bool, SBTarget, DisableAllBreakpoints, ()); 2577 LLDB_REGISTER_METHOD(bool, SBTarget, DeleteAllBreakpoints, ()); 2578 LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsCreateFromFile, 2579 (lldb::SBFileSpec &, lldb::SBBreakpointList &)); 2580 LLDB_REGISTER_METHOD( 2581 lldb::SBError, SBTarget, BreakpointsCreateFromFile, 2582 (lldb::SBFileSpec &, lldb::SBStringList &, lldb::SBBreakpointList &)); 2583 LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile, 2584 (lldb::SBFileSpec &)); 2585 LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile, 2586 (lldb::SBFileSpec &, lldb::SBBreakpointList &, bool)); 2587 LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumWatchpoints, ()); 2588 LLDB_REGISTER_METHOD_CONST(lldb::SBWatchpoint, SBTarget, 2589 GetWatchpointAtIndex, (uint32_t)); 2590 LLDB_REGISTER_METHOD(bool, SBTarget, DeleteWatchpoint, (lldb::watch_id_t)); 2591 LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBTarget, FindWatchpointByID, 2592 (lldb::watch_id_t)); 2593 LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBTarget, WatchAddress, 2594 (lldb::addr_t, size_t, bool, bool, lldb::SBError &)); 2595 LLDB_REGISTER_METHOD(bool, SBTarget, EnableAllWatchpoints, ()); 2596 LLDB_REGISTER_METHOD(bool, SBTarget, DisableAllWatchpoints, ()); 2597 LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromAddress, 2598 (const char *, lldb::SBAddress, lldb::SBType)); 2599 LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromData, 2600 (const char *, lldb::SBData, lldb::SBType)); 2601 LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromExpression, 2602 (const char *, const char *)); 2603 LLDB_REGISTER_METHOD(bool, SBTarget, DeleteAllWatchpoints, ()); 2604 LLDB_REGISTER_METHOD(void, SBTarget, AppendImageSearchPath, 2605 (const char *, const char *, lldb::SBError &)); 2606 LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, AddModule, 2607 (const char *, const char *, const char *)); 2608 LLDB_REGISTER_METHOD( 2609 lldb::SBModule, SBTarget, AddModule, 2610 (const char *, const char *, const char *, const char *)); 2611 LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, AddModule, 2612 (const lldb::SBModuleSpec &)); 2613 LLDB_REGISTER_METHOD(bool, SBTarget, AddModule, (lldb::SBModule &)); 2614 LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumModules, ()); 2615 LLDB_REGISTER_METHOD(void, SBTarget, Clear, ()); 2616 LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, FindModule, 2617 (const lldb::SBFileSpec &)); 2618 LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindCompileUnits, 2619 (const lldb::SBFileSpec &)); 2620 LLDB_REGISTER_METHOD(lldb::ByteOrder, SBTarget, GetByteOrder, ()); 2621 LLDB_REGISTER_METHOD(const char *, SBTarget, GetTriple, ()); 2622 LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetDataByteSize, ()); 2623 LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetCodeByteSize, ()); 2624 LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetAddressByteSize, ()); 2625 LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndex, 2626 (uint32_t)); 2627 LLDB_REGISTER_METHOD(bool, SBTarget, RemoveModule, (lldb::SBModule)); 2628 LLDB_REGISTER_METHOD_CONST(lldb::SBBroadcaster, SBTarget, GetBroadcaster, 2629 ()); 2630 LLDB_REGISTER_METHOD(bool, SBTarget, GetDescription, 2631 (lldb::SBStream &, lldb::DescriptionLevel)); 2632 LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindFunctions, 2633 (const char *, uint32_t)); 2634 LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, 2635 FindGlobalFunctions, 2636 (const char *, uint32_t, lldb::MatchType)); 2637 LLDB_REGISTER_METHOD(lldb::SBType, SBTarget, FindFirstType, (const char *)); 2638 LLDB_REGISTER_METHOD(lldb::SBType, SBTarget, GetBasicType, 2639 (lldb::BasicType)); 2640 LLDB_REGISTER_METHOD(lldb::SBTypeList, SBTarget, FindTypes, (const char *)); 2641 LLDB_REGISTER_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables, 2642 (const char *, uint32_t)); 2643 LLDB_REGISTER_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables, 2644 (const char *, uint32_t, lldb::MatchType)); 2645 LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, FindFirstGlobalVariable, 2646 (const char *)); 2647 LLDB_REGISTER_METHOD(lldb::SBSourceManager, SBTarget, GetSourceManager, ()); 2648 LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions, 2649 (lldb::SBAddress, uint32_t)); 2650 LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions, 2651 (lldb::SBAddress, uint32_t, const char *)); 2652 LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, SetSectionLoadAddress, 2653 (lldb::SBSection, lldb::addr_t)); 2654 LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, ClearSectionLoadAddress, 2655 (lldb::SBSection)); 2656 LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, SetModuleLoadAddress, 2657 (lldb::SBModule, int64_t)); 2658 LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, ClearModuleLoadAddress, 2659 (lldb::SBModule)); 2660 LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindSymbols, 2661 (const char *, lldb::SymbolType)); 2662 LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression, 2663 (const char *)); 2664 LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression, 2665 (const char *, const lldb::SBExpressionOptions &)); 2666 LLDB_REGISTER_METHOD(lldb::addr_t, SBTarget, GetStackRedZoneSize, ()); 2667 LLDB_REGISTER_METHOD_CONST(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo, ()); 2668 LLDB_REGISTER_METHOD(void, SBTarget, SetLaunchInfo, 2669 (const lldb::SBLaunchInfo &)); 2670 } 2671 2672 } 2673 } 2674