[Lldb-commits] [PATCH] D113789: Add the ability to cache information for a module between debugger instances.

2021-11-16 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D113789#3133205 , @clayborg wrote:

> In D113789#3130741 , @labath wrote:
>
>> Maybe it's good for starting a discussion, but I am surprised that we would 
>> need to cache symtab information. This is a fairly simple format that needs 
>> to be read at application runtime as well, so I am surprised that reading it 
>> from the cache is substantially faster than doing it from the object file. 
>> What is the slow part there? Is it demangling by any chance?
>
> Symbol tables for LLDB are made up by scouring every bit of data we can out 
> of one or more symbol tables (ELF has normal symbol table and the dynamic 
> symbol table, and optionally the symbol table in the zipped debug info). 
> There are also many runtime sections like .eh_frame and [...]

Ok, you've convinced me. :) I completely forgot about all the things that go 
into these.

>> Now to the discussion. Overall, I think this is an interesting feature, but 
>> I do have some remarks/questions:
>>
>> - I don't think that  "lldb module cache" is very good name for this feature 
>> as we already have the "platform module cache" feature (see 
>> `Target/ModuleCache.h` and its callers), which deals with downloading (and 
>> caching) modules (object files) from remote systems. And then there's the 
>> clang module cache, of course.. (and the llvm modules, but we fortunately 
>> don't cache those). It would be better if we chose a slightly less 
>> overloaded name. Maybe "index cache" ? (I assume you will also want to store 
>> dwarf indexes there)
>
> yes debug info is the next item I want to put into this cache. "index cache" 
> sounds fine. I will rename once I get a few NFC patches submitted and rebase.
>
>> - I don't see anything which would ensure cache consistency for the case 
>> where multiple debugger instances try to cache the same module 
>> simultaneously. What's the plan for that?
>
> I was hoping to learn LLVM already had this kind of thing and using that! I 
> see below there are some things already in LLVM I should be able to use.
>
>> - Have you considered the building upon the caching infrastructure in llvm 
>> (`llvm/Caching.h`, `llvm/CachePruning.h`)? I believe it already has some 
>> size limiting features and multiprocess synchronization built-in, so using 
>> it would take care of the previous item, and of @wallace's size limit 
>> request.
>
> I will check into that and see if I can use that! I figured it would have 
> been done already, glad to see it has!

Cool. Thanks.

>> - it's moderately strange to be using the gsym file writer for this purpose
>
> When I made gsym I create the FileWriter as something that can easily create 
> binary content without having to go with the ASM print/writer stuff in LLVM 
> as that requires tons of stuff including LLVM targets and object file support.
>
> What suggestions do people have on this front? Should I make a patch to move 
> FileWriter out of GSYM? I don't know how if llvm::gym::FileWriter is useful 
> enough for other folks in LLVM. Any thoughts? Should we just make our own 
> FileWriter class that only does what we need for the caching? Is there any 
> other tech in LLVM that does this kind of thing without having to use the 
> full ARM printer/writer stuff?

The binary writing capabilities in llvm mostly take form of various free 
functions instead of a single rule-them-all class. This makes it hard to 
discover, which is probably the reason for the existence of 
gsym::FileWriter-type classes (the ObjectYAML library also has things like 
that.)   For binary endian-specific writing, there's llvm::endian::Writer in 
`llvm/Support/EndianStream.h`. It doesn't have anything fancy, but I don't 
think we need anything fancy here. The biggest thing it lacks is the ability to 
write a null-terminated string. We could make another free function for that, 
or maybe even add it to the raw_ostream interface (next to `write_zeroes`). I 
don't think you need them here, but there are [US]LEB128 writing functions in 
`llvm/Support/LEB128.h`.

We also have a DataEncoder class on the lldb side. It has (or could be made to 
have) all the writing capabilities you need, but it's not an exact fit because 
it's currently writing to a memory buffer. However, it only has a handful of 
uses, so I could imagine rafactoring it to work with `raw_ostream`s instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113789

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


[Lldb-commits] [PATCH] D113965: [NFC] Refactor symbol table parsing.

2021-11-16 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

This is a good cleanup independently of the caching feature.




Comment at: lldb/include/lldb/Symbol/ObjectFile.h:344
+  /// The symbol table to populate.
+  virtual void ParseSymtab(Symtab &symtab) = 0;
 

I guess this should be protected, as people shouldn't be calling it directly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113965

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


[Lldb-commits] [PATCH] D113098: [lldb] (Partially) enable formatting of utf strings before the program is started

2021-11-16 Thread Pavel Labath via Phabricator via lldb-commits
labath marked 7 inline comments as done.
labath added a comment.

Thanks for the review.




Comment at: lldb/include/lldb/Target/Target.h:1028
+  ///
+  /// This function will read a cache page at a time until a NULL string
+  /// terminator is found. It will stop reading if an aligned sequence of NULL

jingham wrote:
> ReadCStringFromMemory (both flavors) set "force_live_memory" to be true.  
> Note that doesn't mean "don't read from the target" it means "always read 
> from the process first."  It does fall back to the Target if there's no 
> process, AND if your Address is section relative.
> 
> OTOH, you make it a default argument and then set it to "false" - the 
> opposite behavior.  Is there a reason for that?  That seems confusing.
> 
> force_live_memory is really an efficiency thing.  It will only make a 
> difference if the data to be read is in a read-only section of a binary, in 
> which case it will read from there.  lldb always used to prefer reading 
> locally if it can, but if someone has been able to flip permissions and 
> overwrite read-only DATA through some kind of attack, you wouldn't be able to 
> see that if this is the default.  So in actual fact, we pass 
> force_live_memory -> true most of the places we use these Target Memory 
> Reading API's.
> 
> So it seems better to follow ReadCStringFromMemory and just force this to 
> true.
I changed the value to true.

However, I've have copied this pattern from `ReadMemory`, 
`ReadScalarIntegerFromMemory`, etc. Should we be setting the value to true for 
those functions as well?



Comment at: lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp:58
   StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
   options.SetLocation(valobj_addr);
+  options.SetTargetSP(valobj.GetTargetSP());

jingham wrote:
> This should take some form of lldb_private::Address not an lldb::addr_t or it 
> won't work pre-run.  See the overall comment for details.
I believe I've found the right incantation to do that. Please have a look at 
the new version.



Comment at: lldb/source/Target/Target.cpp:1922
+
+addr_t curr_addr = addr.GetLoadAddress(this);
+Address address = addr;

jingham wrote:
> This is wrong.  If the incoming address was section relative, you've thrown 
> that information away.  Just pass Target::ReadMemory the full Address (addr), 
> it will know what to do with it.  And you can use:
> 
> addr.Slide(bytes_read);
> 
> instead of lines 1951-1952 to update the address.
I've removed it. BTW, this was cargo-culted from 
`Target::ReadCStringFromMemory`, so it has the same bug. I'll create a patch to 
just delete that whole function



Comment at: lldb/source/Target/Target.cpp:1924
+Address address = addr;
+const size_t cache_line_size = 512;
+char *curr_dst = dst;

jingham wrote:
> This is a seemingly arbitrary choice.  
> 
> From what I can tell you are copying this from GetCStringFromMemory, so the 
> decision to do this isn't yours...
> 
> IIUC the whole point of this paging so we don't  read a big chunk of memory 
> and then find the terminator a couple of characters in.  The optimal size for 
> that doesn't have to line up with the process cache size, but I don't see why 
> you wouldn't use that if it was handy.
> 
>  Anyway, having this here with no comment is confusing.  Either repeat the 
> original justification or get the process cache line size if there's a 
> process.
I've created a helper function which returns a (properly alinged/rounded) size 
if we have a process, and a fixed value if we don't. Let me know what you think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113098

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


[Lldb-commits] [PATCH] D113098: [lldb] (Partially) enable formatting of utf strings before the program is started

2021-11-16 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 387543.
labath marked 4 inline comments as done.
labath added a comment.

New version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113098

Files:
  lldb/include/lldb/DataFormatters/FormattersHelpers.h
  lldb/include/lldb/DataFormatters/StringPrinter.h
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/Target/Target.h
  lldb/source/DataFormatters/FormattersHelpers.cpp
  lldb/source/DataFormatters/StringPrinter.cpp
  lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
  lldb/source/Plugins/Language/ObjC/NSString.cpp
  lldb/source/Target/Process.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py

Index: lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
===
--- lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
+++ lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
@@ -18,8 +18,24 @@
 def test(self):
 """Test that C++ supports char8_t correctly."""
 self.build()
-lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp"))
 
+lldbutil.run_to_breakpoint_make_target(self)
+
+# Make sure the variables can be printed without a running process.
+self.expect("target variable a", substrs=["char8_t", "0x61 u8'a'"])
+self.expect("target variable ab",
+substrs=["const char8_t *", 'u8"你好"'])
+self.expect("target variable abc", substrs=["char8_t[9]", 'u8"你好"'])
+
+self.expect_expr("a", result_type="char8_t", result_summary="0x61 u8'a'")
+self.expect_expr("ab", result_type="const char8_t *", result_summary='u8"你好"')
+# FIXME: This should work too.
+self.expect("expr abc", substrs=['u8"你好"'], matching=False)
+
+lldbutil.run_break_set_by_source_regexp(self, "// break here", "-f main.cpp")
+self.runCmd("run")
+
+# As well as with it
 self.expect_expr("a", result_type="char8_t", result_summary="0x61 u8'a'")
 self.expect_expr("ab", result_type="const char8_t *", result_summary='u8"你好"')
 self.expect_expr("abc", result_type="char8_t[9]", result_summary='u8"你好"')
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -1904,6 +1904,68 @@
   return total_cstr_len;
 }
 
