SBTarget.h revision 321369
1254721Semaste//===-- SBTarget.h ----------------------------------------------*- C++ -*-===// 2254721Semaste// 3254721Semaste// The LLVM Compiler Infrastructure 4254721Semaste// 5254721Semaste// This file is distributed under the University of Illinois Open Source 6254721Semaste// License. See LICENSE.TXT for details. 7254721Semaste// 8254721Semaste//===----------------------------------------------------------------------===// 9254721Semaste 10254721Semaste#ifndef LLDB_SBTarget_h_ 11254721Semaste#define LLDB_SBTarget_h_ 12254721Semaste 13296417Sdim// C Includes 14296417Sdim// C++ Includes 15296417Sdim// Other libraries and framework includes 16296417Sdim// Project includes 17254721Semaste#include "lldb/API/SBAddress.h" 18288943Sdim#include "lldb/API/SBAttachInfo.h" 19314564Sdim#include "lldb/API/SBBreakpoint.h" 20254721Semaste#include "lldb/API/SBBroadcaster.h" 21314564Sdim#include "lldb/API/SBDefines.h" 22254721Semaste#include "lldb/API/SBFileSpec.h" 23254721Semaste#include "lldb/API/SBFileSpecList.h" 24288943Sdim#include "lldb/API/SBLaunchInfo.h" 25254721Semaste#include "lldb/API/SBSymbolContextList.h" 26254721Semaste#include "lldb/API/SBType.h" 27254721Semaste#include "lldb/API/SBValue.h" 28254721Semaste#include "lldb/API/SBWatchpoint.h" 29254721Semaste 30254721Semastenamespace lldb { 31254721Semaste 32280031Sdimclass SBPlatform; 33280031Sdim 34314564Sdimclass LLDB_API SBTarget { 35254721Semastepublic: 36314564Sdim //------------------------------------------------------------------ 37314564Sdim // Broadcaster bits. 38314564Sdim //------------------------------------------------------------------ 39314564Sdim enum { 40314564Sdim eBroadcastBitBreakpointChanged = (1 << 0), 41314564Sdim eBroadcastBitModulesLoaded = (1 << 1), 42314564Sdim eBroadcastBitModulesUnloaded = (1 << 2), 43314564Sdim eBroadcastBitWatchpointChanged = (1 << 3), 44314564Sdim eBroadcastBitSymbolsLoaded = (1 << 4) 45314564Sdim }; 46254721Semaste 47314564Sdim //------------------------------------------------------------------ 48314564Sdim // Constructors 49314564Sdim //------------------------------------------------------------------ 50314564Sdim SBTarget(); 51254721Semaste 52314564Sdim SBTarget(const lldb::SBTarget &rhs); 53254721Semaste 54314564Sdim SBTarget(const lldb::TargetSP &target_sp); 55254721Semaste 56314564Sdim //------------------------------------------------------------------ 57314564Sdim // Destructor 58314564Sdim //------------------------------------------------------------------ 59314564Sdim ~SBTarget(); 60296417Sdim 61314564Sdim const lldb::SBTarget &operator=(const lldb::SBTarget &rhs); 62288943Sdim 63314564Sdim bool IsValid() const; 64288943Sdim 65314564Sdim static bool EventIsTargetEvent(const lldb::SBEvent &event); 66288943Sdim 67314564Sdim static lldb::SBTarget GetTargetFromEvent(const lldb::SBEvent &event); 68288943Sdim 69314564Sdim static uint32_t GetNumModulesFromEvent(const lldb::SBEvent &event); 70254721Semaste 71314564Sdim static lldb::SBModule GetModuleAtIndexFromEvent(const uint32_t idx, 72314564Sdim const lldb::SBEvent &event); 73254721Semaste 74314564Sdim static const char *GetBroadcasterClassName(); 75280031Sdim 76314564Sdim lldb::SBProcess GetProcess(); 77296417Sdim 78314564Sdim //------------------------------------------------------------------ 79314564Sdim /// Return the platform object associated with the target. 80314564Sdim /// 81314564Sdim /// After return, the platform object should be checked for 82314564Sdim /// validity. 83314564Sdim /// 84314564Sdim /// @return 85314564Sdim /// A platform object. 86314564Sdim //------------------------------------------------------------------ 87314564Sdim lldb::SBPlatform GetPlatform(); 88296417Sdim 89314564Sdim //------------------------------------------------------------------ 90314564Sdim /// Install any binaries that need to be installed. 91314564Sdim /// 92314564Sdim /// This function does nothing when debugging on the host system. 93314564Sdim /// When connected to remote platforms, the target's main executable 94314564Sdim /// and any modules that have their remote install path set will be 95314564Sdim /// installed on the remote platform. If the main executable doesn't 96314564Sdim /// have an install location set, it will be installed in the remote 97314564Sdim /// platform's working directory. 98314564Sdim /// 99314564Sdim /// @return 100314564Sdim /// An error describing anything that went wrong during 101314564Sdim /// installation. 102314564Sdim //------------------------------------------------------------------ 103314564Sdim SBError Install(); 104254721Semaste 105314564Sdim //------------------------------------------------------------------ 106314564Sdim /// Launch a new process. 107314564Sdim /// 108314564Sdim /// Launch a new process by spawning a new process using the 109314564Sdim /// target object's executable module's file as the file to launch. 110314564Sdim /// Arguments are given in \a argv, and the environment variables 111314564Sdim /// are in \a envp. Standard input and output files can be 112314564Sdim /// optionally re-directed to \a stdin_path, \a stdout_path, and 113314564Sdim /// \a stderr_path. 114314564Sdim /// 115314564Sdim /// @param[in] listener 116314564Sdim /// An optional listener that will receive all process events. 117314564Sdim /// If \a listener is valid then \a listener will listen to all 118314564Sdim /// process events. If not valid, then this target's debugger 119314564Sdim /// (SBTarget::GetDebugger()) will listen to all process events. 120314564Sdim /// 121314564Sdim /// @param[in] argv 122314564Sdim /// The argument array. 123314564Sdim /// 124314564Sdim /// @param[in] envp 125314564Sdim /// The environment array. 126314564Sdim /// 127314564Sdim /// @param[in] stdin_path 128314564Sdim /// The path to use when re-directing the STDIN of the new 129314564Sdim /// process. If all stdXX_path arguments are nullptr, a pseudo 130314564Sdim /// terminal will be used. 131314564Sdim /// 132314564Sdim /// @param[in] stdout_path 133314564Sdim /// The path to use when re-directing the STDOUT of the new 134314564Sdim /// process. If all stdXX_path arguments are nullptr, a pseudo 135314564Sdim /// terminal will be used. 136314564Sdim /// 137314564Sdim /// @param[in] stderr_path 138314564Sdim /// The path to use when re-directing the STDERR of the new 139314564Sdim /// process. If all stdXX_path arguments are nullptr, a pseudo 140314564Sdim /// terminal will be used. 141314564Sdim /// 142314564Sdim /// @param[in] working_directory 143314564Sdim /// The working directory to have the child process run in 144314564Sdim /// 145314564Sdim /// @param[in] launch_flags 146314564Sdim /// Some launch options specified by logical OR'ing 147314564Sdim /// lldb::LaunchFlags enumeration values together. 148314564Sdim /// 149314564Sdim /// @param[in] stop_at_entry 150314564Sdim /// If false do not stop the inferior at the entry point. 151314564Sdim /// 152314564Sdim /// @param[out] error 153314564Sdim /// An error object. Contains the reason if there is some failure. 154314564Sdim /// 155314564Sdim /// @return 156314564Sdim /// A process object for the newly created process. 157314564Sdim //------------------------------------------------------------------ 158314564Sdim lldb::SBProcess Launch(SBListener &listener, char const **argv, 159314564Sdim char const **envp, const char *stdin_path, 160314564Sdim const char *stdout_path, const char *stderr_path, 161314564Sdim const char *working_directory, 162314564Sdim uint32_t launch_flags, // See LaunchFlags 163314564Sdim bool stop_at_entry, lldb::SBError &error); 164254721Semaste 165314564Sdim SBProcess LoadCore(const char *core_file); 166314564Sdim 167314564Sdim //------------------------------------------------------------------ 168314564Sdim /// Launch a new process with sensible defaults. 169314564Sdim /// 170314564Sdim /// @param[in] argv 171314564Sdim /// The argument array. 172314564Sdim /// 173314564Sdim /// @param[in] envp 174314564Sdim /// The environment array. 175314564Sdim /// 176314564Sdim /// @param[in] working_directory 177314564Sdim /// The working directory to have the child process run in 178314564Sdim /// 179314564Sdim /// Default: listener 180314564Sdim /// Set to the target's debugger (SBTarget::GetDebugger()) 181314564Sdim /// 182314564Sdim /// Default: launch_flags 183314564Sdim /// Empty launch flags 184314564Sdim /// 185314564Sdim /// Default: stdin_path 186314564Sdim /// Default: stdout_path 187314564Sdim /// Default: stderr_path 188314564Sdim /// A pseudo terminal will be used. 189314564Sdim /// 190314564Sdim /// @return 191314564Sdim /// A process object for the newly created process. 192314564Sdim //------------------------------------------------------------------ 193314564Sdim SBProcess LaunchSimple(const char **argv, const char **envp, 194314564Sdim const char *working_directory); 195314564Sdim 196314564Sdim SBProcess Launch(SBLaunchInfo &launch_info, SBError &error); 197314564Sdim 198314564Sdim SBProcess Attach(SBAttachInfo &attach_info, SBError &error); 199314564Sdim 200314564Sdim //------------------------------------------------------------------ 201314564Sdim /// Attach to process with pid. 202314564Sdim /// 203314564Sdim /// @param[in] listener 204314564Sdim /// An optional listener that will receive all process events. 205314564Sdim /// If \a listener is valid then \a listener will listen to all 206314564Sdim /// process events. If not valid, then this target's debugger 207314564Sdim /// (SBTarget::GetDebugger()) will listen to all process events. 208314564Sdim /// 209314564Sdim /// @param[in] pid 210314564Sdim /// The process ID to attach to. 211314564Sdim /// 212314564Sdim /// @param[out] error 213314564Sdim /// An error explaining what went wrong if attach fails. 214314564Sdim /// 215314564Sdim /// @return 216314564Sdim /// A process object for the attached process. 217314564Sdim //------------------------------------------------------------------ 218314564Sdim lldb::SBProcess AttachToProcessWithID(SBListener &listener, lldb::pid_t pid, 219314564Sdim lldb::SBError &error); 220314564Sdim 221254721Semaste#if defined(__APPLE__) 222314564Sdim // We need to keep this around for a build or two since Xcode links 223314564Sdim // to the 32 bit version of this function. We will take it out soon. 224314564Sdim lldb::SBProcess AttachToProcessWithID(SBListener &listener, 225314564Sdim ::pid_t pid, // 32 bit int process ID 226314564Sdim lldb::SBError &error); // DEPRECATED 227254721Semaste#endif 228296417Sdim 229314564Sdim //------------------------------------------------------------------ 230314564Sdim /// Attach to process with name. 231314564Sdim /// 232314564Sdim /// @param[in] listener 233314564Sdim /// An optional listener that will receive all process events. 234314564Sdim /// If \a listener is valid then \a listener will listen to all 235314564Sdim /// process events. If not valid, then this target's debugger 236314564Sdim /// (SBTarget::GetDebugger()) will listen to all process events. 237314564Sdim /// 238314564Sdim /// @param[in] name 239314564Sdim /// Basename of process to attach to. 240314564Sdim /// 241314564Sdim /// @param[in] wait_for 242314564Sdim /// If true wait for a new instance of 'name' to be launched. 243314564Sdim /// 244314564Sdim /// @param[out] error 245314564Sdim /// An error explaining what went wrong if attach fails. 246314564Sdim /// 247314564Sdim /// @return 248314564Sdim /// A process object for the attached process. 249314564Sdim //------------------------------------------------------------------ 250314564Sdim lldb::SBProcess AttachToProcessWithName(SBListener &listener, 251314564Sdim const char *name, bool wait_for, 252314564Sdim lldb::SBError &error); 253254721Semaste 254314564Sdim //------------------------------------------------------------------ 255314564Sdim /// Connect to a remote debug server with url. 256314564Sdim /// 257314564Sdim /// @param[in] listener 258314564Sdim /// An optional listener that will receive all process events. 259314564Sdim /// If \a listener is valid then \a listener will listen to all 260314564Sdim /// process events. If not valid, then this target's debugger 261314564Sdim /// (SBTarget::GetDebugger()) will listen to all process events. 262314564Sdim /// 263314564Sdim /// @param[in] url 264314564Sdim /// The url to connect to, e.g., 'connect://localhost:12345'. 265314564Sdim /// 266314564Sdim /// @param[in] plugin_name 267314564Sdim /// The plugin name to be used; can be nullptr. 268314564Sdim /// 269314564Sdim /// @param[out] error 270314564Sdim /// An error explaining what went wrong if the connect fails. 271314564Sdim /// 272314564Sdim /// @return 273314564Sdim /// A process object for the connected process. 274314564Sdim //------------------------------------------------------------------ 275314564Sdim lldb::SBProcess ConnectRemote(SBListener &listener, const char *url, 276314564Sdim const char *plugin_name, SBError &error); 277254721Semaste 278314564Sdim lldb::SBFileSpec GetExecutable(); 279254721Semaste 280314564Sdim bool AddModule(lldb::SBModule &module); 281254721Semaste 282314564Sdim lldb::SBModule AddModule(const char *path, const char *triple, 283314564Sdim const char *uuid); 284254721Semaste 285314564Sdim lldb::SBModule AddModule(const char *path, const char *triple, 286314564Sdim const char *uuid_cstr, const char *symfile); 287254721Semaste 288314564Sdim lldb::SBModule AddModule(const SBModuleSpec &module_spec); 289254721Semaste 290314564Sdim uint32_t GetNumModules() const; 291254721Semaste 292314564Sdim lldb::SBModule GetModuleAtIndex(uint32_t idx); 293254721Semaste 294314564Sdim bool RemoveModule(lldb::SBModule module); 295254721Semaste 296314564Sdim lldb::SBDebugger GetDebugger() const; 297254721Semaste 298314564Sdim lldb::SBModule FindModule(const lldb::SBFileSpec &file_spec); 299254721Semaste 300314564Sdim lldb::ByteOrder GetByteOrder(); 301254721Semaste 302314564Sdim uint32_t GetAddressByteSize(); 303280031Sdim 304314564Sdim const char *GetTriple(); 305280031Sdim 306314564Sdim //------------------------------------------------------------------ 307314564Sdim /// Architecture data byte width accessor 308314564Sdim /// 309314564Sdim /// @return 310314564Sdim /// The size in 8-bit (host) bytes of a minimum addressable 311314564Sdim /// unit from the Architecture's data bus 312314564Sdim //------------------------------------------------------------------ 313314564Sdim uint32_t GetDataByteSize(); 314254721Semaste 315314564Sdim //------------------------------------------------------------------ 316314564Sdim /// Architecture code byte width accessor 317314564Sdim /// 318314564Sdim /// @return 319314564Sdim /// The size in 8-bit (host) bytes of a minimum addressable 320314564Sdim /// unit from the Architecture's code bus 321314564Sdim //------------------------------------------------------------------ 322314564Sdim uint32_t GetCodeByteSize(); 323254721Semaste 324314564Sdim //------------------------------------------------------------------ 325314564Sdim /// Set the base load address for a module section. 326314564Sdim /// 327314564Sdim /// @param[in] section 328314564Sdim /// The section whose base load address will be set within this 329314564Sdim /// target. 330314564Sdim /// 331314564Sdim /// @param[in] section_base_addr 332314564Sdim /// The base address for the section. 333314564Sdim /// 334314564Sdim /// @return 335314564Sdim /// An error to indicate success, fail, and any reason for 336314564Sdim /// failure. 337314564Sdim //------------------------------------------------------------------ 338314564Sdim lldb::SBError SetSectionLoadAddress(lldb::SBSection section, 339314564Sdim lldb::addr_t section_base_addr); 340254721Semaste 341314564Sdim //------------------------------------------------------------------ 342314564Sdim /// Clear the base load address for a module section. 343314564Sdim /// 344314564Sdim /// @param[in] section 345314564Sdim /// The section whose base load address will be cleared within 346314564Sdim /// this target. 347314564Sdim /// 348314564Sdim /// @return 349314564Sdim /// An error to indicate success, fail, and any reason for 350314564Sdim /// failure. 351314564Sdim //------------------------------------------------------------------ 352314564Sdim lldb::SBError ClearSectionLoadAddress(lldb::SBSection section); 353254721Semaste 354314564Sdim //------------------------------------------------------------------ 355314564Sdim /// Slide all file addresses for all module sections so that \a module 356314564Sdim /// appears to loaded at these slide addresses. 357314564Sdim /// 358314564Sdim /// When you need all sections within a module to be loaded at a 359314564Sdim /// rigid slide from the addresses found in the module object file, 360314564Sdim /// this function will allow you to easily and quickly slide all 361314564Sdim /// module sections. 362314564Sdim /// 363314564Sdim /// @param[in] module 364314564Sdim /// The module to load. 365314564Sdim /// 366314564Sdim /// @param[in] sections_offset 367314564Sdim /// An offset that will be applied to all section file addresses 368314564Sdim /// (the virtual addresses found in the object file itself). 369314564Sdim /// 370314564Sdim /// @return 371314564Sdim /// An error to indicate success, fail, and any reason for 372314564Sdim /// failure. 373314564Sdim //------------------------------------------------------------------ 374314564Sdim lldb::SBError SetModuleLoadAddress(lldb::SBModule module, 375314564Sdim int64_t sections_offset); 376280031Sdim 377314564Sdim //------------------------------------------------------------------ 378314564Sdim /// Clear the section base load addresses for all sections in a module. 379314564Sdim /// 380314564Sdim /// @param[in] module 381314564Sdim /// The module to unload. 382314564Sdim /// 383314564Sdim /// @return 384314564Sdim /// An error to indicate success, fail, and any reason for 385314564Sdim /// failure. 386314564Sdim //------------------------------------------------------------------ 387314564Sdim lldb::SBError ClearModuleLoadAddress(lldb::SBModule module); 388280031Sdim 389314564Sdim //------------------------------------------------------------------ 390314564Sdim /// Find functions by name. 391314564Sdim /// 392314564Sdim /// @param[in] name 393314564Sdim /// The name of the function we are looking for. 394314564Sdim /// 395314564Sdim /// @param[in] name_type_mask 396314564Sdim /// A logical OR of one or more FunctionNameType enum bits that 397314564Sdim /// indicate what kind of names should be used when doing the 398314564Sdim /// lookup. Bits include fully qualified names, base names, 399314564Sdim /// C++ methods, or ObjC selectors. 400314564Sdim /// See FunctionNameType for more details. 401314564Sdim /// 402314564Sdim /// @return 403314564Sdim /// A lldb::SBSymbolContextList that gets filled in with all of 404314564Sdim /// the symbol contexts for all the matches. 405314564Sdim //------------------------------------------------------------------ 406314564Sdim lldb::SBSymbolContextList 407314564Sdim FindFunctions(const char *name, 408314564Sdim uint32_t name_type_mask = lldb::eFunctionNameTypeAny); 409254721Semaste 410314564Sdim //------------------------------------------------------------------ 411314564Sdim /// Find global and static variables by name. 412314564Sdim /// 413314564Sdim /// @param[in] name 414314564Sdim /// The name of the global or static variable we are looking 415314564Sdim /// for. 416314564Sdim /// 417314564Sdim /// @param[in] max_matches 418314564Sdim /// Allow the number of matches to be limited to \a max_matches. 419314564Sdim /// 420314564Sdim /// @return 421314564Sdim /// A list of matched variables in an SBValueList. 422314564Sdim //------------------------------------------------------------------ 423314564Sdim lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches); 424280031Sdim 425314564Sdim //------------------------------------------------------------------ 426314564Sdim /// Find the first global (or static) variable by name. 427314564Sdim /// 428314564Sdim /// @param[in] name 429314564Sdim /// The name of the global or static variable we are looking 430314564Sdim /// for. 431314564Sdim /// 432314564Sdim /// @return 433314564Sdim /// An SBValue that gets filled in with the found variable (if any). 434314564Sdim //------------------------------------------------------------------ 435314564Sdim lldb::SBValue FindFirstGlobalVariable(const char *name); 436254721Semaste 437314564Sdim //------------------------------------------------------------------ 438314564Sdim /// Find global and static variables by pattern. 439314564Sdim /// 440314564Sdim /// @param[in] name 441314564Sdim /// The pattern to search for global or static variables 442314564Sdim /// 443314564Sdim /// @param[in] max_matches 444314564Sdim /// Allow the number of matches to be limited to \a max_matches. 445314564Sdim /// 446314564Sdim /// @param[in] matchtype 447314564Sdim /// The match type to use. 448314564Sdim /// 449314564Sdim /// @return 450314564Sdim /// A list of matched variables in an SBValueList. 451314564Sdim //------------------------------------------------------------------ 452314564Sdim lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches, 453314564Sdim MatchType matchtype); 454262528Semaste 455314564Sdim //------------------------------------------------------------------ 456314564Sdim /// Find global functions by their name with pattern matching. 457314564Sdim /// 458314564Sdim /// @param[in] name 459314564Sdim /// The pattern to search for global or static variables 460314564Sdim /// 461314564Sdim /// @param[in] max_matches 462314564Sdim /// Allow the number of matches to be limited to \a max_matches. 463314564Sdim /// 464314564Sdim /// @param[in] matchtype 465314564Sdim /// The match type to use. 466314564Sdim /// 467314564Sdim /// @return 468314564Sdim /// A list of matched variables in an SBValueList. 469314564Sdim //------------------------------------------------------------------ 470314564Sdim lldb::SBSymbolContextList FindGlobalFunctions(const char *name, 471314564Sdim uint32_t max_matches, 472314564Sdim MatchType matchtype); 473254721Semaste 474314564Sdim void Clear(); 475280031Sdim 476314564Sdim //------------------------------------------------------------------ 477314564Sdim /// Resolve a current file address into a section offset address. 478314564Sdim /// 479314564Sdim /// @param[in] file_addr 480321369Sdim /// The file address to resolve. 481314564Sdim /// 482314564Sdim /// @return 483314564Sdim /// An SBAddress which will be valid if... 484314564Sdim //------------------------------------------------------------------ 485314564Sdim lldb::SBAddress ResolveFileAddress(lldb::addr_t file_addr); 486254721Semaste 487314564Sdim //------------------------------------------------------------------ 488314564Sdim /// Resolve a current load address into a section offset address. 489314564Sdim /// 490314564Sdim /// @param[in] vm_addr 491314564Sdim /// A virtual address from the current process state that is to 492314564Sdim /// be translated into a section offset address. 493314564Sdim /// 494314564Sdim /// @return 495314564Sdim /// An SBAddress which will be valid if \a vm_addr was 496314564Sdim /// successfully resolved into a section offset address, or an 497314564Sdim /// invalid SBAddress if \a vm_addr doesn't resolve to a section 498314564Sdim /// in a module. 499314564Sdim //------------------------------------------------------------------ 500314564Sdim lldb::SBAddress ResolveLoadAddress(lldb::addr_t vm_addr); 501254721Semaste 502314564Sdim //------------------------------------------------------------------ 503314564Sdim /// Resolve a current load address into a section offset address 504314564Sdim /// using the process stop ID to identify a time in the past. 505314564Sdim /// 506314564Sdim /// @param[in] stop_id 507314564Sdim /// Each time a process stops, the process stop ID integer gets 508314564Sdim /// incremented. These stop IDs are used to identify past times 509314564Sdim /// and can be used in history objects as a cheap way to store 510314564Sdim /// the time at which the sample was taken. Specifying 511314564Sdim /// UINT32_MAX will always resolve the address using the 512314564Sdim /// currently loaded sections. 513314564Sdim /// 514314564Sdim /// @param[in] vm_addr 515314564Sdim /// A virtual address from the current process state that is to 516314564Sdim /// be translated into a section offset address. 517314564Sdim /// 518314564Sdim /// @return 519314564Sdim /// An SBAddress which will be valid if \a vm_addr was 520314564Sdim /// successfully resolved into a section offset address, or an 521314564Sdim /// invalid SBAddress if \a vm_addr doesn't resolve to a section 522314564Sdim /// in a module. 523314564Sdim //------------------------------------------------------------------ 524314564Sdim lldb::SBAddress ResolvePastLoadAddress(uint32_t stop_id, 525314564Sdim lldb::addr_t vm_addr); 526309124Sdim 527314564Sdim SBSymbolContext ResolveSymbolContextForAddress(const SBAddress &addr, 528314564Sdim uint32_t resolve_scope); 529254721Semaste 530314564Sdim //------------------------------------------------------------------ 531314564Sdim /// Read target memory. If a target process is running then memory 532314564Sdim /// is read from here. Otherwise the memory is read from the object 533314564Sdim /// files. For a target whose bytes are sized as a multiple of host 534314564Sdim /// bytes, the data read back will preserve the target's byte order. 535314564Sdim /// 536314564Sdim /// @param[in] addr 537314564Sdim /// A target address to read from. 538314564Sdim /// 539314564Sdim /// @param[out] buf 540314564Sdim /// The buffer to read memory into. 541314564Sdim /// 542314564Sdim /// @param[in] size 543314564Sdim /// The maximum number of host bytes to read in the buffer passed 544314564Sdim /// into this call 545314564Sdim /// 546314564Sdim /// @param[out] error 547321369Sdim /// Status information is written here if the memory read fails. 548314564Sdim /// 549314564Sdim /// @return 550314564Sdim /// The amount of data read in host bytes. 551314564Sdim //------------------------------------------------------------------ 552314564Sdim size_t ReadMemory(const SBAddress addr, void *buf, size_t size, 553314564Sdim lldb::SBError &error); 554254721Semaste 555314564Sdim lldb::SBBreakpoint BreakpointCreateByLocation(const char *file, 556314564Sdim uint32_t line); 557254721Semaste 558314564Sdim lldb::SBBreakpoint 559314564Sdim BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line); 560296417Sdim 561314564Sdim lldb::SBBreakpoint 562314564Sdim BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line, 563314564Sdim lldb::addr_t offset); 564254721Semaste 565314564Sdim lldb::SBBreakpoint 566314564Sdim BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line, 567314564Sdim lldb::addr_t offset, SBFileSpecList &module_list); 568296417Sdim 569314564Sdim lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name, 570314564Sdim const char *module_name = nullptr); 571309124Sdim 572314564Sdim // This version uses name_type_mask = eFunctionNameTypeAuto 573314564Sdim lldb::SBBreakpoint 574314564Sdim BreakpointCreateByName(const char *symbol_name, 575314564Sdim const SBFileSpecList &module_list, 576314564Sdim const SBFileSpecList &comp_unit_list); 577254721Semaste 578314564Sdim lldb::SBBreakpoint BreakpointCreateByName( 579314564Sdim const char *symbol_name, 580314564Sdim uint32_t 581314564Sdim name_type_mask, // Logical OR one or more FunctionNameType enum bits 582314564Sdim const SBFileSpecList &module_list, 583314564Sdim const SBFileSpecList &comp_unit_list); 584254721Semaste 585314564Sdim lldb::SBBreakpoint BreakpointCreateByName( 586314564Sdim const char *symbol_name, 587314564Sdim uint32_t 588314564Sdim name_type_mask, // Logical OR one or more FunctionNameType enum bits 589314564Sdim lldb::LanguageType symbol_language, 590314564Sdim const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list); 591254721Semaste 592314564Sdim lldb::SBBreakpoint BreakpointCreateByNames( 593314564Sdim const char *symbol_name[], uint32_t num_names, 594314564Sdim uint32_t 595314564Sdim name_type_mask, // Logical OR one or more FunctionNameType enum bits 596314564Sdim const SBFileSpecList &module_list, 597314564Sdim const SBFileSpecList &comp_unit_list); 598296417Sdim 599314564Sdim lldb::SBBreakpoint BreakpointCreateByNames( 600314564Sdim const char *symbol_name[], uint32_t num_names, 601314564Sdim uint32_t 602314564Sdim name_type_mask, // Logical OR one or more FunctionNameType enum bits 603314564Sdim lldb::LanguageType symbol_language, 604314564Sdim const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list); 605254721Semaste 606314564Sdim lldb::SBBreakpoint BreakpointCreateByNames( 607314564Sdim const char *symbol_name[], uint32_t num_names, 608314564Sdim uint32_t 609314564Sdim name_type_mask, // Logical OR one or more FunctionNameType enum bits 610314564Sdim lldb::LanguageType symbol_language, 611314564Sdim lldb::addr_t offset, const SBFileSpecList &module_list, 612314564Sdim const SBFileSpecList &comp_unit_list); 613254721Semaste 614314564Sdim lldb::SBBreakpoint BreakpointCreateByRegex(const char *symbol_name_regex, 615314564Sdim const char *module_name = nullptr); 616254721Semaste 617314564Sdim lldb::SBBreakpoint 618314564Sdim BreakpointCreateByRegex(const char *symbol_name_regex, 619314564Sdim const SBFileSpecList &module_list, 620314564Sdim const SBFileSpecList &comp_unit_list); 621254721Semaste 622314564Sdim lldb::SBBreakpoint BreakpointCreateByRegex( 623314564Sdim const char *symbol_name_regex, lldb::LanguageType symbol_language, 624314564Sdim const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list); 625254721Semaste 626314564Sdim lldb::SBBreakpoint 627314564Sdim BreakpointCreateBySourceRegex(const char *source_regex, 628314564Sdim const SBFileSpec &source_file, 629314564Sdim const char *module_name = nullptr); 630254721Semaste 631314564Sdim lldb::SBBreakpoint 632314564Sdim BreakpointCreateBySourceRegex(const char *source_regex, 633314564Sdim const SBFileSpecList &module_list, 634314564Sdim const SBFileSpecList &source_file); 635254721Semaste 636314564Sdim lldb::SBBreakpoint BreakpointCreateBySourceRegex( 637314564Sdim const char *source_regex, const SBFileSpecList &module_list, 638314564Sdim const SBFileSpecList &source_file, const SBStringList &func_names); 639254721Semaste 640314564Sdim lldb::SBBreakpoint BreakpointCreateForException(lldb::LanguageType language, 641314564Sdim bool catch_bp, bool throw_bp); 642254721Semaste 643314564Sdim lldb::SBBreakpoint BreakpointCreateByAddress(addr_t address); 644254721Semaste 645314564Sdim lldb::SBBreakpoint BreakpointCreateBySBAddress(SBAddress &address); 646254721Semaste 647314564Sdim //------------------------------------------------------------------ 648314564Sdim /// Read breakpoints from source_file and return the newly created 649314564Sdim /// breakpoints in bkpt_list. 650314564Sdim /// 651314564Sdim /// @param[in] source_file 652314564Sdim /// The file from which to read the breakpoints. 653314564Sdim /// 654321369Sdim /// @param[out] new_bps 655314564Sdim /// A list of the newly created breakpoints. 656314564Sdim /// 657314564Sdim /// @return 658314564Sdim /// An SBError detailing any errors in reading in the breakpoints. 659314564Sdim //------------------------------------------------------------------ 660314564Sdim lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file, 661314564Sdim SBBreakpointList &new_bps); 662254721Semaste 663314564Sdim //------------------------------------------------------------------ 664314564Sdim /// Read breakpoints from source_file and return the newly created 665314564Sdim /// breakpoints in bkpt_list. 666314564Sdim /// 667314564Sdim /// @param[in] source_file 668314564Sdim /// The file from which to read the breakpoints. 669314564Sdim /// 670314564Sdim /// @param[in] matching_names 671314564Sdim /// Only read in breakpoints whose names match one of the names in this 672314564Sdim /// list. 673314564Sdim /// 674321369Sdim /// @param[out] new_bps 675314564Sdim /// A list of the newly created breakpoints. 676314564Sdim /// 677314564Sdim /// @return 678314564Sdim /// An SBError detailing any errors in reading in the breakpoints. 679314564Sdim //------------------------------------------------------------------ 680314564Sdim lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file, 681314564Sdim SBStringList &matching_names, 682314564Sdim SBBreakpointList &new_bps); 683254721Semaste 684314564Sdim //------------------------------------------------------------------ 685314564Sdim /// Write breakpoints to dest_file. 686314564Sdim /// 687314564Sdim /// @param[in] dest_file 688314564Sdim /// The file to which to write the breakpoints. 689314564Sdim /// 690314564Sdim /// @return 691314564Sdim /// An SBError detailing any errors in writing in the breakpoints. 692314564Sdim //------------------------------------------------------------------ 693314564Sdim lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file); 694254721Semaste 695314564Sdim //------------------------------------------------------------------ 696314564Sdim /// Write breakpoints listed in bkpt_list to dest_file. 697314564Sdim /// 698314564Sdim /// @param[in] dest_file 699314564Sdim /// The file to which to write the breakpoints. 700314564Sdim /// 701314564Sdim /// @param[in] bkpt_list 702314564Sdim /// Only write breakpoints from this list. 703314564Sdim /// 704314564Sdim /// @param[in] append 705314564Sdim /// If \btrue, append the breakpoints in bkpt_list to the others 706314564Sdim /// serialized in dest_file. If dest_file doesn't exist, then a new 707314564Sdim /// file will be created and the breakpoints in bkpt_list written to it. 708314564Sdim /// 709314564Sdim /// @return 710314564Sdim /// An SBError detailing any errors in writing in the breakpoints. 711314564Sdim //------------------------------------------------------------------ 712314564Sdim lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file, 713314564Sdim SBBreakpointList &bkpt_list, 714314564Sdim bool append = false); 715254721Semaste 716314564Sdim uint32_t GetNumBreakpoints() const; 717280031Sdim 718314564Sdim lldb::SBBreakpoint GetBreakpointAtIndex(uint32_t idx) const; 719280031Sdim 720314564Sdim bool BreakpointDelete(break_id_t break_id); 721254721Semaste 722314564Sdim lldb::SBBreakpoint FindBreakpointByID(break_id_t break_id); 723254721Semaste 724314564Sdim // Finds all breakpoints by name, returning the list in bkpt_list. Returns 725314564Sdim // false if the name is not a valid breakpoint name, true otherwise. 726314564Sdim bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list); 727254721Semaste 728314564Sdim bool EnableAllBreakpoints(); 729254721Semaste 730314564Sdim bool DisableAllBreakpoints(); 731254721Semaste 732314564Sdim bool DeleteAllBreakpoints(); 733254721Semaste 734314564Sdim uint32_t GetNumWatchpoints() const; 735254721Semaste 736314564Sdim lldb::SBWatchpoint GetWatchpointAtIndex(uint32_t idx) const; 737254721Semaste 738314564Sdim bool DeleteWatchpoint(lldb::watch_id_t watch_id); 739288943Sdim 740314564Sdim lldb::SBWatchpoint FindWatchpointByID(lldb::watch_id_t watch_id); 741254721Semaste 742314564Sdim lldb::SBWatchpoint WatchAddress(lldb::addr_t addr, size_t size, bool read, 743314564Sdim bool write, SBError &error); 744288943Sdim 745314564Sdim bool EnableAllWatchpoints(); 746288943Sdim 747314564Sdim bool DisableAllWatchpoints(); 748314564Sdim 749314564Sdim bool DeleteAllWatchpoints(); 750314564Sdim 751314564Sdim lldb::SBBroadcaster GetBroadcaster() const; 752314564Sdim 753314564Sdim lldb::SBType FindFirstType(const char *type); 754314564Sdim 755314564Sdim lldb::SBTypeList FindTypes(const char *type); 756314564Sdim 757314564Sdim lldb::SBType GetBasicType(lldb::BasicType type); 758314564Sdim 759314564Sdim lldb::SBValue CreateValueFromAddress(const char *name, lldb::SBAddress addr, 760314564Sdim lldb::SBType type); 761314564Sdim 762314564Sdim lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data, 763314564Sdim lldb::SBType type); 764314564Sdim 765314564Sdim lldb::SBValue CreateValueFromExpression(const char *name, const char *expr); 766314564Sdim 767314564Sdim SBSourceManager GetSourceManager(); 768314564Sdim 769314564Sdim lldb::SBInstructionList ReadInstructions(lldb::SBAddress base_addr, 770314564Sdim uint32_t count); 771314564Sdim 772314564Sdim lldb::SBInstructionList ReadInstructions(lldb::SBAddress base_addr, 773314564Sdim uint32_t count, 774314564Sdim const char *flavor_string); 775314564Sdim 776314564Sdim lldb::SBInstructionList GetInstructions(lldb::SBAddress base_addr, 777314564Sdim const void *buf, size_t size); 778314564Sdim 779314564Sdim // The "WithFlavor" is necessary to keep SWIG from getting confused about 780314564Sdim // overloaded arguments when 781314564Sdim // using the buf + size -> Python Object magic. 782314564Sdim 783314564Sdim lldb::SBInstructionList GetInstructionsWithFlavor(lldb::SBAddress base_addr, 784314564Sdim const char *flavor_string, 785314564Sdim const void *buf, 786314564Sdim size_t size); 787314564Sdim 788314564Sdim lldb::SBInstructionList GetInstructions(lldb::addr_t base_addr, 789314564Sdim const void *buf, size_t size); 790314564Sdim 791314564Sdim lldb::SBInstructionList GetInstructionsWithFlavor(lldb::addr_t base_addr, 792314564Sdim const char *flavor_string, 793314564Sdim const void *buf, 794314564Sdim size_t size); 795314564Sdim 796314564Sdim lldb::SBSymbolContextList FindSymbols(const char *name, 797314564Sdim lldb::SymbolType type = eSymbolTypeAny); 798314564Sdim 799314564Sdim bool operator==(const lldb::SBTarget &rhs) const; 800314564Sdim 801314564Sdim bool operator!=(const lldb::SBTarget &rhs) const; 802314564Sdim 803314564Sdim bool GetDescription(lldb::SBStream &description, 804314564Sdim lldb::DescriptionLevel description_level); 805314564Sdim 806314564Sdim lldb::SBValue EvaluateExpression(const char *expr); 807314564Sdim 808314564Sdim lldb::SBValue EvaluateExpression(const char *expr, 809314564Sdim const SBExpressionOptions &options); 810314564Sdim 811314564Sdim lldb::addr_t GetStackRedZoneSize(); 812314564Sdim 813314564Sdim lldb::SBLaunchInfo GetLaunchInfo() const; 814314564Sdim 815314564Sdim void SetLaunchInfo(const lldb::SBLaunchInfo &launch_info); 816314564Sdim 817254721Semasteprotected: 818314564Sdim friend class SBAddress; 819314564Sdim friend class SBBlock; 820314564Sdim friend class SBBreakpointList; 821314564Sdim friend class SBDebugger; 822314564Sdim friend class SBExecutionContext; 823314564Sdim friend class SBFunction; 824314564Sdim friend class SBInstruction; 825314564Sdim friend class SBModule; 826314564Sdim friend class SBProcess; 827314564Sdim friend class SBSection; 828314564Sdim friend class SBSourceManager; 829314564Sdim friend class SBSymbol; 830314564Sdim friend class SBValue; 831254721Semaste 832314564Sdim //------------------------------------------------------------------ 833314564Sdim // Constructors are private, use static Target::Create function to 834314564Sdim // create an instance of this class. 835314564Sdim //------------------------------------------------------------------ 836254721Semaste 837314564Sdim lldb::TargetSP GetSP() const; 838254721Semaste 839314564Sdim void SetSP(const lldb::TargetSP &target_sp); 840254721Semaste 841254721Semasteprivate: 842314564Sdim lldb::TargetSP m_opaque_sp; 843254721Semaste}; 844254721Semaste 845254721Semaste} // namespace lldb 846254721Semaste 847296417Sdim#endif // LLDB_SBTarget_h_ 848