[Lldb-commits] [PATCH] D24284: [lldb] Read modules from memory when a local copy is not available

2016-10-05 Thread walter erquinigo via lldb-commits
wallace added a comment.

I've run the tests and it's the same with and without this diff :)


https://reviews.llvm.org/D24284



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


[Lldb-commits] [PATCH] D24284: [lldb] Read modules from memory when a local copy is not available

2016-10-06 Thread walter erquinigo via lldb-commits
wallace added a comment.

F2469236: before.txt 

F2469237: after.txt 

These are the output from running the tests. Btw, this was failing before 
because it was reading the export table incorrectly, but I updated it and it 
should be correct now


https://reviews.llvm.org/D24284



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


[Lldb-commits] [PATCH] D24284: [lldb] Read modules from memory when a local copy is not available

2016-10-17 Thread walter erquinigo via lldb-commits
wallace added a comment.

pingping


https://reviews.llvm.org/D24284



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


[Lldb-commits] [lldb] r284422 - [lldb] Read modules from memory when a local copy is not available

2016-10-17 Thread Walter Erquinigo via lldb-commits
Author: wallace
Date: Mon Oct 17 15:28:19 2016
New Revision: 284422

URL: http://llvm.org/viewvc/llvm-project?rev=284422&view=rev
Log:
[lldb] Read modules from memory when a local copy is not available

Summary:
When the local lldb doesn't have access to a copy of the modules in the target, 
e.g. winphone, with this change now we read these modules from memory.

There are mainly 2 changes:
1. create pecoff object files from memory
2. read from memory when the local file is not available

Reviewers: sas, fjricci, zturner

Subscribers: #lldb

Tags: #lldb

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

Modified:
lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Modified: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp?rev=284422&r1=284421&r2=284422&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp Mon Oct 17 
15:28:19 2016
@@ -14,6 +14,7 @@
 
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataBuffer.h"
+#include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/FileSpecList.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -83,7 +84,14 @@ ObjectFile *ObjectFilePECOFF::CreateInst
 ObjectFile *ObjectFilePECOFF::CreateMemoryInstance(
 const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) {
-  return NULL;
+  if (!data_sp || !ObjectFilePECOFF::MagicBytesMatch(data_sp))
+return nullptr;
+  auto objfile_ap = llvm::make_unique(
+  module_sp, data_sp, process_sp, header_addr);
+  if (objfile_ap.get() && objfile_ap->ParseHeader()) {
+return objfile_ap.release();
+  }
+  return nullptr;
 }
 
 size_t ObjectFilePECOFF::GetModuleSpecifications(
@@ -161,6 +169,18 @@ ObjectFilePECOFF::ObjectFilePECOFF(const
   ::memset(&m_coff_header_opt, 0, sizeof(m_coff_header_opt));
 }
 
+ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp,
+   addr_t header_addr)
+: ObjectFile(module_sp, process_sp, header_addr, header_data_sp),
+  m_dos_header(), m_coff_header(), m_coff_header_opt(), m_sect_headers(),
+  m_entry_point_address() {
+  ::memset(&m_dos_header, 0, sizeof(m_dos_header));
+  ::memset(&m_coff_header, 0, sizeof(m_coff_header));
+  ::memset(&m_coff_header_opt, 0, sizeof(m_coff_header_opt));
+}
+
 ObjectFilePECOFF::~ObjectFilePECOFF() {}
 
 bool ObjectFilePECOFF::ParseHeader() {
@@ -396,6 +416,27 @@ bool ObjectFilePECOFF::ParseCOFFOptional
   return success;
 }
 
+DataExtractor ObjectFilePECOFF::ReadImageData(uint32_t offset, size_t size) {
+  if (m_file) {
+DataBufferSP buffer_sp(m_file.ReadFileContents(offset, size));
+return DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize());
+  }
+  ProcessSP process_sp(m_process_wp.lock());
+  DataExtractor data;
+  if (process_sp) {
+auto data_ap = llvm::make_unique(size, 0);
+Error readmem_error;
+size_t bytes_read =
+process_sp->ReadMemory(m_image_base + offset, data_ap->GetBytes(),
+   data_ap->GetByteSize(), readmem_error);
+if (bytes_read == size) {
+  DataBufferSP buffer_sp(data_ap.release());
+  data.SetData(buffer_sp, 0, buffer_sp->GetByteSize());
+}
+  }
+  return data;
+}
+
 //--
 // ParseSectionHeaders
 //--
