classdef LinuxHostDebuggerManager < rtw.connectivity.HostDebuggerManager
    %LINUXHOSTDEBUGGERMANAGER utility class to create an instance of 
    % rtw.connectivity.LinuxSILDebugger
    %
    %   This is an undocumented class. Its methods and properties are
    %   likely to change without warning from one release to the next.
    
    %   Copyright 2020-2022 The MathWorks, Inc.
    
    methods
        function this = LinuxHostDebuggerManager(spkgManager)
            compilerID = {'GCC'};
            % No restriction on GCC version, set to empty
            compilerVersionPairs = {...
                {'GCC', ''}};
            this = this@rtw.connectivity.HostDebuggerManager(compilerID, compilerVersionPairs, spkgManager);
        end
    end

    methods(Access = protected)    
        function checkDebuggerIsAvailable(this, ~)

            % check that GDB and DDD are available and issue an error if
            % not
            if ~rtw.connectivity.HostSILDebugger.commandExists('gdb')
                error(message('PIL:pil:SILDebuggingGDBNotFound'));
            end

            % Check if DDD is available. If it is not, and the VS Code
            % Debug Tool is not enabled or not installed, throw and error.
            this.throwOnMissingUnixDebugger('ddd', 'PIL:pil:SILDebuggingDDDNotFound');
        end
                
        function service = getDebugTool(this)

            if this.TFSPKGManager.isInstalledAndEnabled('VSCodeDebugTool')
                service = target.internal.get('ExecutionService', 'Visual Studio Code');
            else
                service = target.internal.get('ExecutionService', 'DDD');
            end
        end
        
        function populateToolchainInfo(this, defaultComp)
            if strcmp(defaultComp.compStr, 'GNU-x')
                this.populateBasicToolchainInfo(defaultComp);
            end
        end
    end
end
