[Lldb-commits] [PATCH] D122991: [lldb][intelpt] Remove `IntelPTInstruction` and move methods to `DecodedThread`

2022-04-03 Thread Alisamar Husain via Phabricator via lldb-commits
zrthxn created this revision.
zrthxn added a reviewer: wallace.
Herald added a project: All.
zrthxn requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This is to reduce the size of the trace further and has appreciable results.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122991

Files:
  lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
  lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
  lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp

Index: lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
===
--- lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
+++ lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
@@ -78,8 +78,8 @@
   return std::abs(dist);
 }
   };
-  
-	int64_t dist = FindDistanceAndSetPos();
+
+  int64_t dist = FindDistanceAndSetPos();
   m_tsc_range = m_decoded_thread_sp->CalculateTscRange(m_pos);
   return dist;
 }
@@ -93,7 +93,7 @@
 }
 
 lldb::addr_t TraceCursorIntelPT::GetLoadAddress() {
-  return m_decoded_thread_sp->GetInstructions()[m_pos].GetLoadAddress();
+  return m_decoded_thread_sp->GetInstructionLoadAddress(m_pos);
 }
 
 Optional
@@ -111,8 +111,8 @@
 TraceCursorIntelPT::GetInstructionControlFlowType() {
   lldb::addr_t next_load_address =
   m_pos + 1 < GetInternalInstructionSize()
-  ? m_decoded_thread_sp->GetInstructions()[m_pos + 1].GetLoadAddress()
+  ? m_decoded_thread_sp->GetInstructionLoadAddress(m_pos + 1)
   : LLDB_INVALID_ADDRESS;
-  return m_decoded_thread_sp->GetInstructions()[m_pos].GetControlFlowType(
-  next_load_address);
+  return m_decoded_thread_sp->GetInstructionControlFlowType(m_pos,
+next_load_address);
 }
Index: lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
===
--- lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
+++ lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
@@ -51,61 +51,6 @@
   lldb::addr_t m_address;
 };
 
-/// \class IntelPTInstruction
-/// An instruction obtained from decoding a trace. It is either an actual
-/// instruction or an error indicating a gap in the trace.
-///
-/// Gaps in the trace can come in a few flavors:
-///   - tracing gaps (e.g. tracing was paused and then resumed)
-///   - tracing errors (e.g. buffer overflow)
-///   - decoding errors (e.g. some memory region couldn't be decoded)
-/// As mentioned, any gap is represented as an error in this class.
-class IntelPTInstruction {
-public:
-  IntelPTInstruction(const pt_insn &pt_insn)
-  : m_pt_insn(pt_insn), m_is_error(false) {}
-
-  /// Error constructor
-  IntelPTInstruction();
-
-  /// Check if this object represents an error (i.e. a gap).
-  ///
-  /// \return
-  /// Whether this object represents an error.
-  bool IsError() const;
-
-  /// \return
-  /// The instruction pointer address, or \a LLDB_INVALID_ADDRESS if it is
-  /// an error.
-  lldb::addr_t GetLoadAddress() const;
-
-  /// Get the size in bytes of an instance of this class
-  static size_t GetMemoryUsage();
-
-  /// Get the \a lldb::TraceInstructionControlFlowType categories of the
-  /// instruction.
-  ///
-  /// \param[in] next_load_address
-  /// The address of the next instruction in the trace or \b
-  /// LLDB_INVALID_ADDRESS if not available.
-  ///
-  /// \return
-  /// The control flow categories, or \b 0 if the instruction is an error.
-  lldb::TraceInstructionControlFlowType
-  GetControlFlowType(lldb::addr_t next_load_address) const;
-
-  IntelPTInstruction(IntelPTInstruction &&other) = default;
-
-private:
-  IntelPTInstruction(const IntelPTInstruction &other) = delete;
-  const IntelPTInstruction &operator=(const IntelPTInstruction &other) = delete;
-
-  // When adding new members to this class, make sure to update
-  // IntelPTInstruction::GetMemoryUsage() if needed.
-  pt_insn m_pt_insn;
-  bool m_is_error;
-};
-
 /// \class DecodedThread
 /// Class holding the instructions and function call hierarchy obtained from
 /// decoding a trace, as well as a position cursor used when reverse debugging
