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