Target.h revision c86582f4095d146c4177b0ed7f79c923269deca5
1//===-- Target.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 liblldb_Target_h_
11#define liblldb_Target_h_
12
13// C Includes
14// C++ Includes
15
16// Other libraries and framework includes
17// Project includes
18#include "lldb/lldb-public.h"
19#include "lldb/Breakpoint/BreakpointList.h"
20#include "lldb/Breakpoint/BreakpointLocationCollection.h"
21#include "lldb/Breakpoint/WatchpointLocationList.h"
22#include "lldb/Core/Broadcaster.h"
23#include "lldb/Core/Event.h"
24#include "lldb/Core/ModuleList.h"
25#include "lldb/Core/UserSettingsController.h"
26#include "lldb/Core/SourceManager.h"
27#include "lldb/Expression/ClangPersistentVariables.h"
28#include "lldb/Interpreter/NamedOptionValue.h"
29#include "lldb/Symbol/SymbolContext.h"
30#include "lldb/Target/ABI.h"
31#include "lldb/Target/ExecutionContextScope.h"
32#include "lldb/Target/PathMappingList.h"
33#include "lldb/Target/SectionLoadList.h"
34
35#include "lldb/API/SBTarget.h"
36
37namespace lldb_private {
38
39//----------------------------------------------------------------------
40// TargetInstanceSettings
41//----------------------------------------------------------------------
42class TargetInstanceSettings : public InstanceSettings
43{
44public:
45    static OptionEnumValueElement g_dynamic_value_types[];
46
47    TargetInstanceSettings (UserSettingsController &owner, bool live_instance = true, const char *name = NULL);
48
49    TargetInstanceSettings (const TargetInstanceSettings &rhs);
50
51    virtual
52    ~TargetInstanceSettings ();
53
54    TargetInstanceSettings&
55    operator= (const TargetInstanceSettings &rhs);
56
57    void
58    UpdateInstanceSettingsVariable (const ConstString &var_name,
59                                    const char *index_value,
60                                    const char *value,
61                                    const ConstString &instance_name,
62                                    const SettingEntry &entry,
63                                    VarSetOperationType op,
64                                    Error &err,
65                                    bool pending);
66
67    bool
68    GetInstanceSettingsValue (const SettingEntry &entry,
69                              const ConstString &var_name,
70                              StringList &value,
71                              Error *err);
72
73    lldb::DynamicValueType
74    GetPreferDynamicValue()
75    {
76        return (lldb::DynamicValueType) g_dynamic_value_types[m_prefer_dynamic_value].value;
77    }
78
79    bool
80    GetSkipPrologue()
81    {
82        return m_skip_prologue;
83    }
84
85    PathMappingList &
86    GetSourcePathMap ()
87    {
88        return m_source_map;
89    }
90
91    uint32_t
92    GetMaximumNumberOfChildrenToDisplay()
93    {
94        return m_max_children_display;
95    }
96    uint32_t
97    GetMaximumSizeOfStringSummary()
98    {
99        return m_max_strlen_length;
100    }
101
102protected:
103
104    void
105    CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings,
106                          bool pending);
107
108    const ConstString
109    CreateInstanceName ();
110
111    OptionValueFileSpec m_expr_prefix_file;
112    lldb::DataBufferSP m_expr_prefix_contents_sp;
113    int                m_prefer_dynamic_value;
114    OptionValueBoolean m_skip_prologue;
115    PathMappingList m_source_map;
116    uint32_t m_max_children_display;
117    uint32_t m_max_strlen_length;
118
119
120};
121
122//----------------------------------------------------------------------
123// Target
124//----------------------------------------------------------------------
125class Target :
126    public ReferenceCountedBaseVirtual<Target>,
127    public Broadcaster,
128    public ExecutionContextScope,
129    public TargetInstanceSettings
130{
131public:
132    friend class TargetList;
133
134    //------------------------------------------------------------------
135    /// Broadcaster event bits definitions.
136    //------------------------------------------------------------------
137    enum
138    {
139        eBroadcastBitBreakpointChanged  = (1 << 0),
140        eBroadcastBitModulesLoaded      = (1 << 1),
141        eBroadcastBitModulesUnloaded    = (1 << 2)
142    };
143
144    static void
145    SettingsInitialize ();
146
147    static void
148    SettingsTerminate ();
149
150    static lldb::UserSettingsControllerSP &
151    GetSettingsController ();
152
153    static ArchSpec
154    GetDefaultArchitecture ();
155
156    static void
157    SetDefaultArchitecture (const ArchSpec &arch);
158
159    void
160    UpdateInstanceName ();
161
162    lldb::ModuleSP
163    GetSharedModule (const FileSpec& file_spec,
164                     const ArchSpec& arch,
165                     const lldb_private::UUID *uuid = NULL,
166                     const ConstString *object_name = NULL,
167                     off_t object_offset = 0,
168                     Error *error_ptr = NULL);
169private:
170    //------------------------------------------------------------------
171    /// Construct with optional file and arch.
172    ///
173    /// This member is private. Clients must use
174    /// TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
175    /// so all targets can be tracked from the central target list.
176    ///
177    /// @see TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
178    //------------------------------------------------------------------
179    Target (Debugger &debugger,
180            const ArchSpec &target_arch,
181            const lldb::PlatformSP &platform_sp);
182
183    // Helper function.
184    bool
185    ProcessIsValid ();
186
187public:
188    ~Target();
189
190    Mutex &
191    GetAPIMutex ()
192    {
193        return m_mutex;
194    }
195
196    void
197    DeleteCurrentProcess ();
198
199    //------------------------------------------------------------------
200    /// Dump a description of this object to a Stream.
201    ///
202    /// Dump a description of the contents of this object to the
203    /// supplied stream \a s. The dumped content will be only what has
204    /// been loaded or parsed up to this point at which this function
205    /// is called, so this is a good way to see what has been parsed
206    /// in a target.
207    ///
208    /// @param[in] s
209    ///     The stream to which to dump the object descripton.
210    //------------------------------------------------------------------
211    void
212    Dump (Stream *s, lldb::DescriptionLevel description_level);
213
214    const lldb::ProcessSP &
215    CreateProcess (Listener &listener, const char *plugin_name = NULL);
216
217    const lldb::ProcessSP &
218    GetProcessSP () const;
219
220    lldb::TargetSP
221    GetSP();
222
223    void
224    Destroy();
225
226    //------------------------------------------------------------------
227    // This part handles the breakpoints.
228    //------------------------------------------------------------------
229
230    BreakpointList &
231    GetBreakpointList(bool internal = false);
232
233    const BreakpointList &
234    GetBreakpointList(bool internal = false) const;
235
236    lldb::BreakpointSP
237    GetLastCreatedBreakpoint ()
238    {
239        return m_last_created_breakpoint;
240    }
241
242    lldb::BreakpointSP
243    GetBreakpointByID (lldb::break_id_t break_id);
244
245    // Use this to create a file and line breakpoint to a given module or all module it is NULL
246    lldb::BreakpointSP
247    CreateBreakpoint (const FileSpecList *containingModules,
248                      const FileSpec &file,
249                      uint32_t line_no,
250                      bool check_inlines,
251                      bool internal = false);
252
253    // Use this to create breakpoint that matches regex against the source lines in files given in source_file_list:
254    lldb::BreakpointSP
255    CreateSourceRegexBreakpoint (const FileSpecList *containingModules,
256                      const FileSpecList *source_file_list,
257                      RegularExpression &source_regex,
258                      bool internal = false);
259
260    // Use this to create a breakpoint from a load address
261    lldb::BreakpointSP
262    CreateBreakpoint (lldb::addr_t load_addr,
263                      bool internal = false);
264
265    // Use this to create Address breakpoints:
266    lldb::BreakpointSP
267    CreateBreakpoint (Address &addr,
268                      bool internal = false);
269
270    // Use this to create a function breakpoint by regexp in containingModule/containingSourceFiles, or all modules if it is NULL
271    // When "skip_prologue is set to eLazyBoolCalculate, we use the current target
272    // setting, else we use the values passed in
273    lldb::BreakpointSP
274    CreateFuncRegexBreakpoint (const FileSpecList *containingModules,
275                      const FileSpecList *containingSourceFiles,
276                      RegularExpression &func_regexp,
277                      bool internal = false,
278                      LazyBool skip_prologue = eLazyBoolCalculate);
279
280    // Use this to create a function breakpoint by name in containingModule, or all modules if it is NULL
281    // When "skip_prologue is set to eLazyBoolCalculate, we use the current target
282    // setting, else we use the values passed in
283    lldb::BreakpointSP
284    CreateBreakpoint (const FileSpecList *containingModules,
285                      const FileSpecList *containingSourceFiles,
286                      const char *func_name,
287                      uint32_t func_name_type_mask,
288                      bool internal = false,
289                      LazyBool skip_prologue = eLazyBoolCalculate);
290
291    // Use this to create a general breakpoint:
292    lldb::BreakpointSP
293    CreateBreakpoint (lldb::SearchFilterSP &filter_sp,
294                      lldb::BreakpointResolverSP &resolver_sp,
295                      bool internal = false);
296
297    // Use this to create a watchpoint location:
298    lldb::WatchpointLocationSP
299    CreateWatchpointLocation (lldb::addr_t addr,
300                              size_t size,
301                              uint32_t type);
302
303    WatchpointLocationList &
304    GetWatchpointLocationList()
305    {
306        return m_watchpoint_location_list;
307    }
308
309    void
310    RemoveAllBreakpoints (bool internal_also = false);
311
312    void
313    DisableAllBreakpoints (bool internal_also = false);
314
315    void
316    EnableAllBreakpoints (bool internal_also = false);
317
318    bool
319    DisableBreakpointByID (lldb::break_id_t break_id);
320
321    bool
322    EnableBreakpointByID (lldb::break_id_t break_id);
323
324    bool
325    RemoveBreakpointByID (lldb::break_id_t break_id);
326
327    // The flag 'end_to_end', default to true, signifies that the operation is
328    // performed end to end, for both the debugger and the debuggee.
329
330    bool
331    RemoveAllWatchpointLocations (bool end_to_end = true);
332
333    bool
334    DisableAllWatchpointLocations (bool end_to_end = true);
335
336    bool
337    EnableAllWatchpointLocations (bool end_to_end = true);
338
339    bool
340    DisableWatchpointLocationByID (lldb::watch_id_t watch_id);
341
342    bool
343    EnableWatchpointLocationByID (lldb::watch_id_t watch_id);
344
345    bool
346    RemoveWatchpointLocationByID (lldb::watch_id_t watch_id);
347
348    void
349    ModulesDidLoad (ModuleList &module_list);
350
351    void
352    ModulesDidUnload (ModuleList &module_list);
353
354
355    //------------------------------------------------------------------
356    /// Get \a load_addr as a callable code load address for this target
357    ///
358    /// Take \a load_addr and potentially add any address bits that are
359    /// needed to make the address callable. For ARM this can set bit
360    /// zero (if it already isn't) if \a load_addr is a thumb function.
361    /// If \a addr_class is set to eAddressClassInvalid, then the address
362    /// adjustment will always happen. If it is set to an address class
363    /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
364    /// returned.
365    //------------------------------------------------------------------
366    lldb::addr_t
367    GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class = lldb_private::eAddressClassInvalid) const;
368
369    //------------------------------------------------------------------
370    /// Get \a load_addr as an opcode for this target.
371    ///
372    /// Take \a load_addr and potentially strip any address bits that are
373    /// needed to make the address point to an opcode. For ARM this can
374    /// clear bit zero (if it already isn't) if \a load_addr is a
375    /// thumb function and load_addr is in code.
376    /// If \a addr_class is set to eAddressClassInvalid, then the address
377    /// adjustment will always happen. If it is set to an address class
378    /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
379    /// returned.
380    //------------------------------------------------------------------
381    lldb::addr_t
382    GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class = lldb_private::eAddressClassInvalid) const;
383
384protected:
385    void
386    ModuleAdded (lldb::ModuleSP &module_sp);
387
388    void
389    ModuleUpdated (lldb::ModuleSP &old_module_sp, lldb::ModuleSP &new_module_sp);
390
391public:
392    //------------------------------------------------------------------
393    /// Gets the module for the main executable.
394    ///
395    /// Each process has a notion of a main executable that is the file
396    /// that will be executed or attached to. Executable files can have
397    /// dependent modules that are discovered from the object files, or
398    /// discovered at runtime as things are dynamically loaded.
399    ///
400    /// @return
401    ///     The shared pointer to the executable module which can
402    ///     contains a NULL Module object if no executable has been
403    ///     set.
404    ///
405    /// @see DynamicLoader
406    /// @see ObjectFile::GetDependentModules (FileSpecList&)
407    /// @see Process::SetExecutableModule(lldb::ModuleSP&)
408    //------------------------------------------------------------------
409    lldb::ModuleSP
410    GetExecutableModule ();
411
412    Module*
413    GetExecutableModulePointer ();
414
415    //------------------------------------------------------------------
416    /// Set the main executable module.
417    ///
418    /// Each process has a notion of a main executable that is the file
419    /// that will be executed or attached to. Executable files can have
420    /// dependent modules that are discovered from the object files, or
421    /// discovered at runtime as things are dynamically loaded.
422    ///
423    /// Setting the executable causes any of the current dependant
424    /// image information to be cleared and replaced with the static
425    /// dependent image information found by calling
426    /// ObjectFile::GetDependentModules (FileSpecList&) on the main
427    /// executable and any modules on which it depends. Calling
428    /// Process::GetImages() will return the newly found images that
429    /// were obtained from all of the object files.
430    ///
431    /// @param[in] module_sp
432    ///     A shared pointer reference to the module that will become
433    ///     the main executable for this process.
434    ///
435    /// @param[in] get_dependent_files
436    ///     If \b true then ask the object files to track down any
437    ///     known dependent files.
438    ///
439    /// @see ObjectFile::GetDependentModules (FileSpecList&)
440    /// @see Process::GetImages()
441    //------------------------------------------------------------------
442    void
443    SetExecutableModule (lldb::ModuleSP& module_sp, bool get_dependent_files);
444
445    //------------------------------------------------------------------
446    /// Get accessor for the images for this process.
447    ///
448    /// Each process has a notion of a main executable that is the file
449    /// that will be executed or attached to. Executable files can have
450    /// dependent modules that are discovered from the object files, or
451    /// discovered at runtime as things are dynamically loaded. After
452    /// a main executable has been set, the images will contain a list
453    /// of all the files that the executable depends upon as far as the
454    /// object files know. These images will usually contain valid file
455    /// virtual addresses only. When the process is launched or attached
456    /// to, the DynamicLoader plug-in will discover where these images
457    /// were loaded in memory and will resolve the load virtual
458    /// addresses is each image, and also in images that are loaded by
459    /// code.
460    ///
461    /// @return
462    ///     A list of Module objects in a module list.
463    //------------------------------------------------------------------
464    ModuleList&
465    GetImages ()
466    {
467        return m_images;
468    }
469
470    const ModuleList&
471    GetImages () const
472    {
473        return m_images;
474    }
475
476    ArchSpec &
477    GetArchitecture ()
478    {
479        return m_arch;
480    }
481
482    const ArchSpec &
483    GetArchitecture () const
484    {
485        return m_arch;
486    }
487
488    //------------------------------------------------------------------
489    /// Set the architecture for this target.
490    ///
491    /// If the current target has no Images read in, then this just sets the architecture, which will
492    /// be used to select the architecture of the ExecutableModule when that is set.
493    /// If the current target has an ExecutableModule, then calling SetArchitecture with a different
494    /// architecture from the currently selected one will reset the ExecutableModule to that slice
495    /// of the file backing the ExecutableModule.  If the file backing the ExecutableModule does not
496    /// contain a fork of this architecture, then this code will return false, and the architecture
497    /// won't be changed.
498    /// If the input arch_spec is the same as the already set architecture, this is a no-op.
499    ///
500    /// @param[in] arch_spec
501    ///     The new architecture.
502    ///
503    /// @return
504    ///     \b true if the architecture was successfully set, \bfalse otherwise.
505    //------------------------------------------------------------------
506    bool
507    SetArchitecture (const ArchSpec &arch_spec);
508
509    Debugger &
510    GetDebugger ()
511    {
512        return m_debugger;
513    }
514
515    size_t
516    ReadMemoryFromFileCache (const Address& addr,
517                             void *dst,
518                             size_t dst_len,
519                             Error &error);
520
521    // Reading memory through the target allows us to skip going to the process
522    // for reading memory if possible and it allows us to try and read from
523    // any constant sections in our object files on disk. If you always want
524    // live program memory, read straight from the process. If you possibly
525    // want to read from const sections in object files, read from the target.
526    // This version of ReadMemory will try and read memory from the process
527    // if the process is alive. The order is:
528    // 1 - if (prefer_file_cache == true) then read from object file cache
529    // 2 - if there is a valid process, try and read from its memory
530    // 3 - if (prefer_file_cache == false) then read from object file cache
531    size_t
532    ReadMemory (const Address& addr,
533                bool prefer_file_cache,
534                void *dst,
535                size_t dst_len,
536                Error &error,
537                lldb::addr_t *load_addr_ptr = NULL);
538
539    size_t
540    ReadScalarIntegerFromMemory (const Address& addr,
541                                 bool prefer_file_cache,
542                                 uint32_t byte_size,
543                                 bool is_signed,
544                                 Scalar &scalar,
545                                 Error &error);
546
547    uint64_t
548    ReadUnsignedIntegerFromMemory (const Address& addr,
549                                   bool prefer_file_cache,
550                                   size_t integer_byte_size,
551                                   uint64_t fail_value,
552                                   Error &error);
553
554    bool
555    ReadPointerFromMemory (const Address& addr,
556                           bool prefer_file_cache,
557                           Error &error,
558                           Address &pointer_addr);
559
560    SectionLoadList&
561    GetSectionLoadList()
562    {
563        return m_section_load_list;
564    }
565
566    const SectionLoadList&
567    GetSectionLoadList() const
568    {
569        return m_section_load_list;
570    }
571
572
573    //------------------------------------------------------------------
574    /// Load a module in this target by at the section file addresses
575    /// with an optional constant slide applied to each section.
576    ///
577    /// This function will load all top level sections at their file
578    /// addresses and apply an optional constant slide amount to each
579    /// section. This can be used to easily load a module at the same
580    /// addresses that are contained in the object file (trust that
581    /// the addresses in an object file are the correct load addresses).
582    ///
583    /// @param[in] module
584    ///     The module to load.
585    ///
586    /// @param[in] slide
587    ///     A constant slide to add to each file address as each section
588    ///     is being loaded.
589    ///
590    /// @return
591    ///     \b true if loading the module at the specified address
592    ///     causes a section to be loaded when it previously wasn't, or
593    ///     if a section changes load address. Returns \b false if
594    ///     the sections were all already loaded at these addresses.
595    //------------------------------------------------------------------
596    bool
597    LoadModuleWithSlide (Module *module, lldb::addr_t slide);
598
599    static Target *
600    GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr,
601                           const SymbolContext *sc_ptr);
602
603    //------------------------------------------------------------------
604    // lldb::ExecutionContextScope pure virtual functions
605    //------------------------------------------------------------------
606    virtual Target *
607    CalculateTarget ();
608
609    virtual Process *
610    CalculateProcess ();
611
612    virtual Thread *
613    CalculateThread ();
614
615    virtual StackFrame *
616    CalculateStackFrame ();
617
618    virtual void
619    CalculateExecutionContext (ExecutionContext &exe_ctx);
620
621    PathMappingList &
622    GetImageSearchPathList ();
623
624    ClangASTContext *
625    GetScratchClangASTContext();
626
627    const char *
628    GetExpressionPrefixContentsAsCString ();
629
630    // Since expressions results can persist beyond the lifetime of a process,
631    // and the const expression results are available after a process is gone,
632    // we provide a way for expressions to be evaluated from the Target itself.
633    // If an expression is going to be run, then it should have a frame filled
634    // in in th execution context.
635    ExecutionResults
636    EvaluateExpression (const char *expression,
637                        StackFrame *frame,
638                        lldb_private::ExecutionPolicy execution_policy,
639                        bool unwind_on_error,
640                        bool keep_in_memory,
641                        lldb::DynamicValueType use_dynamic,
642                        lldb::ValueObjectSP &result_valobj_sp);
643
644    ClangPersistentVariables &
645    GetPersistentVariables()
646    {
647        return m_persistent_variables;
648    }
649
650    //------------------------------------------------------------------
651    // Target Stop Hooks
652    //------------------------------------------------------------------
653    class StopHook : public UserID
654    {
655    public:
656        ~StopHook ();
657
658        StopHook (const StopHook &rhs);
659
660        StringList *
661        GetCommandPointer ()
662        {
663            return &m_commands;
664        }
665
666        const StringList &
667        GetCommands()
668        {
669            return m_commands;
670        }
671
672        lldb::TargetSP &
673        GetTarget()
674        {
675            return m_target_sp;
676        }
677
678        void
679        SetCommands (StringList &in_commands)
680        {
681            m_commands = in_commands;
682        }
683
684        // Set the specifier.  The stop hook will own the specifier, and is responsible for deleting it when we're done.
685        void
686        SetSpecifier (SymbolContextSpecifier *specifier)
687        {
688            m_specifier_sp.reset (specifier);
689        }
690
691        SymbolContextSpecifier *
692        GetSpecifier ()
693        {
694            return m_specifier_sp.get();
695        }
696
697        // Set the Thread Specifier.  The stop hook will own the thread specifier, and is responsible for deleting it when we're done.
698        void
699        SetThreadSpecifier (ThreadSpec *specifier);
700
701        ThreadSpec *
702        GetThreadSpecifier()
703        {
704            return m_thread_spec_ap.get();
705        }
706
707        bool
708        IsActive()
709        {
710            return m_active;
711        }
712
713        void
714        SetIsActive (bool is_active)
715        {
716            m_active = is_active;
717        }
718
719        void
720        GetDescription (Stream *s, lldb::DescriptionLevel level) const;
721
722    private:
723        lldb::TargetSP m_target_sp;
724        StringList   m_commands;
725        lldb::SymbolContextSpecifierSP m_specifier_sp;
726        std::auto_ptr<ThreadSpec> m_thread_spec_ap;
727        bool m_active;
728
729        // Use AddStopHook to make a new empty stop hook.  The GetCommandPointer and fill it with commands,
730        // and SetSpecifier to set the specifier shared pointer (can be null, that will match anything.)
731        StopHook (lldb::TargetSP target_sp, lldb::user_id_t uid);
732        friend class Target;
733    };
734    typedef lldb::SharedPtr<StopHook>::Type StopHookSP;
735
736    // Add an empty stop hook to the Target's stop hook list, and returns a shared pointer to it in new_hook.
737    // Returns the id of the new hook.
738    lldb::user_id_t
739    AddStopHook (StopHookSP &new_hook);
740
741    void
742    RunStopHooks ();
743
744    size_t
745    GetStopHookSize();
746
747    bool
748    SetSuppresStopHooks (bool suppress)
749    {
750        bool old_value = m_suppress_stop_hooks;
751        m_suppress_stop_hooks = suppress;
752        return old_value;
753    }
754
755    bool
756    GetSuppressStopHooks ()
757    {
758        return m_suppress_stop_hooks;
759    }
760
761//    StopHookSP &
762//    GetStopHookByIndex (size_t index);
763//
764    bool
765    RemoveStopHookByID (lldb::user_id_t uid);
766
767    void
768    RemoveAllStopHooks ();
769
770    StopHookSP
771    GetStopHookByID (lldb::user_id_t uid);
772
773    bool
774    SetStopHookActiveStateByID (lldb::user_id_t uid, bool active_state);
775
776    void
777    SetAllStopHooksActiveState (bool active_state);
778
779    size_t GetNumStopHooks () const
780    {
781        return m_stop_hooks.size();
782    }
783
784    StopHookSP
785    GetStopHookAtIndex (size_t index)
786    {
787        if (index >= GetNumStopHooks())
788            return StopHookSP();
789        StopHookCollection::iterator pos = m_stop_hooks.begin();
790
791        while (index > 0)
792        {
793            pos++;
794            index--;
795        }
796        return (*pos).second;
797    }
798
799    lldb::PlatformSP
800    GetPlatform ()
801    {
802        return m_platform_sp;
803    }
804
805    SourceManager &
806    GetSourceManager ()
807    {
808        return m_source_manager;
809    }
810
811    //------------------------------------------------------------------
812    // Target::SettingsController
813    //------------------------------------------------------------------
814    class SettingsController : public UserSettingsController
815    {
816    public:
817        SettingsController ();
818
819        virtual
820        ~SettingsController ();
821
822        bool
823        SetGlobalVariable (const ConstString &var_name,
824                           const char *index_value,
825                           const char *value,
826                           const SettingEntry &entry,
827                           const VarSetOperationType op,
828                           Error&err);
829
830        bool
831        GetGlobalVariable (const ConstString &var_name,
832                           StringList &value,
833                           Error &err);
834
835        static SettingEntry global_settings_table[];
836        static SettingEntry instance_settings_table[];
837
838        ArchSpec &
839        GetArchitecture ()
840        {
841            return m_default_architecture;
842        }
843    protected:
844
845        lldb::InstanceSettingsSP
846        CreateInstanceSettings (const char *instance_name);
847
848    private:
849
850        // Class-wide settings.
851        ArchSpec m_default_architecture;
852
853        DISALLOW_COPY_AND_ASSIGN (SettingsController);
854    };
855
856
857protected:
858    friend class lldb::SBTarget;
859
860    //------------------------------------------------------------------
861    // Member variables.
862    //------------------------------------------------------------------
863    Debugger &      m_debugger;
864    lldb::PlatformSP m_platform_sp;     ///< The platform for this target.
865    Mutex           m_mutex;            ///< An API mutex that is used by the lldb::SB* classes make the SB interface thread safe
866    ArchSpec        m_arch;
867    ModuleList      m_images;           ///< The list of images for this process (shared libraries and anything dynamically loaded).
868    SectionLoadList m_section_load_list;
869    BreakpointList  m_breakpoint_list;
870    BreakpointList  m_internal_breakpoint_list;
871    lldb::BreakpointSP m_last_created_breakpoint;
872    WatchpointLocationList  m_watchpoint_location_list;
873    // We want to tightly control the process destruction process so
874    // we can correctly tear down everything that we need to, so the only
875    // class that knows about the process lifespan is this target class.
876    lldb::ProcessSP m_process_sp;
877    lldb::SearchFilterSP  m_search_filter_sp;
878    PathMappingList m_image_search_paths;
879    std::auto_ptr<ClangASTContext> m_scratch_ast_context_ap;
880    ClangPersistentVariables m_persistent_variables;      ///< These are the persistent variables associated with this process for the expression parser.
881
882    SourceManager m_source_manager;
883
884    typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection;
885    StopHookCollection      m_stop_hooks;
886    lldb::user_id_t         m_stop_hook_next_id;
887    bool                    m_suppress_stop_hooks;
888
889    //------------------------------------------------------------------
890    // Methods.
891    //------------------------------------------------------------------
892    lldb::SearchFilterSP
893    GetSearchFilterForModule (const FileSpec *containingModule);
894
895    lldb::SearchFilterSP
896    GetSearchFilterForModuleList (const FileSpecList *containingModuleList);
897
898    lldb::SearchFilterSP
899    GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles);
900
901
902    static void
903    ImageSearchPathsChanged (const PathMappingList &path_list,
904                             void *baton);
905
906private:
907    DISALLOW_COPY_AND_ASSIGN (Target);
908};
909
910} // namespace lldb_private
911
912#endif  // liblldb_Target_h_
913