Re: [Lldb-commits] [lldb] a06c28d - Temporarily revert "[test] Exit with an error if no tests are run."

2020-08-04 Thread Raphael “Teemperor” Isemann via lldb-commits
If it helps, all the failing tests are pexpect tests which are always disabled 
on Windows (like, they don't even exist from the test runners POV I believe). 
So I guess that's accidentially triggering that error.

- Raphael

> On 4 Aug 2020, at 03:39, Jordan Rupprecht via lldb-commits 
>  wrote:
> 
> 
> Author: Jordan Rupprecht
> Date: 2020-08-03T18:37:50-07:00
> New Revision: a06c28df3e8c85ceb665d3d9a1ebc2853dfd87a9
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/a06c28df3e8c85ceb665d3d9a1ebc2853dfd87a9
> DIFF: 
> https://github.com/llvm/llvm-project/commit/a06c28df3e8c85ceb665d3d9a1ebc2853dfd87a9.diff
> 
> LOG: Temporarily revert "[test] Exit with an error if no tests are run."
> 
> This reverts commit adb5c23f8c0d60eeec41dcbe21d1b26184e1c97d. It surprisingly 
> fails on a windows build bot: 
> http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/18009
> 
> Will reland after some investigation and/or after adding some extra logging 
> to help debug the issue.
> 
> Added: 
> 
> 
> Modified: 
>lldb/packages/Python/lldbsuite/test/dotest.py
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
> b/lldb/packages/Python/lldbsuite/test/dotest.py
> index 6607f52c49db..3fb802f1c1aa 100644
> --- a/lldb/packages/Python/lldbsuite/test/dotest.py
> +++ b/lldb/packages/Python/lldbsuite/test/dotest.py
> @@ -1039,10 +1039,6 @@ def run_suite():
> (configuration.suite.countTestCases(),
>  configuration.suite.countTestCases() != 1 and "s" or ""))
> 
> -if configuration.suite.countTestCases() == 0:
> -logging.error("did not discover any matching tests")
> -exitTestSuite(1)
> -
> # Invoke the test runner.
> if configuration.count == 1:
> result = unittest2.TextTestRunner(
> 
> 
> 
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

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


[Lldb-commits] [lldb] daa1c6d - [lldb] fix typo

2020-08-04 Thread Luboš Luňák via lldb-commits

Author: Luboš Luňák
Date: 2020-08-04T12:05:57+02:00
New Revision: daa1c6d9d126ea1666463c44930f00df83f3acd6

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

LOG: [lldb] fix typo

Added: 


Modified: 
lldb/source/Core/IOHandlerCursesGUI.cpp

Removed: 




diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp 
b/lldb/source/Core/IOHandlerCursesGUI.cpp
index 262a19dc04b4..144b2112183c 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -916,9 +916,9 @@ void Menu::DrawMenuTitle(Window , bool highlight) {
   } else {
 const int shortcut_key = m_key_value;
 bool underlined_shortcut = false;
-const attr_t hilgight_attr = A_REVERSE;
+const attr_t highlight_attr = A_REVERSE;
 if (highlight)
-  window.AttributeOn(hilgight_attr);
+  window.AttributeOn(highlight_attr);
 if (llvm::isPrint(shortcut_key)) {
   size_t lower_pos = m_name.find(tolower(shortcut_key));
   size_t upper_pos = m_name.find(toupper(shortcut_key));
@@ -945,7 +945,7 @@ void Menu::DrawMenuTitle(Window , bool highlight) {
 }
 
 if (highlight)
-  window.AttributeOff(hilgight_attr);
+  window.AttributeOff(highlight_attr);
 
 if (m_key_name.empty()) {
   if (!underlined_shortcut && llvm::isPrint(m_key_value)) {



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


[Lldb-commits] [PATCH] D85145: Use syntax highlighting also in gui mode

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

In D85145#2192716 , @teemperor wrote:

> I wonder if there is a reasonable way to test this. From what I understand 
> these attributes aren't in any output buffer that we could expect (e.g., with 
> a pexpect test).

I'm not sure. There's TERM hardcoded to vt100 in lldbpexpect, and vt100 is not 
color-capable. Grepping shows other references to vt100. TestGuiBasic.py 
matches "return 1", which should be different with syntax highlight, and it 
still works even with forcing that TERM to e.g. ansi or xterm-color. So at 
least not easily.




Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:461
+  // convert color escape sequences to curses color attributes.
+  void OutputColoredStringTruncated(int right_pad, const StringRef ,
+bool blue) {

teemperor wrote:
> StringRef is usually passed by-value. Also I think the `Truncated` suffix is 
> what was used in other methods to indicate that it doesn't output a full 
> CString, but here we anyway don't use C-Strings (yay).
To my understanding that `Truncated` refers to making sure the text fits the 
curses window, including the padding.





Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:471
+  ::wattron(m_window, COLOR_PAIR(16));
+for (size_t i = 0; i < string.size(); ++i) {
+  if (string[i] != '\x1b') { // esc

teemperor wrote:
> StringRef has a bunch of parsing utilities (consume_front, etc.) that could 
> help here (not tested if that code actually works, so maybe needs some fixes):
> 
> ```
> lang=c++
> llvm::StringRef left_to_parse = string;
> while (!left_to_parse.empty()) {
>   if (!left_to_parse.consume_front("\x1b")) {
> ++text_length;
> continue;
>   }
>   [...]
>   if (!left_to_parse.consume_front("["))
>return llvm::createStringError(llvm::inconvertibleErrorCode(),
>"Missing '[' in color escape sequence");
>   unsigned value;
>   if (left_to_parse.consumeInteger(10, value))
>return llvm::createStringError(llvm::inconvertibleErrorCode(),
>   "No valid color code in color escape 
> sequence");
>   if (!left_to_parse.consume_front("m"))
>return llvm::createStringError(llvm::inconvertibleErrorCode(),
>   "No 'm' in color escape sequence");
>   [...]
> }
> ```
> 
> I just returned an llvm::Error here as it seems more appropriate for parsing 
> errors. You can handle it in the caller with something like that:
> ```
> lang=c++
> handleAllErrors(
> std::move(result_from_call)
> [&](StringError ) { llvm::errs() << "Error while highlighting 
> source: " << e.getMessage() << "\n"; },
> ```
> I just returned an llvm::Error here as it seems more appropriate for parsing 
> errors.

Why? I went simply with assert() because it's meant to parse output from 
another part of LLDB, so it made sense to just make the code fall flat on its 
face in case of a problem. Guessing from your comments the output from the 
highlighter is not as hardcoded as I assumed, so it makes sense to handle it 
gracefully, but still that's a problem of the function and the caller neither 
cares nor can do much about it.



Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D85145

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


[Lldb-commits] [PATCH] D85145: Use syntax highlighting also in gui mode

2020-08-04 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor requested changes to this revision.
teemperor added a comment.
This revision now requires changes to proceed.

In D85145#2191658 , @llunak wrote:

> In D85145#2191421 , @teemperor wrote:
>
>> Btw, the highlighter supports any kind of delimiter string when 
>> 'highlighting' source. So you could add a parameter for a custom highlighter 
>> too and then pass a more convenient highlighter 'style' in to make the 
>> parsing simpler. See the only call MakeVimStyle (which generates the style 
>> that adds the color escapes) and the HighlighterStyle where you can set any 
>> kind of delimiter.
>
> I think I don't want to do that. The gui mode should preferably use the same 
> highlighting as the non-gui one, so if I added a new style, the colors would 
> still need to be mapped somewhen. Moreover the ^[m style parser is 
> actually pretty simple, much simpler than I was originally afraid it'd be, 
> and possibly it could be later needed for something else too.

Yeah I just scrolled over the code and thought that could be simplified with 
dedicated format, but it seems the parsing logic is quite simple. The color 
parser could indeed be useful for getting colors to work on legacy Windows 
terminals, so that seems useful. I only have some small requests to the parsing 
implementation but otherwise this looks good to me. Thanks for working on this!

I wonder if there is a reasonable way to test this. From what I understand 
these attributes aren't in any output buffer that we could expect (e.g., with a 
pexpect test).




Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:461
+  // convert color escape sequences to curses color attributes.
+  void OutputColoredStringTruncated(int right_pad, const StringRef ,
+bool blue) {

StringRef is usually passed by-value. Also I think the `Truncated` suffix is 
what was used in other methods to indicate that it doesn't output a full 
CString, but here we anyway don't use C-Strings (yay).



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:462
+  void OutputColoredStringTruncated(int right_pad, const StringRef ,
+bool blue) {
+int last_text = -1;  // Last position in string that's been written.

`blue` -> `use_blue_background` ?



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:471
+  ::wattron(m_window, COLOR_PAIR(16));
+for (size_t i = 0; i < string.size(); ++i) {
+  if (string[i] != '\x1b') { // esc

StringRef has a bunch of parsing utilities (consume_front, etc.) that could 
help here (not tested if that code actually works, so maybe needs some fixes):

```
lang=c++
llvm::StringRef left_to_parse = string;
while (!left_to_parse.empty()) {
  if (!left_to_parse.consume_front("\x1b")) {
++text_length;
continue;
  }
  [...]
  if (!left_to_parse.consume_front("["))
   return llvm::createStringError(llvm::inconvertibleErrorCode(),
   "Missing '[' in color escape sequence");
  unsigned value;
  if (left_to_parse.consumeInteger(10, value))
   return llvm::createStringError(llvm::inconvertibleErrorCode(),
  "No valid color code in color escape 
sequence");
  if (!left_to_parse.consume_front("m"))
   return llvm::createStringError(llvm::inconvertibleErrorCode(),
  "No 'm' in color escape sequence");
  [...]
}
```

I just returned an llvm::Error here as it seems more appropriate for parsing 
errors. You can handle it in the caller with something like that:
```
lang=c++
handleAllErrors(
std::move(result_from_call)
[&](StringError ) { llvm::errs() << "Error while highlighting 
source: " << e.getMessage() << "\n"; },
```



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:475
+continue;
+  } else {
+if (text_length > 0) {

else after continue



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:492
+}
+const int value = atoi(string.data() + esc_start);
+if (value == 0) { // Reset.

There is also `llvm::to_integer` (and then you could also assert on an 
successful parse as it doesn't use magic return values for errors).



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:1002
 bool underlined_shortcut = false;
-const attr_t hilgight_attr = A_REVERSE;
+const attr_t highlight_attr = A_REVERSE;
 if (highlight)

You can just land typo fixes like this without review.



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:3632
+  StringRef line = lineStream.GetString();
+  if (!line.empty() && line.back() == '\n') // remove trailing \n
+line = StringRef(line.data(), line.size() 

[Lldb-commits] [PATCH] D85237: [lldb] Add an option to inherit TCC permissions from parent.

2020-08-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 283057.

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

https://reviews.llvm.org/D85237

Files:
  lldb/include/lldb/Target/Target.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetProperties.td
  lldb/test/Shell/lit-lldb-init.in

Index: lldb/test/Shell/lit-lldb-init.in
===
--- lldb/test/Shell/lit-lldb-init.in
+++ lldb/test/Shell/lit-lldb-init.in
@@ -4,3 +4,4 @@
 settings set interpreter.echo-comment-commands false
 settings set symbols.clang-modules-cache-path "@LLDB_TEST_MODULE_CACHE_LLDB@"
 settings set target.auto-apply-fixits false
+settings set target.inherit-tcc true
Index: lldb/source/Target/TargetProperties.td
===
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -111,6 +111,9 @@
   def DisableSTDIO: Property<"disable-stdio", "Boolean">,
 DefaultFalse,
 Desc<"Disable stdin/stdout for process (e.g. for a GUI application)">;
+  def InheritTCC: Property<"inherit-tcc", "Boolean">,
+DefaultFalse,
+Desc<"Inherit the TCC permissions from the inferior's parent instead of making the process itself responsible.">;
   def InlineStrategy: Property<"inline-breakpoint-strategy", "Enum">,
 DefaultEnumValue<"eInlineBreakpointsAlways">,
 EnumValues<"OptionEnumValues(g_inline_breakpoint_enums)">,
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3430,6 +3430,8 @@
 });
 m_collection_sp->SetValueChangedCallback(
 ePropertyDisableASLR, [this] { DisableASLRValueChangedCallback(); });
+m_collection_sp->SetValueChangedCallback(
+ePropertyInheritTCC, [this] { InheritTCCValueChangedCallback(); });
 m_collection_sp->SetValueChangedCallback(
 ePropertyDisableSTDIO, [this] { DisableSTDIOValueChangedCallback(); });
 
@@ -3468,6 +3470,7 @@
   ErrorPathValueChangedCallback();
   DetachOnErrorValueChangedCallback();
   DisableASLRValueChangedCallback();
+  InheritTCCValueChangedCallback();
   DisableSTDIOValueChangedCallback();
 }
 
@@ -3550,6 +3553,17 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
 }
 
+bool TargetProperties::GetInheritTCC() const {
+  const uint32_t idx = ePropertyInheritTCC;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_target_properties[idx].default_uint_value != 0);
+}
+
+void TargetProperties::SetInheritTCC(bool b) {
+  const uint32_t idx = ePropertyInheritTCC;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+}
+
 bool TargetProperties::GetDetachOnError() const {
   const uint32_t idx = ePropertyDetachOnError;
   return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -3941,6 +3955,8 @@
   }
   SetDetachOnError(launch_info.GetFlags().Test(lldb::eLaunchFlagDetachOnError));
   SetDisableASLR(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableASLR));
+  SetInheritTCC(
+  launch_info.GetFlags().Test(lldb::eLaunchFlagInheritTCCFromParent));
   SetDisableSTDIO(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableSTDIO));
 }
 
@@ -4004,6 +4020,13 @@
 m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDisableASLR);
 }
 
+void TargetProperties::InheritTCCValueChangedCallback() {
+  if (GetInheritTCC())
+m_launch_info.GetFlags().Set(lldb::eLaunchFlagInheritTCCFromParent);
+  else
+m_launch_info.GetFlags().Clear(lldb::eLaunchFlagInheritTCCFromParent);
+}
+
 void TargetProperties::DisableSTDIOValueChangedCallback() {
   if (GetDisableSTDIO())
 m_launch_info.GetFlags().Set(lldb::eLaunchFlagDisableSTDIO);
Index: lldb/source/Host/macosx/objcxx/Host.mm
===
--- lldb/source/Host/macosx/objcxx/Host.mm
+++ lldb/source/Host/macosx/objcxx/Host.mm
@@ -1095,10 +1095,11 @@
 is_graphical = session_attributes & sessionHasGraphicAccess;
 #endif
 
-  //  When lldb is ran through a graphical session, this makes the debuggee
-  //  process responsible for the TCC prompts. Otherwise, lldb will use the
-  //  launching process privileges.
-  if (is_graphical && launch_info.GetFlags().Test(eLaunchFlagDebug)) {
+  //  When lldb is ran through a graphical session, make the debuggee process
+  //  responsible for its own TCC permissions instead of inheriting them from
+  //  its parent.
+  if (is_graphical && launch_info.GetFlags().Test(eLaunchFlagDebug) &&
+  !launch_info.GetFlags().Test(eLaunchFlagInheritTCCFromParent)) {
 error.SetError(setup_posix_spawn_responsible_flag(), eErrorTypePOSIX);
 if (error.Fail()) {
   LLDB_LOG(log, "error: {0}, 

[Lldb-commits] [PATCH] D85237: [lldb] Add an option to disable TCC

2020-08-04 Thread Frederic Riss via Phabricator via lldb-commits
friss added a comment.

The logic of the patch itself looks fine, but the names, description and commit 
message are off. A process cannot disable TCC, it's always active. What your 
patch decides is whether the inferior is responsible for its own TCC 
permissions. If you don't make the inferior responsible, it inherits the 
permissions of its parent (which might have inherited them from its own 
parent). On the command line, you'll most likely get the Terminal.app 
permissions if nothing in the middle resets the responsible process.


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

https://reviews.llvm.org/D85237

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


[Lldb-commits] [PATCH] D85107: Add a test for 'b' (toggle breakpoint)

2020-08-04 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

lldb/test/API is for testing the public LLDB API functions that are exported as 
lldb::SB*. Not sure this belongs here. There was another patch that was moving 
things around as well where I commented with the same issue.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D85107

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


[Lldb-commits] [PATCH] D85106: Move TestGuiBasicDebug.py to lldb/test and update it

2020-08-04 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

lldb/test/API is usually for testing the lldb::SB* interfaces IIRC. So not sure 
this move makes sense?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D85106

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


[Lldb-commits] [lldb] ba3d84d - [lldb/Test] Skip tests that try to get the remote environment

2020-08-04 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-08-04T14:01:57-07:00
New Revision: ba3d84d82b750296c11e843365aa85962a561ad4

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

LOG: [lldb/Test] Skip tests that try to get the remote environment

We don't support getting the remote environment. The gdb remote protocol
has no packet for that.

Added: 


Modified: 
lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
lldb/test/API/python_api/sbplatform/TestSBPlatform.py

Removed: 




diff  --git a/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py 
b/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
index 6389854ce58f..62c3ac2e5022 100644
--- a/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
+++ b/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
@@ -31,6 +31,7 @@ def assertEqualEntries(self, env, entries):
 
 
 @add_test_categories(['pyapi'])
+@skipIfRemote # Remote environment not supported.
 def test_platform_environment(self):
 env = self.dbg.GetSelectedPlatform().GetEnvironment()
 # We assume at least PATH is set
@@ -67,6 +68,7 @@ def test_launch_info(self):
 
 
 @add_test_categories(['pyapi'])
+@skipIfRemote # Remote environment not supported.
 def test_target_environment(self):
 env = self.dbg.GetSelectedTarget().GetEnvironment()
 # There is no target, so env should be empty

diff  --git a/lldb/test/API/python_api/sbplatform/TestSBPlatform.py 
b/lldb/test/API/python_api/sbplatform/TestSBPlatform.py
index 4735f6ea3b49..3fa4c10b401e 100644
--- a/lldb/test/API/python_api/sbplatform/TestSBPlatform.py
+++ b/lldb/test/API/python_api/sbplatform/TestSBPlatform.py
@@ -9,6 +9,7 @@ class SBPlatformAPICase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
 @add_test_categories(['pyapi'])
+@skipIfRemote # Remote environment not supported.
 def test_run(self):
 self.build()
 plat = lldb.SBPlatform.GetHostPlatform()



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


[Lldb-commits] [PATCH] D85145: Use syntax highlighting also in gui mode

2020-08-04 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:486
+  if (!string.consume_front("[")) {
+llvm::errs() << "Missing '[' in color escape sequence.\n";
+continue;

So what will happen if we actually get these errors? Will it just print right 
in the curses view? If so, that doesn't seem optimal.



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:4255-4275
+init_pair(1, COLOR_BLACK, COLOR_BLACK);
+init_pair(2, COLOR_RED, COLOR_BLACK);
+init_pair(3, COLOR_GREEN, COLOR_BLACK);
+init_pair(4, COLOR_YELLOW, COLOR_BLACK);
+init_pair(5, COLOR_BLUE, COLOR_BLACK);
+init_pair(6, COLOR_MAGENTA, COLOR_BLACK);
+init_pair(7, COLOR_CYAN, COLOR_BLACK);

Maybe we should make #define for each init_pair to make our code more readable?
```
#define GUI_BLACK_BLACK 1
#define GUI_RED_BLACK 2
...
init_pair(GUI_BLACK_BLACK, COLOR_BLACK, COLOR_BLACK);
init_pair(GUI_RED_BLACK, COLOR_BLACK, COLOR_BLACK);
...
```

I know it was using magic numbers before.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D85145

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


[Lldb-commits] [PATCH] D85243: [WIP] Factor out common code from the iPhone/AppleTV/WatchOS simulator platform plugins. (NFC)

2020-08-04 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: friss, jasonmolenda, teemperor, vsk.
Herald added a subscriber: mgorny.
aprantl requested review of this revision.

The implementation of these classes was copied & pasted from the iPhone 
simulator plugin with only a handful of configuration parameters substituted. 
This patch moves the redundant implementations into the base class 
PlatformAppleSimulator.


https://reviews.llvm.org/D85243

Files:
  lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h
  lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
  lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
  lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp

Index: lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp
===
--- lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp
+++ lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp
@@ -8,9 +8,7 @@
 
 #include "gtest/gtest.h"
 
-#include "Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h"
-#include "Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h"
-#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
+#include "Plugins/Platform/MacOSX/PlatformAppleSimulator.h"
 #include "TestingSupport/SubsystemRAII.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostInfo.h"
@@ -20,8 +18,7 @@
 using namespace lldb_private;
 
 class PlatformAppleSimulatorTest : public ::testing::Test {
-  SubsystemRAII
+  SubsystemRAII
   subsystems;
 };
 
Index: lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
===
--- lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -6,7 +6,7 @@
 import unittest2
 
 
-@skipIfDarwin # rdar://problem/64552748
+#@skipIfDarwin # rdar://problem/64552748
 class TestSimulatorPlatformLaunching(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
Index: lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
+++ /dev/null
@@ -1,86 +0,0 @@
-//===-- PlatformiOSSimulator.h --*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#ifndef LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMIOSSIMULATOR_H
-#define LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMIOSSIMULATOR_H
-
-#include 
-#include 
-
-#include "PlatformAppleSimulator.h"
-
-class PlatformiOSSimulator : public PlatformAppleSimulator {
-public:
-  PlatformiOSSimulator();
-
-  ~PlatformiOSSimulator() override;
-
-  // Class Functions
-  static lldb::PlatformSP CreateInstance(bool force,
- const lldb_private::ArchSpec *arch);
-
-  static void Initialize();
-
-  static void Terminate();
-
-  static lldb_private::ConstString GetPluginNameStatic();
-
-  static const char *GetDescriptionStatic();
-
-  // lldb_private::PluginInterface functions
-  lldb_private::ConstString GetPluginName() override {
-return GetPluginNameStatic();
-  }
-
-  uint32_t GetPluginVersion() override { return 1; }
-
-  // lldb_private::Platform functions
-  lldb_private::Status ResolveExecutable(
-  const lldb_private::ModuleSpec _spec, lldb::ModuleSP _sp,
-  const lldb_private::FileSpecList *module_search_paths_ptr) override;
-
-  const char *GetDescription() override { return GetDescriptionStatic(); }
-
-  void GetStatus(lldb_private::Stream ) override;
-
-  virtual lldb_private::Status
-  GetSymbolFile(const lldb_private::FileSpec _file,
-const lldb_private::UUID *uuid_ptr,
-lldb_private::FileSpec _file);
-
-  lldb_private::Status
-  GetSharedModule(const lldb_private::ModuleSpec _spec,
-  lldb_private::Process *process, lldb::ModuleSP _sp,
-  const lldb_private::FileSpecList *module_search_paths_ptr,
-  lldb::ModuleSP *old_module_sp_ptr,
-  bool *did_create_ptr) override;
-
-  uint32_t
-  FindProcesses(const lldb_private::ProcessInstanceInfoMatch _info,
-lldb_private::ProcessInstanceInfoList _infos) 

[Lldb-commits] [lldb] e8b7eda - [lldb/Test] Add @skipIfRemote decorator to TestProcessList.py

2020-08-04 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-08-04T14:40:07-07:00
New Revision: e8b7edafc3dd0ab85903eebdfdb3bb7cc2d66743

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

LOG: [lldb/Test] Add @skipIfRemote decorator to TestProcessList.py

lldb-platform contains a very minimal support for the qfProcessInfo
packet, only allowing the simplest query to get most of the testsuite
running, and returning very little information about the matched
processes.

Added: 


Modified: 
lldb/test/API/commands/platform/process/list/TestProcessList.py

Removed: 




diff  --git a/lldb/test/API/commands/platform/process/list/TestProcessList.py 
b/lldb/test/API/commands/platform/process/list/TestProcessList.py
index 9fc84d4f26e0..fe2ed74916eb 100644
--- a/lldb/test/API/commands/platform/process/list/TestProcessList.py
+++ b/lldb/test/API/commands/platform/process/list/TestProcessList.py
@@ -18,6 +18,7 @@ class ProcessListTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
 @skipIfWindows  # https://bugs.llvm.org/show_bug.cgi?id=43702
+@skipIfRemote   # rdar://problem/66542336
 def test_process_list_with_args(self):
 """Test process list show process args"""
 self.build()



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


[Lldb-commits] [PATCH] D85219: [lldb] fix building with panel.h being in /usr/include/ncurses/

2020-08-04 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

I am not a cmake expert. Might be a good idea to check the git log for people 
with more cmake expertise?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D85219

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


[Lldb-commits] [PATCH] D85237: [lldb] Add an option to inherit TCC permissions from parent.

2020-08-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 283054.
JDevlieghere retitled this revision from "[lldb] Add an option to disable TCC" 
to "[lldb] Add an option to inherit TCC permissions from parent.".
JDevlieghere edited the summary of this revision.
JDevlieghere added a comment.

Make it clear that TCC cannot be disabled but instead we're inheriting the 
permissions.


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

https://reviews.llvm.org/D85237

Files:
  lldb/include/lldb/Target/Target.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetProperties.td
  lldb/test/Shell/lit-lldb-init.in

Index: lldb/test/Shell/lit-lldb-init.in
===
--- lldb/test/Shell/lit-lldb-init.in
+++ lldb/test/Shell/lit-lldb-init.in
@@ -4,3 +4,4 @@
 settings set interpreter.echo-comment-commands false
 settings set symbols.clang-modules-cache-path "@LLDB_TEST_MODULE_CACHE_LLDB@"
 settings set target.auto-apply-fixits false
+settings set target.inherit-tcc true
Index: lldb/source/Target/TargetProperties.td
===
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -111,6 +111,9 @@
   def DisableSTDIO: Property<"disable-stdio", "Boolean">,
 DefaultFalse,
 Desc<"Disable stdin/stdout for process (e.g. for a GUI application)">;
+  def DisableTCC: Property<"inherit-tcc", "Boolean">,
+DefaultFalse,
+Desc<"Inherit the TCC permissions from the inferior's parent instead of making the process itself responsible.">;
   def InlineStrategy: Property<"inline-breakpoint-strategy", "Enum">,
 DefaultEnumValue<"eInlineBreakpointsAlways">,
 EnumValues<"OptionEnumValues(g_inline_breakpoint_enums)">,
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3430,6 +3430,8 @@
 });
 m_collection_sp->SetValueChangedCallback(
 ePropertyDisableASLR, [this] { DisableASLRValueChangedCallback(); });
+m_collection_sp->SetValueChangedCallback(
+ePropertyInheritTCC, [this] { InheritTCCValueChangedCallback(); });
 m_collection_sp->SetValueChangedCallback(
 ePropertyDisableSTDIO, [this] { DisableSTDIOValueChangedCallback(); });
 
@@ -3468,6 +3470,7 @@
   ErrorPathValueChangedCallback();
   DetachOnErrorValueChangedCallback();
   DisableASLRValueChangedCallback();
+  InheritTCCValueChangedCallback();
   DisableSTDIOValueChangedCallback();
 }
 
@@ -3550,6 +3553,17 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
 }
 
+bool TargetProperties::GetInheritTCC() const {
+  const uint32_t idx = ePropertyInheritTCC;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_target_properties[idx].default_uint_value != 0);
+}
+
+void TargetProperties::SetInheritTCC(bool b) {
+  const uint32_t idx = ePropertyInheritTCC;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+}
+
 bool TargetProperties::GetDetachOnError() const {
   const uint32_t idx = ePropertyDetachOnError;
   return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -3941,6 +3955,8 @@
   }
   SetDetachOnError(launch_info.GetFlags().Test(lldb::eLaunchFlagDetachOnError));
   SetDisableASLR(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableASLR));
+  SetInheritTCC(
+  launch_info.GetFlags().Test(lldb::eLaunchFlagDisableInferiorTCC));
   SetDisableSTDIO(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableSTDIO));
 }
 
@@ -4004,6 +4020,13 @@
 m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDisableASLR);
 }
 
+void TargetProperties::InheritTCCValueChangedCallback() {
+  if (GetInheritTCC())
+m_launch_info.GetFlags().Set(lldb::eLaunchFlagInheritTCCFromParent);
+  else
+m_launch_info.GetFlags().Clear(lldb::eLaunchFlagInheritTCCFromParent);
+}
+
 void TargetProperties::DisableSTDIOValueChangedCallback() {
   if (GetDisableSTDIO())
 m_launch_info.GetFlags().Set(lldb::eLaunchFlagDisableSTDIO);
Index: lldb/source/Host/macosx/objcxx/Host.mm
===
--- lldb/source/Host/macosx/objcxx/Host.mm
+++ lldb/source/Host/macosx/objcxx/Host.mm
@@ -1095,10 +1095,11 @@
 is_graphical = session_attributes & sessionHasGraphicAccess;
 #endif
 
-  //  When lldb is ran through a graphical session, this makes the debuggee
-  //  process responsible for the TCC prompts. Otherwise, lldb will use the
-  //  launching process privileges.
-  if (is_graphical && launch_info.GetFlags().Test(eLaunchFlagDebug)) {
+  //  When lldb is ran through a graphical session, make the debuggee process
+  //  responsible for its own TCC permissions instead of inheriting them from
+  //  its 

[Lldb-commits] [lldb] 7e9bab6 - Fix debugserver's qProcessInfo reporting of maccatalyst binaries

2020-08-04 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2020-08-04T16:42:14-07:00
New Revision: 7e9bab6ad51af1cab0c7457e4323166af3ac797c

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

LOG: Fix debugserver's qProcessInfo reporting of maccatalyst binaries

This patch is similar in spirit to https://reviews.llvm.org/D84480,
but does the maccatalyst/macosx disambiguation. I also took the
opportunity to factor out the gdb-remote packet log scanning used by
several testcases into lldbutil functions.

rdar://problem/66059257

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

Added: 
lldb/test/API/macosx/macCatalyst/Makefile
lldb/test/API/macosx/macCatalyst/TestMacCatalyst.py
lldb/test/API/macosx/macCatalyst/main.c
lldb/test/API/macosx/macCatalystAppMacOSFramework/Makefile

lldb/test/API/macosx/macCatalystAppMacOSFramework/TestMacCatalystAppWithMacOSFramework.py
lldb/test/API/macosx/macCatalystAppMacOSFramework/foo.c
lldb/test/API/macosx/macCatalystAppMacOSFramework/foo.h
lldb/test/API/macosx/macCatalystAppMacOSFramework/main.c

Modified: 
lldb/packages/Python/lldbsuite/test/lldbutil.py
lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
lldb/tools/debugserver/source/DNB.cpp
lldb/tools/debugserver/source/DNB.h
lldb/tools/debugserver/source/MacOSX/MachProcess.h
lldb/tools/debugserver/source/MacOSX/MachProcess.mm
lldb/tools/debugserver/source/RNBRemote.cpp

Removed: 
lldb/test/API/macosx/macabi/Makefile
lldb/test/API/macosx/macabi/TestMacABImacOSFramework.py
lldb/test/API/macosx/macabi/foo.c
lldb/test/API/macosx/macabi/foo.h
lldb/test/API/macosx/macabi/main.c



diff  --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 1ce6844d973c..1b366f295540 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -1458,3 +1458,40 @@ def wait_for_file_on_target(testcase, file_path, 
max_attempts=6):
 (file_path, max_attempts))
 
 return read_file_on_target(testcase, file_path)
+
+def packetlog_get_process_info(log):
+"""parse a gdb-remote packet log file and extract the response to 
qProcessInfo"""
+process_info = dict()
+with open(log, "r") as logfile:
+process_info_ostype = None
+expect_process_info_response = False
+for line in logfile:
+if expect_process_info_response:
+for pair in line.split(';'):
+keyval = pair.split(':')
+if len(keyval) == 2:
+process_info[keyval[0]] = keyval[1]
+break
+if 'send packet: $qProcessInfo#' in line:
+expect_process_info_response = True
+return process_info
+
+def packetlog_get_dylib_info(log):
+"""parse a gdb-remote packet log file and extract the *last* response to 
jGetLoadedDynamicLibrariesInfos"""
+import json
+dylib_info = None
+with open(log, "r") as logfile:
+dylib_info = None
+expect_dylib_info_response = False
+for line in logfile:
+if expect_dylib_info_response:
+while line[0] != '$':
+line = line[1:]
+line = line[1:]
+# Unescape '}'.
+dylib_info = json.loads(line.replace('}]','}')[:-4])
+expect_dylib_info_response = False
+if 'send packet: $jGetLoadedDynamicLibrariesInfos:{' in line:
+expect_dylib_info_response = True
+
+return dylib_info

diff  --git a/lldb/test/API/macosx/macCatalyst/Makefile 
b/lldb/test/API/macosx/macCatalyst/Makefile
new file mode 100644
index ..9b9224571fdd
--- /dev/null
+++ b/lldb/test/API/macosx/macCatalyst/Makefile
@@ -0,0 +1,10 @@
+C_SOURCES := main.c
+
+TRIPLE := $(ARCH)-apple-ios13.0-macabi
+CFLAGS_EXTRAS := -target $(TRIPLE)
+
+# FIXME: rdar://problem/54986190
+# There is a Clang driver change missing on llvm.org.
+override CC=xcrun clang
+
+include Makefile.rules

diff  --git a/lldb/test/API/macosx/macCatalyst/TestMacCatalyst.py 
b/lldb/test/API/macosx/macCatalyst/TestMacCatalyst.py
new file mode 100644
index ..555d5a13b555
--- /dev/null
+++ b/lldb/test/API/macosx/macCatalyst/TestMacCatalyst.py
@@ -0,0 +1,43 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbutil as lldbutil
+import os
+import unittest2
+
+
+class TestMacCatalyst(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIf(macos_version=["<", "10.15"])
+@skipUnlessDarwin
+@skipIfDarwinEmbedded
+@skipIfReproducer # This is hitting https://bugs.python.org/issue22393
+def test_macabi(self):
+ 

[Lldb-commits] [PATCH] D84576: Fix debugserver's qProcessInfo reporting of maccatalyst binaries

2020-08-04 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7e9bab6ad51a: Fix debugservers qProcessInfo reporting 
of maccatalyst binaries (authored by aprantl).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D84576?vs=280649=283059#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84576

Files:
  lldb/packages/Python/lldbsuite/test/lldbutil.py
  lldb/test/API/macosx/macCatalyst/Makefile
  lldb/test/API/macosx/macCatalyst/TestMacCatalyst.py
  lldb/test/API/macosx/macCatalyst/main.c
  lldb/test/API/macosx/macCatalystAppMacOSFramework/Makefile
  
lldb/test/API/macosx/macCatalystAppMacOSFramework/TestMacCatalystAppWithMacOSFramework.py
  lldb/test/API/macosx/macCatalystAppMacOSFramework/foo.c
  lldb/test/API/macosx/macCatalystAppMacOSFramework/foo.h
  lldb/test/API/macosx/macCatalystAppMacOSFramework/main.c
  lldb/test/API/macosx/macabi/Makefile
  lldb/test/API/macosx/macabi/TestMacABImacOSFramework.py
  lldb/test/API/macosx/macabi/foo.c
  lldb/test/API/macosx/macabi/foo.h
  lldb/test/API/macosx/macabi/main.c
  lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
  lldb/tools/debugserver/source/DNB.cpp
  lldb/tools/debugserver/source/DNB.h
  lldb/tools/debugserver/source/MacOSX/MachProcess.h
  lldb/tools/debugserver/source/MacOSX/MachProcess.mm
  lldb/tools/debugserver/source/RNBRemote.cpp

Index: lldb/tools/debugserver/source/RNBRemote.cpp
===
--- lldb/tools/debugserver/source/RNBRemote.cpp
+++ lldb/tools/debugserver/source/RNBRemote.cpp
@@ -6356,10 +6356,11 @@
 DNBProcessMemoryRead(pid, load_command_addr, sizeof(lc), );
 (void)bytes_read;
 
+bool is_executable = true;
 uint32_t major_version, minor_version, patch_version;
-auto *platform = DNBGetDeploymentInfo(pid, lc, load_command_addr,
-  major_version, minor_version,
-  patch_version);
+auto *platform =
+DNBGetDeploymentInfo(pid, is_executable, lc, load_command_addr,
+ major_version, minor_version, patch_version);
 if (platform) {
   os_handled = true;
   rep << "ostype:" << platform << ";";
Index: lldb/tools/debugserver/source/MacOSX/MachProcess.mm
===
--- lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -93,6 +93,7 @@
 typedef bool (*CallOpenApplicationFunction)(NSString *bundleIDNSStr,
 NSDictionary *options,
 DNBError , pid_t *return_pid);
+
 // This function runs the BKSSystemService (or FBSSystemService) method
 // openApplication:options:clientPort:withResult,
 // messaging the app passed in bundleIDNSStr.
@@ -483,6 +484,7 @@
 #define _POSIX_SPAWN_DISABLE_ASLR 0x0100
 #endif
 
+
 MachProcess::MachProcess()
 : m_pid(0), m_cpu_type(0), m_child_stdin(-1), m_child_stdout(-1),
   m_child_stderr(-1), m_path(), m_args(), m_task(this),
@@ -603,9 +605,11 @@
 
 MachProcess::DeploymentInfo
 MachProcess::GetDeploymentInfo(const struct load_command ,
-   uint64_t load_command_address) {
+   uint64_t load_command_address,
+   bool is_executable) {
   DeploymentInfo info;
   uint32_t cmd = lc.cmd & ~LC_REQ_DYLD;
+
   // Handle the older LC_VERSION load commands, which don't
   // distinguish between simulator and real hardware.
   auto handle_version_min = [&](char platform) {
@@ -640,6 +644,7 @@
 // unambiguous LC_BUILD_VERSION load commands.
 #endif
   };
+
   switch (cmd) {
   case LC_VERSION_MIN_IPHONEOS:
 handle_version_min(PLATFORM_IOS);
@@ -667,6 +672,27 @@
   }
 #endif
   }
+
+  // The xctest binary is a pure macOS binary but is launched with
+  // DYLD_FORCE_PLATFORM=6. In that case, force the platform to
+  // macCatalyst and use the macCatalyst version of the host OS
+  // instead of the macOS deployment target.
+  if (is_executable && GetProcessPlatformViaDYLDSPI() == PLATFORM_MACCATALYST) {
+info.platform = PLATFORM_MACCATALYST;
+std::string catalyst_version = GetMacCatalystVersionString();
+const char *major = catalyst_version.c_str();
+char *minor = nullptr;
+char *patch = nullptr;
+info.major_version = std::strtoul(major, , 10);
+info.minor_version = 0;
+info.patch_version = 0;
+if (minor && *minor == '.') {
+  info.minor_version = std::strtoul(++minor, , 10);
+  if (patch && *patch == '.')
+info.patch_version = std::strtoul(++patch, nullptr, 10);
+}
+  }
+
   return info;
 }
 

[Lldb-commits] [PATCH] D85258: [test] Use realpath consistently for test root file paths.

2020-08-04 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
rupprecht requested review of this revision.
Herald added a subscriber: JDevlieghere.

LLDB tests assume that tests are in the test tree (the `LLDB_TEST_SRC` env 
variable, configured by `dotest.py`).
If this assertion doesn't hold, tests fail in strange ways. An early place this 
goes wrong is in `compute_mydir` which does a simple length-based substring to 
get the relative path. Later, we use that path to chdir to. If the test file 
and test tree don't agree in realpath-ness (and therefore length), this will be 
a cryptic error of chdir-ing to a directory that does not exist.

The actual discrepency is that the places we look for `use_lldb_suite.py` don't 
use a realpath, but `dotest.py` does (see initialization of 
`configuration.testdirs`).

It doesn't particularly matter whether we use realpath or abspath to 
canonicalize things, but many places end up with implicit dependencies on the 
canonicalized pwd being a realpath, so make them realpath consistently. Also, 
in the `compute_mydir` method mentioned, raise an error if the path types don't 
agree.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85258

Files:
  lldb/packages/Python/lldbsuite/__init__.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/use_lldb_suite.py


Index: lldb/test/API/use_lldb_suite.py
===
--- lldb/test/API/use_lldb_suite.py
+++ lldb/test/API/use_lldb_suite.py
@@ -4,9 +4,8 @@
 
 
 def find_lldb_root():
-lldb_root = os.path.dirname(
-os.path.abspath(inspect.getfile(inspect.currentframe()))
-)
+lldb_root = os.path.realpath(
+os.path.dirname(inspect.getfile(inspect.currentframe(
 while True:
 parent = os.path.dirname(lldb_root)
 if parent == lldb_root: # dirname('/') == '/'
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -496,8 +496,12 @@
 mydir = TestBase.compute_mydir(__file__)
 '''
 # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir
-rel_prefix = test_file[len(os.environ["LLDB_TEST_SRC"]) + 1:]
-return os.path.dirname(rel_prefix)
+lldb_test_src = os.environ["LLDB_TEST_SRC"]
+if not test_file.startswith(lldb_test_src):
+  raise Exception(
+  "Test file '%s' must reside within LLDB_TEST_SRC "
+  "(which is '%s')." % (test_file, lldb_test_src))
+return os.path.dirname(os.path.relpath(test_file, start=lldb_test_src))
 
 def TraceOn(self):
 """Returns True if we are in trace mode (tracing detailed test 
execution)."""
Index: lldb/packages/Python/lldbsuite/__init__.py
===
--- lldb/packages/Python/lldbsuite/__init__.py
+++ lldb/packages/Python/lldbsuite/__init__.py
@@ -6,7 +6,8 @@
 
 
 def find_lldb_root():
-lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
+lldb_root = os.path.realpath(
+os.path.dirname(inspect.getfile(inspect.currentframe(
 while True:
 parent = os.path.dirname(lldb_root)
 if parent == lldb_root: # dirname('/') == '/'


Index: lldb/test/API/use_lldb_suite.py
===
--- lldb/test/API/use_lldb_suite.py
+++ lldb/test/API/use_lldb_suite.py
@@ -4,9 +4,8 @@
 
 
 def find_lldb_root():
-lldb_root = os.path.dirname(
-os.path.abspath(inspect.getfile(inspect.currentframe()))
-)
+lldb_root = os.path.realpath(
+os.path.dirname(inspect.getfile(inspect.currentframe(
 while True:
 parent = os.path.dirname(lldb_root)
 if parent == lldb_root: # dirname('/') == '/'
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -496,8 +496,12 @@
 mydir = TestBase.compute_mydir(__file__)
 '''
 # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir
-rel_prefix = test_file[len(os.environ["LLDB_TEST_SRC"]) + 1:]
-return os.path.dirname(rel_prefix)
+lldb_test_src = os.environ["LLDB_TEST_SRC"]
+if not test_file.startswith(lldb_test_src):
+  raise Exception(
+  "Test file '%s' must reside within LLDB_TEST_SRC "
+  "(which is '%s')." % (test_file, lldb_test_src))
+return os.path.dirname(os.path.relpath(test_file, start=lldb_test_src))
 
 def TraceOn(self):
 """Returns True if we are in trace mode (tracing detailed test execution)."""
Index: 

[Lldb-commits] [PATCH] D85106: Move TestGuiBasicDebug.py to lldb/test and update it

2020-08-04 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Ok, if other tests are in there, I am fine with this move.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D85106

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


[Lldb-commits] [PATCH] D85107: Add a test for 'b' (toggle breakpoint)

2020-08-04 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Sounds like it is ok for tests to be here, looks good.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D85107

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


[Lldb-commits] [PATCH] D85265: Add a setting to always run all threads when stepping

2020-08-04 Thread Jim Ingham via Phabricator via lldb-commits
jingham created this revision.
jingham added a reviewer: friss.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
jingham requested review of this revision.
Herald added a subscriber: JDevlieghere.

There are some platforms (the xnu kernel being one) where trying to run just 
one thread can cause problems, and you need to always run all threads whenever 
you do more than a single step-i.

This patch adds a target.process.run-all-threads setting which overrides the 
default "run-mode" value for all the stepping commands.

I also needed to come up with a way to test this.  The easiest way to do that 
was to use a scripted thread plan so that I could check the incoming value.  
But to do that I needed to plumb the stop others through the scripted-step & 
the ThreadPlanPython, which this patch also does.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85265

Files:
  lldb/bindings/interface/SBThreadPlan.i
  lldb/include/lldb/API/SBThreadPlan.h
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/Target/ThreadPlanPython.h
  lldb/source/API/SBThreadPlan.cpp
  lldb/source/Commands/CommandObjectThread.cpp
  lldb/source/Target/Process.cpp
  lldb/source/Target/TargetProperties.td
  lldb/source/Target/Thread.cpp
  lldb/source/Target/ThreadPlanPython.cpp
  lldb/test/API/functionalities/step_scripted/Steps.py
  lldb/test/API/functionalities/step_scripted/TestStepScripted.py

Index: lldb/test/API/functionalities/step_scripted/TestStepScripted.py
===
--- lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -1,7 +1,7 @@
 """
 Tests stepping with scripted thread plans.
 """
-
+import threading
 import lldb
 import lldbsuite.test.lldbutil as lldbutil
 from lldbsuite.test.decorators import *
@@ -111,3 +111,58 @@
 
 # And foo should have changed:
 self.assertTrue(foo_val.GetValueDidChange(), "Foo changed")
+
+def test_stop_others_from_command(self):
+"""Test that the stop-others flag is set correctly by the command line.
+   Also test that the run-all-threads property overrides this."""
+self.do_test_stop_others()
+
+def run_step(self, stop_others_value, run_mode, token):
+import Steps
+interp = self.dbg.GetCommandInterpreter()
+result = lldb.SBCommandReturnObject()
+
+cmd = "thread step-scripted -C Steps.StepReportsStopOthers -k token -v %s"%(token)
+if run_mode != None:
+cmd = cmd + " --run-mode %s"%(run_mode)
+print(cmd)
+interp.HandleCommand(cmd, result)
+self.assertTrue(result.Succeeded(), "Step scripted failed: %s."%(result.GetError()))
+print(Steps.StepReportsStopOthers.stop_mode_dict)
+value = Steps.StepReportsStopOthers.stop_mode_dict[token]
+self.assertEqual(value, stop_others_value, "Stop others has the correct value.")
+
+def do_test_stop_others(self):
+self.build()
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
+"Set a breakpoint here",
+self.main_source_file)
+# First run with stop others false and see that we got that.
+thread_id = ""
+if sys.version_info.major == 2:
+thread_id = str(threading._get_ident())
+else:
+thread_id = str(threading.get_ident())
+
+# all-threads should set stop others to False.
+self.run_step(False, "all-threads", thread_id)
+
+# this-thread should set stop others to True
+self.run_step(True, "this-thread", thread_id)
+
+# The default value should be stop others:
+self.run_step(True, None, thread_id)
+
+# The target.process.run-all-threads should override this:
+interp = self.dbg.GetCommandInterpreter()
+result = lldb.SBCommandReturnObject()
+
+interp.HandleCommand("settings set target.process.run-all-threads true", result)
+self.assertTrue(result.Succeeded, "setting run-all-threads works.")
+
+self.run_step(False, None, thread_id)
+
+
+
+
+
Index: lldb/test/API/functionalities/step_scripted/Steps.py
===
--- lldb/test/API/functionalities/step_scripted/Steps.py
+++ lldb/test/API/functionalities/step_scripted/Steps.py
@@ -75,9 +75,29 @@
 if not self.value.IsValid():
 return True
 
-print("Got next value: %d"%(self.value.GetValueAsUnsigned()))
 if not self.value.GetValueDidChange():
 self.child_thread_plan = self.queue_child_thread_plan()
 return False
 else:
 return True
+
+# This plan does nothing, but sets stop_mode to the
+# 

[Lldb-commits] [PATCH] D85248: [test] Support git commit version ids for clang.

2020-08-04 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85248

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


[Lldb-commits] [PATCH] D85243: [WIP] Factor out common code from the iPhone/AppleTV/WatchOS simulator platform plugins. (NFC)

2020-08-04 Thread Vedant Kumar via Phabricator via lldb-commits
vsk added inline comments.



Comment at: lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp:313
+#if defined(__APPLE__)
+  // Only accept "unknown" for the vendor if the host is Apple and it
+  // "unknown" wasn't specified (it was just returned because it was NOT

s/it$/if$/



Comment at: lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp:558
+  "arm64e-apple-ios-simulator", "arm64-apple-ios-simulator",
+  "x86_64-apple-ios-simulator", "x86_64h-apple-ios-simulator",
+#else

Can we get into a bad state here when initializing lldb on an embedded device?


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

https://reviews.llvm.org/D85243

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


[Lldb-commits] [PATCH] D85123: Truncate long lines/names if needed in lldb gui

2020-08-04 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:438-450
+va_list args;
+va_start(args, format);
+int size = vsnprintf(nullptr, 0, format, args);
+va_end(args);
+if (size <= 0)
+  return;
+++size; // for \0

Use StreamString?:
```
#include "lldb/Utility/StreamString.h"
void PrintfTruncated(int right_pad, const char *format, ...)
  __attribute__((format(printf, 3, 4))) {
  va_list args;
  va_start(args, format);
  StreamString strm;
  strm.PrintfVarArg(format, args);
  va_end(args);
  PutCStringTruncated(right_pad, strm.GetData());
}
```


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D85123

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


[Lldb-commits] [lldb] e7af986 - [lldb-vscode ]Add Syntax Highlighting to Disassembly View

2020-08-04 Thread Walter Erquinigo via lldb-commits

Author: Yifan Shen
Date: 2020-08-04T13:31:44-07:00
New Revision: e7af98680ad52ffc6d308ef63667ac6fb4bb16a7

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

LOG: [lldb-vscode ]Add Syntax Highlighting to Disassembly View

When lldb cannot find source file thus IDE renders a disassembly view, add 
syntax highlighting for constants, registers and final line comments for better 
debugging experience.
The original plain disassembly view looks like:
{F12401687}
An ideal view is like the screenshot attached.
{F12401515}

In this diff, the mimeType is a kind of media type for formatting the content 
in the response to a source request. Elements in the disassembly view, like 
constants, registers and final line comments are colored for highlighting.
A built-in support in the VSCode IDE for syntax highlighting will identify the 
which mimeType to apply and render the disassembly view as expected.

Reviewed By: wallace, clayborg

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

Added: 
lldb/tools/lldb-vscode/syntaxes/arm.disasm
lldb/tools/lldb-vscode/syntaxes/arm64.disasm
lldb/tools/lldb-vscode/syntaxes/disassembly.json
lldb/tools/lldb-vscode/syntaxes/x86.disasm

Modified: 
lldb/tools/lldb-vscode/lldb-vscode.cpp
lldb/tools/lldb-vscode/package.json

Removed: 




diff  --git a/lldb/tools/lldb-vscode/lldb-vscode.cpp 
b/lldb/tools/lldb-vscode/lldb-vscode.cpp
index 27ee832677d7..355a5ebf356b 100644
--- a/lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ b/lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -2188,6 +2188,7 @@ void request_source(const llvm::json::Object ) {
   } else {
 response["success"] = llvm::json::Value(false);
   }
+  EmplaceSafeString(body, "mimeType", "text/x-lldb.disassembly");
   response.try_emplace("body", std::move(body));
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
 }

diff  --git a/lldb/tools/lldb-vscode/package.json 
b/lldb/tools/lldb-vscode/package.json
index f4408d3607d9..29ca06dd17d6 100644
--- a/lldb/tools/lldb-vscode/package.json
+++ b/lldb/tools/lldb-vscode/package.json
@@ -32,6 +32,24 @@
"vsce": "^1.36.3"
},
"contributes": {
+   "languages": [
+   {
+"id": "lldb.disassembly",
+"aliases": [
+"Disassembly"
+],
+"extensions": [
+".disasm"
+]
+   }
+   ],
+   "grammars": [
+   {
+"language": "lldb.disassembly",
+"scopeName": "source.disassembly",
+"path": "./syntaxes/disassembly.json"
+}
+],
"debuggers": [
{
"type": "lldb-vscode",

diff  --git a/lldb/tools/lldb-vscode/syntaxes/arm.disasm 
b/lldb/tools/lldb-vscode/syntaxes/arm.disasm
new file mode 100644
index ..436a78bfc212
--- /dev/null
+++ b/lldb/tools/lldb-vscode/syntaxes/arm.disasm
@@ -0,0 +1,45 @@
+(lldb) 
+libIGL.so`igl::RenderPipelineDesc::TargetDesc::ColorAttachment::operator==:
+libIGL.so[0x7694] <+0>:  ldrr2, [r1]
+libIGL.so[0x7696] <+2>:  ldrr3, [r0]
+libIGL.so[0x7698] <+4>:  cmpr3, r2
+libIGL.so[0x769a] <+6>:  bne0x76da; <+70> at 
RenderPipelineState.cpp
+libIGL.so[0x769c] <+8>:  ldrb   r2, [r1, #0x5]
+libIGL.so[0x769e] <+10>: ldrb   r3, [r0, #0x5]
+libIGL.so[0x76a0] <+12>: cmpr3, r2
+libIGL.so[0x76a2] <+14>: bne0x76da; <+70> at 
RenderPipelineState.cpp
+libIGL.so[0x76a4] <+16>: ldrr2, [r1, #0x8]
+libIGL.so[0x76a6] <+18>: ldrr3, [r0, #0x8]
+libIGL.so[0x76a8] <+20>: cmpr3, r2
+libIGL.so[0x76aa] <+22>: bne0x76da; <+70> at 
RenderPipelineState.cpp
+libIGL.so[0x76ac] <+24>: ldrr2, [r1, #0xc]
+libIGL.so[0x76ae] <+26>: ldrr3, [r0, #0xc]
+libIGL.so[0x76b0] <+28>: cmpr3, r2
+libIGL.so[0x76b2] <+30>: bne0x76da; <+70> at 
RenderPipelineState.cpp
+libIGL.so[0x76b4] <+32>: ldrr2, [r1, #0x10]
+libIGL.so[0x76b6] <+34>: ldrr3, [r0, #0x10]
+libIGL.so[0x76b8] <+36>: cmpr3, r2
+libIGL.so[0x76ba] <+38>: bne0x76da; <+70> at 
RenderPipelineState.cpp
+libIGL.so[0x76bc] <+40>: ldrr2, [r1, #0x14]
+libIGL.so[0x76be] <+42>: ldrr3, [r0, #0x14]
+libIGL.so[0x76c0] <+44>: cmpr3, r2
+libIGL.so[0x76c2] <+46>: bne0x76da; <+70> at 
RenderPipelineState.cpp
+libIGL.so[0x76c4] <+48>: ldrr2, [r1, #0x18]
+libIGL.so[0x76c6] <+50>: ldrr3, [r0, #0x18]
+libIGL.so[0x76c8] <+52>: cmpr3, r2
+libIGL.so[0x76ca] <+54>: bne0x76da; <+70> at 
RenderPipelineState.cpp
+libIGL.so[0x76cc] <+56>: ldr

[Lldb-commits] [PATCH] D84555: [lldb-vscode ]Add Syntax Highlighting to Disassembly View

2020-08-04 Thread Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe7af98680ad5: [lldb-vscode ]Add Syntax Highlighting to 
Disassembly View (authored by aelitashen, committed by Walter Erquinigo 
walterme...@fb.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84555

Files:
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  lldb/tools/lldb-vscode/package.json
  lldb/tools/lldb-vscode/syntaxes/arm.disasm
  lldb/tools/lldb-vscode/syntaxes/arm64.disasm
  lldb/tools/lldb-vscode/syntaxes/disassembly.json
  lldb/tools/lldb-vscode/syntaxes/x86.disasm

Index: lldb/tools/lldb-vscode/syntaxes/x86.disasm
===
--- /dev/null
+++ lldb/tools/lldb-vscode/syntaxes/x86.disasm
@@ -0,0 +1,28 @@
+0x18000: <0> popq %rdi
+0x18001: <1>pushq $0x0
+0x18003: <3> movq %rsp, %rbp
+0x18006: <6> andq $-0x10, %rsp
+0x1800A: <10>subq $0x10, %rsp
+0x1800E: <14>movl 0x8(%rbp), %esi
+0x18011: <17>leaq 0x10(%rbp), %rdx
+0x18015: <21>leaq -0x101c(%rip), %rcx
+0x1801C: <28>leaq -0x8(%rbp), %r8
+0x18020: <32>   callq 0x18062# dyldbootstrap::start(dyld3::MachOLoaded const*, int, char const**, dyld3::MachOLoaded const*, unsigned long*)
+0x18025: <37>movq -0x8(%rbp), %rdi
+0x18029: <41>cmpq $0x0, %rdi
+0x1802D: <45> jne 0x1803f# <+63>
+0x1802F: <47>movq %rbp, %rsp
+0x18032: <50>addq $0x8, %rsp
+0x18036: <54>movq $0x0, %rbp
+0x1803D: <61>jmpq *%rax
+0x1803F: <63>addq $0x10, %rsp
+0x18043: <67>   pushq %rdi
+0x18044: <68>movq 0x8(%rbp), %rdi
+0x18048: <72>leaq 0x10(%rbp), %rsi
+0x1804C: <76>leaq 0x8(%rsi,%rdi,8), %rdx
+0x18051: <81>movq %rdx, %rcx
+0x18054: <84>movq (%rcx), %r8
+0x18057: <87>addq $0x8, %rcx
+0x1805B: <91>   testq %r8, %r8
+0x1805E: <94> jne 0x18054# <+84>
+0x18060: <96>jmpq *%rax
Index: lldb/tools/lldb-vscode/syntaxes/disassembly.json
===
--- /dev/null
+++ lldb/tools/lldb-vscode/syntaxes/disassembly.json
@@ -0,0 +1,64 @@
+{
+  "name": "Disassembly",
+  "scopeName": "source.disassembly",
+  "uuid": "9ade615f-5d82-4ac5-b22f-a1998c356ebe",
+  "patterns": [
+{
+  "comment": "x86 Address, bytes and opcode",
+  "name": "meta.instruction",
+  "match": "^([A-Za-z0-9]+):\\s([A-Z0-9]{2}\\s)+>?\\s+(\\w+)",
+  "captures": {
+"1": {"name": "constant.numeric"},
+"3": {"name": "keyword.opcode"}
+  }
+},
+{
+  "comment": "ARM Address, bytes and opcode",
+  "name": "meta.instruction",
+  "match": "^libIGL.so\\[([A-Za-z0-9]+)\\]\\s+(\\<\\+[0-9]*\\>):\\s+([A-Za-z]+.?[A-Za-z]*)",
+  "captures": {
+"1": {"name": "constant.numeric"},
+"3": {"name": "keyword.opcode"}
+  }
+},
+{
+  "comment": "ARM64 Address, bytes and opcode",
+  "name": "meta.instruction",
+  "match": "^liblog.so\\[([A-Za-z0-9]+)\\]\\s+(\\<\\+[0-9]*\\>):\\s+([A-Za-z]+.?[A-Za-z]*)",
+  "captures": {
+"1": {"name": "constant.numeric"},
+"3": {"name": "keyword.opcode"}
+  }
+},
+{
+  "comment": "Numeric constant",
+  "name": "constant.numeric",
+  "match": "(\\$|\\b)((0x)|[0-9])[A-Za-z0-9]+\\b"
+},
+{
+  "comment": "x86 Register",
+  "name": "variable.language",
+  "match": "%[A-Za-z][A-Za-z0-9]*"
+},
+{
+  "comment": "ARM Register",
+  "name": "variable.language",
+  "match": "r\\d+"
+},
+{
+  "comment": "ARM Register Shortnames",
+  "name": "variable.language",
+  "match": "(fp|sp|lr|pc|wzr|xzr)"
+},
+{
+  "comment": "ARM64 Register",
+  "name": "variable.language",
+  "match": "(x|w)[0-9]+"
+},
+{
+  "comment": "End of line comment",
+  "name": "comment.line.semicolon",
+  "match": ";.*$"
+}
+  ]
+}
Index: lldb/tools/lldb-vscode/syntaxes/arm64.disasm
===
--- /dev/null
+++ lldb/tools/lldb-vscode/syntaxes/arm64.disasm
@@ -0,0 +1,91 @@
+(lldb) disassemble --name __android_log_config_read
+liblog.so`::__android_log_config_read():
+liblog.so[0x6014] <+0>:   stpx22, x21, [sp, #-0x30]!
+liblog.so[0x6018] <+4>:   stpx20, x19, [sp, #0x10]
+liblog.so[0x601c] <+8>:   stpx29, x30, [sp, #0x20]
+liblog.so[0x6020] <+12>:  addx29, sp, #0x20; =0x20
+liblog.so[0x6024] <+16>:  adrp   x8, 15

[Lldb-commits] [lldb] bb33f92 - [lldb/Test] Add missing stdio.h includes

2020-08-04 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-08-04T13:08:14-07:00
New Revision: bb33f925a673f3bb9793d2157c9d3d46d9ad7f25

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

LOG: [lldb/Test] Add missing stdio.h includes

Fixes error: implicit declaration of function 'printf' is invalid in C99
[-Werror,-Wimplicit-function-declaration]

Added: 


Modified: 
lldb/test/API/commands/target/basic/a.c
lldb/test/API/lang/c/global_variables/main.c

Removed: 




diff  --git a/lldb/test/API/commands/target/basic/a.c 
b/lldb/test/API/commands/target/basic/a.c
index b8157275f1a9..9ce587e41453 100644
--- a/lldb/test/API/commands/target/basic/a.c
+++ b/lldb/test/API/commands/target/basic/a.c
@@ -1,3 +1,5 @@
+#include 
+
 int main(int argc, const char* argv[])
 {
 int *null_ptr = 0;

diff  --git a/lldb/test/API/lang/c/global_variables/main.c 
b/lldb/test/API/lang/c/global_variables/main.c
index 864f094edd48..eb7720a6b048 100644
--- a/lldb/test/API/lang/c/global_variables/main.c
+++ b/lldb/test/API/lang/c/global_variables/main.c
@@ -1,3 +1,5 @@
+#include 
+
 int g_common_1; // Not initialized on purpose to cause it to be undefined 
external in .o file
 int g_file_global_int = 42;
 static const int g_file_static_int = 2;



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


[Lldb-commits] [PATCH] D85237: [lldb] Add an option to inherit TCC permissions from parent.

2020-08-04 Thread Frederic Riss via Phabricator via lldb-commits
friss accepted this revision.
friss added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D85237

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


[Lldb-commits] [lldb] 4c9ed3e - [lldb/testsuite] Skip 'frame diagnose' tests based on architecture

2020-08-04 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-08-04T17:45:55-07:00
New Revision: 4c9ed3ed3d2fc7622acf5fc0d80ad20b44cf376a

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

LOG: [lldb/testsuite] Skip 'frame diagnose' tests based on architecture

AFAICS, the feature only works on x86, skipping the tests has nothing to
do with the target being iOS or remote.

Added: 


Modified: 
lldb/test/API/commands/frame/diagnose/array/TestArray.py
lldb/test/API/commands/frame/diagnose/bad-reference/TestBadReference.py

lldb/test/API/commands/frame/diagnose/complicated-expression/TestComplicatedExpression.py

lldb/test/API/commands/frame/diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py

lldb/test/API/commands/frame/diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py

lldb/test/API/commands/frame/diagnose/dereference-this/TestDiagnoseDereferenceThis.py
lldb/test/API/commands/frame/diagnose/inheritance/TestDiagnoseInheritance.py
lldb/test/API/commands/frame/diagnose/local-variable/TestLocalVariable.py

lldb/test/API/commands/frame/diagnose/virtual-method-call/TestDiagnoseDereferenceVirtualMethodCall.py

Removed: 




diff  --git a/lldb/test/API/commands/frame/diagnose/array/TestArray.py 
b/lldb/test/API/commands/frame/diagnose/array/TestArray.py
index 9b049a2bf2a4..5788cacb9a2e 100644
--- a/lldb/test/API/commands/frame/diagnose/array/TestArray.py
+++ b/lldb/test/API/commands/frame/diagnose/array/TestArray.py
@@ -13,7 +13,7 @@ class TestArray(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
 @skipUnlessDarwin
-@skipIfDarwinEmbedded  #  frame diagnose doesn't 
work for armv7 or arm64
+@skipIf(archs=no_match(['x86_64'])) #  frame 
diagnose doesn't work for armv7 or arm64
 def test_array(self):
 self.build()
 exe = self.getBuildArtifact("a.out")

diff  --git 
a/lldb/test/API/commands/frame/diagnose/bad-reference/TestBadReference.py 
b/lldb/test/API/commands/frame/diagnose/bad-reference/TestBadReference.py
index 8650484f12a6..737b297ed76b 100644
--- a/lldb/test/API/commands/frame/diagnose/bad-reference/TestBadReference.py
+++ b/lldb/test/API/commands/frame/diagnose/bad-reference/TestBadReference.py
@@ -13,7 +13,7 @@ class TestBadReference(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
 @skipUnlessDarwin
-@skipIfDarwinEmbedded  #  frame diagnose doesn't 
work for armv7 or arm64
+@skipIf(archs=no_match(['x86_64'])) #  frame 
diagnose doesn't work for armv7 or arm64
 def test_bad_reference(self):
 TestBase.setUp(self)
 self.build()

diff  --git 
a/lldb/test/API/commands/frame/diagnose/complicated-expression/TestComplicatedExpression.py
 
b/lldb/test/API/commands/frame/diagnose/complicated-expression/TestComplicatedExpression.py
index ccc0f88efe06..277fafd14b57 100644
--- 
a/lldb/test/API/commands/frame/diagnose/complicated-expression/TestComplicatedExpression.py
+++ 
b/lldb/test/API/commands/frame/diagnose/complicated-expression/TestComplicatedExpression.py
@@ -13,7 +13,7 @@ class TestDiagnoseDereferenceArgument(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
 @skipUnlessDarwin
-@skipIfDarwinEmbedded  #  frame diagnose doesn't 
work for armv7 or arm64
+@skipIf(archs=no_match(['x86_64'])) #  frame 
diagnose doesn't work for armv7 or arm64
 def test_diagnose_dereference_argument(self):
 TestBase.setUp(self)
 self.build()

diff  --git 
a/lldb/test/API/commands/frame/diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py
 
b/lldb/test/API/commands/frame/diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py
index bdc89a6ed83d..5d5b3a0cf17f 100644
--- 
a/lldb/test/API/commands/frame/diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py
+++ 
b/lldb/test/API/commands/frame/diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py
@@ -13,7 +13,7 @@ class TestDiagnoseDereferenceArgument(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
 @skipUnlessDarwin
-@skipIfDarwinEmbedded  #  frame diagnose doesn't 
work for armv7 or arm64
+@skipIf(archs=no_match(['x86_64'])) #  frame 
diagnose doesn't work for armv7 or arm64
 def test_diagnose_dereference_argument(self):
 TestBase.setUp(self)
 self.build()

diff  --git 
a/lldb/test/API/commands/frame/diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py
 
b/lldb/test/API/commands/frame/diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py
index c49c80791af8..25d7519e5330 100644
--- 
a/lldb/test/API/commands/frame/diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py
+++ 

[Lldb-commits] [PATCH] D85235: [lldb] Make SBTarget::LaunchSimple start form the target's LaunchInfo

2020-08-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 283100.
JDevlieghere added a comment.

Address Jim's offline feedback about `GetProcessLaunchInfo` including the 
executable.


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

https://reviews.llvm.org/D85235

Files:
  lldb/source/API/SBTarget.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/python_api/target/TestTargetAPI.py
  lldb/test/API/python_api/target/main.c

Index: lldb/test/API/python_api/target/main.c
===
--- lldb/test/API/python_api/target/main.c
+++ lldb/test/API/python_api/target/main.c
@@ -36,17 +36,23 @@
 return val + 3;
 }
 
-int main (int argc, char const *argv[])
-{
-// Set a break at entry to main.
-int A1 = a(1);  // a(1) -> b(1) -> c(1)
-printf("a(1) returns %d\n", A1);
-
-int B2 = b(2);  // b(2) -> c(2)
-printf("b(2) returns %d\n", B2);
-
-int A3 = a(3);  // a(3) -> c(3)
-printf("a(3) returns %d\n", A3);
-
-return 0;
+int main(int argc, char const *argv[], char **env) {
+  // Set a break at entry to main.
+  int A1 = a(1); // a(1) -> b(1) -> c(1)
+  printf("a(1) returns %d\n", A1);
+
+  int B2 = b(2); // b(2) -> c(2)
+  printf("b(2) returns %d\n", B2);
+
+  int A3 = a(3); // a(3) -> c(3)
+  printf("a(3) returns %d\n", A3);
+
+  for (int i = 1; i < argc; i++) {
+printf("arg: %s\n", argv[i]);
+  }
+
+  while (*env)
+printf("env: %s\n", *env++);
+
+  return 0;
 }
Index: lldb/test/API/python_api/target/TestTargetAPI.py
===
--- lldb/test/API/python_api/target/TestTargetAPI.py
+++ lldb/test/API/python_api/target/TestTargetAPI.py
@@ -150,6 +150,38 @@
 self.assertTrue(error.Success(), "Make sure memory read succeeded")
 self.assertEqual(len(content), 1)
 
+
+@add_test_categories(['pyapi'])
+def test_launch_simple(self):
+d = {'EXE': 'b.out'}
+self.build(dictionary=d)
+self.setTearDownCleanup(dictionary=d)
+target = self.create_simple_target('b.out')
+
+process = target.LaunchSimple(
+['foo', 'bar'], ['baz'], self.get_process_working_directory())
+self.runCmd("run")
+output = process.GetSTDOUT()
+self.assertIn('arg: foo', output)
+self.assertIn('arg: bar', output)
+self.assertIn('env: baz', output)
+
+self.runCmd("setting set target.run-args foo")
+self.runCmd("setting set target.env-vars bar=baz")
+process = target.LaunchSimple(None, None,
+  self.get_process_working_directory())
+self.runCmd("run")
+output = process.GetSTDOUT()
+self.assertIn('arg: foo', output)
+self.assertIn('env: bar=baz', output)
+
+self.runCmd("settings set target.disable-stdio true")
+process = target.LaunchSimple(
+None, None, self.get_process_working_directory())
+self.runCmd("run")
+output = process.GetSTDOUT()
+self.assertEqual(output, "")
+
 def create_simple_target(self, fn):
 exe = self.getBuildArtifact(fn)
 target = self.dbg.CreateTarget(exe)
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3914,6 +3914,8 @@
 }
 
 const ProcessLaunchInfo ::GetProcessLaunchInfo() {
+  if (Module *exe_module = m_target->GetExecutableModulePointer())
+m_launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
   m_launch_info.SetArg0(GetArg0()); // FIXME: Arg0 callback doesn't work
   return m_launch_info;
 }
Index: lldb/source/API/SBTarget.cpp
===
--- lldb/source/API/SBTarget.cpp
+++ lldb/source/API/SBTarget.cpp
@@ -287,16 +287,21 @@
  (const char **, const char **, const char *), argv, envp,
  working_directory);
 
-  char *stdin_path = nullptr;
-  char *stdout_path = nullptr;
-  char *stderr_path = nullptr;
-  uint32_t launch_flags = 0;
-  bool stop_at_entry = false;
+  TargetSP target_sp = GetSP();
+  if (!target_sp)
+return LLDB_RECORD_RESULT(SBProcess());
+
+  SBLaunchInfo launch_info = GetLaunchInfo();
+
+  if (argv)
+launch_info.SetArguments(argv, /*append*/ true);
+  if (envp)
+launch_info.SetEnvironmentEntries(envp, /*append*/ false);
+  if (working_directory)
+launch_info.SetWorkingDirectory(working_directory);
+
   SBError error;
-  SBListener listener = GetDebugger().GetListener();
-  return LLDB_RECORD_RESULT(Launch(listener, argv, envp, stdin_path,
-   stdout_path, stderr_path, working_directory,
-   launch_flags, stop_at_entry, error));
+  return LLDB_RECORD_RESULT(Launch(launch_info, error));
 }
 
 SBError SBTarget::Install() {

[Lldb-commits] [PATCH] D85235: [lldb] Make SBTarget::LaunchSimple start form the target's LaunchInfo

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

LGTM


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

https://reviews.llvm.org/D85235

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


[Lldb-commits] [PATCH] D85248: [test] Support git commit version ids for clang.

2020-08-04 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
rupprecht requested review of this revision.
Herald added a subscriber: JDevlieghere.

`getCompilerVersion` assumes that `clang --version` prints out a string like 
`version [0-9\.]+`.
If clang is built from trunk, the version line might look like `clang version 
trunk (123abc)`.

Since there isn't any way of knowing by the commit id alone whether one commit 
is newer or older than another git commit (or clang version), assume that clang 
with a version id like this is very close to trunk. For example, any tests with 
`@skipIf(compiler="clang", compiler_version=['<', '8'])` should be run.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85248

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


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1322,25 +1322,35 @@
Use compiler_version[0] to specify the operator used to determine 
if a match has occurred.
Any operator other than the following defaults to an equality test:
  '>', '>=', "=>", '<', '<=', '=<', '!=', "!" or 'not'
+
+   If the current compiler version cannot be determined, we assume it 
is close to the top
+   of trunk, so any less-than or equal-to comparisons will return 
False, and any
+   greater-than or not-equal-to comparisons will return True.
 """
-if (compiler_version is None):
+if compiler_version is None:
 return True
 operator = str(compiler_version[0])
 version = compiler_version[1]
 
-if (version is None):
+if version is None:
 return True
-if (operator == '>'):
-return LooseVersion(self.getCompilerVersion()) > 
LooseVersion(version)
-if (operator == '>=' or operator == '=>'):
-return LooseVersion(self.getCompilerVersion()) >= 
LooseVersion(version)
-if (operator == '<'):
-return LooseVersion(self.getCompilerVersion()) < 
LooseVersion(version)
-if (operator == '<=' or operator == '=<'):
-return LooseVersion(self.getCompilerVersion()) <= 
LooseVersion(version)
-if (operator == '!=' or operator == '!' or operator == 'not'):
-return str(version) not in str(self.getCompilerVersion())
-return str(version) in str(self.getCompilerVersion())
+
+test_compiler_version = self.getCompilerVersion()
+if test_compiler_version == 'unknown':
+# Assume the compiler version is at or near the top of trunk.
+return operator in ['>', '>=', '!', '!=', 'not']
+
+if operator == '>':
+return LooseVersion(test_compiler_version) > LooseVersion(version)
+if operator == '>=' or operator == '=>':
+return LooseVersion(test_compiler_version) >= LooseVersion(version)
+if operator == '<':
+return LooseVersion(test_compiler_version) < LooseVersion(version)
+if operator == '<=' or operator == '=<':
+return LooseVersion(test_compiler_version) <= LooseVersion(version)
+if operator == '!=' or operator == '!' or operator == 'not':
+return str(version) not in str(test_compiler_version)
+return str(version) in str(test_compiler_version)
 
 def expectedCompiler(self, compilers):
 """Returns True iff any element of compilers is a sub-string of the 
current compiler."""


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1322,25 +1322,35 @@
Use compiler_version[0] to specify the operator used to determine if a match has occurred.
Any operator other than the following defaults to an equality test:
  '>', '>=', "=>", '<', '<=', '=<', '!=', "!" or 'not'
+
+   If the current compiler version cannot be determined, we assume it is close to the top
+   of trunk, so any less-than or equal-to comparisons will return False, and any
+   greater-than or not-equal-to comparisons will return True.
 """
-if (compiler_version is None):
+if compiler_version is None:
 return True
 operator = str(compiler_version[0])
 version = compiler_version[1]
 
-if (version is None):
+if version is None:
 return True
-if (operator == '>'):
-return LooseVersion(self.getCompilerVersion()) > LooseVersion(version)
-if (operator == '>=' or operator == '=>'):
-return LooseVersion(self.getCompilerVersion()) >= LooseVersion(version)
-if (operator == 

[Lldb-commits] [PATCH] D85106: Move TestGuiBasicDebug.py to lldb/test and update it

2020-08-04 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

In D85106#2194840 , @clayborg wrote:

> lldb/test/API is usually for testing the lldb::SB* interfaces IIRC. So not 
> sure this move makes sense?

It's really for any test that wants to use the lldbtest test harness.  There 
are other tests in the commands sub-directory that use lldbutil methods to get 
the test up and going, then a bunch of self.expects to test various command 
line output.  Oddly enough there are also some tests in there (like the 
disassemble/basic test) that don't seem to test command line commands at all.  
But that's a separate issue.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D85106

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


[Lldb-commits] [PATCH] D85258: [test] Use realpath consistently for test root file paths.

2020-08-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:499
 # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir
-rel_prefix = test_file[len(os.environ["LLDB_TEST_SRC"]) + 1:]
-return os.path.dirname(rel_prefix)
+lldb_test_src = os.environ["LLDB_TEST_SRC"]
+if not test_file.startswith(lldb_test_src):

While you are here... can you change this to pass the source directory trough 
the `configuration`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85258

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


[Lldb-commits] [PATCH] D85219: [lldb] fix building with panel.h being in /usr/include/ncurses/

2020-08-04 Thread Michał Górny via Phabricator via lldb-commits
mgorny accepted this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

I suppose this makes sense. Testing it on some more systems might be good but I 
guess buildbot will take care of that.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D85219

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


[Lldb-commits] [PATCH] D85235: [lldb] Make SBTarget::LaunchSimple start form the target's LaunchInfo

2020-08-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 283001.
JDevlieghere added a comment.

Test a few more cases


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

https://reviews.llvm.org/D85235

Files:
  lldb/source/API/SBTarget.cpp
  lldb/test/API/python_api/target/TestTargetAPI.py
  lldb/test/API/python_api/target/main.c

Index: lldb/test/API/python_api/target/main.c
===
--- lldb/test/API/python_api/target/main.c
+++ lldb/test/API/python_api/target/main.c
@@ -36,17 +36,24 @@
 return val + 3;
 }
 
-int main (int argc, char const *argv[])
+int main (int argc, char const *argv[], char** env)
 {
 // Set a break at entry to main.
 int A1 = a(1);  // a(1) -> b(1) -> c(1)
 printf("a(1) returns %d\n", A1);
-
+
 int B2 = b(2);  // b(2) -> c(2)
 printf("b(2) returns %d\n", B2);
-
+
 int A3 = a(3);  // a(3) -> c(3)
 printf("a(3) returns %d\n", A3);
-
+
+for (int i = 1; i < argc; i++) {
+  printf("arg: %s\n", argv[i]);
+}
+
+while (*env)
+  printf("env: %s\n", *env++);
+
 return 0;
 }
Index: lldb/test/API/python_api/target/TestTargetAPI.py
===
--- lldb/test/API/python_api/target/TestTargetAPI.py
+++ lldb/test/API/python_api/target/TestTargetAPI.py
@@ -150,6 +150,38 @@
 self.assertTrue(error.Success(), "Make sure memory read succeeded")
 self.assertEqual(len(content), 1)
 
+
+@add_test_categories(['pyapi'])
+def test_launch_simple(self):
+d = {'EXE': 'b.out'}
+self.build(dictionary=d)
+self.setTearDownCleanup(dictionary=d)
+target = self.create_simple_target('b.out')
+
+process = target.LaunchSimple(
+['foo', 'bar'], ['baz'], self.get_process_working_directory())
+self.runCmd("run")
+output = process.GetSTDOUT()
+self.assertIn('arg: foo', output)
+self.assertIn('arg: bar', output)
+self.assertIn('env: baz', output)
+
+self.runCmd("setting set target.run-args foo")
+self.runCmd("setting set target.env-vars bar=baz")
+process = target.LaunchSimple(None, None,
+  self.get_process_working_directory())
+self.runCmd("run")
+output = process.GetSTDOUT()
+self.assertIn('arg: foo', output)
+self.assertIn('env: bar=baz', output)
+
+self.runCmd("settings set target.disable-stdio true")
+process = target.LaunchSimple(
+None, None, self.get_process_working_directory())
+self.runCmd("run")
+output = process.GetSTDOUT()
+self.assertEqual(output, "")
+
 def create_simple_target(self, fn):
 exe = self.getBuildArtifact(fn)
 target = self.dbg.CreateTarget(exe)
Index: lldb/source/API/SBTarget.cpp
===
--- lldb/source/API/SBTarget.cpp
+++ lldb/source/API/SBTarget.cpp
@@ -287,16 +287,24 @@
  (const char **, const char **, const char *), argv, envp,
  working_directory);
 
-  char *stdin_path = nullptr;
-  char *stdout_path = nullptr;
-  char *stderr_path = nullptr;
-  uint32_t launch_flags = 0;
-  bool stop_at_entry = false;
+  TargetSP target_sp = GetSP();
+  if (!target_sp)
+return LLDB_RECORD_RESULT(SBProcess());
+
+  SBLaunchInfo launch_info = GetLaunchInfo();
+
+  if (Module *exe_module = target_sp->GetExecutableModulePointer())
+launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(),
+  /*add_as_first_arg*/ true);
+  if (argv)
+launch_info.SetArguments(argv, /*append*/ true);
+  if (envp)
+launch_info.SetEnvironmentEntries(envp, /*append*/ false);
+  if (working_directory)
+launch_info.SetWorkingDirectory(working_directory);
+
   SBError error;
-  SBListener listener = GetDebugger().GetListener();
-  return LLDB_RECORD_RESULT(Launch(listener, argv, envp, stdin_path,
-   stdout_path, stderr_path, working_directory,
-   launch_flags, stop_at_entry, error));
+  return LLDB_RECORD_RESULT(Launch(launch_info, error));
 }
 
 SBError SBTarget::Install() {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85175: [test] Use abspath instead of realpath sometimes

2020-08-04 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG817b3a6fe3a4: [test] Use abspath instead of realpath 
sometimes (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85175

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


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -241,7 +241,7 @@
 do_help = True
 
 if args.compiler:
-configuration.compiler = os.path.realpath(args.compiler)
+configuration.compiler = os.path.abspath(args.compiler)
 if not is_exe(configuration.compiler):
 configuration.compiler = which(args.compiler)
 if not is_exe(configuration.compiler):
@@ -461,7 +461,7 @@
 if "DOTEST_PROFILE" in os.environ and "DOTEST_SCRIPT_DIR" in os.environ:
 scriptPath = os.environ["DOTEST_SCRIPT_DIR"]
 else:
-scriptPath = os.path.dirname(os.path.realpath(__file__))
+scriptPath = os.path.dirname(os.path.abspath(__file__))
 if not scriptPath.endswith('test'):
 print("This script expects to reside in lldb's test directory.")
 sys.exit(-1)


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -241,7 +241,7 @@
 do_help = True
 
 if args.compiler:
-configuration.compiler = os.path.realpath(args.compiler)
+configuration.compiler = os.path.abspath(args.compiler)
 if not is_exe(configuration.compiler):
 configuration.compiler = which(args.compiler)
 if not is_exe(configuration.compiler):
@@ -461,7 +461,7 @@
 if "DOTEST_PROFILE" in os.environ and "DOTEST_SCRIPT_DIR" in os.environ:
 scriptPath = os.environ["DOTEST_SCRIPT_DIR"]
 else:
-scriptPath = os.path.dirname(os.path.realpath(__file__))
+scriptPath = os.path.dirname(os.path.abspath(__file__))
 if not scriptPath.endswith('test'):
 print("This script expects to reside in lldb's test directory.")
 sys.exit(-1)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 817b3a6 - [test] Use abspath instead of realpath sometimes

2020-08-04 Thread Jordan Rupprecht via lldb-commits

Author: Jordan Rupprecht
Date: 2020-08-04T08:20:50-07:00
New Revision: 817b3a6fe3a4452eb61a2503c8beaa7267ca0351

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

LOG: [test] Use abspath instead of realpath sometimes

In these two cases, use of `os.path.realpath` is problematic:

- The name of the compiler is significant [1] . For testing purposes, we might
  provide a compiler called "clang" which is actually a symlink to some build
  script (which does some flag processing before invoking the real clang). The
  destination the symlink may not be called "clang", but we still want it to be
  treated as such.
- When using a build system that puts build artifacts in an arbitrary build
  location, and later creates a symlink for it (e.g. creates a
  "/lldbsuite/test/dotest.py" symlinks that points to
  "/build/artifact//dotest.py"), looking at the realpath will not match
  the "test" convention required here.

[1] See `Makefile.rules` in the lldb tree, e.g. we use different flags if the 
compiler is named "clang"

Reviewed By: JDevlieghere

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

Added: 


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

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 3fb802f1c1aa..f43685c069e4 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -241,7 +241,7 @@ def parseOptionsAndInitTestdirs():
 do_help = True
 
 if args.compiler:
-configuration.compiler = os.path.realpath(args.compiler)
+configuration.compiler = os.path.abspath(args.compiler)
 if not is_exe(configuration.compiler):
 configuration.compiler = which(args.compiler)
 if not is_exe(configuration.compiler):
@@ -461,7 +461,7 @@ def setupSysPath():
 if "DOTEST_PROFILE" in os.environ and "DOTEST_SCRIPT_DIR" in os.environ:
 scriptPath = os.environ["DOTEST_SCRIPT_DIR"]
 else:
-scriptPath = os.path.dirname(os.path.realpath(__file__))
+scriptPath = os.path.dirname(os.path.abspath(__file__))
 if not scriptPath.endswith('test'):
 print("This script expects to reside in lldb's test directory.")
 sys.exit(-1)



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


[Lldb-commits] [PATCH] D85241: [intel-pt] Disable/Enable tracing to guarantee the trace is correct

2020-08-04 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 283009.
wallace added a comment.

remove an empty line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85241

Files:
  lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp


Index: lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp
===
--- lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp
+++ lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp
@@ -17,6 +17,7 @@
 #include "ProcessorTrace.h"
 #include "lldb/Host/linux/Support.h"
 
+#include 
 #include 
 
 using namespace lldb;
@@ -273,6 +274,23 @@
 #ifndef PERF_ATTR_SIZE_VER5
   llvm_unreachable("perf event not supported");
 #else
+  // Disable the perf event to force a flush out of the CPU's internal buffer.
+  // Besides, we can guarantee that the CPU won't override any data as we are
+  // reading the buffer.
+  //
+  // The Intel documentation says:
+  //
+  // Packets are first buffered internally and then written out asynchronously.
+  // To collect packet output for postprocessing, a collector needs first to
+  // ensure that all packet data has been flushed from internal buffers.
+  // Software can ensure this by stopping packet generation by clearing
+  // IA32_RTIT_CTL.TraceEn (see “Disabling Packet Generation” in
+  // Section 35.2.7.2).
+  //
+  // This is achieved by the PERF_EVENT_IOC_DISABLE ioctl request, as mentioned
+  // in the man page of perf_event_open.
+  ioctl(*m_fd, PERF_EVENT_IOC_DISABLE);
+
   Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE));
   Status error;
   uint64_t head = m_mmap_meta->aux_head;
@@ -293,6 +311,9 @@
 
   ReadCyclicBuffer(buffer, GetAuxBuffer(), static_cast(head), offset);
   LLDB_LOG(log, "ReadCyclic BUffer Done");
+
+  // Reenable tracing now we have read the buffer
+  ioctl(*m_fd, PERF_EVENT_IOC_ENABLE);
   return error;
 #endif
 }


Index: lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp
===
--- lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp
+++ lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp
@@ -17,6 +17,7 @@
 #include "ProcessorTrace.h"
 #include "lldb/Host/linux/Support.h"
 
+#include 
 #include 
 
 using namespace lldb;
@@ -273,6 +274,23 @@
 #ifndef PERF_ATTR_SIZE_VER5
   llvm_unreachable("perf event not supported");
 #else
+  // Disable the perf event to force a flush out of the CPU's internal buffer.
+  // Besides, we can guarantee that the CPU won't override any data as we are
+  // reading the buffer.
+  //
+  // The Intel documentation says:
+  //
+  // Packets are first buffered internally and then written out asynchronously.
+  // To collect packet output for postprocessing, a collector needs first to
+  // ensure that all packet data has been flushed from internal buffers.
+  // Software can ensure this by stopping packet generation by clearing
+  // IA32_RTIT_CTL.TraceEn (see “Disabling Packet Generation” in
+  // Section 35.2.7.2).
+  //
+  // This is achieved by the PERF_EVENT_IOC_DISABLE ioctl request, as mentioned
+  // in the man page of perf_event_open.
+  ioctl(*m_fd, PERF_EVENT_IOC_DISABLE);
+
   Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE));
   Status error;
   uint64_t head = m_mmap_meta->aux_head;
@@ -293,6 +311,9 @@
 
   ReadCyclicBuffer(buffer, GetAuxBuffer(), static_cast(head), offset);
   LLDB_LOG(log, "ReadCyclic BUffer Done");
+
+  // Reenable tracing now we have read the buffer
+  ioctl(*m_fd, PERF_EVENT_IOC_ENABLE);
   return error;
 #endif
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

2020-08-04 Thread Shu Anzai via Phabricator via lldb-commits
gedatsu217 updated this revision to Diff 282961.
gedatsu217 added a comment.

Add test.

Delete gray character if autosuggestion has the only one character. (e.g. "b") 
(Editline::TabCommand)

Simplify the code.


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

https://reviews.llvm.org/D81001

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Core/IOHandler.h
  lldb/include/lldb/Host/Editline.h
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Core/CoreProperties.td
  lldb/source/Core/Debugger.cpp
  lldb/source/Core/IOHandler.cpp
  lldb/source/Host/common/Editline.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/test/API/iohandler/autosuggestion/TestAutosuggestion.py

Index: lldb/test/API/iohandler/autosuggestion/TestAutosuggestion.py
===
--- /dev/null
+++ lldb/test/API/iohandler/autosuggestion/TestAutosuggestion.py
@@ -0,0 +1,104 @@
+"""
+Tests autosuggestion using pexpect.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+def cursor_horizontal_abs(s):
+return "\x1b[" + str(len(s) + 1) + "G"
+
+
+
+class TestCase(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+@skipIfEditlineSupportMissing
+def test_autosuggestion_add_spaces(self):
+self.launch(extra_args=["-o", "settings set show-autosuggestion true", "-o", "settings set use-color true"])
+
+# Common input codes and escape sequences. 
+faint_color = "\x1b[2m"
+reset = "\x1b[0m"
+
+# Check if spaces are added to hide the previous gray characters.
+self.expect("help frame var")
+self.expect("help frame info")
+self.child.send("help frame v")
+self.child.expect_exact(cursor_horizontal_abs("(lldb) help frame ") + "v" + faint_color + "ar" + reset + " ")
+
+@skipIfAsan
+@skipIfEditlineSupportMissing
+def test_autosuggestion(self):
+self.launch(extra_args=["-o", "settings set show-autosuggestion true", "-o", "settings set use-color true"])
+
+# Common input codes and escape sequences. 
+ctrl_f = "\x06"
+faint_color = "\x1b[2m"
+reset = "\x1b[0m"
+delete = chr(127)
+
+frame_output_needle = "Syntax: frame "  
+# Run 'help frame' once to put it into the command history. 
+self.expect("help frame", substrs=[frame_output_needle])
+
+# Check that LLDB shows the autosuggestion in gray behind the text. 
+self.child.send("hel")
+self.child.expect_exact(cursor_horizontal_abs("(lldb) he") + "l" + faint_color + "p frame" + reset)
+
+# Apply the autosuggestion and press enter. This should print the
+# 'help frame' output if everything went correctly.
+self.child.send(ctrl_f + "\n")
+self.child.expect_exact(frame_output_needle)
+
+# Check that pressing Ctrl+F directly after Ctrl+F again does nothing.
+self.child.send("hel" + ctrl_f + ctrl_f + "\n")
+self.child.expect_exact(frame_output_needle)
+
+# Try autosuggestion using tab and ^f. 
+# \t makes "help" and ^f makes "help frame". If everything went 
+# correct we should see the 'help frame' output again.
+self.child.send("hel\t" + ctrl_f + "\n")
+self.child.expect_exact(frame_output_needle)
+
+# Check that autosuggestion works after delete.
+self.child.send("a1234" + 5 * delete + "hel" + ctrl_f + "\n")
+self.child.expect_exact(frame_output_needle)
+
+# Check that autosuggestion works after delete.
+self.child.send("help x" + delete + ctrl_f + "\n")
+self.child.expect_exact(frame_output_needle)
+
+# Check that autosuggestion complete to the most recent one.
+self.child.send("help frame variable\n")
+self.child.send("help fr")
+self.child.expect_exact(faint_color + "ame variable" + reset)
+self.child.send("\n")
+
+# Try another command.
+apropos_output_needle = "Syntax: apropos "
+# Run 'help frame' once to put it into the command history.
+self.expect("help apropos", substrs=[apropos_output_needle])
+
+# Check that 'hel' should have an autosuggestion for 'help apropos' now.   
+self.child.send("hel")
+self.child.expect_exact(cursor_horizontal_abs("(lldb) he") + "l" + faint_color + "p apropos" + reset)
+
+# Run the command and expect the 'help apropos' output.   
+self.child.send(ctrl_f + "\n")
+

[Lldb-commits] [PATCH] D85241: [intel-pt] Disable/Enable tracing to guarantee the trace is correct

2020-08-04 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
wallace added a reviewer: clayborg.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
wallace requested review of this revision.
Herald added a subscriber: JDevlieghere.

As mentioned in the comment inside the code, the Intel documentation
states that the internal CPU buffer is flushed out to RAM only when tracing is
disabled. Otherwise, the buffer on RAM might be stale.

This diff disables tracing when the trace buffer is going to be read. This is a
quite safe operation, as the reading is done when the inferior is paused at a
breakpoint, so we are not losing any packets because there's no code being
executed.

After the reading is finished, tracing is enabled back.

It's a bit hard to write a test for this now, as Greg Clayton and I will
refactor the PT support, but I tested manually by doing a script that automates
the following flow

  (lldb) b main
  Breakpoint 1: where = a.out`main + 15 at main.cpp:4:7, address = 
0x0040050f
  (lldb) r
  Process 3078226 launched: 
'/home/wallace/llvm-sand/build/Release/Linux-x86_64/llvm/lldb-test-build.noindex/tools/intel-features/intel-pt/simple-test/TestIntelPTSimpleBinary.test_basic_flow/a.out'
 (x86_64)
  Process 3078226 stopped
  * thread #1, name = 'a.out', stop reason = breakpoint 1.1
  frame #0: 0x0040050f a.out`main at main.cpp:4:7
  (lldb) processor-trace start
  (lldb) b 5
  Breakpoint 2: where = a.out`main + 22 at main.cpp:5:12, address = 
0x00400516
  (lldb) c
  Process 3078226 resuming
  Process 3078226 stopped
  * thread #1, name = 'a.out', stop reason = breakpoint 2.1
  frame #0: 0x00400516 a.out`main at main.cpp:5:12
  (lldb) processor-trace show-instr-log 
  thread #1: tid=3078226
  0x40050f <+15>: movl   $0x0, -0x8(%rbp)
  
  >>> Before, some runs of the script up to this point lead to empty traces
  
  (lldb) b 6
  Breakpoint 3: where = a.out`main + 42 at main.cpp:6:14, address = 
0x0040052a
  (lldb) c
  Process 3092991 resuming
  Process 3092991 stopped
  * thread #1, name = 'a.out', stop reason = breakpoint 3.1
  frame #0: 0x0040052a a.out`main at main.cpp:6:14
  (lldb) processor-trace show-instr-log 

  thread #1: tid=3092991
  0x40050f <+15>: movl   $0x0, -0x8(%rbp)
  0x400516 <+22>: movl   $0x0, -0xc(%rbp)
  0x40051d <+29>: cmpl   $0x2710, -0xc(%rbp)   ; imm = 0x2710 
  0x400524 <+36>: jge0x400546  ; <+70> at main.cpp
  0x400524 <+36>: jge0x400546  ; <+70> at main.cpp
  
  >>> The trace was re-enabled correctly and includes the instruction of the
  first reading.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85241

Files:
  lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp


Index: lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp
===
--- lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp
+++ lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp
@@ -17,6 +17,7 @@
 #include "ProcessorTrace.h"
 #include "lldb/Host/linux/Support.h"
 
+#include 
 #include 
 
 using namespace lldb;
@@ -143,6 +144,7 @@
   }
   m_mmap_aux = std::unique_ptr(
   reinterpret_cast(mmap_aux), munmap_delete(bufsize));
+
   return error;
 #endif
 }
@@ -273,6 +275,23 @@
 #ifndef PERF_ATTR_SIZE_VER5
   llvm_unreachable("perf event not supported");
 #else
+  // Disable the perf event to force a flush out of the CPU's internal buffer.
+  // Besides, we can guarantee that the CPU won't override any data as we are
+  // reading the buffer.
+  //
+  // The Intel documentation says:
+  //
+  // Packets are first buffered internally and then written out asynchronously.
+  // To collect packet output for postprocessing, a collector needs first to
+  // ensure that all packet data has been flushed from internal buffers.
+  // Software can ensure this by stopping packet generation by clearing
+  // IA32_RTIT_CTL.TraceEn (see “Disabling Packet Generation” in
+  // Section 35.2.7.2).
+  //
+  // This is achieved by the PERF_EVENT_IOC_DISABLE ioctl request, as mentioned
+  // in the man page of perf_event_open.
+  ioctl(*m_fd, PERF_EVENT_IOC_DISABLE);
+
   Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE));
   Status error;
   uint64_t head = m_mmap_meta->aux_head;
@@ -293,6 +312,9 @@
 
   ReadCyclicBuffer(buffer, GetAuxBuffer(), static_cast(head), offset);
   LLDB_LOG(log, "ReadCyclic BUffer Done");
+
+  // Reenable tracing now we have read the buffer
+  ioctl(*m_fd, PERF_EVENT_IOC_ENABLE);
   return error;
 #endif
 }


Index: lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp
===
--- lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp
+++ 

[Lldb-commits] [PATCH] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

2020-08-04 Thread Shu Anzai via Phabricator via lldb-commits
gedatsu217 added a comment.

@teemperor I understand what you say just now. Indeed, your method is more 
efficient than mine. I'm fixing the code now.


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

https://reviews.llvm.org/D81001

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


[Lldb-commits] [PATCH] D85217: [lldb] Upstream macOS TCC code

2020-08-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: mib, jasonmolenda.
JDevlieghere added a project: LLDB.
JDevlieghere requested review of this revision.

Upstream the code for dealing with TCC introduced in macOS Mojave. This will 
make the debuggee instead of the debugger responsible for the privileges it 
needs.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D85217

Files:
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h


Index: lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h
===
--- /dev/null
+++ lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h
@@ -0,0 +1,46 @@
+//===-- PosixSpawnResponsible.h -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_HOST_POSIXSPAWNRESPONSIBLE_H
+#define LLDB_HOST_POSIXSPAWNRESPONSIBLE_H
+
+#include 
+
+#if __has_include()
+#include 
+#include 
+#include 
+
+// Older SDKs  have responsibility.h but not this particular function. Let's
+// include the prototype here.
+errno_t responsibility_spawnattrs_setdisclaim(posix_spawnattr_t *attrs,
+  bool disclaim);
+
+#endif
+
+static inline int setup_posix_spawn_responsible_flag(posix_spawnattr_t *attr) {
+  if (@available(macOS 10.14, *)) {
+#if __has_include()
+static __typeof__(responsibility_spawnattrs_setdisclaim)
+*responsibility_spawnattrs_setdisclaim_ptr;
+static dispatch_once_t pred;
+dispatch_once(, ^{
+  responsibility_spawnattrs_setdisclaim_ptr =
+#ifdef __cplusplus
+  reinterpret_cast<__typeof__(_spawnattrs_setdisclaim)>
+#endif
+  (dlsym(RTLD_DEFAULT, "responsibility_spawnattrs_setdisclaim"));
+});
+if (responsibility_spawnattrs_setdisclaim_ptr)
+  return responsibility_spawnattrs_setdisclaim_ptr(attr, true);
+#endif
+  }
+  return 0;
+}
+
+#endif // LLDB_HOST_POSIXSPAWNRESPONSIBLE_H
Index: lldb/source/Host/macosx/objcxx/Host.mm
===
--- lldb/source/Host/macosx/objcxx/Host.mm
+++ lldb/source/Host/macosx/objcxx/Host.mm
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "lldb/Host/Host.h"
+#include "PosixSpawnResponsible.h"
 
 #include 
 #include 
@@ -1083,6 +1084,30 @@
 return error;
   }
 
+  bool is_graphical = true;
+
+#if TARGET_OS_OSX
+  // AuthSession.h is only in Security.framework on macOS.
+  SecuritySessionId session_id;
+  SessionAttributeBits session_attributes;
+  OSStatus status =
+  SessionGetInfo(callerSecuritySession, _id, _attributes);
+  if (status == errSessionSuccess)
+is_graphical = session_attributes & sessionHasGraphicAccess;
+#endif
+
+  //  When lldb is ran through a graphical session, this makes the debuggee
+  //  process responsible for the TCC prompts. Otherwise, lldb will use the
+  //  launching process privileges.
+  if (is_graphical && launch_info.GetFlags().Test(eLaunchFlagDebug)) {
+error.SetError(setup_posix_spawn_responsible_flag(), eErrorTypePOSIX);
+if (error.Fail()) {
+  LLDB_LOG(log, "error: {0}, setup_posix_spawn_responsible_flag()",
+   error);
+  return error;
+}
+  }
+
   const char *tmp_argv[2];
   char *const *argv = const_cast(
   launch_info.GetArguments().GetConstArgumentVector());


Index: lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h
===
--- /dev/null
+++ lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h
@@ -0,0 +1,46 @@
+//===-- PosixSpawnResponsible.h -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_HOST_POSIXSPAWNRESPONSIBLE_H
+#define LLDB_HOST_POSIXSPAWNRESPONSIBLE_H
+
+#include 
+
+#if __has_include()
+#include 
+#include 
+#include 
+
+// Older SDKs  have responsibility.h but not this particular function. Let's
+// include the prototype here.
+errno_t responsibility_spawnattrs_setdisclaim(posix_spawnattr_t *attrs,
+  bool disclaim);
+
+#endif
+
+static inline int setup_posix_spawn_responsible_flag(posix_spawnattr_t *attr) {
+  if (@available(macOS 10.14, *)) {
+#if __has_include()
+static __typeof__(responsibility_spawnattrs_setdisclaim)
+*responsibility_spawnattrs_setdisclaim_ptr;
+static dispatch_once_t pred;

[Lldb-commits] [lldb] 041c7b8 - [lldb/Host] Upstream macOS TCC code

2020-08-04 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-08-04T09:23:54-07:00
New Revision: 041c7b84a4b925476d1e21ed302786033bb6035f

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

LOG: [lldb/Host] Upstream macOS TCC code

Upstream the code for dealing with TCC introduced in macOS Mojave. This
will make the debuggee instead of the debugger responsible for the
privileges it needs.

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

Added: 
lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h

Modified: 
lldb/source/Host/macosx/objcxx/Host.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index 1635132a154e..398652ae30d8 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "lldb/Host/Host.h"
+#include "PosixSpawnResponsible.h"
 
 #include 
 #include 
@@ -1083,6 +1084,29 @@ static Status LaunchProcessPosixSpawn(const char 
*exe_path,
 return error;
   }
 
+  bool is_graphical = true;
+
+#if TARGET_OS_OSX
+  SecuritySessionId session_id;
+  SessionAttributeBits session_attributes;
+  OSStatus status =
+  SessionGetInfo(callerSecuritySession, _id, _attributes);
+  if (status == errSessionSuccess)
+is_graphical = session_attributes & sessionHasGraphicAccess;
+#endif
+
+  //  When lldb is ran through a graphical session, this makes the debuggee
+  //  process responsible for the TCC prompts. Otherwise, lldb will use the
+  //  launching process privileges.
+  if (is_graphical && launch_info.GetFlags().Test(eLaunchFlagDebug)) {
+error.SetError(setup_posix_spawn_responsible_flag(), eErrorTypePOSIX);
+if (error.Fail()) {
+  LLDB_LOG(log, "error: {0}, setup_posix_spawn_responsible_flag()",
+   error);
+  return error;
+}
+  }
+
   const char *tmp_argv[2];
   char *const *argv = const_cast(
   launch_info.GetArguments().GetConstArgumentVector());

diff  --git a/lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h 
b/lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h
new file mode 100644
index ..36fe09b5263a
--- /dev/null
+++ b/lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h
@@ -0,0 +1,46 @@
+//===-- PosixSpawnResponsible.h -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_HOST_POSIXSPAWNRESPONSIBLE_H
+#define LLDB_HOST_POSIXSPAWNRESPONSIBLE_H
+
+#include 
+
+#if __has_include()
+#include 
+#include 
+#include 
+
+// Older SDKs  have responsibility.h but not this particular function. Let's
+// include the prototype here.
+errno_t responsibility_spawnattrs_setdisclaim(posix_spawnattr_t *attrs,
+  bool disclaim);
+
+#endif
+
+static inline int setup_posix_spawn_responsible_flag(posix_spawnattr_t *attr) {
+  if (@available(macOS 10.14, *)) {
+#if __has_include()
+static __typeof__(responsibility_spawnattrs_setdisclaim)
+*responsibility_spawnattrs_setdisclaim_ptr;
+static dispatch_once_t pred;
+dispatch_once(, ^{
+  responsibility_spawnattrs_setdisclaim_ptr =
+#ifdef __cplusplus
+  reinterpret_cast<__typeof__(_spawnattrs_setdisclaim)>
+#endif
+  (dlsym(RTLD_DEFAULT, "responsibility_spawnattrs_setdisclaim"));
+});
+if (responsibility_spawnattrs_setdisclaim_ptr)
+  return responsibility_spawnattrs_setdisclaim_ptr(attr, true);
+#endif
+  }
+  return 0;
+}
+
+#endif // LLDB_HOST_POSIXSPAWNRESPONSIBLE_H



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


[Lldb-commits] [PATCH] D85219: [lldb] fix building with panel.h being in /usr/include/ncurses/

2020-08-04 Thread Luboš Luňák via Phabricator via lldb-commits
llunak created this revision.
llunak added a reviewer: clayborg.
Herald added a subscriber: mgorny.
llunak requested review of this revision.

My openSUSE 15.2 has /usr/include/curses.h as a symlink to 
/usr/include/ncurses/curses.h , but there's no such symlink for panel.h . 
Prefer using /usr/include/ncurses for the includes if they are found there by 
the CMake check.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D85219

Files:
  lldb/include/lldb/Host/Config.h.cmake
  lldb/source/Core/IOHandlerCursesGUI.cpp


Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -10,9 +10,14 @@
 #include "lldb/Host/Config.h"
 
 #if LLDB_ENABLE_CURSES
+#if CURSES_HAVE_NCURSES_CURSES_H
+#include 
+#include 
+#else
 #include 
 #include 
 #endif
+#endif
 
 #if defined(__APPLE__)
 #include 
Index: lldb/include/lldb/Host/Config.h.cmake
===
--- lldb/include/lldb/Host/Config.h.cmake
+++ lldb/include/lldb/Host/Config.h.cmake
@@ -38,6 +38,8 @@
 
 #cmakedefine01 LLDB_ENABLE_CURSES
 
+#cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H
+
 #cmakedefine01 LLDB_ENABLE_LIBEDIT
 
 #cmakedefine01 LLDB_ENABLE_LIBXML2


Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -10,9 +10,14 @@
 #include "lldb/Host/Config.h"
 
 #if LLDB_ENABLE_CURSES
+#if CURSES_HAVE_NCURSES_CURSES_H
+#include 
+#include 
+#else
 #include 
 #include 
 #endif
+#endif
 
 #if defined(__APPLE__)
 #include 
Index: lldb/include/lldb/Host/Config.h.cmake
===
--- lldb/include/lldb/Host/Config.h.cmake
+++ lldb/include/lldb/Host/Config.h.cmake
@@ -38,6 +38,8 @@
 
 #cmakedefine01 LLDB_ENABLE_CURSES
 
+#cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H
+
 #cmakedefine01 LLDB_ENABLE_LIBEDIT
 
 #cmakedefine01 LLDB_ENABLE_LIBXML2
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85237: [lldb] Add an option to disable TCC

2020-08-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: mib, friss, jasonmolenda.
JDevlieghere added a project: LLDB.
JDevlieghere requested review of this revision.

Add an option to not present the TCC dialog on behalf of the inferior. The 
motivation is the scenario of running the LLDB test suite from an external hard 
drive. If the inferior is responsible, every test needs to be granted access to 
the external volume. If LLDB takes responsibility, approval needs to be granted 
only once.


https://reviews.llvm.org/D85237

Files:
  lldb/include/lldb/Target/Target.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetProperties.td
  lldb/test/Shell/lit-lldb-init.in

Index: lldb/test/Shell/lit-lldb-init.in
===
--- lldb/test/Shell/lit-lldb-init.in
+++ lldb/test/Shell/lit-lldb-init.in
@@ -4,3 +4,4 @@
 settings set interpreter.echo-comment-commands false
 settings set symbols.clang-modules-cache-path "@LLDB_TEST_MODULE_CACHE_LLDB@"
 settings set target.auto-apply-fixits false
+settings set target.disable-tcc true
Index: lldb/source/Target/TargetProperties.td
===
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -111,6 +111,9 @@
   def DisableSTDIO: Property<"disable-stdio", "Boolean">,
 DefaultFalse,
 Desc<"Disable stdin/stdout for process (e.g. for a GUI application)">;
+  def DisableTCC: Property<"disable-tcc", "Boolean">,
+DefaultFalse,
+Desc<"Disable making the inferior responsible for the TCC prompt.">;
   def InlineStrategy: Property<"inline-breakpoint-strategy", "Enum">,
 DefaultEnumValue<"eInlineBreakpointsAlways">,
 EnumValues<"OptionEnumValues(g_inline_breakpoint_enums)">,
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3430,6 +3430,8 @@
 });
 m_collection_sp->SetValueChangedCallback(
 ePropertyDisableASLR, [this] { DisableASLRValueChangedCallback(); });
+m_collection_sp->SetValueChangedCallback(
+ePropertyDisableTCC, [this] { DisableTCCValueChangedCallback(); });
 m_collection_sp->SetValueChangedCallback(
 ePropertyDisableSTDIO, [this] { DisableSTDIOValueChangedCallback(); });
 
@@ -3468,6 +3470,7 @@
   ErrorPathValueChangedCallback();
   DetachOnErrorValueChangedCallback();
   DisableASLRValueChangedCallback();
+  DisableTCCValueChangedCallback();
   DisableSTDIOValueChangedCallback();
 }
 
@@ -3550,6 +3553,17 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
 }
 
+bool TargetProperties::GetDisableTCC() const {
+  const uint32_t idx = ePropertyDisableTCC;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_target_properties[idx].default_uint_value != 0);
+}
+
+void TargetProperties::SetDisableTCC(bool b) {
+  const uint32_t idx = ePropertyDisableTCC;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+}
+
 bool TargetProperties::GetDetachOnError() const {
   const uint32_t idx = ePropertyDetachOnError;
   return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -3941,6 +3955,8 @@
   }
   SetDetachOnError(launch_info.GetFlags().Test(lldb::eLaunchFlagDetachOnError));
   SetDisableASLR(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableASLR));
+  SetDisableTCC(
+  launch_info.GetFlags().Test(lldb::eLaunchFlagDisableInferiorTCC));
   SetDisableSTDIO(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableSTDIO));
 }
 
@@ -4004,6 +4020,13 @@
 m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDisableASLR);
 }
 
+void TargetProperties::DisableTCCValueChangedCallback() {
+  if (GetDisableTCC())
+m_launch_info.GetFlags().Set(lldb::eLaunchFlagDisableInferiorTCC);
+  else
+m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDisableInferiorTCC);
+}
+
 void TargetProperties::DisableSTDIOValueChangedCallback() {
   if (GetDisableSTDIO())
 m_launch_info.GetFlags().Set(lldb::eLaunchFlagDisableSTDIO);
Index: lldb/source/Host/macosx/objcxx/Host.mm
===
--- lldb/source/Host/macosx/objcxx/Host.mm
+++ lldb/source/Host/macosx/objcxx/Host.mm
@@ -1098,7 +1098,8 @@
   //  When lldb is ran through a graphical session, this makes the debuggee
   //  process responsible for the TCC prompts. Otherwise, lldb will use the
   //  launching process privileges.
-  if (is_graphical && launch_info.GetFlags().Test(eLaunchFlagDebug)) {
+  if (is_graphical && launch_info.GetFlags().Test(eLaunchFlagDebug) &&
+  !launch_info.GetFlags().Test(eLaunchFlagDisableInferiorTCC)) {
 error.SetError(setup_posix_spawn_responsible_flag(), eErrorTypePOSIX);
 

Re: [Lldb-commits] [lldb] a06c28d - Temporarily revert "[test] Exit with an error if no tests are run."

2020-08-04 Thread Jordan Rupprecht via lldb-commits
Thanks, that explains it! Namely this part:

if sys.platform.startswith('win32'):
# llvm.org/pr22274: need a pexpect replacement for windows
class PExpectTest(object):
pass
else:
import pexpect
class PExpectTest(TestBase):

For this change to reland, I'll need to make it always inherit from
TestBase, but suppressed in some other way (maybe seeing if decorators
like @skipIfWindows can be applied to whole test classes)


On Mon, Aug 3, 2020 at 11:40 PM Raphael “Teemperor” Isemann <
teempe...@gmail.com> wrote:

> If it helps, all the failing tests are pexpect tests which are always
> disabled on Windows (like, they don't even exist from the test runners POV
> I believe). So I guess that's accidentially triggering that error.
>
> - Raphael
>
> > On 4 Aug 2020, at 03:39, Jordan Rupprecht via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
> >
> >
> > Author: Jordan Rupprecht
> > Date: 2020-08-03T18:37:50-07:00
> > New Revision: a06c28df3e8c85ceb665d3d9a1ebc2853dfd87a9
> >
> > URL:
> https://github.com/llvm/llvm-project/commit/a06c28df3e8c85ceb665d3d9a1ebc2853dfd87a9
> > DIFF:
> https://github.com/llvm/llvm-project/commit/a06c28df3e8c85ceb665d3d9a1ebc2853dfd87a9.diff
> >
> > LOG: Temporarily revert "[test] Exit with an error if no tests are run."
> >
> > This reverts commit adb5c23f8c0d60eeec41dcbe21d1b26184e1c97d. It
> surprisingly fails on a windows build bot:
> http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/18009
> >
> > Will reland after some investigation and/or after adding some extra
> logging to help debug the issue.
> >
> > Added:
> >
> >
> > Modified:
> >lldb/packages/Python/lldbsuite/test/dotest.py
> >
> > Removed:
> >
> >
> >
> >
> 
> > diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py
> b/lldb/packages/Python/lldbsuite/test/dotest.py
> > index 6607f52c49db..3fb802f1c1aa 100644
> > --- a/lldb/packages/Python/lldbsuite/test/dotest.py
> > +++ b/lldb/packages/Python/lldbsuite/test/dotest.py
> > @@ -1039,10 +1039,6 @@ def run_suite():
> > (configuration.suite.countTestCases(),
> >  configuration.suite.countTestCases() != 1 and "s" or ""))
> >
> > -if configuration.suite.countTestCases() == 0:
> > -logging.error("did not discover any matching tests")
> > -exitTestSuite(1)
> > -
> > # Invoke the test runner.
> > if configuration.count == 1:
> > result = unittest2.TextTestRunner(
> >
> >
> >
> > ___
> > lldb-commits mailing list
> > lldb-commits@lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
>


smime.p7s
Description: S/MIME Cryptographic Signature
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D62732: [RISCV] Add SystemV ABI

2020-08-04 Thread Simon Cook via Phabricator via lldb-commits
simoncook added a comment.
Herald added a subscriber: JDevlieghere.

Thanks for looking at this @luismarques We had planned to put more effort into 
this patch, but time got in the way for quite a lot, but I'm glad it's working; 
thanks for the rebase I'll update this to match shortly. And it's good that it 
looks like it's mostly working. I'm curious about your backtrace showing one 
frame, is that something without debug information, since the example I was 
using when writing this did show a backtrace back to main? It would be good to 
understand why that disn't produce the expected output.

As for next steps, if we're happy with the state then I think this should land 
(assuming qemu is sufficient given it is public), and then we can flesh out 
other bits which give a better experience. I'm not sure how to connect this to 
any automated testing, or where to document any way of checking this manually, 
the state of that isn't quite clear, so any clarity there helps.

Beyond this I think the next stage is implementing the parts for calling 
functions within a target, which if you could help with that would be great. I 
see that as a follow up patch to this, I don't see the two necessarily having 
to land together, since this part enables a useful debugging experience already.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62732

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


[Lldb-commits] [lldb] 31ec6e9 - [test] Fix another realpath->abspath.

2020-08-04 Thread Jordan Rupprecht via lldb-commits

Author: Jordan Rupprecht
Date: 2020-08-04T11:06:31-07:00
New Revision: 31ec6e969d601eb4fbee7bd4be3d03d23b5b3c11

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

LOG: [test] Fix another realpath->abspath.

This is a followup to 817b3a6fe3a4452eb61a2503c8beaa7267ca0351: in 
`builder_base` we should use abspath, not realpath, because the name is 
significant.
This is used by test cases that use `@skipIf(compiler="clang", 
compiler_version=['<', ])`

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/plugins/builder_base.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/plugins/builder_base.py 
b/lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
index a8114b3e0592..0cff6655ed77 100644
--- a/lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ b/lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -34,7 +34,7 @@ def getCompiler():
 """Returns the compiler in effect the test suite is running with."""
 compiler = configuration.compiler if configuration.compiler else "clang"
 compiler = lldbutil.which(compiler)
-return os.path.realpath(compiler)
+return os.path.abspath(compiler)
 
 
 def getArchFlag():



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


[Lldb-commits] [PATCH] D85217: [lldb] Upstream macOS TCC code

2020-08-04 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib accepted this revision.
mib added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D85217

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


[Lldb-commits] [PATCH] D85235: [lldb] Make SBTarget::LaunchSimple start form the target's LaunchInfo

2020-08-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 282990.
JDevlieghere added a comment.

Add test


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

https://reviews.llvm.org/D85235

Files:
  lldb/source/API/SBTarget.cpp
  lldb/test/API/python_api/target/TestTargetAPI.py


Index: lldb/test/API/python_api/target/TestTargetAPI.py
===
--- lldb/test/API/python_api/target/TestTargetAPI.py
+++ lldb/test/API/python_api/target/TestTargetAPI.py
@@ -150,6 +150,20 @@
 self.assertTrue(error.Success(), "Make sure memory read succeeded")
 self.assertEqual(len(content), 1)
 
+
+@add_test_categories(['pyapi'])
+def test_launch_simple(self):
+d = {'EXE': 'b.out'}
+self.build(dictionary=d)
+self.setTearDownCleanup(dictionary=d)
+target = self.create_simple_target('b.out')
+self.runCmd("settings set target.disable-stdio true")
+process = target.LaunchSimple(
+None, None, self.get_process_working_directory())
+self.runCmd("run")
+output = process.GetSTDOUT(1000)
+self.assertEqual(output, "")
+
 def create_simple_target(self, fn):
 exe = self.getBuildArtifact(fn)
 target = self.dbg.CreateTarget(exe)
Index: lldb/source/API/SBTarget.cpp
===
--- lldb/source/API/SBTarget.cpp
+++ lldb/source/API/SBTarget.cpp
@@ -287,16 +287,24 @@
  (const char **, const char **, const char *), argv, envp,
  working_directory);
 
-  char *stdin_path = nullptr;
-  char *stdout_path = nullptr;
-  char *stderr_path = nullptr;
-  uint32_t launch_flags = 0;
-  bool stop_at_entry = false;
+  TargetSP target_sp = GetSP();
+  if (!target_sp)
+return LLDB_RECORD_RESULT(SBProcess());
+
+  SBLaunchInfo launch_info = GetLaunchInfo();
+
+  if (Module *exe_module = target_sp->GetExecutableModulePointer())
+launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(),
+  /*add_as_first_arg*/ true);
+  if (argv)
+launch_info.SetArguments(argv, /*append*/ true);
+  if (envp)
+launch_info.SetEnvironmentEntries(envp, /*append*/ false);
+  if (working_directory)
+launch_info.SetWorkingDirectory(working_directory);
+
   SBError error;
-  SBListener listener = GetDebugger().GetListener();
-  return LLDB_RECORD_RESULT(Launch(listener, argv, envp, stdin_path,
-   stdout_path, stderr_path, working_directory,
-   launch_flags, stop_at_entry, error));
+  return LLDB_RECORD_RESULT(Launch(launch_info, error));
 }
 
 SBError SBTarget::Install() {


Index: lldb/test/API/python_api/target/TestTargetAPI.py
===
--- lldb/test/API/python_api/target/TestTargetAPI.py
+++ lldb/test/API/python_api/target/TestTargetAPI.py
@@ -150,6 +150,20 @@
 self.assertTrue(error.Success(), "Make sure memory read succeeded")
 self.assertEqual(len(content), 1)
 
+
+@add_test_categories(['pyapi'])
+def test_launch_simple(self):
+d = {'EXE': 'b.out'}
+self.build(dictionary=d)
+self.setTearDownCleanup(dictionary=d)
+target = self.create_simple_target('b.out')
+self.runCmd("settings set target.disable-stdio true")
+process = target.LaunchSimple(
+None, None, self.get_process_working_directory())
+self.runCmd("run")
+output = process.GetSTDOUT(1000)
+self.assertEqual(output, "")
+
 def create_simple_target(self, fn):
 exe = self.getBuildArtifact(fn)
 target = self.dbg.CreateTarget(exe)
Index: lldb/source/API/SBTarget.cpp
===
--- lldb/source/API/SBTarget.cpp
+++ lldb/source/API/SBTarget.cpp
@@ -287,16 +287,24 @@
  (const char **, const char **, const char *), argv, envp,
  working_directory);
 
-  char *stdin_path = nullptr;
-  char *stdout_path = nullptr;
-  char *stderr_path = nullptr;
-  uint32_t launch_flags = 0;
-  bool stop_at_entry = false;
+  TargetSP target_sp = GetSP();
+  if (!target_sp)
+return LLDB_RECORD_RESULT(SBProcess());
+
+  SBLaunchInfo launch_info = GetLaunchInfo();
+
+  if (Module *exe_module = target_sp->GetExecutableModulePointer())
+launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(),
+  /*add_as_first_arg*/ true);
+  if (argv)
+launch_info.SetArguments(argv, /*append*/ true);
+  if (envp)
+launch_info.SetEnvironmentEntries(envp, /*append*/ false);
+  if (working_directory)
+launch_info.SetWorkingDirectory(working_directory);
+
   SBError error;
-  SBListener listener = GetDebugger().GetListener();
-  return LLDB_RECORD_RESULT(Launch(listener, argv, envp, stdin_path,
-   stdout_path, 

[Lldb-commits] [PATCH] D85235: [lldb] Make SBTarget::LaunchSimple start form the target's LaunchInfo

2020-08-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: jingham.
JDevlieghere added a project: LLDB.
JDevlieghere requested review of this revision.

Currently `SBTarget::LaunchSimple` creates a new `LaunchInfo` which means it 
ignores any target properties that have been set. Instead, it should start from 
the target's `LaunchInfo` and populated the specified fields.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D85235

Files:
  lldb/source/API/SBTarget.cpp


Index: lldb/source/API/SBTarget.cpp
===
--- lldb/source/API/SBTarget.cpp
+++ lldb/source/API/SBTarget.cpp
@@ -287,16 +287,24 @@
  (const char **, const char **, const char *), argv, envp,
  working_directory);
 
-  char *stdin_path = nullptr;
-  char *stdout_path = nullptr;
-  char *stderr_path = nullptr;
-  uint32_t launch_flags = 0;
-  bool stop_at_entry = false;
+  TargetSP target_sp = GetSP();
+  if (!target_sp)
+return LLDB_RECORD_RESULT(SBProcess());
+
+  SBLaunchInfo launch_info = GetLaunchInfo();
+
+  if (Module *exe_module = target_sp->GetExecutableModulePointer())
+launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(),
+  /*add_as_first_arg*/ true);
+  if (argv)
+launch_info.SetArguments(argv, /*append*/ true);
+  if (envp)
+launch_info.SetEnvironmentEntries(envp, /*append*/ false);
+  if (working_directory)
+launch_info.SetWorkingDirectory(working_directory);
+
   SBError error;
-  SBListener listener = GetDebugger().GetListener();
-  return LLDB_RECORD_RESULT(Launch(listener, argv, envp, stdin_path,
-   stdout_path, stderr_path, working_directory,
-   launch_flags, stop_at_entry, error));
+  return LLDB_RECORD_RESULT(Launch(launch_info, error));
 }
 
 SBError SBTarget::Install() {


Index: lldb/source/API/SBTarget.cpp
===
--- lldb/source/API/SBTarget.cpp
+++ lldb/source/API/SBTarget.cpp
@@ -287,16 +287,24 @@
  (const char **, const char **, const char *), argv, envp,
  working_directory);
 
-  char *stdin_path = nullptr;
-  char *stdout_path = nullptr;
-  char *stderr_path = nullptr;
-  uint32_t launch_flags = 0;
-  bool stop_at_entry = false;
+  TargetSP target_sp = GetSP();
+  if (!target_sp)
+return LLDB_RECORD_RESULT(SBProcess());
+
+  SBLaunchInfo launch_info = GetLaunchInfo();
+
+  if (Module *exe_module = target_sp->GetExecutableModulePointer())
+launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(),
+  /*add_as_first_arg*/ true);
+  if (argv)
+launch_info.SetArguments(argv, /*append*/ true);
+  if (envp)
+launch_info.SetEnvironmentEntries(envp, /*append*/ false);
+  if (working_directory)
+launch_info.SetWorkingDirectory(working_directory);
+
   SBError error;
-  SBListener listener = GetDebugger().GetListener();
-  return LLDB_RECORD_RESULT(Launch(listener, argv, envp, stdin_path,
-   stdout_path, stderr_path, working_directory,
-   launch_flags, stop_at_entry, error));
+  return LLDB_RECORD_RESULT(Launch(launch_info, error));
 }
 
 SBError SBTarget::Install() {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85217: [lldb] Upstream macOS TCC code

2020-08-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG041c7b84a4b9: [lldb/Host] Upstream macOS TCC code (authored 
by JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D85217?vs=282939=282943#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85217

Files:
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h


Index: lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h
===
--- /dev/null
+++ lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h
@@ -0,0 +1,46 @@
+//===-- PosixSpawnResponsible.h -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_HOST_POSIXSPAWNRESPONSIBLE_H
+#define LLDB_HOST_POSIXSPAWNRESPONSIBLE_H
+
+#include 
+
+#if __has_include()
+#include 
+#include 
+#include 
+
+// Older SDKs  have responsibility.h but not this particular function. Let's
+// include the prototype here.
+errno_t responsibility_spawnattrs_setdisclaim(posix_spawnattr_t *attrs,
+  bool disclaim);
+
+#endif
+
+static inline int setup_posix_spawn_responsible_flag(posix_spawnattr_t *attr) {
+  if (@available(macOS 10.14, *)) {
+#if __has_include()
+static __typeof__(responsibility_spawnattrs_setdisclaim)
+*responsibility_spawnattrs_setdisclaim_ptr;
+static dispatch_once_t pred;
+dispatch_once(, ^{
+  responsibility_spawnattrs_setdisclaim_ptr =
+#ifdef __cplusplus
+  reinterpret_cast<__typeof__(_spawnattrs_setdisclaim)>
+#endif
+  (dlsym(RTLD_DEFAULT, "responsibility_spawnattrs_setdisclaim"));
+});
+if (responsibility_spawnattrs_setdisclaim_ptr)
+  return responsibility_spawnattrs_setdisclaim_ptr(attr, true);
+#endif
+  }
+  return 0;
+}
+
+#endif // LLDB_HOST_POSIXSPAWNRESPONSIBLE_H
Index: lldb/source/Host/macosx/objcxx/Host.mm
===
--- lldb/source/Host/macosx/objcxx/Host.mm
+++ lldb/source/Host/macosx/objcxx/Host.mm
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "lldb/Host/Host.h"
+#include "PosixSpawnResponsible.h"
 
 #include 
 #include 
@@ -1083,6 +1084,29 @@
 return error;
   }
 
+  bool is_graphical = true;
+
+#if TARGET_OS_OSX
+  SecuritySessionId session_id;
+  SessionAttributeBits session_attributes;
+  OSStatus status =
+  SessionGetInfo(callerSecuritySession, _id, _attributes);
+  if (status == errSessionSuccess)
+is_graphical = session_attributes & sessionHasGraphicAccess;
+#endif
+
+  //  When lldb is ran through a graphical session, this makes the debuggee
+  //  process responsible for the TCC prompts. Otherwise, lldb will use the
+  //  launching process privileges.
+  if (is_graphical && launch_info.GetFlags().Test(eLaunchFlagDebug)) {
+error.SetError(setup_posix_spawn_responsible_flag(), eErrorTypePOSIX);
+if (error.Fail()) {
+  LLDB_LOG(log, "error: {0}, setup_posix_spawn_responsible_flag()",
+   error);
+  return error;
+}
+  }
+
   const char *tmp_argv[2];
   char *const *argv = const_cast(
   launch_info.GetArguments().GetConstArgumentVector());


Index: lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h
===
--- /dev/null
+++ lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h
@@ -0,0 +1,46 @@
+//===-- PosixSpawnResponsible.h -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_HOST_POSIXSPAWNRESPONSIBLE_H
+#define LLDB_HOST_POSIXSPAWNRESPONSIBLE_H
+
+#include 
+
+#if __has_include()
+#include 
+#include 
+#include 
+
+// Older SDKs  have responsibility.h but not this particular function. Let's
+// include the prototype here.
+errno_t responsibility_spawnattrs_setdisclaim(posix_spawnattr_t *attrs,
+  bool disclaim);
+
+#endif
+
+static inline int setup_posix_spawn_responsible_flag(posix_spawnattr_t *attr) {
+  if (@available(macOS 10.14, *)) {
+#if __has_include()
+static __typeof__(responsibility_spawnattrs_setdisclaim)
+*responsibility_spawnattrs_setdisclaim_ptr;
+static dispatch_once_t pred;
+dispatch_once(, ^{
+  

[Lldb-commits] [PATCH] D85145: Use syntax highlighting also in gui mode

2020-08-04 Thread Luboš Luňák via Phabricator via lldb-commits
llunak updated this revision to Diff 282865.
llunak added a comment.

Updated according to comments.

I find some of the StringRef APIs flawed though: consume_front() returns true 
on success, but consumeInteger() returns false; consume_front() modifies the 
object, but drop_front() doesn't.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D85145

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp

Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -391,11 +391,11 @@
 ::wbkgd(m_window, COLOR_PAIR(color_pair_idx));
   }
 
-  void PutCStringTruncated(int right_pad, const char *s) {
+  void PutCStringTruncated(int right_pad, const char *s, int len = -1) {
 int bytes_left = GetWidth() - GetCursorX();
 if (bytes_left > right_pad) {
   bytes_left -= right_pad;
-  ::waddnstr(m_window, s, bytes_left);
+  ::waddnstr(m_window, s, len < 0 ? bytes_left : std::min(bytes_left, len));
 }
   }
 
@@ -455,6 +455,62 @@
 return std::min(length, std::max(0, GetWidth() - GetCursorX() - 1));
   }
 
+  // Curses doesn't allow direct output of color escape sequences, but that's
+  // how we get source lines from the Highligher class. Read the line and
+  // convert color escape sequences to curses color attributes.
+  void OutputColoredStringTruncated(int right_pad, StringRef string,
+bool use_blue_background) {
+attr_t saved_attr;
+short saved_pair;
+int saved_opts;
+::wattr_get(m_window, _attr, _pair, _opts);
+if (use_blue_background)
+  ::wattron(m_window, COLOR_PAIR(16));
+while (!string.empty()) {
+  size_t esc_pos = string.find('\x1b');
+  if (esc_pos == StringRef::npos) {
+PutCStringTruncated(right_pad, string.data(), string.size());
+break;
+  }
+  if (esc_pos > 0) {
+PutCStringTruncated(right_pad, string.data(), esc_pos);
+string = string.drop_front(esc_pos);
+  }
+  bool consumed = string.consume_front("\x1b");
+  assert(consumed);
+  UNUSED_IF_ASSERT_DISABLED(consumed);
+  // This is written to match our Highlighter classes, which seem to
+  // generate only foreground color escape sequences. If necessary, this
+  // will need to be extended.
+  if (!string.consume_front("[")) {
+llvm::errs() << "Missing '[' in color escape sequence.\n";
+continue;
+  }
+  // Only 8 basic foreground colors and reset, our Highlighter doesn't use
+  // anything else.
+  int value;
+  if (!!string.consumeInteger(10, value) || // Returns false on success.
+  !(value == 0 || (value >= 30 && value <= 37))) {
+llvm::errs() << "No valid color code in color escape sequence.\n";
+continue;
+  }
+  if (!string.consume_front("m")) {
+llvm::errs() << "Missing 'm' in color escape sequence.\n";
+continue;
+  }
+  if (value == 0) { // Reset.
+::wattr_set(m_window, saved_attr, saved_pair, _opts);
+if (use_blue_background)
+  ::wattron(m_window, COLOR_PAIR(16));
+  } else {
+// Mapped directly to first 16 color pairs (black/blue background).
+::wattron(m_window,
+  COLOR_PAIR(value - 30 + 1 + (use_blue_background ? 8 : 0)));
+  }
+}
+::wattr_set(m_window, saved_attr, saved_pair, _opts);
+  }
+
   void Touch() {
 ::touchwin(m_window);
 if (m_parent)
@@ -543,7 +599,7 @@
   void DrawTitleBox(const char *title, const char *bottom_message = nullptr) {
 attr_t attr = 0;
 if (IsActive())
-  attr = A_BOLD | COLOR_PAIR(2);
+  attr = A_BOLD | COLOR_PAIR(18);
 else
   attr = 0;
 if (attr)
@@ -977,14 +1033,14 @@
 
 if (m_key_name.empty()) {
   if (!underlined_shortcut && llvm::isPrint(m_key_value)) {
-window.AttributeOn(COLOR_PAIR(3));
+window.AttributeOn(COLOR_PAIR(19));
 window.Printf(" (%c)", m_key_value);
-window.AttributeOff(COLOR_PAIR(3));
+window.AttributeOff(COLOR_PAIR(19));
   }
 } else {
-  window.AttributeOn(COLOR_PAIR(3));
+  window.AttributeOn(COLOR_PAIR(19));
   window.Printf(" (%s)", m_key_name.c_str());
-  window.AttributeOff(COLOR_PAIR(3));
+  window.AttributeOff(COLOR_PAIR(19));
 }
   }
 }
@@ -996,7 +1052,7 @@
   Menu::Type menu_type = GetType();
   switch (menu_type) {
   case Menu::Type::Bar: {
-window.SetBackground(2);
+window.SetBackground(18);
 window.MoveCursor(0, 0);
 for (size_t i = 0; i < num_submenus; ++i) {
   Menu *menu = submenus[i].get();
@@ -1016,7 +1072,7 @@
 int cursor_x = 0;
 int cursor_y = 0;
 window.Erase();
-window.SetBackground(2);
+window.SetBackground(18);
 window.Box();
 for (size_t i = 0; i < num_submenus;