Commit 3df9a8df authored by Caroline Tice's avatar Caroline Tice
Browse files

This is a very large commit that completely re-does the way lldb
handles user settable internal variables (the equivalent of set/show
variables in gdb).  In addition to the basic infrastructure (most of
which is defined in UserSettingsController.{h,cpp}, there are examples
of two classes that have been set up to contain user settable
variables (the Debugger and Process classes).  The 'settings' command
has been modified to be a command-subcommand structure, and the 'set',
'show' and 'append' commands have been moved into this sub-commabnd
structure.  The old StateVariable class has been completely replaced
by this, and the state variable dictionary has been removed from the
Command Interpreter.  Places that formerly accessed the state variable
mechanism have been modified to access the variables in this new
structure instead (checking the term-width; getting/checking the
prompt; etc.)

Variables are attached to classes; there are two basic "flavors" of
variables that can be set: "global" variables (static/class-wide), and
"instance" variables (one per instance of the class).  The whole thing
has been set up so that any global or instance variable can be set at
any time (e.g. on start up, in your .lldbinit file), whether or not
any instances actually exist (there's a whole pending and default
values mechanism to help deal with that).

llvm-svn: 113041
parent 070ebd93
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -42,8 +42,8 @@ public:
    lldb::SBBroadcaster
    GetBroadcaster ();

    const char **
    GetEnvironmentVariables ();
    //const char **
    //GetEnvironmentVariables ();

    bool
    HasCommands ();
@@ -57,8 +57,8 @@ public:
    bool
    HasAliasOptions ();

    bool
    HasInterpreterVariables ();
    //bool
    //HasInterpreterVariables ();

    lldb::SBProcess
    GetProcess ();
+6 −0
Original line number Diff line number Diff line
@@ -145,6 +145,12 @@ public:
    static SBDebugger
    FindDebuggerWithID (int id);

    lldb::SBError
    SetInternalVariable (const char *var_name, const char *value);

    lldb::SBStringList
    GetInternalVariableValue (const char *var_name);

private:

#ifndef SWIG
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ class SBListener;
class SBModule;
class SBProcess;
class SBSourceManager;
class SBStringList;
class SBSymbol;
class SBSymbolContext;
class SBStringList;
+1 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ public:

protected:
    friend class SBArguments;
    friend class SBDebugger;
    friend class SBCommunication;
    friend class SBHostOS;
    friend class SBInputReader;
+106 −4
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/SourceManager.h"
#include "lldb/Core/UserID.h"
#include "lldb/Core/UserSettingsController.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/TargetList.h"

@@ -33,11 +34,112 @@ namespace lldb_private {
///
/// Provides a global root objects for the debugger core.
//----------------------------------------------------------------------
    

class DebuggerInstanceSettings : public InstanceSettings
{
public:
    
    DebuggerInstanceSettings (UserSettingsController &owner, const char *name = NULL);

    DebuggerInstanceSettings (const DebuggerInstanceSettings &rhs);

    virtual
    ~DebuggerInstanceSettings ();

    DebuggerInstanceSettings&
    operator= (const DebuggerInstanceSettings &rhs);

    void
    UpdateInstanceSettingsVariable (const ConstString &var_name,
                                    const char *index_value,
                                    const char *value,
                                    const ConstString &instance_name,
                                    const SettingEntry &entry,
                                    lldb::VarSetOperationType op,
                                    Error &err,
                                    bool pending);

    void
    GetInstanceSettingsValue (const SettingEntry &entry,
                              const ConstString &var_name,
                              StringList &value);

protected:

    void
    CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings,
                          bool pending);

    bool
    BroadcastPromptChange (const ConstString &instance_name, const char *new_prompt);

    const ConstString
    CreateInstanceName ();

    const ConstString &
    PromptVarName ();

    const ConstString &
    ScriptLangVarName ();
  
private:

    std::string m_prompt;
    lldb::ScriptLanguage m_script_lang;
};



class Debugger :
    public UserID
    public UserID,
    public DebuggerInstanceSettings
{
public:

    class DebuggerSettingsController : public UserSettingsController
    {
    public:

        DebuggerSettingsController ();

        virtual
        ~DebuggerSettingsController ();

        void
        UpdateGlobalVariable (const ConstString &var_name,
                              const char *index_value,
                              const char *value,
                              const SettingEntry &entry,
                              lldb::VarSetOperationType op,
                              Error&err);

        void
        GetGlobalSettingsValue (const ConstString &var_name, 
                                StringList &value);

        static SettingEntry global_settings_table[];
        static SettingEntry instance_settings_table[];

    protected:

        lldb::InstanceSettingsSP
        CreateNewInstanceSettings ();

        bool
        ValidTermWidthValue (const char *value, Error err);

    private:

        // Class-wide settings.
        int m_term_width;

        DISALLOW_COPY_AND_ASSIGN (DebuggerSettingsController);
    };

    static lldb::UserSettingsControllerSP &
    GetSettingsController (bool finish = false);

    static lldb::DebuggerSP
    CreateInstance ();

@@ -137,7 +239,6 @@ public:
        return m_exe_ctx;
    }


    void
    UpdateExecutionContext (ExecutionContext *override_context);

@@ -158,6 +259,9 @@ public:
        return m_use_external_editor;
    }

    static lldb::DebuggerSP
    FindDebuggerWithInstanceName (const ConstString &instance_name);

protected:

    static void
@@ -192,8 +296,6 @@ private:
    // debugger object
    Debugger ();



    DISALLOW_COPY_AND_ASSIGN (Debugger);
};

Loading