[Lldb-commits] [PATCH] D69931: Add cmake variables to specify a python framework to ship with lldb

2019-11-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In principle, this looks pretty similar to D67942 
, and my opinion on it is the same -- I don't 
think we should be in the business of trying to package the transitive set of 
lldb dependencies. I think the lldb install target should install the stuff 
that it has built itself, and the rest should be up to some higher level 
packaging system.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69931



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


[Lldb-commits] [PATCH] D69904: [arm] Add core definition for armv8l and armv7l

2019-11-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Everything except the `CoreUpdated` part LGTM. The CoreUpdated part could use 
another look from someone more familiar with what exactly that code was trying 
to achieve. And a test... I'd consider breaking that off into a separate patch.




Comment at: lldb/packages/Python/lldbsuite/test/make/Makefile.rules:242
endif
-   ifeq "$(ARCH)" "arm"
+ifeq "$(findstring arm,$(ARCH))" "arm"
override ARCH :=

Whitespace issues? If the file uses spaces/tabs inconsistently, feel free to 
reformat in in a separate NFC patch.


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

https://reviews.llvm.org/D69904



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


[Lldb-commits] [lldb] b1b70f6 - [lldb-server] Add setting to force 'g' packet use

2019-11-07 Thread Pavel Labath via lldb-commits

Author: Guilherme Andrade
Date: 2019-11-07T10:48:54+01:00
New Revision: b1b70f6761266c3eecaf8bd71529eaf51994207b

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

LOG: [lldb-server] Add setting to force 'g' packet use

Following up on https://reviews.llvm.org/D62221, this change introduces
the settings plugin.process.gdb-remote.use-g-packet-for-reading.  When
they are on, 'g' packets are used for reading registers.

Using 'g' packets can improve performance by reducing the number of
packets exchanged between client and server when a large number of
registers needs to be fetched.

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

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteClient.py

lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteClient.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteClient.py
index 3bf0c52edaed..fd13b1f2cd64 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteClient.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteClient.py
@@ -7,6 +7,18 @@
 
 class TestGDBRemoteClient(GDBRemoteTestBase):
 
+class gPacketResponder(MockGDBServerResponder):
+def readRegisters(self):
+return 
''
+
+def setUp(self):
+super(TestGDBRemoteClient, self).setUp()
+self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+def tearDown(self):
+lldb.DBG.SetSelectedPlatform(self._initial_platform)
+super(TestGDBRemoteClient, self).tearDown()
+
 def test_connect(self):
 """Test connecting to a remote gdb server"""
 target = self.createTarget("a.yaml")
@@ -37,3 +49,75 @@ def vAttach(self, pid):
 error = lldb.SBError()
 target.AttachToProcessWithID(lldb.SBListener(), 47, error)
 self.assertEquals(error_msg, error.GetCString())
