[Lldb-commits] [PATCH] D87173: Ignores functions that have a range starting outside of a code section
António Afonso via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Sep 4 17:03:07 PDT 2020
aadsm created this revision.
aadsm added reviewers: clayborg, labath.
Herald added a reviewer: shafik.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
aadsm requested review of this revision.
Herald added a subscriber: JDevlieghere.
This is a similar patch to https://reviews.llvm.org/D87172. Greg said we should also do it for functions.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D87173
Files:
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/unittests/SymbolFile/DWARF/Inputs/test-invalid-offsets.yaml
lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
Index: lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
===================================================================
--- lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
+++ lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
@@ -35,14 +35,16 @@
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/DataEncoder.h"
#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Reproducer.h"
#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
class SymbolFileDWARFTests : public testing::Test {
- SubsystemRAII<FileSystem, HostInfo, ObjectFilePECOFF, ObjectFileMachO,
- SymbolFileDWARF, TypeSystemClang, SymbolFilePDB>
+ SubsystemRAII<repro::Reproducer, FileSystem, HostInfo, ObjectFilePECOFF,
+ ObjectFileMachO, SymbolFileDWARF, TypeSystemClang,
+ SymbolFilePDB>
subsystems;
public:
@@ -367,3 +369,27 @@
ASSERT_NE(section_sp.get(), nullptr);
EXPECT_EQ(section_sp->GetType(), eSectionTypeCode);
}
+
+TEST_F(SymbolFileDWARFTests, EnsureAllParseFunctionsExistInCodeSections) {
+ auto ExpectedFile = TestFile::fromYamlFile("test-invalid-offsets.yaml");
+ ASSERT_THAT_EXPECTED(ExpectedFile, llvm::Succeeded());
+
+ lldb::ModuleSP module_sp =
+ std::make_shared<Module>(ExpectedFile->moduleSpec());
+ SymbolFile *symfile = module_sp->GetSymbolFile();
+ ASSERT_NE(symfile, nullptr);
+
+ SymbolContextList sc_list;
+ RegularExpression regex(".");
+ symfile->FindFunctions(regex, false, sc_list);
+ ASSERT_EQ(sc_list.GetSize(), 1U);
+
+ SymbolContext sc;
+ sc_list.GetContextAtIndex(0, sc);
+ EXPECT_STREQ(sc.function->GetName().AsCString(), "main");
+
+ auto section_sp =
+ sc.function->GetAddressRange().GetBaseAddress().GetSection();
+ ASSERT_NE(section_sp.get(), nullptr);
+ EXPECT_EQ(section_sp->GetType(), eSectionTypeCode);
+}
Index: lldb/unittests/SymbolFile/DWARF/Inputs/test-invalid-offsets.yaml
===================================================================
--- lldb/unittests/SymbolFile/DWARF/Inputs/test-invalid-offsets.yaml
+++ lldb/unittests/SymbolFile/DWARF/Inputs/test-invalid-offsets.yaml
@@ -408,8 +408,8 @@
- Value: 0x0000000100000F80
- Value: 0x0000000000000030
- AbbrCode: 0x00000002
- Values:
- - Value: 0x0000000100000F80
+ Values: # DW_TAG_subprogram foo
+ - Value: 0x0000000000000F80 # DW_AT_low_pc points to invalid loc
- Value: 0x000000000000000B
- Value: 0x0000000000000001
BlockData: [ 0x56 ]
@@ -420,7 +420,7 @@
- Value: 0x000000000000006F
- Value: 0x0000000000000001
- AbbrCode: 0x00000003
- Values:
+ Values: # DW_TAG_subprogram main
- Value: 0x0000000100000F90
- Value: 0x0000000000000020
- Value: 0x0000000000000001
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2262,7 +2262,9 @@
func_range.SetByteSize(highest_func_addr - lowest_func_addr);
}
- if (func_range.GetBaseAddress().IsValid()) {
+ auto base_address = func_range.GetBaseAddress();
+ if (base_address.IsSectionOffset() &&
+ base_address.GetSection()->GetType() == eSectionTypeCode) {
Mangled func_name;
if (mangled)
func_name.SetValue(ConstString(mangled), true);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87173.290050.patch
Type: text/x-patch
Size: 3741 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200905/85ca8a5b/attachment.bin>
More information about the lldb-commits
mailing list