[Lldb-commits] [PATCH] D76111: Create basic SBEnvironment class

2020-03-23 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added a comment.

commit fd868f517d2c5ca8c0f160dbec0857b14ecf74c1 
 should be 
associated with `Differential Revision: https://reviews.llvm.org/D76111`.

The revert of fd868f517d2c5ca8c0f160dbec0857b14ecf74c1 
 should 
explain why fd868f517d2c5ca8c0f160dbec0857b14ecf74c1 
 was 
reverted.

Please don't make a commit whose description contains just one word `fix`.

If you are unsure, upload a new diff to trigger Harbormaster, check its test 
status on 3 Linux/Windows/macOS, instead of committing and reverting like 
playing a game. Every commit has a permanent record which will be shared among 
thousands of developers and can increase the size of the repository. Please be 
careful.

`Subscribers:` and `Tags:` lines are generally considered useless. You can 
strip them with:

  arcfilter () {
  git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} 
/Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: 
/,"");print}' | git commit --amend -F -
  }




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76111



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


[Lldb-commits] [PATCH] D74636: [lldb-vscode] Add inheritEnvironment option

2020-03-23 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

I would either add the option to SBLaunchInfo so it can be specified, or 
execute the command. If the target is created, it is setting a target specific 
setting. If had to pick I would add the API to SBLaunchInfo. Whenever I see 
something that can't be done through the API, I like to add that API if it is 
warranted. In our case the value in the SBLaunchInfo should probably be stored 
as a lldb_private::LazyBool which can have the following values:

  enum LazyBool { eLazyBoolCalculate = -1, eLazyBoolNo = 0, eLazyBoolYes = 1 };

It would eLazyBoolCalculate to in the launch info, and if it gets set to true 
or false, then we use that, if it is set to eLazyBoolCalculate we use the 
target setting.




Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:1359
   const auto debuggerRoot = GetString(arguments, "debuggerRoot");
+  bool launchWithDebuggerEnvironment =
+  GetBoolean(arguments, "inheritEnvironment", false);

All other local variables use the same name, can we rename this to 
"inheritEnvironment"?



Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:1380
+  // "inheritEnvironment" argument.
+  if (!launchWithDebuggerEnvironment)
+g_vsc.RunLLDBCommands(llvm::StringRef(),

The other option here would be to add "inheritEnvironment" to the SBLaunchInfo?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74636



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


[Lldb-commits] [lldb] ca69be2 - Create basic SBEnvironment class

2020-03-23 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2020-03-23T19:23:33-07:00
New Revision: ca69be218c03b1528b1439c4ca56074e434c094d

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

LOG: Create basic SBEnvironment class

Added: 
lldb/bindings/interface/SBEnvironment.i
lldb/include/lldb/API/SBEnvironment.h
lldb/source/API/SBEnvironment.cpp
lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py

Modified: 
lldb/bindings/headers.swig
lldb/bindings/interface/SBLaunchInfo.i
lldb/bindings/interface/SBPlatform.i
lldb/bindings/interface/SBTarget.i
lldb/bindings/interfaces.swig
lldb/include/lldb/API/LLDB.h
lldb/include/lldb/API/SBDefines.h
lldb/include/lldb/API/SBLaunchInfo.h
lldb/include/lldb/API/SBPlatform.h
lldb/include/lldb/API/SBTarget.h
lldb/include/lldb/Utility/Environment.h
lldb/include/lldb/lldb-forward.h
lldb/source/API/CMakeLists.txt
lldb/source/API/SBLaunchInfo.cpp
lldb/source/API/SBPlatform.cpp
lldb/source/API/SBTarget.cpp

Removed: 




diff  --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig
index ddd3964beb48..7371e1a3873b 100644
--- a/lldb/bindings/headers.swig
+++ b/lldb/bindings/headers.swig
@@ -21,6 +21,7 @@
 #include "lldb/API/SBData.h"
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBDeclaration.h"
+#include "lldb/API/SBEnvironment.h"
 #include "lldb/API/SBError.h"
 #include "lldb/API/SBEvent.h"
 #include "lldb/API/SBExecutionContext.h"

diff  --git a/lldb/bindings/interface/SBEnvironment.i 
b/lldb/bindings/interface/SBEnvironment.i
new file mode 100644
index ..4ca22fc314d2
--- /dev/null
+++ b/lldb/bindings/interface/SBEnvironment.i
@@ -0,0 +1,48 @@
+//===-- SWIG Interface for SBEnvironment-*- 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
+//
+//===--===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents the environment of a certain process.
+
+Example:
+  for entry in lldb.debugger.GetSelectedTarget().GetEnvironment().GetEntries():
+print(entry)
+
+") SBEnvironment;
+class SBEnvironment {
+public:
+SBEnvironment ();
+
+SBEnvironment (const lldb::SBEnvironment );
+
+~SBEnvironment();
+
+size_t GetNumValues();
+
+const char *Get(const char *name);
+
+const char *GetNameAtIndex(size_t index);
+
+const char *GetValueAtIndex(size_t index);
+
+SBStringList GetEntries();
+
+void PutEntry(const char *name_and_value);
+
+void SetEntries(const SBStringList , bool append);
+
+bool Set(const char *name, const char *value, bool overwrite);
+
+bool Unset(const char *name);
+
+void Clear();
+};
+
+} // namespace lldb

diff  --git a/lldb/bindings/interface/SBLaunchInfo.i 
b/lldb/bindings/interface/SBLaunchInfo.i
index e76950c6fb48..1de89b58b272 100644
--- a/lldb/bindings/interface/SBLaunchInfo.i
+++ b/lldb/bindings/interface/SBLaunchInfo.i
@@ -64,6 +64,12 @@ public:
 void
 SetEnvironmentEntries (const char **envp, bool append);
 
+void
+SetEnvironment(const SBEnvironment , bool append);
+
+SBEnvironment
+GetEnvironment();
+
 void
 Clear ();
 

diff  --git a/lldb/bindings/interface/SBPlatform.i 
b/lldb/bindings/interface/SBPlatform.i
index 1f52edb0232c..81945222c059 100644
--- a/lldb/bindings/interface/SBPlatform.i
+++ b/lldb/bindings/interface/SBPlatform.i
@@ -194,6 +194,9 @@ public:
 lldb::SBUnixSignals
 GetUnixSignals();
 
+lldb::SBEnvironment
+GetEnvironment();
+
 };
 
 } // namespace lldb

diff  --git a/lldb/bindings/interface/SBTarget.i 
b/lldb/bindings/interface/SBTarget.i
index 371bf5c35ebd..57b5ccea6399 100644
--- a/lldb/bindings/interface/SBTarget.i
+++ b/lldb/bindings/interface/SBTarget.i
@@ -677,6 +677,9 @@ public:
 lldb::SBBreakpoint
 BreakpointCreateByAddress (addr_t address);
 
+lldb::SBEnvironment
+GetEnvironment();
+
 lldb::SBBreakpoint
 BreakpointCreateBySBAddress (SBAddress _address);
 

diff  --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig
index 780fe34392ff..e906bb9e5656 100644
--- a/lldb/bindings/interfaces.swig
+++ b/lldb/bindings/interfaces.swig
@@ -29,6 +29,7 @@
 %include "./interface/SBDebugger.i"
 %include "./interface/SBDeclaration.i"
 %include "./interface/SBError.i"
+%include "./interface/SBEnvironment.i"
 %include "./interface/SBEvent.i"
 %include "./interface/SBExecutionContext.i"
 %include "./interface/SBExpressionOptions.i"

diff  --git a/lldb/include/lldb/API/LLDB.h b/lldb/include/lldb/API/LLDB.h
index 12f3b8f32f57..83c38d3b6166 100644

[Lldb-commits] [lldb] 318a0ca - Revert "Create basic SBEnvironment class"

2020-03-23 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2020-03-23T18:20:10-07:00
New Revision: 318a0caf9acc8c4ec778ba4f0bbd115a8244bb85

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

LOG: Revert "Create basic SBEnvironment class"

This reverts commit fd868f517d2c5ca8c0f160dbec0857b14ecf74c1.

Added: 


Modified: 
lldb/bindings/headers.swig
lldb/bindings/interface/SBLaunchInfo.i
lldb/bindings/interface/SBPlatform.i
lldb/bindings/interface/SBTarget.i
lldb/bindings/interfaces.swig
lldb/include/lldb/API/LLDB.h
lldb/include/lldb/API/SBDefines.h
lldb/include/lldb/API/SBLaunchInfo.h
lldb/include/lldb/API/SBPlatform.h
lldb/include/lldb/API/SBTarget.h
lldb/include/lldb/Utility/Environment.h
lldb/include/lldb/lldb-forward.h
lldb/source/API/CMakeLists.txt
lldb/source/API/SBLaunchInfo.cpp
lldb/source/API/SBPlatform.cpp
lldb/source/API/SBReproducer.cpp
lldb/source/API/SBTarget.cpp

Removed: 
lldb/bindings/interface/SBEnvironment.i
lldb/include/lldb/API/SBEnvironment.h
lldb/source/API/SBEnvironment.cpp
lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py



diff  --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig
index 7371e1a3873b..ddd3964beb48 100644
--- a/lldb/bindings/headers.swig
+++ b/lldb/bindings/headers.swig
@@ -21,7 +21,6 @@
 #include "lldb/API/SBData.h"
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBDeclaration.h"
-#include "lldb/API/SBEnvironment.h"
 #include "lldb/API/SBError.h"
 #include "lldb/API/SBEvent.h"
 #include "lldb/API/SBExecutionContext.h"

diff  --git a/lldb/bindings/interface/SBEnvironment.i 
b/lldb/bindings/interface/SBEnvironment.i
deleted file mode 100644
index 4ca22fc314d2..
--- a/lldb/bindings/interface/SBEnvironment.i
+++ /dev/null
@@ -1,48 +0,0 @@
-//===-- SWIG Interface for SBEnvironment-*- 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
-//
-//===--===//
-
-namespace lldb {
-
-%feature("docstring",
-"Represents the environment of a certain process.
-
-Example:
-  for entry in lldb.debugger.GetSelectedTarget().GetEnvironment().GetEntries():
-print(entry)
-
-") SBEnvironment;
-class SBEnvironment {
-public:
-SBEnvironment ();
-
-SBEnvironment (const lldb::SBEnvironment );
-
-~SBEnvironment();
-
-size_t GetNumValues();
-
-const char *Get(const char *name);
-
-const char *GetNameAtIndex(size_t index);
-
-const char *GetValueAtIndex(size_t index);
-
-SBStringList GetEntries();
-
-void PutEntry(const char *name_and_value);
-
-void SetEntries(const SBStringList , bool append);
-
-bool Set(const char *name, const char *value, bool overwrite);
-
-bool Unset(const char *name);
-
-void Clear();
-};
-
-} // namespace lldb

diff  --git a/lldb/bindings/interface/SBLaunchInfo.i 
b/lldb/bindings/interface/SBLaunchInfo.i
index 1de89b58b272..e76950c6fb48 100644
--- a/lldb/bindings/interface/SBLaunchInfo.i
+++ b/lldb/bindings/interface/SBLaunchInfo.i
@@ -64,12 +64,6 @@ public:
 void
 SetEnvironmentEntries (const char **envp, bool append);
 
-void
-SetEnvironment(const SBEnvironment , bool append);
-
-SBEnvironment
-GetEnvironment();
-
 void
 Clear ();
 

diff  --git a/lldb/bindings/interface/SBPlatform.i 
b/lldb/bindings/interface/SBPlatform.i
index 81945222c059..1f52edb0232c 100644
--- a/lldb/bindings/interface/SBPlatform.i
+++ b/lldb/bindings/interface/SBPlatform.i
@@ -194,9 +194,6 @@ public:
 lldb::SBUnixSignals
 GetUnixSignals();
 
-lldb::SBEnvironment
-GetEnvironment();
-
 };
 
 } // namespace lldb

diff  --git a/lldb/bindings/interface/SBTarget.i 
b/lldb/bindings/interface/SBTarget.i
index 57b5ccea6399..371bf5c35ebd 100644
--- a/lldb/bindings/interface/SBTarget.i
+++ b/lldb/bindings/interface/SBTarget.i
@@ -677,9 +677,6 @@ public:
 lldb::SBBreakpoint
 BreakpointCreateByAddress (addr_t address);
 
-lldb::SBEnvironment
-GetEnvironment();
-
 lldb::SBBreakpoint
 BreakpointCreateBySBAddress (SBAddress _address);
 

diff  --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig
index e906bb9e5656..780fe34392ff 100644
--- a/lldb/bindings/interfaces.swig
+++ b/lldb/bindings/interfaces.swig
@@ -29,7 +29,6 @@
 %include "./interface/SBDebugger.i"
 %include "./interface/SBDeclaration.i"
 %include "./interface/SBError.i"
-%include "./interface/SBEnvironment.i"
 %include "./interface/SBEvent.i"
 %include "./interface/SBExecutionContext.i"
 %include "./interface/SBExpressionOptions.i"


[Lldb-commits] [lldb] fd868f5 - Create basic SBEnvironment class

2020-03-23 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2020-03-23T17:59:06-07:00
New Revision: fd868f517d2c5ca8c0f160dbec0857b14ecf74c1

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

LOG: Create basic SBEnvironment class

Added: 
lldb/bindings/interface/SBEnvironment.i
lldb/include/lldb/API/SBEnvironment.h
lldb/source/API/SBEnvironment.cpp
lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py

Modified: 
lldb/bindings/headers.swig
lldb/bindings/interface/SBLaunchInfo.i
lldb/bindings/interface/SBPlatform.i
lldb/bindings/interface/SBTarget.i
lldb/bindings/interfaces.swig
lldb/include/lldb/API/LLDB.h
lldb/include/lldb/API/SBDefines.h
lldb/include/lldb/API/SBLaunchInfo.h
lldb/include/lldb/API/SBPlatform.h
lldb/include/lldb/API/SBTarget.h
lldb/include/lldb/Utility/Environment.h
lldb/include/lldb/lldb-forward.h
lldb/source/API/CMakeLists.txt
lldb/source/API/SBLaunchInfo.cpp
lldb/source/API/SBPlatform.cpp
lldb/source/API/SBReproducer.cpp
lldb/source/API/SBTarget.cpp

Removed: 




diff  --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig
index ddd3964beb48..7371e1a3873b 100644
--- a/lldb/bindings/headers.swig
+++ b/lldb/bindings/headers.swig
@@ -21,6 +21,7 @@
 #include "lldb/API/SBData.h"
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBDeclaration.h"
+#include "lldb/API/SBEnvironment.h"
 #include "lldb/API/SBError.h"
 #include "lldb/API/SBEvent.h"
 #include "lldb/API/SBExecutionContext.h"

diff  --git a/lldb/bindings/interface/SBEnvironment.i 
b/lldb/bindings/interface/SBEnvironment.i
new file mode 100644
index ..4ca22fc314d2
--- /dev/null
+++ b/lldb/bindings/interface/SBEnvironment.i
@@ -0,0 +1,48 @@
+//===-- SWIG Interface for SBEnvironment-*- 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
+//
+//===--===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents the environment of a certain process.
+
+Example:
+  for entry in lldb.debugger.GetSelectedTarget().GetEnvironment().GetEntries():
+print(entry)
+
+") SBEnvironment;
+class SBEnvironment {
+public:
+SBEnvironment ();
+
+SBEnvironment (const lldb::SBEnvironment );
+
+~SBEnvironment();
+
+size_t GetNumValues();
+
+const char *Get(const char *name);
+
+const char *GetNameAtIndex(size_t index);
+
+const char *GetValueAtIndex(size_t index);
+
+SBStringList GetEntries();
+
+void PutEntry(const char *name_and_value);
+
+void SetEntries(const SBStringList , bool append);
+
+bool Set(const char *name, const char *value, bool overwrite);
+
+bool Unset(const char *name);
+
+void Clear();
+};
+
+} // namespace lldb

