summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/gdb-remote
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2013-10-17 01:10:23 +0000
committerGreg Clayton <gclayton@apple.com>2013-10-17 01:10:23 +0000
commit312bcbe8b4820d66feb17949622c7c5cb4a5fb49 (patch)
tree03d6c3b3547ae98654becccb3880d2f07e1492ca /lldb/source/Plugins/Process/gdb-remote
parent8afa543737c102d40302b26f72ea8124353d583e (diff)
downloadbcm5719-llvm-312bcbe8b4820d66feb17949622c7c5cb4a5fb49.tar.gz
bcm5719-llvm-312bcbe8b4820d66feb17949622c7c5cb4a5fb49.zip
<rdar://problem/14972424>
- Made the dynamic register context for the GDB remote plug-in inherit from the generic DynamicRegisterInfo to avoid code duplication - Finished up the target definition python setting stuff. - Added a new "slice" key/value pair that can specify that a register is part of another register: { 'name':'eax', 'set':0, 'bitsize':32, 'encoding':eEncodingUint, 'format':eFormatHex, 'slice': 'rax[31:0]' }, - Added a new "composite" key/value pair that can specify that a register is made up of two or more registers: { 'name':'d0', 'set':0, 'bitsize':64 , 'encoding':eEncodingIEEE754, 'format':eFormatFloat, 'composite': ['s1', 's0'] }, - Added a new "invalidate-regs" key/value pair for when a register is modified, it can invalidate other registers: { 'name':'cpsr', 'set':0, 'bitsize':32 , 'encoding':eEncodingUint, 'format':eFormatHex, 'invalidate-regs': ['r8', 'r9', 'r10', 'r11', 'r12', 'r13', 'r14', 'r15']}, This now completes the feature that allows a GDB remote target to completely describe itself. llvm-svn: 192858
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp130
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h159
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp23
3 files changed, 22 insertions, 290 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index 69dae055bb8..61c6a13d2d4 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -697,136 +697,6 @@ GDBRemoteRegisterContext::ConvertRegisterKindToRegisterNumber (uint32_t kind, ui
return m_reg_info.ConvertRegisterKindToRegisterNumber (kind, num);
}
-size_t
-GDBRemoteDynamicRegisterInfo::SetRegisterInfo (const lldb_private::PythonDictionary &dict)
-{
-#ifndef LLDB_DISABLE_PYTHON
- PythonList sets (dict.GetItemForKey("sets"));
- if (sets)
- {
- const uint32_t num_sets = sets.GetSize();
- for (uint32_t i=0; i<num_sets; ++i)
- {
- PythonString py_set_name(sets.GetItemAtIndex(i));
- ConstString set_name;
- if (py_set_name)
- set_name.SetCString(py_set_name.GetString());
- if (set_name)
- {
- RegisterSet new_set = { set_name.AsCString(), NULL, 0, NULL };
- m_sets.push_back (new_set);
- }
- else
- {
- Clear();
- return 0;
- }
- }
- m_set_reg_nums.resize(m_sets.size());
- }
- PythonList regs (dict.GetItemForKey("registers"));
- if (regs)
- {
- const uint32_t num_regs = regs.GetSize();
- PythonString name_pystr("name");
- PythonString altname_pystr("alt-name");
- PythonString bitsize_pystr("bitsize");
- PythonString offset_pystr("offset");
- PythonString encoding_pystr("encoding");
- PythonString format_pystr("format");
- PythonString set_pystr("set");
- PythonString gcc_pystr("gcc");
- PythonString gdb_pystr("gdb");
- PythonString dwarf_pystr("dwarf");
- PythonString generic_pystr("generic");
- for (uint32_t i=0; i<num_regs; ++i)
- {
- PythonDictionary reg_info_dict(regs.GetItemAtIndex(i));
- if (reg_info_dict)
- {
- // { 'name':'rcx' , 'bitsize' : 64, 'offset' : 16, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 2, 'dwarf' : 2, 'generic':'arg4', 'alt-name':'arg4', },
- RegisterInfo reg_info;
- bzero (&reg_info, sizeof(reg_info));
-
- reg_info.name = ConstString (reg_info_dict.GetItemForKeyAsString(name_pystr)).GetCString();
- if (reg_info.name == NULL)
- {
- Clear();
- return 0;
- }
-
- reg_info.alt_name = ConstString (reg_info_dict.GetItemForKeyAsString(altname_pystr)).GetCString();
-
- reg_info.byte_offset = reg_info_dict.GetItemForKeyAsInteger(offset_pystr, UINT32_MAX);
-
- if (reg_info.byte_offset == UINT32_MAX)
- {
- Clear();
- return 0;
- }
- reg_info.byte_size = reg_info_dict.GetItemForKeyAsInteger(bitsize_pystr, 0) / 8;
-
- if (reg_info.byte_size == 0)
- {
- Clear();
- return 0;
- }
-
- const char *format_cstr = reg_info_dict.GetItemForKeyAsString(format_pystr);
- if (format_cstr)
- {
- if (Args::StringToFormat(format_cstr, reg_info.format, NULL).Fail())
- {
- Clear();
- return 0;
- }
- }
- else
- {
- reg_info.format = (Format)reg_info_dict.GetItemForKeyAsInteger (format_pystr, eFormatHex);
- }
-
- const char *encoding_cstr = reg_info_dict.GetItemForKeyAsString(encoding_pystr);
- if (encoding_cstr)
- reg_info.encoding = Args::StringToEncoding (encoding_cstr, eEncodingUint);
- else
- reg_info.encoding = (Encoding)reg_info_dict.GetItemForKeyAsInteger (encoding_pystr, eEncodingUint);
-
- const int64_t set = reg_info_dict.GetItemForKeyAsInteger(set_pystr, -1);
- if (set >= m_sets.size())
- {
- Clear();
- return 0;
- }
-
- reg_info.kinds[lldb::eRegisterKindLLDB] = i;
- reg_info.kinds[lldb::eRegisterKindGDB] = reg_info_dict.GetItemForKeyAsInteger(gdb_pystr , LLDB_INVALID_REGNUM);
- reg_info.kinds[lldb::eRegisterKindGCC] = reg_info_dict.GetItemForKeyAsInteger(gcc_pystr , LLDB_INVALID_REGNUM);
- reg_info.kinds[lldb::eRegisterKindDWARF] = reg_info_dict.GetItemForKeyAsInteger(dwarf_pystr , LLDB_INVALID_REGNUM);
- const char *generic_cstr = reg_info_dict.GetItemForKeyAsString(generic_pystr);
- if (generic_cstr)
- reg_info.kinds[lldb::eRegisterKindGeneric] = Args::StringToGenericRegister (generic_cstr);
- else
- reg_info.kinds[lldb::eRegisterKindGeneric] = reg_info_dict.GetItemForKeyAsInteger(generic_pystr, LLDB_INVALID_REGNUM);
- const size_t end_reg_offset = reg_info.byte_offset + reg_info.byte_size;
- if (m_reg_data_byte_size < end_reg_offset)
- m_reg_data_byte_size = end_reg_offset;
-
- m_regs.push_back (reg_info);
- m_set_reg_nums[set].push_back(i);
-
- }
- else
- {
- Clear();
- return 0;
- }
- }
- Finalize ();
- }
-#endif
- return 0;
-}
void
GDBRemoteDynamicRegisterInfo::HardcodeARMRegisters(bool from_scratch)
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
index 319813f4005..7a49d693d44 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
@@ -21,23 +21,20 @@
#include "lldb/Core/ConstString.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Target/RegisterContext.h"
+#include "Plugins/Process/Utility/DynamicRegisterInfo.h"
+
#include "GDBRemoteCommunicationClient.h"
class ThreadGDBRemote;
class ProcessGDBRemote;
class StringExtractor;
-class GDBRemoteDynamicRegisterInfo
+class GDBRemoteDynamicRegisterInfo :
+ public DynamicRegisterInfo
{
public:
GDBRemoteDynamicRegisterInfo () :
- m_regs (),
- m_sets (),
- m_set_reg_nums (),
- m_reg_names (),
- m_reg_alt_names (),
- m_set_names (),
- m_reg_data_byte_size (0)
+ DynamicRegisterInfo()
{
}
@@ -46,154 +43,8 @@ public:
}
void
- AddRegister (lldb_private::RegisterInfo reg_info,
- lldb_private::ConstString &reg_name,
- lldb_private::ConstString &reg_alt_name,
- lldb_private::ConstString &set_name)
- {
- const uint32_t reg_num = (uint32_t)m_regs.size();
- m_reg_names.push_back (reg_name);
- m_reg_alt_names.push_back (reg_alt_name);
- reg_info.name = reg_name.AsCString();
- assert (reg_info.name);
- reg_info.alt_name = reg_alt_name.AsCString(NULL);
- uint32_t i;
- if (reg_info.value_regs)
- {
- for (i=0; reg_info.value_regs[i] != LLDB_INVALID_REGNUM; ++i)
- m_value_regs_map[reg_num].push_back(reg_info.value_regs[i]);
- m_value_regs_map[reg_num].push_back(LLDB_INVALID_REGNUM);
- reg_info.value_regs = m_value_regs_map[reg_num].data();
- }
- if (reg_info.invalidate_regs)
- {
- for (i=0; reg_info.invalidate_regs[i] != LLDB_INVALID_REGNUM; ++i)
- m_invalidate_regs_map[reg_num].push_back(reg_info.invalidate_regs[i]);
- m_invalidate_regs_map[reg_num].push_back(LLDB_INVALID_REGNUM);
- reg_info.invalidate_regs = m_invalidate_regs_map[reg_num].data();
- }
- m_regs.push_back (reg_info);
- uint32_t set = GetRegisterSetIndexByName (set_name);
- assert (set < m_sets.size());
- assert (set < m_set_reg_nums.size());
- assert (set < m_set_names.size());
- m_set_reg_nums[set].push_back(reg_num);
- size_t end_reg_offset = reg_info.byte_offset + reg_info.byte_size;
- if (m_reg_data_byte_size < end_reg_offset)
- m_reg_data_byte_size = end_reg_offset;
- }
-
- void
- Finalize ()
- {
- for (uint32_t set = 0; set < m_sets.size(); ++set)
- {
- assert (m_sets.size() == m_set_reg_nums.size());
- m_sets[set].num_registers = m_set_reg_nums[set].size();
- m_sets[set].registers = &m_set_reg_nums[set][0];
- }
- }
-
- size_t
- GetNumRegisters() const
- {
- return m_regs.size();
- }
-
- size_t
- GetNumRegisterSets() const
- {
- return m_sets.size();
- }
-
- size_t
- GetRegisterDataByteSize() const
- {
- return m_reg_data_byte_size;
- }
-
- const lldb_private::RegisterInfo *
- GetRegisterInfoAtIndex (uint32_t i) const
- {
- if (i < m_regs.size())
- return &m_regs[i];
- return NULL;
- }
-
- const lldb_private::RegisterSet *
- GetRegisterSet (uint32_t i) const
- {
- if (i < m_sets.size())
- return &m_sets[i];
- return NULL;
- }
-
- uint32_t
- GetRegisterSetIndexByName (lldb_private::ConstString &set_name)
- {
- name_collection::iterator pos, end = m_set_names.end();
- for (pos = m_set_names.begin(); pos != end; ++pos)
- {
- if (*pos == set_name)
- return static_cast<uint32_t>(std::distance (m_set_names.begin(), pos));
- }
-
- m_set_names.push_back(set_name);
- m_set_reg_nums.resize(m_set_reg_nums.size()+1);
- lldb_private::RegisterSet new_set = { set_name.AsCString(), NULL, 0, NULL };
- m_sets.push_back (new_set);
- return static_cast<uint32_t>(m_sets.size() - 1);
- }
-
- uint32_t
- ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num) const
- {
- reg_collection::const_iterator pos, end = m_regs.end();
- for (pos = m_regs.begin(); pos != end; ++pos)
- {
- if (pos->kinds[kind] == num)
- return static_cast<uint32_t>(std::distance (m_regs.begin(), pos));
- }
-
- return LLDB_INVALID_REGNUM;
- }
- void
- Clear()
- {
- m_regs.clear();
- m_sets.clear();
- m_set_reg_nums.clear();
- m_reg_names.clear();
- m_reg_alt_names.clear();
- m_set_names.clear();
- }
-
- void
HardcodeARMRegisters(bool from_scratch);
- size_t
- SetRegisterInfo (const lldb_private::PythonDictionary &dict);
-
-protected:
- //------------------------------------------------------------------
- // Classes that inherit from GDBRemoteRegisterContext can see and modify these
- //------------------------------------------------------------------
- typedef std::vector <lldb_private::RegisterInfo> reg_collection;
- typedef std::vector <lldb_private::RegisterSet> set_collection;
- typedef std::vector <uint32_t> reg_num_collection;
- typedef std::vector <reg_num_collection> set_reg_num_collection;
- typedef std::vector <lldb_private::ConstString> name_collection;
- typedef std::map<uint32_t, reg_num_collection> reg_to_regs_map;
-
- reg_collection m_regs;
- set_collection m_sets;
- set_reg_num_collection m_set_reg_nums;
- name_collection m_reg_names;
- name_collection m_reg_alt_names;
- name_collection m_set_names;
- reg_to_regs_map m_value_regs_map;
- reg_to_regs_map m_invalidate_regs_map;
- size_t m_reg_data_byte_size; // The number of bytes required to store all registers
};
class GDBRemoteRegisterContext : public lldb_private::RegisterContext
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index e44d7a355f3..1b8791c6e74 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -334,7 +334,18 @@ ProcessGDBRemote::ParsePythonTargetDefinition(const FileSpec &target_definition_
if (target_dict)
{
- if (m_register_info.SetRegisterInfo (target_dict) > 0)
+ PythonDictionary host_info_dict (target_dict.GetItemForKey("host-info"));
+ if (host_info_dict)
+ {
+ ArchSpec host_arch (host_info_dict.GetItemForKeyAsString(PythonString("triple")));
+
+ if (!host_arch.IsCompatibleMatch(GetTarget().GetArchitecture()))
+ {
+ GetTarget().SetArchitecture(host_arch);
+ }
+
+ }
+ if (m_register_info.SetRegisterInfo (target_dict, GetTarget().GetArchitecture().GetByteOrder()) > 0)
{
return true;
}
@@ -522,12 +533,12 @@ ProcessGDBRemote::BuildDynamicRegisterInfo (bool force)
if (reg_num == 0)
{
FileSpec target_definition_fspec = GetGlobalPluginProperties()->GetTargetDefinitionFile ();
-
- // See if we can get register definitions from a python file
- if (ParsePythonTargetDefinition (target_definition_fspec))
+
+ if (target_definition_fspec)
{
- m_register_info.Finalize ();
- return;
+ // See if we can get register definitions from a python file
+ if (ParsePythonTargetDefinition (target_definition_fspec))
+ return;
}
}
OpenPOWER on IntegriCloud