[Lldb-commits] [PATCH] D81516: [lldb/Test] Ensure inline tests have a unique build directory

2020-06-10 Thread Pavel Labath via Phabricator via lldb-commits
labath requested changes to this revision.
labath added a comment.
This revision now requires changes to proceed.

I noticed this issue after committing the patch that caused it. I wasn't 
rushing to fix it because it did not seem like a big problem. But, of course it 
is a big problem for reproducers...

That said, I think the proposed fix is more complicated than needed and would 
not handle `@no_debug_info_test` tests (because the fixup happens in the code 
which does the magic test replication).

It should be sufficient to add this to the definition of `InlineTest` class:

  def getBuildDirBasename(self):
  return self.__class__.__name__ + "." + self.testMethodName

That will result in paths like:

  
lldb-test-build.noindex/functionalities/param_entry_vals/basic_entry_values/BasicEntryValues_GNU.test_dwarf/a.out
  
lldb-test-build.noindex/functionalities/param_entry_vals/basic_entry_values/BasicEntryValues_V5.test_dwarf/a.out

Which is better than 
`lldb-test-build.noindex/functionalities/param_entry_vals/basic_entry_values/lldbsuite.test.lldbtest.test_dwarf/a.out`
 (status quo) and 
`lldb-test-build.noindex/functionalities/param_entry_vals/basic_entry_values/lldbsuite.test.lldbtest.test_BasicEntryValues_V5_dwarf/a.out`
 (what this patch would produce).

Btw, this problem isn't really specific to inline tests. The same problem could 
happen with regular tests if one defined two classes with identically named 
test methods in the same file. Which means we could try to fix this even more 
generally by making the default `getBuildDirBasename` implementation take the 
class name into account. However, multiple classes in a single file are fairly 
strange, and this solution would make the build dir paths even longer than they 
are now, so fixing it this way may not be worth it...




Comment at: lldb/packages/Python/lldbsuite/test/lldbinline.py:209
 test_class = type(name, (InlineTest,), dict(test=test_func,
-name=name, _build_dict=build_dict))
+name=name, __inline_name__=name, _build_dict=build_dict))
 

`__inline_name__` is not a good name according to 
:
```
__double_leading_and_trailing_underscore__: "magic" objects or attributes that 
live in user-controlled namespaces. E.g. __init__, __import__ or __file__. 
Never invent such names; only use them as documented.
```



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

https://reviews.llvm.org/D81516



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


[Lldb-commits] [lldb] 834708a - [lldb][NFC] Rename ClangExpressionDeclMap::AddThisType and clarify documentation

2020-06-10 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-06-10T12:26:47+02:00
New Revision: 834708a6a0d04935d79bfa54c7a1bf9ab7a2ba8f

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

LOG: [lldb][NFC] Rename ClangExpressionDeclMap::AddThisType and clarify 
documentation

Added: 


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

Removed: 




diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index 7d40cd0e8a0e..d71036f793b1 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -759,7 +759,7 @@ void 
ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context) {
 if (!ctx_obj_ptr || status.Fail())
   return;
 
-AddThisType(context, TypeFromUser(m_ctx_obj->GetCompilerType()));
+AddContextClassType(context, TypeFromUser(m_ctx_obj->GetCompilerType()));
 
 m_struct_vars->m_object_pointer_type =
 TypeFromUser(ctx_obj_ptr->GetCompilerType());
@@ -797,7 +797,7 @@ void 
ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context) {
 LLDB_LOG(log, "  CEDM::FEVD Adding type for $__lldb_class: {1}",
  class_qual_type.getAsString());
 
-AddThisType(context, class_user_type);
+AddContextClassType(context, class_user_type);
 
 if (method_decl->isInstance()) {
   // self is a pointer to the object
@@ -839,7 +839,7 @@ void 
ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context) {
 LLDB_LOG(log, "  FEVD Adding type for $__lldb_class: {1}",
  ClangUtil::GetQualType(pointee_type).getAsString());
 
-AddThisType(context, pointee_type);
+AddContextClassType(context, pointee_type);
 TypeFromUser this_user_type(this_type->GetFullCompilerType());
 m_struct_vars->m_object_pointer_type = this_user_type;
   }
@@ -1876,8 +1876,8 @@ void 
ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
   }
 }
 
-void ClangExpressionDeclMap::AddThisType(NameSearchContext &context,
- const TypeFromUser &ut) {
+void ClangExpressionDeclMap::AddContextClassType(NameSearchContext &context,
+ const TypeFromUser &ut) {
   CompilerType copied_clang_type = GuardedCopyType(ut);
 
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));

diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
index 2dc921608348..6974535a8993 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
@@ -588,15 +588,19 @@ class ClangExpressionDeclMap : public ClangASTSource {
   /// The type that needs to be created.
   void AddOneType(NameSearchContext &context, const TypeFromUser &type);
 
-  /// Generate a Decl for "*this" and add a member function declaration to it
-  /// for the expression, then report it.
+  /// Adds the class in which the expression is evaluated to the lookup and
+  /// prepares the class to be used as a context for expression evaluation (for
+  /// example, it creates a fake member function that will contain the
+  /// expression LLDB is trying to evaluate).
   ///
   /// \param[in] context
-  /// The NameSearchContext to use when constructing the Decl.
+  /// The NameSearchContext to which the class should be added as a lookup
+  /// result.
   ///
   /// \param[in] type
-  /// The type for *this.
-  void AddThisType(NameSearchContext &context, const TypeFromUser &type);
+  /// The type of the class that serves as the evaluation context.
+  void AddContextClassType(NameSearchContext &context,
+   const TypeFromUser &type);
 
   /// Move a type out of the current ASTContext into another, but make sure to
   /// export all components of the type also.



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


[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint

2020-06-10 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 269781.
kwk marked an inline comment as done.
kwk added a comment.

- Outsource parts into SearchFilterByModulesAndSupportFiles::FunctionPasses
- Tests with alternating setting target.inline-breakpoint-strategy between 
"always" and "headers"
- Respecting target.inline-breakpoint-strategy setting in 
SearchFilterByModulesAndSupportFiles and maded adjustments in 
BreakpointResolverName::SearchCallback
- Renamed SearchFilterByModuleListAndCUList to 
SearchFilterByModulesAndSupportFiles


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74136

Files:
  lldb/include/lldb/Core/SearchFilter.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Core/SearchFilter.cpp
  lldb/source/Target/Target.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files-func.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files.h
  lldb/test/Shell/Breakpoint/search-support-files.test

Index: lldb/test/Shell/Breakpoint/search-support-files.test
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/search-support-files.test
@@ -0,0 +1,123 @@
+# In these tests we will set breakpoints on a function by name with the
+# target.inline-breakpoint-strategy setting alternating between set "always" and
+# "headers".
+
+# RUN: %build %p/Inputs/search-support-files.cpp -o %t.out
+# RUN: %lldb -b -s %s %t.out | FileCheck --color --dump-input=always %s 
+
+
+#Set breakpoint by function name.
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n function_in_header
+# CHECK: (lldb) breakpoint set -n function_in_header
+# CHECK-NEXT: Breakpoint 1: where = {{.*}}.out`function_in_header(){{.*}} at search-support-files.h
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n function_in_header
+# CHECK: (lldb) breakpoint set -n function_in_header
+# CHECK-NEXT: Breakpoint 2: where = {{.*}}.out`function_in_header(){{.*}} at search-support-files.h
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n main
+# CHECK: (lldb) breakpoint set -n main
+# CHECK-NEXT: Breakpoint 3: where = {{.*}}.out`main{{.*}} at search-support-files.cpp
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n main
+# CHECK: (lldb) breakpoint set -n main
+# CHECK-NEXT: Breakpoint 4: where = {{.*}}.out`main{{.*}} at search-support-files.cpp
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n func
+# CHECK: (lldb) breakpoint set -n func
+# CHECK-NEXT: Breakpoint 5: where = {{.*}}.out`func{{.*}} at search-support-files-func.cpp
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n func
+# CHECK: (lldb) breakpoint set -n func
+# CHECK-NEXT: Breakpoint 6: where = {{.*}}.out`func{{.*}} at search-support-files-func.cpp
+
+
+
+#   Set breakpoint by function name and filename (here: the compilation unit).
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n function_in_header -f search-support-files.cpp
+# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.cpp
+# CHECK-NEXT: Breakpoint 7: no locations (pending).
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n function_in_header -f search-support-files.cpp
+# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.cpp
+# CHECK-NEXT: Breakpoint 8: no locations (pending).
+
+
+
+#   Set breakpoint by function name and source filename (the file in which the
+#   function is defined).
+#
+#   NOTE: This test is the really interesting one as it shows that we can
+# search by source files that are themselves no compilation units.
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n function_in_header -f search-support-files.h
+# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.h
+# CHECK-NEXT: Breakpoint 9: where = {{.*}}.out`function_in_header(){{.*}} at search-support-files.h
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n function_in_header -f search-support-files.h
+# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.h
+# CHECK-NEXT: Breakpoint 10: no locations (pending).
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n func -f search-support-files-func.cpp
+# CHECK: (lldb) breakpoint set -n func -f search-support-files-func.cpp
+# CHECK-NEXT: Breakpoint 11: where = {{.*}}.out`func(){{.*}} at search-support-files-func.cpp
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n func -f search-support-files-func.cpp
+# CHECK: (lldb) breakpoint set -n func -f search-support-files-func.cpp
+# CHECK-NEXT: Breakpoint 12: no locations (pending).
+
+
+
+# 

[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint

2020-06-10 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 269784.
kwk added a comment.

- Fix comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74136

Files:
  lldb/include/lldb/Core/SearchFilter.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Core/SearchFilter.cpp
  lldb/source/Target/Target.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files-func.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files.h
  lldb/test/Shell/Breakpoint/search-support-files.test

Index: lldb/test/Shell/Breakpoint/search-support-files.test
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/search-support-files.test
@@ -0,0 +1,123 @@
+# In these tests we will set breakpoints on a function by name with the
+# target.inline-breakpoint-strategy setting alternating between set "always" and
+# "headers".
+
+# RUN: %build %p/Inputs/search-support-files.cpp -o %t.out
+# RUN: %lldb -b -s %s %t.out | FileCheck --color --dump-input=always %s 
+
+
+#Set breakpoint by function name.
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n function_in_header
+# CHECK: (lldb) breakpoint set -n function_in_header
+# CHECK-NEXT: Breakpoint 1: where = {{.*}}.out`function_in_header(){{.*}} at search-support-files.h
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n function_in_header
+# CHECK: (lldb) breakpoint set -n function_in_header
+# CHECK-NEXT: Breakpoint 2: where = {{.*}}.out`function_in_header(){{.*}} at search-support-files.h
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n main
+# CHECK: (lldb) breakpoint set -n main
+# CHECK-NEXT: Breakpoint 3: where = {{.*}}.out`main{{.*}} at search-support-files.cpp
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n main
+# CHECK: (lldb) breakpoint set -n main
+# CHECK-NEXT: Breakpoint 4: where = {{.*}}.out`main{{.*}} at search-support-files.cpp
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n func
+# CHECK: (lldb) breakpoint set -n func
+# CHECK-NEXT: Breakpoint 5: where = {{.*}}.out`func{{.*}} at search-support-files-func.cpp
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n func
+# CHECK: (lldb) breakpoint set -n func
+# CHECK-NEXT: Breakpoint 6: where = {{.*}}.out`func{{.*}} at search-support-files-func.cpp
+
+
+
+#   Set breakpoint by function name and filename (here: the compilation unit).
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n function_in_header -f search-support-files.cpp
+# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.cpp
+# CHECK-NEXT: Breakpoint 7: no locations (pending).
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n function_in_header -f search-support-files.cpp
+# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.cpp
+# CHECK-NEXT: Breakpoint 8: no locations (pending).
+
+
+
+#   Set breakpoint by function name and source filename (the file in which the
+#   function is defined).
+#
+#   NOTE: This test is the really interesting one as it shows that we can
+# search by source files that are themselves no compilation units.
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n function_in_header -f search-support-files.h
+# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.h
+# CHECK-NEXT: Breakpoint 9: where = {{.*}}.out`function_in_header(){{.*}} at search-support-files.h
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n function_in_header -f search-support-files.h
+# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.h
+# CHECK-NEXT: Breakpoint 10: no locations (pending).
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n func -f search-support-files-func.cpp
+# CHECK: (lldb) breakpoint set -n func -f search-support-files-func.cpp
+# CHECK-NEXT: Breakpoint 11: where = {{.*}}.out`func(){{.*}} at search-support-files-func.cpp
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n func -f search-support-files-func.cpp
+# CHECK: (lldb) breakpoint set -n func -f search-support-files-func.cpp
+# CHECK-NEXT: Breakpoint 12: no locations (pending).
+
+
+
+#   Set breakpoint by function name and source filename. This time the file
+#   doesn't exist or is not the file in which the function is declared or
+#   defined. This is to prove that we haven't widen the search space too much.
+#   When we search for a function in a file that doesn't exist, we should get no
+#   results.
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n function_in_header -f file-not-existing.

[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint

2020-06-10 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 269782.
kwk added a comment.

- remove commented out code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74136

Files:
  lldb/include/lldb/Core/SearchFilter.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Core/SearchFilter.cpp
  lldb/source/Target/Target.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files-func.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files.h
  lldb/test/Shell/Breakpoint/search-support-files.test

Index: lldb/test/Shell/Breakpoint/search-support-files.test
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/search-support-files.test
@@ -0,0 +1,123 @@
+# In these tests we will set breakpoints on a function by name with the
+# target.inline-breakpoint-strategy setting alternating between set "always" and
+# "headers".
+
+# RUN: %build %p/Inputs/search-support-files.cpp -o %t.out
+# RUN: %lldb -b -s %s %t.out | FileCheck --color --dump-input=always %s 
+
+
+#Set breakpoint by function name.
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n function_in_header
+# CHECK: (lldb) breakpoint set -n function_in_header
+# CHECK-NEXT: Breakpoint 1: where = {{.*}}.out`function_in_header(){{.*}} at search-support-files.h
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n function_in_header
+# CHECK: (lldb) breakpoint set -n function_in_header
+# CHECK-NEXT: Breakpoint 2: where = {{.*}}.out`function_in_header(){{.*}} at search-support-files.h
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n main
+# CHECK: (lldb) breakpoint set -n main
+# CHECK-NEXT: Breakpoint 3: where = {{.*}}.out`main{{.*}} at search-support-files.cpp
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n main
+# CHECK: (lldb) breakpoint set -n main
+# CHECK-NEXT: Breakpoint 4: where = {{.*}}.out`main{{.*}} at search-support-files.cpp
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n func
+# CHECK: (lldb) breakpoint set -n func
+# CHECK-NEXT: Breakpoint 5: where = {{.*}}.out`func{{.*}} at search-support-files-func.cpp
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n func
+# CHECK: (lldb) breakpoint set -n func
+# CHECK-NEXT: Breakpoint 6: where = {{.*}}.out`func{{.*}} at search-support-files-func.cpp
+
+
+
+#   Set breakpoint by function name and filename (here: the compilation unit).
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n function_in_header -f search-support-files.cpp
+# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.cpp
+# CHECK-NEXT: Breakpoint 7: no locations (pending).
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n function_in_header -f search-support-files.cpp
+# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.cpp
+# CHECK-NEXT: Breakpoint 8: no locations (pending).
+
+
+
+#   Set breakpoint by function name and source filename (the file in which the
+#   function is defined).
+#
+#   NOTE: This test is the really interesting one as it shows that we can
+# search by source files that are themselves no compilation units.
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n function_in_header -f search-support-files.h
+# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.h
+# CHECK-NEXT: Breakpoint 9: where = {{.*}}.out`function_in_header(){{.*}} at search-support-files.h
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n function_in_header -f search-support-files.h
+# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.h
+# CHECK-NEXT: Breakpoint 10: no locations (pending).
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n func -f search-support-files-func.cpp
+# CHECK: (lldb) breakpoint set -n func -f search-support-files-func.cpp
+# CHECK-NEXT: Breakpoint 11: where = {{.*}}.out`func(){{.*}} at search-support-files-func.cpp
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n func -f search-support-files-func.cpp
+# CHECK: (lldb) breakpoint set -n func -f search-support-files-func.cpp
+# CHECK-NEXT: Breakpoint 12: no locations (pending).
+
+
+
+#   Set breakpoint by function name and source filename. This time the file
+#   doesn't exist or is not the file in which the function is declared or
+#   defined. This is to prove that we haven't widen the search space too much.
+#   When we search for a function in a file that doesn't exist, we should get no
+#   results.
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n function_in_header -f file

[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint

2020-06-10 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 269787.
kwk marked an inline comment as done.
kwk added a comment.

- remove debug output from test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74136

Files:
  lldb/include/lldb/Core/SearchFilter.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Core/SearchFilter.cpp
  lldb/source/Target/Target.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files-func.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files.h
  lldb/test/Shell/Breakpoint/search-support-files.test

Index: lldb/test/Shell/Breakpoint/search-support-files.test
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/search-support-files.test
@@ -0,0 +1,123 @@
+# In these tests we will set breakpoints on a function by name with the
+# target.inline-breakpoint-strategy setting alternating between set "always" and
+# "headers".
+
+# RUN: %build %p/Inputs/search-support-files.cpp -o %t.out
+# RUN: %lldb -b -s %s %t.out | FileCheck %s 
+
+
+#Set breakpoint by function name.
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n function_in_header
+# CHECK: (lldb) breakpoint set -n function_in_header
+# CHECK-NEXT: Breakpoint 1: where = {{.*}}.out`function_in_header(){{.*}} at search-support-files.h
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n function_in_header
+# CHECK: (lldb) breakpoint set -n function_in_header
+# CHECK-NEXT: Breakpoint 2: where = {{.*}}.out`function_in_header(){{.*}} at search-support-files.h
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n main
+# CHECK: (lldb) breakpoint set -n main
+# CHECK-NEXT: Breakpoint 3: where = {{.*}}.out`main{{.*}} at search-support-files.cpp
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n main
+# CHECK: (lldb) breakpoint set -n main
+# CHECK-NEXT: Breakpoint 4: where = {{.*}}.out`main{{.*}} at search-support-files.cpp
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n func
+# CHECK: (lldb) breakpoint set -n func
+# CHECK-NEXT: Breakpoint 5: where = {{.*}}.out`func{{.*}} at search-support-files-func.cpp
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n func
+# CHECK: (lldb) breakpoint set -n func
+# CHECK-NEXT: Breakpoint 6: where = {{.*}}.out`func{{.*}} at search-support-files-func.cpp
+
+
+
+#   Set breakpoint by function name and filename (here: the compilation unit).
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n function_in_header -f search-support-files.cpp
+# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.cpp
+# CHECK-NEXT: Breakpoint 7: no locations (pending).
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n function_in_header -f search-support-files.cpp
+# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.cpp
+# CHECK-NEXT: Breakpoint 8: no locations (pending).
+
+
+
+#   Set breakpoint by function name and source filename (the file in which the
+#   function is defined).
+#
+#   NOTE: This test is the really interesting one as it shows that we can
+# search by source files that are themselves no compilation units.
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n function_in_header -f search-support-files.h
+# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.h
+# CHECK-NEXT: Breakpoint 9: where = {{.*}}.out`function_in_header(){{.*}} at search-support-files.h
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n function_in_header -f search-support-files.h
+# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.h
+# CHECK-NEXT: Breakpoint 10: no locations (pending).
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n func -f search-support-files-func.cpp
+# CHECK: (lldb) breakpoint set -n func -f search-support-files-func.cpp
+# CHECK-NEXT: Breakpoint 11: where = {{.*}}.out`func(){{.*}} at search-support-files-func.cpp
+
+settings set target.inline-breakpoint-strategy headers
+breakpoint set -n func -f search-support-files-func.cpp
+# CHECK: (lldb) breakpoint set -n func -f search-support-files-func.cpp
+# CHECK-NEXT: Breakpoint 12: no locations (pending).
+
+
+
+#   Set breakpoint by function name and source filename. This time the file
+#   doesn't exist or is not the file in which the function is declared or
+#   defined. This is to prove that we haven't widen the search space too much.
+#   When we search for a function in a file that doesn't exist, we should get no
+#   results.
+
+
+
+settings set target.inline-breakpoint-strategy always
+breakpoint set -n function_in_

[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint

2020-06-10 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

@labath I've applied all the ideas we ping-ponged yesterday and I decided to go 
with alternating the `target.inline-breakpoint-strategy` from `always` (the 
default) to `headers`. This way you can exactly see in the test file how things 
are behaving. So before going into the actual code review I'd like to ask you 
and @jingham to take a look at the test file. Is it the behavior described 
there the desired outcome? Then we can discuss the implementation.




Comment at: lldb/source/Breakpoint/BreakpointResolverName.cpp:320
+else
+  remove_it = false;
+  }

This is done on purpose to reverse the decision to remove a context for not 
passing a CU above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74136



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


[Lldb-commits] [lldb] 539b47c - [lldb/Makefile.rules] Apply CFLAGS_EXTRAS after debug-info mode flags

2020-06-10 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-06-10T14:27:53+02:00
New Revision: 539b47c9d1edd3b152efc9073f6729f28cf48d9a

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

LOG: [lldb/Makefile.rules] Apply CFLAGS_EXTRAS after debug-info mode flags

This makes it possible to conditionally override some of these flags via
CFLAGS_EXTRAS. It should be NFC right now, but this seems the logical
order in which to apply these things, and I am going to make use of this
in another patch.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index ea0fa748bc36..554d32007e64 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -295,7 +295,7 @@ ifndef NO_TEST_COMMON_H
   CFLAGS += -include $(THIS_FILE_DIR)/test_common.h
 endif
 
-CFLAGS += $(NO_LIMIT_DEBUG_INFO_FLAGS) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS)
+CFLAGS += $(NO_LIMIT_DEBUG_INFO_FLAGS) $(ARCH_CFLAGS)
 
 # If the OS is Windows, we need to pass -gdwarf to clang, otherwise it will 
build
 # with codeview by default but all the tests rely on dwarf.
@@ -335,6 +335,7 @@ ifeq "$(MAKE_GMODULES)" "YES"
CXXFLAGS += $(MANDATORY_MODULE_BUILD_CFLAGS)
 endif
 
+CFLAGS += $(CFLAGS_EXTRAS)
 CXXFLAGS += -std=c++11 $(CFLAGS) $(ARCH_CXXFLAGS) $(CXXFLAGS_EXTRAS)
 LD = $(CC)
 LDFLAGS ?= $(CFLAGS)



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


[Lldb-commits] [PATCH] D81561: [lldb] Add basic -flimit-debug-info support to expression evaluator

2020-06-10 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: teemperor, clayborg, jingham.
Herald added subscribers: aaron.ballman, aprantl.
Herald added a reviewer: shafik.
Herald added a reviewer: shafik.
Herald added a project: LLDB.

This patch adds support for evaluation of expressions referring to types
which were compiled in -flimit-debug-info (a.k.a -fno-standalone-debug)
in clang. In this mode it's possible that the debug information needed
to fully describe a c++ type is not present in a single shared library

- for example debug info for a base class or a member of a type can

only be found in another shared library.  This situation is not
currently handled well within lldb as we are limited to searching within
a single shared library (lldb_private::Module) when searching for the
definition of these types.

The way that this patch gets around this limitation is by doing the
search at a later stage -- during the construction of the expression ast
context. This works by having the parser (currently SymbolFileDWARF, but
a similar approach is probably needed for PDBs too) mark a type as
"forcefully completed". What this means is that the parser has marked
the type as "complete" in the module ast context (as this is necessary
to e.g. derive classes from it), but its definition is not really there.
This is done via a new field on the ClangASTMetadata struct.

Later, when we are importing such a type into the expression ast, we
check this flag. If the flag is set, we try to find a better definition
for the type in other shared libraries. This part reuses the same code
path (ClangASTSource::CompleteType) that we are using to find
definitions of types that are incomplete in some module (the difference
between this situation and -flimit-debug-info is that in the former
case, the type is only ever used opaquely in the module -- e.g. FILE *

- whereas in the latter the type was fully defined in the source code,

but the compiler chose not to emit its definition in the debug info).

This required a small refactor of the ClangASTSource::CompleteType
function -- I split off the part which searches for the equivalent
complete type into a separate function. This was needed because the
import process operates slightly differently here. Previously, we were
being asked to complete an already imported forward declaration. Now we
are searching for an equivalent declaration before importing anything --
that's because importing an "forcefully completed" type would mark the
type as complete in the destination AST and we would not be asked to
complete it anymore.

This patch only implements this handling for base classes, but other
cases (members, array element types, etc.). The changes for that should
be fairly simple and mostly revolve around marking these types as
"forcefully completed" at an approriate time -- the importing logic is
generic already.

Another aspect, which is also not handled by this patch is viewing these
types via the "frame variable" command. This does not use the AST
importer and so it will need to handle these types on its own -- that
will be the subject of another patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81561

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.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/CxxModuleHandler.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/test/API/functionalities/limit-debug-info/Makefile
  lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
  lldb/test/API/functionalities/limit-debug-info/foo.cpp
  lldb/test/API/functionalities/limit-debug-info/main.cpp
  lldb/test/API/functionalities/limit-debug-info/one.cpp
  lldb/test/API/functionalities/limit-debug-info/onetwo.h
  lldb/test/API/functionalities/limit-debug-info/two.cpp

Index: lldb/test/API/functionalities/limit-debug-info/two.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/limit-debug-info/two.cpp
@@ -0,0 +1,3 @@
+#include "onetwo.h"
+
+Two::~Two() = default;
Index: lldb/test/API/functionalities/limit-debug-info/onetwo.h
===
--- /dev/null
+++ lldb/test/API/functionalities/limit-debug-info/onetwo.h
@@ -0,0 +1,11 @@
+struct One {
+  int one = 142;
+  constexpr One() = default;
+  virtual ~One();
+};
+
+struct Two : One {
+  int two = 242;
+  constexpr Two() = default;
+  ~Two() override;
+};
Index: lldb/test/API/functionalities/limit-debug-info/one.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/limit-debug-info/one.cpp
@@ -0,0 +1,4 @@
+#include "onetwo.h"
+
+One::~One() = default;
+
Index: lldb/test/API/functionalities/limit-debug-

[Lldb-commits] [lldb] 040eca7 - [lldb/Utility] Remove m_ieee_quad from Scalar

2020-06-10 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-06-10T15:15:01+02:00
New Revision: 040eca77170bea12ca0614cdb256b957c3b93810

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

LOG: [lldb/Utility] Remove m_ieee_quad from Scalar

This field is unused (the only way to change its value is via a
constructor which is never called), and as far as I can tell it has been
unused since it was introduced in D12100. It also has some soundness
issues -- e.g.  operator= does not reinitialize it, but uses the old
value from the overwritten object.

It sounds like this class should be able to support different floating
point semantics, but if that is needed, it would be better to start
afresh -- probably by passing in an APFloat::fltSemantics object instead
of a bool flag.

Added: 


Modified: 
lldb/include/lldb/Utility/Scalar.h
lldb/source/Utility/Scalar.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Scalar.h 
b/lldb/include/lldb/Utility/Scalar.h
index 69c948ec6222..0c8f7452cfc3 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -83,20 +83,11 @@ class Scalar {
   Scalar(double v) : m_type(e_double), m_float(v) {
 m_float = llvm::APFloat(v);
   }
-  Scalar(long double v, bool ieee_quad)
-  : m_type(e_long_double), m_float(static_cast(0)),
-m_ieee_quad(ieee_quad) {
-if (ieee_quad)
-  m_float =
-  llvm::APFloat(llvm::APFloat::IEEEquad(),
-llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
-(reinterpret_cast(&v))->x));
-else
-  m_float =
-  llvm::APFloat(llvm::APFloat::x87DoubleExtended(),
-llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
-(reinterpret_cast(&v))->x));
-  }
+  Scalar(long double v)
+  : m_type(e_long_double),
+m_float(llvm::APFloat::x87DoubleExtended(),
+llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
+(reinterpret_cast(&v))->x)) {}
   Scalar(llvm::APInt v) : m_type(), m_float(static_cast(0)) {
 m_integer = llvm::APInt(v);
 m_type = GetBestTypeForBitSize(m_integer.getBitWidth(), true);
@@ -282,7 +273,6 @@ class Scalar {
   Scalar::Type m_type;
   llvm::APInt m_integer;
   llvm::APFloat m_float;
-  bool m_ieee_quad = false;
 
 private:
   friend const Scalar operator+(const Scalar &lhs, const Scalar &rhs);

diff  --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index e55aa2d4d5a4..827a3f68c62a 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -355,14 +355,9 @@ Scalar &Scalar::operator=(double v) {
 
 Scalar &Scalar::operator=(long double v) {
   m_type = e_long_double;
-  if (m_ieee_quad)
-m_float = llvm::APFloat(llvm::APFloat::IEEEquad(),
-llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
-(reinterpret_cast(&v))->x));
-  else
-m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended(),
-llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
-(reinterpret_cast(&v))->x));
+  m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended(),
+  llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
+  (reinterpret_cast(&v))->x));
   return *this;
 }
 
