[Lldb-commits] [lldb] [lldb-dap] Remove `g_dap` references from lldb-dap/LLDBUtils. (PR #115933)

2024-11-12 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


https://github.com/llvm/llvm-project/pull/115933
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Refactoring JSONUtils to not use `g_dap` and instead passing in required arguments. (PR #115561)

2024-11-12 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


https://github.com/llvm/llvm-project/pull/115561
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-da] Refactoring JSONUtils to not use `g_dap` and instead passing in required arguments. (PR #115561)

2024-11-08 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo commented:

Save one comment, everything else seems good

https://github.com/llvm/llvm-project/pull/115561
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-da] Refactoring JSONUtils to not use `g_dap` and instead passing in required arguments. (PR #115561)

2024-11-08 Thread Walter Erquinigo via lldb-commits


@@ -1465,11 +1462,7 @@ CreateRunInTerminalReverseRequest(const 
llvm::json::Object &launch_request,
 llvm::StringRef key = envs.GetNameAtIndex(index);
 llvm::StringRef value = envs.GetValueAtIndex(index);
 
-if (key.empty())
-  g_dap.SendOutput(OutputType::Stderr,
-   "empty environment variable for value: \"" +
-   value.str() + '\"');
-else

walter-erquinigo wrote:

Why did you remove this?

https://github.com/llvm/llvm-project/pull/115561
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-da] Refactoring JSONUtils to not use `g_dap` and instead passing in required arguments. (PR #115561)

2024-11-08 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo edited 
https://github.com/llvm/llvm-project/pull/115561
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Refactoring breakpoints to not use the `g_dap` reference. (PR #115208)

2024-11-08 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

I remember that when lldb-dap was being brought up, the breakpoint structs were 
very simple, but they have become non-trivial at this point, so I second the 
idea of turning them into proper classes with better data encapsulation.

https://github.com/llvm/llvm-project/pull/115208
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Refactoring breakpoints to not use the `g_dap` reference. (PR #115208)

2024-11-07 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

accepting because it seems you addressed all of Pavel's issues

https://github.com/llvm/llvm-project/pull/115208
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Refactoring breakpoints to not use the `g_dap` reference. (PR #115208)

2024-11-07 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

> With these changes, and the fact that BreakpointBase has a DAP& member, the 
> breakpoints cannot be copied. 

I don't see that as a problem, but if at some point we need some more 
flexibility, we should be able to use std::reference_wrapper to store the ref 
and then allow for copies of objects when it makes sense.

> I do wonder if we should further refactor the types in lldb-dap to be a 
> little more like clangd where we have a more distinct protocol representation 
> with toJSON/fromJSON JSON serialization support (e.g. 
> https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clangd/Protocol.h).

100%! 

https://github.com/llvm/llvm-project/pull/115208
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Refactoring breakpoints to not use the `g_dap` reference. (PR #115208)

2024-11-07 Thread Walter Erquinigo via lldb-commits


@@ -11,23 +11,28 @@
 #define LLDB_TOOLS_LLDB_DAP_INSTRUCTIONBREAKPOINT_H
 
 #include "Breakpoint.h"
+#include "DAPForward.h"
+
+#include "lldb/lldb-defines.h"
+#include "lldb/lldb-types.h"
+
+#include 
 
 namespace lldb_dap {
 
 // Instruction Breakpoint
 struct InstructionBreakpoint : public Breakpoint {
 
   lldb::addr_t instructionAddressReference;
-  int32_t id;
   int32_t offset;
 
-  InstructionBreakpoint()
-  : Breakpoint(), instructionAddressReference(LLDB_INVALID_ADDRESS), id(0),
+  InstructionBreakpoint(DAP &d)

walter-erquinigo wrote:

Thanks for your thoughts!

https://github.com/llvm/llvm-project/pull/115208
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Refactoring breakpoints to not use the `g_dap` reference. (PR #115208)

2024-11-07 Thread Walter Erquinigo via lldb-commits


@@ -11,23 +11,28 @@
 #define LLDB_TOOLS_LLDB_DAP_INSTRUCTIONBREAKPOINT_H
 
 #include "Breakpoint.h"
+#include "DAPForward.h"
+
+#include "lldb/lldb-defines.h"
+#include "lldb/lldb-types.h"
+
+#include 
 
 namespace lldb_dap {
 
 // Instruction Breakpoint
 struct InstructionBreakpoint : public Breakpoint {
 
   lldb::addr_t instructionAddressReference;
-  int32_t id;
   int32_t offset;
 
-  InstructionBreakpoint()
-  : Breakpoint(), instructionAddressReference(LLDB_INVALID_ADDRESS), id(0),
+  InstructionBreakpoint(DAP &d)

walter-erquinigo wrote:

@labath , you are becoming my reference for high quality code in LLVM.
In general, do you recommend marking most one-argument constructors as explicit 
in the codebase?

https://github.com/llvm/llvm-project/pull/115208
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Refactoring breakpoints to not use the `g_dap` reference. (PR #115208)

2024-11-07 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo commented:

Besides everything mentioned by Pavel, this looks pretty good.


https://github.com/llvm/llvm-project/pull/115208
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Refactoring breakpoints to not use the `g_dap` reference. (PR #115208)

2024-11-07 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo edited 
https://github.com/llvm/llvm-project/pull/115208
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap to support running in a server mode, allowing multiple connections. (PR #114881)

2024-11-05 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

Yeah, splitting it would be a nice idea

https://github.com/llvm/llvm-project/pull/114881
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] e952728 - [LLDB] Retry Add a target.launch-working-dir setting

2024-11-05 Thread walter erquinigo via lldb-commits

Author: walter erquinigo
Date: 2024-11-05T13:29:51-05:00
New Revision: e952728f88c8b0e0208dc991dd9a04fe8c211cfb

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

LOG: [LLDB] Retry Add a target.launch-working-dir setting

This retries the PR 113521 skipping a test in a remote environment.

Added: 


Modified: 
lldb/include/lldb/Target/Target.h
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Commands/Options.td
lldb/source/Target/Target.cpp
lldb/source/Target/TargetProperties.td
lldb/test/API/commands/process/launch/TestProcessLaunch.py
llvm/docs/ReleaseNotes.md

Removed: 




diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index e4848f19e64d62..cab21c29a7486f 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -37,6 +37,7 @@
 #include "lldb/Utility/RealpathPrefixes.h"
 #include "lldb/Utility/Timeout.h"
 #include "lldb/lldb-public.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace lldb_private {
 
@@ -114,6 +115,8 @@ class TargetProperties : public Properties {
 
   void SetDisableSTDIO(bool b);
 
+  llvm::StringRef GetLaunchWorkingDirectory() const;
+
   const char *GetDisassemblyFlavor() const;
 
   InlineStrategy GetInlineStrategy() const;

diff  --git a/lldb/source/Commands/CommandObjectProcess.cpp 
b/lldb/source/Commands/CommandObjectProcess.cpp
index e7c7d07ad47722..7444e46aa729e7 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -201,6 +201,13 @@ class CommandObjectProcessLaunch : public 
CommandObjectProcessLaunchOrAttach {
 if (target->GetDisableSTDIO())
   m_options.launch_info.GetFlags().Set(eLaunchFlagDisableSTDIO);
 
+if (!m_options.launch_info.GetWorkingDirectory()) {
+  if (llvm::StringRef wd = target->GetLaunchWorkingDirectory();
+  !wd.empty()) {
+m_options.launch_info.SetWorkingDirectory(FileSpec(wd));
+  }
+}
+
 // Merge the launch info environment with the target environment.
 Environment target_env = target->GetEnvironment();
 m_options.launch_info.GetEnvironment().insert(target_env.begin(),

diff  --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 4276d9e7f9c8b0..9d8d45d083eca4 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -691,7 +691,10 @@ let Command = "process launch" in {
   def process_launch_plugin : Option<"plugin", "P">, Arg<"Plugin">,
 Desc<"Name of the process plugin you want to use.">;
   def process_launch_working_dir : Option<"working-dir", "w">, 
Arg<"DirectoryName">,
-Desc<"Set the current working directory to  when running the 
inferior.">;
+Desc<"Set the current working directory to  when running the 
inferior. This option "
+ "applies only to the current `process launch` invocation. If "
+ "`target.launch-working-dir` is set and this option is given, the 
value of this "
+ "option will be used instead of the setting.">;
   def process_launch_arch : Option<"arch", "a">, Arg<"Architecture">,
 Desc<"Set the architecture for the process to launch when ambiguous.">;
   def process_launch_environment : Option<"environment", "E">,

diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 8cd3fa8af6bae1..242d2eaec2a15a 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -4471,6 +4471,11 @@ void TargetProperties::SetDisableSTDIO(bool b) {
   const uint32_t idx = ePropertyDisableSTDIO;
   SetPropertyAtIndex(idx, b);
 }
+llvm::StringRef TargetProperties::GetLaunchWorkingDirectory() const {
+  const uint32_t idx = ePropertyLaunchWorkingDir;
+  return GetPropertyAtIndexAs(
+  idx, g_target_properties[idx].default_cstr_value);
+}
 
 const char *TargetProperties::GetDisassemblyFlavor() const {
   const uint32_t idx = ePropertyDisassemblyFlavor;

diff  --git a/lldb/source/Target/TargetProperties.td 
b/lldb/source/Target/TargetProperties.td
index fb61478fb752dc..00ad8dd2a9f7f9 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -201,6 +201,13 @@ let Definition = "target" in {
   def DebugUtilityExpression: Property<"debug-utility-expression", "Boolean">,
 DefaultFalse,
 Desc<"Enable debugging of LLDB-internal utility expressions.">;
+  def LaunchWorkingDir: Property<"launch-working-dir", "String">,
+DefaultStringValue<"">,
+Desc<"A default value for the working directory to use when launching 
processes. "
+ "It is ignored when empty. This setting is only used when the target 
is "
+ "launched. If you change this setting, the new value will only apply 
to "
+ "subsequent launches. Comman

[Lldb-commits] [lldb] [llvm] Revert "[LLDB] Add a target.launch-working-dir setting" (PR #114973)

2024-11-05 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/114973

Reverts llvm/llvm-project#113521

>From 84633d7ccc926abff46c6480dbe7ccc7e48247ce Mon Sep 17 00:00:00 2001
From: Walter Erquinigo 
Date: Tue, 5 Nov 2024 07:11:32 -0500
Subject: [PATCH] Revert "[LLDB] Add a target.launch-working-dir setting
 (#113521)"

This reverts commit 6620cd25234a42ca4b51490627afcb93fa443dc3.
---
 lldb/include/lldb/Target/Target.h |  3 -
 lldb/source/Commands/CommandObjectProcess.cpp |  7 ---
 lldb/source/Commands/Options.td   |  5 +-
 lldb/source/Target/Target.cpp |  5 --
 lldb/source/Target/TargetProperties.td|  7 ---
 .../process/launch/TestProcessLaunch.py   | 57 ---
 llvm/docs/ReleaseNotes.md |  2 -
 7 files changed, 1 insertion(+), 85 deletions(-)

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index cab21c29a7486f..e4848f19e64d62 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -37,7 +37,6 @@
 #include "lldb/Utility/RealpathPrefixes.h"
 #include "lldb/Utility/Timeout.h"
 #include "lldb/lldb-public.h"
-#include "llvm/ADT/StringRef.h"
 
 namespace lldb_private {
 
@@ -115,8 +114,6 @@ class TargetProperties : public Properties {
 
   void SetDisableSTDIO(bool b);
 
-  llvm::StringRef GetLaunchWorkingDirectory() const;
-
   const char *GetDisassemblyFlavor() const;
 
   InlineStrategy GetInlineStrategy() const;
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp 
b/lldb/source/Commands/CommandObjectProcess.cpp
index 7444e46aa729e7..e7c7d07ad47722 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -201,13 +201,6 @@ class CommandObjectProcessLaunch : public 
CommandObjectProcessLaunchOrAttach {
 if (target->GetDisableSTDIO())
   m_options.launch_info.GetFlags().Set(eLaunchFlagDisableSTDIO);
 
-if (!m_options.launch_info.GetWorkingDirectory()) {
-  if (llvm::StringRef wd = target->GetLaunchWorkingDirectory();
-  !wd.empty()) {
-m_options.launch_info.SetWorkingDirectory(FileSpec(wd));
-  }
-}
-
 // Merge the launch info environment with the target environment.
 Environment target_env = target->GetEnvironment();
 m_options.launch_info.GetEnvironment().insert(target_env.begin(),
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 9d8d45d083eca4..4276d9e7f9c8b0 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -691,10 +691,7 @@ let Command = "process launch" in {
   def process_launch_plugin : Option<"plugin", "P">, Arg<"Plugin">,
 Desc<"Name of the process plugin you want to use.">;
   def process_launch_working_dir : Option<"working-dir", "w">, 
Arg<"DirectoryName">,
-Desc<"Set the current working directory to  when running the 
inferior. This option "
- "applies only to the current `process launch` invocation. If "
- "`target.launch-working-dir` is set and this option is given, the 
value of this "
- "option will be used instead of the setting.">;
+Desc<"Set the current working directory to  when running the 
inferior.">;
   def process_launch_arch : Option<"arch", "a">, Arg<"Architecture">,
 Desc<"Set the architecture for the process to launch when ambiguous.">;
   def process_launch_environment : Option<"environment", "E">,
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 242d2eaec2a15a..8cd3fa8af6bae1 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -4471,11 +4471,6 @@ void TargetProperties::SetDisableSTDIO(bool b) {
   const uint32_t idx = ePropertyDisableSTDIO;
   SetPropertyAtIndex(idx, b);
 }
-llvm::StringRef TargetProperties::GetLaunchWorkingDirectory() const {
-  const uint32_t idx = ePropertyLaunchWorkingDir;
-  return GetPropertyAtIndexAs(
-  idx, g_target_properties[idx].default_cstr_value);
-}
 
 const char *TargetProperties::GetDisassemblyFlavor() const {
   const uint32_t idx = ePropertyDisassemblyFlavor;
diff --git a/lldb/source/Target/TargetProperties.td 
b/lldb/source/Target/TargetProperties.td
index 00ad8dd2a9f7f9..fb61478fb752dc 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -201,13 +201,6 @@ let Definition = "target" in {
   def DebugUtilityExpression: Property<"debug-utility-expression", "Boolean">,
 DefaultFalse,
 Desc<"Enable debugging of LLDB-internal utility expressions.">;
-  def LaunchWorkingDir: Property<"launch-working-dir", "String">,
-DefaultStringValue<"">,
-Desc<"A default value for the working directory to use when launching 
processes. "
- "It is ignored when empty. This setting is only used when the target 
is "
- "launched. If you change this setting, the new value will only apply 
to "
- "subsequent launche

[Lldb-commits] [lldb] [llvm] Revert "[LLDB] Add a target.launch-working-dir setting" (PR #114973)

2024-11-05 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo closed 
https://github.com/llvm/llvm-project/pull/114973
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] Revert "[LLDB] Add a target.launch-working-dir setting" (PR #114973)

2024-11-05 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo edited 
https://github.com/llvm/llvm-project/pull/114973
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [LLDB] Add a target.launch-working-dir setting (PR #113521)

2024-11-05 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo closed 
https://github.com/llvm/llvm-project/pull/113521
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [LLDB] Add a target.launch-working-dir setting (PR #113521)

2024-11-01 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/113521

>From 819380f93381eff8200c7eb9c55372f9a840c379 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Thu, 24 Oct 2024 00:17:48 -0400
Subject: [PATCH] [LLDB] Add a target.launch-working-dir setting

Internally we use bazel in a way in which it can drop you in a LLDB session 
with the target launched in a particular cwd, which is needed for things to 
work. We've been making this automation work via `process launch -w`. However, 
if later the user wants to restart the process with `r`, then they end up using 
a different cwd for relaunching the process.
As a way to fix this, I'm adding a target-level setting that allows setting a 
default cwd used for launching the process without needing the user to specify 
it manually.
---
 lldb/include/lldb/Target/Target.h |  3 +
 lldb/source/Commands/CommandObjectProcess.cpp |  7 +++
 lldb/source/Commands/Options.td   |  5 +-
 lldb/source/Target/Target.cpp |  5 ++
 lldb/source/Target/TargetProperties.td|  6 ++
 .../process/launch/TestProcessLaunch.py   | 57 +++
 llvm/docs/ReleaseNotes.md |  2 +
 7 files changed, 84 insertions(+), 1 deletion(-)

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index e4848f19e64d62..cab21c29a7486f 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -37,6 +37,7 @@
 #include "lldb/Utility/RealpathPrefixes.h"
 #include "lldb/Utility/Timeout.h"
 #include "lldb/lldb-public.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace lldb_private {
 
@@ -114,6 +115,8 @@ class TargetProperties : public Properties {
 
   void SetDisableSTDIO(bool b);
 
+  llvm::StringRef GetLaunchWorkingDirectory() const;
+
   const char *GetDisassemblyFlavor() const;
 
   InlineStrategy GetInlineStrategy() const;
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp 
b/lldb/source/Commands/CommandObjectProcess.cpp
index e7c7d07ad47722..7444e46aa729e7 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -201,6 +201,13 @@ class CommandObjectProcessLaunch : public 
CommandObjectProcessLaunchOrAttach {
 if (target->GetDisableSTDIO())
   m_options.launch_info.GetFlags().Set(eLaunchFlagDisableSTDIO);
 
+if (!m_options.launch_info.GetWorkingDirectory()) {
+  if (llvm::StringRef wd = target->GetLaunchWorkingDirectory();
+  !wd.empty()) {
+m_options.launch_info.SetWorkingDirectory(FileSpec(wd));
+  }
+}
+
 // Merge the launch info environment with the target environment.
 Environment target_env = target->GetEnvironment();
 m_options.launch_info.GetEnvironment().insert(target_env.begin(),
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 4276d9e7f9c8b0..94d1219b82b87e 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -691,7 +691,10 @@ let Command = "process launch" in {
   def process_launch_plugin : Option<"plugin", "P">, Arg<"Plugin">,
 Desc<"Name of the process plugin you want to use.">;
   def process_launch_working_dir : Option<"working-dir", "w">, 
Arg<"DirectoryName">,
-Desc<"Set the current working directory to  when running the 
inferior.">;
+Desc<"Set the current working directory to  when running the 
inferior. This setting "
+ "applies only to the current `process launch` invocation. You can use 
the "
+ "`target.launch-working-dir` setting to set a working-dir that is 
persistent "
+ "across launches.">;
   def process_launch_arch : Option<"arch", "a">, Arg<"Architecture">,
 Desc<"Set the architecture for the process to launch when ambiguous.">;
   def process_launch_environment : Option<"environment", "E">,
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 199efae8a728cc..b6d4b28b03a5b3 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -4428,6 +4428,11 @@ void TargetProperties::SetDisableSTDIO(bool b) {
   const uint32_t idx = ePropertyDisableSTDIO;
   SetPropertyAtIndex(idx, b);
 }
+llvm::StringRef TargetProperties::GetLaunchWorkingDirectory() const {
+  const uint32_t idx = ePropertyLaunchWorkingDir;
+  return GetPropertyAtIndexAs(
+  idx, g_target_properties[idx].default_cstr_value);
+}
 
 const char *TargetProperties::GetDisassemblyFlavor() const {
   const uint32_t idx = ePropertyDisassemblyFlavor;
diff --git a/lldb/source/Target/TargetProperties.td 
b/lldb/source/Target/TargetProperties.td
index fb61478fb752dc..3aa7cc41c4d5ca 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -201,6 +201,12 @@ let Definition = "target" in {
   def DebugUtilityExpression: Property<"debug-utility-expression", "Boolean">,
 DefaultFalse,
 Desc<"Enable debugging of LLDB-internal utility

[Lldb-commits] [lldb] [LLDB] Finish implementing support for DW_FORM_data16 (PR #113508)

2024-11-01 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo closed 
https://github.com/llvm/llvm-project/pull/113508
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Finish implementing support for DW_FORM_data16 (PR #113508)

2024-11-01 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

I was able to make it work using @labath 's suggestion. Fortunately it just 
works.
Please give it another look :)

https://github.com/llvm/llvm-project/pull/113508
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Finish implementing support for DW_FORM_data16 (PR #113508)

2024-11-01 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/113508

>From dce501d494a3d559d490f8d58f6918b63ed9d175 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Wed, 23 Oct 2024 19:49:24 -0400
Subject: [PATCH 1/2] [LLDB] Finish implementing support for DW_FORM_data16

This FORM already has support within LLDB to be parsed as a 16-byte
BLOCK, and all that is left to properly support it in the DWARFParser is
to add it to some enums.

With this, I can debug programs that use libstdc++.so.6.0.33 built with
GCC.
---
 .../Plugins/SymbolFile/DWARF/DWARFFormValue.cpp|  7 +++
 .../Shell/SymbolFile/DWARF/x86/DW_AT_const_value.s | 14 +-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
index f58c6262349c6f..404e50d57a9251 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -306,6 +306,11 @@ bool DWARFFormValue::SkipValue(dw_form_t form,
   *offset_ptr += 8;
   return true;
 
+// 16 byte values
+case DW_FORM_data16:
+  *offset_ptr += 16;
+  return true;
+
 // signed or unsigned LEB 128 values
 case DW_FORM_addrx:
 case DW_FORM_loclistx:
@@ -578,6 +583,7 @@ bool DWARFFormValue::IsBlockForm(const dw_form_t form) {
   case DW_FORM_block1:
   case DW_FORM_block2:
   case DW_FORM_block4:
+  case DW_FORM_data16:
 return true;
   default:
 return false;
@@ -611,6 +617,7 @@ bool DWARFFormValue::FormIsSupported(dw_form_t form) {
 case DW_FORM_data2:
 case DW_FORM_data4:
 case DW_FORM_data8:
+case DW_FORM_data16:
 case DW_FORM_string:
 case DW_FORM_block:
 case DW_FORM_block1:
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_const_value.s 
b/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_const_value.s
index 720684c19beebc..731a558f3e572d 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_const_value.s
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_const_value.s
@@ -3,7 +3,7 @@
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o %t
 # RUN: %lldb %t \
-# RUN:   -o "target variable udata data1 data2 data4 data8 string strp ref4 
udata_ptr" \
+# RUN:   -o "target variable udata data1 data2 data4 data8 data16 string strp 
ref4 udata_ptr" \
 # RUN:   -o exit | FileCheck %s
 
 # CHECK-LABEL: target variable
@@ -14,6 +14,7 @@
 # CHECK: (unsigned long) data2 = 4742
 # CHECK: (unsigned long) data4 = 47424742
 # CHECK: (unsigned long) data8 = 4742474247424742
+# CHECK: (unsigned __int128) data16 = 129440743495415807670381713415221633377
 ## Variables specified using string forms. This behavior purely speculative -- 
I
 ## don't know of any compiler that would represent character strings this way.
 # CHECK: (char[7]) string = "string"
@@ -88,6 +89,7 @@
 var 15, 0x8 # DW_FORM_string
 var 16, 0xe # DW_FORM_strp
 var 17, 0x13# DW_FORM_ref4
+var 18, 0x1e# DW_FORM_data16
 .byte   0   # EOM(3)
 .section.debug_info,"",@progbits
 .Lcu_begin0:
@@ -119,6 +121,11 @@
 .Lulong_ptr:
 .byte   2   # Abbrev DW_TAG_pointer_type
 .long   .Lulong-.Lcu_begin0 # DW_AT_type
+.Lu128:
+.byte   6   # Abbrev DW_TAG_base_type
+.asciz  "Lu128" # DW_AT_name
+.byte   16  # DW_AT_byte_size
+.byte   7   # DW_AT_encoding
 
 .byte   10  # Abbrev DW_TAG_variable
 .asciz  "udata" # DW_AT_name
@@ -165,6 +172,11 @@
 .long   .Lulong_ptr-.Lcu_begin0 # DW_AT_type
 .uleb128 0xdeadbeefbaadf00d # DW_AT_const_value
 
+.byte   18  # Abbrev DW_TAG_variable
+.asciz  "data16"# DW_AT_name
+.long   .Lu128-.Lcu_begin0  # DW_AT_type
+.asciz 
""
 # DW_AT_const_value
+
 .byte   0   # End Of Children Mark
 .Ldebug_info_end0:
 

>From 403bbcaddc40d011cbd262381c3bc4e6768c234a Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 1 Nov 2024 13:14:59 -0400
Subject: [PATCH 2/2] fix fix

---
 lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_const_value.s | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_const_value.s 
b/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_const_value.s
index 731a558f3e572d..306afd32d92235 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_const_value.s
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_const_value.s
@@ -3,7 +3,8 @@
 
 # RUN: llvm-mc -filety

[Lldb-commits] [lldb] [LLDB] Add a target.launch-working-dir setting (PR #113521)

2024-10-31 Thread Walter Erquinigo via lldb-commits


@@ -4428,6 +4428,15 @@ void TargetProperties::SetDisableSTDIO(bool b) {
   const uint32_t idx = ePropertyDisableSTDIO;
   SetPropertyAtIndex(idx, b);
 }
+std::optional
+TargetProperties::GetLaunchWorkingDirectory() const {

walter-erquinigo wrote:

Yeah, that makes sense, also because of consistency with the rest of the code

https://github.com/llvm/llvm-project/pull/113521
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Add a target.launch-working-dir setting (PR #113521)

2024-10-31 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

Sorry, I thought it had been 1 week already. I'll be mindful of that next time. 
And yeah, it's natural that the conference slowed things down.

https://github.com/llvm/llvm-project/pull/113521
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [lldb-dap] Support column breakpoints (PR #113787)

2024-10-30 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

beautiful

https://github.com/llvm/llvm-project/pull/113787
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [lldb-dap] Support column breakpoints (PR #113787)

2024-10-30 Thread Walter Erquinigo via lldb-commits


@@ -281,12 +270,11 @@ def test_clear_breakpoints_unset_breakpoints(self):
 self.assertEqual(
 len(breakpoints), len(lines), "expect %u source breakpoints" % 
(len(lines))
 )
-for breakpoint, index in zip(breakpoints, range(len(lines))):
+for index, breakpoint in enumerate(breakpoints):

walter-erquinigo wrote:

+1

https://github.com/llvm/llvm-project/pull/113787
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [lldb-dap] Support column breakpoints (PR #113787)

2024-10-30 Thread Walter Erquinigo via lldb-commits


@@ -238,9 +238,10 @@ def set_global(self, name, value, id=None):
 def stepIn(
 self, threadId=None, targetId=None, waitForStop=True, 
granularity="statement"
 ):
-self.dap_server.request_stepIn(
+response = self.dap_server.request_stepIn(
 threadId=threadId, targetId=targetId, granularity=granularity
 )
+assert response["success"] is True

walter-erquinigo wrote:

use `self.assertTrue`, which is more idiomatic in our codebase

https://github.com/llvm/llvm-project/pull/113787
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Finish implementing support for DW_FORM_data16 (PR #113508)

2024-10-30 Thread Walter Erquinigo via lldb-commits


@@ -165,6 +172,11 @@
 .long   .Lulong_ptr-.Lcu_begin0 # DW_AT_type
 .uleb128 0xdeadbeefbaadf00d # DW_AT_const_value
 
+.byte   18  # Abbrev DW_TAG_variable
+.asciz  "data16"# DW_AT_name
+.long   .Lu128-.Lcu_begin0  # DW_AT_type
+.asciz 
""
 # DW_AT_const_value

walter-erquinigo wrote:

That's a good idea. I'll try that out!

https://github.com/llvm/llvm-project/pull/113508
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Finish implementing support for DW_FORM_data16 (PR #113508)

2024-10-29 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

Friendly ping, otherwise I'll merge it in a couple of days

https://github.com/llvm/llvm-project/pull/113508
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Add a target.launch-working-dir setting (PR #113521)

2024-10-29 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

Friendly ping, otherwise I'll merge it in a couple of days

https://github.com/llvm/llvm-project/pull/113521
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Add a target.launch-working-dir setting (PR #113521)

2024-10-25 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo edited 
https://github.com/llvm/llvm-project/pull/113521
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap][test] Set disableASLR to False for tests (PR #113593)

2024-10-25 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


https://github.com/llvm/llvm-project/pull/113593
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Fix pointer to reference type (PR #113596)

2024-10-24 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


https://github.com/llvm/llvm-project/pull/113596
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Add a target.launch-working-dir setting (PR #113521)

2024-10-24 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/113521

>From 4c80e266e53c53393700a3030edfc471137d2fd5 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Thu, 24 Oct 2024 00:17:48 -0400
Subject: [PATCH] [LLDB] Add a target.launch-working-dir setting

Internally we use bazel in a way in which it can drop you in a LLDB session 
with the target launched in a particular cwd, which is needed for things to 
work. We've been making this automation work via `process launch -w`. However, 
if later the user wants to restart the process with `r`, then they end up using 
a different cwd for relaunching the process.
As a way to fix this, I'm adding a target-level setting that allows setting a 
default cwd used for launching the process without needing the user to specify 
it manually.
---
 lldb/include/lldb/Target/Target.h |  3 +
 lldb/source/Commands/CommandObjectProcess.cpp |  7 ++
 lldb/source/Target/Target.cpp |  9 +++
 lldb/source/Target/TargetProperties.td|  4 ++
 .../process/launch/TestProcessLaunch.py   | 68 +++
 5 files changed, 91 insertions(+)

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index e4848f19e64d62..0e8bbb41f29941 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -37,6 +37,7 @@
 #include "lldb/Utility/RealpathPrefixes.h"
 #include "lldb/Utility/Timeout.h"
 #include "lldb/lldb-public.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace lldb_private {
 
@@ -114,6 +115,8 @@ class TargetProperties : public Properties {
 
   void SetDisableSTDIO(bool b);
 
+  std::optional GetLaunchWorkingDirectory() const;
+
   const char *GetDisassemblyFlavor() const;
 
   InlineStrategy GetInlineStrategy() const;
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp 
b/lldb/source/Commands/CommandObjectProcess.cpp
index e7c7d07ad47722..b7984c0c1ab860 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -201,6 +201,13 @@ class CommandObjectProcessLaunch : public 
CommandObjectProcessLaunchOrAttach {
 if (target->GetDisableSTDIO())
   m_options.launch_info.GetFlags().Set(eLaunchFlagDisableSTDIO);
 
+if (!m_options.launch_info.GetWorkingDirectory()) {
+  if (std::optional wd =
+  target->GetLaunchWorkingDirectory()) {
+m_options.launch_info.SetWorkingDirectory(FileSpec(*wd));
+  }
+}
+
 // Merge the launch info environment with the target environment.
 Environment target_env = target->GetEnvironment();
 m_options.launch_info.GetEnvironment().insert(target_env.begin(),
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 04395e37f0425d..ef4dabf00c1a9e 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -4428,6 +4428,15 @@ void TargetProperties::SetDisableSTDIO(bool b) {
   const uint32_t idx = ePropertyDisableSTDIO;
   SetPropertyAtIndex(idx, b);
 }
+std::optional
+TargetProperties::GetLaunchWorkingDirectory() const {
+  const uint32_t idx = ePropertyLaunchWorkingDir;
+  llvm::StringRef value = GetPropertyAtIndexAs(
+  idx, g_target_properties[idx].default_cstr_value);
+  if (value.empty())
+return {};
+  return value;
+}
 
 const char *TargetProperties::GetDisassemblyFlavor() const {
   const uint32_t idx = ePropertyDisassemblyFlavor;
diff --git a/lldb/source/Target/TargetProperties.td 
b/lldb/source/Target/TargetProperties.td
index fb61478fb752dc..a6e833d5c6e3f9 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -201,6 +201,10 @@ let Definition = "target" in {
   def DebugUtilityExpression: Property<"debug-utility-expression", "Boolean">,
 DefaultFalse,
 Desc<"Enable debugging of LLDB-internal utility expressions.">;
+  def LaunchWorkingDir: Property<"launch-working-dir", "String">,
+DefaultStringValue<"">,
+Desc<"A default value for the working directory to use when launching 
processes. "
+ "It's not used when empty.">;
 }
 
 let Definition = "process_experimental" in {
diff --git a/lldb/test/API/commands/process/launch/TestProcessLaunch.py 
b/lldb/test/API/commands/process/launch/TestProcessLaunch.py
index 45f9f494ab8f5c..4bab553af01ad9 100644
--- a/lldb/test/API/commands/process/launch/TestProcessLaunch.py
+++ b/lldb/test/API/commands/process/launch/TestProcessLaunch.py
@@ -8,6 +8,7 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
+from pathlib import Path
 
 
 class ProcessLaunchTestCase(TestBase):
@@ -206,3 +207,70 @@ def test_environment_with_special_char(self):
 self.assertEqual(value, evil_var)
 process.Continue()
 self.assertState(process.GetState(), lldb.eStateExited, PROCESS_EXITED)
+
+def test_target_launch_working_dir_prop(self):
+"""Test that the setting `target.launch-w

[Lldb-commits] [lldb] [LLDB] Add a target.launch-working-dir setting (PR #113521)

2024-10-23 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/113521

Internally we use bazel in a way in which it can drop you in a LLDB session 
with the target launched in a particular cwd, which is needed for things to 
work. We've been making this automation work via `process launch -w`. However, 
if later the user wants to restart the process with `r`, then they end up using 
a different cwd for relaunching the process. As a way to fix this, I'm adding a 
target-level setting that allows overriding the cwd used for launching the 
process without needing the user to specify it manually.

>From be5c3c3adcc148e8e89d743b05d2b22f4be8e6c6 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Thu, 24 Oct 2024 00:17:48 -0400
Subject: [PATCH] [LLDB] Add a target.launch-working-dir setting

Internally we use bazel in a way in which it can drop you in a LLDB session 
with the target launched in a particular cwd, which is needed for things to 
work. We've been making this automation work via `process launch -w`. However, 
if later the user wants to restart the process with `r`, then they end up using 
a different cwd for relaunching the process.
As a way to fix this, I'm adding a target-level setting that allows overriding 
the cwd used for launching the process without needing the user to specify it 
manually.
---
 lldb/include/lldb/Target/Target.h |  3 ++
 lldb/source/Commands/CommandObjectProcess.cpp |  5 +++
 lldb/source/Target/Target.cpp |  9 
 lldb/source/Target/TargetProperties.td|  4 ++
 .../process/launch/TestProcessLaunch.py   | 45 +++
 5 files changed, 66 insertions(+)

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index e4848f19e64d62..0e8bbb41f29941 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -37,6 +37,7 @@
 #include "lldb/Utility/RealpathPrefixes.h"
 #include "lldb/Utility/Timeout.h"
 #include "lldb/lldb-public.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace lldb_private {
 
@@ -114,6 +115,8 @@ class TargetProperties : public Properties {
 
   void SetDisableSTDIO(bool b);
 
+  std::optional GetLaunchWorkingDirectory() const;
+
   const char *GetDisassemblyFlavor() const;
 
   InlineStrategy GetInlineStrategy() const;
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp 
b/lldb/source/Commands/CommandObjectProcess.cpp
index e7c7d07ad47722..297c94c1f0a055 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -201,6 +201,11 @@ class CommandObjectProcessLaunch : public 
CommandObjectProcessLaunchOrAttach {
 if (target->GetDisableSTDIO())
   m_options.launch_info.GetFlags().Set(eLaunchFlagDisableSTDIO);
 
+if (std::optional wd =
+target->GetLaunchWorkingDirectory()) {
+  m_options.launch_info.SetWorkingDirectory(FileSpec(*wd));
+}
+
 // Merge the launch info environment with the target environment.
 Environment target_env = target->GetEnvironment();
 m_options.launch_info.GetEnvironment().insert(target_env.begin(),
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 04395e37f0425d..ef4dabf00c1a9e 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -4428,6 +4428,15 @@ void TargetProperties::SetDisableSTDIO(bool b) {
   const uint32_t idx = ePropertyDisableSTDIO;
   SetPropertyAtIndex(idx, b);
 }
+std::optional
+TargetProperties::GetLaunchWorkingDirectory() const {
+  const uint32_t idx = ePropertyLaunchWorkingDir;
+  llvm::StringRef value = GetPropertyAtIndexAs(
+  idx, g_target_properties[idx].default_cstr_value);
+  if (value.empty())
+return {};
+  return value;
+}
 
 const char *TargetProperties::GetDisassemblyFlavor() const {
   const uint32_t idx = ePropertyDisassemblyFlavor;
diff --git a/lldb/source/Target/TargetProperties.td 
b/lldb/source/Target/TargetProperties.td
index fb61478fb752dc..613442501d6b6d 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -201,6 +201,10 @@ let Definition = "target" in {
   def DebugUtilityExpression: Property<"debug-utility-expression", "Boolean">,
 DefaultFalse,
 Desc<"Enable debugging of LLDB-internal utility expressions.">;
+  def LaunchWorkingDir: Property<"launch-working-dir", "String">,
+DefaultStringValue<"">,
+Desc<"An override for the working directory to use when launching 
processes. "
+ "It's not used when empty.">;
 }
 
 let Definition = "process_experimental" in {
diff --git a/lldb/test/API/commands/process/launch/TestProcessLaunch.py 
b/lldb/test/API/commands/process/launch/TestProcessLaunch.py
index 45f9f494ab8f5c..f3afc385a56086 100644
--- a/lldb/test/API/commands/process/launch/TestProcessLaunch.py
+++ b/lldb/test/API/commands/process/launch/TestProcessLaunch.py
@@ -8,6 +8,7 @@
 from lldbsuite.test.decorators import *
 from lldbsuite

[Lldb-commits] [lldb] [LLDB] Finish implementing support for DW_FORM_data16 (PR #106799)

2024-10-23 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

Cancelled in favor of https://github.com/llvm/llvm-project/pull/113508 which 
adds tests


https://github.com/llvm/llvm-project/pull/106799
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Finish implementing support for DW_FORM_data16 (PR #113508)

2024-10-23 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/113508

This FORM already has support within LLDB to be parsed as a 16-byte BLOCK, and 
all that is left to properly support it in the DWARFParser is to add it to some 
enums.

With this, I can debug programs that use libstdc++.so.6.0.33 built with GCC.

>From e1986e8c9ec7071f5256bc648586cd848712a4e9 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Wed, 23 Oct 2024 19:49:24 -0400
Subject: [PATCH] [LLDB] Finish implementing support for DW_FORM_data16

This FORM already has support within LLDB to be parsed as a 16-byte
BLOCK, and all that is left to properly support it in the DWARFParser is
to add it to some enums.

With this, I can debug programs that use libstdc++.so.6.0.33 built with
GCC.
---
 .../Plugins/SymbolFile/DWARF/DWARFFormValue.cpp|  7 +++
 .../Shell/SymbolFile/DWARF/x86/DW_AT_const_value.s | 14 +-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
index f58c6262349c6f..404e50d57a9251 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -306,6 +306,11 @@ bool DWARFFormValue::SkipValue(dw_form_t form,
   *offset_ptr += 8;
   return true;
 
+// 16 byte values
+case DW_FORM_data16:
+  *offset_ptr += 16;
+  return true;
+
 // signed or unsigned LEB 128 values
 case DW_FORM_addrx:
 case DW_FORM_loclistx:
@@ -578,6 +583,7 @@ bool DWARFFormValue::IsBlockForm(const dw_form_t form) {
   case DW_FORM_block1:
   case DW_FORM_block2:
   case DW_FORM_block4:
+  case DW_FORM_data16:
 return true;
   default:
 return false;
@@ -611,6 +617,7 @@ bool DWARFFormValue::FormIsSupported(dw_form_t form) {
 case DW_FORM_data2:
 case DW_FORM_data4:
 case DW_FORM_data8:
+case DW_FORM_data16:
 case DW_FORM_string:
 case DW_FORM_block:
 case DW_FORM_block1:
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_const_value.s 
b/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_const_value.s
index 720684c19beebc..731a558f3e572d 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_const_value.s
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_const_value.s
@@ -3,7 +3,7 @@
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o %t
 # RUN: %lldb %t \
-# RUN:   -o "target variable udata data1 data2 data4 data8 string strp ref4 
udata_ptr" \
+# RUN:   -o "target variable udata data1 data2 data4 data8 data16 string strp 
ref4 udata_ptr" \
 # RUN:   -o exit | FileCheck %s
 
 # CHECK-LABEL: target variable
@@ -14,6 +14,7 @@
 # CHECK: (unsigned long) data2 = 4742
 # CHECK: (unsigned long) data4 = 47424742
 # CHECK: (unsigned long) data8 = 4742474247424742
+# CHECK: (unsigned __int128) data16 = 129440743495415807670381713415221633377
 ## Variables specified using string forms. This behavior purely speculative -- 
I
 ## don't know of any compiler that would represent character strings this way.
 # CHECK: (char[7]) string = "string"
@@ -88,6 +89,7 @@
 var 15, 0x8 # DW_FORM_string
 var 16, 0xe # DW_FORM_strp
 var 17, 0x13# DW_FORM_ref4
+var 18, 0x1e# DW_FORM_data16
 .byte   0   # EOM(3)
 .section.debug_info,"",@progbits
 .Lcu_begin0:
@@ -119,6 +121,11 @@
 .Lulong_ptr:
 .byte   2   # Abbrev DW_TAG_pointer_type
 .long   .Lulong-.Lcu_begin0 # DW_AT_type
+.Lu128:
+.byte   6   # Abbrev DW_TAG_base_type
+.asciz  "Lu128" # DW_AT_name
+.byte   16  # DW_AT_byte_size
+.byte   7   # DW_AT_encoding
 
 .byte   10  # Abbrev DW_TAG_variable
 .asciz  "udata" # DW_AT_name
@@ -165,6 +172,11 @@
 .long   .Lulong_ptr-.Lcu_begin0 # DW_AT_type
 .uleb128 0xdeadbeefbaadf00d # DW_AT_const_value
 
+.byte   18  # Abbrev DW_TAG_variable
+.asciz  "data16"# DW_AT_name
+.long   .Lu128-.Lcu_begin0  # DW_AT_type
+.asciz 
""
 # DW_AT_const_value
+
 .byte   0   # End Of Children Mark
 .Ldebug_info_end0:
 

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


[Lldb-commits] [lldb] [LLDB] Finish implementing support for DW_FORM_data16 (PR #106799)

2024-10-23 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo closed 
https://github.com/llvm/llvm-project/pull/106799
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Finish implementing support for DW_FORM_data16 (PR #106799)

2024-10-23 Thread Walter Erquinigo via lldb-commits


@@ -578,6 +583,7 @@ bool DWARFFormValue::IsBlockForm(const dw_form_t form) {
   case DW_FORM_block1:
   case DW_FORM_block2:
   case DW_FORM_block4:
+  case DW_FORM_data16:

walter-erquinigo wrote:

I think that the block form will be the most convenient way to access this just 
because not all systems have uint128_t.

https://github.com/llvm/llvm-project/pull/106799
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add a compiler/interpreter of LLDB data formatter bytecode to lldb/examples (PR #113398)

2024-10-22 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

Man, this is fantastic. I'll try to implement a little compiler for this for my 
language (Mojo).

https://github.com/llvm/llvm-project/pull/113398
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Creating an API for sending custom dap events from lldb-dap. (PR #112384)

2024-10-15 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo edited 
https://github.com/llvm/llvm-project/pull/112384
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Creating an API for sending custom dap events from lldb-dap. (PR #112384)

2024-10-15 Thread Walter Erquinigo via lldb-commits


@@ -1896,6 +1896,8 @@ void request_initialize(const llvm::json::Object 
&request) {
   cmd.AddCommand(
   "repl-mode", new ReplModeRequestHandler(),
   "Get or set the repl behavior of lldb-dap evaluation requests.");
+  cmd.AddCommand("custom-event", new CustomDAPEventRequestHandler(),

walter-erquinigo wrote:

what about custom-dap-event?

https://github.com/llvm/llvm-project/pull/112384
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Creating an API for sending custom dap events from lldb-dap. (PR #112384)

2024-10-15 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

looks pretty good. Just a minor nit

https://github.com/llvm/llvm-project/pull/112384
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Improving the naming consistency of startDebugging reverse request. (PR #112396)

2024-10-15 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

cool

https://github.com/llvm/llvm-project/pull/112396
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Implement value locations for function pointers (PR #104589)

2024-10-08 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


https://github.com/llvm/llvm-project/pull/104589
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][test] Enable TestDAP_runInTerminal on non-x86 architectures (PR #111543)

2024-10-08 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

Thanks!

https://github.com/llvm/llvm-project/pull/111543
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Make env and source map dictionaries #95137 (PR #106919)

2024-10-07 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

@Da-Viper , you should request commit access!

https://github.com/llvm/llvm-project/pull/106919
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Make env and source map dictionaries #95137 (PR #106919)

2024-10-07 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo closed 
https://github.com/llvm/llvm-project/pull/106919
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Make env and source map dictionaries #95137 (PR #106919)

2024-10-06 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

nice!

https://github.com/llvm/llvm-project/pull/106919
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add: show return value on step out (PR #106907)

2024-10-06 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo commented:

This looks much better!
Could you please write some tests?

https://github.com/llvm/llvm-project/pull/106907
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-10-03 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo closed 
https://github.com/llvm/llvm-project/pull/110543
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-10-03 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

I'm closing this because I figure out a way for my language to be compliant 
with what LLDB expects, following the same path of Rust. I know we should make 
LLDB more generic, but I ended up finding so many little broken things if I 
don't follow C++'s style, and that's too much just for me.

https://github.com/llvm/llvm-project/pull/110543
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap][docs] Improve documentation for contributors (PR #110987)

2024-10-03 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

beautiful

https://github.com/llvm/llvm-project/pull/110987
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap][docs] Improve documentation for contributors (PR #110987)

2024-10-03 Thread Walter Erquinigo via lldb-commits


@@ -1,16 +1,95 @@
-# LLDB-DAP
-
-The `lldb-dap` tool (formerly `lldb-vscode`) is a command line tool that
-implements the [Debug Adapter
-Protocol](https://microsoft.github.io/debug-adapter-protocol/). It can be
-installed as an extension for Visual Studio Code and other IDEs supporting DAP.
-The protocol is easy to run remotely and also can allow other tools and IDEs to
-get a full featured debugger with a well defined protocol.
-
-## Local Installation for Visual Studio Code
+# Contributing to LLDB-DAP
+
+This guide describes how to extend and contribute to lldb-dap.
+For documentation on how to use lldb-dap, see [lldb-dap's 
README](https://github.com/llvm/llvm-project/blob/release/19.x/lldb/tools/lldb-dap/README.md).

walter-erquinigo wrote:

better use `main` instead of `release/19.x`

https://github.com/llvm/llvm-project/pull/110987
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap][docs] Improve documentation for contributors (PR #110987)

2024-10-03 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo edited 
https://github.com/llvm/llvm-project/pull/110987
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap][docs] Fix README (PR #110982)

2024-10-03 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


https://github.com/llvm/llvm-project/pull/110982
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/110543

>From 15132008232d446036a43a8ed3eed5883f80a2d5 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 30 Sep 2024 13:33:35 -0400
Subject: [PATCH] [LLDB] Fix symbol breakpoint lookups for non-C-like languages

I'm developing the Mojo language, and some symbol breakpoints don't work 
because of two reasons that got fixed1:

- There's a prune step that operates on the assuption that the symbol is 
C-like. That was discarding lots of the Mojo breakpoints
- When finding functions for symbol breakpoints with eFunctionNameTypeFull, 
LLDB was only matching die.getMangledName() and not die.GetName(). The latter 
is the one useful for Mojo, because the former has some unreadable format in 
Mojo that is not exposed to the user. This shouldn't cause any regression for 
C-like languages, as the prune step would sanitize them anyway, but it's useful 
for languages like Mojo.
---
 lldb/include/lldb/Target/Language.h   | 16 
 lldb/source/Core/Module.cpp   | 32 ++--
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 38 +++
 .../Language/CPlusPlus/CPlusPlusLanguage.h|  3 ++
 .../Plugins/SymbolFile/DWARF/DWARFIndex.cpp   |  3 +-
 5 files changed, 63 insertions(+), 29 deletions(-)

diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index 41d8eeef469eab..f44f9fc08e7970 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -16,6 +16,7 @@
 #include 
 
 #include "lldb/Core/Highlighter.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/DataFormatters/DumpValueObjectOptions.h"
 #include "lldb/DataFormatters/FormatClasses.h"
@@ -379,6 +380,21 @@ class Language : public PluginInterface {
   /// Python uses \b except. Defaults to \b catch.
   virtual llvm::StringRef GetCatchKeyword() const { return "catch"; }
 
+  /// Method invoked by \a Module::LookupInfo::Prune used to filter out symbol
+  /// search results.
+  ///
+  /// \param[in] sc A symbol that passed the common symbol search lookup
+  ///   process.
+  /// \param[in] lookup_info The full lookup info.
+  ///
+  /// \return whether the given symbol should be discarded from the search
+  /// results.
+  virtual bool
+  SymbolLookupHookShouldPruneResult(const SymbolContext &sc,
+const Module::LookupInfo &lookup_info) {
+return false;
+  }
+
 protected:
   // Classes that inherit from Language can see and modify these
 
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 88cc957e91fac4..0cc21c61a3dfa7 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -787,40 +787,16 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
 }
   }
 
-  // If we have only full name matches we might have tried to set breakpoint on
-  // "func" and specified eFunctionNameTypeFull, but we might have found
-  // "a::func()", "a::b::func()", "c::func()", "func()" and "func". Only
-  // "func()" and "func" should end up matching.
   if (m_name_type_mask == eFunctionNameTypeFull) {
 SymbolContext sc;
 size_t i = start_idx;
 while (i < sc_list.GetSize()) {
   if (!sc_list.GetContextAtIndex(i, sc))
 break;
-  // Make sure the mangled and demangled names don't match before we try to
-  // pull anything out
-  ConstString mangled_name(sc.GetFunctionName(Mangled::ePreferMangled));
-  ConstString full_name(sc.GetFunctionName());
-  if (mangled_name != m_name && full_name != m_name) {
-CPlusPlusLanguage::MethodName cpp_method(full_name);
-if (cpp_method.IsValid()) {
-  if (cpp_method.GetContext().empty()) {
-if (cpp_method.GetBasename().compare(m_name) != 0) {
-  sc_list.RemoveContextAtIndex(i);
-  continue;
-}
-  } else {
-std::string qualified_name;
-llvm::StringRef anon_prefix("(anonymous namespace)");
-if (cpp_method.GetContext() == anon_prefix)
-  qualified_name = cpp_method.GetBasename().str();
-else
-  qualified_name = cpp_method.GetScopeQualifiedName();
-if (qualified_name != m_name.GetCString()) {
-  sc_list.RemoveContextAtIndex(i);
-  continue;
-}
-  }
+  if (Language *languagePlugin = Language::FindPlugin(sc.GetLanguage())) {
+if (languagePlugin->SymbolLookupHookShouldPruneResult(sc, *this)) {
+  sc_list.RemoveContextAtIndex(i);
+  continue;
 }
   }
   ++i;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 06c827c2543f40..c2b07bdc3a3c65 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/C

[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/110543

>From f1088d6f159363086cb040783106ebf18130f645 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 30 Sep 2024 13:33:35 -0400
Subject: [PATCH] [LLDB] Fix symbol breakpoint lookups for non-C-like languages

I'm developing the Mojo language, and some symbol breakpoints don't work 
because of two reasons that got fixed1:

- There's a prune step that operates on the assuption that the symbol is 
C-like. That was discarding lots of the Mojo breakpoints
- When finding functions for symbol breakpoints with eFunctionNameTypeFull, 
LLDB was only matching die.getMangledName() and not die.GetName(). The latter 
is the one useful for Mojo, because the former has some unreadable format in 
Mojo that is not exposed to the user. This shouldn't cause any regression for 
C-like languages, as the prune step would sanitize them anyway, but it's useful 
for languages like Mojo.
---
 lldb/include/lldb/Target/Language.h   | 16 
 lldb/source/Core/Module.cpp   | 32 ++--
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 38 +++
 .../Language/CPlusPlus/CPlusPlusLanguage.h|  3 ++
 .../Plugins/SymbolFile/DWARF/DWARFIndex.cpp   |  3 +-
 5 files changed, 63 insertions(+), 29 deletions(-)

diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index 41d8eeef469eab..f44f9fc08e7970 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -16,6 +16,7 @@
 #include 
 
 #include "lldb/Core/Highlighter.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/DataFormatters/DumpValueObjectOptions.h"
 #include "lldb/DataFormatters/FormatClasses.h"
@@ -379,6 +380,21 @@ class Language : public PluginInterface {
   /// Python uses \b except. Defaults to \b catch.
   virtual llvm::StringRef GetCatchKeyword() const { return "catch"; }
 
+  /// Method invoked by \a Module::LookupInfo::Prune used to filter out symbol
+  /// search results.
+  ///
+  /// \param[in] sc A symbol that passed the common symbol search lookup
+  ///   process.
+  /// \param[in] lookup_info The full lookup info.
+  ///
+  /// \return whether the given symbol should be discarded from the search
+  /// results.
+  virtual bool
+  SymbolLookupHookShouldPruneResult(const SymbolContext &sc,
+const Module::LookupInfo &lookup_info) {
+return false;
+  }
+
 protected:
   // Classes that inherit from Language can see and modify these
 
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 88cc957e91fac4..0cc21c61a3dfa7 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -787,40 +787,16 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
 }
   }
 
-  // If we have only full name matches we might have tried to set breakpoint on
-  // "func" and specified eFunctionNameTypeFull, but we might have found
-  // "a::func()", "a::b::func()", "c::func()", "func()" and "func". Only
-  // "func()" and "func" should end up matching.
   if (m_name_type_mask == eFunctionNameTypeFull) {
 SymbolContext sc;
 size_t i = start_idx;
 while (i < sc_list.GetSize()) {
   if (!sc_list.GetContextAtIndex(i, sc))
 break;
-  // Make sure the mangled and demangled names don't match before we try to
-  // pull anything out
-  ConstString mangled_name(sc.GetFunctionName(Mangled::ePreferMangled));
-  ConstString full_name(sc.GetFunctionName());
-  if (mangled_name != m_name && full_name != m_name) {
-CPlusPlusLanguage::MethodName cpp_method(full_name);
-if (cpp_method.IsValid()) {
-  if (cpp_method.GetContext().empty()) {
-if (cpp_method.GetBasename().compare(m_name) != 0) {
-  sc_list.RemoveContextAtIndex(i);
-  continue;
-}
-  } else {
-std::string qualified_name;
-llvm::StringRef anon_prefix("(anonymous namespace)");
-if (cpp_method.GetContext() == anon_prefix)
-  qualified_name = cpp_method.GetBasename().str();
-else
-  qualified_name = cpp_method.GetScopeQualifiedName();
-if (qualified_name != m_name.GetCString()) {
-  sc_list.RemoveContextAtIndex(i);
-  continue;
-}
-  }
+  if (Language *languagePlugin = Language::FindPlugin(sc.GetLanguage())) {
+if (languagePlugin->SymbolLookupHookShouldPruneResult(sc, *this)) {
+  sc_list.RemoveContextAtIndex(i);
+  continue;
 }
   }
   ++i;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 06c827c2543f40..a9fc0cb0f2d911 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/C

[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/110543

>From d3aa6a3726224c51dc838dd72fef40e9520fd8de Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 30 Sep 2024 13:33:35 -0400
Subject: [PATCH] [LLDB] Fix symbol breakpoint lookups for non-C-like languages

I'm developing the Mojo language, and some symbol breakpoints don't work 
because of two reasons that got fixed1:

- There's a prune step that operates on the assuption that the symbol is 
C-like. That was discarding lots of the Mojo breakpoints
- When finding functions for symbol breakpoints with eFunctionNameTypeFull, 
LLDB was only matching die.getMangledName() and not die.GetName(). The latter 
is the one useful for Mojo, because the former has some unreadable format in 
Mojo that is not exposed to the user. This shouldn't cause any regression for 
C-like languages, as the prune step would sanitize them anyway, but it's useful 
for languages like Mojo.
---
 lldb/include/lldb/Target/Language.h   | 12 ++
 lldb/source/Core/Module.cpp   | 32 ++--
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 38 +++
 .../Language/CPlusPlus/CPlusPlusLanguage.h|  3 ++
 .../Plugins/SymbolFile/DWARF/DWARFIndex.cpp   |  3 +-
 5 files changed, 59 insertions(+), 29 deletions(-)

diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index 41d8eeef469eab..84640bb21221f8 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -16,6 +16,7 @@
 #include 
 
 #include "lldb/Core/Highlighter.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/DataFormatters/DumpValueObjectOptions.h"
 #include "lldb/DataFormatters/FormatClasses.h"
@@ -379,6 +380,17 @@ class Language : public PluginInterface {
   /// Python uses \b except. Defaults to \b catch.
   virtual llvm::StringRef GetCatchKeyword() const { return "catch"; }
 
+  /// Method invoked by \a Module::LookupInfo::Prune used to filter out symbol
+  /// search results.
+  ///
+  /// \return whether the given symbol should be discarded from the search
+  /// returns.
+  virtual bool
+  SymbolLookupHookShouldPruneResult(const SymbolContext &sc,
+const Module::LookupInfo &lookup_info) {
+return false;
+  }
+
 protected:
   // Classes that inherit from Language can see and modify these
 
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 88cc957e91fac4..0cc21c61a3dfa7 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -787,40 +787,16 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
 }
   }
 
-  // If we have only full name matches we might have tried to set breakpoint on
-  // "func" and specified eFunctionNameTypeFull, but we might have found
-  // "a::func()", "a::b::func()", "c::func()", "func()" and "func". Only
-  // "func()" and "func" should end up matching.
   if (m_name_type_mask == eFunctionNameTypeFull) {
 SymbolContext sc;
 size_t i = start_idx;
 while (i < sc_list.GetSize()) {
   if (!sc_list.GetContextAtIndex(i, sc))
 break;
-  // Make sure the mangled and demangled names don't match before we try to
-  // pull anything out
-  ConstString mangled_name(sc.GetFunctionName(Mangled::ePreferMangled));
-  ConstString full_name(sc.GetFunctionName());
-  if (mangled_name != m_name && full_name != m_name) {
-CPlusPlusLanguage::MethodName cpp_method(full_name);
-if (cpp_method.IsValid()) {
-  if (cpp_method.GetContext().empty()) {
-if (cpp_method.GetBasename().compare(m_name) != 0) {
-  sc_list.RemoveContextAtIndex(i);
-  continue;
-}
-  } else {
-std::string qualified_name;
-llvm::StringRef anon_prefix("(anonymous namespace)");
-if (cpp_method.GetContext() == anon_prefix)
-  qualified_name = cpp_method.GetBasename().str();
-else
-  qualified_name = cpp_method.GetScopeQualifiedName();
-if (qualified_name != m_name.GetCString()) {
-  sc_list.RemoveContextAtIndex(i);
-  continue;
-}
-  }
+  if (Language *languagePlugin = Language::FindPlugin(sc.GetLanguage())) {
+if (languagePlugin->SymbolLookupHookShouldPruneResult(sc, *this)) {
+  sc_list.RemoveContextAtIndex(i);
+  continue;
 }
   }
   ++i;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 06c827c2543f40..c2b07bdc3a3c65 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1759,3 +1759,41 @@ bool CPlusPlusLanguage::GetFunctionDisplayName(
 
   return false;
 }
+
+bool CPlusPlusLanguage::Sy

[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/110543

>From dcc5c787a7c146942fed66da5df01ef5a4401744 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 30 Sep 2024 13:33:35 -0400
Subject: [PATCH] [LLDB] Fix symbol breakpoint lookups for non-C-like languages

I'm developing the Mojo language, and some symbol breakpoints don't work 
because of two reasons that got fixed1:

- There's a prune step that operates on the assuption that the symbol is 
C-like. That was discarding lots of the Mojo breakpoints
- When finding functions for symbol breakpoints with eFunctionNameTypeFull, 
LLDB was only matching die.getMangledName() and not die.GetName(). The latter 
is the one useful for Mojo, because the former has some unreadable format in 
Mojo that is not exposed to the user. This shouldn't cause any regression for 
C-like languages, as the prune step would sanitize them anyway, but it's useful 
for languages like Mojo.
---
 lldb/include/lldb/Target/Language.h   |  7 
 lldb/source/Core/Module.cpp   | 32 ++--
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 38 +++
 .../Language/CPlusPlus/CPlusPlusLanguage.h|  3 ++
 .../Plugins/SymbolFile/DWARF/DWARFIndex.cpp   |  3 +-
 5 files changed, 54 insertions(+), 29 deletions(-)

diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index 41d8eeef469eab..c815a073a5228f 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -16,6 +16,7 @@
 #include 
 
 #include "lldb/Core/Highlighter.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/DataFormatters/DumpValueObjectOptions.h"
 #include "lldb/DataFormatters/FormatClasses.h"
@@ -379,6 +380,12 @@ class Language : public PluginInterface {
   /// Python uses \b except. Defaults to \b catch.
   virtual llvm::StringRef GetCatchKeyword() const { return "catch"; }
 
+  virtual bool
+  SymbolLookupHookShouldPruneResult(const SymbolContext &sc,
+const Module::LookupInfo &lookup_info) {
+return false;
+  }
+
 protected:
   // Classes that inherit from Language can see and modify these
 
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 88cc957e91fac4..0cc21c61a3dfa7 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -787,40 +787,16 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
 }
   }
 
-  // If we have only full name matches we might have tried to set breakpoint on
-  // "func" and specified eFunctionNameTypeFull, but we might have found
-  // "a::func()", "a::b::func()", "c::func()", "func()" and "func". Only
-  // "func()" and "func" should end up matching.
   if (m_name_type_mask == eFunctionNameTypeFull) {
 SymbolContext sc;
 size_t i = start_idx;
 while (i < sc_list.GetSize()) {
   if (!sc_list.GetContextAtIndex(i, sc))
 break;
-  // Make sure the mangled and demangled names don't match before we try to
-  // pull anything out
-  ConstString mangled_name(sc.GetFunctionName(Mangled::ePreferMangled));
-  ConstString full_name(sc.GetFunctionName());
-  if (mangled_name != m_name && full_name != m_name) {
-CPlusPlusLanguage::MethodName cpp_method(full_name);
-if (cpp_method.IsValid()) {
-  if (cpp_method.GetContext().empty()) {
-if (cpp_method.GetBasename().compare(m_name) != 0) {
-  sc_list.RemoveContextAtIndex(i);
-  continue;
-}
-  } else {
-std::string qualified_name;
-llvm::StringRef anon_prefix("(anonymous namespace)");
-if (cpp_method.GetContext() == anon_prefix)
-  qualified_name = cpp_method.GetBasename().str();
-else
-  qualified_name = cpp_method.GetScopeQualifiedName();
-if (qualified_name != m_name.GetCString()) {
-  sc_list.RemoveContextAtIndex(i);
-  continue;
-}
-  }
+  if (Language *languagePlugin = Language::FindPlugin(sc.GetLanguage())) {
+if (languagePlugin->SymbolLookupHookShouldPruneResult(sc, *this)) {
+  sc_list.RemoveContextAtIndex(i);
+  continue;
 }
   }
   ++i;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 06c827c2543f40..c2b07bdc3a3c65 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1759,3 +1759,41 @@ bool CPlusPlusLanguage::GetFunctionDisplayName(
 
   return false;
 }
+
+bool CPlusPlusLanguage::SymbolLookupHookShouldPruneResult(
+const SymbolContext &sc, const Module::LookupInfo &lookup_info) {
+  // If we have only full name matches we might have tried to set breakpoint on
+  // "func" and sp

[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread Walter Erquinigo via lldb-commits


@@ -797,6 +797,10 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
 while (i < sc_list.GetSize()) {
   if (!sc_list.GetContextAtIndex(i, sc))
 break;
+  if (!lldb_private::Language::LanguageIsCFamily(sc.GetLanguage())) {

walter-erquinigo wrote:

What you say makes sense.
@jimingham , what about me moving the implementation of this second part of the 
Prune method (line 790 onwards) to Language plugins? I could then create the 
method 
```SymbolLookupPruneHook(SymbolContextList &sc_list, size_t start_idx, 
Module::LookupInfo &lookup_info, Module &module)```

That would be very convenient because I could implement this in my own language 
plugin for further refinements.

What do you think?

https://github.com/llvm/llvm-project/pull/110543
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread Walter Erquinigo via lldb-commits


@@ -24,10 +24,10 @@
 using namespace lldb;
 using namespace lldb_private;
 
-BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,

walter-erquinigo wrote:

Good catch, I didn't realize the formatter changes this file.

https://github.com/llvm/llvm-project/pull/110543
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo edited 
https://github.com/llvm/llvm-project/pull/110543
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/110543

I'm developing the Mojo language, and some symbol breakpoints don't work 
because of two reasons that got fixed1:

- There's a prune step that operates on the assuption that the symbol is 
C-like. That was discarding lots of the Mojo breakpoints
- When finding functions for symbol breakpoints with eFunctionNameTypeFull, 
LLDB was only matching die.getMangledName() and not die.GetName(). The latter 
is the one useful for Mojo, because the former has some unreadable format in 
Mojo that is not exposed to the user. This shouldn't cause any regression for 
C-like languages, as the prune step would sanitize them anyway, but it's useful 
for languages like Mojo.

>From 9ac2f9b2eb34e7495e60500ce9b90cc9370e8709 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 30 Sep 2024 13:33:35 -0400
Subject: [PATCH] [LLDB] Fix symbol breakpoint lookups for non-C-like languages

I'm developing the Mojo language, and some symbol breakpoints don't work 
because of two reasons that got fixed1:

- There's a prune step that operates on the assuption that the symbol is 
C-like. That was discarding lots of the Mojo breakpoints
- When finding functions for symbol breakpoints with eFunctionNameTypeFull, 
LLDB was only matching die.getMangledName() and not die.GetName(). The latter 
is the one useful for Mojo, because the former has some unreadable format in 
Mojo that is not exposed to the user. This shouldn't cause any regression for 
C-like languages, as the prune step would sanitize them anyway, but it's useful 
for languages like Mojo.
---
 lldb/source/Breakpoint/BreakpointResolverName.cpp  | 14 +++---
 lldb/source/Core/Module.cpp|  4 
 .../source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp |  3 ++-
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp 
b/lldb/source/Breakpoint/BreakpointResolverName.cpp
index 264638eb836dc6..77ddd86302cd1d 100644
--- a/lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -24,10 +24,10 @@
 using namespace lldb;
 using namespace lldb_private;
 
-BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,
-const char *name_cstr, FunctionNameType name_type_mask,
-LanguageType language, Breakpoint::MatchType type, lldb::addr_t offset,
-bool skip_prologue)
+BreakpointResolverName::BreakpointResolverName(
+const BreakpointSP &bkpt, const char *name_cstr,
+FunctionNameType name_type_mask, LanguageType language,
+Breakpoint::MatchType type, lldb::addr_t offset, bool skip_prologue)
 : BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
   m_match_type(type), m_language(language), m_skip_prologue(skip_prologue) 
{
   if (m_match_type == Breakpoint::Regexp) {
@@ -237,9 +237,9 @@ void BreakpointResolverName::AddNameLookup(ConstString name,
   if (Language *lang = Language::FindPlugin(m_language)) {
 add_variant_funcs(lang);
   } else {
-// Most likely m_language is eLanguageTypeUnknown. We check each language 
for
-// possible variants or more qualified names and create lookups for those 
as
-// well.
+// Most likely m_language is eLanguageTypeUnknown. We check each language
+// for possible variants or more qualified names and create lookups for
+// those as well.
 Language::ForEach(add_variant_funcs);
   }
 }
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 88cc957e91fac4..29b419e9969743 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -797,6 +797,10 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
 while (i < sc_list.GetSize()) {
   if (!sc_list.GetContextAtIndex(i, sc))
 break;
+  if (!lldb_private::Language::LanguageIsCFamily(sc.GetLanguage())) {
+++i;
+continue;
+  }
   // Make sure the mangled and demangled names don't match before we try to
   // pull anything out
   ConstString mangled_name(sc.GetFunctionName(Mangled::ePreferMangled));
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
index eafddbad03f57b..7bf53dce1b1b07 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
@@ -59,7 +59,8 @@ bool DWARFIndex::ProcessFunctionDIE(
 return true;
 
   // In case of a full match, we just insert everything we find.
-  if (name_type_mask & eFunctionNameTypeFull && die.GetMangledName() == name)
+  if (name_type_mask & eFunctionNameTypeFull &&
+  (die.GetMangledName() == name || die.GetName() == name))
 return callback(die);
 
   // If looking for ObjC selectors, we need to also check if the name is a

___
lldb-commits mailing list
lldb-commits@lists.llvm.org

[Lldb-commits] [lldb] [lldb][docs] Resurrect the information on adding a new language (PR #109427)

2024-09-23 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

beautiful. 

https://github.com/llvm/llvm-project/pull/109427
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Simplify `readMemory` (PR #109485)

2024-09-22 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

looks great! 

https://github.com/llvm/llvm-project/pull/109485
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap][docs] Improve README (PR #109266)

2024-09-20 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


https://github.com/llvm/llvm-project/pull/109266
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add feature to remember last non-empty expression. (PR #107485)

2024-09-20 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

lgtm!

https://github.com/llvm/llvm-project/pull/107485
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][lldb-dap][vscode-lldb] Add Environment configuration for the lldb-dap process (PR #108948)

2024-09-17 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


https://github.com/llvm/llvm-project/pull/108948
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Implement value locations for function pointers (PR #104589)

2024-09-17 Thread Walter Erquinigo via lldb-commits


@@ -1390,7 +1414,10 @@ llvm::json::Value CreateVariable(lldb::SBValue v, 
int64_t var_ref,
 object.try_emplace("variablesReference", 0);
 
   if (v.GetDeclaration().IsValid())
-object.try_emplace("declarationLocationReference", var_ref);
+object.try_emplace("declarationLocationReference", var_ref << 1);
+
+  if (HasValueLocation(v))
+object.try_emplace("valueLocationReference", (var_ref << 1) | 1);

walter-erquinigo wrote:

Please create helper functions that do these bitwise manipulations. That would 
make it more obvious what's going on. E.g. varRefToDeclLocationRef and 
varRefToValueLocationRef

https://github.com/llvm/llvm-project/pull/104589
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Implement value locations for function pointers (PR #104589)

2024-09-17 Thread Walter Erquinigo via lldb-commits


@@ -4087,32 +4114,64 @@ void request_variables(const llvm::json::Object 
&request) {
 void request_locations(const llvm::json::Object &request) {
   llvm::json::Object response;
   FillResponse(request, response);
-  auto arguments = request.getObject("arguments");
+  auto *arguments = request.getObject("arguments");

walter-erquinigo wrote:

please remove the auto here. An explicit type would make this more readable

https://github.com/llvm/llvm-project/pull/104589
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Implement value locations for function pointers (PR #104589)

2024-09-17 Thread Walter Erquinigo via lldb-commits


@@ -1611,16 +1624,17 @@ void request_evaluate(const llvm::json::Object 
&request) {
   VariableDescription desc(value);
   EmplaceSafeString(body, "result", desc.GetResult(context));
   EmplaceSafeString(body, "type", desc.display_type_name);
-  if (value.MightHaveChildren()) {
-auto variableReference = g_dap.variables.InsertVariable(
-value, /*is_permanent=*/context == "repl");
-body.try_emplace("variablesReference", variableReference);
-  } else {
+  auto var_ref = g_dap.variables.InsertVariable(
+  value, /*is_permanent=*/context == "repl");

walter-erquinigo wrote:

Instead of unconditionally creating the var_ref, why don't you create a small 
lambda that creates it just when needed (lines 1630 and 1637)?

https://github.com/llvm/llvm-project/pull/104589
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][intel-pt] Fix build error on conversion from llvm::Error to Status::FromError (PR #108719)

2024-09-16 Thread Walter Erquinigo via lldb-commits


@@ -78,7 +78,7 @@ bool CommandObjectThreadTraceStartIntelPT::DoExecuteOnThreads(
 llvm::ArrayRef tids) {
   if (Error err = m_trace.Start(tids, m_options.m_ipt_trace_size,
 m_options.m_enable_tsc, 
m_options.m_psb_period))
-result.SetError(Status(std::move(err)));
+result.SetError(Status::FromError(std::move(err)));

walter-erquinigo wrote:

just make sure that you really need to invoke std::move. It's possible that the 
compiler can do that on its own and that you don't need the explicit std::move

https://github.com/llvm/llvm-project/pull/108719
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][intel-pt] Fix build error on conversion from llvm::Error to Status::FromError (PR #108719)

2024-09-16 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


https://github.com/llvm/llvm-project/pull/108719
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add feature to remember last non-empty expression. (PR #107485)

2024-09-14 Thread Walter Erquinigo via lldb-commits


@@ -1364,8 +1364,14 @@ void request_evaluate(const llvm::json::Object &request) 
{
   std::string expression = GetString(arguments, "expression").str();
   llvm::StringRef context = GetString(arguments, "context");
 
-  if (context == "repl" && g_dap.DetectExpressionContext(frame, expression) ==
-   ExpressionContext::Command) {
+  if (context == "repl" &&
+  (expression.empty() ?
+   g_dap.last_nonempty_var_expression.empty() :
+   g_dap.DetectExpressionContext(frame, expression) ==

walter-erquinigo wrote:

it's hard to read this. Please move this ternary check into another variable 
with a good name.

https://github.com/llvm/llvm-project/pull/107485
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add feature to remember last non-empty expression. (PR #107485)

2024-09-14 Thread Walter Erquinigo via lldb-commits


@@ -1376,6 +1382,16 @@ void request_evaluate(const llvm::json::Object &request) 
{
 EmplaceSafeString(body, "result", result);
 body.try_emplace("variablesReference", (int64_t)0);
   } else {
+if (context == "repl") {
+  // If the expression is empty and the last expression was for a
+  // variable, set the expression to the previous expression (repeat the
+  // evaluation); otherwise save the current non-empty expression for the
+  // next (possibly empty) variable expression.
+  if (expression.empty())
+expression = g_dap.last_nonempty_var_expression;

walter-erquinigo wrote:

IIUC, this has the following flow in the debug console:

- You send a command (non-var expression) FOO
- You send a var expression VAR
- You send empty text -> then FOO repeats

If that understanding is correct, that would lead to a confusing behavior. I 
think it's better to repeat only if the previous input was exactly a command.

https://github.com/llvm/llvm-project/pull/107485
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Make env and source map dictionaries #95137 (PR #106919)

2024-09-13 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


https://github.com/llvm/llvm-project/pull/106919
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add feature to remember last non-empty expression. (PR #107485)

2024-09-13 Thread Walter Erquinigo via lldb-commits


@@ -1376,6 +1382,16 @@ void request_evaluate(const llvm::json::Object &request) 
{
 EmplaceSafeString(body, "result", result);
 body.try_emplace("variablesReference", (int64_t)0);
   } else {
+if (context != "hover") {

walter-erquinigo wrote:

yeah, this feature should be limited to the repl Debug Console

https://github.com/llvm/llvm-project/pull/107485
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add feature to remember last non-empty expression. (PR #107485)

2024-09-12 Thread Walter Erquinigo via lldb-commits


@@ -1364,8 +1364,20 @@ void request_evaluate(const llvm::json::Object &request) 
{
   std::string expression = GetString(arguments, "expression").str();
   llvm::StringRef context = GetString(arguments, "context");
 
-  if (context == "repl" && g_dap.DetectExpressionContext(frame, expression) ==
-   ExpressionContext::Command) {
+  if (context == "repl" &&
+  ((!expression.empty() &&
+   g_dap.DetectExpressionContext(frame, expression) ==
+   ExpressionContext::Command) ||
+   (expression.empty() &&
+g_dap.last_expression_context == ExpressionContext::Command))) {
+// If the current expression is empty, and the last expression context was
+// for a  command, pass the empty expression along to the

walter-erquinigo wrote:

```suggestion
// for a command, pass the empty expression along to the
```

https://github.com/llvm/llvm-project/pull/107485
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add feature to remember last non-empty expression. (PR #107485)

2024-09-12 Thread Walter Erquinigo via lldb-commits


@@ -1364,8 +1364,20 @@ void request_evaluate(const llvm::json::Object &request) 
{
   std::string expression = GetString(arguments, "expression").str();
   llvm::StringRef context = GetString(arguments, "context");
 
-  if (context == "repl" && g_dap.DetectExpressionContext(frame, expression) ==
-   ExpressionContext::Command) {
+  if (context == "repl" &&
+  ((!expression.empty() &&
+   g_dap.DetectExpressionContext(frame, expression) ==
+   ExpressionContext::Command) ||
+   (expression.empty() &&
+g_dap.last_expression_context == ExpressionContext::Command))) {
+// If the current expression is empty, and the last expression context was
+// for a  command, pass the empty expression along to the
+// CommandInterpreter, to repeat the previous command. Also set the
+// expression context properly for the next (possibly empty) expression.
+g_dap.last_expression_context = ExpressionContext::Command;
+// Since the current expression context is not for a variable, clear the
+// last_nonempty_var_expression field.
+g_dap.last_nonempty_var_expression.clear();

walter-erquinigo wrote:

It would be cleaner if this gets stored in a sort of discriminated union:

LastExpressionInfo:
  - Case Command (no metadata)  
  - Case Var (expression)

this way it's easier to maintain these two variables correctly in sync

https://github.com/llvm/llvm-project/pull/107485
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add feature to remember last non-empty expression. (PR #107485)

2024-09-12 Thread Walter Erquinigo via lldb-commits


@@ -191,6 +198,14 @@ def run_test_evaluate_expressions(
 self.continue_to_next_stop()
 self.assertEvaluate("my_bool_vec", "size=2")
 
+# Test memory read, especially with 'empty' repeat commands.
+if context == "repl":
+  self.continue_to_next_stop()
+  self.assertEvaluate("memory read &my_ints",
+  ".*00 00 00 00 02 00 00 00 04 00 00 00 06 00 00 
00.*\n.*08 00 00 00 0a 00 00 00 0c 00 00 00 0e 00 00 00.*\n")
+  self.assertEvaluate("",
+  ".*10 00 00 00 12 00 00 00 14 00 00 00 16 00 00 
00.*\n.*18 00 00 00 1a 00 00 00 1c 00 00 00.*\n")

walter-erquinigo wrote:

I don't think that this will reliably be the same across systems. Something 
that would be better would be to read from an `uint8_t` array and just read one 
byte at a time. That should work anywhere.

https://github.com/llvm/llvm-project/pull/107485
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Deflake TestDAP_attach (PR #108226)

2024-09-11 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

+1

https://github.com/llvm/llvm-project/pull/108226
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-dap] Added readMemory and WriteMemory, var type correction (PR #108036)

2024-09-11 Thread Walter Erquinigo via lldb-commits


@@ -4332,6 +4339,232 @@ void request_setInstructionBreakpoints(const 
llvm::json::Object &request) {
   g_dap.SendJSON(llvm::json::Value(std::move(response)));
 }
 
+// "ReadMemoryRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "Reads bytes from memory at the provided location.\n
+// Clients should only call this request if the corresponding capability
+// `supportsReadMemoryRequest` is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "readMemory" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/ReadMemoryArguments"
+//   }
+// },
+// "required": [ "command", "arguments" ]
+//   }]
+// },
+// "ReadMemoryArguments": {
+//   "type": "object",
+//   "description": "Arguments for `readMemory` request.",
+//   "properties": {
+// "memoryReference": {
+//   "type": "string",
+//   "description": "Memory reference to the base location from which data
+//   should be read."
+// },
+// "offset": {
+//   "type": "integer",
+//   "description": "Offset (in bytes) to be applied to the reference
+//   location before reading data. Can be negative."
+// },
+// "count": {
+//   "type": "integer",
+//   "description": "Number of bytes to read at the specified location and
+//   offset."
+// }
+//   },
+//   "required": [ "memoryReference", "count" ]
+// },
+// "ReadMemoryResponse": {
+//   "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to `readMemory` request.",
+// "properties": {
+//   "body": {
+// "type": "object",
+// "properties": {
+//   "address": {
+// "type": "string",
+// "description": "The address of the first byte of data returned.
+// \nTreated as a hex value if prefixed with `0x`, or as a decimal
+// value otherwise."
+//   },
+//   "unreadableBytes": {
+// "type": "integer",
+// "description": "The number of unreadable bytes encountered after
+// the last successfully read byte.\nThis can be used to determine
+// the number of bytes that should be skipped before a subsequent
+// `readMemory` request succeeds."
+//   },
+//   "data": {
+// "type": "string",
+// "description": "The bytes read from memory, encoded using
+// base64. If the decoded length of `data` is less than the
+// requested `count` in the original `readMemory` request, and
+// `unreadableBytes` is zero or omitted, then the client should
+// assume it's reached the end of readable memory."
+//   }
+// },
+// "required": [ "address" ]
+//   }
+// }
+//   }]
+// },
+void request_readMemory(const llvm::json::Object &request) {
+  llvm::json::Object response;
+  llvm::json::Array response_readMemory;
+  llvm::json::Object body;
+  lldb::SBError error;
+  FillResponse(request, response);
+
+  auto arguments = request.getObject("arguments");
+  llvm::StringRef memoryReference = GetString(arguments, "memoryReference");
+  const size_t count = GetUnsigned(arguments, "count", 0);
+  const auto offset = GetSigned(arguments, "offset", 0);
+
+  lldb::addr_t address;
+  memoryReference.getAsInteger(0, address);
+  lldb::addr_t address_offset = address + offset;
+  // address as string
+  std::string address_offset_str(std::to_string(address_offset));
+
+  // make storage for the memory to read
+  //  need to use a vector because VC++ 2019 errors out on char buffer[count]
+  std::vector buffer(count);
+
+  // read the memory add to storage
+  lldb::SBProcess process = g_dap.target.GetProcess();
+  size_t countRead =
+  process.ReadMemory(address_offset, buffer.data(), count, error);
+  const llvm::StringRef inputBytes = {buffer.data(), countRead};
+  // return the read memory in base64
+  std::string data = llvm::encodeBase64(inputBytes);
+
+  // body: address, data? in spec formats
+  body.try_emplace("address", std::move(address_offset_str));
+  body.try_emplace("data", std::move(data));
+
+  response.try_emplace("body", std::move(body));
+  g_dap.SendJSON(llvm::json::Value(std::move(response)));
+}
+
+// "WriteMemoryRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "Writes bytes to memory at the provided location.\n
+// Clients should only call this request if the corresponding
+// capability `supportsWriteMemoryRequest` is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "writeMemory" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/WriteMemoryArguments"
+//  

[Lldb-commits] [lldb] [lldb][lldb-dap] Added readMemory and WriteMemory, var type correction (PR #108036)

2024-09-11 Thread Walter Erquinigo via lldb-commits


@@ -4332,6 +4339,232 @@ void request_setInstructionBreakpoints(const 
llvm::json::Object &request) {
   g_dap.SendJSON(llvm::json::Value(std::move(response)));
 }
 
+// "ReadMemoryRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "Reads bytes from memory at the provided location.\n
+// Clients should only call this request if the corresponding capability
+// `supportsReadMemoryRequest` is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "readMemory" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/ReadMemoryArguments"
+//   }
+// },
+// "required": [ "command", "arguments" ]
+//   }]
+// },
+// "ReadMemoryArguments": {
+//   "type": "object",
+//   "description": "Arguments for `readMemory` request.",
+//   "properties": {
+// "memoryReference": {
+//   "type": "string",
+//   "description": "Memory reference to the base location from which data
+//   should be read."
+// },
+// "offset": {
+//   "type": "integer",
+//   "description": "Offset (in bytes) to be applied to the reference
+//   location before reading data. Can be negative."
+// },
+// "count": {
+//   "type": "integer",
+//   "description": "Number of bytes to read at the specified location and
+//   offset."
+// }
+//   },
+//   "required": [ "memoryReference", "count" ]
+// },
+// "ReadMemoryResponse": {
+//   "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to `readMemory` request.",
+// "properties": {
+//   "body": {
+// "type": "object",
+// "properties": {
+//   "address": {
+// "type": "string",
+// "description": "The address of the first byte of data returned.
+// \nTreated as a hex value if prefixed with `0x`, or as a decimal
+// value otherwise."
+//   },
+//   "unreadableBytes": {
+// "type": "integer",
+// "description": "The number of unreadable bytes encountered after
+// the last successfully read byte.\nThis can be used to determine
+// the number of bytes that should be skipped before a subsequent
+// `readMemory` request succeeds."
+//   },
+//   "data": {
+// "type": "string",
+// "description": "The bytes read from memory, encoded using
+// base64. If the decoded length of `data` is less than the
+// requested `count` in the original `readMemory` request, and
+// `unreadableBytes` is zero or omitted, then the client should
+// assume it's reached the end of readable memory."
+//   }
+// },
+// "required": [ "address" ]
+//   }
+// }
+//   }]
+// },
+void request_readMemory(const llvm::json::Object &request) {
+  llvm::json::Object response;
+  llvm::json::Array response_readMemory;
+  llvm::json::Object body;
+  lldb::SBError error;
+  FillResponse(request, response);
+
+  auto arguments = request.getObject("arguments");
+  llvm::StringRef memoryReference = GetString(arguments, "memoryReference");
+  const size_t count = GetUnsigned(arguments, "count", 0);
+  const auto offset = GetSigned(arguments, "offset", 0);
+
+  lldb::addr_t address;
+  memoryReference.getAsInteger(0, address);
+  lldb::addr_t address_offset = address + offset;
+  // address as string
+  std::string address_offset_str(std::to_string(address_offset));
+
+  // make storage for the memory to read
+  //  need to use a vector because VC++ 2019 errors out on char buffer[count]
+  std::vector buffer(count);
+
+  // read the memory add to storage
+  lldb::SBProcess process = g_dap.target.GetProcess();
+  size_t countRead =
+  process.ReadMemory(address_offset, buffer.data(), count, error);
+  const llvm::StringRef inputBytes = {buffer.data(), countRead};
+  // return the read memory in base64
+  std::string data = llvm::encodeBase64(inputBytes);
+
+  // body: address, data? in spec formats
+  body.try_emplace("address", std::move(address_offset_str));
+  body.try_emplace("data", std::move(data));
+
+  response.try_emplace("body", std::move(body));
+  g_dap.SendJSON(llvm::json::Value(std::move(response)));
+}
+
+// "WriteMemoryRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "Writes bytes to memory at the provided location.\n
+// Clients should only call this request if the corresponding
+// capability `supportsWriteMemoryRequest` is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "writeMemory" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/WriteMemoryArguments"
+//  

[Lldb-commits] [lldb] [lldb][lldb-dap] Added readMemory and WriteMemory, var type correction (PR #108036)

2024-09-11 Thread Walter Erquinigo via lldb-commits


@@ -4332,6 +4339,232 @@ void request_setInstructionBreakpoints(const 
llvm::json::Object &request) {
   g_dap.SendJSON(llvm::json::Value(std::move(response)));
 }
 
+// "ReadMemoryRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "Reads bytes from memory at the provided location.\n
+// Clients should only call this request if the corresponding capability
+// `supportsReadMemoryRequest` is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "readMemory" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/ReadMemoryArguments"
+//   }
+// },
+// "required": [ "command", "arguments" ]
+//   }]
+// },
+// "ReadMemoryArguments": {
+//   "type": "object",
+//   "description": "Arguments for `readMemory` request.",
+//   "properties": {
+// "memoryReference": {
+//   "type": "string",
+//   "description": "Memory reference to the base location from which data
+//   should be read."
+// },
+// "offset": {
+//   "type": "integer",
+//   "description": "Offset (in bytes) to be applied to the reference
+//   location before reading data. Can be negative."
+// },
+// "count": {
+//   "type": "integer",
+//   "description": "Number of bytes to read at the specified location and
+//   offset."
+// }
+//   },
+//   "required": [ "memoryReference", "count" ]
+// },
+// "ReadMemoryResponse": {
+//   "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to `readMemory` request.",
+// "properties": {
+//   "body": {
+// "type": "object",
+// "properties": {
+//   "address": {
+// "type": "string",
+// "description": "The address of the first byte of data returned.
+// \nTreated as a hex value if prefixed with `0x`, or as a decimal
+// value otherwise."
+//   },
+//   "unreadableBytes": {
+// "type": "integer",
+// "description": "The number of unreadable bytes encountered after
+// the last successfully read byte.\nThis can be used to determine
+// the number of bytes that should be skipped before a subsequent
+// `readMemory` request succeeds."
+//   },
+//   "data": {
+// "type": "string",
+// "description": "The bytes read from memory, encoded using
+// base64. If the decoded length of `data` is less than the
+// requested `count` in the original `readMemory` request, and
+// `unreadableBytes` is zero or omitted, then the client should
+// assume it's reached the end of readable memory."
+//   }
+// },
+// "required": [ "address" ]
+//   }
+// }
+//   }]
+// },
+void request_readMemory(const llvm::json::Object &request) {
+  llvm::json::Object response;
+  llvm::json::Array response_readMemory;
+  llvm::json::Object body;
+  lldb::SBError error;
+  FillResponse(request, response);
+
+  auto arguments = request.getObject("arguments");
+  llvm::StringRef memoryReference = GetString(arguments, "memoryReference");
+  const size_t count = GetUnsigned(arguments, "count", 0);
+  const auto offset = GetSigned(arguments, "offset", 0);
+
+  lldb::addr_t address;
+  memoryReference.getAsInteger(0, address);
+  lldb::addr_t address_offset = address + offset;
+  // address as string
+  std::string address_offset_str(std::to_string(address_offset));
+
+  // make storage for the memory to read
+  //  need to use a vector because VC++ 2019 errors out on char buffer[count]
+  std::vector buffer(count);
+
+  // read the memory add to storage
+  lldb::SBProcess process = g_dap.target.GetProcess();
+  size_t countRead =
+  process.ReadMemory(address_offset, buffer.data(), count, error);
+  const llvm::StringRef inputBytes = {buffer.data(), countRead};
+  // return the read memory in base64
+  std::string data = llvm::encodeBase64(inputBytes);
+
+  // body: address, data? in spec formats
+  body.try_emplace("address", std::move(address_offset_str));
+  body.try_emplace("data", std::move(data));
+
+  response.try_emplace("body", std::move(body));
+  g_dap.SendJSON(llvm::json::Value(std::move(response)));
+}
+
+// "WriteMemoryRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "Writes bytes to memory at the provided location.\n
+// Clients should only call this request if the corresponding
+// capability `supportsWriteMemoryRequest` is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "writeMemory" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/WriteMemoryArguments"
+//  

[Lldb-commits] [lldb] [lldb][lldb-dap] Added readMemory and WriteMemory, var type correction (PR #108036)

2024-09-11 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo edited 
https://github.com/llvm/llvm-project/pull/108036
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-dap] Added readMemory and WriteMemory, var type correction (PR #108036)

2024-09-11 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo requested changes to this pull request.

Thanks for working on this.
Could you please write some tests?

https://github.com/llvm/llvm-project/pull/108036
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add feature to remember last non-empty expression. (PR #107485)

2024-09-10 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo edited 
https://github.com/llvm/llvm-project/pull/107485
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add feature to remember last non-empty expression. (PR #107485)

2024-09-10 Thread Walter Erquinigo via lldb-commits


@@ -60,7 +60,10 @@ def run_test_evaluate_expressions(
 
 # Expressions at breakpoint 1, which is in main
 self.assertEvaluate("var1", "20")
+# Empty expression should equate to the previous expression.

walter-erquinigo wrote:

Please add a test that uses `memory read` to make sure that two different 
memory read invocations give different valid results

https://github.com/llvm/llvm-project/pull/107485
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add feature to remember last non-empty expression. (PR #107485)

2024-09-10 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo requested changes to this pull request.

 Thanks for working on this!
 I second all that Pavel said.

https://github.com/llvm/llvm-project/pull/107485
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Make env and source map dictionaries #95137 (PR #106919)

2024-09-10 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/106919
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Make env and source map dictionaries #95137 (PR #106919)

2024-09-10 Thread Walter Erquinigo via lldb-commits


@@ -1370,13 +1395,16 @@ CreateRunInTerminalReverseRequest(const 
llvm::json::Object &launch_request,
   if (!cwd.empty())
 run_in_terminal_args.try_emplace("cwd", cwd);
 
-  // We need to convert the input list of environments variables into a
-  // dictionary
-  std::vector envs = GetStrings(launch_request_arguments, "env");
+  std::unordered_map envMap =
+  GetStringMap(*launch_request_arguments, "env");

walter-erquinigo wrote:

You are completely dropping for support for an array-based env list, and we 
can't do this because we'd be breaking tons of launch.json configs. You need to 
effectively support both formats: a map and an array. Convert `GetStringMap` 
into `GetEnv` that takes into account both formats.

https://github.com/llvm/llvm-project/pull/106919
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add: show return value on step out (PR #106907)

2024-09-10 Thread Walter Erquinigo via lldb-commits


@@ -3801,6 +3801,17 @@ void request_variables(const llvm::json::Object 
&request) {
   variable_name_counts[GetNonNullVariableName(variable)]++;
 }
 
+// Show return value if there is any ( in the top frame )
+auto process = g_dap.target.GetProcess();
+auto selectedThread = process.GetSelectedThread();
+lldb::SBValue stopReturnValue = selectedThread.GetStopReturnValue();
+if (stopReturnValue.IsValid() &&
+(selectedThread.GetSelectedFrame().GetFrameID() == 0)) {
+  auto renamedReturnValue = stopReturnValue.Clone("(Return Value)");
+  variables.emplace_back(
+  CreateVariable(renamedReturnValue, 0, UINT64_MAX, hex, false));

walter-erquinigo wrote:

you need to change this. You are passing `variablesReference = 0`, which means 
that if this variable is structured (i.e. it has children), then the user won't 
be able to look into it.

A little bit below this point, there's some code that handles that with

```
int64_t var_ref = 0;
  if (variable.MightHaveChildren() || variable.IsSynthetic()) {
var_ref = g_dap.variables.InsertExpandableVariable(
variable, /*is_permanent=*/false);
  }
variables.emplace_back(CreateVariable(
  variable, var_ref, var_ref != 0 ? var_ref : UINT64_MAX, hex,
  variable_name_counts[GetNonNullVariableName(variable)] > 1));
```
 
 You should be able to refactor out that code and use it for both cases.
Something else that you need to be aware of is that this function has an start 
index and end index, which gets used just below. This is used for paging.
You need to define an index for the return value whenever it's available and do 
the proper offset calculations for the regular variables. I suggest that this 
return value is index 0 so that it appears first.

Besides all of that, please create a test.

And finally, thanks for working on this. I've wanted this feature for so long.

https://github.com/llvm/llvm-project/pull/106907
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add: show return value on step out (PR #106907)

2024-09-10 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/106907
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Finish implementing support for DW_FORM_data16 (PR #106799)

2024-08-30 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo edited 
https://github.com/llvm/llvm-project/pull/106799
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Fix implementing support for DW_FORM_data16 (PR #106799)

2024-08-30 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/106799

This FORM already has support within LLDB to be parsed as a 16-byte
BLOCK, and all that is left to properly support it in the DWARFParser is
to add it to some enums.

With this, I can debug programs that use libstdc++.so.6.0.33 built with
GCC.

Sadly, I haven't figured out a good way to test this.


>From 07ca931aac5fd6e777fbf57b9a838fa6e500160b Mon Sep 17 00:00:00 2001
From: Walter Erquinigo 
Date: Fri, 30 Aug 2024 21:14:43 +
Subject: [PATCH] [LLDB] Fix implementing support for DW_FORM_data16

This FORM already has support within LLDB to be parsed as a 16-byte
BLOCK, and all that is left to properly support it in the DWARFParser is
to add it to some enums.

With this, I can debug programs that use libstdc++.so.6.0.33 built with
GCC.

Sadly, I haven't figured out a good way to test this.
---
 lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
index e1f73f1997e369..e1fcbda469f16d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -306,6 +306,11 @@ bool DWARFFormValue::SkipValue(dw_form_t form,
   *offset_ptr += 8;
   return true;
 
+// 16 byte values
+case DW_FORM_data16:
+  *offset_ptr += 16;
+  return true;
+
 // signed or unsigned LEB 128 values
 case DW_FORM_addrx:
 case DW_FORM_loclistx:
@@ -578,6 +583,7 @@ bool DWARFFormValue::IsBlockForm(const dw_form_t form) {
   case DW_FORM_block1:
   case DW_FORM_block2:
   case DW_FORM_block4:
+  case DW_FORM_data16:
 return true;
   default:
 return false;
@@ -611,6 +617,7 @@ bool DWARFFormValue::FormIsSupported(dw_form_t form) {
 case DW_FORM_data2:
 case DW_FORM_data4:
 case DW_FORM_data8:
+case DW_FORM_data16:
 case DW_FORM_string:
 case DW_FORM_block:
 case DW_FORM_block1:

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


[Lldb-commits] [lldb] Revert "[LLDB][DWARF] Add an option to silence unsupported DW_FORM warnings" (PR #106765)

2024-08-30 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo closed 
https://github.com/llvm/llvm-project/pull/106765
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][DWARF] Add an option to silence unsupported DW_FORM warnings (PR #106609)

2024-08-30 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

Revert commit: https://github.com/llvm/llvm-project/pull/106765

https://github.com/llvm/llvm-project/pull/106609
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Revert "[LLDB][DWARF] Add an option to silence unsupported DW_FORM warnings" (PR #106765)

2024-08-30 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/106765

Reverts llvm/llvm-project#106609

>From c6ff3f00afa70a47853af3e420aa8a99f76db3a9 Mon Sep 17 00:00:00 2001
From: Walter Erquinigo 
Date: Fri, 30 Aug 2024 13:17:47 -0400
Subject: [PATCH] =?UTF-8?q?Revert=20"[LLDB][DWARF]=20Add=20an=20option=20t?=
 =?UTF-8?q?o=20silence=20unsupported=20DW=5FFORM=20warnings=20(=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit 9aa25b8c15c99d8e717121837a2559801e311e2d.
---
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 30 +++
 .../DWARF/SymbolFileDWARFProperties.td|  4 ---
 2 files changed, 11 insertions(+), 23 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 2af6dc880842a4..ff44329d081caa 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -87,7 +87,7 @@
 #include 
 #include 
 
-// #define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN
+//#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN
 
 #ifdef ENABLE_DEBUG_PRINTF
 #include 
@@ -129,11 +129,6 @@ class PluginProperties : public Properties {
   bool IgnoreFileIndexes() const {
 return GetPropertyAtIndexAs(ePropertyIgnoreIndexes, false);
   }
-
-  bool EmitUnsupportedDWFormValueWarning() const {
-return GetPropertyAtIndexAs(
-ePropertyEmitUnsupportedDWFormValueWarning, true);
-  }
 };
 
 } // namespace
@@ -629,14 +624,12 @@ uint32_t SymbolFileDWARF::CalculateAbilities() {
   llvm::DWARFDebugAbbrev *abbrev = DebugAbbrev();
   std::set unsupported_forms = GetUnsupportedForms(abbrev);
   if (!unsupported_forms.empty()) {
-if (GetGlobalPluginProperties().EmitUnsupportedDWFormValueWarning()) {
-  StreamString error;
-  error.Printf("unsupported DW_FORM value%s:",
-   unsupported_forms.size() > 1 ? "s" : "");
-  for (auto form : unsupported_forms)
-error.Printf(" %#x", form);
-  m_objfile_sp->GetModule()->ReportWarning("{0}", error.GetString());
-}
+StreamString error;
+error.Printf("unsupported DW_FORM value%s:",
+ unsupported_forms.size() > 1 ? "s" : "");
+for (auto form : unsupported_forms)
+  error.Printf(" %#x", form);
+m_objfile_sp->GetModule()->ReportWarning("{0}", error.GetString());
 return 0;
   }
 
@@ -1777,17 +1770,16 @@ SymbolFileDWARF 
*SymbolFileDWARF::GetDIERefSymbolFile(const DIERef &die_ref) {
 return this;
 
   if (file_index) {
-// We have a SymbolFileDWARFDebugMap, so let it find the right file
+  // We have a SymbolFileDWARFDebugMap, so let it find the right file
 if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile())
   return debug_map->GetSymbolFileByOSOIndex(*file_index);
-
+
 // Handle the .dwp file case correctly
 if (*file_index == DIERef::k_file_index_mask)
   return GetDwpSymbolFile().get(); // DWP case
 
 // Handle the .dwo file case correctly
-return DebugInfo()
-.GetUnitAtIndex(*die_ref.file_index())
+return DebugInfo().GetUnitAtIndex(*die_ref.file_index())
 ->GetDwoSymbolFile(); // DWO case
   }
   return this;
@@ -3629,7 +3621,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const 
SymbolContext &sc,
 lldb::addr_t location_DW_OP_addr = LLDB_INVALID_ADDRESS;
 if (!location_is_const_value_data) {
   bool op_error = false;
-  const DWARFExpression *location = location_list.GetAlwaysValidExpr();
+  const DWARFExpression* location = location_list.GetAlwaysValidExpr();
   if (location)
 location_DW_OP_addr =
 location->GetLocation_DW_OP_addr(location_form.GetUnit(), 
op_error);
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td
index 0f980a514b6720..2f1ce88808b763 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td
@@ -5,8 +5,4 @@ let Definition = "symbolfiledwarf" in {
 Global,
 DefaultFalse,
 Desc<"Ignore indexes present in the object files and always index DWARF 
manually.">;
-  def EmitUnsupportedDWFormValueWarning: 
Property<"emit-unsupported-dwform-value", "Boolean">,
-Global,
-DefaultTrue,
-Desc<"Emit warnings about unsupported DW_Form values.">;
 }

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


[Lldb-commits] [lldb] [LLDB][DWARF] Add an option to silence unsupported DW_FORM warnings (PR #106609)

2024-08-30 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

@clayborg , sure!

https://github.com/llvm/llvm-project/pull/106609
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


  1   2   3   4   5   6   7   8   9   10   >