@@ -405,12 +446,9 @@ bool ObjectFilePECOFF::ParseSectionHeade
   m_sect_headers.clear();
 
   if (nsects > 0) {
-const uint32_t addr_byte_size = GetAddressByteSize();
 const size_t section_header_byte_size = nsects * sizeof(section_header_t);
-DataBufferSP section_header_data_sp(m_file.ReadFileContents(
-section_header_data_offset, section_header_byte_size));
-DataExtractor section_header_data(section_header_data_sp, GetByteOrder(),
-  addr_byte_size);
+DataExtractor section_header_data =
+ReadImageData(section_header_data_offset, section_header_byte_size);
 
 lldb::offset_t offset = 0;
 if (section_header_data.ValidOffsetForDataOfSize(
@@ -470,68 +508,65 @@ Symtab *ObjectFilePECOFF::GetSymtab() {
 
   const uint32_t num_syms = m_coff_header.nsyms;
 
-  if (num_syms > 0 && m_coff_header.symoff > 0) {
+  if (m_file && num_syms > 0 && m_coff_header.symoff > 0) {
 const uint32_t symbol_size = 18;
-const uint32_t addr_byte_size = GetAddressByteSize(

[Lldb-commits] [PATCH] D24284: [lldb] Read modules from memory when a local copy is not available

2016-10-17 Thread walter erquinigo via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284422: [lldb] Read modules from memory when a local copy is 
not available (authored by wallace).

Changed prior to commit:
  https://reviews.llvm.org/D24284?vs=72597&id=74895#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24284

Files:
  lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Index: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
===
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -50,6 +50,10 @@
const lldb_private::FileSpec *file,
lldb::offset_t file_offset, lldb::offset_t length);
 
+  ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   lldb::DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
+
   ~ObjectFilePECOFF() override;
 
   //--
@@ -130,6 +134,8 @@
 
   bool IsWindowsSubsystem();
 
+  lldb_private::DataExtractor ReadImageData(uint32_t offset, size_t size);
+
 protected:
   bool NeedsEndianSwap() const;
 
Index: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -14,6 +14,7 @@
 
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataBuffer.h"
+#include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/FileSpecList.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -83,7 +84,14 @@
 ObjectFile *ObjectFilePECOFF::CreateMemoryInstance(
 const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) {
-  return NULL;
+  if (!data_sp || !ObjectFilePECOFF::MagicBytesMatch(data_sp))
+return nullptr;
+  auto objfile_ap = llvm::make_unique(
+  module_sp, data_sp, process_sp, header_addr);
+  if (objfile_ap.get() && objfile_ap->ParseHeader()) {
+return objfile_ap.release();
+  }
+  return nullptr;
 }
 
 size_t ObjectFilePECOFF::GetModuleSpecifications(
@@ -161,6 +169,18 @@
   ::memset(&m_coff_header_opt, 0, sizeof(m_coff_header_opt));
 }
 
+ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp,
+   addr_t header_addr)
+: ObjectFile(module_sp, process_sp, header_addr, header_data_sp),
+  m_dos_header(), m_coff_header(), m_coff_header_opt(), m_sect_headers(),
+  m_entry_point_address() {
+  ::memset(&m_dos_header, 0, sizeof(m_dos_header));
+  ::memset(&m_coff_header, 0, sizeof(m_coff_header));
+  ::memset(&m_coff_header_opt, 0, sizeof(m_coff_header_opt));
+}
+
 ObjectFilePECOFF::~ObjectFilePECOFF() {}
 
 bool ObjectFilePECOFF::ParseHeader() {
@@ -396,6 +416,27 @@
   return success;
 }
 
+DataExtractor ObjectFilePECOFF::ReadImageData(uint32_t offset, size_t size) {
+  if (m_file) {
+DataBufferSP buffer_sp(m_file.ReadFileContents(offset, size));
+return DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize());
+  }
+  ProcessSP process_sp(m_process_wp.lock());
+  DataExtractor data;
+  if (process_sp) {
+auto data_ap = llvm::make_unique(size, 0);
+Error readmem_error;
+size_t bytes_read =
+process_sp->ReadMemory(m_image_base + offset, data_ap->GetBytes(),
+   data_ap->GetByteSize(), readmem_error);
+if (bytes_read == size) {
+  DataBufferSP buffer_sp(data_ap.release());
+  data.SetData(buffer_sp, 0, buffer_sp->GetByteSize());
+}
+  }
+  return data;
+}
+
 //--
 // ParseSectionHeaders
 //--
@@ -405,12 +446,9 @@
   m_sect_headers.clear();
 
   if (nsects > 0) {
-const uint32_t addr_byte_size = GetAddressByteSize();
 const size_t section_header_byte_size = nsects * sizeof(section_header_t);
-DataBufferSP section_header_data_sp(m_file.ReadFileContents(
-section_header_data_offset, section_header_byte_size));
-DataExtractor section_header_data(section_header_data_sp, GetByteOrder(),
-  addr_byte_size);
+DataExtractor section_header_data =
+ReadImageData(section_header_data_offset, section_header_byte_size);
 
 lldb::offset_t offset = 0;
 if (section_header_data.ValidOffsetForDataOfSize(
@@ -470,68 +508,65 @@
 
   const uint32_t num_syms = m_coff_header.nsyms;
 
-  if (num_sy

Re: [Lldb-commits] [PATCH] D24283: [lldb] Set the correct triple when creating an ArchSpec for windows

2016-09-06 Thread walter erquinigo via lldb-commits
wallace added a comment.

oh, thank you, first time i'm sending lldb diffs


Repository:
  rL LLVM

https://reviews.llvm.org/D24283



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


Re: [Lldb-commits] [PATCH] D24283: [lldb] Set the correct triple when creating an ArchSpec for windows

2016-09-06 Thread walter erquinigo via lldb-commits
wallace added a comment.

This fixes some issues with arm architectures (where this was unsetting the 
thumbv7 and was fallbacking to thumb).
This is also needed for https://reviews.llvm.org/D24284, where the objet file 
requires a correct architecture inferred from the machine arch


Repository:
  rL LLVM

https://reviews.llvm.org/D24283



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


[Lldb-commits] [PATCH] D24284: [lldb] Read modules from memory when a local copy is not available

2016-09-06 Thread walter erquinigo via lldb-commits
wallace created this revision.
wallace added reviewers: zturner, sas.
wallace added a subscriber: LLDB.
wallace set the repository for this revision to rL LLVM.
wallace added a project: LLDB.

When the local lldb doesn't have access to a copy of the modules in the target, 
e.g. winphone, with this change now we read these modules from memory.

There are mainly 3 changes:
1. set the correct OS when definingn the arch of pecoff files
2. create pecoff object files from memory
3. read from memory when the local file is not available


Repository:
  rL LLVM

https://reviews.llvm.org/D24284

Files:
  lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Index: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
===
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -166,6 +166,13 @@
 bool
 IsThumb();
 
+ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+ lldb::DataBufferSP& header_data_sp,
+ const lldb::ProcessSP &process_sp,
+ lldb::addr_t header_addr);
+
+lldb_private::DataExtractor ReadImageData(uint32_t offset, size_t size);
+
 protected:
 	bool NeedsEndianSwap() const;
 
Index: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -14,6 +14,7 @@
 
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataBuffer.h"
+#include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Host/FileSpec.h"
 #include "lldb/Core/FileSpecList.h"
 #include "lldb/Core/Module.h"
@@ -101,6 +102,12 @@
 const lldb::ProcessSP &process_sp, 
 lldb::addr_t header_addr)
 {
+if (data_sp && ObjectFilePECOFF::MagicBytesMatch(data_sp)) {
+std::auto_ptr objfile_ap(new ObjectFilePECOFF(module_sp, data_sp, process_sp, header_addr));
+if (objfile_ap.get() && objfile_ap->ParseHeader()) {
+return objfile_ap.release();
+}
+}
 return NULL;
 }
 
@@ -205,6 +212,21 @@
 ::memset (&m_coff_header_opt, 0, sizeof(m_coff_header_opt));
 }
 
+ObjectFilePECOFF::ObjectFilePECOFF (const lldb::ModuleSP &module_sp,
+DataBufferSP& header_data_sp,
+const lldb::ProcessSP &process_sp,
+addr_t header_addr) :
+ObjectFile(module_sp, process_sp, header_addr, header_data_sp),
+m_dos_header (),
+m_coff_header (),
+m_coff_header_opt (),
+m_sect_headers (),
+m_entry_point_address ()
+{
+::memset (&m_dos_header, 0, sizeof(m_dos_header));
+::memset (&m_coff_header, 0, sizeof(m_coff_header));
+::memset (&m_coff_header_opt, 0, sizeof(m_coff_header_opt));
+}
 
 ObjectFilePECOFF::~ObjectFilePECOFF()
 {
@@ -465,6 +487,33 @@
 return success;
 }
 
+DataExtractor ObjectFilePECOFF::ReadImageData(uint32_t offset, size_t size) {
+DataExtractor data;
+if (m_file)
+{
+DataBufferSP buffer_sp (m_file.ReadFileContents (offset, size));
+data = DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize ());
+}
+else
+{
+ProcessSP process_sp (m_process_wp.lock());
+if (process_sp)
+{
+std::unique_ptr data_ap (new DataBufferHeap (size, 0));
+Error readmem_error;
+size_t bytes_read = process_sp->ReadMemory (m_image_base + offset,
+data_ap->GetBytes(),
+data_ap->GetByteSize(),
+readmem_error);
+if (bytes_read == size)
+{
+DataBufferSP buffer_sp (data_ap.release());
+data.SetData (buffer_sp, 0, buffer_sp->GetByteSize());
+}
+}
+}
+return data;
+}
 
 //--
 // ParseSectionHeaders
@@ -477,10 +526,8 @@
 
 if (nsects > 0)
 {
-const uint32_t addr_byte_size = GetAddressByteSize ();
 const size_t section_header_byte_size = nsects * sizeof(section_header_t);
-DataBufferSP section_header_data_sp(m_file.ReadFileContents (section_header_data_offset, section_header_byte_size));
-DataExtractor section_header_data (section_header_data_sp, GetByteOrder(), addr_byte_size);
+DataExtractor section_header_data = ReadImageData (section_header_data_offset, section_header_byte_size);
 
 lldb::offset_t offset = 0;
 if (section_header_data.Valid

Re: [Lldb-commits] [PATCH] D24283: [lldb] Set the correct triple when creating an ArchSpec for windows

2016-09-13 Thread walter erquinigo via lldb-commits
wallace updated this revision to Diff 71226.
wallace updated the summary for this revision.
wallace added a comment.

rebase


https://reviews.llvm.org/D24283

Files:
  source/Core/ArchSpec.cpp

Index: source/Core/ArchSpec.cpp
===
--- source/Core/ArchSpec.cpp
+++ source/Core/ArchSpec.cpp
@@ -1034,6 +1034,9 @@
 m_triple.setOS(llvm::Triple::OSType::Solaris);
 break;
   }
+} else if(arch_type == eArchTypeCOFF && os == llvm::Triple::Win32) {
+  m_triple.setVendor(llvm::Triple::PC);
+  m_triple.setOS (llvm::Triple::Win32);
 } else {
   m_triple.setVendor(llvm::Triple::UnknownVendor);
   m_triple.setOS(llvm::Triple::UnknownOS);


Index: source/Core/ArchSpec.cpp
===
--- source/Core/ArchSpec.cpp
+++ source/Core/ArchSpec.cpp
@@ -1034,6 +1034,9 @@
 m_triple.setOS(llvm::Triple::OSType::Solaris);
 break;
   }
+} else if(arch_type == eArchTypeCOFF && os == llvm::Triple::Win32) {
+  m_triple.setVendor(llvm::Triple::PC);
+  m_triple.setOS (llvm::Triple::Win32);
 } else {
   m_triple.setVendor(llvm::Triple::UnknownVendor);
   m_triple.setOS(llvm::Triple::UnknownOS);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D24283: [lldb] Set the correct triple when creating an ArchSpec for windows

2016-09-13 Thread walter erquinigo via lldb-commits
wallace added a comment.

I've run the tests and saw that two tests have been fixed
before:

  Test Methods:   1829
  Reruns:0
  Success:1061
  Expected Failure:113
  Failure:   0
  Error: 7
  Exceptional Exit:  0
  Unexpected Success:   11
  Skip:637
  Timeout:   0
  Expected Timeout:  0

After

  Test Methods:   1829
  Reruns:0
  Success:1061
  Expected Failure:115
  Failure:   0
  Error: 7
  Exceptional Exit:  0
  Unexpected Success:9
  Skip:637
  Timeout:   0
  Expected Timeout:  0

So Expected Failures increased by two


https://reviews.llvm.org/D24283



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


Re: [Lldb-commits] [PATCH] D24283: [lldb] Set the correct triple when creating an ArchSpec for windows

2016-09-13 Thread walter erquinigo via lldb-commits
wallace added a comment.

Hey, apparently this change doesn't affect the test coverage, there are at 
least two flaky tests that sometimes produce unexpected success: 
test_step_over_dwo, test_process_interrupt_dwo

I repeatedly ran the tests with and without my change it the flakiness was 
quite consistent


https://reviews.llvm.org/D24283



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


Re: [Lldb-commits] [PATCH] D24283: [lldb] Set the correct triple when creating an ArchSpec for windows

2016-09-13 Thread walter erquinigo via lldb-commits
wallace added a comment.

btw, i don't have commit access? can you commit it or should i request access?


https://reviews.llvm.org/D24283



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


Re: [Lldb-commits] [PATCH] D24283: [lldb] Set the correct triple when creating an ArchSpec for windows

2016-09-13 Thread walter erquinigo via lldb-commits
wallace added a comment.

thanks!


https://reviews.llvm.org/D24283



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


Re: [Lldb-commits] [PATCH] D24284: [lldb] Read modules from memory when a local copy is not available

2016-09-13 Thread walter erquinigo via lldb-commits
wallace updated this revision to Diff 71265.
wallace updated the summary for this revision.
wallace added a comment.

rebase


https://reviews.llvm.org/D24284

Files:
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -128,6 +128,12 @@
 
   uint32_t GetPluginVersion() override;
 
+  ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   lldb::DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
+
+  lldb_private::DataExtractor ReadImageData(uint32_t offset, size_t size);
+
 protected:
   bool NeedsEndianSwap() const;
 
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -14,6 +14,7 @@
 
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataBuffer.h"
+#include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/FileSpecList.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -83,6 +84,13 @@
 ObjectFile *ObjectFilePECOFF::CreateMemoryInstance(
 const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) {
+  if (data_sp && ObjectFilePECOFF::MagicBytesMatch(data_sp)) {
+std::auto_ptr objfile_ap(
+new ObjectFilePECOFF(module_sp, data_sp, process_sp, header_addr));
+if (objfile_ap.get() && objfile_ap->ParseHeader()) {
+  return objfile_ap.release();
+}
+  }
   return NULL;
 }
 
@@ -161,6 +169,18 @@
   ::memset(&m_coff_header_opt, 0, sizeof(m_coff_header_opt));
 }
 
+ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp,
+   addr_t header_addr)
+: ObjectFile(module_sp, process_sp, header_addr, header_data_sp),
+  m_dos_header(), m_coff_header(), m_coff_header_opt(), m_sect_headers(),
+  m_entry_point_address() {
+  ::memset(&m_dos_header, 0, sizeof(m_dos_header));
+  ::memset(&m_coff_header, 0, sizeof(m_coff_header));
+  ::memset(&m_coff_header_opt, 0, sizeof(m_coff_header_opt));
+}
+
 ObjectFilePECOFF::~ObjectFilePECOFF() {}
 
 bool ObjectFilePECOFF::ParseHeader() {
@@ -396,6 +416,28 @@
   return success;
 }
 
+DataExtractor ObjectFilePECOFF::ReadImageData(uint32_t offset, size_t size) {
+  DataExtractor data;
+  if (m_file) {
+DataBufferSP buffer_sp(m_file.ReadFileContents(offset, size));
+data = DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize());
+  } else {
+ProcessSP process_sp(m_process_wp.lock());
+if (process_sp) {
+  std::unique_ptr data_ap(new DataBufferHeap(size, 0));
+  Error readmem_error;
+  size_t bytes_read =
+  process_sp->ReadMemory(m_image_base + offset, data_ap->GetBytes(),
+ data_ap->GetByteSize(), readmem_error);
+  if (bytes_read == size) {
+DataBufferSP buffer_sp(data_ap.release());
+data.SetData(buffer_sp, 0, buffer_sp->GetByteSize());
+  }
+}
+  }
+  return data;
+}
+
 //--
 // ParseSectionHeaders
 //--
@@ -405,12 +447,9 @@
   m_sect_headers.clear();
 
   if (nsects > 0) {
-const uint32_t addr_byte_size = GetAddressByteSize();
 const size_t section_header_byte_size = nsects * sizeof(section_header_t);
-DataBufferSP section_header_data_sp(m_file.ReadFileContents(
-section_header_data_offset, section_header_byte_size));
-DataExtractor section_header_data(section_header_data_sp, GetByteOrder(),
-  addr_byte_size);
+DataExtractor section_header_data =
+ReadImageData(section_header_data_offset, section_header_byte_size);
 
 lldb::offset_t offset = 0;
 if (section_header_data.ValidOffsetForDataOfSize(
@@ -472,66 +511,63 @@
 
   if (num_syms > 0 && m_coff_header.symoff > 0) {
 const uint32_t symbol_size = 18;
-const uint32_t addr_byte_size = GetAddressByteSize();
 const size_t symbol_data_size = num_syms * symbol_size;
 // Include the 4-byte string table size at the end of the symbols
-DataBufferSP symtab_data_sp(m_file.ReadFileContents(
-m_coff_header.symoff, symbol_data_size + 4));
-DataExtractor symtab_data(symtab_data_sp, GetByteOrder(),
-  addr_byte_size);
-lldb::offset_t offset = symbol_data_size;
-  

Re: [Lldb-commits] [PATCH] D24284: [lldb] Read modules from memory when a local copy is not available

2016-09-14 Thread walter erquinigo via lldb-commits
wallace updated this revision to Diff 71407.
wallace added a comment.

fix pointers


https://reviews.llvm.org/D24284

Files:
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -50,6 +50,10 @@
const lldb_private::FileSpec *file,
lldb::offset_t file_offset, lldb::offset_t length);
 
+  ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   lldb::DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
+
   ~ObjectFilePECOFF() override;
 
   //--
@@ -131,29 +135,31 @@
 bool
 IsThumb();
 
-protected:
-  bool NeedsEndianSwap() const;
-
-  typedef struct dos_header { // DOS .EXE header
-uint16_t e_magic; // Magic number
-uint16_t e_cblp;  // Bytes on last page of file
-uint16_t e_cp;// Pages in file
-uint16_t e_crlc;  // Relocations
-uint16_t e_cparhdr;   // Size of header in paragraphs
-uint16_t e_minalloc;  // Minimum extra paragraphs needed
-uint16_t e_maxalloc;  // Maximum extra paragraphs needed
-uint16_t e_ss;// Initial (relative) SS value
-uint16_t e_sp;// Initial SP value
-uint16_t e_csum;  // Checksum
-uint16_t e_ip;// Initial IP value
-uint16_t e_cs;// Initial (relative) CS value
-uint16_t e_lfarlc;// File address of relocation table
-uint16_t e_ovno;  // Overlay number
-uint16_t e_res[4];// Reserved words
-uint16_t e_oemid; // OEM identifier (for e_oeminfo)
-uint16_t e_oeminfo;   // OEM information; e_oemid specific
-uint16_t e_res2[10];  // Reserved words
-uint32_t e_lfanew;// File address of new exe header
+lldb_private::DataExtractor ReadImageData(uint32_t offset, size_t size);
+
+  protected:
+bool NeedsEndianSwap() const;
+
+typedef struct dos_header { // DOS .EXE header
+  uint16_t e_magic; // Magic number
+  uint16_t e_cblp;  // Bytes on last page of file
+  uint16_t e_cp;// Pages in file
+  uint16_t e_crlc;  // Relocations
+  uint16_t e_cparhdr;   // Size of header in paragraphs
+  uint16_t e_minalloc;  // Minimum extra paragraphs needed
+  uint16_t e_maxalloc;  // Maximum extra paragraphs needed
+  uint16_t e_ss;// Initial (relative) SS value
+  uint16_t e_sp;// Initial SP value
+  uint16_t e_csum;  // Checksum
+  uint16_t e_ip;// Initial IP value
+  uint16_t e_cs;// Initial (relative) CS value
+  uint16_t e_lfarlc;// File address of relocation table
+  uint16_t e_ovno;  // Overlay number
+  uint16_t e_res[4];// Reserved words
+  uint16_t e_oemid; // OEM identifier (for e_oeminfo)
+  uint16_t e_oeminfo;   // OEM information; e_oemid specific
+  uint16_t e_res2[10];  // Reserved words
+  uint32_t e_lfanew;// File address of new exe header
   } dos_header_t;
 
   typedef struct coff_header {
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -10,10 +10,12 @@
 #include "ObjectFilePECOFF.h"
 #include "WindowsMiniDump.h"
 
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/COFF.h"
 
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataBuffer.h"
+#include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/FileSpecList.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -83,6 +85,14 @@
 ObjectFile *ObjectFilePECOFF::CreateMemoryInstance(
 const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) {
+  if (!data_sp || !ObjectFilePECOFF::MagicBytesMatch(data_sp)) {
+return NULL;
+  }
+  auto objfile_ap = llvm::make_unique(
+  module_sp, data_sp, process_sp, header_addr);
+  if (objfile_ap.get() && objfile_ap->ParseHeader()) {
+return objfile_ap.release();
+  }
   return NULL;
 }
 
@@ -164,6 +174,18 @@
   ::memset(&m_coff_header_opt, 0, sizeof(m_coff_header_opt));
 }
 
+ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp,
+   addr_t header_addr)
+: ObjectFile(module_sp, process

Re: [Lldb-commits] [PATCH] D24284: [lldb] Read modules from memory when a local copy is not available

2016-09-14 Thread walter erquinigo via lldb-commits
wallace updated this revision to Diff 71409.
wallace added a comment.

rebase


https://reviews.llvm.org/D24284

Files:
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -50,6 +50,10 @@
const lldb_private::FileSpec *file,
lldb::offset_t file_offset, lldb::offset_t length);
 
+  ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   lldb::DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
+
   ~ObjectFilePECOFF() override;
 
   //--
@@ -128,29 +132,31 @@
 
   uint32_t GetPluginVersion() override;
 
-protected:
-  bool NeedsEndianSwap() const;
-
-  typedef struct dos_header { // DOS .EXE header
-uint16_t e_magic; // Magic number
-uint16_t e_cblp;  // Bytes on last page of file
-uint16_t e_cp;// Pages in file
-uint16_t e_crlc;  // Relocations
-uint16_t e_cparhdr;   // Size of header in paragraphs
-uint16_t e_minalloc;  // Minimum extra paragraphs needed
-uint16_t e_maxalloc;  // Maximum extra paragraphs needed
-uint16_t e_ss;// Initial (relative) SS value
-uint16_t e_sp;// Initial SP value
-uint16_t e_csum;  // Checksum
-uint16_t e_ip;// Initial IP value
-uint16_t e_cs;// Initial (relative) CS value
-uint16_t e_lfarlc;// File address of relocation table
-uint16_t e_ovno;  // Overlay number
-uint16_t e_res[4];// Reserved words
-uint16_t e_oemid; // OEM identifier (for e_oeminfo)
-uint16_t e_oeminfo;   // OEM information; e_oemid specific
-uint16_t e_res2[10];  // Reserved words
-uint32_t e_lfanew;// File address of new exe header
+lldb_private::DataExtractor ReadImageData(uint32_t offset, size_t size);
+
+  protected:
+bool NeedsEndianSwap() const;
+
+typedef struct dos_header { // DOS .EXE header
+  uint16_t e_magic; // Magic number
+  uint16_t e_cblp;  // Bytes on last page of file
+  uint16_t e_cp;// Pages in file
+  uint16_t e_crlc;  // Relocations
+  uint16_t e_cparhdr;   // Size of header in paragraphs
+  uint16_t e_minalloc;  // Minimum extra paragraphs needed
+  uint16_t e_maxalloc;  // Maximum extra paragraphs needed
+  uint16_t e_ss;// Initial (relative) SS value
+  uint16_t e_sp;// Initial SP value
+  uint16_t e_csum;  // Checksum
+  uint16_t e_ip;// Initial IP value
+  uint16_t e_cs;// Initial (relative) CS value
+  uint16_t e_lfarlc;// File address of relocation table
+  uint16_t e_ovno;  // Overlay number
+  uint16_t e_res[4];// Reserved words
+  uint16_t e_oemid; // OEM identifier (for e_oeminfo)
+  uint16_t e_oeminfo;   // OEM information; e_oemid specific
+  uint16_t e_res2[10];  // Reserved words
+  uint32_t e_lfanew;// File address of new exe header
   } dos_header_t;
 
   typedef struct coff_header {
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -10,10 +10,12 @@
 #include "ObjectFilePECOFF.h"
 #include "WindowsMiniDump.h"
 
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/COFF.h"
 
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataBuffer.h"
+#include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/FileSpecList.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -83,6 +85,14 @@
 ObjectFile *ObjectFilePECOFF::CreateMemoryInstance(
 const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) {
+  if (!data_sp || !ObjectFilePECOFF::MagicBytesMatch(data_sp)) {
+return NULL;
+  }
+  auto objfile_ap = llvm::make_unique(
+  module_sp, data_sp, process_sp, header_addr);
+  if (objfile_ap.get() && objfile_ap->ParseHeader()) {
+return objfile_ap.release();
+  }
   return NULL;
 }
 
@@ -161,6 +171,18 @@
   ::memset(&m_coff_header_opt, 0, sizeof(m_coff_header_opt));
 }
 
+ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp,
+   addr_t header_addr)
+: ObjectFile(module_

Re: [Lldb-commits] [PATCH] D24283: [lldb] Set the correct triple when creating an ArchSpec for windows

2016-09-16 Thread walter erquinigo via lldb-commits
wallace added a comment.

ping


https://reviews.llvm.org/D24283



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


Re: [Lldb-commits] [PATCH] D24284: [lldb] Read modules from memory when a local copy is not available

2016-09-16 Thread walter erquinigo via lldb-commits
wallace added a comment.

ping


https://reviews.llvm.org/D24284



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


Re: [Lldb-commits] [PATCH] D24284: [lldb] Read modules from memory when a local copy is not available

2016-09-16 Thread walter erquinigo via lldb-commits
wallace added a comment.

I'm obliged, your grace


https://reviews.llvm.org/D24284



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


Re: [Lldb-commits] [PATCH] D24284: [lldb] Read modules from memory when a local copy is not available

2016-09-19 Thread walter erquinigo via lldb-commits
wallace updated this revision to Diff 71853.
wallace added a comment.

s/NULL/nullptr/


https://reviews.llvm.org/D24284

Files:
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -50,6 +50,10 @@
const lldb_private::FileSpec *file,
lldb::offset_t file_offset, lldb::offset_t length);
 
+  ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   lldb::DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
+
   ~ObjectFilePECOFF() override;
 
   //--
@@ -131,29 +135,31 @@
 bool
 IsThumb();
 
-protected:
-  bool NeedsEndianSwap() const;
-
-  typedef struct dos_header { // DOS .EXE header
-uint16_t e_magic; // Magic number
-uint16_t e_cblp;  // Bytes on last page of file
-uint16_t e_cp;// Pages in file
-uint16_t e_crlc;  // Relocations
-uint16_t e_cparhdr;   // Size of header in paragraphs
-uint16_t e_minalloc;  // Minimum extra paragraphs needed
-uint16_t e_maxalloc;  // Maximum extra paragraphs needed
-uint16_t e_ss;// Initial (relative) SS value
-uint16_t e_sp;// Initial SP value
-uint16_t e_csum;  // Checksum
-uint16_t e_ip;// Initial IP value
-uint16_t e_cs;// Initial (relative) CS value
-uint16_t e_lfarlc;// File address of relocation table
-uint16_t e_ovno;  // Overlay number
-uint16_t e_res[4];// Reserved words
-uint16_t e_oemid; // OEM identifier (for e_oeminfo)
-uint16_t e_oeminfo;   // OEM information; e_oemid specific
-uint16_t e_res2[10];  // Reserved words
-uint32_t e_lfanew;// File address of new exe header
+lldb_private::DataExtractor ReadImageData(uint32_t offset, size_t size);
+
+  protected:
+bool NeedsEndianSwap() const;
+
+typedef struct dos_header { // DOS .EXE header
+  uint16_t e_magic; // Magic number
+  uint16_t e_cblp;  // Bytes on last page of file
+  uint16_t e_cp;// Pages in file
+  uint16_t e_crlc;  // Relocations
+  uint16_t e_cparhdr;   // Size of header in paragraphs
+  uint16_t e_minalloc;  // Minimum extra paragraphs needed
+  uint16_t e_maxalloc;  // Maximum extra paragraphs needed
+  uint16_t e_ss;// Initial (relative) SS value
+  uint16_t e_sp;// Initial SP value
+  uint16_t e_csum;  // Checksum
+  uint16_t e_ip;// Initial IP value
+  uint16_t e_cs;// Initial (relative) CS value
+  uint16_t e_lfarlc;// File address of relocation table
+  uint16_t e_ovno;  // Overlay number
+  uint16_t e_res[4];// Reserved words
+  uint16_t e_oemid; // OEM identifier (for e_oeminfo)
+  uint16_t e_oeminfo;   // OEM information; e_oemid specific
+  uint16_t e_res2[10];  // Reserved words
+  uint32_t e_lfanew;// File address of new exe header
   } dos_header_t;
 
   typedef struct coff_header {
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -10,10 +10,12 @@
 #include "ObjectFilePECOFF.h"
 #include "WindowsMiniDump.h"
 
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/COFF.h"
 
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataBuffer.h"
+#include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/FileSpecList.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -83,7 +85,15 @@
 ObjectFile *ObjectFilePECOFF::CreateMemoryInstance(
 const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) {
-  return NULL;
+  if (!data_sp || !ObjectFilePECOFF::MagicBytesMatch(data_sp)) {
+return nullptr;
+  }
+  auto objfile_ap = llvm::make_unique(
+  module_sp, data_sp, process_sp, header_addr);
+  if (objfile_ap.get() && objfile_ap->ParseHeader()) {
+return objfile_ap.release();
+  }
+  return nullptr;
 }
 
 size_t ObjectFilePECOFF::GetModuleSpecifications(
@@ -164,6 +174,18 @@
   ::memset(&m_coff_header_opt, 0, sizeof(m_coff_header_opt));
 }
 
+ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp,
+   

Re: [Lldb-commits] [PATCH] D24284: [lldb] Read modules from memory when a local copy is not available

2016-09-19 Thread walter erquinigo via lldb-commits
wallace updated this revision to Diff 71855.
wallace added a comment.

rebase


https://reviews.llvm.org/D24284

Files:
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -50,6 +50,10 @@
const lldb_private::FileSpec *file,
lldb::offset_t file_offset, lldb::offset_t length);
 
+  ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   lldb::DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
+
   ~ObjectFilePECOFF() override;
 
   //--
@@ -128,29 +132,31 @@
 
   uint32_t GetPluginVersion() override;
 
-protected:
-  bool NeedsEndianSwap() const;
-
-  typedef struct dos_header { // DOS .EXE header
-uint16_t e_magic; // Magic number
-uint16_t e_cblp;  // Bytes on last page of file
-uint16_t e_cp;// Pages in file
-uint16_t e_crlc;  // Relocations
-uint16_t e_cparhdr;   // Size of header in paragraphs
-uint16_t e_minalloc;  // Minimum extra paragraphs needed
-uint16_t e_maxalloc;  // Maximum extra paragraphs needed
-uint16_t e_ss;// Initial (relative) SS value
-uint16_t e_sp;// Initial SP value
-uint16_t e_csum;  // Checksum
-uint16_t e_ip;// Initial IP value
-uint16_t e_cs;// Initial (relative) CS value
-uint16_t e_lfarlc;// File address of relocation table
-uint16_t e_ovno;  // Overlay number
-uint16_t e_res[4];// Reserved words
-uint16_t e_oemid; // OEM identifier (for e_oeminfo)
-uint16_t e_oeminfo;   // OEM information; e_oemid specific
-uint16_t e_res2[10];  // Reserved words
-uint32_t e_lfanew;// File address of new exe header
+  lldb_private::DataExtractor ReadImageData(uint32_t offset, size_t size);
+
+  protected:
+bool NeedsEndianSwap() const;
+
+typedef struct dos_header { // DOS .EXE header
+  uint16_t e_magic; // Magic number
+  uint16_t e_cblp;  // Bytes on last page of file
+  uint16_t e_cp;// Pages in file
+  uint16_t e_crlc;  // Relocations
+  uint16_t e_cparhdr;   // Size of header in paragraphs
+  uint16_t e_minalloc;  // Minimum extra paragraphs needed
+  uint16_t e_maxalloc;  // Maximum extra paragraphs needed
+  uint16_t e_ss;// Initial (relative) SS value
+  uint16_t e_sp;// Initial SP value
+  uint16_t e_csum;  // Checksum
+  uint16_t e_ip;// Initial IP value
+  uint16_t e_cs;// Initial (relative) CS value
+  uint16_t e_lfarlc;// File address of relocation table
+  uint16_t e_ovno;  // Overlay number
+  uint16_t e_res[4];// Reserved words
+  uint16_t e_oemid; // OEM identifier (for e_oeminfo)
+  uint16_t e_oeminfo;   // OEM information; e_oemid specific
+  uint16_t e_res2[10];  // Reserved words
+  uint32_t e_lfanew;// File address of new exe header
   } dos_header_t;
 
   typedef struct coff_header {
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -10,10 +10,12 @@
 #include "ObjectFilePECOFF.h"
 #include "WindowsMiniDump.h"
 
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/COFF.h"
 
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataBuffer.h"
+#include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/FileSpecList.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -83,7 +85,15 @@
 ObjectFile *ObjectFilePECOFF::CreateMemoryInstance(
 const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) {
-  return NULL;
+  if (!data_sp || !ObjectFilePECOFF::MagicBytesMatch(data_sp)) {
+return nullptr;
+  }
+  auto objfile_ap = llvm::make_unique(
+  module_sp, data_sp, process_sp, header_addr);
+  if (objfile_ap.get() && objfile_ap->ParseHeader()) {
+return objfile_ap.release();
+  }
+  return nullptr;
 }
 
 size_t ObjectFilePECOFF::GetModuleSpecifications(
@@ -161,6 +171,18 @@
   ::memset(&m_coff_header_opt, 0, sizeof(m_coff_header_opt));
 }
 
+ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp,
+ 

Re: [Lldb-commits] [PATCH] D24284: [lldb] Read modules from memory when a local copy is not available

2016-09-20 Thread walter erquinigo via lldb-commits
wallace added a comment.

I was using this patch as well https://reviews.llvm.org/D24530, which might be 
the reason why it fails on your side. I'll double check, but I'm pretty sure 
it's just that


https://reviews.llvm.org/D24284



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


Re: [Lldb-commits] [PATCH] D24284: [lldb] Read modules from memory when a local copy is not available

2016-09-20 Thread walter erquinigo via lldb-commits
wallace updated this revision to Diff 71995.
wallace added a comment.

rebase


https://reviews.llvm.org/D24284

Files:
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -50,6 +50,10 @@
const lldb_private::FileSpec *file,
lldb::offset_t file_offset, lldb::offset_t length);
 
+  ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   lldb::DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
+
   ~ObjectFilePECOFF() override;
 
   //--
@@ -130,6 +134,8 @@
 
   bool IsWindowsSubsystem();
 
+  lldb_private::DataExtractor ReadImageData(uint32_t offset, size_t size);
+
 protected:
   bool NeedsEndianSwap() const;
 
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -14,6 +14,7 @@
 
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataBuffer.h"
+#include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/FileSpecList.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -83,6 +84,13 @@
 ObjectFile *ObjectFilePECOFF::CreateMemoryInstance(
 const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) {
+  if (data_sp && ObjectFilePECOFF::MagicBytesMatch(data_sp)) {
+std::auto_ptr objfile_ap(
+new ObjectFilePECOFF(module_sp, data_sp, process_sp, header_addr));
+if (objfile_ap.get() && objfile_ap->ParseHeader()) {
+  return objfile_ap.release();
+}
+  }
   return NULL;
 }
 
@@ -161,6 +169,18 @@
   ::memset(&m_coff_header_opt, 0, sizeof(m_coff_header_opt));
 }
 
+ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp,
+   addr_t header_addr)
+: ObjectFile(module_sp, process_sp, header_addr, header_data_sp),
+  m_dos_header(), m_coff_header(), m_coff_header_opt(), m_sect_headers(),
+  m_entry_point_address() {
+  ::memset(&m_dos_header, 0, sizeof(m_dos_header));
+  ::memset(&m_coff_header, 0, sizeof(m_coff_header));
+  ::memset(&m_coff_header_opt, 0, sizeof(m_coff_header_opt));
+}
+
 ObjectFilePECOFF::~ObjectFilePECOFF() {}
 
 bool ObjectFilePECOFF::ParseHeader() {
@@ -396,6 +416,28 @@
   return success;
 }
 
+DataExtractor ObjectFilePECOFF::ReadImageData(uint32_t offset, size_t size) {
+  DataExtractor data;
+  if (m_file) {
+DataBufferSP buffer_sp(m_file.ReadFileContents(offset, size));
+data = DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize());
+  } else {
+ProcessSP process_sp(m_process_wp.lock());
+if (process_sp) {
+  std::unique_ptr data_ap(new DataBufferHeap(size, 0));
+  Error readmem_error;
+  size_t bytes_read =
+  process_sp->ReadMemory(m_image_base + offset, data_ap->GetBytes(),
+ data_ap->GetByteSize(), readmem_error);
+  if (bytes_read == size) {
+DataBufferSP buffer_sp(data_ap.release());
+data.SetData(buffer_sp, 0, buffer_sp->GetByteSize());
+  }
+}
+  }
+  return data;
+}
+
 //--
 // ParseSectionHeaders
 //--
@@ -405,12 +447,9 @@
   m_sect_headers.clear();
 
   if (nsects > 0) {
-const uint32_t addr_byte_size = GetAddressByteSize();
 const size_t section_header_byte_size = nsects * sizeof(section_header_t);
-DataBufferSP section_header_data_sp(m_file.ReadFileContents(
-section_header_data_offset, section_header_byte_size));
-DataExtractor section_header_data(section_header_data_sp, GetByteOrder(),
-  addr_byte_size);
+DataExtractor section_header_data =
+ReadImageData(section_header_data_offset, section_header_byte_size);
 
 lldb::offset_t offset = 0;
 if (section_header_data.ValidOffsetForDataOfSize(
@@ -472,66 +511,63 @@
 
   if (num_syms > 0 && m_coff_header.symoff > 0) {
 const uint32_t symbol_size = 18;
-const uint32_t addr_byte_size = GetAddressByteSize();
 const size_t symbol_data_size = num_syms * symbol_size;
 // Include the 4-byte string table size at the end of the symbols
-DataBufferSP symtab_data_sp(m_file.ReadFileContents(
-m_coff_header.symoff, 

Re: [Lldb-commits] [PATCH] D24284: [lldb] Read modules from memory when a local copy is not available

2016-09-26 Thread walter erquinigo via lldb-commits
wallace updated this revision to Diff 72596.
wallace added a comment.

This time I'm calculating the address of the exports header correctly because 
it is
an RVA address.


https://reviews.llvm.org/D24284

Files:
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -50,6 +50,10 @@
const lldb_private::FileSpec *file,
lldb::offset_t file_offset, lldb::offset_t length);
 
+  ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   lldb::DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
+
   ~ObjectFilePECOFF() override;
 
   //--
@@ -130,6 +134,8 @@
 
   bool IsWindowsSubsystem();
 
+  lldb_private::DataExtractor ReadImageData(uint32_t offset, size_t size);
+
 protected:
   bool NeedsEndianSwap() const;
 
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -14,6 +14,7 @@
 
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataBuffer.h"
+#include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/FileSpecList.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -83,6 +84,13 @@
 ObjectFile *ObjectFilePECOFF::CreateMemoryInstance(
 const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) {
+  if (data_sp && ObjectFilePECOFF::MagicBytesMatch(data_sp)) {
+std::auto_ptr objfile_ap(
+new ObjectFilePECOFF(module_sp, data_sp, process_sp, header_addr));
+if (objfile_ap.get() && objfile_ap->ParseHeader()) {
+  return objfile_ap.release();
+}
+  }
   return NULL;
 }
 
@@ -161,6 +169,18 @@
   ::memset(&m_coff_header_opt, 0, sizeof(m_coff_header_opt));
 }
 
+ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp,
+   addr_t header_addr)
+: ObjectFile(module_sp, process_sp, header_addr, header_data_sp),
+  m_dos_header(), m_coff_header(), m_coff_header_opt(), m_sect_headers(),
+  m_entry_point_address() {
+  ::memset(&m_dos_header, 0, sizeof(m_dos_header));
+  ::memset(&m_coff_header, 0, sizeof(m_coff_header));
+  ::memset(&m_coff_header_opt, 0, sizeof(m_coff_header_opt));
+}
+
 ObjectFilePECOFF::~ObjectFilePECOFF() {}
 
 bool ObjectFilePECOFF::ParseHeader() {
@@ -396,6 +416,27 @@
   return success;
 }
 
+DataExtractor ObjectFilePECOFF::ReadImageData(uint32_t offset, size_t size) {
+  if (m_file) {
+DataBufferSP buffer_sp(m_file.ReadFileContents(offset, size));
+return DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize());
+  }
+  ProcessSP process_sp(m_process_wp.lock());
+  DataExtractor data;
+  if (process_sp) {
+std::unique_ptr data_ap(new DataBufferHeap(size, 0));
+Error readmem_error;
+size_t bytes_read =
+process_sp->ReadMemory(m_image_base + offset, data_ap->GetBytes(),
+   data_ap->GetByteSize(), readmem_error);
+if (bytes_read == size) {
+  DataBufferSP buffer_sp(data_ap.release());
+  data.SetData(buffer_sp, 0, buffer_sp->GetByteSize());
+}
+  }
+  return data;
+}
+
 //--
 // ParseSectionHeaders
 //--
@@ -407,10 +448,8 @@
   if (nsects > 0) {
 const uint32_t addr_byte_size = GetAddressByteSize();
 const size_t section_header_byte_size = nsects * sizeof(section_header_t);
-DataBufferSP section_header_data_sp(m_file.ReadFileContents(
-section_header_data_offset, section_header_byte_size));
-DataExtractor section_header_data(section_header_data_sp, GetByteOrder(),
-  addr_byte_size);
+DataExtractor section_header_data =
+ReadImageData(section_header_data_offset, section_header_byte_size);
 
 lldb::offset_t offset = 0;
 if (section_header_data.ValidOffsetForDataOfSize(
@@ -470,68 +509,65 @@
 
   const uint32_t num_syms = m_coff_header.nsyms;
 
-  if (num_syms > 0 && m_coff_header.symoff > 0) {
+  if (m_file && num_syms > 0 && m_coff_header.symoff > 0) {
 const uint32_t symbol_size = 18;
-const uint32_t addr_byte_size = GetAddressByteSize();
 const size_t symbol_data_size = num_syms * symbol_size;
 // Include th

Re: [Lldb-commits] [PATCH] D24284: [lldb] Read modules from memory when a local copy is not available

2016-09-26 Thread walter erquinigo via lldb-commits
wallace updated this revision to Diff 72597.
wallace added a comment.

minor nits


https://reviews.llvm.org/D24284

Files:
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -50,6 +50,10 @@
const lldb_private::FileSpec *file,
lldb::offset_t file_offset, lldb::offset_t length);
 
+  ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   lldb::DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
+
   ~ObjectFilePECOFF() override;
 
   //--
@@ -130,6 +134,8 @@
 
   bool IsWindowsSubsystem();
 
+  lldb_private::DataExtractor ReadImageData(uint32_t offset, size_t size);
+
 protected:
   bool NeedsEndianSwap() const;
 
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -14,6 +14,7 @@
 
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataBuffer.h"
+#include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/FileSpecList.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -83,7 +84,14 @@
 ObjectFile *ObjectFilePECOFF::CreateMemoryInstance(
 const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) {
-  return NULL;
+  if (!data_sp || !ObjectFilePECOFF::MagicBytesMatch(data_sp))
+return nullptr;
+  auto objfile_ap = llvm::make_unique(
+  module_sp, data_sp, process_sp, header_addr);
+  if (objfile_ap.get() && objfile_ap->ParseHeader()) {
+return objfile_ap.release();
+  }
+  return nullptr;
 }
 
 size_t ObjectFilePECOFF::GetModuleSpecifications(
@@ -161,6 +169,18 @@
   ::memset(&m_coff_header_opt, 0, sizeof(m_coff_header_opt));
 }
 
+ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
+   DataBufferSP &header_data_sp,
+   const lldb::ProcessSP &process_sp,
+   addr_t header_addr)
+: ObjectFile(module_sp, process_sp, header_addr, header_data_sp),
+  m_dos_header(), m_coff_header(), m_coff_header_opt(), m_sect_headers(),
+  m_entry_point_address() {
+  ::memset(&m_dos_header, 0, sizeof(m_dos_header));
+  ::memset(&m_coff_header, 0, sizeof(m_coff_header));
+  ::memset(&m_coff_header_opt, 0, sizeof(m_coff_header_opt));
+}
+
 ObjectFilePECOFF::~ObjectFilePECOFF() {}
 
 bool ObjectFilePECOFF::ParseHeader() {
@@ -396,6 +416,27 @@
   return success;
 }
 
+DataExtractor ObjectFilePECOFF::ReadImageData(uint32_t offset, size_t size) {
+  if (m_file) {
+DataBufferSP buffer_sp(m_file.ReadFileContents(offset, size));
+return DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize());
+  }
+  ProcessSP process_sp(m_process_wp.lock());
+  DataExtractor data;
+  if (process_sp) {
+auto data_ap = llvm::make_unique(size, 0);
+Error readmem_error;
+size_t bytes_read =
+process_sp->ReadMemory(m_image_base + offset, data_ap->GetBytes(),
+   data_ap->GetByteSize(), readmem_error);
+if (bytes_read == size) {
+  DataBufferSP buffer_sp(data_ap.release());
+  data.SetData(buffer_sp, 0, buffer_sp->GetByteSize());
+}
+  }
+  return data;
+}
+
 //--
 // ParseSectionHeaders
 //--
@@ -405,12 +446,9 @@
   m_sect_headers.clear();
 
   if (nsects > 0) {
-const uint32_t addr_byte_size = GetAddressByteSize();
 const size_t section_header_byte_size = nsects * sizeof(section_header_t);
-DataBufferSP section_header_data_sp(m_file.ReadFileContents(
-section_header_data_offset, section_header_byte_size));
-DataExtractor section_header_data(section_header_data_sp, GetByteOrder(),
-  addr_byte_size);
+DataExtractor section_header_data =
+ReadImageData(section_header_data_offset, section_header_byte_size);
 
 lldb::offset_t offset = 0;
 if (section_header_data.ValidOffsetForDataOfSize(
@@ -470,68 +508,65 @@
 
   const uint32_t num_syms = m_coff_header.nsyms;
 
-  if (num_syms > 0 && m_coff_header.symoff > 0) {
+  if (m_file && num_syms > 0 && m_coff_header.symoff > 0) {
 const uint32_t symbol_size = 18;
-const uint32_t addr_byte_size = GetAddressByteSize();
 const size_t symbol_data_size = num_syms * symbol_size;
 // Include the 4-byt

[Lldb-commits] [lldb] [LLDB] Support exception breakpoints for plugin-provided languages (PR #97675)

2024-07-03 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/97675

CommandObjectBreakpoint has a harcoded list of languages for which exception 
breakpoints can be enabled. I'm making this a bit more generic so that my Mojo 
plugin can get this feature.
Basically, I'm adding a new overridable method 
`Language::SupportsExceptionBreakpoints` that can be used by language plugins 
to determine whether they support this feature or not. This method is used in 
addition to the hardcoded list and, as an example, I'm using it for the ObjC 
language support.

Another route is simply to avoid doing the check that it's being done right now 
and simply try to the create the exception breakpoint for whatever language 
that is not in the hardcoded list. I'm happy to do that if the reviewers think 
it's a good idea.

As a note, the other possible place for adding this 
`SupportsExceptionBreakpoints` method is in `LanguageRuntime`. However, 
accessing it requires having a process, which is not always the case when 
invoking the `breakpoint set -E` command. The process might not be alive yet, 
so `Language` is a good second place for this.

And as a final note, I don't want to make this `SupportsExceptionBreakpoints` 
complicated. I'm keeping it as simple as possible because it can easily evolve 
as it's not part of the public API.


>From 5d1a7254d1e1a541a7b901be0d3a84eab42474b2 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Thu, 4 Jul 2024 00:34:14 -0400
Subject: [PATCH] [LLDB] Support exception breakpoints for plugin-provided
 languages

CommandObjectBreakpoint has a harcoded list of languages for which exception 
breakpoints can be enabled. I'm making this a bit more generic so that my Mojo 
plugin can get this feature.
Basically, I'm adding a new overridable method 
`Language::SupportsExceptionBreakpoints` that can be used by language plugins 
to determine whether they support this feature or not. This method is used in 
addition to the hardcoded list and, as an example, I'm using it for the ObjC 
language support.

Another route is simply to avoid doing the check that it's being done right now 
and simply try to the create the exception breakpoint for whatever language 
that is not in the hardcoded list. I'm happy to do that if the reviewers think 
it's a good idea.

As a note, the other possible place for adding this 
`SupportsExceptionBreakpoints` method is in `LanguageRuntime`. However, 
accessing it requires having a process, which is not always the case when 
invoking the `breakpoint set -E` command. The process might not be alive yet, 
so `Language` is a good second place for this.

And as a final note, I don't want to make this `SupportsExceptionBreakpoints` 
complicated. I'm keeping it as simple as possible because it can easily evolve 
as it's not part of the public API.
---
 lldb/include/lldb/Target/Language.h  | 6 +-
 lldb/source/Commands/CommandObjectBreakpoint.cpp | 9 ++---
 lldb/source/Plugins/Language/ObjC/ObjCLanguage.h | 2 ++
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index ff7c60bf68bfc..9c2c765ce497f 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -245,7 +245,7 @@ class Language : public PluginInterface {
   // a match.  But we wouldn't want this to match AnotherA::my_function.  The
   // user is specifying a truncated path, not a truncated set of characters.
   // This function does a language-aware comparison for those purposes.
-  virtual bool DemangledNameContainsPath(llvm::StringRef path, 
+  virtual bool DemangledNameContainsPath(llvm::StringRef path,
  ConstString demangled) const;
 
   // if a language has a custom format for printing variable declarations that
@@ -363,6 +363,10 @@ class Language : public PluginInterface {
 return false;
   }
 
+  /// Returns true if this Language supports exception breakpoints via a
+  /// corresponding LanguageRuntime plugin.
+  virtual bool SupportsExceptionBreakpoints() const { return false; }
+
 protected:
   // Classes that inherit from Language can see and modify these
 
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp 
b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index cd4c7790f447e..a5fe9273fac76 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -308,9 +308,6 @@ class CommandObjectBreakpointSet : public 
CommandObjectParsed {
 case eLanguageTypeC_plus_plus_14:
   m_exception_language = eLanguageTypeC_plus_plus;
   break;
-case eLanguageTypeObjC:
-  m_exception_language = eLanguageTypeObjC;
-  break;
 case eLanguageTypeObjC_plus_plus:
   error_context =
   "Set exception breakpoints separately for c++ and objective-c";
@@ -319,6 +316,12 @@ class Com

[Lldb-commits] [lldb] [LLDB] Support exception breakpoints for plugin-provided languages (PR #97675)

2024-07-04 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/97675

>From 5d1a7254d1e1a541a7b901be0d3a84eab42474b2 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Thu, 4 Jul 2024 00:34:14 -0400
Subject: [PATCH 1/2] [LLDB] Support exception breakpoints for plugin-provided
 languages

CommandObjectBreakpoint has a harcoded list of languages for which exception 
breakpoints can be enabled. I'm making this a bit more generic so that my Mojo 
plugin can get this feature.
Basically, I'm adding a new overridable method 
`Language::SupportsExceptionBreakpoints` that can be used by language plugins 
to determine whether they support this feature or not. This method is used in 
addition to the hardcoded list and, as an example, I'm using it for the ObjC 
language support.

Another route is simply to avoid doing the check that it's being done right now 
and simply try to the create the exception breakpoint for whatever language 
that is not in the hardcoded list. I'm happy to do that if the reviewers think 
it's a good idea.

As a note, the other possible place for adding this 
`SupportsExceptionBreakpoints` method is in `LanguageRuntime`. However, 
accessing it requires having a process, which is not always the case when 
invoking the `breakpoint set -E` command. The process might not be alive yet, 
so `Language` is a good second place for this.

And as a final note, I don't want to make this `SupportsExceptionBreakpoints` 
complicated. I'm keeping it as simple as possible because it can easily evolve 
as it's not part of the public API.
---
 lldb/include/lldb/Target/Language.h  | 6 +-
 lldb/source/Commands/CommandObjectBreakpoint.cpp | 9 ++---
 lldb/source/Plugins/Language/ObjC/ObjCLanguage.h | 2 ++
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index ff7c60bf68bfc..9c2c765ce497f 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -245,7 +245,7 @@ class Language : public PluginInterface {
   // a match.  But we wouldn't want this to match AnotherA::my_function.  The
   // user is specifying a truncated path, not a truncated set of characters.
   // This function does a language-aware comparison for those purposes.
-  virtual bool DemangledNameContainsPath(llvm::StringRef path, 
+  virtual bool DemangledNameContainsPath(llvm::StringRef path,
  ConstString demangled) const;
 
   // if a language has a custom format for printing variable declarations that
@@ -363,6 +363,10 @@ class Language : public PluginInterface {
 return false;
   }
 
+  /// Returns true if this Language supports exception breakpoints via a
+  /// corresponding LanguageRuntime plugin.
+  virtual bool SupportsExceptionBreakpoints() const { return false; }
+
 protected:
   // Classes that inherit from Language can see and modify these
 
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp 
b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index cd4c7790f447e..a5fe9273fac76 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -308,9 +308,6 @@ class CommandObjectBreakpointSet : public 
CommandObjectParsed {
 case eLanguageTypeC_plus_plus_14:
   m_exception_language = eLanguageTypeC_plus_plus;
   break;
-case eLanguageTypeObjC:
-  m_exception_language = eLanguageTypeObjC;
-  break;
 case eLanguageTypeObjC_plus_plus:
   error_context =
   "Set exception breakpoints separately for c++ and objective-c";
@@ -319,6 +316,12 @@ class CommandObjectBreakpointSet : public 
CommandObjectParsed {
   error_context = "Unknown language type for exception breakpoint";
   break;
 default:
+  if (Language *languagePlugin = Language::FindPlugin(language)) {
+if (languagePlugin->SupportsExceptionBreakpoints()) {
+  m_exception_language = language;
+  break;
+}
+  }
   error_context = "Unsupported language type for exception breakpoint";
 }
 if (!error_context.empty())
diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h 
b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
index a50f4b036108d..a61d0f128370d 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
@@ -194,6 +194,8 @@ class ObjCLanguage : public Language {
 
   llvm::StringRef GetInstanceVariableName() override { return "self"; }
 
+  bool SupportsExceptionBreakpoints() const override { return true; }
+
   // PluginInterface protocol
   llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
 };

>From e99702d0cafaaa87e06a845e3f3e14868f9e800b Mon Sep 17 00:00:00 2001
From: Walter Erquinigo 
Date: Thu, 4 Jul 2024 10:02:45 -0400
Subject

[Lldb-commits] [lldb] [LLDB] Support exception breakpoints for plugin-provided languages (PR #97675)

2024-07-04 Thread Walter Erquinigo via lldb-commits


@@ -319,6 +316,12 @@ class CommandObjectBreakpointSet : public 
CommandObjectParsed {
   error_context = "Unknown language type for exception breakpoint";
   break;
 default:
+  if (Language *languagePlugin = Language::FindPlugin(language)) {

walter-erquinigo wrote:

Within switch statements I tend to be very paranoid with braces

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


[Lldb-commits] [lldb] [LLDB] Support exception breakpoints for plugin-provided languages (PR #97675)

2024-07-04 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

> And does this list include languages that are not plugin provided?

The hardcoded list in the file being changes includes C++ and Objc in its 
various variants.

> I was wondering why only Objective C changed, but if the rest are not plugins 
> then this makes sense.

That was the only simple example I could use to show how this change does work. 

Thanks for the review!

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


[Lldb-commits] [lldb] [LLDB] Support exception breakpoints for plugin-provided languages (PR #97675)

2024-07-04 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] 3bfc516 - [lldb-dap][NFC] Minor rename

2024-07-05 Thread walter erquinigo via lldb-commits

Author: walter erquinigo
Date: 2024-07-05T13:12:13-04:00
New Revision: 3bfc5167d9e49b9a53e364e8d8853fce543cca0f

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

LOG: [lldb-dap][NFC] Minor rename

As a minor follow up for https://github.com/llvm/llvm-project/pull/97675, I'm 
renaming `SupportsExceptionBreakpoints` to 
`SupportsExceptionBreakpointsOnThrow` and adding a 
`SupportsExceptionBreakpointsOnCatch` to have a bit of more granularity.

Added: 


Modified: 
lldb/include/lldb/Target/Language.h
lldb/source/Commands/CommandObjectBreakpoint.cpp
lldb/source/Plugins/Language/ObjC/ObjCLanguage.h

Removed: 




diff  --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index 2d6e5a40a0c0e4..83bf7635e369a5 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -363,9 +363,13 @@ class Language : public PluginInterface {
 return false;
   }
 
-  /// Returns true if this Language supports exception breakpoints via a
-  /// corresponding LanguageRuntime plugin.
-  virtual bool SupportsExceptionBreakpoints() const { return false; }
+  /// Returns true if this Language supports exception breakpoints on throw via
+  /// a corresponding LanguageRuntime plugin.
+  virtual bool SupportsExceptionBreakpointsOnThrow() const { return false; }
+
+  /// Returns true if this Language supports exception breakpoints on catch via
+  /// a corresponding LanguageRuntime plugin.
+  virtual bool SupportsExceptionBreakpointsOnCatch() const { return false; }
 
 protected:
   // Classes that inherit from Language can see and modify these

diff  --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp 
b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index a5fe9273fac76d..773f8ed2fa8af8 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -317,7 +317,8 @@ class CommandObjectBreakpointSet : public 
CommandObjectParsed {
   break;
 default:
   if (Language *languagePlugin = Language::FindPlugin(language)) {
-if (languagePlugin->SupportsExceptionBreakpoints()) {
+if (languagePlugin->SupportsExceptionBreakpointsOnThrow() ||
+languagePlugin->SupportsExceptionBreakpointsOnCatch()) {
   m_exception_language = language;
   break;
 }

diff  --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h 
b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
index a61d0f128370d4..d9c0cd3c18cfa1 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
@@ -194,7 +194,7 @@ class ObjCLanguage : public Language {
 
   llvm::StringRef GetInstanceVariableName() override { return "self"; }
 
-  bool SupportsExceptionBreakpoints() const override { return true; }
+  bool SupportsExceptionBreakpointsOnThrow() const override { return true; }
 
   // PluginInterface protocol
   llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }



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


[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)

2024-07-05 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/97871

…lly registered languages

First of all, this is done to support exceptions for the Mojo language, but 
it's done in a way that will benefit any other plugin language.

1. I added a new lldb-dap CLI argument (not DAP field) called 
`pre-init-commands`. These commands are executed before DAP initialization. The 
other `init-commands` are executed after DAP initialization. It's worth 
mentioning that the debug adapter returns to VSCode the list of supported 
exception breakpoints during DAP initialization, which means that I need to 
register the Mojo plugin before that initialization step, hence the need for 
`pre-init-commands`. In general, language plugins should be registered in that 
step, as they affect the capabilities of the debugger.
2. I added a set of APIs for lldb-dap to query information of each language 
related to exception breakpoints. E.g. whether a language supports throw or 
catch breakpoints, how the throw keyword is called in each particular language, 
etc.
3. I'm realizing that the Swift support for exception breakpoints in lldb-dap 
should have been implemented in this way, instead of hardcoding it.

>From 63ab70e2a02faed8322c71dc2491428938891471 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 5 Jul 2024 20:30:44 -0400
Subject: [PATCH] [lldb-dap] Support throw and catch exception breakpoints for
 dynamically registered languages

First of all, this is done to support exceptions for the Mojo language, but 
it's done in a way that will benefit any other plugin language.

1. I added a new lldb-dap CLI argument (not DAP field) called 
`pre-init-commands`. These commands are executed before DAP initialization. The 
other `init-commands` are executed after DAP initialization. It's worth 
mentioning that the debug adapter returns to VSCode the list of supported 
exception breakpoints during DAP initialization, which means that I need to 
register the Mojo plugin before that initialization step, hence the need for 
`pre-init-commands`. In general, language plugins should be registered in that 
step, as they affect the capabilities of the debugger.
2. I added a set of APIs for lldb-dap to query information of each language 
related to exception breakpoints. E.g. whether a language supports throw or 
catch breakpoints, how the throw keyword is called in each particular language, 
etc.
3. I'm realizing that the Swift support for exception breakpoints in lldb-dap 
should have been implemented in this way, instead of hardcoding it.
---
 lldb/include/lldb/API/SBLanguageRuntime.h | 26 +++
 lldb/include/lldb/Target/Language.h   |  8 
 lldb/source/API/SBLanguageRuntime.cpp | 40 +
 lldb/tools/lldb-dap/DAP.cpp   | 55 ++-
 lldb/tools/lldb-dap/DAP.h |  2 +
 lldb/tools/lldb-dap/Options.td|  8 
 lldb/tools/lldb-dap/lldb-dap.cpp  | 19 ++--
 7 files changed, 154 insertions(+), 4 deletions(-)

diff --git a/lldb/include/lldb/API/SBLanguageRuntime.h 
b/lldb/include/lldb/API/SBLanguageRuntime.h
index 38aac05d490c1..acdc256fa2ac5 100644
--- a/lldb/include/lldb/API/SBLanguageRuntime.h
+++ b/lldb/include/lldb/API/SBLanguageRuntime.h
@@ -18,6 +18,32 @@ class SBLanguageRuntime {
   static lldb::LanguageType GetLanguageTypeFromString(const char *string);
 
   static const char *GetNameForLanguageType(lldb::LanguageType language);
+
+  /// Returns whether the given language is any version of  C++.
+  static bool LanguageIsCPlusPlus(lldb::LanguageType language);
+
+  /// Returns whether the given language is Obj-C or Obj-C++.
+  static bool LanguageIsObjC(lldb::LanguageType language);
+
+  /// Returns whether the given language is any version of C, C++ or Obj-C.
+  static bool LanguageIsCFamily(lldb::LanguageType language);
+
+  /// Returns whether the given language supports exception breakpoints on
+  /// throw statements.
+  static bool SupportsExceptionBreakpointsOnThrow(lldb::LanguageType language);
+
+  /// Returns whether the given language supports exception breakpoints on
+  /// catch statements.
+  static bool SupportsExceptionBreakpointsOnCatch(lldb::LanguageType language);
+
+  /// Returns the keyword used for throw statements in the given language, e.g.
+  /// Python uses \b raise. Returns \b nullptr if the language is not 
supported.
+  static const char *GetThrowKeywordForLanguage(lldb::LanguageType language);
+
+  /// Returns the keyword used for catch statements in the given language, e.g.
+  /// Python uses \b except. Returns \b nullptr if the language is not
+  /// supported.
+  static const char *GetCatchKeywordForLanguage(lldb::LanguageType language);
 };
 
 } // namespace lldb
diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index 83bf7635e369a..41d8eeef469ea 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.

[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)

2024-07-05 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

This is a screenshot of how it's looking for me on VSCode.
![image](https://github.com/llvm/llvm-project/assets/1613874/7a344b26-549c-4be6-b7d6-7082e701ee88)


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


[Lldb-commits] [lldb] [LLDB] Support exception breakpoints for plugin-provided languages (PR #97675)

2024-07-08 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

> Exception Breakpoints are created by the static method 
> LanguageRuntime::CreateExceptionBreakpoint. So they don't require a process. 

Indeed, but let me elaborate. What I need is a method that doesn't require a 
process that could tell me if a certain language can support exception 
breakpoints, as that's what the checks in the `breakpoint set -E ` 
command try to do.

Then I had two main choices w.r.t `LanguageRuntime`:
- Add the method as non-static `LanguageRuntime`, but `LanguageRuntime` 
instances do require a process.
- Add a static method in `LanguageRuntime`, like `CreateExceptionBreakpoint`, 
but it turns out that `CreateExceptionBreakpoint` ends up relying on 
`Language::GetDefaultExceptionResolverDescription` and 
`Language::GetExceptionResolverDescription`. So this made me believe that it'd 
be better to place all the static exception feature bits in `Language` and not 
`LanguageRuntime`. `LanguageRuntime` seems to be a place more suited for 
dealing with runtime behaviors and not static pieces of information.

> It's a little awkward to have a static method in LanguageRuntime that makes 
> the Exception breakpoint conditioned by a Language method 
> 'SupportsExceptionBreakpoint".

I somewhat agree with it, but probably I'd end up writing a static method 
`LanguageRuntime::SupportsExceptionBreakpoint` that invokes a non-static 
`Language::SupportsExceptionBreakpoint`. And as I mentioned, there's already 
precedent for other exception related stuff in `Language`.

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


[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)

2024-07-08 Thread Walter Erquinigo via lldb-commits


@@ -58,10 +58,17 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
+/// Return string with first character capitalized.
+static std::string capitalize(llvm::StringRef str) {
+  if (str.empty())
+return "";
+  return ((llvm::Twine)llvm::toUpper(str[0]) + str.drop_front()).str();
+}
+
 void DAP::PopulateExceptionBreakpoints() {
   llvm::call_once(init_exception_breakpoints_flag, [this]() {
 exception_breakpoints = std::vector {};
-
+

walter-erquinigo wrote:

This one doesn't affect git blame history. It should be fine :)

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


[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)

2024-07-08 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/97871

>From aa2ad3b675f67581dde07a476725d2574fc6e7da Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 5 Jul 2024 20:30:44 -0400
Subject: [PATCH] [lldb-dap] Support throw and catch exception breakpoints for
 dynamically registered languages

First of all, this is done to support exceptions for the Mojo language, but 
it's done in a way that will benefit any other plugin language.

1. I added a new lldb-dap CLI argument (not DAP field) called 
`pre-init-commands`. These commands are executed before DAP initialization. The 
other `init-commands` are executed after DAP initialization. It's worth 
mentioning that the debug adapter returns to VSCode the list of supported 
exception breakpoints during DAP initialization, which means that I need to 
register the Mojo plugin before that initialization step, hence the need for 
`pre-init-commands`. In general, language plugins should be registered in that 
step, as they affect the capabilities of the debugger.
2. I added a set of APIs for lldb-dap to query information of each language 
related to exception breakpoints. E.g. whether a language supports throw or 
catch breakpoints, how the throw keyword is called in each particular language, 
etc.
3. I'm realizing that the Swift support for exception breakpoints in lldb-dap 
should have been implemented in this way, instead of hardcoding it.
---
 lldb/include/lldb/API/SBLanguageRuntime.h | 26 +++
 lldb/include/lldb/Target/Language.h   |  8 
 lldb/source/API/SBLanguageRuntime.cpp | 40 +
 lldb/tools/lldb-dap/DAP.cpp   | 54 ++-
 lldb/tools/lldb-dap/DAP.h |  2 +
 lldb/tools/lldb-dap/Options.td|  8 
 lldb/tools/lldb-dap/lldb-dap.cpp  | 19 ++--
 7 files changed, 153 insertions(+), 4 deletions(-)

diff --git a/lldb/include/lldb/API/SBLanguageRuntime.h 
b/lldb/include/lldb/API/SBLanguageRuntime.h
index 38aac05d490c1..acdc256fa2ac5 100644
--- a/lldb/include/lldb/API/SBLanguageRuntime.h
+++ b/lldb/include/lldb/API/SBLanguageRuntime.h
@@ -18,6 +18,32 @@ class SBLanguageRuntime {
   static lldb::LanguageType GetLanguageTypeFromString(const char *string);
 
   static const char *GetNameForLanguageType(lldb::LanguageType language);
+
+  /// Returns whether the given language is any version of  C++.
+  static bool LanguageIsCPlusPlus(lldb::LanguageType language);
+
+  /// Returns whether the given language is Obj-C or Obj-C++.
+  static bool LanguageIsObjC(lldb::LanguageType language);
+
+  /// Returns whether the given language is any version of C, C++ or Obj-C.
+  static bool LanguageIsCFamily(lldb::LanguageType language);
+
+  /// Returns whether the given language supports exception breakpoints on
+  /// throw statements.
+  static bool SupportsExceptionBreakpointsOnThrow(lldb::LanguageType language);
+
+  /// Returns whether the given language supports exception breakpoints on
+  /// catch statements.
+  static bool SupportsExceptionBreakpointsOnCatch(lldb::LanguageType language);
+
+  /// Returns the keyword used for throw statements in the given language, e.g.
+  /// Python uses \b raise. Returns \b nullptr if the language is not 
supported.
+  static const char *GetThrowKeywordForLanguage(lldb::LanguageType language);
+
+  /// Returns the keyword used for catch statements in the given language, e.g.
+  /// Python uses \b except. Returns \b nullptr if the language is not
+  /// supported.
+  static const char *GetCatchKeywordForLanguage(lldb::LanguageType language);
 };
 
 } // namespace lldb
diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index 83bf7635e369a..41d8eeef469ea 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -371,6 +371,14 @@ class Language : public PluginInterface {
   /// a corresponding LanguageRuntime plugin.
   virtual bool SupportsExceptionBreakpointsOnCatch() const { return false; }
 
+  /// Returns the keyword used for throw statements in this language, e.g.
+  /// Python uses \b raise. Defaults to \b throw.
+  virtual llvm::StringRef GetThrowKeyword() const { return "throw"; }
+
+  /// Returns the keyword used for catch statements in this language, e.g.
+  /// Python uses \b except. Defaults to \b catch.
+  virtual llvm::StringRef GetCatchKeyword() const { return "catch"; }
+
 protected:
   // Classes that inherit from Language can see and modify these
 
diff --git a/lldb/source/API/SBLanguageRuntime.cpp 
b/lldb/source/API/SBLanguageRuntime.cpp
index d571f282fce03..8599c2598b9fb 100644
--- a/lldb/source/API/SBLanguageRuntime.cpp
+++ b/lldb/source/API/SBLanguageRuntime.cpp
@@ -26,3 +26,43 @@ SBLanguageRuntime::GetNameForLanguageType(lldb::LanguageType 
language) {
 
   return Language::GetNameForLanguageType(language);
 }
+
+bool SBLanguageRuntime::LanguageIsCPlusPlus(lldb::LanguageType language) {
+  return Lang

[Lldb-commits] [lldb] [lldb] Correct invalid format style (PR #98089)

2024-07-08 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


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


[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)

2024-07-10 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

This is a very benign change, so I'll be merging it. Happy to make change 
post-merge if anyone provides any feedback.

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


[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)

2024-07-10 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] Support single stopped event in lldb-dap (PR #98568)

2024-07-12 Thread Walter Erquinigo via lldb-commits


@@ -0,0 +1,91 @@
+"""
+Test lldb-dap setBreakpoints request
+"""
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+import lldbdap_testcase
+from lldbsuite.test import lldbutil
+
+
+class TestDAP_stopEvents(lldbdap_testcase.DAPTestCaseBase):
+@skipIfWindows
+@skipIfRemote

walter-erquinigo wrote:

You don't need `@skipIfRemote`. That decorator is automatically applied to all 
DAP functions.

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


[Lldb-commits] [lldb] Add lldb version into initialize response lldb-dap (PR #98703)

2024-07-15 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] Add lldb version into initialize response lldb-dap (PR #98703)

2024-07-15 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo requested changes to this pull request.


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


[Lldb-commits] [lldb] Add lldb version into initialize response lldb-dap (PR #98703)

2024-07-15 Thread Walter Erquinigo via lldb-commits


@@ -1710,6 +1710,8 @@ void request_initialize(const llvm::json::Object 
&request) {
   body.try_emplace("supportsLogPoints", true);
   // The debug adapter supports data watchpoints.
   body.try_emplace("supportsDataBreakpoints", true);
+  // Putting version string. Note: this is not part of DAP spec.
+  body.try_emplace("version", g_dap.debugger.GetVersionString());

walter-erquinigo wrote:

please call this `__lldb_version`. We tend to add the `__lldb` prefix to 
anything that is non-standard.

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


[Lldb-commits] [lldb] 27b2f4f - [LLDB] Revert #98351 and #98344

2024-07-15 Thread walter erquinigo via lldb-commits

Author: walter erquinigo
Date: 2024-07-15T23:00:17-04:00
New Revision: 27b2f4f861b8aeeabc4eb1a97649062de8fa3992

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

LOG: [LLDB] Revert #98351 and #98344

This reverts commit 2fa1220a37a3f55b76a29803d8333b3a3937d53a.
This reverts commit b9496a74eb4029629ca2e440c5441614e766f773.

The patch #98344 causes a crash in LLDB when parsing some files like 
`numpy.libs/libgfortran-daac5196.so.5.0.0` on graviton (you can download it in 
https://drive.google.com/file/d/12ygLjJwWpzdYsrzBPp1JGiFHxcgM0-XY/view?usp=drive_link
 if you want to troubleshoot yourself).

The assert that is hit is the following:

```
llvm-project/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2452: 
std::pair 
> ObjectFileELF::ParseSymbolTable(lldb_private::Symtab*, lldb::user_id_t, 
lldb_private::Section*): Assertion `strtab->GetObjectFile() == this' failed.
[383588:383636:20240716,025305.572639:ERROR crashpad_client_linux.cc:780] 
Crashpad isn't enabled
```

This object file doesn't have apparently a strings table but LLDB still tries 
to process it due to the code that is being reverted.

Added: 


Modified: 
lldb/include/lldb/Host/Config.h.cmake
lldb/packages/Python/lldbsuite/test/decorators.py
lldb/packages/Python/lldbsuite/test/make/Makefile.rules
lldb/source/API/SBDebugger.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolLocator/CMakeLists.txt
lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp

Removed: 
lldb/test/API/debuginfod/Normal/Makefile
lldb/test/API/debuginfod/Normal/TestDebuginfod.py
lldb/test/API/debuginfod/Normal/main.c
lldb/test/API/debuginfod/SplitDWARF/Makefile
lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py
lldb/test/API/debuginfod/SplitDWARF/main.c



diff  --git a/lldb/include/lldb/Host/Config.h.cmake 
b/lldb/include/lldb/Host/Config.h.cmake
index 9e538534086a2..3defa454f6d42 100644
--- a/lldb/include/lldb/Host/Config.h.cmake
+++ b/lldb/include/lldb/Host/Config.h.cmake
@@ -33,8 +33,6 @@
 
 #cmakedefine01 LLDB_ENABLE_LZMA
 
-#cmakedefine01 LLVM_ENABLE_CURL
-
 #cmakedefine01 LLDB_ENABLE_CURSES
 
 #cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H

diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index 0e8ca159efd55..ecc7b81035f11 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -1053,10 +1053,6 @@ def _get_bool_config_skip_if_decorator(key):
 return unittest.skipIf(not have, "requires " + key)
 
 
-def skipIfCurlSupportMissing(func):
-return _get_bool_config_skip_if_decorator("curl")(func)
-
-
 def skipIfCursesSupportMissing(func):
 return _get_bool_config_skip_if_decorator("curses")(func)
 

diff  --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index d1a2de8b2478a..3d562285ce9cc 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -51,7 +51,7 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 #
 # GNUWin32 uname gives "windows32" or "server version windows32" while
 # some versions of MSYS uname return "MSYS_NT*", but most environments
-# standardize on "Windows_NT", so we'll make it consistent here.
+# standardize on "Windows_NT", so we'll make it consistent here. 
 # When running tests from Visual Studio, the environment variable isn't
 # inherited all the way down to the process spawned for make.
 #--
@@ -213,12 +213,6 @@ else
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
DSYM = $(EXE).debug
endif
-
-   ifeq "$(MAKE_DWP)" "YES"
-   MAKE_DWO := YES
-   DWP_NAME = $(EXE).dwp
-   DYLIB_DWP_NAME = $(DYLIB_NAME).dwp
-   endif
 endif
 
 LIMIT_DEBUG_INFO_FLAGS =
@@ -367,17 +361,6 @@ ifneq "$(OS)" "Darwin"
 
OBJCOPY ?= $(call replace_cc_with,objcopy)
ARCHIVER ?= $(call replace_cc_with,ar)
-   # Look for llvm-dwp or gnu dwp
-   DWP ?= $(call replace_cc_with,llvm-dwp)
-   ifeq ($(wildcard $(DWP)),)
-   DWP = $(call replace_cc_with,dwp)
-   ifeq ($(wildcard $(DWP)),)
-   DWP = $(shell command -v llvm-dwp 2> /dev/null)
-   ifeq ($(wildcard $(DWP)),)
-   DWP = $(shell command -v dwp 2> /dev/null)
-   endif
-   endif
-   endif
override AR = $(ARCHIVER)
 endif
 
@@ -548,10 +531,6 @@ ifneq "$(CXX)" ""
endif
 endif
 
-ifeq "$(GEN_GNU_BUILD_ID)" "YES"
-   LDF

[Lldb-commits] [lldb] [lldb] DebugInfoD tests & fixes (but with dwp testing disabled) (PR #98344)

2024-07-15 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

@kevinfrei , I'm so sorry to tell you that I have reverted this patch. The 
revert commit is 27b2f4f861b8aeeabc4eb1a97649062de8fa3992 and I left some notes 
there, which I also copy here:


The patch #98344 causes a crash in LLDB when parsing some files like 
`numpy.libs/libgfortran-daac5196.so.5.0.0` on graviton (you can download it in 
https://drive.google.com/file/d/12ygLjJwWpzdYsrzBPp1JGiFHxcgM0-XY/view?usp=drive_link
 if you want to troubleshoot yourself).

The assert that is hit is the following:

```
llvm-project/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2452: 
std::pair 
> ObjectFileELF::ParseSymbolTable(lldb_private::Symtab*, lldb::user_id_t, 
lldb_private::Section*): Assertion `strtab->GetObjectFile() == this' failed.
[383588:383636:20240716,025305.572639:ERROR crashpad_client_linux.cc:780] 
Crashpad isn't enabled


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


[Lldb-commits] [lldb] [lldb] DebugInfoD tests & fixes (but with dwp testing disabled) (PR #98344)

2024-07-16 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

@kevinfrei , I'm glad I can be of help to you! Let me know if you want me to 
try out your next iteration of this PR on my device.

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


[Lldb-commits] [lldb] [lldb][debuginfod] Fix the DebugInfoD PR that caused issues when working with stripped binaries (PR #99362)

2024-07-17 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

This LGTM, although I'd rather have someone like @clayborg taking a look

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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-07-20 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

This is very exciting!

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


[Lldb-commits] [lldb] [lldb-dap] Include npm install in the extension installation steps (PR #92028)

2024-05-13 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/92028

Otherwise the build step fails due to missing dependencies.


>From b065234db18dd726b4e39a98ac0c360e052fe438 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 13 May 2024 22:39:47 +0200
Subject: [PATCH] [lldb-dap] Include npm install in the extension installation
 steps

Otherwise the build step fails due to missing dependencies.
---
 lldb/tools/lldb-dap/README.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lldb/tools/lldb-dap/README.md b/lldb/tools/lldb-dap/README.md
index 274b1519208a1..16ce4672be71c 100644
--- a/lldb/tools/lldb-dap/README.md
+++ b/lldb/tools/lldb-dap/README.md
@@ -46,6 +46,7 @@ Installing the plug-in is very straightforward and involves 
just a few steps.
 
 ```bash
 cd /path/to/lldb/tools/lldb-dap
+npm install
 npm run package # This also compiles the extension.
 npm run vscode-install
 ```
@@ -69,6 +70,7 @@ no effect.
 ```bash
 # Bump version in package.json
 cd /path/to/lldb/tools/lldb-dap
+npm install
 npm run package
 npm run vscode-install
 ```

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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

2024-05-14 Thread Walter Erquinigo via lldb-commits


@@ -335,6 +335,37 @@ def cleanup():
 response["success"], "attach failed (%s)" % 
(response["message"])
 )
 
+def attach_by_port(

walter-erquinigo wrote:

could you just extend the `def attach` function? Having a totally new entry 
point just adds more maintainance burden when doing refactors.

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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

2024-05-14 Thread Walter Erquinigo via lldb-commits


@@ -0,0 +1,137 @@
+"""
+Test lldb-dap "port" configuration to "attach" request
+"""
+
+
+import dap_server
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+import lldbdap_testcase
+import os
+import shutil
+import subprocess
+import tempfile
+import threading
+import time
+import sys
+
+
+class TestDAP_attachByPortNum(lldbdap_testcase.DAPTestCaseBase):
+def runTargetProgramOnPort(self, port=None, program=None):
+server_tool = "lldb-server"

walter-erquinigo wrote:

lldb-server is available on linux, and gdbserver on mac, so you need to look 
for both depending on the situation.

@JDevlieghere , is there an SB API that we could use to get the path to the 
gdb-server that LLDB uses?

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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

2024-05-14 Thread Walter Erquinigo via lldb-commits


@@ -762,9 +765,31 @@ void request_attach(const llvm::json::Object &request) {
 // Disable async events so the attach will be successful when we return 
from
 // the launch call and the launch will happen synchronously
 g_dap.debugger.SetAsync(false);
-if (core_file.empty())
-  g_dap.target.Attach(attach_info, error);
-else
+if (core_file.empty()) {
+  if ((pid != LLDB_INVALID_PROCESS_ID) &&
+  (port != LLDB_INVALID_PORT_NUMBER)) {
+// If both pid and port numbers are specified.
+error.SetErrorString("The user can't specify both pid and port");
+  } else if ((port != LLDB_INVALID_PORT_NUMBER) && (port < UINT16_MAX)) {

walter-erquinigo wrote:

Remove `(port < UINT16_MAX)` so that we get a meaningful error from the 
connection logic. 

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


[Lldb-commits] [lldb] [lldb-dap] Correctly detect alias commands with arguments in repl (PR #92137)

2024-05-14 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


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


[Lldb-commits] [lldb] [lldb-dap] Updating VariableDescription to use GetDescription() as a fallback. (PR #77026)

2024-05-14 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

I don't think anything has changed on VSCode proper. I've just verified I have 
the same experience as you. Given what you said, I'm in favor of reverting this 
or at least gating this feature under a json initialization option until the 
original author can look at this.

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


[Lldb-commits] [lldb] [lldb-dap] Include npm install in the extension installation steps (PR #92028)

2024-05-15 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Support publishing to the VSCode market place (PR #92320)

2024-05-15 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

lgtm!

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


[Lldb-commits] [lldb] [lldb] Fixed an invalid error message in the DAP disconnect response (PR #92345)

2024-05-16 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


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


[Lldb-commits] [lldb] [lldb] Fixed the DAP tests in case of a remote target (PR #92398)

2024-05-16 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

2024-05-16 Thread Walter Erquinigo via lldb-commits


@@ -0,0 +1,146 @@
+"""
+Test lldb-dap "port" configuration to "attach" request
+"""
+
+
+import dap_server
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test import lldbplatformutil
+import lldbgdbserverutils
+import lldbdap_testcase
+import os
+import shutil
+import subprocess
+import tempfile
+import threading
+import time
+import sys
+
+
+class TestDAP_attachByPortNum(lldbdap_testcase.DAPTestCaseBase):
+def runTargetProgramOnPort(self, port=None, program=None):
+server_tool = None
+if lldbplatformutil.getPlatform() == "linux":
+server_tool = lldbgdbserverutils.get_lldb_server_exe()
+if server_tool is None:
+self.dap_server.request_disconnect(terminateDebuggee=True)
+self.assertIsNotNone(server_tool, "lldb-server not found.")
+server_tool += " g localhost:" + port + " "
+elif lldbplatformutil.getPlatform() == "macosx":
+server_tool = lldbgdbserverutils.get_debugserver_exe()
+if server_tool is None:
+self.dap_server.request_disconnect(terminateDebuggee=True)
+self.assertIsNotNone(server_tool, "debugserver not found.")
+server_tool += " --listen localhost:" + port + " "
+
+self.process = subprocess.Popen(
+[server_tool + program],
+shell=True,
+stdin=subprocess.PIPE,
+stdout=subprocess.PIPE,
+stderr=subprocess.PIPE,
+)
+
+return self.process
+
+def set_and_hit_breakpoint(self, continueToExit=True):
+source = "main.c"
+main_source_path = os.path.join(os.getcwd(), source)
+breakpoint1_line = line_number(main_source_path, "// breakpoint 1")
+lines = [breakpoint1_line]
+# Set breakpoint in the thread function so we can step the threads
+breakpoint_ids = self.set_source_breakpoints(main_source_path, lines)
+self.assertEqual(
+len(breakpoint_ids), len(lines), "expect correct number of 
breakpoints"
+)
+self.continue_to_breakpoints(breakpoint_ids)
+if continueToExit:
+self.continue_to_exit()
+
+@skipIfWindows
+@skipIfNetBSD  # Hangs on NetBSD as well

walter-erquinigo wrote:

This "as well" looks weird. Did you test it there in fact?

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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

2024-05-16 Thread Walter Erquinigo via lldb-commits


@@ -1572,6 +1572,15 @@ def findBuiltClang(self):
 
 return os.environ["CC"]
 
+def getBuiltinServerTool(self, server_tool):
+# Tries to find simulation/lldb-server/gdbserver tool at the same 
folder as the lldb.
+lldb_dir = os.path.dirname(lldbtest_config.lldbExec)
+path = shutil.which(server_tool, path=lldb_dir)
+if path is not None:
+return path
+
+return ""

walter-erquinigo wrote:

return None instead of an empty string

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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

2024-05-16 Thread Walter Erquinigo via lldb-commits


@@ -676,6 +676,8 @@ void request_attach(const llvm::json::Object &request) {
   auto arguments = request.getObject("arguments");
   const lldb::pid_t pid =
   GetUnsigned(arguments, "pid", LLDB_INVALID_PROCESS_ID);
+  const auto port = GetUnsigned(arguments, "port", LLDB_INVALID_PORT_NUMBER);
+  llvm::StringRef hostname = GetString(arguments, "hostname");

walter-erquinigo wrote:

you can here set the default to "localhost", which will simplify the logic below

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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

2024-05-16 Thread Walter Erquinigo via lldb-commits


@@ -0,0 +1,146 @@
+"""
+Test lldb-dap "port" configuration to "attach" request
+"""
+
+
+import dap_server
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test import lldbplatformutil
+import lldbgdbserverutils
+import lldbdap_testcase
+import os
+import shutil
+import subprocess
+import tempfile
+import threading
+import time
+import sys
+
+
+class TestDAP_attachByPortNum(lldbdap_testcase.DAPTestCaseBase):
+def runTargetProgramOnPort(self, port=None, program=None):
+server_tool = None
+if lldbplatformutil.getPlatform() == "linux":
+server_tool = lldbgdbserverutils.get_lldb_server_exe()
+if server_tool is None:
+self.dap_server.request_disconnect(terminateDebuggee=True)
+self.assertIsNotNone(server_tool, "lldb-server not found.")
+server_tool += " g localhost:" + port + " "
+elif lldbplatformutil.getPlatform() == "macosx":
+server_tool = lldbgdbserverutils.get_debugserver_exe()
+if server_tool is None:
+self.dap_server.request_disconnect(terminateDebuggee=True)
+self.assertIsNotNone(server_tool, "debugserver not found.")
+server_tool += " --listen localhost:" + port + " "

walter-erquinigo wrote:

could you move the logic that finds automatically the path to lldb-server or 
debugserver to lldbdap_testcase? This logic seems to be useful to reuse



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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

2024-05-16 Thread Walter Erquinigo via lldb-commits


@@ -0,0 +1,146 @@
+"""
+Test lldb-dap "port" configuration to "attach" request
+"""
+
+
+import dap_server
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test import lldbplatformutil
+import lldbgdbserverutils
+import lldbdap_testcase
+import os
+import shutil
+import subprocess
+import tempfile
+import threading
+import time
+import sys
+
+
+class TestDAP_attachByPortNum(lldbdap_testcase.DAPTestCaseBase):
+def runTargetProgramOnPort(self, port=None, program=None):
+server_tool = None
+if lldbplatformutil.getPlatform() == "linux":
+server_tool = lldbgdbserverutils.get_lldb_server_exe()
+if server_tool is None:
+self.dap_server.request_disconnect(terminateDebuggee=True)
+self.assertIsNotNone(server_tool, "lldb-server not found.")
+server_tool += " g localhost:" + port + " "
+elif lldbplatformutil.getPlatform() == "macosx":
+server_tool = lldbgdbserverutils.get_debugserver_exe()
+if server_tool is None:
+self.dap_server.request_disconnect(terminateDebuggee=True)
+self.assertIsNotNone(server_tool, "debugserver not found.")
+server_tool += " --listen localhost:" + port + " "
+
+self.process = subprocess.Popen(
+[server_tool + program],
+shell=True,
+stdin=subprocess.PIPE,
+stdout=subprocess.PIPE,
+stderr=subprocess.PIPE,
+)
+
+return self.process
+
+def set_and_hit_breakpoint(self, continueToExit=True):
+source = "main.c"
+main_source_path = os.path.join(os.getcwd(), source)
+breakpoint1_line = line_number(main_source_path, "// breakpoint 1")
+lines = [breakpoint1_line]
+# Set breakpoint in the thread function so we can step the threads
+breakpoint_ids = self.set_source_breakpoints(main_source_path, lines)
+self.assertEqual(
+len(breakpoint_ids), len(lines), "expect correct number of 
breakpoints"
+)
+self.continue_to_breakpoints(breakpoint_ids)
+if continueToExit:
+self.continue_to_exit()
+
+@skipIfWindows
+@skipIfNetBSD  # Hangs on NetBSD as well
+@skipIfRemote
+def test_by_port(self):
+"""
+Tests attaching to a process by port.
+"""
+self.build_and_create_debug_adaptor()
+program = self.getBuildArtifact("a.out")
+
+port = "2345"
+self.process = self.runTargetProgramOnPort(port=port, program=program)
+pid = self.process.pid
+response = self.attach(program=program, port=int(port), 
sourceInitFile=True)
+self.set_and_hit_breakpoint(continueToExit=True)
+self.process.kill()
+
+@skipIfWindows
+@skipIfNetBSD  # Hangs on NetBSD as well
+@skipIfRemote
+def test_by_port_and_pid(self):
+"""
+Tests attaching to a process by process ID and port number.
+"""
+self.build_and_create_debug_adaptor()
+program = self.getBuildArtifact("a.out")
+
+port = "2345"

walter-erquinigo wrote:

use a different port for each test, just in case the test runner executes them 
simultaneously

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


[Lldb-commits] [lldb] [lldb] Fixed the DAP tests in case of a remote target (PR #92416)

2024-05-16 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


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


[Lldb-commits] [lldb] [lldb-dap] Separate user and developer documentation (PR #92428)

2024-05-16 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

beautiful

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


[Lldb-commits] [lldb] [lldb] Fixed the DAP tests in case of a remote target (PR #92416)

2024-05-17 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

That's a great idea. There's no such `dap` category at the moment, but it would 
be nice if such category is created as part of the ongoing lldb-dap test fixes.

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


[Lldb-commits] [lldb] [lldb-dap] Updating VariableDescription to use GetDescription() as a fallback. (PR #77026)

2024-05-17 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

I'm okay with anything that ensures hovering is fast.

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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

2024-05-17 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

Thanks, @labath , for chiming in. I actually agree with all your points.

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


[Lldb-commits] [lldb] [lldb-dap] Don't send expanded descriptions for "hover" expressions (PR #92726)

2024-05-20 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


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


[Lldb-commits] [lldb] Change GetChildCompilerTypeAtIndex to return Expected (NFC) (PR #92979)

2024-05-22 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

Pretty nice! This will be useful for Mojo as well

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


[Lldb-commits] [lldb] [lldb] Fixed the TestDebuggerAPI test on x86_64 Windows host (PR #90580)

2024-05-24 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


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


[Lldb-commits] [lldb] [lldb-dap] Don't call GetNumChildren on non-indexed synthetic variables (PR #93534)

2024-05-28 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

Thanks for doing this.
Btw, that was a clever way of testing this functionality.

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


[Lldb-commits] [lldb] [lldb-dap] Add timestamps to protocol logs (PR #93540)

2024-05-28 Thread Walter Erquinigo via lldb-commits


@@ -103,7 +103,9 @@ void DAP::SendJSON(const llvm::json::Value &json) {
   SendJSON(json_str);
 
   if (log) {
-*log << "<-- " << std::endl
+auto now = std::chrono::duration(
+std::chrono::system_clock::now().time_since_epoch());

walter-erquinigo wrote:

wouldn't it be better to use steady_clock? that's more stable for benchmarking

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


[Lldb-commits] [lldb] [lldb-dap] Add timestamps to protocol logs (PR #93540)

2024-05-28 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

sounds good then!

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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

2024-05-28 Thread Walter Erquinigo via lldb-commits


@@ -749,9 +752,30 @@ void request_attach(const llvm::json::Object &request) {
 // Disable async events so the attach will be successful when we return 
from
 // the launch call and the launch will happen synchronously
 g_dap.debugger.SetAsync(false);
-if (core_file.empty())
-  g_dap.target.Attach(attach_info, error);
-else
+if (core_file.empty()) {
+  if ((pid != LLDB_INVALID_PROCESS_ID) && (port != invalid_port)) {
+// If both pid and port numbers are specified.
+error.SetErrorString("The user can't specify both pid and port");
+  } else if (port != invalid_port) {
+// If port is specified and pid is not.
+lldb::SBListener listener = g_dap.debugger.GetListener();
+
+// If the user hasn't provided the hostname property, default localhost
+// being used.
+std::string connect_url("connect://localhost:");
+
+// If the user has provided hostname other than localhost.
+if (!hostname.empty() && !hostname.starts_with("localhost")) {

walter-erquinigo wrote:

wouldn't it just work with `localhost` being passed to `llvm::formatv`?

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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

2024-05-28 Thread Walter Erquinigo via lldb-commits


@@ -0,0 +1,142 @@
+"""
+Test lldb-dap "port" configuration to "attach" request
+"""
+
+
+import dap_server
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test import lldbplatformutil
+import lldbgdbserverutils
+import lldbdap_testcase
+import os
+import shutil
+import subprocess
+import tempfile
+import threading
+import time
+import sys
+import socket
+
+
+class TestDAP_attachByPortNum(lldbdap_testcase.DAPTestCaseBase):
+def get_free_port(self):
+s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+s.bind(("", 0))
+port = s.getsockname()[1]
+s.close()
+return port
+
+def runTargetProgramOnPort(self, port=None, program=None):
+server_tool = self.getBuiltinServerToolWithPortArg(port)
+self.process = subprocess.Popen(
+[server_tool + program],
+shell=True,
+stdin=subprocess.PIPE,
+stdout=subprocess.PIPE,
+stderr=subprocess.PIPE,
+)
+
+return self.process
+
+def set_and_hit_breakpoint(self, continueToExit=True):
+source = "main.c"
+main_source_path = os.path.join(os.getcwd(), source)
+breakpoint1_line = line_number(main_source_path, "// breakpoint 1")
+lines = [breakpoint1_line]
+# Set breakpoint in the thread function so we can step the threads
+breakpoint_ids = self.set_source_breakpoints(main_source_path, lines)
+self.assertEqual(
+len(breakpoint_ids), len(lines), "expect correct number of 
breakpoints"
+)
+self.continue_to_breakpoints(breakpoint_ids)
+if continueToExit:
+self.continue_to_exit()
+
+@skipIfWindows
+@skipIfNetBSD
+@skipIfRemote
+def test_by_port(self):
+"""
+Tests attaching to a process by port.
+"""
+self.build_and_create_debug_adaptor()
+program = self.getBuildArtifact("a.out")
+
+port = self.get_free_port()
+self.process = self.runTargetProgramOnPort(port=port, program=program)
+pid = self.process.pid
+response = self.attach(program=program, port=port, sourceInitFile=True)
+self.set_and_hit_breakpoint(continueToExit=True)
+self.process.kill()
+
+@skipIfWindows
+@skipIfNetBSD
+@skipIfRemote
+def test_by_port_and_pid(self):
+"""
+Tests attaching to a process by process ID and port number.
+"""
+self.build_and_create_debug_adaptor()
+program = self.getBuildArtifact("a.out")
+
+port = self.get_free_port()
+self.process = self.runTargetProgramOnPort(port=port, program=program)
+pid = self.process.pid
+response = self.attach(
+program=program,
+pid=pid,
+port=port,
+sourceInitFile=True,
+expectFailure=True,
+)
+if not (response and response["success"]):
+self.assertFalse(
+response["success"], "The user can't specify both pid and port"
+)
+self.process.kill()
+
+@skipIfWindows
+@skipIfNetBSD
+@skipIfRemote

walter-erquinigo wrote:

you don't need `@skipIfRemote` anymore

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


[Lldb-commits] [lldb] Fix flaky TestDAP_console test. (PR #94494)

2024-06-05 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


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


[Lldb-commits] [lldb] Fix flaky TestDAP_console test. (PR #94494)

2024-06-07 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

Jonas' suggestion is pretty good. Please do that. Probably something like this 
would work

`
def collect_console(timeout_secs=10, check_interval_secs=1):
 ...
`

Then you can just update every caller of this function to just do 
`collect_console()`

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


[Lldb-commits] [lldb] Fix flaky TestDAP_console test. (PR #94494)

2024-06-10 Thread Walter Erquinigo via lldb-commits


@@ -467,5 +467,5 @@ def test_terminate_commands(self):
 # Once it's disconnected the console should contain the
 # "terminateCommands"
 self.dap_server.request_disconnect(terminateDebuggee=True)
-output = self.collect_console(duration=1.0)
+output = self.collect_console(timeout_secs=1.0)

walter-erquinigo wrote:

add `terminateCommands` to the pattern

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


[Lldb-commits] [lldb] Fix flaky TestDAP_console test. (PR #94494)

2024-06-10 Thread Walter Erquinigo via lldb-commits


@@ -75,6 +75,6 @@ def 
test_command_directive_abort_on_error_attach_commands(self):
 attachCommands=["?!" + command_quiet, "!" + 
command_abort_on_error],
 expectFailure=True,
 )
-full_output = self.collect_console(duration=1.0)
+full_output = self.collect_console(timeout_secs=1.0)

walter-erquinigo wrote:

add `settings` to the pattern

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


[Lldb-commits] [lldb] Fix flaky TestDAP_console test. (PR #94494)

2024-06-10 Thread Walter Erquinigo via lldb-commits


@@ -47,7 +47,7 @@ def do_test_abort_on_error(
 postRunCommands=commands if use_post_run_commands else None,
 expectFailure=True,
 )
-full_output = self.collect_console(duration=1.0)
+full_output = self.collect_console(timeout_secs=1.0)

walter-erquinigo wrote:

add `settings` to the pattern

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


[Lldb-commits] [lldb] Fix flaky TestDAP_console test. (PR #94494)

2024-06-10 Thread Walter Erquinigo via lldb-commits


@@ -235,5 +235,5 @@ def test_terminate_commands(self):
 # Once it's disconnected the console should contain the
 # "terminateCommands"
 self.dap_server.request_disconnect(terminateDebuggee=True)
-output = self.collect_console(duration=1.0)
+output = self.collect_console(timeout_secs=1.0)

walter-erquinigo wrote:

add `terminateCommands` to the pattern

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


[Lldb-commits] [lldb] Fix flaky TestDAP_console test. (PR #94494)

2024-06-10 Thread Walter Erquinigo via lldb-commits


@@ -200,7 +200,7 @@ def test_commands(self):
 # Get output from the console. This should contain both the
 # "exitCommands" that were run after the second breakpoint was hit
 # and the "terminateCommands" due to the debugging session ending
-output = self.collect_console(duration=1.0)
+output = self.collect_console(timeout_secs=1.0)

walter-erquinigo wrote:

add `terminateCommands` to the pattern

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


[Lldb-commits] [lldb] Fix flaky TestDAP_console test. (PR #94494)

2024-06-10 Thread Walter Erquinigo via lldb-commits


@@ -337,7 +337,7 @@ def test_commands(self):
 # Get output from the console. This should contain both the
 # "exitCommands" that were run after the second breakpoint was hit
 # and the "terminateCommands" due to the debugging session ending
-output = self.collect_console(duration=1.0)
+output = self.collect_console(timeout_secs=1.0)

walter-erquinigo wrote:

add `terminateCommands` to the pattern

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


[Lldb-commits] [lldb] Fix flaky TestDAP_console test. (PR #94494)

2024-06-10 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

@mbucko , could you request commit access to Chris Latner? 

```
We grant commit access to contributors with a track record of submitting high 
quality patches. If you would like commit access, please send an email to 
[Chris](mailto:clattner%40llvm.org) with your GitHub username.
```

That would be very helpful in case you break the build bots and want to push a 
hot fix.

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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

2024-06-11 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

I'll review this today or tomorrow. Thanks for all the activity!

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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

2024-06-17 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

This LGTM

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


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

2024-06-25 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

I second everything that Pavel says. I think this would be the best approach. 
The existing frame var implementation is not that "smart", so it should be 
practical to fully replace it with the new DIL in its first stage. 
An additional consideration is that lldb-dap, which is being more and more 
frequently used, relies on `frame var` for executing most expressions. `expr` 
is just a fallback. Therefore, replacing `frame var` with DIL right away has 
the benefit of getting tested right away by all the lldb-dap users. 

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


[Lldb-commits] [lldb] [lldb-dap] Emit declarations along with variables (PR #74865)

2024-08-12 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

> FYI @walter-erquinigo: There is a proposal under discussion to add 
> first-class support for `declarationLocation` (and also `valueLocation`) to 
> the debug adapter protocol. See 
> [microsoft/debug-adapter-protocol#343](https://github.com/microsoft/debug-adapter-protocol/issues/343)

Man, that's amazing. I really hope that get merged

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


[Lldb-commits] [lldb] [LLDB][OSX] Add a fallback support exe directory (PR #103458)

2024-08-13 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/103458

LLDB on OSX is looking at a `bin` directory sibling to the `lib` one that 
contains liblldb for its supporting executables. This works well for CMake, 
however, for other build systems like bazel, it's not that easy to have that 
build structure, for which it's much easier to also use the `lib` directory as 
a fallback under the absence of `bin`.
This shouldn't break anything, but instead should make it a bit easier for LLDB 
to work with different build systems and folder structures.


>From b011e77a937f4279295c55169c6d3049bfe2eaa2 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Tue, 13 Aug 2024 17:09:38 -0400
Subject: [PATCH] [LLDB][OSX] Add a fallback support exe directory

LLDB on OSX is looking at a `bin` directory sibling to the `lib` one that 
contains liblldb for its supporting executables. This works well for CMake, 
however, for other build systems like bazel, it's not that easy to have that 
build structure, for which it's much easier to also use the `lib` directory as 
a fallback under the absence of `bin`.
This shouldn't break anything, but instead should make it a bit easier for LLDB 
to work with different build systems and folder structures.
---
 .../Host/macosx/objcxx/HostInfoMacOSX.mm  | 24 ++-
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index f96e2cf80c5fac..02d02a21ad0955 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -124,6 +124,12 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   return g_program_filespec;
 }
 
+/// Resolve the given candidate support dir and return true if it's valid.
+static bool ResolveAndVerifyCandidateSupportDir(FileSpec &path) {
+  FileSystem::Instance().Resolve(path);
+  return FileSystem::Instance().IsDirectory(path);
+};
+
 bool HostInfoMacOSX::ComputeSupportExeDirectory(FileSpec &file_spec) {
   FileSpec lldb_file_spec = GetShlibDir();
   if (!lldb_file_spec)
@@ -144,16 +150,22 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
 #endif
   } else {
 // Find the bin path relative to the lib path where the cmake-based
-// OS X .dylib lives.  This is not going to work if the bin and lib
-// dir are not both in the same dir.
+// OS X .dylib lives. We try looking first at a possible sibling `bin`
+// directory, and then at the `lib` directory itself.
 //
-// It is not going to work to do it by the executable path either,
+// It is not going to work to do it by the executable path,
 // as in the case of a python script, the executable is python, not
 // the lldb driver.
+FileSpec support_dir_spec_lib(raw_path);
 raw_path.append("/../bin");
-FileSpec support_dir_spec(raw_path);
-FileSystem::Instance().Resolve(support_dir_spec);
-if (!FileSystem::Instance().IsDirectory(support_dir_spec)) {
+FileSpec support_dir_spec_bin(raw_path);
+FileSpec support_dir_spec;
+
+if (ResolveAndVerifyCandidateSupportDir(support_dir_spec_bin)) {
+  support_dir_spec = support_dir_spec_bin;
+} else if (ResolveAndVerifyCandidateSupportDir(support_dir_spec_lib)) {
+  support_dir_spec = support_dir_spec_lib;
+} else {
   Log *log = GetLog(LLDBLog::Host);
   LLDB_LOG(log, "failed to find support directory");
   return false;

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


[Lldb-commits] [lldb] [LLDB][OSX] Add a fallback support exe directory (PR #103458)

2024-08-14 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/103458

>From 656486aa0854db82ace6bee0639ca1d94f7b4fc5 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Tue, 13 Aug 2024 17:09:38 -0400
Subject: [PATCH] [LLDB][OSX] Add a fallback support exe directory

LLDB on OSX is looking at a `bin` directory sibling to the `lib` one that 
contains liblldb for its supporting executables. This works well for CMake, 
however, for other build systems like bazel, it's not that easy to have that 
build structure, for which it's much easier to also use the `lib` directory as 
a fallback under the absence of `bin`.
This shouldn't break anything, but instead should make it a bit easier for LLDB 
to work with different build systems and folder structures.
---
 .../Host/macosx/objcxx/HostInfoMacOSX.mm  | 28 ++-
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index f96e2cf80c5fac..b714f7be187aca 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -124,6 +124,12 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   return g_program_filespec;
 }
 
+/// Resolve the given candidate support dir and return true if it's valid.
+static bool ResolveAndVerifyCandidateSupportDir(FileSpec &path) {
+  FileSystem::Instance().Resolve(path);
+  return FileSystem::Instance().IsDirectory(path);
+};
+
 bool HostInfoMacOSX::ComputeSupportExeDirectory(FileSpec &file_spec) {
   FileSpec lldb_file_spec = GetShlibDir();
   if (!lldb_file_spec)
@@ -144,16 +150,24 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
 #endif
   } else {
 // Find the bin path relative to the lib path where the cmake-based
-// OS X .dylib lives.  This is not going to work if the bin and lib
-// dir are not both in the same dir.
+// OS X .dylib lives. We try looking first at a possible sibling `bin`
+// directory, and then at the `lib` directory itself. This last case is
+// useful for supporting build systems like Bazel which in many cases 
prefer
+// to place support binaries right next to dylibs.
 //
-// It is not going to work to do it by the executable path either,
+// It is not going to work to do it by the executable path,
 // as in the case of a python script, the executable is python, not
 // the lldb driver.
-raw_path.append("/../bin");
-FileSpec support_dir_spec(raw_path);
-FileSystem::Instance().Resolve(support_dir_spec);
-if (!FileSystem::Instance().IsDirectory(support_dir_spec)) {
+FileSpec support_dir_spec_lib(raw_path);
+FileSpec support_dir_spec_bin =
+support_dir_spec_lib.CopyByAppendingPathComponent("/../bin");
+FileSpec support_dir_spec;
+
+if (ResolveAndVerifyCandidateSupportDir(support_dir_spec_bin)) {
+  support_dir_spec = support_dir_spec_bin;
+} else if (ResolveAndVerifyCandidateSupportDir(support_dir_spec_lib)) {
+  support_dir_spec = support_dir_spec_lib;
+} else {
   Log *log = GetLog(LLDBLog::Host);
   LLDB_LOG(log, "failed to find support directory");
   return false;

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


[Lldb-commits] [lldb] [LLDB][OSX] Add a fallback support exe directory (PR #103458)

2024-08-14 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Provide `declarationLocation` for variables (PR #102928)

2024-08-14 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

@vogelsgesang , Mr. Bird, I'm swamped this week with work, but I'll look into 
this before saturday for sure.

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


[Lldb-commits] [lldb] [lldb-dap] Expose log path in extension settings (PR #103482)

2024-08-14 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

nice!

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


[Lldb-commits] [lldb] [lldb-dap] Support inspecting memory (PR #104317)

2024-08-14 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

@clayborg you'll be happy to review this

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


[Lldb-commits] [lldb] [lldb-dap] Support inspecting memory (PR #104317)

2024-08-14 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

@vogelsgesang can you share a screenshot?

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


[Lldb-commits] [lldb] [LLDB][OSX] Removed semi colon generating a warning during build (PR #104398)

2024-08-14 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


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


[Lldb-commits] [lldb] [LLDB][OSX] Removed semi colon generating a warning during build (PR #104398)

2024-08-14 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [LLDB][OSX] Removed semi colon generating a warning during build (PR #104398)

2024-08-14 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

Thank you!

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-15 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

This seems pretty cool! 
Question: what would happen if the top frame (the one with the PC) gets 
filtered out by the recognizer?

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


  1   2   3   4   5   6   7   8   9   10   >