[Lldb-commits] [lldb] r346099 - Update framework-header-fix to force system sed

2018-11-04 Thread Dave Lee via lldb-commits
Author: kastiglione
Date: Sun Nov  4 07:55:28 2018
New Revision: 346099

URL: http://llvm.org/viewvc/llvm-project?rev=346099&view=rev
Log:
Update framework-header-fix to force system sed

Summary:
There are 2 changes here:

1. Use system sed instead of the sed found in the user's path. This
 fixes this script in the case the user has gnu-sed in their $PATH before
 bsd sed since `-i ''` isn't compatible and you need `-i` instead.

2. `set -e` in this script so it fails as soon as one of these commands
 fail instead of throwing errors for each file if they fail

Since this is only ran on macOS, and we're already using this
absolute path below, this seems like a safe addition

Reviewers: kastiglione, beanz

Reviewed By: kastiglione

Subscribers: lldb-commits

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

Modified:
lldb/trunk/scripts/framework-header-fix.sh

Modified: lldb/trunk/scripts/framework-header-fix.sh
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/framework-header-fix.sh?rev=346099&r1=346098&r2=346099&view=diff
==
--- lldb/trunk/scripts/framework-header-fix.sh (original)
+++ lldb/trunk/scripts/framework-header-fix.sh Sun Nov  4 07:55:28 2018
@@ -1,14 +1,17 @@
 #!/bin/sh
 # Usage: framework-header-fix.sh  
+
+set -e
+
 for file in `find $1 -name "*.h"`
 do
-  sed -i.bak 's/\(#include\)[ ]*"lldb\/\(API\/\)\{0,1\}\(.*\)"/\1 
/1' "$file"
-  sed -i.bak 's|/1' "$file"
+  /usr/bin/sed -i.bak 's|http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r335709 - Fix a single typo in SBSymbolContext

2018-06-26 Thread Dave Lee via lldb-commits
Author: kastiglione
Date: Tue Jun 26 23:46:09 2018
New Revision: 335709

URL: http://llvm.org/viewvc/llvm-project?rev=335709&view=rev
Log:
Fix a single typo in SBSymbolContext

Summary: Fix a "Manay" in SBSymbolContext.i

Reviewers: xiaobai

Reviewed By: xiaobai

Subscribers: lldb-commits

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

Modified:
lldb/trunk/scripts/interface/SBSymbolContext.i

