[Lldb-commits] [PATCH] D156606: [lldb] Improve memory usage by freeing CTF types (NFC)

2023-07-31 Thread Michael Buch via Phabricator via lldb-commits
Michael137 accepted this revision.
Michael137 added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D156606

___
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-07-31 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added subscribers: ctetreau, kristof.beyls.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

While working in support for SME's ZA register, I found a circumstance
where restoring ZA after SVE, when the current SVE mode is non-streaming,
will kick the process back into FPSIMD mode. Meaning the SVE values that
you just wrote are now cut off at 128 bit.

The fix for that, I think, is to write ZA then SVE. Problem with that
is, the current ReadAll/WriteAll makes a lot of assumptions about the
saved data length.

This patch changes the format so there is a "kind" written before
each data block. This tells WriteAllRegisterValues what it's looking at
without brittle checks on length, or assumptions about ordering.

If we want to change the order of restoration, all we now have to
do is change the order of saving.

This exposes a bug where the TLS registers are not restored.
This will be fixed by https://reviews.llvm.org/D156512 in some form,
depending on what lands first.

Existing SVE tests certainly check restoration and when I got this
wrong, many, many tests failed. So I think we have enough coverage
already, and more will be coming with future ZA changes.


Repository:
  rG LLVM Github Monorepo

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(uint32_t) + 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,23 +570,26 @@
   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 += sizeof(m_sve_state);
-::memcpy(dst, GetSVEBuffer(), GetSVEBufferSize());
-dst += GetSVEBufferSize();
+dst = AddSavedRegistersKind(dst, SavedRegistersKind::SVE);
+*(reinterpret_cast(dst)) = static_cast(m_sve_state);
+dst += sizeof(uint32_t);
+dst = AddSavedRegistersData(dst, GetSVEBuffer(), GetSVEBufferSize());
   } else {
-::memcpy(dst, GetFPRBuffer(), G

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

2023-07-31 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a reviewer: omjavaid.
DavidSpickett added a comment.
Herald added a subscriber: JDevlieghere.

Even if this turns out not to be needed for Za handling, I think 
`WriteAllRegisterValues` not having to care about the layout is an improvement 
in itself.

Plus, this will give us a warning if we forget to save/restore new registers in 
future. It would have told me I had not done TLS.


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-07-31 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

And an important note, you don't need the size for each block because the 
scalable blocks have headers from ptrace embedded in them anyway (SVE/SSVE/ZA).

I did remove some checks that seemed redundant because all data read by 
WriteAll is going to have been written by ReadALL, so they were unlikely to 
fail.


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-07-31 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

I have some failing tests on Graviton to debug:

  Failed Tests (2):
lldb-api :: 
commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py
lldb-api :: tools/lldb-server/TestGdbRemoteRegisterState.py

But the idea still stands.


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-07-31 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 545652.
DavidSpickett added a comment.

Correct m_sve_state size to fix tests on SVE machines.


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,23 +570,26 @@
   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());
+  if (GetRegisterInfo().IsMTEEnabled()) {
+dst = AddSavedRegisters(dst, SavedRegistersKind::MTE, GetMTEControl(),
+GetMTEControlSize());
+  }
 
-  ::memcpy(dst, GetTLSBuffer(), GetTLSBufferSize());
+  dst = AddSavedRegisters(dst, SavedRegistersKind::TLS, GetTLSBuffer(),
+  GetTLSBufferSize());
 
   return error;
 }
@@ -597,7 +624,8 @@
 return error;
   }
 
-  uint64_t reg_data_min_size = GetGPRBufferSize() + GetFPRSize();
+  uint64_t reg_data_min_size =
+  GetGPRBufferSize() + GetFPRSize() + 2 * (sizeof(SavedRegistersKind));
   if (data_sp->GetByteSize() < reg_data_min_size) {
 error.SetErrorStringWithFormat(
 "NativeRegisterContextLinux_arm64::%s data_sp contained insufficient "
@@ -606,71 +634,76 @@
 return error;
   }
 
-  // Register data starts with GPRs
-  ::memcpy(GetGPRBuffer(), src, Get

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

2023-07-31 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 545657.
DavidSpickett added a comment.

Remove misleading comment. We save the whole SVE context, FPSIMD or not.


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,
+  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,23 +570,26 @@
   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());
+  if (GetRegisterInfo().IsMTEEnabled()) {
+dst = AddSavedRegisters(dst, SavedRegistersKind::MTE, GetMTEControl(),
+GetMTEControlSize());
+  }
 
-  ::memcpy(dst, GetTLSBuffer(), GetTLSBufferSize());
+  dst = AddSavedRegisters(dst, SavedRegistersKind::TLS, GetTLSBuffer(),
+  GetTLSBufferSize());
 
   return error;
 }
@@ -597,7 +624,8 @@
 return error;
   }
 
-  uint64_t reg_data_min_size = GetGPRBufferSize() + GetFPRSize();
+  uint64_t reg_data_min_size =
+  GetGPRBufferSize() + GetFPRSize() + 2 * (sizeof(SavedRegistersKind));
   if (data_sp->GetByteSize() < reg_data_min_size) {
 error.SetErrorStringWithFormat(
 "NativeRegisterContextLinux_arm64::%s data_sp contained insufficient "
@@ -606,71 +634,76 @@
 return error;
   }
 
-  // Register data starts with GPRs
-  ::memcpy(GetGPRBuffer(), src, GetGPRBufferSize());
-  m_gpr_is_

[Lldb-commits] [lldb] ca71dc1 - [lldb-vscode] Adding support for the "disassemble" request.

2023-07-31 Thread David Goldman via lldb-commits

Author: John Harrison
Date: 2023-07-31T12:44:23-04:00
New Revision: ca71dc1b5404ac685c3190c45c342b01e94e4761

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

LOG: [lldb-vscode] Adding support for the "disassemble" request.

Instead of creating psuedo source files for each stack frame this change adopts 
the new DAP “disassemble” request, allowing clients to inspect assembly 
instructions of files with debug info in addition to files without debug info.

[[ 
https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Disassemble
 | spec ]]

See attached screenshot of the disassembly view. {F28473848}

Reviewed By: wallace

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

Added: 
lldb/test/API/tools/lldb-vscode/disassemble/Makefile
lldb/test/API/tools/lldb-vscode/disassemble/TestVSCode_disassemble.py
lldb/test/API/tools/lldb-vscode/disassemble/main.c

Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
lldb/test/API/tools/lldb-vscode/coreFile/TestVSCode_coreFile.py
lldb/tools/lldb-vscode/JSONUtils.cpp
lldb/tools/lldb-vscode/JSONUtils.h
lldb/tools/lldb-vscode/VSCode.cpp
lldb/tools/lldb-vscode/VSCode.h
lldb/tools/lldb-vscode/VSCodeForward.h
lldb/tools/lldb-vscode/lldb-vscode.cpp

Removed: 
lldb/tools/lldb-vscode/SourceReference.h



diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
index adc8436a7daceb..a6c370ccd2036d 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -257,6 +257,19 @@ def continue_to_exit(self, exitCode=0):
 "exitCode == %i" % (exitCode),
 )
 
