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

2024-07-01 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

> LLVM Buildbot has detected a new failure on builder `lldb-aarch64-windows` 
> running on `linaro-armv8-windows-msvc-05` while building `lldb` at step 6 
> "test".
> 
> Full details are available at: 
> https://lab.llvm.org/buildbot/#/builders/141/builds/425
> 
> Here is the relevant piece of the build log for the reference:
> 
> ```
> Step 6 (test) failure: build (failure)
> ...
> 31.128 [1/2/288] Linking CXX executable 
> tools\lldb\unittests\Thread\ThreadTests.exe
> 31.168 [1/1/289] Linking CXX executable 
> tools\lldb\unittests\ValueObject\LLDBValueObjectTests.exe
> llvm-lit.py: 
> C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\utils\lit\lit\llvm\config.py:57:
>  note: using lit tools: C:\Users\tcwg\scoop\apps\git\2.39.0.windows.2\usr\bin
> llvm-lit.py: 
> C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\utils\lit\lit\llvm\config.py:508:
>  note: using clang: 
> c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe
> llvm-lit.py: 
> C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\utils\lit\lit\llvm\config.py:508:
>  note: using ld.lld: 
> c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\ld.lld.exe
> llvm-lit.py: 
> C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\utils\lit\lit\llvm\config.py:508:
>  note: using lld-link: 
> c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\lld-link.exe
> llvm-lit.py: 
> C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\utils\lit\lit\llvm\config.py:508:
>  note: using ld64.lld: 
> c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\ld64.lld.exe
> llvm-lit.py: 
> C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\utils\lit\lit\llvm\config.py:508:
>  note: using wasm-ld: 
> c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\wasm-ld.exe
> 31.169 [0/1/289] Runnin-- Testing: 1983 tests, 2 workers --
> Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 
> FAIL: lldb-shell :: SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp (1616 of 
> 1983)
>  TEST 'lldb-shell :: 
> SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp' FAILED 
> Exit Code: 1
> 
> Command Output (stdout):
> --
> # RUN: at line 19
> c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe 
> --target=specify-a-target-or-use-a-_host-substitution -target x86_64-pc-linux 
> -gdwarf-5 -gsplit-dwarf-fdebug-types-section -gpubnames -c 
> C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\Shell\SymbolFile\DWARF\x86\dwp-foreign-type-units.cpp
>  -o 
> C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\test\Shell\SymbolFile\DWARF\x86\Output\dwp-foreign-type-units.cpp.tmp.main.o
> # executed command: 
> 'c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe' 
> --target=specify-a-target-or-use-a-_host-substitution -target x86_64-pc-linux 
> -gdwarf-5 -gsplit-dwarf -fdebug-types-section -gpubnames -c 
> 'C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\Shell\SymbolFile\DWARF\x86\dwp-foreign-type-units.cpp'
>  -o 
> 'C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\test\Shell\SymbolFile\DWARF\x86\Output\dwp-foreign-type-units.cpp.tmp.main.o'
> # note: command had no output on stdout or stderr
> # RUN: at line 21
> c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe 
> --target=specify-a-target-or-use-a-_host-substitution -target x86_64-pc-linux 
> -gdwarf-5 -gsplit-dwarf -DVARIANT-fdebug-types-section -gpubnames -c 
> C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\Shell\SymbolFile\DWARF\x86\dwp-foreign-type-units.cpp
>  -o 
> C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\test\Shell\SymbolFile\DWARF\x86\Output\dwp-foreign-type-units.cpp.tmp.foo.o
> # executed command: 
> 'c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe' 
> --target=specify-a-target-or-use-a-_host-substitution -target x86_64-pc-linux 
> -gdwarf-5 -gsplit-dwarf -DVARIANT -fdebug-types-section -gpubnames -c 
> 'C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\Shell\SymbolFile\DWARF\x86\dwp-foreign-type-units.cpp'
>  -o 
> 'C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\test\Shell\SymbolFile\DWARF\x86\Output\dwp-foreign-type-units.cpp.tmp.foo.o'
> # note: command had no output on stdout or stderr
> # RUN: at line 23
> c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\ld.lld.exe 
> C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\test\Shell\SymbolFile\DWARF\x86\Output\dwp-foreign-type-units.cpp.tmp.main.o
>  
> C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\test\Shell\SymbolFile\DWARF\x86\Output\dwp-foreign-type-units.cpp.tmp.foo.o
>  -o 
> C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\test\Shell\SymbolFile\DWARF\x86\Output\dwp-foreign-type-units.cpp.tmp
> # executed command: 
> 

[Lldb-commits] [lldb] [lldb/Commands] Add `scripting template list` command with auto discovery (PR #97273)

2024-07-01 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben updated 
https://github.com/llvm/llvm-project/pull/97273

>From 828d8e8c35eb5a3d0886c5d331a8a4aa466c2324 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Mon, 1 Jul 2024 22:07:49 -0700
Subject: [PATCH] [lldb/Commands] Add `scripting template list` command with
 auto discovery

This patch introduces a new `template` multiword sub-command to the
`scripting` top-level command. As the name suggests, this sub-command
operates on scripting templates, and currently has the ability to
automatically discover the various scripting extensions that lldb
supports.

Signed-off-by: Med Ismail Bennani 
---
 lldb/include/lldb/Core/PluginManager.h|  25 +++
 .../Interfaces/ScriptedInterface.h|   7 +
 lldb/include/lldb/lldb-private-interfaces.h   |   4 +
 .../Commands/CommandObjectScripting.cpp   | 171 ++
 lldb/source/Commands/Options.td   |   6 +
 lldb/source/Core/PluginManager.cpp|  83 +
 lldb/source/Plugins/CMakeLists.txt|   3 +
 .../Python/Interfaces/CMakeLists.txt  |   5 +
 .../ScriptedProcessPythonInterface.cpp|  23 +++
 .../ScriptedProcessPythonInterface.h  |  13 +-
 .../ScriptedThreadPlanPythonInterface.cpp |  18 ++
 .../ScriptedThreadPlanPythonInterface.h   |  13 +-
 12 files changed, 369 insertions(+), 2 deletions(-)

diff --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index f2296e2920238..df20109e791a5 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -487,6 +487,31 @@ class PluginManager {
 
   static LanguageSet GetAllTypeSystemSupportedLanguagesForExpressions();
 
+  // Scripted Interface
+  static bool
+  RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
+ ScriptedInterfaceCreateInstance create_callback,
+ lldb::ScriptLanguage language,
+ std::vector command_interpreter_usages,
+ std::vector api_usages);
+
+  static bool UnregisterPlugin(ScriptedInterfaceCreateInstance 
create_callback);
+
+  static ScriptedInterfaceCreateInstance
+  GetScriptedInterfaceCreateCallbackAtIndex(uint32_t idx);
+
+  static llvm::StringRef GetScriptedInterfaceNameAtIndex(uint32_t idx);
+
+  static llvm::StringRef GetScriptedInterfaceDescriptionAtIndex(uint32_t idx);
+
+  static lldb::ScriptLanguage GetScriptedInterfaceLanguageAtIndex(uint32_t 
idx);
+
+  static std::vector
+  GetScriptedInterfaceCommandInterpreterUsagesAtIndex(uint32_t idx);
+
+  static std::vector
+  GetScriptedInterfaceAPIUsagesAtIndex(uint32_t idx);
+
   // REPL
   static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  REPLCreateInstance create_callback,
diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
index 69504dbcda5dc..23658b90bb90a 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
@@ -68,6 +68,13 @@ class ScriptedInterface {
 return true;
   }
 
+  static bool
+  CreateInstance(lldb::ScriptLanguage language,
+ std::vector command_interpreter_usages,
+ std::vector api_usages) {
+return false;
+  }
+
 protected:
   StructuredData::GenericSP m_object_instance_sp;
 };
diff --git a/lldb/include/lldb/lldb-private-interfaces.h 
b/lldb/include/lldb/lldb-private-interfaces.h
index cdd9b51d9329c..2404e28158690 100644
--- a/lldb/include/lldb/lldb-private-interfaces.h
+++ b/lldb/include/lldb/lldb-private-interfaces.h
@@ -124,6 +124,10 @@ typedef lldb::REPLSP (*REPLCreateInstance)(Status ,
lldb::LanguageType language,
Debugger *debugger, Target *target,
const char *repl_options);
+typedef bool (*ScriptedInterfaceCreateInstance)(
+lldb::ScriptLanguage language,
+std::vector command_interpreter_usages,
+std::vector api_usages);
 typedef int (*ComparisonFunction)(const void *, const void *);
 typedef void (*DebuggerInitializeCallback)(Debugger );
 /// Trace
diff --git a/lldb/source/Commands/CommandObjectScripting.cpp 
b/lldb/source/Commands/CommandObjectScripting.cpp
index fee0565a7c48a..ad209f1e20c13 100644
--- a/lldb/source/Commands/CommandObjectScripting.cpp
+++ b/lldb/source/Commands/CommandObjectScripting.cpp
@@ -8,6 +8,7 @@
 
 #include "CommandObjectScripting.h"
 #include "lldb/Core/Debugger.h"
+#include "lldb/Core/PluginManager.h"
 #include "lldb/DataFormatters/DataVisualization.h"
 #include "lldb/Host/Config.h"
 #include "lldb/Host/OptionParser.h"
@@ -21,6 +22,8 @@
 using namespace lldb;
 using namespace lldb_private;
 
+#pragma mark CommandObjectScriptingRun
+
 #define LLDB_OPTIONS_scripting_run
 #include "CommandOptions.inc"
 
@@ 

[Lldb-commits] [clang] [lldb] [clang][AST] fix ast-print of extern with >=2 declarators, fixed (PR #93913)

2024-07-01 Thread Alan Zhao via lldb-commits

alanzhao1 wrote:

Chrome's Windows debug builds also saw crashes due to this commit: 
https://crbug.com/350541784

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


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

2024-07-01 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-aarch64-windows` 
running on `linaro-armv8-windows-msvc-05` while building `lldb` at step 6 
"test".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/141/builds/425