@@ -523,8 +518,7 @@ bool Scalar::Promote(Scalar::Type type) {
   break;
 
 case e_long_double:
-  m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
-  : 
llvm::APFloat::x87DoubleExtended());
+  m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended());
   m_float.convertFromAPInt(m_integer, true,
llvm::APFloat::rmNearestTiesToEven);
   success = true;
@@ -593,8 +587,7 @@ bool Scalar::Promote(Scalar::Type type) {
   break;
 
 case e_long_double:
-  m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
-  : 
llvm::APFloat::x87DoubleExtended());
+  m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended());
   m_float.convertFromAPInt(m_integer, false,
llvm::APFloat::rmNearestTiesToEven);
   success = true;
@@ -659,8 +652,7 @@ bool Scalar::Promote(Scalar::Type type) {
   break;
 
 case e_long_double:
-  m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
-  : 
llvm::APFloat::x87DoubleExtended());
+  m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended());
   m_float.convertFromAPInt(m_integer, true,
llvm::APFloat

[Lldb-commits] [lldb] bb9d93f - [lldb] Replace the LEB128 decoding logic in LLDB's DataExtractor with calls to LLVM's LEB128 implementation

2020-06-10 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-06-10T16:35:09+02:00
New Revision: bb9d93f4d5934259fa2a55aabfda89e631e02037

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

LOG: [lldb] Replace the LEB128 decoding logic in LLDB's DataExtractor with 
calls to LLVM's LEB128 implementation

Reviewers: labath, JDevlieghere

Reviewed By: labath

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

Added: 


Modified: 
lldb/source/Utility/DataExtractor.cpp

Removed: 




diff  --git a/lldb/source/Utility/DataExtractor.cpp 
b/lldb/source/Utility/DataExtractor.cpp
index 023190b2ae91..365ee58bb95b 100644
--- a/lldb/source/Utility/DataExtractor.cpp
+++ b/lldb/source/Utility/DataExtractor.cpp
@@ -24,6 +24,7 @@
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/LEB128.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/MathExtras.h"
 
@@ -877,26 +878,10 @@ uint64_t DataExtractor::GetULEB128(offset_t *offset_ptr) 
const {
   if (src == nullptr)
 return 0;
 
-  const uint8_t *end = m_end;
-
-  if (src < end) {
-uint64_t result = *src++;
-if (result >= 0x80) {
-  result &= 0x7f;
-  int shift = 7;
-  while (src < end) {
-uint8_t byte = *src++;
-result |= static_cast(byte & 0x7f) << shift;
-if ((byte & 0x80) == 0)
-  break;
-shift += 7;
-  }
-}
-*offset_ptr = src - m_start;
-return result;
-  }
-
-  return 0;
+  unsigned byte_count = 0;
+  uint64_t result = llvm::decodeULEB128(src, &byte_count, m_end);
+  *offset_ptr += byte_count;
+  return result;
 }
 
 // Extracts an signed LEB128 number from this object's data starting at the
@@ -910,35 +895,10 @@ int64_t DataExtractor::GetSLEB128(offset_t *offset_ptr) 
const {
   if (src == nullptr)
 return 0;
 
-  const uint8_t *end = m_end;
-
-  if (src < end) {
-int64_t result = 0;
-int shift = 0;
-int size = sizeof(int64_t) * 8;
-
-uint8_t byte = 0;
-int bytecount = 0;
-
-while (src < end) {
-  bytecount++;
-  byte = *src++;
-  result |= static_cast(byte & 0x7f) << shift;
-  shift += 7;
-  if ((byte & 0x80) == 0)
-break;
-}
-
-// Sign bit of byte is 2nd high order bit (0x40)
-if (shift < size && (byte & 0x40)) {
-  // -(static_cast(1) << 63) errors on the negation with UBSan.
-  result |= -(static_cast(1) << shift);
-}
-
-*offset_ptr += bytecount;
-return result;
-  }
-  return 0;
+  unsigned byte_count = 0;
+  int64_t result = llvm::decodeSLEB128(src, &byte_count, m_end);
+  *offset_ptr += byte_count;
+  return result;
 }
 
 // Skips a ULEB128 number (signed or unsigned) from this object's data starting



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


[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint

2020-06-10 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk planned changes to this revision.
kwk added a comment.

IMPORTANT: The behavior of `target.inline-breakpoint-strategy` when set to 
`headers` is still subject to change!

I think the setting is not respected correctly...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74136



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


[Lldb-commits] [PATCH] D81453: [lldb] Replace the LEB128 decoding logic in LLDB's DataExtractor with calls to LLVM's LEB128 implementation

2020-06-10 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbb9d93f4d593: [lldb] Replace the LEB128 decoding logic in 
LLDB's DataExtractor with calls to… (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81453

Files:
  lldb/source/Utility/DataExtractor.cpp


Index: lldb/source/Utility/DataExtractor.cpp
===
--- lldb/source/Utility/DataExtractor.cpp
+++ lldb/source/Utility/DataExtractor.cpp
@@ -24,6 +24,7 @@
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/LEB128.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/MathExtras.h"
 
@@ -877,26 +878,10 @@
   if (src == nullptr)
 return 0;
 
-  const uint8_t *end = m_end;
-
-  if (src < end) {
-uint64_t result = *src++;
-if (result >= 0x80) {
-  result &= 0x7f;
-  int shift = 7;
-  while (src < end) {
-uint8_t byte = *src++;
-result |= static_cast(byte & 0x7f) << shift;
-if ((byte & 0x80) == 0)
-  break;
-shift += 7;
-  }
-}
-*offset_ptr = src - m_start;
-return result;
-  }
-
-  return 0;
+  unsigned byte_count = 0;
+  uint64_t result = llvm::decodeULEB128(src, &byte_count, m_end);
+  *offset_ptr += byte_count;
+  return result;
 }
 
 // Extracts an signed LEB128 number from this object's data starting at the
@@ -910,35 +895,10 @@
   if (src == nullptr)
 return 0;
 
-  const uint8_t *end = m_end;
-
-  if (src < end) {
-int64_t result = 0;
-int shift = 0;
-int size = sizeof(int64_t) * 8;
-
-uint8_t byte = 0;
-int bytecount = 0;
-
-while (src < end) {
-  bytecount++;
-  byte = *src++;
-  result |= static_cast(byte & 0x7f) << shift;
-  shift += 7;
-  if ((byte & 0x80) == 0)
-break;
-}
-
-// Sign bit of byte is 2nd high order bit (0x40)
-if (shift < size && (byte & 0x40)) {
-  // -(static_cast(1) << 63) errors on the negation with UBSan.
-  result |= -(static_cast(1) << shift);
-}
-
-*offset_ptr += bytecount;
-return result;
-  }
-  return 0;
+  unsigned byte_count = 0;
+  int64_t result = llvm::decodeSLEB128(src, &byte_count, m_end);
+  *offset_ptr += byte_count;
+  return result;
 }
 
 // Skips a ULEB128 number (signed or unsigned) from this object's data starting


