summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Commands/CommandObjectMemory.cpp18
-rw-r--r--lldb/source/Core/ArchSpec.cpp23
-rw-r--r--lldb/source/Core/DataExtractor.cpp26
-rw-r--r--lldb/source/Core/Section.cpp14
-rw-r--r--lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp46
-rw-r--r--lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp12
-rw-r--r--lldb/source/Symbol/ObjectFile.cpp3
7 files changed, 102 insertions, 40 deletions
diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp
index 486a5eb912a..6c06ec83183 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -614,7 +614,16 @@ protected:
}
size_t item_count = m_format_options.GetCountValue().GetCurrentValue();
- size_t item_byte_size = m_format_options.GetByteSizeValue().GetCurrentValue();
+
+ // TODO For non-8-bit byte addressable architectures this needs to be
+ // revisited to fully support all lldb's range of formatting options.
+ // Furthermore code memory reads (for those architectures) will not
+ // be correctly formatted even w/o formatting options.
+ size_t item_byte_size =
+ target->GetArchitecture().GetDataByteSize() > 1 ?
+ target->GetArchitecture().GetDataByteSize() :
+ m_format_options.GetByteSizeValue().GetCurrentValue();
+
const size_t num_per_line = m_memory_options.m_num_per_line.GetCurrentValue();
if (total_byte_size == 0)
@@ -661,7 +670,7 @@ protected:
total_byte_size = end_addr - addr;
item_count = total_byte_size / item_byte_size;
}
-
+
uint32_t max_unforced_size = target->GetMaximumMemReadSize();
if (total_byte_size > max_unforced_size && !m_memory_options.m_force)
@@ -858,7 +867,8 @@ protected:
result.SetStatus(eReturnStatusSuccessFinishResult);
DataExtractor data (data_sp,
target->GetArchitecture().GetByteOrder(),
- target->GetArchitecture().GetAddressByteSize());
+ target->GetArchitecture().GetAddressByteSize(),
+ target->GetArchitecture().GetDataByteSize());
Format format = m_format_options.GetFormat();
if ( ( (format == eFormatChar) || (format == eFormatCharPrintable) )
@@ -892,7 +902,7 @@ protected:
format,
item_byte_size,
item_count,
- num_per_line,
+ num_per_line / target->GetArchitecture().GetDataByteSize(),
addr,
0,
0,
diff --git a/lldb/source/Core/ArchSpec.cpp b/lldb/source/Core/ArchSpec.cpp
index 5f010f06640..7750fc546e9 100644
--- a/lldb/source/Core/ArchSpec.cpp
+++ b/lldb/source/Core/ArchSpec.cpp
@@ -118,7 +118,6 @@ static const CoreDefinition g_core_definitions[] =
{ eByteOrderLittle, 4, 4, 4 , llvm::Triple::UnknownArch , ArchSpec::eCore_uknownMach32 , "unknown-mach-32" },
{ eByteOrderLittle, 8, 4, 4 , llvm::Triple::UnknownArch , ArchSpec::eCore_uknownMach64 , "unknown-mach-64" },
- { eByteOrderLittle, 4, 1, 1 , llvm::Triple::kalimba , ArchSpec::eCore_kalimba , "kalimba" },
{ eByteOrderBig , 4, 1, 1 , llvm::Triple::kalimba , ArchSpec::eCore_kalimba3 , "kalimba3" },
{ eByteOrderLittle, 4, 1, 1 , llvm::Triple::kalimba , ArchSpec::eCore_kalimba4 , "kalimba4" },
{ eByteOrderLittle, 4, 1, 1 , llvm::Triple::kalimba , ArchSpec::eCore_kalimba5 , "kalimba5" }
@@ -264,11 +263,9 @@ static const ArchDefinitionEntry g_elf_arch_entries[] =
{ ArchSpec::eCore_x86_64_x86_64 , llvm::ELF::EM_X86_64 , LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // AMD64
{ ArchSpec::eCore_mips64 , llvm::ELF::EM_MIPS , LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // MIPS
{ ArchSpec::eCore_hexagon_generic , llvm::ELF::EM_HEXAGON, LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // HEXAGON
- { ArchSpec::eCore_kalimba , llvm::ELF::EM_CSR_KALIMBA, LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // KALIMBA
- { ArchSpec::eCore_kalimba3 , llvm::ELF::EM_CSR_KALIMBA, 3, 0xFFFFFFFFu, 0xFFFFFFFFu }, // KALIMBA
- { ArchSpec::eCore_kalimba4 , llvm::ELF::EM_CSR_KALIMBA, 4, 0xFFFFFFFFu, 0xFFFFFFFFu }, // KALIMBA
- { ArchSpec::eCore_kalimba5 , llvm::ELF::EM_CSR_KALIMBA, 5, 0xFFFFFFFFu, 0xFFFFFFFFu } // KALIMBA
-
+ { ArchSpec::eCore_kalimba3 , llvm::ELF::EM_CSR_KALIMBA, llvm::Triple::KalimbaSubArch_v3, 0xFFFFFFFFu, 0xFFFFFFFFu }, // KALIMBA
+ { ArchSpec::eCore_kalimba4 , llvm::ELF::EM_CSR_KALIMBA, llvm::Triple::KalimbaSubArch_v4, 0xFFFFFFFFu, 0xFFFFFFFFu }, // KALIMBA
+ { ArchSpec::eCore_kalimba5 , llvm::ELF::EM_CSR_KALIMBA, llvm::Triple::KalimbaSubArch_v5, 0xFFFFFFFFu, 0xFFFFFFFFu } // KALIMBA
};
static const ArchDefinition g_elf_arch_def = {
@@ -503,11 +500,11 @@ ArchSpec::GetDataByteSize () const
switch (m_core)
{
case eCore_kalimba3:
- return 3;
+ return 4;
case eCore_kalimba4:
return 1;
case eCore_kalimba5:
- return 3;
+ return 4;
default:
return 1;
}
@@ -1036,16 +1033,6 @@ cores_match (const ArchSpec::Core core1, const ArchSpec::Core core2, bool try_in
}
break;
- case ArchSpec::eCore_kalimba:
- case ArchSpec::eCore_kalimba3:
- case ArchSpec::eCore_kalimba4:
- case ArchSpec::eCore_kalimba5:
- if (core2 >= ArchSpec::kCore_kalimba_first && core2 <= ArchSpec::kCore_kalimba_last)
- {
- return true;
- }
- break;
-
case ArchSpec::eCore_arm_armv8:
if (!enforce_exact_match)
{
diff --git a/lldb/source/Core/DataExtractor.cpp b/lldb/source/Core/DataExtractor.cpp
index a0958bd6b1c..27dccfe5cf2 100644
--- a/lldb/source/Core/DataExtractor.cpp
+++ b/lldb/source/Core/DataExtractor.cpp
@@ -132,7 +132,8 @@ DataExtractor::DataExtractor () :
m_end (NULL),
m_byte_order(lldb::endian::InlHostByteOrder()),
m_addr_size (4),
- m_data_sp ()
+ m_data_sp (),
+ m_target_byte_size(1)
{
}
@@ -140,12 +141,13 @@ DataExtractor::DataExtractor () :
// This constructor allows us to use data that is owned by someone else.
// The data must stay around as long as this object is valid.
//----------------------------------------------------------------------
-DataExtractor::DataExtractor (const void* data, offset_t length, ByteOrder endian, uint32_t addr_size) :
+DataExtractor::DataExtractor (const void* data, offset_t length, ByteOrder endian, uint32_t addr_size, uint32_t target_byte_size/*=1*/) :
m_start ((uint8_t*)data),
m_end ((uint8_t*)data + length),
m_byte_order(endian),
m_addr_size (addr_size),
- m_data_sp ()
+ m_data_sp (),
+ m_target_byte_size(target_byte_size)
{
}
@@ -156,12 +158,13 @@ DataExtractor::DataExtractor (const void* data, offset_t length, ByteOrder endia
// as long as any DataExtractor objects exist that have a reference to
// this data.
//----------------------------------------------------------------------
-DataExtractor::DataExtractor (const DataBufferSP& data_sp, ByteOrder endian, uint32_t addr_size) :
+DataExtractor::DataExtractor (const DataBufferSP& data_sp, ByteOrder endian, uint32_t addr_size, uint32_t target_byte_size/*=1*/) :
m_start (NULL),
m_end (NULL),
m_byte_order(endian),
m_addr_size (addr_size),
- m_data_sp ()
+ m_data_sp (),
+ m_target_byte_size(target_byte_size)
{
SetData (data_sp);
}
@@ -173,12 +176,13 @@ DataExtractor::DataExtractor (const DataBufferSP& data_sp, ByteOrder endian, uin
// as any object contains a reference to that data. The endian
// swap and address size settings are copied from "data".
//----------------------------------------------------------------------
-DataExtractor::DataExtractor (const DataExtractor& data, offset_t offset, offset_t length) :
+DataExtractor::DataExtractor (const DataExtractor& data, offset_t offset, offset_t length, uint32_t target_byte_size/*=1*/) :
m_start(NULL),
m_end(NULL),
m_byte_order(data.m_byte_order),
m_addr_size(data.m_addr_size),
- m_data_sp()
+ m_data_sp(),
+ m_target_byte_size(target_byte_size)
{
if (data.ValidOffset(offset))
{
@@ -194,7 +198,8 @@ DataExtractor::DataExtractor (const DataExtractor& rhs) :
m_end (rhs.m_end),
m_byte_order (rhs.m_byte_order),
m_addr_size (rhs.m_addr_size),
- m_data_sp (rhs.m_data_sp)
+ m_data_sp (rhs.m_data_sp),
+ m_target_byte_size(rhs.m_target_byte_size)
{
}
@@ -1480,7 +1485,9 @@ DataExtractor::Dump (Stream *s,
s->EOL();
}
if (base_addr != LLDB_INVALID_ADDRESS)
- s->Printf ("0x%8.8" PRIx64 ": ", (uint64_t)(base_addr + (offset - start_offset)));
+ s->Printf ("0x%8.8" PRIx64 ": ",
+ (uint64_t)(base_addr + (offset - start_offset)/m_target_byte_size ));
+
line_start_offset = offset;
}
else
@@ -1535,6 +1542,7 @@ DataExtractor::Dump (Stream *s,
{
s->Printf ("%2.2x", GetU8(&offset));
}
+
// Put an extra space between the groups of bytes if more than one
// is being dumped in a group (item_byte_size is more than 1).
if (item_byte_size > 1)
diff --git a/lldb/source/Core/Section.cpp b/lldb/source/Core/Section.cpp
index 3267c186622..ea33a62b775 100644
--- a/lldb/source/Core/Section.cpp
+++ b/lldb/source/Core/Section.cpp
@@ -28,7 +28,8 @@ Section::Section (const ModuleSP &module_sp,
lldb::offset_t file_offset,
lldb::offset_t file_size,
uint32_t log2align,
- uint32_t flags) :
+ uint32_t flags,
+ uint32_t target_byte_size/*=1*/) :
ModuleChild (module_sp),
UserID (sect_id),
Flags (flags),
@@ -44,7 +45,8 @@ Section::Section (const ModuleSP &module_sp,
m_children (),
m_fake (false),
m_encrypted (false),
- m_thread_specific (false)
+ m_thread_specific (false),
+ m_target_byte_size(target_byte_size)
{
// printf ("Section::Section(%p): module=%p, sect_id = 0x%16.16" PRIx64 ", addr=[0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), file [0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), flags = 0x%8.8x, name = %s\n",
// this, module_sp.get(), sect_id, file_addr, file_addr + byte_size, file_offset, file_offset + file_size, flags, name.GetCString());
@@ -61,7 +63,8 @@ Section::Section (const lldb::SectionSP &parent_section_sp,
lldb::offset_t file_offset,
lldb::offset_t file_size,
uint32_t log2align,
- uint32_t flags) :
+ uint32_t flags,
+ uint32_t target_byte_size/*=1*/) :
ModuleChild (module_sp),
UserID (sect_id),
Flags (flags),
@@ -77,7 +80,8 @@ Section::Section (const lldb::SectionSP &parent_section_sp,
m_children (),
m_fake (false),
m_encrypted (false),
- m_thread_specific (false)
+ m_thread_specific (false),
+ m_target_byte_size(target_byte_size)
{
// printf ("Section::Section(%p): module=%p, sect_id = 0x%16.16" PRIx64 ", addr=[0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), file [0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), flags = 0x%8.8x, name = %s.%s\n",
// this, module_sp.get(), sect_id, file_addr, file_addr + byte_size, file_offset, file_offset + file_size, flags, parent_section_sp->GetName().GetCString(), name.GetCString());
@@ -186,7 +190,7 @@ Section::ContainsFileAddress (addr_t vm_addr) const
{
if (file_addr <= vm_addr)
{
- const addr_t offset = vm_addr - file_addr;
+ const addr_t offset = (vm_addr - file_addr) * m_target_byte_size;
return offset < GetByteSize();
}
}
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index d075312c84c..fa11751b7aa 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -267,10 +267,14 @@ kalimbaVariantFromElfFlags(const elf::elf_word e_flags)
{
// TODO(mg11) Support more variants
case 10:
- kal_arch_variant = 3;
+ kal_arch_variant = llvm::Triple::KalimbaSubArch_v3;
break;
case 14:
- kal_arch_variant = 4;
+ kal_arch_variant = llvm::Triple::KalimbaSubArch_v4;
+ break;
+ case 17:
+ case 20:
+ kal_arch_variant = llvm::Triple::KalimbaSubArch_v5;
break;
default:
break;
@@ -287,6 +291,27 @@ subTypeFromElfHeader(const elf::ELFHeader& header)
LLDB_INVALID_CPUTYPE;
}
+//! brief kalimbaSectionType
+//! The kalimba toolchain identifies a code section as being
+//! one with the SHT_PROGBITS set in the section sh_type and the top
+//! bit in the 32-bit address field set.
+static lldb::SectionType
+kalimbaSectionType(
+ const elf::ELFHeader& header,
+ const elf::ELFSectionHeader& sect_hdr)
+{
+ if (
+ llvm::ELF::EM_CSR_KALIMBA != header.e_machine ||
+ llvm::ELF::SHT_PROGBITS != sect_hdr.sh_type)
+ {
+ return eSectionTypeOther;
+ }
+
+ const lldb::addr_t KAL_CODE_BIT = 1 << 31;
+ return KAL_CODE_BIT & sect_hdr.sh_addr ?
+ eSectionTypeCode : eSectionTypeData;
+}
+
// Arbitrary constant used as UUID prefix for core files.
const uint32_t
ObjectFileELF::g_core_uuid_magic(0xE210C);
@@ -1592,6 +1617,20 @@ ObjectFileELF::CreateSections(SectionList &unified_section_list)
break;
}
+ if (eSectionTypeOther == sect_type)
+ {
+ // the kalimba toolchain assumes that ELF section names are free-form. It does
+ // supports linkscripts which (can) give rise to various arbitarily named
+ // sections being "Code" or "Data".
+ sect_type = kalimbaSectionType(m_header, header);
+ }
+
+ const uint32_t target_bytes_size =
+ eSectionTypeData == sect_type ?
+ m_arch_spec.GetDataByteSize() :
+ eSectionTypeCode == sect_type ?
+ m_arch_spec.GetCodeByteSize() : 1;
+
elf::elf_xword log2align = (header.sh_addralign==0)
? 0
: llvm::Log2_64(header.sh_addralign);
@@ -1605,7 +1644,8 @@ ObjectFileELF::CreateSections(SectionList &unified_section_list)
header.sh_offset, // Offset of this section in the file.
file_size, // Size of the section as found in the file.
log2align, // Alignment of the section
- header.sh_flags)); // Flags for this section.
+ header.sh_flags, // Flags for this section.
+ target_bytes_size));// Number of host bytes per target byte
if (is_thread_specific)
section_sp->SetIsThreadSpecific (is_thread_specific);
diff --git a/lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp b/lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp
index 068b1b10e72..fa3d8e4a3e1 100644
--- a/lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp
+++ b/lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp
@@ -250,7 +250,17 @@ PlatformKalimba::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
{
if (idx == 0)
{
- arch = ArchSpec("kalimba-csr-unknown");
+ arch = ArchSpec("kalimba3-csr-unknown");
+ return true;
+ }
+ if (idx == 1)
+ {
+ arch = ArchSpec("kalimba4-csr-unknown");
+ return true;
+ }
+ if (idx == 2)
+ {
+ arch = ArchSpec("kalimba5-csr-unknown");
return true;
}
return false;
diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp
index 11b54007120..0e24a2e3549 100644
--- a/lldb/source/Symbol/ObjectFile.cpp
+++ b/lldb/source/Symbol/ObjectFile.cpp
@@ -458,6 +458,9 @@ ObjectFile::CopyData (lldb::offset_t offset, size_t length, void *dst) const
size_t
ObjectFile::ReadSectionData (const Section *section, lldb::offset_t section_offset, void *dst, size_t dst_len) const
{
+ assert(section);
+ section_offset *= section->GetTargetByteSize();
+
// If some other objectfile owns this data, pass this to them.
if (section->GetObjectFile() != this)
return section->GetObjectFile()->ReadSectionData (section, section_offset, dst, dst_len);
OpenPOWER on IntegriCloud