[Lldb-commits] [lldb] 48acece - [lldb][NFC] Cleanup ClangASTImporter::LayoutInfo

2020-01-31 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-01-31T09:06:09+01:00
New Revision: 48acece15dcf63cb4fee043a4e66ddf3917a359a

URL: 
https://github.com/llvm/llvm-project/commit/48acece15dcf63cb4fee043a4e66ddf3917a359a
DIFF: 
https://github.com/llvm/llvm-project/commit/48acece15dcf63cb4fee043a4e66ddf3917a359a.diff

LOG: [lldb][NFC] Cleanup ClangASTImporter::LayoutInfo

Added: 


Modified: 
lldb/include/lldb/Symbol/ClangASTImporter.h

Removed: 




diff  --git a/lldb/include/lldb/Symbol/ClangASTImporter.h 
b/lldb/include/lldb/Symbol/ClangASTImporter.h
index bfdb929119cb..fed49d3b13dd 100644
--- a/lldb/include/lldb/Symbol/ClangASTImporter.h
+++ b/lldb/include/lldb/Symbol/ClangASTImporter.h
@@ -33,15 +33,15 @@ namespace lldb_private {
 class ClangASTImporter {
 public:
   struct LayoutInfo {
-LayoutInfo()
-: bit_size(0), alignment(0), field_offsets(), base_offsets(),
-  vbase_offsets() {}
-uint64_t bit_size;
-uint64_t alignment;
+LayoutInfo() = default;
+typedef llvm::DenseMap
+OffsetMap;
+
+uint64_t bit_size = 0;
+uint64_t alignment = 0;
 llvm::DenseMap field_offsets;
-llvm::DenseMap 
base_offsets;
-llvm::DenseMap
-vbase_offsets;
+OffsetMap base_offsets;
+OffsetMap vbase_offsets;
   };
 
   ClangASTImporter()



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


[Lldb-commits] [PATCH] D73517: [lldb] Delete ValueObject::GetBaseClassPath

2020-01-31 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/Core/ValueObject.cpp:2041
 
 void ValueObject::GetExpressionPath(Stream &s, bool qualify_cxx_base_classes,
 GetExpressionPathFormat epformat) {

xiaobai wrote:
> labath wrote:
> > Should we remove the `qualify_cxx_base_classes` argument as well, given 
> > that it no longer does anything ?
> It seems that this is a part of the SBValue interface. I think we can remove 
> it from ValueObject but SBValue will have to stick with it.
That sounds reasonable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73517



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


[Lldb-commits] [PATCH] D73661: [lldb] Move clang-based files out of Symbol

2020-01-31 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

This looks good to me, and I believe everyone else also felt the same way. 
There are still some loops here (TypeSystemClang<->SymbolFileDWARF/PDB), but I 
think those could be broken fairly easily. This is not a problem of this patch, 
and it can be handled later..




Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:37
 
+#include "Plugins/ExpressionParser/Clang//ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"

remove one `/`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73661



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


[Lldb-commits] [lldb] 46ca55f - [lldb][NFC] Add safe Decl->CompilerDecl conversion function TypeSystemClang

2020-01-31 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-01-31T09:44:24+01:00
New Revision: 46ca55f2a2c88609657dff7f49ec54d5a71032d3

URL: 
https://github.com/llvm/llvm-project/commit/46ca55f2a2c88609657dff7f49ec54d5a71032d3
DIFF: 
https://github.com/llvm/llvm-project/commit/46ca55f2a2c88609657dff7f49ec54d5a71032d3.diff

LOG: [lldb][NFC] Add safe Decl->CompilerDecl conversion function TypeSystemClang

This adds a conversion function from clang::Decl to CompilerDecl. It checks
that the TypeSystemClang in the CompilerDecl actually fits to the clang::Decl
AST during creation, thus preventing the creation of CompilerDecl instances with
inconsistent state.

Added: 


Modified: 
lldb/include/lldb/Symbol/TypeSystemClang.h
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Symbol/TypeSystemClang.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/TypeSystemClang.h 
b/lldb/include/lldb/Symbol/TypeSystemClang.h
index 9d4d5e56a4fa..fd8276dbf3dc 100644
--- a/lldb/include/lldb/Symbol/TypeSystemClang.h
+++ b/lldb/include/lldb/Symbol/TypeSystemClang.h
@@ -407,6 +407,16 @@ class TypeSystemClang : public TypeSystem {
   llvm::DenseMap
   &vbase_offsets);
 
+  /// Creates a CompilerDecl from the given Decl with the current
+  /// TypeSystemClang instance as its typesystem.
+  /// The Decl has to come from the ASTContext of this
+  /// TypeSystemClang.
+  CompilerDecl GetCompilerDecl(clang::Decl *decl) {
+assert(&decl->getASTContext() == &getASTContext() &&
+   "CreateCompilerDecl for Decl from wrong ASTContext?");
+return CompilerDecl(this, decl);
+  }
+
   // CompilerDecl override functions
   ConstString DeclGetName(void *opaque_decl) override;
 

diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index c6eb45169da3..cc3b4ed0cd04 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -384,7 +384,7 @@ ClangModulesDeclVendorImpl::FindDecls(ConstString name, 
bool append,
 if (num_matches >= max_matches)
   return num_matches;
 
-decls.push_back(CompilerDecl(m_ast_context.get(), named_decl));
+decls.push_back(m_ast_context->GetCompilerDecl(named_decl));
 ++num_matches;
   }
 

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
index bdc5c315da60..2701f5b3a45e 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
@@ -583,7 +583,7 @@ uint32_t AppleObjCDeclVendor::FindDecls(ConstString name, 
bool append,
current_id, result_iface_type.getAsString(), isa_value);
 }
 
-decls.push_back(CompilerDecl(&m_ast_ctx, result_iface_decl));
+decls.push_back(m_ast_ctx.GetCompilerDecl(result_iface_decl));
 ret++;
 break;
   } else {
@@ -626,7 +626,7 @@ uint32_t AppleObjCDeclVendor::FindDecls(ConstString name, 
bool append,
new_iface_type.getAsString(), (uint64_t)isa);
 }
 
-decls.push_back(CompilerDecl(&m_ast_ctx, iface_decl));
+decls.push_back(m_ast_ctx.GetCompilerDecl(iface_decl));
 ret++;
 break;
   } while (false);

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 468603c35cce..39d4b370bc3c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2182,7 +2182,7 @@ void 
DWARFASTParserClang::EnsureAllDIEsInDeclContextHaveBeenParsed(
 CompilerDecl DWARFASTParserClang::GetDeclForUIDFromDWARF(const DWARFDIE &die) {
   clang::Decl *clang_decl = GetClangDeclForDIE(die);
   if (clang_decl != nullptr)
-return CompilerDecl(&m_ast, clang_decl);
+return m_ast.GetCompilerDecl(clang_decl);
   return CompilerDecl();
 }
 

diff  --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp 
b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
index d06d542472d0..806f7b60bfff 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -1334,7 +1334,7 @@ void 
PdbAstBuilder::ParseDeclsForContext(clang::DeclContext &context) {
 }
 
 CompilerDecl PdbAstBuilder::ToCompilerDecl(clang::D

[Lldb-commits] [PATCH] D73767: [lldb] [test] Respect LLVM_LIBDIR_SUFFIX when linking liblldb

2020-01-31 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, beanz.

Pass LLVM_LIBDIR_SUFFIX over to dotest, and append it to 'lib' when
linking liblldb.  This fixes link failures when tests are run within
stand-alone builds on systems where LLVM_LIBDIR_SUFFIX is not empty.


https://reviews.llvm.org/D73767

Files:
  lldb/packages/Python/lldbsuite/test/configuration.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/dotest_args.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/lit.cfg.py
  lldb/test/API/lit.site.cfg.py.in


Index: lldb/test/API/lit.site.cfg.py.in
===
--- lldb/test/API/lit.site.cfg.py.in
+++ lldb/test/API/lit.site.cfg.py.in
@@ -10,6 +10,7 @@
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.lldb_obj_root = "@LLDB_BINARY_DIR@"
 config.lldb_src_root = "@LLDB_SOURCE_DIR@"
+config.libdir_suffix = "@LLVM_LIBDIR_SUFFIX@"
 config.cmake_cxx_compiler = "@CMAKE_CXX_COMPILER@"
 config.host_os = "@HOST_OS@"
 config.host_triple = "@LLVM_HOST_TRIPLE@"
Index: lldb/test/API/lit.cfg.py
===
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py
@@ -114,6 +114,9 @@
 if config.filecheck:
   dotest_cmd += ['--filecheck', config.filecheck]
 
+if config.libdir_suffix:
+  dotest_cmd += ['--libdir-suffix', config.libdir_suffix]
+
 # We don't want to force users passing arguments to lit to use `;` as a
 # separator. We use Python's simple lexical analyzer to turn the args into a
 # list. Pass there arguments last so they can override anything that was
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1426,7 +1426,9 @@
  os.path.join(
  os.environ["LLDB_SRC"],
  "include")),
-'LD_EXTRAS': "-L%s/../lib -llldb -Wl,-rpath,%s/../lib" % 
(lib_dir, lib_dir)}
+'LD_EXTRAS': "-L%s/../lib%s -llldb -Wl,-rpath,%s/../lib%s" % (
+lib_dir, configuration.libdir_suffix,
+lib_dir, configuration.libdir_suffix)}
 if self.TraceOn():
 print(
 "Building LLDB Driver (%s) from sources %s" %
Index: lldb/packages/Python/lldbsuite/test/dotest_args.py
===
--- lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -172,6 +172,11 @@
 dest='clang_module_cache_dir',
 metavar='The clang module cache directory used by Clang',
 help='The clang module cache directory used in the Make files by Clang 
while building tests. Defaults to /module-cache-clang.')
+group.add_argument(
+'--libdir-suffix',
+dest='libdir_suffix',
+metavar='suffix',
+help='The suffix appended to "lib" directory, e.g. "64"')
 
 # Configuration options
 group = parser.add_argument_group('Remote platform options')
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -452,6 +452,9 @@
 
 os.environ['CLANG_MODULE_CACHE_DIR'] = configuration.clang_module_cache_dir
 
+if args.libdir_suffix:
+configuration.libdir_suffix = args.libdir_suffix
+
 # Gather all the dirs passed on the command line.
 if len(args.args) > 0:
 configuration.testdirs = [os.path.realpath(os.path.abspath(x)) for x 
in args.args]
Index: lldb/packages/Python/lldbsuite/test/configuration.py
===
--- lldb/packages/Python/lldbsuite/test/configuration.py
+++ lldb/packages/Python/lldbsuite/test/configuration.py
@@ -136,6 +136,10 @@
 # same base name.
 all_tests = set()
 
+# The suffix appended to 'lib' directory, used to find LLDB library.
+libdir_suffix = ''
+
+
 def shouldSkipBecauseOfCategories(test_categories):
 if use_categories:
 if len(test_categories) == 0 or len(


Index: lldb/test/API/lit.site.cfg.py.in
===
--- lldb/test/API/lit.site.cfg.py.in
+++ lldb/test/API/lit.site.cfg.py.in
@@ -10,6 +10,7 @@
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.lldb_obj_root = "@LLDB_BINARY_DIR@"
 config.lldb_src_root = "@LLDB_SOURCE_DIR@"
+config.libdir_suffix = "@LLVM_LIBDIR_SUFFIX@"
 config.cmake_cxx_compiler = "@CMAKE_CXX_COMPILER@"
 config.host_os = "@HOST_OS@"
 config.host_triple = "@LLVM_HOST_TRIPLE@"
Index: lldb/test/API/lit.cfg.py

[Lldb-commits] [PATCH] D73594: Refactor CommandObjectTargetSymbolsAdd::AddModuleSymbols

2020-01-31 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.

In D73594#1851044 , @clayborg wrote:

> Looks reasonable to me. Any objections from anyone else? We do have tests for 
> this right?


LGTM too. There are tests for this command already, but of course, we could 
always use a bunch more, particularly for the "error" cases...


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

https://reviews.llvm.org/D73594



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


[Lldb-commits] [PATCH] D70847: [lldb] Set executable module when adding modules to the Target

2020-01-31 Thread Anton Kolesov via Phabricator via lldb-commits
anton.kolesov added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/commands/target/set-exec/TestSetExecutable.py:16
+"""Test adding images to the target."""
+self.build()
+

clayborg wrote:
> Create a yaml file and put it in the same directory as this file. Change this 
> line to be:
> ```
> src_dir = self.getSourceDir()
> yaml_path = os.path.join(src_dir, "a.yaml")
> obj_path = self.getBuildArtifact("a.out")
> self.yaml2obj(yaml_path, obj_path)
> ```
> Make an ELF file that that is for a remote platform where the triple and 
> platform won't match typical hosts.
Do you have any specific suggestions that also have freely available toolchain? 
I have immediate access only to Windows/Linux x86 and Synopsys ARC, and ARC elf 
files don't change the platform - it remains as "host" even when connecting to 
a GDB-server, plus obj2yaml segfaults on ARC elf files.



Comment at: 
lldb/packages/Python/lldbsuite/test/commands/target/set-exec/TestSetExecutable.py:21
+self.assertTrue(target, VALID_TARGET)
+self.assertEqual(len(target.GetTriple()), 0)
+

clayborg wrote:
> Don't know if I would run this assert here. I could see a target that is 
> created with nothing possibly using the host architecture and host platform 
> by default. So maybe remote this assert where the target triple is not set.
As far as I can understand from the `TargetList::CreateTargetInternal`, new 
target will not inherit architecture from the platform when exe file is not 
specified and neither architecture nor platform are given explicitly. So it 
seems that assuming that triplet will be empty is safe.



Comment at: 
lldb/packages/Python/lldbsuite/test/commands/target/set-exec/TestSetExecutable.py:26
+target.AddModule(self.getBuildArtifact("a.out"), None, None)
+self.assertNotEqual(len(target.GetTriple()), 0)

clayborg wrote:
> Check the exact triple of the remote executable you end up adding.
> 
> Also add a check that the platform gets updated. Platforms must be compatible 
> with the architecture of the target's main executable, so it is good to 
> verify that the platform gets updated as well. Something like:
> 
> ```
> platform = target.GetPlatform()
> set.assertEqual(platform.GetName(), "remote-linux")
> ```
> 
> This will make this test complete. If the platform isn't right we will need 
> to fix this as well.
The platform doesn't change with the current code. 
`Target::SetExecutableModule` does direct assignment of architecture and 
doesn't touch the platform, so this is needed:

```
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1405,7 +1405,7 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
 // If we haven't set an architecture yet, reset our architecture based on
 // what we found in the executable module.
 if (!m_arch.GetSpec().IsValid()) {
-  m_arch = executable_sp->GetArchitecture();
+  SetArchitecture(executable_sp->GetArchitecture(), true);
   LLDB_LOG(log,
"setting architecture to {0} ({1}) based on executable file",
m_arch.GetSpec().GetArchitectureName(),
```

It works for me in the test case, but I wonder if `SetArchitecture` wasn't used 
there in the first place for a good reason.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70847



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


[Lldb-commits] [PATCH] D73279: testsuite: generalize `DWARFASTParserClangTests` based on `DWARFExpressionTest`'s YAML

2020-01-31 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D73279#1851068 , @jankratochvil 
wrote:

> But then maybe it also needs:
>
>   # Our current version of gtest does not properly recognize C++11 support
>   # with MSVC, so it falls back to tr1 / experimental classes.  Since LLVM
>   # itself requires C++11, we can safely force it on unconditionally so that
>   # we don't have to fight with the buggy gtest check.
>   add_definitions(-DGTEST_LANG_CXX11=1)
>   add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
>   
>
> as being used in such cases in cmakefiles in llvm/ but on Linux I do not see 
> if it is really needed here or not.


That might explain the warnings I have seen when building with msvc the other 
day. It might good to add those too.




Comment at: lldb/unittests/TestingSupport/CMakeLists.txt:4
   MockTildeExpressionResolver.cpp
+  Symbol/YAMLModuleTester.cpp
   TestUtilities.cpp

The idea was then that this would be a separate library (`lldbSymbolHelpers`) 
with its own CMakeLists.txt and everything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73279



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


[Lldb-commits] [PATCH] D70646: Move non-DWARF code: `DWARFUnit` -> `SymbolFileDWARF`

2020-01-31 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

Looks great, modulo the inline comment.




Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:3987-4008
+  DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU());
+  if (dwarf_ast)
+return dwarf_ast->GetDeclForUIDFromDWARF(die);
+  else
+return CompilerDecl();
+}
+

