Пример #1
0
void
Driver::ExecuteInitialCommands (bool before_file)
{
    size_t num_commands;
    std::vector<std::pair<bool, std::string> > *command_set;
    if (before_file)
        command_set = &(m_option_data.m_initial_commands);
    else
        command_set = &(m_option_data.m_after_file_commands);
    
    num_commands = command_set->size();
    SBCommandReturnObject result;
    bool old_async = GetDebugger().GetAsync();
    GetDebugger().SetAsync(false);
    for (size_t idx = 0; idx < num_commands; idx++)
    {
        bool is_file = (*command_set)[idx].first;
        const char *command = (*command_set)[idx].second.c_str();
        char command_string[PATH_MAX * 2];
        const bool dump_stream_only_if_no_immediate = true;
        const char *executed_command = command;
        if (is_file)
        {
            ::snprintf (command_string, sizeof(command_string), "command source -s %i '%s'", m_option_data.m_source_quietly, command);
            executed_command = command_string;
        }
        
        m_debugger.GetCommandInterpreter().HandleCommand (executed_command, result, false);
        if (!m_option_data.m_source_quietly || result.Succeeded() == false)
        {
            const size_t output_size = result.GetOutputSize();
            if (output_size > 0)
            {
                const char *cstr = result.GetOutput(dump_stream_only_if_no_immediate);
                if (cstr)
                    printf ("%s", cstr);
            }
            const size_t error_size = result.GetErrorSize();
            if (error_size > 0)
            {
                const char *cstr = result.GetError(dump_stream_only_if_no_immediate);
                if (cstr)
                    printf ("%s", cstr);
            }
        }
        
        if (result.Succeeded() == false)
        {
            const char *type = before_file ? "before file" : "after_file";
            if (is_file)
                ::fprintf(stderr, "Aborting %s command execution, command file: '%s' failed.\n", type, command);
            else
                ::fprintf(stderr, "Aborting %s command execution, command: '%s' failed.\n", type, command);
            break;
        }
        result.Clear();
    }
    GetDebugger().SetAsync(old_async);
}
Пример #2
0
//++ ------------------------------------------------------------------------------------
// Details:	This function allows *this driver to call on another driver to perform work
//			should this driver not be able to handle the client data input.
//			SetDriverToFallThruTo() specifies the fall through to driver.
//			Check the error message if the function returns a failure.
// Type:	Overridden.
// Args:	vCmd		- (R) Command instruction to interpret.
//			vwErrMsg	- (W) Error description on command failing.
// Return:	MIstatus::success - Command succeeded.
//			MIstatus::failure - Command failed.
// Throws:	None.
//--
bool Driver::DoFallThruToAnotherDriver( const CMIUtilString & vCmd, CMIUtilString & vwErrMsg )
{
	bool bOk = MIstatus::success;
	vwErrMsg.empty();

	// ToDo: Implement do work on other driver after this driver said "Give up you try"
	// This may nto be required if the feature to 'fall through' is not required
	SBCommandReturnObject returnObj = lldb::SBCommandReturnObject();
	SBCommandInterpreter cmdIntrp = m_debugger.GetCommandInterpreter();
    const lldb::ReturnStatus cmdResult = cmdIntrp.HandleCommand( vCmd.c_str(), returnObj ); MIunused( cmdResult );
	if( returnObj.Succeeded() == false )
	{
		bOk = MIstatus::failure;
		vwErrMsg = returnObj.GetError();
	}
	
	return bOk;
}