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

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

I personally don't particularly care where the tests are, I just wanted all the 
gui tests to be together to make it simpler to run them all.


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] c952ec1 - [lldb] fix building with panel.h being in /usr/include/ncurses/

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

Author: Luboš Luňák
Date: 2020-08-05T09:51:12+02:00
New Revision: c952ec15d38843b69e22dfd7b0665304a0459f9f

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

LOG: [lldb] fix building with panel.h being in /usr/include/ncurses/

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.

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

Added: 


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

Removed: 




diff  --git a/lldb/include/lldb/Host/Config.h.cmake 
b/lldb/include/lldb/Host/Config.h.cmake
index 42f4ca1a26c6..7467f429b628 100644
--- a/lldb/include/lldb/Host/Config.h.cmake
+++ b/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

diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp 
b/lldb/source/Core/IOHandlerCursesGUI.cpp
index 144b2112183c..55c80e778060 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/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 



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


[Lldb-commits] [lldb] 7a63dc5 - [lldb][gui] implement shift+tab for going back in views

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

Author: Luboš Luňák
Date: 2020-08-05T09:51:12+02:00
New Revision: 7a63dc534eb8ebdf1b0aa2c0f6d943d0c7adda1d

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

LOG: [lldb][gui] implement shift+tab for going back in views

Also simplify the code for going forward.

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

Added: 


Modified: 
lldb/source/Core/IOHandlerCursesGUI.cpp

Removed: 




diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp 
b/lldb/source/Core/IOHandlerCursesGUI.cpp
index ea4dfd12ada4..2e991dc37be8 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -692,42 +692,44 @@ class Window {
 
   void SelectNextWindowAsActive() {
 // Move active focus to next window
-const size_t num_subwindows = m_subwindows.size();
-if (m_curr_active_window_idx == UINT32_MAX) {
-  uint32_t idx = 0;
-  for (auto subwindow_sp : m_subwindows) {
-if (subwindow_sp->GetCanBeActive()) {
-  m_curr_active_window_idx = idx;
-  break;
-}
-++idx;
-  }
-} else if (m_curr_active_window_idx + 1 < num_subwindows) {
-  bool handled = false;
+const int num_subwindows = m_subwindows.size();
+int start_idx = 0;
+if (m_curr_active_window_idx != UINT32_MAX) {
   m_prev_active_window_idx = m_curr_active_window_idx;
-  for (size_t idx = m_curr_active_window_idx + 1; idx < num_subwindows;
-   ++idx) {
-if (m_subwindows[idx]->GetCanBeActive()) {
-  m_curr_active_window_idx = idx;
-  handled = true;
-  break;
-}
+  start_idx = m_curr_active_window_idx + 1;
+}
+for (int idx = start_idx; idx < num_subwindows; ++idx) {
+  if (m_subwindows[idx]->GetCanBeActive()) {
+m_curr_active_window_idx = idx;
+return;
   }
-  if (!handled) {
-for (size_t idx = 0; idx <= m_prev_active_window_idx; ++idx) {
-  if (m_subwindows[idx]->GetCanBeActive()) {
-m_curr_active_window_idx = idx;
-break;
-  }
-}
+}
+for (int idx = 0; idx < start_idx; ++idx) {
+  if (m_subwindows[idx]->GetCanBeActive()) {
+m_curr_active_window_idx = idx;
+break;
   }
-} else {
+}
+  }
+
+  void SelectPreviousWindowAsActive() {
+// Move active focus to previous window
+const int num_subwindows = m_subwindows.size();
+int start_idx = num_subwindows - 1;
+if (m_curr_active_window_idx != UINT32_MAX) {
   m_prev_active_window_idx = m_curr_active_window_idx;
-  for (size_t idx = 0; idx < num_subwindows; ++idx) {
-if (m_subwindows[idx]->GetCanBeActive()) {
-  m_curr_active_window_idx = idx;
-  break;
-}
+  start_idx = m_curr_active_window_idx - 1;
+}
+for (int idx = start_idx; idx >= 0; --idx) {
+  if (m_subwindows[idx]->GetCanBeActive()) {
+m_curr_active_window_idx = idx;
+return;
+  }
+}
+for (int idx = num_subwindows - 1; idx > start_idx; --idx) {
+  if (m_subwindows[idx]->GetCanBeActive()) {
+m_curr_active_window_idx = idx;
+break;
   }
 }
   }
@@ -2928,6 +2930,10 @@ class ApplicationDelegate : public WindowDelegate, 
public MenuDelegate {
   window.SelectNextWindowAsActive();
   return eKeyHandled;
 
+case KEY_BTAB:
+  window.SelectPreviousWindowAsActive();
+  return eKeyHandled;
+
 case 'h':
   window.CreateHelpSubwindow();
   return eKeyHandled;
@@ -2952,6 +2958,7 @@ class ApplicationDelegate : public WindowDelegate, public 
MenuDelegate {
   KeyHelp *WindowDelegateGetKeyHelp() override {
 static curses::KeyHelp g_source_view_key_help[] = {
 {'\t', "Select next view"},
+{KEY_BTAB, "Select previous view"},
 {'h', "Show help dialog with view specific key bindings"},
 {',', "Page up"},
 {'.', "Page down"},



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


[Lldb-commits] [PATCH] D85098: Implement breakpoint removal on breakpoint toggling in lldb gui

2020-08-05 Thread Luboš Luňák via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd6868d9ca1db: [lldb][gui] implement breakpoint removal on 
breakpoint toggling (authored by llunak).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85098

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp

Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -3837,37 +3837,7 @@
   return eKeyHandled;
 
 case 'b': // 'b' == toggle breakpoint on currently selected line
-  if (m_selected_line < GetNumSourceLines()) {
-ExecutionContext exe_ctx =
-m_debugger.GetCommandInterpreter().GetExecutionContext();
-if (exe_ctx.HasTargetScope()) {
-  BreakpointSP bp_sp = exe_ctx.GetTargetRef().CreateBreakpoint(
-  nullptr, // Don't limit the breakpoint to certain modules
-  m_file_sp->GetFileSpec(), // Source file
-  m_selected_line +
-  1, // Source line number (m_selected_line is zero based)
-  0, // No column specified.
-  0, // No offset
-  eLazyBoolCalculate,  // Check inlines using global setting
-  eLazyBoolCalculate,  // Skip prologue using global setting,
-  false,   // internal
-  false,   // request_hardware
-  eLazyBoolCalculate); // move_to_nearest_code
-}
-  } else if (m_selected_line < GetNumDisassemblyLines()) {
-const Instruction *inst = m_disassembly_sp->GetInstructionList()
-  .GetInstructionAtIndex(m_selected_line)
-  .get();
-ExecutionContext exe_ctx =
-m_debugger.GetCommandInterpreter().GetExecutionContext();
-if (exe_ctx.HasTargetScope()) {
-  Address addr = inst->GetAddress();
-  BreakpointSP bp_sp = exe_ctx.GetTargetRef().CreateBreakpoint(
-  addr,   // lldb_private::Address
-  false,  // internal
-  false); // request_hardware
-}
-  }
+  ToggleBreakpointOnSelectedLine();
   return eKeyHandled;
 
 case 'D': // 'D' == detach and keep stopped
@@ -3957,6 +3927,85 @@
 return eKeyNotHandled;
   }
 
+  void ToggleBreakpointOnSelectedLine() {
+ExecutionContext exe_ctx =
+m_debugger.GetCommandInterpreter().GetExecutionContext();
+if (!exe_ctx.HasTargetScope())
+  return;
+if (GetNumSourceLines() > 0) {
+  // Source file breakpoint.
+  BreakpointList &bp_list = exe_ctx.GetTargetRef().GetBreakpointList();
+  const size_t num_bps = bp_list.GetSize();
+  for (size_t bp_idx = 0; bp_idx < num_bps; ++bp_idx) {
+BreakpointSP bp_sp = bp_list.GetBreakpointAtIndex(bp_idx);
+const size_t num_bps_locs = bp_sp->GetNumLocations();
+for (size_t bp_loc_idx = 0; bp_loc_idx < num_bps_locs; ++bp_loc_idx) {
+  BreakpointLocationSP bp_loc_sp =
+  bp_sp->GetLocationAtIndex(bp_loc_idx);
+  LineEntry bp_loc_line_entry;
+  if (bp_loc_sp->GetAddress().CalculateSymbolContextLineEntry(
+  bp_loc_line_entry)) {
+if (m_file_sp->GetFileSpec() == bp_loc_line_entry.file &&
+m_selected_line + 1 == bp_loc_line_entry.line) {
+  bool removed =
+  exe_ctx.GetTargetRef().RemoveBreakpointByID(bp_sp->GetID());
+  assert(removed);
+  UNUSED_IF_ASSERT_DISABLED(removed);
+  return; // Existing breakpoint removed.
+}
+  }
+}
+  }
+  // No breakpoint found on the location, add it.
+  BreakpointSP bp_sp = exe_ctx.GetTargetRef().CreateBreakpoint(
+  nullptr, // Don't limit the breakpoint to certain modules
+  m_file_sp->GetFileSpec(), // Source file
+  m_selected_line +
+  1, // Source line number (m_selected_line is zero based)
+  0, // No column specified.
+  0, // No offset
+  eLazyBoolCalculate,  // Check inlines using global setting
+  eLazyBoolCalculate,  // Skip prologue using global setting,
+  false,   // internal
+  false,   // request_hardware
+  eLazyBoolCalculate); // move_to_nearest_code
+} else {
+  // Disassembly breakpoint.
+  assert(GetNumDisassemblyLines() > 0);
+  assert(m_selected_line < GetNumDisassemblyLines());
+  const Instruction *inst = m_disassembly_sp->GetInstructionList()
+.GetInstructionAtIndex(m_selected_line)
+.get();
+  Address addr = inst->GetAddress();
+  // Try to find it.
+  BreakpointLis

[Lldb-commits] [lldb] c7be982 - [lldb][gui] move TestGuiBasicDebug.py to lldb/test and update it

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

Author: Luboš Luňák
Date: 2020-08-05T09:51:13+02:00
New Revision: c7be982c836cdaf7b1ef303d903e6a3de2eb4a34

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

LOG: [lldb][gui] move TestGuiBasicDebug.py to lldb/test and update it

Between the time it was created and it was pushed upstream,
99451b4453688a94c6014cac233d371ab4cc342d has moved the existing
gui gui tests to lldb/test, so move this one too.
And update it to contain TestGuiBasic.py changes since the time
when it was based on that test.

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

Added: 
lldb/test/API/commands/gui/basicdebug/Makefile
lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
lldb/test/API/commands/gui/basicdebug/func.c
lldb/test/API/commands/gui/basicdebug/main.c

Modified: 


Removed: 
lldb/packages/Python/lldbsuite/test/commands/gui/basicdebug/Makefile

lldb/packages/Python/lldbsuite/test/commands/gui/basicdebug/TestGuiBasicDebug.py
lldb/packages/Python/lldbsuite/test/commands/gui/basicdebug/func.c
lldb/packages/Python/lldbsuite/test/commands/gui/basicdebug/main.c



diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/gui/basicdebug/Makefile 
b/lldb/test/API/commands/gui/basicdebug/Makefile
similarity index 100%
rename from lldb/packages/Python/lldbsuite/test/commands/gui/basicdebug/Makefile
rename to lldb/test/API/commands/gui/basicdebug/Makefile

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/gui/basicdebug/TestGuiBasicDebug.py
 b/lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
similarity index 83%
rename from 
lldb/packages/Python/lldbsuite/test/commands/gui/basicdebug/TestGuiBasicDebug.py
rename to lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
index 54c763fd2afc..76d9d3bdc463 100644
--- 
a/lldb/packages/Python/lldbsuite/test/commands/gui/basicdebug/TestGuiBasicDebug.py
+++ b/lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
@@ -11,7 +11,11 @@ class TestGuiBasicDebugCommandTest(PExpectTest):
 
 mydir = TestBase.compute_mydir(__file__)
 
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
 @skipIfCursesSupportMissing
+@skipIfRemote # "run" command will not work correctly for remote debug
 def test_gui(self):
 self.build()
 
@@ -39,4 +43,8 @@ def test_gui(self):
 self.child.send("n") # step over
 self.child.expect("return 0;[^\r\n]+<<< Thread 1: step over")
 
+# Press escape to quit the gui
+self.child.send(escape_key)
+
+self.expect_prompt()
 self.quit()

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/gui/basicdebug/func.c 
b/lldb/test/API/commands/gui/basicdebug/func.c
similarity index 100%
rename from lldb/packages/Python/lldbsuite/test/commands/gui/basicdebug/func.c
rename to lldb/test/API/commands/gui/basicdebug/func.c

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/gui/basicdebug/main.c 
b/lldb/test/API/commands/gui/basicdebug/main.c
similarity index 100%
rename from lldb/packages/Python/lldbsuite/test/commands/gui/basicdebug/main.c
rename to lldb/test/API/commands/gui/basicdebug/main.c



___
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-05 Thread Luboš Luňák via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdb828aba55ac: [lldb][gui] add a test for 'b' 
(toggle breakpoint) (authored by llunak).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85107

Files:
  lldb/test/API/commands/gui/breakpoints/Makefile
  lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
  lldb/test/API/commands/gui/breakpoints/main.c


Index: lldb/test/API/commands/gui/breakpoints/main.c
===
--- /dev/null
+++ lldb/test/API/commands/gui/breakpoints/main.c
@@ -0,0 +1,6 @@
+int main(int argc, char **argv) {
+  int var1 = 1; // First break here
+  int var2 = 2;
+  int var3 = 3;
+  return var1 + var2 + var3;
+}
Index: lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
===
--- /dev/null
+++ lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
@@ -0,0 +1,75 @@
+"""
+Test the 'gui' shortcut 'b' (toggle breakpoint).
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+class TestGuiBasicDebugCommandTest(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+@skipIfCursesSupportMissing
+@skipIfRemote # "run" command will not work correctly for remote debug
+def test_gui(self):
+self.build()
+
+self.launch(executable=self.getBuildArtifact("a.out"), 
dimensions=(100,500))
+self.expect('br set -o true -f main.c -p "// First break here"', 
substrs=["Breakpoint 1", "address ="])
+self.expect("run", substrs=["stop reason ="])
+
+self.child.sendline("breakpoint list")
+self.child.expect_exact("No breakpoints currently set.")
+
+escape_key = chr(27).encode()
+down_key = chr(27)+'OB' # for vt100 terminal (lldbexpect sets 
TERM=vt100)
+
+# Start the GUI and close the welcome window.
+self.child.sendline("gui")
+self.child.send(escape_key)
+self.child.expect_exact("Sources") # wait for gui
+
+# Go to next line, set a breakpoint.
+self.child.send(down_key)
+self.child.send('b')
+self.child.send(escape_key)
+self.expect_prompt()
+self.child.sendline("breakpoint list")
+self.child.expect("2: file = '[^']*main.c', line = 3,.*")
+self.child.sendline("gui")
+self.child.expect_exact("Sources")
+
+# Go two lines down ("gui" resets position), set a breakpoint.
+self.child.send(down_key)
+self.child.send(down_key)
+self.child.send('b')
+self.child.send(escape_key)
+self.expect_prompt()
+self.child.sendline("breakpoint list")
+self.child.expect("2: file = '[^']*main.c', line = 3,")
+self.child.expect("3: file = '[^']*main.c', line = 4,")
+self.child.sendline("gui")
+self.child.expect_exact("Sources")
+
+# Toggle both the breakpoints (remove them).
+self.child.send(down_key)
+self.child.send('b')
+self.child.send(down_key)
+self.child.send('b')
+self.child.send(escape_key)
+self.expect_prompt()
+self.child.sendline("breakpoint list")
+self.child.expect_exact("No breakpoints currently set.")
+self.child.sendline("gui")
+self.child.expect_exact("Sources")
+
+# Press escape to quit the gui
+self.child.send(escape_key)
+
+self.expect_prompt()
+self.quit()
Index: lldb/test/API/commands/gui/breakpoints/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/gui/breakpoints/Makefile
@@ -0,0 +1,2 @@
+C_SOURCES := main.c
+include Makefile.rules


Index: lldb/test/API/commands/gui/breakpoints/main.c
===
--- /dev/null
+++ lldb/test/API/commands/gui/breakpoints/main.c
@@ -0,0 +1,6 @@
+int main(int argc, char **argv) {
+  int var1 = 1; // First break here
+  int var2 = 2;
+  int var3 = 3;
+  return var1 + var2 + var3;
+}
Index: lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
===
--- /dev/null
+++ lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
@@ -0,0 +1,75 @@
+"""
+Test the 'gui' shortcut 'b' (toggle breakpoint).
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+class TestGuiBasicDebugCommandTest(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+# PExpect uses many timeouts internally

[Lldb-commits] [PATCH] D85089: Implement shift+tab for going back in lldb gui views

2020-08-05 Thread Luboš Luňák via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
llunak marked 2 inline comments as done.
Closed by commit rG7a63dc534eb8: [lldb][gui] implement shift+tab for going back 
in views (authored by llunak).
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D85089?vs=282441&id=283149#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85089

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp


Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -692,42 +692,44 @@
 
   void SelectNextWindowAsActive() {
 // Move active focus to next window
-const size_t num_subwindows = m_subwindows.size();
-if (m_curr_active_window_idx == UINT32_MAX) {
-  uint32_t idx = 0;
-  for (auto subwindow_sp : m_subwindows) {
-if (subwindow_sp->GetCanBeActive()) {
-  m_curr_active_window_idx = idx;
-  break;
-}
-++idx;
-  }
-} else if (m_curr_active_window_idx + 1 < num_subwindows) {
-  bool handled = false;
+const int num_subwindows = m_subwindows.size();
+int start_idx = 0;
+if (m_curr_active_window_idx != UINT32_MAX) {
   m_prev_active_window_idx = m_curr_active_window_idx;
-  for (size_t idx = m_curr_active_window_idx + 1; idx < num_subwindows;
-   ++idx) {
-if (m_subwindows[idx]->GetCanBeActive()) {
-  m_curr_active_window_idx = idx;
-  handled = true;
-  break;
-}
+  start_idx = m_curr_active_window_idx + 1;
+}
+for (int idx = start_idx; idx < num_subwindows; ++idx) {
+  if (m_subwindows[idx]->GetCanBeActive()) {
+m_curr_active_window_idx = idx;
+return;
   }
-  if (!handled) {
-for (size_t idx = 0; idx <= m_prev_active_window_idx; ++idx) {
-  if (m_subwindows[idx]->GetCanBeActive()) {
-m_curr_active_window_idx = idx;
-break;
-  }
-}
+}
+for (int idx = 0; idx < start_idx; ++idx) {
+  if (m_subwindows[idx]->GetCanBeActive()) {
+m_curr_active_window_idx = idx;
+break;
   }
-} else {
+}
+  }
+
+  void SelectPreviousWindowAsActive() {
+// Move active focus to previous window
+const int num_subwindows = m_subwindows.size();
+int start_idx = num_subwindows - 1;
+if (m_curr_active_window_idx != UINT32_MAX) {
   m_prev_active_window_idx = m_curr_active_window_idx;
-  for (size_t idx = 0; idx < num_subwindows; ++idx) {
-if (m_subwindows[idx]->GetCanBeActive()) {
-  m_curr_active_window_idx = idx;
-  break;
-}
+  start_idx = m_curr_active_window_idx - 1;
+}
+for (int idx = start_idx; idx >= 0; --idx) {
+  if (m_subwindows[idx]->GetCanBeActive()) {
+m_curr_active_window_idx = idx;
+return;
+  }
+}
+for (int idx = num_subwindows - 1; idx > start_idx; --idx) {
+  if (m_subwindows[idx]->GetCanBeActive()) {
+m_curr_active_window_idx = idx;
+break;
   }
 }
   }
@@ -2928,6 +2930,10 @@
   window.SelectNextWindowAsActive();
   return eKeyHandled;
 
+case KEY_BTAB:
+  window.SelectPreviousWindowAsActive();
+  return eKeyHandled;
+
 case 'h':
   window.CreateHelpSubwindow();
   return eKeyHandled;
@@ -2952,6 +2958,7 @@
   KeyHelp *WindowDelegateGetKeyHelp() override {
 static curses::KeyHelp g_source_view_key_help[] = {
 {'\t', "Select next view"},
+{KEY_BTAB, "Select previous view"},
 {'h', "Show help dialog with view specific key bindings"},
 {',', "Page up"},
 {'.', "Page down"},


Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -692,42 +692,44 @@
 
   void SelectNextWindowAsActive() {
 // Move active focus to next window
-const size_t num_subwindows = m_subwindows.size();
-if (m_curr_active_window_idx == UINT32_MAX) {
-  uint32_t idx = 0;
-  for (auto subwindow_sp : m_subwindows) {
-if (subwindow_sp->GetCanBeActive()) {
-  m_curr_active_window_idx = idx;
-  break;
-}
-++idx;
-  }
-} else if (m_curr_active_window_idx + 1 < num_subwindows) {
-  bool handled = false;
+const int num_subwindows = m_subwindows.size();
+int start_idx = 0;
+if (m_curr_active_window_idx != UINT32_MAX) {
   m_prev_active_window_idx = m_curr_active_window_idx;
-  for (size_t idx = m_curr_active_window_idx + 1; idx < num_subwindows;
-   ++idx) {
-if (m_subwindows[idx]->GetCanBeActive()) {
-  m_curr_active_window_idx = idx;
-  handle

[Lldb-commits] [lldb] 2f1b24b - [lldb][gui] implement TerminalSizeChanged()

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

Author: Luboš Luňák
Date: 2020-08-05T09:51:12+02:00
New Revision: 2f1b24b70c6c3ecf3cf5ccd35209d9d7e426be63

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

LOG: [lldb][gui] implement TerminalSizeChanged()

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

Added: 


Modified: 
lldb/include/lldb/Core/IOHandlerCursesGUI.h
lldb/source/Core/IOHandlerCursesGUI.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/IOHandlerCursesGUI.h 
b/lldb/include/lldb/Core/IOHandlerCursesGUI.h
index fe62eaea643e..22ca735063ba 100644
--- a/lldb/include/lldb/Core/IOHandlerCursesGUI.h
+++ b/lldb/include/lldb/Core/IOHandlerCursesGUI.h
@@ -31,6 +31,8 @@ class IOHandlerCursesGUI : public IOHandler {
 
   void Deactivate() override;
 
+  void TerminalSizeChanged() override;
+
 protected:
   curses::ApplicationAP m_app_ap;
 };

diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp 
b/lldb/source/Core/IOHandlerCursesGUI.cpp
index 55c80e778060..ea4dfd12ada4 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -1197,13 +1197,13 @@ class Application {
 ConstString 
broadcaster_class_process(Process::GetStaticBroadcasterClass());
 debugger.EnableForwardEvents(listener_sp);
 
-bool update = true;
+m_update_screen = true;
 #if defined(__APPLE__)
 std::deque escape_chars;
 #endif
 
 while (!done) {
-  if (update) {
+  if (m_update_screen) {
 m_window_sp->Draw(false);
 // All windows should be calling Window::DeferredRefresh() instead of
 // Window::Refresh() so we can do a single update and avoid any screen
@@ -1215,7 +1215,7 @@ class Application {
 m_window_sp->MoveCursor(0, 0);
 
 doupdate();
-update = false;
+m_update_screen = false;
   }
 
 #if defined(__APPLE__)
@@ -1277,7 +1277,7 @@ class Application {
 if (broadcaster_class == broadcaster_class_process) {
   debugger.GetCommandInterpreter().UpdateExecutionContext(
   nullptr);
-  update = true;
+  m_update_screen = true;
   continue; // Don't get any key, just update our view
 }
   }
@@ -1289,12 +1289,12 @@ class Application {
 switch (key_result) {
 case eKeyHandled:
   debugger.GetCommandInterpreter().UpdateExecutionContext(nullptr);
-  update = true;
+  m_update_screen = true;
   break;
 case eKeyNotHandled:
   if (ch == 12) { // Ctrl+L, force full redraw
 redrawwin(m_window_sp->get());
-update = true;
+m_update_screen = true;
   }
   break;
 case eQuitApplication:
@@ -1313,12 +1313,65 @@ class Application {
 return m_window_sp;
   }
 
+  void TerminalSizeChanged() {
+::endwin();
+::refresh();
+Rect content_bounds = m_window_sp->GetFrame();
+m_window_sp->SetBounds(content_bounds);
+if (WindowSP menubar_window_sp = m_window_sp->FindSubWindow("Menubar"))
+  menubar_window_sp->SetBounds(content_bounds.MakeMenuBar());
+if (WindowSP status_window_sp = m_window_sp->FindSubWindow("Status"))
+  status_window_sp->SetBounds(content_bounds.MakeStatusBar());
+
+WindowSP source_window_sp = m_window_sp->FindSubWindow("Source");
+WindowSP variables_window_sp = m_window_sp->FindSubWindow("Variables");
+WindowSP registers_window_sp = m_window_sp->FindSubWindow("Registers");
+WindowSP threads_window_sp = m_window_sp->FindSubWindow("Threads");
+
+Rect threads_bounds;
+Rect source_variables_bounds;
+content_bounds.VerticalSplitPercentage(0.80, source_variables_bounds,
+   threads_bounds);
+if (threads_window_sp)
+  threads_window_sp->SetBounds(threads_bounds);
+else
+  source_variables_bounds = content_bounds;
+
+Rect source_bounds;
+Rect variables_registers_bounds;
+source_variables_bounds.HorizontalSplitPercentage(
+0.70, source_bounds, variables_registers_bounds);
+if (variables_window_sp || registers_window_sp) {
+  if (variables_window_sp && registers_window_sp) {
+Rect variables_bounds;
+Rect registers_bounds;
+variables_registers_bounds.VerticalSplitPercentage(
+0.50, variables_bounds, registers_bounds);
+variables_window_sp->SetBounds(variables_bounds);
+registers_window_sp->SetBounds(registers_bounds);
+  } else if (variables_window_sp) {
+variables_window_sp->SetBounds(variables_registers_bounds);
+  } else {
+registers_window_sp->SetBounds(variables_registers_bounds);
+  }
+} else {
+  source_bounds = source_variables_bounds;
+}

[Lldb-commits] [PATCH] D85088: Implement TerminalSizeChanged() for lldb ncurses GUI

2020-08-05 Thread Luboš Luňák via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2f1b24b70c6c: [lldb][gui] implement TerminalSizeChanged() 
(authored by llunak).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85088

Files:
  lldb/include/lldb/Core/IOHandlerCursesGUI.h
  lldb/source/Core/IOHandlerCursesGUI.cpp

Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -1197,13 +1197,13 @@
 ConstString broadcaster_class_process(Process::GetStaticBroadcasterClass());
 debugger.EnableForwardEvents(listener_sp);
 
-bool update = true;
+m_update_screen = true;
 #if defined(__APPLE__)
 std::deque escape_chars;
 #endif
 
 while (!done) {
-  if (update) {
+  if (m_update_screen) {
 m_window_sp->Draw(false);
 // All windows should be calling Window::DeferredRefresh() instead of
 // Window::Refresh() so we can do a single update and avoid any screen
@@ -1215,7 +1215,7 @@
 m_window_sp->MoveCursor(0, 0);
 
 doupdate();
-update = false;
+m_update_screen = false;
   }
 
 #if defined(__APPLE__)
@@ -1277,7 +1277,7 @@
 if (broadcaster_class == broadcaster_class_process) {
   debugger.GetCommandInterpreter().UpdateExecutionContext(
   nullptr);
-  update = true;
+  m_update_screen = true;
   continue; // Don't get any key, just update our view
 }
   }
@@ -1289,12 +1289,12 @@
 switch (key_result) {
 case eKeyHandled:
   debugger.GetCommandInterpreter().UpdateExecutionContext(nullptr);
-  update = true;
+  m_update_screen = true;
   break;
 case eKeyNotHandled:
   if (ch == 12) { // Ctrl+L, force full redraw
 redrawwin(m_window_sp->get());
-update = true;
+m_update_screen = true;
   }
   break;
 case eQuitApplication:
@@ -1313,12 +1313,65 @@
 return m_window_sp;
   }
 
+  void TerminalSizeChanged() {
+::endwin();
+::refresh();
+Rect content_bounds = m_window_sp->GetFrame();
+m_window_sp->SetBounds(content_bounds);
+if (WindowSP menubar_window_sp = m_window_sp->FindSubWindow("Menubar"))
+  menubar_window_sp->SetBounds(content_bounds.MakeMenuBar());
+if (WindowSP status_window_sp = m_window_sp->FindSubWindow("Status"))
+  status_window_sp->SetBounds(content_bounds.MakeStatusBar());
+
+WindowSP source_window_sp = m_window_sp->FindSubWindow("Source");
+WindowSP variables_window_sp = m_window_sp->FindSubWindow("Variables");
+WindowSP registers_window_sp = m_window_sp->FindSubWindow("Registers");
+WindowSP threads_window_sp = m_window_sp->FindSubWindow("Threads");
+
+Rect threads_bounds;
+Rect source_variables_bounds;
+content_bounds.VerticalSplitPercentage(0.80, source_variables_bounds,
+   threads_bounds);
+if (threads_window_sp)
+  threads_window_sp->SetBounds(threads_bounds);
+else
+  source_variables_bounds = content_bounds;
+
+Rect source_bounds;
+Rect variables_registers_bounds;
+source_variables_bounds.HorizontalSplitPercentage(
+0.70, source_bounds, variables_registers_bounds);
+if (variables_window_sp || registers_window_sp) {
+  if (variables_window_sp && registers_window_sp) {
+Rect variables_bounds;
+Rect registers_bounds;
+variables_registers_bounds.VerticalSplitPercentage(
+0.50, variables_bounds, registers_bounds);
+variables_window_sp->SetBounds(variables_bounds);
+registers_window_sp->SetBounds(registers_bounds);
+  } else if (variables_window_sp) {
+variables_window_sp->SetBounds(variables_registers_bounds);
+  } else {
+registers_window_sp->SetBounds(variables_registers_bounds);
+  }
+} else {
+  source_bounds = source_variables_bounds;
+}
+
+source_window_sp->SetBounds(source_bounds);
+
+touchwin(stdscr);
+redrawwin(m_window_sp->get());
+m_update_screen = true;
+  }
+
 protected:
   WindowSP m_window_sp;
   WindowDelegates m_window_delegates;
   SCREEN *m_screen;
   FILE *m_in;
   FILE *m_out;
+  bool m_update_screen = false;
 };
 
 } // namespace curses
@@ -3082,7 +3135,7 @@
new_registers_rect);
   registers_window_sp->SetBounds(new_registers_rect);
 } else {
-  // No variables window, grab the bottom part of the source window
+  // No registers window, grab the bottom part of the source window
   Rect new_source_rect;
   source_bounds.Horizont

[Lldb-commits] [lldb] d6868d9 - [lldb][gui] implement breakpoint removal on breakpoint toggling

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

Author: Luboš Luňák
Date: 2020-08-05T09:51:12+02:00
New Revision: d6868d9ca1dbdeceaaa1660b6e7b4af0c207fcae

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

LOG: [lldb][gui] implement breakpoint removal on breakpoint toggling

It says it toggles breakpoints, so if one already exists
on the selected location, remove it instead of adding.

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

Added: 


Modified: 
lldb/source/Core/IOHandlerCursesGUI.cpp

Removed: 




diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp 
b/lldb/source/Core/IOHandlerCursesGUI.cpp
index 2e991dc37be8..37e24d4f7533 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -3837,37 +3837,7 @@ class SourceFileWindowDelegate : public WindowDelegate {
   return eKeyHandled;
 
 case 'b': // 'b' == toggle breakpoint on currently selected line
-  if (m_selected_line < GetNumSourceLines()) {
-ExecutionContext exe_ctx =
-m_debugger.GetCommandInterpreter().GetExecutionContext();
-if (exe_ctx.HasTargetScope()) {
-  BreakpointSP bp_sp = exe_ctx.GetTargetRef().CreateBreakpoint(
-  nullptr, // Don't limit the breakpoint to certain modules
-  m_file_sp->GetFileSpec(), // Source file
-  m_selected_line +
-  1, // Source line number (m_selected_line is zero based)
-  0, // No column specified.
-  0, // No offset
-  eLazyBoolCalculate,  // Check inlines using global setting
-  eLazyBoolCalculate,  // Skip prologue using global setting,
-  false,   // internal
-  false,   // request_hardware
-  eLazyBoolCalculate); // move_to_nearest_code
-}
-  } else if (m_selected_line < GetNumDisassemblyLines()) {
-const Instruction *inst = m_disassembly_sp->GetInstructionList()
-  .GetInstructionAtIndex(m_selected_line)
-  .get();
-ExecutionContext exe_ctx =
-m_debugger.GetCommandInterpreter().GetExecutionContext();
-if (exe_ctx.HasTargetScope()) {
-  Address addr = inst->GetAddress();
-  BreakpointSP bp_sp = exe_ctx.GetTargetRef().CreateBreakpoint(
-  addr,   // lldb_private::Address
-  false,  // internal
-  false); // request_hardware
-}
-  }
+  ToggleBreakpointOnSelectedLine();
   return eKeyHandled;
 
 case 'D': // 'D' == detach and keep stopped
@@ -3957,6 +3927,85 @@ class SourceFileWindowDelegate : public WindowDelegate {
 return eKeyNotHandled;
   }
 
+  void ToggleBreakpointOnSelectedLine() {
+ExecutionContext exe_ctx =
+m_debugger.GetCommandInterpreter().GetExecutionContext();
+if (!exe_ctx.HasTargetScope())
+  return;
+if (GetNumSourceLines() > 0) {
+  // Source file breakpoint.
+  BreakpointList &bp_list = exe_ctx.GetTargetRef().GetBreakpointList();
+  const size_t num_bps = bp_list.GetSize();
+  for (size_t bp_idx = 0; bp_idx < num_bps; ++bp_idx) {
+BreakpointSP bp_sp = bp_list.GetBreakpointAtIndex(bp_idx);
+const size_t num_bps_locs = bp_sp->GetNumLocations();
+for (size_t bp_loc_idx = 0; bp_loc_idx < num_bps_locs; ++bp_loc_idx) {
+  BreakpointLocationSP bp_loc_sp =
+  bp_sp->GetLocationAtIndex(bp_loc_idx);
+  LineEntry bp_loc_line_entry;
+  if (bp_loc_sp->GetAddress().CalculateSymbolContextLineEntry(
+  bp_loc_line_entry)) {
+if (m_file_sp->GetFileSpec() == bp_loc_line_entry.file &&
+m_selected_line + 1 == bp_loc_line_entry.line) {
+  bool removed =
+  exe_ctx.GetTargetRef().RemoveBreakpointByID(bp_sp->GetID());
+  assert(removed);
+  UNUSED_IF_ASSERT_DISABLED(removed);
+  return; // Existing breakpoint removed.
+}
+  }
+}
+  }
+  // No breakpoint found on the location, add it.
+  BreakpointSP bp_sp = exe_ctx.GetTargetRef().CreateBreakpoint(
+  nullptr, // Don't limit the breakpoint to certain modules
+  m_file_sp->GetFileSpec(), // Source file
+  m_selected_line +
+  1, // Source line number (m_selected_line is zero based)
+  0, // No column specified.
+  0, // No offset
+  eLazyBoolCalculate,  // Check inlines using global setting
+  eLazyBoolCalculate,  // Skip prologue using global setting,
+  false,   // internal
+  false,   // request_hardware
+  eLazyBoolCalculate); // move_to_nearest_code
+ 

[Lldb-commits] [lldb] db828ab - [lldb][gui] add a test for 'b' (toggle breakpoint)

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

Author: Luboš Luňák
Date: 2020-08-05T09:51:13+02:00
New Revision: db828aba55aca0ce977f086dcd449f8fe667f30a

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

LOG: [lldb][gui] add a test for 'b' (toggle breakpoint)

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

Added: 
lldb/test/API/commands/gui/breakpoints/Makefile
lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
lldb/test/API/commands/gui/breakpoints/main.c

Modified: 


Removed: 




diff  --git a/lldb/test/API/commands/gui/breakpoints/Makefile 
b/lldb/test/API/commands/gui/breakpoints/Makefile
new file mode 100644
index ..c9319d6e6888
--- /dev/null
+++ b/lldb/test/API/commands/gui/breakpoints/Makefile
@@ -0,0 +1,2 @@
+C_SOURCES := main.c
+include Makefile.rules

diff  --git a/lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py 
b/lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
new file mode 100644
index ..13f5e1380a74
--- /dev/null
+++ b/lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
@@ -0,0 +1,75 @@
+"""
+Test the 'gui' shortcut 'b' (toggle breakpoint).
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+class TestGuiBasicDebugCommandTest(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+@skipIfCursesSupportMissing
+@skipIfRemote # "run" command will not work correctly for remote debug
+def test_gui(self):
+self.build()
+
+self.launch(executable=self.getBuildArtifact("a.out"), 
dimensions=(100,500))
+self.expect('br set -o true -f main.c -p "// First break here"', 
substrs=["Breakpoint 1", "address ="])
+self.expect("run", substrs=["stop reason ="])
+
+self.child.sendline("breakpoint list")
+self.child.expect_exact("No breakpoints currently set.")
+
+escape_key = chr(27).encode()
+down_key = chr(27)+'OB' # for vt100 terminal (lldbexpect sets 
TERM=vt100)
+
+# Start the GUI and close the welcome window.
+self.child.sendline("gui")
+self.child.send(escape_key)
+self.child.expect_exact("Sources") # wait for gui
+
+# Go to next line, set a breakpoint.
+self.child.send(down_key)
+self.child.send('b')
+self.child.send(escape_key)
+self.expect_prompt()
+self.child.sendline("breakpoint list")
+self.child.expect("2: file = '[^']*main.c', line = 3,.*")
+self.child.sendline("gui")
+self.child.expect_exact("Sources")
+
+# Go two lines down ("gui" resets position), set a breakpoint.
+self.child.send(down_key)
+self.child.send(down_key)
+self.child.send('b')
+self.child.send(escape_key)
+self.expect_prompt()
+self.child.sendline("breakpoint list")
+self.child.expect("2: file = '[^']*main.c', line = 3,")
+self.child.expect("3: file = '[^']*main.c', line = 4,")
+self.child.sendline("gui")
+self.child.expect_exact("Sources")
+
+# Toggle both the breakpoints (remove them).
+self.child.send(down_key)
+self.child.send('b')
+self.child.send(down_key)
+self.child.send('b')
+self.child.send(escape_key)
+self.expect_prompt()
+self.child.sendline("breakpoint list")
+self.child.expect_exact("No breakpoints currently set.")
+self.child.sendline("gui")
+self.child.expect_exact("Sources")
+
+# Press escape to quit the gui
+self.child.send(escape_key)
+
+self.expect_prompt()
+self.quit()

diff  --git a/lldb/test/API/commands/gui/breakpoints/main.c 
b/lldb/test/API/commands/gui/breakpoints/main.c
new file mode 100644
index ..61a0843482a4
--- /dev/null
+++ b/lldb/test/API/commands/gui/breakpoints/main.c
@@ -0,0 +1,6 @@
+int main(int argc, char **argv) {
+  int var1 = 1; // First break here
+  int var2 = 2;
+  int var3 = 3;
+  return var1 + var2 + var3;
+}



___
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-05 Thread Luboš Luňák via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc7be982c836c: [lldb][gui] move TestGuiBasicDebug.py to 
lldb/test and update it (authored by llunak).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85106

Files:
  lldb/packages/Python/lldbsuite/test/commands/gui/basicdebug/Makefile
  
lldb/packages/Python/lldbsuite/test/commands/gui/basicdebug/TestGuiBasicDebug.py
  lldb/packages/Python/lldbsuite/test/commands/gui/basicdebug/func.c
  lldb/packages/Python/lldbsuite/test/commands/gui/basicdebug/main.c
  lldb/test/API/commands/gui/basicdebug/Makefile
  lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
  lldb/test/API/commands/gui/basicdebug/func.c
  lldb/test/API/commands/gui/basicdebug/main.c


Index: lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
===
--- lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
+++ lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
@@ -11,7 +11,11 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
 @skipIfCursesSupportMissing
+@skipIfRemote # "run" command will not work correctly for remote debug
 def test_gui(self):
 self.build()
 
@@ -39,4 +43,8 @@
 self.child.send("n") # step over
 self.child.expect("return 0;[^\r\n]+<<< Thread 1: step over")
 
+# Press escape to quit the gui
+self.child.send(escape_key)
+
+self.expect_prompt()
 self.quit()


Index: lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
===
--- lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
+++ lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
@@ -11,7 +11,11 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
 @skipIfCursesSupportMissing
+@skipIfRemote # "run" command will not work correctly for remote debug
 def test_gui(self):
 self.build()
 
@@ -39,4 +43,8 @@
 self.child.send("n") # step over
 self.child.expect("return 0;[^\r\n]+<<< Thread 1: step over")
 
+# Press escape to quit the gui
+self.child.send(escape_key)
+
+self.expect_prompt()
 self.quit()
___
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-05 Thread Luboš Luňák via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc952ec15d388: [lldb] fix building with panel.h being in 
/usr/include/ncurses/ (authored by llunak).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

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] D85123: Truncate long lines/names if needed in lldb gui

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

Use SteamString.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D85123

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/test/API/commands/gui/viewlarge/Makefile
  lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py
  lldb/test/API/commands/gui/viewlarge/main.c

Index: lldb/test/API/commands/gui/viewlarge/main.c
===
--- /dev/null
+++ lldb/test/API/commands/gui/viewlarge/main.c
@@ -0,0 +1,7 @@
+int main(int argc, char **argv) {
+  // This is to be viewed in a 80-column terminal, so make the line below more
+  // than 120 characters wide, to span at least two lines.
+  int a_variable_with_a_very_loong_name = 22;
+  int shortvar = 1;
+  return a_variable_with_a_very_loong_name; // Break here
+}
Index: lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py
===
--- /dev/null
+++ lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py
@@ -0,0 +1,52 @@
+"""
+Test that the 'gui' displays long lines/names correctly without overruns.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+class GuiViewLargeCommandTest(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+@skipIfCursesSupportMissing
+@skipIfRemote # "run" command will not work correctly for remote debug
+def test_gui(self):
+self.build()
+
+# Limit columns to 80, so that long lines will not be displayed completely.
+self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100,80))
+self.expect('br set -f main.c -p "// Break here"', substrs=["Breakpoint 1", "address ="])
+self.expect("run", substrs=["stop reason ="])
+
+escape_key = chr(27).encode()
+
+# Start the GUI and close the welcome window.
+self.child.sendline("gui")
+self.child.send(escape_key)
+
+# Check the sources window.
+self.child.expect_exact("Sources")
+# The string is copy&pasted from a 80-columns terminal. It will be followed by some
+# kind of an escape sequence (color, frame, etc.).
+self.child.expect_exact("int a_variable_with_a_very_looo"+chr(27))
+# The escape here checks that there's no content drawn by the previous line.
+self.child.expect_exact("int shortvar = 1;"+chr(27))
+# Check the triggered breakpoint marker on a long line.
+self.child.expect_exact("<<< Thread 1: breakpoint 1.1"+chr(27))
+
+# Check the variable window.
+self.child.expect_exact("Variables")
+self.child.expect_exact("(int) a_variable_with_a_very_looo"+chr(27))
+self.child.expect_exact("(int) shortvar = 1"+chr(27))
+
+# Press escape to quit the gui
+self.child.send(escape_key)
+
+self.expect_prompt()
+self.quit()
Index: lldb/test/API/commands/gui/viewlarge/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/gui/viewlarge/Makefile
@@ -0,0 +1,2 @@
+C_SOURCES := main.c
+include Makefile.rules
Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -367,23 +367,23 @@
   }
   void Clear() { ::wclear(m_window); }
   void Erase() { ::werase(m_window); }
-  Rect GetBounds() {
+  Rect GetBounds() const {
 return Rect(GetParentOrigin(), GetSize());
   } // Get the rectangle in our parent window
   int GetChar() { return ::wgetch(m_window); }
-  int GetCursorX() { return getcurx(m_window); }
-  int GetCursorY() { return getcury(m_window); }
-  Rect GetFrame() {
+  int GetCursorX() const { return getcurx(m_window); }
+  int GetCursorY() const { return getcury(m_window); }
+  Rect GetFrame() const {
 return Rect(Point(), GetSize());
   } // Get our rectangle in our own coordinate system
-  Point GetParentOrigin() { return Point(GetParentX(), GetParentY()); }
-  Size GetSize() { return Size(GetWidth(), GetHeight()); }
-  int GetParentX() { return getparx(m_window); }
-  int GetParentY() { return getpary(m_window); }
-  int GetMaxX() { return getmaxx(m_window); }
-  int GetMaxY() { return getmaxy(m_window); }
-  int GetWidth() { return GetMaxX(); }
-  int GetHeight() { return GetMaxY(); }
+  Point GetParentOrigin() const { return Point

[Lldb-commits] [PATCH] D85286: [lldb][gui] use names for color pairs, instead of magic numbers

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

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D85286

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp

Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -273,6 +273,32 @@
   const char *description;
 };
 
+// COLOR_PAIR index names
+enum {
+  // First 16 colors are 8 black background and 8 blue background colors,
+  // needed by OutputColoredStringTruncated().
+  BlackOnBlack = 1,
+  RedOnBlack,
+  GreenOnBlack,
+  YellowOnBlack,
+  BlueOnBlack,
+  MagentaOnBlack,
+  CyanOnBlack,
+  WhiteOnBlack,
+  BlackOnBlue,
+  RedOnBlue,
+  GreenOnBlue,
+  YellowOnBlue,
+  BlueOnBlue,
+  MagentaOnBlue,
+  CyanOnBlue,
+  WhiteOnBlue,
+  // Other colors, as needed.
+  BlackOnWhite,
+  MagentaOnWhite,
+  LastColorPairIndex = MagentaOnWhite
+};
+
 class WindowDelegate {
 public:
   virtual ~WindowDelegate() = default;
@@ -462,7 +488,7 @@
 int saved_opts;
 ::wattr_get(m_window, &saved_attr, &saved_pair, &saved_opts);
 if (use_blue_background)
-  ::wattron(m_window, COLOR_PAIR(16));
+  ::wattron(m_window, COLOR_PAIR(WhiteOnBlue));
 while (!string.empty()) {
   size_t esc_pos = string.find('\x1b');
   if (esc_pos == StringRef::npos) {
@@ -498,7 +524,7 @@
   if (value == 0) { // Reset.
 ::wattr_set(m_window, saved_attr, saved_pair, &saved_opts);
 if (use_blue_background)
-  ::wattron(m_window, COLOR_PAIR(16));
+  ::wattron(m_window, COLOR_PAIR(WhiteOnBlue));
   } else {
 // Mapped directly to first 16 color pairs (black/blue background).
 ::wattron(m_window,
@@ -596,7 +622,7 @@
   void DrawTitleBox(const char *title, const char *bottom_message = nullptr) {
 attr_t attr = 0;
 if (IsActive())
-  attr = A_BOLD | COLOR_PAIR(18);
+  attr = A_BOLD | COLOR_PAIR(BlackOnWhite);
 else
   attr = 0;
 if (attr)
@@ -1026,14 +1052,14 @@
 
 if (m_key_name.empty()) {
   if (!underlined_shortcut && llvm::isPrint(m_key_value)) {
-window.AttributeOn(COLOR_PAIR(19));
+window.AttributeOn(COLOR_PAIR(MagentaOnWhite));
 window.Printf(" (%c)", m_key_value);
-window.AttributeOff(COLOR_PAIR(19));
+window.AttributeOff(COLOR_PAIR(MagentaOnWhite));
   }
 } else {
-  window.AttributeOn(COLOR_PAIR(19));
+  window.AttributeOn(COLOR_PAIR(MagentaOnWhite));
   window.Printf(" (%s)", m_key_name.c_str());
-  window.AttributeOff(COLOR_PAIR(19));
+  window.AttributeOff(COLOR_PAIR(MagentaOnWhite));
 }
   }
 }
@@ -2440,7 +2466,7 @@
 
 attr_t changd_attr = 0;
 if (valobj->GetValueDidChange())
-  changd_attr = COLOR_PAIR(2) | A_BOLD;
+  changd_attr = COLOR_PAIR(RedOnBlack) | A_BOLD;
 
 if (value && value[0]) {
   window.PutCStringTruncated(1, " = ");
@@ -3581,7 +3607,7 @@
   }
 
   const attr_t selected_highlight_attr = A_REVERSE;
-  const attr_t pc_highlight_attr = COLOR_PAIR(9);
+  const attr_t pc_highlight_attr = COLOR_PAIR(BlackOnBlue);
 
   for (size_t i = 0; i < num_visible_lines; ++i) {
 const uint32_t curr_line = m_first_visible_line + i;
@@ -3600,7 +3626,7 @@
 highlight_attr = selected_highlight_attr;
 
   if (bp_lines.find(curr_line + 1) != bp_lines.end())
-bp_attr = COLOR_PAIR(18);
+bp_attr = COLOR_PAIR(BlackOnWhite);
 
   if (bp_attr)
 window.AttributeOn(bp_attr);
@@ -3641,7 +3667,7 @@
   window.Printf("%*s", desc_x - window.GetCursorX(), "");
 window.MoveCursor(window_width - stop_description_len - 16,
   line_y);
-const attr_t stop_reason_attr = COLOR_PAIR(17);
+const attr_t stop_reason_attr = COLOR_PAIR(WhiteOnBlue);
 window.AttributeOn(stop_reason_attr);
 window.PrintfTruncated(1, " <<< Thread %u: %s ",
thread->GetIndexID(), stop_description);
@@ -3685,7 +3711,7 @@
 }
 
 const attr_t selected_highlight_attr = A_REVERSE;
-const attr_t pc_highlight_attr = COLOR_PAIR(17);
+const attr_t pc_highlight_attr = COLOR_PAIR(WhiteOnBlue);
 
 StreamString strm;
 
@@ -3733,7 +3759,7 @@
 
   if (bp_file_addrs.find(inst->GetAddress().GetFileAddress()) !=
   bp_file_addrs.end())
-bp_attr = COLOR_PAIR(18);
+bp_attr = COLOR_PAIR(BlackOnWhite);
 
   if (bp_attr)
 window.AttributeOn(bp_attr);
@@ -4263,10 +4289,10 @@
 init_pair(14, COLOR_MAGENTA, COLOR_BLUE);
 init_pair(15, COLOR_CYAN, COLOR_BLUE);
 init_pair(16, COLOR_WHITE, COLOR_BLUE);
-
-init_pair(17, COLOR_WHITE, COLOR_BLUE);
-init_pair(18, COLOR_BLACK, COLOR_WHIT

[Lldb-commits] [lldb] 75012a8 - [lldb] Use PyUnicode_GetLength instead of PyUnicode_GetSize

2020-08-05 Thread Tatyana Krasnukha via lldb-commits

Author: Tatyana Krasnukha
Date: 2020-08-05T11:59:47+03:00
New Revision: 75012a80440f2302d3dc0e57ea264b9c26c26789

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

LOG: [lldb] Use PyUnicode_GetLength instead of PyUnicode_GetSize

PyUnicode_GetSize is deprecated since Python version 3.3.

Added: 


Modified: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
index 6f040fdef09b..7c49502f1b57 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -451,7 +451,11 @@ Expected PythonString::AsUTF8() const {
 size_t PythonString::GetSize() const {
   if (IsValid()) {
 #if PY_MAJOR_VERSION >= 3
+#if PY_MINOR_VERSION >= 3
+return PyUnicode_GetLength(m_py_obj);
+#else
 return PyUnicode_GetSize(m_py_obj);
+#endif
 #else
 return PyString_Size(m_py_obj);
 #endif



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


[Lldb-commits] [lldb] bc056b3 - [lldb] Suppress MSVC warning C4065

2020-08-05 Thread Tatyana Krasnukha via lldb-commits

Author: Tatyana Krasnukha
Date: 2020-08-05T11:59:48+03:00
New Revision: bc056b3aa7130923ab9ad0505c5a8d65ea721e39

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

LOG: [lldb] Suppress MSVC warning C4065

MSVC reports "switch statement contains 'default' but no 'case' labels". 
Suppress,
as this was intended behavior.

Added: 


Modified: 
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp
index eb25a061de4e..1cb8b9c37031 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp
@@ -96,14 +96,22 @@ PlatformSP PlatformRemoteAppleBridge::CreateInstance(bool 
force,
 break;
   }
   if (create) {
+// Suppress warning "switch statement contains 'default' but no 'case' labels".
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4065)
+#endif
 switch (triple.getOS()) {
-// NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS: 
-  break;
+  // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
+  //  break;
 
 default:
   create = false;
   break;
 }
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
   }
 } break;
 default:



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


[Lldb-commits] [lldb] cc68c12 - [lldb/TestingSupport] Manually disable GTEST_HAS_TR1_TUPLE

2020-08-05 Thread Tatyana Krasnukha via lldb-commits

Author: Tatyana Krasnukha
Date: 2020-08-05T11:59:46+03:00
New Revision: cc68c122cd00f99037b8ff7e645e2b387d56da8b

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

LOG: [lldb/TestingSupport] Manually disable GTEST_HAS_TR1_TUPLE

Gtest 1.8.0 uses tr1::tuple which is deprecated on MSVC. We have to force it off
to avoid the compiler warnings, which will become errors after switching on 
C++17
(https://devblogs.microsoft.com/cppblog/c17-feature-removals-and-deprecations).

Added: 


Modified: 
lldb/unittests/TestingSupport/CMakeLists.txt

Removed: 




diff  --git a/lldb/unittests/TestingSupport/CMakeLists.txt 
b/lldb/unittests/TestingSupport/CMakeLists.txt
index 3b5662a16e33..5322362ed3a2 100644
--- a/lldb/unittests/TestingSupport/CMakeLists.txt
+++ b/lldb/unittests/TestingSupport/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Gtest 1.8.0 uses tr1/tuple which is deprecated on MSVC, so we force it off.
+add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
+
 set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL ON)
 add_lldb_library(lldbUtilityHelpers
   MockTildeExpressionResolver.cpp



___
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-05 Thread Luboš Luňák via Phabricator via lldb-commits
llunak added inline comments.



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

clayborg wrote:
> 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.
The idea is that it should ideally never happen, it's technically an internal 
error of not handling what Highlighter produces. In the discussion above I 
mentioned that I originally used assert(). So I don't see a real problem, if 
this actually happens then it shouldn't matter how it shows, and lldb already 
shows other such messages (which is BTW why Ctrl+L to redraw the screen was one 
of my first patches).





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);

clayborg wrote:
> 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.
D85286



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] D85286: [lldb][gui] use names for color pairs, instead of magic numbers

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

Change also SetBackground() calls.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D85286

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp

Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -273,6 +273,32 @@
   const char *description;
 };
 
+// COLOR_PAIR index names
+enum {
+  // First 16 colors are 8 black background and 8 blue background colors,
+  // needed by OutputColoredStringTruncated().
+  BlackOnBlack = 1,
+  RedOnBlack,
+  GreenOnBlack,
+  YellowOnBlack,
+  BlueOnBlack,
+  MagentaOnBlack,
+  CyanOnBlack,
+  WhiteOnBlack,
+  BlackOnBlue,
+  RedOnBlue,
+  GreenOnBlue,
+  YellowOnBlue,
+  BlueOnBlue,
+  MagentaOnBlue,
+  CyanOnBlue,
+  WhiteOnBlue,
+  // Other colors, as needed.
+  BlackOnWhite,
+  MagentaOnWhite,
+  LastColorPairIndex = MagentaOnWhite
+};
+
 class WindowDelegate {
 public:
   virtual ~WindowDelegate() = default;
@@ -462,7 +488,7 @@
 int saved_opts;
 ::wattr_get(m_window, &saved_attr, &saved_pair, &saved_opts);
 if (use_blue_background)
-  ::wattron(m_window, COLOR_PAIR(16));
+  ::wattron(m_window, COLOR_PAIR(WhiteOnBlue));
 while (!string.empty()) {
   size_t esc_pos = string.find('\x1b');
   if (esc_pos == StringRef::npos) {
@@ -498,7 +524,7 @@
   if (value == 0) { // Reset.
 ::wattr_set(m_window, saved_attr, saved_pair, &saved_opts);
 if (use_blue_background)
-  ::wattron(m_window, COLOR_PAIR(16));
+  ::wattron(m_window, COLOR_PAIR(WhiteOnBlue));
   } else {
 // Mapped directly to first 16 color pairs (black/blue background).
 ::wattron(m_window,
@@ -596,7 +622,7 @@
   void DrawTitleBox(const char *title, const char *bottom_message = nullptr) {
 attr_t attr = 0;
 if (IsActive())
-  attr = A_BOLD | COLOR_PAIR(18);
+  attr = A_BOLD | COLOR_PAIR(BlackOnWhite);
 else
   attr = 0;
 if (attr)
@@ -1026,14 +1052,14 @@
 
 if (m_key_name.empty()) {
   if (!underlined_shortcut && llvm::isPrint(m_key_value)) {
-window.AttributeOn(COLOR_PAIR(19));
+window.AttributeOn(COLOR_PAIR(MagentaOnWhite));
 window.Printf(" (%c)", m_key_value);
-window.AttributeOff(COLOR_PAIR(19));
+window.AttributeOff(COLOR_PAIR(MagentaOnWhite));
   }
 } else {
-  window.AttributeOn(COLOR_PAIR(19));
+  window.AttributeOn(COLOR_PAIR(MagentaOnWhite));
   window.Printf(" (%s)", m_key_name.c_str());
-  window.AttributeOff(COLOR_PAIR(19));
+  window.AttributeOff(COLOR_PAIR(MagentaOnWhite));
 }
   }
 }
@@ -1045,7 +1071,7 @@
   Menu::Type menu_type = GetType();
   switch (menu_type) {
   case Menu::Type::Bar: {
-window.SetBackground(18);
+window.SetBackground(BlackOnWhite);
 window.MoveCursor(0, 0);
 for (size_t i = 0; i < num_submenus; ++i) {
   Menu *menu = submenus[i].get();
@@ -1065,7 +1091,7 @@
 int cursor_x = 0;
 int cursor_y = 0;
 window.Erase();
-window.SetBackground(18);
+window.SetBackground(BlackOnWhite);
 window.Box();
 for (size_t i = 0; i < num_submenus; ++i) {
   const bool is_selected = (i == static_cast(selected_idx));
@@ -2440,7 +2466,7 @@
 
 attr_t changd_attr = 0;
 if (valobj->GetValueDidChange())
-  changd_attr = COLOR_PAIR(2) | A_BOLD;
+  changd_attr = COLOR_PAIR(RedOnBlack) | A_BOLD;
 
 if (value && value[0]) {
   window.PutCStringTruncated(1, " = ");
@@ -3309,7 +3335,7 @@
 Thread *thread = exe_ctx.GetThreadPtr();
 StackFrame *frame = exe_ctx.GetFramePtr();
 window.Erase();
-window.SetBackground(18);
+window.SetBackground(BlackOnWhite);
 window.MoveCursor(0, 0);
 if (process) {
   const StateType state = process->GetState();
@@ -3581,7 +3607,7 @@
   }
 
   const attr_t selected_highlight_attr = A_REVERSE;
-  const attr_t pc_highlight_attr = COLOR_PAIR(9);
+  const attr_t pc_highlight_attr = COLOR_PAIR(BlackOnBlue);
 
   for (size_t i = 0; i < num_visible_lines; ++i) {
 const uint32_t curr_line = m_first_visible_line + i;
@@ -3600,7 +3626,7 @@
 highlight_attr = selected_highlight_attr;
 
   if (bp_lines.find(curr_line + 1) != bp_lines.end())
-bp_attr = COLOR_PAIR(18);
+bp_attr = COLOR_PAIR(BlackOnWhite);
 
   if (bp_attr)
 window.AttributeOn(bp_attr);
@@ -3641,7 +3667,7 @@
   window.Printf("%*s", desc_x - window.GetCursorX(), "");
 window.MoveCursor(window_width - stop_description_len - 16,
   line_y);
-const attr_t stop_reason_attr = COLOR_PAIR(17);
+const attr_t stop_reason_attr = COLOR_PAIR(WhiteOnBlue);
 wind

[Lldb-commits] [lldb] 21f142c - [lldb] temporary commit to see why a test is failing only on lldb-aarch64-ubuntu

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

Author: Luboš Luňák
Date: 2020-08-05T11:54:14+02:00
New Revision: 21f142ce1df10fe6cf5721e263fc6e91aea93938

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

LOG: [lldb] temporary commit to see why a test is failing only on 
lldb-aarch64-ubuntu

Added: 


Modified: 
lldb/third_party/Python/module/pexpect-4.6/pexpect/pty_spawn.py

Removed: 




diff  --git a/lldb/third_party/Python/module/pexpect-4.6/pexpect/pty_spawn.py 
b/lldb/third_party/Python/module/pexpect-4.6/pexpect/pty_spawn.py
index 6b9ad3f63f7c..ca651659b461 100644
--- a/lldb/third_party/Python/module/pexpect-4.6/pexpect/pty_spawn.py
+++ b/lldb/third_party/Python/module/pexpect-4.6/pexpect/pty_spawn.py
@@ -212,8 +212,8 @@ def __str__(self):
 s.append(repr(self))
 s.append('command: ' + str(self.command))
 s.append('args: %r' % (self.args,))
-s.append('buffer (last 100 chars): %r' % self.buffer[-100:])
-s.append('before (last 100 chars): %r' % self.before[-100:] if 
self.before else '')
+s.append('buffer (last 100 chars): %r' % self.buffer[-1:])
+s.append('before (last 100 chars): %r' % self.before[-1:] if 
self.before else '')
 s.append('after: %r' % (self.after,))
 s.append('match: %r' % (self.match,))
 s.append('match_index: ' + str(self.match_index))



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


[Lldb-commits] [lldb] 1382819 - Revert "[lldb] temporary commit to see why a test is failing only on lldb-aarch64-ubuntu"

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

Author: Luboš Luňák
Date: 2020-08-05T11:55:02+02:00
New Revision: 138281904ba029bc49fca34a8658a8fcd1b843aa

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

LOG: Revert "[lldb] temporary commit to see why a test is failing only on 
lldb-aarch64-ubuntu"

This reverts commit 21f142ce1df10fe6cf5721e263fc6e91aea93938.

Added: 


Modified: 
lldb/third_party/Python/module/pexpect-4.6/pexpect/pty_spawn.py

Removed: 




diff  --git a/lldb/third_party/Python/module/pexpect-4.6/pexpect/pty_spawn.py 
b/lldb/third_party/Python/module/pexpect-4.6/pexpect/pty_spawn.py
index ca651659b461..6b9ad3f63f7c 100644
--- a/lldb/third_party/Python/module/pexpect-4.6/pexpect/pty_spawn.py
+++ b/lldb/third_party/Python/module/pexpect-4.6/pexpect/pty_spawn.py
@@ -212,8 +212,8 @@ def __str__(self):
 s.append(repr(self))
 s.append('command: ' + str(self.command))
 s.append('args: %r' % (self.args,))
-s.append('buffer (last 100 chars): %r' % self.buffer[-1:])
-s.append('before (last 100 chars): %r' % self.before[-1:] if 
self.before else '')
+s.append('buffer (last 100 chars): %r' % self.buffer[-100:])
+s.append('before (last 100 chars): %r' % self.before[-100:] if 
self.before else '')
 s.append('after: %r' % (self.after,))
 s.append('match: %r' % (self.match,))
 s.append('match_index: ' + str(self.match_index))



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


[Lldb-commits] [lldb] 188187f - [lldb] expect TestGuiBasicDebug.py failure on aarch64

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

Author: Luboš Luňák
Date: 2020-08-05T12:21:05+02:00
New Revision: 188187f062a56604a4339f16f139e3cc720ba2bd

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

LOG: [lldb] expect TestGuiBasicDebug.py failure on aarch64

http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/7287/steps/test/logs/stdio
fails, and the output suggests that gui 'finish' (='thread step-out') is broken
on aarch64.

Added: 


Modified: 
lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py

Removed: 




diff  --git a/lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py 
b/lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
index 76d9d3bdc463..5c3d0d7369b4 100644
--- a/lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
+++ b/lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
@@ -16,6 +16,7 @@ class TestGuiBasicDebugCommandTest(PExpectTest):
 @skipIfAsan
 @skipIfCursesSupportMissing
 @skipIfRemote # "run" command will not work correctly for remote debug
+@expectedFailureAll(archs=["aarch64"], oslist=["linux"])
 def test_gui(self):
 self.build()
 



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


[Lldb-commits] [lldb] 3ab0155 - Revert "[CMake] Simplify CMake handling for zlib"

2020-08-05 Thread Hans Wennborg via lldb-commits

Author: Hans Wennborg
Date: 2020-08-05T12:31:44+02:00
New Revision: 3ab01550b632dad46f9595d74855749557ffd25c

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

LOG: Revert "[CMake] Simplify CMake handling for zlib"

This quietly disabled use of zlib on Windows even when building with
-DLLVM_ENABLE_ZLIB=FORCE_ON.

> Rather than handling zlib handling manually, use find_package from CMake
> to find zlib properly. Use this to normalize the LLVM_ENABLE_ZLIB,
> HAVE_ZLIB, HAVE_ZLIB_H. Furthermore, require zlib if LLVM_ENABLE_ZLIB is
> set to YES, which requires the distributor to explicitly select whether
> zlib is enabled or not. This simplifies the CMake handling and usage in
> the rest of the tooling.
>
> This is a reland of abb0075 with all followup changes and fixes that
> should address issues that were reported in PR44780.
>
> Differential Revision: https://reviews.llvm.org/D79219

This reverts commit 10b1b4a231a485f1711d576e6131f6755e008abe and follow-ups
64d99cc6abed78c00a2a7863b02ce54911a5264f and
f9fec0447e12da9e8cf4b628f6d45f4941e7d182.

Added: 


Modified: 
clang/test/CMakeLists.txt
clang/test/lit.site.cfg.py.in
compiler-rt/test/lit.common.configured.in
lld/test/CMakeLists.txt
lld/test/lit.site.cfg.py.in
lldb/cmake/modules/LLDBStandalone.cmake
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
llvm/cmake/config-ix.cmake
llvm/cmake/modules/LLVMConfig.cmake.in
llvm/include/llvm/Config/config.h.cmake
llvm/lib/Support/CMakeLists.txt
llvm/lib/Support/CRC.cpp
llvm/lib/Support/Compression.cpp
llvm/test/CMakeLists.txt
llvm/test/lit.site.cfg.py.in
llvm/unittests/Support/CompressionTest.cpp
mlir/examples/standalone/CMakeLists.txt

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 334a90498d0d..38bbc5be90d5 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -9,6 +9,15 @@ endif ()
 
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR 
${LLVM_RUNTIME_OUTPUT_INTDIR})
 
+if(CLANG_BUILT_STANDALONE)
+  # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This
+  # value is forced to 0 if zlib was not found, so it is fine to use it
+  # instead of HAVE_LIBZ (not recorded).
+  if(LLVM_ENABLE_ZLIB)
+set(HAVE_LIBZ 1)
+  endif()
+endif()
+
 llvm_canonicalize_cmake_booleans(
   CLANG_BUILD_EXAMPLES
   CLANG_ENABLE_ARCMT
@@ -16,7 +25,7 @@ llvm_canonicalize_cmake_booleans(
   CLANG_SPAWN_CC1
   ENABLE_BACKTRACES
   ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
-  LLVM_ENABLE_ZLIB
+  HAVE_LIBZ
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
   LLVM_ENABLE_PLUGINS
   LLVM_ENABLE_THREADS)

diff  --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 286ea06d798c..d9b5b2f2592e 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -16,7 +16,7 @@ config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.host_cxx = "@CMAKE_CXX_COMPILER@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
-config.have_zlib = @LLVM_ENABLE_ZLIB@
+config.have_zlib = @HAVE_LIBZ@
 config.clang_arcmt = @CLANG_ENABLE_ARCMT@
 config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@

diff  --git a/compiler-rt/test/lit.common.configured.in 
b/compiler-rt/test/lit.common.configured.in
index 000bf9b98470..1f746c067b84 100644
--- a/compiler-rt/test/lit.common.configured.in
+++ b/compiler-rt/test/lit.common.configured.in
@@ -57,7 +57,7 @@ elif config.android:
 else:
   set_default("target_suffix", "-%s" % config.target_arch)
 
-set_default("have_zlib", "@LLVM_ENABLE_ZLIB@")
+set_default("have_zlib", "@HAVE_LIBZ@")
 set_default("libcxx_used", "@LLVM_LIBCXX_USED@")
 
 # LLVM tools dir can be passed in lit parameters, so try to

diff  --git a/lld/test/CMakeLists.txt b/lld/test/CMakeLists.txt
index 52e6118ba876..74b29f5d65b8 100644
--- a/lld/test/CMakeLists.txt
+++ b/lld/test/CMakeLists.txt
@@ -4,8 +4,17 @@ set(LLVM_BUILD_MODE "%(build_mode)s")
 set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s")
 set(LLVM_LIBS_DIR 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/%(build_config)s")
 
+if(LLD_BUILT_STANDALONE)
+  # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This
+  # value is forced to 0 if zlib was not found, so it is fine to use it
+  # instead of HAVE_LIBZ (not recorded).
+  if(LLVM_ENABLE_ZLIB)
+set(HAVE_LIBZ 1)
+  endif()
+endif()
+
 llvm_canonicalize_cmake_booleans(
-  LLVM_ENABLE_ZLIB
+  HAVE_LIBZ
   LLVM_LIBXML2_ENABLED
   )
 

diff  --git a/lld/test/lit.site.cfg.py.in b/lld/test/lit.site.cfg.py.in
index 3d4c51f4ab64..4aa2fcda7

[Lldb-commits] [PATCH] D85289: [DWARFYAML][debug_info] Rename some mapping keys. NFC.

2020-08-05 Thread Xing GUO via Phabricator via lldb-commits
Higuoxing created this revision.
Higuoxing added reviewers: jhenderson, grimar, MaskRay.
Herald added subscribers: llvm-commits, lldb-commits, cmtice, hiraditya, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: alexshap.
Herald added a reviewer: rupprecht.
Herald added projects: LLDB, LLVM.
Higuoxing requested review of this revision.
Herald added a subscriber: JDevlieghere.

This patch renames some mapping keys:

AbbrOffset -> DebugAbbrevOffset
AddrSize   -> AddressSize
AbbrCode   -> AbbrevCode


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85289

Files:
  lldb/test/API/functionalities/source-map/a.yaml
  lldb/unittests/Expression/DWARFExpressionTest.cpp
  lldb/unittests/Symbol/Inputs/inlined-functions.yaml
  lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
  lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp
  llvm/lib/ObjectYAML/DWARFYAML.cpp
  llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml
  llvm/test/ObjectYAML/MachO/DWARF-debug_line.yaml
  llvm/test/ObjectYAML/MachO/DWARF-debug_ranges.yaml
  llvm/test/ObjectYAML/MachO/DWARF2-AddrSize8-FormValues.yaml
  llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml
  llvm/test/tools/llvm-dwarfdump/X86/verify_overlapping_cu_ranges.yaml
  llvm/test/tools/llvm-gsymutil/ARM_AArch64/fat-macho-dwarf.yaml
  llvm/test/tools/llvm-gsymutil/X86/mach-dwarf.yaml
  llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-all-with-dwarf.yaml
  llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
  llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
  llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
  llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp

Index: llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
===
--- llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
+++ llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
@@ -1437,23 +1437,23 @@
 - Attribute:   DW_AT_high_pc
   Form:DW_FORM_addr
   debug_info:
-- Length:  52
-  Version: 4
-  AbbrOffset:  0
-  AddrSize:8
+- Length:52
+  Version:   4
+  DebugAbbrevOffset: 0
+  AddressSize:   8
   Entries:
-- AbbrCode:0x0001
+- AbbrevCode: 0x0001
   Values:
 - Value:   0x0001
 - Value:   0x1000
 - Value:   0x2000
 - Value:   0x0004
-- AbbrCode:0x0002
+- AbbrevCode: 0x0002
   Values:
 - Value:   0x000D
 - Value:   0x1000
 - Value:   0x2000
-- AbbrCode:0x
+- AbbrevCode: 0x
   Values:
   )";
   auto ErrOrSections = DWARFYAML::emitDebugSections(yamldata);
@@ -1516,23 +1516,23 @@
 - Attribute:   DW_AT_high_pc
   Form:DW_FORM_data4
   debug_info:
-- Length:  44
-  Version: 4
-  AbbrOffset:  0
-  AddrSize:8
+- Length:44
+  Version:   4
+  DebugAbbrevOffset: 0
+  AddressSize:   8
   Entries:
-- AbbrCode:0x0001
+- AbbrevCode: 0x0001
   Values:
 - Value:   0x0001
 - Value:   0x1000
 - Value:   0x1000
 - Value:   0x0004
-- AbbrCode:0x0002
+- AbbrevCode: 0x0002
   Values:
 - Value:   0x000D
 - Value:   0x1000
 - Value:   0x1000
-- AbbrCode:0x
+- AbbrevCode: 0x
   Values:
   )";
   auto ErrOrSections = DWARFYAML::emitDebugSections(yamldata);
@@ -1615,35 +1615,35 @@
 - Attribute:   DW_AT_artificial
   Form:DW_FORM_flag_present
   debug_info:
-- Length:  68
-  Version: 4
-  AbbrOffset:  0
-  AddrSize:8
+- Length:68
+  Version:   4
+  DebugAbbrevOffset: 0
+  AddressSize:   8
   Entries:
-- AbbrCode:0x0001
+- AbbrevCode: 0x0001
   Values:
 - Value:   0x0001
 - Value:   0x1000
 - Value:   0x2000
 - Value:   0x0004
-- AbbrCode:0x0002
+- AbbrevCode: 0x0002
   Values:
 - Value:   0x000D
-- AbbrCode:0x0003
+- AbbrevCode: 0x0003
   Values:
 - Value:   0x0011
 - Value:   0x1000
 - Valu

[Lldb-commits] [PATCH] D85289: [DWARFYAML][debug_info] Rename some mapping keys. NFC.

2020-08-05 Thread James Henderson via Phabricator via lldb-commits
jhenderson added a comment.

What's the motivation for doing this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85289

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


[Lldb-commits] [PATCH] D85290: [lldb][gui] use left/right in the source view to scroll

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

I intentionally decided not to reset the column automatically anywhere, because 
I don't know where and if at all that should happen. There should be always an 
indication of being scrolled (too much) to the right, so I'll leave this to 
whoever has an opinion.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D85290

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py

Index: lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py
===
--- lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py
+++ lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py
@@ -25,6 +25,9 @@
 self.expect("run", substrs=["stop reason ="])
 
 escape_key = chr(27).encode()
+left_key = chr(27)+'OD' # for vt100 terminal (lldbexpect sets TERM=vt100)
+right_key = chr(27)+'OC'
+ctrl_l = chr(12)
 
 # Start the GUI.
 self.child.sendline("gui")
@@ -44,6 +47,20 @@
 self.child.expect_exact("(int) a_variable_with_a_very_looo"+chr(27))
 self.child.expect_exact("(int) shortvar = 1"+chr(27))
 
+# Scroll the sources view twice to the right.
+self.child.send(right_key)
+self.child.send(right_key)
+# Force a redraw, otherwise curses will optimize the drawing to not draw all 'o'.
+self.child.send(ctrl_l)
+# The source code is indented by two spaces, so there'll be just two extra 'o' on the right.
+self.child.expect_exact("int a_variable_with_a_very_lo"+chr(27))
+
+# And scroll back to the left.
+self.child.send(left_key)
+self.child.send(left_key)
+self.child.send(ctrl_l)
+self.child.expect_exact("int a_variable_with_a_very_looo"+chr(27))
+
 # Press escape to quit the gui
 self.child.send(escape_key)
 
Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -480,24 +480,41 @@
 
   // 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,
+  // convert color escape sequences to curses color attributes. Use
+  // first_skip_count to skip leading visible characters. Returns false if all
+  // visible characters were skipped due to first_skip_count.
+  bool OutputColoredStringTruncated(int right_pad, StringRef string,
+size_t skip_first_count,
 bool use_blue_background) {
 attr_t saved_attr;
 short saved_pair;
 int saved_opts;
+bool result = false;
 ::wattr_get(m_window, &saved_attr, &saved_pair, &saved_opts);
 if (use_blue_background)
   ::wattron(m_window, COLOR_PAIR(WhiteOnBlue));
 while (!string.empty()) {
   size_t esc_pos = string.find('\x1b');
   if (esc_pos == StringRef::npos) {
-PutCStringTruncated(right_pad, string.data(), string.size());
+string = string.substr(skip_first_count);
+if (!string.empty()) {
+  PutCStringTruncated(right_pad, string.data(), string.size());
+  result = true;
+}
 break;
   }
   if (esc_pos > 0) {
-PutCStringTruncated(right_pad, string.data(), esc_pos);
-string = string.drop_front(esc_pos);
+if (skip_first_count > 0) {
+  int skip = std::min(esc_pos, skip_first_count);
+  string = string.substr(skip);
+  skip_first_count -= skip;
+  esc_pos -= skip;
+}
+if (esc_pos > 0) {
+  PutCStringTruncated(right_pad, string.data(), esc_pos);
+  result = true;
+  string = string.drop_front(esc_pos);
+}
   }
   bool consumed = string.consume_front("\x1b");
   assert(consumed);
@@ -532,6 +549,7 @@
   }
 }
 ::wattr_set(m_window, saved_attr, saved_pair, &saved_opts);
+return result;
   }
 
   void Touch() {
@@ -3380,7 +3398,8 @@
 m_disassembly_scope(nullptr), m_disassembly_sp(), m_disassembly_range(),
 m_title(), m_line_width(4), m_selected_line(0), m_pc_line(0),
 m_stop_id(0), m_frame_idx(UINT32_MAX), m_first_visible_line(0),
-m_min_x(0), m_min_y(0), m_max_x(0), m_max_y(0) {}
+m_first_visible_column(0), m_min_x(0), m_min_y(0), m_max_x(0),
+m_max_y(0) {}
 
   ~SourceFileWindowDelegate() override = default;
 
@@ -3397,6 +3416,8 @@
 {KEY_RETURN, "Run to selected line with one shot breakpoint"},
 {KEY_UP, "Selec

[Lldb-commits] [PATCH] D85289: [DWARFYAML][debug_info] Rename some mapping keys. NFC.

2020-08-05 Thread Xing GUO via Phabricator via lldb-commits
Higuoxing added a comment.

In D85289#2195954 , @jhenderson wrote:

> What's the motivation for doing this?

We should make these mapping keys' name consistent with the spec.
The spec uses 'address_size', 'debug_abbrev_offset', 'abbreviation code' to 
refer these fields.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85289

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


[Lldb-commits] [PATCH] D85289: [DWARFYAML][debug_info] Rename some mapping keys. NFC.

2020-08-05 Thread James Henderson via Phabricator via lldb-commits
jhenderson added a subscriber: labath.
jhenderson added a comment.

I see the point, but we don't do it for all fields in other contexts, and I 
have some mild concerns that `DebugAbbrevOffset` is unnecessarily verbose (I'd 
think `AbbrevOffset` would be sufficient. Perhaps it would be best to draw in 
one or two others? @JDevlieghere / @labath, any thoughts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85289

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


[Lldb-commits] [PATCH] D85289: [DWARFYAML][debug_info] Rename some mapping keys. NFC.

2020-08-05 Thread Xing GUO via Phabricator via lldb-commits
Higuoxing added a comment.

In D85289#2196062 , @jhenderson wrote:

> I see the point, but we don't do it for all fields in other contexts, and I 
> have some mild concerns that `DebugAbbrevOffset` is unnecessarily verbose 
> (I'd think `AbbrevOffset` would be sufficient. Perhaps it would be best to 
> draw in one or two others? @JDevlieghere / @labath, any thoughts?

Yeah, I'm ok with these names. I would like to hear more people's ideas!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85289

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


[Lldb-commits] [PATCH] D85322: [lldb/test] Replace LLDB_TEST_SRC env variable with configuration

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85322

Files:
  lldb/packages/Python/lldbsuite/test/configuration.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test/plugins/builder_base.py


Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -62,12 +62,11 @@
 
 # Construct the base make invocation.
 lldb_test = os.environ["LLDB_TEST"]
-lldb_test_src = os.environ["LLDB_TEST_SRC"]
-if not (lldb_test and lldb_test_src and configuration.test_build_dir and 
test_subdir and
+if not (lldb_test and configuration.test_build_dir and test_subdir and
 test_name and (not os.path.isabs(test_subdir))):
 raise Exception("Could not derive test directories")
 build_dir = os.path.join(configuration.test_build_dir, test_subdir, 
test_name)
-src_dir = os.path.join(lldb_test_src, test_subdir)
+src_dir = os.path.join(configuration.test_src_root, test_subdir)
 # This is a bit of a hack to make inline testcases work.
 makefile = os.path.join(src_dir, "Makefile")
 if not os.path.isfile(makefile):
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -496,7 +496,7 @@
 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:]
+rel_prefix = test_file[len(configuration.test_src_root) + 1:]
 return os.path.dirname(rel_prefix)
 
 def TraceOn(self):
@@ -520,15 +520,11 @@
 # Save old working directory.
 cls.oldcwd = os.getcwd()
 
-# Change current working directory if ${LLDB_TEST_SRC} is defined.
-# See also dotest.py which sets up ${LLDB_TEST_SRC}.
-if ("LLDB_TEST_SRC" in os.environ):
-full_dir = os.path.join(os.environ["LLDB_TEST_SRC"],
-cls.mydir)
-if traceAlways:
-print("Change dir to:", full_dir, file=sys.stderr)
-os.chdir(full_dir)
-lldb.SBReproducer.SetWorkingDirectory(full_dir)
+full_dir = os.path.join(configuration.test_src_root, cls.mydir)
+if traceAlways:
+print("Change dir to:", full_dir, file=sys.stderr)
+os.chdir(full_dir)
+lldb.SBReproducer.SetWorkingDirectory(full_dir)
 
 # Set platform context.
 cls.platformContext = lldbplatformutil.createPlatformContext()
@@ -662,7 +658,7 @@
 
 def getSourceDir(self):
 """Return the full path to the current test."""
-return os.path.join(os.environ["LLDB_TEST_SRC"], self.mydir)
+return os.path.join(configuration.test_src_root, self.mydir)
 
 def getBuildDirBasename(self):
 return self.__class__.__module__ + "." + self.testMethodName
@@ -1095,7 +1091,7 @@
 
 /--..
 """
-dname = os.path.join(os.environ["LLDB_TEST_SRC"],
+dname = os.path.join(configuration.test_src_root,
  os.environ["LLDB_SESSION_DIRNAME"])
 if not os.path.isdir(dname):
 os.mkdir(dname)
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -467,7 +467,6 @@
 sys.exit(-1)
 
 os.environ["LLDB_TEST"] = scriptPath
-os.environ["LLDB_TEST_SRC"] = lldbsuite.lldb_test_root
 
 # Set up the root build directory.
 if not configuration.test_build_dir:
Index: lldb/packages/Python/lldbsuite/test/configuration.py
===
--- lldb/packages/Python/lldbsuite/test/configuration.py
+++ lldb/packages/Python/lldbsuite/test/configuration.py
@@ -103,6 +103,10 @@
 # because it doesn't work under a debugger
 testdirs = [lldbsuite.lldb_test_root]
 
+# The root of the test case tree (where the actual tests reside, not the test
+# infrastructure).
+test_src_root = lldbsuite.lldb_test_root
+
 # Separator string.
 separator = '-' * 70
 


Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ lldb/packages/Python/lldbsuite/test/plugins/builde

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

2020-08-05 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht marked an inline comment as done.
rupprecht 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):

JDevlieghere wrote:
> While you are here... can you change this to pass the source directory trough 
> the `configuration`?
Absolutely, but in the spirit of small/isolated changes, split off as D85322.


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] D62732: [RISCV] Add SystemV ABI

2020-08-05 Thread Luís Marques via Phabricator via lldb-commits
luismarques added a comment.

In D62732#2193729 , @simoncook wrote:

> 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.

Yeah, I think that after the rebase this is nearly ready to land. The only 
additional suggestions I have at this point are:

- We should probably follow the convention and put the registers in 
`Plugins/Process/Utility/RegisterInfos_riscv.h`, like is done for other archs. 
If that isn't trivial I guess it could be a follow-up patch.
- Review the list of callee-saved registers. Aren't `x25` and `x26` missing?
- Nit: there's a typo in this patch that I missed in my rebased commit and 
should be corrected: "poinrter".
- I had renamed the `RISCVflags` members, if you use my rebased commit please 
check if you agree with that alternative.

> 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.

It is with debug information. I had been looking at other issues, but I'm going 
to look into this and I'll let you know what I find out.

> 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.

I agree, we can land this and provide follow-up patches. For my next steps I 
was looking into fixing the issues I was experiencing, if possible, and then 
implementing those TODOs. One of the issues I've diagnosed is that we need to 
add extra logic to handle RV32 vs RV64 based on the ELF header, like is done 
for MIPS, otherwise it incorrectly assumes RV32 when it should be RV64. I'll 
provide a follow-up patch.

Thanks for the feedback and the patch @simoncook!


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] [PATCH] D84780: Setting the /bigobj option globally for Windows debug build. https://bugs.llvm.org/show_bug.cgi?id=46733

2020-08-05 Thread Lei Zhang via Phabricator via lldb-commits
antiagainst accepted this revision.
antiagainst added a comment.
This revision is now accepted and ready to land.

LGTM for SPIR-V side.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84780

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


[Lldb-commits] [PATCH] D79219: [CMake] Simplify CMake handling for zlib

2020-08-05 Thread Hans Wennborg via Phabricator via lldb-commits
hans added a comment.

Reverted in 3ab01550b632dad46f9595d74855749557ffd25c 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79219

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


[Lldb-commits] [PATCH] D79219: [CMake] Simplify CMake handling for zlib

2020-08-05 Thread Hans Wennborg via Phabricator via lldb-commits
hans added a comment.

In D79219#2153585 , @phosek wrote:

> In D79219#2152747 , @labath wrote:
>
>> I wouldn't mind separate (internal) cache variable, though I am somewhat 
>> surprised by this problem. A (non-cache) variable set in one of the parent 
>> scopes should still take precedence over a cache variable with the same 
>> name. And since config-ix.cmake is included from the top CMakeLists.txt, the 
>> value it defines should be available everywhere. Was this a problem for the 
>> regular build, or only for some of the more exotic build setups that don't 
>> start with llvm/CMakeLists.txt ?
>
> Never mind, it's working as expected. The problem is that we disable zlib 
> detection on Windows which I missed before. I'm not sure why that's the case, 
> I tested this on Windows and it seems to be working fine, but for now I've 
> kept the existing behavior, we can consider enabling zlib on Windows in a 
> follow up change.

:-( We rely on zlib on Windows, and we pass -DLLVM_ENABLE_ZLIB=FORCE_ON to 
ensure that the build breaks if it can't be used for some reason.

It seems your change both disabled use of zlib on Windows, and also removed the 
check which made that an error when using FORCE_ON, which means we didn't catch 
this until further down the line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79219

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


[Lldb-commits] [PATCH] D84780: Setting the /bigobj option globally for Windows debug build. https://bugs.llvm.org/show_bug.cgi?id=46733

2020-08-05 Thread Michael Kruse via Phabricator via lldb-commits
Meinersbur added a comment.

Hasn't this already been done in 80bd6ae13ea23d453a1f45d6ccdbfc7d0c877bb0 
?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84780

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


[Lldb-commits] [PATCH] D85322: [lldb/test] Replace LLDB_TEST_SRC env variable with configuration

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

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85322

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


[Lldb-commits] [lldb] 3169d92 - Remove special Hexagon packet traversal code

2020-08-05 Thread Ted Woodward via lldb-commits

Author: Ted Woodward
Date: 2020-08-05T12:05:42-05:00
New Revision: 3169d920ccd16ec3c3e1bf5d91595b70a5278045

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

LOG: Remove special Hexagon packet traversal code

On Hexagon, breakpoints need to be on the first instruction of a packet.
When the LLVM disassembler for Hexagon returned 32 bit instructions, we
needed code to find the start of the current packet. Now that the LLVM
disassembler for Hexagon returns packets instead of instructions, we always
have the first instruction of the packet. Remove the packet traversal code
because it can cause problems when the next packet has more than one
instruction.

Reviewed By: clayborg

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

Added: 


Modified: 
lldb/include/lldb/Core/Disassembler.h
lldb/source/Core/Disassembler.cpp
lldb/source/Target/Process.cpp
lldb/source/Target/ThreadPlanStepRange.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Disassembler.h 
b/lldb/include/lldb/Core/Disassembler.h
index 926a74b933ef..d3b903b83c19 100644
--- a/lldb/include/lldb/Core/Disassembler.h
+++ b/lldb/include/lldb/Core/Disassembler.h
@@ -279,9 +279,6 @@ class InstructionList {
   /// @param[in] start
   /// The instruction index of the first instruction to check.
   ///
-  /// @param[in] target
-  /// A LLDB target object that is used to resolve addresses.
-  ///
   /// @param[in] ignore_calls
   /// It true, then fine the first branch instruction that isn't
   /// a function call (a branch that calls and returns to the next
@@ -298,7 +295,6 @@ class InstructionList {
   /// found.
   //--
   uint32_t GetIndexOfNextBranchInstruction(uint32_t start,
-   Target &target,
bool ignore_calls,
bool *found_calls) const;
 

diff  --git a/lldb/source/Core/Disassembler.cpp 
b/lldb/source/Core/Disassembler.cpp
index 4da823c7a243..cc98b7309d6d 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -990,17 +990,15 @@ void InstructionList::Append(lldb::InstructionSP 
&inst_sp) {
 
 uint32_t
 InstructionList::GetIndexOfNextBranchInstruction(uint32_t start,
- Target &target,
  bool ignore_calls,
  bool *found_calls) const {
   size_t num_instructions = m_instructions.size();
 
   uint32_t next_branch = UINT32_MAX;
-  size_t i;
   
   if (found_calls)
 *found_calls = false;
-  for (i = start; i < num_instructions; i++) {
+  for (size_t i = start; i < num_instructions; i++) {
 if (m_instructions[i]->DoesBranch()) {
   if (ignore_calls && m_instructions[i]->IsCall()) {
 if (found_calls)
@@ -1012,42 +1010,6 @@ 
InstructionList::GetIndexOfNextBranchInstruction(uint32_t start,
 }
   }
 
-  // Hexagon needs the first instruction of the packet with the branch. Go
-  // backwards until we find an instruction marked end-of-packet, or until we
-  // hit start.
-  if (target.GetArchitecture().GetTriple().getArch() == llvm::Triple::hexagon) 
{
-// If we didn't find a branch, find the last packet start.
-if (next_branch == UINT32_MAX) {
-  i = num_instructions - 1;
-}
-
-while (i > start) {
-  --i;
-
-  Status error;
-  uint32_t inst_bytes;
-  bool prefer_file_cache = false; // Read from process if process is 
running
-  lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
-  target.ReadMemory(m_instructions[i]->GetAddress(), prefer_file_cache,
-&inst_bytes, sizeof(inst_bytes), error, &load_addr);
-  // If we have an error reading memory, return start
-  if (!error.Success())
-return start;
-  // check if this is the last instruction in a packet bits 15:14 will be
-  // 11b or 00b for a duplex
-  if (((inst_bytes & 0xC000) == 0xC000) ||
-  ((inst_bytes & 0xC000) == 0x)) {
-// instruction after this should be the start of next packet
-next_branch = i + 1;
-break;
-  }
-}
-
-if (next_branch == UINT32_MAX) {
-  // We couldn't find the previous packet, so return start
-  next_branch = start;
-}
-  }
   return next_branch;
 }
 

diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 36a2930f7915..e88911ad7210 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -5947,10 +5947,8 @@ Process::AdvanceAddressToNextBranchInstruction(Address 
default_stop_addr,
 return retval;
   }
 
-  uint32_t br

[Lldb-commits] [PATCH] D84966: Remove special Hexagon packet traversal code

2020-08-05 Thread Ted Woodward via 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 rG3169d920ccd1: Remove special Hexagon packet traversal code 
(authored by ted).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84966

Files:
  lldb/include/lldb/Core/Disassembler.h
  lldb/source/Core/Disassembler.cpp
  lldb/source/Target/Process.cpp
  lldb/source/Target/ThreadPlanStepRange.cpp

Index: lldb/source/Target/ThreadPlanStepRange.cpp
===
--- lldb/source/Target/ThreadPlanStepRange.cpp
+++ lldb/source/Target/ThreadPlanStepRange.cpp
@@ -327,13 +327,9 @@
   if (instructions == nullptr)
 return false;
   else {
-Target &target = GetThread().GetProcess()->GetTarget();
 const bool ignore_calls = GetKind() == eKindStepOverRange;
-uint32_t branch_index =
-instructions->GetIndexOfNextBranchInstruction(pc_index, target,
-  ignore_calls, 
-  &m_found_calls);
-
+uint32_t branch_index = instructions->GetIndexOfNextBranchInstruction(
+pc_index, ignore_calls, &m_found_calls);
 Address run_to_address;
 
 // If we didn't find a branch, run to the end of the range.
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -5947,10 +5947,8 @@
 return retval;
   }
 
-  uint32_t branch_index =
-  insn_list->GetIndexOfNextBranchInstruction(insn_offset, target,
- false /* ignore_calls*/,
- nullptr);
+  uint32_t branch_index = insn_list->GetIndexOfNextBranchInstruction(
+  insn_offset, false /* ignore_calls*/, nullptr);
   if (branch_index == UINT32_MAX) {
 return retval;
   }
Index: lldb/source/Core/Disassembler.cpp
===
--- lldb/source/Core/Disassembler.cpp
+++ lldb/source/Core/Disassembler.cpp
@@ -990,17 +990,15 @@
 
 uint32_t
 InstructionList::GetIndexOfNextBranchInstruction(uint32_t start,
- Target &target,
  bool ignore_calls,
  bool *found_calls) const {
   size_t num_instructions = m_instructions.size();
 
   uint32_t next_branch = UINT32_MAX;
-  size_t i;
   
   if (found_calls)
 *found_calls = false;
-  for (i = start; i < num_instructions; i++) {
+  for (size_t i = start; i < num_instructions; i++) {
 if (m_instructions[i]->DoesBranch()) {
   if (ignore_calls && m_instructions[i]->IsCall()) {
 if (found_calls)
@@ -1012,42 +1010,6 @@
 }
   }
 
-  // Hexagon needs the first instruction of the packet with the branch. Go
-  // backwards until we find an instruction marked end-of-packet, or until we
-  // hit start.
-  if (target.GetArchitecture().GetTriple().getArch() == llvm::Triple::hexagon) {
-// If we didn't find a branch, find the last packet start.
-if (next_branch == UINT32_MAX) {
-  i = num_instructions - 1;
-}
-
-while (i > start) {
-  --i;
-
-  Status error;
-  uint32_t inst_bytes;
-  bool prefer_file_cache = false; // Read from process if process is running
-  lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
-  target.ReadMemory(m_instructions[i]->GetAddress(), prefer_file_cache,
-&inst_bytes, sizeof(inst_bytes), error, &load_addr);
-  // If we have an error reading memory, return start
-  if (!error.Success())
-return start;
-  // check if this is the last instruction in a packet bits 15:14 will be
-  // 11b or 00b for a duplex
-  if (((inst_bytes & 0xC000) == 0xC000) ||
-  ((inst_bytes & 0xC000) == 0x)) {
-// instruction after this should be the start of next packet
-next_branch = i + 1;
-break;
-  }
-}
-
-if (next_branch == UINT32_MAX) {
-  // We couldn't find the previous packet, so return start
-  next_branch = start;
-}
-  }
   return next_branch;
 }
 
Index: lldb/include/lldb/Core/Disassembler.h
===
--- lldb/include/lldb/Core/Disassembler.h
+++ lldb/include/lldb/Core/Disassembler.h
@@ -279,9 +279,6 @@
   /// @param[in] start
   /// The instruction index of the first instruction to check.
   ///
-  /// @param[in] target
-  /// A LLDB target object that is used to resolve addresses.
-  ///
   /// @param[in] ignore_calls
   /// It true, then fine the first branch instruction that isn't
   /// a function call (a branch that calls and returns to the next
@@ -298,7 +295,6 @@
  

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

2020-08-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG882d8e60dd40: [lldb] Make SBTarget::LaunchSimple start form 
the target's LaunchInfo (authored by JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D85235?vs=283136&id=283283#toc

Repository:
  rG LLVM Github Monorepo

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] D85237: [lldb] Add an option to inherit TCC permissions from parent.

2020-08-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG249a1d4f1bed: [lldb] Add an option to inherit TCC 
permissions from parent. (authored by JDevlieghere).

Repository:
  rG LLVM Github Monorepo

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(eLaunchFlagInheri

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

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

Author: Jonas Devlieghere
Date: 2020-08-05T10:08:28-07:00
New Revision: 882d8e60dd40c01c74b4e16b02cf7ca02e846434

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

LOG: [lldb] Make SBTarget::LaunchSimple start form the target's LaunchInfo

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.

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

Added: 


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

Removed: 




diff  --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index b84e9f10fafe..04540a2fab43 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -287,16 +287,24 @@ SBProcess SBTarget::LaunchSimple(char const **argv, char 
const **envp,
  (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() {

diff  --git a/lldb/test/API/python_api/target/TestTargetAPI.py 
b/lldb/test/API/python_api/target/TestTargetAPI.py
index 016754720c8c..f6b349bd6a3d 100644
--- a/lldb/test/API/python_api/target/TestTargetAPI.py
+++ b/lldb/test/API/python_api/target/TestTargetAPI.py
@@ -150,6 +150,38 @@ def test_read_memory(self):
 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)

diff  --git a/lldb/test/API/python_api/target/main.c 
b/lldb/test/API/python_api/target/main.c
index 7724fa74d9ef..0949c1550a9f 100644
--- a/lldb/test/API/python_api/target/main.c
+++ b/lldb/test/API/python_api/target/main.c
@@ -36,17 +36,24 @@ int c(int val)
 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]);
+}
+
+ 

[Lldb-commits] [lldb] 249a1d4 - [lldb] Add an option to inherit TCC permissions from parent.

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

Author: Jonas Devlieghere
Date: 2020-08-05T10:08:28-07:00
New Revision: 249a1d4f1bed2f2be5781a90b5d4bce8791d338b

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

LOG: [lldb] Add an option to inherit TCC permissions from parent.

Add an option that allows the user to decide to not make the inferior is
responsible for its own TCC permissions. If you don't make the inferior
responsible, it inherits the permissions of its parent. 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. When the permissions are inherited,
approval needs to be granted only once.

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

Added: 


Modified: 
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

Removed: 




diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index c12c68d292b8..92904682ffb6 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -93,6 +93,10 @@ class TargetProperties : public Properties {
 
   void SetDisableASLR(bool b);
 
+  bool GetInheritTCC() const;
+
+  void SetInheritTCC(bool b);
+
   bool GetDetachOnError() const;
 
   void SetDetachOnError(bool b);
@@ -225,6 +229,7 @@ class TargetProperties : public Properties {
   void ErrorPathValueChangedCallback();
   void DetachOnErrorValueChangedCallback();
   void DisableASLRValueChangedCallback();
+  void InheritTCCValueChangedCallback();
   void DisableSTDIOValueChangedCallback();
 
   Environment ComputeEnvironment() const;

diff  --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 051289de439d..107c3ffe8f95 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -126,6 +126,9 @@ FLAGS_ENUM(LaunchFlags){
 eLaunchFlagShellExpandArguments =
 (1u << 10), ///< Perform shell-style argument expansion
 eLaunchFlagCloseTTYOnExit = (1u << 11), ///< Close the open TTY on exit
+eLaunchFlagInheritTCCFromParent =
+(1u << 12), ///< Don't make the inferior responsible for its own TCC
+///< permissions but instead inherit them from its parent.
 };
 
 /// Thread Run Modes.

diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index e4bf6eb569cf..85d2bed25841 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -717,6 +717,9 @@ def setUpCommands(cls):
 # 
diff er in the debug info, which is not being hashed.
 "settings set symbols.enable-external-lookup false",
 
+# Inherit the TCC permissions from the inferior's parent.
+"settings set target.inherit-tcc true",
+
 # Disable fix-its by default so that incorrect expressions in 
tests don't
 # pass just because Clang thinks it has a fix-it.
 "settings set target.auto-apply-fixits false",

diff  --git a/lldb/source/Commands/CommandObjectProcess.cpp 
b/lldb/source/Commands/CommandObjectProcess.cpp
index fd8d38e85637..a5df62f23345 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -184,6 +184,9 @@ class CommandObjectProcessLaunch : public 
CommandObjectProcessLaunchOrAttach {
 else
   m_options.launch_info.GetFlags().Clear(eLaunchFlagDisableASLR);
 
+if (target->GetInheritTCC())
+  m_options.launch_info.GetFlags().Set(eLaunchFlagInheritTCCFromParent);
+
 if (target->GetDetachOnError())
   m_options.launch_info.GetFlags().Set(eLaunchFlagDetachOnError);
 

diff  --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index 398652ae30d8..faac6f59190a 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -1095,10 +1095,11 @@ static Status LaunchProcessPosixSpawn(const char 
*exe_path,
 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 

[Lldb-commits] [lldb] f425c04 - [lldb/test] Replace LLDB_TEST_SRC env variable with configuration

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

Author: Jordan Rupprecht
Date: 2020-08-05T10:19:21-07:00
New Revision: f425c0442c3ef137f2c4ab5eebd3d39036b09d70

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

LOG: [lldb/test] Replace LLDB_TEST_SRC env variable with configuration

Reviewed By: JDevlieghere

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

Added: 


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

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/configuration.py 
b/lldb/packages/Python/lldbsuite/test/configuration.py
index 84de0130f990..251787b940e3 100644
--- a/lldb/packages/Python/lldbsuite/test/configuration.py
+++ b/lldb/packages/Python/lldbsuite/test/configuration.py
@@ -103,6 +103,10 @@
 # because it doesn't work under a debugger
 testdirs = [lldbsuite.lldb_test_root]
 
+# The root of the test case tree (where the actual tests reside, not the test
+# infrastructure).
+test_src_root = lldbsuite.lldb_test_root
+
 # Separator string.
 separator = '-' * 70
 

diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index f43685c069e4..f84bda68d951 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -467,7 +467,6 @@ def setupSysPath():
 sys.exit(-1)
 
 os.environ["LLDB_TEST"] = scriptPath
-os.environ["LLDB_TEST_SRC"] = lldbsuite.lldb_test_root
 
 # Set up the root build directory.
 if not configuration.test_build_dir:

diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 85d2bed25841..fe501f6ac6a2 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -496,7 +496,7 @@ def compute_mydir(test_file):
 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:]
+rel_prefix = test_file[len(configuration.test_src_root) + 1:]
 return os.path.dirname(rel_prefix)
 
 def TraceOn(self):
@@ -520,15 +520,11 @@ def setUpClass(cls):
 # Save old working directory.
 cls.oldcwd = os.getcwd()
 
-# Change current working directory if ${LLDB_TEST_SRC} is defined.
-# See also dotest.py which sets up ${LLDB_TEST_SRC}.
-if ("LLDB_TEST_SRC" in os.environ):
-full_dir = os.path.join(os.environ["LLDB_TEST_SRC"],
-cls.mydir)
-if traceAlways:
-print("Change dir to:", full_dir, file=sys.stderr)
-os.chdir(full_dir)
-lldb.SBReproducer.SetWorkingDirectory(full_dir)
+full_dir = os.path.join(configuration.test_src_root, cls.mydir)
+if traceAlways:
+print("Change dir to:", full_dir, file=sys.stderr)
+os.chdir(full_dir)
+lldb.SBReproducer.SetWorkingDirectory(full_dir)
 
 # Set platform context.
 cls.platformContext = lldbplatformutil.createPlatformContext()
@@ -662,7 +658,7 @@ def clean_working_directory():
 
 def getSourceDir(self):
 """Return the full path to the current test."""
-return os.path.join(os.environ["LLDB_TEST_SRC"], self.mydir)
+return os.path.join(configuration.test_src_root, self.mydir)
 
 def getBuildDirBasename(self):
 return self.__class__.__module__ + "." + self.testMethodName
@@ -1098,7 +1094,7 @@ def getLogBasenameForCurrentTest(self, prefix=None):
 
 /--..
 """
-dname = os.path.join(os.environ["LLDB_TEST_SRC"],
+dname = os.path.join(configuration.test_src_root,
  os.environ["LLDB_SESSION_DIRNAME"])
 if not os.path.isdir(dname):
 os.mkdir(dname)

diff  --git a/lldb/packages/Python/lldbsuite/test/plugins/builder_base.py 
b/lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
index 0cff6655ed77..4d355d9d8805 100644
--- a/lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ b/lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -62,12 +62,11 @@ def getMake(test_subdir, test_name):
 
 # Construct the base make invocation.
 lldb_test = os.environ["LLDB_TEST"]
-lldb_test_src = os.environ["LLDB_TEST_SRC"]
-if not (lldb_test and lldb_test_src and configuration.test_build_dir and 
test_subdir and
+if not (lldb_test and configuration.test_build_dir and test_subdir and
 test_name and (not os.path.isabs(test_subdir))):
 raise 

[Lldb-commits] [PATCH] D85322: [lldb/test] Replace LLDB_TEST_SRC env variable with configuration

2020-08-05 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf425c0442c3e: [lldb/test] Replace LLDB_TEST_SRC env variable 
with configuration (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85322

Files:
  lldb/packages/Python/lldbsuite/test/configuration.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test/plugins/builder_base.py


Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -62,12 +62,11 @@
 
 # Construct the base make invocation.
 lldb_test = os.environ["LLDB_TEST"]
-lldb_test_src = os.environ["LLDB_TEST_SRC"]
-if not (lldb_test and lldb_test_src and configuration.test_build_dir and 
test_subdir and
+if not (lldb_test and configuration.test_build_dir and test_subdir and
 test_name and (not os.path.isabs(test_subdir))):
 raise Exception("Could not derive test directories")
 build_dir = os.path.join(configuration.test_build_dir, test_subdir, 
test_name)
-src_dir = os.path.join(lldb_test_src, test_subdir)
+src_dir = os.path.join(configuration.test_src_root, test_subdir)
 # This is a bit of a hack to make inline testcases work.
 makefile = os.path.join(src_dir, "Makefile")
 if not os.path.isfile(makefile):
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -496,7 +496,7 @@
 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:]
+rel_prefix = test_file[len(configuration.test_src_root) + 1:]
 return os.path.dirname(rel_prefix)
 
 def TraceOn(self):
@@ -520,15 +520,11 @@
 # Save old working directory.
 cls.oldcwd = os.getcwd()
 
-# Change current working directory if ${LLDB_TEST_SRC} is defined.
-# See also dotest.py which sets up ${LLDB_TEST_SRC}.
-if ("LLDB_TEST_SRC" in os.environ):
-full_dir = os.path.join(os.environ["LLDB_TEST_SRC"],
-cls.mydir)
-if traceAlways:
-print("Change dir to:", full_dir, file=sys.stderr)
-os.chdir(full_dir)
-lldb.SBReproducer.SetWorkingDirectory(full_dir)
+full_dir = os.path.join(configuration.test_src_root, cls.mydir)
+if traceAlways:
+print("Change dir to:", full_dir, file=sys.stderr)
+os.chdir(full_dir)
+lldb.SBReproducer.SetWorkingDirectory(full_dir)
 
 # Set platform context.
 cls.platformContext = lldbplatformutil.createPlatformContext()
@@ -662,7 +658,7 @@
 
 def getSourceDir(self):
 """Return the full path to the current test."""
-return os.path.join(os.environ["LLDB_TEST_SRC"], self.mydir)
+return os.path.join(configuration.test_src_root, self.mydir)
 
 def getBuildDirBasename(self):
 return self.__class__.__module__ + "." + self.testMethodName
@@ -1098,7 +1094,7 @@
 
 /--..
 """
-dname = os.path.join(os.environ["LLDB_TEST_SRC"],
+dname = os.path.join(configuration.test_src_root,
  os.environ["LLDB_SESSION_DIRNAME"])
 if not os.path.isdir(dname):
 os.mkdir(dname)
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -467,7 +467,6 @@
 sys.exit(-1)
 
 os.environ["LLDB_TEST"] = scriptPath
-os.environ["LLDB_TEST_SRC"] = lldbsuite.lldb_test_root
 
 # Set up the root build directory.
 if not configuration.test_build_dir:
Index: lldb/packages/Python/lldbsuite/test/configuration.py
===
--- lldb/packages/Python/lldbsuite/test/configuration.py
+++ lldb/packages/Python/lldbsuite/test/configuration.py
@@ -103,6 +103,10 @@
 # because it doesn't work under a debugger
 testdirs = [lldbsuite.lldb_test_root]
 
+# The root of the test case tree (where the actual tests reside, not the test
+# infrastructure).
+test_src_root = lldbsuite.lldb_test_root
+
 # Separator string.
 separator = '-' * 70
 


Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- lldb/packages/Python/lldbsuite/test/plug

[Lldb-commits] [lldb] fcb0d81 - [lldb/test] Use realpath consistently for test root file paths.

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

Author: Jordan Rupprecht
Date: 2020-08-05T11:35:37-07:00
New Revision: fcb0d8163a4f3090cb85d77b459887cf1f84cc7e

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

LOG: [lldb/test] Use realpath consistently for test root file paths.

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.

Reviewed By: JDevlieghere

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

Added: 


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

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/__init__.py 
b/lldb/packages/Python/lldbsuite/__init__.py
index 62f6aee71f30..dfe2eec8eac5 100644
--- a/lldb/packages/Python/lldbsuite/__init__.py
+++ b/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('/') == '/'

diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index fe501f6ac6a2..8823112a6e20 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -496,8 +496,12 @@ def compute_mydir(test_file):
 mydir = TestBase.compute_mydir(__file__)
 '''
 # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir
-rel_prefix = test_file[len(configuration.test_src_root) + 1:]
-return os.path.dirname(rel_prefix)
+lldb_test_src = configuration.test_src_root
+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)."""

diff  --git a/lldb/test/API/use_lldb_suite.py b/lldb/test/API/use_lldb_suite.py
index f1edf1d7304f..613fac40aeb7 100644
--- a/lldb/test/API/use_lldb_suite.py
+++ b/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('/') == '/'



___
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-05 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
rupprecht marked an inline comment as done.
Closed by commit rGfcb0d8163a4f: [lldb/test] Use realpath consistently for test 
root file paths. (authored by rupprecht).

Changed prior to commit:
  https://reviews.llvm.org/D85258?vs=283060&id=283316#toc

Repository:
  rG LLVM Github Monorepo

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

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(configuration.test_src_root) + 1:]
-return os.path.dirname(rel_prefix)
+lldb_test_src = configuration.test_src_root
+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(configuration.test_src_root) + 1:]
-return os.path.dirname(rel_prefix)
+lldb_test_src = configuration.test_src_root
+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('/') == '/'
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 1dbac09 - [lldb/test] Support git commit version ids for clang.

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

Author: Jordan Rupprecht
Date: 2020-08-05T13:16:01-07:00
New Revision: 1dbac09dd6ec8587ae7e16ed669bf73889a21957

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

LOG: [lldb/test] Support git commit version ids for clang.

`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.

Reviewed By: MaskRay

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

Added: 


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

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 8823112a6e20..cc651e5b061d 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1325,25 +1325,35 @@ def expectedCompilerVersion(self, compiler_version):
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."""



___
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-05 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1dbac09dd6ec: [lldb/test] Support git commit version ids for 
clang. (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

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
@@ -1325,25 +1325,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
@@ -1325,25 +1325,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_

[Lldb-commits] [PATCH] D85358: Correctly detect legacy iOS simulator Mach-O objectfiles

2020-08-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: friss, jasonmolenda.
aprantl requested review of this revision.

The code in ObjectFileMachO didn't disambiguate between ios and ios-simulator 
object files for Mach-O objects using the legacy ambiguous LC_VERSION_MIN load 
commands. This used to not matter before taught ArchSpec that ios and 
ios-simulator are no longer compatible.

rdar://problem/66545307


https://reviews.llvm.org/D85358

Files:
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Utility/ArchSpec.cpp
  lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
  lldb/unittests/Utility/ArchSpecTest.cpp

Index: lldb/unittests/Utility/ArchSpecTest.cpp
===
--- lldb/unittests/Utility/ArchSpecTest.cpp
+++ lldb/unittests/Utility/ArchSpecTest.cpp
@@ -305,6 +305,25 @@
 ArchSpec B("x86_64-apple-ios-simulator");
 ASSERT_FALSE(A.IsExactMatch(B));
 ASSERT_FALSE(A.IsCompatibleMatch(B));
+ASSERT_FALSE(B.IsExactMatch(A));
+ASSERT_FALSE(B.IsCompatibleMatch(A));
+  }
+  {
+ArchSpec A("x86_64-apple-ios");
+ArchSpec B("x86_64-apple-ios-simulator");
+ASSERT_FALSE(A.IsExactMatch(B));
+ASSERT_FALSE(A.IsCompatibleMatch(B));
+ASSERT_FALSE(B.IsExactMatch(A));
+ASSERT_FALSE(B.IsCompatibleMatch(A));
+  }
+  {
+// FIXME: This is surprisingly not equivalent to "x86_64-*-*".
+ArchSpec A("x86_64");
+ArchSpec B("x86_64-apple-ios-simulator");
+ASSERT_FALSE(A.IsExactMatch(B));
+ASSERT_TRUE(A.IsCompatibleMatch(B));
+ASSERT_FALSE(B.IsExactMatch(A));
+ASSERT_TRUE(B.IsCompatibleMatch(A));
   }
   {
 ArchSpec A("arm64-apple-ios");
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,6 @@
 import unittest2
 
 
-@skipIfDarwin # rdar://problem/64552748
 class TestSimulatorPlatformLaunching(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
Index: lldb/source/Utility/ArchSpec.cpp
===
--- lldb/source/Utility/ArchSpec.cpp
+++ lldb/source/Utility/ArchSpec.cpp
@@ -1057,20 +1057,6 @@
   return true;
   }
 
-  if (lhs_triple_os != rhs_triple_os) {
-const bool rhs_os_specified = rhs.TripleOSWasSpecified();
-const bool lhs_os_specified = TripleOSWasSpecified();
-// Both architectures had the OS specified, so if they aren't equal then
-// we return false
-if (rhs_os_specified && lhs_os_specified)
-  return false;
-
-// Only fail if both os types are not unknown
-if (lhs_triple_os != llvm::Triple::UnknownOS &&
-rhs_triple_os != llvm::Triple::UnknownOS)
-  return false;
-  }
-
   // x86_64-apple-ios-macabi and x86_64-apple-ios are not compatible.
   if (lhs_triple_os == llvm::Triple::IOS &&
   rhs_triple_os == llvm::Triple::IOS &&
@@ -1079,6 +1065,19 @@
   lhs_triple_env != rhs_triple_env)
 return false;
 
+  if (lhs_triple_os != rhs_triple_os) {
+const bool lhs_os_specified = TripleOSWasSpecified();
+const bool rhs_os_specified = rhs.TripleOSWasSpecified();
+// If both OS types are specified and different, fail.
+if (lhs_os_specified && rhs_os_specified)
+  return false;
+
+// If the pair of os+env is both unspecified, match any other os+env combo.
+if (!exact_match && ((!lhs_os_specified && !lhs_triple.hasEnvironment()) ||
+ (!rhs_os_specified && !rhs_triple.hasEnvironment(
+  return true;
+  }
+
   return IsCompatibleEnvironment(lhs_triple_env, rhs_triple_env);
 }
 
Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -5024,7 +5024,18 @@
 
   auto triple = base_triple;
   triple.setOSName(os.str());
-  os_name.clear();
+
+  // Disambiguate legacy simulator platforms.
+  if (base_triple.getArch() == llvm::Triple::x86_64 ||
+  base_triple.getArch() == llvm::Triple::x86) {
+// The combination of legacy LC_VERSION_MIN load command and
+// x86 architecture always indicates a simulator environment.
+// The combination of LC_VERSION_MIN and arm architecture only
+// appears for native binaries. Back-deploying simulator
+// binaries on Apple Silicon Macs use the modern unambigous
+// LC_BUILD_VERSION load commands; no special handling required.
+triple.setEnvironment(llvm::Triple::Simulator);
+  }
   add_triple(triple);
   break;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commi

[Lldb-commits] [PATCH] D85358: Correctly detect legacy iOS simulator Mach-O objectfiles

2020-08-05 Thread Frederic Riss via Phabricator via lldb-commits
friss added inline comments.



Comment at: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp:5029-5030
+  // Disambiguate legacy simulator platforms.
+  if (base_triple.getArch() == llvm::Triple::x86_64 ||
+  base_triple.getArch() == llvm::Triple::x86) {
+// The combination of legacy LC_VERSION_MIN load command and

It seems like this will also mark a binary with `LC_VERSION_MIN_MACOSX` as a 
simulator binary?


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

https://reviews.llvm.org/D85358

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


[Lldb-commits] [PATCH] D85358: Correctly detect legacy iOS simulator Mach-O objectfiles

2020-08-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 283401.
aprantl added a comment.

Excellent point, Fred!


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

https://reviews.llvm.org/D85358

Files:
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Utility/ArchSpec.cpp
  lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
  lldb/unittests/Utility/ArchSpecTest.cpp

Index: lldb/unittests/Utility/ArchSpecTest.cpp
===
--- lldb/unittests/Utility/ArchSpecTest.cpp
+++ lldb/unittests/Utility/ArchSpecTest.cpp
@@ -305,6 +305,25 @@
 ArchSpec B("x86_64-apple-ios-simulator");
 ASSERT_FALSE(A.IsExactMatch(B));
 ASSERT_FALSE(A.IsCompatibleMatch(B));
+ASSERT_FALSE(B.IsExactMatch(A));
+ASSERT_FALSE(B.IsCompatibleMatch(A));
+  }
+  {
+ArchSpec A("x86_64-apple-ios");
+ArchSpec B("x86_64-apple-ios-simulator");
+ASSERT_FALSE(A.IsExactMatch(B));
+ASSERT_FALSE(A.IsCompatibleMatch(B));
+ASSERT_FALSE(B.IsExactMatch(A));
+ASSERT_FALSE(B.IsCompatibleMatch(A));
+  }
+  {
+// FIXME: This is surprisingly not equivalent to "x86_64-*-*".
+ArchSpec A("x86_64");
+ArchSpec B("x86_64-apple-ios-simulator");
+ASSERT_FALSE(A.IsExactMatch(B));
+ASSERT_TRUE(A.IsCompatibleMatch(B));
+ASSERT_FALSE(B.IsExactMatch(A));
+ASSERT_TRUE(B.IsCompatibleMatch(A));
   }
   {
 ArchSpec A("arm64-apple-ios");
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,6 @@
 import unittest2
 
 
-@skipIfDarwin # rdar://problem/64552748
 class TestSimulatorPlatformLaunching(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
@@ -41,14 +40,14 @@
 
 
 def run_with(self, arch, os, vers, env, expected_load_command):
-self.build(dictionary={'TRIPLE': arch+'-apple-'+os+vers+'-'+env})
+triple = '-'.join([arch, 'apple', os + vers] + (env if env else []))
+self.build(dictionary={'TRIPLE': triple})
 self.check_load_commands(expected_load_command)
 log = self.getBuildArtifact('packets.log')
 self.expect("log enable gdb-remote packets -f "+log)
 lldbutil.run_to_source_breakpoint(self, "break here",
   lldb.SBFileSpec("hello.c"))
-self.expect('image list -b -t',
-patterns=['a\.out '+arch+'-apple-'+os+vers+'.*-'+env])
+self.expect('image list -b -t', patterns=['a\.out '+triple])
 self.check_debugserver(log, os+env, vers)
 
 @skipUnlessDarwin
@@ -101,6 +100,13 @@
 # macOS, however, these legacy load commands are never generated.
 #
 
+@skipUnlessDarwin
+@skipIfDarwinEmbedded
+def test_lc_version_min_macosx(self):
+"""Test running a back-deploying non-simulator MacOS X binary"""
+self.run_with(arch=self.getArchitecture(),
+  os='macosx', vers='10.9', env='',
+  expected_load_command='LC_VERSION_MIN_MACOSX')
 @skipUnlessDarwin
 @skipIfDarwinEmbedded
 @apple_simulator_test('iphone')
Index: lldb/source/Utility/ArchSpec.cpp
===
--- lldb/source/Utility/ArchSpec.cpp
+++ lldb/source/Utility/ArchSpec.cpp
@@ -1057,20 +1057,6 @@
   return true;
   }
 
-  if (lhs_triple_os != rhs_triple_os) {
-const bool rhs_os_specified = rhs.TripleOSWasSpecified();
-const bool lhs_os_specified = TripleOSWasSpecified();
-// Both architectures had the OS specified, so if they aren't equal then
-// we return false
-if (rhs_os_specified && lhs_os_specified)
-  return false;
-
-// Only fail if both os types are not unknown
-if (lhs_triple_os != llvm::Triple::UnknownOS &&
-rhs_triple_os != llvm::Triple::UnknownOS)
-  return false;
-  }
-
   // x86_64-apple-ios-macabi and x86_64-apple-ios are not compatible.
   if (lhs_triple_os == llvm::Triple::IOS &&
   rhs_triple_os == llvm::Triple::IOS &&
@@ -1079,6 +1065,19 @@
   lhs_triple_env != rhs_triple_env)
 return false;
 
+  if (lhs_triple_os != rhs_triple_os) {
+const bool lhs_os_specified = TripleOSWasSpecified();
+const bool rhs_os_specified = rhs.TripleOSWasSpecified();
+// If both OS types are specified and different, fail.
+if (lhs_os_specified && rhs_os_specified)
+  return false;
+
+// If the pair of os+env is both unspecified, match any other os+env combo.
+if (!exact_match && ((!lhs_os_specified && !lhs_triple.hasEnvironment()) ||
+ (!rhs_os_specified && !rhs_triple.hasEnvironment(
+  return true;
+  }
+
   return IsCompatibleEnvironment(lhs_triple_env, rhs_triple_env);
 }
 
Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

[Lldb-commits] [PATCH] D85358: Correctly detect legacy iOS simulator Mach-O objectfiles

2020-08-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 283404.
aprantl added a comment.

Fix typo in test


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

https://reviews.llvm.org/D85358

Files:
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Utility/ArchSpec.cpp
  lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
  lldb/unittests/Utility/ArchSpecTest.cpp

Index: lldb/unittests/Utility/ArchSpecTest.cpp
===
--- lldb/unittests/Utility/ArchSpecTest.cpp
+++ lldb/unittests/Utility/ArchSpecTest.cpp
@@ -305,6 +305,25 @@
 ArchSpec B("x86_64-apple-ios-simulator");
 ASSERT_FALSE(A.IsExactMatch(B));
 ASSERT_FALSE(A.IsCompatibleMatch(B));
+ASSERT_FALSE(B.IsExactMatch(A));
+ASSERT_FALSE(B.IsCompatibleMatch(A));
+  }
+  {
+ArchSpec A("x86_64-apple-ios");
+ArchSpec B("x86_64-apple-ios-simulator");
+ASSERT_FALSE(A.IsExactMatch(B));
+ASSERT_FALSE(A.IsCompatibleMatch(B));
+ASSERT_FALSE(B.IsExactMatch(A));
+ASSERT_FALSE(B.IsCompatibleMatch(A));
+  }
+  {
+// FIXME: This is surprisingly not equivalent to "x86_64-*-*".
+ArchSpec A("x86_64");
+ArchSpec B("x86_64-apple-ios-simulator");
+ASSERT_FALSE(A.IsExactMatch(B));
+ASSERT_TRUE(A.IsCompatibleMatch(B));
+ASSERT_FALSE(B.IsExactMatch(A));
+ASSERT_TRUE(B.IsCompatibleMatch(A));
   }
   {
 ArchSpec A("arm64-apple-ios");
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,6 @@
 import unittest2
 
 
-@skipIfDarwin # rdar://problem/64552748
 class TestSimulatorPlatformLaunching(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
@@ -41,14 +40,14 @@
 
 
 def run_with(self, arch, os, vers, env, expected_load_command):
-self.build(dictionary={'TRIPLE': arch+'-apple-'+os+vers+'-'+env})
+triple = '-'.join([arch, 'apple', os + vers] + ([env] if env else []))
+self.build(dictionary={'TRIPLE': triple})
 self.check_load_commands(expected_load_command)
 log = self.getBuildArtifact('packets.log')
 self.expect("log enable gdb-remote packets -f "+log)
 lldbutil.run_to_source_breakpoint(self, "break here",
   lldb.SBFileSpec("hello.c"))
-self.expect('image list -b -t',
-patterns=['a\.out '+arch+'-apple-'+os+vers+'.*-'+env])
+self.expect('image list -b -t', patterns=['a\.out '+triple])
 self.check_debugserver(log, os+env, vers)
 
 @skipUnlessDarwin
@@ -101,6 +100,13 @@
 # macOS, however, these legacy load commands are never generated.
 #
 
+@skipUnlessDarwin
+@skipIfDarwinEmbedded
+def test_lc_version_min_macosx(self):
+"""Test running a back-deploying non-simulator MacOS X binary"""
+self.run_with(arch=self.getArchitecture(),
+  os='macosx', vers='10.9', env='',
+  expected_load_command='LC_VERSION_MIN_MACOSX')
 @skipUnlessDarwin
 @skipIfDarwinEmbedded
 @apple_simulator_test('iphone')
Index: lldb/source/Utility/ArchSpec.cpp
===
--- lldb/source/Utility/ArchSpec.cpp
+++ lldb/source/Utility/ArchSpec.cpp
@@ -1057,20 +1057,6 @@
   return true;
   }
 
-  if (lhs_triple_os != rhs_triple_os) {
-const bool rhs_os_specified = rhs.TripleOSWasSpecified();
-const bool lhs_os_specified = TripleOSWasSpecified();
-// Both architectures had the OS specified, so if they aren't equal then
-// we return false
-if (rhs_os_specified && lhs_os_specified)
-  return false;
-
-// Only fail if both os types are not unknown
-if (lhs_triple_os != llvm::Triple::UnknownOS &&
-rhs_triple_os != llvm::Triple::UnknownOS)
-  return false;
-  }
-
   // x86_64-apple-ios-macabi and x86_64-apple-ios are not compatible.
   if (lhs_triple_os == llvm::Triple::IOS &&
   rhs_triple_os == llvm::Triple::IOS &&
@@ -1079,6 +1065,19 @@
   lhs_triple_env != rhs_triple_env)
 return false;
 
+  if (lhs_triple_os != rhs_triple_os) {
+const bool lhs_os_specified = TripleOSWasSpecified();
+const bool rhs_os_specified = rhs.TripleOSWasSpecified();
+// If both OS types are specified and different, fail.
+if (lhs_os_specified && rhs_os_specified)
+  return false;
+
+// If the pair of os+env is both unspecified, match any other os+env combo.
+if (!exact_match && ((!lhs_os_specified && !lhs_triple.hasEnvironment()) ||
+ (!rhs_os_specified && !rhs_triple.hasEnvironment(
+  return true;
+  }
+
   return IsCompatibleEnvironment(lhs_triple_env, rhs_triple_env);
 }
 
Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

[Lldb-commits] [PATCH] D85358: Correctly detect legacy iOS simulator Mach-O objectfiles

2020-08-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 283405.
aprantl added a comment.

Fix a second mistake in the updated test.


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

https://reviews.llvm.org/D85358

Files:
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Utility/ArchSpec.cpp
  lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
  lldb/unittests/Utility/ArchSpecTest.cpp

Index: lldb/unittests/Utility/ArchSpecTest.cpp
===
--- lldb/unittests/Utility/ArchSpecTest.cpp
+++ lldb/unittests/Utility/ArchSpecTest.cpp
@@ -305,6 +305,25 @@
 ArchSpec B("x86_64-apple-ios-simulator");
 ASSERT_FALSE(A.IsExactMatch(B));
 ASSERT_FALSE(A.IsCompatibleMatch(B));
+ASSERT_FALSE(B.IsExactMatch(A));
+ASSERT_FALSE(B.IsCompatibleMatch(A));
+  }
+  {
+ArchSpec A("x86_64-apple-ios");
+ArchSpec B("x86_64-apple-ios-simulator");
+ASSERT_FALSE(A.IsExactMatch(B));
+ASSERT_FALSE(A.IsCompatibleMatch(B));
+ASSERT_FALSE(B.IsExactMatch(A));
+ASSERT_FALSE(B.IsCompatibleMatch(A));
+  }
+  {
+// FIXME: This is surprisingly not equivalent to "x86_64-*-*".
+ArchSpec A("x86_64");
+ArchSpec B("x86_64-apple-ios-simulator");
+ASSERT_FALSE(A.IsExactMatch(B));
+ASSERT_TRUE(A.IsCompatibleMatch(B));
+ASSERT_FALSE(B.IsExactMatch(A));
+ASSERT_TRUE(B.IsCompatibleMatch(A));
   }
   {
 ArchSpec A("arm64-apple-ios");
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,6 @@
 import unittest2
 
 
-@skipIfDarwin # rdar://problem/64552748
 class TestSimulatorPlatformLaunching(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
@@ -41,14 +40,16 @@
 
 
 def run_with(self, arch, os, vers, env, expected_load_command):
-self.build(dictionary={'TRIPLE': arch+'-apple-'+os+vers+'-'+env})
+env_list = [env] if env else []
+triple = '-'.join([arch, 'apple', os + vers] + env_list)
+self.build(dictionary={'TRIPLE': triple})
 self.check_load_commands(expected_load_command)
 log = self.getBuildArtifact('packets.log')
 self.expect("log enable gdb-remote packets -f "+log)
 lldbutil.run_to_source_breakpoint(self, "break here",
   lldb.SBFileSpec("hello.c"))
-self.expect('image list -b -t',
-patterns=['a\.out '+arch+'-apple-'+os+vers+'.*-'+env])
+triple_re = '-'.join([arch, 'apple', os + vers+'.*'] + env_list)
+self.expect('image list -b -t', patterns=['a\.out '+triple_re])
 self.check_debugserver(log, os+env, vers)
 
 @skipUnlessDarwin
@@ -101,6 +102,13 @@
 # macOS, however, these legacy load commands are never generated.
 #
 
+@skipUnlessDarwin
+@skipIfDarwinEmbedded
+def test_lc_version_min_macosx(self):
+"""Test running a back-deploying non-simulator MacOS X binary"""
+self.run_with(arch=self.getArchitecture(),
+  os='macosx', vers='10.9', env='',
+  expected_load_command='LC_VERSION_MIN_MACOSX')
 @skipUnlessDarwin
 @skipIfDarwinEmbedded
 @apple_simulator_test('iphone')
Index: lldb/source/Utility/ArchSpec.cpp
===
--- lldb/source/Utility/ArchSpec.cpp
+++ lldb/source/Utility/ArchSpec.cpp
@@ -1057,20 +1057,6 @@
   return true;
   }
 
-  if (lhs_triple_os != rhs_triple_os) {
-const bool rhs_os_specified = rhs.TripleOSWasSpecified();
-const bool lhs_os_specified = TripleOSWasSpecified();
-// Both architectures had the OS specified, so if they aren't equal then
-// we return false
-if (rhs_os_specified && lhs_os_specified)
-  return false;
-
-// Only fail if both os types are not unknown
-if (lhs_triple_os != llvm::Triple::UnknownOS &&
-rhs_triple_os != llvm::Triple::UnknownOS)
-  return false;
-  }
-
   // x86_64-apple-ios-macabi and x86_64-apple-ios are not compatible.
   if (lhs_triple_os == llvm::Triple::IOS &&
   rhs_triple_os == llvm::Triple::IOS &&
@@ -1079,6 +1065,19 @@
   lhs_triple_env != rhs_triple_env)
 return false;
 
+  if (lhs_triple_os != rhs_triple_os) {
+const bool lhs_os_specified = TripleOSWasSpecified();
+const bool rhs_os_specified = rhs.TripleOSWasSpecified();
+// If both OS types are specified and different, fail.
+if (lhs_os_specified && rhs_os_specified)
+  return false;
+
+// If the pair of os+env is both unspecified, match any other os+env combo.
+if (!exact_match && ((!lhs_os_specified && !lhs_triple.hasEnvironment()) ||
+ (!rhs_os_specified && !rhs_triple.hasEnvironment(
+  return true;
+  }
+
   return IsCompatibleEnvironment(lh

[Lldb-commits] [PATCH] D85365: [lldb] Modify the `skipIfRemote` decorator so we can skip all PExpect tests.

2020-08-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: davide, jasonmolenda, friss.
JDevlieghere requested review of this revision.

This patch modifies the `skipIfRemote` decorator so it can apply to a whole 
class, which allows us to skip all PExpect tests as a whole.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D85365

Files:
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/packages/Python/lldbsuite/test/lldbpexpect.py
  
lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
  lldb/test/API/commands/gui/basic/TestGuiBasic.py
  lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
  lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
  lldb/test/API/driver/batch_mode/TestBatchMode.py

Index: lldb/test/API/driver/batch_mode/TestBatchMode.py
===
--- lldb/test/API/driver/batch_mode/TestBatchMode.py
+++ lldb/test/API/driver/batch_mode/TestBatchMode.py
@@ -16,7 +16,6 @@
 mydir = TestBase.compute_mydir(__file__)
 source = 'main.c'
 
-@skipIfRemote  # test not remote-ready llvm.org/pr24813
 @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
 def test_batch_mode_run_crash(self):
 """Test that the lldb driver's batch mode works correctly."""
@@ -47,7 +46,6 @@
 self.expect_prompt()
 self.expect("frame variable touch_me_not", substrs='(char *) touch_me_not')
 
-@skipIfRemote  # test not remote-ready llvm.org/pr24813
 @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
 def test_batch_mode_run_exit(self):
 """Test that the lldb driver's batch mode works correctly."""
@@ -77,7 +75,6 @@
 import pexpect
 child.expect(pexpect.EOF)
 
-@skipIfRemote
 @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
 def test_batch_mode_launch_stop_at_entry(self):
 """Test that the lldb driver's batch mode works correctly for process launch."""
@@ -101,7 +98,7 @@
 child.expect_exact("continue")
 # The App should have not have crashed:
 child.expect_exact("Got there on time and it did not crash.")
-
+
 # Then lldb should exit.
 child.expect_exact("exited")
 import pexpect
@@ -112,7 +109,6 @@
 self.victim.close()
 self.victim = None
 
-@skipIfRemote  # test not remote-ready llvm.org/pr24813
 @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
 @expectedFailureNetBSD
 def test_batch_mode_attach_exit(self):
Index: lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
===
--- lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
+++ lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
@@ -15,7 +15,6 @@
 # under ASAN on a loaded machine..
 @skipIfAsan
 @skipIfCursesSupportMissing
-@skipIfRemote # "run" command will not work correctly for remote debug
 def test_gui(self):
 self.build()
 
Index: lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
===
--- lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
+++ lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
@@ -15,7 +15,6 @@
 # under ASAN on a loaded machine..
 @skipIfAsan
 @skipIfCursesSupportMissing
-@skipIfRemote # "run" command will not work correctly for remote debug
 @expectedFailureAll(archs=["aarch64"], oslist=["linux"])
 def test_gui(self):
 self.build()
Index: lldb/test/API/commands/gui/basic/TestGuiBasic.py
===
--- lldb/test/API/commands/gui/basic/TestGuiBasic.py
+++ lldb/test/API/commands/gui/basic/TestGuiBasic.py
@@ -15,7 +15,6 @@
 # under ASAN on a loaded machine..
 @skipIfAsan
 @skipIfCursesSupportMissing
-@skipIfRemote # "run" command will not work correctly for remote debug
 def test_gui(self):
 self.build()
 
Index: lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
===
--- lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
+++ lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
@@ -14,7 +14,6 @@
 # PExpect uses many timeouts internally and doesn't play well
 # under ASAN on a loaded machine..
 @skipIfAsan
-@skipIfRemote  # test is written to explicitly "run" the binary
 @skipIfEditlineSupportMissing
 def test_basic_completion(self):
 """Test that we can complete a simple multiline expression"""
Index: lldb/packages/Python/lldbsuite/test/lldbpexpect.py
===
--- lldb/packages/Python/lldbsuite/test/lldbpexpec

[Lldb-commits] [PATCH] D85365: [lldb] Modify the `skipIfRemote` decorator so we can skip all PExpect tests.

2020-08-05 Thread Davide Italiano via Phabricator via lldb-commits
davide accepted this revision.
davide added a comment.
This revision is now accepted and ready to land.

I assume we're still allowing to put the decorator on a test-by-test basis, and 
that seems the case from what I see.
If so, LG.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D85365

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


[Lldb-commits] [PATCH] D85365: [lldb] Modify the `skipIfRemote` decorator so we can skip all PExpect tests.

2020-08-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D85365#2197948 , @davide wrote:

> I assume we're still allowing to put the decorator on a test-by-test basis, 
> and that seems the case from what I see.
> If so, LG.

Yup. Thanks!


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D85365

___
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-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



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

vsk wrote:
> Can we get into a bad state here when initializing lldb on an embedded device?
Good question. I think the pragmatic answer here is that we won't encounter 
simulator binaries on an embedded device and that the platform will refuse to 
launch a simulator if one doesn't exist.


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] D85243: Factor out common code from the iPhone/AppleTV/WatchOS simulator platform plugins. (NFC)

2020-08-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 283413.
aprantl retitled this revision from "[WIP] Factor out common code from the 
iPhone/AppleTV/WatchOS simulator platform plugins. (NFC)" to "Factor out common 
code from the iPhone/AppleTV/WatchOS simulator platform plugins. (NFC)".
aprantl added a comment.

Update review feedback. This is now good to go (i.e., review). Removing the 
[WIP] tag.


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

https://reviews.llvm.org/D85243

Files:
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  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/source/Utility/ArchSpec.cpp
  lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
  lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp
  lldb/unittests/Utility/ArchSpecTest.cpp

Index: lldb/unittests/Utility/ArchSpecTest.cpp
===
--- lldb/unittests/Utility/ArchSpecTest.cpp
+++ lldb/unittests/Utility/ArchSpecTest.cpp
@@ -305,6 +305,25 @@
 ArchSpec B("x86_64-apple-ios-simulator");
 ASSERT_FALSE(A.IsExactMatch(B));
 ASSERT_FALSE(A.IsCompatibleMatch(B));
+ASSERT_FALSE(B.IsExactMatch(A));
+ASSERT_FALSE(B.IsCompatibleMatch(A));
+  }
+  {
+ArchSpec A("x86_64-apple-ios");
+ArchSpec B("x86_64-apple-ios-simulator");
+ASSERT_FALSE(A.IsExactMatch(B));
+ASSERT_FALSE(A.IsCompatibleMatch(B));
+ASSERT_FALSE(B.IsExactMatch(A));
+ASSERT_FALSE(B.IsCompatibleMatch(A));
+  }
+  {
+// FIXME: This is surprisingly not equivalent to "x86_64-*-*".
+ArchSpec A("x86_64");
+ArchSpec B("x86_64-apple-ios-simulator");
+ASSERT_FALSE(A.IsExactMatch(B));
+ASSERT_TRUE(A.IsCompatibleMatch(B));
+ASSERT_FALSE(B.IsExactMatch(A));
+ASSERT_TRUE(B.IsCompatibleMatch(A));
   }
   {
 ArchSpec A("arm64-apple-ios");
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,6 @@
 import unittest2
 
 
-@skipIfDarwin # rdar://problem/64552748
 class TestSimulatorPlatformLaunching(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
@@ -41,14 +40,16 @@
 
 
 def run_with(self, arch, os, vers, env, expected_load_command):
-self.build(dictionary={'TRIPLE': arch+'-apple-'+os+vers+'-'+env})
+env_list = [env] if env else []
+triple = '-'.join([arch, 'apple', os + vers] + env_list)
+self.build(dictionary={'TRIPLE': triple})
 self.check_load_commands(expected_load_command)
 log = self.getBuildArtifact('packets.log')
 self.expect("log enable gdb-remote packets -f "+log)
 lldbutil.run_to_source_breakpoint(self, "break here",
   lldb.SBFileSpec("hello.c"))
-self.expect('image list -b -t',
-patterns=['a\.out '+arch+'-apple-'+os+vers+'.*-'+env])
+triple_re = '-'.join([arch, 'apple', os + vers+'.*'] + env_list)
+self.expect('image list -b -t', patterns=['a\.out '+triple_re])
 self.check_debugserver(log, os+env, vers)
 
 @skipUnlessDarwin
@@ -101,6 +102,13 @@
 # macOS, however, these legacy load commands are never generated.
 #
 
+@skipUnlessDarwin
+@skipIfDarwinEmbedded
+def test_lc_version_min_macosx(self):
+"""Test running a back-deploying non-simulator MacOS X binary"""
+self.run_with(arch=self.getArchitecture(),
+ 

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

2020-08-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 283415.
aprantl added a comment.

Actually update the right patch.


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

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/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/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 &module_spec, lldb::ModuleSP &module_sp,
-  const lldb_private::FileSpecList *module_search_paths_ptr) override;
-
-  const char *GetDescription() override { return GetDescriptionStatic(); }
-
-  void GetStatus(lldb_private::Stream &strm) override;
-
-  virtual lldb_private::Status
-  GetSymbolFile(const lldb_private::FileSpec &platform_file,
-const lldb_private::UUID *uuid_ptr,
-lldb_private::FileSpec &local_file);
-
-  lldb_private::Status
-  GetSharedModule(const lldb_private::ModuleSpec &module_spec,
-  lldb_private::Process *process, lldb::ModuleSP &module_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 &match_info,
-lldb_private::ProcessInstanceInfoList &process_infos) override;
-
-  void
-  AddClangModuleCompilationOptions(lldb_private::Target *target,
-   std::vector &options) override {
-return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
-target, options, lldb_private::XcodeSDK::Type::iPhoneSimulator);
-  }
-
-protected:
-  std::mutex m_sdk_dir_mutex;
-  std::string m_sdk_directory;
-  std::string m_build_update;
-
-  llvm::StringRef GetSDKDirectoryAsCString();
-
-private:
-  PlatformiOSSimulator(const PlatformiOSSimulator &) = delete;
-  const PlatformiOSSimulator &operator=(const PlatformiOSSimulator &) = delete;
-};
-
-#endif // LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMIOSSIMULATOR_H
Index: lldb/sou

[Lldb-commits] [lldb] 31137b8 - [lldb] Skip TestProcessConnect when running remotely

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

Author: Jonas Devlieghere
Date: 2020-08-05T15:27:34-07:00
New Revision: 31137b87efc12b1d8cdd8307bcddb986e5c23c61

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

LOG: [lldb] Skip TestProcessConnect when running remotely

This test doesn't make much sense when already running remotely.

Added: 


Modified: 
lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
index 14891b24249b..32a585d5bd34 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
@@ -6,6 +6,7 @@
 from gdbclientutils import *
 
 
+@skipIfRemote
 class TestProcessConnect(GDBRemoteTestBase):
 
 NO_DEBUG_INFO_TESTCASE = True



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


[Lldb-commits] [lldb] df46f17 - [lldb] Modify the `skipIfRemote` decorator so we can skip all PExpect tests.

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

Author: Jonas Devlieghere
Date: 2020-08-05T15:27:34-07:00
New Revision: df46f174db5bbedb66d77041308d48e701c77e96

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

LOG: [lldb] Modify the `skipIfRemote` decorator so we can skip all PExpect 
tests.

This patch modifies the skipIfRemote decorator so it can apply to a
whole class, which allows us to skip all PExpect tests as a whole.

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

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/decorators.py
lldb/packages/Python/lldbsuite/test/lldbpexpect.py

lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
lldb/test/API/commands/gui/basic/TestGuiBasic.py
lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
lldb/test/API/driver/batch_mode/TestBatchMode.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index 873952e4c91a..a472e1c4c52e 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -502,9 +502,7 @@ def is_out_of_tree_debugserver():
 
 def skipIfRemote(func):
 """Decorate the item to skip tests if testing remotely."""
-def is_remote():
-return "skip on remote platform" if lldb.remote_platform else None
-return skipTestIfFn(is_remote)(func)
+return unittest2.skipIf(lldb.remote_platform, "skip on remote 
platform")(func)
 
 
 def skipIfNoSBHeaders(func):

diff  --git a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py 
b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py
index d599bc397622..86216ec034cd 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py
@@ -11,6 +11,7 @@
 import lldb
 from .lldbtest import *
 from . import lldbutil
+from lldbsuite.test.decorators import *
 
 if sys.platform.startswith('win32'):
 # llvm.org/pr22274: need a pexpect replacement for windows
@@ -19,6 +20,7 @@ class PExpectTest(object):
 else:
 import pexpect
 
+@skipIfRemote
 class PExpectTest(TestBase):
 
 NO_DEBUG_INFO_TESTCASE = True

diff  --git 
a/lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
 
b/lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
index 9b2b71230e52..e4935d0e2b84 100644
--- 
a/lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
+++ 
b/lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
@@ -14,7 +14,6 @@ class MultilineCompletionTest(PExpectTest):
 # PExpect uses many timeouts internally and doesn't play well
 # under ASAN on a loaded machine..
 @skipIfAsan
-@skipIfRemote  # test is written to explicitly "run" the binary
 @skipIfEditlineSupportMissing
 def test_basic_completion(self):
 """Test that we can complete a simple multiline expression"""

diff  --git a/lldb/test/API/commands/gui/basic/TestGuiBasic.py 
b/lldb/test/API/commands/gui/basic/TestGuiBasic.py
index 2dcc7d08e6eb..d501b266cc12 100644
--- a/lldb/test/API/commands/gui/basic/TestGuiBasic.py
+++ b/lldb/test/API/commands/gui/basic/TestGuiBasic.py
@@ -15,7 +15,6 @@ class BasicGuiCommandTest(PExpectTest):
 # under ASAN on a loaded machine..
 @skipIfAsan
 @skipIfCursesSupportMissing
-@skipIfRemote # "run" command will not work correctly for remote debug
 def test_gui(self):
 self.build()
 

diff  --git a/lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py 
b/lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
index 5c3d0d7369b4..ed5daf57a444 100644
--- a/lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
+++ b/lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
@@ -15,7 +15,6 @@ class TestGuiBasicDebugCommandTest(PExpectTest):
 # under ASAN on a loaded machine..
 @skipIfAsan
 @skipIfCursesSupportMissing
-@skipIfRemote # "run" command will not work correctly for remote debug
 @expectedFailureAll(archs=["aarch64"], oslist=["linux"])
 def test_gui(self):
 self.build()

diff  --git a/lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py 
b/lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
index 13f5e1380a74..3d075c013262 100644
--- a/lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
+++ b/lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
@@ -15,7 +15,6 @@ class TestGuiBasicDebugCommandTest(PExpectTest):
 # under ASAN on a loaded machine..
 @skipIfAsan
 @skipIfCursesSupportMissing
-@skipIfRemote # "run" command will not work correctly for rem

[Lldb-commits] [PATCH] D85365: [lldb] Modify the `skipIfRemote` decorator so we can skip all PExpect tests.

2020-08-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdf46f174db5b: [lldb] Modify the `skipIfRemote` decorator so 
we can skip all PExpect tests. (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D85365?vs=283409&id=283417#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85365

Files:
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/packages/Python/lldbsuite/test/lldbpexpect.py
  
lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
  lldb/test/API/commands/gui/basic/TestGuiBasic.py
  lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
  lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
  lldb/test/API/driver/batch_mode/TestBatchMode.py

Index: lldb/test/API/driver/batch_mode/TestBatchMode.py
===
--- lldb/test/API/driver/batch_mode/TestBatchMode.py
+++ lldb/test/API/driver/batch_mode/TestBatchMode.py
@@ -16,7 +16,6 @@
 mydir = TestBase.compute_mydir(__file__)
 source = 'main.c'
 
-@skipIfRemote  # test not remote-ready llvm.org/pr24813
 @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
 def test_batch_mode_run_crash(self):
 """Test that the lldb driver's batch mode works correctly."""
@@ -47,7 +46,6 @@
 self.expect_prompt()
 self.expect("frame variable touch_me_not", substrs='(char *) touch_me_not')
 
-@skipIfRemote  # test not remote-ready llvm.org/pr24813
 @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
 def test_batch_mode_run_exit(self):
 """Test that the lldb driver's batch mode works correctly."""
@@ -77,7 +75,6 @@
 import pexpect
 child.expect(pexpect.EOF)
 
-@skipIfRemote
 @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
 def test_batch_mode_launch_stop_at_entry(self):
 """Test that the lldb driver's batch mode works correctly for process launch."""
@@ -101,7 +98,7 @@
 child.expect_exact("continue")
 # The App should have not have crashed:
 child.expect_exact("Got there on time and it did not crash.")
-
+
 # Then lldb should exit.
 child.expect_exact("exited")
 import pexpect
@@ -112,7 +109,6 @@
 self.victim.close()
 self.victim = None
 
-@skipIfRemote  # test not remote-ready llvm.org/pr24813
 @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
 @expectedFailureNetBSD
 def test_batch_mode_attach_exit(self):
Index: lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
===
--- lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
+++ lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
@@ -15,7 +15,6 @@
 # under ASAN on a loaded machine..
 @skipIfAsan
 @skipIfCursesSupportMissing
-@skipIfRemote # "run" command will not work correctly for remote debug
 def test_gui(self):
 self.build()
 
Index: lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
===
--- lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
+++ lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
@@ -15,7 +15,6 @@
 # under ASAN on a loaded machine..
 @skipIfAsan
 @skipIfCursesSupportMissing
-@skipIfRemote # "run" command will not work correctly for remote debug
 @expectedFailureAll(archs=["aarch64"], oslist=["linux"])
 def test_gui(self):
 self.build()
Index: lldb/test/API/commands/gui/basic/TestGuiBasic.py
===
--- lldb/test/API/commands/gui/basic/TestGuiBasic.py
+++ lldb/test/API/commands/gui/basic/TestGuiBasic.py
@@ -15,7 +15,6 @@
 # under ASAN on a loaded machine..
 @skipIfAsan
 @skipIfCursesSupportMissing
-@skipIfRemote # "run" command will not work correctly for remote debug
 def test_gui(self):
 self.build()
 
Index: lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
===
--- lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
+++ lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
@@ -14,7 +14,6 @@
 # PExpect uses many timeouts internally and doesn't play well
 # under ASAN on a loaded machine..
 @skipIfAsan
-@skipIfRemote  # test is written to explicitly "run" the binary
 @skipIfEditlineSupportMissing
 def test_basic_completion(self):
 """Test that we can complete a simple multiline expression"""
Index: lldb/packages/Python/lldbsuite/test/lldbpexpec

[Lldb-commits] [lldb] 927afdf - [lldb] Skip test_launch_simple on Windows

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

Author: Jonas Devlieghere
Date: 2020-08-05T15:38:07-07:00
New Revision: 927afdffbb1deebd83b86d024b67687d758521d0

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

LOG: [lldb] Skip test_launch_simple on Windows

Because stdio manipulation unsupported on Windows.

Added: 


Modified: 
lldb/test/API/python_api/target/TestTargetAPI.py

Removed: 




diff  --git a/lldb/test/API/python_api/target/TestTargetAPI.py 
b/lldb/test/API/python_api/target/TestTargetAPI.py
index f6b349bd6a3d..5bdbf90b3575 100644
--- a/lldb/test/API/python_api/target/TestTargetAPI.py
+++ b/lldb/test/API/python_api/target/TestTargetAPI.py
@@ -152,6 +152,7 @@ def test_read_memory(self):
 
 
 @add_test_categories(['pyapi'])
+@skipIfWindows  # stdio manipulation unsupported on Windows
 def test_launch_simple(self):
 d = {'EXE': 'b.out'}
 self.build(dictionary=d)



___
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-05 Thread Max Kudryavtsev via Phabricator via lldb-commits
max-kudr added a comment.

@JDevlieghere This change is is failing LLDB Windows buildbot 
 since build 18051 
. Can 
you please fix that?


Repository:
  rG LLVM Github Monorepo

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] D85145: Use syntax highlighting also in gui mode

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

LGTM. Raphael? You have any more comments?


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] D85235: [lldb] Make SBTarget::LaunchSimple start form the target's LaunchInfo

2020-08-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D85235#2198013 , @max-kudr wrote:

> @JDevlieghere This change is is failing LLDB Windows buildbot 
>  since build 18051 
> . Can 
> you please fix that?

Thanks for the heads up. I had just pushed a fix:

  commit 927afdffbb1deebd83b86d024b67687d758521d0 
  Author: Jonas Devlieghere 
  Date:   Wed Aug 5 15:37:50 2020 -0700
  
  [lldb] Skip test_launch_simple on Windows
  
  Because stdio manipulation unsupported on Windows.


Repository:
  rG LLVM Github Monorepo

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] D85235: [lldb] Make SBTarget::LaunchSimple start form the target's LaunchInfo

2020-08-05 Thread Max Kudryavtsev via Phabricator via lldb-commits
max-kudr added a comment.

Thank you!


Repository:
  rG LLVM Github Monorepo

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] [lldb] 1adc494 - [CMake] Simplify CMake handling for zlib

2020-08-05 Thread Petr Hosek via lldb-commits

Author: Petr Hosek
Date: 2020-08-05T16:07:11-07:00
New Revision: 1adc494bce44f6004994deed61b30d4b71fe1d05

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

LOG: [CMake] Simplify CMake handling for zlib

Rather than handling zlib handling manually, use find_package from CMake
to find zlib properly. Use this to normalize the LLVM_ENABLE_ZLIB,
HAVE_ZLIB, HAVE_ZLIB_H. Furthermore, require zlib if LLVM_ENABLE_ZLIB is
set to YES, which requires the distributor to explicitly select whether
zlib is enabled or not. This simplifies the CMake handling and usage in
the rest of the tooling.

This is a reland of abb0075 with all followup changes and fixes that
should address issues that were reported in PR44780.

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

Added: 


Modified: 
clang/test/CMakeLists.txt
clang/test/lit.site.cfg.py.in
compiler-rt/test/lit.common.configured.in
lld/test/CMakeLists.txt
lld/test/lit.site.cfg.py.in
lldb/cmake/modules/LLDBStandalone.cmake
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
llvm/cmake/config-ix.cmake
llvm/cmake/modules/LLVMConfig.cmake.in
llvm/include/llvm/Config/config.h.cmake
llvm/lib/Support/CMakeLists.txt
llvm/lib/Support/CRC.cpp
llvm/lib/Support/Compression.cpp
llvm/test/CMakeLists.txt
llvm/test/lit.site.cfg.py.in
llvm/unittests/Support/CompressionTest.cpp
llvm/utils/gn/secondary/clang/test/BUILD.gn
llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn
llvm/utils/gn/secondary/lld/test/BUILD.gn
llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
llvm/utils/gn/secondary/llvm/test/BUILD.gn

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 38bbc5be90d5..334a90498d0d 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -9,15 +9,6 @@ endif ()
 
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR 
${LLVM_RUNTIME_OUTPUT_INTDIR})
 
-if(CLANG_BUILT_STANDALONE)
-  # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This
-  # value is forced to 0 if zlib was not found, so it is fine to use it
-  # instead of HAVE_LIBZ (not recorded).
-  if(LLVM_ENABLE_ZLIB)
-set(HAVE_LIBZ 1)
-  endif()
-endif()
-
 llvm_canonicalize_cmake_booleans(
   CLANG_BUILD_EXAMPLES
   CLANG_ENABLE_ARCMT
@@ -25,7 +16,7 @@ llvm_canonicalize_cmake_booleans(
   CLANG_SPAWN_CC1
   ENABLE_BACKTRACES
   ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
-  HAVE_LIBZ
+  LLVM_ENABLE_ZLIB
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
   LLVM_ENABLE_PLUGINS
   LLVM_ENABLE_THREADS)

diff  --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index d9b5b2f2592e..286ea06d798c 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -16,7 +16,7 @@ config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.host_cxx = "@CMAKE_CXX_COMPILER@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
-config.have_zlib = @HAVE_LIBZ@
+config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.clang_arcmt = @CLANG_ENABLE_ARCMT@
 config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@

diff  --git a/compiler-rt/test/lit.common.configured.in 
b/compiler-rt/test/lit.common.configured.in
index 1f746c067b84..000bf9b98470 100644
--- a/compiler-rt/test/lit.common.configured.in
+++ b/compiler-rt/test/lit.common.configured.in
@@ -57,7 +57,7 @@ elif config.android:
 else:
   set_default("target_suffix", "-%s" % config.target_arch)
 
-set_default("have_zlib", "@HAVE_LIBZ@")
+set_default("have_zlib", "@LLVM_ENABLE_ZLIB@")
 set_default("libcxx_used", "@LLVM_LIBCXX_USED@")
 
 # LLVM tools dir can be passed in lit parameters, so try to

diff  --git a/lld/test/CMakeLists.txt b/lld/test/CMakeLists.txt
index 74b29f5d65b8..52e6118ba876 100644
--- a/lld/test/CMakeLists.txt
+++ b/lld/test/CMakeLists.txt
@@ -4,17 +4,8 @@ set(LLVM_BUILD_MODE "%(build_mode)s")
 set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s")
 set(LLVM_LIBS_DIR 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/%(build_config)s")
 
-if(LLD_BUILT_STANDALONE)
-  # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This
-  # value is forced to 0 if zlib was not found, so it is fine to use it
-  # instead of HAVE_LIBZ (not recorded).
-  if(LLVM_ENABLE_ZLIB)
-set(HAVE_LIBZ 1)
-  endif()
-endif()
-
 llvm_canonicalize_cmake_booleans(
-  HAVE_LIBZ
+  LLVM_ENABLE_ZLIB
   LLVM_LIBXML2_ENABLED
   )
 

diff  --git a/lld/test/lit.site.cfg.py.in b/lld/test/lit.site.cfg.py.in
index 4aa2fcda73bb..3d4c51f4ab64 100644
--- a/lld/test/lit.site.cfg.py.in
+++ b/lld/test/lit.site.cfg.py.in
@@ 

[Lldb-commits] [PATCH] D85049: Unify the code that updates the ArchSpec after finding a fat binary with how it is done for a lean binary

2020-08-05 Thread Davide Italiano via Phabricator via lldb-commits
davide added inline comments.



Comment at: lldb/source/Target/TargetList.cpp:110-111
+// architecture so that the platform matching can be more accurate.
+if (!platform_arch.TripleOSWasSpecified() ||
+!platform_arch.TripleVendorWasSpecified()) {
+  prefer_platform_arch = true;

Is this check strict enough? I thought it should be only TripleOSWasSpecified 
-- what we can infer from the vendor?


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

https://reviews.llvm.org/D85049

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


[Lldb-commits] [PATCH] D85376: Fix how ValueObjectChild handles bit-fields stored in a Scalar in UpdateValue()

2020-08-05 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik created this revision.
shafik added reviewers: aprantl, jingham, vsk.
shafik requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

When bit-field data was stored in a `Scalar` in `ValueObjectChild` during 
`UpdateValue()` it was extracting the bit-field value. Later on in 
`lldb_private::DumpDataExtractor(…)` we were again attempting to extract the 
bit-field:

  s->Printf("%" PRIu64,
  DE.GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size,
   item_bit_offset));

which would then not obtain the correct value. This will remove the extra 
extraction in `UpdateValue()`.

We hit this specific case when values are passed in registers, which we could 
only reproduce in an optimized build.


https://reviews.llvm.org/D85376

Files:
  lldb/source/Core/ValueObjectChild.cpp
  lldb/test/API/functionalities/data-formatter/valueobj-pass-by-reg/Makefile
  
lldb/test/API/functionalities/data-formatter/valueobj-pass-by-reg/TestValueObjPassByRef.py
  lldb/test/API/functionalities/data-formatter/valueobj-pass-by-reg/main.s

Index: lldb/test/API/functionalities/data-formatter/valueobj-pass-by-reg/main.s
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/valueobj-pass-by-reg/main.s
@@ -0,0 +1,653 @@
+## This was generated from the following code:
+##
+## We are testing how ValueObject deals with bit-fields when an argument is
+## passed by register. Compiling at -O1 allows us to capture this case and
+## test it.
+##
+## #include 
+## #include 
+##
+## typedef union
+## {
+##  uint32_t raw;
+##  struct
+##  {
+##uint32_t a : 8;
+##uint32_t b : 8;
+##uint32_t c : 6;
+##uint32_t d : 2;
+##uint32_t e : 6;
+##uint32_t f : 2;
+##  } ;
+## } U;
+##
+## void f(U u) {
+##   printf( "%d\n", u.raw);
+##   return;
+## }
+##
+## int main() {
+##   U u;
+##   u.raw = 0x64A40101;
+##
+##   f(u);
+## }
+##
+## Compiled as follows:
+##
+##
+## clang -g -O1 main.c  -o main
+## clang -g -O1 main.c -S -o main.s
+##
+	.section	__TEXT,__text,regular,pure_instructions
+	.build_version macos, 10, 15	sdk_version 10, 15
+	.globl	_f  ## -- Begin function f
+	.p2align	4, 0x90
+_f: ## @f
+Lfunc_begin0:
+	.file	1 "/Users/shafik/code" "main.c"
+	.loc	1 18 0  ## main.c:18:0
+	.cfi_startproc
+## %bb.0:
+	pushq	%rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq	%rsp, %rbp
+	.cfi_def_cfa_register %rbp
+	##DEBUG_VALUE: f:u <- $edi
+	movl	%edi, %esi
+Ltmp0:
+	##DEBUG_VALUE: f:u <- $esi
+	.loc	1 19 3 prologue_end ## main.c:19:3
+	leaq	L_.str(%rip), %rdi
+	##DEBUG_VALUE: f:u <- $esi
+	xorl	%eax, %eax
+	popq	%rbp
+	jmp	_printf ## TAILCALL
+Ltmp1:
+Lfunc_end0:
+	.cfi_endproc
+## -- End function
+	.globl	_main   ## -- Begin function main
+	.p2align	4, 0x90
+_main:  ## @main
+Lfunc_begin1:
+	.loc	1 23 0  ## main.c:23:0
+	.cfi_startproc
+## %bb.0:
+	pushq	%rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq	%rsp, %rbp
+	.cfi_def_cfa_register %rbp
+Ltmp2:
+	##DEBUG_VALUE: main:u <- 1688469761
+	.loc	1 27 3 prologue_end ## main.c:27:3
+	movl	$1688469761, %edi   ## imm = 0x64A40101
+	callq	_f
+Ltmp3:
+	.loc	1 28 1  ## main.c:28:1
+	xorl	%eax, %eax
+	popq	%rbp
+	retq
+Ltmp4:
+Lfunc_end1:
+	.cfi_endproc
+## -- End function
+	.section	__TEXT,__cstring,cstring_literals
+L_.str: ## @.str
+	.asciz	"%d\n"
+
+	.file	2 "/Applications/Xcode5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/_types" "_uint32_t.h"
+	.section	__DWARF,__debug_str,regular,debug
+Linfo_string:
+	.asciz	"Apple clang version 11.0.0 (clang-1100.0.31.5)" ## string offset=0
+	.asciz	"main.c"## string offset=47
+	.asciz	"/Users/shafik/code"## string offset=54
+	.asciz	"f" ## string offset=73
+	.asciz	"main"  ## string offset=75
+	.asciz	"int"   ## string offset=80
+	.asciz	"u" ## string offset=84
+	.asciz	"U" ## string offset=86
+	.asciz	"raw"   ## string offset=88
+	.asciz	"uint32_t"  ## string offset=92
+	.asciz	"unsigned int"  ## string offset=101
+	.asciz	"a" ## string offset=114
+	.asciz	"b" ## string offset=116
+	.asciz	"c" ## string offset=118
+	.asciz	"d" ## string offset=120
+	.asciz	"e" ## string offset=122
+	.section	__DWARF,__debug_loc,regular,debug
+Lsection_debug_loc:
+Ldebug_loc0:
+.set Lset0, Lfunc_begin0-Lfunc_begin0
+	.quad	Lset0
+.set Lset1, Ltmp0-Lfunc_begin0
+	.quad	Lset1
+	.short	1   

[Lldb-commits] [PATCH] D85376: Fix how ValueObjectChild handles bit-fields stored in a Scalar in UpdateValue()

2020-08-05 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

Note: for the test I did not want to rely on clang choosing to pass the union 
by register, so I used assembly which ensures I will obtain the behavior I am 
looking to capture for the test.


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

https://reviews.llvm.org/D85376

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


[Lldb-commits] [PATCH] D85049: Unify the code that updates the ArchSpec after finding a fat binary with how it is done for a lean binary

2020-08-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/source/Target/TargetList.cpp:162
 // Only one arch and none was specified.
-prefer_platform_arch = true;
-platform_arch = matching_module_spec.GetArchitecture();
+update_platform_arch(matching_module_spec.GetArchitecture());
   }

this is wrong. it should be at line 132!

Thanks @jingham !


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

https://reviews.llvm.org/D85049

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


[Lldb-commits] [PATCH] D85376: Fix how ValueObjectChild handles bit-fields stored in a Scalar in UpdateValue()

2020-08-05 Thread Frederic Riss via Phabricator via lldb-commits
friss added inline comments.



Comment at: lldb/source/Core/ValueObjectChild.cpp:202-205
-if (m_bitfield_bit_size)
-  scalar.ExtractBitfield(m_bitfield_bit_size,
- m_bitfield_bit_offset);
-else

Why remove the code in `ValueObject` rather than avoid re-extracting at 
printing time? I'm not sure which one is correct. If you get your hands on a 
`ValueObject` for the field in your test, what will `GetValueAsUnsigned` 
return? it should give the correct field value.



Comment at: 
lldb/test/API/functionalities/data-formatter/valueobj-pass-by-reg/TestValueObjPassByRef.py:10
+
+@skipUnlessDarwin
+def test(self):

If the test in assembly is what we want, this is also architecture specific. It 
should be restricted to x86_64


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

https://reviews.llvm.org/D85376

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


[Lldb-commits] [PATCH] D85376: Fix how ValueObjectChild handles bit-fields stored in a Scalar in UpdateValue()

2020-08-05 Thread Davide Italiano via Phabricator via lldb-commits
davide requested changes to this revision.
davide added inline comments.
This revision now requires changes to proceed.



Comment at: 
lldb/test/API/functionalities/data-formatter/valueobj-pass-by-reg/Makefile:2
+EXE := a.out
+CFLAGS := -O1
+

This is fundamentally a no-go. Depending on the optimization pipeline passes 
this in a register is an assumption that might go away at some point in the 
future and this test won't test what it has to & will still pass silently.

Something like this might work:
https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables.html


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

https://reviews.llvm.org/D85376

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


[Lldb-commits] [PATCH] D85376: Fix how ValueObjectChild handles bit-fields stored in a Scalar in UpdateValue()

2020-08-05 Thread Davide Italiano via Phabricator via lldb-commits
davide added inline comments.



Comment at: 
lldb/test/API/functionalities/data-formatter/valueobj-pass-by-reg/Makefile:2
+EXE := a.out
+CFLAGS := -O1
+

davide wrote:
> This is fundamentally a no-go. Depending on the optimization pipeline passes 
> this in a register is an assumption that might go away at some point in the 
> future and this test won't test what it has to & will still pass silently.
> 
> Something like this might work:
> https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables.html
*depending on the optimization pipeline, the fact that is passed in a register 
is an assumption that


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

https://reviews.llvm.org/D85376

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


[Lldb-commits] [lldb] 3a538de - [lldb] Make UBSan tests remote ready

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

Author: Jonas Devlieghere
Date: 2020-08-05T18:31:43-07:00
New Revision: 3a538de653607b7602a870d63b13dd51638c1424

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

LOG: [lldb] Make UBSan tests remote ready

Add missing call to registerSanitizerLibrariesWithTarget.

Added: 


Modified: 
lldb/test/API/functionalities/ubsan/basic/TestUbsanBasic.py

lldb/test/API/functionalities/ubsan/user-expression/TestUbsanUserExpression.py

Removed: 




diff  --git a/lldb/test/API/functionalities/ubsan/basic/TestUbsanBasic.py 
b/lldb/test/API/functionalities/ubsan/basic/TestUbsanBasic.py
index d804ef3ea9d7..6b51e5e53c8e 100644
--- a/lldb/test/API/functionalities/ubsan/basic/TestUbsanBasic.py
+++ b/lldb/test/API/functionalities/ubsan/basic/TestUbsanBasic.py
@@ -27,9 +27,9 @@ def setUp(self):
 def ubsan_tests(self):
 # Load the test
 exe = self.getBuildArtifact("a.out")
-self.expect(
-"file " + exe,
-patterns=["Current executable set to .*a.out"])
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+self.registerSanitizerLibrariesWithTarget(target)
 
 self.runCmd("run")
 

diff  --git 
a/lldb/test/API/functionalities/ubsan/user-expression/TestUbsanUserExpression.py
 
b/lldb/test/API/functionalities/ubsan/user-expression/TestUbsanUserExpression.py
index 68f8c0360ff3..bb1607dd4322 100644
--- 
a/lldb/test/API/functionalities/ubsan/user-expression/TestUbsanUserExpression.py
+++ 
b/lldb/test/API/functionalities/ubsan/user-expression/TestUbsanUserExpression.py
@@ -25,9 +25,9 @@ def setUp(self):
 def ubsan_tests(self):
 # Load the test
 exe = self.getBuildArtifact("a.out")
-self.expect(
-"file " + exe,
-patterns=["Current executable set to .*a.out"])
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+self.registerSanitizerLibrariesWithTarget(target)
 
 self.runCmd("breakpoint set -f main.c -l %d" % self.line_breakpoint)
 



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


[Lldb-commits] [PATCH] D85388: [lldb] Fix bug in skipIfRosetta decorator

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

Currently, the `skipIfRosetta` decorator will skip tests with the message "not 
on macOS" on non-macOS platforms. This triggers for example when running tests 
remotely on device. Instead, it should only check the platform and architecture 
when running on the Darwin/macOS platform.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D85388

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


Index: lldb/packages/Python/lldbsuite/test/decorators.py
===
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -538,10 +538,9 @@
 def skipIfRosetta(bugnumber):
 """Skip a test when running the testsuite on macOS under the Rosetta 
translation layer."""
 def is_running_rosetta(self):
-if not lldbplatformutil.getPlatform() in ['darwin', 'macosx']:
-return "not on macOS"
-if (platform.uname()[5] == "arm") and (self.getArchitecture() == 
"x86_64"):
-return "skipped under Rosetta"
+if lldbplatformutil.getPlatform() in ['darwin', 'macosx']:
+if (platform.uname()[5] == "arm") and (self.getArchitecture() == 
"x86_64"):
+return "skipped under Rosetta"
 return None
 return skipTestIfFn(is_running_rosetta)
 


Index: lldb/packages/Python/lldbsuite/test/decorators.py
===
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -538,10 +538,9 @@
 def skipIfRosetta(bugnumber):
 """Skip a test when running the testsuite on macOS under the Rosetta translation layer."""
 def is_running_rosetta(self):
-if not lldbplatformutil.getPlatform() in ['darwin', 'macosx']:
-return "not on macOS"
-if (platform.uname()[5] == "arm") and (self.getArchitecture() == "x86_64"):
-return "skipped under Rosetta"
+if lldbplatformutil.getPlatform() in ['darwin', 'macosx']:
+if (platform.uname()[5] == "arm") and (self.getArchitecture() == "x86_64"):
+return "skipped under Rosetta"
 return None
 return skipTestIfFn(is_running_rosetta)
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85388: [lldb] Fix bug in skipIfRosetta decorator

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



Comment at: lldb/packages/Python/lldbsuite/test/decorators.py:542
-if not lldbplatformutil.getPlatform() in ['darwin', 'macosx']:
-return "not on macOS"
-if (platform.uname()[5] == "arm") and (self.getArchitecture() == 
"x86_64"):

Alternatively this could return `None` which means the test is **not** skipped.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D85388

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


[Lldb-commits] [lldb] 08063f8 - "|" used when "||" was meant in SBTarget::FindFunctions

2020-08-05 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2020-08-05T19:02:00-07:00
New Revision: 08063f85a7eadb1e54d0a03e0307bf15319513e8

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

LOG: "|" used when "||" was meant in SBTarget::FindFunctions

Added: 


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

Removed: 




diff  --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 04540a2fab43..34cab6217565 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -1791,7 +1791,7 @@ lldb::SBSymbolContextList SBTarget::FindFunctions(const 
char *name,
  (const char *, uint32_t), name, name_type_mask);
 
   lldb::SBSymbolContextList sb_sc_list;
-  if (!name | !name[0])
+  if (!name || !name[0])
 return LLDB_RECORD_RESULT(sb_sc_list);
 
   TargetSP target_sp(GetSP());

diff  --git a/lldb/test/API/python_api/target/TestTargetAPI.py 
b/lldb/test/API/python_api/target/TestTargetAPI.py
index 5bdbf90b3575..7db53883eb6a 100644
--- a/lldb/test/API/python_api/target/TestTargetAPI.py
+++ b/lldb/test/API/python_api/target/TestTargetAPI.py
@@ -283,6 +283,10 @@ def find_functions(self, exe_name):
 target = self.dbg.CreateTarget(exe)
 self.assertTrue(target, VALID_TARGET)
 
+# Try it with a null name:
+list = target.FindFunctions(None, lldb.eFunctionNameTypeAuto)
+self.assertTrue(list.GetSize() == 0)
+
 list = target.FindFunctions('c', lldb.eFunctionNameTypeAuto)
 self.assertTrue(list.GetSize() == 1)
 



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


[Lldb-commits] [lldb] 1c1ffa6 - GetPath() returns a std::string temporary. You can't reference just the c_str.

2020-08-05 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2020-08-05T19:12:15-07:00
New Revision: 1c1ffa6a300a60c81be41a3e08a4e9da7499adc1

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

LOG: GetPath() returns a std::string temporary.  You can't reference just the 
c_str.

Found by the static analyzer.

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 338c798e6cef..383cc5b59a37 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1887,15 +1887,15 @@ class MachSymtabSectionInfo {
   m_section_infos[n_sect].vm_range.SetByteSize(
   section_sp->GetByteSize());
 } else {
-  const char *filename = "";
+  std::string filename = "";
   SectionSP first_section_sp(m_section_list->GetSectionAtIndex(0));
   if (first_section_sp)
-filename = 
first_section_sp->GetObjectFile()->GetFileSpec().GetPath().c_str();
+filename = 
first_section_sp->GetObjectFile()->GetFileSpec().GetPath();
 
   Host::SystemLog(Host::eSystemLogError,
   "error: unable to find section %d for a symbol in 
%s, corrupt file?\n",
   n_sect, 
-  filename);
+  filename.c_str());
 }
   }
   if (m_section_infos[n_sect].vm_range.Contains(file_addr)) {



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


[Lldb-commits] [PATCH] D85376: Fix how ValueObjectChild handles bit-fields stored in a Scalar in UpdateValue()

2020-08-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: 
lldb/test/API/functionalities/data-formatter/valueobj-pass-by-reg/Makefile:1
+EXE := a.out
+CFLAGS := -O1

I think this is redundant. The default is a.out



Comment at: 
lldb/test/API/functionalities/data-formatter/valueobj-pass-by-reg/Makefile:2
+EXE := a.out
+CFLAGS := -O1
+

davide wrote:
> davide wrote:
> > This is fundamentally a no-go. Depending on the optimization pipeline 
> > passes this in a register is an assumption that might go away at some point 
> > in the future and this test won't test what it has to & will still pass 
> > silently.
> > 
> > Something like this might work:
> > https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables.html
> *depending on the optimization pipeline, the fact that is passed in a 
> register is an assumption that
Given that the source code is a .s file, I think the -O1 is just redundant and 
can be removed. Using assembler is fine for this purpose.



Comment at: 
lldb/test/API/functionalities/data-formatter/valueobj-pass-by-reg/Makefile:8
+   $(CC) $(CFLAGS) $(SRCDIR)/main.s -c -o main.o
+   $(CC) $(CFLAGS) main.o -o a.out

Is it possible to just override the rule that produces the .o file? Otherwise 
you are dropping the codesign and dsymutil phase.



Comment at: 
lldb/test/API/functionalities/data-formatter/valueobj-pass-by-reg/TestValueObjPassByRef.py:15
+self.runCmd("b f");
+self.runCmd("run");
+

lldbutil has a helper for running to a breakpoint by name.


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

https://reviews.llvm.org/D85376

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


[Lldb-commits] [PATCH] D85388: [lldb] Fix bug in skipIfRosetta decorator

2020-08-05 Thread Davide Italiano via Phabricator via lldb-commits
davide accepted this revision.
davide added a comment.
This revision is now accepted and ready to land.

yes, this makes sense. We could refine the check in future.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D85388

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


[Lldb-commits] [PATCH] D85388: [lldb] Fix bug in skipIfRosetta decorator

2020-08-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4fccdd5c85d0: [lldb] Fix bug in skipIfRosetta decorator 
(authored by JDevlieghere).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85388

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


Index: lldb/packages/Python/lldbsuite/test/decorators.py
===
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -538,10 +538,9 @@
 def skipIfRosetta(bugnumber):
 """Skip a test when running the testsuite on macOS under the Rosetta 
translation layer."""
 def is_running_rosetta(self):
-if not lldbplatformutil.getPlatform() in ['darwin', 'macosx']:
-return "not on macOS"
-if (platform.uname()[5] == "arm") and (self.getArchitecture() == 
"x86_64"):
-return "skipped under Rosetta"
+if lldbplatformutil.getPlatform() in ['darwin', 'macosx']:
+if (platform.uname()[5] == "arm") and (self.getArchitecture() == 
"x86_64"):
+return "skipped under Rosetta"
 return None
 return skipTestIfFn(is_running_rosetta)
 


Index: lldb/packages/Python/lldbsuite/test/decorators.py
===
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -538,10 +538,9 @@
 def skipIfRosetta(bugnumber):
 """Skip a test when running the testsuite on macOS under the Rosetta translation layer."""
 def is_running_rosetta(self):
-if not lldbplatformutil.getPlatform() in ['darwin', 'macosx']:
-return "not on macOS"
-if (platform.uname()[5] == "arm") and (self.getArchitecture() == "x86_64"):
-return "skipped under Rosetta"
+if lldbplatformutil.getPlatform() in ['darwin', 'macosx']:
+if (platform.uname()[5] == "arm") and (self.getArchitecture() == "x86_64"):
+return "skipped under Rosetta"
 return None
 return skipTestIfFn(is_running_rosetta)
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 4fccdd5 - [lldb] Fix bug in skipIfRosetta decorator

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

Author: Jonas Devlieghere
Date: 2020-08-05T20:51:07-07:00
New Revision: 4fccdd5c85d05b3b03d029f533762e233259573c

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

LOG: [lldb] Fix bug in skipIfRosetta decorator

Currently, the skipIfRosetta decorator will skip tests with the message
"not on macOS" on all platforms that are not `darwin` or `macosx`.
Instead, it should only check the platform and architecture when running
on these platforms.

This triggers for example when running the test suite on device.

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

Added: 


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

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index a472e1c4c52e..bdfe6ffd58c0 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -538,10 +538,9 @@ def are_sb_headers_missing():
 def skipIfRosetta(bugnumber):
 """Skip a test when running the testsuite on macOS under the Rosetta 
translation layer."""
 def is_running_rosetta(self):
-if not lldbplatformutil.getPlatform() in ['darwin', 'macosx']:
-return "not on macOS"
-if (platform.uname()[5] == "arm") and (self.getArchitecture() == 
"x86_64"):
-return "skipped under Rosetta"
+if lldbplatformutil.getPlatform() in ['darwin', 'macosx']:
+if (platform.uname()[5] == "arm") and (self.getArchitecture() == 
"x86_64"):
+return "skipped under Rosetta"
 return None
 return skipTestIfFn(is_running_rosetta)
 



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


[Lldb-commits] [PATCH] D85396: Fix a small memory leak in VectorType.cpp and BlockPointer.cpp

2020-08-05 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda created this revision.
jasonmolenda added reviewers: jingham, davide.
jasonmolenda added a project: LLDB.
Herald added a subscriber: JDevlieghere.
jasonmolenda requested review of this revision.

Looking over the clang static analyzer, came across this old memory leak - 
looks like it's been around for at least four years.  These two methods both 
call a formatters::*SyntheticFrontEndCreator method which new's an object and 
returns a pointer to it; they save save that pointer but never call delete.  
This patch puts it in an auto_ptr so it'll be destroyed when it goes out of 
scope.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D85396

Files:
  lldb/source/DataFormatters/VectorType.cpp
  lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp


Index: lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -175,9 +175,9 @@
 
 bool lldb_private::formatters::BlockPointerSummaryProvider(
 ValueObject &valobj, Stream &s, const TypeSummaryOptions &) {
-  lldb_private::SyntheticChildrenFrontEnd *synthetic_children =
-  BlockPointerSyntheticFrontEndCreator(nullptr, valobj.GetSP());
-  if (!synthetic_children) {
+std::auto_ptr synthetic_children;
+synthetic_children.reset(BlockPointerSyntheticFrontEndCreator(nullptr, 
valobj.GetSP()));
+  if (!synthetic_children.get()) {
 return false;
   }
 
Index: lldb/source/DataFormatters/VectorType.cpp
===
--- lldb/source/DataFormatters/VectorType.cpp
+++ lldb/source/DataFormatters/VectorType.cpp
@@ -261,9 +261,9 @@
 
 bool lldb_private::formatters::VectorTypeSummaryProvider(
 ValueObject &valobj, Stream &s, const TypeSummaryOptions &) {
-  auto synthetic_children =
-  VectorTypeSyntheticFrontEndCreator(nullptr, valobj.GetSP());
-  if (!synthetic_children)
+  std::auto_ptr synthetic_children;
+  synthetic_children.reset(VectorTypeSyntheticFrontEndCreator(nullptr, 
valobj.GetSP()));
+  if (!synthetic_children.get())
 return false;
 
   synthetic_children->Update();


Index: lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -175,9 +175,9 @@
 
 bool lldb_private::formatters::BlockPointerSummaryProvider(
 ValueObject &valobj, Stream &s, const TypeSummaryOptions &) {
-  lldb_private::SyntheticChildrenFrontEnd *synthetic_children =
-  BlockPointerSyntheticFrontEndCreator(nullptr, valobj.GetSP());
-  if (!synthetic_children) {
+std::auto_ptr synthetic_children;
+synthetic_children.reset(BlockPointerSyntheticFrontEndCreator(nullptr, valobj.GetSP()));
+  if (!synthetic_children.get()) {
 return false;
   }
 
Index: lldb/source/DataFormatters/VectorType.cpp
===
--- lldb/source/DataFormatters/VectorType.cpp
+++ lldb/source/DataFormatters/VectorType.cpp
@@ -261,9 +261,9 @@
 
 bool lldb_private::formatters::VectorTypeSummaryProvider(
 ValueObject &valobj, Stream &s, const TypeSummaryOptions &) {
-  auto synthetic_children =
-  VectorTypeSyntheticFrontEndCreator(nullptr, valobj.GetSP());
-  if (!synthetic_children)
+  std::auto_ptr synthetic_children;
+  synthetic_children.reset(VectorTypeSyntheticFrontEndCreator(nullptr, valobj.GetSP()));
+  if (!synthetic_children.get())
 return false;
 
   synthetic_children->Update();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85396: Fix a small memory leak in VectorType.cpp and BlockPointer.cpp

2020-08-05 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda updated this revision to Diff 283484.
jasonmolenda added a comment.

Made the change in Xcode and the indentation was off.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85396

Files:
  lldb/source/DataFormatters/VectorType.cpp
  lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp


Index: lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -175,9 +175,10 @@
 
 bool lldb_private::formatters::BlockPointerSummaryProvider(
 ValueObject &valobj, Stream &s, const TypeSummaryOptions &) {
-  lldb_private::SyntheticChildrenFrontEnd *synthetic_children =
-  BlockPointerSyntheticFrontEndCreator(nullptr, valobj.GetSP());
-  if (!synthetic_children) {
+  std::auto_ptr synthetic_children;
+  synthetic_children.reset(
+  BlockPointerSyntheticFrontEndCreator(nullptr, valobj.GetSP()));
+  if (!synthetic_children.get()) {
 return false;
   }
 
Index: lldb/source/DataFormatters/VectorType.cpp
===
--- lldb/source/DataFormatters/VectorType.cpp
+++ lldb/source/DataFormatters/VectorType.cpp
@@ -261,9 +261,10 @@
 
 bool lldb_private::formatters::VectorTypeSummaryProvider(
 ValueObject &valobj, Stream &s, const TypeSummaryOptions &) {
-  auto synthetic_children =
-  VectorTypeSyntheticFrontEndCreator(nullptr, valobj.GetSP());
-  if (!synthetic_children)
+  std::auto_ptr synthetic_children;
+  synthetic_children.reset(
+  VectorTypeSyntheticFrontEndCreator(nullptr, valobj.GetSP()));
+  if (!synthetic_children.get())
 return false;
 
   synthetic_children->Update();


Index: lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -175,9 +175,10 @@
 
 bool lldb_private::formatters::BlockPointerSummaryProvider(
 ValueObject &valobj, Stream &s, const TypeSummaryOptions &) {
-  lldb_private::SyntheticChildrenFrontEnd *synthetic_children =
-  BlockPointerSyntheticFrontEndCreator(nullptr, valobj.GetSP());
-  if (!synthetic_children) {
+  std::auto_ptr synthetic_children;
+  synthetic_children.reset(
+  BlockPointerSyntheticFrontEndCreator(nullptr, valobj.GetSP()));
+  if (!synthetic_children.get()) {
 return false;
   }
 
Index: lldb/source/DataFormatters/VectorType.cpp
===
--- lldb/source/DataFormatters/VectorType.cpp
+++ lldb/source/DataFormatters/VectorType.cpp
@@ -261,9 +261,10 @@
 
 bool lldb_private::formatters::VectorTypeSummaryProvider(
 ValueObject &valobj, Stream &s, const TypeSummaryOptions &) {
-  auto synthetic_children =
-  VectorTypeSyntheticFrontEndCreator(nullptr, valobj.GetSP());
-  if (!synthetic_children)
+  std::auto_ptr synthetic_children;
+  synthetic_children.reset(
+  VectorTypeSyntheticFrontEndCreator(nullptr, valobj.GetSP()));
+  if (!synthetic_children.get())
 return false;
 
   synthetic_children->Update();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85396: Fix a small memory leak in VectorType.cpp and BlockPointer.cpp

2020-08-05 Thread Davide Italiano via Phabricator via lldb-commits
davide accepted this revision.
davide added a comment.
This revision is now accepted and ready to land.

This is correct to the best of my understanding. Thank you Jason.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85396

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


[Lldb-commits] [PATCH] D85396: Fix a small memory leak in VectorType.cpp and BlockPointer.cpp

2020-08-05 Thread Thorsten via Phabricator via lldb-commits
tschuett added a comment.

auto_ptr is deprecated since C++11 and will be removed in C++17.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85396

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


[Lldb-commits] [PATCH] D85396: Fix a small memory leak in VectorType.cpp and BlockPointer.cpp

2020-08-05 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

In D85396#2198668 , @tschuett wrote:

> auto_ptr is deprecated since C++11 and will be removed in C++17.

@jasonmolenda you might want to use `std::unique_ptr` instead -- probably LLVM 
won't migrate to 17 for a while, but still.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85396

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


[Lldb-commits] [PATCH] D85396: Fix a small memory leak in VectorType.cpp and BlockPointer.cpp

2020-08-05 Thread Thorsten via Phabricator via lldb-commits
tschuett added a comment.

And you can write it as

  std::unique_ptr synthetic_children = 
std::make_unique(...);


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85396

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


[Lldb-commits] [PATCH] D85396: Fix a small memory leak in VectorType.cpp and BlockPointer.cpp

2020-08-05 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda updated this revision to Diff 283489.
jasonmolenda added a comment.

Update to std::unique_ptr -- thanks for the reminder!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85396

Files:
  lldb/source/DataFormatters/VectorType.cpp
  lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp


Index: lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -175,9 +175,10 @@
 
 bool lldb_private::formatters::BlockPointerSummaryProvider(
 ValueObject &valobj, Stream &s, const TypeSummaryOptions &) {
-  lldb_private::SyntheticChildrenFrontEnd *synthetic_children =
-  BlockPointerSyntheticFrontEndCreator(nullptr, valobj.GetSP());
-  if (!synthetic_children) {
+  std::unique_ptr synthetic_children;
+  synthetic_children.reset(
+  BlockPointerSyntheticFrontEndCreator(nullptr, valobj.GetSP()));
+  if (!synthetic_children.get()) {
 return false;
   }
 
Index: lldb/source/DataFormatters/VectorType.cpp
===
--- lldb/source/DataFormatters/VectorType.cpp
+++ lldb/source/DataFormatters/VectorType.cpp
@@ -261,9 +261,10 @@
 
 bool lldb_private::formatters::VectorTypeSummaryProvider(
 ValueObject &valobj, Stream &s, const TypeSummaryOptions &) {
-  auto synthetic_children =
-  VectorTypeSyntheticFrontEndCreator(nullptr, valobj.GetSP());
-  if (!synthetic_children)
+  std::unique_ptr synthetic_children;
+  synthetic_children.reset(
+  VectorTypeSyntheticFrontEndCreator(nullptr, valobj.GetSP()));
+  if (!synthetic_children.get())
 return false;
 
   synthetic_children->Update();


Index: lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -175,9 +175,10 @@
 
 bool lldb_private::formatters::BlockPointerSummaryProvider(
 ValueObject &valobj, Stream &s, const TypeSummaryOptions &) {
-  lldb_private::SyntheticChildrenFrontEnd *synthetic_children =
-  BlockPointerSyntheticFrontEndCreator(nullptr, valobj.GetSP());
-  if (!synthetic_children) {
+  std::unique_ptr synthetic_children;
+  synthetic_children.reset(
+  BlockPointerSyntheticFrontEndCreator(nullptr, valobj.GetSP()));
+  if (!synthetic_children.get()) {
 return false;
   }
 
Index: lldb/source/DataFormatters/VectorType.cpp
===
--- lldb/source/DataFormatters/VectorType.cpp
+++ lldb/source/DataFormatters/VectorType.cpp
@@ -261,9 +261,10 @@
 
 bool lldb_private::formatters::VectorTypeSummaryProvider(
 ValueObject &valobj, Stream &s, const TypeSummaryOptions &) {
-  auto synthetic_children =
-  VectorTypeSyntheticFrontEndCreator(nullptr, valobj.GetSP());
-  if (!synthetic_children)
+  std::unique_ptr synthetic_children;
+  synthetic_children.reset(
+  VectorTypeSyntheticFrontEndCreator(nullptr, valobj.GetSP()));
+  if (!synthetic_children.get())
 return false;
 
   synthetic_children->Update();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 9097ef8 - [lldb] Remove pointless assign to found_suffix (NFC)

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

Author: Jonas Devlieghere
Date: 2020-08-05T22:54:03-07:00
New Revision: 9097ef84ce590dd002c972522d08c1de1329a7ce

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

LOG: [lldb] Remove pointless assign to found_suffix (NFC)

Added: 


Modified: 
lldb/source/Utility/Args.cpp

Removed: 




diff  --git a/lldb/source/Utility/Args.cpp b/lldb/source/Utility/Args.cpp
index f718c6f9ff1c..4f3285404b6d 100644
--- a/lldb/source/Utility/Args.cpp
+++ b/lldb/source/Utility/Args.cpp
@@ -640,7 +640,6 @@ void OptionsWithRaw::SetFromString(llvm::StringRef 
arg_string) {
   }
 
   bool found_suffix = false;
-
   while (!arg_string.empty()) {
 // The length of the prefix before parsing.
 std::size_t prev_prefix_length = original_args.size() - arg_string.size();
@@ -679,10 +678,8 @@ void OptionsWithRaw::SetFromString(llvm::StringRef 
arg_string) {
   }
 
   // If we didn't find a suffix delimiter, the whole string is the raw suffix.
-  if (!found_suffix) {
-found_suffix = true;
+  if (!found_suffix)
 m_suffix = std::string(original_args);
-  }
 }
 
 void llvm::yaml::MappingTraits::mapping(IO &io,



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


[Lldb-commits] [lldb] fc0e8fb - [lldb][gui] truncate long lines/names if needed

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

Author: Luboš Luňák
Date: 2020-08-06T08:40:42+02:00
New Revision: fc0e8fb7874a73277b221e3f940b749cdd0a99d7

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

LOG: [lldb][gui] truncate long lines/names if needed

Without this, sources with long lines or variable names may overwrite
panel frames, or even overrun to the following line. There's currently
no way to scroll left/right in the views, so that should be added
to handle these cases.
This commit includes fixing constness of some Window functions,
and also makes PutCStringTruncated() consistent with the added
printf-like variant to take the padding as the first argument (can't
add it after the format to the printf-like function).

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

Added: 
lldb/test/API/commands/gui/viewlarge/Makefile
lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py
lldb/test/API/commands/gui/viewlarge/main.c

Modified: 
lldb/source/Core/IOHandlerCursesGUI.cpp

Removed: 




diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp 
b/lldb/source/Core/IOHandlerCursesGUI.cpp
index 37e24d4f7533..5a921ceeb84a 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -367,23 +367,23 @@ class Window {
   }
   void Clear() { ::wclear(m_window); }
   void Erase() { ::werase(m_window); }
-  Rect GetBounds() {
+  Rect GetBounds() const {
 return Rect(GetParentOrigin(), GetSize());
   } // Get the rectangle in our parent window
   int GetChar() { return ::wgetch(m_window); }
-  int GetCursorX() { return getcurx(m_window); }
-  int GetCursorY() { return getcury(m_window); }
-  Rect GetFrame() {
+  int GetCursorX() const { return getcurx(m_window); }
+  int GetCursorY() const { return getcury(m_window); }
+  Rect GetFrame() const {
 return Rect(Point(), GetSize());
   } // Get our rectangle in our own coordinate system
-  Point GetParentOrigin() { return Point(GetParentX(), GetParentY()); }
-  Size GetSize() { return Size(GetWidth(), GetHeight()); }
-  int GetParentX() { return getparx(m_window); }
-  int GetParentY() { return getpary(m_window); }
-  int GetMaxX() { return getmaxx(m_window); }
-  int GetMaxY() { return getmaxy(m_window); }
-  int GetWidth() { return GetMaxX(); }
-  int GetHeight() { return GetMaxY(); }
+  Point GetParentOrigin() const { return Point(GetParentX(), GetParentY()); }
+  Size GetSize() const { return Size(GetWidth(), GetHeight()); }
+  int GetParentX() const { return getparx(m_window); }
+  int GetParentY() const { return getpary(m_window); }
+  int GetMaxX() const { return getmaxx(m_window); }
+  int GetMaxY() const { return getmaxy(m_window); }
+  int GetWidth() const { return GetMaxX(); }
+  int GetHeight() const { return GetMaxY(); }
   void MoveCursor(int x, int y) { ::wmove(m_window, y, x); }
   void MoveWindow(int x, int y) { MoveWindow(Point(x, y)); }
   void Resize(int w, int h) { ::wresize(m_window, h, w); }
@@ -396,7 +396,7 @@ class Window {
 ::wbkgd(m_window, COLOR_PAIR(color_pair_idx));
   }
 
-  void PutCStringTruncated(const char *s, int right_pad) {
+  void PutCStringTruncated(int right_pad, const char *s) {
 int bytes_left = GetWidth() - GetCursorX();
 if (bytes_left > right_pad) {
   bytes_left -= right_pad;
@@ -438,6 +438,20 @@ class Window {
 va_end(args);
   }
 
+  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());
+  }
+
+  size_t LimitLengthToRestOfLine(size_t length) const {
+return std::min(length, std::max(0, GetWidth() - GetCursorX() - 
1));
+  }
+
   void Touch() {
 ::touchwin(m_window);
 if (m_parent)
@@ -553,7 +567,7 @@ class Window {
   } else {
 MoveCursor(1, GetHeight() - 1);
 PutChar('[');
-PutCStringTruncated(bottom_message, 1);
+PutCStringTruncated(1, bottom_message);
   }
 }
 if (attr)
@@ -1911,7 +1925,7 @@ class FrameTreeDelegate : public TreeDelegate {
 if (FormatEntity::Format(m_format, strm, &sc, &exe_ctx, nullptr,
  nullptr, false, false)) {
   int right_pad = 1;
-  window.PutCStringTruncated(strm.GetString().str().c_str(), 
right_pad);
+  window.PutCStringTruncated(right_pad, 
strm.GetString().str().c_str());
 }
   }
 }
@@ -1970,7 +1984,7 @@ class ThreadTreeDelegate : public TreeDelegate {
   if (FormatEntity::Format(m_format, strm, nullptr, &exe_ctx, nullptr,
nullptr, false, false)) {
 int right_pad = 1;
-window.PutCStringTruncated(strm.Get

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

2020-08-05 Thread Luboš Luňák via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfc0e8fb7874a: [lldb][gui] truncate long lines/names if 
needed (authored by llunak).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85123

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/test/API/commands/gui/viewlarge/Makefile
  lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py
  lldb/test/API/commands/gui/viewlarge/main.c

Index: lldb/test/API/commands/gui/viewlarge/main.c
===
--- /dev/null
+++ lldb/test/API/commands/gui/viewlarge/main.c
@@ -0,0 +1,7 @@
+int main(int argc, char **argv) {
+  // This is to be viewed in a 80-column terminal, so make the line below more
+  // than 120 characters wide, to span at least two lines.
+  int a_variable_with_a_very_loong_name = 22;
+  int shortvar = 1;
+  return a_variable_with_a_very_loong_name; // Break here
+}
Index: lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py
===
--- /dev/null
+++ lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py
@@ -0,0 +1,52 @@
+"""
+Test that the 'gui' displays long lines/names correctly without overruns.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+class GuiViewLargeCommandTest(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+@skipIfCursesSupportMissing
+@skipIfRemote # "run" command will not work correctly for remote debug
+def test_gui(self):
+self.build()
+
+# Limit columns to 80, so that long lines will not be displayed completely.
+self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100,80))
+self.expect('br set -f main.c -p "// Break here"', substrs=["Breakpoint 1", "address ="])
+self.expect("run", substrs=["stop reason ="])
+
+escape_key = chr(27).encode()
+
+# Start the GUI and close the welcome window.
+self.child.sendline("gui")
+self.child.send(escape_key)
+
+# Check the sources window.
+self.child.expect_exact("Sources")
+# The string is copy&pasted from a 80-columns terminal. It will be followed by some
+# kind of an escape sequence (color, frame, etc.).
+self.child.expect_exact("int a_variable_with_a_very_looo"+chr(27))
+# The escape here checks that there's no content drawn by the previous line.
+self.child.expect_exact("int shortvar = 1;"+chr(27))
+# Check the triggered breakpoint marker on a long line.
+self.child.expect_exact("<<< Thread 1: breakpoint 1.1"+chr(27))
+
+# Check the variable window.
+self.child.expect_exact("Variables")
+self.child.expect_exact("(int) a_variable_with_a_very_looo"+chr(27))
+self.child.expect_exact("(int) shortvar = 1"+chr(27))
+
+# Press escape to quit the gui
+self.child.send(escape_key)
+
+self.expect_prompt()
+self.quit()
Index: lldb/test/API/commands/gui/viewlarge/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/gui/viewlarge/Makefile
@@ -0,0 +1,2 @@
+C_SOURCES := main.c
+include Makefile.rules
Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -367,23 +367,23 @@
   }
   void Clear() { ::wclear(m_window); }
   void Erase() { ::werase(m_window); }
-  Rect GetBounds() {
+  Rect GetBounds() const {
 return Rect(GetParentOrigin(), GetSize());
   } // Get the rectangle in our parent window
   int GetChar() { return ::wgetch(m_window); }
-  int GetCursorX() { return getcurx(m_window); }
-  int GetCursorY() { return getcury(m_window); }
-  Rect GetFrame() {
+  int GetCursorX() const { return getcurx(m_window); }
+  int GetCursorY() const { return getcury(m_window); }
+  Rect GetFrame() const {
 return Rect(Point(), GetSize());
   } // Get our rectangle in our own coordinate system
-  Point GetParentOrigin() { return Point(GetParentX(), GetParentY()); }
-  Size GetSize() { return Size(GetWidth(), GetHeight()); }
-  int GetParentX() { return getparx(m_window); }
-  int GetParentY() { return getpary(m_window); }
-  int GetMaxX() { return getmaxx(m_window); }
-  int GetMaxY() { return getmaxy(m_window

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

2020-08-05 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

Sorry was OOO.

The source code is user input, so you can have anything in it. LLDB will 
happily read and return any file contents as long as it matches the source 
path. Like, create a test.cpp, compile it, then just copy over some binary file 
to the source path. Not that we should do some complicated error handling in 
this case, but as long as we don't assert and end the whole debug session it's 
IMHO fine. This LGTM to me now, thanks for working on this!

In D85145#2192991 , @llunak wrote:

> 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.

Yeah I had the same realization when I typed the example.


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