1254721Semaste//===-- SBTarget.h ----------------------------------------------*- C++ -*-===//
2254721Semaste//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6254721Semaste//
7254721Semaste//===----------------------------------------------------------------------===//
8254721Semaste
9254721Semaste#ifndef LLDB_SBTarget_h_
10254721Semaste#define LLDB_SBTarget_h_
11254721Semaste
12254721Semaste#include "lldb/API/SBAddress.h"
13288943Sdim#include "lldb/API/SBAttachInfo.h"
14314564Sdim#include "lldb/API/SBBreakpoint.h"
15254721Semaste#include "lldb/API/SBBroadcaster.h"
16314564Sdim#include "lldb/API/SBDefines.h"
17254721Semaste#include "lldb/API/SBFileSpec.h"
18254721Semaste#include "lldb/API/SBFileSpecList.h"
19288943Sdim#include "lldb/API/SBLaunchInfo.h"
20254721Semaste#include "lldb/API/SBSymbolContextList.h"
21254721Semaste#include "lldb/API/SBType.h"
22254721Semaste#include "lldb/API/SBValue.h"
23254721Semaste#include "lldb/API/SBWatchpoint.h"
24254721Semaste
25254721Semastenamespace lldb {
26254721Semaste
27280031Sdimclass SBPlatform;
28280031Sdim
29314564Sdimclass LLDB_API SBTarget {
30254721Semastepublic:
31314564Sdim  // Broadcaster bits.
32314564Sdim  enum {
33314564Sdim    eBroadcastBitBreakpointChanged = (1 << 0),
34314564Sdim    eBroadcastBitModulesLoaded = (1 << 1),
35314564Sdim    eBroadcastBitModulesUnloaded = (1 << 2),
36314564Sdim    eBroadcastBitWatchpointChanged = (1 << 3),
37314564Sdim    eBroadcastBitSymbolsLoaded = (1 << 4)
38314564Sdim  };
39254721Semaste
40314564Sdim  // Constructors
41314564Sdim  SBTarget();
42254721Semaste
43314564Sdim  SBTarget(const lldb::SBTarget &rhs);
44254721Semaste
45314564Sdim  SBTarget(const lldb::TargetSP &target_sp);
46254721Semaste
47314564Sdim  // Destructor
48314564Sdim  ~SBTarget();
49296417Sdim
50314564Sdim  const lldb::SBTarget &operator=(const lldb::SBTarget &rhs);
51288943Sdim
52353358Sdim  explicit operator bool() const;
53353358Sdim
54314564Sdim  bool IsValid() const;
55288943Sdim
56314564Sdim  static bool EventIsTargetEvent(const lldb::SBEvent &event);
57288943Sdim
58314564Sdim  static lldb::SBTarget GetTargetFromEvent(const lldb::SBEvent &event);
59288943Sdim
60314564Sdim  static uint32_t GetNumModulesFromEvent(const lldb::SBEvent &event);
61254721Semaste
62314564Sdim  static lldb::SBModule GetModuleAtIndexFromEvent(const uint32_t idx,
63314564Sdim                                                  const lldb::SBEvent &event);
64254721Semaste
65314564Sdim  static const char *GetBroadcasterClassName();
66280031Sdim
67314564Sdim  lldb::SBProcess GetProcess();
68296417Sdim
69344779Sdim  /// Sets whether we should collect statistics on lldb or not.
70344779Sdim  ///
71353358Sdim  /// \param[in] v
72344779Sdim  ///     A boolean to control the collection.
73344779Sdim  void SetCollectingStats(bool v);
74344779Sdim
75344779Sdim  /// Returns whether statistics collection are enabled.
76344779Sdim  ///
77353358Sdim  /// \return
78344779Sdim  ///     true if statistics are currently being collected, false
79344779Sdim  ///     otherwise.
80344779Sdim  bool GetCollectingStats();
81344779Sdim
82344779Sdim  /// Returns a dump of the collected statistics.
83344779Sdim  ///
84353358Sdim  /// \return
85344779Sdim  ///     A SBStructuredData with the statistics collected.
86341825Sdim  lldb::SBStructuredData GetStatistics();
87341825Sdim
88314564Sdim  /// Return the platform object associated with the target.
89314564Sdim  ///
90314564Sdim  /// After return, the platform object should be checked for
91314564Sdim  /// validity.
92314564Sdim  ///
93353358Sdim  /// \return
94314564Sdim  ///     A platform object.
95314564Sdim  lldb::SBPlatform GetPlatform();
96296417Sdim
97314564Sdim  /// Install any binaries that need to be installed.
98314564Sdim  ///
99314564Sdim  /// This function does nothing when debugging on the host system.
100314564Sdim  /// When connected to remote platforms, the target's main executable
101314564Sdim  /// and any modules that have their remote install path set will be
102314564Sdim  /// installed on the remote platform. If the main executable doesn't
103314564Sdim  /// have an install location set, it will be installed in the remote
104314564Sdim  /// platform's working directory.
105314564Sdim  ///
106353358Sdim  /// \return
107314564Sdim  ///     An error describing anything that went wrong during
108314564Sdim  ///     installation.
109314564Sdim  SBError Install();
110254721Semaste
111314564Sdim  /// Launch a new process.
112314564Sdim  ///
113314564Sdim  /// Launch a new process by spawning a new process using the
114314564Sdim  /// target object's executable module's file as the file to launch.
115314564Sdim  /// Arguments are given in \a argv, and the environment variables
116314564Sdim  /// are in \a envp. Standard input and output files can be
117314564Sdim  /// optionally re-directed to \a stdin_path, \a stdout_path, and
118314564Sdim  /// \a stderr_path.
119314564Sdim  ///
120353358Sdim  /// \param[in] listener
121314564Sdim  ///     An optional listener that will receive all process events.
122314564Sdim  ///     If \a listener is valid then \a listener will listen to all
123314564Sdim  ///     process events. If not valid, then this target's debugger
124314564Sdim  ///     (SBTarget::GetDebugger()) will listen to all process events.
125314564Sdim  ///
126353358Sdim  /// \param[in] argv
127314564Sdim  ///     The argument array.
128314564Sdim  ///
129353358Sdim  /// \param[in] envp
130314564Sdim  ///     The environment array.
131314564Sdim  ///
132353358Sdim  /// \param[in] stdin_path
133314564Sdim  ///     The path to use when re-directing the STDIN of the new
134314564Sdim  ///     process. If all stdXX_path arguments are nullptr, a pseudo
135314564Sdim  ///     terminal will be used.
136314564Sdim  ///
137353358Sdim  /// \param[in] stdout_path
138314564Sdim  ///     The path to use when re-directing the STDOUT of the new
139314564Sdim  ///     process. If all stdXX_path arguments are nullptr, a pseudo
140314564Sdim  ///     terminal will be used.
141314564Sdim  ///
142353358Sdim  /// \param[in] stderr_path
143314564Sdim  ///     The path to use when re-directing the STDERR of the new
144314564Sdim  ///     process. If all stdXX_path arguments are nullptr, a pseudo
145314564Sdim  ///     terminal will be used.
146314564Sdim  ///
147353358Sdim  /// \param[in] working_directory
148314564Sdim  ///     The working directory to have the child process run in
149314564Sdim  ///
150353358Sdim  /// \param[in] launch_flags
151314564Sdim  ///     Some launch options specified by logical OR'ing
152314564Sdim  ///     lldb::LaunchFlags enumeration values together.
153314564Sdim  ///
154353358Sdim  /// \param[in] stop_at_entry
155314564Sdim  ///     If false do not stop the inferior at the entry point.
156314564Sdim  ///
157353358Sdim  /// \param[out] error
158314564Sdim  ///     An error object. Contains the reason if there is some failure.
159314564Sdim  ///
160353358Sdim  /// \return
161314564Sdim  ///      A process object for the newly created process.
162314564Sdim  lldb::SBProcess Launch(SBListener &listener, char const **argv,
163314564Sdim                         char const **envp, const char *stdin_path,
164314564Sdim                         const char *stdout_path, const char *stderr_path,
165314564Sdim                         const char *working_directory,
166314564Sdim                         uint32_t launch_flags, // See LaunchFlags
167314564Sdim                         bool stop_at_entry, lldb::SBError &error);
168254721Semaste
169314564Sdim  SBProcess LoadCore(const char *core_file);
170341825Sdim  SBProcess LoadCore(const char *core_file, lldb::SBError &error);
171314564Sdim
172314564Sdim  /// Launch a new process with sensible defaults.
173314564Sdim  ///
174353358Sdim  /// \param[in] argv
175314564Sdim  ///     The argument array.
176314564Sdim  ///
177353358Sdim  /// \param[in] envp
178314564Sdim  ///     The environment array.
179314564Sdim  ///
180353358Sdim  /// \param[in] working_directory
181314564Sdim  ///     The working directory to have the child process run in
182314564Sdim  ///
183314564Sdim  /// Default: listener
184314564Sdim  ///     Set to the target's debugger (SBTarget::GetDebugger())
185314564Sdim  ///
186314564Sdim  /// Default: launch_flags
187314564Sdim  ///     Empty launch flags
188314564Sdim  ///
189314564Sdim  /// Default: stdin_path
190314564Sdim  /// Default: stdout_path
191314564Sdim  /// Default: stderr_path
192314564Sdim  ///     A pseudo terminal will be used.
193314564Sdim  ///
194353358Sdim  /// \return
195314564Sdim  ///      A process object for the newly created process.
196314564Sdim  SBProcess LaunchSimple(const char **argv, const char **envp,
197314564Sdim                         const char *working_directory);
198314564Sdim
199314564Sdim  SBProcess Launch(SBLaunchInfo &launch_info, SBError &error);
200314564Sdim
201314564Sdim  SBProcess Attach(SBAttachInfo &attach_info, SBError &error);
202314564Sdim
203314564Sdim  /// Attach to process with pid.
204314564Sdim  ///
205353358Sdim  /// \param[in] listener
206314564Sdim  ///     An optional listener that will receive all process events.
207314564Sdim  ///     If \a listener is valid then \a listener will listen to all
208314564Sdim  ///     process events. If not valid, then this target's debugger
209314564Sdim  ///     (SBTarget::GetDebugger()) will listen to all process events.
210314564Sdim  ///
211353358Sdim  /// \param[in] pid
212314564Sdim  ///     The process ID to attach to.
213314564Sdim  ///
214353358Sdim  /// \param[out] error
215314564Sdim  ///     An error explaining what went wrong if attach fails.
216314564Sdim  ///
217353358Sdim  /// \return
218314564Sdim  ///      A process object for the attached process.
219314564Sdim  lldb::SBProcess AttachToProcessWithID(SBListener &listener, lldb::pid_t pid,
220314564Sdim                                        lldb::SBError &error);
221314564Sdim
222314564Sdim  /// Attach to process with name.
223314564Sdim  ///
224353358Sdim  /// \param[in] listener
225314564Sdim  ///     An optional listener that will receive all process events.
226314564Sdim  ///     If \a listener is valid then \a listener will listen to all
227314564Sdim  ///     process events. If not valid, then this target's debugger
228314564Sdim  ///     (SBTarget::GetDebugger()) will listen to all process events.
229314564Sdim  ///
230353358Sdim  /// \param[in] name
231314564Sdim  ///     Basename of process to attach to.
232314564Sdim  ///
233353358Sdim  /// \param[in] wait_for
234314564Sdim  ///     If true wait for a new instance of 'name' to be launched.
235314564Sdim  ///
236353358Sdim  /// \param[out] error
237314564Sdim  ///     An error explaining what went wrong if attach fails.
238314564Sdim  ///
239353358Sdim  /// \return
240314564Sdim  ///      A process object for the attached process.
241314564Sdim  lldb::SBProcess AttachToProcessWithName(SBListener &listener,
242314564Sdim                                          const char *name, bool wait_for,
243314564Sdim                                          lldb::SBError &error);
244254721Semaste
245314564Sdim  /// Connect to a remote debug server with url.
246314564Sdim  ///
247353358Sdim  /// \param[in] listener
248314564Sdim  ///     An optional listener that will receive all process events.
249314564Sdim  ///     If \a listener is valid then \a listener will listen to all
250314564Sdim  ///     process events. If not valid, then this target's debugger
251314564Sdim  ///     (SBTarget::GetDebugger()) will listen to all process events.
252314564Sdim  ///
253353358Sdim  /// \param[in] url
254314564Sdim  ///     The url to connect to, e.g., 'connect://localhost:12345'.
255314564Sdim  ///
256353358Sdim  /// \param[in] plugin_name
257314564Sdim  ///     The plugin name to be used; can be nullptr.
258314564Sdim  ///
259353358Sdim  /// \param[out] error
260314564Sdim  ///     An error explaining what went wrong if the connect fails.
261314564Sdim  ///
262353358Sdim  /// \return
263314564Sdim  ///      A process object for the connected process.
264314564Sdim  lldb::SBProcess ConnectRemote(SBListener &listener, const char *url,
265314564Sdim                                const char *plugin_name, SBError &error);
266254721Semaste
267314564Sdim  lldb::SBFileSpec GetExecutable();
268254721Semaste
269344779Sdim  // Append the path mapping (from -> to) to the target's paths mapping list.
270344779Sdim  void AppendImageSearchPath(const char *from, const char *to,
271344779Sdim                             lldb::SBError &error);
272344779Sdim
273314564Sdim  bool AddModule(lldb::SBModule &module);
274254721Semaste
275314564Sdim  lldb::SBModule AddModule(const char *path, const char *triple,
276314564Sdim                           const char *uuid);
277254721Semaste
278314564Sdim  lldb::SBModule AddModule(const char *path, const char *triple,
279314564Sdim                           const char *uuid_cstr, const char *symfile);
280254721Semaste
281314564Sdim  lldb::SBModule AddModule(const SBModuleSpec &module_spec);
282254721Semaste
283314564Sdim  uint32_t GetNumModules() const;
284254721Semaste
285314564Sdim  lldb::SBModule GetModuleAtIndex(uint32_t idx);
286254721Semaste
287314564Sdim  bool RemoveModule(lldb::SBModule module);
288254721Semaste
289314564Sdim  lldb::SBDebugger GetDebugger() const;
290254721Semaste
291314564Sdim  lldb::SBModule FindModule(const lldb::SBFileSpec &file_spec);
292254721Semaste
293341825Sdim  /// Find compile units related to *this target and passed source
294341825Sdim  /// file.
295341825Sdim  ///
296353358Sdim  /// \param[in] sb_file_spec
297341825Sdim  ///     A lldb::SBFileSpec object that contains source file
298341825Sdim  ///     specification.
299341825Sdim  ///
300353358Sdim  /// \return
301341825Sdim  ///     A lldb::SBSymbolContextList that gets filled in with all of
302341825Sdim  ///     the symbol contexts for all the matches.
303341825Sdim  lldb::SBSymbolContextList
304341825Sdim  FindCompileUnits(const lldb::SBFileSpec &sb_file_spec);
305341825Sdim
306314564Sdim  lldb::ByteOrder GetByteOrder();
307254721Semaste
308314564Sdim  uint32_t GetAddressByteSize();
309280031Sdim
310314564Sdim  const char *GetTriple();
311280031Sdim
312314564Sdim  /// Architecture data byte width accessor
313314564Sdim  ///
314353358Sdim  /// \return
315314564Sdim  /// The size in 8-bit (host) bytes of a minimum addressable
316314564Sdim  /// unit from the Architecture's data bus
317314564Sdim  uint32_t GetDataByteSize();
318254721Semaste
319314564Sdim  /// Architecture code byte width accessor
320314564Sdim  ///
321353358Sdim  /// \return
322314564Sdim  /// The size in 8-bit (host) bytes of a minimum addressable
323314564Sdim  /// unit from the Architecture's code bus
324314564Sdim  uint32_t GetCodeByteSize();
325254721Semaste
326314564Sdim  /// Set the base load address for a module section.
327314564Sdim  ///
328353358Sdim  /// \param[in] section
329314564Sdim  ///     The section whose base load address will be set within this
330314564Sdim  ///     target.
331314564Sdim  ///
332353358Sdim  /// \param[in] section_base_addr
333314564Sdim  ///     The base address for the section.
334314564Sdim  ///
335353358Sdim  /// \return
336314564Sdim  ///      An error to indicate success, fail, and any reason for
337314564Sdim  ///     failure.
338314564Sdim  lldb::SBError SetSectionLoadAddress(lldb::SBSection section,
339314564Sdim                                      lldb::addr_t section_base_addr);
340254721Semaste
341314564Sdim  /// Clear the base load address for a module section.
342314564Sdim  ///
343353358Sdim  /// \param[in] section
344314564Sdim  ///     The section whose base load address will be cleared within
345314564Sdim  ///     this target.
346314564Sdim  ///
347353358Sdim  /// \return
348314564Sdim  ///      An error to indicate success, fail, and any reason for
349314564Sdim  ///     failure.
350314564Sdim  lldb::SBError ClearSectionLoadAddress(lldb::SBSection section);
351254721Semaste
352314564Sdim  /// Slide all file addresses for all module sections so that \a module
353314564Sdim  /// appears to loaded at these slide addresses.
354314564Sdim  ///
355314564Sdim  /// When you need all sections within a module to be loaded at a
356314564Sdim  /// rigid slide from the addresses found in the module object file,
357314564Sdim  /// this function will allow you to easily and quickly slide all
358314564Sdim  /// module sections.
359314564Sdim  ///
360353358Sdim  /// \param[in] module
361314564Sdim  ///     The module to load.
362314564Sdim  ///
363353358Sdim  /// \param[in] sections_offset
364314564Sdim  ///     An offset that will be applied to all section file addresses
365314564Sdim  ///     (the virtual addresses found in the object file itself).
366314564Sdim  ///
367353358Sdim  /// \return
368314564Sdim  ///     An error to indicate success, fail, and any reason for
369314564Sdim  ///     failure.
370314564Sdim  lldb::SBError SetModuleLoadAddress(lldb::SBModule module,
371314564Sdim                                     int64_t sections_offset);
372280031Sdim
373314564Sdim  /// Clear the section base load addresses for all sections in a module.
374314564Sdim  ///
375353358Sdim  /// \param[in] module
376314564Sdim  ///     The module to unload.
377314564Sdim  ///
378353358Sdim  /// \return
379314564Sdim  ///     An error to indicate success, fail, and any reason for
380314564Sdim  ///     failure.
381314564Sdim  lldb::SBError ClearModuleLoadAddress(lldb::SBModule module);
382280031Sdim
383314564Sdim  /// Find functions by name.
384314564Sdim  ///
385353358Sdim  /// \param[in] name
386314564Sdim  ///     The name of the function we are looking for.
387314564Sdim  ///
388353358Sdim  /// \param[in] name_type_mask
389314564Sdim  ///     A logical OR of one or more FunctionNameType enum bits that
390314564Sdim  ///     indicate what kind of names should be used when doing the
391314564Sdim  ///     lookup. Bits include fully qualified names, base names,
392314564Sdim  ///     C++ methods, or ObjC selectors.
393314564Sdim  ///     See FunctionNameType for more details.
394314564Sdim  ///
395353358Sdim  /// \return
396314564Sdim  ///     A lldb::SBSymbolContextList that gets filled in with all of
397314564Sdim  ///     the symbol contexts for all the matches.
398314564Sdim  lldb::SBSymbolContextList
399314564Sdim  FindFunctions(const char *name,
400314564Sdim                uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
401254721Semaste
402314564Sdim  /// Find global and static variables by name.
403314564Sdim  ///
404353358Sdim  /// \param[in] name
405314564Sdim  ///     The name of the global or static variable we are looking
406314564Sdim  ///     for.
407314564Sdim  ///
408353358Sdim  /// \param[in] max_matches
409314564Sdim  ///     Allow the number of matches to be limited to \a max_matches.
410314564Sdim  ///
411353358Sdim  /// \return
412314564Sdim  ///     A list of matched variables in an SBValueList.
413314564Sdim  lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches);
414280031Sdim
415314564Sdim  /// Find the first global (or static) variable by name.
416314564Sdim  ///
417353358Sdim  /// \param[in] name
418314564Sdim  ///     The name of the global or static variable we are looking
419314564Sdim  ///     for.
420314564Sdim  ///
421353358Sdim  /// \return
422314564Sdim  ///     An SBValue that gets filled in with the found variable (if any).
423314564Sdim  lldb::SBValue FindFirstGlobalVariable(const char *name);
424254721Semaste
425314564Sdim  /// Find global and static variables by pattern.
426314564Sdim  ///
427353358Sdim  /// \param[in] name
428314564Sdim  ///     The pattern to search for global or static variables
429314564Sdim  ///
430353358Sdim  /// \param[in] max_matches
431314564Sdim  ///     Allow the number of matches to be limited to \a max_matches.
432314564Sdim  ///
433353358Sdim  /// \param[in] matchtype
434314564Sdim  ///     The match type to use.
435314564Sdim  ///
436353358Sdim  /// \return
437314564Sdim  ///     A list of matched variables in an SBValueList.
438314564Sdim  lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches,
439314564Sdim                                        MatchType matchtype);
440262528Semaste
441314564Sdim  /// Find global functions by their name with pattern matching.
442314564Sdim  ///
443353358Sdim  /// \param[in] name
444314564Sdim  ///     The pattern to search for global or static variables
445314564Sdim  ///
446353358Sdim  /// \param[in] max_matches
447314564Sdim  ///     Allow the number of matches to be limited to \a max_matches.
448314564Sdim  ///
449353358Sdim  /// \param[in] matchtype
450314564Sdim  ///     The match type to use.
451314564Sdim  ///
452353358Sdim  /// \return
453314564Sdim  ///     A list of matched variables in an SBValueList.
454314564Sdim  lldb::SBSymbolContextList FindGlobalFunctions(const char *name,
455314564Sdim                                                uint32_t max_matches,
456314564Sdim                                                MatchType matchtype);
457254721Semaste
458314564Sdim  void Clear();
459280031Sdim
460314564Sdim  /// Resolve a current file address into a section offset address.
461314564Sdim  ///
462353358Sdim  /// \param[in] file_addr
463321369Sdim  ///     The file address to resolve.
464314564Sdim  ///
465353358Sdim  /// \return
466314564Sdim  ///     An SBAddress which will be valid if...
467314564Sdim  lldb::SBAddress ResolveFileAddress(lldb::addr_t file_addr);
468254721Semaste
469314564Sdim  /// Resolve a current load address into a section offset address.
470314564Sdim  ///
471353358Sdim  /// \param[in] vm_addr
472314564Sdim  ///     A virtual address from the current process state that is to
473314564Sdim  ///     be translated into a section offset address.
474314564Sdim  ///
475353358Sdim  /// \return
476314564Sdim  ///     An SBAddress which will be valid if \a vm_addr was
477314564Sdim  ///     successfully resolved into a section offset address, or an
478314564Sdim  ///     invalid SBAddress if \a vm_addr doesn't resolve to a section
479314564Sdim  ///     in a module.
480314564Sdim  lldb::SBAddress ResolveLoadAddress(lldb::addr_t vm_addr);
481254721Semaste
482314564Sdim  /// Resolve a current load address into a section offset address
483314564Sdim  /// using the process stop ID to identify a time in the past.
484314564Sdim  ///
485353358Sdim  /// \param[in] stop_id
486314564Sdim  ///     Each time a process stops, the process stop ID integer gets
487314564Sdim  ///     incremented. These stop IDs are used to identify past times
488314564Sdim  ///     and can be used in history objects as a cheap way to store
489314564Sdim  ///     the time at which the sample was taken. Specifying
490314564Sdim  ///     UINT32_MAX will always resolve the address using the
491314564Sdim  ///     currently loaded sections.
492314564Sdim  ///
493353358Sdim  /// \param[in] vm_addr
494314564Sdim  ///     A virtual address from the current process state that is to
495314564Sdim  ///     be translated into a section offset address.
496314564Sdim  ///
497353358Sdim  /// \return
498314564Sdim  ///     An SBAddress which will be valid if \a vm_addr was
499314564Sdim  ///     successfully resolved into a section offset address, or an
500314564Sdim  ///     invalid SBAddress if \a vm_addr doesn't resolve to a section
501314564Sdim  ///     in a module.
502314564Sdim  lldb::SBAddress ResolvePastLoadAddress(uint32_t stop_id,
503314564Sdim                                         lldb::addr_t vm_addr);
504309124Sdim
505314564Sdim  SBSymbolContext ResolveSymbolContextForAddress(const SBAddress &addr,
506314564Sdim                                                 uint32_t resolve_scope);
507254721Semaste
508314564Sdim  /// Read target memory. If a target process is running then memory
509314564Sdim  /// is read from here. Otherwise the memory is read from the object
510314564Sdim  /// files. For a target whose bytes are sized as a multiple of host
511314564Sdim  /// bytes, the data read back will preserve the target's byte order.
512314564Sdim  ///
513353358Sdim  /// \param[in] addr
514314564Sdim  ///     A target address to read from.
515314564Sdim  ///
516353358Sdim  /// \param[out] buf
517314564Sdim  ///     The buffer to read memory into.
518314564Sdim  ///
519353358Sdim  /// \param[in] size
520314564Sdim  ///     The maximum number of host bytes to read in the buffer passed
521314564Sdim  ///     into this call
522314564Sdim  ///
523353358Sdim  /// \param[out] error
524321369Sdim  ///     Status information is written here if the memory read fails.
525314564Sdim  ///
526353358Sdim  /// \return
527314564Sdim  ///     The amount of data read in host bytes.
528314564Sdim  size_t ReadMemory(const SBAddress addr, void *buf, size_t size,
529314564Sdim                    lldb::SBError &error);
530254721Semaste
531314564Sdim  lldb::SBBreakpoint BreakpointCreateByLocation(const char *file,
532314564Sdim                                                uint32_t line);
533254721Semaste
534314564Sdim  lldb::SBBreakpoint
535314564Sdim  BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line);
536296417Sdim
537314564Sdim  lldb::SBBreakpoint
538314564Sdim  BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
539314564Sdim                             lldb::addr_t offset);
540254721Semaste
541314564Sdim  lldb::SBBreakpoint
542314564Sdim  BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
543314564Sdim                             lldb::addr_t offset, SBFileSpecList &module_list);
544296417Sdim
545344779Sdim  lldb::SBBreakpoint
546344779Sdim  BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
547344779Sdim                             uint32_t column, lldb::addr_t offset,
548344779Sdim                             SBFileSpecList &module_list);
549344779Sdim
550314564Sdim  lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name,
551314564Sdim                                            const char *module_name = nullptr);
552309124Sdim
553314564Sdim  // This version uses name_type_mask = eFunctionNameTypeAuto
554314564Sdim  lldb::SBBreakpoint
555314564Sdim  BreakpointCreateByName(const char *symbol_name,
556314564Sdim                         const SBFileSpecList &module_list,
557314564Sdim                         const SBFileSpecList &comp_unit_list);
558254721Semaste
559314564Sdim  lldb::SBBreakpoint BreakpointCreateByName(
560314564Sdim      const char *symbol_name,
561314564Sdim      uint32_t
562314564Sdim          name_type_mask, // Logical OR one or more FunctionNameType enum bits
563314564Sdim      const SBFileSpecList &module_list,
564314564Sdim      const SBFileSpecList &comp_unit_list);
565254721Semaste
566314564Sdim  lldb::SBBreakpoint BreakpointCreateByName(
567314564Sdim      const char *symbol_name,
568314564Sdim      uint32_t
569314564Sdim          name_type_mask, // Logical OR one or more FunctionNameType enum bits
570314564Sdim      lldb::LanguageType symbol_language,
571314564Sdim      const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
572254721Semaste
573314564Sdim  lldb::SBBreakpoint BreakpointCreateByNames(
574314564Sdim      const char *symbol_name[], uint32_t num_names,
575314564Sdim      uint32_t
576314564Sdim          name_type_mask, // Logical OR one or more FunctionNameType enum bits
577314564Sdim      const SBFileSpecList &module_list,
578314564Sdim      const SBFileSpecList &comp_unit_list);
579296417Sdim
580314564Sdim  lldb::SBBreakpoint BreakpointCreateByNames(
581314564Sdim      const char *symbol_name[], uint32_t num_names,
582314564Sdim      uint32_t
583314564Sdim          name_type_mask, // Logical OR one or more FunctionNameType enum bits
584314564Sdim      lldb::LanguageType symbol_language,
585314564Sdim      const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
586254721Semaste
587314564Sdim  lldb::SBBreakpoint BreakpointCreateByNames(
588314564Sdim      const char *symbol_name[], uint32_t num_names,
589314564Sdim      uint32_t
590314564Sdim          name_type_mask, // Logical OR one or more FunctionNameType enum bits
591314564Sdim      lldb::LanguageType symbol_language,
592314564Sdim      lldb::addr_t offset, const SBFileSpecList &module_list,
593314564Sdim      const SBFileSpecList &comp_unit_list);
594254721Semaste
595314564Sdim  lldb::SBBreakpoint BreakpointCreateByRegex(const char *symbol_name_regex,
596314564Sdim                                             const char *module_name = nullptr);
597254721Semaste
598314564Sdim  lldb::SBBreakpoint
599314564Sdim  BreakpointCreateByRegex(const char *symbol_name_regex,
600314564Sdim                          const SBFileSpecList &module_list,
601314564Sdim                          const SBFileSpecList &comp_unit_list);
602254721Semaste
603314564Sdim  lldb::SBBreakpoint BreakpointCreateByRegex(
604314564Sdim      const char *symbol_name_regex, lldb::LanguageType symbol_language,
605314564Sdim      const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
606254721Semaste
607314564Sdim  lldb::SBBreakpoint
608314564Sdim  BreakpointCreateBySourceRegex(const char *source_regex,
609314564Sdim                                const SBFileSpec &source_file,
610314564Sdim                                const char *module_name = nullptr);
611254721Semaste
612314564Sdim  lldb::SBBreakpoint
613314564Sdim  BreakpointCreateBySourceRegex(const char *source_regex,
614314564Sdim                                const SBFileSpecList &module_list,
615314564Sdim                                const SBFileSpecList &source_file);
616254721Semaste
617314564Sdim  lldb::SBBreakpoint BreakpointCreateBySourceRegex(
618314564Sdim      const char *source_regex, const SBFileSpecList &module_list,
619314564Sdim      const SBFileSpecList &source_file, const SBStringList &func_names);
620254721Semaste
621314564Sdim  lldb::SBBreakpoint BreakpointCreateForException(lldb::LanguageType language,
622314564Sdim                                                  bool catch_bp, bool throw_bp);
623254721Semaste
624314564Sdim  lldb::SBBreakpoint BreakpointCreateByAddress(addr_t address);
625254721Semaste
626314564Sdim  lldb::SBBreakpoint BreakpointCreateBySBAddress(SBAddress &address);
627344779Sdim
628344779Sdim  /// Create a breakpoint using a scripted resolver.
629344779Sdim  ///
630353358Sdim  /// \param[in] class_name
631344779Sdim  ///    This is the name of the class that implements a scripted resolver.
632344779Sdim  ///
633353358Sdim  /// \param[in] extra_args
634344779Sdim  ///    This is an SBStructuredData object that will get passed to the
635344779Sdim  ///    constructor of the class in class_name.  You can use this to
636344779Sdim  ///    reuse the same class, parametrizing with entries from this
637344779Sdim  ///    dictionary.
638344779Sdim  ///
639353358Sdim  /// \param module_list
640344779Sdim  ///    If this is non-empty, this will be used as the module filter in the
641344779Sdim  ///    SearchFilter created for this breakpoint.
642344779Sdim  ///
643353358Sdim  /// \param file_list
644344779Sdim  ///    If this is non-empty, this will be used as the comp unit filter in the
645344779Sdim  ///    SearchFilter created for this breakpoint.
646344779Sdim  ///
647353358Sdim  /// \return
648344779Sdim  ///     An SBBreakpoint that will set locations based on the logic in the
649344779Sdim  ///     resolver's search callback.
650344779Sdim  lldb::SBBreakpoint BreakpointCreateFromScript(
651344779Sdim      const char *class_name,
652344779Sdim      SBStructuredData &extra_args,
653344779Sdim      const SBFileSpecList &module_list,
654344779Sdim      const SBFileSpecList &file_list,
655344779Sdim      bool request_hardware = false);
656254721Semaste
657314564Sdim  /// Read breakpoints from source_file and return the newly created
658314564Sdim  /// breakpoints in bkpt_list.
659314564Sdim  ///
660353358Sdim  /// \param[in] source_file
661314564Sdim  ///    The file from which to read the breakpoints.
662314564Sdim  ///
663353358Sdim  /// \param[out] new_bps
664314564Sdim  ///    A list of the newly created breakpoints.
665314564Sdim  ///
666353358Sdim  /// \return
667314564Sdim  ///     An SBError detailing any errors in reading in the breakpoints.
668314564Sdim  lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file,
669314564Sdim                                          SBBreakpointList &new_bps);
670254721Semaste
671314564Sdim  /// Read breakpoints from source_file and return the newly created
672314564Sdim  /// breakpoints in bkpt_list.
673314564Sdim  ///
674353358Sdim  /// \param[in] source_file
675314564Sdim  ///    The file from which to read the breakpoints.
676314564Sdim  ///
677353358Sdim  /// \param[in] matching_names
678314564Sdim  ///    Only read in breakpoints whose names match one of the names in this
679314564Sdim  ///    list.
680314564Sdim  ///
681353358Sdim  /// \param[out] new_bps
682314564Sdim  ///    A list of the newly created breakpoints.
683314564Sdim  ///
684353358Sdim  /// \return
685314564Sdim  ///     An SBError detailing any errors in reading in the breakpoints.
686314564Sdim  lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file,
687314564Sdim                                          SBStringList &matching_names,
688314564Sdim                                          SBBreakpointList &new_bps);
689254721Semaste
690314564Sdim  /// Write breakpoints to dest_file.
691314564Sdim  ///
692353358Sdim  /// \param[in] dest_file
693314564Sdim  ///    The file to which to write the breakpoints.
694314564Sdim  ///
695353358Sdim  /// \return
696314564Sdim  ///     An SBError detailing any errors in writing in the breakpoints.
697314564Sdim  lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file);
698254721Semaste
699314564Sdim  /// Write breakpoints listed in bkpt_list to dest_file.
700314564Sdim  ///
701353358Sdim  /// \param[in] dest_file
702314564Sdim  ///    The file to which to write the breakpoints.
703314564Sdim  ///
704353358Sdim  /// \param[in] bkpt_list
705314564Sdim  ///    Only write breakpoints from this list.
706314564Sdim  ///
707353358Sdim  /// \param[in] append
708353358Sdim  ///    If \b true, append the breakpoints in bkpt_list to the others
709314564Sdim  ///    serialized in dest_file.  If dest_file doesn't exist, then a new
710314564Sdim  ///    file will be created and the breakpoints in bkpt_list written to it.
711314564Sdim  ///
712353358Sdim  /// \return
713314564Sdim  ///     An SBError detailing any errors in writing in the breakpoints.
714314564Sdim  lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file,
715314564Sdim                                       SBBreakpointList &bkpt_list,
716314564Sdim                                       bool append = false);
717254721Semaste
718314564Sdim  uint32_t GetNumBreakpoints() const;
719280031Sdim
720314564Sdim  lldb::SBBreakpoint GetBreakpointAtIndex(uint32_t idx) const;
721280031Sdim
722314564Sdim  bool BreakpointDelete(break_id_t break_id);
723254721Semaste
724314564Sdim  lldb::SBBreakpoint FindBreakpointByID(break_id_t break_id);
725254721Semaste
726314564Sdim  // Finds all breakpoints by name, returning the list in bkpt_list.  Returns
727314564Sdim  // false if the name is not a valid breakpoint name, true otherwise.
728314564Sdim  bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list);
729341825Sdim
730327952Sdim  void GetBreakpointNames(SBStringList &names);
731341825Sdim
732327952Sdim  void DeleteBreakpointName(const char *name);
733254721Semaste
734314564Sdim  bool EnableAllBreakpoints();
735254721Semaste
736314564Sdim  bool DisableAllBreakpoints();
737254721Semaste
738314564Sdim  bool DeleteAllBreakpoints();
739254721Semaste
740314564Sdim  uint32_t GetNumWatchpoints() const;
741254721Semaste
742314564Sdim  lldb::SBWatchpoint GetWatchpointAtIndex(uint32_t idx) const;
743254721Semaste
744314564Sdim  bool DeleteWatchpoint(lldb::watch_id_t watch_id);
745288943Sdim
746314564Sdim  lldb::SBWatchpoint FindWatchpointByID(lldb::watch_id_t watch_id);
747254721Semaste
748314564Sdim  lldb::SBWatchpoint WatchAddress(lldb::addr_t addr, size_t size, bool read,
749314564Sdim                                  bool write, SBError &error);
750288943Sdim
751314564Sdim  bool EnableAllWatchpoints();
752288943Sdim
753314564Sdim  bool DisableAllWatchpoints();
754314564Sdim
755314564Sdim  bool DeleteAllWatchpoints();
756314564Sdim
757314564Sdim  lldb::SBBroadcaster GetBroadcaster() const;
758314564Sdim
759314564Sdim  lldb::SBType FindFirstType(const char *type);
760314564Sdim
761314564Sdim  lldb::SBTypeList FindTypes(const char *type);
762314564Sdim
763314564Sdim  lldb::SBType GetBasicType(lldb::BasicType type);
764314564Sdim
765314564Sdim  lldb::SBValue CreateValueFromAddress(const char *name, lldb::SBAddress addr,
766314564Sdim                                       lldb::SBType type);
767314564Sdim
768314564Sdim  lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data,
769314564Sdim                                    lldb::SBType type);
770314564Sdim
771314564Sdim  lldb::SBValue CreateValueFromExpression(const char *name, const char *expr);
772314564Sdim
773314564Sdim  SBSourceManager GetSourceManager();
774314564Sdim
775314564Sdim  lldb::SBInstructionList ReadInstructions(lldb::SBAddress base_addr,
776314564Sdim                                           uint32_t count);
777314564Sdim
778314564Sdim  lldb::SBInstructionList ReadInstructions(lldb::SBAddress base_addr,
779314564Sdim                                           uint32_t count,
780314564Sdim                                           const char *flavor_string);
781314564Sdim
782314564Sdim  lldb::SBInstructionList GetInstructions(lldb::SBAddress base_addr,
783314564Sdim                                          const void *buf, size_t size);
784314564Sdim
785314564Sdim  // The "WithFlavor" is necessary to keep SWIG from getting confused about
786341825Sdim  // overloaded arguments when using the buf + size -> Python Object magic.
787314564Sdim
788314564Sdim  lldb::SBInstructionList GetInstructionsWithFlavor(lldb::SBAddress base_addr,
789314564Sdim                                                    const char *flavor_string,
790314564Sdim                                                    const void *buf,
791314564Sdim                                                    size_t size);
792314564Sdim
793314564Sdim  lldb::SBInstructionList GetInstructions(lldb::addr_t base_addr,
794314564Sdim                                          const void *buf, size_t size);
795314564Sdim
796314564Sdim  lldb::SBInstructionList GetInstructionsWithFlavor(lldb::addr_t base_addr,
797314564Sdim                                                    const char *flavor_string,
798314564Sdim                                                    const void *buf,
799314564Sdim                                                    size_t size);
800314564Sdim
801314564Sdim  lldb::SBSymbolContextList FindSymbols(const char *name,
802314564Sdim                                        lldb::SymbolType type = eSymbolTypeAny);
803314564Sdim
804314564Sdim  bool operator==(const lldb::SBTarget &rhs) const;
805314564Sdim
806314564Sdim  bool operator!=(const lldb::SBTarget &rhs) const;
807314564Sdim
808314564Sdim  bool GetDescription(lldb::SBStream &description,
809314564Sdim                      lldb::DescriptionLevel description_level);
810314564Sdim
811314564Sdim  lldb::SBValue EvaluateExpression(const char *expr);
812314564Sdim
813314564Sdim  lldb::SBValue EvaluateExpression(const char *expr,
814314564Sdim                                   const SBExpressionOptions &options);
815314564Sdim
816314564Sdim  lldb::addr_t GetStackRedZoneSize();
817314564Sdim
818314564Sdim  lldb::SBLaunchInfo GetLaunchInfo() const;
819314564Sdim
820314564Sdim  void SetLaunchInfo(const lldb::SBLaunchInfo &launch_info);
821314564Sdim
822254721Semasteprotected:
823314564Sdim  friend class SBAddress;
824314564Sdim  friend class SBBlock;
825314564Sdim  friend class SBBreakpointList;
826327952Sdim  friend class SBBreakpointNameImpl;
827314564Sdim  friend class SBDebugger;
828314564Sdim  friend class SBExecutionContext;
829314564Sdim  friend class SBFunction;
830314564Sdim  friend class SBInstruction;
831314564Sdim  friend class SBModule;
832314564Sdim  friend class SBProcess;
833314564Sdim  friend class SBSection;
834314564Sdim  friend class SBSourceManager;
835314564Sdim  friend class SBSymbol;
836314564Sdim  friend class SBValue;
837344779Sdim  friend class SBVariablesOptions;
838254721Semaste
839341825Sdim  // Constructors are private, use static Target::Create function to create an
840341825Sdim  // instance of this class.
841254721Semaste
842314564Sdim  lldb::TargetSP GetSP() const;
843254721Semaste
844314564Sdim  void SetSP(const lldb::TargetSP &target_sp);
845254721Semaste
846254721Semasteprivate:
847314564Sdim  lldb::TargetSP m_opaque_sp;
848254721Semaste};
849254721Semaste
850254721Semaste} // namespace lldb
851254721Semaste
852296417Sdim#endif // LLDB_SBTarget_h_
853