xref: /llvm-project/lldb/include/lldb/API/SBTarget.h (revision 24feaab8380c69d5fa3eb8c21ef2d660913fd4a9)
1 //===-- SBTarget.h ----------------------------------------------*- 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 #ifndef LLDB_API_SBTARGET_H
10 #define LLDB_API_SBTARGET_H
11 
12 #include "lldb/API/SBAddress.h"
13 #include "lldb/API/SBAttachInfo.h"
14 #include "lldb/API/SBBreakpoint.h"
15 #include "lldb/API/SBBroadcaster.h"
16 #include "lldb/API/SBDefines.h"
17 #include "lldb/API/SBFileSpec.h"
18 #include "lldb/API/SBFileSpecList.h"
19 #include "lldb/API/SBLaunchInfo.h"
20 #include "lldb/API/SBStatisticsOptions.h"
21 #include "lldb/API/SBSymbolContextList.h"
22 #include "lldb/API/SBType.h"
23 #include "lldb/API/SBValue.h"
24 #include "lldb/API/SBWatchpoint.h"
25 #include "lldb/API/SBWatchpointOptions.h"
26 
27 namespace lldb_private {
28 namespace python {
29 class SWIGBridge;
30 }
31 } // namespace lldb_private
32 
33 namespace lldb {
34 
35 class SBPlatform;
36 
37 class LLDB_API SBTarget {
38 public:
39   // Broadcaster bits.
40   enum {
41     eBroadcastBitBreakpointChanged = (1 << 0),
42     eBroadcastBitModulesLoaded = (1 << 1),
43     eBroadcastBitModulesUnloaded = (1 << 2),
44     eBroadcastBitWatchpointChanged = (1 << 3),
45     eBroadcastBitSymbolsLoaded = (1 << 4),
46     eBroadcastBitSymbolsChanged = (1 << 5),
47   };
48 
49   // Constructors
50   SBTarget();
51 
52   SBTarget(const lldb::SBTarget &rhs);
53 
54   // Destructor
55   ~SBTarget();
56 
57   const lldb::SBTarget &operator=(const lldb::SBTarget &rhs);
58 
59   explicit operator bool() const;
60 
61   bool IsValid() const;
62 
63   static bool EventIsTargetEvent(const lldb::SBEvent &event);
64 
65   static lldb::SBTarget GetTargetFromEvent(const lldb::SBEvent &event);
66 
67   static uint32_t GetNumModulesFromEvent(const lldb::SBEvent &event);
68 
69   static lldb::SBModule GetModuleAtIndexFromEvent(const uint32_t idx,
70                                                   const lldb::SBEvent &event);
71 
72   static const char *GetBroadcasterClassName();
73 
74   lldb::SBProcess GetProcess();
75 
76   /// Sets whether we should collect statistics on lldb or not.
77   ///
78   /// \param[in] v
79   ///     A boolean to control the collection.
80   void SetCollectingStats(bool v);
81 
82   /// Returns whether statistics collection are enabled.
83   ///
84   /// \return
85   ///     true if statistics are currently being collected, false
86   ///     otherwise.
87   bool GetCollectingStats();
88 
89   /// Returns a dump of the collected statistics.
90   ///
91   /// \return
92   ///     A SBStructuredData with the statistics collected.
93   lldb::SBStructuredData GetStatistics();
94 
95   /// Returns a dump of the collected statistics.
96   ///
97   /// \param[in] options
98   ///   An objects object that contains all options for the statistics dumping.
99   ///
100   /// \return
101   ///     A SBStructuredData with the statistics collected.
102   lldb::SBStructuredData GetStatistics(SBStatisticsOptions options);
103 
104   /// Reset the statistics collected for this target.
105   /// This includes clearing symbol table and debug info parsing/index time for
106   /// all modules, breakpoint resolve time and target statistics.
107   void ResetStatistics();
108 
109   /// Return the platform object associated with the target.
110   ///
111   /// After return, the platform object should be checked for
112   /// validity.
113   ///
114   /// \return
115   ///     A platform object.
116   lldb::SBPlatform GetPlatform();
117 
118   /// Return the environment variables that would be used to launch a new
119   /// process.
120   ///
121   /// \return
122   ///     An lldb::SBEnvironment object which is a copy of the target's
123   ///     environment.
124 
125   SBEnvironment GetEnvironment();
126 
127   /// Install any binaries that need to be installed.
128   ///
129   /// This function does nothing when debugging on the host system.
130   /// When connected to remote platforms, the target's main executable
131   /// and any modules that have their remote install path set will be
132   /// installed on the remote platform. If the main executable doesn't
133   /// have an install location set, it will be installed in the remote
134   /// platform's working directory.
135   ///
136   /// \return
137   ///     An error describing anything that went wrong during
138   ///     installation.
139   SBError Install();
140 
141   /// Launch a new process.
142   ///
143   /// Launch a new process by spawning a new process using the
144   /// target object's executable module's file as the file to launch.
145   /// Arguments are given in \a argv, and the environment variables
146   /// are in \a envp. Standard input and output files can be
147   /// optionally re-directed to \a stdin_path, \a stdout_path, and
148   /// \a stderr_path.
149   ///
150   /// \param[in] listener
151   ///     An optional listener that will receive all process events.
152   ///     If \a listener is valid then \a listener will listen to all
153   ///     process events. If not valid, then this target's debugger
154   ///     (SBTarget::GetDebugger()) will listen to all process events.
155   ///
156   /// \param[in] argv
157   ///     The argument array.
158   ///
159   /// \param[in] envp
160   ///     The environment array. If this is null, the default
161   ///     environment values (provided through `settings set
162   ///     target.env-vars`) will be used.
163   ///
164   /// \param[in] stdin_path
165   ///     The path to use when re-directing the STDIN of the new
166   ///     process. If all stdXX_path arguments are nullptr, a pseudo
167   ///     terminal will be used.
168   ///
169   /// \param[in] stdout_path
170   ///     The path to use when re-directing the STDOUT of the new
171   ///     process. If all stdXX_path arguments are nullptr, a pseudo
172   ///     terminal will be used.
173   ///
174   /// \param[in] stderr_path
175   ///     The path to use when re-directing the STDERR of the new
176   ///     process. If all stdXX_path arguments are nullptr, a pseudo
177   ///     terminal will be used.
178   ///
179   /// \param[in] working_directory
180   ///     The working directory to have the child process run in
181   ///
182   /// \param[in] launch_flags
183   ///     Some launch options specified by logical OR'ing
184   ///     lldb::LaunchFlags enumeration values together.
185   ///
186   /// \param[in] stop_at_entry
187   ///     If false do not stop the inferior at the entry point.
188   ///
189   /// \param[out] error
190   ///     An error object. Contains the reason if there is some failure.
191   ///
192   /// \return
193   ///      A process object for the newly created process.
194   lldb::SBProcess Launch(SBListener &listener, char const **argv,
195                          char const **envp, const char *stdin_path,
196                          const char *stdout_path, const char *stderr_path,
197                          const char *working_directory,
198                          uint32_t launch_flags, // See LaunchFlags
199                          bool stop_at_entry, lldb::SBError &error);
200 
201   SBProcess LoadCore(const char *core_file);
202   SBProcess LoadCore(const char *core_file, lldb::SBError &error);
203 
204   /// Launch a new process with sensible defaults.
205   ///
206   /// \param[in] argv
207   ///     The argument array.
208   ///
209   /// \param[in] envp
210   ///     The environment array. If this isn't provided, the default
211   ///     environment values (provided through `settings set
212   ///     target.env-vars`) will be used.
213   ///
214   /// \param[in] working_directory
215   ///     The working directory to have the child process run in
216   ///
217   /// Default: listener
218   ///     Set to the target's debugger (SBTarget::GetDebugger())
219   ///
220   /// Default: launch_flags
221   ///     Empty launch flags
222   ///
223   /// Default: stdin_path
224   /// Default: stdout_path
225   /// Default: stderr_path
226   ///     A pseudo terminal will be used.
227   ///
228   /// \return
229   ///      A process object for the newly created process.
230   SBProcess LaunchSimple(const char **argv, const char **envp,
231                          const char *working_directory);
232 
233   SBProcess Launch(SBLaunchInfo &launch_info, SBError &error);
234 
235   SBProcess Attach(SBAttachInfo &attach_info, SBError &error);
236 
237   /// Attach to process with pid.
238   ///
239   /// \param[in] listener
240   ///     An optional listener that will receive all process events.
241   ///     If \a listener is valid then \a listener will listen to all
242   ///     process events. If not valid, then this target's debugger
243   ///     (SBTarget::GetDebugger()) will listen to all process events.
244   ///
245   /// \param[in] pid
246   ///     The process ID to attach to.
247   ///
248   /// \param[out] error
249   ///     An error explaining what went wrong if attach fails.
250   ///
251   /// \return
252   ///      A process object for the attached process.
253   lldb::SBProcess AttachToProcessWithID(SBListener &listener, lldb::pid_t pid,
254                                         lldb::SBError &error);
255 
256   /// Attach to process with name.
257   ///
258   /// \param[in] listener
259   ///     An optional listener that will receive all process events.
260   ///     If \a listener is valid then \a listener will listen to all
261   ///     process events. If not valid, then this target's debugger
262   ///     (SBTarget::GetDebugger()) will listen to all process events.
263   ///
264   /// \param[in] name
265   ///     Basename of process to attach to.
266   ///
267   /// \param[in] wait_for
268   ///     If true wait for a new instance of 'name' to be launched.
269   ///
270   /// \param[out] error
271   ///     An error explaining what went wrong if attach fails.
272   ///
273   /// \return
274   ///      A process object for the attached process.
275   lldb::SBProcess AttachToProcessWithName(SBListener &listener,
276                                           const char *name, bool wait_for,
277                                           lldb::SBError &error);
278 
279   /// Connect to a remote debug server with url.
280   ///
281   /// \param[in] listener
282   ///     An optional listener that will receive all process events.
283   ///     If \a listener is valid then \a listener will listen to all
284   ///     process events. If not valid, then this target's debugger
285   ///     (SBTarget::GetDebugger()) will listen to all process events.
286   ///
287   /// \param[in] url
288   ///     The url to connect to, e.g., 'connect://localhost:12345'.
289   ///
290   /// \param[in] plugin_name
291   ///     The plugin name to be used; can be nullptr.
292   ///
293   /// \param[out] error
294   ///     An error explaining what went wrong if the connect fails.
295   ///
296   /// \return
297   ///      A process object for the connected process.
298   lldb::SBProcess ConnectRemote(SBListener &listener, const char *url,
299                                 const char *plugin_name, SBError &error);
300 
301   lldb::SBFileSpec GetExecutable();
302 
303   // Append the path mapping (from -> to) to the target's paths mapping list.
304   void AppendImageSearchPath(const char *from, const char *to,
305                              lldb::SBError &error);
306 
307   bool AddModule(lldb::SBModule &module);
308 
309   lldb::SBModule AddModule(const char *path, const char *triple,
310                            const char *uuid);
311 
312   lldb::SBModule AddModule(const char *path, const char *triple,
313                            const char *uuid_cstr, const char *symfile);
314 
315   lldb::SBModule AddModule(const SBModuleSpec &module_spec);
316 
317   uint32_t GetNumModules() const;
318 
319   lldb::SBModule GetModuleAtIndex(uint32_t idx);
320 
321   bool RemoveModule(lldb::SBModule module);
322 
323   lldb::SBDebugger GetDebugger() const;
324 
325   lldb::SBModule FindModule(const lldb::SBFileSpec &file_spec);
326 
327   /// Find compile units related to *this target and passed source
328   /// file.
329   ///
330   /// \param[in] sb_file_spec
331   ///     A lldb::SBFileSpec object that contains source file
332   ///     specification.
333   ///
334   /// \return
335   ///     A lldb::SBSymbolContextList that gets filled in with all of
336   ///     the symbol contexts for all the matches.
337   lldb::SBSymbolContextList
338   FindCompileUnits(const lldb::SBFileSpec &sb_file_spec);
339 
340   lldb::ByteOrder GetByteOrder();
341 
342   uint32_t GetAddressByteSize();
343 
344   const char *GetTriple();
345 
346   const char *GetABIName();
347 
348   const char *GetLabel() const;
349 
350   SBError SetLabel(const char *label);
351 
352   /// Architecture data byte width accessor
353   ///
354   /// \return
355   /// The size in 8-bit (host) bytes of a minimum addressable
356   /// unit from the Architecture's data bus
357   uint32_t GetDataByteSize();
358 
359   /// Architecture code byte width accessor
360   ///
361   /// \return
362   /// The size in 8-bit (host) bytes of a minimum addressable
363   /// unit from the Architecture's code bus
364   uint32_t GetCodeByteSize();
365 
366   /// Gets the target.max-children-count value
367   /// It should be used to limit the number of
368   /// children of large data structures to be displayed.
369   uint32_t GetMaximumNumberOfChildrenToDisplay() const;
370 
371   /// Set the base load address for a module section.
372   ///
373   /// \param[in] section
374   ///     The section whose base load address will be set within this
375   ///     target.
376   ///
377   /// \param[in] section_base_addr
378   ///     The base address for the section.
379   ///
380   /// \return
381   ///      An error to indicate success, fail, and any reason for
382   ///     failure.
383   lldb::SBError SetSectionLoadAddress(lldb::SBSection section,
384                                       lldb::addr_t section_base_addr);
385 
386   /// Clear the base load address for a module section.
387   ///
388   /// \param[in] section
389   ///     The section whose base load address will be cleared within
390   ///     this target.
391   ///
392   /// \return
393   ///      An error to indicate success, fail, and any reason for
394   ///     failure.
395   lldb::SBError ClearSectionLoadAddress(lldb::SBSection section);
396 
397 #ifndef SWIG
398   /// Slide all file addresses for all module sections so that \a module
399   /// appears to loaded at these slide addresses.
400   ///
401   /// When you need all sections within a module to be loaded at a
402   /// rigid slide from the addresses found in the module object file,
403   /// this function will allow you to easily and quickly slide all
404   /// module sections.
405   ///
406   /// \param[in] module
407   ///     The module to load.
408   ///
409   /// \param[in] sections_offset
410   ///     An offset that will be applied to all section file addresses
411   ///     (the virtual addresses found in the object file itself).
412   ///
413   /// \return
414   ///     An error to indicate success, fail, and any reason for
415   ///     failure.
416   LLDB_DEPRECATED_FIXME("Use SetModuleLoadAddress(lldb::SBModule, uint64_t)",
417                         "SetModuleLoadAddress(lldb::SBModule, uint64_t)")
418   lldb::SBError SetModuleLoadAddress(lldb::SBModule module,
419                                      int64_t sections_offset);
420 #endif
421 
422   /// Slide all file addresses for all module sections so that \a module
423   /// appears to loaded at these slide addresses.
424   ///
425   /// When you need all sections within a module to be loaded at a
426   /// rigid slide from the addresses found in the module object file,
427   /// this function will allow you to easily and quickly slide all
428   /// module sections.
429   ///
430   /// \param[in] module
431   ///     The module to load.
432   ///
433   /// \param[in] sections_offset
434   ///     An offset that will be applied to all section file addresses
435   ///     (the virtual addresses found in the object file itself).
436   ///
437   /// \return
438   ///     An error to indicate success, fail, and any reason for
439   ///     failure.
440   lldb::SBError SetModuleLoadAddress(lldb::SBModule module,
441                                      uint64_t sections_offset);
442 
443   /// Clear the section base load addresses for all sections in a module.
444   ///
445   /// \param[in] module
446   ///     The module to unload.
447   ///
448   /// \return
449   ///     An error to indicate success, fail, and any reason for
450   ///     failure.
451   lldb::SBError ClearModuleLoadAddress(lldb::SBModule module);
452 
453   /// Find functions by name.
454   ///
455   /// \param[in] name
456   ///     The name of the function we are looking for.
457   ///
458   /// \param[in] name_type_mask
459   ///     A logical OR of one or more FunctionNameType enum bits that
460   ///     indicate what kind of names should be used when doing the
461   ///     lookup. Bits include fully qualified names, base names,
462   ///     C++ methods, or ObjC selectors.
463   ///     See FunctionNameType for more details.
464   ///
465   /// \return
466   ///     A lldb::SBSymbolContextList that gets filled in with all of
467   ///     the symbol contexts for all the matches.
468   lldb::SBSymbolContextList
469   FindFunctions(const char *name,
470                 uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
471 
472   /// Find global and static variables by name.
473   ///
474   /// \param[in] name
475   ///     The name of the global or static variable we are looking
476   ///     for.
477   ///
478   /// \param[in] max_matches
479   ///     Allow the number of matches to be limited to \a max_matches.
480   ///
481   /// \return
482   ///     A list of matched variables in an SBValueList.
483   lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches);
484 
485   /// Find the first global (or static) variable by name.
486   ///
487   /// \param[in] name
488   ///     The name of the global or static variable we are looking
489   ///     for.
490   ///
491   /// \return
492   ///     An SBValue that gets filled in with the found variable (if any).
493   lldb::SBValue FindFirstGlobalVariable(const char *name);
494 
495   /// Find global and static variables by pattern.
496   ///
497   /// \param[in] name
498   ///     The pattern to search for global or static variables
499   ///
500   /// \param[in] max_matches
501   ///     Allow the number of matches to be limited to \a max_matches.
502   ///
503   /// \param[in] matchtype
504   ///     The match type to use.
505   ///
506   /// \return
507   ///     A list of matched variables in an SBValueList.
508   lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches,
509                                         MatchType matchtype);
510 
511   /// Find global functions by their name with pattern matching.
512   ///
513   /// \param[in] name
514   ///     The pattern to search for global or static variables
515   ///
516   /// \param[in] max_matches
517   ///     Allow the number of matches to be limited to \a max_matches.
518   ///
519   /// \param[in] matchtype
520   ///     The match type to use.
521   ///
522   /// \return
523   ///     A list of matched variables in an SBValueList.
524   lldb::SBSymbolContextList FindGlobalFunctions(const char *name,
525                                                 uint32_t max_matches,
526                                                 MatchType matchtype);
527 
528   void Clear();
529 
530   /// Resolve a current file address into a section offset address.
531   ///
532   /// \param[in] file_addr
533   ///     The file address to resolve.
534   ///
535   /// \return
536   ///     An SBAddress which will be valid if...
537   lldb::SBAddress ResolveFileAddress(lldb::addr_t file_addr);
538 
539   /// Resolve a current load address into a section offset address.
540   ///
541   /// \param[in] vm_addr
542   ///     A virtual address from the current process state that is to
543   ///     be translated into a section offset address.
544   ///
545   /// \return
546   ///     An SBAddress which will be valid if \a vm_addr was
547   ///     successfully resolved into a section offset address, or an
548   ///     invalid SBAddress if \a vm_addr doesn't resolve to a section
549   ///     in a module.
550   lldb::SBAddress ResolveLoadAddress(lldb::addr_t vm_addr);
551 
552   /// Resolve a current load address into a section offset address
553   /// using the process stop ID to identify a time in the past.
554   ///
555   /// \param[in] stop_id
556   ///     Each time a process stops, the process stop ID integer gets
557   ///     incremented. These stop IDs are used to identify past times
558   ///     and can be used in history objects as a cheap way to store
559   ///     the time at which the sample was taken. Specifying
560   ///     UINT32_MAX will always resolve the address using the
561   ///     currently loaded sections.
562   ///
563   /// \param[in] vm_addr
564   ///     A virtual address from the current process state that is to
565   ///     be translated into a section offset address.
566   ///
567   /// \return
568   ///     An SBAddress which will be valid if \a vm_addr was
569   ///     successfully resolved into a section offset address, or an
570   ///     invalid SBAddress if \a vm_addr doesn't resolve to a section
571   ///     in a module.
572   lldb::SBAddress ResolvePastLoadAddress(uint32_t stop_id,
573                                          lldb::addr_t vm_addr);
574 
575   SBSymbolContext ResolveSymbolContextForAddress(const SBAddress &addr,
576                                                  uint32_t resolve_scope);
577 
578   /// Read target memory. If a target process is running then memory
579   /// is read from here. Otherwise the memory is read from the object
580   /// files. For a target whose bytes are sized as a multiple of host
581   /// bytes, the data read back will preserve the target's byte order.
582   ///
583   /// \param[in] addr
584   ///     A target address to read from.
585   ///
586   /// \param[out] buf
587   ///     The buffer to read memory into.
588   ///
589   /// \param[in] size
590   ///     The maximum number of host bytes to read in the buffer passed
591   ///     into this call
592   ///
593   /// \param[out] error
594   ///     Status information is written here if the memory read fails.
595   ///
596   /// \return
597   ///     The amount of data read in host bytes.
598   size_t ReadMemory(const SBAddress addr, void *buf, size_t size,
599                     lldb::SBError &error);
600 
601   lldb::SBBreakpoint BreakpointCreateByLocation(const char *file,
602                                                 uint32_t line);
603 
604   lldb::SBBreakpoint
605   BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line);
606 
607   lldb::SBBreakpoint
608   BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
609                              lldb::addr_t offset);
610 
611   lldb::SBBreakpoint
612   BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
613                              lldb::addr_t offset, SBFileSpecList &module_list);
614 
615   lldb::SBBreakpoint
616   BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
617                              uint32_t column, lldb::addr_t offset,
618                              SBFileSpecList &module_list);
619 
620   lldb::SBBreakpoint
621   BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
622                              uint32_t column, lldb::addr_t offset,
623                              SBFileSpecList &module_list,
624                              bool move_to_nearest_code);
625 
626   lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name,
627                                             const char *module_name = nullptr);
628 
629   // This version uses name_type_mask = eFunctionNameTypeAuto
630   lldb::SBBreakpoint
631   BreakpointCreateByName(const char *symbol_name,
632                          const SBFileSpecList &module_list,
633                          const SBFileSpecList &comp_unit_list);
634 
635   lldb::SBBreakpoint BreakpointCreateByName(
636       const char *symbol_name,
637       uint32_t
638           name_type_mask, // Logical OR one or more FunctionNameType enum bits
639       const SBFileSpecList &module_list,
640       const SBFileSpecList &comp_unit_list);
641 
642   lldb::SBBreakpoint BreakpointCreateByName(
643       const char *symbol_name,
644       uint32_t
645           name_type_mask, // Logical OR one or more FunctionNameType enum bits
646       lldb::LanguageType symbol_language,
647       const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
648 
649 #ifdef SWIG
650   lldb::SBBreakpoint BreakpointCreateByNames(
651       const char **symbol_name, uint32_t num_names,
652       uint32_t
653           name_type_mask, // Logical OR one or more FunctionNameType enum bits
654       const SBFileSpecList &module_list,
655       const SBFileSpecList &comp_unit_list);
656 
657   lldb::SBBreakpoint BreakpointCreateByNames(
658       const char **symbol_name, uint32_t num_names,
659       uint32_t
660           name_type_mask, // Logical OR one or more FunctionNameType enum bits
661       lldb::LanguageType symbol_language,
662       const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
663 
664   lldb::SBBreakpoint BreakpointCreateByNames(
665       const char **symbol_name, uint32_t num_names,
666       uint32_t
667           name_type_mask, // Logical OR one or more FunctionNameType enum bits
668       lldb::LanguageType symbol_language,
669       lldb::addr_t offset, const SBFileSpecList &module_list,
670       const SBFileSpecList &comp_unit_list);
671 #else
672   lldb::SBBreakpoint BreakpointCreateByNames(
673       const char *symbol_name[], uint32_t num_names,
674       uint32_t
675           name_type_mask, // Logical OR one or more FunctionNameType enum bits
676       const SBFileSpecList &module_list,
677       const SBFileSpecList &comp_unit_list);
678 
679   lldb::SBBreakpoint BreakpointCreateByNames(
680       const char *symbol_name[], uint32_t num_names,
681       uint32_t
682           name_type_mask, // Logical OR one or more FunctionNameType enum bits
683       lldb::LanguageType symbol_language,
684       const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
685 
686   lldb::SBBreakpoint BreakpointCreateByNames(
687       const char *symbol_name[], uint32_t num_names,
688       uint32_t
689           name_type_mask, // Logical OR one or more FunctionNameType enum bits
690       lldb::LanguageType symbol_language,
691       lldb::addr_t offset, const SBFileSpecList &module_list,
692       const SBFileSpecList &comp_unit_list);
693 #endif
694 
695   lldb::SBBreakpoint BreakpointCreateByRegex(const char *symbol_name_regex,
696                                              const char *module_name = nullptr);
697 
698   lldb::SBBreakpoint
699   BreakpointCreateByRegex(const char *symbol_name_regex,
700                           const SBFileSpecList &module_list,
701                           const SBFileSpecList &comp_unit_list);
702 
703   lldb::SBBreakpoint BreakpointCreateByRegex(
704       const char *symbol_name_regex, lldb::LanguageType symbol_language,
705       const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
706 
707   lldb::SBBreakpoint
708   BreakpointCreateBySourceRegex(const char *source_regex,
709                                 const SBFileSpec &source_file,
710                                 const char *module_name = nullptr);
711 
712   lldb::SBBreakpoint
713   BreakpointCreateBySourceRegex(const char *source_regex,
714                                 const SBFileSpecList &module_list,
715                                 const SBFileSpecList &source_file);
716 
717   lldb::SBBreakpoint BreakpointCreateBySourceRegex(
718       const char *source_regex, const SBFileSpecList &module_list,
719       const SBFileSpecList &source_file, const SBStringList &func_names);
720 
721   lldb::SBBreakpoint BreakpointCreateForException(lldb::LanguageType language,
722                                                   bool catch_bp, bool throw_bp);
723 
724   lldb::SBBreakpoint BreakpointCreateByAddress(addr_t address);
725 
726   lldb::SBBreakpoint BreakpointCreateBySBAddress(SBAddress &address);
727 
728   /// Create a breakpoint using a scripted resolver.
729   ///
730   /// \param[in] class_name
731   ///    This is the name of the class that implements a scripted resolver.
732   ///
733   /// \param[in] extra_args
734   ///    This is an SBStructuredData object that will get passed to the
735   ///    constructor of the class in class_name.  You can use this to
736   ///    reuse the same class, parametrizing with entries from this
737   ///    dictionary.
738   ///
739   /// \param module_list
740   ///    If this is non-empty, this will be used as the module filter in the
741   ///    SearchFilter created for this breakpoint.
742   ///
743   /// \param file_list
744   ///    If this is non-empty, this will be used as the comp unit filter in the
745   ///    SearchFilter created for this breakpoint.
746   ///
747   /// \return
748   ///     An SBBreakpoint that will set locations based on the logic in the
749   ///     resolver's search callback.
750   lldb::SBBreakpoint BreakpointCreateFromScript(
751       const char *class_name,
752       SBStructuredData &extra_args,
753       const SBFileSpecList &module_list,
754       const SBFileSpecList &file_list,
755       bool request_hardware = false);
756 
757   /// Read breakpoints from source_file and return the newly created
758   /// breakpoints in bkpt_list.
759   ///
760   /// \param[in] source_file
761   ///    The file from which to read the breakpoints.
762   ///
763   /// \param[out] new_bps
764   ///    A list of the newly created breakpoints.
765   ///
766   /// \return
767   ///     An SBError detailing any errors in reading in the breakpoints.
768   lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file,
769                                           SBBreakpointList &new_bps);
770 
771   /// Read breakpoints from source_file and return the newly created
772   /// breakpoints in bkpt_list.
773   ///
774   /// \param[in] source_file
775   ///    The file from which to read the breakpoints.
776   ///
777   /// \param[in] matching_names
778   ///    Only read in breakpoints whose names match one of the names in this
779   ///    list.
780   ///
781   /// \param[out] new_bps
782   ///    A list of the newly created breakpoints.
783   ///
784   /// \return
785   ///     An SBError detailing any errors in reading in the breakpoints.
786   lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file,
787                                           SBStringList &matching_names,
788                                           SBBreakpointList &new_bps);
789 
790   /// Write breakpoints to dest_file.
791   ///
792   /// \param[in] dest_file
793   ///    The file to which to write the breakpoints.
794   ///
795   /// \return
796   ///     An SBError detailing any errors in writing in the breakpoints.
797   lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file);
798 
799   /// Write breakpoints listed in bkpt_list to dest_file.
800   ///
801   /// \param[in] dest_file
802   ///    The file to which to write the breakpoints.
803   ///
804   /// \param[in] bkpt_list
805   ///    Only write breakpoints from this list.
806   ///
807   /// \param[in] append
808   ///    If \b true, append the breakpoints in bkpt_list to the others
809   ///    serialized in dest_file.  If dest_file doesn't exist, then a new
810   ///    file will be created and the breakpoints in bkpt_list written to it.
811   ///
812   /// \return
813   ///     An SBError detailing any errors in writing in the breakpoints.
814   lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file,
815                                        SBBreakpointList &bkpt_list,
816                                        bool append = false);
817 
818   uint32_t GetNumBreakpoints() const;
819 
820   lldb::SBBreakpoint GetBreakpointAtIndex(uint32_t idx) const;
821 
822   bool BreakpointDelete(break_id_t break_id);
823 
824   lldb::SBBreakpoint FindBreakpointByID(break_id_t break_id);
825 
826   // Finds all breakpoints by name, returning the list in bkpt_list.  Returns
827   // false if the name is not a valid breakpoint name, true otherwise.
828   bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list);
829 
830   void GetBreakpointNames(SBStringList &names);
831 
832   void DeleteBreakpointName(const char *name);
833 
834   bool EnableAllBreakpoints();
835 
836   bool DisableAllBreakpoints();
837 
838   bool DeleteAllBreakpoints();
839 
840   uint32_t GetNumWatchpoints() const;
841 
842   lldb::SBWatchpoint GetWatchpointAtIndex(uint32_t idx) const;
843 
844   bool DeleteWatchpoint(lldb::watch_id_t watch_id);
845 
846   lldb::SBWatchpoint FindWatchpointByID(lldb::watch_id_t watch_id);
847 
848   LLDB_DEPRECATED("WatchAddress deprecated, use WatchpointCreateByAddress")
849   lldb::SBWatchpoint WatchAddress(lldb::addr_t addr, size_t size, bool read,
850                                   bool modify, SBError &error);
851 
852   lldb::SBWatchpoint
853   WatchpointCreateByAddress(lldb::addr_t addr, size_t size,
854                             lldb::SBWatchpointOptions options, SBError &error);
855 
856   bool EnableAllWatchpoints();
857 
858   bool DisableAllWatchpoints();
859 
860   bool DeleteAllWatchpoints();
861 
862   lldb::SBBroadcaster GetBroadcaster() const;
863 
864   lldb::SBType FindFirstType(const char *type);
865 
866   lldb::SBTypeList FindTypes(const char *type);
867 
868   lldb::SBType GetBasicType(lldb::BasicType type);
869 
870   lldb::SBValue CreateValueFromAddress(const char *name, lldb::SBAddress addr,
871                                        lldb::SBType type);
872 
873   lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data,
874                                     lldb::SBType type);
875 
876   lldb::SBValue CreateValueFromExpression(const char *name, const char *expr);
877 
878   SBSourceManager GetSourceManager();
879 
880   lldb::SBInstructionList ReadInstructions(lldb::SBAddress base_addr,
881                                            uint32_t count);
882 
883   lldb::SBInstructionList ReadInstructions(lldb::SBAddress base_addr,
884                                            uint32_t count,
885                                            const char *flavor_string);
886 
887   lldb::SBInstructionList ReadInstructions(lldb::SBAddress start_addr,
888                                            lldb::SBAddress end_addr,
889                                            const char *flavor_string);
890 
891   lldb::SBInstructionList GetInstructions(lldb::SBAddress base_addr,
892                                           const void *buf, size_t size);
893 
894   // The "WithFlavor" is necessary to keep SWIG from getting confused about
895   // overloaded arguments when using the buf + size -> Python Object magic.
896 
897   lldb::SBInstructionList GetInstructionsWithFlavor(lldb::SBAddress base_addr,
898                                                     const char *flavor_string,
899                                                     const void *buf,
900                                                     size_t size);
901 
902 #ifndef SWIG
903   lldb::SBInstructionList GetInstructions(lldb::addr_t base_addr,
904                                           const void *buf, size_t size);
905   lldb::SBInstructionList GetInstructionsWithFlavor(lldb::addr_t base_addr,
906                                                     const char *flavor_string,
907                                                     const void *buf,
908                                                     size_t size);
909 #endif
910 
911   lldb::SBSymbolContextList FindSymbols(const char *name,
912                                         lldb::SymbolType type = eSymbolTypeAny);
913 
914   bool operator==(const lldb::SBTarget &rhs) const;
915 
916   bool operator!=(const lldb::SBTarget &rhs) const;
917 
918   bool GetDescription(lldb::SBStream &description,
919                       lldb::DescriptionLevel description_level);
920 
921   lldb::SBValue EvaluateExpression(const char *expr);
922 
923   lldb::SBValue EvaluateExpression(const char *expr,
924                                    const SBExpressionOptions &options);
925 
926   lldb::addr_t GetStackRedZoneSize();
927 
928   bool IsLoaded(const lldb::SBModule &module) const;
929 
930   lldb::SBLaunchInfo GetLaunchInfo() const;
931 
932   void SetLaunchInfo(const lldb::SBLaunchInfo &launch_info);
933 
934   /// Get a \a SBTrace object the can manage the processor trace information of
935   /// this target.
936   ///
937   /// \return
938   ///   The trace object. The returned SBTrace object might not be valid, so it
939   ///   should be checked with a call to "bool SBTrace::IsValid()".
940   lldb::SBTrace GetTrace();
941 
942   /// Create a \a Trace object for the current target using the using the
943   /// default supported tracing technology for this process.
944   ///
945   /// \param[out] error
946   ///     An error if a Trace already exists or the trace couldn't be created.
947   lldb::SBTrace CreateTrace(SBError &error);
948 
949 protected:
950   friend class SBAddress;
951   friend class SBAddressRange;
952   friend class SBBlock;
953   friend class SBBreakpoint;
954   friend class SBBreakpointList;
955   friend class SBBreakpointNameImpl;
956   friend class SBDebugger;
957   friend class SBExecutionContext;
958   friend class SBFrame;
959   friend class SBFunction;
960   friend class SBInstruction;
961   friend class SBModule;
962   friend class SBPlatform;
963   friend class SBProcess;
964   friend class SBSection;
965   friend class SBSourceManager;
966   friend class SBSymbol;
967   friend class SBTypeStaticField;
968   friend class SBValue;
969   friend class SBVariablesOptions;
970 
971   friend class lldb_private::python::SWIGBridge;
972 
973   // Constructors are private, use static Target::Create function to create an
974   // instance of this class.
975 
976   SBTarget(const lldb::TargetSP &target_sp);
977 
978   lldb::TargetSP GetSP() const;
979 
980   void SetSP(const lldb::TargetSP &target_sp);
981 
982 private:
983   lldb::TargetSP m_opaque_sp;
984 };
985 
986 } // namespace lldb
987 
988 #endif // LLDB_API_SBTARGET_H
989