+addr_t Target::GetReasonableReadSize(const Address &addr) {
+  addr_t load_addr = addr.GetLoadAddress(this);
+  if (load_addr != LLDB_INVALID_ADDRESS && m_process_sp) {
+// Avoid crossing cache line boundaries.
+addr_t cache_line_size = m_process_sp->GetMemoryCacheLineSize();
+return cache_line_size - (load_addr % cache_line_size);
+  }
+
+  // The read is going to go to the file cache, so we can just pick a largish
+  // value.
+  return 0x1000;
+}
+
+size_t Target::ReadStringFromMemory(const Address &addr, char *dst,
+size_t max_bytes, Status &error,
+size_t type_width, bool force_live_memory) {
+  if (!dst || !max_bytes || !type_width || max_bytes < type_width)
+return 0;
+
+  size_t total_bytes_read = 0;
+
+  // Ensure a null terminator independent of the number of bytes that is
+  // read.
+  memset(dst, 0, max_bytes);
+  size_t bytes_left = max_bytes - type_width;
+
+  const char terminator[4] = {'\0', '\0', '\0', '\0'};
+  assert(sizeof(terminator) >= type_width && "Attempting to validate a "
+ "string with more than 4 bytes "
+ "per character!");
+
+  Address address = addr;
+  char *curr_dst = dst;
+
+  error.Clear();
+  while (bytes_left > 0 && error.Success()) {
+addr_t bytes_to_read =
+std::min(bytes_left, GetReasonableReadSize(address));
+size_t bytes_read =
+ReadMemory(address, curr_dst, bytes_to_read, error, force_live_memory);
+
+if (bytes_read == 0)
+  break;
+
+// Search for a null terminator of correct size and alignment in
+// bytes_read
+size_t aligned_start = total_bytes_read - total_bytes_read % type_width;
+for (size_t i = aligned_start;
+ i + type_width <= total_bytes_read + bytes_read; i += type_width)
+  if (::memcmp(&dst[i], terminator, type_width) == 0) {
+error.Clear();
+return i;
+  }
+
+total_bytes_read += bytes_read;
+curr_dst += bytes_read;
+address.Slide(bytes_read);
+bytes_left -= bytes_read;
+  }
+  return total_bytes_read;
+}
+
 size_t Target::ReadScalarIntegerFromMemory(const Address &addr, uint32_t byte_size,
bool is_signed, Scalar &scalar,
Status &error,
Index: 

[Lldb-commits] [PATCH] D113893: [lldb/test] Move gdb client utils into the packages tree

2021-11-16 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG33c0f93f6c10: [lldb/test] Move gdb client utils into the 
packages tree (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113893

Files:
  lldb/packages/Python/lldbsuite/test/gdbclientutils.py
  lldb/packages/Python/lldbsuite/test/lldbgdbclient.py
  lldb/test/API/functionalities/gdb_remote_client/TestAArch64XMLRegOffsets.py
  lldb/test/API/functionalities/gdb_remote_client/TestArmRegisterDefinition.py
  lldb/test/API/functionalities/gdb_remote_client/TestFork.py
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
  
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteDiskFileCompletion.py
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
  lldb/test/API/functionalities/gdb_remote_client/TestIOSSimulator.py
  
lldb/test/API/functionalities/gdb_remote_client/TestJLink6Armv7RegisterDefinition.py
  lldb/test/API/functionalities/gdb_remote_client/TestMemoryRegionDirtyPages.py
  lldb/test/API/functionalities/gdb_remote_client/TestMultiprocess.py
  lldb/test/API/functionalities/gdb_remote_client/TestNestedRegDefinitions.py
  lldb/test/API/functionalities/gdb_remote_client/TestNoGPacketSupported.py
  lldb/test/API/functionalities/gdb_remote_client/TestNoWatchpointSupportInfo.py
  lldb/test/API/functionalities/gdb_remote_client/TestPartialGPacket.py
  lldb/test/API/functionalities/gdb_remote_client/TestPlatformClient.py
  lldb/test/API/functionalities/gdb_remote_client/TestPlatformKill.py
  lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
  lldb/test/API/functionalities/gdb_remote_client/TestPty.py
  lldb/test/API/functionalities/gdb_remote_client/TestQemuAArch64TargetXml.py
  lldb/test/API/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py
  lldb/test/API/functionalities/gdb_remote_client/TestRegDefinitionInParts.py
  lldb/test/API/functionalities/gdb_remote_client/TestRemoteRegNums.py
  lldb/test/API/functionalities/gdb_remote_client/TestRestartBug.py
  lldb/test/API/functionalities/gdb_remote_client/TestStopPCs.py
  lldb/test/API/functionalities/gdb_remote_client/TestTargetXMLArch.py
  lldb/test/API/functionalities/gdb_remote_client/TestThreadInfoTrailingComma.py
  lldb/test/API/functionalities/gdb_remote_client/TestThreadSelectionBug.py
  lldb/test/API/functionalities/gdb_remote_client/TestWasm.py
  lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py
  lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
  lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
@@ -1,11 +1,13 @@
 import lldb
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test.decorators import *
-from gdbclientutils import *
-
+from lldbsuite.test.gdbclientutils import *
+from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
 
 class TestqOffsets(GDBRemoteTestBase):
 
+mydir = TestBase.compute_mydir(__file__)
+
 class Responder(MockGDBServerResponder):
 def qOffsets(self):
 return 'Text=47;Data=47'
Index: lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py
@@ -1,11 +1,13 @@
 import lldb
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test.decorators import *
-from gdbclientutils import *
-
+from lldbsuite.test.gdbclientutils import *
+from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
 
 class TestWriteMemory(GDBRemoteTestBase):
 
+mydir = TestBase.compute_mydir(__file__)
+
 def test(self):
 
 class MyResponder(MockGDBServerResponder):
Index: lldb/test/API/functionalities/gdb_remote_client/TestWasm.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestWasm.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestWasm.py
@@ -2,7 +2,8 @@
 import binascii
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test.decorators import *
-from gdbclientutils import *
+from lldbsuite.test.gdbclientutils import *
+from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
 
 LLDB_INVALID_ADDRESS = lldb.LLDB_INVALID_ADDRESS
 load_address = 0x4
@@ -86,6 +87,8 @@
 
 class TestWasm(GDBRemoteTestBase):
 
+mydir = TestBase.compute_mydir(__fil

[Lldb-commits] [lldb] 33c0f93 - [lldb/test] Move gdb client utils into the packages tree

2021-11-16 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-11-16T11:35:56+01:00
New Revision: 33c0f93f6c10acff885fe11b9897943313cd5c26

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

LOG: [lldb/test] Move gdb client utils into the packages tree

This infrastructure has proven proven its worth, so give it a more
prominent place.

My immediate motivation for this is the desire to reuse this
infrastructure for qemu platform testing, but I believe this move makes
sense independently of that. Moving this code to the packages tree will
allow as to add more structure to the gdb client tests -- currently they
are all crammed into the same test folder as that was the only way they
could access this code.

I'm splitting the code into two parts while moving it. The first once
contains just the generic gdb protocol wrappers, while the other one
contains the unit test glue. The reason for that is that for qemu
testing, I need to run the gdb code in a separate process, so I will
only be using the first part there.

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

Added: 
lldb/packages/Python/lldbsuite/test/gdbclientutils.py
lldb/packages/Python/lldbsuite/test/lldbgdbclient.py

Modified: 
lldb/test/API/functionalities/gdb_remote_client/TestAArch64XMLRegOffsets.py
lldb/test/API/functionalities/gdb_remote_client/TestArmRegisterDefinition.py
lldb/test/API/functionalities/gdb_remote_client/TestFork.py
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py

lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteDiskFileCompletion.py
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
lldb/test/API/functionalities/gdb_remote_client/TestIOSSimulator.py

lldb/test/API/functionalities/gdb_remote_client/TestJLink6Armv7RegisterDefinition.py

lldb/test/API/functionalities/gdb_remote_client/TestMemoryRegionDirtyPages.py
lldb/test/API/functionalities/gdb_remote_client/TestMultiprocess.py
lldb/test/API/functionalities/gdb_remote_client/TestNestedRegDefinitions.py
lldb/test/API/functionalities/gdb_remote_client/TestNoGPacketSupported.py

lldb/test/API/functionalities/gdb_remote_client/TestNoWatchpointSupportInfo.py
lldb/test/API/functionalities/gdb_remote_client/TestPartialGPacket.py
lldb/test/API/functionalities/gdb_remote_client/TestPlatformClient.py
lldb/test/API/functionalities/gdb_remote_client/TestPlatformKill.py
lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
lldb/test/API/functionalities/gdb_remote_client/TestPty.py
lldb/test/API/functionalities/gdb_remote_client/TestQemuAArch64TargetXml.py
lldb/test/API/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py
lldb/test/API/functionalities/gdb_remote_client/TestRegDefinitionInParts.py
lldb/test/API/functionalities/gdb_remote_client/TestRemoteRegNums.py
lldb/test/API/functionalities/gdb_remote_client/TestRestartBug.py
lldb/test/API/functionalities/gdb_remote_client/TestStopPCs.py
lldb/test/API/functionalities/gdb_remote_client/TestTargetXMLArch.py

lldb/test/API/functionalities/gdb_remote_client/TestThreadInfoTrailingComma.py
lldb/test/API/functionalities/gdb_remote_client/TestThreadSelectionBug.py
lldb/test/API/functionalities/gdb_remote_client/TestWasm.py
lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py
lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py

Removed: 
lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py



diff  --git a/lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py 
b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py
similarity index 84%
rename from lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
rename to lldb/packages/Python/lldbsuite/test/gdbclientutils.py
index cc95564675b83..183e6a0c597a9 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
+++ b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py
@@ -1,17 +1,10 @@
 import ctypes
 import errno
 import io
-import os
-import os.path
 import threading
 import socket
-import lldb
-import binascii
 import traceback
 from lldbsuite.support import seven
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbtest_config
-
 
 def checksum(message):
 """
@@ -618,100 +611,3 @@ def _handlePacket(self, packet):
 class InvalidPacketException(Exception):
 pass
 
-
-class GDBRemoteTestBase(TestBase):
-"""
-Base class for GDB client tests.
-
-This class will setup and start a mock GDB server for the test to use.
-It al

[Lldb-commits] [PATCH] D113608: [lldb] Simplify specifying of platform supported architectures

2021-11-16 Thread Pavel Labath via Phabricator via lldb-commits
labath marked 2 inline comments as done.
labath added inline comments.



Comment at: lldb/source/Target/Platform.cpp:1217-1218
+std::vector
+Platform::CreateArchList(llvm::Triple::OSType os,
+ llvm::ArrayRef archs) {
+  std::vector list;

JDevlieghere wrote:
> labath wrote:
> > JDevlieghere wrote:
> > > In PlatformDarwin we set the vendor too. Could we have this take an 
> > > optional OSType and Vendor maybe that sets the ones that are not None? 
> > > That would also make migrating PlatformDarwin easier where we currently 
> > > share the code and don't set the OS. Later we could move this out of 
> > > PlatformDarwin into the child classes and have the OS set correctly. 
> > Umm.. maybe? I don't think this function is set in stone, but the nice 
> > thing about it being a helper function is that it's usage is completely 
> > optional. I haven't tried porting the darwin platforms yet, but, from a 
> > cursory glance I did see that they have a lot more complex usage patterns:
> > - they pass subarchitectures as well, so we'd either also need to have an 
> > Optional subarch field, or switch to passing architectures as strings (I 
> > mean, I suppose I could switch to strings now, but it feels more correct to 
> > work with named constants)
> > - a few of them also pass environments 
> > - and some don't even have matching OS fields (`x86_64-apple-macosx` and 
> > `arm64-apple-ios` in the same list)
> > 
> > So, I'd leave it to those patches to determine whether it's better to 
> > extend this function or create a new one.
> Okay, I'm happy to modify the helper when I start using it for the darwin 
> platfomrs. I think at least some of the complexity/inconsistencies is purely 
> historic such as the one where we were specifying an OS in the list of 
> supported architectures in PlatformDarwin. 
Cool. Does that mean I can count on you do convert the darwin platforms? :)

(I was going to try doing it myself, but I have basically no way of checking 
whether my modifications break anything.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113608

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


[Lldb-commits] [lldb] 669e57e - [lldb] Simplify specifying of platform supported architectures

2021-11-16 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-11-16T11:43:48+01:00
New Revision: 669e57ebd1a7137aba7aab47d9d4dd67e1b0b9a0

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

LOG: [lldb] Simplify specifying of platform supported architectures

The GetSupportedArchitectureAtIndex pattern forces the use of
complicated patterns in both the implementations of the function and in
the various callers.

This patch creates a new method (GetSupportedArchitectures), which
returns a list (vector) of architectures. The
GetSupportedArchitectureAtIndex is kept in order to enable incremental
rollout. Base Platform class contains implementations of both of these
methods, using the other method as the source of truth. Platforms
without infinite stacks should implement at least one of them.

This patch also ports Linux, FreeBSD and NetBSD platforms to the new
API. A new helper function (CreateArchList) is added to simplify the
common task of creating a list of ArchSpecs with the same OS but
different architectures.

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

Added: 


Modified: 
lldb/include/lldb/Target/Platform.h
lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
lldb/source/Plugins/Platform/Linux/PlatformLinux.h
lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
lldb/source/Target/Platform.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index 86c62140ba1ff..f3d88d6397d28 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -322,7 +322,13 @@ class Platform : public PluginInterface {
   /// \b true if \a arch was filled in and is valid, \b false
   /// otherwise.
   virtual bool GetSupportedArchitectureAtIndex(uint32_t idx,
-   ArchSpec &arch) = 0;
+   ArchSpec &arch);
+
+  /// Get the platform's supported architectures in the order in which they
+  /// should be searched.
+  /// NB: This implementation is mutually recursive with
+  /// GetSupportedArchitectureAtIndex. Subclasses should implement one of them.
+  virtual std::vector GetSupportedArchitectures();
 
   virtual size_t GetSoftwareBreakpointTrapOpcode(Target &target,
  BreakpointSite *bp_site);
@@ -876,6 +882,12 @@ class Platform : public PluginInterface {
   }
 
 protected:
+  /// Create a list of ArchSpecs with the given OS and a architectures. The
+  /// vendor field is left as an "unspecified unknown".
+  static std::vector
+  CreateArchList(llvm::ArrayRef archs,
+ llvm::Triple::OSType os);
+
   /// Private implementation of connecting to a process. If the stream is set
   /// we connect synchronously.
   lldb::ProcessSP DoConnectProcess(llvm::StringRef connect_url,

diff  --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp 
b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
index ffd92d4fb848d..754d06de7cb92 100644
--- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
+++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
@@ -111,72 +111,27 @@ void PlatformFreeBSD::Terminate() {
 /// Default Constructor
 PlatformFreeBSD::PlatformFreeBSD(bool is_host)
 : PlatformPOSIX(is_host) // This is the local host platform
-{}
-
-bool PlatformFreeBSD::GetSupportedArchitectureAtIndex(uint32_t idx,
-  ArchSpec &arch) {
-  if (IsHost()) {
+{
+  if (is_host) {
 ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
-if (hostArch.GetTriple().isOSFreeBSD()) {
-  if (idx == 0) {
-arch = hostArch;
-return arch.IsValid();
-  } else if (idx == 1) {
-// If the default host architecture is 64-bit, look for a 32-bit
-// variant
-if (hostArch.IsValid() && hostArch.GetTriple().isArch64Bit()) {
-  arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
-  return arch.IsValid();
-}
-  }
+m_supported_architectures.push_back(hostArch);
+if (hostArch.GetTriple().isArch64Bit()) {
+  m_supported_architectures.push_back(
+  HostInfo::GetArchitecture(HostInfo::eArchKind32));
 }
   } else {
-if (m_remote_platform_sp)
-  return m_remote_platform_sp->GetSupportedArchitectureAtIndex(idx, arch);
-
-llvm::Triple triple;
-// Set the OS to FreeBSD
-triple.setOS(llvm::Triple::FreeBSD);
-// Set the architecture
-switch (idx) {
-case 0:
-  triple.setArchName("x86_64");
- 

[Lldb-commits] [PATCH] D113608: [lldb] Simplify specifying of platform supported architectures

2021-11-16 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
labath marked an inline comment as done.
Closed by commit rG669e57ebd1a7: [lldb] Simplify specifying of platform 
supported architectures (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113608

Files:
  lldb/include/lldb/Target/Platform.h
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
  lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
  lldb/source/Plugins/Platform/Linux/PlatformLinux.h
  lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
  lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
  lldb/source/Target/Platform.cpp

Index: lldb/source/Target/Platform.cpp
===
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -1144,6 +1144,35 @@
   return platform_sp;
 }
 
+std::vector
+Platform::CreateArchList(llvm::ArrayRef archs,
+ llvm::Triple::OSType os) {
+  std::vector list;
+  for(auto arch : archs) {
+llvm::Triple triple;
+triple.setArch(arch);
+triple.setOS(os);
+list.push_back(ArchSpec(triple));
+  }
+  return list;
+}
+
+bool Platform::GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) {
+  const auto &archs = GetSupportedArchitectures();
+  if (idx >= archs.size())
+return false;
+  arch = archs[idx];
+  return true;
+}
+
+std::vector Platform::GetSupportedArchitectures() {
+  std::vector result;
+  ArchSpec arch;
+  for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(idx, arch); ++idx)
+result.push_back(arch);
+  return result;
+}
+
 /// Lets a platform answer if it is compatible with a given
 /// architecture and the target triple contained within.
 bool Platform::IsCompatibleArchitecture(const ArchSpec &arch,
Index: lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
===
--- lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
+++ lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
@@ -42,7 +42,7 @@
 
   void GetStatus(Stream &strm) override;
 
-  bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override;
+  std::vector GetSupportedArchitectures() override;
 
   uint32_t GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) override;
 
@@ -54,6 +54,8 @@
   lldb::addr_t length, unsigned prot,
   unsigned flags, lldb::addr_t fd,
   lldb::addr_t offset) override;
+
+  std::vector m_supported_architectures;
 };
 
 } // namespace platform_netbsd
Index: lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
===
--- lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
+++ lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
@@ -100,54 +100,24 @@
 /// Default Constructor
 PlatformNetBSD::PlatformNetBSD(bool is_host)
 : PlatformPOSIX(is_host) // This is the local host platform
-{}
-
-bool PlatformNetBSD::GetSupportedArchitectureAtIndex(uint32_t idx,
- ArchSpec &arch) {
-  if (IsHost()) {
+{
+  if (is_host) {
 ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
-if (hostArch.GetTriple().isOSNetBSD()) {
-  if (idx == 0) {
-arch = hostArch;
-return arch.IsValid();
-  } else if (idx == 1) {
-// If the default host architecture is 64-bit, look for a 32-bit
-// variant
-if (hostArch.IsValid() && hostArch.GetTriple().isArch64Bit()) {
-  arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
-  return arch.IsValid();
-}
-  }
+m_supported_architectures.push_back(hostArch);
+if (hostArch.GetTriple().isArch64Bit()) {
+  m_supported_architectures.push_back(
+  HostInfo::GetArchitecture(HostInfo::eArchKind32));
 }
   } else {
-if (m_remote_platform_sp)
-  return m_remote_platform_sp->GetSupportedArchitectureAtIndex(idx, arch);
-
-llvm::Triple triple;
-// Set the OS to NetBSD
-triple.setOS(llvm::Triple::NetBSD);
-// Set the architecture
-switch (idx) {
-case 0:
-  triple.setArchName("x86_64");
-  break;
-case 1:
-  triple.setArchName("i386");
-  break;
-default:
-  return false;
-}
-// Leave the vendor as "llvm::Triple:UnknownVendor" and don't specify the
-// vendor by calling triple.SetVendorName("unknown") so that it is a
-// "unspecified unknown". This means when someone calls
-// triple.GetVendorName() it will return an empty string which indicates
-// that the vendor can be set when two architectures are merged
-
-// Now set the triple into "arch" and return true
-arch.SetTriple(triple);
- 

[Lldb-commits] [lldb] 098c01c - [lldb] Refactor Platform::ResolveExecutable

2021-11-16 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-11-16T12:52:51+01:00
New Revision: 098c01c132c8d14f08b847793afa045af5bb4522

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

LOG: [lldb] Refactor Platform::ResolveExecutable

Module resolution is probably the most complex piece of lldb [citation
needed], with numerous levels of abstraction, each one implementing
various retry and fallback strategies.

It is also a very repetitive, with only small differences between
"host", "remote-and-connected" and "remote-but-not-(yet)-connected"
scenarios.

The goal of this patch (first in series) is to reduce the number of
abstractions, and deduplicate the code.

One of the reasons for this complexity is the tension between the desire
to offload the process of module resolution to the remote platform
instance (that's how most other platform methods work), and the desire
to keep it local to the outer platform class (its easier to subclass the
outer class, and it generally makes more sense).

This patch resolves that conflict in favour of doing everything in the
outer class. The gdb-remote (our only remote platform) implementation of
ResolveExecutable was not doing anything gdb-specific, and was rather
similar to the other implementations of that method (any divergence is
most likely the result of fixes not being applied everywhere rather than
intentional).

It does this by excising the remote platform out of the resolution
codepath. The gdb-remote implementation of ResolveExecutable is moved to
Platform::ResolveRemoteExecutable, and the (only) call site is
redirected to that. On its own, this does not achieve (much), but it
creates new opportunities for layer peeling and code sharing, since all
of the code now lives closer together.

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

Added: 


Modified: 
lldb/include/lldb/Target/Platform.h
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
lldb/source/Target/Platform.cpp
lldb/source/Target/RemoteAwarePlatform.cpp
lldb/unittests/Target/RemoteAwarePlatformTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index f3d88d6397d28..956b29e45dbab 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -943,8 +943,7 @@ class Platform : public PluginInterface {
   virtual void CalculateTrapHandlerSymbolNames() = 0;
 
   Status GetCachedExecutable(ModuleSpec &module_spec, lldb::ModuleSP 
&module_sp,
- const FileSpecList *module_search_paths_ptr,
- Platform &remote_platform);
+ const FileSpecList *module_search_paths_ptr);
 
   virtual Status DownloadModuleSlice(const FileSpec &src_file_spec,
  const uint64_t src_offset,
@@ -956,6 +955,11 @@ class Platform : public PluginInterface {
 
   virtual const char *GetCacheHostname();
 
+  virtual Status
+  ResolveRemoteExecutable(const ModuleSpec &module_spec,
+  lldb::ModuleSP &exe_module_sp,
+  const FileSpecList *module_search_paths_ptr);
+
 private:
   typedef std::function ModuleResolver;
 
@@ -969,8 +973,7 @@ class Platform : public PluginInterface {
 
   Status LoadCachedExecutable(const ModuleSpec &module_spec,
   lldb::ModuleSP &module_sp,
-  const FileSpecList *module_search_paths_ptr,
-  Platform &remote_platform);
+  const FileSpecList *module_search_paths_ptr);
 
   FileSpec GetModuleCacheRoot();
 };

diff  --git 
a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp 
b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index d0a8fc4ebf381..56e624ab982a8 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -89,76 +89,6 @@ llvm::StringRef PlatformRemoteGDBServer::GetDescription() {
   return GetDescriptionStatic();
 }
 
-Status PlatformRemoteGDBServer::ResolveExecutable(
-const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
-const FileSpecList *module_search_paths_ptr) {
-  // copied from PlatformRemoteiOS
-
-  Status error;
-  // Nothing special to do here, just use the actual file and architecture
-
-  ModuleSpec resolved_module_spec(module_spec);
-
-  // Resolve any executable within an apk on Android?
-  // Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
-
-  if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()) ||
-  module_spec.GetUUID()

[Lldb-commits] [PATCH] D113487: [lldb] Refactor Platform::ResolveExecutable

2021-11-16 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG098c01c132c8: [lldb] Refactor Platform::ResolveExecutable 
(authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113487

Files:
  lldb/include/lldb/Target/Platform.h
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
  lldb/source/Target/Platform.cpp
  lldb/source/Target/RemoteAwarePlatform.cpp
  lldb/unittests/Target/RemoteAwarePlatformTest.cpp

Index: lldb/unittests/Target/RemoteAwarePlatformTest.cpp
===
--- lldb/unittests/Target/RemoteAwarePlatformTest.cpp
+++ lldb/unittests/Target/RemoteAwarePlatformTest.cpp
@@ -31,6 +31,17 @@
ProcessSP(ProcessAttachInfo &, Debugger &, Target *, Status &));
   MOCK_METHOD0(CalculateTrapHandlerSymbolNames, void());
 
+  MOCK_METHOD2(ResolveRemoteExecutable,
+   std::pair(const ModuleSpec &,
+   const FileSpecList *));
+  Status ResolveRemoteExecutable(
+  const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
+  const FileSpecList *module_search_paths_ptr) /*override*/ {
+auto pair = ResolveRemoteExecutable(module_spec, module_search_paths_ptr);
+exe_module_sp = pair.second;
+return pair.first;
+  }
+
   void SetRemotePlatform(lldb::PlatformSP platform) {
 m_remote_platform_sp = platform;
   }
@@ -47,18 +58,6 @@
ProcessSP(ProcessAttachInfo &, Debugger &, Target *, Status &));
   MOCK_METHOD0(CalculateTrapHandlerSymbolNames, void());
   MOCK_METHOD0(GetUserIDResolver, UserIDResolver &());
-
-  MOCK_METHOD2(ResolveExecutable,
-   std::pair(const ModuleSpec &,
-   const FileSpecList *));
-  Status
-  ResolveExecutable(const ModuleSpec &module_spec,
-lldb::ModuleSP &exe_module_sp,
-const FileSpecList *module_search_paths_ptr) /*override*/ {
-auto pair = ResolveExecutable(module_spec, module_search_paths_ptr);
-exe_module_sp = pair.second;
-return pair.first;
-  }
 };
 
 namespace {
@@ -73,15 +72,13 @@
   ModuleSpec executable_spec;
   ModuleSP expected_executable(new Module(executable_spec));
 
-  auto platform_sp = std::make_shared(false);
-  EXPECT_CALL(*platform_sp, ResolveExecutable(_, _))
-  .WillRepeatedly(Return(std::make_pair(Status(), expected_executable)));
-
   RemoteAwarePlatformTester platform(false);
   EXPECT_CALL(platform, GetSupportedArchitectureAtIndex(_, _))
   .WillRepeatedly(Return(false));
+  EXPECT_CALL(platform, ResolveRemoteExecutable(_, _))
+  .WillRepeatedly(Return(std::make_pair(Status(), expected_executable)));
 
-  platform.SetRemotePlatform(platform_sp);
+  platform.SetRemotePlatform(std::make_shared(false));
 
   ModuleSP resolved_sp;
   lldb_private::Status status =
Index: lldb/source/Target/RemoteAwarePlatform.cpp
===
--- lldb/source/Target/RemoteAwarePlatform.cpp
+++ lldb/source/Target/RemoteAwarePlatform.cpp
@@ -72,8 +72,7 @@
   } else {
 if (m_remote_platform_sp) {
   return GetCachedExecutable(resolved_module_spec, exe_module_sp,
- module_search_paths_ptr,
- *m_remote_platform_sp);
+ module_search_paths_ptr);
 }
 
 // We may connect to a process and use the provided executable (Don't use
Index: lldb/source/Target/Platform.cpp
===
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -833,6 +833,7 @@
 lldb::ModuleSP &exe_module_sp,
 const FileSpecList *module_search_paths_ptr) {
   Status error;
+
   if (FileSystem::Instance().Exists(module_spec.GetFileSpec())) {
 if (module_spec.GetArchitecture().IsValid()) {
   error = ModuleList::GetSharedModule(module_spec, exe_module_sp,
@@ -855,9 +856,77 @@
   }
 }
   } else {
-error.SetErrorStringWithFormat("'%s' does not exist",
-   module_spec.GetFileSpec().GetPath().c_str());
+error.SetErrorStringWithFormat(
+"'%s' does not exist", module_spec.GetFileSpec().GetPath().c_str());
+  }
+  return error;
+}
+
+Status
+Platform::ResolveRemoteExecutable(const ModuleSpec &module_spec,
+lldb::ModuleSP &exe_module_sp,
+const FileSpecList *module_search_paths_ptr) {
+  Status error;
+
+  // We may connect to a process and use the provided executable (Don't use
+  // local $PATH).
+  ModuleSpec resolved_module_spec(module_spec);
+
+  // Resolve any executable within a bundle on MacOSX
+  Host::ResolveExecutableInB

[Lldb-commits] [PATCH] D113930: [LLDB][NativePDB] Fix function decl creation for class methods

2021-11-16 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp:1026
+/*mangled_name=*/nullptr, func_ct, lldb::AccessType::eAccessPublic,
+/*is_virtual=*/false, /*is_static=*/false,
+/*is_inline=*/false, /*is_explicit=*/false,

I see you are setting these fall to `false` are you planning on figuring out 
correct values for them eventually or is that handled somewhere else?

Also looking at what we do when we parse DWARF, we also set the 
`ClangASTMetadata` as well. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113930

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


[Lldb-commits] [lldb] 6424dc2 - Increase gdbremote timeout.

2021-11-16 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2021-11-16T09:09:55-08:00
New Revision: 6424dc21bf6b73645ef98a35417e0591b2a95939

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

LOG: Increase gdbremote timeout.

I'm still seeing random timeouts on green dragon.

Added: 


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

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 97a7543b5c1e..268ff70501a8 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -62,8 +62,8 @@ def test_method(self, attrvalue=attrvalue):
 @add_metaclass(GdbRemoteTestCaseFactory)
 class GdbRemoteTestCaseBase(Base):
 
-# Default time out in seconds. The timeout is increased tenfold under Asan.
-DEFAULT_TIMEOUT =  20 * (10 if ('ASAN_OPTIONS' in os.environ) else 1)
+# Default time out in seconds. The timeout is increased fivefold under 
Asan.
+DEFAULT_TIMEOUT =  60 * (5 if ('ASAN_OPTIONS' in os.environ) else 1)
 # Default sleep time in seconds. The sleep time is doubled under Asan.
 DEFAULT_SLEEP   =  5  * (2  if ('ASAN_OPTIONS' in os.environ) else 1)
 



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


[Lldb-commits] [lldb] 6e78cfb - typo

2021-11-16 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2021-11-16T09:09:55-08:00
New Revision: 6e78cfb28ab545b7367306d43f88f29202c0ae12

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

LOG: typo

Added: 


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

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 1999399b89bcd..97a7543b5c1ef 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -791,7 +791,7 @@ def wait_for_thread_count(self, thread_count):
 
 if time.time() > timeout_time:
 raise Exception(
-'timed out after {} seconds while waiting for theads: 
waiting for at least {} threads, found {}'.format(
+'timed out after {} seconds while waiting for threads: 
waiting for at least {} threads, found {}'.format(
 self.DEFAULT_TIMEOUT, thread_count, 
actual_thread_count))
 
 return threads



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


[Lldb-commits] [lldb] 948b36d - Skip tests on older versions of clang

2021-11-16 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2021-11-16T09:09:56-08:00
New Revision: 948b36d2582c9cde913e434bd22814f01e85bdd6

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

LOG: Skip tests on older versions of clang

Added: 


Modified: 
lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py

lldb/test/API/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py
lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py
lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py
lldb/test/API/lang/cpp/modules-import/TestCXXModulesImport.py
lldb/test/API/macosx/universal/TestUniversal.py

Removed: 




diff  --git 
a/lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py 
b/lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py
index f94bcae34cf93..b3a61191480b2 100644
--- 
a/lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py
+++ 
b/lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py
@@ -15,6 +15,7 @@ class ExprCommandCallFunctionTestCase(TestBase):
 compiler="icc",
 bugnumber="llvm.org/pr14437, fails with ICC 13.1")
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
+@skipIf(compiler="clang", compiler_version=['<', '9.0'])
 def test_with(self):
 """Test calling std::String member function."""
 self.build()

diff  --git 
a/lldb/test/API/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py
 
b/lldb/test/API/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py
index abc9c1931489f..5fba71d023fe5 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py
@@ -13,6 +13,7 @@ class TestUniquePtrDbgInfoContent(TestBase):
 
 @add_test_categories(["libc++"])
 @skipIf(compiler=no_match("clang"))
+@skipIf(compiler="clang", compiler_version=['<', '9.0'])
 @skipIfLinux # s.reset() causes link errors on ubuntu 18.04/Clang 9
 def test(self):
 self.build()

diff  --git a/lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py 
b/lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py
index 127461d7f746d..bd7173df5cca4 100644
--- a/lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py
+++ b/lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py
@@ -19,6 +19,7 @@ class TestWeakSymbolsInExpressions(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
 @decorators.skipUnlessDarwin
+@skipIf(compiler="clang", compiler_version=['<', '7.0'])
 def test_weak_symbol_in_expr(self):
 """Tests that we can refer to weak symbols in expressions."""
 self.build()

diff  --git 
a/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py 
b/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py
index 9a5acd5a1887d..6fd60c22cea4f 100644
--- a/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py
+++ b/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py
@@ -42,17 +42,20 @@ def build_and_run(self, test_file):
 lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec(test_file))
 return True
 
+@skipIf(compiler="clang", compiler_version=['<', '9.0'])
 def test_regcall(self):
 if not self.build_and_run("regcall.c"):
 return
 self.expect_expr("func(1, 2, 3, 4)", result_type="int", 
result_value="10")
 
+@skipIf(compiler="clang", compiler_version=['<', '9.0'])
 @expectedFailureDarwin(archs=["arm64", "arm64e"]) # rdar://84528755
 def test_ms_abi(self):
 if not self.build_and_run("ms_abi.c"):
 return
 self.expect_expr("func(1, 2, 3, 4)", result_type="int", 
result_value="10")
 
+@skipIf(compiler="clang", compiler_version=['<', '9.0'])
 def test_stdcall(self):
 if not self.build_and_run("stdcall.c"):
 return
@@ -63,11 +66,13 @@ def test_vectorcall(self):
 return
 self.expect_expr("func(1.0)", result_type="int", result_value="1")
 
+@skipIf(compiler="clang", compiler_version=['<', '9.0'])
 def test_fastcall(self):
 if not self.build_and_run("fastcall.c"):
 return
 self.expect_expr("func(1, 2, 3, 4)", result_type="int", 
result_value="10")
 
+@skipIf(compiler="clang", compiler_version=['<', '9.0'])
 def test_pascal(self):
 if not self.build_and_run("pascal.c"):
 

[Lldb-commits] [PATCH] D114008: Draft PR for the deque, stack, queue lldb data formatters

2021-11-16 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan created this revision.
danilashtefan requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114008

Files:
  lldb/examples/synthetic/gnu_libstdcpp.py
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -918,6 +918,11 @@
   SyntheticChildrenSP(new ScriptedSyntheticChildren(
   stl_deref_flags,
   "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
+  cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
+  RegularExpression("^std::deque<.+>(( )?&)?$"),
+  SyntheticChildrenSP(new ScriptedSyntheticChildren(
+  stl_deref_flags,
+  "lldb.formatters.cpp.gnu_libstdcpp.StdDequeSynthProvider")));
   cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
   RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"),
   SyntheticChildrenSP(new ScriptedSyntheticChildren(
@@ -946,6 +951,10 @@
   RegularExpression("^std::set<.+> >(( )?&)?$"),
   TypeSummaryImplSP(
   new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
+  cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
+  RegularExpression("^std::deque<.+>(( )?&)?$"),
+  TypeSummaryImplSP(
+  new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
   cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
   RegularExpression("^std::multimap<.+> >(( )?&)?$"),
   TypeSummaryImplSP(
Index: lldb/examples/synthetic/gnu_libstdcpp.py
===
--- lldb/examples/synthetic/gnu_libstdcpp.py
+++ lldb/examples/synthetic/gnu_libstdcpp.py
@@ -8,6 +8,80 @@
 # You are encouraged to look at the STL implementation for your platform
 # before relying on these formatters to do the right thing for your setup
 
+class StdDequeSynthProvider:
+def __init__(self, valobj, dict):
+print("Init called")
+self.valobj = valobj
+self.count = None
+
+def update(self):
+# preemptively setting this to None - we might end up changing our mind
+# later
+self.count = None
+try:
+print("Update called")
+self.impl = self.valobj.GetChildMemberWithName('_M_impl')
+self.start  = self.impl.GetChildMemberWithName("_M_start")
+self.start_cur = self.start.GetChildMemberWithName('_M_cur')
+self.finish = self.impl.GetChildMemberWithName("_M_finish")
+self.finish_cur = self.finish.GetChildMemberWithName('_M_cur')
+self.data_type = self.valobj.GetType().GetUnqualifiedType().GetTemplateArgumentType(0)
+self.data_size = self.data_type.GetByteSize()
+except:
+pass
+
+def get_child_index(self, name):
+try:
+return int(name.lstrip('[').rstrip(']'))
+except:
+return -1
+
+def get_child_at_index(self, index):
+print("Get child at index called")
+logger = lldb.formatters.Logger.Logger()
+logger >> "Being asked to fetch child[" + str(index) + "]"
+if index < 0:
+return None
+if index >= self.num_children():
+return None
+try:
+offset = index * self.data_size
+return self.start_cur.CreateChildAtOffset( '[' + str(index) + ']', offset, self.data_type)
+except:
+logger >> "Cannot get child"
+return None
+
+def num_children(self):
+print("Number of children called")
+if self.count is None:
+self.count = self.num_children_impl()
+return self.count
+
+def num_children_impl(self):
+# logger = lldb.formatters.Logger.Logger()
+# try:
+# start_val = self.start_cur.GetValueAsUnsigned(0)
+# print("Start value is: " + str(start_val))
+# finish_val = self.finish_cur.GetValueAsUnsigned(0)
+# print("Finish value is: " + str(finish_val))
+# if start_val == 0 or finish_val == 0:
+# print("Start of Finish val's are 0")
+# return 0
+# if start_val >= finish_val:
+# print("Start is greater than finish")
+# return 0
+
+# num_children = (finish_val - start_val)
+# if (num_children % self.data_size) != 0:
+# return 0
+# else:
+# num_children = num_children // self.data_size
+# return num_children
+# except:
+# print("Cannot determine the size")
+# logger >> "Could not determine the size"
+

[Lldb-commits] [lldb] db5b960 - fix decorator

2021-11-16 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2021-11-16T09:17:47-08:00
New Revision: db5b960e2dd5b2c2eac1973345d162245efc1f39

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

LOG: fix decorator

Added: 


Modified: 
lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py

Removed: 




diff  --git a/lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py 
b/lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py
index bd7173df5cca..09d998b98748 100644
--- a/lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py
+++ b/lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py
@@ -7,7 +7,7 @@
 
 import os
 import lldb
-from lldbsuite.test import decorators
+from lldbsuite.test.decorators import *
 import lldbsuite.test.lldbutil as lldbutil
 from lldbsuite.test.lldbtest import *
 
@@ -18,7 +18,7 @@ class TestWeakSymbolsInExpressions(TestBase):
 
 NO_DEBUG_INFO_TESTCASE = True
 
-@decorators.skipUnlessDarwin
+@skipUnlessDarwin
 @skipIf(compiler="clang", compiler_version=['<', '7.0'])
 def test_weak_symbol_in_expr(self):
 """Tests that we can refer to weak symbols in expressions."""



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


[Lldb-commits] [PATCH] D114008: Draft PR for the deque, stack, queue lldb data formatters

2021-11-16 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan added inline comments.



Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:60
+
+def num_children_impl(self):
+# logger = lldb.formatters.Logger.Logger()

This method does not currently work. I simply tried to calculate the size from 
start and finish pointers. When it did not, I investigated further and this was 
my founding:

This is when we get the iterator value this comes out:

`_Deque_iterator(const _Deque_iterator& __x) noexcept
   169 : _M_cur(__x._M_cur), _M_first(__x._M_first),
   170   _M_last(__x._M_last), _M_node(__x._M_node) { }`

And when it++ is done this is what happens behind:

operator++()
   189   {
   190++_M_cur;
   191if (_M_cur == _M_last)
   192  {
   193_M_set_node(_M_node + 1);
   194_M_cur = _M_first;
   195  }
   196return *this;
   197}




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114008

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


[Lldb-commits] [PATCH] D114008: Draft PR for the deque, stack, queue lldb data formatters

2021-11-16 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan added a comment.

When I mocked the num_children to return 4, formatter works for any structure 
with size <= 4. here is the example:

  std::deque d;
   d.push_front(7);
   d.push_front(5);   
   d.push_front(13);
   d.push_front(25);

(std::deque >) $0 = size=4 {

  [0] = 25
  [1] = 13
  [2] = 5
  [3] = 7

}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114008

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


Re: [Lldb-commits] [PATCH] D113098: [lldb] (Partially) enable formatting of utf strings before the program is started

2021-11-16 Thread Jim Ingham via lldb-commits
Something seems to have happened to reviews.llvm.org.  I can sort of see 
patches, but the interface isn't responding, and I can't actually make comments 
there, so we'll try this way instead.

Your changes look good, the "ReasonableSizeForReading" reasonable.

About the "force_live_memory" thing.  As I understand it, this is really one of 
those "why we can't have nice things" deals that I think we haven't fully 
embraced.  It would be very nice to not have to go to the device for read-only 
loaded sections, since in some situations it can be much faster.  OTOH, the 
security folks are right, silently suppressing these differences hides 
something that, while it almost never happens, matters a lot when it does.  
There's no other reason that I can think of to choose to read read-only 
sections from memory rather than from the binary.

Maybe this is more the sort of thing that should be a policy controlled by a 
Target setting instead of variables passed around and set different ways by 
different functions?  That way security conscious folks can force the always 
read behavior, and everybody else can work a little faster?

Anyway, the patch looks good, and if I could get Phabricator to allow me to 
check "Accept Revision" and click the Submit button, I would do so.

Jim



> On Nov 16, 2021, at 2:34 AM, Pavel Labath via Phabricator 
>  wrote:
> 
> labath updated this revision to Diff 387543.
> labath marked 4 inline comments as done.
> labath added a comment.
> 
> New version.
> 
> 
> Repository:
>  rG LLVM Github Monorepo
> 
> CHANGES SINCE LAST ACTION
>  https://reviews.llvm.org/D113098/new/
> 
> https://reviews.llvm.org/D113098
> 
> Files:
>  lldb/include/lldb/DataFormatters/FormattersHelpers.h
>  lldb/include/lldb/DataFormatters/StringPrinter.h
>  lldb/include/lldb/Target/Process.h
>  lldb/include/lldb/Target/Target.h
>  lldb/source/DataFormatters/FormattersHelpers.cpp
>  lldb/source/DataFormatters/StringPrinter.cpp
>  lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
>  lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
>  lldb/source/Plugins/Language/ObjC/NSString.cpp
>  lldb/source/Target/Process.cpp
>  lldb/source/Target/Target.cpp
>  lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
> 
> 

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


[Lldb-commits] [lldb] 4c484f1 - [llvm] Add a SFINAE template parameter to DenseMapInfo

2021-11-16 Thread River Riddle via lldb-commits

Author: River Riddle
Date: 2021-11-16T18:54:14Z
New Revision: 4c484f11d355e4293f7b245a9330f0a1e89630ac

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

LOG: [llvm] Add a SFINAE template parameter to DenseMapInfo

This allows for using SFINAE partial specialization for DenseMapInfo.
In MLIR, this is particularly useful as it will allow for defining partial
specializations that support all Attribute, Op, and Type classes without
needing to specialize DenseMapInfo for each individual class.

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

Added: 


Modified: 
clang/include/clang/AST/TypeOrdering.h
clang/include/clang/Basic/SourceLocation.h
clang/include/clang/Sema/Sema.h
lldb/include/lldb/Utility/ConstString.h
llvm/include/llvm/ADT/APInt.h
llvm/include/llvm/ADT/APSInt.h
llvm/include/llvm/ADT/ArrayRef.h
llvm/include/llvm/ADT/DenseMapInfo.h
llvm/include/llvm/ADT/Hashing.h
llvm/include/llvm/ADT/ImmutableList.h
llvm/include/llvm/ADT/PointerIntPair.h
llvm/include/llvm/ADT/StringRef.h
llvm/include/llvm/BinaryFormat/WasmTraits.h
llvm/include/llvm/CodeGen/SelectionDAGNodes.h
llvm/include/llvm/IR/Attributes.h
llvm/include/llvm/Support/TypeSize.h
llvm/lib/Support/APInt.cpp
llvm/unittests/ADT/DenseMapTest.cpp
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.h
mlir/include/mlir/IR/Attributes.h
mlir/include/mlir/IR/BuiltinOps.h
mlir/include/mlir/IR/OpDefinition.h
mlir/include/mlir/IR/Types.h
mlir/include/mlir/Support/LLVM.h

Removed: 




diff  --git a/clang/include/clang/AST/TypeOrdering.h 
b/clang/include/clang/AST/TypeOrdering.h
index 6630105136f5c..8037f98cc9651 100644
--- a/clang/include/clang/AST/TypeOrdering.h
+++ b/clang/include/clang/AST/TypeOrdering.h
@@ -34,7 +34,6 @@ struct QualTypeOrdering {
 }
 
 namespace llvm {
-  template struct DenseMapInfo;
 
   template<> struct DenseMapInfo {
 static inline clang::QualType getEmptyKey() { return clang::QualType(); }

diff  --git a/clang/include/clang/Basic/SourceLocation.h 
b/clang/include/clang/Basic/SourceLocation.h
index ba2e9156a2b12..543245a811db5 100644
--- a/clang/include/clang/Basic/SourceLocation.h
+++ b/clang/include/clang/Basic/SourceLocation.h
@@ -23,8 +23,6 @@
 
 namespace llvm {
 
-template  struct DenseMapInfo;
-
 class FoldingSetNodeID;
 template  struct FoldingSetTrait;
 
@@ -467,7 +465,7 @@ namespace llvm {
   /// Define DenseMapInfo so that FileID's can be used as keys in DenseMap and
   /// DenseSets.
   template <>
-  struct DenseMapInfo {
+  struct DenseMapInfo {
 static clang::FileID getEmptyKey() {
   return {};
 }
@@ -488,7 +486,7 @@ namespace llvm {
   /// Define DenseMapInfo so that SourceLocation's can be used as keys in
   /// DenseMap and DenseSet. This trait class is eqivalent to
   /// DenseMapInfo which uses SourceLocation::ID is used as a key.
-  template <> struct DenseMapInfo {
+  template <> struct DenseMapInfo {
 static clang::SourceLocation getEmptyKey() {
   constexpr clang::SourceLocation::UIntTy Zero = 0;
   return clang::SourceLocation::getFromRawEncoding(~Zero);

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5f5755ef13435..a159be2b5fb17 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -74,7 +74,6 @@
 
 namespace llvm {
   class APSInt;
-  template  struct DenseMapInfo;
   template  class DenseSet;
   class SmallBitVector;
   struct InlineAsmIdentifierInfo;

diff  --git a/lldb/include/lldb/Utility/ConstString.h 
b/lldb/include/lldb/Utility/ConstString.h
index 52d3556418f6c..2756f1fd72038 100644
--- a/lldb/include/lldb/Utility/ConstString.h
+++ b/lldb/include/lldb/Utility/ConstString.h
@@ -409,7 +409,7 @@ class ConstString {
   static size_t StaticMemorySize();
 
 protected:
-  template  friend struct ::llvm::DenseMapInfo;
+  template  friend struct ::llvm::DenseMapInfo;
   /// Only used by DenseMapInfo.
   static ConstString FromStringPoolPointer(const char *ptr) {
 ConstString s;

diff  --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 71d75db91c103..595cd94b6b8f6 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -31,7 +31,7 @@ class raw_ostream;
 template  class SmallVectorImpl;
 template  class ArrayRef;
 template  class Optional;
-template  struct DenseMapInfo;
+template  struct DenseMapInfo;
 
 class APInt;
 
@@ -1817,7 +1817,7 @@ class LLVM_NODISCARD APInt {
 
   unsigned BitWidth; ///< The number of bits in this APInt.
 
-  friend struct DenseMapInfo;
+  friend struct DenseMapInfo;
   friend class APSInt;
 
   /// This constructor is used only internally for speed of construction of
@@ -2251,7 +2251,7 @@ void StoreIntToMemory(const

[Lldb-commits] [PATCH] D113965: [NFC] Refactor symbol table parsing.

2021-11-16 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113965

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


[Lldb-commits] [PATCH] D112972: [lldb] use EXT_SUFFIX for python extension

2021-11-16 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112972

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


[Lldb-commits] [PATCH] D113650: [lldb] fix -print-script-interpreter-info on windows

2021-11-16 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM if the Windows bot is happy :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113650

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


[Lldb-commits] [PATCH] D113608: [lldb] Simplify specifying of platform supported architectures

2021-11-16 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Target/Platform.cpp:1217-1218
+std::vector
+Platform::CreateArchList(llvm::Triple::OSType os,
+ llvm::ArrayRef archs) {
+  std::vector list;

labath wrote:
> JDevlieghere wrote:
> > labath wrote:
> > > JDevlieghere wrote:
> > > > In PlatformDarwin we set the vendor too. Could we have this take an 
> > > > optional OSType and Vendor maybe that sets the ones that are not None? 
> > > > That would also make migrating PlatformDarwin easier where we currently 
> > > > share the code and don't set the OS. Later we could move this out of 
> > > > PlatformDarwin into the child classes and have the OS set correctly. 
> > > Umm.. maybe? I don't think this function is set in stone, but the nice 
> > > thing about it being a helper function is that it's usage is completely 
> > > optional. I haven't tried porting the darwin platforms yet, but, from a 
> > > cursory glance I did see that they have a lot more complex usage patterns:
> > > - they pass subarchitectures as well, so we'd either also need to have an 
> > > Optional subarch field, or switch to passing architectures as strings (I 
> > > mean, I suppose I could switch to strings now, but it feels more correct 
> > > to work with named constants)
> > > - a few of them also pass environments 
> > > - and some don't even have matching OS fields (`x86_64-apple-macosx` and 
> > > `arm64-apple-ios` in the same list)
> > > 
> > > So, I'd leave it to those patches to determine whether it's better to 
> > > extend this function or create a new one.
> > Okay, I'm happy to modify the helper when I start using it for the darwin 
> > platfomrs. I think at least some of the complexity/inconsistencies is 
> > purely historic such as the one where we were specifying an OS in the list 
> > of supported architectures in PlatformDarwin. 
> Cool. Does that mean I can count on you do convert the darwin platforms? :)
> 
> (I was going to try doing it myself, but I have basically no way of checking 
> whether my modifications break anything.)
Yup, although I can't commit to a timeframe :-) For validation you'd need to 
run the "on device" test suite and there's no real way for non-Apple people to 
do that, but if you get to it before me I'm more than happy to apply the patch 
locally and try it out. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113608

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


[Lldb-commits] [PATCH] D114029: [clang][NFC] Inclusive terms: rename AccessDeclContextSanity to AccessDeclContextCheck

2021-11-16 Thread Zarko Todorovski via Phabricator via lldb-commits
ZarkoCA created this revision.
ZarkoCA added reviewers: klimek, akyrtzi, quinnp.
ZarkoCA added a project: clang.
ZarkoCA requested review of this revision.
Herald added subscribers: lldb-commits, cfe-commits.
Herald added a project: LLDB.

Rename function to more inclusive name.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114029

Files:
  clang/include/clang/AST/DeclBase.h
  clang/lib/AST/DeclBase.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp


Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -91,7 +91,7 @@
   assert(decl && "VerifyDecl called with nullptr?");
 #ifndef NDEBUG
   // We don't care about the actual access value here but only want to trigger
-  // that Clang calls its internal Decl::AccessDeclContextSanity check.
+  // that Clang calls its internal Decl::AccessDeclContextCheck validation.
   decl->getAccess();
 #endif
 }
Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -964,7 +964,7 @@
   return {};
 }
 
-bool Decl::AccessDeclContextSanity() const {
+bool Decl::AccessDeclContextCheck() const {
 #ifndef NDEBUG
   // Suppress this check if any of the following hold:
   // 1. this is the translation unit (and thus has no parent)
Index: clang/include/clang/AST/DeclBase.h
===
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -352,7 +352,7 @@
  DeclContext *Parent, std::size_t Extra = 0);
 
 private:
-  bool AccessDeclContextSanity() const;
+  bool AccessDeclContextCheck() const;
 
   /// Get the module ownership kind to use for a local lexical child of \p DC,
   /// which may be either a local or (rarely) an imported declaration.
@@ -472,11 +472,11 @@
 
   void setAccess(AccessSpecifier AS) {
 Access = AS;
-assert(AccessDeclContextSanity());
+assert(AccessDeclContextCheck());
   }
 
   AccessSpecifier getAccess() const {
-assert(AccessDeclContextSanity());
+assert(AccessDeclContextCheck());
 return AccessSpecifier(Access);
   }
 


Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -91,7 +91,7 @@
   assert(decl && "VerifyDecl called with nullptr?");
 #ifndef NDEBUG
   // We don't care about the actual access value here but only want to trigger
-  // that Clang calls its internal Decl::AccessDeclContextSanity check.
+  // that Clang calls its internal Decl::AccessDeclContextCheck validation.
   decl->getAccess();
 #endif
 }
Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -964,7 +964,7 @@
   return {};
 }
 
-bool Decl::AccessDeclContextSanity() const {
+bool Decl::AccessDeclContextCheck() const {
 #ifndef NDEBUG
   // Suppress this check if any of the following hold:
   // 1. this is the translation unit (and thus has no parent)
Index: clang/include/clang/AST/DeclBase.h
===
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -352,7 +352,7 @@
  DeclContext *Parent, std::size_t Extra = 0);
 
 private:
-  bool AccessDeclContextSanity() const;
+  bool AccessDeclContextCheck() const;
 
   /// Get the module ownership kind to use for a local lexical child of \p DC,
   /// which may be either a local or (rarely) an imported declaration.
@@ -472,11 +472,11 @@
 
   void setAccess(AccessSpecifier AS) {
 Access = AS;
-assert(AccessDeclContextSanity());
+assert(AccessDeclContextCheck());
   }
 
   AccessSpecifier getAccess() const {
-assert(AccessDeclContextSanity());
+assert(AccessDeclContextCheck());
 return AccessSpecifier(Access);
   }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 4c2cf3a - [lldb] fix -print-script-interpreter-info on windows

2021-11-16 Thread Lawrence D'Anna via lldb-commits

Author: Lawrence D'Anna
Date: 2021-11-16T13:50:20-08:00
New Revision: 4c2cf3a314d9131b1b288e7c8ab0c75ac1b2be1d

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

LOG: [lldb] fix -print-script-interpreter-info on windows

Apparently "{sys.prefix}/bin/python3" isn't where you find the
python interpreter on windows, so the test I wrote for
-print-script-interpreter-info is failing.

We can't rely on sys.executable at runtime, because that will point
to lldb.exe not python.exe.

We can't just record sys.executable from build time, because python
could have been moved to a different location.

But it should be OK to apply relative path from sys.prefix to sys.executable
from build-time to the sys.prefix at runtime.

Reviewed By: JDevlieghere

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

Added: 
lldb/bindings/python/get-python-config.py

Modified: 
lldb/CMakeLists.txt
lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/test/API/functionalities/paths/TestPaths.py

Removed: 




diff  --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 028dadbb8c73c..1a54addf3d557 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -31,24 +31,28 @@ if (WIN32)
 endif()
 
 if (LLDB_ENABLE_PYTHON)
-  if (NOT CMAKE_CROSSCOMPILING)
-execute_process(
-  COMMAND ${Python3_EXECUTABLE}
-  -c "import distutils.sysconfig; 
print(distutils.sysconfig.get_python_lib(True, False, ''))"
-  OUTPUT_VARIABLE LLDB_PYTHON_DEFAULT_RELATIVE_PATH
-  OUTPUT_STRIP_TRAILING_WHITESPACE)
-
-file(TO_CMAKE_PATH ${LLDB_PYTHON_DEFAULT_RELATIVE_PATH} 
LLDB_PYTHON_DEFAULT_RELATIVE_PATH)
-  else ()
-if ("${LLDB_PYTHON_RELATIVE_PATH}" STREQUAL "")
-  message(FATAL_ERROR
-"Crosscompiling LLDB with Python requires manually setting
-LLDB_PYTHON_RELATIVE_PATH.")
-endif ()
-  endif ()
-
-  set(LLDB_PYTHON_RELATIVE_PATH ${LLDB_PYTHON_DEFAULT_RELATIVE_PATH}
-CACHE STRING "Path where Python modules are installed, relative to install 
prefix")
+  set(cachestring_LLDB_PYTHON_RELATIVE_PATH
+"Path where Python modules are installed, relative to install prefix")
+  set(cachestring_LLDB_PYTHON_EXE_RELATIVE_PATH
+"Path to python interpreter exectuable, relative to install prefix")
+
+  foreach(var LLDB_PYTHON_RELATIVE_PATH LLDB_PYTHON_EXE_RELATIVE_PATH)
+if(NOT DEFINED ${var} AND NOT CMAKE_CROSSCOMPILING)
+  execute_process(
+COMMAND ${Python3_EXECUTABLE}
+  ${CMAKE_CURRENT_SOURCE_DIR}/bindings/python/get-python-config.py
+  ${var}
+OUTPUT_VARIABLE value
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+  file(TO_CMAKE_PATH "${value}" value)
+  set(${var} ${value} CACHE STRING ${cachestring_${var}})
+else()
+  if ("${${var}}" STREQUAL "")
+message(FATAL_ERROR
+  "Crosscompiling LLDB with Python requires manually setting ${var}.")
+  endif()
+endif()
+  endforeach()
 endif ()
 
 if (LLDB_ENABLE_LUA)

diff  --git a/lldb/bindings/python/get-python-config.py 
b/lldb/bindings/python/get-python-config.py
new file mode 100755
index 0..7acad6d2d4c9a
--- /dev/null
+++ b/lldb/bindings/python/get-python-config.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+import argparse
+import sysconfig
+import distutils.sysconfig
+
+
+def relpath_nodots(path, base):
+rel = os.path.normpath(os.path.relpath(path, base))
+assert not os.path.isabs(rel)
+parts = rel.split(os.path.sep)
+if parts and parts[0] == '..':
+raise ValueError(f"{path} is not under {base}")
+return rel
+
+def main():
+parser = argparse.ArgumentParser(description="extract cmake variables from 
python")
+parser.add_argument("variable_name")
+args = parser.parse_args()
+if args.variable_name == "LLDB_PYTHON_RELATIVE_PATH":
+print(distutils.sysconfig.get_python_lib(True, False, ''))
+elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
+tried = list()
+exe = sys.executable
+while True:
+try:
+print(relpath_nodots(exe, sys.prefix))
+break
+except ValueError:
+tried.append(exe)
+if os.path.islink(exe):
+exe = os.path.join(os.path.dirname(exe), os.readlink(exe))
+continue
+else:
+print("Could not find a relative path to sys.executable 
under sys.prefix", file=sys.stderr)
+for e in tried:
+print("tried:", e, file=sys.stderr)
+print("sys.prefix:", sys.prefix, file=sys.stderr)
+sys.exit(1)
+
+   

[Lldb-commits] [PATCH] D113650: [lldb] fix -print-script-interpreter-info on windows

2021-11-16 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4c2cf3a314d9: [lldb] fix -print-script-interpreter-info on 
windows (authored by lawrence_danna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113650

Files:
  lldb/CMakeLists.txt
  lldb/bindings/python/get-python-config.py
  lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/test/API/functionalities/paths/TestPaths.py

Index: lldb/test/API/functionalities/paths/TestPaths.py
===
--- lldb/test/API/functionalities/paths/TestPaths.py
+++ lldb/test/API/functionalities/paths/TestPaths.py
@@ -51,8 +51,6 @@
 stream = lldb.SBStream()
 self.assertTrue(info_sd.GetAsJSON(stream).Success())
 info = json.loads(stream.GetData())
-if os.name == 'nt': #FIXME
-return
 prefix = info['prefix']
 self.assertEqual(os.path.realpath(sys.prefix), os.path.realpath(prefix))
 self.assertEqual(
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -410,30 +410,31 @@
   return g_spec;
 }
 
+static const char GetInterpreterInfoScript[] = R"(
+import os
+import sys
+
+def main(lldb_python_dir, python_exe_relative_path):
+  info = {
+"lldb-pythonpath": lldb_python_dir,
+"language": "python",
+"prefix": sys.prefix,
+"executable": os.path.join(sys.prefix, python_exe_relative_path)
+  }
+  return info
+)";
+
+static const char python_exe_relative_path[] = LLDB_PYTHON_EXE_RELATIVE_PATH;
+
 StructuredData::DictionarySP ScriptInterpreterPython::GetInterpreterInfo() {
   GIL gil;
   FileSpec python_dir_spec = GetPythonDir();
   if (!python_dir_spec)
 return nullptr;
-  PythonString python_dir(python_dir_spec.GetPath());
-  PythonDictionary info(PyInitialValue::Empty);
-  llvm::Error error = info.SetItem("lldb-pythonpath", python_dir);
-  if (error)
-return nullptr;
-  static const char script[] = R"(
-def main(info):
-  import sys
-  import os
-  name = 'python' + str(sys.version_info.major)
-  info.update({
-"language": "python",
-"prefix": sys.prefix,
-"executable": os.path.join(sys.prefix, "bin", name),
-  })
-  return info
-)";
-  PythonScript get_info(script);
-  auto info_json = unwrapIgnoringErrors(As(get_info(info)));
+  PythonScript get_info(GetInterpreterInfoScript);
+  auto info_json = unwrapIgnoringErrors(
+  As(get_info(PythonString(python_dir_spec.GetPath()),
+PythonString(python_exe_relative_path;
   if (!info_json)
 return nullptr;
   return info_json.CreateStructuredDictionary();
Index: lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
===
--- lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
+++ lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
@@ -3,6 +3,12 @@
 endif()
 add_definitions(-DLLDB_PYTHON_RELATIVE_LIBDIR="${LLDB_PYTHON_RELATIVE_PATH}")
 
+if(NOT LLDB_PYTHON_EXE_RELATIVE_PATH)
+  message(FATAL_ERROR "LLDB_PYTHON_EXE_RELATIVE_PATH is not set.")
+endif()
+add_definitions(-DLLDB_PYTHON_EXE_RELATIVE_PATH="${LLDB_PYTHON_EXE_RELATIVE_PATH}")
+
+
 if (LLDB_ENABLE_LIBEDIT)
   list(APPEND LLDB_LIBEDIT_LIBS ${LibEdit_LIBRARIES})
 endif()
Index: lldb/bindings/python/get-python-config.py
===
--- /dev/null
+++ lldb/bindings/python/get-python-config.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+import argparse
+import sysconfig
+import distutils.sysconfig
+
+
+def relpath_nodots(path, base):
+rel = os.path.normpath(os.path.relpath(path, base))
+assert not os.path.isabs(rel)
+parts = rel.split(os.path.sep)
+if parts and parts[0] == '..':
+raise ValueError(f"{path} is not under {base}")
+return rel
+
+def main():
+parser = argparse.ArgumentParser(description="extract cmake variables from python")
+parser.add_argument("variable_name")
+args = parser.parse_args()
+if args.variable_name == "LLDB_PYTHON_RELATIVE_PATH":
+print(distutils.sysconfig.get_python_lib(True, False, ''))
+elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
+tried = list()
+exe = sys.executable
+while True:
+try:
+print(relpath_nodots(exe, sys.prefix))
+break
+except ValueError:
+tried.append(exe)
+if os.path.islink(exe):
+exe = os.path.join(os.path.dirname(exe), os.re

[Lldb-commits] [lldb] ae389b2 - [lldb] use EXT_SUFFIX for python extension

2021-11-16 Thread Lawrence D'Anna via lldb-commits

Author: Lawrence D'Anna
Date: 2021-11-16T14:32:26-08:00
New Revision: ae389b2450bd604a3f3bbe5b09b333b2d99801dd

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

LOG: [lldb] use EXT_SUFFIX for python extension

LLDB doesn't use only the python stable ABI, which means loading
it into an incompatible python can cause the process to crash.
_lldb.so should be named with the full EXT_SUFFIX from sysconfig
-- such as _lldb.cpython-39-darwin.so -- so this doesn't happen.

Reviewed By: JDevlieghere

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

Added: 


Modified: 
lldb/CMakeLists.txt
lldb/bindings/python/CMakeLists.txt
lldb/bindings/python/get-python-config.py

Removed: 




diff  --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 1a54addf3d557..c45064d9bef23 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -35,8 +35,10 @@ if (LLDB_ENABLE_PYTHON)
 "Path where Python modules are installed, relative to install prefix")
   set(cachestring_LLDB_PYTHON_EXE_RELATIVE_PATH
 "Path to python interpreter exectuable, relative to install prefix")
+  set(cachestring_LLDB_PYTHON_EXT_SUFFIX
+"Filename extension for native code python modules")
 
-  foreach(var LLDB_PYTHON_RELATIVE_PATH LLDB_PYTHON_EXE_RELATIVE_PATH)
+  foreach(var LLDB_PYTHON_RELATIVE_PATH LLDB_PYTHON_EXE_RELATIVE_PATH 
LLDB_PYTHON_EXT_SUFFIX)
 if(NOT DEFINED ${var} AND NOT CMAKE_CROSSCOMPILING)
   execute_process(
 COMMAND ${Python3_EXECUTABLE}

diff  --git a/lldb/bindings/python/CMakeLists.txt 
b/lldb/bindings/python/CMakeLists.txt
index 5aabaf574636c..1f7ed18a2a0cb 100644
--- a/lldb/bindings/python/CMakeLists.txt
+++ b/lldb/bindings/python/CMakeLists.txt
@@ -149,15 +149,7 @@ function(finish_swig_python swig_target 
lldb_python_bindings_dir lldb_python_tar
   else()
 set(LIBLLDB_SYMLINK_DEST 
"${LLVM_SHLIB_OUTPUT_INTDIR}/liblldb${CMAKE_SHARED_LIBRARY_SUFFIX}")
   endif()
-  if(WIN32)
-if(CMAKE_BUILD_TYPE STREQUAL Debug)
-  set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb_d.pyd")
-else()
-  set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb.pyd")
-endif()
-  else()
-set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb.so")
-  endif()
+  set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb${LLDB_PYTHON_EXT_SUFFIX}")
   create_relative_symlink(${swig_target} ${LIBLLDB_SYMLINK_DEST}
   ${lldb_python_target_dir} 
${LIBLLDB_SYMLINK_OUTPUT_FILE})
 

diff  --git a/lldb/bindings/python/get-python-config.py 
b/lldb/bindings/python/get-python-config.py
index 7acad6d2d4c9a..507a8aa072076 100755
--- a/lldb/bindings/python/get-python-config.py
+++ b/lldb/bindings/python/get-python-config.py
@@ -39,7 +39,8 @@ def main():
 print("tried:", e, file=sys.stderr)
 print("sys.prefix:", sys.prefix, file=sys.stderr)
 sys.exit(1)
-
+elif args.variable_name == "LLDB_PYTHON_EXT_SUFFIX":
+print(sysconfig.get_config_var('EXT_SUFFIX'))
 else:
 parser.error(f"unknown variable {args.variable_name}")
 



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


[Lldb-commits] [PATCH] D112972: [lldb] use EXT_SUFFIX for python extension

2021-11-16 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGae389b2450bd: [lldb] use EXT_SUFFIX for python extension 
(authored by lawrence_danna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112972

Files:
  lldb/CMakeLists.txt
  lldb/bindings/python/CMakeLists.txt
  lldb/bindings/python/get-python-config.py


Index: lldb/bindings/python/get-python-config.py
===
--- lldb/bindings/python/get-python-config.py
+++ lldb/bindings/python/get-python-config.py
@@ -39,9 +39,10 @@
 print("tried:", e, file=sys.stderr)
 print("sys.prefix:", sys.prefix, file=sys.stderr)
 sys.exit(1)
-
+elif args.variable_name == "LLDB_PYTHON_EXT_SUFFIX":
+print(sysconfig.get_config_var('EXT_SUFFIX'))
 else:
 parser.error(f"unknown variable {args.variable_name}")
 
 if __name__ == '__main__':
 main()
\ No newline at end of file
Index: lldb/bindings/python/CMakeLists.txt
===
--- lldb/bindings/python/CMakeLists.txt
+++ lldb/bindings/python/CMakeLists.txt
@@ -149,15 +149,7 @@
   else()
 set(LIBLLDB_SYMLINK_DEST 
"${LLVM_SHLIB_OUTPUT_INTDIR}/liblldb${CMAKE_SHARED_LIBRARY_SUFFIX}")
   endif()
-  if(WIN32)
-if(CMAKE_BUILD_TYPE STREQUAL Debug)
-  set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb_d.pyd")
-else()
-  set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb.pyd")
-endif()
-  else()
-set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb.so")
-  endif()
+  set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb${LLDB_PYTHON_EXT_SUFFIX}")
   create_relative_symlink(${swig_target} ${LIBLLDB_SYMLINK_DEST}
   ${lldb_python_target_dir} 
${LIBLLDB_SYMLINK_OUTPUT_FILE})
 
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -35,8 +35,10 @@
 "Path where Python modules are installed, relative to install prefix")
   set(cachestring_LLDB_PYTHON_EXE_RELATIVE_PATH
 "Path to python interpreter exectuable, relative to install prefix")
+  set(cachestring_LLDB_PYTHON_EXT_SUFFIX
+"Filename extension for native code python modules")
 
-  foreach(var LLDB_PYTHON_RELATIVE_PATH LLDB_PYTHON_EXE_RELATIVE_PATH)
+  foreach(var LLDB_PYTHON_RELATIVE_PATH LLDB_PYTHON_EXE_RELATIVE_PATH 
LLDB_PYTHON_EXT_SUFFIX)
 if(NOT DEFINED ${var} AND NOT CMAKE_CROSSCOMPILING)
   execute_process(
 COMMAND ${Python3_EXECUTABLE}


Index: lldb/bindings/python/get-python-config.py
===
--- lldb/bindings/python/get-python-config.py
+++ lldb/bindings/python/get-python-config.py
@@ -39,9 +39,10 @@
 print("tried:", e, file=sys.stderr)
 print("sys.prefix:", sys.prefix, file=sys.stderr)
 sys.exit(1)
-
+elif args.variable_name == "LLDB_PYTHON_EXT_SUFFIX":
+print(sysconfig.get_config_var('EXT_SUFFIX'))
 else:
 parser.error(f"unknown variable {args.variable_name}")
 
 if __name__ == '__main__':
 main()
\ No newline at end of file
Index: lldb/bindings/python/CMakeLists.txt
===
--- lldb/bindings/python/CMakeLists.txt
+++ lldb/bindings/python/CMakeLists.txt
@@ -149,15 +149,7 @@
   else()
 set(LIBLLDB_SYMLINK_DEST "${LLVM_SHLIB_OUTPUT_INTDIR}/liblldb${CMAKE_SHARED_LIBRARY_SUFFIX}")
   endif()
-  if(WIN32)
-if(CMAKE_BUILD_TYPE STREQUAL Debug)
-  set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb_d.pyd")
-else()
-  set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb.pyd")
-endif()
-  else()
-set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb.so")
-  endif()
+  set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb${LLDB_PYTHON_EXT_SUFFIX}")
   create_relative_symlink(${swig_target} ${LIBLLDB_SYMLINK_DEST}
   ${lldb_python_target_dir} ${LIBLLDB_SYMLINK_OUTPUT_FILE})
 
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -35,8 +35,10 @@
 "Path where Python modules are installed, relative to install prefix")
   set(cachestring_LLDB_PYTHON_EXE_RELATIVE_PATH
 "Path to python interpreter exectuable, relative to install prefix")
+  set(cachestring_LLDB_PYTHON_EXT_SUFFIX
+"Filename extension for native code python modules")
 
-  foreach(var LLDB_PYTHON_RELATIVE_PATH LLDB_PYTHON_EXE_RELATIVE_PATH)
+  foreach(var LLDB_PYTHON_RELATIVE_PATH LLDB_PYTHON_EXE_RELATIVE_PATH LLDB_PYTHON_EXT_SUFFIX)
 if(NOT DEFINED ${var} AND NOT CMAKE_CROSSCOMPILING)
   execute_process(
 COMMAND ${Python3_EXECUTABLE}
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/ma

[Lldb-commits] [lldb] b715b79 - Make it possible for lldb to launch a remote binary with no local file.

2021-11-16 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2021-11-16T16:06:07-08:00
New Revision: b715b79d54d5ca2d4e8c91089b8f6a9389d9dc48

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

LOG: Make it possible for lldb to launch a remote binary with no local file.

We don't actually need a local copy of the main executable to debug
a remote process.  So instead of treating "no local module" as an error,
see if the LaunchInfo has an executable it wants lldb to use, and if so
use it.  Then report whatever error the remote server returns.

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

Added: 
lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py

Modified: 
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Target/Process.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectProcess.cpp 
b/lldb/source/Commands/CommandObjectProcess.cpp
index 8ce14f2a96d5..5fd1718e8484 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -159,7 +159,12 @@ class CommandObjectProcessLaunch : public 
CommandObjectProcessLaunchOrAttach {
 // If our listener is nullptr, users aren't allows to launch
 ModuleSP exe_module_sp = target->GetExecutableModule();
 
-if (exe_module_sp == nullptr) {
+// If the target already has an executable module, then use that.  If it
+// doesn't then someone must be trying to launch using a path that will
+// make sense to the remote stub, but doesn't exist on the local host.
+// In that case use the ExecutableFile that was set in the target's
+// ProcessLaunchInfo.
+if (exe_module_sp == nullptr && 
!target->GetProcessLaunchInfo().GetExecutableFile()) {
   result.AppendError("no file in target, create a debug target using the "
  "'target create' command");
   return false;
@@ -219,11 +224,17 @@ class CommandObjectProcessLaunch : public 
CommandObjectProcessLaunchOrAttach {
 if (!target_settings_argv0.empty()) {
   m_options.launch_info.GetArguments().AppendArgument(
   target_settings_argv0);
-  m_options.launch_info.SetExecutableFile(
-  exe_module_sp->GetPlatformFileSpec(), false);
+  if (exe_module_sp)
+m_options.launch_info.SetExecutableFile(
+exe_module_sp->GetPlatformFileSpec(), false);
+  else
+
m_options.launch_info.SetExecutableFile(target->GetProcessLaunchInfo().GetExecutableFile(),
 false);
 } else {
-  m_options.launch_info.SetExecutableFile(
-  exe_module_sp->GetPlatformFileSpec(), true);
+  if (exe_module_sp)
+m_options.launch_info.SetExecutableFile(
+exe_module_sp->GetPlatformFileSpec(), true);
+  else
+
m_options.launch_info.SetExecutableFile(target->GetProcessLaunchInfo().GetExecutableFile(),
 true);
 }
 
 if (launch_args.GetArgumentCount() == 0) {
@@ -250,11 +261,20 @@ class CommandObjectProcessLaunch : public 
CommandObjectProcessLaunchOrAttach {
 llvm::StringRef data = stream.GetString();
 if (!data.empty())
   result.AppendMessage(data);
-const char *archname =
-exe_module_sp->GetArchitecture().GetArchitectureName();
-result.AppendMessageWithFormat(
-"Process %" PRIu64 " launched: '%s' (%s)\n", process_sp->GetID(),
-exe_module_sp->GetFileSpec().GetPath().c_str(), archname);
+// If we didn't have a local executable, then we wouldn't have had an
+// executable module before launch.
+if (!exe_module_sp)
+  exe_module_sp = target->GetExecutableModule();
+if (!exe_module_sp) {
+  result.AppendWarning("Could not get executable module after 
launch.");
+} else {
+
+  const char *archname =
+  exe_module_sp->GetArchitecture().GetArchitectureName();
+  result.AppendMessageWithFormat(
+  "Process %" PRIu64 " launched: '%s' (%s)\n", process_sp->GetID(),
+  exe_module_sp->GetFileSpec().GetPath().c_str(), archname);
+}
 result.SetStatus(eReturnStatusSuccessFinishResult);
 result.SetDidChangeProcessState(true);
   } else {

diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index a666aeb8bb3f..2233bf675819 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -677,143 +677,133 @@ Status ProcessGDBRemote::DoLaunch(lldb_private::Module 
*exe_module,
   //  LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD);
   //  ::LogSetLogFile ("/dev/stdout");
 
-  ObjectFile *object_file

[Lldb-commits] [PATCH] D113521: Allow lldb to launch a remote executable when there isn't a local copy

2021-11-16 Thread Jim Ingham via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb715b79d54d5: Make it possible for lldb to launch a remote 
binary with no local file. (authored by jingham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113521

Files:
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Target/Process.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py
===
--- /dev/null
+++ lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py
@@ -0,0 +1,88 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestNoLocalFile(GDBRemoteTestBase):
+""" Test the case where there is NO local copy of the file
+being debugged.  We shouldn't immediately error out, but
+rather lldb should ask debugserver if it knows about the file. """
+
+
+@skipIfXmlSupportMissing
+def test(self):
+self.absent_file = '/nosuch_dir/nosuch_subdir/nosuch_executable'
+self.a_packet_file = None
+class MyResponder(MockGDBServerResponder):
+def __init__(self, testcase):
+MockGDBServerResponder.__init__(self)
+self.after_launch = False
+self.testcase = testcase
+self.current_thread = 0
+
+def A(self, packet):
+# This is the main test, we want to see that lldb DID send the
+# A packet to get debugserver to load the file.
+# Skip the length and second length:
+a_arr = packet.split(",")
+self.testcase.a_packet_file = bytearray.fromhex(a_arr[2]).decode()
+return "OK"
+
+def qXferRead(self, obj, annex, offset, length):
+if annex == "target.xml":
+return """
+
+  i386:x86-64
+  
+
+  
+""", False
+else:
+return None, False
+
+def qC(self):
+if not self.after_launch:
+return "QC0"
+return "0"
+
+def qfThreadInfo(self):
+if not self.after_launch:
+return "OK"
+return "m0"
+
+def qsThreadInfo(self):
+if not self.after_launch:
+return "OK"
+return "l"
+
+def qLaunchSuccess(self):
+return "OK"
+
+def qProcessInfo(self):
+return "$pid:10b70;parent-pid:10b20;real-uid:1f6;real-gid:14;effective-uid:1f6;effective-gid:14;cputype:107;cpusubtype:8;ptrsize:8;ostype:macosx;vendor:apple;endian:little;"
+
+
+error = lldb.SBError()
+self.server.responder = MyResponder(self)
+target = self.dbg.CreateTarget(None, "x86_64-apple-macosx", "remote-macosx", False, error)
+self.assertSuccess(error, "Made a valid target")
+launch_info = target.GetLaunchInfo()
+launch_info.SetExecutableFile(lldb.SBFileSpec(self.absent_file), True)
+flags = launch_info.GetLaunchFlags()
+flags |= lldb.eLaunchFlagStopAtEntry
+launch_info.SetLaunchFlags(flags)
+
+process = self.connect(target)
+self.assertTrue(process.IsValid(), "Process is valid")
+
+# We need to fetch the connected event:
+lldbutil.expect_state_changes(self, self.dbg.GetListener(), process, [lldb.eStateConnected])
+
+self.server.responder.after_launch = True
+
+process = target.Launch(launch_info, error)
+self.assertSuccess(error, "Successfully launched.")
+self.assertEqual(process.GetState(), lldb.eStateStopped, "Should be stopped at entry")
+self.assertIsNotNone(self.a_packet_file, "A packet was sent")
+self.assertEqual(self.absent_file, self.a_packet_file, "The A packet file was correct")
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -2493,118 +2493,125 @@
   m_process_input_reader.reset();
 
   Module *exe_module = GetTarget().GetExecutableModulePointer();
-  if (!exe_module) {
-error.SetErrorString("executable module does not exist");
-return error;
-  }
 
-  char local_exec_file_path[PATH_MAX];
-  char platform_exec_file_path[PATH_MAX];
-  exe_module->GetFileSpec().GetPath(local_exec_file_path,
-sizeof(local_exec_file_path));
-  exe_module-

[Lldb-commits] [lldb] dd5505a - Revert "Make it possible for lldb to launch a remote binary with no local file."

2021-11-16 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2021-11-16T16:46:21-08:00
New Revision: dd5505a8f2c75a903ec944b6e46aed2042610673

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

LOG: Revert "Make it possible for lldb to launch a remote binary with no local 
file."

The reworking of the gdb client tests into the PlatformClientTestBase broke
the test for this.  I did the mutatis mutandis for the move, but the test
still fails.  Reverting till I have time to figure out why.

This reverts commit b715b79d54d5ca2d4e8c91089b8f6a9389d9dc48.

Added: 


Modified: 
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Target/Process.cpp

Removed: 
lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py



diff  --git a/lldb/source/Commands/CommandObjectProcess.cpp 
b/lldb/source/Commands/CommandObjectProcess.cpp
index 5fd1718e84840..8ce14f2a96d5e 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -159,12 +159,7 @@ class CommandObjectProcessLaunch : public 
CommandObjectProcessLaunchOrAttach {
 // If our listener is nullptr, users aren't allows to launch
 ModuleSP exe_module_sp = target->GetExecutableModule();
 
-// If the target already has an executable module, then use that.  If it
-// doesn't then someone must be trying to launch using a path that will
-// make sense to the remote stub, but doesn't exist on the local host.
-// In that case use the ExecutableFile that was set in the target's
-// ProcessLaunchInfo.
-if (exe_module_sp == nullptr && 
!target->GetProcessLaunchInfo().GetExecutableFile()) {
+if (exe_module_sp == nullptr) {
   result.AppendError("no file in target, create a debug target using the "
  "'target create' command");
   return false;
@@ -224,17 +219,11 @@ class CommandObjectProcessLaunch : public 
CommandObjectProcessLaunchOrAttach {
 if (!target_settings_argv0.empty()) {
   m_options.launch_info.GetArguments().AppendArgument(
   target_settings_argv0);
-  if (exe_module_sp)
-m_options.launch_info.SetExecutableFile(
-exe_module_sp->GetPlatformFileSpec(), false);
-  else
-
m_options.launch_info.SetExecutableFile(target->GetProcessLaunchInfo().GetExecutableFile(),
 false);
+  m_options.launch_info.SetExecutableFile(
+  exe_module_sp->GetPlatformFileSpec(), false);
 } else {
-  if (exe_module_sp)
-m_options.launch_info.SetExecutableFile(
-exe_module_sp->GetPlatformFileSpec(), true);
-  else
-
m_options.launch_info.SetExecutableFile(target->GetProcessLaunchInfo().GetExecutableFile(),
 true);
+  m_options.launch_info.SetExecutableFile(
+  exe_module_sp->GetPlatformFileSpec(), true);
 }
 
 if (launch_args.GetArgumentCount() == 0) {
@@ -261,20 +250,11 @@ class CommandObjectProcessLaunch : public 
CommandObjectProcessLaunchOrAttach {
 llvm::StringRef data = stream.GetString();
 if (!data.empty())
   result.AppendMessage(data);
-// If we didn't have a local executable, then we wouldn't have had an
-// executable module before launch.
-if (!exe_module_sp)
-  exe_module_sp = target->GetExecutableModule();
-if (!exe_module_sp) {
-  result.AppendWarning("Could not get executable module after 
launch.");
-} else {
-
-  const char *archname =
-  exe_module_sp->GetArchitecture().GetArchitectureName();
-  result.AppendMessageWithFormat(
-  "Process %" PRIu64 " launched: '%s' (%s)\n", process_sp->GetID(),
-  exe_module_sp->GetFileSpec().GetPath().c_str(), archname);
-}
+const char *archname =
+exe_module_sp->GetArchitecture().GetArchitectureName();
+result.AppendMessageWithFormat(
+"Process %" PRIu64 " launched: '%s' (%s)\n", process_sp->GetID(),
+exe_module_sp->GetFileSpec().GetPath().c_str(), archname);
 result.SetStatus(eReturnStatusSuccessFinishResult);
 result.SetDidChangeProcessState(true);
   } else {

diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 2233bf6758190..a666aeb8bb3f6 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -677,133 +677,143 @@ Status ProcessGDBRemote::DoLaunch(lldb_private::Module 
*exe_module,
   //  LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD);
   //  ::LogSetLogFile ("/dev/stdout");
 
-  error = EstablishConnectionIfNeeded(launch_info);
-  if (error.Succes

[Lldb-commits] [PATCH] D113930: [LLDB][NativePDB] Fix function decl creation for class methods

2021-11-16 Thread Zequan Wu via Phabricator via lldb-commits
zequanwu planned changes to this revision.
zequanwu added a comment.

I realized that the test case here is incorrect, because the output of 
`lldb-test symbols dump-ast ...` shows `void virtual_method()` twice. The `void 
virtual_method()` without `virtual` is created by the new code. Because 
`lldb-test symbols dump-ast ...` calls `Module::ParseAllDebugSymbols()` which 
calls `SymbolFileNativePDB::ParseTypes(CompileUnit &comp_unit)`. It will 
construct all debug info inside TagDecls found from TPI stream, so the second 
`void virtual_method()` shows up.

I tried to use this for testing: `lldb-test symbols --find=function 
--name=full::name --function-flags=full ...`, but it doesn't even shows 
information for function `main`.

I'm working on another way to fix it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113930

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


[Lldb-commits] [PATCH] D113650: [lldb] fix -print-script-interpreter-info on windows

2021-11-16 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

This seems to have broken the green dragon incremental bot: 
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/38387/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113650

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


[Lldb-commits] [PATCH] D113650: [lldb] fix -print-script-interpreter-info on windows

2021-11-16 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna added a comment.

In D113650#3136407 , @aprantl wrote:

> This seems to have broken the green dragon incremental bot: 
> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/38387/



  Crosscompiling LLDB with Python requires manually setting
  LLDB_PYTHON_EXE_RELATIVE_PATH.

can you add -DLLDB_PYTHON_EXE_RELATIVE_PATH=somethign to your cmake script?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113650

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