[Lldb-commits] [PATCH] D87051: scan-build-py: fix multiprocessing error

2020-09-05 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0c642828612d: scan-build-py: fix multiprocessing error 
(authored by lawrence_danna).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87051/new/

https://reviews.llvm.org/D87051

Files:
  clang/tools/scan-build-py/bin/analyze-build
  clang/tools/scan-build-py/bin/intercept-build
  clang/tools/scan-build-py/bin/scan-build


Index: clang/tools/scan-build-py/bin/scan-build
===
--- clang/tools/scan-build-py/bin/scan-build
+++ clang/tools/scan-build-py/bin/scan-build
@@ -5,12 +5,13 @@
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 import multiprocessing
-multiprocessing.freeze_support()
-
 import sys
 import os.path
 this_dir = os.path.dirname(os.path.realpath(__file__))
 sys.path.append(os.path.dirname(this_dir))
 
 from libscanbuild.analyze import scan_build
-sys.exit(scan_build())
+
+if __name__ == '__main__':
+multiprocessing.freeze_support()
+sys.exit(scan_build())
Index: clang/tools/scan-build-py/bin/intercept-build
===
--- clang/tools/scan-build-py/bin/intercept-build
+++ clang/tools/scan-build-py/bin/intercept-build
@@ -5,12 +5,13 @@
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 import multiprocessing
-multiprocessing.freeze_support()
-
 import sys
 import os.path
 this_dir = os.path.dirname(os.path.realpath(__file__))
 sys.path.append(os.path.dirname(this_dir))
 
 from libscanbuild.intercept import intercept_build
-sys.exit(intercept_build())
+
+if __name__ == '__main__':
+multiprocessing.freeze_support()
+sys.exit(intercept_build())
Index: clang/tools/scan-build-py/bin/analyze-build
===
--- clang/tools/scan-build-py/bin/analyze-build
+++ clang/tools/scan-build-py/bin/analyze-build
@@ -5,12 +5,13 @@
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 import multiprocessing
-multiprocessing.freeze_support()
-
 import sys
 import os.path
 this_dir = os.path.dirname(os.path.realpath(__file__))
 sys.path.append(os.path.dirname(this_dir))
 
 from libscanbuild.analyze import analyze_build
-sys.exit(analyze_build())
+
+if __name__ == '__main__':
+multiprocessing.freeze_support()
+sys.exit(analyze_build())


Index: clang/tools/scan-build-py/bin/scan-build
===
--- clang/tools/scan-build-py/bin/scan-build
+++ clang/tools/scan-build-py/bin/scan-build
@@ -5,12 +5,13 @@
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 import multiprocessing
-multiprocessing.freeze_support()
-
 import sys
 import os.path
 this_dir = os.path.dirname(os.path.realpath(__file__))
 sys.path.append(os.path.dirname(this_dir))
 
 from libscanbuild.analyze import scan_build
-sys.exit(scan_build())
+
+if __name__ == '__main__':
+multiprocessing.freeze_support()
+sys.exit(scan_build())
Index: clang/tools/scan-build-py/bin/intercept-build
===
--- clang/tools/scan-build-py/bin/intercept-build
+++ clang/tools/scan-build-py/bin/intercept-build
@@ -5,12 +5,13 @@
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 import multiprocessing
-multiprocessing.freeze_support()
-
 import sys
 import os.path
 this_dir = os.path.dirname(os.path.realpath(__file__))
 sys.path.append(os.path.dirname(this_dir))
 
 from libscanbuild.intercept import intercept_build
-sys.exit(intercept_build())
+
+if __name__ == '__main__':
+multiprocessing.freeze_support()
+sys.exit(intercept_build())
Index: clang/tools/scan-build-py/bin/analyze-build
===
--- clang/tools/scan-build-py/bin/analyze-build
+++ clang/tools/scan-build-py/bin/analyze-build
@@ -5,12 +5,13 @@
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 import multiprocessing
-multiprocessing.freeze_support()
-
 import sys
 import os.path
 this_dir = os.path.dirname(os.path.realpath(__file__))
 sys.path.append(os.path.dirname(this_dir))
 
 from libscanbuild.analyze import analyze_build
-sys.exit(analyze_build())
+
+if __name__ == '__main__':
+multiprocessing.freeze_support()
+sys.exit(analyze_build())
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D87172: Check if debug line sequences are starting after the first code segment

2020-09-05 Thread António Afonso via Phabricator via lldb-commits
aadsm added inline comments.



Comment at: lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp:74
   // codes that start at 1, that we get O(1) access.
