[Lldb-commits] [lldb] 08f4b56 - [lldb] Include unistd.h for sleep in profile_vrs_detach

2021-10-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-10-21T17:32:15-07:00
New Revision: 08f4b56fb9795b5d271378fb62c3fed67ab1b754

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

LOG: [lldb] Include unistd.h for sleep in profile_vrs_detach

Added: 


Modified: 
lldb/test/API/macosx/profile_vrs_detach/main.c

Removed: 




diff  --git a/lldb/test/API/macosx/profile_vrs_detach/main.c 
b/lldb/test/API/macosx/profile_vrs_detach/main.c
index 6bcd3342441b..939308414edc 100644
--- a/lldb/test/API/macosx/profile_vrs_detach/main.c
+++ b/lldb/test/API/macosx/profile_vrs_detach/main.c
@@ -1,10 +1,11 @@
 #include 
+#include 
 
 int
 main()
 {
   while (1) {
-sleep(1); // Set a breakpoint here 
+sleep(1); // Set a breakpoint here
 printf("I slept\n");
   }
   return 0;



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


[Lldb-commits] [lldb] 09b95b9 - [lldb] Always set the minimum OS version in the Darwin builder

2021-10-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-10-21T17:03:06-07:00
New Revision: 09b95b9dc9afb0c12e7d10faea17ed0cb6920b9f

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

LOG: [lldb] Always set the minimum OS version in the Darwin builder

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/builders/darwin.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/builders/darwin.py 
b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
index 7718fd4d91f4e..360533f7ad6ba 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/darwin.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
@@ -96,7 +96,7 @@ def getArchCFlags(self, arch):
 version_min = ""
 if env == "simulator":
 version_min = "-m{}-simulator-version-min={}".format(os, version)
-elif os == "macosx":
+else:
 version_min = "-m{}-version-min={}".format(os, version)
 
 return ["ARCH_CFLAGS=-target {} {}".format(triple, version_min)]



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


[Lldb-commits] [PATCH] D112279: Add modules stats into the "statistics dump" command.

2021-10-21 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

The new output looks like:

  (lldb) statistics dump
  {
"expressionEvaluation": {
  "failures": 0,
  "successes": 0
},
"firstStopTime": 0.3503082920002,
"frameVariable": {
  "failures": 0,
  "successes": 0
},
"launchOrAttachTime": 0.3296479580002,
"modules": [
  {
"path": "/Users/gclayton/Documents/src/args/build/a.out",
"symbolTableIndexTime": 1.375e-05,
"symbolTableParseTime": 0.000191375,
"triple": "arm64-apple-macosx11.0.0",
"uuid": "B7F60DCD-68BF-3F2D-AE27-85253725636A"
  },
  {
"path": "/usr/lib/dyld",
"symbolTableIndexTime": 0.0111239589,
"symbolTableParseTime": 0.00678362497,
"triple": "arm64e-apple-macosx11.6.0",
"uuid": "38657979-1ABE-3C9A-BF64-EF3B746216AB"
  },
  {
"path": "/usr/lib/libc++.1.dylib",
"symbolTableIndexTime": 0.0144244579,
"symbolTableParseTime": 0.00955133304,
"triple": "arm64e-apple-macosx11.6.0",
"uuid": "BED05B96-CCAE-365A-B3F5-F8D72F5E77E1"
  },
  ...
],
"targetCreateTime": 0.165567958,
"totalSymbolTableIndexTime": 0.0475319572,
"totalSymbolTableParseTime": 0.07381933300015
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112279

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


[Lldb-commits] [PATCH] D112279: Add modules stats into the "statistics dump" command.

2021-10-21 Thread Greg Clayton via Phabricator via lldb-commits
clayborg created this revision.
clayborg added reviewers: JDevlieghere, labath, wallace, aadsm, jdoerfert.
Herald added a subscriber: emaste.
clayborg requested review of this revision.
Herald added subscribers: lldb-commits, MaskRay.
Herald added a project: LLDB.

The new module stats adds the ability to measure the time it takes to parse and 
index the symbol tables for each module, and reports modules statistics in the 
output of "statistics dump" along with the path, UUID and triple of the module. 
The time it takes to parse and index the symbol tables are also aggregated into 
new top level key/value pairs at the target level.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112279

Files:
  lldb/include/lldb/Core/Module.h
  lldb/include/lldb/Target/Statistics.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Symbol/Symtab.cpp
  lldb/source/Target/Statistics.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/commands/statistics/basic/TestStats.py

Index: lldb/test/API/commands/statistics/basic/TestStats.py
===
--- lldb/test/API/commands/statistics/basic/TestStats.py
+++ lldb/test/API/commands/statistics/basic/TestStats.py
@@ -139,7 +139,10 @@
 keys_exist = [
 'expressionEvaluation',
 'frameVariable',
+'modules',
 'targetCreateTime',
+'totalSymbolTableParseTime',
+'totalSymbolTableIndexTime'
 ]
 keys_missing = [
 'firstStopTime',
@@ -181,9 +184,69 @@
 'firstStopTime',
 'frameVariable',
 'launchOrAttachTime',
+'modules',
 'targetCreateTime',
+'totalSymbolTableParseTime',
+'totalSymbolTableIndexTime'
 ]
 self.verify_keys(stats, '"stats"', keys_exist, None)
 self.assertGreater(stats['firstStopTime'], 0.0)
 self.assertGreater(stats['launchOrAttachTime'], 0.0)
 self.assertGreater(stats['targetCreateTime'], 0.0)
+
+def find_module_in_metrics(self, path, stats):
+modules = stats['modules']
+for module in modules:
+if module['path'] == path:
+return module
+return None
+
+def test_modules(self):
+"""Test "statistics dump --modules"
+
+Output expected to be something like:
+
+(lldb) statistics dump --modules
+{
+  "targetCreateTime": 0.265668995,
+  "totalSymbolTableIndexTime": 0.0568344889,
+  "totalSymbolTableParseTime": 0.09397942199979,
+  "modules": [
+{
+  "path": "/.../TestStats.test_modules/a.out",
+  "symbolTableIndexTime": 2.3816e-05,
+  "symbolTableParseTime": 0.000163747,
+  "triple": "x86_64-apple-macosx11.0.0",
+  "uuid": "10531B95-4DF4-3FFE-9D51-549DD17435E2"
+},
+{
+  "path": "/.../TestStats.test_modules/libload_a.dylib",
+  "symbolTableIndexTime": 2.7852e-05,
+  "symbolTableParseTime": 0.000110246,
+  "triple": "x86_64-apple-macosx11.0.0",
+  "uuid": "F0974CDE-309A-3837-9593-385ABDC93803"
+},
+  ]
+}
+
+"""
+exe = self.getBuildArtifact("a.out")
+target = self.createTestTarget(file_path=exe)
+stats = self.get_stats(log_path="/tmp/test_default_no_run.txt")
+keys_exist = [
+'targetCreateTime',
+'totalSymbolTableIndexTime',
+'totalSymbolTableParseTime',
+'modules',
+]
+self.verify_keys(stats, '"stats"', keys_exist, None)
+exe_module = self.find_module_in_metrics(exe, stats)
+module_keys = [
+'path',
+'symbolTableIndexTime',
+'symbolTableParseTime',
+'triple',
+'uuid',
+]
+self.assertNotEqual(exe_module, None)
+self.verify_keys(exe_module, 'module dict for "%s"' % (exe), module_keys)
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -4454,4 +4454,4 @@
 }
 
 /// Get metrics associated with this target in JSON format.
-llvm::json::Value Target::ReportStatistics() { return m_stats.ToJSON(); }
+llvm::json::Value Target::ReportStatistics() { return m_stats.ToJSON(*this); }
Index: lldb/source/Target/Statistics.cpp
===
--- lldb/source/Target/Statistics.cpp
+++ lldb/source/Target/Statistics.cpp
@@ -17,6 +17,16 @@
 using namespace lldb_private;
 using namespace llvm;
 
+static void 

[Lldb-commits] [PATCH] D111686: Modify "statistics dump" to dump JSON.

2021-10-21 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Fixed buildbots with:

commit 910838f07da7872d2b7cca5b07d64ea9915b6767 
 (HEAD -> 
main, origin/main, origin/HEAD)
Author: Greg Clayton 
Date:   Thu Oct 21 14:21:36 2021 -0700

  Fix buildbots after https://reviews.llvm.org/D111686


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111686

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


[Lldb-commits] [lldb] 910838f - Fix buildbots after https://reviews.llvm.org/D111686

2021-10-21 Thread Greg Clayton via lldb-commits

Author: Greg Clayton
Date: 2021-10-21T14:21:36-07:00
New Revision: 910838f07da7872d2b7cca5b07d64ea9915b6767

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

LOG: Fix buildbots after https://reviews.llvm.org/D111686

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/test/API/commands/statistics/basic/TestStats.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 352ce6fabf165..169f43f59c2f9 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -750,6 +750,10 @@ def getBuildArtifact(self, name="a.out"):
 """Return absolute path to an artifact in the test's build 
directory."""
 return os.path.join(self.getBuildDir(), name)
 
+def getSourcePath(self, name):
+"""Return absolute path to a file in the test's source directory."""
+return os.path.join(self.getSourceDir(), name)
+
 @classmethod
 def setUpCommands(cls):
 commands = [

diff  --git a/lldb/test/API/commands/statistics/basic/TestStats.py 
b/lldb/test/API/commands/statistics/basic/TestStats.py
index 5f9e7b0ca9e2b..838b270f75a99 100644
--- a/lldb/test/API/commands/statistics/basic/TestStats.py
+++ b/lldb/test/API/commands/statistics/basic/TestStats.py
@@ -93,12 +93,18 @@ def test_expressions_frame_var_counts(self):
 substrs=["undeclared identifier 'doesnt_exist'"])
 # Doesn't successfully execute.
 self.expect("expr int *i = nullptr; *i", error=True)
-# Interpret an integer as an array with 3 elements is also a failure.
+# Interpret an integer as an array with 3 elements is a failure for
+# the "expr" command, but the expression evaluation will succeed and
+# be counted as a success even though the "expr" options will for the
+# command to fail. It is more important to track expression evaluation
+# from all sources instead of just through the command, so this was
+# changed. If we want to track command success and fails, we can do
+# so using another metric.
 self.expect("expr -Z 3 -- 1", error=True,
 substrs=["expression cannot be used with --element-count"])
 # We should have gotten 3 new failures and the previous success.
 stats = self.get_stats()
-self.verify_success_fail_count(stats, 'expressionEvaluation', 1, 3)
+self.verify_success_fail_count(stats, 'expressionEvaluation', 2, 2)
 
 self.expect("statistics enable")
 # 'frame var' with enabled statistics will change stats.



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


[Lldb-commits] [PATCH] D111686: Modify "statistics dump" to dump JSON.

2021-10-21 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In D111686#3079352 , @teemperor wrote:

> In D111686#3079248 , @clayborg 
> wrote:
>
>> So there is a buildbot failure due to an expression which succeeds, but 
>> because the "expression" command options don't apply cleanly to the 
>> expression result the "expression" command fails. Question: do we want 
>> "expressionEvaluation" to truly track expression evaluation failures, or 
>> just track the "expression" command success and fails? I updated this patch 
>> to track expression failures only by modifying the 
>> Target::EvaluateExpression(), so if this succeeds and "expr" command fails, 
>> we consider the expression a success right now.
>
> I have to look into this but could we skip that test in the meantime?
>
> There is also another failure that looks like it's caused by some accidental 
> change (see inline)''

I will check in a fix in a few minutes for my buildbot issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111686

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


[Lldb-commits] [PATCH] D111686: Modify "statistics dump" to dump JSON.

2021-10-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

In D111686#3079248 , @clayborg wrote:

> So there is a buildbot failure due to an expression which succeeds, but 
> because the "expression" command options don't apply cleanly to the 
> expression result the "expression" command fails. Question: do we want 
> "expressionEvaluation" to truly track expression evaluation failures, or just 
> track the "expression" command success and fails? I updated this patch to 
> track expression failures only by modifying the Target::EvaluateExpression(), 
> so if this succeeds and "expr" command fails, we consider the expression a 
> success right now.

I have to look into this but could we skip that test in the meantime?

There is also another failure that looks like it's caused by some accidental 
change (see inline)




Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:761
 
+def getShlibBuildArtifact(self, DYLIB_NAME):
+"""Return absolute path to a shared library artifact given the library

clayborg wrote:
> wallace wrote:
> > is this actually used somewhere?
> Not yet, I will remove it
I think you also removed some existing stuff here:

```
PASS: LLDB (C:\buildbot\lldb-x64-windows-ninja\build\bin\clang.exe-x86_64) :: 
test_zero_uuid_modules (TestMiniDumpUUID.MiniDumpUUIDTestCase)
==
ERROR: test_relative_module_name (TestMiniDumpUUID.MiniDumpUUIDTestCase)
--
Traceback (most recent call last):
  File 
"C:\buildbot\lldb-x64-windows-ninja\llvm-project\lldb\test\API\functionalities\postmortem\minidump-new\TestMiniDumpUUID.py",
 line 317, in test_relative_module_name
self.getSourcePath("relative_module_name.yaml"))
AttributeError: 'MiniDumpUUIDTestCase' object has no attribute 'getSourcePath'
Config=x86_64-C:\buildbot\lldb-x64-windows-ninja\build\bin\clang.exe
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111686

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


[Lldb-commits] [PATCH] D112212: [lldb/test] Print build commands in trace mode

2021-10-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

In D112212#3078681 , @dblaikie wrote:

> Does this sort of thing itself get tested? (like this one had a test: 
> https://reviews.llvm.org/D111978 but not sure how much that 
> generalizes/whether there are different parts of the infrastructure are more 
> or less testable)

I think historically we haven't really tested the test infrastructure, but 
we're not historians (badum-ts) so I would vote in favour of adding tests for 
this (and the other testing infra).

(I'll also gladly write some tests for the already existing testing utils 
unless someone objects).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112212

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


[Lldb-commits] [PATCH] D111686: Modify "statistics dump" to dump JSON.

2021-10-21 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

So there is a buildbot failure due to an expression which succeeds, but because 
the "expression" command options don't apply cleanly to the expression result 
the "expression" command fails. Question: do we want "expressionEvaluation" to 
truly track expression evaluation failures, or just track the "expression" 
command success and fails?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111686

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


[Lldb-commits] [PATCH] D112222: [LLDB] libcxx summary formatters for std::string_view

2021-10-21 Thread Ben Jackson via Phabricator via lldb-commits
puremourning updated this revision to Diff 381372.
puremourning added a comment.

Add some tests for dodgy inputs.
Handle invalid cases more consistently.
Factor out some copy paste code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D11

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp
@@ -0,0 +1,108 @@
+#include 
+#include 
+#include 
+
+static size_t touch_string(std::string_view _str_view) {
+  return in_str_view.size(); // Break here to look at bad string view.
+}
+
+int main() {
+  std::wstring_view wempty(L"");
+  std::wstring_view s(L"hello world! מזל טוב!");
+  std::wstring_view S(L"");
+  std::string_view empty("");
+  std::string q_source = "hello world";
+  std::string_view q(q_source);
+  std::string_view Q("quite a long std::strin with lots of info inside it");
+  std::string_view TheVeryLongOne(
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "9012345678901234567890123456789012345678901234567890someText123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"

[Lldb-commits] [lldb] 64f002c - Follow-up fixes for aee49255074fd4ef38d97e6e70cbfbf2f9fd0fa7

2021-10-21 Thread David Blaikie via lldb-commits

Author: David Blaikie
Date: 2021-10-21T13:00:56-07:00
New Revision: 64f002c6d36d674a924c6116ec0b2d731cc3981c

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

LOG: Follow-up fixes for aee49255074fd4ef38d97e6e70cbfbf2f9fd0fa7

Added: 


Modified: 
lldb/test/Shell/SymbolFile/PDB/typedefs.test
lldb/test/Shell/SymbolFile/PDB/udt-layout.test

Removed: 




diff  --git a/lldb/test/Shell/SymbolFile/PDB/typedefs.test 
b/lldb/test/Shell/SymbolFile/PDB/typedefs.test
index 5f70d87823049..a0106dd381c81 100644
--- a/lldb/test/Shell/SymbolFile/PDB/typedefs.test
+++ b/lldb/test/Shell/SymbolFile/PDB/typedefs.test
@@ -16,7 +16,7 @@ CHECK: SymbolFile pdb ([[MOD]])
 CHECK-DAG: name = "char32_t", size = 4, compiler_type = {{.*}} char32_t
 CHECK-DAG: name = "char16_t", size = 2, compiler_type = {{.*}} char16_t
 CHECK-DAG: Type{{.*}} , name = "unsigned long", size = 4, compiler_type = 
{{.*}} unsigned long
-CHECK-DAG: Type{{.*}} , size = 40, compiler_type = {{.*}} unsigned long [10]
+CHECK-DAG: Type{{.*}} , size = 40, compiler_type = {{.*}} unsigned long[10]
 CHECK-DAG: Type{{.*}} , name = "ULongArrayTypedef", compiler_type = {{.*}} 
typedef ULongArrayTypedef
 
 ; Note: compiler_type of `long double` is represented by the one for `double`

diff  --git a/lldb/test/Shell/SymbolFile/PDB/udt-layout.test 
b/lldb/test/Shell/SymbolFile/PDB/udt-layout.test
index f114c200d0219..84414cbf8440d 100644
--- a/lldb/test/Shell/SymbolFile/PDB/udt-layout.test
+++ b/lldb/test/Shell/SymbolFile/PDB/udt-layout.test
@@ -3,7 +3,7 @@ RUN: %build --compiler=clang-cl --output=%t.exe 
%S/Inputs/UdtLayoutTest.cpp
 RUN: %lldb -b -s %S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s
 
 CHECK:(int) C::abc = 123
-CHECK:(List [16]) ls = {
+CHECK:(List[16]) ls = {
 CHECK:  [15] = {
 CHECK:Prev = nullptr
 CHECK:Next = nullptr



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


[Lldb-commits] [PATCH] D112222: [LLDB] libcxx summary formatters for std::string_view

2021-10-21 Thread Ben Jackson via Phabricator via lldb-commits
puremourning added a comment.

In D11#3078896 , @shafik wrote:

> It looks good to me but can we verify it behaves nicely with undefined 
> behavior cases e.g.:
>
>   std::string s = "Hellooo ";
>   std::string_view sv = s + "World\n";

Will add some cases, sure.

> and a case like the one that was fixed in D108228 
> 

Thanks for the pointer! (no pun intended). I will apply the same 
change/mitigattion to my new code.

> I am not expecting any surprises since you are using the underlying string 
> formatter but worth checking.

yes, certainly is, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D11

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


[Lldb-commits] [lldb] d7b3385 - Modify "statistics dump" to dump JSON.

2021-10-21 Thread Greg Clayton via lldb-commits

Author: Greg Clayton
Date: 2021-10-21T12:14:21-07:00
New Revision: d7b338537cf360568474d31c2be86110ac22dc32

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

LOG: Modify "statistics dump" to dump JSON.

This patch is a smaller version of a previous patch 
https://reviews.llvm.org/D110804.

This patch modifies the output of "statistics dump" to be able to get stats 
from the current target. It adds 3 new stats as well. The output of "statistics 
dump" is now emitted as JSON so that it can be used to track performance and 
statistics and the output could be used to populate a database that tracks 
performance. Sample output looks like:

(lldb) statistics dump
{
  "expressionEvaluation": {
"failures": 0,
"successes": 0
  },
  "firstStopTime": 0.3416449280001,
  "frameVariable": {
"failures": 0,
"successes": 0
  },
  "launchOrAttachTime": 0.3196960540001,
  "targetCreateTime": 0.00408630398
}

The top level keys are:

"expressionEvaluation" which replaces the previous stats that were emitted as 
plain text. This dictionary contains the success and fail counts.
"frameVariable" which replaces the previous stats for "frame variable" that 
were emitted as plain text. This dictionary contains the success and fail 
counts.
"targetCreateTime" contains the number of seconds it took to create the target 
and load dependent libraries (if they were enabled) and also will contain 
symbol preloading times if that setting is enabled.
"launchOrAttachTime" is the time it takes from when the launch/attach is 
initiated to when the first private stop occurs.
"firstStopTime" is the time in seconds that it takes to stop at the first stop 
that is presented to the user via the LLDB interface. This value will only have 
meaning if you set a known breakpoint or stop location in your code that you 
want to measure as a performance test.

This diff is also meant as a place to discuess what we want out of the 
"statistics dump" command before adding more funcionality. It is also meant to 
clean up the previous code that was storting statistics in a vector of numbers 
within the lldb_private::Target class.

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

Added: 
lldb/include/lldb/Target/Statistics.h
lldb/source/Target/Statistics.cpp

Modified: 
lldb/include/lldb/Target/Process.h
lldb/include/lldb/Target/Target.h
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/source/API/SBTarget.cpp
lldb/source/Commands/CommandObjectExpression.cpp
lldb/source/Commands/CommandObjectFrame.cpp
lldb/source/Commands/CommandObjectStats.cpp
lldb/source/Commands/Options.td
lldb/source/Target/CMakeLists.txt
lldb/source/Target/Process.cpp
lldb/source/Target/Target.cpp
lldb/test/API/commands/statistics/basic/TestStats.py
lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py

Removed: 




diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 7ac53d3336cdf..e9743ed17dd46 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -238,10 +238,11 @@ class ProcessModID {
 
   ~ProcessModID() = default;
 
-  void BumpStopID() {
-m_stop_id++;
+  uint32_t BumpStopID() {
+const uint32_t prev_stop_id = m_stop_id++;
 if (!IsLastResumeForUserExpression())
   m_last_natural_stop_id++;
+return prev_stop_id;
   }
 
   void BumpMemoryID() { m_memory_id++; }

diff  --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
new file mode 100644
index 0..dfeefcbe74eac
--- /dev/null
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -0,0 +1,118 @@
+//===-- Statistics.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_TARGET_STATISTICS_H
+#define LLDB_TARGET_STATISTICS_H
+
+#include 
+#include 
+#include 
+
+#include "lldb/Utility/Stream.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/Support/JSON.h"
+
+namespace lldb_private {
+
+using StatsClock = std::chrono::high_resolution_clock;
+using StatsDuration = std::chrono::duration;
+using StatsTimepoint = std::chrono::time_point;
+
+/// A class that measures elapsed time in an exception safe way.
+///
+/// This is a RAII class is designed to help gather timing statistics within
+/// LLDB where objects have optional Duration variables that get updated with
+/// elapsed times. This helps LLDB measure statistics for many things that are
+/// then reported in 

[Lldb-commits] [PATCH] D111686: Modify "statistics dump" to dump JSON.

2021-10-21 Thread Greg Clayton via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd7b338537cf3: Modify statistics dump to dump 
JSON. (authored by clayborg).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111686

Files:
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/Target/Statistics.h
  lldb/include/lldb/Target/Target.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/API/SBTarget.cpp
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Commands/CommandObjectFrame.cpp
  lldb/source/Commands/CommandObjectStats.cpp
  lldb/source/Commands/Options.td
  lldb/source/Target/CMakeLists.txt
  lldb/source/Target/Process.cpp
  lldb/source/Target/Statistics.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/commands/statistics/basic/TestStats.py
  lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py

Index: lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
===
--- lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
+++ lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
@@ -10,6 +10,8 @@
 class TestStatsAPI(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
+NO_DEBUG_INFO_TESTCASE = True
+
 def test_stats_api(self):
 self.build()
 exe = self.getBuildArtifact("a.out")
@@ -26,9 +28,18 @@
 stats = target.GetStatistics()
 stream = lldb.SBStream()
 res = stats.GetAsJSON(stream)
-stats_json = sorted(json.loads(stream.GetData()))
-self.assertEqual(len(stats_json), 4)
-self.assertIn("Number of expr evaluation failures", stats_json)
-self.assertIn("Number of expr evaluation successes", stats_json)
-self.assertIn("Number of frame var failures", stats_json)
-self.assertIn("Number of frame var successes", stats_json)
+stats_json = json.loads(stream.GetData())
+self.assertEqual('expressionEvaluation' in stats_json, True,
+'Make sure the "expressionEvaluation" key in in target.GetStatistics()')
+self.assertEqual('frameVariable' in stats_json, True,
+'Make sure the "frameVariable" key in in target.GetStatistics()')
+expressionEvaluation = stats_json['expressionEvaluation']
+self.assertEqual('successes' in expressionEvaluation, True,
+'Make sure the "successes" key in in "expressionEvaluation" dictionary"')
+self.assertEqual('failures' in expressionEvaluation, True,
+'Make sure the "failures" key in in "expressionEvaluation" dictionary"')
+frameVariable = stats_json['frameVariable']
+self.assertEqual('successes' in frameVariable, True,
+'Make sure the "successes" key in in "frameVariable" dictionary"')
+self.assertEqual('failures' in frameVariable, True,
+'Make sure the "failures" key in in "frameVariable" dictionary"')
Index: lldb/test/API/commands/statistics/basic/TestStats.py
===
--- lldb/test/API/commands/statistics/basic/TestStats.py
+++ lldb/test/API/commands/statistics/basic/TestStats.py
@@ -1,4 +1,5 @@
 import lldb
+import json
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
@@ -7,22 +8,87 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
-def test(self):
+def setUp(self):
+TestBase.setUp(self)
 self.build()
-lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.c"))
 
-self.expect("statistics disable", substrs=['need to enable statistics before disabling'], error=True)
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_enable_disable(self):
+"""
+Test "statistics disable" and "statistics enable". These don't do
+anything anymore for cheap to gather statistics. In the future if
+statistics are expensive to gather, we can enable the feature inside
+of LLDB and test that enabling and disabling stops expesive information
+from being gathered.
+"""
+target = self.createTestTarget()
 
-# 'expression' should change the statistics.
+self.expect("statistics disable", substrs=['need to enable statistics before disabling'], error=True)
 self.expect("statistics enable")
 self.expect("statistics enable", substrs=['already enabled'], error=True)
-self.expect("expr patatino", substrs=['27'])
 self.expect("statistics disable")
-self.expect("statistics dump", substrs=['expr evaluation successes : 1\n',
-'expr evaluation failures : 0\n'])
+self.expect("statistics disable", substrs=['need to enable statistics before disabling'], error=True)
 
-

[Lldb-commits] [PATCH] D112222: [LLDB] libcxx summary formatters for std::string_view

2021-10-21 Thread Ben Jackson via Phabricator via lldb-commits
puremourning updated this revision to Diff 381357.
puremourning added a comment.

Revert some formatting lost in rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D11

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp
@@ -0,0 +1,97 @@
+#include 
+#include 
+#include 
+
+int main() {
+  std::wstring_view wempty(L"");
+  std::wstring_view s(L"hello world! מזל טוב!");
+  std::wstring_view S(L"");
+  std::string_view empty("");
+  std::string q_source = "hello world";
+  std::string_view q(q_source);
+  std::string_view Q("quite a long std::strin with lots of info inside it");
+  std::string_view TheVeryLongOne(
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "9012345678901234567890123456789012345678901234567890someText123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  

[Lldb-commits] [PATCH] D112222: [LLDB] libcxx summary formatters for std::string_view

2021-10-21 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

It looks good to me but can we verify it behaves nicely with undefined behavior 
cases e.g.:

  std::string s = "Hellooo ";
  std::string_view sv = s + "World\n";

and a case like the one that was fixed in D108228 


I am not expecting any surprises since you are using the underlying string 
formatter but worth checking.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D11

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


[Lldb-commits] [PATCH] D112222: [LLDB] libcxx summary formatters for std::string_view

2021-10-21 Thread Ben Jackson via Phabricator via lldb-commits
puremourning added a comment.

Thanks for the review!




Comment at: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py:62
+ns = self.namespace
+self.expect(
+"frame variable",

jingham wrote:
> We have lldbtest.expect_var_path for doing this sort of test.  It makes these 
> tests easier to read and less likely to be fooled by accidental matches.
Done. There's s slight difference in this API - the null pointer summary 
returns "" via this api rather than the output which returns "nullptr", so I've 
inlaced both in the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D11

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


[Lldb-commits] [PATCH] D112222: [LLDB] libcxx summary formatters for std::string_view

2021-10-21 Thread Ben Jackson via Phabricator via lldb-commits
puremourning updated this revision to Diff 381344.
puremourning added a comment.

Use expect_var_path rather than just expect in test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D11

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp
@@ -0,0 +1,97 @@
+#include 
+#include 
+#include 
+
+int main() {
+  std::wstring_view wempty(L"");
+  std::wstring_view s(L"hello world! מזל טוב!");
+  std::wstring_view S(L"");
+  std::string_view empty("");
+  std::string q_source = "hello world";
+  std::string_view q(q_source);
+  std::string_view Q("quite a long std::strin with lots of info inside it");
+  std::string_view TheVeryLongOne(
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "9012345678901234567890123456789012345678901234567890someText123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  

[Lldb-commits] [PATCH] D112163: Enable libc++ in the build for libcxx initializerlist pretty printers

2021-10-21 Thread David Blaikie via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd723ad5bcf71: Enable libc++ in the build for libcxx 
initializerlist pretty printers (authored by dblaikie).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112163

Files:
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py


Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
@@ -14,11 +14,7 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
-@skipIfWindows  # libc++ not ported to Windows yet
-@skipIf(compiler="gcc")
-@expectedFailureAll(
-oslist=["linux"],
-bugnumber="fails on clang 3.5 and tot")
+@add_test_categories(["libc++"])
 def test(self):
 """Test that that file and class static variables display correctly."""
 self.build()
Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile
@@ -1,4 +1,6 @@
 CXX_SOURCES := main.cpp
 CXXFLAGS_EXTRAS := -std=c++11
 
+USE_LIBCPP := 1
+
 include Makefile.rules


Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
@@ -14,11 +14,7 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
-@skipIfWindows  # libc++ not ported to Windows yet
-@skipIf(compiler="gcc")
-@expectedFailureAll(
-oslist=["linux"],
-bugnumber="fails on clang 3.5 and tot")
+@add_test_categories(["libc++"])
 def test(self):
 """Test that that file and class static variables display correctly."""
 self.build()
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile
@@ -1,4 +1,6 @@
 CXX_SOURCES := main.cpp
 CXXFLAGS_EXTRAS := -std=c++11
 
+USE_LIBCPP := 1
+
 include Makefile.rules
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] d723ad5 - Enable libc++ in the build for libcxx initializerlist pretty printers

2021-10-21 Thread David Blaikie via lldb-commits

Author: David Blaikie
Date: 2021-10-21T11:35:59-07:00
New Revision: d723ad5bcf7133c3f3950ebb63edf4ddfee56581

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

LOG: Enable libc++ in the build for libcxx initializerlist pretty printers

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

Added: 


Modified: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile
index e78030cbf7528..98af672c70fbe 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile
@@ -1,4 +1,6 @@
 CXX_SOURCES := main.cpp
 CXXFLAGS_EXTRAS := -std=c++11
 
+USE_LIBCPP := 1
+
 include Makefile.rules

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
index 5fef10e6d3ede..16b64210d6592 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
@@ -14,11 +14,7 @@ class InitializerListTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
-@skipIfWindows  # libc++ not ported to Windows yet
-@skipIf(compiler="gcc")
-@expectedFailureAll(
-oslist=["linux"],
-bugnumber="fails on clang 3.5 and tot")
+@add_test_categories(["libc++"])
 def test(self):
 """Test that that file and class static variables display correctly."""
 self.build()



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


[Lldb-commits] [PATCH] D112212: [lldb/test] Print build commands in trace mode

2021-10-21 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a comment.

Does this sort of thing itself get tested? (like this one had a test: 
https://reviews.llvm.org/D111978 but not sure how much that generalizes/whether 
there are different parts of the infrastructure are more or less testable)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112212

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


[Lldb-commits] [PATCH] D111686: Modify "statistics dump" to dump JSON.

2021-10-21 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.

I'm not super happy with the debugger stats as they are right here. Given that 
it only affects a subset of this patch and I don't want to block other work 
that depends on this, it's probably easier for me to create a patch on top of 
this rather than iterating on this one.

LGTM




Comment at: lldb/include/lldb/Target/Statistics.h:96
+};
+
+class GlobalStats {

clayborg wrote:
> JDevlieghere wrote:
> > Do we expect there to be something like `DebuggerStats`? I think it would 
> > be nice from a hierarchy perspective that Global Stats have a map of 
> > debugger -> to debuggerstat who then in turn hold on to a map of target -> 
> > target stats. That hierarchy would work really well for JSON (except they 
> > would be lists instead of maps). 
> I can change this to DebuggerStats as this is essentially what this was.
I do need something that sits about the debugger for the lldb_assert case.



Comment at: lldb/include/lldb/Target/Statistics.h:114
+  static bool g_collecting_stats;
+};
+

clayborg wrote:
> This can be expensive if you start locking a mutex just to increment a stat 
> that is a counter and will make statistics slow down the debugger. I would 
> rather rely on std::atomic or the locks already built into Target or Debugger 
> if possible. If lldb_asserts are firing off at a high rate, we can't be 
> spending thousands of instructions locking and unlocking mutexes.
Yeah, and atomic variable for a particular metric might do the trick. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111686

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


[Lldb-commits] [PATCH] D112222: [LLDB] libcxx summary formatters for std::string_view

2021-10-21 Thread Jim Ingham via Phabricator via lldb-commits
jingham added inline comments.



Comment at: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py:62
+ns = self.namespace
+self.expect(
+"frame variable",

We have lldbtest.expect_var_path for doing this sort of test.  It makes these 
tests easier to read and less likely to be fooled by accidental matches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D11

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


[Lldb-commits] [PATCH] D112222: [LLDB] libcxx summary formatters for std::string_view

2021-10-21 Thread Ben Jackson via Phabricator via lldb-commits
puremourning updated this revision to Diff 381295.
puremourning added a comment.

RE-post with clang-format in path


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D11

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp
@@ -0,0 +1,97 @@
+#include 
+#include 
+#include 
+
+int main() {
+  std::wstring_view wempty(L"");
+  std::wstring_view s(L"hello world! מזל טוב!");
+  std::wstring_view S(L"");
+  std::string_view empty("");
+  std::string q_source = "hello world";
+  std::string_view q(q_source);
+  std::string_view Q("quite a long std::strin with lots of info inside it");
+  std::string_view TheVeryLongOne(
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "9012345678901234567890123456789012345678901234567890someText123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  "901234567890123456789012345678901234567890123456789012345678901234567890"
+  "123456789012345678901234567890123456789012345678901234567890123456789012"
+  "345678901234567890123456789012345678901234567890123456789012345678901234"
+  "567890123456789012345678901234567890123456789012345678901234567890123456"
+  "789012345678901234567890123456789012345678901234567890123456789012345678"
+  

[Lldb-commits] [PATCH] D112222: [LLDB] libcxx summary formatters for std::string_view

2021-10-21 Thread Ben Jackson via Phabricator via lldb-commits
puremourning updated this revision to Diff 381293.
puremourning added a comment.

Remove change to the formatting of empty u16 and u32 strings


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D11

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp
@@ -0,0 +1,27 @@
+#include 
+#include 
+#include 
+
+int main()
+{
+std::wstring_view wempty(L"");
+std::wstring_view s(L"hello world! מזל טוב!");
+std::wstring_view S(L"");
+std::string_view empty("");
+std::string q_source = "hello world";
+std::string_view q(q_source);
+std::string_view Q("quite a long std::strin with lots of info inside it");
+std::string_view 

[Lldb-commits] [PATCH] D112222: [LLDB] libcxx summary formatters for std::string_view

2021-10-21 Thread Ben Jackson via Phabricator via lldb-commits
puremourning added a comment.

> I would actually prefer if we could split this into a separate change :) 
> (Sorry!)

No problem, that was my gut feeling at the time too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D11

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


[Lldb-commits] [PATCH] D112222: [LLDB] libcxx summary formatters for std::string_view

2021-10-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

In D11#3077988 , @puremourning 
wrote:

> I'm happy to revert/split out the change for empty strings, as this is 
> perhaps contentious (and not exactly minimal for this patch).

I would actually prefer if we could split this into a separate change :) 
(Sorry!)

> Also, I'm only implementing libcxx (for now). We can follow up with libstdc++ 
> in another patch if this is accepted.

Sounds good to me.

> This is my first lldb patch, so apologies if I did something out of ordinary.

Nope, I think this is actually looking pretty good. I just have a few nits that 
I'll try get around today/tomorrow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D11

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


[Lldb-commits] [PATCH] D112222: [LLDB] libcxx summary formatters for std::string_view

2021-10-21 Thread Ben Jackson via Phabricator via lldb-commits
puremourning added a comment.

I'm happy to revert/split out the change for empty strings, as this is perhaps 
contentious (and not exactly minimal for this patch).

Also, I'm only implementing libcxx (for now). We can follow up with libstdc++ 
in another patch if this is accepted.

This is my first lldb patch, so apologies if I did something out of ordinary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D11

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


[Lldb-commits] [PATCH] D112222: [LLDB] libcxx summary formatters for std::string_view

2021-10-21 Thread Ben Jackson via Phabricator via lldb-commits
puremourning created this revision.
puremourning requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

When printing a std::string_view, print the referenced string as the
summary. Support string_view, u32string_view, u16string_view and
wstring_view, as we do for std::string and friends.

This is based on the existing fomratter for std::string, and just
extracts the data and length members, pushing them through the existing
string formatter.

In testing this, a "FIXME" was corrected for printing of non-ASCII empty
values. Previously, the "u", 'U" etc. prefixes were not printed for
basic_string<> types that were not char. This is trivial to resolve by
printing the prefix before the `""`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D11

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp
@@ -0,0 +1,27 @@
+#include 
+#include 
+#include 
+
+int main()
+{
+std::wstring_view wempty(L"");
+std::wstring_view s(L"hello world! מזל טוב!");
+std::wstring_view S(L"");
+std::string_view empty("");
+std::string q_source = "hello world";
+std::string_view q(q_source);
+std::string_view Q("quite a long std::strin with lots of info inside it");
+std::string_view 

[Lldb-commits] [PATCH] D112212: [lldb/test] Print build commands in trace mode

2021-10-21 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:1422
+def runBuildCommands(self, commands):
+for cmd in commands:
+self.trace(shlex.join(cmd))

Is this ever going to have more than one command to run?

Seems like the source is the function above that puts a single command into a 
list.



Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:1284
 compiler = self.getCompilerBinary()
-version_output = system([[compiler, "--version"]])
-for line in version_output.split(os.linesep):
-m = re.search('version ([0-9.]+)', line)
-if m:
-return m.group(1)
+version_output = check_output([compiler, "--version"])
+m = re.search(b'version ([0-9.]+)', version_output)

labath wrote:
> DavidSpickett wrote:
> > You could use `universal_newlines` here to get the decoded string. It's a 
> > bit cryptic but saves the decode below.
> > 
> > There is an alias `text` name in 3.7 but requiring that seems ambitious.
> how about `error="replace"` on the `check_output` invocation it's equally 
> cryptic, and does not throw an exception on non-utf output?
> 
> (I'm generally unsure about the best way to handle the byte-string duality in 
> python3 -- whether to try to handle things at the byte level (if they can) or 
> to convert everything to strings as soon as possible and pretend bytes don't 
> exist.)
> and does not throw an exception on non-utf output

I didn't consider that so yeah this looks fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112212

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


[Lldb-commits] [PATCH] D110535: [llvm] [ADT] Update llvm::Split() per Pavel Labath's suggestions

2021-10-21 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 381226.
mgorny added a comment.
This revision is now accepted and ready to land.

Ok, this turned out to be a little bit harder than I anticipated — in 
particular I needed to add a copy constructor and assignment operator.

@labath, do you think it's fine or should I revert to non-`char` version?


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

https://reviews.llvm.org/D110535

Files:
  lldb/source/Host/common/File.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  llvm/include/llvm/ADT/StringExtras.h
  llvm/lib/IR/DataLayout.cpp
  llvm/unittests/ADT/StringExtrasTest.cpp

Index: llvm/unittests/ADT/StringExtrasTest.cpp
===
--- llvm/unittests/ADT/StringExtrasTest.cpp
+++ llvm/unittests/ADT/StringExtrasTest.cpp
@@ -276,7 +276,7 @@
 }
 
 TEST(StringExtrasTest, splitStringRef) {
-  auto Spl = Split("foo<=>bar<=><=>baz", "<=>");
+  auto Spl = split("foo<=>bar<=><=>baz", "<=>");
   auto It = Spl.begin();
   auto End = Spl.end();
 
@@ -291,8 +291,18 @@
   ASSERT_EQ(++It, End);
 }
 
-TEST(StringExtrasTest, splItChar) {
-  auto Spl = Split("foo,bar,,baz", ',');
+TEST(StringExtrasTest, splitStringRefForLoop) {
+  llvm::SmallVector Result;
+  std::array Expected{"foo", "bar", "", "baz"};
+
+  for (StringRef x : split("foo<=>bar<=><=>baz", "<=>"))
+Result.push_back(x);
+
+  EXPECT_EQ(ArrayRef(Result), ArrayRef(Expected));
+}
+
+TEST(StringExtrasTest, splitChar) {
+  auto Spl = split("foo,bar,,baz", ',');
   auto It = Spl.begin();
   auto End = Spl.end();
 
@@ -306,3 +316,13 @@
   EXPECT_EQ(*It, StringRef("baz"));
   ASSERT_EQ(++It, End);
 }
+
+TEST(StringExtrasTest, splitCharForLoop) {
+  llvm::SmallVector Result;
+  std::array Expected{"foo", "bar", "", "baz"};
+
+  for (StringRef x : split("foo,bar,,baz", ','))
+Result.push_back(x);
+
+  EXPECT_EQ(ArrayRef(Result), ArrayRef(Expected));
+}
Index: llvm/lib/IR/DataLayout.cpp
===
--- llvm/lib/IR/DataLayout.cpp
+++ llvm/lib/IR/DataLayout.cpp
@@ -260,12 +260,12 @@
   while (!Desc.empty()) {
 // Split at '-'.
 std::pair Split;
-if (Error Err = split(Desc, '-', Split))
+if (Error Err = ::split(Desc, '-', Split))
   return Err;
 Desc = Split.second;
 
 // Split at ':'.
-if (Error Err = split(Split.first, ':', Split))
+if (Error Err = ::split(Split.first, ':', Split))
   return Err;
 
 // Aliases used below.
@@ -274,7 +274,7 @@
 
 if (Tok == "ni") {
   do {
-if (Error Err = split(Rest, ':', Split))
+if (Error Err = ::split(Rest, ':', Split))
   return Err;
 Rest = Split.second;
 unsigned AS;
@@ -315,7 +315,7 @@
   if (Rest.empty())
 return reportError(
 "Missing size specification for pointer in datalayout string");
-  if (Error Err = split(Rest, ':', Split))
+  if (Error Err = ::split(Rest, ':', Split))
 return Err;
   unsigned PointerMemSize;
   if (Error Err = getIntInBytes(Tok, PointerMemSize))
@@ -327,7 +327,7 @@
   if (Rest.empty())
 return reportError(
 "Missing alignment specification for pointer in datalayout string");
-  if (Error Err = split(Rest, ':', Split))
+  if (Error Err = ::split(Rest, ':', Split))
 return Err;
   unsigned PointerABIAlign;
   if (Error Err = getIntInBytes(Tok, PointerABIAlign))
@@ -342,7 +342,7 @@
   // Preferred alignment.
   unsigned PointerPrefAlign = PointerABIAlign;
   if (!Rest.empty()) {
-if (Error Err = split(Rest, ':', Split))
+if (Error Err = ::split(Rest, ':', Split))
   return Err;
 if (Error Err = getIntInBytes(Tok, PointerPrefAlign))
   return Err;
@@ -352,7 +352,7 @@
 
 // Now read the index. It is the second optional parameter here.
 if (!Rest.empty()) {
-  if (Error Err = split(Rest, ':', Split))
+  if (Error Err = ::split(Rest, ':', Split))
 return Err;
   if (Error Err = getIntInBytes(Tok, IndexSize))
 return Err;
@@ -393,7 +393,7 @@
   if (Rest.empty())
 return reportError(
 "Missing alignment specification in datalayout string");
-  if (Error Err = split(Rest, ':', Split))
+  if (Error Err = ::split(Rest, ':', Split))
 return Err;
   unsigned ABIAlign;
   if (Error Err = getIntInBytes(Tok, ABIAlign))
@@ -410,7 +410,7 @@
   // Preferred alignment.
   unsigned PrefAlign = ABIAlign;
   if (!Rest.empty()) {
-if (Error Err = split(Rest, ':', Split))
+if (Error Err = ::split(Rest, ':', Split))
   return Err;
 if (Error Err = getIntInBytes(Tok, PrefAlign))
   return Err;
@@ 

[Lldb-commits] [PATCH] D112180: Libcpp bitset syntethic children and tests

2021-10-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor requested changes to this revision.
teemperor added a comment.
This revision now requires changes to proceed.

Thanks for working on this!

Some notes/nits:

- nit: The patch seems to have a bunch of unrelated clang-format changes for 
CPlusPlusLanguage.cpp in it. You can prevent that by using git clang-format on 
your local git commit before putting the diff on Phabricator (git tells 
clang-format which lines were modified by you and clang-format will only format 
those).
- LibStdcppBitset.cpp seems to be a 99% identical copy of LibCxxBitset.cpp. I 
think those two classes can just be one class with some variable for the 
different field name in each implementation.
- Same for the test. I think we can merge that into something like 
`.../data-formatter-stl/generic/bitset` and then just have two `test_...` 
methods where one is decorated for libc++ and one for libstdc++. You can change 
the Makefile values for each test with the `dictionary` argument of 
`self.build` (something like `self.build(dictionary={"USE_LIBSTDCPP":"1"})` 
should work I believe).




Comment at: lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt:9
   LibCxxBitset.cpp
+  LibStdcppBitset.cpp
   LibCxxInitializerList.cpp

I think the idea is to keep this sorted alphabetically (even though this 
position probably make more sense, but oh well...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112180

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


[Lldb-commits] [PATCH] D112212: [lldb/test] Print build commands in trace mode

2021-10-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:1284
 compiler = self.getCompilerBinary()
-version_output = system([[compiler, "--version"]])
-for line in version_output.split(os.linesep):
-m = re.search('version ([0-9.]+)', line)
-if m:
-return m.group(1)
+version_output = check_output([compiler, "--version"])
+m = re.search(b'version ([0-9.]+)', version_output)

DavidSpickett wrote:
> You could use `universal_newlines` here to get the decoded string. It's a bit 
> cryptic but saves the decode below.
> 
> There is an alias `text` name in 3.7 but requiring that seems ambitious.
how about `error="replace"` on the `check_output` invocation it's equally 
cryptic, and does not throw an exception on non-utf output?

(I'm generally unsure about the best way to handle the byte-string duality in 
python3 -- whether to try to handle things at the byte level (if they can) or 
to convert everything to strings as soon as possible and pretend bytes don't 
exist.)



Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:1425
+try:
+proc = run(cmd, stdin=DEVNULL, stdout=PIPE, stderr=STDOUT,
+check=True)

DavidSpickett wrote:
> labath wrote:
> > PSA: this function is available from python-3.5 onwards.
> Any reason to use `run(...check=True)` rather than `check_call`?
> 
> https://docs.python.org/3/library/subprocess.html#subprocess.check_call
> 
> (`universal_newlines` applies here too if you want)
I must have thought I needed some of this functionality, but now that I look at 
it -- I don't. So `check_output` it is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112212

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


[Lldb-commits] [PATCH] D112212: [lldb/test] Print build commands in trace mode

2021-10-21 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 381223.
labath added a comment.

Respond to reviewer comments (thanks).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112212

Files:
  lldb/packages/Python/lldbsuite/test/builders/builder.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test_event/build_exception.py

Index: lldb/packages/Python/lldbsuite/test_event/build_exception.py
===
--- lldb/packages/Python/lldbsuite/test_event/build_exception.py
+++ lldb/packages/Python/lldbsuite/test_event/build_exception.py
@@ -1,10 +1,11 @@
+import shlex
+
 class BuildError(Exception):
 
 def __init__(self, called_process_error):
 super(BuildError, self).__init__("Error when building test subject")
-self.command = called_process_error.lldb_extensions.get(
-"command", "")
-self.build_error = called_process_error.lldb_extensions["combined_output"]
+self.command = shlex.join(called_process_error.cmd)
+self.build_error = called_process_error.output
 
 def __str__(self):
 return self.format_build_error(self.command, self.build_error)
@@ -12,4 +13,4 @@
 @staticmethod
 def format_build_error(command, command_output):
 return "Error when building test subject.\n\nBuild Command:\n{}\n\nBuild Command Output:\n{}".format(
-command, command_output.decode("utf-8", errors='ignore'))
+command, command_output)
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -45,6 +45,7 @@
 import re
 import shutil
 import signal
+import shlex
 from subprocess import *
 import sys
 import time
@@ -68,6 +69,7 @@
 from lldbsuite.support import encoded_file
 from lldbsuite.support import funcutils
 from lldbsuite.test.builders import get_builder
+from lldbsuite.test_event import build_exception
 
 # See also dotest.parseOptionsAndInitTestdirs(), where the environment variables
 # LLDB_COMMAND_TRACE is set from '-t' option.
@@ -469,61 +471,6 @@
 def terminate(self):
 lldb.remote_platform.Kill(self._pid)
 
-# From 2.7's subprocess.check_output() convenience function.
-# Return a tuple (stdoutdata, stderrdata).
-
-
-def system(commands, **kwargs):
-r"""Run an os command with arguments and return its output as a byte string.
-
-If the exit code was non-zero it raises a CalledProcessError.  The
-CalledProcessError object will have the return code in the returncode
-attribute and output in the output attribute.
-
-The arguments are the same as for the Popen constructor.  Example:
-
->>> check_output(["ls", "-l", "/dev/null"])
-'crw-rw-rw- 1 root root 1, 3 Oct 18  2007 /dev/null\n'
-
-The stdout argument is not allowed as it is used internally.
-To capture standard error in the result, use stderr=STDOUT.
-
->>> check_output(["/bin/sh", "-c",
-...   "ls -l non_existent_file ; exit 0"],
-...  stderr=STDOUT)
-'ls: non_existent_file: No such file or directory\n'
-"""
-
-output = ""
-error = ""
-for shellCommand in commands:
-if 'stdout' in kwargs:
-raise ValueError(
-'stdout argument not allowed, it will be overridden.')
-process = Popen(
-shellCommand,
-stdout=PIPE,
-stderr=STDOUT,
-**kwargs)
-pid = process.pid
-this_output, this_error = process.communicate()
-retcode = process.poll()
-
-if retcode:
-cmd = kwargs.get("args")
-if cmd is None:
-cmd = shellCommand
-cpe = CalledProcessError(retcode, cmd)
-# Ensure caller can access the stdout/stderr.
-cpe.lldb_extensions = {
-"combined_output": this_output,
-"command": shellCommand
-}
-raise cpe
-output = output + this_output.decode("utf-8", errors='ignore')
-return output
-
-
 def getsource_if_available(obj):
 """
 Return the text of the source code for an object if available.  Otherwise,
@@ -1334,11 +1281,10 @@
 Supports: llvm, clang.
 """
 compiler = self.getCompilerBinary()
-version_output = system([[compiler, "--version"]])
-for line in version_output.split(os.linesep):
-m = re.search('version ([0-9.]+)', line)
-if m:
-return m.group(1)
+version_output = check_output([compiler, "--version"], errors="replace")
+m = re.search('version ([0-9.]+)', version_output)
+if m:
+return m.group(1)
 return 'unknown'
 
 def getDwarfVersion(self):
@@ -1465,9 

[Lldb-commits] [lldb] 6c88086 - [lldb] Fix a thinko in 2ace1e57

2021-10-21 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-21T14:05:49+02:00
New Revision: 6c88086ba8046884bb30a72ae1a8bea95e46f022

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

LOG: [lldb] Fix a thinko in 2ace1e57

An empty plugin name means we should try everything.

Picked up by the windows bot.

Added: 


Modified: 
lldb/source/Core/PluginManager.cpp

Removed: 




diff  --git a/lldb/source/Core/PluginManager.cpp 
b/lldb/source/Core/PluginManager.cpp
index d4a4d040ed082..39a412229d5fd 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -701,11 +701,11 @@ Status PluginManager::SaveCore(const lldb::ProcessSP 
_sp,
   Status error;
   auto  = GetObjectFileInstances().GetInstances();
   for (auto  : instances) {
-if (instance.name.GetStringRef() != plugin_name)
-  continue;
-if (instance.save_core &&
-instance.save_core(process_sp, outfile, core_style, error))
-  return error;
+if (plugin_name.empty() || instance.name.GetStringRef() == plugin_name) {
+  if (instance.save_core &&
+  instance.save_core(process_sp, outfile, core_style, error))
+return error;
+}
   }
   error.SetErrorString(
   "no ObjectFile plugins were able to save a core for this process");



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


[Lldb-commits] [PATCH] D110535: [llvm] [ADT] Update llvm::Split() per Pavel Labath's suggestions

2021-10-21 Thread Michał Górny via Phabricator via lldb-commits
mgorny planned changes to this revision.
mgorny added a comment.

Something's broken.


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

https://reviews.llvm.org/D110535

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


[Lldb-commits] [PATCH] D112212: [lldb/test] Print build commands in trace mode

2021-10-21 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a reviewer: DavidSpickett.
DavidSpickett added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:1284
 compiler = self.getCompilerBinary()
-version_output = system([[compiler, "--version"]])
-for line in version_output.split(os.linesep):
-m = re.search('version ([0-9.]+)', line)
-if m:
-return m.group(1)
+version_output = check_output([compiler, "--version"])
+m = re.search(b'version ([0-9.]+)', version_output)

You could use `universal_newlines` here to get the decoded string. It's a bit 
cryptic but saves the decode below.

There is an alias `text` name in 3.7 but requiring that seems ambitious.



Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:1425
+try:
+proc = run(cmd, stdin=DEVNULL, stdout=PIPE, stderr=STDOUT,
+check=True)

labath wrote:
> PSA: this function is available from python-3.5 onwards.
Any reason to use `run(...check=True)` rather than `check_call`?

https://docs.python.org/3/library/subprocess.html#subprocess.check_call

(`universal_newlines` applies here too if you want)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112212

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


[Lldb-commits] [PATCH] D110535: [llvm] [ADT] Update llvm::Split() per Pavel Labath's suggestions

2021-10-21 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 381209.
mgorny added a comment.

Add explicit test for use in a `for` loop.


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

https://reviews.llvm.org/D110535

Files:
  lldb/source/Host/common/File.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  llvm/include/llvm/ADT/StringExtras.h
  llvm/lib/IR/DataLayout.cpp
  llvm/unittests/ADT/StringExtrasTest.cpp

Index: llvm/unittests/ADT/StringExtrasTest.cpp
===
--- llvm/unittests/ADT/StringExtrasTest.cpp
+++ llvm/unittests/ADT/StringExtrasTest.cpp
@@ -276,7 +276,7 @@
 }
 
 TEST(StringExtrasTest, splitStringRef) {
-  auto Spl = Split("foo<=>bar<=><=>baz", "<=>");
+  auto Spl = split("foo<=>bar<=><=>baz", "<=>");
   auto It = Spl.begin();
   auto End = Spl.end();
 
@@ -291,8 +291,18 @@
   ASSERT_EQ(++It, End);
 }
 
-TEST(StringExtrasTest, splItChar) {
-  auto Spl = Split("foo,bar,,baz", ',');
+TEST(StringExtrasTest, splitStringRefForLoop) {
+  llvm::SmallVector Result;
+  std::array Expected{"foo", "bar", "", "baz"};
+
+  for (StringRef x : split("foo<=>bar<=><=>baz", "<=>"))
+Result.push_back(x);
+
+  EXPECT_EQ(ArrayRef(Result), ArrayRef(Expected));
+}
+
+TEST(StringExtrasTest, splitChar) {
+  auto Spl = split("foo,bar,,baz", ',');
   auto It = Spl.begin();
   auto End = Spl.end();
 
@@ -306,3 +316,13 @@
   EXPECT_EQ(*It, StringRef("baz"));
   ASSERT_EQ(++It, End);
 }
+
+TEST(StringExtrasTest, splitCharForLoop) {
+  llvm::SmallVector Result;
+  std::array Expected{"foo", "bar", "", "baz"};
+
+  for (StringRef x : split("foo,bar,,baz", ','))
+Result.push_back(x);
+
+  EXPECT_EQ(ArrayRef(Result), ArrayRef(Expected));
+}
Index: llvm/lib/IR/DataLayout.cpp
===
--- llvm/lib/IR/DataLayout.cpp
+++ llvm/lib/IR/DataLayout.cpp
@@ -260,12 +260,12 @@
   while (!Desc.empty()) {
 // Split at '-'.
 std::pair Split;
-if (Error Err = split(Desc, '-', Split))
+if (Error Err = ::split(Desc, '-', Split))
   return Err;
 Desc = Split.second;
 
 // Split at ':'.
-if (Error Err = split(Split.first, ':', Split))
+if (Error Err = ::split(Split.first, ':', Split))
   return Err;
 
 // Aliases used below.
@@ -274,7 +274,7 @@
 
 if (Tok == "ni") {
   do {
-if (Error Err = split(Rest, ':', Split))
+if (Error Err = ::split(Rest, ':', Split))
   return Err;
 Rest = Split.second;
 unsigned AS;
@@ -315,7 +315,7 @@
   if (Rest.empty())
 return reportError(
 "Missing size specification for pointer in datalayout string");
-  if (Error Err = split(Rest, ':', Split))
+  if (Error Err = ::split(Rest, ':', Split))
 return Err;
   unsigned PointerMemSize;
   if (Error Err = getIntInBytes(Tok, PointerMemSize))
@@ -327,7 +327,7 @@
   if (Rest.empty())
 return reportError(
 "Missing alignment specification for pointer in datalayout string");
-  if (Error Err = split(Rest, ':', Split))
+  if (Error Err = ::split(Rest, ':', Split))
 return Err;
   unsigned PointerABIAlign;
   if (Error Err = getIntInBytes(Tok, PointerABIAlign))
@@ -342,7 +342,7 @@
   // Preferred alignment.
   unsigned PointerPrefAlign = PointerABIAlign;
   if (!Rest.empty()) {
-if (Error Err = split(Rest, ':', Split))
+if (Error Err = ::split(Rest, ':', Split))
   return Err;
 if (Error Err = getIntInBytes(Tok, PointerPrefAlign))
   return Err;
@@ -352,7 +352,7 @@
 
 // Now read the index. It is the second optional parameter here.
 if (!Rest.empty()) {
-  if (Error Err = split(Rest, ':', Split))
+  if (Error Err = ::split(Rest, ':', Split))
 return Err;
   if (Error Err = getIntInBytes(Tok, IndexSize))
 return Err;
@@ -393,7 +393,7 @@
   if (Rest.empty())
 return reportError(
 "Missing alignment specification in datalayout string");
-  if (Error Err = split(Rest, ':', Split))
+  if (Error Err = ::split(Rest, ':', Split))
 return Err;
   unsigned ABIAlign;
   if (Error Err = getIntInBytes(Tok, ABIAlign))
@@ -410,7 +410,7 @@
   // Preferred alignment.
   unsigned PrefAlign = ABIAlign;
   if (!Rest.empty()) {
-if (Error Err = split(Rest, ':', Split))
+if (Error Err = ::split(Rest, ':', Split))
   return Err;
 if (Error Err = getIntInBytes(Tok, PrefAlign))
   return Err;
@@ -439,7 +439,7 @@
 LegalIntWidths.push_back(Width);
 if (Rest.empty())
   break;
-if (Error Err = split(Rest, ':', Split))
+if (Error Err = ::split(Rest, ':', Split))
   return 

[Lldb-commits] [lldb] 3972415 - [lldb] Silence -Wpessimizing-move warning

2021-10-21 Thread Benjamin Kramer via lldb-commits

Author: Benjamin Kramer
Date: 2021-10-21T12:59:00+02:00
New Revision: 39724158d38766f7d8683f78f54d80d174cae96a

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

LOG: [lldb] Silence -Wpessimizing-move warning

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:3635:10: error: moving 
a local object in a return statement prevents copy elision 
[-Werror,-Wpessimizing-move]
  return std::move(merged);
 ^

Added: 


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

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 90b07ad061b0..d8a17755b247 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3632,7 +3632,7 @@ SymbolFileDWARF::MergeBlockAbstractParameters(const 
DWARFDIE _die,
 }
 merged.push_back(*concrete_it);
   }
-  return std::move(merged);
+  return merged;
 }
 
 size_t SymbolFileDWARF::ParseVariablesInFunctionContext(



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


[Lldb-commits] [PATCH] D112061: [lldb] Remove ConstString from GetPluginNameStatic of some plugins

2021-10-21 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2ace1e5753a4: [lldb] Remove ConstString from 
GetPluginNameStatic of some plugins (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112061

Files:
  lldb/include/lldb/Core/PluginManager.h
  lldb/source/API/SBProcess.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Core/PluginManager.cpp
  lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
  lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
  
lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
  
lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h
  lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
  lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
  lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
  lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
  lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.cpp
  lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.h
  lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp
  lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.h
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
  lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
  lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
  lldb/source/Target/OperatingSystem.cpp

Index: lldb/source/Target/OperatingSystem.cpp
===
--- lldb/source/Target/OperatingSystem.cpp
+++ lldb/source/Target/OperatingSystem.cpp
@@ -17,10 +17,9 @@
  const char *plugin_name) {
   OperatingSystemCreateInstance create_callback = nullptr;
   if (plugin_name) {
-ConstString const_plugin_name(plugin_name);
 create_callback =
 PluginManager::GetOperatingSystemCreateCallbackForPluginName(
-const_plugin_name);
+plugin_name);
 if (create_callback) {
   std::unique_ptr instance_up(
   create_callback(process, true));
Index: lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
===
--- lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
+++ lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
@@ -36,14 +36,12 @@
 
   static void Terminate();
 
-  static lldb_private::ConstString GetPluginNameStatic();
+  static llvm::StringRef GetPluginNameStatic() { return "python"; }
 
-  static const char *GetPluginDescriptionStatic();
+  static llvm::StringRef GetPluginDescriptionStatic();
 
   // lldb_private::PluginInterface Methods
-  llvm::StringRef GetPluginName() override {
-return GetPluginNameStatic().GetStringRef();
-  }
+  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
 
   // lldb_private::OperatingSystem Methods
   bool UpdateThreadList(lldb_private::ThreadList _thread_list,
Index: lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
===
--- lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
+++ lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
@@ -65,12 +65,7 @@
   return nullptr;
 }
 
-ConstString OperatingSystemPython::GetPluginNameStatic() {
-  static ConstString g_name("python");
-  return g_name;
-}
-
-const char *OperatingSystemPython::GetPluginDescriptionStatic() {
+llvm::StringRef OperatingSystemPython::GetPluginDescriptionStatic() {
   return "Operating system plug-in that gathers OS information from a python "
  "class that implements the necessary OperatingSystem functionality.";
 }
Index: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
===
--- lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
+++ lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
@@ -24,7 +24,7 @@
   static void Initialize();
   static void Terminate();
 
-  static ConstString GetPluginNameStatic();
+  static llvm::StringRef GetPluginNameStatic() { return "wasm"; }
   static const char *GetPluginDescriptionStatic() {
 return "WebAssembly object file reader.";
   }
@@ -48,9 +48,7 @@
 
   /// PluginInterface protocol.
   /// \{
-  llvm::StringRef GetPluginName() override {
-return GetPluginNameStatic().GetStringRef();
- 

[Lldb-commits] [lldb] 2ace1e5 - [lldb] Remove ConstString from GetPluginNameStatic of some plugins

2021-10-21 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-21T12:58:45+02:00
New Revision: 2ace1e5753a49195ca17f3e175c7e189cf147760

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

LOG: [lldb] Remove ConstString from GetPluginNameStatic of some plugins

This patch deals with ObjectFile, ObjectContainer and OperatingSystem
plugins. I'll convert the other types in separate patches.

In order to enable piecemeal conversion, I am leaving some ConstStrings
in the lowest PluginManager layers. I'll convert those as the last step.

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

Added: 


Modified: 
lldb/include/lldb/Core/PluginManager.h
lldb/source/API/SBProcess.cpp
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Core/PluginManager.cpp

lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h

lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp

lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h
lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.cpp
lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.h
lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp
lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.h
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
lldb/source/Target/OperatingSystem.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index 2bee2edea6360..122c63183db27 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -121,7 +121,7 @@ class PluginManager {
   GetEmulateInstructionCreateCallbackForPluginName(ConstString name);
 
   // OperatingSystem
-  static bool RegisterPlugin(ConstString name, const char *description,
+  static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  OperatingSystemCreateInstance create_callback,
  DebuggerInitializeCallback 
debugger_init_callback);
 
@@ -131,7 +131,7 @@ class PluginManager {
   GetOperatingSystemCreateCallbackAtIndex(uint32_t idx);
 
   static OperatingSystemCreateInstance
-  GetOperatingSystemCreateCallbackForPluginName(ConstString name);
+  GetOperatingSystemCreateCallbackForPluginName(llvm::StringRef name);
 
   // Language
   static bool RegisterPlugin(ConstString name, const char *description,
@@ -170,7 +170,7 @@ class PluginManager {
 
   // ObjectFile
   static bool
-  RegisterPlugin(ConstString name, const char *description,
+  RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  ObjectFileCreateInstance create_callback,
  ObjectFileCreateMemoryInstance create_memory_callback,
  ObjectFileGetModuleSpecifications get_module_specifications,
@@ -188,16 +188,16 @@ class PluginManager {
   GetObjectFileGetModuleSpecificationsCallbackAtIndex(uint32_t idx);
 
   static ObjectFileCreateMemoryInstance
-  GetObjectFileCreateMemoryCallbackForPluginName(ConstString name);
+  GetObjectFileCreateMemoryCallbackForPluginName(llvm::StringRef name);
 
   static Status SaveCore(const lldb::ProcessSP _sp,
  const FileSpec ,
  lldb::SaveCoreStyle _style,
- const ConstString plugin_name);
+ llvm::StringRef plugin_name);
 
   // ObjectContainer
   static bool
-  RegisterPlugin(ConstString name, const char *description,
+  RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  ObjectContainerCreateInstance create_callback,
  ObjectFileGetModuleSpecifications get_module_specifications);
 

diff  --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp
index acdf75a603160..797e19462800c 100644
--- a/lldb/source/API/SBProcess.cpp
+++ 

[Lldb-commits] [PATCH] D112212: [lldb/test] Print build commands in trace mode

2021-10-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:1425
+try:
+proc = run(cmd, stdin=DEVNULL, stdout=PIPE, stderr=STDOUT,
+check=True)

PSA: this function is available from python-3.5 onwards.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112212

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


[Lldb-commits] [PATCH] D112212: [lldb/test] Print build commands in trace mode

2021-10-21 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: teemperor, JDevlieghere.
labath requested review of this revision.
Herald added a project: LLDB.

Running tests with -t prints all lldb commands being run. It makes sense
to print all the build commands as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112212

Files:
  lldb/packages/Python/lldbsuite/test/builders/builder.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test_event/build_exception.py

Index: lldb/packages/Python/lldbsuite/test_event/build_exception.py
===
--- lldb/packages/Python/lldbsuite/test_event/build_exception.py
+++ lldb/packages/Python/lldbsuite/test_event/build_exception.py
@@ -1,10 +1,11 @@
+import shlex
+
 class BuildError(Exception):
 
 def __init__(self, called_process_error):
 super(BuildError, self).__init__("Error when building test subject")
-self.command = called_process_error.lldb_extensions.get(
-"command", "")
-self.build_error = called_process_error.lldb_extensions["combined_output"]
+self.command = shlex.join(called_process_error.cmd)
+self.build_error = called_process_error.output
 
 def __str__(self):
 return self.format_build_error(self.command, self.build_error)
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -45,6 +45,7 @@
 import re
 import shutil
 import signal
+import shlex
 from subprocess import *
 import sys
 import time
@@ -68,6 +69,7 @@
 from lldbsuite.support import encoded_file
 from lldbsuite.support import funcutils
 from lldbsuite.test.builders import get_builder
+from lldbsuite.test_event import build_exception
 
 # See also dotest.parseOptionsAndInitTestdirs(), where the environment variables
 # LLDB_COMMAND_TRACE is set from '-t' option.
@@ -469,61 +471,6 @@
 def terminate(self):
 lldb.remote_platform.Kill(self._pid)
 
-# From 2.7's subprocess.check_output() convenience function.
-# Return a tuple (stdoutdata, stderrdata).
-
-
-def system(commands, **kwargs):
-r"""Run an os command with arguments and return its output as a byte string.
-
-If the exit code was non-zero it raises a CalledProcessError.  The
-CalledProcessError object will have the return code in the returncode
-attribute and output in the output attribute.
-
-The arguments are the same as for the Popen constructor.  Example:
-
->>> check_output(["ls", "-l", "/dev/null"])
-'crw-rw-rw- 1 root root 1, 3 Oct 18  2007 /dev/null\n'
-
-The stdout argument is not allowed as it is used internally.
-To capture standard error in the result, use stderr=STDOUT.
-
->>> check_output(["/bin/sh", "-c",
-...   "ls -l non_existent_file ; exit 0"],
-...  stderr=STDOUT)
-'ls: non_existent_file: No such file or directory\n'
-"""
-
-output = ""
-error = ""
-for shellCommand in commands:
-if 'stdout' in kwargs:
-raise ValueError(
-'stdout argument not allowed, it will be overridden.')
-process = Popen(
-shellCommand,
-stdout=PIPE,
-stderr=STDOUT,
-**kwargs)
-pid = process.pid
-this_output, this_error = process.communicate()
-retcode = process.poll()
-
-if retcode:
-cmd = kwargs.get("args")
-if cmd is None:
-cmd = shellCommand
-cpe = CalledProcessError(retcode, cmd)
-# Ensure caller can access the stdout/stderr.
-cpe.lldb_extensions = {
-"combined_output": this_output,
-"command": shellCommand
-}
-raise cpe
-output = output + this_output.decode("utf-8", errors='ignore')
-return output
-
-
 def getsource_if_available(obj):
 """
 Return the text of the source code for an object if available.  Otherwise,
@@ -1334,11 +1281,10 @@
 Supports: llvm, clang.
 """
 compiler = self.getCompilerBinary()
-version_output = system([[compiler, "--version"]])
-for line in version_output.split(os.linesep):
-m = re.search('version ([0-9.]+)', line)
-if m:
-return m.group(1)
+version_output = check_output([compiler, "--version"])
+m = re.search(b'version ([0-9.]+)', version_output)
+if m:
+return m.group(1).decode(errors="replace")
 return 'unknown'
 
 def getDwarfVersion(self):
@@ -1465,9 +1411,23 @@
 testname = self.getBuildDirBasename()
 
 module = builder_module()
-if not module.build(debug_info, architecture, compiler, dictionary,
-testdir, testname):
+

[Lldb-commits] [PATCH] D110571: [lldb] Add omitted abstract formal parameters in DWARF symbol files

2021-10-21 Thread Jaroslav Sevcik via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5a3556aa5563: [lldb] Add omitted abstract formal parameters 
in DWARF symbol files (authored by Jaroslav Sevcik ja...@chromium.org, 
committed by jarin).

Changed prior to commit:
  https://reviews.llvm.org/D110571?vs=377020=381197#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110571

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/test/API/functionalities/unused-inlined-parameters/Makefile
  
lldb/test/API/functionalities/unused-inlined-parameters/TestUnusedInlinedParameters.py
  lldb/test/API/functionalities/unused-inlined-parameters/main.c
  lldb/test/Shell/SymbolFile/DWARF/x86/Inputs/unused-inlined-params.s
  lldb/test/Shell/SymbolFile/DWARF/x86/unused-inlined-params.test

Index: lldb/test/Shell/SymbolFile/DWARF/x86/unused-inlined-params.test
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/unused-inlined-params.test
@@ -0,0 +1,48 @@
+# RUN: llvm-mc -filetype=obj %S/Inputs/unused-inlined-params.s \
+# RUN: -triple x86_64-pc-linux -o %t.o
+# RUN: %lldb %t.o -s %s -o exit | FileCheck %s
+
+
+# In this test we verify that inlined functions still mention
+# all their parameters in `frame variable`, even when those
+# parameters were completely optimized away from the concrete
+# instance of the inlined function in the debug info.
+# The debugger should look up the parameters in the abstract
+# origin of the concrete instance.
+
+# Let us check that unused parameters of an inlined function are listed
+# at the inlined function entry.
+image lookup -v -s break_at_inlined_f_in_main
+# CHECK-LABEL: image lookup -v -s break_at_inlined_f_in_main
+# CHECK: name = "unused1", type = "void *", location = 
+# CHECK: name = "used", type = "int", location = DW_OP_consts +42
+# CHECK: name = "unused2", type = "int", location = 
+# CHECK: name = "partial", type = "int", location = DW_OP_reg4 RSI
+# CHECK: name = "unused3", type = "int", location = 
+
+# Show variables outsid of the live range of the 'partial' parameter
+# and verify that the output is as expected.
+image lookup -v -s break_at_inlined_f_in_main_between_printfs
+# CHECK-LABEL: image lookup -v -s break_at_inlined_f_in_main_between_printfs
+# CHECK: name = "unused1", type = "void *", location = 
+# CHECK: name = "used", type = "int", location = DW_OP_reg3 RBX
+# CHECK: name = "unused2", type = "int", location = 
+# Note: image lookup does not show variables outside of their
+#   location, so |partial| is missing here.
+# CHECK-NOT: partial
+# CHECK: name = "unused3", type = "int", location = 
+
+# Check that we show parameters even if all of them are compiled away.
+image lookup -v -s  break_at_inlined_g_in_main
+# CHECK-LABEL: image lookup -v -s  break_at_inlined_g_in_main
+# CHECK: name = "unused", type = "int", location = 
+
+# Check that even the other inlined instance of f displays the correct
+# parameters.
+image lookup -v -s  break_at_inlined_f_in_other
+# CHECK-LABEL: image lookup -v -s  break_at_inlined_f_in_other
+# CHECK: name = "unused1", type = "void *", location = 
+# CHECK: name = "used", type = "int", location = DW_OP_consts +1
+# CHECK: name = "unused2", type = "int", location = 
+# CHECK: name = "partial", type = "int", location =  DW_OP_consts +2
+# CHECK: name = "unused3", type = "int", location = 
Index: lldb/test/Shell/SymbolFile/DWARF/x86/Inputs/unused-inlined-params.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/Inputs/unused-inlined-params.s
@@ -0,0 +1,458 @@
+# The below program is roughly derived from the following C program.
+# To see the annotated debug info, look for the section 
+# '.section.debug_info' below.
+#
+# __attribute__((always_inline))
+# void f(void* unused1, int used, int unused2, int partial, int unused3) {
+#   used += partial;
+#   printf("f %i", partial);
+#   printf("f %i", used);   // |partial| is not live at this line.
+# }
+#
+# void g(int unused) {
+#   printf("Hello");
+# }
+#
+# __attribute__((noinline))
+# void other() {
+#   f(nullptr, 1, 0, 2, 0);
+# }
+#
+# int main(int argc, char** argv) {
+#   f(argv, 42, 1, argc, 2);
+#   g(1);
+#   other();
+#   return 0;
+# }
+
+.text
+.file"unused-inlined-params.c"
+
+.Lcu_begin:
+
+.globlother
+other:
+nop
+.Linlined_f_in_other:
+break_at_inlined_f_in_other:
+callqprintf# Omitted the setup of arguments.
+.Linlined_f_in_other_between_printfs:
+callqprintf# Omitted the setup of arguments.
+.Linlined_f_in_other_end:
+retq
+.Lother_end:
+.sizeother, .Lother_end-other
+
+.globlmain
+main:
+.file1 "/example" "unused-inlined-params.c"
+movl$1, %esi

[Lldb-commits] [lldb] 5a3556a - [lldb] Add omitted abstract formal parameters in DWARF symbol files

2021-10-21 Thread Jaroslav Sevcik via lldb-commits

Author: Jaroslav Sevcik
Date: 2021-10-21T12:33:42+02:00
New Revision: 5a3556aa5563fb89693935303463881df44094de

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

LOG: [lldb] Add omitted abstract formal parameters in DWARF symbol files

This patch fixes a problem introduced by clang change
https://reviews.llvm.org/D95617 and described by
https://bugs.llvm.org/show_bug.cgi?id=50076#c6, where inlined functions
omit unused parameters both in the stack trace and in `frame var`
command. With this patch, the parameters are listed correctly in the
stack trace and in `frame var` command.

Specifically, we parse formal parameters from the abstract version of
inlined functions and use those formal parameters if they are missing
from the concrete version.

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

Added: 
lldb/test/API/functionalities/unused-inlined-parameters/Makefile

lldb/test/API/functionalities/unused-inlined-parameters/TestUnusedInlinedParameters.py
lldb/test/API/functionalities/unused-inlined-parameters/main.c
lldb/test/Shell/SymbolFile/DWARF/x86/Inputs/unused-inlined-params.s
lldb/test/Shell/SymbolFile/DWARF/x86/unused-inlined-params.test

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

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 9078fa3cdc268..90b07ad061b05 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3092,7 +3092,7 @@ size_t SymbolFileDWARF::ParseVariablesForContext(const 
SymbolContext ) {
 sc.comp_unit->SetVariableList(variables);
 
 m_index->GetGlobalVariables(*dwarf_cu, [&](DWARFDIE die) {
-  VariableSP var_sp(ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS));
+  VariableSP var_sp(ParseVariableDIECached(sc, die));
   if (var_sp) {
 variables->AddVariableIfUnique(var_sp);
 ++vars_added;
@@ -3106,6 +3106,26 @@ size_t SymbolFileDWARF::ParseVariablesForContext(const 
SymbolContext ) {
   return 0;
 }
 
+VariableSP SymbolFileDWARF::ParseVariableDIECached(const SymbolContext ,
+   const DWARFDIE ) {
+  if (!die)
+return nullptr;
+
+  DIEToVariableSP _to_variable = die.GetDWARF()->GetDIEToVariable();
+
+  VariableSP var_sp = die_to_variable[die.GetDIE()];
+  if (var_sp)
+return var_sp;
+
+  var_sp = ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS);
+  if (var_sp) {
+die_to_variable[die.GetDIE()] = var_sp;
+if (DWARFDIE spec_die = die.GetReferencedDIE(DW_AT_specification))
+  die_to_variable[spec_die.GetDIE()] = var_sp;
+  }
+  return var_sp;
+}
+
 VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext ,
  const DWARFDIE ,
  const lldb::addr_t func_low_pc) {
@@ -3115,9 +3135,6 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const 
SymbolContext ,
   if (!die)
 return nullptr;
 
-  if (VariableSP var_sp = GetDIEToVariable()[die.GetDIE()])
-return var_sp; // Already been parsed!
-
   const dw_tag_t tag = die.Tag();
   ModuleSP module = GetObjectFile()->GetModule();
 
@@ -3127,8 +3144,6 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const 
SymbolContext ,
 
   DWARFAttributes attributes;
   const size_t num_attributes = die.GetAttributes(attributes);
-  DWARFDIE spec_die;
-  VariableSP var_sp;
   const char *name = nullptr;
   const char *mangled = nullptr;
   Declaration decl;
@@ -3175,9 +3190,6 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const 
SymbolContext ,
 case DW_AT_location:
   location_form = form_value;
   break;
-case DW_AT_specification:
-  spec_die = form_value.Reference();
-  break;
 case DW_AT_start_scope:
   // TODO: Implement this.
   break;
@@ -3188,6 +3200,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const 
SymbolContext ,
 case DW_AT_description:
 case DW_AT_endianity:
 case DW_AT_segment:
+case DW_AT_specification:
 case DW_AT_visibility:
 default:
 case DW_AT_abstract_origin:
@@ -3380,7 +3393,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const 
SymbolContext ,
 location.Update_DW_OP_addr(exe_file_addr);
   } else {
 // Variable didn't make it into the final executable
-return var_sp;
+return nullptr;
   }
 }
   }
@@ -3426,35 +3439,25 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const 
SymbolContext ,
 }
   }
 
-  if (symbol_context_scope) {
-auto type_sp = 

[Lldb-commits] [PATCH] D110535: [llvm] [ADT] Update llvm::Split() per Pavel Labath's suggestions

2021-10-21 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 381189.
mgorny added a comment.

Update LLDB call sites again.


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

https://reviews.llvm.org/D110535

Files:
  lldb/source/Host/common/File.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  llvm/include/llvm/ADT/StringExtras.h
  llvm/lib/IR/DataLayout.cpp
  llvm/unittests/ADT/StringExtrasTest.cpp

Index: llvm/unittests/ADT/StringExtrasTest.cpp
===
--- llvm/unittests/ADT/StringExtrasTest.cpp
+++ llvm/unittests/ADT/StringExtrasTest.cpp
@@ -276,7 +276,7 @@
 }
 
 TEST(StringExtrasTest, splitStringRef) {
-  auto Spl = Split("foo<=>bar<=><=>baz", "<=>");
+  auto Spl = split("foo<=>bar<=><=>baz", "<=>");
   auto It = Spl.begin();
   auto End = Spl.end();
 
@@ -291,8 +291,8 @@
   ASSERT_EQ(++It, End);
 }
 
-TEST(StringExtrasTest, splItChar) {
-  auto Spl = Split("foo,bar,,baz", ',');
+TEST(StringExtrasTest, splitChar) {
+  auto Spl = split("foo,bar,,baz", ',');
   auto It = Spl.begin();
   auto End = Spl.end();
 
Index: llvm/lib/IR/DataLayout.cpp
===
--- llvm/lib/IR/DataLayout.cpp
+++ llvm/lib/IR/DataLayout.cpp
@@ -260,12 +260,12 @@
   while (!Desc.empty()) {
 // Split at '-'.
 std::pair Split;
-if (Error Err = split(Desc, '-', Split))
+if (Error Err = ::split(Desc, '-', Split))
   return Err;
 Desc = Split.second;
 
 // Split at ':'.
-if (Error Err = split(Split.first, ':', Split))
+if (Error Err = ::split(Split.first, ':', Split))
   return Err;
 
 // Aliases used below.
@@ -274,7 +274,7 @@
 
 if (Tok == "ni") {
   do {
-if (Error Err = split(Rest, ':', Split))
+if (Error Err = ::split(Rest, ':', Split))
   return Err;
 Rest = Split.second;
 unsigned AS;
@@ -315,7 +315,7 @@
   if (Rest.empty())
 return reportError(
 "Missing size specification for pointer in datalayout string");
-  if (Error Err = split(Rest, ':', Split))
+  if (Error Err = ::split(Rest, ':', Split))
 return Err;
   unsigned PointerMemSize;
   if (Error Err = getIntInBytes(Tok, PointerMemSize))
@@ -327,7 +327,7 @@
   if (Rest.empty())
 return reportError(
 "Missing alignment specification for pointer in datalayout string");
-  if (Error Err = split(Rest, ':', Split))
+  if (Error Err = ::split(Rest, ':', Split))
 return Err;
   unsigned PointerABIAlign;
   if (Error Err = getIntInBytes(Tok, PointerABIAlign))
@@ -342,7 +342,7 @@
   // Preferred alignment.
   unsigned PointerPrefAlign = PointerABIAlign;
   if (!Rest.empty()) {
-if (Error Err = split(Rest, ':', Split))
+if (Error Err = ::split(Rest, ':', Split))
   return Err;
 if (Error Err = getIntInBytes(Tok, PointerPrefAlign))
   return Err;
@@ -352,7 +352,7 @@
 
 // Now read the index. It is the second optional parameter here.
 if (!Rest.empty()) {
-  if (Error Err = split(Rest, ':', Split))
+  if (Error Err = ::split(Rest, ':', Split))
 return Err;
   if (Error Err = getIntInBytes(Tok, IndexSize))
 return Err;
@@ -393,7 +393,7 @@
   if (Rest.empty())
 return reportError(
 "Missing alignment specification in datalayout string");
-  if (Error Err = split(Rest, ':', Split))
+  if (Error Err = ::split(Rest, ':', Split))
 return Err;
   unsigned ABIAlign;
   if (Error Err = getIntInBytes(Tok, ABIAlign))
@@ -410,7 +410,7 @@
   // Preferred alignment.
   unsigned PrefAlign = ABIAlign;
   if (!Rest.empty()) {
-if (Error Err = split(Rest, ':', Split))
+if (Error Err = ::split(Rest, ':', Split))
   return Err;
 if (Error Err = getIntInBytes(Tok, PrefAlign))
   return Err;
@@ -439,7 +439,7 @@
 LegalIntWidths.push_back(Width);
 if (Rest.empty())
   break;
-if (Error Err = split(Rest, ':', Split))
+if (Error Err = ::split(Rest, ':', Split))
   return Err;
   }
   break;
Index: llvm/include/llvm/ADT/StringExtras.h
===
--- llvm/include/llvm/ADT/StringExtras.h
+++ llvm/include/llvm/ADT/StringExtras.h
@@ -505,6 +505,7 @@
 class SplittingIterator
 : public iterator_facade_base {
+  char SeparatorStorage;
   StringRef Current;
   StringRef Next;
   StringRef Separator;
@@ -515,8 +516,15 @@
 ++*this;
   }
 
+  SplittingIterator(StringRef Str, char Separator)
+  : SeparatorStorage(Separator), Next(Str),
+Separator(, 1) {
+++*this;
+  }
+
   bool operator==(const SplittingIterator ) 

[Lldb-commits] [PATCH] D110535: [llvm] [ADT] Update llvm::Split() per Pavel Labath's suggestions

2021-10-21 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 381187.
mgorny edited the summary of this revision.
mgorny added a comment.

Restored support for `char Separator` — after all, it isn't hard and the cost 
is negligible.


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

https://reviews.llvm.org/D110535

Files:
  llvm/include/llvm/ADT/StringExtras.h
  llvm/lib/IR/DataLayout.cpp
  llvm/unittests/ADT/StringExtrasTest.cpp

Index: llvm/unittests/ADT/StringExtrasTest.cpp
===
--- llvm/unittests/ADT/StringExtrasTest.cpp
+++ llvm/unittests/ADT/StringExtrasTest.cpp
@@ -276,7 +276,7 @@
 }
 
 TEST(StringExtrasTest, splitStringRef) {
-  auto Spl = Split("foo<=>bar<=><=>baz", "<=>");
+  auto Spl = split("foo<=>bar<=><=>baz", "<=>");
   auto It = Spl.begin();
   auto End = Spl.end();
 
@@ -291,8 +291,8 @@
   ASSERT_EQ(++It, End);
 }
 
-TEST(StringExtrasTest, splItChar) {
-  auto Spl = Split("foo,bar,,baz", ',');
+TEST(StringExtrasTest, splitChar) {
+  auto Spl = split("foo,bar,,baz", ',');
   auto It = Spl.begin();
   auto End = Spl.end();
 
Index: llvm/lib/IR/DataLayout.cpp
===
--- llvm/lib/IR/DataLayout.cpp
+++ llvm/lib/IR/DataLayout.cpp
@@ -260,12 +260,12 @@
   while (!Desc.empty()) {
 // Split at '-'.
 std::pair Split;
-if (Error Err = split(Desc, '-', Split))
+if (Error Err = ::split(Desc, '-', Split))
   return Err;
 Desc = Split.second;
 
 // Split at ':'.
-if (Error Err = split(Split.first, ':', Split))
+if (Error Err = ::split(Split.first, ':', Split))
   return Err;
 
 // Aliases used below.
@@ -274,7 +274,7 @@
 
 if (Tok == "ni") {
   do {
-if (Error Err = split(Rest, ':', Split))
+if (Error Err = ::split(Rest, ':', Split))
   return Err;
 Rest = Split.second;
 unsigned AS;
@@ -315,7 +315,7 @@
   if (Rest.empty())
 return reportError(
 "Missing size specification for pointer in datalayout string");
-  if (Error Err = split(Rest, ':', Split))
+  if (Error Err = ::split(Rest, ':', Split))
 return Err;
   unsigned PointerMemSize;
   if (Error Err = getIntInBytes(Tok, PointerMemSize))
@@ -327,7 +327,7 @@
   if (Rest.empty())
 return reportError(
 "Missing alignment specification for pointer in datalayout string");
-  if (Error Err = split(Rest, ':', Split))
+  if (Error Err = ::split(Rest, ':', Split))
 return Err;
   unsigned PointerABIAlign;
   if (Error Err = getIntInBytes(Tok, PointerABIAlign))
@@ -342,7 +342,7 @@
   // Preferred alignment.
   unsigned PointerPrefAlign = PointerABIAlign;
   if (!Rest.empty()) {
-if (Error Err = split(Rest, ':', Split))
+if (Error Err = ::split(Rest, ':', Split))
   return Err;
 if (Error Err = getIntInBytes(Tok, PointerPrefAlign))
   return Err;
@@ -352,7 +352,7 @@
 
 // Now read the index. It is the second optional parameter here.
 if (!Rest.empty()) {
-  if (Error Err = split(Rest, ':', Split))
+  if (Error Err = ::split(Rest, ':', Split))
 return Err;
   if (Error Err = getIntInBytes(Tok, IndexSize))
 return Err;
@@ -393,7 +393,7 @@
   if (Rest.empty())
 return reportError(
 "Missing alignment specification in datalayout string");
-  if (Error Err = split(Rest, ':', Split))
+  if (Error Err = ::split(Rest, ':', Split))
 return Err;
   unsigned ABIAlign;
   if (Error Err = getIntInBytes(Tok, ABIAlign))
@@ -410,7 +410,7 @@
   // Preferred alignment.
   unsigned PrefAlign = ABIAlign;
   if (!Rest.empty()) {
-if (Error Err = split(Rest, ':', Split))
+if (Error Err = ::split(Rest, ':', Split))
   return Err;
 if (Error Err = getIntInBytes(Tok, PrefAlign))
   return Err;
@@ -439,7 +439,7 @@
 LegalIntWidths.push_back(Width);
 if (Rest.empty())
   break;
-if (Error Err = split(Rest, ':', Split))
+if (Error Err = ::split(Rest, ':', Split))
   return Err;
   }
   break;
Index: llvm/include/llvm/ADT/StringExtras.h
===
--- llvm/include/llvm/ADT/StringExtras.h
+++ llvm/include/llvm/ADT/StringExtras.h
@@ -505,6 +505,7 @@
 class SplittingIterator
 : public iterator_facade_base {
+  char SeparatorStorage;
   StringRef Current;
   StringRef Next;
   StringRef Separator;
@@ -515,8 +516,15 @@
 ++*this;
   }
 
+  SplittingIterator(StringRef Str, char Separator)
+  : SeparatorStorage(Separator), Next(Str),
+Separator(, 1) {
+++*this;
+  }
+
   bool operator==(const SplittingIterator ) const {
-return Current == R.Current && Next == R.Next && Separator == R.Separator;
+assert(Separator == R.Separator);
+return 

[Lldb-commits] [PATCH] D112163: Enable libc++ in the build for libcxx initializerlist pretty printers

2021-10-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

There is one on Green Dragon with a few Clang versions 
 and I there 
is my Linux one with a all GCC/Clang versions 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112163

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


[Lldb-commits] [lldb] b8c3683 - [lldb] [Host/SerialPort] Add std::moves for better compatibility

2021-10-21 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-21T11:08:05+02:00
New Revision: b8c3683d46f92a693746217542ab4895562fa36c

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

LOG: [lldb] [Host/SerialPort] Add std::moves for better compatibility

Added: 


Modified: 
lldb/source/Host/common/File.cpp

Removed: 




diff  --git a/lldb/source/Host/common/File.cpp 
b/lldb/source/Host/common/File.cpp
index 68543535687a..1c8a0ab7f83e 100644
--- a/lldb/source/Host/common/File.cpp
+++ b/lldb/source/Host/common/File.cpp
@@ -821,20 +821,20 @@ SerialPort::Create(int fd, OpenOptions options, Options 
serial_options,
 
   Terminal term{fd};
   if (llvm::Error error = term.SetRaw())
-return error;
+return std::move(error);
   if (serial_options.BaudRate) {
 if (llvm::Error error =
 term.SetBaudRate(serial_options.BaudRate.getValue()))
-  return error;
+  return std::move(error);
   }
   if (serial_options.Parity) {
 if (llvm::Error error = term.SetParity(serial_options.Parity.getValue()))
-  return error;
+  return std::move(error);
   }
   if (serial_options.StopBits) {
 if (llvm::Error error =
 term.SetStopBits(serial_options.StopBits.getValue()))
-  return error;
+  return std::move(error);
   }
 
   return out;



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


[Lldb-commits] [lldb] cbe7898 - [lldb] [Host/Terminal] Add missing #ifdef for baudRateToConst()

2021-10-21 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-21T11:00:17+02:00
New Revision: cbe789844703fe72d45b15614fa3b350e76f8570

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

LOG: [lldb] [Host/Terminal] Add missing #ifdef for baudRateToConst()

Added: 


Modified: 
lldb/source/Host/common/Terminal.cpp

Removed: 




diff  --git a/lldb/source/Host/common/Terminal.cpp 
b/lldb/source/Host/common/Terminal.cpp
index 6b7c2821d378..23cd1dea114b 100644
--- a/lldb/source/Host/common/Terminal.cpp
+++ b/lldb/source/Host/common/Terminal.cpp
@@ -112,6 +112,7 @@ llvm::Error Terminal::SetRaw() {
 #endif // #if LLDB_ENABLE_TERMIOS
 }
 
+#if LLDB_ENABLE_TERMIOS
 static llvm::Optional baudRateToConst(unsigned int baud_rate) {
   switch (baud_rate) {
 #if defined(B50)
@@ -254,6 +255,7 @@ static llvm::Optional baudRateToConst(unsigned int 
baud_rate) {
 return llvm::None;
   }
 }
+#endif
 
 llvm::Error Terminal::SetBaudRate(unsigned int baud_rate) {
   llvm::Expected data = GetData();



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


[Lldb-commits] [PATCH] D112163: Enable libc++ in the build for libcxx initializerlist pretty printers

2021-10-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D112163#3077124 , @dblaikie wrote:

> In D112163#3077112 , @teemperor 
> wrote:
>
>> LGTM, thanks!
>>
>> Tests with libc++ as a category are not run on Windows or when GCC is the 
>> test compiler, so those decorators are redundant. Removing the Clang XFAIL 
>> also seems fine, I would just see if any matrix bot complains and then 
>> re-apply it with a proper minimum required version.
>
> "matrix bot"? One of the buildbots/group of them?

It's a single bot that runs the test suite against a variety of compilers 
(well, only various versions of clang, I think)...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112163

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


[Lldb-commits] [lldb] 4745e41 - [lldb] [unittest] Disable SetParity() tests on Linux entirely

2021-10-21 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-21T10:55:02+02:00
New Revision: 4745e4178397b387263f2547e13018e3c8ee396c

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

LOG: [lldb] [unittest] Disable SetParity() tests on Linux entirely

Attempting to enable PARENB causes tcsetattr() to fail on the Debian
and Ubuntu buildbots, so let's skip these tests on Linux entirely.

Added: 


Modified: 
lldb/unittests/Host/posix/TerminalTest.cpp

Removed: 




diff  --git a/lldb/unittests/Host/posix/TerminalTest.cpp 
b/lldb/unittests/Host/posix/TerminalTest.cpp
index 4a81bea88d9e..0313007f89e1 100644
--- a/lldb/unittests/Host/posix/TerminalTest.cpp
+++ b/lldb/unittests/Host/posix/TerminalTest.cpp
@@ -143,12 +143,11 @@ TEST_F(TerminalTest, SetParity) {
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
   EXPECT_EQ(terminfo.c_cflag & PARENB, 0U);
 
+#if !defined(__linux__) // Linux pty devices do not support setting parity
   ASSERT_THAT_ERROR(m_term.SetParity(Terminal::Parity::Even),
 llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
-#if !defined(__linux__) // Linux pty devices strip PARENB
   EXPECT_NE(terminfo.c_cflag & PARENB, 0U);
-#endif
   EXPECT_EQ(terminfo.c_cflag & PARODD, 0U);
 #if defined(CMSPAR)
   EXPECT_EQ(terminfo.c_cflag & CMSPAR, 0U);
@@ -156,9 +155,7 @@ TEST_F(TerminalTest, SetParity) {
 
   ASSERT_THAT_ERROR(m_term.SetParity(Terminal::Parity::Odd), 
llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
-#if !defined(__linux__) // Linux pty devices strip PARENB
   EXPECT_NE(terminfo.c_cflag & PARENB, 0U);
-#endif
   EXPECT_NE(terminfo.c_cflag & PARODD, 0U);
 #if defined(CMSPAR)
   EXPECT_EQ(terminfo.c_cflag & CMSPAR, 0U);
@@ -168,21 +165,20 @@ TEST_F(TerminalTest, SetParity) {
   ASSERT_THAT_ERROR(m_term.SetParity(Terminal::Parity::Space),
 llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
-#if !defined(__linux__) // Linux pty devices strip PARENB
   EXPECT_NE(terminfo.c_cflag & PARENB, 0U);
-#endif
   EXPECT_EQ(terminfo.c_cflag & PARODD, 0U);
   EXPECT_NE(terminfo.c_cflag & CMSPAR, 0U);
 
   ASSERT_THAT_ERROR(m_term.SetParity(Terminal::Parity::Mark),
 llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
-#if !defined(__linux__) // Linux pty devices strip PARENB
   EXPECT_NE(terminfo.c_cflag & PARENB, 0U);
-#endif
   EXPECT_NE(terminfo.c_cflag & PARODD, 0U);
   EXPECT_NE(terminfo.c_cflag & CMSPAR, 0U);
-#else
+#endif // defined(CMSPAR)
+#endif // !defined(__linux__)
+
+#if !defined(CMSPAR)
   ASSERT_THAT_ERROR(m_term.SetParity(Terminal::Parity::Space),
 llvm::Failed(testing::Property(
 ::ErrorInfoBase::message,



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


[Lldb-commits] [PATCH] D111355: [lldb] Add serial:// protocol for connecting to serial port

2021-10-21 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4a7b4beac759: [lldb] Add serial:// protocol for connecting 
to serial port (authored by mgorny).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D111355?vs=380985=381178#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111355

Files:
  lldb/include/lldb/Host/File.h
  lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
  lldb/source/Host/common/File.cpp
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestPty.py
  lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py

Index: lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
===
--- lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
+++ lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
@@ -427,7 +427,7 @@
 return libc.ptsname(self._master.fileno()).decode()
 
 def get_connect_url(self):
-return "file://" + self.get_connect_address()
+return "serial://" + self.get_connect_address()
 
 def close_server(self):
 self._slave.close()
Index: lldb/test/API/functionalities/gdb_remote_client/TestPty.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestPty.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestPty.py
@@ -9,6 +9,38 @@
 mydir = TestBase.compute_mydir(__file__)
 server_socket_class = PtyServerSocket
 
+def get_term_attrs(self):
+import termios
+return termios.tcgetattr(self.server._socket._slave)
+
+def setUp(self):
+super().setUp()
+self.orig_attr = self.get_term_attrs()
+
+def assert_raw_mode(self, current_attr):
+import termios
+self.assertEqual(current_attr[0] & (termios.BRKINT |
+termios.PARMRK |
+termios.ISTRIP | termios.INLCR |
+termios.IGNCR | termios.ICRNL |
+termios.IXON),
+ 0)
+self.assertEqual(current_attr[1] & termios.OPOST, 0)
+self.assertEqual(current_attr[2] & termios.CSIZE, termios.CS8)
+self.assertEqual(current_attr[3] & (termios.ICANON | termios.ECHO |
+termios.ISIG | termios.IEXTEN),
+ 0)
+self.assertEqual(current_attr[6][termios.VMIN], 1)
+self.assertEqual(current_attr[6][termios.VTIME], 0)
+
+def get_parity_flags(self, attr):
+import termios
+return attr[2] & (termios.PARENB | termios.PARODD)
+
+def get_stop_bit_flags(self, attr):
+import termios
+return attr[2] & termios.CSTOPB
+
 def test_process_connect_sync(self):
 """Test the process connect command in synchronous mode"""
 try:
@@ -17,8 +49,20 @@
 substrs=['Platform: remote-gdb-server', 'Connected: no'])
 self.expect("process connect " + self.server.get_connect_url(),
 substrs=['Process', 'stopped'])
+
+current_attr = self.get_term_attrs()
+# serial:// should set raw mode
+self.assert_raw_mode(current_attr)
+# other parameters should be unmodified
+self.assertEqual(current_attr[4:6], self.orig_attr[4:6])
+self.assertEqual(self.get_parity_flags(current_attr),
+ self.get_parity_flags(self.orig_attr))
+self.assertEqual(self.get_stop_bit_flags(current_attr),
+ self.get_stop_bit_flags(self.orig_attr))
 finally:
 self.dbg.GetSelectedTarget().GetProcess().Kill()
+# original mode should be restored on exit
+self.assertEqual(self.get_term_attrs(), self.orig_attr)
 
 def test_process_connect_async(self):
 """Test the process connect command in asynchronous mode"""
@@ -31,7 +75,63 @@
 substrs=['Process', 'stopped'])
 lldbutil.expect_state_changes(self, self.dbg.GetListener(),
   self.process(), [lldb.eStateStopped])
+
+current_attr = self.get_term_attrs()
+# serial:// should set raw mode
+self.assert_raw_mode(current_attr)
+# other parameters should be unmodified
+self.assertEqual(current_attr[4:6], self.orig_attr[4:6])
+self.assertEqual(self.get_parity_flags(current_attr),
+ self.get_parity_flags(self.orig_attr))
+self.assertEqual(self.get_stop_bit_flags(current_attr),
+ 

[Lldb-commits] [lldb] 4a7b4be - [lldb] Add serial:// protocol for connecting to serial port

2021-10-21 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-21T10:46:45+02:00
New Revision: 4a7b4beac759ad9001671a61846ee2bfc9076eec

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

LOG: [lldb] Add serial:// protocol for connecting to serial port

Add a new serial:// protocol along with SerialPort that provides a new
API to open serial ports.  The URL consists of serial device path
followed by URL-style options, e.g.:

serial:///dev/ttyS0?baud=115200=even

If no options are provided, the serial port is only set to raw mode
and the other attributes remain unchanged.  Attributes provided via
options are modified to the specified values.  Upon closing the serial
port, its original attributes are restored.

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

Added: 


Modified: 
lldb/include/lldb/Host/File.h
lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
lldb/source/Host/common/File.cpp
lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
lldb/test/API/functionalities/gdb_remote_client/TestPty.py
lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py

Removed: 




diff  --git a/lldb/include/lldb/Host/File.h b/lldb/include/lldb/Host/File.h
index b0bc7d9535f6c..c192700590a30 100644
--- a/lldb/include/lldb/Host/File.h
+++ b/lldb/include/lldb/Host/File.h
@@ -10,6 +10,7 @@
 #define LLDB_HOST_FILE_H
 
 #include "lldb/Host/PosixApi.h"
+#include "lldb/Host/Terminal.h"
 #include "lldb/Utility/IOObject.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/lldb-private.h"
@@ -433,6 +434,44 @@ class NativeFile : public File {
   const NativeFile =(const NativeFile &) = delete;
 };
 
+class SerialPort : public NativeFile {
+public:
+  struct Options {
+llvm::Optional BaudRate = llvm::None;
+llvm::Optional Parity = llvm::None;
+llvm::Optional StopBits = llvm::None;
+  };
+
+  // Obtain Options corresponding to the passed URL query string
+  // (i.e. the part after '?').
+  static llvm::Expected OptionsFromURL(llvm::StringRef urlqs);
+
+  static llvm::Expected>
+  Create(int fd, OpenOptions options, Options serial_options,
+ bool transfer_ownership);
+
+  bool IsValid() const override {
+return NativeFile::IsValid() && m_is_interactive == eLazyBoolYes;
+  }
+
+  Status Close() override;
+
+  static char ID;
+  virtual bool isA(const void *classID) const override {
+return classID ==  || File::isA(classID);
+  }
+  static bool classof(const File *file) { return file->isA(); }
+
+private:
+  SerialPort(int fd, OpenOptions options, Options serial_options,
+ bool transfer_ownership);
+
+  SerialPort(const SerialPort &) = delete;
+  const SerialPort =(const SerialPort &) = delete;
+
+  TerminalState m_state;
+};
+
 } // namespace lldb_private
 
 #endif // LLDB_HOST_FILE_H

diff  --git a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h 
b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
index 720c019c5a019..7500ec63707b1 100644
--- a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
+++ b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
@@ -88,6 +88,9 @@ class ConnectionFileDescriptor : public Connection {
 
   lldb::ConnectionStatus ConnectFile(llvm::StringRef args, Status *error_ptr);
 
+  lldb::ConnectionStatus ConnectSerialPort(llvm::StringRef args,
+   Status *error_ptr);
+
   lldb::IOObjectSP m_io_sp;
 
   Predicate

diff  --git a/lldb/source/Host/common/File.cpp 
b/lldb/source/Host/common/File.cpp
index 87ed405c4428a..68543535687a7 100644
--- a/lldb/source/Host/common/File.cpp
+++ b/lldb/source/Host/common/File.cpp
@@ -769,5 +769,87 @@ mode_t File::ConvertOpenOptionsForPOSIXOpen(OpenOptions 
open_options) {
   return mode;
 }
 
+llvm::Expected
+SerialPort::OptionsFromURL(llvm::StringRef urlqs) {
+  SerialPort::Options serial_options;
+  for (llvm::StringRef x : llvm::Split(urlqs, '&')) {
+if (x.consume_front("baud=")) {
+  unsigned int baud_rate;
+  if (!llvm::to_integer(x, baud_rate, 10))
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Invalid baud rate: %s",
+   x.str().c_str());
+  serial_options.BaudRate = baud_rate;
+} else if (x.consume_front("parity=")) {
+  serial_options.Parity =
+  llvm::StringSwitch>(x)
+  .Case("no", Terminal::Parity::No)
+  .Case("even", Terminal::Parity::Even)
+  .Case("odd", Terminal::Parity::Odd)
+  .Case("mark", Terminal::Parity::Mark)
+  .Case("space", Terminal::Parity::Space)
+  .Default(llvm::None);
+  if (!serial_options.Parity)
+return llvm::createStringError(
+

[Lldb-commits] [PATCH] D111030: [lldb] [Host] Add setters for common teletype properties to Terminal

2021-10-21 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG92fb574c9f20: [lldb] [Host] Add setters for common teletype 
properties to Terminal (authored by mgorny).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D111030?vs=380943=381173#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111030

Files:
  lldb/include/lldb/Host/Terminal.h
  lldb/source/Host/common/Terminal.cpp
  lldb/unittests/Host/posix/TerminalTest.cpp

Index: lldb/unittests/Host/posix/TerminalTest.cpp
===
--- lldb/unittests/Host/posix/TerminalTest.cpp
+++ lldb/unittests/Host/posix/TerminalTest.cpp
@@ -72,6 +72,149 @@
   EXPECT_EQ(terminfo.c_lflag & ICANON, 0U);
 }
 
+TEST_F(TerminalTest, SetRaw) {
+  struct termios terminfo;
+
+  ASSERT_THAT_ERROR(m_term.SetRaw(), llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+  // NB: cfmakeraw() on glibc disables IGNBRK, on FreeBSD sets it
+  EXPECT_EQ(terminfo.c_iflag &
+(BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON),
+0U);
+  EXPECT_EQ(terminfo.c_oflag & OPOST, 0U);
+  EXPECT_EQ(terminfo.c_lflag & (ICANON | ECHO | ISIG | IEXTEN), 0U);
+  EXPECT_EQ(terminfo.c_cflag & (CSIZE | PARENB), 0U | CS8);
+  EXPECT_EQ(terminfo.c_cc[VMIN], 1);
+  EXPECT_EQ(terminfo.c_cc[VTIME], 0);
+}
+
+TEST_F(TerminalTest, SetBaudRate) {
+  struct termios terminfo;
+
+  ASSERT_THAT_ERROR(m_term.SetBaudRate(38400), llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+  EXPECT_EQ(cfgetispeed(), static_cast(B38400));
+  EXPECT_EQ(cfgetospeed(), static_cast(B38400));
+
+  ASSERT_THAT_ERROR(m_term.SetBaudRate(115200), llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+  EXPECT_EQ(cfgetispeed(), static_cast(B115200));
+  EXPECT_EQ(cfgetospeed(), static_cast(B115200));
+
+  // uncommon value
+#if defined(B153600)
+  ASSERT_THAT_ERROR(m_term.SetBaudRate(153600), llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+  EXPECT_EQ(cfgetispeed(), static_cast(B153600));
+  EXPECT_EQ(cfgetospeed(), static_cast(B153600));
+#else
+  ASSERT_THAT_ERROR(m_term.SetBaudRate(153600),
+llvm::Failed(testing::Property(
+::ErrorInfoBase::message,
+"baud rate 153600 unsupported by the platform")));
+#endif
+}
+
+TEST_F(TerminalTest, SetStopBits) {
+  struct termios terminfo;
+
+  ASSERT_THAT_ERROR(m_term.SetStopBits(1), llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+  EXPECT_EQ(terminfo.c_cflag & CSTOPB, 0U);
+
+  ASSERT_THAT_ERROR(m_term.SetStopBits(2), llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+  EXPECT_NE(terminfo.c_cflag & CSTOPB, 0U);
+
+  ASSERT_THAT_ERROR(m_term.SetStopBits(0),
+llvm::Failed(testing::Property(
+::ErrorInfoBase::message,
+"invalid stop bit count: 0 (must be 1 or 2)")));
+  ASSERT_THAT_ERROR(m_term.SetStopBits(3),
+llvm::Failed(testing::Property(
+::ErrorInfoBase::message,
+"invalid stop bit count: 3 (must be 1 or 2)")));
+}
+
+TEST_F(TerminalTest, SetParity) {
+  struct termios terminfo;
+
+  ASSERT_THAT_ERROR(m_term.SetParity(Terminal::Parity::No), llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+  EXPECT_EQ(terminfo.c_cflag & PARENB, 0U);
+
+  ASSERT_THAT_ERROR(m_term.SetParity(Terminal::Parity::Even),
+llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+#if !defined(__linux__) // Linux pty devices strip PARENB
+  EXPECT_NE(terminfo.c_cflag & PARENB, 0U);
+#endif
+  EXPECT_EQ(terminfo.c_cflag & PARODD, 0U);
+#if defined(CMSPAR)
+  EXPECT_EQ(terminfo.c_cflag & CMSPAR, 0U);
+#endif
+
+  ASSERT_THAT_ERROR(m_term.SetParity(Terminal::Parity::Odd), llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+#if !defined(__linux__) // Linux pty devices strip PARENB
+  EXPECT_NE(terminfo.c_cflag & PARENB, 0U);
+#endif
+  EXPECT_NE(terminfo.c_cflag & PARODD, 0U);
+#if defined(CMSPAR)
+  EXPECT_EQ(terminfo.c_cflag & CMSPAR, 0U);
+#endif
+
+#if defined(CMSPAR)
+  ASSERT_THAT_ERROR(m_term.SetParity(Terminal::Parity::Space),
+llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+#if !defined(__linux__) // Linux pty devices strip PARENB
+  EXPECT_NE(terminfo.c_cflag & PARENB, 0U);
+#endif
+  EXPECT_EQ(terminfo.c_cflag & PARODD, 0U);
+  EXPECT_NE(terminfo.c_cflag & CMSPAR, 0U);
+
+  ASSERT_THAT_ERROR(m_term.SetParity(Terminal::Parity::Mark),
+llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+#if !defined(__linux__) // Linux pty devices strip PARENB
+  EXPECT_NE(terminfo.c_cflag & PARENB, 0U);
+#endif
+  EXPECT_NE(terminfo.c_cflag & PARODD, 0U);
+  EXPECT_NE(terminfo.c_cflag & CMSPAR, 0U);
+#else
+  ASSERT_THAT_ERROR(m_term.SetParity(Terminal::Parity::Space),
+   

[Lldb-commits] [lldb] 92fb574 - [lldb] [Host] Add setters for common teletype properties to Terminal

2021-10-21 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-21T10:33:38+02:00
New Revision: 92fb574c9f20aef56948c51f4921a92efbb72a5b

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

LOG: [lldb] [Host] Add setters for common teletype properties to Terminal

Add setters for common teletype properties to the Terminal class:

- SetRaw() to enable common raw mode options

- SetBaudRate() to set the baud rate

- SetStopBits() to select the number of stop bits

- SetParity() to control parity bit in the output

- SetHardwareControlFlow() to enable or disable hardware control flow
  (if supported)

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

Added: 


Modified: 
lldb/include/lldb/Host/Terminal.h
lldb/source/Host/common/Terminal.cpp
lldb/unittests/Host/posix/TerminalTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/Terminal.h 
b/lldb/include/lldb/Host/Terminal.h
index f8f5d5d16ef90..ff5db4c6b9b05 100644
--- a/lldb/include/lldb/Host/Terminal.h
+++ b/lldb/include/lldb/Host/Terminal.h
@@ -20,6 +20,14 @@ class TerminalState;
 
 class Terminal {
 public:
+  enum class Parity {
+No,
+Even,
+Odd,
+Space,
+Mark,
+  };
+
   Terminal(int fd = -1) : m_fd(fd) {}
 
   ~Terminal() = default;
@@ -38,6 +46,16 @@ class Terminal {
 
   llvm::Error SetCanonical(bool enabled);
 
+  llvm::Error SetRaw();
+
+  llvm::Error SetBaudRate(unsigned int baud_rate);
+
+  llvm::Error SetStopBits(unsigned int stop_bits);
+
+  llvm::Error SetParity(Parity parity);
+
+  llvm::Error SetHardwareFlowControl(bool enabled);
+
 protected:
   struct Data;
 

diff  --git a/lldb/source/Host/common/Terminal.cpp 
b/lldb/source/Host/common/Terminal.cpp
index 7050bae0c3c1c..6b7c2821d3783 100644
--- a/lldb/source/Host/common/Terminal.cpp
+++ b/lldb/source/Host/common/Terminal.cpp
@@ -94,6 +94,267 @@ llvm::Error Terminal::SetCanonical(bool enabled) {
 #endif // LLDB_ENABLE_TERMIOS
 }
 
+llvm::Error Terminal::SetRaw() {
+  llvm::Expected data = GetData();
+  if (!data)
+return data.takeError();
+
+#if LLDB_ENABLE_TERMIOS
+  struct termios _termios = data->m_termios;
+  ::cfmakeraw(_termios);
+
+  // Make sure only one character is needed to return from a read
+  // (cfmakeraw() doesn't do this on NetBSD)
+  fd_termios.c_cc[VMIN] = 1;
+  fd_termios.c_cc[VTIME] = 0;
+
+  return SetData(data.get());
+#endif // #if LLDB_ENABLE_TERMIOS
+}
+
+static llvm::Optional baudRateToConst(unsigned int baud_rate) {
+  switch (baud_rate) {
+#if defined(B50)
+  case 50:
+return B50;
+#endif
+#if defined(B75)
+  case 75:
+return B75;
+#endif
+#if defined(B110)
+  case 110:
+return B110;
+#endif
+#if defined(B134)
+  case 134:
+return B134;
+#endif
+#if defined(B150)
+  case 150:
+return B150;
+#endif
+#if defined(B200)
+  case 200:
+return B200;
+#endif
+#if defined(B300)
+  case 300:
+return B300;
+#endif
+#if defined(B600)
+  case 600:
+return B600;
+#endif
+#if defined(B1200)
+  case 1200:
+return B1200;
+#endif
+#if defined(B1800)
+  case 1800:
+return B1800;
+#endif
+#if defined(B2400)
+  case 2400:
+return B2400;
+#endif
+#if defined(B4800)
+  case 4800:
+return B4800;
+#endif
+#if defined(B9600)
+  case 9600:
+return B9600;
+#endif
+#if defined(B19200)
+  case 19200:
+return B19200;
+#endif
+#if defined(B38400)
+  case 38400:
+return B38400;
+#endif
+#if defined(B57600)
+  case 57600:
+return B57600;
+#endif
+#if defined(B115200)
+  case 115200:
+return B115200;
+#endif
+#if defined(B230400)
+  case 230400:
+return B230400;
+#endif
+#if defined(B460800)
+  case 460800:
+return B460800;
+#endif
+#if defined(B50)
+  case 50:
+return B50;
+#endif
+#if defined(B576000)
+  case 576000:
+return B576000;
+#endif
+#if defined(B921600)
+  case 921600:
+return B921600;
+#endif
+#if defined(B100)
+  case 100:
+return B100;
+#endif
+#if defined(B1152000)
+  case 1152000:
+return B1152000;
+#endif
+#if defined(B150)
+  case 150:
+return B150;
+#endif
+#if defined(B200)
+  case 200:
+return B200;
+#endif
+#if defined(B76800)
+  case 76800:
+return B76800;
+#endif
+#if defined(B153600)
+  case 153600:
+return B153600;
+#endif
+#if defined(B307200)
+  case 307200:
+return B307200;
+#endif
+#if defined(B614400)
+  case 614400:
+return B614400;
+#endif
+#if defined(B250)
+  case 250:
+return B250;
+#endif
+#if defined(B300)
+  case 300:
+return B300;
+#endif
+#if defined(B350)
+  case 350:
+return B350;
+#endif
+#if defined(B400)
+  case 400:
+return B400;
+#endif
+  default:
+return llvm::None;
+  }
+}
+
+llvm::Error Terminal::SetBaudRate(unsigned int baud_rate) {
+  llvm::Expected data = GetData();

[Lldb-commits] [PATCH] D112069: [lldb][AArch64] Add UnwindPlan for Linux sigreturn

2021-10-21 Thread Pavel Labath via Phabricator via lldb-commits
labath requested changes to this revision.
labath added a reviewer: jasonmolenda.
labath added a comment.
This revision now requires changes to proceed.

I don't think this is a scalable way to fix this, and should get more 
discussion. Jason what do you make of this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112069

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


[Lldb-commits] [lldb] 46fb5d5 - [lldb][NFC] clang-format CPlusPlusLanguage.cpp

2021-10-21 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-10-21T10:01:18+02:00
New Revision: 46fb5d5ddffdccbd14a09c7dcff63de6fef63c07

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

LOG: [lldb][NFC] clang-format CPlusPlusLanguage.cpp

Added: 


Modified: 
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 6dd0a07780f12..2fabbff61c66b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -326,13 +326,12 @@ class ManglingSubstitutor
 public:
   ManglingSubstitutor() : Base(nullptr, nullptr) {}
 
-  template
+  template 
   ConstString substitute(llvm::StringRef Mangled, Ts &&... Vals) {
 this->getDerived().reset(Mangled, std::forward(Vals)...);
 return substituteImpl(Mangled);
   }
 
-
 protected:
   void reset(llvm::StringRef Mangled) {
 Base::reset(Mangled.begin(), Mangled.end());
@@ -386,7 +385,6 @@ class ManglingSubstitutor
 llvm::StringRef(Written, std::distance(Written, currentParserPos()));
 Written = currentParserPos();
   }
-
 };
 
 /// Given a mangled function `Mangled`, replace all the primitive function type
@@ -560,26 +558,23 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   AddCXXSummary(cpp_category_sp,
 lldb_private::formatters::LibcxxStringSummaryProviderUTF16,
 "std::u16string summary provider",
-ConstString(
-"^std::__[[:alnum:]]+::basic_string, "
-"std::__[[:alnum:]]+::allocator >$"),
+ConstString("^std::__[[:alnum:]]+::basic_string, "
+"std::__[[:alnum:]]+::allocator >$"),
 stl_summary_flags, true);
 
   AddCXXSummary(cpp_category_sp,
 lldb_private::formatters::LibcxxStringSummaryProviderUTF32,
 "std::u32string summary provider",
-ConstString(
-"^std::__[[:alnum:]]+::basic_string, "
-"std::__[[:alnum:]]+::allocator >$"),
+ConstString("^std::__[[:alnum:]]+::basic_string, "
+"std::__[[:alnum:]]+::allocator >$"),
 stl_summary_flags, true);
 
-  AddCXXSummary(cpp_category_sp,
-lldb_private::formatters::LibcxxWStringSummaryProvider,
-"std::wstring summary provider",
-ConstString("^std::__[[:alnum:]]+::wstring$"),
-stl_summary_flags, true);
+  AddCXXSummary(
+  cpp_category_sp, lldb_private::formatters::LibcxxWStringSummaryProvider,
+  "std::wstring summary provider",
+  ConstString("^std::__[[:alnum:]]+::wstring$"), stl_summary_flags, true);
   AddCXXSummary(cpp_category_sp,
 lldb_private::formatters::LibcxxWStringSummaryProvider,
 "std::wstring summary provider",
@@ -776,11 +771,11 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
 "libc++ std::tuple summary provider",
 ConstString("^std::__[[:alnum:]]+::tuple<.*>(( )?&)?$"),
 stl_summary_flags, true);
-  AddCXXSummary(
-  cpp_category_sp, lldb_private::formatters::LibCxxAtomicSummaryProvider,
-  "libc++ std::atomic summary provider",
-  ConstString("^std::__[[:alnum:]]+::atomic<.+>$"), stl_summary_flags,
-  true);
+  AddCXXSummary(cpp_category_sp,
+lldb_private::formatters::LibCxxAtomicSummaryProvider,
+"libc++ std::atomic summary provider",
+ConstString("^std::__[[:alnum:]]+::atomic<.+>$"),
+stl_summary_flags, true);
   AddCXXSummary(cpp_category_sp,
 lldb_private::formatters::LibcxxOptionalSummaryProvider,
 "libc++ std::optional summary provider",
@@ -867,7 +862,8 @@ static void 
LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   "std::allocator >"),
   cxx11_string_summary_sp);
   cpp_category_sp->GetTypeSummariesContainer()->Add(
-  ConstString("std::__cxx11::basic_string, "
+  ConstString("std::__cxx11::basic_string, "
   "std::allocator >"),
   cxx11_string_summary_sp);
 
@@ -1172,9 +1168,8 @@ CPlusPlusLanguage::GetHardcodedSynthetics() {
 
   llvm::call_once(g_initialize, []() -> void {
 g_formatters.push_back([](lldb_private::ValueObject ,
-  lldb::DynamicValueType,
-  FormatManager &
-  fmt_mgr) -> SyntheticChildren::SharedPointer 
{
+  

[Lldb-commits] [PATCH] D111030: [lldb] [Host] Add setters for common teletype properties to Terminal

2021-10-21 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: lldb/source/Host/common/Terminal.cpp:117
+  switch (baud_rate) {
+#if defined(B0)
+  case 0:

labath wrote:
> Out of curiosity: how does a baud rate of zero work?
It triggers a "hang up" signal to the modem. To be honest, I don't think we 
actually need that and it's kinda ugly API, so maybe I should remove it.


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

https://reviews.llvm.org/D111030

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


[Lldb-commits] [PATCH] D112163: Enable libc++ in the build for libcxx initializerlist pretty printers

2021-10-21 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a comment.

In D112163#3077112 , @teemperor wrote:

> LGTM, thanks!
>
> Tests with libc++ as a category are not run on Windows or when GCC is the 
> test compiler, so those decorators are redundant. Removing the Clang XFAIL 
> also seems fine, I would just see if any matrix bot complains and then 
> re-apply it with a proper minimum required version.

"matrix bot"? One of the buildbots/group of them?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112163

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


[Lldb-commits] [PATCH] D110535: [llvm] [ADT] Update llvm::Split() per Pavel Labath's suggestions

2021-10-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I'm fine with either option, and it doesn't seem to me like @joerg has a 
particularly strong more opinion either, so maybe you can cast the deciding 
vote?

I consider it more important to fix the equality operator and the name 
capitalization (in that order).


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

https://reviews.llvm.org/D110535

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


[Lldb-commits] [PATCH] D111355: [lldb] Add serial:// protocol for connecting to serial port

2021-10-21 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/source/Host/common/File.cpp:847
+: NativeFile(fd, options, transfer_ownership), m_state(fd) {}
+Status SerialPort::Close() {
+  m_state.Restore();

Empty line here


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

https://reviews.llvm.org/D111355

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


[Lldb-commits] [PATCH] D112163: Enable libc++ in the build for libcxx initializerlist pretty printers

2021-10-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!

Tests with libc++ as a category are not run on Windows or when GCC is the test 
compiler, so those decorators are redundant. Removing the Clang XFAIL also 
seems fine, I would just see if any matrix bot complains and then re-apply it 
with a proper minimum required version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112163

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


[Lldb-commits] [PATCH] D111030: [lldb] [Host] Add setters for common teletype properties to Terminal

2021-10-21 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/source/Host/common/Terminal.cpp:117
+  switch (baud_rate) {
+#if defined(B0)
+  case 0:

Out of curiosity: how does a baud rate of zero work?



Comment at: lldb/source/Host/common/Terminal.cpp:316-347
+  bool parity_bit = true;
+  bool odd_bit = false;
+  bool stick_bit = false;
+
+  switch (parity) {
+  case Parity::No:
+parity_bit = false;

mgorny wrote:
> labath wrote:
> > I am wondering if we can avoid the double conversion (enum->bools->flags). 
> > Would something like this be shorter/cleaner:
> > ```
> > unsigned(?) GetParityFlagMask() {
> >   return PARENB | PARODD
> > #ifdef CMSPAR
> > | CMSPAR
> > #endif
> >   ;
> > }
> > Expected GetParityFlags(Parity) // error if parity not supported
> > 
> > SetParity(parity) {
> > getParityFlags(parity); // and check result
> > GetData(); // and check result
> > data.m_termios.c_cflag &= ~GetParityFlagMask();
> > data.m_termios.c_cflag |= flags;
> > SetData();
> > ```
> TBH, I don't like the extra functions because they mean more `#ifdef`s. How 
> do you feel about my new version? I think it might be less optimal but I 
> think it's as readable as it gets.
I like that.


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

https://reviews.llvm.org/D111030

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


[Lldb-commits] [PATCH] D111964: [lldb] [lldb-server] Allow any protocol supported by lldb

2021-10-21 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 381158.
mgorny added a comment.

Make the test verify that (potentially large) `target.xml` can be successfully 
transferred.


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

https://reviews.llvm.org/D111964

Files:
  lldb/test/API/tools/lldb-server/TestPtyServer.py
  lldb/tools/lldb-server/lldb-gdbserver.cpp

Index: lldb/tools/lldb-server/lldb-gdbserver.cpp
===
--- lldb/tools/lldb-server/lldb-gdbserver.cpp
+++ lldb/tools/lldb-server/lldb-gdbserver.cpp
@@ -230,24 +230,27 @@
   final_host_and_port.append("localhost");
 final_host_and_port.append(host_and_port.str());
 
-if (reverse_connect) {
+bool is_url = host_and_port.contains("://");
+if (reverse_connect || is_url) {
   // llgs will connect to the gdb-remote client.
 
-  // Ensure we have a port number for the connection.
-  // Note: use rfind, because the host/port may look like "[::1]:12345".
-  uint32_t connection_portno = 0;
-  const std::string::size_type colon_pos = final_host_and_port.rfind(':');
-  if (colon_pos != std::string::npos)
-llvm::to_integer(final_host_and_port.substr(colon_pos + 1),
- connection_portno);
-  if (connection_portno == 0) {
-llvm::errs() << "error: port number must be specified on when using "
-"reverse connect\n";
-exit(1);
-  }
+  if (!is_url) {
+// Ensure we have a port number for the connection.
+// Note: use rfind, because the host/port may look like "[::1]:12345".
+uint32_t connection_portno = 0;
+const std::string::size_type colon_pos = final_host_and_port.rfind(':');
+if (colon_pos != std::string::npos)
+  llvm::to_integer(final_host_and_port.substr(colon_pos + 1),
+   connection_portno);
+if (connection_portno == 0) {
+  llvm::errs() << "error: port number must be specified on when using "
+  "reverse connect\n";
+  exit(1);
+}
 
-  // Build the connection string.
-  final_host_and_port.insert(0, "connect://");
+// Build the connection string.
+final_host_and_port.insert(0, "connect://");
+  }
 
   // Create the connection.
   connection_up.reset(new ConnectionFileDescriptor);
Index: lldb/test/API/tools/lldb-server/TestPtyServer.py
===
--- /dev/null
+++ lldb/test/API/tools/lldb-server/TestPtyServer.py
@@ -0,0 +1,73 @@
+import gdbremote_testcase
+import lldbgdbserverutils
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbgdbserverutils import *
+
+import xml.etree.ElementTree as ET
+
+
+@skipIfWindows
+class PtyServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+super().setUp()
+import pty
+import tty
+master, slave = pty.openpty()
+tty.setraw(master)
+self._master = io.FileIO(master, 'r+b')
+self._slave = io.FileIO(slave, 'r+b')
+
+def get_debug_monitor_command_line_args(self, attach_pid=None):
+commandline_args = self.debug_monitor_extra_args
+if attach_pid:
+commandline_args += ["--attach=%d" % attach_pid]
+
+libc = ctypes.CDLL(None)
+libc.ptsname.argtypes = (ctypes.c_int,)
+libc.ptsname.restype = ctypes.c_char_p
+pty_path = libc.ptsname(self._master.fileno()).decode()
+commandline_args += ["serial://%s" % (pty_path,)]
+return commandline_args
+
+def connect_to_debug_monitor(self, attach_pid=None):
+self.reverse_connect = False
+server = self.launch_debug_monitor(attach_pid=attach_pid)
+self.assertIsNotNone(server)
+
+# TODO: make it into proper abstraction
+class FakeSocket:
+def __init__(self, fd):
+self.fd = fd
+
+def sendall(self, frame):
+self.fd.write(frame)
+
+def recv(self, count):
+return self.fd.read(count)
+
+self.sock = FakeSocket(self._master)
+self._server = Server(self.sock, server)
+return server
+
+@add_test_categories(["llgs"])
+def test_pty_server(self):
+self.build()
+self.set_inferior_startup_launch()
+self.prep_debug_monitor_and_inferior()
+
+# target.xml transfer should trigger a large enough packet to check
+# for partial write regression
+self.test_sequence.add_log_lines([
+"read packet: $qXfer:features:read:target.xml:0,20#00",
+{
+"direction": "send",
+"regex": re.compile("^\$l(.+)#[0-9a-fA-F]{2}$"),
+"capture": {1: "target_xml"},
+}],
+True)
+context = 

[Lldb-commits] [lldb] d531e5c - [LLDB] [NFC] Typo fix in usage text for "type filter" command

2021-10-21 Thread Shivam Gupta via lldb-commits

Author: Daniel Jalkut
Date: 2021-10-21T12:22:52+05:30
New Revision: d531e5cf58413e34dc006a580d2c109863bddaa1

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

LOG: [LLDB] [NFC] Typo fix in usage text for "type filter" command

When you invoke "help type filter" the resulting help shows:

Syntax: type synthetic []

This patch fixes the help so it says "type filter" instead of "type synthetic".

patch by: "Daniel Jalkut "

Reviewed By: teemperor

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

Added: 


Modified: 
lldb/source/Commands/CommandObjectType.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectType.cpp 
b/lldb/source/Commands/CommandObjectType.cpp
index 90e224867e2a4..3bff844786f4e 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -2978,7 +2978,7 @@ class CommandObjectTypeFilter : public 
CommandObjectMultiword {
   CommandObjectTypeFilter(CommandInterpreter )
   : CommandObjectMultiword(interpreter, "type filter",
"Commands for operating on type filters.",
-   "type synthetic [] ") {
+   "type filter [] ") {
 LoadSubCommand(
 "add", CommandObjectSP(new CommandObjectTypeFilterAdd(interpreter)));
 LoadSubCommand("clear", CommandObjectSP(



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


[Lldb-commits] [PATCH] D112199: [LLDB] [NFC] Typo fix in usage text for "type filter" command

2021-10-21 Thread Shivam Gupta via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd531e5cf5841: [LLDB] [NFC] Typo fix in usage text for 
type filter command (authored by Daniel Jalkut 
jal...@red-sweater.com, committed by xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112199

Files:
  lldb/source/Commands/CommandObjectType.cpp


Index: lldb/source/Commands/CommandObjectType.cpp
===
--- lldb/source/Commands/CommandObjectType.cpp
+++ lldb/source/Commands/CommandObjectType.cpp
@@ -2978,7 +2978,7 @@
   CommandObjectTypeFilter(CommandInterpreter )
   : CommandObjectMultiword(interpreter, "type filter",
"Commands for operating on type filters.",
-   "type synthetic [] ") {
+   "type filter [] ") {
 LoadSubCommand(
 "add", CommandObjectSP(new CommandObjectTypeFilterAdd(interpreter)));
 LoadSubCommand("clear", CommandObjectSP(


Index: lldb/source/Commands/CommandObjectType.cpp
===
--- lldb/source/Commands/CommandObjectType.cpp
+++ lldb/source/Commands/CommandObjectType.cpp
@@ -2978,7 +2978,7 @@
   CommandObjectTypeFilter(CommandInterpreter )
   : CommandObjectMultiword(interpreter, "type filter",
"Commands for operating on type filters.",
-   "type synthetic [] ") {
+   "type filter [] ") {
 LoadSubCommand(
 "add", CommandObjectSP(new CommandObjectTypeFilterAdd(interpreter)));
 LoadSubCommand("clear", CommandObjectSP(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits