bool DoExecute(Args &command, CommandReturnObject &result) override { Stream &strm = result.GetOutputStream(); RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext(); const RegisterInfo *reg_info = nullptr; if (command.GetArgumentCount() == 0) { size_t set_idx; size_t num_register_sets = 1; const size_t set_array_size = m_command_options.set_indexes.GetSize(); if (set_array_size > 0) { for (size_t i = 0; i < set_array_size; ++i) { set_idx = m_command_options.set_indexes[i]->GetUInt64Value(UINT32_MAX, nullptr); if (set_idx < reg_ctx->GetRegisterSetCount()) { if (!DumpRegisterSet(m_exe_ctx, strm, reg_ctx, set_idx)) { if (errno) result.AppendErrorWithFormatv("register read failed: {0}\n", llvm::sys::StrError()); else result.AppendError("unknown error while reading registers.\n"); result.SetStatus(eReturnStatusFailed); break; } } else { result.AppendErrorWithFormat( "invalid register set index: %" PRIu64 "\n", (uint64_t)set_idx); result.SetStatus(eReturnStatusFailed); break; } } } else { if (m_command_options.dump_all_sets) num_register_sets = reg_ctx->GetRegisterSetCount(); for (set_idx = 0; set_idx < num_register_sets; ++set_idx) { // When dump_all_sets option is set, dump primitive as well as // derived registers. DumpRegisterSet(m_exe_ctx, strm, reg_ctx, set_idx, !m_command_options.dump_all_sets.GetCurrentValue()); } } } else { if (m_command_options.dump_all_sets) { result.AppendError("the --all option can't be used when registers " "names are supplied as arguments\n"); result.SetStatus(eReturnStatusFailed); } else if (m_command_options.set_indexes.GetSize() > 0) { result.AppendError("the --set <set> option can't be used when " "registers names are supplied as arguments\n"); result.SetStatus(eReturnStatusFailed); } else { for (auto &entry : command) { // in most LLDB commands we accept $rbx as the name for register RBX // - and here we would reject it and non-existant. we should be more // consistent towards the user and allow them to say reg read $rbx - // internally, however, we should be strict and not allow ourselves // to call our registers $rbx in our own API auto arg_str = entry.ref; arg_str.consume_front("$"); reg_info = reg_ctx->GetRegisterInfoByName(arg_str); if (reg_info) { if (!DumpRegister(m_exe_ctx, strm, reg_ctx, reg_info)) strm.Printf("%-12s = error: unavailable\n", reg_info->name); } else { result.AppendErrorWithFormat("Invalid register name '%s'.\n", arg_str.str().c_str()); } } } } return result.Succeeded(); }