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