Esempio n. 1
0
//++ ------------------------------------------------------------------------------------
// Details:	Get the current driver to validate executable command line arguments.
// Type:	Method.
// Args:	argc		- (R)	An integer that contains the count of arguments that follow in 
//								argv. The argc parameter is always greater than or equal to 1.
//			argv		- (R)	An array of null-terminated strings representing command-line 
//								arguments entered by the user of the program. By convention, 
//								argv[0] is the command with which the program is invoked.
//			vpStdOut	- (R)	Point to a standard output stream. 
//			vwbExiting	- (W)	True = *this want to exit, false = continue to work. 
// Return:	MIstatus::success - Functional succeeded.
//			MIstatus::failure - Functional failed.
// Throws:	None.
//--
bool CMIDriverMgr::DriverParseArgs( const int argc, const char * argv[], FILE * vpStdOut, bool & vwbExiting )
{
	if( m_pDriverCurrent == nullptr )
	{
		const CMIUtilString errMsg( CMIUtilString::Format( MIRSRC( IDS_DRIVER_ERR_CURRENT_NOT_SET ) ) );
		CMICmnStreamStdout::Instance().Write( errMsg, true );
		return MIstatus::failure;
	}

	const lldb::SBError error( m_pDriverCurrent->DoParseArgs( argc, argv, vpStdOut, vwbExiting ) );
	bool bOk = !error.Fail();
	if( !bOk )
	{
		CMIUtilString errMsg;
		const MIchar * pErrorCstr = error.GetCString();
		if( pErrorCstr != nullptr )
			errMsg = CMIUtilString::Format( MIRSRC( IDS_DRIVER_ERR_PARSE_ARGS ), m_pDriverCurrent->GetName().c_str(), pErrorCstr );
		else
			errMsg = CMIUtilString::Format( MIRSRC( IDS_DRIVER_ERR_PARSE_ARGS_UNKNOWN ), m_pDriverCurrent->GetName().c_str() );

		bOk = CMICmnStreamStdout::Instance().Write( errMsg, true );
	}

	return bOk;
}
Esempio n. 2
0
//++
// Details: Short cut function to check MI command's execute status and
//          set an error in case of failure.
// Type:    Method.
// Args:    error - (R) Error description object.
//          successHandler - (R) function describing actions to execute
//          in case of success state of passed SBError object.
//          errorHandler - (R) function describing actions to execute
//          in case of fail status of passed SBError object.
// Return:  bool.
// Throws:  None.
//--
bool CMICmdBase::HandleSBError(const lldb::SBError &error,
                               const std::function<bool()> &successHandler,
                               const std::function<void()> &errorHandler) {
  if (error.Success())
    return successHandler();

  SetError(error.GetCString());
  errorHandler();
  return MIstatus::failure;
}
Esempio n. 3
0
lldb::SBTarget
SBDebugger::CreateTarget (const char *filename,
                          const char *target_triple,
                          const char *platform_name,
                          bool add_dependent_modules,
                          lldb::SBError& sb_error)
{
    SBTarget sb_target;
    TargetSP target_sp;
    if (m_opaque_sp)
    {
        sb_error.Clear();
        FileSpec filename_spec (filename, true);
        OptionGroupPlatform platform_options (false);
        platform_options.SetPlatformName (platform_name);
        
        sb_error.ref() = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, 
                                                                    filename_spec, 
                                                                    target_triple, 
                                                                    add_dependent_modules, 
                                                                    &platform_options,
                                                                    target_sp);
    
        if (sb_error.Success())
            sb_target.SetSP (target_sp);
    }
    else
    {
        sb_error.SetErrorString("invalid target");
    }
    
    LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
    if (log)
    {
        log->Printf ("SBDebugger(%p)::CreateTarget (filename=\"%s\", triple=%s, platform_name=%s, add_dependent_modules=%u, error=%s) => SBTarget(%p)", 
                     m_opaque_sp.get(), 
                     filename, 
                     target_triple,
                     platform_name,
                     add_dependent_modules,
                     sb_error.GetCString(),
                     target_sp.get());
    }
    
    return sb_target;
}