178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch//===-- Target.h ------------------------------------------------*- C++ -*-===//
278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch//
378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch//                     The LLVM Compiler Infrastructure
478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch//
578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch// This file is distributed under the University of Illinois Open Source
678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch// License. See LICENSE.TXT for details.
778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch//
878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch//===----------------------------------------------------------------------===//
978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
1078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#ifndef liblldb_Target_h_
1178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#define liblldb_Target_h_
1278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
1378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch// C Includes
1478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch// C++ Includes
1578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include <list>
1678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
1778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch// Other libraries and framework includes
1878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch// Project includes
1978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/lldb-public.h"
2078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Breakpoint/BreakpointList.h"
2178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Breakpoint/BreakpointLocationCollection.h"
2278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Breakpoint/WatchpointList.h"
2378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Core/ArchSpec.h"
2478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Core/Broadcaster.h"
2578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Core/Disassembler.h"
2678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Core/Event.h"
2778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Core/ModuleList.h"
2878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Core/UserSettingsController.h"
2978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Expression/ClangPersistentVariables.h"
3078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Interpreter/Args.h"
3178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Interpreter/OptionValueBoolean.h"
3278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Interpreter/OptionValueEnumeration.h"
3378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Interpreter/OptionValueFileSpec.h"
3478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Symbol/SymbolContext.h"
3578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Target/ABI.h"
3678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Target/ExecutionContextScope.h"
3778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Target/PathMappingList.h"
3878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch#include "lldb/Target/SectionLoadList.h"
3978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
4078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdochnamespace lldb_private {
4178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
4278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdochextern OptionEnumValueElement g_dynamic_value_types[];
4378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
4478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdochtypedef enum InlineStrategy
4578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch{
4678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    eInlineBreakpointsNever = 0,
4778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    eInlineBreakpointsHeaders,
4878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    eInlineBreakpointsAlways
4978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch} InlineStrategy;
5078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
5178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdochtypedef enum LoadScriptFromSymFile
5278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch{
5378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    eLoadScriptFromSymFileTrue,
5478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    eLoadScriptFromSymFileFalse,
5578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    eLoadScriptFromSymFileWarn
5678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch} LoadScriptFromSymFile;
5778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
5878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch//----------------------------------------------------------------------
5978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch// TargetProperties
6078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch//----------------------------------------------------------------------
6178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdochclass TargetProperties : public Properties
6278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch{
6378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdochpublic:
6478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    TargetProperties(Target *target);
6578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
6678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    virtual
6778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    ~TargetProperties();
6878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
6978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    ArchSpec
7078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetDefaultArchitecture () const;
7178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
7278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    void
7378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SetDefaultArchitecture (const ArchSpec& arch);
7478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
7578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    lldb::DynamicValueType
7678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetPreferDynamicValue() const;
7778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
7878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool
7978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetDisableASLR () const;
8078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
8178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    void
8278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SetDisableASLR (bool b);
8378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
8478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool
8578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetDisableSTDIO () const;
8678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
8778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    void
8878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SetDisableSTDIO (bool b);
8978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
9078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    const char *
9178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetDisassemblyFlavor() const;
9278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
9378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch//    void
9478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch//    SetDisassemblyFlavor(const char *flavor);
9578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
9678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    InlineStrategy
9778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetInlineStrategy () const;
9878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
9978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    const char *
10078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetArg0 () const;
10178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
10278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    void
10378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SetArg0 (const char *arg);
10478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
10578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool
10678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetRunArguments (Args &args) const;
10778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
10878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    void
10978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SetRunArguments (const Args &args);
11078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
11178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    size_t
11278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetEnvironmentAsArgs (Args &env) const;
11378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
11478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool
11578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetSkipPrologue() const;
11678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
11778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    PathMappingList &
11878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetSourcePathMap () const;
11978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
12078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    FileSpecList &
12178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetExecutableSearchPaths ();
12278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
12378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    FileSpecList &
12478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetDebugFileSearchPaths ();
12578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
12678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool
12778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetEnableSyntheticValue () const;
12878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
12978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    uint32_t
13078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetMaximumNumberOfChildrenToDisplay() const;
13178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
13278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    uint32_t
13378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetMaximumSizeOfStringSummary() const;
13478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
13578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    uint32_t
13678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetMaximumMemReadSize () const;
13778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
13878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    FileSpec
13978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetStandardInputPath () const;
14078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
14178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    void
14278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SetStandardInputPath (const char *path);
14378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
14478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    FileSpec
14578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetStandardOutputPath () const;
14678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
14778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    void
14878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SetStandardOutputPath (const char *path);
14978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
15078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    FileSpec
15178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetStandardErrorPath () const;
15278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
15378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    void
15478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SetStandardErrorPath (const char *path);
15578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
15678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool
15778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetBreakpointsConsultPlatformAvoidList ();
15878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
15978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    const char *
16078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetExpressionPrefixContentsAsCString ();
16178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
16278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool
16378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetUseHexImmediates() const;
16478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
16578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool
16678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetUseFastStepping() const;
16778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
16878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    LoadScriptFromSymFile
16978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetLoadScriptFromSymbolFile() const;
17078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
17178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    Disassembler::HexImmediateStyle
17278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetHexImmediateStyle() const;
17378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
17478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch};
17578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
17678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdochtypedef std::shared_ptr<TargetProperties> TargetPropertiesSP;
17778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
17878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdochclass EvaluateExpressionOptions
17978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch{
18078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdochpublic:
18178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    static const uint32_t default_timeout = 500000;
18278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    EvaluateExpressionOptions() :
18378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        m_execution_policy(eExecutionPolicyOnlyWhenNeeded),
18478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        m_coerce_to_id(false),
18578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        m_unwind_on_error(true),
18678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        m_ignore_breakpoints (false),
18778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        m_keep_in_memory(false),
18878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        m_run_others(true),
18978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        m_use_dynamic(lldb::eNoDynamicValues),
19078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        m_timeout_usec(default_timeout)
19178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {}
19278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
19378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    ExecutionPolicy
19478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetExecutionPolicy () const
19578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
19678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return m_execution_policy;
19778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
19878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
19978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    EvaluateExpressionOptions&
20078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SetExecutionPolicy (ExecutionPolicy policy = eExecutionPolicyAlways)
20178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
20278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        m_execution_policy = policy;
20378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return *this;
20478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
20578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
20678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool
20778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    DoesCoerceToId () const
20878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
20978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return m_coerce_to_id;
21078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
21178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
21278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    EvaluateExpressionOptions&
21378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SetCoerceToId (bool coerce = true)
21478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
21578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        m_coerce_to_id = coerce;
21678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return *this;
21778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
21878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
21978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool
22078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    DoesUnwindOnError () const
22178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
22278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return m_unwind_on_error;
22378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
22478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
22578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    EvaluateExpressionOptions&
22678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SetUnwindOnError (bool unwind = false)
22778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
22878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        m_unwind_on_error = unwind;
22978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return *this;
23078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
23178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
23278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool
23378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    DoesIgnoreBreakpoints () const
23478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
23578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return m_ignore_breakpoints;
23678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
23778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
23878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    EvaluateExpressionOptions&
23978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SetIgnoreBreakpoints (bool ignore = false)
24078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
24178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        m_ignore_breakpoints = ignore;
24278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return *this;
24378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
24478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
24578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool
24678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    DoesKeepInMemory () const
24778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
24878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return m_keep_in_memory;
24978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
25078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
25178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    EvaluateExpressionOptions&
25278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SetKeepInMemory (bool keep = true)
25378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
25478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        m_keep_in_memory = keep;
25578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return *this;
25678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
25778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
25878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    lldb::DynamicValueType
25978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetUseDynamic () const
26078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
26178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return m_use_dynamic;
26278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
26378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
26478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    EvaluateExpressionOptions&
26578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SetUseDynamic (lldb::DynamicValueType dynamic = lldb::eDynamicCanRunTarget)
26678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
26778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        m_use_dynamic = dynamic;
26878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return *this;
26978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
27078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
27178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    uint32_t
27278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetTimeoutUsec () const
27378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
27478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return m_timeout_usec;
27578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
27678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
27778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    EvaluateExpressionOptions&
27878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SetTimeoutUsec (uint32_t timeout = 0)
27978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
28078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        m_timeout_usec = timeout;
28178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return *this;
28278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
28378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
28478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool
28578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetRunOthers () const
28678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
28778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return m_run_others;
28878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
28978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
29078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    EvaluateExpressionOptions&
29178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SetRunOthers (bool run_others = true)
29278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
29378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        m_run_others = run_others;
29478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return *this;
29578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
29678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
29778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdochprivate:
29878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    ExecutionPolicy m_execution_policy;
29978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool m_coerce_to_id;
30078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool m_unwind_on_error;
30178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool m_ignore_breakpoints;
30278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool m_keep_in_memory;
30378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool m_run_others;
30478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    lldb::DynamicValueType m_use_dynamic;
30578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    uint32_t m_timeout_usec;
30678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch};
30778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
30878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch//----------------------------------------------------------------------
30978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch// Target
31078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch//----------------------------------------------------------------------
31178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdochclass Target :
31278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    public std::enable_shared_from_this<Target>,
31378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    public TargetProperties,
31478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    public Broadcaster,
31578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    public ExecutionContextScope,
31678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    public ModuleList::Notifier
31778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch{
31878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdochpublic:
31978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    friend class TargetList;
32078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
32178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    //------------------------------------------------------------------
32278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    /// Broadcaster event bits definitions.
32378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    //------------------------------------------------------------------
32478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    enum
32578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
32678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        eBroadcastBitBreakpointChanged  = (1 << 0),
32778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        eBroadcastBitModulesLoaded      = (1 << 1),
32878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        eBroadcastBitModulesUnloaded    = (1 << 2),
32978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        eBroadcastBitWatchpointChanged  = (1 << 3),
33078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        eBroadcastBitSymbolsLoaded      = (1 << 4)
33178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    };
33278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
33378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    // These two functions fill out the Broadcaster interface:
33478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
33578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    static ConstString &GetStaticBroadcasterClass ();
33678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
33778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    virtual ConstString &GetBroadcasterClass() const
33878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
33978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return GetStaticBroadcasterClass();
34078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
34178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
34278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    // This event data class is for use by the TargetList to broadcast new target notifications.
34378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    class TargetEventData : public EventData
34478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
34578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    public:
34678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
34778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        static const ConstString &
34878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        GetFlavorString ();
34978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
35078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        virtual const ConstString &
35178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        GetFlavor () const;
35278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
35378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        TargetEventData (const lldb::TargetSP &new_target_sp);
35478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
35578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        lldb::TargetSP &
35678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        GetTarget()
35778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        {
35878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch            return m_target_sp;
35978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        }
36078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
36178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        virtual
36278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        ~TargetEventData();
36378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
36478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        virtual void
36578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        Dump (Stream *s) const;
36678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
36778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        static const lldb::TargetSP
36878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        GetTargetFromEvent (const lldb::EventSP &event_sp);
36978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
37078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        static const TargetEventData *
37178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        GetEventDataFromEvent (const Event *event_sp);
37278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
37378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    private:
37478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        lldb::TargetSP m_target_sp;
37578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
37678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        DISALLOW_COPY_AND_ASSIGN (TargetEventData);
37778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    };
37878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
37978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    static void
38078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SettingsInitialize ();
38178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
38278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    static void
38378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SettingsTerminate ();
38478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
38578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch//    static lldb::UserSettingsControllerSP &
38678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch//    GetSettingsController ();
38778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
38878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    static FileSpecList
38978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetDefaultExecutableSearchPaths ();
39078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
39178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    static FileSpecList
39278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetDefaultDebugFileSearchPaths ();
39378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
39478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    static ArchSpec
39578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetDefaultArchitecture ();
39678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
39778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    static void
39878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    SetDefaultArchitecture (const ArchSpec &arch);
39978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
40078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch//    void
40178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch//    UpdateInstanceName ();
40278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
40378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    lldb::ModuleSP
40478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetSharedModule (const ModuleSpec &module_spec,
40578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch                     Error *error_ptr = NULL);
40678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
40778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    //----------------------------------------------------------------------
40878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    // Settings accessors
40978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    //----------------------------------------------------------------------
41078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
41178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    static const TargetPropertiesSP &
41278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetGlobalProperties();
41378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
41478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
41578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdochprivate:
41678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    //------------------------------------------------------------------
41778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    /// Construct with optional file and arch.
41878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    ///
41978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    /// This member is private. Clients must use
42078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    /// TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
42178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    /// so all targets can be tracked from the central target list.
42278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    ///
42378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    /// @see TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
42478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    //------------------------------------------------------------------
42578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    Target (Debugger &debugger,
42678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch            const ArchSpec &target_arch,
42778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch            const lldb::PlatformSP &platform_sp);
42878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
42978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    // Helper function.
43078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool
43178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    ProcessIsValid ();
43278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
43378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdochpublic:
43478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    ~Target();
43578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
43678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    Mutex &
43778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetAPIMutex ()
43878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
43978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return m_mutex;
44078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
44178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
44278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    void
44378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    DeleteCurrentProcess ();
44478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
44578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    void
44678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    CleanupProcess ();
44778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    //------------------------------------------------------------------
44878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    /// Dump a description of this object to a Stream.
44978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    ///
45078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    /// Dump a description of the contents of this object to the
45178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    /// supplied stream \a s. The dumped content will be only what has
45278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    /// been loaded or parsed up to this point at which this function
45378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    /// is called, so this is a good way to see what has been parsed
45478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    /// in a target.
45578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    ///
45678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    /// @param[in] s
45778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    ///     The stream to which to dump the object descripton.
45878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    //------------------------------------------------------------------
45978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    void
46078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    Dump (Stream *s, lldb::DescriptionLevel description_level);
46178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
46278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    const lldb::ProcessSP &
46378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    CreateProcess (Listener &listener,
46478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch                   const char *plugin_name,
46578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch                   const FileSpec *crash_file);
46678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
46778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    const lldb::ProcessSP &
46878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetProcessSP () const;
46978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
47078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    bool
47178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    IsValid()
47278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    {
47378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch        return m_valid;
47478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    }
47578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
47678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    void
47778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    Destroy();
47878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
47978901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    //------------------------------------------------------------------
48078901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    // This part handles the breakpoints.
48178901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    //------------------------------------------------------------------
48278901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
48378901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    BreakpointList &
48478901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetBreakpointList(bool internal = false);
48578901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
48678901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    const BreakpointList &
48778901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch    GetBreakpointList(bool internal = false) const;
48878901d17b47ef1f8d6d0a89eaf37f9523ba1de85Ben Murdoch
489    lldb::BreakpointSP
490    GetLastCreatedBreakpoint ()
491    {
492        return m_last_created_breakpoint;
493    }
494
495    lldb::BreakpointSP
496    GetBreakpointByID (lldb::break_id_t break_id);
497
498    // Use this to create a file and line breakpoint to a given module or all module it is NULL
499    lldb::BreakpointSP
500    CreateBreakpoint (const FileSpecList *containingModules,
501                      const FileSpec &file,
502                      uint32_t line_no,
503                      LazyBool check_inlines = eLazyBoolCalculate,
504                      LazyBool skip_prologue = eLazyBoolCalculate,
505                      bool internal = false);
506
507    // Use this to create breakpoint that matches regex against the source lines in files given in source_file_list:
508    lldb::BreakpointSP
509    CreateSourceRegexBreakpoint (const FileSpecList *containingModules,
510                                 const FileSpecList *source_file_list,
511                                 RegularExpression &source_regex,
512                                 bool internal = false);
513
514    // Use this to create a breakpoint from a load address
515    lldb::BreakpointSP
516    CreateBreakpoint (lldb::addr_t load_addr,
517                      bool internal = false);
518
519    // Use this to create Address breakpoints:
520    lldb::BreakpointSP
521    CreateBreakpoint (Address &addr,
522                      bool internal = false);
523
524    // Use this to create a function breakpoint by regexp in containingModule/containingSourceFiles, or all modules if it is NULL
525    // When "skip_prologue is set to eLazyBoolCalculate, we use the current target
526    // setting, else we use the values passed in
527    lldb::BreakpointSP
528    CreateFuncRegexBreakpoint (const FileSpecList *containingModules,
529                               const FileSpecList *containingSourceFiles,
530                               RegularExpression &func_regexp,
531                               LazyBool skip_prologue = eLazyBoolCalculate,
532                               bool internal = false);
533
534    // Use this to create a function breakpoint by name in containingModule, or all modules if it is NULL
535    // When "skip_prologue is set to eLazyBoolCalculate, we use the current target
536    // setting, else we use the values passed in
537    lldb::BreakpointSP
538    CreateBreakpoint (const FileSpecList *containingModules,
539                      const FileSpecList *containingSourceFiles,
540                      const char *func_name,
541                      uint32_t func_name_type_mask,
542                      LazyBool skip_prologue = eLazyBoolCalculate,
543                      bool internal = false);
544
545    lldb::BreakpointSP
546    CreateExceptionBreakpoint (enum lldb::LanguageType language, bool catch_bp, bool throw_bp, bool internal = false);
547
548    // This is the same as the func_name breakpoint except that you can specify a vector of names.  This is cheaper
549    // than a regular expression breakpoint in the case where you just want to set a breakpoint on a set of names
550    // you already know.
551    lldb::BreakpointSP
552    CreateBreakpoint (const FileSpecList *containingModules,
553                      const FileSpecList *containingSourceFiles,
554                      const char *func_names[],
555                      size_t num_names,
556                      uint32_t func_name_type_mask,
557                      LazyBool skip_prologue = eLazyBoolCalculate,
558                      bool internal = false);
559
560    lldb::BreakpointSP
561    CreateBreakpoint (const FileSpecList *containingModules,
562                      const FileSpecList *containingSourceFiles,
563                      const std::vector<std::string> &func_names,
564                      uint32_t func_name_type_mask,
565                      LazyBool skip_prologue = eLazyBoolCalculate,
566                      bool internal = false);
567
568
569    // Use this to create a general breakpoint:
570    lldb::BreakpointSP
571    CreateBreakpoint (lldb::SearchFilterSP &filter_sp,
572                      lldb::BreakpointResolverSP &resolver_sp,
573                      bool internal = false);
574
575    // Use this to create a watchpoint:
576    lldb::WatchpointSP
577    CreateWatchpoint (lldb::addr_t addr,
578                      size_t size,
579                      const ClangASTType *type,
580                      uint32_t kind,
581                      Error &error);
582
583    lldb::WatchpointSP
584    GetLastCreatedWatchpoint ()
585    {
586        return m_last_created_watchpoint;
587    }
588
589    WatchpointList &
590    GetWatchpointList()
591    {
592        return m_watchpoint_list;
593    }
594
595    void
596    RemoveAllBreakpoints (bool internal_also = false);
597
598    void
599    DisableAllBreakpoints (bool internal_also = false);
600
601    void
602    EnableAllBreakpoints (bool internal_also = false);
603
604    bool
605    DisableBreakpointByID (lldb::break_id_t break_id);
606
607    bool
608    EnableBreakpointByID (lldb::break_id_t break_id);
609
610    bool
611    RemoveBreakpointByID (lldb::break_id_t break_id);
612
613    // The flag 'end_to_end', default to true, signifies that the operation is
614    // performed end to end, for both the debugger and the debuggee.
615
616    bool
617    RemoveAllWatchpoints (bool end_to_end = true);
618
619    bool
620    DisableAllWatchpoints (bool end_to_end = true);
621
622    bool
623    EnableAllWatchpoints (bool end_to_end = true);
624
625    bool
626    ClearAllWatchpointHitCounts ();
627
628    bool
629    IgnoreAllWatchpoints (uint32_t ignore_count);
630
631    bool
632    DisableWatchpointByID (lldb::watch_id_t watch_id);
633
634    bool
635    EnableWatchpointByID (lldb::watch_id_t watch_id);
636
637    bool
638    RemoveWatchpointByID (lldb::watch_id_t watch_id);
639
640    bool
641    IgnoreWatchpointByID (lldb::watch_id_t watch_id, uint32_t ignore_count);
642
643    //------------------------------------------------------------------
644    /// Get \a load_addr as a callable code load address for this target
645    ///
646    /// Take \a load_addr and potentially add any address bits that are
647    /// needed to make the address callable. For ARM this can set bit
648    /// zero (if it already isn't) if \a load_addr is a thumb function.
649    /// If \a addr_class is set to eAddressClassInvalid, then the address
650    /// adjustment will always happen. If it is set to an address class
651    /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
652    /// returned.
653    //------------------------------------------------------------------
654    lldb::addr_t
655    GetCallableLoadAddress (lldb::addr_t load_addr, lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
656
657    //------------------------------------------------------------------
658    /// Get \a load_addr as an opcode for this target.
659    ///
660    /// Take \a load_addr and potentially strip any address bits that are
661    /// needed to make the address point to an opcode. For ARM this can
662    /// clear bit zero (if it already isn't) if \a load_addr is a
663    /// thumb function and load_addr is in code.
664    /// If \a addr_class is set to eAddressClassInvalid, then the address
665    /// adjustment will always happen. If it is set to an address class
666    /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
667    /// returned.
668    //------------------------------------------------------------------
669    lldb::addr_t
670    GetOpcodeLoadAddress (lldb::addr_t load_addr, lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
671
672protected:
673    //------------------------------------------------------------------
674    /// Implementing of ModuleList::Notifier.
675    //------------------------------------------------------------------
676
677    virtual void
678    ModuleAdded (const ModuleList& module_list, const lldb::ModuleSP& module_sp);
679
680    virtual void
681    ModuleRemoved (const ModuleList& module_list, const lldb::ModuleSP& module_sp);
682
683    virtual void
684    ModuleUpdated (const ModuleList& module_list,
685                   const lldb::ModuleSP& old_module_sp,
686                   const lldb::ModuleSP& new_module_sp);
687    virtual void
688    WillClearList (const ModuleList& module_list);
689
690public:
691
692    void
693    ModulesDidLoad (ModuleList &module_list);
694
695    void
696    ModulesDidUnload (ModuleList &module_list);
697
698    void
699    SymbolsDidLoad (ModuleList &module_list);
700
701    //------------------------------------------------------------------
702    /// Gets the module for the main executable.
703    ///
704    /// Each process has a notion of a main executable that is the file
705    /// that will be executed or attached to. Executable files can have
706    /// dependent modules that are discovered from the object files, or
707    /// discovered at runtime as things are dynamically loaded.
708    ///
709    /// @return
710    ///     The shared pointer to the executable module which can
711    ///     contains a NULL Module object if no executable has been
712    ///     set.
713    ///
714    /// @see DynamicLoader
715    /// @see ObjectFile::GetDependentModules (FileSpecList&)
716    /// @see Process::SetExecutableModule(lldb::ModuleSP&)
717    //------------------------------------------------------------------
718    lldb::ModuleSP
719    GetExecutableModule ();
720
721    Module*
722    GetExecutableModulePointer ();
723
724    //------------------------------------------------------------------
725    /// Set the main executable module.
726    ///
727    /// Each process has a notion of a main executable that is the file
728    /// that will be executed or attached to. Executable files can have
729    /// dependent modules that are discovered from the object files, or
730    /// discovered at runtime as things are dynamically loaded.
731    ///
732    /// Setting the executable causes any of the current dependant
733    /// image information to be cleared and replaced with the static
734    /// dependent image information found by calling
735    /// ObjectFile::GetDependentModules (FileSpecList&) on the main
736    /// executable and any modules on which it depends. Calling
737    /// Process::GetImages() will return the newly found images that
738    /// were obtained from all of the object files.
739    ///
740    /// @param[in] module_sp
741    ///     A shared pointer reference to the module that will become
742    ///     the main executable for this process.
743    ///
744    /// @param[in] get_dependent_files
745    ///     If \b true then ask the object files to track down any
746    ///     known dependent files.
747    ///
748    /// @see ObjectFile::GetDependentModules (FileSpecList&)
749    /// @see Process::GetImages()
750    //------------------------------------------------------------------
751    void
752    SetExecutableModule (lldb::ModuleSP& module_sp, bool get_dependent_files);
753
754    bool
755    LoadScriptingResources (std::list<Error>& errors,
756                            Stream* feedback_stream = NULL,
757                            bool continue_on_error = true)
758    {
759        return m_images.LoadScriptingResourcesInTarget(this,errors,feedback_stream,continue_on_error);
760    }
761
762    //------------------------------------------------------------------
763    /// Get accessor for the images for this process.
764    ///
765    /// Each process has a notion of a main executable that is the file
766    /// that will be executed or attached to. Executable files can have
767    /// dependent modules that are discovered from the object files, or
768    /// discovered at runtime as things are dynamically loaded. After
769    /// a main executable has been set, the images will contain a list
770    /// of all the files that the executable depends upon as far as the
771    /// object files know. These images will usually contain valid file
772    /// virtual addresses only. When the process is launched or attached
773    /// to, the DynamicLoader plug-in will discover where these images
774    /// were loaded in memory and will resolve the load virtual
775    /// addresses is each image, and also in images that are loaded by
776    /// code.
777    ///
778    /// @return
779    ///     A list of Module objects in a module list.
780    //------------------------------------------------------------------
781    const ModuleList&
782    GetImages () const
783    {
784        return m_images;
785    }
786
787    ModuleList&
788    GetImages ()
789    {
790        return m_images;
791    }
792
793    //------------------------------------------------------------------
794    /// Return whether this FileSpec corresponds to a module that should be considered for general searches.
795    ///
796    /// This API will be consulted by the SearchFilterForNonModuleSpecificSearches
797    /// and any module that returns \b true will not be searched.  Note the
798    /// SearchFilterForNonModuleSpecificSearches is the search filter that
799    /// gets used in the CreateBreakpoint calls when no modules is provided.
800    ///
801    /// The target call at present just consults the Platform's call of the
802    /// same name.
803    ///
804    /// @param[in] module_sp
805    ///     A shared pointer reference to the module that checked.
806    ///
807    /// @return \b true if the module should be excluded, \b false otherwise.
808    //------------------------------------------------------------------
809    bool
810    ModuleIsExcludedForNonModuleSpecificSearches (const FileSpec &module_spec);
811
812    //------------------------------------------------------------------
813    /// Return whether this module should be considered for general searches.
814    ///
815    /// This API will be consulted by the SearchFilterForNonModuleSpecificSearches
816    /// and any module that returns \b true will not be searched.  Note the
817    /// SearchFilterForNonModuleSpecificSearches is the search filter that
818    /// gets used in the CreateBreakpoint calls when no modules is provided.
819    ///
820    /// The target call at present just consults the Platform's call of the
821    /// same name.
822    ///
823    /// FIXME: When we get time we should add a way for the user to set modules that they
824    /// don't want searched, in addition to or instead of the platform ones.
825    ///
826    /// @param[in] module_sp
827    ///     A shared pointer reference to the module that checked.
828    ///
829    /// @return \b true if the module should be excluded, \b false otherwise.
830    //------------------------------------------------------------------
831    bool
832    ModuleIsExcludedForNonModuleSpecificSearches (const lldb::ModuleSP &module_sp);
833
834    ArchSpec &
835    GetArchitecture ()
836    {
837        return m_arch;
838    }
839
840    const ArchSpec &
841    GetArchitecture () const
842    {
843        return m_arch;
844    }
845
846    //------------------------------------------------------------------
847    /// Set the architecture for this target.
848    ///
849    /// If the current target has no Images read in, then this just sets the architecture, which will
850    /// be used to select the architecture of the ExecutableModule when that is set.
851    /// If the current target has an ExecutableModule, then calling SetArchitecture with a different
852    /// architecture from the currently selected one will reset the ExecutableModule to that slice
853    /// of the file backing the ExecutableModule.  If the file backing the ExecutableModule does not
854    /// contain a fork of this architecture, then this code will return false, and the architecture
855    /// won't be changed.
856    /// If the input arch_spec is the same as the already set architecture, this is a no-op.
857    ///
858    /// @param[in] arch_spec
859    ///     The new architecture.
860    ///
861    /// @return
862    ///     \b true if the architecture was successfully set, \bfalse otherwise.
863    //------------------------------------------------------------------
864    bool
865    SetArchitecture (const ArchSpec &arch_spec);
866
867    Debugger &
868    GetDebugger ()
869    {
870        return m_debugger;
871    }
872
873    size_t
874    ReadMemoryFromFileCache (const Address& addr,
875                             void *dst,
876                             size_t dst_len,
877                             Error &error);
878
879    // Reading memory through the target allows us to skip going to the process
880    // for reading memory if possible and it allows us to try and read from
881    // any constant sections in our object files on disk. If you always want
882    // live program memory, read straight from the process. If you possibly
883    // want to read from const sections in object files, read from the target.
884    // This version of ReadMemory will try and read memory from the process
885    // if the process is alive. The order is:
886    // 1 - if (prefer_file_cache == true) then read from object file cache
887    // 2 - if there is a valid process, try and read from its memory
888    // 3 - if (prefer_file_cache == false) then read from object file cache
889    size_t
890    ReadMemory (const Address& addr,
891                bool prefer_file_cache,
892                void *dst,
893                size_t dst_len,
894                Error &error,
895                lldb::addr_t *load_addr_ptr = NULL);
896
897    size_t
898    ReadCStringFromMemory (const Address& addr, std::string &out_str, Error &error);
899
900    size_t
901    ReadCStringFromMemory (const Address& addr, char *dst, size_t dst_max_len, Error &result_error);
902
903    size_t
904    ReadScalarIntegerFromMemory (const Address& addr,
905                                 bool prefer_file_cache,
906                                 uint32_t byte_size,
907                                 bool is_signed,
908                                 Scalar &scalar,
909                                 Error &error);
910
911    uint64_t
912    ReadUnsignedIntegerFromMemory (const Address& addr,
913                                   bool prefer_file_cache,
914                                   size_t integer_byte_size,
915                                   uint64_t fail_value,
916                                   Error &error);
917
918    bool
919    ReadPointerFromMemory (const Address& addr,
920                           bool prefer_file_cache,
921                           Error &error,
922                           Address &pointer_addr);
923
924    SectionLoadList&
925    GetSectionLoadList()
926    {
927        return m_section_load_list;
928    }
929
930    const SectionLoadList&
931    GetSectionLoadList() const
932    {
933        return m_section_load_list;
934    }
935
936    static Target *
937    GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr,
938                           const SymbolContext *sc_ptr);
939
940    //------------------------------------------------------------------
941    // lldb::ExecutionContextScope pure virtual functions
942    //------------------------------------------------------------------
943    virtual lldb::TargetSP
944    CalculateTarget ();
945
946    virtual lldb::ProcessSP
947    CalculateProcess ();
948
949    virtual lldb::ThreadSP
950    CalculateThread ();
951
952    virtual lldb::StackFrameSP
953    CalculateStackFrame ();
954
955    virtual void
956    CalculateExecutionContext (ExecutionContext &exe_ctx);
957
958    PathMappingList &
959    GetImageSearchPathList ();
960
961    ClangASTContext *
962    GetScratchClangASTContext(bool create_on_demand=true);
963
964    ClangASTImporter *
965    GetClangASTImporter();
966
967
968    // Since expressions results can persist beyond the lifetime of a process,
969    // and the const expression results are available after a process is gone,
970    // we provide a way for expressions to be evaluated from the Target itself.
971    // If an expression is going to be run, then it should have a frame filled
972    // in in th execution context.
973    ExecutionResults
974    EvaluateExpression (const char *expression,
975                        StackFrame *frame,
976                        lldb::ValueObjectSP &result_valobj_sp,
977                        const EvaluateExpressionOptions& options = EvaluateExpressionOptions());
978
979    ClangPersistentVariables &
980    GetPersistentVariables()
981    {
982        return m_persistent_variables;
983    }
984
985    //------------------------------------------------------------------
986    // Target Stop Hooks
987    //------------------------------------------------------------------
988    class StopHook : public UserID
989    {
990    public:
991        ~StopHook ();
992
993        StopHook (const StopHook &rhs);
994
995        StringList *
996        GetCommandPointer ()
997        {
998            return &m_commands;
999        }
1000
1001        const StringList &
1002        GetCommands()
1003        {
1004            return m_commands;
1005        }
1006
1007        lldb::TargetSP &
1008        GetTarget()
1009        {
1010            return m_target_sp;
1011        }
1012
1013        void
1014        SetCommands (StringList &in_commands)
1015        {
1016            m_commands = in_commands;
1017        }
1018
1019        // Set the specifier.  The stop hook will own the specifier, and is responsible for deleting it when we're done.
1020        void
1021        SetSpecifier (SymbolContextSpecifier *specifier)
1022        {
1023            m_specifier_sp.reset (specifier);
1024        }
1025
1026        SymbolContextSpecifier *
1027        GetSpecifier ()
1028        {
1029            return m_specifier_sp.get();
1030        }
1031
1032        // Set the Thread Specifier.  The stop hook will own the thread specifier, and is responsible for deleting it when we're done.
1033        void
1034        SetThreadSpecifier (ThreadSpec *specifier);
1035
1036        ThreadSpec *
1037        GetThreadSpecifier()
1038        {
1039            return m_thread_spec_ap.get();
1040        }
1041
1042        bool
1043        IsActive()
1044        {
1045            return m_active;
1046        }
1047
1048        void
1049        SetIsActive (bool is_active)
1050        {
1051            m_active = is_active;
1052        }
1053
1054        void
1055        GetDescription (Stream *s, lldb::DescriptionLevel level) const;
1056
1057    private:
1058        lldb::TargetSP m_target_sp;
1059        StringList   m_commands;
1060        lldb::SymbolContextSpecifierSP m_specifier_sp;
1061        std::unique_ptr<ThreadSpec> m_thread_spec_ap;
1062        bool m_active;
1063
1064        // Use AddStopHook to make a new empty stop hook.  The GetCommandPointer and fill it with commands,
1065        // and SetSpecifier to set the specifier shared pointer (can be null, that will match anything.)
1066        StopHook (lldb::TargetSP target_sp, lldb::user_id_t uid);
1067        friend class Target;
1068    };
1069    typedef std::shared_ptr<StopHook> StopHookSP;
1070
1071    // Add an empty stop hook to the Target's stop hook list, and returns a shared pointer to it in new_hook.
1072    // Returns the id of the new hook.
1073    lldb::user_id_t
1074    AddStopHook (StopHookSP &new_hook);
1075
1076    void
1077    RunStopHooks ();
1078
1079    size_t
1080    GetStopHookSize();
1081
1082    bool
1083    SetSuppresStopHooks (bool suppress)
1084    {
1085        bool old_value = m_suppress_stop_hooks;
1086        m_suppress_stop_hooks = suppress;
1087        return old_value;
1088    }
1089
1090    bool
1091    GetSuppressStopHooks ()
1092    {
1093        return m_suppress_stop_hooks;
1094    }
1095
1096    bool
1097    SetSuppressSyntheticValue (bool suppress)
1098    {
1099        bool old_value = m_suppress_synthetic_value;
1100        m_suppress_synthetic_value = suppress;
1101        return old_value;
1102    }
1103
1104    bool
1105    GetSuppressSyntheticValue ()
1106    {
1107        return m_suppress_synthetic_value;
1108    }
1109
1110//    StopHookSP &
1111//    GetStopHookByIndex (size_t index);
1112//
1113    bool
1114    RemoveStopHookByID (lldb::user_id_t uid);
1115
1116    void
1117    RemoveAllStopHooks ();
1118
1119    StopHookSP
1120    GetStopHookByID (lldb::user_id_t uid);
1121
1122    bool
1123    SetStopHookActiveStateByID (lldb::user_id_t uid, bool active_state);
1124
1125    void
1126    SetAllStopHooksActiveState (bool active_state);
1127
1128    size_t GetNumStopHooks () const
1129    {
1130        return m_stop_hooks.size();
1131    }
1132
1133    StopHookSP
1134    GetStopHookAtIndex (size_t index)
1135    {
1136        if (index >= GetNumStopHooks())
1137            return StopHookSP();
1138        StopHookCollection::iterator pos = m_stop_hooks.begin();
1139
1140        while (index > 0)
1141        {
1142            pos++;
1143            index--;
1144        }
1145        return (*pos).second;
1146    }
1147
1148    lldb::PlatformSP
1149    GetPlatform ()
1150    {
1151        return m_platform_sp;
1152    }
1153
1154    void
1155    SetPlatform (const lldb::PlatformSP &platform_sp)
1156    {
1157        m_platform_sp = platform_sp;
1158    }
1159
1160    SourceManager &
1161    GetSourceManager ();
1162
1163    //------------------------------------------------------------------
1164    // Methods.
1165    //------------------------------------------------------------------
1166    lldb::SearchFilterSP
1167    GetSearchFilterForModule (const FileSpec *containingModule);
1168
1169    lldb::SearchFilterSP
1170    GetSearchFilterForModuleList (const FileSpecList *containingModuleList);
1171
1172    lldb::SearchFilterSP
1173    GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles);
1174
1175protected:
1176    //------------------------------------------------------------------
1177    // Member variables.
1178    //------------------------------------------------------------------
1179    Debugger &      m_debugger;
1180    lldb::PlatformSP m_platform_sp;     ///< The platform for this target.
1181    Mutex           m_mutex;            ///< An API mutex that is used by the lldb::SB* classes make the SB interface thread safe
1182    ArchSpec        m_arch;
1183    ModuleList      m_images;           ///< The list of images for this process (shared libraries and anything dynamically loaded).
1184    SectionLoadList m_section_load_list;
1185    BreakpointList  m_breakpoint_list;
1186    BreakpointList  m_internal_breakpoint_list;
1187    lldb::BreakpointSP m_last_created_breakpoint;
1188    WatchpointList  m_watchpoint_list;
1189    lldb::WatchpointSP m_last_created_watchpoint;
1190    // We want to tightly control the process destruction process so
1191    // we can correctly tear down everything that we need to, so the only
1192    // class that knows about the process lifespan is this target class.
1193    lldb::ProcessSP m_process_sp;
1194    bool m_valid;
1195    lldb::SearchFilterSP  m_search_filter_sp;
1196    PathMappingList m_image_search_paths;
1197    std::unique_ptr<ClangASTContext> m_scratch_ast_context_ap;
1198    std::unique_ptr<ClangASTSource> m_scratch_ast_source_ap;
1199    std::unique_ptr<ClangASTImporter> m_ast_importer_ap;
1200    ClangPersistentVariables m_persistent_variables;      ///< These are the persistent variables associated with this process for the expression parser.
1201
1202    std::unique_ptr<SourceManager> m_source_manager_ap;
1203
1204    typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection;
1205    StopHookCollection      m_stop_hooks;
1206    lldb::user_id_t         m_stop_hook_next_id;
1207    bool                    m_suppress_stop_hooks;
1208    bool                    m_suppress_synthetic_value;
1209
1210    static void
1211    ImageSearchPathsChanged (const PathMappingList &path_list,
1212                             void *baton);
1213
1214private:
1215    DISALLOW_COPY_AND_ASSIGN (Target);
1216};
1217
1218} // namespace lldb_private
1219
1220#endif  // liblldb_Target_h_
1221