summaryrefslogtreecommitdiff
path: root/lldb/source/Core/DumpRegisterValue.cpp
AgeCommit message (Collapse)Author
2024-10-24[lldb] Move ValueObject into its own library (NFC) (#113393)Jonas Devlieghere
ValueObject is part of lldbCore for historical reasons, but conceptually it deserves to be its own library. This does introduce a (link-time) circular dependency between lldbCore and lldbValueObject, which is unfortunate but probably unavoidable because so many things in LLDB rely on ValueObject. We already have cycles and these libraries are never built as dylibs so while this doesn't improve the situation, it also doesn't make things worse. The header includes were updated with the following command: ``` find . -type f -exec sed -i.bak "s%include \"lldb/Core/ValueObject%include \"lldb/ValueObject/ValueObject%" '{}' \; ```
2024-06-20Convert ValueObject::Dump() to return llvm::Error() (NFCish)Adrian Prantl
This change by itself has no measurable effect on the LLDB testsuite. I'm making it in preparation for threading through more errors in the Swift language plugin.
2023-04-18[lldb] Use llvm::byteswap in DumpRegisterValueDavid Spickett
7978abd5aef1ba84d7a1cefbc3443245acff2c48 fixed a build issue on MSVC with some code I previously added, by adding some ifdefs. Now I realise that I should have been using llvm::byteswap in the first place, which does exactly that.
2023-04-17[lldb] fix build issue on MSVC because of missing byte-swap builtinsAshay Rane
The `__builtin_bswap{32,64}()` builtins (introduced in commit e07a421d) are missing from MSVC, which causes build errors when compiling LLDB on Windows (tested with MSVC 19.34.31943.0). This patch replaces the builtins with either MSVC's `_byteswap_u{long,64}()` or the original builtins, or the `bswap_{32,64}()` functions from byteswap.h, depending on which ones are available. Reviewed By: bulbazord Differential Revision: https://reviews.llvm.org/D148541
2023-04-17[lldb] Change some pointers to refs in register printing codeDavid Spickett
No one was passing nullptr for these. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D148228
2023-04-13[lldb] Fix library layering after D145574Fangrui Song
2023-04-13[lldb] Show register fields using bitfield struct typesDavid Spickett
This change uses the information from target.xml sent by the GDB stub to produce C types that we can use to print register fields. lldb-server *does not* produce this information yet. This will only work with GDB stubs that do. gdbserver or qemu are 2 I know of. Testing is added that uses a mocked lldb-server. ``` (lldb) register read cpsr x0 fpcr fpsr x1 cpsr = 0x60001000 = (N = 0, Z = 1, C = 1, V = 0, TCO = 0, DIT = 0, UAO = 0, PAN = 0, SS = 0, IL = 0, SSBS = 1, BTYPE = 0, D = 0, A = 0, I = 0, F = 0, nRW = 0, EL = 0, SP = 0) ``` Only "register read" will display fields, and only when we are not printing a register block. For example, cpsr is a 32 bit register. Using the target's scratch type system we construct a type: ``` struct __attribute__((__packed__)) cpsr { uint32_t N : 1; uint32_t Z : 1; ... uint32_t EL : 2; uint32_t SP : 1; }; ``` If this register had unallocated bits in it, those would have been filled in by RegisterFlags as anonymous fields. A new option "SetChildPrintingDecider" is added so we can disable printing those. Important things about this type: * It is packed so that sizeof(struct cpsr) == sizeof(the real register). (this will hold for all flags types we create) * Each field has the same storage type, which is the same as the type of the raw register value. This prevents fields being spilt over into more storage units, as is allowed by most ABIs. * Each bitfield size matches that of its register field. * The most significant field is first. The last point is required because the most significant bit (MSB) being on the left/top of a print out matches what you'd expect to see in an architecture manual. In addition, having lldb print a different field order on big/little endian hosts is not acceptable. As a consequence, if the target is little endian we have to reverse the order of the fields in the value. The value of each field remains the same. For example 0b01 doesn't become 0b10, it just shifts up or down. This is needed because clang's type system assumes that for a struct like the one above, the least significant bit (LSB) will be first for a little endian target. We need the MSB to be first. Finally, if lldb's host is a different endian to the target we have to byte swap the host endian value to match the endian of the target's typesystem. | Host Endian | Target Endian | Field Order Swap | Byte Order Swap | |-------------|---------------|------------------|-----------------| | Little | Little | Yes | No | | Big | Little | Yes | Yes | | Little | Big | No | Yes | | Big | Big | No | No | Testing was done as follows: * Little -> Little * LE AArch64 native debug. * Big -> Little * s390x lldb running under QEMU, connected to LE AArch64 target. * Little -> Big * LE AArch64 lldb connected to QEMU's GDB stub, which is running an s390x program. * Big -> Big * s390x lldb running under QEMU, connected to another QEMU's GDB stub, which is running an s390x program. As we are not allowed to link core code to plugins directly, I have added a new plugin RegisterTypeBuilder. There is one implementation of this, RegisterTypeBuilderClang, which uses TypeSystemClang to build the CompilerType from the register fields. Reviewed By: jasonmolenda Differential Revision: https://reviews.llvm.org/D145580
2023-01-23[LLDB] Remove return value from DumpRegisterValueDavid Spickett
No one ever checks it. Also convert to early return. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D141687
2022-07-27[lldb] Always use APFloat for FP dumpingPavel Labath
The DumpDataExtractor function had two branches for printing floating point values. One branch (APFloat) was used if we had a Target object around and could query it for the appropriate semantics. If we didn't have a Target, we used host operations to read and format the value. This patch changes second path to use APFloat as well. To make it work, I pick reasonable defaults for different byte size. Notably, I did not include x87 long double in that list (as it is ambibuous and architecture-specific). This exposed a bug where we were printing register values using the target-less branch, even though the registers definitely belong to a target, and we had it available. Fixing this prompted the update of several tests for register values due to slightly different floating point outputs. The most dubious aspect of this patch is the change in TypeSystemClang::GetFloatTypeSemantics to recognize `10` as a valid size for x87 long double. This was necessary because because sizeof(long double) on x86_64 is 16 even though it only holds 10 bytes of useful data. This generalizes the hackaround present in the target-free branch of the dumping function. Differential Revision: https://reviews.llvm.org/D129750
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-24[lldb][NFC] Fix all formatting errors in .cpp file headersRaphael Isemann
Summary: A *.cpp file header in LLDB (and in LLDB) should like this: ``` //===-- TestUtilities.cpp -------------------------------------------------===// ``` However in LLDB most of our source files have arbitrary changes to this format and these changes are spreading through LLDB as folks usually just use the existing source files as templates for their new files (most notably the unnecessary editor language indicator `-*- C++ -*-` is spreading and in every review someone is pointing out that this is wrong, resulting in people pointing out that this is done in the same way in other files). This patch removes most of these inconsistencies including the editor language indicators, all the different missing/additional '-' characters, files that center the file name, missing trailing `===//` (mostly caused by clang-format breaking the line). Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere Reviewed By: JDevlieghere Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D73258
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-08-07Move RegisterValue,Scalar,State from Core to UtilityPavel Labath
These three classes have no external dependencies, but they are used from various low-level APIs. Moving them down to Utility improves overall code layering (although it still does not break any particular dependency completely). The XCode project will need to be updated after this change. Differential Revision: https://reviews.llvm.org/D49740 llvm-svn: 339127
2018-07-24Move dumping code out of RegisterValue classPavel Labath
Summary: The dump function was the only part of this class which depended on high-level functionality. This was due to the DumpDataExtractor function, which uses info from a running target to control dump format (although, RegisterValue doesn't really use the high-level part of DumpDataExtractor). This patch follows the same approach done for the DataExtractor class, and extracts the dumping code into a separate function/file. This file can stay in the higher level code, while the RegisterValue class and anything that does not depend in dumping can stay go to lower layers. The XCode project will need to be updated after this patch. Reviewers: zturner, jingham, clayborg Subscribers: lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D48351 llvm-svn: 337832