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