llvm-project/lldb/source/Core
Ulrich Weigand 461bd680c3 Handle bit fields on big-endian systems correctly
Currently, the DataExtractor::GetMaxU64Bitfield and GetMaxS64Bitfield
routines assume the incoming "bitfield_bit_offset" parameter uses
little-endian bit numbering, i.e. a bitfield_bit_offset 0 refers to
a bitfield whose least-significant bit coincides with the least-
significant bit of the surrounding integer.

On many big-endian systems, however, the big-endian bit numbering
is used for bit fields.  Here, a bitfield_bit_offset 0 refers to
a bitfield whose most-significant bit conincides with the most-
significant bit of the surrounding integer.

Now, in principle LLDB could arbitrarily choose which semantics of
bitfield_bit_offset to use.  However, there are two problems with
the current approach:

- When parsing DWARF, LLDB decodes bit offsets in little-endian
  bit numbering on LE systems, but in big-endian bit numbering
  on BE systems.  Passing those offsets later on into the
  DataExtractor routines gives incorrect results on BE.

- In the interim, LLDB's type layer combines byte and bit offsets
  into a single number.  I.e. instead of recording bitfields by
  specifying the byte offset and byte size of the surrounding
  integer *plus* the bit offset of the bit field within that field,
  it simply records a single bit offset number.

  Now, note that converting from byte offset + bit offset to a
  single offset value and back is well-defined if we either use
  little-endian byte order *and* little-endian bit numbering,
  or use big-endian byte order *and* big-endian bit numbering.
  Any other combination will yield incorrect results.

Therefore, the simplest approach would seem to be to always use
the bit numbering that matches the system byte order.  This makes
storing a single bit offset valid, and makes the existing DWARF
code correct.  The only place to fix is to teach DataExtractor
to use big-endian bit numbering on big endian systems.

However, there is only additional caveat: we also get bit offsets
from LLDB synthetic bitfields.  While the exact semantics of those
doesn't seem to be well-defined, from test cases it appears that
the intent was for the user-provided synthetic bitfield offset to
always use little-endian bit numbering.  Therefore, on a big-endian
system we now have to convert those to big-endian bit numbering
to remain consistent.

Differential Revision: http://reviews.llvm.org/D18982

