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