[[ http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return | 
Don't use else after return ]]. In fact, you might as well fold the 
GetDWARFParser call into the if condition (`if (DWARFASTParser *parser = ...) 
parser->...`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70646



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


[Lldb-commits] [PATCH] D73766: [RFC] Make substrs argument to self.expect ordered by default.

2020-01-31 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I think this is great, but do we really need the extra `ordered` argument for 
this? If you just fix the order of everything beforehand, then the switch to an 
ordered mode can be a no-op.


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

https://reviews.llvm.org/D73766



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


[Lldb-commits] [lldb] 99e63f5 - [lldb] Print the command output when 'expect' fails even if a custom msg is passed

2020-01-31 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-01-31T10:16:46+01:00
New Revision: 99e63f5825ac30912bab1daa563cae9e6c292d52

URL: 
https://github.com/llvm/llvm-project/commit/99e63f5825ac30912bab1daa563cae9e6c292d52
DIFF: 
https://github.com/llvm/llvm-project/commit/99e63f5825ac30912bab1daa563cae9e6c292d52.diff

LOG: [lldb] Print the command output when 'expect' fails even if a custom msg 
is passed

Currently if 'expect' fails and a custom msg is supplied, then lldbtest
will not print the actual command output. This makes it impossible to know
why the test actually failed. This just prints the command output even
if the msg parameter was supplied.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 2b83d26d234a..602749c80fa8 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2364,7 +2364,8 @@ def expect(
 break
 
 self.assertTrue(matched if matching else not matched,
-msg if msg else EXP_MSG(str, output, exe))
+msg + "\nCommand output:\n" + EXP_MSG(str, output, exe)
+if msg else EXP_MSG(str, output, exe))
 
 def expect_expr(
 self,



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


[Lldb-commits] [PATCH] D73766: [RFC] Make substrs argument to self.expect ordered by default.

2020-01-31 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

FWIW I'm currently going over the failing tests and fixing them, so unless I 
find a test that actually needs unordered subsets I don't think having the 
parameter makes sense.


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

https://reviews.llvm.org/D73766



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


[Lldb-commits] [PATCH] D73767: [lldb] [test] Respect LLVM_LIBDIR_SUFFIX when linking liblldb

2020-01-31 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

If we go down this path, then I think we should just pass the full path to the 
lib directory, and remove all the code which tries to autodetect it.

But if you're looking for a quick fix, I think adding "netbsd" to the list of 
operating systems at dotest.py:625 should fix this problem.


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

https://reviews.llvm.org/D73767



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


[Lldb-commits] [PATCH] D70847: [lldb] Set executable module when adding modules to the Target

2020-01-31 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/commands/target/set-exec/TestSetExecutable.py:16
+"""Test adding images to the target."""
+self.build()
+

anton.kolesov wrote:
> clayborg wrote:
> > Create a yaml file and put it in the same directory as this file. Change 
> > this line to be:
> > ```
> > src_dir = self.getSourceDir()
> > yaml_path = os.path.join(src_dir, "a.yaml")
> > obj_path = self.getBuildArtifact("a.out")
> > self.yaml2obj(yaml_path, obj_path)
> > ```
> > Make an ELF file that that is for a remote platform where the triple and 
> > platform won't match typical hosts.
> Do you have any specific suggestions that also have freely available 
> toolchain? I have immediate access only to Windows/Linux x86 and Synopsys 
> ARC, and ARC elf files don't change the platform - it remains as "host" even 
> when connecting to a GDB-server, plus obj2yaml segfaults on ARC elf files.
Would this do the job?
```
--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:ELFDATA2LSB
  Type:ET_DYN
  Machine: EM_AARCH64
  Entry:   0x06C0
Sections:
  - Name:.text
Type:SHT_PROGBITS
Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x06C0
AddressAlign:0x0008
Content: DEADBEEF
...
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70847



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


[Lldb-commits] [PATCH] D73767: [lldb] [test] Respect LLVM_LIBDIR_SUFFIX when linking liblldb

2020-01-31 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

I'm actually trying to make 10.0.0 a little less broken for Gentoo.


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

https://reviews.llvm.org/D73767



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


[Lldb-commits] [PATCH] D73767: [lldb] [test] Respect LLVM_LIBDIR_SUFFIX when linking liblldb

2020-01-31 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Aha, I see. Could you then simply pass LLDB_LIBS_DIR instead of just the suffix?


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

https://reviews.llvm.org/D73767



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


[Lldb-commits] [PATCH] D73767: [lldb] [test] Pass LLVM_LIBS_DIR from CMake for linking liblldb

2020-01-31 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 241672.
mgorny retitled this revision from "[lldb] [test] Respect LLVM_LIBDIR_SUFFIX 
when linking liblldb" to "[lldb] [test] Pass LLVM_LIBS_DIR from CMake for 
linking liblldb".
mgorny edited the summary of this revision.
mgorny added a comment.

The question is, does this break any of the platform hacks? ;-)


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

https://reviews.llvm.org/D73767

Files:
  lldb/packages/Python/lldbsuite/test/configuration.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/dotest_args.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/lit.cfg.py
  lldb/test/API/lit.site.cfg.py.in

Index: lldb/test/API/lit.site.cfg.py.in
===
--- lldb/test/API/lit.site.cfg.py.in
+++ lldb/test/API/lit.site.cfg.py.in
@@ -10,6 +10,7 @@
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.lldb_obj_root = "@LLDB_BINARY_DIR@"
 config.lldb_src_root = "@LLDB_SOURCE_DIR@"
+config.lldb_libs_dir = "@LLDB_LIBS_DIR@"
 config.cmake_cxx_compiler = "@CMAKE_CXX_COMPILER@"
 config.host_os = "@HOST_OS@"
 config.host_triple = "@LLVM_HOST_TRIPLE@"
Index: lldb/test/API/lit.cfg.py
===
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py
@@ -114,6 +114,9 @@
 if config.filecheck:
   dotest_cmd += ['--filecheck', config.filecheck]
 
+if config.lldb_libs_dir:
+  dotest_cmd += ['--lldb-libs-dir', config.lldb_libs_dir]
+
 # We don't want to force users passing arguments to lit to use `;` as a
 # separator. We use Python's simple lexical analyzer to turn the args into a
 # list. Pass there arguments last so they can override anything that was
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1399,7 +1399,7 @@
 stdflag = self.getstdFlag()
 stdlibflag = self.getstdlibFlag()
 
-lib_dir = os.environ["LLDB_LIB_DIR"]
+lib_dir = configuration.lldb_libs_dir
 if self.hasDarwinFramework():
 d = {'CXX_SOURCES': sources,
  'EXE': exe_name,
@@ -1426,7 +1426,7 @@
  os.path.join(
  os.environ["LLDB_SRC"],
  "include")),
-'LD_EXTRAS': "-L%s/../lib -llldb -Wl,-rpath,%s/../lib" % (lib_dir, lib_dir)}
+'LD_EXTRAS': "-L%s -llldb -Wl,-rpath,%s" % (lib_dir, lib_dir)}
 if self.TraceOn():
 print(
 "Building LLDB Driver (%s) from sources %s" %
@@ -1439,7 +1439,7 @@
 
 stdflag = self.getstdFlag()
 
-lib_dir = os.environ["LLDB_LIB_DIR"]
+lib_dir = configuration.lldb_libs_dir
 if self.hasDarwinFramework():
 d = {'DYLIB_CXX_SOURCES': sources,
  'DYLIB_NAME': lib_name,
@@ -1464,7 +1464,7 @@
 os.path.join(
 os.environ["LLDB_SRC"],
 "include")),
-'LD_EXTRAS': "-shared -L%s/../lib -llldb -Wl,-rpath,%s/../lib" % (lib_dir, lib_dir)}
+'LD_EXTRAS': "-shared -L%s -llldb -Wl,-rpath,%s" % (lib_dir, lib_dir)}
 if self.TraceOn():
 print(
 "Building LLDB Library (%s) from sources %s" %
@@ -1677,7 +1677,7 @@
 """
 existing_library_path = os.environ[
 self.dylibPath] if self.dylibPath in os.environ else None
-lib_dir = os.environ["LLDB_LIB_DIR"]
+lib_dir = configuration.lldb_libs_dir
 if existing_library_path:
 return "%s:%s" % (existing_library_path, lib_dir)
 elif sys.platform.startswith("darwin"):
Index: lldb/packages/Python/lldbsuite/test/dotest_args.py
===
--- lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -172,6 +172,11 @@
 dest='clang_module_cache_dir',
 metavar='The clang module cache directory used by Clang',
 help='The clang module cache directory used in the Make files by Clang while building tests. Defaults to /module-cache-clang.')
+group.add_argument(
+'--lldb-libs-dir',
+dest='lldb_libs_dir',
+metavar='path',
+help='The path to LLDB library directory (containing liblldb)')
 
 # Configuration options
 group = parser.add_argument_group('Remote platform options')
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsu

[Lldb-commits] [lldb] 19f1ce6 - [lldb][NFC] Remove ParserVars::m_parser_type member that was never read

2020-01-31 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-01-31T12:54:01+01:00
New Revision: 19f1ce67353c197ab86039bcc15c3ebca02cbaea

URL: 
https://github.com/llvm/llvm-project/commit/19f1ce67353c197ab86039bcc15c3ebca02cbaea
DIFF: 
https://github.com/llvm/llvm-project/commit/19f1ce67353c197ab86039bcc15c3ebca02cbaea.diff

LOG: [lldb][NFC] Remove ParserVars::m_parser_type member that was never read

We only assign values to this member but never read it. Also the
type in there has no side effects so let's just remove it.

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h

Removed: 




diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index 46d654493525..c776043f6b36 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -231,7 +231,6 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const 
NamedDecl *decl,
 var->GetParserVars(GetParserID());
 
 parser_vars->m_named_decl = decl;
-parser_vars->m_parser_type = parser_type;
 
 var->EnableJITVars(GetParserID());
 
@@ -305,7 +304,6 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const 
NamedDecl *decl,
   var->GetParserVars(GetParserID());
 
   parser_vars->m_named_decl = decl;
-  parser_vars->m_parser_type = parser_type;
 
   return true;
 }
@@ -1611,7 +1609,6 @@ void 
ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
   entity->EnableParserVars(GetParserID());
   ClangExpressionVariable::ParserVars *parser_vars =
   entity->GetParserVars(GetParserID());
-  parser_vars->m_parser_type = pt;
   parser_vars->m_named_decl = var_decl;
   parser_vars->m_llvm_value = nullptr;
   parser_vars->m_lldb_value = var_location;
@@ -1650,7 +1647,6 @@ void 
ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
   ClangExpressionVariable::ParserVars *parser_vars =
   llvm::cast(pvar_sp.get())
   ->GetParserVars(GetParserID());
-  parser_vars->m_parser_type = parser_type;
   parser_vars->m_named_decl = var_decl;
   parser_vars->m_llvm_value = nullptr;
   parser_vars->m_lldb_value.Clear();
@@ -1704,7 +1700,6 @@ void 
ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
   parser_vars->m_lldb_value.GetScalar() = symbol_load_addr;
   parser_vars->m_lldb_value.SetValueType(Value::eValueTypeLoadAddress);
 
-  parser_vars->m_parser_type = parser_type;
   parser_vars->m_named_decl = var_decl;
   parser_vars->m_llvm_value = nullptr;
   parser_vars->m_lldb_sym = &symbol;
@@ -1744,7 +1739,6 @@ void 
ClangExpressionDeclMap::AddOneRegister(NameSearchContext &context,
   entity->EnableParserVars(GetParserID());
   ClangExpressionVariable::ParserVars *parser_vars =
   entity->GetParserVars(GetParserID());
-  parser_vars->m_parser_type = parser_clang_type;
   parser_vars->m_named_decl = var_decl;
   parser_vars->m_llvm_value = nullptr;
   parser_vars->m_lldb_value.Clear();

diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
index 0e6de28ee4df..bedd349fe227 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
@@ -114,11 +114,9 @@ class ClangExpressionVariable : public ExpressionVariable {
   class ParserVars {
   public:
 ParserVars()
-: m_parser_type(), m_named_decl(nullptr), m_llvm_value(nullptr),
+: m_named_decl(nullptr), m_llvm_value(nullptr),
   m_lldb_value(), m_lldb_var(), m_lldb_sym(nullptr) {}
 
-TypeFromParser
-m_parser_type; ///< The type of the variable according to the parser
 const clang::NamedDecl
 *m_named_decl; ///< The Decl corresponding to this variable
 llvm::Value *m_llvm_value; ///< The IR value corresponding to this 
variable;



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


[Lldb-commits] [lldb] 1ccc702 - [lldb][NFC] Remove unnecessary ClangASTImporter checks in ClangASTSource

2020-01-31 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-01-31T13:17:08+01:00
New Revision: 1ccc702912fa9c41a58b9007807780a0dcb07707

URL: 
https://github.com/llvm/llvm-project/commit/1ccc702912fa9c41a58b9007807780a0dcb07707
DIFF: 
https://github.com/llvm/llvm-project/commit/1ccc702912fa9c41a58b9007807780a0dcb07707.diff

LOG: [lldb][NFC] Remove unnecessary ClangASTImporter checks in ClangASTSource

A ClangASTSource always has a ClangASTImporter. Let's remove these sporadic
checks with a single assert during construction. They were added originally
for the modern-type-lookup mode that didn't use a ClangASTImporter in there.

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 18e1353ee9b2..8fb0f40ea1d3 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -52,8 +52,9 @@ class ScopedLexicalDeclEraser {
 ClangASTSource::ClangASTSource(const lldb::TargetSP &target,
const lldb::ClangASTImporterSP &importer)
 : m_import_in_progress(false), m_lookups_enabled(false), m_target(target),
-  m_ast_context(nullptr), m_active_lexical_decls(), m_active_lookups() {
-  m_ast_importer_sp = importer;
+  m_ast_context(nullptr), m_ast_importer_sp(importer),
+  m_active_lexical_decls(), m_active_lookups() {
+  assert(m_ast_importer_sp && "No ClangASTImporter passed to ClangASTSource?");
 }
 
 void ClangASTSource::InstallASTContext(TypeSystemClang &clang_ast_context) {
@@ -64,9 +65,6 @@ void ClangASTSource::InstallASTContext(TypeSystemClang 
&clang_ast_context) {
 }
 
 ClangASTSource::~ClangASTSource() {
-  if (!m_ast_importer_sp)
-return;
-
   m_ast_importer_sp->ForgetDestination(m_ast_context);
 
   if (!m_target)
@@ -216,10 +214,6 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
   m_active_lexical_decls.insert(tag_decl);
   ScopedLexicalDeclEraser eraser(m_active_lexical_decls, tag_decl);
 
-  if (!m_ast_importer_sp) {
-return;
-  }
-
   if (!m_ast_importer_sp->CompleteTagDecl(tag_decl)) {
 // We couldn't complete the type.  Maybe there's a definition somewhere
 // else that can be completed.
@@ -343,11 +337,6 @@ void ClangASTSource::CompleteType(clang::ObjCInterfaceDecl 
*interface_decl) {
   LLDB_LOG(log, "  [COID] Before:\n{0}",
ClangUtil::DumpDecl(interface_decl));
 
-  if (!m_ast_importer_sp) {
-lldbassert(0 && "No mechanism for completing a type!");
-return;
-  }
-
   ClangASTImporter::DeclOrigin original = 
m_ast_importer_sp->GetDeclOrigin(interface_decl);
 
   if (original.Valid()) {
@@ -420,9 +409,6 @@ void ClangASTSource::FindExternalLexicalDecls(
 llvm::function_ref predicate,
 llvm::SmallVectorImpl &decls) {
 
-  if (!m_ast_importer_sp)
-return;
-
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
 
   const Decl *context_decl = dyn_cast(decl_context);
@@ -587,8 +573,8 @@ void 
ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) {
 
   if (const NamespaceDecl *namespace_context =
   dyn_cast(context.m_decl_context)) {
-ClangASTImporter::NamespaceMapSP namespace_map =  m_ast_importer_sp ?
-m_ast_importer_sp->GetNamespaceMap(namespace_context) : nullptr;
+ClangASTImporter::NamespaceMapSP namespace_map =
+m_ast_importer_sp->GetNamespaceMap(namespace_context);
 
 if (log && log->GetVerbose())
   LLDB_LOG(log,
@@ -1791,21 +1777,11 @@ NamespaceDecl *ClangASTSource::AddNamespace(
 }
 
 clang::Decl *ClangASTSource::CopyDecl(Decl *src_decl) {
-  if (m_ast_importer_sp) {
-return m_ast_importer_sp->CopyDecl(m_ast_context, src_decl);
-  } else {
-lldbassert(0 && "No mechanism for copying a decl!");
-return nullptr;
-  }
+  return m_ast_importer_sp->CopyDecl(m_ast_context, src_decl);
 }
 
 ClangASTImporter::DeclOrigin ClangASTSource::GetDeclOrigin(const clang::Decl 
*decl) {
-  if (m_ast_importer_sp) {
-return m_ast_importer_sp->GetDeclOrigin(decl);
-  } else {
-// this can happen early enough that no ExternalASTSource is installed.
-return ClangASTImporter::DeclOrigin();
-  }
+  return m_ast_importer_sp->GetDeclOrigin(decl);
 }
 
 CompilerType ClangASTSource::GuardedCopyType(const CompilerType &src_type) {
@@ -1816,15 +1792,8 @@ CompilerType ClangASTSource::GuardedCopyType(const 
CompilerType &src_type) {
 
   SetImportInProgress(true);
 
-  QualType copied_qual_type;
-
-  if (m_ast_importer_sp) {
-copied_qual_type = ClangUtil::GetQualType(
-m_ast_importer_sp->CopyType(*m_clang_ast_context, src_type));
-  } else {
-lldbassert(0 && "No mechanism for copying a type!");
-re

[Lldb-commits] [lldb] 09217b6 - [lldb][NFC] Add a CompilerDecl->clang::Decl conversion function to ClangUtil

2020-01-31 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-01-31T13:20:02+01:00
New Revision: 09217b60fcf1301e0333a69c37c6408d81c46ca5

URL: 
https://github.com/llvm/llvm-project/commit/09217b60fcf1301e0333a69c37c6408d81c46ca5
DIFF: 
https://github.com/llvm/llvm-project/commit/09217b60fcf1301e0333a69c37c6408d81c46ca5.diff

LOG: [lldb][NFC] Add a CompilerDecl->clang::Decl conversion function to 
ClangUtil

This automatically does the type checking for the cast.

Added: 


Modified: 
lldb/include/lldb/Symbol/ClangUtil.h
lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
lldb/source/Symbol/ClangUtil.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/ClangUtil.h 
b/lldb/include/lldb/Symbol/ClangUtil.h
index 5ffbce340e59..31e86cae5c3e 100644
--- a/lldb/include/lldb/Symbol/ClangUtil.h
+++ b/lldb/include/lldb/Symbol/ClangUtil.h
@@ -24,6 +24,10 @@ namespace lldb_private {
 struct ClangUtil {
   static bool IsClangType(const CompilerType &ct);
 
+  /// Returns the clang::Decl of the given CompilerDecl.
+  /// CompilerDecl has to be valid and represent a clang::Decl.
+  static clang::Decl *GetDecl(const CompilerDecl &decl);
+
   static clang::QualType GetQualType(const CompilerType &ct);
 
   static clang::QualType GetCanonicalQualType(const CompilerType &ct);

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
index 54865ae3ea13..f5b0c216902a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
@@ -8,6 +8,7 @@
 
 #include "Plugins/ExpressionParser/Clang/ClangDeclVendor.h"
 
+#include "lldb/Symbol/ClangUtil.h"
 #include "lldb/Symbol/TypeSystemClang.h"
 #include "lldb/Utility/ConstString.h"
 
@@ -22,7 +23,7 @@ uint32_t ClangDeclVendor::FindDecls(ConstString name, bool 
append,
   std::vector compiler_decls;
   uint32_t ret = FindDecls(name, /*append*/ false, max_matches, 
compiler_decls);
   for (CompilerDecl compiler_decl : compiler_decls) {
-clang::Decl *d = static_cast(compiler_decl.GetOpaqueDecl());
+clang::Decl *d = ClangUtil::GetDecl(compiler_decl);
 clang::NamedDecl *nd = llvm::cast(d);
 decls.push_back(nd);
   }

diff  --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp 
b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
index 806f7b60bfff..aa9fff3e4acb 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -1347,7 +1347,7 @@ PdbAstBuilder::ToCompilerDeclContext(clang::DeclContext 
&context) {
 }
 
 clang::Decl * PdbAstBuilder::FromCompilerDecl(CompilerDecl decl) {
-  return static_cast(decl.GetOpaqueDecl());
+  return ClangUtil::GetDecl(decl);
 }
 
 clang::DeclContext *

diff  --git a/lldb/source/Symbol/ClangUtil.cpp 
b/lldb/source/Symbol/ClangUtil.cpp
index 74d95bac4a97..2f3307ee1a5d 100644
--- a/lldb/source/Symbol/ClangUtil.cpp
+++ b/lldb/source/Symbol/ClangUtil.cpp
@@ -28,6 +28,11 @@ bool ClangUtil::IsClangType(const CompilerType &ct) {
   return true;
 }
 
+clang::Decl *ClangUtil::GetDecl(const CompilerDecl &decl) {
+  assert(llvm::isa(decl.GetTypeSystem()));
+  return static_cast(decl.GetOpaqueDecl());
+}
+
 QualType ClangUtil::GetQualType(const CompilerType &ct) {
   // Make sure we have a clang type before making a clang::QualType
   if (!IsClangType(ct))



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


[Lldb-commits] [PATCH] D70847: [lldb] Set executable module when adding modules to the Target

2020-01-31 Thread Anton Kolesov via Phabricator via lldb-commits
anton.kolesov added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/commands/target/set-exec/TestSetExecutable.py:16
+"""Test adding images to the target."""
+self.build()
+

labath wrote:
> anton.kolesov wrote:
> > clayborg wrote:
> > > Create a yaml file and put it in the same directory as this file. Change 
> > > this line to be:
> > > ```
> > > src_dir = self.getSourceDir()
> > > yaml_path = os.path.join(src_dir, "a.yaml")
> > > obj_path = self.getBuildArtifact("a.out")
> > > self.yaml2obj(yaml_path, obj_path)
> > > ```
> > > Make an ELF file that that is for a remote platform where the triple and 
> > > platform won't match typical hosts.
> > Do you have any specific suggestions that also have freely available 
> > toolchain? I have immediate access only to Windows/Linux x86 and Synopsys 
> > ARC, and ARC elf files don't change the platform - it remains as "host" 
> > even when connecting to a GDB-server, plus obj2yaml segfaults on ARC elf 
> > files.
> Would this do the job?
> ```
> --- !ELF
> FileHeader:
>   Class:   ELFCLASS64
>   Data:ELFDATA2LSB
>   Type:ET_DYN
>   Machine: EM_AARCH64
>   Entry:   0x06C0
> Sections:
>   - Name:.text
> Type:SHT_PROGBITS
> Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
> Address: 0x06C0
> AddressAlign:0x0008
> Content: DEADBEEF
> ...
> ```
It is definitely needed to change ET_DYN to ET_EXEC in this yaml, because the 
patch specifically modifies behavior only for executables. With that change 
this works on my x86_64/Linux, but I don't known how it will behave if test 
would be run on aarch64 host - will platform still change to "remote-linux" for 
this ELF or will it remain at "host"? I'm not sure how this process of platform 
selection works - can it distinguish between elf for aarch64-linux and elf for 
baremetal aarch64-elf?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70847



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


[Lldb-commits] [PATCH] D73767: [lldb] [test] Pass LLVM_LIBS_DIR from CMake for linking liblldb

2020-01-31 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D73767#1851418 , @mgorny wrote:

> The question is, does this break any of the platform hacks? ;-)


I think it /may/ break one. See inline comment.

BTW, I think the best way to clean a lot of this up would be to take the tests 
which build executables linking to liblldb, and rewrite them as c++ unit tests 
(at least those that aren't skipped/xfailed everywhere), as cmake knows best 
how to link to the thing it has built. Then, a lot of this stuff can be just 
deleted...




Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:1680
 self.dylibPath] if self.dylibPath in os.environ else None
-lib_dir = os.environ["LLDB_LIB_DIR"]
+lib_dir = configuration.lldb_libs_dir
 if existing_library_path:

I'm not sure if this is right, because (despite the name) `LLDB_LIB_DIR` points 
to the "bin" dir. But then again, this whole function seems pretty wrong, so 
it's hard to say what should it really do here.

 If you don't need this part (the previous patch didn't have it) and want to 
make this safe-ish for cherry-picking, maybe you could leave this part out for 
now.


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

https://reviews.llvm.org/D73767



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


[Lldb-commits] [PATCH] D70847: [lldb] Set executable module when adding modules to the Target

2020-01-31 Thread Pavel Labath via Phabricator via lldb-commits
labath requested changes to this revision.
labath added a comment.

Hmm... now that I actually have read what this patch does, I am starting to 
think that this is not a good idea:

- on linux it was possible to load an executable via "dlopen", at least until 
last year, when it was (partially?) disabled by 
https://patchwork.ozlabs.org/patch/1055380/
- opening an executable via dlopen still works on a mac (10.15.1 Catalina), 
though I'm not sure how much it's officially supported
- on windows LoadLibrary 

 is explicitly documented to be able to open .exe files

Now given that the effect of `SetExecutableModule` is to completely destroy the 
information about other loaded shared libraries, and that dlopening an exe 
works (for some definition of "works") on all major platforms, I don't think 
calling this function in response to a module being added (e.g. because of 
dlopen) is reasonable.

I think we need to go back to the drawing board and handle this at a different 
level -- either by changing lldb-vscode, or some of the higher-level launching 
logic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70847



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


[Lldb-commits] [lldb] 877963a - [lldb/DWARF] Delete some dead code in SymbolFileDWARF

2020-01-31 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-01-31T14:47:25+01:00
New Revision: 877963a35a0405576fc805d5b5087619e14e9f5f

URL: 
https://github.com/llvm/llvm-project/commit/877963a35a0405576fc805d5b5087619e14e9f5f
DIFF: 
https://github.com/llvm/llvm-project/commit/877963a35a0405576fc805d5b5087619e14e9f5f.diff

LOG: [lldb/DWARF] Delete some dead code in SymbolFileDWARF

- m_debug_loc(lists) are unused since the relevant logic was moved to
  DWARFContext.
- const versions of DebugInfo(), DebugAbbrev() are not used, and they
  are dangerous to use as they do not initialize the relevant objects.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 51d05b87a147..c5fe08a8a5aa 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -406,9 +406,8 @@ SymbolFileDWARF::SymbolFileDWARF(ObjectFileSP objfile_sp,
   // contain the .o file index/ID
   m_debug_map_module_wp(), m_debug_map_symfile(nullptr),
   m_context(m_objfile_sp->GetModule()->GetSectionList(), dwo_section_list),
-  m_data_debug_loc(), m_abbr(), m_info(), 
m_fetched_external_modules(false),
-  m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate),
-  m_unique_ast_type_map() {}
+  m_fetched_external_modules(false),
+  m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate) {}
 
 SymbolFileDWARF::~SymbolFileDWARF() {}
 
@@ -561,15 +560,6 @@ uint32_t SymbolFileDWARF::CalculateAbilities() {
   return abilities;
 }
 
-const DWARFDataExtractor &
-SymbolFileDWARF::GetCachedSectionData(lldb::SectionType sect_type,
-  DWARFDataSegment &data_segment) {
-  llvm::call_once(data_segment.m_flag, [this, sect_type, &data_segment] {
-this->LoadSectionData(sect_type, std::ref(data_segment.m_data));
-  });
-  return data_segment.m_data;
-}
-
 void SymbolFileDWARF::LoadSectionData(lldb::SectionType sect_type,
   DWARFDataExtractor &data) {
   ModuleSP module_sp(m_objfile_sp->GetModule());
@@ -606,10 +596,6 @@ DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() {
   return m_abbr.get();
 }
 
-const DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() const {
-  return m_abbr.get();
-}
-
 DWARFDebugInfo *SymbolFileDWARF::DebugInfo() {
   if (m_info == nullptr) {
 static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
@@ -621,10 +607,6 @@ DWARFDebugInfo *SymbolFileDWARF::DebugInfo() {
   return m_info.get();
 }
 
-const DWARFDebugInfo *SymbolFileDWARF::DebugInfo() const {
-  return m_info.get();
-}
-
 DWARFUnit *
 SymbolFileDWARF::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) {
   if (!comp_unit)

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 1e6b518c76ad..556be1e63e6a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -222,12 +222,8 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,
 
   DWARFDebugAbbrev *DebugAbbrev();
 
-  const DWARFDebugAbbrev *DebugAbbrev() const;
-
   DWARFDebugInfo *DebugInfo();
 
-  const DWARFDebugInfo *DebugInfo() const;
-
   DWARFDebugRanges *GetDebugRanges();
 
   static bool SupportedVersion(uint16_t version);
@@ -316,17 +312,8 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,
   typedef llvm::DenseMap
   ClangTypeToDIE;
 
-  struct DWARFDataSegment {
-llvm::once_flag m_flag;
-lldb_private::DWARFDataExtractor m_data;
-  };
-
   DISALLOW_COPY_AND_ASSIGN(SymbolFileDWARF);
 
-  const lldb_private::DWARFDataExtractor &
-  GetCachedSectionData(lldb::SectionType sect_type,
-   DWARFDataSegment &data_segment);
-
   virtual void LoadSectionData(lldb::SectionType sect_type,
lldb_private::DWARFDataExtractor &data);
 
@@ -483,11 +470,6 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,
 
   lldb_private::DWARFContext m_context;
 
-  DWARFDataSegment m_data_debug_loc;
-  DWARFDataSegment m_data_debug_loclists;
-
-  // The unique pointer items below are generated on demand if and when someone
-  // accesses them through a non const version of this class.
   std::unique_ptr m_abbr;
   std::unique_ptr m_info;
   std::unique_ptr m_global_aranges_up;



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


[Lldb-commits] [PATCH] D73781: [lldb/DWARF] Don't assume that a SymbolFileDWARFDwo contains one compile unit

2020-01-31 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: JDevlieghere, aprantl, clayborg.
Herald added a subscriber: arphaman.
Herald added a project: LLDB.
labath added a child revision: D73782: [lldb/DWARF] Don't hold a unique 
SymbolFileDWARFDwo in a DWARFUnit.

This is a preparatory patch to re-enable DWP support in lldb (we already
have code claiming to do that, but it has been completely broken for a
while now).

The idea of the new approach is to make the SymbolFileDWARFDwo class
handle both dwo and dwo files, similar to how llvm uses one DWARFContext
to handle the two.

The first step is to remove the assumption that a SymbolFileDWARFDwo
holds just a single compile unit, i.e. the GetBaseCompileUnit method.
This requires changing the way how we reach the skeleton compile unit
(and the lldb_private::CompileUnit) from a dwo unit, which was
previously done via GetSymbolFile()->GetBaseCompileUnit() (and some
virtual dispatch).

The new approach reuses the "user data" mechanism of DWARFUnits, which
was used to link dwarf units (both skeleton and split) to their
lldb_private counterparts. Now, this is done only for non-dwo units, and
instead of that, the dwo units holds a pointer to the relevant skeleton
unit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73781

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
@@ -13,7 +13,7 @@
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/LLDBAssert.h"
 
-#include "DWARFUnit.h"
+#include "DWARFCompileUnit.h"
 #include "DWARFDebugInfo.h"
 
 using namespace lldb;
@@ -25,8 +25,9 @@
  ObjectFileSP objfile,
  DWARFCompileUnit &dwarf_cu,
  uint64_t dwo_id)
-: SymbolFileDWARFDwo(objfile, dwarf_cu), m_dwp_symfile(dwp_symfile),
-  m_dwo_id(dwo_id) {}
+: SymbolFileDWARFDwo(dwarf_cu.GetSymbolFileDWARF(), objfile,
+ dwarf_cu.GetID()),
+  m_dwp_symfile(dwp_symfile), m_dwo_id(dwo_id) {}
 
 void SymbolFileDWARFDwoDwp::LoadSectionData(lldb::SectionType sect_type,
 DWARFDataExtractor &data) {
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -24,12 +24,11 @@
   static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
   /// \}
 
-  SymbolFileDWARFDwo(lldb::ObjectFileSP objfile, DWARFCompileUnit &dwarf_cu);
+  SymbolFileDWARFDwo(SymbolFileDWARF &m_base_symbol_file,
+ lldb::ObjectFileSP objfile, uint32_t id);
 
   ~SymbolFileDWARFDwo() override = default;
 
-  lldb::CompUnitSP ParseCompileUnit(DWARFCompileUnit &dwarf_cu) override;
-
   DWARFCompileUnit *GetCompileUnit();
 
   DWARFUnit *
@@ -44,8 +43,6 @@
   DWARFDIE
   GetDIE(const DIERef &die_ref) override;
 
-  DWARFCompileUnit *GetBaseCompileUnit() override { return &m_base_dwarf_cu; }
-
   llvm::Optional GetDwoNum() override { return GetID() >> 32; }
 
 protected:
@@ -69,11 +66,11 @@
   const DWARFDIE &die, lldb_private::ConstString type_name,
   bool must_be_implementation) override;
 
-  SymbolFileDWARF &GetBaseSymbolFile();
+  SymbolFileDWARF &GetBaseSymbolFile() { return m_base_symbol_file; }
 
   DWARFCompileUnit *ComputeCompileUnit();
 
-  DWARFCompileUnit &m_base_dwarf_cu;
+  SymbolFileDWARF &m_base_symbol_file;
   DWARFCompileUnit *m_cu = nullptr;
 };
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -23,12 +23,12 @@
 
 char SymbolFileDWARFDwo::ID;
 
-SymbolFileDWARFDwo::SymbolFileDWARFDwo(ObjectFileSP objfile,
-   DWARFCompileUnit &dwarf_cu)
+SymbolFileDWARFDwo::SymbolFileDWARFDwo(SymbolFileDWARF &base_symbol_file,
+   ObjectFileSP objfile, uint32_t id)
 : SymbolFileDWARF(objfile, objfile->GetSectionList(
/*update_module_section

[Lldb-commits] [PATCH] D73782: [lldb/DWARF] Don't hold a unique SymbolFileDWARFDwo in a DWARFUnit

2020-01-31 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: JDevlieghere, aprantl, clayborg.
Herald added a reviewer: jdoerfert.
Herald added a project: LLDB.
labath added a parent revision: D73781: [lldb/DWARF] Don't assume that a 
SymbolFileDWARFDwo contains one compile unit.
labath added a child revision: D73783: [lldb/DWARF] Re-enable basic dwp support.

This is the second dwp preparatory patch. When a SymbolFileDWARFDwo will
hold more than one split unit, it will not be able to be uniquely owned
by a single DWARFUnit. I achieve this by changing the
unique_ptr member of DWARFUnit to
shared_ptr. The shared_ptr points to a DWARFUnit, but it is
in fact holding the entire SymbolFileDWARFDwo alive. This is the same
method used by llvm DWARFUnit (except that is uses the DWARFContext
class).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73782

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -29,10 +29,7 @@
 
   ~SymbolFileDWARFDwo() override = default;
 
-  DWARFCompileUnit *GetCompileUnit();
-
-  DWARFUnit *
-  GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) override;
+  DWARFCompileUnit *GetDWOCompileUnitForHash(uint64_t hash);
 
   size_t GetObjCMethodDIEOffsets(lldb_private::ConstString class_name,
  DIEArray &method_die_offsets) override;
@@ -68,10 +65,9 @@
 
   SymbolFileDWARF &GetBaseSymbolFile() { return m_base_symbol_file; }
 
-  DWARFCompileUnit *ComputeCompileUnit();
+  DWARFCompileUnit *FindSingleCompileUnit();
 
   SymbolFileDWARF &m_base_symbol_file;
-  DWARFCompileUnit *m_cu = nullptr;
 };
 
 #endif // SymbolFileDWARFDwo_SymbolFileDWARFDwo_h_
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -49,13 +49,16 @@
   SymbolFileDWARF::LoadSectionData(sect_type, data);
 }
 
-DWARFCompileUnit *SymbolFileDWARFDwo::GetCompileUnit() {
-  if (!m_cu)
-m_cu = ComputeCompileUnit();
-  return m_cu;
+DWARFCompileUnit *SymbolFileDWARFDwo::GetDWOCompileUnitForHash(uint64_t hash) {
+  DWARFCompileUnit *cu = FindSingleCompileUnit();
+  if (!cu)
+return nullptr;
+  if (hash != cu->GetUnitDIEOnly().GetAttributeValueAsUnsigned(DW_AT_GNU_dwo_id, 0))
+return nullptr;
+  return cu;
 }
 
-DWARFCompileUnit *SymbolFileDWARFDwo::ComputeCompileUnit() {
+DWARFCompileUnit *SymbolFileDWARFDwo::FindSingleCompileUnit() {
   DWARFDebugInfo *debug_info = DebugInfo();
   if (!debug_info)
 return nullptr;
@@ -79,11 +82,6 @@
   return cu;
 }
 
-DWARFUnit *
-SymbolFileDWARFDwo::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) {
-  return GetCompileUnit();
-}
-
 SymbolFileDWARF::DIEToTypePtr &SymbolFileDWARFDwo::GetDIEToType() {
   return GetBaseSymbolFile().GetDIEToType();
 }
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -270,7 +270,7 @@
 
   lldb::user_id_t GetUID(DIERef ref);
 
-  std::unique_ptr
+  std::shared_ptr
   GetDwoSymbolFileForCompileUnit(DWARFUnit &dwarf_cu,
  const DWARFDebugInfoEntry &cu_die);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1554,7 +1554,7 @@
   return {};
 }
 
-std::unique_ptr
+std::shared_ptr
 SymbolFileDWARF::GetDwoSymbolFileForCompileUnit(
 DWARFUnit &unit, const DWARFDebugInfoEntry &cu_die) {
   // If this is a Darwin-style debug map (non-.dSYM) symbol file,
@@ -1609,7 +1609,7 @@
   if (dwo_obj_file == nullptr)
 return nullptr;
 
-  return std::make_unique(*this, dwo_obj_file,
+  return std::make_shared(*this, dwo_obj_file,
   dwarf_cu->GetID());
 }
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -281,7 +281,7 @@
   }
 
   SymbolFileDWARF &m_dwarf;
-  std::unique_ptr m_dwo_symbol_file

[Lldb-commits] [PATCH] D73783: [lldb/DWARF] Re-enable basic dwp support

2020-01-31 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: JDevlieghere, aprantl, clayborg.
Herald added subscribers: mgrang, mgorny.
Herald added a project: LLDB.
labath added a parent revision: D73782: [lldb/DWARF] Don't hold a unique 
SymbolFileDWARFDwo in a DWARFUnit.

This patch removes the bitrotted SymbolFileDWARF(Dwo)Dwp classes, and
replaces them with dwp support implemented directly inside
SymbolFileDWARFDwo, in a manner mirroring the implementation in llvm.
This patch does:

- add support for the .debug_cu_index section to our DWARFContext
- adds a llvm::DWARFUnitIndex argument to the DWARFUnit constructors. This 
argument is used to look up the offsets of the debug_info and debug_abbrev 
contributions in the sections of the dwp file.
- makes sure the creation of the DebugInfo object as well as the initial 
discovery of DWARFUnits is thread-safe, as we can now call this concurrently 
when doing parallel indexing.

This patch does not:

- use the DWARFUnitIndex to search for other kinds of contributions (debug_loc, 
debug_ranges, etc.). This means that units which reference these sections will 
not work correctly. These will be handled by follow-up patches, but even the 
present level of support is sufficient to enable basic functionality.
- Make the llvm::DWARFContext thread-safe. Righ now, it just avoids this 
problem by ensuring everything is initialized ahead of time. However, this is 
something we will run into more often as we try to use more of llvm, and so I 
plan to start looking into our options here.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73783

Files:
  lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h
  lldb/test/Shell/SymbolFile/DWARF/dwp.s
  lldb/unittests/Expression/DWARFExpressionTest.cpp

Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -164,7 +164,7 @@
 llvm::Expected dwarf_unit = DWARFUnit::extract(
 *m_symfile_dwarf, uid,
 *static_cast(&debug_info),
-DIERef::DebugInfo, &offset_ptr);
+DIERef::DebugInfo, &offset_ptr, nullptr);
 if (dwarf_unit)
   m_dwarf_unit = dwarf_unit.get();
   }
Index: lldb/test/Shell/SymbolFile/DWARF/dwp.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/dwp.s
@@ -0,0 +1,149 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc --filetype=obj --triple x86_64-pc-linux %s -o %t --defsym MAIN=0
+# RUN: llvm-mc --filetype=obj --triple x86_64-pc-linux %s -o %t.dwp --defsym DWP=0
+# RUN: %lldb %t -o "target variable A" -b | FileCheck %s
+# RUN: lldb-test symbols %t | FileCheck %s --check-prefix=SYMBOLS
+
+# CHECK: (int) A = 0
+# CHECK: (int) A = 1
+# CHECK: (int) A = 2
+# CHECK: (int) A = 3
+
+# SYMBOLS:  Compile units:
+# SYMBOLS-NEXT: CompileUnit{0x}, language = "unknown", file = '0.c'
+# SYMBOLS-NEXT:   Variable{{.*}}, name = "A", {{.*}}, location = DW_OP_GNU_addr_index 0x0
+# SYMBOLS-NEXT: CompileUnit{0x0001}, language = "unknown", file = '1.c'
+# SYMBOLS-NEXT:   Variable{{.*}}, name = "A", {{.*}}, location = DW_OP_GNU_addr_index 0x1
+# SYMBOLS-NEXT: CompileUnit{0x0002}, language = "unknown", file = '2.c'
+# SYMBOLS-NEXT:   Variable{{.*}}, name = "A", {{.*}}, location = DW_OP_GNU_addr_index 0x2
+# SYMBOLS-NEXT: CompileUnit{0x0003}, language = "unknown", file = '3.c'
+# SYMBOLS-NEXT:   Variable{{.*}}, name = "A", {{.*}}, location = DW_OP_GNU_addr_index 0x3
+# SYMBOLS-NEXT: CompileUnit{0x0004}, language = "unknown", file = ''
+# SYMBOLS-EMPTY:
+
+.section.debug_abbrev,"",@progbits
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   0   # DW_CHILDREN_no
+.ascii  "\260B" # DW_AT_GNU_dwo_name
+.byte   8   # DW_FORM_string
+.ascii  "\261B" # DW_AT_GNU_dwo_id
+.byte   7   # DW_FORM_data8
+.ascii  "\2

[Lldb-commits] [lldb] 789beee - [lldb] Move non-DWARF code: DWARFUnit -> SymbolFileDWARF

2020-01-31 Thread Jan Kratochvil via lldb-commits

Author: Jan Kratochvil
Date: 2020-01-31T15:16:31+01:00
New Revision: 789beeeca3cdeecc00cd731c940e52effdd7c7df

URL: 
https://github.com/llvm/llvm-project/commit/789beeeca3cdeecc00cd731c940e52effdd7c7df
DIFF: 
https://github.com/llvm/llvm-project/commit/789beeeca3cdeecc00cd731c940e52effdd7c7df.diff

LOG: [lldb] Move non-DWARF code: DWARFUnit -> SymbolFileDWARF

This patchset is removing non-DWARF code from DWARFUnit for better
future merge with LLVM DWARF as discussed with @labath.

Differential revision: https://reviews.llvm.org/D70646

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 39d4b370bc3c..57bda49952f4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -155,7 +155,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const 
SymbolContext &sc,
 
   // The type in the Clang module must have the same language as the current 
CU.
   LanguageSet languages;
-  languages.Insert(die.GetCU()->GetLanguageType());
+  languages.Insert(SymbolFileDWARF::GetLanguage(*die.GetCU()));
   llvm::DenseSet searched_symbol_files;
   clang_module_sp->GetSymbolFile()->FindTypes(decl_context, languages,
   searched_symbol_files, 
pcm_types);
@@ -504,7 +504,7 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext 
&sc,
 DWARF_LOG_LOOKUPS));
   SymbolFileDWARF *dwarf = die.GetDWARF();
   const dw_tag_t tag = die.Tag();
-  LanguageType cu_language = die.GetLanguage();
+  LanguageType cu_language = SymbolFileDWARF::GetLanguage(*die.GetCU());
   Type::ResolveState resolve_state = Type::ResolveState::Unresolved;
   Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID;
   TypeSP type_sp;
@@ -726,8 +726,7 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext 
&sc,
 if (type_sp)
   return type_sp;
 
-DWARFDeclContext die_decl_ctx;
-die.GetDWARFDeclContext(die_decl_ctx);
+DWARFDeclContext die_decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
 
 type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
 
@@ -1383,7 +1382,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
   CompilerType clang_type;
   const dw_tag_t tag = die.Tag();
   SymbolFileDWARF *dwarf = die.GetDWARF();
-  LanguageType cu_language = die.GetLanguage();
+  LanguageType cu_language = SymbolFileDWARF::GetLanguage(*die.GetCU());
   Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_TYPE_COMPLETION |
   DWARF_LOG_LOOKUPS);
 
@@ -1515,8 +1514,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 if (type_sp)
   return type_sp;
 
-DWARFDeclContext die_decl_ctx;
-die.GetDWARFDeclContext(die_decl_ctx);
+DWARFDeclContext die_decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
 
 // type_sp = FindDefinitionTypeForDIE (dwarf_cu, die,
 // type_name_const_str);
@@ -2311,9 +2309,11 @@ Function 
*DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
 func_name.SetValue(ConstString(mangled), true);
   else if ((die.GetParent().Tag() == DW_TAG_compile_unit ||
 die.GetParent().Tag() == DW_TAG_partial_unit) &&
-   Language::LanguageIsCPlusPlus(die.GetLanguage()) &&
-   !Language::LanguageIsObjC(die.GetLanguage()) && name &&
-   strcmp(name, "main") != 0) {
+   Language::LanguageIsCPlusPlus(
+   SymbolFileDWARF::GetLanguage(*die.GetCU())) &&
+   !Language::LanguageIsObjC(
+   SymbolFileDWARF::GetLanguage(*die.GetCU())) &&
+   name && strcmp(name, "main") != 0) {
 // If the mangled name is not present in the DWARF, generate the
 // demangled name using the decl context. We skip if the function is
 // "main" as its name is never mangled.
@@ -2323,10 +2323,9 @@ Function 
*DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
 unsigned typ

[Lldb-commits] [PATCH] D70646: Move non-DWARF code: `DWARFUnit` -> `SymbolFileDWARF`

2020-01-31 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG789beeeca3cd: [lldb] Move non-DWARF code: DWARFUnit -> 
SymbolFileDWARF (authored by jankratochvil).

Changed prior to commit:
  https://reviews.llvm.org/D70646?vs=241634&id=241715#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70646

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -301,6 +301,26 @@
 
   lldb_private::FileSpec GetFile(DWARFUnit &unit, size_t file_idx);
 
+  static llvm::Expected
+  GetTypeSystem(DWARFUnit &unit);
+
+  static DWARFASTParser *GetDWARFParser(DWARFUnit &unit);
+
+  // CompilerDecl related functions
+
+  static lldb_private::CompilerDecl GetDecl(const DWARFDIE &die);
+
+  static lldb_private::CompilerDeclContext GetDeclContext(const DWARFDIE &die);
+
+  static lldb_private::CompilerDeclContext
+  GetContainingDeclContext(const DWARFDIE &die);
+
+  static DWARFDeclContext GetDWARFDeclContext(const DWARFDIE &die);
+
+  static lldb::LanguageType LanguageTypeFromDWARF(uint64_t val);
+
+  static lldb::LanguageType GetLanguage(DWARFUnit &unit);
+
 protected:
   typedef llvm::DenseMap
   DIEToTypePtr;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -670,7 +670,7 @@
   cu_file_spec.SetFile(remapped_file, FileSpec::Style::native);
   }
 
-  LanguageType cu_language = DWARFUnit::LanguageTypeFromDWARF(
+  LanguageType cu_language = SymbolFileDWARF::LanguageTypeFromDWARF(
   cu_die.GetAttributeValueAsUnsigned(DW_AT_language, 0));
 
   bool is_optimized = dwarf_cu.GetNonSkeletonUnit().GetIsOptimized();
@@ -748,8 +748,7 @@
   if (!die.IsValid())
 return nullptr;
 
-  auto type_system_or_err =
-  GetTypeSystemForLanguage(die.GetCU()->GetLanguageType());
+  auto type_system_or_err = GetTypeSystemForLanguage(GetLanguage(*die.GetCU()));
   if (auto err = type_system_or_err.takeError()) {
 LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS),
std::move(err), "Unable to parse function");
@@ -781,7 +780,7 @@
   std::lock_guard guard(GetModuleMutex());
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
   if (dwarf_cu)
-return dwarf_cu->GetLanguageType();
+return GetLanguage(*dwarf_cu);
   else
 return eLanguageTypeUnknown;
 }
@@ -1272,7 +1271,7 @@
   // SymbolFileDWARF::GetDIE(). See comments inside the
   // SymbolFileDWARF::GetDIE() for details.
   if (DWARFDIE die = GetDIE(type_uid))
-return die.GetDecl();
+return GetDecl(die);
   return CompilerDecl();
 }
 
@@ -1285,7 +1284,7 @@
   // SymbolFileDWARF::GetDIE(). See comments inside the
   // SymbolFileDWARF::GetDIE() for details.
   if (DWARFDIE die = GetDIE(type_uid))
-return die.GetDeclContext();
+return GetDeclContext(die);
   return CompilerDeclContext();
 }
 
@@ -1296,7 +1295,7 @@
   // SymbolFileDWARF::GetDIE(). See comments inside the
   // SymbolFileDWARF::GetDIE() for details.
   if (DWARFDIE die = GetDIE(type_uid))
-return die.GetContainingDeclContext();
+return GetContainingDeclContext(die);
   return CompilerDeclContext();
 }
 
@@ -1427,8 +1426,7 @@
   dwarf_die.GetID(), dwarf_die.GetTagAsCString(),
   type->GetName().AsCString());
 assert(compiler_type);
-DWARFASTParser *dwarf_ast = dwarf_die.GetDWARFParser();
-if (dwarf_ast)
+if (DWARFASTParser *dwarf_ast = GetDWARFParser(*dwarf_die.GetCU()))
   return dwarf_ast->CompleteTypeFromDWARF(dwarf_die, type, compiler_type);
   }
   return false;
@@ -2099,8 +2097,7 @@
   sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
 
   if (parent_decl_ctx) {
-DWARFASTParser *dwarf_ast = die.GetDWARFParser();
-if (dwarf_ast) {
+if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU())) {
 

[Lldb-commits] [PATCH] D70646: Move non-DWARF code: `DWARFUnit` -> `SymbolFileDWARF`

2020-01-31 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked 2 inline comments as done.
jankratochvil added a comment.

Checked in, thanks for the review.




Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:3987-4008
+  DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU());
+  if (dwarf_ast)
+return dwarf_ast->GetDeclForUIDFromDWARF(die);
+  else
+return CompilerDecl();
+}
+

labath wrote:
> [[ http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return | 
> Don't use else after return ]]. In fact, you might as well fold the 
> GetDWARFParser call into the if condition (`if (DWARFASTParser *parser = ...) 
> parser->...`)
This was only moving the code, I did not expect to also refactor it.  But I 
have thus made these code cleanups which I found.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70646



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


[Lldb-commits] [lldb] b8966de - [lldb] Remove some dead code from SharingPtr.h

2020-01-31 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-01-31T15:46:41+01:00
New Revision: b8966de73f1c7c6b7d585ce4f3ed171d121328ae

URL: 
https://github.com/llvm/llvm-project/commit/b8966de73f1c7c6b7d585ce4f3ed171d121328ae
DIFF: 
https://github.com/llvm/llvm-project/commit/b8966de73f1c7c6b7d585ce4f3ed171d121328ae.diff

LOG: [lldb] Remove some dead code from SharingPtr.h

These classes are not used.

Added: 


Modified: 
lldb/include/lldb/Utility/SharingPtr.h

Removed: 




diff  --git a/lldb/include/lldb/Utility/SharingPtr.h 
b/lldb/include/lldb/Utility/SharingPtr.h
index e4ab3d27a69b..ddd55a00d384 100644
--- a/lldb/include/lldb/Utility/SharingPtr.h
+++ b/lldb/include/lldb/Utility/SharingPtr.h
@@ -359,251 +359,6 @@ SharingPtr const_pointer_cast(const SharingPtr &r) {
   return SharingPtr(r, const_cast(r.get()));
 }
 
-template  class LoggingSharingPtr : public SharingPtr {
-  typedef SharingPtr base;
-
-public:
-  typedef void (*Callback)(void *, const LoggingSharingPtr &, bool action);
-  // action:  false means increment just happened
-  //  true  means decrement is about to happen
-
-  LoggingSharingPtr() : cb_(0), baton_(nullptr) {}
-
-  LoggingSharingPtr(Callback cb, void *baton) : cb_(cb), baton_(baton) {
-if (cb_)
-  cb_(baton_, *this, false);
-  }
-
-  template 
-  LoggingSharingPtr(Y *p) : base(p), cb_(0), baton_(nullptr) {}
-
-  template 
-  LoggingSharingPtr(Y *p, Callback cb, void *baton)
-  : base(p), cb_(cb), baton_(baton) {
-if (cb_)
-  cb_(baton_, *this, false);
-  }
-
-  ~LoggingSharingPtr() {
-if (cb_)
-  cb_(baton_, *this, true);
-  }
-
-  LoggingSharingPtr(const LoggingSharingPtr &p)
-  : base(p), cb_(p.cb_), baton_(p.baton_) {
-if (cb_)
-  cb_(baton_, *this, false);
-  }
-
-  LoggingSharingPtr &operator=(const LoggingSharingPtr &p) {
-if (cb_)
-  cb_(baton_, *this, true);
-base::operator=(p);
-cb_ = p.cb_;
-baton_ = p.baton_;
-if (cb_)
-  cb_(baton_, *this, false);
-return *this;
-  }
-
-  void reset() {
-if (cb_)
-  cb_(baton_, *this, true);
-base::reset();
-  }
-
-  template  void reset(Y *p) {
-if (cb_)
-  cb_(baton_, *this, true);
-base::reset(p);
-if (cb_)
-  cb_(baton_, *this, false);
-  }
-
-  void SetCallback(Callback cb, void *baton) {
-cb_ = cb;
-baton_ = baton;
-  }
-
-  void ClearCallback() {
-cb_ = 0;
-baton_ = 0;
-  }
-
-private:
-  Callback cb_;
-  void *baton_;
-};
-
-template  class IntrusiveSharingPtr;
-
-template  class ReferenceCountedBase {
-public:
-  explicit ReferenceCountedBase() : shared_owners_(-1) {}
-
-  void add_shared();
-
-  void release_shared();
-
-  long use_count() const { return shared_owners_ + 1; }
-
-protected:
-  long shared_owners_;
-
-  friend class IntrusiveSharingPtr;
-
-private:
-  ReferenceCountedBase(const ReferenceCountedBase &) = delete;
-  ReferenceCountedBase &operator=(const ReferenceCountedBase &) = delete;
-};
-
-template  void lldb_private::ReferenceCountedBase::add_shared() {
-#ifdef _MSC_VER
-  _InterlockedIncrement(&shared_owners_);
-#else
-  ++shared_owners_;
-#endif
-}
-
-template 
-void lldb_private::ReferenceCountedBase::release_shared() {
-#ifdef _MSC_VER
-  if (_InterlockedDecrement(&shared_owners_) == -1)
-#else
-  if (--shared_owners_ == -1)
-#endif
-delete static_cast(this);
-}
-
-template 
-class ReferenceCountedBaseVirtual : public imp::shared_count {
-public:
-  explicit ReferenceCountedBaseVirtual() : imp::shared_count(-1) {}
-
-  ~ReferenceCountedBaseVirtual() override = default;
-
-  void on_zero_shared() override;
-};
-
-template  void ReferenceCountedBaseVirtual::on_zero_shared() {}
-
-template  class IntrusiveSharingPtr {
-public:
-  typedef T element_type;
-
-  explicit IntrusiveSharingPtr() : ptr_(0) {}
-
-  explicit IntrusiveSharingPtr(T *ptr) : ptr_(ptr) { add_shared(); }
-
-  IntrusiveSharingPtr(const IntrusiveSharingPtr &rhs) : ptr_(rhs.ptr_) {
-add_shared();
-  }
-
-  template 
-  IntrusiveSharingPtr(const IntrusiveSharingPtr &rhs) : ptr_(rhs.get()) {
-add_shared();
-  }
-
-  IntrusiveSharingPtr &operator=(const IntrusiveSharingPtr &rhs) {
-reset(rhs.get());
-return *this;
-  }
-
-  template 
-  IntrusiveSharingPtr &operator=(const IntrusiveSharingPtr &rhs) {
-reset(rhs.get());
-return *this;
-  }
-
-  IntrusiveSharingPtr &operator=(T *ptr) {
-reset(ptr);
-return *this;
-  }
-
-  ~IntrusiveSharingPtr() {
-release_shared();
-ptr_ = nullptr;
-  }
-
-  T &operator*() const { return *ptr_; }
-
-  T *operator->() const { return ptr_; }
-
-  T *get() const { return ptr_; }
-
-  explicit operator bool() const { return ptr_ != 0; }
-
-  void swap(IntrusiveSharingPtr &rhs) {
-std::swap(ptr_, rhs.ptr_);
-#if defined(ENABLE_SP_LOGGING)
-track_sp(this, ptr_, use_count());
-track_sp(&rhs, rhs.ptr_, rhs.use_count());
-#endif
-  }
-
-  void reset(T *ptr = nullptr) { In

[Lldb-commits] [lldb] 33f65f3 - [lldb] Add a basic unit test for the SharedCluster class

2020-01-31 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-01-31T15:46:41+01:00
New Revision: 33f65f393f6652a0974582f7b13a9aa38a9929a3

URL: 
https://github.com/llvm/llvm-project/commit/33f65f393f6652a0974582f7b13a9aa38a9929a3
DIFF: 
https://github.com/llvm/llvm-project/commit/33f65f393f6652a0974582f7b13a9aa38a9929a3.diff

LOG: [lldb] Add a basic unit test for the SharedCluster class

Added: 
lldb/unittests/Utility/SharedClusterTest.cpp

Modified: 
lldb/unittests/Utility/CMakeLists.txt

Removed: 




diff  --git a/lldb/unittests/Utility/CMakeLists.txt 
b/lldb/unittests/Utility/CMakeLists.txt
index 8dc13327b9b0..5e27c6725d4b 100644
--- a/lldb/unittests/Utility/CMakeLists.txt
+++ b/lldb/unittests/Utility/CMakeLists.txt
@@ -24,6 +24,7 @@ add_lldb_unittest(UtilityTests
   ReproducerInstrumentationTest.cpp
   ReproducerTest.cpp
   ScalarTest.cpp
+  SharedClusterTest.cpp
   StateTest.cpp
   StatusTest.cpp
   StreamTeeTest.cpp

diff  --git a/lldb/unittests/Utility/SharedClusterTest.cpp 
b/lldb/unittests/Utility/SharedClusterTest.cpp
new file mode 100644
index ..a41b12aa18d8
--- /dev/null
+++ b/lldb/unittests/Utility/SharedClusterTest.cpp
@@ -0,0 +1,55 @@
+//===-- SharedClusterTest.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Utility/SharedCluster.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+namespace {
+class DestructNotifier {
+public:
+  DestructNotifier(std::vector &Queue, int Key) : Queue(Queue), Key(Key) 
{}
+  ~DestructNotifier() { Queue.push_back(Key); }
+
+  std::vector &Queue;
+  const int Key;
+};
+} // namespace
+
+TEST(SharedCluster, ClusterManager) {
+  std::vector Queue;
+  auto *CM = new ClusterManager();
+  auto *One = new DestructNotifier(Queue, 1);
+  auto *Two = new DestructNotifier(Queue, 2);
+  CM->ManageObject(One);
+  CM->ManageObject(Two);
+
+  ASSERT_THAT(Queue, testing::IsEmpty());
+  {
+SharingPtr OnePtr = CM->GetSharedPointer(One);
+ASSERT_EQ(OnePtr->Key, 1);
+ASSERT_THAT(Queue, testing::IsEmpty());
+
+{
+  SharingPtr OnePtrCopy = OnePtr;
+  ASSERT_EQ(OnePtrCopy->Key, 1);
+  ASSERT_THAT(Queue, testing::IsEmpty());
+}
+
+{
+  SharingPtr TwoPtr = CM->GetSharedPointer(Two);
+  ASSERT_EQ(TwoPtr->Key, 2);
+  ASSERT_THAT(Queue, testing::IsEmpty());
+}
+
+ASSERT_THAT(Queue, testing::IsEmpty());
+  }
+  ASSERT_THAT(Queue, testing::ElementsAre(1, 2));
+}



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


[Lldb-commits] [PATCH] D73279: testsuite: generalize `DWARFASTParserClangTests` based on `DWARFExpressionTest`'s YAML

2020-01-31 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked 2 inline comments as done.
jankratochvil added a comment.

In D73279#1851201 , @labath wrote:

> That might explain the warnings I have seen when building with msvc the other 
> day. It might good to add those too.


Added.




Comment at: lldb/unittests/TestingSupport/CMakeLists.txt:4
   MockTildeExpressionResolver.cpp
+  Symbol/YAMLModuleTester.cpp
   TestUtilities.cpp

labath wrote:
> The idea was then that this would be a separate library (`lldbSymbolHelpers`) 
> with its own CMakeLists.txt and everything.
Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73279



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


[Lldb-commits] [PATCH] D73279: testsuite: generalize `DWARFASTParserClangTests` based on `DWARFExpressionTest`'s YAML

2020-01-31 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 241721.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73279

Files:
  lldb/unittests/Expression/DWARFExpressionTest.cpp
  lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
  lldb/unittests/TestingSupport/CMakeLists.txt
  lldb/unittests/TestingSupport/Symbol/CMakeLists.txt
  lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
  lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h
  lldb/unittests/TestingSupport/module.modulemap

Index: lldb/unittests/TestingSupport/module.modulemap
===
--- lldb/unittests/TestingSupport/module.modulemap
+++ lldb/unittests/TestingSupport/module.modulemap
@@ -13,4 +13,5 @@
 module lldb_TestingSupport_Symbol {
   requires cplusplus
   module ClangTestUtils { header "Symbol/ClangTestUtils.h" export * }
+  module YAMLModuleTester { header "Symbol/YAMLModuleTester.h" export * }
 }
Index: lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h
===
--- /dev/null
+++ lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h
@@ -0,0 +1,43 @@
+//===- YAMLModuleTester.h ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_UNITTESTS_TESTINGSUPPORT_SYMBOL_YAMLMODULETESTER_H
+#define LLDB_UNITTESTS_TESTINGSUPPORT_SYMBOL_YAMLMODULETESTER_H
+
+#include "Plugins/SymbolFile/DWARF/DWARFUnit.h"
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/TypeSystemClang.h"
+
+namespace lldb_private {
+
+/// Helper class that can construct a module from YAML and evaluate
+/// DWARF expressions on it.
+class YAMLModuleTester {
+  //  SubsystemRAII subsystems;
+  SubsystemRAII subsystems;
+  llvm::StringMap> m_sections_map;
+  lldb::ModuleSP m_module_sp;
+  lldb::ObjectFileSP m_objfile_sp;
+  DWARFUnitSP m_dwarf_unit;
+  std::unique_ptr m_symfile_dwarf;
+
+public:
+  /// Parse the debug info sections from the YAML description.
+  YAMLModuleTester(llvm::StringRef yaml_data, llvm::StringRef triple);
+  DWARFUnitSP GetDwarfUnit() { return m_dwarf_unit; }
+
+  // Evaluate a raw DWARF expression.
+  llvm::Expected Eval(llvm::ArrayRef expr);
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_UNITTESTS_TESTINGSUPPORT_SYMBOL_YAMLMODULETESTER_H
Index: lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
===
--- /dev/null
+++ lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
@@ -0,0 +1,116 @@
+//===- YAMLModuleTester.cpp -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestingSupport/Symbol/YAMLModuleTester.h"
+#include "lldb/Core/Section.h"
+#include "llvm/ObjectYAML/DWARFEmitter.h"
+
+using namespace lldb_private;
+
+/// A mock module holding an object file parsed from YAML.
+class YAMLModule : public lldb_private::Module {
+public:
+  YAMLModule(ArchSpec &arch) : Module(FileSpec("test"), arch) {}
+  void SetObjectFile(lldb::ObjectFileSP obj_file) { m_objfile_sp = obj_file; }
+  ObjectFile *GetObjectFile() override { return m_objfile_sp.get(); }
+};
+
+/// A mock object file that can be parsed from YAML.
+class YAMLObjectFile : public lldb_private::ObjectFile {
+  const lldb::ModuleSP m_module_sp;
+  llvm::StringMap> &m_section_map;
+  /// Because there is only one DataExtractor in the ObjectFile
+  /// interface, all sections are copied into a contiguous buffer.
+  std::vector m_buffer;
+
+public:
+  YAMLObjectFile(const lldb::ModuleSP &module_sp,
+   llvm::StringMap> &map)
+: ObjectFile(module_sp, &module_sp->GetFileSpec(), /*file_offset*/ 0,
+ /*length*/ 0, /*data_sp*/ nullptr, /*data_offset*/ 0),
+  m_module_sp(module_sp), m_section_map(map) {}
+
+  /// Callback for initializing the module's list of sections.
+  void CreateSections(SectionList &unified_section_list) override {
+lldb::offset_t total_bytes = 0;
+for (auto &entry : m_section_map)
+  total_bytes += entry.getValue()->getBufferSize();
+m_buffer.reserve(total_bytes);
+m_data =
+DataExtractor(m_buffer.data(), total_bytes, lldb::eByteOrderLittle, 4);
+
+lldb::user_id_t sect_id = 1;

[Lldb-commits] [PATCH] D70646: Move non-DWARF code: `DWARFUnit` -> `SymbolFileDWARF`

2020-01-31 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked an inline comment as done.
jankratochvil added a comment.

This commit broke: http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/7400/
Going to revert the return value refactorization.
That `DWARFDebugInfoEntry::GetDWARFDeclContext()` refactorization for return 
value was non-trivial and I see I did screw it up I think despite I did not 
want to.  It is now adding it in opposite order.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70646



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


[Lldb-commits] [lldb] 6dd0163 - [lldb] Revert refactorization from: Move non-DWARF code: DWARFUnit -> SymbolFileDWARF

2020-01-31 Thread Jan Kratochvil via lldb-commits

Author: Jan Kratochvil
Date: 2020-01-31T16:06:23+01:00
New Revision: 6dd0163502ff8c48195643b2b08a123c495743a0

URL: 
https://github.com/llvm/llvm-project/commit/6dd0163502ff8c48195643b2b08a123c495743a0
DIFF: 
https://github.com/llvm/llvm-project/commit/6dd0163502ff8c48195643b2b08a123c495743a0.diff

LOG: [lldb] Revert refactorization from: Move non-DWARF code: DWARFUnit -> 
SymbolFileDWARF

Reverting part of commit 789beeeca3cdeecc00cd731c940e52effdd7c7df.

Its DWARFDebugInfoEntry::GetDWARFDeclContext() refactorization for
return value is now adding it in opposite order.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 57bda49952f4..db49010a846f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -726,7 +726,8 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext 
&sc,
 if (type_sp)
   return type_sp;
 
-DWARFDeclContext die_decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
+DWARFDeclContext die_decl_ctx;
+SymbolFileDWARF::GetDWARFDeclContext(die, die_decl_ctx);
 
 type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
 
@@ -1514,7 +1515,8 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 if (type_sp)
   return type_sp;
 
-DWARFDeclContext die_decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
+DWARFDeclContext die_decl_ctx;
+SymbolFileDWARF::GetDWARFDeclContext(die, die_decl_ctx);
 
 // type_sp = FindDefinitionTypeForDIE (dwarf_cu, die,
 // type_name_const_str);
@@ -2323,9 +2325,10 @@ Function 
*DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
 unsigned type_quals = 0;
 std::vector param_types;
 std::vector param_decls;
+DWARFDeclContext decl_ctx;
 StreamString sstr;
 
-DWARFDeclContext decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
+SymbolFileDWARF::GetDWARFDeclContext(die, decl_ctx);
 sstr << decl_ctx.GetQualifiedName();
 
 clang::DeclContext *containing_decl_ctx =

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 4723fc8c35f2..885ca3d32d64 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -868,20 +868,19 @@ void DWARFDebugInfoEntry::BuildFunctionAddressRangeTable(
   }
 }
 
-DWARFDeclContext DWARFDebugInfoEntry::GetDWARFDeclContext(DWARFUnit *cu) const 
{
-  DWARFDeclContext dwarf_decl_ctx;
+void DWARFDebugInfoEntry::GetDWARFDeclContext(
+DWARFUnit *cu, DWARFDeclContext &dwarf_decl_ctx) const {
   const dw_tag_t tag = Tag();
   if (tag != DW_TAG_compile_unit && tag != DW_TAG_partial_unit) {
+dwarf_decl_ctx.AppendDeclContext(tag, GetName(cu));
 DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(cu);
 if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != this) {
   if (parent_decl_ctx_die.Tag() != DW_TAG_compile_unit &&
   parent_decl_ctx_die.Tag() != DW_TAG_partial_unit)
-dwarf_decl_ctx = parent_decl_ctx_die.GetDIE()->GetDWARFDeclContext(
-parent_decl_ctx_die.GetCU());
+parent_decl_ctx_die.GetDIE()->GetDWARFDeclContext(
+parent_decl_ctx_die.GetCU(), dwarf_decl_ctx);
 }
-dwarf_decl_ctx.AppendDeclContext(tag, GetName(cu));
   }
-  return dwarf_decl_ctx;
 }
 
 DWARFDIE

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
index a61ed5bbfe67..2bb69e738a2f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -158,7 +158,8 @@ class DWARFDebugInfoEntry {
 return HasChildren() ? this + 1 : nullptr;
   }
 
-  DWARFDeclContext GetDWARFDeclContext(DWARFUnit *cu) const;
+  void GetDWARFDeclContext(DWARFUnit *cu,
+   DWARFDeclContext &dwarf_decl_ctx) const;
 
   DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu) const;
   DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu,

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index b1d82ddb4e3e..5ef2dd3f04b3 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/Sy

[Lldb-commits] [PATCH] D73767: [lldb] [test] Pass LLVM_LIBS_DIR from CMake for linking liblldb

2020-01-31 Thread Michał Górny via Phabricator via lldb-commits
mgorny marked an inline comment as done.
mgorny added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:1680
 self.dylibPath] if self.dylibPath in os.environ else None
-lib_dir = os.environ["LLDB_LIB_DIR"]
+lib_dir = configuration.lldb_libs_dir
 if existing_library_path:

labath wrote:
> I'm not sure if this is right, because (despite the name) `LLDB_LIB_DIR` 
> points to the "bin" dir. But then again, this whole function seems pretty 
> wrong, so it's hard to say what should it really do here.
> 
>  If you don't need this part (the previous patch didn't have it) and want to 
> make this safe-ish for cherry-picking, maybe you could leave this part out 
> for now.
Ok, I'll do a second run and see if the result changes without it.


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

https://reviews.llvm.org/D73767



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


[Lldb-commits] [PATCH] D70646: Move non-DWARF code: `DWARFUnit` -> `SymbolFileDWARF`

2020-01-31 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

Reverted the refactorization by: 
https://github.com/llvm/llvm-project/commit/6dd0163502ff8c48195643b2b08a123c495743a0


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70646



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


[Lldb-commits] [PATCH] D73767: [lldb] [test] Pass LLVM_LIBS_DIR from CMake for linking liblldb

2020-01-31 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 241728.
mgorny added a comment.

Removed the aforementioned chunk.


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

https://reviews.llvm.org/D73767

Files:
  lldb/packages/Python/lldbsuite/test/configuration.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/dotest_args.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/lit.cfg.py
  lldb/test/API/lit.site.cfg.py.in

Index: lldb/test/API/lit.site.cfg.py.in
===
--- lldb/test/API/lit.site.cfg.py.in
+++ lldb/test/API/lit.site.cfg.py.in
@@ -10,6 +10,7 @@
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.lldb_obj_root = "@LLDB_BINARY_DIR@"
 config.lldb_src_root = "@LLDB_SOURCE_DIR@"
+config.lldb_libs_dir = "@LLDB_LIBS_DIR@"
 config.cmake_cxx_compiler = "@CMAKE_CXX_COMPILER@"
 config.host_os = "@HOST_OS@"
 config.host_triple = "@LLVM_HOST_TRIPLE@"
Index: lldb/test/API/lit.cfg.py
===
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py
@@ -114,6 +114,9 @@
 if config.filecheck:
   dotest_cmd += ['--filecheck', config.filecheck]
 
+if config.lldb_libs_dir:
+  dotest_cmd += ['--lldb-libs-dir', config.lldb_libs_dir]
+
 # We don't want to force users passing arguments to lit to use `;` as a
 # separator. We use Python's simple lexical analyzer to turn the args into a
 # list. Pass there arguments last so they can override anything that was
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1399,7 +1399,7 @@
 stdflag = self.getstdFlag()
 stdlibflag = self.getstdlibFlag()
 
-lib_dir = os.environ["LLDB_LIB_DIR"]
+lib_dir = configuration.lldb_libs_dir
 if self.hasDarwinFramework():
 d = {'CXX_SOURCES': sources,
  'EXE': exe_name,
@@ -1426,7 +1426,7 @@
  os.path.join(
  os.environ["LLDB_SRC"],
  "include")),
-'LD_EXTRAS': "-L%s/../lib -llldb -Wl,-rpath,%s/../lib" % (lib_dir, lib_dir)}
+'LD_EXTRAS': "-L%s -llldb -Wl,-rpath,%s" % (lib_dir, lib_dir)}
 if self.TraceOn():
 print(
 "Building LLDB Driver (%s) from sources %s" %
@@ -1439,7 +1439,7 @@
 
 stdflag = self.getstdFlag()
 
-lib_dir = os.environ["LLDB_LIB_DIR"]
+lib_dir = configuration.lldb_libs_dir
 if self.hasDarwinFramework():
 d = {'DYLIB_CXX_SOURCES': sources,
  'DYLIB_NAME': lib_name,
@@ -1464,7 +1464,7 @@
 os.path.join(
 os.environ["LLDB_SRC"],
 "include")),
-'LD_EXTRAS': "-shared -L%s/../lib -llldb -Wl,-rpath,%s/../lib" % (lib_dir, lib_dir)}
+'LD_EXTRAS': "-shared -L%s -llldb -Wl,-rpath,%s" % (lib_dir, lib_dir)}
 if self.TraceOn():
 print(
 "Building LLDB Library (%s) from sources %s" %
Index: lldb/packages/Python/lldbsuite/test/dotest_args.py
===
--- lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -172,6 +172,11 @@
 dest='clang_module_cache_dir',
 metavar='The clang module cache directory used by Clang',
 help='The clang module cache directory used in the Make files by Clang while building tests. Defaults to /module-cache-clang.')
+group.add_argument(
+'--lldb-libs-dir',
+dest='lldb_libs_dir',
+metavar='path',
+help='The path to LLDB library directory (containing liblldb)')
 
 # Configuration options
 group = parser.add_argument_group('Remote platform options')
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -452,6 +452,9 @@
 
 os.environ['CLANG_MODULE_CACHE_DIR'] = configuration.clang_module_cache_dir
 
+if args.lldb_libs_dir:
+configuration.lldb_libs_dir = args.lldb_libs_dir
+
 # Gather all the dirs passed on the command line.
 if len(args.args) > 0:
 configuration.testdirs = [os.path.realpath(os.path.abspath(x)) for x in args.args]
@@ -559,10 +562,7 @@
 # confusingly, this is the "bin" directory
 lldbLibDir = os.path.dirname(lldbtest_config.lldbExec)
 os.environ["LLDB_LIB_DIR"] = lldbLibDir
-lldbImpLibDir = os.p

[Lldb-commits] [lldb] edc3f4f - [NFC] [lldb] Unindent DWARFDebugInfoEntry::GetDWARFDeclContext

2020-01-31 Thread Jan Kratochvil via lldb-commits

Author: Jan Kratochvil
Date: 2020-01-31T16:51:33+01:00
New Revision: edc3f4f02e54c2ae1067f60f6a0ed6caf5b92ef6

URL: 
https://github.com/llvm/llvm-project/commit/edc3f4f02e54c2ae1067f60f6a0ed6caf5b92ef6
DIFF: 
https://github.com/llvm/llvm-project/commit/edc3f4f02e54c2ae1067f60f6a0ed6caf5b92ef6.diff

LOG: [NFC] [lldb] Unindent DWARFDebugInfoEntry::GetDWARFDeclContext

Reduce code indentation level.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 885ca3d32d64..5d22e3d607ac 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -871,15 +871,15 @@ void DWARFDebugInfoEntry::BuildFunctionAddressRangeTable(
 void DWARFDebugInfoEntry::GetDWARFDeclContext(
 DWARFUnit *cu, DWARFDeclContext &dwarf_decl_ctx) const {
   const dw_tag_t tag = Tag();
-  if (tag != DW_TAG_compile_unit && tag != DW_TAG_partial_unit) {
-dwarf_decl_ctx.AppendDeclContext(tag, GetName(cu));
-DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(cu);
-if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != this) {
-  if (parent_decl_ctx_die.Tag() != DW_TAG_compile_unit &&
-  parent_decl_ctx_die.Tag() != DW_TAG_partial_unit)
-parent_decl_ctx_die.GetDIE()->GetDWARFDeclContext(
-parent_decl_ctx_die.GetCU(), dwarf_decl_ctx);
-}
+  if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit)
+return;
+  dwarf_decl_ctx.AppendDeclContext(tag, GetName(cu));
+  DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(cu);
+  if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != this) {
+if (parent_decl_ctx_die.Tag() != DW_TAG_compile_unit &&
+parent_decl_ctx_die.Tag() != DW_TAG_partial_unit)
+  parent_decl_ctx_die.GetDIE()->GetDWARFDeclContext(
+  parent_decl_ctx_die.GetCU(), dwarf_decl_ctx);
   }
 }
 



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


[Lldb-commits] [PATCH] D73787: [NFC] Refactor `GetDWARFDeclContext` to return `DWARFDeclContext`

2020-01-31 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added a reviewer: labath.
jankratochvil added a project: LLDB.
Herald added a subscriber: aprantl.
Herald added a reviewer: shafik.

In D70646  I broke 
http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/7400/ so this is a 
second attempt.
Unfortunately I do not have reproducible the breakage of Green Dragon locally.
The bug was that `DWARFDebugInfoEntry::GetDWARFDeclContext` reversed order of 
the items, that is fixed now.
OK for check-in? It is no longer so pretty but still worth it IMO.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73787

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -315,8 +315,7 @@
   static lldb_private::CompilerDeclContext
   GetContainingDeclContext(const DWARFDIE &die);
 
-  static void GetDWARFDeclContext(const DWARFDIE &die,
-  DWARFDeclContext &dwarf_decl_ctx);
+  static DWARFDeclContext GetDWARFDeclContext(const DWARFDIE &die);
 
   static lldb::LanguageType LanguageTypeFromDWARF(uint64_t val);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2956,8 +2956,8 @@
 }
 
 if (try_resolving_type) {
-  DWARFDeclContext type_dwarf_decl_ctx;
-  GetDWARFDeclContext(type_die, type_dwarf_decl_ctx);
+  DWARFDeclContext type_dwarf_decl_ctx =
+  GetDWARFDeclContext(type_die);
 
   if (log) {
 GetObjectFile()->GetModule()->LogMessage(
@@ -3374,12 +3374,10 @@
 // declaration context.
 if ((parent_tag == DW_TAG_compile_unit ||
  parent_tag == DW_TAG_partial_unit) &&
-Language::LanguageIsCPlusPlus(GetLanguage(*die.GetCU( {
-  DWARFDeclContext decl_ctx;
-
-  GetDWARFDeclContext(die, decl_ctx);
-  mangled = decl_ctx.GetQualifiedNameAsConstString().GetCString();
-}
+Language::LanguageIsCPlusPlus(GetLanguage(*die.GetCU(
+  mangled = GetDWARFDeclContext(die)
+.GetQualifiedNameAsConstString()
+.GetCString();
   }
 
   if (tag == DW_TAG_formal_parameter)
@@ -3981,14 +3979,13 @@
   return CompilerDeclContext();
 }
 
-void SymbolFileDWARF::GetDWARFDeclContext(const DWARFDIE &die,
-  DWARFDeclContext &dwarf_decl_ctx) {
-  if (!die.IsValid()) {
-dwarf_decl_ctx.Clear();
-return;
-  }
+DWARFDeclContext SymbolFileDWARF::GetDWARFDeclContext(const DWARFDIE &die) {
+  if (!die.IsValid())
+return {};
+  DWARFDeclContext dwarf_decl_ctx =
+  die.GetDIE()->GetDWARFDeclContext(die.GetCU());
   dwarf_decl_ctx.SetLanguage(GetLanguage(*die.GetCU()));
-  die.GetDIE()->GetDWARFDeclContext(die.GetCU(), dwarf_decl_ctx);
+  return dwarf_decl_ctx;
 }
 
 LanguageType SymbolFileDWARF::LanguageTypeFromDWARF(uint64_t val) {
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -158,8 +158,7 @@
 return HasChildren() ? this + 1 : nullptr;
   }
 
-  void GetDWARFDeclContext(DWARFUnit *cu,
-   DWARFDeclContext &dwarf_decl_ctx) const;
+  DWARFDeclContext GetDWARFDeclContext(DWARFUnit *cu) const;
 
   DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu) const;
   DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu,
@@ -169,6 +168,9 @@
   void SetParentIndex(uint32_t idx) { m_parent_idx = idx; }
 
 protected:
+  void DWARFDebugInfoEntry::GetDWARFDeclContext(
+  DWARFUnit *cu, DWARFDeclContext &dwarf_decl_ctx) const;
+
   dw_offset_t m_offset; // Offset within the .debug_info/.debug_types
   uint32_t m_parent_idx; // How many to subtract from "this" to get the parent.
  // If zero this die has no parent
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -883,6 +883,12 @@
   }
 }
 
+DWARFDeclContext DWARFDebugInfo

[Lldb-commits] [PATCH] D73766: [RFC] Make substrs argument to self.expect ordered by default.

2020-01-31 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D73766#1851224 , @teemperor wrote:

> FWIW I'm currently going over the failing tests and fixing them, so unless I 
> find a test that actually needs unordered subsets I don't think having the 
> parameter makes sense.


Yep, that was my reasoning as well, if everything can be converted without 
falling back to the old behavior there's no need to keep the parameter.


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

https://reviews.llvm.org/D73766



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


[Lldb-commits] [PATCH] D73661: [lldb] Move clang-based files out of Symbol

2020-01-31 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

Making this a plugin makes sense. Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73661



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


[Lldb-commits] [lldb] 6c7efe2 - [lldb][NFC] Fix expect calls with wrong order of 'substrs' items for D73766

2020-01-31 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-01-31T17:54:18+01:00
New Revision: 6c7efe2eecf1495d2416ebc485025859d9dee74a

URL: 
https://github.com/llvm/llvm-project/commit/6c7efe2eecf1495d2416ebc485025859d9dee74a
DIFF: 
https://github.com/llvm/llvm-project/commit/6c7efe2eecf1495d2416ebc485025859d9dee74a.diff

LOG: [lldb][NFC] Fix expect calls with wrong order of 'substrs' items for D73766

Currently the substrs parameter takes a list of strings
that need to be found but the ordering isn't checked. D73766
might change that so this changes a several tests so that
the order of the strings in the substrs list is in the order
in which they appear in the output.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/commands/command/script/TestCommandScript.py
lldb/packages/Python/lldbsuite/test/commands/help/TestHelp.py

lldb/packages/Python/lldbsuite/test/commands/platform/process/TestProcessList.py

lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py

lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/condition/TestWatchpointConditionCmd.py

lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/inlined_breakpoints/TestInlinedBreakpoints.py

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py

lldb/packages/Python/lldbsuite/test/functionalities/multiword-commands/TestMultiWordCommands.py
lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py
lldb/packages/Python/lldbsuite/test/types/AbstractBase.py
lldb/packages/Python/lldbsuite/test/types/TestCharType.py
lldb/packages/Python/lldbsuite/test/types/TestCharTypeExpr.py
lldb/packages/Python/lldbsuite/test/types/TestIntegerType.py
lldb/packages/Python/lldbsuite/test/types/TestIntegerTypeExpr.py
lldb/packages/Python/lldbsuite/test/types/TestShortType.py
lldb/packages/Python/lldbsuite/test/types/TestShortTypeExpr.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/command/script/TestCommandScript.py
 
b/lldb/packages/Python/lldbsuite/test/commands/command/script/TestCommandScript.py
index de449612a37e..b103298f24e1 100644
--- 
a/lldb/packages/Python/lldbsuite/test/commands/command/script/TestCommandScript.py
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/command/script/TestCommandScript.py
@@ -86,12 +86,12 @@ def cleanup():
 substrs=["Python command defined by @lldb.command"])
 
 self.expect("help",
-substrs=['For more information run',
- 'welcome'] + decorated_commands)
+substrs=['For more information run']
+ + decorated_commands + ['welcome'])
 
 self.expect("help -a",
-substrs=['For more information run',
- 'welcome'] + decorated_commands)
+substrs=['For more information run']
+ + decorated_commands + ['welcome'])
 
 self.expect("help -u", matching=False,
 substrs=['For more information run'])

diff  --git a/lldb/packages/Python/lldbsuite/test/commands/help/TestHelp.py 
b/lldb/packages/Python/lldbsuite/test/commands/help/TestHelp.py
index 31656af633cc..f671fc7ad5f4 100644
--- a/lldb/packages/Python/lldbsuite/test/commands/help/TestHelp.py
+++ b/lldb/packages/Python/lldbsuite/test/commands/help/TestHelp.py
@@ -78,7 +78,7 @@ def version_number_string(self):
 def test_help_arch(self):
 """Test 'help arch' which should list of supported architectures."""
 self.expect("help arch",
-substrs=['arm', 'x86_64', 'i386'])
+substrs=['arm', 'i386', 'x86_64'])
 
 @no_debug_info_test
 def test_help_version(self):

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/platform/process/TestProcessList.py
 
b/lldb/packages/Python/lldbsuite/test/commands/platform/process/TestProcessList.py
index 102d6f92dd16..d20f6d6a5fea 100644
--- 
a/lldb/packages/Python/lldbsuite/test/commands/platform/process/TestProcessList.py
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/platform/process/TestProcessList.py
@@ -29,4 +29,4 @@ def test_process_list_with_args(self):
 self.addTearDownHook(self.cleanupSubprocesses)
 
 self.expect("platform process list -v",
-substrs=["TestProcess arg1 --arg2 arg3", str(popen.pid)])
+substrs=[str(popen.pid), "TestProcess arg1 --arg2 arg3"])

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py
 
b/lldb/packa

[Lldb-commits] [PATCH] D73148: [lldb/Value] Avoid reading more data than the host has available

2020-01-31 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

In D73148#1850978 , @vsk wrote:

> Yikes, this version seems to break TestClassTemplateParameterPack.py (and 
> probably other tests as well). Maybe we expect to be able to read past the 
> end of the buffer inside of a ValueObjectChild, because the buffer for the 
> next ValueObjectChild is supposed to be there?


Or they could be real bugs?


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

https://reviews.llvm.org/D73148



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


[Lldb-commits] [PATCH] D73781: [lldb/DWARF] Don't assume that a SymbolFileDWARFDwo contains one compile unit

2020-01-31 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

DWO is not really my area of expertise but this looks pretty straightforward.




Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp:29
+: SymbolFileDWARFDwo(dwarf_cu.GetSymbolFileDWARF(), objfile,
+ dwarf_cu.GetID()),
+  m_dwp_symfile(dwp_symfile), m_dwo_id(dwo_id) {}

Did you forget to clang-format?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73781



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


[Lldb-commits] [lldb] 2c19d05 - [lldb/Test] Fix substrs order in self.expect for more tests (NFC)

2020-01-31 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-31T10:29:33-08:00
New Revision: 2c19d05ae91e263585cd4633788d83563e67157a

URL: 
https://github.com/llvm/llvm-project/commit/2c19d05ae91e263585cd4633788d83563e67157a
DIFF: 
https://github.com/llvm/llvm-project/commit/2c19d05ae91e263585cd4633788d83563e67157a.diff

LOG: [lldb/Test] Fix substrs order in self.expect for more tests (NFC)

Currently the substrs parameter takes a list of strings that need to be
found but the ordering isn't checked. D73766 might change that so this
changes a several tests so that the order of the strings in the substrs
list is in the order in which they appear in the output.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/commands/expression/issue_11588/Test11588.py

lldb/packages/Python/lldbsuite/test/commands/frame/recognizer/TestFrameRecognizer.py
lldb/packages/Python/lldbsuite/test/commands/settings/TestSettings.py

lldb/packages/Python/lldbsuite/test/commands/target/basic/TestTargetCommand.py

lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/expression/issue_11588/Test11588.py
 
b/lldb/packages/Python/lldbsuite/test/commands/expression/issue_11588/Test11588.py
index abff18f3fa18..4f50e1cd1add 100644
--- 
a/lldb/packages/Python/lldbsuite/test/commands/expression/issue_11588/Test11588.py
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/expression/issue_11588/Test11588.py
@@ -60,7 +60,8 @@ def cleanup():
 self.expect("expr --show-types -- *(StgClosure*)$r14",
 substrs=["(StgClosure) $",
  "(StgClosure *) &$", "0x",
+ hex(addr)[2:].rstrip("L"),
  "addr = ",
+ str(addr),
  "load_address = ",
- hex(addr)[2:].rstrip("L"),
  str(addr)])

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/frame/recognizer/TestFrameRecognizer.py
 
b/lldb/packages/Python/lldbsuite/test/commands/frame/recognizer/TestFrameRecognizer.py
index 2ecbe1e4c15f..39ca7619acd0 100644
--- 
a/lldb/packages/Python/lldbsuite/test/commands/frame/recognizer/TestFrameRecognizer.py
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/frame/recognizer/TestFrameRecognizer.py
@@ -34,10 +34,12 @@ def test_frame_recognizer_1(self):
 
 self.runCmd("frame recognizer add -l recognizer.MyOtherFrameRecognizer 
-s a.out -n bar -x")
 
-self.expect("frame recognizer list",
-substrs=['0: recognizer.MyFrameRecognizer, module a.out, 
function foo',
- '1: recognizer.MyOtherFrameRecognizer, module 
a.out, function bar (regexp)'
-])
+self.expect(
+"frame recognizer list",
+substrs=[
+'1: recognizer.MyOtherFrameRecognizer, module a.out, function 
bar (regexp)',
+'0: recognizer.MyFrameRecognizer, module a.out, function foo'
+])
 
 self.runCmd("frame recognizer delete 0")
 

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/settings/TestSettings.py 
b/lldb/packages/Python/lldbsuite/test/commands/settings/TestSettings.py
index 1130821bac0f..2bc9a91b5bf5 100644
--- a/lldb/packages/Python/lldbsuite/test/commands/settings/TestSettings.py
+++ b/lldb/packages/Python/lldbsuite/test/commands/settings/TestSettings.py
@@ -485,7 +485,7 @@ def test_settings_with_trailing_whitespace(self):
 
 def test_settings_list(self):
 # List settings (and optionally test the filter to only show 'target' 
settings).
-self.expect("settings list target", substrs=["language", "arg0", 
"detach-on-error"])
+self.expect("settings list target", substrs=["arg0", 
"detach-on-error", "language"])
 self.expect("settings list target", matching=False, 
substrs=["packet-timeout"])
 self.expect("settings list", substrs=["language", "arg0", 
"detach-on-error", "packet-timeout"])
 
@@ -537,33 +537,34 @@ def test_all_settings_exist(self):
  "term-width",
  "thread-format",
  "use-external-editor",
+ "target.breakpoints-use-platform-avoid-list",
  "target.default-arch",
- "target.move-to-nearest-code",
- "target.expr-prefix",
- "target.language",
- "target.prefer-dynamic-value",
+ "target.disable-aslr",
+ "target.disable-stdio",
+ "target.x86-dis

[Lldb-commits] [PATCH] D73782: [lldb/DWARF] Don't hold a unique SymbolFileDWARFDwo in a DWARFUnit

2020-01-31 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp:56
+return nullptr;
+  if (hash != 
cu->GetUnitDIEOnly().GetAttributeValueAsUnsigned(DW_AT_GNU_dwo_id, 0))
+return nullptr;

How often does this function get called? Should we cache the DW_AT_GNU_dwo_id 
in the DWARFCompileUnit to avoid extracting the DW_AT_GNU_dwo_id attribute 
maybe multiple times? 



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h:67
   SymbolFileDWARF &GetBaseSymbolFile() { return m_base_symbol_file; }
 
+  DWARFCompileUnit *FindSingleCompileUnit();

Curious: what is a single compile unit? A bit of a comment in header doc here 
might be nice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73782



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


[Lldb-commits] [PATCH] D73661: [lldb] Move clang-based files out of Symbol

2020-01-31 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.

Nice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73661



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


[Lldb-commits] [PATCH] D73766: [RFC] Make substrs argument to self.expect ordered by default.

2020-01-31 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

The current behavior does make tests less dependent on the exact details of 
lldb's command output.  If there were two independent pieces of data in a 
command output that you wanted to compare against, you would have to fix some 
tests if you ever changed the ordering in the result.  It was the case that the 
gdb test suite hampered the evolution of the command output because it was just 
too much of a pain to go change the tests.  For instance, you really couldn't 
muck with breakpoint reporting output or stop notifications; the pain of fixing 
up the testsuite was way too high.  But in this case, the fix would just be 
reordering the substrings in the Python array.  So though this sort of thing 
makes me a little uneasy, in this case I think it's fine.

Note, if there is a test that depends on the substring output not coming out in 
a fixed order, then I think giving that test the stink-eye is more appropriate 
than keeping an "ordered" flag around.


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

https://reviews.llvm.org/D73766



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


[Lldb-commits] [lldb] 574685b - [lldb/Symbol] Use StringRef ctor to prevent incorrect overload

2020-01-31 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-31T11:00:46-08:00
New Revision: 574685b879acff462faa1e5e480825033c589778

URL: 
https://github.com/llvm/llvm-project/commit/574685b879acff462faa1e5e480825033c589778
DIFF: 
https://github.com/llvm/llvm-project/commit/574685b879acff462faa1e5e480825033c589778.diff

LOG: [lldb/Symbol] Use StringRef ctor to prevent incorrect overload

Use the StringRef constructor instead of toStringRef so we don't end up
with the wrong overload (llvm::toStringRef(bool)).

Fixes PR44736

Added: 


Modified: 
lldb/source/Symbol/TypeSystem.cpp

Removed: 




diff  --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index be080018852a..b0131e988363 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -239,7 +239,7 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   error = llvm::make_error(
   "TypeSystem for language " +
-  llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+  llvm::StringRef(Language::GetNameForLanguageType(language)) +
   " doesn't exist",
   llvm::inconvertibleErrorCode());
   return std::move(error);
@@ -256,7 +256,7 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
 }
 error = llvm::make_error(
 "TypeSystem for language " +
-llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+llvm::StringRef(Language::GetNameForLanguageType(language)) +
 " doesn't exist",
 llvm::inconvertibleErrorCode());
 return std::move(error);
@@ -266,7 +266,7 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
 if (!can_create) {
   error = llvm::make_error(
   "Unable to find type system for language " +
-  llvm::toStringRef(Language::GetNameForLanguageType(language)),
+  llvm::StringRef(Language::GetNameForLanguageType(language)),
   llvm::inconvertibleErrorCode());
 } else {
   // Cache even if we get a shared pointer that contains a null type system
@@ -279,7 +279,7 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   error = llvm::make_error(
   "TypeSystem for language " +
-  llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+  llvm::StringRef(Language::GetNameForLanguageType(language)) +
   " doesn't exist",
   llvm::inconvertibleErrorCode());
 }
@@ -308,7 +308,7 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   error = llvm::make_error(
   "TypeSystem for language " +
-  llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+  llvm::StringRef(Language::GetNameForLanguageType(language)) +
   " doesn't exist",
   llvm::inconvertibleErrorCode());
   return std::move(error);
@@ -325,7 +325,7 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
 }
 error = llvm::make_error(
 "TypeSystem for language " +
-llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+llvm::StringRef(Language::GetNameForLanguageType(language)) +
 " doesn't exist",
 llvm::inconvertibleErrorCode());
 return std::move(error);
@@ -335,7 +335,7 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
 if (!can_create) {
   error = llvm::make_error(
   "Unable to find type system for language " +
-  llvm::toStringRef(Language::GetNameForLanguageType(language)),
+  llvm::StringRef(Language::GetNameForLanguageType(language)),
   llvm::inconvertibleErrorCode());
 } else {
   // Cache even if we get a shared pointer that contains a null type system
@@ -348,7 +348,7 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   error = llvm::make_error(
   "TypeSystem for language " +
-  llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+  llvm::StringRef(Language::GetNameForLanguageType(language)) +
   " doesn't exist",
   llvm::inconvertibleErrorCode());
 }



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


[Lldb-commits] [PATCH] D73783: [lldb/DWARF] Re-enable basic dwp support

2020-01-31 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

This looks good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73783



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


[Lldb-commits] [PATCH] D73279: testsuite: generalize `DWARFASTParserClangTests` based on `DWARFExpressionTest`'s YAML

2020-01-31 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

I like the direction!




Comment at: lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp:1
+//===- YAMLModuleTester.cpp -*- C++ 
-*-===//
+//

Nit: the `-*- C++ -*-` only makes sense in a .h file where the language is 
ambiguous.



Comment at: lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h:24
+class YAMLModuleTester {
+  //  SubsystemRAII subsystems;
+  SubsystemRAII subsystems;

?



Comment at: lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h:37
+
+  // Evaluate a raw DWARF expression.
+  llvm::Expected Eval(llvm::ArrayRef expr);

///



Comment at: lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h:38
+  // Evaluate a raw DWARF expression.
+  llvm::Expected Eval(llvm::ArrayRef expr);
+};

Should this be implemented in a sub-class that is specific to the 
DWARFExpression tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73279



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


[Lldb-commits] [PATCH] D73279: testsuite: generalize `DWARFASTParserClangTests` based on `DWARFExpressionTest`'s YAML

2020-01-31 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 241784.
jankratochvil marked 3 inline comments as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73279

Files:
  lldb/unittests/Expression/DWARFExpressionTest.cpp
  lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
  lldb/unittests/TestingSupport/CMakeLists.txt
  lldb/unittests/TestingSupport/Symbol/CMakeLists.txt
  lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
  lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h
  lldb/unittests/TestingSupport/module.modulemap

Index: lldb/unittests/TestingSupport/module.modulemap
===
--- lldb/unittests/TestingSupport/module.modulemap
+++ lldb/unittests/TestingSupport/module.modulemap
@@ -13,4 +13,5 @@
 module lldb_TestingSupport_Symbol {
   requires cplusplus
   module ClangTestUtils { header "Symbol/ClangTestUtils.h" export * }
+  module YAMLModuleTester { header "Symbol/YAMLModuleTester.h" export * }
 }
Index: lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h
===
--- /dev/null
+++ lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h
@@ -0,0 +1,40 @@
+//===- YAMLModuleTester.h ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_UNITTESTS_TESTINGSUPPORT_SYMBOL_YAMLMODULETESTER_H
+#define LLDB_UNITTESTS_TESTINGSUPPORT_SYMBOL_YAMLMODULETESTER_H
+
+#include "Plugins/SymbolFile/DWARF/DWARFUnit.h"
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/TypeSystemClang.h"
+
+namespace lldb_private {
+
+/// Helper class that can construct a module from YAML and evaluate
+/// DWARF expressions on it.
+class YAMLModuleTester {
+protected:
+  SubsystemRAII subsystems;
+  llvm::StringMap> m_sections_map;
+  lldb::ModuleSP m_module_sp;
+  lldb::ObjectFileSP m_objfile_sp;
+  DWARFUnitSP m_dwarf_unit;
+  std::unique_ptr m_symfile_dwarf;
+
+public:
+  /// Parse the debug info sections from the YAML description.
+  YAMLModuleTester(llvm::StringRef yaml_data, llvm::StringRef triple);
+  DWARFUnitSP GetDwarfUnit() { return m_dwarf_unit; }
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_UNITTESTS_TESTINGSUPPORT_SYMBOL_YAMLMODULETESTER_H
Index: lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
===
--- /dev/null
+++ lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
@@ -0,0 +1,116 @@
+//===-- YAMLModuleTester.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestingSupport/Symbol/YAMLModuleTester.h"
+#include "lldb/Core/Section.h"
+#include "llvm/ObjectYAML/DWARFEmitter.h"
+
+using namespace lldb_private;
+
+/// A mock module holding an object file parsed from YAML.
+class YAMLModule : public lldb_private::Module {
+public:
+  YAMLModule(ArchSpec &arch) : Module(FileSpec("test"), arch) {}
+  void SetObjectFile(lldb::ObjectFileSP obj_file) { m_objfile_sp = obj_file; }
+  ObjectFile *GetObjectFile() override { return m_objfile_sp.get(); }
+};
+
+/// A mock object file that can be parsed from YAML.
+class YAMLObjectFile : public lldb_private::ObjectFile {
+  const lldb::ModuleSP m_module_sp;
+  llvm::StringMap> &m_section_map;
+  /// Because there is only one DataExtractor in the ObjectFile
+  /// interface, all sections are copied into a contiguous buffer.
+  std::vector m_buffer;
+
+public:
+  YAMLObjectFile(const lldb::ModuleSP &module_sp,
+ llvm::StringMap> &map)
+  : ObjectFile(module_sp, &module_sp->GetFileSpec(), /*file_offset*/ 0,
+   /*length*/ 0, /*data_sp*/ nullptr, /*data_offset*/ 0),
+m_module_sp(module_sp), m_section_map(map) {}
+
+  /// Callback for initializing the module's list of sections.
+  void CreateSections(SectionList &unified_section_list) override {
+lldb::offset_t total_bytes = 0;
+for (auto &entry : m_section_map)
+  total_bytes += entry.getValue()->getBufferSize();
+m_buffer.reserve(total_bytes);
+m_data =
+DataExtractor(m_buffer.data(), total_bytes, lldb::eByteOrderLittle, 4);
+
+lldb::user_id_t sect_id = 1;
+for (auto &entry : m_section_map) {
+  llvm::StringRef na

[Lldb-commits] [PATCH] D73279: testsuite: generalize `DWARFASTParserClangTests` based on `DWARFExpressionTest`'s YAML

2020-01-31 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked 8 inline comments as done.
jankratochvil added inline comments.



Comment at: lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h:24
+class YAMLModuleTester {
+  //  SubsystemRAII subsystems;
+  SubsystemRAII subsystems;

aprantl wrote:
> ?
some leftover, sorry



Comment at: lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h:37
+
+  // Evaluate a raw DWARF expression.
+  llvm::Expected Eval(llvm::ArrayRef expr);

aprantl wrote:
> ///
OK although it was even in the original file.



Comment at: lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h:38
+  // Evaluate a raw DWARF expression.
+  llvm::Expected Eval(llvm::ArrayRef expr);
+};

aprantl wrote:
> Should this be implemented in a sub-class that is specific to the 
> DWARFExpression tests?
Yes, true, I did not realize that, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73279



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


[Lldb-commits] [lldb] 8be3021 - [lldb] Move clang-based files out of Symbol

2020-01-31 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2020-01-31T12:20:10-08:00
New Revision: 8be30215feeff1d82fe2bde0c9fb0e6cd1bfc15c

URL: 
https://github.com/llvm/llvm-project/commit/8be30215feeff1d82fe2bde0c9fb0e6cd1bfc15c
DIFF: 
https://github.com/llvm/llvm-project/commit/8be30215feeff1d82fe2bde0c9fb0e6cd1bfc15c.diff

LOG: [lldb] Move clang-based files out of Symbol

Summary:
This change represents the move of ClangASTImporter, ClangASTMetadata,
ClangExternalASTSourceCallbacks, ClangUtil, CxxModuleHandler, and
TypeSystemClang from lldbSource to lldbPluginExpressionParserClang.h

This explicitly removes knowledge of clang internals from lldbSymbol,
moving towards a more generic core implementation of lldb.

Reviewers: JDevlieghere, davide, aprantl, teemperor, clayborg, labath, jingham, 
shafik

Subscribers: emaste, mgorny, arphaman, jfb, usaxena95, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D73661

Added: 
lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.h

lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h
lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.h
lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.h
lldb/source/Plugins/TypeSystem/CMakeLists.txt
lldb/source/Plugins/TypeSystem/Clang/CMakeLists.txt
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h

Modified: 
lldb/source/API/SystemInitializerFull.cpp
lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
lldb/source/Plugins/ABI/SysV-ppc64/CMakeLists.txt
lldb/source/Plugins/CMakeLists.txt
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
lldb/source/Plugins/Language/ObjC/CF.cpp
lldb/source/Plugins/Language/ObjC/CMakeLists.txt
lldb/source/Plugins/Language/ObjC/Cocoa.cpp
lldb/source/Plugins/Language/ObjC/NSArray.cpp
lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
lldb/source/Plugins/Language/ObjC/NSError.cpp
lldb/source/Plugins/Language/ObjC/NSException.cpp
lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp
lldb/source/Plugins/Language/ObjC/NSSet.cpp
lldb/source/Plugins/Language/ObjC/NSString.cpp
lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt

lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2

[Lldb-commits] [PATCH] D73661: [lldb] Move clang-based files out of Symbol

2020-01-31 Thread Alex Langford via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8be30215feef: [lldb] Move clang-based files out of Symbol 
(authored by xiaobai).

Changed prior to commit:
  https://reviews.llvm.org/D73661?vs=241584&id=241791#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73661

Files:
  lldb/include/lldb/Symbol/ClangASTImporter.h
  lldb/include/lldb/Symbol/ClangASTMetadata.h
  lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
  lldb/include/lldb/Symbol/ClangUtil.h
  lldb/include/lldb/Symbol/CxxModuleHandler.h
  lldb/include/lldb/Symbol/TypeSystemClang.h
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
  lldb/source/Plugins/ABI/SysV-ppc64/CMakeLists.txt
  lldb/source/Plugins/CMakeLists.txt
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
  lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.h
  lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
  lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.h
  lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
  lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
  lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
  lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
  lldb/source/Plugins/Language/ObjC/CF.cpp
  lldb/source/Plugins/Language/ObjC/CMakeLists.txt
  lldb/source/Plugins/Language/ObjC/Cocoa.cpp
  lldb/source/Plugins/Language/ObjC/NSArray.cpp
  lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
  lldb/source/Plugins/Language/ObjC/NSError.cpp
  lldb/source/Plugins/Language/ObjC/NSException.cpp
  lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp
  lldb/source/Plugins/Language/ObjC/NSSet.cpp
  lldb/source/Plugins/Language/ObjC/NSString.cpp
  lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
  lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt
  lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
  lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
  lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
  lldb/source/Plugins/Platform/POSIX/CMakeLists.txt
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFA

[Lldb-commits] [lldb] 81b0bec - [lldb/Test] Fix substrs order in self.expect for more tests (NFC)

2020-01-31 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-31T12:44:24-08:00
New Revision: 81b0becaaee65fa5342eca6c2dc7855852a92372

URL: 
https://github.com/llvm/llvm-project/commit/81b0becaaee65fa5342eca6c2dc7855852a92372
DIFF: 
https://github.com/llvm/llvm-project/commit/81b0becaaee65fa5342eca6c2dc7855852a92372.diff

LOG: [lldb/Test] Fix substrs order in self.expect for more tests (NFC)

Currently the substrs parameter takes a list of strings that need to be
found but the ordering isn't checked. D73766 might change that so this
changes a several tests so that the order of the strings in the substrs
list is in the order in which they appear in the output.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py

lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py

lldb/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
index 895f4fa1e374..9f0ba1116867 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
@@ -38,7 +38,7 @@ def test_bad_command_lines(self):
 """Make sure we get appropriate errors when we give invalid key/value
options"""
 self.build()
-self.do_test_bad_options()
+self.do_test_bad_options()
 
 def make_target_and_import(self):
 target = lldbutil.run_to_breakpoint_make_target(self)
@@ -110,7 +110,7 @@ def do_test(self):
 module_list.Clear()
 file_list.Append(lldb.SBFileSpec("noFileOfThisName.xxx"))
 wrong.append(target.BreakpointCreateFromScript("resolver.Resolver", 
extra_args, module_list, file_list))
-
+
 # Now make sure the CU level iteration obeys the file filters:
 file_list.Clear()
 module_list.Clear()
@@ -142,7 +142,7 @@ def do_test(self):
 # Now run to main and ensure we hit the breakpoints we should have:
 
 lldbutil.run_to_breakpoint_do_run(self, target, right[0])
-
+
 # Test the hit counts:
 for i in range(0, len(right)):
 self.assertEqual(right[i].GetHitCount(), 1, "Breakpoint %d has the 
wrong hit count"%(i))
@@ -167,12 +167,12 @@ def do_test_depths(self):
 bkpt = target.BreakpointCreateFromScript("resolver.Resolver", 
extra_args, module_list, file_list)
 self.assertTrue(bkpt.GetNumLocations() > 0, "Resolver got no 
locations.")
 self.expect("script print(resolver.Resolver.got_files)", 
substrs=["2"], msg="Was only passed modules")
-
+
 # Make a breakpoint that asks for modules, check that we didn't get 
any files:
 bkpt = 
target.BreakpointCreateFromScript("resolver.ResolverModuleDepth", extra_args, 
module_list, file_list)
 self.assertTrue(bkpt.GetNumLocations() > 0, "ResolverModuleDepth got 
no locations.")
 self.expect("script print(resolver.Resolver.got_files)", 
substrs=["2"], msg="Was only passed modules")
-
+
 # Make a breakpoint that asks for compile units, check that we didn't 
get any files:
 bkpt = target.BreakpointCreateFromScript("resolver.ResolverCUDepth", 
extra_args, module_list, file_list)
 self.assertTrue(bkpt.GetNumLocations() > 0, "ResolverCUDepth got no 
locations.")
@@ -187,7 +187,7 @@ def do_test_depths(self):
 bkpt = target.BreakpointCreateFromScript("resolver.ResolverFuncDepth", 
extra_args, module_list, file_list)
 self.assertTrue(bkpt.GetNumLocations() > 0, "ResolverFuncDepth got no 
locations.")
 self.expect("script print(resolver.Resolver.got_files)", 
substrs=["3"], msg="Was only passed modules")
-self.expect("script print(resolver.Resolver.func_list)", 
substrs=["break_on_me", "main", "test_func"], msg="Saw all the functions")
+self.expect("script print(resolver.Resolver.func_list)", 
substrs=['test_func', 'break_on_me', 'main'], msg="Saw all the functions")
 
 def

[Lldb-commits] [PATCH] D73802: [lldb] Introduce i386 support in NetBSD Process plugin

2020-01-31 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, krytarowski.

Introduce support for i386 platform that is shared with amd64
in the same plugin.  The concept is partially based on the Linux
implementation.

The plugin tries to reuse as much code as possible.  As a result, i386
register enums are mapped into amd64 values and those are used in actual
code.  The code for accessing FPU and debug registers is shared,
although general-purpose register layouts do not match between the two
kernel APIs and need to be #ifdef-ed.

This layout will also make it possible to add support for debugging
32-bit programs on amd64 with minimal added code.

In order for this to work, I had to add missing data for debug registers
on i386.


https://reviews.llvm.org/D73802

Files:
  lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
  lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
  lldb/source/Plugins/Process/Utility/CMakeLists.txt
  lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.h
  lldb/source/Plugins/Process/Utility/RegisterInfos_i386.h
  lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h

Index: lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h
===
--- lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h
+++ lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h
@@ -113,7 +113,8 @@
   lldb_bndstatus_i386,
   k_last_mpxc_i386 = lldb_bndstatus_i386,
 
-  lldb_dr0_i386,
+  k_first_dbr_i386,
+  lldb_dr0_i386 = k_first_dbr_i386,
   lldb_dr1_i386,
   lldb_dr2_i386,
   lldb_dr3_i386,
@@ -121,6 +122,7 @@
   lldb_dr5_i386,
   lldb_dr6_i386,
   lldb_dr7_i386,
+  k_last_dbr_i386 = lldb_dr7_i386,
 
   k_num_registers_i386,
   k_num_gpr_registers_i386 = k_last_gpr_i386 - k_first_gpr_i386 + 1,
@@ -131,6 +133,7 @@
   k_num_fpr_registers_i386 +
   k_num_avx_registers_i386 +
   k_num_mpx_registers_i386,
+  k_num_dbr_registers_i386 = k_last_dbr_i386 - k_first_dbr_i386 + 1,
 };
 
 // Internal codes for all x86_64 registers.
Index: lldb/source/Plugins/Process/Utility/RegisterInfos_i386.h
===
--- lldb/source/Plugins/Process/Utility/RegisterInfos_i386.h
+++ lldb/source/Plugins/Process/Utility/RegisterInfos_i386.h
@@ -145,7 +145,7 @@
 DR_OFFSET(i), eEncodingUint, eFormatHex,   \
   {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,   \
LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,   \
-   LLDB_INVALID_REGNUM },  \
+   lldb_##reg##i##_i386 }, \
nullptr, nullptr, nullptr, 0\
   }
 
Index: lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.h
===
--- /dev/null
+++ lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.h
@@ -0,0 +1,25 @@
+//===-- RegisterContextNetBSD_i386.h *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_RegisterContextNetBSD_i386_H_
+#define liblldb_RegisterContextNetBSD_i386_H_
+
+#include "RegisterInfoInterface.h"
+
+class RegisterContextNetBSD_i386 : public lldb_private::RegisterInfoInterface {
+public:
+  RegisterContextNetBSD_i386(const lldb_private::ArchSpec &target_arch);
+
+  size_t GetGPRSize() const override;
+
+  const lldb_private::RegisterInfo *GetRegisterInfo() const override;
+
+  uint32_t GetRegisterCount() const override;
+};
+
+#endif
Index: lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.cpp
===
--- /dev/null
+++ lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.cpp
@@ -0,0 +1,95 @@
+//===-- RegisterContextNetBSD_i386.cpp -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===-===//
+
+#include "RegisterContextNetBSD_i386.h"
+#include "RegisterContextPOSIX_x86.h"
+
+using namespace lldb_private;
+using namespace lldb;
+
+// this needs to match 'struct reg'
+struct GPR {
+  uint32_t eax;
+  uint32_t ecx;
+  uint32_t edx;
+  uint32_t ebx;
+ 

[Lldb-commits] [lldb] d02fb00 - [lldb/Test] Make substrs argument to self.expect ordered.

2020-01-31 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-31T13:35:37-08:00
New Revision: d02fb002dd6b57e2ecbc3a4c3df91f5ed3a6054e

URL: 
https://github.com/llvm/llvm-project/commit/d02fb002dd6b57e2ecbc3a4c3df91f5ed3a6054e
DIFF: 
https://github.com/llvm/llvm-project/commit/d02fb002dd6b57e2ecbc3a4c3df91f5ed3a6054e.diff

LOG: [lldb/Test] Make substrs argument to self.expect ordered.

This patch changes the behavior of the substrs argument to self.expect.
Currently, the elements of substrs are unordered and as long as the
string appears in the output, the assertion passes.

We can be more precise by requiring that the substrings be ordered in
the way they appear. My hope is that this will make it harder to
accidentally pass a check because a string appears out of order.

Differential revision: https://reviews.llvm.org/D73766

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 602749c80fa8..933a99d5e142 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2341,8 +2341,11 @@ def expect(
 # Look for sub strings, if specified.
 keepgoing = matched if matching else not matched
 if substrs and keepgoing:
+start = 0
 for substr in substrs:
-matched = output.find(substr) != -1
+index = output[start:].find(substr)
+start = start + index if matching else 0
+matched = index != -1
 with recording(self, trace) as sbuf:
 print("%s sub string: %s" % (heading, substr), file=sbuf)
 print("Matched" if matched else "Not matched", file=sbuf)



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


[Lldb-commits] [PATCH] D73766: [RFC] Make substrs argument to self.expect ordered by default.

2020-01-31 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd02fb002dd6b: [lldb/Test] Make substrs argument to 
self.expect ordered. (authored by JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D73766?vs=241637&id=241801#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73766

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2341,8 +2341,11 @@
 # Look for sub strings, if specified.
 keepgoing = matched if matching else not matched
 if substrs and keepgoing:
+start = 0
 for substr in substrs:
-matched = output.find(substr) != -1
+index = output[start:].find(substr)
+start = start + index if matching else 0
+matched = index != -1
 with recording(self, trace) as sbuf:
 print("%s sub string: %s" % (heading, substr), file=sbuf)
 print("Matched" if matched else "Not matched", file=sbuf)


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2341,8 +2341,11 @@
 # Look for sub strings, if specified.
 keepgoing = matched if matching else not matched
 if substrs and keepgoing:
+start = 0
 for substr in substrs:
-matched = output.find(substr) != -1
+index = output[start:].find(substr)
+start = start + index if matching else 0
+matched = index != -1
 with recording(self, trace) as sbuf:
 print("%s sub string: %s" % (heading, substr), file=sbuf)
 print("Matched" if matched else "Not matched", file=sbuf)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D73802: [lldb] Introduce i386 support in NetBSD Process plugin

2020-01-31 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added inline comments.



Comment at: 
lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.cpp:62
+  GPR gpr;
+  FPR_i386 i387;
+  uint32_t u_debugreg[8]; // Debug registers (DR0 - DR7).

Please add `uint32_t tlsbase;`.


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

https://reviews.llvm.org/D73802



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


[Lldb-commits] [lldb] 6f2a4c4 - Revert "[lldb/Test] Make substrs argument to self.expect ordered."

2020-01-31 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-31T13:50:39-08:00
New Revision: 6f2a4c424e14e2564c64450d9416036ebe97b260

URL: 
https://github.com/llvm/llvm-project/commit/6f2a4c424e14e2564c64450d9416036ebe97b260
DIFF: 
https://github.com/llvm/llvm-project/commit/6f2a4c424e14e2564c64450d9416036ebe97b260.diff

LOG: Revert "[lldb/Test] Make substrs argument to self.expect ordered."

Temporarily revert to fix the tests that only fail on the bots because
of the newly enforced substr order.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 933a99d5e142..602749c80fa8 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2341,11 +2341,8 @@ def expect(
 # Look for sub strings, if specified.
 keepgoing = matched if matching else not matched
 if substrs and keepgoing:
-start = 0
 for substr in substrs:
-index = output[start:].find(substr)
-start = start + index if matching else 0
-matched = index != -1
+matched = output.find(substr) != -1
 with recording(self, trace) as sbuf:
 print("%s sub string: %s" % (heading, substr), file=sbuf)
 print("Matched" if matched else "Not matched", file=sbuf)



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


[Lldb-commits] [PATCH] D73148: [lldb/Value] Avoid reading more data than the host has available

2020-01-31 Thread Vedant Kumar via Phabricator via lldb-commits
vsk updated this revision to Diff 241814.
vsk edited the summary of this revision.
vsk added a comment.

- Go with @gclayton's original suggestion, as it's proven to be impractical to 
alter the notion of a Value's size in the Value/ValueObject logic.
- I've tested this and gotten a clean check-lldb run. The added tests now pass 
ASan-clean.


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

https://reviews.llvm.org/D73148

Files:
  lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/TestNoASanExceptionAfterEvalOP_piece.py
  lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/main.cpp
  lldb/source/Core/ValueObjectVariable.cpp
  lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-smaller-than-struct.s

Index: lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-smaller-than-struct.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-smaller-than-struct.s
@@ -0,0 +1,110 @@
+# RUN: llvm-mc -filetype=obj -o %t -triple x86_64-pc-linux %s
+# RUN: %lldb %t -o "target variable reset" -b | FileCheck %s
+
+# CHECK: (lldb) target variable reset
+# CHECK: (auto_reset) reset = {
+# CHECK:   ptr = 0xdeadbeefbaadf00d
+# Note: We need to find some way to represent "prev" as unknown/undefined.
+# CHECK:   prev = false
+# CHECK: }
+
+.section.debug_abbrev,"",@progbits
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   1   # DW_CHILDREN_yes
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   2   # Abbreviation Code
+.byte   52  # DW_TAG_variable
+.byte   0   # DW_CHILDREN_no
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   73  # DW_AT_type
+.byte   19  # DW_FORM_ref4
+.byte   2   # DW_AT_location
+.byte   24  # DW_FORM_exprloc
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   3   # Abbreviation Code
+.byte   36  # DW_TAG_base_type
+.byte   0   # DW_CHILDREN_no
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   62  # DW_AT_encoding
+.byte   11  # DW_FORM_data1
+.byte   11  # DW_AT_byte_size
+.byte   11  # DW_FORM_data1
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   4   # Abbreviation Code
+.byte   19  # DW_TAG_structure_type
+.byte   1   # DW_CHILDREN_yes
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   11  # DW_AT_byte_size
+.byte   11  # DW_FORM_data1
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   5   # Abbreviation Code
+.byte   13  # DW_TAG_member
+.byte   0   # DW_CHILDREN_no
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   73  # DW_AT_type
+.byte   19  # DW_FORM_ref4
+.byte   56  # DW_AT_data_member_location
+.byte   11  # DW_FORM_data1
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   6   # Abbreviation Code
+.byte   15  # DW_TAG_pointer_type
+.byte   0   # DW_CHILDREN_no
+.byte   73  # DW_AT_type
+.byte   19  # DW_FORM_ref4
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   0   # EOM(3)
+
+.section.debug_info,"",@progbits
+.Lcu_begin0:
+.long   .Lcu_end-.Lcu_start # Length of Unit
+.Lcu_start:
+.short  4   # DWARF version number
+.long   .debug_abbrev   # Offset Into Abbrev. Section
+.byte   8   # Address Size (in bytes)
+.byte   1   # Abbrev [1] 0xb:0x6c DW_TAG_compile_u

[Lldb-commits] [lldb] d3bdd51 - [lldb/Platform] Always print Kernel last

2020-01-31 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-31T14:36:39-08:00
New Revision: d3bdd51f70449435443b3e8ff254cba49d4aba80

URL: 
https://github.com/llvm/llvm-project/commit/d3bdd51f70449435443b3e8ff254cba49d4aba80
DIFF: 
https://github.com/llvm/llvm-project/commit/d3bdd51f70449435443b3e8ff254cba49d4aba80.diff

LOG: [lldb/Platform] Always print Kernel last

Specializations of the Platform class print the kernel after calling the
super method. By printing the kernel at the end in the super class, we
guarantee the order is the same on different platforms.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformCommand.py
lldb/source/Target/Platform.cpp

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformCommand.py
 
b/lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformCommand.py
index ab45b221c94d..9c16da8ad005 100644
--- 
a/lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformCommand.py
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformCommand.py
@@ -42,8 +42,9 @@ def test_status(self):
 'Platform',
 'Triple',
 'OS Version',
+'Hostname',
 'Kernel',
-'Hostname'])
+])
 
 @expectedFailureAll(oslist=["windows"])
 @no_debug_info_test

diff  --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 0ad3f36266c3..3739ccd7edc6 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -421,9 +421,6 @@ void Platform::GetStatus(Stream &strm) {
 strm.EOL();
   }
 
-  if (GetOSKernelDescription(s))
-strm.Printf("Kernel: %s\n", s.c_str());
-
   if (IsHost()) {
 strm.Printf("  Hostname: %s\n", GetHostname());
   } else {
@@ -443,6 +440,9 @@ void Platform::GetStatus(Stream &strm) {
 
   if (!specific_info.empty())
 strm.Printf("Platform-specific connection: %s\n", specific_info.c_str());
+
+  if (GetOSKernelDescription(s))
+strm.Printf("Kernel: %s\n", s.c_str());
 }
 
 llvm::VersionTuple Platform::GetOSVersion(Process *process) {



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


[Lldb-commits] [PATCH] D73808: [lldb/ClangASTContext] Supply trivial TypeSourceInfo to NonTypeTemplateParmDecl::Create

2020-01-31 Thread Vedant Kumar via Phabricator via lldb-commits
vsk created this revision.
vsk added reviewers: teemperor, shafik.
Herald added a subscriber: kristof.beyls.

This fixes a UBSan error seen while debugging clang:

Member call on null pointer of type 'clang::TypeSourceInfo'

rdar://58783517


https://reviews.llvm.org/D73808

Files:
  
lldb/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp
  lldb/source/Symbol/TypeSystemClang.cpp


Index: lldb/source/Symbol/TypeSystemClang.cpp
===
--- lldb/source/Symbol/TypeSystemClang.cpp
+++ lldb/source/Symbol/TypeSystemClang.cpp
@@ -1275,11 +1275,12 @@
 if (name && name[0])
   identifier_info = &ast.Idents.get(name);
 if (IsValueParam(template_param_infos.args[i])) {
+  QualType template_param_type =
+  template_param_infos.args[i].getIntegralType();
   template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
   ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
-  identifier_info, template_param_infos.args[i].getIntegralType(),
-  parameter_pack, nullptr));
-
+  identifier_info, template_param_type, parameter_pack,
+  ast.getTrivialTypeSourceInfo(template_param_type)));
 } else {
   template_param_decls.push_back(TemplateTypeParmDecl::Create(
   ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
Index: 
lldb/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp
===
--- 
lldb/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp
+++ 
lldb/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp
@@ -34,6 +34,11 @@
   bool isIntBool() { return true; }
 };
 
+template struct array {
+  int Arr[Size];
+  array() {}
+};
+
 int main (int argc, char const *argv[])
 {
 C myC;
@@ -53,12 +58,15 @@
 D myLesserD;
 myD.member = 64;
 (void)D().isIntBool();
-(void)D().isIntBool();
-return myD.member != 64;   //% self.expect("expression -- myD", 
DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["64"])
+(void)D().isIntBool(); //% self.expect("expression -- myD", 
DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["64"])
 //% self.expect("expression -- 
myLesserD.isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"])
 //% self.expect("expression -- 
myD.isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["true"])
 
 // See comment above.
 //#% self.expect("expression -- D().isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"])
 //#% self.expect("expression -- D().isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["true"])
+
+array<3> myArray; //% self.expect("expression -- myArray", 
DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["Arr"])
+
+return 1;
 }


Index: lldb/source/Symbol/TypeSystemClang.cpp
===
--- lldb/source/Symbol/TypeSystemClang.cpp
+++ lldb/source/Symbol/TypeSystemClang.cpp
@@ -1275,11 +1275,12 @@
 if (name && name[0])
   identifier_info = &ast.Idents.get(name);
 if (IsValueParam(template_param_infos.args[i])) {
+  QualType template_param_type =
+  template_param_infos.args[i].getIntegralType();
   template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
   ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
-  identifier_info, template_param_infos.args[i].getIntegralType(),
-  parameter_pack, nullptr));
-
+  identifier_info, template_param_type, parameter_pack,
+  ast.getTrivialTypeSourceInfo(template_param_type)));
 } else {
   template_param_decls.push_back(TemplateTypeParmDecl::Create(
   ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp
===
--- lldb/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp
@@ -34,6 +34,11 @@
   bool isIntBool() { return true; }
 };
 
+template struct array {
+  int Arr[Size];
+  array() {}
+};
+
 int main (int argc, char const *argv[])
 {
 C myC;
@@ -53,12 +58,15 @@
 D myLesserD;
 myD.member = 64;
 (void)D().isIntBool();
-(void)D().isIntBool();
-return myD.member != 64;	//% self.expect("expression -- myD", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["64"])
+(void)D().isIntBool(); //% self.expect("expression -- myD", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["64"])
 //% self.expect("expression -- myLesserD.isIntBool()", DATA_TYPES_DISPLAY

[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-01-31 Thread Paolo Severini via Phabricator via lldb-commits
paolosev updated this revision to Diff 241824.
paolosev marked 2 inline comments as done.
paolosev added a comment.

Fixed the tests as suggested, and also added a couple more tests, to cover both 
the case where the Wasm module is loaded from memory and the case where it is 
loaded from a file.

> However, when I though about that idea further, I realized that any default 
> plugin we could implement this way could not be complete, as we would be 
> missing the part which (un)loads modules when a new shared library 
> (dis)appears. This is something that cannot be done in a generic way, as that 
> usually requires setting breakpoint on some special symbol, or getting 
> notifications about shared library events in some other way. I don't know 
> whether this is something that you will also need/plan to implement for wasm, 
> or if one can assume that all modules are loaded from the get-go, but this is 
> what convinced me that putting this in a separate plugin is fine.

Yes, we'll need to support the case where a Wasm module is loaded at runtime, I 
think ProcessGDBRemote already does most of the work when it receives a stop 
event that contains the "library" flag and calls LoadModules() again. But I 
need to test this carefully.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_sym.yaml
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_wasm_embedded_debug_sections.yaml
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_wasm_external_debug_sections.yaml
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/DynamicLoader/CMakeLists.txt
  lldb/source/Plugins/DynamicLoader/wasm-DYLD/CMakeLists.txt
  lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp
  lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
  lldb/tools/lldb-test/SystemInitializerTest.cpp

Index: lldb/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -37,6 +37,7 @@
 #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
 #include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
 #include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
+#include "Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h"
 #include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
 #include "Plugins/Instruction/PPC64/EmulateInstructionPPC64.h"
 #include "Plugins/InstrumentationRuntime/ASan/ASanRuntime.h"
@@ -246,6 +247,7 @@
   DynamicLoaderMacOSXDYLD::Initialize();
   DynamicLoaderMacOS::Initialize();
   DynamicLoaderPOSIXDYLD::Initialize();
+  wasm::DynamicLoaderWasmDYLD::Initialize(); // before DynamicLoaderStatic.
   DynamicLoaderStatic::Initialize();
   DynamicLoaderWindowsDYLD::Initialize();
 
@@ -329,6 +331,7 @@
   DynamicLoaderMacOSXDYLD::Terminate();
   DynamicLoaderMacOS::Terminate();
   DynamicLoaderPOSIXDYLD::Terminate();
+  wasm::DynamicLoaderWasmDYLD::Terminate();
   DynamicLoaderStatic::Terminate();
   DynamicLoaderWindowsDYLD::Terminate();
 
Index: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
===
--- lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
+++ lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
@@ -1,153 +1,151 @@
-//===-- ObjectFileWasm.h *- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#ifndef LLDB_PLUGINS_OBJECTFILE_WASM_OBJECTFILEWASM_H
-#define LLDB_PLUGINS_OBJECTFILE_WASM_OBJECTFILEWASM_H
-
-#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Utility/ArchSpec.h"
-
-namespace lldb_private {
-namespace wasm {
-
-/// Generic Wasm object file reader.
-///
-/// This class provides a generic wasm32 reader plugin implementing the
-/// ObjectFile protocol.
-class ObjectFileWasm : public ObjectFile {
-public:
-  static void Initialize();
-  static void Terminate();
-
-  static ConstString GetPluginNameStatic();
-  static const char *GetPluginDescriptionStatic() {
-return "WebAssembly object file reader.";
-  }
-
-  static ObjectFile *
-  CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
- lldb::offset_t data_offset, const FileSpec *file,
- lldb::o

[Lldb-commits] [PATCH] D73589: Improve help text for (lldb) target symbols add

2020-01-31 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added a comment.

In D73589#1845971 , @jasonmolenda 
wrote:

> Looks good, for the --shlib option I would get rid of the "full path or base 
> name" language and just say "name", my two cents.


I agree just "name" seems fine.  Done.


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

https://reviews.llvm.org/D73589



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


[Lldb-commits] [lldb] 8e36d24 - [lldb] Remove unused CPPLanguageRuntime dependency

2020-01-31 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2020-01-31T15:23:18-08:00
New Revision: 8e36d24fca9f4586bcde588a10c8892ff62e1ff5

URL: 
https://github.com/llvm/llvm-project/commit/8e36d24fca9f4586bcde588a10c8892ff62e1ff5
DIFF: 
https://github.com/llvm/llvm-project/commit/8e36d24fca9f4586bcde588a10c8892ff62e1ff5.diff

LOG: [lldb] Remove unused CPPLanguageRuntime dependency

Added: 


Modified: 
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp

Removed: 




diff  --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt
index 0260212266fb..508a361aa6dd 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt
@@ -5,7 +5,6 @@ add_lldb_library(lldbPluginCPPRuntime PLUGIN
 lldbCore
 lldbSymbol
 lldbTarget
-lldbPluginTypeSystemClang
 )
 
 add_subdirectory(ItaniumABI)

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index 64348840ccb8..55b3b6f30173 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -18,7 +18,6 @@
 #include "lldb/Symbol/Variable.h"
 #include "lldb/Symbol/VariableList.h"
 
-#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/UniqueCStringMap.h"
 #include "lldb/Symbol/CompileUnit.h"



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


Re: [Lldb-commits] [lldb] r355466 - Replace debug-only assert with a plain old assert.

2020-01-31 Thread Vedant Kumar via lldb-commits


> On Mar 5, 2019, at 5:07 PM, Adrian Prantl via lldb-commits 
>  wrote:
> 
> Author: adrian
> Date: Tue Mar  5 17:07:45 2019
> New Revision: 355466
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=355466&view=rev
> Log:
> Replace debug-only assert with a plain old assert.
> 
> Modified:
>lldb/trunk/source/Interpreter/CommandObject.cpp
> 
> Modified: lldb/trunk/source/Interpreter/CommandObject.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=355466&r1=355465&r2=355466&view=diff
> ==
> --- lldb/trunk/source/Interpreter/CommandObject.cpp (original)
> +++ lldb/trunk/source/Interpreter/CommandObject.cpp Tue Mar  5 17:07:45 2019
> @@ -136,17 +136,15 @@ bool CommandObject::ParseOptions(Args &a
> }
> 
> bool CommandObject::CheckRequirements(CommandReturnObject &result) {
> -#ifdef LLDB_CONFIGURATION_DEBUG
>   // Nothing should be stored in m_exe_ctx between running commands as
>   // m_exe_ctx has shared pointers to the target, process, thread and frame 
> and
>   // we don't want any CommandObject instances to keep any of these objects
>   // around longer than for a single command. Every command should call
> -  // CommandObject::Cleanup() after it has completed
> -  assert(m_exe_ctx.GetTargetPtr() == NULL);
> -  assert(m_exe_ctx.GetProcessPtr() == NULL);
> -  assert(m_exe_ctx.GetThreadPtr() == NULL);
> -  assert(m_exe_ctx.GetFramePtr() == NULL);
> -#endif
> +  // CommandObject::Cleanup() after it has completed.
> +  assert(!m_exe_ctx.GetTargetPtr());

Hi all,

I'm actually hitting this assert now when I try debugging clang with a 
sanitized lldb. Any advice appreciated!

Stop hook #1 added.
(lldb) s
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
  * frame #0: 0x0001044d2268 clang-10`clang::noteBottomOfStack() at 
Stack.cpp:42:8
frame #1: 0x00012295 clang-10`main(argc_=64, 
argv_=0x7ffeefbff160) at driver.cpp:342:3
frame #2: 0x7fff722ba3d5 libdyld.dylib`start + 1

Assertion failed: (!m_exe_ctx.GetTargetPtr()), function CheckRequirements, file 
/Users/vsk/src/llvm-project-master/lldb/source/Interpreter/CommandObject.cpp, 
line 153.
Stack dump:
0.  Program arguments: 
/Users/vsk/src/builds/llvm-project-master-SAN/bin/lldb -o b main -o r -o target 
stop-hook add -o bt -o v -o s -o s -- 
/Users/vsk/src/builds/llvm-project-master-D/bin/clang-10 -cc1 -triple 
x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage 
-Werror=deprecated-objc-isa-usage -emit-obj -disable-free -main-file-name 
sqlite3.c -mrelocation-model pic -pic-level 2 -mthread-model posix 
-mframe-pointer=all -fno-rounding-math -masm-verbose -munwind-tables 
-target-sdk-version=10.14 -target-cpu penryn -dwarf-column-info 
-debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb 
-target-linker-version 556 -resource-dir 
/Users/vsk/src/builds/llvm-project-master-RA/lib/clang/11.0.0 -isysroot 
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include 
-internal-isystem 
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include 
-internal-isystem 
/Users/vsk/src/builds/llvm-project-master-RA/lib/clang/11.0.0/include 
-internal-externc-isystem 
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -O2 
-fdebug-compilation-dir /Users/vsk/src/builds/llvm-project-master-RA 
-ferror-limit 19 -fmessage-length 178 -stack-protector 1 -fblocks 
-fencode-extended-block-signature -fregister-global-dtors-with-atexit 
-fgnuc-version=4.2.1 -fobjc-runtime=macosx-10.14.0 -fmax-type-align=16 
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp 
-o /dev/null -x c /Users/vsk/Downloads/sqlite-amalgamation-3300100/sqlite3.c
zsh: abort  ~/src/builds/llvm-project-master-SAN/bin/lldb -o "b main" -o 
"r" -o  -o "s" -

vedant


> +  assert(!m_exe_ctx.GetProcessPtr());
> +  assert(!m_exe_ctx.GetThreadPtr());
> +  assert(!m_exe_ctx.GetFramePtr());
> 
>   // Lock down the interpreter's execution context prior to running the 
> command
>   // so we guarantee the selected target, process, thread and frame can't go
> 
> 
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

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


Re: [Lldb-commits] [lldb] r355466 - Replace debug-only assert with a plain old assert.

2020-01-31 Thread Adrian Prantl via lldb-commits
This could be the known bug where a CommandObject is scheduled while the same 
CommandObject is already deeper on the command stack. I tried digging up the 
bugreport for that, but I couldn't find it.

-- adrian

> On Jan 31, 2020, at 3:59 PM, Vedant Kumar  wrote:
> 
> 
> 
>> On Mar 5, 2019, at 5:07 PM, Adrian Prantl via lldb-commits 
>>  wrote:
>> 
>> Author: adrian
>> Date: Tue Mar  5 17:07:45 2019
>> New Revision: 355466
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=355466&view=rev
>> Log:
>> Replace debug-only assert with a plain old assert.
>> 
>> Modified:
>>   lldb/trunk/source/Interpreter/CommandObject.cpp
>> 
>> Modified: lldb/trunk/source/Interpreter/CommandObject.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=355466&r1=355465&r2=355466&view=diff
>> ==
>> --- lldb/trunk/source/Interpreter/CommandObject.cpp (original)
>> +++ lldb/trunk/source/Interpreter/CommandObject.cpp Tue Mar  5 17:07:45 2019
>> @@ -136,17 +136,15 @@ bool CommandObject::ParseOptions(Args &a
>> }
>> 
>> bool CommandObject::CheckRequirements(CommandReturnObject &result) {
>> -#ifdef LLDB_CONFIGURATION_DEBUG
>>  // Nothing should be stored in m_exe_ctx between running commands as
>>  // m_exe_ctx has shared pointers to the target, process, thread and frame 
>> and
>>  // we don't want any CommandObject instances to keep any of these objects
>>  // around longer than for a single command. Every command should call
>> -  // CommandObject::Cleanup() after it has completed
>> -  assert(m_exe_ctx.GetTargetPtr() == NULL);
>> -  assert(m_exe_ctx.GetProcessPtr() == NULL);
>> -  assert(m_exe_ctx.GetThreadPtr() == NULL);
>> -  assert(m_exe_ctx.GetFramePtr() == NULL);
>> -#endif
>> +  // CommandObject::Cleanup() after it has completed.
>> +  assert(!m_exe_ctx.GetTargetPtr());
> 
> Hi all,
> 
> I'm actually hitting this assert now when I try debugging clang with a 
> sanitized lldb. Any advice appreciated!
> 
> Stop hook #1 added.
> (lldb) s
> * thread #1, queue = 'com.apple.main-thread', stop reason = step in
>  * frame #0: 0x0001044d2268 clang-10`clang::noteBottomOfStack() at 
> Stack.cpp:42:8
>frame #1: 0x00012295 clang-10`main(argc_=64, 
> argv_=0x7ffeefbff160) at driver.cpp:342:3
>frame #2: 0x7fff722ba3d5 libdyld.dylib`start + 1
> 
> Assertion failed: (!m_exe_ctx.GetTargetPtr()), function CheckRequirements, 
> file 
> /Users/vsk/src/llvm-project-master/lldb/source/Interpreter/CommandObject.cpp, 
> line 153.
> Stack dump:
> 0.  Program arguments: 
> /Users/vsk/src/builds/llvm-project-master-SAN/bin/lldb -o b main -o r -o 
> target stop-hook add -o bt -o v -o s -o s -- 
> /Users/vsk/src/builds/llvm-project-master-D/bin/clang-10 -cc1 -triple 
> x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage 
> -Werror=deprecated-objc-isa-usage -emit-obj -disable-free -main-file-name 
> sqlite3.c -mrelocation-model pic -pic-level 2 -mthread-model posix 
> -mframe-pointer=all -fno-rounding-math -masm-verbose -munwind-tables 
> -target-sdk-version=10.14 -target-cpu penryn -dwarf-column-info 
> -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb 
> -target-linker-version 556 -resource-dir 
> /Users/vsk/src/builds/llvm-project-master-RA/lib/clang/11.0.0 -isysroot 
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include 
> -internal-isystem 
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include 
> -internal-isystem 
> /Users/vsk/src/builds/llvm-project-master-RA/lib/clang/11.0.0/include 
> -internal-externc-isystem 
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -O2 
> -fdebug-compilation-dir /Users/vsk/src/builds/llvm-project-master-RA 
> -ferror-limit 19 -fmessage-length 178 -stack-protector 1 -fblocks 
> -fencode-extended-block-signature -fregister-global-dtors-with-atexit 
> -fgnuc-version=4.2.1 -fobjc-runtime=macosx-10.14.0 -fmax-type-align=16 
> -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp 
> -o /dev/null -x c /Users/vsk/Downloads/sqlite-amalgamation-3300100/sqlite3.c
> zsh: abort  ~/src/builds/llvm-project-master-SAN/bin/lldb -o "b main" -o 
> "r" -o  -o "s" -
> 
> vedant
> 
> 
>> +  assert(!m_exe_ctx.GetProcessPtr());
>> +  assert(!m_exe_ctx.GetThreadPtr());
>> +  assert(!m_exe_ctx.GetFramePtr());
>> 
>>  // Lock down the interpreter's execution context prior to running the 
>> command
>>  // so we guarantee the selected target, process, thread and frame can't go
>> 
>> 
>> ___
>> lldb-commits mailing list
>> lldb-commits@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

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


Re: [Lldb-commits] [lldb] r355466 - Replace debug-only assert with a plain old assert.

2020-01-31 Thread Vedant Kumar via lldb-commits
Interesting. I'll keep poking at this.

> On Jan 31, 2020, at 4:04 PM, Adrian Prantl via lldb-commits 
>  wrote:
> 
> This could be the known bug where a CommandObject is scheduled while the same 
> CommandObject is already deeper on the command stack. I tried digging up the 
> bugreport for that, but I couldn't find it.
> 
> -- adrian
> 
>> On Jan 31, 2020, at 3:59 PM, Vedant Kumar > > wrote:
>> 
>> 
>> 
>>> On Mar 5, 2019, at 5:07 PM, Adrian Prantl via lldb-commits 
>>> mailto:lldb-commits@lists.llvm.org>> wrote:
>>> 
>>> Author: adrian
>>> Date: Tue Mar  5 17:07:45 2019
>>> New Revision: 355466
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=355466&view=rev 
>>> 
>>> Log:
>>> Replace debug-only assert with a plain old assert.
>>> 
>>> Modified:
>>>   lldb/trunk/source/Interpreter/CommandObject.cpp
>>> 
>>> Modified: lldb/trunk/source/Interpreter/CommandObject.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=355466&r1=355465&r2=355466&view=diff
>>>  
>>> 
>>> ==
>>> --- lldb/trunk/source/Interpreter/CommandObject.cpp (original)
>>> +++ lldb/trunk/source/Interpreter/CommandObject.cpp Tue Mar  5 17:07:45 2019
>>> @@ -136,17 +136,15 @@ bool CommandObject::ParseOptions(Args &a
>>> }
>>> 
>>> bool CommandObject::CheckRequirements(CommandReturnObject &result) {
>>> -#ifdef LLDB_CONFIGURATION_DEBUG
>>>  // Nothing should be stored in m_exe_ctx between running commands as
>>>  // m_exe_ctx has shared pointers to the target, process, thread and frame 
>>> and
>>>  // we don't want any CommandObject instances to keep any of these objects
>>>  // around longer than for a single command. Every command should call
>>> -  // CommandObject::Cleanup() after it has completed
>>> -  assert(m_exe_ctx.GetTargetPtr() == NULL);
>>> -  assert(m_exe_ctx.GetProcessPtr() == NULL);
>>> -  assert(m_exe_ctx.GetThreadPtr() == NULL);
>>> -  assert(m_exe_ctx.GetFramePtr() == NULL);
>>> -#endif
>>> +  // CommandObject::Cleanup() after it has completed.
>>> +  assert(!m_exe_ctx.GetTargetPtr());
>> 
>> Hi all,
>> 
>> I'm actually hitting this assert now when I try debugging clang with a 
>> sanitized lldb. Any advice appreciated!
>> 
>> Stop hook #1 added.
>> (lldb) s
>> * thread #1, queue = 'com.apple.main-thread', stop reason = step in
>>  * frame #0: 0x0001044d2268 clang-10`clang::noteBottomOfStack() at 
>> Stack.cpp:42:8
>>frame #1: 0x00012295 clang-10`main(argc_=64, 
>> argv_=0x7ffeefbff160) at driver.cpp:342:3
>>frame #2: 0x7fff722ba3d5 libdyld.dylib`start + 1
>> 
>> Assertion failed: (!m_exe_ctx.GetTargetPtr()), function CheckRequirements, 
>> file 
>> /Users/vsk/src/llvm-project-master/lldb/source/Interpreter/CommandObject.cpp,
>>  line 153.
>> Stack dump:
>> 0.  Program arguments: 
>> /Users/vsk/src/builds/llvm-project-master-SAN/bin/lldb -o b main -o r -o 
>> target stop-hook add -o bt -o v -o s -o s -- 
>> /Users/vsk/src/builds/llvm-project-master-D/bin/clang-10 -cc1 -triple 
>> x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage 
>> -Werror=deprecated-objc-isa-usage -emit-obj -disable-free -main-file-name 
>> sqlite3.c -mrelocation-model pic -pic-level 2 -mthread-model posix 
>> -mframe-pointer=all -fno-rounding-math -masm-verbose -munwind-tables 
>> -target-sdk-version=10.14 -target-cpu penryn -dwarf-column-info 
>> -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb 
>> -target-linker-version 556 -resource-dir 
>> /Users/vsk/src/builds/llvm-project-master-RA/lib/clang/11.0.0 -isysroot 
>> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include 
>> -internal-isystem 
>> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include 
>> -internal-isystem 
>> /Users/vsk/src/builds/llvm-project-master-RA/lib/clang/11.0.0/include 
>> -internal-externc-isystem 
>> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -O2 
>> -fdebug-compilation-dir /Users/vsk/src/builds/llvm-project-master-RA 
>> -ferror-limit 19 -fmessage-length 178 -stack-protector 1 -fblocks 
>> -fencode-extended-block-signature -fregister-global-dtors-with-atexit 
>> -fgnuc-version=4.2.1 -fobjc-runtime=macosx-10.14.0 -fmax-type-align=16 
>> -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops 
>> -vectorize-slp -o /dev/null -x c 
>> /Users/vsk/Downloads/sqlite-amalgamation-3300100/sqlite3.c
>> zsh: abort  ~/src/builds/llvm-project-master-SAN/bin/lldb -o "b main" -o 
>> "r" -o  -o "s" -
>> 
>> vedant
>> 
>> 
>>> +  assert(!m_exe_ctx.GetProcessPtr());
>>> +  assert(!m_exe_ctx.GetThreadPtr());
>>> +  assert(!m_exe_ctx.GetFramePtr());
>>> 
>>>  // Lock down the interpreter's execution context prior to running the 
>>> com

[Lldb-commits] [lldb] 009e3e5 - [lldb/MCDisasm] Simplify predicates in MCDisasmInstance, NFC

2020-01-31 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-01-31T16:33:12-08:00
New Revision: 009e3e53c1fe4848916a3b7de1dff60a2644fa46

URL: 
https://github.com/llvm/llvm-project/commit/009e3e53c1fe4848916a3b7de1dff60a2644fa46
DIFF: 
https://github.com/llvm/llvm-project/commit/009e3e53c1fe4848916a3b7de1dff60a2644fa46.diff

LOG: [lldb/MCDisasm] Simplify predicates in MCDisasmInstance, NFC

Added: 


Modified: 
lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp 
b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
index e9399c368e73..ea4b4cde7036 100644
--- a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -86,76 +86,18 @@ class InstructionLLVMC : public lldb_private::Instruction {
   : Instruction(address, addr_class),
 m_disasm_wp(std::static_pointer_cast(
 disasm.shared_from_this())),
-m_does_branch(eLazyBoolCalculate), 
m_has_delay_slot(eLazyBoolCalculate),
-m_is_call(eLazyBoolCalculate), m_is_valid(false),
 m_using_file_addr(false) {}
 
   ~InstructionLLVMC() override = default;
 
   bool DoesBranch() override {
-if (m_does_branch == eLazyBoolCalculate) {
-  DisassemblerScope disasm(*this);
-  if (disasm) {
-DataExtractor data;
-if (m_opcode.GetData(data)) {
-  bool is_alternate_isa;
-  lldb::addr_t pc = m_address.GetFileAddress();
-
-  DisassemblerLLVMC::MCDisasmInstance *mc_disasm_ptr =
-  GetDisasmToUse(is_alternate_isa, disasm);
-  const uint8_t *opcode_data = data.GetDataStart();
-  const size_t opcode_data_len = data.GetByteSize();
-  llvm::MCInst inst;
-  const size_t inst_size =
-  mc_disasm_ptr->GetMCInst(opcode_data, opcode_data_len, pc, inst);
-  // Be conservative, if we didn't understand the instruction, say it
-  // might branch...
-  if (inst_size == 0)
-m_does_branch = eLazyBoolYes;
-  else {
-const bool can_branch = mc_disasm_ptr->CanBranch(inst);
-if (can_branch)
-  m_does_branch = eLazyBoolYes;
-else
-  m_does_branch = eLazyBoolNo;
-  }
-}
-  }
-}
-return m_does_branch == eLazyBoolYes;
+VisitInstruction();
+return m_does_branch;
   }
 
   bool HasDelaySlot() override {
-if (m_has_delay_slot == eLazyBoolCalculate) {
-  DisassemblerScope disasm(*this);
-  if (disasm) {
-DataExtractor data;
-if (m_opcode.GetData(data)) {
-  bool is_alternate_isa;
-  lldb::addr_t pc = m_address.GetFileAddress();
-
-  DisassemblerLLVMC::MCDisasmInstance *mc_disasm_ptr =
-  GetDisasmToUse(is_alternate_isa, disasm);
-  const uint8_t *opcode_data = data.GetDataStart();
-  const size_t opcode_data_len = data.GetByteSize();
-  llvm::MCInst inst;
-  const size_t inst_size =
-  mc_disasm_ptr->GetMCInst(opcode_data, opcode_data_len, pc, inst);
-  // if we didn't understand the instruction, say it doesn't have a
-  // delay slot...
-  if (inst_size == 0)
-m_has_delay_slot = eLazyBoolNo;
-  else {
-const bool has_delay_slot = mc_disasm_ptr->HasDelaySlot(inst);
-if (has_delay_slot)
-  m_has_delay_slot = eLazyBoolYes;
-else
-  m_has_delay_slot = eLazyBoolNo;
-  }
-}
-  }
-}
-return m_has_delay_slot == eLazyBoolYes;
+VisitInstruction();
+return m_has_delay_slot;
   }
 
   DisassemblerLLVMC::MCDisasmInstance *GetDisasmToUse(bool &is_alternate_isa) {
@@ -369,14 +311,6 @@ class InstructionLLVMC : public lldb_private::Instruction {
   }
   m_mnemonics = std::string(mnemonic_strm.GetString());
   return;
-} else {
-  if (m_does_branch == eLazyBoolCalculate) {
-const bool can_branch = mc_disasm_ptr->CanBranch(inst);
-if (can_branch)
-  m_does_branch = eLazyBoolYes;
-else
-  m_does_branch = eLazyBoolNo;
-  }
 }
 
 static RegularExpression s_regex(
@@ -866,42 +800,54 @@ class InstructionLLVMC : public lldb_private::Instruction 
{
   }
 
   bool IsCall() override {
-if (m_is_call == eLazyBoolCalculate) {
-  DisassemblerScope disasm(*this);
-  if (disasm) {
-DataExtractor data;
-if (m_opcode.GetData(data)) {
-  bool is_alternate_isa;
-  lldb::addr_t pc = m_address.GetFileAddress();
-
-  DisassemblerLLVMC::MCDisasmInstance *mc_disasm_ptr =
-  GetDisasmToUse(is_alternate_isa, disasm);
-  const uint8_t *opcode_data = data.GetDataStart();
-  con

[Lldb-commits] [lldb] 14135f5 - [lldb/Value] Avoid reading more data than the host has available

2020-01-31 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-01-31T16:33:12-08:00
New Revision: 14135f50a036af4d3a64b8e2e0dc2ecda5260533

URL: 
https://github.com/llvm/llvm-project/commit/14135f50a036af4d3a64b8e2e0dc2ecda5260533
DIFF: 
https://github.com/llvm/llvm-project/commit/14135f50a036af4d3a64b8e2e0dc2ecda5260533.diff

LOG: [lldb/Value] Avoid reading more data than the host has available

Value::GetValueByteSize() reports the size of a Value as the size of its
underlying CompilerType. However, a host buffer that backs a Value may
be smaller than GetValueByteSize().

This situation arises when the host is only able to partially evaluate a
Value, e.g. because the expression contains DW_OP_piece.

The cleanest fix I've found to this problem is Greg's suggestion, which
is to resize the Value if (after evaluating an expression) it's found to
be too small. I've tried several alternatives which all (in one way or
the other) tried to teach the Value/ValueObjectChild system not to read
past the end of a host buffer, but this was flaky and impractical as it
isn't easy to figure out the host buffer's size (Value::GetScalar() can
point to somewhere /inside/ a host buffer, but you need to walk up the
ValueObject hierarchy to try and find its size).

This fixes an ASan error in lldb seen when debugging a clang binary.
I've added a regression test in test/functionalities/optimized_code. The
point of that test is not specifically to check that DW_OP_piece is
handled a particular way, but rather to check that lldb doesn't crash on
an input that it used to crash on.

Testing: check-lldb, and running the added tests using a sanitized lldb

--

Thanks to Jim for pointing out that an earlier version of this patch,
which simply changed the definition of Value::GetValueByteSize(), would
interact poorly with the ValueObject machinery.

Thanks also to Pavel who suggested a neat way to test this change
(which, incidentally, caught another ASan issue still present in the
original version of this patch).

rdar://58665925

Differential Revision: https://reviews.llvm.org/D73148

Added: 
lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/Makefile

lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/TestNoASanExceptionAfterEvalOP_piece.py
lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/main.cpp
lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-smaller-than-struct.s

Modified: 
lldb/source/Core/ValueObjectVariable.cpp

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/Makefile 
b/lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/Makefile
new file mode 100644
index ..129330fd9faf
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+CXXFLAGS_EXTRAS := -O2
+include Makefile.rules

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/TestNoASanExceptionAfterEvalOP_piece.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/TestNoASanExceptionAfterEvalOP_piece.py
new file mode 100644
index ..c8308c16011e
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/TestNoASanExceptionAfterEvalOP_piece.py
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals())

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/main.cpp 
b/lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/main.cpp
new file mode 100644
index ..f1beaf3020d5
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/main.cpp
@@ -0,0 +1,31 @@
+// This is a regression test that checks whether lldb can inspect the variables
+// in this program without triggering an ASan exception.
+
+__attribute__((noinline, optnone)) int use(int x) { return x; }
+
+volatile int sink;
+
+struct S1 {
+  int f1;
+  int *f2;
+};
+
+struct S2 {
+  char a, b;
+  int pad;
+  S2(int x) {
+a = x & 0xff;
+b = x & 0xff00;
+  }
+};
+
+int main() {
+  S1 v1;
+  v1.f1 = sink;
+  v1.f2 = nullptr;
+  sink++; //% self.expect("frame variable v1", substrs=["S1"])
+  S2 v2(v1.f1);
+  sink += use(v2.a); //% self.expect("frame variable v2", substrs=["S2"])
+  sink += use(v2.pad); //% self.expect("frame variable v2", substrs=["S2"])
+  return 0;
+}

diff  --git a/lldb/source/Core/ValueObjectVariable.cpp 
b/lldb/source/Core/ValueObjectVariable.cpp
index 945e5c411ec1..d0664276dc17 100644
--- a/lldb/source/Core/ValueObjectVariable.cpp
+++ b/lldb/source/Core/ValueObjectVariable.cpp
@@ -166,6 +166,27 @@ bool ValueObjectVariable::UpdateValue() {
 
   Value::ValueType value_type = m_value.GetValueType();
 
+  // The size of the buffer within m_value can be less than the s

[Lldb-commits] [PATCH] D73148: [lldb/Value] Avoid reading more data than the host has available

2020-01-31 Thread Vedant Kumar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG14135f50a036: [lldb/Value] Avoid reading more data than the 
host has available (authored by vsk).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D73148?vs=241814&id=241846#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73148

Files:
  lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/TestNoASanExceptionAfterEvalOP_piece.py
  lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/main.cpp
  lldb/source/Core/ValueObjectVariable.cpp
  lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-smaller-than-struct.s

Index: lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-smaller-than-struct.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-smaller-than-struct.s
@@ -0,0 +1,110 @@
+# RUN: llvm-mc -filetype=obj -o %t -triple x86_64-pc-linux %s
+# RUN: %lldb %t -o "target variable reset" -b | FileCheck %s
+
+# CHECK: (lldb) target variable reset
+# CHECK: (auto_reset) reset = {
+# CHECK:   ptr = 0xdeadbeefbaadf00d
+# Note: We need to find some way to represent "prev" as unknown/undefined.
+# CHECK:   prev = false
+# CHECK: }
+
+.section.debug_abbrev,"",@progbits
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   1   # DW_CHILDREN_yes
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   2   # Abbreviation Code
+.byte   52  # DW_TAG_variable
+.byte   0   # DW_CHILDREN_no
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   73  # DW_AT_type
+.byte   19  # DW_FORM_ref4
+.byte   2   # DW_AT_location
+.byte   24  # DW_FORM_exprloc
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   3   # Abbreviation Code
+.byte   36  # DW_TAG_base_type
+.byte   0   # DW_CHILDREN_no
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   62  # DW_AT_encoding
+.byte   11  # DW_FORM_data1
+.byte   11  # DW_AT_byte_size
+.byte   11  # DW_FORM_data1
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   4   # Abbreviation Code
+.byte   19  # DW_TAG_structure_type
+.byte   1   # DW_CHILDREN_yes
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   11  # DW_AT_byte_size
+.byte   11  # DW_FORM_data1
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   5   # Abbreviation Code
+.byte   13  # DW_TAG_member
+.byte   0   # DW_CHILDREN_no
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   73  # DW_AT_type
+.byte   19  # DW_FORM_ref4
+.byte   56  # DW_AT_data_member_location
+.byte   11  # DW_FORM_data1
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   6   # Abbreviation Code
+.byte   15  # DW_TAG_pointer_type
+.byte   0   # DW_CHILDREN_no
+.byte   73  # DW_AT_type
+.byte   19  # DW_FORM_ref4
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   0   # EOM(3)
+
+.section.debug_info,"",@progbits
+.Lcu_begin0:
+.long   .Lcu_end-.Lcu_start # Length of Unit
+.Lcu_start:
+.short  4   # DWARF version number
+.long   .debug_abbrev   # Offset Into Abbrev. Section
+.byte   8   # Address Size (in bytes)
+.byte   1   # Abbrev [1] 0xb:0x6c DW_TAG_compile_u

Re: [Lldb-commits] [lldb] r355466 - Replace debug-only assert with a plain old assert.

2020-01-31 Thread Jim Ingham via lldb-commits
That shouldn't be ASAN specific, that should happen on and 
LLDB_CONFIGURATION_DEBUG build.  If it only happens on ASAN builds, something 
else must be going wrong.

BTW, those asserts only make sense if you can't re-enter the command 
interpreter while a command is active.  In the case of a command that runs the 
target synchronously (like "step") with stop hooks or breakpoint commands, the 
"step" command won't have completed when you're running the commands in the 
stop hook or the breakpoint callback.  So that assumption is clearly not 
correct.

I don't think those asserts serve any useful purpose beyond reminding us that 
some day we really need to take the time to tease apart the part of 
CommandObject that forms the template for the command, and the part that 
represents this particular execution of that command.  

The CommandObject is a singleton, so it makes no sense for it to hold the data 
for any given execution.  We skate by on this for the most part because 
commands tend to do:

1) Store away the execution context for this command invocation
2) Parse Command Input into the option ivars in the CommandObject
3) Use those ivars to figure out what to do
4) Do It
5) Report a result that doesn't rely on the input data 

Since you don't generally get a chance to run another command till stage 4, it 
doesn't matter that that operation might overwrite the context or option ivars 
in the current CommandObject.  

This is clearly the wrong design, but unfortunately it has never caused any 
problems serious enough to motivate fixing it.

Jim

> On Jan 31, 2020, at 4:04 PM, Adrian Prantl  wrote:
> 
> This could be the known bug where a CommandObject is scheduled while the same 
> CommandObject is already deeper on the command stack. I tried digging up the 
> bugreport for that, but I couldn't find it.
> 
> -- adrian
> 
>> On Jan 31, 2020, at 3:59 PM, Vedant Kumar  wrote:
>> 
>> 
>> 
>>> On Mar 5, 2019, at 5:07 PM, Adrian Prantl via lldb-commits 
>>>  wrote:
>>> 
>>> Author: adrian
>>> Date: Tue Mar  5 17:07:45 2019
>>> New Revision: 355466
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=355466&view=rev
>>> Log:
>>> Replace debug-only assert with a plain old assert.
>>> 
>>> Modified:
>>>   lldb/trunk/source/Interpreter/CommandObject.cpp
>>> 
>>> Modified: lldb/trunk/source/Interpreter/CommandObject.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=355466&r1=355465&r2=355466&view=diff
>>> ==
>>> --- lldb/trunk/source/Interpreter/CommandObject.cpp (original)
>>> +++ lldb/trunk/source/Interpreter/CommandObject.cpp Tue Mar  5 17:07:45 2019
>>> @@ -136,17 +136,15 @@ bool CommandObject::ParseOptions(Args &a
>>> }
>>> 
>>> bool CommandObject::CheckRequirements(CommandReturnObject &result) {
>>> -#ifdef LLDB_CONFIGURATION_DEBUG
>>>  // Nothing should be stored in m_exe_ctx between running commands as
>>>  // m_exe_ctx has shared pointers to the target, process, thread and frame 
>>> and
>>>  // we don't want any CommandObject instances to keep any of these objects
>>>  // around longer than for a single command. Every command should call
>>> -  // CommandObject::Cleanup() after it has completed
>>> -  assert(m_exe_ctx.GetTargetPtr() == NULL);
>>> -  assert(m_exe_ctx.GetProcessPtr() == NULL);
>>> -  assert(m_exe_ctx.GetThreadPtr() == NULL);
>>> -  assert(m_exe_ctx.GetFramePtr() == NULL);
>>> -#endif
>>> +  // CommandObject::Cleanup() after it has completed.
>>> +  assert(!m_exe_ctx.GetTargetPtr());
>> 
>> Hi all,
>> 
>> I'm actually hitting this assert now when I try debugging clang with a 
>> sanitized lldb. Any advice appreciated!
>> 
>> Stop hook #1 added.
>> (lldb) s
>> * thread #1, queue = 'com.apple.main-thread', stop reason = step in
>>  * frame #0: 0x0001044d2268 clang-10`clang::noteBottomOfStack() at 
>> Stack.cpp:42:8
>>frame #1: 0x00012295 clang-10`main(argc_=64, 
>> argv_=0x7ffeefbff160) at driver.cpp:342:3
>>frame #2: 0x7fff722ba3d5 libdyld.dylib`start + 1
>> 
>> Assertion failed: (!m_exe_ctx.GetTargetPtr()), function CheckRequirements, 
>> file 
>> /Users/vsk/src/llvm-project-master/lldb/source/Interpreter/CommandObject.cpp,
>>  line 153.
>> Stack dump:
>> 0.  Program arguments: 
>> /Users/vsk/src/builds/llvm-project-master-SAN/bin/lldb -o b main -o r -o 
>> target stop-hook add -o bt -o v -o s -o s -- 
>> /Users/vsk/src/builds/llvm-project-master-D/bin/clang-10 -cc1 -triple 
>> x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage 
>> -Werror=deprecated-objc-isa-usage -emit-obj -disable-free -main-file-name 
>> sqlite3.c -mrelocation-model pic -pic-level 2 -mthread-model posix 
>> -mframe-pointer=all -fno-rounding-math -masm-verbose -munwind-tables 
>> -target-sdk-version=10.14 -target-cpu penryn -dwarf-column-info 
>> -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb 
>> -target-linker-version 556 -resource-dir

Re: [Lldb-commits] [lldb] r355466 - Replace debug-only assert with a plain old assert.

2020-01-31 Thread Adrian Prantl via lldb-commits
> On Jan 31, 2020, at 4:53 PM, Jim Ingham  wrote:
> 
> That shouldn't be ASAN specific, that should happen on and 
> LLDB_CONFIGURATION_DEBUG build.  If it only happens on ASAN builds, something 
> else must be going wrong.
> 
> BTW, those asserts only make sense if you can't re-enter the command 
> interpreter while a command is active.  In the case of a command that runs 
> the target synchronously (like "step") with stop hooks or breakpoint 
> commands, the "step" command won't have completed when you're running the 
> commands in the stop hook or the breakpoint callback.  So that assumption is 
> clearly not correct.
> 
> I don't think those asserts serve any useful purpose beyond reminding us that 
> some day we really need to take the time to tease apart the part of 
> CommandObject that forms the template for the command, and the part that 
> represents this particular execution of that command.  
> 
> The CommandObject is a singleton, so it makes no sense for it to hold the 
> data for any given execution.  We skate by on this for the most part because 
> commands tend to do:
> 
> 1) Store away the execution context for this command invocation
> 2) Parse Command Input into the option ivars in the CommandObject
> 3) Use those ivars to figure out what to do
> 4) Do It
> 5) Report a result that doesn't rely on the input data 
> 
> Since you don't generally get a chance to run another command till stage 4, 
> it doesn't matter that that operation might overwrite the context or option 
> ivars in the current CommandObject.  
> 
> This is clearly the wrong design, but unfortunately it has never caused any 
> problems serious enough to motivate fixing it.
> 
> Jim
> 
>> On Jan 31, 2020, at 4:04 PM, Adrian Prantl  wrote:
>> 
>> This could be the known bug where a CommandObject is scheduled while the 
>> same CommandObject is already deeper on the command stack. I tried digging 
>> up the bugreport for that, but I couldn't find it.