llvm-svn: 266312
2016-04-14 14:32:57 +00:00
..
Address.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes. 2016-03-02 01:09:03 +00:00
AddressRange.cpp Add -Wimplicit-fallthrough command line option to clang in 2016-02-16 04:14:33 +00:00
AddressResolver.cpp Move lldb-log.cpp to core/Logging.cpp 2015-03-18 18:20:42 +00:00
AddressResolverFileLine.cpp Move lldb-log.cpp to core/Logging.cpp 2015-03-18 18:20:42 +00:00
AddressResolverName.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes. 2016-03-02 01:09:03 +00:00
ArchSpec.cpp Support Linux on SystemZ as platform 2016-04-14 14:28:34 +00:00
Baton.cpp
Broadcaster.cpp Fix log in Broadcaster causing a crash 2016-03-08 13:33:14 +00:00
CMakeLists.txt [cmake] Remove LLVM_NO_RTTI. 2015-09-03 08:46:55 +00:00
Communication.cpp Change over the broadcaster/listener process to hold shared or weak pointers 2016-03-07 21:50:25 +00:00
Connection.cpp Create a ConnectionGenericFile class for Windows. 2014-10-06 21:23:09 +00:00
ConnectionMachPort.cpp I make no claims that Mach ports work, but at least we should check the right thing 2015-06-03 22:35:55 +00:00
ConnectionSharedMemory.cpp Unicode support on Win32. 2016-03-22 17:58:09 +00:00
ConstString.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes. 2016-03-10 23:57:12 +00:00
CxaDemangle.cpp Shuffle an #undef to avoid a warning on FreeBSD 2016-03-14 20:39:08 +00:00
DataBufferHeap.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes. 2016-03-03 00:51:40 +00:00
DataBufferMemoryMap.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes. 2016-03-03 00:51:40 +00:00
DataEncoder.cpp Remove unnecessary <limits> includes. 2016-03-15 21:11:02 +00:00
DataExtractor.cpp Handle bit fields on big-endian systems correctly 2016-04-14 14:32:57 +00:00
Debugger.cpp Change over the broadcaster/listener process to hold shared or weak pointers 2016-03-07 21:50:25 +00:00
Disassembler.cpp Consolidate the knowledge of what arm cores are always executing 2016-04-05 05:01:30 +00:00
DynamicLoader.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes. 2016-03-03 00:51:40 +00:00
EmulateInstruction.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes. 2016-03-03 00:51:40 +00:00
Error.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes. 2016-03-10 23:57:12 +00:00
Event.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes. 2016-03-10 23:57:12 +00:00
FastDemangle.cpp Fix all of the unannotated switch cases to annotate the fall through or do the right thing and break. 2016-02-26 01:20:20 +00:00
FileLineResolver.cpp Move lldb-log.cpp to core/Logging.cpp 2015-03-18 18:20:42 +00:00
FileSpecList.cpp Remove unnecessary <limits> includes. 2016-03-15 21:11:02 +00:00
FormatEntity.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes. 2016-03-10 23:57:12 +00:00
History.cpp
IOHandler.cpp Fix for missing prompt on Windows 2016-03-24 20:35:03 +00:00
Listener.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes. 2016-03-10 23:57:12 +00:00
Log.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes. 2016-03-10 23:57:12 +00:00
Logging.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes. 2016-03-11 21:55:47 +00:00
Mangled.cpp Don't demangle a name when Mangled::GetName() is called with ePreferMangled. Only demangle if this isn't the the value for the "preference" argument indicating the user wants the demangled name. This will stop a lot of symbols from being demangled when parsing the symbol table in ObjectFileMachO. 2015-12-17 01:00:50 +00:00
Module.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes. 2016-03-11 20:20:38 +00:00
ModuleChild.cpp
ModuleList.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes. 2016-03-11 20:20:38 +00:00
Opcode.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes. 2016-03-11 21:55:47 +00:00
PluginManager.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes. 2016-03-11 21:55:47 +00:00
RegisterValue.cpp Make Scalar::GetBytes and RegisterValue::GetBytes const 2016-04-14 14:31:08 +00:00
RegularExpression.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes. 2016-03-12 00:31:13 +00:00
Scalar.cpp Fix usage of APInt.getRawData for big-endian systems 2016-04-14 14:32:01 +00:00
SearchFilter.cpp Remove unnecessary <limits> includes. 2016-03-15 21:11:02 +00:00
Section.cpp Remove unnecessary <limits> includes. 2016-03-15 21:11:02 +00:00
SourceManager.cpp Silence some MSVC warnings. 2015-08-26 23:55:14 +00:00
State.cpp
Stream.cpp Make lldb::endian::InlHostByteOrder() private. 2015-11-07 04:40:13 +00:00
StreamAsynchronousIO.cpp Fix warnings detected by -Wpessimizing-move 2015-07-28 09:18:32 +00:00
StreamCallback.cpp
StreamFile.cpp Support for truncate/append on log files 2015-03-20 09:43:20 +00:00
StreamGDBRemote.cpp merge lldb-platform-work branch (and assorted fixes) into trunk 2013-08-26 23:57:52 +00:00
StreamString.cpp Silence -Wqual-cast warnings from GCC 5.2 2015-10-18 19:34:38 +00:00
StringList.cpp Remove duplicate header added in r256927 2016-01-07 14:34:52 +00:00
StructuredData.cpp Make the "lldb/Utility/JSON.h" able to parse JSON into tokens with the new JSONParser class. 2015-07-06 23:40:40 +00:00
Timer.cpp Get rid of a global constructor that was causing a warning on MacOSX and make the Timer safe to use after the main threads global destructor chain is called. 2016-03-24 21:46:47 +00:00
UUID.cpp Add Utility/ModuleCache class and integrate it with PlatformGDBRemoteServer - in order to allow modules caching from remote targets. 2015-03-10 01:15:28 +00:00
UserID.cpp Implemented a types.py module that allows types to be inspected for padding. 2013-06-19 21:50:28 +00:00
UserSettingsController.cpp Don't #include "lldb-python.h" from anywhere. 2015-05-29 17:41:47 +00:00
VMRange.cpp
Value.cpp Certain hardware architectures have registers of 256 bits in size 2016-03-10 00:14:29 +00:00
ValueObject.cpp Handle bit fields on big-endian systems correctly 2016-04-14 14:32:57 +00:00
ValueObjectCast.cpp [SBValue] Add a method GetNumChildren(uint32_t max) 2015-10-21 19:28:08 +00:00
ValueObjectChild.cpp More rework of the updating logic for ValueObjectChild. Still just refactoring with no feature change 2015-11-09 23:59:53 +00:00
ValueObjectConstResult.cpp Add an LLDB data formatter for single-element NSArray and NSDictionary Cocoa containers 2016-02-29 21:06:50 +00:00
ValueObjectConstResultCast.cpp Add an LLDB data formatter for single-element NSArray and NSDictionary Cocoa containers 2016-02-29 21:06:50 +00:00
ValueObjectConstResultChild.cpp Add an LLDB data formatter for single-element NSArray and NSDictionary Cocoa containers 2016-02-29 21:06:50 +00:00
ValueObjectConstResultImpl.cpp Add an LLDB data formatter for single-element NSArray and NSDictionary Cocoa containers 2016-02-29 21:06:50 +00:00
ValueObjectDynamicValue.cpp Add a way for source languages to "mark" ValueObjects with language-specific flags 2015-11-09 19:27:34 +00:00
ValueObjectList.cpp
ValueObjectMemory.cpp [SBValue] Add a method GetNumChildren(uint32_t max) 2015-10-21 19:28:08 +00:00
ValueObjectRegister.cpp [SBValue] Add a method GetNumChildren(uint32_t max) 2015-10-21 19:28:08 +00:00
ValueObjectSyntheticFilter.cpp Add a way for source languages to "mark" ValueObjects with language-specific flags 2015-11-09 19:27:34 +00:00
ValueObjectVariable.cpp Add support for DW_OP_push_object_address in dwarf expressions 2016-02-26 14:21:10 +00:00