Index: lldb/source/Utility/DataExtractor.cpp
===
--- lldb/source/Utility/DataExtractor.cpp
+++ lldb/source/Utility/DataExtractor.cpp
@@ -24,6 +24,7 @@
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/LEB128.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/MathExtras.h"
 
@@ -877,26 +878,10 @@
   if (src == nullptr)
 return 0;
 
-  const uint8_t *end = m_end;
-
-  if (src < end) {
-uint64_t result = *src++;
-if (result >= 0x80) {
-  result &= 0x7f;
-  int shift = 7;
-  while (src < end) {
-uint8_t byte = *src++;
-result |= static_cast(byte & 0x7f) << shift;
-if ((byte & 0x80) == 0)
-  break;
-shift += 7;
-  }
-}
-*offset_ptr = src - m_start;
-return result;
-  }
-
-  return 0;
+  unsigned byte_count = 0;
+  uint64_t result = llvm::decodeULEB128(src, &byte_count, m_end);
+  *offset_ptr += byte_count;
+  return result;
 }
 
 // Extracts an signed LEB128 number from this object's data starting at the
@@ -910,35 +895,10 @@
   if (src == nullptr)
 return 0;
 
-  const uint8_t *end = m_end;
-
-  if (src < end) {
-int64_t result = 0;
-int shift = 0;
-int size = sizeof(int64_t) * 8;
-
-uint8_t byte = 0;
-int bytecount = 0;
-
-while (src < end) {
-  bytecount++;
-  byte = *src++;
-  result |= static_cast(byte & 0x7f) << shift;
-  shift += 7;
-  if ((byte & 0x80) == 0)
-break;
-}
-
-// Sign bit of byte is 2nd high order bit (0x40)
-if (shift < size && (byte & 0x40)) {
-  // -(static_cast(1) << 63) errors on the negation with UBSan.
-  result |= -(static_cast(1) << shift);
-}
-
-*offset_ptr += bytecount;
-return result;
-  }
-  return 0;
+  unsigned byte_count = 0;
+  int64_t result = llvm::decodeSLEB128(src, &byte_count, m_end);
+  *offset_ptr += byte_count;
+  return result;
 }
 
 // Skips a ULEB128 number (signed or unsigned) from this object's data starting
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 42229b6 - [lldb] XFAIL TestForwardDeclaration.test_debug_names on windows

2020-06-10 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-06-10T17:09:51+02:00
New Revision: 42229b6de756d7e3843d9cdd1988a88d76970695

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

LOG: [lldb] XFAIL TestForwardDeclaration.test_debug_names on windows

Before 539b47c9 this test was not actually using the debug_names section
because the -gdwarf added by Makefile.rules on windows overrode the
-gdwarf-5 flag from CFLAGS_EXTRAS. Now that -gdwarf-5 is respected, the
test is failing.

Added: 


Modified: 
lldb/test/API/lang/c/forward/TestForwardDeclaration.py

Removed: 




diff  --git a/lldb/test/API/lang/c/forward/TestForwardDeclaration.py 
b/lldb/test/API/lang/c/forward/TestForwardDeclaration.py
index f955d013bc90..f8f8a46d8a29 100644
--- a/lldb/test/API/lang/c/forward/TestForwardDeclaration.py
+++ b/lldb/test/API/lang/c/forward/TestForwardDeclaration.py
@@ -59,6 +59,7 @@ def test(self):
 @skipIfDarwin
 @skipIf(compiler=no_match("clang"))
 @skipIf(compiler_version=["<", "7.0"])
+@expectedFailureAll(oslist=["windows"])
 def test_debug_names(self):
 """Test that we are able to find complete types when using DWARF v5
 accelerator tables"""



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


[Lldb-commits] [PATCH] D81453: [lldb] Replace the LEB128 decoding logic in LLDB's DataExtractor with calls to LLVM's LEB128 implementation

2020-06-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Utility/DataExtractor.cpp:911
 uint32_t DataExtractor::Skip_LEB128(offset_t *offset_ptr) const {
   uint32_t bytes_consumed = 0;
   const uint8_t *src = PeekData(*offset_ptr, 1);

labath wrote:
> JDevlieghere wrote:
> > Should we hoist this into llvm as well (as a separate patch). It seems like 
> > at least `lld/ELF/EhFrame.cpp` is using the same functionality. 
> TBH, I'm tempted to just delete it. I doubt that "skipping" an LEB128 is 
> going to be noticeably faster than "reading" it, and llvm::DataExtractor has 
> no equivalent function...
Even better :-) 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81453



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


[Lldb-commits] [PATCH] D81516: [lldb/Test] Ensure inline tests have a unique build directory

2020-06-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 269871.
JDevlieghere added a comment.

Implement Pavel's approach


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

https://reviews.llvm.org/D81516

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


Index: lldb/packages/Python/lldbsuite/test/lldbinline.py
===
--- lldb/packages/Python/lldbsuite/test/lldbinline.py
+++ lldb/packages/Python/lldbsuite/test/lldbinline.py
@@ -82,6 +82,11 @@
 
 
 class InlineTest(TestBase):
+# Overrides
+
+def getBuildDirBasename(self):
+return self.__class__.__name__ + "." + self.testMethodName
+
 # Internal implementation
 
 def BuildMakefile(self):


Index: lldb/packages/Python/lldbsuite/test/lldbinline.py
===
--- lldb/packages/Python/lldbsuite/test/lldbinline.py
+++ lldb/packages/Python/lldbsuite/test/lldbinline.py
@@ -82,6 +82,11 @@
 
 
 class InlineTest(TestBase):
+# Overrides
+
+def getBuildDirBasename(self):
+return self.__class__.__name__ + "." + self.testMethodName
+
 # Internal implementation
 
 def BuildMakefile(self):
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81516: [lldb/Test] Ensure inline tests have a unique build directory

2020-06-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere marked 2 inline comments as done.
JDevlieghere added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/lldbinline.py:209
 test_class = type(name, (InlineTest,), dict(test=test_func,
-name=name, _build_dict=build_dict))
+name=name, __inline_name__=name, _build_dict=build_dict))
 

labath wrote:
> `__inline_name__` is not a good name according to 
> :
> ```
> __double_leading_and_trailing_underscore__: "magic" objects or attributes 
> that live in user-controlled namespaces. E.g. __init__, __import__ or 
> __file__. Never invent such names; only use them as documented.
> ```
> 
I did it for consistency with `__no_debug_info_test__`. Based on that PEP we 
should rename it to `__no_debug_info_test`?


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

https://reviews.llvm.org/D81516



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


[Lldb-commits] [PATCH] D81589: [lldb/SymbolFile] Don't parse the whole line table for the support files (WIP)

2020-06-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 269893.

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

https://reviews.llvm.org/D81589

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -174,6 +174,33 @@
   return *line_table;
 }
 
+static bool ParseLLVMLineTablePrologue(lldb_private::DWARFContext &context,
+   llvm::DWARFDebugLine::Prologue 
&prologue,
+   dw_offset_t line_offset,
+   dw_offset_t unit_offset) {
+  Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
+  bool success = true;
+  llvm::DWARFDataExtractor data = context.getOrLoadLineData().GetAsLLVM();
+  llvm::DWARFContext &ctx = context.GetAsLLVM();
+  uint64_t offset = line_offset;
+  llvm::Error error = prologue.parse(
+  data, &offset,
+  [&](llvm::Error e) {
+success = false;
+LLDB_LOG_ERROR(log, std::move(e),
+   "SymbolFileDWARF::ParseSupportFiles failed to parse "
+   "line table prologue");
+  },
+  ctx, nullptr);
+  if (error) {
+LLDB_LOG_ERROR(log, std::move(error),
+   "SymbolFileDWARF::ParseSupportFiles failed to parse line "
+   "table prologue");
+return false;
+  }
+  return success;
+}
+
 static llvm::Optional
 GetFileByIndex(const llvm::DWARFDebugLine::Prologue &prologue, size_t idx,
llvm::StringRef compile_dir, FileSpec::Style style) {
@@ -854,8 +881,29 @@
 
 bool SymbolFileDWARF::ParseSupportFiles(CompileUnit &comp_unit,
 FileSpecList &support_files) {
-  if (!comp_unit.GetLineTable())
-ParseLineTable(comp_unit);
+  std::lock_guard guard(GetModuleMutex());
+  DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
+  if (!dwarf_cu)
+return false;
+
+  const DWARFBaseDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
+  if (!dwarf_cu_die)
+return false;
+
+  const dw_offset_t cu_line_offset = dwarf_cu_die.GetAttributeValueAsUnsigned(
+  DW_AT_stmt_list, DW_INVALID_OFFSET);
+  if (cu_line_offset == DW_INVALID_OFFSET)
+return false;
+
+  llvm::DWARFDebugLine::Prologue prologue;
+  if (!ParseLLVMLineTablePrologue(m_context, prologue, cu_line_offset,
+  dwarf_cu->GetOffset()))
+return false;
+
+  comp_unit.SetSupportFiles(ParseSupportFilesFromPrologue(
+  comp_unit.GetModule(), prologue, dwarf_cu->GetPathStyle(),
+  dwarf_cu->GetCompilationDirectory().GetCString()));
+
   return true;
 }
 
@@ -1024,10 +1072,6 @@
 comp_unit.SetLineTable(line_table_up.release());
   }
 
-  comp_unit.SetSupportFiles(ParseSupportFilesFromPrologue(
-  comp_unit.GetModule(), line_table->Prologue, dwarf_cu->GetPathStyle(),
-  dwarf_cu->GetCompilationDirectory().GetCString()));
-
   return true;
 }
 


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -174,6 +174,33 @@
   return *line_table;
 }
 