@@ -178,14 +123,32 @@
   /// Append a decoding error (i.e. an instruction that failed to be decoded).
   void AppendError(llvm::Error &&error);
 
-  /// Get the instructions from the decoded trace. Some of them might indicate
-  /// errors (i.e. gaps) in the trace. For an instruction error, you can access
-  /// its underlying error message with the \a GetErrorByInstructionIndex()
-  /// method.
+  /// Get the instruction pointers from the decoded trace. Some of them might
+  /// indicate errors (i.e. gaps) in the trace. For an instruction error, you
+  /// can access its underlying error message with the \a
+  /// GetErrorByInstructionIndex() method.
   ///
   /// \return
   ///   The instructions of the trace.
-  llvm::ArrayRef GetIns

[Lldb-commits] [PATCH] D122997: do not show the help window on first gui startup

2022-04-03 Thread Luboš Luňák via Phabricator via lldb-commits
llunak created this revision.
llunak added a reviewer: clayborg.
llunak added a project: LLDB.
Herald added a subscriber: JDevlieghere.
Herald added a project: All.
llunak requested review of this revision.
Herald added a subscriber: lldb-commits.

It's rather annoying if it's there after every startup, and that 'Help (F6 
)' at the top should be enough to help people who 
don't know.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122997

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/test/API/commands/gui/basic/TestGuiBasic.py
  lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
  lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
  lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py


Index: lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py
===
--- lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py
+++ lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py
@@ -31,9 +31,8 @@
 right_key = chr(27)+'OC'
 ctrl_l = chr(12)
 
-# Start the GUI and close the welcome window.
+# Start the GUI.
 self.child.sendline("gui")
-self.child.send(escape_key)
 
 # Check the sources window.
 self.child.expect_exact("Sources")
Index: lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
===
--- lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
+++ lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
@@ -29,9 +29,8 @@
 escape_key = chr(27).encode()
 down_key = chr(27)+'OB' # for vt100 terminal (lldbexpect sets 
TERM=vt100)
 
-# Start the GUI and close the welcome window.
+# Start the GUI.
 self.child.sendline("gui")
-self.child.send(escape_key)
 self.child.expect_exact("Sources") # wait for gui
 
 # Go to next line, set a breakpoint.
Index: lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
===
--- lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
+++ lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
@@ -25,10 +25,8 @@
 
 escape_key = chr(27).encode()
 
-# Start the GUI and close the welcome window.
+# Start the GUI.
 self.child.sendline("gui")
-self.child.expect("Welcome to the LLDB curses GUI.")
-self.child.send(escape_key)
 
 # Simulate a simple debugging session.
 self.child.send("s") # step
Index: lldb/test/API/commands/gui/basic/TestGuiBasic.py
===
--- lldb/test/API/commands/gui/basic/TestGuiBasic.py
+++ lldb/test/API/commands/gui/basic/TestGuiBasic.py
@@ -26,18 +26,9 @@
 
 escape_key = chr(27).encode()
 
-# Start the GUI for the first time and check for the welcome window.
+# Start the GUI.
 self.child.sendline("gui")
-self.child.expect_exact("Welcome to the LLDB curses GUI.")
 
-# Press escape to quit the welcome screen
-self.child.send(escape_key)
-# Press escape again to quit the gui
-self.child.send(escape_key)
-self.expect_prompt()
-
-# Start the GUI a second time, this time we should have the normal GUI.
-self.child.sendline("gui")
 # Check for GUI elements in the menu bar.
 self.child.expect_exact("Target")
 self.child.expect_exact("Process")
Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -7665,14 +7665,6 @@
 status_window_sp->SetDelegate(
 WindowDelegateSP(new StatusBarWindowDelegate(m_debugger)));
 
-// Show the main help window once the first time the curses GUI is
-// launched
-static bool g_showed_help = false;
-if (!g_showed_help) {
-  g_showed_help = true;
-  main_window_sp->CreateHelpSubwindow();
-}
-
 // All colors with black background.
 init_pair(1, COLOR_BLACK, COLOR_BLACK);
 init_pair(2, COLOR_RED, COLOR_BLACK);