diff  --git a/lldb/bindings/interface/SBLaunchInfo.i 
b/lldb/bindings/interface/SBLaunchInfo.i
index e76950c6fb48..1de89b58b272 100644
--- a/lldb/bindings/interface/SBLaunchInfo.i
+++ b/lldb/bindings/interface/SBLaunchInfo.i
@@ -64,6 +64,12 @@ public:
 void
 SetEnvironmentEntries (const char **envp, bool append);
 
+void
+SetEnvironment(const SBEnvironment , bool append);
+
+SBEnvironment
+GetEnvironment();
+
 void
 Clear ();
 

diff  --git a/lldb/bindings/interface/SBPlatform.i 
b/lldb/bindings/interface/SBPlatform.i
index 1f52edb0232c..81945222c059 100644
--- a/lldb/bindings/interface/SBPlatform.i
+++ b/lldb/bindings/interface/SBPlatform.i
@@ -194,6 +194,9 @@ public:
 lldb::SBUnixSignals
 GetUnixSignals();
 
+lldb::SBEnvironment
+GetEnvironment();
+
 };
 
 } // namespace lldb

diff  --git a/lldb/bindings/interface/SBTarget.i 
b/lldb/bindings/interface/SBTarget.i
index 371bf5c35ebd..57b5ccea6399 100644
--- a/lldb/bindings/interface/SBTarget.i
+++ b/lldb/bindings/interface/SBTarget.i
@@ -677,6 +677,9 @@ public:
 lldb::SBBreakpoint
 BreakpointCreateByAddress (addr_t address);
 
+lldb::SBEnvironment
+GetEnvironment();
+
 lldb::SBBreakpoint
 BreakpointCreateBySBAddress (SBAddress _address);
 

diff  --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig
index 780fe34392ff..e906bb9e5656 100644
--- a/lldb/bindings/interfaces.swig
+++ b/lldb/bindings/interfaces.swig
@@ -29,6 +29,7 @@
 %include "./interface/SBDebugger.i"
 %include "./interface/SBDeclaration.i"
 %include "./interface/SBError.i"
+%include "./interface/SBEnvironment.i"
 %include "./interface/SBEvent.i"
 %include "./interface/SBExecutionContext.i"
 %include "./interface/SBExpressionOptions.i"

diff  --git a/lldb/include/lldb/API/LLDB.h b/lldb/include/lldb/API/LLDB.h
index 

[Lldb-commits] [PATCH] D76650: Data formatters: fix detection of C strings

2020-03-23 Thread Jaroslav Sevcik via Phabricator via lldb-commits
jarin created this revision.
jarin added a reviewer: teemperor.
jarin added a project: LLDB.
Herald added a subscriber: lldb-commits.

Detection of C strings does not work well for pointers. If the value object 
holding a (char*) pointer does not have an address (e.g., if it is a temp), the 
value is not considered a C string and its formatting is left to 
DumpDataExtractor rather than the special handling in  
ValueObject::DumpPrintableRepresentation. This leads to inconsistent outputs, 
e.g., in escaping non-ASCII characters. See the test for an example; the second 
test expectation is not met (without this patch). With this patch, the C string 
detection only insists that the pointer value is valid. The patch makes the 
code consistent with how the pointer is obtained in 
ValueObject::ReadPointedString.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76650

Files:
  lldb/source/Core/ValueObject.cpp
  lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/Makefile
  
lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/TestCstringUnicode.py
  lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/main.cpp


Index: 
lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/main.cpp
@@ -0,0 +1,4 @@
+int main() {
+  const char *s = "é";
+  return 0; // break here
+}
Index: 
lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/TestCstringUnicode.py
===
--- /dev/null
+++ 
lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/TestCstringUnicode.py
@@ -0,0 +1,18 @@
+# coding=utf8
+
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class CstringUnicodeTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_cstring_unicode(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here",
+lldb.SBFileSpec("main.cpp", False))
+self.expect("expr s", substrs=['"é"'])
+self.expect("expr (const char*)s", substrs=['"é"'])
Index: 
lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -764,7 +764,7 @@
 return true;
   addr_t cstr_address = LLDB_INVALID_ADDRESS;
   AddressType cstr_address_type = eAddressTypeInvalid;
-  cstr_address = GetAddressOf(true, _address_type);
+  cstr_address = GetPointerValue(_address_type);
   return (cstr_address != LLDB_INVALID_ADDRESS);
 }
 


Index: lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/main.cpp
@@ -0,0 +1,4 @@
+int main() {
+  const char *s = "é";
+  return 0; // break here
+}
Index: lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/TestCstringUnicode.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/TestCstringUnicode.py
@@ -0,0 +1,18 @@
+# coding=utf8
+
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class CstringUnicodeTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_cstring_unicode(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here",
+lldb.SBFileSpec("main.cpp", False))
+self.expect("expr s", substrs=['"é"'])
+self.expect("expr (const char*)s", substrs=['"é"'])
Index: lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/cstring-utf8-summary/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -764,7 +764,7 @@
 return true;
   addr_t cstr_address = LLDB_INVALID_ADDRESS;
   AddressType cstr_address_type = eAddressTypeInvalid;
-  cstr_address = GetAddressOf(true, _address_type);
+  cstr_address = GetPointerValue(_address_type);
   

[Lldb-commits] [PATCH] D76529: [lldb-vscode] Add missing launchCommands entry in the package.json

2020-03-23 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 252150.
wallace added a comment.

Use clayborg's wording. Thanks, milord.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76529

Files:
  lldb/tools/lldb-vscode/package.json


Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -140,6 +140,11 @@

"description": "Commands executed just before the program is launched.",

"default": []
},
+   "launchCommands": {
+   "type": 
"array",
+   
"description": "Custom commands that are executed instead of launching a 
process. A target will be created with the launch arguments prior to executing 
these commands. The commands may optionally create a new target and must 
perform a launch. A valid process must exist after these commands complete or 
the \"launch\" will fail.",
+   
"default": []
+   },
"stopCommands": {
"type": 
"array",

"description": "Commands executed each time the program stops.",


Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -140,6 +140,11 @@
 	"description": "Commands executed just before the program is launched.",
 	"default": []
 			},
