Skip to content

[lldb] Fix crash in SymbolFileCTF::ParseFunctions #89845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ SymbolFileCTF::CreateInteger(const CTFInteger &ctf_integer) {

CompilerType compiler_type = m_ast->GetBasicType(basic_type);

if (basic_type != eBasicTypeVoid) {
if (basic_type != eBasicTypeVoid && basic_type != eBasicTypeBool) {
// Make sure the type we got is an integer type.
bool compiler_type_is_signed = false;
if (!compiler_type.IsIntegerType(compiler_type_is_signed))
Expand Down Expand Up @@ -802,7 +802,8 @@ size_t SymbolFileCTF::ParseFunctions(CompileUnit &cu) {
}

Type *arg_type = ResolveTypeUID(arg_uid);
arg_types.push_back(arg_type->GetFullCompilerType());
arg_types.push_back(arg_type ? arg_type->GetFullCompilerType()
: CompilerType());
}

if (symbol) {
Expand All @@ -813,8 +814,9 @@ size_t SymbolFileCTF::ParseFunctions(CompileUnit &cu) {

// Create function type.
CompilerType func_type = m_ast->CreateFunctionType(
ret_type->GetFullCompilerType(), arg_types.data(), arg_types.size(),
is_variadic, 0, clang::CallingConv::CC_C);
ret_type ? ret_type->GetFullCompilerType() : CompilerType(),
arg_types.data(), arg_types.size(), is_variadic, 0,
clang::CallingConv::CC_C);
lldb::user_id_t function_type_uid = m_types.size() + 1;
TypeSP type_sp =
MakeType(function_type_uid, symbol->GetName(), 0, nullptr,
Expand Down
5 changes: 4 additions & 1 deletion lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,11 @@ lldb::BasicType TypeSystemClang::GetBasicTypeEnumeration(llvm::StringRef name) {
{"__int128_t", eBasicTypeInt128},
{"__uint128_t", eBasicTypeUnsignedInt128},

// Miscellaneous
// "bool"
{"bool", eBasicTypeBool},
{"_Bool", eBasicTypeBool},

// Miscellaneous
{"float", eBasicTypeFloat},
{"double", eBasicTypeDouble},
{"long double", eBasicTypeLongDouble},
Expand Down
2 changes: 1 addition & 1 deletion lldb/test/API/macosx/ctf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ MAKE_DSYM := YES
ifeq "$(COMPRESS_CTF)" "YES"
COMPRESS := -c
else
COMPRESS :=
COMPRESS :=
endif

all: a.out a.ctf
Expand Down
1 change: 1 addition & 0 deletions lldb/test/API/macosx/ctf/TestCTF.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def do_test(self):
"[2] = 'b'",
"[3] = 'c'",
'u = (i = 1, s = "")',
"b = false",
"f = 0x0000000000000000",
],
)
Expand Down
3 changes: 3 additions & 0 deletions lldb/test/API/macosx/ctf/test.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <stdbool.h>
#include <stdio.h>

struct ForwardDecl;
Expand All @@ -24,6 +25,7 @@ typedef struct MyNestedStruct {
char a[4];
MyEnumT e;
MyUnionT u;
_Bool b;
} MyNestedStructT;

typedef struct MyStruct {
Expand Down Expand Up @@ -54,6 +56,7 @@ void populate(MyInt i) {
foo.n.a[2] = 'c';
foo.n.a[3] = 'd';
foo.n.e = eOne;
foo.n.b = false;
foo.f = NULL;
forward = NULL;
bar.b = i;
Expand Down