-
Couldn't load subscription status.
- Fork 15k
[LLDB][NativePDB] Add modifiers to modified type name #159296
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
Conversation
|
@llvm/pr-subscribers-lldb Author: nerix (Nerixyz) ChangesWhen creating LLDB types from The DIA plugin had a test for this. That test also assumed that function types had a name. I removed that check here, because function/procedure types themselves in PDB don't have a name: I assume DIA gets the name from the function symbol itself. In the native plugin, that name isn't included and multiple functions with the same signature will reuse one type, whereas DIA would create a new type for each function. The Shell/SymbolFile/PDB/func-symbols.test also relies on this. Full diff: https://github.com/llvm/llvm-project/pull/159296.diff 2 Files Affected:
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index cfecda4817976..f081965a76183 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -549,10 +549,18 @@ lldb::TypeSP SymbolFileNativePDB::CreateModifierType(PdbTypeSymId type_id,
TpiStream &stream = m_index->tpi();
std::string name;
+
+ if ((mr.Modifiers & ModifierOptions::Const) != ModifierOptions::None)
+ name += "const ";
+ if ((mr.Modifiers & ModifierOptions::Volatile) != ModifierOptions::None)
+ name += "volatile ";
+ if ((mr.Modifiers & ModifierOptions::Unaligned) != ModifierOptions::None)
+ name += "__unaligned ";
+
if (mr.ModifiedType.isSimple())
- name = std::string(GetSimpleTypeName(mr.ModifiedType.getSimpleKind()));
+ name += GetSimpleTypeName(mr.ModifiedType.getSimpleKind());
else
- name = computeTypeName(stream.typeCollection(), mr.ModifiedType);
+ name += computeTypeName(stream.typeCollection(), mr.ModifiedType);
Declaration decl;
lldb::TypeSP modified_type = GetOrCreateType(mr.ModifiedType);
diff --git a/lldb/test/Shell/SymbolFile/PDB/type-quals.test b/lldb/test/Shell/SymbolFile/PDB/type-quals.test
index e0d79ac0b7529..370c0a21b093a 100644
--- a/lldb/test/Shell/SymbolFile/PDB/type-quals.test
+++ b/lldb/test/Shell/SymbolFile/PDB/type-quals.test
@@ -2,35 +2,37 @@ REQUIRES: target-windows, msvc
RUN: mkdir -p %t.dir
RUN: %build --compiler=clang-cl --mode=compile --arch=32 --nodefaultlib --output=%t.dir/TypeQualsTest.cpp.obj %S/Inputs/TypeQualsTest.cpp
RUN: %build --compiler=msvc --mode=link --arch=32 --nodefaultlib --output=%t.dir/TypeQualsTest.cpp.exe %t.dir/TypeQualsTest.cpp.obj
-RUN: lldb-test symbols %t.dir/TypeQualsTest.cpp.exe | FileCheck %s
+RUN: env LLDB_USE_NATIVE_PDB_READER=0 lldb-test symbols %t.dir/TypeQualsTest.cpp.exe | FileCheck %s
+RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols %t.dir/TypeQualsTest.cpp.exe | FileCheck %s
CHECK: Module [[MOD:.*]]
-CHECK-DAG: SymbolFile pdb ([[MOD]])
+CHECK-DAG: SymbolFile {{(native-)?}}pdb ([[MOD]])
CHECK-DAG: Type{{.*}} , name = "const int", size = 4, compiler_type = {{.*}} const int
CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int *
CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int **const
CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int *const
CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int *const *
-CHECK-DAG: Type{{.*}} , name = "Func1", {{.*}}, compiler_type = {{.*}} void (const int *, const int *, const int **const, const int *const *)
+CHECK-DAG: Type{{.*}} , {{.*}}, compiler_type = {{.*}} void (const int *, const int *, const int **const, const int *const *)
CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} volatile int *
-CHECK-DAG: Type{{.*}} , name = "Func2", {{.*}}, compiler_type = {{.*}} void (volatile int *, volatile int *)
+CHECK-DAG: Type{{.*}} , {{.*}}, compiler_type = {{.*}} void (volatile int *, volatile int *)
CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int *
CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int *&
CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int &&
CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int &
CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int &
-CHECK-DAG: Type{{.*}} , name = "Func3", {{.*}}, compiler_type = {{.*}} void (int *&, int &, const int &, int &&)
+CHECK-DAG: Type{{.*}} , {{.*}}, compiler_type = {{.*}} void (int *&, int &, const int &, int &&)
// FIXME: __unaligned is not supported.
-CHECK-DAG: Type{{.*}} , name = "Func4", {{.*}}, compiler_type = {{.*}} void (int *, int *)
+CHECK-DAG: Type{{.*}} , {{.*}}, compiler_type = {{.*}} void (int *, int *)
CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int *__restrict
CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int &__restrict
-CHECK-DAG: Type{{.*}} , name = "Func5", {{.*}}, compiler_type = {{.*}} void (int, int *__restrict, int &__restrict)
+CHECK-DAG: Type{{.*}} , {{.*}}, compiler_type = {{.*}} void (int, int *__restrict, int &__restrict)
-CHECK-DAG: Type{{.*}} , name = "Func6", {{.*}}, compiler_type = {{.*}} void (const volatile int *__restrict)
+CHECK-DAG: Type{{.*}} , name = "{{volatile const|const volatile}} int", size = 4, compiler_type = {{.*}} {{volatile const|const volatile}} int
+CHECK-DAG: Type{{.*}} , {{.*}}, compiler_type = {{.*}} void (const volatile int *__restrict)
CHECK-DAG: Type{{.*}} , size = 400, compiler_type = {{.*}} volatile int *[100]
CHECK-DAG: Type{{.*}} , size = 4000, compiler_type = {{.*}} volatile int *[10][100]
|
When creating LLDB types from
LF_MODIFIERrecords, the type name of the modified type was used. This didn't include the modifiers (const/volatile/__unaligned). With this PR, they're included.The DIA plugin had a test for this. That test also assumed that function types had a name. I removed that check here, because function/procedure types themselves in PDB don't have a name:
I assume DIA gets the name from the function symbol itself. In the native plugin, that name isn't included and multiple functions with the same signature will reuse one type, whereas DIA would create a new type for each function. The Shell/SymbolFile/PDB/func-symbols.test also relies on this.