[Lldb-commits] [lldb] [llvm][tblgen] Add `SourcePath` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread Shao-Ce SUN via lldb-commits

sunshaoce wrote:

> ⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️
> 
> You can test this locally with the following command:
> ```shell
> git-clang-format --diff b8b4ee6b450766796b162b4811a6b3f723d07268 
> d07486764071679c8cbcd5e7c4905eb41b4770b3 -- 
> clang/utils/TableGen/ClangASTNodesEmitter.cpp 
> clang/utils/TableGen/ClangASTPropertiesEmitter.cpp 
> clang/utils/TableGen/ClangAttrEmitter.cpp 
> clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp 
> clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp 
> clang/utils/TableGen/ClangCommentHTMLTagsEmitter.cpp 
> clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp 
> clang/utils/TableGen/ClangSyntaxEmitter.cpp 
> clang/utils/TableGen/ClangTypeNodesEmitter.cpp 
> lldb/utils/TableGen/LLDBOptionDefEmitter.cpp 
> lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp 
> llvm/include/llvm/TableGen/TableGenBackend.h 
> llvm/lib/TableGen/TableGenBackend.cpp 
> llvm/utils/TableGen/AsmMatcherEmitter.cpp 
> llvm/utils/TableGen/AsmWriterEmitter.cpp llvm/utils/TableGen/VTEmitter.cpp 
> mlir/tools/mlir-tblgen/DialectGen.cpp mlir/tools/mlir-tblgen/EnumsGen.cpp 
> mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp 
> mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp 
> mlir/tools/mlir-tblgen/RewriterGen.cpp 
> mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
> ```
> 
> View the diff from clang-format here.
> ```diff
> diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
> b/clang/utils/TableGen/ClangAttrEmitter.cpp
> index 6ba82a22df1e..dddc9b9896ef 100644
> --- a/clang/utils/TableGen/ClangAttrEmitter.cpp
> +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
> @@ -3170,27 +3170,27 @@ namespace clang {
>  
>  // Emits the enumeration list for attributes.
>  void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS) {
> -  emitSourceFileHeader("List of all attributes that Clang recognizes", OS,
> -   Records);
> +emitSourceFileHeader("List of all attributes that Clang recognizes", OS,
> + Records);
>  
> -  AttrClassHierarchy Hierarchy(Records);
> +AttrClassHierarchy Hierarchy(Records);
>  
> -  // Add defaulting macro definitions.
> -  Hierarchy.emitDefaultDefines(OS);
> -  emitDefaultDefine(OS, "PRAGMA_SPELLING_ATTR", nullptr);
> +// Add defaulting macro definitions.
> +Hierarchy.emitDefaultDefines(OS);
> +emitDefaultDefine(OS, "PRAGMA_SPELLING_ATTR", nullptr);
>  
> -  std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
> -  std::vector PragmaAttrs;
> -  for (auto *Attr : Attrs) {
> -if (!Attr->getValueAsBit("ASTNode"))
> -  continue;
> +std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
> +std::vector PragmaAttrs;
> +for (auto *Attr : Attrs) {
> +  if (!Attr->getValueAsBit("ASTNode"))
> +continue;
>  
> -// Add the attribute to the ad-hoc groups.
> -if (AttrHasPragmaSpelling(Attr))
> -  PragmaAttrs.push_back(Attr);
> +  // Add the attribute to the ad-hoc groups.
> +  if (AttrHasPragmaSpelling(Attr))
> +PragmaAttrs.push_back(Attr);
>  
> -// Place it in the hierarchy.
> -Hierarchy.classifyAttr(Attr);
> +  // Place it in the hierarchy.
> +  Hierarchy.classifyAttr(Attr);
>}
>  
>// Emit the main attribute list.
> ```

Is this suggestion correct?

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


[Lldb-commits] [lldb] [llvm][tblgen] Add `SourcePath` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread Renato Golin via lldb-commits

rengolin wrote:

> Is this suggestion correct?

Doesn't look right to me. I seems it's suggesting 4 spaces tabs, which isn't 
what we normally use. Something wrong with the clang-format job, maybe?

@tru @tstellar 

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


[Lldb-commits] [lldb] [llvm][tblgen] Add `SourcePath` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread Tobias Hieta via lldb-commits

tru wrote:

No I don't think it's job's fault. I ran clang-format on this file and it's not 
formatted at all, so I think when we ask it to just format a patch like we do 
in the job, it gets a bit confused and give you a bit of non-sense formatting. 
This is just a limitation of not running formatting on the whole file. 

Two solutions:
1) just ignore it, it looks fine in general.
2) Push a NFC commit that fixes the formatting of this file and then 
rebase/merge to get that commit in your branch and it should look fine.


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


[Lldb-commits] [lldb] [llvm][tblgen] Add `SourcePath` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread Tobias Hieta via lldb-commits

tru wrote:

Looking at it - it seems like none of Tablegen is correctly clang-formatted. If 
that's not desired, maybe it should have a local .clang-format file to disable 
the formatting of these files.

Do we have a clang-tblgen maintainer? Couldn't find anything in the codeowners 
and git log history seems to be very split.

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


