Skip to content

Commit 185ae5c

Browse files
committed
Revert "[LLDB][NativePDB] Create functions with mangled name (#149701)"
This reverts commit e98f34e. This broke demangling of Itanium symbols on i386.
1 parent 5923004 commit 185ae5c

File tree

11 files changed

+31
-72
lines changed

11 files changed

+31
-72
lines changed

lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,16 @@ struct CreateMethodDecl : public TypeVisitorCallbacks {
3838
TypeIndex func_type_index,
3939
clang::FunctionDecl *&function_decl,
4040
lldb::opaque_compiler_type_t parent_ty,
41-
llvm::StringRef proc_name, ConstString mangled_name,
42-
CompilerType func_ct)
41+
llvm::StringRef proc_name, CompilerType func_ct)
4342
: m_index(m_index), m_clang(m_clang), func_type_index(func_type_index),
4443
function_decl(function_decl), parent_ty(parent_ty),
45-
proc_name(proc_name), mangled_name(mangled_name), func_ct(func_ct) {}
44+
proc_name(proc_name), func_ct(func_ct) {}
4645
PdbIndex &m_index;
4746
TypeSystemClang &m_clang;
4847
TypeIndex func_type_index;
4948
clang::FunctionDecl *&function_decl;
5049
lldb::opaque_compiler_type_t parent_ty;
5150
llvm::StringRef proc_name;
52-
ConstString mangled_name;
5351
CompilerType func_ct;
5452

5553
llvm::Error visitKnownMember(CVMemberRecord &cvr,
@@ -89,7 +87,8 @@ struct CreateMethodDecl : public TypeVisitorCallbacks {
8987
bool is_artificial = (options & MethodOptions::CompilerGenerated) ==
9088
MethodOptions::CompilerGenerated;
9189
function_decl = m_clang.AddMethodToCXXRecordType(
92-
parent_ty, proc_name, mangled_name, func_ct, /*access=*/access_type,
90+
parent_ty, proc_name,
91+
/*asm_label=*/{}, func_ct, /*access=*/access_type,
9392
/*is_virtual=*/is_virtual, /*is_static=*/is_static,
9493
/*is_inline=*/false, /*is_explicit=*/false,
9594
/*is_attr_used=*/false, /*is_artificial=*/is_artificial);
@@ -893,26 +892,22 @@ PdbAstBuilder::CreateFunctionDecl(PdbCompilandSymId func_id,
893892
tag_record = CVTagRecord::create(index.tpi().getType(*eti)).asTag();
894893
}
895894
}
896-
897-
ConstString mangled_name(
898-
pdb->FindMangledFunctionName(func_id).value_or(llvm::StringRef()));
899-
900895
if (!tag_record.FieldList.isSimple()) {
901896
CVType field_list_cvt = index.tpi().getType(tag_record.FieldList);
902897
FieldListRecord field_list;
903898
if (llvm::Error error = TypeDeserializer::deserializeAs<FieldListRecord>(
904899
field_list_cvt, field_list))
905900
llvm::consumeError(std::move(error));
906901
CreateMethodDecl process(index, m_clang, func_ti, function_decl,
907-
parent_opaque_ty, func_name, mangled_name,
908-
func_ct);
902+
parent_opaque_ty, func_name, func_ct);
909903
if (llvm::Error err = visitMemberRecordStream(field_list.Data, process))
910904
llvm::consumeError(std::move(err));
911905
}
912906

