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