The one I was thinking about was  which says the 
stop-hooks test is failing when building in debug mode.

-- adrian


>> 
>> -- adrian
>> 
>>> On Jan 31, 2020, at 3:59 PM, Vedant Kumar  wrote:
>>> 
>>> 
>>> 
 On Mar 5, 2019, at 5:07 PM, Adrian Prantl via lldb-commits 
  wrote:
 
 Author: adrian
 Date: Tue Mar  5 17:07:45 2019
 New Revision: 355466
 
 URL: http://llvm.org/viewvc/llvm-project?rev=355466&view=rev
 Log:
 Replace debug-only assert with a plain old assert.
 
 Modified:
  lldb/trunk/source/Interpreter/CommandObject.cpp
 
 Modified: lldb/trunk/source/Interpreter/CommandObject.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=355466&r1=355465&r2=355466&view=diff
 ==
 --- lldb/trunk/source/Interpreter/CommandObject.cpp (original)
 +++ lldb/trunk/source/Interpreter/CommandObject.cpp Tue Mar  5 17:07:45 
 2019
 @@ -136,17 +136,15 @@ bool CommandObject::ParseOptions(Args &a
 }
 
 bool CommandObject::CheckRequirements(CommandReturnObject &result) {
 -#ifdef LLDB_CONFIGURATION_DEBUG
 // Nothing should be stored in m_exe_ctx between running commands as
 // m_exe_ctx has shared pointers to the target, process, thread and frame 
 and
 // we don't want any CommandObject instances to keep any of these objects
 // around longer than for a single command. Every command should call
 -  // CommandObject::Cleanup() after it has completed
 -  assert(m_exe_ctx.GetTargetPtr() == NULL);
 -  assert(m_exe_ctx.GetProcessPtr() == NULL);
 -  assert(m_exe_ctx.GetThreadPtr() == NULL);
 -  assert(m_exe_ctx.GetFramePtr() == NULL);
 -#endif
 +  // CommandObject::Cleanup() after it has completed.
 +  assert(!m_exe_ctx.GetTargetPtr());
>>> 
>>> Hi all,
>>> 
>>> I'm actually hitting this assert now when I try debugging clang with a 
>>> sanitized lldb. Any advice appreciated!
>>> 
>>> Stop hook #1 added.
>>> (lldb) s
>>> * thread #1, queue = 'com.apple.main-thread', stop reason = step in
>>> * frame #0: 0x0001044d2268 clang-10`clang::noteBottomOfStack() at 
>>> Stack.cpp:42:8
>>>   frame #1: 0x00012295 clang-10`main(argc_=64, 
>>> argv_=0x7ffeefbff160) at driver.cpp:342:3
>>>   frame #2: 0x7fff722ba3d5 libdyld.dylib`start + 1
>>> 
>>> Assertion failed: (!m_exe_ctx.GetTargetPtr()), function CheckRequirements, 
>>> file 
>>> /Users/vsk/src/llvm-project-master/lldb/source/Interpreter/CommandObject.cpp,
>>>  line 153.
>>> Stack dump:
>>> 0.  Program arguments: 
>>> /Users/vsk/src/builds/llvm-project-master-SAN/bin/lldb -o b main -o r -o 
>>> target stop-hook add -o bt -o v -o s -o s -- 
>>> /Users/vsk/src/builds/llvm-project-master-D/bin/clang-10 -cc1 -triple 
>>> x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage 
>>> -Werror=deprecated-objc-isa-usage -emit-obj -disable-free -main-file-name 
>>> sqlit