Modified: lldb/trunk/scripts/interface/SBSymbolContext.i
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBSymbolContext.i?rev=335709&r1=335708&r2=335709&view=diff
==
--- lldb/trunk/scripts/interface/SBSymbolContext.i (original)
+++ lldb/trunk/scripts/interface/SBSymbolContext.i Tue Jun 26 23:46:09 2018
@@ -12,7 +12,7 @@ namespace lldb {
 %feature("docstring",
 "A context object that provides access to core debugger entities.
 
-Manay debugger functions require a context when doing lookups. This class
+Many debugger functions require a context when doing lookups. This class
 provides a common structure that can be used as the result of a query that
 can contain a single result.
 


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


[Lldb-commits] [lldb] r336287 - Fix and simplify lldb.command decorator

2018-07-04 Thread Dave Lee via lldb-commits
Author: kastiglione
Date: Wed Jul  4 09:11:43 2018
New Revision: 336287

URL: http://llvm.org/viewvc/llvm-project?rev=336287&view=rev
Log:
Fix and simplify lldb.command decorator

Summary:
This change fixes one issue with `lldb.command`, and also reduces the 
implementation.

The fix: a command function's docstring was not shown when running `help 
`. This is because the docstring attached the source function is 
not propagated to the decorated function (`f.__call__`). By returning the 
original function, the docstring will be properly displayed by `help`.

Also with this change, the command name is assumed to be the function's name, 
but can still be explicitly defined as previously.

Additionally, the implementation was updated to:

* Remove inner class
* Remove use of `inspect` module
* Remove `*args` and `**kwargs`

Reviewers: clayborg

Reviewed By: clayborg

Subscribers: keith, xiaobai, lldb-commits

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

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script/decorated.py
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script/py_import
lldb/trunk/scripts/Python/python-extensions.swig

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py?rev=336287&r1=336286&r2=336287&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py
 Wed Jul  4 09:11:43 2018
@@ -49,6 +49,7 @@ class CmdPythonTestCase(TestBase):
 self.runCmd('command script delete tell_curr', check=False)
 self.runCmd('command script delete bug11569', check=False)
 self.runCmd('command script delete takes_exe_ctx', check=False)
+self.runCmd('command script delete decorated', check=False)
 
 # Execute the cleanup function during test case tear down.
 self.addTearDownHook(cleanup)
@@ -67,13 +68,19 @@ class CmdPythonTestCase(TestBase):
 substrs=['Just a docstring for welcome_impl',
  'A command that says hello to LLDB users'])
 
+decorated_commands = ["decorated" + str(n) for n in range(1, 5)]
+for name in decorated_commands:
+self.expect(name, substrs=["hello from " + name])
+self.expect("help " + name,
+substrs=["Python command defined by @lldb.command"])
+
 self.expect("help",
 substrs=['For more information run',
- 'welcome'])
+ 'welcome'] + decorated_commands)
 
 self.expect("help -a",
 substrs=['For more information run',
- 'welcome'])
+ 'welcome'] + decorated_commands)
 
 self.expect("help -u", matching=False,
 substrs=['For more information run'])

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script/decorated.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script/decorated.py?rev=336287&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script/decorated.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script/decorated.py
 Wed Jul  4 09:11:43 2018
@@ -0,0 +1,35 @@
+from __future__ import print_function
+
+import lldb
+
+
+@lldb.command()
+def decorated1(debugger, args, exe_ctx, result, dict):
+"""
+Python command defined by @lldb.command
+"""
+print("hello from decorated1", file=result)
+
+
+@lldb.command(doc="Python command defined by @lldb.command")
+def decorated2(debugger, args, exe_ctx, result, dict):
+"""
+This docstring is overridden.
+"""
+print("hello from decorated2", file=result)
+
+
+@lldb.command()
+def decorated3(debugger, args, result, dict):
+"""
+Python command defined by @lldb.command
+"""
+print("hello from decorated3", file=result)
+
+
+@lldb.command("decorated4")
+def _decorated4(debugger, args, exe_ctx, result, dict):
+"""
+Python command defined by @lldb.command
+"""
+print("hello from decorated4", file=result)

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script/py_import
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script/py_import?

[Lldb-commits] [lldb] r355793 - Quiet command regex instructions during batch execution

2019-03-10 Thread Dave Lee via lldb-commits
Author: kastiglione
Date: Sun Mar 10 16:15:48 2019
New Revision: 355793

URL: http://llvm.org/viewvc/llvm-project?rev=355793&view=rev
Log:
Quiet command regex instructions during batch execution

Summary:
Within .lldbinit, regex commands can be structured as a list of substitutions 
over
multiple lines. It's possible that this is uninentional, but it works and has
benefits.

For example:

command regex 
s/pat1/repl1/
s/pat2/repl2/
...

I use this form of `command regex` in my `~/.lldbinit`, because it makes it
clearer to write and read compared to a single line definition, because
multiline substitutions don't need to be quoted, and are broken up one per line.

However, multiline definitions result in usage instructions being printed for
each use. The result is that every time I run `lldb`, I get a dozen or more
lines of noise. With this change, the instructions are only printed when
`command regex` is invoked interactively, or from a terminal, neither of which
are true when lldb is sourcing `~/.lldbinit`.

Reviewers: clayborg, jingham

Reviewed By: clayborg

Subscribers: jdoerfert, kastiglione, xiaobai, keith, lldb-commits

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

Modified:
lldb/trunk/include/lldb/Core/IOHandler.h
lldb/trunk/include/lldb/Expression/REPL.h
lldb/trunk/lit/Commands/command-regex-delete.test
lldb/trunk/lit/Commands/command-regex-unalias.test
lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp
lldb/trunk/source/Commands/CommandObjectCommands.cpp
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Commands/CommandObjectType.cpp
lldb/trunk/source/Commands/CommandObjectWatchpointCommand.cpp
lldb/trunk/source/Core/IOHandler.cpp
lldb/trunk/source/Expression/REPL.cpp

lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h

Modified: lldb/trunk/include/lldb/Core/IOHandler.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/IOHandler.h?rev=355793&r1=355792&r2=355793&view=diff
==
--- lldb/trunk/include/lldb/Core/IOHandler.h (original)
+++ lldb/trunk/include/lldb/Core/IOHandler.h Sun Mar 10 16:15:48 2019
@@ -200,7 +200,7 @@ public:
 
   virtual ~IOHandlerDelegate() = default;
 
-  virtual void IOHandlerActivated(IOHandler &io_handler) {}
+  virtual void IOHandlerActivated(IOHandler &io_handler, bool interactive) {}
 
   virtual void IOHandlerDeactivated(IOHandler &io_handler) {}
 

Modified: lldb/trunk/include/lldb/Expression/REPL.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/REPL.h?rev=355793&r1=355792&r2=355793&view=diff
==
--- lldb/trunk/include/lldb/Expression/REPL.h (original)
+++ lldb/trunk/include/lldb/Expression/REPL.h Sun Mar 10 16:15:48 2019
@@ -85,7 +85,7 @@ public:
   //--
   // IOHandler::Delegate functions
   //--
-  void IOHandlerActivated(IOHandler &io_handler) override;
+  void IOHandlerActivated(IOHandler &io_handler, bool interactive) override;
 
   bool IOHandlerInterrupt(IOHandler &io_handler) override;
 

Modified: lldb/trunk/lit/Commands/command-regex-delete.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Commands/command-regex-delete.test?rev=355793&r1=355792&r2=355793&view=diff
==
--- lldb/trunk/lit/Commands/command-regex-delete.test (original)
+++ lldb/trunk/lit/Commands/command-regex-delete.test Sun Mar 10 16:15:48 2019
@@ -2,7 +2,7 @@
 # RUN: %lldb -s %s 2>&1 | FileCheck %s
 
 command regex 'Help__'
-# CHECK: Enter one of more sed substitution commands in the form
+# CHECK: Enter one or more sed substitution commands in the form
 # We need to leave a new line after to end the regex.
 s/^$/help/
 

Modified: lldb/trunk/lit/Commands/command-regex-unalias.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Commands/command-regex-unalias.test?rev=355793&r1=355792&r2=355793&view=diff
==
--- lldb/trunk/lit/Commands/command-regex-unalias.test (original)
+++ lldb/trunk/lit/Commands/command-regex-unalias.test Sun Mar 10 16:15:48 2019
@@ -2,7 +2,7 @@
 # RUN: %lldb -s %s 2>&1 | FileCheck %s
 
 command regex 'Help__'
-# CHECK: Enter one of more sed substitution commands in the form
+# CHECK: Enter one or more sed substitution commands in the form
 # We need to leave a new line after to end the regex.
 s/^$/help/
 

Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointComm

Re: [Lldb-commits] [PATCH] D59101: [SBAPI] Log from record macro

2019-03-11 Thread Dave Lee via lldb-commits
Yeah given the evidence, maybe it's fine left as is. I worked around it
locally so I am not blocked. Thanks!

On Monday, March 11, 2019, Jonas Devlieghere  wrote:

> It's weird that this only occurs when building with Xcode, none of the
> bots seem affected. Anyway, I'm updating the macros and verifying the build
> works locally when using Xcode.
>
> On Sun, Mar 10, 2019 at 3:25 PM Dave Lee via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> kastiglione added a comment.
>>
>> I'm getting build failures that appear to be caused by this patch. I'm
>> compiling on macOS with Xcode 10.1. The failures are uses of
>> `LLDB_RECORD_DUMMY()`, passing a callback function pointer as one of the
>> args. This results in errors like:
>>
>>   ../../tools/lldb/include/lldb/Utility/ReproducerInstrumentation.h:37:6:
>> error: invalid operands to binary expression ('llvm::raw_string_ostream'
>> and 'bool (*)(void *, lldb::SBProcess &, lldb::SBThread &,
>> lldb::SBBreakpointLocation &)')
>> ss << t;
>> ~~ ^  ~
>>
>> and
>>
>>   ../../include/llvm/Support/raw_ostream.h:202:16: note: candidate
>> function not viable: no known conversion from 'bool (*)(void *,
>> lldb::SBProcess &, lldb::SBThread &, lldb::SBBreakpointLocation &)' to
>> 'const void *' for 1st argument; take the address of the argument with &
>> raw_ostream &operator<<(const void *P);
>>
>>
>> Repository:
>>   rLLDB LLDB
>>
>> CHANGES SINCE LAST ACTION
>>   https://reviews.llvm.org/D59101/new/
>>
>> https://reviews.llvm.org/D59101
>>
>>
>>
>>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb/Commands] Alias `script` command to `scripting execute` (PR #97263)

2024-07-01 Thread Dave Lee via lldb-commits


@@ -518,6 +518,15 @@ void CommandInterpreter::Initialize() {
 AddAlias("re", cmd_obj_sp);
   }
 
+  cmd_obj_sp = GetCommandSPExact("scripting execute");
+  if (cmd_obj_sp) {
+AddAlias("sc", cmd_obj_sp);
+AddAlias("scr", cmd_obj_sp);
+AddAlias("scri", cmd_obj_sp);
+AddAlias("scrip", cmd_obj_sp);
+AddAlias("script", cmd_obj_sp);

kastiglione wrote:

this is unfortunate, do these pollute help output? if so, can we hide them?

is there no way to make a prefix match an alias, when it's shorter?

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


[Lldb-commits] [lldb] [lldb/Commands] Alias `script` command to `scripting execute` (PR #97263)

2024-07-01 Thread Dave Lee via lldb-commits

https://github.com/kastiglione approved this pull request.

In addition to the comment about unique prefixes, my only other comment is, 
have you considered `scripting run`?

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


[Lldb-commits] [lldb] [lldb/Commands] Alias `script` command to `scripting run` (PR #97263)

2024-07-02 Thread Dave Lee via lldb-commits

kastiglione wrote:

> The problem with this command is that it either executes a script given to it 
> on the command line, or it runs the embedded script interpreter...

I don't see the problem. The original `script` does both of those things, and 
`run` works fits those two use case as well or better than `execute`, in my 
opinion.

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


[Lldb-commits] [lldb] [lldb/Commands] Alias `script` command to `scripting run` (PR #97263)

2024-07-02 Thread Dave Lee via lldb-commits

kastiglione wrote:

@medismailben 👍 I saw, and also wanted to reply to Jim.

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


[Lldb-commits] [lldb] [lldb] Improve summary string handling of dollar chars (PR #98190)

2024-07-09 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/98190

None

>From 24f2c8ee442b67bae4b78543f54cae4b026f3862 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Mon, 8 Jul 2024 11:19:55 -0700
Subject: [PATCH] [lldb] Improve summary string handling of dollar chars

---
 lldb/source/Core/FormatEntity.cpp | 258 +-
 .../data-formatter/special-chars/Makefile |   2 +
 .../TestSummaryStringSpecialChars.py  |  19 ++
 .../data-formatter/special-chars/main.c   |   9 +
 4 files changed, 156 insertions(+), 132 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/data-formatter/special-chars/Makefile
 create mode 100644 
lldb/test/API/functionalities/data-formatter/special-chars/TestSummaryStringSpecialChars.py
 create mode 100644 
lldb/test/API/functionalities/data-formatter/special-chars/main.c

diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index fe95858f35c9f..4e1f37099148b 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -2170,154 +2170,148 @@ static Status ParseInternal(llvm::StringRef &format, 
Entry &parent_entry,
 } break;
 
 case '$':
-  if (format.size() == 1) {
-// '$' at the end of a format string, just print the '$'
+  format = format.drop_front(); // Skip the '$'
+  if (format.empty() || format.front() != '{') {
+// Print '$' when not followed by '{'.
 parent_entry.AppendText("$");
   } else {
-format = format.drop_front(); // Skip the '$'
-
-if (format[0] == '{') {
-  format = format.drop_front(); // Skip the '{'
-
-  llvm::StringRef variable, variable_format;
-  error = FormatEntity::ExtractVariableInfo(format, variable,
-variable_format);
-  if (error.Fail())
-return error;
-  bool verify_is_thread_id = false;
-  Entry entry;
-  if (!variable_format.empty()) {
-entry.printf_format = variable_format.str();
-
-// If the format contains a '%' we are going to assume this is a
-// printf style format. So if you want to format your thread ID
-// using "0x%llx" you can use: ${thread.id%0x%llx}
-//
-// If there is no '%' in the format, then it is assumed to be a
-// LLDB format name, or one of the extended formats specified in
-// the switch statement below.
-
-if (entry.printf_format.find('%') == std::string::npos) {
-  bool clear_printf = false;
-
-  if (entry.printf_format.size() == 1) {
-switch (entry.printf_format[0]) {
-case '@': // if this is an @ sign, print ObjC description
-  entry.number = ValueObject::
-  eValueObjectRepresentationStyleLanguageSpecific;
-  clear_printf = true;
-  break;
-case 'V': // if this is a V, print the value using the default
-  // format
-  entry.number =
-  ValueObject::eValueObjectRepresentationStyleValue;
-  clear_printf = true;
-  break;
-case 'L': // if this is an L, print the location of the value
-  entry.number =
-  ValueObject::eValueObjectRepresentationStyleLocation;
-  clear_printf = true;
-  break;
-case 'S': // if this is an S, print the summary after all
-  entry.number =
-  ValueObject::eValueObjectRepresentationStyleSummary;
-  clear_printf = true;
-  break;
-case '#': // if this is a '#', print the number of children
-  entry.number =
-  
ValueObject::eValueObjectRepresentationStyleChildrenCount;
-  clear_printf = true;
-  break;
-case 'T': // if this is a 'T', print the type
-  entry.number =
-  ValueObject::eValueObjectRepresentationStyleType;
-  clear_printf = true;
-  break;
-case 'N': // if this is a 'N', print the name
-  entry.number =
-  ValueObject::eValueObjectRepresentationStyleName;
-  clear_printf = true;
-  break;
-case '>': // if this is a '>', print the expression path
-  entry.number = ValueObject::
-  eValueObjectRepresentationStyleExpressionPath;
-  clear_printf = true;
-  break;
-}
+format = format.drop_front(); // Skip the '{'
+
+llvm::StringRef variable, variable_format;
+error = FormatEntity::ExtractVariableInfo(format, variabl

[Lldb-commits] [lldb] [lldb] Improve summary string handling of dollar chars (PR #98190)

2024-07-09 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Improve summary string handling of dollar chars (PR #98190)

2024-07-09 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Improve summary string handling of dollar chars (PR #98190)

2024-07-09 Thread Dave Lee via lldb-commits

kastiglione wrote:

Note that this is essentially a few lines of concrete change, most of the 
change is whitespace only. Use `?w=1` to filter out whitespace only changes: 
https://github.com/llvm/llvm-project/pull/98190/files?w=1

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


[Lldb-commits] [lldb] [lldb] Improve summary string handling of dollar chars (PR #98190)

2024-07-09 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/98190

>From 24f2c8ee442b67bae4b78543f54cae4b026f3862 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Mon, 8 Jul 2024 11:19:55 -0700
Subject: [PATCH 1/2] [lldb] Improve summary string handling of dollar chars

---
 lldb/source/Core/FormatEntity.cpp | 258 +-
 .../data-formatter/special-chars/Makefile |   2 +
 .../TestSummaryStringSpecialChars.py  |  19 ++
 .../data-formatter/special-chars/main.c   |   9 +
 4 files changed, 156 insertions(+), 132 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/data-formatter/special-chars/Makefile
 create mode 100644 
lldb/test/API/functionalities/data-formatter/special-chars/TestSummaryStringSpecialChars.py
 create mode 100644 
lldb/test/API/functionalities/data-formatter/special-chars/main.c

diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index fe95858f35c9f..4e1f37099148b 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -2170,154 +2170,148 @@ static Status ParseInternal(llvm::StringRef &format, 
Entry &parent_entry,
 } break;
 
 case '$':
-  if (format.size() == 1) {
-// '$' at the end of a format string, just print the '$'
+  format = format.drop_front(); // Skip the '$'
+  if (format.empty() || format.front() != '{') {
+// Print '$' when not followed by '{'.
 parent_entry.AppendText("$");
   } else {
-format = format.drop_front(); // Skip the '$'
-
-if (format[0] == '{') {
-  format = format.drop_front(); // Skip the '{'
-
-  llvm::StringRef variable, variable_format;
-  error = FormatEntity::ExtractVariableInfo(format, variable,
-variable_format);
-  if (error.Fail())
-return error;
-  bool verify_is_thread_id = false;
-  Entry entry;
-  if (!variable_format.empty()) {
-entry.printf_format = variable_format.str();
-
-// If the format contains a '%' we are going to assume this is a
-// printf style format. So if you want to format your thread ID
-// using "0x%llx" you can use: ${thread.id%0x%llx}
-//
-// If there is no '%' in the format, then it is assumed to be a
-// LLDB format name, or one of the extended formats specified in
-// the switch statement below.
-
-if (entry.printf_format.find('%') == std::string::npos) {
-  bool clear_printf = false;
-
-  if (entry.printf_format.size() == 1) {
-switch (entry.printf_format[0]) {
-case '@': // if this is an @ sign, print ObjC description
-  entry.number = ValueObject::
-  eValueObjectRepresentationStyleLanguageSpecific;
-  clear_printf = true;
-  break;
-case 'V': // if this is a V, print the value using the default
-  // format
-  entry.number =
-  ValueObject::eValueObjectRepresentationStyleValue;
-  clear_printf = true;
-  break;
-case 'L': // if this is an L, print the location of the value
-  entry.number =
-  ValueObject::eValueObjectRepresentationStyleLocation;
-  clear_printf = true;
-  break;
-case 'S': // if this is an S, print the summary after all
-  entry.number =
-  ValueObject::eValueObjectRepresentationStyleSummary;
-  clear_printf = true;
-  break;
-case '#': // if this is a '#', print the number of children
-  entry.number =
-  
ValueObject::eValueObjectRepresentationStyleChildrenCount;
-  clear_printf = true;
-  break;
-case 'T': // if this is a 'T', print the type
-  entry.number =
-  ValueObject::eValueObjectRepresentationStyleType;
-  clear_printf = true;
-  break;
-case 'N': // if this is a 'N', print the name
-  entry.number =
-  ValueObject::eValueObjectRepresentationStyleName;
-  clear_printf = true;
-  break;
-case '>': // if this is a '>', print the expression path
-  entry.number = ValueObject::
-  eValueObjectRepresentationStyleExpressionPath;
-  clear_printf = true;
-  break;
-}
+format = format.drop_front(); // Skip the '{'
+
+llvm::StringRef variable, variable_format;
+error = FormatEntity::ExtractVariableInfo(format, variable,

[Lldb-commits] [lldb] [lldb] Improve summary string handling of dollar chars (PR #98190)

2024-07-09 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] baffaf0 - [lldb] Add required skipIfLLVMTargetMissing for X86 (NFC)

2024-05-11 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2024-05-11T11:48:31-07:00
New Revision: baffaf000fd4667f33b3756d0d3b645b1d926b44

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

LOG: [lldb] Add required skipIfLLVMTargetMissing for X86 (NFC)

Added: 


Modified: 
lldb/test/API/macosx/rosetta/TestRosetta.py
lldb/test/API/macosx/universal64/TestUniversal64.py

Removed: 




diff  --git a/lldb/test/API/macosx/rosetta/TestRosetta.py 
b/lldb/test/API/macosx/rosetta/TestRosetta.py
index ce40de475ef16..a812f558a8fc9 100644
--- a/lldb/test/API/macosx/rosetta/TestRosetta.py
+++ b/lldb/test/API/macosx/rosetta/TestRosetta.py
@@ -40,6 +40,7 @@ class TestRosetta(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
 @skipUnlessAppleSilicon
+@skipIfLLVMTargetMissing("X86")
 @skipIfDarwinEmbedded
 def test_rosetta(self):
 """There can be many tests in a test case - describe this test here."""

diff  --git a/lldb/test/API/macosx/universal64/TestUniversal64.py 
b/lldb/test/API/macosx/universal64/TestUniversal64.py
index 98661443086ef..893ff14d81138 100644
--- a/lldb/test/API/macosx/universal64/TestUniversal64.py
+++ b/lldb/test/API/macosx/universal64/TestUniversal64.py
@@ -17,6 +17,7 @@ def do_test(self):
 # actually launch them here.
 
 # The Makefile manually invokes clang.
+@skipIfLLVMTargetMissing("X86")
 @skipIfAsan
 @skipUnlessDarwin
 @skipIfDarwinEmbedded
@@ -26,6 +27,7 @@ def test_universal64_executable(self):
 self.do_test()
 
 # The Makefile manually invokes clang.
+@skipIfLLVMTargetMissing("X86")
 @skipIfAsan
 @skipUnlessDarwin
 @skipIfDarwinEmbedded



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


[Lldb-commits] [lldb] lldb Support custom LLVM formatting for variables (PR #91868)

2024-05-11 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/91868

- **[lldb] Support custom LLVM formatting for variables (#81196)**
- **[lldb] Handle non-existent llvm_format**


>From 30a36018b9c96d7ddd969815ef850987d781338e Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Tue, 30 Apr 2024 10:45:10 -0700
Subject: [PATCH 1/2] [lldb] Support custom LLVM formatting for variables
 (#81196)

Adds support for applying LLVM formatting to variables.

The reason for this is to support cases such as the following.

Let's say you have two separate bytes that you want to print as a
combined hex value. Consider the following summary string:

```
${var.byte1%x}${var.byte2%x}
```

The output of this will be: `0x120x34`. That is, a `0x` prefix is
unconditionally applied to each byte. This is unlike printf formatting
where you must include the `0x` yourself.

Currently, there's no way to do this with summary strings, instead
you'll need a summary provider in python or c++.

This change introduces formatting support using LLVM's formatter system.
This allows users to achieve the desired custom formatting using:

```
${var.byte1:x-}${var.byte2:x-}
```

Here, each variable is suffixed with `:x-`. This is passed to the LLVM
formatter as `{0:x-}`. For integer values, `x` declares the output as
hex, and `-` declares that no `0x` prefix is to be used. Further, one
could write:

```
${var.byte1:x-2}${var.byte2:x-2}
```

Where the added `2` results in these bytes being written with a minimum
of 2 digits.

An alternative considered was to add a new format specifier that would
print hex values without the `0x` prefix. The reason that approach was
not taken is because in addition to forcing a `0x` prefix, hex values
are also forced to use leading zeros. This approach lets the user have
full control over formatting.
---
 lldb/docs/use/variable.rst|  9 +++
 lldb/source/Core/FormatEntity.cpp | 70 ---
 .../custom-printf-summary/Makefile|  2 +
 .../TestCustomSummaryLLVMFormat.py| 20 ++
 .../custom-printf-summary/main.c  | 13 
 5 files changed, 104 insertions(+), 10 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile
 create mode 100644 
lldb/test/API/functionalities/data-formatter/custom-printf-summary/TestCustomSummaryLLVMFormat.py
 create mode 100644 
lldb/test/API/functionalities/data-formatter/custom-printf-summary/main.c

diff --git a/lldb/docs/use/variable.rst b/lldb/docs/use/variable.rst
index 8eaed6405315b..e9175b25336ba 100644
--- a/lldb/docs/use/variable.rst
+++ b/lldb/docs/use/variable.rst
@@ -460,6 +460,15 @@ summary strings, regardless of the format they have 
applied to their types. To
 do that, you can use %format inside an expression path, as in ${var.x->x%u},
 which would display the value of x as an unsigned integer.
 
+Additionally, custom output can be achieved by using an LLVM format string,
+commencing with the ``:`` marker. To illustrate, compare ``${var.byte%x}`` and
+``${var.byte:x-}``. The former uses lldb's builtin hex formatting (``x``),
+which unconditionally inserts a ``0x`` prefix, and also zero pads the value to
+match the size of the type. The latter uses ``llvm::formatv`` formatting
+(``:x-``), and will print only the hex value, with no ``0x`` prefix, and no
+padding. This raw control is useful when composing multiple pieces into a
+larger whole.
+
 You can also use some other special format markers, not available for formats
 themselves, but which carry a special meaning when used in this context:
 
diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index ba62e26252591..da5b1cfce74ac 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -57,6 +57,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/Regex.h"
 #include "llvm/TargetParser/Triple.h"
 
 #include 
@@ -658,6 +659,38 @@ static char ConvertValueObjectStyleToChar(
   return '\0';
 }
 
+static llvm::Regex LLVMFormatPattern{"x[-+]?\\d*|n|d", 
llvm::Regex::IgnoreCase};
+
+static bool DumpValueWithLLVMFormat(Stream &s, llvm::StringRef options,
+ValueObject &valobj) {
+  std::string formatted;
+  std::string llvm_format = ("{0:" + options + "}").str();
+
+  // Options supported by format_provider for integral arithmetic types.
+  // See table in FormatProviders.h.
+
+  auto type_info = valobj.GetTypeInfo();
+  if (type_info & eTypeIsInteger && LLVMFormatPattern.match(options)) {
+if (type_info & eTypeIsSigned) {
+  bool success = false;
+  int64_t integer = valobj.GetValueAsSigned(0, &success);
+  if (success)
+formatted = llvm::formatv(llvm_format.data(), integer);
+} else {
+  bool success = false;
+  uint64_t integer = valobj.GetValueAsUnsigned(0, &success);
+ 

[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)

2024-05-11 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)

2024-05-11 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)

2024-05-15 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)

2024-05-15 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)

2024-05-15 Thread Dave Lee via lldb-commits

kastiglione wrote:

@adrian-prantl updated the description:

> Re-apply https://github.com/llvm/llvm-project/pull/81196, with a fix that 
> handles the absence of llvm formatting: 
> https://github.com/llvm/llvm-project/commit/3ba650e91eded3543764f37921dcce3bb47d425f

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


[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)

2024-05-15 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/91868

>From 30a36018b9c96d7ddd969815ef850987d781338e Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Tue, 30 Apr 2024 10:45:10 -0700
Subject: [PATCH 1/3] [lldb] Support custom LLVM formatting for variables
 (#81196)

Adds support for applying LLVM formatting to variables.

The reason for this is to support cases such as the following.

Let's say you have two separate bytes that you want to print as a
combined hex value. Consider the following summary string:

```
${var.byte1%x}${var.byte2%x}
```

The output of this will be: `0x120x34`. That is, a `0x` prefix is
unconditionally applied to each byte. This is unlike printf formatting
where you must include the `0x` yourself.

Currently, there's no way to do this with summary strings, instead
you'll need a summary provider in python or c++.

This change introduces formatting support using LLVM's formatter system.
This allows users to achieve the desired custom formatting using:

```
${var.byte1:x-}${var.byte2:x-}
```

Here, each variable is suffixed with `:x-`. This is passed to the LLVM
formatter as `{0:x-}`. For integer values, `x` declares the output as
hex, and `-` declares that no `0x` prefix is to be used. Further, one
could write:

```
${var.byte1:x-2}${var.byte2:x-2}
```

Where the added `2` results in these bytes being written with a minimum
of 2 digits.

An alternative considered was to add a new format specifier that would
print hex values without the `0x` prefix. The reason that approach was
not taken is because in addition to forcing a `0x` prefix, hex values
are also forced to use leading zeros. This approach lets the user have
full control over formatting.
---
 lldb/docs/use/variable.rst|  9 +++
 lldb/source/Core/FormatEntity.cpp | 70 ---
 .../custom-printf-summary/Makefile|  2 +
 .../TestCustomSummaryLLVMFormat.py| 20 ++
 .../custom-printf-summary/main.c  | 13 
 5 files changed, 104 insertions(+), 10 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile
 create mode 100644 
lldb/test/API/functionalities/data-formatter/custom-printf-summary/TestCustomSummaryLLVMFormat.py
 create mode 100644 
lldb/test/API/functionalities/data-formatter/custom-printf-summary/main.c

diff --git a/lldb/docs/use/variable.rst b/lldb/docs/use/variable.rst
index 8eaed6405315b..e9175b25336ba 100644
--- a/lldb/docs/use/variable.rst
+++ b/lldb/docs/use/variable.rst
@@ -460,6 +460,15 @@ summary strings, regardless of the format they have 
applied to their types. To
 do that, you can use %format inside an expression path, as in ${var.x->x%u},
 which would display the value of x as an unsigned integer.
 
+Additionally, custom output can be achieved by using an LLVM format string,
+commencing with the ``:`` marker. To illustrate, compare ``${var.byte%x}`` and
+``${var.byte:x-}``. The former uses lldb's builtin hex formatting (``x``),
+which unconditionally inserts a ``0x`` prefix, and also zero pads the value to
+match the size of the type. The latter uses ``llvm::formatv`` formatting
+(``:x-``), and will print only the hex value, with no ``0x`` prefix, and no
+padding. This raw control is useful when composing multiple pieces into a
+larger whole.
+
 You can also use some other special format markers, not available for formats
 themselves, but which carry a special meaning when used in this context:
 
diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index ba62e26252591..da5b1cfce74ac 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -57,6 +57,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/Regex.h"
 #include "llvm/TargetParser/Triple.h"
 
 #include 
@@ -658,6 +659,38 @@ static char ConvertValueObjectStyleToChar(
   return '\0';
 }
 
+static llvm::Regex LLVMFormatPattern{"x[-+]?\\d*|n|d", 
llvm::Regex::IgnoreCase};
+
+static bool DumpValueWithLLVMFormat(Stream &s, llvm::StringRef options,
+ValueObject &valobj) {
+  std::string formatted;
+  std::string llvm_format = ("{0:" + options + "}").str();
+
+  // Options supported by format_provider for integral arithmetic types.
+  // See table in FormatProviders.h.
+
+  auto type_info = valobj.GetTypeInfo();
+  if (type_info & eTypeIsInteger && LLVMFormatPattern.match(options)) {
+if (type_info & eTypeIsSigned) {
+  bool success = false;
+  int64_t integer = valobj.GetValueAsSigned(0, &success);
+  if (success)
+formatted = llvm::formatv(llvm_format.data(), integer);
+} else {
+  bool success = false;
+  uint64_t integer = valobj.GetValueAsUnsigned(0, &success);
+  if (success)
+formatted = llvm::formatv(llvm_format.data(), integer);
+}
+  }
+
+  if (formatted.empt

[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)

2024-05-15 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/91868

>From 30a36018b9c96d7ddd969815ef850987d781338e Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Tue, 30 Apr 2024 10:45:10 -0700
Subject: [PATCH 1/4] [lldb] Support custom LLVM formatting for variables
 (#81196)

Adds support for applying LLVM formatting to variables.

The reason for this is to support cases such as the following.

Let's say you have two separate bytes that you want to print as a
combined hex value. Consider the following summary string:

```
${var.byte1%x}${var.byte2%x}
```

The output of this will be: `0x120x34`. That is, a `0x` prefix is
unconditionally applied to each byte. This is unlike printf formatting
where you must include the `0x` yourself.

Currently, there's no way to do this with summary strings, instead
you'll need a summary provider in python or c++.

This change introduces formatting support using LLVM's formatter system.
This allows users to achieve the desired custom formatting using:

```
${var.byte1:x-}${var.byte2:x-}
```

Here, each variable is suffixed with `:x-`. This is passed to the LLVM
formatter as `{0:x-}`. For integer values, `x` declares the output as
hex, and `-` declares that no `0x` prefix is to be used. Further, one
could write:

```
${var.byte1:x-2}${var.byte2:x-2}
```

Where the added `2` results in these bytes being written with a minimum
of 2 digits.

An alternative considered was to add a new format specifier that would
print hex values without the `0x` prefix. The reason that approach was
not taken is because in addition to forcing a `0x` prefix, hex values
are also forced to use leading zeros. This approach lets the user have
full control over formatting.
---
 lldb/docs/use/variable.rst|  9 +++
 lldb/source/Core/FormatEntity.cpp | 70 ---
 .../custom-printf-summary/Makefile|  2 +
 .../TestCustomSummaryLLVMFormat.py| 20 ++
 .../custom-printf-summary/main.c  | 13 
 5 files changed, 104 insertions(+), 10 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile
 create mode 100644 
lldb/test/API/functionalities/data-formatter/custom-printf-summary/TestCustomSummaryLLVMFormat.py
 create mode 100644 
lldb/test/API/functionalities/data-formatter/custom-printf-summary/main.c

diff --git a/lldb/docs/use/variable.rst b/lldb/docs/use/variable.rst
index 8eaed6405315b..e9175b25336ba 100644
--- a/lldb/docs/use/variable.rst
+++ b/lldb/docs/use/variable.rst
@@ -460,6 +460,15 @@ summary strings, regardless of the format they have 
applied to their types. To
 do that, you can use %format inside an expression path, as in ${var.x->x%u},
 which would display the value of x as an unsigned integer.
 
+Additionally, custom output can be achieved by using an LLVM format string,
+commencing with the ``:`` marker. To illustrate, compare ``${var.byte%x}`` and
+``${var.byte:x-}``. The former uses lldb's builtin hex formatting (``x``),
+which unconditionally inserts a ``0x`` prefix, and also zero pads the value to
+match the size of the type. The latter uses ``llvm::formatv`` formatting
+(``:x-``), and will print only the hex value, with no ``0x`` prefix, and no
+padding. This raw control is useful when composing multiple pieces into a
+larger whole.
+
 You can also use some other special format markers, not available for formats
 themselves, but which carry a special meaning when used in this context:
 
diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index ba62e26252591..da5b1cfce74ac 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -57,6 +57,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/Regex.h"
 #include "llvm/TargetParser/Triple.h"
 
 #include 
@@ -658,6 +659,38 @@ static char ConvertValueObjectStyleToChar(
   return '\0';
 }
 
+static llvm::Regex LLVMFormatPattern{"x[-+]?\\d*|n|d", 
llvm::Regex::IgnoreCase};
+
+static bool DumpValueWithLLVMFormat(Stream &s, llvm::StringRef options,
+ValueObject &valobj) {
+  std::string formatted;
+  std::string llvm_format = ("{0:" + options + "}").str();
+
+  // Options supported by format_provider for integral arithmetic types.
+  // See table in FormatProviders.h.
+
+  auto type_info = valobj.GetTypeInfo();
+  if (type_info & eTypeIsInteger && LLVMFormatPattern.match(options)) {
+if (type_info & eTypeIsSigned) {
+  bool success = false;
+  int64_t integer = valobj.GetValueAsSigned(0, &success);
+  if (success)
+formatted = llvm::formatv(llvm_format.data(), integer);
+} else {
+  bool success = false;
+  uint64_t integer = valobj.GetValueAsUnsigned(0, &success);
+  if (success)
+formatted = llvm::formatv(llvm_format.data(), integer);
+}
+  }
+
+  if (formatted.empt

[Lldb-commits] [lldb] [lldb] Add the word "backtrace" to bt help string (PR #92618)

2024-05-17 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/92618

None

>From 1564ae4ce3a56fc1f11e03e82e0da1e01f25f3ed Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Thu, 16 May 2024 14:01:22 -0700
Subject: [PATCH] [lldb] Add the word "backtrace" to bt help string

---
 lldb/source/Commands/CommandObjectThread.cpp   |  4 ++--
 lldb/source/Interpreter/CommandInterpreter.cpp | 10 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/lldb/source/Commands/CommandObjectThread.cpp 
b/lldb/source/Commands/CommandObjectThread.cpp
index 4397ee14ea074..db96ee2cec383 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -114,8 +114,8 @@ class CommandObjectThreadBacktrace : public 
CommandObjectIterateOverThreads {
   CommandObjectThreadBacktrace(CommandInterpreter &interpreter)
   : CommandObjectIterateOverThreads(
 interpreter, "thread backtrace",
-"Show thread call stacks.  Defaults to the current thread, thread "
-"indexes can be specified as arguments.\n"
+"Show backtraces of thread call stacks.  Defaults to the current "
+"thread, thread indexes can be specified as arguments.\n"
 "Use the thread-index \"all\" to see all threads.\n"
 "Use the thread-index \"unique\" to see threads grouped by unique "
 "call stacks.\n"
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index 4c58ecc3c1848..3e470a6989bbf 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -816,11 +816,11 @@ void CommandInterpreter::LoadCommandDictionary() {
   std::unique_ptr bt_regex_cmd_up(
   new CommandObjectRegexCommand(
   *this, "_regexp-bt",
-  "Show the current thread's call stack.  Any numeric argument "
-  "displays at most that many "
-  "frames.  The argument 'all' displays all threads.  Use 'settings"
-  " set frame-format' to customize the printing of individual frames "
-  "and 'settings set thread-format' to customize the thread header.",
+  "Show backtrace of the current thread's call stack.  Any numeric "
+  "argument displays at most that many frames.  The argument 'all' "
+  "displays all threads.  Use 'settings set frame-format' to customize 
"
+  "the printing of individual frames and 'settings set thread-format' "
+  "to customize the thread header.",
   "bt [ | all]", 0, false));
   if (bt_regex_cmd_up) {
 // accept but don't document "bt -c " -- before bt was a regex

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


[Lldb-commits] [lldb] [lldb] Add the word "backtrace" to bt help string (PR #92618)

2024-05-17 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add the word "backtrace" to bt help string (PR #92618)

2024-05-17 Thread Dave Lee via lldb-commits

kastiglione wrote:

Open to alternative rewordings that include "backtrace".

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


[Lldb-commits] [lldb] [lldb] Add the word "backtrace" to bt help string (PR #92618)

2024-05-21 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Improve identification of Dlang mangled names (PR #93881)

2024-05-30 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/93881

None

>From 21a61a1a5ae68fc1e913f73c4311258675990f95 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Thu, 30 May 2024 13:29:41 -0700
Subject: [PATCH] [lldb] Improve identification of Dlang mangled names

---
 lldb/source/Core/Mangled.cpp | 11 +--
 lldb/test/API/lang/c/non-mangled/Makefile|  4 
 .../API/lang/c/non-mangled/TestCNonMangled.py| 16 
 lldb/test/API/lang/c/non-mangled/main.c  |  8 
 4 files changed, 37 insertions(+), 2 deletions(-)
 create mode 100644 lldb/test/API/lang/c/non-mangled/Makefile
 create mode 100644 lldb/test/API/lang/c/non-mangled/TestCNonMangled.py
 create mode 100644 lldb/test/API/lang/c/non-mangled/main.c

diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index 8efc4c639cca5..3142c81d12ed9 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -19,6 +19,7 @@
 #include "lldb/Utility/Stream.h"
 #include "lldb/lldb-enumerations.h"
 
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Demangle/Demangle.h"
 #include "llvm/Support/Compiler.h"
@@ -48,8 +49,14 @@ Mangled::ManglingScheme 
Mangled::GetManglingScheme(llvm::StringRef const name) {
   if (name.starts_with("_R"))
 return Mangled::eManglingSchemeRustV0;
 
-  if (name.starts_with("_D"))
-return Mangled::eManglingSchemeD;
+  if (name.starts_with("_D")) {
+// A dlang mangled name begins with `_D`, followed by a numeric length.
+// See `SymbolName` and `LName` in
+// https://dlang.org/spec/abi.html#name_mangling
+llvm::StringRef buf = name.drop_front(2);
+if (!buf.empty() && llvm::isDigit(buf.front()))
+  return Mangled::eManglingSchemeD;
+  }
 
   if (name.starts_with("_Z"))
 return Mangled::eManglingSchemeItanium;
diff --git a/lldb/test/API/lang/c/non-mangled/Makefile 
b/lldb/test/API/lang/c/non-mangled/Makefile
new file mode 100644
index 0..695335e068c0c
--- /dev/null
+++ b/lldb/test/API/lang/c/non-mangled/Makefile
@@ -0,0 +1,4 @@
+C_SOURCES := main.c
+CFLAGS_EXTRAS := -std=c99
+
+include Makefile.rules
diff --git a/lldb/test/API/lang/c/non-mangled/TestCNonMangled.py 
b/lldb/test/API/lang/c/non-mangled/TestCNonMangled.py
new file mode 100644
index 0..32bd778fa6eb6
--- /dev/null
+++ b/lldb/test/API/lang/c/non-mangled/TestCNonMangled.py
@@ -0,0 +1,16 @@
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class TestCase(TestBase):
+
+def test_functions_having_dlang_mangling_prefix(self):
+"""
+Ensure C functions with a '_D' prefix alone are not mistakenly treated
+as a Dlang mangled name. A proper Dlang mangling will have digits
+immediately following the '_D' prefix.
+"""
+self.build()
+_, _, thread, _ = lldbutil.run_to_name_breakpoint(self, "_Dfunction")
+symbol = thread.frame[0].symbol
+self.assertEqual(symbol.GetDisplayName(), "_Dfunction")
diff --git a/lldb/test/API/lang/c/non-mangled/main.c 
b/lldb/test/API/lang/c/non-mangled/main.c
new file mode 100644
index 0..ad9d86e5c25a8
--- /dev/null
+++ b/lldb/test/API/lang/c/non-mangled/main.c
@@ -0,0 +1,8 @@
+#include 
+
+void _Dfunction() {}
+
+int main() {
+  _Dfunction();
+  return 0;
+}

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


[Lldb-commits] [lldb] [lldb] Improve identification of Dlang mangled names (PR #93881)

2024-05-30 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Improve identification of Dlang mangled names (PR #93881)

2024-05-30 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/93881

>From 21a61a1a5ae68fc1e913f73c4311258675990f95 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Thu, 30 May 2024 13:29:41 -0700
Subject: [PATCH 1/2] [lldb] Improve identification of Dlang mangled names

---
 lldb/source/Core/Mangled.cpp | 11 +--
 lldb/test/API/lang/c/non-mangled/Makefile|  4 
 .../API/lang/c/non-mangled/TestCNonMangled.py| 16 
 lldb/test/API/lang/c/non-mangled/main.c  |  8 
 4 files changed, 37 insertions(+), 2 deletions(-)
 create mode 100644 lldb/test/API/lang/c/non-mangled/Makefile
 create mode 100644 lldb/test/API/lang/c/non-mangled/TestCNonMangled.py
 create mode 100644 lldb/test/API/lang/c/non-mangled/main.c

diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index 8efc4c639cca5..3142c81d12ed9 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -19,6 +19,7 @@
 #include "lldb/Utility/Stream.h"
 #include "lldb/lldb-enumerations.h"
 
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Demangle/Demangle.h"
 #include "llvm/Support/Compiler.h"
@@ -48,8 +49,14 @@ Mangled::ManglingScheme 
Mangled::GetManglingScheme(llvm::StringRef const name) {
   if (name.starts_with("_R"))
 return Mangled::eManglingSchemeRustV0;
 
-  if (name.starts_with("_D"))
-return Mangled::eManglingSchemeD;
+  if (name.starts_with("_D")) {
+// A dlang mangled name begins with `_D`, followed by a numeric length.
+// See `SymbolName` and `LName` in
+// https://dlang.org/spec/abi.html#name_mangling
+llvm::StringRef buf = name.drop_front(2);
+if (!buf.empty() && llvm::isDigit(buf.front()))
+  return Mangled::eManglingSchemeD;
+  }
 
   if (name.starts_with("_Z"))
 return Mangled::eManglingSchemeItanium;
diff --git a/lldb/test/API/lang/c/non-mangled/Makefile 
b/lldb/test/API/lang/c/non-mangled/Makefile
new file mode 100644
index 0..695335e068c0c
--- /dev/null
+++ b/lldb/test/API/lang/c/non-mangled/Makefile
@@ -0,0 +1,4 @@
+C_SOURCES := main.c
+CFLAGS_EXTRAS := -std=c99
+
+include Makefile.rules
diff --git a/lldb/test/API/lang/c/non-mangled/TestCNonMangled.py 
b/lldb/test/API/lang/c/non-mangled/TestCNonMangled.py
new file mode 100644
index 0..32bd778fa6eb6
--- /dev/null
+++ b/lldb/test/API/lang/c/non-mangled/TestCNonMangled.py
@@ -0,0 +1,16 @@
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class TestCase(TestBase):
+
+def test_functions_having_dlang_mangling_prefix(self):
+"""
+Ensure C functions with a '_D' prefix alone are not mistakenly treated
+as a Dlang mangled name. A proper Dlang mangling will have digits
+immediately following the '_D' prefix.
+"""
+self.build()
+_, _, thread, _ = lldbutil.run_to_name_breakpoint(self, "_Dfunction")
+symbol = thread.frame[0].symbol
+self.assertEqual(symbol.GetDisplayName(), "_Dfunction")
diff --git a/lldb/test/API/lang/c/non-mangled/main.c 
b/lldb/test/API/lang/c/non-mangled/main.c
new file mode 100644
index 0..ad9d86e5c25a8
--- /dev/null
+++ b/lldb/test/API/lang/c/non-mangled/main.c
@@ -0,0 +1,8 @@
+#include 
+
+void _Dfunction() {}
+
+int main() {
+  _Dfunction();
+  return 0;
+}

>From 8ddb652eae41b1baad462307324963f26ab3230b Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Thu, 30 May 2024 14:25:07 -0700
Subject: [PATCH 2/2] Fix formatting of TestCNonMangled.py

---
 lldb/test/API/lang/c/non-mangled/TestCNonMangled.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lldb/test/API/lang/c/non-mangled/TestCNonMangled.py 
b/lldb/test/API/lang/c/non-mangled/TestCNonMangled.py
index 32bd778fa6eb6..aae2f05263fcd 100644
--- a/lldb/test/API/lang/c/non-mangled/TestCNonMangled.py
+++ b/lldb/test/API/lang/c/non-mangled/TestCNonMangled.py
@@ -3,7 +3,6 @@
 
 
 class TestCase(TestBase):
-
 def test_functions_having_dlang_mangling_prefix(self):
 """
 Ensure C functions with a '_D' prefix alone are not mistakenly treated

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


[Lldb-commits] [lldb] [lldb] Improve identification of Dlang mangled names (PR #93881)

2024-05-30 Thread Dave Lee via lldb-commits

kastiglione wrote:

> This a little bit raises the question why we don't do the same checks for 
> `_R` and `_Z`.

I asked myself the same. Turns out Rust doesn't have a number following the 
`_R` prefix, so it's not as simple. Given that C++ is much more load bearing, I 
didn't want to include changes that affect C++ in this diff. I don't want the 
Dlang functionality to be reverted if something goes wrong with an equivalent 
C++ change.

> It would be even better if the various demanglers in llvm had a quick "could 
> this be mine" check so we didn't have to encode this in lldb.

I agree. That can be a next step.

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


[Lldb-commits] [lldb] [lldb] Improve identification of Dlang mangled names (PR #93881)

2024-05-31 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix Dlang symbol test breakage (PR #94046)

2024-05-31 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/94046

None

>From a783b4c189d3c5387418e58156667ecc8382b5ce Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Fri, 31 May 2024 13:47:24 -0700
Subject: [PATCH] [lldb] Fix Dlang symbol test breakage

---
 lldb/source/Core/Mangled.cpp| 5 +++--
 lldb/unittests/Core/MangledTest.cpp | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index 3142c81d12ed9..387c4fac6b0f8 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -50,11 +50,12 @@ Mangled::ManglingScheme 
Mangled::GetManglingScheme(llvm::StringRef const name) {
 return Mangled::eManglingSchemeRustV0;
 
   if (name.starts_with("_D")) {
-// A dlang mangled name begins with `_D`, followed by a numeric length.
+// A dlang mangled name begins with `_D`, followed by a numeric length. One
+// known exception is the symbol `_Dmain`.
 // See `SymbolName` and `LName` in
 // https://dlang.org/spec/abi.html#name_mangling
 llvm::StringRef buf = name.drop_front(2);
-if (!buf.empty() && llvm::isDigit(buf.front()))
+if (!buf.empty() && (llvm::isDigit(buf.front()) || name == "_Dmain"))
   return Mangled::eManglingSchemeD;
   }
 
diff --git a/lldb/unittests/Core/MangledTest.cpp 
b/lldb/unittests/Core/MangledTest.cpp
index 4efc961d371d3..a3760ba43b3c9 100644
--- a/lldb/unittests/Core/MangledTest.cpp
+++ b/lldb/unittests/Core/MangledTest.cpp
@@ -81,12 +81,12 @@ TEST(MangledTest, ResultForValidDLangName) {
   EXPECT_STREQ(expected_result.GetCString(), the_demangled.GetCString());
 }
 
-TEST(MangledTest, EmptyForInvalidDLangName) {
+TEST(MangledTest, SameForInvalidDLangPrefixedName) {
   ConstString mangled_name("_DDD");
   Mangled the_mangled(mangled_name);
   ConstString the_demangled = the_mangled.GetDemangledName();
 
-  EXPECT_STREQ("", the_demangled.GetCString());
+  EXPECT_STREQ("_DDD", the_demangled.GetCString());
 }
 
 TEST(MangledTest, RecognizeSwiftMangledNames) {

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


[Lldb-commits] [lldb] [lldb] Fix Dlang symbol test breakage (PR #94046)

2024-05-31 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Improve identification of Dlang mangled names (PR #93881)

2024-05-31 Thread Dave Lee via lldb-commits

kastiglione wrote:

@gulfemsavrun apologies, fix is here: #94046 

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


[Lldb-commits] [lldb] [lldb] Fix Dlang symbol test breakage (PR #94046)

2024-05-31 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Improve identification of Dlang mangled names (PR #93881)

2024-06-03 Thread Dave Lee via lldb-commits

kastiglione wrote:

@DavidSpickett thanks, is there a link to a log? I'm curious.

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


[Lldb-commits] [lldb] [lldb] Fix declaration of thread argument in CommandObjectThreadStepWithTypeAndScope (PR #95146)

2024-06-11 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/95146

None

>From 1f4d61ed4e0ab42d5e5ac0937c0af0572f0f8f10 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Mon, 10 Jun 2024 10:46:08 -0700
Subject: [PATCH] [lldb] Fix declaration of thread argument in
 CommandObjectThreadStepWithTypeAndScope

---
 lldb/source/Commands/CommandObjectThread.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Commands/CommandObjectThread.cpp 
b/lldb/source/Commands/CommandObjectThread.cpp
index db96ee2cec383..bb2be560ebfff 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -383,7 +383,7 @@ class CommandObjectThreadStepWithTypeAndScope : public 
CommandObjectParsed {
 eCommandProcessMustBePaused),
 m_step_type(step_type), m_step_scope(step_scope),
 m_class_options("scripted step") {
-AddSimpleArgumentList(eArgTypeThreadID, eArgRepeatOptional);
+AddSimpleArgumentList(eArgTypeThreadIndex, eArgRepeatOptional);
 
 if (step_type == eStepTypeScripted) {
   m_all_options.Append(&m_class_options, LLDB_OPT_SET_1 | LLDB_OPT_SET_2,

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


[Lldb-commits] [lldb] [lldb] Fix declaration of thread argument in CommandObjectThreadStepWithTypeAndScope (PR #95146)

2024-06-11 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix declaration of thread argument in CommandObjectThreadStepWithTypeAndScope (PR #95146)

2024-06-11 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix declaration of thread argument in CommandObjectThreadStepWithTypeAndScope (PR #95146)

2024-06-11 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [DWIMPrint] Move the setting of the result status into dump_val_object (PR #96232)

2024-06-20 Thread Dave Lee via lldb-commits

https://github.com/kastiglione approved this pull request.

thanks

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


[Lldb-commits] [lldb] [GDBRemote] Handle 'heap' memory region info type (PR #105883)

2024-08-23 Thread Dave Lee via lldb-commits

https://github.com/kastiglione approved this pull request.


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


[Lldb-commits] [lldb] [GDBRemote] Handle 'heap' memory region info type (PR #105883)

2024-08-23 Thread Dave Lee via lldb-commits


@@ -1635,6 +1635,8 @@ Status GDBRemoteCommunicationClient::GetMemoryRegionInfo(
   for (llvm::StringRef entry : llvm::split(value, ',')) {
 if (entry == "stack")
   region_info.SetIsStackMemory(MemoryRegionInfo::eYes);
+if (entry == "heap")

kastiglione wrote:

else if?

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


[Lldb-commits] [lldb] [lldb] In-progress — All ValueObjectSP instances are now valid (non-null) but have an error state (PR #74912)

2023-12-19 Thread Dave Lee via lldb-commits

kastiglione wrote:

> ### Goal
>
> Every `ValueObjectSP` will have an actual value and will never be equal to 
> `nullptr`.

I would like to learn more about the goal. It seems like the existing code will 
result in widespread use of `optional>`. Is the plan to 
reduce these cases to a smaller amount? If not, then it's not clear to me how 
having the codebase predominantly use `optional>` is 
better than mostly using `shared_ptr`. Is this refactoring a known 
(named) pattern? Are there other examples of where a `shared_ptr` is 
replaced with `optional>`?

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


[Lldb-commits] [lldb] e19339f - [lldb] Identify Swift-implemented ObjC classes

2023-07-20 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2023-07-20T19:32:12-07:00
New Revision: e19339f5f8c15d4307aaed14309e38e3c87121ac

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

LOG: [lldb] Identify Swift-implemented ObjC classes

Classes implemented in Swift can be exposed to ObjC. For those classes, the ObjC
metadata is incomplete. Specifically, the encoded types of the ivars are 
incomplete. As
one might expect, the Swift metadata _is_ complete. In such cases, the Swift 
runtime
should be consulted when determining the dynamic type of a value.

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

Added: 


Modified: 
lldb/include/lldb/Target/LanguageRuntime.h
lldb/source/Core/ValueObjectDynamicValue.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h

Removed: 




diff  --git a/lldb/include/lldb/Target/LanguageRuntime.h 
b/lldb/include/lldb/Target/LanguageRuntime.h
index 9cc79dc976c4d8..eff79a0bf0d062 100644
--- a/lldb/include/lldb/Target/LanguageRuntime.h
+++ b/lldb/include/lldb/Target/LanguageRuntime.h
@@ -67,6 +67,12 @@ class LanguageRuntime : public Runtime, public 
PluginInterface {
 
   virtual lldb::LanguageType GetLanguageType() const = 0;
 
+  /// Return the preferred language runtime instance, which in most cases will
+  /// be the current instance.
+  virtual LanguageRuntime *GetPreferredLanguageRuntime(ValueObject &in_value) {
+return nullptr;
+  }
+
   virtual bool GetObjectDescription(Stream &str, ValueObject &object) = 0;
 
   virtual bool GetObjectDescription(Stream &str, Value &value,

diff  --git a/lldb/source/Core/ValueObjectDynamicValue.cpp 
b/lldb/source/Core/ValueObjectDynamicValue.cpp
index 9db50aeeec9eaa..e6e30dce9d1e4a 100644
--- a/lldb/source/Core/ValueObjectDynamicValue.cpp
+++ b/lldb/source/Core/ValueObjectDynamicValue.cpp
@@ -149,7 +149,18 @@ bool ValueObjectDynamicValue::UpdateValue() {
   if (known_type != lldb::eLanguageTypeUnknown &&
   known_type != lldb::eLanguageTypeC) {
 runtime = process->GetLanguageRuntime(known_type);
-if (runtime)
+if (auto *preferred_runtime =
+runtime->GetPreferredLanguageRuntime(*m_parent)) {
+  // Try the preferred runtime first.
+  found_dynamic_type = preferred_runtime->GetDynamicTypeAndAddress(
+  *m_parent, m_use_dynamic, class_type_or_name, dynamic_address,
+  value_type);
+  if (found_dynamic_type)
+// Set the operative `runtime` for later use in this function.
+runtime = preferred_runtime;
+}
+if (!found_dynamic_type)
+  // Fallback to the runtime for `known_type`.
   found_dynamic_type = runtime->GetDynamicTypeAndAddress(
   *m_parent, m_use_dynamic, class_type_or_name, dynamic_address,
   value_type);

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
index 80ba352228c543..39969520b74556 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
@@ -10,8 +10,10 @@
 
 #include "lldb/Expression/FunctionCaller.h"
 #include "lldb/Target/ABI.h"
+#include "lldb/Target/Language.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
+#include "lldb/lldb-enumerations.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -668,6 +670,19 @@ uint64_t ClassDescriptorV2::GetInstanceSize() {
   return 0;
 }
 
+// From the ObjC runtime.
+static uint8_t IS_SWIFT_STABLE = 1U << 1;
+
+LanguageType ClassDescriptorV2::GetImplementationLanguage() const {
+  std::unique_ptr objc_class;
+  if (auto *process = m_runtime.GetProcess())
+if (Read_objc_class(process, objc_class))
+  if (objc_class->m_flags & IS_SWIFT_STABLE)
+return lldb::eLanguageTypeSwift;
+
+  return lldb::eLanguageTypeObjC;
+}
+
 ClassDescriptorV2::iVarsStorage::iVarsStorage() : m_ivars(), m_mutex() {}
 
 size_t ClassDescriptorV2::iVarsStorage::size() { return m_ivars.size(); }

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
index 09e5383d7fb95a..d298af92ba5e62 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCCl

[Lldb-commits] [lldb] a6ff60e - [lldb] Delete unused LibcxxOptionalSummaryProvider (NFC)

2023-07-20 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2023-07-20T19:32:58-07:00
New Revision: a6ff60ecdd061cc21383108ac092ae4a700f9143

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

LOG: [lldb] Delete unused LibcxxOptionalSummaryProvider (NFC)

No longer needed following refactoring in D115178.

Added: 


Modified: 
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.h

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index cb601603a3c43d..cae17ef992b215 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -76,27 +76,6 @@ 
lldb_private::formatters::GetSecondValueOfLibCXXCompressedPair(
   return value;
 }
 
-bool lldb_private::formatters::LibcxxOptionalSummaryProvider(
-ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
-  ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
-  if (!valobj_sp)
-return false;
-
-  // An optional either contains a value or not, the member __engaged_ is
-  // a bool flag, it is true if the optional has a value and false otherwise.
-  ValueObjectSP engaged_sp(valobj_sp->GetChildMemberWithName("__engaged_"));
-
-  if (!engaged_sp)
-return false;
-
-  llvm::StringRef engaged_as_cstring(
-  engaged_sp->GetValueAsUnsigned(0) == 1 ? "true" : "false");
-
-  stream.Printf(" Has Value=%s ", engaged_as_cstring.data());
-
-  return true;
-}
-
 bool lldb_private::formatters::LibcxxFunctionSummaryProvider(
 ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
 

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
index 2dae71b24419d6..f65801e2cb1b9c 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
@@ -59,10 +59,6 @@ bool LibcxxWStringViewSummaryProvider(
 ValueObject &valobj, Stream &stream,
 const TypeSummaryOptions &options); // libc++ std::wstring_view
 
-bool LibcxxOptionalSummaryProvider(
-ValueObject &valobj, Stream &stream,
-const TypeSummaryOptions &options); // libc++ std::optional<>
-
 bool LibcxxSmartPointerSummaryProvider(
 ValueObject &valobj, Stream &stream,
 const TypeSummaryOptions



___
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 setting to customize the prompt color (PR #66218)

2023-09-13 Thread Dave Lee via lldb-commits

kastiglione wrote:

> You will need access to the debugger, target, process etc. Currently Editline 
> lives in Host, so we'd have to move that out into Core to avoid circular 
> dependencies.

can we wire up the ansi color formatting without supporting all these other 
bits of data?

if we're going to eventually support formatting in the prompt, it seems like we 
should just do that, instead of adding settings and then later removing them.

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


[Lldb-commits] [lldb] [lldb][Docs] Document our major differences from the LLVM style (PR #66345)

2023-09-19 Thread Dave Lee via lldb-commits


@@ -18,19 +18,45 @@ Please refer to the `LLVM Developer Policy
 authoring and uploading a patch. LLDB differs from the LLVM Developer
 Policy in the following respects.
 
- - **Test infrastructure**: Like LLVM it is  important to submit tests with 
your
-   patches, but note that LLDB uses a different system for tests. Refer to the
-   `test documentation `_ for more details and the ``lldb/test``
-   folder on disk for examples.
-
- - **Coding Style**: LLDB's code style differs from
-   `LLVM's coding style `_.
-   Unfortunately there is no document describing the differences. Please be
-   consistent with the existing code.
-
 For anything not explicitly listed here, assume that LLDB follows the LLVM
 policy.
 
+Coding Style
+
+
+LLDB's code style differs from `LLVM's coding style 
`_
+in a few ways. The 2 main ones are:
+
+* `Variable and function naming 
`_:
+
+  * Variables are ``snake_case``.
+
+  * Functions and methods are ``UpperCamelCase``.
+
+  * Static, global and member variables have ``s_``, ``g_`` and ``_m``

kastiglione wrote:

typo: `_m` should be `m_`.

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


[Lldb-commits] [lldb] [lldb] Fix stdcpp type summary mistakenly marked as regex (NFC) (PR #66949)

2023-09-20 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/66949

`std::basic_string` is not a regex, and treating it as such could 
unintentionally
cause a formatter to substring match a template type parameter, for example:
`std::vector>`.

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


>From b943b22bf585acfa65ec812f3af0d48865c9b8ac Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Thu, 17 Aug 2023 16:09:15 -0700
Subject: [PATCH] [lldb] Fix stdcpp type summary mistakenly marked as regex
 (NFC)

`std::basic_string` is not a regex, and treating it as such could 
unintentionally
cause a formatter to substring match a template type parameter, for example:
`std::vector>`.

Differential Revision: https://reviews.llvm.org/D158663
---
 lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 3d709e3d6759556..c1743a5e0a418dd 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1009,7 +1009,7 @@ static void 
LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   cpp_category_sp->AddTypeSummary("std::string", eFormatterMatchExact,
   std_string_summary_sp);
   cpp_category_sp->AddTypeSummary("std::basic_string",
-  eFormatterMatchRegex, std_string_summary_sp);
+  eFormatterMatchExact, std_string_summary_sp);
   cpp_category_sp->AddTypeSummary(
   "std::basic_string,std::allocator >",
   eFormatterMatchExact, std_string_summary_sp);

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


[Lldb-commits] [lldb] [lldb] Fix stdcpp type summary mistakenly marked as regex (NFC) (PR #66949)

2023-09-20 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] Change the return type of CalculateNumChildren to uint32_t. (PR #83501)

2024-02-29 Thread Dave Lee via lldb-commits

https://github.com/kastiglione approved this pull request.


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


[Lldb-commits] [lldb] [lldb] Extract getter function for experimental target properties (NFC) (PR #83504)

2024-02-29 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/83504

None

>From 969f441344e179c9167fe707cf8f01edae6dbfc5 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Thu, 29 Feb 2024 15:38:22 -0800
Subject: [PATCH] [lldb] Extract getter function for experimental target
 properties (NFC)

---
 lldb/include/lldb/Target/Target.h |  6 --
 lldb/source/Target/Target.cpp | 24 +---
 2 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 8f57358981d4d2..2c2e6b2831ccee 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -244,8 +244,6 @@ class TargetProperties : public Properties {
 
   bool GetInjectLocalVariables(ExecutionContext *exe_ctx) const;
 
-  void SetInjectLocalVariables(ExecutionContext *exe_ctx, bool b);
-
   void SetRequireHardwareBreakpoints(bool b);
 
   bool GetRequireHardwareBreakpoints() const;
@@ -259,6 +257,10 @@ class TargetProperties : public Properties {
   bool GetDebugUtilityExpression() const;
 
 private:
+  std::optional
+  GetExperimentalPropertyValue(size_t prop_idx,
+   ExecutionContext *exe_ctx = nullptr) const;
+
   // Callbacks for m_launch_info.
   void Arg0ValueChangedCallback();
   void RunArgsValueChangedCallback();
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index e982a30a3ae4ff..09b0ac42631d1a 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -43,6 +43,7 @@
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Target/ABI.h"
+#include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Language.h"
 #include "lldb/Target/LanguageRuntime.h"
 #include "lldb/Target/Process.h"
@@ -4227,28 +4228,21 @@ void TargetProperties::UpdateLaunchInfoFromProperties() 
{
   DisableSTDIOValueChangedCallback();
 }
 
-bool TargetProperties::GetInjectLocalVariables(
-ExecutionContext *exe_ctx) const {
+std::optional TargetProperties::GetExperimentalPropertyValue(
+size_t prop_idx, ExecutionContext *exe_ctx) const {
   const Property *exp_property =
   m_collection_sp->GetPropertyAtIndex(ePropertyExperimental, exe_ctx);
   OptionValueProperties *exp_values =
   exp_property->GetValue()->GetAsProperties();
   if (exp_values)
-return exp_values
-->GetPropertyAtIndexAs(ePropertyInjectLocalVars, exe_ctx)
-.value_or(true);
-  else
-return true;
+return exp_values->GetPropertyAtIndexAs(prop_idx, exe_ctx);
+  return std::nullopt;
 }
 
-void TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx,
-   bool b) {
-  const Property *exp_property =
-  m_collection_sp->GetPropertyAtIndex(ePropertyExperimental, exe_ctx);
-  OptionValueProperties *exp_values =
-  exp_property->GetValue()->GetAsProperties();
-  if (exp_values)
-exp_values->SetPropertyAtIndex(ePropertyInjectLocalVars, true, exe_ctx);
+bool TargetProperties::GetInjectLocalVariables(
+ExecutionContext *exe_ctx) const {
+  return GetExperimentalPropertyValue(ePropertyInjectLocalVars, exe_ctx)
+  .value_or(true);
 }
 
 ArchSpec TargetProperties::GetDefaultArchitecture() const {

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


[Lldb-commits] [lldb] [lldb] Extract getter function for experimental target properties (NFC) (PR #83504)

2024-02-29 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Extract getter function for experimental target properties (NFC) (PR #83504)

2024-02-29 Thread Dave Lee via lldb-commits


@@ -4227,28 +4228,21 @@ void TargetProperties::UpdateLaunchInfoFromProperties() 
{
   DisableSTDIOValueChangedCallback();
 }
 
-bool TargetProperties::GetInjectLocalVariables(
-ExecutionContext *exe_ctx) const {
+std::optional TargetProperties::GetExperimentalPropertyValue(
+size_t prop_idx, ExecutionContext *exe_ctx) const {
   const Property *exp_property =
   m_collection_sp->GetPropertyAtIndex(ePropertyExperimental, exe_ctx);
   OptionValueProperties *exp_values =
   exp_property->GetValue()->GetAsProperties();
   if (exp_values)
-return exp_values
-->GetPropertyAtIndexAs(ePropertyInjectLocalVars, exe_ctx)
-.value_or(true);
-  else
-return true;
+return exp_values->GetPropertyAtIndexAs(prop_idx, exe_ctx);
+  return std::nullopt;
 }
 
-void TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx,
-   bool b) {

kastiglione wrote:

huh, `b` wasn't even being used.

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


[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)

2024-03-05 Thread Dave Lee via lldb-commits


@@ -333,3 +335,41 @@ def expectedCompiler(compilers):
 return True
 
 return False
+
+
+# This is a helper function to determine if a specific version of Xcode's 
linker
+# contains a TLS bug. We want to skip TLS tests if they contain this bug, but
+# adding a linker/linker_version conditions to a decorator is challenging due 
to
+# the number of ways linkers can enter the build process.
+def darwinLinkerHasTLSBug():
+"""Returns true iff a test is running on a darwin platform and the host 
linker is between versions 1000 and 1109."""
+darwin_platforms = lldbplatform.translate(lldbplatform.darwin_all)
+if getPlatform() not in darwin_platforms:
+return False
+
+linker_path = (
+subprocess.check_output(["xcrun", "--find", 
"ld"]).rstrip().decode("utf-8")

kastiglione wrote:

I believe this is more conventional:

```suggestion
subprocess.check_output(["xcrun", "--find", "ld"], text=True).rstrip()
```

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


[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)

2024-03-05 Thread Dave Lee via lldb-commits


@@ -333,3 +335,41 @@ def expectedCompiler(compilers):
 return True
 
 return False
+
+
+# This is a helper function to determine if a specific version of Xcode's 
linker
+# contains a TLS bug. We want to skip TLS tests if they contain this bug, but
+# adding a linker/linker_version conditions to a decorator is challenging due 
to
+# the number of ways linkers can enter the build process.
+def darwinLinkerHasTLSBug():
+"""Returns true iff a test is running on a darwin platform and the host 
linker is between versions 1000 and 1109."""
+darwin_platforms = lldbplatform.translate(lldbplatform.darwin_all)
+if getPlatform() not in darwin_platforms:
+return False
+
+linker_path = (
+subprocess.check_output(["xcrun", "--find", 
"ld"]).rstrip().decode("utf-8")
+)
+if not is_exe(linker_path):
+return False
+
+raw_linker_info = (
+subprocess.check_output([linker_path, "-version_details"])
+.rstrip()
+.decode("utf-8")
+)
+parsed_linker_info = json.loads(raw_linker_info)
+if "version" not in parsed_linker_info:
+return False
+
+raw_version = parsed_linker_info["version"]
+version = None
+try:
+version = int(raw_version)

kastiglione wrote:

this this guaranteed to always be an integer? Note that `ld -ld_classic 
-version_details` has a version of "954.7" on my machine. Were there any 
releases with decimals in the range that has the bug?

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


[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)

2024-03-05 Thread Dave Lee via lldb-commits


@@ -333,3 +335,41 @@ def expectedCompiler(compilers):
 return True
 
 return False
+
+
+# This is a helper function to determine if a specific version of Xcode's 
linker
+# contains a TLS bug. We want to skip TLS tests if they contain this bug, but
+# adding a linker/linker_version conditions to a decorator is challenging due 
to
+# the number of ways linkers can enter the build process.
+def darwinLinkerHasTLSBug():
+"""Returns true iff a test is running on a darwin platform and the host 
linker is between versions 1000 and 1109."""
+darwin_platforms = lldbplatform.translate(lldbplatform.darwin_all)
+if getPlatform() not in darwin_platforms:
+return False
+
+linker_path = (
+subprocess.check_output(["xcrun", "--find", 
"ld"]).rstrip().decode("utf-8")
+)
+if not is_exe(linker_path):
+return False
+
+raw_linker_info = (
+subprocess.check_output([linker_path, "-version_details"])
+.rstrip()
+.decode("utf-8")
+)
+parsed_linker_info = json.loads(raw_linker_info)
+if "version" not in parsed_linker_info:
+return False
+
+raw_version = parsed_linker_info["version"]
+version = None
+try:
+version = int(raw_version)
+except:
+return False
+
+if version is None:
+return False
+
+return 1000 <= version and version <= 1109

kastiglione wrote:

```suggestion
try:
version = int(raw_version)
return 1000 <= version <= 1109
except:
return False
```

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


[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)

2024-03-05 Thread Dave Lee via lldb-commits


@@ -333,3 +335,41 @@ def expectedCompiler(compilers):
 return True
 
 return False
+
+
+# This is a helper function to determine if a specific version of Xcode's 
linker
+# contains a TLS bug. We want to skip TLS tests if they contain this bug, but
+# adding a linker/linker_version conditions to a decorator is challenging due 
to
+# the number of ways linkers can enter the build process.
+def darwinLinkerHasTLSBug():

kastiglione wrote:

should there be two functions here? A generic function that can check for 
arbitrary version ranges, and then a specific `darwinLinkerHasTLSBug` which is 
implemented as:

```py
def darwinLinkerHasTLSBug():
return 1000 <= checkDarwinLinkerVersion() <= 1109
```

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


[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)

2024-03-05 Thread Dave Lee via lldb-commits


@@ -333,3 +335,41 @@ def expectedCompiler(compilers):
 return True
 
 return False
+
+
+# This is a helper function to determine if a specific version of Xcode's 
linker
+# contains a TLS bug. We want to skip TLS tests if they contain this bug, but
+# adding a linker/linker_version conditions to a decorator is challenging due 
to
+# the number of ways linkers can enter the build process.
+def darwinLinkerHasTLSBug():
+"""Returns true iff a test is running on a darwin platform and the host 
linker is between versions 1000 and 1109."""
+darwin_platforms = lldbplatform.translate(lldbplatform.darwin_all)
+if getPlatform() not in darwin_platforms:
+return False
+
+linker_path = (
+subprocess.check_output(["xcrun", "--find", 
"ld"]).rstrip().decode("utf-8")
+)
+if not is_exe(linker_path):
+return False
+
+raw_linker_info = (
+subprocess.check_output([linker_path, "-version_details"])
+.rstrip()
+.decode("utf-8")
+)
+parsed_linker_info = json.loads(raw_linker_info)
+if "version" not in parsed_linker_info:
+return False
+
+raw_version = parsed_linker_info["version"]

kastiglione wrote:

```suggestion
raw_version = parsed_linker_info.get("version")
```

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


[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)

2024-03-05 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)

2024-03-05 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)

2024-03-06 Thread Dave Lee via lldb-commits

kastiglione wrote:

We're going to need this logic in a couple from shell tests too.

Should we:
1. Duplicate the logic into lit.cfg.py?
2. Import lldbplatformutil.py into lit.cfg.py? (are there any python 
structure/layout issues that would complicate this?)
3. Put the logic in an independent location and have both lit.cfg.py and 
lldbplatformutil.py import that?

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


[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld64 bug (PR #84246)

2024-03-06 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/84246

None

>From 1fb13a2d034dbea1d1ba2ef87354199a815f3788 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Wed, 6 Mar 2024 14:23:05 -0800
Subject: [PATCH] [lldb] Disable shell tests affected by ld64 bug

---
 lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test|  2 +-
 .../Shell/Unwind/thread-step-out-ret-addr-check.test |  2 +-
 lldb/test/Shell/lit.cfg.py   | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test 
b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test
index 3df9906394f432..783bfd45c4669a 100644
--- a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test
+++ b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test
@@ -1,7 +1,7 @@
 # Test handing of dwarf expressions specifying the location of registers, if
 # those expressions refer to the frame's CFA value.
 
-# UNSUPPORTED: system-windows
+# UNSUPPORTED: system-windows, ld64-tls-bug
 # REQUIRES: target-x86_64, native
 
 # RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/eh-frame-dwarf-unwind.s -o %t
diff --git a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test 
b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
index 682b0e5332b1c5..a2b5ae8a9e3e5f 100644
--- a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -2,7 +2,7 @@
 # points to non-executable memory.
 
 # REQUIRES: target-x86_64
-# UNSUPPORTED: system-windows
+# UNSUPPORTED: system-windows, ld64-tls-bug
 
 # RUN: %clang_host %p/Inputs/call-asm.c -x assembler-with-cpp 
%p/Inputs/thread-step-out-ret-addr-check.s -o %t
 # RUN: not %lldb %t -s %s -b 2>&1 | FileCheck %s
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index d75c1f532e147f..6d41dc7d8d7325 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -1,5 +1,6 @@
 # -*- Python -*-
 
+import json
 import os
 import platform
 import re
@@ -179,3 +180,14 @@ def calculate_arch_features(arch_string):
 
 if "LD_PRELOAD" in os.environ:
 config.available_features.add("ld_preload-present")
+
+# Determine if a specific version of Xcode's linker contains a TLS bug. We want
+# to skip TLS tests if they contain this bug.
+try:
+raw_version_details = subprocess.check_output(("xcrun", "ld", 
"-version_details"))
+version_details = json.loads(raw_version_details)
+version = version_details.get("version", "0")
+if 1000 <= float(version) <= 1109:
+config.available_features.add("ld64-tls-bug")
+except:
+pass

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


[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld64 bug (PR #84246)

2024-03-06 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)

2024-03-06 Thread Dave Lee via lldb-commits

kastiglione wrote:

To start with option #​1 I created 
https://github.com/llvm/llvm-project/pull/84246

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


[Lldb-commits] [lldb] [lldb] Log module build remarks to types log too (PR #84260)

2024-03-06 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/84260

None

>From c828091ab173a2c23e10649ad7b131a02ae4e6c1 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Wed, 6 Mar 2024 15:55:38 -0800
Subject: [PATCH] [lldb] Log module build remarks to types log too

---
 .../Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index 5ce0d35378230c..89e56213c1bfe0 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -191,7 +191,7 @@ void StoringDiagnosticConsumer::EndSourceFile() {
 
 bool StoringDiagnosticConsumer::HandleModuleRemark(
 const clang::Diagnostic &info) {
-  Log *log = GetLog(LLDBLog::Expressions);
+  Log *log = GetLog(LLDBLog::Types | LLDBLog::Expressions);
   switch (info.getID()) {
   case clang::diag::remark_module_build: {
 const auto &module_name = info.getArgStdStr(0);

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


[Lldb-commits] [lldb] [lldb] Remove unused #includes in ClangModulesDeclVendor.cpp (PR #84262)

2024-03-06 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/84262

None

>From ba079bd1d130a460e481b6c10b33f1ddd58421a3 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Wed, 6 Mar 2024 16:02:13 -0800
Subject: [PATCH] [lldb] Remove unused #includes in ClangModulesDeclVendor.cpp

---
 .../ExpressionParser/Clang/ClangModulesDeclVendor.cpp | 8 
 1 file changed, 8 deletions(-)

diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index 5ce0d35378230c..cc5250ca0f7883 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -8,7 +8,6 @@
 
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticFrontend.h"
-#include "clang/Basic/DiagnosticSerialization.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendActions.h"
@@ -19,20 +18,15 @@
 #include "clang/Sema/Lookup.h"
 #include "clang/Serialization/ASTReader.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Threading.h"
 
 #include "ClangHost.h"
 #include "ClangModulesDeclVendor.h"
-#include "ModuleDependencyCollector.h"
 
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/Progress.h"
-#include "lldb/Host/Host.h"
-#include "lldb/Host/HostInfo.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/SourceModule.h"
 #include "lldb/Target/Target.h"
@@ -40,10 +34,8 @@
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
-#include "lldb/Utility/StreamString.h"
 
 #include 
-#include 
 
 using namespace lldb_private;
 

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


[Lldb-commits] [lldb] [lldb] Minor cleanup in StoringDiagnosticConsumer (PR #84263)

2024-03-06 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/84263

None

>From e5bed6b190687cc31ecb69da006bc93d9284994a Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Wed, 6 Mar 2024 16:03:22 -0800
Subject: [PATCH] [lldb] Minor cleanup in StoringDiagnosticConsumer

---
 .../ExpressionParser/Clang/ClangModulesDeclVendor.cpp  | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index 5ce0d35378230c..7fdaa2762be56d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -80,7 +80,6 @@ class StoringDiagnosticConsumer : public 
clang::DiagnosticConsumer {
   std::shared_ptr m_os;
   /// Output string filled by m_os. Will be reused for different diagnostics.
   std::string m_output;
-  Log *m_log;
   /// A Progress with explicitly managed lifetime.
   std::unique_ptr m_current_progress_up;
   std::vector m_module_build_stack;
@@ -142,12 +141,10 @@ class ClangModulesDeclVendorImpl : public 
ClangModulesDeclVendor {
 } // anonymous namespace
 
 StoringDiagnosticConsumer::StoringDiagnosticConsumer() {
-  m_log = GetLog(LLDBLog::Expressions);
-
-  clang::DiagnosticOptions *m_options = new clang::DiagnosticOptions();
+  clang::DiagnosticOptions *options = new clang::DiagnosticOptions();
   m_os = std::make_shared(m_output);
   m_diag_printer =
-  std::make_shared(*m_os, m_options);
+  std::make_shared(*m_os, options);
 }
 
 void StoringDiagnosticConsumer::HandleDiagnostic(

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


[Lldb-commits] [lldb] [lldb] Minor cleanup in StoringDiagnosticConsumer (PR #84263)

2024-03-06 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/84263

>From e5bed6b190687cc31ecb69da006bc93d9284994a Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Wed, 6 Mar 2024 16:03:22 -0800
Subject: [PATCH 1/2] [lldb] Minor cleanup in StoringDiagnosticConsumer

---
 .../ExpressionParser/Clang/ClangModulesDeclVendor.cpp  | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index 5ce0d35378230c..7fdaa2762be56d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -80,7 +80,6 @@ class StoringDiagnosticConsumer : public 
clang::DiagnosticConsumer {
   std::shared_ptr m_os;
   /// Output string filled by m_os. Will be reused for different diagnostics.
   std::string m_output;
-  Log *m_log;
   /// A Progress with explicitly managed lifetime.
   std::unique_ptr m_current_progress_up;
   std::vector m_module_build_stack;
@@ -142,12 +141,10 @@ class ClangModulesDeclVendorImpl : public 
ClangModulesDeclVendor {
 } // anonymous namespace
 
 StoringDiagnosticConsumer::StoringDiagnosticConsumer() {
-  m_log = GetLog(LLDBLog::Expressions);
-
-  clang::DiagnosticOptions *m_options = new clang::DiagnosticOptions();
+  clang::DiagnosticOptions *options = new clang::DiagnosticOptions();
   m_os = std::make_shared(m_output);
   m_diag_printer =
-  std::make_shared(*m_os, m_options);
+  std::make_shared(*m_os, options);
 }
 
 void StoringDiagnosticConsumer::HandleDiagnostic(

>From 13bfecf4740f7a3cf8cef98a91f4560fe6a59cfd Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Wed, 6 Mar 2024 16:10:37 -0800
Subject: [PATCH 2/2] more cleanup

---
 .../Clang/ClangModulesDeclVendor.cpp | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index 7fdaa2762be56d..2a992d6b36208d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -75,9 +75,11 @@ class StoringDiagnosticConsumer : public 
clang::DiagnosticConsumer {
   std::vector m_diagnostics;
   /// The DiagnosticPrinter used for creating the full diagnostic messages
   /// that are stored in m_diagnostics.
-  std::shared_ptr m_diag_printer;
+  std::unique_ptr m_diag_printer;
   /// Output stream of m_diag_printer.
-  std::shared_ptr m_os;
+  std::unique_ptr m_os;
+  /// Diagnostics options of m_diag_printer.
+  std::unique_ptr m_options;
   /// Output string filled by m_os. Will be reused for different diagnostics.
   std::string m_output;
   /// A Progress with explicitly managed lifetime.
@@ -141,10 +143,10 @@ class ClangModulesDeclVendorImpl : public 
ClangModulesDeclVendor {
 } // anonymous namespace
 
 StoringDiagnosticConsumer::StoringDiagnosticConsumer() {
-  clang::DiagnosticOptions *options = new clang::DiagnosticOptions();
-  m_os = std::make_shared(m_output);
+  m_options = std::make_unique();
+  m_os = std::make_unique(m_output);
   m_diag_printer =
-  std::make_shared(*m_os, options);
+  std::make_unique(*m_os, m_options.get());
 }
 
 void StoringDiagnosticConsumer::HandleDiagnostic(

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


[Lldb-commits] [lldb] [lldb] Minor cleanup in StoringDiagnosticConsumer (PR #84263)

2024-03-06 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Minor cleanup in StoringDiagnosticConsumer (PR #84263)

2024-03-06 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Minor cleanup in StoringDiagnosticConsumer (PR #84263)

2024-03-06 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Remove unused #includes in ClangModulesDeclVendor.cpp (PR #84262)

2024-03-06 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Extract getter function for experimental target properties (NFC) (PR #83504)

2024-03-06 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Log module build remarks to types log too (PR #84260)

2024-03-06 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld64 bug (PR #84246)

2024-03-07 Thread Dave Lee via lldb-commits


@@ -179,3 +180,14 @@ def calculate_arch_features(arch_string):
 
 if "LD_PRELOAD" in os.environ:
 config.available_features.add("ld_preload-present")
+

kastiglione wrote:

my thinking is that the darwin check is baked into the invocation of xcrun. If 
you think it's better to check for darwin explicitly, I will make that change 
it.

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


[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld64 bug (PR #84246)

2024-03-07 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/84246

>From 1fb13a2d034dbea1d1ba2ef87354199a815f3788 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Wed, 6 Mar 2024 14:23:05 -0800
Subject: [PATCH 1/2] [lldb] Disable shell tests affected by ld64 bug

---
 lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test|  2 +-
 .../Shell/Unwind/thread-step-out-ret-addr-check.test |  2 +-
 lldb/test/Shell/lit.cfg.py   | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test 
b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test
index 3df9906394f432..783bfd45c4669a 100644
--- a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test
+++ b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test
@@ -1,7 +1,7 @@
 # Test handing of dwarf expressions specifying the location of registers, if
 # those expressions refer to the frame's CFA value.
 
-# UNSUPPORTED: system-windows
+# UNSUPPORTED: system-windows, ld64-tls-bug
 # REQUIRES: target-x86_64, native
 
 # RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/eh-frame-dwarf-unwind.s -o %t
diff --git a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test 
b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
index 682b0e5332b1c5..a2b5ae8a9e3e5f 100644
--- a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -2,7 +2,7 @@
 # points to non-executable memory.
 
 # REQUIRES: target-x86_64
-# UNSUPPORTED: system-windows
+# UNSUPPORTED: system-windows, ld64-tls-bug
 
 # RUN: %clang_host %p/Inputs/call-asm.c -x assembler-with-cpp 
%p/Inputs/thread-step-out-ret-addr-check.s -o %t
 # RUN: not %lldb %t -s %s -b 2>&1 | FileCheck %s
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index d75c1f532e147f..6d41dc7d8d7325 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -1,5 +1,6 @@
 # -*- Python -*-
 
+import json
 import os
 import platform
 import re
@@ -179,3 +180,14 @@ def calculate_arch_features(arch_string):
 
 if "LD_PRELOAD" in os.environ:
 config.available_features.add("ld_preload-present")
+
+# Determine if a specific version of Xcode's linker contains a TLS bug. We want
+# to skip TLS tests if they contain this bug.
+try:
+raw_version_details = subprocess.check_output(("xcrun", "ld", 
"-version_details"))
+version_details = json.loads(raw_version_details)
+version = version_details.get("version", "0")
+if 1000 <= float(version) <= 1109:
+config.available_features.add("ld64-tls-bug")
+except:
+pass

>From 92f29840ba8df95b0fb8fa7fd2bf9a679e749849 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Thu, 7 Mar 2024 10:10:22 -0800
Subject: [PATCH 2/2] The bug is not TLS specific

---
 lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test  | 2 +-
 lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test | 2 +-
 lldb/test/Shell/lit.cfg.py | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test 
b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test
index 783bfd45c4669a..7b5d6650fe2f75 100644
--- a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test
+++ b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test
@@ -1,7 +1,7 @@
 # Test handing of dwarf expressions specifying the location of registers, if
 # those expressions refer to the frame's CFA value.
 
-# UNSUPPORTED: system-windows, ld64-tls-bug
+# UNSUPPORTED: system-windows, ld_new-bug
 # REQUIRES: target-x86_64, native
 
 # RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/eh-frame-dwarf-unwind.s -o %t
diff --git a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test 
b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
index a2b5ae8a9e3e5f..9bc7c78f79b26b 100644
--- a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -2,7 +2,7 @@
 # points to non-executable memory.
 
 # REQUIRES: target-x86_64
-# UNSUPPORTED: system-windows, ld64-tls-bug
+# UNSUPPORTED: system-windows, ld_new-bug
 
 # RUN: %clang_host %p/Inputs/call-asm.c -x assembler-with-cpp 
%p/Inputs/thread-step-out-ret-addr-check.s -o %t
 # RUN: not %lldb %t -s %s -b 2>&1 | FileCheck %s
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 6d41dc7d8d7325..1362dfcf7c4354 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -181,13 +181,13 @@ def calculate_arch_features(arch_string):
 if "LD_PRELOAD" in os.environ:
 config.available_features.add("ld_preload-present")
 
-# Determine if a specific version of Xcode's linker contains a TLS bug. We want
-# to skip TLS tests if they contain this bug.
+# Determine if a specific version of Xcode's linker contains a bug. We want to
+# skip affected tests if they contain this bug.
 try:
 raw_version_details = subprocess.check_outpu

[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld64 bug (PR #84246)

2024-03-07 Thread Dave Lee via lldb-commits

kastiglione wrote:

Called it `ld_new-bug`. If it's not the TLS bug, I wonder if the version range 
is correct.

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


[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld_new bug (PR #84246)

2024-03-07 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Minor cleanup in StoringDiagnosticConsumer (PR #84263)

2024-03-07 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld_new bug (PR #84246)

2024-03-07 Thread Dave Lee via lldb-commits

kastiglione wrote:

I think this should be merged, and if either end of the version range proves to 
be too limited, we can increase the range.

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


[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld_new bug (PR #84246)

2024-03-07 Thread Dave Lee via lldb-commits


@@ -179,3 +180,14 @@ def calculate_arch_features(arch_string):
 
 if "LD_PRELOAD" in os.environ:
 config.available_features.add("ld_preload-present")
+
+# Determine if a specific version of Xcode's linker contains a bug. We want to
+# skip affected tests if they contain this bug.
+try:
+raw_version_details = subprocess.check_output(("xcrun", "ld", 
"-version_details"))
+version_details = json.loads(raw_version_details)
+version = version_details.get("version", "0")
+if 1000 <= float(version) <= 1109:

kastiglione wrote:

float will be insufficient, this will need to handle versions such as `1100.1.1`

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


[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld_new bug (PR #84246)

2024-03-07 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/84246

>From 1fb13a2d034dbea1d1ba2ef87354199a815f3788 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Wed, 6 Mar 2024 14:23:05 -0800
Subject: [PATCH 1/3] [lldb] Disable shell tests affected by ld64 bug

---
 lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test|  2 +-
 .../Shell/Unwind/thread-step-out-ret-addr-check.test |  2 +-
 lldb/test/Shell/lit.cfg.py   | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test 
b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test
index 3df9906394f432..783bfd45c4669a 100644
--- a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test
+++ b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test
@@ -1,7 +1,7 @@
 # Test handing of dwarf expressions specifying the location of registers, if
 # those expressions refer to the frame's CFA value.
 
-# UNSUPPORTED: system-windows
+# UNSUPPORTED: system-windows, ld64-tls-bug
 # REQUIRES: target-x86_64, native
 
 # RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/eh-frame-dwarf-unwind.s -o %t
diff --git a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test 
b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
index 682b0e5332b1c5..a2b5ae8a9e3e5f 100644
--- a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -2,7 +2,7 @@
 # points to non-executable memory.
 
 # REQUIRES: target-x86_64
-# UNSUPPORTED: system-windows
+# UNSUPPORTED: system-windows, ld64-tls-bug
 
 # RUN: %clang_host %p/Inputs/call-asm.c -x assembler-with-cpp 
%p/Inputs/thread-step-out-ret-addr-check.s -o %t
 # RUN: not %lldb %t -s %s -b 2>&1 | FileCheck %s
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index d75c1f532e147f..6d41dc7d8d7325 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -1,5 +1,6 @@
 # -*- Python -*-
 
+import json
 import os
 import platform
 import re
@@ -179,3 +180,14 @@ def calculate_arch_features(arch_string):
 
 if "LD_PRELOAD" in os.environ:
 config.available_features.add("ld_preload-present")
+
+# Determine if a specific version of Xcode's linker contains a TLS bug. We want
+# to skip TLS tests if they contain this bug.
+try:
+raw_version_details = subprocess.check_output(("xcrun", "ld", 
"-version_details"))
+version_details = json.loads(raw_version_details)
+version = version_details.get("version", "0")
+if 1000 <= float(version) <= 1109:
+config.available_features.add("ld64-tls-bug")
+except:
+pass

>From 92f29840ba8df95b0fb8fa7fd2bf9a679e749849 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Thu, 7 Mar 2024 10:10:22 -0800
Subject: [PATCH 2/3] The bug is not TLS specific

---
 lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test  | 2 +-
 lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test | 2 +-
 lldb/test/Shell/lit.cfg.py | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test 
b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test
index 783bfd45c4669a..7b5d6650fe2f75 100644
--- a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test
+++ b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind.test
@@ -1,7 +1,7 @@
 # Test handing of dwarf expressions specifying the location of registers, if
 # those expressions refer to the frame's CFA value.
 
-# UNSUPPORTED: system-windows, ld64-tls-bug
+# UNSUPPORTED: system-windows, ld_new-bug
 # REQUIRES: target-x86_64, native
 
 # RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/eh-frame-dwarf-unwind.s -o %t
diff --git a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test 
b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
index a2b5ae8a9e3e5f..9bc7c78f79b26b 100644
--- a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -2,7 +2,7 @@
 # points to non-executable memory.
 
 # REQUIRES: target-x86_64
-# UNSUPPORTED: system-windows, ld64-tls-bug
+# UNSUPPORTED: system-windows, ld_new-bug
 
 # RUN: %clang_host %p/Inputs/call-asm.c -x assembler-with-cpp 
%p/Inputs/thread-step-out-ret-addr-check.s -o %t
 # RUN: not %lldb %t -s %s -b 2>&1 | FileCheck %s
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 6d41dc7d8d7325..1362dfcf7c4354 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -181,13 +181,13 @@ def calculate_arch_features(arch_string):
 if "LD_PRELOAD" in os.environ:
 config.available_features.add("ld_preload-present")
 
-# Determine if a specific version of Xcode's linker contains a TLS bug. We want
-# to skip TLS tests if they contain this bug.
+# Determine if a specific version of Xcode's linker contains a bug. We want to
+# skip affected tests if they contain this bug.
 try:
 raw_version_details = subprocess.check_outpu

[Lldb-commits] [lldb] [lldb] Disable shell tests affected by ld_new bug (PR #84246)

2024-03-07 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)

2024-03-07 Thread Dave Lee via lldb-commits


@@ -333,3 +335,41 @@ def expectedCompiler(compilers):
 return True
 
 return False
+
+
+# This is a helper function to determine if a specific version of Xcode's 
linker
+# contains a TLS bug. We want to skip TLS tests if they contain this bug, but
+# adding a linker/linker_version conditions to a decorator is challenging due 
to
+# the number of ways linkers can enter the build process.
+def darwinLinkerHasTLSBug():
+"""Returns true iff a test is running on a darwin platform and the host 
linker is between versions 1000 and 1109."""
+darwin_platforms = lldbplatform.translate(lldbplatform.darwin_all)
+if getPlatform() not in darwin_platforms:
+return False
+
+linker_path = (
+subprocess.check_output(["xcrun", "--find", 
"ld"]).rstrip().decode("utf-8")
+)
+if not is_exe(linker_path):
+return False
+
+raw_linker_info = (
+subprocess.check_output([linker_path, "-version_details"])
+.rstrip()
+.decode("utf-8")
+)
+parsed_linker_info = json.loads(raw_linker_info)
+if "version" not in parsed_linker_info:
+return False
+
+raw_version = parsed_linker_info["version"]
+version = None
+try:
+version = int(raw_version)

kastiglione wrote:

`float` also isn't sufficient, since some versions can contain 3 separate 
numbers (ie `100.5.8`).

In my related PR, I used this:

```py
version_tuple = tuple(int(x) for x in version.split("."))
if (1000,) <= version_tuple <= (1109,):
# handle bug
```

Comparisons of tuples appear to behave as desired.

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


[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)

2024-03-07 Thread Dave Lee via lldb-commits

https://github.com/kastiglione approved this pull request.

looks good

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


[Lldb-commits] [lldb] [lldb] XFAIL TestIndirectSymbols on darwin (PR #85127)

2024-03-13 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/85127

None

>From 5d0a5c8721766544067ccd8e169a5e2effeba981 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Wed, 13 Mar 2024 13:30:20 -0700
Subject: [PATCH] [lldb] XFAIL TestIndirectSymbols on darwin

---
 lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py 
b/lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py
index fbe6db9f892d55..ad4cb4b12c796a 100644
--- a/lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py
+++ b/lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py
@@ -16,6 +16,7 @@ def setUp(self):
 
 @skipUnlessDarwin
 @add_test_categories(["pyapi"])
+@expectedFailureDarwin("rdar://120796553")
 def test_with_python_api(self):
 """Test stepping and setting breakpoints in indirect and re-exported 
symbols."""
 self.build()

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


[Lldb-commits] [lldb] [lldb] XFAIL TestIndirectSymbols on darwin (PR #85127)

2024-03-13 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] XFAIL TestIndirectSymbols on darwin (PR #85127)

2024-03-13 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Skip TestIndirectSymbols (PR #85133)

2024-03-13 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/85133

Correction to cb8f3837e2311c369ef24a077a0c34e4ff56c08f


>From f5fb7236ad4df2fe9322ab00e4839e92ef29a8d3 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Wed, 13 Mar 2024 14:09:20 -0700
Subject: [PATCH] [lldb] Skip TestIndirectSymbols

Correction to cb8f3837e2311c369ef24a077a0c34e4ff56c08f
---
 lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py 
b/lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py
index ad4cb4b12c796a..c4bbedc9289130 100644
--- a/lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py
+++ b/lldb/test/API/macosx/indirect_symbol/TestIndirectSymbols.py
@@ -16,7 +16,7 @@ def setUp(self):
 
 @skipUnlessDarwin
 @add_test_categories(["pyapi"])
-@expectedFailureDarwin("rdar://120796553")
+@skipIf(bugnumber="rdar://120796553")
 def test_with_python_api(self):
 """Test stepping and setting breakpoints in indirect and re-exported 
symbols."""
 self.build()

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


[Lldb-commits] [lldb] [lldb] Skip TestIndirectSymbols (PR #85133)

2024-03-13 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Skip TestIndirectSymbols (PR #85133)

2024-03-13 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)

2024-03-13 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/85152

None

>From 970cf82fa3d64c5a4e1b3929c110b42974ef13cd Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Wed, 13 Mar 2024 14:49:23 -0700
Subject: [PATCH] [lldb] Fix dwim-print to not delete non-result persistent
 variables

---
 lldb/source/Commands/CommandObjectDWIMPrint.cpp| 12 ++--
 lldb/test/API/commands/dwim-print/TestDWIMPrint.py | 12 
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp 
b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index b183cb423111fb..5c043dfd101be6 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -170,6 +170,14 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 ExpressionResults expr_result = target.EvaluateExpression(
 expr, exe_scope, valobj_sp, eval_options, &fixed_expression);
 
+auto persistent_name = valobj_sp->GetName();
+// EvaluateExpression doesn't generate a new persistent result (`$0`) when
+// the expression is already just a persistent variable (`$var`). Instead,
+// the same persistent variable is reused. Take note of when a persistent
+// result is created, to prevent unintentional deletion of a user's
+// persistent variable.
+bool did_persist_result = persistent_name != expr;
+
 // Only mention Fix-Its if the expression evaluator applied them.
 // Compiler errors refer to the final expression after applying Fix-It(s).
 if (!fixed_expression.empty() && target.GetEnableNotifyAboutFixIts()) {
@@ -199,9 +207,9 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 }
   }
 
-  if (suppress_result)
+  if (did_persist_result && suppress_result)
 if (auto result_var_sp =
-target.GetPersistentVariable(valobj_sp->GetName())) {
+target.GetPersistentVariable(persistent_name)) {
   auto language = valobj_sp->GetPreferredDisplayLanguage();
   if (auto *persistent_state =
   target.GetPersistentExpressionStateForLanguage(language))
diff --git a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py 
b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
index 040632096c70e7..c650b1e3533e08 100644
--- a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
+++ b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
@@ -146,3 +146,15 @@ def test_void_result(self):
 self, "// break here", lldb.SBFileSpec("main.c")
 )
 self.expect("dwim-print (void)15", matching=False, 
patterns=["(?i)error"])
+
+def test_preserves_persistent_variables(self):
+"""Test dwim-print does not delete persistent variables."""
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.c")
+)
+self.expect("dwim-print int $i = 15")
+# Run the same expression twice and verify success. This ensures the
+# first command does not delete the persistent variable.
+for _ in range(2):
+self.expect("dwim-print $i", startstr="(int) 15")

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


[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)

2024-03-13 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)

2024-03-14 Thread Dave Lee via lldb-commits


@@ -170,6 +170,14 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 ExpressionResults expr_result = target.EvaluateExpression(
 expr, exe_scope, valobj_sp, eval_options, &fixed_expression);
 
+auto persistent_name = valobj_sp->GetName();
+// EvaluateExpression doesn't generate a new persistent result (`$0`) when
+// the expression is already just a persistent variable (`$var`). Instead,
+// the same persistent variable is reused. Take note of when a persistent
+// result is created, to prevent unintentional deletion of a user's
+// persistent variable.
+bool did_persist_result = persistent_name != expr;

kastiglione wrote:

I agree that it's not ideal, but I felt it was sufficient.

> what you want to test, which is whether the result of the expression was a 
> new expression result variable

exactly. However I think peeking at the result variables is also not ideal. 
Both my initial stab at this, and your suggestion are deducing whether a new 
expression result variable was created. If I'm to change the API, I think it'd 
be ideal to make the API communicate have means to communicate this explicitly.

There's another approach I considered taking. Before calling 
`EvaluateExpression`, try the expression as a persistent variable and check in 
the target to see if it exists, and if it does exist, use it (and avoid 
`EvaluateExpression` altogether). This is similar to how expressions are first 
treated as frame variables (and as @felipepiovezan has requested, we should try 
`target variable` too).

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


[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)

2024-03-14 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)

2024-03-15 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix dwim-print to not delete non-result persistent variables (PR #85152)

2024-03-15 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/85152

>From 970cf82fa3d64c5a4e1b3929c110b42974ef13cd Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Wed, 13 Mar 2024 14:49:23 -0700
Subject: [PATCH 1/2] [lldb] Fix dwim-print to not delete non-result persistent
 variables

---
 lldb/source/Commands/CommandObjectDWIMPrint.cpp| 12 ++--
 lldb/test/API/commands/dwim-print/TestDWIMPrint.py | 12 
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp 
b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index b183cb423111fb..5c043dfd101be6 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -170,6 +170,14 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 ExpressionResults expr_result = target.EvaluateExpression(
 expr, exe_scope, valobj_sp, eval_options, &fixed_expression);
 
+auto persistent_name = valobj_sp->GetName();
+// EvaluateExpression doesn't generate a new persistent result (`$0`) when
+// the expression is already just a persistent variable (`$var`). Instead,
+// the same persistent variable is reused. Take note of when a persistent
+// result is created, to prevent unintentional deletion of a user's
+// persistent variable.
+bool did_persist_result = persistent_name != expr;
+
 // Only mention Fix-Its if the expression evaluator applied them.
 // Compiler errors refer to the final expression after applying Fix-It(s).
 if (!fixed_expression.empty() && target.GetEnableNotifyAboutFixIts()) {
@@ -199,9 +207,9 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 }
   }
 
-  if (suppress_result)
+  if (did_persist_result && suppress_result)
 if (auto result_var_sp =
-target.GetPersistentVariable(valobj_sp->GetName())) {
+target.GetPersistentVariable(persistent_name)) {
   auto language = valobj_sp->GetPreferredDisplayLanguage();
   if (auto *persistent_state =
   target.GetPersistentExpressionStateForLanguage(language))
diff --git a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py 
b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
index 040632096c70e7..c650b1e3533e08 100644
--- a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
+++ b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
@@ -146,3 +146,15 @@ def test_void_result(self):
 self, "// break here", lldb.SBFileSpec("main.c")
 )
 self.expect("dwim-print (void)15", matching=False, 
patterns=["(?i)error"])
+
+def test_preserves_persistent_variables(self):
+"""Test dwim-print does not delete persistent variables."""
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.c")
+)
+self.expect("dwim-print int $i = 15")
+# Run the same expression twice and verify success. This ensures the
+# first command does not delete the persistent variable.
+for _ in range(2):
+self.expect("dwim-print $i", startstr="(int) 15")

>From 6503e22c894d9ed3f0d94d30a2165cf7f1914e47 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Fri, 15 Mar 2024 11:02:24 -0700
Subject: [PATCH 2/2] Try expr as a persistent variable

---
 .../Commands/CommandObjectDWIMPrint.cpp   | 24 +--
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp 
b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index 5c043dfd101be6..9db0c5a1e73ea1 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -23,7 +23,6 @@
 #include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-forward.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/FormatVariadic.h"
 
 #include 
 
@@ -161,7 +160,16 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 }
   }
 
-  // Second, also lastly, try `expr` as a source expression to evaluate.
+  // Second, try `expr` as a persistent variable.
+  if (expr.starts_with("$"))
+if (auto var_sp = target.GetPersistentVariable(ConstString(expr)))
+  if (auto valobj_sp = var_sp->GetValueObject()) {
+valobj_sp->Dump(result.GetOutputStream(), dump_options);
+result.SetStatus(eReturnStatusSuccessFinishResult);
+return;
+  }
+
+  // Third, and lastly, try `expr` as a source expression to evaluate.
   {
 auto *exe_scope = m_exe_ctx.GetBestExecutionContextScope();
 ValueObjectSP valobj_sp;
@@ -170,14 +178,6 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 ExpressionResults expr_result = target.EvaluateExpression(
 expr, exe_scope, valobj_sp, eval_options, &fixed_expression);
 
-auto persistent_name = valobj_sp->GetName();
-// EvaluateExpression doesn't generate a new persis

  1   2   3   4   5   6   7   >