+def disassemble(self, threadId=None, frameIndex=None):
+stackFrames = self.get_stackFrames(
+threadId=threadId, startFrame=frameIndex, levels=1
+)
+self.assertIsNotNone(stackFrames)
+memoryReference = stackFrames[0]["instructionPointerReference"]
+self.assertIsNotNone(memoryReference)
+
+if memoryReference not in self.vscode.disassembled_instructions:
+self.vscode.request_disassemble(memoryReference=memoryReference)
+
+return self.vscode.disassembled_instructions[memoryReference]
+
 def attach(
 self,
 program=None,

diff  --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
index 5a6bc0f594023d..14f0bf0a2d4ed3 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -135,6 +135,7 @@ def __init__(self, recv, send, init_commands, 
log_file=None):
 self.configuration_done_sent = False
 self.frame_scopes = {}
 self.init_commands = init_commands
+self.disassembled_instructions = {}
 
 @classmethod
 def encode_content(cls, s):
@@ -427,7 +428,7 @@ def get_thread_id(self, threadIndex=0):
 
 def get_stackFrame(self, frameIndex=0, threadId=None):
 """Get a single "StackFrame" object from a "stackTrace" request and
-return the "StackFrame as a python dictionary, or None on failure
+return the "StackFrame" as a python dictionary, or None on failure
 """
 if threadId is None:
 threadId = self.get_thread_id()
@@ -647,6 +648,22 @@ def request_disconnect(self, terminateDebuggee=None):
 "arguments": args_dict,
 }
 return self.send_recv(command_dict)
+
+def request_disassemble(self, memoryReference, offset=-50, 
instructionCount=200, resolveSymbols=True):
+args_dict = {
+"memoryReference": memoryReference,
+"offset": offset,
+"instructionCount": instructionCount,
+"resolveSymbols": resolveSymbols
+}
+command_dict = {
+"command": "disassemble",
+"type": "request",
+"arguments": args_dict,
+}
+instructions = self.send_recv(command_dict)["body"]["instructions"]
+for inst in instructions:
+self.disassembled_instructions[inst["address"]] = inst
 
 def request_evaluate(self, expression, frameIndex=0, threadId=None, 
context=None):
 stackFrame = self.get_stackFrame(frameIndex=frameIndex, 
threadId=threadId)

diff  --git a/lldb/test/API/tools/lldb-vscode/coreFile/TestVSCode_coreFile.py 
b/lldb/test/API/tools/lldb-vscode/coreFile/TestVSCode_coreFile.py
index

[Lldb-commits] [PATCH] D156493: [lldb-vsocde] Adding support for the "disassemble" request.

2023-07-31 Thread David Goldman via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGca71dc1b5404: [lldb-vscode] Adding support for the 
"disassemble" request. (authored by ashgti, committed by dgoldman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156493

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/coreFile/TestVSCode_coreFile.py
  lldb/test/API/tools/lldb-vscode/disassemble/Makefile
  lldb/test/API/tools/lldb-vscode/disassemble/TestVSCode_disassemble.py
  lldb/test/API/tools/lldb-vscode/disassemble/main.c
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/SourceReference.h
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/VSCodeForward.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -50,6 +50,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/ScopeExit.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/Option.h"
@@ -1563,6 +1564,8 @@
   body.try_emplace("supportsStepInTargetsRequest", false);
   // The debug adapter supports the completions request.
   body.try_emplace("supportsCompletionsRequest", true);
+  // The debug adapter supports the disassembly request.
+  body.try_emplace("supportsDisassembleRequest", true);
 
   llvm::json::Array completion_characters;
   completion_characters.emplace_back(".");
@@ -2588,18 +2591,7 @@
 void request_source(const llvm::json::Object &request) {
   llvm::json::Object response;
   FillResponse(request, response);
-  llvm::json::Object body;
-
-  auto arguments = request.getObject("arguments");
-  auto source = arguments->getObject("source");
-  auto sourceReference = GetSigned(source, "sourceReference", -1);
-  auto pos = g_vsc.source_map.find((lldb::addr_t)sourceReference);
-  if (pos != g_vsc.source_map.end()) {
-EmplaceSafeString(body, "content", pos->second.content);
-  } else {
-response["success"] = llvm::json::Value(false);
-  }
-  EmplaceSafeString(body, "mimeType", "text/x-lldb.disassembly");
+  llvm::json::Object body{{"content", ""}};
   response.try_emplace("body", std::move(body));
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
 }
@@ -3301,6 +3293,211 @@
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
 }
 
+// "DisassembleRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "Disassembles code stored at the provided
+// location.\nClients should only call this request if the corresponding
+// capability `supportsDisassembleRequest` is true.", "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "disassemble" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/DisassembleArguments"
+//   }
+// },
+// "required": [ "command", "arguments" ]
+//   }]
+// },
+// "DisassembleArguments": {
+//   "type": "object",
+//   "description": "Arguments for `disassemble` request.",
+//   "properties": {
+// "memoryReference": {
+//   "type": "string",
+//   "description": "Memory reference to the base location containing the
+//   instructions to disassemble."
+// },
+// "offset": {
+//   "type": "integer",
+//   "description": "Offset (in bytes) to be applied to the reference
+//   location before disassembling. Can be negative."
+// },
+// "instructionOffset": {
+//   "type": "integer",
+//   "description": "Offset (in instructions) to be applied after the byte
+//   offset (if any) before disassembling. Can be negative."
+// },
+// "instructionCount": {
+//   "type": "integer",
+//   "description": "Number of instructions to disassemble starting at the
+//   specified location and offset.\nAn adapter must return exactly this
+//   number of instructions - any unavailable instructions should be
+//   replaced with an implementation-defined 'invalid instruction' value."
+// },
+// "resolveSymbols": {
+//   "type": "boolean",
+//   "description": "If true, the adapter should attempt to resolve memory
+//   addresses and other values to symbolic names."
+// }
+//   },
+//   "required": [ "memoryReference", "instructionCount" ]
+// },
+// "DisassembleResponse": {
+//   "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to `disassemble` request.",
+// "properties": {
+//   "body": {
+//