-  
+
   const auto byte_order = eByteOrderLittle;

clayborg wrote:
> remove whitespace only changes please. Ditto for all whitespace only changes 
> below.
Can I make an argument to allow this on diffs? Most repos have a no trailing 
whitespace rule and because of this most editors are configured to remote 
trailing whitespaces on save. I've also just checked this is the case for LLVM: 
https://llvm.org/docs/CodingStandards.html#whitespace

I can either:
1) git add -i (which is a pain), or
2) configure my editor to not remove trailing white spaces for this project 
(which I guess it should be fine since clang-format takes care of it in the end)

Doing 2) is pretty easy to me (but it also means everyone else has to do it), 
since LLVM code convention is to disallow trailing whitespaces I could split 
this into 2 diffs, one with the bug fix and another one with trailing 
whitespace removal only (so no one else has the same problem with this file in 
the future). I don't see what is the advantage of having 2 diffs (just more 
work) so that's why I'm making the case to allow removal of trailing 
whitespaces in the files of a diff.

What do you think?





Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87172/new/

https://reviews.llvm.org/D87172

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D87172: Check if debug line sequences are starting after the first code segment

2020-09-05 Thread António Afonso via Phabricator via lldb-commits
aadsm updated this revision to Diff 290112.
aadsm added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87172/new/

https://reviews.llvm.org/D87172

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
  lldb/unittests/SymbolFile/DWARF/Inputs/test-invalid-addresses.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
@@ -14,6 +14,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 
+#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
 #include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
 #include "Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h"
 #include "Plugins/SymbolFile/DWARF/DWARFDataExtractor.h"
