[Lldb-commits] [lldb] 4a8e4b5 - [lldb][gui] use names for color pairs, instead of magic numbers

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

Author: Luboš Luňák
Date: 2020-08-06T08:58:29+02:00
New Revision: 4a8e4b5c744791da629ec4a282acdf536f4471dd

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

LOG: [lldb][gui] use names for color pairs, instead of magic numbers

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

Added: 


Modified: 
lldb/source/Core/IOHandlerCursesGUI.cpp

Removed: 




diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp 
b/lldb/source/Core/IOHandlerCursesGUI.cpp
index 4eb441a4d7ee..9ae077124ab1 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -273,6 +273,32 @@ struct KeyHelp {
   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 @@ class Window {
 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 @@ class Window {
   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 @@ class Window {
   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 @@ void Menu::DrawMenuTitle(Window &window, bool 
highlight) {
 
 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 @@ bool Menu::WindowDelegateDraw(Window &window, bool force) 
{
   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 @@ bool Menu::WindowDelegateDraw(Window &window, bool force) 
{
 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 @@ class ValueObjectListDelegate : public WindowDelegate {
 
 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 @@ class StatusBarWindowDelegate : public WindowDelegate {
 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 @@ class SourceFileWindowDelegate : public WindowDelegate {
   }
 
   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_lin

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

2020-08-06 Thread Luboš Luňák via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4a8e4b5c7447: [lldb][gui] use names for color pairs, instead 
of magic numbers (authored by llunak).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

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

2020-08-06 Thread Luboš Luňák via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG14406ca01fd3: [lldb][gui] use syntax highlighting also in 
gui mode (authored by llunak).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D85145?vs=282865&id=283498#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85145

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp

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

[Lldb-commits] [lldb] 14406ca - [lldb][gui] use syntax highlighting also in gui mode

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

Author: Luboš Luňák
Date: 2020-08-06T08:57:53+02:00
New Revision: 14406ca01fd3f401742b0f78f3780f62f3934468

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

LOG: [lldb][gui] use syntax highlighting also in gui mode

Use the same functionality as the non-gui mode, the colors just
need translating to curses colors.

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

Added: 


Modified: 
lldb/source/Core/IOHandlerCursesGUI.cpp

Removed: 




diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp 
b/lldb/source/Core/IOHandlerCursesGUI.cpp
index 5a921ceeb84a..4eb441a4d7ee 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -396,11 +396,11 @@ class Window {
 ::wbkgd(m_window, COLOR_PAIR(color_pair_idx));
   }
 
-  void PutCStringTruncated(int right_pad, const char *s) {
+  void PutCStringTruncated(int right_pad, const char *s, int len = -1) {
 int bytes_left = GetWidth() - GetCursorX();
 if (bytes_left > right_pad) {
   bytes_left -= right_pad;
-  ::waddnstr(m_window, s, bytes_left);
+  ::waddnstr(m_window, s, len < 0 ? bytes_left : std::min(bytes_left, 
len));
 }
   }
 
@@ -452,6 +452,62 @@ class Window {
 return std::min(length, std::max(0, GetWidth() - GetCursorX() - 
1));
   }
 
+  // Curses doesn't allow direct output of color escape sequences, but that's
+  // how we get source lines from the Highligher class. Read the line and
+  // convert color escape sequences to curses color attributes.
+  void OutputColoredStringTruncated(int right_pad, StringRef string,
+bool use_blue_background) {
+attr_t saved_attr;
+short saved_pair;
+int saved_opts;
+::wattr_get(m_window, &saved_attr, &saved_pair, &saved_opts);
+if (use_blue_background)
+  ::wattron(m_window, COLOR_PAIR(16));
+while (!string.empty()) {
+  size_t esc_pos = string.find('\x1b');
+  if (esc_pos == StringRef::npos) {
+PutCStringTruncated(right_pad, string.data(), string.size());
+break;
+  }
+  if (esc_pos > 0) {
+PutCStringTruncated(right_pad, string.data(), esc_pos);
+string = string.drop_front(esc_pos);
+  }
+  bool consumed = string.consume_front("\x1b");
+  assert(consumed);
+  UNUSED_IF_ASSERT_DISABLED(consumed);
+  // This is written to match our Highlighter classes, which seem to
+  // generate only foreground color escape sequences. If necessary, this
+  // will need to be extended.
+  if (!string.consume_front("[")) {
+llvm::errs() << "Missing '[' in color escape sequence.\n";
+continue;
+  }
+  // Only 8 basic foreground colors and reset, our Highlighter doesn't use
+  // anything else.
+  int value;
+  if (!!string.consumeInteger(10, value) || // Returns false on success.
+  !(value == 0 || (value >= 30 && value <= 37))) {
+llvm::errs() << "No valid color code in color escape sequence.\n";
+continue;
+  }
+  if (!string.consume_front("m")) {
+llvm::errs() << "Missing 'm' in color escape sequence.\n";
+continue;
+  }
+  if (value == 0) { // Reset.
+::wattr_set(m_window, saved_attr, saved_pair, &saved_opts);
+if (use_blue_background)
+  ::wattron(m_window, COLOR_PAIR(16));
+  } else {
+// Mapped directly to first 16 color pairs (black/blue background).
+::wattron(m_window,
+  COLOR_PAIR(value - 30 + 1 + (use_blue_background ? 8 : 0)));
+  }
+}
+::wattr_set(m_window, saved_attr, saved_pair, &saved_opts);
+  }
+
   void Touch() {
 ::touchwin(m_window);
 if (m_parent)
@@ -540,7 +596,7 @@ class Window {
   void DrawTitleBox(const char *title, const char *bottom_message = nullptr) {
 attr_t attr = 0;
 if (IsActive())
-  attr = A_BOLD | COLOR_PAIR(2);
+  attr = A_BOLD | COLOR_PAIR(18);
 else
   attr = 0;
 if (attr)
@@ -970,14 +1026,14 @@ void Menu::DrawMenuTitle(Window &window, bool highlight) 
{
 
 if (m_key_name.empty()) {
   if (!underlined_shortcut && llvm::isPrint(m_key_value)) {
-window.AttributeOn(COLOR_PAIR(3));
+window.AttributeOn(COLOR_PAIR(19));
 window.Printf(" (%c)", m_key_value);
-window.AttributeOff(COLOR_PAIR(3));
+window.AttributeOff(COLOR_PAIR(19));
   }
 } else {
-  window.AttributeOn(COLOR_PAIR(3));
+  window.AttributeOn(COLOR_PAIR(19));
   window.Printf(" (%s)", m_key_name.c_str());
-  window.AttributeOff(COLOR_PAIR(3));
+  window.AttributeOff(COLOR_PAIR(19));
 }
   }
 }
@@ -989,7 +1045,7 @@ bool Menu::WindowDelegateDraw(Window &window, bool force) {
   Menu::Type menu_type = GetType();
   switch 

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

2020-08-06 Thread Xing GUO via Phabricator via lldb-commits
Higuoxing added a subscriber: jankratochvil.
Higuoxing added a comment.

CC @jankratochvil who might also have thoughts on this topic :-)


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] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

2020-08-06 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

So the way the issue with the single space is now solved is by doing 
CC_REDISPLAY when we're only adding the single space? Isn't that also deleting 
the whole autosuggestion?

In D81001#2190864 , @gedatsu217 wrote:

 I don't think the value of m_previous_autosuggestion_size should only grow 
 (which is what this if is doing), as this way we just keep printing a 
 longer and longer space buffer over time. Just printing enough to clear 
 the buffer of the previous completion is enough.
>>>
>>> If I keep the number of characters of the only previous command, I think 
>>> there is a problem. For example, If I type "help frame var" → "help frame 
>>> info" → "help frame v", the remains are hidden. However, If I type "help 
>>> frame var" → "help frame info" → "help" → "help frame v", the number of 
>>> characters of "help frame var" is more than that of "help", so "help frame 
>>> v[aro]" is displayed. What do you think?
>>
>> Not sure if I understand your example correctly, but as soon as you type 
>> "help frame ", you should have an autosuggestion of "help frame info" and 
>> then typing the "v" should clear the "nfo" part. The "help" autosuggestion 
>> should not be involved at all in any logic after you typed "help "?
>
> What I mean is that if I should keep the length of characters of the only 
> previous command, following thing occurs.
>
> 1. execution "help frame var" and m_previous_autosuggestion_size = len("help 
> frame var") = 14
> 2. execution "help frame info" and m_previous_autosuggestion_size = len("help 
> frame info") = 15
> 3. execution "help" and m_previous_autosuggestion_size = len("help") = 4
> 4. Typing "help frame v". Then, spaces_to_print = 
> m_previous_autosuggestion_size - line.size() - to_add.getValue().length() = 4 
> - 12 - 2 < 0. So, spaces are not added. (In short, "help frame v[aro]" is 
> displayed.)
>
> (Maybe, I do not understand what you say. )

I think you got it :). My point was that `m_previous_autosuggestion_size` is 
updated everytime you type a character from what I can see, so you don't see 
the `4` from step 3. It's more like this from what I can tell:

1. same as your step 1.
2. same as your step 2.
3. same asyour step 3: execution "help" and m_previous_autosuggestion_size = 
len("help") = 4

3.5 [new step]: Typing "help frame ". m_previous_autosuggestion_size = 
len("help frame info") = 15. This is because we update the size in 
TypedCharacter which gets triggered for every character.

4. Typing "help frame v". Then, spaces_to_print = 
m_previous_autosuggestion_size - line.size() - to_add.getValue().length() = 15 
- 12 - 2 = 1. (which is exactly the space needed to overwrite the 'o').




Comment at: lldb/source/Host/common/Editline.cpp:1009
 to_add.push_back(request.GetParsedArg().GetQuoteChar());
+  if (m_suggestion_callback && to_add.empty()) {
+to_add.push_back(' ');

I think this can be shortened to just:
```
lang=c++
  to_add.push_back(' ');
  el_insertstr(m_editline, to_add.c_str());
  // Clear autosuggestion from line buffer if we only added a space.
  if (to_add == " ")
return CC_REDISPLAY;
  return CC_REFRESH;
}
```



Comment at: lldb/source/Host/common/Editline.cpp:1081
+if (spaces_to_print > 0) {
+  std::string spaces = std::string((int)spaces_to_print, ' ');
+  fputs(spaces.c_str(), m_output_file);

The `(int)` cast isn't necessary.


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

https://reviews.llvm.org/D81001

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


[Lldb-commits] [lldb] d40c44e - [lldb] Fix LLDB compilation with ncurses 6.2 due to wattr_set/get being a macro

2020-08-06 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-08-06T10:52:57+02:00
New Revision: d40c44e89e11659439072a4b57d2c0c191d5cae5

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

LOG: [lldb] Fix LLDB compilation with ncurses 6.2 due to wattr_set/get being a 
macro

My ncurses 6.2 arch defines those two functions as macros, so the scope operator
doesn't work here.

Added: 


Modified: 
lldb/source/Core/IOHandlerCursesGUI.cpp

Removed: 




diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp 
b/lldb/source/Core/IOHandlerCursesGUI.cpp
index 9ae077124ab1..931ddb2ea9e3 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -486,7 +486,7 @@ class Window {
 attr_t saved_attr;
 short saved_pair;
 int saved_opts;
-::wattr_get(m_window, &saved_attr, &saved_pair, &saved_opts);
+wattr_get(m_window, &saved_attr, &saved_pair, &saved_opts);
 if (use_blue_background)
   ::wattron(m_window, COLOR_PAIR(WhiteOnBlue));
 while (!string.empty()) {
@@ -522,7 +522,7 @@ class Window {
 continue;
   }
   if (value == 0) { // Reset.
-::wattr_set(m_window, saved_attr, saved_pair, &saved_opts);
+wattr_set(m_window, saved_attr, saved_pair, &saved_opts);
 if (use_blue_background)
   ::wattron(m_window, COLOR_PAIR(WhiteOnBlue));
   } else {
@@ -531,7 +531,7 @@ class Window {
   COLOR_PAIR(value - 30 + 1 + (use_blue_background ? 8 : 0)));
   }
 }
-::wattr_set(m_window, saved_attr, saved_pair, &saved_opts);
+wattr_set(m_window, saved_attr, saved_pair, &saved_opts);
   }
 
   void Touch() {



___
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-06 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.
Herald added a subscriber: JDevlieghere.

This broke compilation on Ubuntu 18.04:

  In file included from ../tools/lldb/source/Core/IOHandlerCursesGUI.cpp:17:0:
  ../tools/lldb/source/Core/IOHandlerCursesGUI.cpp: In member function ‘void 
curses::Window::OutputColoredStringTruncated(int, llvm::StringRef, bool)’:
  ../tools/lldb/source/Core/IOHandlerCursesGUI.cpp:463:7: error: expected 
id-expression before ‘(’ token
   ::wattr_get(m_window, &saved_attr, &saved_pair, &saved_opts);
 ^
  ../tools/lldb/source/Core/IOHandlerCursesGUI.cpp:499:11: error: expected 
id-expression before ‘(’ token
   ::wattr_set(m_window, saved_attr, saved_pair, &saved_opts);
 ^
  ../tools/lldb/source/Core/IOHandlerCursesGUI.cpp:508:7: error: expected 
id-expression before ‘(’ token
   ::wattr_set(m_window, saved_attr, saved_pair, &saved_opts);
 ^


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85145

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


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

2020-08-06 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Same on Arch Linux. Should be fixed in 45f9fc890705a8272e5253602f5506fdef4586e2 
(I just removed the scope operator).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85145

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


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

2020-08-06 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D85145#2199045 , @teemperor wrote:

> Same on Arch Linux. Should be fixed in 
> 45f9fc890705a8272e5253602f5506fdef4586e2 (I just removed the scope operator).

Indeed it is, thanks!


Repository:
  rG LLVM Github Monorepo

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] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

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

> So the way the issue with the single space is now solved is by doing 
> CC_REDISPLAY when we're only adding the single space? Isn't that also 
> deleting the whole autosuggestion?

Yes. CC_REDISPLAY can delete all the gray characters left.




Comment at: lldb/source/Host/common/Editline.cpp:1081
+if (spaces_to_print > 0) {
+  std::string spaces = std::string((int)spaces_to_print, ' ');
+  fputs(spaces.c_str(), m_output_file);

teemperor wrote:
> The `(int)` cast isn't necessary.
I found that lldb crashed. Sorry, I should have checked more when I uploaded 
this.

I use spaces_to_print as size_t, but this sometimes becomes less than zero. So, 
I have to use this as int.




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

https://reviews.llvm.org/D81001

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


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

2020-08-06 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added subscribers: max-kudr, omjavaid.
omjavaid added a comment.

In D85235#2198062 , @JDevlieghere 
wrote:

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

This still fails on http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu and 
http://lab.llvm.org:8011/builders/lldb-arm-ubuntu


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] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

2020-08-06 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

In D81001#2199205 , @gedatsu217 wrote:

>> So the way the issue with the single space is now solved is by doing 
>> CC_REDISPLAY when we're only adding the single space? Isn't that also 
>> deleting the whole autosuggestion?
>
> Yes. CC_REDISPLAY can delete all the gray characters left.

So, if I would type "b" and then press tab, the autosuggestion would briefly 
disappear until I type the next character?




Comment at: lldb/source/Host/common/Editline.cpp:1081
+if (spaces_to_print > 0) {
+  std::string spaces = std::string((int)spaces_to_print, ' ');
+  fputs(spaces.c_str(), m_output_file);

gedatsu217 wrote:
> teemperor wrote:
> > The `(int)` cast isn't necessary.
> I found that lldb crashed. Sorry, I should have checked more when I uploaded 
> this.
> 
> I use spaces_to_print as size_t, but this sometimes becomes less than zero. 
> So, I have to use this as int.
> 
> 
Yeah I see that spaces_to_print can overflow. How about this code instead that 
avoids all the casting and overflowing and so on:

```
lang=c++
size_t new_autosuggestion_size = line.size() + to_add->length();
// If the previous command line + autosuggestion was longer than the
// current autosuggestion, make sure that the autosuggestion is overwriting
// the old output by enough adding trailing spaces.
if (new_autosuggestion_size < m_previous_autosuggestion_size) {
  size_t spaces_to_print = m_previous_autosuggestion_size - 
new_autosuggestion_size;
  std::string spaces = std::string(spaces_to_print, ' ');
  fputs(spaces.c_str(), m_output_file);
}
m_previous_autosuggestion_size = new_autosuggestion_size;
```


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

https://reviews.llvm.org/D81001

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


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

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

> So, if I would type "b" and then press tab, the autosuggestion would briefly 
> disappear until I type the next character?

Yes. Indeed, it may not be good.  I'll think of other ways.


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

https://reviews.llvm.org/D81001

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


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

2020-08-06 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

In D81001#2199450 , @gedatsu217 wrote:

>> So, if I would type "b" and then press tab, the autosuggestion would briefly 
>> disappear until I type the next character?
>
> Yes. Indeed, it may not be good.  I'll think of other ways.

This seems minor enough that I wouldn't block the whole patch over it, so this 
can be addresses in a follow-up patch.

Are there any other problems with the current state of the patch that haven't 
been resolved? (I went over the comments, but it's hard to say what has and 
hasn't been fixed until now).


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

https://reviews.llvm.org/D81001

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


[Lldb-commits] [PATCH] D85134: [lldb][AArch64] Correct compile options for Neon corefile

2020-08-06 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid accepted this revision.
omjavaid added a comment.
This revision is now accepted and ready to land.

Thanks for fixing this. SVE was just a typo orignal core files were generated 
without SVE flag on a aarch64-linux target.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85134

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


[Lldb-commits] [lldb] 94a5919 - [LLDB] Skip test_launch_simple from TestTargetAPI.py on Arm/AArch64 Linux

2020-08-06 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2020-08-06T17:38:20+05:00
New Revision: 94a5919946a0a6b87720d9d1dfd15071ae3a5a49

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

LOG: [LLDB] Skip test_launch_simple from TestTargetAPI.py on Arm/AArch64 Linux

Recently added TestTargetAPI.py test "test_launch_simple" is failing on
Arm/AArch64 Linux targets. Putting them to skip until fixed.

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

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 7db53883eb6a..70bf1a3b4d07 100644
--- a/lldb/test/API/python_api/target/TestTargetAPI.py
+++ b/lldb/test/API/python_api/target/TestTargetAPI.py
@@ -153,6 +153,7 @@ def test_read_memory(self):
 
 @add_test_categories(['pyapi'])
 @skipIfWindows  # stdio manipulation unsupported on Windows
+@skipIf(oslist=["linux"], archs=["arm", "aarch64"])
 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] D85134: [lldb][AArch64] Correct compile options for Neon corefile

2020-08-06 Thread David Spickett via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe82866d5d9ee: [lldb][AArch64] Correct compile options for 
Neon corefile (authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85134

Files:
  lldb/test/API/functionalities/postmortem/elf-core/aarch64-neon.c
  lldb/test/API/functionalities/postmortem/elf-core/linux-aarch64-neon.c


Index: lldb/test/API/functionalities/postmortem/elf-core/linux-aarch64-neon.c
===
--- lldb/test/API/functionalities/postmortem/elf-core/linux-aarch64-neon.c
+++ lldb/test/API/functionalities/postmortem/elf-core/linux-aarch64-neon.c
@@ -1,6 +1,6 @@
-// compile with -march=armv8-a+sve on compatible aarch64 compiler
-// linux-aarch64-sve.core was generated by: aarch64-linux-gnu-gcc-8
-// commandline: -march=armv8-a+sve -nostdlib -static -g linux-aarch64-sve.c
+// compile with -march=armv8-a+simd on compatible aarch64 compiler
+// linux-aarch64-neon.core was generated by: aarch64-linux-gnu-gcc-8
+// commandline: -march=armv8-a+simd -nostdlib -static -g linux-aarch64-neon.c
 static void bar(char *boom) {
   char F = 'b';
   asm volatile("fmov d0,  #0.5\n\t");


Index: lldb/test/API/functionalities/postmortem/elf-core/linux-aarch64-neon.c
===
--- lldb/test/API/functionalities/postmortem/elf-core/linux-aarch64-neon.c
+++ lldb/test/API/functionalities/postmortem/elf-core/linux-aarch64-neon.c
@@ -1,6 +1,6 @@
-// compile with -march=armv8-a+sve on compatible aarch64 compiler
-// linux-aarch64-sve.core was generated by: aarch64-linux-gnu-gcc-8
-// commandline: -march=armv8-a+sve -nostdlib -static -g linux-aarch64-sve.c
+// compile with -march=armv8-a+simd on compatible aarch64 compiler
+// linux-aarch64-neon.core was generated by: aarch64-linux-gnu-gcc-8
+// commandline: -march=armv8-a+simd -nostdlib -static -g linux-aarch64-neon.c
 static void bar(char *boom) {
   char F = 'b';
   asm volatile("fmov d0,  #0.5\n\t");
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] e82866d - [lldb][AArch64] Correct compile options for Neon corefile

2020-08-06 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2020-08-06T13:39:09+01:00
New Revision: e82866d5d9eef913252833789acda04ef8389e52

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

LOG: [lldb][AArch64] Correct compile options for Neon corefile

SVE is not required, it has its own test. Note that
there is no "+neon" so "+simd" is used instead.

Also rename the file to match the name of the corefile
it produces.

Reviewed By: omjavaid

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

Added: 
lldb/test/API/functionalities/postmortem/elf-core/linux-aarch64-neon.c

Modified: 


Removed: 
lldb/test/API/functionalities/postmortem/elf-core/aarch64-neon.c



diff  --git a/lldb/test/API/functionalities/postmortem/elf-core/aarch64-neon.c 
b/lldb/test/API/functionalities/postmortem/elf-core/linux-aarch64-neon.c
similarity index 75%
rename from lldb/test/API/functionalities/postmortem/elf-core/aarch64-neon.c
rename to lldb/test/API/functionalities/postmortem/elf-core/linux-aarch64-neon.c
index e5742d2e44b7..475e1ac93f88 100644
--- a/lldb/test/API/functionalities/postmortem/elf-core/aarch64-neon.c
+++ b/lldb/test/API/functionalities/postmortem/elf-core/linux-aarch64-neon.c
@@ -1,6 +1,6 @@
-// compile with -march=armv8-a+sve on compatible aarch64 compiler
-// linux-aarch64-sve.core was generated by: aarch64-linux-gnu-gcc-8
-// commandline: -march=armv8-a+sve -nostdlib -static -g linux-aarch64-sve.c
+// compile with -march=armv8-a+simd on compatible aarch64 compiler
+// linux-aarch64-neon.core was generated by: aarch64-linux-gnu-gcc-8
+// commandline: -march=armv8-a+simd -nostdlib -static -g linux-aarch64-neon.c
 static void bar(char *boom) {
   char F = 'b';
   asm volatile("fmov d0,  #0.5\n\t");



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


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

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

> Are there any other problems with the current state of the patch that haven't 
> been resolved? (I went over the comments, but it's hard to say what has and 
> hasn't been fixed until now).

Yes, I have solved all the problems.


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

https://reviews.llvm.org/D81001

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


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

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

Simplify the code.


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

https://reviews.llvm.org/D81001

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

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

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

2020-08-06 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Alright, let's see if the others see any other issues, otherwise I think this 
is finally good to go.




Comment at: lldb/source/Host/common/Editline.cpp:1011
   el_insertstr(m_editline, to_add.c_str());
-  break;
+  if (to_add == " ")
+return CC_REDISPLAY;

Without a comment this code is very mysterious to whoever will read it.


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

https://reviews.llvm.org/D81001

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


[Lldb-commits] [lldb] a6db64e - [ELF] Allow sections after a non-SHF_ALLOC section to be covered by PT_LOAD

2020-08-06 Thread Fangrui Song via lldb-commits

Author: Fangrui Song
Date: 2020-08-06T08:27:15-07:00
New Revision: a6db64ef4a9906c96ef5652739ac15aefaa7827c

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

LOG: [ELF] Allow sections after a non-SHF_ALLOC section to be covered by PT_LOAD

GNU ld allows sections after a non-SHF_ALLOC section to be covered by PT_LOAD
(PR37607) and assigns addresses to non-SHF_ALLOC output sections (similar to
SHF_ALLOC NOBITS sections. The location counter is not advanced).

This patch tries to fix PR37607 (remove a special case in
`Writer::createPhdrs`). To make the created PT_LOAD meaningful, we cannot
reset dot to 0 for a middle non-SHF_ALLOC output section. This results in
removal of two special cases in LinkerScript::assignOffsets. Non-SHF_ALLOC
non-orphan sections can have non-zero addresses like in GNU ld.

The zero address rule for non-SHF_ALLOC sections is weakened to apply to orphan
only. This results in a special case in createSection and findOrphanPos, 
respectively.

Reviewed By: jhenderson

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

Added: 


Modified: 
lld/ELF/LinkerScript.cpp
lld/ELF/Writer.cpp
lld/test/ELF/linkerscript/compress-debug-sections-custom.s
lld/test/ELF/linkerscript/sections.s
lld/test/ELF/linkerscript/symbols-non-alloc.test
lldb/test/Shell/SymbolFile/DWARF/Inputs/debug-line-basic.script

Removed: 




diff  --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 72e2ebff9b8c..a187aa1eb05a 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -586,6 +586,8 @@ static OutputSection *findByName(ArrayRef 
vec,
 static OutputSection *createSection(InputSectionBase *isec,
 StringRef outsecName) {
   OutputSection *sec = script->createOutputSection(outsecName, "");
+  if (!(isec->flags & SHF_ALLOC))
+sec->addrExpr = [] { return 0; };
   sec->recordSection(isec);
   return sec;
 }
@@ -848,9 +850,6 @@ static OutputSection *findFirstSection(PhdrEntry *load) {
 // This function assigns offsets to input sections and an output section
 // for a single sections command (e.g. ".text { *(.text); }").
 void LinkerScript::assignOffsets(OutputSection *sec) {
-  if (!(sec->flags & SHF_ALLOC))
-dot = 0;
-
   const bool sameMemRegion = ctx->memRegion == sec->memRegion;
   const bool prevLMARegionIsDefault = ctx->lmaRegion == nullptr;
   ctx->memRegion = sec->memRegion;
@@ -858,7 +857,7 @@ void LinkerScript::assignOffsets(OutputSection *sec) {
   if (ctx->memRegion)
 dot = ctx->memRegion->curPos;
 
-  if ((sec->flags & SHF_ALLOC) && sec->addrExpr)
+  if (sec->addrExpr)
 setDot(sec->addrExpr, sec->location, false);
 
   // If the address of the section has been moved forward by an explicit

diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index c1469e123336..1bd6fb61e2e4 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1234,7 +1234,13 @@ static bool shouldSkip(BaseCommand *cmd) {
 static std::vector::iterator
 findOrphanPos(std::vector::iterator b,
   std::vector::iterator e) {
+  // OutputSections without the SHF_ALLOC flag are not part of the memory image
+  // and their addresses usually don't matter. Place any orphan sections 
without
+  // the SHF_ALLOC flag at the end so that these do not affect the address
+  // assignment of OutputSections with the SHF_ALLOC flag.
   OutputSection *sec = cast(*e);
+  if (!(sec->flags & SHF_ALLOC))
+return e;
 
   // Find the first element that has as close a rank as possible.
   auto i = std::max_element(b, e, [=](BaseCommand *a, BaseCommand *b) {
@@ -2329,8 +2335,6 @@ std::vector 
Writer::createPhdrs(Partition &part) {
   }
 
   for (OutputSection *sec : outputSections) {
-if (!(sec->flags & SHF_ALLOC))
-  break;
 if (!needsPtLoad(sec))
   continue;
 

diff  --git a/lld/test/ELF/linkerscript/compress-debug-sections-custom.s 
b/lld/test/ELF/linkerscript/compress-debug-sections-custom.s
index f61d6398b1f0..7b9a8d091bf5 100644
--- a/lld/test/ELF/linkerscript/compress-debug-sections-custom.s
+++ b/lld/test/ELF/linkerscript/compress-debug-sections-custom.s
@@ -1,9 +1,10 @@
 # REQUIRES: x86, zlib
 
+## NOTE GNU ld makes .debug_str and .debug_info SHF_ALLOC due to `. += 10`.
 # RUN: echo "SECTIONS { \
 # RUN:  .text : { . += 0x10; *(.text) } \
-# RUN:  .debug_str : { . += 0x10; *(.debug_str) } \
-# RUN:  .debug_info : { . += 0x10; *(.debug_info) } \
+# RUN:  .debug_str 0 : { . += 0x10; *(.debug_str) } \
+# RUN:  .debug_info 0 : { . += 0x10; *(.debug_info) } \
 # RUN:  }" > %t.script
 
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o

diff  --git a/lld/test/ELF/linkerscript/sections.s 
b/lld/test/ELF/linkerscript/sections.s
index 

[Lldb-commits] [PATCH] D85100: [ELF] Allow sections after a non-SHF_ALLOC section to be covered by PT_LOAD

2020-08-06 Thread Fangrui Song via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Revision".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa6db64ef4a99: [ELF] Allow sections after a non-SHF_ALLOC 
section to be covered by PT_LOAD (authored by MaskRay).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D85100?vs=283277&id=283618#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85100

Files:
  lld/ELF/LinkerScript.cpp
  lld/ELF/Writer.cpp
  lld/test/ELF/linkerscript/compress-debug-sections-custom.s
  lld/test/ELF/linkerscript/sections.s
  lld/test/ELF/linkerscript/symbols-non-alloc.test
  lldb/test/Shell/SymbolFile/DWARF/Inputs/debug-line-basic.script

Index: lldb/test/Shell/SymbolFile/DWARF/Inputs/debug-line-basic.script
===
--- lldb/test/Shell/SymbolFile/DWARF/Inputs/debug-line-basic.script
+++ lldb/test/Shell/SymbolFile/DWARF/Inputs/debug-line-basic.script
@@ -2,11 +2,11 @@
   text PT_LOAD;
 }
 SECTIONS {
-  .shstrtab : { *(.shstrtab) }
-  .debug_info   : { *(.debug_info  ) }
-  .debug_line   : { *(.debug_line  ) }
-  .debug_str: { *(.debug_str   ) }
-  .debug_abbrev : { *(.debug_abbrev) }
+  .shstrtab 0 : { *(.shstrtab) }
+  .debug_info   0 : { *(.debug_info  ) }
+  .debug_line   0 : { *(.debug_line  ) }
+  .debug_str0 : { *(.debug_str   ) }
+  .debug_abbrev 0 : { *(.debug_abbrev) }
 
   . = 0x201000;
   .text : { *(.text .text.f) } :text
Index: lld/test/ELF/linkerscript/symbols-non-alloc.test
===
--- lld/test/ELF/linkerscript/symbols-non-alloc.test
+++ lld/test/ELF/linkerscript/symbols-non-alloc.test
@@ -1,14 +1,17 @@
 # REQUIRES: x86
+## The address of a symbol assignment after a non-SHF_ALLOC section equals the
+## end address of the section.
+
 # RUN: echo '.section .nonalloc,""; .quad 0' \
 # RUN:   | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t
 # RUN: ld.lld -o %t2 --script %s %t
 # RUN: llvm-objdump --section-headers -t %t2 | FileCheck %s
 
 # CHECK: Sections:
-# CHECK:  .nonalloc 0008 
+# CHECK:  .nonalloc 0008 0120
 
 # CHECK: SYMBOL TABLE:
-# CHECK:  0008 g .nonalloc  Sym
+# CHECK:  0128 g .nonalloc  Sym
 
 SECTIONS {
   . = SIZEOF_HEADERS;
Index: lld/test/ELF/linkerscript/sections.s
===
--- lld/test/ELF/linkerscript/sections.s
+++ lld/test/ELF/linkerscript/sections.s
@@ -25,8 +25,10 @@
 # SEC-DEFAULT: 7 .shstrtab 003b {{[0-9a-f]*}}
 # SEC-DEFAULT: 8 .strtab   0008 {{[0-9a-f]*}}
 
-# Sections are put in order specified in linker script, other than alloc
-# sections going first.
+## Sections are placed in the order specified by the linker script. .data has
+## a PT_LOAD segment, even if it is preceded by a non-alloc section. To
+## allow this, place non-alloc orphan sections at the end and advance
+## location counters for non-alloc non-orphan sections.
 # RUN: echo "SECTIONS { \
 # RUN:  .bss : { *(.bss) } \
 # RUN:  other : { *(other) } \
@@ -34,20 +36,27 @@
 # RUN:  .symtab : { *(.symtab) } \
 # RUN:  .strtab : { *(.strtab) } \
 # RUN:  .data : { *(.data) } \
-# RUN:  .text : { *(.text) } }" > %t.script
-# RUN: ld.lld -o %t3 --script %t.script %t
-# RUN: llvm-objdump --section-headers %t3 | \
-# RUN:   FileCheck -check-prefix=SEC-ORDER %s
+# RUN:  .text : { *(.text) } }" > %t3.lds
+# RUN: ld.lld -o %t3a -T %t3.lds %t
+# RUN: llvm-readelf -S -l %t3a | FileCheck --check-prefix=SEC-ORDER %s
+# RUN: ld.lld -o %t3b -T %t3.lds --unique %t
+# RUN: llvm-readelf -S -l %t3b | FileCheck --check-prefix=SEC-ORDER %s
 
-#   Idx Name  Size
-# SEC-ORDER: 1 .bss  0002 {{[0-9a-f]*}} BSS
-# SEC-ORDER: 2 other 0003 {{[0-9a-f]*}} DATA
-# SEC-ORDER: 3 .shstrtab 003b {{[0-9a-f]*}}
-# SEC-ORDER: 4 .symtab   0030 {{[0-9a-f]*}}
-# SEC-ORDER: 5 .strtab   0008 {{[0-9a-f]*}}
-# SEC-ORDER: 6 .comment  0008 {{[0-9a-f]*}}
-# SEC-ORDER: 7 .data 0020 {{[0-9a-f]*}} DATA
-# SEC-ORDER: 8 .text 000e {{[0-9a-f]*}} TEXT
+# SEC-ORDER:   [Nr] Name  Type Address  OffSize   ES Flg
+# SEC-ORDER:   [ 0]   NULL  00 00 00
+# SEC-ORDER-NEXT:  [ 1] .bss  NOBITS    001000 02 00  WA
+# SEC-ORDER-NEXT:  [ 2] other PROGBITS 0002 001002 03 00  WA
+# SEC-ORDER-NEXT:  [ 3] .shstrtab STRTAB   0005 001005 3b 00
+# SEC-ORDER-NEXT:  [ 4] .symtab   SYMTAB   0040 001040 30 18
+# SEC-ORDER-NEXT:  [ 5] .strtab   STRTAB   

[Lldb-commits] [lldb] f6913e7 - [lldb][NFC] Document and encapsulate OriginMap in ASTContextMetadata

2020-08-06 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-08-06T17:37:29+02:00
New Revision: f6913e74400aa932b3edc7cc765495247799fcb0

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

LOG: [lldb][NFC] Document and encapsulate OriginMap in ASTContextMetadata

Just adds the respective accessor functions to ASTContextMetadata instead
of directly exposing the OriginMap to the whole world.

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index ac16738933ac..6d8773779a69 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -245,9 +245,9 @@ class CompleteTagDeclsScope : public 
ClangASTImporter::NewDeclListener {
   m_decls_already_completed.insert(decl);
 
   // We should only complete decls coming from the source context.
-  assert(to_context_md->m_origins[decl].ctx == m_src_ctx);
+  assert(to_context_md->getOrigin(decl).ctx == m_src_ctx);
 
-  Decl *original_decl = to_context_md->m_origins[decl].decl;
+  Decl *original_decl = to_context_md->getOrigin(decl).decl;
 
   // Complete the decl now.
   TypeSystemClang::GetCompleteDecl(m_src_ctx, original_decl);
@@ -266,7 +266,7 @@ class CompleteTagDeclsScope : public 
ClangASTImporter::NewDeclListener {
 container_decl->setHasExternalVisibleStorage(false);
   }
 
-  to_context_md->m_origins.erase(decl);
+  to_context_md->removeOrigin(decl);
 }
 
 // Stop listening to imported decls. We do this after clearing the
@@ -581,10 +581,7 @@ bool 
ClangASTImporter::CompleteTagDeclWithOrigin(clang::TagDecl *decl,
 
   ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
 
-  OriginMap &origins = context_md->m_origins;
-
-  origins[decl] = DeclOrigin(origin_ast_ctx, origin_decl);
-
+  context_md->setOrigin(decl, DeclOrigin(origin_ast_ctx, origin_decl));
   return true;
 }
 
@@ -721,29 +718,14 @@ ClangASTImporter::DeclOrigin
 ClangASTImporter::GetDeclOrigin(const clang::Decl *decl) {
   ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
 
-  OriginMap &origins = context_md->m_origins;
-
-  OriginMap::iterator iter = origins.find(decl);
-
-  if (iter != origins.end())
-return iter->second;
-  return DeclOrigin();
+  return context_md->getOrigin(decl);
 }
 
 void ClangASTImporter::SetDeclOrigin(const clang::Decl *decl,
  clang::Decl *original_decl) {
   ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
-
-  OriginMap &origins = context_md->m_origins;
-
-  OriginMap::iterator iter = origins.find(decl);
-
-  if (iter != origins.end()) {
-iter->second.decl = original_decl;
-iter->second.ctx = &original_decl->getASTContext();
-return;
-  }
-  origins[decl] = DeclOrigin(&original_decl->getASTContext(), original_decl);
+  context_md->setOrigin(
+  decl, DeclOrigin(&original_decl->getASTContext(), original_decl));
 }
 
 void ClangASTImporter::RegisterNamespaceMap(const clang::NamespaceDecl *decl,
@@ -817,14 +799,7 @@ void ClangASTImporter::ForgetSource(clang::ASTContext 
*dst_ast,
 return;
 
   md->m_delegates.erase(src_ast);
-
-  for (OriginMap::iterator iter = md->m_origins.begin();
-   iter != md->m_origins.end();) {
-if (iter->second.ctx == src_ast)
-  md->m_origins.erase(iter++);
-else
-  ++iter;
-  }
+  md->removeOriginsWithContext(src_ast);
 }
 
 ClangASTImporter::MapCompleter::~MapCompleter() { return; }
@@ -1100,37 +1075,31 @@ void 
ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
   m_master.MaybeGetContextMetadata(m_source_ctx);
 
   if (from_context_md) {
-OriginMap &origins = from_context_md->m_origins;
+DeclOrigin origin = from_context_md->getOrigin(from);
 
-OriginMap::iterator origin_iter = origins.find(from);
-
-if (origin_iter != origins.end()) {
-  if (to_context_md->m_origins.find(to) == to_context_md->m_origins.end() 
||
-  user_id != LLDB_INVALID_UID) {
-if (origin_iter->second.ctx != &to->getASTContext())
-  to_context_md->m_origins[to] = origin_iter->second;
-  }
+if (origin.Valid()) {
+  if (!to_context_md->hasOrigin(to) || user_id != LLDB_INVALID_UID)
+if (origin.ctx != &to->getASTContext())
+  to_context_md->setOrigin(to, origin);
 
   ImporterDelegateSP direct_completer =
-  m_master.GetDelegate(&to->getASTContext(), origin_iter->second.ctx);
+  m_master.GetDelegate(&to->ge

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

2020-08-06 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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] D85376: Fix how ValueObjectChild handles bit-fields stored in a Scalar in UpdateValue()

2020-08-06 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a subscriber: JDevlieghere.
shafik 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

friss wrote:
> 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.
`lldb_private::DumpDataExtractor(…)` is general purpose and it used by a lot of 
other code, it does know the value comes from a `Scalar` or otherwise it is 
just receiving a `DataExtractor` and obtaining the data from there. 



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

aprantl wrote:
> 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.
I did try using Specifying Registers for Local Variables and it did not work :-(

but in good news, I don't need the `-O1` it was left over when I was struggling 
to get the test going.



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

shafik wrote:
> aprantl wrote:
> > 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.
> I did try using Specifying Registers for Local Variables and it did not work 
> :-(
> 
> but in good news, I don't need the `-O1` it was left over when I was 
> struggling to get the test going.
Yes, this was left over when I was experimenting trying to get the test to work 
I do not need the `-O1`.



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

aprantl wrote:
> Is it possible to just override the rule that produces the .o file? Otherwise 
> you are dropping the codesign and dsymutil phase.
Let me see if I can remove the `.o` step.



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

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



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

aprantl wrote:
> lldbutil has a helper for running to a breakpoint by name.
I could not get it to work using `lldbutil` I was working w/ @JDevlieghere on 
this and he thought that made sense. IIUC I would have rewrite the assembly 
file to make it work.


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-06 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik updated this revision to Diff 283647.
shafik added a comment.

Removing use of `-O1` from Makefile.


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

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   ## Loc expr size
+	.byte	85  ## super-register DW_OP_reg5
+.set Lset2, Ltmp0-Lfunc_begin0
+	.quad	Lset2
+.set Lset3, Ltmp1-Lfunc_begin0
+	.quad	Lset3
+	.short	1   ## Loc expr size
+	.byte	84  ## super-register DW_OP_reg4
+	.quad	0
+	.quad	0
+	.section	__DWARF,__debug_abbrev,regular,debug
+Lsection_abbrev:
+	.byte	1   ## Abbreviation Code
+	.byte	17  ## DW_TAG_compile_unit
+	.byte	1   ## DW_CHILDREN_yes
+	.byte	37  ## DW_AT_producer
+	.byte	14  ## DW_F

[Lldb-commits] [lldb] 9dbdaea - Remove unused variable "saved_opts".

2020-08-06 Thread Sterling Augustine via lldb-commits

Author: Sterling Augustine
Date: 2020-08-06T10:20:21-07:00
New Revision: 9dbdaea9a0e6f58417b5bd8980e7ea6723fd1783

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

LOG: Remove unused variable "saved_opts".

wattr_get is a macro, and the documentation states:
"The parameter opts is reserved for  future use,
applications must supply a null pointer."

In practice, passing a variable there is harmless, except
that it is unused inside the macro, which causes unused
variable warnings.

The various places where

Added: 


Modified: 
lldb/source/Core/IOHandlerCursesGUI.cpp

Removed: 




diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp 
b/lldb/source/Core/IOHandlerCursesGUI.cpp
index 931ddb2ea9e3..6a24625fc7eb 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -485,8 +485,7 @@ class Window {
 bool use_blue_background) {
 attr_t saved_attr;
 short saved_pair;
-int saved_opts;
-wattr_get(m_window, &saved_attr, &saved_pair, &saved_opts);
+wattr_get(m_window, &saved_attr, &saved_pair, nullptr);
 if (use_blue_background)
   ::wattron(m_window, COLOR_PAIR(WhiteOnBlue));
 while (!string.empty()) {
@@ -522,7 +521,7 @@ class Window {
 continue;
   }
   if (value == 0) { // Reset.
-wattr_set(m_window, saved_attr, saved_pair, &saved_opts);
+wattr_set(m_window, saved_attr, saved_pair, nullptr);
 if (use_blue_background)
   ::wattron(m_window, COLOR_PAIR(WhiteOnBlue));
   } else {
@@ -531,7 +530,7 @@ class Window {
   COLOR_PAIR(value - 30 + 1 + (use_blue_background ? 8 : 0)));
   }
 }
-wattr_set(m_window, saved_attr, saved_pair, &saved_opts);
+wattr_set(m_window, saved_attr, saved_pair, nullptr);
   }
 
   void Touch() {



___
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-06 Thread Sterling Augustine via Phabricator via lldb-commits
saugustine added a comment.

This change has a subtle isse with wattr_get and friends: saved_opts isn't 
actually used, and the documentation for them says to always pass a nullptr. 
"The parameter opts is reserved for future use, applications must supply a null 
pointer."

I fixed it in 9dbdaea9a0e6f58417b5bd8980e7ea6723fd1783 
.


Repository:
  rG LLVM Github Monorepo

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] [lldb] 99298c7 - [lldb/testsuite] Change get_debugserver_exe to support Rosetta

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

Author: Fred Riss
Date: 2020-08-06T10:38:30-07:00
New Revision: 99298c7fc540c74c89c92f0e5d617e00cb87cf19

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

LOG: [lldb/testsuite] Change get_debugserver_exe to support Rosetta

In order to be able to run the debugserver tests against the Rosetta
debugserver, detect the Rosetta run configuration and return the
system Rosetta debugserver.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
index 815ba3491c1d..e0ea38c78840 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
@@ -12,6 +12,7 @@
 import socket_packet_pump
 import subprocess
 from lldbsuite.test.lldbtest import *
+from lldbsuite.test import configuration
 
 from six.moves import queue
 
@@ -89,6 +90,10 @@ def get_debugserver_exe():
 if "LLDB_DEBUGSERVER_PATH" in os.environ:
 return os.environ["LLDB_DEBUGSERVER_PATH"]
 
+if configuration.arch and configuration.arch == "x86_64" and \
+   platform.machine().startswith("arm64"):
+return '/Library/Apple/usr/libexec/oah/debugserver'
+
 return _get_debug_monitor_from_lldb(
 lldbtest_config.lldbExec, "debugserver")
 



___
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-06 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik updated this revision to Diff 283658.
shafik added a comment.

- Refactored the Makefile and test based on offline comments from Adrian.


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

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   ## Loc expr size
+	.byte	85  ## super-register DW_OP_reg5
+.set Lset2, Ltmp0-Lfunc_begin0
+	.quad	Lset2
+.set Lset3, Ltmp1-Lfunc_begin0
+	.quad	Lset3
+	.short	1   ## Loc expr size
+	.byte	84  ## super-register DW_OP_reg4
+	.quad	0
+	.quad	0
+	.section	__DWARF,__debug_abbrev,regular,debug
+Lsection_abbrev:
+	.byte	1   ## Abbreviation Code
+	.byte	17  ## DW_TAG_compile_unit
+	.byte	1   ## DW_CHILDREN_yes
+	.byte	37  ## DW_AT_producer
+	

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

2020-08-06 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

shafik wrote:
> friss wrote:
> > 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.
> `lldb_private::DumpDataExtractor(…)` is general purpose and it used by a lot 
> of other code, it does know the value comes from a `Scalar` or otherwise it 
> is just receiving a `DataExtractor` and obtaining the data from there. 
You didn't answer the most important question. Will `GetValueAsUnsigned` return 
the correct value on such a ValueObject once you remove this code?


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-06 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 283669.
aprantl added a comment.

Address review feedback.


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

https://reviews.llvm.org/D85049

Files:
  lldb/source/Target/TargetList.cpp
  lldb/test/API/macosx/universal/Makefile
  lldb/test/API/macosx/universal/TestUniversal.py

Index: lldb/test/API/macosx/universal/TestUniversal.py
===
--- lldb/test/API/macosx/universal/TestUniversal.py
+++ lldb/test/API/macosx/universal/TestUniversal.py
@@ -1,7 +1,3 @@
-"""Test aspects of lldb commands on universal binaries."""
-
-
-
 import unittest2
 import os
 import lldb
@@ -14,6 +10,7 @@
 return "AVX2" in features.split()
 
 class UniversalTestCase(TestBase):
+"""Test aspects of lldb commands on universal binaries."""
 
 NO_DEBUG_INFO_TESTCASE = True
 mydir = TestBase.compute_mydir(__file__)
@@ -39,9 +36,10 @@
 
 # Create a target by the debugger.
 target = self.dbg.CreateTargetWithFileAndTargetTriple(
-exe, "x86_64-apple-macosx")
+exe, "x86_64-apple-macosx10.10")
 self.assertTrue(target, VALID_TARGET)
-self.expect("image list -A -b", substrs=["x86_64 testit"])
+self.expect("image list -t -b", substrs=["x86_64-apple-macosx10.9.0 testit"])
+self.expect("target list", substrs=["testit", "arch=x86_64-apple-macosx10.10"])
 
 # Now launch the process, and do not stop at entry point.
 process = target.LaunchSimple(
Index: lldb/test/API/macosx/universal/Makefile
===
--- lldb/test/API/macosx/universal/Makefile
+++ lldb/test/API/macosx/universal/Makefile
@@ -8,13 +8,13 @@
 	lipo -create -o testit $^
 
 testit.x86_64h: testit.x86_64h.o
-	$(CC) -isysroot $(SDKROOT) -arch x86_64h -o testit.x86_64h $<
+	$(CC) -isysroot $(SDKROOT) -target x86_64h-apple-macosx10.9 -o testit.x86_64h $<
 
 testit.x86_64: testit.x86_64.o
-	$(CC) -isysroot $(SDKROOT) -arch x86_64 -o testit.x86_64 $<
+	$(CC) -isysroot $(SDKROOT) -target x86_64-apple-macosx10.9 -o testit.x86_64 $<
 
 testit.x86_64h.o: main.c
-	$(CC) -isysroot $(SDKROOT) -g -O0 -arch x86_64h -c -o testit.x86_64h.o $<
+	$(CC) -isysroot $(SDKROOT) -g -O0 -target x86_64h-apple-macosx10.9-apple-macosx10.9-apple-macosx10.9-apple-macosx10.9 -c -o testit.x86_64h.o $<
 
 testit.x86_64.o: main.c
-	$(CC) -isysroot $(SDKROOT) -g -O0 -arch x86_64 -c -o testit.x86_64.o $<
+	$(CC) -isysroot $(SDKROOT) -g -O0 -target x86_64-apple-macosx10.9 -c -o testit.x86_64.o $<
Index: lldb/source/Target/TargetList.cpp
===
--- lldb/source/Target/TargetList.cpp
+++ lldb/source/Target/TargetList.cpp
@@ -104,6 +104,15 @@
   }
 
   bool prefer_platform_arch = false;
+  auto update_platform_arch = [&](const ArchSpec &module_arch) {
+// If the OS or vendor weren't specified, then adopt the module's
+// architecture so that the platform matching can be more accurate.
+if (!platform_arch.TripleOSWasSpecified() ||
+!platform_arch.TripleVendorWasSpecified()) {
+  prefer_platform_arch = true;
+  platform_arch = module_arch;
+}
+  };
 
   if (!user_exe_path.empty()) {
 ModuleSpec module_spec(FileSpec(user_exe_path, FileSpec::Style::native));
@@ -155,16 +164,14 @@
   }
 }
   } else if (arch.IsValid()) {
-// A (valid) architecture was specified.
+// Fat binary. A (valid) architecture was specified.
 module_spec.GetArchitecture() = arch;
 if (module_specs.FindMatchingModuleSpec(module_spec,
-matching_module_spec)) {
-  prefer_platform_arch = true;
-  platform_arch = matching_module_spec.GetArchitecture();
-}
+matching_module_spec))
+update_platform_arch(matching_module_spec.GetArchitecture());
   } else {
-// No architecture specified, check if there is only one platform for
-// all of the architectures.
+// Fat binary. No architecture specified, check if there is
+// only one platform for all of the architectures.
 PlatformSP host_platform_sp = Platform::GetHostPlatform();
 std::vector platforms;
 for (size_t i = 0; i < num_specs; ++i) {
@@ -251,7 +258,7 @@
   // If we have a valid architecture, make sure the current platform is
   // compatible with that architecture.
   if (!prefer_platform_arch && arch.IsValid()) {
-if (!platform_sp->IsCompatibleArchitecture(arch, false, &platform_arch)) {
+if (!platform_sp->IsCompatibleArchitecture(arch, false, nullptr)) {
   platform_sp = Platform::GetPlatformForArchitecture(arch, &platform_arch);
   if (!is_dummy_target && platform_sp)
 debugger.GetPlatformList().SetSelectedPlatform(platform_sp);
@@ -260,8 +267,7 @@
 // If "arch" isn't valid, ye

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

2020-08-06 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik 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

friss wrote:
> shafik wrote:
> > friss wrote:
> > > 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.
> > `lldb_private::DumpDataExtractor(…)` is general purpose and it used by a 
> > lot of other code, it does know the value comes from a `Scalar` or 
> > otherwise it is just receiving a `DataExtractor` and obtaining the data 
> > from there. 
> You didn't answer the most important question. Will `GetValueAsUnsigned` 
> return the correct value on such a ValueObject once you remove this code?
apologies, misunderstood.

Yes, it does:

```
(lldb) script var = lldb.frame.FindVariable("u")
(lldb) script print(var.GetChildMemberWithName('raw'))
(uint32_t) raw = 1688469761
(lldb) script print(var.GetChildMemberWithName('a'))
(uint32_t:8) a = 1
(lldb) script print(var.GetChildMemberWithName('b'))
(uint32_t:8) b = 1
(lldb) script print(var.GetChildMemberWithName('c'))
(uint32_t:6) c = 36
(lldb) script print(var.GetChildMemberWithName('d'))
(uint32_t:2) d = 2
(lldb) script print(var.GetChildMemberWithName('e'))
(uint32_t:6) e = 36
(lldb) script print(var.GetChildMemberWithName('f'))
(uint32_t:2) f = 1

```


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] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

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

add comments.

revise a test(add self.quit()).


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

https://reviews.llvm.org/D81001

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

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

[Lldb-commits] [lldb] 86aa8e6 - [lldb] Use target.GetLaunchInfo() instead of creating an empty one.

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

Author: Jonas Devlieghere
Date: 2020-08-06T11:51:26-07:00
New Revision: 86aa8e6363c7e00f211de62ccb3236556e9841df

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

LOG: [lldb] Use target.GetLaunchInfo() instead of creating an empty one.

Update tests that were creating an empty LaunchInfo instead of using the
one coming from the target. This ensures target properties are honored.

Added: 


Modified: 
lldb/test/API/commands/disassemble/basic/TestFrameDisassemble.py
lldb/test/API/commands/frame/language/TestGuessLanguage.py
lldb/test/API/commands/frame/var/TestFrameVar.py

lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py

lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py

lldb/test/API/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py
lldb/test/API/functionalities/signal/TestSendSignal.py

lldb/test/API/functionalities/tail_call_frames/sbapi_support/TestTailCallFrameSBAPI.py

lldb/test/API/functionalities/tail_call_frames/thread_step_out_or_return/TestSteppingOutWithArtificialFrames.py
lldb/test/API/macosx/thread-names/TestInterruptThreadNames.py
lldb/test/API/python_api/process/TestProcessAPI.py
lldb/test/API/python_api/process/io/TestProcessIO.py

Removed: 




diff  --git a/lldb/test/API/commands/disassemble/basic/TestFrameDisassemble.py 
b/lldb/test/API/commands/disassemble/basic/TestFrameDisassemble.py
index 47973a0d61ed..156458234a16 100644
--- a/lldb/test/API/commands/disassemble/basic/TestFrameDisassemble.py
+++ b/lldb/test/API/commands/disassemble/basic/TestFrameDisassemble.py
@@ -41,7 +41,7 @@ def frame_disassemble_test(self):
 # environment variables, add them using SetArguments or
 # SetEnvironmentEntries
 
-launch_info = lldb.SBLaunchInfo(None)
+launch_info = target.GetLaunchInfo()
 process = target.Launch(launch_info, error)
 self.assertTrue(process, PROCESS_IS_VALID)
 

diff  --git a/lldb/test/API/commands/frame/language/TestGuessLanguage.py 
b/lldb/test/API/commands/frame/language/TestGuessLanguage.py
index 32a8950b9711..046f73f37c2b 100644
--- a/lldb/test/API/commands/frame/language/TestGuessLanguage.py
+++ b/lldb/test/API/commands/frame/language/TestGuessLanguage.py
@@ -53,7 +53,7 @@ def do_test(self):
 # environment variables, add them using SetArguments or
 # SetEnvironmentEntries
 
-launch_info = lldb.SBLaunchInfo(None)
+launch_info = target.GetLaunchInfo()
 process = target.Launch(launch_info, error)
 self.assertTrue(process, PROCESS_IS_VALID)
 

diff  --git a/lldb/test/API/commands/frame/var/TestFrameVar.py 
b/lldb/test/API/commands/frame/var/TestFrameVar.py
index 874faf8c64d1..798815fb58be 100644
--- a/lldb/test/API/commands/frame/var/TestFrameVar.py
+++ b/lldb/test/API/commands/frame/var/TestFrameVar.py
@@ -42,7 +42,7 @@ def do_test(self):
 # environment variables, add them using SetArguments or
 # SetEnvironmentEntries
 
-launch_info = lldb.SBLaunchInfo(None)
+launch_info = target.GetLaunchInfo()
 process = target.Launch(launch_info, error)
 self.assertTrue(process, PROCESS_IS_VALID)
 

diff  --git 
a/lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
 
b/lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
index 8ab84bd3203e..47c016e14c2d 100644
--- 
a/lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
+++ 
b/lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
@@ -66,7 +66,7 @@ def test_target_auto_install_main_executable(self):
 
 # Disable the auto install.
 self.runCmd("settings set target.auto-install-main-executable false")
-self.expect("settings show target.auto-install-main-executable", 
+self.expect("settings show target.auto-install-main-executable",
 substrs=["target.auto-install-main-executable (boolean) = false"])
 
 self.runCmd("platform select %s"%configuration.lldb_platform_name)
@@ -80,7 +80,7 @@ def test_target_auto_install_main_executable(self):
 target = new_debugger.GetSelectedTarget()
 breakpoint = target.BreakpointCreateByName("main")
 
-launch_info = lldb.SBLaunchInfo(None)
+launch_info = taget.GetLaunchInfo()
 error = lldb.SBError()
 process = target.Launch(launch_info, error)
 self.assertTrue(process, PROCESS_IS_VALID)

diff  --git 
a/lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py
 
b/lldb/test/API/functionalities/breakpoint/address_breakpoin

[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-06 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl 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;

davide wrote:
> Is this check strict enough? I thought it should be only TripleOSWasSpecified 
> -- what we can infer from the vendor?
Git archeology says that this comes from 
3f19ada88e24008b24a5db20b7f78f5cff525a0b / SVN r212783.
Quoting: `- Fixed the coded in TargetList::CreateTarget() so it does the right 
thing with an underspecified triple where just the arch is specified.`

I think it's specifically supposed to detect a triple with just a CPU, which is 
what we get from `target create --arch`. I think your comment still rings true.


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-06 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik 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

shafik wrote:
> friss wrote:
> > shafik wrote:
> > > friss wrote:
> > > > 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.
> > > `lldb_private::DumpDataExtractor(…)` is general purpose and it used by a 
> > > lot of other code, it does know the value comes from a `Scalar` or 
> > > otherwise it is just receiving a `DataExtractor` and obtaining the data 
> > > from there. 
> > You didn't answer the most important question. Will `GetValueAsUnsigned` 
> > return the correct value on such a ValueObject once you remove this code?
> apologies, misunderstood.
> 
> Yes, it does:
> 
> ```
> (lldb) script var = lldb.frame.FindVariable("u")
> (lldb) script print(var.GetChildMemberWithName('raw'))
> (uint32_t) raw = 1688469761
> (lldb) script print(var.GetChildMemberWithName('a'))
> (uint32_t:8) a = 1
> (lldb) script print(var.GetChildMemberWithName('b'))
> (uint32_t:8) b = 1
> (lldb) script print(var.GetChildMemberWithName('c'))
> (uint32_t:6) c = 36
> (lldb) script print(var.GetChildMemberWithName('d'))
> (uint32_t:2) d = 2
> (lldb) script print(var.GetChildMemberWithName('e'))
> (uint32_t:6) e = 36
> (lldb) script print(var.GetChildMemberWithName('f'))
> (uint32_t:2) f = 1
> 
> ```
Whoops, copy-pasta:

```
(lldb) script print(var.GetChildMemberWithName('raw').GetValueAsUnsigned())
1688469761
(lldb) script print(var.GetChildMemberWithName('a').GetValueAsUnsigned())
1
(lldb) script print(var.GetChildMemberWithName('b').GetValueAsUnsigned())
1
(lldb) script print(var.GetChildMemberWithName('c').GetValueAsUnsigned())
36
(lldb) script print(var.GetChildMemberWithName('d').GetValueAsUnsigned())
2
(lldb) script print(var.GetChildMemberWithName('e').GetValueAsUnsigned())
36
(lldb) script print(var.GetChildMemberWithName('f').GetValueAsUnsigned())
1
```


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-06 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik updated this revision to Diff 283703.
shafik added a comment.

- Add more tests


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

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   ## Loc expr size
+	.byte	85  ## super-register DW_OP_reg5
+.set Lset2, Ltmp0-Lfunc_begin0
+	.quad	Lset2
+.set Lset3, Ltmp1-Lfunc_begin0
+	.quad	Lset3
+	.short	1   ## Loc expr size
+	.byte	84  ## super-register DW_OP_reg4
+	.quad	0
+	.quad	0
+	.section	__DWARF,__debug_abbrev,regular,debug
+Lsection_abbrev:
+	.byte	1   ## Abbreviation Code
+	.byte	17  ## DW_TAG_compile_unit
+	.byte	1   ## DW_CHILDREN_yes
+	.byte	37  ## DW_AT_producer
+	.byte	14  ## DW_FORM_strp
+	.byte	19 

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

2020-08-06 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added a comment.

The test LGTM now! Please be sure to address Fred's comment before committing.


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-06 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Do we have an end-to-end (with source code instead of assembler) test for ObjC 
bitfields, too? If not, it might still be a good a idea to add one even if it 
doesn't add coverage for this particular change.


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] D85358: Correctly detect legacy iOS simulator Mach-O objectfiles

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

LGTM!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/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] [lldb] 05df9cc - Correctly detect legacy iOS simulator Mach-O objectfiles

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

Author: Adrian Prantl
Date: 2020-08-06T12:40:45-07:00
New Revision: 05df9cc70367a60cb34bee773389ab2522984f8b

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

LOG: Correctly detect legacy iOS simulator Mach-O objectfiles

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

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

Added: 


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

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 383cc5b59a37..e7701c350ff5 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -5007,8 +5007,8 @@ void ObjectFileMachO::GetAllArchSpecs(const 
llvm::MachO::mach_header &header,
 
 struct version_min_command version_min;
 switch (load_cmd.cmd) {
-case llvm::MachO::LC_VERSION_MIN_IPHONEOS:
 case llvm::MachO::LC_VERSION_MIN_MACOSX:
+case llvm::MachO::LC_VERSION_MIN_IPHONEOS:
 case llvm::MachO::LC_VERSION_MIN_TVOS:
 case llvm::MachO::LC_VERSION_MIN_WATCHOS: {
   if (load_cmd.cmdsize != sizeof(version_min))
@@ -5024,7 +5024,19 @@ void ObjectFileMachO::GetAllArchSpecs(const 
llvm::MachO::mach_header &header,
 
   auto triple = base_triple;
   triple.setOSName(os.str());
-  os_name.clear();
+
+  // Disambiguate legacy simulator platforms.
+  if (load_cmd.cmd != llvm::MachO::LC_VERSION_MIN_MACOSX &&
+  (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;
 }

diff  --git a/lldb/source/Utility/ArchSpec.cpp 
b/lldb/source/Utility/ArchSpec.cpp
index 6e4f1b5326dd..9cbd5df3a7b6 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -1057,20 +1057,6 @@ bool ArchSpec::IsEqualTo(const ArchSpec &rhs, bool 
exact_match) const {
   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 @@ bool ArchSpec::IsEqualTo(const ArchSpec &rhs, bool 
exact_match) const {
   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 
diff erent, 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);
 }
 

diff  --git a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py 
b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
index 9b5aed1ed619..26264868d893 100644
--- a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -6,7 +6,6 @@
 import unittest2
 
 
-@skipIfDarwin # rdar://problem/64552748
 class TestSimulatorPlatformLaunching(TestBase):
 
  

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

2020-08-06 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG05df9cc70367: Correctly detect legacy iOS simulator Mach-O 
objectfiles (authored by aprantl).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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()) ||
+

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

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



Comment at: lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp:85
+  if (!m_sdk.empty())
+strm.Printf("  SDK Path: \"%s\"\n", m_sdk.str().c_str());
+  else

If you use `<<` you could drop the `.str().c_str()`. Alternatively, you could 
use `Format` which uses the `llvm::fmt` logic.



Comment at: lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h:96
 protected:
+  const char *m_class_name;
+  const char *m_description;

"While you are here" could we make these StringRefs? 



Comment at: lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h:122
+lldb_private::Status
+
+GetSymbolFile(const lldb_private::FileSpec &platform_file,

Weird formatting. Did you clang-format?


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



Comment at: lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp:85
+  if (!m_sdk.empty())
+strm.Printf("  SDK Path: \"%s\"\n", m_sdk.str().c_str());
+  else

JDevlieghere wrote:
> If you use `<<` you could drop the `.str().c_str()`. Alternatively, you could 
> use `Format` which uses the `llvm::fmt` logic.
that makes sense, yes.



Comment at: lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h:96
 protected:
+  const char *m_class_name;
+  const char *m_description;

JDevlieghere wrote:
> "While you are here" could we make these StringRefs? 
I could, but these are used specifically/only for the lldb Plugin API:

`const char *GetDescription() override { return m_description; }`

Do you think it's worth doing regardless?



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-06 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h:96
 protected:
+  const char *m_class_name;
+  const char *m_description;

aprantl wrote:
> JDevlieghere wrote:
> > "While you are here" could we make these StringRefs? 
> I could, but these are used specifically/only for the lldb Plugin API:
> 
> `const char *GetDescription() override { return m_description; }`
> 
> Do you think it's worth doing regardless?
> 
I think it'd be nice, but more something for a separate NFC patch. It's 
definitely not that important and I'm sure you have better stuff to do :p 


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] [lldb] ba37b14 - [LLDB] Skip test_launch_simple from TestTargetAPI.py when remote

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

Author: Jonas Devlieghere
Date: 2020-08-06T13:03:18-07:00
New Revision: ba37b144e6cf7ecaa7e6eb5bb34c02aeaa8a9e3c

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

LOG: [LLDB] Skip test_launch_simple from TestTargetAPI.py when remote

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 70bf1a3b4d07..68c56ae4096b 100644
--- a/lldb/test/API/python_api/target/TestTargetAPI.py
+++ b/lldb/test/API/python_api/target/TestTargetAPI.py
@@ -153,6 +153,7 @@ def test_read_memory(self):
 
 @add_test_categories(['pyapi'])
 @skipIfWindows  # stdio manipulation unsupported on Windows
+@skipIfRemote   # stdio manipulation unsupported on remote iOS 
devices
 @skipIf(oslist=["linux"], archs=["arm", "aarch64"])
 def test_launch_simple(self):
 d = {'EXE': 'b.out'}
@@ -287,7 +288,7 @@ def find_functions(self, exe_name):
 # 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] f406a90 - Add missing override to Makefile

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

Author: Adrian Prantl
Date: 2020-08-06T13:07:16-07:00
New Revision: f406a90a08c3993cd5bfd5e6a546165e55fec9b4

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

LOG: Add missing override to Makefile

Added: 


Modified: 
lldb/test/API/macosx/macCatalyst/Makefile
lldb/test/API/macosx/macCatalystAppMacOSFramework/Makefile

Removed: 




diff  --git a/lldb/test/API/macosx/macCatalyst/Makefile 
b/lldb/test/API/macosx/macCatalyst/Makefile
index 9b9224571fdd..f358ff85ea9f 100644
--- a/lldb/test/API/macosx/macCatalyst/Makefile
+++ b/lldb/test/API/macosx/macCatalyst/Makefile
@@ -1,6 +1,6 @@
 C_SOURCES := main.c
 
-TRIPLE := $(ARCH)-apple-ios13.0-macabi
+override TRIPLE := $(ARCH)-apple-ios13.0-macabi
 CFLAGS_EXTRAS := -target $(TRIPLE)
 
 # FIXME: rdar://problem/54986190

diff  --git a/lldb/test/API/macosx/macCatalystAppMacOSFramework/Makefile 
b/lldb/test/API/macosx/macCatalystAppMacOSFramework/Makefile
index 96fbf4a9cf17..b24fe3f574cc 100644
--- a/lldb/test/API/macosx/macCatalystAppMacOSFramework/Makefile
+++ b/lldb/test/API/macosx/macCatalystAppMacOSFramework/Makefile
@@ -1,7 +1,7 @@
 C_SOURCES := main.c
 LD_EXTRAS := -L. -lfoo
 
-TRIPLE := $(ARCH)-apple-ios13.0-macabi
+override TRIPLE := $(ARCH)-apple-ios13.0-macabi
 CFLAGS_EXTRAS := -target $(TRIPLE)
 
 # FIXME: rdar://problem/54986190



___
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-06 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added inline comments.



Comment at: lldb/source/Target/TargetList.cpp:144
 prefer_platform_arch = true;
 platform_arch = matching_module_spec.GetArchitecture();
   }

Should this conditional be replaced with your `update_platform_arch` lambda? 


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] D85049: Unify the code that updates the ArchSpec after finding a fat binary with how it is done for a lean binary

2020-08-06 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.
This revision is now accepted and ready to land.

LGTM, it's hard to keep all the supported behaviors in my head but I think this 
is right.


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

2020-08-06 Thread Vedant Kumar via Phabricator via lldb-commits
vsk added a comment.

I gave this another look-over, and while I didn't spot anything troubling, I'm 
not terribly familiar with this code. I'll give this a third pass later today 
if review is still needed.




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

aprantl wrote:
> 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.
All the same, just in case we need to introduce mac-specific code in the 
future, it may be more convenient to write this as `#if TARGET_OS_MAC == 1 && 
TARGET_CPU_ARM == 1` (hope I've spelled that correctly!)


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] D85049: Unify the code that updates the ArchSpec after finding a fat binary with how it is done for a lean binary

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



Comment at: lldb/source/Target/TargetList.cpp:144
 prefer_platform_arch = true;
 platform_arch = matching_module_spec.GetArchitecture();
   }

jasonmolenda wrote:
> Should this conditional be replaced with your `update_platform_arch` lambda? 
Yes!


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] D85049: Unify the code that updates the ArchSpec after finding a fat binary with how it is done for a lean binary

2020-08-06 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0fa520af6734: Unify the code that updates the ArchSpec after 
finding a fat binary (authored by aprantl).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D85049?vs=283669&id=283719#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85049

Files:
  lldb/source/Target/TargetList.cpp
  lldb/test/API/macosx/universal/Makefile
  lldb/test/API/macosx/universal/TestUniversal.py

Index: lldb/test/API/macosx/universal/TestUniversal.py
===
--- lldb/test/API/macosx/universal/TestUniversal.py
+++ lldb/test/API/macosx/universal/TestUniversal.py
@@ -1,7 +1,3 @@
-"""Test aspects of lldb commands on universal binaries."""
-
-
-
 import unittest2
 import os
 import lldb
@@ -14,6 +10,7 @@
 return "AVX2" in features.split()
 
 class UniversalTestCase(TestBase):
+"""Test aspects of lldb commands on universal binaries."""
 
 NO_DEBUG_INFO_TESTCASE = True
 mydir = TestBase.compute_mydir(__file__)
@@ -39,9 +36,10 @@
 
 # Create a target by the debugger.
 target = self.dbg.CreateTargetWithFileAndTargetTriple(
-exe, "x86_64-apple-macosx")
+exe, "x86_64-apple-macosx10.10")
 self.assertTrue(target, VALID_TARGET)
-self.expect("image list -A -b", substrs=["x86_64 testit"])
+self.expect("image list -t -b", substrs=["x86_64-apple-macosx10.9.0 testit"])
+self.expect("target list", substrs=["testit", "arch=x86_64-apple-macosx10.10"])
 
 # Now launch the process, and do not stop at entry point.
 process = target.LaunchSimple(
Index: lldb/test/API/macosx/universal/Makefile
===
--- lldb/test/API/macosx/universal/Makefile
+++ lldb/test/API/macosx/universal/Makefile
@@ -8,13 +8,13 @@
 	lipo -create -o testit $^
 
 testit.x86_64h: testit.x86_64h.o
-	$(CC) -isysroot $(SDKROOT) -arch x86_64h -o testit.x86_64h $<
+	$(CC) -isysroot $(SDKROOT) -target x86_64h-apple-macosx10.9 -o testit.x86_64h $<
 
 testit.x86_64: testit.x86_64.o
-	$(CC) -isysroot $(SDKROOT) -arch x86_64 -o testit.x86_64 $<
+	$(CC) -isysroot $(SDKROOT) -target x86_64-apple-macosx10.9 -o testit.x86_64 $<
 
 testit.x86_64h.o: main.c
-	$(CC) -isysroot $(SDKROOT) -g -O0 -arch x86_64h -c -o testit.x86_64h.o $<
+	$(CC) -isysroot $(SDKROOT) -g -O0 -target x86_64h-apple-macosx10.9-apple-macosx10.9-apple-macosx10.9-apple-macosx10.9 -c -o testit.x86_64h.o $<
 
 testit.x86_64.o: main.c
-	$(CC) -isysroot $(SDKROOT) -g -O0 -arch x86_64 -c -o testit.x86_64.o $<
+	$(CC) -isysroot $(SDKROOT) -g -O0 -target x86_64-apple-macosx10.9 -c -o testit.x86_64.o $<
Index: lldb/source/Target/TargetList.cpp
===
--- lldb/source/Target/TargetList.cpp
+++ lldb/source/Target/TargetList.cpp
@@ -104,6 +104,15 @@
   }
 
   bool prefer_platform_arch = false;
+  auto update_platform_arch = [&](const ArchSpec &module_arch) {
+// If the OS or vendor weren't specified, then adopt the module's
+// architecture so that the platform matching can be more accurate.
+if (!platform_arch.TripleOSWasSpecified() ||
+!platform_arch.TripleVendorWasSpecified()) {
+  prefer_platform_arch = true;
+  platform_arch = module_arch;
+}
+  };
 
   if (!user_exe_path.empty()) {
 ModuleSpec module_spec(FileSpec(user_exe_path, FileSpec::Style::native));
@@ -129,11 +138,7 @@
   // If the OS or vendor weren't specified, then adopt the module's
   // architecture so that the platform matching can be more
   // accurate.
-  if (!platform_arch.TripleOSWasSpecified() ||
-  !platform_arch.TripleVendorWasSpecified()) {
-prefer_platform_arch = true;
-platform_arch = matching_module_spec.GetArchitecture();
-  }
+  update_platform_arch(matching_module_spec.GetArchitecture());
 } else {
   StreamString platform_arch_strm;
   StreamString module_arch_strm;
@@ -155,16 +160,14 @@
   }
 }
   } else if (arch.IsValid()) {
-// A (valid) architecture was specified.
+// Fat binary. A (valid) architecture was specified.
 module_spec.GetArchitecture() = arch;
 if (module_specs.FindMatchingModuleSpec(module_spec,
-matching_module_spec)) {
-  prefer_platform_arch = true;
-  platform_arch = matching_module_spec.GetArchitecture();
-}
+matching_module_spec))
+update_platform_arch(matching_module_spec.GetArchitecture());
   } else {
-// No architecture specified, check if there is only one platf

[Lldb-commits] [lldb] 0fa520a - Unify the code that updates the ArchSpec after finding a fat binary

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

Author: Adrian Prantl
Date: 2020-08-06T13:30:17-07:00
New Revision: 0fa520af6734c5f1fab80629337e3f08fd8770db

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

LOG: Unify the code that updates the ArchSpec after finding a fat binary
with how it is done for a lean binary

In particular this affects how target create --arch is handled — it
allowed us to override the deployment target (a useful feature for the
expression evaluator), but the fat binary case didn't.

rdar://problem/66024437

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

(cherry picked from commit 470bdd3caaab0b6e0ffed4da304244be40b78668)

Added: 


Modified: 
lldb/source/Target/TargetList.cpp
lldb/test/API/macosx/universal/Makefile
lldb/test/API/macosx/universal/TestUniversal.py

Removed: 




diff  --git a/lldb/source/Target/TargetList.cpp 
b/lldb/source/Target/TargetList.cpp
index 7e243e5ed338..d4d3740286b7 100644
--- a/lldb/source/Target/TargetList.cpp
+++ b/lldb/source/Target/TargetList.cpp
@@ -104,6 +104,15 @@ Status TargetList::CreateTargetInternal(
   }
 
   bool prefer_platform_arch = false;
+  auto update_platform_arch = [&](const ArchSpec &module_arch) {
+// If the OS or vendor weren't specified, then adopt the module's
+// architecture so that the platform matching can be more accurate.
+if (!platform_arch.TripleOSWasSpecified() ||
+!platform_arch.TripleVendorWasSpecified()) {
+  prefer_platform_arch = true;
+  platform_arch = module_arch;
+}
+  };
 
   if (!user_exe_path.empty()) {
 ModuleSpec module_spec(FileSpec(user_exe_path, FileSpec::Style::native));
@@ -129,11 +138,7 @@ Status TargetList::CreateTargetInternal(
   // If the OS or vendor weren't specified, then adopt the module's
   // architecture so that the platform matching can be more
   // accurate.
-  if (!platform_arch.TripleOSWasSpecified() ||
-  !platform_arch.TripleVendorWasSpecified()) {
-prefer_platform_arch = true;
-platform_arch = matching_module_spec.GetArchitecture();
-  }
+  update_platform_arch(matching_module_spec.GetArchitecture());
 } else {
   StreamString platform_arch_strm;
   StreamString module_arch_strm;
@@ -155,16 +160,14 @@ Status TargetList::CreateTargetInternal(
   }
 }
   } else if (arch.IsValid()) {
-// A (valid) architecture was specified.
+// Fat binary. A (valid) architecture was specified.
 module_spec.GetArchitecture() = arch;
 if (module_specs.FindMatchingModuleSpec(module_spec,
-matching_module_spec)) {
-  prefer_platform_arch = true;
-  platform_arch = matching_module_spec.GetArchitecture();
-}
+matching_module_spec))
+update_platform_arch(matching_module_spec.GetArchitecture());
   } else {
-// No architecture specified, check if there is only one platform for
-// all of the architectures.
+// Fat binary. No architecture specified, check if there is
+// only one platform for all of the architectures.
 PlatformSP host_platform_sp = Platform::GetHostPlatform();
 std::vector platforms;
 for (size_t i = 0; i < num_specs; ++i) {
@@ -251,7 +254,7 @@ Status TargetList::CreateTargetInternal(
   // If we have a valid architecture, make sure the current platform is
   // compatible with that architecture.
   if (!prefer_platform_arch && arch.IsValid()) {
-if (!platform_sp->IsCompatibleArchitecture(arch, false, &platform_arch)) {
+if (!platform_sp->IsCompatibleArchitecture(arch, false, nullptr)) {
   platform_sp = Platform::GetPlatformForArchitecture(arch, &platform_arch);
   if (!is_dummy_target && platform_sp)
 debugger.GetPlatformList().SetSelectedPlatform(platform_sp);
@@ -260,8 +263,7 @@ Status TargetList::CreateTargetInternal(
 // If "arch" isn't valid, yet "platform_arch" is, it means we have an
 // executable file with a single architecture which should be used.
 ArchSpec fixed_platform_arch;
-if (!platform_sp->IsCompatibleArchitecture(platform_arch, false,
-   &fixed_platform_arch)) {
+if (!platform_sp->IsCompatibleArchitecture(platform_arch, false, nullptr)) 
{
   platform_sp = Platform::GetPlatformForArchitecture(platform_arch,
  &fixed_platform_arch);
   if (!is_dummy_target && platform_sp)

diff  --git a/lldb/test/API/macosx/universal/Makefile 
b/lldb/test/API/macosx/universal/Makefile
index a6926557015d..8712fde

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

2020-08-06 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:
> aprantl wrote:
> > 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.
> All the same, just in case we need to introduce mac-specific code in the 
> future, it may be more convenient to write this as `#if TARGET_OS_MAC == 1 && 
> TARGET_CPU_ARM == 1` (hope I've spelled that correctly!)
Thanks! In case you didn't already notice, I just wanted to point out that I 
merely moved this code from one file to another in this commit. That said, 
that's not an excuse to not improve it, of course!


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



Comment at: lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h:96
 protected:
+  const char *m_class_name;
+  const char *m_description;

JDevlieghere wrote:
> aprantl wrote:
> > JDevlieghere wrote:
> > > "While you are here" could we make these StringRefs? 
> > I could, but these are used specifically/only for the lldb Plugin API:
> > 
> > `const char *GetDescription() override { return m_description; }`
> > 
> > Do you think it's worth doing regardless?
> > 
> I think it'd be nice, but more something for a separate NFC patch. It's 
> definitely not that important and I'm sure you have better stuff to do :p 
I just tried to do this, which made me realize that a StringRef is objectively 
worse. A StringRef doesn't guarantee a NUL-terminated string, so we'd either 
need to make this a documented requirement (kind of dangerous) or write return 
m_description.str().c_str(), which is also silly.

The right thing to do is to change the Plugin interface itself to use StringRef.


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-06 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 283729.
aprantl added a comment.

Address feedback from @JDevlieghere


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/

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

2020-08-06 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 283730.
aprantl marked 2 inline comments as done.
aprantl added a comment.

clang-format


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_PLATFORMIOSSIMUL

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

2020-08-06 Thread Vedant Kumar via Phabricator via lldb-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Looks good to me.


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-06 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

Ship it


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-06 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG243903f3262d: Factor out common code from the 
iPhone/AppleTV/WatchOS simulator platform… (authored by aprantl).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

[Lldb-commits] [lldb] 243903f - Factor out common code from the iPhone/AppleTV/WatchOS simulator platform plugins. (NFC)

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

Author: Adrian Prantl
Date: 2020-08-06T16:36:58-07:00
New Revision: 243903f3262d0e1727fe7d473da741c4a742a937

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

LOG: Factor out common code from the iPhone/AppleTV/WatchOS simulator platform 
plugins. (NFC)

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

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

Added: 


Modified: 
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/PlatformMacOSX.cpp
lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp

Removed: 
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/PlatformiOSSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h



diff  --git a/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt 
b/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
index 4470797120566..8b5be337f45b7 100644
--- a/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
+++ b/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
@@ -19,9 +19,6 @@ list(APPEND PLUGIN_PLATFORM_MACOSX_SOURCES
 
 list(APPEND PLUGIN_PLATFORM_MACOSX_DARWIN_ONLY_SOURCES
   PlatformAppleSimulator.cpp
-  PlatformiOSSimulator.cpp
-  PlatformAppleTVSimulator.cpp
-  PlatformAppleWatchSimulator.cpp
   )
 
 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
index 0160fb95c58a9..5201e203f77e6 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
@@ -12,16 +12,21 @@
 #include 
 #endif
 
-#include 
-#include 
-#include "lldb/Host/PseudoTerminal.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/PluginManager.h"
 #include "lldb/Host/HostInfo.h"
+#include "lldb/Host/PseudoTerminal.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/StreamString.h"
+
 #include "llvm/Support/Threading.h"
 
+#include 
+#include 
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -29,15 +34,17 @@ using namespace lldb_private;
 #define UNSUPPORTED_ERROR ("Apple simulators aren't supported on this 
platform")
 #endif
 
-// Static Functions
-void PlatformAppleSimulator::Initialize() { PlatformDarwin::Initialize(); }
-
-void PlatformAppleSimulator::Terminate() { PlatformDarwin::Terminate(); }
-
 /// Default Constructor
 PlatformAppleSimulator::PlatformAppleSimulator(
+const char *class_name, const char *description, ConstString plugin_name,
+llvm::Triple::OSType preferred_os,
+llvm::SmallVector supported_triples,
+llvm::StringRef sdk, lldb_private::XcodeSDK::Type sdk_type,
 CoreSimulatorSupport::DeviceType::ProductFamilyID kind)
-: PlatformDarwin(true), m_kind(kind) {}
+: PlatformDarwin(true), m_class_name(class_name),
+  m_description(description), m_plugin_name(plugin_name), m_kind(kind),
+  m_os_type(preferred_os), m_supported_triples(supported_triples),
+  m_sdk(sdk), m_sdk_type(sdk_type) {}
 
 /// Destructor.
 ///
@@ -73,6 +80,12 @@ lldb_private::Status PlatformAppleSimulator::LaunchProcess(
 }
 
 void PlatformAppleSimulator::GetStatus(Stream &strm) {
+  Platform::GetStatus(strm);
+  if (!m_sdk.empty())
+strm << "  SDK Path: \"" << m_sdk << "\"\n";
+  else
+strm << "  SDK Path: error: unable to locate SDK\n";
+
 #if defined(__APPLE__)
   // This will get called by subclasses, so just output status on the current
   // simulator
@@ -87,31 +100,30 @@ void PlatformAppleSimulator::GetStatus(Stream &strm) {
 strm.Printf("Available devices:\n");
 for (size_t i = 0; i < num_devices; ++i) {
   CoreSimulatorSupport::Device device = devices.GetDeviceAtIndex(i);
-  strm.Printf("   %s: %s\n", device.GetUDID().c_str(),
-  device.GetName().c_str());
+  strm << "   " << device.GetUDID() << ": " << device.GetName() << "\n";
 }
 
 if (m_device.hasValue() && m_device->operator bool()) {
-  strm.Printf("Current device: %s: %s", m_device->GetUDID().c_str(),
-  m_device->GetName().c_str());

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

2020-08-06 Thread Jim Ingham via Phabricator via lldb-commits
jingham updated this revision to Diff 283767.
jingham added a comment.

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85265

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

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

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

2020-08-06 Thread Jim Ingham via Phabricator via lldb-commits
jingham updated this revision to Diff 283769.
jingham added a comment.

Remove a file that got inadvertently included from another commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85265

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

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

[Lldb-commits] [lldb] dbf44b8 - [LLDB] Mark test_launch_simple as a no-debug-info test

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

Author: Jonas Devlieghere
Date: 2020-08-06T23:18:37-07:00
New Revision: dbf44b833067cfe59056d07130e7afcb8fc149c7

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

LOG: [LLDB] Mark test_launch_simple as a no-debug-info test

No need to run this test with the multiple variants.

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 68c56ae4096b..b97ae8175c05 100644
--- a/lldb/test/API/python_api/target/TestTargetAPI.py
+++ b/lldb/test/API/python_api/target/TestTargetAPI.py
@@ -155,6 +155,7 @@ def test_read_memory(self):
 @skipIfWindows  # stdio manipulation unsupported on Windows
 @skipIfRemote   # stdio manipulation unsupported on remote iOS 
devices
 @skipIf(oslist=["linux"], archs=["arm", "aarch64"])
+@no_debug_info_test
 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