[Lldb-commits] [lldb] 6891812 - [lldb] Improve memory usage by freeing CTF types (NFC)

2023-07-31 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-07-31T09:47:46-07:00
New Revision: 68918125c11648379b473d8b2d297872cea9f504

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

LOG: [lldb] Improve memory usage by freeing CTF types (NFC)

Improve memory usage by reducing the lifetime of CTF types. Once a CTF
type has been converted to a (complete) LLDB type, there's no need to
keep it in memory anymore. For most types, we can free them right after
creating the corresponding LLDB types. The only exception is record
types, which are only completed lazily.

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

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/CTF/CTFTypes.h
lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/CTF/CTFTypes.h 
b/lldb/source/Plugins/SymbolFile/CTF/CTFTypes.h
index 99a74dbe674aea..c1016b2af0c6bc 100644
--- a/lldb/source/Plugins/SymbolFile/CTF/CTFTypes.h
+++ b/lldb/source/Plugins/SymbolFile/CTF/CTFTypes.h
@@ -46,6 +46,8 @@ struct CTFInteger : public CTFType {
  uint32_t encoding)
   : CTFType(eInteger, uid, name), bits(bits), encoding(encoding) {}
 
+  static bool classof(const CTFType *T) { return T->kind == eInteger; }
+
   uint32_t bits;
   uint32_t encoding;
 };
@@ -55,6 +57,11 @@ struct CTFModifier : public CTFType {
   CTFModifier(Kind kind, lldb::user_id_t uid, uint32_t type)
   : CTFType(kind, uid, ""), type(type) {}
 
+  static bool classof(const CTFType *T) {
+return T->kind == ePointer || T->kind == eConst || T->kind == eVolatile ||
+   T->kind == eRestrict;
+  }
+
 public:
   uint32_t type;
 };
