[Lldb-commits] [PATCH] D48295: [WIP] Implement new ReturnMIStatus method of CMICmdBase class.

Alexander Polyakov via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 19 15:49:43 PDT 2018


apolyakov added a comment.

>   bool handleSBError(SBError error, std::function<std::string(SBError)> convert) {
>     if (error.Success())
>       return false;
>   
>     SetError(convert(error));
>     return error_handler();
>   }
>   
>   ...
>   bool CMICmdCmdExecContinue::Execute() {
>     if (handleSBError(CMICmnLLDBDebugSessionInfo::Instance().GetProcess().Continue(), [](SBError error){
>           return CMIUtilString::Format(
>              MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE),
>              this->m_cmdData.strMiCmd.c_str(),
>              rErrMsg.c_str());'
>          }) 
>       return MIstatus::failure;
>   
>     // potentially run other SBAPI commands...
>     return MIstatus::success;
>   };
>   

In this case, it's not clear how to pass `error_handler` to `handleSBError(...)`. Moreover, user may want to specify action for success case which isn't presented in your example.

About using more than one SB API command: it's possible even in my patch, just use `ReturnMIStatus` like:

  if (!ReturnMIStatus(success_handler, error_handler, error))
    return MIstatus::failure;
  
  // do other stuff
  ...
  return MIstatus::success;


https://reviews.llvm.org/D48295





More information about the lldb-commits mailing list