[Lldb-commits] [PATCH] D151567: [LLVM][Support] Report EISDIR when opening a directory on AIX

2023-06-28 Thread Hubert Tong via Phabricator via lldb-commits
hubert.reinterpretcast added a comment.

In D151567#4458232 , 
@hubert.reinterpretcast wrote:

> @azhan92, please incorporate a revert of 
> https://reviews.llvm.org/rG64ca650cf9f180cc0b68c0005639028084066e10. Since it 
> is an `XFAIL`. once the problem is fixed, the test will end up being an 
> "unexpected success" unless we remove the `XFAIL`.

@azhan92, I believe that the fix needs to be done at a lower level. Currently, 
we are addressing one case (in `expandResponseFiles`). That does not address 
other cases where the ability to open directories for reading on AIX causes 
unexpected behaviour for LLVM.

We should go deeper to see where the `EISDIR` error originates (likely "below" 
the `expandResponseFile` call) on other platforms.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151567

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


[Lldb-commits] [PATCH] D151567: [LLVM][Support] Report EISDIR when opening a directory on AIX

2023-06-28 Thread Hubert Tong via Phabricator via lldb-commits
hubert.reinterpretcast added a comment.

@azhan92, rG6ace52e5e49cff6664fc301fa4985fc28c88f26f 
 and 
rGc14df228ff3ca73e3c5c00c495216bba56665fd5 
 should 
also be reverted. Same reason: `XFAIL`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151567

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


[Lldb-commits] [PATCH] D151567: [LLVM][Support] Report EISDIR when opening a directory on AIX

2023-06-28 Thread Hubert Tong via Phabricator via lldb-commits
hubert.reinterpretcast added a comment.

@azhan92, please incorporate a revert of 
https://reviews.llvm.org/rG64ca650cf9f180cc0b68c0005639028084066e10. Since it 
is an `XFAIL`. once the problem is fixed, the test will end up being an 
"unexpected success" unless we remove the `XFAIL`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151567

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


[Lldb-commits] [PATCH] D154037: Recognize BSS-only DATA segments as sections that need to be slid/loaded at addresses

2023-06-28 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda created this revision.
jasonmolenda added a reviewer: JDevlieghere.
jasonmolenda added a project: LLDB.
Herald added a project: All.
jasonmolenda requested review of this revision.
Herald added a subscriber: lldb-commits.

ObjectFileMachO::SetLoadAddress() takes a slide or base load address and 
applies the correct address difference to each section in the Target.  It only 
makes these changes to "loadable" sections and one of the heuristics 
incorrectly disqualified a DATA segment that has no on-disk content, e.g. a 
BSS-only DATA segment.  A DATA segment is allowed to have no file size; this is 
a small patch to SectionIsLoadable to recognize that.  And add a quick test 
case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154037

Files:
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/test/API/macosx/bss-only-data-section-sliding/Makefile
  
lldb/test/API/macosx/bss-only-data-section-sliding/TestBSSOnlyDataSectionSliding.py
  lldb/test/API/macosx/bss-only-data-section-sliding/main.c


Index: lldb/test/API/macosx/bss-only-data-section-sliding/main.c
===
--- /dev/null
+++ lldb/test/API/macosx/bss-only-data-section-sliding/main.c
@@ -0,0 +1,2 @@
+int glob = 0;
+int main() { return glob; }
Index: 
lldb/test/API/macosx/bss-only-data-section-sliding/TestBSSOnlyDataSectionSliding.py
===
--- /dev/null
+++ 
lldb/test/API/macosx/bss-only-data-section-sliding/TestBSSOnlyDataSectionSliding.py
@@ -0,0 +1,27 @@
+"""Test that we a BSS-data only DATA segment is slid with other segments."""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestBSSOnlyDataSectionSliding(TestBase):
+@skipUnlessDarwin
+def test_with_python_api(self):
+"""Test that we get thread names when interrupting a process."""
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+target = self.dbg.CreateTarget(exe, "", "", False, lldb.SBError())
+self.assertTrue(target, VALID_TARGET)
+
+module = target.modules[0]
+self.assertTrue(module.IsValid())
+data_sect = module.section["__DATA"]
+self.assertTrue(data_sect.IsValid())
+
+target.SetModuleLoadAddress(module, 0x17000)
+self.assertEqual(
+data_sect.GetFileAddress() + 0x17000, 
data_sect.GetLoadAddress(target)
+)
Index: lldb/test/API/macosx/bss-only-data-section-sliding/Makefile
===
--- /dev/null
+++ lldb/test/API/macosx/bss-only-data-section-sliding/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -6048,7 +6048,8 @@
   if (!section)
 return false;
   const bool is_dsym = (m_header.filetype == MH_DSYM);
-  if (section->GetFileSize() == 0 && !is_dsym)
+  if (section->GetFileSize() == 0 && !is_dsym &&
+  section->GetName() != GetSegmentNameDATA())
 return false;
   if (section->IsThreadSpecific())
 return false;


Index: lldb/test/API/macosx/bss-only-data-section-sliding/main.c
===
--- /dev/null
+++ lldb/test/API/macosx/bss-only-data-section-sliding/main.c
@@ -0,0 +1,2 @@
+int glob = 0;
+int main() { return glob; }
Index: lldb/test/API/macosx/bss-only-data-section-sliding/TestBSSOnlyDataSectionSliding.py
===
--- /dev/null
+++ lldb/test/API/macosx/bss-only-data-section-sliding/TestBSSOnlyDataSectionSliding.py
@@ -0,0 +1,27 @@
+"""Test that we a BSS-data only DATA segment is slid with other segments."""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestBSSOnlyDataSectionSliding(TestBase):
+@skipUnlessDarwin
+def test_with_python_api(self):
+"""Test that we get thread names when interrupting a process."""
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+target = self.dbg.CreateTarget(exe, "", "", False, lldb.SBError())
+self.assertTrue(target, VALID_TARGET)
+
+module = target.modules[0]
+self.assertTrue(module.IsValid())
+data_sect = module.section["__DATA"]
+self.assertTrue(data_sect.IsValid())
+
+target.SetModuleLoadAddress(module, 0x17000)
+self.assertEqual(
+data_sect.GetFileAddress() + 0x17000, data_sect.GetLoadAddress(target)
+)
Index: lldb/test/API/macosx/bss-only-data-section-sliding/Makefile

[Lldb-commits] [PATCH] D154028: [lldb-vscode] Prior to running the launchCommands during a launch request set the launch info so the configured launch information is accessible by the launch commands.

2023-06-28 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

THANKS


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154028

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


[Lldb-commits] [PATCH] D154026: [lldb-vscode] Adjusting CreateSource to detect compiler generated frames.

2023-06-28 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

pretty nice. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154026

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


[Lldb-commits] [PATCH] D154030: [lldb-vscode] Creating a new flag for adjusting the behavior of evaluation repl expressions to allow users to more easily invoke lldb commands.

2023-06-28 Thread John Harrison via Phabricator via lldb-commits
ashgti updated this revision to Diff 535592.
ashgti added a comment.

Formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154030

Files:
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/Options.td
  lldb/tools/lldb-vscode/README.md
  lldb/tools/lldb-vscode/SourceBreakpoint.cpp
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -252,7 +252,7 @@
 }
   }
 
-  // We will have cleared g_vsc.focus_tid if he focus thread doesn't have
+  // We will have cleared g_vsc.focus_tid if the focus thread doesn't have
   // a stop reason, so if it was cleared, or wasn't set, or doesn't exist,
   // then set the focus thread to the first thread with a stop reason.
   if (!focus_thread_exists || g_vsc.focus_tid == LLDB_INVALID_THREAD_ID)
@@ -1065,50 +1065,62 @@
   FillResponse(request, response);
   llvm::json::Object body;
   auto arguments = request.getObject("arguments");
+
+  // If we have a frame, try to set the context for variable completions.
+  lldb::SBFrame frame = g_vsc.GetLLDBFrame(*arguments);
+  if (frame.IsValid()) {
+frame.GetThread().GetProcess().SetSelectedThread(frame.GetThread());
+frame.GetThread().SetSelectedFrame(frame.GetFrameID());
+  }
+
   std::string text = std::string(GetString(arguments, "text"));
   auto original_column = GetSigned(arguments, "column", text.size());
-  auto actual_column = original_column - 1;
+  auto original_line = GetSigned(arguments, "line", 1);
+  auto offset = original_column - 1;
+  if (original_line > 1) {
+llvm::StringRef text_ref{text};
+::llvm::SmallVector<::llvm::StringRef, 2> lines;
+text_ref.split(lines, '\n');
+for (int i = 0; i < original_line - 1; i++) {
+  offset += lines[i].size();
+}
+  }
   llvm::json::Array targets;