Index: lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py
===
--- lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py
+++ lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py
@@ -31,9 +31,8 @@
 right_key = chr(27)+'OC'
 ctrl_l = chr(12)
 
-# Start the GUI and close the welcome window.
+# Start the GUI.
 self.child.sendline("gui")
-self.child.send(escape_key)
 
 # Check the sources window.
 self.child.expect_exact("Sources")
Index: lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py

[Lldb-commits] [lldb] 11b6d2f - [lldb][gui] draw highlight for selected line even if empty

2022-04-03 Thread Luboš Luňák via lldb-commits

Author: Luboš Luňák
Date: 2022-04-03T17:52:00+02:00
New Revision: 11b6d2f9cdd5840efddce368d5f9e30f059859eb

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

LOG: [lldb][gui] draw highlight for selected line even if empty

Added: 


Modified: 
lldb/source/Core/IOHandlerCursesGUI.cpp

Removed: 




diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp 
b/lldb/source/Core/IOHandlerCursesGUI.cpp
index 6f416ee8dae77..dbeb5b28e501c 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -7024,8 +7024,8 @@ class SourceFileWindowDelegate : public WindowDelegate {
 line = line.drop_back();
   bool wasWritten = window.OutputColoredStringTruncated(
   1, line, m_first_visible_column, line_is_selected);
-  if (line_is_selected && !wasWritten) {
-// Draw an empty space to show the selected line if empty,
+  if (!wasWritten && (line_is_selected || is_pc_line)) {
+// Draw an empty space to show the selected/PC line if empty,
 // or draw '<' if nothing is visible because of scrolling too much
 // to the right.
 window.PutCStringTruncated(



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


[Lldb-commits] [lldb] 5c540c7 - [lldb][gui] fix background of syntax-highlighted non-selected PC line

2022-04-03 Thread Luboš Luňák via lldb-commits

Author: Luboš Luňák
Date: 2022-04-03T17:52:01+02:00
New Revision: 5c540c751c0210ba7a04f901fbbb6840777c9ef2

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

LOG: [lldb][gui] fix background of syntax-highlighted non-selected PC line

It is the PC line, selected or not, that gets the blue-background
highlight. Without this, a keyword like 'bool' got black background
if the line wasn't selected.
And the blue-background highlight is handled by OutputColoredStringTruncated(),
so no point in setting it explicitly in the calling code.

Added: 


Modified: 
lldb/source/Core/IOHandlerCursesGUI.cpp

Removed: 




diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp 
b/lldb/source/Core/IOHandlerCursesGUI.cpp
index dbeb5b28e501c..a30665c3660aa 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -6977,9 +6977,6 @@ class SourceFileWindowDelegate : public WindowDelegate {
 }
   }
 
-  const attr_t selected_highlight_attr = A_REVERSE;
-  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;
 if (curr_line < num_source_lines) {
@@ -6987,14 +6984,13 @@ class SourceFileWindowDelegate : public WindowDelegate {
   window.MoveCursor(1, line_y);
   const bool is_pc_line = curr_line == m_pc_line;
   const bool line_is_selected = m_selected_line == curr_line;
-  // Highlight the line as the PC line first, then if the selected
-  // line isn't the same as the PC line, highlight it 
diff erently
+  // Highlight the line as the PC line first (done by passing
+  // argument to OutputColoredStringTruncated()), then if the selected
+  // line isn't the same as the PC line, highlight it 
diff erently.
   attr_t highlight_attr = 0;
   attr_t bp_attr = 0;
-  if (is_pc_line)
-highlight_attr = pc_highlight_attr;
-  else if (line_is_selected)
-highlight_attr = selected_highlight_attr;
+  if (line_is_selected && !is_pc_line)
+highlight_attr = A_REVERSE;
 
   if (bp_lines.find(curr_line + 1) != bp_lines.end())
 bp_attr = COLOR_PAIR(BlackOnWhite);
@@ -7023,7 +7019,7 @@ class SourceFileWindowDelegate : public WindowDelegate {
   if (line.endswith("\n"))
 line = line.drop_back();
   bool wasWritten = window.OutputColoredStringTruncated(
-  1, line, m_first_visible_column, line_is_selected);
+  1, line, m_first_visible_column, is_pc_line);
   if (!wasWritten && (line_is_selected || is_pc_line)) {
 // Draw an empty space to show the selected/PC line if empty,
 // or draw '<' if nothing is visible because of scrolling too much



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


[Lldb-commits] [lldb] 5e79a00 - [lldb][gui] use symbolic names rather than hardcoded values

2022-04-03 Thread Luboš Luňák via lldb-commits

Author: Luboš Luňák
Date: 2022-04-03T17:52:01+02:00
New Revision: 5e79a00178c22dc00d2e5cf73b7b639d44e3f73d

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

LOG: [lldb][gui] use symbolic names rather than hardcoded values

Added: 


Modified: 
lldb/source/Core/IOHandlerCursesGUI.cpp

Removed: 




diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp 
b/lldb/source/Core/IOHandlerCursesGUI.cpp
index a30665c3660aa..2240954bc47da 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -28,6 +28,7 @@
 #include "lldb/Core/StreamFile.h"
 #include "lldb/Core/ValueObjectUpdater.h"
 #include "lldb/Host/File.h"
+#include "lldb/Utility/AnsiTerminal.h"
 #include "lldb/Utility/Predicate.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/StreamString.h"
@@ -495,7 +496,7 @@ class Surface {
 if (use_blue_background)
   ::wattron(m_window, COLOR_PAIR(WhiteOnBlue));
 while (!string.empty()) {
-  size_t esc_pos = string.find('\x1b');
+  size_t esc_pos = string.find(ANSI_ESC_START);
   if (esc_pos == StringRef::npos) {
 string = string.substr(skip_first_count);
 if (!string.empty()) {
@@ -517,26 +518,24 @@ class Surface {
   string = string.drop_front(esc_pos);
 }
   }
-  bool consumed = string.consume_front("\x1b");
+  bool consumed = string.consume_front(ANSI_ESC_START);
   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))) {
+  !(value == 0 ||
+(value >= ANSI_FG_COLOR_BLACK && value <= ANSI_FG_COLOR_WHITE))) {
 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";
+  if (!string.consume_front(ANSI_ESC_END)) {
+llvm::errs() << "Missing '" << ANSI_ESC_END
+ << "' in color escape sequence.\n";
 continue;
   }
   if (value == 0) { // Reset.
@@ -545,8 +544,8 @@ class Surface {
   ::wattron(m_window, COLOR_PAIR(WhiteOnBlue));
   } else {
 // Mapped directly to first 16 color pairs (black/blue background).
-::wattron(m_window,
-  COLOR_PAIR(value - 30 + 1 + (use_blue_background ? 8 : 0)));
+::wattron(m_window, COLOR_PAIR(value - ANSI_FG_COLOR_BLACK + 1 +
+   (use_blue_background ? 8 : 0)));
   }
 }
 wattr_set(m_window, saved_attr, saved_pair, nullptr);



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


[Lldb-commits] [lldb] baebf23 - [lldb][gui] underline the current token

2022-04-03 Thread Luboš Luňák via lldb-commits

Author: Luboš Luňák
Date: 2022-04-03T17:52:01+02:00
New Revision: baebf2389657d0abb91861b7d277b7104f928d2b

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

LOG: [lldb][gui] underline the current token

Just like the non-gui listing already does.

Added: 


Modified: 
lldb/source/Core/IOHandlerCursesGUI.cpp

Removed: 




diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp 
b/lldb/source/Core/IOHandlerCursesGUI.cpp
index 2240954bc47da..bb15f4d55936e 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -524,11 +524,11 @@ class Surface {
   // 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.
-  // Only 8 basic foreground colors and reset, our Highlighter doesn't use
-  // anything else.
+  // Only 8 basic foreground colors, underline and reset, our Highlighter
+  // doesn't use anything else.
   int value;
   if (!!string.consumeInteger(10, value) || // Returns false on success.
-  !(value == 0 ||
+  !(value == 0 || value == ANSI_CTRL_UNDERLINE ||
 (value >= ANSI_FG_COLOR_BLACK && value <= ANSI_FG_COLOR_WHITE))) {
 llvm::errs() << "No valid color code in color escape sequence.\n";
 continue;
@@ -542,6 +542,8 @@ class Surface {
 wattr_set(m_window, saved_attr, saved_pair, nullptr);
 if (use_blue_background)
   ::wattron(m_window, COLOR_PAIR(WhiteOnBlue));
+  } else if (value == ANSI_CTRL_UNDERLINE) {
+::wattron(m_window, A_UNDERLINE);
   } else {
 // Mapped directly to first 16 color pairs (black/blue background).
 ::wattron(m_window, COLOR_PAIR(value - ANSI_FG_COLOR_BLACK + 1 +
@@ -7013,7 +7015,12 @@ class SourceFileWindowDelegate : public WindowDelegate {
 window.AttributeOn(highlight_attr);
 
   StreamString lineStream;
-  m_file_sp->DisplaySourceLines(curr_line + 1, {}, 0, 0, &lineStream);
+
+  llvm::Optional column;
+  if (is_pc_line && m_sc.line_entry.IsValid() && 
m_sc.line_entry.column)
+column = m_sc.line_entry.column - 1;
+  m_file_sp->DisplaySourceLines(curr_line + 1, column, 0, 0,
+&lineStream);
   StringRef line = lineStream.GetString();
   if (line.endswith("\n"))
 line = line.drop_back();



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


[Lldb-commits] [PATCH] D122998: use just '#' instead of 'frame #2' in the threads/frame view

2022-04-03 Thread Luboš Luňák via Phabricator via lldb-commits
llunak created this revision.
llunak added a reviewer: clayborg.
llunak added a project: LLDB.
Herald added a subscriber: JDevlieghere.
Herald added a project: All.
llunak requested review of this revision.
Herald added a subscriber: lldb-commits.

Since the threads/frame view is taking only a small part on the right side of 
the screen, only a part of the function name of each frame is visible. It seems 
rather wasteful to spell out 'frame' there when it's obvious that it is a 
frame, it's better to use the space for more of the function name.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122998

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py


Index: 
lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
===
--- lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
+++ lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
@@ -33,7 +33,7 @@
 self.child.expect_exact("Threads")
 
 # The thread running thread_start_routine should be expanded.
-self.child.expect_exact("frame #0: break_here")
+self.child.expect_exact("#0: break_here")
 
 # Exit GUI.
 self.child.send(escape_key)
@@ -47,7 +47,7 @@
 self.child.expect_exact("Threads")
 
 # The main thread should be expanded.
-self.child.expect("frame #\d+: main")
+self.child.expect("#\d+: main")
 
 # Quit the GUI
 self.child.send(escape_key)
Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -5015,8 +5015,7 @@
 public:
   FrameTreeDelegate() : TreeDelegate() {
 FormatEntity::Parse(
-"frame #${frame.index}: {${function.name}${function.pc-offset}}}",
-m_format);
+"#${frame.index}: {${function.name}${function.pc-offset}}}", m_format);
   }
 
   ~FrameTreeDelegate() override = default;


Index: lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
===
--- lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
+++ lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
@@ -33,7 +33,7 @@
 self.child.expect_exact("Threads")
 
 # The thread running thread_start_routine should be expanded.
-self.child.expect_exact("frame #0: break_here")
+self.child.expect_exact("#0: break_here")
 
 # Exit GUI.
 self.child.send(escape_key)
@@ -47,7 +47,7 @@
 self.child.expect_exact("Threads")
 
 # The main thread should be expanded.
-self.child.expect("frame #\d+: main")
+self.child.expect("#\d+: main")
 
 # Quit the GUI
 self.child.send(escape_key)
Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -5015,8 +5015,7 @@
 public:
   FrameTreeDelegate() : TreeDelegate() {
 FormatEntity::Parse(
-"frame #${frame.index}: {${function.name}${function.pc-offset}}}",
-m_format);
+"#${frame.index}: {${function.name}${function.pc-offset}}}", m_format);
   }
 
   ~FrameTreeDelegate() override = default;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D123001: make 'step out' step out of the selected frame

2022-04-03 Thread Luboš Luňák via Phabricator via lldb-commits
llunak created this revision.
llunak added a reviewer: clayborg.
llunak added a project: LLDB.
Herald added a subscriber: JDevlieghere.
Herald added a project: All.
llunak requested review of this revision.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123001

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


Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -1953,7 +1953,7 @@
   return error;
 }
 
-Status Thread::StepOut() {
+Status Thread::StepOut(uint32_t frame_idx) {
   Status error;
   Process *process = GetProcess().get();
   if (StateIsStoppedState(process->GetState(), true)) {
@@ -1963,7 +1963,7 @@
 
 ThreadPlanSP new_plan_sp(QueueThreadPlanForStepOut(
 abort_other_plans, nullptr, first_instruction, stop_other_threads,
-eVoteYes, eVoteNoOpinion, 0, error));
+eVoteYes, eVoteNoOpinion, frame_idx, error));
 
 new_plan_sp->SetIsControllingPlan(true);
 new_plan_sp->SetOkayToDiscard(false);
Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -6402,8 +6402,11 @@
   if (exe_ctx.HasThreadScope()) {
 Process *process = exe_ctx.GetProcessPtr();
 if (process && process->IsAlive() &&
-StateIsStoppedState(process->GetState(), true))
-  exe_ctx.GetThreadRef().StepOut();
+StateIsStoppedState(process->GetState(), true)) {
+  Thread *thread = exe_ctx.GetThreadPtr();
+  uint32_t frame_idx = thread->GetSelectedFrameIndex();
+  exe_ctx.GetThreadRef().StepOut(frame_idx);
+}
   }
 }
   return MenuActionResult::Handled;
@@ -7361,7 +7364,9 @@
 m_debugger.GetCommandInterpreter().GetExecutionContext();
 if (exe_ctx.HasThreadScope() &&
 StateIsStoppedState(exe_ctx.GetProcessRef().GetState(), true)) {
-  exe_ctx.GetThreadRef().StepOut();
+  Thread *thread = exe_ctx.GetThreadPtr();
+  uint32_t frame_idx = thread->GetSelectedFrameIndex();
+  exe_ctx.GetThreadRef().StepOut(frame_idx);
 }
   }
   return eKeyHandled;
Index: lldb/include/lldb/Target/Thread.h
===
--- lldb/include/lldb/Target/Thread.h
+++ lldb/include/lldb/Target/Thread.h
@@ -539,9 +539,12 @@
   /// This function is designed to be used by commands where the
   /// process is publicly stopped.
   ///
+  /// \param[in] frame_idx
+  /// The frame index to step out of.
+  ///
   /// \return
   /// An error that describes anything that went wrong
-  virtual Status StepOut();
+  virtual Status StepOut(uint32_t frame_idx = 0);
 
   /// Retrieves the per-thread data area.
   /// Most OSs maintain a per-thread pointer (e.g. the FS register on
@@ -836,7 +839,7 @@
   ///See standard meanings for the stop & run votes in ThreadPlan.h.
   ///
   /// \param[in] frame_idx
-  /// The fame index.
+  /// The frame index.
   ///
   /// \param[out] status
   /// A status with an error if queuing failed.


Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -1953,7 +1953,7 @@
   return error;
 }
 
-Status Thread::StepOut() {
+Status Thread::StepOut(uint32_t frame_idx) {
   Status error;
   Process *process = GetProcess().get();
   if (StateIsStoppedState(process->GetState(), true)) {
@@ -1963,7 +1963,7 @@
 
 ThreadPlanSP new_plan_sp(QueueThreadPlanForStepOut(
 abort_other_plans, nullptr, first_instruction, stop_other_threads,
-eVoteYes, eVoteNoOpinion, 0, error));
+eVoteYes, eVoteNoOpinion, frame_idx, error));
 
 new_plan_sp->SetIsControllingPlan(true);
 new_plan_sp->SetOkayToDiscard(false);
Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -6402,8 +6402,11 @@
   if (exe_ctx.HasThreadScope()) {
 Process *process = exe_ctx.GetProcessPtr();
 if (process && process->IsAlive() &&
-StateIsStoppedState(process->GetState(), true))
-  exe_ctx.GetThreadRef().StepOut();
+StateIsStoppedState(process->GetState(), true)) {
+  Thread *thread = exe_ctx.GetThreadPtr();
+  uint32_t frame_idx = thread->GetSelectedFrameIndex();
+  exe_ctx.GetThreadRef().StepOut(frame_idx);
+}
   }
 }
   return MenuActionResult::Handled;
@@ -7361,7 +7364,9 @@
 m_debugger.GetCommandInterpreter().GetExecutionContext

[Lldb-commits] [PATCH] D123008: remove the "expand" diamond for variables where expanding fails

2022-04-03 Thread Luboš Luňák via Phabricator via lldb-commits
llunak created this revision.
llunak added a reviewer: clayborg.
llunak added a project: LLDB.
Herald added a subscriber: JDevlieghere.
Herald added a project: All.
llunak requested review of this revision.
Herald added a subscriber: lldb-commits.

If the variables view shows a variable that is a struct that has 
MightHaveChildren(), the expand diamond is shown, but if trying to expand it 
and it's not possible (e.g. incomplete type), remove the expand diamond to 
visualize that it can't be in fact expanded. Otherwise it feels kinda weird 
that a tree item cannot be expanded even though it "should".

I guess the MightHaveChildren() checking means that GetChildren() may be 
expensive, so also do not call it for rows that are not expanded.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123008

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp


Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -4537,7 +4537,8 @@
 if (parent)
   parent->DrawTreeForChild(window, this, 0);
 
-if (might_have_children) {
+if (might_have_children &&
+(!calculated_children || !GetChildren().empty())) {
   // It we can get UTF8 characters to work we should try to use the
   // "symbol" UTF8 string below
   //const char *symbol = "";
@@ -5824,9 +5825,11 @@
 ++m_num_rows;
   }
 
-  auto &children = row.GetChildren();
-  if (row.expanded && !children.empty()) {
-DisplayRows(window, children, options);
+  if (row.expanded) {
+auto &children = row.GetChildren();
+if (!children.empty()) {
+  DisplayRows(window, children, options);
+}
   }
 }
   }
@@ -5847,11 +5850,13 @@
 return &row;
   else {
 --row_index;
-auto &children = row.GetChildren();
-if (row.expanded && !children.empty()) {
-  Row *result = GetRowForRowIndexImpl(children, row_index);
-  if (result)
-return result;
+if (row.expanded) {
+  auto &children = row.GetChildren();
+  if (!children.empty()) {
+Row *result = GetRowForRowIndexImpl(children, row_index);
+if (result)
+  return result;
+  }
 }
   }
 }


Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -4537,7 +4537,8 @@
 if (parent)
   parent->DrawTreeForChild(window, this, 0);
 
-if (might_have_children) {
+if (might_have_children &&
+(!calculated_children || !GetChildren().empty())) {
   // It we can get UTF8 characters to work we should try to use the
   // "symbol" UTF8 string below
   //const char *symbol = "";
@@ -5824,9 +5825,11 @@
 ++m_num_rows;
   }
 
-  auto &children = row.GetChildren();
-  if (row.expanded && !children.empty()) {
-DisplayRows(window, children, options);
+  if (row.expanded) {
+auto &children = row.GetChildren();
+if (!children.empty()) {
+  DisplayRows(window, children, options);
+}
   }
 }
   }
@@ -5847,11 +5850,13 @@
 return &row;
   else {
 --row_index;
-auto &children = row.GetChildren();
-if (row.expanded && !children.empty()) {
-  Row *result = GetRowForRowIndexImpl(children, row_index);
-  if (result)
-return result;
+if (row.expanded) {
+  auto &children = row.GetChildren();
+  if (!children.empty()) {
+Row *result = GetRowForRowIndexImpl(children, row_index);
+if (result)
+  return result;
+  }
 }
   }
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits