diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp index a0e88f6ab4ba2..6e6071fd54606 100644 --- a/lldb/source/Commands/CommandObjectRegister.cpp +++ b/lldb/source/Commands/CommandObjectRegister.cpp @@ -406,8 +406,9 @@ class CommandObjectRegisterInfo : public CommandObjectParsed { CommandObjectRegisterInfo(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "register info", "View information about a register.", nullptr, - eCommandRequiresRegContext | - eCommandProcessMustBeLaunched) { + eCommandRequiresFrame | eCommandRequiresRegContext | + eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused) { SetHelpLong(R"( Name The name lldb uses for the register, optionally with an alias. Size The size of the register in bytes and again in bits. diff --git a/lldb/test/API/commands/register/register/register_command/TestRegisters.py b/lldb/test/API/commands/register/register/register_command/TestRegisters.py index 2e5c82a26cf1b..f2ee3c4a047a2 100644 --- a/lldb/test/API/commands/register/register/register_command/TestRegisters.py +++ b/lldb/test/API/commands/register/register/register_command/TestRegisters.py @@ -659,3 +659,17 @@ def test_fs_gs_base(self): pthread_self_val.GetValueAsUnsigned(0), "fs_base does not equal to pthread_self() value.", ) + + def test_process_must_be_stopped(self): + """Check that all register commands error when the process is not stopped.""" + self.build() + exe = self.getBuildArtifact("a.out") + pid = self.spawnSubprocess(exe, ["wait_for_attach"]).pid + # Async so we can enter commands while the process is running. + self.setAsync(True) + self.runCmd("process attach --continue -p %d" % pid) + + err_msg = "Command requires a process which is currently stopped." + self.expect("register read pc", substrs=[err_msg], error=True) + self.expect("register write pc 0", substrs=[err_msg], error=True) + self.expect("register info pc", substrs=[err_msg], error=True)