+static bool ParseLLVMLineTablePrologue(lldb_private::DWARFContext &context,
+   llvm::DWARFDebugLine::Prologue &prologue,
+   dw_offset_t line_offset,
+   dw_offset_t unit_offset) {
+  Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
+  bool success = true;
+  llvm::DWARFDataExtractor data = context.getOrLoadLineData().GetAsLLVM();
+  llvm::DWARFContext &ctx = context.GetAsLLVM();
+  uint64_t offset = line_offset;
+  llvm::Error error = prologue.parse(
+  data, &offset,
+  [&](llvm::Error e) {
+success = false;
+LLDB_LOG_ERROR(log, std::move(e),
+   "SymbolFileDWARF::ParseSupportFiles failed to parse "
+   "line table prologue");
+  },
+  ctx, nullptr);
+  if (error) {
+LLDB_LOG_ERROR(log, std::move(error),
+   "SymbolFileDWARF::ParseSupportFiles failed to parse line "
+   "table prologue");
+return false;
+  }
+  return success;
+}
+
 static llvm::Optional
 GetFileByIndex(const llvm::DWARFDebugLine::Prologue &prologue, size_t idx,
llvm::StringRef compile_dir, FileSpec::Style style) {
@@ -854,8 +881,29 @@
 
 bool SymbolFileDWARF::ParseSupportFiles(CompileUnit &comp_unit,
 FileSpecList &support_files) {
-  if (!comp_unit.GetLineTable())
-ParseLineTable(comp_unit);
+  std::lock_guard guard(GetModuleMutex());
+  DWARFUnit *dwarf_cu = Ge

[Lldb-commits] [PATCH] D81589: [lldb/SymbolFile] Don't parse the whole line table for the support files (WIP)

2020-06-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.
JDevlieghere updated this revision to Diff 269893.

https://reviews.llvm.org/D81589

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -174,6 +174,33 @@
   return *line_table;
 }
 
+static bool ParseLLVMLineTablePrologue(lldb_private::DWARFContext &context,
+   llvm::DWARFDebugLine::Prologue 
&prologue,
+   dw_offset_t line_offset,
+   dw_offset_t unit_offset) {
+  Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
+  bool success = true;
+  llvm::DWARFDataExtractor data = context.getOrLoadLineData().GetAsLLVM();
+  llvm::DWARFContext &ctx = context.GetAsLLVM();
+  uint64_t offset = line_offset;
+  llvm::Error error = prologue.parse(
+  data, &offset,
+  [&](llvm::Error e) {
+success = false;
+LLDB_LOG_ERROR(log, std::move(e),
+   "SymbolFileDWARF::ParseSupportFiles failed to parse "
+   "line table prologue");
+  },
+  ctx, nullptr);
+  if (error) {
+LLDB_LOG_ERROR(log, std::move(error),
+   "SymbolFileDWARF::ParseSupportFiles failed to parse line "
+   "table prologue");
+return false;
+  }
+  return success;
+}
+
 static llvm::Optional
 GetFileByIndex(const llvm::DWARFDebugLine::Prologue &prologue, size_t idx,
llvm::StringRef compile_dir, FileSpec::Style style) {
@@ -854,8 +881,29 @@
 
 bool SymbolFileDWARF::ParseSupportFiles(CompileUnit &comp_unit,
 FileSpecList &support_files) {
-  if (!comp_unit.GetLineTable())
-ParseLineTable(comp_unit);
+  std::lock_guard guard(GetModuleMutex());
+  DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
+  if (!dwarf_cu)
+return false;
+
+  const DWARFBaseDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
+  if (!dwarf_cu_die)
+return false;
+
+  const dw_offset_t cu_line_offset = dwarf_cu_die.GetAttributeValueAsUnsigned(
+  DW_AT_stmt_list, DW_INVALID_OFFSET);
+  if (cu_line_offset == DW_INVALID_OFFSET)
+return false;
+
+  llvm::DWARFDebugLine::Prologue prologue;
+  if (!ParseLLVMLineTablePrologue(m_context, prologue, cu_line_offset,
+  dwarf_cu->GetOffset()))
+return false;
+
+  comp_unit.SetSupportFiles(ParseSupportFilesFromPrologue(
+  comp_unit.GetModule(), prologue, dwarf_cu->GetPathStyle(),
+  dwarf_cu->GetCompilationDirectory().GetCString()));
+
   return true;
 }
 
@@ -1024,10 +1072,6 @@
 comp_unit.SetLineTable(line_table_up.release());
   }
 
-  comp_unit.SetSupportFiles(ParseSupportFilesFromPrologue(
-  comp_unit.GetModule(), line_table->Prologue, dwarf_cu->GetPathStyle(),
-  dwarf_cu->GetCompilationDirectory().GetCString()));
-
   return true;
 }
 


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -174,6 +174,33 @@
   return *line_table;
 }
 
+static bool ParseLLVMLineTablePrologue(lldb_private::DWARFContext &context,
+   llvm::DWARFDebugLine::Prologue &prologue,
+   dw_offset_t line_offset,
+   dw_offset_t unit_offset) {
+  Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
+  bool success = true;
+  llvm::DWARFDataExtractor data = context.getOrLoadLineData().GetAsLLVM();
+  llvm::DWARFContext &ctx = context.GetAsLLVM();
+  uint64_t offset = line_offset;
+  llvm::Error error = prologue.parse(
+  data, &offset,
+  [&](llvm::Error e) {
+success = false;
+LLDB_LOG_ERROR(log, std::move(e),
+   "SymbolFileDWARF::ParseSupportFiles failed to parse "
+   "line table prologue");
+  },
+  ctx, nullptr);
+  if (error) {
+LLDB_LOG_ERROR(log, std::move(error),
+   "SymbolFileDWARF::ParseSupportFiles failed to parse line "
+   "table prologue");
+return false;
+  }
+  return success;
+}
+
 static llvm::Optional
 GetFileByIndex(const llvm::DWARFDebugLine::Prologue &prologue, size_t idx,
llvm::StringRef compile_dir, FileSpec::Style style) {
@@ -854,8 +881,29 @@
 
 bool SymbolFileDWARF::ParseSupportFiles(CompileUnit &comp_unit,
 FileSpecList &support_files) {
-  if (!comp_unit.GetLineTable())
-ParseLineTable(comp_unit);
+  std::lock_guard guard(Get

[Lldb-commits] [PATCH] D81612: [lldb/Test] Assert that no targets or global modules remain after a test completes.

2020-06-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: friss, labath, jingham, vsk.
Herald added a subscriber: abidh.

The reproducer intentionally leak every object allocated during replay, which 
means that modules never get orphaned. If this were to happen for another 
reason, we might not be testing what we think we are. Assert that there are no 
targets left at the end of a test and that the global module cache is empty in 
the non-reproducer scenario.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D81612

Files:
  lldb/bindings/interface/SBModule.i
  lldb/include/lldb/API/SBModule.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/API/SBModule.cpp


Index: lldb/source/API/SBModule.cpp
===
--- lldb/source/API/SBModule.cpp
+++ lldb/source/API/SBModule.cpp
@@ -683,6 +683,13 @@
   return LLDB_RECORD_RESULT(sb_addr);
 }
 
+uint32_t SBModule::GetNumberAllocatedModules() {
+  LLDB_RECORD_STATIC_METHOD_NO_ARGS(uint32_t, SBModule,
+GetNumberAllocatedModules);
+
+  return Module::GetNumberAllocatedModules();
+}
+
 namespace lldb_private {
 namespace repro {
 
@@ -757,6 +764,8 @@
  GetObjectFileHeaderAddress, ());
   LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule,
  GetObjectFileEntryPointAddress, ());
+  LLDB_REGISTER_STATIC_METHOD(uint32_t, SBModule, GetNumberAllocatedModules,
+  ());
 }
 
 }
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2022,6 +2022,14 @@
 for target in targets:
 self.dbg.DeleteTarget(target)
 
+# Modules are not orphaned during reproducer replay because they're
+# leaked on purpose.
+if not configuration.is_reproducer():
+# Assert that all targets are deleted.
+self.assertEqual(self.dbg.GetNumTargets(), 0)
+# Assert that the global module cache is empty.
+self.assertEqual(lldb.SBModule.GetNumberAllocatedModules(), 0)
+
 # Do this last, to make sure it's in reverse order from how we setup.
 Base.tearDown(self)
 
Index: lldb/include/lldb/API/SBModule.h
===
--- lldb/include/lldb/API/SBModule.h
+++ lldb/include/lldb/API/SBModule.h
@@ -288,6 +288,9 @@
   lldb::SBAddress GetObjectFileHeaderAddress() const;
   lldb::SBAddress GetObjectFileEntryPointAddress() const;
 
+  /// Get the number of global modules.
+  static uint32_t GetNumberAllocatedModules();
+
 private:
   friend class SBAddress;
   friend class SBFrame;
Index: lldb/bindings/interface/SBModule.i
===
--- lldb/bindings/interface/SBModule.i
+++ lldb/bindings/interface/SBModule.i
@@ -344,6 +344,9 @@
 lldb::SBAddress
 GetObjectFileEntryPointAddress() const;
 
+static uint32_t
+GetNumberAllocatedModules();
+
 STRING_EXTENSION(SBModule)
 
 #ifdef SWIGPYTHON


Index: lldb/source/API/SBModule.cpp
===
--- lldb/source/API/SBModule.cpp
+++ lldb/source/API/SBModule.cpp
@@ -683,6 +683,13 @@
   return LLDB_RECORD_RESULT(sb_addr);
 }
 
+uint32_t SBModule::GetNumberAllocatedModules() {
+  LLDB_RECORD_STATIC_METHOD_NO_ARGS(uint32_t, SBModule,
+GetNumberAllocatedModules);
+
+  return Module::GetNumberAllocatedModules();
+}
+
 namespace lldb_private {
 namespace repro {
 
@@ -757,6 +764,8 @@
  GetObjectFileHeaderAddress, ());
   LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule,
  GetObjectFileEntryPointAddress, ());
+  LLDB_REGISTER_STATIC_METHOD(uint32_t, SBModule, GetNumberAllocatedModules,
+  ());
 }
 
 }
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2022,6 +2022,14 @@
 for target in targets:
 self.dbg.DeleteTarget(target)
 
+# Modules are not orphaned during reproducer replay because they're
+# leaked on purpose.
+if not configuration.is_reproducer():
+# Assert that all targets are deleted.
+self.assertEqual(self.dbg.GetNumTargets(), 0)
+# Assert that the global module cache is empty.
+self.assertEqual(lldb.SBModule.GetNumberAllocatedModules(), 0)
+
 # Do this last, to make sure it's in reverse order from how we setup.
 Base.tearDown(self)
 
Index: lldb/include/lldb/API/SBModule.h

[Lldb-commits] [PATCH] D80112: Check if thread was suspended during previous stop added.

2020-06-10 Thread Ilya Bukonkin via Phabricator via lldb-commits
fallkrum updated this revision to Diff 269963.
fallkrum added a comment.

Sorry for misunderstanding, you were right, it is possible to reproduce 
situation via SB API tests. Please check them out.

In D80112#2080516 , @jingham wrote:

> This patch has gotten hard to read because the latest version seems to have 
> lots of unrelated changes, maybe from running clang-format over code you 
> aren't actually changing?  Can you remove all these irrelevant changes and 
> repost the patch?


Yes, it was due to clang-format, removed irrelevant changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80112

Files:
  lldb/include/lldb/Target/Process.h
  lldb/source/Target/Process.cpp
  lldb/test/API/functionalities/thread/ignore_suspended/Makefile
  
