Target.h revision 5eb54bb63835eb01b200223503b5fd89a7557dd5
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    lldb::WatchpointLocationSP
302    GetLastCreatedWatchpointLocation ()
303    {
304        return m_last_created_watchpoint_location;
305    }
306
307    WatchpointLocationList &
308    GetWatchpointLocationList()
309    {
310        return m_watchpoint_location_list;
311    }
312
313    void
314    RemoveAllBreakpoints (bool internal_also = false);
315
316    void
317    DisableAllBreakpoints (bool internal_also = false);
318
319    void
320    EnableAllBreakpoints (bool internal_also = false);
321
322    bool
323    DisableBreakpointByID (lldb::break_id_t break_id);
324
325    bool
326    EnableBreakpointByID (lldb::break_id_t break_id);
327
328    bool
329    RemoveBreakpointByID (lldb::break_id_t break_id);
330
331    // The flag 'end_to_end', default to true, signifies that the operation is
332    // performed end to end, for both the debugger and the debuggee.
333
334    bool
335    RemoveAllWatchpointLocations (bool end_to_end = true);
336
337    bool
338    DisableAllWatchpointLocations (bool end_to_end = true);
339
340    bool
341    EnableAllWatchpointLocations (bool end_to_end = true);
342
343    bool
344    DisableWatchpointLocationByID (lldb::watch_id_t watch_id);
345
346    bool
347    EnableWatchpointLocationByID (lldb::watch_id_t watch_id);
348
349    bool
350    RemoveWatchpointLocationByID (lldb::watch_id_t watch_id);
351
352    void
353    ModulesDidLoad (ModuleList &module_list);
354
355    void
356    ModulesDidUnload (ModuleList &module_list);
357
358
359    //------------------------------------------------------------------
360    /// Get \a load_addr as a callable code load address for this target
361    ///
362    /// Take \a load_addr and potentially add any address bits that are
363    /// needed to make the address callable. For ARM this can set bit
364    /// zero (if it already isn't) if \a load_addr is a thumb function.
365    /// If \a addr_class is set to eAddressClassInvalid, then the address
366    /// adjustment will always happen. If it is set to an address class
367    /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
368    /// returned.
369    //------------------------------------------------------------------
370    lldb::addr_t
371    GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class = lldb_private::eAddressClassInvalid) const;
372
373    //------------------------------------------------------------------
374    /// Get \a load_addr as an opcode for this target.
375    ///
376    /// Take \a load_addr and potentially strip any address bits that are
377    /// needed to make the address point to an opcode. For ARM this can
378    /// clear bit zero (if it already isn't) if \a load_addr is a
379    /// thumb function and load_addr is in code.
380    /// If \a addr_class is set to eAddressClassInvalid, then the address
381    /// adjustment will always happen. If it is set to an address class
382    /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
383    /// returned.
384    //------------------------------------------------------------------
385    lldb::addr_t
386    GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class = lldb_private::eAddressClassInvalid) const;
387
388protected:
389    void
390    ModuleAdded (lldb::ModuleSP &module_sp);
391
392    void
393    ModuleUpdated (lldb::ModuleSP &old_module_sp, lldb::ModuleSP &new_module_sp);
394
395public:
396    //------------------------------------------------------------------
397    /// Gets the module for the main executable.
398    ///
399    /// Each process has a notion of a main executable that is the file
400    /// that will be executed or attached to. Executable files can have
401    /// dependent modules that are discovered from the object files, or
402    /// discovered at runtime as things are dynamically loaded.
403    ///
404    /// @return
405    ///     The shared pointer to the executable module which can
406    ///     contains a NULL Module object if no executable has been
407    ///     set.
408    ///
409    /// @see DynamicLoader
410    /// @see ObjectFile::GetDependentModules (FileSpecList&)
411    /// @see Process::SetExecutableModule(lldb::ModuleSP&)
412    //------------------------------------------------------------------
413    lldb::ModuleSP
414    GetExecutableModule ();
415
416    Module*
417    GetExecutableModulePointer ();
418
419    //------------------------------------------------------------------
420    /// Set the main executable module.
421    ///
422    /// Each process has a notion of a main executable that is the file
423    /// that will be executed or attached to. Executable files can have
424    /// dependent modules that are discovered from the object files, or
425    /// discovered at runtime as things are dynamically loaded.
426    ///
427    /// Setting the executable causes any of the current dependant
428    /// image information to be cleared and replaced with the static
429    /// dependent image information found by calling
430    /// ObjectFile::GetDependentModules (FileSpecList&) on the main
431    /// executable and any modules on which it depends. Calling
432    /// Process::GetImages() will return the newly found images that
433    /// were obtained from all of the object files.
434    ///
435    /// @param[in] module_sp
436    ///     A shared pointer reference to the module that will become
437    ///     the main executable for this process.
438    ///
439    /// @param[in] get_dependent_files
440    ///     If \b true then ask the object files to track down any
441    ///     known dependent files.
442    ///
443    /// @see ObjectFile::GetDependentModules (FileSpecList&)
444    /// @see Process::GetImages()
445    //------------------------------------------------------------------
446    void
447    SetExecutableModule (lldb::ModuleSP& module_sp, bool get_dependent_files);
448
449    //------------------------------------------------------------------
450    /// Get accessor for the images for this process.
451    ///
452    /// Each process has a notion of a main executable that is the file
453    /// that will be executed or attached to. Executable files can have
454    /// dependent modules that are discovered from the object files, or
455    /// discovered at runtime as things are dynamically loaded. After
456    /// a main executable has been set, the images will contain a list
457    /// of all the files that the executable depends upon as far as the
458    /// object files know. These images will usually contain valid file
459    /// virtual addresses only. When the process is launched or attached
460    /// to, the DynamicLoader plug-in will discover where these images
461    /// were loaded in memory and will resolve the load virtual
462    /// addresses is each image, and also in images that are loaded by
463    /// code.
464    ///
465    /// @return
466    ///     A list of Module objects in a module list.
467    //------------------------------------------------------------------
468    ModuleList&
469    GetImages ()
470    {
471        return m_images;
472    }
473
474    const ModuleList&
475    GetImages () const
476    {
477        return m_images;
478    }
479
480    ArchSpec &
481    GetArchitecture ()
482    {
483        return m_arch;
484    }
485
486    const ArchSpec &
487    GetArchitecture () const
488    {
489        return m_arch;
490    }
491
492    //------------------------------------------------------------------
493    /// Set the architecture for this target.
494    ///
495    /// If the current target has no Images read in, then this just sets the architecture, which will
496    /// be used to select the architecture of the ExecutableModule when that is set.
497    /// If the current target has an ExecutableModule, then calling SetArchitecture with a different
498    /// architecture from the currently selected one will reset the ExecutableModule to that slice
499    /// of the file backing the ExecutableModule.  If the file backing the ExecutableModule does not
500    /// contain a fork of this architecture, then this code will return false, and the architecture
501    /// won't be changed.
502    /// If the input arch_spec is the same as the already set architecture, this is a no-op.
503    ///
504    /// @param[in] arch_spec
505    ///     The new architecture.
506    ///
507    /// @return
508    ///     \b true if the architecture was successfully set, \bfalse otherwise.
509    //------------------------------------------------------------------
510    bool
511    SetArchitecture (const ArchSpec &arch_spec);
512
513    Debugger &
514    GetDebugger ()
515    {
516        return m_debugger;
517    }
518
519    size_t
520    ReadMemoryFromFileCache (const Address& addr,
521                             void *dst,
522                             size_t dst_len,
523                             Error &error);
524
525    // Reading memory through the target allows us to skip going to the process
526    // for reading memory if possible and it allows us to try and read from
527    // any constant sections in our object files on disk. If you always want
528    // live program memory, read straight from the process. If you possibly
529    // want to read from const sections in object files, read from the target.
530    // This version of ReadMemory will try and read memory from the process
531    // if the process is alive. The order is:
532    // 1 - if (prefer_file_cache == true) then read from object file cache
533    // 2 - if there is a valid process, try and read from its memory
534    // 3 - if (prefer_file_cache == false) then read from object file cache
535    size_t
536    ReadMemory (const Address& addr,
537                bool prefer_file_cache,
538                void *dst,
539                size_t dst_len,
540                Error &error,
541                lldb::addr_t *load_addr_ptr = NULL);
542
543    size_t
544    ReadScalarIntegerFromMemory (const Address& addr,
545                                 bool prefer_file_cache,
546                                 uint32_t byte_size,
547                                 bool is_signed,
548                                 Scalar &scalar,
549                                 Error &error);
550
551    uint64_t
552    ReadUnsignedIntegerFromMemory (const Address& addr,
553                                   bool prefer_file_cache,
554                                   size_t integer_byte_size,
555                                   uint64_t fail_value,
556                                   Error &error);
557
558    bool
559    ReadPointerFromMemory (const Address& addr,
560                           bool prefer_file_cache,
561                           Error &error,
562                           Address &pointer_addr);
563
564    SectionLoadList&
565    GetSectionLoadList()
566    {
567        return m_section_load_list;
568    }
569
570    const SectionLoadList&
571    GetSectionLoadList() const
572    {
573        return m_section_load_list;
574    }
575
576
577    //------------------------------------------------------------------
578    /// Load a module in this target by at the section file addresses
579    /// with an optional constant slide applied to each section.
580    ///
581    /// This function will load all top level sections at their file
582    /// addresses and apply an optional constant slide amount to each
583    /// section. This can be used to easily load a module at the same
584    /// addresses that are contained in the object file (trust that
585    /// the addresses in an object file are the correct load addresses).
586    ///
587    /// @param[in] module
588    ///     The module to load.
589    ///
590    /// @param[in] slide
591    ///     A constant slide to add to each file address as each section
592    ///     is being loaded.
593    ///
594    /// @return
595    ///     \b true if loading the module at the specified address
596    ///     causes a section to be loaded when it previously wasn't, or
597    ///     if a section changes load address. Returns \b false if
598    ///     the sections were all already loaded at these addresses.
599    //------------------------------------------------------------------
600    bool
601    LoadModuleWithSlide (Module *module, lldb::addr_t slide);
602
603    static Target *
604    GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr,
605                           const SymbolContext *sc_ptr);
606
607    //------------------------------------------------------------------
608    // lldb::ExecutionContextScope pure virtual functions
609    //------------------------------------------------------------------
610    virtual Target *
611    CalculateTarget ();
612
613    virtual Process *
614    CalculateProcess ();
615
616    virtual Thread *
617    CalculateThread ();
618
619    virtual StackFrame *
620    CalculateStackFrame ();
621
622    virtual void
623    CalculateExecutionContext (ExecutionContext &exe_ctx);
624
625    PathMappingList &
626    GetImageSearchPathList ();
627
628    ClangASTContext *
629    GetScratchClangASTContext();
630
631    const char *
632    GetExpressionPrefixContentsAsCString ();
633
634    // Since expressions results can persist beyond the lifetime of a process,
635    // and the const expression results are available after a process is gone,
636    // we provide a way for expressions to be evaluated from the Target itself.
637    // If an expression is going to be run, then it should have a frame filled
638    // in in th execution context.
639    ExecutionResults
640    EvaluateExpression (const char *expression,
641                        StackFrame *frame,
642                        lldb_private::ExecutionPolicy execution_policy,
643                        bool unwind_on_error,
644                        bool keep_in_memory,
645                        lldb::DynamicValueType use_dynamic,
646                        lldb::ValueObjectSP &result_valobj_sp);
647
648    ClangPersistentVariables &
649    GetPersistentVariables()
650    {
651        return m_persistent_variables;
652    }
653
654    //------------------------------------------------------------------
655    // Target Stop Hooks
656    //------------------------------------------------------------------
657    class StopHook : public UserID
658    {
659    public:
660        ~StopHook ();
661
662        StopHook (const StopHook &rhs);
663
664        StringList *
665        GetCommandPointer ()
666        {
667            return &m_commands;
668        }
669
670        const StringList &
671        GetCommands()
672        {
673            return m_commands;
674        }
675
676        lldb::TargetSP &
677        GetTarget()
678        {
679            return m_target_sp;
680        }
681
682        void
683        SetCommands (StringList &in_commands)
684        {
685            m_commands = in_commands;
686        }
687
688        // Set the specifier.  The stop hook will own the specifier, and is responsible for deleting it when we're done.
689        void
690        SetSpecifier (SymbolContextSpecifier *specifier)
691        {
692            m_specifier_sp.reset (specifier);
693        }
694
695        SymbolContextSpecifier *
696        GetSpecifier ()
697        {
698            return m_specifier_sp.get();
699        }
700
701        // Set the Thread Specifier.  The stop hook will own the thread specifier, and is responsible for deleting it when we're done.
702        void
703        SetThreadSpecifier (ThreadSpec *specifier);
704
705        ThreadSpec *
706        GetThreadSpecifier()
707        {
708            return m_thread_spec_ap.get();
709        }
710
711        bool
712        IsActive()
713        {
714            return m_active;
715        }
716
717        void
718        SetIsActive (bool is_active)
719        {
720            m_active = is_active;
721        }
722
723        void
724        GetDescription (Stream *s, lldb::DescriptionLevel level) const;
725
726    private:
727        lldb::TargetSP m_target_sp;
728        StringList   m_commands;
729        lldb::SymbolContextSpecifierSP m_specifier_sp;
730        std::auto_ptr<ThreadSpec> m_thread_spec_ap;
731        bool m_active;
732
733        // Use AddStopHook to make a new empty stop hook.  The GetCommandPointer and fill it with commands,
734        // and SetSpecifier to set the specifier shared pointer (can be null, that will match anything.)
735        StopHook (lldb::TargetSP target_sp, lldb::user_id_t uid);
736        friend class Target;
737    };
738    typedef lldb::SharedPtr<StopHook>::Type StopHookSP;
739
740    // Add an empty stop hook to the Target's stop hook list, and returns a shared pointer to it in new_hook.
741    // Returns the id of the new hook.
742    lldb::user_id_t
743    AddStopHook (StopHookSP &new_hook);
744
745    void
746    RunStopHooks ();
747
748    size_t
749    GetStopHookSize();
750
751    bool
752    SetSuppresStopHooks (bool suppress)
753    {
754        bool old_value = m_suppress_stop_hooks;
755        m_suppress_stop_hooks = suppress;
756        return old_value;
757    }
758
759    bool
760    GetSuppressStopHooks ()
761    {
762        return m_suppress_stop_hooks;
763    }
764
765//    StopHookSP &
766//    GetStopHookByIndex (size_t index);
767//
768    bool
769    RemoveStopHookByID (lldb::user_id_t uid);
770
771    void
772    RemoveAllStopHooks ();
773
774    StopHookSP
775    GetStopHookByID (lldb::user_id_t uid);
776
777    bool
778    SetStopHookActiveStateByID (lldb::user_id_t uid, bool active_state);
779
780    void
781    SetAllStopHooksActiveState (bool active_state);
782
783    size_t GetNumStopHooks () const
784    {
785        return m_stop_hooks.size();
786    }
787
788    StopHookSP
789    GetStopHookAtIndex (size_t index)
790    {
791        if (index >= GetNumStopHooks())
792            return StopHookSP();
793        StopHookCollection::iterator pos = m_stop_hooks.begin();
794
795        while (index > 0)
796        {
797            pos++;
798            index--;
799        }
800        return (*pos).second;
801    }
802
803    lldb::PlatformSP
804    GetPlatform ()
805    {
806        return m_platform_sp;
807    }
808
809    SourceManager &
810    GetSourceManager ()
811    {
812        return m_source_manager;
813    }
814
815    //------------------------------------------------------------------
816    // Target::SettingsController
817    //------------------------------------------------------------------
818    class SettingsController : public UserSettingsController
819    {
820    public:
821        SettingsController ();
822
823        virtual
824        ~SettingsController ();
825
826        bool
827        SetGlobalVariable (const ConstString &var_name,
828                           const char *index_value,
829                           const char *value,
830                           const SettingEntry &entry,
831                           const VarSetOperationType op,
832                           Error&err);
833
834        bool
835        GetGlobalVariable (const ConstString &var_name,
836                           StringList &value,
837                           Error &err);
838
839        static SettingEntry global_settings_table[];
840        static SettingEntry instance_settings_table[];
841
842        ArchSpec &
843        GetArchitecture ()
844        {
845            return m_default_architecture;
846        }
847    protected:
848
849        lldb::InstanceSettingsSP
850        CreateInstanceSettings (const char *instance_name);
851
852    private:
853
854        // Class-wide settings.
855        ArchSpec m_default_architecture;
856
857        DISALLOW_COPY_AND_ASSIGN (SettingsController);
858    };
859
860
861protected:
862    //------------------------------------------------------------------
863    // Member variables.
864    //------------------------------------------------------------------
865    Debugger &      m_debugger;
866    lldb::PlatformSP m_platform_sp;     ///< The platform for this target.
867    Mutex           m_mutex;            ///< An API mutex that is used by the lldb::SB* classes make the SB interface thread safe
868    ArchSpec        m_arch;
869    ModuleList      m_images;           ///< The list of images for this process (shared libraries and anything dynamically loaded).
870    SectionLoadList m_section_load_list;
871    BreakpointList  m_breakpoint_list;
872    BreakpointList  m_internal_breakpoint_list;
873    lldb::BreakpointSP m_last_created_breakpoint;
874    WatchpointLocationList  m_watchpoint_location_list;
875    lldb::WatchpointLocationSP m_last_created_watchpoint_location;
876    // We want to tightly control the process destruction process so
877    // we can correctly tear down everything that we need to, so the only
878    // class that knows about the process lifespan is this target class.
879    lldb::ProcessSP m_process_sp;
880    lldb::SearchFilterSP  m_search_filter_sp;
881    PathMappingList m_image_search_paths;
882    std::auto_ptr<ClangASTContext> m_scratch_ast_context_ap;
883    ClangPersistentVariables m_persistent_variables;      ///< These are the persistent variables associated with this process for the expression parser.
884
885    SourceManager m_source_manager;
886
887    typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection;
888    StopHookCollection      m_stop_hooks;
889    lldb::user_id_t         m_stop_hook_next_id;
890    bool                    m_suppress_stop_hooks;
891
892    //------------------------------------------------------------------
893    // Methods.
894    //------------------------------------------------------------------
895    lldb::SearchFilterSP
896    GetSearchFilterForModule (const FileSpec *containingModule);
897
898    lldb::SearchFilterSP
899    GetSearchFilterForModuleList (const FileSpecList *containingModuleList);
900
901    lldb::SearchFilterSP
902    GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles);
903
904
905    static void
906    ImageSearchPathsChanged (const PathMappingList &path_list,
907                             void *baton);
908
909private:
910    DISALLOW_COPY_AND_ASSIGN (Target);
911};
912
913} // namespace lldb_private
914
915#endif  // liblldb_Target_h_
916