+			"launchCommands": {
+	"type": "array",
+	"description": "Custom commands that are executed instead of launching a process. A target will be created with the launch arguments prior to executing these commands. The commands may optionally create a new target and must perform a launch. A valid process must exist after these commands complete or the \"launch\" will fail.",
+	"default": []
+			},
 			"stopCommands": {
 	"type": "array",
 	"description": "Commands executed each time the program stops.",
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D76450: [lldb/PlatformDarwin] Always delete destination file first in PutFile

2020-03-23 Thread Frederic Riss via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb6ae8937e031: [lldb/PlatformDarwin] Always delete 
destination file first in PutFile (authored by friss).

Changed prior to commit:
  https://reviews.llvm.org/D76450?vs=251461=252146#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76450

Files:
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h


Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
@@ -25,6 +25,11 @@
 
   ~PlatformDarwin() override;
 
+  lldb_private::Status PutFile(const lldb_private::FileSpec ,
+   const lldb_private::FileSpec ,
+   uint32_t uid = UINT32_MAX,
+   uint32_t gid = UINT32_MAX) override;
+
   // lldb_private::Platform functions
   lldb_private::Status
   ResolveSymbolFile(lldb_private::Target ,
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -58,6 +58,17 @@
 /// inherited from by the plug-in instance.
 PlatformDarwin::~PlatformDarwin() {}
 
+lldb_private::Status
+PlatformDarwin::PutFile(const lldb_private::FileSpec ,
+const lldb_private::FileSpec , uint32_t 
uid,
+uint32_t gid) {
+  // Unconditionally unlink the destination. If it is an executable,
+  // simply opening it and truncating its contents would invalidate
+  // its cached code signature.
+  Unlink(destination);
+  return PlatformPOSIX::PutFile(source, destination, uid, gid);
+}
+
 FileSpecList PlatformDarwin::LocateExecutableScriptingResources(
 Target *target, Module , Stream *feedback_stream) {
   FileSpecList file_list;


Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
@@ -25,6 +25,11 @@
 
   ~PlatformDarwin() override;
 
+  lldb_private::Status PutFile(const lldb_private::FileSpec ,
+   const lldb_private::FileSpec ,
+   uint32_t uid = UINT32_MAX,
+   uint32_t gid = UINT32_MAX) override;
+
   // lldb_private::Platform functions
   lldb_private::Status
   ResolveSymbolFile(lldb_private::Target ,
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -58,6 +58,17 @@
 /// inherited from by the plug-in instance.
 PlatformDarwin::~PlatformDarwin() {}
 
+lldb_private::Status
+PlatformDarwin::PutFile(const lldb_private::FileSpec ,
+const lldb_private::FileSpec , uint32_t uid,
+uint32_t gid) {
+  // Unconditionally unlink the destination. If it is an executable,
+  // simply opening it and truncating its contents would invalidate
+  // its cached code signature.
+  Unlink(destination);
+  return PlatformPOSIX::PutFile(source, destination, uid, gid);
+}
+
 FileSpecList PlatformDarwin::LocateExecutableScriptingResources(
 Target *target, Module , Stream *feedback_stream) {
   FileSpecList file_list;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] b6ae893 - [lldb/PlatformDarwin] Always delete destination file first in PutFile

2020-03-23 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-23T14:34:17-07:00
New Revision: b6ae8937e031cde2e70e6a83d46c21e940fdf4ac

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

LOG: [lldb/PlatformDarwin] Always delete destination file first in PutFile

Summary:
The default behavior of Platform::PutFile is to open the file and
truncate it if it already exists. This works fine and is a sensible
default, but it interacts badly with code-signing on iOS, as doing so
invalidates the signature of the file (even if the new content has a
valid code signature).

We have a couple tests which on purpose reload a different binary with
the same name. Those tests are currently broken because of the above
interaction.

This patch simply makes the Darwin platform unconditionally delete the
destination file before sending the new one to work around this issue.

Reviewers: jasonmolenda

Subscribers: lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h

Removed: 




diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 46dd3774e5a9..350043f8d4e9 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -58,6 +58,17 @@ PlatformDarwin::PlatformDarwin(bool is_host)
 /// inherited from by the plug-in instance.
 PlatformDarwin::~PlatformDarwin() {}
 
+lldb_private::Status
+PlatformDarwin::PutFile(const lldb_private::FileSpec ,
+const lldb_private::FileSpec , uint32_t 
uid,
+uint32_t gid) {
+  // Unconditionally unlink the destination. If it is an executable,
+  // simply opening it and truncating its contents would invalidate
+  // its cached code signature.
+  Unlink(destination);
+  return PlatformPOSIX::PutFile(source, destination, uid, gid);
+}
+
 FileSpecList PlatformDarwin::LocateExecutableScriptingResources(
 Target *target, Module , Stream *feedback_stream) {
   FileSpecList file_list;

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
index 6d51edbc9294..f6729c508f00 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
@@ -25,6 +25,11 @@ class PlatformDarwin : public PlatformPOSIX {
 
   ~PlatformDarwin() override;
 
+  lldb_private::Status PutFile(const lldb_private::FileSpec ,
+   const lldb_private::FileSpec ,
+   uint32_t uid = UINT32_MAX,
+   uint32_t gid = UINT32_MAX) override;
+
   // lldb_private::Platform functions
   lldb_private::Status
   ResolveSymbolFile(lldb_private::Target ,



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


[Lldb-commits] [PATCH] D74636: [lldb-vscode] Add inheritEnvironment option

2020-03-23 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

TBH I'd prefer to have consistency across all these options regardless of how 
the target is launched. That means modifying the defaults of the target 
settings that can be specified via launch.json arguments.

What do you think, @clayborg?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74636



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


[Lldb-commits] [PATCH] D76532: Internal expressions should not increment the next result variable numbering

2020-03-23 Thread Jim Ingham via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG67d67ebe8f25: Internal expressions shouldnt increment 
the result variable numbering. (authored by jingham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76532

Files:
  lldb/include/lldb/Expression/ExpressionVariable.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Core/ValueObject.cpp
  lldb/source/Expression/ExpressionVariable.cpp
  lldb/source/Expression/Materializer.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/source/Target/ABI.cpp
  lldb/test/API/commands/expression/result_numbering/Makefile
  lldb/test/API/commands/expression/result_numbering/TestResultNumbering.py
  lldb/test/API/commands/expression/result_numbering/main.c

Index: lldb/test/API/commands/expression/result_numbering/main.c
===
--- /dev/null
+++ lldb/test/API/commands/expression/result_numbering/main.c
@@ -0,0 +1,18 @@
+#include 
+
+int
+call_me(int input)
+{
+  return input;
+}
+
+int
+main()
+{
+  int value = call_me(0); // Set a breakpoint here
+  while (value < 10)
+{
+  printf("Add conditions to this breakpoint: %d.\n", value++);
+}
+  return 0;
+}
Index: lldb/test/API/commands/expression/result_numbering/TestResultNumbering.py
===
--- /dev/null
+++ lldb/test/API/commands/expression/result_numbering/TestResultNumbering.py
@@ -0,0 +1,48 @@
+"""
+Make sure running internal expressions doesn't
+influence the result variable numbering.
+"""
+
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class TestExpressionResultNumbering(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_sample_rename_this(self):
+self.build()
+self.main_source_file = lldb.SBFileSpec("main.c")
+self.do_numbering_test()
+
+def do_numbering_test(self):
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
+   "Set a breakpoint here", self.main_source_file)
+
+bkpt = target.BreakpointCreateBySourceRegex("Add conditions to this breakpoint",
+self.main_source_file)
+self.assertEqual(bkpt.GetNumLocations(), 1, "Set the breakpoint")
+
+bkpt.SetCondition("call_me(value) < 6")
+
+# Get the number of the last expression:
+result = thread.frames[0].EvaluateExpression("call_me(200)")
+self.assertTrue(result.GetError().Success(), "Our expression succeeded")
+name = result.GetName()
+ordinal = int(name[1:])
+
+process.Continue()
+
+# The condition evaluation had to run a 4 expressions, but we haven't
+# run any user expressions.
+result = thread.frames[0].EvaluateExpression("call_me(200)")
+self.assertTrue(result.GetError().Success(), "Our expression succeeded the second time")
+after_name = result.GetName()
+after_ordinal = int(after_name[1:])
+self.assertEqual(ordinal + 1, after_ordinal) 
Index: lldb/test/API/commands/expression/result_numbering/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/expression/result_numbering/Makefile
@@ -0,0 +1,4 @@
+C_SOURCES := main.c
+CFLAGS_EXTRAS := -std=c99
+
+include Makefile.rules
Index: lldb/source/Target/ABI.cpp
===
--- lldb/source/Target/ABI.cpp
+++ lldb/source/Target/ABI.cpp
@@ -97,10 +97,8 @@
 if (!persistent_expression_state)
   return {};
 
-auto prefix = persistent_expression_state->GetPersistentVariablePrefix();
 ConstString persistent_variable_name =
-persistent_expression_state->GetNextPersistentVariableName(target,
-   prefix);
+persistent_expression_state->GetNextPersistentVariableName();
 
 lldb::ValueObjectSP const_valobj_sp;
 
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -924,9 +924,7 @@
 }
 
 ConstString ClangUserExpression::ResultDelegate::GetName() {
-  auto prefix = m_persistent_state->GetPersistentVariablePrefix();
-  return m_persistent_state->GetNextPersistentVariableName(*m_target_sp,
-   prefix);
+  return 

[Lldb-commits] [lldb] 67d67eb - Internal expressions shouldn't increment the result variable numbering.

2020-03-23 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2020-03-23T13:30:37-07:00
New Revision: 67d67ebe8f2535c5de75c62820f7713f87d07307

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

LOG: Internal expressions shouldn't increment the result variable numbering.

There an option: EvaluateExpressionOptions::SetResultIsInternal to indicate
whether the result number should be returned to the pool or not.  It
got broken when the PersistentExpressionState was refactored.

This fixes the issue and provides a test of the behavior.

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

Added: 
lldb/test/API/commands/expression/result_numbering/Makefile
lldb/test/API/commands/expression/result_numbering/TestResultNumbering.py
lldb/test/API/commands/expression/result_numbering/main.c

Modified: 
lldb/include/lldb/Expression/ExpressionVariable.h
lldb/include/lldb/Target/Target.h
lldb/source/Core/ValueObject.cpp
lldb/source/Expression/ExpressionVariable.cpp
lldb/source/Expression/Materializer.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
lldb/source/Target/ABI.cpp

Removed: 




diff  --git a/lldb/include/lldb/Expression/ExpressionVariable.h 
b/lldb/include/lldb/Expression/ExpressionVariable.h
index c523176e003f..60062d212bad 100644
--- a/lldb/include/lldb/Expression/ExpressionVariable.h
+++ b/lldb/include/lldb/Expression/ExpressionVariable.h
@@ -221,11 +221,7 @@ class PersistentExpressionState : public 
ExpressionVariableList {
uint32_t addr_byte_size) = 0;
 
   /// Return a new persistent variable name with the specified prefix.
-  ConstString GetNextPersistentVariableName(Target ,
-llvm::StringRef prefix);
-
-  virtual llvm::StringRef
-  GetPersistentVariablePrefix(bool is_error = false) const = 0;
+  virtual ConstString GetNextPersistentVariableName(bool is_error = false) = 0;
 
   virtual void
   RemovePersistentVariable(lldb::ExpressionVariableSP variable) = 0;
@@ -237,6 +233,10 @@ class PersistentExpressionState : public 
ExpressionVariableList {
 
   void RegisterExecutionUnit(lldb::IRExecutionUnitSP _unit_sp);
 
+protected:
+  virtual llvm::StringRef
+  GetPersistentVariablePrefix(bool is_error = false) const = 0;
+
 private:
   LLVMCastKind m_kind;
 

diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 77cda4998192..cc74fe0f3d74 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1100,11 +1100,6 @@ class Target : public 
std::enable_shared_from_this,
 
   lldb::ExpressionVariableSP GetPersistentVariable(ConstString name);
 
-  /// Return the next available number for numbered persistent variables.
-  unsigned GetNextPersistentVariableIndex() {
-return m_next_persistent_variable_index++;
-  }
-
   lldb::addr_t GetPersistentSymbol(ConstString name);
 
   /// This method will return the address of the starting function for

diff  --git a/lldb/source/Core/ValueObject.cpp 
b/lldb/source/Core/ValueObject.cpp
index e1d0ca941108..4c9c44ea15f4 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -3270,9 +3270,7 @@ ValueObjectSP ValueObject::Persist() {
   if (!persistent_state)
 return nullptr;
 
-  auto prefix = persistent_state->GetPersistentVariablePrefix();
-  ConstString name =
-  persistent_state->GetNextPersistentVariableName(*target_sp, prefix);
+  ConstString name = persistent_state->GetNextPersistentVariableName();
 
   ValueObjectSP const_result_sp =
   ValueObjectConstResult::Create(target_sp.get(), GetValue(), name);

diff  --git a/lldb/source/Expression/ExpressionVariable.cpp 
b/lldb/source/Expression/ExpressionVariable.cpp
index 7c27c0f249ec..d95f0745cf4b 100644
--- a/lldb/source/Expression/ExpressionVariable.cpp
+++ b/lldb/source/Expression/ExpressionVariable.cpp
@@ -76,13 +76,3 @@ void PersistentExpressionState::RegisterExecutionUnit(
 }
   }
 }
-
-ConstString PersistentExpressionState::GetNextPersistentVariableName(
-Target , llvm::StringRef Prefix) {
-  llvm::SmallString<64> name;
-  {
-llvm::raw_svector_ostream os(name);
-os << Prefix << target.GetNextPersistentVariableIndex();
-  }
-  return ConstString(name);
-}

diff  --git a/lldb/source/Expression/Materializer.cpp 
b/lldb/source/Expression/Materializer.cpp
index 33c061effca4..8e96891257e4 100644
--- a/lldb/source/Expression/Materializer.cpp
+++ b/lldb/source/Expression/Materializer.cpp
@@ -881,11 +881,9 @@ class EntityResultVariable : public Materializer::Entity {
   return;
 }
 
-ConstString name =
-

[Lldb-commits] [PATCH] D76569: Convert CommandObjectCommands functions to return StringRefs

2020-03-23 Thread Shivam Mittal via Phabricator via lldb-commits
shivammittal99 updated this revision to Diff 252125.
shivammittal99 added a comment.

Remove conditional and move raw_command_string line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76569

Files:
  lldb/source/Commands/CommandObjectCommands.cpp


Index: lldb/source/Commands/CommandObjectCommands.cpp
===
--- lldb/source/Commands/CommandObjectCommands.cpp
+++ lldb/source/Commands/CommandObjectCommands.cpp
@@ -527,14 +527,13 @@
 m_option_group.NotifyOptionParsingStarting(_ctx);
 
 OptionsWithRaw args_with_suffix(raw_command_line);
-const char *remainder = args_with_suffix.GetRawPart().c_str();
 
 if (args_with_suffix.HasArgs())
   if (!ParseOptionsAndNotify(args_with_suffix.GetArgs(), result,
  m_option_group, exe_ctx))
 return false;
 
-llvm::StringRef raw_command_string(remainder);
+llvm::StringRef raw_command_string = args_with_suffix.GetRawPart();
 Args args(raw_command_string);
 
 if (args.GetArgumentCount() < 2) {
@@ -1171,14 +1170,9 @@
   return llvm::makeArrayRef(g_regex_options);
 }
 
-// TODO: Convert these functions to return StringRefs.
-const char *GetHelp() {
-  return (m_help.empty() ? nullptr : m_help.c_str());
-}
+llvm::StringRef GetHelp() { return m_help; }
 
-const char *GetSyntax() {
-  return (m_syntax.empty() ? nullptr : m_syntax.c_str());
-}
+llvm::StringRef GetSyntax() { return m_syntax; }
 
   protected:
 // Instance variables to hold the values for command options.


Index: lldb/source/Commands/CommandObjectCommands.cpp
===
--- lldb/source/Commands/CommandObjectCommands.cpp
+++ lldb/source/Commands/CommandObjectCommands.cpp
@@ -527,14 +527,13 @@
 m_option_group.NotifyOptionParsingStarting(_ctx);
 
 OptionsWithRaw args_with_suffix(raw_command_line);
-const char *remainder = args_with_suffix.GetRawPart().c_str();
 
 if (args_with_suffix.HasArgs())
   if (!ParseOptionsAndNotify(args_with_suffix.GetArgs(), result,
  m_option_group, exe_ctx))
 return false;
 
-llvm::StringRef raw_command_string(remainder);
+llvm::StringRef raw_command_string = args_with_suffix.GetRawPart();
 Args args(raw_command_string);
 
 if (args.GetArgumentCount() < 2) {
@@ -1171,14 +1170,9 @@
   return llvm::makeArrayRef(g_regex_options);
 }
 
-// TODO: Convert these functions to return StringRefs.
-const char *GetHelp() {
-  return (m_help.empty() ? nullptr : m_help.c_str());
-}
+llvm::StringRef GetHelp() { return m_help; }
 
-const char *GetSyntax() {
-  return (m_syntax.empty() ? nullptr : m_syntax.c_str());
-}
+llvm::StringRef GetSyntax() { return m_syntax; }
 
   protected:
 // Instance variables to hold the values for command options.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D76476: Add formatter for libc++ std::unique_ptr

2020-03-23 Thread Shafik Yaghmour via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa567d6809e15: [DataFormatters] Add formatter for libc++ 
std::unique_ptr (authored by shafik).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D76476?vs=251783=252112#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76476

Files:
  lldb/include/lldb/DataFormatters/FormattersHelpers.h
  lldb/source/DataFormatters/FormattersHelpers.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
  lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp
@@ -0,0 +1,13 @@
+#include 
+#include 
+#include 
+
+int main() {
+  std::unique_ptr up_empty;
+  std::unique_ptr up_int = std::make_unique(10);
+  std::unique_ptr up_str = std::make_unique("hello");
+  std::unique_ptr _int_ref = up_int;
+  std::unique_ptr &_int_ref_ref = std::make_unique(10);
+
+  return 0; // break here
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
@@ -0,0 +1,47 @@
+"""
+Test lldb data formatter for libc++ std::unique_ptr.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class LibcxUniquePtrDataFormatterTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@add_test_categories(["libc++"])
+def test_with_run_command(self):
+"""Test that that file and class static variables display correctly."""
+self.build()
+
+(self.target, self.process, _, bkpt) = lldbutil.run_to_source_breakpoint(self, '// break here',
+lldb.SBFileSpec("main.cpp", False))
+
+self.expect("frame variable up_empty",
+substrs=['(std::unique_ptr >) up_empty = nullptr {',
+   '__value_ = ',
+   '}'])
+
+self.expect("frame variable up_int",
+substrs=['(std::unique_ptr >) up_int = 10 {',
+   '__value_ = ',
+   '}'])
+
+self.expect("frame variable up_int_ref",
+substrs=['(std::unique_ptr > &) up_int_ref = 10: {',
+   '__value_ = ',
+   '}'])
+
+self.expect("frame variable up_int_ref_ref",
+substrs=['(std::unique_ptr > &&) up_int_ref_ref = 10: {',
+   '__value_ = ',
+   '}'])
+
+self.expect("frame variable up_str",
+substrs=['up_str = "hello" {',
+   '__value_ = ',
+   '}'])
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/Makefile
@@ -0,0 +1,6 @@
+CXX_SOURCES := main.cpp
+
+USE_LIBCPP := 1
+
+CXXFLAGS_EXTRAS := -std=c++14
+include Makefile.rules
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
@@ -290,15 +290,6 @@
m_element_type);
 }
 
-static ValueObjectSP GetValueOfCompressedPair(ValueObject ) {
-  ValueObjectSP value = pair.GetChildMemberWithName(ConstString("__value_"), true);
-  if (! value) {
-// pre-r300140 member name
-value = pair.GetChildMemberWithName(ConstString("__first_"), true);
-  }
-  return value;
-}
-
 bool ForwardListFrontEnd::Update() {
   AbstractListFrontEnd::Update();
 
@@ -311,7 +302,7 @@
   m_backend.GetChildMemberWithName(ConstString("__before_begin_"), true));
   if (!impl_sp)
 return false;
-  impl_sp = GetValueOfCompressedPair(*impl_sp);
+  impl_sp = GetValueOfLibCXXCompressedPair(*impl_sp);
   if 

[Lldb-commits] [lldb] a567d68 - [DataFormatters] Add formatter for libc++ std::unique_ptr

2020-03-23 Thread via lldb-commits

Author: shafik
Date: 2020-03-23T11:48:20-07:00
New Revision: a567d6809e1514f34975d746bb1c93301792a74c

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

LOG: [DataFormatters] Add formatter for libc++ std::unique_ptr

This adds a formatter for libc++ std::unique_ptr.

I also refactored GetValueOfCompressedPair(...) out of LibCxxList.cpp since I 
need the same functionality and it made sense to share it.

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

Added: 

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

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp

Modified: 
lldb/include/lldb/DataFormatters/FormattersHelpers.h
lldb/source/DataFormatters/FormattersHelpers.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/FormattersHelpers.h 
b/lldb/include/lldb/DataFormatters/FormattersHelpers.h
index 93642e57fde0..a5b0da57e5d8 100644
--- a/lldb/include/lldb/DataFormatters/FormattersHelpers.h
+++ b/lldb/include/lldb/DataFormatters/FormattersHelpers.h
@@ -56,6 +56,8 @@ size_t ExtractIndexFromString(const char *item_name);
 
 lldb::addr_t GetArrayAddressOrPointerValue(ValueObject );
 
+lldb::ValueObjectSP GetValueOfLibCXXCompressedPair(ValueObject );
+
 time_t GetOSXEpoch();
 
 struct InferiorSizedWord {

diff  --git a/lldb/source/DataFormatters/FormattersHelpers.cpp 
b/lldb/source/DataFormatters/FormattersHelpers.cpp
index 96e93808c18e..7944ff06eee5 100644
--- a/lldb/source/DataFormatters/FormattersHelpers.cpp
+++ b/lldb/source/DataFormatters/FormattersHelpers.cpp
@@ -142,3 +142,14 @@ 
lldb_private::formatters::GetArrayAddressOrPointerValue(ValueObject ) {
 
   return data_addr;
 }
+
+lldb::ValueObjectSP
+lldb_private::formatters::GetValueOfLibCXXCompressedPair(ValueObject ) {
+  ValueObjectSP value =
+  pair.GetChildMemberWithName(ConstString("__value_"), true);
+  if (!value) {
+// pre-r300140 member name
+value = pair.GetChildMemberWithName(ConstString("__first_"), true);
+  }
+  return value;
+}

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 97084da5fffa..ecb577e0c531 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -611,6 +611,15 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   "shared_ptr synthetic children",
   ConstString("^(std::__[[:alnum:]]+::)shared_ptr<.+>(( )?&)?$"),
   stl_synth_flags, true);
+
+  ConstString libcxx_std_unique_ptr_regex(
+  "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$");
+  AddCXXSynthetic(
+  cpp_category_sp,
+  lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEndCreator,
+  "unique_ptr synthetic children", libcxx_std_unique_ptr_regex,
+  stl_synth_flags, true);
+
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator,
@@ -715,6 +724,10 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
 "libc++ std::weak_ptr summary provider",
 ConstString("^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"),
 stl_summary_flags, true);
+  AddCXXSummary(cpp_category_sp,
+lldb_private::formatters::LibcxxUniquePointerSummaryProvider,
+"libc++ std::unique_ptr summary provider",
+libcxx_std_unique_ptr_regex, stl_summary_flags, true);
 
   AddCXXSynthetic(
   cpp_category_sp,

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 7152ff407f29..84dd09a47d8a 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -144,6 +144,43 @@ bool 
lldb_private::formatters::LibcxxSmartPointerSummaryProvider(
   return true;
 }
 
+bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider(
+ValueObject , Stream , const TypeSummaryOptions ) {
+  ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
+  if (!valobj_sp)
+return false;
+
+  ValueObjectSP ptr_sp(
+  valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true));
+  if (!ptr_sp)
+return false;
+
+  ptr_sp = GetValueOfLibCXXCompressedPair(*ptr_sp);
+  if 

[Lldb-commits] [PATCH] D76593: [lldb-vscode] Convert g_vsc.launch_info to a local variable

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

Yes, this works now that we are creating the target in this function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76593



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


[Lldb-commits] [lldb] ae37e22 - [lldb/Reproducers] Mark reproducer test directory as unsupported on Windows

2020-03-23 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-03-23T09:54:11-07:00
New Revision: ae37e2285d233f28217e4e95a3ff71059c7ee8c7

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

LOG: [lldb/Reproducers] Mark reproducer test directory as unsupported on Windows

Reproducers are unsupported on Windows. Rather than having a UNSUPPORTED
line in every test, just skip the whole subdirectory.

Added: 


Modified: 
lldb/test/Shell/Reproducer/Functionalities/TestDataFormatter.test
lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test
lldb/test/Shell/Reproducer/Functionalities/TestImageList.test
lldb/test/Shell/Reproducer/Functionalities/TestStepping.test
lldb/test/Shell/Reproducer/TestCaptureEnvOverride.test
lldb/test/Shell/Reproducer/TestCrash.test
lldb/test/Shell/Reproducer/TestDiscard.test
lldb/test/Shell/Reproducer/TestDump.test
lldb/test/Shell/Reproducer/TestGDBRemoteRepro.test
lldb/test/Shell/Reproducer/TestMultipleTargets.test
lldb/test/Shell/Reproducer/TestRelativePath.test
lldb/test/Shell/Reproducer/TestReuseDirectory.test
lldb/test/Shell/Reproducer/TestSynchronous.test
lldb/test/Shell/Reproducer/TestWorkingDir.test
lldb/test/Shell/Reproducer/lit.local.cfg

Removed: 




diff  --git a/lldb/test/Shell/Reproducer/Functionalities/TestDataFormatter.test 
b/lldb/test/Shell/Reproducer/Functionalities/TestDataFormatter.test
index 7db8bc4b36cf..d133c8d3b9f9 100644
--- a/lldb/test/Shell/Reproducer/Functionalities/TestDataFormatter.test
+++ b/lldb/test/Shell/Reproducer/Functionalities/TestDataFormatter.test
@@ -1,4 +1,4 @@
-# UNSUPPORTED: system-windows, system-freebsd
+# UNSUPPORTED: system-freebsd
 
 # This tests that data formatters continue to work when replaying a reproducer.
 

diff  --git 
a/lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test 
b/lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test
index e2bcb2d96570..f400cef07a24 100644
--- a/lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test
+++ b/lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test
@@ -1,4 +1,4 @@
-# UNSUPPORTED: system-windows, system-freebsd
+# UNSUPPORTED: system-freebsd
 # XFAIL: system-netbsd
 
 # Flaky

diff  --git a/lldb/test/Shell/Reproducer/Functionalities/TestImageList.test 
b/lldb/test/Shell/Reproducer/Functionalities/TestImageList.test
index db319093f174..ec8b36ea9576 100644
--- a/lldb/test/Shell/Reproducer/Functionalities/TestImageList.test
+++ b/lldb/test/Shell/Reproducer/Functionalities/TestImageList.test
@@ -1,4 +1,4 @@
-# UNSUPPORTED: system-windows, system-freebsd
+# UNSUPPORTED: system-freebsd
 
 # This tests that image list works when replaying. We arbitrarily assume
 # there's at least two entries and compare that they're identical.

diff  --git a/lldb/test/Shell/Reproducer/Functionalities/TestStepping.test 
b/lldb/test/Shell/Reproducer/Functionalities/TestStepping.test
index 1dec9a077c7b..ba9164f4b43a 100644
--- a/lldb/test/Shell/Reproducer/Functionalities/TestStepping.test
+++ b/lldb/test/Shell/Reproducer/Functionalities/TestStepping.test
@@ -1,4 +1,4 @@
-# UNSUPPORTED: system-windows, system-freebsd
+# UNSUPPORTED: system-freebsd
 
 # This tests that stepping continues to work when replaying a reproducer.
 

diff  --git a/lldb/test/Shell/Reproducer/TestCaptureEnvOverride.test 
b/lldb/test/Shell/Reproducer/TestCaptureEnvOverride.test
index a8e7bdec250e..ef06bce8983f 100644
--- a/lldb/test/Shell/Reproducer/TestCaptureEnvOverride.test
+++ b/lldb/test/Shell/Reproducer/TestCaptureEnvOverride.test
@@ -1,4 +1,3 @@
-# UNSUPPORTED: system-windows
 # This tests the LLDB_CAPTURE_REPRODUCER override.
 
 # RUN: %lldb -b -o 'reproducer status' --capture --capture-path %t.repro 
/bin/ls | FileCheck %s --check-prefix CAPTURE

diff  --git a/lldb/test/Shell/Reproducer/TestCrash.test 
b/lldb/test/Shell/Reproducer/TestCrash.test
index cb0c09aad141..1389a9b76ad3 100644
--- a/lldb/test/Shell/Reproducer/TestCrash.test
+++ b/lldb/test/Shell/Reproducer/TestCrash.test
@@ -1,4 +1,3 @@
-# UNSUPPORTED: system-windows
 # This tests that a reproducer is generated when LLDB crashes.
 
 # Start clean.

diff  --git a/lldb/test/Shell/Reproducer/TestDiscard.test 
b/lldb/test/Shell/Reproducer/TestDiscard.test
index db9614aabb84..829aabbe2b03 100644
--- a/lldb/test/Shell/Reproducer/TestDiscard.test
+++ b/lldb/test/Shell/Reproducer/TestDiscard.test
@@ -1,4 +1,3 @@
-# UNSUPPORTED: system-windows
 # This ensures that the reproducer properly cleans up after itself.
 
 # Build the inferior.

diff  --git a/lldb/test/Shell/Reproducer/TestDump.test 
b/lldb/test/Shell/Reproducer/TestDump.test
index c193b806b547..8300a97004bb 100644
--- a/lldb/test/Shell/Reproducer/TestDump.test
+++ 

[Lldb-commits] [PATCH] D76626: [lldb/Reproducers] Collect files imported by command script import

2020-03-23 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: LLDB, labath, aprantl.

Files imported by the script interpreter aren't opened by LLDB so they don't 
end up in the reproducer. The solution is to explicitly add them to the 
FileCollector.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D76626

Files:
  lldb/include/lldb/Host/FileSystem.h
  lldb/source/Host/common/FileSystem.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/test/Shell/Reproducer/Inputs/foo.lua
  lldb/test/Shell/Reproducer/Inputs/foo.py
  lldb/test/Shell/Reproducer/TestLuaImport.test
  lldb/test/Shell/Reproducer/TestPythonImport.test

Index: lldb/test/Shell/Reproducer/TestPythonImport.test
===
--- /dev/null
+++ lldb/test/Shell/Reproducer/TestPythonImport.test
@@ -0,0 +1,11 @@
+# REQUIRES: python
+# UNSUPPORTED: system-windows
+# Ensure that the reproducers know about imported Python modules.
+
+# RUN: rm -rf %t.repro
+# RUN: %lldb -x -b --capture --capture-path %t.repro -o 'command script import  %S/Inputs/foo.py' -o 'reproducer generate' | FileCheck %s --check-prefix CAPTURE
+
+# CAPTURE: 95126
+
+# RUN: %lldb -b -o 'reproducer dump -p files -f %t.repro' | FileCheck %s --check-prefix FILES
+# FILES: foo.py
Index: lldb/test/Shell/Reproducer/TestLuaImport.test
===
--- /dev/null
+++ lldb/test/Shell/Reproducer/TestLuaImport.test
@@ -0,0 +1,11 @@
+# REQUIRES: lua
+# UNSUPPORTED: system-windows
+# Ensure that the reproducers know about imported Lua modules.
+
+# RUN: rm -rf %t.repro
+# RUN: %lldb -x -b --script-language lua --capture --capture-path %t.repro -o 'command script import  %S/Inputs/foo.lua' -o 'reproducer generate' | FileCheck %s --check-prefix CAPTURE
+
+# CAPTURE: 95126
+
+# RUN: %lldb -b -o 'reproducer dump -p files -f %t.repro' | FileCheck %s --check-prefix FILES
+# FILES: foo.lua
Index: lldb/test/Shell/Reproducer/Inputs/foo.py
===
--- /dev/null
+++ lldb/test/Shell/Reproducer/Inputs/foo.py
@@ -0,0 +1 @@
+print('95126')
Index: lldb/test/Shell/Reproducer/Inputs/foo.lua
===
--- /dev/null
+++ lldb/test/Shell/Reproducer/Inputs/foo.lua
@@ -0,0 +1 @@
+print('95126')
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -2772,6 +2772,7 @@
   {
 FileSpec target_file(pathname);
 FileSystem::Instance().Resolve(target_file);
+FileSystem::Instance().Collect(target_file);
 std::string basename(target_file.GetFilename().GetCString());
 
 StreamString command_stream;
Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -89,6 +89,7 @@
 const char *filename, bool init_session, lldb_private::Status ,
 StructuredData::ObjectSP *module_sp) {
 
+  FileSystem::Instance().Collect(filename);
   if (llvm::Error e = m_lua->LoadModule(filename)) {
 error.SetErrorStringWithFormatv("lua failed to import '{0}': {1}\n",
 filename, llvm::toString(std::move(e)));
Index: lldb/source/Host/common/FileSystem.cpp
===
--- lldb/source/Host/common/FileSystem.cpp
+++ lldb/source/Host/common/FileSystem.cpp
@@ -279,7 +279,7 @@
 std::shared_ptr
 FileSystem::CreateDataBuffer(const llvm::Twine , uint64_t size,
  uint64_t offset) {
-  AddFile(path);
+  Collect(path);
 
   const bool is_volatile = !IsLocal(path);
   const ErrorOr external_path = GetExternalPath(path);
@@ -417,7 +417,7 @@
 Expected FileSystem::Open(const FileSpec _spec,
   File::OpenOptions options,
   uint32_t permissions, bool should_close_fd) {
-  AddFile(file_spec.GetPath());
+  Collect(file_spec.GetPath());
 
   const int open_flags = GetOpenFlags(options);
   const mode_t open_mode =
@@ -465,7 +465,11 @@
   return GetExternalPath(file_spec.GetPath());
 }
 
-void FileSystem::AddFile(const llvm::Twine ) {
+void FileSystem::Collect(const FileSpec _spec) {
+  Collect(file_spec.GetPath());
+}
+
+void FileSystem::Collect(const llvm::Twine ) {
   if (m_collector && !llvm::sys::fs::is_directory(file)) {
 m_collector->addFile(file);
   }
Index: lldb/include/lldb/Host/FileSystem.h

[Lldb-commits] [PATCH] D74023: [RISCV] ELF attribute section for RISC-V

2020-03-23 Thread Hsiangkai Wang via Phabricator via lldb-commits
HsiangKai added a comment.

In D74023#1933427 , @jhenderson wrote:

> @HsiangKai, have you noticed that there are some test failures according to 
> the harbourmaster bot? They look like they could be related to this somehow.


@jhenderson, yes, I found test failures in harbormaster. The failures are 
occurred after I rebased my patch on master branch. After digging into error 
messages, I found the failures are triggered by find_if(). Maybe I misuse 
find_if() in this patch? Do you have any idea about this?
By the way, I also found some patch, D75015 , 
landed even harbormaster is failed. I am curious about is it a necessary 
condition to pass harbormaster before landing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74023



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


[Lldb-commits] [PATCH] D76569: Convert CommandObjectCommands functions to return StringRefs

2020-03-23 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

In D76569#1936796 , @shivammittal99 
wrote:

> > run by hand ASAN-built LLDB for the code modified by this patch.
>
> How do I do that? This is my first PR to llvm, so I am not aware of the 
> tools. Please bear with me.


FYI, after the fact, if you've already committed the patch, you can also check 
the sanitized bot, which runs the entire testsuite using an ASAN+UBSAN lldb: 
http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-sanitized/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76569



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


Re: [Lldb-commits] [lldb] b4a6e63 - [lldb/Target] Rework the way the inferior environment is created

2020-03-23 Thread Frédéric Riss via lldb-commits
The new testing for “inherit-env=false” is failing on Windows. I skipped the 
test for now.

Could it be that it never worked there? (In which case XFail would be a better 
resolution)
Does anyone have easy access to a Windows build to try it out?

Thanks,
Fred

> On Mar 23, 2020, at 7:59 AM, Fred Riss via lldb-commits 
>  wrote:
> 
> 
> Author: Fred Riss
> Date: 2020-03-23T07:58:34-07:00
> New Revision: b4a6e63ea12309bf667d1569a20ec5b081cbf2a4
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/b4a6e63ea12309bf667d1569a20ec5b081cbf2a4
> DIFF: 
> https://github.com/llvm/llvm-project/commit/b4a6e63ea12309bf667d1569a20ec5b081cbf2a4.diff
> 
> LOG: [lldb/Target] Rework the way the inferior environment is created
> 
> Summary:
> The interactions between the environment settings (`target.env-vars`,
> `target.inherit-env`) and the inferior life-cycle are non-obvious
> today. For example, if `target.inherit-env` is set, the `target.env-vars`
> setting will be augmented with the contents of the host environment
> the first time the launch environment is queried (usually at
> launch). After that point, toggling `target.inherit-env` will have no
> effect as there's no tracking of what comes from the host and what is
> a user setting.
> 
> This patch computes the environment every time it is queried rather
> than updating the contents of the `target.env-vars` property. This
> means that toggling the `target.inherit-env` property later will now
> have the intended effect.
> 
> This patch also adds a `target.unset-env-vars` settings that one can
> use to remove variables from the launch environment. Using this, you
> can inherit all but a few of the host environment.
> 
> The way the launch environment is constructed is:
>  1/ if `target.inherit-env` is set, then read the host environment
>  into the launch environment.
>  2/ Remove for the environment the variables listed in
>  `target.unset-env`.
>  3/ Augment the launch environment with the contents of
>  `target.env-vars`. This overrides any common values with the host
>  environment.
> 
> The one functional difference here that could be seen as a regression
> is that `target.env-vars` will not contain the inferior environment
> after launch. The patch implements a better alternative in the
> `target show-launch-environment` command which will return the
> environment computed through the above rules.
> 
> Reviewers: labath, jingham
> 
> Subscribers: lldb-commits
> 
> Tags: #lldb
> 
> Differential Revision: https://reviews.llvm.org/D76470
> 
> Added: 
> 
> 
> Modified: 
>lldb/include/lldb/Target/Target.h
>lldb/source/Commands/CommandObjectTarget.cpp
>lldb/source/Target/Target.cpp
>lldb/source/Target/TargetProperties.td
>lldb/test/API/commands/settings/TestSettings.py
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/lldb/include/lldb/Target/Target.h 
> b/lldb/include/lldb/Target/Target.h
> index 2e7932f49e6f..77cda4998192 100644
> --- a/lldb/include/lldb/Target/Target.h
> +++ b/lldb/include/lldb/Target/Target.h
> @@ -225,9 +225,12 @@ class TargetProperties : public Properties {
>   void DisableASLRValueChangedCallback();
>   void DisableSTDIOValueChangedCallback();
> 
> +  Environment ComputeEnvironment() const;
> +
>   // Member variables.
>   ProcessLaunchInfo m_launch_info;
>   std::unique_ptr m_experimental_properties_up;
> +  Target *m_target;
> };
> 
> class EvaluateExpressionOptions {
> 
> diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp 
> b/lldb/source/Commands/CommandObjectTarget.cpp
> index c70117c7a80a..95f81fc6cd54 100644
> --- a/lldb/source/Commands/CommandObjectTarget.cpp
> +++ b/lldb/source/Commands/CommandObjectTarget.cpp
> @@ -682,6 +682,41 @@ class CommandObjectTargetDelete : public 
> CommandObjectParsed {
>   OptionGroupBoolean m_cleanup_option;
> };
> 
> +class CommandObjectTargetShowLaunchEnvironment : public CommandObjectParsed {
> +public:
> +  CommandObjectTargetShowLaunchEnvironment(CommandInterpreter )
> +  : CommandObjectParsed(
> +interpreter, "target show-launch-environment",
> +"Shows the environment being passed to the process when 
> launched, "
> +"taking info account 3 settings: target.env-vars, "
> +"target.inherit-env and target.unset-env-vars.",
> +nullptr, eCommandRequiresTarget) {}
> +
> +  ~CommandObjectTargetShowLaunchEnvironment() override = default;
> +
> +protected:
> +  bool DoExecute(Args , CommandReturnObject ) override {
> +Target *target = m_exe_ctx.GetTargetPtr();
> +Environment env = target->GetEnvironment();
> +
> +std::vector env_vector;
> +env_vector.reserve(env.size());
> +for (auto  : env)
> +  env_vector.push_back();
> +std::sort(env_vector.begin(), env_vector.end(),
> +  [](Environment::value_type *a, Environment::value_type *b) {
> +return a->first() < b->first();
> +  

[Lldb-commits] [lldb] 7e10581 - [lldb/testsuite] Skip part of TestSettings.py on windows

2020-03-23 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-23T09:15:16-07:00
New Revision: 7e10581e8c15af39e6f0820768c5d43587f9088d

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

LOG: [lldb/testsuite] Skip part of TestSettings.py on windows

The newly introduced tests for unsetting environment variables
is failing on Windows. Skip the test there to allow investigation.

It seems like setting inherit-env to false was never tested
before. Could it be that the Windows process launcher doesn't
honor this setting?

Added: 


Modified: 
lldb/test/API/commands/settings/TestSettings.py

Removed: 




diff  --git a/lldb/test/API/commands/settings/TestSettings.py 
b/lldb/test/API/commands/settings/TestSettings.py
index 29360856a735..c0cdc085f129 100644
--- a/lldb/test/API/commands/settings/TestSettings.py
+++ b/lldb/test/API/commands/settings/TestSettings.py
@@ -286,6 +286,7 @@ def do_test_run_args_and_env_vars(self, use_launchsimple):
 "Environment variable 'MY_ENV_VAR' successfully passed."])
 
 @skipIfRemote  # it doesn't make sense to send host env to remote target
+@skipIf(oslist=["windows"])
 def test_pass_host_env_vars(self):
 """Test that the host env vars are passed to the launched process."""
 self.build()



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


[Lldb-commits] [PATCH] D76569: Convert CommandObjectCommands functions to return StringRefs

2020-03-23 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In D76569#1936796 , @shivammittal99 
wrote:

> How do I do that? This is my first PR to llvm, so I am not aware of the 
> tools. Please bear with me.


No big deal, just compile it with `-DLLVM_USE_SANITIZER=Address` as you have 
already done above and run `./bin/lldb` to test the code changed in this patch. 
Thanks for this work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76569



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


[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-23 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 252059.
kwk added a comment.

- Adjust buildID verification


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

Files:
  lldb/cmake/modules/FindDebuginfod.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/DebugInfoD.h
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/DebugInfoD.cpp
  lldb/test/CMakeLists.txt
  lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
  lldb/test/Shell/lit.cfg.py
  lldb/test/Shell/lit.site.cfg.py.in

Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -16,6 +16,7 @@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@
+config.lldb_enable_debuginfod = @LLDB_ENABLE_DEBUGINFOD@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
 config.lldb_enable_python = @LLDB_ENABLE_PYTHON@
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -117,6 +117,9 @@
 if config.lldb_enable_lzma:
 config.available_features.add('lzma')
 
+if config.lldb_enable_debuginfod:
+config.available_features.add('debuginfod')
+
 if find_executable('xz') != None:
 config.available_features.add('xz')
 
Index: lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
@@ -0,0 +1,135 @@
+// clang-format off
+// REQUIRES: debuginfod
+// UNSUPPORTED: darwin, windows
+
+//  Test that we can display the source of functions using debuginfod when the
+//  original source file is no longer present.
+//  
+//  The debuginfod client requires a buildid in the binary, so we compile one in.
+//  We can create the directory structure on disc that the client expects on a
+//  webserver that serves source files. Then we fire up a python based http
+//  server in the root of that mock directory, set the DEBUGINFOD_URLS
+//  environment variable and let LLDB do the rest. 
+//  
+//  Go here to find more about debuginfod:
+//  https://sourceware.org/elfutils/Debuginfod.html
+
+
+//We copy this file because we want to compile and later move it away
+
+// RUN: mkdir -p %t.buildroot
+// RUN: cp %s %t.buildroot/test.cpp
+
+//We use the prefix map in order to overwrite all DW_AT_decl_file paths
+//in the DWARF. We cd into the directory before compiling to get
+//DW_AT_comp_dir pickup %t.buildroot as well so it will be replaced by
+///my/new/path.
+
+// RUN: cd %t.buildroot
+// RUN: %clang_host \
+// RUN:   -g \
+// RUN:   -Wl,--build-id="0xaabbccdd" \
+// RUN:   -fdebug-prefix-map=%t.buildroot=/my/new/path \
+// RUN:   -o %t \
+// RUN:   %t.buildroot/test.cpp
+
+
+//We move the original source file to a directory that looks like a debuginfod
+//URL part.
+
+// RUN: rm -rf %t.mock
+// RUN: mkdir -p   %t.mock/buildid/aabbccdd/source/my/new/path
+// RUN: mv%t.buildroot/test.cpp %t.mock/buildid/aabbccdd/source/my/new/path
+
+
+//Adjust where debuginfod stores cache files:
+
+// RUN: rm -rf %t.debuginfod_cache_path
+// RUN: mkdir -p %t.debuginfod_cache_path
+// RUN: export DEBUGINFOD_CACHE_PATH=%t.debuginfod_cache_path
+
+
+//Start HTTP file server on port picked by OS and wait until it is ready
+//The server will be closed on exit of the test.
+
+// RUN: rm -f "%t.server.log"
+// RUN: timeout 5 python3 -u -m http.server 0 --directory %t.mock --bind "localhost" &> %t.server.log & export PID=$!
+// RUN: trap 'kill $PID;' EXIT INT
+
+
+//Extract HTTP address from the first line of the server log
+//(e.g. "Serving HTTP on 127.0.0.1 port 40587 (http://127.0.0.1:40587/) ..")
+
+// RUN: echo -n "Waiting for server to be ready"
+// RUN: SERVER_ADDRESS=""
+// RUN: while [ -z "$SERVER_ADDRESS" ]; do \
+// RUN: echo -n "."; \
+// RUN: sleep 0.01; \
+// RUN: SERVER_ADDRESS=$(head -n1 %t.server.log | grep "http://.\+/\+; -o); \
+// RUN: done
+// RUN: echo "DONE"
+
+
+//-- TEST 1 --  No debuginfod awareness 
+
+
+// RUN: DEBUGINFOD_URLS="" \
+// RUN: %lldb -f %t -o 'source list -n main' | FileCheck --dump-input=fail %s --check-prefix=TEST-1
+
+// TEST-1: (lldb) source list -n main
+// TEST-1: File: /my/new/path/test.cpp
+// TEST-1-EMPTY:
+
+
+//-- TEST 2 -- debuginfod URL pointing in wrong place --
+
+
+// RUN: DEBUGINFOD_URLS="http://example.com/debuginfod; \
+// RUN: %lldb -f %t -o 'source list -n main' 

[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-23 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 252054.
kwk marked 2 inline comments as done.
kwk added a comment.

- Remove commented out code
- Remove lldb/packages/Python/lldbsuite/test/httpserver.py in favor of lit test
- Removed commented out left-over code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

Files:
  lldb/cmake/modules/FindDebuginfod.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/DebugInfoD.h
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/DebugInfoD.cpp
  lldb/test/CMakeLists.txt
  lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
  lldb/test/Shell/lit.cfg.py
  lldb/test/Shell/lit.site.cfg.py.in

Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -16,6 +16,7 @@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@
+config.lldb_enable_debuginfod = @LLDB_ENABLE_DEBUGINFOD@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
 config.lldb_enable_python = @LLDB_ENABLE_PYTHON@
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -117,6 +117,9 @@
 if config.lldb_enable_lzma:
 config.available_features.add('lzma')
 
+if config.lldb_enable_debuginfod:
+config.available_features.add('debuginfod')
+
 if find_executable('xz') != None:
 config.available_features.add('xz')
 
Index: lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
@@ -0,0 +1,135 @@
+// clang-format off
+// REQUIRES: debuginfod
+// UNSUPPORTED: darwin, windows
+
+//  Test that we can display the source of functions using debuginfod when the
+//  original source file is no longer present.
+//  
+//  The debuginfod client requires a buildid in the binary, so we compile one in.
+//  We can create the directory structure on disc that the client expects on a
+//  webserver that serves source files. Then we fire up a python based http
+//  server in the root of that mock directory, set the DEBUGINFOD_URLS
+//  environment variable and let LLDB do the rest. 
+//  
+//  Go here to find more about debuginfod:
+//  https://sourceware.org/elfutils/Debuginfod.html
+
+
+//We copy this file because we want to compile and later move it away
+
+// RUN: mkdir -p %t.buildroot
+// RUN: cp %s %t.buildroot/test.cpp
+
+//We use the prefix map in order to overwrite all DW_AT_decl_file paths
+//in the DWARF. We cd into the directory before compiling to get
+//DW_AT_comp_dir pickup %t.buildroot as well so it will be replaced by
+///my/new/path.
+
+// RUN: cd %t.buildroot
+// RUN: %clang_host \
+// RUN:   -g \
+// RUN:   -Wl,--build-id="0xaabbccdd" \
+// RUN:   -fdebug-prefix-map=%t.buildroot=/my/new/path \
+// RUN:   -o %t \
+// RUN:   %t.buildroot/test.cpp
+
+
+//We move the original source file to a directory that looks like a debuginfod
+//URL part.
+
+// RUN: rm -rf %t.mock
+// RUN: mkdir -p   %t.mock/buildid/aabbccdd/source/my/new/path
+// RUN: mv%t.buildroot/test.cpp %t.mock/buildid/aabbccdd/source/my/new/path
+
+
+//Adjust where debuginfod stores cache files:
+
+// RUN: rm -rf %t.debuginfod_cache_path
+// RUN: mkdir -p %t.debuginfod_cache_path
+// RUN: export DEBUGINFOD_CACHE_PATH=%t.debuginfod_cache_path
+
+
+//Start HTTP file server on port picked by OS and wait until it is ready
+//The server will be closed on exit of the test.
+
+// RUN: rm -f "%t.server.log"
+// RUN: timeout 5 python3 -u -m http.server 0 --directory %t.mock --bind "localhost" &> %t.server.log & export PID=$!
+// RUN: trap 'kill $PID;' EXIT INT
+
+
+//Extract HTTP address from the first line of the server log
+//(e.g. "Serving HTTP on 127.0.0.1 port 40587 (http://127.0.0.1:40587/) ..")
+
+// RUN: echo -n "Waiting for server to be ready"
+// RUN: SERVER_ADDRESS=""
+// RUN: while [ -z "$SERVER_ADDRESS" ]; do \
+// RUN: echo -n "."; \
+// RUN: sleep 0.01; \
+// RUN: SERVER_ADDRESS=$(head -n1 %t.server.log | grep "http://.\+/\+; -o); \
+// RUN: done
+// RUN: echo "DONE"
+
+
+//-- TEST 1 --  No debuginfod awareness 
+
+
+// RUN: DEBUGINFOD_URLS="" \
+// RUN: %lldb -f %t -o 'source list -n main' | FileCheck --dump-input=fail %s --check-prefix=TEST-1
+
+// TEST-1: (lldb) source list -n main
+// TEST-1: File: /my/new/path/test.cpp
+// TEST-1-EMPTY:
+
+
+//-- TEST 2 -- debuginfod URL 

[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-23 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added inline comments.



Comment at: lldb/source/Host/common/DebugInfoD.cpp:43
+  buildID.GetBytes().size() ==
+  sizeof(llvm::support::ulittle32_t)) // .gnu_debuglink crc32
+return llvm::createStringError(llvm::inconvertibleErrorCode(),

If it is done this way (and not in `libdebuginfod.so`) I think there should be 
`<=8` because LLDB contains:
```
if (gnu_debuglink_crc) {
  // Use 4 bytes of crc from the .gnu_debuglink section.
  u32le data(gnu_debuglink_crc);
  uuid = UUID::fromData(, sizeof(data));
} else if (core_notes_crc) {
  // Use 8 bytes - first 4 bytes for *magic* prefix, mainly to make
  // it look different form .gnu_debuglink crc followed by 4 bytes
  // of note segments crc.
  u32le data[] = {u32le(g_core_uuid_magic), u32le(core_notes_crc)};
  uuid = UUID::fromData(data, sizeof(data));
}
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750



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


[Lldb-commits] [PATCH] D76009: [lldb/Target] Initialize new targets environment variables from target.env-vars

2020-03-23 Thread Frederic Riss via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9228a9efc6c5: [lldb/Target] Initialize new targets 
environment variables from target.env-vars (authored by friss).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76009

Files:
  lldb/include/lldb/Target/Target.h
  lldb/source/Target/Target.cpp
  lldb/test/API/commands/settings/TestSettings.py

Index: lldb/test/API/commands/settings/TestSettings.py
===
--- lldb/test/API/commands/settings/TestSettings.py
+++ lldb/test/API/commands/settings/TestSettings.py
@@ -218,6 +218,15 @@
 self.addTearDownHook(
 lambda: self.runCmd("settings clear target.env-vars"))
 
+launch_info = self.dbg.GetTargetAtIndex(0).GetLaunchInfo()
+found_env_var = False
+for i in range(0, launch_info.GetNumEnvironmentEntries()):
+if launch_info.GetEnvironmentEntryAtIndex(i) == "MY_ENV_VAR=YES":
+found_env_var = True
+break
+self.assertTrue(found_env_var,
+"MY_ENV_VAR was not set in LunchInfo object")
+
 self.runCmd("process launch --working-dir '{0}'".format(self.get_process_working_directory()),
 RUN_SUCCEEDED)
 
@@ -238,15 +247,6 @@
 """Test that the host env vars are passed to the launched process."""
 self.build()
 
-exe = self.getBuildArtifact("a.out")
-self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
-
-# By default, inherit-env is 'true'.
-self.expect(
-'settings show target.inherit-env',
-"Default inherit-env is 'true'",
-startstr="target.inherit-env (boolean) = true")
-
 # Set some host environment variables now.
 os.environ["MY_HOST_ENV_VAR1"] = "VAR1"
 os.environ["MY_HOST_ENV_VAR2"] = "VAR2"
@@ -256,6 +256,15 @@
 os.environ.pop("MY_HOST_ENV_VAR1")
 os.environ.pop("MY_HOST_ENV_VAR2")
 
+exe = self.getBuildArtifact("a.out")
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+# By default, inherit-env is 'true'.
+self.expect(
+'settings show target.inherit-env',
+"Default inherit-env is 'true'",
+startstr="target.inherit-env (boolean) = true")
+
 self.addTearDownHook(unset_env_variables)
 self.runCmd("process launch --working-dir '{0}'".format(self.get_process_working_directory()),
 RUN_SUCCEEDED)
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -113,6 +113,8 @@
  target_arch.GetArchitectureName(),
  target_arch.GetTriple().getTriple().c_str());
   }
+
+  UpdateLaunchInfoFromProperties();
 }
 
 Target::~Target() {
@@ -3468,18 +3470,6 @@
 ConstString("Experimental settings - setting these won't produce "
 "errors if the setting is not present."),
 true, m_experimental_properties_up->GetValueProperties());
-
-// Update m_launch_info once it was created
-Arg0ValueChangedCallback();
-RunArgsValueChangedCallback();
-// EnvVarsValueChangedCallback(); // FIXME: cause segfault in
-// Target::GetPlatform()
-InputPathValueChangedCallback();
-OutputPathValueChangedCallback();
-ErrorPathValueChangedCallback();
-DetachOnErrorValueChangedCallback();
-DisableASLRValueChangedCallback();
-DisableSTDIOValueChangedCallback();
   } else {
 m_collection_sp =
 std::make_shared(ConstString("target"));
@@ -3498,6 +3488,18 @@
 
 TargetProperties::~TargetProperties() = default;
 
+void TargetProperties::UpdateLaunchInfoFromProperties() {
+  Arg0ValueChangedCallback();
+  RunArgsValueChangedCallback();
+  EnvVarsValueChangedCallback();
+  InputPathValueChangedCallback();
+  OutputPathValueChangedCallback();
+  ErrorPathValueChangedCallback();
+  DetachOnErrorValueChangedCallback();
+  DisableASLRValueChangedCallback();
+  DisableSTDIOValueChangedCallback();
+}
+
 bool TargetProperties::GetInjectLocalVariables(
 ExecutionContext *exe_ctx) const {
   const Property *exp_property = m_collection_sp->GetPropertyAtIndex(
Index: lldb/include/lldb/Target/Target.h
===
--- lldb/include/lldb/Target/Target.h
+++ lldb/include/lldb/Target/Target.h
@@ -211,6 +211,8 @@
 
   bool GetAutoInstallMainExecutable() const;
 
+  void UpdateLaunchInfoFromProperties();
+
 private:
   // Callbacks for m_launch_info.
   void Arg0ValueChangedCallback();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D76045: [lldb/API] Make Launch(Simple) use args and env from target properties

2020-03-23 Thread Frederic Riss via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcd7b45057ca9: [lldb/API] Make Launch(Simple) use args and 
env from target properties (authored by friss).

Changed prior to commit:
  https://reviews.llvm.org/D76045?vs=249834=252051#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76045

Files:
  lldb/include/lldb/API/SBTarget.h
  lldb/source/API/SBTarget.cpp
  lldb/test/API/commands/settings/TestSettings.py

Index: lldb/test/API/commands/settings/TestSettings.py
===
--- lldb/test/API/commands/settings/TestSettings.py
+++ lldb/test/API/commands/settings/TestSettings.py
@@ -204,10 +204,15 @@
 
 @skipIfDarwinEmbedded   #  debugserver on ios etc can't write files
 def test_run_args_and_env_vars(self):
+self.do_test_run_args_and_env_vars(use_launchsimple=False)
+
+@skipIfDarwinEmbedded   #  debugserver on ios etc can't write files
+def test_launchsimple_args_and_env_vars(self):
+self.do_test_run_args_and_env_vars(use_launchsimple=True)
+
+def do_test_run_args_and_env_vars(self, use_launchsimple):
 """Test that run-args and env-vars are passed to the launched process."""
 self.build()
-exe = self.getBuildArtifact("a.out")
-self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
 # Set the run-args and the env-vars.
 # And add hooks to restore the settings during tearDown().
@@ -218,7 +223,11 @@
 self.addTearDownHook(
 lambda: self.runCmd("settings clear target.env-vars"))
 
-launch_info = self.dbg.GetTargetAtIndex(0).GetLaunchInfo()
+exe = self.getBuildArtifact("a.out")
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+target = self.dbg.GetTargetAtIndex(0)
+launch_info = target.GetLaunchInfo()
 found_env_var = False
 for i in range(0, launch_info.GetNumEnvironmentEntries()):
 if launch_info.GetEnvironmentEntryAtIndex(i) == "MY_ENV_VAR=YES":
@@ -227,7 +236,12 @@
 self.assertTrue(found_env_var,
 "MY_ENV_VAR was not set in LunchInfo object")
 
-self.runCmd("process launch --working-dir '{0}'".format(self.get_process_working_directory()),
+wd = self.get_process_working_directory()
+if use_launchsimple:
+process = target.LaunchSimple(None, None, wd)
+self.assertTrue(process)
+else:
+self.runCmd("process launch --working-dir '{0}'".format(wd),
 RUN_SUCCEEDED)
 
 # Read the output file produced by running the program.
Index: lldb/source/API/SBTarget.cpp
===
--- lldb/source/API/SBTarget.cpp
+++ lldb/source/API/SBTarget.cpp
@@ -371,10 +371,19 @@
 Module *exe_module = target_sp->GetExecutableModulePointer();
 if (exe_module)
   launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
-if (argv)
+if (argv) {
   launch_info.GetArguments().AppendArguments(argv);
-if (envp)
+} else {
+  auto default_launch_info = target_sp->GetProcessLaunchInfo();
+  launch_info.GetArguments().AppendArguments(
+  default_launch_info.GetArguments());
+}
+if (envp) {
   launch_info.GetEnvironment() = Environment(envp);
+} else {
+  auto default_launch_info = target_sp->GetProcessLaunchInfo();
+  launch_info.GetEnvironment() = default_launch_info.GetEnvironment();
+}
 
 if (listener.IsValid())
   launch_info.SetListener(listener.GetSP());
Index: lldb/include/lldb/API/SBTarget.h
===
--- lldb/include/lldb/API/SBTarget.h
+++ lldb/include/lldb/API/SBTarget.h
@@ -127,7 +127,9 @@
   /// The argument array.
   ///
   /// \param[in] envp
-  /// The environment array.
+  /// The environment array. If this is null, the default
+  /// environment values (provided through `settings set
+  /// target.env-vars`) will be used.
   ///
   /// \param[in] stdin_path
   /// The path to use when re-directing the STDIN of the new
@@ -175,7 +177,9 @@
   /// The argument array.
   ///
   /// \param[in] envp
-  /// The environment array.
+  /// The environment array. If this isn't provided, the default
+  /// environment values (provided through `settings set
+  /// target.env-vars`) will be used.
   ///
   /// \param[in] working_directory
   /// The working directory to have the child process run in
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D76470: [lldb/Target] Rework the way the inferior environment is created

2020-03-23 Thread Frederic Riss via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb4a6e63ea123: [lldb/Target] Rework the way the inferior 
environment is created (authored by friss).

Changed prior to commit:
  https://reviews.llvm.org/D76470?vs=251813=252052#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76470

Files:
  lldb/include/lldb/Target/Target.h
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetProperties.td
  lldb/test/API/commands/settings/TestSettings.py

Index: lldb/test/API/commands/settings/TestSettings.py
===
--- lldb/test/API/commands/settings/TestSettings.py
+++ lldb/test/API/commands/settings/TestSettings.py
@@ -236,6 +236,10 @@
 self.assertTrue(found_env_var,
 "MY_ENV_VAR was not set in LunchInfo object")
 
+self.expect(
+'target show-launch-environment',
+substrs=["MY_ENV_VAR=YES"])
+
 wd = self.get_process_working_directory()
 if use_launchsimple:
 process = target.LaunchSimple(None, None, wd)
@@ -256,6 +260,31 @@
 "argv[3] matches",
 "Environment variable 'MY_ENV_VAR' successfully passed."])
 
+# Check that env-vars overrides unset-env-vars.
+self.runCmd('settings set target.unset-env-vars MY_ENV_VAR')
+
+self.expect(
+'target show-launch-environment',
+'env-vars overrides unset-env-vars',
+substrs=["MY_ENV_VAR=YES"])
+
+wd = self.get_process_working_directory()
+if use_launchsimple:
+process = target.LaunchSimple(None, None, wd)
+self.assertTrue(process)
+else:
+self.runCmd("process launch --working-dir '{0}'".format(wd),
+RUN_SUCCEEDED)
+
+# Read the output file produced by running the program.
+output = lldbutil.read_file_from_process_wd(self, "output2.txt")
+
+self.expect(
+output,
+exe=False,
+substrs=[
+"Environment variable 'MY_ENV_VAR' successfully passed."])
+
 @skipIfRemote  # it doesn't make sense to send host env to remote target
 def test_pass_host_env_vars(self):
 """Test that the host env vars are passed to the launched process."""
@@ -269,6 +298,7 @@
 def unset_env_variables():
 os.environ.pop("MY_HOST_ENV_VAR1")
 os.environ.pop("MY_HOST_ENV_VAR2")
+self.addTearDownHook(unset_env_variables)
 
 exe = self.getBuildArtifact("a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
@@ -279,7 +309,33 @@
 "Default inherit-env is 'true'",
 startstr="target.inherit-env (boolean) = true")
 
-self.addTearDownHook(unset_env_variables)
+self.expect(
+'target show-launch-environment',
+'Host environment is passed correctly',
+substrs=['MY_HOST_ENV_VAR1=VAR1', 'MY_HOST_ENV_VAR2=VAR2'])
+self.runCmd("process launch --working-dir '{0}'".format(self.get_process_working_directory()),
+RUN_SUCCEEDED)
+
+# Read the output file produced by running the program.
+output = lldbutil.read_file_from_process_wd(self, "output1.txt")
+
+self.expect(
+output,
+exe=False,
+substrs=[
+"The host environment variable 'MY_HOST_ENV_VAR1' successfully passed.",
+"The host environment variable 'MY_HOST_ENV_VAR2' successfully passed."])
+
+# Now test that we can prevent the inferior from inheriting the
+# environment.
+self.runCmd('settings set target.inherit-env false')
+
+self.expect(
+'target show-launch-environment',
+'target.inherit-env affects `target show-launch-environment`',
+matching=False,
+substrs = ['MY_HOST_ENV_VAR1=VAR1', 'MY_HOST_ENV_VAR2=VAR2'])
+
 self.runCmd("process launch --working-dir '{0}'".format(self.get_process_working_directory()),
 RUN_SUCCEEDED)
 
@@ -289,10 +345,42 @@
 self.expect(
 output,
 exe=False,
+matching=False,
 substrs=[
 "The host environment variable 'MY_HOST_ENV_VAR1' successfully passed.",
 "The host environment variable 'MY_HOST_ENV_VAR2' successfully passed."])
 
+# Now test that we can unset variables from the inherited environment.
+self.runCmd('settings set target.inherit-env true')
+self.runCmd('settings set target.unset-env-vars MY_HOST_ENV_VAR1')
+self.runCmd("process launch --working-dir '{0}'".format(self.get_process_working_directory()),
+RUN_SUCCEEDED)
+
+# Read the output file produced by running the 

[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-23 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

@labath @fche2 @jankratochvil I've implemented the logic to ignore invalid 
UUIDs and the ones that are too short. Can you have another look please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750



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


[Lldb-commits] [lldb] cd7b450 - [lldb/API] Make Launch(Simple) use args and env from target properties

2020-03-23 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-23T07:58:33-07:00
New Revision: cd7b45057ca9bc72b99a0abc6c9be25e0f72fbcf

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

LOG: [lldb/API] Make Launch(Simple) use args and env from target properties

Summary:
When no arguments or environment is provided to SBTarget::LaunchSimple,
make it use the values surrently set in the target properties. You can
get the current behavior back by passing an empty array instead.

It seems like using the target defaults is a much more intuitive
behavior for those APIs. It's unllikely that anyone passed NULL/None to
this API after having set properties in order to explicitely ignore them.

One direct application of this change is within the testsuite. We have
plenty of tests calling LaunchSimple and passing None as environment.
If you passed --inferior-env to dotest.py to, for example, set
(DY)LD_LIBRARY_PATH, it wouldn't be taken into account.

Reviewers: jingham, labath, #libc_abi!

Subscribers: libcxx-commits, lldb-commits

Tags: #lldb, #libc_abi

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

Added: 


Modified: 
lldb/include/lldb/API/SBTarget.h
lldb/source/API/SBTarget.cpp
lldb/test/API/commands/settings/TestSettings.py

Removed: 




diff  --git a/lldb/include/lldb/API/SBTarget.h 
b/lldb/include/lldb/API/SBTarget.h
index a50e791d4fe3..1db54279fcb5 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -127,7 +127,9 @@ class LLDB_API SBTarget {
   /// The argument array.
   ///
   /// \param[in] envp
-  /// The environment array.
+  /// The environment array. If this is null, the default
+  /// environment values (provided through `settings set
+  /// target.env-vars`) will be used.
   ///
   /// \param[in] stdin_path
   /// The path to use when re-directing the STDIN of the new
@@ -175,7 +177,9 @@ class LLDB_API SBTarget {
   /// The argument array.
   ///
   /// \param[in] envp
-  /// The environment array.
+  /// The environment array. If this isn't provided, the default
+  /// environment values (provided through `settings set
+  /// target.env-vars`) will be used.
   ///
   /// \param[in] working_directory
   /// The working directory to have the child process run in

diff  --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index b90e77280d24..a70f54135e02 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -371,10 +371,19 @@ SBProcess SBTarget::Launch(SBListener , char 
const **argv,
 Module *exe_module = target_sp->GetExecutableModulePointer();
 if (exe_module)
   launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
-if (argv)
+if (argv) {
   launch_info.GetArguments().AppendArguments(argv);
-if (envp)
+} else {
+  auto default_launch_info = target_sp->GetProcessLaunchInfo();
+  launch_info.GetArguments().AppendArguments(
+  default_launch_info.GetArguments());
+}
+if (envp) {
   launch_info.GetEnvironment() = Environment(envp);
+} else {
+  auto default_launch_info = target_sp->GetProcessLaunchInfo();
+  launch_info.GetEnvironment() = default_launch_info.GetEnvironment();
+}
 
 if (listener.IsValid())
   launch_info.SetListener(listener.GetSP());

diff  --git a/lldb/test/API/commands/settings/TestSettings.py 
b/lldb/test/API/commands/settings/TestSettings.py
index 6ec59bbe7a09..b203f85de9fb 100644
--- a/lldb/test/API/commands/settings/TestSettings.py
+++ b/lldb/test/API/commands/settings/TestSettings.py
@@ -204,10 +204,15 @@ def test_disassembler_settings(self):
 
 @skipIfDarwinEmbedded   #  debugserver on ios etc 
can't write files
 def test_run_args_and_env_vars(self):
+self.do_test_run_args_and_env_vars(use_launchsimple=False)
+
+@skipIfDarwinEmbedded   #  debugserver on ios etc 
can't write files
+def test_launchsimple_args_and_env_vars(self):
+self.do_test_run_args_and_env_vars(use_launchsimple=True)
+
+def do_test_run_args_and_env_vars(self, use_launchsimple):
 """Test that run-args and env-vars are passed to the launched 
process."""
 self.build()
-exe = self.getBuildArtifact("a.out")
-self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
 # Set the run-args and the env-vars.
 # And add hooks to restore the settings during tearDown().
@@ -218,7 +223,11 @@ def test_run_args_and_env_vars(self):
 self.addTearDownHook(
 lambda: self.runCmd("settings clear target.env-vars"))
 
-launch_info = self.dbg.GetTargetAtIndex(0).GetLaunchInfo()
+exe = self.getBuildArtifact("a.out")
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+  

[Lldb-commits] [lldb] 9228a9e - [lldb/Target] Initialize new targets environment variables from target.env-vars

2020-03-23 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-23T07:58:33-07:00
New Revision: 9228a9efc6c57a932d936ebb214f6ff5bafe79ff

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

LOG: [lldb/Target] Initialize new targets environment variables from 
target.env-vars

Summary:
The TargetProperties constructor invokes a series of callbacks to
prime the properties from the default ones. The one callback in
charge of updating the inferior environment was commented out
because it crashed.

The reason for the crash is that TargetProperties is a parent class
of Target and the callbacks were invoked using a Target that was
not fully initialized. This patch moves the initial callback
invocations to a separate function that can be called at the end
the Target constructor, thus preventing the crash.

One existing test had to be modified, because the initialization of
the environment properties now take place at the time the target is
created, not at the first use of the environment (usually launch
time).

The added test checks that the LaunchInfo object returned by
the target has been primed with the values from the settings.

Reviewers: jingham, labath

Subscribers: lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/include/lldb/Target/Target.h
lldb/source/Target/Target.cpp
lldb/test/API/commands/settings/TestSettings.py

Removed: 




diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 3a8570c0d630..2e7932f49e6f 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -211,6 +211,8 @@ class TargetProperties : public Properties {
 
   bool GetAutoInstallMainExecutable() const;
 
+  void UpdateLaunchInfoFromProperties();
+
 private:
   // Callbacks for m_launch_info.
   void Arg0ValueChangedCallback();

diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 2bb53bcd4230..0162ca838e78 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -113,6 +113,8 @@ Target::Target(Debugger , const ArchSpec 
_arch,
  target_arch.GetArchitectureName(),
  target_arch.GetTriple().getTriple().c_str());
   }
+
+  UpdateLaunchInfoFromProperties();
 }
 
 Target::~Target() {
@@ -3468,18 +3470,6 @@ TargetProperties::TargetProperties(Target *target)
 ConstString("Experimental settings - setting these won't produce "
 "errors if the setting is not present."),
 true, m_experimental_properties_up->GetValueProperties());
-
-// Update m_launch_info once it was created
-Arg0ValueChangedCallback();
-RunArgsValueChangedCallback();
-// EnvVarsValueChangedCallback(); // FIXME: cause segfault in
-// Target::GetPlatform()
-InputPathValueChangedCallback();
-OutputPathValueChangedCallback();
-ErrorPathValueChangedCallback();
-DetachOnErrorValueChangedCallback();
-DisableASLRValueChangedCallback();
-DisableSTDIOValueChangedCallback();
   } else {
 m_collection_sp =
 std::make_shared(ConstString("target"));
@@ -3498,6 +3488,18 @@ TargetProperties::TargetProperties(Target *target)
 
 TargetProperties::~TargetProperties() = default;
 
+void TargetProperties::UpdateLaunchInfoFromProperties() {
+  Arg0ValueChangedCallback();
+  RunArgsValueChangedCallback();
+  EnvVarsValueChangedCallback();
+  InputPathValueChangedCallback();
+  OutputPathValueChangedCallback();
+  ErrorPathValueChangedCallback();
+  DetachOnErrorValueChangedCallback();
+  DisableASLRValueChangedCallback();
+  DisableSTDIOValueChangedCallback();
+}
+
 bool TargetProperties::GetInjectLocalVariables(
 ExecutionContext *exe_ctx) const {
   const Property *exp_property = m_collection_sp->GetPropertyAtIndex(

diff  --git a/lldb/test/API/commands/settings/TestSettings.py 
b/lldb/test/API/commands/settings/TestSettings.py
index ffb194fda808..6ec59bbe7a09 100644
--- a/lldb/test/API/commands/settings/TestSettings.py
+++ b/lldb/test/API/commands/settings/TestSettings.py
@@ -218,6 +218,15 @@ def test_run_args_and_env_vars(self):
 self.addTearDownHook(
 lambda: self.runCmd("settings clear target.env-vars"))
 
+launch_info = self.dbg.GetTargetAtIndex(0).GetLaunchInfo()
+found_env_var = False
+for i in range(0, launch_info.GetNumEnvironmentEntries()):
+if launch_info.GetEnvironmentEntryAtIndex(i) == "MY_ENV_VAR=YES":
+found_env_var = True
+break
+self.assertTrue(found_env_var,
+"MY_ENV_VAR was not set in LunchInfo object")
+
 self.runCmd("process launch --working-dir 
'{0}'".format(self.get_process_working_directory()),
 RUN_SUCCEEDED)
 
@@ -238,15 

[Lldb-commits] [lldb] b4a6e63 - [lldb/Target] Rework the way the inferior environment is created

2020-03-23 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-23T07:58:34-07:00
New Revision: b4a6e63ea12309bf667d1569a20ec5b081cbf2a4

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

LOG: [lldb/Target] Rework the way the inferior environment is created

Summary:
The interactions between the environment settings (`target.env-vars`,
`target.inherit-env`) and the inferior life-cycle are non-obvious
today. For example, if `target.inherit-env` is set, the `target.env-vars`
setting will be augmented with the contents of the host environment
the first time the launch environment is queried (usually at
launch). After that point, toggling `target.inherit-env` will have no
effect as there's no tracking of what comes from the host and what is
a user setting.

This patch computes the environment every time it is queried rather
than updating the contents of the `target.env-vars` property. This
means that toggling the `target.inherit-env` property later will now
have the intended effect.

This patch also adds a `target.unset-env-vars` settings that one can
use to remove variables from the launch environment. Using this, you
can inherit all but a few of the host environment.

The way the launch environment is constructed is:
  1/ if `target.inherit-env` is set, then read the host environment
  into the launch environment.
  2/ Remove for the environment the variables listed in
  `target.unset-env`.
  3/ Augment the launch environment with the contents of
  `target.env-vars`. This overrides any common values with the host
  environment.

The one functional difference here that could be seen as a regression
is that `target.env-vars` will not contain the inferior environment
after launch. The patch implements a better alternative in the
`target show-launch-environment` command which will return the
environment computed through the above rules.

Reviewers: labath, jingham

Subscribers: lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/include/lldb/Target/Target.h
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/TargetProperties.td
lldb/test/API/commands/settings/TestSettings.py

Removed: 




diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 2e7932f49e6f..77cda4998192 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -225,9 +225,12 @@ class TargetProperties : public Properties {
   void DisableASLRValueChangedCallback();
   void DisableSTDIOValueChangedCallback();
 
+  Environment ComputeEnvironment() const;
+
   // Member variables.
   ProcessLaunchInfo m_launch_info;
   std::unique_ptr m_experimental_properties_up;
+  Target *m_target;
 };
 
 class EvaluateExpressionOptions {

diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index c70117c7a80a..95f81fc6cd54 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -682,6 +682,41 @@ class CommandObjectTargetDelete : public 
CommandObjectParsed {
   OptionGroupBoolean m_cleanup_option;
 };
 
+class CommandObjectTargetShowLaunchEnvironment : public CommandObjectParsed {
+public:
+  CommandObjectTargetShowLaunchEnvironment(CommandInterpreter )
+  : CommandObjectParsed(
+interpreter, "target show-launch-environment",
+"Shows the environment being passed to the process when launched, "
+"taking info account 3 settings: target.env-vars, "
+"target.inherit-env and target.unset-env-vars.",
+nullptr, eCommandRequiresTarget) {}
+
+  ~CommandObjectTargetShowLaunchEnvironment() override = default;
+
+protected:
+  bool DoExecute(Args , CommandReturnObject ) override {
+Target *target = m_exe_ctx.GetTargetPtr();
+Environment env = target->GetEnvironment();
+
+std::vector env_vector;
+env_vector.reserve(env.size());
+for (auto  : env)
+  env_vector.push_back();
+std::sort(env_vector.begin(), env_vector.end(),
+  [](Environment::value_type *a, Environment::value_type *b) {
+return a->first() < b->first();
+  });
+
+auto  = result.GetOutputStream();
+for (auto  : env_vector)
+  strm.Format("{0}={1}\n", KV->first(), KV->second);
+
+result.SetStatus(eReturnStatusSuccessFinishResult);
+return result.Succeeded();
+  }
+};
+
 #pragma mark CommandObjectTargetVariable
 
 // "target variable"
@@ -4876,6 +4911,9 @@ 
CommandObjectMultiwordTarget::CommandObjectMultiwordTarget(
  CommandObjectSP(new CommandObjectTargetList(interpreter)));
   LoadSubCommand("select",
  CommandObjectSP(new 

[Lldb-commits] [PATCH] D76593: [lldb-vscode] Convert g_vsc.launch_info to a local variable

2020-03-23 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D76593#1936757 , @anton.kolesov 
wrote:

> In D76593#1936337 , @labath wrote:
>
> > Sounds like a good idea. Could you do the same for `attach_info` (it looks 
> > like it should be possible)? Otherwise, one is left wondering about what's 
> > the difference...
>
>
> I have that as my next patch - it seems like something that should be in a 
> separate commit, but in the same pull request, but I don't know how to 
> properly submit patch series for review at Phabricator - only through 
> "related revisions", I presume?


You can (and should) use the "related revisions" functionality to denote the 
relationship between patches, but the purpose of this relationship is to make 
it easier to review by explaining what depends on what. We don't really have a 
concept of a "pull request" consisting of multiple patches, which get all 
committed as a group. Normally each patch should make sense on its own, even if 
it's not immediately useful (e.g. because it introduces an interface that is 
not yet used by anyone). The "related" patches can then explain/demonstrate how 
it's going to be used, but the preceding patches don't need to wait for a green 
light on the entire group to be committed. If there's some deviation from this 
(e.g. a preparatory refactoring patch makes some code substantially more 
complicated and so it may not be desired if the latter patch is not accepted, 
or there is some uncertainty about the overall direction of the patchset), it 
should be called out explicitly.

But none of this is really relevant for this patch, which is so simple you 
could have done it in one commit (and it could be argued that it *should* be 
done in a single commit, as doing it partway introduces a somewhat inconsistent 
state, which is undesirable).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76593



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


[Lldb-commits] [PATCH] D76280: [lldb] Mark expressions that couldn't be parsed or executed as failed expressions

2020-03-23 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6a4905ae2d65: [lldb] Mark expressions that couldnt be 
parsed or executed as failed… (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76280

Files:
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Commands/CommandObjectExpression.h
  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
@@ -21,6 +21,20 @@
 self.expect("statistics dump", substrs=['expr evaluation successes : 
1\n',
 'expr evaluation failures : 
0\n'])
 
+self.expect("statistics enable")
+# Doesn't parse.
+self.expect("expr doesnt_exist", error=True,
+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.
+self.expect("expr -Z 3 -- 1", error=True,
+substrs=["expression cannot be used with --element-count"])
+self.expect("statistics disable")
+# We should have gotten 3 new failures and the previous success.
+self.expect("statistics dump", substrs=['expr evaluation successes : 
1\n',
+'expr evaluation failures : 
3\n'])
+
 # 'frame var' with disabled statistics shouldn't change stats.
 self.expect("frame var", substrs=['27'])
 
Index: lldb/source/Commands/CommandObjectExpression.h
===
--- lldb/source/Commands/CommandObjectExpression.h
+++ lldb/source/Commands/CommandObjectExpression.h
@@ -71,6 +71,16 @@
   /// expression in the given target.
   EvaluateExpressionOptions GetEvalOptions(const Target );
 
+  /// Evaluates the given expression.
+  /// \param output_stream The stream to which the evaluation result will be
+  ///  printed.
+  /// \param error_stream Contains error messages that should be displayed to
+  /// the user in case the evaluation fails.
+  /// \param result A CommandReturnObject which status will be set to the
+  ///   appropriate value depending on evaluation success and
+  ///   whether the expression produced any result.
+  /// \return Returns true iff the expression was successfully evaluated,
+  /// executed and the result could be printed to the output stream.
   bool EvaluateExpression(llvm::StringRef expr, Stream _stream,
   Stream _stream, CommandReturnObject );
 
Index: lldb/source/Commands/CommandObjectExpression.cpp
===
--- lldb/source/Commands/CommandObjectExpression.cpp
+++ lldb/source/Commands/CommandObjectExpression.cpp
@@ -486,7 +486,8 @@
 }
   }
 
-  return true;
+  return (success != eExpressionSetupError &&
+  success != eExpressionParseError);
 }
 
 void CommandObjectExpression::IOHandlerInputComplete(IOHandler _handler,


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
@@ -21,6 +21,20 @@
 self.expect("statistics dump", substrs=['expr evaluation successes : 1\n',
 'expr evaluation failures : 0\n'])
 
+self.expect("statistics enable")
+# Doesn't parse.
+self.expect("expr doesnt_exist", error=True,
+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.
+self.expect("expr -Z 3 -- 1", error=True,
+substrs=["expression cannot be used with --element-count"])
+self.expect("statistics disable")
+# We should have gotten 3 new failures and the previous success.
+self.expect("statistics dump", substrs=['expr evaluation successes : 1\n',
+'expr evaluation failures : 3\n'])
+
 # 'frame var' with disabled statistics shouldn't change stats.
 self.expect("frame var", substrs=['27'])
 
Index: lldb/source/Commands/CommandObjectExpression.h
===

[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-23 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 252026.
kwk added a comment.

- check for valid UUID
- less verbose mkdir and rm output
- More explicit test and documentation
- fixup


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

Files:
  lldb/cmake/modules/FindDebuginfod.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/DebugInfoD.h
  lldb/packages/Python/lldbsuite/test/httpserver.py
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/DebugInfoD.cpp
  lldb/test/CMakeLists.txt
  lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
  lldb/test/Shell/lit.cfg.py
  lldb/test/Shell/lit.site.cfg.py.in

Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -16,6 +16,7 @@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@
+config.lldb_enable_debuginfod = @LLDB_ENABLE_DEBUGINFOD@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
 config.lldb_enable_python = @LLDB_ENABLE_PYTHON@
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -117,6 +117,9 @@
 if config.lldb_enable_lzma:
 config.available_features.add('lzma')
 
+if config.lldb_enable_debuginfod:
+config.available_features.add('debuginfod')
+
 if find_executable('xz') != None:
 config.available_features.add('xz')
 
Index: lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
@@ -0,0 +1,135 @@
+// clang-format off
+// REQUIRES: debuginfod
+// UNSUPPORTED: darwin, windows
+
+//  Test that we can display the source of functions using debuginfod when the
+//  original source file is no longer present.
+//  
+//  The debuginfod client requires a buildid in the binary, so we compile one in.
+//  We can create the directory structure on disc that the client expects on a
+//  webserver that serves source files. Then we fire up a python based http
+//  server in the root of that mock directory, set the DEBUGINFOD_URLS
+//  environment variable and let LLDB do the rest. 
+//  
+//  Go here to find more about debuginfod:
+//  https://sourceware.org/elfutils/Debuginfod.html
+
+
+//We copy this file because we want to compile and later move it away
+
+// RUN: mkdir -p %t.buildroot
+// RUN: cp %s %t.buildroot/test.cpp
+
+//We use the prefix map in order to overwrite all DW_AT_decl_file paths
+//in the DWARF. We cd into the directory before compiling to get
+//DW_AT_comp_dir pickup %t.buildroot as well so it will be replaced by
+///my/new/path.
+
+// RUN: cd %t.buildroot
+// RUN: %clang_host \
+// RUN:   -g \
+// RUN:   -Wl,--build-id="0xaabbccdd" \
+// RUN:   -fdebug-prefix-map=%t.buildroot=/my/new/path \
+// RUN:   -o %t \
+// RUN:   %t.buildroot/test.cpp
+
+
+//We move the original source file to a directory that looks like a debuginfod
+//URL part.
+
+// RUN: rm -rf %t.mock
+// RUN: mkdir -p   %t.mock/buildid/aabbccdd/source/my/new/path
+// RUN: mv%t.buildroot/test.cpp %t.mock/buildid/aabbccdd/source/my/new/path
+
+
+//Adjust where debuginfod stores cache files:
+
+// RUN: rm -rf %t.debuginfod_cache_path
+// RUN: mkdir -p %t.debuginfod_cache_path
+// RUN: export DEBUGINFOD_CACHE_PATH=%t.debuginfod_cache_path
+
+
+//Start HTTP file server on port picked by OS and wait until it is ready
+//The server will be closed on exit of the test.
+
+// RUN: rm -f "%t.server.log"
+// RUN: timeout 5 python3 -u -m http.server 0 --directory %t.mock --bind "localhost" &> %t.server.log & export PID=$!
+// RUN: trap 'kill $PID;' EXIT INT
+
+
+//Extract HTTP address from the first line of the server log
+//(e.g. "Serving HTTP on 127.0.0.1 port 40587 (http://127.0.0.1:40587/) ..")
+
+// RUN: echo -n "Waiting for server to be ready"
+// RUN: SERVER_ADDRESS=""
+// RUN: while [ -z "$SERVER_ADDRESS" ]; do \
+// RUN: echo -n "."; \
+// RUN: sleep 0.01; \
+// RUN: SERVER_ADDRESS=$(head -n1 %t.server.log | grep "http://.\+/\+; -o); \
+// RUN: done
+// RUN: echo "DONE"
+
+
+//-- TEST 1 --  No debuginfod awareness 
+
+
+// RUN: DEBUGINFOD_URLS="" \
+// RUN: %lldb -f %t -o 'source list -n main' | FileCheck --dump-input=fail %s --check-prefix=TEST-1
+
+// TEST-1: (lldb) source list -n main
+// TEST-1: File: /my/new/path/test.cpp
+// TEST-1-EMPTY:
+
+
+//-- TEST 2 -- debuginfod URL pointing in wrong place 

[Lldb-commits] [lldb] 6a4905a - [lldb] Mark expressions that couldn't be parsed or executed as failed expressions

2020-03-23 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-03-23T15:28:17+01:00
New Revision: 6a4905ae2d65a2883112bf8cbf83c35c0c03f410

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

LOG: [lldb] Mark expressions that couldn't be parsed or executed as failed 
expressions

Summary:
LLDB keeps statistics of how many expression evaluations are 'successful' and 
'failed'
which are updated after each expression evaluation (assuming statistics are 
enabled).
>From what I understand the idea is that this could be used to define how well 
>LLDB's
expression evaluator is working.

Currently all expressions are considered successful unless the user passes an 
explicit
positive element counting to the expression command (with the `-Z` flag) and 
then passes
an expression that successfully evaluates to a type that doesn't support 
element counting.
Expressions that fail to parse, execute or any other outcome are considered 
successful
at the moment which means we nearly always have a 100% expression evaluation
success rate.

This patch makes that expressions that fail to parse or execute to count as 
failed
expressions.

We can't know whether the expression failed because of an user error
of because LLDB couldn't correctly parse/compile it, but I would argue that 
this is
still an improvement. Assuming that the percentage of valid user expressions 
stays
mostly constant over time (which seems like a reasonable assumption), then this
way we can still see if we are doing relatively better/worse from release to 
release.

Reviewers: davide, aprantl, JDevlieghere

Reviewed By: aprantl

Subscribers: abidh

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

Added: 


Modified: 
lldb/source/Commands/CommandObjectExpression.cpp
lldb/source/Commands/CommandObjectExpression.h
lldb/test/API/commands/statistics/basic/TestStats.py

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectExpression.cpp 
b/lldb/source/Commands/CommandObjectExpression.cpp
index 7d8de573df0e..9a314c251475 100644
--- a/lldb/source/Commands/CommandObjectExpression.cpp
+++ b/lldb/source/Commands/CommandObjectExpression.cpp
@@ -486,7 +486,8 @@ bool 
CommandObjectExpression::EvaluateExpression(llvm::StringRef expr,
 }
   }
 
-  return true;
+  return (success != eExpressionSetupError &&
+  success != eExpressionParseError);
 }
 
 void CommandObjectExpression::IOHandlerInputComplete(IOHandler _handler,

diff  --git a/lldb/source/Commands/CommandObjectExpression.h 
b/lldb/source/Commands/CommandObjectExpression.h
index ddee9c36924d..1e59cbc14528 100644
--- a/lldb/source/Commands/CommandObjectExpression.h
+++ b/lldb/source/Commands/CommandObjectExpression.h
@@ -71,6 +71,16 @@ class CommandObjectExpression : public CommandObjectRaw,
   /// expression in the given target.
   EvaluateExpressionOptions GetEvalOptions(const Target );
 
+  /// Evaluates the given expression.
+  /// \param output_stream The stream to which the evaluation result will be
+  ///  printed.
+  /// \param error_stream Contains error messages that should be displayed to
+  /// the user in case the evaluation fails.
+  /// \param result A CommandReturnObject which status will be set to the
+  ///   appropriate value depending on evaluation success and
+  ///   whether the expression produced any result.
+  /// \return Returns true iff the expression was successfully evaluated,
+  /// executed and the result could be printed to the output stream.
   bool EvaluateExpression(llvm::StringRef expr, Stream _stream,
   Stream _stream, CommandReturnObject );
 

diff  --git a/lldb/test/API/commands/statistics/basic/TestStats.py 
b/lldb/test/API/commands/statistics/basic/TestStats.py
index 76bc22433848..be028199fade 100644
--- a/lldb/test/API/commands/statistics/basic/TestStats.py
+++ b/lldb/test/API/commands/statistics/basic/TestStats.py
@@ -21,6 +21,20 @@ def test(self):
 self.expect("statistics dump", substrs=['expr evaluation successes : 
1\n',
 'expr evaluation failures : 
0\n'])
 
+self.expect("statistics enable")
+# Doesn't parse.
+self.expect("expr doesnt_exist", error=True,
+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.
+self.expect("expr -Z 3 -- 1", error=True,
+substrs=["expression cannot be used with --element-count"])
+self.expect("statistics disable")
+# We should have gotten 3 new failures and the previous success.
+

[Lldb-commits] [PATCH] D76569: Convert CommandObjectCommands functions to return StringRefs

2020-03-23 Thread Shivam Mittal via Phabricator via lldb-commits
shivammittal99 added a comment.

> run by hand ASAN-built LLDB for the code modified by this patch.

How do I do that? This is my first PR to llvm, so I am not aware of the tools. 
Please bear with me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76569



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


[Lldb-commits] [PATCH] D75488: Preserve the owning module information from DWARF in the synthesized AST

2020-03-23 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




Comment at: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h:318
+  /// Synthesize a clang::Module and return its ID or a default-constructed ID.
+  OptionalClangModuleID GetOrCreateClangModule(llvm::StringRef name, 
OptionalClangModuleID parent,
+  bool is_framework = false,

This probably deserves a hint that this can only be called on an 
TypeSystemClang that has created its own clang::ASTContext (otherwise the 
ASTSource could be anything and this asserts) as all other functions in 
TypeSystemClang otherwise work in both modes. `Should not be called when 
TypeSystemClang adopted an existing clang::ASTContext` or something like that.


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

https://reviews.llvm.org/D75488



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


[Lldb-commits] [PATCH] D76593: [lldb-vscode] Convert g_vsc.launch_info to a local variable

2020-03-23 Thread Anton Kolesov via Phabricator via lldb-commits
anton.kolesov added a comment.

In D76593#1936337 , @labath wrote:

> Sounds like a good idea. Could you do the same for `attach_info` (it looks 
> like it should be possible)? Otherwise, one is left wondering about what's 
> the difference...


I have that as my next patch - it seems like something that should be in a 
separate commit, but in the same pull request, but I don't know how to properly 
submit patch series for review at Phabricator - only through "related 
revisions", I presume?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76593



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


[Lldb-commits] [PATCH] D76569: Convert CommandObjectCommands functions to return StringRefs

2020-03-23 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

I do not have the testsuite running with ASAN (it is also failing for me) but I 
expected to at least run by hand ASAN-built LLDB for the code modified by this 
patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76569



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


[Lldb-commits] [PATCH] D76569: Convert CommandObjectCommands functions to return StringRefs

2020-03-23 Thread Shivam Mittal via Phabricator via lldb-commits
shivammittal99 added a comment.

@jankratochvil When I use `LLVM_USE_SANITIZER=Address` and then run `ninja 
check-lldb` I get other errors:

  $ ninja check-lldb -j 1
  [1/1981] Building DiagnosticDriverKinds.inc...
  FAILED: tools/clang/include/clang/Basic/DiagnosticDriverKinds.inc 
  cd /home/shivam/Desktop/projects/github/llvm-project/build && 
/home/shivam/Desktop/projects/github/llvm-project/build/bin/clang-tblgen 
-gen-clang-diags-defs -clang-component=Driver -I 
/home/shivam/Desktop/projects/github/llvm-project/clang/include -I 
/home/shivam/Desktop/projects/github/llvm-project/clang/include/clang/Basic -I 
/home/shivam/Desktop/projects/github/llvm-project/llvm/include 
/home/shivam/Desktop/projects/github/llvm-project/clang/include/clang/Basic/Diagnostic.td
 --write-if-changed -o 
tools/clang/include/clang/Basic/DiagnosticDriverKinds.inc -d 
tools/clang/include/clang/Basic/DiagnosticDriverKinds.inc.d
  
  =
  ==22777==ERROR: LeakSanitizer: detected memory leaks
  
  Direct leak of 67584 byte(s) in 1 object(s) allocated from:
  #0 0x7fdc5bc1cae8 in malloc 
(/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10dae8)
  #1 0x561564416caa in RegisterHandlers() 
(/home/shivam/Desktop/projects/github/llvm-project/build/bin/clang-tblgen+0x500caa)
  #2 0x561564419c86 in llvm::sys::AddSignalHandler(void (*)(void*), void*) 
(/home/shivam/Desktop/projects/github/llvm-project/build/bin/clang-tblgen+0x503c86)
  #3 0x561563fb1d25 in main 
(/home/shivam/Desktop/projects/github/llvm-project/build/bin/clang-tblgen+0x9bd25)
  #4 0x7fdc5b5991e2 in __libc_start_main 
(/lib/x86_64-linux-gnu/libc.so.6+0x271e2)
  
  SUMMARY: AddressSanitizer: 67584 byte(s) leaked in 1 allocation(s).
  ninja: build stopped: subcommand failed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76569



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


[Lldb-commits] [PATCH] D76471: Remap the target SDK directory to the host SDK directory

2020-03-23 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Thanks for the explanation. I have some ideas on this below, though I am not 
sure if I know enough about the problem to be able to tell which ones are 
feasible.

In D76471#1933923 , @aprantl wrote:

> Thanks, Pavel, these are all very valid concerns and in retrospect I should 
> have at least slapped an RFC label on this before dumping into phabricator 
> last night. The goal of this (and I should have mentioned that in the 
> description) is to make the Xcode SDK something that behaves more like the 
> compiler's resource directory, as in that it ships with LLDB rather than with 
> the debugged program. This important primarily for importing Swift and Clang 
> modules in the expression evaluator, and getting at the APINotes from the SDK 
> in Swift.
>
> For a cross-debugging scenario, this means you have to have an SDK for your 
> target installed alongside LLDB. In Xcode this will always be the case. As 
> you correctly identified my first patch does not work if you are cross 
> debugging, e.g., a macOS target from a Linux machine because we are querying 
> the HostPlatform for the SDK path and only PlatformDarwin implements this 
> function. I'm open to any suggestions (and will also think about this myself) 
> for how to make the layering less awkward, the only hard requirement I have 
> is that I need the SDK path remapping information inside the per-module Swift 
> typesystem, so I can't depend on a target for any of this.
>
> What do you think about the general idea of a HostPlatform having several 
> cross-SDKs installed and knowing where to find them? What would be a better 
> place for this otherwise?


I don't think putting this knowledge inside the host platform instance is a 
good idea. It already seems very odd to be enumerating all darwin platforms 
inside PlatformDarwin, when there is already PlatformXXX class for each of 
these platforms. It would be even weirder to include non-darwin platforms there.

Technically, platform objects are not tied to any particular target, and all 
you need to get one is an ArchSpec (`static 
Platform::GetPlatformForArchitecture`). Putting this knowledge into the "right" 
platform instances and then finding them based on the module's ArchSpec seems 
like it should be possible. I'm not convinced its a good idea to reach for a 
Platform object from a Module (it seems to open possibilities for 
inconsistencies between the platform chosen in this way, and the platform used 
for eventual launches), but it definitely seems better than defaulting to the 
host platform object (which also doesn't do anything to address the 
inconsistency).

Alternatively, since the list of "sdk" that the lldb happens to come with is a 
property of how it is built/deployed, it may also make sense to put this logic 
into the Host module somehow. A combination of the two approaches might be 
interesting too (the interactions between host and platform are always a bit 
weird). E.g., we could still query the Platform object for the sdk, but it 
would defer to some Host functionality to produce the right value. That way we 
could use `xcrun` (or whatever) on a mac, but theoretically other host systems 
could implement a different mechanism to locate the mac SDKs.

Finally, it may be possible to just have the list of sdks as some hardcoded 
list (populated by the build system?), in which case the code for that could 
live just about anywhere...


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

https://reviews.llvm.org/D76471



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


[Lldb-commits] [PATCH] D76593: [lldb-vscode] Convert g_vsc.launch_info to a local variable

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

Sounds like a good idea. Could you do the same for `attach_info` (it looks like 
it should be possible)? Otherwise, one is left wondering about what's the 
difference...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76593



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


[Lldb-commits] [PATCH] D76593: [lldb-vscode] Convert g_vsc.launch_info to a local variable

2020-03-23 Thread Anton Kolesov via Phabricator via lldb-commits
anton.kolesov created this revision.
anton.kolesov added reviewers: labath, clayborg.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This field inside of the global variable can be a simple local variable because
it is used in only one function: request_launch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76593

Files:
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1381,26 +1381,26 @@
   }
 
   // Instantiate a launch info instance for the target.
-  g_vsc.launch_info = g_vsc.target.GetLaunchInfo();
+  auto launch_info = g_vsc.target.GetLaunchInfo();
 
   // Grab the current working directory if there is one and set it in the
   // launch info.
   const auto cwd = GetString(arguments, "cwd");
   if (!cwd.empty())
-g_vsc.launch_info.SetWorkingDirectory(cwd.data());
+launch_info.SetWorkingDirectory(cwd.data());
 
   // Extract any extra arguments and append them to our program arguments for
   // when we launch
   auto args = GetStrings(arguments, "args");
   if (!args.empty())
-g_vsc.launch_info.SetArguments(MakeArgv(args).data(), true);
+launch_info.SetArguments(MakeArgv(args).data(), true);
 
   // Pass any environment variables along that the user specified.
   auto envs = GetStrings(arguments, "env");
   if (!envs.empty())
-g_vsc.launch_info.SetEnvironmentEntries(MakeArgv(envs).data(), true);
+launch_info.SetEnvironmentEntries(MakeArgv(envs).data(), true);
 
-  auto flags = g_vsc.launch_info.GetLaunchFlags();
+  auto flags = launch_info.GetLaunchFlags();
 
   if (GetBoolean(arguments, "disableASLR", true))
 flags |= lldb::eLaunchFlagDisableASLR;
@@ -1409,9 +1409,9 @@
   if (GetBoolean(arguments, "shellExpandArguments", false))
 flags |= lldb::eLaunchFlagShellExpandArguments;
   const bool detatchOnError = GetBoolean(arguments, "detachOnError", false);
-  g_vsc.launch_info.SetDetachOnError(detatchOnError);
-  g_vsc.launch_info.SetLaunchFlags(flags | lldb::eLaunchFlagDebug |
-   lldb::eLaunchFlagStopAtEntry);
+  launch_info.SetDetachOnError(detatchOnError);
+  launch_info.SetLaunchFlags(flags | lldb::eLaunchFlagDebug |
+ lldb::eLaunchFlagStopAtEntry);
 
   // Run any pre run LLDB commands the user specified in the launch.json
   g_vsc.RunPreRunCommands();
@@ -1419,7 +1419,7 @@
 // Disable async events so the launch will be successful when we return 
from
 // the launch call and the launch will happen synchronously
 g_vsc.debugger.SetAsync(false);
-g_vsc.target.Launch(g_vsc.launch_info, error);
+g_vsc.target.Launch(launch_info, error);
 g_vsc.debugger.SetAsync(true);
   } else {
 g_vsc.RunLLDBCommands("Running launchCommands:", launchCommands);
Index: lldb/tools/lldb-vscode/VSCode.h
===
--- lldb/tools/lldb-vscode/VSCode.h
+++ lldb/tools/lldb-vscode/VSCode.h
@@ -71,7 +71,6 @@
   lldb::SBDebugger debugger;
   lldb::SBTarget target;
   lldb::SBAttachInfo attach_info;
-  lldb::SBLaunchInfo launch_info;
   lldb::SBValueList variables;
   lldb::SBBroadcaster broadcaster;
   int64_t num_regs;
Index: lldb/tools/lldb-vscode/VSCode.cpp
===
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -28,7 +28,7 @@
 VSCode g_vsc;
 
 VSCode::VSCode()
-: launch_info(nullptr), variables(), broadcaster("lldb-vscode"),
+: variables(), broadcaster("lldb-vscode"),
   num_regs(0), num_locals(0), num_globals(0), log(),
   exception_breakpoints(
   {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1381,26 +1381,26 @@
   }
 
   // Instantiate a launch info instance for the target.
-  g_vsc.launch_info = g_vsc.target.GetLaunchInfo();
+  auto launch_info = g_vsc.target.GetLaunchInfo();
 
   // Grab the current working directory if there is one and set it in the
   // launch info.
   const auto cwd = GetString(arguments, "cwd");
   if (!cwd.empty())
-g_vsc.launch_info.SetWorkingDirectory(cwd.data());
+launch_info.SetWorkingDirectory(cwd.data());
 
   // Extract any extra arguments and append them to our program arguments for
   // when we launch
   auto args = GetStrings(arguments, "args");
   if (!args.empty())
-g_vsc.launch_info.SetArguments(MakeArgv(args).data(), true);
+launch_info.SetArguments(MakeArgv(args).data(), true);
 
   // Pass any environment variables along that the user specified.
   auto 

[Lldb-commits] [PATCH] D74636: [lldb-vscode] Add inheritEnvironment option

2020-03-23 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D74636#1934466 , @wallace wrote:

> I added some tests cases to show why I used "settings set target.inherit-env".
>
> There are currently two ways to launch a process. Either with the plain 
> "program" argument,
>  or with the "launchCommands" argument. The latter is assumed to create a 
> target by executing
>  arbitrary commands, which may go through CommandObjectProcess.
>
> As by default target.inherit-env is true, if we first set its value to what 
> we got from the 
>  inheritEnvironment argument, then both kinds of launchers would behave the 
> same way.


Thanks for the explanation. That makes sort of sense, but it does raise the 
question of the handling of other launch command arguments. What happens if the 
user specifies the environment (`env`) in the launch command, but uses the 
`launchCommands` method of launching? Will that environment still be applied? 
And what about the rest of the launch arguments (disable-aslr, stop-on-entry, 
disable-stdio)? It seems odd to have this special treatment for only a single 
property.

> I haven't found an API for changing this setting, so I ended up invoking the 
> command.

Yeah, I'm afraid we don't have an API for getting/setting settings right now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74636



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


[Lldb-commits] [PATCH] D76470: [lldb/Target] Rework the way the inferior environment is created

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

looks good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76470



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


[Lldb-commits] [PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-03-23 Thread Manoj Gupta via Phabricator via lldb-commits
manojgupta added a comment.

Thanks for the quick fix, verified that the crash is fixed on trunk.


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

https://reviews.llvm.org/D73534



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