[Lldb-commits] [PATCH] D149719: [LLDB] Add a hook to notify REPLs that an expression was evaluated

2023-05-02 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
Herald added a project: All.
wallace requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

REPL implementations don't have an easy way to know that an expression has been 
evaluated, so I'm adding a simple function for that. In the future we can add 
another hook for meta commands.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149719

Files:
  lldb/include/lldb/Expression/REPL.h
  lldb/source/Expression/REPL.cpp


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -342,7 +342,8 @@
expr_prefix, result_valobj_sp, error,
nullptr); // fixed expression
 
-  // CommandInterpreter  = debugger.GetCommandInterpreter();
+  OnExpressionEvaluated(exe_ctx, code, expr_options, execution_results,
+result_valobj_sp, error);
 
   if (process_sp && process_sp->IsAlive()) {
 bool add_to_code = true;
Index: lldb/include/lldb/Expression/REPL.h
===
--- lldb/include/lldb/Expression/REPL.h
+++ lldb/include/lldb/Expression/REPL.h
@@ -107,6 +107,18 @@
  CompletionRequest ) override;
 
 protected:
+  /// Method that can be optionally overriden by subclasses to get notified
+  /// whenever an expression has been evaluated. The params of this method
+  /// include the inputs and outputs of the expression evaluation.
+  ///
+  /// Note: meta commands that start with : are not included by this method.
+  virtual void
+  OnExpressionEvaluated(const ExecutionContext _ctx, llvm::StringRef code,
+const EvaluateExpressionOptions _options,
+lldb::ExpressionResults execution_results,
+const lldb::ValueObjectSP _valobj_sp,
+const Status ) {}
+
   static int CalculateActualIndentation(const StringList );
 
   // Subclasses should override these functions to implement a functional REPL.


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -342,7 +342,8 @@
expr_prefix, result_valobj_sp, error,
nullptr); // fixed expression
 
-  // CommandInterpreter  = debugger.GetCommandInterpreter();
+  OnExpressionEvaluated(exe_ctx, code, expr_options, execution_results,
+result_valobj_sp, error);
 
   if (process_sp && process_sp->IsAlive()) {
 bool add_to_code = true;
Index: lldb/include/lldb/Expression/REPL.h
===
--- lldb/include/lldb/Expression/REPL.h
+++ lldb/include/lldb/Expression/REPL.h
@@ -107,6 +107,18 @@
  CompletionRequest ) override;
 
 protected:
+  /// Method that can be optionally overriden by subclasses to get notified
+  /// whenever an expression has been evaluated. The params of this method
+  /// include the inputs and outputs of the expression evaluation.
+  ///
+  /// Note: meta commands that start with : are not included by this method.
+  virtual void
+  OnExpressionEvaluated(const ExecutionContext _ctx, llvm::StringRef code,
+const EvaluateExpressionOptions _options,
+lldb::ExpressionResults execution_results,
+const lldb::ValueObjectSP _valobj_sp,
+const Status ) {}
+
   static int CalculateActualIndentation(const StringList );
 
   // Subclasses should override these functions to implement a functional REPL.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D149717: [lldb] Make some functions useful to REPLs public

2023-05-02 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
Herald added a project: All.
wallace requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

`StartEventHandlerThread` and `StopEventHandlerThread` are available to the 
SwiftREPL even though they are protected because SwiftREPL is a friend class of 
Debugger. I'm developing my own REPL and having access to these functions, 
including `FlushProcessOutput`, is desirable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149717

Files:
  lldb/include/lldb/Core/Debugger.h


Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -500,6 +500,19 @@
   SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback,
  void *baton);
 
+  /// Manually start the global event handler thread. It should be used by
+  /// programs that use LLDB as a library.
+  bool StartEventHandlerThread();
+
+  /// Stop the global event handler thread. It should only be used by programs
+  /// that manually invoked \a Debugger::StartEventHandlerThread().
+  void StopEventHandlerThread();
+
+  /// Force flushing the process's pending stdout and stderr to the debuggers'
+  /// asynchronous stdout and stderr streams.
+  void FlushProcessOutput(Process , bool flush_stdout,
+  bool flush_stderr);
+
 protected:
   friend class CommandInterpreter;
   friend class REPL;
@@ -548,10 +561,6 @@
 
   void PrintProgress(const ProgressEventData );
 
-  bool StartEventHandlerThread();
-
-  void StopEventHandlerThread();
-
   void PushIOHandler(const lldb::IOHandlerSP _sp,
  bool cancel_top_handler = true);
 
@@ -587,8 +596,6 @@
 
   // Ensures two threads don't attempt to flush process output in parallel.
   std::mutex m_output_flush_mutex;
-  void FlushProcessOutput(Process , bool flush_stdout,
-  bool flush_stderr);
 
   SourceManager::SourceFileCache () {
 return m_source_file_cache;


Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -500,6 +500,19 @@
   SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback,
  void *baton);
 
+  /// Manually start the global event handler thread. It should be used by
+  /// programs that use LLDB as a library.
+  bool StartEventHandlerThread();
+
+  /// Stop the global event handler thread. It should only be used by programs
+  /// that manually invoked \a Debugger::StartEventHandlerThread().
+  void StopEventHandlerThread();
+
+  /// Force flushing the process's pending stdout and stderr to the debuggers'
+  /// asynchronous stdout and stderr streams.
+  void FlushProcessOutput(Process , bool flush_stdout,
+  bool flush_stderr);
+
 protected:
   friend class CommandInterpreter;
   friend class REPL;
@@ -548,10 +561,6 @@
 
   void PrintProgress(const ProgressEventData );
 
-  bool StartEventHandlerThread();
-
-  void StopEventHandlerThread();
-
   void PushIOHandler(const lldb::IOHandlerSP _sp,
  bool cancel_top_handler = true);
 
@@ -587,8 +596,6 @@
 
   // Ensures two threads don't attempt to flush process output in parallel.
   std::mutex m_output_flush_mutex;