@@ -62,27 +69,36 @@ struct CTFModifier : public CTFType {
 struct CTFPointer : public CTFModifier {
   CTFPointer(lldb::user_id_t uid, uint32_t type)
   : CTFModifier(ePointer, uid, type) {}
+
+  static bool classof(const CTFType *T) { return T->kind == ePointer; }
 };
 
 struct CTFConst : public CTFModifier {
   CTFConst(lldb::user_id_t uid, uint32_t type)
   : CTFModifier(eConst, uid, type) {}
+
+  static bool classof(const CTFType *T) { return T->kind == eConst; }
 };
 
 struct CTFVolatile : public CTFModifier {
   CTFVolatile(lldb::user_id_t uid, uint32_t type)
   : CTFModifier(eVolatile, uid, type) {}
+
+  static bool classof(const CTFType *T) { return T->kind == eVolatile; }
 };
 
 struct CTFRestrict : public CTFModifier {
   CTFRestrict(lldb::user_id_t uid, uint32_t type)
   : CTFModifier(eRestrict, uid, type) {}
+  static bool classof(const CTFType *T) { return T->kind == eRestrict; }
 };
 
 struct CTFTypedef : public CTFType {
   CTFTypedef(lldb::user_id_t uid, llvm::StringRef name, uint32_t type)
   : CTFType(eTypedef, uid, name), type(type) {}
 
+  static bool classof(const CTFType *T) { return T->kind == eTypedef; }
+
   uint32_t type;
 };
 
@@ -91,6 +107,8 @@ struct CTFArray : public CTFType {
uint32_t index, uint32_t nelems)
   : CTFType(eArray, uid, name), type(type), index(index), nelems(nelems) {}
 
+  static bool classof(const CTFType *T) { return T->kind == eArray; }
+
   uint32_t type;
   uint32_t index;
   uint32_t nelems;
@@ -110,6 +128,8 @@ struct CTFEnum : public CTFType {
 assert(this->values.size() == nelems);
   }
 
+  static bool classof(const CTFType *T) { return T->kind == eEnum; }
+
   uint32_t nelems;
   uint32_t size;
   std::vector values;
@@ -121,6 +141,8 @@ struct CTFFunction : public CTFType {
   : CTFType(eFunction, uid, name), nargs(nargs), return_type(return_type),
 args(std::move(args)), variadic(variadic) {}
 
+  static bool classof(const CTFType *T) { return T->kind == eFunction; }
+
   uint32_t nargs;
   uint32_t return_type;
 
@@ -144,6 +166,10 @@ struct CTFRecord : public CTFType {
   : CTFType(kind, uid, name), nfields(nfields), size(size),
 fields(std::move(fields)) {}
 
+  static bool classof(const CTFType *T) {
+return T->kind == eStruct || T->kind == eUnion;
+  }
+
   uint32_t nfields;
   uint32_t size;
   std::vector fields;
@@ -153,17 +179,23 @@ struct CTFStruct : public CTFRecord {
   CTFStruct(lldb::user_id_t uid, llvm::StringRef name, uint32_t nfields,
 uint32_t size, std::vector fields)
   : CTFRecord(eStruct, uid, name, nfields, size, std::move(fields)){};
+
+  static bool classof(const CTFType *T) { return T->kind == eStruct; }
 };
 
 struct CTFUnion : public CTFRecord {
   CTFUnion(lldb::user_id_t uid, llvm::StringRef name, uint32_t nfields,
uint32_t size, std::vector fields)
   : CTFRecord(eUnion, uid, name, nfields, size, std::move(fields)){};
+
+  static bool classof(const CTFType *T) { return T->kind == eUnion; }
 };
 
 struct CTFForward : public CTFT

[Lldb-commits] [PATCH] D156606: [lldb] Improve memory usage by freeing CTF types (NFC)

2023-07-31 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG68918125c116: [lldb] Improve memory usage by freeing CTF 
types (NFC) (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156606

Files:
  lldb/source/Plugins/SymbolFile/CTF/CTFTypes.h
  lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
  lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.h

Index: lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.h
===
--- lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.h
+++ lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.h
@@ -245,15 +245,17 @@
 
   std::optional m_header;
 
-  std::vector> m_ctf_types;
+  /// Parsed CTF types.
+  llvm::DenseMap> m_ctf_types;
+
+  /// Parsed LLDB types.
+  llvm::DenseMap m_types;
 
   /// To complete types, we need a way to map (imcomplete) compiler types back
   /// to parsed CTF types.
   llvm::DenseMap
   m_compiler_types;
 
-  llvm::DenseMap m_types;
-
   std::vector m_functions;
   std::vector m_variables;
 
Index: lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
===
--- lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -523,8 +523,7 @@
   assert(ctf_type && "m_compiler_types should only contain valid CTF types");
 
   // We only support resolving record types.
-  assert(ctf_type->kind == CTFType::Kind::eStruct ||
- ctf_type->kind == CTFType::Kind::eUnion);
+  assert(llvm::isa(ctf_type));
 
   // Cast to the appropriate CTF type.
   const CTFRecord *ctf_record = static_cast(ctf_type);
@@ -551,9 +550,10 @@
   }
   m_ast->CompleteTagDeclarationDefinition(compiler_type);
 
-  // Now that the compiler type is no longer incomplete we don't need to
-  // remember it anymore.
+  // Now that the compiler type is complete, we don't need to remember it
+  // anymore and can remove the CTF record type.
   m_compiler_types.erase(compiler_type.GetOpaqueQualType());
+  m_ctf_types.erase(ctf_type->uid);
 
   return true;
 }
@@ -727,9 +727,8 @@
 llvm::Expected> type_or_error =
 ParseType(type_offset, type_uid);
 if (type_or_error) {
-  m_ctf_types.emplace_back(std::move(*type_or_error));
+  m_ctf_types[(*type_or_error)->uid] = std::move(*type_or_error);
 } else {
-  m_ctf_types.emplace_back(std::unique_ptr());
   LLDB_LOG_ERROR(log, type_or_error.takeError(),
  "Failed to parse type {1} at offset {2}: {0}", type_uid,
  type_offset);
@@ -982,16 +981,16 @@
 }
 
 lldb_private::Type *SymbolFileCTF::ResolveTypeUID(lldb::user_id_t type_uid) {
-  auto find_result = m_types.find(type_uid);
-  if (find_result != m_types.end())
-return find_result->second.get();
+  auto type_it = m_types.find(type_uid);
+  if (type_it != m_types.end())
+return type_it->second.get();
 
-  if (type_uid == 0 || type_uid > m_ctf_types.size())
+  auto ctf_type_it = m_ctf_types.find(type_uid);
+  if (ctf_type_it == m_ctf_types.end())
 return nullptr;
 
-  CTFType *ctf_type = m_ctf_types[type_uid - 1].get();
-  if (!ctf_type)
-return nullptr;
+  CTFType *ctf_type = ctf_type_it->second.get();
+  assert(ctf_type && "m_ctf_types should only contain valid CTF types");
 
   Log *log = GetLog(LLDBLog::Symbols);
 
@@ -1013,6 +1012,11 @@
 
   m_types[type_uid] = type_sp;
 
+  // Except for record types which we'll need to complete later, we don't need
+  // the CTF type anymore.
+  if (!isa(ctf_type))
+m_ctf_types.erase(type_uid);
+
   return type_sp.get();
 }
 
Index: lldb/source/Plugins/SymbolFile/CTF/CTFTypes.h
===
--- lldb/source/Plugins/SymbolFile/CTF/CTFTypes.h
+++ lldb/source/Plugins/SymbolFile/CTF/CTFTypes.h
@@ -46,6 +46,8 @@
  uint32_t encoding)
   : CTFType(eInteger, uid, name), bits(bits), encoding(encoding) {}
 
+  static bool classof(const CTFType *T) { return T->kind == eInteger; }
+
   uint32_t bits;
   uint32_t encoding;
 };
@@ -55,6 +57,11 @@
   CTFModifier(Kind kind, lldb::user_id_t uid, uint32_t type)
   : CTFType(kind, uid, ""), type(type) {}
 
+  static bool classof(const CTFType *T) {
+return T->kind == ePointer || T->kind == eConst || T->kind == eVolatile ||
+   T->kind == eRestrict;
+  }
+
 public:
   uint32_t type;
 };
@@ -62,27 +69,36 @@
 struct CTFPointer : public CTFModifier {
   CTFPointer(lldb::user_id_t uid, uint32_t type)
   : CTFModifier(ePointer, uid, type) {}
+
+  static bool classof(const CTFType *T) { return T->kind == ePointer; }
 };
 
 struct CTFConst : public CTFModifier {
   CTFConst(lldb::user_id_t uid, uint32_t type)
   : CTFModifier(eConst, uid, type) {}
+
+  st

[Lldb-commits] [lldb] db9087a - [lldb] Clean up uses of UuidCompatibility.h

2023-07-31 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2023-07-31T10:30:07-07:00
New Revision: db9087a696a65042701049b9028096aeda82aa98

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

LOG: [lldb] Clean up uses of UuidCompatibility.h

This commit does a few related things:
- Removes unused function `uuid_is_null`
- Removes unneeded includes of UuidCompatibility.h
- Renames UuidCompatibility to AppleUuidCompatibility and adds a comment
  to clarify intent of header.
- Moves AppleUuidCompatibility to the include directory

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

Added: 
lldb/include/lldb/Utility/AppleUuidCompatibility.h

Modified: 
lldb/source/Expression/ObjectFileJIT.cpp
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Removed: 
lldb/source/Utility/UuidCompatibility.h



diff  --git a/lldb/source/Utility/UuidCompatibility.h 
b/lldb/include/lldb/Utility/AppleUuidCompatibility.h
similarity index 67%
rename from lldb/source/Utility/UuidCompatibility.h
rename to lldb/include/lldb/Utility/AppleUuidCompatibility.h
index 40ebc1de24e4d8..88913a68ece8d7 100644
--- a/lldb/source/Utility/UuidCompatibility.h
+++ b/lldb/include/lldb/Utility/AppleUuidCompatibility.h
@@ -6,20 +6,11 @@
 //
 
//===--===//
 
-// Include this header if your system does not have a definition of uuid_t
+// Include this header for a definition of uuid_t compatible with Darwin's
+// definition.
 
 #ifndef utility_UUID_COMPATIBILITY_H
 #define utility_UUID_COMPATIBILITY_H
-
 // uuid_t is guaranteed to always be a 16-byte array
 typedef unsigned char uuid_t[16];
-
-// Return 1 if uuid is null, that is, all zeroes.
-inline __attribute__((always_inline)) int uuid_is_null(uuid_t uuid) {
-  for (int i = 0; i < 16; i++)
-if (uuid[i])
-  return 0;
-  return 1;
-}
-
 #endif // utility_UUID_COMPATIBILITY_H

diff  --git a/lldb/source/Expression/ObjectFileJIT.cpp 
b/lldb/source/Expression/ObjectFileJIT.cpp
index 10fac9a9a4452b..9a839866096bdd 100644
--- a/lldb/source/Expression/ObjectFileJIT.cpp
+++ b/lldb/source/Expression/ObjectFileJIT.cpp
@@ -25,10 +25,6 @@
 #include "lldb/Utility/Timer.h"
 #include "lldb/Utility/UUID.h"
 
-#ifndef __APPLE__
-#include "Utility/UuidCompatibility.h"
-#endif
-
 using namespace lldb;
 using namespace lldb_private;
 

diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 06b8df8df2aa21..e56a930d80c6b1 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -7,7 +7,6 @@
 
//===--===//
 
 #include "lldb/Host/macosx/HostInfoMacOSX.h"
-#include "Utility/UuidCompatibility.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
@@ -32,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 // Objective-C/C++ includes
 #include 

diff  --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 0230ae23f4a0be..1e3e2e5641ad83 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -43,12 +43,6 @@
 #define DEBUG_PRINTF(fmt, ...)
 #endif
 
-#ifndef __APPLE__
-#include "Utility/UuidCompatibility.h"
-#else
-#include 
-#endif
-
 #include 
 
 using namespace lldb;

diff  --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index 8df3e8e36c0db2..0bd465aba2d8a2 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -40,7 +40,7 @@
 #endif
 
 #ifndef __APPLE__
-#include "Utility/UuidCompatibility.h"
+#include "lldb/Utility/AppleUuidCompatibility.h"
 #else
 #include 
 #endif

diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index d5cab1bb1a5324..2d706835fd2400 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -63,7 +63,7 @@
 #endif
 
 #ifndef __APPLE__
-#include "Utility/UuidCompatibility.h"
+#include "lldb/Utility/AppleUuidCompatibility.h"
 #else
 #include 
 #endif



_

[Lldb-commits] [PATCH] D156562: [lldb] Clean up uses of UuidCompatibility.h

2023-07-31 Thread Alex Langford via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdb9087a696a6: [lldb] Clean up uses of UuidCompatibility.h 
(authored by bulbazord).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156562

Files:
  lldb/include/lldb/Utility/AppleUuidCompatibility.h
  lldb/source/Expression/ObjectFileJIT.cpp
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Utility/UuidCompatibility.h

Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -63,7 +63,7 @@
 #endif
 
 #ifndef __APPLE__
-#include "Utility/UuidCompatibility.h"
+#include "lldb/Utility/AppleUuidCompatibility.h"
 #else
 #include 
 #endif
Index: lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
===
--- lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -40,7 +40,7 @@
 #endif
 
 #ifndef __APPLE__
-#include "Utility/UuidCompatibility.h"
+#include "lldb/Utility/AppleUuidCompatibility.h"
 #else
 #include 
 #endif
Index: lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
===
--- lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -43,12 +43,6 @@
 #define DEBUG_PRINTF(fmt, ...)
 #endif
 
-#ifndef __APPLE__
-#include "Utility/UuidCompatibility.h"
-#else
-#include 
-#endif
-
 #include 
 
 using namespace lldb;
Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -7,7 +7,6 @@
 //===--===//
 
 #include "lldb/Host/macosx/HostInfoMacOSX.h"
-#include "Utility/UuidCompatibility.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
@@ -32,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 // Objective-C/C++ includes
 #include 
Index: lldb/source/Expression/ObjectFileJIT.cpp
===
--- lldb/source/Expression/ObjectFileJIT.cpp
+++ lldb/source/Expression/ObjectFileJIT.cpp
@@ -25,10 +25,6 @@
 #include "lldb/Utility/Timer.h"
 #include "lldb/Utility/UUID.h"
 
-#ifndef __APPLE__
-#include "Utility/UuidCompatibility.h"
-#endif
-
 using namespace lldb;
 using namespace lldb_private;
 
Index: lldb/include/lldb/Utility/AppleUuidCompatibility.h
===
--- lldb/include/lldb/Utility/AppleUuidCompatibility.h
+++ lldb/include/lldb/Utility/AppleUuidCompatibility.h
@@ -6,20 +6,11 @@
 //
 //===--===//
 
-// Include this header if your system does not have a definition of uuid_t
+// Include this header for a definition of uuid_t compatible with Darwin's
+// definition.
 
 #ifndef utility_UUID_COMPATIBILITY_H
 #define utility_UUID_COMPATIBILITY_H
-
 // uuid_t is guaranteed to always be a 16-byte array
 typedef unsigned char uuid_t[16];
-
-// Return 1 if uuid is null, that is, all zeroes.
-inline __attribute__((always_inline)) int uuid_is_null(uuid_t uuid) {
-  for (int i = 0; i < 16; i++)
-if (uuid[i])
-  return 0;
-  return 1;
-}
-
 #endif // utility_UUID_COMPATIBILITY_H
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D156086: [lldb][NFC] Use MCInstrAnalysis when available in the disassembler plugin

2023-07-31 Thread Venkata Ramanaiah Nalamothu via Phabricator via lldb-commits
RamNalamothu updated this revision to Diff 545753.
RamNalamothu added a comment.

Add lldb test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156086

Files:
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
  lldb/unittests/Disassembler/x86/TestGetControlFlowKindx86.cpp
  llvm/include/llvm/MC/MCInstrAnalysis.h

Index: llvm/include/llvm/MC/MCInstrAnalysis.h
===
--- llvm/include/llvm/MC/MCInstrAnalysis.h
+++ llvm/include/llvm/MC/MCInstrAnalysis.h
@@ -18,6 +18,7 @@
 #include "llvm/MC/MCInst.h"
 #include "llvm/MC/MCInstrDesc.h"
 #include "llvm/MC/MCInstrInfo.h"
+#include "llvm/MC/MCRegisterInfo.h"
 #include 
 #include 
 
@@ -64,6 +65,19 @@
 return Info->get(Inst.getOpcode()).isTerminator();
   }
 
