[Lldb-commits] [lldb] [lldb] Use packaging module instead of pkg_resources (PR #93712)

2024-05-31 Thread Pavel Labath via lldb-commits

labath wrote:

> @labath Does your ✅ mean the 
> [debian](https://lab.llvm.org/buildbot/#/builders/68) bot has this package 
> installed?

Affirmative.

> Did a bit of digging around; it looks like at the very least the Arch Linux 
> python package and the Python docker container don't contain the `packaging` 
> library. It's included in Arch's `python-pip` package, but having `pip` as a 
> dependency to test LLDB seems odd.

FWIW, there appears to be an actual arch package for this 
, so it shouldn't 
be (I think -- I'm not an Arch user) necessary to install `pip`.

That said, using a package designed (AIUI) for python versions for parsing 
versions of gcc/clang does strike me as somewhat... unusual, even if it does 
work, so ***maybe*** there is case to be made for writing something custom (I'm 
not sure if  we really need anything more elaborate than `tuple([int(part) for 
part in version.split(".")])`)

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


[Lldb-commits] [lldb] [lldb][test] Add --make argument to dotest.py (PR #93883)

2024-05-31 Thread Pavel Labath via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][test] Add --make argument to dotest.py (PR #93883)

2024-05-31 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Add --make argument to dotest.py (PR #93883)

2024-05-31 Thread Pavel Labath via lldb-commits


@@ -40,7 +40,9 @@ def getMake(self, test_subdir, test_name):
 """Returns the invocation for GNU make.
 The first argument is a tuple of the relative path to the testcase
 and its filename stem."""
-if platform.system() == "FreeBSD" or platform.system() == "NetBSD":
+if configuration.make_path is not None:
+make = configuration.make_path
+elif platform.system() == "FreeBSD" or platform.system() == "NetBSD":
 make = "gmake"
 else:
 make = "make"

labath wrote:

I think it'd be nicer to move this code to dotest.py, as that's where we deal 
with locating the compiler, and all the other tools.

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


[Lldb-commits] [lldb] [lldb][test] Add --target-os argument to dotest.py (PR #93887)

2024-05-31 Thread Pavel Labath via lldb-commits

labath wrote:

Would it be possible to pass this automatically from the python process? 
Basically set `OS` to the value of `lldbplatformutil.getPlatform()` ? We could 
keep the existing exception for Android, although I don't think that anyone 
tests Android these days (your PRs sort of demonstrate that)...

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


[Lldb-commits] [lldb] [lldb][test] Add --sysroot argument to dotest.py (PR #93885)

2024-05-31 Thread Pavel Labath via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][test] Disable PIE for some API tests (PR #93808)

2024-05-31 Thread Pavel Labath via lldb-commits

labath wrote:

Ok, I see now. It's an ld.bfd vs ld.lld thing. You probably have your clang 
configured to use lld. LLD does not put relocation addends into the data 
section (on both arm and intel). ld.bfd does, which is why this sort of happens 
to work there. Was your intention to test with LLD?

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


[Lldb-commits] [lldb] [lldb] Avoid (unlimited) GetNumChildren calls when printing values (PR #93946)

2024-05-31 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/93946

For some data formatters, even getting the number of children can be an 
expensive operations (e.g., needing to walk a linked list to determine the 
number of elements). This is then wasted work when we know we will be printing 
only small number of them.

This patch replaces the calls to GetNumChildren (at least those on the "frame 
var" path) with the calls to the capped version, passing the value of 
`max-children-count` setting (plus one)

>From 957f0a85a0e0d2de9f34d00e28ba932e5affce86 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Fri, 31 May 2024 10:06:19 +
Subject: [PATCH] [lldb] Avoid (unlimited) GetNumChildren calls when printing
 values

For some data formatters, even getting the number of children can be an
expensive operations (e.g., needing to walk a linked list to determine
the number of elements). This is then wasted work when we know we will
be printing only small number of them.

This patch replaces the calls to GetNumChildren (at least those on the
"frame var" path) with the calls to the capped version, passing the
value of `max-children-count` setting (plus one)
---
 lldb/source/DataFormatters/FormatManager.cpp  | 10 ---
 .../DataFormatters/ValueObjectPrinter.cpp | 27 ++-
 .../synthcapping/TestSyntheticCapping.py  | 11 
 .../synthcapping/fooSynthProvider.py  | 16 ++-
 4 files changed, 47 insertions(+), 17 deletions(-)

diff --git a/lldb/source/DataFormatters/FormatManager.cpp 
b/lldb/source/DataFormatters/FormatManager.cpp
index d7ba5b4b70c94..84c0c7eed1431 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -9,6 +9,7 @@
 #include "lldb/DataFormatters/FormatManager.h"
 
 #include "lldb/Core/Debugger.h"
+#include "lldb/Core/ValueObject.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/DataFormatters/LanguageCategory.h"
 #include "lldb/Interpreter/ScriptInterpreter.h"
@@ -442,16 +443,19 @@ lldb::Format 
FormatManager::GetSingleItemFormat(lldb::Format vector_format) {
 }
 
 bool FormatManager::ShouldPrintAsOneLiner(ValueObject &valobj) {
+  TargetSP target_sp = valobj.GetTargetSP();
   // if settings say no oneline whatsoever
-  if (valobj.GetTargetSP().get() &&
-  !valobj.GetTargetSP()->GetDebugger().GetAutoOneLineSummaries())
+  if (target_sp && !target_sp->GetDebugger().GetAutoOneLineSummaries())
 return false; // then don't oneline
 
   // if this object has a summary, then ask the summary
   if (valobj.GetSummaryFormat().get() != nullptr)
 return valobj.GetSummaryFormat()->IsOneLiner();
 
-  auto num_children = valobj.GetNumChildren();
+  size_t max_num_children =
+  (target_sp ? *target_sp : Target::GetGlobalProperties())
+  .GetMaximumNumberOfChildrenToDisplay();
+  auto num_children = valobj.GetNumChildren(max_num_children);
   if (!num_children) {
 llvm::consumeError(num_children.takeError());
 return true;
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp 
b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index bbdc2a9981570..c2933d8574583 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -14,6 +14,8 @@
 #include "lldb/Target/Language.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/Stream.h"
+#include "llvm/Support/MathExtras.h"
+#include 
 
 using namespace lldb;
 using namespace lldb_private;
@@ -628,22 +630,21 @@ ValueObjectPrinter::GetMaxNumChildrenToPrint(bool 
&print_dotdotdot) {
   if (m_options.m_pointer_as_array)
 return m_options.m_pointer_as_array.m_element_count;
 
-  auto num_children_or_err = synth_valobj.GetNumChildren();
+  const uint32_t max_num_children =
+  m_options.m_ignore_cap ? UINT32_MAX
+ : GetMostSpecializedValue()
+   .GetTargetSP()
+   ->GetMaximumNumberOfChildrenToDisplay();
+  // Ask for one more child than the maximum to see if we should print "...".
+  auto num_children_or_err = synth_valobj.GetNumChildren(
+  llvm::SaturatingAdd(max_num_children, uint32_t(1)));
   if (!num_children_or_err)
 return num_children_or_err;
-  uint32_t num_children = *num_children_or_err;
-  print_dotdotdot = false;
-  if (num_children) {
-const size_t max_num_children = GetMostSpecializedValue()
-.GetTargetSP()
-
->GetMaximumNumberOfChildrenToDisplay();
-
-if (num_children > max_num_children && !m_options.m_ignore_cap) {
-  print_dotdotdot = true;
-  return max_num_children;
-}
+  if (*num_children_or_err > max_num_children) {
+print_dotdotdot = true;
+return max_num_children;
   }
-  return num_children;
+  return num_children_or_err;
 }
 
 void ValueObjectPrinter::PrintChildrenPostamble(bool print_dotdotdo

[Lldb-commits] [lldb] [lldb] Avoid (unlimited) GetNumChildren calls when printing values (PR #93946)

2024-05-31 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

For some data formatters, even getting the number of children can be an 
expensive operations (e.g., needing to walk a linked list to determine the 
number of elements). This is then wasted work when we know we will be printing 
only small number of them.

This patch replaces the calls to GetNumChildren (at least those on the "frame 
var" path) with the calls to the capped version, passing the value of 
`max-children-count` setting (plus one)

---
Full diff: https://github.com/llvm/llvm-project/pull/93946.diff


4 Files Affected:

- (modified) lldb/source/DataFormatters/FormatManager.cpp (+7-3) 
- (modified) lldb/source/DataFormatters/ValueObjectPrinter.cpp (+14-13) 
- (modified) 
lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
 (+11) 
- (modified) 
lldb/test/API/functionalities/data-formatter/synthcapping/fooSynthProvider.py 
(+15-1) 


``diff
diff --git a/lldb/source/DataFormatters/FormatManager.cpp 
b/lldb/source/DataFormatters/FormatManager.cpp
index d7ba5b4b70c94..84c0c7eed1431 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -9,6 +9,7 @@
 #include "lldb/DataFormatters/FormatManager.h"
 
 #include "lldb/Core/Debugger.h"
+#include "lldb/Core/ValueObject.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/DataFormatters/LanguageCategory.h"
 #include "lldb/Interpreter/ScriptInterpreter.h"
@@ -442,16 +443,19 @@ lldb::Format 
FormatManager::GetSingleItemFormat(lldb::Format vector_format) {
 }
 
 bool FormatManager::ShouldPrintAsOneLiner(ValueObject &valobj) {
+  TargetSP target_sp = valobj.GetTargetSP();
   // if settings say no oneline whatsoever
-  if (valobj.GetTargetSP().get() &&
-  !valobj.GetTargetSP()->GetDebugger().GetAutoOneLineSummaries())
+  if (target_sp && !target_sp->GetDebugger().GetAutoOneLineSummaries())
 return false; // then don't oneline
 
   // if this object has a summary, then ask the summary
   if (valobj.GetSummaryFormat().get() != nullptr)
 return valobj.GetSummaryFormat()->IsOneLiner();
 
-  auto num_children = valobj.GetNumChildren();
+  size_t max_num_children =
+  (target_sp ? *target_sp : Target::GetGlobalProperties())
+  .GetMaximumNumberOfChildrenToDisplay();
+  auto num_children = valobj.GetNumChildren(max_num_children);
   if (!num_children) {
 llvm::consumeError(num_children.takeError());
 return true;
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp 
b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index bbdc2a9981570..c2933d8574583 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -14,6 +14,8 @@
 #include "lldb/Target/Language.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/Stream.h"
+#include "llvm/Support/MathExtras.h"
+#include 
 
 using namespace lldb;
 using namespace lldb_private;
@@ -628,22 +630,21 @@ ValueObjectPrinter::GetMaxNumChildrenToPrint(bool 
&print_dotdotdot) {
   if (m_options.m_pointer_as_array)
 return m_options.m_pointer_as_array.m_element_count;
 
-  auto num_children_or_err = synth_valobj.GetNumChildren();
+  const uint32_t max_num_children =
+  m_options.m_ignore_cap ? UINT32_MAX
+ : GetMostSpecializedValue()
+   .GetTargetSP()
+   ->GetMaximumNumberOfChildrenToDisplay();
+  // Ask for one more child than the maximum to see if we should print "...".
+  auto num_children_or_err = synth_valobj.GetNumChildren(
+  llvm::SaturatingAdd(max_num_children, uint32_t(1)));
   if (!num_children_or_err)
 return num_children_or_err;
-  uint32_t num_children = *num_children_or_err;
-  print_dotdotdot = false;
-  if (num_children) {
-const size_t max_num_children = GetMostSpecializedValue()
-.GetTargetSP()
-
->GetMaximumNumberOfChildrenToDisplay();
-
-if (num_children > max_num_children && !m_options.m_ignore_cap) {
-  print_dotdotdot = true;
-  return max_num_children;
-}
+  if (*num_children_or_err > max_num_children) {
+print_dotdotdot = true;
+return max_num_children;
   }
-  return num_children;
+  return num_children_or_err;
 }
 
 void ValueObjectPrinter::PrintChildrenPostamble(bool print_dotdotdot) {
diff --git 
a/lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
 
b/lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
index d53dadef836e5..9ca232abefa03 100644
--- 
a/lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
+++ 
b/lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
@@ -68,6 +68,11 @@ def cleanup():
 "r = 34",
 ],
 )
+# num_children

[Lldb-commits] [lldb] [lldb] Avoid (unlimited) GetNumChildren calls when printing values (PR #93946)

2024-05-31 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
a2bcb932f3130c3c18ceb06872da9002f6845c4b...957f0a85a0e0d2de9f34d00e28ba932e5affce86
 
lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
 lldb/test/API/functionalities/data-formatter/synthcapping/fooSynthProvider.py
``





View the diff from darker here.


``diff
--- fooSynthProvider.py 2024-05-31 10:22:49.00 +
+++ fooSynthProvider.py 2024-05-31 10:26:02.044860 +
@@ -1,10 +1,9 @@
 import lldb
 
 
 class fooSynthProvider:
-
 # For testing purposes, we'll keep track of the maximum value of
 # max_num_children we've been called with.
 MAX_NUM_CHILDREN_MAX = 0
 
 @classmethod

``




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


[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-31 Thread Alexey Merzlyakov via lldb-commits

AlexeyMerzlyakov wrote:

No, I have no rights to do this

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


[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-31 Thread David Spickett via lldb-commits


@@ -0,0 +1,84 @@
+//===-- RegisterContextPOSIXCore_riscv64.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RegisterContextPOSIXCore_riscv64.h"
+
+#include "lldb/Utility/DataBufferHeap.h"
+
+using namespace lldb_private;
+
+std::unique_ptr
+RegisterContextCorePOSIX_riscv64::Create(Thread &thread, const ArchSpec &arch,
+ const DataExtractor &gpregset,
+ llvm::ArrayRef notes) {
+  Flags flags = 0;
+
+  return std::unique_ptr(
+  new RegisterContextCorePOSIX_riscv64(
+  thread, std::make_unique(arch, flags),

DavidSpickett wrote:

Super nit pick: can you just pass `Flags()` here. It's pass by copy and there's 
a default constructor that uses the value 0.

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


[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-31 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-31 Thread David Spickett via lldb-commits


@@ -0,0 +1,84 @@
+//===-- RegisterContextPOSIXCore_riscv64.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RegisterContextPOSIXCore_riscv64.h"
+
+#include "lldb/Utility/DataBufferHeap.h"
+
+using namespace lldb_private;
+
+std::unique_ptr
+RegisterContextCorePOSIX_riscv64::Create(Thread &thread, const ArchSpec &arch,
+ const DataExtractor &gpregset,
+ llvm::ArrayRef notes) {
+  Flags flags = 0;
+
+  return std::unique_ptr(
+  new RegisterContextCorePOSIX_riscv64(
+  thread, std::make_unique(arch, flags),

DavidSpickett wrote:

So you can remove the variable above I mean.

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


[Lldb-commits] [lldb] [lldb] Avoid (unlimited) GetNumChildren calls when printing values (PR #93946)

2024-05-31 Thread Pavel Labath via lldb-commits

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/93946

>From 1e25ef1cc5ff4d12a3e5b85c8ea7cd30a3e0908e Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Fri, 31 May 2024 10:06:19 +
Subject: [PATCH] [lldb] Avoid (unlimited) GetNumChildren calls when printing
 values

For some data formatters, even getting the number of children can be an
expensive operations (e.g., needing to walk a linked list to determine
the number of elements). This is then wasted work when we know we will
be printing only small number of them.

This patch replaces the calls to GetNumChildren (at least those on the
"frame var" path) with the calls to the capped version, passing the
value of `max-children-count` setting (plus one)
---
 lldb/source/DataFormatters/FormatManager.cpp  | 10 ---
 .../DataFormatters/ValueObjectPrinter.cpp | 27 ++-
 .../synthcapping/TestSyntheticCapping.py  | 11 
 .../synthcapping/fooSynthProvider.py  | 15 ++-
 4 files changed, 46 insertions(+), 17 deletions(-)

diff --git a/lldb/source/DataFormatters/FormatManager.cpp 
b/lldb/source/DataFormatters/FormatManager.cpp
index d7ba5b4b70c94..84c0c7eed1431 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -9,6 +9,7 @@
 #include "lldb/DataFormatters/FormatManager.h"
 
 #include "lldb/Core/Debugger.h"
+#include "lldb/Core/ValueObject.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/DataFormatters/LanguageCategory.h"
 #include "lldb/Interpreter/ScriptInterpreter.h"
@@ -442,16 +443,19 @@ lldb::Format 
FormatManager::GetSingleItemFormat(lldb::Format vector_format) {
 }
 
 bool FormatManager::ShouldPrintAsOneLiner(ValueObject &valobj) {
+  TargetSP target_sp = valobj.GetTargetSP();
   // if settings say no oneline whatsoever
-  if (valobj.GetTargetSP().get() &&
-  !valobj.GetTargetSP()->GetDebugger().GetAutoOneLineSummaries())
+  if (target_sp && !target_sp->GetDebugger().GetAutoOneLineSummaries())
 return false; // then don't oneline
 
   // if this object has a summary, then ask the summary
   if (valobj.GetSummaryFormat().get() != nullptr)
 return valobj.GetSummaryFormat()->IsOneLiner();
 
-  auto num_children = valobj.GetNumChildren();
+  size_t max_num_children =
+  (target_sp ? *target_sp : Target::GetGlobalProperties())
+  .GetMaximumNumberOfChildrenToDisplay();
+  auto num_children = valobj.GetNumChildren(max_num_children);
   if (!num_children) {
 llvm::consumeError(num_children.takeError());
 return true;
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp 
b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index bbdc2a9981570..c2933d8574583 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -14,6 +14,8 @@
 #include "lldb/Target/Language.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/Stream.h"
+#include "llvm/Support/MathExtras.h"
+#include 
 
 using namespace lldb;
 using namespace lldb_private;
@@ -628,22 +630,21 @@ ValueObjectPrinter::GetMaxNumChildrenToPrint(bool 
&print_dotdotdot) {
   if (m_options.m_pointer_as_array)
 return m_options.m_pointer_as_array.m_element_count;
 
-  auto num_children_or_err = synth_valobj.GetNumChildren();
+  const uint32_t max_num_children =
+  m_options.m_ignore_cap ? UINT32_MAX
+ : GetMostSpecializedValue()
+   .GetTargetSP()
+   ->GetMaximumNumberOfChildrenToDisplay();
+  // Ask for one more child than the maximum to see if we should print "...".
+  auto num_children_or_err = synth_valobj.GetNumChildren(
+  llvm::SaturatingAdd(max_num_children, uint32_t(1)));
   if (!num_children_or_err)
 return num_children_or_err;
-  uint32_t num_children = *num_children_or_err;
-  print_dotdotdot = false;
-  if (num_children) {
-const size_t max_num_children = GetMostSpecializedValue()
-.GetTargetSP()
-
->GetMaximumNumberOfChildrenToDisplay();
-
-if (num_children > max_num_children && !m_options.m_ignore_cap) {
-  print_dotdotdot = true;
-  return max_num_children;
-}
+  if (*num_children_or_err > max_num_children) {
+print_dotdotdot = true;
+return max_num_children;
   }
-  return num_children;
+  return num_children_or_err;
 }
 
 void ValueObjectPrinter::PrintChildrenPostamble(bool print_dotdotdot) {
diff --git 
a/lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
 
b/lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
index d53dadef836e5..9ca232abefa03 100644
--- 
a/lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
+++ 
b/lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
@@ -68,6 +68,11 @@ def cleanup():
   

[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-31 Thread David Spickett via lldb-commits


@@ -0,0 +1,84 @@
+//===-- RegisterContextPOSIXCore_riscv64.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RegisterContextPOSIXCore_riscv64.h"
+
+#include "lldb/Utility/DataBufferHeap.h"
+
+using namespace lldb_private;
+
+std::unique_ptr
+RegisterContextCorePOSIX_riscv64::Create(
+lldb_private::Thread &thread, const lldb_private::ArchSpec &arch,
+const lldb_private::DataExtractor &gpregset,
+llvm::ArrayRef notes) {
+  Flags flags = 0;
+
+  auto register_info_up =
+  std::make_unique(arch, flags);
+  return std::unique_ptr(
+  new RegisterContextCorePOSIX_riscv64(thread, std::move(register_info_up),
+   gpregset, notes));
+}
+
+RegisterContextCorePOSIX_riscv64::RegisterContextCorePOSIX_riscv64(
+Thread &thread, std::unique_ptr register_info,
+const DataExtractor &gpregset, llvm::ArrayRef notes)
+: RegisterContextPOSIX_riscv64(thread, std::move(register_info)) {
+
+  m_gpr_buffer = std::make_shared(gpregset.GetDataStart(),
+  gpregset.GetByteSize());
+  m_gpr.SetData(m_gpr_buffer);
+  m_gpr.SetByteOrder(gpregset.GetByteOrder());
+
+  ArchSpec arch = m_register_info_up->GetTargetArchitecture();
+  DataExtractor fpregset = getRegset(notes, arch.GetTriple(), FPR_Desc);
+  m_fpr_buffer = std::make_shared(fpregset.GetDataStart(),

DavidSpickett wrote:

For obvious reasons, not a RISC-V expert, but Debian chose RV64GC 
(https://wiki.debian.org/RISC-V#Hardware_baseline_and_ABI_choice) which 
apparently converts to `RV64IMAFDCZicsr_Zifencei` and `F` is single precision 
floating point.

So I agree, it's reasonable for lldb to assume they exist. Certainly not a 
concern for this PR.

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


[Lldb-commits] [lldb] [lldb][RISCV] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-31 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][RISCV] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-31 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Corefiles can be debugged anywhere, so you should add a test case to 
`lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py`.

There is a way to minimise the size of the core file, see 
https://man7.org/linux/man-pages/man5/core.5.html "Controlling which mappings 
are written to the core dump". I usually generate a normal core, then keep 
removing stuff until the tests stop passing. Sometimes there's not much we can 
remove.

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


[Lldb-commits] [lldb] [lldb][RISCV] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-31 Thread David Spickett via lldb-commits


@@ -0,0 +1,84 @@
+//===-- RegisterContextPOSIXCore_riscv64.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RegisterContextPOSIXCore_riscv64.h"
+
+#include "lldb/Utility/DataBufferHeap.h"
+
+using namespace lldb_private;
+
+std::unique_ptr
+RegisterContextCorePOSIX_riscv64::Create(
+lldb_private::Thread &thread, const lldb_private::ArchSpec &arch,
+const lldb_private::DataExtractor &gpregset,
+llvm::ArrayRef notes) {
+  Flags flags = 0;
+
+  auto register_info_up =
+  std::make_unique(arch, flags);
+  return std::unique_ptr(
+  new RegisterContextCorePOSIX_riscv64(thread, std::move(register_info_up),
+   gpregset, notes));
+}
+
+RegisterContextCorePOSIX_riscv64::RegisterContextCorePOSIX_riscv64(
+Thread &thread, std::unique_ptr register_info,
+const DataExtractor &gpregset, llvm::ArrayRef notes)
+: RegisterContextPOSIX_riscv64(thread, std::move(register_info)) {
+
+  m_gpr_buffer = std::make_shared(gpregset.GetDataStart(),
+  gpregset.GetByteSize());
+  m_gpr.SetData(m_gpr_buffer);
+  m_gpr.SetByteOrder(gpregset.GetByteOrder());
+
+  ArchSpec arch = m_register_info_up->GetTargetArchitecture();
+  DataExtractor fpregset = getRegset(notes, arch.GetTriple(), FPR_Desc);
+  m_fpr_buffer = std::make_shared(fpregset.GetDataStart(),
+  fpregset.GetByteSize());
+  m_fpr.SetData(m_fpr_buffer);
+  m_fpr.SetByteOrder(fpregset.GetByteOrder());
+}
+
+RegisterContextCorePOSIX_riscv64::~RegisterContextCorePOSIX_riscv64() = 
default;
+
+bool RegisterContextCorePOSIX_riscv64::ReadGPR() { return true; }
+
+bool RegisterContextCorePOSIX_riscv64::ReadFPR() { return true; }
+
+bool RegisterContextCorePOSIX_riscv64::WriteGPR() {
+  assert(0);

DavidSpickett wrote:

That's right, core dumps are read only.

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


[Lldb-commits] [lldb] [lldb] FormatManager::GetPossibleMatches assumes all ValueObjects have targets. (PR #93880)

2024-05-31 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb] FormatManager::GetPossibleMatches assumes all ValueObjects have targets. (PR #93880)

2024-05-31 Thread David Spickett via lldb-commits

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

LGTM assuming you can make the formatter happy.

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


[Lldb-commits] [lldb] [lldb][test] Disable PIE for some API tests (PR #93808)

2024-05-31 Thread Vladislav Dzhidzhoev via lldb-commits

dzhidzhoev wrote:

> Ok, I see now. It's an ld.bfd vs ld.lld thing. You probably have your clang 
> configured to use lld. LLD does not put relocation addends into the data 
> section (on both arm and intel). ld.bfd does, which is why this sort of 
> happens to work there. Was your intention to test with LLD?

Yep, I run it with lld built together with clang and lldb. Should the condition 
be narrowed to affect only builds with lld? 

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


[Lldb-commits] [lldb] [lldb] Fix 'session save' command on Windows (PR #93833)

2024-05-31 Thread Vladislav Dzhidzhoev via lldb-commits

https://github.com/dzhidzhoev updated 
https://github.com/llvm/llvm-project/pull/93833

>From 15acc7cdf26c06c2be0d52d8341bce2870a55606 Mon Sep 17 00:00:00 2001
From: Vladislav Dzhidzhoev 
Date: Fri, 10 May 2024 22:59:31 +
Subject: [PATCH] [lldb] Fix 'session save' command on Windows

1. Use dashes (-) instead of colons (:) as time separator in a session log
file name since Windows doesn't support saving files with names containing
colons.

2. Temporary file creation code is changed in the test:
On Windows, the temporary file should be closed before 'session save'
writes session log to it. NamedTemporaryFile() can preserve the file
after closing it with delete_on_close=False option.
However, this option is only available since Python 3.12. Thus
mkstemp() is used for temporary file creation as the more compatible
option.
---
 lldb/source/Interpreter/CommandInterpreter.cpp | 2 ++
 lldb/test/API/commands/session/save/TestSessionSave.py | 6 ++
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index 7f21f382adb83..6a61882df093d 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -3235,6 +3235,8 @@ bool CommandInterpreter::SaveTranscript(
   if (output_file == std::nullopt || output_file->empty()) {
 std::string now = llvm::to_string(std::chrono::system_clock::now());
 std::replace(now.begin(), now.end(), ' ', '_');
+// Can't have file name with colons on Windows
+std::replace(now.begin(), now.end(), ':', '-');
 const std::string file_name = "lldb_session_" + now + ".log";
 
 FileSpec save_location = GetSaveSessionDirectory();
diff --git a/lldb/test/API/commands/session/save/TestSessionSave.py 
b/lldb/test/API/commands/session/save/TestSessionSave.py
index 98985c66010bb..1be0feb81a1c4 100644
--- a/lldb/test/API/commands/session/save/TestSessionSave.py
+++ b/lldb/test/API/commands/session/save/TestSessionSave.py
@@ -1,6 +1,7 @@
 """
 Test the session save feature
 """
+
 import os
 import tempfile
 
@@ -19,7 +20,6 @@ def raw_transcript_builder(self, cmd, res):
 raw += res.GetError()
 return raw
 
-@skipIfWindows
 @no_debug_info_test
 def test_session_save(self):
 raw = ""
@@ -61,8 +61,7 @@ def test_session_save(self):
 self.assertFalse(res.Succeeded())
 raw += self.raw_transcript_builder(cmd, res)
 
-tf = tempfile.NamedTemporaryFile()
-output_file = tf.name
+output_file = self.getBuildArtifact('my-session')
 
 res = lldb.SBCommandReturnObject()
 interpreter.HandleCommand("session save " + output_file, res)
@@ -95,7 +94,6 @@ def test_session_save(self):
 for line in lines:
 self.assertIn(line, content)
 
-@skipIfWindows
 @no_debug_info_test
 def test_session_save_on_quit(self):
 raw = ""

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


[Lldb-commits] [lldb] [lldb] Fix 'session save' command on Windows (PR #93833)

2024-05-31 Thread Vladislav Dzhidzhoev via lldb-commits

https://github.com/dzhidzhoev updated 
https://github.com/llvm/llvm-project/pull/93833

>From c5e417a812d86226b087346cadb05d3aae9fe1d0 Mon Sep 17 00:00:00 2001
From: Vladislav Dzhidzhoev 
Date: Fri, 10 May 2024 22:59:31 +
Subject: [PATCH] [lldb] Fix 'session save' command on Windows

1. Use dashes (-) instead of colons (:) as time separator in a session log
file name since Windows doesn't support saving files with names containing
colons.

2. Temporary file creation code is changed in the test:
On Windows, the temporary file should be closed before 'session save'
writes session log to it. NamedTemporaryFile() can preserve the file
after closing it with delete_on_close=False option.
However, this option is only available since Python 3.12. Thus
mkstemp() is used for temporary file creation as the more compatible
option.
---
 lldb/source/Interpreter/CommandInterpreter.cpp | 2 ++
 lldb/test/API/commands/session/save/TestSessionSave.py | 5 +
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index 7f21f382adb83..6a61882df093d 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -3235,6 +3235,8 @@ bool CommandInterpreter::SaveTranscript(
   if (output_file == std::nullopt || output_file->empty()) {
 std::string now = llvm::to_string(std::chrono::system_clock::now());
 std::replace(now.begin(), now.end(), ' ', '_');
+// Can't have file name with colons on Windows
+std::replace(now.begin(), now.end(), ':', '-');
 const std::string file_name = "lldb_session_" + now + ".log";
 
 FileSpec save_location = GetSaveSessionDirectory();
diff --git a/lldb/test/API/commands/session/save/TestSessionSave.py 
b/lldb/test/API/commands/session/save/TestSessionSave.py
index 98985c66010bb..aa99bcd56aed4 100644
--- a/lldb/test/API/commands/session/save/TestSessionSave.py
+++ b/lldb/test/API/commands/session/save/TestSessionSave.py
@@ -19,7 +19,6 @@ def raw_transcript_builder(self, cmd, res):
 raw += res.GetError()
 return raw
 
-@skipIfWindows
 @no_debug_info_test
 def test_session_save(self):
 raw = ""
@@ -61,8 +60,7 @@ def test_session_save(self):
 self.assertFalse(res.Succeeded())
 raw += self.raw_transcript_builder(cmd, res)
 
-tf = tempfile.NamedTemporaryFile()
-output_file = tf.name
+output_file = self.getBuildArtifact('my-session')
 
 res = lldb.SBCommandReturnObject()
 interpreter.HandleCommand("session save " + output_file, res)
@@ -95,7 +93,6 @@ def test_session_save(self):
 for line in lines:
 self.assertIn(line, content)
 
-@skipIfWindows
 @no_debug_info_test
 def test_session_save_on_quit(self):
 raw = ""

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


[Lldb-commits] [lldb] c5e417a - [lldb] Fix 'session save' command on Windows

2024-05-31 Thread Vladislav Dzhidzhoev via lldb-commits

Author: Vladislav Dzhidzhoev
Date: 2024-05-31T17:18:21+02:00
New Revision: c5e417a812d86226b087346cadb05d3aae9fe1d0

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

LOG: [lldb] Fix 'session save' command on Windows

1. Use dashes (-) instead of colons (:) as time separator in a session log
file name since Windows doesn't support saving files with names containing
colons.

2. Temporary file creation code is changed in the test:
On Windows, the temporary file should be closed before 'session save'
writes session log to it. NamedTemporaryFile() can preserve the file
after closing it with delete_on_close=False option.
However, this option is only available since Python 3.12. Thus
mkstemp() is used for temporary file creation as the more compatible
option.

Added: 


Modified: 
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/test/API/commands/session/save/TestSessionSave.py

Removed: 




diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index 7f21f382adb83..6a61882df093d 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -3235,6 +3235,8 @@ bool CommandInterpreter::SaveTranscript(
   if (output_file == std::nullopt || output_file->empty()) {
 std::string now = llvm::to_string(std::chrono::system_clock::now());
 std::replace(now.begin(), now.end(), ' ', '_');
+// Can't have file name with colons on Windows
+std::replace(now.begin(), now.end(), ':', '-');
 const std::string file_name = "lldb_session_" + now + ".log";
 
 FileSpec save_location = GetSaveSessionDirectory();

diff  --git a/lldb/test/API/commands/session/save/TestSessionSave.py 
b/lldb/test/API/commands/session/save/TestSessionSave.py
index 98985c66010bb..aa99bcd56aed4 100644
--- a/lldb/test/API/commands/session/save/TestSessionSave.py
+++ b/lldb/test/API/commands/session/save/TestSessionSave.py
@@ -19,7 +19,6 @@ def raw_transcript_builder(self, cmd, res):
 raw += res.GetError()
 return raw
 
-@skipIfWindows
 @no_debug_info_test
 def test_session_save(self):
 raw = ""
@@ -61,8 +60,7 @@ def test_session_save(self):
 self.assertFalse(res.Succeeded())
 raw += self.raw_transcript_builder(cmd, res)
 
-tf = tempfile.NamedTemporaryFile()
-output_file = tf.name
+output_file = self.getBuildArtifact('my-session')
 
 res = lldb.SBCommandReturnObject()
 interpreter.HandleCommand("session save " + output_file, res)
@@ -95,7 +93,6 @@ def test_session_save(self):
 for line in lines:
 self.assertIn(line, content)
 
-@skipIfWindows
 @no_debug_info_test
 def test_session_save_on_quit(self):
 raw = ""



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


[Lldb-commits] [lldb] [lldb] Fix 'session save' command on Windows (PR #93833)

2024-05-31 Thread Vladislav Dzhidzhoev via lldb-commits

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


[Lldb-commits] [lldb] 5e423f1 - [lldb][test] Add --sysroot argument to dotest.py

2024-05-31 Thread Vladislav Dzhidzhoev via lldb-commits

Author: Vladislav Dzhidzhoev
Date: 2024-05-31T17:24:14+02:00
New Revision: 5e423f1c5119387879c04069f048d6dbfc2c90d6

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

LOG: [lldb][test] Add --sysroot argument to dotest.py

This argument allows to set specific sysroot pass which will be used for
building LLDB API test programs.
It might come in handy for setting up cross-platform remote runs of API
tests on Windows host.

It can be useful for cross-compiling LLDB API tests. The argument can be
set using `LLDB_TEST_USER_ARGS` argument:
```
cmake ...
-DLLDB_TEST_USER_ARGS="...;--sysroot;C:\path\to\sysroot;..."
...
```

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/packages/Python/lldbsuite/test/dotest_args.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 2e537e3fd3ce0..70bc1d85091bc 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -304,7 +304,9 @@ def parseOptionsAndInitTestdirs():
 lldbtest_config.out_of_tree_debugserver = args.out_of_tree_debugserver
 
 # Set SDKROOT if we are using an Apple SDK
-if platform_system == "Darwin" and args.apple_sdk:
+if args.sysroot is not None:
+configuration.sdkroot = args.sysroot
+elif platform_system == "Darwin" and args.apple_sdk:
 configuration.sdkroot = seven.get_command_output(
 'xcrun --sdk "%s" --show-sdk-path 2> /dev/null' % (args.apple_sdk)
 )

diff  --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py 
b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index 8b00c7a4d56e7..e385954f8cc03 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -49,6 +49,15 @@ def create_parser():
 """Specify the compiler(s) used to build the inferior executables. 
The compiler path can be an executable basename or a full path to a compiler 
executable. This option can be specified multiple times."""
 ),
 )
+group.add_argument(
+"--sysroot",
+metavar="sysroot",
+dest="sysroot",
+default="",
+help=textwrap.dedent(
+"""Specify the path to sysroot. This overrides apple_sdk 
sysroot."""
+),
+)
 if sys.platform == "darwin":
 group.add_argument(
 "--apple-sdk",



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


[Lldb-commits] [lldb] [lldb] FormatManager::GetPossibleMatches assumes all ValueObjects have targets. (PR #93880)

2024-05-31 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Avoid (unlimited) GetNumChildren calls when printing values (PR #93946)

2024-05-31 Thread Jonas Devlieghere via lldb-commits


@@ -442,16 +443,19 @@ lldb::Format 
FormatManager::GetSingleItemFormat(lldb::Format vector_format) {
 }
 
 bool FormatManager::ShouldPrintAsOneLiner(ValueObject &valobj) {
+  TargetSP target_sp = valobj.GetTargetSP();
   // if settings say no oneline whatsoever
-  if (valobj.GetTargetSP().get() &&
-  !valobj.GetTargetSP()->GetDebugger().GetAutoOneLineSummaries())
+  if (target_sp && !target_sp->GetDebugger().GetAutoOneLineSummaries())
 return false; // then don't oneline
 
   // if this object has a summary, then ask the summary
   if (valobj.GetSummaryFormat().get() != nullptr)
 return valobj.GetSummaryFormat()->IsOneLiner();
 
-  auto num_children = valobj.GetNumChildren();
+  size_t max_num_children =

JDevlieghere wrote:

Nit: `const` like in ValueObjectPrinter?

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


[Lldb-commits] [lldb] [lldb] Avoid (unlimited) GetNumChildren calls when printing values (PR #93946)

2024-05-31 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Avoid (unlimited) GetNumChildren calls when printing values (PR #93946)

2024-05-31 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Add --target-os argument to dotest.py (PR #93887)

2024-05-31 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> Would it be possible to pass this automatically from the python process? 
> Basically set `OS` to the value of `lldbplatformutil.getPlatform()` ? We 
> could keep the existing exception for Android, although I don't think that 
> anyone tests Android these days (your PRs sort of demonstrate that)...

+1, I'd prefer to have the logic centralized in one place (i.e. Python), pass 
it explicitly and remove the code in `Makefile.rules` that uses `uname`. 

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


[Lldb-commits] [lldb] [lldb][test] Add --make argument to dotest.py (PR #93883)

2024-05-31 Thread Vladislav Dzhidzhoev via lldb-commits

https://github.com/dzhidzhoev updated 
https://github.com/llvm/llvm-project/pull/93883

>From 01fb7af6eabac1df410e117e5a0ccafb149dc2cb Mon Sep 17 00:00:00 2001
From: Vladislav Dzhidzhoev 
Date: Sat, 13 Apr 2024 23:55:25 +
Subject: [PATCH 1/2] [lldb][test] Add --make argument to dotest.py

This argument allows to specify the path to make which is used by
LLDB API tests to compile test programs.
It might come in handy for setting up cross-platform remote runs of API tests 
on Windows host.

It can be used to override the make path of LLDB API tests using 
`LLDB_TEST_USER_ARGS` argument:
```
cmake ...
-DLLDB_TEST_USER_ARGS="...;--make;C:\\Path\\to\\make.exe;..."
...
```
---
 lldb/packages/Python/lldbsuite/test/builders/builder.py | 4 +++-
 lldb/packages/Python/lldbsuite/test/configuration.py| 1 +
 lldb/packages/Python/lldbsuite/test/dotest.py   | 2 ++
 lldb/packages/Python/lldbsuite/test/dotest_args.py  | 6 ++
 4 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py 
b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index 21ea3530e24fc..178ce8bc3c490 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -40,7 +40,9 @@ def getMake(self, test_subdir, test_name):
 """Returns the invocation for GNU make.
 The first argument is a tuple of the relative path to the testcase
 and its filename stem."""
-if platform.system() == "FreeBSD" or platform.system() == "NetBSD":
+if configuration.make_path is not None:
+make = configuration.make_path
+elif platform.system() == "FreeBSD" or platform.system() == "NetBSD":
 make = "gmake"
 else:
 make = "make"
diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py 
b/lldb/packages/Python/lldbsuite/test/configuration.py
index dbd4a2d72a15d..27eef040497d1 100644
--- a/lldb/packages/Python/lldbsuite/test/configuration.py
+++ b/lldb/packages/Python/lldbsuite/test/configuration.py
@@ -43,6 +43,7 @@
 compiler = None
 dsymutil = None
 sdkroot = None
+make_path = None
 
 # The overriden dwarf verison.
 dwarf_version = 0
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 2e537e3fd3ce0..42b39bc6e2f7b 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -266,6 +266,8 @@ def parseOptionsAndInitTestdirs():
 configuration.compiler = candidate
 break
 
+if args.make:
+configuration.make_path = args.make
 if args.dsymutil:
 configuration.dsymutil = args.dsymutil
 elif platform_system == "Darwin":
diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py 
b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index 8b00c7a4d56e7..a0a840416c567 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -87,6 +87,12 @@ def create_parser():
 ),
 )
 
+group.add_argument(
+"--make",
+metavar="make",
+dest="make",
+help=textwrap.dedent("Specify which make to use."),
+)
 group.add_argument(
 "--dsymutil",
 metavar="dsymutil",

>From 60032f8510b7086e36a86172fbaa090e4d7ef66f Mon Sep 17 00:00:00 2001
From: Vladislav Dzhidzhoev 
Date: Fri, 31 May 2024 18:05:25 +0200
Subject: [PATCH 2/2] Moved make detection to dotest.py

---
 lldb/packages/Python/lldbsuite/test/builders/builder.py | 9 +
 lldb/packages/Python/lldbsuite/test/dotest.py   | 5 +
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py 
b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index 178ce8bc3c490..4ea9a86c1d5fc 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -40,13 +40,6 @@ def getMake(self, test_subdir, test_name):
 """Returns the invocation for GNU make.
 The first argument is a tuple of the relative path to the testcase
 and its filename stem."""
-if configuration.make_path is not None:
-make = configuration.make_path
-elif platform.system() == "FreeBSD" or platform.system() == "NetBSD":
-make = "gmake"
-else:
-make = "make"
-
 # Construct the base make invocation.
 lldb_test = os.environ["LLDB_TEST"]
 if not (
@@ -64,7 +57,7 @@ def getMake(self, test_subdir, test_name):
 if not os.path.isfile(makefile):
 makefile = os.path.join(build_dir, "Makefile")
 return [
-make,
+configuration.make_path,
 "VPATH=" + src_dir,
 "-C",
 build_dir,
diff --git a/lldb/packages/Python/ll

[Lldb-commits] [lldb] [lldb][test] Add --make argument to dotest.py (PR #93883)

2024-05-31 Thread Vladislav Dzhidzhoev via lldb-commits


@@ -40,7 +40,9 @@ def getMake(self, test_subdir, test_name):
 """Returns the invocation for GNU make.
 The first argument is a tuple of the relative path to the testcase
 and its filename stem."""
-if platform.system() == "FreeBSD" or platform.system() == "NetBSD":
+if configuration.make_path is not None:
+make = configuration.make_path
+elif platform.system() == "FreeBSD" or platform.system() == "NetBSD":
 make = "gmake"
 else:
 make = "make"

dzhidzhoev wrote:

Updated MR

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


[Lldb-commits] [lldb] [lldb][test] Add --make argument to dotest.py (PR #93883)

2024-05-31 Thread Vladislav Dzhidzhoev via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Add --make argument to dotest.py (PR #93883)

2024-05-31 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
419d363385c7fa8bd969a817f95ab025ae94277c...60032f8510b7086e36a86172fbaa090e4d7ef66f
 lldb/packages/Python/lldbsuite/test/builders/builder.py 
lldb/packages/Python/lldbsuite/test/configuration.py 
lldb/packages/Python/lldbsuite/test/dotest.py 
lldb/packages/Python/lldbsuite/test/dotest_args.py
``





View the diff from darker here.


``diff
--- dotest.py   2024-05-31 16:05:25.00 +
+++ dotest.py   2024-05-31 16:08:04.479627 +
@@ -266,11 +266,11 @@
 configuration.compiler = candidate
 break
 
 if args.make:
 configuration.make_path = args.make
-elif platform_system == "FreeBSD" or platform_system  == "NetBSD":
+elif platform_system == "FreeBSD" or platform_system == "NetBSD":
 configuration.make_path = "gmake"
 else:
 configuration.make_path = "make"
 
 if args.dsymutil:

``




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


[Lldb-commits] [lldb] [lldb] Use packaging module instead of pkg_resources (PR #93712)

2024-05-31 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> That said, using a package designed (AIUI) for python versions for parsing 
> versions of gcc/clang does strike me as somewhat... unusual, even if it does 
> work, so _**maybe**_ there is case to be made for writing something custom 
> (I'm not sure if we really need anything more elaborate than 
> `tuple([int(part) for part in version.split(".")])`)

Agreed. The first time I took a stab at this, that was the first thing I tried, 
but I quickly discovered that we had at least one tool (I think it was Python 
itself?) that contained alphabetical characters (something like `1.2.3rc` or 
`1.2.3.dev`) and I didn't feel like dealing with all the possible edge cases. 
We have other packages the test suite relies on (pexpect, psutil, etc) so it 
seemed reasonable, but if folks feel strongly about it we can maintain our own 
"version parsing". 

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


[Lldb-commits] [lldb] [lldb] Use packaging module instead of pkg_resources (PR #93712)

2024-05-31 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> FWIW, there appears to be an actual arch package for this 
> https://archlinux.org/packages/extra/any/python-packaging/, so it shouldn't 
> be (I think -- I'm not an Arch user) necessary to install `pip`.

Homebrew on macOS works similarly, it has a 
[python-packaging](https://formulae.brew.sh/formula/python-packaging) package 
that you install with `brew install python-packaging`.

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


[Lldb-commits] [lldb] [lldb][test] Add --make argument to dotest.py (PR #93883)

2024-05-31 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][test] Add --make argument to dotest.py (PR #93883)

2024-05-31 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

LGTM with the formatting fixed.

https://github.com/llvm/llvm-project/pull/93883
___
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 Jonas Devlieghere via lldb-commits

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


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] FormatManager::GetPossibleMatches assumes all ValueObjects have targets. (PR #93880)

2024-05-31 Thread via lldb-commits

jimingham wrote:

> LGTM assuming you can make the formatter happy.

This change says "If a ValueObject has no target, don't try to find a formatter 
for it".  If it doesn't have a target, it's either an error or stale, and isn't 
going to have a value to format, so any more work we did here would be 
pointless.

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


[Lldb-commits] [lldb] 1e81b67 - [lldb] FormatManager::GetPossibleMatches assumes all ValueObjects have targets. (#93880)

2024-05-31 Thread via lldb-commits

Author: jimingham
Date: 2024-05-31T10:43:05-07:00
New Revision: 1e81b67925fdd77a3d65ba2a7f652d1e840512f4

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

LOG: [lldb] FormatManager::GetPossibleMatches assumes all ValueObjects have 
targets. (#93880)

But one made in a situation where that's impossible might only have an
error, and no symbol context, so that's not necessarily true. Check for
the target's validity before using it.

Fixes issue #93313

Added: 


Modified: 
lldb/source/DataFormatters/FormatManager.cpp
lldb/test/API/python_api/run_locker/TestRunLocker.py

Removed: 




diff  --git a/lldb/source/DataFormatters/FormatManager.cpp 
b/lldb/source/DataFormatters/FormatManager.cpp
index d7ba5b4b70c94..60765952760a2 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -176,8 +176,14 @@ void FormatManager::GetPossibleMatches(
 FormattersMatchCandidate::Flags current_flags, bool root_level) {
   compiler_type = compiler_type.GetTypeForFormatters();
   ConstString type_name(compiler_type.GetTypeName());
+  // A ValueObject that couldn't be made correctly won't necessarily have a
+  // target.  We aren't going to find a formatter in this case anyway, so we
+  // should just exit.
+  TargetSP target_sp = valobj.GetTargetSP();
+  if (!target_sp)
+return;
   ScriptInterpreter *script_interpreter =
-  valobj.GetTargetSP()->GetDebugger().GetScriptInterpreter();
+  target_sp->GetDebugger().GetScriptInterpreter();
   if (valobj.GetBitfieldBitSize() > 0) {
 StreamString sstring;
 sstring.Printf("%s:%d", type_name.AsCString(), 
valobj.GetBitfieldBitSize());

diff  --git a/lldb/test/API/python_api/run_locker/TestRunLocker.py 
b/lldb/test/API/python_api/run_locker/TestRunLocker.py
index 4e0dd26bff70d..d525bbf6b406f 100644
--- a/lldb/test/API/python_api/run_locker/TestRunLocker.py
+++ b/lldb/test/API/python_api/run_locker/TestRunLocker.py
@@ -85,6 +85,13 @@ def runlocker_test(self, stop_at_entry):
 # you aren't supposed to do while running, and that we get some
 # actual error:
 val = target.EvaluateExpression("SomethingToCall()")
+# There was a bug [#93313] in the printing that would cause repr to 
crash, so I'm
+# testing that separately.
+self.assertIn(
+"can't evaluate expressions when the process is running",
+repr(val),
+"repr works"
+)
 error = val.GetError()
 self.assertTrue(error.Fail(), "Failed to run expression")
 self.assertIn(



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


[Lldb-commits] [lldb] [lldb] FormatManager::GetPossibleMatches assumes all ValueObjects have targets. (PR #93880)

2024-05-31 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Avoid (unlimited) GetNumChildren calls when printing values (PR #93946)

2024-05-31 Thread via lldb-commits

jimingham wrote:

This seems reasonable.  However, I note that on the page where we show how to 
write synthetic child providers, we say:

   def num_children(self):
  this call should return the number of children that you want your object 
to have

That's actually not true - we pass the max_children argument on to the 
num_children method, and in fact some of the tests do use the max parameter.  
But since you're making that actually useful, can you fix the docs so people 
will know to take advantage of this?

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


[Lldb-commits] [lldb] A few updates around "transcript" (PR #92843)

2024-05-31 Thread via lldb-commits

https://github.com/royitaqi updated 
https://github.com/llvm/llvm-project/pull/92843

>From 8499f16ad46b3268f35da2bfcbfa02a10aab935a Mon Sep 17 00:00:00 2001
From: Roy Shi 
Date: Mon, 20 May 2024 22:30:40 -0400
Subject: [PATCH 01/10] Add resolvedCommand to transcript, add transcript to
 statistics dump

---
 lldb/include/lldb/API/SBCommandInterpreter.h  |  3 +-
 .../lldb/Interpreter/CommandInterpreter.h |  5 +--
 .../source/Interpreter/CommandInterpreter.cpp |  6 
 lldb/source/Target/Statistics.cpp | 31 +++
 .../commands/statistics/basic/TestStats.py| 30 ++
 .../interpreter/TestCommandInterpreterAPI.py  | 20 
 6 files changed, 86 insertions(+), 9 deletions(-)

diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h 
b/lldb/include/lldb/API/SBCommandInterpreter.h
index 8ac36344b3a79..8eb4a71cb7f88 100644
--- a/lldb/include/lldb/API/SBCommandInterpreter.h
+++ b/lldb/include/lldb/API/SBCommandInterpreter.h
@@ -320,7 +320,8 @@ class SBCommandInterpreter {
 
   /// Returns a list of handled commands, output and error. Each element in
   /// the list is a dictionary with the following keys/values:
-  /// - "command" (string): The command that was executed.
+  /// - "command" (string): The command that was given by the user.
+  /// - "resolvedCommand" (string): The expanded command that was executed.
   /// - "output" (string): The output of the command. Empty ("") if no output.
   /// - "error" (string): The error of the command. Empty ("") if no error.
   /// - "seconds" (float): The time it took to execute the command.
diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index ccc30cf4f1a82..7f420daca450a 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -580,7 +580,7 @@ class CommandInterpreter : public Broadcaster,
   void SetEchoCommentCommands(bool enable);
 
   bool GetRepeatPreviousCommand() const;
-  
+
   bool GetRequireCommandOverwrite() const;
 
   const CommandObject::CommandMap &GetUserCommands() const {
@@ -776,7 +776,8 @@ class CommandInterpreter : public Broadcaster,
 
   /// Contains a list of handled commands and their details. Each element in
   /// the list is a dictionary with the following keys/values:
-  /// - "command" (string): The command that was executed.
+  /// - "command" (string): The command that was given by the user.
+  /// - "resolvedCommand" (string): The expanded command that was executed.
   /// - "output" (string): The output of the command. Empty ("") if no output.
   /// - "error" (string): The error of the command. Empty ("") if no error.
   /// - "seconds" (float): The time it took to execute the command.
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index 811726e30af4d..04820bd7d39f6 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2011,6 +2011,12 @@ bool CommandInterpreter::HandleCommand(const char 
*command_line,
   wants_raw_input ? "True" : "False");
   }
 
+  // To test whether or not transcript should be saved, `transcript_item` is
+  // used instead of `GetSaveTrasncript()`. This is because the latter will
+  // fail when the command is "settings set interpreter.save-transcript true".
+  if (transcript_item)
+transcript_item->AddStringItem("resolvedCommand", command_string);
+
   // Phase 2.
   // Take care of things like setting up the history command & calling the
   // appropriate Execute method on the CommandObject, with the appropriate
diff --git a/lldb/source/Target/Statistics.cpp 
b/lldb/source/Target/Statistics.cpp
index 7f866ae0ef324..fd31377abd06b 100644
--- a/lldb/source/Target/Statistics.cpp
+++ b/lldb/source/Target/Statistics.cpp
@@ -16,6 +16,7 @@
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/UnixSignals.h"
+#include "lldb/Utility/StructuredData.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -362,6 +363,36 @@ llvm::json::Value DebuggerStats::ReportStatistics(
 global_stats.try_emplace("modules", std::move(json_modules));
 global_stats.try_emplace("memory", std::move(json_memory));
 global_stats.try_emplace("commands", std::move(cmd_stats));
+
+// When transcript is available, add it to the to-be-returned statistics.
+//
+// NOTE:
+// When the statistics is polled by an LLDB command:
+// - The transcript in the returned statistics *will NOT* contain the
+//   returned statistics itself.
+// - The returned statistics *will* be written to the internal transcript
+//   buffer as the output of the said LLDB command. It *will* appear in
+//   the next statistcs or transcript poll.
+//
+// For example, let's say the following commands are run in order:
+// - "version"
+// - "statisti

[Lldb-commits] [lldb] A few updates around "transcript" (PR #92843)

2024-05-31 Thread via lldb-commits


@@ -1425,4 +1425,6 @@ let Command = "statistics dump" in {
 Desc<"Dump the total possible debug info statistics. "
 "Force loading all the debug information if not yet loaded, and collect "
 "statistics with those.">;
+  def statistics_dump_transcript: Option<"transcript", "t">, Group<1>,
+Desc<"Include transcript.">;

royitaqi wrote:

Added.

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


[Lldb-commits] [lldb] [lldb] Avoid (unlimited) GetNumChildren calls when printing values (PR #93946)

2024-05-31 Thread via lldb-commits

jimingham wrote:

BTW, because the max number of children is probably getting ignored in the 
wild, this has to be advisory, you can't require that:

val.GetNumChildren(max_children) <= max_children

I don't think you do that but it might be good to note the fact.

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


[Lldb-commits] [lldb] A few updates around "transcript" (PR #92843)

2024-05-31 Thread Greg Clayton via lldb-commits

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


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


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

2024-05-31 Thread via lldb-commits

Author: Dave Lee
Date: 2024-05-31T11:20:23-07:00
New Revision: 5a02a9a2e6794f086dfe1cd6f15ba2210bc0

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

LOG: [lldb] Improve identification of Dlang mangled names (#93881)

Reduce false positive identification of C names as Dlang mangled names. This 
happens 
when a C function uses the prefix `_D`.

The [Dlang ABI](https://dlang.org/spec/abi.html#name_mangling) shows that 
mangled names 
have a length immediately following the `_D` prefix. This change checks for a 
digit 
after the `_D` prefix, when identifying the mangling scheme of a symbol. This 
doesn't 
prevent false positives entirely, but does make it less likely.

Added: 
lldb/test/API/lang/c/non-mangled/Makefile
lldb/test/API/lang/c/non-mangled/TestCNonMangled.py
lldb/test/API/lang/c/non-mangled/main.c

Modified: 
lldb/source/Core/Mangled.cpp

Removed: 




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..aae2f05263fcd
--- /dev/null
+++ b/lldb/test/API/lang/c/non-mangled/TestCNonMangled.py
@@ -0,0 +1,15 @@
+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-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] A few updates around "transcript" (PR #92843)

2024-05-31 Thread via lldb-commits

https://github.com/royitaqi updated 
https://github.com/llvm/llvm-project/pull/92843

>From 8499f16ad46b3268f35da2bfcbfa02a10aab935a Mon Sep 17 00:00:00 2001
From: Roy Shi 
Date: Mon, 20 May 2024 22:30:40 -0400
Subject: [PATCH 01/11] Add resolvedCommand to transcript, add transcript to
 statistics dump

---
 lldb/include/lldb/API/SBCommandInterpreter.h  |  3 +-
 .../lldb/Interpreter/CommandInterpreter.h |  5 +--
 .../source/Interpreter/CommandInterpreter.cpp |  6 
 lldb/source/Target/Statistics.cpp | 31 +++
 .../commands/statistics/basic/TestStats.py| 30 ++
 .../interpreter/TestCommandInterpreterAPI.py  | 20 
 6 files changed, 86 insertions(+), 9 deletions(-)

diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h 
b/lldb/include/lldb/API/SBCommandInterpreter.h
index 8ac36344b3a79..8eb4a71cb7f88 100644
--- a/lldb/include/lldb/API/SBCommandInterpreter.h
+++ b/lldb/include/lldb/API/SBCommandInterpreter.h
@@ -320,7 +320,8 @@ class SBCommandInterpreter {
 
   /// Returns a list of handled commands, output and error. Each element in
   /// the list is a dictionary with the following keys/values:
-  /// - "command" (string): The command that was executed.
+  /// - "command" (string): The command that was given by the user.
+  /// - "resolvedCommand" (string): The expanded command that was executed.
   /// - "output" (string): The output of the command. Empty ("") if no output.
   /// - "error" (string): The error of the command. Empty ("") if no error.
   /// - "seconds" (float): The time it took to execute the command.
diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index ccc30cf4f1a82..7f420daca450a 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -580,7 +580,7 @@ class CommandInterpreter : public Broadcaster,
   void SetEchoCommentCommands(bool enable);
 
   bool GetRepeatPreviousCommand() const;
-  
+
   bool GetRequireCommandOverwrite() const;
 
   const CommandObject::CommandMap &GetUserCommands() const {
@@ -776,7 +776,8 @@ class CommandInterpreter : public Broadcaster,
 
   /// Contains a list of handled commands and their details. Each element in
   /// the list is a dictionary with the following keys/values:
-  /// - "command" (string): The command that was executed.
+  /// - "command" (string): The command that was given by the user.
+  /// - "resolvedCommand" (string): The expanded command that was executed.
   /// - "output" (string): The output of the command. Empty ("") if no output.
   /// - "error" (string): The error of the command. Empty ("") if no error.
   /// - "seconds" (float): The time it took to execute the command.
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index 811726e30af4d..04820bd7d39f6 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2011,6 +2011,12 @@ bool CommandInterpreter::HandleCommand(const char 
*command_line,
   wants_raw_input ? "True" : "False");
   }
 
+  // To test whether or not transcript should be saved, `transcript_item` is
+  // used instead of `GetSaveTrasncript()`. This is because the latter will
+  // fail when the command is "settings set interpreter.save-transcript true".
+  if (transcript_item)
+transcript_item->AddStringItem("resolvedCommand", command_string);
+
   // Phase 2.
   // Take care of things like setting up the history command & calling the
   // appropriate Execute method on the CommandObject, with the appropriate
diff --git a/lldb/source/Target/Statistics.cpp 
b/lldb/source/Target/Statistics.cpp
index 7f866ae0ef324..fd31377abd06b 100644
--- a/lldb/source/Target/Statistics.cpp
+++ b/lldb/source/Target/Statistics.cpp
@@ -16,6 +16,7 @@
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/UnixSignals.h"
+#include "lldb/Utility/StructuredData.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -362,6 +363,36 @@ llvm::json::Value DebuggerStats::ReportStatistics(
 global_stats.try_emplace("modules", std::move(json_modules));
 global_stats.try_emplace("memory", std::move(json_memory));
 global_stats.try_emplace("commands", std::move(cmd_stats));
+
+// When transcript is available, add it to the to-be-returned statistics.
+//
+// NOTE:
+// When the statistics is polled by an LLDB command:
+// - The transcript in the returned statistics *will NOT* contain the
+//   returned statistics itself.
+// - The returned statistics *will* be written to the internal transcript
+//   buffer as the output of the said LLDB command. It *will* appear in
+//   the next statistcs or transcript poll.
+//
+// For example, let's say the following commands are run in order:
+// - "version"
+// - "statisti

[Lldb-commits] [lldb] Add doc strings for SBValue::IsValid and SBValue::GetError. (PR #94007)

2024-05-31 Thread via lldb-commits

https://github.com/jimingham created 
https://github.com/llvm/llvm-project/pull/94007

The IsValid API is actually quite weak - it means "this value can't answer any 
questions meaningfully." But I've run into a couple cases where people thought 
it meant "was able to reconstruct the value on this stop" which it does not 
mean.
These additions should clear that up.

>From e024ea45c052411f2e7284c0ef5a6d048681cad7 Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Fri, 31 May 2024 11:29:27 -0700
Subject: [PATCH] Add doc strings for SBValue::IsValid and SBValue::GetError.

The IsValid API is actually quite weak - it means "this value can't
answer any questions meaningfully." But I've run into a couple cases
where people thought it meant "was able to reconstruct the value on
this stop" which it does not mean.
These additions should clear that up.
---
 lldb/bindings/interface/SBValueDocstrings.i | 30 +
 1 file changed, 30 insertions(+)

diff --git a/lldb/bindings/interface/SBValueDocstrings.i 
b/lldb/bindings/interface/SBValueDocstrings.i
index 59fa807f5ec95..7abbfe58dc5ea 100644
--- a/lldb/bindings/interface/SBValueDocstrings.i
+++ b/lldb/bindings/interface/SBValueDocstrings.i
@@ -45,6 +45,36 @@ SBValue instance which interprets the value object as 
representing the head of a
 linked list."
 ) lldb::SBValue;
 
+%feature("docstring", "
+Returns true if the SBValue holds any useful state
+and false otherwise.
+IsValid is a very weak API, lldb will only return
+invalid SBValues if it has no useful information
+about the SBValue.
+The two main ways you will end up with an invalid
+SBValue are:
+1) default constructed SBValues are not valid.
+2) SBValues that have outlived their SBTarget are
+no longer valid since its not safe to ask them
+questions.
+"
+) lldb::SBValue::IsValid
+
+%feature("docstring", "
+SBValues use the lldb::SBError object returned by
+this API to report construction errors when the SBValue
+is made; and on each stop, the SBError will tell you
+whether lldb could successfully determine the value for
+this program entity represented by this SBValue.
+
+For instance, if you made an SBValue to
+represent a local variable, and then stepped to a PC where
+the variable was unavailable due to optimization, then
+GetError().Success() will be false for this stop, and the
+error string will have more information about the failure.
+"
+) lldb::SBValue::GetError
+
 %feature("docstring", "
 Get a child value by index from a value.
 

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


[Lldb-commits] [lldb] Add doc strings for SBValue::IsValid and SBValue::GetError. (PR #94007)

2024-05-31 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (jimingham)


Changes

The IsValid API is actually quite weak - it means "this value can't answer any 
questions meaningfully." But I've run into a couple cases where people thought 
it meant "was able to reconstruct the value on this stop" which it does not 
mean.
These additions should clear that up.

---
Full diff: https://github.com/llvm/llvm-project/pull/94007.diff


1 Files Affected:

- (modified) lldb/bindings/interface/SBValueDocstrings.i (+30) 


``diff
diff --git a/lldb/bindings/interface/SBValueDocstrings.i 
b/lldb/bindings/interface/SBValueDocstrings.i
index 59fa807f5ec95..7abbfe58dc5ea 100644
--- a/lldb/bindings/interface/SBValueDocstrings.i
+++ b/lldb/bindings/interface/SBValueDocstrings.i
@@ -45,6 +45,36 @@ SBValue instance which interprets the value object as 
representing the head of a
 linked list."
 ) lldb::SBValue;
 
+%feature("docstring", "
+Returns true if the SBValue holds any useful state
+and false otherwise.
+IsValid is a very weak API, lldb will only return
+invalid SBValues if it has no useful information
+about the SBValue.
+The two main ways you will end up with an invalid
+SBValue are:
+1) default constructed SBValues are not valid.
+2) SBValues that have outlived their SBTarget are
+no longer valid since its not safe to ask them
+questions.
+"
+) lldb::SBValue::IsValid
+
+%feature("docstring", "
+SBValues use the lldb::SBError object returned by
+this API to report construction errors when the SBValue
+is made; and on each stop, the SBError will tell you
+whether lldb could successfully determine the value for
+this program entity represented by this SBValue.
+
+For instance, if you made an SBValue to
+represent a local variable, and then stepped to a PC where
+the variable was unavailable due to optimization, then
+GetError().Success() will be false for this stop, and the
+error string will have more information about the failure.
+"
+) lldb::SBValue::GetError
+
 %feature("docstring", "
 Get a child value by index from a value.
 

``




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


[Lldb-commits] [lldb] A few updates around "transcript" (PR #92843)

2024-05-31 Thread via lldb-commits

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


[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [mlir] [openmp] [polly] fix(python): fix comparison to None (PR #91857)

2024-05-31 Thread Eisuke Kawashima via lldb-commits

https://github.com/e-kwsm updated 
https://github.com/llvm/llvm-project/pull/91857

>From 8379b042ef389e7c032e1bc3b32957bd386e2411 Mon Sep 17 00:00:00 2001
From: Eisuke Kawashima 
Date: Sat, 11 May 2024 23:57:11 +0900
Subject: [PATCH 1/2] fix(python): fix comparison to None

from PEP8 (https://peps.python.org/pep-0008/#programming-recommendations):

> Comparisons to singletons like None should always be done with is or
> is not, never the equality operators.
---
 .../clang-tidy/checks/gen-static-analyzer-docs.py|  2 +-
 clang/docs/DebuggingCoroutines.rst   |  8 
 clang/tools/include-mapping/gen_std.py   |  2 +-
 clang/utils/check_cfc/obj_diff.py|  2 +-
 clang/utils/module-deps-to-rsp.py|  2 +-
 compiler-rt/test/asan/lit.cfg.py |  2 +-
 compiler-rt/test/builtins/Unit/lit.cfg.py|  2 +-
 compiler-rt/test/ctx_profile/lit.cfg.py  |  2 +-
 compiler-rt/test/lsan/lit.common.cfg.py  |  2 +-
 compiler-rt/test/memprof/lit.cfg.py  |  2 +-
 compiler-rt/test/profile/lit.cfg.py  |  2 +-
 .../android_commands/android_compile.py  |  2 +-
 .../sanitizer_common/ios_commands/iossim_compile.py  |  2 +-
 compiler-rt/test/ubsan/lit.common.cfg.py |  2 +-
 compiler-rt/test/ubsan_minimal/lit.common.cfg.py |  2 +-
 .../dexter/dex/command/ParseCommand.py   |  2 +-
 .../DebuggerControllers/ConditionalController.py |  4 ++--
 .../DebuggerControllers/ControllerHelpers.py |  2 +-
 .../debuginfo-tests/dexter/dex/debugger/Debuggers.py |  2 +-
 .../dexter/dex/debugger/visualstudio/VisualStudio.py |  2 +-
 .../debuginfo-tests/dexter/dex/tools/test/Tool.py|  2 +-
 cross-project-tests/lit.cfg.py   |  2 +-
 lldb/docs/use/python.rst |  4 ++--
 .../python/armv7_cortex_m_target_defintion.py|  2 +-
 lldb/packages/Python/lldbsuite/test/dotest.py|  2 +-
 lldb/packages/Python/lldbsuite/test/lldbtest.py  |  6 +++---
 lldb/packages/Python/lldbsuite/test/lldbutil.py  |  6 +++---
 .../lldbsuite/test/tools/intelpt/intelpt_testcase.py |  2 +-
 .../address_breakpoints/TestBadAddressBreakpoints.py |  2 +-
 .../step_scripted/TestStepScripted.py|  2 +-
 .../TestStopOnSharedlibraryEvents.py |  2 +-
 lldb/test/API/lua_api/TestLuaAPI.py  |  2 +-
 .../thread_suspend/TestInternalThreadSuspension.py   |  2 +-
 lldb/test/API/python_api/event/TestEvents.py |  2 +-
 .../process/read-mem-cstring/TestReadMemCString.py   |  2 +-
 lldb/test/API/python_api/type/TestTypeList.py|  2 +-
 .../API/python_api/was_interrupted/interruptible.py  |  2 +-
 lldb/test/Shell/lit.cfg.py   |  2 +-
 llvm/utils/indirect_calls.py |  2 +-
 llvm/utils/lit/lit/TestRunner.py |  2 +-
 llvm/utils/lit/lit/util.py   |  2 +-
 llvm/utils/schedcover.py |  2 +-
 llvm/utils/shuffle_select_fuzz_tester.py | 12 ++--
 mlir/test/python/ir/affine_expr.py   |  2 +-
 mlir/test/python/ir/attributes.py|  8 
 mlir/test/python/ir/builtin_types.py |  8 
 openmp/libompd/gdb-plugin/ompd/ompd_callbacks.py |  2 +-
 polly/lib/External/isl/libisl-gdb.py |  4 ++--
 polly/lib/External/isl/python/isl.py.top |  4 ++--
 polly/utils/pyscop/isl.py|  8 
 50 files changed, 75 insertions(+), 75 deletions(-)

diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py 
b/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py
index 6545a3906fa50..53ecb60dec539 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py
+++ b/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py
@@ -47,7 +47,7 @@ def get_checkers(checkers_td, checkers_rst):
 parent_package_ = package["ParentPackage"]
 hidden = (checker["Hidden"] != 0) or (package["Hidden"] != 0)
 
-while parent_package_ != None:
+while parent_package_ is not None:
 parent_package = table_entries[parent_package_["def"]]
 checker_package_prefix = (
 parent_package["PackageName"] + "." + checker_package_prefix
diff --git a/clang/docs/DebuggingCoroutines.rst 
b/clang/docs/DebuggingCoroutines.rst
index 53bdd08fdbc02..7f464c1f4f28c 100644
--- a/clang/docs/DebuggingCoroutines.rst
+++ b/clang/docs/DebuggingCoroutines.rst
@@ -513,7 +513,7 @@ So we can use the ``continuation`` field to construct the 
asynchronous stack:
   self.coro_frame = coro_frame
   self.resume_func = dereference(self.coro_frame.resume_addr)
   self.resume_func_block = gdb.block_for_pc(self.resume_func)
-  if self.resume_func_

[Lldb-commits] [lldb] [lldb] Use packaging module instead of pkg_resources (PR #93712)

2024-05-31 Thread Daniel Thornburgh via lldb-commits

mysterymath wrote:

> We have other packages the test suite relies on (pexpect, psutil, etc) so it 
> seemed reasonable, but if folks feel strongly about it we can maintain our 
> own "version parsing".

Notably the other packages are optional; the lion's share of the test suite can 
be run without them. Cursorily it looks like this wouldn't be the case here? 
Admittedly, Fuchsia is the reason at least one of those callouts has been 
added; we've struggled reigning in LLVM/LLDB's deps due to the manual nature of 
our build scripts and bureaucratic hassles involved in taking on new deps. But 
it might be a good idea to have a broader discussion about what the mandatory 
dep story is/should be for parts of LLVM, rather than doing this piecemeal on 
patches like this.

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


[Lldb-commits] [lldb] fix(lldb/**.py): fix comparison to None (PR #94017)

2024-05-31 Thread Eisuke Kawashima via lldb-commits

https://github.com/e-kwsm created 
https://github.com/llvm/llvm-project/pull/94017

from PEP8 (https://peps.python.org/pep-0008/#programming-recommendations):

> Comparisons to singletons like None should always be done with is or is not, 
> never the equality operators.

>From 3142b6184498b133866dee82d25d0eb596507740 Mon Sep 17 00:00:00 2001
From: Eisuke Kawashima 
Date: Sat, 11 May 2024 23:57:11 +0900
Subject: [PATCH] fix(lldb/**.py): fix comparison to None

from PEP8 (https://peps.python.org/pep-0008/#programming-recommendations):

> Comparisons to singletons like None should always be done with is or
> is not, never the equality operators.
---
 lldb/bindings/interface/SBBreakpointDocstrings.i  | 2 +-
 lldb/bindings/interface/SBDataExtensions.i| 8 
 lldb/docs/use/python.rst  | 4 ++--
 lldb/examples/python/armv7_cortex_m_target_defintion.py   | 2 +-
 lldb/packages/Python/lldbsuite/test/dotest.py | 2 +-
 lldb/packages/Python/lldbsuite/test/lldbtest.py   | 6 +++---
 lldb/packages/Python/lldbsuite/test/lldbutil.py   | 6 +++---
 .../lldbsuite/test/tools/intelpt/intelpt_testcase.py  | 2 +-
 .../address_breakpoints/TestBadAddressBreakpoints.py  | 2 +-
 .../API/functionalities/step_scripted/TestStepScripted.py | 2 +-
 .../TestStopOnSharedlibraryEvents.py  | 2 +-
 lldb/test/API/lua_api/TestLuaAPI.py   | 2 +-
 .../macosx/thread_suspend/TestInternalThreadSuspension.py | 2 +-
 lldb/test/API/python_api/event/TestEvents.py  | 2 +-
 .../process/read-mem-cstring/TestReadMemCString.py| 2 +-
 lldb/test/API/python_api/type/TestTypeList.py | 2 +-
 lldb/test/API/python_api/was_interrupted/interruptible.py | 2 +-
 lldb/test/Shell/lit.cfg.py| 2 +-
 18 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/lldb/bindings/interface/SBBreakpointDocstrings.i 
b/lldb/bindings/interface/SBBreakpointDocstrings.i
index 74c139d5d9fb6..dca2819a9927b 100644
--- a/lldb/bindings/interface/SBBreakpointDocstrings.i
+++ b/lldb/bindings/interface/SBBreakpointDocstrings.i
@@ -39,7 +39,7 @@ TestBreakpointIgnoreCount.py),::
 #lldbutil.print_stacktraces(process)
 from lldbutil import get_stopped_thread
 thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
-self.assertTrue(thread != None, 'There should be a thread stopped due 
to breakpoint')
+self.assertTrue(thread is not None, 'There should be a thread stopped 
due to breakpoint')
 frame0 = thread.GetFrameAtIndex(0)
 frame1 = thread.GetFrameAtIndex(1)
 frame2 = thread.GetFrameAtIndex(2)
diff --git a/lldb/bindings/interface/SBDataExtensions.i 
b/lldb/bindings/interface/SBDataExtensions.i
index d980e79221c6d..ddea77a088dfa 100644
--- a/lldb/bindings/interface/SBDataExtensions.i
+++ b/lldb/bindings/interface/SBDataExtensions.i
@@ -40,19 +40,19 @@ STRING_EXTENSION_OUTSIDE(SBData)
 lldbtarget = lldbdict['target']
 else:
 lldbtarget = None
-if target == None and lldbtarget != None and lldbtarget.IsValid():
+if target is None and lldbtarget is not None and 
lldbtarget.IsValid():
 target = lldbtarget
-if ptr_size == None:
+if ptr_size is None:
 if target and target.IsValid():
 ptr_size = target.addr_size
 else:
 ptr_size = 8
-if endian == None:
+if endian is None:
 if target and target.IsValid():
 endian = target.byte_order
 else:
 endian = lldbdict['eByteOrderLittle']
-if size == None:
+if size is None:
 if value > 2147483647:
 size = 8
 elif value < -2147483648:
diff --git a/lldb/docs/use/python.rst b/lldb/docs/use/python.rst
index 6183d6935d80e..d9c29d95708c1 100644
--- a/lldb/docs/use/python.rst
+++ b/lldb/docs/use/python.rst
@@ -75,13 +75,13 @@ later explanations:
12: if root_word == word:
13: return cur_path
14: elif word < root_word:
-   15: if left_child_ptr.GetValue() == None:
+   15: if left_child_ptr.GetValue() is None:
16: return ""
17: else:
18: cur_path = cur_path + "L"
19: return DFS (left_child_ptr, word, cur_path)
20: else:
-   21: if right_child_ptr.GetValue() == None:
+   21: if right_child_ptr.GetValue() is None:
22: return ""
23: else:
24: cur_path = cur_path + "R"
diff --git a/lldb/examples/python/armv7_cortex_m_target_defintion.py 
b/lldb/examples/python/armv7_cortex_m_target_defintion.py
index 42eaa39993dae..8225670f33e6b 100755
--- a/lldb/examples/python/armv7_cortex_m_target_defint

[Lldb-commits] [lldb] fix(lldb/**.py): fix comparison to None (PR #94017)

2024-05-31 Thread via lldb-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[Lldb-commits] [lldb] fix(lldb/**.py): fix comparison to None (PR #94017)

2024-05-31 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Eisuke Kawashima (e-kwsm)


Changes

from PEP8 (https://peps.python.org/pep-0008/#programming-recommendations):

> Comparisons to singletons like None should always be done with is or is 
not, never the equality operators.

---
Full diff: https://github.com/llvm/llvm-project/pull/94017.diff


18 Files Affected:

- (modified) lldb/bindings/interface/SBBreakpointDocstrings.i (+1-1) 
- (modified) lldb/bindings/interface/SBDataExtensions.i (+4-4) 
- (modified) lldb/docs/use/python.rst (+2-2) 
- (modified) lldb/examples/python/armv7_cortex_m_target_defintion.py (+1-1) 
- (modified) lldb/packages/Python/lldbsuite/test/dotest.py (+1-1) 
- (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+3-3) 
- (modified) lldb/packages/Python/lldbsuite/test/lldbutil.py (+3-3) 
- (modified) 
lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py (+1-1) 
- (modified) 
lldb/test/API/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py
 (+1-1) 
- (modified) lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
(+1-1) 
- (modified) 
lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py
 (+1-1) 
- (modified) lldb/test/API/lua_api/TestLuaAPI.py (+1-1) 
- (modified) 
lldb/test/API/macosx/thread_suspend/TestInternalThreadSuspension.py (+1-1) 
- (modified) lldb/test/API/python_api/event/TestEvents.py (+1-1) 
- (modified) 
lldb/test/API/python_api/process/read-mem-cstring/TestReadMemCString.py (+1-1) 
- (modified) lldb/test/API/python_api/type/TestTypeList.py (+1-1) 
- (modified) lldb/test/API/python_api/was_interrupted/interruptible.py (+1-1) 
- (modified) lldb/test/Shell/lit.cfg.py (+1-1) 


``diff
diff --git a/lldb/bindings/interface/SBBreakpointDocstrings.i 
b/lldb/bindings/interface/SBBreakpointDocstrings.i
index 74c139d5d9fb6..dca2819a9927b 100644
--- a/lldb/bindings/interface/SBBreakpointDocstrings.i
+++ b/lldb/bindings/interface/SBBreakpointDocstrings.i
@@ -39,7 +39,7 @@ TestBreakpointIgnoreCount.py),::
 #lldbutil.print_stacktraces(process)
 from lldbutil import get_stopped_thread
 thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
-self.assertTrue(thread != None, 'There should be a thread stopped due 
to breakpoint')
+self.assertTrue(thread is not None, 'There should be a thread stopped 
due to breakpoint')
 frame0 = thread.GetFrameAtIndex(0)
 frame1 = thread.GetFrameAtIndex(1)
 frame2 = thread.GetFrameAtIndex(2)
diff --git a/lldb/bindings/interface/SBDataExtensions.i 
b/lldb/bindings/interface/SBDataExtensions.i
index d980e79221c6d..ddea77a088dfa 100644
--- a/lldb/bindings/interface/SBDataExtensions.i
+++ b/lldb/bindings/interface/SBDataExtensions.i
@@ -40,19 +40,19 @@ STRING_EXTENSION_OUTSIDE(SBData)
 lldbtarget = lldbdict['target']
 else:
 lldbtarget = None
-if target == None and lldbtarget != None and lldbtarget.IsValid():
+if target is None and lldbtarget is not None and 
lldbtarget.IsValid():
 target = lldbtarget
-if ptr_size == None:
+if ptr_size is None:
 if target and target.IsValid():
 ptr_size = target.addr_size
 else:
 ptr_size = 8
-if endian == None:
+if endian is None:
 if target and target.IsValid():
 endian = target.byte_order
 else:
 endian = lldbdict['eByteOrderLittle']
-if size == None:
+if size is None:
 if value > 2147483647:
 size = 8
 elif value < -2147483648:
diff --git a/lldb/docs/use/python.rst b/lldb/docs/use/python.rst
index 6183d6935d80e..d9c29d95708c1 100644
--- a/lldb/docs/use/python.rst
+++ b/lldb/docs/use/python.rst
@@ -75,13 +75,13 @@ later explanations:
12: if root_word == word:
13: return cur_path
14: elif word < root_word:
-   15: if left_child_ptr.GetValue() == None:
+   15: if left_child_ptr.GetValue() is None:
16: return ""
17: else:
18: cur_path = cur_path + "L"
19: return DFS (left_child_ptr, word, cur_path)
20: else:
-   21: if right_child_ptr.GetValue() == None:
+   21: if right_child_ptr.GetValue() is None:
22: return ""
23: else:
24: cur_path = cur_path + "R"
diff --git a/lldb/examples/python/armv7_cortex_m_target_defintion.py 
b/lldb/examples/python/armv7_cortex_m_target_defintion.py
index 42eaa39993dae..8225670f33e6b 100755
--- a/lldb/examples/python/armv7_cortex_m_target_defintion.py
+++ b/lldb/examples/python/armv7_cortex_m_target_defintion.py
@@ -222,7 +222,7 @@ def get_reg_num(reg_num_dict, reg_name):
 
 def get_target_definition():

[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [mlir] [openmp] [polly] fix(python): fix comparison to None (PR #91857)

2024-05-31 Thread Eisuke Kawashima via lldb-commits

e-kwsm wrote:

broken into

- #94012
- #94013
- #94014
- #94015
- #94016
- #94017
- #94018
- #94019
- #94020
- #94021
- #94022


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


[Lldb-commits] [lldb] [lldb] Support reading DW_OP_piece from file address (PR #94026)

2024-05-31 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/94026

We received a bug report where someone was trying to print a global variable 
without a process. This would succeed in a debug build but fail in a on 
optimized build. We traced the issue back to the location being described by a 
DW_OP_addr + DW_OP_piece.

The issue is that the DWARF expression evaluator only support reading pieces 
from a load address. There's no reason it cannot do the same for a file 
address, and indeed, that solves the problem.

I unsuccessfully tried to craft a test case to illustrate the original example, 
using a global struct and trying to trick the compiler into breaking it apart 
with SROA. Instead I wrote a unit test that uses a mock target to read memory 
from.

rdar://127435923

>From 0487856604f97d94d1be2502d9c41080064e2a64 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 31 May 2024 12:21:28 -0700
Subject: [PATCH] [lldb] Support reading DW_OP_piece from file address

We received a bug report where someone was trying to print a global
variable without a process. This would succeed in a debug build but fail
in a on optimized build. We traced the issue back to the location being
described by a DW_OP_addr + DW_OP_piece.

The issue is that the DWARF expression evaluator only support reading
pieces from a load address. There's no reason it cannot do the same for
a file address, and indeed, that solves the problem.

I unsuccessfully tried to craft a test case to illustrate the original
example, using a global struct and trying to trick the compiler into
breaking it apart with SROA. Instead I wrote a unit test that uses a
mock target to read memory from.

rdar://127435923
---
 lldb/include/lldb/Target/Target.h |  8 +--
 lldb/source/Expression/DWARFExpression.cpp| 46 ++
 .../Expression/DWARFExpressionTest.cpp| 60 +++
 3 files changed, 97 insertions(+), 17 deletions(-)

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 7ad9f33586054..792a4caa76e2d 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1077,9 +1077,9 @@ class Target : public 
std::enable_shared_from_this,
   // section, then read from the file cache
   // 2 - if there is a process, then read from memory
   // 3 - if there is no process, then read from the file cache
-  size_t ReadMemory(const Address &addr, void *dst, size_t dst_len,
-Status &error, bool force_live_memory = false,
-lldb::addr_t *load_addr_ptr = nullptr);
+  virtual size_t ReadMemory(const Address &addr, void *dst, size_t dst_len,
+Status &error, bool force_live_memory = false,
+lldb::addr_t *load_addr_ptr = nullptr);
 
   size_t ReadCStringFromMemory(const Address &addr, std::string &out_str,
Status &error, bool force_live_memory = false);
@@ -1615,7 +1615,7 @@ class Target : public 
std::enable_shared_from_this,
 
   TargetStats &GetStatistics() { return m_stats; }
 
-private:
+protected:
   /// Construct with optional file and arch.
   ///
   /// This member is private. Clients must use
diff --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index c061fd1140fff..aed550e52c579 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -2153,21 +2153,41 @@ bool DWARFExpression::Evaluate(
 }
 break;
 
-  case Value::ValueType::FileAddress:
-  case Value::ValueType::HostAddress:
-if (error_ptr) {
-  lldb::addr_t addr = 
curr_piece_source_value.GetScalar().ULongLong(
-  LLDB_INVALID_ADDRESS);
+  case Value::ValueType::FileAddress: {
+lldb::addr_t addr = curr_piece_source_value.GetScalar().ULongLong(
+LLDB_INVALID_ADDRESS);
+if (target) {
+  if (curr_piece.ResizeData(piece_byte_size) == piece_byte_size) {
+if (target->ReadMemory(addr, curr_piece.GetBuffer().GetBytes(),
+   piece_byte_size, error,
+   /*force_live_memory=*/false) !=
+piece_byte_size) {
+  if (error_ptr)
+error_ptr->SetErrorStringWithFormat(
+"failed to read memory DW_OP_piece(%" PRIu64
+") from load address 0x%" PRIx64,
+piece_byte_size, addr);
+  return false;
+}
+  } else {
+if (error_ptr)
+  error_ptr->SetErrorStringWithFormat(
+  "failed to read memory DW_OP_piece(%" PRIu64
+  ") from load address 0x%" PRIx64,
+  piece_byte_size, addr);
+ret

[Lldb-commits] [lldb] [lldb] Support reading DW_OP_piece from file address (PR #94026)

2024-05-31 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

We received a bug report where someone was trying to print a global variable 
without a process. This would succeed in a debug build but fail in a on 
optimized build. We traced the issue back to the location being described by a 
DW_OP_addr + DW_OP_piece.

The issue is that the DWARF expression evaluator only support reading pieces 
from a load address. There's no reason it cannot do the same for a file 
address, and indeed, that solves the problem.

I unsuccessfully tried to craft a test case to illustrate the original example, 
using a global struct and trying to trick the compiler into breaking it apart 
with SROA. Instead I wrote a unit test that uses a mock target to read memory 
from.

rdar://127435923

---
Full diff: https://github.com/llvm/llvm-project/pull/94026.diff


3 Files Affected:

- (modified) lldb/include/lldb/Target/Target.h (+4-4) 
- (modified) lldb/source/Expression/DWARFExpression.cpp (+33-13) 
- (modified) lldb/unittests/Expression/DWARFExpressionTest.cpp (+60) 


``diff
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 7ad9f33586054..792a4caa76e2d 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1077,9 +1077,9 @@ class Target : public 
std::enable_shared_from_this,
   // section, then read from the file cache
   // 2 - if there is a process, then read from memory
   // 3 - if there is no process, then read from the file cache
-  size_t ReadMemory(const Address &addr, void *dst, size_t dst_len,
-Status &error, bool force_live_memory = false,
-lldb::addr_t *load_addr_ptr = nullptr);
+  virtual size_t ReadMemory(const Address &addr, void *dst, size_t dst_len,
+Status &error, bool force_live_memory = false,
+lldb::addr_t *load_addr_ptr = nullptr);
 
   size_t ReadCStringFromMemory(const Address &addr, std::string &out_str,
Status &error, bool force_live_memory = false);
@@ -1615,7 +1615,7 @@ class Target : public 
std::enable_shared_from_this,
 
   TargetStats &GetStatistics() { return m_stats; }
 
-private:
+protected:
   /// Construct with optional file and arch.
   ///
   /// This member is private. Clients must use
diff --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index c061fd1140fff..aed550e52c579 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -2153,21 +2153,41 @@ bool DWARFExpression::Evaluate(
 }
 break;
 
-  case Value::ValueType::FileAddress:
-  case Value::ValueType::HostAddress:
-if (error_ptr) {
-  lldb::addr_t addr = 
curr_piece_source_value.GetScalar().ULongLong(
-  LLDB_INVALID_ADDRESS);
+  case Value::ValueType::FileAddress: {
+lldb::addr_t addr = curr_piece_source_value.GetScalar().ULongLong(
+LLDB_INVALID_ADDRESS);
+if (target) {
+  if (curr_piece.ResizeData(piece_byte_size) == piece_byte_size) {
+if (target->ReadMemory(addr, curr_piece.GetBuffer().GetBytes(),
+   piece_byte_size, error,
+   /*force_live_memory=*/false) !=
+piece_byte_size) {
+  if (error_ptr)
+error_ptr->SetErrorStringWithFormat(
+"failed to read memory DW_OP_piece(%" PRIu64
+") from load address 0x%" PRIx64,
+piece_byte_size, addr);
+  return false;
+}
+  } else {
+if (error_ptr)
+  error_ptr->SetErrorStringWithFormat(
+  "failed to read memory DW_OP_piece(%" PRIu64
+  ") from load address 0x%" PRIx64,
+  piece_byte_size, addr);
+return false;
+  }
+}
+  } break;
+  case Value::ValueType::HostAddress: {
+lldb::addr_t addr = curr_piece_source_value.GetScalar().ULongLong(
+LLDB_INVALID_ADDRESS);
+if (error_ptr)
   error_ptr->SetErrorStringWithFormat(
   "failed to read memory DW_OP_piece(%" PRIu64
-  ") from %s address 0x%" PRIx64,
-  piece_byte_size, curr_piece_source_value.GetValueType() ==
-   Value::ValueType::FileAddress
-   ? "file"
-   : "host",
-  addr);
-}
-return false;
+  ") from host address 0x%" PRIx64,
+  piece_byte_size, addr);
+  } break;
 

[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [mlir] [openmp] [polly] fix(python): fix comparison to None (PR #91857)

2024-05-31 Thread Eisuke Kawashima via lldb-commits

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


[Lldb-commits] [lldb] fix(lldb/**.py): fix invalid escape sequences (PR #94034)

2024-05-31 Thread Eisuke Kawashima via lldb-commits

https://github.com/e-kwsm created 
https://github.com/llvm/llvm-project/pull/94034

None

>From 5c7ba6c7d95cced5d8acc609a40a6b8307bc7fed Mon Sep 17 00:00:00 2001
From: Eisuke Kawashima 
Date: Sat, 11 May 2024 02:39:21 +0900
Subject: [PATCH] fix(lldb/**.py): fix invalid escape sequences

---
 lldb/examples/python/crashlog.py  |   8 +-
 lldb/examples/python/delta.py |   2 +-
 lldb/examples/python/gdbremote.py |   4 +-
 lldb/examples/python/jump.py  |   6 +-
 lldb/examples/python/performance.py   |   2 +-
 lldb/examples/python/symbolication.py |   6 +-
 .../Python/lldbsuite/test/lldbpexpect.py  |   2 +-
 .../test/test_runner/process_control.py   |   2 +-
 .../command/backticks/TestBackticksInAlias.py |   4 +-
 .../TestMemoryAllocSettings.py|   2 +-
 .../API/commands/expression/test/TestExprs.py |   2 +-
 .../TestGuiExpandThreadsTree.py   |   2 +-
 lldb/test/API/commands/help/TestHelp.py   |   6 +-
 .../TestLaunchWithShellExpand.py  |   2 +-
 .../register/TestRegistersUnavailable.py  |   4 +-
 .../API/commands/settings/TestSettings.py |  12 +-
 .../target/basic/TestTargetCommand.py |   2 +-
 .../dwo/TestDumpDwo.py|  16 +-
 .../oso/TestDumpOso.py|  16 +-
 .../API/commands/trace/TestTraceDumpInfo.py   |   2 +-
 .../API/commands/trace/TestTraceEvents.py |   4 +-
 .../API/commands/trace/TestTraceStartStop.py  |  12 +-
 lldb/test/API/commands/trace/TestTraceTSC.py  |  10 +-
 .../driver/quit_speed/TestQuitWithProcess.py  |   2 +-
 .../TestBreakpointByLineAndColumn.py  |   2 +-
 .../TestBreakpointLocations.py|   2 +-
 .../TestDataFormatterAdv.py   |   6 +-
 .../TestDataFormatterCpp.py   |   6 +-
 .../TestDataFormatterObjCNSContainer.py   |  16 +-
 .../TestDataFormatterSkipSummary.py   |   2 +-
 .../TestDataFormatterGenericUnordered.py  |  22 +--
 .../libcxx/atomic/TestLibCxxAtomic.py |   2 +-
 .../initializerlist/TestInitializerList.py|   2 +-
 .../TestTypeSummaryListArg.py |   4 +-
 .../memory-region/TestMemoryRegion.py |   2 +-
 .../target_var/TestTargetVar.py   |   2 +-
 .../completion/TestIOHandlerCompletion.py |   2 +-
 .../c/function_types/TestFunctionTypes.py |   2 +-
 .../TestRegisterVariables.py  |   2 +-
 .../API/lang/c/set_values/TestSetValues.py|   4 +-
 lldb/test/API/lang/c/strings/TestCStrings.py  |   2 +-
 .../API/lang/c/tls_globals/TestTlsGlobals.py  |   8 +-
 .../API/lang/cpp/char1632_t/TestChar1632T.py  |   8 +-
 .../cpp/class_static/TestStaticVariables.py   |   4 +-
 .../lang/cpp/class_types/TestClassTypes.py|   2 +-
 .../cpp/dynamic-value/TestDynamicValue.py |   2 +-
 .../API/lang/cpp/namespace/TestNamespace.py   |   4 +-
 .../lang/cpp/signed_types/TestSignedTypes.py  |   4 +-
 .../cpp/unsigned_types/TestUnsignedTypes.py   |   2 +-
 .../test/API/lang/mixed/TestMixedLanguages.py |   4 +-
 .../lang/objc/foundation/TestObjCMethods.py   |   2 +-
 .../objc/foundation/TestObjCMethodsNSArray.py |  10 +-
 .../objc/foundation/TestObjCMethodsNSError.py |   2 +-
 .../objc/foundation/TestObjCMethodsString.py  |  10 +-
 .../TestObjCDynamicValue.py   |   2 +-
 .../TestObjCBuiltinTypes.py   |   4 +-
 .../TestAArch64LinuxMTEMemoryTagCoreFile.py   |  44 ++---
 .../TestAArch64LinuxMTEMemoryTagAccess.py | 160 +-
 .../TestAArch64LinuxMTEMemoryTagFaults.py |   6 +-
 .../TestAArch64LinuxTaggedMemoryRegion.py |   4 +-
 .../macosx/add-dsym/TestAddDsymDownload.py|   2 +-
 .../TestFirmwareCorefiles.py  |   2 +-
 .../kern-ver-str/TestKernVerStrLCNOTE.py  |   2 +-
 .../TestMultipleBinaryCorefile.py |   2 +-
 .../macosx/simulator/TestSimulatorPlatform.py |   2 +-
 .../skinny-corefile/TestSkinnyCorefile.py |   2 +-
 .../TestTargetArchFromModule.py   |   2 +-
 .../API/source-manager/TestSourceManager.py   |   2 +-
 .../lldb-server/TestGdbRemoteModuleInfo.py|   6 +-
 .../API/tools/lldb-server/TestPtyServer.py|   2 +-
 .../TestGdbRemoteTargetXmlPacket.py   |   2 +-
 lldb/test/API/types/AbstractBase.py   |   6 +-
 lldb/utils/lui/sourcewin.py   |   2 +-
 73 files changed, 263 insertions(+), 263 deletions(-)

diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index 641b2e64d53b1..13e5d77ec6fe2 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -294,7 +294,7 @@ class DarwinImage(symbolication.Image):
 except:
 dsymForUUIDBinary = ""
 
-dwarfdump_uuid_regex = re.compile("UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) 
.*")
+dwarfdump_uuid_regex = re.compile(r"UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) 
.*")
 
 def __init__(
 self, tex

[Lldb-commits] [lldb] fix(lldb/**.py): fix invalid escape sequences (PR #94034)

2024-05-31 Thread via lldb-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[Lldb-commits] [lldb] [lldb] Support reading DW_OP_piece from file address (PR #94026)

2024-05-31 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/94026

>From 3aaf98ebce78fd376d33bd0aeb4d4c57762ea63a Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 31 May 2024 12:21:28 -0700
Subject: [PATCH] [lldb] Support reading DW_OP_piece from file address

We received a bug report where someone was trying to print a global
variable without a process. This would succeed in a debug build but fail
in a on optimized build. We traced the issue back to the location being
described by a DW_OP_addr + DW_OP_piece.

The issue is that the DWARF expression evaluator only support reading
pieces from a load address. There's no reason it cannot do the same for
a file address, and indeed, that solves the problem.

I unsuccessfully tried to craft a test case to illustrate the original
example, using a global struct and trying to trick the compiler into
breaking it apart with SROA. Instead I wrote a unit test that uses a
mock target to read memory from.

rdar://127435923
---
 lldb/include/lldb/Target/Target.h |  8 +--
 lldb/source/Expression/DWARFExpression.cpp| 58 +++---
 .../Expression/DWARFExpressionTest.cpp| 60 +++
 3 files changed, 100 insertions(+), 26 deletions(-)

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 7ad9f33586054..792a4caa76e2d 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1077,9 +1077,9 @@ class Target : public 
std::enable_shared_from_this,
   // section, then read from the file cache
   // 2 - if there is a process, then read from memory
   // 3 - if there is no process, then read from the file cache
-  size_t ReadMemory(const Address &addr, void *dst, size_t dst_len,
-Status &error, bool force_live_memory = false,
-lldb::addr_t *load_addr_ptr = nullptr);
+  virtual size_t ReadMemory(const Address &addr, void *dst, size_t dst_len,
+Status &error, bool force_live_memory = false,
+lldb::addr_t *load_addr_ptr = nullptr);
 
   size_t ReadCStringFromMemory(const Address &addr, std::string &out_str,
Status &error, bool force_live_memory = false);
@@ -1615,7 +1615,7 @@ class Target : public 
std::enable_shared_from_this,
 
   TargetStats &GetStatistics() { return m_stats; }
 
-private:
+protected:
   /// Construct with optional file and arch.
   ///
   /// This member is private. Clients must use
diff --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index c061fd1140fff..4e2942aa3ebf7 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -2123,23 +2123,22 @@ bool DWARFExpression::Evaluate(
 
   const Value::ValueType curr_piece_source_value_type =
   curr_piece_source_value.GetValueType();
+  Scalar &scalar = curr_piece_source_value.GetScalar();
+  const lldb::addr_t addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
   switch (curr_piece_source_value_type) {
   case Value::ValueType::Invalid:
 return false;
   case Value::ValueType::LoadAddress:
 if (process) {
   if (curr_piece.ResizeData(piece_byte_size) == piece_byte_size) {
-lldb::addr_t load_addr =
-curr_piece_source_value.GetScalar().ULongLong(
-LLDB_INVALID_ADDRESS);
-if (process->ReadMemory(
-load_addr, curr_piece.GetBuffer().GetBytes(),
-piece_byte_size, error) != piece_byte_size) {
+if (process->ReadMemory(addr, 
curr_piece.GetBuffer().GetBytes(),
+piece_byte_size,
+error) != piece_byte_size) {
   if (error_ptr)
 error_ptr->SetErrorStringWithFormat(
 "failed to read memory DW_OP_piece(%" PRIu64
-") from 0x%" PRIx64,
-piece_byte_size, load_addr);
+") from load address 0x%" PRIx64,
+piece_byte_size, addr);
   return false;
 }
   } else {
@@ -2153,26 +2152,41 @@ bool DWARFExpression::Evaluate(
 }
 break;
 
-  case Value::ValueType::FileAddress:
-  case Value::ValueType::HostAddress:
-if (error_ptr) {
-  lldb::addr_t addr = 
curr_piece_source_value.GetScalar().ULongLong(
-  LLDB_INVALID_ADDRESS);
+  case Value::ValueType::FileAddress: {
+if (target) {
+  if (curr_piece.ResizeData(piece_byte_size) == piece_byte_size) {
+if (target->ReadMemory(addr, curr_piece.GetBuffer().GetBytes(),
+   pi

[Lldb-commits] [lldb] fix(lldb/**.py): fix invalid escape sequences (PR #94034)

2024-05-31 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Eisuke Kawashima (e-kwsm)


Changes



---

Patch is 94.92 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/94034.diff


73 Files Affected:

- (modified) lldb/examples/python/crashlog.py (+4-4) 
- (modified) lldb/examples/python/delta.py (+1-1) 
- (modified) lldb/examples/python/gdbremote.py (+2-2) 
- (modified) lldb/examples/python/jump.py (+3-3) 
- (modified) lldb/examples/python/performance.py (+1-1) 
- (modified) lldb/examples/python/symbolication.py (+3-3) 
- (modified) lldb/packages/Python/lldbsuite/test/lldbpexpect.py (+1-1) 
- (modified) lldb/packages/Python/lldbsuite/test/test_runner/process_control.py 
(+1-1) 
- (modified) lldb/test/API/commands/command/backticks/TestBackticksInAlias.py 
(+2-2) 
- (modified) 
lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py 
(+1-1) 
- (modified) lldb/test/API/commands/expression/test/TestExprs.py (+1-1) 
- (modified) 
lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py 
(+1-1) 
- (modified) lldb/test/API/commands/help/TestHelp.py (+3-3) 
- (modified) 
lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py
 (+1-1) 
- (modified) 
lldb/test/API/commands/register/register/TestRegistersUnavailable.py (+2-2) 
- (modified) lldb/test/API/commands/settings/TestSettings.py (+6-6) 
- (modified) lldb/test/API/commands/target/basic/TestTargetCommand.py (+1-1) 
- (modified) 
lldb/test/API/commands/target/dump-separate-debug-info/dwo/TestDumpDwo.py 
(+8-8) 
- (modified) 
lldb/test/API/commands/target/dump-separate-debug-info/oso/TestDumpOso.py 
(+8-8) 
- (modified) lldb/test/API/commands/trace/TestTraceDumpInfo.py (+1-1) 
- (modified) lldb/test/API/commands/trace/TestTraceEvents.py (+2-2) 
- (modified) lldb/test/API/commands/trace/TestTraceStartStop.py (+6-6) 
- (modified) lldb/test/API/commands/trace/TestTraceTSC.py (+5-5) 
- (modified) lldb/test/API/driver/quit_speed/TestQuitWithProcess.py (+1-1) 
- (modified) 
lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
 (+1-1) 
- (modified) 
lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
 (+1-1) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
 (+3-3) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
 (+3-3) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py
 (+8-8) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
 (+1-1) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
 (+11-11) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
 (+1-1) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
 (+1-1) 
- (modified) 
lldb/test/API/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py
 (+2-2) 
- (modified) lldb/test/API/functionalities/memory-region/TestMemoryRegion.py 
(+1-1) 
- (modified) lldb/test/API/functionalities/target_var/TestTargetVar.py (+1-1) 
- (modified) lldb/test/API/iohandler/completion/TestIOHandlerCompletion.py 
(+1-1) 
- (modified) lldb/test/API/lang/c/function_types/TestFunctionTypes.py (+1-1) 
- (modified) lldb/test/API/lang/c/register_variables/TestRegisterVariables.py 
(+1-1) 
- (modified) lldb/test/API/lang/c/set_values/TestSetValues.py (+2-2) 
- (modified) lldb/test/API/lang/c/strings/TestCStrings.py (+1-1) 
- (modified) lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py (+4-4) 
- (modified) lldb/test/API/lang/cpp/char1632_t/TestChar1632T.py (+4-4) 
- (modified) lldb/test/API/lang/cpp/class_static/TestStaticVariables.py (+2-2) 
- (modified) lldb/test/API/lang/cpp/class_types/TestClassTypes.py (+1-1) 
- (modified) lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py (+1-1) 
- (modified) lldb/test/API/lang/cpp/namespace/TestNamespace.py (+2-2) 
- (modified) lldb/test/API/lang/cpp/signed_types/TestSignedTypes.py (+2-2) 
- (modified) lldb/test/API/lang/cpp/unsigned_types/TestUnsignedTypes.py (+1-1) 
- (modified) lldb/test/API/lang/mixed/TestMixedLanguages.py (+2-2) 
- (modified) lldb/test/API/lang/objc/foundation/TestObjCMethods.py (+1-1) 
- (modified) lldb/test/API/lang/objc/foundation/TestObjCMethodsNSArray.py 
(+5-5) 
- (modified) lldb/test/API/lang/objc/foundation/TestObjCMethodsNSError.py 
(+1-1) 
- (modified) lldb/test/API/lang/objc/foundation/TestObjCMethodsString.py (+5-5) 
- (modified) lldb/test/API/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py 
(+1-1) 
- (modified) 
lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py (+2-2) 
- (m

[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [libcxx] [lld] [lldb] [llvm] [mlir] [polly] fix(python): fix invalid escape sequences (PR #91856)

2024-05-31 Thread Eisuke Kawashima via lldb-commits

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


[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [libcxx] [lld] [lldb] [llvm] [mlir] [polly] fix(python): fix invalid escape sequences (PR #91856)

2024-05-31 Thread Eisuke Kawashima via lldb-commits

e-kwsm wrote:

broken into

- #94028
- #94029
- #94030
- #94031
- #94032
- #94033
- #94034
- #94035
- #94036
- #94037


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


[Lldb-commits] [lldb] [lldb] Support reading DW_OP_piece from file address (PR #94026)

2024-05-31 Thread Jonas Devlieghere via lldb-commits


@@ -1615,7 +1615,7 @@ class Target : public 
std::enable_shared_from_this,
 
   TargetStats &GetStatistics() { return m_stats; }
 
-private:
+protected:

JDevlieghere wrote:

If you're wondering, this is so the unit test can access the private 
constructor. 

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


[Lldb-commits] [lldb] [lldb] Support reading DW_OP_piece from file address (PR #94026)

2024-05-31 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/94026

>From 72844ebd5cf8f74f6db5d1c52d1f557ca942dbee Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 31 May 2024 12:21:28 -0700
Subject: [PATCH] [lldb] Support reading DW_OP_piece from file address

We received a bug report where someone was trying to print a global
variable without a process. This would succeed in a debug build but fail
in a on optimized build. We traced the issue back to the location being
described by a DW_OP_addr + DW_OP_piece.

The issue is that the DWARF expression evaluator only support reading
pieces from a load address. There's no reason it cannot do the same for
a file address, and indeed, that solves the problem.

I unsuccessfully tried to craft a test case to illustrate the original
example, using a global struct and trying to trick the compiler into
breaking it apart with SROA. Instead I wrote a unit test that uses a
mock target to read memory from.

rdar://127435923
---
 lldb/include/lldb/Target/Target.h |  8 +--
 lldb/source/Expression/DWARFExpression.cpp| 57 +++---
 .../Expression/DWARFExpressionTest.cpp| 60 +++
 3 files changed, 100 insertions(+), 25 deletions(-)

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 7ad9f33586054..792a4caa76e2d 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1077,9 +1077,9 @@ class Target : public 
std::enable_shared_from_this,
   // section, then read from the file cache
   // 2 - if there is a process, then read from memory
   // 3 - if there is no process, then read from the file cache
-  size_t ReadMemory(const Address &addr, void *dst, size_t dst_len,
-Status &error, bool force_live_memory = false,
-lldb::addr_t *load_addr_ptr = nullptr);
+  virtual size_t ReadMemory(const Address &addr, void *dst, size_t dst_len,
+Status &error, bool force_live_memory = false,
+lldb::addr_t *load_addr_ptr = nullptr);
 
   size_t ReadCStringFromMemory(const Address &addr, std::string &out_str,
Status &error, bool force_live_memory = false);
@@ -1615,7 +1615,7 @@ class Target : public 
std::enable_shared_from_this,
 
   TargetStats &GetStatistics() { return m_stats; }
 
-private:
+protected:
   /// Construct with optional file and arch.
   ///
   /// This member is private. Clients must use
diff --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index c061fd1140fff..326be0d683804 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -2123,23 +2123,22 @@ bool DWARFExpression::Evaluate(
 
   const Value::ValueType curr_piece_source_value_type =
   curr_piece_source_value.GetValueType();
+  Scalar &scalar = curr_piece_source_value.GetScalar();
+  const lldb::addr_t addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
   switch (curr_piece_source_value_type) {
   case Value::ValueType::Invalid:
 return false;
   case Value::ValueType::LoadAddress:
 if (process) {
   if (curr_piece.ResizeData(piece_byte_size) == piece_byte_size) {
-lldb::addr_t load_addr =
-curr_piece_source_value.GetScalar().ULongLong(
-LLDB_INVALID_ADDRESS);
-if (process->ReadMemory(
-load_addr, curr_piece.GetBuffer().GetBytes(),
-piece_byte_size, error) != piece_byte_size) {
+if (process->ReadMemory(addr, 
curr_piece.GetBuffer().GetBytes(),
+piece_byte_size,
+error) != piece_byte_size) {
   if (error_ptr)
 error_ptr->SetErrorStringWithFormat(
 "failed to read memory DW_OP_piece(%" PRIu64
-") from 0x%" PRIx64,
-piece_byte_size, load_addr);
+") from load address 0x%" PRIx64,
+piece_byte_size, addr);
   return false;
 }
   } else {
@@ -2153,26 +2152,42 @@ bool DWARFExpression::Evaluate(
 }
 break;
 
-  case Value::ValueType::FileAddress:
-  case Value::ValueType::HostAddress:
-if (error_ptr) {
-  lldb::addr_t addr = 
curr_piece_source_value.GetScalar().ULongLong(
-  LLDB_INVALID_ADDRESS);
+  case Value::ValueType::FileAddress: {
+if (target) {
+  if (curr_piece.ResizeData(piece_byte_size) == piece_byte_size) {
+if (target->ReadMemory(addr, curr_piece.GetBuffer().GetBytes(),
+   pi

[Lldb-commits] [lldb] [lldb] Support reading DW_OP_piece from file address (PR #94026)

2024-05-31 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Support reading DW_OP_piece from file address (PR #94026)

2024-05-31 Thread Adrian Prantl via lldb-commits


@@ -2153,26 +2152,41 @@ bool DWARFExpression::Evaluate(
 }
 break;
 
-  case Value::ValueType::FileAddress:
-  case Value::ValueType::HostAddress:
-if (error_ptr) {
-  lldb::addr_t addr = 
curr_piece_source_value.GetScalar().ULongLong(
-  LLDB_INVALID_ADDRESS);
+  case Value::ValueType::FileAddress: {
+if (target) {
+  if (curr_piece.ResizeData(piece_byte_size) == piece_byte_size) {
+if (target->ReadMemory(addr, curr_piece.GetBuffer().GetBytes(),
+   piece_byte_size, error,
+   /*force_live_memory=*/false) !=
+piece_byte_size) {
+  if (error_ptr)
+error_ptr->SetErrorStringWithFormat(
+"failed to read memory DW_OP_piece(%" PRIu64
+") from file address 0x%" PRIx64,
+piece_byte_size, addr);
+  return false;
+}
+  } else {
+if (error_ptr)

adrian-prantl wrote:

We need to convert this function to Expected, too, at some point.

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


[Lldb-commits] [lldb] [lldb] Support reading DW_OP_piece from file address (PR #94026)

2024-05-31 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl approved this pull request.


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


[Lldb-commits] [lldb] [lldb] Support reading DW_OP_piece from file address (PR #94026)

2024-05-31 Thread Jonas Devlieghere via lldb-commits


@@ -2153,26 +2152,41 @@ bool DWARFExpression::Evaluate(
 }
 break;
 
-  case Value::ValueType::FileAddress:
-  case Value::ValueType::HostAddress:
-if (error_ptr) {
-  lldb::addr_t addr = 
curr_piece_source_value.GetScalar().ULongLong(
-  LLDB_INVALID_ADDRESS);
+  case Value::ValueType::FileAddress: {
+if (target) {
+  if (curr_piece.ResizeData(piece_byte_size) == piece_byte_size) {
+if (target->ReadMemory(addr, curr_piece.GetBuffer().GetBytes(),
+   piece_byte_size, error,
+   /*force_live_memory=*/false) !=
+piece_byte_size) {
+  if (error_ptr)
+error_ptr->SetErrorStringWithFormat(
+"failed to read memory DW_OP_piece(%" PRIu64
+") from file address 0x%" PRIx64,
+piece_byte_size, addr);
+  return false;
+}
+  } else {
+if (error_ptr)

JDevlieghere wrote:

Yeah, absolutely. 

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


[Lldb-commits] [clang] [lldb] [llvm] [openmp] [polly] fix(python): fix comparison to True/False (PR #91858)

2024-05-31 Thread Eisuke Kawashima via lldb-commits

https://github.com/e-kwsm updated 
https://github.com/llvm/llvm-project/pull/91858

>From cdc6e7c4ee2238e82fb9bf1754962d0aff10422b Mon Sep 17 00:00:00 2001
From: Eisuke Kawashima 
Date: Sun, 12 May 2024 00:06:53 +0900
Subject: [PATCH 1/2] fix(python): fix comparison to True/False

from PEP8 (https://peps.python.org/pep-0008/#programming-recommendations):

> Comparisons to singletons like None should always be done with is or
> is not, never the equality operators.
---
 clang/tools/scan-build/bin/set-xcode-analyzer   | 2 +-
 clang/utils/check_cfc/check_cfc.py  | 4 ++--
 lldb/examples/python/crashlog.py| 2 +-
 lldb/examples/python/disasm-stress-test.py  | 4 ++--
 lldb/examples/summaries/cocoa/CFString.py   | 6 +++---
 lldb/examples/summaries/pysummary.py| 2 +-
 lldb/examples/synthetic/bitfield/example.py | 2 +-
 lldb/packages/Python/lldbsuite/test/lldbtest.py | 2 +-
 lldb/test/API/commands/command/script/welcome.py| 2 +-
 .../commands/expression/call-throws/TestCallThatThrows.py   | 6 +++---
 .../disassemble/aarch64-adrp-add/TestAArch64AdrpAdd.py  | 2 +-
 .../gdb_remote_client/TestNoWatchpointSupportInfo.py| 2 +-
 lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py | 2 +-
 lldb/test/API/tools/lldb-server/TestLldbGdbServer.py| 2 +-
 llvm/utils/indirect_calls.py| 2 +-
 openmp/libompd/gdb-plugin/ompd/ompd.py  | 2 +-
 openmp/tools/archer/tests/lit.cfg   | 2 +-
 .../External/isl/imath/tests/gmp-compat-test/genpytest.py   | 2 +-
 18 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/clang/tools/scan-build/bin/set-xcode-analyzer 
b/clang/tools/scan-build/bin/set-xcode-analyzer
index f8c3f775ef7de..8d797bee4ae3b 100755
--- a/clang/tools/scan-build/bin/set-xcode-analyzer
+++ b/clang/tools/scan-build/bin/set-xcode-analyzer
@@ -107,7 +107,7 @@ def main():
 foundSpec = True
 ModifySpec(x, isBuiltinAnalyzer, path)
 
-  if foundSpec == False:
+  if foundSpec is False:
   print "(-) No compiler configuration file was found.  Xcode's analyzer 
has not been updated."
 
 if __name__ == '__main__':
diff --git a/clang/utils/check_cfc/check_cfc.py 
b/clang/utils/check_cfc/check_cfc.py
index 27d732d91030c..d4ddcb5bbb6a3 100755
--- a/clang/utils/check_cfc/check_cfc.py
+++ b/clang/utils/check_cfc/check_cfc.py
@@ -156,7 +156,7 @@ def get_output_file(args):
 elif arg.startswith("-o"):
 # Specified conjoined with -o
 return arg[2:]
-assert grabnext == False
+assert grabnext is False
 
 return None
 
@@ -182,7 +182,7 @@ def replace_output_file(args, new_name):
 if replaceidx is None:
 raise Exception
 replacement = new_name
-if attached == True:
+if attached is True:
 replacement = "-o" + new_name
 args[replaceidx] = replacement
 return args
diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index 641b2e64d53b1..62bd73643a46e 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -166,7 +166,7 @@ def dump_symbolicated(self, crash_log, options):
 this_thread_crashed = self.app_specific_backtrace
 if not this_thread_crashed:
 this_thread_crashed = self.did_crash()
-if options.crashed_only and this_thread_crashed == False:
+if options.crashed_only and this_thread_crashed is False:
 return
 
 print("%s" % self)
diff --git a/lldb/examples/python/disasm-stress-test.py 
b/lldb/examples/python/disasm-stress-test.py
index 2d3314ee8e8ff..8487b24fdcba7 100755
--- a/lldb/examples/python/disasm-stress-test.py
+++ b/lldb/examples/python/disasm-stress-test.py
@@ -95,13 +95,13 @@ def GetLLDBFrameworkPath():
 
 debugger = lldb.SBDebugger.Create()
 
-if debugger.IsValid() == False:
+if debugger.IsValid() is False:
 print("Couldn't create an SBDebugger")
 sys.exit(-1)
 
 target = debugger.CreateTargetWithFileAndArch(None, arg_ns.arch)
 
-if target.IsValid() == False:
+if target.IsValid() is False:
 print("Couldn't create an SBTarget for architecture " + arg_ns.arch)
 sys.exit(-1)
 
diff --git a/lldb/examples/summaries/cocoa/CFString.py 
b/lldb/examples/summaries/cocoa/CFString.py
index 13c294ca34122..fdea2c48870cb 100644
--- a/lldb/examples/summaries/cocoa/CFString.py
+++ b/lldb/examples/summaries/cocoa/CFString.py
@@ -253,9 +253,9 @@ def get_child_at_index(self, index):
 elif (
 self.inline
 and self.explicit
-and self.unicode == False
-and self.special == False
-and self.mutable == False
+and self.unicode is False
+and self.special is False
+and self.mutable is False
  

[Lldb-commits] [lldb] [lldb] Support reading DW_OP_piece from file address (PR #94026)

2024-05-31 Thread Alex Langford via lldb-commits


@@ -768,3 +768,63 @@ TEST(DWARFExpression, ExtensionsDWO) {
 
   testExpressionVendorExtensions(dwo_module_sp, *dwo_dwarf_unit);
 }
+
+TEST_F(DWARFExpressionMockProcessTest, DW_OP_piece_file_addr) {
+  struct MockTarget : Target {
+MockTarget(Debugger &debugger, const ArchSpec &target_arch,
+   const lldb::PlatformSP &platform_sp)
+: Target(debugger, target_arch, platform_sp, true) {}
+
+size_t ReadMemory(const Address &addr, void *dst, size_t dst_len,
+  Status &error, bool force_live_memory = false,
+  lldb::addr_t *load_addr_ptr = nullptr) override {
+  // We expected to be called in a very specific way.
+  assert(dst_len == 1);
+  assert(addr.GetOffset() == 0x40 || addr.GetOffset() == 0x50);
+
+  if (addr.GetOffset() == 0x40)
+((uint8_t *)dst)[0] = 0x11;
+
+  if (addr.GetOffset() == 0x50)
+((uint8_t *)dst)[0] = 0x22;
+
+  return 1;
+}
+  };
+
+  // Set up a mock process.
+  ArchSpec arch("i386-pc-linux");
+  Platform::SetHostPlatform(
+  platform_linux::PlatformLinux::CreateInstance(true, &arch));
+  lldb::DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+  lldb::PlatformSP platform_sp;
+  lldb::TargetSP target_sp =
+  std::make_shared(*debugger_sp, arch, platform_sp);
+  ASSERT_TRUE(target_sp);
+  ASSERT_TRUE(target_sp->GetArchitecture().IsValid());
+
+  ExecutionContext exe_ctx(target_sp, false);
+
+  uint8_t expr[] = {DW_OP_addr, 0x40, 0x0, 0x0, 0x0, DW_OP_piece, 1,
+DW_OP_addr, 0x50, 0x0, 0x0, 0x0, DW_OP_piece, 1};
+  DataExtractor extractor(expr, sizeof(expr), lldb::eByteOrderLittle,
+  /*addr_size*/ 4);
+  Value result;
+  Status status;
+  ASSERT_TRUE(DWARFExpression::Evaluate(
+  &exe_ctx, /*reg_ctx*/ nullptr, /*module_sp*/ {}, extractor,
+  /*unit*/ nullptr, lldb::eRegisterKindLLDB,
+  /*initial_value_ptr*/ nullptr,
+  /*object_address_ptr*/ nullptr, result, &status))
+  << status.ToError();
+
+  ASSERT_EQ(result.GetValueType(), Value::ValueType::HostAddress);

bulbazord wrote:

Trying to understand this test a bit better: It looks like in 
DWARFExpression::Evaluate you primarily changed the 
`Value::ValueType::FileAddress` case, but this asserts that the result's value 
type should be a HostAddress. Is this correct? Or am I missing something?

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


[Lldb-commits] [lldb] fix(lldb/**.py): fix comparison to True/False (PR #94039)

2024-05-31 Thread Eisuke Kawashima via lldb-commits

https://github.com/e-kwsm created 
https://github.com/llvm/llvm-project/pull/94039

from PEP8 (https://peps.python.org/pep-0008/#programming-recommendations):

> Comparisons to singletons like None should always be done with is or is not, 
> never the equality operators.

>From 7b8df11972495daf31e5ab73ae90e2dc7bd51263 Mon Sep 17 00:00:00 2001
From: Eisuke Kawashima 
Date: Sun, 12 May 2024 00:06:53 +0900
Subject: [PATCH] fix(lldb/**.py): fix comparison to True/False

from PEP8 (https://peps.python.org/pep-0008/#programming-recommendations):

> Comparisons to singletons like None should always be done with is or
> is not, never the equality operators.
---
 lldb/examples/python/crashlog.py| 2 +-
 lldb/examples/python/disasm-stress-test.py  | 4 ++--
 lldb/examples/summaries/cocoa/CFString.py   | 6 +++---
 lldb/examples/summaries/pysummary.py| 2 +-
 lldb/examples/synthetic/bitfield/example.py | 2 +-
 lldb/packages/Python/lldbsuite/test/lldbtest.py | 2 +-
 lldb/test/API/commands/command/script/welcome.py| 2 +-
 .../commands/expression/call-throws/TestCallThatThrows.py   | 6 +++---
 .../disassemble/aarch64-adrp-add/TestAArch64AdrpAdd.py  | 2 +-
 .../gdb_remote_client/TestNoWatchpointSupportInfo.py| 2 +-
 lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py | 2 +-
 lldb/test/API/tools/lldb-server/TestLldbGdbServer.py| 2 +-
 12 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index 641b2e64d53b1..ead9955cd13b7 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -166,7 +166,7 @@ def dump_symbolicated(self, crash_log, options):
 this_thread_crashed = self.app_specific_backtrace
 if not this_thread_crashed:
 this_thread_crashed = self.did_crash()
-if options.crashed_only and this_thread_crashed == False:
+if options.crashed_only and not this_thread_crashed:
 return
 
 print("%s" % self)
diff --git a/lldb/examples/python/disasm-stress-test.py 
b/lldb/examples/python/disasm-stress-test.py
index 2d3314ee8e8ff..62b2b90a2860a 100755
--- a/lldb/examples/python/disasm-stress-test.py
+++ b/lldb/examples/python/disasm-stress-test.py
@@ -95,13 +95,13 @@ def GetLLDBFrameworkPath():
 
 debugger = lldb.SBDebugger.Create()
 
-if debugger.IsValid() == False:
+if not debugger.IsValid():
 print("Couldn't create an SBDebugger")
 sys.exit(-1)
 
 target = debugger.CreateTargetWithFileAndArch(None, arg_ns.arch)
 
-if target.IsValid() == False:
+if not target.IsValid():
 print("Couldn't create an SBTarget for architecture " + arg_ns.arch)
 sys.exit(-1)
 
diff --git a/lldb/examples/summaries/cocoa/CFString.py 
b/lldb/examples/summaries/cocoa/CFString.py
index 13c294ca34122..74bd927e9db21 100644
--- a/lldb/examples/summaries/cocoa/CFString.py
+++ b/lldb/examples/summaries/cocoa/CFString.py
@@ -253,9 +253,9 @@ def get_child_at_index(self, index):
 elif (
 self.inline
 and self.explicit
-and self.unicode == False
-and self.special == False
-and self.mutable == False
+and not self.unicode
+and not self.special
+and not self.mutable
 ):
 return self.handle_inline_explicit()
 elif self.unicode:
diff --git a/lldb/examples/summaries/pysummary.py 
b/lldb/examples/summaries/pysummary.py
index e63a0bff56a13..2a05c1cbf8f28 100644
--- a/lldb/examples/summaries/pysummary.py
+++ b/lldb/examples/summaries/pysummary.py
@@ -2,7 +2,7 @@
 
 
 def pyobj_summary(value, unused):
-if value is None or value.IsValid() == False or 
value.GetValueAsUnsigned(0) == 0:
+if value is None or not value.IsValid() or value.GetValueAsUnsigned(0) == 
0:
 return ""
 refcnt = value.GetChildMemberWithName("ob_refcnt")
 expr = "(char*)PyString_AsString( (PyObject*)PyObject_Str( 
(PyObject*)0x%x) )" % (
diff --git a/lldb/examples/synthetic/bitfield/example.py 
b/lldb/examples/synthetic/bitfield/example.py
index 2f58123268aa1..45416477bfef2 100644
--- a/lldb/examples/synthetic/bitfield/example.py
+++ b/lldb/examples/synthetic/bitfield/example.py
@@ -51,7 +51,7 @@ def get_child_at_index(self, index):
 return None
 if index > self.num_children():
 return None
-if self.valobj.IsValid() == False:
+if not self.valobj.IsValid():
 return None
 if index == 0:
 return self.valobj.GetChildMemberWithName("value")
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 1ad8ab6e6e462..1854f6c2c2e7b 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packa

[Lldb-commits] [lldb] fix(lldb/**.py): fix comparison to True/False (PR #94039)

2024-05-31 Thread via lldb-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[Lldb-commits] [lldb] fix(lldb/**.py): fix comparison to True/False (PR #94039)

2024-05-31 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Eisuke Kawashima (e-kwsm)


Changes

from PEP8 (https://peps.python.org/pep-0008/#programming-recommendations):

> Comparisons to singletons like None should always be done with is or is 
not, never the equality operators.

---
Full diff: https://github.com/llvm/llvm-project/pull/94039.diff


12 Files Affected:

- (modified) lldb/examples/python/crashlog.py (+1-1) 
- (modified) lldb/examples/python/disasm-stress-test.py (+2-2) 
- (modified) lldb/examples/summaries/cocoa/CFString.py (+3-3) 
- (modified) lldb/examples/summaries/pysummary.py (+1-1) 
- (modified) lldb/examples/synthetic/bitfield/example.py (+1-1) 
- (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+1-1) 
- (modified) lldb/test/API/commands/command/script/welcome.py (+1-1) 
- (modified) 
lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py (+3-3) 
- (modified) 
lldb/test/API/functionalities/disassemble/aarch64-adrp-add/TestAArch64AdrpAdd.py
 (+1-1) 
- (modified) 
lldb/test/API/functionalities/gdb_remote_client/TestNoWatchpointSupportInfo.py 
(+1-1) 
- (modified) lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py (+1-1) 
- (modified) lldb/test/API/tools/lldb-server/TestLldbGdbServer.py (+1-1) 


``diff
diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index 641b2e64d53b1..ead9955cd13b7 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -166,7 +166,7 @@ def dump_symbolicated(self, crash_log, options):
 this_thread_crashed = self.app_specific_backtrace
 if not this_thread_crashed:
 this_thread_crashed = self.did_crash()
-if options.crashed_only and this_thread_crashed == False:
+if options.crashed_only and not this_thread_crashed:
 return
 
 print("%s" % self)
diff --git a/lldb/examples/python/disasm-stress-test.py 
b/lldb/examples/python/disasm-stress-test.py
index 2d3314ee8e8ff..62b2b90a2860a 100755
--- a/lldb/examples/python/disasm-stress-test.py
+++ b/lldb/examples/python/disasm-stress-test.py
@@ -95,13 +95,13 @@ def GetLLDBFrameworkPath():
 
 debugger = lldb.SBDebugger.Create()
 
-if debugger.IsValid() == False:
+if not debugger.IsValid():
 print("Couldn't create an SBDebugger")
 sys.exit(-1)
 
 target = debugger.CreateTargetWithFileAndArch(None, arg_ns.arch)
 
-if target.IsValid() == False:
+if not target.IsValid():
 print("Couldn't create an SBTarget for architecture " + arg_ns.arch)
 sys.exit(-1)
 
diff --git a/lldb/examples/summaries/cocoa/CFString.py 
b/lldb/examples/summaries/cocoa/CFString.py
index 13c294ca34122..74bd927e9db21 100644
--- a/lldb/examples/summaries/cocoa/CFString.py
+++ b/lldb/examples/summaries/cocoa/CFString.py
@@ -253,9 +253,9 @@ def get_child_at_index(self, index):
 elif (
 self.inline
 and self.explicit
-and self.unicode == False
-and self.special == False
-and self.mutable == False
+and not self.unicode
+and not self.special
+and not self.mutable
 ):
 return self.handle_inline_explicit()
 elif self.unicode:
diff --git a/lldb/examples/summaries/pysummary.py 
b/lldb/examples/summaries/pysummary.py
index e63a0bff56a13..2a05c1cbf8f28 100644
--- a/lldb/examples/summaries/pysummary.py
+++ b/lldb/examples/summaries/pysummary.py
@@ -2,7 +2,7 @@
 
 
 def pyobj_summary(value, unused):
-if value is None or value.IsValid() == False or 
value.GetValueAsUnsigned(0) == 0:
+if value is None or not value.IsValid() or value.GetValueAsUnsigned(0) == 
0:
 return ""
 refcnt = value.GetChildMemberWithName("ob_refcnt")
 expr = "(char*)PyString_AsString( (PyObject*)PyObject_Str( 
(PyObject*)0x%x) )" % (
diff --git a/lldb/examples/synthetic/bitfield/example.py 
b/lldb/examples/synthetic/bitfield/example.py
index 2f58123268aa1..45416477bfef2 100644
--- a/lldb/examples/synthetic/bitfield/example.py
+++ b/lldb/examples/synthetic/bitfield/example.py
@@ -51,7 +51,7 @@ def get_child_at_index(self, index):
 return None
 if index > self.num_children():
 return None
-if self.valobj.IsValid() == False:
+if not self.valobj.IsValid():
 return None
 if index == 0:
 return self.valobj.GetChildMemberWithName("value")
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 1ad8ab6e6e462..1854f6c2c2e7b 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2446,7 +2446,7 @@ def found_str(matched):
 log_lines.append(pattern_line)
 
 # Convert to bool because match objects
-# are True-ish but != True itself
+# ar

[Lldb-commits] [clang] [lldb] [llvm] [openmp] [polly] fix(python): fix comparison to True/False (PR #91858)

2024-05-31 Thread Eisuke Kawashima via lldb-commits

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


[Lldb-commits] [clang] [lldb] [llvm] [openmp] [polly] fix(python): fix comparison to True/False (PR #91858)

2024-05-31 Thread Eisuke Kawashima via lldb-commits

e-kwsm wrote:

Broken into

- #94038
- #94039
- #94040
- #94041
- #94042



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


[Lldb-commits] [lldb] [lldb] Support reading DW_OP_piece from file address (PR #94026)

2024-05-31 Thread Jonas Devlieghere via lldb-commits


@@ -768,3 +768,63 @@ TEST(DWARFExpression, ExtensionsDWO) {
 
   testExpressionVendorExtensions(dwo_module_sp, *dwo_dwarf_unit);
 }
+
+TEST_F(DWARFExpressionMockProcessTest, DW_OP_piece_file_addr) {
+  struct MockTarget : Target {
+MockTarget(Debugger &debugger, const ArchSpec &target_arch,
+   const lldb::PlatformSP &platform_sp)
+: Target(debugger, target_arch, platform_sp, true) {}
+
+size_t ReadMemory(const Address &addr, void *dst, size_t dst_len,
+  Status &error, bool force_live_memory = false,
+  lldb::addr_t *load_addr_ptr = nullptr) override {
+  // We expected to be called in a very specific way.
+  assert(dst_len == 1);
+  assert(addr.GetOffset() == 0x40 || addr.GetOffset() == 0x50);
+
+  if (addr.GetOffset() == 0x40)
+((uint8_t *)dst)[0] = 0x11;
+
+  if (addr.GetOffset() == 0x50)
+((uint8_t *)dst)[0] = 0x22;
+
+  return 1;
+}
+  };
+
+  // Set up a mock process.
+  ArchSpec arch("i386-pc-linux");
+  Platform::SetHostPlatform(
+  platform_linux::PlatformLinux::CreateInstance(true, &arch));
+  lldb::DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+  lldb::PlatformSP platform_sp;
+  lldb::TargetSP target_sp =
+  std::make_shared(*debugger_sp, arch, platform_sp);
+  ASSERT_TRUE(target_sp);
+  ASSERT_TRUE(target_sp->GetArchitecture().IsValid());
+
+  ExecutionContext exe_ctx(target_sp, false);
+
+  uint8_t expr[] = {DW_OP_addr, 0x40, 0x0, 0x0, 0x0, DW_OP_piece, 1,
+DW_OP_addr, 0x50, 0x0, 0x0, 0x0, DW_OP_piece, 1};
+  DataExtractor extractor(expr, sizeof(expr), lldb::eByteOrderLittle,
+  /*addr_size*/ 4);
+  Value result;
+  Status status;
+  ASSERT_TRUE(DWARFExpression::Evaluate(
+  &exe_ctx, /*reg_ctx*/ nullptr, /*module_sp*/ {}, extractor,
+  /*unit*/ nullptr, lldb::eRegisterKindLLDB,
+  /*initial_value_ptr*/ nullptr,
+  /*object_address_ptr*/ nullptr, result, &status))
+  << status.ToError();
+
+  ASSERT_EQ(result.GetValueType(), Value::ValueType::HostAddress);

JDevlieghere wrote:

I can see how this is confusing. This is the **result** of the expression, 
which we read in pieces, and because it's non-contiguous, necessarily need to 
store in host memory. It's unrelated to the Value representing the `DW_OP_addr` 
on the stack in the DWARF expression. 

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


[Lldb-commits] [lldb] [lldb] Support reading DW_OP_piece from file address (PR #94026)

2024-05-31 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] Add doc strings for SBValue::IsValid and SBValue::GetError. (PR #94007)

2024-05-31 Thread Alex Langford via lldb-commits


@@ -45,6 +45,36 @@ SBValue instance which interprets the value object as 
representing the head of a
 linked list."
 ) lldb::SBValue;
 
+%feature("docstring", "
+Returns true if the SBValue holds any useful state
+and false otherwise.
+IsValid is a very weak API, lldb will only return

bulbazord wrote:

Suggestion: "weak" -> "limited"
In my opinion, weak sounds like a value judgement as opposed to limited which 
sounds more neutral.

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


[Lldb-commits] [lldb] Add doc strings for SBValue::IsValid and SBValue::GetError. (PR #94007)

2024-05-31 Thread Alex Langford via lldb-commits


@@ -45,6 +45,36 @@ SBValue instance which interprets the value object as 
representing the head of a
 linked list."
 ) lldb::SBValue;
 
+%feature("docstring", "
+Returns true if the SBValue holds any useful state
+and false otherwise.
+IsValid is a very weak API, lldb will only return
+invalid SBValues if it has no useful information
+about the SBValue.
+The two main ways you will end up with an invalid
+SBValue are:
+1) default constructed SBValues are not valid.
+2) SBValues that have outlived their SBTarget are
+no longer valid since its not safe to ask them
+questions.
+"
+) lldb::SBValue::IsValid
+
+%feature("docstring", "
+SBValues use the lldb::SBError object returned by

bulbazord wrote:

I'm not sure "use" is the right verb here. My read is that it implies the 
SBValue does something with the SBError, but this function is the thing that 
"reports" the error right?
Suggestion:
"Returns an SBError object that contains information about the most recent 
error related to this SBValue." (followed by some examples like you have below)

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


[Lldb-commits] [lldb] Add doc strings for SBValue::IsValid and SBValue::GetError. (PR #94007)

2024-05-31 Thread Alex Langford via lldb-commits


@@ -45,6 +45,36 @@ SBValue instance which interprets the value object as 
representing the head of a
 linked list."
 ) lldb::SBValue;
 
+%feature("docstring", "
+Returns true if the SBValue holds any useful state
+and false otherwise.
+IsValid is a very weak API, lldb will only return
+invalid SBValues if it has no useful information
+about the SBValue.
+The two main ways you will end up with an invalid
+SBValue are:
+1) default constructed SBValues are not valid.
+2) SBValues that have outlived their SBTarget are
+no longer valid since its not safe to ask them

bulbazord wrote:

What does it mean for it to be "not safe" to ask it questions? Does LLDB crash? 
Or does it modify state in an unpredictable manner? I think this should either 
be more specific about the consequences (e.g. "... no longer valid. Request 
data from the SBValue {is undefined, will crash LLDB, will return invalid 
data}.")

If you want to be vague about the behavior of this scenario (so that we aren't 
on the hook for guaranteeing the behavior stay the same) we should say that it 
is "undefined".

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


[Lldb-commits] [lldb] Add doc strings for SBValue::IsValid and SBValue::GetError. (PR #94007)

2024-05-31 Thread Alex Langford via lldb-commits


@@ -45,6 +45,36 @@ SBValue instance which interprets the value object as 
representing the head of a
 linked list."
 ) lldb::SBValue;
 
+%feature("docstring", "
+Returns true if the SBValue holds any useful state
+and false otherwise.
+IsValid is a very weak API, lldb will only return
+invalid SBValues if it has no useful information
+about the SBValue.
+The two main ways you will end up with an invalid
+SBValue are:
+1) default constructed SBValues are not valid.
+2) SBValues that have outlived their SBTarget are
+no longer valid since its not safe to ask them
+questions.
+"
+) lldb::SBValue::IsValid
+
+%feature("docstring", "
+SBValues use the lldb::SBError object returned by
+this API to report construction errors when the SBValue
+is made; and on each stop, the SBError will tell you
+whether lldb could successfully determine the value for
+this program entity represented by this SBValue.

bulbazord wrote:

`this program entity` -> `the program entity`
You have "this" twice in a row, it reads a bit repetitive IMO.

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


[Lldb-commits] [lldb] [llvm] Add a createError variant without error code (NFC) (PR #93209)

2024-05-31 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

Thanks for providing the context, Lang!
Inside of LLDB we use llvm::Expected often in completely closed environments 
where the expectation is always that all errors are handled internally and we 
never would exit the process with an error code, so this would be useful here.

https://github.com/llvm/llvm-project/pull/93209
___
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] Improve identification of Dlang mangled names (PR #93881)

2024-05-31 Thread via lldb-commits

gulfemsavrun wrote:

We started seeing test failures in `LLDBCoreTests`:
```
Script:
--
/b/s/w/ir/x/w/llvm_build/tools/lldb/unittests/Core/./LLDBCoreTests 
--gtest_filter=MangledTest.EmptyForInvalidDLangName
--
lldb/unittests/Core/MangledTest.cpp:89: Failure
Expected equality of these values:
  ""
  the_demangled.GetCString()
Which is: "_DDD"


lldb/unittests/Core/MangledTest.cpp:89
Expected equality of these values:
  ""
  the_demangled.GetCString()
Which is: "_DDD"
```
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8746397023380830177/overview

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 via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/94046.diff


2 Files Affected:

- (modified) lldb/source/Core/Mangled.cpp (+3-2) 
- (modified) lldb/unittests/Core/MangledTest.cpp (+2-2) 


``diff
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) {

``




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] 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] Fix Dlang symbol test breakage (PR #94046)

2024-05-31 Thread Jonas Devlieghere via lldb-commits

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


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] 68fdc1c - [lldb] Fix Dlang symbol test breakage (#94046)

2024-05-31 Thread via lldb-commits

Author: Dave Lee
Date: 2024-05-31T14:04:40-07:00
New Revision: 68fdc1cf87eb04686e079af27eaeec0f1c41f8cc

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

LOG: [lldb] Fix Dlang symbol test breakage (#94046)

Follow up to #93881. Updates missed tests and handles `_Dmain`.

Added: 


Modified: 
lldb/source/Core/Mangled.cpp
lldb/unittests/Core/MangledTest.cpp

Removed: 




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 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] ad884d9 - A few updates around "transcript" (#92843)

2024-05-31 Thread via lldb-commits

Author: royitaqi
Date: 2024-05-31T14:42:00-07:00
New Revision: ad884d97288c752ba9088d01cf7ab80b20e4d2a6

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

LOG: A few updates around "transcript" (#92843)

# Changes

1. Changes to the structured transcript.
1. Add fields `commandName` and `commandArguments`. They will hold the
name and the arguments string of the expanded/executed command (e.g.
`breakpoint set` and `-f main.cpp -l 4`). This is not to be confused
with the `command` field, which holds the user input (e.g. `br s -f
main.cpp -l 4`).
2. Add field `timestampInEpochSeconds`. It will hold the timestamp when
the command is executed.
3. Rename field `seconds` to `durationInSeconds`, to improve
readability, especially since `timestampInEpochSeconds` is added.
2. When transcript is available and the newly added option
`--transcript` is present, add the transcript to the output of
`statistics dump`, as a JSON array under a new field `transcript`.
3. A few test name and comment changes.

Added: 


Modified: 
lldb/include/lldb/API/SBCommandInterpreter.h
lldb/include/lldb/Interpreter/CommandInterpreter.h
lldb/include/lldb/Target/Statistics.h
lldb/source/Commands/CommandObjectStats.cpp
lldb/source/Commands/Options.td
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Target/Statistics.cpp
lldb/test/API/commands/statistics/basic/TestStats.py
lldb/test/API/python_api/interpreter/TestCommandInterpreterAPI.py

Removed: 




diff  --git a/lldb/include/lldb/API/SBCommandInterpreter.h 
b/lldb/include/lldb/API/SBCommandInterpreter.h
index 8ac36344b3a79..639309aa32bfc 100644
--- a/lldb/include/lldb/API/SBCommandInterpreter.h
+++ b/lldb/include/lldb/API/SBCommandInterpreter.h
@@ -320,10 +320,17 @@ class SBCommandInterpreter {
 
   /// Returns a list of handled commands, output and error. Each element in
   /// the list is a dictionary with the following keys/values:
-  /// - "command" (string): The command that was executed.
+  /// - "command" (string): The command that was given by the user.
+  /// - "commandName" (string): The name of the executed command.
+  /// - "commandArguments" (string): The arguments of the executed command.
   /// - "output" (string): The output of the command. Empty ("") if no output.
   /// - "error" (string): The error of the command. Empty ("") if no error.
-  /// - "seconds" (float): The time it took to execute the command.
+  /// - "durationInSeconds" (float): The time it took to execute the command.
+  /// - "timestampInEpochSeconds" (int): The timestamp when the command is
+  ///   executed.
+  ///
+  /// Turn on settings `interpreter.save-transcript` for LLDB to populate
+  /// this list. Otherwise this list is empty.
   SBStructuredData GetTranscript();
 
 protected:

diff  --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index ccc30cf4f1a82..8863523b2e31f 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -776,10 +776,14 @@ class CommandInterpreter : public Broadcaster,
 
   /// Contains a list of handled commands and their details. Each element in
   /// the list is a dictionary with the following keys/values:
-  /// - "command" (string): The command that was executed.
+  /// - "command" (string): The command that was given by the user.
+  /// - "commandName" (string): The name of the executed command.
+  /// - "commandArguments" (string): The arguments of the executed command.
   /// - "output" (string): The output of the command. Empty ("") if no output.
   /// - "error" (string): The error of the command. Empty ("") if no error.
-  /// - "seconds" (float): The time it took to execute the command.
+  /// - "durationInSeconds" (float): The time it took to execute the command.
+  /// - "timestampInEpochSeconds" (int): The timestamp when the command is
+  ///   executed.
   ///
   /// Turn on settings `interpreter.save-transcript` for LLDB to populate
   /// this list. Otherwise this list is empty.

diff  --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index c4f17b503a1f9..c04d529290fff 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,6 +133,7 @@ struct ConstStringStats {
 struct StatisticsOptions {
   bool summary_only = false;
   bool load_all_debug_info = false;
+  bool include_transcript = false;
 };
 
 /// A class that represents statistics for a since lldb_private::Target.

diff  --git a/lldb/source/Commands/CommandObjectStats.cpp 
b/lldb/source/Commands/CommandObjectStats.cpp
index a92bb5d1165ee..1935b0fdfadfb 100644
--- a/lldb/source/Commands/CommandObjectStats.cpp
+++ b/lldb/sour

[Lldb-commits] [lldb] A few updates around "transcript" (PR #92843)

2024-05-31 Thread Greg Clayton via lldb-commits

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


  1   2   >