-  void FlushProcessOutput(Process , bool flush_stdout,
-  bool flush_stderr);
 
   SourceManager::SourceFileCache () {
 return m_source_file_cache;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D149663: [lldb] Remove FileSpec::GetLastPathComponent

2023-05-02 Thread Alex Langford via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc4f3f5225df7: [lldb] Remove FileSpec::GetLastPathComponent 
(authored by bulbazord).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149663

Files:
  lldb/include/lldb/Utility/FileSpec.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
  lldb/source/Target/Platform.cpp
  lldb/source/Utility/FileSpec.cpp
  lldb/source/Utility/XcodeSDK.cpp

Index: lldb/source/Utility/XcodeSDK.cpp
===
--- lldb/source/Utility/XcodeSDK.cpp
+++ lldb/source/Utility/XcodeSDK.cpp
@@ -242,7 +242,7 @@
 
 bool XcodeSDK::SDKSupportsModules(XcodeSDK::Type desired_type,
   const FileSpec _path) {
-  ConstString last_path_component = sdk_path.GetLastPathComponent();
+  ConstString last_path_component = sdk_path.GetFilename();
 
   if (!last_path_component)
 return false;
Index: lldb/source/Utility/FileSpec.cpp
===
--- lldb/source/Utility/FileSpec.cpp
+++ lldb/source/Utility/FileSpec.cpp
@@ -429,12 +429,6 @@
   return *this;
 }
 
-ConstString FileSpec::GetLastPathComponent() const {
-  llvm::SmallString<64> current_path;
-  GetPath(current_path, false);
-  return ConstString(llvm::sys::path::filename(current_path, m_style));
-}
-
 void FileSpec::PrependPathComponent(llvm::StringRef component) {
   llvm::SmallString<64> new_path(component);
   llvm::SmallString<64> current_path;
Index: lldb/source/Target/Platform.cpp
===
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -435,7 +435,7 @@
 // make the new directory and get in there
 FileSpec dst_dir = rc_baton->dst;
 if (!dst_dir.GetFilename())
-  dst_dir.SetFilename(src.GetLastPathComponent());
+  dst_dir.SetFilename(src.GetFilename());
 Status error = rc_baton->platform_ptr->MakeDirectory(
 dst_dir, lldb::eFilePermissionsDirectoryDefault);
 if (error.Fail()) {
Index: lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
===
--- lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
+++ lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
@@ -1268,7 +1268,7 @@
 
 auto _spec = module_sp->GetFileSpec();
 found_logging_support_module =
-(file_spec.GetLastPathComponent() == logging_module_name);
+(file_spec.GetFilename() == logging_module_name);
 if (found_logging_support_module)
   break;
   }
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1238,10 +1238,9 @@
 
 FileSpec platform_pull_upart(platform_file);
 std::vector path_parts;
-path_parts.push_back(
-platform_pull_upart.GetLastPathComponent().AsCString());
+path_parts.push_back(platform_pull_upart.GetFilename().AsCString());
 while (platform_pull_upart.RemoveLastPathComponent()) {
-  ConstString part = platform_pull_upart.GetLastPathComponent();
+  ConstString part = platform_pull_upart.GetFilename();
   path_parts.push_back(part.AsCString());
 }
 const size_t path_parts_size = path_parts.size();
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -166,7 +166,7 @@
 auto raw_data = coff_obj.getData();
 LLDB_SCOPED_TIMERF(
 "Calculating module crc32 %s with size %" PRIu64 " KiB",
-FileSpec(coff_obj.getFileName()).GetLastPathComponent().AsCString(),
+FileSpec(coff_obj.getFileName()).GetFilename().AsCString(),
 static_cast(raw_data.size()) / 1024);
 gnu_debuglink_crc = llvm::crc32(0, llvm::arrayRefFromStringRef(raw_data));
   }
@@ -295,7 +295,7 @@
   const auto *map = GetGlobalPluginProperties().ModuleABIMap();
   if (map->GetNumValues() > 0) {
 // Step 1: Try with the exact file name.
-auto name = file.GetLastPathComponent();
+auto name = file.GetFilename();
 module_env_option = map->GetValueForKey(name);
 if (!module_env_option) {
   // Step 2: Try with the file name in lowercase.
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- 

[Lldb-commits] [lldb] c4f3f52 - [lldb] Remove FileSpec::GetLastPathComponent

2023-05-02 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2023-05-02T17:21:33-07:00
New Revision: c4f3f5225df73cf83042b5e3615549aae0be2422

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

LOG: [lldb] Remove FileSpec::GetLastPathComponent

As far as I can tell, this just computes the filename of the FileSpec,
which is already conveniently stored in m_filename. We can use
FileSpec::GetFilename() instead.

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

Added: 


Modified: 
lldb/include/lldb/Utility/FileSpec.h
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
lldb/source/Target/Platform.cpp
lldb/source/Utility/FileSpec.cpp
lldb/source/Utility/XcodeSDK.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/FileSpec.h 
b/lldb/include/lldb/Utility/FileSpec.h
index 3238bacacb929..919b5e8564583 100644
--- a/lldb/include/lldb/Utility/FileSpec.h
+++ b/lldb/include/lldb/Utility/FileSpec.h
@@ -408,8 +408,6 @@ class FileSpec {
   /// A boolean value indicating whether the path was updated.
   bool RemoveLastPathComponent();
 
-  ConstString GetLastPathComponent() const;
-
 protected:
   // Convenience method for setting the file without changing the style.
   void SetFile(llvm::StringRef path);

diff  --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 11fee6e4e7b96..937d1482e4ab4 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -623,7 +623,7 @@ size_t ObjectFileELF::GetModuleSpecifications(
 if (!gnu_debuglink_crc) {
   LLDB_SCOPED_TIMERF(
   "Calculating module crc32 %s with size %" PRIu64 " KiB",
-  file.GetLastPathComponent().AsCString(),
+  file.GetFilename().AsCString(),
   (length - file_offset) / 1024);
 
   // For core files - which usually don't happen to have a

diff  --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp 
b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 4f1ce5c640513..97f40aef769b4 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -166,7 +166,7 @@ static UUID GetCoffUUID(llvm::object::COFFObjectFile 
_obj) {
 auto raw_data = coff_obj.getData();
 LLDB_SCOPED_TIMERF(
 "Calculating module crc32 %s with size %" PRIu64 " KiB",
-FileSpec(coff_obj.getFileName()).GetLastPathComponent().AsCString(),
+FileSpec(coff_obj.getFileName()).GetFilename().AsCString(),
 static_cast(raw_data.size()) / 1024);
 gnu_debuglink_crc = llvm::crc32(0, llvm::arrayRefFromStringRef(raw_data));
   }
@@ -295,7 +295,7 @@ size_t ObjectFilePECOFF::GetModuleSpecifications(
   const auto *map = GetGlobalPluginProperties().ModuleABIMap();
   if (map->GetNumValues() > 0) {
 // Step 1: Try with the exact file name.
-auto name = file.GetLastPathComponent();
+auto name = file.GetFilename();
 module_env_option = map->GetValueForKey(name);
 if (!module_env_option) {
   // Step 2: Try with the file name in lowercase.

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 87586e13fe7a7..76c6b535679a6 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1238,10 +1238,9 @@ lldb_private::Status 
PlatformDarwin::FindBundleBinaryInExecSearchPaths(
 
 FileSpec platform_pull_upart(platform_file);
 std::vector path_parts;
-path_parts.push_back(
-platform_pull_upart.GetLastPathComponent().AsCString());
+path_parts.push_back(platform_pull_upart.GetFilename().AsCString());
 while (platform_pull_upart.RemoveLastPathComponent()) {
-  ConstString part = platform_pull_upart.GetLastPathComponent();
+  ConstString part = platform_pull_upart.GetFilename();
   path_parts.push_back(part.AsCString());
 }
 const size_t path_parts_size = path_parts.size();

diff  --git 
a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp 
b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
index 375b171e6d6ce..53c89bd5f618b 100644
--- a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
+++ b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
@@ -1268,7 +1268,7 @@ void StructuredDataDarwinLog::ModulesDidLoad(Process 
,
 
   

[Lldb-commits] [PATCH] D149671: [lldb] Minor cleanups at callsites of FileSpec::GetFileNameExtension

2023-05-02 Thread Alex Langford via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG50e79d725c10: [lldb] Minor cleanups at callsites of 
FileSpec::GetFileNameExtension (authored by bulbazord).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149671

Files:
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
@@ -131,14 +131,13 @@
 }
 
 llvm::Error Lua::LoadModule(llvm::StringRef filename) {
-  FileSpec file(filename);
+  const FileSpec file(filename);
   if (!FileSystem::Instance().Exists(file)) {
 return llvm::make_error("invalid path",
llvm::inconvertibleErrorCode());
   }
 
-  llvm::StringRef module_extension = file.GetFileNameExtension();
-  if (module_extension != ".lua") {
+  if (file.GetFileNameExtension() != ".lua") {
 return llvm::make_error("invalid extension",
llvm::inconvertibleErrorCode());
   }
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
@@ -137,7 +137,8 @@
   // with the binary inside it ('.../foo.dSYM/Contents/Resources/DWARF/foo').
   // A dSYM bundle may have multiple DWARF binaries in them, so a vector
   // of matches is returned.
-  static std::vector GetDWARFBinaryInDSYMBundle(FileSpec 
dsym_bundle);
+  static std::vector
+  GetDWARFBinaryInDSYMBundle(const FileSpec _bundle);
 
   Status GetSharedModuleKext(const ModuleSpec _spec, Process *process,
  lldb::ModuleSP _sp,
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -421,7 +421,7 @@
   static constexpr llvm::StringLiteral g_kdk_suffix = ".kdk";
 
   PlatformDarwinKernel *thisp = (PlatformDarwinKernel *)baton;
-  FileSpec file_spec(path);
+  const FileSpec file_spec(path);
   if (ft == llvm::sys::fs::file_type::directory_file &&
   (file_spec.GetFileNameExtension() == g_sdk_suffix ||
file_spec.GetFileNameExtension() == g_kdk_suffix)) {
@@ -482,7 +482,7 @@
   static constexpr llvm::StringLiteral g_kext_suffix = ".kext";
   static constexpr llvm::StringLiteral g_dsym_suffix = ".dSYM";
 
-  FileSpec file_spec(path);
+  const FileSpec file_spec(path);
   llvm::StringRef file_spec_extension = file_spec.GetFileNameExtension();
 
   Log *log = GetLog(LLDBLog::Platform);
@@ -691,7 +691,7 @@
 // it should iterate over every binary in the DWARF subdir
 // and return them all.
 std::vector
-PlatformDarwinKernel::GetDWARFBinaryInDSYMBundle(FileSpec dsym_bundle) {
+PlatformDarwinKernel::GetDWARFBinaryInDSYMBundle(const FileSpec _bundle) {
   std::vector results;
   static constexpr llvm::StringLiteral g_dsym_suffix = ".dSYM";
   if (dsym_bundle.GetFileNameExtension() != g_dsym_suffix) {
Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -2161,7 +2161,7 @@
 }
 
 const char *pcm_path = command.GetArgumentAtIndex(0);
-FileSpec pcm_file{pcm_path};
+const FileSpec pcm_file{pcm_path};
 
 if (pcm_file.GetFileNameExtension() != ".pcm") {
   result.AppendError("file must have a .pcm extension");


Index: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
@@ -131,14 +131,13 @@
 }
 
 llvm::Error Lua::LoadModule(llvm::StringRef filename) {
-  FileSpec file(filename);
+  const FileSpec file(filename);
   if (!FileSystem::Instance().Exists(file)) {
 return llvm::make_error("invalid path",
llvm::inconvertibleErrorCode());
   }
 
-  llvm::StringRef module_extension = file.GetFileNameExtension();
-  if (module_extension != ".lua") {
+  if (file.GetFileNameExtension() != ".lua") {
 return llvm::make_error("invalid extension",
llvm::inconvertibleErrorCode());
   }
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h

[Lldb-commits] [lldb] 50e79d7 - [lldb] Minor cleanups at callsites of FileSpec::GetFileNameExtension

2023-05-02 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2023-05-02T17:20:29-07:00
New Revision: 50e79d725c105344e292d1fe8044a69467c20346

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

LOG: [lldb] Minor cleanups at callsites of FileSpec::GetFileNameExtension

FileSpec::GetFileNameExtension returns a StringRef. In some cases we
are calling it and then storing the result in a local. To prevent
cases where we store the StringRef, mutate the Filespec, and then try to
use the stored StringRef afterwards, I've audited the callsites and made
adjustments to mitigate: Either marking the FileSpec it comes from as
const (to avoid mutations) or by not storing the StringRef in a local if
it makes sense not to.

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

Added: 


Modified: 
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 6d63b306d42a1..0a1cacfaf7509 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -2161,7 +2161,7 @@ class CommandObjectTargetModulesDumpClangPCMInfo : public 
CommandObjectParsed {
 }
 
 const char *pcm_path = command.GetArgumentAtIndex(0);
-FileSpec pcm_file{pcm_path};
+const FileSpec pcm_file{pcm_path};
 
 if (pcm_file.GetFileNameExtension() != ".pcm") {
   result.AppendError("file must have a .pcm extension");

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
index 1a9229d76f439..a50d35b7d40ab 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -421,7 +421,7 @@ PlatformDarwinKernel::FindKDKandSDKDirectoriesInDirectory(
   static constexpr llvm::StringLiteral g_kdk_suffix = ".kdk";
 
   PlatformDarwinKernel *thisp = (PlatformDarwinKernel *)baton;
-  FileSpec file_spec(path);
+  const FileSpec file_spec(path);
   if (ft == llvm::sys::fs::file_type::directory_file &&
   (file_spec.GetFileNameExtension() == g_sdk_suffix ||
file_spec.GetFileNameExtension() == g_kdk_suffix)) {
@@ -482,7 +482,7 @@ PlatformDarwinKernel::GetKernelsAndKextsInDirectoryHelper(
   static constexpr llvm::StringLiteral g_kext_suffix = ".kext";
   static constexpr llvm::StringLiteral g_dsym_suffix = ".dSYM";
 
-  FileSpec file_spec(path);
+  const FileSpec file_spec(path);
   llvm::StringRef file_spec_extension = file_spec.GetFileNameExtension();
 
   Log *log = GetLog(LLDBLog::Platform);
@@ -691,7 +691,7 @@ bool PlatformDarwinKernel::KerneldSYMHasNoSiblingBinary(
 // it should iterate over every binary in the DWARF subdir
 // and return them all.
 std::vector
-PlatformDarwinKernel::GetDWARFBinaryInDSYMBundle(FileSpec dsym_bundle) {
+PlatformDarwinKernel::GetDWARFBinaryInDSYMBundle(const FileSpec _bundle) {
   std::vector results;
   static constexpr llvm::StringLiteral g_dsym_suffix = ".dSYM";
   if (dsym_bundle.GetFileNameExtension() != g_dsym_suffix) {

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
index 1b0708cd9f8dc..e28f77cd44d55 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
@@ -137,7 +137,8 @@ class PlatformDarwinKernel : public PlatformDarwin {
   // with the binary inside it ('.../foo.dSYM/Contents/Resources/DWARF/foo').
   // A dSYM bundle may have multiple DWARF binaries in them, so a vector
   // of matches is returned.
-  static std::vector GetDWARFBinaryInDSYMBundle(FileSpec 
dsym_bundle);
+  static std::vector
+  GetDWARFBinaryInDSYMBundle(const FileSpec _bundle);
 
   Status GetSharedModuleKext(const ModuleSpec _spec, Process *process,
  lldb::ModuleSP _sp,

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
index 852bb3bb14c6c..9c2227cc3884e 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
@@ -131,14 +131,13 @@ llvm::Error Lua::CheckSyntax(llvm::StringRef buffer) {
 }
 
 llvm::Error Lua::LoadModule(llvm::StringRef filename) {
-  FileSpec file(filename);
+  const FileSpec file(filename);
   if (!FileSystem::Instance().Exists(file)) {
 return llvm::make_error("invalid path",
llvm::inconvertibleErrorCode());
   }
 
-  llvm::StringRef 

[Lldb-commits] [PATCH] D149692: Allow scripted thread plans to modify the stop reason shown when the plan completes

2023-05-02 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib accepted this revision.
mib added a comment.
This revision is now accepted and ready to land.

Alright


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149692

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


[Lldb-commits] [lldb] 6ea1a0d - [LLDB] Add/Remove xfail for some API tests on Windows

2023-05-02 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2023-05-03T04:45:55+05:00
New Revision: 6ea1a0d4fc3823de143a288df2059b48dc01cf72

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

LOG: [LLDB] Add/Remove xfail for some API tests on Windows

This patch add or removes XFAIL decorator from various tests which were marked
xfail for windows.

since 44363f2 various tests have started passing but introduced a couple of new 
failures.
Weight is in favor of new XPasses and I have removed XFail decorator from them. 
Also
some new tests have started failing for which we need to file separate bugs. I 
have
marked them xfail for now and will add the bug id after investigating the issue.

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

Added: 


Modified: 

lldb/test/API/commands/expression/deleting-implicit-copy-constructor/TestDeletingImplicitCopyConstructor.py
lldb/test/API/commands/expression/save_jit_objects/TestSaveJITObjects.py

lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py

lldb/test/API/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py
lldb/test/API/functionalities/inline-stepping/TestInlineStepping.py
lldb/test/API/functionalities/step-avoids-no-debug/TestStepNoDebug.py
lldb/test/API/lang/c/step-target/TestStepTarget.py
lldb/test/API/lang/cpp/constructors/TestCppConstructors.py
lldb/test/API/lang/cpp/global_variables/TestCPPGlobalVariables.py
lldb/test/API/lang/cpp/namespace/TestNamespace.py
lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py
lldb/test/API/lang/cpp/this_class_type_mixing/TestThisClassTypeMixing.py
lldb/test/API/python_api/function_symbol/TestDisasmAPI.py
lldb/test/API/python_api/function_symbol/TestSymbolAPI.py
lldb/test/API/python_api/symbol-context/TestSymbolContext.py
lldb/test/API/python_api/target/TestTargetAPI.py
lldb/test/API/python_api/value/TestValueAPI.py

Removed: 




diff  --git 
a/lldb/test/API/commands/expression/deleting-implicit-copy-constructor/TestDeletingImplicitCopyConstructor.py
 
b/lldb/test/API/commands/expression/deleting-implicit-copy-constructor/TestDeletingImplicitCopyConstructor.py
index e14f160f1e576..2ee90181d9327 100644
--- 
a/lldb/test/API/commands/expression/deleting-implicit-copy-constructor/TestDeletingImplicitCopyConstructor.py
+++ 
b/lldb/test/API/commands/expression/deleting-implicit-copy-constructor/TestDeletingImplicitCopyConstructor.py
@@ -2,4 +2,4 @@
 from lldbsuite.test import decorators
 
 lldbinline.MakeInlineTest(__file__, globals(),
-  [decorators.expectedFailureAll(bugnumber="llvm.org/pr50814", 
compiler="gcc")])
+  [decorators.expectedFailureAll(bugnumber="llvm.org/pr50814", 
compiler="gcc"), decorators.expectedFailureAll(oslist=["windows"])])

diff  --git 
a/lldb/test/API/commands/expression/save_jit_objects/TestSaveJITObjects.py 
b/lldb/test/API/commands/expression/save_jit_objects/TestSaveJITObjects.py
index 157bed4880a3d..e3e20ad94707d 100644
--- a/lldb/test/API/commands/expression/save_jit_objects/TestSaveJITObjects.py
+++ b/lldb/test/API/commands/expression/save_jit_objects/TestSaveJITObjects.py
@@ -22,7 +22,6 @@ def cleanJITFiles(self):
 os.remove(j)
 return
 
-@expectedFailureAll(oslist=["windows"])
 def test_save_jit_objects(self):
 self.build()
 os.chdir(self.getBuildDir())

diff  --git 
a/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
 
b/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
index 8a143bdf3817a..edac8b1981fdf 100644
--- 
a/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
+++ 
b/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
@@ -13,20 +13,17 @@ class TestScriptedResolver(TestBase):
 
 NO_DEBUG_INFO_TESTCASE = True
 
-@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528")
 def test_scripted_resolver(self):
 """Use a scripted resolver to set a by symbol name breakpoint"""
 self.build()
 self.do_test()
 
-@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528")
 def test_search_depths(self):
 """ Make sure we are called at the right depths depending on what we 
return
 from __get_depth__"""
 self.build()
 self.do_test_depths()
 
-@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528")
 def test_command_line(self):
 """ Test setting a resolver breakpoint from the command line """
 self.build()

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py
 

[Lldb-commits] [PATCH] D149663: [lldb] Remove FileSpec::GetLastPathComponent

2023-05-02 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

Given the current behavior, LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149663

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


[Lldb-commits] [PATCH] D149702: [DebugInfo] Add language code for the new Mojo language

2023-05-02 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



Comment at: lldb/include/lldb/lldb-enumerations.h:493
   eLanguageTypeAda2012 = 0x002f,
+  eLanguageTypeMojo = 0x0030,
 

aprantl wrote:
> bulbazord wrote:
> > These values correspond to DWARF5's official language codes and `0x0030` is 
> > technically already taken. LLDB just hasn't been updated yet. I don't think 
> > this should necessarily block this patch but this value will need to be 
> > changed at some point.
> > 
> > See: https://dwarfstd.org/languages.html
> Registering a new language with the DWARF committee is a pretty quick process 
> nowadays. Please do that before taking a constant in the reserved range.
Thanks for the information. I'll do so then :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149702

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


[Lldb-commits] [PATCH] D149702: [DebugInfo] Add language code for the new Mojo language

2023-05-02 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/include/lldb/lldb-enumerations.h:493
   eLanguageTypeAda2012 = 0x002f,
+  eLanguageTypeMojo = 0x0030,
 

bulbazord wrote:
> These values correspond to DWARF5's official language codes and `0x0030` is 
> technically already taken. LLDB just hasn't been updated yet. I don't think 
> this should necessarily block this patch but this value will need to be 
> changed at some point.
> 
> See: https://dwarfstd.org/languages.html
Registering a new language with the DWARF committee is a pretty quick process 
nowadays. Please do that before taking a constant in the reserved range.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149702

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


[Lldb-commits] [PATCH] D149702: [DebugInfo] Add language code for the new Mojo language

2023-05-02 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added inline comments.



Comment at: lldb/include/lldb/lldb-enumerations.h:493
   eLanguageTypeAda2012 = 0x002f,
+  eLanguageTypeMojo = 0x0030,
 

These values correspond to DWARF5's official language codes and `0x0030` is 
technically already taken. LLDB just hasn't been updated yet. I don't think 
this should necessarily block this patch but this value will need to be changed 
at some point.

See: https://dwarfstd.org/languages.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149702

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


[Lldb-commits] [PATCH] D149702: [DebugInfo] Add language code for the new Mojo language

2023-05-02 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
Herald added a reviewer: deadalnix.
Herald added a subscriber: hiraditya.
Herald added a project: All.
wallace requested review of this revision.
Herald added projects: LLDB, LLVM.
Herald added subscribers: llvm-commits, lldb-commits.

Modular just announced a new language called Mojo. This patch adds the 
corresponding language code that will ease development and sharing of its LLDB 
language plug-in.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149702

Files:
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Target/Language.cpp
  llvm/include/llvm-c/DebugInfo.h
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/BinaryFormat/Dwarf.h
  llvm/lib/IR/DIBuilder.cpp


Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -150,7 +150,7 @@
 DICompileUnit::DebugNameTableKind NameTableKind, bool RangesBaseAddress,
 StringRef SysRoot, StringRef SDK) {
 
-  assert(((Lang <= dwarf::DW_LANG_Ada2012 && Lang >= dwarf::DW_LANG_C89) ||
+  assert(((Lang <= dwarf::DW_LANG_Mojo && Lang >= dwarf::DW_LANG_C89) ||
   (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) 
&&
  "Invalid Language tag");
 
Index: llvm/include/llvm/BinaryFormat/Dwarf.h
===
--- llvm/include/llvm/BinaryFormat/Dwarf.h
+++ llvm/include/llvm/BinaryFormat/Dwarf.h
@@ -263,6 +263,7 @@
   case DW_LANG_Fortran18:
   case DW_LANG_Ada2005:
   case DW_LANG_Ada2012:
+  case DW_LANG_Mojo:
 result = false;
 break;
   }
@@ -329,6 +330,7 @@
   case DW_LANG_C17:
   case DW_LANG_Ada2005:
   case DW_LANG_Ada2012:
+  case DW_LANG_Mojo:
 result = false;
 break;
   }
@@ -393,6 +395,7 @@
   case DW_LANG_Fortran18:
   case DW_LANG_Ada2005:
   case DW_LANG_Ada2012:
+  case DW_LANG_Mojo:
 return false;
   }
   llvm_unreachable("Unknown language kind.");
Index: llvm/include/llvm/BinaryFormat/Dwarf.def
===
--- llvm/include/llvm/BinaryFormat/Dwarf.def
+++ llvm/include/llvm/BinaryFormat/Dwarf.def
@@ -925,6 +925,7 @@
 HANDLE_DW_LANG(0x002d, Fortran18, 0, 0, DWARF)
 HANDLE_DW_LANG(0x002e, Ada2005, 0, 0, DWARF)
 HANDLE_DW_LANG(0x002f, Ada2012, 0, 0, DWARF)
+HANDLE_DW_LANG(0x0030, Mojo, 0, 0, DWARF)
 // Vendor extensions:
 HANDLE_DW_LANG(0x8001, Mips_Assembler, std::nullopt, 0, MIPS)
 HANDLE_DW_LANG(0x8e57, GOOGLE_RenderScript, 0, 0, GOOGLE)
Index: llvm/include/llvm-c/DebugInfo.h
===
--- llvm/include/llvm-c/DebugInfo.h
+++ llvm/include/llvm-c/DebugInfo.h
@@ -125,6 +125,7 @@
   LLVMDWARFSourceLanguageFortran18,
   LLVMDWARFSourceLanguageAda2005,
   LLVMDWARFSourceLanguageAda2012,
+  LLVMDWARFSourceLanguageMojo,
   // Vendor extensions:
   LLVMDWARFSourceLanguageMips_Assembler,
   LLVMDWARFSourceLanguageGOOGLE_RenderScript,
Index: lldb/source/Target/Language.cpp
===
--- lldb/source/Target/Language.cpp
+++ lldb/source/Target/Language.cpp
@@ -209,6 +209,7 @@
 {"fortran18", eLanguageTypeFortran18},
 {"ada2005", eLanguageTypeAda2005},
 {"ada2012", eLanguageTypeAda2012},
+{"mojo", eLanguageTypeMojo},
 // Vendor Extensions
 {"assembler", eLanguageTypeMipsAssembler},
 // Now synonyms, in arbitrary order
@@ -463,7 +464,7 @@
   // The base implementation does a simple contains comparision:
   if (path.empty())
 return false;
-  return demangled.GetStringRef().contains(path);  
   
+  return demangled.GetStringRef().contains(path); 
 }
 
 DumpValueObjectOptions::DeclPrintingHelper Language::GetDeclPrintingHelper() {
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -490,6 +490,7 @@
   eLanguageTypeFortran18 = 0x002d,
   eLanguageTypeAda2005 = 0x002e,
   eLanguageTypeAda2012 = 0x002f,
+  eLanguageTypeMojo = 0x0030,
 
   // Vendor Extensions
   // Note: Language::GetNameForLanguageType


Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -150,7 +150,7 @@
 DICompileUnit::DebugNameTableKind NameTableKind, bool RangesBaseAddress,
 StringRef SysRoot, StringRef SDK) {
 
-  assert(((Lang <= dwarf::DW_LANG_Ada2012 && Lang >= dwarf::DW_LANG_C89) ||
+  assert(((Lang <= dwarf::DW_LANG_Mojo && Lang >= dwarf::DW_LANG_C89) ||
   (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
  "Invalid Language tag");
 
Index: llvm/include/llvm/BinaryFormat/Dwarf.h
===
--- 

[Lldb-commits] [PATCH] D149692: Allow scripted thread plans to modify the stop reason shown when the plan completes

2023-05-02 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

In D149692#4313715 , @mib wrote:

> This looks good to me, although I'm wondering whether instead of passing a 
> string, we should pass a dictionary. This way the user could either fill the 
> dictionary with a simple stop reason description or the MachException data 
> What do you think Jim ?

ThreadPlan stop reasons are only for display purposes, we don't ever reason 
based on them.  We do put data in StopInfo's but this isn't constructing a 
StopInfo, it's just adding the string to StopInfoPlanComplete.  So I can't see 
what use would be made of the more complex return.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149692

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


[Lldb-commits] [PATCH] D149692: Allow scripted thread plans to modify the stop reason shown when the plan completes

2023-05-02 Thread Jim Ingham via Phabricator via lldb-commits
jingham marked an inline comment as done.
jingham added inline comments.



Comment at: lldb/bindings/python/python-wrapper.swig:390
+  if (PyErr_Occurred()) {
+printf("Error occured for call to %s.\n",
+   method_name);

mib wrote:
> If we passed a `Status&` instead of a `bool&` we would be able to get that 
> error message in lldb.
GetDescription doesn't end up returning a Status, just a bool saying whether 
anything got added.  So even if I added a Status here, there would be no place 
for it to go.



Comment at: lldb/include/lldb/Interpreter/ScriptInterpreter.h:320
+   lldb_private::Stream *stream,
+   bool _error) {
+script_error = true;

mib wrote:
> For Scripted Process, I pass a `Status&` argument which can hold an error 
> message for better debugging. By doing so, you can also return 
> `Status.Success()`
There isn't any place to return an error along the GetStopDescription path 
above us.  That API just returns a bool saying whether you added information to 
the stream.  So returning just a bool at this layer mirrors its use better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149692

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


[Lldb-commits] [PATCH] D149692: Allow scripted thread plans to modify the stop reason shown when the plan completes

2023-05-02 Thread Jim Ingham via Phabricator via lldb-commits
jingham updated this revision to Diff 518878.
jingham added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149692

Files:
  lldb/bindings/python/python-wrapper.swig
  lldb/examples/python/scripted_step.py
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/include/lldb/Target/ThreadPlanPython.h
  lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
  lldb/source/Target/ThreadPlanPython.cpp
  lldb/test/API/functionalities/step_scripted/Steps.py
  lldb/test/API/functionalities/step_scripted/TestStepScripted.py
  lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Index: lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
===
--- lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -107,6 +107,14 @@
   return false;
 }
 
+bool 
+lldb_private::LLDBSWIGPythonCallThreadPlan(void *implementor,
+const char *method_name,
+Stream *event_sp,
+bool _error) {
+  return false;
+}
+
 python::PythonObject
 lldb_private::LLDBSwigPythonCreateScriptedBreakpointResolver(
 const char *python_class_name, const char *session_dictionary_name,
Index: lldb/test/API/functionalities/step_scripted/TestStepScripted.py
===
--- lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -41,7 +41,8 @@
 
 frame = thread.GetFrameAtIndex(0)
 self.assertEqual("main", frame.GetFunctionName())
-
+stop_desc = thread.GetStopDescription(1000)
+self.assertIn("Stepping out from", stop_desc, "Got right description")
 
 def test_misspelled_plan_name(self):
 """Test that we get a useful error if we misspell the plan class name"""
@@ -106,6 +107,10 @@
 # And foo should have changed:
 self.assertTrue(foo_val.GetValueDidChange(), "Foo changed")
 
+# And we should have a reasonable stop description:
+desc = thread.GetStopDescription(1000)
+self.assertIn("Stepped until foo changed", desc, "Got right stop description")
+
 def test_stop_others_from_command(self):
 """Test that the stop-others flag is set correctly by the command line.
Also test that the run-all-threads property overrides this."""
@@ -119,10 +124,12 @@
 cmd = "thread step-scripted -C Steps.StepReportsStopOthers -k token -v %s"%(token)
 if run_mode != None:
 cmd = cmd + " --run-mode %s"%(run_mode)
-print(cmd)
+if self.TraceOn():
+print(cmd)
 interp.HandleCommand(cmd, result)
 self.assertTrue(result.Succeeded(), "Step scripted failed: %s."%(result.GetError()))
-print(Steps.StepReportsStopOthers.stop_mode_dict)
+if self.TraceOn():
+print(Steps.StepReportsStopOthers.stop_mode_dict)
 value = Steps.StepReportsStopOthers.stop_mode_dict[token]
 self.assertEqual(value, stop_others_value, "Stop others has the correct value.")
 
Index: lldb/test/API/functionalities/step_scripted/Steps.py
===
--- lldb/test/API/functionalities/step_scripted/Steps.py
+++ lldb/test/API/functionalities/step_scripted/Steps.py
@@ -19,6 +19,11 @@
 def should_step(self):
 return False
 
+def stop_description(self, stream):
+if self.child_thread_plan.IsPlanComplete():
+return self.child_thread_plan.GetDescription(stream)
+return True
+
 def queue_child_thread_plan(self):
 return None
 
@@ -39,19 +44,18 @@
 # This plan does a step-over until a variable changes value.
 class StepUntil(StepWithChild):
 def __init__(self, thread_plan, args_data, dict):
+self.thread_plan = thread_plan
 self.frame = thread_plan.GetThread().frames[0]
 self.target = thread_plan.GetThread().GetProcess().GetTarget()
-func_entry = args_data.GetValueForKey("variable_name")
+var_entry = args_data.GetValueForKey("variable_name")
 
-if not func_entry.IsValid():
+if not var_entry.IsValid():
 print("Did not get a valid entry for variable_name")
-func_name = func_entry.GetStringValue(100)
+self.var_name = var_entry.GetStringValue(100)
 
-self.value = self.frame.FindVariable(func_name)
+self.value = self.frame.FindVariable(self.var_name)
 if self.value.GetError().Fail():
 

[Lldb-commits] [PATCH] D149096: [lldb] Speed up looking for dSYM next to executable

2023-05-02 Thread Alex Langford via Phabricator via lldb-commits
bulbazord abandoned this revision.
bulbazord added a comment.

I'm going to see how we could potentially improve FileSpec's performance rather 
than go with this approach.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149096

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


[Lldb-commits] [PATCH] D149697: [lldb] Remove distribution_id from ArchSpec

2023-05-02 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: jasonmolenda, labath, DavidSpickett.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The qHostInfo packet in the gdb-remote communication protocol specifies
that distribution_id can be set, so lldb handles that. But we store that
in the ArchSpec representing the "Host" platform (whatever platform the
debug server is running on). This field is otherwise unused in ArchSpec,
so it would be a lot easier if we stored that information at the
gdb-remote communication layer.

Sidenote: The distribution_id field is currently unused but I did not
want to remove it in case some folks found it useful (e.g. in downstream
forks).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149697

Files:
  lldb/include/lldb/Host/HostInfoBase.h
  lldb/include/lldb/Utility/ArchSpec.h
  lldb/source/Host/linux/HostInfoLinux.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Utility/ArchSpec.cpp

Index: lldb/source/Utility/ArchSpec.cpp
===
--- lldb/source/Utility/ArchSpec.cpp
+++ lldb/source/Utility/ArchSpec.cpp
@@ -543,7 +543,6 @@
   m_triple = llvm::Triple();
   m_core = kCore_invalid;
   m_byte_order = eByteOrderInvalid;
-  m_distribution_id.Clear();
   m_flags = 0;
 }
 
@@ -689,14 +688,6 @@
   return llvm::Triple::UnknownArch;
 }
 
-ConstString ArchSpec::GetDistributionId() const {
-  return m_distribution_id;
-}
-
-void ArchSpec::SetDistributionId(const char *distribution_id) {
-  m_distribution_id.SetCString(distribution_id);
-}
-
 uint32_t ArchSpec::GetAddressByteSize() const {
   const CoreDefinition *core_def = FindCoreDefinition(m_core);
   if (core_def) {
@@ -979,8 +970,6 @@
 }
 
 bool ArchSpec::IsMatch(const ArchSpec , MatchType match) const {
-  // explicitly ignoring m_distribution_id in this method.
-
   if (GetByteOrder() != rhs.GetByteOrder() ||
   !cores_match(GetCore(), rhs.GetCore(), true, match == ExactMatch))
 return false;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -187,8 +187,8 @@
   response.PutStringAsRawHex8(host_triple.getTriple());
   response.Printf(";ptrsize:%u;", host_arch.GetAddressByteSize());
 
-  const char *distribution_id = host_arch.GetDistributionId().AsCString();
-  if (distribution_id) {
+  llvm::StringRef distribution_id = HostInfo::GetDistributionId();
+  if (!distribution_id.empty()) {
 response.PutCString("distribution_id:");
 response.PutStringAsRawHex8(distribution_id);
 response.PutCString(";");
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
@@ -583,6 +583,7 @@
   uint32_t m_addressing_bits = 0;
 
   ArchSpec m_host_arch;
+  std::string m_host_distribution_id;
   ArchSpec m_process_arch;
   UUID m_process_standalone_uuid;
   lldb::addr_t m_process_standalone_value = LLDB_INVALID_ADDRESS;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -69,10 +69,10 @@
   m_supports_vFileSize(true), m_supports_vFileMode(true),
   m_supports_vFileExists(true), m_supports_vRun(true),
 
-  m_host_arch(), m_process_arch(), m_os_build(), m_os_kernel(),
-  m_hostname(), m_gdb_server_name(), m_default_packet_timeout(0),
-  m_qSupported_response(), m_supported_async_json_packets_sp(),
-  m_qXfer_memory_map() {}
+  m_host_arch(), m_host_distribution_id(), m_process_arch(), m_os_build(),
+  m_os_kernel(), m_hostname(), m_gdb_server_name(),
+  m_default_packet_timeout(0), m_qSupported_response(),
+  m_supported_async_json_packets_sp(), m_qXfer_memory_map() {}
 
 // Destructor
 GDBRemoteCommunicationClient::~GDBRemoteCommunicationClient() {
@@ -307,6 +307,7 @@
 m_qSymbol_requests_done = false;
 m_supports_qModuleInfo = true;
 m_host_arch.Clear();
+m_host_distribution_id.clear();
 m_os_version = llvm::VersionTuple();
 m_os_build.clear();
 m_os_kernel.clear();
@@ -1206,7 +1207,6 @@
 std::string environment;
 std::string 

[Lldb-commits] [lldb] 2b6c5bb - [lldb-vscode] Implement RestartRequest

2023-05-02 Thread Jorge Gorbe Moya via lldb-commits

Author: Jorge Gorbe Moya
Date: 2023-05-02T14:50:39-07:00
New Revision: 2b6c5bb995be1b675c1d92e2d46403c76764e5c7

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

LOG: [lldb-vscode] Implement RestartRequest

This is an optional request, but supporting it makes the experience
better when re-launching a big binary that takes significant time to
parse: instead of tearing down and re-create the whole session we just
need to kill the current process and launch a new one.

Some non-obvious comments that might help review this change:

* After killing the process, we get an "exited" event for it. Because
  the process no longer exists some interesting things can occur that
  manifest as flaky failures if not dealt with:

  - `EventIsProcessEvent` relies on `SBEvent::GetBroadcasterClass`,
which can crash if the broadcaster is no longer there: the event
only holds a weak_ptr to its broadcaster, and `GetBroadcasterClass`
uses it without checking.

Other `EventIs*` functions look at the flavor of the EventData, so I
have modified EventIsProcessEvent to do that.

  - We keep the PID of the old process so we can detect its "exited"
event and not terminate the whole session. But sometimes the
SBProcess we get from the event won't have a PID, for some reason.

* I have factored out the code to launch a process out to a new
  LaunchProcess function, so it can be used from both `request_launch`
  and `request_restart`.

* The restart_runInTerminal test has the same problem with debug builds
  as the original runInTerminal test: when attaching to the launcher
  instance of lldb-vscode it takes a long time to parse its debug info.
  I have used the same workaround to disable that particular test for
  debug builds.

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

Added: 
lldb/test/API/tools/lldb-vscode/restart/Makefile
lldb/test/API/tools/lldb-vscode/restart/TestVSCode_restart.py
lldb/test/API/tools/lldb-vscode/restart/TestVSCode_restart_runInTerminal.py
lldb/test/API/tools/lldb-vscode/restart/main.c

Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
lldb/source/API/SBProcess.cpp
lldb/tools/lldb-vscode/VSCode.cpp
lldb/tools/lldb-vscode/VSCode.h
lldb/tools/lldb-vscode/lldb-vscode.cpp

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
index c2de4ad5c7d9a..16d26a8fa2216 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -588,6 +588,15 @@ def request_continue(self, threadId=None):
 # Caller must still call wait_for_stopped.
 return response
 
+def request_restart(self):
+command_dict = {
+'command': 'restart',
+'type': 'request',
+}
+response = self.send_recv(command_dict)
+# Caller must still call wait_for_stopped.
+return response
+
 def request_disconnect(self, terminateDebuggee=None):
 args_dict = {}
 if terminateDebuggee is not None:

diff  --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp
index 2004b66eafe34..4af1a983fe20f 100644
--- a/lldb/source/API/SBProcess.cpp
+++ b/lldb/source/API/SBProcess.cpp
@@ -779,8 +779,8 @@ SBProcess::GetStructuredDataFromEvent(const lldb::SBEvent 
) {
 bool SBProcess::EventIsProcessEvent(const SBEvent ) {
   LLDB_INSTRUMENT_VA(event);
 
-  return (event.GetBroadcasterClass() == SBProcess::GetBroadcasterClass()) &&
- !EventIsStructuredDataEvent(event);
+  return Process::ProcessEventData::GetEventDataFromEvent(event.get()) !=
+ nullptr;
 }
 
 bool SBProcess::EventIsStructuredDataEvent(const lldb::SBEvent ) {

diff  --git a/lldb/test/API/tools/lldb-vscode/restart/Makefile 
b/lldb/test/API/tools/lldb-vscode/restart/Makefile
new file mode 100644
index 0..10495940055b6
--- /dev/null
+++ b/lldb/test/API/tools/lldb-vscode/restart/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules

diff  --git a/lldb/test/API/tools/lldb-vscode/restart/TestVSCode_restart.py 
b/lldb/test/API/tools/lldb-vscode/restart/TestVSCode_restart.py
new file mode 100644
index 0..6715b167bcdb0
--- /dev/null
+++ b/lldb/test/API/tools/lldb-vscode/restart/TestVSCode_restart.py
@@ -0,0 +1,82 @@
+"""
+Test lldb-vscode RestartRequest.
+"""
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import line_number
+import lldbvscode_testcase
+
+
+class TestVSCode_restart(lldbvscode_testcase.VSCodeTestCaseBase):
+
+@skipIfWindows
+@skipIfRemote
+def test_basic_functionality(self):
+'''
+

[Lldb-commits] [PATCH] D147831: [lldb-vscode] Implement RestartRequest

2023-05-02 Thread Jorge Gorbe Moya via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2b6c5bb995be: [lldb-vscode] Implement RestartRequest 
(authored by jgorbe).

Changed prior to commit:
  https://reviews.llvm.org/D147831?vs=512305=518866#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147831

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/source/API/SBProcess.cpp
  lldb/test/API/tools/lldb-vscode/restart/Makefile
  lldb/test/API/tools/lldb-vscode/restart/TestVSCode_restart.py
  lldb/test/API/tools/lldb-vscode/restart/TestVSCode_restart_runInTerminal.py
  lldb/test/API/tools/lldb-vscode/restart/main.c
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -458,7 +458,8 @@
 // manually send a stopped event in request_configurationDone(...)
 // so don't send any before then.
 if (g_vsc.configuration_done_sent) {
-  // Only report a stopped event if the process was not restarted.
+  // Only report a stopped event if the process was not
+  // automatically restarted.
   if (!lldb::SBProcess::GetRestartedFromEvent(event)) {
 SendStdOutStdErr(process);
 SendThreadStoppedEvent();
@@ -468,14 +469,22 @@
   case lldb::eStateRunning:
 g_vsc.WillContinue();
 break;
-  case lldb::eStateExited: {
-// Run any exit LLDB commands the user specified in the
-// launch.json
-g_vsc.RunExitCommands();
-SendProcessExitedEvent(process);
-SendTerminatedEvent();
-done = true;
-  } break;
+  case lldb::eStateExited:
+// When restarting, we can get an "exited" event for the process we
+// just killed with the old PID, or even with no PID. In that case
+// we don't have to terminate the session.
+if (process.GetProcessID() == LLDB_INVALID_PROCESS_ID ||
+process.GetProcessID() == g_vsc.restarting_process_id) {
+  g_vsc.restarting_process_id = LLDB_INVALID_PROCESS_ID;
+} else {
+  // Run any exit LLDB commands the user specified in the
+  // launch.json
+  g_vsc.RunExitCommands();
+  SendProcessExitedEvent(process);
+  SendTerminatedEvent();
+  done = true;
+}
+break;
   }
 } else if ((event_mask & lldb::SBProcess::eBroadcastBitSTDOUT) ||
(event_mask & lldb::SBProcess::eBroadcastBitSTDERR)) {
@@ -592,6 +601,7 @@
 // }
 void request_attach(const llvm::json::Object ) {
   g_vsc.is_attach = true;
+  g_vsc.last_launch_or_attach_request = request;
   llvm::json::Object response;
   lldb::SBError error;
   FillResponse(request, response);
@@ -1527,7 +1537,7 @@
   // The debug adapter supports the RestartRequest. In this case a client
   // should not implement 'restart' by terminating and relaunching the adapter
   // but by calling the RestartRequest.
-  body.try_emplace("supportsRestartRequest", false);
+  body.try_emplace("supportsRestartRequest", true);
   // The debug adapter supports 'exceptionOptions' on the
   // setExceptionBreakpoints request.
   body.try_emplace("supportsExceptionOptions", true);
@@ -1622,6 +1632,71 @@
  error.GetCString());
 }
 
+// Takes a LaunchRequest object and launches the process, also handling
+// runInTerminal if applicable. It doesn't do any of the additional
+// initialization and bookkeeping stuff that is needed for `request_launch`.
+// This way we can reuse the process launching logic for RestartRequest too.
+lldb::SBError LaunchProcess(const llvm::json::Object ) {
+  lldb::SBError error;
+  auto arguments = request.getObject("arguments");
+  auto launchCommands = GetStrings(arguments, "launchCommands");
+
+  // Instantiate a launch info instance for the target.
+  auto launch_info = g_vsc.target.GetLaunchInfo();
+
+  // Grab the current working directory if there is one and set it in the
+  // launch info.
+  const auto cwd = GetString(arguments, "cwd");
+  if (!cwd.empty())
+launch_info.SetWorkingDirectory(cwd.data());
+
+  // Extract any extra arguments and append them to our program arguments for
+  // when we launch
+  auto args = GetStrings(arguments, "args");
+  if (!args.empty())
+launch_info.SetArguments(MakeArgv(args).data(), true);
+
+  // Pass any environment variables along that the user specified.
+  auto envs = GetStrings(arguments, "env");
+  if (!envs.empty())
+

[Lldb-commits] [PATCH] D149692: Allow scripted thread plans to modify the stop reason shown when the plan completes

2023-05-02 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

This looks good to me, although I'm wondering whether instead of passing a 
string, we should pass a dictionary. This way the user could either fill the 
dictionary with a simple stop reason description or the MachException data What 
do you think Jim ?




Comment at: lldb/bindings/python/python-wrapper.swig:390
+  if (PyErr_Occurred()) {
+printf("Error occured for call to %s.\n",
+   method_name);

If we passed a `Status&` instead of a `bool&` we would be able to get that 
error message in lldb.



Comment at: lldb/examples/python/scripted_step.py:156
+def stop_description(self, stream):
+self.step_thread_plan.GetDescription(s, lldb.eDescriptionLevelBrief)
+

This is probably a typo



Comment at: lldb/include/lldb/Interpreter/ScriptInterpreter.h:320
+   lldb_private::Stream *stream,
+   bool _error) {
+script_error = true;

For Scripted Process, I pass a `Status&` argument which can hold an error 
message for better debugging. By doing so, you can also return 
`Status.Success()`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149692

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


[Lldb-commits] [PATCH] D149692: Allow scripted thread plans to modify the stop reason shown when the plan completes

2023-05-02 Thread Jim Ingham via Phabricator via lldb-commits
jingham created this revision.
jingham added reviewers: JDevlieghere, delcypher, mib.
Herald added a project: All.
jingham requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

We were just printing some fairly ugly boiler plate, for instance:

(lldb) thread step-scripted -C scripted_step.SimpleStep
Process 15467 stopped

- thread #1, queue = 'com.apple.main-thread', stop reason = Python thread plan 
implemented by class scripted_step.SimpleStep.

This change allows the scripted ThreadPlan to implement:

  def stop_description(self, stream):
  stream.Print("Simple step completed")

and then you will see:

(lldb) thread step-scripted -C scripted_step.SimpleStep
Process 15226 stopped

- thread #1, queue = 'com.apple.main-thread', stop reason = Simple step 
completed


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149692

Files:
  lldb/bindings/python/python-wrapper.swig
  lldb/examples/python/scripted_step.py
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/include/lldb/Target/ThreadPlanPython.h
  lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
  lldb/source/Target/ThreadPlanPython.cpp
  lldb/test/API/functionalities/step_scripted/Steps.py
  lldb/test/API/functionalities/step_scripted/TestStepScripted.py
  lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Index: lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
===
--- lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -107,6 +107,14 @@
   return false;
 }
 
+bool 
+lldb_private::LLDBSWIGPythonCallThreadPlan(void *implementor,
+const char *method_name,
+Stream *event_sp,
+bool _error) {
+  return false;
+}
+
 python::PythonObject
 lldb_private::LLDBSwigPythonCreateScriptedBreakpointResolver(
 const char *python_class_name, const char *session_dictionary_name,
Index: lldb/test/API/functionalities/step_scripted/TestStepScripted.py
===
--- lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -41,7 +41,8 @@
 
 frame = thread.GetFrameAtIndex(0)
 self.assertEqual("main", frame.GetFunctionName())
-
+stop_desc = thread.GetStopDescription(1000)
+self.assertIn("Stepping out from", stop_desc, "Got right description")
 
 def test_misspelled_plan_name(self):
 """Test that we get a useful error if we misspell the plan class name"""
@@ -106,6 +107,10 @@
 # And foo should have changed:
 self.assertTrue(foo_val.GetValueDidChange(), "Foo changed")
 
+# And we should have a reasonable stop description:
+desc = thread.GetStopDescription(1000)
+self.assertIn("Stepped until foo changed", desc, "Got right stop description")
+
 def test_stop_others_from_command(self):
 """Test that the stop-others flag is set correctly by the command line.
Also test that the run-all-threads property overrides this."""
@@ -119,10 +124,12 @@
 cmd = "thread step-scripted -C Steps.StepReportsStopOthers -k token -v %s"%(token)
 if run_mode != None:
 cmd = cmd + " --run-mode %s"%(run_mode)
-print(cmd)
+if self.TraceOn():
+print(cmd)
 interp.HandleCommand(cmd, result)
 self.assertTrue(result.Succeeded(), "Step scripted failed: %s."%(result.GetError()))
-print(Steps.StepReportsStopOthers.stop_mode_dict)
+if self.TraceOn():
+print(Steps.StepReportsStopOthers.stop_mode_dict)
 value = Steps.StepReportsStopOthers.stop_mode_dict[token]
 self.assertEqual(value, stop_others_value, "Stop others has the correct value.")
 
Index: lldb/test/API/functionalities/step_scripted/Steps.py
===
--- lldb/test/API/functionalities/step_scripted/Steps.py
+++ lldb/test/API/functionalities/step_scripted/Steps.py
@@ -19,6 +19,11 @@
 def should_step(self):
 return False
 
+def stop_description(self, stream):
+if self.child_thread_plan.IsPlanComplete():
+return self.child_thread_plan.GetDescription(stream)
+return True
+
 def queue_child_thread_plan(self):
 return None
 
@@ -39,19 +44,18 @@
 # This plan does a step-over until a variable changes value.
 class StepUntil(StepWithChild):
 def __init__(self, thread_plan, args_data, dict):
+self.thread_plan = thread_plan
 self.frame = 

[Lldb-commits] [lldb] 8b68360 - [lldb] Assert on invalid index in OptionValueProperties (NFC)

2023-05-02 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-05-02T12:49:36-07:00
New Revision: 8b6836020464a537c829c56d34ec8f348e1f6056

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

LOG: [lldb] Assert on invalid index in OptionValueProperties (NFC)

All indexes passed to GetPropertyAtIndex are constants generated by
ablegen. We should never pass an invalid index.

Added: 


Modified: 
lldb/include/lldb/Interpreter/OptionValueProperties.h
lldb/source/Core/Debugger.cpp
lldb/source/Interpreter/OptionValueProperties.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h 
b/lldb/include/lldb/Interpreter/OptionValueProperties.h
index b32bb8fa91c8..4782d7eff947 100644
--- a/lldb/include/lldb/Interpreter/OptionValueProperties.h
+++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h
@@ -68,8 +68,6 @@ class OptionValueProperties
 
   // Subclass specific functions
 
-  virtual size_t GetNumProperties() const;
-
   // Get the index of a property given its exact name in this property
   // collection, "name" can't be a path to a property path that refers to a
   // property within a property
@@ -205,10 +203,12 @@ class OptionValueProperties
 
 protected:
   Property *ProtectedGetPropertyAtIndex(uint32_t idx) {
+assert(idx < m_properties.size() && "invalid property index");
 return ((idx < m_properties.size()) ? _properties[idx] : nullptr);
   }
 
   const Property *ProtectedGetPropertyAtIndex(uint32_t idx) const {
+assert(idx < m_properties.size() && "invalid property index");
 return ((idx < m_properties.size()) ? _properties[idx] : nullptr);
   }
 

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 349f1c91d1e3..ff249bc1952f 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -812,6 +812,9 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, 
void *baton)
 GetStaticBroadcasterClass().AsCString()),
   m_forward_listener_sp(), m_clear_once() {
   m_instance_name.SetString(llvm::formatv("debugger_{0}", GetID()).str());
+  // Initialize the debugger properties as early as possible as other parts of
+  // LLDB will start querying them during construction.
+  m_collection_sp->Initialize(g_debugger_properties);
   if (log_callback)
 m_callback_handler_sp =
 std::make_shared(log_callback, baton);
@@ -833,7 +836,6 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, 
void *baton)
   }
   assert(m_dummy_target_sp.get() && "Couldn't construct dummy target?");
 
-  m_collection_sp->Initialize(g_debugger_properties);
   m_collection_sp->AppendProperty(
   ConstString("target"), "Settings specify to debugging targets.", true,
   Target::GetGlobalProperties().GetValueProperties());

diff  --git a/lldb/source/Interpreter/OptionValueProperties.cpp 
b/lldb/source/Interpreter/OptionValueProperties.cpp
index 7f402374a12e..20d613af9481 100644
--- a/lldb/source/Interpreter/OptionValueProperties.cpp
+++ b/lldb/source/Interpreter/OptionValueProperties.cpp
@@ -22,10 +22,6 @@ using namespace lldb_private;
 
 OptionValueProperties::OptionValueProperties(ConstString name) : m_name(name) 
{}
 
-size_t OptionValueProperties::GetNumProperties() const {
-  return m_properties.size();
-}
-
 void OptionValueProperties::Initialize(const PropertyDefinitions ) {
   for (const auto  : defs) {
 Property property(definition);



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


[Lldb-commits] [lldb] ad74df1 - Revert "[lldb][DWARFExpression] Fix DW_OP_div to use signed division"

2023-05-02 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2023-05-02T15:36:56-04:00
New Revision: ad74df12b8b2949bd6f45dc469dc41d488e69f78

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

LOG: Revert "[lldb][DWARFExpression] Fix DW_OP_div to use signed division"

This reverts commit e15d6b520e1e85d2cdf9ffc66f0c4698390eaa3d.

Newly added test fails on Darwin platforms and arm.

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

Added: 


Modified: 
lldb/source/Expression/DWARFExpression.cpp

Removed: 
lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s



diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 9232282d81353..f2ca6534c2fc1 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -1436,12 +1436,8 @@ bool DWARFExpression::Evaluate(
   return false;
 } else {
   stack.pop_back();
-  Scalar divisor, dividend;
-  divisor = tmp.ResolveValue(exe_ctx);
-  dividend = stack.back().ResolveValue(exe_ctx);
-  divisor.MakeSigned();
-  dividend.MakeSigned();
-  stack.back() = dividend / divisor;
+  stack.back() =
+  stack.back().ResolveValue(exe_ctx) / tmp.ResolveValue(exe_ctx);
   if (!stack.back().ResolveValue(exe_ctx).IsValid()) {
 if (error_ptr)
   error_ptr->SetErrorString("Divide failed.");

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s 
b/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s
deleted file mode 100644
index f6fbcdadfdc8d..0
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s
+++ /dev/null
@@ -1,468 +0,0 @@
-  # Test handling of values represented via DW_OP_div
-
-  # RUN: %clang --target=x86_64-pc-linux -o %t %s
-  # RUN: %lldb %t -o "b f" -o "r" -o "c" -o "c" -o "expression -T -- i" \
-  # RUN: -o "exit" | FileCheck %s
-
-  # Failing case was:
-  # (uint32_t) $0 = 0
-  # CHECK: (uint32_t) $0 = 2
-   
-  # This case is generated from the following code:
-  # #include "stdint.h"
-  # static volatile uint64_t g = 0;
-  #  static const int32_t f()
-  #  {
-  #uint32_t i;
-  #for (i = 0; (i != 10); i++)
-  #  ++g;
-  #return 0;
-  #  
-  #  }
-  #
-  #  int main()
-  #  {
-  #f();
-  #return 0;
-  #
-  #  }
-
-  .text
-   .file   "signed_dw_op_div.c"
-   .file   1 "/usr/local/include/bits" "types.h" md5 
0x96c0983c9cdaf387938a8268d00aa594
-   .file   2 "/usr/local/include/bits" "stdint-uintn.h" md5 
0xbedfab747425222bb150968c14e40abd
-   .globl  main# -- Begin function main
-   .p2align4, 0x90
-   .type   main,@function
-main:   # @main
-.Lfunc_begin0:
-   .loc0 13 0  # signed_dw_op_div.c:13:0
-   .cfi_startproc
-# %bb.0:
-   movl$3, %eax
-   #DEBUG_VALUE: f:i <- 0
-   .p2align4, 0x90
-.LBB0_1:# =>This Inner Loop Header: Depth=1
-.Ltmp0:
-   #DEBUG_VALUE: f:i <- [DW_OP_consts 3, DW_OP_minus, DW_OP_consts 
18446744073709551615, DW_OP_div, DW_OP_stack_value] $eax
-   .loc0 8 7 prologue_end  # signed_dw_op_div.c:8:7
-   incqg(%rip)
-.Ltmp1:
-   #DEBUG_VALUE: f:i <- [DW_OP_consts 3, DW_OP_minus, DW_OP_consts 
18446744073709551615, DW_OP_div, DW_OP_consts 1, DW_OP_plus, DW_OP_stack_value] 
$eax
-   .loc0 7 20  # signed_dw_op_div.c:7:20
-   decl%eax
-.Ltmp2:
-   .loc0 7 5 is_stmt 0 # signed_dw_op_div.c:7:5
-   jne .LBB0_1
-.Ltmp3:
-# %bb.2:
-   .loc0 15 5 is_stmt 1# signed_dw_op_div.c:15:5
-   xorl%eax, %eax
-   retq
-.Ltmp4:
-.Lfunc_end0:
-   .size   main, .Lfunc_end0-main
-   .cfi_endproc
-   .file   3 "/usr/local/include/bits" "stdint-intn.h" md5 
0x90039fb90b44dcbf118222513050fe57
-# -- End function
-   .type   g,@object   # @g
-   .local  g
-   .comm   g,8,8
-   .section.debug_loclists,"",@progbits
-   .long   .Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length
-.Ldebug_list_header_start0:
-   .short  5   # Version
-   .byte   8   # Address size
-   .byte   0   # Segment selector size
-   .long   1   # Offset entry count
-.Lloclists_table_base0:
-   .long   .Ldebug_loc0-.Lloclists_table_base0
-.Ldebug_loc0:
-   .byte   4   # 

[Lldb-commits] [PATCH] D147370: [lldb] fixing #61727 fixing incorrect variable displaying with DW_OP_div

2023-05-02 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

Reverted for now until we find fix for test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147370

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


[Lldb-commits] [PATCH] D147370: [lldb] fixing #61727 fixing incorrect variable displaying with DW_OP_div

2023-05-02 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

In D147370#4313196 , @asl wrote:

> This seems to fail on ARM: 
> https://lab.llvm.org/buildbot/#/builders/17/builds/37130

Investigating


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147370

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


[Lldb-commits] [PATCH] D149663: [lldb] Remove FileSpec::GetLastPathComponent

2023-05-02 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

In D149663#4313123 , @bulbazord wrote:

> In D149663#4313112 , @mib wrote:
>
>> @bulbazord What if the FileSpec is pointing to a directory instead of a file 
>> ? What would `GetFilename` return in that case compared to 
>> `GetLastPathComponent` ?
>
> FileSpec chops everything up into a directory and a filename, even if it's 
> pointing to a directory. For example:
>
>   fspec = lldb.SBFileSpec("/foo/bar/baz/")
>   print(fspec.GetDirectory())
>   print(fspec.GetFilename())
>
> This will print "/foo/bar" followed by "baz". baz is clearly a directory, but 
> FileSpec will treat it as the filename. `GetLastPathComponent` uses 
> `llvm::sys::path::filename` to get the last element of the path, which is the 
> exact same mechanism we use when constructing FileSpec's internal 
> `m_directory` and `m_filename` in the first place.

Here's some more bike-shedding: This is not related to this patch specifically, 
but I don't think `GetFilename()`should return `baz` since it's not a file. 
Similarly, `GetDirectory()` should `/foo/bar/baz/`. Then in order to get the 
pointed file or directory I'd use `GetLastPathComponent()`. And to get the 
parent (`/foo/bar`), I think we should expose a new `GetParent` method. TBH, I 
find the current behavior very confusing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149663

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


[Lldb-commits] [lldb] 419bc85 - Revert "Add amissing REQUIRES: to test"

2023-05-02 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2023-05-02T11:41:58-07:00
New Revision: 419bc85675fe73f2d19cd3f756cf029248fb4295

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

LOG: Revert "Add amissing REQUIRES: to test"

This reverts commit 1f74964b403c615c121c0adbd06661adaae14667.

The googles. They do nothing!

Added: 


Modified: 
lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s

Removed: 




diff  --git a/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s 
b/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s
index 5d1edf8b73da..f6fbcdadfdc8 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s
@@ -1,6 +1,5 @@
   # Test handling of values represented via DW_OP_div
 
-  # REQUIRES: lld
   # RUN: %clang --target=x86_64-pc-linux -o %t %s
   # RUN: %lldb %t -o "b f" -o "r" -o "c" -o "c" -o "expression -T -- i" \
   # RUN: -o "exit" | FileCheck %s



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


[Lldb-commits] [PATCH] D147370: [lldb] fixing #61727 fixing incorrect variable displaying with DW_OP_div

2023-05-02 Thread Anton Korobeynikov via Phabricator via lldb-commits
asl added a comment.

The test seems to rely on the presence of the linker for the desired target 
platform, so cannot be used on cross-compile environment.

   TEST 'lldb-shell :: 
SymbolFile/DWARF/x86/DW_OP_div-with-signed.s' FAILED 
  Script:
  --
  : 'RUN: at line 3';   
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang 
--target=specify-a-target-or-use-a-_host-substitution --target=x86_64-pc-linux 
-o 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/DW_OP_div-with-signed.s.tmp
 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s
  : 'RUN: at line 4';   
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/lldb --no-lldbinit -S 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/test/Shell/lit-lldb-init-quiet
 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/DW_OP_div-with-signed.s.tmp
 -o "b f" -o "r" -o "c" -o "c" -o "expression -T -- i"  -o "exit" | 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/FileCheck 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s
  --
  Exit Code: 1
  Command Output (stderr):
  --
  /usr/bin/ld: unrecognised emulation mode: elf_x86_64
  Supported emulations: armelf_linux_eabi armelfb_linux_eabi
  clang: error: linker command failed with exit code 1 (use -v to see 
invocation)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147370

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


[Lldb-commits] [PATCH] D147370: [lldb] fixing #61727 fixing incorrect variable displaying with DW_OP_div

2023-05-02 Thread Anton Korobeynikov via Phabricator via lldb-commits
asl added a comment.

This seems to fail on ARM: 
https://lab.llvm.org/buildbot/#/builders/17/builds/37130


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147370

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


[Lldb-commits] [PATCH] D149663: [lldb] Remove FileSpec::GetLastPathComponent

2023-05-02 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added a comment.

In D149663#4313112 , @mib wrote:

> @bulbazord What if the FileSpec is pointing to a directory instead of a file 
> ? What would `GetFilename` return in that case compared to 
> `GetLastPathComponent` ?

FileSpec chops everything up into a directory and a filename, even if it's 
pointing to a directory. For example:

  fspec = lldb.SBFileSpec("/foo/bar/baz/")
  print(fspec.GetDirectory())
  print(fspec.GetFilename())

This will print "/foo/bar" followed by "baz". baz is clearly a directory, but 
FileSpec will treat it as the filename. `GetLastPathComponent` uses 
`llvm::sys::path::filename` to get the last element of the path, which is the 
exact same mechanism we use when constructing FileSpec's internal `m_directory` 
and `m_filename` in the first place.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149663

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


[Lldb-commits] [lldb] 1f74964 - Add amissing REQUIRES: to test

2023-05-02 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2023-05-02T11:16:04-07:00
New Revision: 1f74964b403c615c121c0adbd06661adaae14667

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

LOG: Add amissing REQUIRES: to test

Added: 


Modified: 
lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s

Removed: 




diff  --git a/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s 
b/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s
index f6fbcdadfdc8..5d1edf8b73da 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s
@@ -1,5 +1,6 @@
   # Test handling of values represented via DW_OP_div
 
+  # REQUIRES: lld
   # RUN: %clang --target=x86_64-pc-linux -o %t %s
   # RUN: %lldb %t -o "b f" -o "r" -o "c" -o "c" -o "expression -T -- i" \
   # RUN: -o "exit" | FileCheck %s



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


[Lldb-commits] [PATCH] D147370: [lldb] fixing #61727 fixing incorrect variable displaying with DW_OP_div

2023-05-02 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

I'll try adding a `# REQUIRES: lld`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147370

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


[Lldb-commits] [PATCH] D149663: [lldb] Remove FileSpec::GetLastPathComponent

2023-05-02 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

@bulbazord What if the FileSpec is pointing to a directory instead of a file ? 
What would `GetFilename` return in that case compared to `GetLastPathComponent` 
?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149663

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


[Lldb-commits] [PATCH] D147370: [lldb] fixing #61727 fixing incorrect variable displaying with DW_OP_div

2023-05-02 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

This test is failing on Darwin: 
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/lastFailedBuild/testReport/lldb-shell/SymbolFile_DWARF_x86/DW_OP_div_with_signed_s/

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/lastFailedBuild/

ld: unknown option: --hash-style=gnu
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147370

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


[Lldb-commits] [lldb] 30c1f31 - [lldb] Fix 8be139fc1251 for propery value changes

2023-05-02 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-05-02T11:09:53-07:00
New Revision: 30c1f31274e5abb535387940af2337c2e4fcc8a7

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

LOG: [lldb] Fix 8be139fc1251 for propery value changes

Fix 8be139fc1251 for mid-air collision with the propery value changes.

Added: 


Modified: 
lldb/source/Target/Target.cpp

Removed: 




diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 9d4581d4ffd4..74ab4ea373d8 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -4588,20 +4588,20 @@ uint64_t TargetProperties::GetExprErrorLimit() const {
 
 uint64_t TargetProperties::GetExprAllocAddress() const {
   const uint32_t idx = ePropertyExprAllocAddress;
-  return m_collection_sp->GetPropertyAtIndexAsUInt64(
-  nullptr, idx, g_target_properties[idx].default_uint_value);
+  return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
+  g_target_properties[idx].default_uint_value);
 }
 
 uint64_t TargetProperties::GetExprAllocSize() const {
   const uint32_t idx = ePropertyExprAllocSize;
-  return m_collection_sp->GetPropertyAtIndexAsUInt64(
-  nullptr, idx, g_target_properties[idx].default_uint_value);
+  return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
+  g_target_properties[idx].default_uint_value);
 }
 
 uint64_t TargetProperties::GetExprAllocAlign() const {
   const uint32_t idx = ePropertyExprAllocAlign;
-  return m_collection_sp->GetPropertyAtIndexAsUInt64(
-  nullptr, idx, g_target_properties[idx].default_uint_value);
+  return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
+  g_target_properties[idx].default_uint_value);
 }
 
 bool TargetProperties::GetBreakpointsConsultPlatformAvoidList() {



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


[Lldb-commits] [PATCH] D149262: [lldb] Add settings for expression evaluation memory allocations.

2023-05-02 Thread Anton Korobeynikov via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8be139fc1251: [lldb] Add settings for expression evaluation 
memory allocations. (authored by kuilpd, committed by asl).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149262

Files:
  lldb/include/lldb/Target/ABI.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Expression/IRMemoryMap.cpp
  lldb/source/Expression/LLVMUserExpression.cpp
  lldb/source/Plugins/ABI/MSP430/ABISysV_msp430.h
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetProperties.td
  lldb/test/API/commands/expression/memory-allocation/Makefile
  lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py
  lldb/test/API/commands/expression/memory-allocation/main.cpp

Index: lldb/test/API/commands/expression/memory-allocation/main.cpp
===
--- /dev/null
+++ lldb/test/API/commands/expression/memory-allocation/main.cpp
@@ -0,0 +1,3 @@
+int main() {
+  return 0;
+}
Index: lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py
===
--- /dev/null
+++ lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py
@@ -0,0 +1,35 @@
+"""
+Test changing setting for expression memory allocation.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestMemoryAllocSettings(TestBase):
+
+def test(self):
+"""Test changing settings for expression memory allocation."""
+self.build()
+target = self.createTestTarget()
+
+self.log_file = self.getBuildArtifact("log-expr.txt")
+
+self.runCmd("settings set target.expr-alloc-address 0xdead")
+self.runCmd("settings set target.expr-alloc-size 1")
+self.runCmd("settings set target.expr-alloc-align 0x1000")
+
+self.runCmd("log enable lldb expr -f " + self.log_file)
+self.runCmd("expression -- int foo; ")
+
+self.assertTrue(os.path.isfile(self.log_file))
+with open(self.log_file, 'r') as f:
+log = f.read()
+
+alloc0 = re.search('^.*IRMemoryMap::Malloc.+?0xdead.*$', log, re.MULTILINE)
+# Malloc adds additional bytes to allocation size, hence 10007
+alloc1 = re.search('^.*IRMemoryMap::Malloc\s*?\(10007.+?0xdead1000.*$', log, re.MULTILINE)
+self.assertTrue(alloc0, "Couldn't find an allocation at a given address.")
+self.assertTrue(alloc1, "Couldn't find an allocation of a given size at a given address.")
+
Index: lldb/test/API/commands/expression/memory-allocation/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/expression/memory-allocation/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Target/TargetProperties.td
===
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -24,6 +24,15 @@
 DefaultUnsignedValue<5>,
 Desc<"The maximum amount of errors to emit while parsing an expression. "
  "A value of 0 means to always continue parsing if possible.">;
+  def ExprAllocAddress: Property<"expr-alloc-address", "UInt64">,
+DefaultUnsignedValue<0>,
+Desc<"Start address within the process address space of memory allocation for expression evaluation.">;
+  def ExprAllocSize: Property<"expr-alloc-size", "UInt64">,
+DefaultUnsignedValue<0>,
+Desc<"Amount of memory in bytes to allocate for expression evaluation.">;
+  def ExprAllocAlign: Property<"expr-alloc-align", "UInt64">,
+DefaultUnsignedValue<0>,
+Desc<"Alignment for each memory allocation for expression evaluation.">;
   def PreferDynamic: Property<"prefer-dynamic-value", "Enum">,
 DefaultEnumValue<"eDynamicDontRunTarget">,
 EnumValues<"OptionEnumValues(g_dynamic_value_types)">,
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -4586,6 +4586,24 @@
   g_target_properties[idx].default_uint_value);
 }
 
+uint64_t TargetProperties::GetExprAllocAddress() const {
+  const uint32_t idx = ePropertyExprAllocAddress;
+  return m_collection_sp->GetPropertyAtIndexAsUInt64(
+  nullptr, idx, g_target_properties[idx].default_uint_value);
+}
+
+uint64_t TargetProperties::GetExprAllocSize() const {
+  const uint32_t idx = ePropertyExprAllocSize;
+  return m_collection_sp->GetPropertyAtIndexAsUInt64(
+  nullptr, idx, g_target_properties[idx].default_uint_value);
+}
+
+uint64_t TargetProperties::GetExprAllocAlign() const {
+  const 

[Lldb-commits] [lldb] 8be139f - [lldb] Add settings for expression evaluation memory allocations.

2023-05-02 Thread Anton Korobeynikov via lldb-commits

Author: Ilya Kuklin
Date: 2023-05-02T11:02:44-07:00
New Revision: 8be139fc1251b99316d65403bde9c2326b12da20

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

LOG: [lldb] Add settings for expression evaluation memory allocations.

Expression evaluation allocates memory for storing intermediate data during 
evaluation. For it to work properly it has to be allocated within target's 
available address space, for example within first 0x bytes for the 16-bit 
MSP430. The memory for such targets can be very tightly packed, but not all 
targets support GetMemoryRegionInfo API to pick an unused region, like MSP430 
with MSPDebug GDB server.

These settings allow the programmer to manually pick precisely where and how 
much memory to allocate for expression evaluation in order not to overlap with 
existing data in process memory.

Reviewed By: bulbazord

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

Added: 
lldb/test/API/commands/expression/memory-allocation/Makefile

lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py
lldb/test/API/commands/expression/memory-allocation/main.cpp

Modified: 
lldb/include/lldb/Target/ABI.h
lldb/include/lldb/Target/Target.h
lldb/source/Expression/IRMemoryMap.cpp
lldb/source/Expression/LLVMUserExpression.cpp
lldb/source/Plugins/ABI/MSP430/ABISysV_msp430.h
lldb/source/Target/Target.cpp
lldb/source/Target/TargetProperties.td

Removed: 




diff  --git a/lldb/include/lldb/Target/ABI.h b/lldb/include/lldb/Target/ABI.h
index f0753172d3e71..f600e29c7c4b0 100644
--- a/lldb/include/lldb/Target/ABI.h
+++ b/lldb/include/lldb/Target/ABI.h
@@ -147,6 +147,8 @@ class ABI : public PluginInterface {
 
   virtual bool GetPointerReturnRegister(const char *) { return false; }
 
+  virtual uint64_t GetStackFrameSize() { return 512 * 1024; }
+
   static lldb::ABISP FindPlugin(lldb::ProcessSP process_sp, const ArchSpec 
);
 
 protected:

diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index b557dd26a3acc..d15f0705630ce 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -204,6 +204,12 @@ class TargetProperties : public Properties {
 
   uint64_t GetExprErrorLimit() const;
 
+  uint64_t GetExprAllocAddress() const;
+
+  uint64_t GetExprAllocSize() const;
+
+  uint64_t GetExprAllocAlign() const;
+
   bool GetUseHexImmediates() const;
 
   bool GetUseFastStepping() const;

diff  --git a/lldb/source/Expression/IRMemoryMap.cpp 
b/lldb/source/Expression/IRMemoryMap.cpp
index 951444db86a87..de631370bb048 100644
--- a/lldb/source/Expression/IRMemoryMap.cpp
+++ b/lldb/source/Expression/IRMemoryMap.cpp
@@ -92,26 +92,26 @@ lldb::addr_t IRMemoryMap::FindSpace(size_t size) {
 ret = llvm::alignTo(addr + alloc_size, 4096);
   }
 
+  uint64_t end_of_memory;
+  switch (GetAddressByteSize()) {
+  case 2:
+end_of_memory = 0xull;
+break;
+  case 4:
+end_of_memory = 0xull;
+break;
+  case 8:
+end_of_memory = 0xull;
+break;
+  default:
+lldbassert(false && "Invalid address size.");
+return LLDB_INVALID_ADDRESS;
+  }
+
   // Now, if it's possible to use the GetMemoryRegionInfo API to detect mapped
   // regions, walk forward through memory until a region is found that has
   // adequate space for our allocation.
   if (process_is_alive) {
-uint64_t end_of_memory;
-switch (process_sp->GetAddressByteSize()) {
-case 2:
-  end_of_memory = 0xull;
-  break;
-case 4:
-  end_of_memory = 0xull;
-  break;
-case 8:
-  end_of_memory = 0xull;
-  break;
-default:
-  lldbassert(false && "Invalid address size.");
-  return LLDB_INVALID_ADDRESS;
-}
-
 MemoryRegionInfo region_info;
 Status err = process_sp->GetMemoryRegionInfo(ret, region_info);
 if (err.Success()) {
@@ -147,29 +147,40 @@ lldb::addr_t IRMemoryMap::FindSpace(size_t size) {
   // to the end of the allocations we've already reported, or use a 'sensible'
   // default if this is our first allocation.
   if (m_allocations.empty()) {
-uint32_t address_byte_size = GetAddressByteSize();
-if (address_byte_size != UINT32_MAX) {
-  switch (address_byte_size) {
-  case 2:
-ret = 0x8000ull;
-break;
-  case 4:
-ret = 0xee00ull;
-break;
-  case 8:
-ret = 0xdead0fffull;
-break;
-  default:
-lldbassert(false && "Invalid address size.");
+uint64_t alloc_address = target_sp->GetExprAllocAddress();
+if (alloc_address > 0) {
+  if (alloc_address >= end_of_memory) {
+lldbassert(0 && "The allocation address for expression evaluation must 
"
+  

[Lldb-commits] [PATCH] D149262: [lldb] Add settings for expression evaluation memory allocations.

2023-05-02 Thread Ilia Kuklin via Phabricator via lldb-commits
kuilpd updated this revision to Diff 518801.
kuilpd added a comment.

Rebased.


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

https://reviews.llvm.org/D149262

Files:
  lldb/include/lldb/Target/ABI.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Expression/IRMemoryMap.cpp
  lldb/source/Expression/LLVMUserExpression.cpp
  lldb/source/Plugins/ABI/MSP430/ABISysV_msp430.h
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetProperties.td
  lldb/test/API/commands/expression/memory-allocation/Makefile
  lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py
  lldb/test/API/commands/expression/memory-allocation/main.cpp

Index: lldb/test/API/commands/expression/memory-allocation/main.cpp
===
--- /dev/null
+++ lldb/test/API/commands/expression/memory-allocation/main.cpp
@@ -0,0 +1,3 @@
+int main() {
+  return 0;
+}
Index: lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py
===
--- /dev/null
+++ lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py
@@ -0,0 +1,35 @@
+"""
+Test changing setting for expression memory allocation.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestMemoryAllocSettings(TestBase):
+
+def test(self):
+"""Test changing settings for expression memory allocation."""
+self.build()
+target = self.createTestTarget()
+
+self.log_file = self.getBuildArtifact("log-expr.txt")
+
+self.runCmd("settings set target.expr-alloc-address 0xdead")
+self.runCmd("settings set target.expr-alloc-size 1")
+self.runCmd("settings set target.expr-alloc-align 0x1000")
+
+self.runCmd("log enable lldb expr -f " + self.log_file)
+self.runCmd("expression -- int foo; ")
+
+self.assertTrue(os.path.isfile(self.log_file))
+with open(self.log_file, 'r') as f:
+log = f.read()
+
+alloc0 = re.search('^.*IRMemoryMap::Malloc.+?0xdead.*$', log, re.MULTILINE)
+# Malloc adds additional bytes to allocation size, hence 10007
+alloc1 = re.search('^.*IRMemoryMap::Malloc\s*?\(10007.+?0xdead1000.*$', log, re.MULTILINE)
+self.assertTrue(alloc0, "Couldn't find an allocation at a given address.")
+self.assertTrue(alloc1, "Couldn't find an allocation of a given size at a given address.")
+
Index: lldb/test/API/commands/expression/memory-allocation/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/expression/memory-allocation/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Target/TargetProperties.td
===
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -24,6 +24,15 @@
 DefaultUnsignedValue<5>,
 Desc<"The maximum amount of errors to emit while parsing an expression. "
  "A value of 0 means to always continue parsing if possible.">;
+  def ExprAllocAddress: Property<"expr-alloc-address", "UInt64">,
+DefaultUnsignedValue<0>,
+Desc<"Start address within the process address space of memory allocation for expression evaluation.">;
+  def ExprAllocSize: Property<"expr-alloc-size", "UInt64">,
+DefaultUnsignedValue<0>,
+Desc<"Amount of memory in bytes to allocate for expression evaluation.">;
+  def ExprAllocAlign: Property<"expr-alloc-align", "UInt64">,
+DefaultUnsignedValue<0>,
+Desc<"Alignment for each memory allocation for expression evaluation.">;
   def PreferDynamic: Property<"prefer-dynamic-value", "Enum">,
 DefaultEnumValue<"eDynamicDontRunTarget">,
 EnumValues<"OptionEnumValues(g_dynamic_value_types)">,
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -4586,6 +4586,24 @@
   g_target_properties[idx].default_uint_value);
 }
 
+uint64_t TargetProperties::GetExprAllocAddress() const {
+  const uint32_t idx = ePropertyExprAllocAddress;
+  return m_collection_sp->GetPropertyAtIndexAsUInt64(
+  nullptr, idx, g_target_properties[idx].default_uint_value);
+}
+
+uint64_t TargetProperties::GetExprAllocSize() const {
+  const uint32_t idx = ePropertyExprAllocSize;
+  return m_collection_sp->GetPropertyAtIndexAsUInt64(
+  nullptr, idx, g_target_properties[idx].default_uint_value);
+}
+
+uint64_t TargetProperties::GetExprAllocAlign() const {
+  const uint32_t idx = ePropertyExprAllocAlign;
+  return m_collection_sp->GetPropertyAtIndexAsUInt64(
+  nullptr, idx, g_target_properties[idx].default_uint_value);
+}
+
 bool TargetProperties::GetBreakpointsConsultPlatformAvoidList() 

[Lldb-commits] [PATCH] D149671: [lldb] Minor cleanups at callsites of FileSpec::GetFileNameExtension

2023-05-02 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, mib, jingham, jasonmolenda.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

FileSpec::GetFileNameExtension returns a StringRef. In some cases we
are calling it and then storing the result in a StringRef. To prevent
cases where we store the StringRef, mutate the Filespec, and then try to
use the FileSpec afterwards, I've audited the callsites and made
adjustments to mitigate: Either marking the FileSpec it comes from as
const (to avoid mutations) or by not storing the StringRef in a local if
it makes sense not to.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149671

Files:
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
@@ -131,14 +131,13 @@
 }
 
 llvm::Error Lua::LoadModule(llvm::StringRef filename) {
-  FileSpec file(filename);
+  const FileSpec file(filename);
   if (!FileSystem::Instance().Exists(file)) {
 return llvm::make_error("invalid path",
llvm::inconvertibleErrorCode());
   }
 
-  llvm::StringRef module_extension = file.GetFileNameExtension();
-  if (module_extension != ".lua") {
+  if (file.GetFileNameExtension() != ".lua") {
 return llvm::make_error("invalid extension",
llvm::inconvertibleErrorCode());
   }
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
@@ -137,7 +137,8 @@
   // with the binary inside it ('.../foo.dSYM/Contents/Resources/DWARF/foo').
   // A dSYM bundle may have multiple DWARF binaries in them, so a vector
   // of matches is returned.
-  static std::vector GetDWARFBinaryInDSYMBundle(FileSpec 
dsym_bundle);
+  static std::vector
+  GetDWARFBinaryInDSYMBundle(const FileSpec _bundle);
 
   Status GetSharedModuleKext(const ModuleSpec _spec, Process *process,
  lldb::ModuleSP _sp,
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -422,7 +422,7 @@
   static constexpr llvm::StringLiteral g_kdk_suffix = ".kdk";
 
   PlatformDarwinKernel *thisp = (PlatformDarwinKernel *)baton;
-  FileSpec file_spec(path);
+  const FileSpec file_spec(path);
   if (ft == llvm::sys::fs::file_type::directory_file &&
   (file_spec.GetFileNameExtension() == g_sdk_suffix ||
file_spec.GetFileNameExtension() == g_kdk_suffix)) {
@@ -483,7 +483,7 @@
   static constexpr llvm::StringLiteral g_kext_suffix = ".kext";
   static constexpr llvm::StringLiteral g_dsym_suffix = ".dSYM";
 
-  FileSpec file_spec(path);
+  const FileSpec file_spec(path);
   llvm::StringRef file_spec_extension = file_spec.GetFileNameExtension();
 
   Log *log = GetLog(LLDBLog::Platform);
@@ -692,7 +692,7 @@
 // it should iterate over every binary in the DWARF subdir
 // and return them all.
 std::vector
-PlatformDarwinKernel::GetDWARFBinaryInDSYMBundle(FileSpec dsym_bundle) {
+PlatformDarwinKernel::GetDWARFBinaryInDSYMBundle(const FileSpec _bundle) {
   std::vector results;
   static constexpr llvm::StringLiteral g_dsym_suffix = ".dSYM";
   if (dsym_bundle.GetFileNameExtension() != g_dsym_suffix) {
Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -2161,7 +2161,7 @@
 }
 
 const char *pcm_path = command.GetArgumentAtIndex(0);
-FileSpec pcm_file{pcm_path};
+const FileSpec pcm_file{pcm_path};
 
 if (pcm_file.GetFileNameExtension() != ".pcm") {
   result.AppendError("file must have a .pcm extension");


Index: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
@@ -131,14 +131,13 @@
 }
 
 llvm::Error Lua::LoadModule(llvm::StringRef filename) {
-  FileSpec file(filename);
+  const FileSpec file(filename);
   if (!FileSystem::Instance().Exists(file)) {
 return llvm::make_error("invalid path",
  

[Lldb-commits] [PATCH] D149625: [lldb] Refactor SBFileSpec::GetDirectory

2023-05-02 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added a comment.

In D149625#4312838 , @jingham wrote:

> The old code had the side-effect of NOT resolving the path of the SBFileSpec 
> in order to get its directory.  I am not sure whether that was on purpose or 
> not, however.

To be more precise, the old code had the side-effect of guaranteeing that 
whatever path was given to you was from an unresolved FileSpec. Right now, if 
the SBFileSpec is unresolved, this will do the exact same thing as before. With 
this change, if an SBFileSpec is resolved, the path you're getting is from a 
resolved FileSpec. I'm pretty sure that this shouldn't actually be different 
than what was there before since we're making a copy from the underlying 
FileSpec though, unless I'm missing something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149625

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


[Lldb-commits] [PATCH] D149663: [lldb] Remove FileSpec::GetLastPathComponent

2023-05-02 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149663

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


[Lldb-commits] [PATCH] D149663: [lldb] Remove FileSpec::GetLastPathComponent

2023-05-02 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, mib, jingham, jasonmolenda.
Herald added a subscriber: emaste.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added subscribers: lldb-commits, MaskRay.
Herald added a project: LLDB.

As far as I can tell, this just computes the filename of the FileSpec,
which is already conveniently stored in m_filename. We can use
FileSpec::GetFilename() instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149663

Files:
  lldb/include/lldb/Utility/FileSpec.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
  lldb/source/Target/Platform.cpp
  lldb/source/Utility/FileSpec.cpp
  lldb/source/Utility/XcodeSDK.cpp

Index: lldb/source/Utility/XcodeSDK.cpp
===
--- lldb/source/Utility/XcodeSDK.cpp
+++ lldb/source/Utility/XcodeSDK.cpp
@@ -242,7 +242,7 @@
 
 bool XcodeSDK::SDKSupportsModules(XcodeSDK::Type desired_type,
   const FileSpec _path) {
-  ConstString last_path_component = sdk_path.GetLastPathComponent();
+  ConstString last_path_component = sdk_path.GetFilename();
 
   if (!last_path_component)
 return false;
Index: lldb/source/Utility/FileSpec.cpp
===
--- lldb/source/Utility/FileSpec.cpp
+++ lldb/source/Utility/FileSpec.cpp
@@ -429,12 +429,6 @@
   return *this;
 }
 
-ConstString FileSpec::GetLastPathComponent() const {
-  llvm::SmallString<64> current_path;
-  GetPath(current_path, false);
-  return ConstString(llvm::sys::path::filename(current_path, m_style));
-}
-
 void FileSpec::PrependPathComponent(llvm::StringRef component) {
   llvm::SmallString<64> new_path(component);
   llvm::SmallString<64> current_path;
Index: lldb/source/Target/Platform.cpp
===
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -435,7 +435,7 @@
 // make the new directory and get in there
 FileSpec dst_dir = rc_baton->dst;
 if (!dst_dir.GetFilename())
-  dst_dir.SetFilename(src.GetLastPathComponent());
+  dst_dir.SetFilename(src.GetFilename());
 Status error = rc_baton->platform_ptr->MakeDirectory(
 dst_dir, lldb::eFilePermissionsDirectoryDefault);
 if (error.Fail()) {
Index: lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
===
--- lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
+++ lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
@@ -1268,7 +1268,7 @@
 
 auto _spec = module_sp->GetFileSpec();
 found_logging_support_module =
-(file_spec.GetLastPathComponent() == logging_module_name);
+(file_spec.GetFilename() == logging_module_name);
 if (found_logging_support_module)
   break;
   }
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1238,10 +1238,9 @@
 
 FileSpec platform_pull_upart(platform_file);
 std::vector path_parts;
-path_parts.push_back(
-platform_pull_upart.GetLastPathComponent().AsCString());
+path_parts.push_back(platform_pull_upart.GetFilename().AsCString());
 while (platform_pull_upart.RemoveLastPathComponent()) {
-  ConstString part = platform_pull_upart.GetLastPathComponent();
+  ConstString part = platform_pull_upart.GetFilename();
   path_parts.push_back(part.AsCString());
 }
 const size_t path_parts_size = path_parts.size();
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -166,7 +166,7 @@
 auto raw_data = coff_obj.getData();
 LLDB_SCOPED_TIMERF(
 "Calculating module crc32 %s with size %" PRIu64 " KiB",
-FileSpec(coff_obj.getFileName()).GetLastPathComponent().AsCString(),
+FileSpec(coff_obj.getFileName()).GetFilename().AsCString(),
 static_cast(raw_data.size()) / 1024);
 gnu_debuglink_crc = llvm::crc32(0, llvm::arrayRefFromStringRef(raw_data));
   }
@@ -295,7 +295,7 @@
   const auto *map = GetGlobalPluginProperties().ModuleABIMap();
   if (map->GetNumValues() > 0) {
 // Step 1: Try with the exact file name.
-auto name = file.GetLastPathComponent();
+auto name = file.GetFilename();
 module_env_option = map->GetValueForKey(name);
 if 

[Lldb-commits] [PATCH] D149625: [lldb] Refactor SBFileSpec::GetDirectory

2023-05-02 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

The old code had the side-effect of NOT resolving the path of the SBFileSpec in 
order to get its directory.  I am not sure whether that was on purpose or not, 
however.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149625

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


[Lldb-commits] [PATCH] D149625: [lldb] Refactor SBFileSpec::GetDirectory

2023-05-02 Thread Alex Langford via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2bea2d7b070d: [lldb] Refactor SBFileSpec::GetDirectory 
(authored by bulbazord).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149625

Files:
  lldb/source/API/SBFileSpec.cpp


Index: lldb/source/API/SBFileSpec.cpp
===
--- lldb/source/API/SBFileSpec.cpp
+++ lldb/source/API/SBFileSpec.cpp
@@ -114,9 +114,7 @@
 const char *SBFileSpec::GetDirectory() const {
   LLDB_INSTRUMENT_VA(this);
 
-  FileSpec directory{*m_opaque_up};
-  directory.ClearFilename();
-  return directory.GetPathAsConstString().GetCString();
+  return m_opaque_up->GetDirectory().GetCString();
 }
 
 void SBFileSpec::SetFilename(const char *filename) {


Index: lldb/source/API/SBFileSpec.cpp
===
--- lldb/source/API/SBFileSpec.cpp
+++ lldb/source/API/SBFileSpec.cpp
@@ -114,9 +114,7 @@
 const char *SBFileSpec::GetDirectory() const {
   LLDB_INSTRUMENT_VA(this);
 
-  FileSpec directory{*m_opaque_up};
-  directory.ClearFilename();
-  return directory.GetPathAsConstString().GetCString();
+  return m_opaque_up->GetDirectory().GetCString();
 }
 
 void SBFileSpec::SetFilename(const char *filename) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 2bea2d7 - [lldb] Refactor SBFileSpec::GetDirectory

2023-05-02 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2023-05-02T10:01:36-07:00
New Revision: 2bea2d7b070dc5df723ce2b92dbc654b8bb1847e

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

LOG: [lldb] Refactor SBFileSpec::GetDirectory

There's no reason to create an entire new filespec to mutate and grab
data from when we can just grab the data directly.

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

Added: 


Modified: 
lldb/source/API/SBFileSpec.cpp

Removed: 




diff  --git a/lldb/source/API/SBFileSpec.cpp b/lldb/source/API/SBFileSpec.cpp
index a7df9afc4b8e..8668b64b4ce7 100644
--- a/lldb/source/API/SBFileSpec.cpp
+++ b/lldb/source/API/SBFileSpec.cpp
@@ -114,9 +114,7 @@ const char *SBFileSpec::GetFilename() const {
 const char *SBFileSpec::GetDirectory() const {
   LLDB_INSTRUMENT_VA(this);
 
-  FileSpec directory{*m_opaque_up};
-  directory.ClearFilename();
-  return directory.GetPathAsConstString().GetCString();
+  return m_opaque_up->GetDirectory().GetCString();
 }
 
 void SBFileSpec::SetFilename(const char *filename) {



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


[Lldb-commits] [PATCH] D149641: [docs] Hide collaboration and include graphs in doxygen docs

2023-05-02 Thread Shilei Tian via Phabricator via lldb-commits
tianshilei1992 added a comment.

Looks good on the OpenMP side as we don’t generally have a good API doc anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149641

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


[Lldb-commits] [PATCH] D149641: [docs] Hide collaboration and include graphs in doxygen docs

2023-05-02 Thread Aaron Ballman via Phabricator via lldb-commits
aaron.ballman added a comment.
Herald added a reviewer: jdoerfert.
Herald added subscribers: jplehr, sstefan1, JDevlieghere.

I think this is a reasonable change -- I don't see a whole lot of value out 
from the include or collaboration graphs, so unless someone has strong opinions 
otherwise, I think this LG for the Clang side of things.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149641

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


[Lldb-commits] [lldb] 73e15b5 - [lldb] Add cstdio include to fix a595b931f1f91897317a4257df313bddfeb029a6

2023-05-02 Thread Dmitry Chernenkov via lldb-commits

Author: Dmitry Chernenkov
Date: 2023-05-02T12:47:37Z
New Revision: 73e15b5edb4fa4a77e68c299a6e3b21e610d351f

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

LOG: [lldb] Add cstdio include to fix a595b931f1f91897317a4257df313bddfeb029a6

Added: 


Modified: 
lldb/include/lldb/API/SBFile.h

Removed: 




diff  --git a/lldb/include/lldb/API/SBFile.h b/lldb/include/lldb/API/SBFile.h
index d8b348b25c815..ebdc5607b7942 100644
--- a/lldb/include/lldb/API/SBFile.h
+++ b/lldb/include/lldb/API/SBFile.h
@@ -11,6 +11,8 @@
 
 #include "lldb/API/SBDefines.h"
 
+#include 
+
 namespace lldb {
 
 class LLDB_API SBFile {



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


[Lldb-commits] [PATCH] D147370: [lldb] fixing #61727 fixing incorrect variable displaying with DW_OP_div

2023-05-02 Thread Michael Buch via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe15d6b520e1e: [lldb][DWARFExpression] Fix DW_OP_div to use 
signed division (authored by jwnhy, committed by Michael137).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147370

Files:
  lldb/source/Expression/DWARFExpression.cpp
  lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s

Index: lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s
@@ -0,0 +1,468 @@
+  # Test handling of values represented via DW_OP_div
+
+  # RUN: %clang --target=x86_64-pc-linux -o %t %s
+  # RUN: %lldb %t -o "b f" -o "r" -o "c" -o "c" -o "expression -T -- i" \
+  # RUN: -o "exit" | FileCheck %s
+
+  # Failing case was:
+  # (uint32_t) $0 = 0
+  # CHECK: (uint32_t) $0 = 2
+	
+  # This case is generated from the following code:
+  # #include "stdint.h"
+  # static volatile uint64_t g = 0;
+  #  static const int32_t f()
+  #  {
+  #uint32_t i;
+  #for (i = 0; (i != 10); i++)
+  #  ++g;
+  #return 0;
+  #  
+  #  }
+  #
+  #  int main()
+  #  {
+  #f();
+  #return 0;
+  #
+  #  }
+
+  .text
+	.file	"signed_dw_op_div.c"
+	.file	1 "/usr/local/include/bits" "types.h" md5 0x96c0983c9cdaf387938a8268d00aa594
+	.file	2 "/usr/local/include/bits" "stdint-uintn.h" md5 0xbedfab747425222bb150968c14e40abd
+	.globl	main# -- Begin function main
+	.p2align	4, 0x90
+	.type	main,@function
+main:   # @main
+.Lfunc_begin0:
+	.loc	0 13 0  # signed_dw_op_div.c:13:0
+	.cfi_startproc
+# %bb.0:
+	movl	$3, %eax
+	#DEBUG_VALUE: f:i <- 0
+	.p2align	4, 0x90
+.LBB0_1:# =>This Inner Loop Header: Depth=1
+.Ltmp0:
+	#DEBUG_VALUE: f:i <- [DW_OP_consts 3, DW_OP_minus, DW_OP_consts 18446744073709551615, DW_OP_div, DW_OP_stack_value] $eax
+	.loc	0 8 7 prologue_end  # signed_dw_op_div.c:8:7
+	incq	g(%rip)
+.Ltmp1:
+	#DEBUG_VALUE: f:i <- [DW_OP_consts 3, DW_OP_minus, DW_OP_consts 18446744073709551615, DW_OP_div, DW_OP_consts 1, DW_OP_plus, DW_OP_stack_value] $eax
+	.loc	0 7 20  # signed_dw_op_div.c:7:20
+	decl	%eax
+.Ltmp2:
+	.loc	0 7 5 is_stmt 0 # signed_dw_op_div.c:7:5
+	jne	.LBB0_1
+.Ltmp3:
+# %bb.2:
+	.loc	0 15 5 is_stmt 1# signed_dw_op_div.c:15:5
+	xorl	%eax, %eax
+	retq
+.Ltmp4:
+.Lfunc_end0:
+	.size	main, .Lfunc_end0-main
+	.cfi_endproc
+	.file	3 "/usr/local/include/bits" "stdint-intn.h" md5 0x90039fb90b44dcbf118222513050fe57
+# -- End function
+	.type	g,@object   # @g
+	.local	g
+	.comm	g,8,8
+	.section	.debug_loclists,"",@progbits
+	.long	.Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length
+.Ldebug_list_header_start0:
+	.short	5   # Version
+	.byte	8   # Address size
+	.byte	0   # Segment selector size
+	.long	1   # Offset entry count
+.Lloclists_table_base0:
+	.long	.Ldebug_loc0-.Lloclists_table_base0
+.Ldebug_loc0:
+	.byte	4   # DW_LLE_offset_pair
+	.uleb128 .Ltmp0-.Lfunc_begin0   #   starting offset
+	.uleb128 .Ltmp1-.Lfunc_begin0   #   ending offset
+	.byte	16  # Loc expr size
+	.byte	112 # DW_OP_breg0
+	.byte	0   # 0
+	.byte	16  # DW_OP_constu
+	.byte	255 # 4294967295
+	.byte	255 # 
+	.byte	255 # 
+	.byte	255 # 
+	.byte	15  # 
+	.byte	26  # DW_OP_and
+	.byte	17  # DW_OP_consts
+	.byte	3   # 3
+	.byte	28  # DW_OP_minus
+	.byte	17  # DW_OP_consts
+	.byte	127 # -1
+	.byte	27  # DW_OP_div
+	.byte	159 # DW_OP_stack_value
+	.byte	4   # DW_LLE_offset_pair
+	.uleb128 .Ltmp1-.Lfunc_begin0   #   starting offset
+	.uleb128 .Ltmp2-.Lfunc_begin0   #   ending offset
+	.byte	19  # Loc expr size
+	.byte	112 # DW_OP_breg0
+	.byte	0   # 0
+	.byte	16  # DW_OP_constu
+	.byte	255 # 4294967295
+	.byte	255 # 
+	.byte	255 

[Lldb-commits] [lldb] e15d6b5 - [lldb][DWARFExpression] Fix DW_OP_div to use signed division

2023-05-02 Thread Michael Buch via lldb-commits

Author: LU Hongyi
Date: 2023-05-02T07:38:52-04:00
New Revision: e15d6b520e1e85d2cdf9ffc66f0c4698390eaa3d

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

LOG: [lldb][DWARFExpression] Fix DW_OP_div to use signed division

This patch resolves an issue where a value
is incorrectly displayed if it is represented
by DW_OP_div.

This issue is caused by lldb evaluating
operands of DW_OP_div as unsigned
and performed unintended unsigned
division.

This issue is resolved by creating two
temporary signed scalar and performing
signed division.

(Addresses GH#61727)

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

Added: 
lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s

Modified: 
lldb/source/Expression/DWARFExpression.cpp

Removed: 




diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index f2ca6534c2fc1..9232282d81353 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -1436,8 +1436,12 @@ bool DWARFExpression::Evaluate(
   return false;
 } else {
   stack.pop_back();
-  stack.back() =
-  stack.back().ResolveValue(exe_ctx) / tmp.ResolveValue(exe_ctx);
+  Scalar divisor, dividend;
+  divisor = tmp.ResolveValue(exe_ctx);
+  dividend = stack.back().ResolveValue(exe_ctx);
+  divisor.MakeSigned();
+  dividend.MakeSigned();
+  stack.back() = dividend / divisor;
   if (!stack.back().ResolveValue(exe_ctx).IsValid()) {
 if (error_ptr)
   error_ptr->SetErrorString("Divide failed.");

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s 
b/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s
new file mode 100644
index 0..f6fbcdadfdc8d
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_div-with-signed.s
@@ -0,0 +1,468 @@
+  # Test handling of values represented via DW_OP_div
+
+  # RUN: %clang --target=x86_64-pc-linux -o %t %s
+  # RUN: %lldb %t -o "b f" -o "r" -o "c" -o "c" -o "expression -T -- i" \
+  # RUN: -o "exit" | FileCheck %s
+
+  # Failing case was:
+  # (uint32_t) $0 = 0
+  # CHECK: (uint32_t) $0 = 2
+   
+  # This case is generated from the following code:
+  # #include "stdint.h"
+  # static volatile uint64_t g = 0;
+  #  static const int32_t f()
+  #  {
+  #uint32_t i;
+  #for (i = 0; (i != 10); i++)
+  #  ++g;
+  #return 0;
+  #  
+  #  }
+  #
+  #  int main()
+  #  {
+  #f();
+  #return 0;
+  #
+  #  }
+
+  .text
+   .file   "signed_dw_op_div.c"
+   .file   1 "/usr/local/include/bits" "types.h" md5 
0x96c0983c9cdaf387938a8268d00aa594
+   .file   2 "/usr/local/include/bits" "stdint-uintn.h" md5 
0xbedfab747425222bb150968c14e40abd
+   .globl  main# -- Begin function main
+   .p2align4, 0x90
+   .type   main,@function
+main:   # @main
+.Lfunc_begin0:
+   .loc0 13 0  # signed_dw_op_div.c:13:0
+   .cfi_startproc
+# %bb.0:
+   movl$3, %eax
+   #DEBUG_VALUE: f:i <- 0
+   .p2align4, 0x90
+.LBB0_1:# =>This Inner Loop Header: Depth=1
+.Ltmp0:
+   #DEBUG_VALUE: f:i <- [DW_OP_consts 3, DW_OP_minus, DW_OP_consts 
18446744073709551615, DW_OP_div, DW_OP_stack_value] $eax
+   .loc0 8 7 prologue_end  # signed_dw_op_div.c:8:7
+   incqg(%rip)
+.Ltmp1:
+   #DEBUG_VALUE: f:i <- [DW_OP_consts 3, DW_OP_minus, DW_OP_consts 
18446744073709551615, DW_OP_div, DW_OP_consts 1, DW_OP_plus, DW_OP_stack_value] 
$eax
+   .loc0 7 20  # signed_dw_op_div.c:7:20
+   decl%eax
+.Ltmp2:
+   .loc0 7 5 is_stmt 0 # signed_dw_op_div.c:7:5
+   jne .LBB0_1
+.Ltmp3:
+# %bb.2:
+   .loc0 15 5 is_stmt 1# signed_dw_op_div.c:15:5
+   xorl%eax, %eax
+   retq
+.Ltmp4:
+.Lfunc_end0:
+   .size   main, .Lfunc_end0-main
+   .cfi_endproc
+   .file   3 "/usr/local/include/bits" "stdint-intn.h" md5 
0x90039fb90b44dcbf118222513050fe57
+# -- End function
+   .type   g,@object   # @g
+   .local  g
+   .comm   g,8,8
+   .section.debug_loclists,"",@progbits
+   .long   .Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length
+.Ldebug_list_header_start0:
+   .short  5   # Version
+   .byte   8   # Address size
+   .byte   0   # Segment selector size
+   

[Lldb-commits] [lldb] 52882de - [lldb][test] TestCPP20Standard.py: make it a libc++ test

2023-05-02 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2023-05-02T07:38:53-04:00
New Revision: 52882de0e641487329c9e093a90ea3dad01842c8

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

LOG: [lldb][test] TestCPP20Standard.py: make it a libc++ test

We just want to test whether the language switch works.
This is easier to control for libc++, since for bots building
the tests against libstdc++ we might not have the necessary
`` header available currently.

Added: 


Modified: 
lldb/test/API/lang/cpp/standards/cpp20/Makefile
lldb/test/API/lang/cpp/standards/cpp20/TestCPP20Standard.py

Removed: 




diff  --git a/lldb/test/API/lang/cpp/standards/cpp20/Makefile 
b/lldb/test/API/lang/cpp/standards/cpp20/Makefile
index 4f79c0a900c3a..ec2f8d171f49a 100644
--- a/lldb/test/API/lang/cpp/standards/cpp20/Makefile
+++ b/lldb/test/API/lang/cpp/standards/cpp20/Makefile
@@ -1,3 +1,4 @@
+USE_LIBCPP := 1
 CXX_SOURCES := main.cpp
 CXXFLAGS_EXTRAS := -std=c++20
 

diff  --git a/lldb/test/API/lang/cpp/standards/cpp20/TestCPP20Standard.py 
b/lldb/test/API/lang/cpp/standards/cpp20/TestCPP20Standard.py
index 017e621fd06e5..4c305f32b08bb 100644
--- a/lldb/test/API/lang/cpp/standards/cpp20/TestCPP20Standard.py
+++ b/lldb/test/API/lang/cpp/standards/cpp20/TestCPP20Standard.py
@@ -4,6 +4,7 @@
 from lldbsuite.test import lldbutil
 
 class TestCPP20Standard(TestBase):
+@add_test_categories(["libc++"])
 @skipIf(compiler="clang", compiler_version=['<', '11.0'])
 def test_cpp20(self):
 """



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


[Lldb-commits] [PATCH] D149641: [docs] Hide collaboration and include graphs in doxygen docs

2023-05-02 Thread Timm Bäder via Phabricator via lldb-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, shafik.
Herald added a reviewer: bollu.
Herald added subscribers: bviyer, Moerafaat, zero9178, bzcheeseman, ayermolo, 
sdasgup3, wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, 
jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, 
antiagainst, shauheen, rriddle, mehdi_amini, thopre.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added projects: Flang, All.
tbaeder requested review of this revision.
Herald added subscribers: cfe-commits, llvm-commits, openmp-commits, 
lldb-commits, yota9, stephenneuendorffer, nicolasvasilache, jdoerfert.
Herald added projects: clang, LLDB, OpenMP, MLIR, LLVM, clang-tools-extra.

I think they are pretty useless and make the docs harder to read.

Set the `COLLABORATION_GRAPH`, `INCLUDE_GRAPH` and `INCLUDED_BY_GRAPH` 
variables all to `NO`.

The changes are similar to the ones done in 
https://github.com/googleapis/google-cloud-cpp/pull/397, but I did not remove 
the class graph, I think that one is actually helpful.

Not sure who to add as reviewers (none of the codeowners files seem to mention 
a owner for docs...), so adding some frontend people.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149641

Files:
  bolt/docs/doxygen.cfg.in
  clang-tools-extra/docs/doxygen.cfg.in
  clang/docs/doxygen.cfg.in
  flang/docs/doxygen.cfg.in
  lldb/docs/doxygen.cfg.in
  llvm/docs/doxygen.cfg.in
  mlir/docs/doxygen.cfg.in
  openmp/docs/doxygen.cfg.in
  openmp/runtime/doc/doxygen/config
  polly/docs/doxygen.cfg.in

Index: polly/docs/doxygen.cfg.in
===
--- polly/docs/doxygen.cfg.in
+++ polly/docs/doxygen.cfg.in
@@ -2103,7 +2103,7 @@
 # The default value is: YES.
 # This tag requires that the tag HAVE_DOT is set to YES.
 
-COLLABORATION_GRAPH= YES
+COLLABORATION_GRAPH= NO
 
 # If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
 # groups, showing the direct groups dependencies.
@@ -2148,7 +2148,7 @@
 # The default value is: YES.
 # This tag requires that the tag HAVE_DOT is set to YES.
 
-INCLUDE_GRAPH  = YES
+INCLUDE_GRAPH  = NO
 
 # If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
 # set to YES then doxygen will generate a graph for each documented file showing
@@ -2157,7 +2157,7 @@
 # The default value is: YES.
 # This tag requires that the tag HAVE_DOT is set to YES.
 
-INCLUDED_BY_GRAPH  = YES
+INCLUDED_BY_GRAPH  = NO
 
 # If the CALL_GRAPH tag is set to YES then doxygen will generate a call
 # dependency graph for every global function or class method.
Index: openmp/runtime/doc/doxygen/config
===
--- openmp/runtime/doc/doxygen/config
+++ openmp/runtime/doc/doxygen/config
@@ -1671,7 +1671,7 @@
 # indirect implementation dependencies (inheritance, containment, and
 # class references variables) of the class with other documented classes.
 
-COLLABORATION_GRAPH= YES
+COLLABORATION_GRAPH= NO
 
 # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
 # will generate a graph for groups, showing the direct groups dependencies
@@ -1703,14 +1703,14 @@
 # file showing the direct and indirect include dependencies of the file with
 # other documented files.
 
-INCLUDE_GRAPH  = YES
+INCLUDE_GRAPH  = NO
 
 # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
 # HAVE_DOT tags are set to YES then doxygen will generate a graph for each
 # documented header file showing the documented files that directly or
 # indirectly include this file.
 
-INCLUDED_BY_GRAPH  = YES
+INCLUDED_BY_GRAPH  = NO
 
 # If the CALL_GRAPH and HAVE_DOT options are set to YES then
 # doxygen will generate a call dependency graph for every global function
Index: openmp/docs/doxygen.cfg.in
===
--- openmp/docs/doxygen.cfg.in
+++ openmp/docs/doxygen.cfg.in
@@ -2091,7 +2091,7 @@
 # The default value is: YES.
 # This tag requires that the tag HAVE_DOT is set to YES.
 
-COLLABORATION_GRAPH= YES
+COLLABORATION_GRAPH= NO
 
 # If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
 # groups, showing the direct groups dependencies.
@@ -2136,7 +2136,7 @@
 # The default value is: YES.
 # This tag requires that the tag HAVE_DOT is set to YES.
 
-INCLUDE_GRAPH  = YES
+INCLUDE_GRAPH  = NO
 
 # If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
 # set to YES then doxygen will generate a graph for each documented file showing
@@ -2145,7 +2145,7 @@
 # The default value is: YES.
 # This tag requires that the tag HAVE_DOT is set to YES.
 
-INCLUDED_BY_GRAPH  = YES
+INCLUDED_BY_GRAPH  = NO
 
 # If the CALL_GRAPH tag is set to YES then doxygen 

[Lldb-commits] [lldb] ddd9358 - [lldb] Remove unused will_modify argument (NFC)

2023-05-02 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-05-02T00:20:34-07:00
New Revision: ddd9358bcaef5a348dd387a6a27539f7f49646d1

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

LOG: [lldb] Remove unused will_modify argument (NFC)

Various OptionValue related classes are passing around will_modify but
the value is never used. This patch simplifies the interfaces by
removing the redundant argument.

Added: 


Modified: 
lldb/include/lldb/Core/UserSettingsController.h
lldb/include/lldb/Interpreter/OptionValue.h
lldb/include/lldb/Interpreter/OptionValueArray.h
lldb/include/lldb/Interpreter/OptionValueDictionary.h
lldb/include/lldb/Interpreter/OptionValueProperties.h
lldb/source/API/SBDebugger.cpp
lldb/source/Commands/CommandObjectSettings.cpp
lldb/source/Core/Disassembler.cpp
lldb/source/Core/ModuleList.cpp
lldb/source/Core/UserSettingsController.cpp
lldb/source/Interpreter/OptionValueArray.cpp
lldb/source/Interpreter/OptionValueDictionary.cpp
lldb/source/Interpreter/OptionValueProperties.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
lldb/source/Target/Platform.cpp
lldb/source/Target/Process.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/Thread.cpp
lldb/unittests/Interpreter/TestOptionValue.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/UserSettingsController.h 
b/lldb/include/lldb/Core/UserSettingsController.h
index 8afef06359738..19b080d125a35 100644
--- a/lldb/include/lldb/Core/UserSettingsController.h
+++ b/lldb/include/lldb/Core/UserSettingsController.h
@@ -47,7 +47,6 @@ class Properties {
 
   virtual lldb::OptionValueSP GetPropertyValue(const ExecutionContext *exe_ctx,
llvm::StringRef property_path,
-   bool will_modify,
Status ) const;
 
   virtual Status SetPropertyValue(const ExecutionContext *exe_ctx,

diff  --git a/lldb/include/lldb/Interpreter/OptionValue.h 
b/lldb/include/lldb/Interpreter/OptionValue.h
index 562eab64b5183..7d6ab6c3f6f5e 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -108,7 +108,6 @@ class OptionValue {
   // Subclasses can override these functions
   virtual lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
   llvm::StringRef name,
-  bool will_modify,
   Status ) const {
 error.SetErrorStringWithFormat("'%s' is not a value subvalue", 
name.str().c_str());
 return lldb::OptionValueSP();

diff  --git a/lldb/include/lldb/Interpreter/OptionValueArray.h 
b/lldb/include/lldb/Interpreter/OptionValueArray.h
index 147e15ef4335d..0e1bae103d41f 100644
--- a/lldb/include/lldb/Interpreter/OptionValueArray.h
+++ b/lldb/include/lldb/Interpreter/OptionValueArray.h
@@ -46,7 +46,7 @@ class OptionValueArray : public Cloneable {
   bool IsAggregateValue() const override { return true; }
 
   lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
-  llvm::StringRef name, bool will_modify,
+  llvm::StringRef name,
   Status ) const override;
 
   // Subclass specific functions

diff  --git a/lldb/include/lldb/Interpreter/OptionValueDictionary.h 
b/lldb/include/lldb/Interpreter/OptionValueDictionary.h
index 4c250468b3cda..18ef448237157 100644
--- a/lldb/include/lldb/Interpreter/OptionValueDictionary.h
+++ b/lldb/include/lldb/Interpreter/OptionValueDictionary.h
@@ -61,7 +61,7 @@ class OptionValueDictionary
   lldb::OptionValueSP GetValueForKey(llvm::StringRef key) const;
 
   lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
-  llvm::StringRef name, bool will_modify,
+  llvm::StringRef name,
   Status ) const override;
 
   Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op,

diff  --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h 
b/lldb/include/lldb/Interpreter/OptionValueProperties.h
index 691a42a7aeec3..2666585802d63 100644
--- a/lldb/include/lldb/Interpreter/OptionValueProperties.h
+++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h
@@ -79,30 +79,28 @@ class OptionValueProperties
   // not be a path to a property path that refers to a property within a
   // property
   virtual const Property *GetProperty(const ExecutionContext *exe_ctx,
-