[Lldb-commits] [PATCH] D111964: [lldb] [lldb-gdbserver] Unify listen/connect code to use ConnectionFileDescriptor

2021-10-25 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I like this. For lack of a better place, I'd place the `LLGSArgToURL` function 
into `GDBRemoteCommunicationServerLLGS.h`. That is the ~highest level file that 
can still be unit tested.




Comment at: lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h:46
+  llvm::StringRef url,
+  std::function socket_id_callback,
+  Status *error_ptr);

I'd use `llvm::function_ref` here



Comment at: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp:550-554
+  if (!error.Fail())
+socket_id_callback(socket_name);
+
+  if (!error.Fail())
+error = listen_socket->Accept(socket);

you can merge these two



Comment at: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp:583-610
+ConnectionStatus ConnectionFileDescriptor::UnixAbstractSocketAccept(
+llvm::StringRef socket_name,
+std::function socket_id_callback,
+Status *error_ptr) {
+  Status error;
+  std::unique_ptr listen_socket = Socket::Create(
+  Socket::ProtocolUnixAbstract, m_child_processes_inherit, error);

This is identical to `NamedSocketAccept` modulo the socket type constant, 
right? Can you merge these?



Comment at: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp:647
 
+  uint16_t port = listening_socket.get()->GetLocalPortNumber();
+  socket_id_callback(port != 0 ? std::to_string(port) : "");

Can this ever be zero ?



Comment at: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp:880
+  if (llvm::Optional url = URI::Parse(url_arg)) {
+if (!reverse_connect) {
+  // Translate the scheme from LLGS notation to ConnectionFileDescriptor.

I'd "reverse" this condition :P



Comment at: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp:898
+  // expect the remainder to be the port.
+  if (host_port[0] == ':')
+host_port = std::string("localhost") + host_port;

Can this string be empty? Maybe use `url_arg.startswith()`, just in case.


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

https://reviews.llvm.org/D111964

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


[Lldb-commits] [PATCH] D112212: [lldb/test] Print build commands in trace mode

2021-10-25 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D112212#3083194 , @teemperor wrote:

> Given that `shlex.join` is only used for making the diagnostics copy-pastable 
> into the terminal, we could probably get away by just making it use the 
> normal string conversion of list or something like `" ".join(...)`. I don't 
> think we have anyone that really debugs tests in Python2 builds.

Yeah, I was thinking the same thing, but given that Oct 26th is like tomorrow, 
I think I can just wait a couple of days.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112212

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


[Lldb-commits] [PATCH] D112169: [lldb] [Communication] Add a WriteAll() method that resumes writing

2021-10-25 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I think it would be worth at least spending a bit of time to understand the 
reason for using non-blocking i/o here. Given that all Reads should go through 
the select(2) in ConnectionFileDescriptor::BytesAvailable, it's possible we 
could avoid it altogether.


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

https://reviews.llvm.org/D112169

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


[Lldb-commits] [PATCH] D112357: [lldb] [Host] Move port predicate-related logic to gdb-remote

2021-10-25 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 pure goodness.


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

https://reviews.llvm.org/D112357

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


[Lldb-commits] [PATCH] D112169: [lldb] [Communication] Add a WriteAll() method that resumes writing

2021-10-25 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

I'm not against that. However, unless I'm mistaken — even with blocking I/O, we 
need to account for the `write()` being interrupted in the middle of operation 
and returning less than `src_len`.


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

https://reviews.llvm.org/D112169

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


[Lldb-commits] [PATCH] D112314: [lldb] [Utility/UriParser] Return results as 'struct URI'

2021-10-25 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.

cool


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

https://reviews.llvm.org/D112314

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


[Lldb-commits] [PATCH] D112169: [lldb] [Communication] Add a WriteAll() method that resumes writing

2021-10-25 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D112169#3083380 , @mgorny wrote:

> I'm not against that. However, unless I'm mistaken — even with blocking I/O, 
> we need to account for the `write()` being interrupted in the middle of 
> operation and returning less than `src_len`.

You're not mistaken. However, we can get rid of the funky sleep.


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

https://reviews.llvm.org/D112169

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


[Lldb-commits] [PATCH] D111964: [lldb] [lldb-gdbserver] Unify listen/connect code to use ConnectionFileDescriptor

2021-10-25 Thread Michał Górny via Phabricator via lldb-commits
mgorny marked 4 inline comments as done.
mgorny added inline comments.



Comment at: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp:583-610
+ConnectionStatus ConnectionFileDescriptor::UnixAbstractSocketAccept(
+llvm::StringRef socket_name,
+std::function socket_id_callback,
+Status *error_ptr) {
+  Status error;
+  std::unique_ptr listen_socket = Socket::Create(
+  Socket::ProtocolUnixAbstract, m_child_processes_inherit, error);

labath wrote:
> This is identical to `NamedSocketAccept` modulo the socket type constant, 
> right? Can you merge these?
Yes; in fact, most of the functions are pretty similar. However, I'd prefer to 
defer merging them until after the port predicate removal patch, as that should 
also open the possibility of combining them with the TCP socket methods too.



Comment at: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp:647
 
+  uint16_t port = listening_socket.get()->GetLocalPortNumber();
+  socket_id_callback(port != 0 ? std::to_string(port) : "");

labath wrote:
> Can this ever be zero ?
Yes, when `getsockname()` fails. I suppose we could modify it to use 
`llvm::Optional<...>` or even `llvm::Expected<...>` but this is one place where 
I don't think we need to care much about proper error handling.



Comment at: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp:898
+  // expect the remainder to be the port.
+  if (host_port[0] == ':')
+host_port = std::string("localhost") + host_port;

labath wrote:
> Can this string be empty? Maybe use `url_arg.startswith()`, just in case.
I don't think it can, or at least I wasn't able to get an empty string in (the 
argument parser seems to reject them) but sure, no harm in being extra secure.


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

https://reviews.llvm.org/D111964

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


[Lldb-commits] [PATCH] D111964: [lldb] [lldb-gdbserver] Unify listen/connect code to use ConnectionFileDescriptor

2021-10-25 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 381876.
mgorny marked an inline comment as done.
mgorny added a comment.

Move to gdb-remote. Update per requests.

I've also added a `typedef` for the callback and optimized the URI parsing a 
bit to hopefully involve less temporary strings.


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

https://reviews.llvm.org/D111964

Files:
  lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
  lldb/test/API/tools/lldb-server/TestPtyServer.py
  lldb/tools/lldb-server/lldb-gdbserver.cpp
  lldb/unittests/Process/gdb-remote/CMakeLists.txt
  lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerLLGSTest.cpp

Index: lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerLLGSTest.cpp
===
--- /dev/null
+++ lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerLLGSTest.cpp
@@ -0,0 +1,75 @@
+//===-- GDBRemoteCommunicationServerLLGSTest.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h"
+
+#include "llvm/Testing/Support/Error.h"
+
+using namespace lldb_private::process_gdb_remote;
+
+TEST(GDBRemoteCommunicationServerLLGSTest, LLGSArgToURL) {
+  // LLGS new-style URLs should be passed through (indepenently of
+  // --reverse-connect)
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("listen://127.0.0.1:1234", false),
+   llvm::HasValue("listen://127.0.0.1:1234"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("listen://127.0.0.1:1234", true),
+   llvm::HasValue("listen://127.0.0.1:1234"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("connect://127.0.0.1:1234", false),
+   llvm::HasValue("connect://127.0.0.1:1234"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("connect://127.0.0.1:1234", true),
+   llvm::HasValue("connect://127.0.0.1:1234"));
+
+  // LLGS legacy listen URLs should be converted if !reverse_connect
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("tcp://127.0.0.1:1234", false),
+   llvm::HasValue("listen://127.0.0.1:1234"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("unix:///tmp/foo", false),
+   llvm::HasValue("unix-accept:///tmp/foo"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("unix-abstract://foo", false),
+   llvm::HasValue("unix-abstract-accept://foo"));
+
+  // LLGS listen host:port pairs should be converted to listen://
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("127.0.0.1:1234", false),
+   llvm::HasValue("listen://127.0.0.1:1234"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("[::1]:1234", false),
+   llvm::HasValue("listen://[::1]:1234"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("[[::1]:1234]", false),
+   llvm::HasValue("listen://[[::1]:1234]"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("localhost:1234", false),
+   llvm::HasValue("listen://localhost:1234"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("*:1234", false),
+   llvm::HasValue("listen://*:1234"));
+
+  // LLGS listen :port special-case should be converted to listen://
+  EXPECT_THAT_EXPECTED(LLGSArgToURL(":1234", false),
+   llvm::HasValue("listen://localhost:1234"));
+
+  // LLGS listen UNIX sockets should be converted to unix-accept://
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("/tmp/foo", false),
+   llvm::HasValue("unix-accept:///tmp/foo"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("127.0.0.1", false),
+   llvm::HasValue("unix-accept://127.0.0.1"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("[::1]", false),
+   llvm::HasValue("unix-accept://[::1]"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("localhost", false),
+   llvm::HasValue("unix-accept://localhost"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL(":frobnicate", false),
+   llvm::HasValue("unix-accept://:frobnicate"));
+
+  // LLGS reverse connect host:port pairs should be converted to listen://
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("127.0.0.1:1234", true),
+   llvm::HasValue("connect://127.0.0.1:1234"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("[::1]:1234", true),
+   llvm::HasValue("connect://[::1]:1234"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("[[::1]:1234]", true),
+   llvm::HasValue("connect://[[::1]:1234]"));
+  EXPECT

[Lldb-commits] [lldb] c1055f0 - [lldb/DWARF] Don't create lldb_private::Functions for gc'ed DW_TAG_subprograms

2021-10-25 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-25T10:32:35+02:00
New Revision: c1055f09190856ae58c9a075b4103d77623228ee

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

LOG: [lldb/DWARF] Don't create lldb_private::Functions for gc'ed 
DW_TAG_subprograms

Front-load the first_valid_code_address check, so that we avoid creating
the function object (instead of simply refusing to use it in queries).

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

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/test/Shell/SymbolFile/DWARF/x86/dead-code-filtering.yaml

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
index ffe24836955fa..00123a4b92160 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
@@ -32,7 +32,8 @@ class DWARFASTParser {
 
   virtual lldb_private::Function *
   ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit,
- const DWARFDIE &die) = 0;
+ const DWARFDIE &die,
+ const lldb_private::AddressRange &range) = 0;
 
   virtual bool
   CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type,

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index ec560f3fdd69d..a240784c942b0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2342,8 +2342,11 @@ size_t DWARFASTParserClang::ParseChildEnumerators(
   return enumerators_added;
 }
 
-Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
-  const DWARFDIE &die) {
+Function *
+DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
+const DWARFDIE &die,
+const AddressRange &func_range) {
+  assert(func_range.GetBaseAddress().IsValid());
   DWARFRangeList func_ranges;
   const char *name = nullptr;
   const char *mangled = nullptr;
@@ -2363,94 +2366,75 @@ Function 
*DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
   if (die.GetDIENamesAndRanges(name, mangled, func_ranges, decl_file, 
decl_line,
decl_column, call_file, call_line, call_column,
&frame_base)) {
+Mangled func_name;
+if (mangled)
+  func_name.SetValue(ConstString(mangled), true);
+else if ((die.GetParent().Tag() == DW_TAG_compile_unit ||
+  die.GetParent().Tag() == DW_TAG_partial_unit) &&
+ Language::LanguageIsCPlusPlus(
+ SymbolFileDWARF::GetLanguage(*die.GetCU())) &&
+ !Language::LanguageIsObjC(
+ SymbolFileDWARF::GetLanguage(*die.GetCU())) &&
+ name && strcmp(name, "main") != 0) {
+  // If the mangled name is not present in the DWARF, generate the
+  // demangled name using the decl context. We skip if the function is
+  // "main" as its name is never mangled.
+  bool is_static = false;
+  bool is_variadic = false;
+  bool has_template_params = false;
+  unsigned type_quals = 0;
+  std::vector param_types;
+  std::vector param_decls;
+  StreamString sstr;
+
+  DWARFDeclContext decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
+  sstr << decl_ctx.GetQualifiedName();
 
-// Union of all ranges in the function DIE (if the function is
-// discontiguous)
-AddressRange func_range;
-lldb::addr_t lowest_func_addr = func_ranges.GetMinRangeBase(0);
-lldb::addr_t highest_func_addr = func_ranges.GetMaxRangeEnd(0);
-if (lowest_func_addr != LLDB_INVALID_ADDRESS &&
-lowest_func_addr <= highest_func_addr) {
-  ModuleSP module_sp(die.GetModule());
-  func_range.GetBaseAddress().ResolveAddressUsingFileSections(
-  lowest_func_addr, module_sp->GetSectionList());
-  if (func_range.GetBaseAddress().IsValid())
-func_range.SetByteSize(highest_func_addr - lowest_func_addr);
-}
-
-if (func_range.GetBaseAddress().IsValid()) {
-  Mangled func_name;
-  if (mangled)
-func_name.SetValue(ConstString(mangled), true);
-  else if ((die.GetParent().Tag() == DW_TAG_compile_unit ||
-die.GetParent().Tag() == DW_TAG_partial_unit) &&
-   Language::Langu

[Lldb-commits] [lldb] 6fa1b4f - Remove ConstString from DynamicLoader, JITLoader and Instruction plugin names

2021-10-25 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-25T10:32:35+02:00
New Revision: 6fa1b4ff4b05b9b9a432f7310802255c160c8f4f

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

LOG: Remove ConstString from DynamicLoader, JITLoader and Instruction plugin 
names

Added: 


Modified: 
lldb/include/lldb/Core/PluginManager.h
lldb/include/lldb/Target/DynamicLoader.h
lldb/source/Core/DynamicLoader.cpp
lldb/source/Core/EmulateInstruction.cpp
lldb/source/Core/PluginManager.cpp

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp
lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h
lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp
lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h
lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
lldb/source/Target/Process.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index 3c79cd2e6c146..97f8dae1bcfd2 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -84,7 +84,7 @@ class PluginManager {
 
   // DynamicLoader
   static bool
-  RegisterPlugin(ConstString name, const char *description,
+  RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  DynamicLoaderCreateInstance create_callback,
  DebuggerInitializeCallback debugger_init_callback = nullptr);
 
@@ -94,11 +94,11 @@ class PluginManager {
   GetDynamicLoaderCreateCallbackAtIndex(uint32_t idx);
 
   static DynamicLoaderCreateInstance
-  GetDynamicLoaderCreateCallbackForPluginName(ConstString name);
+  GetDynamicLoaderCreateCallbackForPluginName(llvm::StringRef name);
 
   // JITLoader
   static bool
-  RegisterPlugin(ConstString name, const char *description,
+  RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  JITLoaderCreateInstance create_callback,
  DebuggerInitializeCallback debugger_init_callback = nullptr);
 
@@ -108,7 +108,7 @@ class PluginManager {
   GetJITLoaderCreateCallbackAtIndex(uint32_t idx);
 
   // EmulateInstruction
-  static bool RegisterPlugin(ConstString name, const char *description,
+  static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  EmulateInstructionCreateInstance create_callback);
 
   static bool
@@ -118,7 +118,7 @@ class PluginManager {
   GetEmulateInstructionCreateCallbackAtIndex(uint32_t idx);
 
   static EmulateInstructionCreateInstance
-  GetEmulateInstructionCreateCallbackForPluginName(ConstString name);
+  GetEmulateInstructionCreateCallbackForPluginName(llvm::StringRef name);
 
   // OperatingSystem
   static bool RegisterPlugin(llv

[Lldb-commits] [PATCH] D112310: [lldb/DWARF] Don't create lldb_private::Functions for gc'ed DW_TAG_subprograms

2021-10-25 Thread Pavel Labath via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc1055f091908: [lldb/DWARF] Don't create 
lldb_private::Functions for gc'ed DW_TAG_subprograms (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112310

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/Shell/SymbolFile/DWARF/x86/dead-code-filtering.yaml

Index: lldb/test/Shell/SymbolFile/DWARF/x86/dead-code-filtering.yaml
===
--- lldb/test/Shell/SymbolFile/DWARF/x86/dead-code-filtering.yaml
+++ lldb/test/Shell/SymbolFile/DWARF/x86/dead-code-filtering.yaml
@@ -1,6 +1,16 @@
 # RUN: yaml2obj %s > %t
+# RUN: lldb-test symbols %t | FileCheck %s --check-prefix=TEST
 # RUN: %lldb %t -o "image dump line-table a.c" -o "image lookup -n _start" -o "image lookup -n f" -o exit | FileCheck %s
 
+# TEST: Compile units:
+# TEST-NEXT: CompileUnit{0x}, language = "c", file = 'a.c'
+# TEST-NEXT: Function{0x0043}, demangled = _start, type_uid = 0x0043
+# TEST-NEXT: Block{0x0043}, ranges = [0x0080-0x0086)
+# TEST-EMPTY:
+# TEST-EMPTY:
+# TEST-NEXT: Symtab
+
+
 # CHECK-LABEL: image dump line-table a.c
 # CHECK-NEXT: Line table for a.c
 # CHECK-NEXT: 0x0080: a.c:1
@@ -59,6 +69,8 @@
   Attributes:
 - Attribute:   DW_AT_producer
   Form:DW_FORM_string
+- Attribute:   DW_AT_language
+  Form:DW_FORM_data1
 - Attribute:   DW_AT_name
   Form:DW_FORM_string
 - Attribute:   DW_AT_stmt_list
@@ -86,6 +98,7 @@
 - AbbrCode:0x0001
   Values:
 - CStr:Hand-written DWARF
+- Value:   2
 - CStr:a.c
 - Value:   0x
 - Value:   0x
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -856,7 +856,32 @@
   if (!dwarf_ast)
 return nullptr;
 
-  return dwarf_ast->ParseFunctionFromDWARF(comp_unit, die);
+  DWARFRangeList ranges;
+  if (die.GetDIE()->GetAttributeAddressRanges(die.GetCU(), ranges,
+  /*check_hi_lo_pc=*/true) == 0)
+return nullptr;
+
+  // Union of all ranges in the function DIE (if the function is
+  // discontiguous)
+  AddressRange func_range;
+  lldb::addr_t lowest_func_addr = ranges.GetMinRangeBase(0);
+  lldb::addr_t highest_func_addr = ranges.GetMaxRangeEnd(0);
+  if (lowest_func_addr == LLDB_INVALID_ADDRESS ||
+  lowest_func_addr >= highest_func_addr ||
+  lowest_func_addr < m_first_code_address)
+return nullptr;
+
+  ModuleSP module_sp(die.GetModule());
+  func_range.GetBaseAddress().ResolveAddressUsingFileSections(
+  lowest_func_addr, module_sp->GetSectionList());
+  if (!func_range.GetBaseAddress().IsValid())
+return nullptr;
+
+  func_range.SetByteSize(highest_func_addr - lowest_func_addr);
+  if (!FixupAddress(func_range.GetBaseAddress()))
+return nullptr;
+
+  return dwarf_ast->ParseFunctionFromDWARF(comp_unit, die, func_range);
 }
 
 lldb::addr_t SymbolFileDWARF::FixupAddress(lldb::addr_t file_addr) {
@@ -2263,10 +2288,8 @@
   addr = sc.function->GetAddressRange().GetBaseAddress();
 }
 
-if (addr.IsValid() && addr.GetFileAddress() >= m_first_code_address) {
-  sc_list.Append(sc);
-  return true;
-}
+sc_list.Append(sc);
+return true;
   }
 
   return false;
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -47,7 +47,8 @@
 
   lldb_private::Function *
   ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit,
- const DWARFDIE &die) override;
+ const DWARFDIE &die,
+ const lldb_private::AddressRange &func_range) override;
 
   bool
   CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type,
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2342,8

[Lldb-commits] [PATCH] D111964: [lldb] [lldb-gdbserver] Unify listen/connect code to use ConnectionFileDescriptor

2021-10-25 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp:583-610
+ConnectionStatus ConnectionFileDescriptor::UnixAbstractSocketAccept(
+llvm::StringRef socket_name,
+std::function socket_id_callback,
+Status *error_ptr) {
+  Status error;
+  std::unique_ptr listen_socket = Socket::Create(
+  Socket::ProtocolUnixAbstract, m_child_processes_inherit, error);

mgorny wrote:
> labath wrote:
> > This is identical to `NamedSocketAccept` modulo the socket type constant, 
> > right? Can you merge these?
> Yes; in fact, most of the functions are pretty similar. However, I'd prefer 
> to defer merging them until after the port predicate removal patch, as that 
> should also open the possibility of combining them with the TCP socket 
> methods too.
Ok, sounds good.



Comment at: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp:647
 
+  uint16_t port = listening_socket.get()->GetLocalPortNumber();
+  socket_id_callback(port != 0 ? std::to_string(port) : "");

mgorny wrote:
> labath wrote:
> > Can this ever be zero ?
> Yes, when `getsockname()` fails. I suppose we could modify it to use 
> `llvm::Optional<...>` or even `llvm::Expected<...>` but this is one place 
> where I don't think we need to care much about proper error handling.
But how can it fail? This is a socket that we've just created and its totally 
under our control...


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

https://reviews.llvm.org/D111964

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


[Lldb-commits] [lldb] 21bb808 - [lldb] Support serial port parity checking

2021-10-25 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-25T10:51:46+02:00
New Revision: 21bb808eb4867b35b08fa962c7c25e812fcc8836

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

LOG: [lldb] Support serial port parity checking

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

Added: 


Modified: 
lldb/include/lldb/Host/File.h
lldb/include/lldb/Host/Terminal.h
lldb/source/Host/common/File.cpp
lldb/source/Host/common/Terminal.cpp
lldb/unittests/Host/posix/TerminalTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/File.h b/lldb/include/lldb/Host/File.h
index c192700590a30..d10ec1fe282a1 100644
--- a/lldb/include/lldb/Host/File.h
+++ b/lldb/include/lldb/Host/File.h
@@ -439,6 +439,7 @@ class SerialPort : public NativeFile {
   struct Options {
 llvm::Optional BaudRate = llvm::None;
 llvm::Optional Parity = llvm::None;
+llvm::Optional ParityCheck = llvm::None;
 llvm::Optional StopBits = llvm::None;
   };
 

diff  --git a/lldb/include/lldb/Host/Terminal.h 
b/lldb/include/lldb/Host/Terminal.h
index ff5db4c6b9b05..81930cdf02361 100644
--- a/lldb/include/lldb/Host/Terminal.h
+++ b/lldb/include/lldb/Host/Terminal.h
@@ -28,6 +28,18 @@ class Terminal {
 Mark,
   };
 
+  enum class ParityCheck {
+// No parity checking
+No,
+// Replace erraneous bytes with NUL
+ReplaceWithNUL,
+// Ignore erraneous bytes
+Ignore,
+// Mark erraneous bytes by prepending them with \xFF\x00; real \xFF
+// is escaped to \xFF\xFF
+Mark,
+  };
+
   Terminal(int fd = -1) : m_fd(fd) {}
 
   ~Terminal() = default;
@@ -54,6 +66,8 @@ class Terminal {
 
   llvm::Error SetParity(Parity parity);
 
+  llvm::Error SetParityCheck(ParityCheck parity_check);
+
   llvm::Error SetHardwareFlowControl(bool enabled);
 
 protected:

diff  --git a/lldb/source/Host/common/File.cpp 
b/lldb/source/Host/common/File.cpp
index 27a47cab78925..daac1fef2f36d 100644
--- a/lldb/source/Host/common/File.cpp
+++ b/lldb/source/Host/common/File.cpp
@@ -794,6 +794,21 @@ SerialPort::OptionsFromURL(llvm::StringRef urlqs) {
 llvm::inconvertibleErrorCode(),
 "Invalid parity (must be no, even, odd, mark or space): %s",
 x.str().c_str());
+} else if (x.consume_front("parity-check=")) {
+  serial_options.ParityCheck =
+  llvm::StringSwitch>(x)
+  .Case("no", Terminal::ParityCheck::No)
+  .Case("replace", Terminal::ParityCheck::ReplaceWithNUL)
+  .Case("ignore", Terminal::ParityCheck::Ignore)
+  // "mark" mode is not currently supported as it requires special
+  // input processing
+  // .Case("mark", Terminal::ParityCheck::Mark)
+  .Default(llvm::None);
+  if (!serial_options.ParityCheck)
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"Invalid parity-check (must be no, replace, ignore or mark): %s",
+x.str().c_str());
 } else if (x.consume_front("stop-bits=")) {
   unsigned int stop_bits;
   if (!llvm::to_integer(x, stop_bits, 10) ||
@@ -831,6 +846,11 @@ SerialPort::Create(int fd, OpenOptions options, Options 
serial_options,
 if (llvm::Error error = term.SetParity(serial_options.Parity.getValue()))
   return std::move(error);
   }
+  if (serial_options.ParityCheck) {
+if (llvm::Error error =
+term.SetParityCheck(serial_options.ParityCheck.getValue()))
+  return std::move(error);
+  }
   if (serial_options.StopBits) {
 if (llvm::Error error =
 term.SetStopBits(serial_options.StopBits.getValue()))

diff  --git a/lldb/source/Host/common/Terminal.cpp 
b/lldb/source/Host/common/Terminal.cpp
index 23cd1dea114bf..1efd1bb9139d3 100644
--- a/lldb/source/Host/common/Terminal.cpp
+++ b/lldb/source/Host/common/Terminal.cpp
@@ -335,6 +335,26 @@ llvm::Error Terminal::SetParity(Terminal::Parity parity) {
 #endif // #if LLDB_ENABLE_TERMIOS
 }
 
+llvm::Error Terminal::SetParityCheck(Terminal::ParityCheck parity_check) {
+  llvm::Expected data = GetData();
+  if (!data)
+return data.takeError();
+
+#if LLDB_ENABLE_TERMIOS
+  struct termios &fd_termios = data->m_termios;
+  fd_termios.c_iflag &= ~(IGNPAR | PARMRK | INPCK);
+
+  if (parity_check != ParityCheck::No) {
+fd_termios.c_iflag |= INPCK;
+if (parity_check == ParityCheck::Ignore)
+  fd_termios.c_iflag |= IGNPAR;
+else if (parity_check == ParityCheck::Mark)
+  fd_termios.c_iflag |= PARMRK;
+  }
+  return SetData(data.get());
+#endif // #if LLDB_ENABLE_TERMIOS
+}
+
 llvm::Error Terminal::SetHardwareFlowControl(bool enabled) {
   llvm::Expected data = GetData();
   if (!data)

diff  --git a/lldb/unittests/Host/posix/TerminalTest.cpp 
b/lldb/unittests/Host/posix/TerminalTest.cpp

[Lldb-commits] [PATCH] D112365: [lldb] Support serial port parity checking

2021-10-25 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG21bb808eb486: [lldb] Support serial port parity checking 
(authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112365

Files:
  lldb/include/lldb/Host/File.h
  lldb/include/lldb/Host/Terminal.h
  lldb/source/Host/common/File.cpp
  lldb/source/Host/common/Terminal.cpp
  lldb/unittests/Host/posix/TerminalTest.cpp

Index: lldb/unittests/Host/posix/TerminalTest.cpp
===
--- lldb/unittests/Host/posix/TerminalTest.cpp
+++ lldb/unittests/Host/posix/TerminalTest.cpp
@@ -190,6 +190,36 @@
 #endif
 }
 
+TEST_F(TerminalTest, SetParityCheck) {
+  struct termios terminfo;
+
+  ASSERT_THAT_ERROR(m_term.SetParityCheck(Terminal::ParityCheck::No),
+llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, &terminfo), 0);
+  EXPECT_EQ(terminfo.c_iflag & (IGNPAR | PARMRK | INPCK), 0U);
+
+  ASSERT_THAT_ERROR(
+  m_term.SetParityCheck(Terminal::ParityCheck::ReplaceWithNUL),
+  llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, &terminfo), 0);
+  EXPECT_NE(terminfo.c_iflag & INPCK, 0U);
+  EXPECT_EQ(terminfo.c_iflag & (IGNPAR | PARMRK), 0U);
+
+  ASSERT_THAT_ERROR(m_term.SetParityCheck(Terminal::ParityCheck::Ignore),
+llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, &terminfo), 0);
+  EXPECT_NE(terminfo.c_iflag & IGNPAR, 0U);
+  EXPECT_EQ(terminfo.c_iflag & PARMRK, 0U);
+  EXPECT_NE(terminfo.c_iflag & INPCK, 0U);
+
+  ASSERT_THAT_ERROR(m_term.SetParityCheck(Terminal::ParityCheck::Mark),
+llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, &terminfo), 0);
+  EXPECT_EQ(terminfo.c_iflag & IGNPAR, 0U);
+  EXPECT_NE(terminfo.c_iflag & PARMRK, 0U);
+  EXPECT_NE(terminfo.c_iflag & INPCK, 0U);
+}
+
 TEST_F(TerminalTest, SetHardwareFlowControl) {
 #if defined(CRTSCTS)
   struct termios terminfo;
Index: lldb/source/Host/common/Terminal.cpp
===
--- lldb/source/Host/common/Terminal.cpp
+++ lldb/source/Host/common/Terminal.cpp
@@ -335,6 +335,26 @@
 #endif // #if LLDB_ENABLE_TERMIOS
 }
 
+llvm::Error Terminal::SetParityCheck(Terminal::ParityCheck parity_check) {
+  llvm::Expected data = GetData();
+  if (!data)
+return data.takeError();
+
+#if LLDB_ENABLE_TERMIOS
+  struct termios &fd_termios = data->m_termios;
+  fd_termios.c_iflag &= ~(IGNPAR | PARMRK | INPCK);
+
+  if (parity_check != ParityCheck::No) {
+fd_termios.c_iflag |= INPCK;
+if (parity_check == ParityCheck::Ignore)
+  fd_termios.c_iflag |= IGNPAR;
+else if (parity_check == ParityCheck::Mark)
+  fd_termios.c_iflag |= PARMRK;
+  }
+  return SetData(data.get());
+#endif // #if LLDB_ENABLE_TERMIOS
+}
+
 llvm::Error Terminal::SetHardwareFlowControl(bool enabled) {
   llvm::Expected data = GetData();
   if (!data)
Index: lldb/source/Host/common/File.cpp
===
--- lldb/source/Host/common/File.cpp
+++ lldb/source/Host/common/File.cpp
@@ -794,6 +794,21 @@
 llvm::inconvertibleErrorCode(),
 "Invalid parity (must be no, even, odd, mark or space): %s",
 x.str().c_str());
+} else if (x.consume_front("parity-check=")) {
+  serial_options.ParityCheck =
+  llvm::StringSwitch>(x)
+  .Case("no", Terminal::ParityCheck::No)
+  .Case("replace", Terminal::ParityCheck::ReplaceWithNUL)
+  .Case("ignore", Terminal::ParityCheck::Ignore)
+  // "mark" mode is not currently supported as it requires special
+  // input processing
+  // .Case("mark", Terminal::ParityCheck::Mark)
+  .Default(llvm::None);
+  if (!serial_options.ParityCheck)
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"Invalid parity-check (must be no, replace, ignore or mark): %s",
+x.str().c_str());
 } else if (x.consume_front("stop-bits=")) {
   unsigned int stop_bits;
   if (!llvm::to_integer(x, stop_bits, 10) ||
@@ -831,6 +846,11 @@
 if (llvm::Error error = term.SetParity(serial_options.Parity.getValue()))
   return std::move(error);
   }
+  if (serial_options.ParityCheck) {
+if (llvm::Error error =
+term.SetParityCheck(serial_options.ParityCheck.getValue()))
+  return std::move(error);
+  }
   if (serial_options.StopBits) {
 if (llvm::Error error =
 term.SetStopBits(serial_options.StopBits.getValue()))
Index: lldb/include/lldb/Host/Terminal.h
===
--- lldb/include/lldb/Host/Terminal.h
+++ lldb/include/lldb/Host/Terminal.h
@@ -28,6 +28,18 @@
 Mark,
   };
 
+  enum class ParityCheck {
+// No parity checking
+No,
+// Replace e

[Lldb-commits] [PATCH] D111964: [lldb] [lldb-gdbserver] Unify listen/connect code to use ConnectionFileDescriptor

2021-10-25 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp:647
 
+  uint16_t port = listening_socket.get()->GetLocalPortNumber();
+  socket_id_callback(port != 0 ? std::to_string(port) : "");

labath wrote:
> mgorny wrote:
> > labath wrote:
> > > Can this ever be zero ?
> > Yes, when `getsockname()` fails. I suppose we could modify it to use 
> > `llvm::Optional<...>` or even `llvm::Expected<...>` but this is one place 
> > where I don't think we need to care much about proper error handling.
> But how can it fail? This is a socket that we've just created and its totally 
> under our control...
Yeah, exactly, that's why I said proper error handling is not very important 
there — but technically the function provides some potential error conditions. 
Are you suggesting we just pass zero as-is then?


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

https://reviews.llvm.org/D111964

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


[Lldb-commits] [lldb] 0e5a414 - [lldb] [Utility/UriParser] Return results as 'struct URI'

2021-10-25 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-25T10:58:21+02:00
New Revision: 0e5a4147e52470516af8c3c6644dca007a6ec4be

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

LOG: [lldb] [Utility/UriParser] Return results as 'struct URI'

Return results of URI parsing as 'struct URI' instead of assigning them
via output parameters.

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

Added: 


Modified: 
lldb/include/lldb/Utility/UriParser.h
lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
lldb/source/Utility/UriParser.cpp
lldb/tools/lldb-server/Acceptor.cpp
lldb/unittests/Host/ConnectionFileDescriptorTest.cpp
lldb/unittests/Host/SocketTest.cpp
lldb/unittests/Utility/UriParserTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/UriParser.h 
b/lldb/include/lldb/Utility/UriParser.h
index f07df8fb24735..3c0f8d2273d03 100644
--- a/lldb/include/lldb/Utility/UriParser.h
+++ b/lldb/include/lldb/Utility/UriParser.h
@@ -13,20 +13,23 @@
 #include "llvm/ADT/StringRef.h"
 
 namespace lldb_private {
-class UriParser {
-public:
-  // Parses
-  // RETURN VALUE
-  //   if url is valid, function returns true and
-  //   scheme/hostname/port/path are set to the parsed values
-  //   port it set to llvm::None if it is not included in the URL
-  //
-  //   if the url is invalid, function returns false and
-  //   output parameters remain unchanged
-  static bool Parse(llvm::StringRef uri, llvm::StringRef &scheme,
-llvm::StringRef &hostname, llvm::Optional &port,
-llvm::StringRef &path);
+
+struct URI {
+  llvm::StringRef scheme;
+  llvm::StringRef hostname;
+  llvm::Optional port;
+  llvm::StringRef path;
+
+  bool operator==(const URI &R) const {
+return port == R.port && scheme == R.scheme && hostname == R.hostname &&
+   path == R.path;
+  }
+
+  static llvm::Optional Parse(llvm::StringRef uri);
 };
-}
+
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const URI &U);
+
+} // namespace lldb_private
 
 #endif // LLDB_UTILITY_URIPARSER_H

diff  --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp 
b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
index f9b5cfd758d89..a9bae540cda7b 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -155,15 +155,14 @@ Status PlatformAndroid::ConnectRemote(Args &args) {
   if (!m_remote_platform_sp)
 m_remote_platform_sp = PlatformSP(new PlatformAndroidRemoteGDBServer());
 
-  llvm::Optional port;
-  llvm::StringRef scheme, host, path;
   const char *url = args.GetArgumentAtIndex(0);
   if (!url)
 return Status("URL is null.");
-  if (!UriParser::Parse(url, scheme, host, port, path))
+  llvm::Optional parsed_url = URI::Parse(url);
+  if (!parsed_url)
 return Status("Invalid URL: %s", url);
-  if (host != "localhost")
-m_device_id = std::string(host);
+  if (parsed_url->hostname != "localhost")
+m_device_id = parsed_url->hostname.str();
 
   auto error = PlatformLinux::ConnectRemote(args);
   if (error.Success()) {

diff  --git 
a/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp 
b/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
index 3c9a33c93d27b..d172ce5802c05 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
@@ -109,25 +109,25 @@ Status PlatformAndroidRemoteGDBServer::ConnectRemote(Args 
&args) {
 return Status(
 "\"platform connect\" takes a single argument: ");
 
-  llvm::Optional remote_port;
-  llvm::StringRef scheme, host, path;
   const char *url = args.GetArgumentAtIndex(0);
   if (!url)
 return Status("URL is null.");
-  if (!UriParser::Parse(url, scheme, host, remote_port, path))
+  llvm::Optional parsed_url = URI::Parse(url);
+  if (!parsed_url)
 return Status("Invalid URL: %s", url);
-  if (host != "localhost")
-m_device_id = std::string(host);
+  if (parsed_url->hostname != "localhost")
+m_device_id = parsed_url->hostname.str();
 
   m_socket_namespace.reset();
-  if (scheme == "unix-connect")
+  if (parsed_url->scheme == "unix-connect")
 m_socket_namespace = AdbClient::UnixSocketNamespaceFileSystem;
-  else if (scheme == "unix-abstract-connect")
+  else if (parsed_url->scheme == "unix-abstract-connect")
 m_socket_namespace = AdbClient::UnixSocketNamespaceAbstract;
 
   std::string connect_url;
-  auto error = MakeConnect

[Lldb-commits] [PATCH] D112314: [lldb] [Utility/UriParser] Return results as 'struct URI'

2021-10-25 Thread Michał Górny via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0e5a4147e524: [lldb] [Utility/UriParser] Return results as 
'struct URI' (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112314

Files:
  lldb/include/lldb/Utility/UriParser.h
  lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
  lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
  lldb/source/Utility/UriParser.cpp
  lldb/tools/lldb-server/Acceptor.cpp
  lldb/unittests/Host/ConnectionFileDescriptorTest.cpp
  lldb/unittests/Host/SocketTest.cpp
  lldb/unittests/Utility/UriParserTest.cpp

Index: lldb/unittests/Utility/UriParserTest.cpp
===
--- lldb/unittests/Utility/UriParserTest.cpp
+++ lldb/unittests/Utility/UriParserTest.cpp
@@ -3,174 +3,95 @@
 
 using namespace lldb_private;
 
-// result strings (scheme/hostname/port/path) passed into UriParser::Parse
-// are initialized to kAsdf so we can verify that they are unmodified if the
-// URI is invalid
-static const char *kAsdf = "asdf";
-
-class UriTestCase {
-public:
-  UriTestCase(const char *uri, const char *scheme, const char *hostname,
-  llvm::Optional port, const char *path)
-  : m_uri(uri), m_result(true), m_scheme(scheme), m_hostname(hostname),
-m_port(port), m_path(path) {}
-
-  UriTestCase(const char *uri)
-  : m_uri(uri), m_result(false), m_scheme(kAsdf), m_hostname(kAsdf),
-m_port(1138), m_path(kAsdf) {}
-
-  const char *m_uri;
-  bool m_result;
-  const char *m_scheme;
-  const char *m_hostname;
-  llvm::Optional m_port;
-  const char *m_path;
-};
-
-#define VALIDATE   \
-  llvm::StringRef scheme(kAsdf);   \
-  llvm::StringRef hostname(kAsdf); \
-  llvm::Optional port(1138); \
-  llvm::StringRef path(kAsdf); \
-  EXPECT_EQ(testCase.m_result, \
-UriParser::Parse(testCase.m_uri, scheme, hostname, port, path));   \
-  EXPECT_STREQ(testCase.m_scheme, scheme.str().c_str());   \
-  EXPECT_STREQ(testCase.m_hostname, hostname.str().c_str());   \
-  EXPECT_EQ(testCase.m_port, port);\
-  EXPECT_STREQ(testCase.m_path, path.str().c_str());
-
 TEST(UriParserTest, Minimal) {
-  const UriTestCase testCase("x://y", "x", "y", llvm::None, "/");
-  VALIDATE
+  EXPECT_EQ((URI{"x", "y", llvm::None, "/"}), URI::Parse("x://y"));
 }
 
 TEST(UriParserTest, MinimalPort) {
-  const UriTestCase testCase("x://y:1", "x", "y", 1, "/");
-  llvm::StringRef scheme(kAsdf);
-  llvm::StringRef hostname(kAsdf);
-  llvm::Optional port(1138);
-  llvm::StringRef path(kAsdf);
-  bool result = UriParser::Parse(testCase.m_uri, scheme, hostname, port, path);
-  EXPECT_EQ(testCase.m_result, result);
-
-  EXPECT_STREQ(testCase.m_scheme, scheme.str().c_str());
-  EXPECT_STREQ(testCase.m_hostname, hostname.str().c_str());
-  EXPECT_EQ(testCase.m_port, port);
-  EXPECT_STREQ(testCase.m_path, path.str().c_str());
+  EXPECT_EQ((URI{"x", "y", 1, "/"}), URI::Parse("x://y:1"));
 }
 
 TEST(UriParserTest, MinimalPath) {
-  const UriTestCase testCase("x://y/", "x", "y", llvm::None, "/");
-  VALIDATE
+  EXPECT_EQ((URI{"x", "y", llvm::None, "/"}), URI::Parse("x://y/"));
 }
 
 TEST(UriParserTest, MinimalPortPath) {
-  const UriTestCase testCase("x://y:1/", "x", "y", 1, "/");
-  VALIDATE
+  EXPECT_EQ((URI{"x", "y", 1, "/"}), URI::Parse("x://y:1/"));
 }
 
 TEST(UriParserTest, LongPath) {
-  const UriTestCase testCase("x://y/abc/def/xyz", "x", "y", llvm::None,
- "/abc/def/xyz");
-  VALIDATE
+  EXPECT_EQ((URI{"x", "y", llvm::None, "/abc/def/xyz"}),
+URI::Parse("x://y/abc/def/xyz"));
 }
 
 TEST(UriParserTest, TypicalPortPathIPv4) {
-  const UriTestCase testCase("connect://192.168.100.132:5432/", "connect",
- "192.168.100.132", 5432, "/");
-  VALIDATE;
+  EXPECT_EQ((URI{"connect", "192.168.100.132", 5432, "/"}),
+URI::Parse("connect://192.168.100.132:5432/"));
 }
 
 TEST(UriParserTest, TypicalPortPathIPv6) {
-  const UriTestCase testCase(
-  "connect://[2601:600:107f:db64:a42b:4faa:284:3082]:5432/", "connect",
-  "2601:600:107f:db64:a42b:4faa:284:3082", 5432, "/");
-  VALIDATE;
+  EXPECT_EQ(
+  (URI{"connect", "2601:600:107f:db64:a42b:4faa:284:3082", 5432, "/"}),
+  URI::Parse("connect://[2601

[Lldb-commits] [lldb] 1397c56 - Fix windows build for 6fa1b4ff4

2021-10-25 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-25T11:12:39+02:00
New Revision: 1397c56d7ae844033d8ba9b7dee2b1b30a6b37c0

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

LOG: Fix windows build for 6fa1b4ff4

Added: 


Modified: 
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
index 0952e2da289e0..7990079170a61 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -624,7 +624,7 @@ lldb::addr_t ProcessWindows::GetImageInfoAddress() {
 DynamicLoaderWindowsDYLD *ProcessWindows::GetDynamicLoader() {
   if (m_dyld_up.get() == NULL)
 m_dyld_up.reset(DynamicLoader::FindPlugin(
-this, DynamicLoaderWindowsDYLD::GetPluginNameStatic().GetCString()));
+this, DynamicLoaderWindowsDYLD::GetPluginNameStatic()));
   return static_cast(m_dyld_up.get());
 }
 



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


[Lldb-commits] [lldb] 309fccd - [lldb][NFC] Use llvm::Optional to refer to Optional

2021-10-25 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-10-25T11:37:15+02:00
New Revision: 309fccdac936c49d0771878b3f4dd345a5e1c5d8

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

LOG: [lldb][NFC] Use llvm::Optional to refer to Optional

clang::Optional is just an alias used within Clang.

Added: 


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

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index a240784c942b0..0b3f83e709622 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2786,7 +2786,7 @@ void DWARFASTParserClang::ParseSingleMember(
   die.GetCU()->Supports_unnamed_objc_bitfields();
 
 if (detect_unnamed_bitfields) {
-  clang::Optional unnamed_field_info;
+  llvm::Optional unnamed_field_info;
   uint64_t last_field_end = 0;
 
   last_field_end = last_field_info.bit_offset + last_field_info.bit_size;



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


[Lldb-commits] [PATCH] D111964: [lldb] [lldb-gdbserver] Unify listen/connect code to use ConnectionFileDescriptor

2021-10-25 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 381916.
mgorny added a comment.

Remove error handling from socket name getters.


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

https://reviews.llvm.org/D111964

Files:
  lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
  lldb/test/API/tools/lldb-server/TestPtyServer.py
  lldb/tools/lldb-server/lldb-gdbserver.cpp
  lldb/unittests/Process/gdb-remote/CMakeLists.txt
  lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerLLGSTest.cpp

Index: lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerLLGSTest.cpp
===
--- /dev/null
+++ lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerLLGSTest.cpp
@@ -0,0 +1,75 @@
+//===-- GDBRemoteCommunicationServerLLGSTest.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h"
+
+#include "llvm/Testing/Support/Error.h"
+
+using namespace lldb_private::process_gdb_remote;
+
+TEST(GDBRemoteCommunicationServerLLGSTest, LLGSArgToURL) {
+  // LLGS new-style URLs should be passed through (indepenently of
+  // --reverse-connect)
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("listen://127.0.0.1:1234", false),
+   llvm::HasValue("listen://127.0.0.1:1234"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("listen://127.0.0.1:1234", true),
+   llvm::HasValue("listen://127.0.0.1:1234"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("connect://127.0.0.1:1234", false),
+   llvm::HasValue("connect://127.0.0.1:1234"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("connect://127.0.0.1:1234", true),
+   llvm::HasValue("connect://127.0.0.1:1234"));
+
+  // LLGS legacy listen URLs should be converted if !reverse_connect
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("tcp://127.0.0.1:1234", false),
+   llvm::HasValue("listen://127.0.0.1:1234"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("unix:///tmp/foo", false),
+   llvm::HasValue("unix-accept:///tmp/foo"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("unix-abstract://foo", false),
+   llvm::HasValue("unix-abstract-accept://foo"));
+
+  // LLGS listen host:port pairs should be converted to listen://
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("127.0.0.1:1234", false),
+   llvm::HasValue("listen://127.0.0.1:1234"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("[::1]:1234", false),
+   llvm::HasValue("listen://[::1]:1234"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("[[::1]:1234]", false),
+   llvm::HasValue("listen://[[::1]:1234]"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("localhost:1234", false),
+   llvm::HasValue("listen://localhost:1234"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("*:1234", false),
+   llvm::HasValue("listen://*:1234"));
+
+  // LLGS listen :port special-case should be converted to listen://
+  EXPECT_THAT_EXPECTED(LLGSArgToURL(":1234", false),
+   llvm::HasValue("listen://localhost:1234"));
+
+  // LLGS listen UNIX sockets should be converted to unix-accept://
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("/tmp/foo", false),
+   llvm::HasValue("unix-accept:///tmp/foo"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("127.0.0.1", false),
+   llvm::HasValue("unix-accept://127.0.0.1"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("[::1]", false),
+   llvm::HasValue("unix-accept://[::1]"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("localhost", false),
+   llvm::HasValue("unix-accept://localhost"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL(":frobnicate", false),
+   llvm::HasValue("unix-accept://:frobnicate"));
+
+  // LLGS reverse connect host:port pairs should be converted to listen://
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("127.0.0.1:1234", true),
+   llvm::HasValue("connect://127.0.0.1:1234"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("[::1]:1234", true),
+   llvm::HasValue("connect://[::1]:1234"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("[[::1]:1234]", true),
+   llvm::HasValue("connect://[[::1]:1234]"));
+  EXPECT_THAT_EXPECTED(LLGSArgToURL("localhost:1234", true),
+   llvm::HasValue("connect://localhost:1234"));
+}
+
Index: lldb/unittests/Process/gdb-r

[Lldb-commits] [PATCH] D111964: [lldb] [lldb-gdbserver] Unify listen/connect code to use ConnectionFileDescriptor

2021-10-25 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 381918.
mgorny added a comment.

Remove error handling from URI mapping to make the code simpler. In the end, 
the only possible error here was '--reverse-connect without valid host:port' 
and we can just treat that as UNIX connect for symmetry with 
non-reverse-connect mode.


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

https://reviews.llvm.org/D111964

Files:
  lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
  lldb/test/API/tools/lldb-server/TestPtyServer.py
  lldb/tools/lldb-server/lldb-gdbserver.cpp
  lldb/unittests/Process/gdb-remote/CMakeLists.txt
  lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerLLGSTest.cpp

Index: lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerLLGSTest.cpp
===
--- /dev/null
+++ lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerLLGSTest.cpp
@@ -0,0 +1,63 @@
+//===-- GDBRemoteCommunicationServerLLGSTest.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h"
+
+using namespace lldb_private::process_gdb_remote;
+
+TEST(GDBRemoteCommunicationServerLLGSTest, LLGSArgToURL) {
+  // LLGS new-style URLs should be passed through (indepenently of
+  // --reverse-connect)
+  EXPECT_EQ(LLGSArgToURL("listen://127.0.0.1:1234", false),
+"listen://127.0.0.1:1234");
+  EXPECT_EQ(LLGSArgToURL("listen://127.0.0.1:1234", true),
+"listen://127.0.0.1:1234");
+  EXPECT_EQ(LLGSArgToURL("connect://127.0.0.1:1234", false),
+"connect://127.0.0.1:1234");
+  EXPECT_EQ(LLGSArgToURL("connect://127.0.0.1:1234", true),
+"connect://127.0.0.1:1234");
+
+  // LLGS legacy listen URLs should be converted if !reverse_connect
+  EXPECT_EQ(LLGSArgToURL("tcp://127.0.0.1:1234", false),
+"listen://127.0.0.1:1234");
+  EXPECT_EQ(LLGSArgToURL("unix:///tmp/foo", false), "unix-accept:///tmp/foo");
+  EXPECT_EQ(LLGSArgToURL("unix-abstract://foo", false),
+"unix-abstract-accept://foo");
+
+  // LLGS listen host:port pairs should be converted to listen://
+  EXPECT_EQ(LLGSArgToURL("127.0.0.1:1234", false), "listen://127.0.0.1:1234");
+  EXPECT_EQ(LLGSArgToURL("[::1]:1234", false), "listen://[::1]:1234");
+  EXPECT_EQ(LLGSArgToURL("[[::1]:1234]", false), "listen://[[::1]:1234]");
+  EXPECT_EQ(LLGSArgToURL("localhost:1234", false), "listen://localhost:1234");
+  EXPECT_EQ(LLGSArgToURL("*:1234", false), "listen://*:1234");
+
+  // LLGS listen :port special-case should be converted to listen://
+  EXPECT_EQ(LLGSArgToURL(":1234", false), "listen://localhost:1234");
+
+  // LLGS listen UNIX sockets should be converted to unix-accept://
+  EXPECT_EQ(LLGSArgToURL("/tmp/foo", false), "unix-accept:///tmp/foo");
+  EXPECT_EQ(LLGSArgToURL("127.0.0.1", false), "unix-accept://127.0.0.1");
+  EXPECT_EQ(LLGSArgToURL("[::1]", false), "unix-accept://[::1]");
+  EXPECT_EQ(LLGSArgToURL("localhost", false), "unix-accept://localhost");
+  EXPECT_EQ(LLGSArgToURL(":frobnicate", false), "unix-accept://:frobnicate");
+
+  // LLGS reverse connect host:port pairs should be converted to connect://
+  EXPECT_EQ(LLGSArgToURL("127.0.0.1:1234", true), "connect://127.0.0.1:1234");
+  EXPECT_EQ(LLGSArgToURL("[::1]:1234", true), "connect://[::1]:1234");
+  EXPECT_EQ(LLGSArgToURL("[[::1]:1234]", true), "connect://[[::1]:1234]");
+  EXPECT_EQ(LLGSArgToURL("localhost:1234", true), "connect://localhost:1234");
+
+  // with LLGS reverse connect, anything else goes as unix-connect://
+  EXPECT_EQ(LLGSArgToURL("/tmp/foo", true), "unix-connect:///tmp/foo");
+  EXPECT_EQ(LLGSArgToURL("127.0.0.1", true), "unix-connect://127.0.0.1");
+  EXPECT_EQ(LLGSArgToURL("[::1]", true), "unix-connect://[::1]");
+  EXPECT_EQ(LLGSArgToURL("localhost", true), "unix-connect://localhost");
+  EXPECT_EQ(LLGSArgToURL(":frobnicate", true), "unix-connect://:frobnicate");
+}
Index: lldb/unittests/Process/gdb-remote/CMakeLists.txt
===
--- lldb/unittests/Process/gdb-remote/CMakeLists.txt
+++ lldb/unittests/Process/gdb-remote/CMakeLists.txt
@@ -1,6 +1,7 @@
 add_lldb_unittest(ProcessGdbRemoteTests
   GDBRemoteClientBaseTest.cpp
   GDBRemoteCommunicationClientTest.cpp
+  GDBRemoteCommunicationServerLLGSTest.cpp
   GDBRemoteCommunicationServerTest.cpp
   GDBRemoteCommunicationTest.cpp
   GDBRemoteTestUtils.cpp
Index: 

[Lldb-commits] [lldb] a24b2b6 - [lldb] Also print index of child when ValueCheck fails

2021-10-25 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-10-25T13:03:56+02:00
New Revision: a24b2b6aa06a001a98328acf624a5a8b1ab4139a

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

LOG: [lldb] Also print index of child when ValueCheck fails

Makes the test failure reason more obvious in cases where we have unnamed fields
or large records.

Added: 


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

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 3ba3084690fae..d8940b996f8dc 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -315,7 +315,8 @@ def check_value_children(self, test_base, val, 
error_msg=None):
 for i in range(0, val.GetNumChildren()):
 expected_child = self.children[i]
 actual_child = val.GetChildAtIndex(i)
-expected_child.check_value(test_base, actual_child, error_msg)
+child_error = "Checking child with index " + str(i) + ":\n" + 
error_msg
+expected_child.check_value(test_base, actual_child, child_error)
 
 class recording(SixStringIO):
 """



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


[Lldb-commits] [lldb] 025f6ca - [lldb] Modernize TestBitfields

2021-10-25 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-10-25T13:11:39+02:00
New Revision: 025f6ca7c469b6412b58b69fab17092548d5f6c1

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

LOG: [lldb] Modernize TestBitfields

This just does the usual modernizations such as using new test functions where
possible, clang-formatting the source, avoiding manual process setup,
assert improvements (` assertTrue(a == b) -> assertEqual(a, b)`).

This doesn't add any new test cases but removes some dependence on unrelated
features where possible (e.g., structs declared in functions, using the standard
library to printf stuff or initialize objects).

Added: 


Modified: 
lldb/test/API/lang/c/bitfields/TestBitfields.py
lldb/test/API/lang/c/bitfields/main.c

Removed: 




diff  --git a/lldb/test/API/lang/c/bitfields/TestBitfields.py 
b/lldb/test/API/lang/c/bitfields/TestBitfields.py
index 2f52fce21ec57..4a144d5e80c65 100644
--- a/lldb/test/API/lang/c/bitfields/TestBitfields.py
+++ b/lldb/test/API/lang/c/bitfields/TestBitfields.py
@@ -1,4 +1,4 @@
-"""Show bitfields and check that they display correctly."""
+"""Test C bitfields."""
 
 
 
@@ -8,142 +8,100 @@
 from lldbsuite.test import lldbutil
 
 
-class BitfieldsTestCase(TestBase):
+class TestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
-def setUp(self):
-# Call super's setUp().
-TestBase.setUp(self)
-# Find the line number to break inside main().
-self.line = line_number('main.c', '// Set break point at this line.')
+def run_to_main(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec("main.c"))
 
 # BitFields exhibit crashes in record layout on Windows
 # (http://llvm.org/pr21800)
 @skipIfWindows
-def test_and_run_command(self):
-"""Test 'frame variable ...' on a variable with bitfields."""
-self.build()
-exe = self.getBuildArtifact("a.out")
-self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
-
-# Break inside the main.
-lldbutil.run_break_set_by_file_and_line(
-self, "main.c", self.line, num_expected_locations=1, 
loc_exact=True)
-
-self.runCmd("run", RUN_SUCCEEDED)
-
-# The stop reason of the thread should be breakpoint.
-self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
-substrs=['stopped',
- 'stop reason = breakpoint'])
-
-# The breakpoint should have a hit count of 1.
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
-
-# This should display correctly.
-self.expect(
-"frame variable --show-types bits",
-VARIABLES_DISPLAYED_CORRECTLY,
-substrs=[
-'(uint32_t:1) b1 = 1',
-'(uint32_t:2) b2 = 3',
-'(uint32_t:3) b3 = 7',
-'(uint32_t) b4 = 15',
-'(uint32_t:5) b5 = 31',
-'(uint32_t:6) b6 = 63',
-'(uint32_t:7) b7 = 127',
-'(uint32_t:4) four = 15'])
-
-# And so should this.
-# rdar://problem/8348251
-self.expect(
-"frame variable --show-types",
-VARIABLES_DISPLAYED_CORRECTLY,
-substrs=[
-'(uint32_t:1) b1 = 1',
-'(uint32_t:2) b2 = 3',
-'(uint32_t:3) b3 = 7',
-'(uint32_t) b4 = 15',
-'(uint32_t:5) b5 = 31',
-'(uint32_t:6) b6 = 63',
-'(uint32_t:7) b7 = 127',
-'(uint32_t:4) four = 15'])
-
-self.expect("expr (bits.b1)", VARIABLES_DISPLAYED_CORRECTLY,
-substrs=['uint32_t', '1'])
-self.expect("expr (bits.b2)", VARIABLES_DISPLAYED_CORRECTLY,
-substrs=['uint32_t', '3'])
-self.expect("expr (bits.b3)", VARIABLES_DISPLAYED_CORRECTLY,
-substrs=['uint32_t', '7'])
-self.expect("expr (bits.b4)", VARIABLES_DISPLAYED_CORRECTLY,
-substrs=['uint32_t', '15'])
-self.expect("expr (bits.b5)", VARIABLES_DISPLAYED_CORRECTLY,
-substrs=['uint32_t', '31'])
-self.expect("expr (bits.b6)", VARIABLES_DISPLAYED_CORRECTLY,
-substrs=['uint32_t', '63'])
-self.expect("expr (bits.b7)", VARIABLES_DISPLAYED_CORRECTLY,
-substrs=['uint32_t', '127'])
-self.expect("expr (bits.four)", VARIABLES_DISPLAYED_CORRECTLY,
-substrs=['uint32_t', '15'])
-
-self.expect(
-"frame variable --show-types more_bits",
-VARIABLES_DISPLAYED_CORRECTLY,
-substrs=[

[Lldb-commits] [PATCH] D112439: normalize file path when searching the source map

2021-10-25 Thread Xu Jun via Phabricator via lldb-commits
xujuntwt95329 created this revision.
xujuntwt95329 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The key stored in the source map is a normalized path string with host's
path style, so it is also necessary to normalize the file path during
searching the map


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112439

Files:
  lldb/source/Target/PathMappingList.cpp


Index: lldb/source/Target/PathMappingList.cpp
===
--- lldb/source/Target/PathMappingList.cpp
+++ lldb/source/Target/PathMappingList.cpp
@@ -218,7 +218,12 @@
 }
 
 llvm::Optional PathMappingList::FindFile(const FileSpec &orig_spec) 
const {
-  if (auto remapped = RemapPath(orig_spec.GetPath(), /*only_if_exists=*/true))
+  // We must normalize the orig_spec again using the host's path style,
+  // otherwise there will be mismatch between the host and remote platform
+  // if they use different path styles.
+  if (auto remapped = RemapPath(
+  NormalizePath(ConstString(orig_spec.GetCString())).GetStringRef(),
+  /*only_if_exists=*/true))
 return remapped;
 
   return {};


Index: lldb/source/Target/PathMappingList.cpp
===
--- lldb/source/Target/PathMappingList.cpp
+++ lldb/source/Target/PathMappingList.cpp
@@ -218,7 +218,12 @@
 }
 
 llvm::Optional PathMappingList::FindFile(const FileSpec &orig_spec) const {
-  if (auto remapped = RemapPath(orig_spec.GetPath(), /*only_if_exists=*/true))
+  // We must normalize the orig_spec again using the host's path style,
+  // otherwise there will be mismatch between the host and remote platform
+  // if they use different path styles.
+  if (auto remapped = RemapPath(
+  NormalizePath(ConstString(orig_spec.GetCString())).GetStringRef(),
+  /*only_if_exists=*/true))
 return remapped;
 
   return {};
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D112442: [lldb] [Host/ConnectionFileDescriptor] Do not use non-blocking mode

2021-10-25 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste, teemperor.
mgorny requested review of this revision.

Disable non-blocking mode that's enabled only for file:// and serial://
protocols.  We do not seem to have a really good reason for it, and it
only complicates handling partial writes.


https://reviews.llvm.org/D112442

Files:
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp


Index: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
===
--- lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -722,13 +722,6 @@
 llvm::sys::RetryAfterSignal(-1, ::tcsetattr, fd, TCSANOW, &options);
   }
 
-  int flags = ::fcntl(fd, F_GETFL, 0);
-  if (flags >= 0) {
-if ((flags & O_NONBLOCK) == 0) {
-  flags |= O_NONBLOCK;
-  ::fcntl(fd, F_SETFL, flags);
-}
-  }
   m_io_sp =
   std::make_shared(fd, File::eOpenOptionReadWrite, true);
   return eConnectionStatusSuccess;
@@ -761,14 +754,6 @@
 return eConnectionStatusError;
   }
 
-  int flags = ::fcntl(fd, F_GETFL, 0);
-  if (flags >= 0) {
-if ((flags & O_NONBLOCK) == 0) {
-  flags |= O_NONBLOCK;
-  ::fcntl(fd, F_SETFL, flags);
-}
-  }
-
   llvm::Expected> serial_sp = SerialPort::Create(
   fd, File::eOpenOptionReadWrite, serial_options.get(), true);
   if (!serial_sp) {


Index: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
===
--- lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -722,13 +722,6 @@
 llvm::sys::RetryAfterSignal(-1, ::tcsetattr, fd, TCSANOW, &options);
   }
 
-  int flags = ::fcntl(fd, F_GETFL, 0);
-  if (flags >= 0) {
-if ((flags & O_NONBLOCK) == 0) {
-  flags |= O_NONBLOCK;
-  ::fcntl(fd, F_SETFL, flags);
-}
-  }
   m_io_sp =
   std::make_shared(fd, File::eOpenOptionReadWrite, true);
   return eConnectionStatusSuccess;
@@ -761,14 +754,6 @@
 return eConnectionStatusError;
   }
 
-  int flags = ::fcntl(fd, F_GETFL, 0);
-  if (flags >= 0) {
-if ((flags & O_NONBLOCK) == 0) {
-  flags |= O_NONBLOCK;
-  ::fcntl(fd, F_SETFL, flags);
-}
-  }
-
   llvm::Expected> serial_sp = SerialPort::Create(
   fd, File::eOpenOptionReadWrite, serial_options.get(), true);
   if (!serial_sp) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D112442: [lldb] [Host/ConnectionFileDescriptor] Do not use non-blocking mode

2021-10-25 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.

All read should be going through the select(2) in 
ConnectionFileDescriptor::BytesAvaliable, which effectively erases 
(non-)blocking mode differences in reading. And we do want to perform writes in 
blocking mode.


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

https://reviews.llvm.org/D112442

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


[Lldb-commits] [lldb] 40e4ac3 - [lldb] Modernize Platform::GetOSBuildString

2021-10-25 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-25T15:58:58+02:00
New Revision: 40e4ac3e5b3548aa77367da37aba52f2556b855e

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

LOG: [lldb] Modernize Platform::GetOSBuildString

Added: 


Modified: 
lldb/include/lldb/Target/Platform.h
lldb/include/lldb/Target/RemoteAwarePlatform.h
lldb/source/API/SBPlatform.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/source/Target/Platform.cpp
lldb/source/Target/RemoteAwarePlatform.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index 7cb534afe6ecc..d1351d5c729b4 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -212,7 +212,7 @@ class Platform : public PluginInterface {
 
   bool SetOSVersion(llvm::VersionTuple os_version);
 
-  bool GetOSBuildString(std::string &s);
+  llvm::Optional GetOSBuildString();
 
   bool GetOSKernelDescription(std::string &s);
 
@@ -240,9 +240,8 @@ class Platform : public PluginInterface {
   // HostInfo::GetOSVersion().
   virtual bool GetRemoteOSVersion() { return false; }
 
-  virtual bool GetRemoteOSBuildString(std::string &s) {
-s.clear();
-return false;
+  virtual llvm::Optional GetRemoteOSBuildString() {
+return llvm::None;
   }
 
   virtual bool GetRemoteOSKernelDescription(std::string &s) {

diff  --git a/lldb/include/lldb/Target/RemoteAwarePlatform.h 
b/lldb/include/lldb/Target/RemoteAwarePlatform.h
index 269d152998897..d8f7720d2fd96 100644
--- a/lldb/include/lldb/Target/RemoteAwarePlatform.h
+++ b/lldb/include/lldb/Target/RemoteAwarePlatform.h
@@ -64,7 +64,7 @@ class RemoteAwarePlatform : public Platform {
  FileSpec &local_file) override;
 
   bool GetRemoteOSVersion() override;
-  bool GetRemoteOSBuildString(std::string &s) override;
+  llvm::Optional GetRemoteOSBuildString() override;
   bool GetRemoteOSKernelDescription(std::string &s) override;
   ArchSpec GetRemoteSystemArchitecture() override;
 

diff  --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp
index 496c40a0678fe..71d6b1c41e32f 100644
--- a/lldb/source/API/SBPlatform.cpp
+++ b/lldb/source/API/SBPlatform.cpp
@@ -458,13 +458,11 @@ const char *SBPlatform::GetOSBuild() {
 
   PlatformSP platform_sp(GetSP());
   if (platform_sp) {
-std::string s;
-if (platform_sp->GetOSBuildString(s)) {
-  if (!s.empty()) {
-// Const-ify the string so we don't need to worry about the lifetime of
-// the string
-return ConstString(s.c_str()).GetCString();
-  }
+std::string s = platform_sp->GetOSBuildString().getValueOr("");
+if (!s.empty()) {
+  // Const-ify the string so we don't need to worry about the lifetime of
+  // the string
+  return ConstString(s).GetCString();
 }
   }
   return nullptr;

diff  --git 
a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
index 236eacebf7148..97b2b4a3b7401 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
@@ -630,13 +630,12 @@ Status PlatformRemoteDarwinDevice::GetSharedModule(
 uint32_t PlatformRemoteDarwinDevice::GetConnectedSDKIndex() {
   if (IsConnected()) {
 if (m_connected_module_sdk_idx == UINT32_MAX) {
-  std::string build;
-  if (GetRemoteOSBuildString(build)) {
+  if (llvm::Optional build = GetRemoteOSBuildString()) {
 const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
 for (uint32_t i = 0; i < num_sdk_infos; ++i) {
   const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
   if (strstr(sdk_dir_info.directory.GetFilename().AsCString(""),
- build.c_str())) {
+ build->c_str())) {
 m_connected_module_sdk_idx = i;
   }
 }

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
index ea93d9944879c..c654f3c4264f9 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
@@ -163,8 +163,8 @@ lldb_private::Status PlatformRemoteMacOSX::GetFileWithUUID(
 #if !defined(__linux__)
 local_

[Lldb-commits] [PATCH] D112169: [lldb] [Communication] Add a WriteAll() method that resumes writing

2021-10-25 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 381980.
mgorny added a comment.

`sleep()` is no longer necessary now that we're operating in blocking mode.


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

https://reviews.llvm.org/D112169

Files:
  lldb/include/lldb/Core/Communication.h
  lldb/source/Core/Communication.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp


Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -101,7 +101,7 @@
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
   ConnectionStatus status = eConnectionStatusSuccess;
   char ch = '+';
-  const size_t bytes_written = Write(&ch, 1, status, nullptr);
+  const size_t bytes_written = WriteAll(&ch, 1, status, nullptr);
   LLDB_LOGF(log, "<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, 
ch);
   m_history.AddPacket(ch, GDBRemotePacket::ePacketTypeSend, bytes_written);
   return bytes_written;
@@ -111,7 +111,7 @@
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
   ConnectionStatus status = eConnectionStatusSuccess;
   char ch = '-';
-  const size_t bytes_written = Write(&ch, 1, status, nullptr);
+  const size_t bytes_written = WriteAll(&ch, 1, status, nullptr);
   LLDB_LOGF(log, "<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, 
ch);
   m_history.AddPacket(ch, GDBRemotePacket::ePacketTypeSend, bytes_written);
   return bytes_written;
@@ -137,7 +137,7 @@
 ConnectionStatus status = eConnectionStatusSuccess;
 const char *packet_data = packet.data();
 const size_t packet_length = packet.size();
-size_t bytes_written = Write(packet_data, packet_length, status, nullptr);
+size_t bytes_written = WriteAll(packet_data, packet_length, status, 
nullptr);
 if (log) {
   size_t binary_start_offset = 0;
   if (strncmp(packet_data, "$vFile:pwrite:", strlen("$vFile:pwrite:")) ==
Index: lldb/source/Core/Communication.cpp
===
--- lldb/source/Core/Communication.cpp
+++ lldb/source/Core/Communication.cpp
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -189,6 +190,19 @@
   return 0;
 }
 
+size_t Communication::WriteAll(const void *src, size_t src_len,
+   ConnectionStatus &status, Status *error_ptr) {
+  size_t total_written = 0;
+  while (1) {
+size_t written = Write(static_cast(src) + total_written,
+   src_len - total_written, status, error_ptr);
+total_written += written;
+if (status != eConnectionStatusSuccess || total_written >= src_len)
+  break;
+  }
+  return total_written;
+}
+
 bool Communication::StartReadThread(Status *error_ptr) {
   if (error_ptr)
 error_ptr->Clear();
Index: lldb/include/lldb/Core/Communication.h
===
--- lldb/include/lldb/Core/Communication.h
+++ lldb/include/lldb/Core/Communication.h
@@ -209,6 +209,22 @@
   size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status,
Status *error_ptr);
 
+  /// Repeatedly attempt writing until either \a src_len bytes are written
+  /// or a permanent failure occurs.
+  ///
+  /// \param[in] src
+  /// A source buffer that must be at least \a src_len bytes
+  /// long.
+  ///
+  /// \param[in] src_len
+  /// The number of bytes to attempt to write, and also the
+  /// number of bytes are currently available in \a src.
+  ///
+  /// \return
+  /// The number of bytes actually Written.
+  size_t WriteAll(const void *src, size_t src_len,
+  lldb::ConnectionStatus &status, Status *error_ptr);
+
   /// Sets the connection that it to be used by this class.
   ///
   /// By making a communication class that uses different connections it


Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -101,7 +101,7 @@
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
   ConnectionStatus status = eConnectionStatusSuccess;
   char ch = '+';
-  const size_t bytes_written = Write(&ch, 1, status, nullptr);
+  const size_t bytes_written = WriteAll(&ch, 1, status, nullptr);
   LLDB_LOGF(log, "<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
   m_history.AddPacket(ch, GDBRemotePacket::ePacketTypeSend, bytes_written);
   return bytes_written;
@@ -111,7 +111,7 @@
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
   ConnectionStatus status = eConnectionStatusSuc

[Lldb-commits] [lldb] 9d63b90 - [lldb] [Host/ConnectionFileDescriptor] Do not use non-blocking mode

2021-10-25 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-25T16:24:00+02:00
New Revision: 9d63b90b59a6283531199e29038954db9ae23d74

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

LOG: [lldb] [Host/ConnectionFileDescriptor] Do not use non-blocking mode

Disable non-blocking mode that's enabled only for file:// and serial://
protocols.  All read operations should be going through the select(2)
in ConnectionFileDescriptor::BytesAvaliable, which effectively erases
(non-)blocking mode differences in reading.  We do want to perform
writes in the blocking mode.

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

Added: 


Modified: 
lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp

Removed: 




diff  --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp 
b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index e94f0ea79..8e8ff8a4e3a03 100644
--- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -722,13 +722,6 @@ ConnectionStatus 
ConnectionFileDescriptor::ConnectFile(llvm::StringRef s,
 llvm::sys::RetryAfterSignal(-1, ::tcsetattr, fd, TCSANOW, &options);
   }
 
-  int flags = ::fcntl(fd, F_GETFL, 0);
-  if (flags >= 0) {
-if ((flags & O_NONBLOCK) == 0) {
-  flags |= O_NONBLOCK;
-  ::fcntl(fd, F_SETFL, flags);
-}
-  }
   m_io_sp =
   std::make_shared(fd, File::eOpenOptionReadWrite, true);
   return eConnectionStatusSuccess;
@@ -761,14 +754,6 @@ 
ConnectionFileDescriptor::ConnectSerialPort(llvm::StringRef s,
 return eConnectionStatusError;
   }
 
-  int flags = ::fcntl(fd, F_GETFL, 0);
-  if (flags >= 0) {
-if ((flags & O_NONBLOCK) == 0) {
-  flags |= O_NONBLOCK;
-  ::fcntl(fd, F_SETFL, flags);
-}
-  }
-
   llvm::Expected> serial_sp = SerialPort::Create(
   fd, File::eOpenOptionReadWrite, serial_options.get(), true);
   if (!serial_sp) {



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


[Lldb-commits] [PATCH] D112442: [lldb] [Host/ConnectionFileDescriptor] Do not use non-blocking mode

2021-10-25 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9d63b90b59a6: [lldb] [Host/ConnectionFileDescriptor] Do not 
use non-blocking mode (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112442

Files:
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp


Index: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
===
--- lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -722,13 +722,6 @@
 llvm::sys::RetryAfterSignal(-1, ::tcsetattr, fd, TCSANOW, &options);
   }
 
-  int flags = ::fcntl(fd, F_GETFL, 0);
-  if (flags >= 0) {
-if ((flags & O_NONBLOCK) == 0) {
-  flags |= O_NONBLOCK;
-  ::fcntl(fd, F_SETFL, flags);
-}
-  }
   m_io_sp =
   std::make_shared(fd, File::eOpenOptionReadWrite, true);
   return eConnectionStatusSuccess;
@@ -761,14 +754,6 @@
 return eConnectionStatusError;
   }
 
-  int flags = ::fcntl(fd, F_GETFL, 0);
-  if (flags >= 0) {
-if ((flags & O_NONBLOCK) == 0) {
-  flags |= O_NONBLOCK;
-  ::fcntl(fd, F_SETFL, flags);
-}
-  }
-
   llvm::Expected> serial_sp = SerialPort::Create(
   fd, File::eOpenOptionReadWrite, serial_options.get(), true);
   if (!serial_sp) {


Index: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
===
--- lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -722,13 +722,6 @@
 llvm::sys::RetryAfterSignal(-1, ::tcsetattr, fd, TCSANOW, &options);
   }
 
-  int flags = ::fcntl(fd, F_GETFL, 0);
-  if (flags >= 0) {
-if ((flags & O_NONBLOCK) == 0) {
-  flags |= O_NONBLOCK;
-  ::fcntl(fd, F_SETFL, flags);
-}
-  }
   m_io_sp =
   std::make_shared(fd, File::eOpenOptionReadWrite, true);
   return eConnectionStatusSuccess;
@@ -761,14 +754,6 @@
 return eConnectionStatusError;
   }
 
-  int flags = ::fcntl(fd, F_GETFL, 0);
-  if (flags >= 0) {
-if ((flags & O_NONBLOCK) == 0) {
-  flags |= O_NONBLOCK;
-  ::fcntl(fd, F_SETFL, flags);
-}
-  }
-
   llvm::Expected> serial_sp = SerialPort::Create(
   fd, File::eOpenOptionReadWrite, serial_options.get(), true);
   if (!serial_sp) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D112457: Modernize and simplify HostInfo::GetOSKernelDescription

2021-10-25 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: mgorny, teemperor.
Herald added a subscriber: emaste.
labath requested review of this revision.
Herald added a project: LLDB.

Replace bool+by-ref argument with llvm::Optional, and move the common
implementation into HostInfoPOSIX. Based on my (simple) experiment,
the uname and the sysctl approach return the same value on MacOS, so
there's no need for a mac-specific implementation of this functionality.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112457

Files:
  lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
  lldb/include/lldb/Host/linux/HostInfoLinux.h
  lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
  lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
  lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
  lldb/include/lldb/Host/posix/HostInfoPosix.h
  lldb/include/lldb/Host/windows/HostInfoWindows.h
  lldb/source/Host/freebsd/HostInfoFreeBSD.cpp
  lldb/source/Host/linux/HostInfoLinux.cpp
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
  lldb/source/Host/netbsd/HostInfoNetBSD.cpp
  lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
  lldb/source/Host/windows/HostInfoWindows.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Target/Platform.cpp

Index: lldb/source/Target/Platform.cpp
===
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -493,8 +493,11 @@
 }
 
 bool Platform::GetOSKernelDescription(std::string &s) {
-  if (IsHost())
-return HostInfo::GetOSKernelDescription(s);
+  if (IsHost()) {
+llvm::Optional desc = HostInfo::GetOSKernelDescription();
+s = desc.getValueOr("");
+return desc.hasValue();
+  }
   return GetRemoteOSKernelDescription(s);
 }
 
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -272,13 +272,13 @@
 response.PutStringAsRawHex8(*s);
 response.PutChar(';');
   }
-  std::string s;
-  if (HostInfo::GetOSKernelDescription(s)) {
+  if (llvm::Optional s = HostInfo::GetOSKernelDescription()) {
 response.PutCString("os_kernel:");
-response.PutStringAsRawHex8(s);
+response.PutStringAsRawHex8(*s);
 response.PutChar(';');
   }
 
+  std::string s;
 #if defined(__APPLE__)
 
 #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
Index: lldb/source/Host/windows/HostInfoWindows.cpp
===
--- lldb/source/Host/windows/HostInfoWindows.cpp
+++ lldb/source/Host/windows/HostInfoWindows.cpp
@@ -82,10 +82,8 @@
   return "Windows NT " + version.getAsString();
 }
 
-bool HostInfoWindows::GetOSKernelDescription(std::string &s) {
-  llvm::Optional build = GetOSBuildString();
-  s = build.getValueOr("");
-  return build.hasValue();
+llvm::Optional HostInfoWindows::GetOSKernelDescription() {
+  return GetOSBuildString();
 }
 
 bool HostInfoWindows::GetHostname(std::string &s) {
Index: lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
===
--- lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
+++ lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
@@ -41,20 +41,6 @@
   return llvm::None;
 }
 
-bool HostInfoOpenBSD::GetOSKernelDescription(std::string &s) {
-  struct utsname un;
-
-  ::memset(&un, 0, sizeof(utsname));
-  s.clear();
-
-  if (uname(&un) < 0)
-return false;
-
-  s.assign(un.version);
-
-  return true;
-}
-
 FileSpec HostInfoOpenBSD::GetProgramFileSpec() {
   static FileSpec g_program_filespec;
   return g_program_filespec;
Index: lldb/source/Host/netbsd/HostInfoNetBSD.cpp
===
--- lldb/source/Host/netbsd/HostInfoNetBSD.cpp
+++ lldb/source/Host/netbsd/HostInfoNetBSD.cpp
@@ -54,20 +54,6 @@
   return llvm::None;
 }
 
-bool HostInfoNetBSD::GetOSKernelDescription(std::string &s) {
-  struct utsname un;
-
-  ::memset(&un, 0, sizeof(un));
-  s.clear();
-
-  if (::uname(&un) < 0)
-return false;
-
-  s.assign(un.version);
-
-  return true;
-}
-
 FileSpec HostInfoNetBSD::GetProgramFileSpec() {
   static FileSpec g_program_filespec;
 
Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -65,18 +65,6 @@
   return llvm::None;
 }
 
-bool HostInfoMacOSX::GetOSKernelDescription(std::string &s) {
-  int mib[2] = {CTL_KERN, KERN_VERSION};
-  char cstr[PATH_MAX];
-  size_t cstr_len = sizeof(cstr);
-  if (::sysctl(mib, 2, cstr, &cstr_len, NULL, 0) == 0) {
-s.assign(cstr, cstr_len);
-return true;
-  }
-  s.clear();
-  return false;
-}
-
 stat

[Lldb-commits] [lldb] a53978c - [lldb] Remove a trailing \0 from the result of HostInfoMacOSX::GetOSBuildString

2021-10-25 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-25T17:33:06+02:00
New Revision: a53978c95c46a8bef563058fa35a688f8cbaaf88

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

LOG: [lldb] Remove a trailing \0 from the result of 
HostInfoMacOSX::GetOSBuildString

This has been in there since forever, but only started to matter once
40e4ac3e changed how we print the string.

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index e32cfb0aade0..5f141b08e866 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -60,7 +60,7 @@
   char cstr[PATH_MAX];
   size_t cstr_len = sizeof(cstr);
   if (::sysctl(mib, 2, cstr, &cstr_len, NULL, 0) == 0)
-return std::string(cstr, cstr_len);
+return std::string(cstr, cstr_len - 1);
 
   return llvm::None;
 }



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


[Lldb-commits] [PATCH] D112457: Modernize and simplify HostInfo::GetOSKernelDescription

2021-10-25 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/D112457/new/

https://reviews.llvm.org/D112457

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


[Lldb-commits] [PATCH] D112279: Add modules stats into the "statistics dump" command.

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

Can we use the UUID as the module identifier (at least in the JSON)? Other than 
that, this LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112279

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


[Lldb-commits] [lldb] 974c2f5 - [lldb] Modernize and expand TestCppBitfields

2021-10-25 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-10-25T18:19:26+02:00
New Revision: 974c2f5e22112659549a54ff95ee310a1aac469d

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

LOG: [lldb] Modernize and expand TestCppBitfields

* clang-format test source.
* Removed the dead setup code.
* Using expect_expr etc. instead of raw expect.
* Slightly expanded with tests for vtable pointers (which mostly just crash 
atm.)
* Removed some other minor test guideline problems.

Added: 


Modified: 
lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
lldb/test/API/lang/cpp/bitfields/main.cpp

Removed: 




diff  --git a/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py 
b/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
index c67446f47803..4cdaf32ca065 100644
--- a/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
+++ b/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
@@ -10,143 +10,165 @@ class CppBitfieldsTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
-def setUp(self):
-# Call super's setUp().
-TestBase.setUp(self)
-# Find the line number to break inside main().
-self.line = line_number('main.cpp', '// Set break point at this line.')
-
-def test_and_run_command(self):
-"""Test 'frame variable ...' on a variable with bitfields."""
+@no_debug_info_test
+def test_bitfields(self):
 self.build()
-
-lldbutil.run_to_source_breakpoint(self, '// Set break point at this 
line.',
-  lldb.SBFileSpec("main.cpp", False))
-
-# The stop reason of the thread should be breakpoint.
-self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
-substrs=['stopped',
- 'stop reason = breakpoint'])
-
-# The breakpoint should have a hit count of 1.
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
-
-self.expect("expr (lba.a)", VARIABLES_DISPLAYED_CORRECTLY,
-substrs=['unsigned int', '2'])
-self.expect("expr (lbb.b)", VARIABLES_DISPLAYED_CORRECTLY,
-substrs=['unsigned int', '3'])
-self.expect("expr (lbc.c)", VARIABLES_DISPLAYED_CORRECTLY,
-substrs=['unsigned int', '4'])
-self.expect("expr (lbd.a)", VARIABLES_DISPLAYED_CORRECTLY,
-substrs=['unsigned int', '5'])
-self.expect("expr (clang_example.f.a)", VARIABLES_DISPLAYED_CORRECTLY,
-substrs=['uint64_t', '1'])
-
-self.expect("expr uwbf",
-substrs=['a = 255',
-'b = 65535',
-'c = 4294967295',
-'x = 4294967295'] )
-
-self.expect("expr uwubf",
-substrs=['a = 16777215',
-'x = 4294967295'] )
-
-self.expect(
-"frame variable --show-types lba",
-VARIABLES_DISPLAYED_CORRECTLY,
-substrs=[
-'(int:32)  = ',
-'(unsigned int:20) a = 2',
-])
-
-self.expect(
-"frame variable --show-types lbb",
-VARIABLES_DISPLAYED_CORRECTLY,
-substrs=[
-'(unsigned int:1) a = 1',
-'(int:31)  =',
-'(unsigned int:20) b = 3',
-])
-
-self.expect(
-"frame variable --show-types lbc",
-VARIABLES_DISPLAYED_CORRECTLY,
-substrs=[
-'(int:22)  =',
-'(unsigned int:1) a = 1',
-'(unsigned int:1) b = 0',
-'(unsigned int:5) c = 4',
-'(unsigned int:1) d = 1',
-'(int:2)  =',
-'(unsigned int:20) e = 20',
-])
-
-self.expect(
-"frame variable --show-types lbd",
-VARIABLES_DISPLAYED_CORRECTLY,
-substrs=[
-'(char[3]) arr = "ab"',
-'(int:32)  =',
-'(unsigned int:20) a = 5',
-])
-
-self.expect(
-"frame variable --show-types clang_example",
-VARIABLES_DISPLAYED_CORRECTLY,
-substrs=[
-   '(int:22)  =',
-   '(uint64_t:1) a = 1',
-   '(uint64_t:1) b = 0',
-   '(uint64_t:1) c = 1',
-   '(uint64_t:1) d = 0',
-   '(uint64_t:1) e = 1',
-   '(uint64_t:1) f = 0',
-   '(uint64_t:1) g = 1',
-   '(uint64_t:1) h = 0',
-   '(uint64_t:1) i = 1',
-   '(uint64_t:1) j = 0',
-   '(uint64_t:1) k = 1',
-])
-
-self.expect(
-  

[Lldb-commits] [PATCH] D112457: Modernize and simplify HostInfo::GetOSKernelDescription

2021-10-25 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: lldb/include/lldb/Host/posix/HostInfoPosix.h:25
   static bool GetHostname(std::string &s);
+  static llvm::Optional GetOSKernelDescription();
 

Ok, I must be missing something but I don't see the implementation of this in 
this patch.



Comment at: lldb/source/Target/Platform.cpp:495
 
 bool Platform::GetOSKernelDescription(std::string &s) {
+  if (IsHost()) {

I'd also change this prototype while at it ;-).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112457

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


[Lldb-commits] [PATCH] D112340: [lldb/Formatters] Remove space from vector type string summaries (NFCI)

2021-10-25 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a comment.

In D112340#3081540 , @teemperor wrote:

> In D112340#3081532 , @dblaikie 
> wrote:
>
>> Sorry I missed this - are these tested anywhere/should I have been able to 
>> discover if these needed to be changed before I made the change?
>
> TestCompactVectors tests this but its unfortunately marked as Darwin-only (as 
> it includes the `Accelerate` framework). Providing a platform-neutral test 
> that just typedef's the same things as Accelerate (in addition to the test 
> including the real framework) seems like a good idea.

Good to know - will keep it in mind, but don't think I'm up for writing that 
test right now myself (not especially familiar with lldb test infrastructure, 
etc).

Was this reported by a buildbot, do you think/know of? Probably would've been 
happy to debug-via-buildbot and fix it that way, but don't recall seeing a 
fail-mail about this (but as always, there's a fair bit of buildbot noise and 
sometimes it's hard to find the cause/issue in a fail-mail such that I end up 
ignoring them)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112340

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


[Lldb-commits] [PATCH] D111899: LLDB tests modification for hardware breakpoints

2021-10-25 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha accepted this revision.
tatyana-krasnukha added a comment.
This revision is now accepted and ready to land.

LGTM, but I would wait for one more approve.


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

https://reviews.llvm.org/D111899

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


[Lldb-commits] [PATCH] D112439: normalize file path when searching the source map

2021-10-25 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

Is it possible to add a test for that? In any case, this makes sense to me


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112439

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


Re: [Lldb-commits] [PATCH] D112340: [lldb/Formatters] Remove space from vector type string summaries (NFCI)

2021-10-25 Thread Raphael Isemann via lldb-commits
Not actually sure when/how Green Dragon is mailing external people,
but usually someone just watches the build bot and emails/comments on
commits that are breaking the buildbot. Green Dragon is more of a
monte carlo simulation than a real build bot so I wouldn't be
surprised if it doesn't send automatic failure emails to non-Apple
people.

Also that 'let's write a test' was more a note for myself to write
that test (which I hopefully get around today).

Am Mo., 25. Okt. 2021 um 19:10 Uhr schrieb David Blaikie via
Phabricator :
>
> dblaikie added a comment.
>
> In D112340#3081540 , @teemperor 
> wrote:
>
> > In D112340#3081532 , @dblaikie 
> > wrote:
> >
> >> Sorry I missed this - are these tested anywhere/should I have been able to 
> >> discover if these needed to be changed before I made the change?
> >
> > TestCompactVectors tests this but its unfortunately marked as Darwin-only 
> > (as it includes the `Accelerate` framework). Providing a platform-neutral 
> > test that just typedef's the same things as Accelerate (in addition to the 
> > test including the real framework) seems like a good idea.
>
> Good to know - will keep it in mind, but don't think I'm up for writing that 
> test right now myself (not especially familiar with lldb test infrastructure, 
> etc).
>
> Was this reported by a buildbot, do you think/know of? Probably would've been 
> happy to debug-via-buildbot and fix it that way, but don't recall seeing a 
> fail-mail about this (but as always, there's a fair bit of buildbot noise and 
> sometimes it's hard to find the cause/issue in a fail-mail such that I end up 
> ignoring them)
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D112340/new/
>
> https://reviews.llvm.org/D112340
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D112340: [lldb/Formatters] Remove space from vector type string summaries (NFCI)

2021-10-25 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a comment.

In D112340#3084953 , @teemperor wrote:

> Not actually sure when/how Green Dragon is mailing external people,
> but usually someone just watches the build bot and emails/comments on
> commits that are breaking the buildbot. Green Dragon is more of a
> monte carlo simulation than a real build bot so I wouldn't be
> surprised if it doesn't send automatic failure emails to non-Apple
> people.
>
> Also that 'let's write a test' was more a note for myself to write
> that test (which I hopefully get around today).

Cool - thanks for all the details!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112340

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


[Lldb-commits] [PATCH] D111491: [lldb] [gdb-remote] Remove HardcodeARMRegisters() hack

2021-10-25 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.
This revision is now accepted and ready to land.

Sorry for the delay in looking at this one.  Yes, we usually put a new 
debugserver on devices every year, and we don't need to support devices this 
old any more, this is fine to remove.  Thanks!


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

https://reviews.llvm.org/D111491

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


[Lldb-commits] [PATCH] D112457: Modernize and simplify HostInfo::GetOSKernelDescription

2021-10-25 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 382048.
labath added a comment.

add missing implementation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112457

Files:
  lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
  lldb/include/lldb/Host/linux/HostInfoLinux.h
  lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
  lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
  lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
  lldb/include/lldb/Host/posix/HostInfoPosix.h
  lldb/include/lldb/Host/windows/HostInfoWindows.h
  lldb/source/Host/freebsd/HostInfoFreeBSD.cpp
  lldb/source/Host/linux/HostInfoLinux.cpp
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
  lldb/source/Host/netbsd/HostInfoNetBSD.cpp
  lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
  lldb/source/Host/posix/HostInfoPosix.cpp
  lldb/source/Host/windows/HostInfoWindows.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Target/Platform.cpp

Index: lldb/source/Target/Platform.cpp
===
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -493,8 +493,11 @@
 }
 
 bool Platform::GetOSKernelDescription(std::string &s) {
-  if (IsHost())
-return HostInfo::GetOSKernelDescription(s);
+  if (IsHost()) {
+llvm::Optional desc = HostInfo::GetOSKernelDescription();
+s = desc.getValueOr("");
+return desc.hasValue();
+  }
   return GetRemoteOSKernelDescription(s);
 }
 
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -272,13 +272,13 @@
 response.PutStringAsRawHex8(*s);
 response.PutChar(';');
   }
-  std::string s;
-  if (HostInfo::GetOSKernelDescription(s)) {
+  if (llvm::Optional s = HostInfo::GetOSKernelDescription()) {
 response.PutCString("os_kernel:");
-response.PutStringAsRawHex8(s);
+response.PutStringAsRawHex8(*s);
 response.PutChar(';');
   }
 
+  std::string s;
 #if defined(__APPLE__)
 
 #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
Index: lldb/source/Host/windows/HostInfoWindows.cpp
===
--- lldb/source/Host/windows/HostInfoWindows.cpp
+++ lldb/source/Host/windows/HostInfoWindows.cpp
@@ -82,10 +82,8 @@
   return "Windows NT " + version.getAsString();
 }
 
-bool HostInfoWindows::GetOSKernelDescription(std::string &s) {
-  llvm::Optional build = GetOSBuildString();
-  s = build.getValueOr("");
-  return build.hasValue();
+llvm::Optional HostInfoWindows::GetOSKernelDescription() {
+  return GetOSBuildString();
 }
 
 bool HostInfoWindows::GetHostname(std::string &s) {
Index: lldb/source/Host/posix/HostInfoPosix.cpp
===
--- lldb/source/Host/posix/HostInfoPosix.cpp
+++ lldb/source/Host/posix/HostInfoPosix.cpp
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 using namespace lldb_private;
@@ -37,6 +38,17 @@
   return false;
 }
 
+llvm::Optional HostInfoPosix::GetOSKernelDescription() {
+  struct utsname un;
+
+  ::memset(&un, 0, sizeof(utsname));
+
+  if (uname(&un) < 0)
+return llvm::None;
+
+  return std::string(un.version);
+}
+
 #ifdef __ANDROID__
 #include 
 #endif
Index: lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
===
--- lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
+++ lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
@@ -41,20 +41,6 @@
   return llvm::None;
 }
 
-bool HostInfoOpenBSD::GetOSKernelDescription(std::string &s) {
-  struct utsname un;
-
-  ::memset(&un, 0, sizeof(utsname));
-  s.clear();
-
-  if (uname(&un) < 0)
-return false;
-
-  s.assign(un.version);
-
-  return true;
-}
-
 FileSpec HostInfoOpenBSD::GetProgramFileSpec() {
   static FileSpec g_program_filespec;
   return g_program_filespec;
Index: lldb/source/Host/netbsd/HostInfoNetBSD.cpp
===
--- lldb/source/Host/netbsd/HostInfoNetBSD.cpp
+++ lldb/source/Host/netbsd/HostInfoNetBSD.cpp
@@ -54,20 +54,6 @@
   return llvm::None;
 }
 
-bool HostInfoNetBSD::GetOSKernelDescription(std::string &s) {
-  struct utsname un;
-
-  ::memset(&un, 0, sizeof(un));
-  s.clear();
-
-  if (::uname(&un) < 0)
-return false;
-
-  s.assign(un.version);
-
-  return true;
-}
-
 FileSpec HostInfoNetBSD::GetProgramFileSpec() {
   static FileSpec g_program_filespec;
 
Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -65,18 +65,

[Lldb-commits] [PATCH] D112471: [LLDB] Fix Cpsr size for WoA64 target

2021-10-25 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid created this revision.
omjavaid added reviewers: mstorsjo, DavidSpickett.
Herald added a subscriber: kristof.beyls.
omjavaid requested review of this revision.

CPSR on Arm64 is 4 bytes in size but windows on Arm implementation is trying to 
read/write 8 bytes against a byte register causing LLDB unit tests failures.

Ref: 
https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-arm64_nt_context


https://reviews.llvm.org/D112471

Files:
  
lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
  
lldb/source/Plugins/Process/Windows/Common/arm64/RegisterContextWindows_arm64.cpp


Index: 
lldb/source/Plugins/Process/Windows/Common/arm64/RegisterContextWindows_arm64.cpp
===
--- 
lldb/source/Plugins/Process/Windows/Common/arm64/RegisterContextWindows_arm64.cpp
+++ 
lldb/source/Plugins/Process/Windows/Common/arm64/RegisterContextWindows_arm64.cpp
@@ -171,7 +171,7 @@
 reg_value.SetUInt64(m_context.Pc);
 break;
   case gpr_cpsr:
-reg_value.SetUInt64(m_context.Cpsr);
+reg_value.SetUInt32(m_context.Cpsr);
 break;
 
   case gpr_w0:
@@ -385,7 +385,7 @@
 m_context.Pc = reg_value.GetAsUInt64();
 break;
   case gpr_cpsr:
-m_context.Cpsr = reg_value.GetAsUInt64();
+m_context.Cpsr = reg_value.GetAsUInt32();
 break;
 
   case fpu_v0:
Index: 
lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
===
--- 
lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
+++ 
lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
@@ -220,7 +220,7 @@
 reg_value.SetUInt64(tls_context.Pc);
 break;
   case gpr_cpsr_arm64:
-reg_value.SetUInt64(tls_context.Cpsr);
+reg_value.SetUInt32(tls_context.Cpsr);
 break;
 
   case gpr_w0_arm64:
@@ -317,7 +317,7 @@
 tls_context.Pc = reg_value.GetAsUInt64();
 break;
   case gpr_cpsr_arm64:
-tls_context.Cpsr = reg_value.GetAsUInt64();
+tls_context.Cpsr = reg_value.GetAsUInt32();
 break;
 
   case gpr_w0_arm64:


Index: lldb/source/Plugins/Process/Windows/Common/arm64/RegisterContextWindows_arm64.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/arm64/RegisterContextWindows_arm64.cpp
+++ lldb/source/Plugins/Process/Windows/Common/arm64/RegisterContextWindows_arm64.cpp
@@ -171,7 +171,7 @@
 reg_value.SetUInt64(m_context.Pc);
 break;
   case gpr_cpsr:
-reg_value.SetUInt64(m_context.Cpsr);
+reg_value.SetUInt32(m_context.Cpsr);
 break;
 
   case gpr_w0:
@@ -385,7 +385,7 @@
 m_context.Pc = reg_value.GetAsUInt64();
 break;
   case gpr_cpsr:
-m_context.Cpsr = reg_value.GetAsUInt64();
+m_context.Cpsr = reg_value.GetAsUInt32();
 break;
 
   case fpu_v0:
Index: lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
+++ lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
@@ -220,7 +220,7 @@
 reg_value.SetUInt64(tls_context.Pc);
 break;
   case gpr_cpsr_arm64:
-reg_value.SetUInt64(tls_context.Cpsr);
+reg_value.SetUInt32(tls_context.Cpsr);
 break;
 
   case gpr_w0_arm64:
@@ -317,7 +317,7 @@
 tls_context.Pc = reg_value.GetAsUInt64();
 break;
   case gpr_cpsr_arm64:
-tls_context.Cpsr = reg_value.GetAsUInt64();
+tls_context.Cpsr = reg_value.GetAsUInt32();
 break;
 
   case gpr_w0_arm64:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D112457: Modernize and simplify HostInfo::GetOSKernelDescription

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



Comment at: lldb/include/lldb/Host/posix/HostInfoPosix.h:25
   static bool GetHostname(std::string &s);
+  static llvm::Optional GetOSKernelDescription();
 

mgorny wrote:
> Ok, I must be missing something but I don't see the implementation of this in 
> this patch.
I forgot to amend the implementation into the patch. Thanks for catching that.



Comment at: lldb/source/Target/Platform.cpp:495
 
 bool Platform::GetOSKernelDescription(std::string &s) {
+  if (IsHost()) {

mgorny wrote:
> I'd also change this prototype while at it ;-).
A lot of this code is only built/tested on some platforms, so I wanted to do 
that as a followup -- to reduce the number of moving parts. I also did 
GetOSBuildString in two parts, and both parts managed to break something.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112457

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


[Lldb-commits] [PATCH] D112167: [lldb/Plugins] Refactor ScriptedThread register context creation

2021-10-25 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere requested changes to this revision.
JDevlieghere added inline comments.
This revision now requires changes to proceed.



Comment at: lldb/source/Plugins/Process/scripted/ScriptedThread.cpp:105
+  lldb::RegisterContextSP reg_ctx_sp;
+  Status error;
+

It looks like this error is set but never used/returned? Should this return an 
`Expected` with the caller dealing with the error? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112167

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


[Lldb-commits] [PATCH] D111491: [lldb] [gdb-remote] Remove HardcodeARMRegisters() hack

2021-10-25 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

Thanks!


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

https://reviews.llvm.org/D111491

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


[Lldb-commits] [PATCH] D112457: Modernize and simplify HostInfo::GetOSKernelDescription

2021-10-25 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: lldb/source/Host/posix/HostInfoPosix.cpp:44
+
+  ::memset(&un, 0, sizeof(utsname));
+

I'm somewhat surprised that you need to do that. I wonder if there was a real 
reason why it's done or just someone being overly careful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112457

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


[Lldb-commits] [lldb] 26c584f - [lldb] [gdb-remote] Remove HardcodeARMRegisters() hack

2021-10-25 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-25T20:05:29+02:00
New Revision: 26c584f4f1a3359bcb31b357ec020e7b8038c10c

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

LOG: [lldb] [gdb-remote] Remove HardcodeARMRegisters() hack

HardcodeARMRegisters() is a hack that was supposed to be used "until
we can get an updated debugserver down on the devices".  Since it was
introduced back in 2012, there is a good chance that the debugserver
has been updated at least once since then.  Removing this code makes
transition to the new DynamicRegisterInfo API easier.

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

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index 80294aefc4108..9410c9bd83ec4 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -815,266 +815,3 @@ bool 
GDBRemoteDynamicRegisterInfo::UpdateARM64SVERegistersInfos(uint64_t vg) {
   ConfigureOffsets();
   return true;
 }
-
-void GDBRemoteDynamicRegisterInfo::HardcodeARMRegisters(bool from_scratch) {
-  // For Advanced SIMD and VFP register mapping.
-  static uint32_t g_d0_regs[] = {26, 27, LLDB_INVALID_REGNUM};  // (s0, s1)
-  static uint32_t g_d1_regs[] = {28, 29, LLDB_INVALID_REGNUM};  // (s2, s3)
-  static uint32_t g_d2_regs[] = {30, 31, LLDB_INVALID_REGNUM};  // (s4, s5)
-  static uint32_t g_d3_regs[] = {32, 33, LLDB_INVALID_REGNUM};  // (s6, s7)
-  static uint32_t g_d4_regs[] = {34, 35, LLDB_INVALID_REGNUM};  // (s8, s9)
-  static uint32_t g_d5_regs[] = {36, 37, LLDB_INVALID_REGNUM};  // (s10, s11)
-  static uint32_t g_d6_regs[] = {38, 39, LLDB_INVALID_REGNUM};  // (s12, s13)
-  static uint32_t g_d7_regs[] = {40, 41, LLDB_INVALID_REGNUM};  // (s14, s15)
-  static uint32_t g_d8_regs[] = {42, 43, LLDB_INVALID_REGNUM};  // (s16, s17)
-  static uint32_t g_d9_regs[] = {44, 45, LLDB_INVALID_REGNUM};  // (s18, s19)
-  static uint32_t g_d10_regs[] = {46, 47, LLDB_INVALID_REGNUM}; // (s20, s21)
-  static uint32_t g_d11_regs[] = {48, 49, LLDB_INVALID_REGNUM}; // (s22, s23)
-  static uint32_t g_d12_regs[] = {50, 51, LLDB_INVALID_REGNUM}; // (s24, s25)
-  static uint32_t g_d13_regs[] = {52, 53, LLDB_INVALID_REGNUM}; // (s26, s27)
-  static uint32_t g_d14_regs[] = {54, 55, LLDB_INVALID_REGNUM}; // (s28, s29)
-  static uint32_t g_d15_regs[] = {56, 57, LLDB_INVALID_REGNUM}; // (s30, s31)
-  static uint32_t g_q0_regs[] = {
-  26, 27, 28, 29, LLDB_INVALID_REGNUM}; // (d0, d1) -> (s0, s1, s2, s3)
-  static uint32_t g_q1_regs[] = {
-  30, 31, 32, 33, LLDB_INVALID_REGNUM}; // (d2, d3) -> (s4, s5, s6, s7)
-  static uint32_t g_q2_regs[] = {
-  34, 35, 36, 37, LLDB_INVALID_REGNUM}; // (d4, d5) -> (s8, s9, s10, s11)
-  static uint32_t g_q3_regs[] = {
-  38, 39, 40, 41, LLDB_INVALID_REGNUM}; // (d6, d7) -> (s12, s13, s14, s15)
-  static uint32_t g_q4_regs[] = {
-  42, 43, 44, 45, LLDB_INVALID_REGNUM}; // (d8, d9) -> (s16, s17, s18, s19)
-  static uint32_t g_q5_regs[] = {
-  46, 47, 48, 49,
-  LLDB_INVALID_REGNUM}; // (d10, d11) -> (s20, s21, s22, s23)
-  static uint32_t g_q6_regs[] = {
-  50, 51, 52, 53,
-  LLDB_INVALID_REGNUM}; // (d12, d13) -> (s24, s25, s26, s27)
-  static uint32_t g_q7_regs[] = {
-  54, 55, 56, 57,
-  LLDB_INVALID_REGNUM}; // (d14, d15) -> (s28, s29, s30, s31)
-  static uint32_t g_q8_regs[] = {59, 60, LLDB_INVALID_REGNUM};  // (d16, d17)
-  static uint32_t g_q9_regs[] = {61, 62, LLDB_INVALID_REGNUM};  // (d18, d19)
-  static uint32_t g_q10_regs[] = {63, 64, LLDB_INVALID_REGNUM}; // (d20, d21)
-  static uint32_t g_q11_regs[] = {65, 66, LLDB_INVALID_REGNUM}; // (d22, d23)
-  static uint32_t g_q12_regs[] = {67, 68, LLDB_INVALID_REGNUM}; // (d24, d25)
-  static uint32_t g_q13_regs[] = {69, 70, LLDB_INVALID_REGNUM}; // (d26, d27)
-  static uint32_t g_q14_regs[] = {71, 72, LLDB_INVALID_REGNUM}; // (d28, d29)
-  static uint32_t g_q15_regs[] = {73, 74, LLDB_INVALID_REGNUM}; // (d30, d31)
-
-  // This is our array of composite registers, with each element coming from
-  // the above register mappings.
-  static uint32_t *g_composites[] = {
-  g_d0_regs,  g_d1_regs,  g_d2_regs,  g_d3_regs,  g_d4_regs,  g_d5_regs,
-  g_d6_regs,  g_d7_regs,  g_d8_regs,  g_d9_regs,  g_d10_regs, g_d11_regs,
-  g_d12_regs, g_d13_regs, g_d14_regs, g_d15_regs, g_q0_regs,  g_q1_regs,
-  g_q2_regs,  g_q3_regs,  g_q4_regs,  g_q5_regs,  g_q6_regs,  g_q7_regs,
-   

[Lldb-commits] [lldb] 1bd258f - [lldb] [DynamicRegisterInfo] Remove AddRegister() and make Finalize() protected

2021-10-25 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-25T20:05:30+02:00
New Revision: 1bd258fd4e2c94d35cdda07b4ca64a2de8d4a047

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

LOG: [lldb] [DynamicRegisterInfo] Remove AddRegister() and make Finalize() 
protected

Now that AddRegister() is no longer used, remove it.  While at it,
we can also make Finalize() protected as all supported API methods
call it internally.

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

Added: 


Modified: 
lldb/include/lldb/Target/DynamicRegisterInfo.h
lldb/source/Target/DynamicRegisterInfo.cpp
lldb/unittests/Target/DynamicRegisterInfoTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/DynamicRegisterInfo.h 
b/lldb/include/lldb/Target/DynamicRegisterInfo.h
index e5395f0171afc..20f442529da8e 100644
--- a/lldb/include/lldb/Target/DynamicRegisterInfo.h
+++ b/lldb/include/lldb/Target/DynamicRegisterInfo.h
@@ -57,11 +57,6 @@ class DynamicRegisterInfo {
   size_t SetRegisterInfo(std::vector &®s,
  const lldb_private::ArchSpec &arch);
 
-  void AddRegister(lldb_private::RegisterInfo reg_info,
-   lldb_private::ConstString &set_name);
-
-  void Finalize(const lldb_private::ArchSpec &arch);
-
   size_t GetNumRegisters() const;
 
   size_t GetNumRegisterSets() const;
@@ -116,6 +111,8 @@ class DynamicRegisterInfo {
 
   void MoveFrom(DynamicRegisterInfo &&info);
 
+  void Finalize(const lldb_private::ArchSpec &arch);
+
   void ConfigureOffsets();
 
   reg_collection m_regs;

diff  --git a/lldb/source/Target/DynamicRegisterInfo.cpp 
b/lldb/source/Target/DynamicRegisterInfo.cpp
index b278e36768215..9f894f86aea85 100644
--- a/lldb/source/Target/DynamicRegisterInfo.cpp
+++ b/lldb/source/Target/DynamicRegisterInfo.cpp
@@ -422,35 +422,6 @@ size_t DynamicRegisterInfo::SetRegisterInfo(
   return m_regs.size();
 }
 
-void DynamicRegisterInfo::AddRegister(RegisterInfo reg_info,
-  ConstString &set_name) {
-  assert(!m_finalized);
-  const uint32_t reg_num = m_regs.size();
-  assert(reg_info.name);
-  uint32_t i;
-  if (reg_info.value_regs) {
-for (i = 0; reg_info.value_regs[i] != LLDB_INVALID_REGNUM; ++i)
-  m_value_regs_map[reg_num].push_back(reg_info.value_regs[i]);
-
-// invalidate until Finalize() is called
-reg_info.value_regs = nullptr;
-  }
-  if (reg_info.invalidate_regs) {
-for (i = 0; reg_info.invalidate_regs[i] != LLDB_INVALID_REGNUM; ++i)
-  m_invalidate_regs_map[reg_num].push_back(reg_info.invalidate_regs[i]);
-
-// invalidate until Finalize() is called
-reg_info.invalidate_regs = nullptr;
-  }
-
-  m_regs.push_back(reg_info);
-  uint32_t set = GetRegisterSetIndexByName(set_name, true);
-  assert(set < m_sets.size());
-  assert(set < m_set_reg_nums.size());
-  assert(set < m_set_names.size());
-  m_set_reg_nums[set].push_back(reg_num);
-}
-
 void DynamicRegisterInfo::Finalize(const ArchSpec &arch) {
   if (m_finalized)
 return;

diff  --git a/lldb/unittests/Target/DynamicRegisterInfoTest.cpp 
b/lldb/unittests/Target/DynamicRegisterInfoTest.cpp
index f027602d5a969..ac76358d959f1 100644
--- a/lldb/unittests/Target/DynamicRegisterInfoTest.cpp
+++ b/lldb/unittests/Target/DynamicRegisterInfoTest.cpp
@@ -25,108 +25,6 @@ static std::vector regs_to_vector(uint32_t *regs) 
{
   return ret;
 }
 
-class DynamicRegisterInfoTest : public ::testing::Test {
-protected:
-  DynamicRegisterInfo info;
-  uint32_t next_regnum = 0;
-  ConstString group{"group"};
-
-  uint32_t AddTestRegister(const char *name, uint32_t byte_size,
-   std::vector value_regs = {},
-   std::vector invalidate_regs = {}) {
-struct RegisterInfo new_reg {
-  name, nullptr, byte_size, LLDB_INVALID_INDEX32, lldb::eEncodingUint,
-  lldb::eFormatUnsigned,
-  {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
-   next_regnum, next_regnum},
-  nullptr, nullptr
-};
-
-if (!value_regs.empty()) {
-  value_regs.push_back(LLDB_INVALID_REGNUM);
-  new_reg.value_regs = value_regs.data();
-}
-if (!invalidate_regs.empty()) {
-  invalidate_regs.push_back(LLDB_INVALID_REGNUM);
-  new_reg.invalidate_regs = invalidate_regs.data();
-}
-
-info.AddRegister(new_reg, group);
-return next_regnum++;
-  }
-
-  void AssertRegisterInfo(uint32_t reg_num, const char *reg_name,
-  uint32_t byte_offset,
-  std::vector value_regs = {},
-  std::vector invalidate_regs = {}) {
-const RegisterInfo *reg = info.GetRegisterInfoAtIndex(reg_num);
-EXPECT_NE(reg, nullptr);
-if (!reg)
-  return;
-
-EXPECT_STREQ(reg->name, reg_name);
-EXPECT_EQ

[Lldb-commits] [PATCH] D111491: [lldb] [gdb-remote] Remove HardcodeARMRegisters() hack

2021-10-25 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG26c584f4f1a3: [lldb] [gdb-remote] Remove 
HardcodeARMRegisters() hack (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111491

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -515,31 +515,7 @@
 }
   }
 
-  if (!registers.empty()) {
-AddRemoteRegisters(registers, arch_to_use);
-return;
-  }
-
-  // We didn't get anything if the accumulated reg_num is zero.  See if we are
-  // debugging ARM and fill with a hard coded register set until we can get an
-  // updated debugserver down on the devices. On the other hand, if the
-  // accumulated reg_num is positive, see if we can add composite registers to
-  // the existing primordial ones.
-  bool from_scratch = (m_register_info_sp->GetNumRegisters() == 0);
-
-  if (!target_arch.IsValid()) {
-if (arch_to_use.IsValid() &&
-(arch_to_use.GetMachine() == llvm::Triple::arm ||
- arch_to_use.GetMachine() == llvm::Triple::thumb) &&
-arch_to_use.GetTriple().getVendor() == llvm::Triple::Apple)
-  m_register_info_sp->HardcodeARMRegisters(from_scratch);
-  } else if (target_arch.GetMachine() == llvm::Triple::arm ||
- target_arch.GetMachine() == llvm::Triple::thumb) {
-m_register_info_sp->HardcodeARMRegisters(from_scratch);
-  }
-
-  // At this point, we can finalize our register info.
-  m_register_info_sp->Finalize(GetTarget().GetArchitecture());
+  AddRemoteRegisters(registers, arch_to_use);
 }
 
 Status ProcessGDBRemote::WillLaunch(lldb_private::Module *module) {
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
@@ -38,7 +38,6 @@
 
   ~GDBRemoteDynamicRegisterInfo() override = default;
 
-  void HardcodeARMRegisters(bool from_scratch);
   bool UpdateARM64SVERegistersInfos(uint64_t vg);
 };
 
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -815,266 +815,3 @@
   ConfigureOffsets();
   return true;
 }
-
-void GDBRemoteDynamicRegisterInfo::HardcodeARMRegisters(bool from_scratch) {
-  // For Advanced SIMD and VFP register mapping.
-  static uint32_t g_d0_regs[] = {26, 27, LLDB_INVALID_REGNUM};  // (s0, s1)
-  static uint32_t g_d1_regs[] = {28, 29, LLDB_INVALID_REGNUM};  // (s2, s3)
-  static uint32_t g_d2_regs[] = {30, 31, LLDB_INVALID_REGNUM};  // (s4, s5)
-  static uint32_t g_d3_regs[] = {32, 33, LLDB_INVALID_REGNUM};  // (s6, s7)
-  static uint32_t g_d4_regs[] = {34, 35, LLDB_INVALID_REGNUM};  // (s8, s9)
-  static uint32_t g_d5_regs[] = {36, 37, LLDB_INVALID_REGNUM};  // (s10, s11)
-  static uint32_t g_d6_regs[] = {38, 39, LLDB_INVALID_REGNUM};  // (s12, s13)
-  static uint32_t g_d7_regs[] = {40, 41, LLDB_INVALID_REGNUM};  // (s14, s15)
-  static uint32_t g_d8_regs[] = {42, 43, LLDB_INVALID_REGNUM};  // (s16, s17)
-  static uint32_t g_d9_regs[] = {44, 45, LLDB_INVALID_REGNUM};  // (s18, s19)
-  static uint32_t g_d10_regs[] = {46, 47, LLDB_INVALID_REGNUM}; // (s20, s21)
-  static uint32_t g_d11_regs[] = {48, 49, LLDB_INVALID_REGNUM}; // (s22, s23)
-  static uint32_t g_d12_regs[] = {50, 51, LLDB_INVALID_REGNUM}; // (s24, s25)
-  static uint32_t g_d13_regs[] = {52, 53, LLDB_INVALID_REGNUM}; // (s26, s27)
-  static uint32_t g_d14_regs[] = {54, 55, LLDB_INVALID_REGNUM}; // (s28, s29)
-  static uint32_t g_d15_regs[] = {56, 57, LLDB_INVALID_REGNUM}; // (s30, s31)
-  static uint32_t g_q0_regs[] = {
-  26, 27, 28, 29, LLDB_INVALID_REGNUM}; // (d0, d1) -> (s0, s1, s2, s3)
-  static uint32_t g_q1_regs[] = {
-  30, 31, 32, 33, LLDB_INVALID_REGNUM}; // (d2, d3) -> (s4, s5, s6, s7)
-  static uint32_t g_q2_regs[] = {
-  34, 35, 36, 37, LLDB_INVALID_REGNUM}; // (d4, d5) -> (s8, s9, s10, s11)
-  static uint32_t g_q3_regs[] = {
-  38, 39, 40, 41, LLDB_INVALID_REGNUM}; // (d6, d7) -> (s12, s13, s14, s15)
-  static uint32_t g_q4_regs[] = {
-  42, 43, 44, 45, LLDB_INVALID_REGNUM}; // (d8, d9) -> (s16, s17, s18, s19)
-  static uint32_t g_q5_regs[] = {
-  46, 47, 48, 49,
-  LLDB_INVALID_REGNUM}; // (d1

[Lldb-commits] [PATCH] D111498: [lldb] [DynamicRegisterInfo] Remove AddRegister() and make Finalize() protected

2021-10-25 Thread Michał Górny via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1bd258fd4e2c: [lldb] [DynamicRegisterInfo] Remove 
AddRegister() and make Finalize() protected (authored by mgorny).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D111498?vs=378469&id=382059#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111498

Files:
  lldb/include/lldb/Target/DynamicRegisterInfo.h
  lldb/source/Target/DynamicRegisterInfo.cpp
  lldb/unittests/Target/DynamicRegisterInfoTest.cpp

Index: lldb/unittests/Target/DynamicRegisterInfoTest.cpp
===
--- lldb/unittests/Target/DynamicRegisterInfoTest.cpp
+++ lldb/unittests/Target/DynamicRegisterInfoTest.cpp
@@ -25,108 +25,6 @@
   return ret;
 }
 
-class DynamicRegisterInfoTest : public ::testing::Test {
-protected:
-  DynamicRegisterInfo info;
-  uint32_t next_regnum = 0;
-  ConstString group{"group"};
-
-  uint32_t AddTestRegister(const char *name, uint32_t byte_size,
-   std::vector value_regs = {},
-   std::vector invalidate_regs = {}) {
-struct RegisterInfo new_reg {
-  name, nullptr, byte_size, LLDB_INVALID_INDEX32, lldb::eEncodingUint,
-  lldb::eFormatUnsigned,
-  {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
-   next_regnum, next_regnum},
-  nullptr, nullptr
-};
-
-if (!value_regs.empty()) {
-  value_regs.push_back(LLDB_INVALID_REGNUM);
-  new_reg.value_regs = value_regs.data();
-}
-if (!invalidate_regs.empty()) {
-  invalidate_regs.push_back(LLDB_INVALID_REGNUM);
-  new_reg.invalidate_regs = invalidate_regs.data();
-}
-
-info.AddRegister(new_reg, group);
-return next_regnum++;
-  }
-
-  void AssertRegisterInfo(uint32_t reg_num, const char *reg_name,
-  uint32_t byte_offset,
-  std::vector value_regs = {},
-  std::vector invalidate_regs = {}) {
-const RegisterInfo *reg = info.GetRegisterInfoAtIndex(reg_num);
-EXPECT_NE(reg, nullptr);
-if (!reg)
-  return;
-
-EXPECT_STREQ(reg->name, reg_name);
-EXPECT_EQ(reg->byte_offset, byte_offset);
-EXPECT_THAT(regs_to_vector(reg->value_regs), value_regs);
-EXPECT_THAT(regs_to_vector(reg->invalidate_regs), invalidate_regs);
-  }
-};
-
-#define ASSERT_REG(reg, ...)   \
-  {\
-SCOPED_TRACE("at register " #reg); \
-AssertRegisterInfo(reg, #reg, __VA_ARGS__);\
-  }
-
-TEST_F(DynamicRegisterInfoTest, finalize_regs) {
-  // Add regular registers
-  uint32_t b1 = AddTestRegister("b1", 8);
-  uint32_t b2 = AddTestRegister("b2", 8);
-
-  // Add a few sub-registers
-  uint32_t s1 = AddTestRegister("s1", 4, {b1});
-  uint32_t s2 = AddTestRegister("s2", 4, {b2});
-
-  // Add a register with invalidate_regs
-  uint32_t i1 = AddTestRegister("i1", 8, {}, {b1});
-
-  // Add a register with indirect invalidate regs to be expanded
-  // TODO: why is it done conditionally to value_regs?
-  uint32_t i2 = AddTestRegister("i2", 4, {b2}, {i1});
-
-  info.Finalize(lldb_private::ArchSpec());
-
-  ASSERT_REG(b1, 0);
-  ASSERT_REG(b2, 8);
-  ASSERT_REG(s1, 0, {b1});
-  ASSERT_REG(s2, 8, {b2});
-  ASSERT_REG(i1, 16, {}, {b1});
-  ASSERT_REG(i2, 8, {b2}, {b1, i1});
-}
-
-TEST_F(DynamicRegisterInfoTest, no_finalize_regs) {
-  // Add regular registers
-  uint32_t b1 = AddTestRegister("b1", 8);
-  uint32_t b2 = AddTestRegister("b2", 8);
-
-  // Add a few sub-registers
-  uint32_t s1 = AddTestRegister("s1", 4, {b1});
-  uint32_t s2 = AddTestRegister("s2", 4, {b2});
-
-  // Add a register with invalidate_regs
-  uint32_t i1 = AddTestRegister("i1", 8, {}, {b1});
-
-  // Add a register with indirect invalidate regs to be expanded
-  // TODO: why is it done conditionally to value_regs?
-  uint32_t i2 = AddTestRegister("i2", 4, {b2}, {i1});
-
-  ASSERT_REG(b1, LLDB_INVALID_INDEX32);
-  ASSERT_REG(b2, LLDB_INVALID_INDEX32);
-  ASSERT_REG(s1, LLDB_INVALID_INDEX32);
-  ASSERT_REG(s2, LLDB_INVALID_INDEX32);
-  ASSERT_REG(i1, LLDB_INVALID_INDEX32);
-  ASSERT_REG(i2, LLDB_INVALID_INDEX32);
-}
-
 class DynamicRegisterInfoRegisterTest : public ::testing::Test {
 protected:
   std::vector m_regs;
Index: lldb/source/Target/DynamicRegisterInfo.cpp
===
--- lldb/source/Target/DynamicRegisterInfo.cpp
+++ lldb/source/Target/DynamicRegisterInfo.cpp
@@ -422,35 +422,6 @@
   return m_regs.size();
 }
 
-void DynamicRegisterInfo::AddRegister(RegisterInfo reg_info,
-  ConstString &set_n

[Lldb-commits] [PATCH] D112180: Libcpp bitset syntethic children and tests

2021-10-25 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan updated this revision to Diff 382066.
danilashtefan added a comment.

I have corrected everything according to the previous comments. Wallace will 
kindly help me to format the code, since I have the following formatter error 
Stack dump:
0.Program arguments: clang-format -lines=1:149 -lines=0:0 
lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp 
/lib/x86_64-linux-gnu/libLLVM-10.so.1(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x1f)[0x7fa7b5d204ff]
/lib/x86_64-linux-gnu/libLLVM-10.so.1(_ZN4llvm3sys17RunSignalHandlersEv+0x50)[0x7fa7b5d1e7b0]
/lib/x86_64-linux-gnu/libLLVM-10.so.1(+0x981ac5)[0x7fa7b5d20ac5]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0)[0x7fa7bc4f03c0]
/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZNK5clang13SourceManager16translateLineColENS_6FileIDEjj+0xcf)[0x7fa7ba1cc83f]
clang-format[0x407e10]
clang-format[0x406b64]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x7fa7b4e4e0b3]
clang-format[0x40652e]
error: clang-format -lines=1:149 -lines=0:0 
lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp failed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112180

Files:
  lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
@@ -1,29 +1,28 @@
 #include 
 #include 
 
-template
-void fill(std::bitset &b) {
+template  void fill(std::bitset &b) {
   b.set();
   b[0] = b[1] = false;
   for (std::size_t i = 2; i < N; ++i) {
-for (std::size_t j = 2*i; j < N; j+=i)
+for (std::size_t j = 2 * i; j < N; j += i)
   b[j] = false;
   }
 }
 
-template
+template 
 void by_ref_and_ptr(std::bitset &ref, std::bitset *ptr) {
-// Check ref and ptr
-return;
+  // Check ref and ptr
+  return;
 }
 
 int main() {
   std::bitset<0> empty;
   std::bitset<13> small;
   fill(small);
-  std::bitset<200> large;
+  std::bitset<70> large;
   fill(large);
   by_ref_and_ptr(small, &small); // break here
-  by_ref_and_ptr(large, &large);
+  by_ref_and_ptr(large, &large); 
   return 0;
 }
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
@@ -1,5 +1,5 @@
 """
-Test lldb data formatter subsystem.
+Test lldb data formatter subsystem for bitset for libcxx and libstdcpp.
 """
 
 
@@ -9,14 +9,15 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
+USE_LIBSTDCPP = "USE_LIBSTDCPP"
+USE_LIBCPP = "USE_LIBCPP"
 
-class TestDataFormatterLibcxxBitset(TestBase):
+class GenericBitsetDataFormatterTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
 def setUp(self):
 TestBase.setUp(self)
-
 primes = [1]*300
 primes[0] = primes[1] = 0
 for i in range(2, len(primes)):
@@ -33,21 +34,29 @@
 self.assertEqual(child.GetValueAsUnsigned(), self.primes[i],
 "variable: %s, index: %d"%(name, size))
 
-@add_test_categories(["libc++"])
-def test_value(self):
+def do_test_value(self, stdlib_type):
 """Test that std::bitset is displayed correctly"""
-self.build()
+self.build(dictionary={stdlib_type: "1"})
+
 lldbutil.run_to_source_breakpoint(self, '// break here',
 lldb.SBFileSpec("main.cpp", False))
 
 self.check("empty", 0)
 self.check("small", 13)
-self.check("large", 200)
+self.check("large", 70)
+
+@add_test_categories(["libstdcxx"])
+def test_value_libstdcpp(self):
+self.do_test_

[Lldb-commits] [PATCH] D112471: [LLDB] Fix Cpsr size for WoA64 target

2021-10-25 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo accepted this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D112471

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


[Lldb-commits] [PATCH] D112279: Add modules stats into the "statistics dump" command.

2021-10-25 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In D112279#3084758 , @JDevlieghere 
wrote:

> Can we use the UUID as the module identifier (at least in the JSON)? Other 
> than that, this LGTM.

Some binaries don't have UUID values and I didn't want to use a UUID when it 
was there and something else when the UUID wasn't there. The main example is 
all .o files don't have UUID values and many linux binaries may or may not have 
them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112279

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


[Lldb-commits] [lldb] c571988 - Add modules stats into the "statistics dump" command.

2021-10-25 Thread Greg Clayton via lldb-commits

Author: Greg Clayton
Date: 2021-10-25T11:50:02-07:00
New Revision: c571988e9d576f78c00e45fc730f68953c45ea3a

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

LOG: Add modules stats into the "statistics dump" command.

The new module stats adds the ability to measure the time it takes to parse and 
index the symbol tables for each module, and reports modules statistics in the 
output of "statistics dump" along with the path, UUID and triple of the module. 
The time it takes to parse and index the symbol tables are also aggregated into 
new top level key/value pairs at the target level.

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

Added: 


Modified: 
lldb/include/lldb/Core/Module.h
lldb/include/lldb/Target/Statistics.h
lldb/source/API/SBTarget.cpp
lldb/source/Commands/CommandObjectStats.cpp
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Symbol/Symtab.cpp
lldb/source/Target/Statistics.cpp
lldb/source/Target/Target.cpp
lldb/test/API/commands/statistics/basic/TestStats.py
lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py

Removed: 




diff  --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 767f2d232947c..b80f4fd9b85a7 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -16,6 +16,7 @@
 #include "lldb/Symbol/SymbolContextScope.h"
 #include "lldb/Symbol/TypeSystem.h"
 #include "lldb/Target/PathMappingList.h"
+#include "lldb/Target/Statistics.h"
 #include "lldb/Utility/ArchSpec.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/FileSpec.h"
@@ -870,6 +871,18 @@ class Module : public std::enable_shared_from_this,
   /// Update the ArchSpec to a more specific variant.
   bool MergeArchitecture(const ArchSpec &arch_spec);
 
+  /// Accessor for the symbol table parse time metric.
+  ///
+  /// The value is returned as a reference to allow it to be updated by the
+  /// ElapsedTime RAII object.
+  StatsDuration &GetSymtabParseTime() { return m_symtab_parse_time; }
+  
+  /// Accessor for the symbol table index time metric.
+  ///
+  /// The value is returned as a reference to allow it to be updated by the
+  /// ElapsedTime RAII object.
+  StatsDuration &GetSymtabIndexTime() { return m_symtab_index_time; }
+
   /// \class LookupInfo Module.h "lldb/Core/Module.h"
   /// A class that encapsulates name lookup information.
   ///
@@ -995,6 +1008,14 @@ class Module : public 
std::enable_shared_from_this,
   mutable bool m_file_has_changed : 1,
   m_first_file_changed_log : 1; /// See if the module was modified after it
 /// was initially opened.
+  /// We store a symbol table parse time duration here because we might have
+  /// an object file and a symbol file which both have symbol tables. The parse
+  /// time for the symbol tables can be aggregated here.
+  StatsDuration m_symtab_parse_time{0.0};
+  /// We store a symbol named index time duration here because we might have
+  /// an object file and a symbol file which both have symbol tables. The parse
+  /// time for the symbol tables can be aggregated here.
+  StatsDuration m_symtab_index_time{0.0};
 
   /// Resolve a file or load virtual address.
   ///

diff  --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index dfeefcbe74eac..6bfc7a9f32e4d 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -72,10 +72,21 @@ struct StatsSuccessFail {
   uint32_t failures = 0;
 };
 
+/// A class that represents statistics for a since lldb_private::Module.
+struct ModuleStats {
+  llvm::json::Value ToJSON() const;
+  intptr_t identifier;
+  std::string path;
+  std::string uuid;
+  std::string triple;
+  double symtab_parse_time = 0.0;
+  double symtab_index_time = 0.0;
+};
+
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON();
+  llvm::json::Value ToJSON(Target &target);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -92,6 +103,8 @@ class TargetStats {
   llvm::Optional m_first_public_stop_time;
   StatsSuccessFail m_expr_eval{"expressionEvaluation"};
   StatsSuccessFail m_frame_var{"frameVariable"};
+  std::vector m_module_identifiers;
+  void CollectStats(Target &target);
 };
 
 class DebuggerStats {
@@ -99,11 +112,19 @@ class DebuggerStats {
   static void SetCollectingStats(bool enable) { g_collecting_stats = enable; }
   static bool GetCollectingStats() { return g_collecting_stats; }
 
-  

[Lldb-commits] [PATCH] D112279: Add modules stats into the "statistics dump" command.

2021-10-25 Thread Greg Clayton via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc571988e9d57: Add modules stats into the "statistics 
dump" command. (authored by clayborg).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112279

Files:
  lldb/include/lldb/Core/Module.h
  lldb/include/lldb/Target/Statistics.h
  lldb/source/API/SBTarget.cpp
  lldb/source/Commands/CommandObjectStats.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Symbol/Symtab.cpp
  lldb/source/Target/Statistics.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/commands/statistics/basic/TestStats.py
  lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py

Index: lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
===
--- lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
+++ lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
@@ -28,11 +28,16 @@
 stats = target.GetStatistics()
 stream = lldb.SBStream()
 res = stats.GetAsJSON(stream)
-stats_json = json.loads(stream.GetData())
+debug_stats = json.loads(stream.GetData())
+self.assertEqual('targets' in debug_stats, True,
+'Make sure the "targets" key in in target.GetStatistics()')
+self.assertEqual('modules' in debug_stats, True,
+'Make sure the "modules" key in in target.GetStatistics()')
+stats_json = debug_stats['targets'][0]
 self.assertEqual('expressionEvaluation' in stats_json, True,
-'Make sure the "expressionEvaluation" key in in target.GetStatistics()')
+'Make sure the "expressionEvaluation" key in in target.GetStatistics()["targets"][0]')
 self.assertEqual('frameVariable' in stats_json, True,
-'Make sure the "frameVariable" key in in target.GetStatistics()')
+'Make sure the "frameVariable" key in in target.GetStatistics()["targets"][0]')
 expressionEvaluation = stats_json['expressionEvaluation']
 self.assertEqual('successes' in expressionEvaluation, True,
 'Make sure the "successes" key in in "expressionEvaluation" dictionary"')
Index: lldb/test/API/commands/statistics/basic/TestStats.py
===
--- lldb/test/API/commands/statistics/basic/TestStats.py
+++ lldb/test/API/commands/statistics/basic/TestStats.py
@@ -82,12 +82,18 @@
 f.write(metrics_json)
 return json.loads(metrics_json)
 
+
+def get_target_stats(self, debug_stats):
+if "targets" in debug_stats:
+return debug_stats["targets"][0]
+return None
+
 def test_expressions_frame_var_counts(self):
 lldbutil.run_to_source_breakpoint(self, "// break here",
   lldb.SBFileSpec("main.c"))
 
 self.expect("expr patatino", substrs=['27'])
-stats = self.get_stats()
+stats = self.get_target_stats(self.get_stats())
 self.verify_success_fail_count(stats, 'expressionEvaluation', 1, 0)
 self.expect("expr doesnt_exist", error=True,
 substrs=["undeclared identifier 'doesnt_exist'"])
@@ -103,13 +109,13 @@
 self.expect("expr -Z 3 -- 1", error=True,
 substrs=["expression cannot be used with --element-count"])
 # We should have gotten 3 new failures and the previous success.
-stats = self.get_stats()
+stats = self.get_target_stats(self.get_stats())
 self.verify_success_fail_count(stats, 'expressionEvaluation', 2, 2)
 
 self.expect("statistics enable")
 # 'frame var' with enabled statistics will change stats.
 self.expect("frame var", substrs=['27'])
-stats = self.get_stats()
+stats = self.get_target_stats(self.get_stats())
 self.verify_success_fail_count(stats, 'frameVariable', 1, 0)
 
 def test_default_no_run(self):
@@ -123,22 +129,39 @@
 
 (lldb) statistics dump
 {
-  "targetCreateTime": 0.265668995,
-  "expressionEvaluation": {
-"failures": 0,
-"successes": 0
-  },
-  "frameVariable": {
-"failures": 0,
-"successes": 0
-  },
+  "modules" : [...],
+  "targets" : [
+{
+"targetCreateTime": 0.265668995,
+"expressionEvaluation": {
+"failures": 0,
+"successes": 0
+},
+"frameVariable": {
+"failures": 0,
+"successes": 0
+},
+   

[Lldb-commits] [PATCH] D112439: normalize file path when searching the source map

2021-10-25 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Adding a test would be great for this. Please add one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112439

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


[Lldb-commits] [PATCH] D112180: Libcpp bitset syntethic children and tests

2021-10-25 Thread walter erquinigo via Phabricator via lldb-commits
wallace requested changes to this revision.
wallace added a comment.
This revision now requires changes to proceed.

almost there!




Comment at: lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp:20
 
-class BitsetFrontEnd : public SyntheticChildrenFrontEnd {
+// This class can be used for handling bitsets from both libcxx and libstdcpp.
+class GenericBitsetFrontEnd : public SyntheticChildrenFrontEnd {

Use `///` instead of `//`, that way it'll appear in the official documentation



Comment at: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py:32-35
 for i in range(size):
 child = var.GetChildAtIndex(i)
 self.assertEqual(child.GetValueAsUnsigned(), self.primes[i],
 "variable: %s, index: %d"%(name, size))

What teemperor is saying is to something like:

  children = [ValueCheck(name="", summary='')]
  for i in range(size):
children.append(
  valobj = self.expect_var_path(
name,
type="std::bitset<" + size + ">", # you might need to change this 
depending on the stdlib you use for each test
children=children,
)

  self.assertRegex(valobj.summary, r'^"hello"( strong=1)? weak=1$') # change 
this for the actual summary of the object


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112180

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


[Lldb-commits] [PATCH] D112180: Libcpp bitset syntethic children and tests

2021-10-25 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



Comment at: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py:32-35
 for i in range(size):
 child = var.GetChildAtIndex(i)
 self.assertEqual(child.GetValueAsUnsigned(), self.primes[i],
 "variable: %s, index: %d"%(name, size))

wallace wrote:
> What teemperor is saying is to something like:
> 
>   children = [ValueCheck(name="", summary='')]
>   for i in range(size):
> children.append(
>   valobj = self.expect_var_path(
> name,
> type="std::bitset<" + size + ">", # you might need to change this 
> depending on the stdlib you use for each test
> children=children,
> )
> 
>   self.assertRegex(valobj.summary, r'^"hello"( strong=1)? weak=1$') # change 
> this for the actual summary of the object
Ugh, I made some mistakes

```
children = []
for i in range(size):
  children.append(
valobj = self.expect_var_path( // this will check the entire bitset and the 
children argument will check its children
  name,
  type="std::bitset<" + size + ">", // you might need to change this 
depending on the stdlib you use for each test
  children=children,
  )

self.assertRegex(valobj.summary, r'^"hello"( strong=1)? weak=1$') # change this 
for the actual summary of the object
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112180

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


[Lldb-commits] [PATCH] D112495: [lldb] [Host/ConnectionFileDescriptor] Refactor to improve code reuse

2021-10-25 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, teemperor, krytarowski, emaste.
mgorny requested review of this revision.

Refactor ConnectionFileDescriptor to improve code reuse for different
types of sockets.  Unify method naming.

While at it, remove some (now-)dead code from Socket.


https://reviews.llvm.org/D112495

Files:
  lldb/include/lldb/Host/Socket.h
  lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
  lldb/source/Host/common/Socket.cpp
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp

Index: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
===
--- lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -151,17 +151,17 @@
 auto method =
 llvm::StringSwitch(scheme)
-.Case("listen", &ConnectionFileDescriptor::SocketListenAndAccept)
+.Case("listen", &ConnectionFileDescriptor::AcceptTCP)
 .Cases("accept", "unix-accept",
-   &ConnectionFileDescriptor::NamedSocketAccept)
+   &ConnectionFileDescriptor::AcceptNamedSocket)
 .Case("unix-abstract-accept",
-  &ConnectionFileDescriptor::UnixAbstractSocketAccept)
+  &ConnectionFileDescriptor::AcceptAbstractSocket)
 .Cases("connect", "tcp-connect",
&ConnectionFileDescriptor::ConnectTCP)
 .Case("udp", &ConnectionFileDescriptor::ConnectUDP)
-.Case("unix-connect", &ConnectionFileDescriptor::NamedSocketConnect)
+.Case("unix-connect", &ConnectionFileDescriptor::ConnectNamedSocket)
 .Case("unix-abstract-connect",
-  &ConnectionFileDescriptor::UnixAbstractSocketConnect)
+  &ConnectionFileDescriptor::ConnectAbstractSocket)
 #if LLDB_ENABLE_POSIX
 .Case("fd", &ConnectionFileDescriptor::ConnectFD)
 .Case("file", &ConnectionFileDescriptor::ConnectFile)
@@ -532,24 +532,25 @@
   return eConnectionStatusLostConnection;
 }
 
-ConnectionStatus ConnectionFileDescriptor::NamedSocketAccept(
-llvm::StringRef socket_name, socket_id_callback_type socket_id_callback,
+lldb::ConnectionStatus ConnectionFileDescriptor::AcceptSocket(
+Socket::SocketProtocol socket_protocol, llvm::StringRef socket_name,
+llvm::function_ref post_listen_callback,
 Status *error_ptr) {
   Status error;
-  std::unique_ptr listen_socket = Socket::Create(
-  Socket::ProtocolUnixDomain, m_child_processes_inherit, error);
-  Socket *socket = nullptr;
+  std::unique_ptr listening_socket =
+  Socket::Create(socket_protocol, m_child_processes_inherit, error);
+  Socket *accepted_socket;
 
   if (!error.Fail())
-error = listen_socket->Listen(socket_name, 5);
+error = listening_socket->Listen(socket_name, 5);
 
   if (!error.Fail()) {
-socket_id_callback(socket_name);
-error = listen_socket->Accept(socket);
+post_listen_callback(*listening_socket);
+error = listening_socket->Accept(accepted_socket);
   }
 
   if (!error.Fail()) {
-m_io_sp.reset(socket);
+m_io_sp.reset(accepted_socket);
 m_uri.assign(socket_name.str());
 return eConnectionStatusSuccess;
   }
@@ -559,40 +560,19 @@
   return eConnectionStatusError;
 }
 
-ConnectionStatus ConnectionFileDescriptor::NamedSocketConnect(
-llvm::StringRef socket_name, socket_id_callback_type socket_id_callback,
-Status *error_ptr) {
-  Socket *socket = nullptr;
-  Status error =
-  Socket::UnixDomainConnect(socket_name, m_child_processes_inherit, socket);
-  if (error_ptr)
-*error_ptr = error;
-  m_io_sp.reset(socket);
-  if (error.Fail())
-return eConnectionStatusError;
-  m_uri.assign(std::string(socket_name));
-  return eConnectionStatusSuccess;
-}
-
-ConnectionStatus ConnectionFileDescriptor::UnixAbstractSocketAccept(
-llvm::StringRef socket_name, socket_id_callback_type socket_id_callback,
-Status *error_ptr) {
+lldb::ConnectionStatus
+ConnectionFileDescriptor::ConnectSocket(Socket::SocketProtocol socket_protocol,
+llvm::StringRef socket_name,
+Status *error_ptr) {
   Status error;
-  std::unique_ptr listen_socket = Socket::Create(
-  Socket::ProtocolUnixAbstract, m_child_processes_inherit, error);
-  Socket *socket = nullptr;
-
-  if (!error.Fail())
-error = listen_socket->Listen(socket_name, 5);
+  std::unique_ptr socket =
+  Socket::Create(socket_protocol, m_child_processes_inherit, error);
 
   if (!error.Fail())
-socket_id_callback(socket_name);
-
-  if (!error.Fail())
-error = listen_socket->Accept(socket);
+error = socket->Connect(socket_name);
 
   if (!error.Fail()) {
-m_io_sp.reset(socket);
+m_io_sp = std::move(socket);
 m_uri.assign(socket_name.str());
 return eConnectionStatusSuccess;
   }
@@ -602,72 +582,63 @@
   return eCon

[Lldb-commits] [PATCH] D112497: [lldb] Configure CMake policy CMP0116 for standalone builds

2021-10-25 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added a reviewer: JDevlieghere.
Herald added a subscriber: mgorny.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Using CMake >=3.20 results in many warnings about this new policy. This change 
silences the warnings by explicitly declaring use of the "OLD" behavior.

This applies D101083  to LLDBStandalone.cmake.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112497

Files:
  lldb/cmake/modules/LLDBStandalone.cmake


Index: lldb/cmake/modules/LLDBStandalone.cmake
===
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -1,3 +1,9 @@
+# CMP0116: Ninja generators transform `DEPFILE`s from `add_custom_command()`
+# New in CMake 3.20. https://cmake.org/cmake/help/latest/policy/CMP0116.html
+if(POLICY CMP0116)
+  cmake_policy(SET CMP0116 OLD)
+endif()
+
 option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 
'install' target." OFF)
 
 find_package(LLVM REQUIRED CONFIG HINTS ${LLVM_DIR} NO_CMAKE_FIND_ROOT_PATH)


Index: lldb/cmake/modules/LLDBStandalone.cmake
===
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -1,3 +1,9 @@
+# CMP0116: Ninja generators transform `DEPFILE`s from `add_custom_command()`
+# New in CMake 3.20. https://cmake.org/cmake/help/latest/policy/CMP0116.html
+if(POLICY CMP0116)
+  cmake_policy(SET CMP0116 OLD)
+endif()
+
 option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
 
 find_package(LLVM REQUIRED CONFIG HINTS ${LLVM_DIR} NO_CMAKE_FIND_ROOT_PATH)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D112497: [lldb] Configure CMake policy CMP0116 for standalone builds

2021-10-25 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/D112497/new/

https://reviews.llvm.org/D112497

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


[Lldb-commits] [lldb] 65dae8b - [lldb] Configure CMake policy CMP0116 for standalone builds

2021-10-25 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2021-10-25T16:29:36-07:00
New Revision: 65dae8b2f20c32632e48922456a305504f4e6fbe

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

LOG: [lldb] Configure CMake policy CMP0116 for standalone builds

Using CMake >=3.20 results in many warnings about this new policy. This change 
silences the warnings by explicitly declaring use of the "OLD" behavior.

This applies D101083 to LLDBStandalone.cmake.

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

Added: 


Modified: 
lldb/cmake/modules/LLDBStandalone.cmake

Removed: 




diff  --git a/lldb/cmake/modules/LLDBStandalone.cmake 
b/lldb/cmake/modules/LLDBStandalone.cmake
index 26812f9c63f7c..5be9e57f23bfc 100644
--- a/lldb/cmake/modules/LLDBStandalone.cmake
+++ b/lldb/cmake/modules/LLDBStandalone.cmake
@@ -1,3 +1,9 @@
+# CMP0116: Ninja generators transform `DEPFILE`s from `add_custom_command()`
+# New in CMake 3.20. https://cmake.org/cmake/help/latest/policy/CMP0116.html
+if(POLICY CMP0116)
+  cmake_policy(SET CMP0116 OLD)
+endif()
+
 option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 
'install' target." OFF)
 
 find_package(LLVM REQUIRED CONFIG HINTS ${LLVM_DIR} NO_CMAKE_FIND_ROOT_PATH)



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


[Lldb-commits] [PATCH] D112497: [lldb] Configure CMake policy CMP0116 for standalone builds

2021-10-25 Thread Dave Lee via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG65dae8b2f20c: [lldb] Configure CMake policy CMP0116 for 
standalone builds (authored by kastiglione).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112497

Files:
  lldb/cmake/modules/LLDBStandalone.cmake


Index: lldb/cmake/modules/LLDBStandalone.cmake
===
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -1,3 +1,9 @@
+# CMP0116: Ninja generators transform `DEPFILE`s from `add_custom_command()`
+# New in CMake 3.20. https://cmake.org/cmake/help/latest/policy/CMP0116.html
+if(POLICY CMP0116)
+  cmake_policy(SET CMP0116 OLD)
+endif()
+
 option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 
'install' target." OFF)
 
 find_package(LLVM REQUIRED CONFIG HINTS ${LLVM_DIR} NO_CMAKE_FIND_ROOT_PATH)


Index: lldb/cmake/modules/LLDBStandalone.cmake
===
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -1,3 +1,9 @@
+# CMP0116: Ninja generators transform `DEPFILE`s from `add_custom_command()`
+# New in CMake 3.20. https://cmake.org/cmake/help/latest/policy/CMP0116.html
+if(POLICY CMP0116)
+  cmake_policy(SET CMP0116 OLD)
+endif()
+
 option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
 
 find_package(LLVM REQUIRED CONFIG HINTS ${LLVM_DIR} NO_CMAKE_FIND_ROOT_PATH)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D112501: Add new key/value pairs to the module statistics for "statistics dump".

2021-10-25 Thread Greg Clayton via Phabricator via lldb-commits
clayborg created this revision.
clayborg added reviewers: JDevlieghere, wallace, aadsm, labath, jingham.
Herald added a subscriber: arphaman.
clayborg requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The new key/value pairs that are added to each module's stats are:
"debugInfoByteSize": The size in bytes of debug info for each module.
"debugInfoIndexTime": The time in seconds that it took to index the debug info.
"debugInfoParseTime": The time in seconds that debug info had to be parsed.

At the top level we add up all of the debug info size, parse time and index 
time with the following keys:
"totalDebugInfoByteSize": The size in bytes of all debug info in all modules.
"totalDebugInfoIndexTime": The time in seconds that it took to index all debug 
info if it was indexed for all modules.
"totalDebugInfoParseTime": The time in seconds that debug info was parsed for 
all modules.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112501

Files:
  lldb/include/lldb/Core/Section.h
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/include/lldb/Target/Statistics.h
  lldb/source/Core/Section.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
  lldb/source/Symbol/SymbolFile.cpp
  lldb/source/Target/Statistics.cpp
  lldb/test/API/commands/statistics/basic/TestStats.py

Index: lldb/test/API/commands/statistics/basic/TestStats.py
===
--- lldb/test/API/commands/statistics/basic/TestStats.py
+++ lldb/test/API/commands/statistics/basic/TestStats.py
@@ -144,6 +144,9 @@
 "moduleIdentifiers": [...],
 }
   ],
+  "totalDebugInfoByteSize": 182522234,
+  "totalDebugInfoIndexTime": 2.33343,
+  "totalDebugInfoParseTime": 8.212140024071,
   "totalSymbolTableParseTime": 0.123,
   "totalSymbolTableIndexTime": 0.234,
 }
@@ -155,6 +158,9 @@
 'targets',
 'totalSymbolTableParseTime',
 'totalSymbolTableIndexTime',
+'totalDebugInfoByteSize',
+'totalDebugInfoIndexTime',
+'totalDebugInfoParseTime',
 ]
 self.verify_keys(debug_stats, '"debug_stats"', debug_stat_keys, None)
 stats = debug_stats['targets'][0]
@@ -198,6 +204,9 @@
 },
 }
 ],
+"totalDebugInfoByteSize": 182522234,
+"totalDebugInfoIndexTime": 2.33343,
+"totalDebugInfoParseTime": 8.212140024071,
 "totalSymbolTableParseTime": 0.123,
 "totalSymbolTableIndexTime": 0.234,
 }
@@ -212,6 +221,9 @@
 'targets',
 'totalSymbolTableParseTime',
 'totalSymbolTableIndexTime',
+'totalDebugInfoByteSize',
+'totalDebugInfoIndexTime',
+'totalDebugInfoParseTime',
 ]
 self.verify_keys(debug_stats, '"debug_stats"', debug_stat_keys, None)
 stats = debug_stats['targets'][0]
@@ -247,6 +259,9 @@
 'targets',
 'totalSymbolTableParseTime',
 'totalSymbolTableIndexTime',
+'totalDebugInfoParseTime',
+'totalDebugInfoIndexTime',
+'totalDebugInfoByteSize'
 ]
 self.verify_keys(debug_stats, '"debug_stats"', debug_stat_keys, None)
 stats = debug_stats['targets'][0]
@@ -256,6 +271,9 @@
 self.verify_keys(stats, '"stats"', keys_exist, None)
 exe_module = self.find_module_in_metrics(exe, debug_stats)
 module_keys = [
+'debugInfoByteSize',
+'debugInfoIndexTime',
+'debugInfoParseTime',
 'identifier',
 'path',
 'symbolTableIndexTime',
Index: lldb/source/Target/Statistics.cpp
===
--- lldb/source/Target/Statistics.cpp
+++ lldb/source/Target/Statistics.cpp
@@ -50,6 +50,9 @@
   module.try_emplace("identifier", identifier);
   module.try_emplace("symbolTableParseTime", symtab_parse_time);
   module.try_emplace("symbolTableIndexTime", symtab_index_time);
+  module.try_emplace("debugInfoParseTime", debug_parse_time);
+  module.try_emplace("debugInfoIndexTime", debug_index_time);
+  module.try_emplace("debugInfoByteSize", (int64_t)debug_info_size

[Lldb-commits] [PATCH] D112501: Add new key/value pairs to the module statistics for "statistics dump".

2021-10-25 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

New output looks like:

  (lldb) statistics dump
  {
"modules": [
  {
"debugInfoByteSize": 876,
"debugInfoIndexTime": 0,
"debugInfoParseTime": 0.000118668002,
"identifier": 5224745544,
"path": "/Users/gclayton/Documents/src/args/build/a.out",
"symbolTableIndexTime": 1.4334e-05,
"symbolTableParseTime": 0.000196667001,
"triple": "arm64-apple-macosx11.0.0",
"uuid": "B7F60DCD-68BF-3F2D-AE27-85253725636A"
  },
  ...
],
"targets": [
  {
"expressionEvaluation": {
  "failures": 0,
  "successes": 0
},
"firstStopTime": 0.344916501,
"frameVariable": {
  "failures": 0,
  "successes": 0
},
"launchOrAttachTime": 0.324432501,
"moduleIdentifiers": [
  5224745544,
  ...
],
"targetCreateTime": 0.166235582
  }
],
"totalDebugInfoByteSize": 16989,
"totalDebugInfoIndexTime": 0,
"totalDebugInfoParseTime": 0.000237336005,
"totalSymbolTableIndexTime": 0.0477563347,
"totalSymbolTableParseTime": 0.0750837964
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112501

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


[Lldb-commits] [PATCH] D112501: Add new key/value pairs to the module statistics for "statistics dump".

2021-10-25 Thread Greg Clayton via Phabricator via lldb-commits
clayborg updated this revision to Diff 382159.
clayborg added a comment.

Fix headerdoc that mentioned llvm::None.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112501

Files:
  lldb/include/lldb/Core/Section.h
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/include/lldb/Target/Statistics.h
  lldb/source/Core/Section.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
  lldb/source/Symbol/SymbolFile.cpp
  lldb/source/Target/Statistics.cpp
  lldb/test/API/commands/statistics/basic/TestStats.py

Index: lldb/test/API/commands/statistics/basic/TestStats.py
===
--- lldb/test/API/commands/statistics/basic/TestStats.py
+++ lldb/test/API/commands/statistics/basic/TestStats.py
@@ -144,6 +144,9 @@
 "moduleIdentifiers": [...],
 }
   ],
+  "totalDebugInfoByteSize": 182522234,
+  "totalDebugInfoIndexTime": 2.33343,
+  "totalDebugInfoParseTime": 8.212140024071,
   "totalSymbolTableParseTime": 0.123,
   "totalSymbolTableIndexTime": 0.234,
 }
@@ -155,6 +158,9 @@
 'targets',
 'totalSymbolTableParseTime',
 'totalSymbolTableIndexTime',
+'totalDebugInfoByteSize',
+'totalDebugInfoIndexTime',
+'totalDebugInfoParseTime',
 ]
 self.verify_keys(debug_stats, '"debug_stats"', debug_stat_keys, None)
 stats = debug_stats['targets'][0]
@@ -198,6 +204,9 @@
 },
 }
 ],
+"totalDebugInfoByteSize": 182522234,
+"totalDebugInfoIndexTime": 2.33343,
+"totalDebugInfoParseTime": 8.212140024071,
 "totalSymbolTableParseTime": 0.123,
 "totalSymbolTableIndexTime": 0.234,
 }
@@ -212,6 +221,9 @@
 'targets',
 'totalSymbolTableParseTime',
 'totalSymbolTableIndexTime',
+'totalDebugInfoByteSize',
+'totalDebugInfoIndexTime',
+'totalDebugInfoParseTime',
 ]
 self.verify_keys(debug_stats, '"debug_stats"', debug_stat_keys, None)
 stats = debug_stats['targets'][0]
@@ -247,6 +259,9 @@
 'targets',
 'totalSymbolTableParseTime',
 'totalSymbolTableIndexTime',
+'totalDebugInfoParseTime',
+'totalDebugInfoIndexTime',
+'totalDebugInfoByteSize'
 ]
 self.verify_keys(debug_stats, '"debug_stats"', debug_stat_keys, None)
 stats = debug_stats['targets'][0]
@@ -256,6 +271,9 @@
 self.verify_keys(stats, '"stats"', keys_exist, None)
 exe_module = self.find_module_in_metrics(exe, debug_stats)
 module_keys = [
+'debugInfoByteSize',
+'debugInfoIndexTime',
+'debugInfoParseTime',
 'identifier',
 'path',
 'symbolTableIndexTime',
Index: lldb/source/Target/Statistics.cpp
===
--- lldb/source/Target/Statistics.cpp
+++ lldb/source/Target/Statistics.cpp
@@ -50,6 +50,9 @@
   module.try_emplace("identifier", identifier);
   module.try_emplace("symbolTableParseTime", symtab_parse_time);
   module.try_emplace("symbolTableIndexTime", symtab_index_time);
+  module.try_emplace("debugInfoParseTime", debug_parse_time);
+  module.try_emplace("debugInfoIndexTime", debug_index_time);
+  module.try_emplace("debugInfoByteSize", (int64_t)debug_info_size);
   return module;
 }
 
@@ -109,6 +112,9 @@
   json::Array json_modules;
   double symtab_parse_time = 0.0;
   double symtab_index_time = 0.0;
+  double debug_parse_time = 0.0;
+  double debug_index_time = 0.0;
+  uint64_t debug_info_size = 0;
   if (target) {
 json_targets.emplace_back(target->ReportStatistics());
   } else {
@@ -119,18 +125,31 @@
   std::lock_guard guard(
   Module::GetAllocationModuleCollectionMutex());
   const size_t num_modules = Module::GetNumberAllocatedModules();
-  ModuleSP module_sp;
   for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
 Module *module = Module::GetAllocatedModuleAtIndex(image_idx);
 ModuleStats module_stat;
 module_stat.identifier = (intptr_t)module;
 module_stat.path = 

[Lldb-commits] [PATCH] D112501: Add new key/value pairs to the module statistics for "statistics dump".

2021-10-25 Thread Greg Clayton via Phabricator via lldb-commits
clayborg updated this revision to Diff 382160.
clayborg added a comment.

Added newlines to files that needed them at the end of the file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112501

Files:
  lldb/include/lldb/Core/Section.h
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/include/lldb/Target/Statistics.h
  lldb/source/Core/Section.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
  lldb/source/Symbol/SymbolFile.cpp
  lldb/source/Target/Statistics.cpp
  lldb/test/API/commands/statistics/basic/TestStats.py

Index: lldb/test/API/commands/statistics/basic/TestStats.py
===
--- lldb/test/API/commands/statistics/basic/TestStats.py
+++ lldb/test/API/commands/statistics/basic/TestStats.py
@@ -144,6 +144,9 @@
 "moduleIdentifiers": [...],
 }
   ],
+  "totalDebugInfoByteSize": 182522234,
+  "totalDebugInfoIndexTime": 2.33343,
+  "totalDebugInfoParseTime": 8.212140024071,
   "totalSymbolTableParseTime": 0.123,
   "totalSymbolTableIndexTime": 0.234,
 }
@@ -155,6 +158,9 @@
 'targets',
 'totalSymbolTableParseTime',
 'totalSymbolTableIndexTime',
+'totalDebugInfoByteSize',
+'totalDebugInfoIndexTime',
+'totalDebugInfoParseTime',
 ]
 self.verify_keys(debug_stats, '"debug_stats"', debug_stat_keys, None)
 stats = debug_stats['targets'][0]
@@ -198,6 +204,9 @@
 },
 }
 ],
+"totalDebugInfoByteSize": 182522234,
+"totalDebugInfoIndexTime": 2.33343,
+"totalDebugInfoParseTime": 8.212140024071,
 "totalSymbolTableParseTime": 0.123,
 "totalSymbolTableIndexTime": 0.234,
 }
@@ -212,6 +221,9 @@
 'targets',
 'totalSymbolTableParseTime',
 'totalSymbolTableIndexTime',
+'totalDebugInfoByteSize',
+'totalDebugInfoIndexTime',
+'totalDebugInfoParseTime',
 ]
 self.verify_keys(debug_stats, '"debug_stats"', debug_stat_keys, None)
 stats = debug_stats['targets'][0]
@@ -247,6 +259,9 @@
 'targets',
 'totalSymbolTableParseTime',
 'totalSymbolTableIndexTime',
+'totalDebugInfoParseTime',
+'totalDebugInfoIndexTime',
+'totalDebugInfoByteSize'
 ]
 self.verify_keys(debug_stats, '"debug_stats"', debug_stat_keys, None)
 stats = debug_stats['targets'][0]
@@ -256,6 +271,9 @@
 self.verify_keys(stats, '"stats"', keys_exist, None)
 exe_module = self.find_module_in_metrics(exe, debug_stats)
 module_keys = [
+'debugInfoByteSize',
+'debugInfoIndexTime',
+'debugInfoParseTime',
 'identifier',
 'path',
 'symbolTableIndexTime',
Index: lldb/source/Target/Statistics.cpp
===
--- lldb/source/Target/Statistics.cpp
+++ lldb/source/Target/Statistics.cpp
@@ -50,6 +50,9 @@
   module.try_emplace("identifier", identifier);
   module.try_emplace("symbolTableParseTime", symtab_parse_time);
   module.try_emplace("symbolTableIndexTime", symtab_index_time);
+  module.try_emplace("debugInfoParseTime", debug_parse_time);
+  module.try_emplace("debugInfoIndexTime", debug_index_time);
+  module.try_emplace("debugInfoByteSize", (int64_t)debug_info_size);
   return module;
 }
 
@@ -109,6 +112,9 @@
   json::Array json_modules;
   double symtab_parse_time = 0.0;
   double symtab_index_time = 0.0;
+  double debug_parse_time = 0.0;
+  double debug_index_time = 0.0;
+  uint64_t debug_info_size = 0;
   if (target) {
 json_targets.emplace_back(target->ReportStatistics());
   } else {
@@ -119,18 +125,31 @@
   std::lock_guard guard(
   Module::GetAllocationModuleCollectionMutex());
   const size_t num_modules = Module::GetNumberAllocatedModules();
-  ModuleSP module_sp;
   for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
 Module *module = Module::GetAllocatedModuleAtIndex(image_idx);
 ModuleStats module_stat;
 module_stat.identifier = (intptr_t)module;

[Lldb-commits] [PATCH] D112501: Add new key/value pairs to the module statistics for "statistics dump".

2021-10-25 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

looks good




Comment at: lldb/include/lldb/Symbol/SymbolFile.h:309
+  /// this call should add the size of all sections that contain debug
+  /// information. Symbols the symbol tables are not considered debug
+  /// information for this call to make it easy and quick for this number to be

`Symbols the symbol tables` -> fix that :)



Comment at: 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp:1463-1464
+SymbolFile *symfile = module_sp->GetSymbolFile();
+if (symfile)
+  elapsed += symfile->GetDebugInfoParseTime();
+  }

missing braces


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112501

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


[Lldb-commits] [PATCH] D112439: normalize file path when searching the source map

2021-10-25 Thread Xu Jun via Phabricator via lldb-commits
xujuntwt95329 added a comment.

In D112439#3084948 , @wallace wrote:

> Is it possible to add a test for that? In any case, this makes sense to me



In D112439#3085304 , @clayborg wrote:

> Adding a test would be great for this. Please add one.

Thanks a lot for your comments, I'll add a test and update the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112439

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


[Lldb-commits] [PATCH] D112310: [lldb/DWARF] Don't create lldb_private::Functions for gc'ed DW_TAG_subprograms

2021-10-25 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:866
+  // discontiguous)
+  AddressRange func_range;
+  lldb::addr_t lowest_func_addr = ranges.GetMinRangeBase(0);

You declare `func_range` here but don't use it till the next block, did you 
mean to use it in this block?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112310

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


[Lldb-commits] [lldb] b1bb1d4 - [lldb] Skip tests for target var without a proc on both arm64 & arm64e

2021-10-25 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-10-25T20:45:38-07:00
New Revision: b1bb1d4c46889c4cae2b6586b50c3397584fa064

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

LOG: [lldb] Skip tests for target var without a proc on both arm64 & arm64e

LLDB needs to be taught about chained fixups.



Added: 


Modified: 
lldb/test/API/commands/target/basic/TestTargetCommand.py
lldb/test/API/lang/c/global_variables/TestGlobalVariables.py

Removed: 




diff  --git a/lldb/test/API/commands/target/basic/TestTargetCommand.py 
b/lldb/test/API/commands/target/basic/TestTargetCommand.py
index 8a57b05ebb316..30cb9d7d6c84f 100644
--- a/lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ b/lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -44,8 +44,7 @@ def test_target_command(self):
 self.buildAll()
 self.do_target_command()
 
-@expectedFailureAll(archs=['arm64e']) # 
-@expectedFailureDarwin(archs=["arm64"]) # 
+@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

 def test_target_variable_command(self):
 """Test 'target variable' command before and after starting the 
inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')}
@@ -54,8 +53,7 @@ def test_target_variable_command(self):
 
 self.do_target_variable_command('globals')
 
-@expectedFailureAll(archs=['arm64e']) # 
-@expectedFailureDarwin(archs=["arm64"]) # 
+@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

 def test_target_variable_command_no_fail(self):
 """Test 'target variable' command before and after starting the 
inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')}

diff  --git a/lldb/test/API/lang/c/global_variables/TestGlobalVariables.py 
b/lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
index 8e0591a9602d7..9338c104b7f24 100644
--- a/lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
+++ b/lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
@@ -21,7 +21,7 @@ def setUp(self):
 self.shlib_names = ["a"]
 
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
-@expectedFailureAll(archs=["arm64e"]) # 
+@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

 def test_without_process(self):
 """Test that static initialized variables can be inspected without
 process."""



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