[Lldb-commits] [lldb] [clang-tools-extra] [clang] [llvm] Add new API in SBTarget for loading core from SBFile (PR #71769)

2023-11-14 Thread via lldb-commits

https://github.com/GeorgeHuyubo updated 
https://github.com/llvm/llvm-project/pull/71769

>From fd42e87a663754ca7273715ea40f397df41e3da0 Mon Sep 17 00:00:00 2001
From: George Hu 
Date: Wed, 8 Nov 2023 16:25:34 -0800
Subject: [PATCH] Add new API in SBTarget for loading core from SBFile

---
 lldb/include/lldb/API/SBTarget.h  |  1 +
 lldb/include/lldb/Target/PostMortemProcess.h  | 15 
 lldb/include/lldb/Target/Process.h| 10 +-
 lldb/include/lldb/Target/ProcessTrace.h   |  5 +--
 lldb/include/lldb/Target/Target.h |  3 +-
 lldb/include/lldb/lldb-private-interfaces.h   |  7 ++--
 lldb/source/API/SBTarget.cpp  | 34 +--
 lldb/source/Commands/CommandObjectTarget.cpp  | 11 +-
 lldb/source/Core/IOHandlerCursesGUI.cpp   | 13 +--
 .../FreeBSDKernel/ProcessFreeBSDKernel.cpp| 27 +--
 .../FreeBSDKernel/ProcessFreeBSDKernel.h  |  8 ++---
 .../Process/MacOSX-Kernel/ProcessKDP.cpp  |  4 +--
 .../Process/MacOSX-Kernel/ProcessKDP.h|  9 ++---
 .../Process/elf-core/ProcessElfCore.cpp   | 22 ++--
 .../Plugins/Process/elf-core/ProcessElfCore.h | 12 +++
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  9 ++---
 .../Process/gdb-remote/ProcessGDBRemote.h |  3 +-
 .../Process/mach-core/ProcessMachCore.cpp | 23 +++--
 .../Process/mach-core/ProcessMachCore.h   | 11 +++---
 .../Process/minidump/ProcessMinidump.cpp  | 16 +
 .../Process/minidump/ProcessMinidump.h|  6 ++--
 .../Process/scripted/ScriptedProcess.cpp  |  2 +-
 .../Process/scripted/ScriptedProcess.h|  2 +-
 lldb/source/Target/Process.cpp| 11 +++---
 lldb/source/Target/ProcessTrace.cpp   | 11 +++---
 lldb/source/Target/Target.cpp |  2 +-
 .../postmortem/elf-core/TestLinuxCore.py  | 16 +
 .../Target/LocateModuleCallbackTest.cpp   |  3 +-
 28 files changed, 200 insertions(+), 96 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b4..afc949390ac3379 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -184,6 +184,7 @@ class LLDB_API SBTarget {
 
   SBProcess LoadCore(const char *core_file);
   SBProcess LoadCore(const char *core_file, lldb::SBError );
+  SBProcess LoadCore(SBFile , lldb::SBError );
 
   /// Launch a new process with sensible defaults.
   ///
diff --git a/lldb/include/lldb/Target/PostMortemProcess.h 
b/lldb/include/lldb/Target/PostMortemProcess.h
index 7207fc99ef29a41..2bd775c9e2c5196 100644
--- a/lldb/include/lldb/Target/PostMortemProcess.h
+++ b/lldb/include/lldb/Target/PostMortemProcess.h
@@ -10,6 +10,8 @@
 #define LLDB_TARGET_POSTMORTEMPROCESS_H
 
 #include "lldb/Target/Process.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/lldb-forward.h"
 
 namespace lldb_private {
 
@@ -24,7 +26,20 @@ class PostMortemProcess : public Process {
   using Process::Process;
 
 public:
+  PostMortemProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
+lldb::FileSP file_sp)
+  : Process(target_sp, listener_sp), m_core_file(file_sp) {}
+
   bool IsLiveDebugSession() const override { return false; }
+
+  FileSpec GetCoreFile() const override {
+FileSpec file_spec;
+m_core_file->GetFileSpec(file_spec);
+return file_spec;
+  }
+
+protected:
+  lldb::FileSP m_core_file;
 };
 
 } // namespace lldb_private
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index a6d3e6c2d16926e..6e2cafbfce9698e 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -52,6 +52,7 @@
 #include "lldb/Utility/TraceGDBRemotePackets.h"
 #include "lldb/Utility/UnimplementedError.h"
 #include "lldb/Utility/UserIDResolver.h"
+#include "lldb/lldb-forward.h"
 #include "lldb/lldb-private.h"
 
 #include "llvm/ADT/ArrayRef.h"
@@ -507,7 +508,7 @@ class Process : public 
std::enable_shared_from_this,
   static lldb::ProcessSP FindPlugin(lldb::TargetSP target_sp,
 llvm::StringRef plugin_name,
 lldb::ListenerSP listener_sp,
-const FileSpec *crash_file_path,
+lldb::FileSP crash_file_sp,
 bool can_connect);
 
   /// Static function that can be used with the \b host function
@@ -1469,6 +1470,13 @@ class Process : public 
std::enable_shared_from_this,
 
   virtual bool IsLiveDebugSession() const { return true; };
 
+  /// Provide a way to retrieve the core dump file that is loaded for 
debugging.
+  /// Only available if IsLiveDebugSession() returns false.
+  ///
+  /// \return
+  /// File path to the core file.
+  virtual FileSpec GetCoreFile() const { return {}; }
+
   /// Before lldb detaches from a process, it warns the user that they are
   /// about to lose their debug 

[Lldb-commits] [lldb] Add new API in SBTarget for loading core from SBFile (PR #71769)

2023-11-14 Thread via lldb-commits

https://github.com/GeorgeHuyubo updated 
https://github.com/llvm/llvm-project/pull/71769

>From fd42e87a663754ca7273715ea40f397df41e3da0 Mon Sep 17 00:00:00 2001
From: George Hu 
Date: Wed, 8 Nov 2023 16:25:34 -0800
Subject: [PATCH] Add new API in SBTarget for loading core from SBFile

---
 lldb/include/lldb/API/SBTarget.h  |  1 +
 lldb/include/lldb/Target/PostMortemProcess.h  | 15 
 lldb/include/lldb/Target/Process.h| 10 +-
 lldb/include/lldb/Target/ProcessTrace.h   |  5 +--
 lldb/include/lldb/Target/Target.h |  3 +-
 lldb/include/lldb/lldb-private-interfaces.h   |  7 ++--
 lldb/source/API/SBTarget.cpp  | 34 +--
 lldb/source/Commands/CommandObjectTarget.cpp  | 11 +-
 lldb/source/Core/IOHandlerCursesGUI.cpp   | 13 +--
 .../FreeBSDKernel/ProcessFreeBSDKernel.cpp| 27 +--
 .../FreeBSDKernel/ProcessFreeBSDKernel.h  |  8 ++---
 .../Process/MacOSX-Kernel/ProcessKDP.cpp  |  4 +--
 .../Process/MacOSX-Kernel/ProcessKDP.h|  9 ++---
 .../Process/elf-core/ProcessElfCore.cpp   | 22 ++--
 .../Plugins/Process/elf-core/ProcessElfCore.h | 12 +++
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  9 ++---
 .../Process/gdb-remote/ProcessGDBRemote.h |  3 +-
 .../Process/mach-core/ProcessMachCore.cpp | 23 +++--
 .../Process/mach-core/ProcessMachCore.h   | 11 +++---
 .../Process/minidump/ProcessMinidump.cpp  | 16 +
 .../Process/minidump/ProcessMinidump.h|  6 ++--
 .../Process/scripted/ScriptedProcess.cpp  |  2 +-
 .../Process/scripted/ScriptedProcess.h|  2 +-
 lldb/source/Target/Process.cpp| 11 +++---
 lldb/source/Target/ProcessTrace.cpp   | 11 +++---
 lldb/source/Target/Target.cpp |  2 +-
 .../postmortem/elf-core/TestLinuxCore.py  | 16 +
 .../Target/LocateModuleCallbackTest.cpp   |  3 +-
 28 files changed, 200 insertions(+), 96 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b4..afc949390ac3379 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -184,6 +184,7 @@ class LLDB_API SBTarget {
 
   SBProcess LoadCore(const char *core_file);
   SBProcess LoadCore(const char *core_file, lldb::SBError );
+  SBProcess LoadCore(SBFile , lldb::SBError );
 
   /// Launch a new process with sensible defaults.
   ///
diff --git a/lldb/include/lldb/Target/PostMortemProcess.h 
b/lldb/include/lldb/Target/PostMortemProcess.h
index 7207fc99ef29a41..2bd775c9e2c5196 100644
--- a/lldb/include/lldb/Target/PostMortemProcess.h
+++ b/lldb/include/lldb/Target/PostMortemProcess.h
@@ -10,6 +10,8 @@
 #define LLDB_TARGET_POSTMORTEMPROCESS_H
 
 #include "lldb/Target/Process.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/lldb-forward.h"
 
 namespace lldb_private {
 
@@ -24,7 +26,20 @@ class PostMortemProcess : public Process {
   using Process::Process;
 
 public:
+  PostMortemProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
+lldb::FileSP file_sp)
+  : Process(target_sp, listener_sp), m_core_file(file_sp) {}
+
   bool IsLiveDebugSession() const override { return false; }
+
+  FileSpec GetCoreFile() const override {
+FileSpec file_spec;
+m_core_file->GetFileSpec(file_spec);
+return file_spec;
+  }
+
+protected:
+  lldb::FileSP m_core_file;
 };
 
 } // namespace lldb_private
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index a6d3e6c2d16926e..6e2cafbfce9698e 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -52,6 +52,7 @@
 #include "lldb/Utility/TraceGDBRemotePackets.h"
 #include "lldb/Utility/UnimplementedError.h"
 #include "lldb/Utility/UserIDResolver.h"
+#include "lldb/lldb-forward.h"
 #include "lldb/lldb-private.h"
 
 #include "llvm/ADT/ArrayRef.h"
@@ -507,7 +508,7 @@ class Process : public 
std::enable_shared_from_this,
   static lldb::ProcessSP FindPlugin(lldb::TargetSP target_sp,
 llvm::StringRef plugin_name,
 lldb::ListenerSP listener_sp,
-const FileSpec *crash_file_path,
+lldb::FileSP crash_file_sp,
 bool can_connect);
 
   /// Static function that can be used with the \b host function
@@ -1469,6 +1470,13 @@ class Process : public 
std::enable_shared_from_this,
 
   virtual bool IsLiveDebugSession() const { return true; };
 
+  /// Provide a way to retrieve the core dump file that is loaded for 
debugging.
+  /// Only available if IsLiveDebugSession() returns false.
+  ///
+  /// \return
+  /// File path to the core file.
+  virtual FileSpec GetCoreFile() const { return {}; }
+
   /// Before lldb detaches from a process, it warns the user that they are
   /// about to lose their debug 

[Lldb-commits] [lldb] Add new API in SBTarget for loading core from SBFile (PR #71769)

2023-11-14 Thread via lldb-commits

https://github.com/GeorgeHuyubo updated 
https://github.com/llvm/llvm-project/pull/71769

>From 76f7fd2c62921f15c35b4dd57cc6bfa8a8be93b2 Mon Sep 17 00:00:00 2001
From: George Hu 
Date: Wed, 8 Nov 2023 16:25:34 -0800
Subject: [PATCH] Add new API in SBTarget for loading core from SBFile

---
 lldb/include/lldb/API/SBTarget.h  |  1 +
 lldb/include/lldb/Target/PostMortemProcess.h  | 15 
 lldb/include/lldb/Target/Process.h| 10 +-
 lldb/include/lldb/Target/ProcessTrace.h   |  5 +--
 lldb/include/lldb/Target/Target.h |  3 +-
 lldb/include/lldb/lldb-private-interfaces.h   |  7 ++--
 lldb/source/API/SBTarget.cpp  | 34 +--
 lldb/source/Commands/CommandObjectTarget.cpp  | 11 +-
 lldb/source/Core/IOHandlerCursesGUI.cpp   | 13 +--
 .../FreeBSDKernel/ProcessFreeBSDKernel.cpp| 27 +--
 .../FreeBSDKernel/ProcessFreeBSDKernel.h  |  8 ++---
 .../Process/MacOSX-Kernel/ProcessKDP.cpp  |  4 +--
 .../Process/MacOSX-Kernel/ProcessKDP.h|  9 ++---
 .../Process/elf-core/ProcessElfCore.cpp   | 22 ++--
 .../Plugins/Process/elf-core/ProcessElfCore.h | 12 +++
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  9 ++---
 .../Process/gdb-remote/ProcessGDBRemote.h |  3 +-
 .../Process/mach-core/ProcessMachCore.cpp | 23 +++--
 .../Process/mach-core/ProcessMachCore.h   | 11 +++---
 .../Process/minidump/ProcessMinidump.cpp  | 16 +
 .../Process/minidump/ProcessMinidump.h|  6 ++--
 .../Process/scripted/ScriptedProcess.cpp  |  2 +-
 .../Process/scripted/ScriptedProcess.h|  2 +-
 lldb/source/Target/Process.cpp|  7 ++--
 lldb/source/Target/ProcessTrace.cpp   | 11 +++---
 lldb/source/Target/Target.cpp |  2 +-
 .../postmortem/elf-core/TestLinuxCore.py  | 16 +
 .../Target/LocateModuleCallbackTest.cpp   |  3 +-
 28 files changed, 198 insertions(+), 94 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b4..afc949390ac3379 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -184,6 +184,7 @@ class LLDB_API SBTarget {
 
   SBProcess LoadCore(const char *core_file);
   SBProcess LoadCore(const char *core_file, lldb::SBError );
+  SBProcess LoadCore(SBFile , lldb::SBError );
 
   /// Launch a new process with sensible defaults.
   ///
diff --git a/lldb/include/lldb/Target/PostMortemProcess.h 
b/lldb/include/lldb/Target/PostMortemProcess.h
index 7207fc99ef29a41..2bd775c9e2c5196 100644
--- a/lldb/include/lldb/Target/PostMortemProcess.h
+++ b/lldb/include/lldb/Target/PostMortemProcess.h
@@ -10,6 +10,8 @@
 #define LLDB_TARGET_POSTMORTEMPROCESS_H
 
 #include "lldb/Target/Process.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/lldb-forward.h"
 
 namespace lldb_private {
 
@@ -24,7 +26,20 @@ class PostMortemProcess : public Process {
   using Process::Process;
 
 public:
+  PostMortemProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
+lldb::FileSP file_sp)
+  : Process(target_sp, listener_sp), m_core_file(file_sp) {}
+
   bool IsLiveDebugSession() const override { return false; }
+
+  FileSpec GetCoreFile() const override {
+FileSpec file_spec;
+m_core_file->GetFileSpec(file_spec);
+return file_spec;
+  }
+
+protected:
+  lldb::FileSP m_core_file;
 };
 
 } // namespace lldb_private
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index a6d3e6c2d16926e..6e2cafbfce9698e 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -52,6 +52,7 @@
 #include "lldb/Utility/TraceGDBRemotePackets.h"
 #include "lldb/Utility/UnimplementedError.h"
 #include "lldb/Utility/UserIDResolver.h"
+#include "lldb/lldb-forward.h"
 #include "lldb/lldb-private.h"
 
 #include "llvm/ADT/ArrayRef.h"
@@ -507,7 +508,7 @@ class Process : public 
std::enable_shared_from_this,
   static lldb::ProcessSP FindPlugin(lldb::TargetSP target_sp,
 llvm::StringRef plugin_name,
 lldb::ListenerSP listener_sp,
-const FileSpec *crash_file_path,
+lldb::FileSP crash_file_sp,
 bool can_connect);
 
   /// Static function that can be used with the \b host function
@@ -1469,6 +1470,13 @@ class Process : public 
std::enable_shared_from_this,
 
   virtual bool IsLiveDebugSession() const { return true; };
 
+  /// Provide a way to retrieve the core dump file that is loaded for 
debugging.
+  /// Only available if IsLiveDebugSession() returns false.
+  ///
+  /// \return
+  /// File path to the core file.
+  virtual FileSpec GetCoreFile() const { return {}; }
+
   /// Before lldb detaches from a process, it warns the user that they are
   /// about to lose their debug 

[Lldb-commits] [lldb] Add new API in SBTarget for loading core from SBFile (PR #71769)

2023-11-14 Thread via lldb-commits

https://github.com/GeorgeHuyubo updated 
https://github.com/llvm/llvm-project/pull/71769

>From 6550a970a88ef92fbadf63e7913ad7325d7aebc4 Mon Sep 17 00:00:00 2001
From: George Hu 
Date: Wed, 8 Nov 2023 16:25:34 -0800
Subject: [PATCH] Add new API in SBTarget for loading core from SBFile

---
 lldb/include/lldb/API/SBTarget.h  |  1 +
 lldb/include/lldb/Target/PostMortemProcess.h  | 15 
 lldb/include/lldb/Target/Process.h| 10 +-
 lldb/include/lldb/Target/ProcessTrace.h   |  5 +--
 lldb/include/lldb/Target/Target.h |  3 +-
 lldb/include/lldb/lldb-private-interfaces.h   |  7 ++--
 lldb/source/API/SBTarget.cpp  | 35 +--
 lldb/source/Commands/CommandObjectTarget.cpp  | 11 +-
 lldb/source/Core/IOHandlerCursesGUI.cpp   | 13 +--
 .../FreeBSDKernel/ProcessFreeBSDKernel.cpp| 27 --
 .../FreeBSDKernel/ProcessFreeBSDKernel.h  |  8 ++---
 .../Process/MacOSX-Kernel/ProcessKDP.cpp  |  4 +--
 .../Process/MacOSX-Kernel/ProcessKDP.h|  9 ++---
 .../Process/elf-core/ProcessElfCore.cpp   | 22 ++--
 .../Plugins/Process/elf-core/ProcessElfCore.h | 12 +++
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  9 ++---
 .../Process/gdb-remote/ProcessGDBRemote.h |  3 +-
 .../Process/mach-core/ProcessMachCore.cpp | 23 ++--
 .../Process/mach-core/ProcessMachCore.h   | 11 +++---
 .../Process/minidump/ProcessMinidump.cpp  | 16 +
 .../Process/minidump/ProcessMinidump.h|  6 ++--
 .../Process/scripted/ScriptedProcess.cpp  |  2 +-
 .../Process/scripted/ScriptedProcess.h|  2 +-
 lldb/source/Target/Process.cpp|  7 ++--
 lldb/source/Target/ProcessTrace.cpp   | 11 +++---
 lldb/source/Target/Target.cpp |  2 +-
 .../postmortem/elf-core/TestLinuxCore.py  | 16 +
 .../Target/LocateModuleCallbackTest.cpp   |  3 +-
 28 files changed, 199 insertions(+), 94 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b4..afc949390ac3379 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -184,6 +184,7 @@ class LLDB_API SBTarget {
 
   SBProcess LoadCore(const char *core_file);
   SBProcess LoadCore(const char *core_file, lldb::SBError );
+  SBProcess LoadCore(SBFile , lldb::SBError );
 
   /// Launch a new process with sensible defaults.
   ///
diff --git a/lldb/include/lldb/Target/PostMortemProcess.h 
b/lldb/include/lldb/Target/PostMortemProcess.h
index 7207fc99ef29a41..2bd775c9e2c5196 100644
--- a/lldb/include/lldb/Target/PostMortemProcess.h
+++ b/lldb/include/lldb/Target/PostMortemProcess.h
@@ -10,6 +10,8 @@
 #define LLDB_TARGET_POSTMORTEMPROCESS_H
 
 #include "lldb/Target/Process.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/lldb-forward.h"
 
 namespace lldb_private {
 
@@ -24,7 +26,20 @@ class PostMortemProcess : public Process {
   using Process::Process;
 
 public:
+  PostMortemProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
+lldb::FileSP file_sp)
+  : Process(target_sp, listener_sp), m_core_file(file_sp) {}
+
   bool IsLiveDebugSession() const override { return false; }
+
+  FileSpec GetCoreFile() const override {
+FileSpec file_spec;
+m_core_file->GetFileSpec(file_spec);
+return file_spec;
+  }
+
+protected:
+  lldb::FileSP m_core_file;
 };
 
 } // namespace lldb_private
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index a6d3e6c2d16926e..6e2cafbfce9698e 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -52,6 +52,7 @@
 #include "lldb/Utility/TraceGDBRemotePackets.h"
 #include "lldb/Utility/UnimplementedError.h"
 #include "lldb/Utility/UserIDResolver.h"
+#include "lldb/lldb-forward.h"
 #include "lldb/lldb-private.h"
 
 #include "llvm/ADT/ArrayRef.h"
@@ -507,7 +508,7 @@ class Process : public 
std::enable_shared_from_this,
   static lldb::ProcessSP FindPlugin(lldb::TargetSP target_sp,
 llvm::StringRef plugin_name,
 lldb::ListenerSP listener_sp,
-const FileSpec *crash_file_path,
+lldb::FileSP crash_file_sp,
 bool can_connect);
 
   /// Static function that can be used with the \b host function
@@ -1469,6 +1470,13 @@ class Process : public 
std::enable_shared_from_this,
 
   virtual bool IsLiveDebugSession() const { return true; };
 
+  /// Provide a way to retrieve the core dump file that is loaded for 
debugging.
+  /// Only available if IsLiveDebugSession() returns false.
+  ///
+  /// \return
+  /// File path to the core file.
+  virtual FileSpec GetCoreFile() const { return {}; }
+
   /// Before lldb detaches from a process, it warns the user that they are
   /// about to lose their debug 

[Lldb-commits] [lldb] Add new API in SBTarget for loading core from SBFile (PR #71769)

2023-11-14 Thread via lldb-commits

https://github.com/GeorgeHuyubo updated 
https://github.com/llvm/llvm-project/pull/71769

>From b2160235dea7b18395dc3dba9e6a5b735278ac9e Mon Sep 17 00:00:00 2001
From: George Hu 
Date: Wed, 8 Nov 2023 16:25:34 -0800
Subject: [PATCH] Add new API in SBTarget for loading core from SBFile

---
 lldb/include/lldb/API/SBTarget.h  |  1 +
 lldb/include/lldb/Target/PostMortemProcess.h  | 15 +++
 lldb/include/lldb/Target/Process.h| 10 -
 lldb/include/lldb/Target/ProcessTrace.h   |  5 ++-
 lldb/include/lldb/Target/Target.h |  3 +-
 lldb/include/lldb/lldb-private-interfaces.h   |  7 ++--
 lldb/source/API/SBTarget.cpp  | 41 +++
 lldb/source/Commands/CommandObjectTarget.cpp  | 37 ++---
 lldb/source/Core/IOHandlerCursesGUI.cpp   | 13 +-
 .../FreeBSDKernel/ProcessFreeBSDKernel.cpp| 27 +++-
 .../FreeBSDKernel/ProcessFreeBSDKernel.h  |  8 ++--
 .../Process/MacOSX-Kernel/ProcessKDP.cpp  |  4 +-
 .../Process/MacOSX-Kernel/ProcessKDP.h|  9 ++--
 .../Process/elf-core/ProcessElfCore.cpp   | 24 ++-
 .../Plugins/Process/elf-core/ProcessElfCore.h | 12 +++---
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  9 ++--
 .../Process/gdb-remote/ProcessGDBRemote.h |  3 +-
 .../Process/mach-core/ProcessMachCore.cpp | 23 ++-
 .../Process/mach-core/ProcessMachCore.h   | 11 +++--
 .../Process/minidump/ProcessMinidump.cpp  | 16 
 .../Process/minidump/ProcessMinidump.h|  6 +--
 .../Process/scripted/ScriptedProcess.cpp  |  2 +-
 .../Process/scripted/ScriptedProcess.h|  2 +-
 lldb/source/Target/Process.cpp|  7 ++--
 lldb/source/Target/ProcessTrace.cpp   | 11 ++---
 lldb/source/Target/Target.cpp |  2 +-
 .../postmortem/elf-core/TestLinuxCore.py  | 16 
 .../Target/LocateModuleCallbackTest.cpp   |  3 +-
 28 files changed, 212 insertions(+), 115 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b4..afc949390ac3379 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -184,6 +184,7 @@ class LLDB_API SBTarget {
 
   SBProcess LoadCore(const char *core_file);
   SBProcess LoadCore(const char *core_file, lldb::SBError );
+  SBProcess LoadCore(SBFile , lldb::SBError );
 
   /// Launch a new process with sensible defaults.
   ///
diff --git a/lldb/include/lldb/Target/PostMortemProcess.h 
b/lldb/include/lldb/Target/PostMortemProcess.h
index 7207fc99ef29a41..2bd775c9e2c5196 100644
--- a/lldb/include/lldb/Target/PostMortemProcess.h
+++ b/lldb/include/lldb/Target/PostMortemProcess.h
@@ -10,6 +10,8 @@
 #define LLDB_TARGET_POSTMORTEMPROCESS_H
 
 #include "lldb/Target/Process.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/lldb-forward.h"
 
 namespace lldb_private {
 
@@ -24,7 +26,20 @@ class PostMortemProcess : public Process {
   using Process::Process;
 
 public:
+  PostMortemProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
+lldb::FileSP file_sp)
+  : Process(target_sp, listener_sp), m_core_file(file_sp) {}
+
   bool IsLiveDebugSession() const override { return false; }
+
+  FileSpec GetCoreFile() const override {
+FileSpec file_spec;
+m_core_file->GetFileSpec(file_spec);
+return file_spec;
+  }
+
+protected:
+  lldb::FileSP m_core_file;
 };
 
 } // namespace lldb_private
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index a6d3e6c2d16926e..6e2cafbfce9698e 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -52,6 +52,7 @@
 #include "lldb/Utility/TraceGDBRemotePackets.h"
 #include "lldb/Utility/UnimplementedError.h"
 #include "lldb/Utility/UserIDResolver.h"
+#include "lldb/lldb-forward.h"
 #include "lldb/lldb-private.h"
 
 #include "llvm/ADT/ArrayRef.h"
@@ -507,7 +508,7 @@ class Process : public 
std::enable_shared_from_this,
   static lldb::ProcessSP FindPlugin(lldb::TargetSP target_sp,
 llvm::StringRef plugin_name,
 lldb::ListenerSP listener_sp,
-const FileSpec *crash_file_path,
+lldb::FileSP crash_file_sp,
 bool can_connect);
 
   /// Static function that can be used with the \b host function
@@ -1469,6 +1470,13 @@ class Process : public 
std::enable_shared_from_this,
 
   virtual bool IsLiveDebugSession() const { return true; };
 
+  /// Provide a way to retrieve the core dump file that is loaded for 
debugging.
+  /// Only available if IsLiveDebugSession() returns false.
+  ///
+  /// \return
+  /// File path to the core file.
+  virtual FileSpec GetCoreFile() const { return {}; }
+
   /// Before lldb detaches from a process, it warns the user that they are
   /// about to lose their debug session. In 

[Lldb-commits] [lldb] [llvm] Remove hardware index from watchpoints and breakpoints (PR #72012)

2023-11-14 Thread Med Ismail Bennani via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] [llvm] Remove hardware index from watchpoints and breakpoints (PR #72012)

2023-11-14 Thread Alex Langford via lldb-commits

bulbazord wrote:

> > > The Linux MIPS support has been ripped out and the remaining support for 
> > > MIPS probably gets no real testing
> > 
> > 
> > Don't know the status but the BSD's still have some MIPS support.
> 
> Yeah I've been trying to keep the MIPS watchpoint code in the sources as I've 
> been updating it (it doesn't distinguish the low nibble of addresses iirc and 
> there's code to decode the load/store instruction to find the exact address 
> accessed), even if it's not currently maintained I'd rather not remove it, 
> it's not a lot of code. Someone may want to re-support this exciting 
> architecture again in the future.

Makes sense to me! I can think of a few MIPS platforms I personally would like 
to see supported. :)

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


[Lldb-commits] [lldb] [llvm] Remove hardware index from watchpoints and breakpoints (PR #72012)

2023-11-14 Thread Alex Langford via lldb-commits

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

Awesome, thank you!  

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


[Lldb-commits] [lldb] Add new API in SBTarget for loading core from SBFile (PR #71769)

2023-11-14 Thread via lldb-commits

https://github.com/GeorgeHuyubo updated 
https://github.com/llvm/llvm-project/pull/71769

>From e6b2d9d1bbd4fe2fceeb9474fd0af636370b3079 Mon Sep 17 00:00:00 2001
From: George Hu 
Date: Wed, 8 Nov 2023 16:25:34 -0800
Subject: [PATCH] Add new API in SBTarget for loading core from SBFile

---
 lldb/include/lldb/API/SBTarget.h  |  3 +-
 lldb/include/lldb/Target/PostMortemProcess.h  | 15 ++
 lldb/include/lldb/Target/Process.h| 22 +---
 lldb/include/lldb/Target/ProcessTrace.h   |  5 +-
 lldb/include/lldb/Target/Target.h |  3 +-
 lldb/include/lldb/lldb-private-interfaces.h   |  7 +--
 lldb/source/API/SBTarget.cpp  | 41 +++
 lldb/source/Commands/CommandObjectTarget.cpp  | 50 ---
 lldb/source/Core/IOHandlerCursesGUI.cpp   | 13 -
 .../FreeBSDKernel/ProcessFreeBSDKernel.cpp| 27 ++
 .../FreeBSDKernel/ProcessFreeBSDKernel.h  |  8 +--
 .../Process/MacOSX-Kernel/ProcessKDP.cpp  |  4 +-
 .../Process/MacOSX-Kernel/ProcessKDP.h|  9 ++--
 .../Process/elf-core/ProcessElfCore.cpp   | 28 ++-
 .../Plugins/Process/elf-core/ProcessElfCore.h | 12 ++---
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  9 ++--
 .../Process/gdb-remote/ProcessGDBRemote.h |  5 +-
 .../Process/mach-core/ProcessMachCore.cpp | 25 ++
 .../Process/mach-core/ProcessMachCore.h   | 11 ++--
 .../Process/minidump/ProcessMinidump.cpp  | 16 +++---
 .../Process/minidump/ProcessMinidump.h|  6 +--
 .../Process/scripted/ScriptedProcess.cpp  |  4 +-
 .../Process/scripted/ScriptedProcess.h|  2 +-
 lldb/source/Target/Process.cpp|  7 ++-
 lldb/source/Target/ProcessTrace.cpp   | 11 ++--
 lldb/source/Target/Target.cpp |  2 +-
 .../postmortem/elf-core/TestLinuxCore.py  | 16 ++
 .../Target/LocateModuleCallbackTest.cpp   |  3 +-
 28 files changed, 233 insertions(+), 131 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b4..fc6584ec15d5123 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -184,6 +184,7 @@ class LLDB_API SBTarget {
 
   SBProcess LoadCore(const char *core_file);
   SBProcess LoadCore(const char *core_file, lldb::SBError );
+  SBProcess LoadCore(SBFile , lldb::SBError );
 
   /// Launch a new process with sensible defaults.
   ///
@@ -326,7 +327,7 @@ class LLDB_API SBTarget {
   uint32_t GetAddressByteSize();
 
   const char *GetTriple();
-  
+
   const char *GetABIName();
 
   const char *GetLabel() const;
diff --git a/lldb/include/lldb/Target/PostMortemProcess.h 
b/lldb/include/lldb/Target/PostMortemProcess.h
index 7207fc99ef29a41..2bd775c9e2c5196 100644
--- a/lldb/include/lldb/Target/PostMortemProcess.h
+++ b/lldb/include/lldb/Target/PostMortemProcess.h
@@ -10,6 +10,8 @@
 #define LLDB_TARGET_POSTMORTEMPROCESS_H
 
 #include "lldb/Target/Process.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/lldb-forward.h"
 
 namespace lldb_private {
 
@@ -24,7 +26,20 @@ class PostMortemProcess : public Process {
   using Process::Process;
 
 public:
+  PostMortemProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
+lldb::FileSP file_sp)
+  : Process(target_sp, listener_sp), m_core_file(file_sp) {}
+
   bool IsLiveDebugSession() const override { return false; }
+
+  FileSpec GetCoreFile() const override {
+FileSpec file_spec;
+m_core_file->GetFileSpec(file_spec);
+return file_spec;
+  }
+
+protected:
+  lldb::FileSP m_core_file;
 };
 
 } // namespace lldb_private
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index a6d3e6c2d16926e..00d52a07bf33fb3 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -52,6 +52,7 @@
 #include "lldb/Utility/TraceGDBRemotePackets.h"
 #include "lldb/Utility/UnimplementedError.h"
 #include "lldb/Utility/UserIDResolver.h"
+#include "lldb/lldb-forward.h"
 #include "lldb/lldb-private.h"
 
 #include "llvm/ADT/ArrayRef.h"
@@ -354,11 +355,11 @@ class Process : public 
std::enable_shared_from_this,
   };
   // This is all the event bits the public process broadcaster broadcasts.
   // The process shadow listener signs up for all these bits...
-  static constexpr int g_all_event_bits = eBroadcastBitStateChanged 
+  static constexpr int g_all_event_bits = eBroadcastBitStateChanged
 | eBroadcastBitInterrupt
-| eBroadcastBitSTDOUT 
+| eBroadcastBitSTDOUT
 | eBroadcastBitSTDERR
-| eBroadcastBitProfileData 
+| eBroadcastBitProfileData
 | eBroadcastBitStructuredData;
 
   enum {
@@ -390,7 +391,7 @@ class Process : public 

[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-14 Thread Alex Langford via lldb-commits


@@ -1255,6 +1258,676 @@ class CommandObjectScriptingObject : public 
CommandObjectRaw {
   CompletionType m_completion_type = eNoCompletion;
 };
 
+
+/// This command implements a lldb parsed scripted command.  The command
+/// provides a definition of the options and arguments, and a option value
+/// setting callback, and then the command's execution function gets passed
+/// just the parsed arguments.
+/// Note, implementing a command in Python using these base interfaces is a bit
+/// of a pain, but it is much easier to export this low level interface, and
+/// then make it nicer on the Python side, than to try to do that in a
+/// script language neutral way.
+/// So I've also added a base class in Python that provides a table-driven
+/// way of defining the options and arguments, which automatically fills the
+/// option values, making them available as properties in Python.
+/// 
+class CommandObjectScriptingObjectParsed : public CommandObjectParsed {
+private: 
+  class CommandOptions : public Options {
+  public:
+CommandOptions(CommandInterpreter , 
+StructuredData::GenericSP cmd_obj_sp) : m_interpreter(interpreter), 
+m_cmd_obj_sp(cmd_obj_sp) {}
+
+~CommandOptions() override = default;
+
+Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+  ExecutionContext *execution_context) override {
+  Status error;
+  ScriptInterpreter *scripter = 
+m_interpreter.GetDebugger().GetScriptInterpreter();
+  if (!scripter) {
+error.SetErrorString("No script interpreter for SetOptionValue.");
+return error;
+  }
+  if (!m_cmd_obj_sp) {
+error.SetErrorString("SetOptionValue called with empty cmd_obj.");
+return error;
+  }
+  if (!m_options_definition_up) {
+error.SetErrorString("SetOptionValue called before options definitions 
"
+ "were created.");
+return error;
+  }
+  // Pass the long option, since you aren't actually required to have a
+  // short_option, and for those options the index or short option 
character
+  // aren't meaningful on the python side.
+  const char * long_option = 
+m_options_definition_up.get()[option_idx].long_option;
+  bool success = scripter->SetOptionValueForCommandObject(m_cmd_obj_sp, 
+execution_context, long_option, option_arg);
+  if (!success)
+error.SetErrorStringWithFormatv("Error setting option: {0} to {1}",
+long_option, option_arg);
+  return error;
+}
+
+void OptionParsingStarting(ExecutionContext *execution_context) override {
+  ScriptInterpreter *scripter = 
+m_interpreter.GetDebugger().GetScriptInterpreter();
+  if (!scripter) {
+return;
+  }
+  if (!m_cmd_obj_sp) {
+return;
+  }
+  scripter->OptionParsingStartedForCommandObject(m_cmd_obj_sp);
+};
+
+llvm::ArrayRef GetDefinitions() override {
+  if (!m_options_definition_up)
+return {};
+  return llvm::ArrayRef(m_options_definition_up.get(), m_num_options);
+}
+
+static bool ParseUsageMaskFromArray(StructuredData::ObjectSP obj_sp, 
+size_t counter, uint32_t _mask, Status ) {
+  // If the usage entry is not provided, we use LLDB_OPT_SET_ALL.
+  // If the usage mask is a UINT, the option belongs to that group.
+  // If the usage mask is a vector of UINT's, the option belongs to all the
+  // groups listed.
+  // If a subelement of the vector is a vector of two ints, then the option
+  // belongs to the inclusive range from the first to the second element.
+  if (!obj_sp) {
+usage_mask = LLDB_OPT_SET_ALL;
+return true;
+  }
+  
+  usage_mask = 0;
+  
+  StructuredData::UnsignedInteger *uint_val = 
+  obj_sp->GetAsUnsignedInteger();
+  if (uint_val) {
+// If this is an integer, then this specifies a single group:
+uint32_t value = uint_val->GetValue();
+if (value == 0) {
+  error.SetErrorStringWithFormatv(
+  "0 is not a valid group for option {0}", counter);
+  return false;
+}
+usage_mask = (1 << (value - 1));
+return true;
+  }
+  // Otherwise it has to be an array:
+  StructuredData::Array *array_val = obj_sp->GetAsArray();
+  if (!array_val) {
+error.SetErrorStringWithFormatv(
+"required field is not a array for option {0}", counter);
+return false;
+  }
+  // This is the array ForEach for accumulating a group usage mask from
+  // an array of string descriptions of groups.
+  auto groups_accumulator 
+  = [counter, _mask, ] 
+(StructuredData::Object *obj) -> bool {
+StructuredData::UnsignedInteger *int_val = obj->GetAsUnsignedInteger();
+if (int_val) {
+  uint32_t 

[Lldb-commits] [lldb] Add new API in SBTarget for loading core from SBFile (PR #71769)

2023-11-14 Thread via lldb-commits

https://github.com/GeorgeHuyubo updated 
https://github.com/llvm/llvm-project/pull/71769

>From 493be399a8d8e024769a9eba66d6a86192ff11e9 Mon Sep 17 00:00:00 2001
From: George Hu 
Date: Wed, 8 Nov 2023 16:25:34 -0800
Subject: [PATCH] Add new API in SBTarget for loading core from SBFile

---
 lldb/include/lldb/API/SBTarget.h  |  3 +-
 lldb/include/lldb/Target/PostMortemProcess.h  | 15 ++
 lldb/include/lldb/Target/Process.h| 36 +++--
 lldb/include/lldb/Target/ProcessTrace.h   |  5 +-
 lldb/include/lldb/Target/Target.h |  3 +-
 lldb/include/lldb/lldb-private-interfaces.h   |  7 +--
 lldb/source/API/SBTarget.cpp  | 41 +++
 lldb/source/Commands/CommandObjectTarget.cpp  | 50 ---
 lldb/source/Core/IOHandlerCursesGUI.cpp   | 13 -
 .../FreeBSDKernel/ProcessFreeBSDKernel.cpp| 27 ++
 .../FreeBSDKernel/ProcessFreeBSDKernel.h  |  8 +--
 .../Process/MacOSX-Kernel/ProcessKDP.cpp  |  4 +-
 .../Process/MacOSX-Kernel/ProcessKDP.h|  9 ++--
 .../Process/elf-core/ProcessElfCore.cpp   | 30 +--
 .../Plugins/Process/elf-core/ProcessElfCore.h | 12 ++---
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  9 ++--
 .../Process/gdb-remote/ProcessGDBRemote.h |  5 +-
 .../Process/mach-core/ProcessMachCore.cpp | 25 ++
 .../Process/mach-core/ProcessMachCore.h   | 11 ++--
 .../Process/minidump/ProcessMinidump.cpp  | 16 +++---
 .../Process/minidump/ProcessMinidump.h|  6 +--
 .../Process/scripted/ScriptedProcess.cpp  |  4 +-
 .../Process/scripted/ScriptedProcess.h|  2 +-
 lldb/source/Target/Process.cpp| 11 ++--
 lldb/source/Target/ProcessTrace.cpp   | 11 ++--
 lldb/source/Target/Target.cpp |  2 +-
 .../postmortem/elf-core/TestLinuxCore.py  | 16 ++
 .../Target/LocateModuleCallbackTest.cpp   |  3 +-
 28 files changed, 242 insertions(+), 142 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b4..fc6584ec15d5123 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -184,6 +184,7 @@ class LLDB_API SBTarget {
 
   SBProcess LoadCore(const char *core_file);
   SBProcess LoadCore(const char *core_file, lldb::SBError );
+  SBProcess LoadCore(SBFile , lldb::SBError );
 
   /// Launch a new process with sensible defaults.
   ///
@@ -326,7 +327,7 @@ class LLDB_API SBTarget {
   uint32_t GetAddressByteSize();
 
   const char *GetTriple();
-  
+
   const char *GetABIName();
 
   const char *GetLabel() const;
diff --git a/lldb/include/lldb/Target/PostMortemProcess.h 
b/lldb/include/lldb/Target/PostMortemProcess.h
index 7207fc99ef29a41..2bd775c9e2c5196 100644
--- a/lldb/include/lldb/Target/PostMortemProcess.h
+++ b/lldb/include/lldb/Target/PostMortemProcess.h
@@ -10,6 +10,8 @@
 #define LLDB_TARGET_POSTMORTEMPROCESS_H
 
 #include "lldb/Target/Process.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/lldb-forward.h"
 
 namespace lldb_private {
 
@@ -24,7 +26,20 @@ class PostMortemProcess : public Process {
   using Process::Process;
 
 public:
+  PostMortemProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
+lldb::FileSP file_sp)
+  : Process(target_sp, listener_sp), m_core_file(file_sp) {}
+
   bool IsLiveDebugSession() const override { return false; }
+
+  FileSpec GetCoreFile() const override {
+FileSpec file_spec;
+m_core_file->GetFileSpec(file_spec);
+return file_spec;
+  }
+
+protected:
+  lldb::FileSP m_core_file;
 };
 
 } // namespace lldb_private
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index a6d3e6c2d16926e..ac3547462a1fe65 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -52,6 +52,7 @@
 #include "lldb/Utility/TraceGDBRemotePackets.h"
 #include "lldb/Utility/UnimplementedError.h"
 #include "lldb/Utility/UserIDResolver.h"
+#include "lldb/lldb-forward.h"
 #include "lldb/lldb-private.h"
 
 #include "llvm/ADT/ArrayRef.h"
@@ -354,12 +355,10 @@ class Process : public 
std::enable_shared_from_this,
   };
   // This is all the event bits the public process broadcaster broadcasts.
   // The process shadow listener signs up for all these bits...
-  static constexpr int g_all_event_bits = eBroadcastBitStateChanged 
-| eBroadcastBitInterrupt
-| eBroadcastBitSTDOUT 
-| eBroadcastBitSTDERR
-| eBroadcastBitProfileData 
-| eBroadcastBitStructuredData;
+  static constexpr int g_all_event_bits =
+  eBroadcastBitStateChanged | eBroadcastBitInterrupt | eBroadcastBitSTDOUT 
|
+  eBroadcastBitSTDERR | eBroadcastBitProfileData |
+  eBroadcastBitStructuredData;
 
   enum {
 

[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-14 Thread Alex Langford via lldb-commits


@@ -2755,6 +2755,58 @@ bool ScriptInterpreterPythonImpl::RunScriptBasedCommand(
   return ret_val;
 }
 
+bool ScriptInterpreterPythonImpl::RunScriptBasedParsedCommand(
+StructuredData::GenericSP impl_obj_sp, Args ,
+ScriptedCommandSynchronicity synchronicity,
+lldb_private::CommandReturnObject _retobj, Status ,

bulbazord wrote:

Makes sense to me.

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-14 Thread Alex Langford via lldb-commits


@@ -476,6 +476,14 @@ class ScriptInterpreter : public PluginInterface {
 return false;
   }
 
+  virtual bool RunScriptBasedParsedCommand(
+  StructuredData::GenericSP impl_obj_sp, Args& args,
+  ScriptedCommandSynchronicity synchronicity,
+  lldb_private::CommandReturnObject _retobj, Status ,

bulbazord wrote:

Agreed.

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-14 Thread Alex Langford via lldb-commits


@@ -0,0 +1,315 @@
+"""
+This module implements a couple of utility classes to make writing
+lldb parsed commands more Pythonic.
+The way to use it is to make a class for you command that inherits from 
ParsedCommandBase.
+That will make an LLDBOVParser which you will use for your
+option definition, and to fetch option values for the current invocation
+of your command.  Access to the OV parser is through:
+
+ParsedCommandBase.get_parser()
+
+Next, implement setup_command_definition in your new command class, and call:
+
+  self.get_parser().add_option
+
+to add all your options.  The order doesn't matter for options, lldb will sort 
them
+alphabetically for you when it prints help.
+
+Similarly you can define the arguments with:
+
+  self.get_parser.add_argument
+
+at present, lldb doesn't do as much work as it should verifying arguments, it 
pretty
+much only checks that commands that take no arguments don't get passed 
arguments.
+
+Then implement the execute function for your command as:
+
+def __call__(self, debugger, args_array, exe_ctx, result):
+
+The arguments will be in a python array as strings.  
+
+You can access the option values using varname you passed in when defining the 
option.  
+If you need to know whether a given option was set by the user or not, you can 
retrieve 
+the option definition array with:
+
+  self.get_options_definition()
+
+look up your element by varname and check the "_value_set" element.
+
+There are example commands in the lldb testsuite at:
+
+llvm-project/lldb/test/API/commands/command/script/add/test_commands.py
+
+FIXME: I should make a convenient wrapper for that. 
+"""
+import inspect
+import lldb
+import sys
+
+class LLDBOVParser:
+def __init__(self):
+self.options_array = []
+self.args_array = []
+
+# Some methods to translate common value types.  Should return a
+# tuple of the value and an error value (True => error) if the
+# type can't be converted.
+# FIXME: Need a way to push the conversion error string back to lldb.
+@staticmethod
+def to_bool(in_value):
+error = True
+value = False
+low_in = in_value.lower()
+if low_in == "yes" or low_in == "true" or low_in == "1":
+value = True
+error = False
+
+if not value and low_in == "no" or low_in == "false" or low_in == "0":
+value = False
+error = False
+
+return (value, error)
+
+@staticmethod
+def to_int(in_value):
+#FIXME: Not doing errors yet...
+return (int(in_value), False)
+
+def to_unsigned(in_value):
+# FIXME: find an unsigned converter...
+# And handle errors.
+return (int(in_value), False)
+
+translators = {
+lldb.eArgTypeBoolean : to_bool,
+lldb.eArgTypeBreakpointID : to_unsigned,
+lldb.eArgTypeByteSize : to_unsigned,
+lldb.eArgTypeCount : to_unsigned,
+lldb.eArgTypeFrameIndex : to_unsigned,
+lldb.eArgTypeIndex : to_unsigned,
+lldb.eArgTypeLineNum : to_unsigned,
+lldb.eArgTypeNumLines : to_unsigned,
+lldb.eArgTypeNumberPerLine : to_unsigned,
+lldb.eArgTypeOffset : to_int,
+lldb.eArgTypeThreadIndex : to_unsigned,
+lldb.eArgTypeUnsignedInteger : to_unsigned,
+lldb.eArgTypeWatchpointID : to_unsigned,
+lldb.eArgTypeColumnNum : to_unsigned,
+lldb.eArgTypeRecognizerID : to_unsigned,
+lldb.eArgTypeTargetID : to_unsigned,
+lldb.eArgTypeStopHookID : to_unsigned
+}
+
+@classmethod
+def translate_value(cls, value_type, value):
+error = False
+try:
+return cls.translators[value_type](value)
+except KeyError:
+# If we don't have a translator, return the string value.
+return (value, False)
+
+# FIXME: would this be better done on the C++ side?
+# The common completers are missing some useful ones.
+# For instance there really should be a common Type completer
+# And an "lldb command name" completer.
+completion_table = {
+lldb.eArgTypeAddressOrExpression : lldb.eVariablePathCompletion,
+lldb.eArgTypeArchitecture : lldb.eArchitectureCompletion,
+lldb.eArgTypeBreakpointID : lldb.eBreakpointCompletion,
+lldb.eArgTypeBreakpointIDRange : lldb.eBreakpointCompletion,
+lldb.eArgTypeBreakpointName : lldb.eBreakpointNameCompletion,
+lldb.eArgTypeClassName : lldb.eSymbolCompletion,
+lldb.eArgTypeDirectoryName : lldb.eDiskDirectoryCompletion,
+lldb.eArgTypeExpression : lldb.eVariablePathCompletion,
+lldb.eArgTypeExpressionPath : lldb.eVariablePathCompletion,
+lldb.eArgTypeFilename : lldb.eDiskFileCompletion,
+lldb.eArgTypeFrameIndex : lldb.eFrameIndexCompletion,
+lldb.eArgTypeFunctionName : lldb.eSymbolCompletion,
+lldb.eArgTypeFunctionOrSymbol : 

[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-14 Thread Alex Langford via lldb-commits


@@ -0,0 +1,315 @@
+"""
+This module implements a couple of utility classes to make writing
+lldb parsed commands more Pythonic.
+The way to use it is to make a class for you command that inherits from 
ParsedCommandBase.
+That will make an LLDBOVParser which you will use for your
+option definition, and to fetch option values for the current invocation
+of your command.  Access to the OV parser is through:
+
+ParsedCommandBase.get_parser()
+
+Next, implement setup_command_definition in your new command class, and call:
+
+  self.get_parser().add_option
+
+to add all your options.  The order doesn't matter for options, lldb will sort 
them
+alphabetically for you when it prints help.
+
+Similarly you can define the arguments with:
+
+  self.get_parser.add_argument
+
+at present, lldb doesn't do as much work as it should verifying arguments, it 
pretty
+much only checks that commands that take no arguments don't get passed 
arguments.
+
+Then implement the execute function for your command as:
+
+def __call__(self, debugger, args_array, exe_ctx, result):
+
+The arguments will be in a python array as strings.  
+
+You can access the option values using varname you passed in when defining the 
option.  
+If you need to know whether a given option was set by the user or not, you can 
retrieve 
+the option definition array with:
+
+  self.get_options_definition()
+
+look up your element by varname and check the "_value_set" element.
+
+There are example commands in the lldb testsuite at:
+
+llvm-project/lldb/test/API/commands/command/script/add/test_commands.py
+
+FIXME: I should make a convenient wrapper for that. 
+"""
+import inspect
+import lldb
+import sys
+
+class LLDBOVParser:
+def __init__(self):
+self.options_array = []
+self.args_array = []
+
+# Some methods to translate common value types.  Should return a
+# tuple of the value and an error value (True => error) if the
+# type can't be converted.
+# FIXME: Need a way to push the conversion error string back to lldb.
+@staticmethod
+def to_bool(in_value):
+error = True
+value = False
+low_in = in_value.lower()
+if low_in == "yes" or low_in == "true" or low_in == "1":
+value = True
+error = False
+
+if not value and low_in == "no" or low_in == "false" or low_in == "0":
+value = False
+error = False
+
+return (value, error)
+
+@staticmethod
+def to_int(in_value):
+#FIXME: Not doing errors yet...
+return (int(in_value), False)
+
+def to_unsigned(in_value):
+# FIXME: find an unsigned converter...
+# And handle errors.
+return (int(in_value), False)
+
+translators = {
+lldb.eArgTypeBoolean : to_bool,
+lldb.eArgTypeBreakpointID : to_unsigned,
+lldb.eArgTypeByteSize : to_unsigned,
+lldb.eArgTypeCount : to_unsigned,
+lldb.eArgTypeFrameIndex : to_unsigned,
+lldb.eArgTypeIndex : to_unsigned,
+lldb.eArgTypeLineNum : to_unsigned,
+lldb.eArgTypeNumLines : to_unsigned,
+lldb.eArgTypeNumberPerLine : to_unsigned,
+lldb.eArgTypeOffset : to_int,
+lldb.eArgTypeThreadIndex : to_unsigned,
+lldb.eArgTypeUnsignedInteger : to_unsigned,
+lldb.eArgTypeWatchpointID : to_unsigned,
+lldb.eArgTypeColumnNum : to_unsigned,
+lldb.eArgTypeRecognizerID : to_unsigned,
+lldb.eArgTypeTargetID : to_unsigned,
+lldb.eArgTypeStopHookID : to_unsigned
+}
+
+@classmethod
+def translate_value(cls, value_type, value):
+error = False
+try:
+return cls.translators[value_type](value)
+except KeyError:
+# If we don't have a translator, return the string value.
+return (value, False)
+
+# FIXME: would this be better done on the C++ side?
+# The common completers are missing some useful ones.
+# For instance there really should be a common Type completer
+# And an "lldb command name" completer.
+completion_table = {
+lldb.eArgTypeAddressOrExpression : lldb.eVariablePathCompletion,
+lldb.eArgTypeArchitecture : lldb.eArchitectureCompletion,
+lldb.eArgTypeBreakpointID : lldb.eBreakpointCompletion,
+lldb.eArgTypeBreakpointIDRange : lldb.eBreakpointCompletion,
+lldb.eArgTypeBreakpointName : lldb.eBreakpointNameCompletion,
+lldb.eArgTypeClassName : lldb.eSymbolCompletion,
+lldb.eArgTypeDirectoryName : lldb.eDiskDirectoryCompletion,
+lldb.eArgTypeExpression : lldb.eVariablePathCompletion,
+lldb.eArgTypeExpressionPath : lldb.eVariablePathCompletion,
+lldb.eArgTypeFilename : lldb.eDiskFileCompletion,
+lldb.eArgTypeFrameIndex : lldb.eFrameIndexCompletion,
+lldb.eArgTypeFunctionName : lldb.eSymbolCompletion,
+lldb.eArgTypeFunctionOrSymbol : 

[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-14 Thread Alex Langford via lldb-commits


@@ -0,0 +1,315 @@
+"""
+This module implements a couple of utility classes to make writing
+lldb parsed commands more Pythonic.
+The way to use it is to make a class for you command that inherits from 
ParsedCommandBase.
+That will make an LLDBOVParser which you will use for your
+option definition, and to fetch option values for the current invocation
+of your command.  Access to the OV parser is through:
+
+ParsedCommandBase.get_parser()
+
+Next, implement setup_command_definition in your new command class, and call:
+
+  self.get_parser().add_option
+
+to add all your options.  The order doesn't matter for options, lldb will sort 
them
+alphabetically for you when it prints help.
+
+Similarly you can define the arguments with:
+
+  self.get_parser.add_argument
+
+at present, lldb doesn't do as much work as it should verifying arguments, it 
pretty
+much only checks that commands that take no arguments don't get passed 
arguments.
+
+Then implement the execute function for your command as:
+
+def __call__(self, debugger, args_array, exe_ctx, result):
+
+The arguments will be in a python array as strings.  
+
+You can access the option values using varname you passed in when defining the 
option.  
+If you need to know whether a given option was set by the user or not, you can 
retrieve 
+the option definition array with:
+
+  self.get_options_definition()
+
+look up your element by varname and check the "_value_set" element.
+
+There are example commands in the lldb testsuite at:
+
+llvm-project/lldb/test/API/commands/command/script/add/test_commands.py
+
+FIXME: I should make a convenient wrapper for that. 
+"""
+import inspect
+import lldb
+import sys
+
+class LLDBOVParser:
+def __init__(self):
+self.options_array = []
+self.args_array = []
+
+# Some methods to translate common value types.  Should return a
+# tuple of the value and an error value (True => error) if the
+# type can't be converted.
+# FIXME: Need a way to push the conversion error string back to lldb.
+@staticmethod
+def to_bool(in_value):
+error = True
+value = False
+low_in = in_value.lower()
+if low_in == "yes" or low_in == "true" or low_in == "1":
+value = True
+error = False
+
+if not value and low_in == "no" or low_in == "false" or low_in == "0":
+value = False
+error = False
+
+return (value, error)
+
+@staticmethod
+def to_int(in_value):
+#FIXME: Not doing errors yet...
+return (int(in_value), False)
+
+def to_unsigned(in_value):
+# FIXME: find an unsigned converter...
+# And handle errors.
+return (int(in_value), False)
+
+translators = {
+lldb.eArgTypeBoolean : to_bool,
+lldb.eArgTypeBreakpointID : to_unsigned,
+lldb.eArgTypeByteSize : to_unsigned,
+lldb.eArgTypeCount : to_unsigned,
+lldb.eArgTypeFrameIndex : to_unsigned,
+lldb.eArgTypeIndex : to_unsigned,
+lldb.eArgTypeLineNum : to_unsigned,
+lldb.eArgTypeNumLines : to_unsigned,
+lldb.eArgTypeNumberPerLine : to_unsigned,
+lldb.eArgTypeOffset : to_int,
+lldb.eArgTypeThreadIndex : to_unsigned,
+lldb.eArgTypeUnsignedInteger : to_unsigned,
+lldb.eArgTypeWatchpointID : to_unsigned,
+lldb.eArgTypeColumnNum : to_unsigned,
+lldb.eArgTypeRecognizerID : to_unsigned,
+lldb.eArgTypeTargetID : to_unsigned,
+lldb.eArgTypeStopHookID : to_unsigned
+}
+
+@classmethod
+def translate_value(cls, value_type, value):
+error = False
+try:
+return cls.translators[value_type](value)
+except KeyError:
+# If we don't have a translator, return the string value.
+return (value, False)
+
+# FIXME: would this be better done on the C++ side?
+# The common completers are missing some useful ones.
+# For instance there really should be a common Type completer
+# And an "lldb command name" completer.
+completion_table = {

bulbazord wrote:

Is doing it in C++ independent of this change? I think it would be worth 
writing more about this (either in the FIXME or in a GitHub issue). I've been 
slowly learning and understanding how CommandObjects work but I have very 
little knowledge on the completer machinery.


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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-14 Thread Alex Langford via lldb-commits


@@ -0,0 +1,315 @@
+"""
+This module implements a couple of utility classes to make writing
+lldb parsed commands more Pythonic.
+The way to use it is to make a class for you command that inherits from 
ParsedCommandBase.
+That will make an LLDBOVParser which you will use for your
+option definition, and to fetch option values for the current invocation
+of your command.  Access to the OV parser is through:
+
+ParsedCommandBase.get_parser()
+
+Next, implement setup_command_definition in your new command class, and call:
+
+  self.get_parser().add_option
+
+to add all your options.  The order doesn't matter for options, lldb will sort 
them
+alphabetically for you when it prints help.
+
+Similarly you can define the arguments with:
+
+  self.get_parser.add_argument
+
+at present, lldb doesn't do as much work as it should verifying arguments, it 
pretty
+much only checks that commands that take no arguments don't get passed 
arguments.
+
+Then implement the execute function for your command as:
+
+def __call__(self, debugger, args_array, exe_ctx, result):
+
+The arguments will be in a python array as strings.  
+
+You can access the option values using varname you passed in when defining the 
option.  
+If you need to know whether a given option was set by the user or not, you can 
retrieve 
+the option definition array with:
+
+  self.get_options_definition()
+
+look up your element by varname and check the "_value_set" element.
+
+There are example commands in the lldb testsuite at:
+
+llvm-project/lldb/test/API/commands/command/script/add/test_commands.py
+
+FIXME: I should make a convenient wrapper for that. 
+"""
+import inspect
+import lldb
+import sys
+
+class LLDBOVParser:
+def __init__(self):
+self.options_array = []
+self.args_array = []
+
+# Some methods to translate common value types.  Should return a
+# tuple of the value and an error value (True => error) if the
+# type can't be converted.
+# FIXME: Need a way to push the conversion error string back to lldb.
+@staticmethod
+def to_bool(in_value):
+error = True
+value = False
+low_in = in_value.lower()
+if low_in == "yes" or low_in == "true" or low_in == "1":
+value = True
+error = False
+
+if not value and low_in == "no" or low_in == "false" or low_in == "0":
+value = False
+error = False
+
+return (value, error)
+
+@staticmethod
+def to_int(in_value):
+#FIXME: Not doing errors yet...
+return (int(in_value), False)
+
+def to_unsigned(in_value):
+# FIXME: find an unsigned converter...
+# And handle errors.
+return (int(in_value), False)
+
+translators = {
+lldb.eArgTypeBoolean : to_bool,
+lldb.eArgTypeBreakpointID : to_unsigned,
+lldb.eArgTypeByteSize : to_unsigned,
+lldb.eArgTypeCount : to_unsigned,
+lldb.eArgTypeFrameIndex : to_unsigned,
+lldb.eArgTypeIndex : to_unsigned,
+lldb.eArgTypeLineNum : to_unsigned,
+lldb.eArgTypeNumLines : to_unsigned,
+lldb.eArgTypeNumberPerLine : to_unsigned,
+lldb.eArgTypeOffset : to_int,
+lldb.eArgTypeThreadIndex : to_unsigned,
+lldb.eArgTypeUnsignedInteger : to_unsigned,
+lldb.eArgTypeWatchpointID : to_unsigned,
+lldb.eArgTypeColumnNum : to_unsigned,
+lldb.eArgTypeRecognizerID : to_unsigned,
+lldb.eArgTypeTargetID : to_unsigned,
+lldb.eArgTypeStopHookID : to_unsigned
+}
+
+@classmethod
+def translate_value(cls, value_type, value):
+error = False
+try:
+return cls.translators[value_type](value)
+except KeyError:
+# If we don't have a translator, return the string value.
+return (value, False)

bulbazord wrote:

I think I missed that the first time I read this. Thanks for clarifying.

I wonder if it might be worth introducing a `NamedTuple` type representing this 
if it's going to be the interface we go with?

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-14 Thread Alex Langford via lldb-commits


@@ -0,0 +1,315 @@
+"""
+This module implements a couple of utility classes to make writing
+lldb parsed commands more Pythonic.
+The way to use it is to make a class for you command that inherits from 
ParsedCommandBase.
+That will make an LLDBOVParser which you will use for your
+option definition, and to fetch option values for the current invocation
+of your command.  Access to the OV parser is through:
+
+ParsedCommandBase.get_parser()
+
+Next, implement setup_command_definition in your new command class, and call:
+
+  self.get_parser().add_option
+
+to add all your options.  The order doesn't matter for options, lldb will sort 
them
+alphabetically for you when it prints help.
+
+Similarly you can define the arguments with:
+
+  self.get_parser.add_argument
+
+at present, lldb doesn't do as much work as it should verifying arguments, it 
pretty
+much only checks that commands that take no arguments don't get passed 
arguments.
+
+Then implement the execute function for your command as:
+
+def __call__(self, debugger, args_array, exe_ctx, result):
+
+The arguments will be in a python array as strings.  
+
+You can access the option values using varname you passed in when defining the 
option.  
+If you need to know whether a given option was set by the user or not, you can 
retrieve 
+the option definition array with:
+
+  self.get_options_definition()
+
+look up your element by varname and check the "_value_set" element.
+
+There are example commands in the lldb testsuite at:
+
+llvm-project/lldb/test/API/commands/command/script/add/test_commands.py
+
+FIXME: I should make a convenient wrapper for that. 
+"""
+import inspect
+import lldb
+import sys
+
+class LLDBOVParser:
+def __init__(self):
+self.options_array = []
+self.args_array = []
+
+# Some methods to translate common value types.  Should return a
+# tuple of the value and an error value (True => error) if the
+# type can't be converted.
+# FIXME: Need a way to push the conversion error string back to lldb.

bulbazord wrote:

We don't do it often but there is prior art. Specifically in a few of our SBAPI 
extensions, such as SBAddress and SBData. My $0.02 is that it's worth making 
these interfaces more pythonic since people will want to write their own 
commands with python.

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


[Lldb-commits] [lldb] Add support for arm64 registers in minidump core file saving. (PR #72315)

2023-11-14 Thread Greg Clayton via lldb-commits

clayborg wrote:

@antmox Hopefully this clears up the issue on the build bot! Thanks for testing 
this for me.

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


[Lldb-commits] [lldb] Add support for arm64 registers in minidump core file saving. (PR #72315)

2023-11-14 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] beb702c - Add support for arm64 registers in minidump core file saving. (#72315)

2023-11-14 Thread via lldb-commits

Author: Greg Clayton
Date: 2023-11-14T16:49:44-08:00
New Revision: beb702c0ad69244da6caedca9a0f3c6ee42e5bae

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

LOG: Add support for arm64 registers in minidump core file saving. (#72315)

This patch adds support for saving minidumps with the arm64
architecture. It also will cause unsupported architectures to emit an
error where before this patch it would emit a minidump with partial
information. This new code is tested by the arm64 windows buildbot that
was failing:

https://lab.llvm.org/buildbot/#/builders/219/builds/6868

This is needed following this PR:
https://github.com/llvm/llvm-project/pull/71772

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.cpp
lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index e8e0d09b5324d0f..50d1b563f469cf8 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -8,6 +8,7 @@
 
 #include "MinidumpFileBuilder.h"
 
+#include "Plugins/Process/minidump/RegisterContextMinidump_ARM64.h"
 #include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h"
 
 #include "lldb/Core/Module.h"
@@ -293,7 +294,7 @@ Status MinidumpFileBuilder::AddModuleList(Target ) {
 }
 
 uint16_t read_register_u16_raw(RegisterContext *reg_ctx,
-   const std::string _name) {
+   llvm::StringRef reg_name) {
   const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
   if (!reg_info)
 return 0;
@@ -305,7 +306,7 @@ uint16_t read_register_u16_raw(RegisterContext *reg_ctx,
 }
 
 uint32_t read_register_u32_raw(RegisterContext *reg_ctx,
-   const std::string _name) {
+   llvm::StringRef reg_name) {
   const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
   if (!reg_info)
 return 0;
@@ -317,7 +318,7 @@ uint32_t read_register_u32_raw(RegisterContext *reg_ctx,
 }
 
 uint64_t read_register_u64_raw(RegisterContext *reg_ctx,
-   const std::string _name) {
+   llvm::StringRef reg_name) {
   const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
   if (!reg_info)
 return 0;
@@ -329,25 +330,42 @@ uint64_t read_register_u64_raw(RegisterContext *reg_ctx,
 }
 
 llvm::support::ulittle16_t read_register_u16(RegisterContext *reg_ctx,
- const std::string _name) {
+ llvm::StringRef reg_name) {
   return static_cast(
   read_register_u16_raw(reg_ctx, reg_name));
 }
 
 llvm::support::ulittle32_t read_register_u32(RegisterContext *reg_ctx,
- const std::string _name) {
+ llvm::StringRef reg_name) {
   return static_cast(
   read_register_u32_raw(reg_ctx, reg_name));
 }
 
 llvm::support::ulittle64_t read_register_u64(RegisterContext *reg_ctx,
- const std::string _name) {
+ llvm::StringRef reg_name) {
   return static_cast(
   read_register_u64_raw(reg_ctx, reg_name));
 }
 
+void read_register_u128(RegisterContext *reg_ctx, llvm::StringRef reg_name,
+uint8_t *dst) {
+  const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
+  if (reg_info) {
+lldb_private::RegisterValue reg_value;
+if (reg_ctx->ReadRegister(reg_info, reg_value)) {
+  Status error;
+  uint32_t bytes_copied = reg_value.GetAsMemoryData(
+  *reg_info, dst, 16, lldb::ByteOrder::eByteOrderLittle, error);
+  if (bytes_copied == 16)
+return;
+}
+  }
+  // If anything goes wrong, then zero out the register value.
+  memset(dst, 0, 16);
+}
+
 lldb_private::minidump::MinidumpContext_x86_64
-GetThreadContext_64(RegisterContext *reg_ctx) {
+GetThreadContext_x86_64(RegisterContext *reg_ctx) {
   lldb_private::minidump::MinidumpContext_x86_64 thread_context = {};
   thread_context.p1_home = {};
   thread_context.context_flags = static_cast(
@@ -381,6 +399,71 @@ GetThreadContext_64(RegisterContext *reg_ctx) {
   return thread_context;
 }
 
+minidump::RegisterContextMinidump_ARM64::Context
+GetThreadContext_ARM64(RegisterContext *reg_ctx) {
+  

[Lldb-commits] [lldb] Add support for arm64 registers in minidump core file saving. (PR #72315)

2023-11-14 Thread antoine moynault via lldb-commits

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


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


[Lldb-commits] [lldb] Add support for arm64 registers in minidump core file saving. (PR #72315)

2023-11-14 Thread Greg Clayton via lldb-commits

clayborg wrote:

> LGTM. minidump tests are now OK on linaro-armv8-windows-msvc machine.

Feel free to accept this patch then and I can get it merged!


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


[Lldb-commits] [lldb] Add support for arm64 registers in minidump core file saving. (PR #72315)

2023-11-14 Thread antoine moynault via lldb-commits

antmox wrote:

LGTM. minidump tests are now OK on linaro-armv8-windows-msvc machine.


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


[Lldb-commits] [lldb] [llvm] Emit DIE's size in bits when size is not a multiple of 8 (PR #69741)

2023-11-14 Thread David Blaikie via lldb-commits

dwblaikie wrote:

> > I guess one question that might be relevant - does Swift have something 
> > like sizeof and what result does it give for these sort of types with bits 
> > to spare?
> 
> You can't actually use that with these types as these are special compiler 
> builtin types which aren't actually accessible in source code.

Perhaps observable indirectly?
 
> > But like I said - it seems like structs with tail padding are similar to 
> > this situation - we still describe the whole size of the struct, because 
> > that's used for creating arrays of instances, ABI passing, etc. But the 
> > tail padding can still be used, in certain circumstances, when laying out a 
> > derived class. We encode this as the POD-ness of the type, and so if you 
> > wanted to create a class that derived from one described in DWARF you could 
> > do so & would know whether or not to put the derived class's members into 
> > the tail padding of the base or not.
> 
> I understand the rationale of basing this on precedent, but in this case in 
> this case we should break from it for two reasons:
> 
> * DW_AT_BIT_SIZE is already a standardized attribute in Dwarf that fits this 
> use case.

I'm arguing it doesn't fit it particularly well. We use it for bit fields - 
which are pretty special, for instance, but it seems like this thing isn't 
quite like that - it does have a whole byte size (if you allocated an array of 
them, for instance, I'm guessing they're a byte each, right?) but then has some 
padding bits that can be reused in some circumstances? That's why I'm saying it 
seems like it fits more closely to the struct padding representation.

> * Round up to the nearest byte would lose information, which can be kept with 
> fairly minimal downsides in my opinion.

Seems like it'd still need to be special cased, right? The consumer would go 
"oh, this has a bit size, but if we want an array of them, or to allocate them 
for ABI purposes, etc, I have to round it up to the nearest byte"? or something 
like that.

Some pointers to documentation about these types, and the range of 
uses/instances there are might be handy (like is this a general concept? Or is 
it only one type that uses this (`bool` equivalent, with 7 padding bytes 
unused) or a class of types (a small finite list of them? Unbounded (like if I 
put a bool in my custom struct - does my custom struct end up with a bit size 
too?))

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


[Lldb-commits] [lldb] [llvm] Emit DIE's size in bits when size is not a multiple of 8 (PR #69741)

2023-11-14 Thread Augusto Noronha via lldb-commits

augusto2112 wrote:

> I guess one question that might be relevant - does Swift have something like 
> sizeof and what result does it give for these sort of types with bits to 
> spare?

You can't actually use that with these types as these are special compiler 
builtin types which aren't actually accessible in source code.

> But like I said - it seems like structs with tail padding are similar to this 
> situation - we still describe the whole size of the struct, because that's 
> used for creating arrays of instances, ABI passing, etc. But the tail padding 
> can still be used, in certain circumstances, when laying out a derived class. 
> We encode this as the POD-ness of the type, and so if you wanted to create a 
> class that derived from one described in DWARF you could do so & would know 
> whether or not to put the derived class's members into the tail padding of 
> the base or not.

I understand the rationale of basing this on precedent, but in this case in 
this case we should break from it for two reasons:

- DW_AT_BIT_SIZE is already a standardized attribute in Dwarf that fits this 
use case.
- Round up to the nearest byte would lose information, which can be kept with 
fairly minimal downsides in my opinion.

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


[Lldb-commits] [lldb] Centralize the code that figures out which memory ranges to save into core files (PR #71772)

2023-11-14 Thread antoine moynault via lldb-commits

antmox wrote:

@clayborg yes sure I will test this on the same machine

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


[Lldb-commits] [lldb] Add support for arm64 registers in minidump core file saving. (PR #72315)

2023-11-14 Thread Greg Clayton via lldb-commits

https://github.com/clayborg updated 
https://github.com/llvm/llvm-project/pull/72315

>From dd4dd79853566049874f49d1290217f5abde23fd Mon Sep 17 00:00:00 2001
From: Greg Clayton 
Date: Tue, 14 Nov 2023 13:53:25 -0800
Subject: [PATCH 1/2] Add support for arm64 registers in minidump core file
 saving.

This patch adds support for saving minidumps with the arm64 architecture. It 
also will cause unsupported architectures to emit an error where before this 
patch it would emit a minidump with partial information. This new code is 
tested by the arm64 windows buildbot that was failing:

https://lab.llvm.org/buildbot/#/builders/219/builds/6868

This is needed following this PR: 
https://github.com/llvm/llvm-project/pull/71772
---
 .../Minidump/MinidumpFileBuilder.cpp  | 225 --
 .../ObjectFile/Minidump/MinidumpFileBuilder.h |  12 +-
 .../Minidump/ObjectFileMinidump.cpp   |  23 +-
 .../minidump/RegisterContextMinidump_ARM64.h  |   2 +-
 4 files changed, 173 insertions(+), 89 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index e8e0d09b5324d0f..8699479cadb36ad 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -9,6 +9,7 @@
 #include "MinidumpFileBuilder.h"
 
 #include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h"
+#include "Plugins/Process/minidump/RegisterContextMinidump_ARM64.h"
 
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
@@ -293,7 +294,7 @@ Status MinidumpFileBuilder::AddModuleList(Target ) {
 }
 
 uint16_t read_register_u16_raw(RegisterContext *reg_ctx,
-   const std::string _name) {
+   llvm::StringRef reg_name) {
   const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
   if (!reg_info)
 return 0;
@@ -305,7 +306,7 @@ uint16_t read_register_u16_raw(RegisterContext *reg_ctx,
 }
 
 uint32_t read_register_u32_raw(RegisterContext *reg_ctx,
-   const std::string _name) {
+   llvm::StringRef reg_name) {
   const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
   if (!reg_info)
 return 0;
@@ -317,7 +318,7 @@ uint32_t read_register_u32_raw(RegisterContext *reg_ctx,
 }
 
 uint64_t read_register_u64_raw(RegisterContext *reg_ctx,
-   const std::string _name) {
+   llvm::StringRef reg_name) {
   const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
   if (!reg_info)
 return 0;
@@ -329,25 +330,44 @@ uint64_t read_register_u64_raw(RegisterContext *reg_ctx,
 }
 
 llvm::support::ulittle16_t read_register_u16(RegisterContext *reg_ctx,
- const std::string _name) {
+ llvm::StringRef reg_name) {
   return static_cast(
   read_register_u16_raw(reg_ctx, reg_name));
 }
 
 llvm::support::ulittle32_t read_register_u32(RegisterContext *reg_ctx,
- const std::string _name) {
+ llvm::StringRef reg_name) {
   return static_cast(
   read_register_u32_raw(reg_ctx, reg_name));
 }
 
 llvm::support::ulittle64_t read_register_u64(RegisterContext *reg_ctx,
- const std::string _name) {
+ llvm::StringRef reg_name) {
   return static_cast(
   read_register_u64_raw(reg_ctx, reg_name));
 }
 
+void read_register_u128(RegisterContext *reg_ctx, llvm::StringRef reg_name,
+uint8_t *dst) {
+  const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
+  if (reg_info) {
+lldb_private::RegisterValue reg_value;
+if (reg_ctx->ReadRegister(reg_info, reg_value)) {
+  Status error;
+  uint32_t bytes_copied =
+  reg_value.GetAsMemoryData(*reg_info, dst, 16,
+lldb::ByteOrder::eByteOrderLittle,
+error);
+  if (bytes_copied == 16)
+return;
+}
+  }
+  // If anything goes wrong, then zero out the register value.
+  memset(dst, 0, 16);
+}
+
 lldb_private::minidump::MinidumpContext_x86_64
-GetThreadContext_64(RegisterContext *reg_ctx) {
+GetThreadContext_x86_64(RegisterContext *reg_ctx) {
   lldb_private::minidump::MinidumpContext_x86_64 thread_context = {};
   thread_context.p1_home = {};
   thread_context.context_flags = static_cast(
@@ -381,6 +401,73 @@ GetThreadContext_64(RegisterContext *reg_ctx) {
   return thread_context;
 }
 
+minidump::RegisterContextMinidump_ARM64::Context
+GetThreadContext_ARM64(RegisterContext *reg_ctx) {
+  minidump::RegisterContextMinidump_ARM64::Context thread_context = {};
+  thread_context.context_flags = 

[Lldb-commits] [lldb] Add support for arm64 registers in minidump core file saving. (PR #72315)

2023-11-14 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 447af1ce99c066169c5ea85a23963e8d3d93124a 
dd4dd79853566049874f49d1290217f5abde23fd -- 
lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h 
lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.cpp 
lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index 8699479cad..50d1b563f4 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -8,8 +8,8 @@
 
 #include "MinidumpFileBuilder.h"
 
-#include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h"
 #include "Plugins/Process/minidump/RegisterContextMinidump_ARM64.h"
+#include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h"
 
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
@@ -354,10 +354,8 @@ void read_register_u128(RegisterContext *reg_ctx, 
llvm::StringRef reg_name,
 lldb_private::RegisterValue reg_value;
 if (reg_ctx->ReadRegister(reg_info, reg_value)) {
   Status error;
-  uint32_t bytes_copied =
-  reg_value.GetAsMemoryData(*reg_info, dst, 16,
-lldb::ByteOrder::eByteOrderLittle,
-error);
+  uint32_t bytes_copied = reg_value.GetAsMemoryData(
+  *reg_info, dst, 16, lldb::ByteOrder::eByteOrderLittle, error);
   if (bytes_copied == 16)
 return;
 }
@@ -409,7 +407,7 @@ GetThreadContext_ARM64(RegisterContext *reg_ctx) {
   minidump::RegisterContextMinidump_ARM64::Flags::Integer |
   minidump::RegisterContextMinidump_ARM64::Flags::FloatingPoint);
   char reg_name[16];
-  for (uint32_t i=0; i<31; ++i) {
+  for (uint32_t i = 0; i < 31; ++i) {
 snprintf(reg_name, sizeof(reg_name), "x%u", i);
 thread_context.x[i] = read_register_u64(reg_ctx, reg_name);
   }
@@ -420,9 +418,9 @@ GetThreadContext_ARM64(RegisterContext *reg_ctx) {
   thread_context.cpsr = read_register_u32(reg_ctx, "cpsr");
   thread_context.fpsr = read_register_u32(reg_ctx, "fpsr");
   thread_context.fpcr = read_register_u32(reg_ctx, "fpcr");
-  for (uint32_t i=0; i<32; ++i) {
+  for (uint32_t i = 0; i < 32; ++i) {
 snprintf(reg_name, sizeof(reg_name), "v%u", i);
-read_register_u128(reg_ctx, reg_name, _context.v[i*16]);
+read_register_u128(reg_ctx, reg_name, _context.v[i * 16]);
   }
   return thread_context;
 }
@@ -433,39 +431,37 @@ class ArchThreadContexts {
 lldb_private::minidump::MinidumpContext_x86_64 x86_64;
 lldb_private::minidump::RegisterContextMinidump_ARM64::Context arm64;
   };
+
 public:
   ArchThreadContexts(llvm::Triple::ArchType arch) : m_arch(arch) {}
 
   bool prepareRegisterContext(RegisterContext *reg_ctx) {
 switch (m_arch) {
-  case llvm::Triple::ArchType::x86_64:
-x86_64 = GetThreadContext_x86_64(reg_ctx);
-return true;
-  case llvm::Triple::ArchType::aarch64:
-arm64 = GetThreadContext_ARM64(reg_ctx);
-return true;
-  default:
-break;
+case llvm::Triple::ArchType::x86_64:
+  x86_64 = GetThreadContext_x86_64(reg_ctx);
+  return true;
+case llvm::Triple::ArchType::aarch64:
+  arm64 = GetThreadContext_ARM64(reg_ctx);
+  return true;
+default:
+  break;
 }
 return false;
   }
 
-  const void *data() const {
-return _64;
-  }
+  const void *data() const { return _64; }
 
   size_t size() const {
 switch (m_arch) {
-  case llvm::Triple::ArchType::x86_64:
-return sizeof(x86_64);
-  case llvm::Triple::ArchType::aarch64:
-return sizeof(arm64);
-  default:
-break;
+case llvm::Triple::ArchType::x86_64:
+  return sizeof(x86_64);
+case llvm::Triple::ArchType::aarch64:
+  return sizeof(arm64);
+default:
+  break;
 }
 return 0;
   }
-
 };
 
 // Function returns start and size of the memory region that contains
@@ -525,7 +521,8 @@ Status MinidumpFileBuilder::AddThreadList(const 
lldb::ProcessSP _sp) {
 const ArchSpec  = target.GetArchitecture();
 ArchThreadContexts thread_context(arch.GetMachine());
 if (!thread_context.prepareRegisterContext(reg_ctx)) {
-  error.SetErrorStringWithFormat("architecture %s not supported.",
+  error.SetErrorStringWithFormat(
+  "architecture %s not supported.",
   arch.GetTriple().getArchName().str().c_str());
   return error;
 }
@@ -571,7 +568,6 @@ Status MinidumpFileBuilder::AddThreadList(const 
lldb::ProcessSP _sp) {
 
 

[Lldb-commits] [lldb] Add support for arm64 registers in minidump core file saving. (PR #72315)

2023-11-14 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Greg Clayton (clayborg)


Changes

This patch adds support for saving minidumps with the arm64 architecture. It 
also will cause unsupported architectures to emit an error where before this 
patch it would emit a minidump with partial information. This new code is 
tested by the arm64 windows buildbot that was failing:

https://lab.llvm.org/buildbot/#/builders/219/builds/6868

This is needed following this PR: 
https://github.com/llvm/llvm-project/pull/71772

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


4 Files Affected:

- (modified) lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
(+154-71) 
- (modified) lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h 
(+8-4) 
- (modified) lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.cpp 
(+10-13) 
- (modified) 
lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h (+1-1) 


``diff
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index e8e0d09b5324d0f..8699479cadb36ad 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -9,6 +9,7 @@
 #include "MinidumpFileBuilder.h"
 
 #include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h"
+#include "Plugins/Process/minidump/RegisterContextMinidump_ARM64.h"
 
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
@@ -293,7 +294,7 @@ Status MinidumpFileBuilder::AddModuleList(Target ) {
 }
 
 uint16_t read_register_u16_raw(RegisterContext *reg_ctx,
-   const std::string _name) {
+   llvm::StringRef reg_name) {
   const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
   if (!reg_info)
 return 0;
@@ -305,7 +306,7 @@ uint16_t read_register_u16_raw(RegisterContext *reg_ctx,
 }
 
 uint32_t read_register_u32_raw(RegisterContext *reg_ctx,
-   const std::string _name) {
+   llvm::StringRef reg_name) {
   const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
   if (!reg_info)
 return 0;
@@ -317,7 +318,7 @@ uint32_t read_register_u32_raw(RegisterContext *reg_ctx,
 }
 
 uint64_t read_register_u64_raw(RegisterContext *reg_ctx,
-   const std::string _name) {
+   llvm::StringRef reg_name) {
   const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
   if (!reg_info)
 return 0;
@@ -329,25 +330,44 @@ uint64_t read_register_u64_raw(RegisterContext *reg_ctx,
 }
 
 llvm::support::ulittle16_t read_register_u16(RegisterContext *reg_ctx,
- const std::string _name) {
+ llvm::StringRef reg_name) {
   return static_cast(
   read_register_u16_raw(reg_ctx, reg_name));
 }
 
 llvm::support::ulittle32_t read_register_u32(RegisterContext *reg_ctx,
- const std::string _name) {
+ llvm::StringRef reg_name) {
   return static_cast(
   read_register_u32_raw(reg_ctx, reg_name));
 }
 
 llvm::support::ulittle64_t read_register_u64(RegisterContext *reg_ctx,
- const std::string _name) {
+ llvm::StringRef reg_name) {
   return static_cast(
   read_register_u64_raw(reg_ctx, reg_name));
 }
 
+void read_register_u128(RegisterContext *reg_ctx, llvm::StringRef reg_name,
+uint8_t *dst) {
+  const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
+  if (reg_info) {
+lldb_private::RegisterValue reg_value;
+if (reg_ctx->ReadRegister(reg_info, reg_value)) {
+  Status error;
+  uint32_t bytes_copied =
+  reg_value.GetAsMemoryData(*reg_info, dst, 16,
+lldb::ByteOrder::eByteOrderLittle,
+error);
+  if (bytes_copied == 16)
+return;
+}
+  }
+  // If anything goes wrong, then zero out the register value.
+  memset(dst, 0, 16);
+}
+
 lldb_private::minidump::MinidumpContext_x86_64
-GetThreadContext_64(RegisterContext *reg_ctx) {
+GetThreadContext_x86_64(RegisterContext *reg_ctx) {
   lldb_private::minidump::MinidumpContext_x86_64 thread_context = {};
   thread_context.p1_home = {};
   thread_context.context_flags = static_cast(
@@ -381,6 +401,73 @@ GetThreadContext_64(RegisterContext *reg_ctx) {
   return thread_context;
 }
 
+minidump::RegisterContextMinidump_ARM64::Context
+GetThreadContext_ARM64(RegisterContext *reg_ctx) {
+  minidump::RegisterContextMinidump_ARM64::Context thread_context = {};
+  thread_context.context_flags = static_cast(
+  

[Lldb-commits] [lldb] Centralize the code that figures out which memory ranges to save into core files (PR #71772)

2023-11-14 Thread Greg Clayton via lldb-commits

clayborg wrote:

> [antmox](/antmox)

https://github.com/llvm/llvm-project/pull/72315

A new PR to fix this issue. Is there any way you can test this to see if this 
works?

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


[Lldb-commits] [lldb] Add support for arm64 registers in minidump core file saving. (PR #72315)

2023-11-14 Thread Greg Clayton via lldb-commits

https://github.com/clayborg created 
https://github.com/llvm/llvm-project/pull/72315

This patch adds support for saving minidumps with the arm64 architecture. It 
also will cause unsupported architectures to emit an error where before this 
patch it would emit a minidump with partial information. This new code is 
tested by the arm64 windows buildbot that was failing:

https://lab.llvm.org/buildbot/#/builders/219/builds/6868

This is needed following this PR: 
https://github.com/llvm/llvm-project/pull/71772

>From dd4dd79853566049874f49d1290217f5abde23fd Mon Sep 17 00:00:00 2001
From: Greg Clayton 
Date: Tue, 14 Nov 2023 13:53:25 -0800
Subject: [PATCH] Add support for arm64 registers in minidump core file saving.

This patch adds support for saving minidumps with the arm64 architecture. It 
also will cause unsupported architectures to emit an error where before this 
patch it would emit a minidump with partial information. This new code is 
tested by the arm64 windows buildbot that was failing:

https://lab.llvm.org/buildbot/#/builders/219/builds/6868

This is needed following this PR: 
https://github.com/llvm/llvm-project/pull/71772
---
 .../Minidump/MinidumpFileBuilder.cpp  | 225 --
 .../ObjectFile/Minidump/MinidumpFileBuilder.h |  12 +-
 .../Minidump/ObjectFileMinidump.cpp   |  23 +-
 .../minidump/RegisterContextMinidump_ARM64.h  |   2 +-
 4 files changed, 173 insertions(+), 89 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index e8e0d09b5324d0f..8699479cadb36ad 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -9,6 +9,7 @@
 #include "MinidumpFileBuilder.h"
 
 #include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h"
+#include "Plugins/Process/minidump/RegisterContextMinidump_ARM64.h"
 
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
@@ -293,7 +294,7 @@ Status MinidumpFileBuilder::AddModuleList(Target ) {
 }
 
 uint16_t read_register_u16_raw(RegisterContext *reg_ctx,
-   const std::string _name) {
+   llvm::StringRef reg_name) {
   const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
   if (!reg_info)
 return 0;
@@ -305,7 +306,7 @@ uint16_t read_register_u16_raw(RegisterContext *reg_ctx,
 }
 
 uint32_t read_register_u32_raw(RegisterContext *reg_ctx,
-   const std::string _name) {
+   llvm::StringRef reg_name) {
   const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
   if (!reg_info)
 return 0;
@@ -317,7 +318,7 @@ uint32_t read_register_u32_raw(RegisterContext *reg_ctx,
 }
 
 uint64_t read_register_u64_raw(RegisterContext *reg_ctx,
-   const std::string _name) {
+   llvm::StringRef reg_name) {
   const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
   if (!reg_info)
 return 0;
@@ -329,25 +330,44 @@ uint64_t read_register_u64_raw(RegisterContext *reg_ctx,
 }
 
 llvm::support::ulittle16_t read_register_u16(RegisterContext *reg_ctx,
- const std::string _name) {
+ llvm::StringRef reg_name) {
   return static_cast(
   read_register_u16_raw(reg_ctx, reg_name));
 }
 
 llvm::support::ulittle32_t read_register_u32(RegisterContext *reg_ctx,
- const std::string _name) {
+ llvm::StringRef reg_name) {
   return static_cast(
   read_register_u32_raw(reg_ctx, reg_name));
 }
 
 llvm::support::ulittle64_t read_register_u64(RegisterContext *reg_ctx,
- const std::string _name) {
+ llvm::StringRef reg_name) {
   return static_cast(
   read_register_u64_raw(reg_ctx, reg_name));
 }
 
+void read_register_u128(RegisterContext *reg_ctx, llvm::StringRef reg_name,
+uint8_t *dst) {
+  const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
+  if (reg_info) {
+lldb_private::RegisterValue reg_value;
+if (reg_ctx->ReadRegister(reg_info, reg_value)) {
+  Status error;
+  uint32_t bytes_copied =
+  reg_value.GetAsMemoryData(*reg_info, dst, 16,
+lldb::ByteOrder::eByteOrderLittle,
+error);
+  if (bytes_copied == 16)
+return;
+}
+  }
+  // If anything goes wrong, then zero out the register value.
+  memset(dst, 0, 16);
+}
+
 lldb_private::minidump::MinidumpContext_x86_64
-GetThreadContext_64(RegisterContext *reg_ctx) {
+GetThreadContext_x86_64(RegisterContext *reg_ctx) {
   

[Lldb-commits] [lldb] Centralize the code that figures out which memory ranges to save into core files (PR #71772)

2023-11-14 Thread Greg Clayton via lldb-commits

clayborg wrote:

> [core_dmps.tar.gz](https://github.com/llvm/llvm-project/files/13355872/core_dmps.tar.gz)
>  here is an archive with the 2 core.dmp files

It does indeed seem like my new core file creation code is being triggered on 
windows. I am working on a fix that adds ARM64 support to the built in minidump 
creator.

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


[Lldb-commits] [flang] [compiler-rt] [clang-tools-extra] [lldb] [lld] [llvm] [libcxx] [clang] [libc] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)

2023-11-14 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/71771

>From 06c4cf02dfb4b20c8349c5f3c7209276f6d56edf Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 9 Nov 2023 02:21:46 +
Subject: [PATCH 1/3] Fix clang to recognize new C23 modifiers %w and %wf when
 printing

---
 clang/include/clang/AST/FormatString.h | 16 +++-
 clang/lib/AST/FormatString.cpp | 52 +-
 clang/lib/AST/PrintfFormatString.cpp   | 19 ++
 clang/test/Sema/format-strings-ms.c| 28 ++
 4 files changed, 112 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/FormatString.h 
b/clang/include/clang/AST/FormatString.h
index 5c4ad9baaef608c..6a886854650f1d9 100644
--- a/clang/include/clang/AST/FormatString.h
+++ b/clang/include/clang/AST/FormatString.h
@@ -81,8 +81,10 @@ class LengthModifier {
 AsLongDouble, // 'L'
 AsAllocate,   // for '%as', GNU extension to C90 scanf
 AsMAllocate,  // for '%ms', GNU extension to scanf
-AsWide,   // 'w' (MSVCRT, like l but only for c, C, s, S, or Z
-AsWideChar = AsLong // for '%ls', only makes sense for printf
+AsWide,   // 'w' (1. MSVCRT, like l but only for c, C, s, S, or Z on 
windows
+  // 2. for b, d, i, o, u, x, or X when a size followed(like 
8, 16, 32 or 64)
+AsWideFast,   // 'wf' (for b, d, i, o, u, x, or X)
+AsWideChar = AsLong, // for '%ls', only makes sense for printf
   };
 
   LengthModifier()
@@ -417,6 +419,7 @@ class FormatSpecifier {
   ///  http://www.opengroup.org/onlinepubs/009695399/functions/printf.html
   bool UsesPositionalArg;
   unsigned argIndex;
+  unsigned size;
 public:
   FormatSpecifier(bool isPrintf)
 : CS(isPrintf), VectorNumElts(false),
@@ -460,6 +463,15 @@ class FormatSpecifier {
 FieldWidth = Amt;
   }
 
+  void setSize(unsigned s) {
+size = s;
+  }
+
+  unsigned getSize() const {
+return size;
+  }
+
+
   bool usesPositionalArg() const { return UsesPositionalArg; }
 
   bool hasValidLengthModifier(const TargetInfo ,
diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp
index e0c9e18cfe3a243..ebc136e780717e4 100644
--- a/clang/lib/AST/FormatString.cpp
+++ b/clang/lib/AST/FormatString.cpp
@@ -286,7 +286,33 @@ 
clang::analyze_format_string::ParseLengthModifier(FormatSpecifier ,
   lmKind = LengthModifier::AsInt3264;
   break;
 case 'w':
-  lmKind = LengthModifier::AsWide; ++I; break;
+  ++I;
+  if (I == E) return false;
+  if (*I == 'f') {
+lmKind = LengthModifier::AsWideFast;
+++I;
+  } else {
+lmKind = LengthModifier::AsWide;
+  }
+
+  if (I == E) return false;
+  int s = 0;
+  while (unsigned(*I - '0') <= 9) {
+s = 10 * s + unsigned(*I - '0');
+++I;
+  }
+
+  // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows
+  // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 
or 64)
+  if (s != 0) {
+std::set supported_list {8, 16, 32, 64};
+if (supported_list.count(s) == 0) {
+  return false;
+}
+FS.setSize(s);
+  }
+
+  break;
   }
   LengthModifier lm(lmPosition, lmKind);
   FS.setLengthModifier(lm);
@@ -703,6 +729,8 @@ analyze_format_string::LengthModifier::toString() const {
 return "m";
   case AsWide:
 return "w";
+  case AsWideFast:
+return "wf";
   case None:
 return "";
   }
@@ -970,6 +998,27 @@ bool FormatSpecifier::hasValidLengthModifier(const 
TargetInfo ,
 case ConversionSpecifier::SArg:
 case ConversionSpecifier::ZArg:
   return Target.getTriple().isOSMSVCRT();
+case ConversionSpecifier::bArg:
+case ConversionSpecifier::dArg:
+case ConversionSpecifier::iArg:
+case ConversionSpecifier::oArg:
+case ConversionSpecifier::uArg:
+case ConversionSpecifier::xArg:
+case ConversionSpecifier::XArg:
+  return true;
+default:
+  return false;
+  }
+case LengthModifier::AsWideFast:
+  switch (CS.getKind()) {
+case ConversionSpecifier::bArg:
+case ConversionSpecifier::dArg:
+case ConversionSpecifier::iArg:
+case ConversionSpecifier::oArg:
+case ConversionSpecifier::uArg:
+case ConversionSpecifier::xArg:
+case ConversionSpecifier::XArg:
+  return true;
 default:
   return false;
   }
@@ -996,6 +1045,7 @@ bool FormatSpecifier::hasStandardLengthModifier() const {
 case LengthModifier::AsInt3264:
 case LengthModifier::AsInt64:
 case LengthModifier::AsWide:
+case LengthModifier::AsWideFast:
 case LengthModifier::AsShortLong: // ???
   return false;
   }
diff --git a/clang/lib/AST/PrintfFormatString.cpp 
b/clang/lib/AST/PrintfFormatString.cpp
index f0b9d0ecaf23461..4b9111e8bcf509a 100644
--- a/clang/lib/AST/PrintfFormatString.cpp
+++ 

[Lldb-commits] [clang] [libcxx] [lldb] [llvm] [libc] [compiler-rt] [clang-tools-extra] [flang] [lld] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)

2023-11-14 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/71771

>From 06c4cf02dfb4b20c8349c5f3c7209276f6d56edf Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 9 Nov 2023 02:21:46 +
Subject: [PATCH 1/3] Fix clang to recognize new C23 modifiers %w and %wf when
 printing

---
 clang/include/clang/AST/FormatString.h | 16 +++-
 clang/lib/AST/FormatString.cpp | 52 +-
 clang/lib/AST/PrintfFormatString.cpp   | 19 ++
 clang/test/Sema/format-strings-ms.c| 28 ++
 4 files changed, 112 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/FormatString.h 
b/clang/include/clang/AST/FormatString.h
index 5c4ad9baaef608c..6a886854650f1d9 100644
--- a/clang/include/clang/AST/FormatString.h
+++ b/clang/include/clang/AST/FormatString.h
@@ -81,8 +81,10 @@ class LengthModifier {
 AsLongDouble, // 'L'
 AsAllocate,   // for '%as', GNU extension to C90 scanf
 AsMAllocate,  // for '%ms', GNU extension to scanf
-AsWide,   // 'w' (MSVCRT, like l but only for c, C, s, S, or Z
-AsWideChar = AsLong // for '%ls', only makes sense for printf
+AsWide,   // 'w' (1. MSVCRT, like l but only for c, C, s, S, or Z on 
windows
+  // 2. for b, d, i, o, u, x, or X when a size followed(like 
8, 16, 32 or 64)
+AsWideFast,   // 'wf' (for b, d, i, o, u, x, or X)
+AsWideChar = AsLong, // for '%ls', only makes sense for printf
   };
 
   LengthModifier()
@@ -417,6 +419,7 @@ class FormatSpecifier {
   ///  http://www.opengroup.org/onlinepubs/009695399/functions/printf.html
   bool UsesPositionalArg;
   unsigned argIndex;
+  unsigned size;
 public:
   FormatSpecifier(bool isPrintf)
 : CS(isPrintf), VectorNumElts(false),
@@ -460,6 +463,15 @@ class FormatSpecifier {
 FieldWidth = Amt;
   }
 
+  void setSize(unsigned s) {
+size = s;
+  }
+
+  unsigned getSize() const {
+return size;
+  }
+
+
   bool usesPositionalArg() const { return UsesPositionalArg; }
 
   bool hasValidLengthModifier(const TargetInfo ,
diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp
index e0c9e18cfe3a243..ebc136e780717e4 100644
--- a/clang/lib/AST/FormatString.cpp
+++ b/clang/lib/AST/FormatString.cpp
@@ -286,7 +286,33 @@ 
clang::analyze_format_string::ParseLengthModifier(FormatSpecifier ,
   lmKind = LengthModifier::AsInt3264;
   break;
 case 'w':
-  lmKind = LengthModifier::AsWide; ++I; break;
+  ++I;
+  if (I == E) return false;
+  if (*I == 'f') {
+lmKind = LengthModifier::AsWideFast;
+++I;
+  } else {
+lmKind = LengthModifier::AsWide;
+  }
+
+  if (I == E) return false;
+  int s = 0;
+  while (unsigned(*I - '0') <= 9) {
+s = 10 * s + unsigned(*I - '0');
+++I;
+  }
+
+  // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows
+  // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 
or 64)
+  if (s != 0) {
+std::set supported_list {8, 16, 32, 64};
+if (supported_list.count(s) == 0) {
+  return false;
+}
+FS.setSize(s);
+  }
+
+  break;
   }
   LengthModifier lm(lmPosition, lmKind);
   FS.setLengthModifier(lm);
@@ -703,6 +729,8 @@ analyze_format_string::LengthModifier::toString() const {
 return "m";
   case AsWide:
 return "w";
+  case AsWideFast:
+return "wf";
   case None:
 return "";
   }
@@ -970,6 +998,27 @@ bool FormatSpecifier::hasValidLengthModifier(const 
TargetInfo ,
 case ConversionSpecifier::SArg:
 case ConversionSpecifier::ZArg:
   return Target.getTriple().isOSMSVCRT();
+case ConversionSpecifier::bArg:
+case ConversionSpecifier::dArg:
+case ConversionSpecifier::iArg:
+case ConversionSpecifier::oArg:
+case ConversionSpecifier::uArg:
+case ConversionSpecifier::xArg:
+case ConversionSpecifier::XArg:
+  return true;
+default:
+  return false;
+  }
+case LengthModifier::AsWideFast:
+  switch (CS.getKind()) {
+case ConversionSpecifier::bArg:
+case ConversionSpecifier::dArg:
+case ConversionSpecifier::iArg:
+case ConversionSpecifier::oArg:
+case ConversionSpecifier::uArg:
+case ConversionSpecifier::xArg:
+case ConversionSpecifier::XArg:
+  return true;
 default:
   return false;
   }
@@ -996,6 +1045,7 @@ bool FormatSpecifier::hasStandardLengthModifier() const {
 case LengthModifier::AsInt3264:
 case LengthModifier::AsInt64:
 case LengthModifier::AsWide:
+case LengthModifier::AsWideFast:
 case LengthModifier::AsShortLong: // ???
   return false;
   }
diff --git a/clang/lib/AST/PrintfFormatString.cpp 
b/clang/lib/AST/PrintfFormatString.cpp
index f0b9d0ecaf23461..4b9111e8bcf509a 100644
--- a/clang/lib/AST/PrintfFormatString.cpp
+++ 

[Lldb-commits] [clang] [libcxx] [lldb] [llvm] [libc] [compiler-rt] [clang-tools-extra] [flang] [lld] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)

2023-11-14 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/71771

>From 06c4cf02dfb4b20c8349c5f3c7209276f6d56edf Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 9 Nov 2023 02:21:46 +
Subject: [PATCH 1/2] Fix clang to recognize new C23 modifiers %w and %wf when
 printing

---
 clang/include/clang/AST/FormatString.h | 16 +++-
 clang/lib/AST/FormatString.cpp | 52 +-
 clang/lib/AST/PrintfFormatString.cpp   | 19 ++
 clang/test/Sema/format-strings-ms.c| 28 ++
 4 files changed, 112 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/FormatString.h 
b/clang/include/clang/AST/FormatString.h
index 5c4ad9baaef608c..6a886854650f1d9 100644
--- a/clang/include/clang/AST/FormatString.h
+++ b/clang/include/clang/AST/FormatString.h
@@ -81,8 +81,10 @@ class LengthModifier {
 AsLongDouble, // 'L'
 AsAllocate,   // for '%as', GNU extension to C90 scanf
 AsMAllocate,  // for '%ms', GNU extension to scanf
-AsWide,   // 'w' (MSVCRT, like l but only for c, C, s, S, or Z
-AsWideChar = AsLong // for '%ls', only makes sense for printf
+AsWide,   // 'w' (1. MSVCRT, like l but only for c, C, s, S, or Z on 
windows
+  // 2. for b, d, i, o, u, x, or X when a size followed(like 
8, 16, 32 or 64)
+AsWideFast,   // 'wf' (for b, d, i, o, u, x, or X)
+AsWideChar = AsLong, // for '%ls', only makes sense for printf
   };
 
   LengthModifier()
@@ -417,6 +419,7 @@ class FormatSpecifier {
   ///  http://www.opengroup.org/onlinepubs/009695399/functions/printf.html
   bool UsesPositionalArg;
   unsigned argIndex;
+  unsigned size;
 public:
   FormatSpecifier(bool isPrintf)
 : CS(isPrintf), VectorNumElts(false),
@@ -460,6 +463,15 @@ class FormatSpecifier {
 FieldWidth = Amt;
   }
 
+  void setSize(unsigned s) {
+size = s;
+  }
+
+  unsigned getSize() const {
+return size;
+  }
+
+
   bool usesPositionalArg() const { return UsesPositionalArg; }
 
   bool hasValidLengthModifier(const TargetInfo ,
diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp
index e0c9e18cfe3a243..ebc136e780717e4 100644
--- a/clang/lib/AST/FormatString.cpp
+++ b/clang/lib/AST/FormatString.cpp
@@ -286,7 +286,33 @@ 
clang::analyze_format_string::ParseLengthModifier(FormatSpecifier ,
   lmKind = LengthModifier::AsInt3264;
   break;
 case 'w':
-  lmKind = LengthModifier::AsWide; ++I; break;
+  ++I;
+  if (I == E) return false;
+  if (*I == 'f') {
+lmKind = LengthModifier::AsWideFast;
+++I;
+  } else {
+lmKind = LengthModifier::AsWide;
+  }
+
+  if (I == E) return false;
+  int s = 0;
+  while (unsigned(*I - '0') <= 9) {
+s = 10 * s + unsigned(*I - '0');
+++I;
+  }
+
+  // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows
+  // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 
or 64)
+  if (s != 0) {
+std::set supported_list {8, 16, 32, 64};
+if (supported_list.count(s) == 0) {
+  return false;
+}
+FS.setSize(s);
+  }
+
+  break;
   }
   LengthModifier lm(lmPosition, lmKind);
   FS.setLengthModifier(lm);
@@ -703,6 +729,8 @@ analyze_format_string::LengthModifier::toString() const {
 return "m";
   case AsWide:
 return "w";
+  case AsWideFast:
+return "wf";
   case None:
 return "";
   }
@@ -970,6 +998,27 @@ bool FormatSpecifier::hasValidLengthModifier(const 
TargetInfo ,
 case ConversionSpecifier::SArg:
 case ConversionSpecifier::ZArg:
   return Target.getTriple().isOSMSVCRT();
+case ConversionSpecifier::bArg:
+case ConversionSpecifier::dArg:
+case ConversionSpecifier::iArg:
+case ConversionSpecifier::oArg:
+case ConversionSpecifier::uArg:
+case ConversionSpecifier::xArg:
+case ConversionSpecifier::XArg:
+  return true;
+default:
+  return false;
+  }
+case LengthModifier::AsWideFast:
+  switch (CS.getKind()) {
+case ConversionSpecifier::bArg:
+case ConversionSpecifier::dArg:
+case ConversionSpecifier::iArg:
+case ConversionSpecifier::oArg:
+case ConversionSpecifier::uArg:
+case ConversionSpecifier::xArg:
+case ConversionSpecifier::XArg:
+  return true;
 default:
   return false;
   }
@@ -996,6 +1045,7 @@ bool FormatSpecifier::hasStandardLengthModifier() const {
 case LengthModifier::AsInt3264:
 case LengthModifier::AsInt64:
 case LengthModifier::AsWide:
+case LengthModifier::AsWideFast:
 case LengthModifier::AsShortLong: // ???
   return false;
   }
diff --git a/clang/lib/AST/PrintfFormatString.cpp 
b/clang/lib/AST/PrintfFormatString.cpp
index f0b9d0ecaf23461..4b9111e8bcf509a 100644
--- a/clang/lib/AST/PrintfFormatString.cpp
+++ 

[Lldb-commits] [lldb] Centralize the code that figures out which memory ranges to save into core files (PR #71772)

2023-11-14 Thread antoine moynault via lldb-commits

antmox wrote:

[core_dmps.tar.gz](https://github.com/llvm/llvm-project/files/13355872/core_dmps.tar.gz)
here is an archive with the 2 core.dmp files

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


[Lldb-commits] [lldb] [llvm] [openmp] [clang-tools-extra] [flang] [mlir] [libcxx] [libc] [clang] GlobalISel: Guard return in llvm::getIConstantSplatVal (PR #71989)

2023-11-14 Thread Changpeng Fang via lldb-commits

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


[Lldb-commits] [mlir] [clang-tools-extra] [llvm] [clang] [openmp] [libc] [lldb] [libcxx] [flang] GlobalISel: Guard return in llvm::getIConstantSplatVal (PR #71989)

2023-11-14 Thread Changpeng Fang via lldb-commits

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


[Lldb-commits] [mlir] [clang-tools-extra] [llvm] [clang] [openmp] [libc] [lldb] [libcxx] [flang] GlobalISel: Guard return in llvm::getIConstantSplatVal (PR #71989)

2023-11-14 Thread Changpeng Fang via lldb-commits

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


[Lldb-commits] [llvm] [libc] [flang] [openmp] [clang] [mlir] [libcxx] [lldb] [clang-tools-extra] GlobalISel: Guard return in llvm::getIConstantSplatVal (PR #71989)

2023-11-14 Thread Stanislav Mekhanoshin via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Fixing a type encoding issue with dap Stopped events. (PR #72292)

2023-11-14 Thread John Harrison via lldb-commits


@@ -953,9 +953,9 @@ llvm::json::Value CreateThreadStopped(lldb::SBThread 
,
 } else {
   body.try_emplace("reason", "breakpoint");
   char desc_str[64];
-  uint64_t bp_id = thread.GetStopReasonDataAtIndex(0);
-  uint64_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
-  snprintf(desc_str, sizeof(desc_str), "breakpoint %" PRIu64 ".%" PRIu64,
+  break_id_t bp_id = thread.GetStopReasonDataAtIndex(0);

ashgti wrote:

These are implicitly cast here 
https://github.com/llvm/llvm-project/blob/e823136d43c40b0a9ba6930fd285768f1b46fcb6/lldb/source/API/SBThread.cpp#L251C35-L251C48
 to uint64_t, this is converting it back to the internal type. This should be 
okay.

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


[Lldb-commits] [mlir] [lldb] [llvm] [clang] [flang] [libc] [compiler-rt] [libcxx] [clang-tools-extra] [lld] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-11-14 Thread Sang Ik Lee via lldb-commits


@@ -0,0 +1,56 @@
+// RUN: mlir-opt %s 
-pass-pipeline='builtin.module(spirv-attach-target{ver=v1.0 
caps=Addresses,Int64,Kernel},convert-gpu-to-spirv{use-64bit-index=true},gpu.module(spirv.module(spirv-lower-abi-attrs,spirv-update-vce)),func.func(llvm-request-c-wrappers),convert-scf-to-cf,convert-cf-to-llvm,convert-arith-to-llvm,convert-math-to-llvm,convert-func-to-llvm,gpu-to-llvm{use-bare-pointers-for-kernels=true},gpu-module-to-binary,expand-strided-metadata,lower-affine,finalize-memref-to-llvm,reconcile-unrealized-casts)'
 \
+// RUN: | mlir-cpu-runner \
+// RUN:   --shared-libs=%mlir_sycl_runtime \
+// RUN:   --shared-libs=%mlir_runner_utils \
+// RUN:   --entry-point-result=void \
+// RUN: | FileCheck %s
+
+module @add attributes {gpu.container_module} {
+  memref.global "private" constant @__constant_2x2x2xf32_0 : memref<2x2x2xf32> 
= dense<[[[1.1, 2.2], [3.3, 4.4]], [[5.5, 6.6], [7.7, 8.8 ]]]>
+  memref.global "private" constant @__constant_2x2x2xf32 : memref<2x2x2xf32> = 
dense<[[[1.2, 2.3], [4.5, 5.8]], [[7.2, 8.3], [10.5, 11.8]]]>
+  func.func @main() {
+%0 = memref.get_global @__constant_2x2x2xf32 : memref<2x2x2xf32>
+%1 = memref.get_global @__constant_2x2x2xf32_0 : memref<2x2x2xf32>
+%2 = call @test(%0, %1) : (memref<2x2x2xf32>, memref<2x2x2xf32>) -> 
memref<2x2x2xf32>
+%cast = memref.cast %2 : memref<2x2x2xf32> to memref<*xf32>
+call @printMemrefF32(%cast) : (memref<*xf32>) -> ()
+return
+  }
+  func.func private @printMemrefF32(memref<*xf32>)
+  func.func @test(%arg0: memref<2x2x2xf32>, %arg1: memref<2x2x2xf32>) -> 
memref<2x2x2xf32> {

silee2 wrote:

Done.

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


[Lldb-commits] [lldb] [lldb-dap] Fixing a type encoding issue with dap Stopped events. (PR #72292)

2023-11-14 Thread Greg Clayton via lldb-commits

clayborg wrote:

LGTM. I didn't mean to accept the patch when it was using `PRIo32`

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


[Lldb-commits] [mlir] [compiler-rt] [flang] [clang] [clang-tools-extra] [lld] [libc] [libcxx] [llvm] [lldb] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-11-14 Thread Sang Ik Lee via lldb-commits


@@ -377,10 +379,17 @@ 
llvm::LaunchKernel::createKernelLaunch(mlir::gpu::LaunchFuncOp op,
   if (!binary)
 return op.emitError() << "Couldn't find the binary: " << binaryIdentifier;
 
+  auto binaryVar = dyn_cast(binary);
+  llvm::Constant *binaryInit = binaryVar->getInitializer();
+  auto binaryDataSeq = dyn_cast(binaryInit);

silee2 wrote:

Added pointer checks.

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


[Lldb-commits] [mlir] [compiler-rt] [flang] [clang] [clang-tools-extra] [lld] [libc] [libcxx] [llvm] [lldb] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-11-14 Thread Sang Ik Lee via lldb-commits


@@ -4,6 +4,7 @@
 module attributes {gpu.container_module} {
   // CHECK: [[ARGS_TY:%.*]] = type { i32, i32 }
   // CHECK: @kernel_module_bin_cst = internal constant [4 x i8] c"BLOB", align 
8
+  // CHECK:  @kernel_module_bin_size_cst = internal constant i64 4, align 8

silee2 wrote:

Done.

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


[Lldb-commits] [mlir] [lldb] [llvm] [clang] [flang] [libc] [compiler-rt] [libcxx] [clang-tools-extra] [lld] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-11-14 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 updated 
https://github.com/llvm/llvm-project/pull/71430

>From c76403cf8629b8f7d8a5b7a3ee5da2881713a7f8 Mon Sep 17 00:00:00 2001
From: "Lee, Sang Ik" 
Date: Mon, 6 Nov 2023 18:47:23 +
Subject: [PATCH 1/5] [MLIR] Enable GPU Dialect to SYCL runtime integration

GPU Dialect lowering to SYCL runtime is driven by spirv.target_env
attached to gpu.module. As a result of this, spirv.target_env remains
as an input to LLVMIR Translation.
A SPIRVToLLVMIRTranslation without any actual translation is added to
avoid an unregistered error in mlir-cpu-runner.
SelectObjectAttr.cpp is updated to
1) Pass binary size argument to getModuleLoadFn
2) Pass parameter count to getKernelLaunchFn
This change does not impact CUDA and ROCM usage since both
mlir_cuda_runtime and mlir_rocm_runtime are already updated to
accept and ignore the extra arguments.
---
 mlir/include/mlir/Target/LLVMIR/Dialect/All.h |  3 ++
 .../Dialect/SPIRV/SPIRVToLLVMIRTranslation.h  | 31 +++
 mlir/lib/Target/LLVMIR/CMakeLists.txt |  1 +
 mlir/lib/Target/LLVMIR/Dialect/CMakeLists.txt |  1 +
 .../LLVMIR/Dialect/GPU/SelectObjectAttr.cpp   | 50 +
 .../LLVMIR/Dialect/SPIRV/CMakeLists.txt   | 13 +
 .../SPIRV/SPIRVToLLVMIRTranslation.cpp| 31 +++
 mlir/test/CMakeLists.txt  |  4 ++
 .../Integration/GPU/SYCL/gpu-to-spirv.mlir| 54 +++
 mlir/test/Integration/GPU/SYCL/lit.local.cfg  |  2 +
 mlir/test/Target/LLVMIR/gpu.mlir  |  9 ++--
 mlir/test/lit.cfg.py  |  3 ++
 mlir/test/lit.site.cfg.py.in  |  1 +
 13 files changed, 188 insertions(+), 15 deletions(-)
 create mode 100644 
mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h
 create mode 100644 mlir/lib/Target/LLVMIR/Dialect/SPIRV/CMakeLists.txt
 create mode 100644 
mlir/lib/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.cpp
 create mode 100644 mlir/test/Integration/GPU/SYCL/gpu-to-spirv.mlir
 create mode 100644 mlir/test/Integration/GPU/SYCL/lit.local.cfg

diff --git a/mlir/include/mlir/Target/LLVMIR/Dialect/All.h 
b/mlir/include/mlir/Target/LLVMIR/Dialect/All.h
index 0563b9bf3d475a4..5dfc15afb75931a 100644
--- a/mlir/include/mlir/Target/LLVMIR/Dialect/All.h
+++ b/mlir/include/mlir/Target/LLVMIR/Dialect/All.h
@@ -26,6 +26,7 @@
 #include "mlir/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/ROCDL/ROCDLToLLVMIRTranslation.h"
+#include "mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/X86Vector/X86VectorToLLVMIRTranslation.h"
 
 namespace mlir {
@@ -45,6 +46,7 @@ static inline void 
registerAllToLLVMIRTranslations(DialectRegistry ) {
   registerOpenACCDialectTranslation(registry);
   registerOpenMPDialectTranslation(registry);
   registerROCDLDialectTranslation(registry);
+  registerSPIRVDialectTranslation(registry);
   registerX86VectorDialectTranslation(registry);
 
   // Extension required for translating GPU offloading Ops.
@@ -61,6 +63,7 @@ registerAllGPUToLLVMIRTranslations(DialectRegistry ) 
{
   registerLLVMDialectTranslation(registry);
   registerNVVMDialectTranslation(registry);
   registerROCDLDialectTranslation(registry);
+  registerSPIRVDialectTranslation(registry);
 
   // Extension required for translating GPU offloading Ops.
   gpu::registerOffloadingLLVMTranslationInterfaceExternalModels(registry);
diff --git 
a/mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h 
b/mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h
new file mode 100644
index 000..e9580a10b4ca780
--- /dev/null
+++ b/mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h
@@ -0,0 +1,31 @@
+//===- SPIRVToLLVMIRTranslation.h - SPIRV to LLVM IR *- 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
+//
+//===--===//
+//
+// This provides registration calls for SPIRV dialect to LLVM IR translation.
+//
+//===--===//
+
+#ifndef MLIR_TARGET_LLVMIR_DIALECT_SPIRV_SPIRVTOLLVMIRTRANSLATION_H
+#define MLIR_TARGET_LLVMIR_DIALECT_SPIRV_SPIRVTOLLVMIRTRANSLATION_H
+
+namespace mlir {
+
+class DialectRegistry;
+class MLIRContext;
+
+/// Register the SPIRV dialect and the translation from it to the LLVM IR in 
the
+/// given registry;
+void registerSPIRVDialectTranslation(DialectRegistry );
+
+/// Register the SPIRV dialect and the translation from it in the registry
+/// associated with the given context.
+void registerSPIRVDialectTranslation(MLIRContext );
+
+} // namespace mlir
+
+#endif // 

[Lldb-commits] [lldb] [lldb-dap] Fixing a type encoding issue with dap Stopped events. (PR #72292)

2023-11-14 Thread John Harrison via lldb-commits


@@ -953,9 +953,9 @@ llvm::json::Value CreateThreadStopped(lldb::SBThread 
,
 } else {
   body.try_emplace("reason", "breakpoint");
   char desc_str[64];
-  uint64_t bp_id = thread.GetStopReasonDataAtIndex(0);
-  uint64_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
-  snprintf(desc_str, sizeof(desc_str), "breakpoint %" PRIu64 ".%" PRIu64,
+  break_id_t bp_id = thread.GetStopReasonDataAtIndex(0);
+  break_id_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
+  snprintf(desc_str, sizeof(desc_str), "breakpoint %" PRIo32 ".%" PRIo32,

ashgti wrote:

Switched to `llvm::vformat`.

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


[Lldb-commits] [lldb] [lldb-dap] Fixing a type encoding issue with dap Stopped events. (PR #72292)

2023-11-14 Thread John Harrison via lldb-commits


@@ -953,9 +953,9 @@ llvm::json::Value CreateThreadStopped(lldb::SBThread 
,
 } else {
   body.try_emplace("reason", "breakpoint");
   char desc_str[64];
-  uint64_t bp_id = thread.GetStopReasonDataAtIndex(0);
-  uint64_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
-  snprintf(desc_str, sizeof(desc_str), "breakpoint %" PRIu64 ".%" PRIu64,
+  break_id_t bp_id = thread.GetStopReasonDataAtIndex(0);
+  break_id_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
+  snprintf(desc_str, sizeof(desc_str), "breakpoint %" PRIo32 ".%" PRIo32,

ashgti wrote:

Switched to llvm::vformat instead.

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


[Lldb-commits] [lldb] [lldb-dap] Fixing a type encoding issue with dap Stopped events. (PR #72292)

2023-11-14 Thread John Harrison via lldb-commits

https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/72292

>From ed4b044027e4ccc02bd19af394a076892baeea95 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Tue, 14 Nov 2023 10:02:41 -0800
Subject: [PATCH] [lldb-dap] Fixing a type encoding issue with dap Stopped
 events.

Previously the type of the breakpoint id in the Stopped event was a uint64_t, 
however thats the wrong type for a breakpoint id, which can cause encoding 
issues when internal breakpoints are hit.
---
 lldb/tools/lldb-dap/JSONUtils.cpp | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp 
b/lldb/tools/lldb-dap/JSONUtils.cpp
index 2023291729762f1..ebb0ba202183c28 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -13,6 +13,7 @@
 #include 
 
 #include "llvm/Support/FormatAdapters.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ScopedPrinter.h"
 
@@ -952,11 +953,10 @@ llvm::json::Value CreateThreadStopped(lldb::SBThread 
,
   EmplaceSafeString(body, "description", exc_bp->label);
 } else {
   body.try_emplace("reason", "breakpoint");
-  char desc_str[64];
-  uint64_t bp_id = thread.GetStopReasonDataAtIndex(0);
-  uint64_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
-  snprintf(desc_str, sizeof(desc_str), "breakpoint %" PRIu64 ".%" PRIu64,
-   bp_id, bp_loc_id);
+  lldb::break_id_t bp_id = thread.GetStopReasonDataAtIndex(0);
+  lldb::break_id_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
+  std::string desc_str =
+  llvm::formatv("breakpoint {0}.{1}", bp_id, bp_loc_id);
   body.try_emplace("hitBreakpointIds",
llvm::json::Array{llvm::json::Value(bp_id)});
   EmplaceSafeString(body, "description", desc_str);

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] DWARFv5: support DW_TAG_variable static data members declarations (PR #72236)

2023-11-14 Thread Greg Clayton via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Fixing a type encoding issue with dap Stopped events. (PR #72292)

2023-11-14 Thread Greg Clayton via lldb-commits


@@ -953,9 +953,9 @@ llvm::json::Value CreateThreadStopped(lldb::SBThread 
,
 } else {
   body.try_emplace("reason", "breakpoint");
   char desc_str[64];
-  uint64_t bp_id = thread.GetStopReasonDataAtIndex(0);
-  uint64_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
-  snprintf(desc_str, sizeof(desc_str), "breakpoint %" PRIu64 ".%" PRIu64,
+  break_id_t bp_id = thread.GetStopReasonDataAtIndex(0);

clayborg wrote:

We have an abstract API to access stop reason data via `uint64_t 
SBThread::GetStopReasonDataAtIndex(...)` which returns a `uint64_t`, but the 
`break_id_t` is defined as `typedef int32_t break_id_t;`. If we want to show 
the breakpoint ID correctly as a negative number for internal breakpoints, then 
this should be ok.

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


[Lldb-commits] [lldb] Centralize the code that figures out which memory ranges to save into core files (PR #71772)

2023-11-14 Thread Greg Clayton via lldb-commits

clayborg wrote:

> @clayborg I will try to reproduce on the buildbot windows machine. build 
> ongoing

If you end up being able to reproduce, if you can send the minidump file that 
was produced I should be able to look at it to make sure it was not produced by 
the core file saver. But if this is debugging a COFF file, it should only be 
using the native windows API to produce a core file and then load it. And I 
don't see any changes in this PR that should affect this, but you never know!

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


[Lldb-commits] [lldb] [lldb-dap] Fixing a type encoding issue with dap Stopped events. (PR #72292)

2023-11-14 Thread David Goldman via lldb-commits


@@ -953,9 +953,9 @@ llvm::json::Value CreateThreadStopped(lldb::SBThread 
,
 } else {
   body.try_emplace("reason", "breakpoint");
   char desc_str[64];
-  uint64_t bp_id = thread.GetStopReasonDataAtIndex(0);
-  uint64_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
-  snprintf(desc_str, sizeof(desc_str), "breakpoint %" PRIu64 ".%" PRIu64,
+  break_id_t bp_id = thread.GetStopReasonDataAtIndex(0);

DavidGoldman wrote:

This looks like an implicit cast from uint64_t to int32_t, how safe is this?

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


[Lldb-commits] [lldb] [flang] [mlir] [clang-tools-extra] [openmp] [clang] [libcxx] [libc] [llvm] GlobalISel: Guard return in llvm::getIConstantSplatVal (PR #71989)

2023-11-14 Thread Changpeng Fang via lldb-commits

changpeng wrote:

> Typo in subject "**Guard** return ..."?

You are right. Thanks.

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


[Lldb-commits] [lldb] [flang] [mlir] [clang-tools-extra] [openmp] [clang] [libcxx] [libc] [llvm] GlobalISel: Guard return in llvm::getIConstantSplatVal (PR #71989)

2023-11-14 Thread Changpeng Fang via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Fixing a type encoding issue with dap Stopped events. (PR #72292)

2023-11-14 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Fixing a type encoding issue with dap Stopped events. (PR #72292)

2023-11-14 Thread Greg Clayton via lldb-commits


@@ -953,9 +953,9 @@ llvm::json::Value CreateThreadStopped(lldb::SBThread 
,
 } else {
   body.try_emplace("reason", "breakpoint");
   char desc_str[64];
-  uint64_t bp_id = thread.GetStopReasonDataAtIndex(0);
-  uint64_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
-  snprintf(desc_str, sizeof(desc_str), "breakpoint %" PRIu64 ".%" PRIu64,
+  break_id_t bp_id = thread.GetStopReasonDataAtIndex(0);
+  break_id_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
+  snprintf(desc_str, sizeof(desc_str), "breakpoint %" PRIo32 ".%" PRIo32,

clayborg wrote:

This is indeed octal which isn't what we want. You need to use `PRIi32`

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


[Lldb-commits] [lldb] [lldb-dap] Fixing a type encoding issue with dap Stopped events. (PR #72292)

2023-11-14 Thread Greg Clayton via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for threads (PR #72196)

2023-11-14 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] 1654d7d - [lldb-dap] Add an option to provide a format for threads (#72196)

2023-11-14 Thread via lldb-commits

Author: Walter Erquinigo
Date: 2023-11-14T13:23:55-05:00
New Revision: 1654d7dc38af3bd10ab55929161966601672c115

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

LOG: [lldb-dap] Add an option to provide a format for threads (#72196)

When this option gets enabled, descriptions of threads will be generated
using the format provided in the launch configuration instead of
generating it manually in the dap code. This allows lldb-dap to show an
output similar to the one in the CLI.
This is very similar to https://github.com/llvm/llvm-project/pull/71843

Added: 
lldb/test/API/tools/lldb-dap/threads/Makefile
lldb/test/API/tools/lldb-dap/threads/TestDAP_threads.py
lldb/test/API/tools/lldb-dap/threads/main.c

Modified: 
lldb/include/lldb/API/SBFormat.h
lldb/include/lldb/API/SBThread.h
lldb/include/lldb/Target/Thread.h
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
lldb/source/API/SBThread.cpp
lldb/source/Target/Thread.cpp
lldb/tools/lldb-dap/DAP.cpp
lldb/tools/lldb-dap/DAP.h
lldb/tools/lldb-dap/JSONUtils.cpp
lldb/tools/lldb-dap/lldb-dap.cpp
lldb/tools/lldb-dap/package.json

Removed: 
lldb/test/API/tools/lldb-dap/correct-thread/Makefile
lldb/test/API/tools/lldb-dap/correct-thread/TestDAP_correct_thread.py
lldb/test/API/tools/lldb-dap/correct-thread/main.c



diff  --git a/lldb/include/lldb/API/SBFormat.h 
b/lldb/include/lldb/API/SBFormat.h
index 1bbaad18cafafab..757340ab2b5c2a4 100644
--- a/lldb/include/lldb/API/SBFormat.h
+++ b/lldb/include/lldb/API/SBFormat.h
@@ -52,6 +52,7 @@ class LLDB_API SBFormat {
 
 protected:
   friend class SBFrame;
+  friend class SBThread;
 
   /// \return
   ///   The underlying shared pointer storage for this object.

diff  --git a/lldb/include/lldb/API/SBThread.h 
b/lldb/include/lldb/API/SBThread.h
index 49c3d954fa93329..dcf6aa9d5424e85 100644
--- a/lldb/include/lldb/API/SBThread.h
+++ b/lldb/include/lldb/API/SBThread.h
@@ -200,6 +200,21 @@ class LLDB_API SBThread {
 
   bool GetDescription(lldb::SBStream , bool stop_format) const;
 
+  /// Similar to \a GetDescription() but the format of the description can be
+  /// configured via the \p format parameter. See
+  /// https://lldb.llvm.org/use/formatting.html for more information on format
+  /// strings.
+  ///
+  /// \param[in] format
+  ///   The format to use for generating the description.
+  ///
+  /// \param[out] output
+  ///   The stream where the description will be written to.
+  ///
+  /// \return
+  ///   An error object with an error message in case of failures.
+  SBError GetDescriptionWithFormat(const SBFormat , SBStream );
+
   bool GetStatus(lldb::SBStream ) const;
 
   SBThread GetExtendedBacktraceThread(const char *type);

diff  --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index dabdbb8d455021a..e423dd4a6d2baa7 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread.h
@@ -490,6 +490,23 @@ class Thread : public std::enable_shared_from_this,
   void DumpTraceInstructions(Stream , size_t count,
  size_t start_position = 0) const;
 
+  /// Print a description of this thread using the provided thread format.
+  ///
+  /// \param[out] strm
+  ///   The Stream to print the description to.
+  ///
+  /// \param[in] frame_idx
+  ///   If not \b LLDB_INVALID_FRAME_ID, then use this frame index as context 
to
+  ///   generate the description.
+  ///
+  /// \param[in] format
+  ///   The input format.
+  ///
+  /// \return
+  ///   \b true if and only if dumping with the given \p format worked.
+  bool DumpUsingFormat(Stream , uint32_t frame_idx,
+   const FormatEntity::Entry *format);
+
   // If stop_format is true, this will be the form used when we print stop
   // info. If false, it will be the form we use for thread list and co.
   void DumpUsingSettingsFormat(Stream , uint32_t frame_idx,

diff  --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index a41861c59d2875a..518e3b9cf5bab33 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -733,6 +733,7 @@ def request_launch(
 enableSyntheticChildDebugging=False,
 commandEscapePrefix="`",
 customFrameFormat=None,
+customThreadFormat=None,
 ):
 args_dict = {"program": program}
 if args:
@@ -776,6 +777,8 @@ def request_launch(
 args_dict["postRunCommands"] = postRunCommands
 if customFrameFormat:
 

[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for threads (PR #72196)

2023-11-14 Thread Greg Clayton via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Fixing a type encoding issue with dap Stopped events. (PR #72292)

2023-11-14 Thread Walter Erquinigo via lldb-commits


@@ -953,9 +953,9 @@ llvm::json::Value CreateThreadStopped(lldb::SBThread 
,
 } else {
   body.try_emplace("reason", "breakpoint");
   char desc_str[64];
-  uint64_t bp_id = thread.GetStopReasonDataAtIndex(0);
-  uint64_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
-  snprintf(desc_str, sizeof(desc_str), "breakpoint %" PRIu64 ".%" PRIu64,
+  break_id_t bp_id = thread.GetStopReasonDataAtIndex(0);
+  break_id_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
+  snprintf(desc_str, sizeof(desc_str), "breakpoint %" PRIo32 ".%" PRIo32,

walter-erquinigo wrote:

could you change this to use formatv? This kind of printing hurts my eyes.
Isn't PRIo32 octal?

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


[Lldb-commits] [lldb] [lldb-dap] Fixing a type encoding issue with dap Stopped events. (PR #72292)

2023-11-14 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)


Changes

Previously the type of the breakpoint id in the Stopped event was a uint64_t, 
however thats the wrong type for a breakpoint id, which can cause encoding 
issues when internal breakpoints are hit.

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


1 Files Affected:

- (modified) lldb/tools/lldb-dap/JSONUtils.cpp (+3-3) 


``diff
diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp 
b/lldb/tools/lldb-dap/JSONUtils.cpp
index 2023291729762f1..2b96c4f21aeb04d 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -953,9 +953,9 @@ llvm::json::Value CreateThreadStopped(lldb::SBThread 
,
 } else {
   body.try_emplace("reason", "breakpoint");
   char desc_str[64];
-  uint64_t bp_id = thread.GetStopReasonDataAtIndex(0);
-  uint64_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
-  snprintf(desc_str, sizeof(desc_str), "breakpoint %" PRIu64 ".%" PRIu64,
+  break_id_t bp_id = thread.GetStopReasonDataAtIndex(0);
+  break_id_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
+  snprintf(desc_str, sizeof(desc_str), "breakpoint %" PRIo32 ".%" PRIo32,
bp_id, bp_loc_id);
   body.try_emplace("hitBreakpointIds",
llvm::json::Array{llvm::json::Value(bp_id)});

``




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


[Lldb-commits] [lldb] [lldb-dap] Fixing a type encoding issue with dap Stopped events. (PR #72292)

2023-11-14 Thread John Harrison via lldb-commits

https://github.com/ashgti created 
https://github.com/llvm/llvm-project/pull/72292

Previously the type of the breakpoint id in the Stopped event was a uint64_t, 
however thats the wrong type for a breakpoint id, which can cause encoding 
issues when internal breakpoints are hit.

>From 5077857569f4f6ed74feedc2afe58a1a576ce4eb Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Tue, 14 Nov 2023 10:02:41 -0800
Subject: [PATCH] [lldb-dap] Fixing a type encoding issue with dap Stopped
 events.

Previously the type of the breakpoint id in the Stopped event was a uint64_t, 
however thats the wrong type for a breakpoint id, which can cause encoding 
issues when internal breakpoints are hit.
---
 lldb/tools/lldb-dap/JSONUtils.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp 
b/lldb/tools/lldb-dap/JSONUtils.cpp
index 2023291729762f1..2b96c4f21aeb04d 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -953,9 +953,9 @@ llvm::json::Value CreateThreadStopped(lldb::SBThread 
,
 } else {
   body.try_emplace("reason", "breakpoint");
   char desc_str[64];
-  uint64_t bp_id = thread.GetStopReasonDataAtIndex(0);
-  uint64_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
-  snprintf(desc_str, sizeof(desc_str), "breakpoint %" PRIu64 ".%" PRIu64,
+  break_id_t bp_id = thread.GetStopReasonDataAtIndex(0);
+  break_id_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
+  snprintf(desc_str, sizeof(desc_str), "breakpoint %" PRIo32 ".%" PRIo32,
bp_id, bp_loc_id);
   body.try_emplace("hitBreakpointIds",
llvm::json::Array{llvm::json::Value(bp_id)});

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread José Lira Junior via lldb-commits

junior-jl wrote:

In this last commit, your suggestions on the algorithm were done (the use of 
`remaining` instead of `text` and `drop_front`. Also, the method is now on 
`Stream` and called `PutCStringColorHighlighted` as you recommended. It looks 
way better that way.

> Then later use that with strm.printf like this: 
> https://godbolt.org/z/zG6Tsn4WP

This is new for me. Thank you!

In `Stream.h`, we tried to keep up with the file standard. Hence, the comments:

```cpp
  /// Output a C string to the stream with color highlighting.
  ///
  /// Print a C string \a text to the stream, applying color highlighting to
  /// the specified \a pattern within the string.
  ///
  /// \param[in] text
  /// The string to be output to the stream.
  ///
  /// \param[in] pattern
  /// The portion of the \a text string to be colorized for highlighting.
  void PutCStringColorHighlighted(llvm::StringRef text, const char *pattern);
```

Please let me know if we should drop these.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread José Lira Junior via lldb-commits

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

From 2c23aaf231beef11d3e0db6506fe82323a0be6a0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= 
Date: Tue, 7 Nov 2023 16:57:18 -0300
Subject: [PATCH 1/3] [lldb] colorize symbols in image lookup

---
 lldb/include/lldb/Core/Address.h  |  7 ++-
 lldb/include/lldb/Symbol/Symbol.h |  4 +-
 lldb/include/lldb/Symbol/SymbolContext.h  |  8 +--
 lldb/source/Commands/CommandObjectTarget.cpp  | 15 --
 lldb/source/Core/Address.cpp  | 53 ---
 lldb/source/Symbol/Symbol.cpp | 18 ---
 lldb/source/Symbol/SymbolContext.cpp  | 16 --
 .../Commands/command-image-lookup-color.test  | 25 +
 8 files changed, 114 insertions(+), 32 deletions(-)
 create mode 100644 lldb/test/Shell/Commands/command-image-lookup-color.test

diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h
index b19e694427546f8..fac0ced910a11d4 100644
--- a/lldb/include/lldb/Core/Address.h
+++ b/lldb/include/lldb/Core/Address.h
@@ -246,8 +246,11 @@ class Address {
   /// \see Address::DumpStyle
   bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
 DumpStyle fallback_style = DumpStyleInvalid,
-uint32_t addr_byte_size = UINT32_MAX,
-bool all_ranges = false) const;
+uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false,
+const char *pattern = nullptr) const;
+
+  static void DumpName(Stream *strm, llvm::StringRef text,
+   const char *pattern = nullptr);
 
   AddressClass GetAddressClass() const;
 
diff --git a/lldb/include/lldb/Symbol/Symbol.h 
b/lldb/include/lldb/Symbol/Symbol.h
index 44a2d560010fe40..0e41cd95e0ef17d 100644
--- a/lldb/include/lldb/Symbol/Symbol.h
+++ b/lldb/include/lldb/Symbol/Symbol.h
@@ -174,8 +174,8 @@ class Symbol : public SymbolContextScope {
 
   void SetFlags(uint32_t flags) { m_flags = flags; }
 
-  void GetDescription(Stream *s, lldb::DescriptionLevel level,
-  Target *target) const;
+  void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
+  const char *pattern = nullptr) const;
 
   bool IsSynthetic() const { return m_is_synthetic; }
 
diff --git a/lldb/include/lldb/Symbol/SymbolContext.h 
b/lldb/include/lldb/Symbol/SymbolContext.h
index b0f5ffead2a1656..9567c3f4384c175 100644
--- a/lldb/include/lldb/Symbol/SymbolContext.h
+++ b/lldb/include/lldb/Symbol/SymbolContext.h
@@ -150,8 +150,8 @@ class SymbolContext {
   bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope,
const Address _addr, bool show_fullpaths,
bool show_module, bool show_inlined_frames,
-   bool show_function_arguments,
-   bool show_function_name) const;
+   bool show_function_arguments, bool show_function_name,
+   const char *pattern = nullptr) const;
 
   /// Get the address range contained within a symbol context.
   ///
@@ -217,8 +217,8 @@ class SymbolContext {
   /// The symbol that was found, or \b nullptr if none was found.
   const Symbol *FindBestGlobalDataSymbol(ConstString name, Status );
 
-  void GetDescription(Stream *s, lldb::DescriptionLevel level,
-  Target *target) const;
+  void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
+  const char *pattern = nullptr) const;
 
   uint32_t GetResolvedMask() const;
 
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 8f052d0a7b837e2..a83575ad82d6909 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -8,6 +8,7 @@
 
 #include "CommandObjectTarget.h"
 
+#include "lldb/Core/Address.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/Module.h"
@@ -1534,7 +1535,7 @@ static void DumpOsoFilesTable(Stream ,
 
 static void DumpAddress(ExecutionContextScope *exe_scope,
 const Address _addr, bool verbose, bool all_ranges,
-Stream ) {
+Stream , const char *pattern = nullptr) {
   strm.IndentMore();
   strm.Indent("Address: ");
   so_addr.Dump(, exe_scope, Address::DumpStyleModuleWithFileAddress);
@@ -1544,13 +1545,14 @@ static void DumpAddress(ExecutionContextScope 
*exe_scope,
   strm.Indent("Summary: ");
   const uint32_t save_indent = strm.GetIndentLevel();
   strm.SetIndentLevel(save_indent + 13);
-  so_addr.Dump(, exe_scope, Address::DumpStyleResolvedDescription);
+  so_addr.Dump(, exe_scope, Address::DumpStyleResolvedDescription,
+   Address::DumpStyleInvalid, UINT32_MAX, false, pattern);
   strm.SetIndentLevel(save_indent);
   // Print out detailed address 

[Lldb-commits] [lldb] Centralize the code that figures out which memory ranges to save into core files (PR #71772)

2023-11-14 Thread antoine moynault via lldb-commits

antmox wrote:

@clayborg 
I will try to reproduce on the buildbot windows machine. build ongoing

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread José Lira Junior via lldb-commits

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread José Lira Junior via lldb-commits


@@ -163,7 +166,10 @@ bool SymbolContext::DumpStopContext(Stream *s, 
ExecutionContextScope *exe_scope,
   dumped_something = true;
   if (symbol->GetType() == eSymbolTypeTrampoline)
 s->PutCString("symbol stub for: ");
-  symbol->GetName().Dump(s);
+  if (pattern)
+Address::DumpName(s, symbol->GetName().GetStringRef(), pattern);
+  else
+symbol->GetName().Dump(s);

junior-jl wrote:

✅ 

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread José Lira Junior via lldb-commits


@@ -252,11 +253,16 @@ void Symbol::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
   s->Printf(", value = 0x%16.16" PRIx64,
 m_addr_range.GetBaseAddress().GetOffset());
   }
-  ConstString demangled = GetMangled().GetDemangledName();
-  if (demangled)
-s->Printf(", name=\"%s\"", demangled.AsCString());
-  if (m_mangled.GetMangledName())
-s->Printf(", mangled=\"%s\"", m_mangled.GetMangledName().AsCString());
+  if (ConstString mangled_name = m_mangled.GetMangledName()) {
+s->Printf(", mangled=\"");
+Address::DumpName(s, mangled_name.GetStringRef(), pattern);
+s->Printf("\"");
+  }
+  if (ConstString demangled = m_mangled.GetDemangledName()) {
+s->Printf(", name=\"");
+Address::DumpName(s, demangled.GetStringRef(), pattern);
+s->Printf("\"");

junior-jl wrote:

Thanks, corrected!

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread José Lira Junior via lldb-commits

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread José Lira Junior via lldb-commits


@@ -95,7 +97,8 @@ bool SymbolContext::DumpStopContext(Stream *s, 
ExecutionContextScope *exe_scope,
   if (!name)
 name = function->GetName();
   if (name)
-name.Dump(s);
+pattern ? Address::DumpName(s, name.GetStringRef(), pattern)
+: name.Dump(s);

junior-jl wrote:

True. I did not do this in first place, because I didn't realize that `Dump(s)` 
would basically be `s.PutCString(name)`. Changed this.

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


[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for threads (PR #72196)

2023-11-14 Thread Walter Erquinigo via lldb-commits

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

>From b6205d1befdaefc5ef17a9bc7b3eec960caecda6 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 13 Nov 2023 21:42:26 -0500
Subject: [PATCH] thread format

---
 lldb/include/lldb/API/SBFormat.h  |  1 +
 lldb/include/lldb/API/SBThread.h  | 15 +++
 lldb/include/lldb/Target/Thread.h | 17 
 .../test/tools/lldb-dap/dap_server.py |  3 ++
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  4 ++
 lldb/source/API/SBThread.cpp  | 35 ---
 lldb/source/Target/Thread.cpp | 19 +---
 .../{correct-thread => threads}/Makefile  |  0
 .../TestDAP_threads.py}   | 27 +++-
 .../{correct-thread => threads}/main.c|  0
 lldb/tools/lldb-dap/DAP.cpp   | 17 +++-
 lldb/tools/lldb-dap/DAP.h |  3 ++
 lldb/tools/lldb-dap/JSONUtils.cpp | 43 +++
 lldb/tools/lldb-dap/lldb-dap.cpp  |  2 +
 lldb/tools/lldb-dap/package.json  | 10 +
 15 files changed, 164 insertions(+), 32 deletions(-)
 rename lldb/test/API/tools/lldb-dap/{correct-thread => threads}/Makefile (100%)
 rename lldb/test/API/tools/lldb-dap/{correct-thread/TestDAP_correct_thread.py 
=> threads/TestDAP_threads.py} (63%)
 rename lldb/test/API/tools/lldb-dap/{correct-thread => threads}/main.c (100%)

diff --git a/lldb/include/lldb/API/SBFormat.h b/lldb/include/lldb/API/SBFormat.h
index 1bbaad18cafafab..757340ab2b5c2a4 100644
--- a/lldb/include/lldb/API/SBFormat.h
+++ b/lldb/include/lldb/API/SBFormat.h
@@ -52,6 +52,7 @@ class LLDB_API SBFormat {
 
 protected:
   friend class SBFrame;
+  friend class SBThread;
 
   /// \return
   ///   The underlying shared pointer storage for this object.
diff --git a/lldb/include/lldb/API/SBThread.h b/lldb/include/lldb/API/SBThread.h
index 49c3d954fa93329..dcf6aa9d5424e85 100644
--- a/lldb/include/lldb/API/SBThread.h
+++ b/lldb/include/lldb/API/SBThread.h
@@ -200,6 +200,21 @@ class LLDB_API SBThread {
 
   bool GetDescription(lldb::SBStream , bool stop_format) const;
 
+  /// Similar to \a GetDescription() but the format of the description can be
+  /// configured via the \p format parameter. See
+  /// https://lldb.llvm.org/use/formatting.html for more information on format
+  /// strings.
+  ///
+  /// \param[in] format
+  ///   The format to use for generating the description.
+  ///
+  /// \param[out] output
+  ///   The stream where the description will be written to.
+  ///
+  /// \return
+  ///   An error object with an error message in case of failures.
+  SBError GetDescriptionWithFormat(const SBFormat , SBStream );
+
   bool GetStatus(lldb::SBStream ) const;
 
   SBThread GetExtendedBacktraceThread(const char *type);
diff --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index dabdbb8d455021a..e423dd4a6d2baa7 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread.h
@@ -490,6 +490,23 @@ class Thread : public std::enable_shared_from_this,
   void DumpTraceInstructions(Stream , size_t count,
  size_t start_position = 0) const;
 
+  /// Print a description of this thread using the provided thread format.
+  ///
+  /// \param[out] strm
+  ///   The Stream to print the description to.
+  ///
+  /// \param[in] frame_idx
+  ///   If not \b LLDB_INVALID_FRAME_ID, then use this frame index as context 
to
+  ///   generate the description.
+  ///
+  /// \param[in] format
+  ///   The input format.
+  ///
+  /// \return
+  ///   \b true if and only if dumping with the given \p format worked.
+  bool DumpUsingFormat(Stream , uint32_t frame_idx,
+   const FormatEntity::Entry *format);
+
   // If stop_format is true, this will be the form used when we print stop
   // info. If false, it will be the form we use for thread list and co.
   void DumpUsingSettingsFormat(Stream , uint32_t frame_idx,
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index a41861c59d2875a..518e3b9cf5bab33 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -733,6 +733,7 @@ def request_launch(
 enableSyntheticChildDebugging=False,
 commandEscapePrefix="`",
 customFrameFormat=None,
+customThreadFormat=None,
 ):
 args_dict = {"program": program}
 if args:
@@ -776,6 +777,8 @@ def request_launch(
 args_dict["postRunCommands"] = postRunCommands
 if customFrameFormat:
 args_dict["customFrameFormat"] = customFrameFormat
+if customThreadFormat:
+args_dict["customThreadFormat"] = customThreadFormat
 
 args_dict["enableAutoVariableSummaries"] = 

[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for threads (PR #72196)

2023-11-14 Thread Walter Erquinigo via lldb-commits


@@ -839,4 +839,19 @@ void DAP::SetFrameFormat(llvm::StringRef format) {
   }
 }
 
+void DAP::SetThreadFormat(llvm::StringRef format) {
+  if (format.empty())
+return;
+  lldb::SBError error;
+  g_dap.thread_format = lldb::SBFormat(format.data(), error);

walter-erquinigo wrote:

good catch. I sometimes forget that StringRef can contain anything

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


[Lldb-commits] [lldb] [lldb] Fix MaxSummaryLength target property type (PR #72233)

2023-11-14 Thread via lldb-commits

dancing-leaves wrote:

@DavidSpickett sure, thanks for the tip on where to add it. Will update the PR 
with tests.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread via lldb-commits

https://github.com/taalhaataahir0102 updated 
https://github.com/llvm/llvm-project/pull/69422

>From 2c23aaf231beef11d3e0db6506fe82323a0be6a0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= 
Date: Tue, 7 Nov 2023 16:57:18 -0300
Subject: [PATCH 1/2] [lldb] colorize symbols in image lookup

---
 lldb/include/lldb/Core/Address.h  |  7 ++-
 lldb/include/lldb/Symbol/Symbol.h |  4 +-
 lldb/include/lldb/Symbol/SymbolContext.h  |  8 +--
 lldb/source/Commands/CommandObjectTarget.cpp  | 15 --
 lldb/source/Core/Address.cpp  | 53 ---
 lldb/source/Symbol/Symbol.cpp | 18 ---
 lldb/source/Symbol/SymbolContext.cpp  | 16 --
 .../Commands/command-image-lookup-color.test  | 25 +
 8 files changed, 114 insertions(+), 32 deletions(-)
 create mode 100644 lldb/test/Shell/Commands/command-image-lookup-color.test

diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h
index b19e694427546f8..fac0ced910a11d4 100644
--- a/lldb/include/lldb/Core/Address.h
+++ b/lldb/include/lldb/Core/Address.h
@@ -246,8 +246,11 @@ class Address {
   /// \see Address::DumpStyle
   bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
 DumpStyle fallback_style = DumpStyleInvalid,
-uint32_t addr_byte_size = UINT32_MAX,
-bool all_ranges = false) const;
+uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false,
+const char *pattern = nullptr) const;
+
+  static void DumpName(Stream *strm, llvm::StringRef text,
+   const char *pattern = nullptr);
 
   AddressClass GetAddressClass() const;
 
diff --git a/lldb/include/lldb/Symbol/Symbol.h 
b/lldb/include/lldb/Symbol/Symbol.h
index 44a2d560010fe40..0e41cd95e0ef17d 100644
--- a/lldb/include/lldb/Symbol/Symbol.h
+++ b/lldb/include/lldb/Symbol/Symbol.h
@@ -174,8 +174,8 @@ class Symbol : public SymbolContextScope {
 
   void SetFlags(uint32_t flags) { m_flags = flags; }
 
-  void GetDescription(Stream *s, lldb::DescriptionLevel level,
-  Target *target) const;
+  void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
+  const char *pattern = nullptr) const;
 
   bool IsSynthetic() const { return m_is_synthetic; }
 
diff --git a/lldb/include/lldb/Symbol/SymbolContext.h 
b/lldb/include/lldb/Symbol/SymbolContext.h
index b0f5ffead2a1656..9567c3f4384c175 100644
--- a/lldb/include/lldb/Symbol/SymbolContext.h
+++ b/lldb/include/lldb/Symbol/SymbolContext.h
@@ -150,8 +150,8 @@ class SymbolContext {
   bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope,
const Address _addr, bool show_fullpaths,
bool show_module, bool show_inlined_frames,
-   bool show_function_arguments,
-   bool show_function_name) const;
+   bool show_function_arguments, bool show_function_name,
+   const char *pattern = nullptr) const;
 
   /// Get the address range contained within a symbol context.
   ///
@@ -217,8 +217,8 @@ class SymbolContext {
   /// The symbol that was found, or \b nullptr if none was found.
   const Symbol *FindBestGlobalDataSymbol(ConstString name, Status );
 
-  void GetDescription(Stream *s, lldb::DescriptionLevel level,
-  Target *target) const;
+  void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
+  const char *pattern = nullptr) const;
 
   uint32_t GetResolvedMask() const;
 
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 8f052d0a7b837e2..a83575ad82d6909 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -8,6 +8,7 @@
 
 #include "CommandObjectTarget.h"
 
+#include "lldb/Core/Address.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/Module.h"
@@ -1534,7 +1535,7 @@ static void DumpOsoFilesTable(Stream ,
 
 static void DumpAddress(ExecutionContextScope *exe_scope,
 const Address _addr, bool verbose, bool all_ranges,
-Stream ) {
+Stream , const char *pattern = nullptr) {
   strm.IndentMore();
   strm.Indent("Address: ");
   so_addr.Dump(, exe_scope, Address::DumpStyleModuleWithFileAddress);
@@ -1544,13 +1545,14 @@ static void DumpAddress(ExecutionContextScope 
*exe_scope,
   strm.Indent("Summary: ");
   const uint32_t save_indent = strm.GetIndentLevel();
   strm.SetIndentLevel(save_indent + 13);
-  so_addr.Dump(, exe_scope, Address::DumpStyleResolvedDescription);
+  so_addr.Dump(, exe_scope, Address::DumpStyleResolvedDescription,
+   Address::DumpStyleInvalid, UINT32_MAX, false, pattern);
   strm.SetIndentLevel(save_indent);
   // Print out detailed 

[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] DWARFv5: support DW_TAG_variable static data members declarations (PR #72236)

2023-11-14 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/72236

>From de2be505917256a03718a10928547730d03bc8bc Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 13 Nov 2023 08:13:08 +
Subject: [PATCH 1/2] [lldb][DWARFASTParserClang] DWARFv5: support
 DW_TAG_variable static data members

The accepted DWARFv5 issue 161118.1: "DW_TAG for C++ static data members"
specifies that static data member declaration be described
by DW_TAG_variable. Make sure we recognize such members.
---
 .../Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp  | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index f5628b2753da2a7..79d3199855e1be7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -144,7 +144,7 @@ static bool ShouldIgnoreArtificialField(llvm::StringRef 
FieldName) {
 
 std::optional
 DWARFASTParserClang::FindConstantOnVariableDefinition(DWARFDIE die) {
-  assert(die.Tag() == llvm::dwarf::DW_TAG_member);
+  assert(die.Tag() == DW_TAG_member || die.Tag() == DW_TAG_variable);
 
   auto *dwarf = die.GetDWARF();
   if (!dwarf)
@@ -2889,7 +2889,7 @@ void DWARFASTParserClang::CreateStaticMemberVariable(
 const DWARFDIE , const MemberAttributes ,
 const lldb_private::CompilerType _clang_type) {
   Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
-  assert(die.Tag() == DW_TAG_member);
+  assert(die.Tag() == DW_TAG_member || die.Tag() == DW_TAG_variable);
 
   Type *var_type = die.ResolveTypeUID(attrs.encoding_form.Reference());
 
@@ -3195,6 +3195,10 @@ bool DWARFASTParserClang::ParseChildMembers(
   }
   break;
 
+case DW_TAG_variable: {
+  const MemberAttributes attrs(die, parent_die, module_sp);
+  CreateStaticMemberVariable(die, attrs, class_clang_type);
+} break;
 case DW_TAG_member:
   ParseSingleMember(die, parent_die, class_clang_type,
 default_accessibility, layout_info, last_field_info);

>From 85f9a63eacee3ce450177b48c4abb40e4cf1e897 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Tue, 14 Nov 2023 10:33:41 +
Subject: [PATCH 2/2] fixup! add comment

---
 lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 79d3199855e1be7..37efe70461977ad 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2965,6 +2965,7 @@ void DWARFASTParserClang::ParseSingleMember(
   // data members is DW_AT_declaration, so we check it instead.
   // FIXME: Since DWARFv5, static data members are marked DW_AT_variable so we
   // can consistently detect them on both GCC and Clang without below 
heuristic.
+  // Remove this block if we ever drop DWARFv4 support.
   if (attrs.member_byte_offset == UINT32_MAX &&
   attrs.data_bit_offset == UINT64_MAX && attrs.is_declaration) {
 CreateStaticMemberVariable(die, attrs, class_clang_type);

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


[Lldb-commits] [lldb] 27c5a9b - [lldb][test] TestConstStaticIntegralMember.py: fix on older clang versions

2023-11-14 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2023-11-14T10:31:07Z
New Revision: 27c5a9bbb01a464bb85624db2d0808f30de7c996

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

LOG: [lldb][test] TestConstStaticIntegralMember.py: fix on older clang versions

`638a8393615e911b729d5662096f60ef49f1c65e` removed the `dsym`
condition for older compiler versions which caused the `dwarf`
variants tests to XPASS. This patch reverts to only XFAIL-ing
the `dsym` variant.

`15c80852028ff4020b3f85ee13ad3a2ed4bce3be` added
`test_shadowed_static_inline_members` which isn't supported
on older compiler versions.

Added: 


Modified: 

lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py

Removed: 




diff  --git 
a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
 
b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
index b84f376a3e4400d..2e078ce9446b01a 100644
--- 
a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ 
b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -105,7 +105,9 @@ def test(self):
 # For debug-info produced by older versions of clang, dsymutil strips the
 # debug info for classes that only have const static data members without
 # definitions.
-@expectedFailureAll(compiler=["clang"], compiler_version=["<", "18.0"])
+@expectedFailureAll(
+debug_info=["dsym"], compiler=["clang"], compiler_version=["<", "18.0"]
+)
 def test_class_with_only_const_static(self):
 self.build()
 lldbutil.run_to_source_breakpoint(
@@ -172,6 +174,9 @@ def test_class_with_only_constexpr_static(self):
 "ClassWithEnumAlias::enum_alias_alias", 
result_value="scoped_enum_case1"
 )
 
+# With older versions of Clang, LLDB fails to evaluate classes with only
+# constexpr members when dsymutil is enabled
+@expectedFailureAll(compiler=["clang"], compiler_version=["<", "18.0"])
 def test_shadowed_static_inline_members(self):
 """Tests that the expression evaluator and SBAPI can both
 correctly determine the requested inline static variable



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


[Lldb-commits] [lldb] [lldb] Fix MaxSummaryLength target property type (PR #72233)

2023-11-14 Thread David Spickett via lldb-commits

DavidSpickett wrote:

If you are comfortable adding and running tests, 
`lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py`
 is the place for it, after the `max-children-count` ones.

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


[Lldb-commits] [lldb] [lldb] Fix MaxSummaryLength target property type (PR #72233)

2023-11-14 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Turns out you can't set a negative value from within lldb at least:
```
(lldb) settings set target.max-string-summary-length -1
error: unknown or ambiguous option
```

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] DWARFv5: support DW_TAG_variable static data members declarations (PR #72236)

2023-11-14 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] DWARFv5: support DW_TAG_variable static data members declarations (PR #72236)

2023-11-14 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

The accepted DWARFv5 issue 161118.1: "DW_TAG for C++ static data members" 
specifies that static data member declaration be described by DW_TAG_variable. 
Make sure we recognize such members.

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


1 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(+6-2) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index f5628b2753da2a7..79d3199855e1be7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -144,7 +144,7 @@ static bool ShouldIgnoreArtificialField(llvm::StringRef 
FieldName) {
 
 std::optional
 DWARFASTParserClang::FindConstantOnVariableDefinition(DWARFDIE die) {
-  assert(die.Tag() == llvm::dwarf::DW_TAG_member);
+  assert(die.Tag() == DW_TAG_member || die.Tag() == DW_TAG_variable);
 
   auto *dwarf = die.GetDWARF();
   if (!dwarf)
@@ -2889,7 +2889,7 @@ void DWARFASTParserClang::CreateStaticMemberVariable(
 const DWARFDIE , const MemberAttributes ,
 const lldb_private::CompilerType _clang_type) {
   Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
-  assert(die.Tag() == DW_TAG_member);
+  assert(die.Tag() == DW_TAG_member || die.Tag() == DW_TAG_variable);
 
   Type *var_type = die.ResolveTypeUID(attrs.encoding_form.Reference());
 
@@ -3195,6 +3195,10 @@ bool DWARFASTParserClang::ParseChildMembers(
   }
   break;
 
+case DW_TAG_variable: {
+  const MemberAttributes attrs(die, parent_die, module_sp);
+  CreateStaticMemberVariable(die, attrs, class_clang_type);
+} break;
 case DW_TAG_member:
   ParseSingleMember(die, parent_die, class_clang_type,
 default_accessibility, layout_info, last_field_info);

``




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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] DWARFv5: support DW_TAG_variable static data members declarations (PR #72236)

2023-11-14 Thread Michael Buch via lldb-commits

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/72236

The accepted DWARFv5 issue 161118.1: "DW_TAG for C++ static data members" 
specifies that static data member declaration be described by DW_TAG_variable. 
Make sure we recognize such members.

>From de2be505917256a03718a10928547730d03bc8bc Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 13 Nov 2023 08:13:08 +
Subject: [PATCH] [lldb][DWARFASTParserClang] DWARFv5: support DW_TAG_variable
 static data members

The accepted DWARFv5 issue 161118.1: "DW_TAG for C++ static data members"
specifies that static data member declaration be described
by DW_TAG_variable. Make sure we recognize such members.
---
 .../Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp  | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index f5628b2753da2a7..79d3199855e1be7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -144,7 +144,7 @@ static bool ShouldIgnoreArtificialField(llvm::StringRef 
FieldName) {
 
 std::optional
 DWARFASTParserClang::FindConstantOnVariableDefinition(DWARFDIE die) {
-  assert(die.Tag() == llvm::dwarf::DW_TAG_member);
+  assert(die.Tag() == DW_TAG_member || die.Tag() == DW_TAG_variable);
 
   auto *dwarf = die.GetDWARF();
   if (!dwarf)
@@ -2889,7 +2889,7 @@ void DWARFASTParserClang::CreateStaticMemberVariable(
 const DWARFDIE , const MemberAttributes ,
 const lldb_private::CompilerType _clang_type) {
   Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
-  assert(die.Tag() == DW_TAG_member);
+  assert(die.Tag() == DW_TAG_member || die.Tag() == DW_TAG_variable);
 
   Type *var_type = die.ResolveTypeUID(attrs.encoding_form.Reference());
 
@@ -3195,6 +3195,10 @@ bool DWARFASTParserClang::ParseChildMembers(
   }
   break;
 
+case DW_TAG_variable: {
+  const MemberAttributes attrs(die, parent_die, module_sp);
+  CreateStaticMemberVariable(die, attrs, class_clang_type);
+} break;
 case DW_TAG_member:
   ParseSingleMember(die, parent_die, class_clang_type,
 default_accessibility, layout_info, last_field_info);

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


[Lldb-commits] [lldb] [lldb] Fix MaxSummaryLength target property type (PR #72233)

2023-11-14 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Thanks for the fix!

You'll be shocked (not shocked :) ) to know that there are zero tests for this 
setting currently. I'll have a look for an obvious place to put that, isn't 
difficult to test as you've shown.

I can't think of any reason to have negative summary lengths, so changing to 
unsigned doesn't seem like an issue.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> Hello again, David. We've done these. When I fetched the most recent changes 
> in LLVM project today, the ninja check-lldb was okay again. Just FYI, I did 
> not update any dependency.

Nice, there was a change around there recently but I didn't feel like making 
you update if it wasn't necessary.

> I tried commenting on the more recent suggestions you made that were 
> addressed.

Yes thank you this is looking *very* clean now!

> Should we add some tests to the file with settings set use-color false?

As long as that file has 1 regex search in it, then no. All you need to be sure 
of is that when colours are disabled, none are emitted. All the multiple match, 
end of string match, etc, that can stay in the test file you've got.

> Right now, the colorize only works for symbols, i.e., the -s flag. Should 
> this also work for the -F and -n flags? If so, is it better that we add this 
> on this PR or in another patch?

That would be fantastic, but you should concentrate on symbols for this PR. 
It's enough to stand on its own as a change.

Finally, one of you asked about where `Address::DumpName` should live. Now the 
code is cleaned up, I see more clearly what you mean.

Looking at the signature `Address::DumpName(Stream *strm, llvm::StringRef text, 
const char *pattern)` you could imagine this as a member of Stream instead. 
Perhaps `.PutCStringHighlighted(`? Then you can do 
`strm.PutCStringHighlighted(text, pattern)`.

Maybe having "color" in the name is good. `PutCStringColorHighlighted`?

Then 1. You can have standalone tests and do less testing in the shell tests 
and 2. If you do want to do files and function highlighting, it's in a nice 
central place.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread David Spickett via lldb-commits


@@ -0,0 +1,25 @@
+# RUN: %clang_host -g %S/Inputs/main.c -o %t
+
+# Checking simple search
+
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s ma' 
| FileCheck %s --check-prefix CHECK1
+# CHECK1: Name: {{.+}}31mma{{.+}}0min.c
+# CHECK1: Summary: {{.+}}`{{.+}}31mma{{.+}}0min at main.c:2
+
+# Checking for regex searches
+
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s 
main.c|foo' | FileCheck %s --check-prefix CHECK2
+# CHECK2: Name: {{.+}}31mmain.c{{.+}}0m
+# CHECK2: Summary: {{.+}}`{{.+}}31mfoo{{.+}}0m at main.c:1
+
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s 
m[abc]' | FileCheck %s --check-prefix CHECK3
+# CHECK3: Name: {{.+}}31mma{{.+}}0min.c
+# CHECK3: Summary: {{.+}}`{{.+}}31mma{{.+}}0min at main.c:2
+
+# Checking tail match
+
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s 
.*o$' | FileCheck %s --check-prefix CHECK4
+# CHECK4: Summary: {{.+}}`{{.+}}31mfoo{{.+}}0m at main.c:1
+
+# RUN: %lldb %t -o 'settings set use-color true' -o 'image lookup -r -s 
IMPPATTERN123456' | FileCheck %s --check-prefix CHECK5

DavidSpickett wrote:

Comment here like, "check that we don't attempt to color anything when there 
are no symbols".

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread David Spickett via lldb-commits


@@ -403,9 +404,41 @@ bool Address::GetDescription(Stream , Target ,
   return false;
 }
 
+void Address::DumpName(Stream *strm, llvm::StringRef text,
+   const char *pattern) {
+  if (!pattern) {
+strm->PutCString(text.data());
+return;
+  }
+
+  llvm::Regex reg_pattern(pattern);
+  llvm::SmallVector matches;
+  llvm::StringRef remaining = text;
+  std::string red_start =
+  lldb_private::ansi::FormatAnsiTerminalCodes("${ansi.fg.red}");
+  std::string reset_color =
+  lldb_private::ansi::FormatAnsiTerminalCodes("${ansi.normal}");

DavidSpickett wrote:

I'm also wondering whether you could make this into a format string like:
```
lldb_private::ansi::FormatAnsiTerminalCodes("${ansi.fg.red}%s${ansi.normal}")
```
Then later use that with strm.printf like this: https://godbolt.org/z/zG6Tsn4WP

Assuming that stream's Printf does support `.*` like that.

Just saves you having to wrap the colour codes around the text each time and is 
a bit more obvious to the reader.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread David Spickett via lldb-commits


@@ -403,9 +404,41 @@ bool Address::GetDescription(Stream , Target ,
   return false;
 }
 
+void Address::DumpName(Stream *strm, llvm::StringRef text,
+   const char *pattern) {
+  if (!pattern) {
+strm->PutCString(text.data());
+return;
+  }
+
+  llvm::Regex reg_pattern(pattern);
+  llvm::SmallVector matches;
+  llvm::StringRef remaining = text;
+  std::string red_start =
+  lldb_private::ansi::FormatAnsiTerminalCodes("${ansi.fg.red}");
+  std::string reset_color =
+  lldb_private::ansi::FormatAnsiTerminalCodes("${ansi.normal}");
+
+  size_t last_pos = 0;
+  while (reg_pattern.match(remaining, )) {
+llvm::StringRef match = matches[0];
+size_t match_start_pos = match.data() - text.data();
+size_t match_end_pos = match_start_pos + match.size();
+
+strm->Write(text.data() + last_pos, match_start_pos - last_pos);
+strm->PutCString(red_start.c_str());
+strm->Write(text.data() + match_start_pos, match.size());
+strm->PutCString(reset_color.c_str());
+last_pos = match_end_pos;
+remaining = text.substr(last_pos);
+  }
+  if (last_pos < text.size())
+strm->PutCString(text.data() + last_pos);

DavidSpickett wrote:

Is this the same as using `remaining` ? Maybe it could be `if 
(remaining.size()) { stream remaining}`.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread David Spickett via lldb-commits


@@ -403,9 +404,41 @@ bool Address::GetDescription(Stream , Target ,
   return false;
 }
 
+void Address::DumpName(Stream *strm, llvm::StringRef text,
+   const char *pattern) {
+  if (!pattern) {
+strm->PutCString(text.data());
+return;
+  }
+
+  llvm::Regex reg_pattern(pattern);
+  llvm::SmallVector matches;
+  llvm::StringRef remaining = text;
+  std::string red_start =
+  lldb_private::ansi::FormatAnsiTerminalCodes("${ansi.fg.red}");
+  std::string reset_color =
+  lldb_private::ansi::FormatAnsiTerminalCodes("${ansi.normal}");
+
+  size_t last_pos = 0;
+  while (reg_pattern.match(remaining, )) {
+llvm::StringRef match = matches[0];
+size_t match_start_pos = match.data() - text.data();
+size_t match_end_pos = match_start_pos + match.size();
+
+strm->Write(text.data() + last_pos, match_start_pos - last_pos);

DavidSpickett wrote:

Is `text.data() + last_pos` == `remaining` in this case? Maybe not but if it is 
it'd be a nice simplification.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread David Spickett via lldb-commits


@@ -95,7 +97,8 @@ bool SymbolContext::DumpStopContext(Stream *s, 
ExecutionContextScope *exe_scope,
   if (!name)
 name = function->GetName();
   if (name)
-name.Dump(s);
+pattern ? Address::DumpName(s, name.GetStringRef(), pattern)
+: name.Dump(s);

DavidSpickett wrote:

But cool use of the `?` regardless :)

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread David Spickett via lldb-commits


@@ -95,7 +97,8 @@ bool SymbolContext::DumpStopContext(Stream *s, 
ExecutionContextScope *exe_scope,
   if (!name)
 name = function->GetName();
   if (name)
-name.Dump(s);
+pattern ? Address::DumpName(s, name.GetStringRef(), pattern)
+: name.Dump(s);

DavidSpickett wrote:

Could you just call Address::DumpName all the time here? If `pattern` is 
`nullptr` it will take the fast path and just dump the string won't it?

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread David Spickett via lldb-commits


@@ -403,9 +404,41 @@ bool Address::GetDescription(Stream , Target ,
   return false;
 }
 
+void Address::DumpName(Stream *strm, llvm::StringRef text,
+   const char *pattern) {
+  if (!pattern) {
+strm->PutCString(text.data());
+return;
+  }
+
+  llvm::Regex reg_pattern(pattern);
+  llvm::SmallVector matches;
+  llvm::StringRef remaining = text;
+  std::string red_start =
+  lldb_private::ansi::FormatAnsiTerminalCodes("${ansi.fg.red}");
+  std::string reset_color =
+  lldb_private::ansi::FormatAnsiTerminalCodes("${ansi.normal}");
+
+  size_t last_pos = 0;
+  while (reg_pattern.match(remaining, )) {
+llvm::StringRef match = matches[0];
+size_t match_start_pos = match.data() - text.data();
+size_t match_end_pos = match_start_pos + match.size();
+
+strm->Write(text.data() + last_pos, match_start_pos - last_pos);
+strm->PutCString(red_start.c_str());
+strm->Write(text.data() + match_start_pos, match.size());
+strm->PutCString(reset_color.c_str());
+last_pos = match_end_pos;
+remaining = text.substr(last_pos);

DavidSpickett wrote:

It may be clearer to `drop_front` (or `substr`, it's the same thing but my 
functional bias prefers drop) from `remaining` as we go, instead of referring 
to `text` all the time.

So you print up to where the match is, drop_front however much that was, print 
the match, drop_front the size of the match, etc, etc.

That way the algorithm is all centered on `remaining` and we aren't referring 
back to `text` the whole time.

And it can be summed up as "while there is remaining text keep printing it".

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread David Spickett via lldb-commits


@@ -403,9 +404,41 @@ bool Address::GetDescription(Stream , Target ,
   return false;
 }
 
+void Address::DumpName(Stream *strm, llvm::StringRef text,
+   const char *pattern) {
+  if (!pattern) {
+strm->PutCString(text.data());
+return;
+  }
+
+  llvm::Regex reg_pattern(pattern);
+  llvm::SmallVector matches;
+  llvm::StringRef remaining = text;
+  std::string red_start =

DavidSpickett wrote:

Worth adding a comment here that if pattern is not null, we know we have been 
asked to use colours.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread David Spickett via lldb-commits


@@ -0,0 +1,25 @@
+# RUN: %clang_host -g %S/Inputs/main.c -o %t
+
+# Checking simple search

DavidSpickett wrote:

This one is also regex, so "simple regex search"?

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread David Spickett via lldb-commits


@@ -0,0 +1,25 @@
+# RUN: %clang_host -g %S/Inputs/main.c -o %t
+
+# Checking simple search
+
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s ma' 
| FileCheck %s --check-prefix CHECK1
+# CHECK1: Name: {{.+}}31mma{{.+}}0min.c
+# CHECK1: Summary: {{.+}}`{{.+}}31mma{{.+}}0min at main.c:2
+
+# Checking for regex searches

DavidSpickett wrote:

Maybe "search that finds >1 symbol"?

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread David Spickett via lldb-commits


@@ -163,7 +166,10 @@ bool SymbolContext::DumpStopContext(Stream *s, 
ExecutionContextScope *exe_scope,
   dumped_something = true;
   if (symbol->GetType() == eSymbolTypeTrampoline)
 s->PutCString("symbol stub for: ");
-  symbol->GetName().Dump(s);
+  if (pattern)
+Address::DumpName(s, symbol->GetName().GetStringRef(), pattern);
+  else
+symbol->GetName().Dump(s);

DavidSpickett wrote:

Same here, I think you can just always call Address::DumpName and it'll take 
the fast path if pattern is nullptr.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread David Spickett via lldb-commits


@@ -0,0 +1,25 @@
+# RUN: %clang_host -g %S/Inputs/main.c -o %t
+
+# Checking simple search
+
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s ma' 
| FileCheck %s --check-prefix CHECK1
+# CHECK1: Name: {{.+}}31mma{{.+}}0min.c
+# CHECK1: Summary: {{.+}}`{{.+}}31mma{{.+}}0min at main.c:2
+
+# Checking for regex searches
+
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s 
main.c|foo' | FileCheck %s --check-prefix CHECK2
+# CHECK2: Name: {{.+}}31mmain.c{{.+}}0m
+# CHECK2: Summary: {{.+}}`{{.+}}31mfoo{{.+}}0m at main.c:1
+
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s 
m[abc]' | FileCheck %s --check-prefix CHECK3
+# CHECK3: Name: {{.+}}31mma{{.+}}0min.c
+# CHECK3: Summary: {{.+}}`{{.+}}31mma{{.+}}0min at main.c:2
+
+# Checking tail match
+
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s 
.*o$' | FileCheck %s --check-prefix CHECK4
+# CHECK4: Summary: {{.+}}`{{.+}}31mfoo{{.+}}0m at main.c:1
+
+# RUN: %lldb %t -o 'settings set use-color true' -o 'image lookup -r -s 
IMPPATTERN123456' | FileCheck %s --check-prefix CHECK5
+# CHECK5-NOT: {{[0-9]+}} symbols match the regular expression

DavidSpickett wrote:

Another one I'm thinking about is what about multiple matches on the same 
symbol line? Or rather, within the symbol name.

So `foo_bar` would be matched twice by `(foo|bar)`. Not sure if there's a 
symbol in the program that'll fit that already. If not you could easily add one 
to support this test case.

You could even use `main` again. `(ma|n\.o$)`. It might pick up other symbols 
so just look for the main line and ignore anything else that comes up.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-14 Thread David Spickett via lldb-commits


@@ -252,11 +253,16 @@ void Symbol::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
   s->Printf(", value = 0x%16.16" PRIx64,
 m_addr_range.GetBaseAddress().GetOffset());
   }
-  ConstString demangled = GetMangled().GetDemangledName();
-  if (demangled)
-s->Printf(", name=\"%s\"", demangled.AsCString());
-  if (m_mangled.GetMangledName())
-s->Printf(", mangled=\"%s\"", m_mangled.GetMangledName().AsCString());
+  if (ConstString mangled_name = m_mangled.GetMangledName()) {
+s->Printf(", mangled=\"");
+Address::DumpName(s, mangled_name.GetStringRef(), pattern);
+s->Printf("\"");
+  }
+  if (ConstString demangled = m_mangled.GetDemangledName()) {
+s->Printf(", name=\"");
+Address::DumpName(s, demangled.GetStringRef(), pattern);
+s->Printf("\"");

DavidSpickett wrote:

This is almost right, but we want demangled first, then mangled, to exactly 
match the previous code.

The reasoning here is that the demangled name is going to be more useful, if we 
have it, than the mangled name. Demangled might be `foo(std::vector<` 
whereas the mangled is like `12fa_foo3421(asfd<` (exaggerating but you get the 
idea).

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


[Lldb-commits] [lldb] [lldb] Fix MaxSummaryLength target property type (PR #72233)

2023-11-14 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (dancing-leaves)


Changes

Hi, there seems to be a regression since 
https://github.com/llvm/llvm-project/commit/6f8b33f6dfd0a0f8d2522b6c832bd6298ae2f3f3.
 `Max String Summary Length` target property is not read properly and the 
default value (1024) is being used instead.

16.0.6:
```
(lldb) settings set target.max-string-summary-length 16
(lldb) var
(std::string) longStdString = 
"0123456789101112131415161718192021222324252627282930313233343536"
(const char *) longCharPointer = 0x5556f310 
"0123456789101112131415161718192021222324252627282930313233343536"
```

17.0.4:
```
(lldb) settings set target.max-string-summary-length 16
(lldb) var
(std::string) longStdString = 
"0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133234335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377"...
(const char *) longCharPointer = 0x5556f310 "*same as line above*"...
```

Comparison fails here:
https://github.com/llvm/llvm-project/blob/9cb1673fa5d267148ac81ee31b37f1d2f7c0f2b8/lldb/source/Interpreter/OptionValue.cpp#L256

Due to the type difference:
https://github.com/llvm/llvm-project/blob/9cb1673fa5d267148ac81ee31b37f1d2f7c0f2b8/lldb/source/Target/Target.cpp#L4611
https://github.com/llvm/llvm-project/blob/9cb1673fa5d267148ac81ee31b37f1d2f7c0f2b8/lldb/source/Target/TargetProperties.td#L98

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


1 Files Affected:

- (modified) lldb/source/Target/TargetProperties.td (+1-1) 


``diff
diff --git a/lldb/source/Target/TargetProperties.td 
b/lldb/source/Target/TargetProperties.td
index 154a6e5919ab0cd..d2fccdb7b9b39c9 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -95,7 +95,7 @@ let Definition = "target" in {
   def MaxChildrenDepth: Property<"max-children-depth", "UInt64">,
 DefaultUnsignedValue<0x>,
 Desc<"Maximum depth to expand children.">;
-  def MaxSummaryLength: Property<"max-string-summary-length", "SInt64">,
+  def MaxSummaryLength: Property<"max-string-summary-length", "UInt64">,
 DefaultUnsignedValue<1024>,
 Desc<"Maximum number of characters to show when using %s in summary 
strings.">;
   def MaxMemReadSize: Property<"max-memory-read-size", "SInt64">,

``




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


  1   2   >