+
+def test_read_registers_using_g_packets(self):
+"""Test reading registers using 'g' packets (default behavior)"""
+self.server.responder = self.gPacketResponder()
+target = self.createTarget("a.yaml")
+process = self.connect(target)
+
+self.assertEquals(1, self.server.responder.packetLog.count("g"))
+self.server.responder.packetLog = []
+self.read_registers(process)
+# Reading registers should not cause any 'p' packets to be exchanged.
+self.assertEquals(
+0, len([p for p in self.server.responder.packetLog if 
p.startswith("p")]))
+
+def test_read_registers_using_p_packets(self):
+"""Test reading registers using 'p' packets"""
+self.dbg.HandleCommand(
+"settings set 
plugin.process.gdb-remote.use-g-packet-for-reading false")
+target = self.createTarget("a.yaml")
+process = self.connect(target)
+
+self.read_registers(process)
+self.assertFalse("g" in self.server.responder.packetLog)
+self.assertGreater(
+len([p for p in self.server.responder.packetLog if 
p.startswith("p")]), 0)
+
+def test_write_registers_using_P_packets(self):
+"""Test w

[Lldb-commits] [PATCH] D62931: [lldb-server] Add setting to force 'g' packet use

2019-11-07 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb1b70f676126: [lldb-server] Add setting to force 
'g' packet use (authored by guiandrade, committed by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62931

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteClient.py
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
  lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp

Index: lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -301,13 +301,14 @@
 if (process_sp) {
   ProcessGDBRemote *gdb_process =
   static_cast(process_sp.get());
-  // read_all_registers_at_once will be true if 'p' packet is not
-  // supported.
+  bool pSupported =
+  gdb_process->GetGDBRemote().GetpPacketSupported(GetID());
   bool read_all_registers_at_once =
-  !gdb_process->GetGDBRemote().GetpPacketSupported(GetID());
+  !pSupported || gdb_process->m_use_g_packet_for_reading;
+  bool write_all_registers_at_once = !pSupported;
   reg_ctx_sp = std::make_shared(
   *this, concrete_frame_idx, gdb_process->m_register_info,
-  read_all_registers_at_once);
+  read_all_registers_at_once, write_all_registers_at_once);
 }
   } else {
 Unwind *unwinder = GetUnwinder();
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
@@ -13,4 +13,8 @@
 Global,
 DefaultFalse,
 Desc<"If true, the libraries-svr4 feature will be used to get a hold of the process's loaded modules.">;
+  def UseGPacketForReading: Property<"use-g-packet-for-reading", "Boolean">,
+Global,
+DefaultTrue,
+Desc<"Specify if the server should use 'g' packets to read registers.">;
 }
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -284,6 +284,7 @@
   lldb::CommandObjectSP m_command_sp;
   int64_t m_breakpoint_pc_offset;
   lldb::tid_t m_initial_tid; // The initial thread ID, given by stub on attach
+  bool m_use_g_packet_for_reading;
 
   bool m_replay_mode;
   bool m_allow_flash_writes;
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
@@ -154,6 +154,11 @@
 nullptr, idx,
 g_processgdbremote_properties[idx].default_uint_value != 0);
   }
+
+  bool GetUseGPacketForReading() const {
+const uint32_t idx = ePropertyUseGPacketForReading;
+return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, true);
+  }
 };
 
 typedef std::shared_ptr ProcessKDPPropertiesSP;
@@ -309,6 +314,9 @@
   GetGlobalPluginProperties()->GetPacketTimeout();
   if (timeout_seconds > 0)
 m_gdb_comm.SetPacketTimeout(std::chrono::seconds(timeout_seconds));
+
+  m_use_g_packet_for_reading =
+  GetGlobalPluginProperties()->GetUseGPacketForReading();
 }
 
 // Destructor
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
@@ -41,7 +41,7 @@
 public:
   GDBRemoteRegisterContext(ThreadGDBRemote &thread, uint32_t concrete_frame_idx,
GDBRemoteDynamicRegisterInfo ®_info,
-   bool read_all_at_once);
+   bool read_all_at_once, bool write_all_at_once);
 
   ~GDBRemoteRegisterContext() override;
 
@@ -114,6 +114,7 @@
   std::vector m_reg_valid;
   DataExtractor m_reg_data;
   bool m_read_all_at_once;
+  bool m_write_all_at_once;
 
 pr

[Lldb-commits] [PATCH] D69944: [lldb] Add -m option to 'target modules dump symtab' to disable demangling

2019-11-07 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

I'll add a Windows-specific test as a follow-up (because that test will 
probably involve fixing the Windows bot and I don't want this reverted).


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D69944



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


[Lldb-commits] [PATCH] D69944: [lldb] Add -m option to 'target modules dump symtab' to disable demangling

2019-11-07 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: LLDB.
Herald added subscribers: lldb-commits, JDevlieghere, abidh.
Herald added a project: LLDB.
teemperor added a project: Upstreaming LLDB's downstream patches.
teemperor added a comment.

I'll add a Windows-specific test as a follow-up (because that test will 
probably involve fixing the Windows bot and I don't want this reverted).


This option was added downstream in swift-lldb. This upstreams this option as 
it seems useful and also adds the missing tests.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D69944

Files:
  lldb/include/lldb/Symbol/Symbol.h
  lldb/include/lldb/Symbol/Symtab.h
  
lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/Makefile
  
lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/TestDumpSymtabDemangle.py
  
lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/main.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Commands/Options.td
  lldb/source/Symbol/Symbol.cpp
  lldb/source/Symbol/Symtab.cpp

Index: lldb/source/Symbol/Symtab.cpp
===
--- lldb/source/Symbol/Symtab.cpp
+++ lldb/source/Symbol/Symtab.cpp
@@ -70,7 +70,8 @@
   m_file_addr_to_index_computed = false;
 }
 
-void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order) {
+void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order,
+  Mangled::NamePreference name_preference) {
   std::lock_guard guard(m_mutex);
 
   //s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
@@ -97,7 +98,7 @@
   const_iterator end = m_symbols.end();
   for (const_iterator pos = m_symbols.begin(); pos != end; ++pos) {
 s->Indent();
-pos->Dump(s, target, std::distance(begin, pos));
+pos->Dump(s, target, std::distance(begin, pos), name_preference);
   }
 } break;
 
@@ -121,7 +122,8 @@
end = name_map.end();
pos != end; ++pos) {
 s->Indent();
-pos->second->Dump(s, target, pos->second - &m_symbols[0]);
+pos->second->Dump(s, target, pos->second - &m_symbols[0],
+  name_preference);
   }
 } break;
 
@@ -134,7 +136,7 @@
   for (size_t i = 0; i < num_entries; ++i) {
 s->Indent();
 const uint32_t symbol_idx = m_file_addr_to_index.GetEntryRef(i).data;
-m_symbols[symbol_idx].Dump(s, target, symbol_idx);
+m_symbols[symbol_idx].Dump(s, target, symbol_idx, name_preference);
   }
   break;
 }
@@ -143,8 +145,8 @@
   }
 }
 
-void Symtab::Dump(Stream *s, Target *target,
-  std::vector &indexes) const {
+void Symtab::Dump(Stream *s, Target *target, std::vector &indexes,
+  Mangled::NamePreference name_preference) const {
   std::lock_guard guard(m_mutex);
 
   const size_t num_symbols = GetNumSymbols();
@@ -162,7 +164,7 @@
   size_t idx = *pos;
   if (idx < num_symbols) {
 s->Indent();
-m_symbols[idx].Dump(s, target, idx);
+m_symbols[idx].Dump(s, target, idx, name_preference);
   }
 }
   }
Index: lldb/source/Symbol/Symbol.cpp
===
--- lldb/source/Symbol/Symbol.cpp
+++ lldb/source/Symbol/Symbol.cpp
@@ -210,7 +210,8 @@
 s->Printf(", mangled=\"%s\"", m_mangled.GetMangledName().AsCString());
 }
 
-void Symbol::Dump(Stream *s, Target *target, uint32_t index) const {
+void Symbol::Dump(Stream *s, Target *target, uint32_t index,
+  Mangled::NamePreference name_preference) const {
   s->Printf("[%5u] %6u %c%c%c %-15s ", index, GetID(), m_is_debug ? 'D' : ' ',
 m_is_synthetic ? 'S' : ' ', m_is_external ? 'X' : ' ',
 GetTypeAsString());
@@ -218,7 +219,7 @@
   // Make sure the size of the symbol is up to date before dumping
   GetByteSize();
 
-  ConstString name = m_mangled.GetName(GetLanguage());
+  ConstString name = m_mangled.GetName(GetLanguage(), name_preference);
   if (ValueIsAddress()) {
 if (!m_addr_range.GetBaseAddress().Dump(s, nullptr,
 Address::DumpStyleFileAddress))
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -4,6 +4,8 @@
   def tm_sort : Option<"sort", "s">, Group<1>,
 Desc<"Supply a sort order when dumping the symbol table.">,
 EnumArg<"SortOrder", "OptionEnumValues(g_sort_option_enumeration)">;
+  def tm_smn : Option<"show-mangled-names", "m">, Group<1>,
+Desc<"Do not demangle symbol names before showing them.">;
 }
 
 let Command = "help" in {
Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarg

[Lldb-commits] [PATCH] D69944: [lldb] Add -m option to 'target modules dump symtab' to disable demangling

2019-11-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

You could just make a YAML file with some symbols inside. That would isolate 
you from any host mangling specifics (which I think is a good thing, as this 
test is really about the command line option, and not mangling).


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D69944



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


[Lldb-commits] [PATCH] D69944: [lldb] Add -m option to 'target modules dump symtab' to disable demangling

2019-11-07 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk accepted this revision.
kwk added a comment.
This revision is now accepted and ready to land.

LGTM with the exception of a local variable name.




Comment at: lldb/source/Commands/CommandObjectTarget.cpp:2008
 uint32_t num_dumped = 0;
+Mangled::NamePreference preference =
+(m_options.m_prefer_mangled ? Mangled::ePreferMangled

How about calling this variable `name_preference`?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D69944



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


[Lldb-commits] [PATCH] D69944: [lldb] Add -m option to 'target modules dump symtab' to disable demangling

2019-11-07 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added inline comments.



Comment at: lldb/source/Commands/Options.td:8
+  def tm_smn : Option<"show-mangled-names", "m">, Group<1>,
+Desc<"Do not demangle symbol names before showing them.">;
 }

Does it make sense to tell what the default is here?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D69944



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


[Lldb-commits] [PATCH] D68909: change shortcut for 'step out' from 'o' to 'f'

2019-11-07 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

Are there no tests for this code?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68909



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


[Lldb-commits] [PATCH] D69944: [lldb] Add -m option to 'target modules dump symtab' to disable demangling

2019-11-07 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 228229.
teemperor added a comment.

- Renamed variable.
- Now using yaml2obj


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

https://reviews.llvm.org/D69944

Files:
  lldb/include/lldb/Symbol/Symbol.h
  lldb/include/lldb/Symbol/Symtab.h
  
lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/TestDumpSymtabDemangle.py
  
lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/a.yaml
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Commands/Options.td
  lldb/source/Symbol/Symbol.cpp
  lldb/source/Symbol/Symtab.cpp

Index: lldb/source/Symbol/Symtab.cpp
===
--- lldb/source/Symbol/Symtab.cpp
+++ lldb/source/Symbol/Symtab.cpp
@@ -70,7 +70,8 @@
   m_file_addr_to_index_computed = false;
 }
 
-void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order) {
+void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order,
+  Mangled::NamePreference name_preference) {
   std::lock_guard guard(m_mutex);
 
   //s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
@@ -97,7 +98,7 @@
   const_iterator end = m_symbols.end();
   for (const_iterator pos = m_symbols.begin(); pos != end; ++pos) {
 s->Indent();
-pos->Dump(s, target, std::distance(begin, pos));
+pos->Dump(s, target, std::distance(begin, pos), name_preference);
   }
 } break;
 
@@ -121,7 +122,8 @@
end = name_map.end();
pos != end; ++pos) {
 s->Indent();
-pos->second->Dump(s, target, pos->second - &m_symbols[0]);
+pos->second->Dump(s, target, pos->second - &m_symbols[0],
+  name_preference);
   }
 } break;
 
@@ -134,7 +136,7 @@
   for (size_t i = 0; i < num_entries; ++i) {
 s->Indent();
 const uint32_t symbol_idx = m_file_addr_to_index.GetEntryRef(i).data;
-m_symbols[symbol_idx].Dump(s, target, symbol_idx);
+m_symbols[symbol_idx].Dump(s, target, symbol_idx, name_preference);
   }
   break;
 }
@@ -143,8 +145,8 @@
   }
 }
 
-void Symtab::Dump(Stream *s, Target *target,
-  std::vector &indexes) const {
+void Symtab::Dump(Stream *s, Target *target, std::vector &indexes,
+  Mangled::NamePreference name_preference) const {
   std::lock_guard guard(m_mutex);
 
   const size_t num_symbols = GetNumSymbols();
@@ -162,7 +164,7 @@
   size_t idx = *pos;
   if (idx < num_symbols) {
 s->Indent();
-m_symbols[idx].Dump(s, target, idx);
+m_symbols[idx].Dump(s, target, idx, name_preference);
   }
 }
   }
Index: lldb/source/Symbol/Symbol.cpp
===
--- lldb/source/Symbol/Symbol.cpp
+++ lldb/source/Symbol/Symbol.cpp
@@ -210,7 +210,8 @@
 s->Printf(", mangled=\"%s\"", m_mangled.GetMangledName().AsCString());
 }
 
-void Symbol::Dump(Stream *s, Target *target, uint32_t index) const {
+void Symbol::Dump(Stream *s, Target *target, uint32_t index,
+  Mangled::NamePreference name_preference) const {
   s->Printf("[%5u] %6u %c%c%c %-15s ", index, GetID(), m_is_debug ? 'D' : ' ',
 m_is_synthetic ? 'S' : ' ', m_is_external ? 'X' : ' ',
 GetTypeAsString());
@@ -218,7 +219,7 @@
   // Make sure the size of the symbol is up to date before dumping
   GetByteSize();
 
-  ConstString name = m_mangled.GetName(GetLanguage());
+  ConstString name = m_mangled.GetName(GetLanguage(), name_preference);
   if (ValueIsAddress()) {
 if (!m_addr_range.GetBaseAddress().Dump(s, nullptr,
 Address::DumpStyleFileAddress))
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -4,6 +4,8 @@
   def tm_sort : Option<"sort", "s">, Group<1>,
 Desc<"Supply a sort order when dumping the symbol table.">,
 EnumArg<"SortOrder", "OptionEnumValues(g_sort_option_enumeration)">;
+  def tm_smn : Option<"show-mangled-names", "m">, Group<1>,
+Desc<"Do not demangle symbol names before showing them.">;
 }
 
 let Command = "help" in {
Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -1420,12 +1420,13 @@
 }
 
 static void DumpModuleSymtab(CommandInterpreter &interpreter, Stream &strm,
- Module *module, SortOrder sort_order) {
+ Module *module, SortOrder sort_order,
+ Mangled::NamePreference name_preference) {
   if (!module)
 return;
   if (Symtab *symtab = module->GetSymtab())
 symtab->Dump(&strm, interpreter.GetExecutionContext().G

[Lldb-commits] [PATCH] D69944: [lldb] Add -m option to 'target modules dump symtab' to disable demangling

2019-11-07 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.

BTW, is it possible to prune the yaml to remove the stuff irrelevant for the 
test? I'm not that familiar with how macho2yaml works, but the equivalent elf 
representation of this can be as short as:

  --- !ELF
  FileHeader:
Class:   ELFCLASS64
Data:ELFDATA2LSB
Type:ET_REL
Machine: EM_X86_64
  Sections:
- Name:.text
  Type:SHT_PROGBITS
  Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
  AddressAlign:0x0010
  Content: 554889E5897DFC5DC3
  Symbols:
- Name:_ZN3foo3barEi
  Type:STT_FUNC
  Section: .text
  Size:0x0009
  ...


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

https://reviews.llvm.org/D69944



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


[Lldb-commits] [PATCH] D69944: [lldb] Add -m option to 'target modules dump symtab' to disable demangling

2019-11-07 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor requested review of this revision.
teemperor marked an inline comment as done.
teemperor added inline comments.



Comment at: lldb/source/Commands/Options.td:8
+  def tm_smn : Option<"show-mangled-names", "m">, Group<1>,
+Desc<"Do not demangle symbol names before showing them.">;
 }

kwk wrote:
> Does it make sense to tell what the default is here?
It seems to me this is implied because this option is only offering to turn it 
off.


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

https://reviews.llvm.org/D69944



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


[Lldb-commits] [PATCH] D69944: [lldb] Add -m option to 'target modules dump symtab' to disable demangling

2019-11-07 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 228235.
teemperor added a comment.

- Blatantly steal Pavel's yaml file as MachO seems very verbose.


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

https://reviews.llvm.org/D69944

Files:
  lldb/include/lldb/Symbol/Symbol.h
  lldb/include/lldb/Symbol/Symtab.h
  
lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/TestDumpSymtabDemangle.py
  
lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/a.yaml
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Commands/Options.td
  lldb/source/Symbol/Symbol.cpp
  lldb/source/Symbol/Symtab.cpp

Index: lldb/source/Symbol/Symtab.cpp
===
--- lldb/source/Symbol/Symtab.cpp
+++ lldb/source/Symbol/Symtab.cpp
@@ -70,7 +70,8 @@
   m_file_addr_to_index_computed = false;
 }
 
-void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order) {
+void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order,
+  Mangled::NamePreference name_preference) {
   std::lock_guard guard(m_mutex);
 
   //s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
@@ -97,7 +98,7 @@
   const_iterator end = m_symbols.end();
   for (const_iterator pos = m_symbols.begin(); pos != end; ++pos) {
 s->Indent();
-pos->Dump(s, target, std::distance(begin, pos));
+pos->Dump(s, target, std::distance(begin, pos), name_preference);
   }
 } break;
 
@@ -121,7 +122,8 @@
end = name_map.end();
pos != end; ++pos) {
 s->Indent();
-pos->second->Dump(s, target, pos->second - &m_symbols[0]);
+pos->second->Dump(s, target, pos->second - &m_symbols[0],
+  name_preference);
   }
 } break;
 
@@ -134,7 +136,7 @@
   for (size_t i = 0; i < num_entries; ++i) {
 s->Indent();
 const uint32_t symbol_idx = m_file_addr_to_index.GetEntryRef(i).data;
-m_symbols[symbol_idx].Dump(s, target, symbol_idx);
+m_symbols[symbol_idx].Dump(s, target, symbol_idx, name_preference);
   }
   break;
 }
@@ -143,8 +145,8 @@
   }
 }
 
-void Symtab::Dump(Stream *s, Target *target,
-  std::vector &indexes) const {
+void Symtab::Dump(Stream *s, Target *target, std::vector &indexes,
+  Mangled::NamePreference name_preference) const {
   std::lock_guard guard(m_mutex);
 
   const size_t num_symbols = GetNumSymbols();
@@ -162,7 +164,7 @@
   size_t idx = *pos;
   if (idx < num_symbols) {
 s->Indent();
-m_symbols[idx].Dump(s, target, idx);
+m_symbols[idx].Dump(s, target, idx, name_preference);
   }
 }
   }
Index: lldb/source/Symbol/Symbol.cpp
===
--- lldb/source/Symbol/Symbol.cpp
+++ lldb/source/Symbol/Symbol.cpp
@@ -210,7 +210,8 @@
 s->Printf(", mangled=\"%s\"", m_mangled.GetMangledName().AsCString());
 }
 
-void Symbol::Dump(Stream *s, Target *target, uint32_t index) const {
+void Symbol::Dump(Stream *s, Target *target, uint32_t index,
+  Mangled::NamePreference name_preference) const {
   s->Printf("[%5u] %6u %c%c%c %-15s ", index, GetID(), m_is_debug ? 'D' : ' ',
 m_is_synthetic ? 'S' : ' ', m_is_external ? 'X' : ' ',
 GetTypeAsString());
@@ -218,7 +219,7 @@
   // Make sure the size of the symbol is up to date before dumping
   GetByteSize();
 
-  ConstString name = m_mangled.GetName(GetLanguage());
+  ConstString name = m_mangled.GetName(GetLanguage(), name_preference);
   if (ValueIsAddress()) {
 if (!m_addr_range.GetBaseAddress().Dump(s, nullptr,
 Address::DumpStyleFileAddress))
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -4,6 +4,8 @@
   def tm_sort : Option<"sort", "s">, Group<1>,
 Desc<"Supply a sort order when dumping the symbol table.">,
 EnumArg<"SortOrder", "OptionEnumValues(g_sort_option_enumeration)">;
+  def tm_smn : Option<"show-mangled-names", "m">, Group<1>,
+Desc<"Do not demangle symbol names before showing them.">;
 }
 
 let Command = "help" in {
Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -1420,12 +1420,13 @@
 }
 
 static void DumpModuleSymtab(CommandInterpreter &interpreter, Stream &strm,
- Module *module, SortOrder sort_order) {
+ Module *module, SortOrder sort_order,
+ Mangled::NamePreference name_preference) {
   if (!module)
 return;
   if (Symtab *symtab = module->GetSymtab())
 symtab->Dump(&strm, interpreter

[Lldb-commits] [lldb] 87bc320 - [lldb] Add -m option to 'target modules dump symtab' to disable demangling

2019-11-07 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-07T15:47:01+01:00
New Revision: 87bc320b510e91a1a71aa8a154c585db65579628

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

LOG: [lldb] Add -m option to 'target modules dump symtab' to disable demangling

Summary: This option was added downstream in swift-lldb. This upstreams this 
option as it seems useful and also adds the missing tests.

Reviewers: #lldb, kwk, labath

Reviewed By: kwk, labath

Subscribers: labath, kwk, abidh, JDevlieghere, lldb-commits

Tags: #lldb, #upstreaming_lldb_s_downstream_patches

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

Added: 

lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/TestDumpSymtabDemangle.py

lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/a.yaml

Modified: 
lldb/include/lldb/Symbol/Symbol.h
lldb/include/lldb/Symbol/Symtab.h
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Commands/Options.td
lldb/source/Symbol/Symbol.cpp
lldb/source/Symbol/Symtab.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Symbol.h 
b/lldb/include/lldb/Symbol/Symbol.h
index b7f179d1449b..36f89c044ea9 100644
--- a/lldb/include/lldb/Symbol/Symbol.h
+++ b/lldb/include/lldb/Symbol/Symbol.h
@@ -43,7 +43,9 @@ class Symbol : public SymbolContextScope {
 
   bool Compare(ConstString name, lldb::SymbolType type) const;
 
-  void Dump(Stream *s, Target *target, uint32_t index) const;
+  void Dump(Stream *s, Target *target, uint32_t index,
+Mangled::NamePreference name_preference =
+Mangled::ePreferDemangled) const;
 
   bool ValueIsAddress() const;
 

diff  --git a/lldb/include/lldb/Symbol/Symtab.h 
b/lldb/include/lldb/Symbol/Symtab.h
index 99d15771ccc5..e42261ef11da 100644
--- a/lldb/include/lldb/Symbol/Symtab.h
+++ b/lldb/include/lldb/Symbol/Symtab.h
@@ -40,8 +40,12 @@ class Symtab {
   uint32_t AddSymbol(const Symbol &symbol);
   size_t GetNumSymbols() const;
   void SectionFileAddressesChanged();
-  void Dump(Stream *s, Target *target, SortOrder sort_type);
-  void Dump(Stream *s, Target *target, std::vector &indexes) const;
+  void
+  Dump(Stream *s, Target *target, SortOrder sort_type,
+   Mangled::NamePreference name_preference = Mangled::ePreferDemangled);
+  void Dump(Stream *s, Target *target, std::vector &indexes,
+Mangled::NamePreference name_preference =
+Mangled::ePreferDemangled) const;
   uint32_t GetIndexForSymbol(const Symbol *symbol) const;
   std::recursive_mutex &GetMutex() { return m_mutex; }
   Symbol *FindSymbolByID(lldb::user_id_t uid) const;

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/TestDumpSymtabDemangle.py
 
b/lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/TestDumpSymtabDemangle.py
new file mode 100644
index ..9f95a11f3875
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/TestDumpSymtabDemangle.py
@@ -0,0 +1,30 @@
+"""
+Test 'target modules dump symtab -m' doesn't demangle symbols.
+"""
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@no_debug_info_test
+def test(self):
+src_dir = self.getSourceDir()
+yaml_path = os.path.join(src_dir, "a.yaml")
+yaml_base, ext = os.path.splitext(yaml_path)
+obj_path = self.getBuildArtifact("main.o")
+self.yaml2obj(yaml_path, obj_path)
+
+# Create a target with the object file we just created from YAML
+target = self.dbg.CreateTarget(obj_path)
+self.assertTrue(target, VALID_TARGET)
+
+# First test that we demangle by default and our mangled symbol isn't 
in the output.
+self.expect("target modules dump symtab", substrs=["foo::bar(int)"])
+self.expect("target modules dump symtab", matching=False, 
substrs=["_ZN3foo3barEi"])
+
+# Turn off demangling and make sure that we now see the mangled name 
in the output.
+self.expect("target modules dump symtab -m", substrs=["_ZN3foo3barEi"])

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/a.yaml
 
b/lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/a.yaml
new file mode 100644
index ..ed591d7c1c19
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/a.yaml
@@ -0,0 +1,18 @@
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_X86_64
+Sections:
+  - Name:.text
+Type:SHT_PRO

[Lldb-commits] [PATCH] D69944: [lldb] Add -m option to 'target modules dump symtab' to disable demangling

2019-11-07 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG87bc320b510e: [lldb] Add -m option to 'target modules 
dump symtab' to disable demangling (authored by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69944

Files:
  lldb/include/lldb/Symbol/Symbol.h
  lldb/include/lldb/Symbol/Symtab.h
  
lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/TestDumpSymtabDemangle.py
  
lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/a.yaml
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Commands/Options.td
  lldb/source/Symbol/Symbol.cpp
  lldb/source/Symbol/Symtab.cpp

Index: lldb/source/Symbol/Symtab.cpp
===
--- lldb/source/Symbol/Symtab.cpp
+++ lldb/source/Symbol/Symtab.cpp
@@ -70,7 +70,8 @@
   m_file_addr_to_index_computed = false;
 }
 
-void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order) {
+void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order,
+  Mangled::NamePreference name_preference) {
   std::lock_guard guard(m_mutex);
 
   //s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
@@ -97,7 +98,7 @@
   const_iterator end = m_symbols.end();
   for (const_iterator pos = m_symbols.begin(); pos != end; ++pos) {
 s->Indent();
-pos->Dump(s, target, std::distance(begin, pos));
+pos->Dump(s, target, std::distance(begin, pos), name_preference);
   }
 } break;
 
@@ -121,7 +122,8 @@
end = name_map.end();
pos != end; ++pos) {
 s->Indent();
-pos->second->Dump(s, target, pos->second - &m_symbols[0]);
+pos->second->Dump(s, target, pos->second - &m_symbols[0],
+  name_preference);
   }
 } break;
 
@@ -134,7 +136,7 @@
   for (size_t i = 0; i < num_entries; ++i) {
 s->Indent();
 const uint32_t symbol_idx = m_file_addr_to_index.GetEntryRef(i).data;
-m_symbols[symbol_idx].Dump(s, target, symbol_idx);
+m_symbols[symbol_idx].Dump(s, target, symbol_idx, name_preference);
   }
   break;
 }
@@ -143,8 +145,8 @@
   }
 }
 
-void Symtab::Dump(Stream *s, Target *target,
-  std::vector &indexes) const {
+void Symtab::Dump(Stream *s, Target *target, std::vector &indexes,
+  Mangled::NamePreference name_preference) const {
   std::lock_guard guard(m_mutex);
 
   const size_t num_symbols = GetNumSymbols();
@@ -162,7 +164,7 @@
   size_t idx = *pos;
   if (idx < num_symbols) {
 s->Indent();
-m_symbols[idx].Dump(s, target, idx);
+m_symbols[idx].Dump(s, target, idx, name_preference);
   }
 }
   }
Index: lldb/source/Symbol/Symbol.cpp
===
--- lldb/source/Symbol/Symbol.cpp
+++ lldb/source/Symbol/Symbol.cpp
@@ -210,7 +210,8 @@
 s->Printf(", mangled=\"%s\"", m_mangled.GetMangledName().AsCString());
 }
 
-void Symbol::Dump(Stream *s, Target *target, uint32_t index) const {
+void Symbol::Dump(Stream *s, Target *target, uint32_t index,
+  Mangled::NamePreference name_preference) const {
   s->Printf("[%5u] %6u %c%c%c %-15s ", index, GetID(), m_is_debug ? 'D' : ' ',
 m_is_synthetic ? 'S' : ' ', m_is_external ? 'X' : ' ',
 GetTypeAsString());
@@ -218,7 +219,7 @@
   // Make sure the size of the symbol is up to date before dumping
   GetByteSize();
 
-  ConstString name = m_mangled.GetName(GetLanguage());
+  ConstString name = m_mangled.GetName(GetLanguage(), name_preference);
   if (ValueIsAddress()) {
 if (!m_addr_range.GetBaseAddress().Dump(s, nullptr,
 Address::DumpStyleFileAddress))
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -4,6 +4,8 @@
   def tm_sort : Option<"sort", "s">, Group<1>,
 Desc<"Supply a sort order when dumping the symbol table.">,
 EnumArg<"SortOrder", "OptionEnumValues(g_sort_option_enumeration)">;
+  def tm_smn : Option<"show-mangled-names", "m">, Group<1>,
+Desc<"Do not demangle symbol names before showing them.">;
 }
 
 let Command = "help" in {
Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -1420,12 +1420,13 @@
 }
 
 static void DumpModuleSymtab(CommandInterpreter &interpreter, Stream &strm,
- Module *module, SortOrder sort_order) {
+ Module *module, SortOrder sort_order,
+ Mangled::NamePreference name_preference) {
   if

[Lldb-commits] [PATCH] D68909: change shortcut for 'step out' from 'o' to 'f'

2019-11-07 Thread Luboš Luňák via Phabricator via lldb-commits
llunak added a comment.

In D68909#1736931 , @kwk wrote:

> Are there no tests for this code?


https://reviews.llvm.org/D68541 adds one that also covers this.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68909



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


[Lldb-commits] [lldb] 44f4346 - [lldb] Comment typo fix

2019-11-07 Thread Jan Kratochvil via lldb-commits

Author: Jan Kratochvil
Date: 2019-11-07T17:48:25+01:00
New Revision: 44f43461c018e7fdc3b1cf3a7a41f52b1cb20a39

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

LOG: [lldb] Comment typo fix

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
index 6501ac27f27d..348b33464a54 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
@@ -63,7 +63,7 @@ class DWARFDeclContext {
 
   const char *GetQualifiedName() const;
 
-  // Same as GetQaulifiedName, but the life time of the returned string will
+  // Same as GetQualifiedName, but the life time of the returned string will
   // be that of the LLDB session.
   lldb_private::ConstString GetQualifiedNameAsConstString() const {
 return lldb_private::ConstString(GetQualifiedName());



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


[Lldb-commits] [lldb] ff9d732 - crashlog.py: Improve regular expressions

2019-11-07 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2019-11-07T10:52:06-08:00
New Revision: ff9d732887385e6f3e516769419dd64b406d81d8

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

LOG: crashlog.py: Improve regular expressions

This is yet another change to the regular expressions in crashlog.py
that fix a few edge cases, and attempt to improve the readability
quite a bit in the process. My last change to support spaces in
filenames introduced a bug that caused the version/archspec field to
be parsed as part of the image name.

For example, in "0x111 - 0x2 +MyApp Pro arm64 <01234>", the
name of the image was recognized as "MyApp Pro arm64" instead of
"MyApp Pro" with a "version" of arm64.

The bugfix makes the space following an optional field mandatory
*inside* the optional group.

rdar://problem/56883435

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

Added: 


Modified: 
lldb/examples/python/crashlog.py
lldb/test/Shell/Python/crashlog.test

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index 9a8ec8c1a43f..b7b62acc60ef 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -101,10 +101,22 @@ class CrashLog(symbolication.Symbolicator):
 thread_regex = re.compile('^Thread ([0-9]+)([^:]*):(.*)')
 app_backtrace_regex = re.compile(
 '^Application Specific Backtrace ([0-9]+)([^:]*):(.*)')
-frame_regex = 
re.compile('^([0-9]+)\s+(.+?)\s+(0x[0-9a-fA-F]{7}[0-9a-fA-F]+) +(.*)')
-null_frame_regex = re.compile('^([0-9]+)\s+\?\?\?\s+(0{7}0+) +(.*)')
-image_regex_uuid = re.compile(
-
'(0x[0-9a-fA-F]+)[-\s]+(0x[0-9a-fA-F]+)\s+[+]?(.+?)\s+(\(.+\))?\s?(<([-0-9a-fA-F]+)>)?
 (.*)')
+version = r'(\(.+\)|(arm|x86_)[0-9a-z]+)\s+'
+frame_regex = re.compile(r'^([0-9]+)' r'\s'# id
+ r'+(.+?)'r'\s+'   # img_name
+ r'(' +version+ r')?'  # img_version
+ r'(0x[0-9a-fA-F]{7}[0-9a-fA-F]+)' # addr
+ r' +(.*)' # offs
+)
+null_frame_regex = re.compile(r'^([0-9]+)\s+\?\?\?\s+(0{7}0+) +(.*)')
+image_regex_uuid = re.compile(r'(0x[0-9a-fA-F]+)'# img_lo
+  r'\s+' '-' r'\s+'  #   -
+  r'(0x[0-9a-fA-F]+)' r'\s+' # img_hi
+  r'[+]?(.+?)'r'\s+' # img_name
+  r'(' +version+ ')?'# img_version
+  r'(<([-0-9a-fA-F]+)>\s+)?' # img_uuid
+  r'(/.*)'   # img_path
+ )
 empty_line_regex = re.compile('^$')
 
 class Thread:
@@ -489,18 +501,20 @@ def __init__(self, path, verbose):
 continue
 frame_match = self.frame_regex.search(line)
 if frame_match:
-ident = frame_match.group(2)
+(frame_id, frame_img_name, _, frame_img_version, _,
+ frame_addr, frame_ofs) = frame_match.groups()
+ident = frame_img_name
 thread.add_ident(ident)
 if ident not in self.idents:
 self.idents.append(ident)
-
thread.frames.append(CrashLog.Frame(int(frame_match.group(1)), int(
-frame_match.group(3), 0), frame_match.group(4)))
+thread.frames.append(CrashLog.Frame(int(frame_id), int(
+frame_addr, 0), frame_ofs))
 else:
 print('error: frame regex failed for line: "%s"' % line)
 elif parse_mode == PARSE_MODE_IMAGES:
 image_match = self.image_regex_uuid.search(line)
 if image_match:
-(img_lo, img_hi, img_name, img_version,
+(img_lo, img_hi, img_name, _, img_version, _,
  _, img_uuid, img_path) = image_match.groups()
 image = CrashLog.DarwinImage(int(img_lo, 0), int(img_hi, 
0),
  img_name.strip(),

diff  --git a/lldb/test/Shell/Python/crashlog.test 
b/lldb/test/Shell/Python/crashlog.test
index 24d72eae41fa..37e0e8c5740d 100644
--- a/lldb/test/Shell/Python/crashlog.test
+++ b/lldb/test/Shell/Python/crashlog.test
@@ -1,5 +1,6 @@
 # -*- python 
-*-
 # REQUIRES: system-darwin
+# DEBUG: cd %S/../../../examples/python && cat %s | %lldb && false
 # RUN: cd %S/../../../examples/python

[Lldb-commits] [PATCH] D69871: crashlog.py: Improve regular expressions

2019-11-07 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGff9d73288738: crashlog.py: Improve regular expressions 
(authored by aprantl).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D69871?vs=228141&id=228278#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69871

Files:
  lldb/examples/python/crashlog.py
  lldb/test/Shell/Python/crashlog.test

Index: lldb/test/Shell/Python/crashlog.test
===
--- lldb/test/Shell/Python/crashlog.test
+++ lldb/test/Shell/Python/crashlog.test
@@ -1,5 +1,6 @@
 # -*- python -*-
 # REQUIRES: system-darwin
+# DEBUG: cd %S/../../../examples/python && cat %s | %lldb && false
 # RUN: cd %S/../../../examples/python && cat %s | %lldb | FileCheck %s
 # CHECK-LABEL: {{S}}KIP BEYOND CHECKS
 script
@@ -32,8 +33,8 @@
 "0x111 - 0x2 +MyApp Pro arm64  <01234> /tmp/MyApp Pro.app/MyApp Pro",
 # CHECK: 0x111
 # CHECK: 0x2
-# CHECK: MyApp Pro arm64
-# CHECK: None
+# CHECK: MyApp Pro
+# CHECK: arm64
 # CHECK: 01234
 # CHECK: /tmp/MyApp Pro.app/MyApp Pro
 
@@ -45,13 +46,45 @@
 # CHECK: 01234
 # CHECK: /tmp/MyApp Pro.app/MyApp Pro
 
-"0x7fff63f2 - 0x7fff63f77ff7  libc++.1.dylib (400.9.4) /usr/lib/libc++.1.dylib"
+"0x111 - 0x222 MyFramework Plus.dylib (1.11 - MyFramework 1.11) <01234> /tmp/MyFramework Plus.dylib",
+# CHECK: 0x111
+# CHECK: 0x222
+# CHECK: MyFramework Plus.dylib
+# CHECK: ({{.*}}
+# CHECK: 1.11 - MyFramework 1.11
+# CHECK: <{{.*}}
+# CHECK: 01234
+# CHECK: /tmp/MyFramework Plus.dylib
+
+"0x111 - 0x222 MyFramework-dev.dylib (1.0.0svn - 1.0.0svn) <01234> /MyFramework-dev.dylib",
+# CHECK: 0x111
+# CHECK: 0x222
+# CHECK: MyFramework-dev.dylib
+# CHECK: ({{.*}}
+# CHECK: 1.0.0svn - 1.0.0svn
+# CHECK: <{{.*}}
+# CHECK: 01234
+# CHECK: /MyFramework-dev.dylib
+
+"0x7fff63f2 - 0x7fff63f77ff7  libc++.1.dylib (400.9.4) /usr/lib/libc++.1.dylib",
 # CHECK: 0x7fff63f2
 # CHECK: 0x7fff63f77ff7
 # CHECK: libc++.1.dylib
-# CHECK: (400.9.4)
+# CHECK: ({{.*}}
+# CHECK: 400.9.4
+# CHECK: None
 # CHECK: None
 # CHECK: /usr/lib/libc++.1.dylib
+
+"0x1047b8000 - 0x10481 dyld arm64e   /usr/lib/dyld"
+# CHECK: 0x1047b8000
+# CHECK: 0x10481
+# CHECK: dyld
+# CHECK: {{.*}}
+# CHECK: arm64e
+# CHECK: <{{.*}}
+# CHECK: cfa789d10da63f9a8996daf84ed9d04f
+# CHECK: /usr/lib/dyld
 ]
 # CHECK-LABEL: FRAMES
 frames = [
@@ -67,7 +100,10 @@
 # CHECK: lldb_private{{.*}} + 105
 "2   MyApp Pro arm64	0x00019b0db3a8 foo + 72",
 # CHECK: 2
-# CHECK: MyApp Pro arm64
+# CHECK: MyApp Pro
+# CHECK: a
+# CHECK: arm64
+# CHECK: a
 # CHECK: 0x00019b0db3a8
 # CHECK: foo + 72
 "3   He 0x1	0x00019b0db3a8 foo + 72"
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -101,10 +101,22 @@
 thread_regex = re.compile('^Thread ([0-9]+)([^:]*):(.*)')
 app_backtrace_regex = re.compile(
 '^Application Specific Backtrace ([0-9]+)([^:]*):(.*)')
-frame_regex = re.compile('^([0-9]+)\s+(.+?)\s+(0x[0-9a-fA-F]{7}[0-9a-fA-F]+) +(.*)')
-null_frame_regex = re.compile('^([0-9]+)\s+\?\?\?\s+(0{7}0+) +(.*)')
-image_regex_uuid = re.compile(
-'(0x[0-9a-fA-F]+)[-\s]+(0x[0-9a-fA-F]+)\s+[+]?(.+?)\s+(\(.+\))?\s?(<([-0-9a-fA-F]+)>)? (.*)')
+version = r'(\(.+\)|(arm|x86_)[0-9a-z]+)\s+'
+frame_regex = re.compile(r'^([0-9]+)' r'\s'# id
+ r'+(.+?)'r'\s+'   # img_name
+ r'(' +version+ r')?'  # img_version
+ r'(0x[0-9a-fA-F]{7}[0-9a-fA-F]+)' # addr
+ r' +(.*)' # offs
+)
+null_frame_regex = re.compile(r'^([0-9]+)\s+\?\?\?\s+(0{7}0+) +(.*)')
+image_regex_uuid = re.compile(r'(0x[0-9a-fA-F]+)'# img_lo
+  r'\s+' '-' r'\s+'  #   -
+  r'(0x[0-9a-fA-F]+)' r'\s+' # img_hi
+  r'[+]?(.+?)'r'\s+' # img_name
+  r'(' +version+ ')?'# img_version
+  r'(<([-0-9a-fA-F]+)>\s+)?' # img_uuid
+  r'(/.*)'   # img_path
+ )
 empty_line_regex = re.compile('^$')
 
 class Thread:
@@ -489,18 +501,20 @@
 continue
 frame_match = self.frame_regex.search(line)
 if frame_match:
-ident = frame_match.g

[Lldb-commits] [lldb] c62a9f1 - [lldb] Improve assert in GDBRemoteCommunicationReplayServer

2019-11-07 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2019-11-07T12:43:59-08:00
New Revision: c62a9f180c26e2fed012531caa581f0d736bfed9

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

LOG: [lldb] Improve assert in GDBRemoteCommunicationReplayServer

While investigating an issue where a different packet was sent during
replay I noticed how annoying it is that the existing assert doesn't
specify what packet is actually different. It's printed to the log, but
enabling logging has the potential to change LLDB's behavior. The same
is true when debugging LLDB while it's replaying the reproducer.

I replaced the assert with a printf of the unexpected packet followed by
a fatal_error wrapped in ifndef NDEBUG. The behavior is the same as the
previous assert, just with more/better context.

Added: 


Modified: 

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
index 2d26c550dc76..3a01df0fc82a 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
@@ -143,7 +143,14 @@ 
GDBRemoteCommunicationReplayServer::GetPacketAndSendResponse(
  entry.packet.data);
 LLDB_LOG(log, "GDBRemoteCommunicationReplayServer actual packet: 
'{0}'",
  packet.GetStringRef());
-assert(false && "Encountered unexpected packet during replay");
+#ifndef NDEBUG
+// This behaves like a regular assert, but prints the expected and
+// received packet before aborting.
+printf("Reproducer expected packet: '%s'\n", 
entry.packet.data.c_str());
+printf("Reproducer received packet: '%s'\n",
+   packet.GetStringRef().data());
+llvm::report_fatal_error("Encountered unexpected packet during 
replay");
+#endif
 return PacketResult::ErrorSendFailed;
   }
 



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


[Lldb-commits] [lldb] f1539b9 - BreakpointDummyOptionGroup was using g_breakpoint_modify_options rather than g_breakpoint_dummy_options

2019-11-07 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2019-11-07T14:25:04-08:00
New Revision: f1539b9db39a59a5e50c065c39e491ba4f890377

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

LOG: BreakpointDummyOptionGroup was using g_breakpoint_modify_options rather 
than g_breakpoint_dummy_options
causing the -D option for breakpoint set command to be incorrectly parsed.

Patch by Martin Svensson.

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

Added: 
lldb/test/Shell/Breakpoint/Inputs/dummy-target.c
lldb/test/Shell/Breakpoint/dummy-target.test

Modified: 
lldb/source/Commands/CommandObjectBreakpoint.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp 
b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index 5d0cc3d9dcea..380f753ea339 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -180,7 +180,7 @@ class BreakpointDummyOptionGroup : public OptionGroup {
 ExecutionContext *execution_context) override {
 Status error;
 const int short_option =
-g_breakpoint_modify_options[option_idx].short_option;
+g_breakpoint_dummy_options[option_idx].short_option;
 
 switch (short_option) {
 case 'D':

diff  --git a/lldb/test/Shell/Breakpoint/Inputs/dummy-target.c 
b/lldb/test/Shell/Breakpoint/Inputs/dummy-target.c
new file mode 100644
index ..76e8197013aa
--- /dev/null
+++ b/lldb/test/Shell/Breakpoint/Inputs/dummy-target.c
@@ -0,0 +1 @@
+int main() { return 0; }

diff  --git a/lldb/test/Shell/Breakpoint/dummy-target.test 
b/lldb/test/Shell/Breakpoint/dummy-target.test
new file mode 100644
index ..873a4d3adc00
--- /dev/null
+++ b/lldb/test/Shell/Breakpoint/dummy-target.test
@@ -0,0 +1,23 @@
+# RUN: mkdir -p %t
+# RUN: cd %t
+# RUN: %build %p/Inputs/dummy-target.c -o dummy.out
+# RUN: %lldb -b -s %s dummy.out | FileCheck %s
+
+breakpoint set -D -n main
+# CHECK: Breakpoint {{[0-9]}}: no locations (pending).
+# CHECK: Breakpoint set in dummy target
+
+breakpoint list
+# CHECK: No breakpoints currently set
+
+breakpoint list -D
+# CHECK: name = 'main', locations = 0 (pending)
+
+target delete
+# CHECK: 1 targets deleted
+
+target create dummy.out
+# CHECK: Current executable set to {{.*}}dummy.out
+
+breakpoint list
+# CHECK: name = 'main', locations = {{[1-9]}}



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


[Lldb-commits] [PATCH] D69425: [lldb] Fix broken -D option for breakpoint set command

2019-11-07 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

In D69425#1731155 , @poya wrote:

> No commit access, so would need some assistance getting this change into the 
> repo.


I pushed this (f1539b9db39a59a5e50c065c39e491ba4f890377 
).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69425



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


[Lldb-commits] [PATCH] D69425: [lldb] Fix broken -D option for breakpoint set command

2019-11-07 Thread Jim Ingham via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf1539b9db39a: BreakpointDummyOptionGroup was using 
g_breakpoint_modify_options rather than… (authored by jingham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69425

Files:
  lldb/source/Commands/CommandObjectBreakpoint.cpp
  lldb/test/Shell/Breakpoint/Inputs/dummy-target.c
  lldb/test/Shell/Breakpoint/dummy-target.test


Index: lldb/test/Shell/Breakpoint/dummy-target.test
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/dummy-target.test
@@ -0,0 +1,23 @@
+# RUN: mkdir -p %t
+# RUN: cd %t
+# RUN: %build %p/Inputs/dummy-target.c -o dummy.out
+# RUN: %lldb -b -s %s dummy.out | FileCheck %s
+
+breakpoint set -D -n main
+# CHECK: Breakpoint {{[0-9]}}: no locations (pending).
+# CHECK: Breakpoint set in dummy target
+
+breakpoint list
+# CHECK: No breakpoints currently set
+
+breakpoint list -D
+# CHECK: name = 'main', locations = 0 (pending)
+
+target delete
+# CHECK: 1 targets deleted
+
+target create dummy.out
+# CHECK: Current executable set to {{.*}}dummy.out
+
+breakpoint list
+# CHECK: name = 'main', locations = {{[1-9]}}
Index: lldb/test/Shell/Breakpoint/Inputs/dummy-target.c
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/Inputs/dummy-target.c
@@ -0,0 +1 @@
+int main() { return 0; }
Index: lldb/source/Commands/CommandObjectBreakpoint.cpp
===
--- lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -180,7 +180,7 @@
 ExecutionContext *execution_context) override {
 Status error;
 const int short_option =
-g_breakpoint_modify_options[option_idx].short_option;
+g_breakpoint_dummy_options[option_idx].short_option;
 
 switch (short_option) {
 case 'D':


Index: lldb/test/Shell/Breakpoint/dummy-target.test
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/dummy-target.test
@@ -0,0 +1,23 @@
+# RUN: mkdir -p %t
+# RUN: cd %t
+# RUN: %build %p/Inputs/dummy-target.c -o dummy.out
+# RUN: %lldb -b -s %s dummy.out | FileCheck %s
+
+breakpoint set -D -n main
+# CHECK: Breakpoint {{[0-9]}}: no locations (pending).
+# CHECK: Breakpoint set in dummy target
+
+breakpoint list
+# CHECK: No breakpoints currently set
+
+breakpoint list -D
+# CHECK: name = 'main', locations = 0 (pending)
+
+target delete
+# CHECK: 1 targets deleted
+
+target create dummy.out
+# CHECK: Current executable set to {{.*}}dummy.out
+
+breakpoint list
+# CHECK: name = 'main', locations = {{[1-9]}}
Index: lldb/test/Shell/Breakpoint/Inputs/dummy-target.c
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/Inputs/dummy-target.c
@@ -0,0 +1 @@
+int main() { return 0; }
Index: lldb/source/Commands/CommandObjectBreakpoint.cpp
===
--- lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -180,7 +180,7 @@
 ExecutionContext *execution_context) override {
 Status error;
 const int short_option =
-g_breakpoint_modify_options[option_idx].short_option;
+g_breakpoint_dummy_options[option_idx].short_option;
 
 switch (short_option) {
 case 'D':
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] cbdd92b - Modernize TestWeakSymbols Makefile

2019-11-07 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2019-11-07T14:53:52-08:00
New Revision: cbdd92be8a57e204aeb346c02ec6c4f440499679

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

LOG: Modernize TestWeakSymbols Makefile

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/commands/expression/weak_symbols/Makefile

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/expression/weak_symbols/Makefile 
b/lldb/packages/Python/lldbsuite/test/commands/expression/weak_symbols/Makefile
index c8b38907ac92..6fd8133312ad 100644
--- 
a/lldb/packages/Python/lldbsuite/test/commands/expression/weak_symbols/Makefile
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/expression/weak_symbols/Makefile
@@ -1,25 +1,20 @@
-CFLAGS_EXTRAS := -std=c99
-LD_FLAGS := -dynamiclib
-include Makefile.rules
-
-all: a.out dylib missing
+C_SOURCES := main.c
+CFLAGS_EXTRAS := -std=c99 -fmodules
+LD_EXTRAS := -ldylib -L.
 
-dylib: dylib.o
-   $(CC)  $(LD_FLAGS) -o libdylib.dylib dylib.o
-
-missing: dylib2.o
-   mkdir hidden
-   $(CC)  $(LD_FLAGS) -o hidden/libdylib.dylib dylib2.o
+all: a.out hidden/libdylib.dylib
 
-a.out: main.o dylib missing
-   $(CC)  $(CFLAGS) -L. -ldylib main.o
+a.out: libdylib.dylib
 
-dylib.o: dylib.h $(SRCDIR)/dylib.c
-   $(CC) -DHAS_THEM  $(CFLAGS) -c $(SRCDIR)/dylib.c
-
-dylib2.o: dylib.h $(SRCDIR)/dylib.c
-   $(CC)  $(CFLAGS) -c $(SRCDIR)/dylib.c -o dylib2.o
+include Makefile.rules
 
-main.o: dylib.h $(SRCDIR)/main.c
-   $(CC)  $(CFLAGS) -c $(SRCDIR)/main.c -fmodules 
-fmodules-cache-path=$(CLANG_MODULE_CACHE_DIR)
+libdylib.dylib: dylib.c
+   $(MAKE) -C $(BUILDDIR) -f $(MAKEFILE_RULES) \
+   C_SOURCES= DYLIB_C_SOURCES=dylib.c DYLIB_NAME=dylib \
+   CFLAGS_EXTRAS=-DHAS_THEM LD_EXTRAS=-dynamiclib
 
+hidden/libdylib.dylib:
+   mkdir hidden
+   $(MAKE) -C $(BUILDDIR)/hidden -f $(MAKEFILE_RULES) \
+   C_SOURCES= DYLIB_C_SOURCES=dylib.c DYLIB_NAME=dylib \
+   LD_EXTRAS=-dynamiclib



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


[Lldb-commits] [PATCH] D69931: Add cmake variables to specify a python framework to ship with lldb

2019-11-07 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

In D69931#1736607 , @labath wrote:

> In principle, this looks pretty similar to D67942 
> , and my opinion on it is the same -- I 
> don't think we should be in the business of trying to package the transitive 
> set of lldb dependencies. I think the lldb install target should install the 
> stuff that it has built itself, and the rest should be up to some higher 
> level packaging system.


+1 it will never end if we go down this way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69931



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


Re: [Lldb-commits] [lldb] 0877dd1 - [Driver] Force llvm to install its handlers before lldb's

2019-11-07 Thread via lldb-commits
Hey JF, Pavel,

We're still seeing crashes due to SIGPIPE on some lldb bots. This workaround in 
the lldb driver is insufficient, because liblldb.dylib may install its own a 
fresh set of llvm signal handlers (the `NumRegisteredSignals` global is not 
shared by all images loaded in a process). Here is a trace that illustrates the 
issue: https://gist.github.com/vedantk/2d0cc1df9bea9f0fa74ee101d240b82c.

I think we should fix this by changing llvm's default behavior: let's have it 
ignore SIGPIPE. Driver programs (like clang, dwarfdump, etc.) can then opt-in 
to exiting when SIGPIPE is received. Wdyt?

Some alternatives include:

- Add a static initializer to liblldb.dylib that copies the workaround in the 
driver. This should work fine, but it's a duct tape on top of a bandaid.
- Have the dynamic linker coalesce all copies of `NumRegisteredSignals` in a 
process. This would incur an app launch time hit on iOS (where libllvm is hot 
code), and it doesn't seem very portable.

vedant


> On Oct 25, 2019, at 11:19 AM, Vedant Kumar via lldb-commits 
>  wrote:
> 
> 
> Author: Vedant Kumar
> Date: 2019-10-25T11:19:10-07:00
> New Revision: 0877dd14e4e85550f8e267b5ceeff1d3409c41ba
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/0877dd14e4e85550f8e267b5ceeff1d3409c41ba
> DIFF: 
> https://github.com/llvm/llvm-project/commit/0877dd14e4e85550f8e267b5ceeff1d3409c41ba.diff
> 
> LOG: [Driver] Force llvm to install its handlers before lldb's
> 
> Install llvm's signal handlers up front to prevent lldb's handlers from being
> ignored. This is (hopefully) a stopgap workaround.
> 
> When lldb invokes an llvm API that installs signal handlers (e.g.
> llvm::sys::RemoveFileOnSignal, possibly via a compiler embedded within lldb),
> lldb's signal handlers are overriden if llvm is installing its handlers for 
> the
> first time.
> 
> To work around llvm's behavior, force it to install its handlers up front, and
> *then* install lldb's handlers. In practice this is used to prevent lldb test
> processes from exiting due to IO_ERR when SIGPIPE is received.
> 
> Note that when llvm installs its handlers, it 1) records the old handlers it
> replaces and 2) re-installs the old handlers when its new handler is invoked.
> That means that a signal not explicitly handled by lldb can fall back to being
> handled by llvm's handler the first time it is received, and then by the
> default handler the second time it is received.
> 
> Differential Revision: https://reviews.llvm.org/D69403
> 
> Added: 
> 
> 
> Modified: 
>lldb/tools/driver/Driver.cpp
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
> index 4a403a7ffb46..8140e2a04c6e 100644
> --- a/lldb/tools/driver/Driver.cpp
> +++ b/lldb/tools/driver/Driver.cpp
> @@ -845,6 +845,25 @@ int main(int argc, char const *argv[])
>   }
>   SBHostOS::ThreadCreated("");
> 
> +  // Install llvm's signal handlers up front to prevent lldb's handlers from
> +  // being ignored. This is (hopefully) a stopgap workaround.
> +  //
> +  // When lldb invokes an llvm API that installs signal handlers (e.g.
> +  // llvm::sys::RemoveFileOnSignal, possibly via a compiler embedded within
> +  // lldb), lldb's signal handlers are overriden if llvm is installing its
> +  // handlers for the first time.
> +  //
> +  // To work around llvm's behavior, force it to install its handlers up 
> front,
> +  // and *then* install lldb's handlers. In practice this is used to prevent
> +  // lldb test processes from exiting due to IO_ERR when SIGPIPE is received.
> +  //
> +  // Note that when llvm installs its handlers, it 1) records the old 
> handlers
> +  // it replaces and 2) re-installs the old handlers when its new handler is
> +  // invoked. That means that a signal not explicitly handled by lldb can 
> fall
> +  // back to being handled by llvm's handler the first time it is received,
> +  // and then by the default handler the second time it is received.
> +  llvm::sys::AddSignalHandler([](void *) -> void {}, nullptr);
> +
>   signal(SIGINT, sigint_handler);
> #if !defined(_MSC_VER)
>   signal(SIGPIPE, SIG_IGN);
> 
> 
> 
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

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


[Lldb-commits] [PATCH] D69931: Add cmake variables to specify a python framework to ship with lldb

2019-11-07 Thread Shoaib Meenai via Phabricator via lldb-commits
smeenai added a comment.

I agree on not getting into the business of installing Python ourselves, but 
there's also the rpath issue. The Windows case is different because you just 
put all your DLLs in the same directory (or some other directory in your PATH) 
and you're done. With macOS, you have to specify an rpath for liblldb to be 
able to find the Python framework. It'd be really nice to support adding 
additional rpaths in the build system itself (it could be a more generic 
mechanism; it doesn't have to be Python-specific). CMake does offer 
`CMAKE_INSTALL_RPATH`, but that applies to every single target. You could also 
use install_name_tool after building to modify the rpath, but that feels like a 
kludge.

How would people feel about a patch that just adds the ability to set 
additional rpaths on liblldb?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69931



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


[Lldb-commits] [lldb] 6602e1f - Reordering KextImageInfo::LoadImageUsingMemoryModule

2019-11-07 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2019-11-07T19:34:09-08:00
New Revision: 6602e1fb0e34c1a755ef561de24e5b78a460672a

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

LOG: Reordering KextImageInfo::LoadImageUsingMemoryModule
so we only call ModulesDidLoad at the end of the method
after the new module has been added to the target and
the sections have all been adjusted to their actual
load addresses.  Solves a problem where an operating
system plugin in the kernel could be loaded multiple
times; the first before the binary had even been
added to the target.



Added: 


Modified: 

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp 
b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index 0c212735be7c..6019a1cc7602 100644
--- 
a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ 
b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -791,18 +791,14 @@ bool 
DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
   module_spec.GetArchitecture() = target.GetArchitecture();
 
   // For the kernel, we really do need an on-disk file copy of the binary
-  // to do anything useful. This will force a clal to
+  // to do anything useful. This will force a call to dsymForUUID if it
+  // exists, instead of depending on the DebugSymbols preferences being 
+  // set.
   if (IsKernel()) {
 if (Symbols::DownloadObjectAndSymbolFile(module_spec, true)) {
   if (FileSystem::Instance().Exists(module_spec.GetFileSpec())) {
 m_module_sp = std::make_shared(module_spec.GetFileSpec(),
target.GetArchitecture());
-if (m_module_sp.get() &&
-m_module_sp->MatchesModuleSpec(module_spec)) {
-  ModuleList loaded_module_list;
-  loaded_module_list.Append(m_module_sp);
-  target.ModulesDidLoad(loaded_module_list);
-}
   }
 }
   }
@@ -810,6 +806,8 @@ bool 
DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
   // If the current platform is PlatformDarwinKernel, create a ModuleSpec
   // with the filename set to be the bundle ID for this kext, e.g.
   // "com.apple.filesystems.msdosfs", and ask the platform to find it.
+  // PlatformDarwinKernel does a special scan for kexts on the local
+  // system.
   PlatformSP platform_sp(target.GetPlatform());
   if (!m_module_sp && platform_sp) {
 ConstString platform_name(platform_sp->GetPluginName());
@@ -818,7 +816,7 @@ bool 
DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
 if (platform_name == g_platform_name) {
   ModuleSpec kext_bundle_module_spec(module_spec);
   FileSpec kext_filespec(m_name.c_str());
- FileSpecList search_paths = target.GetExecutableSearchPaths();
+  FileSpecList search_paths = target.GetExecutableSearchPaths();
   kext_bundle_module_spec.GetFileSpec() = kext_filespec;
   platform_sp->GetSharedModule(kext_bundle_module_spec, process,
m_module_sp, &search_paths, nullptr,
@@ -847,7 +845,7 @@ bool 
DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
 // UUIDs
 if (m_module_sp) {
   if (m_uuid.IsValid() && m_module_sp->GetUUID() == m_uuid) {
-target.GetImages().AppendIfNeeded(m_module_sp);
+target.GetImages().AppendIfNeeded(m_module_sp, false);
 if (IsKernel() &&
 target.GetExecutableModulePointer() != m_module_sp.get()) {
   target.SetExecutableModule(m_module_sp, eLoadDependentsNo);
@@ -945,6 +943,14 @@ bool 
DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
 s.Flush();
   }
 
+  // Notify the target about the module being added;
+  // set breakpoints, load dSYM scripts, etc. as needed.
+  if (is_loaded && m_module_sp) {
+ModuleList loaded_module_list;
+loaded_module_list.Append(m_module_sp);
+target.ModulesDidLoad(loaded_module_list);
+  }
+
   return is_loaded;
 }
 



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