[Lldb-commits] [lldb] b5e49e9 - [lldb] Ignore certain Clang type sugar when creating the type name

2020-09-22 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-09-22T13:37:20+02:00
New Revision: b5e49e91cb90eda1f926139c8567e27f1b664cc1

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

LOG: [lldb] Ignore certain Clang type sugar when creating the type name

Clang has some type sugar that only serves as a way to preserve the way a user
has typed a certain type in the source code. These types are currently not
unwrapped when we query the type name for a Clang type, which means that this
type sugar actually influences what formatters are picked for a certain type.
Currently if a user decides to reference a type by doing `::GlobalDecl Var = 
3;`,
the type formatter for `GlobalDecl` will not be used (as the type sugar
around the type gives it the name `::GlobalDecl`. The same goes for other ways
to spell out a type such as `auto` etc.

With this patch most of this type sugar gets stripped when the full type name is
calculated. Typedefs are not getting desugared as that seems counterproductive.
I also don't desugar atomic types as that's technically not type sugar.

Reviewed By: jarin

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

Added: 
lldb/test/API/lang/cpp/elaborated-types/Makefile
lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
lldb/test/API/lang/cpp/elaborated-types/main.cpp

Modified: 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index d80d07574073..ee6fc895d585 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3639,6 +3639,16 @@ ConstString 
TypeSystemClang::GetTypeName(lldb::opaque_compiler_type_t type) {
 
   clang::QualType qual_type(GetQualType(type));
 
+  // Remove certain type sugar from the name. Sugar such as elaborated types
+  // or template types which only serve to improve diagnostics shouldn't
+  // act as their own types from the user's perspective (e.g., formatter
+  // shouldn't format a variable 
diff erently depending on how the ser has
+  // specified the type. '::Type' and 'Type' should behave the same).
+  // Typedefs and atomic derived types are not removed as they are actually
+  // useful for identifiying specific types.
+  qual_type = RemoveWrappingTypes(qual_type,
+  {clang::Type::Typedef, clang::Type::Atomic});
+
   // For a typedef just return the qualified name.
   if (const auto *typedef_type = qual_type->getAs()) {
 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();

diff  --git a/lldb/test/API/lang/cpp/elaborated-types/Makefile 
b/lldb/test/API/lang/cpp/elaborated-types/Makefile
new file mode 100644
index ..8b20bcb0
--- /dev/null
+++ b/lldb/test/API/lang/cpp/elaborated-types/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

diff  --git a/lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py 
b/lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
new file mode 100644
index ..395ba30b5454
--- /dev/null
+++ b/lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
@@ -0,0 +1,40 @@
+"""
+Test elaborated types (e.g. Clang's ElaboratedType or TemplateType sugar).
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@no_debug_info_test
+def test(self):
+self.build()
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+# Add a type formatter for 'Struct'.
+self.expect("type summary add Struct --summary-string '(summary 
x=${var.x})'")
+# Check that creating an expr with an elaborated type ('::Struct')
+# triggers our formatter for 'Struct' while keeping the elaborated type
+# as the display type.
+result = self.expect_expr("::Struct s; s.x = 4; s",
+  result_type="::Struct",
+  result_summary="(summary x=4)")
+# Test that a plain elaborated type is only in the display type name 
but
+# not in the full type name.
+self.assertEqual(result.GetTypeName(), "Struct")
+
+# Test the same for template types (that also only act as sugar to 
better
+# show how the template was specified by the user).
+
+# Declare a template that can actually be instantiated.
+# FIXME: The error message here is incorrect.
+self.expect("expr --top-level -- template struct $V {};",
+error=True, substrs=["Couldn't fin

[Lldb-commits] [PATCH] D87481: [lldb] Ignore certain Clang type sugar when creating the type name

2020-09-22 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb5e49e91cb90: [lldb] Ignore certain Clang type sugar when 
creating the type name (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/D87481/new/

https://reviews.llvm.org/D87481

Files:
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/test/API/lang/cpp/elaborated-types/Makefile
  lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
  lldb/test/API/lang/cpp/elaborated-types/main.cpp


Index: lldb/test/API/lang/cpp/elaborated-types/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/elaborated-types/main.cpp
@@ -0,0 +1,9 @@
+struct Struct {
+  int x;
+};
+
+int main() {
+  Struct use;
+  use.x = 3;
+  return use.x; // break here
+}
Index: lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
@@ -0,0 +1,40 @@
+"""
+Test elaborated types (e.g. Clang's ElaboratedType or TemplateType sugar).
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@no_debug_info_test
+def test(self):
+self.build()
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+# Add a type formatter for 'Struct'.
+self.expect("type summary add Struct --summary-string '(summary 
x=${var.x})'")
+# Check that creating an expr with an elaborated type ('::Struct')
+# triggers our formatter for 'Struct' while keeping the elaborated type
+# as the display type.
+result = self.expect_expr("::Struct s; s.x = 4; s",
+  result_type="::Struct",
+  result_summary="(summary x=4)")
+# Test that a plain elaborated type is only in the display type name 
but
+# not in the full type name.
+self.assertEqual(result.GetTypeName(), "Struct")
+
+# Test the same for template types (that also only act as sugar to 
better
+# show how the template was specified by the user).
+
+# Declare a template that can actually be instantiated.
+# FIXME: The error message here is incorrect.
+self.expect("expr --top-level -- template struct $V {};",
+error=True, substrs=["Couldn't find $__lldb_expr() in the 
module"])
+result = self.expect_expr("$V<::Struct> s; s",
+  result_type="$V< ::Struct>")
+self.assertEqual(result.GetTypeName(), "$V")
Index: lldb/test/API/lang/cpp/elaborated-types/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/elaborated-types/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3639,6 +3639,16 @@
 
   clang::QualType qual_type(GetQualType(type));
 
+  // Remove certain type sugar from the name. Sugar such as elaborated types
+  // or template types which only serve to improve diagnostics shouldn't
+  // act as their own types from the user's perspective (e.g., formatter
+  // shouldn't format a variable differently depending on how the ser has
+  // specified the type. '::Type' and 'Type' should behave the same).
+  // Typedefs and atomic derived types are not removed as they are actually
+  // useful for identifiying specific types.
+  qual_type = RemoveWrappingTypes(qual_type,
+  {clang::Type::Typedef, clang::Type::Atomic});
+
   // For a typedef just return the qualified name.
   if (const auto *typedef_type = qual_type->getAs()) {
 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();


Index: lldb/test/API/lang/cpp/elaborated-types/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/elaborated-types/main.cpp
@@ -0,0 +1,9 @@
+struct Struct {
+  int x;
+};
+
+int main() {
+  Struct use;
+  use.x = 3;
+  return use.x; // break here
+}
Index: lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
@@ -0,0 +1,40 @@
+"""
+Test elaborated types (e.g. Clang's ElaboratedType or TemplateType sugar).
+"""
+
+import lldb
+from lldbsuite.test.decorator

[Lldb-commits] [PATCH] D88099: [lldb] Fix GetRemoteSharedModule fallback logic

2020-09-22 Thread Joseph Tremoulet via Phabricator via lldb-commits
JosephTremoulet created this revision.
Herald added a reviewer: JDevlieghere.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
JosephTremoulet requested review of this revision.

When the various methods of locating the module in GetRemoteSharedModule
fail, make sure we pass the original module spec to the bail-out call to
the provided resolver function.

Also make sure we consistently use the resolved module spec from the
various success paths.

Thanks to what appears to have been an accidentally inverted condition
(commit 85967fa applied the new condition to a path where GetModuleSpec
returns false, but should have applied it when GetModuleSpec returns
true), without this fix we only pass the original module spec in the
fallback if the original spec has no uuid (or has a uuid that somehow
matches the resolved module's uuid despite the call to GetModuleSpec
failing).  This manifested as a bug when processing a minidump file with
a user-provided sysroot, since in that case the resolver call was being
applied to resolved_module_spec (despite resolution failing), which did
not have the path of its file_spec set.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88099

Files:
  lldb/source/Target/Platform.cpp
  lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py


Index: lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -455,3 +455,29 @@
 check_region(17, 0x40169000, 0x4016b000, True,  True,  False, True,  d)
 check_region(18, 0x4016b000, 0x40176000, True,  True,  False, True,  n)
 check_region(-1, 0x40176000, max_int,False, False, False, False, n)
+
+@skipIfLLVMTargetMissing("X86")
+def test_minidump_sysroot(self):
+"""Test that lldb can find a module referenced in an i386 linux 
minidump using the sysroot."""
+
+# Copy linux-x86_64 executable to tmp_sysroot/temp/test/ (since it was 
compiled as
+# /tmp/test/linux-x86_64)
+tmp_sysroot = os.path.join(
+self.getBuildDir(), "lldb_i386_mock_sysroot")
+executable = os.path.join(
+tmp_sysroot, "tmp", "test", "linux-x86_64")
+exe_dir = os.path.dirname(executable)
+lldbutil.mkdir_p(exe_dir)
+shutil.copyfile("linux-x86_64", executable)
+
+# Set sysroot and load core
+self.runCmd("platform select remote-linux --sysroot '%s'" %
+tmp_sysroot)
+self.process_from_yaml("linux-x86_64.yaml")
+self.check_state()
+
+# Check that we loaded the module from the sysroot
+self.assertEqual(self.target.GetNumModules(), 1)
+module = self.target.GetModuleAtIndex(0)
+spec = module.GetFileSpec()
+self.assertEqual(spec.GetDirectory(), exe_dir)
Index: lldb/source/Target/Platform.cpp
===
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -1580,21 +1580,29 @@
   if (error.Success() && module_sp)
 break;
 }
-if (module_sp)
+if (module_sp) {
+  resolved_module_spec = arch_module_spec;
   got_module_spec = true;
+}
   }
 
   if (!got_module_spec) {
 // Get module information from a target.
-if (!GetModuleSpec(module_spec.GetFileSpec(), 
module_spec.GetArchitecture(),
-   resolved_module_spec)) {
+if (GetModuleSpec(module_spec.GetFileSpec(), module_spec.GetArchitecture(),
+  resolved_module_spec)) {
   if (!module_spec.GetUUID().IsValid() ||
   module_spec.GetUUID() == resolved_module_spec.GetUUID()) {
-return module_resolver(module_spec);
+got_module_spec = true;
   }
 }
   }
 
+  if (!got_module_spec) {
+// Fall back to the given module resolver, which may have its own
+// search logic.
+return module_resolver(module_spec);
+  }
+
   // If we are looking for a specific UUID, make sure resolved_module_spec has
   // the same one before we search.
   if (module_spec.GetUUID().IsValid()) {


Index: lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -455,3 +455,29 @@
 check_region(17, 0x40169000, 0x4016b000, True,  True,  False, True,  d)
 check_region(18, 0x4016b000, 0x40176000, True,  True,  False, True,  n)
 check_region(-1, 0x40176000, max_int,False, False, False, False, n)
+
+@skipIfLLVMTargetMissing("X86")
+def test_minidump_sysroot(self):
+"""Test that lldb can find a mod

[Lldb-commits] [PATCH] D88099: [lldb] Fix GetRemoteSharedModule fallback logic

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88099

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


[Lldb-commits] [lldb] 783dc7d - [lldb] Skip TestMiniDumpUUID with reproducers

2020-09-22 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-09-22T11:28:39-07:00
New Revision: 783dc7dc7ed7487d0782c2feb8854df949b98e69

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

LOG: [lldb] Skip TestMiniDumpUUID with reproducers

The modules not getting orphaned is wreaking havoc when the UUIDs match
between tests.

Added: 


Modified: 
lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py 
b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
index c4dcddba631b..052fcaebfdd0 100644
--- a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
+++ b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
@@ -12,6 +12,7 @@
 from lldbsuite.test import lldbutil
 
 
+@skipIfReproducer # Modules are not orphaned and it finds the module with the 
same UUID from test_partial_uuid_match.
 class MiniDumpUUIDTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
@@ -213,6 +214,7 @@ def test_breakpad_overflow_hash_match(self):
 cmd = 'settings set target.exec-search-paths "%s"' % 
(os.path.dirname(so_path))
 self.dbg.HandleCommand(cmd)
 modules = 
self.get_minidump_modules("linux-arm-breakpad-uuid-match.yaml")
+import pdb; pdb.set_trace()
 self.assertEqual(1, len(modules))
 # LLDB makes up it own UUID as well when there is no build ID so we
 # will check that this matches.
@@ -315,7 +317,6 @@ def test_add_module_build_id_4(self):
 "a", "", "01020304-0506-0708-090A-0B0C0D0E0F10").IsValid())
 self.assertFalse(self.target.AddModule("a", "", "01020305").IsValid())
 
-@skipIfReproducer # Modules are not orphaned and it finds the module with 
the same UUID from test_partial_uuid_match.
 def test_remove_placeholder_add_real_module(self):
 """
 Test that removing a placeholder module and adding back the real



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


[Lldb-commits] [lldb] 8457ae0 - [lldb] Skip test_common_completion_process_pid_and_name with reproducers

2020-09-22 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-09-22T11:28:39-07:00
New Revision: 8457ae0d9359590b2db1e8e090531197be4d62c6

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

LOG: [lldb] Skip test_common_completion_process_pid_and_name with reproducers

This test launches a subprocess which will have a different PID during
capture and replay.

Added: 


Modified: 
lldb/test/API/functionalities/completion/TestCompletion.py

Removed: 




diff  --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index 4e78b6e23730..4061e0963d48 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -131,6 +131,7 @@ def completions_contain_str(self, input, needle):
 
 
 @skipIfRemote
+@skipIfReproducer
 def test_common_completion_process_pid_and_name(self):
 # The LLDB process itself and the process already attached to are both
 # ignored by the process discovery mechanism, thus we need a process 
known



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


[Lldb-commits] [PATCH] D86416: [lldb] -stdlib=libc++ for linking with lldb lib also if LLVM_ENABLE_LIBCXX

2020-09-22 Thread Luboš Luňák via Phabricator via lldb-commits
llunak added a comment.

In D86416#2286333 , @JDevlieghere 
wrote:

> Which tests are affected by this?

I don't know. There are 5 hits for 'buildDriver' and 8 for '%include_SB_APIs%' 
under tests/, so at least 13, but I don't know if that's all.

> How much work would it be to convert them as suggested?

I don't know either. I don't plan on doing that, at least not now. My patch is 
a fix and it's done. The suggestion is an improvement. surely it can be done 
after the fix.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D86416

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


[Lldb-commits] [lldb] ef7d22a - Revert "[lldb] XFAIL TestMemoryHistory on Linux"

2020-09-22 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-09-22T21:13:44+02:00
New Revision: ef7d22a98683ce98b6a2c4d0818d2d9978d42861

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

LOG: Revert "[lldb] XFAIL TestMemoryHistory on Linux"

This reverts commit 7518006d75accd21325747430d6bced66b2c5ada.

This test apparently works on the Swift CI ubuntu bot, so it shouldn't be
XFAIL'd on Linux.

Added: 


Modified: 
lldb/test/API/functionalities/asan/TestMemoryHistory.py

Removed: 




diff  --git a/lldb/test/API/functionalities/asan/TestMemoryHistory.py 
b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
index 0b8dc20f27c5..37c34984f43b 100644
--- a/lldb/test/API/functionalities/asan/TestMemoryHistory.py
+++ b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
@@ -15,9 +15,6 @@ class AsanTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
-@expectedFailureAll(
-oslist=["linux"],
-bugnumber="non-core functionality, need to reenable and fix later (DES 
2014.11.07)")
 @skipIfFreeBSD  # llvm.org/pr21136 runtimes not yet available by default
 @expectedFailureNetBSD
 @skipUnlessAddressSanitizer



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


[Lldb-commits] [lldb] f212122 - [lldb][test] Remove accidental import pdb in 783dc7dc7ed7487d0782c2feb8854df949b98e69

2020-09-22 Thread Fangrui Song via lldb-commits

Author: Fangrui Song
Date: 2020-09-22T13:08:12-07:00
New Revision: f21212215031e5871c38daf3b06b1a6250fd

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

LOG: [lldb][test] Remove accidental import pdb in 
783dc7dc7ed7487d0782c2feb8854df949b98e69

Added: 


Modified: 
lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py 
b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
index 052fcaebfdd0..1dc2c81485d0 100644
--- a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
+++ b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
@@ -214,7 +214,6 @@ def test_breakpad_overflow_hash_match(self):
 cmd = 'settings set target.exec-search-paths "%s"' % 
(os.path.dirname(so_path))
 self.dbg.HandleCommand(cmd)
 modules = 
self.get_minidump_modules("linux-arm-breakpad-uuid-match.yaml")
-import pdb; pdb.set_trace()
 self.assertEqual(1, len(modules))
 # LLDB makes up it own UUID as well when there is no build ID so we
 # will check that this matches.



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


[Lldb-commits] [PATCH] D87765: [llvm][lldb] Add optimal ThreadPool concurrency

2020-09-22 Thread Alexandre Ganea via Phabricator via lldb-commits
aganea added a comment.

@dmantipov Do you have commit access (which I can encourage you ask here 
 if you're 
planning further changes) or should I commit this for you?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87765

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


[Lldb-commits] [lldb] ed621e7 - [trace] avoid using

2020-09-22 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2020-09-22T16:08:58-07:00
New Revision: ed621e76a9889e25a9cbed47e0b96a7a6fdbdb80

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

LOG: [trace] avoid using 

Easy fix based on the feedback by maskray on
https://reviews.llvm.org/D85705.

Added: 


Modified: 
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSettingsParser.cpp
lldb/source/Target/TraceSettingsParser.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSettingsParser.cpp 
b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSettingsParser.cpp
index c8f90c9a978d..2430f779d956 100644
--- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSettingsParser.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSettingsParser.cpp
@@ -14,14 +14,14 @@ using namespace llvm;
 
 StringRef TraceIntelPTSettingsParser::GetPluginSchema() {
   return R"({
-  "type": "intel-pt",
-  "pt_cpu": {
-"vendor": "intel" | "unknown",
-"family": integer,
-"model": integer,
-"stepping": integer
-  }
-})";
+"type": "intel-pt",
+"pt_cpu": {
+  "vendor": "intel" | "unknown",
+  "family": integer,
+  "model": integer,
+  "stepping": integer
+}
+  })";
 }
 
 llvm::Error TraceIntelPTSettingsParser::ParsePTCPU(const json::Object &trace) {

diff  --git a/lldb/source/Target/TraceSettingsParser.cpp 
b/lldb/source/Target/TraceSettingsParser.cpp
index 2c0f337ee9a1..9021d93e17e0 100644
--- a/lldb/source/Target/TraceSettingsParser.cpp
+++ b/lldb/source/Target/TraceSettingsParser.cpp
@@ -8,7 +8,6 @@
 
 #include "lldb/Target/TraceSettingsParser.h"
 
-#include 
 #include 
 
 #include "Plugins/Process/Utility/HistoryThread.h"
@@ -123,12 +122,7 @@ StringRef TraceSettingsParser::GetSchema() {
   if (schema.empty()) {
 std::ostringstream schema_builder;
 schema_builder << "{\n \"trace\": ";
-
-// We need to add spaces to indent correctly the plugin schema
-std::string plugin_schema(GetPluginSchema());
-plugin_schema = std::regex_replace(plugin_schema, std::regex("\n"), "\n  
");
-schema_builder << plugin_schema << ",\n";
-
+schema_builder << GetPluginSchema().str() << ",\n";
 schema_builder << R"(  "processes": [
 {
   "pid": integer,



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


[Lldb-commits] [PATCH] D88119: [lldb] Remove lldb-perf remenant

2020-09-22 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added a reviewer: JDevlieghere.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
kastiglione requested review of this revision.

Delete a file remaining from the deletion of lldb-perf in D64362 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88119

Files:
  lldb/tools/lldb-perf/darwin/sketch/foobar.sketch2




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


[Lldb-commits] [PATCH] D88123: Add the ability to write 'target stop-hooks' in Python

2020-09-22 Thread Jim Ingham via Phabricator via lldb-commits
jingham created this revision.
jingham added a reviewer: JDevlieghere.
Herald added subscribers: lldb-commits, dang.
Herald added a project: LLDB.
jingham requested review of this revision.

Previously, you could only have a list of command-line commands as the reaction 
to a stop hook.

This patch adds the ability to define the stop hooks directly in Python, which 
allows you to do logging and add logic to the stop hook more easily.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88123

Files:
  lldb/bindings/python/python-swigsafecast.swig
  lldb/bindings/python/python-wrapper.swig
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/include/lldb/Symbol/SymbolContext.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Commands/Options.td
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
  lldb/source/Symbol/SymbolContext.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
  lldb/test/API/commands/target/stop-hooks/TestStopHooks.py
  lldb/test/API/commands/target/stop-hooks/main.c
  lldb/test/API/commands/target/stop-hooks/stop_hook.py
  lldb/test/Shell/Commands/Inputs/stop_hook.py
  lldb/test/Shell/Commands/command-stop-hook-output.test
  lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Index: lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
===
--- lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -254,3 +254,17 @@
  const lldb::TargetSP &target_sp) {
   return nullptr;
 }
+
+extern "C" void *LLDBSwigPythonCreateScriptedStopHook(
+lldb::TargetSP target_sp, const char *python_class_name,
+const char *session_dictionary_name,
+lldb_private::StructuredDataImpl *args_impl, Status &error) {
+  return nullptr;
+}
+
+extern "C" bool
+LLDBSwigPythonStopHookCallHandleStop(void *implementor,
+ lldb::ExecutionContextRefSP exc_ctx_sp,
+ lldb::StreamSP stream) {
+  return false;
+}
Index: lldb/test/Shell/Commands/command-stop-hook-output.test
===
--- /dev/null
+++ lldb/test/Shell/Commands/command-stop-hook-output.test
@@ -0,0 +1,18 @@
+# RUN: %clang_host -g %S/Inputs/main.c -o %t
+# RUN: %lldb %t -O 'command script import %S/Inputs/stop_hook.py' -s %s -o exit | FileCheck %s
+
+b main
+# CHECK-LABEL: b main
+# CHECK: Breakpoint 1: where = {{.*}}`main
+
+target stop-hook add -P stop_hook.stop_handler
+# CHECK-LABEL: target stop-hook add -P stop_hook.stop_handler
+# CHECK: Stop hook #1 added.
+
+run
+# CHECK-LABEL: run
+# CHECK: I did indeed run
+# CHECK: Process {{.*}} stopped
+# CHECK: stop reason = breakpoint 1
+# CHECK:   frame #0: {{.*}}`main at main.c
+
Index: lldb/test/Shell/Commands/Inputs/stop_hook.py
===
--- /dev/null
+++ lldb/test/Shell/Commands/Inputs/stop_hook.py
@@ -0,0 +1,10 @@
+import lldb
+
+class stop_handler:
+def __init__(self, target, extra_args, dict):
+self.extra_args = extra_args
+self.target = target
+
+def handle_stop(self, exe_ctx, stream):
+stream.Print("I did indeed run\n")
+return True
Index: lldb/test/API/commands/target/stop-hooks/stop_hook.py
===
--- /dev/null
+++ lldb/test/API/commands/target/stop-hooks/stop_hook.py
@@ -0,0 +1,34 @@
+import lldb
+
+class stop_handler:
+def __init__(self, target, extra_args, dict):
+self.extra_args = extra_args
+self.target = target
+self.counter = 0
+ret_val = self.extra_args.GetValueForKey("return_false")
+if ret_val:
+self.ret_val = False
+else:
+self.ret_val = True
+
+def handle_stop(self, exe_ctx, stream):
+self.counter += 1
+stream.Print("I have stopped %d times.\n"%(self.counter))
+increment = 1
+value = self.extra_args.GetValueForKey("increment")
+if value:
+incr_as_str = value.GetStringValue(100)
+increment = int(incr_as_str)
+else:
+stream.Print("Could not find increment in extra_args\n")
+frame = exe_ctx.GetFrame()
+expression = "g_var += %d"%(increment)
+expr_result = frame.EvaluateExpression(expression)
+if not expr_result.GetError().Success():
+stream.Print("Error running expression: %s"%(expr_result.GetError().GetCString()))
+value = exe_ctx.target.FindFirstGlobalVariable("g_var")
+if not value.IsValid():
+stream.Print("Didn't get a valid value for g_var.")
+else:
+   

[Lldb-commits] [PATCH] D88123: Add the ability to write 'target stop-hooks' in Python

2020-09-22 Thread Jim Ingham via Phabricator via lldb-commits
jingham updated this revision to Diff 293603.
jingham added a comment.

Added docs to the python-reference.rst


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88123

Files:
  lldb/bindings/python/python-swigsafecast.swig
  lldb/bindings/python/python-wrapper.swig
  lldb/docs/use/python-reference.rst
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/include/lldb/Symbol/SymbolContext.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Commands/Options.td
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
  lldb/source/Symbol/SymbolContext.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
  lldb/test/API/commands/target/stop-hooks/TestStopHooks.py
  lldb/test/API/commands/target/stop-hooks/main.c
  lldb/test/API/commands/target/stop-hooks/stop_hook.py
  lldb/test/Shell/Commands/Inputs/stop_hook.py
  lldb/test/Shell/Commands/command-stop-hook-output.test
  lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Index: lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
===
--- lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -254,3 +254,17 @@
  const lldb::TargetSP &target_sp) {
   return nullptr;
 }
+
+extern "C" void *LLDBSwigPythonCreateScriptedStopHook(
+lldb::TargetSP target_sp, const char *python_class_name,
+const char *session_dictionary_name,
+lldb_private::StructuredDataImpl *args_impl, Status &error) {
+  return nullptr;
+}
+
+extern "C" bool
+LLDBSwigPythonStopHookCallHandleStop(void *implementor,
+ lldb::ExecutionContextRefSP exc_ctx_sp,
+ lldb::StreamSP stream) {
+  return false;
+}
Index: lldb/test/Shell/Commands/command-stop-hook-output.test
===
--- /dev/null
+++ lldb/test/Shell/Commands/command-stop-hook-output.test
@@ -0,0 +1,18 @@
+# RUN: %clang_host -g %S/Inputs/main.c -o %t
+# RUN: %lldb %t -O 'command script import %S/Inputs/stop_hook.py' -s %s -o exit | FileCheck %s
+
+b main
+# CHECK-LABEL: b main
+# CHECK: Breakpoint 1: where = {{.*}}`main
+
+target stop-hook add -P stop_hook.stop_handler
+# CHECK-LABEL: target stop-hook add -P stop_hook.stop_handler
+# CHECK: Stop hook #1 added.
+
+run
+# CHECK-LABEL: run
+# CHECK: I did indeed run
+# CHECK: Process {{.*}} stopped
+# CHECK: stop reason = breakpoint 1
+# CHECK:   frame #0: {{.*}}`main at main.c
+
Index: lldb/test/Shell/Commands/Inputs/stop_hook.py
===
--- /dev/null
+++ lldb/test/Shell/Commands/Inputs/stop_hook.py
@@ -0,0 +1,10 @@
+import lldb
+
+class stop_handler:
+def __init__(self, target, extra_args, dict):
+self.extra_args = extra_args
+self.target = target
+
+def handle_stop(self, exe_ctx, stream):
+stream.Print("I did indeed run\n")
+return True
Index: lldb/test/API/commands/target/stop-hooks/stop_hook.py
===
--- /dev/null
+++ lldb/test/API/commands/target/stop-hooks/stop_hook.py
@@ -0,0 +1,34 @@
+import lldb
+
+class stop_handler:
+def __init__(self, target, extra_args, dict):
+self.extra_args = extra_args
+self.target = target
+self.counter = 0
+ret_val = self.extra_args.GetValueForKey("return_false")
+if ret_val:
+self.ret_val = False
+else:
+self.ret_val = True
+
+def handle_stop(self, exe_ctx, stream):
+self.counter += 1
+stream.Print("I have stopped %d times.\n"%(self.counter))
+increment = 1
+value = self.extra_args.GetValueForKey("increment")
+if value:
+incr_as_str = value.GetStringValue(100)
+increment = int(incr_as_str)
+else:
+stream.Print("Could not find increment in extra_args\n")
+frame = exe_ctx.GetFrame()
+expression = "g_var += %d"%(increment)
+expr_result = frame.EvaluateExpression(expression)
+if not expr_result.GetError().Success():
+stream.Print("Error running expression: %s"%(expr_result.GetError().GetCString()))
+value = exe_ctx.target.FindFirstGlobalVariable("g_var")
+if not value.IsValid():
+stream.Print("Didn't get a valid value for g_var.")
+else:
+int_val = value.GetValueAsUnsigned()
+return self.ret_val
Index: lldb/test/API/commands/target/stop-hooks/main.c
===
--- lldb/test/API/commands/target/

[Lldb-commits] [PATCH] D88123: Add the ability to write 'target stop-hooks' in Python

2020-09-22 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added inline comments.



Comment at: lldb/source/Commands/CommandObjectTarget.cpp:4625
+  
+def__init__(self, target, extra_args, dict):
+

missing space after `def`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88123

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


[Lldb-commits] [PATCH] D88129: Add "break delete --disabled" to delete all currently disabled breakpoints

2020-09-22 Thread Jim Ingham via Phabricator via lldb-commits
jingham created this revision.
Herald added subscribers: lldb-commits, dang.
Herald added a reviewer: JDevlieghere.
Herald added a project: LLDB.
jingham requested review of this revision.

Sometimes in a debug session you set a whole bunch of breakpoints and gradually 
disable the ones that aren't helpful.  At some point you want to clean up the 
breakpoint state before continuing, and getting rid of all those disabled 
breakpoints at one blow is a handy tool to have.

This patch adds "break delete --disabled" that deletes all the currently 
disabled breakpoints.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88129

Files:
  lldb/source/Commands/CommandObjectBreakpoint.cpp
  lldb/source/Commands/Options.td
  
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py

Index: lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
===
--- lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
+++ lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
@@ -287,3 +287,32 @@
 self.assertEqual(com_list.GetStringAtIndex(0), "bt", "First bt")
 self.assertEqual(com_list.GetStringAtIndex(1), "thread list", "Next thread list")
 self.assertEqual(com_list.GetStringAtIndex(2), "continue", "Last continue")
+
+def test_breakpoint_delete_disabled(self):
+"""Test 'break delete --disabled' works"""
+self.build()
+exe = self.getBuildArtifact("a.out")
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target.IsValid(), "Created an invalid target.")
+
+bp_1 = target.BreakpointCreateByName("main")
+bp_2 = target.BreakpointCreateByName("not_here")
+bp_3 = target.BreakpointCreateByName("main")
+
+bp_1.SetEnabled(False)
+bp_3.SetEnabled(False)
+
+bp_id_1 = bp_1.GetID()
+bp_id_2 = bp_2.GetID()
+bp_id_3 = bp_3.GetID()
+
+self.runCmd("breakpoint delete --disabled")
+
+bp_1 = target.FindBreakpointByID(bp_id_1)
+self.assertFalse(bp_1.IsValid(), "Didn't delete disabled breakpoint 1")
+
+bp_2 = target.FindBreakpointByID(bp_id_2)
+self.assertTrue(bp_2.IsValid(), "Deleted enabled breakpoint 2")
+
+bp_3 = target.FindBreakpointByID(bp_id_3)
+self.assertFalse(bp_3.IsValid(), "Didn't delete disabled breakpoint 3")
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -227,6 +227,8 @@
   def breakpoint_delete_dummy_breakpoints : Option<"dummy-breakpoints", "D">,
 Group<1>, Desc<"Delete Dummy breakpoints - i.e. breakpoints set before a "
 "file is provided, which prime new targets.">;
+  def breakpoint_delete_disabled : Option<"disabled", "d">, Group<1>,
+Desc<"Delete all breakpoints which are currently disabled.">;
 }
 
 let Command = "breakpoint name" in {
Index: lldb/source/Commands/CommandObjectBreakpoint.cpp
===
--- lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -1423,7 +1423,8 @@
 
   class CommandOptions : public Options {
   public:
-CommandOptions() : Options(), m_use_dummy(false), m_force(false) {}
+CommandOptions() : Options(), m_use_dummy(false), m_force(false),
+  m_delete_disabled(false) {}
 
 ~CommandOptions() override = default;
 
@@ -1440,6 +1441,10 @@
   case 'D':
 m_use_dummy = true;
 break;
+
+  case 'd':
+m_delete_disabled = true;
+break;
 
   default:
 llvm_unreachable("Unimplemented option");
@@ -1451,6 +1456,7 @@
 void OptionParsingStarting(ExecutionContext *execution_context) override {
   m_use_dummy = false;
   m_force = false;
+  m_delete_disabled = false;
 }
 
 llvm::ArrayRef GetDefinitions() override {
@@ -1460,16 +1466,18 @@
 // Instance variables to hold the values for command options.
 bool m_use_dummy;
 bool m_force;
+bool m_delete_disabled;
   };
 
 protected:
   bool DoExecute(Args &command, CommandReturnObject &result) override {
 Target &target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
-
+result.Clear();
+
 std::unique_lock lock;
 target.GetBreakpointList().GetListMutex(lock);
 
-const BreakpointList &breakpoints = target.GetBreakpointList();
+BreakpointList &breakpoints = target.GetBreakpointList();
 
 size_t num_breakpoints = breakpoints.GetSize();
 
@@ -1479,7 +1487,7 @@
   return false;
 }
 
-if (command.empty()) {
+if (command.empty() && !m_options.m_delete_disabled) {
   if (!m_options.m_force &&
   !m_interpreter.Confirm(
   "About to delete all breakpoints, do