MCPcopy Create free account
hub / github.com/Vector35/debugger / ReadAllRegisters

Method ReadAllRegisters

core/adapters/lldbadapter.cpp:661–705  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

659
660
661std::unordered_map<std::string, DebugRegister> LldbAdapter::ReadAllRegisters()
662{
663 std::unordered_map<std::string, DebugRegister> result;
664
665 SBThread thread = m_process.GetSelectedThread();
666 if (!thread.IsValid())
667 return result;
668
669 size_t frameCount = thread.GetNumFrames();
670 if (frameCount == 0)
671 return result;
672
673 SBFrame frame = thread.GetFrameAtIndex(0);
674 if (!frame.IsValid())
675 return result;
676
677 size_t regIndex = 0;
678 SBValueList regGroups = frame.GetRegisters();
679 size_t numGroups = regGroups.GetSize();
680 for (size_t i = 0; i < numGroups; i++)
681 {
682 SBValue regGroupInfo = regGroups.GetValueAtIndex(i);
683 if (!regGroupInfo.IsValid())
684 continue;
685
686 size_t numRegs = regGroupInfo.GetNumChildren();
687 for (size_t j = 0; j < numRegs; j++)
688 {
689 SBValue reg = regGroupInfo.GetChildAtIndex(j);
690 // TODO: register width and internal index
691 // Right now we basically rely on LLDB to always return the registers in the same order
692
693 // SBValue::GetName() sometimes returns NULL on the second call. So we must get its value only once and save
694 // it. Calling it twice causes problem.
695 const char* regNameStr = reg.GetName();
696 if (reg.IsValid() && (regNameStr != nullptr))
697 {
698 std::string regName(regNameStr);
699 if (!regName.empty())
700 result[regName] = DebugRegister(regName, reg.GetValueAsUnsigned(), reg.GetByteSize() * 8, regIndex++);
701 }
702 }
703 }
704 return result;
705}
706
707
708DebugRegister LldbAdapter::ReadRegister(const std::string& name)

Callers 1

UpdateMethod · 0.45

Calls 3

GetNameMethod · 0.80
DebugRegisterClass · 0.50
GetRegistersMethod · 0.45

Tested by

no test coverage detected