Here is the relevant piece of the build log for the reference:
```
Step 6 (test) failure: build (failure)
...
31.128 [1/2/288] Linking CXX executable 
tools\lldb\unittests\Thread\ThreadTests.exe
31.168 [1/1/289] Linking CXX executable 
tools\lldb\unittests\ValueObject\LLDBValueObjectTests.exe
llvm-lit.py: 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\utils\lit\lit\llvm\config.py:57:
 note: using lit tools: C:\Users\tcwg\scoop\apps\git\2.39.0.windows.2\usr\bin
llvm-lit.py: 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\utils\lit\lit\llvm\config.py:508:
 note: using clang: 
c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe
llvm-lit.py: 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\utils\lit\lit\llvm\config.py:508:
 note: using ld.lld: 
c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\ld.lld.exe
llvm-lit.py: 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\utils\lit\lit\llvm\config.py:508:
 note: using lld-link: 
c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\lld-link.exe
llvm-lit.py: 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\utils\lit\lit\llvm\config.py:508:
 note: using ld64.lld: 
c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\ld64.lld.exe
llvm-lit.py: 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\utils\lit\lit\llvm\config.py:508:
 note: using wasm-ld: 
c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\wasm-ld.exe
31.169 [0/1/289] Runnin-- Testing: 1983 tests, 2 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 
FAIL: lldb-shell :: SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp (1616 of 
1983)
 TEST 'lldb-shell :: 
SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp' FAILED 
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 19
c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe 
--target=specify-a-target-or-use-a-_host-substitution -target x86_64-pc-linux 
-gdwarf-5 -gsplit-dwarf-fdebug-types-section -gpubnames -c 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\Shell\SymbolFile\DWARF\x86\dwp-foreign-type-units.cpp
 -o 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\test\Shell\SymbolFile\DWARF\x86\Output\dwp-foreign-type-units.cpp.tmp.main.o
# executed command: 
'c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe' 
--target=specify-a-target-or-use-a-_host-substitution -target x86_64-pc-linux 
-gdwarf-5 -gsplit-dwarf -fdebug-types-section -gpubnames -c 
'C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\Shell\SymbolFile\DWARF\x86\dwp-foreign-type-units.cpp'
 -o 
'C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\test\Shell\SymbolFile\DWARF\x86\Output\dwp-foreign-type-units.cpp.tmp.main.o'
# note: command had no output on stdout or stderr
# RUN: at line 21
c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe 
--target=specify-a-target-or-use-a-_host-substitution -target x86_64-pc-linux 
-gdwarf-5 -gsplit-dwarf -DVARIANT-fdebug-types-section -gpubnames -c 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\Shell\SymbolFile\DWARF\x86\dwp-foreign-type-units.cpp
 -o 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\test\Shell\SymbolFile\DWARF\x86\Output\dwp-foreign-type-units.cpp.tmp.foo.o
# executed command: 
'c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe' 
--target=specify-a-target-or-use-a-_host-substitution -target x86_64-pc-linux 
-gdwarf-5 -gsplit-dwarf -DVARIANT -fdebug-types-section -gpubnames -c 
'C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\Shell\SymbolFile\DWARF\x86\dwp-foreign-type-units.cpp'
 -o 
'C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\test\Shell\SymbolFile\DWARF\x86\Output\dwp-foreign-type-units.cpp.tmp.foo.o'
# note: command had no output on stdout or stderr
# RUN: at line 23
c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\ld.lld.exe 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\test\Shell\SymbolFile\DWARF\x86\Output\dwp-foreign-type-units.cpp.tmp.main.o
 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\test\Shell\SymbolFile\DWARF\x86\Output\dwp-foreign-type-units.cpp.tmp.foo.o
 -o 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\test\Shell\SymbolFile\DWARF\x86\Output\dwp-foreign-type-units.cpp.tmp
# executed command: 
'c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\ld.lld.exe' 
'C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\test\Shell\SymbolFile\DWARF\x86\Output\dwp-foreign-type-units.cpp.tmp.main.o'
 

[Lldb-commits] [lldb] [lldb] [ObjectFileMachO] BSS segments are loadable segments (PR #96983)

2024-07-01 Thread Jason Molenda via lldb-commits

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


[Lldb-commits] [lldb] 91c0ef6 - [lldb] [ObjectFileMachO] BSS segments are loadable segments (#96983)

2024-07-01 Thread via lldb-commits

Author: Jason Molenda
Date: 2024-07-01T21:56:33-07:00
New Revision: 91c0ef6f67821eb7298cb05988045e92354ac77b

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

LOG: [lldb] [ObjectFileMachO] BSS segments are loadable segments (#96983)

ObjectFileMachO::SetLoadAddress sets the address of each segment in a
binary in a Target, but it ignores segments that are not loaded in the
virtual address space. It was marking segments that were purely BSS --
having no content in the file, but in zero-initialized memory when
running in the virtual address space -- as not-loadable, unless they
were named "DATA". This works pretty well for typical userland binaries,
but in less Darwin environments, there may be BSS segments with other
names, that ARE loadable.

I looked at the origin of SectionIsLoadable's check for this, and it was
a cleanup by Greg in 2018 where we had three different implementations
of the idea in ObjectFileMachO and one of them skipped zero-file-size
segments (BSS), which made it into the centralized SectionIsLoadable
method.

Also add some logging to the DynamicLoader log channel when loading a
binary - it's the first place I look when debugging segment address
setting bugs, and it wasn't emitting anything.

rdar://129870649

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 2979bf69bf762..0dcb1bed23548 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -6159,10 +6159,6 @@ Section *ObjectFileMachO::GetMachHeaderSection() {
 bool ObjectFileMachO::SectionIsLoadable(const Section *section) {
   if (!section)
 return false;
-  const bool is_dsym = (m_header.filetype == MH_DSYM);
-  if (section->GetFileSize() == 0 && !is_dsym &&
-  section->GetName() != GetSegmentNameDATA())
-return false;
   if (section->IsThreadSpecific())
 return false;
   if (GetModule().get() != section->GetModule().get())
@@ -6202,6 +6198,7 @@ lldb::addr_t 
ObjectFileMachO::CalculateSectionLoadAddressForMemoryImage(
 
 bool ObjectFileMachO::SetLoadAddress(Target , lldb::addr_t value,
  bool value_is_offset) {
+  Log *log(GetLog(LLDBLog::DynamicLoader));
   ModuleSP module_sp = GetModule();
   if (!module_sp)
 return false;
@@ -6217,17 +6214,33 @@ bool ObjectFileMachO::SetLoadAddress(Target , 
lldb::addr_t value,
   // malformed.
   const bool warn_multiple = true;
 
+  if (log) {
+StreamString logmsg;
+logmsg << "ObjectFileMachO::SetLoadAddress ";
+if (GetFileSpec())
+  logmsg << "path='" << GetFileSpec().GetPath() << "' ";
+if (GetUUID()) {
+  logmsg << "uuid=" << GetUUID().GetAsString();
+}
+LLDB_LOGF(log, "%s", logmsg.GetData());
+  }
   if (value_is_offset) {
 // "value" is an offset to apply to each top level segment
 for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
   // Iterate through the object file sections to find all of the
   // sections that size on disk (to avoid __PAGEZERO) and load them
   SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
-  if (SectionIsLoadable(section_sp.get()))
+  if (SectionIsLoadable(section_sp.get())) {
+LLDB_LOGF(log,
+  "ObjectFileMachO::SetLoadAddress segment '%s' load addr is "
+  "0x%" PRIx64,
+  section_sp->GetName().AsCString(),
+  section_sp->GetFileAddress() + value);
 if (target.GetSectionLoadList().SetSectionLoadAddress(
 section_sp, section_sp->GetFileAddress() + value,
 warn_multiple))
   ++num_loaded_sections;
+  }
 }
   } else {
 // "value" is the new base address of the mach_header, adjust each
@@ -6242,6 +6255,10 @@ bool ObjectFileMachO::SetLoadAddress(Target , 
lldb::addr_t value,
 CalculateSectionLoadAddressForMemoryImage(
 value, mach_header_section, section_sp.get());
 if (section_load_addr != LLDB_INVALID_ADDRESS) {
+  LLDB_LOGF(log,
+"ObjectFileMachO::SetLoadAddress segment '%s' load addr is 
"
+"0x%" PRIx64,
+section_sp->GetName().AsCString(), section_load_addr);
   if (target.GetSectionLoadList().SetSectionLoadAddress(
   section_sp, section_load_addr, warn_multiple))
 ++num_loaded_sections;



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


[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-01 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/96260

>From 9b541e6a035635e26c6a24eca022de8552fa4c17 Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Thu, 20 Jun 2024 17:53:17 -0700
Subject: [PATCH 1/5] [lldb] Change lldb's breakpoint handling behavior

lldb today has two rules:  When a thread stops at a BreakpointSite,
we set the thread's StopReason to be "breakpoint hit" (regardless
if we've actually hit the breakpoint, or if we've merely stopped
*at* the breakpoint instruction/point and haven't tripped it yet).
And second, when resuming a process, any thread sitting at a
BreakpointSite is silently stepped over the BreakpointSite -- because
we've already flagged the breakpoint hit when we stopped there
originally.

In this patch, I change lldb to only set a thread's stop reason to
breakpoint-hit when we've actually executed the instruction/triggered
the breakpoint.  When we resume, we only silently step past a
BreakpointSite that we've registered as hit.  We preserve this state
across inferior function calls that the user may do while stopped,
etc.

Also, when a user adds a new breakpoint at $pc while stopped, or
changes $pc to be the address of a BreakpointSite, we will silently
step past that breakpoint when the process resumes.  This is purely
a UX call, I don't think there's any person who wants to set a
breakpoint at $pc and then hit it immediately on resuming.

One non-intuitive UX from this change, but I'm convinced it is
necessary:  If you're stopped at a BreakpointSite that has not yet
executed, you `stepi`, you will hit the breakpoint and the pc will
not yet advance.  This thread has not completed its stepi, and the
thread plan is still on the stack.  If you then `continue` the
thread, lldb will now stop and say, "instruction step completed",
one instruction past the BreakpointSite.  You can continue a second
time to resume execution.  I discussed this with Jim, and trying
to paper over this behavior will lead to more complicated scenarios
behaving non-intuitively.  And mostly it's the testsuite that was
trying to instruction step past a breakpoint and getting thrown off
-- and I changed those tests to expect the new behavior.

The bugs driving this change are all from lldb dropping the real
stop reason for a thread and setting it to breakpoint-hit when that
was not the case.  Jim hit one where we have an aarch64 watchpoint
that triggers one instruction before a BreakpointSite.  On this
arch we are notified of the watchpoint hit after the instruction
has been unrolled -- we disable the watchpoint, instruction step,
re-enable the watchpoint and collect the new value.  But now we're
on a BreakpointSite so the watchpoint-hit stop reason is lost.

Another was reported by ZequanWu in
https://discourse.llvm.org/t/lldb-unable-to-break-at-start/78282
we attach to/launch a process with the pc at a BreakpointSite and
misbehave.  Caroline Tice mentioned it is also a problem they've
had with putting a breakpoint on _dl_debug_state.

The change to each Process plugin that does execution control
is that

1. If we've stopped at a BreakpointSite (whether we hit it or not),
we call Thread::SetThreadStoppedAtBreakpointSite(pc) to record the
state at the point when the thread stopped.  (so we can detect
newly-added breakpoints, or when the pc is changed to an instruction
that is a BreakpointSite)

2. When we have actually hit a breakpoint, and it is enabled for
this thread, we call Thread::SetThreadHitBreakpointAtAddr(pc) so
we know that it should be silently stepped past when we resume
execution.

When resuming, we silently step over a breakpoint if we've hit it,
or if it is newly added (or the pc was changed to an existing
BreakpointSite).

The biggest set of changes is to StopInfoMachException where we
translate a Mach Exception into a stop reason.  The Mach exception
codes differ in a few places depending on the target (unambiguously),
and I didn't want to duplicate the new code for each target so I've
tested what mach exceptions we get for each action on each target,
and reorganized StopInfoMachException::CreateStopReasonWithMachException
to document these possible values, and handle them without specializing
based on the target arch.

rdar://123942164
---
 lldb/include/lldb/Target/Thread.h |  29 ++
 .../Process/Utility/StopInfoMachException.cpp | 296 +++---
 .../Process/Windows/Common/ProcessWindows.cpp |  16 +-
 .../Process/gdb-remote/ProcessGDBRemote.cpp   | 118 +++
 .../Process/scripted/ScriptedThread.cpp   |   9 +
 lldb/source/Target/Thread.cpp |  17 +-
 .../TestConsecutiveBreakpoints.py |  26 +-
 .../TestStepOverBreakpoint.py |   6 +-
 8 files changed, 235 insertions(+), 282 deletions(-)

diff --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index c17bddf4d98b8..1e1aead896018 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ 

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

2024-07-01 Thread Med Ismail Bennani via lldb-commits

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


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

2024-07-01 Thread via lldb-commits

Author: Med Ismail Bennani
Date: 2024-07-01T21:35:21-07:00
New Revision: 410de0c8c831a4a63075dd03f80ca83205860746

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

LOG: [lldb/Commands] Alias `script` command to `scripting run` (#97263)

This patch introduces a new top-level `scripting` command with an `run`
sub-command, that basically replaces the `script` raw command.

To avoid breaking the `script` command usages, this patch also adds an
`script` alias to the `scripting run` sub-command.

The reason behind this change is to have a top-level command that will
cover scripting related subcommands.

Signed-off-by: Med Ismail Bennani 

Added: 
lldb/source/Commands/CommandObjectScripting.cpp
lldb/source/Commands/CommandObjectScripting.h

Modified: 
lldb/source/Commands/CMakeLists.txt
lldb/source/Commands/Options.td
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/test/API/functionalities/abbreviation/TestAbbreviations.py

Removed: 
lldb/source/Commands/CommandObjectScript.cpp
lldb/source/Commands/CommandObjectScript.h



diff  --git a/lldb/source/Commands/CMakeLists.txt 
b/lldb/source/Commands/CMakeLists.txt
index 6a36c5376d5c5..76397227d535d 100644
--- a/lldb/source/Commands/CMakeLists.txt
+++ b/lldb/source/Commands/CMakeLists.txt
@@ -26,7 +26,7 @@ add_lldb_library(lldbCommands NO_PLUGIN_DEPENDENCIES
   CommandObjectQuit.cpp
   CommandObjectRegexCommand.cpp
   CommandObjectRegister.cpp
-  CommandObjectScript.cpp
+  CommandObjectScripting.cpp
   CommandObjectSession.cpp
   CommandObjectSettings.cpp
   CommandObjectSource.cpp

diff  --git a/lldb/source/Commands/CommandObjectScript.cpp 
b/lldb/source/Commands/CommandObjectScript.cpp
deleted file mode 100644
index 25f25b8e65947..0
--- a/lldb/source/Commands/CommandObjectScript.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-//===-- CommandObjectScript.cpp 
---===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "CommandObjectScript.h"
-#include "lldb/Core/Debugger.h"
-#include "lldb/DataFormatters/DataVisualization.h"
-#include "lldb/Host/Config.h"
-#include "lldb/Host/OptionParser.h"
-#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Interpreter/CommandOptionArgumentTable.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Interpreter/OptionArgParser.h"
-#include "lldb/Interpreter/ScriptInterpreter.h"
-#include "lldb/Utility/Args.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-#define LLDB_OPTIONS_script
-#include "CommandOptions.inc"
-
-Status CommandObjectScript::CommandOptions::SetOptionValue(
-uint32_t option_idx, llvm::StringRef option_arg,
-ExecutionContext *execution_context) {
-  Status error;
-  const int short_option = m_getopt_table[option_idx].val;
-
-  switch (short_option) {
-  case 'l':
-language = (lldb::ScriptLanguage)OptionArgParser::ToOptionEnum(
-option_arg, GetDefinitions()[option_idx].enum_values,
-eScriptLanguageNone, error);
-if (!error.Success())
-  error.SetErrorStringWithFormat("unrecognized value for language '%s'",
- option_arg.str().c_str());
-break;
-  default:
-llvm_unreachable("Unimplemented option");
-  }
-
-  return error;
-}
-
-void CommandObjectScript::CommandOptions::OptionParsingStarting(
-ExecutionContext *execution_context) {
-  language = lldb::eScriptLanguageNone;
-}
-
-llvm::ArrayRef
-CommandObjectScript::CommandOptions::GetDefinitions() {
-  return llvm::ArrayRef(g_script_options);
-}
-
-CommandObjectScript::CommandObjectScript(CommandInterpreter )
-: CommandObjectRaw(
-  interpreter, "script",
-  "Invoke the script interpreter with provided code and display any "
-  "results.  Start the interactive interpreter if no code is 
supplied.",
-  "script [--language  --] []") {}
-
-CommandObjectScript::~CommandObjectScript() = default;
-
-void CommandObjectScript::DoExecute(llvm::StringRef command,
-CommandReturnObject ) {
-  // Try parsing the language option but when the command contains a raw part
-  // separated by the -- delimiter.
-  OptionsWithRaw raw_args(command);
-  if (raw_args.HasArgs()) {
-if (!ParseOptions(raw_args.GetArgs(), result))
-  return;
-command = raw_args.GetRawPart();
-  }
-
-  lldb::ScriptLanguage language =
-  (m_options.language == lldb::eScriptLanguageNone)
-  ? m_interpreter.GetDebugger().GetScriptLanguage()
-  : 

[Lldb-commits] [lldb] fix issue with debug-types-dwo-cross-reference.cpp.tmp test (PR #97381)

2024-07-01 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Paul Johnston (pauljohnston2009)


Changes

fixes issue from https://github.com/llvm/llvm-project/issues/97380

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


1 Files Affected:

- (modified) 
lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-dwo-cross-reference.cpp (+2-2) 


``diff
diff --git 
a/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-dwo-cross-reference.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-dwo-cross-reference.cpp
index 0e29cb3e7f16e..7e96e8d3e1dd0 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-dwo-cross-reference.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-dwo-cross-reference.cpp
@@ -10,7 +10,7 @@
 // RUN: llvm-dwarfdump %t1.dwo -debug-types -debug-info | FileCheck 
--check-prefix=ONEUNIT %s
 // RUN: llvm-dwarfdump %t2.dwo -debug-types -debug-info | FileCheck 
--check-prefix=ONEUNIT %s
 // RUN: ld.lld %t1.o %t2.o -o %t
-// RUN: %lldb %t -o "target var a b **b.a" -b | FileCheck %s
+// RUN: %lldb %t -o "target var a b" -o "print **b.a" -b | FileCheck %s
 
 // ONEUNIT-COUNT-1: DW_TAG_type_unit
 
@@ -18,7 +18,7 @@
 // CHECK:  (const B) b = {
 // CHECK-NEXT:   a = 0x{{.*}}
 // CHECK-NEXT: }
-// CHECK:  (const A) **b.a = (a = 42)
+// CHECK:  (const A) (a = 42)
 
 struct A;
 

``




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


[Lldb-commits] [lldb] fix issue with debug-types-dwo-cross-reference.cpp.tmp test (PR #97381)

2024-07-01 Thread Paul Johnston via lldb-commits

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


[Lldb-commits] [lldb] fix issue with debug-types-dwo-cross-reference.cpp.tmp test (PR #97381)

2024-07-01 Thread via lldb-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[Lldb-commits] [lldb] fix issue with debug-types-dwo-cross-reference.cpp.tmp test (PR #97381)

2024-07-01 Thread Paul Johnston via lldb-commits

https://github.com/pauljohnston2009 created 
https://github.com/llvm/llvm-project/pull/97381

None

>From e68f42344b95108eac9a83de8586b65f8bc1adef Mon Sep 17 00:00:00 2001
From: Paul Johnston 
Date: Tue, 2 Jul 2024 14:19:14 +1000
Subject: [PATCH] fix issue with debug-types-dwo-cross-reference.cpp.tmp test

---
 .../SymbolFile/DWARF/x86/debug-types-dwo-cross-reference.cpp  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-dwo-cross-reference.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-dwo-cross-reference.cpp
index 0e29cb3e7f16e..7e96e8d3e1dd0 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-dwo-cross-reference.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-dwo-cross-reference.cpp
@@ -10,7 +10,7 @@
 // RUN: llvm-dwarfdump %t1.dwo -debug-types -debug-info | FileCheck 
--check-prefix=ONEUNIT %s
 // RUN: llvm-dwarfdump %t2.dwo -debug-types -debug-info | FileCheck 
--check-prefix=ONEUNIT %s
 // RUN: ld.lld %t1.o %t2.o -o %t
-// RUN: %lldb %t -o "target var a b **b.a" -b | FileCheck %s
+// RUN: %lldb %t -o "target var a b" -o "print **b.a" -b | FileCheck %s
 
 // ONEUNIT-COUNT-1: DW_TAG_type_unit
 
@@ -18,7 +18,7 @@
 // CHECK:  (const B) b = {
 // CHECK-NEXT:   a = 0x{{.*}}
 // CHECK-NEXT: }
-// CHECK:  (const A) **b.a = (a = 42)
+// CHECK:  (const A) (a = 42)
 
 struct A;
 

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


[Lldb-commits] [lldb] [lldb] [ObjectFileMachO] BSS segments are loadable segments (PR #96983)

2024-07-01 Thread Jonas Devlieghere via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-01 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

Hi @AlexK0 I restructured this PR to track everything with a single piece of 
state in the Thread object, and redid all three Process plugins.  I'm feeling a 
lot better about my changes to ProcessWindows now.  I haven't tested the 
aarch64 ubuntu yet, I will do that tomorrow and if that looks good, I'm going 
to ask for more careful reviews of the PR.  No rush at all, but if you have a 
chance to try this version on Windows I would really appreciate it.  Thanks!

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


[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-01 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/96260

>From 9b541e6a035635e26c6a24eca022de8552fa4c17 Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Thu, 20 Jun 2024 17:53:17 -0700
Subject: [PATCH 1/4] [lldb] Change lldb's breakpoint handling behavior

lldb today has two rules:  When a thread stops at a BreakpointSite,
we set the thread's StopReason to be "breakpoint hit" (regardless
if we've actually hit the breakpoint, or if we've merely stopped
*at* the breakpoint instruction/point and haven't tripped it yet).
And second, when resuming a process, any thread sitting at a
BreakpointSite is silently stepped over the BreakpointSite -- because
we've already flagged the breakpoint hit when we stopped there
originally.

In this patch, I change lldb to only set a thread's stop reason to
breakpoint-hit when we've actually executed the instruction/triggered
the breakpoint.  When we resume, we only silently step past a
BreakpointSite that we've registered as hit.  We preserve this state
across inferior function calls that the user may do while stopped,
etc.

Also, when a user adds a new breakpoint at $pc while stopped, or
changes $pc to be the address of a BreakpointSite, we will silently
step past that breakpoint when the process resumes.  This is purely
a UX call, I don't think there's any person who wants to set a
breakpoint at $pc and then hit it immediately on resuming.

One non-intuitive UX from this change, but I'm convinced it is
necessary:  If you're stopped at a BreakpointSite that has not yet
executed, you `stepi`, you will hit the breakpoint and the pc will
not yet advance.  This thread has not completed its stepi, and the
thread plan is still on the stack.  If you then `continue` the
thread, lldb will now stop and say, "instruction step completed",
one instruction past the BreakpointSite.  You can continue a second
time to resume execution.  I discussed this with Jim, and trying
to paper over this behavior will lead to more complicated scenarios
behaving non-intuitively.  And mostly it's the testsuite that was
trying to instruction step past a breakpoint and getting thrown off
-- and I changed those tests to expect the new behavior.

The bugs driving this change are all from lldb dropping the real
stop reason for a thread and setting it to breakpoint-hit when that
was not the case.  Jim hit one where we have an aarch64 watchpoint
that triggers one instruction before a BreakpointSite.  On this
arch we are notified of the watchpoint hit after the instruction
has been unrolled -- we disable the watchpoint, instruction step,
re-enable the watchpoint and collect the new value.  But now we're
on a BreakpointSite so the watchpoint-hit stop reason is lost.

Another was reported by ZequanWu in
https://discourse.llvm.org/t/lldb-unable-to-break-at-start/78282
we attach to/launch a process with the pc at a BreakpointSite and
misbehave.  Caroline Tice mentioned it is also a problem they've
had with putting a breakpoint on _dl_debug_state.

The change to each Process plugin that does execution control
is that

1. If we've stopped at a BreakpointSite (whether we hit it or not),
we call Thread::SetThreadStoppedAtBreakpointSite(pc) to record the
state at the point when the thread stopped.  (so we can detect
newly-added breakpoints, or when the pc is changed to an instruction
that is a BreakpointSite)

2. When we have actually hit a breakpoint, and it is enabled for
this thread, we call Thread::SetThreadHitBreakpointAtAddr(pc) so
we know that it should be silently stepped past when we resume
execution.

When resuming, we silently step over a breakpoint if we've hit it,
or if it is newly added (or the pc was changed to an existing
BreakpointSite).

The biggest set of changes is to StopInfoMachException where we
translate a Mach Exception into a stop reason.  The Mach exception
codes differ in a few places depending on the target (unambiguously),
and I didn't want to duplicate the new code for each target so I've
tested what mach exceptions we get for each action on each target,
and reorganized StopInfoMachException::CreateStopReasonWithMachException
to document these possible values, and handle them without specializing
based on the target arch.

rdar://123942164
---
 lldb/include/lldb/Target/Thread.h |  29 ++
 .../Process/Utility/StopInfoMachException.cpp | 296 +++---
 .../Process/Windows/Common/ProcessWindows.cpp |  16 +-
 .../Process/gdb-remote/ProcessGDBRemote.cpp   | 118 +++
 .../Process/scripted/ScriptedThread.cpp   |   9 +
 lldb/source/Target/Thread.cpp |  17 +-
 .../TestConsecutiveBreakpoints.py |  26 +-
 .../TestStepOverBreakpoint.py |   6 +-
 8 files changed, 235 insertions(+), 282 deletions(-)

diff --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index c17bddf4d98b8..1e1aead896018 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ 

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

2024-07-01 Thread Med Ismail Bennani via lldb-commits

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


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

2024-07-01 Thread Med Ismail Bennani via lldb-commits

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


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

2024-07-01 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben updated 
https://github.com/llvm/llvm-project/pull/97263

>From 47344cbd1ae8a43eab1b845f893cc04114eeaa35 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Mon, 1 Jul 2024 20:51:35 -0700
Subject: [PATCH] [lldb/Commands] Alias `script` command to `scripting run`

This patch introduces a new top-level `scripting` command with an
`run` sub-command, that basically replaces the `script` raw command.

To avoid breaking the `script` command usages, this patch also adds an
`script` alias to the `scripting run` sub-command.

The reason behind this change is to have a top-level command that will
cover scripting related subcommands.

Signed-off-by: Med Ismail Bennani 
---
 lldb/source/Commands/CMakeLists.txt   |   2 +-
 lldb/source/Commands/CommandObjectScript.cpp  | 113 --
 lldb/source/Commands/CommandObjectScript.h|  42 -
 .../Commands/CommandObjectScripting.cpp   | 144 ++
 lldb/source/Commands/CommandObjectScripting.h |  25 +++
 lldb/source/Commands/Options.td   |   2 +-
 .../source/Interpreter/CommandInterpreter.cpp |  13 +-
 .../abbreviation/TestAbbreviations.py |   8 +-
 8 files changed, 189 insertions(+), 160 deletions(-)
 delete mode 100644 lldb/source/Commands/CommandObjectScript.cpp
 delete mode 100644 lldb/source/Commands/CommandObjectScript.h
 create mode 100644 lldb/source/Commands/CommandObjectScripting.cpp
 create mode 100644 lldb/source/Commands/CommandObjectScripting.h

diff --git a/lldb/source/Commands/CMakeLists.txt 
b/lldb/source/Commands/CMakeLists.txt
index 6a36c5376d5c5..76397227d535d 100644
--- a/lldb/source/Commands/CMakeLists.txt
+++ b/lldb/source/Commands/CMakeLists.txt
@@ -26,7 +26,7 @@ add_lldb_library(lldbCommands NO_PLUGIN_DEPENDENCIES
   CommandObjectQuit.cpp
   CommandObjectRegexCommand.cpp
   CommandObjectRegister.cpp
-  CommandObjectScript.cpp
+  CommandObjectScripting.cpp
   CommandObjectSession.cpp
   CommandObjectSettings.cpp
   CommandObjectSource.cpp
diff --git a/lldb/source/Commands/CommandObjectScript.cpp 
b/lldb/source/Commands/CommandObjectScript.cpp
deleted file mode 100644
index 25f25b8e65947..0
--- a/lldb/source/Commands/CommandObjectScript.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-//===-- CommandObjectScript.cpp 
---===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "CommandObjectScript.h"
-#include "lldb/Core/Debugger.h"
-#include "lldb/DataFormatters/DataVisualization.h"
-#include "lldb/Host/Config.h"
-#include "lldb/Host/OptionParser.h"
-#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Interpreter/CommandOptionArgumentTable.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Interpreter/OptionArgParser.h"
-#include "lldb/Interpreter/ScriptInterpreter.h"
-#include "lldb/Utility/Args.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-#define LLDB_OPTIONS_script
-#include "CommandOptions.inc"
-
-Status CommandObjectScript::CommandOptions::SetOptionValue(
-uint32_t option_idx, llvm::StringRef option_arg,
-ExecutionContext *execution_context) {
-  Status error;
-  const int short_option = m_getopt_table[option_idx].val;
-
-  switch (short_option) {
-  case 'l':
-language = (lldb::ScriptLanguage)OptionArgParser::ToOptionEnum(
-option_arg, GetDefinitions()[option_idx].enum_values,
-eScriptLanguageNone, error);
-if (!error.Success())
-  error.SetErrorStringWithFormat("unrecognized value for language '%s'",
- option_arg.str().c_str());
-break;
-  default:
-llvm_unreachable("Unimplemented option");
-  }
-
-  return error;
-}
-
-void CommandObjectScript::CommandOptions::OptionParsingStarting(
-ExecutionContext *execution_context) {
-  language = lldb::eScriptLanguageNone;
-}
-
-llvm::ArrayRef
-CommandObjectScript::CommandOptions::GetDefinitions() {
-  return llvm::ArrayRef(g_script_options);
-}
-
-CommandObjectScript::CommandObjectScript(CommandInterpreter )
-: CommandObjectRaw(
-  interpreter, "script",
-  "Invoke the script interpreter with provided code and display any "
-  "results.  Start the interactive interpreter if no code is 
supplied.",
-  "script [--language  --] []") {}
-
-CommandObjectScript::~CommandObjectScript() = default;
-
-void CommandObjectScript::DoExecute(llvm::StringRef command,
-CommandReturnObject ) {
-  // Try parsing the language option but when the command contains a raw part
-  // separated by the -- delimiter.
-  OptionsWithRaw raw_args(command);
-  if (raw_args.HasArgs()) {
-if (!ParseOptions(raw_args.GetArgs(), result))
-  return;

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

2024-07-01 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben updated 
https://github.com/llvm/llvm-project/pull/97263

>From b9eba8c81b342d038f0ca6cb40f2390225c3770f Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Mon, 1 Jul 2024 20:45:34 -0700
Subject: [PATCH] [lldb/Commands] Alias `script` command to `scripting run`

This patch introduces a new top-level `scripting` command with an
`run` sub-command, that basically replaces the `script` raw command.

To avoid breaking the `script` command usages, this patch also adds an
`script` alias to the `scripting run` sub-command.

The reason behind this change is to have a top-level command that will
cover scripting related subcommands.

Signed-off-by: Med Ismail Bennani 
---
 lldb/source/Commands/CMakeLists.txt   |   2 +-
 lldb/source/Commands/CommandObjectScript.cpp  | 113 --
 lldb/source/Commands/CommandObjectScript.h|  42 -
 .../Commands/CommandObjectScripting.cpp   | 144 ++
 lldb/source/Commands/CommandObjectScripting.h |  25 +++
 lldb/source/Commands/Options.td   |   2 +-
 .../source/Interpreter/CommandInterpreter.cpp |  13 +-
 .../abbreviation/TestAbbreviations.py |   8 +-
 8 files changed, 189 insertions(+), 160 deletions(-)
 delete mode 100644 lldb/source/Commands/CommandObjectScript.cpp
 delete mode 100644 lldb/source/Commands/CommandObjectScript.h
 create mode 100644 lldb/source/Commands/CommandObjectScripting.cpp
 create mode 100644 lldb/source/Commands/CommandObjectScripting.h

diff --git a/lldb/source/Commands/CMakeLists.txt 
b/lldb/source/Commands/CMakeLists.txt
index 6a36c5376d5c5..76397227d535d 100644
--- a/lldb/source/Commands/CMakeLists.txt
+++ b/lldb/source/Commands/CMakeLists.txt
@@ -26,7 +26,7 @@ add_lldb_library(lldbCommands NO_PLUGIN_DEPENDENCIES
   CommandObjectQuit.cpp
   CommandObjectRegexCommand.cpp
   CommandObjectRegister.cpp
-  CommandObjectScript.cpp
+  CommandObjectScripting.cpp
   CommandObjectSession.cpp
   CommandObjectSettings.cpp
   CommandObjectSource.cpp
diff --git a/lldb/source/Commands/CommandObjectScript.cpp 
b/lldb/source/Commands/CommandObjectScript.cpp
deleted file mode 100644
index 25f25b8e65947..0
--- a/lldb/source/Commands/CommandObjectScript.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-//===-- CommandObjectScript.cpp 
---===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "CommandObjectScript.h"
-#include "lldb/Core/Debugger.h"
-#include "lldb/DataFormatters/DataVisualization.h"
-#include "lldb/Host/Config.h"
-#include "lldb/Host/OptionParser.h"
-#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Interpreter/CommandOptionArgumentTable.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Interpreter/OptionArgParser.h"
-#include "lldb/Interpreter/ScriptInterpreter.h"
-#include "lldb/Utility/Args.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-#define LLDB_OPTIONS_script
-#include "CommandOptions.inc"
-
-Status CommandObjectScript::CommandOptions::SetOptionValue(
-uint32_t option_idx, llvm::StringRef option_arg,
-ExecutionContext *execution_context) {
-  Status error;
-  const int short_option = m_getopt_table[option_idx].val;
-
-  switch (short_option) {
-  case 'l':
-language = (lldb::ScriptLanguage)OptionArgParser::ToOptionEnum(
-option_arg, GetDefinitions()[option_idx].enum_values,
-eScriptLanguageNone, error);
-if (!error.Success())
-  error.SetErrorStringWithFormat("unrecognized value for language '%s'",
- option_arg.str().c_str());
-break;
-  default:
-llvm_unreachable("Unimplemented option");
-  }
-
-  return error;
-}
-
-void CommandObjectScript::CommandOptions::OptionParsingStarting(
-ExecutionContext *execution_context) {
-  language = lldb::eScriptLanguageNone;
-}
-
-llvm::ArrayRef
-CommandObjectScript::CommandOptions::GetDefinitions() {
-  return llvm::ArrayRef(g_script_options);
-}
-
-CommandObjectScript::CommandObjectScript(CommandInterpreter )
-: CommandObjectRaw(
-  interpreter, "script",
-  "Invoke the script interpreter with provided code and display any "
-  "results.  Start the interactive interpreter if no code is 
supplied.",
-  "script [--language  --] []") {}
-
-CommandObjectScript::~CommandObjectScript() = default;
-
-void CommandObjectScript::DoExecute(llvm::StringRef command,
-CommandReturnObject ) {
-  // Try parsing the language option but when the command contains a raw part
-  // separated by the -- delimiter.
-  OptionsWithRaw raw_args(command);
-  if (raw_args.HasArgs()) {
-if (!ParseOptions(raw_args.GetArgs(), result))
-  return;

[Lldb-commits] [lldb] [lldb/docs] Add scripting extensions documentation to the website (PR #97262)

2024-07-01 Thread via lldb-commits


@@ -0,0 +1,70 @@
+from abc import abstractmethod
+
+import lldb
+
+
+class ScriptedThreadPlan:
+"""
+Class that provides data for an instance of a LLDB 'ScriptedThreadPlan' 
plug-in class used to construct custom stepping logic.
+
+"""
+
+def __init__(self, thread_plan: lldb.SBThreadPlan):
+"""Initialization needs a valid lldb.SBThreadPlan object. This plug-in 
will get created after a live process is valid and has stopped.
+
+Args:
+thread_plan (lldb.SBThreadPlan): The underlying `ThreadPlan` that 
is pushed onto the plan stack.
+"""
+self.thread_plan = thread_plan
+
+def explains_stop(self, event: lldb.SBEvent) -> bool:
+"""Each plan is asked if it "explains" the stop.  The first plan to 
claim the stop wins.
+
+Args:
+event (lldb.SBEvent): The process stop event.
+
+Returns:
+bool: `True` if this stop could be claimed by this thread plan, 
`False` otherwise.
+Defaults to `True`.
+"""
+return True
+
+def is_stale(self) -> bool:
+"""If your plan is no longer relevant (for instance, you were stepping 
in a particular stack frame, but some other operation pushed that frame off the 
stack) return True and your plan will get popped.
+
+Returns:
+bool: `True` if this thread plan is stale, `False` otherwise.
+Defaults to `True`.
+"""
+return True

jimingham wrote:

Saying you are stale in case of error is appropriate for the Scripted Thread 
Plan runner plan.  If the underlying Python code can't figure out what its 
state is, it's likely in a bad way and we should mark it as stale and get rid 
of it.  
But these templates are more analogous to the base ThreadPlan than to the 
scripted plan runner.

That one does:

  virtual bool IsPlanStale() { return false; }


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


[Lldb-commits] [lldb] [lldb/docs] Add scripting extensions documentation to the website (PR #97262)

2024-07-01 Thread Med Ismail Bennani via lldb-commits


@@ -0,0 +1,70 @@
+from abc import abstractmethod
+
+import lldb
+
+
+class ScriptedThreadPlan:
+"""
+Class that provides data for an instance of a LLDB 'ScriptedThreadPlan' 
plug-in class used to construct custom stepping logic.
+
+"""
+
+def __init__(self, thread_plan: lldb.SBThreadPlan):
+"""Initialization needs a valid lldb.SBThreadPlan object. This plug-in 
will get created after a live process is valid and has stopped.
+
+Args:
+thread_plan (lldb.SBThreadPlan): The underlying `ThreadPlan` that 
is pushed onto the plan stack.
+"""
+self.thread_plan = thread_plan
+
+def explains_stop(self, event: lldb.SBEvent) -> bool:
+"""Each plan is asked if it "explains" the stop.  The first plan to 
claim the stop wins.
+
+Args:
+event (lldb.SBEvent): The process stop event.
+
+Returns:
+bool: `True` if this stop could be claimed by this thread plan, 
`False` otherwise.
+Defaults to `True`.
+"""
+return True
+
+def is_stale(self) -> bool:
+"""If your plan is no longer relevant (for instance, you were stepping 
in a particular stack frame, but some other operation pushed that frame off the 
stack) return True and your plan will get popped.
+
+Returns:
+bool: `True` if this thread plan is stale, `False` otherwise.
+Defaults to `True`.
+"""
+return True

medismailben wrote:

I went with `True` since this is the default value in case of an error on the 
C++ side:

https://github.com/apple/llvm-project/blob/swift/release/6.0/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp#L1754

Do you think we should change the default value everywhere to be False ?

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


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

2024-07-01 Thread Med Ismail Bennani via lldb-commits

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


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

2024-07-01 Thread Med Ismail Bennani via lldb-commits


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

medismailben wrote:

I agree its not the most elegant solution but I'd prefer solving the partial 
matching issue in a follow-up.

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


[Lldb-commits] [lldb] [lldb] [ObjectFileMachO] BSS segments are loadable segments (PR #96983)

2024-07-01 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/96983

>From 6bd566504355e8d50b9c922df9ebce18e07a726f Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Thu, 27 Jun 2024 15:34:48 -0700
Subject: [PATCH 1/2] [lldb] [ObjectFileMachO] BSS segments are loadable
 segments

ObjectFileMachO::SetLoadAddress sets the address of each segment
in a binary in a Target, but it ignores segments that are not loaded
in the virtual address space.  It was marking segments that were
purely BSS -- having no content in the file, but in zero-initialized
memory when running in the virtual address space -- as not-loadable,
unless they were named "DATA".  This works pretty well for typical
userland binaries, but in less Darwin environments, there may be
BSS segments with other names, that ARE loadable.

I looked at the origin of SectionIsLoadable's check for this, and
it was a cleanup by Greg in 2018 where we had three different
implementations of the idea in ObjectFileMachO and one of them
skipped zero-file-size segments (BSS), which made it into the
centralized SectionIsLoadable method.

Also add some logging to the DynamicLoader log channel when loading
a binary - it's the first place I look when debugging segment address
setting bugs, and it wasn't emitting anything.

rdar://129870649
---
 .../ObjectFile/Mach-O/ObjectFileMachO.cpp | 31 ---
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 2979bf69bf762..164c4409747e0 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -6159,10 +6159,6 @@ Section *ObjectFileMachO::GetMachHeaderSection() {
 bool ObjectFileMachO::SectionIsLoadable(const Section *section) {
   if (!section)
 return false;
-  const bool is_dsym = (m_header.filetype == MH_DSYM);
-  if (section->GetFileSize() == 0 && !is_dsym &&
-  section->GetName() != GetSegmentNameDATA())
-return false;
   if (section->IsThreadSpecific())
 return false;
   if (GetModule().get() != section->GetModule().get())
@@ -6202,6 +6198,7 @@ lldb::addr_t 
ObjectFileMachO::CalculateSectionLoadAddressForMemoryImage(
 
 bool ObjectFileMachO::SetLoadAddress(Target , lldb::addr_t value,
  bool value_is_offset) {
+  Log *log(GetLog(LLDBLog::DynamicLoader));
   ModuleSP module_sp = GetModule();
   if (!module_sp)
 return false;
@@ -6217,17 +6214,37 @@ bool ObjectFileMachO::SetLoadAddress(Target , 
lldb::addr_t value,
   // malformed.
   const bool warn_multiple = true;
 
+  if (log) {
+std::string binary_description;
+if (GetFileSpec()) {
+  binary_description += "path='";
+  binary_description += GetFileSpec().GetPath();
+  binary_description += "' ";
+}
+if (GetUUID()) {
+  binary_description += "uuid=";
+  binary_description += GetUUID().GetAsString();
+}
+LLDB_LOGF(log, "ObjectFileMachO::SetLoadAddress %s",
+  binary_description.c_str());
+  }
   if (value_is_offset) {
 // "value" is an offset to apply to each top level segment
 for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
   // Iterate through the object file sections to find all of the
   // sections that size on disk (to avoid __PAGEZERO) and load them
   SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
-  if (SectionIsLoadable(section_sp.get()))
+  if (SectionIsLoadable(section_sp.get())) {
+LLDB_LOGF(log,
+  "ObjectFileMachO::SetLoadAddress segment '%s' load addr is "
+  "0x%" PRIx64,
+  section_sp->GetName().AsCString(),
+  section_sp->GetFileAddress() + value);
 if (target.GetSectionLoadList().SetSectionLoadAddress(
 section_sp, section_sp->GetFileAddress() + value,
 warn_multiple))
   ++num_loaded_sections;
+  }
 }
   } else {
 // "value" is the new base address of the mach_header, adjust each
@@ -6242,6 +6259,10 @@ bool ObjectFileMachO::SetLoadAddress(Target , 
lldb::addr_t value,
 CalculateSectionLoadAddressForMemoryImage(
 value, mach_header_section, section_sp.get());
 if (section_load_addr != LLDB_INVALID_ADDRESS) {
+  LLDB_LOGF(log,
+"ObjectFileMachO::SetLoadAddress segment '%s' load addr is 
"
+"0x%" PRIx64,
+section_sp->GetName().AsCString(), section_load_addr);
   if (target.GetSectionLoadList().SetSectionLoadAddress(
   section_sp, section_load_addr, warn_multiple))
 ++num_loaded_sections;

>From 2a7b154cbdffb75d763d3f8587266c9a7c0a0eb0 Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Mon, 1 Jul 2024 17:29:41 -0700
Subject: [PATCH 2/2] Build up the log message 

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

2024-07-01 Thread via lldb-commits

jimingham wrote:

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

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

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


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

2024-07-01 Thread via lldb-commits


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

jimingham wrote:

The problem is that if we have the command `scripting` and the alias `script` 
and we see `sc` we need to resolve that command ambiguity.  The only tool we 
have for ambiguous command resolution at present is "exact matches always win".

If we wanted to solve this w/o making all the exact matches we intend to win, 
we could add a ranking system to the commands and aliases, which bias ambiguous 
matches in favor of one or the other of the commands, or some similar system.  
I worry that would get messy pretty quickly, but anyway, you'd need something 
like that.

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


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

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

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

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

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


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

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


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

kastiglione wrote:

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

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

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


[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)

2024-07-01 Thread Helena Kotas via lldb-commits

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


[Lldb-commits] [clang] [lldb] [HLSL] Intangible AST type (PR #97362)

2024-07-01 Thread Helena Kotas via lldb-commits

https://github.com/hekota created 
https://github.com/llvm/llvm-project/pull/97362

llvm/llvm-project#90631



>From a07ea8d187cbba5717b89f5c54138f12993b3ee8 Mon Sep 17 00:00:00 2001
From: Justin Bogner 
Date: Thu, 6 Jun 2024 11:44:56 -0700
Subject: [PATCH 1/4] wip: Stub out adding an HLSLResource builtin type

There are a couple of things that may be wrong here:

- Adding the PREDEF_TYPE to ASTBitCodes seems sketchy, but matches
  prior art.
- I skipped name mangling for now - can it come up?
- We use an unspellable name in a few places
- The type info matches `void *`. Does that make sense?
---
 clang/include/clang-c/Index.h   |  4 +++-
 clang/include/clang/AST/ASTContext.h|  1 +
 clang/include/clang/AST/BuiltinTypes.def|  3 +++
 clang/include/clang/AST/Type.h  | 12 
 clang/include/clang/Serialization/ASTBitCodes.h |  5 -
 clang/lib/AST/ASTContext.cpp|  8 
 clang/lib/AST/ExprConstant.cpp  |  1 +
 clang/lib/AST/ItaniumMangle.cpp |  4 
 clang/lib/AST/MicrosoftMangle.cpp   |  5 +
 clang/lib/AST/NSAPI.cpp |  1 +
 clang/lib/AST/Type.cpp  |  3 +++
 clang/lib/AST/TypeLoc.cpp   |  1 +
 clang/lib/CodeGen/CGDebugInfo.cpp   |  5 +
 clang/lib/CodeGen/CGDebugInfo.h |  1 +
 clang/lib/CodeGen/CGHLSLRuntime.cpp | 13 +
 clang/lib/CodeGen/CGHLSLRuntime.h   |  2 ++
 clang/lib/CodeGen/CodeGenTypes.cpp  |  4 
 clang/lib/CodeGen/ItaniumCXXABI.cpp |  1 +
 clang/lib/Index/USRGeneration.cpp   |  2 ++
 clang/lib/Serialization/ASTCommon.cpp   |  3 +++
 clang/lib/Serialization/ASTReader.cpp   |  3 +++
 clang/tools/libclang/CIndex.cpp |  1 +
 clang/tools/libclang/CXType.cpp |  2 ++
 .../Plugins/TypeSystem/Clang/TypeSystemClang.cpp|  2 ++
 24 files changed, 85 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index ce2282937f86c..b47407f571dfe 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -2966,7 +2966,9 @@ enum CXTypeKind {
 
   CXType_ExtVector = 176,
   CXType_Atomic = 177,
-  CXType_BTFTagAttributed = 178
+  CXType_BTFTagAttributed = 178,
+
+  CXType_HLSLResource = 179
 };
 
 /**
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index de86cb5e9d7fc..57e4d7c7c6d33 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1130,6 +1130,7 @@ class ASTContext : public RefCountedBase {
 #include "clang/Basic/OpenCLImageTypes.def"
   CanQualType OCLSamplerTy, OCLEventTy, OCLClkEventTy;
   CanQualType OCLQueueTy, OCLReserveIDTy;
+  CanQualType HLSLResourceTy;
   CanQualType IncompleteMatrixIdxTy;
   CanQualType ArraySectionTy;
   CanQualType OMPArrayShapingTy, OMPIteratorTy;
diff --git a/clang/include/clang/AST/BuiltinTypes.def 
b/clang/include/clang/AST/BuiltinTypes.def
index 444be4311a743..74c6585688a71 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -257,6 +257,9 @@ BUILTIN_TYPE(OCLQueue, OCLQueueTy)
 // OpenCL reserve_id_t.
 BUILTIN_TYPE(OCLReserveID, OCLReserveIDTy)
 
+// HLSL resource type
+BUILTIN_TYPE(HLSLResource, HLSLResourceTy)
+
 // This represents the type of an expression whose type is
 // totally unknown, e.g. 'T::foo'.  It is permitted for this to
 // appear in situations where the structure of the type is
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 61246479188e9..720ce7715903c 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2626,6 +2626,10 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   bool isBitIntType() const;// Bit-precise integer type
   bool isOpenCLSpecificType() const;// Any OpenCL specific type
 
+  bool isHLSLResourceType() const;// HLSL resource type
+  bool isHLSLSpecificType() const;  // Any HLSL specific type
+
+
   /// Determines if this type, which must satisfy
   /// isObjCLifetimeType(), is implicitly __unsafe_unretained rather
   /// than implicitly __strong.
@@ -7887,6 +7891,14 @@ inline bool Type::isOpenCLSpecificType() const {
  isQueueT() || isReserveIDT() || isPipeType() || isOCLExtOpaqueType();
 }
 
+inline bool Type::isHLSLResourceType() const {
+  return isSpecificBuiltinType(BuiltinType::HLSLResource);
+}
+
+inline bool Type::isHLSLSpecificType() const {
+  return isHLSLResourceType();
+}
+
 inline bool Type::isTemplateTypeParmType() const {
   return isa(CanonicalType);
 }
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h 

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

2024-07-01 Thread via lldb-commits

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

LGTM with a couple little nits.

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


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

2024-07-01 Thread via lldb-commits


@@ -80,7 +80,9 @@ def test_command_abbreviations_and_aliases(self):
 # Check a command that wants the raw input.
 command_interpreter.ResolveCommand(r"""sc print("\n\n\tHello!\n")""", 
result)
 self.assertTrue(result.Succeeded())
-self.assertEqual(r"""script print("\n\n\tHello!\n")""", 
result.GetOutput())

jimingham wrote:

Since you are explicitly making the default lldb treat `script` as an alias for 
script execute, it might be good to test that as well.  We're already testing 
`sc` just above.

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


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

2024-07-01 Thread via lldb-commits


@@ -9,14 +9,21 @@
 #ifndef LLDB_SOURCE_INTERPRETER_COMMANDOBJECTSCRIPT_H
 #define LLDB_SOURCE_INTERPRETER_COMMANDOBJECTSCRIPT_H
 
-#include "lldb/Interpreter/CommandObject.h"
+#include "lldb/Interpreter/CommandObjectMultiword.h"
 
 namespace lldb_private {
 
-class CommandObjectScript : public CommandObjectRaw {
+class CommandObjectMultiwordScripting : public CommandObjectMultiword {
 public:
-  CommandObjectScript(CommandInterpreter );
-  ~CommandObjectScript() override;
+  CommandObjectMultiwordScripting(CommandInterpreter );
+
+  ~CommandObjectMultiwordScripting() override;
+};
+
+class CommandObjectScriptingExecute : public CommandObjectRaw {

jimingham wrote:

We're somewhat inconsistent about this, but we don't tend to put the 
subcommands of the multiword commands in the header file.  It's not necessary 
since they get added to the command in the .cpp file and aren't needed more 
globally.

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


[Lldb-commits] [lldb] [lldb/docs] Add scripting extensions documentation to the website (PR #97262)

2024-07-01 Thread via lldb-commits


@@ -0,0 +1,70 @@
+from abc import abstractmethod
+
+import lldb
+
+
+class ScriptedThreadPlan:
+"""
+Class that provides data for an instance of a LLDB 'ScriptedThreadPlan' 
plug-in class used to construct custom stepping logic.
+
+"""
+
+def __init__(self, thread_plan: lldb.SBThreadPlan):
+"""Initialization needs a valid lldb.SBThreadPlan object. This plug-in 
will get created after a live process is valid and has stopped.
+
+Args:
+thread_plan (lldb.SBThreadPlan): The underlying `ThreadPlan` that 
is pushed onto the plan stack.
+"""
+self.thread_plan = thread_plan
+
+def explains_stop(self, event: lldb.SBEvent) -> bool:
+"""Each plan is asked if it "explains" the stop.  The first plan to 
claim the stop wins.
+
+Args:
+event (lldb.SBEvent): The process stop event.
+
+Returns:
+bool: `True` if this stop could be claimed by this thread plan, 
`False` otherwise.
+Defaults to `True`.
+"""
+return True
+
+def is_stale(self) -> bool:
+"""If your plan is no longer relevant (for instance, you were stepping 
in a particular stack frame, but some other operation pushed that frame off the 
stack) return True and your plan will get popped.
+
+Returns:
+bool: `True` if this thread plan is stale, `False` otherwise.
+Defaults to `True`.
+"""
+return True

jimingham wrote:

Should the template default to True here?  Plans don't frequently go stale, the 
get popped because of MischiefManaged much more frequently.  So most plans 
don't need to implement is_stale, at least not at first.

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


[Lldb-commits] [lldb] [lldb/docs] Add scripting extensions documentation to the website (PR #97262)

2024-07-01 Thread via lldb-commits


@@ -0,0 +1,70 @@
+from abc import abstractmethod
+
+import lldb
+
+
+class ScriptedThreadPlan:
+"""
+Class that provides data for an instance of a LLDB 'ScriptedThreadPlan' 
plug-in class used to construct custom stepping logic.
+
+"""
+
+def __init__(self, thread_plan: lldb.SBThreadPlan):
+"""Initialization needs a valid lldb.SBThreadPlan object. This plug-in 
will get created after a live process is valid and has stopped.
+
+Args:
+thread_plan (lldb.SBThreadPlan): The underlying `ThreadPlan` that 
is pushed onto the plan stack.
+"""
+self.thread_plan = thread_plan
+
+def explains_stop(self, event: lldb.SBEvent) -> bool:
+"""Each plan is asked if it "explains" the stop.  The first plan to 
claim the stop wins.

jimingham wrote:

Might be good to specify the ordering here:

Each plan is asked - from youngest to oldest - if it "explains" the stop.

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


[Lldb-commits] [lldb] [lldb/docs] Add scripting extensions documentation to the website (PR #97262)

2024-07-01 Thread via lldb-commits


@@ -11,6 +11,65 @@ some of these things by going through an example, explaining 
how to use
 Python scripting to find a bug in a program that searches for text in a
 large binary tree.
 
+Operating System Thread Plugins
+---
+
+.. automodapi:: lldb.plugins.operating_system
+:no-heading:
+:members:
+:undoc-members:
+:skip: command
+:skip: declaration
+:skip: in_range
+:skip: is_numeric_type
+:skip: lldb_iter
+:no-inheritance-diagram:
+
+Scripted Process Plugins
+---
+
+.. automodapi:: lldb.plugins.scripted_process
+:no-heading:
+:members:
+:undoc-members:
+:skip: ABCMeta
+:skip: command
+:skip: declaration
+:skip: in_range
+:skip: is_numeric_type
+:skip: lldb_iter
+:no-inheritance-diagram:

jimingham wrote:

We really should refresh the Python Scripting page, having more task-focused 
docs would be good.  But that's pretty old at this point, and focused on a 
single problem, so I agree with Jonas, it's not the right place to put this 
info.

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


[Lldb-commits] [lldb] 95038a5 - [LLDB] Import decorators in TestPythonOSPlugin.py

2024-07-01 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2024-07-02T02:29:16+05:00
New Revision: 95038a58268f8aeb7e35ce07fd82bbb3f48e4673

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

LOG: [LLDB] Import decorators in TestPythonOSPlugin.py

This fixes a regression caused by my commit where I added test
as skipped using a decorator but forgot to add import decorator
in TestPythonOSPlugin.py

Added: 


Modified: 
lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py 
b/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
index 2043543dc04ac..479c94c231540 100644
--- 
a/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
+++ 
b/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
@@ -5,6 +5,7 @@
 
 import os
 import lldb
+from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 import lldbsuite.test.lldbutil as lldbutil
 



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


[Lldb-commits] [lldb] f5dd845 - [LLDB] SkipIf TestPythonOSPlugin.py on Windows

2024-07-01 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2024-07-02T02:21:23+05:00
New Revision: f5dd8450940b003afb446846840cd19b067d327d

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

LOG: [LLDB] SkipIf TestPythonOSPlugin.py on Windows

test_run_python_os_step in TestPythonOSPlugin.py fails on Windows
after PR #97043. The test passes when run individually using dotest.py.

I have marked this skipped for windows to make LLDB AArch64 Windows
buildbot happy.

https://github.com/llvm/llvm-project/commit/a4c18137d84bc48df49ee0101bef465a955e62ac
https://lab.llvm.org/buildbot/#/builders/141/builds/379

Added: 


Modified: 
lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py 
b/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
index e03e8e0df7782..2043543dc04ac 100644
--- 
a/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
+++ 
b/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
@@ -17,6 +17,7 @@ def test_python_os_plugin(self):
 self.build()
 self.run_python_os_funcionality()
 
+@skipIfWindows  # This is flaky on Windows
 def test_run_python_os_step(self):
 """Test that the Python operating system plugin works correctly when 
single stepping a virtual thread"""
 self.build()



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


[Lldb-commits] [lldb] [LLDB] DebugInfoD tests: attempt to fix Fuchsia build (PR #96802)

2024-07-01 Thread Kevin Frei via lldb-commits

https://github.com/kevinfrei updated 
https://github.com/llvm/llvm-project/pull/96802

>From 95832768ffb3b115e95df19ae5ef14231cad32cc Mon Sep 17 00:00:00 2001
From: Kevin Frei 
Date: Mon, 25 Mar 2024 08:23:47 -0700
Subject: [PATCH 01/13] Trying to deal with Linux AArch64 test failures :/

---
 .../SymbolVendor/ELF/SymbolVendorELF.cpp  |  18 ++
 .../API/debuginfod/Normal/TestDebuginfod.py   | 187 +
 .../SplitDWARF/TestDebuginfodDWP.py   | 196 ++
 3 files changed, 401 insertions(+)
 create mode 100644 lldb/test/API/debuginfod/Normal/TestDebuginfod.py
 create mode 100644 lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py

diff --git a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp 
b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
index b5fe35d71032a..a881218a56cef 100644
--- a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
+++ b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
@@ -44,6 +44,24 @@ llvm::StringRef 
SymbolVendorELF::GetPluginDescriptionStatic() {
  "executables.";
 }
 
+// If this is needed elsewhere, it can be exported/moved.
+static bool IsDwpSymbolFile(const lldb::ModuleSP _sp,
+const FileSpec _spec) {
+  DataBufferSP dwp_file_data_sp;
+  lldb::offset_t dwp_file_data_offset = 0;
+  // Try to create an ObjectFile from the file_spec.
+  ObjectFileSP dwp_obj_file = ObjectFile::FindPlugin(
+  module_sp, _spec, 0, FileSystem::Instance().GetByteSize(file_spec),
+  dwp_file_data_sp, dwp_file_data_offset);
+  // The presence of a debug_cu_index section is the key identifying feature of
+  // a DWP file. Make sure we don't fill in the section list on dwp_obj_file
+  // (by calling GetSectionList(false)) as this is invoked before we may have
+  // all the symbol files collected and available.
+  return dwp_obj_file && ObjectFileELF::classof(dwp_obj_file.get()) &&
+ dwp_obj_file->GetSectionList(false)->FindSectionByType(
+ eSectionTypeDWARFDebugCuIndex, false);
+}
+
 // CreateInstance
 //
 // Platforms can register a callback to use when creating symbol vendors to
diff --git a/lldb/test/API/debuginfod/Normal/TestDebuginfod.py 
b/lldb/test/API/debuginfod/Normal/TestDebuginfod.py
new file mode 100644
index 0..a662fb9fc6e68
--- /dev/null
+++ b/lldb/test/API/debuginfod/Normal/TestDebuginfod.py
@@ -0,0 +1,187 @@
+import os
+import shutil
+import tempfile
+import struct
+
+import lldb
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+def getUUID(aoutuuid):
+"""
+Pull the 20 byte UUID out of the .note.gnu.build-id section that was dumped
+to a file already, as part of the build.
+"""
+with open(aoutuuid, "rb") as f:
+data = f.read(36)
+if len(data) != 36:
+return None
+header = struct.unpack_from("<4I", data)
+if len(header) != 4:
+return None
+# 4 element 'prefix', 20 bytes of uuid, 3 byte long string: 'GNU':
+if header[0] != 4 or header[1] != 20 or header[2] != 3 or header[3] != 
0x554E47:
+return None
+return data[16:].hex()
+
+
+"""
+Test support for the DebugInfoD network symbol acquisition protocol.
+This one is for simple / no split-dwarf scenarios.
+
+For no-split-dwarf scenarios, there are 2 variations:
+1 - A stripped binary with it's corresponding unstripped binary:
+2 - A stripped binary with a corresponding --only-keep-debug symbols file
+"""
+
+
+@skipUnlessPlatform(["linux", "freebsd"])
+class DebugInfodTests(TestBase):
+# No need to try every flavor of debug inf.
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_normal_no_symbols(self):
+"""
+Validate behavior with no symbols or symbol locator.
+('baseline negative' behavior)
+"""
+test_root = self.config_test(["a.out"])
+self.try_breakpoint(False)
+
+def test_normal_default(self):
+"""
+Validate behavior with symbols, but no symbol locator.
+('baseline positive' behavior)
+"""
+test_root = self.config_test(["a.out", "a.out.debug"])
+self.try_breakpoint(True)
+
+def test_debuginfod_symbols(self):
+"""
+Test behavior with the full binary available from Debuginfod as
+'debuginfo' from the plug-in.
+"""
+test_root = self.config_test(["a.out"], "a.out.full")
+self.try_breakpoint(True)
+
+def test_debuginfod_executable(self):
+"""
+Test behavior with the full binary available from Debuginfod as
+'executable' from the plug-in.
+"""
+test_root = self.config_test(["a.out"], None, "a.out.full")
+self.try_breakpoint(True)
+
+def test_debuginfod_okd_symbols(self):
+"""
+Test behavior with the 'only-keep-debug' symbols available from 
Debuginfod.
+"""
+test_root = 

[Lldb-commits] [lldb] Fix flake in TestZerothFrame.py (PR #96685)

2024-07-01 Thread Kendal Harland via lldb-commits

https://github.com/kendalharland updated 
https://github.com/llvm/llvm-project/pull/96685

>From e3d44a2fed3d4129e245d5695c3af0c21bb7b329 Mon Sep 17 00:00:00 2001
From: kendal 
Date: Mon, 24 Jun 2024 13:42:20 -0700
Subject: [PATCH] Fix flake in TestZerothFrame.py

This test is relying on the order of `process.threads` which is
nondeterministic. By selecting the thread based on whether it is
stopped at our breakpoint we can reliably select the correct one.
---
 .../unwind/zeroth_frame/TestZerothFrame.py| 23 ---
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git 
a/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py 
b/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
index f4e883d314644..deb30669cc40e 100644
--- a/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
+++ b/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
@@ -40,28 +40,24 @@ def test(self):
 target = self.dbg.CreateTarget(exe)
 self.assertTrue(target, VALID_TARGET)
 
-bp1_line = line_number("main.c", "// Set breakpoint 1 here")
-bp2_line = line_number("main.c", "// Set breakpoint 2 here")
-
-lldbutil.run_break_set_by_file_and_line(
-self, "main.c", bp1_line, num_expected_locations=1
-)
-lldbutil.run_break_set_by_file_and_line(
-self, "main.c", bp2_line, num_expected_locations=1
-)
+main_dot_c = lldb.SBFileSpec("main.c")
+bp1 = target.BreakpointCreateBySourceRegex("// Set breakpoint 1 here", 
main_dot_c)
+bp2 = target.BreakpointCreateBySourceRegex("// Set breakpoint 2 here", 
main_dot_c)
 
 process = target.LaunchSimple(None, None, 
self.get_process_working_directory())
 self.assertTrue(process, VALID_PROCESS)
 
-thread = process.GetThreadAtIndex(0)
+thread = self.thread()
+
 if self.TraceOn():
 print("Backtrace at the first breakpoint:")
 for f in thread.frames:
 print(f)
+
 # Check that we have stopped at correct breakpoint.
 self.assertEqual(
-process.GetThreadAtIndex(0).frame[0].GetLineEntry().GetLine(),
-bp1_line,
+thread.frame[0].GetLineEntry().GetLine(),
+bp1.GetLocationAtIndex(0).GetAddress().GetLineEntry().GetLine(),
 "LLDB reported incorrect line number.",
 )
 
@@ -70,7 +66,6 @@ def test(self):
 # 'continue' command.
 process.Continue()
 
-thread = process.GetThreadAtIndex(0)
 if self.TraceOn():
 print("Backtrace at the second breakpoint:")
 for f in thread.frames:
@@ -78,7 +73,7 @@ def test(self):
 # Check that we have stopped at the breakpoint
 self.assertEqual(
 thread.frame[0].GetLineEntry().GetLine(),
-bp2_line,
+bp2.GetLocationAtIndex(0).GetAddress().GetLineEntry().GetLine(),
 "LLDB reported incorrect line number.",
 )
 # Double-check with GetPCAddress()

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


[Lldb-commits] [lldb] Fix type error when calling random.randrange with 'float' arg (PR #97328)

2024-07-01 Thread Kendal Harland via lldb-commits


@@ -75,7 +75,7 @@ def __init__(self):
 class Pipe(object):
 def __init__(self, prefix):
 while True:
-self.name = "lldb-" + str(random.randrange(1e10))
+self.name = "lldb-" + str(random.randrange(int(1e10)))

kendalharland wrote:

I would prefer to leave it as the original author wrote it if that's alright. 
I'm assuming they found the shorthand more readable

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


[Lldb-commits] [lldb] Fix test assertions in TestDAP_stepInTargets.py (PR #96687)

2024-07-01 Thread Kendal Harland via lldb-commits

kendalharland wrote:

> > I'm not sure if these names come from the demangler or debug info, but 
> > windows has different implementations for both, so it not surprising 
> > they're different. Assuming we don't care about the precise formatting of 
> > the names, we could just check whether the name of the function is in the 
> > string (and change the name to something more unique): 
> > assertIn("my_first_step_target", step_in_targets[0]["label"])
> 
> Sorry for the late follow up, I got pulled into fixing something else. I 
> think this is a simple enough solution. I'll reupload and re-ping for review.

Updated in the latest commit.

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


[Lldb-commits] [lldb] Fix test assertions in TestDAP_stepInTargets.py (PR #96687)

2024-07-01 Thread Kendal Harland via lldb-commits

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


[Lldb-commits] [lldb] Fix test assertions in TestDAP_stepInTargets.py (PR #96687)

2024-07-01 Thread Kendal Harland via lldb-commits

https://github.com/kendalharland updated 
https://github.com/llvm/llvm-project/pull/96687

>From 58adc302fe08220f60513599f8a9ff6a72ce49ac Mon Sep 17 00:00:00 2001
From: kendal 
Date: Mon, 24 Jun 2024 14:01:31 -0700
Subject: [PATCH] Fix test assertions in TestDAP_stepInTargets.py

---
 .../lldb-dap/stepInTargets/TestDAP_stepInTargets.py  | 12 +---
 lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp  |  6 +++---
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git 
a/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py 
b/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py
index 6296f6554d07e..5deb054f0915a 100644
--- a/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py
+++ b/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py
@@ -55,14 +55,12 @@ def test_basic(self):
 self.assertEqual(len(step_in_targets), 3, "expect 3 step in targets")
 
 # Verify the target names are correct.
-self.assertEqual(step_in_targets[0]["label"], "bar()", "expect bar()")
-self.assertEqual(step_in_targets[1]["label"], "bar2()", "expect 
bar2()")
-self.assertEqual(
-step_in_targets[2]["label"], "foo(int, int)", "expect foo(int, 
int)"
-)
+self.assertIn("funcB", step_in_targets[0]["label"], "expect funcB")
+self.assertIn("funcA", step_in_targets[1]["label"], "expect funcA")
+self.assertIn("foo", step_in_targets[2]["label"], "expect foo")
 
-# Choose to step into second target and verify that we are in bar2()
+# Choose to step into second target and verify that we are in funcB()
 self.stepIn(threadId=tid, targetId=step_in_targets[1]["id"], 
waitForStop=True)
 leaf_frame = self.dap_server.get_stackFrame()
 self.assertIsNotNone(leaf_frame, "expect a leaf frame")
-self.assertEqual(leaf_frame["name"], "bar2()")
+self.assertIn("funcB", leaf_frame["name"], "expect funcB")
diff --git a/lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp 
b/lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp
index d3c3dbcc139ef..a48b79af0c760 100644
--- a/lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp
+++ b/lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp
@@ -1,11 +1,11 @@
 
 int foo(int val, int extra) { return val + extra; }
 
-int bar() { return 22; }
+int funcA() { return 22; }
 
-int bar2() { return 54; }
+int funcB() { return 54; }
 
 int main(int argc, char const *argv[]) {
-  foo(bar(), bar2()); // set breakpoint here
+  foo(funcA(), funcB()); // set breakpoint here
   return 0;
 }

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


[Lldb-commits] [lldb] 781ba3c - [LLDB] Fix TestGdbRemoteConnection.py on Windows

2024-07-01 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2024-07-02T01:41:32+05:00
New Revision: 781ba3c6b0bc5e4f6b54b43cce94a4aee175ffc1

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

LOG: [LLDB] Fix TestGdbRemoteConnection.py on Windows

This fixes TestGdbRemoteConnection.py failing after PR #91570 on
AArch64 Windows LLDB buildbot.

https://lab.llvm.org/buildbot/#/builders/141/builds/376

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
index 5253839c7405d..5bd352d3ac549 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
@@ -14,7 +14,7 @@
 from textwrap import dedent
 import shutil
 import select
-
+import random
 
 def _get_support_exe(basename):
 support_dir = lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir)



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


[Lldb-commits] [lldb] [lldb] Make semantics of SupportFile equivalence explicit (PR #97126)

2024-07-01 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] dd5df27 - [lldb] Make semantics of SupportFile equivalence explicit (#97126)

2024-07-01 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-07-01T12:54:35-07:00
New Revision: dd5df27d9c6b47793b72d4c8f2a796e5d8dc343d

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

LOG: [lldb] Make semantics of SupportFile equivalence explicit (#97126)

This is an improved attempt to improve the semantics of SupportFile
equivalence, taking into account the feedback from #95606.

Pavel's comment about the lack of a concise name because the concept
isn't trivial made me realize that I don't want to abstract this concept
away behind a helper function. Instead, I opted for a rather verbose
enum that forces the caller to consider exactly what kind of comparison
is appropriate for every call.

Added: 
lldb/unittests/Utility/SupportFileTest.cpp

Modified: 
lldb/include/lldb/Utility/SupportFile.h
lldb/source/Breakpoint/BreakpointResolver.cpp
lldb/source/Commands/CommandObjectSource.cpp
lldb/source/Symbol/LineEntry.cpp
lldb/source/Symbol/LineTable.cpp
lldb/source/Target/ThreadPlanStepOverRange.cpp
lldb/source/Target/ThreadPlanStepRange.cpp
lldb/unittests/Utility/CMakeLists.txt

Removed: 




diff  --git a/lldb/include/lldb/Utility/SupportFile.h 
b/lldb/include/lldb/Utility/SupportFile.h
index 21b986dcaba28..334a0aaac2c27 100644
--- a/lldb/include/lldb/Utility/SupportFile.h
+++ b/lldb/include/lldb/Utility/SupportFile.h
@@ -30,15 +30,37 @@ class SupportFile {
 
   virtual ~SupportFile() = default;
 
-  /// Return true if both SupportFiles have the same FileSpec and, if both have
-  /// a valid Checksum, the Checksum is the same.
-  bool operator==(const SupportFile ) const {
-if (m_checksum && other.m_checksum)
-  return m_file_spec == other.m_file_spec && m_checksum == 
other.m_checksum;
-return m_file_spec == other.m_file_spec;
-  }
+  enum SupportFileEquality : uint8_t {
+eEqualFileSpec = (1u << 1),
+eEqualChecksum = (1u << 2),
+eEqualChecksumIfSet = (1u << 3),
+eEqualFileSpecAndChecksum = eEqualFileSpec | eEqualChecksum,
+eEqualFileSpecAndChecksumIfSet = eEqualFileSpec | eEqualChecksumIfSet,
+  };
+
+  bool Equal(const SupportFile ,
+ SupportFileEquality equality = eEqualFileSpecAndChecksum) const {
+assert(!(equality & eEqualChecksum & eEqualChecksumIfSet) &&
+   "eEqualChecksum and eEqualChecksumIfSet are mutually exclusive");
+
+if (equality & eEqualFileSpec) {
+  if (m_file_spec != other.m_file_spec)
+return false;
+}
 
-  bool operator!=(const SupportFile ) const { return !(*this == other); }
+if (equality & eEqualChecksum) {
+  if (m_checksum != other.m_checksum)
+return false;
+}
+
+if (equality & eEqualChecksumIfSet) {
+  if (m_checksum && other.m_checksum)
+if (m_checksum != other.m_checksum)
+  return false;
+}
+
+return true;
+  }
 
   /// Return the file name only. Useful for resolving breakpoints by file name.
   const FileSpec () const { return m_file_spec; };

diff  --git a/lldb/source/Breakpoint/BreakpointResolver.cpp 
b/lldb/source/Breakpoint/BreakpointResolver.cpp
index ff4e2a9985197..2d52cbf827ef9 100644
--- a/lldb/source/Breakpoint/BreakpointResolver.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolver.cpp
@@ -222,8 +222,9 @@ void BreakpointResolver::SetSCMatchesByLine(
 auto worklist_begin = std::partition(
 all_scs.begin(), all_scs.end(), [&](const SymbolContext ) {
   if (sc.line_entry.GetFile() == match.line_entry.GetFile() ||
-  *sc.line_entry.original_file_sp ==
-  *match.line_entry.original_file_sp) {
+  sc.line_entry.original_file_sp->Equal(
+  *match.line_entry.original_file_sp,
+  SupportFile::eEqualFileSpecAndChecksumIfSet)) {
 // When a match is found, keep track of the smallest line number.
 closest_line = std::min(closest_line, sc.line_entry.line);
 return false;

diff  --git a/lldb/source/Commands/CommandObjectSource.cpp 
b/lldb/source/Commands/CommandObjectSource.cpp
index 0c1267456a184..f54b712adfc46 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -747,13 +747,17 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 
 bool operator==(const SourceInfo ) const {
   return function == rhs.function &&
- *line_entry.original_file_sp == *rhs.line_entry.original_file_sp 
&&
+ line_entry.original_file_sp->Equal(
+ *rhs.line_entry.original_file_sp,
+ SupportFile::eEqualFileSpecAndChecksumIfSet) &&
  line_entry.line == rhs.line_entry.line;
 }
 
 bool operator!=(const SourceInfo ) const {
   return function != rhs.function ||
-   

[Lldb-commits] [lldb] [lldb/Commands] Add `scripting template list` command with auto discovery (PR #97273)

2024-07-01 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben updated 
https://github.com/llvm/llvm-project/pull/97273

>From 8e016c7aa66c4d5f7a90b5dc05b05c1838919177 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Mon, 1 Jul 2024 12:00:04 -0700
Subject: [PATCH 1/2] [lldb/Commands] Alias `script` command to `scripting
 execute`

This patch introduces a new top-level `scripting` command with an
`execute` sub-command, that basically replaces the `script` raw command.

To avoid breaking the `script` command usages, this patch also adds an
`script` alias to the `scripting execute` sub-command.

The reason behind this change is to have a top-level command that will
cover scripting related subcommands.

Signed-off-by: Med Ismail Bennani 
---
 lldb/source/Commands/CMakeLists.txt   |  2 +-
 ...tScript.cpp => CommandObjectScripting.cpp} | 44 +--
 ...bjectScript.h => CommandObjectScripting.h} | 17 ---
 lldb/source/Commands/Options.td   |  2 +-
 .../source/Interpreter/CommandInterpreter.cpp | 13 +-
 .../abbreviation/TestAbbreviations.py |  4 +-
 6 files changed, 59 insertions(+), 23 deletions(-)
 rename lldb/source/Commands/{CommandObjectScript.cpp => 
CommandObjectScripting.cpp} (68%)
 rename lldb/source/Commands/{CommandObjectScript.h => 
CommandObjectScripting.h} (71%)

diff --git a/lldb/source/Commands/CMakeLists.txt 
b/lldb/source/Commands/CMakeLists.txt
index 6a36c5376d5c5..76397227d535d 100644
--- a/lldb/source/Commands/CMakeLists.txt
+++ b/lldb/source/Commands/CMakeLists.txt
@@ -26,7 +26,7 @@ add_lldb_library(lldbCommands NO_PLUGIN_DEPENDENCIES
   CommandObjectQuit.cpp
   CommandObjectRegexCommand.cpp
   CommandObjectRegister.cpp
-  CommandObjectScript.cpp
+  CommandObjectScripting.cpp
   CommandObjectSession.cpp
   CommandObjectSettings.cpp
   CommandObjectSource.cpp
diff --git a/lldb/source/Commands/CommandObjectScript.cpp 
b/lldb/source/Commands/CommandObjectScripting.cpp
similarity index 68%
rename from lldb/source/Commands/CommandObjectScript.cpp
rename to lldb/source/Commands/CommandObjectScripting.cpp
index 25f25b8e65947..72f653690e532 100644
--- a/lldb/source/Commands/CommandObjectScript.cpp
+++ b/lldb/source/Commands/CommandObjectScripting.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectScript.cpp 
---===//
+//===-- CommandObjectScripting.cpp 
===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-#include "CommandObjectScript.h"
+#include "CommandObjectScripting.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/DataFormatters/DataVisualization.h"
 #include "lldb/Host/Config.h"
@@ -21,10 +21,10 @@
 using namespace lldb;
 using namespace lldb_private;
 
-#define LLDB_OPTIONS_script
+#define LLDB_OPTIONS_scripting_execute
 #include "CommandOptions.inc"
 
-Status CommandObjectScript::CommandOptions::SetOptionValue(
+Status CommandObjectScriptingExecute::CommandOptions::SetOptionValue(
 uint32_t option_idx, llvm::StringRef option_arg,
 ExecutionContext *execution_context) {
   Status error;
@@ -46,27 +46,29 @@ Status CommandObjectScript::CommandOptions::SetOptionValue(
   return error;
 }
 
-void CommandObjectScript::CommandOptions::OptionParsingStarting(
+void CommandObjectScriptingExecute::CommandOptions::OptionParsingStarting(
 ExecutionContext *execution_context) {
   language = lldb::eScriptLanguageNone;
 }
 
 llvm::ArrayRef
-CommandObjectScript::CommandOptions::GetDefinitions() {
-  return llvm::ArrayRef(g_script_options);
+CommandObjectScriptingExecute::CommandOptions::GetDefinitions() {
+  return llvm::ArrayRef(g_scripting_execute_options);
 }
 
-CommandObjectScript::CommandObjectScript(CommandInterpreter )
+CommandObjectScriptingExecute::CommandObjectScriptingExecute(
+CommandInterpreter )
 : CommandObjectRaw(
-  interpreter, "script",
+  interpreter, "scripting execute",
   "Invoke the script interpreter with provided code and display any "
   "results.  Start the interactive interpreter if no code is 
supplied.",
-  "script [--language  --] []") {}
+  "scripting execute [--language  --] "
+  "[]") {}
 
-CommandObjectScript::~CommandObjectScript() = default;
+CommandObjectScriptingExecute::~CommandObjectScriptingExecute() = default;
 
-void CommandObjectScript::DoExecute(llvm::StringRef command,
-CommandReturnObject ) {
+void CommandObjectScriptingExecute::DoExecute(llvm::StringRef command,
+  CommandReturnObject ) {
   // Try parsing the language option but when the command contains a raw part
   // separated by the -- delimiter.
   OptionsWithRaw raw_args(command);
@@ -111,3 +113,19 @@ void 

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

2024-07-01 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben updated 
https://github.com/llvm/llvm-project/pull/97263

>From 8e016c7aa66c4d5f7a90b5dc05b05c1838919177 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Mon, 1 Jul 2024 12:00:04 -0700
Subject: [PATCH] [lldb/Commands] Alias `script` command to `scripting execute`

This patch introduces a new top-level `scripting` command with an
`execute` sub-command, that basically replaces the `script` raw command.

To avoid breaking the `script` command usages, this patch also adds an
`script` alias to the `scripting execute` sub-command.

The reason behind this change is to have a top-level command that will
cover scripting related subcommands.

Signed-off-by: Med Ismail Bennani 
---
 lldb/source/Commands/CMakeLists.txt   |  2 +-
 ...tScript.cpp => CommandObjectScripting.cpp} | 44 +--
 ...bjectScript.h => CommandObjectScripting.h} | 17 ---
 lldb/source/Commands/Options.td   |  2 +-
 .../source/Interpreter/CommandInterpreter.cpp | 13 +-
 .../abbreviation/TestAbbreviations.py |  4 +-
 6 files changed, 59 insertions(+), 23 deletions(-)
 rename lldb/source/Commands/{CommandObjectScript.cpp => 
CommandObjectScripting.cpp} (68%)
 rename lldb/source/Commands/{CommandObjectScript.h => 
CommandObjectScripting.h} (71%)

diff --git a/lldb/source/Commands/CMakeLists.txt 
b/lldb/source/Commands/CMakeLists.txt
index 6a36c5376d5c5..76397227d535d 100644
--- a/lldb/source/Commands/CMakeLists.txt
+++ b/lldb/source/Commands/CMakeLists.txt
@@ -26,7 +26,7 @@ add_lldb_library(lldbCommands NO_PLUGIN_DEPENDENCIES
   CommandObjectQuit.cpp
   CommandObjectRegexCommand.cpp
   CommandObjectRegister.cpp
-  CommandObjectScript.cpp
+  CommandObjectScripting.cpp
   CommandObjectSession.cpp
   CommandObjectSettings.cpp
   CommandObjectSource.cpp
diff --git a/lldb/source/Commands/CommandObjectScript.cpp 
b/lldb/source/Commands/CommandObjectScripting.cpp
similarity index 68%
rename from lldb/source/Commands/CommandObjectScript.cpp
rename to lldb/source/Commands/CommandObjectScripting.cpp
index 25f25b8e65947..72f653690e532 100644
--- a/lldb/source/Commands/CommandObjectScript.cpp
+++ b/lldb/source/Commands/CommandObjectScripting.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectScript.cpp 
---===//
+//===-- CommandObjectScripting.cpp 
===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-#include "CommandObjectScript.h"
+#include "CommandObjectScripting.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/DataFormatters/DataVisualization.h"
 #include "lldb/Host/Config.h"
@@ -21,10 +21,10 @@
 using namespace lldb;
 using namespace lldb_private;
 
-#define LLDB_OPTIONS_script
+#define LLDB_OPTIONS_scripting_execute
 #include "CommandOptions.inc"
 
-Status CommandObjectScript::CommandOptions::SetOptionValue(
+Status CommandObjectScriptingExecute::CommandOptions::SetOptionValue(
 uint32_t option_idx, llvm::StringRef option_arg,
 ExecutionContext *execution_context) {
   Status error;
@@ -46,27 +46,29 @@ Status CommandObjectScript::CommandOptions::SetOptionValue(
   return error;
 }
 
-void CommandObjectScript::CommandOptions::OptionParsingStarting(
+void CommandObjectScriptingExecute::CommandOptions::OptionParsingStarting(
 ExecutionContext *execution_context) {
   language = lldb::eScriptLanguageNone;
 }
 
 llvm::ArrayRef
-CommandObjectScript::CommandOptions::GetDefinitions() {
-  return llvm::ArrayRef(g_script_options);
+CommandObjectScriptingExecute::CommandOptions::GetDefinitions() {
+  return llvm::ArrayRef(g_scripting_execute_options);
 }
 
-CommandObjectScript::CommandObjectScript(CommandInterpreter )
+CommandObjectScriptingExecute::CommandObjectScriptingExecute(
+CommandInterpreter )
 : CommandObjectRaw(
-  interpreter, "script",
+  interpreter, "scripting execute",
   "Invoke the script interpreter with provided code and display any "
   "results.  Start the interactive interpreter if no code is 
supplied.",
-  "script [--language  --] []") {}
+  "scripting execute [--language  --] "
+  "[]") {}
 
-CommandObjectScript::~CommandObjectScript() = default;
+CommandObjectScriptingExecute::~CommandObjectScriptingExecute() = default;
 
-void CommandObjectScript::DoExecute(llvm::StringRef command,
-CommandReturnObject ) {
+void CommandObjectScriptingExecute::DoExecute(llvm::StringRef command,
+  CommandReturnObject ) {
   // Try parsing the language option but when the command contains a raw part
   // separated by the -- delimiter.
   OptionsWithRaw raw_args(command);
@@ -111,3 +113,19 @@ void 

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

2024-07-01 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
a9c12e481bfef5b2913e2241486f4dd450188cd2...1f3d0498ccedc4c8adef01d44c29be8b1a78b133
 lldb/test/API/functionalities/abbreviation/TestAbbreviations.py
``





View the diff from darker here.


``diff
--- TestAbbreviations.py2024-07-01 18:53:49.00 +
+++ TestAbbreviations.py2024-07-01 18:57:53.107299 +
@@ -78,11 +78,13 @@
 self.assertFalse(result.Succeeded())
 
 # Check a command that wants the raw input.
 command_interpreter.ResolveCommand(r"""sc print("\n\n\tHello!\n")""", 
result)
 self.assertTrue(result.Succeeded())
-self.assertEqual(r"""scripting execute print("\n\n\tHello!\n")""", 
result.GetOutput())
+self.assertEqual(
+r"""scripting execute print("\n\n\tHello!\n")""", 
result.GetOutput()
+)
 
 # Prompt changing stuff should be tested, but this doesn't seem like 
the
 # right test to do it in.  It has nothing to do with aliases or 
abbreviations.
 # self.runCmd("com sou ./change_prompt.lldb")
 # self.expect("settings show prompt",

``




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


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

2024-07-01 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben updated 
https://github.com/llvm/llvm-project/pull/97263

>From 1f3d0498ccedc4c8adef01d44c29be8b1a78b133 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Mon, 1 Jul 2024 11:53:49 -0700
Subject: [PATCH] [lldb/Commands] Alias `script` command to `scripting execute`

This patch introduces a new top-level `scripting` command with an
`execute` sub-command, that basically replaces the `script` raw command.

To avoid breaking the `script` command usages, this patch also adds an
`script` alias to the `scripting execute` sub-command.

The reason behind this change is to have a top-level command that will
cover scripting related subcommands.

Signed-off-by: Med Ismail Bennani 
---
 lldb/source/Commands/CMakeLists.txt   |  2 +-
 ...tScript.cpp => CommandObjectScripting.cpp} | 44 +--
 ...bjectScript.h => CommandObjectScripting.h} | 17 ---
 lldb/source/Commands/Options.td   |  2 +-
 .../source/Interpreter/CommandInterpreter.cpp | 13 +-
 .../abbreviation/TestAbbreviations.py |  2 +-
 6 files changed, 57 insertions(+), 23 deletions(-)
 rename lldb/source/Commands/{CommandObjectScript.cpp => 
CommandObjectScripting.cpp} (68%)
 rename lldb/source/Commands/{CommandObjectScript.h => 
CommandObjectScripting.h} (71%)

diff --git a/lldb/source/Commands/CMakeLists.txt 
b/lldb/source/Commands/CMakeLists.txt
index 6a36c5376d5c5..76397227d535d 100644
--- a/lldb/source/Commands/CMakeLists.txt
+++ b/lldb/source/Commands/CMakeLists.txt
@@ -26,7 +26,7 @@ add_lldb_library(lldbCommands NO_PLUGIN_DEPENDENCIES
   CommandObjectQuit.cpp
   CommandObjectRegexCommand.cpp
   CommandObjectRegister.cpp
-  CommandObjectScript.cpp
+  CommandObjectScripting.cpp
   CommandObjectSession.cpp
   CommandObjectSettings.cpp
   CommandObjectSource.cpp
diff --git a/lldb/source/Commands/CommandObjectScript.cpp 
b/lldb/source/Commands/CommandObjectScripting.cpp
similarity index 68%
rename from lldb/source/Commands/CommandObjectScript.cpp
rename to lldb/source/Commands/CommandObjectScripting.cpp
index 25f25b8e65947..72f653690e532 100644
--- a/lldb/source/Commands/CommandObjectScript.cpp
+++ b/lldb/source/Commands/CommandObjectScripting.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectScript.cpp 
---===//
+//===-- CommandObjectScripting.cpp 
===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-#include "CommandObjectScript.h"
+#include "CommandObjectScripting.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/DataFormatters/DataVisualization.h"
 #include "lldb/Host/Config.h"
@@ -21,10 +21,10 @@
 using namespace lldb;
 using namespace lldb_private;
 
-#define LLDB_OPTIONS_script
+#define LLDB_OPTIONS_scripting_execute
 #include "CommandOptions.inc"
 
-Status CommandObjectScript::CommandOptions::SetOptionValue(
+Status CommandObjectScriptingExecute::CommandOptions::SetOptionValue(
 uint32_t option_idx, llvm::StringRef option_arg,
 ExecutionContext *execution_context) {
   Status error;
@@ -46,27 +46,29 @@ Status CommandObjectScript::CommandOptions::SetOptionValue(
   return error;
 }
 
-void CommandObjectScript::CommandOptions::OptionParsingStarting(
+void CommandObjectScriptingExecute::CommandOptions::OptionParsingStarting(
 ExecutionContext *execution_context) {
   language = lldb::eScriptLanguageNone;
 }
 
 llvm::ArrayRef
-CommandObjectScript::CommandOptions::GetDefinitions() {
-  return llvm::ArrayRef(g_script_options);
+CommandObjectScriptingExecute::CommandOptions::GetDefinitions() {
+  return llvm::ArrayRef(g_scripting_execute_options);
 }
 
-CommandObjectScript::CommandObjectScript(CommandInterpreter )
+CommandObjectScriptingExecute::CommandObjectScriptingExecute(
+CommandInterpreter )
 : CommandObjectRaw(
-  interpreter, "script",
+  interpreter, "scripting execute",
   "Invoke the script interpreter with provided code and display any "
   "results.  Start the interactive interpreter if no code is 
supplied.",
-  "script [--language  --] []") {}
+  "scripting execute [--language  --] "
+  "[]") {}
 
-CommandObjectScript::~CommandObjectScript() = default;
+CommandObjectScriptingExecute::~CommandObjectScriptingExecute() = default;
 
-void CommandObjectScript::DoExecute(llvm::StringRef command,
-CommandReturnObject ) {
+void CommandObjectScriptingExecute::DoExecute(llvm::StringRef command,
+  CommandReturnObject ) {
   // Try parsing the language option but when the command contains a raw part
   // separated by the -- delimiter.
   OptionsWithRaw raw_args(command);
@@ -111,3 +113,19 @@ void 

[Lldb-commits] [lldb] 0323d8d - [lldb-dap] Bump the version to 0.2.2

2024-07-01 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2024-07-01T11:34:05-07:00
New Revision: 0323d8d83ccad9a74df36d2662e96aa0f56e3060

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

LOG: [lldb-dap] Bump the version to 0.2.2

Bump the lldb-dap version to 0.2.2.

Added: 


Modified: 
lldb/tools/lldb-dap/package.json

Removed: 




diff  --git a/lldb/tools/lldb-dap/package.json 
b/lldb/tools/lldb-dap/package.json
index 62cf69b359728..fd5de30ed28dd 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -1,7 +1,7 @@
 {
   "name": "lldb-dap",
   "displayName": "LLDB DAP",
-  "version": "0.2.1",
+  "version": "0.2.2",
   "publisher": "llvm-vs-code-extensions",
   "homepage": "https://lldb.llvm.org;,
   "description": "LLDB debugging from VSCode",



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


[Lldb-commits] [clang] [lldb] [clang][AST] fix ast-print of extern with >=2 declarators, fixed (PR #93913)

2024-07-01 Thread Aaron Ballman via lldb-commits

AaronBallman wrote:

I reverted these changes in 71ff749d6b9aee70c6d26d9781b9f70bf6a8c445 so 
@temyurchenko can investigate the issues.

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


[Lldb-commits] [lldb] 71ff749 - Revert "[clang][AST] fix ast-print of extern with >=2 declarators"

2024-07-01 Thread Aaron Ballman via lldb-commits

Author: Aaron Ballman
Date: 2024-07-01T14:19:37-04:00
New Revision: 71ff749d6b9aee70c6d26d9781b9f70bf6a8c445

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

LOG: Revert "[clang][AST] fix ast-print of extern  with >=2 declarators"

This reverts commit 48f13d48a88c14acbaea7c3ee05018bb173fb360.

It broke some external bots:
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6805/console
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8743609724828014497/+/u/clang/build/stdout

Added: 


Modified: 
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclPrinter.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp

Removed: 
clang/test/AST/ast-print-language-linkage.cpp



diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index ff3325543919f..16ed6d88d1cb1 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -576,16 +576,13 @@ template  static bool 
isFirstInExternCContext(T *D) {
   return First->isInExternCContext();
 }
 
-static bool isUnbracedLanguageLinkage(const DeclContext *DC) {
-  if (const auto *SD = dyn_cast_if_present(DC))
-return !SD->hasBraces();
+static bool isSingleLineLanguageLinkage(const Decl ) {
+  if (const auto *SD = dyn_cast(D.getDeclContext()))
+if (!SD->hasBraces())
+  return true;
   return false;
 }
 
-static bool hasUnbracedLanguageLinkage(const Decl ) {
-  return isUnbracedLanguageLinkage(D.getDeclContext());
-}
-
 static bool isDeclaredInModuleInterfaceOrPartition(const NamedDecl *D) {
   if (auto *M = D->getOwningModule())
 return M->isInterfaceOrPartition();
@@ -647,7 +644,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl 
*D,
 
   if (Var->getStorageClass() != SC_Extern &&
   Var->getStorageClass() != SC_PrivateExtern &&
-  !hasUnbracedLanguageLinkage(*Var))
+  !isSingleLineLanguageLinkage(*Var))
 return LinkageInfo::internal();
 }
 
@@ -2121,12 +2118,6 @@ VarDecl::VarDecl(Kind DK, ASTContext , DeclContext *DC,
 "ParmVarDeclBitfields too large!");
   static_assert(sizeof(NonParmVarDeclBitfields) <= sizeof(unsigned),
 "NonParmVarDeclBitfields too large!");
-
-  // The unbraced `extern "C"` invariant is that the storage class
-  // specifier is omitted in the source code, i.e. SC_None (but is,
-  // implicitly, `extern`).
-  assert(!isUnbracedLanguageLinkage(DC) || SC == SC_None);
-
   AllBits = 0;
   VarDeclBits.SClass = SC;
   // Everything else is implicitly initialized to false.
@@ -2310,7 +2301,7 @@ VarDecl::isThisDeclarationADefinition(ASTContext ) 
const {
   //   A declaration directly contained in a linkage-specification is treated
   //   as if it contains the extern specifier for the purpose of determining
   //   the linkage of the declared name and whether it is a definition.
-  if (hasUnbracedLanguageLinkage(*this))
+  if (isSingleLineLanguageLinkage(*this))
 return DeclarationOnly;
 
   // C99 6.9.2p2:
@@ -3036,12 +3027,6 @@ FunctionDecl::FunctionDecl(Kind DK, ASTContext , 
DeclContext *DC,
   DeclContext(DK), redeclarable_base(C), Body(), ODRHash(0),
   EndRangeLoc(NameInfo.getEndLoc()), DNLoc(NameInfo.getInfo()) {
   assert(T.isNull() || T->isFunctionType());
-
-  // The unbraced `extern "C"` invariant is that the storage class
-  // specifier is omitted in the source code, i.e. SC_None (but is,
-  // implicitly, `extern`).
-  assert(!isUnbracedLanguageLinkage(DC) || S == SC_None);
-
   FunctionDeclBits.SClass = S;
   FunctionDeclBits.IsInline = isInlineSpecified;
   FunctionDeclBits.IsInlineSpecified = isInlineSpecified;

diff  --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index b8e0ef1b40358..26773a69ab9ac 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -633,7 +633,7 @@ static void printExplicitSpecifier(ExplicitSpecifier ES, 
llvm::raw_ostream ,
   Out << Proto;
 }
 
-static void maybePrintTagKeywordIfSupressingScopes(PrintingPolicy ,
+static void MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy ,
QualType T,
llvm::raw_ostream ) {
   StringRef prefix = T->isClassType()   ? "class "
@@ -643,22 +643,6 @@ static void 
maybePrintTagKeywordIfSupressingScopes(PrintingPolicy ,
   Out << prefix;
 }
 
-/// Return the language of the linkage spec of `D`, if applicable.
-///
-/// \Return - "C" if `D` has been declared with unbraced `extern "C"`
-/// - "C++" if `D` has been declared with unbraced `extern "C++"`
-/// - nullptr in any other 

[Lldb-commits] [lldb] Fix type error when calling random.randrange with 'float' arg (PR #97328)

2024-07-01 Thread Jonas Devlieghere via lldb-commits


@@ -75,7 +75,7 @@ def __init__(self):
 class Pipe(object):
 def __init__(self, prefix):
 while True:
-self.name = "lldb-" + str(random.randrange(1e10))
+self.name = "lldb-" + str(random.randrange(int(1e10)))

JDevlieghere wrote:

How about `random.randrange(100)`? 

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


[Lldb-commits] [clang] [lldb] [clang][AST] fix ast-print of extern with >=2 declarators, fixed (PR #93913)

2024-07-01 Thread via lldb-commits

Prabhuk wrote:

I am part of the Fuchsia toolchain team. Our Clang toolchain CI builders crash 
and I suspect this change is the reason. I am verifying that. But here's the 
log:

https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8743609724828014497/+/u/clang/build/stdout

and the crash:

```
[1562/1592](22) Building CXX object 
compiler-rt/lib/orc/CMakeFiles/RTOrc.x86_64.dir/dlfcn_wrapper.cpp.obj
FAILED: compiler-rt/lib/orc/CMakeFiles/RTOrc.x86_64.dir/dlfcn_wrapper.cpp.obj 
/b/s/w/ir/x/w/llvm_build/./bin/clang-cl --target=x86_64-pc-windows-msvc  
/nologo -TP -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS 
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS 
-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/orc/.. 
-I/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/orc/../../include -Xclang 
-ivfsoverlay -Xclang /b/s/w/ir/cache/windows_sdk/llvm-vfsoverlay.yaml 
/winsysroot /b/s/w/ir/cache/windows_sdk /Zc:inline /Zc:__cplusplus /Oi /bigobj 
/permissive- -Werror=unguarded-availability-new -wd4141 -wd4146 -wd4244 -wd4267 
-wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 
-wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 
-wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 
-wd5105 -wd4324 -w14062 -we4238 /Gw /W4 -Wno-unused-parameter /O2 /Ob1  
-std:c++17 -MD -Zi -fno-builtin -fno-sanitize=safe-stack -fno-lto /Oy- /GS- 
/Zc:threadSafeInit- -Wthread-safety -Wthread-safety-reference 
-Wthread-safety-beta /Z7 -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions 
/wd4146 /wd4291 /wd4391 /wd4722 /wd4800 -ftrivial-auto-var-init=pattern 
-I/b/s/w/ir/x/w/llvm_build/include 
-I/b/s/w/ir/x/w/llvm-llvm-project/llvm/include /D_HAS_EXCEPTIONS=0 
/showIncludes 
/Focompiler-rt/lib/orc/CMakeFiles/RTOrc.x86_64.dir/dlfcn_wrapper.cpp.obj 
/Fdcompiler-rt/lib/orc/CMakeFiles/RTOrc.x86_64.dir/ -c -- 
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/orc/dlfcn_wrapper.cpp
clang-cl: clang/lib/AST/Decl.cpp:2128: clang::VarDecl::VarDecl(Kind, ASTContext 
&, DeclContext *, SourceLocation, SourceLocation, const IdentifierInfo *, 
QualType, TypeSourceInfo *, StorageClass): Assertion 
`!isUnbracedLanguageLinkage(DC) || SC == SC_None' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: /b/s/w/ir/x/w/llvm_build/./bin/clang-cl 
--target=x86_64-pc-windows-msvc /nologo -TP -DUNICODE 
-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS 
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS 
-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/orc/.. 
-I/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/orc/../../include -Xclang 
-ivfsoverlay -Xclang /b/s/w/ir/cache/windows_sdk/llvm-vfsoverlay.yaml 
/winsysroot /b/s/w/ir/cache/windows_sdk /Zc:inline /Zc:__cplusplus /Oi /bigobj 
/permissive- -Werror=unguarded-availability-new -wd4141 -wd4146 -wd4244 -wd4267 
-wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 
-wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 
-wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 
-wd5105 -wd4324 -w14062 -we4238 /Gw /W4 -Wno-unused-parameter /O2 /Ob1 
-std:c++17 -MD -Zi -fno-builtin -fno-sanitize=safe-stack -fno-lto /Oy- /GS- 
/Zc:threadSafeInit- -Wthread-safety -Wthread-safety-reference 
-Wthread-safety-beta /Z7 -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions 
/wd4146 /wd4291 /wd4391 /wd4722 /wd4800 -ftrivial-auto-var-init=pattern 
-I/b/s/w/ir/x/w/llvm_build/include 
-I/b/s/w/ir/x/w/llvm-llvm-project/llvm/include /D_HAS_EXCEPTIONS=0 
/showIncludes 
/Focompiler-rt/lib/orc/CMakeFiles/RTOrc.x86_64.dir/dlfcn_wrapper.cpp.obj 
/Fdcompiler-rt/lib/orc/CMakeFiles/RTOrc.x86_64.dir/ -c -- 
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/orc/dlfcn_wrapper.cpp
1.  /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/orc/common.h:37:75: 
current parser token ';'
#0 0x55e9c8d476d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/b/s/w/ir/x/w/llvm_build/./bin/clang-cl+0x8abb6d8)
clang-cl: error: clang frontend command failed with exit code 134 (use -v to 
see invocation)
Fuchsia clang version 19.0.0git (https://llvm.googlesource.com/llvm-project 
0d88f662ff4db7e78a6c48db79ef62c5228d5f2a)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: /b/s/w/ir/x/w/llvm_build/bin
Build config: +assertions
clang-cl: note: diagnostic msg: 

```