@@ -40,8 +41,8 @@
 using namespace lldb_private;
 
 class SymbolFileDWARFTests : public testing::Test {
-  SubsystemRAII
+  SubsystemRAII
   subsystems;
 
 public:
@@ -70,7 +71,7 @@
 TEST_F(SymbolFileDWARFTests, TestAbbrevOrder1Start1) {
   // Test that if we have a .debug_abbrev that contains ordered abbreviation
   // codes that start at 1, that we get O(1) access.
-  
+
   const auto byte_order = eByteOrderLittle;
   const uint8_t addr_size = 4;
   StreamString encoder(Stream::eBinary, addr_size, byte_order);
@@ -81,7 +82,7 @@
   encoder.PutULEB128(DW_FORM_strp);
   encoder.PutULEB128(0);
   encoder.PutULEB128(0);
-  
+
   encoder.PutULEB128(2); // Abbrev code 2
   encoder.PutULEB128(DW_TAG_subprogram);
   encoder.PutHex8(DW_CHILDREN_no);
@@ -89,9 +90,9 @@
   encoder.PutULEB128(DW_FORM_strp);
   encoder.PutULEB128(0);
   encoder.PutULEB128(0);
-  
+
   encoder.PutULEB128(0); // Abbrev code 0 (termination)
- 
+
   DWARFDataExtractor data;
   data.SetData(encoder.GetData(), encoder.GetSize(), byte_order);
   DWARFAbbreviationDeclarationSet abbrev_set;
@@ -101,7 +102,7 @@
   // Make sure we have O(1) access to each abbreviation by making sure the
   // index offset is 1 and not UINT32_MAX
   EXPECT_EQ(abbrev_set.GetIndexOffset(), 1u);
-  
+
   auto abbrev1 = abbrev_set.GetAbbreviationDeclaration(1);
   EXPECT_EQ(abbrev1->Tag(), DW_TAG_compile_unit);
   EXPECT_TRUE(abbrev1->HasChildren());
@@ -115,7 +116,7 @@
 TEST_F(SymbolFileDWARFTests, TestAbbrevOrder1Start5) {
   // Test that if we have a .debug_abbrev that contains ordered abbreviation
   // codes that start at 5, that we get O(1) access.
-  
+
   const auto byte_order = eByteOrderLittle;
   const uint8_t addr_size = 4;
   StreamString encoder(Stream::eBinary, addr_size, byte_order);
@@ -126,7 +127,7 @@
   encoder.PutULEB128(DW_FORM_strp);
   encoder.PutULEB128(0);
   encoder.PutULEB128(0);
-  
+
   encoder.PutULEB128(6); // Abbrev code 6
   encoder.PutULEB128(DW_TAG_subprogram);
   encoder.PutHex8(DW_CHILDREN_no);
@@ -134,9 +135,9 @@
   encoder.PutULEB128(DW_FORM_strp);
   encoder.PutULEB128(0);
   encoder.PutULEB128(0);
-  
+
   encoder.PutULEB128(0); // Abbrev code 0 (termination)
-  
+
   DWARFDataExtractor data;
   data.SetData(encoder.GetData(), encoder.GetSize(), byte_order);
   DWARFAbbreviationDeclarationSet abbrev_set;
@@ -146,7 +147,7 @@
   // Make sure we have O(1) access to each abbreviation by making sure the
   // index offset is 5 and not UINT32_MAX
   EXPECT_EQ(abbrev_set.GetIndexOffset(), 5u);
-  
+
   auto abbrev1 = abbrev_set.GetAbbreviationDeclaration(5);
   EXPECT_EQ(abbrev1->Tag(), DW_TAG_compile_unit);
   EXPECT_TRUE(abbrev1->HasChildren());
@@ -160,7 +161,7 @@
 TEST_F(SymbolFileDWARFTests, TestAbbrevOutOfOrder) {
   // Test that if we have a .debug_abbrev that contains unordered abbreviation
   // codes, that we can access the information correctly.
-  
+
   const auto byte_order = eByteOrderLittle;
   const uint8_t addr_size = 4;
   StreamString encoder(Stream::eBinary, addr_size, byte_order);
@@ -171,7 +172,7 @@
   encoder.PutULEB128(DW_FORM_strp);
   encoder.PutULEB128(0);
   encoder.PutULEB128(0);
-  
+
   encoder.PutULEB128(1); // Abbrev code 1
   encoder.PutULEB128(DW_TAG_subprogram);
   encoder.PutHex8(DW_CHILDREN_no);
@@ -179,9 +180,9 @@
   encoder.PutULEB128(DW_FORM_strp);
   encoder.PutULEB128(0);
   encoder.PutULEB128(0);
-  
+
   encoder.PutULEB128(0); // Abbrev code 0 (termination)
-  
+
   DWARFDataExtractor data;
   data.SetData(encoder.GetData(), encoder.GetSize(), byte_order);
   DWARFAbbreviationDeclarationSet abbrev_set;
@@ -191,7 +192,7 @@
   // Make sure we don't have O(1) access to each abbreviation by making sure
   // the index offset is UINT32_MAX
   EXPECT_EQ(abbrev_set.GetIndexOffset(), UINT32_MAX);
-  
+
   auto abbrev1 = abbrev_set.GetAbbreviationDeclaration(2);
   EXPECT_EQ(abbrev1->Tag(), DW_TAG_compile_un

[Lldb-commits] [PATCH] D87173: Ignores functions that have a range starting outside of a code section

2020-09-05 Thread António Afonso via Phabricator via lldb-commits
aadsm updated this revision to Diff 290113.
aadsm added a comment.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

Check lowest code address instead of checking if the section is code.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87173/new/

https://reviews.llvm.org/D87173

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/unittests/SymbolFile/DWARF/Inputs/test-invalid-addresses.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
+  SubsystemRAII
   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(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-addresses.yaml
===
--- lldb/unittests/SymbolFile/DWARF/Inputs/test-invalid-addresses.yaml
+++ lldb/unittests/SymbolFile/DWARF/Inputs/test-invalid-addresses.yaml
@@ -420,8 +420,8 @@
 - Value:   0x00010F80
 - Value:   0x0030
 - AbbrCode:0x0002
-  Values:
-- Value:   0x00010F80
+  Values: # DW_TAG_subprogram foo
+- Value:   0x0F80 # DW_AT_low_pc points to invalid loc
 - Value:   0x000B
 - Value:   0x0001
   BlockData:   [ 0x56 ]
@@ -432,7 +432,7 @@
 - Value:   0x006F
 - Value:   0x0001
 - AbbrCode:0x0003
-  Values:
+  Values: # DW_TAG_subprogram main
 - Value:   0x00010F90
 - Value:   0x0020
 - Value:   0x0001
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -779,7 +779,8 @@
   if (!dwarf_ast)
 return nullptr;
 
-  return dwarf_ast->ParseFunctionFromDWARF(comp_unit, die);
+  return dwarf_ast->ParseFunctionFromDWARF(comp_unit, die,
+   m_first_code_address);
 }
 
 lldb::addr_t SymbolFileDWARF::FixupAddress(lldb::addr_t file_addr) {
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -47,7 +47,8 @@
 
   lldb_private::Function *
   ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit,
- const DWARFDIE &die) override;
+ const DWARFDIE &die,
+ lldb::addr_t first_code_address) override;
 
   bool
   CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type,
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2226,8 +2226,10 @@
   retur