913907
if (!function_decl) {
914908
function_decl = m_clang.AddMethodToCXXRecordType(
915-
parent_opaque_ty, func_name, mangled_name, func_ct,
909+
parent_opaque_ty, func_name,
910+
/*asm_label=*/{}, func_ct,
916911
/*access=*/lldb::AccessType::eAccessPublic,
917912
/*is_virtual=*/false, /*is_static=*/false,
918913
/*is_inline=*/false, /*is_explicit=*/false,

lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,7 @@ lldb::FunctionSP SymbolFileNativePDB::CreateFunction(PdbCompilandSymId func_id,
501501
return nullptr;
502502

503503
PdbTypeSymId sig_id(proc.FunctionType, false);
504-
std::optional<llvm::StringRef> mangled_opt =
505-
FindMangledSymbol(SegmentOffset(proc.Segment, proc.CodeOffset));
506-
Mangled mangled(mangled_opt.value_or(proc.Name));
504+
Mangled mangled(proc.Name);
507505
FunctionSP func_sp = std::make_shared<Function>(
508506
&comp_unit, toOpaqueUid(func_id), toOpaqueUid(sig_id), mangled,
509507
func_type.get(), func_addr,
@@ -2664,31 +2662,6 @@ SymbolFileNativePDB::GetContextForType(TypeIndex ti) {
26642662
return ctx;
26652663
}
26662664

2667-
std::optional<llvm::StringRef>
2668-
SymbolFileNativePDB::FindMangledFunctionName(PdbCompilandSymId func_id) {
2669-
const CompilandIndexItem *cci =
2670-
m_index->compilands().GetCompiland(func_id.modi);
2671-
if (!cci)
2672-
return std::nullopt;
2673-
2674-
CVSymbol sym_record = cci->m_debug_stream.readSymbolAtOffset(func_id.offset);
2675-
if (sym_record.kind() != S_LPROC32 && sym_record.kind() != S_GPROC32)
2676-
return std::nullopt;
2677-
2678-
ProcSym proc(static_cast<SymbolRecordKind>(sym_record.kind()));
2679-
cantFail(SymbolDeserializer::deserializeAs<ProcSym>(sym_record, proc));
2680-
return FindMangledSymbol(SegmentOffset(proc.Segment, proc.CodeOffset));
2681-
}
2682-
2683-
std::optional<llvm::StringRef>
2684-
SymbolFileNativePDB::FindMangledSymbol(SegmentOffset so) {
2685-
auto symbol = m_index->publics().findByAddress(m_index->symrecords(),
2686-
so.segment, so.offset);
2687-
if (!symbol)
2688-
return std::nullopt;
2689-
return symbol->first.Name;
2690-
}
2691-
26922665
void SymbolFileNativePDB::CacheUdtDeclarations() {
26932666
for (CVType cvt : m_index->ipi().typeArray()) {
26942667
switch (cvt.kind()) {

lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,6 @@ class SymbolFileNativePDB : public SymbolFileCommon {
140140

141141
std::optional<PdbCompilandSymId> FindSymbolScope(PdbCompilandSymId id);
142142

143-
/// Find the mangled name for a function
144-
///
145-
/// \param id A symbol ID of a S_LPROC32/S_GPROC32 record
146-
/// \returns The mangled name of the function (if available)
147-
std::optional<llvm::StringRef> FindMangledFunctionName(PdbCompilandSymId id);
148-
149143
void FindTypes(const lldb_private::TypeQuery &match,
150144
lldb_private::TypeResults &results) override;
151145

@@ -275,8 +269,6 @@ class SymbolFileNativePDB : public SymbolFileCommon {
275269
void CacheUdtDeclarations();
276270
llvm::Expected<Declaration> ResolveUdtDeclaration(PdbTypeSymId type_id);
277271

278-
std::optional<llvm::StringRef> FindMangledSymbol(SegmentOffset so);
279-
280272
llvm::BumpPtrAllocator m_allocator;
281273

282274
lldb::addr_t m_obj_load_address = 0;

lldb/test/Shell/SymbolFile/NativePDB/break-by-function.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ int main(int argc, char **argv) {
5050
// CHECK: 1: name = 'main', locations = 1
5151
// CHECK: 1.1: where = break-by-function.cpp.tmp.exe`main + {{[0-9]+}}
5252
// CHECK: 2: name = 'OvlGlobalFn', locations = 3
53-
// CHECK: 2.1: where = break-by-function.cpp.tmp.exe`int OvlGlobalFn(int) + {{[0-9]+}}
54-
// CHECK: 2.2: where = break-by-function.cpp.tmp.exe`int OvlGlobalFn(int, int)
55-
// CHECK: 2.3: where = break-by-function.cpp.tmp.exe`int OvlGlobalFn(int, int, int) + {{[0-9]+}}
53+
// CHECK: 2.1: where = break-by-function.cpp.tmp.exe`OvlGlobalFn + {{[0-9]+}}
54+
// CHECK: 2.2: where = break-by-function.cpp.tmp.exe`OvlGlobalFn
55+
// CHECK: 2.3: where = break-by-function.cpp.tmp.exe`OvlGlobalFn + {{[0-9]+}}
5656
// CHECK: 3: name = 'StaticFn', locations = 1
5757
// CHECK: 3.1: where = break-by-function.cpp.tmp.exe`StaticFn + {{[0-9]+}}
5858
// CHECK: 4: name = 'DoesntExist', locations = 0 (pending)

lldb/test/Shell/SymbolFile/NativePDB/break-by-line.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ int main(int argc, char **argv) {
2424
// CHECK: (lldb) target create "{{.*}}break-by-line.cpp.tmp.exe"
2525
// CHECK: Current executable set to '{{.*}}break-by-line.cpp.tmp.exe'
2626
// CHECK: (lldb) break set -f break-by-line.cpp -l 15
27-
// CHECK: Breakpoint 1: where = break-by-line.cpp.tmp.exe`int NS::NamespaceFn(int) + {{[0-9]+}} at break-by-line.cpp:15
27+
// CHECK: Breakpoint 1: where = break-by-line.cpp.tmp.exe`NS::NamespaceFn + {{[0-9]+}} at break-by-line.cpp:15

lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int main(int argc, char **argv) {
2525
// CHECK-NEXT: disassembly.cpp.tmp.exe[{{.*}}] <+12>: mov qword ptr [rsp + 0x28], rdx
2626
// CHECK-NEXT: disassembly.cpp.tmp.exe[{{.*}}] <+17>: mov dword ptr [rsp + 0x24], ecx
2727
// CHECK: ** 15 foo();
28-
// CHECK: disassembly.cpp.tmp.exe[{{.*}}] <+21>: call {{.*}} ; int foo(void) at disassembly.cpp:12
28+
// CHECK: disassembly.cpp.tmp.exe[{{.*}}] <+21>: call {{.*}} ; foo at disassembly.cpp:12
2929
// CHECK: ** 16 return 0;
3030
// CHECK-NEXT: 17 }
3131
// CHECK-NEXT: 18

lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,19 +148,18 @@ int main(int argc, char **argv) {
148148
// FIND-OVERLOAD-BASE-DAG: FuncType: id = {{.*}}, compiler_type = "int (void)"
149149
// FIND-OVERLOAD-BASE-DAG: FuncType: id = {{.*}}, compiler_type = "int (char)"
150150
// FIND-OVERLOAD-BASE-DAG: FuncType: id = {{.*}}, compiler_type = "int (char, int, ...)"
151-
// FIND-OVERLOAD-BASE-DAG: Function: id = {{.*}}, name = "int Class::overloaded_method(bool)"
151+
// FIND-OVERLOAD-BASE-DAG: Function: id = {{.*}}, name = "Class::overloaded_method"
152152
// FIND-OVERLOAD-BASE-DAG: FuncType: id = {{.*}}, compiler_type = "_Bool (void)"
153153
// FIND-OVERLOAD-BASE-DAG: FuncType: id = {{.*}}, compiler_type = "_Bool (int)"
154154
// FIND-OVERLOAD-BASE-DAG: FuncType: id = {{.*}}, compiler_type = "int (_Bool)"
155-
// FIND-OVERLOAD-BASE-DAG: Function: id = {{.*}}, name = "char overloaded_method(void)"
156-
// FIND-OVERLOAD-BASE-DAG: Function: id = {{.*}}, name = "char overloaded_method(int)"
155+
// FIND-OVERLOAD-BASE-DAG: Function: id = {{.*}}, name = "overloaded_method"
157156
// FIND-OVERLOAD-BASE-DAG: FuncType: id = {{.*}}, compiler_type = "char (void)"
158157
// FIND-OVERLOAD-BASE-DAG: FuncType: id = {{.*}}, compiler_type = "char (int)"
159158

160159
// FIND-OVERLOAD-METHOD-NOT: "overloaded_method"
161160
// FIND-OVERLOAD-METHOD-DAG: Function: id = {{.*}}, name = "{{.*}}Struct::overloaded_method{{.*}}"
162161
// FIND-OVERLOAD-METHOD-DAG: FuncType: id = {{.*}}, compiler_type = "int (void)"
163162
// FIND-OVERLOAD-METHOD-DAG: FuncType: id = {{.*}}, compiler_type = "int (char)"
164-
// FIND-OVERLOAD-METHOD-DAG: Function: id = {{.*}}, name = "bool Class::overloaded_method(void)"
163+
// FIND-OVERLOAD-METHOD-DAG: Function: id = {{.*}}, name = "Class::overloaded_method"
165164
// FIND-OVERLOAD-METHOD-DAG: FuncType: id = {{.*}}, compiler_type = "_Bool (void)"
166165
// FIND-OVERLOAD-METHOD-DAG: FuncType: id = {{.*}}, compiler_type = "_Bool (int)"

lldb/test/Shell/SymbolFile/NativePDB/local-variables.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ int main(int argc, char **argv) {
5555
// CHECK-NEXT: (lldb) step
5656
// CHECK-NEXT: Process {{.*}} stopped
5757
// CHECK-NEXT: * thread #1, stop reason = step in
58-
// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`int Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}}
58+
// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}}
5959
// CHECK-NEXT: 6
6060
// CHECK-NEXT: 7
6161
// CHECK-NEXT: 8 int Function(int Param1, char Param2) {
@@ -71,7 +71,7 @@ int main(int argc, char **argv) {
7171
// CHECK-NEXT: (lldb) step
7272
// CHECK-NEXT: Process {{.*}} stopped
7373
// CHECK-NEXT: * thread #1, stop reason = step in
74-
// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`int Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}}
74+
// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}}
7575
// CHECK-NEXT: 7
7676
// CHECK-NEXT: 8 int Function(int Param1, char Param2) {
7777
// CHECK-NEXT: 9 unsigned Local1 = Param1 + 1;
@@ -89,7 +89,7 @@ int main(int argc, char **argv) {
8989
// CHECK-NEXT: (lldb) step
9090
// CHECK-NEXT: Process {{.*}} stopped
9191
// CHECK-NEXT: * thread #1, stop reason = step in
92-
// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`int Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}}
92+
// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}}
9393
// CHECK-NEXT: 8 int Function(int Param1, char Param2) {
9494
// CHECK-NEXT: 9 unsigned Local1 = Param1 + 1;
9595
// CHECK-NEXT: 10 char Local2 = Param2 + 1;
@@ -109,7 +109,7 @@ int main(int argc, char **argv) {
109109
// CHECK-NEXT: (lldb) step
110110
// CHECK-NEXT: Process {{.*}} stopped
111111
// CHECK-NEXT: * thread #1, stop reason = step in
112-
// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`int Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}}
112+
// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}}
113113
// CHECK-NEXT: 9 unsigned Local1 = Param1 + 1;
114114
// CHECK-NEXT: 10 char Local2 = Param2 + 1;
115115
// CHECK-NEXT: 11 ++Local1;
@@ -129,7 +129,7 @@ int main(int argc, char **argv) {
129129
// CHECK-NEXT: (lldb) step
130130
// CHECK-NEXT: Process {{.*}} stopped
131131
// CHECK-NEXT: * thread #1, stop reason = step in
132-
// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`int Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}}
132+
// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}}
133133
// CHECK-NEXT: 10 char Local2 = Param2 + 1;
134134
// CHECK-NEXT: 11 ++Local1;
135135
// CHECK-NEXT: 12 ++Local2;

lldb/test/Shell/SymbolFile/NativePDB/stack_unwinding01.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ int main(int argc, char **argv) {
2424

2525
// CHECK: (lldb) thread backtrace
2626
// CHECK-NEXT: * thread #1, stop reason = breakpoint 1.1
27-
// CHECK-NEXT: * frame #0: {{.*}} stack_unwinding01.cpp.tmp.exe`void Struct::simple_method(this={{.*}}, a=2, b=2) at stack_unwinding01.cpp:12
27+
// CHECK-NEXT: * frame #0: {{.*}} stack_unwinding01.cpp.tmp.exe`Struct::simple_method(this={{.*}}, a=2, b=2) at stack_unwinding01.cpp:12
2828
// CHECK-NEXT: frame #1: {{.*}} stack_unwinding01.cpp.tmp.exe`main(argc={{.*}}, argv={{.*}}) at stack_unwinding01.cpp:20
2929

3030

3131
// CHECK: (lldb) thread backtrace
3232
// CHECK-NEXT: * thread #1, stop reason = breakpoint 1.1
33-
// CHECK-NEXT: * frame #0: {{.*}} stack_unwinding01.cpp.tmp.exe`void Struct::simple_method(this={{.*}}, a=3, b=2) at stack_unwinding01.cpp:12
34-
// CHECK-NEXT: frame #1: {{.*}} stack_unwinding01.cpp.tmp.exe`void Struct::simple_method(this={{.*}}, a=2, b=2) at stack_unwinding01.cpp:12
33+
// CHECK-NEXT: * frame #0: {{.*}} stack_unwinding01.cpp.tmp.exe`Struct::simple_method(this={{.*}}, a=3, b=2) at stack_unwinding01.cpp:12
34+
// CHECK-NEXT: frame #1: {{.*}} stack_unwinding01.cpp.tmp.exe`Struct::simple_method(this={{.*}}, a=2, b=2) at stack_unwinding01.cpp:12
3535
// CHECK-NEXT: frame #2: {{.*}} stack_unwinding01.cpp.tmp.exe`main(argc={{.*}}, argv={{.*}}) at stack_unwinding01.cpp:20
3636

3737
// CHECK: (lldb) thread backtrace
3838
// CHECK-NEXT: * thread #1, stop reason = breakpoint 1.1
39-
// CHECK-NEXT: * frame #0: {{.*}} stack_unwinding01.cpp.tmp.exe`void Struct::simple_method(this={{.*}}, a=4, b=2) at stack_unwinding01.cpp:12
40-
// CHECK-NEXT: frame #1: {{.*}} stack_unwinding01.cpp.tmp.exe`void Struct::simple_method(this={{.*}}, a=3, b=2) at stack_unwinding01.cpp:12
41-
// CHECK-NEXT: frame #2: {{.*}} stack_unwinding01.cpp.tmp.exe`void Struct::simple_method(this={{.*}}, a=2, b=2) at stack_unwinding01.cpp:12
39+
// CHECK-NEXT: * frame #0: {{.*}} stack_unwinding01.cpp.tmp.exe`Struct::simple_method(this={{.*}}, a=4, b=2) at stack_unwinding01.cpp:12
40+
// CHECK-NEXT: frame #1: {{.*}} stack_unwinding01.cpp.tmp.exe`Struct::simple_method(this={{.*}}, a=3, b=2) at stack_unwinding01.cpp:12
41+
// CHECK-NEXT: frame #2: {{.*}} stack_unwinding01.cpp.tmp.exe`Struct::simple_method(this={{.*}}, a=2, b=2) at stack_unwinding01.cpp:12
4242
// CHECK-NEXT: frame #3: {{.*}} stack_unwinding01.cpp.tmp.exe`main(argc={{.*}}, argv={{.*}}) at stack_unwinding01.cpp:20

lldb/test/Shell/SymbolFile/PDB/function-nested-block.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ RUN: lldb-test symbols -find=function -file FunctionNestedBlockTest.cpp -line 4
44
RUN: lldb-test symbols -find=block -file FunctionNestedBlockTest.cpp -line 4 %t.exe | FileCheck --check-prefix=CHECK-BLOCK %s
55

66
CHECK-FUNCTION: Found 1 functions:
7-
CHECK-FUNCTION: name = "main"
7+
CHECK-FUNCTION: name = "{{.*}}", mangled = "{{_?}}main"
88

99
CHECK-BLOCK: Found 1 blocks:
1010
CHECK-BLOCK: Blocks: id = {{.*}}, range = {{.*}}

0 commit comments

Comments
 (0)