-  // NOTE: the 'line' argument is not needed, as multiline expressions
-  // work well already
-  // TODO: support frameID. Currently
-  // g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions
-  // is frame-unaware.
-
-  if (!text.empty() && text[0] == '`') {
-text = text.substr(1);
-actual_column--;
-  } else {
-char command[] = "expression -- ";
+
+  if (g_vsc.DetectExpressionContext(text) == ExpressionContext::Variable) {
+char command[] = "frame variable ";
 text = command + text;
-actual_column += strlen(command);
+offset += strlen(command);
   }
   lldb::SBStringList matches;
   lldb::SBStringList descriptions;
-  g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions(
-  text.c_str(), actual_column, 0, -1, matches, descriptions);
-  size_t count = std::min((uint32_t)100, matches.GetSize());
-  targets.reserve(count);
-  for (size_t i = 0; i < count; i++) {
-std::string match = matches.GetStringAtIndex(i);
-std::string description = descriptions.GetStringAtIndex(i);
-
-llvm::json::Object item;
-
-llvm::StringRef match_ref = match;
-for (llvm::StringRef commit_point : {".", "->"}) {
-  if (match_ref.contains(commit_point)) {
-match_ref = match_ref.rsplit(commit_point).second;
+
+  if (g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions(
+  text.c_str(), offset, 0, 100, matches, descriptions)) {
+// The first element is the common substring after the cursor position for
+// all the matches. The rest of the elements are the matches.
+targets.reserve(matches.GetSize() - 1);
+std::string common_pattern = matches.GetStringAtIndex(0);
+for (size_t i = 1; i < matches.GetSize(); i++) {
+  std::string match = matches.GetStringAtIndex(i);
+  std::string description = descriptions.GetStringAtIndex(i);
+
+  llvm::json::Object item;
+  llvm::StringRef match_ref = match;
+  for (llvm::StringRef commit_point : {".", "->"}) {
+if (match_ref.contains(commit_point)) {
+  match_ref = match_ref.rsplit(commit_point).second;
+}
   }
-}
-EmplaceSafeString(item, "text", match_ref);
+  EmplaceSafeString(item, "text", match_ref);
 
-if (description.empty())
-  EmplaceSafeString(item, "label", match);
-else
-  EmplaceSafeString(item, "label", match + " -- " + description);
+  if (description.empty())
+EmplaceSafeString(item, "label", match);
+  else
+EmplaceSafeString(item, "label", match + " -- " + description);
 
-targets.emplace_back(std::move(item));
+  targets.emplace_back(std::move(item));
+}
   }
 
   body.try_emplace("targets", std::move(targets));
@@ -1223,12 +1235,17 @@
   llvm::json::Object body;
   auto arguments = 

[Lldb-commits] [PATCH] D154030: [lldb-vscode] Creating a new flag for adjusting the behavior of evaluation repl expressions to allow users to more easily invoke lldb commands.

2023-06-28 Thread John Harrison via Phabricator via lldb-commits
ashgti updated this revision to Diff 535591.
ashgti added a comment.

Formatting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154030

Files:
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/Options.td
  lldb/tools/lldb-vscode/README.md
  lldb/tools/lldb-vscode/SourceBreakpoint.cpp
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -252,7 +252,7 @@
 }
   }
 
-  // We will have cleared g_vsc.focus_tid if he focus thread doesn't have
+  // We will have cleared g_vsc.focus_tid if the focus thread doesn't have
   // a stop reason, so if it was cleared, or wasn't set, or doesn't exist,
   // then set the focus thread to the first thread with a stop reason.
   if (!focus_thread_exists || g_vsc.focus_tid == LLDB_INVALID_THREAD_ID)
@@ -1065,50 +1065,62 @@
   FillResponse(request, response);
   llvm::json::Object body;
   auto arguments = request.getObject("arguments");
+
+  // If we have a frame, try to set the context for variable completions.
+  lldb::SBFrame frame = g_vsc.GetLLDBFrame(*arguments);
+  if (frame.IsValid()) {
+frame.GetThread().GetProcess().SetSelectedThread(frame.GetThread());
+frame.GetThread().SetSelectedFrame(frame.GetFrameID());
+  }
+
   std::string text = std::string(GetString(arguments, "text"));
   auto original_column = GetSigned(arguments, "column", text.size());
-  auto actual_column = original_column - 1;
+  auto original_line = GetSigned(arguments, "line", 1);
+  auto offset = original_column - 1;
+  if (original_line > 1) {
+llvm::StringRef text_ref{text};
+::llvm::SmallVector<::llvm::StringRef, 2> lines;
+text_ref.split(lines, '\n');
+for (int i = 0; i < original_line - 1; i++) {
+  offset += lines[i].size();
+}
+  }
   llvm::json::Array targets;
-  // NOTE: the 'line' argument is not needed, as multiline expressions
-  // work well already
-  // TODO: support frameID. Currently
-  // g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions
-  // is frame-unaware.
-
-  if (!text.empty() && text[0] == '`') {
-text = text.substr(1);
-actual_column--;
-  } else {
-char command[] = "expression -- ";
+
+  if (g_vsc.DetectExpressionContext(text) == ExpressionContext::Variable) {
+char command[] = "frame variable ";
 text = command + text;
-actual_column += strlen(command);
+offset += strlen(command);
   }
   lldb::SBStringList matches;
   lldb::SBStringList descriptions;
-  g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions(
-  text.c_str(), actual_column, 0, -1, matches, descriptions);
-  size_t count = std::min((uint32_t)100, matches.GetSize());
-  targets.reserve(count);
-  for (size_t i = 0; i < count; i++) {
-std::string match = matches.GetStringAtIndex(i);
-std::string description = descriptions.GetStringAtIndex(i);
-
-llvm::json::Object item;
-
-llvm::StringRef match_ref = match;
-for (llvm::StringRef commit_point : {".", "->"}) {
-  if (match_ref.contains(commit_point)) {
-match_ref = match_ref.rsplit(commit_point).second;
+
+  if (g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions(
+  text.c_str(), offset, 0, 100, matches, descriptions)) {
+// The first element is the common substring after the cursor position for
+// all the matches. The rest of the elements are the matches.
+targets.reserve(matches.GetSize() - 1);
+std::string common_pattern = matches.GetStringAtIndex(0);
+for (size_t i = 1; i < matches.GetSize(); i++) {
+  std::string match = matches.GetStringAtIndex(i);
+  std::string description = descriptions.GetStringAtIndex(i);
+
+  llvm::json::Object item;
+  llvm::StringRef match_ref = match;
+  for (llvm::StringRef commit_point : {".", "->"}) {
+if (match_ref.contains(commit_point)) {
+  match_ref = match_ref.rsplit(commit_point).second;
+}
   }
-}
-EmplaceSafeString(item, "text", match_ref);
+  EmplaceSafeString(item, "text", match_ref);
 
-if (description.empty())
-  EmplaceSafeString(item, "label", match);
-else
-  EmplaceSafeString(item, "label", match + " -- " + description);
+  if (description.empty())
+EmplaceSafeString(item, "label", match);
+  else
+EmplaceSafeString(item, "label", match + " -- " + description);
 
-targets.emplace_back(std::move(item));
+  targets.emplace_back(std::move(item));
+}
   }
 
   body.try_emplace("targets", std::move(targets));
@@ -1223,12 +1235,17 @@
   llvm::json::Object body;
   auto arguments = 

[Lldb-commits] [PATCH] D154030: [lldb-vscode] Creating a new flag for adjusting the behavior of evaluation repl expressions to allow users to more easily invoke lldb commands.

2023-06-28 Thread John Harrison via Phabricator via lldb-commits
ashgti updated this revision to Diff 535590.
ashgti added a comment.

Another tweak to the auto mode behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154030

Files:
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/Options.td
  lldb/tools/lldb-vscode/README.md
  lldb/tools/lldb-vscode/SourceBreakpoint.cpp
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -252,7 +252,7 @@
 }
   }
 
-  // We will have cleared g_vsc.focus_tid if he focus thread doesn't have
+  // We will have cleared g_vsc.focus_tid if the focus thread doesn't have
   // a stop reason, so if it was cleared, or wasn't set, or doesn't exist,
   // then set the focus thread to the first thread with a stop reason.
   if (!focus_thread_exists || g_vsc.focus_tid == LLDB_INVALID_THREAD_ID)
@@ -1065,50 +1065,62 @@
   FillResponse(request, response);
   llvm::json::Object body;
   auto arguments = request.getObject("arguments");
+
+  // If we have a frame, try to set the context for variable completions.
+  lldb::SBFrame frame = g_vsc.GetLLDBFrame(*arguments);
+  if (frame.IsValid()) {
+frame.GetThread().GetProcess().SetSelectedThread(frame.GetThread());
+frame.GetThread().SetSelectedFrame(frame.GetFrameID());
+  }
+
   std::string text = std::string(GetString(arguments, "text"));
   auto original_column = GetSigned(arguments, "column", text.size());
-  auto actual_column = original_column - 1;
+  auto original_line = GetSigned(arguments, "line", 1);
+  auto offset = original_column - 1;
+  if (original_line > 1) {
+llvm::StringRef text_ref{text};
+::llvm::SmallVector<::llvm::StringRef, 2> lines;
+text_ref.split(lines, '\n');
+for (int i = 0; i < original_line - 1; i++) {
+  offset += lines[i].size();
+}
+  }
   llvm::json::Array targets;
-  // NOTE: the 'line' argument is not needed, as multiline expressions
-  // work well already
-  // TODO: support frameID. Currently
-  // g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions
-  // is frame-unaware.
-
-  if (!text.empty() && text[0] == '`') {
-text = text.substr(1);
-actual_column--;
-  } else {
-char command[] = "expression -- ";
+
+  if (g_vsc.DetectExpressionContext(text) == ExpressionContext::Variable) {
+char command[] = "frame variable ";
 text = command + text;
-actual_column += strlen(command);
+offset += strlen(command);
   }
   lldb::SBStringList matches;
   lldb::SBStringList descriptions;
-  g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions(
-  text.c_str(), actual_column, 0, -1, matches, descriptions);
-  size_t count = std::min((uint32_t)100, matches.GetSize());
-  targets.reserve(count);
-  for (size_t i = 0; i < count; i++) {
-std::string match = matches.GetStringAtIndex(i);
-std::string description = descriptions.GetStringAtIndex(i);
-
-llvm::json::Object item;
-
-llvm::StringRef match_ref = match;
-for (llvm::StringRef commit_point : {".", "->"}) {
-  if (match_ref.contains(commit_point)) {
-match_ref = match_ref.rsplit(commit_point).second;
+
+  if (g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions(
+  text.c_str(), offset, 0, 100, matches, descriptions)) {
+// The first element is the common substring after the cursor position for
+// all the matches. The rest of the elements are the matches.
+targets.reserve(matches.GetSize() - 1);
+std::string common_pattern = matches.GetStringAtIndex(0);
+for (size_t i = 1; i < matches.GetSize(); i++) {
+  std::string match = matches.GetStringAtIndex(i);
+  std::string description = descriptions.GetStringAtIndex(i);
+
+  llvm::json::Object item;
+  llvm::StringRef match_ref = match;
+  for (llvm::StringRef commit_point : {".", "->"}) {
+if (match_ref.contains(commit_point)) {
+  match_ref = match_ref.rsplit(commit_point).second;
+}
   }
-}
-EmplaceSafeString(item, "text", match_ref);
+  EmplaceSafeString(item, "text", match_ref);
 
-if (description.empty())
-  EmplaceSafeString(item, "label", match);
-else
-  EmplaceSafeString(item, "label", match + " -- " + description);
+  if (description.empty())
+EmplaceSafeString(item, "label", match);
+  else
+EmplaceSafeString(item, "label", match + " -- " + description);
 
-targets.emplace_back(std::move(item));
+  targets.emplace_back(std::move(item));
+}
   }
 
   body.try_emplace("targets", std::move(targets));
@@ -1223,12 +1235,17 @@
   llvm::json::Object body;
   auto 

[Lldb-commits] [PATCH] D154030: [lldb-vscode] Creating a new flag for adjusting the behavior of evaluation repl expressions to allow users to more easily invoke lldb commands.

2023-06-28 Thread John Harrison via Phabricator via lldb-commits
ashgti updated this revision to Diff 535580.
ashgti added a comment.

Small tweak to the auto expression mode.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154030

Files:
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/Options.td
  lldb/tools/lldb-vscode/README.md
  lldb/tools/lldb-vscode/SourceBreakpoint.cpp
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -252,7 +252,7 @@
 }
   }
 
-  // We will have cleared g_vsc.focus_tid if he focus thread doesn't have
+  // We will have cleared g_vsc.focus_tid if the focus thread doesn't have
   // a stop reason, so if it was cleared, or wasn't set, or doesn't exist,
   // then set the focus thread to the first thread with a stop reason.
   if (!focus_thread_exists || g_vsc.focus_tid == LLDB_INVALID_THREAD_ID)
@@ -1065,50 +1065,62 @@
   FillResponse(request, response);
   llvm::json::Object body;
   auto arguments = request.getObject("arguments");
+
+  // If we have a frame, try to set the context for variable completions.
+  lldb::SBFrame frame = g_vsc.GetLLDBFrame(*arguments);
+  if (frame.IsValid()) {
+frame.GetThread().GetProcess().SetSelectedThread(frame.GetThread());
+frame.GetThread().SetSelectedFrame(frame.GetFrameID());
+  }
+
   std::string text = std::string(GetString(arguments, "text"));
   auto original_column = GetSigned(arguments, "column", text.size());
-  auto actual_column = original_column - 1;
+  auto original_line = GetSigned(arguments, "line", 1);
+  auto offset = original_column - 1;
+  if (original_line > 1) {
+llvm::StringRef text_ref{text};
+::llvm::SmallVector<::llvm::StringRef, 2> lines;
+text_ref.split(lines, '\n');
+for (int i = 0; i < original_line - 1; i++) {
+  offset += lines[i].size();
+}
+  }
   llvm::json::Array targets;
-  // NOTE: the 'line' argument is not needed, as multiline expressions
-  // work well already
-  // TODO: support frameID. Currently
-  // g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions
-  // is frame-unaware.
-
-  if (!text.empty() && text[0] == '`') {
-text = text.substr(1);
-actual_column--;
-  } else {
-char command[] = "expression -- ";
+
+  if (g_vsc.DetectExpressionContext(text) == ExpressionContext::Variable) {
+char command[] = "frame variable ";
 text = command + text;
-actual_column += strlen(command);
+offset += strlen(command);
   }
   lldb::SBStringList matches;
   lldb::SBStringList descriptions;
-  g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions(
-  text.c_str(), actual_column, 0, -1, matches, descriptions);
-  size_t count = std::min((uint32_t)100, matches.GetSize());
-  targets.reserve(count);
-  for (size_t i = 0; i < count; i++) {
-std::string match = matches.GetStringAtIndex(i);
-std::string description = descriptions.GetStringAtIndex(i);
-
-llvm::json::Object item;
-
-llvm::StringRef match_ref = match;
-for (llvm::StringRef commit_point : {".", "->"}) {
-  if (match_ref.contains(commit_point)) {
-match_ref = match_ref.rsplit(commit_point).second;
+
+  if (g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions(
+  text.c_str(), offset, 0, 100, matches, descriptions)) {
+// The first element is the common substring after the cursor position for
+// all the matches. The rest of the elements are the matches.
+targets.reserve(matches.GetSize() - 1);
+std::string common_pattern = matches.GetStringAtIndex(0);
+for (size_t i = 1; i < matches.GetSize(); i++) {
+  std::string match = matches.GetStringAtIndex(i);
+  std::string description = descriptions.GetStringAtIndex(i);
+
+  llvm::json::Object item;
+  llvm::StringRef match_ref = match;
+  for (llvm::StringRef commit_point : {".", "->"}) {
+if (match_ref.contains(commit_point)) {
+  match_ref = match_ref.rsplit(commit_point).second;
+}
   }
-}
-EmplaceSafeString(item, "text", match_ref);
+  EmplaceSafeString(item, "text", match_ref);
 
-if (description.empty())
-  EmplaceSafeString(item, "label", match);
-else
-  EmplaceSafeString(item, "label", match + " -- " + description);
+  if (description.empty())
+EmplaceSafeString(item, "label", match);
+  else
+EmplaceSafeString(item, "label", match + " -- " + description);
 
-targets.emplace_back(std::move(item));
+  targets.emplace_back(std::move(item));
+}
   }
 
   body.try_emplace("targets", std::move(targets));
@@ -1223,12 +1235,17 @@
   llvm::json::Object body;
   auto 

[Lldb-commits] [PATCH] D154029: [lldb-vscode] Adding support for column break points.

2023-06-28 Thread John Harrison via Phabricator via lldb-commits
ashgti added reviewers: wallace, ivanhernandez13.
ashgti added a comment.

Adding column information to breakpoints, including the ability to set column 
inline breakpoints from VS Code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154029

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


[Lldb-commits] [PATCH] D154028: [lldb-vscode] Prior to running the launchCommands during a launch request set the launch info so the configured launch information is accessible by the launch commands.

2023-06-28 Thread John Harrison via Phabricator via lldb-commits
ashgti added a reviewer: wallace.
ashgti added a comment.

A small improvement to allow launchCommands to access the configured launch 
info.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154028

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


[Lldb-commits] [PATCH] D154026: [lldb-vscode] Adjusting CreateSource to detect compiler generated frames.

2023-06-28 Thread John Harrison via Phabricator via lldb-commits
ashgti added reviewers: ivanhernandez13, wallace.
ashgti added a comment.

A small fix for displaying compiler-generated frames.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154026

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


[Lldb-commits] [PATCH] D154030: [lldb-vscode] Creating a new flag for adjusting the behavior of evaluation repl expressions to allow users to more easily invoke lldb commands.

2023-06-28 Thread John Harrison via Phabricator via lldb-commits
ashgti created this revision.
Herald added a project: All.
ashgti requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This adds a new flag and lldb runtime command to allow users to manage the 
behavior of the lldb-vscode evaluate repl request.

When evaluating a repl context this now has runtime managed flag for control 
how the repl behaviors with the follow values:

- `variable` - the existing behavior, with this mode requests are evaluted in 
the current frame context as variable expressions. To trigger a lldb command 
prefix an expression with ` and it will be evaluted as an lldb command.
- `command` - all expressions are evaluated as lldb commands.
- `auto` - An alternative mode that will attempt to determine if the expression 
is an lldb command or a variable expression. Based off the intepreted results 
the expression will be evaluted either as a command or an expression.

Additionally, I enabled completions and ensured they work with the new repl 
expression behavior to provide auto-completes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154030

Files:
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/Options.td
  lldb/tools/lldb-vscode/README.md
  lldb/tools/lldb-vscode/SourceBreakpoint.cpp
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -252,7 +252,7 @@
 }
   }
 
-  // We will have cleared g_vsc.focus_tid if he focus thread doesn't have
+  // We will have cleared g_vsc.focus_tid if the focus thread doesn't have
   // a stop reason, so if it was cleared, or wasn't set, or doesn't exist,
   // then set the focus thread to the first thread with a stop reason.
   if (!focus_thread_exists || g_vsc.focus_tid == LLDB_INVALID_THREAD_ID)
@@ -1065,50 +1065,62 @@
   FillResponse(request, response);
   llvm::json::Object body;
   auto arguments = request.getObject("arguments");
+
+  // If we have a frame, try to set the context for variable completions.
+  lldb::SBFrame frame = g_vsc.GetLLDBFrame(*arguments);
+  if (frame.IsValid()) {
+frame.GetThread().GetProcess().SetSelectedThread(frame.GetThread());
+frame.GetThread().SetSelectedFrame(frame.GetFrameID());
+  }
+
   std::string text = std::string(GetString(arguments, "text"));
   auto original_column = GetSigned(arguments, "column", text.size());
-  auto actual_column = original_column - 1;
+  auto original_line = GetSigned(arguments, "line", 1);
+  auto offset = original_column - 1;
+  if (original_line > 1) {
+llvm::StringRef text_ref{text};
+::llvm::SmallVector<::llvm::StringRef, 2> lines;
+text_ref.split(lines, '\n');
+for (int i = 0; i < original_line - 1; i++) {
+  offset += lines[i].size();
+}
+  }
   llvm::json::Array targets;
-  // NOTE: the 'line' argument is not needed, as multiline expressions
-  // work well already
-  // TODO: support frameID. Currently
-  // g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions
-  // is frame-unaware.
-
-  if (!text.empty() && text[0] == '`') {
-text = text.substr(1);
-actual_column--;
-  } else {
-char command[] = "expression -- ";
+
+  if (g_vsc.DetectExpressionContext(text) == ExpressionContext::Variable) {
+char command[] = "frame variable ";
 text = command + text;
-actual_column += strlen(command);
+offset += strlen(command);
   }
   lldb::SBStringList matches;
   lldb::SBStringList descriptions;
-  g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions(
-  text.c_str(), actual_column, 0, -1, matches, descriptions);
-  size_t count = std::min((uint32_t)100, matches.GetSize());
-  targets.reserve(count);
-  for (size_t i = 0; i < count; i++) {
-std::string match = matches.GetStringAtIndex(i);
-std::string description = descriptions.GetStringAtIndex(i);
-
-llvm::json::Object item;
-
-llvm::StringRef match_ref = match;
-for (llvm::StringRef commit_point : {".", "->"}) {
-  if (match_ref.contains(commit_point)) {
-match_ref = match_ref.rsplit(commit_point).second;
+
+  if (g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions(
+  text.c_str(), offset, 0, 100, matches, descriptions)) {
+// The first element is the common substring after the cursor position for
+// all the matches. The rest of the elements are the matches.
+targets.reserve(matches.GetSize() - 1);
+std::string common_pattern = matches.GetStringAtIndex(0);
+for (size_t i = 1; i < matches.GetSize(); i++) {
+  std::string match = matches.GetStringAtIndex(i);
+  std::string description = descriptions.GetStringAtIndex(i);
+
+  

[Lldb-commits] [PATCH] D154029: [lldb-vscode] Adding support for column break points.

2023-06-28 Thread John Harrison via Phabricator via lldb-commits
ashgti created this revision.
Herald added a project: All.
ashgti requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154029

Files:
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/SourceBreakpoint.cpp


Index: lldb/tools/lldb-vscode/SourceBreakpoint.cpp
===
--- lldb/tools/lldb-vscode/SourceBreakpoint.cpp
+++ lldb/tools/lldb-vscode/SourceBreakpoint.cpp
@@ -16,7 +16,9 @@
   column(GetUnsigned(obj, "column", 0)) {}
 
 void SourceBreakpoint::SetBreakpoint(const llvm::StringRef source_path) {
-  bp = g_vsc.target.BreakpointCreateByLocation(source_path.str().c_str(), 
line);
+  lldb::SBFileSpecList module_list;
+  bp = g_vsc.target.BreakpointCreateByLocation(source_path.str().c_str(), line,
+   column, 0, module_list);
   // See comments in BreakpointBase::GetBreakpointLabel() for details of why
   // we add a label to our breakpoints.
   bp.AddName(GetBreakpointLabel());
Index: lldb/tools/lldb-vscode/JSONUtils.h
===
--- lldb/tools/lldb-vscode/JSONUtils.h
+++ lldb/tools/lldb-vscode/JSONUtils.h
@@ -232,13 +232,21 @@
 /// provided by the setBreakpoints request are returned to the IDE as a
 /// fallback.
 ///
+/// \param[in] request_column
+/// An optional column to use when creating the resulting "Breakpoint" 
object.
+/// It is used if the breakpoint has no valid locations.
+/// It is useful to ensure the same column
+/// provided by the setBreakpoints request are returned to the IDE as a
+/// fallback.
+///
 /// \return
 /// A "Breakpoint" JSON object with that follows the formal JSON
 /// definition outlined by Microsoft.
 llvm::json::Value
 CreateBreakpoint(lldb::SBBreakpoint ,
  std::optional request_path = std::nullopt,
- std::optional request_line = std::nullopt);
+ std::optional request_line = std::nullopt,
+ std::optional request_column = std::nullopt);
 
 /// Converts a LLDB module to a VS Code DAP module for use in "modules" events.
 ///
Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -308,7 +308,8 @@
 // }
 llvm::json::Value CreateBreakpoint(lldb::SBBreakpoint ,
std::optional request_path,
-   std::optional request_line) {
+   std::optional request_line,
+   std::optional request_column) {
   // Each breakpoint location is treated as a separate breakpoint for VS code.
   // They don't have the notion of a single breakpoint with multiple locations.
   llvm::json::Object object;
@@ -345,11 +346,16 @@
 const auto line = line_entry.GetLine();
 if (line != UINT32_MAX)
   object.try_emplace("line", line);
+const auto column = line_entry.GetColumn();
+if (column != 0)
+  object.try_emplace("column", column);
 object.try_emplace("source", CreateSource(line_entry));
   }
   // We try to add request_line as a fallback
   if (request_line)
 object.try_emplace("line", *request_line);
+  if (request_column)
+object.try_emplace("column", *request_column);
   return llvm::json::Value(std::move(object));
 }
 


Index: lldb/tools/lldb-vscode/SourceBreakpoint.cpp
===
--- lldb/tools/lldb-vscode/SourceBreakpoint.cpp
+++ lldb/tools/lldb-vscode/SourceBreakpoint.cpp
@@ -16,7 +16,9 @@
   column(GetUnsigned(obj, "column", 0)) {}
 
 void SourceBreakpoint::SetBreakpoint(const llvm::StringRef source_path) {
-  bp = g_vsc.target.BreakpointCreateByLocation(source_path.str().c_str(), line);
+  lldb::SBFileSpecList module_list;
+  bp = g_vsc.target.BreakpointCreateByLocation(source_path.str().c_str(), line,
+   column, 0, module_list);
   // See comments in BreakpointBase::GetBreakpointLabel() for details of why
   // we add a label to our breakpoints.
   bp.AddName(GetBreakpointLabel());
Index: lldb/tools/lldb-vscode/JSONUtils.h
===
--- lldb/tools/lldb-vscode/JSONUtils.h
+++ lldb/tools/lldb-vscode/JSONUtils.h
@@ -232,13 +232,21 @@
 /// provided by the setBreakpoints request are returned to the IDE as a
 /// fallback.
 ///
+/// \param[in] request_column
+/// An optional column to use when creating the resulting "Breakpoint" object.
+/// It is used if the breakpoint has no valid locations.
+/// It is useful to ensure the same column
+/// provided by the setBreakpoints request are 

[Lldb-commits] [PATCH] D154028: [lldb-vscode] Prior to running the launchCommands during a launch request set the launch info so the configured launch information is accessible by the launch commands.

2023-06-28 Thread John Harrison via Phabricator via lldb-commits
ashgti created this revision.
Herald added a project: All.
ashgti requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154028

Files:
  lldb/tools/lldb-vscode/README.md
  lldb/tools/lldb-vscode/lldb-vscode.cpp


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1695,6 +1695,9 @@
 g_vsc.target.Launch(launch_info, error);
 g_vsc.debugger.SetAsync(true);
   } else {
+// Set the launch info so that run commands can access the configured 
+// launch details.
+g_vsc.target.SetLaunchInfo(launch_info);
 g_vsc.RunLLDBCommands("Running launchCommands:", launchCommands);
 // The custom commands might have created a new target so we should use the
 // selected target after these commands are run.
Index: lldb/tools/lldb-vscode/README.md
===
--- lldb/tools/lldb-vscode/README.md
+++ lldb/tools/lldb-vscode/README.md
@@ -95,6 +95,7 @@
 |**initCommands**   |[string]| | LLDB commands executed upon debugger startup 
prior to creating the LLDB target. Commands and command output will be sent to 
the debugger console when they are executed.
 |**preRunCommands** |[string]| | LLDB commands executed just before launching 
after the LLDB target has been created. Commands and command output will be 
sent to the debugger console when they are executed.
 |**stopCommands**   |[string]| | LLDB commands executed just after each stop. 
Commands and command output will be sent to the debugger console when they are 
executed.
+|**launchCommands** |[string]| | LLDB commands executed to launch the program. 
Commands and command output will be sent to the debugger console when they are 
executed.
 |**exitCommands**   |[string]| | LLDB commands executed when the program 
exits. Commands and command output will be sent to the debugger console when 
they are executed.
 |**terminateCommands** |[string]| | LLDB commands executed when the debugging 
session ends. Commands and command output will be sent to the debugger console 
when they are executed.
 |**sourceMap**  |[string[2]]| | Specify an array of path re-mappings. Each 
element in the array must be a two element array containing a source and 
destination pathname.


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1695,6 +1695,9 @@
 g_vsc.target.Launch(launch_info, error);
 g_vsc.debugger.SetAsync(true);
   } else {
+// Set the launch info so that run commands can access the configured 
+// launch details.
+g_vsc.target.SetLaunchInfo(launch_info);
 g_vsc.RunLLDBCommands("Running launchCommands:", launchCommands);
 // The custom commands might have created a new target so we should use the
 // selected target after these commands are run.
Index: lldb/tools/lldb-vscode/README.md
===
--- lldb/tools/lldb-vscode/README.md
+++ lldb/tools/lldb-vscode/README.md
@@ -95,6 +95,7 @@
 |**initCommands**   |[string]| | LLDB commands executed upon debugger startup prior to creating the LLDB target. Commands and command output will be sent to the debugger console when they are executed.
 |**preRunCommands** |[string]| | LLDB commands executed just before launching after the LLDB target has been created. Commands and command output will be sent to the debugger console when they are executed.
 |**stopCommands**   |[string]| | LLDB commands executed just after each stop. Commands and command output will be sent to the debugger console when they are executed.
+|**launchCommands** |[string]| | LLDB commands executed to launch the program. Commands and command output will be sent to the debugger console when they are executed.
 |**exitCommands**   |[string]| | LLDB commands executed when the program exits. Commands and command output will be sent to the debugger console when they are executed.
 |**terminateCommands** |[string]| | LLDB commands executed when the debugging session ends. Commands and command output will be sent to the debugger console when they are executed.
 |**sourceMap**  |[string[2]]| | Specify an array of path re-mappings. Each element in the array must be a two element array containing a source and destination pathname.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D154026: [lldb-vscode] Adjusting CreateSource to detect compiler generated frames.

2023-06-28 Thread John Harrison via Phabricator via lldb-commits
ashgti created this revision.
Herald added a project: All.
ashgti requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154026

Files:
  lldb/tools/lldb-vscode/JSONUtils.cpp


Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -613,7 +613,9 @@
 llvm::json::Value CreateSource(lldb::SBFrame , int64_t _line) {
   disasm_line = 0;
   auto line_entry = frame.GetLineEntry();
-  if (line_entry.GetFileSpec().IsValid())
+  // A line entry of 0 indicates the line is compiler generated i.e. no source
+  // file so don't return early with the line entry.
+  if (line_entry.GetFileSpec().IsValid() && line_entry.GetLine() != 0)
 return CreateSource(line_entry);
 
   llvm::json::Object object;
@@ -650,7 +652,11 @@
   }
   const auto num_insts = insts.GetSize();
   if (low_pc != LLDB_INVALID_ADDRESS && num_insts > 0) {
-EmplaceSafeString(object, "name", frame.GetFunctionName());
+if (line_entry.GetLine() == 0) {
+  EmplaceSafeString(object, "name", "");
+} else {
+  EmplaceSafeString(object, "name", frame.GetDisplayFunctionName());
+}
 SourceReference source;
 llvm::raw_string_ostream src_strm(source.content);
 std::string line;


Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -613,7 +613,9 @@
 llvm::json::Value CreateSource(lldb::SBFrame , int64_t _line) {
   disasm_line = 0;
   auto line_entry = frame.GetLineEntry();
-  if (line_entry.GetFileSpec().IsValid())
+  // A line entry of 0 indicates the line is compiler generated i.e. no source
+  // file so don't return early with the line entry.
+  if (line_entry.GetFileSpec().IsValid() && line_entry.GetLine() != 0)
 return CreateSource(line_entry);
 
   llvm::json::Object object;
@@ -650,7 +652,11 @@
   }
   const auto num_insts = insts.GetSize();
   if (low_pc != LLDB_INVALID_ADDRESS && num_insts > 0) {
-EmplaceSafeString(object, "name", frame.GetFunctionName());
+if (line_entry.GetLine() == 0) {
+  EmplaceSafeString(object, "name", "");
+} else {
+  EmplaceSafeString(object, "name", frame.GetDisplayFunctionName());
+}
 SourceReference source;
 llvm::raw_string_ostream src_strm(source.content);
 std::string line;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D154025: [lldb-vscode] Prior to running the launchCommands during a launch request set the launch info so the configured launch information is accessible by the launch commands.

2023-06-28 Thread John Harrison via Phabricator via lldb-commits
ashgti created this revision.
Herald added a project: All.
ashgti requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

[lldb-vscode] Adding support for column break points.

[lldb-vscode] Creating a new flag for adjusting the behavior of evaluation repl 
expressions to allow users to more easily invoke lldb commands.

This adds a new flag and lldb runtime command to allow users to manage the 
behavior of the lldb-vscode evaluate repl request.

When evaluating a repl context this now has runtime managed flag for control 
how the repl behaviors with the follow values:

- `variable` - the existing behavior, with this mode requests are evaluted in 
the current frame context as variable expressions. To trigger a lldb command 
prefix an expression with ` and it will be evaluted as an lldb command.
- `command` - all expressions are evaluated as lldb commands.
- `auto` - An alternative mode that will attempt to determine if the expression 
is an lldb command or a variable expression. Based off the intepreted results 
the expression will be evaluted either as a command or an expression.

Additionally, I enabled completions and ensured they work with the new repl 
expression behavior to provide auto-completes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154025

Files:
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/Options.td
  lldb/tools/lldb-vscode/README.md
  lldb/tools/lldb-vscode/SourceBreakpoint.cpp
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -252,7 +252,7 @@
 }
   }
 
-  // We will have cleared g_vsc.focus_tid if he focus thread doesn't have
+  // We will have cleared g_vsc.focus_tid if the focus thread doesn't have
   // a stop reason, so if it was cleared, or wasn't set, or doesn't exist,
   // then set the focus thread to the first thread with a stop reason.
   if (!focus_thread_exists || g_vsc.focus_tid == LLDB_INVALID_THREAD_ID)
@@ -1065,50 +1065,62 @@
   FillResponse(request, response);
   llvm::json::Object body;
   auto arguments = request.getObject("arguments");
+  
+  // If we have a frame, try to set the context for variable completions.
+  lldb::SBFrame frame = g_vsc.GetLLDBFrame(*arguments);
+  if (frame.IsValid()) {
+frame.GetThread().GetProcess().SetSelectedThread(frame.GetThread());
+frame.GetThread().SetSelectedFrame(frame.GetFrameID());
+  }
+  
   std::string text = std::string(GetString(arguments, "text"));
   auto original_column = GetSigned(arguments, "column", text.size());
-  auto actual_column = original_column - 1;
+  auto original_line = GetSigned(arguments, "line", 1);
+  auto offset = original_column - 1;
+  if (original_line > 1) {
+llvm::StringRef text_ref{text};
+::llvm::SmallVector<::llvm::StringRef, 2> lines;
+text_ref.split(lines, '\n');
+for (int i = 0; i < original_line - 1; i++) {
+  offset += lines[i].size();
+}
+  }
   llvm::json::Array targets;
-  // NOTE: the 'line' argument is not needed, as multiline expressions
-  // work well already
-  // TODO: support frameID. Currently
-  // g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions
-  // is frame-unaware.
-
-  if (!text.empty() && text[0] == '`') {
-text = text.substr(1);
-actual_column--;
-  } else {
-char command[] = "expression -- ";
+
+  if (g_vsc.DetectExpressionContext(text) == ExpressionContext::Variable) {
+char command[] = "frame variable ";
 text = command + text;
-actual_column += strlen(command);
+offset += strlen(command);
   }
   lldb::SBStringList matches;
   lldb::SBStringList descriptions;
-  g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions(
-  text.c_str(), actual_column, 0, -1, matches, descriptions);
-  size_t count = std::min((uint32_t)100, matches.GetSize());
-  targets.reserve(count);
-  for (size_t i = 0; i < count; i++) {
-std::string match = matches.GetStringAtIndex(i);
-std::string description = descriptions.GetStringAtIndex(i);
-
-llvm::json::Object item;
-
-llvm::StringRef match_ref = match;
-for (llvm::StringRef commit_point : {".", "->"}) {
-  if (match_ref.contains(commit_point)) {
-match_ref = match_ref.rsplit(commit_point).second;
+
+  if (g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions(
+  text.c_str(), offset, 0, 100, matches, descriptions)) {
+// The first element is the common substring after the cursor position for all
+// the matches. The rest of the elements are the matches.
+targets.reserve(matches.GetSize() - 1);
+std::string common_pattern = 

[Lldb-commits] [PATCH] D153489: [lldb] Print hint if object description is requested but not implemented

2023-06-28 Thread Augusto Noronha via Phabricator via lldb-commits
augusto2112 updated this revision to Diff 535561.
augusto2112 marked 5 inline comments as done.
augusto2112 added a comment.

Addressed comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153489

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Commands/CommandObjectDWIMPrint.cpp
  lldb/source/Core/CoreProperties.td
  lldb/source/Core/Debugger.cpp
  lldb/test/API/lang/objc/objc-po-hint/Makefile
  lldb/test/API/lang/objc/objc-po-hint/TestObjcPoHint.py
  lldb/test/API/lang/objc/objc-po-hint/main.m

Index: lldb/test/API/lang/objc/objc-po-hint/main.m
===
--- /dev/null
+++ lldb/test/API/lang/objc/objc-po-hint/main.m
@@ -0,0 +1,22 @@
+#import 
+
+@interface Foo : NSObject {}
+
+-(id) init;
+
+@end
+
+@implementation Foo
+
+-(id) init
+{
+return self = [super init];
+}
+@end
+
+int main()
+{
+Foo *foo = [Foo new];
+NSLog(@"a"); // Set breakpoint here.
+return 0;
+}
Index: lldb/test/API/lang/objc/objc-po-hint/TestObjcPoHint.py
===
--- /dev/null
+++ lldb/test/API/lang/objc/objc-po-hint/TestObjcPoHint.py
@@ -0,0 +1,49 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestObjcPoHint(TestBase):
+def test_show_po_hint(self):
+### Test that the po hint is shown once with the DWIM print command
+self.build()
+_, _, _, _ = lldbutil.run_to_source_breakpoint(
+self, "Set breakpoint here", lldb.SBFileSpec("main.m")
+)
+# Make sure the hint is printed the first time
+self.expect(
+"dwim-print -O -- foo",
+substrs=[
+"note: object description requested, but type doesn't implement "
+'a custom object description. Consider using "p" instead of "po"',
+"(
+  idx, g_debugger_properties[idx].default_uint_value != 0);
+}
+
 bool Debugger::GetUseSourceCache() const {
   const uint32_t idx = ePropertyUseSourceCache;
   return GetPropertyAtIndexAs(
Index: lldb/source/Core/CoreProperties.td
===
--- lldb/source/Core/CoreProperties.td
+++ lldb/source/Core/CoreProperties.td
@@ -195,6 +195,10 @@
 Global,
 DefaultStringValue<"${ansi.normal}">,
 Desc<"When displaying suggestion in a color-enabled terminal, use the ANSI terminal code specified in this format immediately after the suggestion.">;
+  def ShowDontUsePoHint: Property<"show-dont-use-po-hint", "Boolean">,
+Global,
+DefaultTrue,
+Desc<"If true, and object description was requested for a type that does not implement it, LLDB will print a hint telling the user to consider using p instead.">;
   def DWIMPrintVerbosity: Property<"dwim-print-verbosity", "Enum">,
 Global,
 DefaultEnumValue<"eDWIMPrintVerbosityNone">,
Index: lldb/source/Commands/CommandObjectDWIMPrint.cpp
===
--- lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -25,6 +25,8 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/FormatVariadic.h"
 
+#include 
+
 using namespace llvm;
 using namespace lldb;
 using namespace lldb_private;
@@ -95,8 +97,46 @@
   m_expr_options.m_verbosity, m_format_options.GetFormat());
   dump_options.SetHideRootName(suppress_result);
 
+  bool is_po = m_varobj_options.use_objc;
+
   StackFrame *frame = m_exe_ctx.GetFramePtr();
 
+  // Either Swift was explicitly specified, or the frame is Swift.
+  lldb::LanguageType language = m_expr_options.language;
+  if (language == lldb::eLanguageTypeUnknown && frame)
+language = frame->GuessLanguage();
+
+  // Add a hint if object description was requested, but no description
+  // function was implemented.
+  auto maybe_add_hint = [&](llvm::StringRef output) {
+// Identify the default output of object description for Swift and
+// Objective-C
+// ". The regex is:
+// - Start with "<".
+// - Followed by 1 or more non-whitespace characters.
+// - Followed by ": 0x".
+// - Followed by 5 or more hex digits.
+// - Followed by ">".
+// - End with zero or more whitespace characters.
+const std::regex swift_class_regex("^<\\S+: 0x[[:xdigit:]]{5,}>\\s*$");
+
+if (GetDebugger().GetShowDontUsePoHint() && target_ptr &&
+(language == lldb::eLanguageTypeSwift ||
+ language == lldb::eLanguageTypeObjC) &&
+std::regex_match(output.data(), swift_class_regex)) {
+
+  static llvm::SmallPtrSet targets_warned;
+  if (targets_warned.contains(target_ptr))
+return;
+
+  result.GetOutputStream()
+  << "note: object description requested, but type doesn't 

[Lldb-commits] [PATCH] D153922: [lldb] Duplicate Target::Launch resuming logic into CommandObjectPlatformProcessLaunch

2023-06-28 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added inline comments.



Comment at: lldb/source/Commands/CommandObjectPlatform.cpp:1232
+
+assert(launch_info.GetHijackListener());
+

DavidSpickett wrote:
> DavidSpickett wrote:
> > This assert fails on Linux. Is it necessary or should I look into why it's 
> > null here on Linux?
> > 
> > WaitForProcessToStop on down either checks that the pointer is non null 
> > before use, or substitutes in another (presumably non-null) hijacker.
> To clarify, fails while running the tests in https://reviews.llvm.org/D153636.
I included it to follow (copy) `Target::Launch`. I don't know for fact that 
it's needed, so +1 to removing the assert if needed for Linux.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153922

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


[Lldb-commits] [PATCH] D153840: [LLDB] Fix buffer overflow problem in DWARFExpression::Evaluate.

2023-06-28 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a comment.

I'm not sure if this is the right fix - these reads are for implementing 
DW_OP_deref_size, by the looks of it - so I think it does make sense that the 
size read is not the size of the address, but the size specified in the 
DW_OP_deref_size. There is a requirement that DW_OP_deref_size's size may not 
be larger than the system address - so maybe the input that hit this is 
incorrect, and lldb should've failed earlier (validating the size retrieved at 
line 1082 is within the bounds)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153840

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


[Lldb-commits] [PATCH] D153840: [LLDB] Fix buffer overflow problem in DWARFExpression::Evaluate.

2023-06-28 Thread Caroline Tice via Phabricator via lldb-commits
cmtice added a comment.
Herald added subscribers: Michael137, JDevlieghere.

I updated the version that I committed to use 'sizeof' as recommended.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153840

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


[Lldb-commits] [PATCH] D153840: [LLDB] Fix buffer overflow problem in DWARFExpression::Evaluate.

2023-06-28 Thread Caroline Tice via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGee476996bec7: [LLDB] Fix buffer overflow problem in 
DWARFExpression::Evaluate. (authored by cmtice).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D153840?vs=534856=535482#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153840

Files:
  lldb/source/Expression/DWARFExpression.cpp


Index: lldb/source/Expression/DWARFExpression.cpp
===
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -1138,15 +1138,16 @@
 
 if (load_addr == LLDB_INVALID_ADDRESS && so_addr.IsSectionOffset()) {
   uint8_t addr_bytes[8];
+  size_t buf_size = sizeof(addr_bytes);
   Status error;
 
   if (target &&
-  target->ReadMemory(so_addr, _bytes, size, error,
- /*force_live_memory=*/false) == size) {
+  target->ReadMemory(so_addr, _bytes, buf_size, error,
+ /*force_live_memory=*/false) == buf_size) {
 ObjectFile *objfile = module_sp->GetObjectFile();
 
 stack.back().GetScalar() = DerefSizeExtractDataHelper(
-addr_bytes, size, objfile->GetByteOrder(), size);
+addr_bytes, size, objfile->GetByteOrder(), buf_size);
 stack.back().ClearContext();
 break;
   } else {
@@ -1170,13 +1171,13 @@
 lldb::addr_t pointer_addr =
 stack.back().GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
 uint8_t addr_bytes[sizeof(lldb::addr_t)];
+size_t buf_size = sizeof(addr_bytes);
 Status error;
-if (process->ReadMemory(pointer_addr, _bytes, size, error) ==
-size) {
-
+if (process->ReadMemory(pointer_addr, _bytes, buf_size, error)
+== buf_size) {
   stack.back().GetScalar() =
   DerefSizeExtractDataHelper(addr_bytes, sizeof(addr_bytes),
- process->GetByteOrder(), size);
+ process->GetByteOrder(), 
buf_size);
   stack.back().ClearContext();
 } else {
   if (error_ptr)


Index: lldb/source/Expression/DWARFExpression.cpp
===
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -1138,15 +1138,16 @@
 
 if (load_addr == LLDB_INVALID_ADDRESS && so_addr.IsSectionOffset()) {
   uint8_t addr_bytes[8];
+  size_t buf_size = sizeof(addr_bytes);
   Status error;
 
   if (target &&
-  target->ReadMemory(so_addr, _bytes, size, error,
- /*force_live_memory=*/false) == size) {
+  target->ReadMemory(so_addr, _bytes, buf_size, error,
+ /*force_live_memory=*/false) == buf_size) {
 ObjectFile *objfile = module_sp->GetObjectFile();
 
 stack.back().GetScalar() = DerefSizeExtractDataHelper(
-addr_bytes, size, objfile->GetByteOrder(), size);
+addr_bytes, size, objfile->GetByteOrder(), buf_size);
 stack.back().ClearContext();
 break;
   } else {
@@ -1170,13 +1171,13 @@
 lldb::addr_t pointer_addr =
 stack.back().GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
 uint8_t addr_bytes[sizeof(lldb::addr_t)];
+size_t buf_size = sizeof(addr_bytes);
 Status error;
-if (process->ReadMemory(pointer_addr, _bytes, size, error) ==
-size) {
-
+if (process->ReadMemory(pointer_addr, _bytes, buf_size, error)
+== buf_size) {
   stack.back().GetScalar() =
   DerefSizeExtractDataHelper(addr_bytes, sizeof(addr_bytes),
- process->GetByteOrder(), size);
+ process->GetByteOrder(), buf_size);
   stack.back().ClearContext();
 } else {
   if (error_ptr)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] ee47699 - [LLDB] Fix buffer overflow problem in DWARFExpression::Evaluate.

2023-06-28 Thread Caroline Tice via lldb-commits

Author: Caroline Tice
Date: 2023-06-28T11:46:55-07:00
New Revision: ee476996bec7f170928505a4c5b7715183cfbada

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

LOG: [LLDB] Fix buffer overflow problem in DWARFExpression::Evaluate.

In two calls to ReadMemory in DWARFExpression.cpp, the buffer size
passed to ReadMemory is not actually the size of the buffer (I suspect
a copy/paste error where the variable name was not properly
updated). This caused a buffer overflow bug, which we found throuth
Address Sanitizer.  This patch fixes the problem by passing the
correct buffer size to the calls to ReadMemory (and to the
DataExtractor).

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

Added: 


Modified: 
lldb/source/Expression/DWARFExpression.cpp

Removed: 




diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 9232282d81353..5f71a12456972 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -1138,15 +1138,16 @@ bool DWARFExpression::Evaluate(
 
 if (load_addr == LLDB_INVALID_ADDRESS && so_addr.IsSectionOffset()) {
   uint8_t addr_bytes[8];
+  size_t buf_size = sizeof(addr_bytes);
   Status error;
 
   if (target &&
-  target->ReadMemory(so_addr, _bytes, size, error,
- /*force_live_memory=*/false) == size) {
+  target->ReadMemory(so_addr, _bytes, buf_size, error,
+ /*force_live_memory=*/false) == buf_size) {
 ObjectFile *objfile = module_sp->GetObjectFile();
 
 stack.back().GetScalar() = DerefSizeExtractDataHelper(
-addr_bytes, size, objfile->GetByteOrder(), size);
+addr_bytes, size, objfile->GetByteOrder(), buf_size);
 stack.back().ClearContext();
 break;
   } else {
@@ -1170,13 +1171,13 @@ bool DWARFExpression::Evaluate(
 lldb::addr_t pointer_addr =
 stack.back().GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
 uint8_t addr_bytes[sizeof(lldb::addr_t)];
+size_t buf_size = sizeof(addr_bytes);
 Status error;
-if (process->ReadMemory(pointer_addr, _bytes, size, error) ==
-size) {
-
+if (process->ReadMemory(pointer_addr, _bytes, buf_size, error)
+== buf_size) {
   stack.back().GetScalar() =
   DerefSizeExtractDataHelper(addr_bytes, sizeof(addr_bytes),
- process->GetByteOrder(), size);
+ process->GetByteOrder(), 
buf_size);
   stack.back().ClearContext();
 } else {
   if (error_ptr)



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


[Lldb-commits] [PATCH] D153489: [lldb] Print hint if object description is requested but not implemented

2023-06-28 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added inline comments.



Comment at: lldb/source/Commands/CommandObjectDWIMPrint.h:46-51
+  /// Add a hint if object description was requested, but no description
+  /// function was implemented, and dump valobj to output_stream after.
+  static void MaybeAddPoHintAndDump(ValueObject ,
+const DumpValueObjectOptions _options,
+lldb::LanguageType language, bool is_po,
+Stream _stream);

kastiglione wrote:
> Should this hint be part of dwim-print only? At this point I see `expression` 
> as a command you use to do exactly what you ask it to do.
I see you asked this same question, and I had missed it at first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153489

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


[Lldb-commits] [PATCH] D153489: [lldb] Print hint if object description is requested but not implemented

2023-06-28 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added a comment.

> I wonder if we should hint in all 3 command objects (expr, frame var and 
> DWIM) or if we should limit this to DWIM instead (since DWIM is the one 
> aliased to p and po and I don't think vo or expr -O are often used 
> unintentionally).

I missed this comment. My instinct is to have only dwim-print produce the hint. 
It feels more in scope for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153489

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


[Lldb-commits] [PATCH] D153489: [lldb] Print hint if object description is requested but not implemented

2023-06-28 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added inline comments.



Comment at: lldb/source/Commands/CommandObjectDWIMPrint.cpp:81-83
+<< "note: object description requested, but type doesn't implement "
+   "a custom object description. Consider using \"p\" instead of "
+   "\"po\"\n";

I wonder if there are users who might ignore this, and then find it annoying to 
see it repeatedly. Should it be a once per session warning? Once per class? Or 
controlled by a setting.



Comment at: lldb/source/Commands/CommandObjectDWIMPrint.cpp:153-154
 
-  valobj_sp->Dump(result.GetOutputStream(), dump_options);
+  MaybeAddPoHintAndDump(*valobj_sp.get(), dump_options, language, is_po,
+result.GetOutputStream());
+

I know it would be less "DRY", but it also feels weird to me to pass in a bool 
that controls whether the function does anything. At the callsite, I think the 
semantics would be more clear as:

```
if (is_po)
MaybeAddPoHintAndDump(*valobj_sp.get(), dump_options, language, 
  result.GetOutputStream());
```



Comment at: lldb/source/Commands/CommandObjectDWIMPrint.cpp:177
   if (valobj_sp->GetError().GetError() != UserExpression::kNoResult)
-valobj_sp->Dump(result.GetOutputStream(), dump_options);
+MaybeAddPoHintAndDump(*valobj_sp.get(), dump_options, language, is_po,
+  result.GetOutputStream());





Comment at: lldb/source/Commands/CommandObjectDWIMPrint.h:46-51
+  /// Add a hint if object description was requested, but no description
+  /// function was implemented, and dump valobj to output_stream after.
+  static void MaybeAddPoHintAndDump(ValueObject ,
+const DumpValueObjectOptions _options,
+lldb::LanguageType language, bool is_po,
+Stream _stream);

Should this hint be part of dwim-print only? At this point I see `expression` 
as a command you use to do exactly what you ask it to do.



Comment at: lldb/source/Commands/CommandObjectFrame.cpp:708
 rec_value_sp->GetPreferredDisplayLanguage());
+rec_value_sp->GetPreferredDisplayLanguage();
 
options.SetRootValueObjectName(rec_value_sp->GetName().AsCString());

Why is this line added? If this getter has side effects, we should create an 
appropriately named function that performs the side effects.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153489

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


[Lldb-commits] [PATCH] D98653: [lldb] Refactor variable paths to support languages with non-pointer "this" (NFC)

2023-06-28 Thread Dave Lee via Phabricator via lldb-commits
kastiglione abandoned this revision.
kastiglione added a comment.
Herald added a subscriber: Michael137.
Herald added a project: All.

This was superseded by D145276 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98653

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


[Lldb-commits] [PATCH] D151567: [LLVM][Support] Report EISDIR when opening a directory on AIX

2023-06-28 Thread Alison Zhang via Phabricator via lldb-commits
azhan92 updated this revision to Diff 535389.
azhan92 added a comment.
Herald added subscribers: JDevlieghere, jdoerfert.

Remove unrelated changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151567

Files:
  llvm/lib/Support/CommandLine.cpp
  llvm/unittests/Support/CommandLineTest.cpp


Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -1060,7 +1060,6 @@
   ASSERT_STREQ(Argv[0], "clang");
   ASSERT_STREQ(Argv[1], AFileExp.c_str());
 
-#if !defined(_AIX) && !defined(__MVS__)
   std::string ADirExp = std::string("@") + std::string(ADir.path());
   Argv = {"clang", ADirExp.c_str()};
   Res = cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv);
@@ -1068,7 +1067,6 @@
   ASSERT_EQ(2U, Argv.size());
   ASSERT_STREQ(Argv[0], "clang");
   ASSERT_STREQ(Argv[1], ADirExp.c_str());
-#endif
 }
 
 TEST(CommandLineTest, SetDefaultValue) {
Index: llvm/lib/Support/CommandLine.cpp
===
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -1289,8 +1289,9 @@
 }
 
 ErrorOr Res = FS->status(FName);
+std::error_code EC;
 if (!Res || !Res->exists()) {
-  std::error_code EC = Res.getError();
+  EC = Res.getError();
   if (!InConfigFile) {
 // If the specified file does not exist, leave '@file' unexpanded, as
 // libiberty does.
@@ -1305,6 +1306,11 @@
"': " + EC.message());
 }
 const llvm::vfs::Status  = Res.get();
+if (FileStatus.isDirectory()) {
+  EC = std::make_error_code(std::errc::is_a_directory);
+  return createStringError(EC, Twine("cannot not open file '") + FName +
+   "': " + EC.message());
+}
 
 auto IsEquivalent =
 [FileStatus, this](const ResponseFileRecord ) -> ErrorOr {


Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -1060,7 +1060,6 @@
   ASSERT_STREQ(Argv[0], "clang");
   ASSERT_STREQ(Argv[1], AFileExp.c_str());
 
-#if !defined(_AIX) && !defined(__MVS__)
   std::string ADirExp = std::string("@") + std::string(ADir.path());
   Argv = {"clang", ADirExp.c_str()};
   Res = cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv);
@@ -1068,7 +1067,6 @@
   ASSERT_EQ(2U, Argv.size());
   ASSERT_STREQ(Argv[0], "clang");
   ASSERT_STREQ(Argv[1], ADirExp.c_str());
-#endif
 }
 
 TEST(CommandLineTest, SetDefaultValue) {
Index: llvm/lib/Support/CommandLine.cpp
===
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -1289,8 +1289,9 @@
 }
 
 ErrorOr Res = FS->status(FName);
+std::error_code EC;
 if (!Res || !Res->exists()) {
-  std::error_code EC = Res.getError();
+  EC = Res.getError();
   if (!InConfigFile) {
 // If the specified file does not exist, leave '@file' unexpanded, as
 // libiberty does.
@@ -1305,6 +1306,11 @@
"': " + EC.message());
 }
 const llvm::vfs::Status  = Res.get();
+if (FileStatus.isDirectory()) {
+  EC = std::make_error_code(std::errc::is_a_directory);
+  return createStringError(EC, Twine("cannot not open file '") + FName +
+   "': " + EC.message());
+}
 
 auto IsEquivalent =
 [FileStatus, this](const ResponseFileRecord ) -> ErrorOr {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D153868: [lldb] Use LLVM's implementation of AppleTables for apple_objc

2023-06-28 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8e71d14972b4: [lldb] Use LLVMs implementation of 
AppleTables for apple_objc (authored by fdeazeve).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153868

Files:
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h

Index: lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
+++ /dev/null
@@ -1,157 +0,0 @@
-//===-- HashedNameToDIE.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_SYMBOLFILE_DWARF_HASHEDNAMETODIE_H
-#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_HASHEDNAMETODIE_H
-
-#include 
-
-#include "lldb/Core/MappedHash.h"
-#include "lldb/Core/dwarf.h"
-#include "lldb/Utility/RegularExpression.h"
-#include "lldb/lldb-defines.h"
-
-#include "DWARFDefines.h"
-#include "DWARFFormValue.h"
-#include "NameToDIE.h"
-
-class DWARFMappedHash {
-public:
-  enum AtomType : uint16_t {
-eAtomTypeNULL = 0u,
-/// DIE offset, check form for encoding.
-eAtomTypeDIEOffset = 1u,
-/// DIE offset of the compiler unit header that contains the item in
-/// question.
-eAtomTypeCUOffset = 2u,
-/// DW_TAG_xxx value, should be encoded as DW_FORM_data1 (if no tags exceed
-/// 255) or DW_FORM_data2.
-eAtomTypeTag = 3u,
-// Flags from enum NameFlags.
-eAtomTypeNameFlags = 4u,
-// Flags from enum TypeFlags.
-eAtomTypeTypeFlags = 5u,
-/// A 32 bit hash of the full qualified name (since all hash entries are
-/// basename only) For example a type like "std::vector::iterator"
-/// would have a name of "iterator" and a 32 bit hash for
-/// "std::vector::iterator" to allow us to not have to pull in debug
-/// info for a type when we know the fully qualified name.
-eAtomTypeQualNameHash = 6u
-  };
-
-  /// Bit definitions for the eAtomTypeTypeFlags flags.
-  enum TypeFlags {
-/// Always set for C++, only set for ObjC if this is the
-/// @implementation for class.
-eTypeFlagClassIsImplementation = (1u << 1)
-  };
-
-  struct DIEInfo {
-dw_offset_t die_offset = DW_INVALID_OFFSET;
-dw_tag_t tag = llvm::dwarf::DW_TAG_null;
-
-/// Any flags for this DIEInfo.
-uint32_t type_flags = 0;
-
-/// A 32 bit hash of the fully qualified name.
-uint32_t qualified_name_hash = 0;
-
-DIEInfo() = default;
-DIEInfo(dw_offset_t o, dw_tag_t t, uint32_t f, uint32_t h);
-
-explicit operator DIERef() const {
-  return DIERef(std::nullopt, DIERef::Section::DebugInfo, die_offset);
-}
-  };
-
-  struct Atom {
-AtomType type;
-dw_form_t form;
-  };
-
-  typedef std::vector DIEInfoArray;
-  typedef std::vector AtomArray;
-
-  class Prologue {
-  public:
-Prologue(dw_offset_t _die_base_offset = 0);
-
-void ClearAtoms();
-
-bool ContainsAtom(AtomType atom_type) const;
-
-void Clear();
-
-void AppendAtom(AtomType type, dw_form_t form);
-
-lldb::offset_t Read(const lldb_private::DataExtractor ,
-lldb::offset_t offset);
-
-size_t GetByteSize() const;
-
-size_t GetMinimumHashDataByteSize() const;
-
-bool HashDataHasFixedByteSize() const;
-
-/// DIE offset base so die offsets in hash_data can be CU relative.
-dw_offset_t die_base_offset;
-AtomArray atoms;
-uint32_t atom_mask = 0;
-size_t min_hash_data_byte_size = 0;
-bool hash_data_has_fixed_byte_size = true;
-  };
-
-  class Header : public MappedHash::Header {
-  public:
-size_t GetByteSize(const HeaderData _data) override;
-
-lldb::offset_t Read(lldb_private::DataExtractor ,
-lldb::offset_t offset) override;
-
-bool Read(const lldb_private::DWARFDataExtractor ,
-  lldb::offset_t *offset_ptr, DIEInfo _data) const;
-  };
-
-  /// A class for reading and using a saved hash table from a block of data in
-  /// memory.
-  class MemoryTable
-  : public MappedHash::MemoryTable {
-  public:
-MemoryTable(lldb_private::DWARFDataExtractor _data,
-const lldb_private::DWARFDataExtractor _table,
-const char *name);
-
-const char *GetStringForKeyType(KeyType key) const override;
-
-bool ReadHashData(uint32_t hash_data_offset,
-  HashData _data) 

[Lldb-commits] [lldb] 8e71d14 - [lldb] Use LLVM's implementation of AppleTables for apple_objc

2023-06-28 Thread Felipe de Azevedo Piovezan via lldb-commits

Author: Felipe de Azevedo Piovezan
Date: 2023-06-28T10:05:36-04:00
New Revision: 8e71d14972b48df8c5b701a9aec19af3194f9a5e

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

LOG: [lldb] Use LLVM's implementation of AppleTables for apple_objc

This concludes the migration of accelerator tables from LLDB code to LLVM code.

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

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt

Removed: 
lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h



diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
index 0cd8b3d71bd4f..34fb98b5a9b69 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -13,6 +13,7 @@
 
 #include "lldb/Core/Module.h"
 #include "lldb/Symbol/Function.h"
+#include "llvm/Support/DJB.h"
 
 using namespace lldb_private;
 using namespace lldb;
@@ -35,10 +36,8 @@ std::unique_ptr AppleDWARFIndex::Create(
   auto apple_types_table_up = std::make_unique(
   apple_types.GetAsLLVMDWARF(), llvm_debug_str);
 
-  auto apple_objc_table_up = std::make_unique(
-  apple_objc, debug_str, ".apple_objc");
-  if (!apple_objc_table_up->IsValid())
-apple_objc_table_up.reset();
+  auto apple_objc_table_up = std::make_unique(
+  apple_objc.GetAsLLVMDWARF(), llvm_debug_str);
 
   auto extract_and_check = [](auto ) {
 if (auto E = TablePtr->extract()) {
@@ -50,6 +49,7 @@ std::unique_ptr AppleDWARFIndex::Create(
   extract_and_check(apple_names_table_up);
   extract_and_check(apple_namespaces_table_up);
   extract_and_check(apple_types_table_up);
+  extract_and_check(apple_objc_table_up);
 
   if (apple_names_table_up || apple_namespaces_table_up ||
   apple_types_table_up || apple_objc_table_up)
@@ -172,9 +172,7 @@ void AppleDWARFIndex::GetObjCMethods(
 ConstString class_name, llvm::function_ref callback) {
   if (!m_apple_objc_up)
 return;
-  m_apple_objc_up->FindByName(
-  class_name.GetStringRef(),
-  DIERefCallback(callback, class_name.GetStringRef()));
+  SearchFor(*m_apple_objc_up, class_name, callback);
 }
 
 void AppleDWARFIndex::GetCompleteObjCClass(

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h 
b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
index 5ff88cd5e20dd..6b948e0798953 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
@@ -10,7 +10,6 @@
 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_APPLEDWARFINDEX_H
 
 #include "Plugins/SymbolFile/DWARF/DWARFIndex.h"
-#include "Plugins/SymbolFile/DWARF/HashedNameToDIE.h"
 #include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
 
 namespace lldb_private {
@@ -25,7 +24,7 @@ class AppleDWARFIndex : public DWARFIndex {
   std::unique_ptr apple_names,
   std::unique_ptr 
apple_namespaces,
   std::unique_ptr apple_types,
-  std::unique_ptr apple_objc)
+  std::unique_ptr apple_objc)
   : DWARFIndex(module), m_apple_names_up(std::move(apple_names)),
 m_apple_namespaces_up(std::move(apple_namespaces)),
 m_apple_types_up(std::move(apple_types)),
@@ -66,7 +65,7 @@ class AppleDWARFIndex : public DWARFIndex {
   std::unique_ptr m_apple_names_up;
   std::unique_ptr m_apple_namespaces_up;
   std::unique_ptr m_apple_types_up;
-  std::unique_ptr m_apple_objc_up;
+  std::unique_ptr m_apple_objc_up;
 
   /// Search for entries whose name is `name` in `table`, calling `callback` 
for
   /// each match. If `search_for_tag` is provided, ignore entries whose tag is

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt 
b/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
index 5eb2df9e7c15d..dad2060400687 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
@@ -31,7 +31,6 @@ add_lldb_library(lldbPluginSymbolFileDWARF PLUGIN
   DWARFIndex.cpp
   DWARFTypeUnit.cpp
   DWARFUnit.cpp
-  HashedNameToDIE.cpp
   LogChannelDWARF.cpp
   ManualDWARFIndex.cpp
   NameToDIE.cpp

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
deleted file mode 100644
index 19d24328a2da6..0
--- a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
+++ /dev/null
@@ -1,339 +0,0 @@
-//===-- HashedNameToDIE.cpp 
---===//
-//

[Lldb-commits] [PATCH] D153867: [lldb] Use LLVM's implementation of AppleTables for apple_debug_types

2023-06-28 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe12c701ff040: [lldb] Use LLVMs implementation of 
AppleTables for apple_debug_types (authored by fdeazeve).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153867

Files:
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h

Index: llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
===
--- llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
+++ llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
@@ -314,6 +314,13 @@
   /// Return the Atom description, which can be used to interpret the raw values
   /// of the Accelerator Entries in this table.
   ArrayRef> getAtomsDesc();
+
+  /// Returns true iff `AtomTy` is one of the atoms available in Entries of this
+  /// table.
+  bool containsAtomType(HeaderData::AtomType AtomTy) const {
+return is_contained(make_first_range(HdrData.Atoms), AtomTy);
+  }
+
   bool validateForms();
 
   /// Return information related to the DWARF DIE we're looking for when
Index: lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
+++ lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
@@ -135,19 +135,6 @@
 bool FindByName(llvm::StringRef name,
 llvm::function_ref callback);
 
-void FindByNameAndTag(llvm::StringRef name, const dw_tag_t tag,
-  llvm::function_ref callback);
-
-void FindByNameAndTagAndQualifiedNameHash(
-llvm::StringRef name, const dw_tag_t tag,
-const uint32_t qualified_name_hash,
-llvm::function_ref callback);
-
-void
-FindCompleteObjCClassByName(llvm::StringRef name,
-llvm::function_ref callback,
-bool must_be_implementation);
-
   protected:
 void FindByName(llvm::StringRef name, DIEInfoArray _info_array);
 
@@ -164,25 +151,6 @@
   llvm::function_ref callback);
 
 protected:
-  static void ExtractDIEArray(const DIEInfoArray _info_array,
-  const dw_tag_t tag,
-  llvm::function_ref callback);
-
-  static void ExtractDIEArray(const DIEInfoArray _info_array,
-  const dw_tag_t tag,
-  const uint32_t qualified_name_hash,
-  llvm::function_ref callback);
-
-  static void
-  ExtractClassOrStructDIEArray(const DIEInfoArray _info_array,
-   bool return_implementation_only_if_available,
-   llvm::function_ref callback);
-
-  static void
-  ExtractTypesFromDIEArray(const DIEInfoArray _info_array,
-   uint32_t type_flag_mask, uint32_t type_flag_value,
-   llvm::function_ref callback);
-
   static const char *GetAtomTypeName(uint16_t atom);
 };
 
Index: lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
@@ -23,92 +23,6 @@
   return true;
 }
 
-void DWARFMappedHash::ExtractDIEArray(
-const DIEInfoArray _info_array, const dw_tag_t tag,
-llvm::function_ref callback) {
-  if (tag == 0) {
-ExtractDIEArray(die_info_array, callback);
-return;
-  }
-
-  const size_t count = die_info_array.size();
-  for (size_t i = 0; i < count; ++i) {
-const dw_tag_t die_tag = die_info_array[i].tag;
-bool tag_matches = die_tag == 0 || tag == die_tag;
-if (!tag_matches) {
-  if (die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type)
-tag_matches = tag == DW_TAG_structure_type || tag == DW_TAG_class_type;
-}
-if (tag_matches) {
-  if (!callback(DIERef(die_info_array[i])))
-return;
-}
-  }
-}
-
-void DWARFMappedHash::ExtractDIEArray(
-const DIEInfoArray _info_array, const dw_tag_t tag,
-const uint32_t qualified_name_hash,
-llvm::function_ref callback) {
-  if (tag == 0) {
-ExtractDIEArray(die_info_array, callback);
-return;
-  }
-
-  const size_t count = die_info_array.size();
-  for (size_t i = 0; i < count; ++i) {
-if (qualified_name_hash != die_info_array[i].qualified_name_hash)
-  continue;
-const dw_tag_t die_tag = die_info_array[i].tag;
-bool tag_matches = die_tag == 0 || tag == die_tag;
-if 

[Lldb-commits] [lldb] e12c701 - [lldb] Use LLVM's implementation of AppleTables for apple_debug_types

2023-06-28 Thread Felipe de Azevedo Piovezan via lldb-commits

Author: Felipe de Azevedo Piovezan
Date: 2023-06-28T09:19:14-04:00
New Revision: e12c701ff0405880045f0330fb6ff94e31ec5c47

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

LOG: [lldb] Use LLVM's implementation of AppleTables for apple_debug_types

This commit is replacing really old LLDB code, and we've found some odd
behavior while doing this replacement. While the changes here are largely NFC,
there are some subtle changes that fix such odd behavior.

The most curious example of this is the method `FindCompleteObjCClassName`,
which has a flag `must_be_implementation`. This flag was _only_ being respected
for accelerator tables containing the atom `type_flags`, which seems
counter-intuitive. The implementation for DWARF 5 tables does not do that and
neither does the code introduced in this patch.

There were other weird cases, for example, we found boolean logic that was
always true in a code path: look for a `if  !has_qualified_name...` deleted
line; that condition was true by simple if/else analysis.

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

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
index 5cc44ea5b50c8..0cd8b3d71bd4f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -32,10 +32,8 @@ std::unique_ptr AppleDWARFIndex::Create(
   std::make_unique(
   apple_namespaces.GetAsLLVMDWARF(), llvm_debug_str);
 
-  auto apple_types_table_up = std::make_unique(
-  apple_types, debug_str, ".apple_types");
-  if (!apple_types_table_up->IsValid())
-apple_types_table_up.reset();
+  auto apple_types_table_up = std::make_unique(
+  apple_types.GetAsLLVMDWARF(), llvm_debug_str);
 
   auto apple_objc_table_up = std::make_unique(
   apple_objc, debug_str, ".apple_objc");
@@ -51,6 +49,7 @@ std::unique_ptr AppleDWARFIndex::Create(
 
   extract_and_check(apple_names_table_up);
   extract_and_check(apple_namespaces_table_up);
+  extract_and_check(apple_types_table_up);
 
   if (apple_names_table_up || apple_namespaces_table_up ||
   apple_types_table_up || apple_objc_table_up)
@@ -62,16 +61,69 @@ std::unique_ptr AppleDWARFIndex::Create(
   return nullptr;
 }
 
+/// Returns true if `tag` is a class_type of structure_type tag.
+static bool IsClassOrStruct(dw_tag_t tag) {
+  return tag == DW_TAG_class_type || tag == DW_TAG_structure_type;
+}
+
+/// Returns true if `entry` has an extractable DW_ATOM_qual_name_hash and it
+/// matches `expected_hash`.
+static bool
+EntryHasMatchingQualhash(const llvm::AppleAcceleratorTable::Entry ,
+ uint32_t expected_hash) {
+  std::optional form_value =
+  entry.lookup(dwarf::DW_ATOM_qual_name_hash);
+  if (!form_value)
+return false;
+  std::optional hash = form_value->getAsUnsignedConstant();
+  return hash && (*hash == expected_hash);
+}
+
+/// Returns true if `entry` has an extractable DW_ATOM_die_tag and it matches
+/// `expected_tag`. We also consider it a match if the tags are 
diff erent but
+/// in the set of {TAG_class_type, TAG_struct_type}.
+static bool EntryHasMatchingTag(const llvm::AppleAcceleratorTable::Entry 
,
+dw_tag_t expected_tag) {
+  std::optional form_value =
+  entry.lookup(dwarf::DW_ATOM_die_tag);
+  if (!form_value)
+return false;
+  std::optional maybe_tag = form_value->getAsUnsignedConstant();
+  if (!maybe_tag)
+return false;
+  auto tag = static_cast(*maybe_tag);
+  return tag == expected_tag ||
+ (IsClassOrStruct(tag) && IsClassOrStruct(expected_tag));
+}
+
+/// Returns true if `entry` has an extractable DW_ATOM_type_flags and the flag
+/// "DW_FLAG_type_implementation" is set.
+static bool
+HasImplementationFlag(const llvm::AppleAcceleratorTable::Entry ) {
+  std::optional form_value =
+  entry.lookup(dwarf::DW_ATOM_type_flags);
+  if (!form_value)
+return false;
+  std::optional Flags = form_value->getAsUnsignedConstant();
+  return Flags &&
+ (*Flags & llvm::dwarf::AcceleratorTable::DW_FLAG_type_implementation);
+}
+
 void AppleDWARFIndex::SearchFor(const llvm::AppleAcceleratorTable ,
 llvm::StringRef name,
 llvm::function_ref 
callback,
 std::optional search_for_tag,
   

[Lldb-commits] [PATCH] D153866: [lldb] Use LLVM's implementation of AppleTables for apple_{names, namespaces}

2023-06-28 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4d5c9ad9c3d7: [lldb] Use LLVMs implementation of 
AppleTables for apple_{names,namespaces} (authored by fdeazeve).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153866

Files:
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h

Index: lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
+++ lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
@@ -132,14 +132,6 @@
 bool ReadHashData(uint32_t hash_data_offset,
   HashData _data) const override;
 
-void
-AppendAllDIEsThatMatchingRegex(const lldb_private::RegularExpression ,
-   DIEInfoArray _info_array) const;
-
-void AppendAllDIEsInRange(const uint32_t die_offset_start,
-  const uint32_t die_offset_end,
-  DIEInfoArray _info_array) const;
-
 bool FindByName(llvm::StringRef name,
 llvm::function_ref callback);
 
@@ -157,10 +149,6 @@
 bool must_be_implementation);
 
   protected:
-Result AppendHashDataForRegularExpression(
-const lldb_private::RegularExpression ,
-lldb::offset_t *hash_data_offset_ptr, Pair ) const;
-
 void FindByName(llvm::StringRef name, DIEInfoArray _info_array);
 
 Result GetHashDataForName(llvm::StringRef name,
Index: lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
@@ -404,131 +404,6 @@
   }
 }
 
-DWARFMappedHash::MemoryTable::Result
-DWARFMappedHash::MemoryTable::AppendHashDataForRegularExpression(
-const lldb_private::RegularExpression ,
-lldb::offset_t *hash_data_offset_ptr, Pair ) const {
-  pair.key = m_data.GetU32(hash_data_offset_ptr);
-  // If the key is zero, this terminates our chain of HashData objects for this
-  // hash value.
-  if (pair.key == 0)
-return eResultEndOfHashData;
-
-  // There definitely should be a string for this string offset, if there
-  // isn't, there is something wrong, return and error.
-  const char *strp_cstr = m_string_table.PeekCStr(pair.key);
-  if (strp_cstr == nullptr)
-return eResultError;
-
-  const uint32_t count = m_data.GetU32(hash_data_offset_ptr);
-  const size_t min_total_hash_data_size =
-  count * m_header.header_data.GetMinimumHashDataByteSize();
-  if (count > 0 && m_data.ValidOffsetForDataOfSize(*hash_data_offset_ptr,
-   min_total_hash_data_size)) {
-// The name in the name table may be a mangled name, in which case we
-// should also compare against the demangled version.  The simplest way to
-// do that is to use the Mangled class:
-lldb_private::Mangled mangled_name((llvm::StringRef(strp_cstr)));
-const bool match = mangled_name.NameMatches(regex);
-
-if (!match && m_header.header_data.HashDataHasFixedByteSize()) {
-  // If the regex doesn't match and we have fixed size data, we can just
-  // add the total byte size of all HashData objects to the hash data
-  // offset and be done...
-  *hash_data_offset_ptr += min_total_hash_data_size;
-} else {
-  // If the string does match, or we don't have fixed size data then we
-  // need to read the hash data as a stream. If the string matches we also
-  // append all HashData objects to the value array.
-  for (uint32_t i = 0; i < count; ++i) {
-DIEInfo die_info;
-if (m_header.Read(m_data, hash_data_offset_ptr, die_info)) {
-  // Only happened if the HashData of the string matched...
-  if (match)
-pair.value.push_back(die_info);
-} else {
-  // Something went wrong while reading the data
-  *hash_data_offset_ptr = UINT32_MAX;
-  return eResultError;
-}
-  }
-}
-// Return the correct response depending on if the string matched or not...
-if (match) {
-  // The key (cstring) matches and we have lookup results!
-  return eResultKeyMatch;
-} else {
-  // The key doesn't match, this function will get called again for the
-  // next key/value or the key terminator which in our case is a zero
-  // .debug_str offset.
-  return eResultKeyMismatch;
-}
-  } else {
-*hash_data_offset_ptr = UINT32_MAX;

[Lldb-commits] [lldb] 4d5c9ad - [lldb] Use LLVM's implementation of AppleTables for apple_{names, namespaces}

2023-06-28 Thread Felipe de Azevedo Piovezan via lldb-commits

Author: Felipe de Azevedo Piovezan
Date: 2023-06-28T08:31:02-04:00
New Revision: 4d5c9ad9c3d7ed84efa1307ec158829b95badc6f

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

LOG: [lldb] Use LLVM's implementation of AppleTables for 
apple_{names,namespaces}

All the new code should match the behavior of the old exactly.

Of note, the custom queries used to be implemented inside `HashedNameToDIE.cpp`
(which is the LLDB implementation of the tables). However, when porting to LLVM,
we believe they don't belong inside the LLVM table implementation:

1. They don't require any knowledge about the table itself
2. They are not relevant for other users of these classes.
3. They use LLDB data structures.

As such, we implement these custom queries inside AppleDWARFIndex.cpp.

Types and Objective-C tables are done separately, as they have slightly
different functionality that require rewriting more code.

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

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
index 33555d4f8f4ba..5cc44ea5b50c8 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -22,16 +22,15 @@ std::unique_ptr AppleDWARFIndex::Create(
 Module , DWARFDataExtractor apple_names,
 DWARFDataExtractor apple_namespaces, DWARFDataExtractor apple_types,
 DWARFDataExtractor apple_objc, DWARFDataExtractor debug_str) {
-  auto apple_names_table_up = std::make_unique(
-  apple_names, debug_str, ".apple_names");
-  if (!apple_names_table_up->IsValid())
-apple_names_table_up.reset();
+
+  llvm::DataExtractor llvm_debug_str = debug_str.GetAsLLVM();
+
+  auto apple_names_table_up = std::make_unique(
+  apple_names.GetAsLLVMDWARF(), llvm_debug_str);
 
   auto apple_namespaces_table_up =
-  std::make_unique(
-  apple_namespaces, debug_str, ".apple_namespaces");
-  if (!apple_namespaces_table_up->IsValid())
-apple_namespaces_table_up.reset();
+  std::make_unique(
+  apple_namespaces.GetAsLLVMDWARF(), llvm_debug_str);
 
   auto apple_types_table_up = std::make_unique(
   apple_types, debug_str, ".apple_types");
@@ -43,6 +42,16 @@ std::unique_ptr AppleDWARFIndex::Create(
   if (!apple_objc_table_up->IsValid())
 apple_objc_table_up.reset();
 
+  auto extract_and_check = [](auto ) {
+if (auto E = TablePtr->extract()) {
+  llvm::consumeError(std::move(E));
+  TablePtr.reset();
+}
+  };
+
+  extract_and_check(apple_names_table_up);
+  extract_and_check(apple_namespaces_table_up);
+
   if (apple_names_table_up || apple_namespaces_table_up ||
   apple_types_table_up || apple_objc_table_up)
 return std::make_unique(
@@ -53,13 +62,23 @@ std::unique_ptr AppleDWARFIndex::Create(
   return nullptr;
 }
 
+void AppleDWARFIndex::SearchFor(const llvm::AppleAcceleratorTable ,
+llvm::StringRef name,
+llvm::function_ref 
callback,
+std::optional search_for_tag,
+std::optional search_for_qualhash) {
+  assert(!search_for_tag && !search_for_qualhash && "not yet implemented");
+  auto converted_cb = DIERefCallback(callback, name);
+  for (const auto  : table.equal_range(name))
+if (!converted_cb(entry))
+  break;
+}
+
 void AppleDWARFIndex::GetGlobalVariables(
 ConstString basename, llvm::function_ref callback) {
   if (!m_apple_names_up)
 return;
-  m_apple_names_up->FindByName(
-  basename.GetStringRef(),
-  DIERefCallback(callback, basename.GetStringRef()));
+  SearchFor(*m_apple_names_up, basename, callback);
 }
 
 void AppleDWARFIndex::GetGlobalVariables(
@@ -68,11 +87,13 @@ void AppleDWARFIndex::GetGlobalVariables(
   if (!m_apple_names_up)
 return;
 
-  DWARFMappedHash::DIEInfoArray hash_data;
-  m_apple_names_up->AppendAllDIEsThatMatchingRegex(regex, hash_data);
-  // This is not really the DIE name.
-  DWARFMappedHash::ExtractDIEArray(hash_data,
-   DIERefCallback(callback, regex.GetText()));
+  DIERefCallbackImpl converted_cb = DIERefCallback(callback, regex.GetText());
+
+  for (const auto  : m_apple_names_up->entries())
+if (std::optional name = entry.readName();
+name && 

[Lldb-commits] [PATCH] D153636: [LLDB] Fix the use of "platform process launch" with no extra arguments

2023-06-28 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: 
lldb/test/API/commands/platform/process/launch/TestPlatformProcessLaunch.py:50
+self.runCmd("settings set target.run-args D E")
+self.runCmd("platform process launch --stdout {}".format(outfile))
+self.runCmd("continue")

kastiglione wrote:
> kastiglione wrote:
> > @DavidSpickett did you mean for this command to use the `-s` flag too?
> I have merged D153922, which fails with this test as-is. Before 
> re-committing, this test will need to use `-s` like the other invocations, or 
> remove the `"continue"` command on the next line.
Will do. The missing -s was a mistake, in fact some of them failed on Linux 
without it. Perhaps a timing issue and I just got lucky on my local machine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153636

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


[Lldb-commits] [PATCH] D153922: [lldb] Duplicate Target::Launch resuming logic into CommandObjectPlatformProcessLaunch

2023-06-28 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: lldb/source/Commands/CommandObjectPlatform.cpp:1232
+
+assert(launch_info.GetHijackListener());
+

DavidSpickett wrote:
> This assert fails on Linux. Is it necessary or should I look into why it's 
> null here on Linux?
> 
> WaitForProcessToStop on down either checks that the pointer is non null 
> before use, or substitutes in another (presumably non-null) hijacker.
To clarify, fails while running the tests in https://reviews.llvm.org/D153636.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153922

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


[Lldb-commits] [PATCH] D153922: [lldb] Duplicate Target::Launch resuming logic into CommandObjectPlatformProcessLaunch

2023-06-28 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

Thanks for testing and fixing this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153922

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


[Lldb-commits] [PATCH] D153922: [lldb] Duplicate Target::Launch resuming logic into CommandObjectPlatformProcessLaunch

2023-06-28 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: lldb/source/Commands/CommandObjectPlatform.cpp:1232
+
+assert(launch_info.GetHijackListener());
+

This assert fails on Linux. Is it necessary or should I look into why it's null 
here on Linux?

WaitForProcessToStop on down either checks that the pointer is non null before 
use, or substitutes in another (presumably non-null) hijacker.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153922

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


[Lldb-commits] [PATCH] D153844: Summary: [lldb] Fix libncurses, libpanel library link order

2023-06-28 Thread Hau Hsu via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG28722dcc2556: Summary: [lldb] Fix libncurses, libpanel 
library link order (authored by hauhsu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153844

Files:
  lldb/source/Core/CMakeLists.txt


Index: lldb/source/Core/CMakeLists.txt
===
--- lldb/source/Core/CMakeLists.txt
+++ lldb/source/Core/CMakeLists.txt
@@ -10,7 +10,7 @@
 set(LLDB_LIBEDIT_LIBS)
 
 if (LLDB_ENABLE_CURSES)
-  list(APPEND LLDB_CURSES_LIBS ${CURSES_LIBRARIES} ${PANEL_LIBRARIES})
+  list(APPEND LLDB_CURSES_LIBS ${PANEL_LIBRARIES} ${CURSES_LIBRARIES})
   if(LLVM_ENABLE_TERMINFO)
 list(APPEND LLDB_CURSES_LIBS ${TERMINFO_LIB})
   endif()


Index: lldb/source/Core/CMakeLists.txt
===
--- lldb/source/Core/CMakeLists.txt
+++ lldb/source/Core/CMakeLists.txt
@@ -10,7 +10,7 @@
 set(LLDB_LIBEDIT_LIBS)
 
 if (LLDB_ENABLE_CURSES)
-  list(APPEND LLDB_CURSES_LIBS ${CURSES_LIBRARIES} ${PANEL_LIBRARIES})
+  list(APPEND LLDB_CURSES_LIBS ${PANEL_LIBRARIES} ${CURSES_LIBRARIES})
   if(LLVM_ENABLE_TERMINFO)
 list(APPEND LLDB_CURSES_LIBS ${TERMINFO_LIB})
   endif()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 28722dc - Summary: [lldb] Fix libncurses, libpanel library link order

2023-06-28 Thread Hau Hsu via lldb-commits

Author: Hau Hsu
Date: 2023-06-28T15:00:22+08:00
New Revision: 28722dcc2556b9cea5c7d9a4dd8343ac68e696ef

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

LOG: Summary: [lldb] Fix libncurses, libpanel library link order

libpanel depends on libcurses, so when linking static libraries, libpanel
should be places prior to libcurses.

This patch resolves error like:
```
.../x86_64-centos6-linux-gnu/bin/ld:
.../lib/libpanelw.a(p_show.o):
in function `show_panel':
p_show.c:(.text+0x39): undefined reference to `_nc_panelhook_sp'
.../x86_64-centos6-linux-gnu/bin/ld:
.../lib/libpanelw.a(p_show.o):
in function `update_panels_sp':
p_update.c:(.text+0x1f): undefined reference to `_nc_panelhook_sp'
collect2: error: ld returned 1 exit status
```

Reviewed By: JDevlieghere

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

Added: 


Modified: 
lldb/source/Core/CMakeLists.txt

Removed: 




diff  --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt
index f5b44d3a3d73a..2de642e10e61a 100644
--- a/lldb/source/Core/CMakeLists.txt
+++ b/lldb/source/Core/CMakeLists.txt
@@ -10,7 +10,7 @@ set(LLDB_CURSES_LIBS)
 set(LLDB_LIBEDIT_LIBS)
 
 if (LLDB_ENABLE_CURSES)
-  list(APPEND LLDB_CURSES_LIBS ${CURSES_LIBRARIES} ${PANEL_LIBRARIES})
+  list(APPEND LLDB_CURSES_LIBS ${PANEL_LIBRARIES} ${CURSES_LIBRARIES})
   if(LLVM_ENABLE_TERMINFO)
 list(APPEND LLDB_CURSES_LIBS ${TERMINFO_LIB})
   endif()



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