+  virtual bool mayAffectControlFlow(const MCInst &Inst,
+const MCRegisterInfo &MCRI) const {
+if (isBranch(Inst) || isCall(Inst) || isReturn(Inst) ||
+isIndirectBranch(Inst))
+  return true;
+unsigned PC = MCRI.getProgramCounter();
+if (PC == 0)
+  return false;
+if (Info->get(Inst.getOpcode()).hasDefOfPhysReg(Inst, PC, MCRI))
+  return true;
+return false;
+  }
+
   /// Returns true if at least one of the register writes performed by
   /// \param Inst implicitly clears the upper portion of all super-registers.
   ///
Index: lldb/unittests/Disassembler/x86/TestGetControlFlowKindx86.cpp
===
--- lldb/unittests/Disassembler/x86/TestGetControlFlowKindx86.cpp
+++ lldb/unittests/Disassembler/x86/TestGetControlFlowKindx86.cpp
@@ -140,6 +140,17 @@
   ExecutionContext exe_ctx (nullptr, nullptr, nullptr);
   InstructionControlFlowKind kind = inst_sp->GetControlFlowKind(&exe_ctx);
   EXPECT_EQ(kind, result[i]);
+
+  // Also, test the DisassemblerLLVMC::MCDisasmInstance methods.
+  if (kind == eInstructionControlFlowKindReturn)
+EXPECT_FALSE(inst_sp->IsCall());
+  if (kind == eInstructionControlFlowKindCall)
+EXPECT_TRUE(inst_sp->IsCall());
+  if (kind == eInstructionControlFlowKindCall ||
+  kind == eInstructionControlFlowKindJump ||
+  kind == eInstructionControlFlowKindCondJump ||
+  kind == eInstructionControlFlowKindReturn)
+EXPECT_TRUE(inst_sp->DoesBranch());
 }
   }
 }
Index: lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
===
--- lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -18,6 +18,7 @@
 #include "llvm/MC/MCDisassembler/MCRelocationInfo.h"
 #include "llvm/MC/MCInst.h"
 #include "llvm/MC/MCInstPrinter.h"
+#include "llvm/MC/MCInstrAnalysis.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSubtargetInfo.h"
@@ -75,7 +76,8 @@
std::unique_ptr &&asm_info_up,
std::unique_ptr &&context_up,
std::unique_ptr &&disasm_up,
-   std::unique_ptr &&instr_printer_up);
+   std::unique_ptr &&instr_printer_up,
+   std::unique_ptr &&instr_analysis_up);
 
   std::unique_ptr m_instr_info_up;
   std::unique_ptr m_reg_info_up;
@@ -84,6 +86,7 @@
   std::unique_ptr m_context_up;
   std::unique_ptr m_disasm_up;
   std::unique_ptr m_instr_printer_up;
+  std::unique_ptr m_instr_analysis_up;
 };
 
 namespace x86 {
@@ -1287,11 +1290,15 @@
   if (!instr_printer_up)
 return Instance();
 
-  return Instance(
-  new MCDisasmInstance(std::move(instr_info_up), std::move(reg_info_up),
-   std::move(subtarget_info_up), std::move(asm_info_up),
-   std::move(context_up), std::move(disasm_up),
-   std::move(instr_printer_up)));
+  // Not all targets may have registered createMCInstrAnalysis().
+  std::unique_ptr instr_analysis_up(
+  curr_target->createMCInstrAnalysis(instr_info_up.get()));
+
+  return Instance(new MCDisasmInstance(
+  std::move(instr_info_up), std::move(reg_info_up),
+  std::move(subtarget_info_up), std::move(asm_info_up),
+  std::move(context_up), std::move(disasm_up), std::move(instr_printer_up),
+  std::move(instr_analysis_up)));
 }
 
 DisassemblerLLVMC::MCDisasmInstance::MCDisasmInstance(
@@ -1301,13 +1308,15 @@
 std::unique_ptr &&asm_info_up,
 std::unique_ptr &&context_up,
 std::unique_ptr &&disasm_up,
-std::unique_ptr &&instr_printer_up)
+std::unique_ptr &&instr_printer_up,
+std::unique_ptr &&instr_analysis_up)
 : m_instr_info_up(std::move(instr_info_up)),
   m_reg_info_up(std::move(reg_info_up)),
   m_subtarget_info_up(std::move(subtarget_info_up)),
   m_asm_info_up(std::move(asm_info_up)),
   m_context_u

[Lldb-commits] [lldb] 4e429fd - Few linter fixes

2023-07-31 Thread David Blaikie via lldb-commits

Author: David Blaikie
Date: 2023-07-31T18:52:57Z
New Revision: 4e429fd2a72511bc3c0a20e1b12f735863e615df

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

LOG: Few linter fixes

size() > 0 -> !empty
indentation
mismatched names on parameters in decls/defs
const on value return types

Added: 