[Lldb-commits] [lldb] [lldb] Add SetValueFromCString API to SyntheticFronend (PR #67309)

2023-09-25 Thread Pavel Kosov via lldb-commits

https://github.com/kpdev created https://github.com/llvm/llvm-project/pull/67309

It is a first of three patches neded for adding an ability to update 
std::string/wstring/etc during debug process. This patch adds to the synthetic 
child interface a “change value” method which goes back to the synthetic child 
provider and ask it if it knows how to change the underlying value that the 
synthetic child represents

Overall context is avaliable in the following question: 
https://discourse.llvm.org/t/clarify-hostaddress-loadaddress-logic/72175/3:

~~

Huawei RRI, OS Lab

>From 07f943e3c243a41f1e7395379ca09a1ee79f2a93 Mon Sep 17 00:00:00 2001
From: Pavel Kosov 
Date: Mon, 25 Sep 2023 13:41:03 +0300
Subject: [PATCH] [lldb] Add SetValueFromCString API to SyntheticFronend
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It is a first of three patches neded for adding an ability to update 
std::string/wstring/etc during debug process.
This patch adds to the synthetic child interface a “change value” method which 
goes back to the synthetic child provider and
ask it if it knows how to change the underlying value that the synthetic child 
represents

Overall context is avaliable in the following question: 
https://discourse.llvm.org/t/clarify-hostaddress-loadaddress-logic/72175/3:

~~

Huawei RRI, OS Lab
---
 lldb/include/lldb/Core/ValueObject.h | 11 +++
 lldb/include/lldb/DataFormatters/TypeSynthetic.h |  8 +++-
 lldb/source/Core/ValueObject.cpp |  7 ++-
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/lldb/include/lldb/Core/ValueObject.h 
b/lldb/include/lldb/Core/ValueObject.h
index 3af94f0a86e2fcc..892f5d0dea4f650 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -589,6 +589,14 @@ class ValueObject {
 
   virtual bool IsSynthetic() { return false; }
 
+  void SetSyntheticFrontend(SyntheticChildrenFrontEnd *synth_front) {
+m_synthetic_frontend = synth_front;
+  }
+
+  SyntheticChildrenFrontEnd *GetSyntheticFrontend() const {
+return m_synthetic_frontend;
+  }
+
   lldb::ValueObjectSP
   GetQualifiedRepresentationIfAvailable(lldb::DynamicValueType dynValue,
 bool synthValue);
@@ -898,6 +906,9 @@ class ValueObject {
   /// Unique identifier for every value object.
   UserID m_id;
 
+  // If frontend exist - we may try to update our value through it
+  SyntheticChildrenFrontEnd *m_synthetic_frontend = nullptr;
+
   // Utility class for initializing all bitfields in ValueObject's 
constructors.
   // FIXME: This could be done via default initializers once we have C++20.
   struct Bitflags {
diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h 
b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
index 41be9b7efda8fdb..3a19804b22c196c 100644
--- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h
+++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
@@ -34,7 +34,9 @@ class SyntheticChildrenFrontEnd {
 
 public:
   SyntheticChildrenFrontEnd(ValueObject &backend)
-  : m_backend(backend), m_valid(true) {}
+  : m_backend(backend), m_valid(true) {
+backend.SetSyntheticFrontend(this);
+  }
 
   virtual ~SyntheticChildrenFrontEnd() = default;
 
@@ -75,6 +77,10 @@ class SyntheticChildrenFrontEnd {
   // display purposes
   virtual ConstString GetSyntheticTypeName() { return ConstString(); }
 
+  virtual bool SetValueFromCString(const char *value_str, Status &error) {
+return false;
+  }
+
   typedef std::shared_ptr SharedPointer;
   typedef std::unique_ptr AutoPointer;
 
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index ebfc1cf4d6fe9e1..cea3ea523020443 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -1535,7 +1535,12 @@ bool ValueObject::SetValueFromCString(const char 
*value_str, Status &error) {
 }
   } else {
 // We don't support setting things bigger than a scalar at present.
-error.SetErrorString("unable to write aggregate data type");
+// But maybe our frontend knows how to update the value.
+if (auto *frontend = GetSyntheticFrontend()) {
+  return frontend->SetValueFromCString(value_str, error);
+} else {
+  error.SetErrorString("unable to write aggregate data type");
+}
 return false;
   }
 

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


[Lldb-commits] [lldb] [lldb] Add SetValueFromCString API to SyntheticFronend (PR #67309)

2023-09-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb


Changes

It is a first of three patches neded for adding an ability to update 
std::string/wstring/etc during debug process. This patch adds to the synthetic 
child interface a “change value” method which goes back to the synthetic child 
provider and ask it if it knows how to change the underlying value that the 
synthetic child represents

Overall context is avaliable in the following question: 
https://discourse.llvm.org/t/clarify-hostaddress-loadaddress-logic/72175/3:

~~

Huawei RRI, OS Lab

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


3 Files Affected:

- (modified) lldb/include/lldb/Core/ValueObject.h (+11) 
- (modified) lldb/include/lldb/DataFormatters/TypeSynthetic.h (+7-1) 
- (modified) lldb/source/Core/ValueObject.cpp (+6-1) 


``diff
diff --git a/lldb/include/lldb/Core/ValueObject.h 
b/lldb/include/lldb/Core/ValueObject.h
index 3af94f0a86e2fcc..892f5d0dea4f650 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -589,6 +589,14 @@ class ValueObject {
 
   virtual bool IsSynthetic() { return false; }
 
+  void SetSyntheticFrontend(SyntheticChildrenFrontEnd *synth_front) {
+m_synthetic_frontend = synth_front;
+  }
+
+  SyntheticChildrenFrontEnd *GetSyntheticFrontend() const {
+return m_synthetic_frontend;
+  }
+
   lldb::ValueObjectSP
   GetQualifiedRepresentationIfAvailable(lldb::DynamicValueType dynValue,
 bool synthValue);
@@ -898,6 +906,9 @@ class ValueObject {
   /// Unique identifier for every value object.
   UserID m_id;
 
+  // If frontend exist - we may try to update our value through it
+  SyntheticChildrenFrontEnd *m_synthetic_frontend = nullptr;
+
   // Utility class for initializing all bitfields in ValueObject's 
constructors.
   // FIXME: This could be done via default initializers once we have C++20.
   struct Bitflags {
diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h 
b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
index 41be9b7efda8fdb..3a19804b22c196c 100644
--- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h
+++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
@@ -34,7 +34,9 @@ class SyntheticChildrenFrontEnd {
 
 public:
   SyntheticChildrenFrontEnd(ValueObject &backend)
-  : m_backend(backend), m_valid(true) {}
+  : m_backend(backend), m_valid(true) {
+backend.SetSyntheticFrontend(this);
+  }
 
   virtual ~SyntheticChildrenFrontEnd() = default;
 
@@ -75,6 +77,10 @@ class SyntheticChildrenFrontEnd {
   // display purposes
   virtual ConstString GetSyntheticTypeName() { return ConstString(); }
 
+  virtual bool SetValueFromCString(const char *value_str, Status &error) {
+return false;
+  }
+
   typedef std::shared_ptr SharedPointer;
   typedef std::unique_ptr AutoPointer;
 
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index ebfc1cf4d6fe9e1..cea3ea523020443 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -1535,7 +1535,12 @@ bool ValueObject::SetValueFromCString(const char 
*value_str, Status &error) {
 }
   } else {
 // We don't support setting things bigger than a scalar at present.
-error.SetErrorString("unable to write aggregate data type");
+// But maybe our frontend knows how to update the value.
+if (auto *frontend = GetSyntheticFrontend()) {
+  return frontend->SetValueFromCString(value_str, error);
+} else {
+  error.SetErrorString("unable to write aggregate data type");
+}
 return false;
   }
 

``




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


[Lldb-commits] [lldb] [llvm][tblgen] Add `SourcePath` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread via lldb-commits

cor3ntin wrote:

@tru I'd ask @AaronBallman. My vote would be to reformat.

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


[Lldb-commits] [lldb] [llvm][tblgen] Add `SourcePath` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread Renato Golin via lldb-commits

rengolin wrote:

> @tru I'd ask @AaronBallman. My vote would be to reformat.

Not as a requirement for this patch, I imagine?

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


[Lldb-commits] [lldb] [llvm][tblgen] Add `SourcePath` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread Aaron Ballman via lldb-commits

AaronBallman wrote:

> > @tru I'd ask @AaronBallman. My vote would be to reformat.
> 
> Not as a requirement for this patch, I imagine?

If we wanted to reformat the file as an NFC commit (before or after this 
patch), that would be fine. But let's please not reformat as part of this patch 
(that makes code archeology much harder).

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


[Lldb-commits] [lldb] [llvm][tblgen] Add `SourcePath` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread Aaron Ballman via lldb-commits

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

LGTM (fine to land without tests as it only adds comments to generated header 
files)

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


[Lldb-commits] [lldb] 247b7d0 - [cmake] Add LLVM_FORCE_VC_REVISION option (#67125)

2023-09-25 Thread via lldb-commits

Author: David Truby
Date: 2023-09-25T14:32:52+01:00
New Revision: 247b7d068497de085b7fd66c6531034afa9709f0

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

LOG: [cmake] Add LLVM_FORCE_VC_REVISION option (#67125)

This patch adds a LLVM_FORCE_VC_REVISION option to force a custom
VC revision to be included instead of trying to fetch one from a
git command. This is helpful in environments where git is not
available or is non-functional but the vc revision is available
through some other means.

Added: 


Modified: 
clang/lib/Basic/CMakeLists.txt
flang/lib/Common/CMakeLists.txt
lld/Common/CMakeLists.txt
lldb/source/Version/CMakeLists.txt
llvm/CMakeLists.txt
llvm/cmake/modules/GenerateVersionFromVCS.cmake
llvm/docs/CMake.rst
llvm/include/llvm/Support/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index db59d7dd96da0a4..36ccf7d0809453e 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -39,6 +39,8 @@ add_custom_command(OUTPUT "${version_inc}"
"-DHEADER_FILE=${version_inc}"
"-DLLVM_VC_REPOSITORY=${llvm_vc_repository}"
"-DLLVM_VC_REVISION=${llvm_vc_revision}"
+   "-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}"
+   
"-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}"
-P "${generate_vcs_version_script}")
 
 # Mark the generated header as being generated.

diff  --git a/flang/lib/Common/CMakeLists.txt b/flang/lib/Common/CMakeLists.txt
index 81cee82e04b88ae..c6f818ad27cd19a 100644
--- a/flang/lib/Common/CMakeLists.txt
+++ b/flang/lib/Common/CMakeLists.txt
@@ -12,7 +12,7 @@ endif()
 if(flang_vc AND LLVM_APPEND_VC_REV)
   set(flang_source_dir ${FLANG_SOURCE_DIR})
 endif()
-
+ 
 # Create custom target to generate the VC revision include.
 add_custom_command(OUTPUT "${version_inc}"
   DEPENDS "${llvm_vc}" "${flang_vc}" "${generate_vcs_version_script}"
@@ -20,6 +20,8 @@ add_custom_command(OUTPUT "${version_inc}"
"-DLLVM_SOURCE_DIR=${llvm_source_dir}"
"-DFLANG_SOURCE_DIR=${flang_source_dir}"
"-DHEADER_FILE=${version_inc}"
+   "-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}"
+   
"-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}"
-P "${generate_vcs_version_script}")
 
 # Mark the generated header as being generated.

diff  --git a/lld/Common/CMakeLists.txt b/lld/Common/CMakeLists.txt
index c975da2a49b6bda..4f503d04f7844f7 100644
--- a/lld/Common/CMakeLists.txt
+++ b/lld/Common/CMakeLists.txt
@@ -13,6 +13,8 @@ add_custom_command(OUTPUT "${version_inc}"
   COMMAND ${CMAKE_COMMAND} "-DNAMES=LLD"
   "-DLLD_SOURCE_DIR=${lld_source_dir}"
   "-DHEADER_FILE=${version_inc}"
+  "-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}"
+  "-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}"
   -P "${generate_vcs_version_script}")
 
 # Mark the generated header as being generated.

diff  --git a/lldb/source/Version/CMakeLists.txt 
b/lldb/source/Version/CMakeLists.txt
index c1393b5dd6e6b62..90fe53d52cc5d05 100644
--- a/lldb/source/Version/CMakeLists.txt
+++ b/lldb/source/Version/CMakeLists.txt
@@ -17,6 +17,8 @@ add_custom_command(OUTPUT "${vcs_version_inc}"
   COMMAND ${CMAKE_COMMAND} "-DNAMES=LLDB"
"-DLLDB_SOURCE_DIR=${lldb_source_dir}"
"-DHEADER_FILE=${vcs_version_inc}"
+   "-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}"
+   
"-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}"
-P "${generate_vcs_version_script}")
 
 set_source_files_properties("${vcs_version_inc}"

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index fa39c7554de1f61..5985256498dcbb2 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -325,6 +325,12 @@ include(VersionFromVCS)
 option(LLVM_APPEND_VC_REV
   "Embed the version control system revision in LLVM" ON)
 
+set(LLVM_FORCE_VC_REVISION
+  "" CACHE STRING "Force custom VC revision for LLVM_APPEND_VC_REV")
+
+set(LLVM_FORCE_VC_REPOSITORY
+  "" CACHE STRING "Force custom VC repository for LLVM_APPEND_VC_REV")
+
 option(LLVM_TOOL_LLVM_DRIVER_BUILD "Enables building the llvm multicall tool" 
OFF)
 
 set(PACKAGE_NAME LLVM)

diff  --git a/llvm/cmake/modules/GenerateVersionFromVCS.cmake 
b/llvm/cmake/modules/GenerateVersionFromVCS.cmake
index 9cd780e5aa162c0..1b3b2946e62b25c 100644
--- a/llvm/cmake/modules/GenerateVersionFromVCS.cmake
+++ b/llvm/cmake/modules/GenerateVersionFromVCS.cm

[Lldb-commits] [lldb] [cmake] Add LLVM_FORCE_VC_REVISION option (PR #67125)

2023-09-25 Thread David Truby via lldb-commits

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


[Lldb-commits] [lldb] [llvm][tblgen] Add `SourcePath` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread NAKAMURA Takumi via lldb-commits


@@ -59,4 +60,8 @@ void llvm::emitSourceFileHeader(StringRef Desc, raw_ostream 
&OS) {
   printLine(OS, Prefix, ' ', Suffix);
   printLine(OS, "\\*===", '-', "===*/");
   OS << '\n';
+
+  // Print the path of source file
+  if (!Record.getInputFilename().empty())
+OS << "// Generated from: " << Record.getInputFilename() << "\n\n";

chapuni wrote:

I think this could be enabled if the base path would be given from the build 
system.

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


[Lldb-commits] [lldb] [llvm][tblgen] Add `SourcePath` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread NAKAMURA Takumi via lldb-commits

https://github.com/chapuni requested changes to this pull request.

Hang on, would it expose build paths to installed headers?

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


[Lldb-commits] [lldb] [llvm][tblgen] Add `SourcePath` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread Aaron Ballman via lldb-commits


@@ -59,4 +60,8 @@ void llvm::emitSourceFileHeader(StringRef Desc, raw_ostream 
&OS) {
   printLine(OS, Prefix, ' ', Suffix);
   printLine(OS, "\\*===", '-', "===*/");
   OS << '\n';
+
+  // Print the path of source file
+  if (!Record.getInputFilename().empty())
+OS << "// Generated from: " << Record.getInputFilename() << "\n\n";

AaronBallman wrote:

Good question! I was thinking it would give just the base file name, not the 
full path to the file: 
https://github.com/llvm/llvm-project/blob/aa8f5e6156821aec1fed595f2e13d69655ec3311/llvm/lib/TableGen/Main.cpp#L115
 -- that looks like it will generate whatever was given on the command line, 
which could very well be a full path.

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


[Lldb-commits] [lldb] [lldb] add command start (PR #67019)

2023-09-25 Thread José Lira Junior via lldb-commits

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


[Lldb-commits] [lldb] [lldb] add command start (PR #67019)

2023-09-25 Thread José Lira Junior via lldb-commits

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


[Lldb-commits] [lldb] [llvm][tblgen] Add `SourcePath` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread Shao-Ce SUN via lldb-commits

sunshaoce wrote:

I am not sure how to keep only the `llvm-project//Filename` path except by 
hard-coding. Or how to keep only the base file name? This could limit it to 
within 80 characters.

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


[Lldb-commits] [lldb] [llvm][tblgen] Add `SourcePath` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread Aaron Ballman via lldb-commits

AaronBallman wrote:

> I am not sure how to keep only the `llvm-project//Filename` path except 
> by hard-coding. Or how about only keeping the base file name? This could 
> limit it to within 80 characters.

I'd recommend using this API: 
https://github.com/llvm/llvm-project/blob/2f23666ae7e434a222a67ac6499d118035ab7903/llvm/include/llvm/Support/Path.h#L357
 to get the base filename from the path, and then print just the base filename.

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


[Lldb-commits] [lldb] [llvm][tblgen] Add `SourcePath` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread Shao-Ce SUN via lldb-commits
" + sys::path::filename(Record.getInputFilename()),"
In-Reply-To: 


https://github.com/sunshaoce updated 
https://github.com/llvm/llvm-project/pull/65744

>From 23d0b738bf40ea44e159f4f8d7355d4d6bc0688d Mon Sep 17 00:00:00 2001
From: Shao-Ce SUN 
Date: Sat, 23 Sep 2023 11:38:33 +0800
Subject: [PATCH 1/3] [llvm][tblgen] Add `SourcePath` for
 `emitSourceFileHeader`

---
 llvm/include/llvm/TableGen/TableGenBackend.h | 3 ++-
 llvm/lib/TableGen/TableGenBackend.cpp| 7 ++-
 llvm/utils/TableGen/VTEmitter.cpp| 3 ++-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/TableGen/TableGenBackend.h 
b/llvm/include/llvm/TableGen/TableGenBackend.h
index 39f1e14bc950841..7bbd163b0433aca 100644
--- a/llvm/include/llvm/TableGen/TableGenBackend.h
+++ b/llvm/include/llvm/TableGen/TableGenBackend.h
@@ -50,7 +50,8 @@ template  class OptClass : Opt {
 
 /// emitSourceFileHeader - Output an LLVM style file header to the specified
 /// raw_ostream.
-void emitSourceFileHeader(StringRef Desc, raw_ostream &OS);
+void emitSourceFileHeader(StringRef Desc, raw_ostream &OS,
+  StringRef SourcePath = "");
 
 } // End llvm namespace
 
diff --git a/llvm/lib/TableGen/TableGenBackend.cpp 
b/llvm/lib/TableGen/TableGenBackend.cpp
index 135ec643bc3a7df..a50df8dbdcfb220 100644
--- a/llvm/lib/TableGen/TableGenBackend.cpp
+++ b/llvm/lib/TableGen/TableGenBackend.cpp
@@ -40,7 +40,8 @@ static void printLine(raw_ostream &OS, const Twine &Prefix, 
char Fill,
   OS << Suffix << '\n';
 }
 
-void llvm::emitSourceFileHeader(StringRef Desc, raw_ostream &OS) {
+void llvm::emitSourceFileHeader(StringRef Desc, raw_ostream &OS,
+StringRef SourcePath) {
   printLine(OS, "/*===- TableGen'erated file ", '-', "*- C++ -*-===*\\");
   StringRef Prefix("|* ");
   StringRef Suffix(" *|");
@@ -59,4 +60,8 @@ void llvm::emitSourceFileHeader(StringRef Desc, raw_ostream 
&OS) {
   printLine(OS, Prefix, ' ', Suffix);
   printLine(OS, "\\*===", '-', "===*/");
   OS << '\n';
+
+  // Print the path of source file
+  if (!SourcePath.empty())
+OS << "// Generated from: " << SourcePath << "\n\n";
 }
diff --git a/llvm/utils/TableGen/VTEmitter.cpp 
b/llvm/utils/TableGen/VTEmitter.cpp
index d398a7e7b58f40a..03fa3d64b41fe6c 100644
--- a/llvm/utils/TableGen/VTEmitter.cpp
+++ b/llvm/utils/TableGen/VTEmitter.cpp
@@ -30,7 +30,8 @@ class VTEmitter {
 } // End anonymous namespace.
 
 void VTEmitter::run(raw_ostream &OS) {
-  emitSourceFileHeader("ValueTypes Source Fragment", OS);
+  emitSourceFileHeader("ValueTypes Source Fragment", OS,
+   Records.getInputFilename());
 
   std::array VTsByNumber = {};
   auto ValueTypes = Records.getAllDerivedDefinitions("ValueType");

>From d07486764071679c8cbcd5e7c4905eb41b4770b3 Mon Sep 17 00:00:00 2001
From: Shao-Ce SUN 
Date: Sun, 24 Sep 2023 00:52:02 +0800
Subject: [PATCH 2/3] add more tests

---
 clang/utils/TableGen/ClangASTNodesEmitter.cpp |  4 +-
 .../TableGen/ClangASTPropertiesEmitter.cpp|  8 ++--
 clang/utils/TableGen/ClangAttrEmitter.cpp | 47 +++
 .../ClangCommentCommandInfoEmitter.cpp|  8 ++--
 ...mentHTMLNamedCharacterReferenceEmitter.cpp |  4 +-
 .../TableGen/ClangCommentHTMLTagsEmitter.cpp  |  5 +-
 .../TableGen/ClangOpenCLBuiltinEmitter.cpp|  6 +--
 clang/utils/TableGen/ClangSyntaxEmitter.cpp   |  4 +-
 .../utils/TableGen/ClangTypeNodesEmitter.cpp  |  2 +-
 lldb/utils/TableGen/LLDBOptionDefEmitter.cpp  |  2 +-
 .../utils/TableGen/LLDBPropertyDefEmitter.cpp |  4 +-
 llvm/include/llvm/TableGen/TableGenBackend.h  |  3 +-
 llvm/lib/TableGen/TableGenBackend.cpp |  6 +--
 llvm/utils/TableGen/AsmMatcherEmitter.cpp |  2 +-
 llvm/utils/TableGen/AsmWriterEmitter.cpp  |  2 +-
 llvm/utils/TableGen/VTEmitter.cpp |  3 +-
 mlir/tools/mlir-tblgen/DialectGen.cpp |  4 +-
 mlir/tools/mlir-tblgen/EnumsGen.cpp   |  4 +-
 mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp |  2 +-
 mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp   |  4 +-
 mlir/tools/mlir-tblgen/RewriterGen.cpp|  2 +-
 mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp  | 22 +
 22 files changed, 81 insertions(+), 67 deletions(-)

diff --git a/clang/utils/TableGen/ClangASTNodesEmitter.cpp 
b/clang/utils/TableGen/ClangASTNodesEmitter.cpp
index 2b8d7a9efdf10c9..16a1c74b9d91ad6 100644
--- a/clang/utils/TableGen/ClangASTNodesEmitter.cpp
+++ b/clang/utils/TableGen/ClangASTNodesEmitter.cpp
@@ -169,7 +169,7 @@ void ClangASTNodesEmitter::deriveChildTree() {
 void ClangASTNodesEmitter::run(raw_ostream &OS) {
   deriveChildTree();
 
-  emitSourceFileHeader("List of AST nodes of a particular kind", OS);
+  emitSourceFileHeader("List of AST nodes of a particular kind", OS, Records);
 
   // Write the preamble
   OS << "#ifndef ABSTRACT_" << macroHierarchyName() << "\n";
@@ -205,7 +205,7 @@ void clang::EmitClangASTNodes(RecordKeeper &RK, raw_ostream 
&OS,
 void clang::EmitClangDeclContext(RecordKee

[Lldb-commits] [lldb] [llvm][tblgen] Add `SourcePath` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread Shao-Ce SUN via lldb-commits
" + sys::path::filename(Record.getInputFilename()),"
In-Reply-To: 


sunshaoce wrote:

Addressed. Thanks! Now it is
```
/*===- TableGen'erated file -*- C++ -*-===*\
|**|
|* ValueTypes Source Fragment *|
|**|
|* Automatically generated file, do not edit! *|
|* From: ValueTypes.td*|
|**|
\*===--===*/
```

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


[Lldb-commits] [lldb] [lldb] Add SetValueFromCString API to SyntheticFronend (PR #67309)

2023-09-25 Thread via lldb-commits

jimingham wrote:

Getting the SyntheticFrontEnd to try updating the synthetic value is a good 
addition.  But I'm not sure that ValueObject should be the one that should 
provide access directly to the FrontEnd?  Why isn't it enough to have the 
ValueObjectSynthetic's SetValueFromCString do this?  If you have decided to 
pull the Non-synthetic value (and so are accessing the ValueObjectVariable 
directly, would you expect to have the synthetic value do an update?  When 
would something that is a ValueObject but not a ValueObjectSynthetic really 
want to update the value using the SyntheticFrontEnd?

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


[Lldb-commits] [lldb] [lldb][Commands] Show symbol change bit in SB API (PR #66144)

2023-09-25 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/66144

>From 8754d93a72bdff94f95f991d9bf1112e5f9fe692 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 12 Sep 2023 13:49:50 -0700
Subject: [PATCH 1/5] [lldb][Commands] Show symbol change bit in SB API

This exposes the `eBroadcastBitSymbolChange` bit to the SB
API to show when a symbol change event has been broadcast as
this wasn't being done before. Also refactors `eBroadcastSymbolChange`
to `eBroadcastBitSymbolChange` to match the naming convention
for other event bits used in the debugger.
---
 lldb/include/lldb/API/SBDebugger.h|  2 ++
 lldb/include/lldb/Core/Debugger.h |  2 +-
 lldb/source/Commands/CommandObjectTarget.cpp  |  4 
 lldb/source/Core/Debugger.cpp |  4 ++--
 .../add-dsym/uuid/TestAddDsymCommand.py   | 24 +++
 5 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 29cf2c16fad4bd7..abb08e93d197a18 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -46,6 +47,7 @@ class LLDB_API SBDebugger {
   eBroadcastBitProgress = (1 << 0),
   eBroadcastBitWarning = (1 << 1),
   eBroadcastBitError = (1 << 2),
+  eBroadcastBitSymbolChange = (1 << 3),
   };
 
   SBDebugger();
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 5532cace606bfed..6cdf1a183b18e54 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -83,7 +83,7 @@ class Debugger : public 
std::enable_shared_from_this,
 eBroadcastBitProgress = (1 << 0),
 eBroadcastBitWarning = (1 << 1),
 eBroadcastBitError = (1 << 2),
-eBroadcastSymbolChange = (1 << 3),
+eBroadcastBitSymbolChange = (1 << 3),
   };
 
   using DebuggerList = std::vector;
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 3e024ff91b382d7..8051b3826294ab3 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -4504,6 +4504,10 @@ class CommandObjectTargetSymbolsAdd : public 
CommandObjectParsed {
   if (process)
 process->Flush();
 }
+
+if (result.Succeeded())
+  Debugger::ReportSymbolChange(module_spec);
+
 return result.Succeeded();
   }
 
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 7ec1efc64fe9383..924741f45040bf0 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -1536,7 +1536,7 @@ void Debugger::ReportSymbolChange(const ModuleSpec 
&module_spec) {
 std::lock_guard guard(*g_debugger_list_mutex_ptr);
 for (DebuggerSP debugger_sp : *g_debugger_list_ptr) {
   EventSP event_sp = std::make_shared(
-  Debugger::eBroadcastSymbolChange,
+  Debugger::eBroadcastBitSymbolChange,
   new SymbolChangeEventData(debugger_sp, module_spec));
   debugger_sp->GetBroadcaster().BroadcastEvent(event_sp);
 }
@@ -1844,7 +1844,7 @@ lldb::thread_result_t Debugger::DefaultEventHandler() {
 
   listener_sp->StartListeningForEvents(
   &m_broadcaster, eBroadcastBitProgress | eBroadcastBitWarning |
-  eBroadcastBitError | eBroadcastSymbolChange);
+  eBroadcastBitError | eBroadcastBitSymbolChange);
 
   // Let the thread that spawned us know that we have started up and that we
   // are now listening to all required events so no events get missed
diff --git a/lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py 
b/lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py
index d16ca32d79e6808..01b7d41f85c1185 100644
--- a/lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py
+++ b/lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py
@@ -57,6 +57,30 @@ def test_add_dsym_with_dSYM_bundle(self):
 self.exe_name = "a.out"
 self.do_add_dsym_with_dSYM_bundle(self.exe_name)
 
+@no_debug_info_test
+def test_report_symbol_change(self):
+"""Test that when adding a symbol file, the eBroadcastBitSymbolChange 
event gets broadcasted."""
+self.generate_main_cpp(version=1)
+self.build(debug_info="dsym")
+
+self.exe_name = "a.out"
+
+# Get the broadcaster and listen for the symbol change event
+self.broadcaster = self.dbg.GetBroadcaster()
+self.listener = lldbutil.start_listening_from(
+self.broadcaster, lldb.SBDebugger.eBroadcastBitSymbolChange
+)
+
+# Add the dSYM
+self.do_add_dsym_with_success(self.exe_name)
+
+# Get the next event
+event = lldbutil.fetch_next_event(self, self.listener, 

[Lldb-commits] [lldb] [lldb][Commands] Check that modules reports that they're loaded (PR #66144)

2023-09-25 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] 962ef99 - [lldb] Protect RNBRemote from a data race

2023-09-25 Thread Augusto Noronha via lldb-commits

Author: Augusto Noronha
Date: 2023-09-25T11:17:42-07:00
New Revision: 962ef991da2836775191435fb732fc61ec07d5e6

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

LOG: [lldb] Protect RNBRemote from a data race

Summary:
Thread sanitizer reports the following data race:

```
  Write of size 8 at 0x000103303e70 by thread T1 (mutexes: write M0):
#0 RNBRemote::CommDataReceived(std::__1::basic_string, std::__1::allocator> const&) 
RNBRemote.cpp:1075 (debugserver:arm64+0x100038db8) (BuildId: 
f130b34f693c4f3eba96139104af2b71320021000e00)
#1 RNBRemote::ThreadFunctionReadRemoteData(void*) RNBRemote.cpp:1180 
(debugserver:arm64+0x1000391dc) (BuildId: 
f130b34f693c4f3eba96139104af2b71320021000e00)

  Previous read of size 8 at 0x000103303e70 by main thread:
#0 RNBRemote::GetPacketPayload(std::__1::basic_string, std::__1::allocator>&) RNBRemote.cpp:797 
(debugserver:arm64+0x100037c5c) (BuildId: 
f130b34f693c4f3eba96139104af2b71320021000e00)
#1 RNBRemote::GetPacket(std::__1::basic_string, std::__1::allocator>&, RNBRemote::Packet&, 
bool) RNBRemote.cpp:907 (debugserver:arm64+0x1000378cc) (BuildId: 
f130b34f693c4f3eba96139104af2b71320021000e00)
```

RNBRemote already has a mutex, extend its usage to protect the read of
m_rx_packets.

Reviewers: jdevlieghere, bulbazord, jingham

Subscribers:

Added: 


Modified: 
lldb/tools/debugserver/source/RNBRemote.cpp

Removed: 




diff  --git a/lldb/tools/debugserver/source/RNBRemote.cpp 
b/lldb/tools/debugserver/source/RNBRemote.cpp
index ea039101bb541b0..4e9086b0411f2d7 100644
--- a/lldb/tools/debugserver/source/RNBRemote.cpp
+++ b/lldb/tools/debugserver/source/RNBRemote.cpp
@@ -777,26 +777,28 @@ rnb_err_t RNBRemote::GetPacketPayload(std::string 
&return_packet) {
   // DNBLogThreadedIf (LOG_RNB_MAX, "%8u RNBRemote::%s called",
   // (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__);
 
-  PThreadMutex::Locker locker(m_mutex);
-  if (m_rx_packets.empty()) {
-// Only reset the remote command available event if we have no more packets
-m_ctx.Events().ResetEvents(RNBContext::event_read_packet_available);
-// DNBLogThreadedIf (LOG_RNB_MAX, "%8u RNBRemote::%s error: no packets
-// available...", (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true),
-// __FUNCTION__);
-return rnb_err;
-  }
+  {
+PThreadMutex::Locker locker(m_mutex);
+if (m_rx_packets.empty()) {
+  // Only reset the remote command available event if we have no more
+  // packets
+  m_ctx.Events().ResetEvents(RNBContext::event_read_packet_available);
+  // DNBLogThreadedIf (LOG_RNB_MAX, "%8u RNBRemote::%s error: no packets
+  // available...", (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true),
+  // __FUNCTION__);
+  return rnb_err;
+}
 
-  // DNBLogThreadedIf (LOG_RNB_MAX, "%8u RNBRemote::%s has %u queued packets",
-  // (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__,
-  // m_rx_packets.size());
-  return_packet.swap(m_rx_packets.front());
-  m_rx_packets.pop_front();
-  locker.Reset(); // Release our lock on the mutex
-
-  if (m_rx_packets.empty()) {
-// Reset the remote command available event if we have no more packets
-m_ctx.Events().ResetEvents(RNBContext::event_read_packet_available);
+// DNBLogThreadedIf (LOG_RNB_MAX, "%8u RNBRemote::%s has %u queued 
packets",
+// (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__,
+// m_rx_packets.size());
+return_packet.swap(m_rx_packets.front());
+m_rx_packets.pop_front();
+
+if (m_rx_packets.empty()) {
+  // Reset the remote command available event if we have no more packets
+  m_ctx.Events().ResetEvents(RNBContext::event_read_packet_available);
+}
   }
 
   // DNBLogThreadedIf (LOG_RNB_MEDIUM, "%8u RNBRemote::%s: '%s'",



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


[Lldb-commits] [lldb] [lldb] add command start (PR #67019)

2023-09-25 Thread Greg Clayton via lldb-commits
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -38,7 +38,18 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
   case 's': // Stop at program entry point
 launch_info.GetFlags().Set(eLaunchFlagStopAtEntry);
 break;
-
+  case 'm': // Stop at main function
+  {
+TargetSP target_sp =
+execution_context ? execution_context->GetTargetSP() : TargetSP();
+BreakpointSP bp_sp = target_sp->CreateBreakpoint(
+nullptr, nullptr, "main", eFunctionNameTypeAuto, eLanguageTypeUnknown,

clayborg wrote:

This actually only works on darwin, as the entry point address actually points 
to the main function. For linux, this points to "_start", so my suggested 
approach above doesn't actually work for all platforms.

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


[Lldb-commits] [lldb] [lldb][FreeBSD] Add dynamic loader handle class for FreeBSD Kernel (PR #67106)

2023-09-25 Thread Greg Clayton via lldb-commits


@@ -0,0 +1,770 @@
+#include "lldb/Breakpoint/StoppointCallbackContext.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Section.h"
+#include "lldb/Core/StreamFile.h"
+#include "lldb/Interpreter/OptionValueProperties.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/OperatingSystem.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+#include "lldb/Target/ThreadPlanRunToAddress.h"
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/State.h"
+
+#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
+
+#include "DynamicLoaderFreeBSDKernel.h"
+#include 
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+LLDB_PLUGIN_DEFINE(DynamicLoaderFreeBSDKernel)
+
+void DynamicLoaderFreeBSDKernel::Initialize() {
+  PluginManager::RegisterPlugin(GetPluginNameStatic(),
+GetPluginDescriptionStatic(), CreateInstance,
+DebuggerInit);
+}
+
+void DynamicLoaderFreeBSDKernel::Terminate() {
+  PluginManager::UnregisterPlugin(CreateInstance);
+}
+
+llvm::StringRef DynamicLoaderFreeBSDKernel::GetPluginDescriptionStatic() {
+  return "The Dynamic Loader Plugin For FreeBSD Kernel";
+}
+
+static bool is_kernel(Module *module) {
+  if (!module)
+return false;
+
+  ObjectFile *objfile = module->GetObjectFile();
+  if (!objfile)
+return false;
+  if (objfile->GetType() != ObjectFile::eTypeExecutable)
+return false;
+  if (objfile->GetStrata() != ObjectFile::eStrataUnknown &&
+  objfile->GetStrata() != ObjectFile::eStrataUser)

clayborg wrote:

It is ok if something only works for FreeBSD too, just check the OSABI in the 
ELF header if this only works for FreeBSD. If this works for linux as well, 
then feel free to make it work for both!

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


[Lldb-commits] [lldb] d3505c2 - [lldb] Modify the DWARFDebugAbbrev interface to be closer to LLVM's (#67190)

2023-09-25 Thread via lldb-commits

Author: Alex Langford
Date: 2023-09-25T13:11:39-07:00
New Revision: d3505c28a770fabd77d7483afbca383d453bef02

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

LOG: [lldb] Modify the DWARFDebugAbbrev interface to be closer to LLVM's 
(#67190)

I want to work towards unifying the implementations. It would be a lot
easier to do if LLDB's DWARFDebugAbbrev looked more similar to LLVM's
implementation, so this change moves in that direction.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
index 0cd53463ee65e08..bcebba6abd3ee5c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
@@ -15,24 +15,30 @@ using namespace lldb;
 using namespace lldb_private;
 
 // DWARFDebugAbbrev constructor
-DWARFDebugAbbrev::DWARFDebugAbbrev()
-: m_abbrevCollMap(), m_prev_abbr_offset_pos(m_abbrevCollMap.end()) {}
+DWARFDebugAbbrev::DWARFDebugAbbrev(const DWARFDataExtractor &data)
+: m_abbrevCollMap(), m_prev_abbr_offset_pos(m_abbrevCollMap.end()),
+  m_data(data.GetAsLLVM()) {}
 
 // DWARFDebugAbbrev::Parse()
-llvm::Error DWARFDebugAbbrev::parse(const DWARFDataExtractor &data) {
-  llvm::DataExtractor llvm_data = data.GetAsLLVM();
+llvm::Error DWARFDebugAbbrev::parse() {
+  if (!m_data)
+return llvm::Error::success();
+
   lldb::offset_t offset = 0;
 
-  while (llvm_data.isValidOffset(offset)) {
+  while (m_data->isValidOffset(offset)) {
 uint32_t initial_cu_offset = offset;
 DWARFAbbreviationDeclarationSet abbrevDeclSet;
 
-llvm::Error error = abbrevDeclSet.extract(llvm_data, &offset);
-if (error)
+llvm::Error error = abbrevDeclSet.extract(*m_data, &offset);
+if (error) {
+  m_data = std::nullopt;
   return error;
+}
 
 m_abbrevCollMap[initial_cu_offset] = abbrevDeclSet;
   }
+  m_data = std::nullopt;
   m_prev_abbr_offset_pos = m_abbrevCollMap.end();
   return llvm::ErrorSuccess();
 }

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
index 0a579e34b001337..6d0616deeb91038 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
@@ -29,18 +29,19 @@ typedef DWARFAbbreviationDeclarationCollMap::const_iterator
 
 class DWARFDebugAbbrev {
 public:
-  DWARFDebugAbbrev();
+  DWARFDebugAbbrev(const lldb_private::DWARFDataExtractor &data);
   const DWARFAbbreviationDeclarationSet *
   GetAbbreviationDeclarationSet(dw_offset_t cu_abbr_offset) const;
   /// Extract all abbreviations for a particular compile unit.  Returns
   /// llvm::ErrorSuccess() on success, and an appropriate llvm::Error object
   /// otherwise.
-  llvm::Error parse(const lldb_private::DWARFDataExtractor &data);
+  llvm::Error parse();
   void GetUnsupportedForms(std::set &invalid_forms) const;
 
 protected:
   DWARFAbbreviationDeclarationCollMap m_abbrevCollMap;
   mutable DWARFAbbreviationDeclarationCollMapConstIter m_prev_abbr_offset_pos;
+  mutable std::optional m_data;
 };
 
 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGABBREV_H

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 04c729e333a9854..9832c324a2c0e55 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -622,8 +622,8 @@ DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() {
   if (debug_abbrev_data.GetByteSize() == 0)
 return nullptr;
 
-  auto abbr = std::make_unique();
-  llvm::Error error = abbr->parse(debug_abbrev_data);
+  auto abbr = std::make_unique(debug_abbrev_data);
+  llvm::Error error = abbr->parse();
   if (error) {
 Log *log = GetLog(DWARFLog::DebugInfo);
 LLDB_LOG_ERROR(log, std::move(error),



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


[Lldb-commits] [lldb] [lldb] Modify the DWARFDebugAbbrev interface to be closer to LLVM's (PR #67190)

2023-09-25 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [PATCH] D159101: [RISC-V] Add RISC-V ABI plugin

2023-09-25 Thread Ted Woodward via Phabricator via lldb-commits
ted updated this revision to Diff 557321.
ted added a comment.

Remove disabling JIT and enabling IR Interpreter function calls, as requested
by Jason Molenda.

Added default unwind plan as suggested by Jason Molenda.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159101

Files:
  lldb/source/Plugins/ABI/CMakeLists.txt
  lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
  lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.h
  lldb/source/Plugins/ABI/RISCV/CMakeLists.txt
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp

Index: lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
===
--- lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -1550,6 +1550,8 @@
 ArchSpec::eRISCV_float_abi_quad)
   features_str += "+f,+d,+q,";
 // FIXME: how do we detect features such as `+a`, `+m`?
+// Turn them on by default now, since everyone seems to use them
+features_str += "+a,+m,";
   }
 
   // We use m_disasm_up.get() to tell whether we are valid or not, so if this
Index: lldb/source/Plugins/ABI/RISCV/CMakeLists.txt
===
--- /dev/null
+++ lldb/source/Plugins/ABI/RISCV/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_lldb_library(lldbPluginABIRISCV PLUGIN
+  ABISysV_riscv.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbPluginProcessUtility
+  LINK_COMPONENTS
+Support
+TargetParser
+  )
Index: lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.h
===
--- /dev/null
+++ lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.h
@@ -0,0 +1,131 @@
+//===-- ABISysV_riscv.h -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_ABISysV_riscv_h_
+#define liblldb_ABISysV_riscv_h_
+
+// Other libraries and framework includes
+#include 
+
+#include "llvm/TargetParser/Triple.h"
+
+// Project includes
+#include "lldb/Target/ABI.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Utility/Flags.h"
+#include "lldb/lldb-private.h"
+
+class ABISysV_riscv : public lldb_private::RegInfoBasedABI {
+public:
+  ~ABISysV_riscv() override = default;
+
+  size_t GetRedZoneSize() const override { return 0; }
+
+  bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp,
+  lldb::addr_t functionAddress,
+  lldb::addr_t returnAddress,
+  llvm::ArrayRef args) const override;
+
+  // Special thread plan for GDB style non-jit function calls.
+  bool
+  PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp,
+ lldb::addr_t functionAddress, lldb::addr_t returnAddress,
+ llvm::Type &prototype,
+ llvm::ArrayRef args) const override;
+
+  bool GetArgumentValues(lldb_private::Thread &thread,
+ lldb_private::ValueList &values) const override;
+
+  lldb_private::Status
+  SetReturnValueObject(lldb::StackFrameSP &frame_sp,
+   lldb::ValueObjectSP &new_value) override;
+
+  lldb::ValueObjectSP
+  GetReturnValueObjectImpl(lldb_private::Thread &thread,
+   lldb_private::CompilerType &type) const override;
+
+  // Specialized to work with llvm IR types.
+  lldb::ValueObjectSP GetReturnValueObjectImpl(lldb_private::Thread &thread,
+   llvm::Type &type) const override;
+
+  bool
+  CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
+
+  bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
+
+  bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
+
+  bool CallFrameAddressIsValid(lldb::addr_t cfa) override {
+// The CFA must be 128 bit aligned, unless the E ABI is used
+lldb_private::ArchSpec arch = GetProcessSP()->GetTarget().GetArchitecture();
+lldb_private::Flags arch_flags = arch.GetFlags();
+if (arch_flags.Test(lldb_private::ArchSpec::eRISCV_rve))
+  return (cfa & 0x3ull) == 0;
+return (cfa & 0xfull) == 0;
+  }
+
+  void SetIsRV64(bool is_rv64) { m_is_rv64 = is_rv64; }
+
+  bool CodeAddressIsValid(lldb::addr_t pc) override {
+// Calls can use the least significant bit to store auxiliary information,
+// so no strict check is done for alignment.
+
+lldb_private::ArchSpec arch = GetProcessSP()->GetTarget().GetArchitecture();
+
+//  & 2 set is a fault if C extension is not used.
+lldb_priv

[Lldb-commits] [PATCH] D159101: [RISC-V] Add RISC-V ABI plugin

2023-09-25 Thread Ted Woodward via Phabricator via lldb-commits
ted updated this revision to Diff 557322.
ted marked 3 inline comments as done.
ted added a comment.

Change "word_size = m_is_rv64 ? 8 : 4" to "word_size = reg_size"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159101

Files:
  lldb/source/Plugins/ABI/CMakeLists.txt
  lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
  lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.h
  lldb/source/Plugins/ABI/RISCV/CMakeLists.txt
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp

Index: lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
===
--- lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -1550,6 +1550,8 @@
 ArchSpec::eRISCV_float_abi_quad)
   features_str += "+f,+d,+q,";
 // FIXME: how do we detect features such as `+a`, `+m`?
+// Turn them on by default now, since everyone seems to use them
+features_str += "+a,+m,";
   }
 
   // We use m_disasm_up.get() to tell whether we are valid or not, so if this
Index: lldb/source/Plugins/ABI/RISCV/CMakeLists.txt
===
--- /dev/null
+++ lldb/source/Plugins/ABI/RISCV/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_lldb_library(lldbPluginABIRISCV PLUGIN
+  ABISysV_riscv.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbPluginProcessUtility
+  LINK_COMPONENTS
+Support
+TargetParser
+  )
Index: lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.h
===
--- /dev/null
+++ lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.h
@@ -0,0 +1,131 @@
+//===-- ABISysV_riscv.h -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_ABISysV_riscv_h_
+#define liblldb_ABISysV_riscv_h_
+
+// Other libraries and framework includes
+#include 
+
+#include "llvm/TargetParser/Triple.h"
+
+// Project includes
+#include "lldb/Target/ABI.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Utility/Flags.h"
+#include "lldb/lldb-private.h"
+
+class ABISysV_riscv : public lldb_private::RegInfoBasedABI {
+public:
+  ~ABISysV_riscv() override = default;
+
+  size_t GetRedZoneSize() const override { return 0; }
+
+  bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp,
+  lldb::addr_t functionAddress,
+  lldb::addr_t returnAddress,
+  llvm::ArrayRef args) const override;
+
+  // Special thread plan for GDB style non-jit function calls.
+  bool
+  PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp,
+ lldb::addr_t functionAddress, lldb::addr_t returnAddress,
+ llvm::Type &prototype,
+ llvm::ArrayRef args) const override;
+
+  bool GetArgumentValues(lldb_private::Thread &thread,
+ lldb_private::ValueList &values) const override;
+
+  lldb_private::Status
+  SetReturnValueObject(lldb::StackFrameSP &frame_sp,
+   lldb::ValueObjectSP &new_value) override;
+
+  lldb::ValueObjectSP
+  GetReturnValueObjectImpl(lldb_private::Thread &thread,
+   lldb_private::CompilerType &type) const override;
+
+  // Specialized to work with llvm IR types.
+  lldb::ValueObjectSP GetReturnValueObjectImpl(lldb_private::Thread &thread,
+   llvm::Type &type) const override;
+
+  bool
+  CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
+
+  bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
+
+  bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
+
+  bool CallFrameAddressIsValid(lldb::addr_t cfa) override {
+// The CFA must be 128 bit aligned, unless the E ABI is used
+lldb_private::ArchSpec arch = GetProcessSP()->GetTarget().GetArchitecture();
+lldb_private::Flags arch_flags = arch.GetFlags();
+if (arch_flags.Test(lldb_private::ArchSpec::eRISCV_rve))
+  return (cfa & 0x3ull) == 0;
+return (cfa & 0xfull) == 0;
+  }
+
+  void SetIsRV64(bool is_rv64) { m_is_rv64 = is_rv64; }
+
+  bool CodeAddressIsValid(lldb::addr_t pc) override {
+// Calls can use the least significant bit to store auxiliary information,
+// so no strict check is done for alignment.
+
+lldb_private::ArchSpec arch = GetProcessSP()->GetTarget().GetArchitecture();
+
+//  & 2 set is a fault if C extension is not used.
+lldb_private::Flags arch_flags(arch.GetFlags());
+if (!a

[Lldb-commits] [PATCH] D159101: [RISC-V] Add RISC-V ABI plugin

2023-09-25 Thread Ted Woodward via Phabricator via lldb-commits
ted updated this revision to Diff 557323.
ted marked 4 inline comments as done.
ted added a comment.

Fix comment about "a" registers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159101

Files:
  lldb/source/Plugins/ABI/CMakeLists.txt
  lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
  lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.h
  lldb/source/Plugins/ABI/RISCV/CMakeLists.txt
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp

Index: lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
===
--- lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -1550,6 +1550,8 @@
 ArchSpec::eRISCV_float_abi_quad)
   features_str += "+f,+d,+q,";
 // FIXME: how do we detect features such as `+a`, `+m`?
+// Turn them on by default now, since everyone seems to use them
+features_str += "+a,+m,";
   }
 
   // We use m_disasm_up.get() to tell whether we are valid or not, so if this
Index: lldb/source/Plugins/ABI/RISCV/CMakeLists.txt
===
--- /dev/null
+++ lldb/source/Plugins/ABI/RISCV/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_lldb_library(lldbPluginABIRISCV PLUGIN
+  ABISysV_riscv.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbPluginProcessUtility
+  LINK_COMPONENTS
+Support
+TargetParser
+  )
Index: lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.h
===
--- /dev/null
+++ lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.h
@@ -0,0 +1,131 @@
+//===-- ABISysV_riscv.h -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_ABISysV_riscv_h_
+#define liblldb_ABISysV_riscv_h_
+
+// Other libraries and framework includes
+#include 
+
+#include "llvm/TargetParser/Triple.h"
+
+// Project includes
+#include "lldb/Target/ABI.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Utility/Flags.h"
+#include "lldb/lldb-private.h"
+
+class ABISysV_riscv : public lldb_private::RegInfoBasedABI {
+public:
+  ~ABISysV_riscv() override = default;
+
+  size_t GetRedZoneSize() const override { return 0; }
+
+  bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp,
+  lldb::addr_t functionAddress,
+  lldb::addr_t returnAddress,
+  llvm::ArrayRef args) const override;
+
+  // Special thread plan for GDB style non-jit function calls.
+  bool
+  PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp,
+ lldb::addr_t functionAddress, lldb::addr_t returnAddress,
+ llvm::Type &prototype,
+ llvm::ArrayRef args) const override;
+
+  bool GetArgumentValues(lldb_private::Thread &thread,
+ lldb_private::ValueList &values) const override;
+
+  lldb_private::Status
+  SetReturnValueObject(lldb::StackFrameSP &frame_sp,
+   lldb::ValueObjectSP &new_value) override;
+
+  lldb::ValueObjectSP
+  GetReturnValueObjectImpl(lldb_private::Thread &thread,
+   lldb_private::CompilerType &type) const override;
+
+  // Specialized to work with llvm IR types.
+  lldb::ValueObjectSP GetReturnValueObjectImpl(lldb_private::Thread &thread,
+   llvm::Type &type) const override;
+
+  bool
+  CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
+
+  bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
+
+  bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
+
+  bool CallFrameAddressIsValid(lldb::addr_t cfa) override {
+// The CFA must be 128 bit aligned, unless the E ABI is used
+lldb_private::ArchSpec arch = GetProcessSP()->GetTarget().GetArchitecture();
+lldb_private::Flags arch_flags = arch.GetFlags();
+if (arch_flags.Test(lldb_private::ArchSpec::eRISCV_rve))
+  return (cfa & 0x3ull) == 0;
+return (cfa & 0xfull) == 0;
+  }
+
+  void SetIsRV64(bool is_rv64) { m_is_rv64 = is_rv64; }
+
+  bool CodeAddressIsValid(lldb::addr_t pc) override {
+// Calls can use the least significant bit to store auxiliary information,
+// so no strict check is done for alignment.
+
+lldb_private::ArchSpec arch = GetProcessSP()->GetTarget().GetArchitecture();
+
+//  & 2 set is a fault if C extension is not used.
+lldb_private::Flags arch_flags(arch.GetFlags());
+if (!arch_flags.Test(lldb_private::Arch

[Lldb-commits] [lldb] [lldb] Add SetValueFromCString API to SyntheticFronend (PR #67309)

2023-09-25 Thread Alex Langford via lldb-commits

https://github.com/bulbazord requested changes to this pull request.

I echo Jim's sentiments here, not sure if this is the right way to go about it. 
Independent of that, I have one concern about the implementation and a few 
minor points.

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


[Lldb-commits] [lldb] [lldb] Add SetValueFromCString API to SyntheticFronend (PR #67309)

2023-09-25 Thread Alex Langford via lldb-commits


@@ -1535,7 +1535,12 @@ bool ValueObject::SetValueFromCString(const char 
*value_str, Status &error) {
 }
   } else {
 // We don't support setting things bigger than a scalar at present.
-error.SetErrorString("unable to write aggregate data type");
+// But maybe our frontend knows how to update the value.
+if (auto *frontend = GetSyntheticFrontend()) {
+  return frontend->SetValueFromCString(value_str, error);
+} else {
+  error.SetErrorString("unable to write aggregate data type");
+}

bulbazord wrote:

llvm style is to avoid braces for single line blocks in if/else/etc.

You can also drop the `else` since it comes after a return.

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


[Lldb-commits] [lldb] [lldb] Add SetValueFromCString API to SyntheticFronend (PR #67309)

2023-09-25 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add SetValueFromCString API to SyntheticFronend (PR #67309)

2023-09-25 Thread Alex Langford via lldb-commits


@@ -75,6 +77,10 @@ class SyntheticChildrenFrontEnd {
   // display purposes
   virtual ConstString GetSyntheticTypeName() { return ConstString(); }
 
+  virtual bool SetValueFromCString(const char *value_str, Status &error) {
+return false;
+  }
+

bulbazord wrote:

Where is this used? I assume you have code downstream that actually implements 
this?

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


[Lldb-commits] [lldb] [lldb] Add SetValueFromCString API to SyntheticFronend (PR #67309)

2023-09-25 Thread Alex Langford via lldb-commits


@@ -34,7 +34,9 @@ class SyntheticChildrenFrontEnd {
 
 public:
   SyntheticChildrenFrontEnd(ValueObject &backend)
-  : m_backend(backend), m_valid(true) {}
+  : m_backend(backend), m_valid(true) {
+backend.SetSyntheticFrontend(this);
+  }

bulbazord wrote:

Ignoring whether or not ValueObject should hold a pointer to a 
SyntheticFrontEnd, I'm concerned about the lifetime management of this 
solution. If a SyntheticChildrenFrontEnd is destroyed, the underlying 
`ValueObject` will be holding a dangling pointer.

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


[Lldb-commits] [lldb] [lldb] add command start (PR #67019)

2023-09-25 Thread José Lira Junior via lldb-commits

https://github.com/junior-jl updated 
https://github.com/llvm/llvm-project/pull/67019

From 11270775865a8415e00b4d899703f84717344967 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= 
Date: Thu, 21 Sep 2023 11:12:58 -0300
Subject: [PATCH 1/3] [lldb] add command start

---
 lldb/source/Commands/CMakeLists.txt   |   1 +
 lldb/source/Commands/CommandObjectStart.cpp   | 102 ++
 lldb/source/Commands/CommandObjectStart.h |  32 ++
 .../source/Interpreter/CommandInterpreter.cpp |   2 +
 4 files changed, 137 insertions(+)
 create mode 100644 lldb/source/Commands/CommandObjectStart.cpp
 create mode 100644 lldb/source/Commands/CommandObjectStart.h

diff --git a/lldb/source/Commands/CMakeLists.txt 
b/lldb/source/Commands/CMakeLists.txt
index 6a36c5376d5c574..54c62e0f5284beb 100644
--- a/lldb/source/Commands/CMakeLists.txt
+++ b/lldb/source/Commands/CMakeLists.txt
@@ -30,6 +30,7 @@ add_lldb_library(lldbCommands NO_PLUGIN_DEPENDENCIES
   CommandObjectSession.cpp
   CommandObjectSettings.cpp
   CommandObjectSource.cpp
+  CommandObjectStart.cpp
   CommandObjectStats.cpp
   CommandObjectTarget.cpp
   CommandObjectThread.cpp
diff --git a/lldb/source/Commands/CommandObjectStart.cpp 
b/lldb/source/Commands/CommandObjectStart.cpp
new file mode 100644
index 000..7406143c50fec1b
--- /dev/null
+++ b/lldb/source/Commands/CommandObjectStart.cpp
@@ -0,0 +1,102 @@
+//===-- CommandObjectStart.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 "CommandObjectStart.h"
+#include "lldb/Interpreter/CommandObject.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+// Constructor for CommandObjectStart
+CommandObjectStart::CommandObjectStart(CommandInterpreter &interpreter)
+: CommandObjectParsed(
+  interpreter, "start",
+  "Launches the process and pauses execution at main function",
+  "start args [optional args]") {
+  // Define command arguments
+  CommandArgumentData pause_location{eArgTypeName, eArgRepeatPlain};
+  m_arguments.push_back({pause_location});
+}
+
+CommandObjectStart::~CommandObjectStart() = default;
+
+// Execute the 'start' command
+bool CommandObjectStart::DoExecute(Args &command, CommandReturnObject &result) 
{
+  // Check if the 'first' subcommand is specified
+  bool pause_at_first_instruction = false;
+
+  if (command.GetArgumentCount() == 1 &&
+  strcmp(command.GetArgumentAtIndex(0), "first") == 0) {
+pause_at_first_instruction = true;
+  }
+
+  // Get the current selected target
+  TargetSP target_sp = GetDebugger().GetSelectedTarget();
+  if (!target_sp) {
+result.AppendError("No target selected.\n");
+return false;
+  }
+
+  // Create the breakpoint at main or the first instruction
+  BreakpointSP bp_sp;
+  if (pause_at_first_instruction) {
+ModuleSP exe_module_sp = target_sp->GetExecutableModule();
+ObjectFile *object = exe_module_sp->GetObjectFile();
+Address address = object->GetEntryPointAddress();
+
+if (!address.IsValid()) {
+  result.AppendError("Failed to get the entry point address");
+  result.SetStatus(eReturnStatusFailed);
+  return false;
+}
+
+bp_sp = target_sp->CreateBreakpoint(address, false, false);
+
+  } else {
+// Create a breakpoint at the main function
+bp_sp = target_sp->CreateBreakpoint(
+nullptr, nullptr, "main", eFunctionNameTypeAuto, eLanguageTypeUnknown,
+0, eLazyBoolNo, false, false);
+  }
+
+  if (!bp_sp) {
+result.AppendError("Breakpoint creation failed.\n");
+result.SetStatus(eReturnStatusFailed);
+return false;
+  } else {
+result.GetOutputStream().Printf("Breakpoint created%s.\n",
+pause_at_first_instruction
+? " at first instruction"
+: " in main function");
+result.SetStatus(eReturnStatusSuccessFinishResult);
+  }
+
+  // Construct the process launch info
+  ProcessLaunchInfo launch_info;
+  launch_info.SetShell(HostInfo::GetDefaultShell());
+  ModuleSP exe_module_sp = target_sp->GetExecutableModule();
+  if (!exe_module_sp) {
+result.AppendError("No executable module found.\n");
+return false;
+  }
+
+  launch_info.SetExecutableFile(exe_module_sp->GetPlatformFileSpec(), true);
+  // Launch the process
+  StreamString stream;
+  Status error = target_sp->Launch(launch_info, &stream);
+
+  if (error.Success()) {
+result.SetStatus(eReturnStatusSuccessFinishResult);
+result.GetOutputStream().Printf("Process launched successfully.\n");
+  } else {
+result.AppendErrorWithFormat("Process launch failed: %s\n",
+ error.AsC

[Lldb-commits] [lldb] [lldb] add command start (PR #67019)

2023-09-25 Thread José Lira Junior via lldb-commits

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


[Lldb-commits] [lldb] [lldb] add command start (PR #67019)

2023-09-25 Thread José Lira Junior via lldb-commits

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


[Lldb-commits] [lldb] [lldb] add command start (PR #67019)

2023-09-25 Thread José Lira Junior via lldb-commits

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


[Lldb-commits] [lldb] [lldb] add command start (PR #67019)

2023-09-25 Thread José Lira Junior via lldb-commits

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


[Lldb-commits] [lldb] [lldb] add command start (PR #67019)

2023-09-25 Thread José Lira Junior via lldb-commits

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


[Lldb-commits] [lldb] [lldb] add command start (PR #67019)

2023-09-25 Thread José Lira Junior via lldb-commits

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


[Lldb-commits] [lldb] [lldb] add command start (PR #67019)

2023-09-25 Thread José Lira Junior via lldb-commits

https://github.com/junior-jl updated 
https://github.com/llvm/llvm-project/pull/67019

From 11270775865a8415e00b4d899703f84717344967 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= 
Date: Thu, 21 Sep 2023 11:12:58 -0300
Subject: [PATCH 1/4] [lldb] add command start

---
 lldb/source/Commands/CMakeLists.txt   |   1 +
 lldb/source/Commands/CommandObjectStart.cpp   | 102 ++
 lldb/source/Commands/CommandObjectStart.h |  32 ++
 .../source/Interpreter/CommandInterpreter.cpp |   2 +
 4 files changed, 137 insertions(+)
 create mode 100644 lldb/source/Commands/CommandObjectStart.cpp
 create mode 100644 lldb/source/Commands/CommandObjectStart.h

diff --git a/lldb/source/Commands/CMakeLists.txt 
b/lldb/source/Commands/CMakeLists.txt
index 6a36c5376d5c574..54c62e0f5284beb 100644
--- a/lldb/source/Commands/CMakeLists.txt
+++ b/lldb/source/Commands/CMakeLists.txt
@@ -30,6 +30,7 @@ add_lldb_library(lldbCommands NO_PLUGIN_DEPENDENCIES
   CommandObjectSession.cpp
   CommandObjectSettings.cpp
   CommandObjectSource.cpp
+  CommandObjectStart.cpp
   CommandObjectStats.cpp
   CommandObjectTarget.cpp
   CommandObjectThread.cpp
diff --git a/lldb/source/Commands/CommandObjectStart.cpp 
b/lldb/source/Commands/CommandObjectStart.cpp
new file mode 100644
index 000..7406143c50fec1b
--- /dev/null
+++ b/lldb/source/Commands/CommandObjectStart.cpp
@@ -0,0 +1,102 @@
+//===-- CommandObjectStart.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 "CommandObjectStart.h"
+#include "lldb/Interpreter/CommandObject.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+// Constructor for CommandObjectStart
+CommandObjectStart::CommandObjectStart(CommandInterpreter &interpreter)
+: CommandObjectParsed(
+  interpreter, "start",
+  "Launches the process and pauses execution at main function",
+  "start args [optional args]") {
+  // Define command arguments
+  CommandArgumentData pause_location{eArgTypeName, eArgRepeatPlain};
+  m_arguments.push_back({pause_location});
+}
+
+CommandObjectStart::~CommandObjectStart() = default;
+
+// Execute the 'start' command
+bool CommandObjectStart::DoExecute(Args &command, CommandReturnObject &result) 
{
+  // Check if the 'first' subcommand is specified
+  bool pause_at_first_instruction = false;
+
+  if (command.GetArgumentCount() == 1 &&
+  strcmp(command.GetArgumentAtIndex(0), "first") == 0) {
+pause_at_first_instruction = true;
+  }
+
+  // Get the current selected target
+  TargetSP target_sp = GetDebugger().GetSelectedTarget();
+  if (!target_sp) {
+result.AppendError("No target selected.\n");
+return false;
+  }
+
+  // Create the breakpoint at main or the first instruction
+  BreakpointSP bp_sp;
+  if (pause_at_first_instruction) {
+ModuleSP exe_module_sp = target_sp->GetExecutableModule();
+ObjectFile *object = exe_module_sp->GetObjectFile();
+Address address = object->GetEntryPointAddress();
+
+if (!address.IsValid()) {
+  result.AppendError("Failed to get the entry point address");
+  result.SetStatus(eReturnStatusFailed);
+  return false;
+}
+
+bp_sp = target_sp->CreateBreakpoint(address, false, false);
+
+  } else {
+// Create a breakpoint at the main function
+bp_sp = target_sp->CreateBreakpoint(
+nullptr, nullptr, "main", eFunctionNameTypeAuto, eLanguageTypeUnknown,
+0, eLazyBoolNo, false, false);
+  }
+
+  if (!bp_sp) {
+result.AppendError("Breakpoint creation failed.\n");
+result.SetStatus(eReturnStatusFailed);
+return false;
+  } else {
+result.GetOutputStream().Printf("Breakpoint created%s.\n",
+pause_at_first_instruction
+? " at first instruction"
+: " in main function");
+result.SetStatus(eReturnStatusSuccessFinishResult);
+  }
+
+  // Construct the process launch info
+  ProcessLaunchInfo launch_info;
+  launch_info.SetShell(HostInfo::GetDefaultShell());
+  ModuleSP exe_module_sp = target_sp->GetExecutableModule();
+  if (!exe_module_sp) {
+result.AppendError("No executable module found.\n");
+return false;
+  }
+
+  launch_info.SetExecutableFile(exe_module_sp->GetPlatformFileSpec(), true);
+  // Launch the process
+  StreamString stream;
+  Status error = target_sp->Launch(launch_info, &stream);
+
+  if (error.Success()) {
+result.SetStatus(eReturnStatusSuccessFinishResult);
+result.GetOutputStream().Printf("Process launched successfully.\n");
+  } else {
+result.AppendErrorWithFormat("Process launch failed: %s\n",
+ error.AsC

[Lldb-commits] [lldb] [lldb] add command start (PR #67019)

2023-09-25 Thread José Lira Junior via lldb-commits


@@ -38,7 +38,18 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
   case 's': // Stop at program entry point
 launch_info.GetFlags().Set(eLaunchFlagStopAtEntry);
 break;
-
+  case 'm': // Stop at main function
+  {
+TargetSP target_sp =
+execution_context ? execution_context->GetTargetSP() : TargetSP();
+BreakpointSP bp_sp = target_sp->CreateBreakpoint(
+nullptr, nullptr, "main", eFunctionNameTypeAuto, eLanguageTypeUnknown,

junior-jl wrote:

I resolved the other points, this is the only part missing. Should I use 
`eFunctionNameTypeBase`?

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


[Lldb-commits] [lldb] [lldb] add command start (PR #67019)

2023-09-25 Thread José Lira Junior via lldb-commits

junior-jl wrote:

Thank you @bulbazord & @clayborg for the step-by-step, it was really helpful. I 
reverted the first commit, removed the shell modification you mentioned and the 
created breakpoint is now one-shot, @jimingham.

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


[Lldb-commits] [lldb] [lldb] add stop-at-main option to process launch (PR #67019)

2023-09-25 Thread José Lira Junior via lldb-commits

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


[Lldb-commits] [lldb] [lldb] add stop-at-main option to process launch (PR #67019)

2023-09-25 Thread Greg Clayton via lldb-commits
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -675,6 +675,8 @@ let Command = "platform shell" in {
 let Command = "process launch" in {
   def process_launch_stop_at_entry : Option<"stop-at-entry", "s">,
 Desc<"Stop at the entry point of the program when launching a process.">;
+  def process_launch_stop_at_main : Option<"stop-at-main", "m">,
+Desc<"Stop at the main function of the program when launching a process.">;

clayborg wrote:

If we are going to add platform support, we might want to rename this to be 
"stop-at-user-entry" or some other thing since some platforms might not support 
a "main" function.

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


[Lldb-commits] [lldb] [lldb] add stop-at-main option to process launch (PR #67019)

2023-09-25 Thread Greg Clayton via lldb-commits
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 


https://github.com/clayborg commented:

See my inline comments. I am wondering if we want to get the platform involved 
here so they can do the right thing for any platform and it might involve 
renaming the option away from containing "main" since that might not be the 
user entry point into a program for all platforms. 

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


[Lldb-commits] [lldb] [lldb] add stop-at-main option to process launch (PR #67019)

2023-09-25 Thread Greg Clayton via lldb-commits
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -38,7 +38,18 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
   case 's': // Stop at program entry point
 launch_info.GetFlags().Set(eLaunchFlagStopAtEntry);
 break;
-
+  case 'm': // Stop at main function
+  {
+TargetSP target_sp =
+execution_context ? execution_context->GetTargetSP() : TargetSP();
+BreakpointSP bp_sp = target_sp->CreateBreakpoint(
+nullptr, nullptr, "main", eFunctionNameTypeAuto, eLanguageTypeUnknown,
+0, eLazyBoolNo, false, false);

clayborg wrote:

It is useful to put c style comment with variable names in it, so instead of 
the above line, you would have:
```
/*offset=*/0, /*skip_prologue=*/eLazyBoolNo, /*internal=*/false, 
/*request_hardware=*/false);

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


[Lldb-commits] [lldb] [lldb] add stop-at-main option to process launch (PR #67019)

2023-09-25 Thread Greg Clayton via lldb-commits
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 


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


[Lldb-commits] [lldb] [lldb] add stop-at-main option to process launch (PR #67019)

2023-09-25 Thread Greg Clayton via lldb-commits
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -38,7 +38,18 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
   case 's': // Stop at program entry point
 launch_info.GetFlags().Set(eLaunchFlagStopAtEntry);
 break;
-
+  case 'm': // Stop at main function
+  {
+TargetSP target_sp =
+execution_context ? execution_context->GetTargetSP() : TargetSP();
+BreakpointSP bp_sp = target_sp->CreateBreakpoint(
+nullptr, nullptr, "main", eFunctionNameTypeAuto, eLanguageTypeUnknown,

clayborg wrote:

The other options would be to ask the Platform.h layer to do this. We have 
platforms classes that abstract things different platforms. Example include 
PlatformLinux, PlatformDarwin (for macOS, watchOS, tvOS, and iOS), 
PlatformAndroid, etc. We could add a default implementation into the 
Platform.h/Platform.cpp file that would set a breakpoint at main. The idea 
would be we would add a virtual function to Platform.h like:
```
class Platform {
  /// Create a beakpoint at the user level starting function for a program.
  virtual BreakpointSP CreateStartBreakpoint(lldb_private::Target &target);
...
```
Then this could can grab the platform from the target and call this:
```
BreakpointSP bp_sp  = target->GetPlatform()->CreateStartBreakpoint();
```
That way new platforms can do the right thing and customize this. The default 
implementation in the Platform.cpp can just do what you did above:
```
BreakpointSP Platform::CreateStartBreakpoint(lldb_private::Target &target) {
  return target_sp->CreateBreakpoint(
nullptr, nullptr, "main", eFunctionNameTypeAuto, eLanguageTypeUnknown,
0, eLazyBoolNo, false, false);
```
and we could override this for Darwin (base class for all Apple platforms) to 
use the use my previously suggested code:
```
BreakpointSP PlatformDarwin::CreateStartBreakpoint(lldb_private::Target 
&target) {
  // On Darwin systems the object file's entry point address is the user 
function entry
  // point like "main". Using this kind of breakpoint is more efficient than 
looking up a
  // function by name as this avoids parsing the debug info or symbol tables.
  ModuleSP exe_module_sp = target.GetExecutableModule();
  lldb_private::Address entry_addr;
  if (exe_module_sp ) {
ObjectFile *objfile = exe_module_sp ->GetObjectFile();
if (objfile)
entry_addr = objfile->GetEntryPointAddress();
  }
  if (entry_addr.IsValid())
return target.CreateBreakpoint(entry_addr, /*internal=*/false, 
/*hardware=*/false);
  return BreakpointSP();
}
```

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


[Lldb-commits] [lldb] [lldb] add stop-at-main option to process launch (PR #67019)

2023-09-25 Thread Greg Clayton via lldb-commits
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -38,7 +38,18 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
   case 's': // Stop at program entry point
 launch_info.GetFlags().Set(eLaunchFlagStopAtEntry);
 break;
-
+  case 'm': // Stop at main function
+  {
+TargetSP target_sp =
+execution_context ? execution_context->GetTargetSP() : TargetSP();
+BreakpointSP bp_sp = target_sp->CreateBreakpoint(
+nullptr, nullptr, "main", eFunctionNameTypeAuto, eLanguageTypeUnknown,

clayborg wrote:

yes eFunctionNameTypeBase is the right thing. "main" with auto will match many 
extra things we don't want like:
- "Foo::main(...)"
- "-[ObjectiveClass main]" (objectiive C class method)
- "+[ObjectiveClass main]" (objective C static function)

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


[Lldb-commits] [lldb] [lldb-vscode] Display a more descriptive summary for containers and pointers (PR #65514)

2023-09-25 Thread David Blaikie via lldb-commits


@@ -132,6 +132,84 @@ std::vector GetStrings(const 
llvm::json::Object *obj,
   return strs;
 }
 
+/// Create a short summary for a container that contains the summary of its
+/// first children, so that the user can get a glimpse of its contents at a
+/// glance.
+static std::optional
+GetSyntheticSummaryForContainer(lldb::SBValue &v) {
+  if (v.TypeIsPointerType() || !v.MightHaveChildren())
+return std::nullopt;
+  /// As this operation can be potentially slow, we limit the total time spent
+  /// fetching children to a few ms.
+  const auto max_evaluation_time = std::chrono::milliseconds(10);
+  /// We don't want to generate a extremely long summary string, so we limit 
its
+  /// length.
+  const size_t max_length = 32;
+
+  auto start = std::chrono::steady_clock::now();
+  std::string summary;
+  llvm::raw_string_ostream os(summary);
+  os << "{";
+
+  llvm::StringRef separator = "";
+
+  for (size_t i = 0, e = v.GetNumChildren(); i < e; ++i) {

dwblaikie wrote:

I'm not sure I understand. `v.GetNumChildren()` wouldn't need to do any more 
work for a case with "10 class pointer variables", right? You can determine how 
many children this type has (10) without completing the types those pointers 
point to?

Or is it later code (like line 168, etc) that try to get the summary of those 
pointer member variables that are an issue? (though getting the summary of a 
pointer shouldn't automatically dereference the pointer/complete its pointed-to 
type, should it?)

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


[Lldb-commits] [lldb] [lldb] [debugserver] Preserve signing bits on lr in debugserver (PR #67384)

2023-09-25 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda created 
https://github.com/llvm/llvm-project/pull/67384

In https://reviews.llvm.org/D136620 I changed debugserver to stop using the 
kernel-provided functions
arm_thread_state64_get_{pc,lr,sp,fp} to postprocess those four registers on 
aarch64 systems after we thread_get_state() them. The kernel stores these four 
registers with signing internally, either from the inferior process' actual 
signing, or its own.

When a program had crashed by doing an authenticated BL to an address with 
improper signing, the inferior process would crash and that improperly signed 
pc would be given to debugserver via thread_get_state. debugserver would run 
that through arm_thread_state64_get_pc() and then debugserver would crash when 
authenticating & stripping the value, on newer Mac hardware.

To avoid debugserver crashing on a crashed inferior process, I switched from 
using these system functions to strip the values, to simply clearing the bits 
outright in debugserver.

However, lr is a special case where the inferior may have signed this value 
(against the stack pointer value at the time).  Or it may not yet have any 
authentication bits, right after a BL.  In the latter case, the kernel will add 
its own auth bits for while it is stored inside the kernel.  In the case of a 
user lr value, we cannot authenticate it in debugserver without knowing the sp 
value it was signed against (and the way it is signed is not specified by the 
ABI) so an "improperly" signed lr (whatever that means) won't cause debugserver 
to crash.

debugserver can thread_get_state the inferior's lr, run it through 
arm_thread_state64_get_lr(), and get the actual signed 64-bit value that the 
inferior process is using.  And the specifics of how that lr is signed may be 
important for debugging the process, instead of how I am currently clearing the 
auth bits outright.

This patch reverts that change for lr only, and also adds a new logging to 
debugserver specifically for the four sp/fp/lr/pc values that thread_get_state 
hands to us, before we process them at all.

>From 5e588f4163c5d6790ac6b8836558aa3a5bf1ccfc Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Mon, 25 Sep 2023 16:01:22 -0700
Subject: [PATCH] [lldb] [debugserver] Preserve signing bits on lr in
 debugserver

In https://reviews.llvm.org/D136620 I changed debugserver to
stop using the kernel-provided functions
arm_thread_state64_get_{pc,lr,sp,fp} to postprocess those four
registers on aarch64 systems after we thread_get_state() them.
The kernel stores these four registers with signing internally,
either from the inferior process' actual signing, or its own.

When a program had crashed by doing an authenticated BL to an address
with improper signing, the inferior process would crash and that
improperly signed pc would be given to debugserver via thread_get_state.
debugserver would run that through arm_thread_state64_get_pc() and
then debugserver would crash when authenticating & stripping the
value, on newer Mac hardware.

To avoid debugserver crashing on a crashed inferior process, I
switched from using these system functions to strip the values, to
simply clearing the bits outright in debugserver.

However, lr is a special case where the inferior may have signed
this value (against the stack pointer value at the time).  Or it
may not yet have any authentication bits, right after a BL.  In the
latter case, the kernel will add its own auth bits for while it is
stored inside the kernel.  In the case of a user lr value, we cannot
authenticate it in debugserver without knowing the sp value it was
signed against (and the way it is signed is not specified by the
ABI) so an "improperly" signed lr (whatever that means) won't cause
debugserver to crash.

debugserver can thread_get_state the inferior's lr, run it through
arm_thread_state64_get_lr(), and get the actual signed 64-bit value
that the inferior process is using.  And the specifics of how that
lr is signed may be important for debugging the process, instead of
how I am currently clearing the auth bits outright.

This patch reverts that change for lr only, and also adds a new
logging to debugserver specifically for the four sp/fp/lr/pc values
that thread_get_state hands to us, before we process them at all.
---
 .../source/MacOSX/arm64/DNBArchImplARM64.cpp  | 20 +--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp 
b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
index bdecae81d31a71a..e02ef6353640a44 100644
--- a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
@@ -169,6 +169,23 @@ kern_return_t DNBArchMachARM64::GetGPRState(bool force) {
  (thread_state_t)&m_state.context.gpr, &count);
   if (DNBLogEnabledForAny(LOG_THREAD)) {
 uint64_t *x = &m_state.context.gpr.__x[0];
+

[Lldb-commits] [lldb] [lldb] [debugserver] Preserve signing bits on lr in debugserver (PR #67384)

2023-09-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb


Changes

In https://reviews.llvm.org/D136620 I changed debugserver to stop using the 
kernel-provided functions
arm_thread_state64_get_{pc,lr,sp,fp} to postprocess those four registers on 
aarch64 systems after we thread_get_state() them. The kernel stores these four 
registers with signing internally, either from the inferior process' actual 
signing, or its own.

When a program had crashed by doing an authenticated BL to an address with 
improper signing, the inferior process would crash and that improperly signed 
pc would be given to debugserver via thread_get_state. debugserver would run 
that through arm_thread_state64_get_pc() and then debugserver would crash when 
authenticating & stripping the value, on newer Mac hardware.

To avoid debugserver crashing on a crashed inferior process, I switched from 
using these system functions to strip the values, to simply clearing the bits 
outright in debugserver.

However, lr is a special case where the inferior may have signed this value 
(against the stack pointer value at the time).  Or it may not yet have any 
authentication bits, right after a BL.  In the latter case, the kernel will add 
its own auth bits for while it is stored inside the kernel.  In the case of a 
user lr value, we cannot authenticate it in debugserver without knowing the sp 
value it was signed against (and the way it is signed is not specified by the 
ABI) so an "improperly" signed lr (whatever that means) won't cause debugserver 
to crash.

debugserver can thread_get_state the inferior's lr, run it through 
arm_thread_state64_get_lr(), and get the actual signed 64-bit value that the 
inferior process is using.  And the specifics of how that lr is signed may be 
important for debugging the process, instead of how I am currently clearing the 
auth bits outright.

This patch reverts that change for lr only, and also adds a new logging to 
debugserver specifically for the four sp/fp/lr/pc values that thread_get_state 
hands to us, before we process them at all.

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


1 Files Affected:

- (modified) lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp 
(+18-2) 


``diff
diff --git a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp 
b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
index bdecae81d31a71a..e02ef6353640a44 100644
--- a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
@@ -169,6 +169,23 @@ kern_return_t DNBArchMachARM64::GetGPRState(bool force) {
  (thread_state_t)&m_state.context.gpr, &count);
   if (DNBLogEnabledForAny(LOG_THREAD)) {
 uint64_t *x = &m_state.context.gpr.__x[0];
+DNBLogThreaded("thread_get_state signed regs "
+   "\n   fp=%16.16llx"
+   "\n   lr=%16.16llx"
+   "\n   sp=%16.16llx"
+   "\n   pc=%16.16llx",
+#if __has_feature(ptrauth_calls) && defined(__LP64__)
+   reinterpret_cast(m_state.context.gpr.__opaque_fp),
+   reinterpret_cast(m_state.context.gpr.__opaque_lr),
+   reinterpret_cast(m_state.context.gpr.__opaque_sp),
+   reinterpret_cast(m_state.context.gpr.__opaque_pc)
+#else
+   m_state.context.gpr.__fp,
+   m_state.context.gpr.__lr, 
+   m_state.context.gpr.__sp,
+   m_state.context.gpr.__pc
+#endif
+);
 
 #if __has_feature(ptrauth_calls) && defined(__LP64__)
 uint64_t log_fp = clear_pac_bits(
@@ -2173,8 +2190,7 @@ bool DNBArchMachARM64::GetRegisterValue(uint32_t set, 
uint32_t reg,
   reinterpret_cast(m_state.context.gpr.__opaque_pc));
   break;
 case gpr_lr:
-  value->value.uint64 = clear_pac_bits(
-  reinterpret_cast(m_state.context.gpr.__opaque_lr));
+  value->value.uint64 = arm_thread_state64_get_lr(m_state.context.gpr);
   break;
 case gpr_sp:
   value->value.uint64 = clear_pac_bits(

``




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


[Lldb-commits] [lldb] [lldb] [debugserver] Preserve signing bits on lr in debugserver (PR #67384)

2023-09-25 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] [debugserver] Preserve signing bits on lr in debugserver (PR #67384)

2023-09-25 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff feb7b1914d513c709b9e024dfed709bb889cc853 
5e588f4163c5d6790ac6b8836558aa3a5bf1ccfc -- 
lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp 
b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
index e02ef6353640..e3bd91e8d446 100644
--- a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
@@ -180,10 +180,8 @@ kern_return_t DNBArchMachARM64::GetGPRState(bool force) {
reinterpret_cast(m_state.context.gpr.__opaque_sp),
reinterpret_cast(m_state.context.gpr.__opaque_pc)
 #else
-   m_state.context.gpr.__fp,
-   m_state.context.gpr.__lr, 
-   m_state.context.gpr.__sp,
-   m_state.context.gpr.__pc
+   m_state.context.gpr.__fp, m_state.context.gpr.__lr,
+   m_state.context.gpr.__sp, m_state.context.gpr.__pc
 #endif
 );
 

``




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


[Lldb-commits] [lldb] [lldb] [debugserver] Preserve signing bits on lr in debugserver (PR #67384)

2023-09-25 Thread Jason Molenda via lldb-commits

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


[Lldb-commits] [lldb] b7961f2 - [lldb] [debugserver] Preserve signing bits on lr in debugserver (#67384)

2023-09-25 Thread via lldb-commits

Author: Jason Molenda
Date: 2023-09-25T17:02:25-07:00
New Revision: b7961f2cb97556bfc50f7828d5f869d96ab9352e

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

LOG: [lldb] [debugserver] Preserve signing bits on lr in debugserver (#67384)

In https://reviews.llvm.org/D136620 I changed debugserver to stop using
the kernel-provided functions
arm_thread_state64_get_{pc,lr,sp,fp} to postprocess those four registers
on aarch64 systems after we thread_get_state() them. The kernel stores
these four registers with signing internally, either from the inferior
process' actual signing, or its own.

When a program had crashed by doing an authenticated BL to an address
with improper signing, the inferior process would crash and that
improperly signed pc would be given to debugserver via thread_get_state.
debugserver would run that through arm_thread_state64_get_pc() and then
debugserver would crash when authenticating & stripping the value, on
newer Mac hardware.

To avoid debugserver crashing on a crashed inferior process, I switched
from using these system functions to strip the values, to simply
clearing the bits outright in debugserver.

However, lr is a special case where the inferior may have signed this
value (against the stack pointer value at the time). Or it may not yet
have any authentication bits, right after a BL. In the latter case, the
kernel will add its own auth bits for while it is stored inside the
kernel. In the case of a user lr value, we cannot authenticate it in
debugserver without knowing the sp value it was signed against (and the
way it is signed is not specified by the ABI) so an "improperly" signed
lr (whatever that means) won't cause debugserver to crash.

debugserver can thread_get_state the inferior's lr, run it through
arm_thread_state64_get_lr(), and get the actual signed 64-bit value that
the inferior process is using. And the specifics of how that lr is
signed may be important for debugging the process, instead of how I am
currently clearing the auth bits outright.

This patch reverts that change for lr only, and also adds a new logging
to debugserver specifically for the four sp/fp/lr/pc values that
thread_get_state hands to us, before we process them at all.

Added: 


Modified: 
lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp

Removed: 




diff  --git a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp 
b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
index bdecae81d31a71a..e02ef6353640a44 100644
--- a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
@@ -169,6 +169,23 @@ kern_return_t DNBArchMachARM64::GetGPRState(bool force) {
  (thread_state_t)&m_state.context.gpr, &count);
   if (DNBLogEnabledForAny(LOG_THREAD)) {
 uint64_t *x = &m_state.context.gpr.__x[0];
+DNBLogThreaded("thread_get_state signed regs "
+   "\n   fp=%16.16llx"
+   "\n   lr=%16.16llx"
+   "\n   sp=%16.16llx"
+   "\n   pc=%16.16llx",
+#if __has_feature(ptrauth_calls) && defined(__LP64__)
+   reinterpret_cast(m_state.context.gpr.__opaque_fp),
+   reinterpret_cast(m_state.context.gpr.__opaque_lr),
+   reinterpret_cast(m_state.context.gpr.__opaque_sp),
+   reinterpret_cast(m_state.context.gpr.__opaque_pc)
+#else
+   m_state.context.gpr.__fp,
+   m_state.context.gpr.__lr, 
+   m_state.context.gpr.__sp,
+   m_state.context.gpr.__pc
+#endif
+);
 
 #if __has_feature(ptrauth_calls) && defined(__LP64__)
 uint64_t log_fp = clear_pac_bits(
@@ -2173,8 +2190,7 @@ bool DNBArchMachARM64::GetRegisterValue(uint32_t set, 
uint32_t reg,
   reinterpret_cast(m_state.context.gpr.__opaque_pc));
   break;
 case gpr_lr:
-  value->value.uint64 = clear_pac_bits(
-  reinterpret_cast(m_state.context.gpr.__opaque_lr));
+  value->value.uint64 = arm_thread_state64_get_lr(m_state.context.gpr);
   break;
 case gpr_sp:
   value->value.uint64 = clear_pac_bits(



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


[Lldb-commits] [lldb] [lldb-vscode] Display a more descriptive summary for containers and pointers (PR #65514)

2023-09-25 Thread Greg Clayton via lldb-commits


@@ -132,6 +132,84 @@ std::vector GetStrings(const 
llvm::json::Object *obj,
   return strs;
 }
 
+/// Create a short summary for a container that contains the summary of its
+/// first children, so that the user can get a glimpse of its contents at a
+/// glance.
+static std::optional
+GetSyntheticSummaryForContainer(lldb::SBValue &v) {
+  if (v.TypeIsPointerType() || !v.MightHaveChildren())
+return std::nullopt;
+  /// As this operation can be potentially slow, we limit the total time spent
+  /// fetching children to a few ms.
+  const auto max_evaluation_time = std::chrono::milliseconds(10);
+  /// We don't want to generate a extremely long summary string, so we limit 
its
+  /// length.
+  const size_t max_length = 32;
+
+  auto start = std::chrono::steady_clock::now();
+  std::string summary;
+  llvm::raw_string_ostream os(summary);
+  os << "{";
+
+  llvm::StringRef separator = "";
+
+  for (size_t i = 0, e = v.GetNumChildren(); i < e; ++i) {

clayborg wrote:

> I'm not sure I understand. `v.GetNumChildren()` wouldn't need to do any more 
> work for a case with "10 class pointer variables", right? 

correct. that is a problem. This API is asking any variable how many children 
it has. So if we have a CompilerType in LLDB that represents a class, it starts 
off as a forward declaration and it can complete itself through the external 
AST support in clang. As soon as we call GetNumChildren, we need to complete 
the type as some of the children of a type might come from base classes, but 
only if they have fields or other base classes that contain fields. Empty base 
classes do not show up in the variable view. And then we need to count the 
number of fields that the class actaully has as well so we can show them as 
children, so as soon as we call "v.GetNumChildren()" we must complete the type.

> You can determine how many children this type has (10) without completing the 
> types those pointers point to?

Correct yes, that is what I meant by "layout type". LLDB has the ability to say 
"get me a version of this type that is needed to layout this current class". So 
if a class has 10 ivars that are all pointers, we don't need to complete those 
classes. If we have 10 ivars that are class instances, then we do need to 
complete the type since we assist in the clang AST context in laying out the 
type with the help of the DWARF info. This is needed because of 
"-flimit-debug-info". If we have class A that inherits from class B, and there 
is no class B definition in the DWARF, then we have to have the DWARF help us 
laying out the type. What we do is start and end a definition for class B and 
we attach. metadata saying "this class should have been complete but wasn't", 
and the layout support that clang has allows us to specify the offsets of all 
fields and base classes so we can always show the variable correctly to people. 
The layout stuff is needed because DWARF doesn't encode many things, one being 
the current pragma pack settings and other things that can affect the layout of 
the type.

> Or is it later code (like line 168, etc) that try to get the summary of those 
> pointer member variables that are an issue? (though getting the summary of a 
> pointer shouldn't automatically dereference the pointer/complete its 
> pointed-to type, should it?)

Any summary code that needs to access children to make up the summary string 
can be expensive and cause the type to need to be completed due to above 
explanation. If we have a "Foo *", the value of the variable will show as the 
pointer value, but if the type that is being pointed to has a summary, we do 
end up showing that for pointers and for references. This is because users 
expect it from the GDB days and due to the way we expand variables. If we have 
a "Point *" and we expand it in a GUI, we don't expect it to expand to a 
"Point" and then for it to need to be expanded yet again to see the "x" and "y" 
values, we expect to directly see the "x" and "y" right away. If the pointee is 
a simple type, like an "int *", we exand and show the "int", but if we have a 
class pointer, then we immediately show the children of the class. Many users 
complained when we initially did it where a "Point *" would expand to a "Point" 
object, so we changed lldb.




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


[Lldb-commits] [lldb] [lldb] add stop-at-main option to process launch (PR #67019)

2023-09-25 Thread via lldb-commits
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -38,7 +38,18 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
   case 's': // Stop at program entry point
 launch_info.GetFlags().Set(eLaunchFlagStopAtEntry);
 break;
-
+  case 'm': // Stop at main function
+  {
+TargetSP target_sp =
+execution_context ? execution_context->GetTargetSP() : TargetSP();
+BreakpointSP bp_sp = target_sp->CreateBreakpoint(
+nullptr, nullptr, "main", eFunctionNameTypeAuto, eLanguageTypeUnknown,
+0, eLazyBoolNo, false, false);

jimingham wrote:

Don't you want eFunctionNameTypeFull?  You wouldn't want to break on 
SomeCPlusPlusClass::main, which eFunctionNameTypeBase will break on.

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


[Lldb-commits] [lldb] [lldb] add stop-at-main option to process launch (PR #67019)

2023-09-25 Thread via lldb-commits
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -38,7 +38,18 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
   case 's': // Stop at program entry point
 launch_info.GetFlags().Set(eLaunchFlagStopAtEntry);
 break;
-
+  case 'm': // Stop at main function
+  {
+TargetSP target_sp =
+execution_context ? execution_context->GetTargetSP() : TargetSP();
+BreakpointSP bp_sp = target_sp->CreateBreakpoint(
+nullptr, nullptr, "main", eFunctionNameTypeAuto, eLanguageTypeUnknown,

jimingham wrote:

IIUC, we're not trying to break at the actual entry point (that's what 
-stop-at-entry-point does) but the main executable's Language entry point.  I'm 
not sure that is something the platform can know.   For all the C-based 
languages it was "main", but for some other languages it might be something 
else.  For Ada apparently it can be anything and you designate it "main" some 
other way.  In other languages it could just have a different name than 
"main"...

If that's true, shouldn't we be asking all the Languages we support what their 
"main" function is, not the Platforms.  I'm not sure they can know.  And for 
situations like the Ada one the language would have to be able to figure out 
what the main function was by some Ada specific means.



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


[Lldb-commits] [lldb] [lldb] add stop-at-main option to process launch (PR #67019)

2023-09-25 Thread Greg Clayton via lldb-commits
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -38,7 +38,18 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
   case 's': // Stop at program entry point
 launch_info.GetFlags().Set(eLaunchFlagStopAtEntry);
 break;
-
+  case 'm': // Stop at main function
+  {
+TargetSP target_sp =
+execution_context ? execution_context->GetTargetSP() : TargetSP();
+BreakpointSP bp_sp = target_sp->CreateBreakpoint(
+nullptr, nullptr, "main", eFunctionNameTypeAuto, eLanguageTypeUnknown,
+0, eLazyBoolNo, false, false);

clayborg wrote:

Yes, you are correct, eFunctionNameTypeFull is the right choice. 

Jim what do you think about getting the platform involved in setting this 
breakpoint as I described? Is that overkill? I am good with either approach.

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


[Lldb-commits] [lldb] [lldb] add stop-at-main option to process launch (PR #67019)

2023-09-25 Thread via lldb-commits
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -38,7 +38,18 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
   case 's': // Stop at program entry point
 launch_info.GetFlags().Set(eLaunchFlagStopAtEntry);
 break;
-
+  case 'm': // Stop at main function
+  {
+TargetSP target_sp =
+execution_context ? execution_context->GetTargetSP() : TargetSP();
+BreakpointSP bp_sp = target_sp->CreateBreakpoint(
+nullptr, nullptr, "main", eFunctionNameTypeAuto, eLanguageTypeUnknown,

jimingham wrote:

In the simplest case, we gather a set of names one or more from each Language, 
and then make one multiple name breakpoint for all of them.

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


[Lldb-commits] [lldb] [lldb] add stop-at-main option to process launch (PR #67019)

2023-09-25 Thread via lldb-commits
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -675,6 +675,8 @@ let Command = "platform shell" in {
 let Command = "process launch" in {
   def process_launch_stop_at_entry : Option<"stop-at-entry", "s">,
 Desc<"Stop at the entry point of the program when launching a process.">;
+  def process_launch_stop_at_main : Option<"stop-at-main", "m">,
+Desc<"Stop at the main function of the program when launching a process.">;

jimingham wrote:

Yes, that better expresses what this does.

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


[Lldb-commits] [lldb] [lldb] add stop-at-main option to process launch (PR #67019)

2023-09-25 Thread Greg Clayton via lldb-commits
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -38,7 +38,18 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
   case 's': // Stop at program entry point
 launch_info.GetFlags().Set(eLaunchFlagStopAtEntry);
 break;
-
+  case 'm': // Stop at main function
+  {
+TargetSP target_sp =
+execution_context ? execution_context->GetTargetSP() : TargetSP();
+BreakpointSP bp_sp = target_sp->CreateBreakpoint(
+nullptr, nullptr, "main", eFunctionNameTypeAuto, eLanguageTypeUnknown,

clayborg wrote:

Yeah, there is no way to know what language the main entrypoint was written in, 
so no hope of figuring out the language. I would be fine with the multiple 
names approach from all languages. If you want that feature, can you give Jose 
some clues what he should do to make that happen?

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


[Lldb-commits] [lldb] [lldb] add stop-at-main option to process launch (PR #67019)

2023-09-25 Thread via lldb-commits
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -38,7 +38,18 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
   case 's': // Stop at program entry point
 launch_info.GetFlags().Set(eLaunchFlagStopAtEntry);
 break;
-
+  case 'm': // Stop at main function
+  {
+TargetSP target_sp =
+execution_context ? execution_context->GetTargetSP() : TargetSP();
+BreakpointSP bp_sp = target_sp->CreateBreakpoint(
+nullptr, nullptr, "main", eFunctionNameTypeAuto, eLanguageTypeUnknown,
+0, eLazyBoolNo, false, false);

jimingham wrote:

I think abstracting out each Language's entry point function name is the only 
really strong argument for adding this option, so I think we should do that.  
But as I said below, I think that's something our supported Language plugins 
would know, I don't think the Platform knows this.

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


[Lldb-commits] [lldb] [lldb] add stop-at-main option to process launch (PR #67019)

2023-09-25 Thread Greg Clayton via lldb-commits
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 


https://github.com/clayborg commented:

After Jim's recent comments sounds like the Platform is not the right place to 
set the breakpoint. So please ignore my comments suggesting to use the Platform 
layer.

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


[Lldb-commits] [lldb] [lldb] add stop-at-main option to process launch (PR #67019)

2023-09-25 Thread via lldb-commits
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -38,7 +38,18 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
   case 's': // Stop at program entry point
 launch_info.GetFlags().Set(eLaunchFlagStopAtEntry);
 break;
-
+  case 'm': // Stop at main function
+  {
+TargetSP target_sp =
+execution_context ? execution_context->GetTargetSP() : TargetSP();
+BreakpointSP bp_sp = target_sp->CreateBreakpoint(
+nullptr, nullptr, "main", eFunctionNameTypeAuto, eLanguageTypeUnknown,

jimingham wrote:

We have a list of "Supported Languages" (Language::GetSupportedLangauges) which 
are the ones we actually have plugins for as opposed to the ones whose names we 
know.  That's the list you should be querying. 

We should add a new API to the Language plugin: 
Language::GetUserEntrypointName() and then this code should iterate over all 
the supported languages building up a unique list of entry point names using 
this API.  At present there's going to be one: "main" repeated many times but I 
think Walter promised us another one soon...  

If you find more than one name, there's a Target::CreateBreakpoint overload 
that takes a `const char *func_names[]` - that you can use to make one 
portmanteau breakpoint for all the entry point names.  

It's also a good idea to add a shared library filter instead of the first 
`nullptr` in the code above, and specify the main executable.  You know the 
entry point has to be in the main executable, and so it would be inefficient to 
search the whole world for this breakpoint.  It could also end up not being 
what you want, because some other shared library might call a function named 
"main" as part of it's shared library loading code (which happens before the 
language's entry point) so you would in fact stop too early.

You'll need to pass eLanguageTypeUnknown for the language.

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


[Lldb-commits] [lldb] [lldb] add stop-at-main option to process launch (PR #67019)

2023-09-25 Thread via lldb-commits
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -38,7 +38,18 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
   case 's': // Stop at program entry point
 launch_info.GetFlags().Set(eLaunchFlagStopAtEntry);
 break;
-
+  case 'm': // Stop at main function
+  {
+TargetSP target_sp =
+execution_context ? execution_context->GetTargetSP() : TargetSP();
+BreakpointSP bp_sp = target_sp->CreateBreakpoint(
+nullptr, nullptr, "main", eFunctionNameTypeAuto, eLanguageTypeUnknown,

jimingham wrote:

It's probably also fine to implement a default version in the Language class 
that returns `main`.  No need to make everyone override this method when it's 
`main` for most languages.

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


[Lldb-commits] [lldb] [llvm][tblgen] Add `SourcePath` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread NAKAMURA Takumi via lldb-commits
" + sys::path::filename(Record.getInputFilename()),"
In-Reply-To: 


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

Looks good. 
At the moment, this doesn't emit `path` but `file name`.
Since I'll push reformatting, could you rebase, squash, and retitle before 
pushing?

I guess we could emit more fancy paths with `-I` include paths. It may be done 
in the future.

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


[Lldb-commits] [lldb] [llvm][tblgen] Add `Source Filename` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread Shao-Ce SUN via lldb-commits
" + sys::path::filename(Record.getInputFilename()),"
In-Reply-To: 


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


[Lldb-commits] [lldb] [llvm][tblgen] Add `Source Filename` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread Shao-Ce SUN via lldb-commits
" + sys::path::filename(Record.getInputFilename()),"
In-Reply-To: 


https://github.com/sunshaoce updated 
https://github.com/llvm/llvm-project/pull/65744

>From 8fd7007fa437a0eefb66015861f76f65095c31bc Mon Sep 17 00:00:00 2001
From: Shao-Ce SUN 
Date: Sat, 23 Sep 2023 11:38:33 +0800
Subject: [PATCH 1/3] [llvm][tblgen] Add `SourcePath` for
 `emitSourceFileHeader`

---
 llvm/include/llvm/TableGen/TableGenBackend.h | 3 ++-
 llvm/lib/TableGen/TableGenBackend.cpp| 7 ++-
 llvm/utils/TableGen/VTEmitter.cpp| 3 ++-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/TableGen/TableGenBackend.h 
b/llvm/include/llvm/TableGen/TableGenBackend.h
index 39f1e14bc950841..7bbd163b0433aca 100644
--- a/llvm/include/llvm/TableGen/TableGenBackend.h
+++ b/llvm/include/llvm/TableGen/TableGenBackend.h
@@ -50,7 +50,8 @@ template  class OptClass : Opt {
 
 /// emitSourceFileHeader - Output an LLVM style file header to the specified
 /// raw_ostream.
-void emitSourceFileHeader(StringRef Desc, raw_ostream &OS);
+void emitSourceFileHeader(StringRef Desc, raw_ostream &OS,
+  StringRef SourcePath = "");
 
 } // End llvm namespace
 
diff --git a/llvm/lib/TableGen/TableGenBackend.cpp 
b/llvm/lib/TableGen/TableGenBackend.cpp
index 705c3a17a765750..164443a347dcc53 100644
--- a/llvm/lib/TableGen/TableGenBackend.cpp
+++ b/llvm/lib/TableGen/TableGenBackend.cpp
@@ -40,7 +40,8 @@ static void printLine(raw_ostream &OS, const Twine &Prefix, 
char Fill,
   OS << Suffix << '\n';
 }
 
-void llvm::emitSourceFileHeader(StringRef Desc, raw_ostream &OS) {
+void llvm::emitSourceFileHeader(StringRef Desc, raw_ostream &OS,
+StringRef SourcePath) {
   printLine(OS, "/*===- TableGen'erated file ", '-', "*- C++ -*-===*\\");
   StringRef Prefix("|* ");
   StringRef Suffix(" *|");
@@ -59,4 +60,8 @@ void llvm::emitSourceFileHeader(StringRef Desc, raw_ostream 
&OS) {
   printLine(OS, Prefix, ' ', Suffix);
   printLine(OS, "\\*===", '-', "===*/");
   OS << '\n';
+
+  // Print the path of source file
+  if (!SourcePath.empty())
+OS << "// Generated from: " << SourcePath << "\n\n";
 }
diff --git a/llvm/utils/TableGen/VTEmitter.cpp 
b/llvm/utils/TableGen/VTEmitter.cpp
index d398a7e7b58f40a..03fa3d64b41fe6c 100644
--- a/llvm/utils/TableGen/VTEmitter.cpp
+++ b/llvm/utils/TableGen/VTEmitter.cpp
@@ -30,7 +30,8 @@ class VTEmitter {
 } // End anonymous namespace.
 
 void VTEmitter::run(raw_ostream &OS) {
-  emitSourceFileHeader("ValueTypes Source Fragment", OS);
+  emitSourceFileHeader("ValueTypes Source Fragment", OS,
+   Records.getInputFilename());
 
   std::array VTsByNumber = {};
   auto ValueTypes = Records.getAllDerivedDefinitions("ValueType");

>From 0d138680a7d663b8373834223cc6665dc9e3a6ba Mon Sep 17 00:00:00 2001
From: Shao-Ce SUN 
Date: Sun, 24 Sep 2023 00:52:02 +0800
Subject: [PATCH 2/3] add more tests

---
 clang/utils/TableGen/ClangASTNodesEmitter.cpp |  4 +-
 .../TableGen/ClangASTPropertiesEmitter.cpp|  8 ++--
 clang/utils/TableGen/ClangAttrEmitter.cpp | 48 +++
 .../ClangCommentCommandInfoEmitter.cpp| 10 ++--
 ...mentHTMLNamedCharacterReferenceEmitter.cpp |  5 +-
 .../TableGen/ClangCommentHTMLTagsEmitter.cpp  |  4 +-
 .../TableGen/ClangOpenCLBuiltinEmitter.cpp|  6 +--
 clang/utils/TableGen/ClangSyntaxEmitter.cpp   |  4 +-
 .../utils/TableGen/ClangTypeNodesEmitter.cpp  |  2 +-
 lldb/utils/TableGen/LLDBOptionDefEmitter.cpp  |  2 +-
 .../utils/TableGen/LLDBPropertyDefEmitter.cpp |  4 +-
 llvm/include/llvm/TableGen/TableGenBackend.h  |  3 +-
 llvm/lib/TableGen/TableGenBackend.cpp |  6 +--
 llvm/utils/TableGen/AsmMatcherEmitter.cpp |  2 +-
 llvm/utils/TableGen/AsmWriterEmitter.cpp  |  2 +-
 llvm/utils/TableGen/VTEmitter.cpp |  3 +-
 mlir/tools/mlir-tblgen/DialectGen.cpp |  4 +-
 mlir/tools/mlir-tblgen/EnumsGen.cpp   |  4 +-
 mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp |  2 +-
 mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp   |  4 +-
 mlir/tools/mlir-tblgen/RewriterGen.cpp|  2 +-
 mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp  | 22 +
 22 files changed, 81 insertions(+), 70 deletions(-)

diff --git a/clang/utils/TableGen/ClangASTNodesEmitter.cpp 
b/clang/utils/TableGen/ClangASTNodesEmitter.cpp
index 2b8d7a9efdf10c9..16a1c74b9d91ad6 100644
--- a/clang/utils/TableGen/ClangASTNodesEmitter.cpp
+++ b/clang/utils/TableGen/ClangASTNodesEmitter.cpp
@@ -169,7 +169,7 @@ void ClangASTNodesEmitter::deriveChildTree() {
 void ClangASTNodesEmitter::run(raw_ostream &OS) {
   deriveChildTree();
 
-  emitSourceFileHeader("List of AST nodes of a particular kind", OS);
+  emitSourceFileHeader("List of AST nodes of a particular kind", OS, Records);
 
   // Write the preamble
   OS << "#ifndef ABSTRACT_" << macroHierarchyName() << "\n";
@@ -205,7 +205,7 @@ void clang::EmitClangASTNodes(RecordKeeper &RK, raw_ostream 
&OS,
 void clang::EmitClangDeclContext(RecordKee

[Lldb-commits] [lldb] [llvm][tblgen] Add `Source Filename` for `emitSourceFileHeader` (PR #65744)

2023-09-25 Thread Shao-Ce SUN via lldb-commits
" + sys::path::filename(Record.getInputFilename()),"
In-Reply-To: 


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


[Lldb-commits] [lldb] b0e28eb - [llvm][tblgen] Add `Source Filename` for `emitSourceFileHeader` (#65744)

2023-09-25 Thread via lldb-commits

Author: Shao-Ce SUN
Date: 2023-09-26T13:40:56+08:00
New Revision: b0e28eb832710964067a17d845de15ada2da2b9c

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

LOG: [llvm][tblgen] Add `Source Filename` for `emitSourceFileHeader` (#65744)

I think this is very helpful for reading generated `.inc` files.

Added: 


Modified: 
clang/utils/TableGen/ClangASTNodesEmitter.cpp
clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp
clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
clang/utils/TableGen/ClangCommentHTMLTagsEmitter.cpp
clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
clang/utils/TableGen/ClangSyntaxEmitter.cpp
clang/utils/TableGen/ClangTypeNodesEmitter.cpp
lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp
llvm/include/llvm/TableGen/TableGenBackend.h
llvm/lib/TableGen/TableGenBackend.cpp
llvm/utils/TableGen/AsmMatcherEmitter.cpp
llvm/utils/TableGen/AsmWriterEmitter.cpp
llvm/utils/TableGen/VTEmitter.cpp
mlir/tools/mlir-tblgen/DialectGen.cpp
mlir/tools/mlir-tblgen/EnumsGen.cpp
mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
mlir/tools/mlir-tblgen/RewriterGen.cpp
mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp

Removed: 




diff  --git a/clang/utils/TableGen/ClangASTNodesEmitter.cpp 
b/clang/utils/TableGen/ClangASTNodesEmitter.cpp
index 2b8d7a9efdf10c9..16a1c74b9d91ad6 100644
--- a/clang/utils/TableGen/ClangASTNodesEmitter.cpp
+++ b/clang/utils/TableGen/ClangASTNodesEmitter.cpp
@@ -169,7 +169,7 @@ void ClangASTNodesEmitter::deriveChildTree() {
 void ClangASTNodesEmitter::run(raw_ostream &OS) {
   deriveChildTree();
 
-  emitSourceFileHeader("List of AST nodes of a particular kind", OS);
+  emitSourceFileHeader("List of AST nodes of a particular kind", OS, Records);
 
   // Write the preamble
   OS << "#ifndef ABSTRACT_" << macroHierarchyName() << "\n";
@@ -205,7 +205,7 @@ void clang::EmitClangASTNodes(RecordKeeper &RK, raw_ostream 
&OS,
 void clang::EmitClangDeclContext(RecordKeeper &Records, raw_ostream &OS) {
   // FIXME: Find a .td file format to allow for this to be represented better.
 
-  emitSourceFileHeader("List of AST Decl nodes", OS);
+  emitSourceFileHeader("List of AST Decl nodes", OS, Records);
 
   OS << "#ifndef DECL_CONTEXT\n";
   OS << "#  define DECL_CONTEXT(DECL)\n";

diff  --git a/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp 
b/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
index 19613880641efe9..de8dda60681ff87 100644
--- a/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
+++ b/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
@@ -593,7 +593,7 @@ void ASTPropsEmitter::emitWriteOfProperty(StringRef 
writerName,
 template 
 static void emitASTReader(RecordKeeper &records, raw_ostream &out,
   StringRef description) {
-  emitSourceFileHeader(description, out);
+  emitSourceFileHeader(description, out, records);
 
   ASTPropsEmitter(records, out).emitNodeReaderClass();
 }
@@ -607,7 +607,7 @@ void clang::EmitClangTypeReader(RecordKeeper &records, 
raw_ostream &out) {
 template 
 static void emitASTWriter(RecordKeeper &records, raw_ostream &out,
   StringRef description) {
-  emitSourceFileHeader(description, out);
+  emitSourceFileHeader(description, out, records);
 
   ASTPropsEmitter(records, out).emitNodeWriterClass();
 }
@@ -852,7 +852,7 @@ void ASTPropsEmitter::emitBasicReaderWriterFile(const 
ReaderWriterInfo &info) {
 /// Emit an .inc file that defines some helper classes for reading
 /// basic values.
 void clang::EmitClangBasicReader(RecordKeeper &records, raw_ostream &out) {
-  emitSourceFileHeader("Helper classes for BasicReaders", out);
+  emitSourceFileHeader("Helper classes for BasicReaders", out, records);
 
   // Use any property, we won't be using those properties.
   auto info = ReaderWriterInfo::forReader();
@@ -862,7 +862,7 @@ void clang::EmitClangBasicReader(RecordKeeper &records, 
raw_ostream &out) {
 /// Emit an .inc file that defines some helper classes for writing
 /// basic values.
 void clang::EmitClangBasicWriter(RecordKeeper &records, raw_ostream &out) {
-  emitSourceFileHeader("Helper classes for BasicWriters", out);
+  emitSourceFileHeader("Helper classes for BasicWriters", out, records);
 
   // Use any property, we won't be using those properties.
   auto info = ReaderWriterInfo::forWriter();

diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 00bcbe1153518c8..a015ec36a30dc9e 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang

[Lldb-commits] [lldb] [lldb] Add SetValueFromCString API to SyntheticFronend (PR #67309)

2023-09-25 Thread Pavel Kosov via lldb-commits


@@ -75,6 +77,10 @@ class SyntheticChildrenFrontEnd {
   // display purposes
   virtual ConstString GetSyntheticTypeName() { return ConstString(); }
 
+  virtual bool SetValueFromCString(const char *value_str, Status &error) {
+return false;
+  }
+

kpdev wrote:

It will be used in the following patches (it is the first, two more to come). 
But maybe it is better to use one big patch with all changes?

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


[Lldb-commits] [lldb] [lldb] Add SetValueFromCString API to SyntheticFronend (PR #67309)

2023-09-25 Thread Pavel Kosov via lldb-commits

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