summaryrefslogtreecommitdiff
path: root/lldb/source/Utility/ArchSpec.cpp
AgeCommit message (Collapse)Author
2025-09-19Revert "[ELF][LLDB] Add an nvsass triple (#159459)" (#159879)Joseph Huber
Summary: This patch has broken the `libc` build bot. I could work around that but the changes seem unnecessary. This reverts commit 9ba844eb3a21d461c3adc7add7691a076c6992fc.
2025-09-19[ELF][LLDB] Add an nvsass triple (#159459)Walter Erquinigo
When handling CUDA ELF files via objdump or LLDB, the ELF parser in LLVM needs to distinguish if an ELF file is sass or not, which requires a triple for sass to exist in llvm. This patch includes all the necessary changes for LLDB and objdump to correctly identify these files with the correct triple.
2025-09-19[lldb] Add a static_assert that g_core_definitions matches the Core enum ↵Jonas Devlieghere
(#159452) This PR uses the same trick as 7ced9fff95473 to ensure the `g_core_definitions` table is correctly indexed by the Core enum. It's easy to make a mistake. Case in point: this caught two entries that appeared in the wrong order.
2025-09-12[LLDB][NVIDIA] Add NVPTX architecture support (#158334)Andrew Gontarek
- Introduced a new method `IsNVPTX()` in `ArchSpec` to check for NVPTX architecture. - Implemented the corresponding method in `ArchSpec.cpp` to utilize the existing triple architecture checks.
2025-09-10[NFC][lldb] Cleanup the ArchDefinitionEntry definitons. (#152618)Greg Clayton
This patch has default initialization values for the "sub", "cpu_mask" and "sub_mask" member variables of the ArchDefinitionEntry structure. This can simplify and cleanup the ArchDefinitionEntry arrays by allowing those that don't override the values to not have to initialize the values in the definitions if they match the default values. This patchs also disables clang format to align the values in the columns for easier readability.
2025-08-21[lldb] Add flag to "settings show" to include default values (#153233)Dave Lee
Adds a `--defaults`/`-d` flag to `settings show`. This mode will _optionally_ show a setting's default value. In other words, this does not always print a default value for every setting. A default value is not shown when the current value _is_ the default. Note: some setting types do not print empty or invalid values. For these setting types, if the default value is empty or invalid, the same elision logic is applied to printing the default value.
2025-07-14[lldb] Improve disassembly of unknown instructions (#145793)tedwoodward
LLDB uses the LLVM disassembler to determine the size of instructions and to do the actual disassembly. Currently, if the LLVM disassembler can't disassemble an instruction, LLDB will ignore the instruction size, assume the instruction size is the minimum size for that device, print no useful opcode, and print nothing for the instruction. This patch changes this behavior to separate the instruction size and "can't disassemble". If the LLVM disassembler knows the size, but can't dissasemble the instruction, LLDB will use that size. It will print out the opcode, and will print "<unknown>" for the instruction. This is much more useful to both a user and a script. The impetus behind this change is to clean up RISC-V disassembly when the LLVM disassembler doesn't understand all of the instructions. RISC-V supports proprietary extensions, where the TD files don't know about certain instructions, and the disassembler can't disassemble them. Internal users want to be able to disassemble these instructions. With llvm-objdump, the solution is to pipe the output of the disassembly through a filter program. This patch modifies LLDB's disassembly to look more like llvm-objdump's, and includes an example python script that adds a command "fdis" that will disassemble, then pipe the output through a specified filter program. This has been tested with crustfilt, a sample filter located at https://github.com/quic/crustfilt . Changes in this PR: - Decouple "can't disassemble" with "instruction size". DisassemblerLLVMC::MCDisasmInstance::GetMCInst now returns a bool for valid disassembly, and has the size as an out paramter. Use the size even if the disassembly is invalid. Disassemble if disassemby is valid. - Always print out the opcode when -b is specified. Previously it wouldn't print out the opcode if it couldn't disassemble. - Print out RISC-V opcodes the way llvm-objdump does. Code for the new Opcode Type eType16_32Tuples by Jason Molenda. - Print <unknown> for instructions that can't be disassembled, matching llvm-objdump, instead of printing nothing. - Update max riscv32 and riscv64 instruction size to 8. - Add example "fdis" command script. - Added disassembly byte test for x86 with known and unknown instructions. - Added disassembly byte test for riscv32 with known and unknown instructions, with and without filtering. - Added test from Jason Molenda to RISC-V disassembly unit tests.
2025-05-04[lldb] Remove unused local variables (NFC) (#138457)Kazu Hirata
2025-04-23Add MachO RISC-V CPU type and CPU subtype to llvm & lldb (#136785)Jonas Devlieghere
Add the enum values for MachO RISC-V CPU type and CPU subtype to llvm and use in LLDB's ArchSpec.
2025-02-10[lldb] [darwin] Upstream a few DriverKit cases (#126604)Jason Molenda
A DriverKit process is a kernel extension that runs in userland, instead of running in the kernel address space/priv levels, they've been around a couple of years. From lldb's perspective a DriverKit process is no different from any other userland level process, but it has a different Triple so we need to handle those cases in the lldb codebase. Some of the DriverKit triple handling had been upstreamed to llvm-project, but I noticed a few cases that had not yet. Cleaning that up.
2025-01-13[lldb] Add amd64 ArchSpec (#122533)Brad Smith
amd64 is used on OpenBSD.
2024-08-29[lldb] Add armv7a and armv8a ArchSpecs (#106433)Jordan R AW
armv7a and armv8a are common names for the application subarch for arm. These names in particular are used in ChromeOS, Android, and a few other known applications. In ChromeOS, we encountered a bug where armv7a arch was not recognised and segfaulted when starting an executable on an arm32 device. Google Issue Tracker: https://issuetracker.google.com/361414339
2024-08-22[lldb][AIX] Updating XCOFF,PPC entry in LLDB ArchSpec (#105523)Dhruv Srivastava
This PR is in reference to porting LLDB on AIX. Link to discussions on llvm discourse and github: 1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640 2. #101657 The complete changes for porting are present in this draft PR: #102601 The changes in this PR are intended to update the Architecture entry for LLDB with XCOFF,PPC. 1. Added new ArchitectureType `eArchTypeXCOFF` 2. Added a new `ArchDefinitionEntry g_xcoff_arch_entries[]` 3. Added a new case for `XCOFF in ArchSpec::SetArchitecture(..)` 4. Updated `ArchDefinition *g_arch_definitions[]`
2024-02-26Replace ArchSpec::PiecewiseCompare() with Triple::operator==()Adrian Prantl
Looking ast the definition of both functions this is *almost* an NFC change, except that Triple also looks at the SubArch (important) and ObjectFormat (less so). This fixes a bug that only manifests with how Xcode uses the SBAPI to attach to a process by name: it guesses the architecture based on the system. If the system is arm64 and the Process is arm64e Target fails to update the triple because it deemed the two to be equivalent. rdar://123338218
2024-02-23Revert "Replace ArchSpec::PiecewiseCompare() with Triple::operator==()"Adrian Prantl
This reverts commit 5e6bed8c0ea2f7fe380127763c8f753adae0fc1b while investigating the bots.
2024-02-23Replace ArchSpec::PiecewiseCompare() with Triple::operator==() (#82804)Adrian Prantl
Looking ast the definition of both functions this is *almost* an NFC change, except that Triple also looks at the SubArch (important) and ObjectFormat (less so). This fixes a bug that only manifests with how Xcode uses the SBAPI to attach to a process by name: it guesses the architecture based on the system. If the system is arm64 and the Process is arm64e Target fails to update the triple because it deemed the two to be equivalent. rdar://123338218
2023-05-03[lldb] Remove distribution_id from ArchSpecAlex Langford
The qHostInfo packet in the gdb-remote communication protocol specifies that distribution_id can be set, so lldb handles that. But we store that in the ArchSpec representing the "Host" platform (whatever platform the debug server is running on). This field is otherwise unused in ArchSpec, so it would be a lot easier if we stored that information at the gdb-remote communication layer. Sidenote: The distribution_id field is currently unused but I did not want to remove it in case some folks found it useful (e.g. in downstream forks). Differential Revision: https://reviews.llvm.org/D149697
2023-04-17[lldb] Add support for MSP430 in LLDB.Ilya Kuklin
Add MSP430 to the list of available targets, implement MSP430 ABI, add support for debugging targets with 16-bit address size. The update is intended for use with MSPDebug, a GDB server implementation for MSP430. Reviewed By: bulbazord, DavidSpickett Differential Revision: https://reviews.llvm.org/D146965
2023-04-17Revert "[lldb] Add support for MSP430 in LLDB."Anton Korobeynikov
This reverts commit 82c02b733c7736507a41a26bebd37d3f8e88bd4e. Apparently, the original patch was not rebased onto `main
2023-04-17[lldb] Add support for MSP430 in LLDB.Anton Korobeynikov
Add MSP430 to the list of available targets, implement MSP430 ABI, add support for debugging targets with 16-bit address size. The update is intended for use with MSPDebug, a GDB server implementation for MSP430. Reviewed By: bulbazord, DavidSpickett Differential Revision: https://reviews.llvm.org/D146965
2023-02-07[NFC][TargetParser] Remove llvm/Support/ARMTargetParser.hArchibald Elliott
2022-11-09[ARM] Move Triple::getARMCPUForArch into ARMTargetParserTomas Matheson
This is very backend specific so either belongs in Toolchains/ARM or in ARMTargetParser. Since it is used in lldb, ARMTargetParser made more sense. This is part of an effort to move information about ARM/AArch64 architecture versions, extensions and CPUs into their respective TargetParsers. Differential Revision: https://reviews.llvm.org/D137564
2022-11-01[LLDB][LoongArch] Add LoongArch ArchSpec and subtype detectionTiezhu Yang
Define LoongArch architecture subtypes, add the LoongArch ArchSpec bits, and inspect the ELF header to detect the right subtype based on ELF class. Here is a simple test: ``` [loongson@linux ~]$ cat hello.c int main() { printf("Hello, World!\n"); return 0; } [loongson@linux ~]$ clang hello.c -g -o hello ``` Without this patch: ``` [loongson@linux ~]$ llvm-project/llvm/build/bin/lldb hello (lldb) target create "hello" error: '/home/loongson/hello' doesn't contain any 'host' platform architectures: unknown ``` With this patch: ``` [loongson@linux ~]$ llvm-project/llvm/build/bin/lldb hello (lldb) target create "hello" Current executable set to '/home/loongson/hello' (loongarch64). (lldb) run Process 735167 launched: '/home/loongson/hello' (loongarch64) Hello, World! Process 735167 exited with status = 0 (0x00000000) (lldb) quit [loongson@linux ~]$ llvm-project/llvm/build/bin/llvm-lit llvm-project/lldb/test/Shell/ObjectFile/ELF/loongarch-arch.yaml llvm-lit: /home/loongson/llvm-project/llvm/utils/lit/lit/llvm/config.py:456: note: using clang: /home/loongson/llvm-project/llvm/build/bin/clang -- Testing: 1 tests, 1 workers -- PASS: lldb-shell :: ObjectFile/ELF/loongarch-arch.yaml (1 of 1) Testing Time: 0.09s Passed: 1 ``` Reviewed By: SixWeining, xen0n, DavidSpickett Differential Revision: https://reviews.llvm.org/D137057
2022-09-19[lldb] Remove LLDB reproducersJonas Devlieghere
This patch removes the remaining reproducer code. The SBReproducer class remains for ABI stability but is just an empty shell. This completes the removal process outlined on the mailing list [1]. [1] https://lists.llvm.org/pipermail/lldb-dev/2021-September/017045.html
2022-09-08[lldb] Use std::size instead of llvm::array_lengthofJoe Loser
LLVM contains a helpful function for getting the size of a C-style array: `llvm::array_lengthof`. This is useful prior to C++17, but not as helpful for C++17 or later: `std::size` already has support for C-style arrays. Change call sites to use `std::size` instead. Differential Revision: https://reviews.llvm.org/D133501
2022-08-20Use range-based for loops (NFC)Kazu Hirata
2022-08-17[LLDB][JIT] Set processor for ARM architecturePavel Kosov
Patch sets ARM cpu, before compiling JIT code. This enables FastISel for armv6 and higher CPUs and allows using hardware FPU ~~~ OS Laboratory. Huawei RRI. Saint-Petersburg Reviewed By: DavidSpickett Differential Revision: https://reviews.llvm.org/D131783
2022-08-08[lldb] LLVM_FALLTHROUGH => [[fallthrough]]. NFCFangrui Song
2022-08-02[lldb] Create an enum to specify the kind of ArchSpec matchingPavel Labath
s/true/ArchSpec::ExactMatch s/false/ArchSpec::CompatibleMatch Differential Revision: https://reviews.llvm.org/D121290
2022-06-22[lldb] Fix reading i686-windows executables with GNU environmentMartin Storsjö
25c8a061c5739677d2fc0af29a8cc9520207b923 / D127048 added an option for setting the ABI to GNU. When an object file is loaded, there's only minimal verification done for the architecture spec set for it, if the object file only provides one. However, for i386 object files, the PECOFF object file plugin provides two architectures, i386-pc-windows and i686-pc-windows. This picks a totally different codepath in TargetList::CreateTargetInternal, where it's treated as a fat binary. This goes through more verifications to see if the architectures provided by the object file matches what the platform plugin supports. The PlatformWindows() constructor explicitly adds the "i386-pc-windows" and "i686-pc-windows" architectures (even when running on other architectures), which allows this "fat binary verification" to succeed for the i386 object files that provide two architectures. However, after that commit, if the object file is advertised with the different environment (either when lldb is built in a mingw environment, or if that setting is set), the fat binary validation won't accept the file any longer. Update ArchSpec::IsEqualTo with more logic for the Windows use cases; mismatching vendors is not an issue (they don't have any practical effect on Windows), and GNU and MSVC environments are compatible to the point that PlatformWindows can handle object files for both environments/ABIs. As a separate path forward, one could also consider to stop returning two architecture specs from ObjectFilePECOFF::GetModuleSpecifications for i386 files. Differential Revision: https://reviews.llvm.org/D128268
2022-05-05[lldb] Fix ppc64 detection in lldbserge-sans-paille
Currently, ppc64le and ppc64 (defaulting to big endian) have the same descriptor, thus the linear scan always return ppc64le. Handle that through subtype. This is a recommit of f114f009486816ed4b3bf984f0fbbb8fc80914f6 with a new test setup that doesn't involves (unsupported) corefiles. Differential Revision: https://reviews.llvm.org/D124760
2022-05-03Revert "[lldb] Fix ppc64 detection in lldb"David Spickett
This reverts commit f114f009486816ed4b3bf984f0fbbb8fc80914f6. Due to hitting an assert on our lldb bots: https://lab.llvm.org/buildbot/#/builders/96/builds/22715 ../llvm-project/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp:170: virtual lldb::RegisterContextSP ThreadElfCore::CreateRegisterContextForFrame( lldb_private::StackFrame *): Assertion `false && "Architecture or OS not supported"' failed.
2022-05-03[lldb] Fix ppc64 detection in lldbserge-sans-paille
Currently, ppc64le and ppc64 (defaulting to big endian) have the same descriptor, thus the linear scan always return ppc64le. Handle that through subtype. Differential Revision: https://reviews.llvm.org/D124760
2022-04-01Simplify ArchSpec::IsFullySpecifiedTriple() (NFC)Adrian Prantl
I found this function somewhat hard to read and removed a few entirely redundant checks and converted it to early exits. Differential Revision: https://reviews.llvm.org/D122912
2022-02-03[lldb] Rename Logging.h to LLDBLog.h and clean up includesPavel Labath
Most of our code was including Log.h even though that is not where the "lldb" log channel is defined (Log.h defines the generic logging infrastructure). This worked because Log.h included Logging.h, even though it should. After the recent refactor, it became impossible the two files include each other in this direction (the opposite inclusion is needed), so this patch removes the workaround that was put in place and cleans up all files to include the right thing. It also renames the file to LLDBLog to better reflect its purpose.
2022-02-02[lldb] Convert "LLDB" log channel to the new APIPavel Labath
2022-01-26Revert "Rename llvm::array_lengthof into llvm::size to match std::size from ↵Benjamin Kramer
C++17" This reverts commit ef8206320769ad31422a803a0d6de6077fd231d2. - It conflicts with the existing llvm::size in STLExtras, which will now never be called. - Calling it without llvm:: breaks C++17 compat
2022-01-26Rename llvm::array_lengthof into llvm::size to match std::size from C++17serge-sans-paille
As a conquence move llvm::array_lengthof from STLExtras.h to STLForwardCompat.h (which is included by STLExtras.h so no build breakage expected).
2021-12-10Remove one change from https://reviews.llvm.org/D115431Jason Molenda
The change to ArchSpec::SetArchitecture that was setting the ObjectFile of a mach-o binary to llvm::Triple::MachO. It's not necessary for my patch, and it changes the output of image list -t causing TestUniversal.py to fail on x86_64 systems. The bots turned up the failure, I was developing and testing this on an Apple Silicon mac.
2021-12-09Set a default number of address bits on Darwin arm64 systemsJason Molenda
With arm64e ARMv8.3 pointer authentication, lldb needs to know how many bits are used for addressing and how many are used for pointer auth signing. This should be determined dynamically from the inferior system / corefile, but there are some workflows where it still isn't recorded and we fall back on a default value that is correct on some Darwin environments. This patch also explicitly sets the vendor of mach-o binaries to Apple, so we select an Apple ABI instead of a random other ABI. It adds a function pointer formatter for systems where pointer authentication is in use, and we can strip the ptrauth bits off of the function pointer address and get a different value that points to an actual symbol. Differential Revision: https://reviews.llvm.org/D115431 rdar://84644661
2021-07-02[lldb] Replace default bodies of special member functions with = default;Jonas Devlieghere
Replace default bodies of special member functions with = default; $ run-clang-tidy.py -header-filter='lldb' -checks='-*,modernize-use-equals-default' -fix , https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-equals-default.html Differential revision: https://reviews.llvm.org/D104041
2021-06-25[lldb] Rename StringRef _lower() method calls to _insensitive()Martin Storsjö
2021-04-15NFC put the armv6m entry with the other Cortex-M entriesJason Molenda
The armv6m entry in cores_match() got separated from its friends armv7m and armv7em. Reuniting them to make it easier to keep them updated in all at the same time.
2021-04-15Mark armv6m compat with armv7em; match armv7em being compat with armv6mJason Molenda
armv7em and armv6m in ArchSpec cores_match() will return true. There was a small bug where the reverse order would not return true. rdar://76387176
2021-02-03[lldb] Honor the CPU type & subtype when launching on macOSJonas Devlieghere
Honor the CPU type (and subtype) when launching the inferior on macOS. Part of this functionality was thought to be no longer needed and removed in 85bd4369610fe60397455c8e0914a09288285e84, however it's still needed, for example to launch binaries under Rosetta 2 on Apple Silicon. This patch will use posix_spawnattr_setarchpref_np if available and fallback to posix_spawnattr_setbinpref_np if not. Differential revision: https://reviews.llvm.org/D95922
2021-01-20[lldb] Upstream eCore_arm_arm64e enum value in ArchSpecJonas Devlieghere
Upstream the eCore_arm_arm64e enum value in ArchSpec. All the other arm64e triple changes already landed in LLVM. Differential revision: https://reviews.llvm.org/D95110
2021-01-07[LLDB][RISCV] Add RISC-V ArchSpec and rv32/rv64 variant detectionLuís Marques
Adds the RISC-V ArchSpec bits contributed by @simoncook as part of D62732, plus logic to distinguish between riscv32 and riscv64 based on ELF class. The patch follows the implementation approach previously used for MIPS. It defines RISC-V architecture subtypes and inspects the ELF header, namely the ELF class, to detect the right subtype. Differential Revision: https://reviews.llvm.org/D86292
2020-12-03[lldb] Use the cpu subtype enum values from llvm::MachO in ArchSpec (NFC)Jonas Devlieghere
Use the cpu subtype enum values from llvm::MachO in the ArchSpec MachO table. As I'm already cluttering the history, restore the table's formatting to its original glory. Differential revision: https://reviews.llvm.org/D92601
2020-12-03[lldb] Recognize MachO cpu sub-type 2 as arm64Jonas Devlieghere
Make sure we recognize cpu sub-type 2 as arm64. In reality it's arm64e, but we don't have the triple for that. Without this patch, we fall back to unknown-apple-macosx- for the default architecture, which breaks things like running expressions without a target. Differential revision: https://reviews.llvm.org/D92603
2020-09-23Utility: ignore OS version on non-Darwin targets in `ArchSpec`Saleem Abdulrasool
The OS version field is generally not very helpful for non-Darwin targets. On Linux, it identifies the kernel version which moves out-of-sync with the userspace. On Windows, this field actually ends up corresponding to the Visual Studio toolset version instead of the OS version. Consider non-Darwin targets without an OS version to be fully specified. Differential Revision: https://reviews.llvm.org/D88181 Reviewed By: Jonas Devlieghere, Dave Lee