[Lldb-commits] [lldb] [lldb] Fix TypeSystemClang::GetBasicTypeEnumeration for 128-bit int types (PR #162278)
Matej Košík via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 7 05:53:07 PDT 2025
https://github.com/sedymrak created https://github.com/llvm/llvm-project/pull/162278
When we take the following C program:
```
int main() {
return 0;
}
```
and create a statically-linked executable from it:
```
clang -static -g -o main main.c
```
Then we can observe the following `lldb` behavior:
```
$ lldb
(lldb) target create main
Current executable set to '.../main' (x86_64).
(lldb) breakpoint set --name main
Breakpoint 1: where = main`main + 11 at main.c:2:3, address = 0x000000000022aa7b
(lldb) process launch
Process 3773637 launched: '/home/me/tmp/built-in/main' (x86_64)
Process 3773637 stopped
* thread #1, name = 'main', stop reason = breakpoint 1.1
frame #0: 0x000000000022aa7b main`main at main.c:2:3
1 int main() {
-> 2 return 0;
3 }
(lldb) script lldb.debugger.GetSelectedTarget().FindFirstType("__int128").size
0
(lldb) script lldb.debugger.GetSelectedTarget().FindFirstType("unsigned __int128").size
0
(lldb) quit
```
The value return by the `SBTarget::FindFirstType` method is wrong for the `__int128` and `unsigned __int128` basic types.
The proposed changes make the `TypeSystemClang::GetBasicTypeEnumeration` method consistent with `gcc` and `clang` C [language extension](https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html) related to 128-bit integer types as well as with the `BuiltinType::getName` method in the LLVM codebase itself.
When the above change is applied, the behavior of the `lldb` changes in the following (desired) way:
```
$ lldb
(lldb) target create main
Current executable set to '.../main' (x86_64).
(lldb) breakpoint set --name main
Breakpoint 1: where = main`main + 11 at main.c:2:3, address = 0x000000000022aa7b
(lldb) process launch
Process 3773637 launched: '/home/me/tmp/built-in/main' (x86_64)
Process 3773637 stopped
* thread #1, name = 'main', stop reason = breakpoint 1.1
frame #0: 0x000000000022aa7b main`main at main.c:2:3
1 int main() {
-> 2 return 0;
3 }
(lldb) script lldb.debugger.GetSelectedTarget().FindFirstType("__int128").size
16
(lldb) script lldb.debugger.GetSelectedTarget().FindFirstType("unsigned __int128").size
16
(lldb) quit
```
>From a0f1a1cff80523696340cc0a0c7aa0711bdb7a16 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Tue, 7 Oct 2025 12:18:43 +0200
Subject: [PATCH] [lldb] Fix the TypeSystemClang::GetBasicTypeEnumeration wrt.
128-bit integer types
---
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 21c265ede0bc5..1a574c97d9e46 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -849,8 +849,8 @@ lldb::BasicType TypeSystemClang::GetBasicTypeEnumeration(llvm::StringRef name) {
{"unsigned long long int", eBasicTypeUnsignedLongLong},
// "int128"
- {"__int128_t", eBasicTypeInt128},
- {"__uint128_t", eBasicTypeUnsignedInt128},
+ {"__int128", eBasicTypeInt128},
+ {"unsigned __int128", eBasicTypeUnsignedInt128},
// "bool"
{"bool", eBasicTypeBool},
More information about the lldb-commits
mailing list