[Lldb-commits] [lldb] c62ffb1 - [lldb/Reproducers] Include string length in string (de)serialization.

2020-01-31 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-31T17:40:49-08:00
New Revision: c62ffb1b192daa66a8602d1511e04fb31809ffbe

URL: 
https://github.com/llvm/llvm-project/commit/c62ffb1b192daa66a8602d1511e04fb31809ffbe
DIFF: 
https://github.com/llvm/llvm-project/commit/c62ffb1b192daa66a8602d1511e04fb31809ffbe.diff

LOG: [lldb/Reproducers] Include string length in string (de)serialization.

This allows us to differentiate between an empty string and a nullptr.

(cherry picked from commit 53e206284fa715886020d6a5553bf791582850a3)

Added: 


Modified: 
lldb/include/lldb/Utility/ReproducerInstrumentation.h
lldb/source/Utility/ReproducerInstrumentation.cpp
lldb/unittests/Utility/ReproducerInstrumentationTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h 
b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
index e91eb7f5922c..b0424e40d5bf 100644
--- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h
+++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
@@ -602,8 +602,12 @@ class Serializer {
   }
 
   void Serialize(const char *t) {
-m_stream << t;
-m_stream.write(0x0);
+const size_t size = t ? strlen(t) : std::numeric_limits::max();
+Serialize(size);
+if (t) {
+  m_stream << t;
+  m_stream.write(0x0);
+}
   }
 
   void Serialize(const char **t) {
@@ -620,11 +624,8 @@ class Serializer {
 Serialize(size);
 
 // Serialize the content of the array.
-while (*t) {
-  m_stream << *t;
-  m_stream.write(0x0);
-  ++t;
-}
+while (*t)
+  Serialize(*t++);
   }
 
   /// Serialization stream.

diff  --git a/lldb/source/Utility/ReproducerInstrumentation.cpp 
b/lldb/source/Utility/ReproducerInstrumentation.cpp
index 1835e7098c25..cfb77c0d8c3a 100644
--- a/lldb/source/Utility/ReproducerInstrumentation.cpp
+++ b/lldb/source/Utility/ReproducerInstrumentation.cpp
@@ -28,11 +28,12 @@ template <> char *Deserializer::Deserialize() {
 }
 
 template <> const char *Deserializer::Deserialize() {
-  auto pos = m_buffer.find('\0');
-  if (pos == llvm::StringRef::npos)
+  const size_t size = Deserialize();
+  if (size == std::numeric_limits::max())
 return nullptr;
+  assert(HasData(size + 1));
   const char *str = m_buffer.data();
-  m_buffer = m_buffer.drop_front(pos + 1);
+  m_buffer = m_buffer.drop_front(size + 1);
 #ifdef LLDB_REPRO_INSTR_TRACE
   llvm::errs() << "Deserializing with " << LLVM_PRETTY_FUNCTION << " -> \""
<< str << "\"\n";
@@ -41,7 +42,7 @@ template <> const char *Deserializer::Deserialize() {
 }
 
 template <> const char **Deserializer::Deserialize() {
-  size_t size = Deserialize();
+  const size_t size = Deserialize();
   if (size == 0)
 return nullptr;
   const char **r =

diff  --git a/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp 
b/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp
index e87c49f7bc00..490d188c83b7 100644
--- a/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp
+++ b/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp
@@ -393,6 +393,21 @@ TEST(SerializationRountripTest, 
SerializeDeserializeCString) {
   EXPECT_STREQ(cstr, deserializer.Deserialize());
 }
 
+TEST(SerializationRountripTest, SerializeDeserializeCStringNull) {
+  const char *cstr = nullptr;
+
+  std::string str;
+  llvm::raw_string_ostream os(str);
+
+  Serializer serializer(os);
+  serializer.SerializeAll(cstr);
+
+  llvm::StringRef buffer(os.str());
+  Deserializer deserializer(buffer);
+
+  EXPECT_EQ(nullptr, deserializer.Deserialize());
+}
+
 TEST(SerializationRountripTest, SerializeDeserializeCStringArray) {
   const char *foo = "foo";
   const char *bar = "bar";



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


[Lldb-commits] [lldb] 2637769 - [lldb] Remove LanguageRuntime::GetOverrideExprOptions

2020-01-31 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2020-01-31T22:05:23-08:00
New Revision: 2637769b9f38010082276b7b839a17b102d1ac93

URL: 
https://github.com/llvm/llvm-project/commit/2637769b9f38010082276b7b839a17b102d1ac93
DIFF: 
https://github.com/llvm/llvm-project/commit/2637769b9f38010082276b7b839a17b102d1ac93.diff

LOG: [lldb] Remove LanguageRuntime::GetOverrideExprOptions

LanguageRuntime::GetOverrideExprOptions is specific to clang and was
only overridden in RenderScriptRuntime. LanguageRuntime in shouldn't
have any knowledge of clang, so remove it from LanguageRuntime and leave
it only in RenderScriptRuntime.

Added: 


Modified: 
lldb/include/lldb/Target/LanguageRuntime.h
lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Removed: 




diff  --git a/lldb/include/lldb/Target/LanguageRuntime.h 
b/lldb/include/lldb/Target/LanguageRuntime.h
index 73c8dfa3874d..7af6cd2e91ff 100644
--- a/lldb/include/lldb/Target/LanguageRuntime.h
+++ b/lldb/include/lldb/Target/LanguageRuntime.h
@@ -21,8 +21,6 @@
 #include "lldb/lldb-private.h"
 #include "lldb/lldb-public.h"
 
-#include "clang/Basic/TargetOptions.h"
-
 namespace lldb_private {
 
 class ExceptionSearchFilter : public SearchFilter {
@@ -162,13 +160,6 @@ class LanguageRuntime : public PluginInterface {
 
   virtual void ModulesDidLoad(const ModuleList &module_list) {}
 
-  // Called by the Clang expression evaluation engine to allow runtimes to
-  // alter the set of target options provided to the compiler. If the options
-  // prototype is modified, runtimes must return true, false otherwise.
-  virtual bool GetOverrideExprOptions(clang::TargetOptions &prototype) {
-return false;
-  }
-
   // Called by ClangExpressionParser::PrepareForExecution to query for any
   // custom LLVM IR passes that need to be run before an expression is
   // assembled and run.

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt 
b/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
index 3bb120a48e90..909e92ace8d4 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
@@ -41,6 +41,7 @@ add_lldb_library(lldbPluginExpressionParserClang PLUGIN
 lldbPluginCPlusPlusLanguage
 lldbPluginCPPRuntime
 lldbPluginObjCRuntime
+lldbPluginRenderScriptRuntime
 lldbPluginTypeSystemClang
   CLANG_LIBS
 clangAST

diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 1516d5b0277b..3faf6f238b23 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -91,6 +91,7 @@
 #include "lldb/Utility/StringList.h"
 
 #include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+#include 
"Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h"
 
 #include 
 #include 
@@ -392,9 +393,13 @@ ClangExpressionParser::ClangExpressionParser(
   // target. In this case, a specialized language runtime is available and we
   // can query it for extra options. For 99% of use cases, this will not be
   // needed and should be provided when basic platform detection is not enough.
-  if (lang_rt)
+  // FIXME: Generalize this. Only RenderScriptRuntime currently supports this
+  // currently. Hardcoding this isn't ideal but it's better than 
LanguageRuntime
+  // having knowledge of clang::TargetOpts.
+  if (auto *renderscript_rt =
+  llvm::dyn_cast_or_null(lang_rt))
 overridden_target_opts =
-lang_rt->GetOverrideExprOptions(m_compiler->getTargetOpts());
+renderscript_rt->GetOverrideExprOptions(m_compiler->getTargetOpts());
 
   if (overridden_target_opts)
 if (log && log->GetVerbose()) {

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
 
b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
index c3740ba55a11..2fec7dcf4f6e 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ 
b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -24,6 +24,10 @@
 
 #include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
 
+namespace clang {
+class TargetOptions;
+};
+
 namespace lldb_private {
 namespace lldb_renderscript {
 
@@ -402,6 +406,8 @@ class RenderScriptRuntime : public 
lldb_private::CPPLanguageRuntime {
 return false;
   }
 
+  bool GetOverrideExprOptions(clang::TargetOptions &prototype);
+
   // PluginInterface protocol
   lldb_private::ConstString GetPluginName() override;
 
@@ -577,

[Lldb-commits] [PATCH] D73802: [lldb] Introduce i386 support in NetBSD Process plugin

2020-01-31 Thread Michał Górny via Phabricator via lldb-commits
mgorny marked an inline comment as done.
mgorny added inline comments.



Comment at: 
lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.cpp:62
+  GPR gpr;
+  FPR_i386 i387;
+  uint32_t u_debugreg[8]; // Debug registers (DR0 - DR7).

krytarowski wrote:
> Please add `uint32_t tlsbase;`.
To what purpose? It's not being used anywhere.


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

https://reviews.llvm.org/D73802



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


[Lldb-commits] [PATCH] D73827: [lldb] Delete ClangForward.h

2020-01-31 Thread Alex Langford via Phabricator via lldb-commits
xiaobai created this revision.
xiaobai added a reviewer: LLDB.
Herald added subscribers: usaxena95, arphaman.
Herald added a project: LLDB.

I think that there are very few things from clang that actually need forward
declaration, so not having a ClangForward header makes sense.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73827

Files:
  lldb/include/lldb/Core/ClangForward.h
  lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.h
  lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
  lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -27,7 +27,6 @@
 #include "llvm/ADT/SmallVector.h"
 
 #include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
-#include "lldb/Core/ClangForward.h"
 #include "lldb/Expression/ExpressionVariable.h"
 #include "lldb/Symbol/CompilerType.h"
 #include "lldb/Symbol/TypeSystem.h"
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -19,7 +19,6 @@
 #include "DWARFDefines.h"
 #include "DWARFFormValue.h"
 #include "LogChannelDWARF.h"
-#include "lldb/Core/ClangForward.h"
 #include "lldb/Core/PluginInterface.h"
 
 #include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
Index: lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
+++ lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
@@ -17,7 +17,6 @@
 #include "llvm/Support/Casting.h"
 
 #include "lldb/Breakpoint/BreakpointPrecondition.h"
-#include "lldb/Core/ClangForward.h"
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/Core/ThreadSafeDenseMap.h"
 #include "lldb/Symbol/CompilerType.h"
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -15,13 +15,11 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclObjC.h"
 
-#include "lldb/Core/ClangForward.h"
 #include "lldb/Host/OptionParser.h"
 #include "lldb/Symbol/CompilerType.h"
 #include "lldb/lldb-enumerations.h"
 
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
-#include "lldb/Core/ClangForward.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
Index: lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
+++ lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
@@ -10,7 +10,6 @@
 #ifndef liblldb_IRForTarget_h_
 #define liblldb_IRForTarget_h_
 
-#include "lldb/Core/ClangForward.h"
 #include "lldb/Symbol/TaggedASTType.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Status.h"
@@ -38,6 +37,10 @@
 class Value;
 }
 
+namespace clang {
+class NamedDecl;
+}
+
 namespace lldb_private {
 class ClangExpressionDeclMap;
 class IRExecutionUnit;
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
@@ -15,7 +15,6 @@
 
 #include "ClangExpressionHelper.h"
 
-#include "lldb/Core/ClangForward.h"
 #include "lldb/Expression/UtilityFunction.h"
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-private.h"
Index: lldb/source/Plugins/ExpressionParser/Cla