From 2f59302ce804c0886ccc4dcdd5e51789981d4bc3 Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Tue, 26 Mar 2013 01:27:04 +0000 Subject: Make register read and write accept $ as valid. This allows: (lldb) reg read rbx rbx = 0x0000000000000000 (lldb) reg read $rbx rbx = 0x0000000000000000 (lldb) reg write $rbx 1 (lldb) reg read $rbx rbx = 0x0000000000000001 to function correctly It is not done at the RegisterContext level because we should keep the internal API clean of this user-friendly behavior and name registers appropriately. If this ends up being needed in more places we can reconsider. llvm-svn: 177961 --- lldb/source/Commands/CommandObjectRegister.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lldb/source/Commands/CommandObjectRegister.cpp') diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp index 79a76fbaed9..0a9115ec015 100644 --- a/lldb/source/Commands/CommandObjectRegister.cpp +++ b/lldb/source/Commands/CommandObjectRegister.cpp @@ -228,6 +228,12 @@ protected: const char *arg_cstr; for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx) { + // 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 + if (*arg_cstr == '$') + arg_cstr = arg_cstr+1; reg_info = reg_ctx->GetRegisterInfoByName(arg_cstr); if (reg_info) @@ -410,6 +416,15 @@ protected: { const char *reg_name = command.GetArgumentAtIndex(0); const char *value_str = command.GetArgumentAtIndex(1); + + + // 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 write $rbx - internally, however, we should be strict and not allow ourselves + // to call our registers $rbx in our own API + if (reg_name && *reg_name == '$') + reg_name = reg_name+1; + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name); if (reg_info) -- cgit v1.2.3