lldb/test/API/functionalities/thread/ignore_suspended/TestIgnoreSuspendedThread.py
  lldb/test/API/functionalities/thread/ignore_suspended/main.cpp
  lldb/unittests/CMakeLists.txt
  lldb/unittests/Process/CMakeLists.txt
  lldb/unittests/Process/ProcessEventDataTest.cpp
  lldb/unittests/Thread/CMakeLists.txt
  lldb/unittests/Thread/ThreadTest.cpp

Index: lldb/unittests/Thread/ThreadTest.cpp
===
--- /dev/null
+++ lldb/unittests/Thread/ThreadTest.cpp
@@ -0,0 +1,166 @@
+//===-- ThreadTest.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/Target/Thread.h"
+#include "Plugins/Platform/Linux/PlatformLinux.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/StopInfo.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/Reproducer.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+using namespace lldb_private::repro;
+using namespace lldb;
+
+namespace {
+class ThreadTest : public ::testing::Test {
+public:
+  void SetUp() override {
+llvm::cantFail(Reproducer::Initialize(ReproducerMode::Off, llvm::None));
+FileSystem::Initialize();
+HostInfo::Initialize();
+platform_linux::PlatformLinux::Initialize();
+  }
+  void TearDown() override {
+platform_linux::PlatformLinux::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+Reproducer::Terminate();
+  }
+};
+
+class DummyProcess : public Process {
+public:
+  using Process::Process;
+
+  virtual bool CanDebug(lldb::TargetSP target, bool plugin_specified_by_name) {
+return true;
+  }
+  virtual Status DoDestroy() { return {}; }
+  virtual void RefreshStateAfterStop() {}
+  virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
+  Status &error) {
+return 0;
+  }
+  virtual bool UpdateThreadList(ThreadList &old_thread_list,
+ThreadList &new_thread_list) {
+return false;
+  }
+  virtual ConstString GetPluginName() { return ConstString("Dummy"); }
+  virtual uint32_t GetPluginVersion() { return 0; }
+
+  ProcessModID &GetModIDNonConstRef() { return m_mod_id; }
+};
+
+class DummyThread : public Thread {
+public:
+  using Thread::Thread;
+
+  ~DummyThread() override { DestroyThread(); }
+
+  void RefreshStateAfterStop() override {}
+
+  lldb::RegisterContextSP GetRegisterContext() override { return nullptr; }
+
+  lldb::RegisterContextSP
+  CreateRegisterContextForFrame(StackFrame *frame) override {
+return nullptr;
+  }
+
+  bool CalculateStopInfo() override { return false; }
+};
+} // namespace
+
+TargetSP CreateTarget(DebuggerSP &debugger_sp, ArchSpec &arch) {
+  Status error;
+  PlatformSP platform_sp;
+  TargetSP target_sp;
+  error = debugger_sp->GetTargetList().CreateTarget(
+  *debugger_sp, "", arch, eLoadDependentsNo, platform_sp, target_sp);
+
+  if (target_sp) {
+debugger_sp->GetTargetList().SetSelectedTarget(target_sp.get());
+  }
+
+  return target_sp;
+}
+
+TEST_F(ThreadTest, SetStopInfo) {
+  ArchSpec arch("powerpc64-pc-linux");
+
+  Platform::SetHostPlatform(
+  platform_linux::PlatformLinux::CreateInstance(true, &arch));
+
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  TargetSP target_sp = CreateTarget(debugger_sp, arch);
+  ASSERT_TRUE(target_sp);
+
+  ListenerSP listener_sp(Listener::MakeListener("dummy"));
+  ProcessSP process_sp = std::make_shared(target_sp, listener_sp);
+  ASSERT_TRUE(process_sp);
+
+  DummyProcess *process = static_cast(process_sp.get());
+
+  ThreadSP thread_sp = std::make_shared(*process_sp.get(), 0);
+  ASSERT_TRUE(thread_sp);
+
+  StopInfoSP stopinfo_sp =
+  StopInfo::CreateStopR

[Lldb-commits] [lldb] 661fcfc - debugserver: Enable -DLLDB_ENERGY when compiling against an internal SDK

2020-06-10 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2020-06-10T14:10:27-07:00
New Revision: 661fcfcd8afa4fbf4284a1ea8c0fc948dcc8fcac

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

LOG: debugserver: Enable -DLLDB_ENERGY when compiling against an internal SDK

This brings over functionality from the xcodeproject that went missing during 
the CMake transition.

rdar://problem/63840635

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

Added: 


Modified: 
lldb/tools/debugserver/source/CMakeLists.txt

Removed: 




diff  --git a/lldb/tools/debugserver/source/CMakeLists.txt 
b/lldb/tools/debugserver/source/CMakeLists.txt
index 151386d0c130..6c4fa026092b 100644
--- a/lldb/tools/debugserver/source/CMakeLists.txt
+++ b/lldb/tools/debugserver/source/CMakeLists.txt
@@ -129,6 +129,14 @@ if(LLDB_USE_ENTITLEMENTS)
   endif()
 endif()
 
+if($ENV{SDKROOT} MATCHES ".Internal.sdk$")
+  message(STATUS "LLDB debugserver energy support is enabled")
+  add_definitions(-DLLDB_ENERGY)
+  set(ENERGY_LIBRARY -lpmenergy -lpmsample)
+else()
+  message(STATUS "LLDB debugserver energy support is disabled")
+endif()
+
 set(generated_mach_interfaces
   ${CMAKE_CURRENT_BINARY_DIR}/mach_exc.h
   ${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c
@@ -208,7 +216,8 @@ target_link_libraries(lldbDebugserverCommon
   lldbDebugserverDarwin_DarwinLog
   ${FOUNDATION_LIBRARY}
   ${SECURITY_LIBRARY}
-  ${LIBCOMPRESSION})
+  ${LIBCOMPRESSION}
+  ${ENERGY_LIBRARY})
 if(HAVE_LIBCOMPRESSION)
   set_property(TARGET lldbDebugserverCommon APPEND PROPERTY
 COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION)



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


[Lldb-commits] [PATCH] D81300: Enable -DLLDB_ENERGY when compiling against an internal SDK

2020-06-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl marked an inline comment as done.
aprantl added inline comments.



Comment at: lldb/tools/debugserver/source/CMakeLists.txt:132
 
+if($ENV{SDKROOT} MATCHES ".Internal.sdk$")
+  message(STATUS "LLDB debugserver energy support is enabled")

JDevlieghere wrote:
> I guess this should be guarded by `if(APPLE)`? 
The whole directory is already guarded by this:
```
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
  add_lldb_tool_subdirectory(darwin-debug)
  if(NOT LLDB_USE_SYSTEM_DEBUGSERVER)
add_lldb_tool_subdirectory(debugserver)
  endif()
endif()
```


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

https://reviews.llvm.org/D81300



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


[Lldb-commits] [PATCH] D81300: Enable -DLLDB_ENERGY when compiling against an internal SDK

2020-06-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl marked an inline comment as done.
aprantl added inline comments.



Comment at: lldb/tools/debugserver/source/CMakeLists.txt:135
+  add_definitions(-DLLDB_ENERGY)
+  set(ENERGY_LIBRARY -lpmenergy -lpmsample)
+else()

JDevlieghere wrote:
> Can we not use the `find_library` patter that we use for things like 
> springboard above?
There isn't really anything to find. It's in `/usr/lib`.


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

https://reviews.llvm.org/D81300



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


[Lldb-commits] [PATCH] D81300: Enable -DLLDB_ENERGY when compiling against an internal SDK

2020-06-10 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG661fcfcd8afa: debugserver: Enable -DLLDB_ENERGY when 
compiling against an internal SDK (authored by aprantl).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81300

Files:
  lldb/tools/debugserver/source/CMakeLists.txt


Index: lldb/tools/debugserver/source/CMakeLists.txt
===
--- lldb/tools/debugserver/source/CMakeLists.txt
+++ lldb/tools/debugserver/source/CMakeLists.txt
@@ -129,6 +129,14 @@
   endif()
 endif()
 
+if($ENV{SDKROOT} MATCHES ".Internal.sdk$")
+  message(STATUS "LLDB debugserver energy support is enabled")
+  add_definitions(-DLLDB_ENERGY)
+  set(ENERGY_LIBRARY -lpmenergy -lpmsample)
+else()
+  message(STATUS "LLDB debugserver energy support is disabled")
+endif()
+
 set(generated_mach_interfaces
   ${CMAKE_CURRENT_BINARY_DIR}/mach_exc.h
   ${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c
@@ -208,7 +216,8 @@
   lldbDebugserverDarwin_DarwinLog
   ${FOUNDATION_LIBRARY}
   ${SECURITY_LIBRARY}
-  ${LIBCOMPRESSION})
+  ${LIBCOMPRESSION}
+  ${ENERGY_LIBRARY})
 if(HAVE_LIBCOMPRESSION)
   set_property(TARGET lldbDebugserverCommon APPEND PROPERTY
 COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION)


Index: lldb/tools/debugserver/source/CMakeLists.txt
===
--- lldb/tools/debugserver/source/CMakeLists.txt
+++ lldb/tools/debugserver/source/CMakeLists.txt
@@ -129,6 +129,14 @@
   endif()
 endif()
 
+if($ENV{SDKROOT} MATCHES ".Internal.sdk$")
+  message(STATUS "LLDB debugserver energy support is enabled")
+  add_definitions(-DLLDB_ENERGY)
+  set(ENERGY_LIBRARY -lpmenergy -lpmsample)
+else()
+  message(STATUS "LLDB debugserver energy support is disabled")
+endif()
+
 set(generated_mach_interfaces
   ${CMAKE_CURRENT_BINARY_DIR}/mach_exc.h
   ${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c
@@ -208,7 +216,8 @@
   lldbDebugserverDarwin_DarwinLog
   ${FOUNDATION_LIBRARY}
   ${SECURITY_LIBRARY}
-  ${LIBCOMPRESSION})
+  ${LIBCOMPRESSION}
+  ${ENERGY_LIBRARY})
 if(HAVE_LIBCOMPRESSION)
   set_property(TARGET lldbDebugserverCommon APPEND PROPERTY
 COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 351823f - [lldb/Test] Add 'std-module' category and skip them with reproducers

2020-06-10 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-06-10T14:59:05-07:00
New Revision: 351823fbf16007444fa76dc7f1434de285649ca7

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

LOG: [lldb/Test] Add 'std-module' category and skip them with reproducers

These tests are flaky on the reproducer bot. I suspect it has something
to do with the module cache. Skipping the whole category while I
investigate the issue.

Added: 
lldb/test/API/commands/expression/import-std-module/.categories

Modified: 
lldb/packages/Python/lldbsuite/test/test_categories.py
lldb/test/API/lit.cfg.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/test_categories.py 
b/lldb/packages/Python/lldbsuite/test/test_categories.py
index f0d6b9ce17de..177c50ee17cf 100644
--- a/lldb/packages/Python/lldbsuite/test/test_categories.py
+++ b/lldb/packages/Python/lldbsuite/test/test_categories.py
@@ -35,6 +35,7 @@
 'stresstest': 'Tests related to stressing lldb limits',
 'flakey': 'Flakey test cases, i.e. tests that do not reliably pass at each 
execution',
 'darwin-log': 'Darwin log tests',
+'std-module': 'Tests related to importing the std module',
 'watchpoint': 'Watchpoint-related tests',
 'lldb-vscode': 'Visual Studio Code debug adaptor tests',
 'lldb-server': 'Tests related to lldb-server',

diff  --git a/lldb/test/API/commands/expression/import-std-module/.categories 
b/lldb/test/API/commands/expression/import-std-module/.categories
new file mode 100644
index ..5fc979ca1442
--- /dev/null
+++ b/lldb/test/API/commands/expression/import-std-module/.categories
@@ -0,0 +1 @@
+std-module

diff  --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index e96c1c7dee2f..f0cfe69511ac 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -129,7 +129,7 @@ def find_shlibpath_var():
 
 if 'lldb-repro-capture' in config.available_features or \
 'lldb-repro-replay' in config.available_features:
-  dotest_cmd += ['--skip-category=lldb-vscode']
+  dotest_cmd += ['--skip-category=lldb-vscode', '--skip-category=std-module']
 
 if config.enabled_plugins:
   for plugin in config.enabled_plugins:



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


[Lldb-commits] [PATCH] D80112: Check if thread was suspended during previous stop added.

2020-06-10 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

Thanks, this is looking good.  I have a bunch of nits, but nothing substantial.




Comment at: lldb/source/Target/Process.cpp:3944
+bool Process::ProcessEventData::ShouldStop(Event *event_ptr,
+   bool *have_valid_stopinfo_ptr) {
+  ProcessSP process_sp(m_process_wp.lock());

I would use a reference for `have_valid_stopinfo_ptr` here.  Passing this in 
isn't optional (and you don't check if the pointer is null...) which is better 
expressed by taking a reference.  If you do have a reason why you want this to 
be a pointer, then you need to check if its non-null before setting it.

Also, I think "found_valid_stopinfo" is a better name.  "have" makes it sound 
like you are asking whether the ProcessEventData has a valid stopinfo pointer, 
which doesn't really make sense since Events don't have stop info.

What you are saying is the should stop computation found one...



Comment at: lldb/source/Target/Process.cpp:3977
+} else {
+  /*
+   For the sake of logical consistency. For example we have only

I'm not entirely sure about this part.  Setting the "have_valid_stopinfo_ptr 
would only matter if we stopped and no non-suspended thread had a valid stop 
reason.  That's really only going to happen because there was a bug in the 
stub, but when this happens we really can't figure out what to do.  The 
suspended thread's StopInfo isn't going to help us because it is stale by now.

I think the right thing to do in this case is say nobody had an opinion, and 
let the upper layers deal with whether they want to ignore a seemingly spurious 
stop, or stop and let the user decide what to do.



Comment at: lldb/source/Target/Process.cpp:4094
   // If we're stopped and haven't restarted, then do the StopInfo actions here:
   if (m_state == eStateStopped && !m_restarted) {
 bool does_anybody_have_an_opinion = false;

You could convert this to an early return if you feel like it.  The llvm style 
purists prefer that.



Comment at: 
lldb/test/API/functionalities/thread/ignore_suspended/TestIgnoreSuspendedThread.py:2
+"""
+Test suspeneded threads.
+"""

Spelling.  Also, say what you are testing about suspended threads, like "test 
that a suspended thread doesn't affect should-stop decisions."



Comment at: 
lldb/test/API/functionalities/thread/ignore_suspended/TestIgnoreSuspendedThread.py:14
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):

This test doesn't depend on the details of debug info generation, and doesn't 
need to be run once for each format.  If you put:

NO_DEBUG_INFO_TESTCASE = True

it will only get run once.



Comment at: 
lldb/test/API/functionalities/thread/ignore_suspended/TestIgnoreSuspendedThread.py:46
+#The breakpoint list should show 1 locations.
+self.expect(
+"breakpoint list -f",

What you are testing in this `self.expect` is already all tested by 
run_break_set_by_file_and_line.  I don't think you need to repeat it.  If you 
want to assert that the breakpoint was set exactly on the line number 
requested, just pass `loc_exact = True` as well as num_expected_locations.



Comment at: 
lldb/test/API/functionalities/thread/ignore_suspended/TestIgnoreSuspendedThread.py:62
+
+print('First stop:')
+self.printThreadsStoppedByBreakpoint(process)

We've been trying to enforce the discipline that tests only emit stdout if 
tracing is on.  So this print and the subsequent 
printThreadsStoppedByBreakpoint should be guarded by:


```
if self.TraceOn():
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80112



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


[Lldb-commits] [PATCH] D81499: [Debugger] Use FileSystem instead of calling llvm::sys::fs::openFileForWrite directly.

2020-06-10 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

This looks okay to me though I'm not very familiar with the llvm file system 
interfaces.

Do we have any tests that tests that log output gets emitted to the file 
requested when you do "log enable -f somefile whatever"?  If so and they still 
work, LGTM.  If we don't test that at all, we should probably add a test on the 
principle of "when you monkey with something that doesn't have a test, you 
should add one..."


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D81499



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


[Lldb-commits] [PATCH] D81499: [Debugger] Use FileSystem instead of calling llvm::sys::fs::openFileForWrite directly.

2020-06-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D81499#2086268 , @jingham wrote:

> This looks okay to me though I'm not very familiar with the llvm file system 
> interfaces.
>
> Do we have any tests that tests that log output gets emitted to the file 
> requested when you do "log enable -f somefile whatever"?  If so and they 
> still work, LGTM.  If we don't test that at all, we should probably add a 
> test on the principle of "when you monkey with something that doesn't have a 
> test, you should add one..."


Yep, we had two tests that were screaming at me when I messed up :-)


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D81499



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


[Lldb-commits] [PATCH] D81499: [Debugger] Use FileSystem instead of calling llvm::sys::fs::openFileForWrite directly.

2020-06-10 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

LGTM then.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D81499



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


[Lldb-commits] [PATCH] D81612: [lldb/Test] Assert that no targets or global modules remain after a test completes.

2020-06-10 Thread Vedant Kumar via Phabricator via lldb-commits
vsk added inline comments.



Comment at: lldb/bindings/interface/SBModule.i:347
 
+static uint32_t
+GetNumberAllocatedModules();

Can we add a %feature("docstring", ...) blurb about this, advising script 
authors that it's probably not an API they're interested in?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D81612



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


[Lldb-commits] [PATCH] D81561: [lldb] Add basic -flimit-debug-info support to expression evaluator

2020-06-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

The overall approach is what we had talked about previously and looks good as 
far as I can tell. I don't do enough expression parser work to give the accept 
on this, but I have no problems with what I see. If any expression parser 
experts are not on the reviewers, please add them!

This will be great to have, thanks for starting this off!!!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81561



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


[Lldb-commits] [PATCH] D81561: [lldb] Add basic -flimit-debug-info support to expression evaluator

2020-06-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

If we run into a class in the AST importer that was forcefully completed and we 
can't find a better definition, what do we do? Error out? Do what we did. I 
would like there to be a nice log line in the "log enable lldb expr" to tell us 
when this happens so we can know why an expression is failing if we don't emit 
an error and stop the expression.

Also, for "frame variable" and the any ValueObject objects, we can easily see 
what a BaseClass is marked as forcefully completed and just do a simple type 
search for the type given a full decl context as context and substitute the 
type. That won't use any of this code, it will just need to know to grab the 
the full type from the target by doing a search. We could make a function 
similar to CompilerType::GetCompleteType() that takes a target so that it can 
search all of the modules in a target for a type.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81561



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


[Lldb-commits] [lldb] 6b2e676 - [Debugger] Use FileSystem instead of calling openFileForWrite directly.

2020-06-10 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-06-10T18:13:32-07:00
New Revision: 6b2e676555c10201705a3c2e928f3d35d1fa1d4f

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

LOG: [Debugger] Use FileSystem instead of calling openFileForWrite directly.

This replaces the (only) call to llvm::sys::fs::openFileForWrite with
FileSystem::Open. This guarantees that we include log files in the
reproducers.

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

Added: 


Modified: 
lldb/source/Core/Debugger.cpp

Removed: 




diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 546dc9e86e7d..5f4f1e266d81 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -1154,17 +1154,22 @@ bool Debugger::EnableLog(llvm::StringRef channel,
 if (pos != m_log_streams.end())
   log_stream_sp = pos->second.lock();
 if (!log_stream_sp) {
-  llvm::sys::fs::OpenFlags flags = llvm::sys::fs::OF_Text;
+  File::OpenOptions flags =
+  File::eOpenOptionWrite | File::eOpenOptionCanCreate;
   if (log_options & LLDB_LOG_OPTION_APPEND)
-flags |= llvm::sys::fs::OF_Append;
-  int FD;
-  if (std::error_code ec = llvm::sys::fs::openFileForWrite(
-  log_file, FD, llvm::sys::fs::CD_CreateAlways, flags)) {
-error_stream << "Unable to open log file: " << ec.message();
+flags |= File::eOpenOptionAppend;
+  else
+flags |= File::eOpenOptionTruncate;
+  auto file = FileSystem::Instance().Open(
+  FileSpec(log_file), flags, lldb::eFilePermissionsFileDefault, false);
+  if (!file) {
+// FIXME: This gets garbled when called from the log command.
+error_stream << "Unable to open log file: " << log_file;
 return false;
   }
-  log_stream_sp =
-  std::make_shared(FD, should_close, unbuffered);
+
+  log_stream_sp = std::make_shared(
+  (*file)->GetDescriptor(), should_close, unbuffered);
   m_log_streams[log_file] = log_stream_sp;
 }
   }



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


[Lldb-commits] [PATCH] D81612: [lldb/Test] Assert that no targets or global modules remain after a test completes.

2020-06-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 270017.
JDevlieghere added a comment.

Address @vsk's feedback.


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

https://reviews.llvm.org/D81612

Files:
  lldb/bindings/interface/SBModule.i
  lldb/include/lldb/API/SBModule.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/API/SBModule.cpp


Index: lldb/source/API/SBModule.cpp
===
--- lldb/source/API/SBModule.cpp
+++ lldb/source/API/SBModule.cpp
@@ -683,6 +683,13 @@
   return LLDB_RECORD_RESULT(sb_addr);
 }
 
+uint32_t SBModule::GetNumberAllocatedModules() {
+  LLDB_RECORD_STATIC_METHOD_NO_ARGS(uint32_t, SBModule,
+GetNumberAllocatedModules);
+
+  return Module::GetNumberAllocatedModules();
+}
+
 namespace lldb_private {
 namespace repro {
 
@@ -757,6 +764,8 @@
  GetObjectFileHeaderAddress, ());
   LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule,
  GetObjectFileEntryPointAddress, ());
+  LLDB_REGISTER_STATIC_METHOD(uint32_t, SBModule, GetNumberAllocatedModules,
+  ());
 }
 
 }
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2022,6 +2022,14 @@
 for target in targets:
 self.dbg.DeleteTarget(target)
 
+# Modules are not orphaned during reproducer replay because they're
+# leaked on purpose.
+if not configuration.is_reproducer():
+# Assert that all targets are deleted.
+self.assertEqual(self.dbg.GetNumTargets(), 0)
+# Assert that the global module cache is empty.
+self.assertEqual(lldb.SBModule.GetNumberAllocatedModules(), 0)
+
 # Do this last, to make sure it's in reverse order from how we setup.
 Base.tearDown(self)
 
Index: lldb/include/lldb/API/SBModule.h
===
--- lldb/include/lldb/API/SBModule.h
+++ lldb/include/lldb/API/SBModule.h
@@ -288,6 +288,9 @@
   lldb::SBAddress GetObjectFileHeaderAddress() const;
   lldb::SBAddress GetObjectFileEntryPointAddress() const;
 
+  /// Get the number of global modules.
+  static uint32_t GetNumberAllocatedModules();
+
 private:
   friend class SBAddress;
   friend class SBFrame;
Index: lldb/bindings/interface/SBModule.i
===
--- lldb/bindings/interface/SBModule.i
+++ lldb/bindings/interface/SBModule.i
@@ -344,6 +344,15 @@
 lldb::SBAddress
 GetObjectFileEntryPointAddress() const;
 
+%feature("docstring", "
+Returns the number of modules in the module cache. This is an
+implementation detail exposed for testing and should not be relied upon.
+
+@return
+The number of modules in the module cache.") GetNumberAllocatedModules;
+static uint32_t
+GetNumberAllocatedModules();
+
 STRING_EXTENSION(SBModule)
 
 #ifdef SWIGPYTHON


Index: lldb/source/API/SBModule.cpp
===
--- lldb/source/API/SBModule.cpp
+++ lldb/source/API/SBModule.cpp
@@ -683,6 +683,13 @@
   return LLDB_RECORD_RESULT(sb_addr);
 }
 
+uint32_t SBModule::GetNumberAllocatedModules() {
+  LLDB_RECORD_STATIC_METHOD_NO_ARGS(uint32_t, SBModule,
+GetNumberAllocatedModules);
+
+  return Module::GetNumberAllocatedModules();
+}
+
 namespace lldb_private {
 namespace repro {
 
@@ -757,6 +764,8 @@
  GetObjectFileHeaderAddress, ());
   LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule,
  GetObjectFileEntryPointAddress, ());
+  LLDB_REGISTER_STATIC_METHOD(uint32_t, SBModule, GetNumberAllocatedModules,
+  ());
 }
 
 }
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2022,6 +2022,14 @@
 for target in targets:
 self.dbg.DeleteTarget(target)
 
+# Modules are not orphaned during reproducer replay because they're
+# leaked on purpose.
+if not configuration.is_reproducer():
+# Assert that all targets are deleted.
+self.assertEqual(self.dbg.GetNumTargets(), 0)
+# Assert that the global module cache is empty.
+self.assertEqual(lldb.SBModule.GetNumberAllocatedModules(), 0)
+
 # Do this last, to make sure it's in reverse order from how we setup.
 Base.tearDown(self)
 
Index: lldb/include/lldb/API/SBModule.h
===
--- lldb/include/lldb/API/SBModule.

[Lldb-commits] [PATCH] D81499: [Debugger] Use FileSystem instead of calling llvm::sys::fs::openFileForWrite directly.

2020-06-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b2e676555c1: [Debugger] Use FileSystem instead of calling 
openFileForWrite directly. (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81499

Files:
  lldb/source/Core/Debugger.cpp


Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -1154,17 +1154,22 @@
 if (pos != m_log_streams.end())
   log_stream_sp = pos->second.lock();
 if (!log_stream_sp) {
-  llvm::sys::fs::OpenFlags flags = llvm::sys::fs::OF_Text;
+  File::OpenOptions flags =
+  File::eOpenOptionWrite | File::eOpenOptionCanCreate;
   if (log_options & LLDB_LOG_OPTION_APPEND)
-flags |= llvm::sys::fs::OF_Append;
-  int FD;
-  if (std::error_code ec = llvm::sys::fs::openFileForWrite(
-  log_file, FD, llvm::sys::fs::CD_CreateAlways, flags)) {
-error_stream << "Unable to open log file: " << ec.message();
+flags |= File::eOpenOptionAppend;
+  else
+flags |= File::eOpenOptionTruncate;
+  auto file = FileSystem::Instance().Open(
+  FileSpec(log_file), flags, lldb::eFilePermissionsFileDefault, false);
+  if (!file) {
+// FIXME: This gets garbled when called from the log command.
+error_stream << "Unable to open log file: " << log_file;
 return false;
   }
-  log_stream_sp =
-  std::make_shared(FD, should_close, unbuffered);
+
+  log_stream_sp = std::make_shared(
+  (*file)->GetDescriptor(), should_close, unbuffered);
   m_log_streams[log_file] = log_stream_sp;
 }
   }


Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -1154,17 +1154,22 @@
 if (pos != m_log_streams.end())
   log_stream_sp = pos->second.lock();
 if (!log_stream_sp) {
-  llvm::sys::fs::OpenFlags flags = llvm::sys::fs::OF_Text;
+  File::OpenOptions flags =
+  File::eOpenOptionWrite | File::eOpenOptionCanCreate;
   if (log_options & LLDB_LOG_OPTION_APPEND)
-flags |= llvm::sys::fs::OF_Append;
-  int FD;
-  if (std::error_code ec = llvm::sys::fs::openFileForWrite(
-  log_file, FD, llvm::sys::fs::CD_CreateAlways, flags)) {
-error_stream << "Unable to open log file: " << ec.message();
+flags |= File::eOpenOptionAppend;
+  else
+flags |= File::eOpenOptionTruncate;
+  auto file = FileSystem::Instance().Open(
+  FileSpec(log_file), flags, lldb::eFilePermissionsFileDefault, false);
+  if (!file) {
+// FIXME: This gets garbled when called from the log command.
+error_stream << "Unable to open log file: " << log_file;
 return false;
   }
-  log_stream_sp =
-  std::make_shared(FD, should_close, unbuffered);
+
+  log_stream_sp = std::make_shared(
+  (*file)->GetDescriptor(), should_close, unbuffered);
   m_log_streams[log_file] = log_stream_sp;
 }
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81561: [lldb] Add basic -flimit-debug-info support to expression evaluator

2020-06-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

It's great to see this being addressed! I have a high-level question: When 
completing types across lldb::Modules — in which ASTContext is the complete 
type created? Since a per-module TypeSystem can be shared by many debuggers, I 
want to make sure that types from another module don't pollute another module's 
ASTContext, and that they are created in the/a scratch context instead.




Comment at: lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp:882
+  auto *td = dyn_cast(From);
+  if (td && md && md->IsForcefullyCompleted()) {
+if (auto *proxy = llvm::dyn_cast(

Can you document what case exactly is being handled here?



Comment at: lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.h:87
 
+  bool IsForcefullyCompleted() const { return m_is_forcefully_completed; }
+

It would be important to document somewhere what the semantics of this 
attribute are exactly, since the name is not self-explanatory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81561



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


[Lldb-commits] [PATCH] D81589: [lldb/SymbolFile] Don't parse the whole line table for the support files (WIP)

2020-06-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

Yes this fixes the regression and actually speeds things up a bit. My results 
were a speed up of 17% to 30% versus 11.3.1 LLDB.

Just one nit in the way we are getting the DW_AT_stmt_list and not adding in 
the line table offset in the inline comments and this is good to go.




Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:893-896
+  const dw_offset_t cu_line_offset = dwarf_cu_die.GetAttributeValueAsUnsigned(
+  DW_AT_stmt_list, DW_INVALID_OFFSET);
+  if (cu_line_offset == DW_INVALID_OFFSET)
+return false;

DWARFContext::getLineTableForUnit() in 
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp grabs the DW_AT_stmt_list like this:

```
  auto Offset = toSectionOffset(UnitDIE.find(DW_AT_stmt_list));
  if (!Offset)
return false; // No line table for this compile unit.

  uint64_t stmtOffset = *Offset + U->getLineTableOffset();
```
Modifying this a bit would be a good idea to make sure we are compatible with 
all DWARF. Or we can put a function into DWARFUnit that does this correctly and 
switch DWARFContext::getLineTableForUnit() and our code over to use it to avoid 
duplicated code. 


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

https://reviews.llvm.org/D81589



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


[Lldb-commits] [PATCH] D81200: [vscode] set default values for terminateDebuggee for the disconnect request

2020-06-10 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 270038.
wallace added a comment.

I updated the tests and did some minor changes.

@clayborg, after some testing, I noticed that this doesn't fix the problem of 
lldb-vscode instances not dying, however it solves the problem
of long-running inferiors not dying. Both are issues anyway.

I'll send another patch fixing the first problem, but at least this solves the 
second one.

Btw, I mentioned before that even after detaching, lldb-vscode was capturing 
some output by the inferior, however this is fine. 
lldb-vscode captures just some of the inferior's output in its even loop until 
it gets the eBroadcastBitStopEventThread event, 
after that lldb-vscode dies normally. So this diff should be fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81200

Files:
  lldb/test/API/tools/lldb-vscode/disconnect/Makefile
  lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py
  lldb/test/API/tools/lldb-vscode/disconnect/main.cpp
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -514,6 +514,7 @@
 //   }]
 // }
 void request_attach(const llvm::json::Object &request) {
+  g_vsc.is_attach = true;
   llvm::json::Object response;
   lldb::SBError error;
   FillResponse(request, response);
@@ -769,7 +770,9 @@
   FillResponse(request, response);
   auto arguments = request.getObject("arguments");
 
-  bool terminateDebuggee = GetBoolean(arguments, "terminateDebuggee", false);
+  bool defaultTerminateDebuggee = g_vsc.is_attach ? false : true;
+  bool terminateDebuggee =
+  GetBoolean(arguments, "terminateDebuggee", defaultTerminateDebuggee);
   lldb::SBProcess process = g_vsc.target.GetProcess();
   auto state = process.GetState();
 
@@ -788,10 +791,9 @@
   case lldb::eStateStopped:
   case lldb::eStateRunning:
 g_vsc.debugger.SetAsync(false);
-if (terminateDebuggee)
-  process.Kill();
-else
-  process.Detach();
+lldb::SBError error = terminateDebuggee ? process.Kill() : process.Detach();
+if (!error.Success())
+  response.try_emplace("error", error.GetCString());
 g_vsc.debugger.SetAsync(true);
 break;
   }
@@ -1357,6 +1359,7 @@
 //   }]
 // }
 void request_launch(const llvm::json::Object &request) {
+  g_vsc.is_attach = false;
   llvm::json::Object response;
   lldb::SBError error;
   FillResponse(request, response);
Index: lldb/tools/lldb-vscode/VSCode.h
===
--- lldb/tools/lldb-vscode/VSCode.h
+++ lldb/tools/lldb-vscode/VSCode.h
@@ -89,6 +89,7 @@
   lldb::tid_t focus_tid;
   bool sent_terminated_event;
   bool stop_at_entry;
+  bool is_attach;
   // Keep track of the last stop thread index IDs as threads won't go away
   // unless we send a "thread" event to indicate the thread exited.
   llvm::DenseSet thread_ids;
Index: lldb/tools/lldb-vscode/VSCode.cpp
===
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -38,7 +38,7 @@
{"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
{"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
   focus_tid(LLDB_INVALID_THREAD_ID), sent_terminated_event(false),
-  stop_at_entry(false) {
+  stop_at_entry(false), is_attach(false) {
   const char *log_file_path = getenv("LLDBVSCODE_LOG");
 #if defined(_WIN32)
 // Windows opens stdout and stdin in text mode which converts \n to 13,10
Index: lldb/test/API/tools/lldb-vscode/disconnect/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/disconnect/main.cpp
@@ -0,0 +1,33 @@
+#include 
+#include 
+
+void print(int x) {
+  printf("%d\n", x); // breakpoint
+}
+
+void handle_launch() {
+  print(0);
+}
+
+void handle_attach(char *sync_file_path) {
+  lldb_enable_attach();
+
+  {
+// Create a file to signal that this process has started up.
+std::ofstream sync_file;
+sync_file.open(sync_file_path);
+  }
+
+  // We wait for some input in order to proceed
+  int x;
+  scanf("%d", &x);
+  print(x);
+}
+
+int main(int argc, char **args) {
+  if (argc == 1)
+handle_launch();
+  else
+handle_attach(args[1]);
+  return 0;
+}
Index: lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py
@@ -0,0 +1,80 @@
+"""
+Test lldb-vscode disconnect request
+"""
+
+
+import unittest2
+import vscode
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+f