Modified: 

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
index d298af92ba5e62..920a5eba20abd9 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
@@ -77,7 +77,7 @@ class ClassDescriptorV2 : public 
ObjCLanguageRuntime::ClassDescriptor {
   void GetIVarInformation();
 
 private:
-  static const uint32_t RW_REALIZED = (1 << 31);
+  static const uint32_t RW_REALIZED = (1u << 31);
 
   struct objc_class_t {
 ObjCLanguageRuntime::ObjCISA m_isa = 0; // The class's metaclass.
@@ -173,7 +173,8 @@ class ClassDescriptorV2 : public 
ObjCLanguageRuntime::ClassDescriptor {
 }
 
 bool Read(Process *process, lldb::addr_t addr,
-  lldb::addr_t relative_method_lists_base_addr, bool, bool);
+  lldb::addr_t relative_selector_base_addr, bool is_small,
+  bool has_direct_sel);
   };
 
   struct ivar_list_t {

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index d5357b94d68edc..a50cdc88cd0124 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -1399,7 +1399,7 @@ class RemoteNXMapTable {
   return *this;
 }
 
-const element operator*() const {
+element operator*() const {
   if (m_index == -1) {
 // TODO find a way to make this an error, but not an assert
 return element();
@@ -2739,7 +2739,7 @@ lldb::addr_t 
AppleObjCRuntimeV2::LookupRuntimeSymbol(ConstString name) {
   std::pair class_and_ivar =
   ivar_skipped_prefix.split('.');
 
-  if (class_and_ivar.first.size() && class_and_ivar.second.size()) {
+  if (!class_and_ivar.first.empty() && !class_and_ivar.second.empty()) {
 const ConstString class_name_cs(class_and_ivar.first);
 ClassDescriptorSP descriptor =
 
ObjCLanguageRuntime::GetClassDescriptorFromClassName(class_name_cs);

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
index 678865ecd9186f..c9d0b3a907b54b 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
@@ -65,12 +65,12 @@ class AppleObjCRuntimeV2 : public AppleObjCRuntime {
 return ObjCRuntimeVersions::eAppleObjC_V2;
   }
 
-  size_t GetByteOffsetForIvar(CompilerType &parent_qual_type,
+  size_t GetByteOffsetForIvar(CompilerType &parent_ast_type,
   const char *ivar_name) override;
 
   void UpdateISAToDescriptorMapIfNeeded() override;
 
-  ClassDescriptorSP GetClassDescriptor(ValueObject &in_value) override;
+  ClassDescriptorSP GetClassDescriptor(ValueObject &valobj) override;
 
   ClassDescriptorSP GetClassDescriptorFromISA(ObjCISA isa) override;
 

diff  --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp 
b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 8f9d9173af9fbf..d81b634be87b1e 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -2867,7 +2867,7 @@ bool IRTranslator::translateVAArg(const User &U, 
MachineIRBuilder &MIRBuilder) {
 }
 
 bool IRTranslator::translateUnreachable(const User &U, MachineIRBuilder 
&MIRBuilder) {
-if (!MF->getTarget().Options.TrapUnreachable)
+  if (!MF->getTarget().Options.TrapUnreachable)
 return true;
 
   auto &UI = cast(U);

diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 87ba56137728b3..7191e89d36071b 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAG

[Lldb-commits] [PATCH] D156732: Display PC instead of for stack trace in vscode

2023-07-31 Thread Tom Yang via Phabricator via lldb-commits
zhyty created this revision.
Herald added a project: All.
zhyty requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

It isn't useful for users to see "" as a stack trace when lldb fails 
to symbolicate a stack frame. I've replaced "" with the value of the 
program counter instead.

Test Plan:

To test this, I opened a target that lldb fails to symbolicate in
VSCode, and observed in the CALL STACK section that instead of being
shown as "", those stack frames are represented by their
program counters.

I also ran `lldb-dotest -p TestVSCode` and saw that the tests passed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156732

Files:
  lldb/tools/lldb-vscode/JSONUtils.cpp


Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -762,8 +762,14 @@
   const char *func_name = frame.GetFunctionName();
   if (func_name)
 frame_name = func_name;
-  else
-frame_name = "";
+  else {
+// If the function name is unavailable, display the pc address as a 
16-digit
+// hex string.
+frame_name.clear();
+llvm::raw_string_ostream os(frame_name);
+os << llvm::format_hex(frame.GetPC(), 18);
+os.flush();
+  }
   bool is_optimized = frame.GetFunction().GetIsOptimized();
   if (is_optimized)
 frame_name += " [opt]";


Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -762,8 +762,14 @@
   const char *func_name = frame.GetFunctionName();
   if (func_name)
 frame_name = func_name;
-  else
-frame_name = "";
+  else {
+// If the function name is unavailable, display the pc address as a 16-digit
+// hex string.
+frame_name.clear();
+llvm::raw_string_ostream os(frame_name);
+os << llvm::format_hex(frame.GetPC(), 18);
+os.flush();
+  }
   bool is_optimized = frame.GetFunction().GetIsOptimized();
   if (is_optimized)
 frame_name += " [opt]";
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D156270: [lldb][NFCI] Change logic to find clang resource dir in standalone builds

2023-07-31 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

This broke the standalone bot: 
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-standalone/

I was able to reproduce the issue locally and reverting this commit fixes the 
issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156270

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


[Lldb-commits] [PATCH] D156763: [lldb] Fix building LLDB standlone without framework

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

In a809720102fae8d1b5a7073f99f9dae9395c5f41 
 I 
refactored some logic to
deal with the clang resource directory in standalone LLDB builds.
However, this logic escaped me because it only runs when you do not
build LLDB.framework.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156763

Files:
  lldb/source/API/CMakeLists.txt


Index: lldb/source/API/CMakeLists.txt
===
--- lldb/source/API/CMakeLists.txt
+++ lldb/source/API/CMakeLists.txt
@@ -204,13 +204,11 @@
   # When building the LLDB framework, this isn't necessary as there we copy 
everything we need into
   # the framework (including the Clang resourece directory).
   if(NOT LLDB_BUILD_FRAMEWORK)
-set(LLDB_CLANG_RESOURCE_DIR_PARENT "$/clang")
-file(MAKE_DIRECTORY "${LLDB_CLANG_RESOURCE_DIR_PARENT}")
+set(LLDB_CLANG_RESOURCE_DIR "$/clang")
 add_custom_command(TARGET liblldb POST_BUILD
-  COMMENT "Linking Clang resource dir into LLDB build directory: 
${LLDB_CLANG_RESOURCE_DIR_PARENT}"
-  COMMAND ${CMAKE_COMMAND} -E make_directory 
"${LLDB_CLANG_RESOURCE_DIR_PARENT}"
-  COMMAND ${CMAKE_COMMAND} -E create_symlink 
"${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}"
-  
"${LLDB_CLANG_RESOURCE_DIR_PARENT}/${LLDB_CLANG_RESOURCE_DIR_NAME}"
+  COMMENT "Linking Clang resource dir into LLDB build directory: 
${LLDB_CLANG_RESOURCE_DIR}"
+  COMMAND ${CMAKE_COMMAND} -E create_symlink
+  "${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}" "${LLDB_CLANG_RESOURCE_DIR}"
 )
   endif()
 endif()


Index: lldb/source/API/CMakeLists.txt
===
--- lldb/source/API/CMakeLists.txt
+++ lldb/source/API/CMakeLists.txt
@@ -204,13 +204,11 @@
   # When building the LLDB framework, this isn't necessary as there we copy everything we need into
   # the framework (including the Clang resourece directory).
   if(NOT LLDB_BUILD_FRAMEWORK)
-set(LLDB_CLANG_RESOURCE_DIR_PARENT "$/clang")
-file(MAKE_DIRECTORY "${LLDB_CLANG_RESOURCE_DIR_PARENT}")
+set(LLDB_CLANG_RESOURCE_DIR "$/clang")
 add_custom_command(TARGET liblldb POST_BUILD
-  COMMENT "Linking Clang resource dir into LLDB build directory: ${LLDB_CLANG_RESOURCE_DIR_PARENT}"
-  COMMAND ${CMAKE_COMMAND} -E make_directory "${LLDB_CLANG_RESOURCE_DIR_PARENT}"
-  COMMAND ${CMAKE_COMMAND} -E create_symlink "${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}"
-  "${LLDB_CLANG_RESOURCE_DIR_PARENT}/${LLDB_CLANG_RESOURCE_DIR_NAME}"
+  COMMENT "Linking Clang resource dir into LLDB build directory: ${LLDB_CLANG_RESOURCE_DIR}"
+  COMMAND ${CMAKE_COMMAND} -E create_symlink
+  "${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}" "${LLDB_CLANG_RESOURCE_DIR}"
 )
   endif()
 endif()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D156764: [lldb][NFCI] More forward declarations in SBDefines.h

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

I noticed these were missing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156764

Files:
  lldb/include/lldb/API/SBDefines.h


Index: lldb/include/lldb/API/SBDefines.h
===
--- lldb/include/lldb/API/SBDefines.h
+++ lldb/include/lldb/API/SBDefines.h
@@ -46,6 +46,7 @@
 class LLDB_API SBAttachInfo;
 class LLDB_API SBBlock;
 class LLDB_API SBBreakpoint;
+class LLDB_API SBBreakpointList;
 class LLDB_API SBBreakpointLocation;
 class LLDB_API SBBreakpointName;
 class LLDB_API SBBreakpointNameImpl;
@@ -85,11 +86,13 @@
 class LLDB_API SBModuleSpec;
 class LLDB_API SBModuleSpecList;
 class LLDB_API SBPlatform;
+class LLDB_API SBPlatformConnectOptions;
 class LLDB_API SBPlatformShellCommand;
 class LLDB_API SBProcess;
 class LLDB_API SBProcessInfo;
 class LLDB_API SBQueue;
 class LLDB_API SBQueueItem;
+class LLDB_API SBReplayOptions;
 class LLDB_API SBReproducer;
 class LLDB_API SBScriptObject;
 class LLDB_API SBSection;


Index: lldb/include/lldb/API/SBDefines.h
===
--- lldb/include/lldb/API/SBDefines.h
+++ lldb/include/lldb/API/SBDefines.h
@@ -46,6 +46,7 @@
 class LLDB_API SBAttachInfo;
 class LLDB_API SBBlock;
 class LLDB_API SBBreakpoint;
+class LLDB_API SBBreakpointList;
 class LLDB_API SBBreakpointLocation;
 class LLDB_API SBBreakpointName;
 class LLDB_API SBBreakpointNameImpl;
@@ -85,11 +86,13 @@
 class LLDB_API SBModuleSpec;
 class LLDB_API SBModuleSpecList;
 class LLDB_API SBPlatform;
+class LLDB_API SBPlatformConnectOptions;
 class LLDB_API SBPlatformShellCommand;
 class LLDB_API SBProcess;
 class LLDB_API SBProcessInfo;
 class LLDB_API SBQueue;
 class LLDB_API SBQueueItem;
+class LLDB_API SBReplayOptions;
 class LLDB_API SBReproducer;
 class LLDB_API SBScriptObject;
 class LLDB_API SBSection;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D156763: [lldb] Fix building LLDB standlone without framework

2023-07-31 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.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156763

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


[Lldb-commits] [PATCH] D156774: [WIP][lldb] Parse enums while parsing a type

2023-07-31 Thread Vlad Serebrennikov via Phabricator via lldb-commits
Endill created this revision.
Endill added a reviewer: JDevlieghere.
Endill added a project: LLDB.
Herald added a reviewer: shafik.
Herald added a project: All.
Endill requested review of this revision.
Herald added a subscriber: lldb-commits.

Fixes #64291 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156774

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3037,6 +3037,17 @@
module_sp, base_classes, layout_info);
   break;
 
+case DW_TAG_enumeration_type:
+{
+  SymbolContextScope *scope;
+  scope = parent_die.GetDWARF()->GetObjectFile()->GetModule().get();
+  assert(scope);
+  SymbolContext sc(scope);
+  ParsedDWARFTypeAttributes attrs{die};
+  ParseEnum(sc, die, attrs);
+}
+break;
+
 default:
   break;
 }


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3037,6 +3037,17 @@
module_sp, base_classes, layout_info);
   break;
 
+case DW_TAG_enumeration_type:
+{
+  SymbolContextScope *scope;
+  scope = parent_die.GetDWARF()->GetObjectFile()->GetModule().get();
+  assert(scope);
+  SymbolContext sc(scope);
+  ParsedDWARFTypeAttributes attrs{die};
+  ParseEnum(sc, die, attrs);
+}
+break;
+
 default:
   break;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D156774: [WIP][lldb] Parse enums while parsing a type

2023-07-31 Thread Vlad Serebrennikov via Phabricator via lldb-commits
Endill added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:3043
+  SymbolContextScope *scope;
+  scope = parent_die.GetDWARF()->GetObjectFile()->GetModule().get();
+  assert(scope);

I've used 
https://github.com/llvm/llvm-project/blob/fa2b038cadf17d08014e5fb75c47b5024860953e/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp#L2689
 as a reference, and I guess I'm missing CompileUnit counterpart of this. 
Surprisingly to me, even with CompileUnit part missing, I was able to debug a 
Clang crash successfully.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156774

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


[Lldb-commits] [PATCH] D156774: [WIP][lldb] Parse enums while parsing a type

2023-07-31 Thread Vlad Serebrennikov via Phabricator via lldb-commits
Endill added a comment.

This patch is intentionally aimed squarely at enums.
But I'd like lldb to address the issue of accessing compile-time constants 
holistically. Or at least agree on a path forward for that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156774

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