[lldb-dev] showing CPU register flags

Greg Clayton via lldb-dev lldb-dev at lists.llvm.org
Wed Aug 17 17:02:43 PDT 2016


> On Aug 17, 2016, at 8:17 AM, Giusti, Valentina via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> 
> Hi everyone,
> 
> I am currently implementing the support for the Intel MPX registers in LLDB. This register set includes 2 registers, BNDSTATUS and BNDCFGU, which store information about the status and configuration of the MPX feature in several fields.
> I think that it would be useful for the user to have a nice display of such fields, so that they don't have to extract the information from the raw values of the registers. However, I see that the other registers are just displayed as raw values, without any better ways to explore their contents.
> 
> Should I just follow this approach, and also just let the MPX registers be available through their raw values? 
> Or have there ever been any requests for ways to display the register flags from LLDB?

We haven't done anything fancy for registers yet. I see a few ways to do this:

1 - allow register values to specify a CompilerType as the way to display the register. Right now registers always default to use simple built in types:


CompilerType
ValueObjectRegister::GetCompilerTypeImpl ()
{
    if (!m_compiler_type.IsValid())
    {
        ExecutionContext exe_ctx (GetExecutionContextRef());
        Target *target = exe_ctx.GetTargetPtr();
        if (target)
        {
            Module *exe_module = target->GetExecutableModulePointer();
            if (exe_module)
            {
                TypeSystem *type_system = exe_module->GetTypeSystemForLanguage (eLanguageTypeC);
                if (type_system)
                    m_compiler_type = type_system->GetBuiltinTypeForEncodingAndBitSize (m_reg_info.encoding,
                                                                                     m_reg_info.byte_size * 8);
            }
        }
    }
    return m_compiler_type;
}


so we currently take the encoding and byte size and make a built in type for it. We could allow a RegisterContext to manually create types using for a given target. 

We might allow RegisterInfo structs to have an extra field that is expression text that defines a register type something like:

const char *my_register_type = "typedef enum EnumType { eValueA, eValueB, eValueC}; struct reg_type { uint8_t a : 7, b:2, c:2; EnumType enum; }"

Then we could use the top level expression parser to parse the expression and extract the "reg_type" as a CompilerType from the source code. Then you could define any type you want for your register. Sean Callanan will be able to help with expression parser details if this sounds like something you would like to do. I can help with the rest of the plumbing. 

Greg Clayton


More information about the lldb-dev mailing list