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