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