https://github.com/llvm/llvm-project/pull/93913
___

[Lldb-commits] [lldb] [lldb] Don't unregister a listener that's being destroyed (PR #97300)

2024-07-01 Thread via lldb-commits

jimingham wrote:

This LGTM.

W.R.T. your comment about Primary Listeners...

For the most part, Broadcaster classes don't actually need Listeners to 
function.  The breakpoint system can work just fine if no one is listening to 
breakpoint changed events on the target.  So it never sets a PrimaryListener, 
and just ends up with a series of Secondary Listeners.

But there is one case where this is not true, which is the Process class.  If 
no one is listening to Process events, then execution control in lldb doesn't 
work.  Since that really doesn't make sense, we require Processes be created 
with a primary listener, and just so we don't have to reason about what to do 
if it goes away, the Process keeps it alive.  

Of course, just holding the primary listener as a shared pointer only solves 
half the problem.  It doesn't ensure that the Listener is draining the queue.  
But I don't see how it can be the Process class's job to make sure that happens.

Anyway, having a primary listener should be the uncommon case, and should only 
occur when the Broadcaster has to have a Listener to cooperate with to do its 
job.

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


[Lldb-commits] [lldb] [lldb/docs] Add scripting extensions documentation to the website (PR #97262)

2024-07-01 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere commented:

I'm excited to see these extension points getting documented! What would make 
this even more valuable is having a page that documents all of LLDB's extension 
points (and explains the duality between scripting LLDB interactions vs 
scripting LLDB's behavior) and explain what you can use them for and how to do 
that. Basically the points you made in your EuroLLVM talk, but in website form. 
The Python Reference page already covers a bit of that so that could serve as a 
starting point. 

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


[Lldb-commits] [lldb] [lldb/docs] Add scripting extensions documentation to the website (PR #97262)

2024-07-01 Thread Jonas Devlieghere via lldb-commits


@@ -11,6 +11,65 @@ some of these things by going through an example, explaining 
how to use
 Python scripting to find a bug in a program that searches for text in a
 large binary tree.
 
+Operating System Thread Plugins
+---
+
+.. automodapi:: lldb.plugins.operating_system
+:no-heading:
+:members:
+:undoc-members:
+:skip: command
+:skip: declaration
+:skip: in_range
+:skip: is_numeric_type
+:skip: lldb_iter
+:no-inheritance-diagram:
+
+Scripted Process Plugins
+---
+
+.. automodapi:: lldb.plugins.scripted_process
+:no-heading:
+:members:
+:undoc-members:
+:skip: ABCMeta
+:skip: command
+:skip: declaration
+:skip: in_range
+:skip: is_numeric_type
+:skip: lldb_iter
+:no-inheritance-diagram:

JDevlieghere wrote:

I don't think you meant to add this to the [Python 
Scripting](https://lldb.llvm.org/use/python.html) page as this is a tutorial. 
The automatically generated documentation should probably end up on the [Python 
API](https://lldb.llvm.org/python_api.html) page. But you probably also want to 
have a page that explains what these things are, and how you'd use them. It 
seems like the [Python 
Reference](https://lldb.llvm.org/use/python-reference.html) page would be best 
suited for that. 

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


[Lldb-commits] [lldb] [lldb/docs] Add scripting extensions documentation to the website (PR #97262)

2024-07-01 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] Fix type error when calling random.randrange with 'float' arg (PR #97328)

2024-07-01 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Kendal Harland (kendalharland)


Changes

This test only runs on Windows and fails because we're passing a literal of the 
wrong type to random.randrange.

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


1 Files Affected:

- (modified) 
lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py (+1-1) 


``diff
diff --git 
a/lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py 
b/lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py
index 853b7ad5ef290..f31a57b767c72 100644
--- a/lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py
+++ b/lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py
@@ -75,7 +75,7 @@ def __init__(self):
 class Pipe(object):
 def __init__(self, prefix):
 while True:
-self.name = "lldb-" + str(random.randrange(1e10))
+self.name = "lldb-" + str(random.randrange(int(1e10)))
 full_name = ".\\pipe\\" + self.name
 self._handle = CreateNamedPipe(
 full_name,

``




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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-07-01 Thread via lldb-commits

jimingham wrote:

> A high-level concern that I have with this is the grammar is full of 
> C++-specific nodes, which is not something I would like to see in living in 
> `Core`. Have we previously reached any consensus on how we want to handle 
> different languages in DIL? I would be more comfortable with moving most of 
> this into the `Plugins/Language/CPlusPlus` directory and having only a 
> generic, language-agnostic driver live in `Core`.

My .02:

The problem here is that the commands that use the DIL often have no idea what 
language the path expression they are being asked to parse is going to end up 
being.  

`(lldb) target var some_DIL_expression
`

could find C/ObjC/C++/Rust/Swift variables that match that expression.

The idea for the DIL is to have enough syntax to express sensible data lookup 
and presentation that would cover the variety of languages we support.  That's 
going to end up looking like the languages we are using it to model, but it 
shouldn't be driven by them.  I think that's better than having the DIL have 
language specific variants and the user somehow has to know to pick the right 
one for the context.

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


[Lldb-commits] [lldb] Fix type error when calling random.randrange with 'float' arg (PR #97328)

2024-07-01 Thread Kendal Harland via lldb-commits

https://github.com/kendalharland updated 
https://github.com/llvm/llvm-project/pull/97328

>From 108865deb28016f6ebe7c507e082e0998a4d4839 Mon Sep 17 00:00:00 2001
From: kendal 
Date: Mon, 1 Jul 2024 10:33:51 -0700
Subject: [PATCH] Fix type error when calling random.randrange with 'float' arg

---
 .../tools/lldb-server/commandline/TestGdbRemoteConnection.py| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py 
b/lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py
index 853b7ad5ef290..f31a57b767c72 100644
--- a/lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py
+++ b/lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py
@@ -75,7 +75,7 @@ def __init__(self):
 class Pipe(object):
 def __init__(self, prefix):
 while True:
-self.name = "lldb-" + str(random.randrange(1e10))
+self.name = "lldb-" + str(random.randrange(int(1e10)))
 full_name = ".\\pipe\\" + self.name
 self._handle = CreateNamedPipe(
 full_name,

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


[Lldb-commits] [lldb] Fix type error when calling random.randrange with 'float' arg (PR #97328)

2024-07-01 Thread via lldb-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[Lldb-commits] [lldb] Fix type error when calling random.randrange with 'float' arg (PR #97328)

2024-07-01 Thread Kendal Harland via lldb-commits

https://github.com/kendalharland created 
https://github.com/llvm/llvm-project/pull/97328

This test only runs on Windows and fails because we're passing a literal of the 
wrong type to random.randrange.

>From 68c7fe6a0bf4a2385587a563c06892cd7b4eaea8 Mon Sep 17 00:00:00 2001
From: kendal 
Date: Mon, 1 Jul 2024 10:20:08 -0700
Subject: [PATCH 1/2] Disable TestUseSourceCache on Windows amd64

This test also fails on Windows amd64, although it is only
disabled for aarch64.
---
 .../commands/settings/use_source_cache/TestUseSourceCache.py| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py 
b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
index c54345af4994c..421599080a9e5 100644
--- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
+++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
@@ -18,7 +18,7 @@ def test_set_use_source_cache_false(self):
 self.set_use_source_cache_and_test(False)
 
 @skipIf(hostoslist=no_match(["windows"]))
-@skipIf(oslist=["windows"], archs=["aarch64"])  # Fails on windows 11
+@skipIf(oslist=["windows"])  # Fails on windows 11
 def test_set_use_source_cache_true(self):
 """Test that after 'set use-source-cache false', files are locked."""
 self.set_use_source_cache_and_test(True)

>From b8830b5c963e2b59d7265bc84473c5973ac1258f Mon Sep 17 00:00:00 2001
From: kendal 
Date: Mon, 1 Jul 2024 10:33:51 -0700
Subject: [PATCH 2/2] Fix type error when calling random.randrange with 'float'
 arg

---
 .../tools/lldb-server/commandline/TestGdbRemoteConnection.py| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py 
b/lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py
index 853b7ad5ef290..f31a57b767c72 100644
--- a/lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py
+++ b/lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py
@@ -75,7 +75,7 @@ def __init__(self):
 class Pipe(object):
 def __init__(self, prefix):
 while True:
-self.name = "lldb-" + str(random.randrange(1e10))
+self.name = "lldb-" + str(random.randrange(int(1e10)))
 full_name = ".\\pipe\\" + self.name
 self._handle = CreateNamedPipe(
 full_name,

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


[Lldb-commits] [clang] [lldb] [clang][AST] fix ast-print of extern with >=2 declarators, fixed (PR #93913)

2024-07-01 Thread Chelsea Cassanova via lldb-commits

chelcassanova wrote:

Hey! Looks like this commit broke some tests on the LLDB macOS buildbots: 
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6805/console

```
Assertion failed: (!isUnbracedLanguageLinkage(DC) || SC == SC_None), function 
VarDecl, file Decl.cpp, line 2128.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace.
Stack dump:
0.  :1:1: current parser token 'sum'
1.  :44:1: parsing function body '$__lldb_expr'
2.  :44:1: in compound statement ('{}')
```

In the tests
```
lldb-api :: commands/expression/dont_allow_jit/TestAllowJIT.py
  lldb-api :: commands/expression/entry-bp/TestExprEntryBP.py
  lldb-api :: commands/expression/result_numbering/TestResultNumbering.py
```

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


[Lldb-commits] [lldb] Disable TestUseSourceCache on Windows (PR #97324)

2024-07-01 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Kendal Harland (kendalharland)


Changes

This test also fails on Windows amd64, although it is only disabled for aarch64.

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


1 Files Affected:

- (modified) 
lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py (+1-1) 


``diff
diff --git 
a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py 
b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
index c54345af4994c..421599080a9e5 100644
--- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
+++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
@@ -18,7 +18,7 @@ def test_set_use_source_cache_false(self):
 self.set_use_source_cache_and_test(False)
 
 @skipIf(hostoslist=no_match(["windows"]))
-@skipIf(oslist=["windows"], archs=["aarch64"])  # Fails on windows 11
+@skipIf(oslist=["windows"])  # Fails on windows 11
 def test_set_use_source_cache_true(self):
 """Test that after 'set use-source-cache false', files are locked."""
 self.set_use_source_cache_and_test(True)

``




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


[Lldb-commits] [lldb] Disable TestUseSourceCache on Windows (PR #97324)

2024-07-01 Thread Kendal Harland via lldb-commits

https://github.com/kendalharland updated 
https://github.com/llvm/llvm-project/pull/97324

>From 68c7fe6a0bf4a2385587a563c06892cd7b4eaea8 Mon Sep 17 00:00:00 2001
From: kendal 
Date: Mon, 1 Jul 2024 10:20:08 -0700
Subject: [PATCH] Disable TestUseSourceCache on Windows amd64

This test also fails on Windows amd64, although it is only
disabled for aarch64.
---
 .../commands/settings/use_source_cache/TestUseSourceCache.py| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py 
b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
index c54345af4994c..421599080a9e5 100644
--- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
+++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
@@ -18,7 +18,7 @@ def test_set_use_source_cache_false(self):
 self.set_use_source_cache_and_test(False)
 
 @skipIf(hostoslist=no_match(["windows"]))
-@skipIf(oslist=["windows"], archs=["aarch64"])  # Fails on windows 11
+@skipIf(oslist=["windows"])  # Fails on windows 11
 def test_set_use_source_cache_true(self):
 """Test that after 'set use-source-cache false', files are locked."""
 self.set_use_source_cache_and_test(True)

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


[Lldb-commits] [lldb] Disable TestUseSourceCache on Windows (PR #97324)

2024-07-01 Thread via lldb-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[Lldb-commits] [lldb] Disable TestUseSourceCache on Windows (PR #97324)

2024-07-01 Thread Kendal Harland via lldb-commits

https://github.com/kendalharland created 
https://github.com/llvm/llvm-project/pull/97324

This test also fails on Windows amd64, although it is only disabled for aarch64.

>From 1d2c11e18e833104279fa6a005e4a64bb7be6216 Mon Sep 17 00:00:00 2001
From: kendal 
Date: Mon, 24 Jun 2024 13:42:20 -0700
Subject: [PATCH 1/2] Fix flake in TestZerothFrame.py

This test is relying on the order of `process.threads` which is
nondeterministic. By selecting the thread based on whether it is
stopped at our breakpoint we can reliably select the correct one.
---
 .../unwind/zeroth_frame/TestZerothFrame.py| 23 ---
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git 
a/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py 
b/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
index f4e883d314644..deb30669cc40e 100644
--- a/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
+++ b/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
@@ -40,28 +40,24 @@ def test(self):
 target = self.dbg.CreateTarget(exe)
 self.assertTrue(target, VALID_TARGET)
 
-bp1_line = line_number("main.c", "// Set breakpoint 1 here")
-bp2_line = line_number("main.c", "// Set breakpoint 2 here")
-
-lldbutil.run_break_set_by_file_and_line(
-self, "main.c", bp1_line, num_expected_locations=1
-)
-lldbutil.run_break_set_by_file_and_line(
-self, "main.c", bp2_line, num_expected_locations=1
-)
+main_dot_c = lldb.SBFileSpec("main.c")
+bp1 = target.BreakpointCreateBySourceRegex("// Set breakpoint 1 here", 
main_dot_c)
+bp2 = target.BreakpointCreateBySourceRegex("// Set breakpoint 2 here", 
main_dot_c)
 
 process = target.LaunchSimple(None, None, 
self.get_process_working_directory())
 self.assertTrue(process, VALID_PROCESS)
 
-thread = process.GetThreadAtIndex(0)
+thread = self.thread()
+
 if self.TraceOn():
 print("Backtrace at the first breakpoint:")
 for f in thread.frames:
 print(f)
+
 # Check that we have stopped at correct breakpoint.
 self.assertEqual(
-process.GetThreadAtIndex(0).frame[0].GetLineEntry().GetLine(),
-bp1_line,
+thread.frame[0].GetLineEntry().GetLine(),
+bp1.GetLocationAtIndex(0).GetAddress().GetLineEntry().GetLine(),
 "LLDB reported incorrect line number.",
 )
 
@@ -70,7 +66,6 @@ def test(self):
 # 'continue' command.
 process.Continue()
 
-thread = process.GetThreadAtIndex(0)
 if self.TraceOn():
 print("Backtrace at the second breakpoint:")
 for f in thread.frames:
@@ -78,7 +73,7 @@ def test(self):
 # Check that we have stopped at the breakpoint
 self.assertEqual(
 thread.frame[0].GetLineEntry().GetLine(),
-bp2_line,
+bp2.GetLocationAtIndex(0).GetAddress().GetLineEntry().GetLine(),
 "LLDB reported incorrect line number.",
 )
 # Double-check with GetPCAddress()

>From e0c2a42a215948a9f77524cc101e76d7c0eddb56 Mon Sep 17 00:00:00 2001
From: kendal 
Date: Mon, 1 Jul 2024 10:20:08 -0700
Subject: [PATCH 2/2] Disable TestUseSourceCache on Windows amd64

This test also fails on Windows amd64, although it is only
disabled for aarch64.
---
 .../commands/settings/use_source_cache/TestUseSourceCache.py| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py 
b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
index c54345af4994c..421599080a9e5 100644
--- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
+++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
@@ -18,7 +18,7 @@ def test_set_use_source_cache_false(self):
 self.set_use_source_cache_and_test(False)
 
 @skipIf(hostoslist=no_match(["windows"]))
-@skipIf(oslist=["windows"], archs=["aarch64"])  # Fails on windows 11
+@skipIf(oslist=["windows"])  # Fails on windows 11
 def test_set_use_source_cache_true(self):
 """Test that after 'set use-source-cache false', files are locked."""
 self.set_use_source_cache_and_test(True)

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


[Lldb-commits] [lldb] [lldb] Make semantics of SupportFile equivalence explicit (PR #97126)

2024-07-01 Thread Jonas Devlieghere via lldb-commits

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

>From 0c39366879c56ceb0ef6b021d8098bc73e26445b Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 28 Jun 2024 16:50:05 -0700
Subject: [PATCH 1/3] [lldb] Make semantics of SupportFile equivalence explicit

This is an improved attempt to improve the semantics of SupportFile
equivalence, taking into account the feedback from #95606.

Pavel's comment about the lack of a concise name because the concept
isn't trivial made me realize that I don't want to abstract this concept
away behind a helper function. Instead, I opted for a rather verbose
enum that forces the caller to consider exactly what kind of comparison
is appropriate for every call.
---
 lldb/include/lldb/Utility/SupportFile.h   | 39 +++
 lldb/source/Breakpoint/BreakpointResolver.cpp |  5 ++-
 lldb/source/Commands/CommandObjectSource.cpp  |  8 +++-
 lldb/source/Symbol/LineEntry.cpp  |  3 +-
 lldb/source/Symbol/LineTable.cpp  |  2 +-
 .../source/Target/ThreadPlanStepOverRange.cpp | 15 ---
 lldb/source/Target/ThreadPlanStepRange.cpp|  5 ++-
 7 files changed, 55 insertions(+), 22 deletions(-)

diff --git a/lldb/include/lldb/Utility/SupportFile.h 
b/lldb/include/lldb/Utility/SupportFile.h
index 21b986dcaba28..4b672684e4b4e 100644
--- a/lldb/include/lldb/Utility/SupportFile.h
+++ b/lldb/include/lldb/Utility/SupportFile.h
@@ -11,6 +11,7 @@
 
 #include "lldb/Utility/Checksum.h"
 #include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Flags.h"
 
 namespace lldb_private {
 
@@ -30,15 +31,37 @@ class SupportFile {
 
   virtual ~SupportFile() = default;
 
-  /// Return true if both SupportFiles have the same FileSpec and, if both have
-  /// a valid Checksum, the Checksum is the same.
-  bool operator==(const SupportFile ) const {
-if (m_checksum && other.m_checksum)
-  return m_file_spec == other.m_file_spec && m_checksum == 
other.m_checksum;
-return m_file_spec == other.m_file_spec;
-  }
+  enum SupportFileEquality : uint8_t {
+eEqualFileSpec = (1u << 1),
+eEqualChecksum = (1u << 2),
+eEqualChecksumIfSet = (1u << 3),
+eEqualFileSpecAndChecksum = eEqualFileSpec | eEqualChecksum,
+eEqualFileSpecAndChecksumIfSet = eEqualFileSpec | eEqualChecksumIfSet,
+  };
+
+  bool Equal(const SupportFile ,
+ SupportFileEquality equality = eEqualFileSpecAndChecksum) const {
+assert(!(equality & eEqualChecksum & eEqualChecksumIfSet) &&
+   "eEqualChecksum and eEqualChecksumIfSet are mutually exclusive");
+
+if (equality & eEqualFileSpec) {
+  if (m_file_spec != other.m_file_spec)
+return false;
+}
 
-  bool operator!=(const SupportFile ) const { return !(*this == other); }
+if (equality & eEqualChecksum) {
+  if (m_checksum != other.m_checksum)
+return false;
+}
+
+if (equality & eEqualChecksumIfSet) {
+  if (m_checksum && other.m_checksum)
+if (m_checksum != other.m_checksum)
+  return false;
+}
+
+return true;
+  }
 
   /// Return the file name only. Useful for resolving breakpoints by file name.
   const FileSpec () const { return m_file_spec; };
diff --git a/lldb/source/Breakpoint/BreakpointResolver.cpp 
b/lldb/source/Breakpoint/BreakpointResolver.cpp
index ff4e2a9985197..2d52cbf827ef9 100644
--- a/lldb/source/Breakpoint/BreakpointResolver.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolver.cpp
@@ -222,8 +222,9 @@ void BreakpointResolver::SetSCMatchesByLine(
 auto worklist_begin = std::partition(
 all_scs.begin(), all_scs.end(), [&](const SymbolContext ) {
   if (sc.line_entry.GetFile() == match.line_entry.GetFile() ||
-  *sc.line_entry.original_file_sp ==
-  *match.line_entry.original_file_sp) {
+  sc.line_entry.original_file_sp->Equal(
+  *match.line_entry.original_file_sp,
+  SupportFile::eEqualFileSpecAndChecksumIfSet)) {
 // When a match is found, keep track of the smallest line number.
 closest_line = std::min(closest_line, sc.line_entry.line);
 return false;
diff --git a/lldb/source/Commands/CommandObjectSource.cpp 
b/lldb/source/Commands/CommandObjectSource.cpp
index 0c1267456a184..f54b712adfc46 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -747,13 +747,17 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 
 bool operator==(const SourceInfo ) const {
   return function == rhs.function &&
- *line_entry.original_file_sp == *rhs.line_entry.original_file_sp 
&&
+ line_entry.original_file_sp->Equal(
+ *rhs.line_entry.original_file_sp,
+ SupportFile::eEqualFileSpecAndChecksumIfSet) &&
  line_entry.line == rhs.line_entry.line;
 }
 
 bool operator!=(const SourceInfo ) const {
   return function != 

[Lldb-commits] [lldb] [lldb] Make semantics of SupportFile equivalence explicit (PR #97126)

2024-07-01 Thread Jonas Devlieghere via lldb-commits

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

>From 0c39366879c56ceb0ef6b021d8098bc73e26445b Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 28 Jun 2024 16:50:05 -0700
Subject: [PATCH 1/2] [lldb] Make semantics of SupportFile equivalence explicit

This is an improved attempt to improve the semantics of SupportFile
equivalence, taking into account the feedback from #95606.

Pavel's comment about the lack of a concise name because the concept
isn't trivial made me realize that I don't want to abstract this concept
away behind a helper function. Instead, I opted for a rather verbose
enum that forces the caller to consider exactly what kind of comparison
is appropriate for every call.
---
 lldb/include/lldb/Utility/SupportFile.h   | 39 +++
 lldb/source/Breakpoint/BreakpointResolver.cpp |  5 ++-
 lldb/source/Commands/CommandObjectSource.cpp  |  8 +++-
 lldb/source/Symbol/LineEntry.cpp  |  3 +-
 lldb/source/Symbol/LineTable.cpp  |  2 +-
 .../source/Target/ThreadPlanStepOverRange.cpp | 15 ---
 lldb/source/Target/ThreadPlanStepRange.cpp|  5 ++-
 7 files changed, 55 insertions(+), 22 deletions(-)

diff --git a/lldb/include/lldb/Utility/SupportFile.h 
b/lldb/include/lldb/Utility/SupportFile.h
index 21b986dcaba28..4b672684e4b4e 100644
--- a/lldb/include/lldb/Utility/SupportFile.h
+++ b/lldb/include/lldb/Utility/SupportFile.h
@@ -11,6 +11,7 @@
 
 #include "lldb/Utility/Checksum.h"
 #include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Flags.h"
 
 namespace lldb_private {
 
@@ -30,15 +31,37 @@ class SupportFile {
 
   virtual ~SupportFile() = default;
 
-  /// Return true if both SupportFiles have the same FileSpec and, if both have
-  /// a valid Checksum, the Checksum is the same.
-  bool operator==(const SupportFile ) const {
-if (m_checksum && other.m_checksum)
-  return m_file_spec == other.m_file_spec && m_checksum == 
other.m_checksum;
-return m_file_spec == other.m_file_spec;
-  }
+  enum SupportFileEquality : uint8_t {
+eEqualFileSpec = (1u << 1),
+eEqualChecksum = (1u << 2),
+eEqualChecksumIfSet = (1u << 3),
+eEqualFileSpecAndChecksum = eEqualFileSpec | eEqualChecksum,
+eEqualFileSpecAndChecksumIfSet = eEqualFileSpec | eEqualChecksumIfSet,
+  };
+
+  bool Equal(const SupportFile ,
+ SupportFileEquality equality = eEqualFileSpecAndChecksum) const {
+assert(!(equality & eEqualChecksum & eEqualChecksumIfSet) &&
+   "eEqualChecksum and eEqualChecksumIfSet are mutually exclusive");
+
+if (equality & eEqualFileSpec) {
+  if (m_file_spec != other.m_file_spec)
+return false;
+}
 
-  bool operator!=(const SupportFile ) const { return !(*this == other); }
+if (equality & eEqualChecksum) {
+  if (m_checksum != other.m_checksum)
+return false;
+}
+
+if (equality & eEqualChecksumIfSet) {
+  if (m_checksum && other.m_checksum)
+if (m_checksum != other.m_checksum)
+  return false;
+}
+
+return true;
+  }
 
   /// Return the file name only. Useful for resolving breakpoints by file name.
   const FileSpec () const { return m_file_spec; };
diff --git a/lldb/source/Breakpoint/BreakpointResolver.cpp 
b/lldb/source/Breakpoint/BreakpointResolver.cpp
index ff4e2a9985197..2d52cbf827ef9 100644
--- a/lldb/source/Breakpoint/BreakpointResolver.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolver.cpp
@@ -222,8 +222,9 @@ void BreakpointResolver::SetSCMatchesByLine(
 auto worklist_begin = std::partition(
 all_scs.begin(), all_scs.end(), [&](const SymbolContext ) {
   if (sc.line_entry.GetFile() == match.line_entry.GetFile() ||
-  *sc.line_entry.original_file_sp ==
-  *match.line_entry.original_file_sp) {
+  sc.line_entry.original_file_sp->Equal(
+  *match.line_entry.original_file_sp,
+  SupportFile::eEqualFileSpecAndChecksumIfSet)) {
 // When a match is found, keep track of the smallest line number.
 closest_line = std::min(closest_line, sc.line_entry.line);
 return false;
diff --git a/lldb/source/Commands/CommandObjectSource.cpp 
b/lldb/source/Commands/CommandObjectSource.cpp
index 0c1267456a184..f54b712adfc46 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -747,13 +747,17 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 
 bool operator==(const SourceInfo ) const {
   return function == rhs.function &&
- *line_entry.original_file_sp == *rhs.line_entry.original_file_sp 
&&
+ line_entry.original_file_sp->Equal(
+ *rhs.line_entry.original_file_sp,
+ SupportFile::eEqualFileSpecAndChecksumIfSet) &&
  line_entry.line == rhs.line_entry.line;
 }
 
 bool operator!=(const SourceInfo ) const {
   return function != 

[Lldb-commits] [lldb] [lldb] Don't unregister a listener that's being destroyed (PR #97300)

2024-07-01 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] Fix flake in TestZerothFrame.py (PR #96685)

2024-07-01 Thread Kendal Harland via lldb-commits

kendalharland wrote:

> Looks good. Are you able to merge this on your own?

Nope, I'll need someone with write access to do it.

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


[Lldb-commits] [lldb] Fix flake in TestZerothFrame.py (PR #96685)

2024-07-01 Thread Kendal Harland via lldb-commits

https://github.com/kendalharland updated 
https://github.com/llvm/llvm-project/pull/96685

>From 1d2c11e18e833104279fa6a005e4a64bb7be6216 Mon Sep 17 00:00:00 2001
From: kendal 
Date: Mon, 24 Jun 2024 13:42:20 -0700
Subject: [PATCH] Fix flake in TestZerothFrame.py

This test is relying on the order of `process.threads` which is
nondeterministic. By selecting the thread based on whether it is
stopped at our breakpoint we can reliably select the correct one.
---
 .../unwind/zeroth_frame/TestZerothFrame.py| 23 ---
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git 
a/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py 
b/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
index f4e883d314644..deb30669cc40e 100644
--- a/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
+++ b/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
@@ -40,28 +40,24 @@ def test(self):
 target = self.dbg.CreateTarget(exe)
 self.assertTrue(target, VALID_TARGET)
 
-bp1_line = line_number("main.c", "// Set breakpoint 1 here")
-bp2_line = line_number("main.c", "// Set breakpoint 2 here")
-
-lldbutil.run_break_set_by_file_and_line(
-self, "main.c", bp1_line, num_expected_locations=1
-)
-lldbutil.run_break_set_by_file_and_line(
-self, "main.c", bp2_line, num_expected_locations=1
-)
+main_dot_c = lldb.SBFileSpec("main.c")
+bp1 = target.BreakpointCreateBySourceRegex("// Set breakpoint 1 here", 
main_dot_c)
+bp2 = target.BreakpointCreateBySourceRegex("// Set breakpoint 2 here", 
main_dot_c)
 
 process = target.LaunchSimple(None, None, 
self.get_process_working_directory())
 self.assertTrue(process, VALID_PROCESS)
 
-thread = process.GetThreadAtIndex(0)
+thread = self.thread()
+
 if self.TraceOn():
 print("Backtrace at the first breakpoint:")
 for f in thread.frames:
 print(f)
+
 # Check that we have stopped at correct breakpoint.
 self.assertEqual(
-process.GetThreadAtIndex(0).frame[0].GetLineEntry().GetLine(),
-bp1_line,
+thread.frame[0].GetLineEntry().GetLine(),
+bp1.GetLocationAtIndex(0).GetAddress().GetLineEntry().GetLine(),
 "LLDB reported incorrect line number.",
 )
 
@@ -70,7 +66,6 @@ def test(self):
 # 'continue' command.
 process.Continue()
 
-thread = process.GetThreadAtIndex(0)
 if self.TraceOn():
 print("Backtrace at the second breakpoint:")
 for f in thread.frames:
@@ -78,7 +73,7 @@ def test(self):
 # Check that we have stopped at the breakpoint
 self.assertEqual(
 thread.frame[0].GetLineEntry().GetLine(),
-bp2_line,
+bp2.GetLocationAtIndex(0).GetAddress().GetLineEntry().GetLine(),
 "LLDB reported incorrect line number.",
 )
 # Double-check with GetPCAddress()

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


[Lldb-commits] [lldb] [lldb] Parse and display register field enums (PR #95768)

2024-07-01 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Thanks for the report, fixed in https://github.com/llvm/llvm-project/pull/97270.

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


[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow transparent lookup through anonymous namespaces (PR #97275)

2024-07-01 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] 65c807e - [lldb][TypeSystemClang] Allow transparent lookup through anonymous namespaces (#97275)

2024-07-01 Thread via lldb-commits

Author: Michael Buch
Date: 2024-07-01T17:21:58+02:00
New Revision: 65c807e69545ec23c1a258f66f744874531c7d26

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

LOG: [lldb][TypeSystemClang] Allow transparent lookup through anonymous 
namespaces (#97275)

This patch allows expressions to reference entities in anonymous
namespaces. Previously this would have resulted in:
```
(lldb) expr foo::FooAnonymousVar
error: :1:6: no member named 'FooAnonymousVar' in namespace 
'foo'
1 | foo::FooAnonymousVar
  | ~^
```

We already allow such lookups through inline namespaces, and for the
purposes of lookup, anonymous namespaces shouldn't behave any different.

Fixes https://github.com/llvm/llvm-project/issues/96963.

Added: 


Modified: 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/test/API/lang/cpp/namespace/TestNamespace.py
lldb/test/API/lang/cpp/namespace/main.cpp

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index cd1c500d9aa29..093d27a92d718 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9484,14 +9484,24 @@ bool TypeSystemClang::DeclContextIsContainedInLookup(
   auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
   auto *other = (clang::DeclContext *)other_opaque_decl_ctx;
 
+  // If we have an inline or anonymous namespace, then the lookup of the
+  // parent context also includes those namespace contents.
+  auto is_transparent_lookup_allowed = [](clang::DeclContext *DC) {
+if (DC->isInlineNamespace())
+  return true;
+
+if (auto const *NS = dyn_cast(DC))
+  return NS->isAnonymousNamespace();
+
+return false;
+  };
+
   do {
 // A decl context always includes its own contents in its lookup.
 if (decl_ctx == other)
   return true;
-
-// If we have an inline namespace, then the lookup of the parent context
-// also includes the inline namespace contents.
-  } while (other->isInlineNamespace() && (other = other->getParent()));
+  } while (is_transparent_lookup_allowed(other) &&
+   (other = other->getParent()));
 
   return false;
 }

diff  --git a/lldb/test/API/lang/cpp/namespace/TestNamespace.py 
b/lldb/test/API/lang/cpp/namespace/TestNamespace.py
index d747e2be77c8e..84891b322180c 100644
--- a/lldb/test/API/lang/cpp/namespace/TestNamespace.py
+++ b/lldb/test/API/lang/cpp/namespace/TestNamespace.py
@@ -253,3 +253,16 @@ def test_with_run_command(self):
 self.expect_expr(
 "((::B::Bar*)&::B::bar)->x()", result_type="int", result_value="42"
 )
+
+self.expect_expr("InAnon1::var_in_anon", result_type="int", 
result_value="10")
+self.expect_expr(
+"InAnon1::InAnon2::var_in_anon", result_type="int", 
result_value="5"
+)
+self.expect_expr(
+"InAnon1::inline_ns::var_in_anon", result_type="int", 
result_value="15"
+)
+self.expect_expr(
+"InAnon1::inline_ns::InAnon2::var_in_anon",
+result_type="int",
+result_value="5",
+)

diff  --git a/lldb/test/API/lang/cpp/namespace/main.cpp 
b/lldb/test/API/lang/cpp/namespace/main.cpp
index 6a8efa160766b..2edfab8437639 100644
--- a/lldb/test/API/lang/cpp/namespace/main.cpp
+++ b/lldb/test/API/lang/cpp/namespace/main.cpp
@@ -127,6 +127,22 @@ struct Foo {
 };
 } // namespace NS2
 
+namespace {
+namespace InAnon1 {
+int var_in_anon = 10;
+namespace {
+inline namespace inline_ns {
+int var_in_anon = 15;
+namespace InAnon2 {
+namespace {
+int var_in_anon = 5;
+} // namespace
+} // namespace InAnon2
+} // namespace inline_ns
+} // namespace
+} // namespace InAnon1
+} // namespace
+
 int
 main (int argc, char const *argv[])
 {
@@ -140,5 +156,6 @@ main (int argc, char const *argv[])
 ::B::Bar bb;
 A::B::Bar ab;
 return Foo::myfunc(12) + bb.x() + ab.y() + NS1::NS2::Foo{}.bar() +
-   NS2::Foo{}.bar();
+   NS2::Foo{}.bar() + InAnon1::var_in_anon +
+   InAnon1::InAnon2::var_in_anon + InAnon1::inline_ns::var_in_anon;
 }



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


[Lldb-commits] [lldb] [llvm] [lldb][FreeBSD][AArch64] Enable register field detection (PR #85058)

2024-07-01 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] ea4cf92 - [lldb][FreeBSD][AArch64] Enable register field detection (#85058)

2024-07-01 Thread via lldb-commits

Author: David Spickett
Date: 2024-07-01T16:18:57+01:00
New Revision: ea4cf923edf441897c31edd59a0d7bc8c6f380ff

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

LOG: [lldb][FreeBSD][AArch64] Enable register field detection (#85058)

This extends the existing register fields support from AArch64 Linux
to AArch64 FreeBSD. So you will now see output like this:
```
(lldb) register read cpsr
cpsr = 0x6200
 = (N = 0, Z = 1, C = 1, V = 0, DIT = 0, SS = 0, IL = 0, SSBS = 0, D = 
1, A = 0, I = 0, F = 0, nRW = 0, EL = 0, SP = 0) 
```

Linux and FreeBSD both have HWCAP/HWCAP2 so the detection mechanism
is the same and I've renamed the detector class to reflect that.

I have confirmed that FreeBSD's treatment of CPSR (spsr as the kernel
calls it) is similair enough that we can use the same field information.

(see `sys/arm64/include/armreg.h` and `PSR_SETTABLE_64`)

For testing I've enabled the same live process test as Linux
and added a shell test using an existing FreeBSD core file.

Note that the latter does not need XML support because when reading
a core file we are not sending the information via target.xml,
it's just internal to LLDB.

Added: 
lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.cpp
lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.h
lldb/test/Shell/Register/Core/aarch64-freebsd-register-fields.test

Modified: 
lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h
lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp
lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm64.cpp
lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm64.h
lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_mips64.cpp
lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_powerpc.cpp
lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.cpp
lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.cpp
lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.h
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
lldb/source/Plugins/Process/Utility/CMakeLists.txt
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
lldb/test/API/commands/register/register/register_command/TestRegisters.py
llvm/docs/ReleaseNotes.rst
llvm/utils/gn/secondary/lldb/source/Plugins/Process/Utility/BUILD.gn

Removed: 
lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.h



diff  --git 
a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h 
b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h
index 484beac99..b7f659ef24de2 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h
@@ -9,14 +9,13 @@
 #ifndef lldb_NativeRegisterContextFreeBSD_h
 #define lldb_NativeRegisterContextFreeBSD_h
 
-#include "lldb/Host/common/NativeThreadProtocol.h"
-
 #include "Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h"
 
 namespace lldb_private {
 namespace process_freebsd {
 
 class NativeProcessFreeBSD;
+class NativeThreadFreeBSD;
 
 class NativeRegisterContextFreeBSD
 : public virtual NativeRegisterContextRegisterInfo {
@@ -28,7 +27,7 @@ class NativeRegisterContextFreeBSD
   // executable.
   static NativeRegisterContextFreeBSD *
   CreateHostNativeRegisterContextFreeBSD(const ArchSpec _arch,
- NativeThreadProtocol _thread);
+ NativeThreadFreeBSD _thread);
   virtual llvm::Error
   CopyHardwareWatchpointsFrom(NativeRegisterContextFreeBSD ) = 0;
 

diff  --git 
a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp 
b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp
index 2c50176643878..f19085600d6c9 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp
@@ -29,12 +29,12 @@ using namespace lldb_private::process_freebsd;
 
 NativeRegisterContextFreeBSD *
 NativeRegisterContextFreeBSD::CreateHostNativeRegisterContextFreeBSD(
-const ArchSpec _arch, NativeThreadProtocol _thread) {
+const ArchSpec _arch, NativeThreadFreeBSD _thread) {
   return new NativeRegisterContextFreeBSD_arm(target_arch, native_thread);
 }
 
 NativeRegisterContextFreeBSD_arm::NativeRegisterContextFreeBSD_arm(
-const ArchSpec _arch, NativeThreadProtocol _thread)
+const ArchSpec _arch, 

[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow transparent lookup through anonymous namespaces (PR #97275)

2024-07-01 Thread Adrian Prantl via lldb-commits

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


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


[Lldb-commits] [lldb] [llvm] [lldb][FreeBSD][AArch64] Enable register field detection (PR #85058)

2024-07-01 Thread David Spickett via lldb-commits

DavidSpickett wrote:

CI failure is an unrelated BOLT test:
```
_bk;t=1719829907081Failed Tests (1):
<...>
_bk;t=1719829907081  BOLT :: X86/reader-stale-yaml-std.test
<...>
_bk;t=1719829907081  Failed   :   1 (0.22%)
```

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


[Lldb-commits] [lldb] [lldb] Don't unregister a listener that's being destroyed (PR #97300)

2024-07-01 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb][FreeBSD][AArch64] Enable register field detection (PR #85058)

2024-07-01 Thread Andrew Turner via lldb-commits

zxombie wrote:

This looks good to me

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


[Lldb-commits] [lldb] [lldb] Don't unregister a listener that's being destroyed (PR #97300)

2024-07-01 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

It's not necessary because the broadcasters (and broadcast managers) hold a 
weak_ptr (*) to it, and will delete the weak_ptr next time they try to lock it. 
Doing this prevents recursion in RemoveListener, where the function can end up 
holding the only shared_ptr to a listener, and its destruction can trigger 
another call to RemoveListener -- which will mess up the state of the first 
instance.

This is the same bug that we've have fixed in
https://reviews.llvm.org/D23406, but it was effectively undone in 
https://reviews.llvm.org/D157556. With the addition of a primary listener, a 
fix like D23406 becomes unwieldy (and it has already shown itself to be 
fragile), which is why this patch attempts a different approach.

Like in 2016, I don't know a good way to unit test this bug, since it depends 
on precise timing, but the thing I like about this approach is that it enables 
us to change the broadcaster mutex into a non-recursive one. While that doesn't 
prevent the bug from happening again, it will make it much easier to spot in 
the future, as the code will hang with a smoking gun (instead of crashing a 
little while later). I'm going to attempt that in a separate patch to minimize 
disruption.

(*) Technically a broadcaster holds the *primary* listener as a shared_ptr. 
That's probably not a good idea, because it means the listener will never get 
destroyed (unless it is explicitly unregistered), but it also means that this 
change has no impact on primary listeners.

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


1 Files Affected:

- (modified) lldb/source/Utility/Listener.cpp (+1-1) 


``diff
diff --git a/lldb/source/Utility/Listener.cpp b/lldb/source/Utility/Listener.cpp
index 6a74c530ad257..5aacb4104e1cf 100644
--- a/lldb/source/Utility/Listener.cpp
+++ b/lldb/source/Utility/Listener.cpp
@@ -30,7 +30,7 @@ Listener::Listener(const char *name)
 Listener::~Listener() {
   Log *log = GetLog(LLDBLog::Object);
 
-  Clear();
+  // Don't call Clear() from here as that can cause races. See #96750.
 
   LLDB_LOGF(log, "%p Listener::%s('%s')", static_cast(this),
 __FUNCTION__, m_name.c_str());

``




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


[Lldb-commits] [lldb] [lldb] Don't unregister a listener that's being destroyed (PR #97300)

2024-07-01 Thread Pavel Labath via lldb-commits

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

It's not necessary because the broadcasters (and broadcast managers) hold a 
weak_ptr (*) to it, and will delete the weak_ptr next time they try to lock it. 
Doing this prevents recursion in RemoveListener, where the function can end up 
holding the only shared_ptr to a listener, and its destruction can trigger 
another call to RemoveListener -- which will mess up the state of the first 
instance.

This is the same bug that we've have fixed in
https://reviews.llvm.org/D23406, but it was effectively undone in 
https://reviews.llvm.org/D157556. With the addition of a primary listener, a 
fix like D23406 becomes unwieldy (and it has already shown itself to be 
fragile), which is why this patch attempts a different approach.

Like in 2016, I don't know a good way to unit test this bug, since it depends 
on precise timing, but the thing I like about this approach is that it enables 
us to change the broadcaster mutex into a non-recursive one. While that doesn't 
prevent the bug from happening again, it will make it much easier to spot in 
the future, as the code will hang with a smoking gun (instead of crashing a 
little while later). I'm going to attempt that in a separate patch to minimize 
disruption.

(*) Technically a broadcaster holds the *primary* listener as a shared_ptr. 
That's probably not a good idea, because it means the listener will never get 
destroyed (unless it is explicitly unregistered), but it also means that this 
change has no impact on primary listeners.

>From 542d54217a060594e3bd51782194d3bbfbbff7e2 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Mon, 1 Jul 2024 10:48:51 +
Subject: [PATCH] [lldb] Don't unregister a listener that's being destroyed

It's not necessary because the broadcasters (and broadcast managers)
hold a weak_ptr (*) to it, and will delete the weak_ptr next time they try
to lock it. Doing this prevents recursion in RemoveListener, where the
function can end up holding the only shared_ptr to a listener, and its
destruction can trigger another call to RemoveListener -- which will
mess up the state of the first instance.

This is the same bug that we've have fixed in
https://reviews.llvm.org/D23406, but it was effectively undone in
https://reviews.llvm.org/D157556. With the addition of a primary
listener, a fix like D23406 becomes unwieldy (and it has already shown
itself to be fragile), which is why this patch attempts a different
approach.

Like in 2016, I don't know a good way to unit test this bug, since it
depends on precise timing, but the thing I like about this approach is
that it enables us to change the broadcaster mutex into a non-recursive
one. While that doesn't prevent the bug from happening again, it will
make it much easier to spot in the future, as the code will hang with a
smoking gun (instead of crashing a little while later). I'm going to
attempt that in a separate patch to minimize disruption.

(*) Technically a broadcaster holds the *primary* listener as a
shared_ptr. That's probably not a good idea, because it means the
listener will never get destroyed (unless it is explicitly
unregistered), but it also means that this change has no impact on
primary listeners.
---
 lldb/source/Utility/Listener.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Utility/Listener.cpp b/lldb/source/Utility/Listener.cpp
index 6a74c530ad257..5aacb4104e1cf 100644
--- a/lldb/source/Utility/Listener.cpp
+++ b/lldb/source/Utility/Listener.cpp
@@ -30,7 +30,7 @@ Listener::Listener(const char *name)
 Listener::~Listener() {
   Log *log = GetLog(LLDBLog::Object);
 
-  Clear();
+  // Don't call Clear() from here as that can cause races. See #96750.
 
   LLDB_LOGF(log, "%p Listener::%s('%s')", static_cast(this),
 __FUNCTION__, m_name.c_str());

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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-07-01 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

A high-level concern that I have with this is the grammar is full of 
C++-specific nodes, which is not something I would like to see in living in 
`Core`. Have we previously reached any consensus on how we want to handle 
different languages in DIL?
I would be more comfortable with moving most of this into the 
`Plugins/Language/CPlusPlus` directory and having only a generic, 
language-agnostic driver live in `Core`.

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


[Lldb-commits] [clang] [lldb] [clang][AST] fix ast-print of extern with >=2 declarators, fixed (PR #93913)

2024-07-01 Thread Aaron Ballman via lldb-commits

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


[Lldb-commits] [lldb] 48f13d4 - [clang][AST] fix ast-print of extern with >=2 declarators

2024-07-01 Thread via lldb-commits

Author: temyurchenko
Date: 2024-07-01T09:25:27-04:00
New Revision: 48f13d48a88c14acbaea7c3ee05018bb173fb360

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

LOG: [clang][AST] fix ast-print of extern  with >=2 declarators

Fixes #93913

Added: 
clang/test/AST/ast-print-language-linkage.cpp

Modified: 
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclPrinter.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp

Removed: 




diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 16ed6d88d1cb1..ff3325543919f 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -576,13 +576,16 @@ template  static bool 
isFirstInExternCContext(T *D) {
   return First->isInExternCContext();
 }
 
-static bool isSingleLineLanguageLinkage(const Decl ) {
-  if (const auto *SD = dyn_cast(D.getDeclContext()))
-if (!SD->hasBraces())
-  return true;
+static bool isUnbracedLanguageLinkage(const DeclContext *DC) {
+  if (const auto *SD = dyn_cast_if_present(DC))
+return !SD->hasBraces();
   return false;
 }
 
+static bool hasUnbracedLanguageLinkage(const Decl ) {
+  return isUnbracedLanguageLinkage(D.getDeclContext());
+}
+
 static bool isDeclaredInModuleInterfaceOrPartition(const NamedDecl *D) {
   if (auto *M = D->getOwningModule())
 return M->isInterfaceOrPartition();
@@ -644,7 +647,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl 
*D,
 
   if (Var->getStorageClass() != SC_Extern &&
   Var->getStorageClass() != SC_PrivateExtern &&
-  !isSingleLineLanguageLinkage(*Var))
+  !hasUnbracedLanguageLinkage(*Var))
 return LinkageInfo::internal();
 }
 
@@ -2118,6 +2121,12 @@ VarDecl::VarDecl(Kind DK, ASTContext , DeclContext *DC,
 "ParmVarDeclBitfields too large!");
   static_assert(sizeof(NonParmVarDeclBitfields) <= sizeof(unsigned),
 "NonParmVarDeclBitfields too large!");
+
+  // The unbraced `extern "C"` invariant is that the storage class
+  // specifier is omitted in the source code, i.e. SC_None (but is,
+  // implicitly, `extern`).
+  assert(!isUnbracedLanguageLinkage(DC) || SC == SC_None);
+
   AllBits = 0;
   VarDeclBits.SClass = SC;
   // Everything else is implicitly initialized to false.
@@ -2301,7 +2310,7 @@ VarDecl::isThisDeclarationADefinition(ASTContext ) 
const {
   //   A declaration directly contained in a linkage-specification is treated
   //   as if it contains the extern specifier for the purpose of determining
   //   the linkage of the declared name and whether it is a definition.
-  if (isSingleLineLanguageLinkage(*this))
+  if (hasUnbracedLanguageLinkage(*this))
 return DeclarationOnly;
 
   // C99 6.9.2p2:
@@ -3027,6 +3036,12 @@ FunctionDecl::FunctionDecl(Kind DK, ASTContext , 
DeclContext *DC,
   DeclContext(DK), redeclarable_base(C), Body(), ODRHash(0),
   EndRangeLoc(NameInfo.getEndLoc()), DNLoc(NameInfo.getInfo()) {
   assert(T.isNull() || T->isFunctionType());
+
+  // The unbraced `extern "C"` invariant is that the storage class
+  // specifier is omitted in the source code, i.e. SC_None (but is,
+  // implicitly, `extern`).
+  assert(!isUnbracedLanguageLinkage(DC) || S == SC_None);
+
   FunctionDeclBits.SClass = S;
   FunctionDeclBits.IsInline = isInlineSpecified;
   FunctionDeclBits.IsInlineSpecified = isInlineSpecified;

diff  --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 26773a69ab9ac..b8e0ef1b40358 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -633,7 +633,7 @@ static void printExplicitSpecifier(ExplicitSpecifier ES, 
llvm::raw_ostream ,
   Out << Proto;
 }
 
-static void MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy ,
+static void maybePrintTagKeywordIfSupressingScopes(PrintingPolicy ,
QualType T,
llvm::raw_ostream ) {
   StringRef prefix = T->isClassType()   ? "class "
@@ -643,6 +643,22 @@ static void 
MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy ,
   Out << prefix;
 }
 
+/// Return the language of the linkage spec of `D`, if applicable.
+///
+/// \Return - "C" if `D` has been declared with unbraced `extern "C"`
+/// - "C++" if `D` has been declared with unbraced `extern "C++"`
+/// - nullptr in any other case
+static const char *tryGetUnbracedLinkageLanguage(const Decl *D) {
+  const auto *SD = dyn_cast(D->getDeclContext());
+  if (!SD || SD->hasBraces())
+return nullptr;
+  if (SD->getLanguage() == LinkageSpecLanguageIDs::C)
+return "C";
+  assert(SD->getLanguage() == 

[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow transparent lookup through anonymous namespaces (PR #97275)

2024-07-01 Thread Michael Buch via lldb-commits

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

>From f6c801efec331a832f2f10386be9cc14c8bb9565 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 1 Jul 2024 11:46:37 +0200
Subject: [PATCH 1/2] [lldb][TypeSystemClang] Allow transparent lookup through
 anonymous namespaces

This patch allows expressions to reference entities in
anonymous namespaces. Previously this would have resulted in:
```
(lldb) expr foo::FooAnonymousVar
error: :1:6: no member named 'FooAnonymousVar' in namespace 
'foo'
1 | foo::FooAnonymousVar
  | ~^
```

We already allow such lookups through inline namespaces, and for
the purposes of lookup, anonymous namespaces shouldn't behave
any different.

Fixes https://github.com/llvm/llvm-project/issues/96963.
---
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 18 ++
 .../API/lang/cpp/namespace/TestNamespace.py   |  5 +
 lldb/test/API/lang/cpp/namespace/main.cpp | 19 ++-
 3 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index cd1c500d9aa29..093d27a92d718 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9484,14 +9484,24 @@ bool TypeSystemClang::DeclContextIsContainedInLookup(
   auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
   auto *other = (clang::DeclContext *)other_opaque_decl_ctx;
 
+  // If we have an inline or anonymous namespace, then the lookup of the
+  // parent context also includes those namespace contents.
+  auto is_transparent_lookup_allowed = [](clang::DeclContext *DC) {
+if (DC->isInlineNamespace())
+  return true;
+
+if (auto const *NS = dyn_cast(DC))
+  return NS->isAnonymousNamespace();
+
+return false;
+  };
+
   do {
 // A decl context always includes its own contents in its lookup.
 if (decl_ctx == other)
   return true;
-
-// If we have an inline namespace, then the lookup of the parent context
-// also includes the inline namespace contents.
-  } while (other->isInlineNamespace() && (other = other->getParent()));
+  } while (is_transparent_lookup_allowed(other) &&
+   (other = other->getParent()));
 
   return false;
 }
diff --git a/lldb/test/API/lang/cpp/namespace/TestNamespace.py 
b/lldb/test/API/lang/cpp/namespace/TestNamespace.py
index d747e2be77c8e..83bfe173658cc 100644
--- a/lldb/test/API/lang/cpp/namespace/TestNamespace.py
+++ b/lldb/test/API/lang/cpp/namespace/TestNamespace.py
@@ -253,3 +253,8 @@ def test_with_run_command(self):
 self.expect_expr(
 "((::B::Bar*)&::B::bar)->x()", result_type="int", result_value="42"
 )
+
+self.expect_expr("InAnon1::var_in_anon", result_type="int", 
result_value="10")
+self.expect_expr("InAnon1::InAnon2::var_in_anon", result_type="int", 
result_value="5")
+self.expect_expr("InAnon1::inline_ns::var_in_anon", result_type="int", 
result_value="15")
+self.expect_expr("InAnon1::inline_ns::InAnon2::var_in_anon", 
result_type="int", result_value="5")
diff --git a/lldb/test/API/lang/cpp/namespace/main.cpp 
b/lldb/test/API/lang/cpp/namespace/main.cpp
index 6a8efa160766b..2edfab8437639 100644
--- a/lldb/test/API/lang/cpp/namespace/main.cpp
+++ b/lldb/test/API/lang/cpp/namespace/main.cpp
@@ -127,6 +127,22 @@ struct Foo {
 };
 } // namespace NS2
 
+namespace {
+namespace InAnon1 {
+int var_in_anon = 10;
+namespace {
+inline namespace inline_ns {
+int var_in_anon = 15;
+namespace InAnon2 {
+namespace {
+int var_in_anon = 5;
+} // namespace
+} // namespace InAnon2
+} // namespace inline_ns
+} // namespace
+} // namespace InAnon1
+} // namespace
+
 int
 main (int argc, char const *argv[])
 {
@@ -140,5 +156,6 @@ main (int argc, char const *argv[])
 ::B::Bar bb;
 A::B::Bar ab;
 return Foo::myfunc(12) + bb.x() + ab.y() + NS1::NS2::Foo{}.bar() +
-   NS2::Foo{}.bar();
+   NS2::Foo{}.bar() + InAnon1::var_in_anon +
+   InAnon1::InAnon2::var_in_anon + InAnon1::inline_ns::var_in_anon;
 }

>From 27734b12297e268905f87573c90077f2f616ea70 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 1 Jul 2024 12:19:03 +0200
Subject: [PATCH 2/2] fixup! python format

---
 lldb/test/API/lang/cpp/namespace/TestNamespace.py | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lldb/test/API/lang/cpp/namespace/TestNamespace.py 
b/lldb/test/API/lang/cpp/namespace/TestNamespace.py
index 83bfe173658cc..84891b322180c 100644
--- a/lldb/test/API/lang/cpp/namespace/TestNamespace.py
+++ b/lldb/test/API/lang/cpp/namespace/TestNamespace.py
@@ -255,6 +255,14 @@ def test_with_run_command(self):
 )
 
 self.expect_expr("InAnon1::var_in_anon", result_type="int", 
result_value="10")
-self.expect_expr("InAnon1::InAnon2::var_in_anon", result_type="int", 

[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow transparent lookup through anonymous namespaces (PR #97275)

2024-07-01 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
b0f20f214ab43c800130e0d249e8ee2459b906ea...f6c801efec331a832f2f10386be9cc14c8bb9565
 lldb/test/API/lang/cpp/namespace/TestNamespace.py
``





View the diff from darker here.


``diff
--- TestNamespace.py2024-07-01 10:08:52.00 +
+++ TestNamespace.py2024-07-01 10:12:31.810901 +
@@ -253,8 +253,16 @@
 self.expect_expr(
 "((::B::Bar*)&::B::bar)->x()", result_type="int", result_value="42"
 )
 
 self.expect_expr("InAnon1::var_in_anon", result_type="int", 
result_value="10")
-self.expect_expr("InAnon1::InAnon2::var_in_anon", result_type="int", 
result_value="5")
-self.expect_expr("InAnon1::inline_ns::var_in_anon", result_type="int", 
result_value="15")
-self.expect_expr("InAnon1::inline_ns::InAnon2::var_in_anon", 
result_type="int", result_value="5")
+self.expect_expr(
+"InAnon1::InAnon2::var_in_anon", result_type="int", 
result_value="5"
+)
+self.expect_expr(
+"InAnon1::inline_ns::var_in_anon", result_type="int", 
result_value="15"
+)
+self.expect_expr(
+"InAnon1::inline_ns::InAnon2::var_in_anon",
+result_type="int",
+result_value="5",
+)

``




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


[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow transparent lookup through anonymous namespaces (PR #97275)

2024-07-01 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

This patch allows expressions to reference entities in anonymous namespaces. 
Previously this would have resulted in:
```
(lldb) expr foo::FooAnonymousVar
error: user expression 0:1:6: no member named 'FooAnonymousVar' in 
namespace 'foo'
1 | foo::FooAnonymousVar
  | ~^
```

We already allow such lookups through inline namespaces, and for the purposes 
of lookup, anonymous namespaces shouldn't behave any different.

Fixes https://github.com/llvm/llvm-project/issues/96963.

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


3 Files Affected:

- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+14-4) 
- (modified) lldb/test/API/lang/cpp/namespace/TestNamespace.py (+5) 
- (modified) lldb/test/API/lang/cpp/namespace/main.cpp (+18-1) 


``diff
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index cd1c500d9aa29..093d27a92d718 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9484,14 +9484,24 @@ bool TypeSystemClang::DeclContextIsContainedInLookup(
   auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
   auto *other = (clang::DeclContext *)other_opaque_decl_ctx;
 
+  // If we have an inline or anonymous namespace, then the lookup of the
+  // parent context also includes those namespace contents.
+  auto is_transparent_lookup_allowed = [](clang::DeclContext *DC) {
+if (DC->isInlineNamespace())
+  return true;
+
+if (auto const *NS = dyn_cast(DC))
+  return NS->isAnonymousNamespace();
+
+return false;
+  };
+
   do {
 // A decl context always includes its own contents in its lookup.
 if (decl_ctx == other)
   return true;
-
-// If we have an inline namespace, then the lookup of the parent context
-// also includes the inline namespace contents.
-  } while (other->isInlineNamespace() && (other = other->getParent()));
+  } while (is_transparent_lookup_allowed(other) &&
+   (other = other->getParent()));
 
   return false;
 }
diff --git a/lldb/test/API/lang/cpp/namespace/TestNamespace.py 
b/lldb/test/API/lang/cpp/namespace/TestNamespace.py
index d747e2be77c8e..83bfe173658cc 100644
--- a/lldb/test/API/lang/cpp/namespace/TestNamespace.py
+++ b/lldb/test/API/lang/cpp/namespace/TestNamespace.py
@@ -253,3 +253,8 @@ def test_with_run_command(self):
 self.expect_expr(
 "((::B::Bar*)&::B::bar)->x()", result_type="int", result_value="42"
 )
+
+self.expect_expr("InAnon1::var_in_anon", result_type="int", 
result_value="10")
+self.expect_expr("InAnon1::InAnon2::var_in_anon", result_type="int", 
result_value="5")
+self.expect_expr("InAnon1::inline_ns::var_in_anon", result_type="int", 
result_value="15")
+self.expect_expr("InAnon1::inline_ns::InAnon2::var_in_anon", 
result_type="int", result_value="5")
diff --git a/lldb/test/API/lang/cpp/namespace/main.cpp 
b/lldb/test/API/lang/cpp/namespace/main.cpp
index 6a8efa160766b..2edfab8437639 100644
--- a/lldb/test/API/lang/cpp/namespace/main.cpp
+++ b/lldb/test/API/lang/cpp/namespace/main.cpp
@@ -127,6 +127,22 @@ struct Foo {
 };
 } // namespace NS2
 
+namespace {
+namespace InAnon1 {
+int var_in_anon = 10;
+namespace {
+inline namespace inline_ns {
+int var_in_anon = 15;
+namespace InAnon2 {
+namespace {
+int var_in_anon = 5;
+} // namespace
+} // namespace InAnon2
+} // namespace inline_ns
+} // namespace
+} // namespace InAnon1
+} // namespace
+
 int
 main (int argc, char const *argv[])
 {
@@ -140,5 +156,6 @@ main (int argc, char const *argv[])
 ::B::Bar bb;
 A::B::Bar ab;
 return Foo::myfunc(12) + bb.x() + ab.y() + NS1::NS2::Foo{}.bar() +
-   NS2::Foo{}.bar();
+   NS2::Foo{}.bar() + InAnon1::var_in_anon +
+   InAnon1::InAnon2::var_in_anon + InAnon1::inline_ns::var_in_anon;
 }

``




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


[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow transparent lookup through anonymous namespaces (PR #97275)

2024-07-01 Thread Michael Buch via lldb-commits

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

This patch allows expressions to reference entities in anonymous namespaces. 
Previously this would have resulted in:
```
(lldb) expr foo::FooAnonymousVar
error: :1:6: no member named 'FooAnonymousVar' in namespace 
'foo'
1 | foo::FooAnonymousVar
  | ~^
```

We already allow such lookups through inline namespaces, and for the purposes 
of lookup, anonymous namespaces shouldn't behave any different.

Fixes https://github.com/llvm/llvm-project/issues/96963.

>From f6c801efec331a832f2f10386be9cc14c8bb9565 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 1 Jul 2024 11:46:37 +0200
Subject: [PATCH] [lldb][TypeSystemClang] Allow transparent lookup through
 anonymous namespaces

This patch allows expressions to reference entities in
anonymous namespaces. Previously this would have resulted in:
```
(lldb) expr foo::FooAnonymousVar
error: :1:6: no member named 'FooAnonymousVar' in namespace 
'foo'
1 | foo::FooAnonymousVar
  | ~^
```

We already allow such lookups through inline namespaces, and for
the purposes of lookup, anonymous namespaces shouldn't behave
any different.

Fixes https://github.com/llvm/llvm-project/issues/96963.
---
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 18 ++
 .../API/lang/cpp/namespace/TestNamespace.py   |  5 +
 lldb/test/API/lang/cpp/namespace/main.cpp | 19 ++-
 3 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index cd1c500d9aa29..093d27a92d718 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9484,14 +9484,24 @@ bool TypeSystemClang::DeclContextIsContainedInLookup(
   auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
   auto *other = (clang::DeclContext *)other_opaque_decl_ctx;
 
+  // If we have an inline or anonymous namespace, then the lookup of the
+  // parent context also includes those namespace contents.
+  auto is_transparent_lookup_allowed = [](clang::DeclContext *DC) {
+if (DC->isInlineNamespace())
+  return true;
+
+if (auto const *NS = dyn_cast(DC))
+  return NS->isAnonymousNamespace();
+
+return false;
+  };
+
   do {
 // A decl context always includes its own contents in its lookup.
 if (decl_ctx == other)
   return true;
-
-// If we have an inline namespace, then the lookup of the parent context
-// also includes the inline namespace contents.
-  } while (other->isInlineNamespace() && (other = other->getParent()));
+  } while (is_transparent_lookup_allowed(other) &&
+   (other = other->getParent()));
 
   return false;
 }
diff --git a/lldb/test/API/lang/cpp/namespace/TestNamespace.py 
b/lldb/test/API/lang/cpp/namespace/TestNamespace.py
index d747e2be77c8e..83bfe173658cc 100644
--- a/lldb/test/API/lang/cpp/namespace/TestNamespace.py
+++ b/lldb/test/API/lang/cpp/namespace/TestNamespace.py
@@ -253,3 +253,8 @@ def test_with_run_command(self):
 self.expect_expr(
 "((::B::Bar*)&::B::bar)->x()", result_type="int", result_value="42"
 )
+
+self.expect_expr("InAnon1::var_in_anon", result_type="int", 
result_value="10")
+self.expect_expr("InAnon1::InAnon2::var_in_anon", result_type="int", 
result_value="5")
+self.expect_expr("InAnon1::inline_ns::var_in_anon", result_type="int", 
result_value="15")
+self.expect_expr("InAnon1::inline_ns::InAnon2::var_in_anon", 
result_type="int", result_value="5")
diff --git a/lldb/test/API/lang/cpp/namespace/main.cpp 
b/lldb/test/API/lang/cpp/namespace/main.cpp
index 6a8efa160766b..2edfab8437639 100644
--- a/lldb/test/API/lang/cpp/namespace/main.cpp
+++ b/lldb/test/API/lang/cpp/namespace/main.cpp
@@ -127,6 +127,22 @@ struct Foo {
 };
 } // namespace NS2
 
+namespace {
+namespace InAnon1 {
+int var_in_anon = 10;
+namespace {
+inline namespace inline_ns {
+int var_in_anon = 15;
+namespace InAnon2 {
+namespace {
+int var_in_anon = 5;
+} // namespace
+} // namespace InAnon2
+} // namespace inline_ns
+} // namespace
+} // namespace InAnon1
+} // namespace
+
 int
 main (int argc, char const *argv[])
 {
@@ -140,5 +156,6 @@ main (int argc, char const *argv[])
 ::B::Bar bb;
 A::B::Bar ab;
 return Foo::myfunc(12) + bb.x() + ab.y() + NS1::NS2::Foo{}.bar() +
-   NS2::Foo{}.bar();
+   NS2::Foo{}.bar() + InAnon1::var_in_anon +
+   InAnon1::InAnon2::var_in_anon + InAnon1::inline_ns::var_in_anon;
 }

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


[Lldb-commits] [lldb] [llvm] [lldb][FreeBSD][AArch64] Enable register field detection (PR #85058)

2024-07-01 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/85058

>From 6a013c6b46306c4d170efb1a6df2956c9dc61b30 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 4 Mar 2024 14:31:40 +
Subject: [PATCH 1/2] [lldb][FreeBSD][AArch64] Enable register field detection

This extends the existing register fields support from AArch64 Linux
to AArch64 FreeBSD. So you will now see output like this:
```
(lldb) register read cpsr
cpsr = 0x6200
 = (N = 0, Z = 1, C = 1, V = 0, DIT = 0, SS = 0, IL = 0, SSBS = 0, D = 
1, A = 0, I = 0, F = 0, nRW = 0, EL = 0, SP = 0)
```

Linux and FreeBSD both have HWCAP/HWCAP2 so the detection mechanism
is the same and I've renamed the detector class to reflect that.

I have confirmed that FreeBSD's treatment of CPSR (spsr as the kernel
calls it) is similair enough that we can use the same field information.

(see `sys/arm64/include/armreg.h` and `PSR_SETTABLE_64`)

For testing I've enabled the same live process test as Linux
and added a shell test using an existing FreeBSD core file.

Note that the latter does not need XML support because when reading
a core file we are not sending the information via target.xml,
it's just internal to LLDB.
---
 .../FreeBSD/NativeRegisterContextFreeBSD.h|  5 ++-
 .../NativeRegisterContextFreeBSD_arm.cpp  |  4 +--
 .../NativeRegisterContextFreeBSD_arm64.cpp| 24 +++--
 .../NativeRegisterContextFreeBSD_arm64.h  |  2 +-
 .../NativeRegisterContextFreeBSD_mips64.cpp   |  4 +--
 .../NativeRegisterContextFreeBSD_powerpc.cpp  |  4 +--
 .../NativeRegisterContextFreeBSD_x86_64.cpp   |  4 +--
 .../Process/FreeBSD/NativeThreadFreeBSD.cpp   |  4 +++
 .../Process/FreeBSD/NativeThreadFreeBSD.h |  2 ++
 .../NativeRegisterContextLinux_arm64.cpp  | 16 -
 .../Plugins/Process/Utility/CMakeLists.txt|  2 +-
 ...64.cpp => RegisterFlagsDetector_arm64.cpp} | 36 ++-
 ..._arm64.h => RegisterFlagsDetector_arm64.h} | 16 -
 .../RegisterContextPOSIXCore_arm64.cpp| 18 +-
 .../elf-core/RegisterContextPOSIXCore_arm64.h |  4 +--
 .../register_command/TestRegisters.py |  2 +-
 .../Core/aarch64-freebsd-register-fields.test | 15 
 llvm/docs/ReleaseNotes.rst|  3 ++
 .../source/Plugins/Process/Utility/BUILD.gn   |  2 +-
 19 files changed, 107 insertions(+), 60 deletions(-)
 rename lldb/source/Plugins/Process/Utility/{RegisterFlagsLinux_arm64.cpp => 
RegisterFlagsDetector_arm64.cpp} (85%)
 rename lldb/source/Plugins/Process/Utility/{RegisterFlagsLinux_arm64.h => 
RegisterFlagsDetector_arm64.h} (85%)
 create mode 100644 
lldb/test/Shell/Register/Core/aarch64-freebsd-register-fields.test

diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h 
b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h
index 484beac99..b7f659ef24de2 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h
@@ -9,14 +9,13 @@
 #ifndef lldb_NativeRegisterContextFreeBSD_h
 #define lldb_NativeRegisterContextFreeBSD_h
 
-#include "lldb/Host/common/NativeThreadProtocol.h"
-
 #include "Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h"
 
 namespace lldb_private {
 namespace process_freebsd {
 
 class NativeProcessFreeBSD;
+class NativeThreadFreeBSD;
 
 class NativeRegisterContextFreeBSD
 : public virtual NativeRegisterContextRegisterInfo {
@@ -28,7 +27,7 @@ class NativeRegisterContextFreeBSD
   // executable.
   static NativeRegisterContextFreeBSD *
   CreateHostNativeRegisterContextFreeBSD(const ArchSpec _arch,
- NativeThreadProtocol _thread);
+ NativeThreadFreeBSD _thread);
   virtual llvm::Error
   CopyHardwareWatchpointsFrom(NativeRegisterContextFreeBSD ) = 0;
 
diff --git 
a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp 
b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp
index 2c50176643878..f19085600d6c9 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp
@@ -29,12 +29,12 @@ using namespace lldb_private::process_freebsd;
 
 NativeRegisterContextFreeBSD *
 NativeRegisterContextFreeBSD::CreateHostNativeRegisterContextFreeBSD(
-const ArchSpec _arch, NativeThreadProtocol _thread) {
+const ArchSpec _arch, NativeThreadFreeBSD _thread) {
   return new NativeRegisterContextFreeBSD_arm(target_arch, native_thread);
 }
 
 NativeRegisterContextFreeBSD_arm::NativeRegisterContextFreeBSD_arm(
-const ArchSpec _arch, NativeThreadProtocol _thread)
+const ArchSpec _arch, NativeThreadFreeBSD _thread)
 : NativeRegisterContextRegisterInfo(
   native_thread, new RegisterInfoPOSIX_arm(target_arch)) {}
 
diff --git 

[Lldb-commits] [lldb] [llvm] [lldb][FreeBSD][AArch64] Enable register field detection (PR #85058)

2024-07-01 Thread David Spickett via lldb-commits


@@ -18,9 +18,9 @@ namespace lldb_private {
 struct RegisterInfo;
 
 /// This class manages the storage and detection of register field information
-/// for Arm64 Linux registers. The same register may have different fields on
-/// different CPUs. This class abstracts out the field detection process so we
-/// can use it on live processes and core files.
+/// for Arm64 Linux and FreeBSD registers. The same register may have different

DavidSpickett wrote:

Done.

To make this completely generic it'll need to switch to using some sort of llvm 
feature bitset type, but that will be pretty evident to whomever does the work, 
regardless of the content of the comments.

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


[Lldb-commits] [lldb] [llvm] [lldb][FreeBSD][AArch64] Enable register field detection (PR #85058)

2024-07-01 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/85058

>From 33b750696a5958ae13420796e82fb9f5b2ea8fa9 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 4 Mar 2024 14:31:40 +
Subject: [PATCH 1/2] [lldb][FreeBSD][AArch64] Enable register field detection

This extends the existing register fields support from AArch64 Linux
to AArch64 FreeBSD. So you will now see output like this:
```
(lldb) register read cpsr
cpsr = 0x6200
 = (N = 0, Z = 1, C = 1, V = 0, DIT = 0, SS = 0, IL = 0, SSBS = 0, D = 
1, A = 0, I = 0, F = 0, nRW = 0, EL = 0, SP = 0)
```

Linux and FreeBSD both have HWCAP/HWCAP2 so the detection mechanism
is the same and I've renamed the detector class to reflect that.

I have confirmed that FreeBSD's treatment of CPSR (spsr as the kernel
calls it) is similair enough that we can use the same field information.

(see `sys/arm64/include/armreg.h` and `PSR_SETTABLE_64`)

For testing I've enabled the same live process test as Linux
and added a shell test using an existing FreeBSD core file.

Note that the latter does not need XML support because when reading
a core file we are not sending the information via target.xml,
it's just internal to LLDB.
---
 .../FreeBSD/NativeRegisterContextFreeBSD.h|  5 ++-
 .../NativeRegisterContextFreeBSD_arm.cpp  |  4 +--
 .../NativeRegisterContextFreeBSD_arm64.cpp| 24 +++--
 .../NativeRegisterContextFreeBSD_arm64.h  |  2 +-
 .../NativeRegisterContextFreeBSD_mips64.cpp   |  4 +--
 .../NativeRegisterContextFreeBSD_powerpc.cpp  |  4 +--
 .../NativeRegisterContextFreeBSD_x86_64.cpp   |  4 +--
 .../Process/FreeBSD/NativeThreadFreeBSD.cpp   |  4 +++
 .../Process/FreeBSD/NativeThreadFreeBSD.h |  2 ++
 .../NativeRegisterContextLinux_arm64.cpp  | 16 -
 .../Plugins/Process/Utility/CMakeLists.txt|  2 +-
 ...64.cpp => RegisterFlagsDetector_arm64.cpp} | 36 ++-
 ..._arm64.h => RegisterFlagsDetector_arm64.h} | 16 -
 .../RegisterContextPOSIXCore_arm64.cpp| 18 +-
 .../elf-core/RegisterContextPOSIXCore_arm64.h |  4 +--
 .../register_command/TestRegisters.py |  2 +-
 .../Core/aarch64-freebsd-register-fields.test | 15 
 llvm/docs/ReleaseNotes.rst|  3 ++
 .../source/Plugins/Process/Utility/BUILD.gn   |  2 +-
 19 files changed, 107 insertions(+), 60 deletions(-)
 rename lldb/source/Plugins/Process/Utility/{RegisterFlagsLinux_arm64.cpp => 
RegisterFlagsDetector_arm64.cpp} (85%)
 rename lldb/source/Plugins/Process/Utility/{RegisterFlagsLinux_arm64.h => 
RegisterFlagsDetector_arm64.h} (85%)
 create mode 100644 
lldb/test/Shell/Register/Core/aarch64-freebsd-register-fields.test

diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h 
b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h
index 484beac99..b7f659ef24de2 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h
@@ -9,14 +9,13 @@
 #ifndef lldb_NativeRegisterContextFreeBSD_h
 #define lldb_NativeRegisterContextFreeBSD_h
 
-#include "lldb/Host/common/NativeThreadProtocol.h"
-
 #include "Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h"
 
 namespace lldb_private {
 namespace process_freebsd {
 
 class NativeProcessFreeBSD;
+class NativeThreadFreeBSD;
 
 class NativeRegisterContextFreeBSD
 : public virtual NativeRegisterContextRegisterInfo {
@@ -28,7 +27,7 @@ class NativeRegisterContextFreeBSD
   // executable.
   static NativeRegisterContextFreeBSD *
   CreateHostNativeRegisterContextFreeBSD(const ArchSpec _arch,
- NativeThreadProtocol _thread);
+ NativeThreadFreeBSD _thread);
   virtual llvm::Error
   CopyHardwareWatchpointsFrom(NativeRegisterContextFreeBSD ) = 0;
 
diff --git 
a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp 
b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp
index 2c50176643878..f19085600d6c9 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp
@@ -29,12 +29,12 @@ using namespace lldb_private::process_freebsd;
 
 NativeRegisterContextFreeBSD *
 NativeRegisterContextFreeBSD::CreateHostNativeRegisterContextFreeBSD(
-const ArchSpec _arch, NativeThreadProtocol _thread) {
+const ArchSpec _arch, NativeThreadFreeBSD _thread) {
   return new NativeRegisterContextFreeBSD_arm(target_arch, native_thread);
 }
 
 NativeRegisterContextFreeBSD_arm::NativeRegisterContextFreeBSD_arm(
-const ArchSpec _arch, NativeThreadProtocol _thread)
+const ArchSpec _arch, NativeThreadFreeBSD _thread)
 : NativeRegisterContextRegisterInfo(
   native_thread, new RegisterInfoPOSIX_arm(target_arch)) {}
 
diff --git 

[Lldb-commits] [lldb] [lldb/Commands] Add `scripting template list` command with auto discovery (PR #97273)

2024-07-01 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Med Ismail Bennani (medismailben)


Changes

This patch introduces a new `template` multiword sub-command to the
`scripting` top-level command. As the name suggests, this sub-command
operates on scripting templates, and currently has the ability to
automatically discover the various scripting extensions that lldb
supports.

Signed-off-by: Med Ismail Bennani ismail@bennani.ma


---

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


17 Files Affected:

- (modified) lldb/include/lldb/Core/PluginManager.h (+25) 
- (modified) lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h (+7) 
- (modified) lldb/include/lldb/lldb-private-interfaces.h (+4) 
- (modified) lldb/source/Commands/CMakeLists.txt (+1-1) 
- (removed) lldb/source/Commands/CommandObjectScript.cpp (-113) 
- (removed) lldb/source/Commands/CommandObjectScript.h (-42) 
- (added) lldb/source/Commands/CommandObjectScripting.cpp (+290) 
- (added) lldb/source/Commands/CommandObjectScripting.h (+80) 
- (modified) lldb/source/Commands/Options.td (+8-2) 
- (modified) lldb/source/Core/PluginManager.cpp (+83) 
- (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+7-2) 
- (modified) lldb/source/Plugins/CMakeLists.txt (+3) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt (+5) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp
 (+23) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.h
 (+12-1) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
 (+18) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
 (+12-1) 


``diff
diff --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index f2296e2920238..df20109e791a5 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -487,6 +487,31 @@ class PluginManager {
 
   static LanguageSet GetAllTypeSystemSupportedLanguagesForExpressions();
 
+  // Scripted Interface
+  static bool
+  RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
+ ScriptedInterfaceCreateInstance create_callback,
+ lldb::ScriptLanguage language,
+ std::vector command_interpreter_usages,
+ std::vector api_usages);
+
+  static bool UnregisterPlugin(ScriptedInterfaceCreateInstance 
create_callback);
+
+  static ScriptedInterfaceCreateInstance
+  GetScriptedInterfaceCreateCallbackAtIndex(uint32_t idx);
+
+  static llvm::StringRef GetScriptedInterfaceNameAtIndex(uint32_t idx);
+
+  static llvm::StringRef GetScriptedInterfaceDescriptionAtIndex(uint32_t idx);
+
+  static lldb::ScriptLanguage GetScriptedInterfaceLanguageAtIndex(uint32_t 
idx);
+
+  static std::vector
+  GetScriptedInterfaceCommandInterpreterUsagesAtIndex(uint32_t idx);
+
+  static std::vector
+  GetScriptedInterfaceAPIUsagesAtIndex(uint32_t idx);
+
   // REPL
   static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  REPLCreateInstance create_callback,
diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
index 69504dbcda5dc..23658b90bb90a 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
@@ -68,6 +68,13 @@ class ScriptedInterface {
 return true;
   }
 
+  static bool
+  CreateInstance(lldb::ScriptLanguage language,
+ std::vector command_interpreter_usages,
+ std::vector api_usages) {
+return false;
+  }
+
 protected:
   StructuredData::GenericSP m_object_instance_sp;
 };
diff --git a/lldb/include/lldb/lldb-private-interfaces.h 
b/lldb/include/lldb/lldb-private-interfaces.h
index cdd9b51d9329c..2404e28158690 100644
--- a/lldb/include/lldb/lldb-private-interfaces.h
+++ b/lldb/include/lldb/lldb-private-interfaces.h
@@ -124,6 +124,10 @@ typedef lldb::REPLSP (*REPLCreateInstance)(Status ,
lldb::LanguageType language,
Debugger *debugger, Target *target,
const char *repl_options);
+typedef bool (*ScriptedInterfaceCreateInstance)(
+lldb::ScriptLanguage language,
+std::vector command_interpreter_usages,
+std::vector api_usages);
 typedef int (*ComparisonFunction)(const void *, const void *);
 typedef void (*DebuggerInitializeCallback)(Debugger );
 /// Trace
diff --git a/lldb/source/Commands/CMakeLists.txt 
b/lldb/source/Commands/CMakeLists.txt
index 6a36c5376d5c5..76397227d535d 100644
--- a/lldb/source/Commands/CMakeLists.txt
+++ 

[Lldb-commits] [lldb] [lldb/Commands] Add `scripting template list` command with auto discovery (PR #97273)

2024-07-01 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

Depends on #97263 

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


[Lldb-commits] [lldb] [lldb/Commands] Add `scripting template list` command with auto discovery (PR #97273)

2024-07-01 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben created 
https://github.com/llvm/llvm-project/pull/97273

This patch introduces a new `template` multiword sub-command to the
`scripting` top-level command. As the name suggests, this sub-command
operates on scripting templates, and currently has the ability to
automatically discover the various scripting extensions that lldb
supports.

Signed-off-by: Med Ismail Bennani 


>From 2a003d7d648e3c61a0562be4a533c5ec79cedd6d Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Mon, 1 Jul 2024 00:34:55 -0700
Subject: [PATCH 1/2] [lldb/Commands] Alias `script` command to `scripting
 execute`

This patch introduces a new top-level `scripting` command with an
`execute` sub-command, that basically replaces the `script` raw command.

To avoid breaking the `script` command usages, this patch also adds an
`script` alias to the `scripting execute` sub-command.

The reason behind this change is to have a top-level command that will
cover scripting related subcommands.

Signed-off-by: Med Ismail Bennani 
---
 lldb/source/Commands/CMakeLists.txt   |  2 +-
 ...tScript.cpp => CommandObjectScripting.cpp} | 44 +--
 ...bjectScript.h => CommandObjectScripting.h} | 17 ---
 lldb/source/Commands/Options.td   |  2 +-
 .../source/Interpreter/CommandInterpreter.cpp |  9 +++-
 5 files changed, 52 insertions(+), 22 deletions(-)
 rename lldb/source/Commands/{CommandObjectScript.cpp => 
CommandObjectScripting.cpp} (68%)
 rename lldb/source/Commands/{CommandObjectScript.h => 
CommandObjectScripting.h} (71%)

diff --git a/lldb/source/Commands/CMakeLists.txt 
b/lldb/source/Commands/CMakeLists.txt
index 6a36c5376d5c5..76397227d535d 100644
--- a/lldb/source/Commands/CMakeLists.txt
+++ b/lldb/source/Commands/CMakeLists.txt
@@ -26,7 +26,7 @@ add_lldb_library(lldbCommands NO_PLUGIN_DEPENDENCIES
   CommandObjectQuit.cpp
   CommandObjectRegexCommand.cpp
   CommandObjectRegister.cpp
-  CommandObjectScript.cpp
+  CommandObjectScripting.cpp
   CommandObjectSession.cpp
   CommandObjectSettings.cpp
   CommandObjectSource.cpp
diff --git a/lldb/source/Commands/CommandObjectScript.cpp 
b/lldb/source/Commands/CommandObjectScripting.cpp
similarity index 68%
rename from lldb/source/Commands/CommandObjectScript.cpp
rename to lldb/source/Commands/CommandObjectScripting.cpp
index 25f25b8e65947..72f653690e532 100644
--- a/lldb/source/Commands/CommandObjectScript.cpp
+++ b/lldb/source/Commands/CommandObjectScripting.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectScript.cpp 
---===//
+//===-- CommandObjectScripting.cpp 
===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-#include "CommandObjectScript.h"
+#include "CommandObjectScripting.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/DataFormatters/DataVisualization.h"
 #include "lldb/Host/Config.h"
@@ -21,10 +21,10 @@
 using namespace lldb;
 using namespace lldb_private;
 
-#define LLDB_OPTIONS_script
+#define LLDB_OPTIONS_scripting_execute
 #include "CommandOptions.inc"
 
-Status CommandObjectScript::CommandOptions::SetOptionValue(
+Status CommandObjectScriptingExecute::CommandOptions::SetOptionValue(
 uint32_t option_idx, llvm::StringRef option_arg,
 ExecutionContext *execution_context) {
   Status error;
@@ -46,27 +46,29 @@ Status CommandObjectScript::CommandOptions::SetOptionValue(
   return error;
 }
 
-void CommandObjectScript::CommandOptions::OptionParsingStarting(
+void CommandObjectScriptingExecute::CommandOptions::OptionParsingStarting(
 ExecutionContext *execution_context) {
   language = lldb::eScriptLanguageNone;
 }
 
 llvm::ArrayRef
-CommandObjectScript::CommandOptions::GetDefinitions() {
-  return llvm::ArrayRef(g_script_options);
+CommandObjectScriptingExecute::CommandOptions::GetDefinitions() {
+  return llvm::ArrayRef(g_scripting_execute_options);
 }
 
-CommandObjectScript::CommandObjectScript(CommandInterpreter )
+CommandObjectScriptingExecute::CommandObjectScriptingExecute(
+CommandInterpreter )
 : CommandObjectRaw(
-  interpreter, "script",
+  interpreter, "scripting execute",
   "Invoke the script interpreter with provided code and display any "
   "results.  Start the interactive interpreter if no code is 
supplied.",
-  "script [--language  --] []") {}
+  "scripting execute [--language  --] "
+  "[]") {}
 
-CommandObjectScript::~CommandObjectScript() = default;
+CommandObjectScriptingExecute::~CommandObjectScriptingExecute() = default;
 
-void CommandObjectScript::DoExecute(llvm::StringRef command,
-CommandReturnObject ) {
+void CommandObjectScriptingExecute::DoExecute(llvm::StringRef command,
+ 

  1   2   >