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