[Lldb-commits] [PATCH] D85641: [LLDB] Convert SVE macros into c++ constants and inlines

2020-08-19 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG090306fc80db: Convert SVE macros into c++ constants and 
inlines (authored by omjavaid).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85641

Files:
  lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
  lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp

Index: lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
===
--- lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
+++ lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
@@ -57,20 +57,22 @@
 }
 
 void RegisterContextCorePOSIX_arm64::ConfigureRegisterContext() {
-  if (m_sveregset.GetByteSize() > sizeof(user_sve_header)) {
+  if (m_sveregset.GetByteSize() > sizeof(sve::user_sve_header)) {
 uint64_t sve_header_field_offset = 8;
 m_sve_vector_length = m_sveregset.GetU16(&sve_header_field_offset);
 sve_header_field_offset = 12;
 uint16_t sve_header_flags_field =
 m_sveregset.GetU16(&sve_header_field_offset);
-if ((sve_header_flags_field & SVE_PT_REGS_MASK) == SVE_PT_REGS_FPSIMD)
+if ((sve_header_flags_field & sve::ptrace_regs_mask) ==
+sve::ptrace_regs_fpsimd)
   m_sve_state = SVEState::FPSIMD;
-else if ((sve_header_flags_field & SVE_PT_REGS_MASK) == SVE_PT_REGS_SVE)
+else if ((sve_header_flags_field & sve::ptrace_regs_mask) ==
+ sve::ptrace_regs_sve)
   m_sve_state = SVEState::Full;
 
-if (sve_vl_valid(m_sve_vector_length))
+if (sve::vl_valid(m_sve_vector_length))
   m_register_info_up->ConfigureVectorRegisterInfos(
-  sve_vq_from_vl(m_sve_vector_length));
+  sve::vq_from_vl(m_sve_vector_length));
 else {
   m_sve_state = SVEState::Disabled;
   m_sve_vector_length = 0;
@@ -85,11 +87,11 @@
   uint32_t sve_reg_offset = LLDB_INVALID_INDEX32;
   if (m_sve_state == SVEState::FPSIMD) {
 const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
-sve_reg_offset = SVE_PT_FPSIMD_OFFSET + (reg - GetRegNumSVEZ0()) * 16;
+sve_reg_offset = sve::ptrace_fpsimd_offset + (reg - GetRegNumSVEZ0()) * 16;
   } else if (m_sve_state == SVEState::Full) {
 uint32_t sve_z0_offset = GetGPRSize() + 8;
 sve_reg_offset =
-SVE_SIG_REGS_OFFSET + reg_info->byte_offset - sve_z0_offset;
+sve::SigRegsOffset() + reg_info->byte_offset - sve_z0_offset;
   }
 
   return sve_reg_offset;
@@ -132,15 +134,15 @@
   if (reg == GetRegNumFPSR()) {
 sve_reg_num = reg;
 if (m_sve_state == SVEState::Full)
-  offset = SVE_PT_SVE_FPSR_OFFSET(sve_vq_from_vl(m_sve_vector_length));
+  offset = sve::PTraceFPSROffset(sve::vq_from_vl(m_sve_vector_length));
 else if (m_sve_state == SVEState::FPSIMD)
-  offset = SVE_PT_FPSIMD_OFFSET + (32 * 16);
+  offset = sve::ptrace_fpsimd_offset + (32 * 16);
   } else if (reg == GetRegNumFPCR()) {
 sve_reg_num = reg;
 if (m_sve_state == SVEState::Full)
-  offset = SVE_PT_SVE_FPCR_OFFSET(sve_vq_from_vl(m_sve_vector_length));
+  offset = sve::PTraceFPCROffset(sve::vq_from_vl(m_sve_vector_length));
 else if (m_sve_state == SVEState::FPSIMD)
-  offset = SVE_PT_FPSIMD_OFFSET + (32 * 16) + 4;
+  offset = sve::ptrace_fpsimd_offset + (32 * 16) + 4;
   } else {
 // Extract SVE Z register value register number for this reg_info
 if (reg_info->value_regs &&
Index: lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
===
--- lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
+++ lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
@@ -9,60 +9,57 @@
 #ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXPTRACEDEFINES_ARM64SVE_H
 #define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXPTRACEDEFINES_ARM64SVE_H
 
-// LinuxPTraceDefines_arm64sve.h defines essential macros for manipulating
-// AArch64 SVE core dump registers. Add guard for aarch64/Linux hosts where
-// newer versions of ptrace.h or sigcontext.h might already define SVE macros.
-#ifndef SVE_SIG_REGS_OFFSET
-
 #include 
 
-struct aarch64_context {
-  uint16_t magic;
-  uint16_t size;
-};
-
-#define SVE_MAGIC 0x53564501
-
-struct sve_context {
-  struct aarch64_context head;
-  uint16_t vl;
-  uint16_t reserved[3];
-};
+namespace lldb_private {
+namespace sve {
 
 /*
  * The SVE architecture leaves space for future expansion of the
  * vector length beyond its initial architectural limit of 2048 bits
  * (16 quadwords).
  *
- * See linux/Documentation/arm64/sve.txt for a description of the VL/VQ
- * terminology.
+ * See /Documentation/arm64/sve.rst for a description
+ * of the vl/vq terminology

[Lldb-commits] [lldb] 090306f - Convert SVE macros into c++ constants and inlines

2020-08-19 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2020-08-19T12:28:16+05:00
New Revision: 090306fc80dbf3e524d0ce4a7c39e0852f0ba144

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

LOG: Convert SVE macros into c++ constants and inlines

This patch updates LLDB's in house version of SVE ptrace/sig macros by
converting them into constants and inlines. They are housed under sve
namespace and are used by process elf-core for reading SVE register data.

Reviewed By: labath

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

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h 
b/lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
index fe3aed96d859..7f6f7cf5832d 100644
--- a/lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
+++ b/lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
@@ -9,60 +9,57 @@
 #ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXPTRACEDEFINES_ARM64SVE_H
 #define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXPTRACEDEFINES_ARM64SVE_H
 
-// LinuxPTraceDefines_arm64sve.h defines essential macros for manipulating
-// AArch64 SVE core dump registers. Add guard for aarch64/Linux hosts where
-// newer versions of ptrace.h or sigcontext.h might already define SVE macros.
-#ifndef SVE_SIG_REGS_OFFSET
-
 #include 
 
-struct aarch64_context {
-  uint16_t magic;
-  uint16_t size;
-};
-
-#define SVE_MAGIC 0x53564501
-
-struct sve_context {
-  struct aarch64_context head;
-  uint16_t vl;
-  uint16_t reserved[3];
-};
+namespace lldb_private {
+namespace sve {
 
 /*
  * The SVE architecture leaves space for future expansion of the
  * vector length beyond its initial architectural limit of 2048 bits
  * (16 quadwords).
  *
- * See linux/Documentation/arm64/sve.txt for a description of the VL/VQ
- * terminology.
+ * See /Documentation/arm64/sve.rst for a description
+ * of the vl/vq terminology.
  */
-#define SVE_VQ_BYTES 16 /* number of bytes per quadword */
 
-#define SVE_VQ_MIN 1
-#define SVE_VQ_MAX 512
+const uint16_t vq_bytes = 16; /* number of bytes per quadword */
+
+const uint16_t vq_min = 1;
+const uint16_t vq_max = 512;
+
+const uint16_t vl_min = vq_min * vq_bytes;
+const uint16_t vl_max = vq_max * vq_bytes;
 
-#define SVE_VL_MIN (SVE_VQ_MIN * SVE_VQ_BYTES)
-#define SVE_VL_MAX (SVE_VQ_MAX * SVE_VQ_BYTES)
+const uint16_t num_of_zregs = 32;
+const uint16_t num_of_pregs = 16;
 
-#define SVE_NUM_ZREGS 32
-#define SVE_NUM_PREGS 16
+inline uint16_t vl_valid(uint16_t vl) {
+  return (vl % vq_bytes == 0 && vl >= vl_min && vl <= vl_max);
+}
 
-#define sve_vl_valid(vl)   
\
-  ((vl) % SVE_VQ_BYTES == 0 && (vl) >= SVE_VL_MIN && (vl) <= SVE_VL_MAX)
-#define sve_vq_from_vl(vl) ((vl) / SVE_VQ_BYTES)
-#define sve_vl_from_vq(vq) ((vq)*SVE_VQ_BYTES)
+inline uint16_t vq_from_vl(uint16_t vl) { return vl / vq_bytes; }
+inline uint16_t vl_from_vq(uint16_t vq) { return vq * vq_bytes; }
+
+/* A new signal frame record sve_context encodes the SVE Registers on signal
+ * delivery. sve_context struct definition may be included in asm/sigcontext.h.
+ * We define sve_context_size which will be used by LLDB sve helper functions.
+ * More information on sve_context can be found in Linux kernel source tree at
+ * Documentation/arm64/sve.rst.
+ */
+
+const uint16_t sve_context_size = 16;
 
 /*
  * If the SVE registers are currently live for the thread at signal delivery,
  * sve_context.head.size >=
- * SVE_SIG_CONTEXT_SIZE(sve_vq_from_vl(sve_context.vl))
- * and the register data may be accessed using the SVE_SIG_*() macros.
+ * SigContextSize(vq_from_vl(sve_context.vl))
+ * and the register data may be accessed using the Sig*() functions.
  *
  * If sve_context.head.size <
- * SVE_SIG_CONTEXT_SIZE(sve_vq_from_vl(sve_context.vl)),
+ * SigContextSize(vq_from_vl(sve_context.vl)),
  * the SVE registers were not live for the thread and no register data
- * is included: in this case, the SVE_SIG_*() macros should not be
+ * is included: in this case, the Sig*() functions should not be
  * used except for this check.
  *
  * The same convention applies when returning from a signal: a caller
@@ -76,27 +73,27 @@ struct sve_context {
  * doing a sigreturn.
  *
  *
- * Note: for all these macros, the "vq" argument denotes the SVE
+ * Note: for all these functions, the "vq" argument denotes the SVE
  * vector length in quadwords (i.e., units of 128 bits).
  *
- * The correct way to obtain vq is to use sve_vq_from_vl(vl).  The
- * result is valid if and only if sve_vl_valid(vl) is true.  This is
+ * The correct way to obtain

[Lldb-commits] [PATCH] D84501: NativeThreadLinux invalidate register cache on stop

2020-08-19 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf4f40c376f5: [LLDB] NativeThreadLinux invalidate register 
cache on stop (authored by omjavaid).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84501

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


Index: lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
+++ lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
@@ -241,9 +241,6 @@
   if (signo != LLDB_INVALID_SIGNAL_NUMBER)
 data = signo;
 
-  // Before thread resumes, clear any cached register data structures
-  GetRegisterContext().InvalidateAllRegisters();
-
   return NativeProcessLinux::PtraceWrapper(PTRACE_CONT, GetID(), nullptr,
reinterpret_cast(data));
 }
@@ -265,9 +262,6 @@
   if (signo != LLDB_INVALID_SIGNAL_NUMBER)
 data = signo;
 
-  // Before thread resumes, clear any cached register data structures
-  GetRegisterContext().InvalidateAllRegisters();
-
   // If hardware single-stepping is not supported, we just do a continue. The
   // breakpoint on the next instruction has been setup in
   // NativeProcessLinux::Resume.
@@ -325,6 +319,9 @@
   if (m_state == StateType::eStateStepping)
 m_step_workaround.reset();
 
+  // On every stop, clear any cached register data structures
+  GetRegisterContext().InvalidateAllRegisters();
+
   const StateType new_state = StateType::eStateStopped;
   MaybeLogStateChange(new_state);
   m_state = new_state;


Index: lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
+++ lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
@@ -241,9 +241,6 @@
   if (signo != LLDB_INVALID_SIGNAL_NUMBER)
 data = signo;
 
-  // Before thread resumes, clear any cached register data structures
-  GetRegisterContext().InvalidateAllRegisters();
-
   return NativeProcessLinux::PtraceWrapper(PTRACE_CONT, GetID(), nullptr,
reinterpret_cast(data));
 }
@@ -265,9 +262,6 @@
   if (signo != LLDB_INVALID_SIGNAL_NUMBER)
 data = signo;
 
-  // Before thread resumes, clear any cached register data structures
-  GetRegisterContext().InvalidateAllRegisters();
-
   // If hardware single-stepping is not supported, we just do a continue. The
   // breakpoint on the next instruction has been setup in
   // NativeProcessLinux::Resume.
@@ -325,6 +319,9 @@
   if (m_state == StateType::eStateStepping)
 m_step_workaround.reset();
 
+  // On every stop, clear any cached register data structures
+  GetRegisterContext().InvalidateAllRegisters();
+
   const StateType new_state = StateType::eStateStopped;
   MaybeLogStateChange(new_state);
   m_state = new_state;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] af4f40c - [LLDB] NativeThreadLinux invalidate register cache on stop

2020-08-19 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2020-08-19T12:30:38+05:00
New Revision: af4f40c376f5f05ec1b7cc72840518e917eaf091

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

LOG: [LLDB] NativeThreadLinux invalidate register cache on stop

In our discussion D79699 SVE ptrace register access support we decide to
invalidate register context cached data on every stop instead of doing
at before Step/Resume.

InvalidateAllRegisters was added to facilitate flushing of SVE register
context configuration and cached register values. It now makes more
sense to move invalidation after every stop where we initiate SVE
configuration update if needed by calling ConfigureRegisterContext.

Reviewed By: labath

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

Added: 


Modified: 
lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp 
b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
index 14eea2df3810..5aec98bdeca6 100644
--- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
@@ -241,9 +241,6 @@ Status NativeThreadLinux::Resume(uint32_t signo) {
   if (signo != LLDB_INVALID_SIGNAL_NUMBER)
 data = signo;
 
-  // Before thread resumes, clear any cached register data structures
-  GetRegisterContext().InvalidateAllRegisters();
-
   return NativeProcessLinux::PtraceWrapper(PTRACE_CONT, GetID(), nullptr,
reinterpret_cast(data));
 }
@@ -265,9 +262,6 @@ Status NativeThreadLinux::SingleStep(uint32_t signo) {
   if (signo != LLDB_INVALID_SIGNAL_NUMBER)
 data = signo;
 
-  // Before thread resumes, clear any cached register data structures
-  GetRegisterContext().InvalidateAllRegisters();
-
   // If hardware single-stepping is not supported, we just do a continue. The
   // breakpoint on the next instruction has been setup in
   // NativeProcessLinux::Resume.
@@ -325,6 +319,9 @@ void NativeThreadLinux::SetStopped() {
   if (m_state == StateType::eStateStepping)
 m_step_workaround.reset();
 
+  // On every stop, clear any cached register data structures
+  GetRegisterContext().InvalidateAllRegisters();
+
   const StateType new_state = StateType::eStateStopped;
   MaybeLogStateChange(new_state);
   m_state = new_state;



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


[Lldb-commits] [PATCH] D85539: [lldb] Extend builder to pass the TRIPLE spec to Make

2020-08-19 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.
This revision is now accepted and ready to land.

This looks good to me, getting any logic out of the Makefile templates that we 
can, that's a good improvement for maintainability.


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

https://reviews.llvm.org/D85539

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


[Lldb-commits] [PATCH] D86194: [DWARFYAML] Add support for emitting multiple abbrev tables.

2020-08-19 Thread James Henderson via Phabricator via lldb-commits
jhenderson added inline comments.



Comment at: llvm/lib/ObjectYAML/DWARFEmitter.cpp:100
+  for (const DWARFYAML::AbbrevTable &AbbrevTable : DI.DebugAbbrev) {
+for (auto AbbrevDecl : AbbrevTable.Table) {
+  AbbrevCode =

Don't use `auto` here. It's not obvious what the type is.



Comment at: llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml:900
+
+## n) Test that yaml2obj emits an error message when a compilation unit has 
values but there is no associated abbrev tables.
+





Comment at: llvm/tools/obj2yaml/dwarf2yaml.cpp:26-43
+  DWARFYAML::AbbrevTable AbbrevTable;
   for (auto AbbrvDecl : AbbrvDeclSet.second) {
 DWARFYAML::Abbrev Abbrv;
 Abbrv.Code = AbbrvDecl.getCode();
 Abbrv.Tag = AbbrvDecl.getTag();
 Abbrv.Children = AbbrvDecl.hasChildren() ? dwarf::DW_CHILDREN_yes
  : dwarf::DW_CHILDREN_no;

Does this work?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86194

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


[Lldb-commits] [PATCH] D86194: [DWARFYAML] Add support for emitting multiple abbrev tables.

2020-08-19 Thread Xing GUO via Phabricator via lldb-commits
Higuoxing added inline comments.



Comment at: llvm/tools/obj2yaml/dwarf2yaml.cpp:26-43
+  DWARFYAML::AbbrevTable AbbrevTable;
   for (auto AbbrvDecl : AbbrvDeclSet.second) {
 DWARFYAML::Abbrev Abbrv;
 Abbrv.Code = AbbrvDecl.getCode();
 Abbrv.Tag = AbbrvDecl.getTag();
 Abbrv.Children = AbbrvDecl.hasChildren() ? dwarf::DW_CHILDREN_yes
  : dwarf::DW_CHILDREN_no;

jhenderson wrote:
> Does this work?
Yes, I think it works.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86194

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


[Lldb-commits] [PATCH] D86194: [DWARFYAML] Add support for emitting multiple abbrev tables.

2020-08-19 Thread James Henderson via Phabricator via lldb-commits
jhenderson accepted this revision.
jhenderson added a comment.
This revision is now accepted and ready to land.

LGTM, except for the new test change - I think that should be in a different 
patch.




Comment at: llvm/test/ObjectYAML/MachO/DWARF-debug_abbrev.yaml:1
+## Test that yaml2obj is able to emit the __debug_abbrev section and obj2yaml 
is able to
+## convert it back.

Let's move this test change into a different patch, to avoid doing too much at 
once.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86194

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


[Lldb-commits] [lldb] 567ba6c - [LLDB] Add ptrace register access for AArch64 SVE registers

2020-08-19 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2020-08-19T15:11:01+05:00
New Revision: 567ba6c468b93accefed944e5a44b1052d3597de

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

LOG: [LLDB] Add ptrace register access for AArch64 SVE registers

This patch adds NativeRegisterContext_arm64 ptrace routines to access
AArch64 SVE register set. This patch also adds a test-case to test
AArch64 SVE register access and dynamic size configuration capability.

Reviewed By: labath

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

Added: 

lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/Makefile

lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py

lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/main.c

Modified: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
index beae3aef7c07..f7b398ce620d 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
@@ -21,14 +21,17 @@
 #include "Plugins/Process/Linux/NativeProcessLinux.h"
 #include "Plugins/Process/Linux/Procfs.h"
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#include "Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h"
 
 // System includes - They have to be included after framework includes because
 // they define some macros which collide with variable names in other modules
 #include 
 // NT_PRSTATUS and NT_FPREGSET definition
 #include 
-// user_hwdebug_state definition
-#include 
+
+#ifndef NT_ARM_SVE
+#define NT_ARM_SVE 0x405 /* ARM Scalable Vector Extension */
+#endif
 
 #define REG_CONTEXT_SIZE (GetGPRSize() + GetFPRSize())
 
@@ -59,14 +62,21 @@ 
NativeRegisterContextLinux_arm64::NativeRegisterContextLinux_arm64(
   ::memset(&m_gpr_arm64, 0, sizeof(m_gpr_arm64));
   ::memset(&m_hwp_regs, 0, sizeof(m_hwp_regs));
   ::memset(&m_hbr_regs, 0, sizeof(m_hbr_regs));
+  ::memset(&m_sve_header, 0, sizeof(m_sve_header));
 
   // 16 is just a maximum value, query hardware for actual watchpoint count
   m_max_hwp_supported = 16;
   m_max_hbp_supported = 16;
+
   m_refresh_hwdebug_info = true;
 
   m_gpr_is_valid = false;
   m_fpu_is_valid = false;
+  m_sve_buffer_is_valid = false;
+  m_sve_header_is_valid = false;
+
+  // SVE is not enabled until we query user_sve_header
+  m_sve_state = SVEState::Unknown;
 }
 
 RegisterInfoPOSIX_arm64 &
@@ -109,28 +119,96 @@ NativeRegisterContextLinux_arm64::ReadRegister(const 
RegisterInfo *reg_info,
 
   uint8_t *src;
   uint32_t offset;
+  uint64_t sve_vg;
+  std::vector sve_reg_non_live;
 
   if (IsGPR(reg)) {
-if (!m_gpr_is_valid) {
-  error = ReadGPR();
-  if (error.Fail())
-return error;
-}
+error = ReadGPR();
+if (error.Fail())
+  return error;
 
 offset = reg_info->byte_offset;
 assert(offset < GetGPRSize());
 src = (uint8_t *)GetGPRBuffer() + offset;
 
   } else if (IsFPR(reg)) {
-if (!m_fpu_is_valid) {
-
+if (m_sve_state == SVEState::Disabled) {
+  // SVE is disabled take legacy route for FPU register access
   error = ReadFPR();
   if (error.Fail())
 return error;
+
+  offset = CalculateFprOffset(reg_info);
+  assert(offset < GetFPRSize());
+  src = (uint8_t *)GetFPRBuffer() + offset;
+} else {
+  // SVE enabled, we will read and cache SVE ptrace data
+  error = ReadAllSVE();
+  if (error.Fail())
+return error;
+
+  // FPSR and FPCR will be located right after Z registers in
+  // SVEState::FPSIMD while in SVEState::Full they will be located at the
+  // end of register data after an alignment correction based on currently
+  // selected vector length.
+  uint32_t sve_reg_num = LLDB_INVALID_REGNUM;
+  if (reg == GetRegisterInfo().GetRegNumFPSR()) {
+sve_reg_num = reg;
+if (m_sve_state == SVEState::Full)
+  offset = SVE_PT_SVE_FPSR_OFFSET(sve_vq_from_vl(m_sve_header.vl));
+else if (m_sve_state == SVEState::FPSIMD)
+  offset = SVE_PT_FPSIMD_OFFSET + (32 * 16);
+  } else if (reg == GetRegisterInfo().GetRegNumFPCR()) {
+sve_reg_num = reg;
+if (m_sve_state == SVEState::Full)
+  offset = SVE_PT_S

[Lldb-commits] [PATCH] D79699: Add ptrace register access for AArch64 SVE registers

2020-08-19 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG567ba6c468b9: [LLDB] Add ptrace register access for AArch64 
SVE registers (authored by omjavaid).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D79699?vs=285956&id=286522#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79699

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  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/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/Makefile
  
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py
  
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/main.c

Index: lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/main.c
===
--- /dev/null
+++ lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/main.c
@@ -0,0 +1,53 @@
+int main() {
+  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\n\t");
+  asm volatile("cpy  z29.b, p5/z, #30\n\t");
+  asm volatile("cpy  z30.b, p10/z, #31\n\t");
+  asm volatile("cpy  z31.b, p15/z, #32\n\t");
+  return 0; // Set a break point here.
+}
Index: lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py
===
--- /dev/null
+++ lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py
@@ -0,0 +1,176 @@
+"""
+Test the AArch64 SVE registers.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class RegisterCommandsTestCase(TestBase):
+
+def targetHasSVE(self):
+triple = self.dbg.GetSelectedPlatform().GetTriple()
+
+# TODO other platforms, please implement this function
+if not re.match(".*-.*-linux", triple):
+return False
+
+# Need to do something different for non-Linux/Android targets
+cpuinfo_path = self.getBuildArtifact("cpuinfo")
+if configuration.lldb_platform_name:
+self.runCmd('platform get-file "/proc/cpuinfo" ' + cpuinfo_path)
+
+f = open(cpuinfo_path, 'r')
+cpuinfo = f.read()
+f.close()
+return " sve " in cpuinfo
+
+def check_sve_register_size(self, set, name, expected):
+reg_value = set.GetChildMemberWithName(name)
+self.assertTrue(reg_value.IsValid(),
+'Verify we have a register named "%s"' % (name))
+self.assertEqual(reg_value.GetByteSize(), expected,
+  

[Lldb-commits] [PATCH] D82865: [LLDB] Add GetByteOffset to SBValue interface for reading register offset

2020-08-19 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added a comment.

@labath  ping!


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

https://reviews.llvm.org/D82865

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


[Lldb-commits] [PATCH] D82863: [LLDB] Add support to resize SVE registers at run-time

2020-08-19 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added a comment.

@labath  ping!


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

https://reviews.llvm.org/D82863

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


[Lldb-commits] [PATCH] D82857: [LLDB] Add per-thread register infos shared pointer in gdb-remote

2020-08-19 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added a comment.

@labath  ping!


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

https://reviews.llvm.org/D82857

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


[Lldb-commits] [PATCH] D82853: [LLDB] Support custom expedited register set in gdb-remote

2020-08-19 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added a comment.

@labath  ping!


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

https://reviews.llvm.org/D82853

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


[Lldb-commits] [PATCH] D82855: [LLDB] Send SVE vg register in custom expedited registerset

2020-08-19 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid updated this revision to Diff 286525.
omjavaid added a comment.

This revision updated after rebase.


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

https://reviews.llvm.org/D82855

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h


Index: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
===
--- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
+++ lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
@@ -101,6 +101,7 @@
   uint32_t GetRegNumSVEFFR() const;
   uint32_t GetRegNumFPCR() const;
   uint32_t GetRegNumFPSR() const;
+  uint32_t GetRegNumSVEVG() const;
 
 private:
   typedef std::map>
Index: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
===
--- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
+++ lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
@@ -341,3 +341,5 @@
 uint32_t RegisterInfoPOSIX_arm64::GetRegNumFPCR() const { return fpu_fpcr; }
 
 uint32_t RegisterInfoPOSIX_arm64::GetRegNumFPSR() const { return fpu_fpsr; }
+
+uint32_t RegisterInfoPOSIX_arm64::GetRegNumSVEVG() const { return sve_vg; }
Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
@@ -44,6 +44,8 @@
 
   void InvalidateAllRegisters() override;
 
+  const RegisterSet *GetExpeditedRegisterSet() const override;
+
   // Hardware breakpoints/watchpoint management functions
 
   uint32_t NumSupportedHardwareBreakpoints() override;
@@ -112,6 +114,9 @@
   struct user_sve_header m_sve_header;
   std::vector m_sve_ptrace_payload;
 
+  RegisterSet m_expedited_reg_set;
+  std::vector m_expedited_reg_nums;
+
   // Debug register info for hardware breakpoints and watchpoints management.
   struct DREG {
 lldb::addr_t address;  // Breakpoint/watchpoint address value.
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
@@ -1085,6 +1085,20 @@
   GetRegisterInfo().ConfigureVectorRegisterInfos(
   RegisterInfoPOSIX_arm64::eVectorQuadwordAArch64);
 } else {
+  // Setup expedited register set if not done already.
+  if (m_sve_state == SVEState::Unknown) {
+const uint32_t *reg_list_set0 =
+GetRegisterInfo().GetRegisterSet(0)->registers;
+const size_t reg_count_set0 =
+GetRegisterInfo().GetRegisterSet(0)->num_registers;
+
+m_expedited_reg_nums = std::vector(
+reg_list_set0, reg_list_set0 + reg_count_set0);
+m_expedited_reg_nums.push_back(GetRegisterInfo().GetRegNumSVEVG());
+m_expedited_reg_set = {"Expedited Registers", "expedited",
+   m_expedited_reg_nums.size(),
+   m_expedited_reg_nums.data()};
+  }
   if ((m_sve_header.flags & SVE_PT_REGS_MASK) == SVE_PT_REGS_FPSIMD)
 m_sve_state = SVEState::FPSIMD;
   else if ((m_sve_header.flags & SVE_PT_REGS_MASK) == SVE_PT_REGS_SVE)
@@ -1123,8 +1137,14 @@
 void *NativeRegisterContextLinux_arm64::GetSVEBuffer() {
   if (m_sve_state == SVEState::FPSIMD)
 return m_sve_ptrace_payload.data() + SVE_PT_FPSIMD_OFFSET;
-
   return m_sve_ptrace_payload.data();
 }
 
+const RegisterSet *
+NativeRegisterContextLinux_arm64::GetExpeditedRegisterSet() const {
+  if (m_sve_state == SVEState::FPSIMD || m_sve_state == SVEState::Full)
+&m_expedited_reg_set;
+  return GetRegisterInfo().GetRegisterSet(0);
+}
+
 #endif // defined (__arm64__) || defined (__aarch64__)


Index: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
===
--- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
+++ lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
@@ -101,6 +101,7 @@
   uint32_t GetRegNumSVEFFR() const;
   uint32_t GetRegNumFPCR() const;
   uint32_t GetRegNumFPSR() const;
+  uint32_t GetRegNumSVEVG() const;
 
 private:
   typedef std::map>
Index: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
===
--- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
+++ lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
@@ -341,3 +341,5 @@
 ui

[Lldb-commits] [PATCH] D82855: [LLDB] Send SVE vg register in custom expedited registerset

2020-08-19 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added a comment.

@labath ping!


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

https://reviews.llvm.org/D82855

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


[Lldb-commits] [lldb] bd791e9 - [LLDB] Minor fix in TestSVERegisters.py for AArch64/Linux buildbot

2020-08-19 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2020-08-19T15:47:59+05:00
New Revision: bd791e97f8bb0e4bb507bf51850183515ecc6743

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

LOG: [LLDB] Minor fix in TestSVERegisters.py for AArch64/Linux buildbot

This adds a minor test case fix to previously submitted AArch64 SVE
ptrace support. This was failing on LLDB/AArch64 Linux buildbot.

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

Added: 


Modified: 

lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py

Removed: 




diff  --git 
a/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py
 
b/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py
index c34f4ae27802..42d30f6cb113 100644
--- 
a/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py
+++ 
b/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py
@@ -21,10 +21,16 @@ def targetHasSVE(self):
 cpuinfo_path = self.getBuildArtifact("cpuinfo")
 if configuration.lldb_platform_name:
 self.runCmd('platform get-file "/proc/cpuinfo" ' + cpuinfo_path)
+else:
+cpuinfo_path = "/proc/cpuinfo"
+
+try:
+f = open(cpuinfo_path, 'r')
+cpuinfo = f.read()
+f.close()
+except:
+return False
 
-f = open(cpuinfo_path, 'r')
-cpuinfo = f.read()
-f.close()
 return " sve " in cpuinfo
 
 def check_sve_register_size(self, set, name, expected):



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


[Lldb-commits] [PATCH] D86174: [lldb] Convert builders to classes so we can use inheritance to override platform specific methods (NFC)

2020-08-19 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/packages/Python/lldbsuite/builders/freebsd.py:5-11
+def buildDsym(self,
+  sender=None,
+  architecture=None,
+  compiler=None,
+  dictionary=None,
+  testdir=None):
+return False

How about we put this into the base class, and remove all the noop builders?


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

https://reviews.llvm.org/D86174

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


[Lldb-commits] [lldb] c1b1868 - [lldb] Make error messages in TestQueues more helpfull

2020-08-19 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-08-19T13:30:31+02:00
New Revision: c1b1868f35bbb4d6e63515c00eb74d5aeac1aecc

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

LOG: [lldb] Make error messages in TestQueues more helpfull

Added: 


Modified: 
lldb/test/API/macosx/queues/TestQueues.py

Removed: 




diff  --git a/lldb/test/API/macosx/queues/TestQueues.py 
b/lldb/test/API/macosx/queues/TestQueues.py
index 805ad21a4137..e177daa54fa3 100644
--- a/lldb/test/API/macosx/queues/TestQueues.py
+++ b/lldb/test/API/macosx/queues/TestQueues.py
@@ -226,8 +226,8 @@ def queues(self):
 "requested_qos.printable_name",
 stream),
 "Get QoS printable string for user initiated QoS thread")
-self.assertTrue(
-stream.GetData() == "User Initiated",
+self.assertEqual(
+stream.GetData(), "User Initiated",
 "user initiated QoS thread name is valid")
 stream.Clear()
 self.assertTrue(
@@ -235,8 +235,8 @@ def queues(self):
 "requested_qos.printable_name",
 stream),
 "Get QoS printable string for user interactive QoS thread")
-self.assertTrue(
-stream.GetData() == "User Interactive",
+self.assertEqual(
+stream.GetData(), "User Interactive",
 "user interactive QoS thread name is valid")
 stream.Clear()
 self.assertTrue(
@@ -244,8 +244,8 @@ def queues(self):
 "requested_qos.printable_name",
 stream),
 "Get QoS printable string for utility QoS thread")
-self.assertTrue(
-stream.GetData() == "Utility",
+self.assertEqual(
+stream.GetData(), "Utility",
 "utility QoS thread name is valid")
 stream.Clear()
 self.assertTrue(
@@ -256,15 +256,15 @@ def queues(self):
 qosName = stream.GetData()
 self.assertTrue(
 qosName == "User Initiated" or qosName == "Default",
-"unspecified QoS thread name is valid")
+"unspecified QoS thread name is valid: " + str(qosName))
 stream.Clear()
 self.assertTrue(
 background_thread.GetInfoItemByPathAsString(
 "requested_qos.printable_name",
 stream),
 "Get QoS printable string for background QoS thread")
-self.assertTrue(
-stream.GetData() == "Background",
+self.assertEqual(
+stream.GetData(), "Background",
 "background QoS thread name is valid")
 
 @skipIfDarwin # rdar://50379398



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


[Lldb-commits] [PATCH] D85820: Use find_library for ncurses

2020-08-19 Thread Ye Henry Tian via Phabricator via lldb-commits
yehenrytian added a comment.

It looks like this change is causing a "regression" for MLIR tests:

https://mlir.llvm.org/getting_started/

  git clone https://github.com/llvm/llvm-project.git
  mkdir llvm-project/build
  cd llvm-project/build
  cmake -G Ninja ../llvm \
 -DLLVM_ENABLE_PROJECTS=mlir \
 -DLLVM_BUILD_EXAMPLES=ON \
 -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" \
 -DCMAKE_BUILD_TYPE=Release \
 -DLLVM_ENABLE_ASSERTIONS=ON \
  #  -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLLVM_ENABLE_LLD=ON
  
  cmake --build . --target check-mlir

Build results:

  
  
  Failed Tests (1):
MLIR :: Examples/standalone/test.toy
  
  
  Testing Time: 17.98s
Unsupported:  22
Passed : 553
Failed :   1

Has anyone hit this issue or tested MLIR? Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85820

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


[Lldb-commits] [PATCH] D85820: Use find_library for ncurses

2020-08-19 Thread Harmen Stoppels via Phabricator via lldb-commits
haampie added a comment.

@gribozavr2: can you try https://reviews.llvm.org/D86134? It should fix your 
issue, as well as the same issue w.r.t. the ZLIB changes of 
https://reviews.llvm.org/D79219 on macOS.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85820

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


[Lldb-commits] [PATCH] D85820: Use find_library for ncurses

2020-08-19 Thread Harmen Stoppels via Phabricator via lldb-commits
haampie added a comment.

@srj could you please try / review https://reviews.llvm.org/D86173 for a fix 
for your problem?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85820

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


[Lldb-commits] [PATCH] D85820: Use find_library for ncurses

2020-08-19 Thread Steven Johnson via Phabricator via lldb-commits
srj added a comment.

This seems to have injected a link-time dependency on `setupterm` etc. even if 
you configure CMake with LLVM_ENABLE_TERMINFO=OFF (which was not the case 
before) -- this is breaking some builds of Halide as a result. (Should the 
`#idef LLVM_ENABLE_TERMINFO` actually if `#if` instead of `#ifdef`?)

Please consider reverting this change if a fix-forward isn't available soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85820

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


[Lldb-commits] [PATCH] D79219: [CMake] Simplify CMake handling for zlib

2020-08-19 Thread Harmen Stoppels via Phabricator via lldb-commits
haampie added inline comments.



Comment at: llvm/lib/Support/CMakeLists.txt:217
+  endif()
+  if(CMAKE_SHARED_LIBRARY_PREFIX AND CMAKE_SHARED_LIBRARY_SUFFIX AND
+  zlib_library MATCHES 
"^${CMAKE_SHARED_LIBRARY_PREFIX}.*${CMAKE_SHARED_LIBRARY_SUFFIX}$")

This will not work on macOS since cmake will find stub libraries by default 
(/path/to/libz.tbd), see 
https://github.com/Kitware/CMake/blob/master/Modules/Platform/Darwin.cmake#L71 
for the search order.

Instead you most likely want to use `CMAKE_FIND_LIBRARY_PREFIXES` and 
`CMAKE_FIND_LIBRARY_SUFFIXES`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79219

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


[Lldb-commits] [PATCH] D85820: Use find_library for ncurses

2020-08-19 Thread Steven Johnson via Phabricator via lldb-commits
srj added inline comments.



Comment at: llvm/include/llvm/Config/config.h.cmake:212
 /* Define if the setupterm() function is supported this platform. */
-#cmakedefine HAVE_TERMINFO ${HAVE_TERMINFO}
+#cmakedefine LLVM_ENABLE_TERMINFO ${LLVM_ENABLE_TERMINFO}
 

srj wrote:
> In my local build of LLVM, I end up with 
> 
> `#define LLVM_ENABLE_TERMINFO 1`
> 
> in the generated `config.h` file, even thought I configured LLVM's CMake 
> build with `-D LLVM_ENABLE_TERMINFO=OFF` -- surely this is a bug.
> 
(fyi, prior to this commit, the corresponding line was `/* #undef HAVE_TERMINFO 
*/`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85820

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


[Lldb-commits] [PATCH] D85820: Use find_library for ncurses

2020-08-19 Thread Dmitri Gribenko via Phabricator via lldb-commits
gribozavr2 added a comment.

@haampie It looks like this change caused a build problem with OCaml enabled.

Before: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/34606

After: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/34607

Could you take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85820

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


[Lldb-commits] [PATCH] D85820: Use find_library for ncurses

2020-08-19 Thread Harmen Stoppels via Phabricator via lldb-commits
haampie added inline comments.



Comment at: llvm/include/llvm/Config/config.h.cmake:212
 /* Define if the setupterm() function is supported this platform. */
-#cmakedefine HAVE_TERMINFO ${HAVE_TERMINFO}
+#cmakedefine LLVM_ENABLE_TERMINFO ${LLVM_ENABLE_TERMINFO}
 

srj wrote:
> srj wrote:
> > In my local build of LLVM, I end up with 
> > 
> > `#define LLVM_ENABLE_TERMINFO 1`
> > 
> > in the generated `config.h` file, even thought I configured LLVM's CMake 
> > build with `-D LLVM_ENABLE_TERMINFO=OFF` -- surely this is a bug.
> > 
> (fyi, prior to this commit, the corresponding line was `/* #undef 
> HAVE_TERMINFO */`)
@srj you are completely right, the `find_library` lost its `if 
(LLVM_ENABLE_TERMINFO)` when the last review comments were addressed. Let me 
submit a patch asap


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85820

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


[Lldb-commits] [PATCH] D85820: Use find_library for ncurses

2020-08-19 Thread Steven Johnson via Phabricator via lldb-commits
srj added inline comments.



Comment at: llvm/include/llvm/Config/config.h.cmake:212
 /* Define if the setupterm() function is supported this platform. */
-#cmakedefine HAVE_TERMINFO ${HAVE_TERMINFO}
+#cmakedefine LLVM_ENABLE_TERMINFO ${LLVM_ENABLE_TERMINFO}
 

In my local build of LLVM, I end up with 

`#define LLVM_ENABLE_TERMINFO 1`

in the generated `config.h` file, even thought I configured LLVM's CMake build 
with `-D LLVM_ENABLE_TERMINFO=OFF` -- surely this is a bug.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85820

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


[Lldb-commits] [PATCH] D86110: [WIP][DebugInfo] Lazily parse debug_loclist offsets

2020-08-19 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D86110#2224163 , @dblaikie wrote:

> In D86110#2223905 , @labath wrote:
>
>> This sounds perfectly reasonable to me. The offsets are present in memory 
>> already so there's no point in storing them in a vector as well.
>
> Thanks for taking a look! I'll take this as approval and commit soon.

The patch had a WIP label, so I was only looking/commenting on the high-level 
idea. But after looking at the implementation more closely, I think that looks 
good too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86110

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


[Lldb-commits] [PATCH] D85539: [lldb] Extend builder to pass the TRIPLE spec to Make

2020-08-19 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added inline comments.



Comment at: lldb/packages/Python/lldbsuite/builders/builder.py:201-202
 self.getCCSpec(compiler),
 self.getDsymutilSpec(),
+self.getCodesignSpec(),
 self.getSDKRootSpec(),

Instead of a new method for each variable any subclass might want to set it 
would probably be better to just have an `getExtraMakeArgs` method that each 
subclass can return whatever it wants. ARCH_CFLAGS is fairly generic, so it may 
make sense to keep that separate, but DSYMUTIL and CODESIGN (and maybe SDKROOT) 
sound like they could go into the "extra" category.


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

https://reviews.llvm.org/D85539

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


[Lldb-commits] [PATCH] D82865: [LLDB] Add GetByteOffset to SBValue interface for reading register offset

2020-08-19 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

The new API looks fairly confusing. This doesn't sound like something that the 
SB users should generally know or care about. What would the GetByteOffset 
function return in the generic case?
I don't find the explanation in the summary convincing. Presumably, you should 
be able to verify the proper behavior by checking the data (and its size) that 
the SBValue object holds. If that returns the right thing, who cares about the 
value of the offset field?


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

https://reviews.llvm.org/D82865

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


[Lldb-commits] [PATCH] D82853: [LLDB] Support custom expedited register set in gdb-remote

2020-08-19 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Looking at the dependent patch, I see that you need to conjure up a fake 
register set to make this work. That works, but doesn't seem entirely optimal. 
This expedition function doesn't really care about register sets, it just needs 
a way to get a list of registers. What if we just made the interface return 
that? (e.g. `ArrayRef GetExpeditedRegisters()`)

And instead of handing the nullptr specially in the caller, we could just make 
the default implementation of this function return the first (zeroth) register 
set...


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

https://reviews.llvm.org/D82853

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


[Lldb-commits] [PATCH] D85968: [lldb] Forcefully complete a type when adding nested classes

2020-08-19 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s:7
 
-# RUN: llvm-mc --triple x86_64-pc-linux %s --filetype=obj > %t
-# RUN: %lldb %t -o "expr a" -o exit 2>&1 | FileCheck %s --check-prefix=EXPR
-# RUN: %lldb %t -o "target var a" -o exit 2>&1 | FileCheck %s 
--check-prefix=VAR
-
-# EXPR: incomplete type 'A' where a complete type is required
+# RUN: rm -rf %t
+# RUN: split-file %s %t

MaskRay wrote:
> In many cases `rm -rf %t` is not needed. `split-file` will unlink the output 
> if it was originally a file.
Aha. That seems useful, albeit unexpected.



Comment at: lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s:9
+# RUN: split-file %s %t
+# RUN: llvm-mc --triple x86_64-pc-linux %t/asm --filetype=obj > %t.o
+# RUN: %lldb -o "settings set interpreter.stop-command-source-on-error false" \

MaskRay wrote:
> No need to change now: `-o` is recommended (I think the arguments are (1) for 
> aesthetic value (2) when llvm-mc fails, don't leave an empty file)
cool


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85968

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


[Lldb-commits] [lldb] d736339 - [lldb] Add typedefs to the DeclContext they are created in

2020-08-19 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-19T14:57:43+02:00
New Revision: d7363397c669f611e379988ea12fb428847fce61

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

LOG: [lldb] Add typedefs to the DeclContext they are created in

TypeSystemClang::CreateTypedef was creating a typedef in the right
DeclContext, but it was not actually adding it as a child of the
context. The resulting inconsistent state meant that we would be unable
to reference the typedef from an expression directly, but we could use
them if they end up being pulled in by some previous subexpression
(because the ASTImporter will set up the correct links in the expression
ast).

This patch adds the typedef to the decl context it is created in.

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

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
lldb/test/API/lang/cpp/typedef/main.cpp

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 724826de63fa..d8616ef35b0f 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2538,6 +2538,7 @@ def expect_expr(
 value_check = ValueCheck(type=result_type, value=result_value,
  summary=result_summary, 
children=result_children)
 value_check.check_value(self, eval_result, str(eval_result))
+return eval_result
 
 def invoke(self, obj, name, trace=False):
 """Use reflection to call a method dynamically with no argument."""

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 608cdc25d072..d80d07574073 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4495,6 +4495,7 @@ CompilerType TypeSystemClang::CreateTypedef(
 clang_ast, decl_ctx, clang::SourceLocation(), clang::SourceLocation(),
 &clang_ast.Idents.get(typedef_name),
 clang_ast.getTrivialTypeSourceInfo(qual_type));
+decl_ctx->addDecl(decl);
 SetOwningModule(decl, TypePayloadClang(payload).GetOwningModule());
 
 clang::TagDecl *tdecl = nullptr;

diff  --git a/lldb/test/API/lang/cpp/typedef/TestCppTypedef.py 
b/lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
index 2aa2bcfe431a..35a2fba7ca9d 100644
--- a/lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
+++ b/lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
@@ -29,8 +29,16 @@ def test_typedef(self):
 
 # First of all, check that we can get a typedefed type correctly in a 
simple case
 
-expr_result = frame.EvaluateExpression("(SF)s")
-self.assertTrue(expr_result.IsValid(), "Expression failed with: " + 
str(expr_result.GetError()))
+expr_result = self.expect_expr("(SF)s", 
result_children=[ValueCheck(value="0.5")])
+self.expect_expr("(ns::SF)s", 
result_children=[ValueCheck(value="0.5")])
+self.expect_expr("(ST::SF)s", 
result_children=[ValueCheck(value="0.5")])
+
+self.filecheck("image dump ast a.out", __file__, "--strict-whitespace")
+# CHECK:  {{^}}|-TypedefDecl {{.*}} SF 'S'
+# CHECK:  {{^}}|-NamespaceDecl {{.*}} ns
+# CHECK-NEXT: {{^}}| `-TypedefDecl {{.*}} SF 'S'
+# CHECK:  {{^}}`-CXXRecordDecl {{.*}} struct ST definition
+# CHECK:  {{^}}  `-TypedefDecl {{.*}} SF 'S'
 
 typedef_type = expr_result.GetType();
 self.assertTrue(typedef_type.IsValid(), "Can't get `SF` type of 
evaluated expression")

diff  --git a/lldb/test/API/lang/cpp/typedef/main.cpp 
b/lldb/test/API/lang/cpp/typedef/main.cpp
index f1407b630a62..05757869ffec 100644
--- a/lldb/test/API/lang/cpp/typedef/main.cpp
+++ b/lldb/test/API/lang/cpp/typedef/main.cpp
@@ -7,7 +7,16 @@ struct S {
 
 typedef S SF;
 
+namespace ns {
+typedef S SF;
+}
+struct ST {
+  typedef S SF;
+};
+
 int main (int argc, char const *argv[]) {
   SF s{ .5 };
+  ns::SF in_ns;
+  ST::SF in_struct;
   return 0; // Set a breakpoint here
 }



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


[Lldb-commits] [PATCH] D86140: [lldb] Add typedefs to the DeclContext they are created in

2020-08-19 Thread Pavel Labath 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 rGd7363397c669: [lldb] Add typedefs to the DeclContext they 
are created in (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86140

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
  lldb/test/API/lang/cpp/typedef/main.cpp


Index: lldb/test/API/lang/cpp/typedef/main.cpp
===
--- lldb/test/API/lang/cpp/typedef/main.cpp
+++ lldb/test/API/lang/cpp/typedef/main.cpp
@@ -7,7 +7,16 @@
 
 typedef S SF;
 
+namespace ns {
+typedef S SF;
+}
+struct ST {
+  typedef S SF;
+};
+
 int main (int argc, char const *argv[]) {
   SF s{ .5 };
+  ns::SF in_ns;
+  ST::SF in_struct;
   return 0; // Set a breakpoint here
 }
Index: lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
===
--- lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
+++ lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
@@ -29,8 +29,16 @@
 
 # First of all, check that we can get a typedefed type correctly in a 
simple case
 
-expr_result = frame.EvaluateExpression("(SF)s")
-self.assertTrue(expr_result.IsValid(), "Expression failed with: " + 
str(expr_result.GetError()))
+expr_result = self.expect_expr("(SF)s", 
result_children=[ValueCheck(value="0.5")])
+self.expect_expr("(ns::SF)s", 
result_children=[ValueCheck(value="0.5")])
+self.expect_expr("(ST::SF)s", 
result_children=[ValueCheck(value="0.5")])
+
+self.filecheck("image dump ast a.out", __file__, "--strict-whitespace")
+# CHECK:  {{^}}|-TypedefDecl {{.*}} SF 'S'
+# CHECK:  {{^}}|-NamespaceDecl {{.*}} ns
+# CHECK-NEXT: {{^}}| `-TypedefDecl {{.*}} SF 'S'
+# CHECK:  {{^}}`-CXXRecordDecl {{.*}} struct ST definition
+# CHECK:  {{^}}  `-TypedefDecl {{.*}} SF 'S'
 
 typedef_type = expr_result.GetType();
 self.assertTrue(typedef_type.IsValid(), "Can't get `SF` type of 
evaluated expression")
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4495,6 +4495,7 @@
 clang_ast, decl_ctx, clang::SourceLocation(), clang::SourceLocation(),
 &clang_ast.Idents.get(typedef_name),
 clang_ast.getTrivialTypeSourceInfo(qual_type));
+decl_ctx->addDecl(decl);
 SetOwningModule(decl, TypePayloadClang(payload).GetOwningModule());
 
 clang::TagDecl *tdecl = nullptr;
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2538,6 +2538,7 @@
 value_check = ValueCheck(type=result_type, value=result_value,
  summary=result_summary, 
children=result_children)
 value_check.check_value(self, eval_result, str(eval_result))
+return eval_result
 
 def invoke(self, obj, name, trace=False):
 """Use reflection to call a method dynamically with no argument."""


Index: lldb/test/API/lang/cpp/typedef/main.cpp
===
--- lldb/test/API/lang/cpp/typedef/main.cpp
+++ lldb/test/API/lang/cpp/typedef/main.cpp
@@ -7,7 +7,16 @@
 
 typedef S SF;
 
+namespace ns {
+typedef S SF;
+}
+struct ST {
+  typedef S SF;
+};
+
 int main (int argc, char const *argv[]) {
   SF s{ .5 };
+  ns::SF in_ns;
+  ST::SF in_struct;
   return 0; // Set a breakpoint here
 }
Index: lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
===
--- lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
+++ lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
@@ -29,8 +29,16 @@
 
 # First of all, check that we can get a typedefed type correctly in a simple case
 
-expr_result = frame.EvaluateExpression("(SF)s")
-self.assertTrue(expr_result.IsValid(), "Expression failed with: " + str(expr_result.GetError()))
+expr_result = self.expect_expr("(SF)s", result_children=[ValueCheck(value="0.5")])
+self.expect_expr("(ns::SF)s", result_children=[ValueCheck(value="0.5")])
+self.expect_expr("(ST::SF)s", result_children=[ValueCheck(value="0.5")])
+
+self.filecheck("image dump ast a.out", __file__, "--strict-whitespace")
+# CHECK:  {{^}}|-TypedefDecl {{.*}} SF 'S'
+# CHECK:  {{^}}|-NamespaceDecl {{.*}} ns
+# CHECK-NEXT: {{^}}| `-TypedefDecl {{.*}} SF 'S'
+# CHECK:  {{^}}`-CXXRecordDe

[Lldb-commits] [lldb] 9cc2f13 - [lldb] Clean up DW_AT_declaration-with-children.s test

2020-08-19 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-19T14:58:50+02:00
New Revision: 9cc2f13deeb30de3a2ce1854c36f6c0a8de86d6c

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

LOG: [lldb] Clean up DW_AT_declaration-with-children.s test

Address some post-commit feedback on D85968.

Added: 


Modified: 
lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s

Removed: 




diff  --git 
a/lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s 
b/lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s
index e00dc1961749..f17902918e38 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s
+++ b/lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s
@@ -4,9 +4,8 @@
 
 # REQUIRES: x86
 
-# RUN: rm -rf %t
 # RUN: split-file %s %t
-# RUN: llvm-mc --triple x86_64-pc-linux %t/asm --filetype=obj > %t.o
+# RUN: llvm-mc --triple x86_64-pc-linux %t/asm --filetype=obj -o %t.o
 # RUN: %lldb -o "settings set interpreter.stop-command-source-on-error false" \
 # RUN:   -s %t/commands -o exit %t.o 2>&1 | FileCheck %s
 



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


[Lldb-commits] [PATCH] D86216: [lldb] Forcefully complete a type when adding typedefs

2020-08-19 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: teemperor, shafik.
Herald added a project: LLDB.
labath requested review of this revision.
Herald added a subscriber: JDevlieghere.

This is very similar to D85968 , only more 
elusive to since we were not
adding the typedef type to the relevant DeclContext until D86140 
, which
meant that the DeclContext was populated (and the relevant assertion
hit) only after importing the type into the expression ast in a
particular way.

I haven't checked whether this situation can be hit in the gmodules
case, but my money is on "yes".


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86216

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s

Index: lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s
===
--- lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s
+++ lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s
@@ -28,6 +28,13 @@
 # CHECK-LABEL: expr b1
 # CHECK: (B::B1) $0 = (ptr = 0xbaadf00d)
 
+target var c1
+# CHECK-LABEL: target var c1
+# CHECK: (C::C1) c1 = 424742
+
+expr c1
+# CHECK-LABEL: expr c1
+# CHECK: (C::C1) $1 = 424742
 #--- asm
 .text
 _ZN1AC2Ev:
@@ -42,6 +49,8 @@
 
 b1:
 .quad   0xbaadf00d
+c1:
+.long   42474247
 
 .section.debug_abbrev,"",@progbits
 .byte   1   # Abbreviation Code
@@ -118,6 +127,17 @@
 .byte   19  # DW_FORM_ref4
 .byte   0   # EOM(1)
 .byte   0   # EOM(2)
+.byte   9   # Abbreviation Code
+.byte   36  # DW_TAG_base_type
+.byte   0   # DW_CHILDREN_no
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   62  # DW_AT_encoding
+.byte   11  # DW_FORM_data1
+.byte   11  # DW_AT_byte_size
+.byte   11  # DW_FORM_data1
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
 .byte   10  # Abbreviation Code
 .byte   46  # DW_TAG_subprogram
 .byte   1   # DW_CHILDREN_yes
@@ -146,6 +166,15 @@
 .byte   25  # DW_FORM_flag_present
 .byte   0   # EOM(1)
 .byte   0   # EOM(2)
+.byte   12  # Abbreviation Code
+.byte   22  # DW_TAG_typedef
+.byte   0   # DW_CHILDREN_no
+.byte   73  # DW_AT_type
+.byte   19  # DW_FORM_ref4
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
 .byte   0   # EOM(3)
 .section.debug_info,"",@progbits
 .Lcu_begin0:
@@ -222,7 +251,6 @@
 .LB1:
 .byte   6   # Abbrev [6] DW_TAG_class_type
 .asciz  "B1"# DW_AT_name
-# DW_AT_declaration
 .byte   7   # Abbrev [5] 0x58:0xc DW_TAG_member
 .asciz  "ptr"   # DW_AT_name
 .long   .LAptr  # DW_AT_type
@@ -237,5 +265,33 @@
 .byte   3
 .quad   b1
 
+# Case 3: A typedef in DW_AT_declaration struct.
+# C++ equivalent:
+# struct C {
+#   virtual ~C(); // not defined here
+#   typedef int C1;
+# };
+# C::C1 c1;
+.Lint:
+.byte   9   # Abbrev [9] DW_TAG_base_type
+.asciz  "int"   # DW_AT_name
+.byte   5   # DW_AT_encoding
+.byte   4   # DW_AT_byte_size
+.byte   3   # Abbrev [3] DW_TAG_structure_type
+.asciz  "C" # DW_AT_name
+# DW_AT_declaration
+.LC1:
+.byte   12  # Abbrev [12] DW_TAG_typedef
+.long   .Lint-.Lcu_begin0   # DW_AT_type
+.asciz  "C1"  

[Lldb-commits] [PATCH] D86220: [lldb/Utility] Simplify Scalar handling of float types

2020-08-19 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: JDevlieghere, teemperor.
Herald added a project: LLDB.
labath requested review of this revision.

Similarly to D85836 , collapse all Scalar 
float types to a single enum
value, and use APFloat semantics to differentiate between. This
simplifies the code, and opens to door to supporting other floating
point semantics (which would be needed for fully supporting
architectures with more interesting float types such as PPC).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86220

Files:
  lldb/include/lldb/Utility/Scalar.h
  lldb/source/Utility/Scalar.cpp
  lldb/unittests/Utility/ScalarTest.cpp

Index: lldb/unittests/Utility/ScalarTest.cpp
===
--- lldb/unittests/Utility/ScalarTest.cpp
+++ lldb/unittests/Utility/ScalarTest.cpp
@@ -16,6 +16,7 @@
 #include "llvm/Testing/Support/Error.h"
 
 using namespace lldb_private;
+using llvm::APFloat;
 using llvm::APInt;
 using llvm::Failed;
 using llvm::Succeeded;
@@ -304,12 +305,12 @@
 
   EXPECT_FALSE(a.IntegralPromote(64, true));
 
-  EXPECT_TRUE(a.FloatPromote(Scalar::e_double));
-  EXPECT_EQ(Scalar::e_double, a.GetType());
+  EXPECT_TRUE(a.FloatPromote(APFloat::IEEEdouble()));
+  EXPECT_EQ(Scalar::e_float, a.GetType());
   EXPECT_EQ(47.0, a.Double());
 
-  EXPECT_FALSE(a.FloatPromote(Scalar::e_float));
-  EXPECT_TRUE(a.FloatPromote(Scalar::e_long_double));
+  EXPECT_FALSE(a.FloatPromote(APFloat::IEEEsingle()));
+  EXPECT_TRUE(a.FloatPromote(APFloat::x87DoubleExtended()));
   EXPECT_EQ(47.0L, a.LongDouble());
 }
 
Index: lldb/source/Utility/Scalar.cpp
===
--- lldb/source/Utility/Scalar.cpp
+++ lldb/source/Utility/Scalar.cpp
@@ -26,17 +26,11 @@
 using llvm::APFloat;
 using llvm::APInt;
 
-namespace {
-enum class Category { Void, Integral, Float };
-}
-
-static Category GetCategory(Scalar::Type type) {
+Scalar::Category Scalar::GetCategory(Scalar::Type type) {
   switch (type) {
   case Scalar::e_void:
 return Category::Void;
   case Scalar::e_float:
-  case Scalar::e_double:
-  case Scalar::e_long_double:
 return Category::Float;
   case Scalar::e_sint:
   case Scalar::e_uint:
@@ -52,49 +46,62 @@
 return false;
   case Scalar::e_sint:
   case Scalar::e_float:
-  case Scalar::e_double:
-  case Scalar::e_long_double:
 return true;
   }
   llvm_unreachable("Unhandled type!");
 }
 
-Scalar::IntPromotionKey Scalar::GetIntKey() const {
-  assert(GetCategory(GetType()) == Category::Integral);
-  return {m_integer.getBitWidth(), !IsSigned(m_type)};
+Scalar::PromotionKey Scalar::GetPromoKey() const {
+  Category cat = GetCategory(m_type);
+  switch (cat) {
+  case Category::Void:
+return {cat, 0, false};
+  case Category::Integral:
+return {cat, m_integer.getBitWidth(), !IsSigned(m_type)};
+  case Category::Float:
+return GetFloatPromoKey(m_float.getSemantics());
+  }
+  llvm_unreachable("Unhandled category!");
+}
+
+Scalar::PromotionKey Scalar::GetFloatPromoKey(const llvm::fltSemantics &sem) {
+  static const llvm::fltSemantics *order[] = {&APFloat::IEEEsingle(),
+  &APFloat::IEEEdouble(),
+  &APFloat::x87DoubleExtended()};
+  for (const auto &entry : llvm::enumerate(order)) {
+if (entry.value() == &sem)
+  return {Category::Float, entry.index(), false};
+  }
+  llvm_unreachable("Unsupported semantics!");
 }
 
 // Promote to max type currently follows the ANSI C rule for type promotion in
 // expressions.
 Scalar::Type Scalar::PromoteToMaxType(Scalar &lhs, Scalar &rhs) {
   const auto &Promote = [](Scalar &a, const Scalar &b) {
-if (GetCategory(b.GetType()) == Category::Integral)
+switch (GetCategory(b.GetType())) {
+case Category::Void:
+  break;
+case Category::Integral:
   a.IntegralPromote(b.UInt128(APInt()).getBitWidth(),
 IsSigned(b.GetType()));
-else
-  a.FloatPromote(b.GetType());
+  break;
+case Category::Float:
+  a.FloatPromote(b.m_float.getSemantics());
+}
   };
 
-  // Extract the types of both the right and left hand side values
-  Scalar::Type lhs_type = lhs.GetType();
-  Scalar::Type rhs_type = rhs.GetType();
-
-  if (GetCategory(lhs_type) == Category::Integral &&
-  GetCategory(rhs_type) == Category::Integral) {
-IntPromotionKey lhs_key = lhs.GetIntKey();
-IntPromotionKey rhs_key = rhs.GetIntKey();
-if (lhs_key > rhs_key)
-  Promote(rhs, lhs);
-else if (rhs_key > lhs_key)
-  Promote(lhs, rhs);
-  } else if (lhs_type > rhs_type)
+  PromotionKey lhs_key = lhs.GetPromoKey();
+  PromotionKey rhs_key = rhs.GetPromoKey();
+
+  if (lhs_key > rhs_key)
 Promote(rhs, lhs);
-  else if (lhs_type < rhs_type)
+  else if (rhs_key > lhs_key)
 Promote(lhs, rhs);
 
   // Make sure our type promotion worked as expected
-  if

[Lldb-commits] [PATCH] D86174: [lldb] Convert builders to classes so we can use inheritance to override platform specific methods (NFC)

2020-08-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1922bf12e1f3: [lldb] Convert builders to use inheritance 
(NFC) (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D86174?vs=286454&id=286571#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86174

Files:
  lldb/packages/Python/lldbsuite/builders/__init__.py
  lldb/packages/Python/lldbsuite/builders/builder.py
  lldb/packages/Python/lldbsuite/builders/darwin.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules
  lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
  lldb/packages/Python/lldbsuite/test/plugins/builder_darwin.py
  lldb/packages/Python/lldbsuite/test/plugins/builder_freebsd.py
  lldb/packages/Python/lldbsuite/test/plugins/builder_linux.py
  lldb/packages/Python/lldbsuite/test/plugins/builder_netbsd.py
  lldb/packages/Python/lldbsuite/test/plugins/builder_openbsd.py
  lldb/packages/Python/lldbsuite/test/plugins/builder_win32.py

Index: lldb/packages/Python/lldbsuite/test/plugins/builder_win32.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_win32.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from builder_base import *
-
-
-def buildDsym(
-sender=None,
-architecture=None,
-compiler=None,
-dictionary=None,
-testdir=None):
-return False
Index: lldb/packages/Python/lldbsuite/test/plugins/builder_openbsd.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_openbsd.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from builder_base import *
-
-
-def buildDsym(
-sender=None,
-architecture=None,
-compiler=None,
-dictionary=None,
-testdir=None):
-return False
Index: lldb/packages/Python/lldbsuite/test/plugins/builder_netbsd.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_netbsd.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from builder_base import *
-
-
-def buildDsym(
-sender=None,
-architecture=None,
-compiler=None,
-dictionary=None,
-testdir=None):
-return False
Index: lldb/packages/Python/lldbsuite/test/plugins/builder_linux.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_linux.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from builder_base import *
-
-
-def buildDsym(
-sender=None,
-architecture=None,
-compiler=None,
-dictionary=None,
-testdir=None):
-return False
Index: lldb/packages/Python/lldbsuite/test/plugins/builder_freebsd.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_freebsd.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from builder_base import *
-
-
-def buildDsym(
-sender=None,
-architecture=None,
-compiler=None,
-dictionary=None,
-testdir=None):
-return False
Index: lldb/packages/Python/lldbsuite/test/plugins/builder_darwin.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_darwin.py
+++ /dev/null
@@ -1,28 +0,0 @@
-
-import lldbsuite.test.lldbtest as lldbtest
-
-from builder_base import *
-
-def buildDsym(
-sender=None,
-architecture=None,
-compiler=None,
-dictionary=None,
-testdir=None,
-testname=None):
-"""Build the binaries with dsym debug info."""
-commands = []
-commands.append(getMake(testdir, testname) +
-["MAKE_DSYM=YES",
- getArchSpec(architecture),
- getCCSpec(compiler),
- getDsymutilSpec(),
- getSDKRootSpec(),
- getModuleCacheSpec(),
- "all",
- getCmdLine(dictionary)])
-
-runBuildCommands(commands, sender=sender)
-
-# True signifies that we can handle building dsym.
-return True
Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ /dev/null
@@ -1,249 +0,0 @@
-"""
-If the build* function is passed the compiler argument, for example, 'llvm-gcc',
-it is passed as a make variable to the make command.  Otherwise, we check the
-LLDB_CC environment variable; if it is defined, it is passed as a make variable
-to the make command.
-
-If neither the compiler keyword argument nor the LLDB_CC environment variable is
-specified, no CC make variable is passed to the make command.  The Makefile gets
-

[Lldb-commits] [lldb] 1922bf1 - [lldb] Convert builders to use inheritance (NFC)

2020-08-19 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-08-19T08:44:29-07:00
New Revision: 1922bf12e1f3f228c0f57b27c796ebea4a50c358

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

LOG: [lldb] Convert builders to use inheritance (NFC)

Rather than have different modules for different platforms, use
inheritance so we can have a Builer base class and optional child
classes that override platform specific methods.

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

Added: 
lldb/packages/Python/lldbsuite/builders/__init__.py
lldb/packages/Python/lldbsuite/builders/builder.py
lldb/packages/Python/lldbsuite/builders/darwin.py

Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Removed: 
lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
lldb/packages/Python/lldbsuite/test/plugins/builder_darwin.py
lldb/packages/Python/lldbsuite/test/plugins/builder_freebsd.py
lldb/packages/Python/lldbsuite/test/plugins/builder_linux.py
lldb/packages/Python/lldbsuite/test/plugins/builder_netbsd.py
lldb/packages/Python/lldbsuite/test/plugins/builder_openbsd.py
lldb/packages/Python/lldbsuite/test/plugins/builder_win32.py



diff  --git a/lldb/packages/Python/lldbsuite/builders/__init__.py 
b/lldb/packages/Python/lldbsuite/builders/__init__.py
new file mode 100644
index ..0bfcd592031d
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/builders/__init__.py
@@ -0,0 +1,16 @@
+"""
+This module builds test binaries for the test suite using Make.
+
+Platform specific builders can override methods in the Builder base class. The
+factory method below hands out builders based on the given platform.
+"""
+
+from .builder import Builder
+
+
+def get_builder(platform):
+  """Returns a Builder instance for the given platform."""
+  if platform == 'darwin':
+from .darwin import BuilderDarwin
+return BuilderDarwin()
+  return Builder()

diff  --git a/lldb/packages/Python/lldbsuite/builders/builder.py 
b/lldb/packages/Python/lldbsuite/builders/builder.py
new file mode 100644
index ..2b0873c37501
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/builders/builder.py
@@ -0,0 +1,240 @@
+import os
+import platform
+import subprocess
+import sys
+
+import lldbsuite.test.lldbtest as lldbtest
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test import configuration
+from lldbsuite.test_event import build_exception
+
+
+class Builder:
+def getArchitecture(self):
+"""Returns the architecture in effect the test suite is running 
with."""
+return configuration.arch if configuration.arch else ""
+
+def getCompiler(self):
+"""Returns the compiler in effect the test suite is running with."""
+compiler = configuration.compiler if configuration.compiler else 
"clang"
+compiler = lldbutil.which(compiler)
+return os.path.abspath(compiler)
+
+def getMake(self, test_subdir, test_name):
+"""Returns the invocation for GNU make.
+The first argument is a tuple of the relative path to the testcase
+and its filename stem."""
+if platform.system() == "FreeBSD" or platform.system() == "NetBSD":
+make = "gmake"
+else:
+make = "make"
+
+# Construct the base make invocation.
+lldb_test = os.environ["LLDB_TEST"]
+if not (lldb_test and configuration.test_build_dir and test_subdir
+and test_name and (not os.path.isabs(test_subdir))):
+raise Exception("Could not derive test directories")
+build_dir = os.path.join(configuration.test_build_dir, test_subdir,
+ test_name)
+src_dir = os.path.join(configuration.test_src_root, test_subdir)
+# This is a bit of a hack to make inline testcases work.
+makefile = os.path.join(src_dir, "Makefile")
+if not os.path.isfile(makefile):
+makefile = os.path.join(build_dir, "Makefile")
+return [
+make, "VPATH=" + src_dir, "-C", build_dir, "-I", src_dir, "-I",
+os.path.join(lldb_test, "make"), "-f", makefile
+]
+
+def getCmdLine(self, d):
+"""
+Helper function to return a properly formatted command line argument(s)
+string used for the make system.
+"""
+
+# If d is None or an empty mapping, just return an empty string.
+if not d:
+return ""
+pattern = '%s="%s"' if "win32" in sys.platform else "%s='%s'"
+
+def setOrAppendVariable(k, v):
+append_vars = ["CFLAGS", "CFLAGS_EXTRAS", "LD_EXTRAS"]
+if k in append_vars and k in os.environ:
+v = os.environ[k] + " " + v
+r

[Lldb-commits] [lldb] b623f3c - [lldb] Move builders under lldbsuite.test as they import lldbtest (NFC)

2020-08-19 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-08-19T09:07:51-07:00
New Revision: b623f3c0b41aee2984e54bf7a4909532faacc426

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

LOG: [lldb] Move builders under lldbsuite.test as they import lldbtest (NFC)

Added: 
lldb/packages/Python/lldbsuite/test/builders/__init__.py
lldb/packages/Python/lldbsuite/test/builders/builder.py
lldb/packages/Python/lldbsuite/test/builders/darwin.py

Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py

Removed: 
lldb/packages/Python/lldbsuite/builders/__init__.py
lldb/packages/Python/lldbsuite/builders/builder.py
lldb/packages/Python/lldbsuite/builders/darwin.py



diff  --git a/lldb/packages/Python/lldbsuite/builders/__init__.py 
b/lldb/packages/Python/lldbsuite/test/builders/__init__.py
similarity index 93%
rename from lldb/packages/Python/lldbsuite/builders/__init__.py
rename to lldb/packages/Python/lldbsuite/test/builders/__init__.py
index 0bfcd592031d..84024f291810 100644
--- a/lldb/packages/Python/lldbsuite/builders/__init__.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/__init__.py
@@ -5,12 +5,12 @@
 factory method below hands out builders based on the given platform.
 """
 
-from .builder import Builder
-
 
 def get_builder(platform):
   """Returns a Builder instance for the given platform."""
   if platform == 'darwin':
 from .darwin import BuilderDarwin
 return BuilderDarwin()
+
+  from .builder import Builder
   return Builder()

diff  --git a/lldb/packages/Python/lldbsuite/builders/builder.py 
b/lldb/packages/Python/lldbsuite/test/builders/builder.py
similarity index 100%
rename from lldb/packages/Python/lldbsuite/builders/builder.py
rename to lldb/packages/Python/lldbsuite/test/builders/builder.py

diff  --git a/lldb/packages/Python/lldbsuite/builders/darwin.py 
b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
similarity index 100%
rename from lldb/packages/Python/lldbsuite/builders/darwin.py
rename to lldb/packages/Python/lldbsuite/test/builders/darwin.py

diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 21e112a709c6..de9a9a2c7002 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -65,9 +65,9 @@
 from . import lldbtest_config
 from . import lldbutil
 from . import test_categories
-from lldbsuite.builders import get_builder
 from lldbsuite.support import encoded_file
 from lldbsuite.support import funcutils
+from lldbsuite.test.builders import get_builder
 
 # See also dotest.parseOptionsAndInitTestdirs(), where the environment 
variables
 # LLDB_COMMAND_TRACE is set from '-t' option.



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


[Lldb-commits] [PATCH] D86220: [lldb/Utility] Simplify Scalar handling of float types

2020-08-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/source/Utility/Scalar.cpp:68
+Scalar::PromotionKey Scalar::GetFloatPromoKey(const llvm::fltSemantics &sem) {
+  static const llvm::fltSemantics *order[] = {&APFloat::IEEEsingle(),
+  &APFloat::IEEEdouble(),

`std::array` or `ArrayRef` maybe?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86220

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


[Lldb-commits] [lldb] 804691a - [lldb] Fix buildDsym signature in Builder base class

2020-08-19 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-08-19T09:47:25-07:00
New Revision: 804691adc9c93eb2ac68baf531e1a6f8b6fdb0c1

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

LOG: [lldb] Fix buildDsym signature in Builder base class

The method was missing the optional argument `testname`.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/builders/builder.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py 
b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index 2b0873c37501..659e619e3d6a 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -231,7 +231,8 @@ def buildDsym(self,
   architecture=None,
   compiler=None,
   dictionary=None,
-  testdir=None):
+  testdir=None,
+  testname=None):
 # False signifies that we cannot handle building with dSYM.
 return False
 



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


[Lldb-commits] [lldb] 074c591 - [lldb] Add getExtraMakeArgs to Builder (NFC)

2020-08-19 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-08-19T09:47:25-07:00
New Revision: 074c591a7e9b366582dfc8dc127dd8df2ab1ac99

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

LOG: [lldb] Add getExtraMakeArgs to Builder (NFC)

Instead of a new method for each variable any subclass might want to
set, have a method getExtraMakeArgs that each subclass can use to return
whatever extra Make arguments it wants.

As per Pavel's suggestion in D85539.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/builders/builder.py
lldb/packages/Python/lldbsuite/test/builders/darwin.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py 
b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index 659e619e3d6a..160bafb95b56 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -20,6 +20,13 @@ def getCompiler(self):
 compiler = lldbutil.which(compiler)
 return os.path.abspath(compiler)
 
+def getExtraMakeArgs(self):
+"""
+Helper function to return extra argumentsfor the make system. This
+method is meant to be overridden by platform specific builders.
+"""
+return ""
+
 def getMake(self, test_subdir, test_name):
 """Returns the invocation for GNU make.
 The first argument is a tuple of the relative path to the testcase
@@ -101,15 +108,6 @@ def getCCSpec(self, compiler):
 else:
 return ""
 
-def getDsymutilSpec(self):
-"""
-Helper function to return the key-value string to specify the dsymutil
-used for the make system.
-"""
-if configuration.dsymutil:
-return "DSYMUTIL={}".format(configuration.dsymutil)
-return ""
-
 def getSDKRootSpec(self):
 """
 Helper function to return the key-value string to specify the SDK root
@@ -143,7 +141,7 @@ def buildDefault(self,
 "all",
 self.getArchSpec(architecture),
 self.getCCSpec(compiler),
-self.getDsymutilSpec(),
+self.getExtraMakeArgs(),
 self.getSDKRootSpec(),
 self.getModuleCacheSpec(),
 self.getCmdLine(dictionary)
@@ -168,7 +166,7 @@ def buildDwarf(self,
 "MAKE_DSYM=NO",
 self.getArchSpec(architecture),
 self.getCCSpec(compiler),
-self.getDsymutilSpec(),
+self.getExtraMakeArgs(),
 self.getSDKRootSpec(),
 self.getModuleCacheSpec(),
 self.getCmdLine(dictionary)
@@ -192,7 +190,7 @@ def buildDwo(self,
 "MAKE_DSYM=NO", "MAKE_DWO=YES",
 self.getArchSpec(architecture),
 self.getCCSpec(compiler),
-self.getDsymutilSpec(),
+self.getExtraMakeArgs(),
 self.getSDKRootSpec(),
 self.getModuleCacheSpec(),
 self.getCmdLine(dictionary)
@@ -216,7 +214,7 @@ def buildGModules(self,
 "MAKE_DSYM=NO", "MAKE_GMODULES=YES",
 self.getArchSpec(architecture),
 self.getCCSpec(compiler),
-self.getDsymutilSpec(),
+self.getExtraMakeArgs(),
 self.getSDKRootSpec(),
 self.getModuleCacheSpec(),
 self.getCmdLine(dictionary)

diff  --git a/lldb/packages/Python/lldbsuite/test/builders/darwin.py 
b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
index 826a3b491514..ce0aa0b13343 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/darwin.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
@@ -1,7 +1,24 @@
 from .builder import Builder
 
+from lldbsuite.test import configuration
+
 
 class BuilderDarwin(Builder):
+def getExtraMakeArgs(self):
+"""
+Helper function to return extra argumentsfor the make system. This
+method is meant to be overridden by platform specific builders.
+"""
+args = dict()
+
+if configuration.dsymutil:
+args['DSYMUTIL'] = configuration.dsymutil
+
+# Return extra args as a formatted string.
+return ' '.join(
+{'{}="{}"'.format(key, value)
+ for key, value in args.items()})
+
 def buildDsym(self,
   sender=None,
   architecture=None,
@@ -16,7 +33,7 @@ def buildDsym(self,
 "MAKE_DSYM=YES",
 self.getArchSpec(architecture),
 self.getCCSpec(compiler),
-self.getDsymutilSpec(),
+self.getExtraMakeArgs(),
 self.getSDKRootSpec(),
  

[Lldb-commits] [PATCH] D85988: Fix the ability to list iOS simulator processes.

2020-08-19 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

In D85988#616 , @clayborg wrote:

> Adrian: is there something I need to do to enable simulator tests? I added a 
> test to TestSimulatorPlatform.py but if I run:
>
>   $ ../debug/bin/llvm-lit -sv lldb/test/API/macosx/simulator
>   llvm-lit: 
> /Users/gclayton/Documents/src/lldb/mono/llvm-project/lldb/test/API/lit.cfg.py:147:
>  warning: Could not set a default per-test timeout. Requires the Python 
> psutil module but it could not be found. Try installing it via pip or via 
> your operating system's package manager.
>   
>   Testing Time: 19.61s
> Unsupported: 1
>   
>   1 warning(s) in tests
>
> It is unsupported? I am running this on a mac. Do I need to launch a 
> simulator first? Extra arguments to the test suite?

No, the tests are supposed to run. Green dragon (which is running a consumer 
macOS + consumer Xcode) is running this test. I know because it sometimes fails 
because it couldn't launch the simulator :-(
The test was XFAILed a few weeks ago — is your LLVM up-to-date?




Comment at: lldb/source/Host/macosx/objcxx/Host.mm:509
triple_arch == llvm::Triple::x86_64);
-  const char *cstr = data.GetCStr(&offset);
-  if (cstr) {
-process_info.GetExecutableFile().SetFile(cstr, 
FileSpec::Style::native);
+  llvm::StringRef str(data.GetCStr(&offset));
+  if (!str.empty()) {

data.GetCStringRef()?
http://llvm.org/doxygen/classllvm_1_1DataExtractor.html

Not sure if we surface that through the LLDB dataextractor, but we probably 
should.



Comment at: lldb/source/Host/macosx/objcxx/Host.mm:510
+  llvm::StringRef str(data.GetCStr(&offset));
+  if (!str.empty()) {
+process_info.GetExecutableFile().SetFile(str, FileSpec::Style::native);

```
if (str.empty())
   return false;
```



Comment at: lldb/source/Host/macosx/objcxx/Host.mm:528
   for (int i = 0; i < static_cast(argc); ++i) {
-cstr = data.GetCStr(&offset);
-if (cstr)
-  proc_args.AppendArgument(llvm::StringRef(cstr));
+str = data.GetCStr(&offset);
+if (!str.empty())

same here (GetCStringRef)
Perhaps also use a fresh variable to avoid confusion?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85988

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


[Lldb-commits] [PATCH] D86110: [WIP][DebugInfo] Lazily parse debug_loclist offsets

2020-08-19 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a comment.

In D86110#2225970 , @labath wrote:

> In D86110#2224163 , @dblaikie wrote:
>
>> In D86110#2223905 , @labath wrote:
>>
>>> This sounds perfectly reasonable to me. The offsets are present in memory 
>>> already so there's no point in storing them in a vector as well.
>>
>> Thanks for taking a look! I'll take this as approval and commit soon.
>
> The patch had a WIP label, so I was only looking/commenting on the high-level 
> idea. But after looking at the implementation more closely, I think that 
> looks good too.

Right right - sorry about that. Realized after I committed it it still had that 
tag & totally understand it gave the wrong impression. I think when I wrote the 
commit message I was still thinking about it, but by the time I sent it for 
review, tested more things, etc, I was more comfortable with it & didn't think 
to change the message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86110

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


[Lldb-commits] [PATCH] D86235: Fix swig scripts install target name

2020-08-19 Thread António Afonso via Phabricator via lldb-commits
aadsm created this revision.
aadsm added reviewers: JDevlieghere, wallace, clayborg.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.
aadsm requested review of this revision.

LLVM install component targets needs to be in the form of: 
install-{target}[-stripped]

I tested with:

  cmake ... -DLLVM_ENABLE_PROJECTS="clang;lldb" 
-DLLVM_DISTRIBUTION_COMPONENTS="lldb;liblldb;finish_swig_python_scripts" ...
  DESTDIR=... ninja install-distribution

@JDevlieghere `finish_swig_python_scripts` is a really weird name for a 
distribution component, any reason that it has to be this way?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86235

Files:
  lldb/bindings/python/CMakeLists.txt


Index: lldb/bindings/python/CMakeLists.txt
===
--- lldb/bindings/python/CMakeLists.txt
+++ lldb/bindings/python/CMakeLists.txt
@@ -164,7 +164,7 @@
 string(REPLACE ${CMAKE_CFG_INTDIR} "\$\{CMAKE_INSTALL_CONFIG_NAME\}" 
lldb_python_target_dir ${lldb_python_target_dir})
   endif()
   set(swig_scripts_target "${swig_target}_scripts")
-  set(swig_scripts_install_target "${swig_target}_scripts_install")
+  set(swig_scripts_install_target "install-${swig_scripts_target}")
   add_custom_target(${swig_scripts_target})
   add_dependencies(${swig_scripts_target} ${swig_target})
   install(DIRECTORY ${lldb_python_target_dir}/../


Index: lldb/bindings/python/CMakeLists.txt
===
--- lldb/bindings/python/CMakeLists.txt
+++ lldb/bindings/python/CMakeLists.txt
@@ -164,7 +164,7 @@
 string(REPLACE ${CMAKE_CFG_INTDIR} "\$\{CMAKE_INSTALL_CONFIG_NAME\}" lldb_python_target_dir ${lldb_python_target_dir})
   endif()
   set(swig_scripts_target "${swig_target}_scripts")
-  set(swig_scripts_install_target "${swig_target}_scripts_install")
+  set(swig_scripts_install_target "install-${swig_scripts_target}")
   add_custom_target(${swig_scripts_target})
   add_dependencies(${swig_scripts_target} ${swig_target})
   install(DIRECTORY ${lldb_python_target_dir}/../
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84974: Enable Launching the Debugee in VSCode Terminal

2020-08-19 Thread Yifan Shen via Phabricator via lldb-commits
aelitashen updated this revision to Diff 286620.
aelitashen added a comment.

Refactor code and optimize logic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84974

Files:
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -343,7 +343,7 @@
   char buffer[1024];
   size_t count;
   while ((count = process.GetSTDOUT(buffer, sizeof(buffer))) > 0)
-  g_vsc.SendOutput(OutputType::Stdout, llvm::StringRef(buffer, count));
+g_vsc.SendOutput(OutputType::Stdout, llvm::StringRef(buffer, count));
   while ((count = process.GetSTDERR(buffer, sizeof(buffer))) > 0)
 g_vsc.SendOutput(OutputType::Stderr, llvm::StringRef(buffer, count));
 }
@@ -448,10 +448,10 @@
 if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded) {
   body.try_emplace("reason", "new");
 } else if (event_mask &
-lldb::SBTarget::eBroadcastBitModulesUnloaded) {
+   lldb::SBTarget::eBroadcastBitModulesUnloaded) {
   body.try_emplace("reason", "removed");
 } else if (event_mask &
-lldb::SBTarget::eBroadcastBitSymbolsLoaded) {
+   lldb::SBTarget::eBroadcastBitSymbolsLoaded) {
   body.try_emplace("reason", "changed");
 }
 body.try_emplace("module", module_value);
@@ -873,7 +873,9 @@
 // "CompletionsRequest": {
 //   "allOf": [ { "$ref": "#/definitions/Request" }, {
 // "type": "object",
-// "description": "Returns a list of possible completions for a given caret position and text.\nThe CompletionsRequest may only be called if the 'supportsCompletionsRequest' capability exists and is true.",
+// "description": "Returns a list of possible completions for a given caret
+// position and text.\nThe CompletionsRequest may only be called if the
+// 'supportsCompletionsRequest' capability exists and is true.",
 // "properties": {
 //   "command": {
 // "type": "string",
@@ -892,19 +894,23 @@
 //   "properties": {
 // "frameId": {
 //   "type": "integer",
-//   "description": "Returns completions in the scope of this stack frame. If not specified, the completions are returned for the global scope."
+//   "description": "Returns completions in the scope of this stack frame.
+//   If not specified, the completions are returned for the global scope."
 // },
 // "text": {
 //   "type": "string",
-//   "description": "One or more source lines. Typically this is the text a user has typed into the debug console before he asked for completion."
+//   "description": "One or more source lines. Typically this is the text a
+//   user has typed into the debug console before he asked for completion."
 // },
 // "column": {
 //   "type": "integer",
-//   "description": "The character position for which to determine the completion proposals."
+//   "description": "The character position for which to determine the
+//   completion proposals."
 // },
 // "line": {
 //   "type": "integer",
-//   "description": "An optional line for which to determine the completion proposals. If missing the first line of the text is assumed."
+//   "description": "An optional line for which to determine the completion
+//   proposals. If missing the first line of the text is assumed."
 // }
 //   },
 //   "required": [ "text", "column" ]
@@ -933,39 +939,51 @@
 // },
 // "CompletionItem": {
 //   "type": "object",
-//   "description": "CompletionItems are the suggestions returned from the CompletionsRequest.",
-//   "properties": {
+//   "description": "CompletionItems are the suggestions returned from the
+//   CompletionsRequest.", "properties": {
 // "label": {
 //   "type": "string",
-//   "description": "The label of this completion item. By default this is also the text that is inserted when selecting this completion."
+//   "description": "The label of this completion item. By default this is
+//   also the text that is inserted when selecting this completion."
 // },
 // "text": {
 //   "type": "string",
-//   "description": "If text is not falsy then it is inserted instead of the label."
+//   "description": "If text is not falsy then it is inserted instead of the
+//   label."
 // },
 // "sortText": {
 //   "type": "string",
-//   "description": "A string that should be used when comparing this item with other items. When `falsy` the label is used."
+//   "description": "A string that should be used when comparing this item
+//   with other items. When `falsy` 

[Lldb-commits] [PATCH] D84974: Enable Launching the Debugee in VSCode Terminal

2020-08-19 Thread Yifan Shen via Phabricator via lldb-commits
aelitashen added a comment.

I tried rebase onto the commit that Walter created just for formatting but I am 
not sure why it didn't remove those formatting noise..




Comment at: lldb/tools/lldb-vscode/VSCode.cpp:410
+
+VSCode::PacketStatus VSCode::SendReverseRequest(llvm::json::Object &request,
+llvm::json::Object &response) {

clayborg wrote:
> clayborg wrote:
> > clayborg wrote:
> > > add "const" to before "llvm::json::Object &request"
> > I see we are modifying "request" below, so we can't make it "const". There 
> > are two ways to fix this:
> > 1 - change it to be "llvm::json::Object request" and then use std::move() 
> > when calling SendReverseRequest. 
> > 2 - just leave as a reference and modify the original object.
> > 
> > I think I prefer option #1.
> Or we can leave this as "const" as originally suggested and add a function to 
> VSCode:
> 
> ```
> llvm::json::Object VSCode::CreateReverseRequest(std::string command) {
>   llvm::json::Object request;
>   request.try_emplace("type", "request");
>   request.try_emplace("command", command);
>   request.try_emplace("seq", ++reverse_request_seq);
>   return request;
> }
> 
> ```
> And call that in request_runInTerminal when creating the reverse request 
> packet. See other inline comment for details.
I eventually choose #1 cuz const keeps raising problem when calling function 
like try_emplace() and move() :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84974

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


[Lldb-commits] [PATCH] D86235: Fix swig scripts install target name

2020-08-19 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.

No reason other than consistency by always appending to the given target. I 
didn't think of the requirement for the `install-`prefix. LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86235

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


[Lldb-commits] [PATCH] D84974: Enable Launching the Debugee in VSCode Terminal

2020-08-19 Thread Greg Clayton via Phabricator via lldb-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

All of the code looks good now and we need to add a test. This means we will 
need to modify vscode.py in the test suite to be able to received the reverse 
request and just launch the process. We don't need to launch the program in a 
terminal, just spawn the process using subprocess.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84974

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


[Lldb-commits] [PATCH] D85539: [lldb] Extend builder to pass the TRIPLE spec to Make

2020-08-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe5d08fcbac72: [lldb] Extend Darwin builder to pass the 
ARCH_CFLAGS spec to Make. (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D85539?vs=286455&id=286623#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85539

Files:
  lldb/packages/Python/lldbsuite/test/builders/builder.py
  lldb/packages/Python/lldbsuite/test/builders/darwin.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -94,65 +94,6 @@
 # from the triple alone
 #--
 ARCH_CFLAGS :=
-ifneq "$(TRIPLE)" ""
-	triple_space = $(subst -, ,$(TRIPLE))
-	ARCH =$(word 1, $(triple_space))
-	TRIPLE_VENDOR =$(word 2, $(triple_space))
-	triple_os_and_version =$(shell echo $(word 3, $(triple_space)) | sed 's/\([a-z]*\)\(.*\)/\1 \2/')
-	TRIPLE_OS =$(word 1, $(triple_os_and_version))
-	TRIPLE_VERSION =$(word 2, $(triple_os_and_version))
-	TRIPLE_ENV =$(word 4, $(triple_space))
-	ifeq "$(TRIPLE_VENDOR)" "apple"
-		ifeq "$(TRIPLE_OS)" "ios"
-			ifeq "$(TRIPLE_ENV)" "simulator"
-SDK_NAME := iphonesimulator
-			else
-			ifeq "$(TRIPLE_ENV)" "macabi"
-SDK_NAME := macosx
-			else
-SDK_NAME := iphoneos
-			endif
-			endif
-		endif
-		ifeq "$(TRIPLE_OS)" "tvos"
-			ifeq "$(TRIPLE_ENV)" "simulator"
-SDK_NAME := appletvsimulator
-			else
-SDK_NAME := appletvos
-			endif
-		endif
-		ifeq "$(TRIPLE_OS)" "watchos"
-			ifeq "$(TRIPLE_ENV)" "simulator"
-SDK_NAME := watchsimulator
-			else
-SDK_NAME := watchos
-			endif
-		endif
-		ifneq "$(TRIPLE_OS)" "macosx"
-			ifeq "$(TRIPLE_ENV)" ""
-CODESIGN := codesign
-			endif
-		endif
-
-		ifeq "$(SDKROOT)" ""
-			SDKROOT := $(shell xcrun --sdk $(SDK_NAME) --show-sdk-path)
-		endif
-		ifeq "$(TRIPLE_VERSION)" ""
-			ifeq "$(SDK_NAME)" ""
-   $(error "SDK_NAME is empty")
-			endif
-			TRIPLE_VERSION := $(shell xcrun --sdk $(SDK_NAME) --show-sdk-version)
-		endif
-		ifeq "$(TRIPLE_ENV)" "simulator"
-			ARCH_CFLAGS := -m$(TRIPLE_OS)-simulator-version-min=$(TRIPLE_VERSION)
-		else
-		ifneq "$(TRIPLE_OS)" "macosx"
-			ARCH_CFLAGS := -m$(TRIPLE_OS)-version-min=$(TRIPLE_VERSION)
-		endif
-		endif
-	endif
-	ARCH_CFLAGS += -target $(TRIPLE)
-endif
 ifeq "$(OS)" "Android"
 	include $(THIS_FILE_DIR)/Android.rules
 endif
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -766,15 +766,6 @@
 return ver
 
 
-def setDefaultTripleForPlatform():
-if configuration.lldb_platform_name == 'ios-simulator':
-triple_str = 'x86_64-apple-ios%s' % (
-getVersionForSDK('iphonesimulator'))
-os.environ['TRIPLE'] = triple_str
-return {'TRIPLE': triple_str}
-return {}
-
-
 def checkCompiler():
 # Add some intervention here to sanity check that the compiler requested is sane.
 # If found not to be an executable program, we abort.
@@ -947,14 +938,6 @@
 else:
 configuration.lldb_platform_url = None
 
-platform_changes = setDefaultTripleForPlatform()
-first = True
-for key in platform_changes:
-if first:
-print("Environment variables setup for platform support:")
-first = False
-print("%s = %s" % (key, platform_changes[key]))
-
 if configuration.lldb_platform_working_dir:
 print("Setting remote platform working directory to '%s'..." %
   (configuration.lldb_platform_working_dir))
Index: lldb/packages/Python/lldbsuite/test/builders/darwin.py
===
--- lldb/packages/Python/lldbsuite/test/builders/darwin.py
+++ lldb/packages/Python/lldbsuite/test/builders/darwin.py
@@ -1,4 +1,43 @@
+import re
+import subprocess
+
 from .builder import Builder
+from lldbsuite.test import configuration
+
+REMOTE_PLATFORM_NAME_RE = re.compile(r"^remote-(.+)$")
+SIMULATOR_PLATFORM_RE = re.compile(r"^(.+)-simulator$")
+
+
+def get_sdk(os, env):
+if os == "ios":
+if env == "simulator":
+return "iphonesimulator"
+if env == "macabi":
+return "macosx"
+return "iphoneos"
+elif os == "tvos":
+if env == "simulator":
+return "appletvsimulator"
+return "appletvos"
+elif os == "watchos":
+if env == "simulator":
+return "watchsimulator"
+return 

[Lldb-commits] [lldb] e5d08fc - [lldb] Extend Darwin builder to pass the ARCH_CFLAGS spec to Make.

2020-08-19 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-08-19T11:47:29-07:00
New Revision: e5d08fcbac722d487973d9c96838c0589f1953c3

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

LOG: [lldb] Extend Darwin builder to pass the ARCH_CFLAGS spec to Make.

Construct the ARCH_CFLAGS in Python rather than in Make by disassembling
the TRIPLE.

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

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/builders/builder.py
lldb/packages/Python/lldbsuite/test/builders/darwin.py
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py 
b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index 160bafb95b56a..4a8985104874c 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -25,6 +25,9 @@ def getExtraMakeArgs(self):
 Helper function to return extra argumentsfor the make system. This
 method is meant to be overridden by platform specific builders.
 """
+
+def getArchCFlags(self, architecture):
+"""Returns the ARCH_CFLAGS for the make system."""
 return ""
 
 def getMake(self, test_subdir, test_name):
@@ -139,6 +142,7 @@ def buildDefault(self,
 commands.append(
 self.getMake(testdir, testname) + [
 "all",
+self.getArchCFlags(architecture),
 self.getArchSpec(architecture),
 self.getCCSpec(compiler),
 self.getExtraMakeArgs(),
@@ -164,6 +168,7 @@ def buildDwarf(self,
 commands.append(
 self.getMake(testdir, testname) + [
 "MAKE_DSYM=NO",
+self.getArchCFlags(architecture),
 self.getArchSpec(architecture),
 self.getCCSpec(compiler),
 self.getExtraMakeArgs(),
@@ -188,6 +193,7 @@ def buildDwo(self,
 commands.append(
 self.getMake(testdir, testname) + [
 "MAKE_DSYM=NO", "MAKE_DWO=YES",
+self.getArchCFlags(architecture),
 self.getArchSpec(architecture),
 self.getCCSpec(compiler),
 self.getExtraMakeArgs(),
@@ -212,6 +218,7 @@ def buildGModules(self,
 commands.append(
 self.getMake(testdir, testname) + [
 "MAKE_DSYM=NO", "MAKE_GMODULES=YES",
+self.getArchCFlags(architecture),
 self.getArchSpec(architecture),
 self.getCCSpec(compiler),
 self.getExtraMakeArgs(),

diff  --git a/lldb/packages/Python/lldbsuite/test/builders/darwin.py 
b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
index ce0aa0b13343e..704897d4a5f65 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/darwin.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
@@ -1,4 +1,43 @@
+import re
+import subprocess
+
 from .builder import Builder
+from lldbsuite.test import configuration
+
+REMOTE_PLATFORM_NAME_RE = re.compile(r"^remote-(.+)$")
+SIMULATOR_PLATFORM_RE = re.compile(r"^(.+)-simulator$")
+
+
+def get_sdk(os, env):
+if os == "ios":
+if env == "simulator":
+return "iphonesimulator"
+if env == "macabi":
+return "macosx"
+return "iphoneos"
+elif os == "tvos":
+if env == "simulator":
+return "appletvsimulator"
+return "appletvos"
+elif os == "watchos":
+if env == "simulator":
+return "watchsimulator"
+return "watchos"
+return os
+
+
+def get_os_env_from_platform(platform):
+match = REMOTE_PLATFORM_NAME_RE.match(platform)
+if match:
+return match.group(1), ""
+match = SIMULATOR_PLATFORM_RE.match(platform)
+if match:
+return match.group(1), "simulator"
+return None, None
+
+
+def get_os_from_sdk(sdk):
+return sdk[:sdk.find('.')], ""
 
 from lldbsuite.test import configuration
 
@@ -14,10 +53,62 @@ def getExtraMakeArgs(self):
 if configuration.dsymutil:
 args['DSYMUTIL'] = configuration.dsymutil
 
+os, _ = self.getOsAndEnv()
+if os and os != "macosx":
+args['CODESIGN'] = 'codesign'
+
 # Return extra args as a formatted string.
 return ' '.join(
 {'{}="{}"'.format(key, value)
  for key, value in args.items()})
+def getOsAndEnv(self):
+if configuration.lldb_platform_name:
+return get_os_env_from_platform(configuration.lldb_platform_name)
+elif configuration.apple_sdk:
+return get_os_from_sdk(configuration.apple_sdk)
+return Non

[Lldb-commits] [PATCH] D86237: [lldb] Code sign binaries with entitlements

2020-08-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: jasonmolenda.
JDevlieghere requested review of this revision.

Binaries need to be code signed to run on device.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D86237

Files:
  lldb/packages/Python/lldbsuite/test/builders/darwin.py
  lldb/packages/Python/lldbsuite/test/make/entitlements.plist


Index: lldb/packages/Python/lldbsuite/test/make/entitlements.plist
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/make/entitlements.plist
@@ -0,0 +1,10 @@
+
+http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
+
+
+com.apple.security.get-task-allow
+
+com.apple.private.security.no-sandbox
+
+
+
Index: lldb/packages/Python/lldbsuite/test/builders/darwin.py
===
--- lldb/packages/Python/lldbsuite/test/builders/darwin.py
+++ lldb/packages/Python/lldbsuite/test/builders/darwin.py
@@ -1,4 +1,5 @@
 import re
+import os
 import subprocess
 
 from .builder import Builder
@@ -53,9 +54,12 @@
 if configuration.dsymutil:
 args['DSYMUTIL'] = configuration.dsymutil
 
-os, _ = self.getOsAndEnv()
-if os and os != "macosx":
-args['CODESIGN'] = 'codesign'
+operating_system, _ = self.getOsAndEnv()
+if operating_system and operating_system != "macosx":
+builder_dir = os.path.dirname(os.path.abspath(__file__))
+test_dir = os.path.dirname(builder_dir)
+entitlements = os.path.join(test_dir, 'make', 'entitlements.plist')
+args['CODESIGN'] = 'codesign --entitlements 
{}'.format(entitlements)
 
 # Return extra args as a formatted string.
 return ' '.join(


Index: lldb/packages/Python/lldbsuite/test/make/entitlements.plist
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/make/entitlements.plist
@@ -0,0 +1,10 @@
+
+http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
+
+
+com.apple.security.get-task-allow
+
+com.apple.private.security.no-sandbox
+
+
+
Index: lldb/packages/Python/lldbsuite/test/builders/darwin.py
===
--- lldb/packages/Python/lldbsuite/test/builders/darwin.py
+++ lldb/packages/Python/lldbsuite/test/builders/darwin.py
@@ -1,4 +1,5 @@
 import re
+import os
 import subprocess
 
 from .builder import Builder
@@ -53,9 +54,12 @@
 if configuration.dsymutil:
 args['DSYMUTIL'] = configuration.dsymutil
 
-os, _ = self.getOsAndEnv()
-if os and os != "macosx":
-args['CODESIGN'] = 'codesign'
+operating_system, _ = self.getOsAndEnv()
+if operating_system and operating_system != "macosx":
+builder_dir = os.path.dirname(os.path.abspath(__file__))
+test_dir = os.path.dirname(builder_dir)
+entitlements = os.path.join(test_dir, 'make', 'entitlements.plist')
+args['CODESIGN'] = 'codesign --entitlements {}'.format(entitlements)
 
 # Return extra args as a formatted string.
 return ' '.join(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D86237: [lldb] Code sign binaries with entitlements

2020-08-19 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D86237

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


[Lldb-commits] [PATCH] D86237: [lldb] Code sign binaries with entitlements

2020-08-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb40a3814b6fd: [lldb] Code sign binaries with entitlements 
(authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86237

Files:
  lldb/packages/Python/lldbsuite/test/builders/darwin.py
  lldb/packages/Python/lldbsuite/test/make/entitlements.plist


Index: lldb/packages/Python/lldbsuite/test/make/entitlements.plist
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/make/entitlements.plist
@@ -0,0 +1,10 @@
+
+http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
+
+
+com.apple.security.get-task-allow
+
+com.apple.private.security.no-sandbox
+
+
+
Index: lldb/packages/Python/lldbsuite/test/builders/darwin.py
===
--- lldb/packages/Python/lldbsuite/test/builders/darwin.py
+++ lldb/packages/Python/lldbsuite/test/builders/darwin.py
@@ -1,4 +1,5 @@
 import re
+import os
 import subprocess
 
 from .builder import Builder
@@ -53,9 +54,12 @@
 if configuration.dsymutil:
 args['DSYMUTIL'] = configuration.dsymutil
 
-os, _ = self.getOsAndEnv()
-if os and os != "macosx":
-args['CODESIGN'] = 'codesign'
+operating_system, _ = self.getOsAndEnv()
+if operating_system and operating_system != "macosx":
+builder_dir = os.path.dirname(os.path.abspath(__file__))
+test_dir = os.path.dirname(builder_dir)
+entitlements = os.path.join(test_dir, 'make', 'entitlements.plist')
+args['CODESIGN'] = 'codesign --entitlements 
{}'.format(entitlements)
 
 # Return extra args as a formatted string.
 return ' '.join(


Index: lldb/packages/Python/lldbsuite/test/make/entitlements.plist
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/make/entitlements.plist
@@ -0,0 +1,10 @@
+
+http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
+
+
+com.apple.security.get-task-allow
+
+com.apple.private.security.no-sandbox
+
+
+
Index: lldb/packages/Python/lldbsuite/test/builders/darwin.py
===
--- lldb/packages/Python/lldbsuite/test/builders/darwin.py
+++ lldb/packages/Python/lldbsuite/test/builders/darwin.py
@@ -1,4 +1,5 @@
 import re
+import os
 import subprocess
 
 from .builder import Builder
@@ -53,9 +54,12 @@
 if configuration.dsymutil:
 args['DSYMUTIL'] = configuration.dsymutil
 
-os, _ = self.getOsAndEnv()
-if os and os != "macosx":
-args['CODESIGN'] = 'codesign'
+operating_system, _ = self.getOsAndEnv()
+if operating_system and operating_system != "macosx":
+builder_dir = os.path.dirname(os.path.abspath(__file__))
+test_dir = os.path.dirname(builder_dir)
+entitlements = os.path.join(test_dir, 'make', 'entitlements.plist')
+args['CODESIGN'] = 'codesign --entitlements {}'.format(entitlements)
 
 # Return extra args as a formatted string.
 return ' '.join(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] b40a381 - [lldb] Code sign binaries with entitlements

2020-08-19 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-08-19T11:55:36-07:00
New Revision: b40a3814b6fd0c784b52622eddac56d7c321d7cc

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

LOG: [lldb] Code sign binaries with entitlements

Binaries need to be code signed with entitlements to run on device.

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

Added: 
lldb/packages/Python/lldbsuite/test/make/entitlements.plist

Modified: 
lldb/packages/Python/lldbsuite/test/builders/darwin.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/builders/darwin.py 
b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
index 704897d4a5f6..470ea5d01db2 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/darwin.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
@@ -1,4 +1,5 @@
 import re
+import os
 import subprocess
 
 from .builder import Builder
@@ -53,9 +54,12 @@ def getExtraMakeArgs(self):
 if configuration.dsymutil:
 args['DSYMUTIL'] = configuration.dsymutil
 
-os, _ = self.getOsAndEnv()
-if os and os != "macosx":
-args['CODESIGN'] = 'codesign'
+operating_system, _ = self.getOsAndEnv()
+if operating_system and operating_system != "macosx":
+builder_dir = os.path.dirname(os.path.abspath(__file__))
+test_dir = os.path.dirname(builder_dir)
+entitlements = os.path.join(test_dir, 'make', 'entitlements.plist')
+args['CODESIGN'] = 'codesign --entitlements 
{}'.format(entitlements)
 
 # Return extra args as a formatted string.
 return ' '.join(

diff  --git a/lldb/packages/Python/lldbsuite/test/make/entitlements.plist 
b/lldb/packages/Python/lldbsuite/test/make/entitlements.plist
new file mode 100644
index ..3c009ffaa59c
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/make/entitlements.plist
@@ -0,0 +1,10 @@
+
+http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
+
+
+com.apple.security.get-task-allow
+
+com.apple.private.security.no-sandbox
+
+
+



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


[Lldb-commits] [PATCH] D85988: Fix the ability to list iOS simulator processes.

2020-08-19 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In D85988#2226496 , @aprantl wrote:

> In D85988#616 , @clayborg wrote:
>
>> Adrian: is there something I need to do to enable simulator tests? I added a 
>> test to TestSimulatorPlatform.py but if I run:
>>
>>   $ ../debug/bin/llvm-lit -sv lldb/test/API/macosx/simulator
>>   llvm-lit: 
>> /Users/gclayton/Documents/src/lldb/mono/llvm-project/lldb/test/API/lit.cfg.py:147:
>>  warning: Could not set a default per-test timeout. Requires the Python 
>> psutil module but it could not be found. Try installing it via pip or via 
>> your operating system's package manager.
>>   
>>   Testing Time: 19.61s
>> Unsupported: 1
>>   
>>   1 warning(s) in tests
>>
>> It is unsupported? I am running this on a mac. Do I need to launch a 
>> simulator first? Extra arguments to the test suite?
>
> No, the tests are supposed to run. Green dragon (which is running a consumer 
> macOS + consumer Xcode) is running this test. I know because it sometimes 
> fails because it couldn't launch the simulator :-(
> The test was XFAILed a few weeks ago — is your LLVM up-to-date?

It was up to date. Can you run my invocation on your lldb?:

  ../debug/bin/llvm-lit -sv lldb/test/API/macosx/simulator


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85988

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


[Lldb-commits] [lldb] 9f5210a - [lldb] Print the load command that wasn't found in TestSimulatorPlatform

2020-08-19 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-08-19T12:42:59-07:00
New Revision: 9f5210aacfec8602beb60f309389e2261b4d3c75

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

LOG: [lldb] Print the load command that wasn't found in TestSimulatorPlatform

Print which load command we were looking for when the sanity check
fails:

  AssertionError: 0 != 1 : wrong number of load commands for
  LC_VERSION_MIN_MACOSX

Added: 


Modified: 
lldb/test/API/macosx/simulator/TestSimulatorPlatform.py

Removed: 




diff  --git a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py 
b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
index 9fd542d2f667..4c3a86531c8f 100644
--- a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -21,7 +21,10 @@ def check_load_commands(self, expected_load_command):
 for line in load_cmds.split('\n'):
 if expected_load_command in line:
   found += 1
-self.assertEquals(found, 1, "wrong load command")
+self.assertEquals(
+found, 1, "wrong number of load commands for {}".format(
+expected_load_command))
+
 
 def check_debugserver(self, log, expected_platform, expected_version):
 """scan the debugserver packet log"""



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


[Lldb-commits] [PATCH] D85988: Fix the ability to list iOS simulator processes.

2020-08-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D85988#2226889 , @clayborg wrote:

> In D85988#2226496 , @aprantl wrote:
>
>> In D85988#616 , @clayborg wrote:
>>
>>> Adrian: is there something I need to do to enable simulator tests? I added 
>>> a test to TestSimulatorPlatform.py but if I run:
>>>
>>>   $ ../debug/bin/llvm-lit -sv lldb/test/API/macosx/simulator
>>>   llvm-lit: 
>>> /Users/gclayton/Documents/src/lldb/mono/llvm-project/lldb/test/API/lit.cfg.py:147:
>>>  warning: Could not set a default per-test timeout. Requires the Python 
>>> psutil module but it could not be found. Try installing it via pip or via 
>>> your operating system's package manager.
>>>   
>>>   Testing Time: 19.61s
>>> Unsupported: 1
>>>   
>>>   1 warning(s) in tests
>>>
>>> It is unsupported? I am running this on a mac. Do I need to launch a 
>>> simulator first? Extra arguments to the test suite?
>>
>> No, the tests are supposed to run. Green dragon (which is running a consumer 
>> macOS + consumer Xcode) is running this test. I know because it sometimes 
>> fails because it couldn't launch the simulator :-(
>> The test was XFAILed a few weeks ago — is your LLVM up-to-date?
>
> It was up to date. Can you run my invocation on your lldb?:
>
>   ../debug/bin/llvm-lit -sv lldb/test/API/macosx/simulator

That works for me, but it looks like you're using the standalone/Xcode build, 
so maybe that's borked somehow :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85988

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


[Lldb-commits] [PATCH] D85988: Fix the ability to list iOS simulator processes.

2020-08-19 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In D85988#2226911 , @JDevlieghere 
wrote:

> In D85988#2226889 , @clayborg wrote:
>
>> In D85988#2226496 , @aprantl wrote:
>>
>>> In D85988#616 , @clayborg 
>>> wrote:
>>>
 Adrian: is there something I need to do to enable simulator tests? I added 
 a test to TestSimulatorPlatform.py but if I run:

   $ ../debug/bin/llvm-lit -sv lldb/test/API/macosx/simulator
   llvm-lit: 
 /Users/gclayton/Documents/src/lldb/mono/llvm-project/lldb/test/API/lit.cfg.py:147:
  warning: Could not set a default per-test timeout. Requires the Python 
 psutil module but it could not be found. Try installing it via pip or via 
 your operating system's package manager.
   
   Testing Time: 19.61s
 Unsupported: 1
   
   1 warning(s) in tests

 It is unsupported? I am running this on a mac. Do I need to launch a 
 simulator first? Extra arguments to the test suite?
>>>
>>> No, the tests are supposed to run. Green dragon (which is running a 
>>> consumer macOS + consumer Xcode) is running this test. I know because it 
>>> sometimes fails because it couldn't launch the simulator :-(
>>> The test was XFAILed a few weeks ago — is your LLVM up-to-date?
>>
>> It was up to date. Can you run my invocation on your lldb?:
>>
>>   ../debug/bin/llvm-lit -sv lldb/test/API/macosx/simulator
>
> That works for me, but it looks like you're using the standalone/Xcode build, 
> so maybe that's borked somehow :(

I am using the mono-repo build with cmake + ninja.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85988

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


[Lldb-commits] [PATCH] D86242: [lldb/interpreter] Add REPL-specific init file.

2020-08-19 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added reviewers: JDevlieghere, jingham.
mib added a project: LLDB.
Herald added a subscriber: lldb-commits.
mib requested review of this revision.

This patch adds the infrostructure to add language specific REPL init
files. It's the foundation work to a following patch that will Swift REPL
init file.

When lldb is launched with the `--repl` option, it will look for a REPL
init file in the home directory and source it. This overrides the
default `~/.lldbinit`, which content might make the REPL behave
unexpectedly. If the REPL init file doesn't exists, lldb will fall back
to the default init file.

rdar://65836048

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86242

Files:
  lldb/docs/man/lldb.rst
  lldb/include/lldb/API/SBCommandInterpreter.h
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/source/API/SBDebugger.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/tools/driver/Driver.cpp

Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -493,7 +493,7 @@
   // Before we handle any options from the command line, we parse the
   // .lldbinit file in the user's home directory.
   SBCommandReturnObject result;
-  sb_interpreter.SourceInitFileInHomeDirectory(result);
+  sb_interpreter.SourceInitFileInHomeDirectory(result, m_option_data.m_repl);
   if (m_option_data.m_debug_mode) {
 result.PutError(m_debugger.GetErrorFile());
 result.PutOutput(m_debugger.GetOutputFile());
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2090,6 +2090,22 @@
   FileSystem::Instance().Resolve(init_file);
 }
 
+static void GetHomeREPLInitFile(llvm::SmallVectorImpl &init_file,
+LanguageType language) {
+  std::string init_file_name;
+
+  switch (language) {
+  // TODO: Add support for a language used with a REPL.
+  default:
+return;
+  }
+
+  llvm::sys::path::home_directory(init_file);
+  llvm::sys::path::append(init_file, init_file_name);
+
+  FileSystem::Instance().Resolve(init_file);
+}
+
 static void GetCwdInitFile(llvm::SmallVectorImpl &init_file) {
   llvm::StringRef s = ".lldbinit";
   init_file.assign(s.begin(), s.end());
@@ -2164,15 +2180,27 @@
 
 /// We will first see if there is an application specific ".lldbinit" file
 /// whose name is "~/.lldbinit" followed by a "-" and the name of the program.
-/// If this file doesn't exist, we fall back to just the "~/.lldbinit" file.
-void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result) {
+/// If this file doesn't exist, we fall back to the REPL init file for the
+/// default home init file in "~/.lldbinit".
+void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result,
+bool repl_enabled) {
   if (m_skip_lldbinit_files) {
 result.SetStatus(eReturnStatusSuccessFinishNoResult);
 return;
   }
 
   llvm::SmallString<128> init_file;
-  GetHomeInitFile(init_file);
+
+  if (repl_enabled) {
+LanguageType language = {};
+TargetSP target_sp = GetDebugger().GetSelectedTarget();
+if (target_sp)
+  language = target_sp->GetLanguage();
+GetHomeREPLInitFile(init_file, language);
+  }
+
+  if (init_file.empty())
+GetHomeInitFile(init_file);
 
   if (!m_skip_app_init_files) {
 llvm::StringRef program_name =
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -220,7 +220,7 @@
 interp.get()->SkipLLDBInitFiles(false);
 interp.get()->SkipAppInitFiles(false);
 SBCommandReturnObject result;
-interp.SourceInitFileInHomeDirectory(result);
+interp.SourceInitFileInHomeDirectory(result, false);
   } else {
 interp.get()->SkipLLDBInitFiles(true);
 interp.get()->SkipAppInitFiles(true);
Index: lldb/source/API/SBCommandInterpreter.cpp
===
--- lldb/source/API/SBCommandInterpreter.cpp
+++ lldb/source/API/SBCommandInterpreter.cpp
@@ -478,6 +478,25 @@
   }
 }
 
+void SBCommandInterpreter::SourceInitFileInHomeDirectory(
+SBCommandReturnObject &result, bool repl_enabled) {
+  LLDB_RECORD_METHOD(void, SBCommandInterpreter, SourceInitFileInHomeDirectory,
+ (lldb::SBCommandReturnObject &, bool), result,
+ repl_enabled);
+
+  result.Clear();
+  if (IsValid()) {
+TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
+std::unique_lock lock;
+if (target_sp)
+  lock = std::unique_lock(target_sp->GetAPIMutex());
+m_opaque_ptr->SourceInitFile

[Lldb-commits] [PATCH] D86242: [lldb/interpreter] Add REPL-specific init file.

2020-08-19 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 286648.
mib added a comment.

Fixed typo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86242

Files:
  lldb/docs/man/lldb.rst
  lldb/include/lldb/API/SBCommandInterpreter.h
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/source/API/SBDebugger.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/tools/driver/Driver.cpp

Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -493,7 +493,7 @@
   // Before we handle any options from the command line, we parse the
   // .lldbinit file in the user's home directory.
   SBCommandReturnObject result;
-  sb_interpreter.SourceInitFileInHomeDirectory(result);
+  sb_interpreter.SourceInitFileInHomeDirectory(result, m_option_data.m_repl);
   if (m_option_data.m_debug_mode) {
 result.PutError(m_debugger.GetErrorFile());
 result.PutOutput(m_debugger.GetOutputFile());
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2090,6 +2090,22 @@
   FileSystem::Instance().Resolve(init_file);
 }
 
+static void GetHomeREPLInitFile(llvm::SmallVectorImpl &init_file,
+LanguageType language) {
+  std::string init_file_name;
+
+  switch (language) {
+  // TODO: Add support for a language used with a REPL.
+  default:
+return;
+  }
+
+  llvm::sys::path::home_directory(init_file);
+  llvm::sys::path::append(init_file, init_file_name);
+
+  FileSystem::Instance().Resolve(init_file);
+}
+
 static void GetCwdInitFile(llvm::SmallVectorImpl &init_file) {
   llvm::StringRef s = ".lldbinit";
   init_file.assign(s.begin(), s.end());
@@ -2164,15 +2180,27 @@
 
 /// We will first see if there is an application specific ".lldbinit" file
 /// whose name is "~/.lldbinit" followed by a "-" and the name of the program.
-/// If this file doesn't exist, we fall back to just the "~/.lldbinit" file.
-void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result) {
+/// If this file doesn't exist, we fall back to the REPL init file or the
+/// default home init file in "~/.lldbinit".
+void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result,
+bool repl_enabled) {
   if (m_skip_lldbinit_files) {
 result.SetStatus(eReturnStatusSuccessFinishNoResult);
 return;
   }
 
   llvm::SmallString<128> init_file;
-  GetHomeInitFile(init_file);
+
+  if (repl_enabled) {
+LanguageType language = {};
+TargetSP target_sp = GetDebugger().GetSelectedTarget();
+if (target_sp)
+  language = target_sp->GetLanguage();
+GetHomeREPLInitFile(init_file, language);
+  }
+
+  if (init_file.empty())
+GetHomeInitFile(init_file);
 
   if (!m_skip_app_init_files) {
 llvm::StringRef program_name =
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -220,7 +220,7 @@
 interp.get()->SkipLLDBInitFiles(false);
 interp.get()->SkipAppInitFiles(false);
 SBCommandReturnObject result;
-interp.SourceInitFileInHomeDirectory(result);
+interp.SourceInitFileInHomeDirectory(result, false);
   } else {
 interp.get()->SkipLLDBInitFiles(true);
 interp.get()->SkipAppInitFiles(true);
Index: lldb/source/API/SBCommandInterpreter.cpp
===
--- lldb/source/API/SBCommandInterpreter.cpp
+++ lldb/source/API/SBCommandInterpreter.cpp
@@ -478,6 +478,25 @@
   }
 }
 
+void SBCommandInterpreter::SourceInitFileInHomeDirectory(
+SBCommandReturnObject &result, bool repl_enabled) {
+  LLDB_RECORD_METHOD(void, SBCommandInterpreter, SourceInitFileInHomeDirectory,
+ (lldb::SBCommandReturnObject &, bool), result,
+ repl_enabled);
+
+  result.Clear();
+  if (IsValid()) {
+TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
+std::unique_lock lock;
+if (target_sp)
+  lock = std::unique_lock(target_sp->GetAPIMutex());
+m_opaque_ptr->SourceInitFileHome(result.ref(), repl_enabled);
+  } else {
+result->AppendError("SBCommandInterpreter is not valid");
+result->SetStatus(eReturnStatusFailed);
+  }
+}
+
 void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory(
 SBCommandReturnObject &result) {
   LLDB_RECORD_METHOD(void, SBCommandInterpreter,
@@ -806,6 +825,9 @@
   LLDB_REGISTER_METHOD(void, SBCommandInterpreter,
SourceInitFileInHomeDirectory,
(lldb::SBCommandReturnObject &));
+  LLDB_REGISTER_METHOD(void, SBCommandIn

[Lldb-commits] [PATCH] D86242: [lldb/interpreter] Add REPL-specific init file.

2020-08-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/docs/man/lldb.rst:312
 
 First, it will read the application specific init file whose name is
 ~/.lldbinit followed by a "-" and the name of the current program. This would

I wonder if we should have the description here, and refer to it from the REPL 
section. 



Comment at: lldb/include/lldb/API/SBCommandInterpreter.h:150
+  void SourceInitFileInHomeDirectory(lldb::SBCommandReturnObject &result,
+ bool repl_enabled);
 

nit: How about `is_repl` as this is not really something you turn on and off? 



Comment at: lldb/include/lldb/API/SBCommandInterpreter.h:150
+  void SourceInitFileInHomeDirectory(lldb::SBCommandReturnObject &result,
+ bool repl_enabled);
 

JDevlieghere wrote:
> nit: How about `is_repl` as this is not really something you turn on and off? 
I'd also give it a default argument (`false`). 



Comment at: lldb/source/API/SBDebugger.cpp:223
 SBCommandReturnObject result;
-interp.SourceInitFileInHomeDirectory(result);
+interp.SourceInitFileInHomeDirectory(result, false);
   } else {

This can go with the default arg.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86242

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


[Lldb-commits] [lldb] a3fc61c - [lldb] Move Xcode SDK helper functions into lldbutil

2020-08-19 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-08-19T13:30:27-07:00
New Revision: a3fc61c80f89ea709a1128caa2de2723fe307c81

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

LOG: [lldb] Move Xcode SDK helper functions into lldbutil

This allows the logic to be reused by both the builders and the tests.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/builders/darwin.py
lldb/packages/Python/lldbsuite/test/lldbutil.py
lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/builders/darwin.py 
b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
index 470ea5d01db2..f9005397d50e 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/darwin.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
@@ -4,29 +4,12 @@
 
 from .builder import Builder
 from lldbsuite.test import configuration
+import lldbsuite.test.lldbutil as lldbutil
 
 REMOTE_PLATFORM_NAME_RE = re.compile(r"^remote-(.+)$")
 SIMULATOR_PLATFORM_RE = re.compile(r"^(.+)-simulator$")
 
 
-def get_sdk(os, env):
-if os == "ios":
-if env == "simulator":
-return "iphonesimulator"
-if env == "macabi":
-return "macosx"
-return "iphoneos"
-elif os == "tvos":
-if env == "simulator":
-return "appletvsimulator"
-return "appletvos"
-elif os == "watchos":
-if env == "simulator":
-return "watchsimulator"
-return "watchos"
-return os
-
-
 def get_os_env_from_platform(platform):
 match = REMOTE_PLATFORM_NAME_RE.match(platform)
 if match:
@@ -92,13 +75,11 @@ def getArchCFlags(self, architecture):
 return ""
 
 # Get the SDK from the os and env.
-sdk = get_sdk(os, env)
+sdk = lldbutil.get_xcode_sdk(os, env)
 if not sdk:
 return ""
 
-version = subprocess.check_output(
-["xcrun", "--sdk", sdk,
- "--show-sdk-version"]).rstrip().decode('utf-8')
+version = lldbutil.get_xcode_sdk_version(sdk)
 if not version:
 return ""
 

diff  --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index d0ba25e185cd..d4fd7f4b1f65 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -12,6 +12,7 @@
 import os
 import re
 import sys
+import subprocess
 
 # Third-party modules
 from six import StringIO as SixStringIO
@@ -54,6 +55,40 @@ def mkdir_p(path):
 raise
 if not os.path.isdir(path):
 raise OSError(errno.ENOTDIR, "%s is not a directory"%path)
+
+
+# 
+# Dealing with SDK and triples
+# 
+
+def get_xcode_sdk(os, env):
+if os == "ios":
+if env == "simulator":
+return "iphonesimulator"
+if env == "macabi":
+return "macosx"
+return "iphoneos"
+elif os == "tvos":
+if env == "simulator":
+return "appletvsimulator"
+return "appletvos"
+elif os == "watchos":
+if env == "simulator":
+return "watchsimulator"
+return "watchos"
+return os
+
+
+def get_xcode_sdk_version(sdk):
+return subprocess.check_output(
+['xcrun', '--sdk', sdk, '--show-sdk-version']).rstrip().decode('utf-8')
+
+
+def get_xcode_sdk_root(sdk):
+return subprocess.check_output(['xcrun', '--sdk', sdk, '--show-sdk-path'
+]).rstrip().decode('utf-8')
+
+
 # ===
 # Disassembly for an SBFunction or an SBSymbol object
 # ===
@@ -525,7 +560,7 @@ def run_break_set_by_file_colon_line(
 file_name = path,
 line_number = line_number,
 column_number = column_number)
-
+
 return get_bpno_from_match(break_results)
 
 def run_break_set_command(test, command):

diff  --git a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py 
b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
index 51aa004baea6..2db6e334752d 100644
--- a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -48,8 +48,7 @@ def check_simulator_ostype(self, sdk, platform, 
arch='x86_64'):
 # Launch the process using simctl
 self.assertIsNotNone(deviceUDID)
 exe_name = 'test_simulator_platform_{}'.format(platform)
-sdkroot = subprocess.check_output(['xcrun', '--show-sdk-path', '--sdk',
-   sdk]).decode("utf-8")
+sdkroot = lldbutil.get_xcode_sdk_root(sdk)
 self.build

[Lldb-commits] [PATCH] D86244: [lldb] Update TestSimulatorPlatform.py now that the Makefile no longer decomposes the TRIPLE

2020-08-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: aprantl.
JDevlieghere requested review of this revision.

We move the triple (de)composition logic into the builder in e5d08fcbac72 
 but this 
test is relying on Make to construct the `ARCH_CFLAGS` from the given `TRIPLE`. 
This updates the test to pass `ARC`, `ARCH_CFLAGS` and `SDKROOT` instead.


https://reviews.llvm.org/D86244

Files:
  lldb/test/API/macosx/simulator/TestSimulatorPlatform.py


Index: lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
===
--- lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -20,7 +20,7 @@
 found = 0
 for line in load_cmds.split('\n'):
 if expected_load_command in line:
-  found += 1
+found += 1
 self.assertEquals(
 found, 1, "wrong number of load commands for {}".format(
 expected_load_command))
@@ -46,7 +46,24 @@
 def run_with(self, arch, os, vers, env, expected_load_command):
 env_list = [env] if env else []
 triple = '-'.join([arch, 'apple', os + vers] + env_list)
-self.build(dictionary={'TRIPLE': triple})
+
+version_min = ''
+if vers:
+if env == 'simulator':
+version_min = '-m{}-simulator-version-min={}'.format(os, vers)
+elif os == 'macosx':
+version_min = '-m{}-version-min={}'.format(os, vers)
+
+sdk = lldbutil.get_xcode_sdk(os, env)
+sdk_root = lldbutil.get_xcode_sdk_root(sdk)
+
+self.build(
+dictionary={
+'ARCH': arch,
+'ARCH_CFLAGS': '-target {} {}'.format(triple, version_min),
+'SDKROOT': sdk_root
+})
+
 self.check_load_commands(expected_load_command)
 log = self.getBuildArtifact('packets.log')
 self.expect("log enable gdb-remote packets -f "+log)


Index: lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
===
--- lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -20,7 +20,7 @@
 found = 0
 for line in load_cmds.split('\n'):
 if expected_load_command in line:
-  found += 1
+found += 1
 self.assertEquals(
 found, 1, "wrong number of load commands for {}".format(
 expected_load_command))
@@ -46,7 +46,24 @@
 def run_with(self, arch, os, vers, env, expected_load_command):
 env_list = [env] if env else []
 triple = '-'.join([arch, 'apple', os + vers] + env_list)
-self.build(dictionary={'TRIPLE': triple})
+
+version_min = ''
+if vers:
+if env == 'simulator':
+version_min = '-m{}-simulator-version-min={}'.format(os, vers)
+elif os == 'macosx':
+version_min = '-m{}-version-min={}'.format(os, vers)
+
+sdk = lldbutil.get_xcode_sdk(os, env)
+sdk_root = lldbutil.get_xcode_sdk_root(sdk)
+
+self.build(
+dictionary={
+'ARCH': arch,
+'ARCH_CFLAGS': '-target {} {}'.format(triple, version_min),
+'SDKROOT': sdk_root
+})
+
 self.check_load_commands(expected_load_command)
 log = self.getBuildArtifact('packets.log')
 self.expect("log enable gdb-remote packets -f "+log)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D86235: Fix swig scripts install target name

2020-08-19 Thread António Afonso via Phabricator via lldb-commits
aadsm added a comment.

@JDevlieghere thanks for the quick review, but on the name I mean the actual 
`finish_swig_python_scripts`, this sounds like a step name and not a component 
distributed by llvm like `liblldb` ot `lldb-server`. That was the reason at the 
time I named it `lldb-python-scripts` because it was very clear what was being 
installed.
Would you be fine with me changing `swig_scripts_target` back to 
`lldb-python-scripts`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86235

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


[Lldb-commits] [PATCH] D86242: [lldb/interpreter] Add REPL-specific init file.

2020-08-19 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added inline comments.



Comment at: lldb/docs/man/lldb.rst:312
 
 First, it will read the application specific init file whose name is
 ~/.lldbinit followed by a "-" and the name of the current program. This would

JDevlieghere wrote:
> I wonder if we should have the description here, and refer to it from the 
> REPL section. 
Sounds good.



Comment at: lldb/include/lldb/API/SBCommandInterpreter.h:150
+  void SourceInitFileInHomeDirectory(lldb::SBCommandReturnObject &result,
+ bool repl_enabled);
 

JDevlieghere wrote:
> JDevlieghere wrote:
> > nit: How about `is_repl` as this is not really something you turn on and 
> > off? 
> I'd also give it a default argument (`false`). 
Giving it a default argument caused ambiguity in some cases (mainly when 
generating the bindings) that's why I left it like this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86242

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


[Lldb-commits] [PATCH] D86235: Fix swig scripts install target name

2020-08-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D86235#2227052 , @aadsm wrote:

> @JDevlieghere thanks for the quick review, but on the name I mean the actual 
> `finish_swig_python_scripts`, this sounds like a step name and not a 
> component distributed by llvm like `liblldb` ot `lldb-server`. That was the 
> reason at the time I named it `lldb-python-scripts` because it was very clear 
> what was being installed.
> Would you be fine with me changing `swig_scripts_target` back to 
> `lldb-python-scripts`?

No objections at all. IIUC that would mean changing the first argument in 
`CMakeLists.txt:89` to:

  finish_swig_python("lldb-python" "${lldb_python_bindings_dir}" 
"${lldb_python_target_dir}")

and then in `CMakeLists.txt:166` something like

  set(swig_scripts_target "${swig_target}-scripts")
  set(swig_scripts_install_target "install-${swig_scripts_target}")

Sounds good to me, I didn't know anybody as explicitly specifying them 
anywhere, I wouldn't have broken that if I had known. My apologies.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86235

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


[Lldb-commits] [PATCH] D86242: [lldb/interpreter] Add REPL-specific init file

2020-08-19 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 286660.
mib marked an inline comment as done.
mib retitled this revision from "[lldb/interpreter] Add REPL-specific init 
file." to "[lldb/interpreter] Add REPL-specific init file".
mib edited the summary of this revision.
mib added a comment.

Addressed @JDevlieghere comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86242

Files:
  lldb/docs/man/lldb.rst
  lldb/include/lldb/API/SBCommandInterpreter.h
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/source/API/SBDebugger.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/tools/driver/Driver.cpp

Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -493,7 +493,7 @@
   // Before we handle any options from the command line, we parse the
   // .lldbinit file in the user's home directory.
   SBCommandReturnObject result;
-  sb_interpreter.SourceInitFileInHomeDirectory(result);
+  sb_interpreter.SourceInitFileInHomeDirectory(result, m_option_data.m_repl);
   if (m_option_data.m_debug_mode) {
 result.PutError(m_debugger.GetErrorFile());
 result.PutOutput(m_debugger.GetOutputFile());
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2090,6 +2090,22 @@
   FileSystem::Instance().Resolve(init_file);
 }
 
+static void GetHomeREPLInitFile(llvm::SmallVectorImpl &init_file,
+LanguageType language) {
+  std::string init_file_name;
+
+  switch (language) {
+  // TODO: Add support for a language used with a REPL.
+  default:
+return;
+  }
+
+  llvm::sys::path::home_directory(init_file);
+  llvm::sys::path::append(init_file, init_file_name);
+
+  FileSystem::Instance().Resolve(init_file);
+}
+
 static void GetCwdInitFile(llvm::SmallVectorImpl &init_file) {
   llvm::StringRef s = ".lldbinit";
   init_file.assign(s.begin(), s.end());
@@ -2164,15 +2180,27 @@
 
 /// We will first see if there is an application specific ".lldbinit" file
 /// whose name is "~/.lldbinit" followed by a "-" and the name of the program.
-/// If this file doesn't exist, we fall back to just the "~/.lldbinit" file.
-void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result) {
+/// If this file doesn't exist, we fall back to the REPL init file or the
+/// default home init file in "~/.lldbinit".
+void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result,
+bool is_repl) {
   if (m_skip_lldbinit_files) {
 result.SetStatus(eReturnStatusSuccessFinishNoResult);
 return;
   }
 
   llvm::SmallString<128> init_file;
-  GetHomeInitFile(init_file);
+
+  if (is_repl) {
+LanguageType language = {};
+TargetSP target_sp = GetDebugger().GetSelectedTarget();
+if (target_sp)
+  language = target_sp->GetLanguage();
+GetHomeREPLInitFile(init_file, language);
+  }
+
+  if (init_file.empty())
+GetHomeInitFile(init_file);
 
   if (!m_skip_app_init_files) {
 llvm::StringRef program_name =
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -220,7 +220,7 @@
 interp.get()->SkipLLDBInitFiles(false);
 interp.get()->SkipAppInitFiles(false);
 SBCommandReturnObject result;
-interp.SourceInitFileInHomeDirectory(result);
+interp.SourceInitFileInHomeDirectory(result, false);
   } else {
 interp.get()->SkipLLDBInitFiles(true);
 interp.get()->SkipAppInitFiles(true);
Index: lldb/source/API/SBCommandInterpreter.cpp
===
--- lldb/source/API/SBCommandInterpreter.cpp
+++ lldb/source/API/SBCommandInterpreter.cpp
@@ -478,6 +478,24 @@
   }
 }
 
+void SBCommandInterpreter::SourceInitFileInHomeDirectory(
+SBCommandReturnObject &result, bool is_repl) {
+  LLDB_RECORD_METHOD(void, SBCommandInterpreter, SourceInitFileInHomeDirectory,
+ (lldb::SBCommandReturnObject &, bool), result, is_repl);
+
+  result.Clear();
+  if (IsValid()) {
+TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
+std::unique_lock lock;
+if (target_sp)
+  lock = std::unique_lock(target_sp->GetAPIMutex());
+m_opaque_ptr->SourceInitFileHome(result.ref(), is_repl);
+  } else {
+result->AppendError("SBCommandInterpreter is not valid");
+result->SetStatus(eReturnStatusFailed);
+  }
+}
+
 void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory(
 SBCommandReturnObject &result) {
   LLDB_RECORD_METHOD(void, SBCommandInterpreter,
@@ -806,6 +824,9 @@
   LLDB_REGISTER

[Lldb-commits] [PATCH] D86244: [lldb] Update TestSimulatorPlatform.py now that the Makefile no longer decomposes the TRIPLE

2020-08-19 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

I just learned that we no longer compute SDKROOT in Makefile.rules, so this 
seems resonable.


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

https://reviews.llvm.org/D86244

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


[Lldb-commits] [PATCH] D86242: [lldb/interpreter] Add REPL-specific init file

2020-08-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:2183
 /// whose name is "~/.lldbinit" followed by a "-" and the name of the program.
-/// If this file doesn't exist, we fall back to just the "~/.lldbinit" file.
-void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result) {
+/// If this file doesn't exist, we fall back to the REPL init file or the
+/// default home init file in "~/.lldbinit".

This is wrong, you check the REPL file first, fi that works you use that, 
otherwise you fall back to the app specific one, and finally to the global one. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86242

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


[Lldb-commits] [PATCH] D86242: [lldb/interpreter] Add REPL-specific init file

2020-08-19 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added inline comments.



Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:2183
 /// whose name is "~/.lldbinit" followed by a "-" and the name of the program.
-/// If this file doesn't exist, we fall back to just the "~/.lldbinit" file.
-void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result) {
+/// If this file doesn't exist, we fall back to the REPL init file or the
+/// default home init file in "~/.lldbinit".

JDevlieghere wrote:
> This is wrong, you check the REPL file first, fi that works you use that, 
> otherwise you fall back to the app specific one, and finally to the global 
> one. 
Yes, but the application init file overrides the REPL init file that also 
override the global one, that's why I put it this way in the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86242

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


[Lldb-commits] [PATCH] D85539: [lldb] Extend builder to pass the TRIPLE spec to Make

2020-08-19 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

It broke the Debian buildbot: 
http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/16095
And also Fedora (although there the commit looks as a different one): 
http://lab.llvm.org:8014/builders/lldb-x86_64-fedora?numbuilds=1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85539

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


[Lldb-commits] [PATCH] D86242: [lldb/interpreter] Add REPL-specific init file

2020-08-19 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 286673.
mib added a comment.

Update man page to reflect current implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86242

Files:
  lldb/docs/man/lldb.rst
  lldb/include/lldb/API/SBCommandInterpreter.h
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/source/API/SBDebugger.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/tools/driver/Driver.cpp

Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -493,7 +493,7 @@
   // Before we handle any options from the command line, we parse the
   // .lldbinit file in the user's home directory.
   SBCommandReturnObject result;
-  sb_interpreter.SourceInitFileInHomeDirectory(result);
+  sb_interpreter.SourceInitFileInHomeDirectory(result, m_option_data.m_repl);
   if (m_option_data.m_debug_mode) {
 result.PutError(m_debugger.GetErrorFile());
 result.PutOutput(m_debugger.GetOutputFile());
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2090,6 +2090,22 @@
   FileSystem::Instance().Resolve(init_file);
 }
 
+static void GetHomeREPLInitFile(llvm::SmallVectorImpl &init_file,
+LanguageType language) {
+  std::string init_file_name;
+
+  switch (language) {
+  // TODO: Add support for a language used with a REPL.
+  default:
+return;
+  }
+
+  llvm::sys::path::home_directory(init_file);
+  llvm::sys::path::append(init_file, init_file_name);
+
+  FileSystem::Instance().Resolve(init_file);
+}
+
 static void GetCwdInitFile(llvm::SmallVectorImpl &init_file) {
   llvm::StringRef s = ".lldbinit";
   init_file.assign(s.begin(), s.end());
@@ -2164,15 +2180,27 @@
 
 /// We will first see if there is an application specific ".lldbinit" file
 /// whose name is "~/.lldbinit" followed by a "-" and the name of the program.
-/// If this file doesn't exist, we fall back to just the "~/.lldbinit" file.
-void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result) {
+/// If this file doesn't exist, we fall back to the REPL init file or the
+/// default home init file in "~/.lldbinit".
+void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result,
+bool is_repl) {
   if (m_skip_lldbinit_files) {
 result.SetStatus(eReturnStatusSuccessFinishNoResult);
 return;
   }
 
   llvm::SmallString<128> init_file;
-  GetHomeInitFile(init_file);
+
+  if (is_repl) {
+LanguageType language = {};
+TargetSP target_sp = GetDebugger().GetSelectedTarget();
+if (target_sp)
+  language = target_sp->GetLanguage();
+GetHomeREPLInitFile(init_file, language);
+  }
+
+  if (init_file.empty())
+GetHomeInitFile(init_file);
 
   if (!m_skip_app_init_files) {
 llvm::StringRef program_name =
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -220,7 +220,7 @@
 interp.get()->SkipLLDBInitFiles(false);
 interp.get()->SkipAppInitFiles(false);
 SBCommandReturnObject result;
-interp.SourceInitFileInHomeDirectory(result);
+interp.SourceInitFileInHomeDirectory(result, false);
   } else {
 interp.get()->SkipLLDBInitFiles(true);
 interp.get()->SkipAppInitFiles(true);
Index: lldb/source/API/SBCommandInterpreter.cpp
===
--- lldb/source/API/SBCommandInterpreter.cpp
+++ lldb/source/API/SBCommandInterpreter.cpp
@@ -478,6 +478,24 @@
   }
 }
 
+void SBCommandInterpreter::SourceInitFileInHomeDirectory(
+SBCommandReturnObject &result, bool is_repl) {
+  LLDB_RECORD_METHOD(void, SBCommandInterpreter, SourceInitFileInHomeDirectory,
+ (lldb::SBCommandReturnObject &, bool), result, is_repl);
+
+  result.Clear();
+  if (IsValid()) {
+TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
+std::unique_lock lock;
+if (target_sp)
+  lock = std::unique_lock(target_sp->GetAPIMutex());
+m_opaque_ptr->SourceInitFileHome(result.ref(), is_repl);
+  } else {
+result->AppendError("SBCommandInterpreter is not valid");
+result->SetStatus(eReturnStatusFailed);
+  }
+}
+
 void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory(
 SBCommandReturnObject &result) {
   LLDB_RECORD_METHOD(void, SBCommandInterpreter,
@@ -806,6 +824,9 @@
   LLDB_REGISTER_METHOD(void, SBCommandInterpreter,
SourceInitFileInHomeDirectory,
(lldb::SBCommandReturnObject &));
+  LLDB_REGISTER_METHOD(void, SBCommandInterprete

[Lldb-commits] [PATCH] D86242: [lldb/interpreter] Add REPL-specific init file

2020-08-19 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 286674.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86242

Files:
  lldb/docs/man/lldb.rst
  lldb/include/lldb/API/SBCommandInterpreter.h
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/source/API/SBDebugger.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/tools/driver/Driver.cpp

Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -493,7 +493,7 @@
   // Before we handle any options from the command line, we parse the
   // .lldbinit file in the user's home directory.
   SBCommandReturnObject result;
-  sb_interpreter.SourceInitFileInHomeDirectory(result);
+  sb_interpreter.SourceInitFileInHomeDirectory(result, m_option_data.m_repl);
   if (m_option_data.m_debug_mode) {
 result.PutError(m_debugger.GetErrorFile());
 result.PutOutput(m_debugger.GetOutputFile());
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2090,6 +2090,22 @@
   FileSystem::Instance().Resolve(init_file);
 }
 
+static void GetHomeREPLInitFile(llvm::SmallVectorImpl &init_file,
+LanguageType language) {
+  std::string init_file_name;
+
+  switch (language) {
+  // TODO: Add support for a language used with a REPL.
+  default:
+return;
+  }
+
+  llvm::sys::path::home_directory(init_file);
+  llvm::sys::path::append(init_file, init_file_name);
+
+  FileSystem::Instance().Resolve(init_file);
+}
+
 static void GetCwdInitFile(llvm::SmallVectorImpl &init_file) {
   llvm::StringRef s = ".lldbinit";
   init_file.assign(s.begin(), s.end());
@@ -2164,15 +2180,27 @@
 
 /// We will first see if there is an application specific ".lldbinit" file
 /// whose name is "~/.lldbinit" followed by a "-" and the name of the program.
-/// If this file doesn't exist, we fall back to just the "~/.lldbinit" file.
-void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result) {
+/// If this file doesn't exist, we fall back to the REPL init file or the
+/// default home init file in "~/.lldbinit".
+void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result,
+bool is_repl) {
   if (m_skip_lldbinit_files) {
 result.SetStatus(eReturnStatusSuccessFinishNoResult);
 return;
   }
 
   llvm::SmallString<128> init_file;
-  GetHomeInitFile(init_file);
+
+  if (is_repl) {
+LanguageType language = {};
+TargetSP target_sp = GetDebugger().GetSelectedTarget();
+if (target_sp)
+  language = target_sp->GetLanguage();
+GetHomeREPLInitFile(init_file, language);
+  }
+
+  if (init_file.empty())
+GetHomeInitFile(init_file);
 
   if (!m_skip_app_init_files) {
 llvm::StringRef program_name =
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -220,7 +220,7 @@
 interp.get()->SkipLLDBInitFiles(false);
 interp.get()->SkipAppInitFiles(false);
 SBCommandReturnObject result;
-interp.SourceInitFileInHomeDirectory(result);
+interp.SourceInitFileInHomeDirectory(result, false);
   } else {
 interp.get()->SkipLLDBInitFiles(true);
 interp.get()->SkipAppInitFiles(true);
Index: lldb/source/API/SBCommandInterpreter.cpp
===
--- lldb/source/API/SBCommandInterpreter.cpp
+++ lldb/source/API/SBCommandInterpreter.cpp
@@ -478,6 +478,24 @@
   }
 }
 
+void SBCommandInterpreter::SourceInitFileInHomeDirectory(
+SBCommandReturnObject &result, bool is_repl) {
+  LLDB_RECORD_METHOD(void, SBCommandInterpreter, SourceInitFileInHomeDirectory,
+ (lldb::SBCommandReturnObject &, bool), result, is_repl);
+
+  result.Clear();
+  if (IsValid()) {
+TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
+std::unique_lock lock;
+if (target_sp)
+  lock = std::unique_lock(target_sp->GetAPIMutex());
+m_opaque_ptr->SourceInitFileHome(result.ref(), is_repl);
+  } else {
+result->AppendError("SBCommandInterpreter is not valid");
+result->SetStatus(eReturnStatusFailed);
+  }
+}
+
 void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory(
 SBCommandReturnObject &result) {
   LLDB_RECORD_METHOD(void, SBCommandInterpreter,
@@ -806,6 +824,9 @@
   LLDB_REGISTER_METHOD(void, SBCommandInterpreter,
SourceInitFileInHomeDirectory,
(lldb::SBCommandReturnObject &));
+  LLDB_REGISTER_METHOD(void, SBCommandInterpreter,
+   SourceInitFileInHomeDirectory,
+   

[Lldb-commits] [PATCH] D86242: [lldb/interpreter] Add REPL-specific init file

2020-08-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/docs/man/lldb.rst:314
+If launched with a `REPL`_ option, it will first look for a REPL configuration
+file, specific to the REPL language. If this file doesn't exist, or `lldb`
+wasn't launch with `REPL`_, meaning there is neither a REPL init file nor an

:program:`lldb`



Comment at: lldb/docs/man/lldb.rst:323
 
+
 To always load the .lldbinit file in the current working directory, add the

Spurious newline



Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:2183
 /// whose name is "~/.lldbinit" followed by a "-" and the name of the program.
-/// If this file doesn't exist, we fall back to just the "~/.lldbinit" file.
-void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result) {
+/// If this file doesn't exist, we fall back to the REPL init file or the
+/// default home init file in "~/.lldbinit".

mib wrote:
> JDevlieghere wrote:
> > This is wrong, you check the REPL file first, fi that works you use that, 
> > otherwise you fall back to the app specific one, and finally to the global 
> > one. 
> Yes, but the application init file overrides the REPL init file that also 
> override the global one, that's why I put it this way in the comment.
Cool, now the docs and the comment are in sync. That code is really confusing 
though but I think I was the last to touch it so that's my bad :-) 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86242

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


[Lldb-commits] [lldb] 868b45b - [lldb/interpreter] Add REPL-specific init file

2020-08-19 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2020-08-20T00:36:32+02:00
New Revision: 868b45b5b31d1203cab09ae0306f4c47e6070f68

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

LOG: [lldb/interpreter] Add REPL-specific init file

This patch adds the infrastructure to have language specific REPL init
files. It's the foundation work to a following patch that will introduce
Swift REPL init file.

When lldb is launched with the `--repl` option, it will look for a REPL
init file in the home directory and source it. This overrides the
default `~/.lldbinit`, which content might make the REPL behave
unexpectedly. If the REPL init file doesn't exists, lldb will fall back
to the default init file.

rdar://65836048

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/docs/man/lldb.rst
lldb/include/lldb/API/SBCommandInterpreter.h
lldb/include/lldb/Interpreter/CommandInterpreter.h
lldb/source/API/SBCommandInterpreter.cpp
lldb/source/API/SBDebugger.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/tools/driver/Driver.cpp

Removed: 




diff  --git a/lldb/docs/man/lldb.rst b/lldb/docs/man/lldb.rst
index 87be124d788e..19a5eaab8e8c 100644
--- a/lldb/docs/man/lldb.rst
+++ b/lldb/docs/man/lldb.rst
@@ -305,11 +305,15 @@ CONFIGURATION FILES
 :program:`lldb` reads things like settings, aliases and commands from the
 .lldbinit file.
 
-First, it will read the application specific init file whose name is
-~/.lldbinit followed by a "-" and the name of the current program. This would
-be ~/.lldbinit-lldb for the command line :program:`lldb` and ~/.lldbinit-Xcode
-for Xcode. If there is no application specific init file, the global
-~/.lldbinit is read.
+First, :program:`lldb` will try to read the application specific init file
+whose name is ~/.lldbinit followed by a "-" and the name of the current
+program. This would be ~/.lldbinit-lldb for the command line :program:`lldb`
+and ~/.lldbinit-Xcode for Xcode. If there is no application specific init
+file, :program:`lldb` will look for an init file in the home directory.
+If launched with a `REPL`_ option, it will first look for a REPL configuration
+file, specific to the REPL language. If this file doesn't exist, or 
:program:`lldb`
+wasn't launch with `REPL`_, meaning there is neither a REPL init file nor an
+application specific init file, `lldb` will fallback to the global ~/.lldbinit.
 
 Secondly, it will look for an .lldbinit file in the current working directory.
 For security reasons, :program:`lldb` will print a warning and not source this

diff  --git a/lldb/include/lldb/API/SBCommandInterpreter.h 
b/lldb/include/lldb/API/SBCommandInterpreter.h
index a70e060bec99..2364a8dae88c 100644
--- a/lldb/include/lldb/API/SBCommandInterpreter.h
+++ b/lldb/include/lldb/API/SBCommandInterpreter.h
@@ -146,6 +146,8 @@ class SBCommandInterpreter {
  const char *auto_repeat_command);
 
   void SourceInitFileInHomeDirectory(lldb::SBCommandReturnObject &result);
+  void SourceInitFileInHomeDirectory(lldb::SBCommandReturnObject &result,
+ bool is_repl);
 
   void
   SourceInitFileInCurrentWorkingDirectory(lldb::SBCommandReturnObject &result);

diff  --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 36d7e5d3c118..f899861bb218 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -256,7 +256,7 @@ class CommandInterpreter : public Broadcaster,
   }
 
   void SourceInitFileCwd(CommandReturnObject &result);
-  void SourceInitFileHome(CommandReturnObject &result);
+  void SourceInitFileHome(CommandReturnObject &result, bool is_repl = false);
 
   bool AddCommand(llvm::StringRef name, const lldb::CommandObjectSP &cmd_sp,
   bool can_replace);

diff  --git a/lldb/source/API/SBCommandInterpreter.cpp 
b/lldb/source/API/SBCommandInterpreter.cpp
index f4f19577b36c..31e7da8323b8 100644
--- a/lldb/source/API/SBCommandInterpreter.cpp
+++ b/lldb/source/API/SBCommandInterpreter.cpp
@@ -478,6 +478,24 @@ void SBCommandInterpreter::SourceInitFileInHomeDirectory(
   }
 }
 
+void SBCommandInterpreter::SourceInitFileInHomeDirectory(
+SBCommandReturnObject &result, bool is_repl) {
+  LLDB_RECORD_METHOD(void, SBCommandInterpreter, SourceInitFileInHomeDirectory,
+ (lldb::SBCommandReturnObject &, bool), result, is_repl);
+
+  result.Clear();
+  if (IsValid()) {
+TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
+std::unique_lock lock;
+if (target_sp)
+  lock = std::unique_lock(target_sp->GetAPIMutex());
+m_opaque_ptr->SourceInitFile

[Lldb-commits] [PATCH] D86242: [lldb/interpreter] Add REPL-specific init file

2020-08-19 Thread Med Ismail Bennani 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 rG868b45b5b31d: [lldb/interpreter] Add REPL-specific init file 
(authored by mib).

Changed prior to commit:
  https://reviews.llvm.org/D86242?vs=286674&id=286678#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86242

Files:
  lldb/docs/man/lldb.rst
  lldb/include/lldb/API/SBCommandInterpreter.h
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/source/API/SBDebugger.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/tools/driver/Driver.cpp

Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -493,7 +493,7 @@
   // Before we handle any options from the command line, we parse the
   // .lldbinit file in the user's home directory.
   SBCommandReturnObject result;
-  sb_interpreter.SourceInitFileInHomeDirectory(result);
+  sb_interpreter.SourceInitFileInHomeDirectory(result, m_option_data.m_repl);
   if (m_option_data.m_debug_mode) {
 result.PutError(m_debugger.GetErrorFile());
 result.PutOutput(m_debugger.GetOutputFile());
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2090,6 +2090,22 @@
   FileSystem::Instance().Resolve(init_file);
 }
 
+static void GetHomeREPLInitFile(llvm::SmallVectorImpl &init_file,
+LanguageType language) {
+  std::string init_file_name;
+
+  switch (language) {
+  // TODO: Add support for a language used with a REPL.
+  default:
+return;
+  }
+
+  llvm::sys::path::home_directory(init_file);
+  llvm::sys::path::append(init_file, init_file_name);
+
+  FileSystem::Instance().Resolve(init_file);
+}
+
 static void GetCwdInitFile(llvm::SmallVectorImpl &init_file) {
   llvm::StringRef s = ".lldbinit";
   init_file.assign(s.begin(), s.end());
@@ -2164,15 +2180,27 @@
 
 /// We will first see if there is an application specific ".lldbinit" file
 /// whose name is "~/.lldbinit" followed by a "-" and the name of the program.
-/// If this file doesn't exist, we fall back to just the "~/.lldbinit" file.
-void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result) {
+/// If this file doesn't exist, we fall back to the REPL init file or the
+/// default home init file in "~/.lldbinit".
+void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result,
+bool is_repl) {
   if (m_skip_lldbinit_files) {
 result.SetStatus(eReturnStatusSuccessFinishNoResult);
 return;
   }
 
   llvm::SmallString<128> init_file;
-  GetHomeInitFile(init_file);
+
+  if (is_repl) {
+LanguageType language = {};
+TargetSP target_sp = GetDebugger().GetSelectedTarget();
+if (target_sp)
+  language = target_sp->GetLanguage();
+GetHomeREPLInitFile(init_file, language);
+  }
+
+  if (init_file.empty())
+GetHomeInitFile(init_file);
 
   if (!m_skip_app_init_files) {
 llvm::StringRef program_name =
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -220,7 +220,7 @@
 interp.get()->SkipLLDBInitFiles(false);
 interp.get()->SkipAppInitFiles(false);
 SBCommandReturnObject result;
-interp.SourceInitFileInHomeDirectory(result);
+interp.SourceInitFileInHomeDirectory(result, false);
   } else {
 interp.get()->SkipLLDBInitFiles(true);
 interp.get()->SkipAppInitFiles(true);
Index: lldb/source/API/SBCommandInterpreter.cpp
===
--- lldb/source/API/SBCommandInterpreter.cpp
+++ lldb/source/API/SBCommandInterpreter.cpp
@@ -478,6 +478,24 @@
   }
 }
 
+void SBCommandInterpreter::SourceInitFileInHomeDirectory(
+SBCommandReturnObject &result, bool is_repl) {
+  LLDB_RECORD_METHOD(void, SBCommandInterpreter, SourceInitFileInHomeDirectory,
+ (lldb::SBCommandReturnObject &, bool), result, is_repl);
+
+  result.Clear();
+  if (IsValid()) {
+TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
+std::unique_lock lock;
+if (target_sp)
+  lock = std::unique_lock(target_sp->GetAPIMutex());
+m_opaque_ptr->SourceInitFileHome(result.ref(), is_repl);
+  } else {
+result->AppendError("SBCommandInterpreter is not valid");
+result->SetStatus(eReturnStatusFailed);
+  }
+}
+
 void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory(
 SBCommandReturnObject &result) {
   LLDB_RECORD_METHOD(void, SBCommandInterpreter,
@@ -806,6 +824,9 @@
   LLDB_REGISTER

[Lldb-commits] [PATCH] D86244: [lldb] Update TestSimulatorPlatform.py now that the Makefile no longer decomposes the TRIPLE

2020-08-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG09ca3f41bbc5: [lldb] Update TestSimulatorPlatform.py to set 
ARCH_CFLAGS instead of TRIPLE (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86244

Files:
  lldb/test/API/macosx/simulator/TestSimulatorPlatform.py


Index: lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
===
--- lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -20,7 +20,7 @@
 found = 0
 for line in load_cmds.split('\n'):
 if expected_load_command in line:
-  found += 1
+found += 1
 self.assertEquals(
 found, 1, "wrong number of load commands for {}".format(
 expected_load_command))
@@ -46,7 +46,24 @@
 def run_with(self, arch, os, vers, env, expected_load_command):
 env_list = [env] if env else []
 triple = '-'.join([arch, 'apple', os + vers] + env_list)
-self.build(dictionary={'TRIPLE': triple})
+
+version_min = ''
+if vers:
+if env == 'simulator':
+version_min = '-m{}-simulator-version-min={}'.format(os, vers)
+elif os == 'macosx':
+version_min = '-m{}-version-min={}'.format(os, vers)
+
+sdk = lldbutil.get_xcode_sdk(os, env)
+sdk_root = lldbutil.get_xcode_sdk_root(sdk)
+
+self.build(
+dictionary={
+'ARCH': arch,
+'ARCH_CFLAGS': '-target {} {}'.format(triple, version_min),
+'SDKROOT': sdk_root
+})
+
 self.check_load_commands(expected_load_command)
 log = self.getBuildArtifact('packets.log')
 self.expect("log enable gdb-remote packets -f "+log)


Index: lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
===
--- lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -20,7 +20,7 @@
 found = 0
 for line in load_cmds.split('\n'):
 if expected_load_command in line:
-  found += 1
+found += 1
 self.assertEquals(
 found, 1, "wrong number of load commands for {}".format(
 expected_load_command))
@@ -46,7 +46,24 @@
 def run_with(self, arch, os, vers, env, expected_load_command):
 env_list = [env] if env else []
 triple = '-'.join([arch, 'apple', os + vers] + env_list)
-self.build(dictionary={'TRIPLE': triple})
+
+version_min = ''
+if vers:
+if env == 'simulator':
+version_min = '-m{}-simulator-version-min={}'.format(os, vers)
+elif os == 'macosx':
+version_min = '-m{}-version-min={}'.format(os, vers)
+
+sdk = lldbutil.get_xcode_sdk(os, env)
+sdk_root = lldbutil.get_xcode_sdk_root(sdk)
+
+self.build(
+dictionary={
+'ARCH': arch,
+'ARCH_CFLAGS': '-target {} {}'.format(triple, version_min),
+'SDKROOT': sdk_root
+})
+
 self.check_load_commands(expected_load_command)
 log = self.getBuildArtifact('packets.log')
 self.expect("log enable gdb-remote packets -f "+log)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 09ca3f4 - [lldb] Update TestSimulatorPlatform.py to set ARCH_CFLAGS instead of TRIPLE

2020-08-19 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-08-19T15:42:44-07:00
New Revision: 09ca3f41bbc5c2c4480accd6404f61bd9e5172a5

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

LOG: [lldb] Update TestSimulatorPlatform.py to set ARCH_CFLAGS instead of TRIPLE

I move the triple (de)composition logic into the builder in e5d08fcbac72
but this test is relying on Make to construct the set the ARCH,
ARCH_CFLAGS and SDKROOT based on the given TRIPLE. This patch updates
the test to pass these variables directly.

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

Added: 


Modified: 
lldb/test/API/macosx/simulator/TestSimulatorPlatform.py

Removed: 




diff  --git a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py 
b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
index 4c3a86531c8f..7be192491251 100644
--- a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -20,7 +20,7 @@ def check_load_commands(self, expected_load_command):
 found = 0
 for line in load_cmds.split('\n'):
 if expected_load_command in line:
-  found += 1
+found += 1
 self.assertEquals(
 found, 1, "wrong number of load commands for {}".format(
 expected_load_command))
@@ -46,7 +46,24 @@ def check_debugserver(self, log, expected_platform, 
expected_version):
 def run_with(self, arch, os, vers, env, expected_load_command):
 env_list = [env] if env else []
 triple = '-'.join([arch, 'apple', os + vers] + env_list)
-self.build(dictionary={'TRIPLE': triple})
+
+version_min = ''
+if vers:
+if env == 'simulator':
+version_min = '-m{}-simulator-version-min={}'.format(os, vers)
+elif os == 'macosx':
+version_min = '-m{}-version-min={}'.format(os, vers)
+
+sdk = lldbutil.get_xcode_sdk(os, env)
+sdk_root = lldbutil.get_xcode_sdk_root(sdk)
+
+self.build(
+dictionary={
+'ARCH': arch,
+'ARCH_CFLAGS': '-target {} {}'.format(triple, version_min),
+'SDKROOT': sdk_root
+})
+
 self.check_load_commands(expected_load_command)
 log = self.getBuildArtifact('packets.log')
 self.expect("log enable gdb-remote packets -f "+log)



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


[Lldb-commits] [lldb] a6eb70c - [lldb] Return empty string from getExtraMakeArgs when not implemented

2020-08-19 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-08-19T17:52:50-07:00
New Revision: a6eb70c052da767aef6b041d0db20bdf3a9e06b5

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

LOG: [lldb] Return empty string from getExtraMakeArgs when not implemented

No return statement means the method returns None which breaks a list
comprehension down the line that expects a str instance.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/builders/builder.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py 
b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index 4a8985104874..fbfa86700e22 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -25,6 +25,7 @@ def getExtraMakeArgs(self):
 Helper function to return extra argumentsfor the make system. This
 method is meant to be overridden by platform specific builders.
 """
+return ""
 
 def getArchCFlags(self, architecture):
 """Returns the ARCH_CFLAGS for the make system."""



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


[Lldb-commits] [PATCH] D86261: Add hashing of the .text section to ProcessMinidump.

2020-08-19 Thread Greg Clayton via Phabricator via lldb-commits
clayborg created this revision.
clayborg added reviewers: labath, jhenderson, aadsm, wallace.
Herald added a project: LLDB.
clayborg requested review of this revision.
Herald added a subscriber: JDevlieghere.

Breakpad will always have a UUID for binaries when it creates minidump files. 
If an ELF files has a GNU build ID, it will use that. If it doesn't, it will 
create one by hashing up to the first 4096 bytes of the .text section. LLDB was 
not able to load these binaries even when we had the right binary because the 
UUID didn't match. LLDB will use the GNU build ID first as the main UUID for a 
binary and fallback onto a 8 byte CRC if a binary doesn't have one. With this 
fix, we will check for the Breakpad hash or the Facebook hash (a modified 
version of the breakpad hash that collides a bit less) and accept binaries when 
these hashes match.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86261

Files:
  lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
  lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad.yaml
  
lldb/test/API/functionalities/postmortem/minidump-new/linux-arm-breakpad-uuid-match.yaml
  
lldb/test/API/functionalities/postmortem/minidump-new/linux-arm-facebook-uuid-match.yaml

Index: lldb/test/API/functionalities/postmortem/minidump-new/linux-arm-facebook-uuid-match.yaml
===
--- /dev/null
+++ lldb/test/API/functionalities/postmortem/minidump-new/linux-arm-facebook-uuid-match.yaml
@@ -0,0 +1,15 @@
+--- !minidump
+Streams:
+  - Type:SystemInfo
+Processor Arch:  ARM
+Platform ID: Linux
+CSD Version: '15E216'
+CPU:
+  CPUID:   0x
+  - Type:ModuleList
+Modules:
+  - Base of Image:   0x1000
+Size of Image:   0x1000
+Module Name: '/invalid/path/on/current/system/libbreakpad.so'
+CodeView Record: 52534453141010100410101013101010575e451000
+...
Index: lldb/test/API/functionalities/postmortem/minidump-new/linux-arm-breakpad-uuid-match.yaml
===
--- /dev/null
+++ lldb/test/API/functionalities/postmortem/minidump-new/linux-arm-breakpad-uuid-match.yaml
@@ -0,0 +1,15 @@
+--- !minidump
+Streams:
+  - Type:SystemInfo
+Processor Arch:  ARM
+Platform ID: Linux
+CSD Version: '15E216'
+CPU:
+  CPUID:   0x
+  - Type:ModuleList
+Modules:
+  - Base of Image:   0x1000
+Size of Image:   0x1000
+Module Name: '/invalid/path/on/current/system/libbreakpad.so'
+CodeView Record: 52534453040014000300474e55
+...
Index: lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad.yaml
===
--- /dev/null
+++ lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad.yaml
@@ -0,0 +1,15 @@
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:ELFDATA2LSB
+  Type:ET_DYN
+  Machine: EM_ARM
+  Flags:   [ EF_ARM_SOFT_FLOAT, EF_ARM_EABI_VER5 ]
+Sections:
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x0001
+AddressAlign:0x0004
+Content: 040014000300474E5500
Index: lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
===
--- lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
+++ lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
@@ -179,6 +179,50 @@
"/invalid/path/on/current/system/libuuidmismatch.so",
"7295E17C-6668-9E05-CBB5-DEE5003865D5")
 
+def test_breakpad_hash_match(self):
+"""
+Breakpad creates minidump files using CvRecord in each module whose
+signature is set to PDB70 where the UUID is a hash generated by
+breakpad of the .text section. This is only done when the
+executable has no ELF build ID.
+
+This test verifies that if we have a minidump with a 16 byte UUID,
+that we are able to associate a symbol file with no ELF build ID
+and match it up by hashing the .text section.
+"""
+so_path = self.getBuildArtifact("libbreakpad.so")
+self.yaml2obj("libbreakpad.yaml", so_path)
+cmd = 'settings set target.exec-search-paths "%s"' % (os.path.dirname(so_path))
+self.dbg.HandleCommand(cmd)
+modules = self.get_minidump_modules("linux-arm-breakpad-uuid-match.yaml")
+self.assertEqual(1, len(modules))
+# LL

[Lldb-commits] [PATCH] D86216: [lldb] Forcefully complete a type when adding typedefs

2020-08-19 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor 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/D86216/new/

https://reviews.llvm.org/D86216

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


[Lldb-commits] [PATCH] D83116: [DWARFYAML] Add support for referencing different abbrev tables.

2020-08-19 Thread Xing GUO via Phabricator via lldb-commits
Higuoxing added a comment.






Comment at: llvm/include/llvm/ObjectYAML/DWARFEmitter.h:34
+private:
+  Data &DWARF;
+  std::map AbbrevID2Index;

labath wrote:
> jhenderson wrote:
> > Would it make any sense to merge the `DWARFYAML::Data` class and 
> > `DWARFYAML::DWARFState` class at all?
> That would definitely be nice.
>>! @jhenderson :
> Would it make any sense to merge the `DWARFYAML::Data` class and 
> `DWARFYAML::DWARFState` class at all?

>>! @labath :
> That would definitely be nice.

I think they can be merged. But is there any particular reason to merge them? 
Personally, I would like to keep the `DWARFYAML::DWARFState` class. Here are a 
few concerns I would like to address:

- If we merge the `DWARFYAML::DWARFState` and `DWARFYAML::Data` at all, we will 
need to add some helper variables, e.g. `AbbrevTableID2Index` and a method like 
`Error DWARFYAML::link()` to `DWARFYAML::Data` class to link DWARF sections. We 
will have to call this special method before DWARF sections being emitted. If 
we port DWARF support to other binary format in the future, e.g., wasm, we 
might forget to call this method. If we make DWARF emitters accept 
`DWARFYAML::DWARFState`, it's easy to figure out that we need a `DWARFState` 
before emitting DWARF sections.

- Besides, I think `DWARFYAML::Data` and `DWARFYAML::DWARFState` have different 
functions. `DWARFYAML::Data` is used to contain original DWARF section 
descriptions and `DWARFYAML::DWARFState` contains helper structs and methods 
which helps link DWARF sections. It might be good not to merge them so that we 
can easily figure out when and where are those sections get linked?

I can be persuaded :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83116

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