[Lldb-commits] [lldb] 4d1cf54 - [lldb] Fix build with MSVC by using LLVM_PRETTY_FUNCTION

2023-09-01 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-09-01T07:40:35Z
New Revision: 4d1cf5403fc05a738f2d548429dbd51cb2300765

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

LOG: [lldb] Fix build with MSVC by using LLVM_PRETTY_FUNCTION

Fixes #65157

07c215e8a8af54d0084af7291ac29fef3672fcd8 added some extra logging
which compiles ok with clang but not msvc. Use LLVM_PRETTY_FUNCTION
to fix that.

Fix suggested by Carlos Alberto Enciso.

Added: 


Modified: 
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp

Removed: 




diff  --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
index 1ef284c4690629..ebda9b230e677a 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -332,7 +332,7 @@ DYLDRendezvous::RendezvousAction 
DYLDRendezvous::GetAction() const {
 bool DYLDRendezvous::UpdateSOEntriesFromRemote() {
   const auto action = GetAction();
   Log *log = GetLog(LLDBLog::DynamicLoader);
-  LLDB_LOG(log, "{0} action = {1}", __PRETTY_FUNCTION__, ActionToCStr(action));
+  LLDB_LOG(log, "{0} action = {1}", LLVM_PRETTY_FUNCTION, 
ActionToCStr(action));
 
   if (action == eNoAction)
 return false;
@@ -372,7 +372,7 @@ bool DYLDRendezvous::UpdateSOEntries() {
   m_removed_soentries.clear();
   const auto action = GetAction();
   Log *log = GetLog(LLDBLog::DynamicLoader);
-  LLDB_LOG(log, "{0} action = {1}", __PRETTY_FUNCTION__, ActionToCStr(action));
+  LLDB_LOG(log, "{0} action = {1}", LLVM_PRETTY_FUNCTION, 
ActionToCStr(action));
   switch (action) {
   case eTakeSnapshot:
 m_soentries.clear();



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


[Lldb-commits] [PATCH] D156687: [lldb][AArch64] Add kind marker to ReadAll/WriteALLRegisterValues data

2023-09-01 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added inline comments.



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp:573
 
-  ::memcpy(dst, GetGPRBuffer(), GetGPRBufferSize());
-  dst += GetGPRBufferSize();
+  dst = AddSavedRegisters(dst, SavedRegistersKind::GPR, GetGPRBuffer(),
+  GetGPRBufferSize());

I think we have lost some of code readability of ReadAllRegisterValues function 
by introducing AddSavedRegisters mechanism. It does remove some duplication of 
memcpy but it also introduces some differentiation between 
Read/WritellRegisterValues functions. I am inclined that we should put the 
memcpy into ReadAllRegisterValues to make it look similar to its Write 
counterpart. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156687

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


[Lldb-commits] [PATCH] D157845: [lldb][AArch64] Remove bool return from UpdateARM64SVERegistersInfos

2023-09-01 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid accepted this revision.
omjavaid added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157845

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


[Lldb-commits] [PATCH] D157609: [lldb] Search debug file paths when looking for split DWARF files

2023-09-01 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 555330.
DavidSpickett added a comment.

In the interests of my own sanity I've squashed the subsequent review into this 
one
and applied the suggestions from both.

Also I changed the tests to look for a global so we don't have to update the
line number all the time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157609

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  
lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-dwoname-absolute-compdir.c
  
lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-absolute-compdir.c
  
lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-relative-compdir.c
  
lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-relative-compdir.c
  lldb/test/Shell/SymbolFile/DWARF/dwo-relative-filename-only-binary-dir.c

Index: lldb/test/Shell/SymbolFile/DWARF/dwo-relative-filename-only-binary-dir.c
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/dwo-relative-filename-only-binary-dir.c
@@ -0,0 +1,23 @@
+/// Check that LLDB can find a relative DWO file next to a binary just using the
+/// filename of that DWO. For example "main.dwo" not "a/b/main.dwo".
+// RUN: rm -rf %t.compdir/
+// RUN: mkdir -p %t.compdir/a/b/
+// RUN: cp %s %t.compdir/a/b/main.c
+// RUN: cd %t.compdir/a/
+/// The produced DWO is named b/main-main.dwo, with a DW_AT_comp_dir of a/.
+// RUN: %clang_host -g -gsplit-dwarf -fdebug-prefix-map=%t.compdir=. b/main.c -o b/main
+// RUN: cd ../..
+/// Move binary and DWO out of expected locations.
+// RUN: mv %t.compdir/a/b/main %t.compdir/
+// RUN: mv %t.compdir/a/b/main-main.dwo %t.compdir/
+// RUN: %lldb --no-lldbinit %t.compdir/main \
+// RUN:   -o "b main" -o "run" -o "p num" --batch 2>&1 | FileCheck %s
+
+// CHECK-NOT: warning: {{.*}}main unable to locate separate debug file (dwo, dwp). Debugging will be degraded.
+// CHECK: (int) 5
+
+int num = 5;
+
+int main(void) {
+  return 0;
+}
\ No newline at end of file
Index: lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-relative-compdir.c
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-relative-compdir.c
@@ -0,0 +1,28 @@
+/// Check that LLDB uses the paths in target.debug-file-search-paths to find
+/// split DWARF files with a relative DW_AT_comp_dir set, when the program file
+/// has been moved and/or we're executing it from another directory.
+// RUN: rm -rf %t.compdir/ %t.e/
+// RUN: mkdir -p %t.compdir/a/b/c/d/
+// RUN: cp %s %t.compdir/a/b/c/d/main.c
+// RUN: cd %t.compdir/a/b/
+/// The produced DWO is named c/d/main-main.dwo, with a DW_AT_comp_dir of a/b.
+// RUN: %clang_host -g -gsplit-dwarf -fdebug-prefix-map=%t.compdir=. c/d/main.c -o c/d/main
+// RUN: cd ../../..
+/// Move only the program, leaving the DWO file in place.
+// RUN: mv %t.compdir/a/b/c/d/main %t.compdir/a/
+/// Debug it from yet another path.
+// RUN: mkdir -p %t.e/
+// RUN: cd %t.e
+/// LLDB won't find the DWO next to the binary or in the current dir, so it
+/// should find the DWO file by doing %t.compdir/ + a/b/ + c/d/main-main.dwo.
+// RUN: %lldb --no-lldbinit %t.compdir/a/main \
+// RUN:   -O "settings append target.debug-file-search-paths %t.compdir" \
+// RUN:   -o "b main.c:27" -o "run" -o "frame variable" --batch 2>&1 | FileCheck %s
+
+// CHECK-NOT: warning: {{.*}}main unable to locate separate debug file (dwo, dwp). Debugging will be degraded.
+// CHECK: (int) num = 5
+
+int main(void) {
+  int num = 5;
+  return 0;
+}
\ No newline at end of file
Index: lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-relative-compdir.c
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-relative-compdir.c
@@ -0,0 +1,28 @@
+/// Check that when LLDB is looking for a relative DWO it uses the debug search
+/// paths setting. If it doesn't find it by adding the whole relative path to
+/// of DWO it should try adding just the filename (e.g. main.dwo) to each debug
+/// search path.
+// RUN: rm -rf %t.compdir/
+// RUN: mkdir -p %t.compdir/a/b/
+// RUN: cp %s %t.compdir/a/b/main.c
+// RUN: cd %t.compdir/a/
+/// The produced DWO is named /b/main-main.dwo, with a DW_AT_comp_dir of a/.
+// RUN: %clang_host -g -gsplit-dwarf -fdebug-prefix-map=%t.compdir=. b/main.c -o b/main
+// RUN: cd ../..
+/// Move the DWO file away from the expected location.
+// RUN: mv %t.compdir/a/b/main-main.dwo %t.compdir/
+/// LLDB won't find the DWO next to the binary or by adding the relative path
+/// to any of the search paths. So it should find the DWO file at
+/// %t.compdir/main-main.dwo.
+// RUN: %lldb --no-lldbinit %t.compdir/a/b/main \
+// RUN:   -O "settings appe

[Lldb-commits] [PATCH] D158182: [lldb] Try to find relative DWO files by file name only, as a last resort

2023-09-01 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett abandoned this revision.
DavidSpickett added a comment.

Squashed into previous review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158182

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


[Lldb-commits] [PATCH] D157609: [lldb] Add more ways to find split DWARF files

2023-09-01 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett marked 2 inline comments as done.
DavidSpickett added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:1755
+  dwo_file.AppendPathComponent(dwo_name);
+  found = FileSystem::Instance().Exists(dwo_file);
+} else {

clayborg wrote:
> If "found == false" here, do we want to fall through to the "else" clause 
> below? This would mean we have a full path to a DW_AT_comp_dir, but we didn't 
> find the .dwo file and "dwo_name" is relative, so maybe we should try to use 
> the relative "dwo_name" below without the comp dir if not found?
I've done this in this latest revision.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:1795
 
-  if (!FileSystem::Instance().Exists(dwo_file)) {
+  if (!found) {
 unit.SetDwoError(Status::createWithFormat(

clayborg wrote:
> Here is where we might think about doing the debug info search path + 
> basename searches since it doesn't matter if the .dwo file original path was 
> relative or not.
This is now done above, either relative or not will end up trying paths + 
dwoname and paths + filename.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157609

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


[Lldb-commits] [PATCH] D157609: [lldb] Add more ways to find split DWARF files

2023-09-01 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 555333.
DavidSpickett marked 2 inline comments as done.
DavidSpickett added a comment.

Use *.dwo in commands since I'm not sure the DWO name will be the
same everywhere. The specific name isn't important, we know there's
only going to be one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157609

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  
lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-dwoname-absolute-compdir.c
  
lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-absolute-compdir.c
  
lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-relative-compdir.c
  
lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-relative-compdir.c
  lldb/test/Shell/SymbolFile/DWARF/dwo-relative-filename-only-binary-dir.c

Index: lldb/test/Shell/SymbolFile/DWARF/dwo-relative-filename-only-binary-dir.c
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/dwo-relative-filename-only-binary-dir.c
@@ -0,0 +1,23 @@
+/// Check that LLDB can find a relative DWO file next to a binary just using the
+/// filename of that DWO. For example "main.dwo" not "a/b/main.dwo".
+// RUN: rm -rf %t.compdir/
+// RUN: mkdir -p %t.compdir/a/b/
+// RUN: cp %s %t.compdir/a/b/main.c
+// RUN: cd %t.compdir/a/
+/// The produced DWO is named b/main-main.dwo, with a DW_AT_comp_dir of a/.
+// RUN: %clang_host -g -gsplit-dwarf -fdebug-prefix-map=%t.compdir=. b/main.c -o b/main
+// RUN: cd ../..
+/// Move binary and DWO out of expected locations.
+// RUN: mv %t.compdir/a/b/main %t.compdir/
+// RUN: mv %t.compdir/a/b/*.dwo %t.compdir/
+// RUN: %lldb --no-lldbinit %t.compdir/main \
+// RUN:   -o "b main" -o "run" -o "p num" --batch 2>&1 | FileCheck %s
+
+// CHECK-NOT: warning: {{.*}}main unable to locate separate debug file (dwo, dwp). Debugging will be degraded.
+// CHECK: (int) 5
+
+int num = 5;
+
+int main(void) {
+  return 0;
+}
\ No newline at end of file
Index: lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-relative-compdir.c
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-relative-compdir.c
@@ -0,0 +1,28 @@
+/// Check that LLDB uses the paths in target.debug-file-search-paths to find
+/// split DWARF files with a relative DW_AT_comp_dir set, when the program file
+/// has been moved and/or we're executing it from another directory.
+// RUN: rm -rf %t.compdir/ %t.e/
+// RUN: mkdir -p %t.compdir/a/b/c/d/
+// RUN: cp %s %t.compdir/a/b/c/d/main.c
+// RUN: cd %t.compdir/a/b/
+/// The produced DWO is named c/d/main-main.dwo, with a DW_AT_comp_dir of a/b.
+// RUN: %clang_host -g -gsplit-dwarf -fdebug-prefix-map=%t.compdir=. c/d/main.c -o c/d/main
+// RUN: cd ../../..
+/// Move only the program, leaving the DWO file in place.
+// RUN: mv %t.compdir/a/b/c/d/main %t.compdir/a/
+/// Debug it from yet another path.
+// RUN: mkdir -p %t.e/
+// RUN: cd %t.e
+/// LLDB won't find the DWO next to the binary or in the current dir, so it
+/// should find the DWO file by doing %t.compdir/ + a/b/ + c/d/main-main.dwo.
+// RUN: %lldb --no-lldbinit %t.compdir/a/main \
+// RUN:   -O "settings append target.debug-file-search-paths %t.compdir" \
+// RUN:   -o "b main.c:27" -o "run" -o "frame variable" --batch 2>&1 | FileCheck %s
+
+// CHECK-NOT: warning: {{.*}}main unable to locate separate debug file (dwo, dwp). Debugging will be degraded.
+// CHECK: (int) num = 5
+
+int main(void) {
+  int num = 5;
+  return 0;
+}
\ No newline at end of file
Index: lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-relative-compdir.c
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-relative-compdir.c
@@ -0,0 +1,28 @@
+/// Check that when LLDB is looking for a relative DWO it uses the debug search
+/// paths setting. If it doesn't find it by adding the whole relative path to
+/// of DWO it should try adding just the filename (e.g. main.dwo) to each debug
+/// search path.
+// RUN: rm -rf %t.compdir/
+// RUN: mkdir -p %t.compdir/a/b/
+// RUN: cp %s %t.compdir/a/b/main.c
+// RUN: cd %t.compdir/a/
+/// The produced DWO is named /b/main-main.dwo, with a DW_AT_comp_dir of a/.
+// RUN: %clang_host -g -gsplit-dwarf -fdebug-prefix-map=%t.compdir=. b/main.c -o b/main
+// RUN: cd ../..
+/// Move the DWO file away from the expected location.
+// RUN: mv %t.compdir/a/b/*.dwo %t.compdir/
+/// LLDB won't find the DWO next to the binary or by adding the relative path
+/// to any of the search paths. So it should find the DWO file at
+/// %t.compdir/main-main.dwo.
+// RUN: %lldb --no-lldbinit %t.compdir/a/b/main \
+// RUN:   -O "settings append target.debug-file-search-paths %t.com

[Lldb-commits] [PATCH] D156687: [lldb][AArch64] Add kind marker to ReadAll/WriteALLRegisterValues data

2023-09-01 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp:573
 
-  ::memcpy(dst, GetGPRBuffer(), GetGPRBufferSize());
-  dst += GetGPRBufferSize();
+  dst = AddSavedRegisters(dst, SavedRegistersKind::GPR, GetGPRBuffer(),
+  GetGPRBufferSize());

omjavaid wrote:
> I think we have lost some of code readability of ReadAllRegisterValues 
> function by introducing AddSavedRegisters mechanism. It does remove some 
> duplication of memcpy but it also introduces some differentiation between 
> Read/WritellRegisterValues functions. I am inclined that we should put the 
> memcpy into ReadAllRegisterValues to make it look similar to its Write 
> counterpart. 
I added it to avoid repeating:
```
  Add kind whatever
  ::memcpy(dst, src, size);
  dst = dst + size;
```
Or rather, not repeating it because it was very easy to forget to advance the 
pointer. The same applies to WriteAllRegisterValues, but there is some more 
logic in between the steps so I didn't do it there.

If memcpy returned a pointer one beyond the end of the buffer I wouldn't mind 
doing:
```
Add kind
dst = memcpy(...)
```

But it only returns the original destination pointer.

So I'd rather not inline all the memcopies here but I could try harder to add a 
convenience function for WriteAllRegisterValues, so they more closely match.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156687

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


[Lldb-commits] [PATCH] D157883: [lldb][AArch64] Add SME's Array Storage (ZA) and streaming vector length (SVG) registers

2023-09-01 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 555343.
DavidSpickett added a comment.

Correct SVE reconfigure on non-SVE machines. It used to return if there was
no vg, which is correct, not sure why I changed that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157883

Files:
  lldb/include/lldb/Utility/RegisterValue.h
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
  lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Target/DynamicRegisterInfo.cpp
  
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
  
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_dynamic_resize/Makefile
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_dynamic_resize/TestZAThreadedDynamic.py
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_dynamic_resize/main.c
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/Makefile
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/TestZARegisterSaveRestore.py
  lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/main.c

Index: lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/main.c
===
--- /dev/null
+++ lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/main.c
@@ -0,0 +1,225 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Important details for this program:
+// * Making a syscall will disable streaming mode if it is active.
+// * Changing the vector length will make streaming mode and ZA inactive.
+// * ZA can be active independent of streaming mode.
+// * ZA's size is the streaming vector length squared.
+
+#ifndef PR_SME_SET_VL
+#define PR_SME_SET_VL 63
+#endif
+
+#ifndef PR_SME_GET_VL
+#define PR_SME_GET_VL 64
+#endif
+
+#ifndef PR_SME_VL_LEN_MASK
+#define PR_SME_VL_LEN_MASK 0x
+#endif
+
+#define SM_INST(c) asm volatile("msr s0_3_c4_c" #c "_3, xzr")
+#define SMSTART SM_INST(7)
+#define SMSTART_SM SM_INST(3)
+#define SMSTART_ZA SM_INST(5)
+#define SMSTOP SM_INST(6)
+#define SMSTOP_SM SM_INST(2)
+#define SMSTOP_ZA SM_INST(4)
+
+int start_vl = 0;
+int other_vl = 0;
+
+void write_sve_regs() {
+  // We assume the smefa64 feature is present, which allows ffr access
+  // in streaming mode.
+  asm volatile("setffr\n\t");
+  asm volatile("ptrue p0.b\n\t");
+  asm volatile("ptrue p1.h\n\t");
+  asm volatile("ptrue p2.s\n\t");
+  asm volatile("ptrue p3.d\n\t");
+  asm volatile("pfalse p4.b\n\t");
+  asm volatile("ptrue p5.b\n\t");
+  asm volatile("ptrue p6.h\n\t");
+  asm volatile("ptrue p7.s\n\t");
+  asm volatile("ptrue p8.d\n\t");
+  asm volatile("pfalse p9.b\n\t");
+  asm volatile("ptrue p10.b\n\t");
+  asm volatile("ptrue p11.h\n\t");
+  asm volatile("ptrue p12.s\n\t");
+  asm volatile("ptrue p13.d\n\t");
+  asm volatile("pfalse p14.b\n\t");
+  asm volatile("ptrue p15.b\n\t");
+
+  asm volatile("cpy  z0.b, p0/z, #1\n\t");
+  asm volatile("cpy  z1.b, p5/z, #2\n\t");
+  asm volatile("cpy  z2.b, p10/z, #3\n\t");
+  asm volatile("cpy  z3.b, p15/z, #4\n\t");
+  asm volatile("cpy  z4.b, p0/z, #5\n\t");
+  asm volatile("cpy  z5.b, p5/z, #6\n\t");
+  asm volatile("cpy  z6.b, p10/z, #7\n\t");
+  asm volatile("cpy  z7.b, p15/z, #8\n\t");
+  asm volatile("cpy  z8.b, p0/z, #9\n\t");
+  asm volatile("cpy  z9.b, p5/z, #10\n\t");
+  asm volatile("cpy  z10.b, p10/z, #11\n\t");
+  asm volatile("cpy  z11.b, p15/z, #12\n\t");
+  asm volatile("cpy  z12.b, p0/z, #13\n\t");
+  asm volatile("cpy  z13.b, p5/z, #14\n\t");
+  asm volatile("cpy  z14.b, p10/z, #15\n\t");
+  asm volatile("cpy  z15.b, p15/z, #16\n\t");
+  asm volatile("cpy  z16.b, p0/z, #17\n\t");
+  asm volatile("cpy  z17.b, p5/z, #18\n\t");
+  asm volatile("cpy  z18.b, p10/z, #19\n\t");
+  asm volatile("cpy  z19.b, p15/z, #20\n\t");
+  asm volatile("cpy  z20.b, p0/z, #21\n\t");
+  asm volatile("cpy  z21.b, p5/z, #22\n\t");
+  asm volatile("cpy  z22.b, p10/z, #23\n\t");
+  asm volatile("cpy  z23.b, p15/z, #24\n\t");
+  asm volatile("cpy  z24.b, p0/z, #25\n\t");
+  asm volatile("cpy  z25.b, p5/z, #26\n\t");
+  asm volatile("cpy  z26.b, p10/z, #27\n\t");
+  

[Lldb-commits] [PATCH] D156687: [lldb][AArch64] Add kind marker to ReadAll/WriteALLRegisterValues data

2023-09-01 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 555347.
DavidSpickett added a comment.

So this is almost the opposite of what you asked for, but I made 
WriteAllRegisterValues
similar to ReadAll by giving it it's own convenient wrapper function.

Which ensures you don't forget to set a valid bool, or increment the src 
pointer.

Also I realised I can dedupe a lot of if (error.Fail()). SVE is a bit special 
due
to writing header then header+register, so it does the header manually.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156687

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp

Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
@@ -499,6 +499,30 @@
   return Status("Failed to write register value");
 }
 
+enum SavedRegistersKind : uint32_t {
+  GPR,
+  SVE, // Used for SVE and SSVE.
+  FPR, // When there is no SVE, or SVE in FPSIMD mode.
+  MTE,
+  TLS,
+};
+
+static uint8_t *AddSavedRegistersKind(uint8_t *dst, SavedRegistersKind kind) {
+  *(reinterpret_cast(dst)) = kind;
+  return dst + sizeof(uint32_t);
+}
+
+static uint8_t *AddSavedRegistersData(uint8_t *dst, void *src, size_t size) {
+  ::memcpy(dst, src, size);
+  return dst + size;
+}
+
+static uint8_t *AddSavedRegisters(uint8_t *dst, enum SavedRegistersKind kind,
+  void *src, size_t size) {
+  dst = AddSavedRegistersKind(dst, kind);
+  return AddSavedRegistersData(dst, src, size);
+}
+
 Status NativeRegisterContextLinux_arm64::ReadAllRegisterValues(
 lldb::WritableDataBufferSP &data_sp) {
   // AArch64 register data must contain GPRs and either FPR or SVE registers.
@@ -512,33 +536,33 @@
   // corresponds to register sets enabled by current register context.
 
   Status error;
-  uint32_t reg_data_byte_size = GetGPRBufferSize();
+  uint32_t reg_data_byte_size = sizeof(SavedRegistersKind) + GetGPRBufferSize();
   error = ReadGPR();
   if (error.Fail())
 return error;
 
   // If SVE is enabled we need not copy FPR separately.
   if (GetRegisterInfo().IsSVEEnabled() || GetRegisterInfo().IsSSVEEnabled()) {
-reg_data_byte_size += GetSVEBufferSize();
-// Also store the current SVE mode.
-reg_data_byte_size += sizeof(uint32_t);
+// Store mode and register data.
+reg_data_byte_size +=
+sizeof(SavedRegistersKind) + sizeof(m_sve_state) + GetSVEBufferSize();
 error = ReadAllSVE();
   } else {
-reg_data_byte_size += GetFPRSize();
+reg_data_byte_size += sizeof(SavedRegistersKind) + GetFPRSize();
 error = ReadFPR();
   }
   if (error.Fail())
 return error;
 
   if (GetRegisterInfo().IsMTEEnabled()) {
-reg_data_byte_size += GetMTEControlSize();
+reg_data_byte_size += sizeof(SavedRegistersKind) + GetMTEControlSize();
 error = ReadMTEControl();
 if (error.Fail())
   return error;
   }
 
   // tpidr is always present but tpidr2 depends on SME.
-  reg_data_byte_size += GetTLSBufferSize();
+  reg_data_byte_size += sizeof(SavedRegistersKind) + GetTLSBufferSize();
   error = ReadTLS();
   if (error.Fail())
 return error;
@@ -546,29 +570,38 @@
   data_sp.reset(new DataBufferHeap(reg_data_byte_size, 0));
   uint8_t *dst = data_sp->GetBytes();
 
-  ::memcpy(dst, GetGPRBuffer(), GetGPRBufferSize());
-  dst += GetGPRBufferSize();
+  dst = AddSavedRegisters(dst, SavedRegistersKind::GPR, GetGPRBuffer(),
+  GetGPRBufferSize());
 
   if (GetRegisterInfo().IsSVEEnabled() || GetRegisterInfo().IsSSVEEnabled()) {
-*dst = static_cast(m_sve_state);
+dst = AddSavedRegistersKind(dst, SavedRegistersKind::SVE);
+*(reinterpret_cast(dst)) = m_sve_state;
 dst += sizeof(m_sve_state);
-::memcpy(dst, GetSVEBuffer(), GetSVEBufferSize());
-dst += GetSVEBufferSize();
+dst = AddSavedRegistersData(dst, GetSVEBuffer(), GetSVEBufferSize());
   } else {
-::memcpy(dst, GetFPRBuffer(), GetFPRSize());
-dst += GetFPRSize();
+dst = AddSavedRegisters(dst, SavedRegistersKind::FPR, GetFPRBuffer(),
+GetFPRSize());
   }
 
   if (GetRegisterInfo().IsMTEEnabled()) {
-::memcpy(dst, GetMTEControl(), GetMTEControlSize());
-dst += GetMTEControlSize();
+dst = AddSavedRegisters(dst, SavedRegistersKind::MTE, GetMTEControl(),
+GetMTEControlSize());
   }
 
-  ::memcpy(dst, GetTLSBuffer(), GetTLSBufferSize());
+  dst = AddSavedRegisters(dst, SavedRegistersKind::TLS, GetTLSBuffer(),
+  GetTLSBufferSize());
 
   return error;
 }
 
+static Status RestoreRegisters(void *buffer, const uint8_t **src, size_t len,
+   bool &is_valid, std::function writer) {
+  ::memcpy(buffer, *src

[Lldb-commits] [PATCH] D156687: [lldb][AArch64] Add kind marker to ReadAll/WriteALLRegisterValues data

2023-09-01 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

So hopefully it is more readable in both in the sense that Readall/writeall is 
almost declarative. The details are all in the helpers so you can't forget one 
of them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156687

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


[Lldb-commits] [PATCH] D157883: [lldb][AArch64] Add SME's Array Storage (ZA) and streaming vector length (SVG) registers

2023-09-01 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 555353.
DavidSpickett added a comment.

Rebase after changes to WriteAllRegisterValues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157883

Files:
  lldb/include/lldb/Utility/RegisterValue.h
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
  lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Target/DynamicRegisterInfo.cpp
  
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
  
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_dynamic_resize/Makefile
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_dynamic_resize/TestZAThreadedDynamic.py
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_dynamic_resize/main.c
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/Makefile
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/TestZARegisterSaveRestore.py
  lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/main.c

Index: lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/main.c
===
--- /dev/null
+++ lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/main.c
@@ -0,0 +1,225 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Important details for this program:
+// * Making a syscall will disable streaming mode if it is active.
+// * Changing the vector length will make streaming mode and ZA inactive.
+// * ZA can be active independent of streaming mode.
+// * ZA's size is the streaming vector length squared.
+
+#ifndef PR_SME_SET_VL
+#define PR_SME_SET_VL 63
+#endif
+
+#ifndef PR_SME_GET_VL
+#define PR_SME_GET_VL 64
+#endif
+
+#ifndef PR_SME_VL_LEN_MASK
+#define PR_SME_VL_LEN_MASK 0x
+#endif
+
+#define SM_INST(c) asm volatile("msr s0_3_c4_c" #c "_3, xzr")
+#define SMSTART SM_INST(7)
+#define SMSTART_SM SM_INST(3)
+#define SMSTART_ZA SM_INST(5)
+#define SMSTOP SM_INST(6)
+#define SMSTOP_SM SM_INST(2)
+#define SMSTOP_ZA SM_INST(4)
+
+int start_vl = 0;
+int other_vl = 0;
+
+void write_sve_regs() {
+  // We assume the smefa64 feature is present, which allows ffr access
+  // in streaming mode.
+  asm volatile("setffr\n\t");
+  asm volatile("ptrue p0.b\n\t");
+  asm volatile("ptrue p1.h\n\t");
+  asm volatile("ptrue p2.s\n\t");
+  asm volatile("ptrue p3.d\n\t");
+  asm volatile("pfalse p4.b\n\t");
+  asm volatile("ptrue p5.b\n\t");
+  asm volatile("ptrue p6.h\n\t");
+  asm volatile("ptrue p7.s\n\t");
+  asm volatile("ptrue p8.d\n\t");
+  asm volatile("pfalse p9.b\n\t");
+  asm volatile("ptrue p10.b\n\t");
+  asm volatile("ptrue p11.h\n\t");
+  asm volatile("ptrue p12.s\n\t");
+  asm volatile("ptrue p13.d\n\t");
+  asm volatile("pfalse p14.b\n\t");
+  asm volatile("ptrue p15.b\n\t");
+
+  asm volatile("cpy  z0.b, p0/z, #1\n\t");
+  asm volatile("cpy  z1.b, p5/z, #2\n\t");
+  asm volatile("cpy  z2.b, p10/z, #3\n\t");
+  asm volatile("cpy  z3.b, p15/z, #4\n\t");
+  asm volatile("cpy  z4.b, p0/z, #5\n\t");
+  asm volatile("cpy  z5.b, p5/z, #6\n\t");
+  asm volatile("cpy  z6.b, p10/z, #7\n\t");
+  asm volatile("cpy  z7.b, p15/z, #8\n\t");
+  asm volatile("cpy  z8.b, p0/z, #9\n\t");
+  asm volatile("cpy  z9.b, p5/z, #10\n\t");
+  asm volatile("cpy  z10.b, p10/z, #11\n\t");
+  asm volatile("cpy  z11.b, p15/z, #12\n\t");
+  asm volatile("cpy  z12.b, p0/z, #13\n\t");
+  asm volatile("cpy  z13.b, p5/z, #14\n\t");
+  asm volatile("cpy  z14.b, p10/z, #15\n\t");
+  asm volatile("cpy  z15.b, p15/z, #16\n\t");
+  asm volatile("cpy  z16.b, p0/z, #17\n\t");
+  asm volatile("cpy  z17.b, p5/z, #18\n\t");
+  asm volatile("cpy  z18.b, p10/z, #19\n\t");
+  asm volatile("cpy  z19.b, p15/z, #20\n\t");
+  asm volatile("cpy  z20.b, p0/z, #21\n\t");
+  asm volatile("cpy  z21.b, p5/z, #22\n\t");
+  asm volatile("cpy  z22.b, p10/z, #23\n\t");
+  asm volatile("cpy  z23.b, p15/z, #24\n\t");
+  asm volatile("cpy  z24.b, p0/z, #25\n\t");
+  asm volatile("cpy  z25.b, p5/z, #26\n\t");
+  asm volatile("cpy  z26.b, p10/z, #27\n\t");
+  asm volatile("cpy  z27.b, p15/z, #28\n\t");
+  asm volatile("cpy  z28.b, p0/z, #29

[Lldb-commits] [PATCH] D156687: [lldb][AArch64] Add kind marker to ReadAll/WriteALLRegisterValues data

2023-09-01 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added inline comments.



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp:539
   Status error;
-  uint32_t reg_data_byte_size = GetGPRBufferSize();
+  uint32_t reg_data_byte_size = sizeof(SavedRegistersKind) + 
GetGPRBufferSize();
   error = ReadGPR();

Now that we are trying to make both Read and Write look similar lets pull out 
size calculation into a separate helper function.



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp:577
   if (GetRegisterInfo().IsSVEEnabled() || GetRegisterInfo().IsSSVEEnabled()) {
-*dst = static_cast(m_sve_state);
+dst = AddSavedRegistersKind(dst, SavedRegistersKind::SVE);
+*(reinterpret_cast(dst)) = m_sve_state;

Another point that just came to my mind is the kind terminology used here. In 
LLDB we differentiate registers into kinds example: LLDB kinds, DWARF kinds. 
For differentiating between register in this an appropraite term would be 
"register set".  So lets rename this to SaveRegisterSet/RestoreRegisterSet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156687

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


[Lldb-commits] [PATCH] D156687: [lldb][AArch64] Add kind marker to ReadAll/WriteALLRegisterValues data

2023-09-01 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added inline comments.



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp:503
+enum SavedRegistersKind : uint32_t {
+  GPR,
+  SVE, // Used for SVE and SSVE.

Consider renaming this to RegisterSetName or RegisterSetType


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156687

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


[Lldb-commits] [PATCH] D159315: [lldb] Add OperatingSystem base class to the lldb python module

2023-09-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

In D159315#4633227 , @hawkinsw wrote:

> I hope that some comments are helpful! The documentation that you added is 
> tremendously helpful -- I know how documentation is sometimes a thankless 
> task, so I will say what everyone is thinking: "THANK YOU".

Thanks @hawkinsw ! I really appreciate it :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159315

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


[Lldb-commits] [PATCH] D159315: [lldb] Add OperatingSystem base class to the lldb python module

2023-09-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 555397.
mib added a reviewer: hawkinsw.
mib added a comment.

Address @hawkinsw feedbacks.


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

https://reviews.llvm.org/D159315

Files:
  lldb/bindings/python/CMakeLists.txt
  lldb/examples/python/templates/operating_system.py
  lldb/examples/python/templates/scripted_process.py
  lldb/test/API/functionalities/plugins/python_os_plugin/operating_system.py

Index: lldb/test/API/functionalities/plugins/python_os_plugin/operating_system.py
===
--- lldb/test/API/functionalities/plugins/python_os_plugin/operating_system.py
+++ lldb/test/API/functionalities/plugins/python_os_plugin/operating_system.py
@@ -1,29 +1,14 @@
-#!/usr/bin/env python
-
 import lldb
 import struct
 
+from lldb.plugins.operating_system import OperatingSystem
+
 
-class OperatingSystemPlugIn(object):
+class OperatingSystemPlugIn(OperatingSystem):
 """Class that provides data for an instance of a LLDB 'OperatingSystemPython' plug-in class"""
 
 def __init__(self, process):
-"""Initialization needs a valid.SBProcess object.
-
-This plug-in will get created after a live process is valid and has stopped for the
-first time."""
-self.process = None
-self.registers = None
-self.threads = None
-if isinstance(process, lldb.SBProcess) and process.IsValid():
-self.process = process
-self.threads = None  # Will be an dictionary containing info for each thread
-
-def get_target(self):
-# NOTE: Don't use "lldb.target" when trying to get your target as the "lldb.target"
-# tracks the current target in the LLDB command interpreter which isn't the
-# correct thing to use for this plug-in.
-return self.process.target
+super().__init__(process)
 
 def create_thread(self, tid, context):
 if tid == 0x4:
@@ -40,23 +25,6 @@
 
 def get_thread_info(self):
 if not self.threads:
-# The sample dictionary below shows the values that can be returned for a thread
-# tid => thread ID (mandatory)
-# name => thread name (optional key/value pair)
-# queue => thread dispatch queue name (optional key/value pair)
-# state => thred state (mandatory, set to 'stopped' for now)
-# stop_reason => thread stop reason. (mandatory, usually set to 'none')
-#  Possible values include:
-#   'breakpoint' if the thread is stopped at a breakpoint
-#   'none' thread is just stopped because the process is stopped
-#   'trace' the thread just single stepped
-#   The usual value for this while threads are in memory is 'none'
-# register_data_addr => the address of the register data in memory (optional key/value pair)
-#   Specifying this key/value pair for a thread will avoid a call to get_register_data()
-#   and can be used when your registers are in a thread context structure that is contiguous
-#   in memory. Don't specify this if your register layout in memory doesn't match the layout
-# described by the dictionary returned from a call to the
-# get_register_info() method.
 self.threads = [
 {
 "tid": 0x1,
Index: lldb/examples/python/templates/scripted_process.py
===
--- lldb/examples/python/templates/scripted_process.py
+++ lldb/examples/python/templates/scripted_process.py
@@ -244,16 +244,16 @@
 """
 
 @abstractmethod
-def __init__(self, scripted_process, args):
+def __init__(self, process, args):
 """Construct a scripted thread.
 
 Args:
-process (ScriptedProcess): The scripted process owning this thread.
+process (ScriptedProcess/lldb.SBProcess): The process owning this thread.
 args (lldb.SBStructuredData): A Dictionary holding arbitrary
 key/value pairs used by the scripted thread.
 """
 self.target = None
-self.scripted_process = None
+self.originating_process = None
 self.process = None
 self.args = None
 self.idx = 0
@@ -268,9 +268,13 @@
 self.frames = []
 self.extended_info = []
 
-if isinstance(scripted_process, ScriptedProcess):
-self.target = scripted_process.target
-self.scripted_process = scripted_process
+if (
+isinstance(process, ScriptedProcess)
+or isinstance(process, lldb.SBProcess)
+and process.IsValid()
+):
+self.target = process.target
+self.originating_process = process
 self.process = self.target.GetProcess()
 self.get_register_info()
 
@@ -354,1

[Lldb-commits] [PATCH] D159315: [lldb] Add OperatingSystem base class to the lldb python module

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

Looks great. LGTM!


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

https://reviews.llvm.org/D159315

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


[Lldb-commits] [PATCH] D159164: [lldb] Add assembly syntax highlighting

2023-09-01 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Yes, this simplifies the patch a lot. Looks good after we check the mnemonic 
and comment for no color when used through the SBInstruction APIs.




Comment at: 
lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py:69
+ci.HandleCommand("settings set use-color true", res)
+self.assertEqual(inst.GetOperands(target), "w0, #0x63")
+ci.HandleCommand("settings set use-color false", res)

Can we check both:
```
inst.GetMnemonic(target)
inst.GetComment(target)
```
here too to make sure no colorization gets added?


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

https://reviews.llvm.org/D159164

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


[Lldb-commits] [PATCH] D159164: [lldb] Add assembly syntax highlighting

2023-09-01 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 555417.
JDevlieghere marked an inline comment as done.
JDevlieghere added a comment.

Test `GetMnemonic` and `GetComment`.


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

https://reviews.llvm.org/D159164

Files:
  lldb/include/lldb/Core/Disassembler.h
  lldb/source/Core/Disassembler.cpp
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h
  lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py

Index: lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
===
--- lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
+++ lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
@@ -59,9 +59,19 @@
 elif arch in ("aarch64", "arm64"):
 self.assertEqual(inst.GetMnemonic(target), "mov")
 self.assertEqual(inst.GetOperands(target), "w0, #0x63")
+self.assertEqual(inst.GetComment(target), "=99 ")
 self.assertEqual(
 inst.GetControlFlowKind(target), lldb.eInstructionControlFlowKindUnknown
 )
+# Make sure that using colors doesn't affect the output here.
+res = lldb.SBCommandReturnObject()
+ci = self.dbg.GetCommandInterpreter()
+ci.HandleCommand("settings set use-color true", res)
+self.assertEqual(inst.GetOperands(target), "w0, #0x63")
+self.assertEqual(inst.GetMnemonic(target), "mov")
+self.assertEqual(inst.GetComment(target), "=99 ")
+ci.HandleCommand("settings set use-color false", res)
+
 elif arch == "arm":
 self.assertEqual(inst.GetMnemonic(target), "mov")
 self.assertEqual(inst.GetOperands(target), "r3, #99")
Index: lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h
===
--- lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h
+++ lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h
@@ -42,6 +42,8 @@
 lldb::offset_t data_offset, size_t num_instructions,
 bool append, bool data_from_file) override;
 
+  void SetUseColor(bool use_color) override;
+
   // PluginInterface protocol
   llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
 
Index: lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
===
--- lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -9,6 +9,7 @@
 #include "DisassemblerLLVMC.h"
 
 #include "llvm-c/Disassembler.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/MC/MCAsmInfo.h"
@@ -63,6 +64,8 @@
   void PrintMCInst(llvm::MCInst &mc_inst, lldb::addr_t pc,
std::string &inst_string, std::string &comments_string);
   void SetStyle(bool use_hex_immed, HexImmediateStyle hex_style);
+  void SetUseColor(bool use_color);
+  bool GetUseColor() const;
   bool CanBranch(llvm::MCInst &mc_inst) const;
   bool HasDelaySlot(llvm::MCInst &mc_inst) const;
   bool IsCall(llvm::MCInst &mc_inst) const;
@@ -576,6 +579,12 @@
 else
   mc_disasm_ptr = disasm->m_disasm_up.get();
 
+// Disable coloring for the duration of this function.
+const bool saved_use_color = mc_disasm_ptr->GetUseColor();
+mc_disasm_ptr->SetUseColor(false);
+auto on_exit = llvm::make_scope_exit(
+[=]() { mc_disasm_ptr->SetUseColor(saved_use_color); });
+
 lldb::addr_t pc = m_address.GetFileAddress();
 m_using_file_addr = true;
 
@@ -1344,10 +1353,12 @@
   llvm::raw_string_ostream inst_stream(inst_string);
   llvm::raw_string_ostream comments_stream(comments_string);
 
+  inst_stream.enable_colors(m_instr_printer_up->getUseColor());
   m_instr_printer_up->setCommentStream(comments_stream);
   m_instr_printer_up->printInst(&mc_inst, pc, llvm::StringRef(),
 *m_subtarget_info_up, inst_stream);
   m_instr_printer_up->setCommentStream(llvm::nulls());
+
   comments_stream.flush();
 
   static std::string g_newlines("\r\n");
@@ -1374,6 +1385,14 @@
   }
 }
 
+void DisassemblerLLVMC::MCDisasmInstance::SetUseColor(bool use_color) {
+  m_instr_printer_up->setUseColor(use_color);
+}
+
+bool DisassemblerLLVMC::MCDisasmInstance::GetUseColor() const {
+  return m_instr_printer_up->getUseColor();
+}
+
 bool DisassemblerLLVMC::MCDisasmInstance::CanBranch(
 llvm::MCInst &mc_inst) const {
   if (m_instr_analysis_up)
@@ -1597,6 +1616,13 @@
   return lldb::DisassemblerSP();
 }
 
+void DisassemblerLLVMC::SetUseColor(bool use_color) {
+  if (m_disasm_up)
+m_disasm_up->SetUseColor(use_color);
+ 

[Lldb-commits] [PATCH] D159315: [lldb] Add OperatingSystem base class to the lldb python module

2023-09-01 Thread Alex Langford via Phabricator via lldb-commits
bulbazord accepted this revision.
bulbazord added a comment.

LGTM


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

https://reviews.llvm.org/D159315

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


[Lldb-commits] [PATCH] D157609: [lldb] Add more ways to find split DWARF files

2023-09-01 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:1801
+FileSpecList dwo_paths;
+FileSpec spec_to_get_name(dwo_name);
+llvm::StringRef filename_only = spec_to_get_name.GetFilename();

Rename to "dwo_name_spec"? I think we can use this down below in following 
inline comments



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:1804
+
+FileSpec next_to_binary(
+m_objfile_sp->GetFileSpec().GetDirectory().GetStringRef());

Rename to "binary_directory"?



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:1808-1810
+FileSpec dwo_name_next_to_binary(next_to_binary);
+dwo_name_next_to_binary.AppendPathComponent(dwo_name);
+dwo_paths.Append(dwo_name_next_to_binary);

Should we only do this if "dwo_name" is relative? Also if "comp_dir" is 
relative, do we want to add another path to search here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157609

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


[Lldb-commits] [PATCH] D159164: [lldb] Add assembly syntax highlighting

2023-09-01 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

lgtm. Is there any more things you want to add to this patch test wise, or is 
this complete?


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

https://reviews.llvm.org/D159164

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


[Lldb-commits] [PATCH] D159164: [lldb] Add assembly syntax highlighting

2023-09-01 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 555442.
JDevlieghere added a comment.

As I was adding another test I realized an issue with the previous approach due 
to the fact that we cache the result. The solution is to cache both the plain 
and the marked up result, and have the different accessors decide whether they 
want colored output or not. As a result, I've removed the global Disassembler 
option to enable color, as it's not really meaningful anymore. I've also added 
a test to make sure this doesn't break.


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

https://reviews.llvm.org/D159164

Files:
  lldb/include/lldb/Core/Disassembler.h
  lldb/source/API/SBInstruction.cpp
  lldb/source/API/SBInstructionList.cpp
  lldb/source/Core/Disassembler.cpp
  lldb/source/Core/DumpDataExtractor.cpp
  lldb/source/Expression/IRExecutionUnit.cpp
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
  
lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
  lldb/source/Symbol/Function.cpp
  lldb/source/Symbol/Symbol.cpp
  lldb/source/Target/ThreadPlanTracer.cpp
  lldb/source/Target/TraceDumper.cpp
  lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
  lldb/test/Shell/Commands/command-disassemble-aarch64-color.s

Index: lldb/test/Shell/Commands/command-disassemble-aarch64-color.s
===
--- /dev/null
+++ lldb/test/Shell/Commands/command-disassemble-aarch64-color.s
@@ -0,0 +1,32 @@
+# REQUIRES: aarch64
+
+# This checks that lldb's disassembler colors AArch64 disassembly.
+
+# RUN: llvm-mc -filetype=obj -triple aarch64-linux-gnueabihf %s -o %t --mattr=+all
+# RUN: %lldb %t -o "settings set use-color true" -o "disassemble -n fn" -o exit 2>&1 | FileCheck %s
+
+.globl  fn
+.type   fn, @function
+fn:
+  // These are in alphabetical order by extension name
+  aesd v0.16b, v0.16b   // AEK_AES
+  bfadd z23.h, p3/m, z23.h, z13.h   // AEK_B16B16
+  bfdot v2.2s, v3.4h, v4.4h // AEK_BF16
+  brb iall  // AEK_BRBE
+  crc32b w0, w0, w0 // AEK_CRC
+  // AEK_CRYPTO enables a combination of other features
+  smin x0, x0, #0   // AEK_CSSC
+  sysp	#0, c2, c0, #0, x0, x1  // AEK_D128
+  sdot v0.2s, v1.8b, v2.8b  // AEK_DOTPROD
+  fmmla z0.s, z1.s, z2.s// AEK_F32MM
+
+# CHECK: `fn:
+# CHECK-NEXT: [0x0] <+0>:aesd   v0.16b, v0.16b
+# CHECK-NEXT: [0x4] <+4>:bfadd  z23.h, p3/m, z23.h, z13.h
+# CHECK-NEXT: [0x8] <+8>:bfdot  v2.2s, v3.4h, v4.4h
+# CHECK-NEXT: [0xc] <+12>:   brbiall
+# CHECK-NEXT: [0x10] <+16>:  crc32b w0, w0, w0
+# CHECK-NEXT: [0x14] <+20>:  smin   x0, x0, #0x0
+# CHECK-NEXT: [0x18] <+24>:  sysp   #0x0, c2, c0, #0x0, x0, x1
+# CHECK-NEXT: [0x1c] <+28>:  sdot   v0.2s, v1.8b, v2.8b
+# CHECK-NEXT: [0x20] <+32>:  fmmla  z0.s, z1.s, z2.s
Index: lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
===
--- lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
+++ lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
@@ -59,9 +59,19 @@
 elif arch in ("aarch64", "arm64"):
 self.assertEqual(inst.GetMnemonic(target), "mov")
 self.assertEqual(inst.GetOperands(target), "w0, #0x63")
+self.assertEqual(inst.GetComment(target), "=99 ")
 self.assertEqual(
 inst.GetControlFlowKind(target), lldb.eInstructionControlFlowKindUnknown
 )
+# Make sure that using colors doesn't affect the output here.
+res = lldb.SBCommandReturnObject()
+ci = self.dbg.GetCommandInterpreter()
+ci.HandleCommand("settings set use-color true", res)
+self.assertEqual(inst.GetOperands(target), "w0, #0x63")
+self.assertEqual(inst.GetMnemonic(target), "mov")
+self.assertEqual(inst.GetComment(target), "=99 ")
+ci.HandleCommand("settings set use-color false", res)
+
 elif arch == "arm":
 self.assertEqual(inst.GetMnemonic(target), "mov")
 self.assertEqual(inst.GetOperands(target), "r3, #99")
Index: lldb/source/Target/TraceDumper.cpp
===
--- lldb/source/Target/TraceDumper.cpp
+++ lldb/source/Target/TraceDumper.cpp
@@ -189,7 +189,8 @@
 &m_s, /*max_opcode_byte_size=*/0,
 /*show_address=*/false,
 /*show_bytes=*/false, m_options.show_control_flow_kind,
-&item.symbol_info->exe_ctx, &item.symbol_info-

[Lldb-commits] [PATCH] D159164: [lldb] Add assembly syntax highlighting

2023-09-01 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

@clayborg let me know if you're happy with this. To answer your previous 
question, I'm not planning anymore changes.


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

https://reviews.llvm.org/D159164

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


[Lldb-commits] [PATCH] D159164: [lldb] Add assembly syntax highlighting

2023-09-01 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: lldb/include/lldb/Core/Disassembler.h:158
 bool show_bytes, bool show_control_flow_kind,
-const ExecutionContext *exe_ctx,
+bool show_color, const ExecutionContext *exe_ctx,
 const SymbolContext *sym_ctx,

We might not need "bool show_color" here if we can rely on the 
"exe_ctx->GetTarget()->GetDebugger()"?



Comment at: lldb/include/lldb/Core/Disassembler.h:343-344
   void Dump(Stream *s, bool show_address, bool show_bytes,
-bool show_control_flow_kind, const ExecutionContext *exe_ctx);
+bool show_control_flow_kind, bool show_color,
+const ExecutionContext *exe_ctx);
 

Ditto here. Should we rely on the exe_ctx having a target and thus we can get 
to the debugger instead of passing "show_color" as a separate arg?



Comment at: lldb/include/lldb/Core/Disassembler.h:457-458
  bool mixed_source_and_assembly,
- uint32_t num_mixed_context_lines, uint32_t options,
- Stream &strm);
+ uint32_t num_mixed_context_lines, bool show_color,
+ uint32_t options, Stream &strm);
 

should "show_color" be put as a bit into the "options" instead?



Comment at: lldb/source/API/SBInstruction.cpp:263-264
 FormatEntity::Parse("${addr}: ", format);
 inst_sp->Dump(&s.ref(), 0, true, false, /*show_control_flow_kind=*/false,
-  nullptr, &sc, nullptr, &format, 0);
+  /*show_color=*/false, nullptr, &sc, nullptr, &format, 0);
 return true;

If we rely on the execution context being NULL, then we don't need to pass in 
color as false here.



Comment at: lldb/source/API/SBInstruction.cpp:299
 inst_sp->Dump(&out_stream, 0, true, false, 
/*show_control_flow_kind=*/false,
-  nullptr, &sc, nullptr, &format, 0);
+  /*show_color=*/false, nullptr, &sc, nullptr, &format, 0);
   }

ditto



Comment at: lldb/source/API/SBInstructionList.cpp:169-170
 inst->Dump(&sref, max_opcode_byte_size, true, false,
-   /*show_control_flow_kind=*/false, nullptr, &sc, &prev_sc,
-   &format, 0);
+   /*show_control_flow_kind=*/false, /*show_color=*/false,
+   nullptr, &sc, &prev_sc, &format, 0);
 sref.EOL();

ditto



Comment at: lldb/source/Core/Disassembler.cpp:604-605
bool show_address, bool show_bytes,
-   bool show_control_flow_kind,
+   bool show_control_flow_kind, bool show_color,
const ExecutionContext *exe_ctx,
const SymbolContext *sym_ctx,

Should we just rely on the "exe_ctx" having a target here instead of adding a 
new parameter here? Cause we can do "exe_ctx->GetTarget()->GetDebugger()" if 
needed. If no exe_ctx, then assume no color?



Comment at: lldb/source/Core/Disassembler.cpp:658
+  if (opcode_name.length() >= opcode_column_width) {
+opcode_column_width = opcode_name.length() + 1;
   }

The color codes bytes should't contribute to the opcode columns width. We 
should probably use "m_opcode_name", but we will need to guarantee that both 
are filled in if we ask for color. Can we modify it so if we ask for the opcode 
name with color that we always fill in the m_opcode_name in as well?



Comment at: lldb/source/Core/DumpDataExtractor.cpp:160
+s, show_address, show_bytes, show_control_flow_kind,
+target_sp->GetDebugger().GetUseColor(), &exe_ctx);
   }

Here is an example of where we fill the execution context in with the target, 
but also pass in "target_sp->GetDebugger().GetUseColor()"


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

https://reviews.llvm.org/D159164

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


[Lldb-commits] [PATCH] D159164: [lldb] Add assembly syntax highlighting

2023-09-01 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 555489.
JDevlieghere marked 9 inline comments as done.
JDevlieghere added a comment.

Use the execution context to enable colors.


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

https://reviews.llvm.org/D159164

Files:
  lldb/include/lldb/Core/Disassembler.h
  lldb/source/Core/Disassembler.cpp
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
  lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
  lldb/test/Shell/Commands/command-disassemble-aarch64-color.s

Index: lldb/test/Shell/Commands/command-disassemble-aarch64-color.s
===
--- /dev/null
+++ lldb/test/Shell/Commands/command-disassemble-aarch64-color.s
@@ -0,0 +1,32 @@
+# REQUIRES: aarch64
+
+# This checks that lldb's disassembler colors AArch64 disassembly.
+
+# RUN: llvm-mc -filetype=obj -triple aarch64-linux-gnueabihf %s -o %t --mattr=+all
+# RUN: %lldb %t -o "settings set use-color true" -o "disassemble -n fn" -o exit 2>&1 | FileCheck %s
+
+.globl  fn
+.type   fn, @function
+fn:
+  // These are in alphabetical order by extension name
+  aesd v0.16b, v0.16b   // AEK_AES
+  bfadd z23.h, p3/m, z23.h, z13.h   // AEK_B16B16
+  bfdot v2.2s, v3.4h, v4.4h // AEK_BF16
+  brb iall  // AEK_BRBE
+  crc32b w0, w0, w0 // AEK_CRC
+  // AEK_CRYPTO enables a combination of other features
+  smin x0, x0, #0   // AEK_CSSC
+  sysp	#0, c2, c0, #0, x0, x1  // AEK_D128
+  sdot v0.2s, v1.8b, v2.8b  // AEK_DOTPROD
+  fmmla z0.s, z1.s, z2.s// AEK_F32MM
+
+# CHECK: `fn:
+# CHECK-NEXT: [0x0] <+0>:aesd   v0.16b, v0.16b
+# CHECK-NEXT: [0x4] <+4>:bfadd  z23.h, p3/m, z23.h, z13.h
+# CHECK-NEXT: [0x8] <+8>:bfdot  v2.2s, v3.4h, v4.4h
+# CHECK-NEXT: [0xc] <+12>:   brbiall
+# CHECK-NEXT: [0x10] <+16>:  crc32b w0, w0, w0
+# CHECK-NEXT: [0x14] <+20>:  smin   x0, x0, #0x0
+# CHECK-NEXT: [0x18] <+24>:  sysp   #0x0, c2, c0, #0x0, x0, x1
+# CHECK-NEXT: [0x1c] <+28>:  sdot   v0.2s, v1.8b, v2.8b
+# CHECK-NEXT: [0x20] <+32>:  fmmla  z0.s, z1.s, z2.s
Index: lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
===
--- lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
+++ lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
@@ -59,9 +59,19 @@
 elif arch in ("aarch64", "arm64"):
 self.assertEqual(inst.GetMnemonic(target), "mov")
 self.assertEqual(inst.GetOperands(target), "w0, #0x63")
+self.assertEqual(inst.GetComment(target), "=99 ")
 self.assertEqual(
 inst.GetControlFlowKind(target), lldb.eInstructionControlFlowKindUnknown
 )
+# Make sure that using colors doesn't affect the output here.
+res = lldb.SBCommandReturnObject()
+ci = self.dbg.GetCommandInterpreter()
+ci.HandleCommand("settings set use-color true", res)
+self.assertEqual(inst.GetOperands(target), "w0, #0x63")
+self.assertEqual(inst.GetMnemonic(target), "mov")
+self.assertEqual(inst.GetComment(target), "=99 ")
+ci.HandleCommand("settings set use-color false", res)
+
 elif arch == "arm":
 self.assertEqual(inst.GetMnemonic(target), "mov")
 self.assertEqual(inst.GetOperands(target), "r3, #99")
Index: lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
===
--- lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -63,6 +63,8 @@
   void PrintMCInst(llvm::MCInst &mc_inst, lldb::addr_t pc,
std::string &inst_string, std::string &comments_string);
   void SetStyle(bool use_hex_immed, HexImmediateStyle hex_style);
+  void SetUseColor(bool use_color);
+  bool GetUseColor() const;
   bool CanBranch(llvm::MCInst &mc_inst) const;
   bool HasDelaySlot(llvm::MCInst &mc_inst) const;
   bool IsCall(llvm::MCInst &mc_inst) const;
@@ -565,7 +567,9 @@
 
 if (m_opcode.GetData(data)) {
   std::string out_string;
+  std::string markup_out_string;
   std::string comment_string;
+  std::string markup_comment_string;
 
   DisassemblerScope disasm(*this, exe_ctx);
   if (disasm) {
@@ -607,7 +611,14 @@
 
 if (inst_size > 0) {
   mc_disasm_ptr->SetStyle(use_hex_immediates, hex_style);
+
+  const bool saved_use_color = mc_disasm_ptr->GetUseCol

[Lldb-commits] [PATCH] D159164: [lldb] Add assembly syntax highlighting

2023-09-01 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Just one last inline comment where we can't use the colorized string to 
calculate the column width and this is good to go.




Comment at: lldb/source/Core/Disassembler.cpp:662-663
   // consistent column spacing in these cases, unfortunately.
-  if (m_opcode_name.length() >= opcode_column_width) {
-opcode_column_width = m_opcode_name.length() + 1;
+  if (opcode_name.length() >= opcode_column_width) {
+opcode_column_width = opcode_name.length() + 1;
   }

still need to directly use "m_opcode_name" here instead of "opcode_name" so we 
don't include color codes as characters.


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

https://reviews.llvm.org/D159164

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


[Lldb-commits] [PATCH] D159164: [lldb] Add assembly syntax highlighting

2023-09-01 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere marked an inline comment as done.
JDevlieghere added a comment.

Thanks Greg!


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

https://reviews.llvm.org/D159164

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


[Lldb-commits] [PATCH] D159164: [lldb] Add assembly syntax highlighting

2023-09-01 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: lldb/source/Core/Disassembler.cpp:662-663
   // consistent column spacing in these cases, unfortunately.
-  if (m_opcode_name.length() >= opcode_column_width) {
-opcode_column_width = m_opcode_name.length() + 1;
+  if (opcode_name.length() >= opcode_column_width) {
+opcode_column_width = opcode_name.length() + 1;
   }

clayborg wrote:
> still need to directly use "m_opcode_name" here instead of "opcode_name" so 
> we don't include color codes as characters.



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

https://reviews.llvm.org/D159164

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


[Lldb-commits] [PATCH] D159164: [lldb] Add assembly syntax highlighting

2023-09-01 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa69f78b080ef: [lldb] Add syntax color highlighting for 
disassembly (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D159164?vs=555489&id=13#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159164

Files:
  lldb/include/lldb/Core/Disassembler.h
  lldb/source/Core/Disassembler.cpp
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
  lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
  lldb/test/Shell/Commands/command-disassemble-aarch64-color.s

Index: lldb/test/Shell/Commands/command-disassemble-aarch64-color.s
===
--- /dev/null
+++ lldb/test/Shell/Commands/command-disassemble-aarch64-color.s
@@ -0,0 +1,33 @@
+# UNSUPPORTED: system-windows
+# REQUIRES: aarch64
+
+# This checks that lldb's disassembler colors AArch64 disassembly.
+
+# RUN: llvm-mc -filetype=obj -triple aarch64-linux-gnueabihf %s -o %t --mattr=+all
+# RUN: %lldb %t -o "settings set use-color true" -o "disassemble -n fn" -o exit 2>&1 | FileCheck %s
+
+.globl  fn
+.type   fn, @function
+fn:
+  // These are in alphabetical order by extension name
+  aesd v0.16b, v0.16b   // AEK_AES
+  bfadd z23.h, p3/m, z23.h, z13.h   // AEK_B16B16
+  bfdot v2.2s, v3.4h, v4.4h // AEK_BF16
+  brb iall  // AEK_BRBE
+  crc32b w0, w0, w0 // AEK_CRC
+  // AEK_CRYPTO enables a combination of other features
+  smin x0, x0, #0   // AEK_CSSC
+  sysp	#0, c2, c0, #0, x0, x1  // AEK_D128
+  sdot v0.2s, v1.8b, v2.8b  // AEK_DOTPROD
+  fmmla z0.s, z1.s, z2.s// AEK_F32MM
+
+# CHECK: `fn:
+# CHECK-NEXT: [0x0] <+0>:aesd   v0.16b, v0.16b
+# CHECK-NEXT: [0x4] <+4>:bfadd  z23.h, p3/m, z23.h, z13.h
+# CHECK-NEXT: [0x8] <+8>:bfdot  v2.2s, v3.4h, v4.4h
+# CHECK-NEXT: [0xc] <+12>:   brbiall
+# CHECK-NEXT: [0x10] <+16>:  crc32b w0, w0, w0
+# CHECK-NEXT: [0x14] <+20>:  smin   x0, x0, #0x0
+# CHECK-NEXT: [0x18] <+24>:  sysp   #0x0, c2, c0, #0x0, x0, x1
+# CHECK-NEXT: [0x1c] <+28>:  sdot   v0.2s, v1.8b, v2.8b
+# CHECK-NEXT: [0x20] <+32>:  fmmla  z0.s, z1.s, z2.s
Index: lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
===
--- lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
+++ lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
@@ -59,9 +59,19 @@
 elif arch in ("aarch64", "arm64"):
 self.assertEqual(inst.GetMnemonic(target), "mov")
 self.assertEqual(inst.GetOperands(target), "w0, #0x63")
+self.assertEqual(inst.GetComment(target), "=99 ")
 self.assertEqual(
 inst.GetControlFlowKind(target), lldb.eInstructionControlFlowKindUnknown
 )
+# Make sure that using colors doesn't affect the output here.
+res = lldb.SBCommandReturnObject()
+ci = self.dbg.GetCommandInterpreter()
+ci.HandleCommand("settings set use-color true", res)
+self.assertEqual(inst.GetOperands(target), "w0, #0x63")
+self.assertEqual(inst.GetMnemonic(target), "mov")
+self.assertEqual(inst.GetComment(target), "=99 ")
+ci.HandleCommand("settings set use-color false", res)
+
 elif arch == "arm":
 self.assertEqual(inst.GetMnemonic(target), "mov")
 self.assertEqual(inst.GetOperands(target), "r3, #99")
Index: lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
===
--- lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -63,6 +63,8 @@
   void PrintMCInst(llvm::MCInst &mc_inst, lldb::addr_t pc,
std::string &inst_string, std::string &comments_string);
   void SetStyle(bool use_hex_immed, HexImmediateStyle hex_style);
+  void SetUseColor(bool use_color);
+  bool GetUseColor() const;
   bool CanBranch(llvm::MCInst &mc_inst) const;
   bool HasDelaySlot(llvm::MCInst &mc_inst) const;
   bool IsCall(llvm::MCInst &mc_inst) const;
@@ -565,7 +567,9 @@
 
 if (m_opcode.GetData(data)) {
   std::string out_string;
+  std::string markup_out_string;
   std::string comment_string;
+  std::string markup_comment_string;
 
   DisassemblerScope disasm(*this, exe_ctx);
   

[Lldb-commits] [lldb] a69f78b - [lldb] Add syntax color highlighting for disassembly

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

Author: Jonas Devlieghere
Date: 2023-09-01T14:47:45-07:00
New Revision: a69f78b080ef7efd2854ba199248713d956ea40c

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

LOG: [lldb] Add syntax color highlighting for disassembly

Add support for syntax color highlighting disassembly in LLDB. This
patch relies on 77d1032516e7, which introduces support for syntax
highlighting in MC.

Currently only AArch64 and X86 have color support, but other interested
backends can adopt WithColor in their respective MCInstPrinter.

Differential revision: https://reviews.llvm.org/D159164

Added: 
lldb/test/Shell/Commands/command-disassemble-aarch64-color.s

Modified: 
lldb/include/lldb/Core/Disassembler.h
lldb/source/Core/Disassembler.cpp
lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py

Removed: 




diff  --git a/lldb/include/lldb/Core/Disassembler.h 
b/lldb/include/lldb/Core/Disassembler.h
index 181d0b5d0e2902..885ac1bb4a7ef8 100644
--- a/lldb/include/lldb/Core/Disassembler.h
+++ b/lldb/include/lldb/Core/Disassembler.h
@@ -64,14 +64,16 @@ class Instruction {
 
   const Address &GetAddress() const { return m_address; }
 
-  const char *GetMnemonic(const ExecutionContext *exe_ctx) {
+  const char *GetMnemonic(const ExecutionContext *exe_ctx,
+  bool markup = false) {
 CalculateMnemonicOperandsAndCommentIfNeeded(exe_ctx);
-return m_opcode_name.c_str();
+return markup ? m_markup_opcode_name.c_str() : m_opcode_name.c_str();
   }
 
-  const char *GetOperands(const ExecutionContext *exe_ctx) {
+  const char *GetOperands(const ExecutionContext *exe_ctx,
+  bool markup = false) {
 CalculateMnemonicOperandsAndCommentIfNeeded(exe_ctx);
-return m_mnemonics.c_str();
+return markup ? m_markup_mnemonics.c_str() : m_mnemonics.c_str();
   }
 
   const char *GetComment(const ExecutionContext *exe_ctx) {
@@ -244,7 +246,9 @@ class Instruction {
 protected:
   Opcode m_opcode; // The opcode for this instruction
   std::string m_opcode_name;
+  std::string m_markup_opcode_name;
   std::string m_mnemonics;
+  std::string m_markup_mnemonics;
   std::string m_comment;
   bool m_calculated_strings;
 

diff  --git a/lldb/source/Core/Disassembler.cpp 
b/lldb/source/Core/Disassembler.cpp
index 104e9100e38830..166b5fdf22f0b4 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -645,18 +645,29 @@ void Instruction::Dump(lldb_private::Stream *s, uint32_t 
max_opcode_byte_size,
instruction_control_flow_kind));
   }
 
+  bool show_color = false;
+  if (exe_ctx) {
+if (TargetSP target_sp = exe_ctx->GetTargetSP()) {
+  show_color = target_sp->GetDebugger().GetUseColor();
+}
+  }
   const size_t opcode_pos = ss.GetSizeOfLastLine();
+  const std::string &opcode_name =
+  show_color ? m_markup_opcode_name : m_opcode_name;
+  const std::string &mnemonics = show_color ? m_markup_mnemonics : m_mnemonics;
 
   // The default opcode size of 7 characters is plenty for most architectures
   // but some like arm can pull out the occasional vqrshrun.s16.  We won't get
-  // consistent column spacing in these cases, unfortunately.
+  // consistent column spacing in these cases, unfortunately. Also note that we
+  // need to directly use m_opcode_name here (instead of opcode_name) so we
+  // don't include color codes as characters.
   if (m_opcode_name.length() >= opcode_column_width) {
 opcode_column_width = m_opcode_name.length() + 1;
   }
 
-  ss.PutCString(m_opcode_name);
+  ss.PutCString(opcode_name);
   ss.FillLastLineToColumn(opcode_pos + opcode_column_width, ' ');
-  ss.PutCString(m_mnemonics);
+  ss.PutCString(mnemonics);
 
   if (!m_comment.empty()) {
 ss.FillLastLineToColumn(

diff  --git a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp 
b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
index 2e0e8e8cf7d36c..be0715d8c5e95c 100644
--- a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -63,6 +63,8 @@ class DisassemblerLLVMC::MCDisasmInstance {
   void PrintMCInst(llvm::MCInst &mc_inst, lldb::addr_t pc,
std::string &inst_string, std::string &comments_string);
   void SetStyle(bool use_hex_immed, HexImmediateStyle hex_style);
+  void SetUseColor(bool use_color);
+  bool GetUseColor() const;
   bool CanBranch(llvm::MCInst &mc_inst) const;
   bool HasDelaySlot(llvm::MCInst &mc_inst) const;
   bool IsCall(llvm::MCInst &mc_inst) const;
@@ -565,7 +567,9 @@ class InstructionLLVMC : public lldb_private::Instruction {
 
 if (m_opcode.GetData(data)) {
   std::stri

lldb-commits@lists.llvm.org

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159387

Files:
  lldb/include/lldb/DataFormatters/TypeCategoryMap.h
  lldb/source/DataFormatters/TypeCategoryMap.cpp


Index: lldb/source/DataFormatters/TypeCategoryMap.cpp
===
--- lldb/source/DataFormatters/TypeCategoryMap.cpp
+++ lldb/source/DataFormatters/TypeCategoryMap.cpp
@@ -139,20 +139,6 @@
   return true;
 }
 
-bool TypeCategoryMap::Get(uint32_t pos, ValueSP &entry) {
-  std::lock_guard guard(m_map_mutex);
-  MapIterator iter = m_map.begin();
-  MapIterator end = m_map.end();
-  while (pos > 0) {
-iter++;
-pos--;
-if (iter == end)
-  return false;
-  }
-  entry = iter->second;
-  return false;
-}
-
 bool TypeCategoryMap::AnyMatches(
 const FormattersMatchCandidate &candidate_type,
 TypeCategoryImpl::FormatCategoryItems items, bool only_enabled,
Index: lldb/include/lldb/DataFormatters/TypeCategoryMap.h
===
--- lldb/include/lldb/DataFormatters/TypeCategoryMap.h
+++ lldb/include/lldb/DataFormatters/TypeCategoryMap.h
@@ -63,8 +63,6 @@
 
   bool Get(KeyType name, ValueSP &entry);
 
-  bool Get(uint32_t pos, ValueSP &entry);
-
   void ForEach(ForEachCallback callback);
 
   lldb::TypeCategoryImplSP GetAtIndex(uint32_t);


Index: lldb/source/DataFormatters/TypeCategoryMap.cpp
===
--- lldb/source/DataFormatters/TypeCategoryMap.cpp
+++ lldb/source/DataFormatters/TypeCategoryMap.cpp
@@ -139,20 +139,6 @@
   return true;
 }
 
-bool TypeCategoryMap::Get(uint32_t pos, ValueSP &entry) {
-  std::lock_guard guard(m_map_mutex);
-  MapIterator iter = m_map.begin();
-  MapIterator end = m_map.end();
-  while (pos > 0) {
-iter++;
-pos--;
-if (iter == end)
-  return false;
-  }
-  entry = iter->second;
-  return false;
-}
-
 bool TypeCategoryMap::AnyMatches(
 const FormattersMatchCandidate &candidate_type,
 TypeCategoryImpl::FormatCategoryItems items, bool only_enabled,
Index: lldb/include/lldb/DataFormatters/TypeCategoryMap.h
===
--- lldb/include/lldb/DataFormatters/TypeCategoryMap.h
+++ lldb/include/lldb/DataFormatters/TypeCategoryMap.h
@@ -63,8 +63,6 @@
 
   bool Get(KeyType name, ValueSP &entry);
 
-  bool Get(uint32_t pos, ValueSP &entry);
-
   void ForEach(ForEachCallback callback);
 
   lldb::TypeCategoryImplSP GetAtIndex(uint32_t);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


lldb-commits@lists.llvm.org

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

LGTM 🚀


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159387

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


[Lldb-commits] [lldb] 2f9cd63 - [LLDB] Fix IOHandlerEditline::GetCurrentLines()

2023-09-01 Thread walter erquinigo via lldb-commits

Author: walter erquinigo
Date: 2023-09-01T20:52:00-04:00
New Revision: 2f9cd6377f3d972ed8cf814225a02a353d6cc545

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

LOG: [LLDB] Fix IOHandlerEditline::GetCurrentLines()

This method was working as expected if LLDB_ENABLE_LIBEDIT is false, however, 
if it was true, then the variable m_current_lines_ptr was always pointing to an 
empty list, because Editline only updates its contents once the full input has 
been completed (see 
https://github.com/llvm/llvm-project/blob/main/lldb/source/Host/common/Editline.cpp#L1576).

A simple fix is to invoke Editline::GetInputAsStringList() from 
GetCurrentLines(), which is already used in many places as the common way to 
get the full input list.

Added: 


Modified: 
lldb/include/lldb/Core/IOHandler.h
lldb/include/lldb/Host/Editline.h
lldb/source/Core/IOHandler.cpp
lldb/source/Expression/REPL.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/IOHandler.h 
b/lldb/include/lldb/Core/IOHandler.h
index 0eef77e81ccb83..bb0fb58175a6bc 100644
--- a/lldb/include/lldb/Core/IOHandler.h
+++ b/lldb/include/lldb/Core/IOHandler.h
@@ -403,7 +403,7 @@ class IOHandlerEditline : public IOHandler {
 
   void SetInterruptExits(bool b) { m_interrupt_exits = b; }
 
-  const StringList *GetCurrentLines() const { return m_current_lines_ptr; }
+  StringList GetCurrentLines() const;
 
   uint32_t GetCurrentLineIndex() const;
 

diff  --git a/lldb/include/lldb/Host/Editline.h 
b/lldb/include/lldb/Host/Editline.h
index 4e2a26e04fa672..35fd179abb509c 100644
--- a/lldb/include/lldb/Host/Editline.h
+++ b/lldb/include/lldb/Host/Editline.h
@@ -227,6 +227,9 @@ class Editline {
 
   void PrintAsync(Stream *stream, const char *s, size_t len);
 
+  /// Convert the current input lines into a UTF8 StringList
+  StringList GetInputAsStringList(int line_count = UINT32_MAX);
+
 private:
   /// Sets the lowest line number for multi-line editing sessions.  A value of
   /// zero suppresses
@@ -282,9 +285,6 @@ class Editline {
   /// Save the line currently being edited
   void SaveEditedLine();
 
-  /// Convert the current input lines into a UTF8 StringList
-  StringList GetInputAsStringList(int line_count = UINT32_MAX);
-
   /// Replaces the current multi-line session with the next entry from history.
   unsigned char RecallHistory(HistoryOperation op);
 

diff  --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp
index 4591d9985b9616..ac9a9bb2844594 100644
--- a/lldb/source/Core/IOHandler.cpp
+++ b/lldb/source/Core/IOHandler.cpp
@@ -508,6 +508,21 @@ uint32_t IOHandlerEditline::GetCurrentLineIndex() const {
   return m_curr_line_idx;
 }
 
+StringList IOHandlerEditline::GetCurrentLines() const {
+#if LLDB_ENABLE_LIBEDIT
+  if (m_editline_up)
+return m_editline_up->GetInputAsStringList();
+#endif
+  // When libedit is not used, the current lines can be gotten from
+  // `m_current_lines_ptr`, which is updated whenever a new line is processed.
+  // This doesn't happen when libedit is used, in which case
+  // `m_current_lines_ptr` is only updated when the full input is terminated.
+
+  if (m_current_lines_ptr)
+return *m_current_lines_ptr;
+  return StringList();
+}
+
 bool IOHandlerEditline::GetLines(StringList &lines, bool &interrupted) {
   m_current_lines_ptr = &lines;
 

diff  --git a/lldb/source/Expression/REPL.cpp b/lldb/source/Expression/REPL.cpp
index 7e48c8f293d3b9..07d5b5b3dd9346 100644
--- a/lldb/source/Expression/REPL.cpp
+++ b/lldb/source/Expression/REPL.cpp
@@ -528,17 +528,15 @@ void REPL::IOHandlerComplete(IOHandler &io_handler,
   current_code.append(m_code.CopyList());
 
   IOHandlerEditline &editline = static_cast(io_handler);
-  const StringList *current_lines = editline.GetCurrentLines();
-  if (current_lines) {
-const uint32_t current_line_idx = editline.GetCurrentLineIndex();
-
-if (current_line_idx < current_lines->GetSize()) {
-  for (uint32_t i = 0; i < current_line_idx; ++i) {
-const char *line_cstr = current_lines->GetStringAtIndex(i);
-if (line_cstr) {
-  current_code.append("\n");
-  current_code.append(line_cstr);
-}
+  StringList current_lines = editline.GetCurrentLines();
+  const uint32_t current_line_idx = editline.GetCurrentLineIndex();
+
+  if (current_line_idx < current_lines.GetSize()) {
+for (uint32_t i = 0; i < current_line_idx; ++i) {
+  const char *line_cstr = current_lines.GetStringAtIndex(i);
+  if (line_cstr) {
+current_code.append("\n");
+current_code.append(line_cstr);
   }
 }
   }



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