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