[Lldb-commits] [PATCH] D72909: Make SymbolFileDWARF::ParseLineTable use std::sort instead of insertion sort

2020-01-21 Thread George Rimar via Phabricator via lldb-commits
grimar added inline comments.



Comment at: lldb/source/Symbol/LineTable.cpp:27
+  LineTable::Entry::LessThanBinaryPredicate less_than_bp(this);
+  std::sort(sequences.begin(), sequences.end(), less_than_bp);
+  for (auto *sequence : sequences) {

I wonder if this have to be `std::stable_sort`?
For `std::sort` the order of equal elements is not guaranteed to be preserved.

nit: you could also probably use the `llvm::sort` (it would be a bit shorter):
`llvm::sort(sequences, less_than_bp);`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72909



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


[Lldb-commits] [PATCH] D69933: [ASTImporter] Limit imports of structs

2020-01-21 Thread Jaroslav Sevcik via Phabricator via lldb-commits
jarin updated this revision to Diff 239235.
jarin added a comment.
Herald added a subscriber: lldb-commits.

I changed the diff so that it does not touch Clang's AST importer, instead it 
patches LLDB's wrapper of the AST importer.

The idea is to only import complete a record if the current evaluation asked 
for them to be completed. In particular, if the current evaluation has not ask 
for a record R to be completed and LLDB is being asked to import R, we supply 
an incomplete version of R even if we happen to have a complete definition of R 
lying around in parsed debug info.

This is achieved in a hacky way - if we have a complete record R, we pretend it 
is incomplete by temporarily clearing R's isCompleteDefinition bit. 
Interestingly, this hack is already used in 
ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69933

Files:
  lldb/include/lldb/Symbol/ClangASTImporter.h
  lldb/source/Symbol/ClangASTImporter.cpp


Index: lldb/source/Symbol/ClangASTImporter.cpp
===
--- lldb/source/Symbol/ClangASTImporter.cpp
+++ lldb/source/Symbol/ClangASTImporter.cpp
@@ -42,9 +42,12 @@
   if (!delegate_sp)
 return CompilerType();
 
+  delegate_sp->SetCompleted(src_qual_type->getAsTagDecl());
+
   ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp, &dst_clang_ast);
 
   llvm::Expected ret_or_error = delegate_sp->Import(src_qual_type);
+
   if (!ret_or_error) {
 Log *log =
   lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
@@ -252,6 +255,7 @@
   if (auto *tag_decl = dyn_cast(decl)) {
 if (auto *original_tag_decl = dyn_cast(original_decl)) {
   if (original_tag_decl->isCompleteDefinition()) {
+m_delegate->SetCompleted(original_tag_decl);
 m_delegate->ImportDefinitionTo(tag_decl, original_tag_decl);
 tag_decl->setCompleteDefinition(true);
   }
@@ -584,6 +588,8 @@
   ImporterDelegateSP delegate_sp(
   GetDelegate(&decl->getASTContext(), decl_origin.ctx));
 
+  delegate_sp->SetCompleted(decl_origin.decl);
+
   ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp,
 &decl->getASTContext());
   if (delegate_sp)
@@ -855,6 +861,10 @@
 
 ClangASTImporter::MapCompleter::~MapCompleter() { return; }
 
+void ClangASTImporter::ASTImporterDelegate::SetCompleted(Decl *from) {
+  m_completed_decls.insert(from);
+}
+
 llvm::Expected
 ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl *From) {
   if (m_std_handler) {
@@ -903,7 +913,20 @@
 }
   }
 
-  return ASTImporter::ImportImpl(From);
+  CXXRecordDecl *record_decl_to_set_complete = nullptr;
+  if (CXXRecordDecl *record_decl = dyn_cast(From)) {
+if (record_decl->isCompleteDefinition() &&
+!record_decl->isAnonymousStructOrUnion() &&
+m_completed_decls.find(From) == m_completed_decls.end()) {
+  record_decl->setCompleteDefinition(false);
+  record_decl_to_set_complete = record_decl;
+}
+  }
+  llvm::Expected result = ASTImporter::ImportImpl(From);
+  if (record_decl_to_set_complete) {
+record_decl_to_set_complete->setCompleteDefinition(true);
+  }
+  return result;
 }
 
 void ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(
Index: lldb/include/lldb/Symbol/ClangASTImporter.h
===
--- lldb/include/lldb/Symbol/ClangASTImporter.h
+++ lldb/include/lldb/Symbol/ClangASTImporter.h
@@ -231,6 +231,8 @@
 
 clang::Decl *GetOriginalDecl(clang::Decl *To) override;
 
+void SetCompleted(clang::Decl *from);
+
 void SetImportListener(NewDeclListener *listener) {
   assert(m_new_decl_listener == nullptr && "Already attached a listener?");
   m_new_decl_listener = listener;
@@ -246,6 +248,7 @@
 /// were created from the 'std' C++ module to prevent that the Importer
 /// tries to sync them with the broken equivalent in the debug info AST.
 llvm::SmallPtrSet m_decls_to_ignore;
+llvm::SmallPtrSet m_completed_decls;
 ClangASTImporter &m_master;
 clang::ASTContext *m_source_ctx;
 CxxModuleHandler *m_std_handler = nullptr;
@@ -257,6 +260,7 @@
   typedef llvm::DenseMap DelegateMap;
   typedef llvm::DenseMap
   NamespaceMetaMap;
+  typedef std::set CompletedRecordSet;
 
   struct ASTContextMetadata {
 ASTContextMetadata(clang::ASTContext *dst_ctx)


Index: lldb/source/Symbol/ClangASTImporter.cpp
===
--- lldb/source/Symbol/ClangASTImporter.cpp
+++ lldb/source/Symbol/ClangASTImporter.cpp
@@ -42,9 +42,12 @@
   if (!delegate_sp)
 return CompilerType();
 
+  delegate_sp->SetCompleted(src_qual_type->getAsTagDecl());
+
   ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp, &dst_clang_ast);
 
   llvm::Expected ret_or_er

[Lldb-commits] [PATCH] D72748: [lldb/IOHandler] Change the way we manage IO handler

2020-01-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D72748#1829956 , @JDevlieghere 
wrote:

> In D72748#1823945 , @labath wrote:
>
> > I didn't actually try it but I am pretty sure this will deadlock with 
> > nested lldb command files (running `command source` from a file that is 
> > itself being sourced). Changing the mutex to a recursive_mutex would fix 
> > that, but I don't believe it would make this fully correct -- it would just 
> > make it harder to demonstrate that it's wrong. OTOH, that may be the best 
> > thing we can do in the current state of affairs.
> >
> > The thing I don't understand now is why do we even need this stack in the 
> > first place. It seems like this could be handled by just running a new 
> > iohandler "main loop" instead of pushing something. Take the "expr" command 
> > for example. In the single-line mode it evaluates the expression 
> > synchronously, but in a multi-line expression, it returns immediately after 
> > pushing it's own IOHandler (which then gathers the expression and calls 
> > back into the command to run it). I don't see why we couldn't achieve the 
> > same thing by "running" the iohandler directly, instead of pushing it to 
> > some stack and waiting for it to be executed at the top level. The same 
> > thing could be said for the "script" command and various other things which 
> > "hijack" the main (lldb) iohandler.
>
>
> Isn't the problem that you can't be sure your IO handler pushes another one 
> on top of the stack? I considered an alternative implementation, where the 
> synchronous IO handlers has its own stack and everything that's pushed while 
> it is executing ends up on that stack. It adds a lot of complexity and you 
> still need to synchronize with the "main loop"


Well.. in the way I as imagining things, there would be no stacks (at least no 
explicit stacks), no pushing, and everything would execute in the "synchronous" 
mode. So e.g., when we start up the main "(lldb)" loop, we just take that 
iohandler, and run it until it says it's done. If the user types "script", then 
we start another "main loop" with the python iohandler, but the main loop can 
be completely oblivious to that -- as far as it is concerned, its iohandler is 
still executing `CommandObjectScript::DoExecute`. When the user exits the 
python prompt the control returns to the (lldb) iohandler just like it would 
after any other "simple" command. So, essentially, there's still some stacking 
involved, but it's not managed explicitly -- it just comes out from the way the 
code is organized. Similarly, the "breakpoint command add" could run an 
iohandler to collect the breakpoint commands, "process continue" could run a 
loop to forward the inferior stdio, etc.

(The last bit is tricky because of ^C, and it means that we will still need to 
have some global notion of the "active" or "top" iohandler, which is the one 
that receives ^Cs, but still, I think that it should be possible to run 
everything "synchronously" and I hope that would get us rid of a lot of 
complexity.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72748



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


[Lldb-commits] [PATCH] D73016: [lldb/CMake] Make it possible to disable plugins at configuration time

2020-01-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D73016#1830303 , @JDevlieghere 
wrote:

> - I'm aware of the linker issue when you reconfigure. I've spent quite some 
> time investigating this and this seems related to the way libraries to link 
> are cached by CMake. I verified that we're no longer passing the disabled 
> library to target_link_libraries and yet the linker error remains. It looks 
> like this might be fix starting with CMake 3.12 
> (https://cmake.org/cmake/help/git-stage/policy/CMP0073.html).


Interesting. This looks like something that we could hac^H^H^Hwork around even 
with cmake<=3.12 by force-setting the appropriate variable to "". If we cared 
enough about this, that is...


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D73016



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


[Lldb-commits] [PATCH] D72909: Make SymbolFileDWARF::ParseLineTable use std::sort instead of insertion sort

2020-01-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added inline comments.



Comment at: lldb/source/Symbol/LineTable.cpp:27
+  LineTable::Entry::LessThanBinaryPredicate less_than_bp(this);
+  std::sort(sequences.begin(), sequences.end(), less_than_bp);
+  for (auto *sequence : sequences) {

grimar wrote:
> I wonder if this have to be `std::stable_sort`?
> For `std::sort` the order of equal elements is not guaranteed to be preserved.
> 
> nit: you could also probably use the `llvm::sort` (it would be a bit shorter):
> `llvm::sort(sequences, less_than_bp);`
I think we should change this to llvm::sort just because of the additional 
checks we get there (I think the shuffle/sort<->stable_sort checks are only in 
llvm::sort).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72909



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


[Lldb-commits] [PATCH] D73018: [lldb] Add SystemInitializerAllPlugins and delete copy-pasted Init code in SystemInitializerFull and SystemInitializerTest

2020-01-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 239251.
teemperor added a comment.

- Removed all the duplicated linking flags too.


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

https://reviews.llvm.org/D73018

Files:
  lldb/include/lldb/Initialization/SystemInitializerAllPlugins.h
  lldb/source/API/CMakeLists.txt
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/API/SystemInitializerFull.h
  lldb/source/CMakeLists.txt
  lldb/source/Initialization/AllPlugins/CMakeLists.txt
  lldb/source/Initialization/AllPlugins/SystemInitializerAllPlugins.cpp
  lldb/source/Initialization/CMakeLists.txt
  lldb/source/Initialization/Common/CMakeLists.txt
  lldb/source/Initialization/Common/SystemInitializer.cpp
  lldb/source/Initialization/Common/SystemInitializerCommon.cpp
  lldb/source/Initialization/Common/SystemLifetimeManager.cpp
  lldb/source/Initialization/SystemInitializer.cpp
  lldb/source/Initialization/SystemInitializerCommon.cpp
  lldb/source/Initialization/SystemLifetimeManager.cpp
  lldb/tools/lldb-test/CMakeLists.txt
  lldb/tools/lldb-test/SystemInitializerTest.cpp
  lldb/tools/lldb-test/SystemInitializerTest.h

Index: lldb/tools/lldb-test/SystemInitializerTest.h
===
--- lldb/tools/lldb-test/SystemInitializerTest.h
+++ lldb/tools/lldb-test/SystemInitializerTest.h
@@ -9,7 +9,7 @@
 #ifndef LLDB_API_SYSTEM_INITIALIZER_TEST_H
 #define LLDB_API_SYSTEM_INITIALIZER_TEST_H
 
-#include "lldb/Initialization/SystemInitializerCommon.h"
+#include "lldb/Initialization/SystemInitializerAllPlugins.h"
 
 namespace lldb_private {
 /// Initializes lldb.
@@ -18,7 +18,7 @@
 /// services needed to use the full LLDB application.  This class is
 /// not intended to be used externally, but is instead used
 /// internally by SBDebugger to initialize the system.
-class SystemInitializerTest : public SystemInitializerCommon {
+class SystemInitializerTest : public SystemInitializerAllPlugins {
 public:
   SystemInitializerTest();
   ~SystemInitializerTest() override;
Index: lldb/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -1,4 +1,4 @@
-//===-- SystemInitializerTest.cpp ---*- C++ -*-===//
+//===-- SystemInitializerAllPlugins.cpp ---===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -10,265 +10,20 @@
 
 #include "lldb/Core/Debugger.h"
 #include "lldb/Host/Host.h"
-#include "lldb/Initialization/SystemInitializerCommon.h"
+#include "lldb/Initialization/SystemInitializerAllPlugins.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Utility/Timer.h"
 
-#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
-#include "Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h"
-#include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h"
-#include "Plugins/ABI/SysV-arc/ABISysV_arc.h"
-#include "Plugins/ABI/SysV-arm/ABISysV_arm.h"
-#include "Plugins/ABI/SysV-arm64/ABISysV_arm64.h"
-#include "Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h"
-#include "Plugins/ABI/SysV-i386/ABISysV_i386.h"
-#include "Plugins/ABI/SysV-mips/ABISysV_mips.h"
-#include "Plugins/ABI/SysV-mips64/ABISysV_mips64.h"
-#include "Plugins/ABI/SysV-ppc/ABISysV_ppc.h"
-#include "Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h"
-#include "Plugins/ABI/SysV-s390x/ABISysV_s390x.h"
-#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
-#include "Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h"
-#include "Plugins/Architecture/Arm/ArchitectureArm.h"
-#include "Plugins/Architecture/Mips/ArchitectureMips.h"
-#include "Plugins/Architecture/PPC64/ArchitecturePPC64.h"
-#include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h"
-#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h"
-#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
-#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
-#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
-#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
-#include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
-#include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
-#include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h"
-#include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
-#include "Plugins/Instruction/PPC64/EmulateInstructionPPC64.h"
-#include "Plugins/InstrumentationRuntime/ASan/ASanRuntime.h"
-#include "Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h"
-#include "Plugins/InstrumentationRuntime/TSan/TSanRuntime.h"
-#include "Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h"
-#include "Plugins/JITLoader/GDB/JITLoaderGDB.h"
-#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
-#include "Pl

[Lldb-commits] [PATCH] D73018: [lldb] Add SystemInitializerAllPlugins and delete copy-pasted Init code in SystemInitializerFull and SystemInitializerTest

2020-01-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor marked an inline comment as done.
teemperor added a comment.

I moved the single non-plugin call back to the original Full/Test subclasses so 
the name is now correct. Also I removed all the duplicated linking flags that I 
forgot to remove before.

I also don't think we should make this a header. With a header we still need to 
copy the linking flags around and it also deviates from the existing approach 
of using subclasses like SystemInitializerCommon (which anyway looks nicer).


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

https://reviews.llvm.org/D73018



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


[Lldb-commits] [PATCH] D73067: [lldb/CMake] Auto-generate the Initialize and Terminate calls for plugins (WIP)

2020-01-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Overall, I like this, but I have a lot of comments:

- I actually very much like the plugin namespace idea -- it makes it harder to 
use plugin code from non-plugin code, and allows plugins of the same category 
(e.g. ProcessLinux and ProcessNetBSD) to define similar concepts without fear 
of name clashes. I do see how that gets in the way of auto-generation though, 
so putting the initialization endpoints into a more predictable place seems 
like a good compromise. I wouldn't put the entire main class into the 
lldb_private namespace  though, as that is also something that should not be 
accessed by generic code. Ideally, I'd just take the `Initialize` and 
`Terminate` (TBH, I don't think we really need the terminate function, but that 
may be more refactoring than you're ready for right now), and put it into a 
completely separate, predictibly-named file (`void 
lldb_private::InitializeProcessLinux()` in 
`Plugins/Process/Linux/Initialization.h` ?). That way the "main" file could be 
free to include anything it wants, without fear of polluting the namespace of 
anything, and we could get rid of the ScriptInterpreterPythonImpl thingy.
- it would be nice to auto-generate the `#include` directives too. Including 
everything and then not using it sort of works, but it does not feel right. It 
should be fairly easy to generate an additional .def file with just the 
includes...
- The way you disable ScriptInterpreterPython/Lua plugins is pretty hacky. 
Maybe the .def file should offer a way to exclude entire plugin classes?

  #ifdef LLDB_WANT_SCRIPT_INTERPRETERS
  ScriptInterpreterPython::Initialize(); // or whatever
  #endif

- some of the things you initialize are definitely not plugins (e.g. 
`Plugins/Process/Utilty`, `Plugins/Language/ClangCommon`).  I think that things 
which don't need to register their entry points anywhere should not need to 
have the Initialize/Terminate goo... Can we avoid that, perhaps by making the 
"plugin" special at the cmake level. Since this code is used only by other 
plugins, it makes sense to have it somewhere under `Plugins/`, but it is not 
really a plugin, it does not need to register anything, and we do not need to 
be able to explicitly disable it (as it will get enabled/disabled automatically 
when used by the other plugins).
- Having this as one bit patch is fine for now, but once we agree on the 
general idea, it should be split off into smaller patches, as some of the 
changes are not completely trivial (like the bunching of the macos platform 
plugins for instance)

In D73067#1830408 , @JDevlieghere 
wrote:

> In D73067#1830304 , @compnerd wrote:
>
> > Do we need to worry about ordering of the plugins?
>
>
> Yes, it appears to matter... I'm still seeing test failures which I need to 
> debug. I'm not sure yet if they're because of missing initializers (that 
> don't have a corresponding CMake plugin) or because of the ordering.


Order of plugins within a kind should not matter, but it's possible it does. 
Some of the entry points may need to be changed so that they are less grabby. 
I'm not sure if order of plugin kinds matters right now, but I don't think it 
would be wrong if it did (e.g. have symbol files depend on object files). 
However, it looks like this approach already supports that...


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D73067



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


[Lldb-commits] [PATCH] D73018: [lldb] Add SystemInitializerAllPlugins and delete copy-pasted Init code in SystemInitializerFull and SystemInitializerTest

2020-01-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D73018#1830697 , @teemperor wrote:

> I moved the single non-plugin call back to the original Full/Test subclasses 
> so the name is now correct. Also I removed all the duplicated linking flags 
> that I forgot to remove before.


This still leaves the question of the script interpreter plugins, which are 
suspiciously *not* included in "all plugins". The script interpreters are quite 
special, so I think it's fine to handle them separately -- the question is just 
how to convey that distinction. Move them into a different top level folder? 
Call this `SystemInitializerMostPlugins` ?

However, an even bigger question is what is the relationship of this patch and 
D73067 ? Right now, they seem to be taking the 
plugin system in two different directions, so I don't think it makes sense to 
accept either one before we decide what that direction is...




Comment at: lldb/source/API/SystemInitializerFull.h:21
 /// internally by SBDebugger to initialize the system.
-class SystemInitializerFull : public SystemInitializerCommon {
+class SystemInitializerFull : public SystemInitializerAllPlugins {
 public:

Maybe call this SystemInitializerAPI, or SystemInitializer(Lib)LLDB.. Having 
both "Full" and "AllPlugins" is confusing...


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

https://reviews.llvm.org/D73018



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


[Lldb-commits] [PATCH] D73018: [lldb] Add SystemInitializerAllPlugins and delete copy-pasted Init code in SystemInitializerFull and SystemInitializerTest

2020-01-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

> This still leaves the question of the script interpreter plugins, which are 
> suspiciously *not* included in "all plugins". The script interpreters are 
> quite special, so I think it's fine to handle them separately -- the question 
> is just how to convey that distinction. Move them into a different top level 
> folder? Call this `SystemInitializerMostPlugins` ?

Yeah, those 'plugins' aren't actually standalone plugins but require the SWIG 
wrapper code to link (and the SWIG wrapper code is compiled in the API/ 
folder). We can fix this by moving the SWIG code into the AllPlugins folder 
(which would either be done in this commit or as a follow-up).

> However, an even bigger question is what is the relationship of this patch 
> and D73067 ? Right now, they seem to be 
> taking the plugin system in two different directions, so I don't think it 
> makes sense to accept either one before we decide what that direction is...

D73067  is more focused on making the list of 
plugins to init/terminate depend on the CMake configuration, but even with 
D73067  we still need to copy around the 
linking flags, include the def file and the other boilerplate. I don't think we 
should deduplicate identical code with macros (especially since the 
SystemInitializers already took the approach of making subclasses). So this 
patch solves the code duplication, D73067  
solves the fact that the plugin itself is not dependent on the actual plugin 
list.


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

https://reviews.llvm.org/D73018



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


[Lldb-commits] [PATCH] D68961: Add support for DW_AT_export_symbols for anonymous structs

2020-01-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: 
lldb/test/Shell/SymbolFile/DWARF/clang-ast-from-dwarf-unamed-and-anon-structs.cpp:1
+// Test to verify we are corectly generating anonymous flags when parsing
+// anonymous class and unnamed structs from DWARF to the a clang AST node.

I am seeing this test fail sporadically (mostly depending on the build config). 
This happens because the test output is nondeterministic (sometimes the 
"anonymous" structs are printed in different order. I think this is down to 
SymbolFileDWARF::GetTypes using pointer values (through `TypeSet = 
std::set`) in its operation...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68961



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


[Lldb-commits] [lldb] 1f7b95d - [lldb][NFC] Convert LLDB_LOGF to LLDB_LOG in ClangASTSource.cpp

2020-01-21 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-01-21T13:44:22+01:00
New Revision: 1f7b95d038e687fdaffdff55d32c16934f7bff60

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

LOG: [lldb][NFC] Convert LLDB_LOGF to LLDB_LOG in ClangASTSource.cpp

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 42927ab6cc8a..fed0e6e47a6b 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -200,11 +200,11 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
   unsigned int current_id = invocation_id++;
 
   if (log) {
-LLDB_LOGF(log,
-  "CompleteTagDecl[%u] on (ASTContext*)%p Completing "
-  "(TagDecl*)%p named %s",
-  current_id, static_cast(m_ast_context),
-  static_cast(tag_decl), 
tag_decl->getName().str().c_str());
+LLDB_LOG(log,
+ "CompleteTagDecl[{0}] on (ASTContext*){1} Completing "
+ "(TagDecl*){2} named {3}",
+ current_id, static_cast(m_ast_context),
+ static_cast(tag_decl), tag_decl->getName());
 
 LLDB_LOG(log, "  CTD[%u] Before:\n{0}", current_id,
  ClangUtil::DumpDecl(tag_decl));
@@ -224,10 +224,10 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
 // We couldn't complete the type.  Maybe there's a definition somewhere
 // else that can be completed.
 
-LLDB_LOGF(log,
-  "  CTD[%u] Type could not be completed in the module in "
-  "which it was first found.",
-  current_id);
+LLDB_LOG(log,
+ "  CTD[{0}] Type could not be completed in the module in "
+ "which it was first found.",
+ current_id);
 
 bool found = false;
 
@@ -239,9 +239,9 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
   m_ast_importer_sp->GetNamespaceMap(namespace_context);
 
   if (log && log->GetVerbose())
-LLDB_LOGF(log, "  CTD[%u] Inspecting namespace map %p (%d 
entries)",
-  current_id, static_cast(namespace_map.get()),
-  static_cast(namespace_map->size()));
+LLDB_LOG(log,
+ "  CTD[{0}] Inspecting namespace map{1} ({2} entries)",
+ current_id, namespace_map.get(), namespace_map->size());
 
   if (!namespace_map)
 return;
@@ -249,9 +249,9 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
   for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(),
 e = namespace_map->end();
i != e && !found; ++i) {
-LLDB_LOGF(log, "  CTD[%u] Searching namespace %s in module %s",
-  current_id, i->second.GetName().AsCString(),
-  i->first->GetFileSpec().GetFilename().GetCString());
+LLDB_LOG(log, "  CTD[{0}] Searching namespace {1} in module {2}",
+ current_id, i->second.GetName(),
+ i->first->GetFileSpec().GetFilename());
 
 TypeList types;
 
@@ -335,11 +335,10 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
 void ClangASTSource::CompleteType(clang::ObjCInterfaceDecl *interface_decl) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
 
-  LLDB_LOGF(log,
-"[CompleteObjCInterfaceDecl] on (ASTContext*)%p Completing "
-"an ObjCInterfaceDecl named %s",
-static_cast(m_ast_context),
-interface_decl->getName().str().c_str());
+  LLDB_LOG(log,
+   "[CompleteObjCInterfaceDecl] on (ASTContext*){0} Completing "
+   "an ObjCInterfaceDecl named {1}",
+   m_ast_context, interface_decl->getName());
   LLDB_LOG(log, "  [COID] Before:\n{0}",
ClangUtil::DumpDecl(interface_decl));
 
@@ -369,7 +368,7 @@ void ClangASTSource::CompleteType(clang::ObjCInterfaceDecl 
*interface_decl) {
 CompleteType(interface_decl->getSuperClass());
 
   if (log) {
-LLDB_LOGF(log, "  [COID] After:");
+LLDB_LOG(log, "  [COID] After:");
 LLDB_LOG(log, "  [COID] {0}", ClangUtil::DumpDecl(interface_decl));
   }
 }
@@ -441,23 +440,24 @@ void ClangASTSource::FindExternalLexicalDecls(
 
   if (log) {
 if (const NamedDecl *context_named_decl = 
dyn_cast(context_decl))
-  LLDB_LOGF(
-  log,
-  "FindExternalLexicalDecls[%u] on (ASTContext*)%p in '%s' 
(%sDecl*)%p",
-  current_id, static_cast(m_ast_context),
-  context_named_decl->getNameAsString().c_str(),
- 

[Lldb-commits] [PATCH] D73018: [lldb] Add SystemInitializerAllPlugins and delete copy-pasted Init code in SystemInitializerFull and SystemInitializerTest

2020-01-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D73018#1830891 , @teemperor wrote:

> > This still leaves the question of the script interpreter plugins, which are 
> > suspiciously *not* included in "all plugins". The script interpreters are 
> > quite special, so I think it's fine to handle them separately -- the 
> > question is just how to convey that distinction. Move them into a different 
> > top level folder? Call this `SystemInitializerMostPlugins` ?
>
> Yeah, those 'plugins' aren't actually standalone plugins but require the SWIG 
> wrapper code to link (and the SWIG wrapper code is compiled in the API/ 
> folder). We can fix this by moving the SWIG code into the AllPlugins folder 
> (which would either be done in this commit or as a follow-up).


I'm afraid it's not that simple, as the swig code in turn depends on all the 
lldb public interfaces, which are provided by the API folder. So, even if you 
somehow manage to link this, it would still be nonsensical from the POV of 
lldb-test, as it does not include the lldb APIs. (That's why I said it may make 
sense to put these closer to/into the API folder.)

> 
> 
>> However, an even bigger question is what is the relationship of this patch 
>> and D73067 ? Right now, they seem to be 
>> taking the plugin system in two different directions, so I don't think it 
>> makes sense to accept either one before we decide what that direction is...
> 
> D73067  is more focused on making the list 
> of plugins to init/terminate depend on the CMake configuration, but even with 
> D73067  we still need to copy around the 
> linking flags, include the def file and the other boilerplate. I don't think 
> we should deduplicate identical code with macros (especially since the 
> SystemInitializers already took the approach of making subclasses). So this 
> patch solves the code duplication, D73067  
> solves the fact that the plugin itself is not dependent on the actual plugin 
> list.

Right, I now understand what you meant by the header file comment. Yes, these 
are somewhat independent subject, but they are still touching the exact same 
code (== rebase nightmare), and I don't even think they are fully orthogonal -- 
e.g. if we go through with the other patch, including the idea for generating 
the `#include` list, then the amount of boilerplate is reduced by like 90%. At 
that point, it's not clear to me whether introducing a separate "initializer" 
package is worth the final 10%. After that work is done, we may decide that we 
still want to do this, or we may see a better way to achieve the same goal 
(maybe something in cmake).

, though I agree that the current situation is bad, I also don't want to 
give too much emphasis on the "all plugins" case. I see being able to pick and 
choose what we include as a very nice property, and I'd rather encourage that 
instead. Selecting plugins at build time is one thing, but I'd like to also 
have it for different programs. We now just have three users (liblldb, 
lldb-server and lldb-test), but already each one requires different sets of 
plugins. If, in the future lldb-test continues to grow, then it may make sense 
to split it into multiple utilities (e.g. `lldb-objdump` instead of `lldb-test 
object-file`, where the former would only depend on the object file plugins). 
The main reason I haven't done anything about that yet is because in the 
current state of affairs, each tool would end up transitively depending on the 
whole world anyway...


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

https://reviews.llvm.org/D73018



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


[Lldb-commits] [PATCH] D73018: [lldb] Add SystemInitializerAllPlugins and delete copy-pasted Init code in SystemInitializerFull and SystemInitializerTest

2020-01-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I just thought of another corner case (which may be important for the other 
patch too): `Plugins/Process/Linux` and `Plugins/Process/NetBSD` are used in 
lldb-server and are not/should not be used in liblldb (or lldb-test). 
`Plugins/Process/Windows` is even weirder because it's used from both :/.


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

https://reviews.llvm.org/D73018



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


[Lldb-commits] [lldb] 3f9b6b2 - [lldb] Use llvm::stable_sort in Line

2020-01-21 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-01-21T14:09:58+01:00
New Revision: 3f9b6b270f87430c28fb2ff811d3b58dbf8bfdde

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

LOG: [lldb] Use llvm::stable_sort in Line

This addresses some post-commit feedback on D72909.

Added: 


Modified: 
lldb/source/Symbol/LineTable.cpp

Removed: 




diff  --git a/lldb/source/Symbol/LineTable.cpp 
b/lldb/source/Symbol/LineTable.cpp
index 21e451021cd6..e95d09908f32 100644
--- a/lldb/source/Symbol/LineTable.cpp
+++ b/lldb/source/Symbol/LineTable.cpp
@@ -24,7 +24,7 @@ LineTable::LineTable(CompileUnit *comp_unit)
 LineTable::LineTable(CompileUnit *comp_unit, std::vector 
&sequences)
 : m_comp_unit(comp_unit), m_entries() {
   LineTable::Entry::LessThanBinaryPredicate less_than_bp(this);
-  std::sort(sequences.begin(), sequences.end(), less_than_bp);
+  llvm::stable_sort(sequences, less_than_bp);
   for (auto *sequence : sequences) {
 LineSequenceImpl *seq = reinterpret_cast(sequence);
 m_entries.insert(m_entries.end(), seq->m_entries.begin(),



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


[Lldb-commits] [PATCH] D72909: Make SymbolFileDWARF::ParseLineTable use std::sort instead of insertion sort

2020-01-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/Symbol/LineTable.cpp:27
+  LineTable::Entry::LessThanBinaryPredicate less_than_bp(this);
+  std::sort(sequences.begin(), sequences.end(), less_than_bp);
+  for (auto *sequence : sequences) {

teemperor wrote:
> grimar wrote:
> > I wonder if this have to be `std::stable_sort`?
> > For `std::sort` the order of equal elements is not guaranteed to be 
> > preserved.
> > 
> > nit: you could also probably use the `llvm::sort` (it would be a bit 
> > shorter):
> > `llvm::sort(sequences, less_than_bp);`
> I think we should change this to llvm::sort just because of the additional 
> checks we get there (I think the shuffle/sort<->stable_sort checks are only 
> in llvm::sort).
I've changed this to llvm::stable_sort in 9a52ea5cf9c. I went for a stable sort 
because it's possible (though probably not very useful) for the debug info to 
contain two line sequences for the same address (and I've just today found a 
flaky test due to nondeterminism in lldb).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72909



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


[Lldb-commits] [lldb] 18a96fd - [lldb/DWARF] Fix a leak in line table construction

2020-01-21 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-01-21T14:44:11+01:00
New Revision: 18a96fd573b134fed7d8ea6b87930e7a059d6c90

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

LOG: [lldb/DWARF] Fix a leak in line table construction

We were creating a bunch of LineSequence objects but never deleting
them.

This fixes the leak and changes the code to use std::unique_ptr, to make
it harder to make the same mistake again.

Added: 


Modified: 
lldb/include/lldb/Symbol/LineTable.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Symbol/LineTable.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/LineTable.h 
b/lldb/include/lldb/Symbol/LineTable.h
index 363966aae9f3..0323bf5e8039 100644
--- a/lldb/include/lldb/Symbol/LineTable.h
+++ b/lldb/include/lldb/Symbol/LineTable.h
@@ -46,7 +46,8 @@ class LineTable {
   ///
   /// \param[in] sequences
   /// Unsorted list of line sequences.
-  LineTable(CompileUnit *comp_unit, std::vector &sequences);
+  LineTable(CompileUnit *comp_unit,
+std::vector> &&sequences);
 
   /// Destructor.
   ~LineTable();
@@ -70,7 +71,7 @@ class LineTable {
bool is_epilogue_begin, bool is_terminal_entry);
 
   // Used to instantiate the LineSequence helper class
-  static LineSequence *CreateLineSequenceContainer();
+  static std::unique_ptr CreateLineSequenceContainer();
 
   // Append an entry to a caller-provided collection that will later be
   // inserted in this line table.
@@ -265,7 +266,8 @@ class LineTable {
 public:
   LessThanBinaryPredicate(LineTable *line_table);
   bool operator()(const LineTable::Entry &, const LineTable::Entry &) 
const;
-  bool operator()(const LineSequence*, const LineSequence*) const;
+  bool operator()(const std::unique_ptr &,
+  const std::unique_ptr &) const;
 
 protected:
   LineTable *m_line_table;

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index a07297414e05..19e15b527903 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -995,21 +995,22 @@ bool SymbolFileDWARF::ParseLineTable(CompileUnit 
&comp_unit) {
   // FIXME: Rather than parsing the whole line table and then copying it over
   // into LLDB, we should explore using a callback to populate the line table
   // while we parse to reduce memory usage.
-  LineSequence *sequence = LineTable::CreateLineSequenceContainer();
-  std::vector sequences;
+  std::unique_ptr sequence =
+  LineTable::CreateLineSequenceContainer();
+  std::vector> sequences;
   for (auto &row : line_table->Rows) {
 LineTable::AppendLineEntryToSequence(
-sequence, row.Address.Address, row.Line, row.Column, row.File,
+sequence.get(), row.Address.Address, row.Line, row.Column, row.File,
 row.IsStmt, row.BasicBlock, row.PrologueEnd, row.EpilogueBegin,
 row.EndSequence);
 if (row.EndSequence) {
-  sequences.push_back(sequence);
+  sequences.push_back(std::move(sequence));
   sequence = LineTable::CreateLineSequenceContainer();
 }
   }
 
   std::unique_ptr line_table_up =
-  std::make_unique(&comp_unit, sequences);
+  std::make_unique(&comp_unit, std::move(sequences));
 
   if (SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile()) {
 // We have an object file that has a line table with addresses that are not

diff  --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp 
b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index 917ab68af418..7bef47e8eaee 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -1817,7 +1817,7 @@ bool SymbolFilePDB::ParseCompileUnitLineTable(CompileUnit 
&comp_unit,
 prev_source_idx, false, false, false, false, true);
 
 line_table->InsertSequence(sequence.release());
-sequence.reset(line_table->CreateLineSequenceContainer());
+sequence = line_table->CreateLineSequenceContainer();
   }
 
   if (ShouldAddLine(match_line, lno, length)) {
@@ -1854,7 +1854,7 @@ bool SymbolFilePDB::ParseCompileUnitLineTable(CompileUnit 
&comp_unit,
   prev_source_idx, false, false, false, false, true);
 }
 
-line_table->InsertSequence(sequence.release());
+line_table->InsertSequence(sequence.get());
   }
 
   if (line_table->GetSize()) {

diff  --git a/lldb/source/Symbol/LineTable.cpp 
b/lldb/source/Symbol/LineTable.cpp
index e95d09908f32..79d08024f20c 100644
--- a/lldb/source/Symbol/LineTable.cpp
+++ b/lldb/source/Symbol/LineTable.cpp
@@ -21

[Lldb-commits] [lldb] 5e70f4b - [lldb/breakpad] Use new line table constructor

2020-01-21 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-01-21T15:04:27+01:00
New Revision: 5e70f4bdc15960730d0ff2aa167399e36bc64278

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

LOG: [lldb/breakpad] Use new line table constructor

The old construction method can be quadratic for some inputs. This
approach guarantees a reasonable performance.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp 
b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
index b2c4d0883341..0d251c9e2e0a 100644
--- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -694,18 +694,18 @@ void 
SymbolFileBreakpad::ParseLineTableAndSupportFiles(CompileUnit &cu,
  "How did we create compile units without a base address?");
 
   SupportFileMap map;
-  data.line_table_up = std::make_unique(&cu);
-  std::unique_ptr line_seq_up(
-  data.line_table_up->CreateLineSequenceContainer());
+  std::vector> sequences;
+  std::unique_ptr line_seq_up =
+  LineTable::CreateLineSequenceContainer();
   llvm::Optional next_addr;
   auto finish_sequence = [&]() {
-data.line_table_up->AppendLineEntryToSequence(
+LineTable::AppendLineEntryToSequence(
 line_seq_up.get(), *next_addr, /*line*/ 0, /*column*/ 0,
 /*file_idx*/ 0, /*is_start_of_statement*/ false,
 /*is_start_of_basic_block*/ false, /*is_prologue_end*/ false,
 /*is_epilogue_begin*/ false, /*is_terminal_entry*/ true);
-data.line_table_up->InsertSequence(line_seq_up.get());
-line_seq_up->Clear();
+sequences.push_back(std::move(line_seq_up));
+line_seq_up = LineTable::CreateLineSequenceContainer();
   };
 
   LineIterator It(*m_objfile_sp, Record::Func, data.bookmark),
@@ -722,7 +722,7 @@ void 
SymbolFileBreakpad::ParseLineTableAndSupportFiles(CompileUnit &cu,
   // Discontiguous entries. Finish off the previous sequence and reset.
   finish_sequence();
 }
-data.line_table_up->AppendLineEntryToSequence(
+LineTable::AppendLineEntryToSequence(
 line_seq_up.get(), record->Address, record->LineNum, /*column*/ 0,
 map[record->FileNum], /*is_start_of_statement*/ true,
 /*is_start_of_basic_block*/ false, /*is_prologue_end*/ false,
@@ -731,6 +731,7 @@ void 
SymbolFileBreakpad::ParseLineTableAndSupportFiles(CompileUnit &cu,
   }
   if (next_addr)
 finish_sequence();
+  data.line_table_up = std::make_unique(&cu, std::move(sequences));
   data.support_files = map.translate(cu.GetPrimaryFile(), *m_files);
 }
 



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


[Lldb-commits] [PATCH] D73067: [lldb/CMake] Auto-generate the Initialize and Terminate calls for plugins (WIP)

2020-01-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Since the initialization function will have to have predictable names anyway, 
instead of generating the `#include` directives, we could just automatically 
forward declare the needed functions. So, the .def file would expand to 
something like:

  extern lldb_initialize_objectfile_elf();
  lldb_initialize_objectfile_elf();
  extern lldb_initialize_objectfile_macho();
  lldb_initialize_objectfile_macho();
  ...

That way we would have only one generated file, and we could ditch the 
`Initialization.h` file for every plugin (which would contain just the two 
forward declarations anyway). And this approach would be pretty close to what 
we'd need to do for dynamically loaded plugins (where instead of an extern 
declaration we'd have a dlsym lookup).


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D73067



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


[Lldb-commits] [PATCH] D73112: [lldb/DWARF] Remove one more auto-dwo method

2020-01-21 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: JDevlieghere, aprantl, clayborg.
Herald added a reviewer: jdoerfert.
Herald added a project: LLDB.

Our DWARFUnit was automatically forwarding the requests to the split
unit when looking for a DIE by offset. llvm::DWARFUnit does not do that,
and is not likely to start doing it any time soon.

This patch deletes the this logic and updates the callers to request the
correct unit instead. While doing that, I've found a bit of duplicated
code for lookup up a function and block by address, so I've extracted
that into a helper function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73112

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -381,6 +381,13 @@
   bool ResolveFunction(const DWARFDIE &die, bool include_inlines,
lldb_private::SymbolContextList &sc_list);
 
+  /// Resolve functions and (possibly) blocks for the given file address and a
+  /// compile unit. The compile unit comes from the sc argument and it must be
+  /// set. The results of the lookup (if any) are written back to the symbol
+  /// context.
+  void ResolveFunctionAndBlock(lldb::addr_t file_vm_addr, bool lookup_block,
+   lldb_private::SymbolContext &sc);
+
   virtual lldb::TypeSP
   FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext &die_decl_ctx);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1771,6 +1771,32 @@
   return *m_global_aranges_up;
 }
 
+void SymbolFileDWARF::ResolveFunctionAndBlock(lldb::addr_t file_vm_addr,
+  bool lookup_block,
+  SymbolContext &sc) {
+  assert(sc.comp_unit);
+  DWARFUnit &cu = GetDWARFCompileUnit(sc.comp_unit)->GetNonSkeletonUnit();
+  DWARFDIE function_die = cu.LookupAddress(file_vm_addr);
+  DWARFDIE block_die;
+  if (function_die) {
+sc.function = sc.comp_unit->FindFunctionByUID(function_die.GetID()).get();
+if (sc.function == nullptr)
+  sc.function = ParseFunction(*sc.comp_unit, function_die);
+
+if (sc.function && lookup_block)
+  block_die = function_die.LookupDeepestBlock(file_vm_addr);
+  }
+
+  if (!sc.function || ! lookup_block)
+return;
+
+  Block &block = sc.function->GetBlock(true);
+  if (block_die)
+sc.block = block.FindBlockByID(block_die.GetID());
+  else
+sc.block = block.FindBlockByID(function_die.GetID());
+}
+
 uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr,
SymbolContextItem resolve_scope,
SymbolContext &sc) {
@@ -1834,17 +1860,11 @@
 bool force_check_line_table = false;
 if (resolve_scope &
 (eSymbolContextFunction | eSymbolContextBlock)) {
-  DWARFDIE function_die = dwarf_cu->LookupAddress(file_vm_addr);
-  DWARFDIE block_die;
-  if (function_die) {
-sc.function =
-sc.comp_unit->FindFunctionByUID(function_die.GetID()).get();
-if (sc.function == nullptr)
-  sc.function = ParseFunction(*sc.comp_unit, function_die);
-
-if (sc.function && (resolve_scope & eSymbolContextBlock))
-  block_die = function_die.LookupDeepestBlock(file_vm_addr);
-  } else {
+  ResolveFunctionAndBlock(file_vm_addr,
+  resolve_scope & eSymbolContextBlock, sc);
+  if (sc.function)
+resolved |= eSymbolContextFunction;
+  else {
 // We might have had a compile unit that had discontiguous
 // address ranges where the gaps are symbols that don't have
 // any debug info. Discontiguous compile unit address ranges
@@ -1853,21 +1873,8 @@
 // of the aranges down.
 force_check_line_table = true;
   }
-
-  if (sc.function != nullptr) {
-resolved |= eSymbolContextFunction;
-
-if (resolve_scope & eSymbolContextBlock) {
-  Block &block = sc.function->GetBlock(true);
-
-  if (block_die)
-sc.block = block.FindBlockByID(block_die.GetID());
-  else
-

[Lldb-commits] [PATCH] D73116: [lldb/Initializers] Move all macOS initializers into PlatformMacOSX

2020-01-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, jingham, teemperor, xiaobai.
Herald added a project: LLDB.

PlatformMacOSX is the main entry point to the plugin with the same name. This 
is part of a greater refactoring to auto generate the initializers. (D73067 
)


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D73116

Files:
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp

Index: lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
@@ -8,9 +8,13 @@
 
 #include "PlatformMacOSX.h"
 #include "lldb/Host/Config.h"
-
-
-#include 
+#include "PlatformiOSSimulator.h"
+#include "PlatformDarwinKernel.h"
+#include "PlatformAppleTVSimulator.h"
+#include "PlatformAppleWatchSimulator.h"
+#include "PlatformRemoteAppleTV.h"
+#include "PlatformRemoteAppleWatch.h"
+#include "PlatformRemoteAppleBridge.h"
 
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/Module.h"
@@ -28,6 +32,8 @@
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/StreamString.h"
 
+#include 
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -35,6 +41,13 @@
 
 void PlatformMacOSX::Initialize() {
   PlatformDarwin::Initialize();
+  PlatformiOSSimulator::Initialize();
+  PlatformDarwinKernel::Initialize();
+  PlatformAppleTVSimulator::Initialize();
+  PlatformAppleWatchSimulator::Initialize();
+  PlatformRemoteAppleTV::Initialize();
+  PlatformRemoteAppleWatch::Initialize();
+  PlatformRemoteAppleBridge::Initialize();
 
   if (g_initialize_count++ == 0) {
 #if defined(__APPLE__)
@@ -55,6 +68,13 @@
 }
   }
 
+  PlatformRemoteAppleBridge::Initialize();
+  PlatformRemoteAppleWatch::Initialize();
+  PlatformRemoteAppleTV::Initialize();
+  PlatformAppleWatchSimulator::Initialize();
+  PlatformAppleTVSimulator::Initialize();
+  PlatformDarwinKernel::Initialize();
+  PlatformiOSSimulator::Initialize();
   PlatformDarwin::Terminate();
 }
 
Index: lldb/source/API/SystemInitializerFull.cpp
===
--- lldb/source/API/SystemInitializerFull.cpp
+++ lldb/source/API/SystemInitializerFull.cpp
@@ -102,13 +102,6 @@
 
 #if defined(__APPLE__)
 #include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
-#include "Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h"
-#include "Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h"
-#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h"
-#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
 #include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h"
 #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
 #endif
@@ -206,10 +199,6 @@
   platform_android::PlatformAndroid::Initialize();
   PlatformRemoteiOS::Initialize();
   PlatformMacOSX::Initialize();
-#if defined(__APPLE__)
-  PlatformiOSSimulator::Initialize();
-  PlatformDarwinKernel::Initialize();
-#endif
 
   // Initialize LLVM and Clang
   llvm::InitializeAllTargets();
@@ -273,11 +262,6 @@
 #if defined(__APPLE__)
   SymbolVendorMacOSX::Initialize();
   ProcessKDP::Initialize();
-  PlatformAppleTVSimulator::Initialize();
-  PlatformAppleWatchSimulator::Initialize();
-  PlatformRemoteAppleTV::Initialize();
-  PlatformRemoteAppleWatch::Initialize();
-  PlatformRemoteAppleBridge::Initialize();
   DynamicLoaderDarwinKernel::Initialize();
 #endif
 
@@ -366,11 +350,6 @@
   DynamicLoaderDarwinKernel::Terminate();
   ProcessKDP::Terminate();
   SymbolVendorMacOSX::Terminate();
-  PlatformAppleTVSimulator::Terminate();
-  PlatformAppleWatchSimulator::Terminate();
-  PlatformRemoteAppleTV::Terminate();
-  PlatformRemoteAppleWatch::Terminate();
-  PlatformRemoteAppleBridge::Terminate();
 #endif
 
 #if defined(__FreeBSD__)
@@ -388,7 +367,6 @@
   DynamicLoaderStatic::Terminate();
   DynamicLoaderWindowsDYLD::Terminate();
 
-
   platform_freebsd::PlatformFreeBSD::Terminate();
   platform_linux::PlatformLinux::Terminate();
   platform_netbsd::PlatformNetBSD::Terminate();
@@ -397,10 +375,6 @@
   platform_android::PlatformAndroid::Terminate();
   PlatformMacOSX::Terminate();
   PlatformRemoteiOS::Terminate();
-#if defined(__APPLE__)
-  PlatformiOSSimulator::Terminate();
-  PlatformDarwinKernel::Terminate();
-#endif
 
   breakpad::ObjectFileBreakpad::Terminate();
   ObjectFileELF::Terminate();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D73116: [lldb/Initializers] Move all macOS initializers into PlatformMacOSX

2020-01-21 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 seems fine to me.




Comment at: lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp:9-35
 #include "PlatformMacOSX.h"
 #include "lldb/Host/Config.h"
-
-
-#include 
+#include "PlatformiOSSimulator.h"
+#include "PlatformDarwinKernel.h"
+#include "PlatformAppleTVSimulator.h"
+#include "PlatformAppleWatchSimulator.h"
+#include "PlatformRemoteAppleTV.h"

The placement of all of this is still pretty odd (the Host/Config.h seems 
weirdly sandwiched between macos files). Just delete the whitespace and let 
clang-format sort things?



Comment at: lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp:71-77
+  PlatformRemoteAppleBridge::Initialize();
+  PlatformRemoteAppleWatch::Initialize();
+  PlatformRemoteAppleTV::Initialize();
+  PlatformAppleWatchSimulator::Initialize();
+  PlatformAppleTVSimulator::Initialize();
+  PlatformDarwinKernel::Initialize();
+  PlatformiOSSimulator::Initialize();

terminate


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D73116



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


[Lldb-commits] [PATCH] D73119: [lldb/Initializers] Rename plugins to match their entry points

2020-01-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, teemperor, xiaobai.
Herald added subscribers: jsji, atanasyan, kbarton, mgorny, nemanjai.
Herald added a project: LLDB.

Rename plugins to match their entry points. This is part of a greater 
refactoring to auto generate the initializers. (D73067 
)


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D73119

Files:
  lldb/source/Plugins/Disassembler/llvm/CMakeLists.txt
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt
  lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  lldb/source/Plugins/Instruction/ARM/CMakeLists.txt
  lldb/source/Plugins/Instruction/ARM64/CMakeLists.txt
  lldb/source/Plugins/Instruction/MIPS/CMakeLists.txt
  lldb/source/Plugins/Instruction/MIPS64/CMakeLists.txt
  lldb/source/Plugins/Instruction/PPC64/CMakeLists.txt
  lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
  lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/CMakeLists.txt
  lldb/source/Plugins/InstrumentationRuntime/TSan/CMakeLists.txt
  lldb/source/Plugins/InstrumentationRuntime/UBSan/CMakeLists.txt
  lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
  lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt
  lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
  lldb/source/Plugins/LanguageRuntime/ObjC/CMakeLists.txt
  lldb/source/Plugins/ObjectContainer/Universal-Mach-O/CMakeLists.txt
  lldb/source/Plugins/OperatingSystem/Python/CMakeLists.txt
  lldb/source/Plugins/Platform/Android/CMakeLists.txt
  lldb/source/Plugins/Platform/CMakeLists.txt
  lldb/source/Plugins/Platform/gdb-server/CMakeLists.txt
  lldb/source/Plugins/Process/MacOSX-Kernel/CMakeLists.txt
  lldb/source/Plugins/Process/elf-core/CMakeLists.txt
  lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  lldb/source/Plugins/UnwindAssembly/x86/CMakeLists.txt
  lldb/source/Symbol/CMakeLists.txt
  lldb/source/Target/CMakeLists.txt
  lldb/tools/lldb-server/CMakeLists.txt
  lldb/unittests/Disassembler/CMakeLists.txt
  lldb/unittests/Expression/CMakeLists.txt
  lldb/unittests/UnwindAssembly/ARM64/CMakeLists.txt
  lldb/unittests/UnwindAssembly/PPC64/CMakeLists.txt
  lldb/unittests/UnwindAssembly/x86/CMakeLists.txt

Index: lldb/unittests/UnwindAssembly/x86/CMakeLists.txt
===
--- lldb/unittests/UnwindAssembly/x86/CMakeLists.txt
+++ lldb/unittests/UnwindAssembly/x86/CMakeLists.txt
@@ -3,7 +3,7 @@
 LINK_LIBS
   lldbCore
   lldbSymbol
-  lldbPluginUnwindAssemblyX86
+  lldbPluginUnwindAssembly_x86
 LINK_COMPONENTS
   Support
   ${LLVM_TARGETS_TO_BUILD}
Index: lldb/unittests/UnwindAssembly/PPC64/CMakeLists.txt
===
--- lldb/unittests/UnwindAssembly/PPC64/CMakeLists.txt
+++ lldb/unittests/UnwindAssembly/PPC64/CMakeLists.txt
@@ -5,8 +5,8 @@
 lldbSymbol
 lldbTarget
 lldbPluginUnwindAssemblyInstEmulation
-lldbPluginDisassemblerLLVM
-lldbPluginInstructionPPC64
+lldbPluginDisassemblerLLVMC
+lldbPluginEmulateInstructionPPC64
 lldbPluginProcessUtility
   LINK_COMPONENTS
 Support
Index: lldb/unittests/UnwindAssembly/ARM64/CMakeLists.txt
===
--- lldb/unittests/UnwindAssembly/ARM64/CMakeLists.txt
+++ lldb/unittests/UnwindAssembly/ARM64/CMakeLists.txt
@@ -5,8 +5,8 @@
 lldbSymbol
 lldbTarget
 lldbPluginUnwindAssemblyInstEmulation
-lldbPluginDisassemblerLLVM
-lldbPluginInstructionARM64
+lldbPluginDisassemblerLLVMC
+lldbPluginEmulateInstructionARM64
 lldbPluginProcessUtility
   LINK_COMPONENTS
 Support
Index: lldb/unittests/Expression/CMakeLists.txt
===
--- lldb/unittests/Expression/CMakeLists.txt
+++ lldb/unittests/Expression/CMakeLists.txt
@@ -7,7 +7,7 @@
 
   LINK_LIBS
 lldbCore
-lldbPluginExpressionParserClang
+lldbPluginClangASTContext
 lldbUtility
 lldbUtilityHelpers
 LLVMTestingSupport
Index: lldb/unittests/Disassembler/CMakeLists.txt
===
--- lldb/unittests/Disassembler/CMakeLists.txt
+++ lldb/unittests/Disassembler/CMakeLists.txt
@@ -6,7 +6,7 @@
   lldbCore
   lldbSymbol
   lldbTarget
-  lldbPluginDisassemblerLLVM
+  lldbPluginDisassemblerLLVMC
   lldbPluginProcessUtility
 LINK_COMPONENTS
   Support
Index: lldb/tools/lldb-server/CMakeLists.txt
===
--- lldb/tools/lldb-server/CMakeLists.txt
+++ lldb/tools/lldb-server/CMakeLists.txt
@@ -41,9 +41,9 @@
   lldbHost
   lldbInitialization
   ${LLDB_PLUGINS}
-  lldbPluginInstructionARM
-  lldbPluginInstructionMIPS
-  lldbPluginInstructi

[Lldb-commits] [lldb] a731c6b - [lldb/Initializers] Move all macOS initializers into PlatformMacOSX

2020-01-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-21T09:40:48-08:00
New Revision: a731c6ba94d0464c6a122de1af70ab88ffb5c1a6

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

LOG: [lldb/Initializers] Move all macOS initializers into PlatformMacOSX

PlatformMacOSX is the main entry point to the plugin with the same name.
This is part of a greater refactoring to auto generate the initializers.

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

Added: 


Modified: 
lldb/source/API/SystemInitializerFull.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp

Removed: 




diff  --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index 7e4398a042e2..80f92a8709d5 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -102,13 +102,6 @@
 
 #if defined(__APPLE__)
 #include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
-#include "Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h"
-#include "Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h"
-#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h"
-#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
 #include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h"
 #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
 #endif
@@ -206,10 +199,6 @@ llvm::Error SystemInitializerFull::Initialize() {
   platform_android::PlatformAndroid::Initialize();
   PlatformRemoteiOS::Initialize();
   PlatformMacOSX::Initialize();
-#if defined(__APPLE__)
-  PlatformiOSSimulator::Initialize();
-  PlatformDarwinKernel::Initialize();
-#endif
 
   // Initialize LLVM and Clang
   llvm::InitializeAllTargets();
@@ -273,11 +262,6 @@ llvm::Error SystemInitializerFull::Initialize() {
 #if defined(__APPLE__)
   SymbolVendorMacOSX::Initialize();
   ProcessKDP::Initialize();
-  PlatformAppleTVSimulator::Initialize();
-  PlatformAppleWatchSimulator::Initialize();
-  PlatformRemoteAppleTV::Initialize();
-  PlatformRemoteAppleWatch::Initialize();
-  PlatformRemoteAppleBridge::Initialize();
   DynamicLoaderDarwinKernel::Initialize();
 #endif
 
@@ -366,11 +350,6 @@ void SystemInitializerFull::Terminate() {
   DynamicLoaderDarwinKernel::Terminate();
   ProcessKDP::Terminate();
   SymbolVendorMacOSX::Terminate();
-  PlatformAppleTVSimulator::Terminate();
-  PlatformAppleWatchSimulator::Terminate();
-  PlatformRemoteAppleTV::Terminate();
-  PlatformRemoteAppleWatch::Terminate();
-  PlatformRemoteAppleBridge::Terminate();
 #endif
 
 #if defined(__FreeBSD__)
@@ -388,7 +367,6 @@ void SystemInitializerFull::Terminate() {
   DynamicLoaderStatic::Terminate();
   DynamicLoaderWindowsDYLD::Terminate();
 
-
   platform_freebsd::PlatformFreeBSD::Terminate();
   platform_linux::PlatformLinux::Terminate();
   platform_netbsd::PlatformNetBSD::Terminate();
@@ -397,10 +375,6 @@ void SystemInitializerFull::Terminate() {
   platform_android::PlatformAndroid::Terminate();
   PlatformMacOSX::Terminate();
   PlatformRemoteiOS::Terminate();
-#if defined(__APPLE__)
-  PlatformiOSSimulator::Terminate();
-  PlatformDarwinKernel::Terminate();
-#endif
 
   breakpad::ObjectFileBreakpad::Terminate();
   ObjectFileELF::Terminate();

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
index 134a4c7c8075..081fed2322db 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
@@ -7,16 +7,19 @@
 
//===--===//
 
 #include "PlatformMacOSX.h"
-#include "lldb/Host/Config.h"
-
-
-#include 
-
+#include "PlatformAppleTVSimulator.h"
+#include "PlatformAppleWatchSimulator.h"
+#include "PlatformDarwinKernel.h"
+#include "PlatformRemoteAppleBridge.h"
+#include "PlatformRemoteAppleTV.h"
+#include "PlatformRemoteAppleWatch.h"
+#include "PlatformiOSSimulator.h"
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Host/Config.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Symbol/ObjectFile.h"
@@ -28,6 +31,8 @@
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/StreamString.h"
 
+#include 
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -35,6 +40,13 @@ static uint32_t g_initialize_count = 0;
 
 void PlatformMacOSX::Initialize() {
   PlatformDarwin::Initialize();
+  PlatformiOSSimulator::Initialize();
+  Plat

[Lldb-commits] [PATCH] D73116: [lldb/Initializers] Move all macOS initializers into PlatformMacOSX

2020-01-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa731c6ba94d0: [lldb/Initializers] Move all macOS 
initializers into PlatformMacOSX (authored by JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D73116?vs=239343&id=239355#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73116

Files:
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp

Index: lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
@@ -7,16 +7,19 @@
 //===--===//
 
 #include "PlatformMacOSX.h"
-#include "lldb/Host/Config.h"
-
-
-#include 
-
+#include "PlatformAppleTVSimulator.h"
+#include "PlatformAppleWatchSimulator.h"
+#include "PlatformDarwinKernel.h"
+#include "PlatformRemoteAppleBridge.h"
+#include "PlatformRemoteAppleTV.h"
+#include "PlatformRemoteAppleWatch.h"
+#include "PlatformiOSSimulator.h"
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Host/Config.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Symbol/ObjectFile.h"
@@ -28,6 +31,8 @@
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/StreamString.h"
 
+#include 
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -35,6 +40,13 @@
 
 void PlatformMacOSX::Initialize() {
   PlatformDarwin::Initialize();
+  PlatformiOSSimulator::Initialize();
+  PlatformDarwinKernel::Initialize();
+  PlatformAppleTVSimulator::Initialize();
+  PlatformAppleWatchSimulator::Initialize();
+  PlatformRemoteAppleTV::Initialize();
+  PlatformRemoteAppleWatch::Initialize();
+  PlatformRemoteAppleBridge::Initialize();
 
   if (g_initialize_count++ == 0) {
 #if defined(__APPLE__)
@@ -55,6 +67,13 @@
 }
   }
 
+  PlatformRemoteAppleBridge::Terminate();
+  PlatformRemoteAppleWatch::Terminate();
+  PlatformRemoteAppleTV::Terminate();
+  PlatformAppleWatchSimulator::Terminate();
+  PlatformAppleTVSimulator::Terminate();
+  PlatformDarwinKernel::Terminate();
+  PlatformiOSSimulator::Terminate();
   PlatformDarwin::Terminate();
 }
 
Index: lldb/source/API/SystemInitializerFull.cpp
===
--- lldb/source/API/SystemInitializerFull.cpp
+++ lldb/source/API/SystemInitializerFull.cpp
@@ -102,13 +102,6 @@
 
 #if defined(__APPLE__)
 #include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
-#include "Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h"
-#include "Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h"
-#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h"
-#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
 #include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h"
 #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
 #endif
@@ -206,10 +199,6 @@
   platform_android::PlatformAndroid::Initialize();
   PlatformRemoteiOS::Initialize();
   PlatformMacOSX::Initialize();
-#if defined(__APPLE__)
-  PlatformiOSSimulator::Initialize();
-  PlatformDarwinKernel::Initialize();
-#endif
 
   // Initialize LLVM and Clang
   llvm::InitializeAllTargets();
@@ -273,11 +262,6 @@
 #if defined(__APPLE__)
   SymbolVendorMacOSX::Initialize();
   ProcessKDP::Initialize();
-  PlatformAppleTVSimulator::Initialize();
-  PlatformAppleWatchSimulator::Initialize();
-  PlatformRemoteAppleTV::Initialize();
-  PlatformRemoteAppleWatch::Initialize();
-  PlatformRemoteAppleBridge::Initialize();
   DynamicLoaderDarwinKernel::Initialize();
 #endif
 
@@ -366,11 +350,6 @@
   DynamicLoaderDarwinKernel::Terminate();
   ProcessKDP::Terminate();
   SymbolVendorMacOSX::Terminate();
-  PlatformAppleTVSimulator::Terminate();
-  PlatformAppleWatchSimulator::Terminate();
-  PlatformRemoteAppleTV::Terminate();
-  PlatformRemoteAppleWatch::Terminate();
-  PlatformRemoteAppleBridge::Terminate();
 #endif
 
 #if defined(__FreeBSD__)
@@ -388,7 +367,6 @@
   DynamicLoaderStatic::Terminate();
   DynamicLoaderWindowsDYLD::Terminate();
 
-
   platform_freebsd::PlatformFreeBSD::Terminate();
   platform_linux::PlatformLinux::Terminate();
   platform_netbsd::PlatformNetBSD::Terminate();
@@ -397,10 +375,6 @@
   platform_android::PlatformAndroid::Terminate();
   PlatformMacOSX::Terminate();
   PlatformRemoteiOS::Terminate();
-#if defined(__APPLE__)
-  PlatformiOSSimulator::Terminate();
-  PlatformDarwinKernel::Terminate();
-#endif
 
   breakpad::ObjectFi

[Lldb-commits] [PATCH] D73121: [lldb/Initializers] Move all ObjC initializers into AppleObjCRuntime

2020-01-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, teemperor, xiaobai.
Herald added a project: LLDB.

AppleObjCRuntime is the main entry point to the plugin with the same name.
This is part of a greater refactoring to auto generate the initializers.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D73121

Files:
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
  lldb/tools/lldb-test/SystemInitializerTest.cpp

Index: lldb/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -53,8 +53,7 @@
 #include "Plugins/Language/ObjC/ObjCLanguage.h"
 #include "Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h"
 #include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h"
-#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h"
-#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
+#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
 #include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h"
 #include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
 #include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
@@ -226,8 +225,7 @@
 
   SymbolFileDWARFDebugMap::Initialize();
   ItaniumABILanguageRuntime::Initialize();
-  AppleObjCRuntimeV2::Initialize();
-  AppleObjCRuntimeV1::Initialize();
+  AppleObjCRuntime::Initialize();
   SystemRuntimeMacOSX::Initialize();
   RenderScriptRuntime::Initialize();
 
@@ -324,8 +322,7 @@
 
   SymbolFileDWARFDebugMap::Terminate();
   ItaniumABILanguageRuntime::Terminate();
-  AppleObjCRuntimeV2::Terminate();
-  AppleObjCRuntimeV1::Terminate();
+  AppleObjCRuntime::Terminate();
   SystemRuntimeMacOSX::Terminate();
   RenderScriptRuntime::Terminate();
 
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
@@ -31,6 +31,10 @@
 
   static char ID;
 
+  static void Initialize();
+
+  static void Terminate();
+
   bool isA(const void *ClassID) const override {
 return ClassID == &ID || ObjCLanguageRuntime::isA(ClassID);
   }
@@ -84,7 +88,7 @@
   bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override;
 
   lldb::SearchFilterSP CreateExceptionSearchFilter() override;
-  
+
   static std::tuple GetExceptionThrowLocation();
 
   lldb::ValueObjectSP GetExceptionObjectForThread(
@@ -97,7 +101,7 @@
 
   virtual void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true,
 lldb::addr_t &cf_false);
-
+
   virtual bool IsTaggedPointer (lldb::addr_t addr) { return false; }
 
 protected:
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -8,10 +8,12 @@
 //===--===//
 
 #include "AppleObjCRuntime.h"
+#include "AppleObjCRuntimeV1.h"
+#include "AppleObjCRuntimeV2.h"
 #include "AppleObjCTrampolineHandler.h"
-
-#include "clang/AST/Type.h"
-
+#include "Plugins/Language/ObjC/NSString.h"
+#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
+#include "Plugins/Process/Utility/HistoryThread.h"
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
@@ -35,10 +37,7 @@
 #include "lldb/Utility/Scalar.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/StreamString.h"
-
-#include "Plugins/Process/Utility/HistoryThread.h"
-#include "Plugins/Language/ObjC/NSString.h"
-#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
+#include "clang/AST/Type.h"
 
 #include 
 
@@ -55,6 +54,16 @@
   ReadObjCLibraryIfNeeded(process->GetTarget().GetImages());
 }
 
+void AppleObjCRuntime::Initialize() {
+  AppleObjCRuntimeV2::Initialize();
+  AppleObjCRuntimeV1::Initialize();
+}
+
+void AppleObjCRuntime::Terminate() {
+  AppleObjCRuntimeV2::Terminate();
+  AppleObjCRuntimeV1::Terminate();
+}
+
 bool AppleObjCRuntime::GetObjectDescription(Stream &str, ValueObject &valobj) {
   CompilerType compiler_type(valobj.GetCompilerType());
   bool is_signed;
@@ -479,7 +488,7 @@
 
   auto descriptor = GetClassDescriptor(*cpp_exception);
   if (!descriptor || !descriptor->IsValid()) return 

[Lldb-commits] [PATCH] D73119: [lldb/Initializers] Rename plugins to match their entry points

2020-01-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.
Herald added a subscriber: wuzish.

There are three names to consider here:

- the name of the cmake target
- the name of the main .h file
- the name of the folders the plugin is in

Here you seem to be standardizing the first two, sometimes at the expense 
breaking existing symmetry with the third one (lldbPluginProcessMacOSXKernel -> 
lldbPluginProcessKDP) . Could we make all three consistent? I don't know 
whether you'll need that for the auto-generation, but it sure won't hurt..


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D73119



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


[Lldb-commits] [lldb] cf26380 - [lldb/tools] Update lldb-test's system initializer

2020-01-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-21T09:58:35-08:00
New Revision: cf263807a6c0a6989476ae9d44a21a657e048c94

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

LOG: [lldb/tools] Update lldb-test's system initializer

After a731c6ba94d0 the initializer only has to call the PlatformMacOSX
to initialize all the macOS platforms.

Added: 


Modified: 
lldb/tools/lldb-test/SystemInitializerTest.cpp

Removed: 




diff  --git a/lldb/tools/lldb-test/SystemInitializerTest.cpp 
b/lldb/tools/lldb-test/SystemInitializerTest.cpp
index 409ce2ed0bc1..16d39d7cae56 100644
--- a/lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ b/lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -91,13 +91,6 @@
 
 #if defined(__APPLE__)
 #include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
-#include "Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h"
-#include "Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h"
-#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h"
-#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
 #include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h"
 #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
 #endif
@@ -177,10 +170,6 @@ llvm::Error SystemInitializerTest::Initialize() {
   platform_android::PlatformAndroid::Initialize();
   PlatformRemoteiOS::Initialize();
   PlatformMacOSX::Initialize();
-#if defined(__APPLE__)
-  PlatformiOSSimulator::Initialize();
-  PlatformDarwinKernel::Initialize();
-#endif
 
   // Initialize LLVM and Clang
   llvm::InitializeAllTargets();
@@ -244,12 +233,6 @@ llvm::Error SystemInitializerTest::Initialize() {
 #if defined(__APPLE__)
   SymbolVendorMacOSX::Initialize();
   ProcessKDP::Initialize();
-  PlatformAppleTVSimulator::Initialize();
-  PlatformAppleWatchSimulator::Initialize();
-  PlatformRemoteAppleTV::Initialize();
-  PlatformRemoteAppleWatch::Initialize();
-  PlatformRemoteAppleBridge::Initialize();
-  DynamicLoaderDarwinKernel::Initialize();
 #endif
 
   // This plugin is valid on any host that talks to a Darwin remote. It
@@ -337,11 +320,6 @@ void SystemInitializerTest::Terminate() {
   DynamicLoaderDarwinKernel::Terminate();
   ProcessKDP::Terminate();
   SymbolVendorMacOSX::Terminate();
-  PlatformAppleTVSimulator::Terminate();
-  PlatformAppleWatchSimulator::Terminate();
-  PlatformRemoteAppleTV::Terminate();
-  PlatformRemoteAppleWatch::Terminate();
-  PlatformRemoteAppleBridge::Terminate();
 #endif
 
 #if defined(__FreeBSD__)
@@ -359,7 +337,6 @@ void SystemInitializerTest::Terminate() {
   DynamicLoaderStatic::Terminate();
   DynamicLoaderWindowsDYLD::Terminate();
 
-
   platform_freebsd::PlatformFreeBSD::Terminate();
   platform_linux::PlatformLinux::Terminate();
   platform_netbsd::PlatformNetBSD::Terminate();
@@ -368,10 +345,6 @@ void SystemInitializerTest::Terminate() {
   platform_android::PlatformAndroid::Terminate();
   PlatformMacOSX::Terminate();
   PlatformRemoteiOS::Terminate();
-#if defined(__APPLE__)
-  PlatformiOSSimulator::Terminate();
-  PlatformDarwinKernel::Terminate();
-#endif
 
   breakpad::ObjectFileBreakpad::Terminate();
   ObjectFileELF::Terminate();



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


[Lldb-commits] [PATCH] D73053: [lldb/DataFormatters] Fix the `$$deference$$` synthetic child

2020-01-21 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

Except for one typo in the comment (thanks for adding that BTW) looks good.




Comment at: lldb/docs/use/variable.rst:907
+  if index == 0:
+  return 
+  return None

of -> from


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73053



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


[Lldb-commits] [PATCH] D69524: [debugserver] Delete macOS/PPC debug server implementation

2020-01-21 Thread Vedant Kumar via Phabricator via lldb-commits
vsk added a comment.
Herald added a subscriber: wuzish.

Friendly ping. This isn't urgent, just seems like a simple cleanup.


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

https://reviews.llvm.org/D69524



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


[Lldb-commits] [PATCH] D73125: [lldb/Plugins] Move entry points out of plugin namespace

2020-01-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, teemperor, xiaobai.
Herald added subscribers: abidh, aheejin, sbc100, emaste.
Herald added a project: LLDB.

This moves the plugin entry points (the class that has the `::Initialize` and 
`::Terminate` methods) out of the plugin namespace. This is part of a greater 
refactoring to auto generate the initializers. (D73067 
)


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D73125

Files:
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
  lldb/source/Plugins/Platform/Android/PlatformAndroid.h
  lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
  lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
  lldb/source/Plugins/Platform/Linux/PlatformLinux.h
  lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
  lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
  lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
  lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h
  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/ThreadGDBRemote.h
  lldb/source/Plugins/Process/minidump/ProcessMinidump.h
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
  lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp
  lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h
  lldb/tools/lldb-test/SystemInitializerTest.cpp

Index: lldb/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -151,23 +151,23 @@
   if (auto e = SystemInitializerCommon::Initialize())
 return e;
 
-  breakpad::ObjectFileBreakpad::Initialize();
+  ObjectFileBreakpad::Initialize();
   ObjectFileELF::Initialize();
   ObjectFileMachO::Initialize();
   ObjectFilePECOFF::Initialize();
-  wasm::ObjectFileWasm::Initialize();
+  ObjectFileWasm::Initialize();
 
   ObjectContainerBSDArchive::Initialize();
   ObjectContainerUniversalMachO::Initialize();
 
   ScriptInterpreterNone::Initialize();
 
-  platform_freebsd::PlatformFreeBSD::Initialize();
-  platform_linux::PlatformLinux::Initialize();
-  platform_netbsd::PlatformNetBSD::Initialize();
-  platform_openbsd::PlatformOpenBSD::Initialize();
+  PlatformFreeBSD::Initialize();
+  PlatformLinux::Initialize();
+  PlatformNetBSD::Initialize();
+  PlatformOpenBSD::Initialize();
   PlatformWindows::Initialize();
-  platform_android::PlatformAndroid::Initialize();
+  PlatformAndroid::Initialize();
   PlatformRemoteiOS::Initialize();
   PlatformMacOSX::Initialize();
 
@@ -191,7 +191,7 @@
   JITLoaderGDB::Initialize();
   ProcessElfCore::Initialize();
   ProcessMachCore::Initialize();
-  minidump::ProcessMinidump::Initialize();
+  ProcessMinidump::Initialize();
   MemoryHistoryASan::Initialize();
   AddressSanitizerRuntime::Initialize();
   ThreadSanitizerRuntime::Initialize();
@@ -199,11 +199,11 @@
   MainThreadCheckerRuntime::Initialize();
 
   SymbolVendorELF::Initialize();
-  breakpad::SymbolFileBreakpad::Initialize();
+  SymbolFileBreakpad::Initialize();
   SymbolFileDWARF::Initialize();
   SymbolFilePDB::Initialize();
   SymbolFileSymtab::Initialize();
-  wasm::SymbolVendorWasm::Initialize();
+  SymbolVendorWasm::Initialize();
   UnwindAssemblyInstEmulation::Initialize();
   UnwindAssembly_x86::Initialize();
 
@@ -240,9 +240,9 @@
   StructuredDataDarwinLog::Initialize();
 
   // Platform agnostic plugins
-  platform_gdb_server::PlatformRemoteGDBServer::Initialize();
+  PlatformRemoteGDBServer::Initialize();
 
-  process_gdb_remote::ProcessGDBRemote::Initialize();
+  ProcessGDBRemote::Initialize();
   DynamicLoaderMacOSXDYLD::Initialize();
   DynamicLoaderMacOS::Initialize();
   DynamicLoaderPOSIXDYLD::Initialize();
@@ -284,15 +284,15 @@
   JITLoaderGDB::Terminate();
   ProcessElfCore::Terminate();
   ProcessMachCore::Terminate();
-  minidump::ProcessMinidump::Terminate();
+  ProcessMinidump::Terminate();
   MemoryHistoryASan::Terminate();
   AddressSanitizerRuntime::Terminate();
   ThreadSanitizerRuntime::Terminate();
   UndefinedBehaviorSanitizerRuntime::Terminate();
   MainThreadCheckerRuntime::Terminate();
-  wasm::SymbolVendorWasm::Terminate();
+  SymbolVendorWasm::T

[Lldb-commits] [PATCH] D69524: [debugserver] Delete macOS/PPC debug server implementation

2020-01-21 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.

Ah, sorry yes, the initial debugserver implementation was written back when 
macOS ppc was still a thing (although on its way out) - but the time the switch 
happened to lldb, we'd dropped support entirely.  I doubt any of this code was 
ever actually used.


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

https://reviews.llvm.org/D69524



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


[Lldb-commits] [PATCH] D73121: [lldb/Initializers] Move all ObjC initializers into AppleObjCRuntime

2020-01-21 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp:58
+void AppleObjCRuntime::Initialize() {
+  AppleObjCRuntimeV2::Initialize();
+  AppleObjCRuntimeV1::Initialize();

I am curious does order matter? Same below for `Terminate`


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D73121



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


[Lldb-commits] [lldb] 9aba2ce - [debugserver] Delete macOS/PPC debug server implementation

2020-01-21 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-01-21T10:59:38-08:00
New Revision: 9aba2ced34b295658f3f07311efe665495987426

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

LOG: [debugserver] Delete macOS/PPC debug server implementation

macOS/PPC support was dropped in 10.6 (Snow Leopard).

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

Added: 


Modified: 
lldb/tools/debugserver/source/MacOSX/CMakeLists.txt

Removed: 
lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp
lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h



diff  --git a/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt 
b/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt
index 73ba6492a0ef..001f861d2718 100644
--- a/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt
+++ b/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt
@@ -26,11 +26,6 @@ if(NOT LLDB_DEBUGSERVER_ARCH OR "${LLDB_DEBUGSERVER_ARCH}" 
MATCHES ".*86.*")
   include_directories(${CURRENT_SOURCE_DIR}/i386 ${CURRENT_SOURCE_DIR}/x86_64)
 endif()
 
-if("${LLDB_DEBUGSERVER_ARCH}" MATCHES ".*ppc.*")
-  list(APPEND SOURCES ppc/DNBArchImpl.cpp)
-  include_directories(${CURRENT_SOURCE_DIR}/ppc)
-endif()
-
 add_subdirectory(DarwinLog)
 
 include_directories(..)

diff  --git a/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp 
b/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp
deleted file mode 100644
index c6671b5066a4..
--- a/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp
+++ /dev/null
@@ -1,487 +0,0 @@
-//===-- DNBArchImpl.cpp -*- C++ 
-*-===//
-//
-// 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
-//
-//===--===//
-//
-//  Created by Greg Clayton on 6/25/07.
-//
-//===--===//
-
-#if defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__)
-
-#if __DARWIN_UNIX03
-#define PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(reg) __##reg
-#else
-#define PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(reg) reg
-#endif
-
-#include "MacOSX/ppc/DNBArchImpl.h"
-#include "DNBBreakpoint.h"
-#include "DNBLog.h"
-#include "DNBRegisterInfo.h"
-#include "MacOSX/MachThread.h"
-
-static const uint8_t g_breakpoint_opcode[] = {0x7F, 0xC0, 0x00, 0x08};
-
-const uint8_t *DNBArchMachPPC::SoftwareBreakpointOpcode(nub_size_t size) {
-  if (size == 4)
-return g_breakpoint_opcode;
-  return NULL;
-}
-
-uint32_t DNBArchMachPPC::GetCPUType() { return CPU_TYPE_POWERPC; }
-
-uint64_t DNBArchMachPPC::GetPC(uint64_t failValue) {
-  // Get program counter
-  if (GetGPRState(false) == KERN_SUCCESS)
-return m_state.gpr.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(srr0);
-  return failValue;
-}
-
-kern_return_t DNBArchMachPPC::SetPC(uint64_t value) {
-  // Get program counter
-  kern_return_t err = GetGPRState(false);
-  if (err == KERN_SUCCESS) {
-m_state.gpr.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(srr0) = value;
-err = SetGPRState();
-  }
-  return err == KERN_SUCCESS;
-}
-
-uint64_t DNBArchMachPPC::GetSP(uint64_t failValue) {
-  // Get stack pointer
-  if (GetGPRState(false) == KERN_SUCCESS)
-return m_state.gpr.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(r1);
-  return failValue;
-}
-
-kern_return_t DNBArchMachPPC::GetGPRState(bool force) {
-  if (force || m_state.GetError(e_regSetGPR, Read)) {
-mach_msg_type_number_t count = e_regSetWordSizeGPR;
-m_state.SetError(e_regSetGPR, Read,
- ::thread_get_state(m_thread->MachPortNumber(), 
e_regSetGPR,
-(thread_state_t)&m_state.gpr, &count));
-  }
-  return m_state.GetError(e_regSetGPR, Read);
-}
-
-kern_return_t DNBArchMachPPC::GetFPRState(bool force) {
-  if (force || m_state.GetError(e_regSetFPR, Read)) {
-mach_msg_type_number_t count = e_regSetWordSizeFPR;
-m_state.SetError(e_regSetFPR, Read,
- ::thread_get_state(m_thread->MachPortNumber(), 
e_regSetFPR,
-(thread_state_t)&m_state.fpr, &count));
-  }
-  return m_state.GetError(e_regSetFPR, Read);
-}
-
-kern_return_t DNBArchMachPPC::GetEXCState(bool force) {
-  if (force || m_state.GetError(e_regSetEXC, Read)) {
-mach_msg_type_number_t count = e_regSetWordSizeEXC;
-m_state.SetError(e_regSetEXC, Read,
- ::thread_get_state(m_thread->MachPortNumber(), 
e_regSetEXC,
-(thread_state_t)&m_state.exc, &count));
-  }
-  return m_state.GetError(e_regSetEXC, Read);
-}
-
-kern_return_t DNBArchMachPPC::GetVECState(bool force) {
-  if (force 

[Lldb-commits] [lldb] 441aebc - [debugserver] Delete stale code referencing ppc

2020-01-21 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-01-21T11:04:04-08:00
New Revision: 441aebc5235af164a784d0b9bd460c07e01e9045

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

LOG: [debugserver] Delete stale code referencing ppc

Added: 


Modified: 
lldb/tools/debugserver/source/DNBArch.h
lldb/tools/debugserver/source/DNBDefs.h
lldb/tools/debugserver/source/RNBDefs.h
lldb/tools/debugserver/source/RNBServices.cpp

Removed: 




diff  --git a/lldb/tools/debugserver/source/DNBArch.h 
b/lldb/tools/debugserver/source/DNBArch.h
index b5e2e25ef47e..03b6b60ed86d 100644
--- a/lldb/tools/debugserver/source/DNBArch.h
+++ b/lldb/tools/debugserver/source/DNBArch.h
@@ -120,7 +120,6 @@ class DNBArchProtocol {
 #include "MacOSX/arm/DNBArchImpl.h"
 #include "MacOSX/arm64/DNBArchImplARM64.h"
 #include "MacOSX/i386/DNBArchImplI386.h"
-#include "MacOSX/ppc/DNBArchImpl.h"
 #include "MacOSX/x86_64/DNBArchImplX86_64.h"
 
 #endif

diff  --git a/lldb/tools/debugserver/source/DNBDefs.h 
b/lldb/tools/debugserver/source/DNBDefs.h
index 22cfce1757f7..2136eb6d5c44 100644
--- a/lldb/tools/debugserver/source/DNBDefs.h
+++ b/lldb/tools/debugserver/source/DNBDefs.h
@@ -20,15 +20,13 @@
 #include 
 
 // Define nub_addr_t and the invalid address value from the architecture
-#if defined(__x86_64__) || defined(__ppc64__) || defined(__arm64__) || 
\
-defined(__aarch64__)
+#if defined(__x86_64__) || defined(__arm64__) || defined(__aarch64__)
 
 // 64 bit address architectures
 typedef uint64_t nub_addr_t;
 #define INVALID_NUB_ADDRESS ((nub_addr_t)~0ull)
 
-#elif defined(__i386__) || defined(__powerpc__) || defined(__ppc__) || 
\
-defined(__arm__)
+#elif defined(__i386__) || defined(__powerpc__) || defined(__arm__)
 
 // 32 bit address architectures
 

diff  --git a/lldb/tools/debugserver/source/RNBDefs.h 
b/lldb/tools/debugserver/source/RNBDefs.h
index 4cc7c220b7f2..fe5d9de04cbe 100644
--- a/lldb/tools/debugserver/source/RNBDefs.h
+++ b/lldb/tools/debugserver/source/RNBDefs.h
@@ -50,14 +50,6 @@ extern "C" const double CONCAT(DEBUGSERVER_PROGRAM_SYMBOL, 
VersionNumber);
 
 #define RNB_ARCH "x86_64"
 
-#elif defined(__ppc64__)
-
-#define RNB_ARCH "ppc64"
-
-#elif defined(__powerpc__) || defined(__ppc__)
-
-#define RNB_ARCH "ppc"
-
 #elif defined(__arm64__) || defined(__aarch64__)
 
 #define RNB_ARCH "arm64"

diff  --git a/lldb/tools/debugserver/source/RNBServices.cpp 
b/lldb/tools/debugserver/source/RNBServices.cpp
index 085aaddfaf15..7b2ab7c9b737 100644
--- a/lldb/tools/debugserver/source/RNBServices.cpp
+++ b/lldb/tools/debugserver/source/RNBServices.cpp
@@ -62,9 +62,8 @@ int GetProcesses(CFMutableArrayRef plistMutableArray, bool 
all_users) {
   proc_info.kp_proc.p_stat ==
   SZOMB || // Zombies are bad, they like brains...
   proc_info.kp_proc.p_flag & P_TRACED || // Being debugged?
-  proc_info.kp_proc.p_flag & P_WEXIT ||  // Working on exiting?
-  proc_info.kp_proc.p_flag &
-  P_TRANSLATED) // Skip translated ppc (Rosetta)
+  proc_info.kp_proc.p_flag & P_WEXIT // Working on exiting?
+  )
 continue;
 
   // Create a new mutable dictionary for each application



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


[Lldb-commits] [lldb] 7c9bcba - [lldb] Add a setting to not install the main executable

2020-01-21 Thread Francesco Petrogalli via lldb-commits

Author: Francesco Petrogalli
Date: 2020-01-21T19:06:44Z
New Revision: 7c9bcba644c4fc2178e20060d9ba2ff1f50ae15e

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

LOG: [lldb] Add a setting to not install the main executable

Summary:
Add setting target.auto-install-main-executable that controls whether
the main executable should be automatically installed when connected to
a remote platform even if it does not have an explicit install path
specified. The default is true as the current behaviour.

Reviewers: omjavaid, JDevlieghere, srhines, labath, clayborg

Reviewed By: clayborg

Subscribers: kevin.brodsky, lldb-commits, llvm-commits

Tags: #lldb

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

Added: 

lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/Makefile

lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py

lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/main.cpp

Modified: 
lldb/include/lldb/Target/Target.h
lldb/source/Target/Target.cpp
lldb/source/Target/TargetProperties.td

Removed: 




diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 1e9153c401ef..4396f05c75aa 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -207,6 +207,8 @@ class TargetProperties : public Properties {
 
   bool GetRequireHardwareBreakpoints() const;
 
+  bool GetAutoInstallMainExecutable() const;
+
 private:
   // Callbacks for m_launch_info.
   void Arg0ValueChangedCallback();

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/Makefile
 
b/lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/Makefile
new file mode 100644
index ..1354ec49464a
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/Makefile
@@ -0,0 +1,9 @@
+CXX_SOURCES := main.cpp
+CXXFLAGS := -DBUILD=\"stock\"
+
+a.out: a.device.out
+
+include Makefile.rules
+
+a.device.out:
+   $(CXX) $(CXXFLAGS) -DBUILD=\"device\" -o $@ $(SRCDIR)/main.cpp

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
 
b/lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
new file mode 100644
index ..0169cd494f54
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
@@ -0,0 +1,137 @@
+"""
+Test target commands: target.auto-install-main-executable.
+"""
+
+import time
+import gdbremote_testcase
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestAutoInstallMainExecutable(gdbremote_testcase.GdbRemoteTestCaseBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+super(TestAutoInstallMainExecutable, self).setUp()
+self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+def tearDown(self):
+lldb.DBG.SetSelectedPlatform(self._initial_platform)
+super(TestAutoInstallMainExecutable, self).tearDown()
+
+@llgs_test
+@no_debug_info_test
+@skipIf(remote=False)
+@expectedFailureAll(hostoslist=["windows"], triple='.*-android')
+def test_target_auto_install_main_executable(self):
+self.build()
+self.init_llgs_test(False)
+
+# Manually install the modified binary.
+working_dir = lldb.remote_platform.GetWorkingDirectory()
+src_device = lldb.SBFileSpec(self.getBuildArtifact("a.device.out"))
+dest = lldb.SBFileSpec(os.path.join(working_dir, "a.out"))
+err = lldb.remote_platform.Put(src_device, dest)
+if err.Fail():
+raise RuntimeError(
+"Unable copy '%s' to '%s'.\n>>> %s" %
+(src_device.GetFilename(), working_dir, err.GetCString()))
+
+m = re.search("^(.*)://([^/]*):(.*)$", configuration.lldb_platform_url)
+protocol = m.group(1)
+hostname = m.group(2)
+hostport = int(m.group(3))
+listen_url = "*:"+str(hostport+1)
+
+commandline_args = [
+"platform",
+"--listen",
+listen_url,
+"--server"
+]
+
+self.spawnSubprocess(
+self.debug_monitor_exe,
+commandline_args,
+install_remote=False)
+self.addTearDownHook(self.cleanupSubprocesses)
+
+# Wait for the new process gets ready.
+time.sleep(0.1)
+
+new_debugger = lldb.SBDebugger.Create()
+new_

[Lldb-commits] [PATCH] D69524: [debugserver] Delete macOS/PPC debug server implementation

2020-01-21 Thread Vedant Kumar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9aba2ced34b2: [debugserver] Delete macOS/PPC debug server 
implementation (authored by vsk).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69524

Files:
  lldb/tools/debugserver/source/MacOSX/CMakeLists.txt
  lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp
  lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h

Index: lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h
===
--- lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h
+++ /dev/null
@@ -1,159 +0,0 @@
-//===-- DNBArchImpl.h ---*- C++ -*-===//
-//
-// 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
-//
-//===--===//
-//
-//  Created by Greg Clayton on 6/25/07.
-//
-//===--===//
-
-#ifndef __DebugNubArchMachPPC_h__
-#define __DebugNubArchMachPPC_h__
-
-#if defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__)
-
-#include "DNBArch.h"
-
-class MachThread;
-
-class DNBArchMachPPC : public DNBArchProtocol {
-public:
-  DNBArchMachPPC(MachThread *thread) : m_thread(thread), m_state() {}
-
-  virtual ~DNBArchMachPPC() {}
-
-  virtual const DNBRegisterSetInfo *
-  GetRegisterSetInfo(nub_size_t *num_reg_sets) const;
-  virtual bool GetRegisterValue(uint32_t set, uint32_t reg,
-DNBRegisterValue *value) const;
-  virtual kern_return_t GetRegisterState(int set, bool force);
-  virtual kern_return_t SetRegisterState(int set);
-  virtual bool RegisterSetStateIsValid(int set) const;
-
-  virtual uint64_t GetPC(uint64_t failValue); // Get program counter
-  virtual kern_return_t SetPC(uint64_t value);
-  virtual uint64_t GetSP(uint64_t failValue); // Get stack pointer
-  virtual bool ThreadWillResume();
-  virtual bool ThreadDidStop();
-
-  static const uint8_t *SoftwareBreakpointOpcode(nub_size_t byte_size);
-  static uint32_t GetCPUType();
-
-protected:
-  kern_return_t EnableHardwareSingleStep(bool enable);
-
-  enum RegisterSet {
-e_regSetALL = REGISTER_SET_ALL,
-e_regSetGPR,
-e_regSetFPR,
-e_regSetEXC,
-e_regSetVEC,
-kNumRegisterSets
-  };
-
-  typedef enum RegisterSetWordSizeTag {
-e_regSetWordSizeGPR = PPC_THREAD_STATE_COUNT,
-e_regSetWordSizeFPR = PPC_FLOAT_STATE_COUNT,
-e_regSetWordSizeEXC = PPC_EXCEPTION_STATE_COUNT,
-e_regSetWordSizeVEC = PPC_VECTOR_STATE_COUNT
-  } RegisterSetWordSize;
-
-  enum { Read = 0, Write = 1, kNumErrors = 2 };
-
-  struct State {
-ppc_thread_state_t gpr;
-ppc_float_state_t fpr;
-ppc_exception_state_t exc;
-ppc_vector_state_t vec;
-kern_return_t gpr_errs[2]; // Read/Write errors
-kern_return_t fpr_errs[2]; // Read/Write errors
-kern_return_t exc_errs[2]; // Read/Write errors
-kern_return_t vec_errs[2]; // Read/Write errors
-
-State() {
-  uint32_t i;
-  for (i = 0; i < kNumErrors; i++) {
-gpr_errs[i] = -1;
-fpr_errs[i] = -1;
-exc_errs[i] = -1;
-vec_errs[i] = -1;
-  }
-}
-void InvalidateAllRegisterStates() { SetError(e_regSetALL, Read, -1); }
-kern_return_t GetError(int set, uint32_t err_idx) const {
-  if (err_idx < kNumErrors) {
-switch (set) {
-// When getting all errors, just OR all values together to see if
-// we got any kind of error.
-case e_regSetALL:
-  return gpr_errs[err_idx] | fpr_errs[err_idx] | exc_errs[err_idx] |
- vec_errs[err_idx];
-case e_regSetGPR:
-  return gpr_errs[err_idx];
-case e_regSetFPR:
-  return fpr_errs[err_idx];
-case e_regSetEXC:
-  return exc_errs[err_idx];
-case e_regSetVEC:
-  return vec_errs[err_idx];
-default:
-  break;
-}
-  }
-  return -1;
-}
-bool SetError(int set, uint32_t err_idx, kern_return_t err) {
-  if (err_idx < kNumErrors) {
-switch (set) {
-case e_regSetALL:
-  gpr_errs[err_idx] = fpr_errs[err_idx] = exc_errs[err_idx] =
-  vec_errs[err_idx] = err;
-  return true;
-
-case e_regSetGPR:
-  gpr_errs[err_idx] = err;
-  return true;
-
-case e_regSetFPR:
-  fpr_errs[err_idx] = err;
-  return true;
-
-case e_regSetEXC:
-  exc_errs[err_idx] = err;
-  return true;
-
-case e_regSetVEC:
-  vec_errs[err_idx] = err;
-  return true;
-
-default:
-  break;
-}
-  }
-  return false;
-}

[Lldb-commits] [PATCH] D71761: [lldb] Add a setting to not install the main executable

2020-01-21 Thread Francesco Petrogalli via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7c9bcba644c4: [lldb] Add a setting to not install the main 
executable (authored by fpetrogalli).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71761

Files:
  lldb/include/lldb/Target/Target.h
  
lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/Makefile
  
lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
  
lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/main.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetProperties.td

Index: lldb/source/Target/TargetProperties.td
===
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -154,6 +154,9 @@
   def RequireHardwareBreakpoints: Property<"require-hardware-breakpoint", "Boolean">,
 DefaultFalse,
 Desc<"Require all breakpoints to be hardware breakpoints.">;
+  def AutoInstallMainExecutable: Property<"auto-install-main-executable", "Boolean">,
+DefaultTrue,
+Desc<"Always install the main executable when connected to a remote platform.">;
 }
 
 let Definition = "process" in {
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -2691,8 +2691,10 @@
   if (platform_sp) {
 if (platform_sp->IsRemote()) {
   if (platform_sp->IsConnected()) {
-// Install all files that have an install path, and always install the
-// main executable when connected to a remote platform
+// Install all files that have an install path when connected to a
+// remote platform. If target.auto-install-main-executable is set then
+// also install the main executable even if it does not have an explicit
+// install path specified.
 const ModuleList &modules = GetImages();
 const size_t num_images = modules.GetSize();
 for (size_t idx = 0; idx < num_images; ++idx) {
@@ -2703,10 +2705,8 @@
 if (local_file) {
   FileSpec remote_file(module_sp->GetRemoteInstallFileSpec());
   if (!remote_file) {
-if (is_main_executable) // TODO: add setting for always
-// installing main executable???
-{
-  // Always install the main executable
+if (is_main_executable && GetAutoInstallMainExecutable()) {
+  // Automatically install the main executable.
   remote_file = platform_sp->GetRemoteWorkingDirectory();
   remote_file.AppendPathComponent(
   module_sp->GetFileSpec().GetFilename().GetCString());
@@ -3970,6 +3970,12 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
 }
 
+bool TargetProperties::GetAutoInstallMainExecutable() const {
+  const uint32_t idx = ePropertyAutoInstallMainExecutable;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_target_properties[idx].default_uint_value != 0);
+}
+
 void TargetProperties::Arg0ValueChangedCallback() {
   m_launch_info.SetArg0(GetArg0());
 }
Index: lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/main.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/main.cpp
@@ -0,0 +1,8 @@
+#include 
+
+const char* build = BUILD;
+
+int main(int argc, char **argv) {
+  printf("argc: %d\n", argc);
+  return argv[0][0];
+}
Index: lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
@@ -0,0 +1,137 @@
+"""
+Test target commands: target.auto-install-main-executable.
+"""
+
+import time
+import gdbremote_testcase
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestAutoInstallMainExecutable(gdbremote_testcase.GdbRemoteTestCaseBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+super(TestAutoInstallMainExecutable, self).setUp()
+self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+def tearDown(self):
+lldb.DBG.SetSelectedPlatform(self._initial_platform)
+super(TestAutoInstallMainExecutable, self).tearDown()
+
+@llgs_test
+@no_debug_info_test
+@skipIf(remote=False)
+@expectedFailureAll(hostoslist=["windows"], triple='.*-android')
+def test

[Lldb-commits] [lldb] 9bb1178 - Revert "[lldb] Add a setting to not install the main executable"

2020-01-21 Thread Francesco Petrogalli via lldb-commits

Author: Francesco Petrogalli
Date: 2020-01-21T19:24:02Z
New Revision: 9bb11785dca6b8ee1edb69b52c936edc95a794f0

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

LOG: Revert "[lldb] Add a setting to not install the main executable"

The commit has been reverted as it does not mention the author of the
patch.

This reverts commit 7c9bcba644c4fc2178e20060d9ba2ff1f50ae15e.

Added: 


Modified: 
lldb/include/lldb/Target/Target.h
lldb/source/Target/Target.cpp
lldb/source/Target/TargetProperties.td

Removed: 

lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/Makefile

lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py

lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/main.cpp



diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 4396f05c75aa..1e9153c401ef 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -207,8 +207,6 @@ class TargetProperties : public Properties {
 
   bool GetRequireHardwareBreakpoints() const;
 
-  bool GetAutoInstallMainExecutable() const;
-
 private:
   // Callbacks for m_launch_info.
   void Arg0ValueChangedCallback();

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/Makefile
 
b/lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/Makefile
deleted file mode 100644
index 1354ec49464a..
--- 
a/lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-CXX_SOURCES := main.cpp
-CXXFLAGS := -DBUILD=\"stock\"
-
-a.out: a.device.out
-
-include Makefile.rules
-
-a.device.out:
-   $(CXX) $(CXXFLAGS) -DBUILD=\"device\" -o $@ $(SRCDIR)/main.cpp

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
 
b/lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
deleted file mode 100644
index 0169cd494f54..
--- 
a/lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
+++ /dev/null
@@ -1,137 +0,0 @@
-"""
-Test target commands: target.auto-install-main-executable.
-"""
-
-import time
-import gdbremote_testcase
-
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class TestAutoInstallMainExecutable(gdbremote_testcase.GdbRemoteTestCaseBase):
-mydir = TestBase.compute_mydir(__file__)
-
-def setUp(self):
-super(TestAutoInstallMainExecutable, self).setUp()
-self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-def tearDown(self):
-lldb.DBG.SetSelectedPlatform(self._initial_platform)
-super(TestAutoInstallMainExecutable, self).tearDown()
-
-@llgs_test
-@no_debug_info_test
-@skipIf(remote=False)
-@expectedFailureAll(hostoslist=["windows"], triple='.*-android')
-def test_target_auto_install_main_executable(self):
-self.build()
-self.init_llgs_test(False)
-
-# Manually install the modified binary.
-working_dir = lldb.remote_platform.GetWorkingDirectory()
-src_device = lldb.SBFileSpec(self.getBuildArtifact("a.device.out"))
-dest = lldb.SBFileSpec(os.path.join(working_dir, "a.out"))
-err = lldb.remote_platform.Put(src_device, dest)
-if err.Fail():
-raise RuntimeError(
-"Unable copy '%s' to '%s'.\n>>> %s" %
-(src_device.GetFilename(), working_dir, err.GetCString()))
-
-m = re.search("^(.*)://([^/]*):(.*)$", configuration.lldb_platform_url)
-protocol = m.group(1)
-hostname = m.group(2)
-hostport = int(m.group(3))
-listen_url = "*:"+str(hostport+1)
-
-commandline_args = [
-"platform",
-"--listen",
-listen_url,
-"--server"
-]
-
-self.spawnSubprocess(
-self.debug_monitor_exe,
-commandline_args,
-install_remote=False)
-self.addTearDownHook(self.cleanupSubprocesses)
-
-# Wait for the new process gets ready.
-time.sleep(0.1)
-
-new_debugger = lldb.SBDebugger.Create()
-new_debugger.SetAsync(False)
-
-def del_debugger(new_debugger=new_debugger):
-del new_debugger
-self.addTearDownHook(del_debugger)
-
-new_platform = lldb.SBPlatform(lldb.remote_platform.GetName())
-new_debugger.SetSelectedPlatform(new_platform)
-new_interpreter = new_debugger.GetC

[Lldb-commits] [lldb] 95116c5 - [lldb] Add a setting to not install the main executable

2020-01-21 Thread Francesco Petrogalli via lldb-commits

Author: Daniel Kiss
Date: 2020-01-21T19:26:18Z
New Revision: 95116c591fab993df76bd20cfa74d2d44a1a9cc6

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

LOG: [lldb] Add a setting to not install the main executable

Summary:
Add setting target.auto-install-main-executable that controls whether
the main executable should be automatically installed when connected to
a remote platform even if it does not have an explicit install path
specified. The default is true as the current behaviour.

Reviewers: omjavaid, JDevlieghere, srhines, labath, clayborg

Reviewed By: clayborg

Subscribers: kevin.brodsky, lldb-commits, llvm-commits

Tags: #lldb

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

Added: 

lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/Makefile

lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py

lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/main.cpp

Modified: 
lldb/include/lldb/Target/Target.h
lldb/source/Target/Target.cpp
lldb/source/Target/TargetProperties.td

Removed: 




diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 1e9153c401ef..4396f05c75aa 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -207,6 +207,8 @@ class TargetProperties : public Properties {
 
   bool GetRequireHardwareBreakpoints() const;
 
+  bool GetAutoInstallMainExecutable() const;
+
 private:
   // Callbacks for m_launch_info.
   void Arg0ValueChangedCallback();

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/Makefile
 
b/lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/Makefile
new file mode 100644
index ..1354ec49464a
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/Makefile
@@ -0,0 +1,9 @@
+CXX_SOURCES := main.cpp
+CXXFLAGS := -DBUILD=\"stock\"
+
+a.out: a.device.out
+
+include Makefile.rules
+
+a.device.out:
+   $(CXX) $(CXXFLAGS) -DBUILD=\"device\" -o $@ $(SRCDIR)/main.cpp

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
 
b/lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
new file mode 100644
index ..0169cd494f54
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
@@ -0,0 +1,137 @@
+"""
+Test target commands: target.auto-install-main-executable.
+"""
+
+import time
+import gdbremote_testcase
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestAutoInstallMainExecutable(gdbremote_testcase.GdbRemoteTestCaseBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+super(TestAutoInstallMainExecutable, self).setUp()
+self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+def tearDown(self):
+lldb.DBG.SetSelectedPlatform(self._initial_platform)
+super(TestAutoInstallMainExecutable, self).tearDown()
+
+@llgs_test
+@no_debug_info_test
+@skipIf(remote=False)
+@expectedFailureAll(hostoslist=["windows"], triple='.*-android')
+def test_target_auto_install_main_executable(self):
+self.build()
+self.init_llgs_test(False)
+
+# Manually install the modified binary.
+working_dir = lldb.remote_platform.GetWorkingDirectory()
+src_device = lldb.SBFileSpec(self.getBuildArtifact("a.device.out"))
+dest = lldb.SBFileSpec(os.path.join(working_dir, "a.out"))
+err = lldb.remote_platform.Put(src_device, dest)
+if err.Fail():
+raise RuntimeError(
+"Unable copy '%s' to '%s'.\n>>> %s" %
+(src_device.GetFilename(), working_dir, err.GetCString()))
+
+m = re.search("^(.*)://([^/]*):(.*)$", configuration.lldb_platform_url)
+protocol = m.group(1)
+hostname = m.group(2)
+hostport = int(m.group(3))
+listen_url = "*:"+str(hostport+1)
+
+commandline_args = [
+"platform",
+"--listen",
+listen_url,
+"--server"
+]
+
+self.spawnSubprocess(
+self.debug_monitor_exe,
+commandline_args,
+install_remote=False)
+self.addTearDownHook(self.cleanupSubprocesses)
+
+# Wait for the new process gets ready.
+time.sleep(0.1)
+
+new_debugger = lldb.SBDebugger.Create()
+new_debugger.

[Lldb-commits] [PATCH] D69933: [ASTImporter] Limit imports of structs

2020-01-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

I really don't think the ASTImporter should ever manipulate records in the 
source context (effectively the source context should be considered immutable). 
It also seems *very* wrong that what we import depends in any way on a previous 
expression so I agree we should fix that. In theory the ImportDefinition call 
in the ASTImporter shouldn't do any real work as we have the MinimalImport mode 
on in LLDB so it should only load some bare bone record with external storage 
IIUC. So I think the original version of the patch seems like a better approach 
to me from a quick glance.

In D69933#1830602 , @jarin wrote:

> This is achieved in a hacky way - if we have a complete record R, we pretend 
> it is incomplete by temporarily clearing R's isCompleteDefinition bit. 
> Interestingly, this hack is already used in 
> ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo.


I don't think we do the same hack in the 
`ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo`. There we forcibly 
set the complete definition bit of the target to the value of the source (and 
never touch the source AST). But this code also seems really shady as I can't 
see why we would ever have to do that unless the import goes wrong.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69933



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


[Lldb-commits] [PATCH] D73116: [lldb/Initializers] Move all macOS initializers into PlatformMacOSX

2020-01-21 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

This change is causing a build break on Windows (which was hidden by the 
Hexagon build break you just fixed :().

http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/12857/steps/build/logs/stdio


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73116



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


[Lldb-commits] [PATCH] D73121: [lldb/Initializers] Move all ObjC initializers into AppleObjCRuntime

2020-01-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere marked 2 inline comments as done.
JDevlieghere added inline comments.



Comment at: 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp:58
+void AppleObjCRuntime::Initialize() {
+  AppleObjCRuntimeV2::Initialize();
+  AppleObjCRuntimeV1::Initialize();

shafik wrote:
> I am curious does order matter? Same below for `Terminate`
I've kept the same order but I don't think it matters.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D73121



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


[Lldb-commits] [PATCH] D71770: [lldb] Don't process symlinks deep inside DWARFUnit

2020-01-21 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Looks like this broke the ASAN bot?

http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-sanitized/783/testReport/junit/lldb-api/functionalities_breakpoint_comp_dir_symlink/TestCompDirSymLink_py/

lldb-api.functionalities/breakpoint/comp_dir_symlink.TestCompDirSymLink.py 
(from lldb-api):

  =
  ==83604==ERROR: AddressSanitizer: SEGV on unknown address 0x (pc 
0x7fff77668712 bp 0x7ffee0e29f10 sp 0x7ffee0e29f10 T0)
  ==83604==The signal is caused by a READ memory access.
  ==83604==Hint: address points to the zero page.
  #0 0x7fff77668712 in _platform_strlen+0x12 
(libsystem_platform.dylib:x86_64+0x1712)
  #1 0x10ee1191b in wrap_readlink+0x5b 
(libclang_rt.asan_osx_dynamic.dylib:x86_64+0x3991b)
  #2 0x119a61e57 in 
lldb_private::FileSystem::Readlink(lldb_private::FileSpec const&, 
lldb_private::FileSpec&) FileSystemPosix.cpp:46
  #3 0x1197f4b0d in 
lldb_private::ModuleListProperties::UpdateSymlinkMappings() ModuleList.cpp:122
  #4 0x119af5664 in 
lldb_private::OptionValueFileSpecList::SetValueFromString(llvm::StringRef, 
lldb_private::VarSetOperationType) OptionValueFileSpecList.cpp
  #5 0x119b01851 in 
lldb_private::OptionValueProperties::SetSubValue(lldb_private::ExecutionContext 
const*, lldb_private::VarSetOperationType, llvm::StringRef, llvm::StringRef) 
OptionValueProperties.cpp:209
  #6 0x119886a80 in 
lldb_private::Properties::SetPropertyValue(lldb_private::ExecutionContext 
const*, lldb_private::VarSetOperationType, llvm::StringRef, llvm::StringRef) 
UserSettingsController.cpp:49
  #7 0x1197234cb in 
lldb_private::Debugger::SetPropertyValue(lldb_private::ExecutionContext const*, 
lldb_private::VarSetOperationType, llvm::StringRef, llvm::StringRef) 
Debugger.cpp:275
  #8 0x11c2e19ef in CommandObjectSettingsSet::DoExecute(llvm::StringRef, 
lldb_private::CommandReturnObject&) CommandObjectSettings.cpp:222
  #9 0x119aba342 in lldb_private::CommandObjectRaw::Execute(char const*, 
lldb_private::CommandReturnObject&) CommandObject.cpp:1003
  #10 0x119a94b4a in lldb_private::CommandInterpreter::HandleCommand(char 
const*, lldb_private::LazyBool, lldb_private::CommandReturnObject&, 
lldb_private::ExecutionContext*, bool, bool) CommandInterpreter.cpp:1762
  #11 0x118c1b547 in lldb::SBCommandInterpreter::HandleCommand(char const*, 
lldb::SBExecutionContext&, lldb::SBCommandReturnObject&, bool) 
SBCommandInterpreter.cpp:281
  #12 0x118c1a83a in lldb::SBCommandInterpreter::HandleCommand(char const*, 
lldb::SBCommandReturnObject&, bool) SBCommandInterpreter.cpp:259
  #13 0x1193cfa28 in _wrap_SBCommandInterpreter_HandleCommand(_object*, 
_object*) LLDBWrapPython.cpp:14074


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71770



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


[Lldb-commits] [PATCH] D71770: [lldb] Don't process symlinks deep inside DWARFUnit

2020-01-21 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Looks like a missing nullptr check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71770



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


[Lldb-commits] [PATCH] D70847: [lldb] Set executable module when adding modules to the Target

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

context is missing with this diff (use git diff -U999). Changes look good. 
We do need a test though. All we need to do is create a target with nothing, 
then add the image to the target and make sure the platform and arch are 
updated. No need to run anything. Seeing as this wasn't working before this 
change, we don't have a test that covers it. You can create an ELF file and run 
obj2yaml on it and save the text file into the test directory. The test can run 
yaml2obj to generate the file, create an empty target, use the API that his 
patch fixes and very info on the target.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70847



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


[Lldb-commits] [lldb] b6c62ef - [lldb/Platform] Re-add ifdef's to guard macOS-only code.

2020-01-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-21T12:26:52-08:00
New Revision: b6c62ef0871576dd03de2c0077ba15ad0be23f6b

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

LOG: [lldb/Platform] Re-add ifdef's to guard macOS-only code.

I moved the code from the system initializer to PlatformMacOSX. The
defines are still necessary because MacOSX is initialized on other
platforms where the other platforms are not available.

Added: 


Modified: 
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
index 081fed2322db..745918f255ab 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "PlatformMacOSX.h"
+#if defined(__APPLE__)
 #include "PlatformAppleTVSimulator.h"
 #include "PlatformAppleWatchSimulator.h"
 #include "PlatformDarwinKernel.h"
@@ -14,6 +15,7 @@
 #include "PlatformRemoteAppleTV.h"
 #include "PlatformRemoteAppleWatch.h"
 #include "PlatformiOSSimulator.h"
+#endif
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
@@ -40,6 +42,7 @@ static uint32_t g_initialize_count = 0;
 
 void PlatformMacOSX::Initialize() {
   PlatformDarwin::Initialize();
+#if defined(__APPLE__)
   PlatformiOSSimulator::Initialize();
   PlatformDarwinKernel::Initialize();
   PlatformAppleTVSimulator::Initialize();
@@ -47,6 +50,7 @@ void PlatformMacOSX::Initialize() {
   PlatformRemoteAppleTV::Initialize();
   PlatformRemoteAppleWatch::Initialize();
   PlatformRemoteAppleBridge::Initialize();
+#endif
 
   if (g_initialize_count++ == 0) {
 #if defined(__APPLE__)
@@ -67,6 +71,7 @@ void PlatformMacOSX::Terminate() {
 }
   }
 
+#if defined(__APPLE__)
   PlatformRemoteAppleBridge::Terminate();
   PlatformRemoteAppleWatch::Terminate();
   PlatformRemoteAppleTV::Terminate();
@@ -74,6 +79,7 @@ void PlatformMacOSX::Terminate() {
   PlatformAppleTVSimulator::Terminate();
   PlatformDarwinKernel::Terminate();
   PlatformiOSSimulator::Terminate();
+#endif
   PlatformDarwin::Terminate();
 }
 



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


Re: [Lldb-commits] [PATCH] D73116: [lldb/Initializers] Move all macOS initializers into PlatformMacOSX

2020-01-21 Thread Jonas Devlieghere via lldb-commits
Thanks, I was in meetings. Should be fixed

commit b6c62ef0871576dd03de2c0077ba15ad0be23f6b (HEAD -> master, origin/master)
Author: Jonas Devlieghere 
Date:   Tue Jan 21 12:25:45 2020 -0800

[lldb/Platform] Re-add ifdef's to guard macOS-only code.

I moved the code from the system initializer to PlatformMacOSX. The
defines are still necessary because MacOSX is initialized on other
platforms where the other platforms are not available.

On Tue, Jan 21, 2020 at 11:55 AM Stella Stamenova via Phabricator
 wrote:
>
> stella.stamenova added a comment.
>
> This change is causing a build break on Windows (which was hidden by the 
> Hexagon build break you just fixed :().
>
> http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/12857/steps/build/logs/stdio
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D73116/new/
>
> https://reviews.llvm.org/D73116
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D72963: When darwin-debug exec's inferior suspended, make debugserver know that suspend count is higher than normal

2020-01-21 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

We do have people that don't create debugserver and just use the installed one 
to avoid code signing. Will there be any issue with people using older 
debugservers?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72963



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


[Lldb-commits] [lldb] aa91ce3 - [lldb/CMake] Add check-lldb-shell and check-lldb-api targets for Xcode

2020-01-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-21T13:22:33-08:00
New Revision: aa91ce3e1dd53a614894d5bef515c5859eea368a

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

LOG: [lldb/CMake] Add check-lldb-shell and check-lldb-api targets for Xcode

The Xcode generator does not provide the auto-generated targets where
you can append a folder name to check-lldb. Instead add two custom lit
targets to run just the shell and api tests.

Added: 


Modified: 
lldb/test/API/CMakeLists.txt
lldb/test/Shell/CMakeLists.txt

Removed: 




diff  --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 0fe88337ba58..9aad9fc750ca 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -179,3 +179,11 @@ configure_lit_site_cfg(
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
+
+if (CMAKE_GENERATOR STREQUAL "Xcode")
+  # Xcode does not get the auto-generated targets. We need to create
+  # check-lldb-api manually.
+  add_lit_testsuite(check-lldb-api "Running lldb api test suite"
+${CMAKE_CURRENT_BINARY_DIR}
+DEPENDS lldb-test-deps)
+endif()

diff  --git a/lldb/test/Shell/CMakeLists.txt b/lldb/test/Shell/CMakeLists.txt
index 91b4e282204b..d203f1e093c7 100644
--- a/lldb/test/Shell/CMakeLists.txt
+++ b/lldb/test/Shell/CMakeLists.txt
@@ -7,3 +7,11 @@ configure_lit_site_cfg(
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit-lldb-init.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit-lldb-init)
+
+if (CMAKE_GENERATOR STREQUAL "Xcode")
+  # Xcode does not get the auto-generated targets. We need to create
+  # check-lldb-shell manually.
+  add_lit_testsuite(check-lldb-shell "Running lldb shell test suite"
+${CMAKE_CURRENT_BINARY_DIR}
+DEPENDS lldb-test-deps)
+endif()



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


[Lldb-commits] [lldb] 0478ead - [lldb/DataFormatters] Fix the `$$deference$$` synthetic child

2020-01-21 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-01-21T13:35:55-08:00
New Revision: 0478eadf73c191199cba12c85785cfafb8bfa174

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

LOG: [lldb/DataFormatters] Fix the `$$deference$$` synthetic child

Summary:
The ValueObject code checks for a special `$$dereference$$` synthetic
child to allow formatter providers to implement a natural
dereferencing behavior in `frame variable` for objects like smart
pointers.

This support was broken when used directly throught the Python API and
not trhough `frame variable`. The reason is that
SBFrame.FindVariable() will return by default the synthetic variable
if it exists, while `frame variable` will not do this eagerly. The
code in `ValueObject::Dereference()` accounted for the latter but not
for the former. The fix is trivial. The test change includes
additional covergage for the already-working bahevior as it wasn't
covered by the testsuite before.

This commit also adds a short piece of documentatione explaining that
it is possible (even advisable) to provide this synthetic child
outstide of the range of the normal children.

Reviewers: jingham

Subscribers: lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/docs/use/variable.rst

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp
lldb/source/Core/ValueObject.cpp

Removed: 




diff  --git a/lldb/docs/use/variable.rst b/lldb/docs/use/variable.rst
index 13a56637ecea..4e3f25eb6a4a 100644
--- a/lldb/docs/use/variable.rst
+++ b/lldb/docs/use/variable.rst
@@ -846,7 +846,7 @@ adheres to a given interface (the word is italicized 
because Python has no
 explicit notion of interface, by that word we mean a given set of methods must
 be implemented by the Python class):
 
-::
+.. code-block:: python
 
class SyntheticChildrenProvider:
   def __init__(self, valobj, internal_dict):
@@ -885,7 +885,28 @@ returning default no-children responses.
 
 If a synthetic child provider supplies a special child named
 ``$$dereference$$`` then it will be used when evaluating ``operator *`` and
-``operator ->`` in the frame variable command and related SB API functions.
+``operator ->`` in the frame variable command and related SB API
+functions. It is possible to declare this synthetic child without
+including it in the range of children displayed by LLDB. For example,
+this subset of a synthetic children provider class would allow the
+synthetic value to be dereferenced without actually showing any
+synthtic children in the UI:
+
+.. code-block:: python
+
+  class SyntheticChildrenProvider:
+  [...]
+  def num_children(self):
+  return 0
+  def get_child_index(self, name):
+  if name == '$$dereference$$':
+  return 0
+  return -1
+  def get_child_at_index(self, index):
+  if index == 0:
+  return 
+  return None
+
 
 For examples of how synthetic children are created, you are encouraged to look
 at examples/synthetic in the LLDB trunk. Please, be aware that the code in

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
index 5f908f76b0ab..9d4759100ce2 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
@@ -38,19 +38,9 @@ def setUp(self):
 
 def data_formatter_commands(self):
 """Test using Python synthetic children provider."""
-self.runCmd("file " + self.getBuildArtifact("a.out"), 
CURRENT_EXECUTABLE_SET)
-
-lldbutil.run_break_set_by_file_and_line(
-self, "main.cpp", self.line, num_expected_locations=1, 
loc_exact=True)
-
-self.runCmd("run", RUN_SUCCEEDED)
-
-process = self.dbg.GetSelectedTarget().GetProcess()
 
-# The stop reason of the thread should be breakpoint.
-self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
-substrs=['stopped',
- 'stop reason = breakpoint'])
+_, process, thread, _ = lldbutil.run_to_line_breakpoint(

[Lldb-commits] [PATCH] D73112: [lldb/DWARF] Remove one more auto-dwo method

2020-01-21 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/D73112/new/

https://reviews.llvm.org/D73112



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


[Lldb-commits] [PATCH] D73053: [lldb/DataFormatters] Fix the `$$deference$$` synthetic child

2020-01-21 Thread Frederic Riss via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0478eadf73c1: [lldb/DataFormatters] Fix the `$$deference$$` 
synthetic child (authored by friss).

Changed prior to commit:
  https://reviews.llvm.org/D73053?vs=239188&id=239425#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73053

Files:
  lldb/docs/use/variable.rst
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp
  lldb/source/Core/ValueObject.cpp

Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -2859,6 +2859,9 @@
 GetSyntheticValue()
 ->GetChildMemberWithName(ConstString("$$dereference$$"), true)
 .get();
+  } else if (IsSynthetic()) {
+m_deref_valobj =
+GetChildMemberWithName(ConstString("$$dereference$$"), true).get();
   }
 
   if (m_deref_valobj) {
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp
===
--- lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp
@@ -46,11 +46,17 @@
 wrapint(int X) : x(X) {}
 };
 
+struct wrapfoo
+{
+foo *ptr;
+};
+
 int main()
 {
 foo f00_1(1);
 foo *f00_ptr = new foo(12);
-
+wrapfoo wrapper{f00_ptr};
+
 f00_1.a++; // Set break point at this line.
 
 wrapint test_cast('A' +
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py
@@ -28,3 +28,29 @@
 
 def update(self):
 return True
+
+
+class wrapfooSynthProvider:
+
+def __init__(self, valobj, dict):
+self.valobj = valobj
+
+def num_children(self):
+return 1
+
+def get_child_at_index(self, index):
+if index == 0:
+return self.valobj.GetChildMemberWithName('ptr')
+if index == 1:
+return self.valobj.GetChildMemberWithName('ptr').Dereference()
+return None
+
+def get_child_index(self, name):
+if name == 'ptr':
+return 0
+if name == '$$dereference$$':
+return 1
+return -1
+
+def update(self):
+return True
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
@@ -38,19 +38,9 @@
 
 def data_formatter_commands(self):
 """Test using Python synthetic children provider."""
-self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
-
-lldbutil.run_break_set_by_file_and_line(
-self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
-
-self.runCmd("run", RUN_SUCCEEDED)
-
-process = self.dbg.GetSelectedTarget().GetProcess()
 
-# The stop reason of the thread should be breakpoint.
-self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
-substrs=['stopped',
- 'stop reason = breakpoint'])
+_, process, thread, _ = lldbutil.run_to_line_breakpoint(
+self, lldb.SBFileSpec("main.cpp"), self.line)
 
 # This is the function to remove the custom formats in order to have a
 # clean slate for the next test case.
@@ -72,6 +62,7 @@
 # now set up the synth
 self.runCmd("script from fooSynthProvider import *")
 self.runCmd("type synth add -l fooSynthProvider foo")
+self.runCmd("type synth add -l wrapfooSynthProvider wrapfoo")
 self.expect("type synthetic list foo", substrs=['fooSynthProvider'])
 
 # note that the value of fake_a depends on target byte order
@@ -147,6 +138,10 @@
 substrs=['r = 45',

[Lldb-commits] [lldb] 83a131b - Fix an over-suspend bug with LaunchInNewTerminalWithAppleScript sessions

2020-01-21 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2020-01-21T14:55:46-08:00
New Revision: 83a131b276426a0dc97f43c139a0f3b308f24154

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

LOG: Fix an over-suspend bug with LaunchInNewTerminalWithAppleScript sessions

When launching an inferior in a new terminal window via AppleScript
and the darwin-debug helper program, we could often end up with the
inferior process having a too-high suspend count, and it would never
resume execution.

lldb tries to wait until darwin-debug has finished its work and has
launched the inferior (WaitForProcessToSIGSTOP) but this wasn't
working correctly - and cannot be made to work.

This patch removes WaitForProcessToSIGSTOP, adds a special tiny
segment to the darwin-debug executable so it can be identified as
that binary (ExecExtraSuspend), and adds code to debugserver to
detect this segment.  When debugserver sees this segment, it notes
that the next exec will be done with a launch-suspended flag.  When
the next exec happens, debugserver forces an extra task_resume when
we resume the inferior.

An alternative approach would be if lldb could detect when the
inferior has been launched by darwin-debug unambiguously; monitoring
when the unix socket between darwin-debug and lldb was closed would
have been a reasonable way to do this too.



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

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/Host.mm
lldb/tools/darwin-debug/CMakeLists.txt
lldb/tools/debugserver/source/MacOSX/MachProcess.mm
lldb/tools/debugserver/source/MacOSX/MachTask.h
lldb/tools/debugserver/source/MacOSX/MachTask.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index 9febb8fb8b29..233734109c41 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -153,33 +153,6 @@
   return NULL;
 }
 
-static bool WaitForProcessToSIGSTOP(const lldb::pid_t pid,
-const int timeout_in_seconds) {
-  const int time_delta_usecs = 10;
-  const int num_retries = timeout_in_seconds / time_delta_usecs;
-  for (int i = 0; i < num_retries; i++) {
-struct proc_bsdinfo bsd_info;
-int error = ::proc_pidinfo(pid, PROC_PIDTBSDINFO, (uint64_t)0, &bsd_info,
-   PROC_PIDTBSDINFO_SIZE);
-
-switch (error) {
-case EINVAL:
-case ENOTSUP:
-case ESRCH:
-case EPERM:
-  return false;
-
-default:
-  break;
-
-case 0:
-  if (bsd_info.pbi_status == SSTOP)
-return true;
-}
-::usleep(time_delta_usecs);
-  }
-  return false;
-}
 #if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
 
 const char *applscript_in_new_tty = "tell application \"Terminal\"\n"
@@ -325,11 +298,6 @@ repeat with the_window in (get windows)\n\
   lldb_error = accept_thread->Join(&accept_thread_result);
   if (lldb_error.Success() && accept_thread_result) {
 pid = (intptr_t)accept_thread_result;
-
-// Wait for process to be stopped at the entry point by watching
-// for the process status to be set to SSTOP which indicates it it
-// SIGSTOP'ed at the entry point
-WaitForProcessToSIGSTOP(pid, 5);
   }
 
   llvm::sys::fs::remove(unix_socket_name);

diff  --git a/lldb/tools/darwin-debug/CMakeLists.txt 
b/lldb/tools/darwin-debug/CMakeLists.txt
index b902788f05ab..ab3dbf0060ab 100644
--- a/lldb/tools/darwin-debug/CMakeLists.txt
+++ b/lldb/tools/darwin-debug/CMakeLists.txt
@@ -1,3 +1,11 @@
+
+# Create an LC_SEGMENT with the special name ExecExtraSuspend which
+# debugserver can detect - it tells debugserver that it will exec a
+# process and that process will start suspended, so debugserver will
+# need to double-resume it to make it run.  A random file is copied
+# into the segment.
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} 
-Wl,-sectcreate,ExecExtraSuspend,ExecExtraSuspend,${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt")
+
 add_lldb_tool(darwin-debug ADD_TO_FRAMEWORK
   darwin-debug.cpp
 )

diff  --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm 
b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
index 40facdfb5cf9..e4ec6129f70c 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -734,6 +734,8 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary 
*options,
   this_seg.nsects = seg.nsects;
   this_seg.flags = seg.flags;
   inf.segments.push_back(this_seg);
+  if (this_seg.name == "ExecExtraSuspend")
+m_task.TaskWillExecProcessesSuspended();
 }
 if (lc.cmd == LC_SEGMENT_64) {
   struct segment_command_64 seg;
@@ -755,6 +757,8 @@ static bool FBSAddEventDataToOptions(

[Lldb-commits] [PATCH] D72963: When darwin-debug exec's inferior suspended, make debugserver know that suspend count is higher than normal

2020-01-21 Thread Jason Molenda 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 rG83a131b27642: Fix an over-suspend bug with 
LaunchInNewTerminalWithAppleScript sessions (authored by jasonmolenda).

Changed prior to commit:
  https://reviews.llvm.org/D72963?vs=238909&id=239440#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72963

Files:
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/tools/darwin-debug/CMakeLists.txt
  lldb/tools/debugserver/source/MacOSX/MachProcess.mm
  lldb/tools/debugserver/source/MacOSX/MachTask.h
  lldb/tools/debugserver/source/MacOSX/MachTask.mm

Index: lldb/tools/debugserver/source/MacOSX/MachTask.mm
===
--- lldb/tools/debugserver/source/MacOSX/MachTask.mm
+++ lldb/tools/debugserver/source/MacOSX/MachTask.mm
@@ -69,7 +69,8 @@
 //--
 MachTask::MachTask(MachProcess *process)
 : m_process(process), m_task(TASK_NULL), m_vm_memory(),
-  m_exception_thread(0), m_exception_port(MACH_PORT_NULL) {
+  m_exception_thread(0), m_exception_port(MACH_PORT_NULL),
+  m_exec_will_be_suspended(false), m_do_double_resume(false) {
   memset(&m_exc_port_info, 0, sizeof(m_exc_port_info));
 }
 
@@ -103,6 +104,14 @@
   err = BasicInfo(task, &task_info);
 
   if (err.Success()) {
+if (m_do_double_resume && task_info.suspend_count == 2) {
+  err = ::task_resume(task);
+  if (DNBLogCheckLogBit(LOG_TASK) || err.Fail())
+err.LogThreaded("::task_resume double-resume after exec-start-stopped "
+"( target_task = 0x%4.4x )", task);
+}
+m_do_double_resume = false;
+  
 // task_resume isn't counted like task_suspend calls are, are, so if the
 // task is not suspended, don't try and resume it since it is already
 // running
@@ -135,6 +144,8 @@
   m_task = TASK_NULL;
   m_exception_thread = 0;
   m_exception_port = MACH_PORT_NULL;
+  m_exec_will_be_suspended = false;
+  m_do_double_resume = false;
 }
 
 //--
@@ -651,6 +662,9 @@
 err.LogThreaded("::mach_port_deallocate ( task = 0x%4.4x, name = 0x%4.4x )",
 task_self, exception_port);
 
+  m_exec_will_be_suspended = false;
+  m_do_double_resume = false;
+
   return err.Status();
 }
 
@@ -960,4 +974,14 @@
 void MachTask::TaskPortChanged(task_t task)
 {
   m_task = task;
+
+  // If we've just exec'd to a new process, and it
+  // is started suspended, we'll need to do two
+  // task_resume's to get the inferior process to
+  // continue.
+  if (m_exec_will_be_suspended)
+m_do_double_resume = true;
+  else
+m_do_double_resume = false;
+  m_exec_will_be_suspended = false;
 }
Index: lldb/tools/debugserver/source/MacOSX/MachTask.h
===
--- lldb/tools/debugserver/source/MacOSX/MachTask.h
+++ lldb/tools/debugserver/source/MacOSX/MachTask.h
@@ -85,6 +85,7 @@
   const MachProcess *Process() const { return m_process; }
 
   nub_size_t PageSize();
+  void TaskWillExecProcessesSuspended() { m_exec_will_be_suspended = true; }
 
 protected:
   MachProcess *m_process; // The mach process that owns this MachTask
@@ -97,6 +98,12 @@
 // need it
   mach_port_t m_exception_port; // Exception port on which we will receive child
 // exceptions
+  bool m_exec_will_be_suspended; // If this task exec's another process, that
+// process will be launched suspended and we will
+// need to execute one extra Resume to get it
+// to progress from dyld_start.
+  bool m_do_double_resume;  // next time we task_resume(), do it twice to
+// fix a too-high suspend count.
 
   typedef std::map allocation_collection;
   allocation_collection m_allocations;
Index: lldb/tools/debugserver/source/MacOSX/MachProcess.mm
===
--- lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -734,6 +734,8 @@
   this_seg.nsects = seg.nsects;
   this_seg.flags = seg.flags;
   inf.segments.push_back(this_seg);
+  if (this_seg.name == "ExecExtraSuspend")
+m_task.TaskWillExecProcessesSuspended();
 }
 if (lc.cmd == LC_SEGMENT_64) {
   struct segment_command_64 seg;
@@ -755,6 +757,8 @@
   this_seg.nsects = seg.nsects;
   this_seg.flags = seg.flags;
   inf.segments.push_back(this_seg);
+  if (this_seg.name == "ExecExtraSuspend")
+m_task.TaskWillExecProcessesSuspended();
 }
 if (lc.cmd == LC_UUID) {
   

[Lldb-commits] [lldb] 7745990 - [lldb/Plugin] Rename TSanRuntime for consistency with plugin (NFC)

2020-01-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-21T15:02:41-08:00
New Revision: 7745990dd93267d73e08ac5d9e5104645791a70e

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

LOG: [lldb/Plugin] Rename TSanRuntime for consistency with plugin (NFC)

Renames TSanRuntime to InstrumentationRuntimeTSan to be
consistent with the directory structure and plugin name.

Added: 

lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.h

Modified: 
lldb/source/API/SystemInitializerFull.cpp
lldb/source/Plugins/InstrumentationRuntime/TSan/CMakeLists.txt
lldb/tools/lldb-test/SystemInitializerTest.cpp

Removed: 
lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp
lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h



diff  --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index 9c5f53d1e68b..4be9904fb28d 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -56,7 +56,7 @@
 #include "Plugins/Instruction/PPC64/EmulateInstructionPPC64.h"
 #include "Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h"
 #include 
"Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h"
-#include "Plugins/InstrumentationRuntime/TSan/TSanRuntime.h"
+#include "Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.h"
 #include "Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h"
 #include "Plugins/JITLoader/GDB/JITLoaderGDB.h"
 #include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
@@ -223,7 +223,7 @@ llvm::Error SystemInitializerFull::Initialize() {
   minidump::ProcessMinidump::Initialize();
   MemoryHistoryASan::Initialize();
   InstrumentationRuntimeASan::Initialize();
-  ThreadSanitizerRuntime::Initialize();
+  InstrumentationRuntimeTSan::Initialize();
   UndefinedBehaviorSanitizerRuntime::Initialize();
   MainThreadCheckerRuntime::Initialize();
 
@@ -317,7 +317,7 @@ void SystemInitializerFull::Terminate() {
   minidump::ProcessMinidump::Terminate();
   MemoryHistoryASan::Terminate();
   InstrumentationRuntimeASan::Terminate();
-  ThreadSanitizerRuntime::Terminate();
+  InstrumentationRuntimeTSan::Terminate();
   UndefinedBehaviorSanitizerRuntime::Terminate();
   MainThreadCheckerRuntime::Terminate();
   wasm::SymbolVendorWasm::Terminate();

diff  --git a/lldb/source/Plugins/InstrumentationRuntime/TSan/CMakeLists.txt 
b/lldb/source/Plugins/InstrumentationRuntime/TSan/CMakeLists.txt
index 4dcd34131b8e..a388cbb2ddfe 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/TSan/CMakeLists.txt
+++ b/lldb/source/Plugins/InstrumentationRuntime/TSan/CMakeLists.txt
@@ -1,5 +1,5 @@
 add_lldb_library(lldbPluginInstrumentationRuntimeTSan PLUGIN
-  TSanRuntime.cpp
+  InstrumentationRuntimeTSan.cpp
 
   LINK_LIBS
 lldbBreakpoint

diff  --git a/lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp 
b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
similarity index 95%
rename from lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp
rename to 
lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
index 45a3aeeb204e..699876690fae 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp
+++ 
b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
@@ -1,4 +1,4 @@
-//===-- TSanRuntime.cpp -*- C++ 
-*-===//
+//===-- InstrumentationRuntimeTSan.cpp --*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-#include "TSanRuntime.h"
+#include "InstrumentationRuntimeTSan.h"
 
 #include "Plugins/Process/Utility/HistoryThread.h"
 #include "lldb/Breakpoint/StoppointCallbackContext.h"
@@ -36,29 +36,29 @@ using namespace lldb;
 using namespace lldb_private;
 
 lldb::InstrumentationRuntimeSP
-ThreadSanitizerRuntime::CreateInstance(const lldb::ProcessSP &process_sp) {
-  return InstrumentationRuntimeSP(new ThreadSanitizerRuntime(process_sp));
+InstrumentationRuntimeTSan::CreateInstance(const lldb::ProcessSP &process_sp) {
+  return InstrumentationRuntimeSP(new InstrumentationRuntimeTSan(process_sp));
 }
 
-void ThreadSanitizerRuntime::Initialize() {
+void InstrumentationRuntimeTSan::Initialize() {
   PluginManager::RegisterPlugin(
   GetPluginNameStatic(), "ThreadSanitizer instrumentation runtime plugin.",
   CreateInstance, GetTypeStatic);
 }
 
-void ThreadSanitizerRuntime::Ter

[Lldb-commits] [lldb] 0feedeb - [lldb/Plugin] Rename AddressSanitizerRuntime for consistency with plugin (NFC)

2020-01-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-21T15:02:41-08:00
New Revision: 0feedebf4f4b2a888c0d66e2347342234b6fc5ff

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

LOG: [lldb/Plugin] Rename AddressSanitizerRuntime for consistency with plugin 
(NFC)

Renames AddressSanitizerRuntime to InstrumentationRuntimeASan to be
consistent with the directory structure and plugin name.

Added: 

lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h

Modified: 
lldb/source/API/SystemInitializerFull.cpp
lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
lldb/tools/lldb-test/SystemInitializerTest.cpp

Removed: 
lldb/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp
lldb/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h



diff  --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index 80f92a8709d5..9c5f53d1e68b 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -54,7 +54,7 @@
 #include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h"
 #include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
 #include "Plugins/Instruction/PPC64/EmulateInstructionPPC64.h"
-#include "Plugins/InstrumentationRuntime/ASan/ASanRuntime.h"
+#include "Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h"
 #include 
"Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h"
 #include "Plugins/InstrumentationRuntime/TSan/TSanRuntime.h"
 #include "Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h"
@@ -222,7 +222,7 @@ llvm::Error SystemInitializerFull::Initialize() {
   ProcessMachCore::Initialize();
   minidump::ProcessMinidump::Initialize();
   MemoryHistoryASan::Initialize();
-  AddressSanitizerRuntime::Initialize();
+  InstrumentationRuntimeASan::Initialize();
   ThreadSanitizerRuntime::Initialize();
   UndefinedBehaviorSanitizerRuntime::Initialize();
   MainThreadCheckerRuntime::Initialize();
@@ -316,7 +316,7 @@ void SystemInitializerFull::Terminate() {
   ProcessMachCore::Terminate();
   minidump::ProcessMinidump::Terminate();
   MemoryHistoryASan::Terminate();
-  AddressSanitizerRuntime::Terminate();
+  InstrumentationRuntimeASan::Terminate();
   ThreadSanitizerRuntime::Terminate();
   UndefinedBehaviorSanitizerRuntime::Terminate();
   MainThreadCheckerRuntime::Terminate();

diff  --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
index dc7464fd1939..0b2902701846 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
+++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
@@ -1,5 +1,5 @@
 add_lldb_library(lldbPluginInstrumentationRuntimeASan PLUGIN
-  ASanRuntime.cpp
+  InstrumentationRuntimeASan.cpp
 
   LINK_LIBS
 lldbBreakpoint

diff  --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
similarity index 89%
rename from lldb/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp
rename to 
lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
index 2e5dd5989e77..b84b8a1f4a59 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp
+++ 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
@@ -1,4 +1,4 @@
-//===-- ASanRuntime.cpp -*- C++ 
-*-===//
+//===-- InstrumentationRuntimeASan.cpp --*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-#include "ASanRuntime.h"
+#include "InstrumentationRuntimeASan.h"
 
 #include "lldb/Breakpoint/StoppointCallbackContext.h"
 #include "lldb/Core/Debugger.h"
@@ -31,39 +31,39 @@ using namespace lldb;
 using namespace lldb_private;
 
 lldb::InstrumentationRuntimeSP
-AddressSanitizerRuntime::CreateInstance(const lldb::ProcessSP &process_sp) {
-  return InstrumentationRuntimeSP(new AddressSanitizerRuntime(process_sp));
+InstrumentationRuntimeASan::CreateInstance(const lldb::ProcessSP &process_sp) {
+  return InstrumentationRuntimeSP(new InstrumentationRuntimeASan(process_sp));
 }
 
-void AddressSanitizerRuntime::Initialize() {
+void InstrumentationRuntimeASan::Initialize() {
   PluginManager::RegisterPlugin(
   GetPluginNameStatic(), "AddressSanitizer instrumentation runtime 
plugin.",
   CreateInstance, GetTypeStatic);
 }

[Lldb-commits] [lldb] be96042 - [lldb/Plugin] Move DisassemblerLLVMC for consistency with plugin (NFC)

2020-01-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-21T15:17:29-08:00
New Revision: be9604247e33146b53f270fd35c4a7c4a44fda53

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

LOG: [lldb/Plugin] Move DisassemblerLLVMC for consistency with plugin (NFC)

Rename the DisassemblerLLVMC directory from llvm to LLVMC to match the
plugin name.

Added: 
lldb/source/Plugins/Disassembler/LLVMC/CMakeLists.txt
lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h

Modified: 
lldb/source/API/SystemInitializerFull.cpp
lldb/source/Plugins/Disassembler/CMakeLists.txt
lldb/tools/lldb-test/SystemInitializerTest.cpp
lldb/unittests/Disassembler/TestArm64Disassembly.cpp
lldb/unittests/Disassembler/TestArmv7Disassembly.cpp
lldb/unittests/UnwindAssembly/ARM64/TestArm64InstEmulation.cpp
lldb/unittests/UnwindAssembly/PPC64/TestPPC64InstEmulation.cpp

Removed: 
lldb/source/Plugins/Disassembler/llvm/CMakeLists.txt
lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h



diff  --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index 720f1aad744b..6ae538045ffb 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -43,7 +43,7 @@
 #include "Plugins/Architecture/Arm/ArchitectureArm.h"
 #include "Plugins/Architecture/Mips/ArchitectureMips.h"
 #include "Plugins/Architecture/PPC64/ArchitecturePPC64.h"
-#include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h"
+#include "Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h"
 #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h"
 #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
 #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"

diff  --git a/lldb/source/Plugins/Disassembler/CMakeLists.txt 
b/lldb/source/Plugins/Disassembler/CMakeLists.txt
index 6e3c904d5a60..bec56765b60f 100644
--- a/lldb/source/Plugins/Disassembler/CMakeLists.txt
+++ b/lldb/source/Plugins/Disassembler/CMakeLists.txt
@@ -1 +1 @@
-add_subdirectory(llvm)
+add_subdirectory(LLVMC)

diff  --git a/lldb/source/Plugins/Disassembler/llvm/CMakeLists.txt 
b/lldb/source/Plugins/Disassembler/LLVMC/CMakeLists.txt
similarity index 100%
rename from lldb/source/Plugins/Disassembler/llvm/CMakeLists.txt
rename to lldb/source/Plugins/Disassembler/LLVMC/CMakeLists.txt

diff  --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp 
b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
similarity index 100%
rename from lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
rename to lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp

diff  --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h 
b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h
similarity index 100%
rename from lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h
rename to lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h

diff  --git a/lldb/tools/lldb-test/SystemInitializerTest.cpp 
b/lldb/tools/lldb-test/SystemInitializerTest.cpp
index b6cd146f4d88..d6c52f54998a 100644
--- a/lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ b/lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -33,7 +33,7 @@
 #include "Plugins/Architecture/Arm/ArchitectureArm.h"
 #include "Plugins/Architecture/Mips/ArchitectureMips.h"
 #include "Plugins/Architecture/PPC64/ArchitecturePPC64.h"
-#include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h"
+#include "Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h"
 #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h"
 #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
 #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"

diff  --git a/lldb/unittests/Disassembler/TestArm64Disassembly.cpp 
b/lldb/unittests/Disassembler/TestArm64Disassembly.cpp
index 2f631a64a0c5..23c8b6685701 100644
--- a/lldb/unittests/Disassembler/TestArm64Disassembly.cpp
+++ b/lldb/unittests/Disassembler/TestArm64Disassembly.cpp
@@ -15,7 +15,7 @@
 #include "lldb/Utility/ArchSpec.h"
 #include "lldb/Target/ExecutionContext.h"
 
-#include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h"
+#include "Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h"
 #include "llvm/Support/TargetSelect.h"
 
 using namespace lldb;

diff  --git a/lldb/unittests/Disassembler/TestArmv7Disassembly.cpp 
b/lldb/unittests/Disassembler/TestArmv7Disassembly.cpp
index 2acf818ff012..2b1253137df5 100644
--- a/lldb/unittests/Disassembler/TestArmv7Disassembly.cpp
+++ b/lldb/unittests/Disassembler/TestArmv7Disassembly.cpp
@@ -15,7 +15,7 @@
 #include "lldb/Utility/ArchSpec.h"
 #include "lldb/Target/Executi

[Lldb-commits] [PATCH] D73112: [lldb/DWARF] Remove one more auto-dwo method

2020-01-21 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Thanks for doing the cleanup. After we switched over to using the DWARFDie 
more, there are probably many more cleanups like this where the code didn't get 
converted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73112



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


[Lldb-commits] [lldb] fa00176 - Fix typos

2020-01-21 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2020-01-21T15:32:34-08:00
New Revision: fa001767f0856118e8e7c8f12c31ef7c3afe2b4e

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

LOG: Fix typos

Added: 


Modified: 
lldb/docs/use/symbols.rst
lldb/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile
lldb/packages/Python/lldbsuite/test/make/Makefile.rules
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp

Removed: 




diff  --git a/lldb/docs/use/symbols.rst b/lldb/docs/use/symbols.rst
index fe79782959a3..757d165b9e23 100644
--- a/lldb/docs/use/symbols.rst
+++ b/lldb/docs/use/symbols.rst
@@ -267,7 +267,7 @@ contains the DWARF. Whenever DebugSymbols.framework is 
asked to lookup a dSYM
 file, it will first look in any file mapped UUID directories for a quick match
 if the defaults are appropriately set.
 
-For example, if we take the sample UUID plist inforamtion from above, we can
+For example, if we take the sample UUID plist information from above, we can
 create a File Mapped UUID directory cache in
 **~/Library/SymbolCache/dsyms/uuids**. We can easily see how things are laid
 out:

diff  --git 
a/lldb/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile 
b/lldb/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile
index c39743d999da..f42ac2e81cc7 100644
--- a/lldb/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile
@@ -5,7 +5,7 @@ all: limit nolimit
 
 include Makefile.rules
 
-# Force a.cpp to be built with no debug inforamtion
+# Force a.cpp to be built with no debug information
 a.o: CFLAGS = $(CFLAGS_NO_DEBUG)
 
 # The default testsuite setup forces -fno-limit-debug-info. Let's not rely on

diff  --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index ecb75413a0c0..4ae54561a28f 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -43,9 +43,9 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 
 # The test harness invokes the test Makefiles with an explicit 'all'
 # target, but its handy to be able to recursively call this Makefile
-# without speficying a goal. You almost certainly want to build 'all',
+# without specifying a goal. You almost certainly want to build 'all',
 # and not only the first target defined in this file (which might vary
-# according to varaible values).
+# according to variable values).
 .DEFAULT_GOAL := all
 
 #--

diff  --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp 
b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index 7bef47e8eaee..f7f0b404eae8 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -1225,7 +1225,7 @@ void SymbolFilePDB::CacheFunctionNames() {
 
 // To search a method name, like NS::Class:MemberFunc, LLDB searches
 // its base name, i.e. MemberFunc by default. Since PDBSymbolFunc does
-// not have inforamtion of this, we extract base names and cache them
+// not have information of this, we extract base names and cache them
 // by our own effort.
 llvm::StringRef basename = MSVCUndecoratedNameParser::DropScope(name);
 if (!basename.empty())



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


[Lldb-commits] [PATCH] D73119: [lldb/Initializers] Rename plugins to match their entry points

2020-01-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 239452.

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

https://reviews.llvm.org/D73119

Files:
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/CMakeLists.txt
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt
  lldb/source/Plugins/EmulateInstruction/ARM/CMakeLists.txt
  lldb/source/Plugins/EmulateInstruction/ARM/EmulateInstructionARM.cpp
  lldb/source/Plugins/EmulateInstruction/ARM/EmulateInstructionARM.h
  lldb/source/Plugins/EmulateInstruction/ARM/EmulationStateARM.cpp
  lldb/source/Plugins/EmulateInstruction/ARM/EmulationStateARM.h
  lldb/source/Plugins/EmulateInstruction/ARM64/CMakeLists.txt
  lldb/source/Plugins/EmulateInstruction/ARM64/EmulateInstructionARM64.cpp
  lldb/source/Plugins/EmulateInstruction/ARM64/EmulateInstructionARM64.h
  lldb/source/Plugins/EmulateInstruction/CMakeLists.txt
  lldb/source/Plugins/EmulateInstruction/MIPS/CMakeLists.txt
  lldb/source/Plugins/EmulateInstruction/MIPS/EmulateInstructionMIPS.cpp
  lldb/source/Plugins/EmulateInstruction/MIPS/EmulateInstructionMIPS.h
  lldb/source/Plugins/EmulateInstruction/MIPS64/CMakeLists.txt
  lldb/source/Plugins/EmulateInstruction/MIPS64/EmulateInstructionMIPS64.cpp
  lldb/source/Plugins/EmulateInstruction/MIPS64/EmulateInstructionMIPS64.h
  lldb/source/Plugins/EmulateInstruction/PPC64/CMakeLists.txt
  lldb/source/Plugins/EmulateInstruction/PPC64/EmulateInstructionPPC64.cpp
  lldb/source/Plugins/EmulateInstruction/PPC64/EmulateInstructionPPC64.h
  lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  lldb/source/Plugins/Instruction/ARM/CMakeLists.txt
  lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
  lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
  lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
  lldb/source/Plugins/Instruction/ARM/EmulationStateARM.h
  lldb/source/Plugins/Instruction/ARM64/CMakeLists.txt
  lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
  lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
  lldb/source/Plugins/Instruction/CMakeLists.txt
  lldb/source/Plugins/Instruction/MIPS/CMakeLists.txt
  lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
  lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
  lldb/source/Plugins/Instruction/MIPS64/CMakeLists.txt
  lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
  lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
  lldb/source/Plugins/Instruction/PPC64/CMakeLists.txt
  lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp
  lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h
  lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
  lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt
  lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
  lldb/source/Plugins/LanguageRuntime/ObjC/CMakeLists.txt
  lldb/source/Plugins/ObjectContainer/Universal-Mach-O/CMakeLists.txt
  lldb/source/Plugins/OperatingSystem/Python/CMakeLists.txt
  lldb/source/Plugins/Platform/Android/CMakeLists.txt
  lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
  lldb/source/Plugins/Platform/CMakeLists.txt
  lldb/source/Plugins/Platform/RemoteGDBServer/CMakeLists.txt
  lldb/source/Plugins/Platform/RemoteGDBServer/PlatformRemoteGDBServer.cpp
  lldb/source/Plugins/Platform/RemoteGDBServer/PlatformRemoteGDBServer.h
  lldb/source/Plugins/Platform/gdb-server/CMakeLists.txt
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
  lldb/source/Plugins/Process/CMakeLists.txt
  lldb/source/Plugins/Process/KDP/CMakeLists.txt
  lldb/source/Plugins/Process/KDP/CommunicationKDP.cpp
  lldb/source/Plugins/Process/KDP/CommunicationKDP.h
  lldb/source/Plugins/Process/KDP/ProcessKDP.cpp
  lldb/source/Plugins/Process/KDP/ProcessKDP.h
  lldb/source/Plugins/Process/KDP/ProcessKDPLog.cpp
  lldb/source/Plugins/Process/KDP/ProcessKDPLog.h
  lldb/source/Plugins/Process/KDP/ProcessKDPProperties.td
  lldb/source/Plugins/Process/KDP/RegisterContextKDP_arm.cpp
  lldb/source/Plugins/Process/KDP/RegisterContextKDP_arm.h
  lldb/source/Plugins/Process/KDP/RegisterContextKDP_arm64.cpp
  lldb/source/Plugins/Process/KDP/RegisterContextKDP_arm64.h
  lldb/source/Plugins/Process/KDP/RegisterContextKDP_i386.cpp
  lldb/source/Plugins/Process/KDP/RegisterContextKDP_i386.h
  lldb/source/Plugins/Process/KDP/RegisterContextKDP_x86_64.cpp
  lldb/source/Plugins/Process/KDP/RegisterContextKDP_x86_64.h
  lldb/source/Plugins/Process/KDP/ThreadKDP.cpp
  lldb/source/Plugins/Process/KDP/ThreadKDP.h
  lldb/source/Plugins/Process/MacOSX-Kernel/CMakeLists.txt
  lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
  lldb/source/Plugins/Process/MacOSX-Kernel/

[Lldb-commits] [PATCH] D73148: [lldb/Value] Report size of Value as size of underlying data buffer

2020-01-21 Thread Vedant Kumar via Phabricator via lldb-commits
vsk created this revision.
vsk added reviewers: jingham, aprantl.

Value::GetValueByteSize() assumes that the size of a Value is always
equal to the size of the underlying variable's CompilerType. However,
llvm's DWARF generator doesn't appear to create fresh types with new
sizes when emitting fragments / DW_OP_piece. It seems like there's a
faulty assumption in lldb (although it's plausible that llvm is just
generating weird DWARF).

This patch teaches GetValueByteSize() to report the size of a Value as
the size of its data buffer if it's a host address.

I'm not sure whether this is an exhaustive fix. This does fix an ASan
error in lldb seen when debugging a clang binary.

ASan report: F11233245: asan-report-rdar58665925.txt 


rdar://58665925


https://reviews.llvm.org/D73148

Files:
  lldb/source/Core/Value.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp


Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -360,4 +360,16 @@
   // Note that the "00" should really be "undef", but we can't
   // represent that yet.
   llvm::HasValue(GetScalar(16, 0xff00, true)));
+
+  for (unsigned char ByteSize = 1; ByteSize <= 8; ++ByteSize) {
+llvm::Expected empty = Evaluate({DW_OP_piece, ByteSize});
+// Note that the "00" should really be "undef", but we can't
+// represent that yet.
+EXPECT_THAT_EXPECTED(empty,
+ llvm::HasValue(GetScalar(ByteSize * 8, 0, true)));
+
+Value pieces;
+ASSERT_EQ(pieces.AppendDataToHostBuffer(empty.get()), ByteSize);
+ASSERT_EQ(pieces.GetValueByteSize(nullptr, nullptr), ByteSize);
+  }
 }
Index: lldb/source/Core/Value.cpp
===
--- lldb/source/Core/Value.cpp
+++ lldb/source/Core/Value.cpp
@@ -222,6 +222,11 @@
   case eContextTypeLLDBType: // Type *
   case eContextTypeVariable: // Variable *
   {
+// The size of this Value may be less than the size of the type of its
+// source variable due to truncating operations such as DW_OP_piece.
+if (m_value_type == eValueTypeHostAddress)
+  return GetBuffer().GetByteSize();
+
 auto *scope = exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr;
 if (llvm::Optional size = GetCompilerType().GetByteSize(scope)) {
   if (error_ptr)


Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -360,4 +360,16 @@
   // Note that the "00" should really be "undef", but we can't
   // represent that yet.
   llvm::HasValue(GetScalar(16, 0xff00, true)));
+
+  for (unsigned char ByteSize = 1; ByteSize <= 8; ++ByteSize) {
+llvm::Expected empty = Evaluate({DW_OP_piece, ByteSize});
+// Note that the "00" should really be "undef", but we can't
+// represent that yet.
+EXPECT_THAT_EXPECTED(empty,
+ llvm::HasValue(GetScalar(ByteSize * 8, 0, true)));
+
+Value pieces;
+ASSERT_EQ(pieces.AppendDataToHostBuffer(empty.get()), ByteSize);
+ASSERT_EQ(pieces.GetValueByteSize(nullptr, nullptr), ByteSize);
+  }
 }
Index: lldb/source/Core/Value.cpp
===
--- lldb/source/Core/Value.cpp
+++ lldb/source/Core/Value.cpp
@@ -222,6 +222,11 @@
   case eContextTypeLLDBType: // Type *
   case eContextTypeVariable: // Variable *
   {
+// The size of this Value may be less than the size of the type of its
+// source variable due to truncating operations such as DW_OP_piece.
+if (m_value_type == eValueTypeHostAddress)
+  return GetBuffer().GetByteSize();
+
 auto *scope = exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr;
 if (llvm::Optional size = GetCompilerType().GetByteSize(scope)) {
   if (error_ptr)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D72748: [lldb/IOHandler] Change the way we manage IO handler

2020-01-21 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In D72748#1830638 , @labath wrote:

> In D72748#1829956 , @JDevlieghere 
> wrote:
>
> > In D72748#1823945 , @labath wrote:
> >
> > > I didn't actually try it but I am pretty sure this will deadlock with 
> > > nested lldb command files (running `command source` from a file that is 
> > > itself being sourced). Changing the mutex to a recursive_mutex would fix 
> > > that, but I don't believe it would make this fully correct -- it would 
> > > just make it harder to demonstrate that it's wrong. OTOH, that may be the 
> > > best thing we can do in the current state of affairs.
> > >
> > > The thing I don't understand now is why do we even need this stack in the 
> > > first place. It seems like this could be handled by just running a new 
> > > iohandler "main loop" instead of pushing something. Take the "expr" 
> > > command for example. In the single-line mode it evaluates the expression 
> > > synchronously, but in a multi-line expression, it returns immediately 
> > > after pushing it's own IOHandler (which then gathers the expression and 
> > > calls back into the command to run it). I don't see why we couldn't 
> > > achieve the same thing by "running" the iohandler directly, instead of 
> > > pushing it to some stack and waiting for it to be executed at the top 
> > > level. The same thing could be said for the "script" command and various 
> > > other things which "hijack" the main (lldb) iohandler.
> >
> >
> > Isn't the problem that you can't be sure your IO handler pushes another one 
> > on top of the stack? I considered an alternative implementation, where the 
> > synchronous IO handlers has its own stack and everything that's pushed 
> > while it is executing ends up on that stack. It adds a lot of complexity 
> > and you still need to synchronize with the "main loop"
>
>
> Well.. in the way I as imagining things, there would be no stacks (at least 
> no explicit stacks), no pushing, and everything would execute in the 
> "synchronous" mode. So e.g., when we start up the main "(lldb)" loop, we just 
> take that iohandler, and run it until it says it's done. If the user types 
> "script", then we start another "main loop" with the python iohandler, but 
> the main loop can be completely oblivious to that -- as far as it is 
> concerned, its iohandler is still executing `CommandObjectScript::DoExecute`. 
> When the user exits the python prompt the control returns to the (lldb) 
> iohandler just like it would after any other "simple" command. So, 
> essentially, there's still some stacking involved, but it's not managed 
> explicitly -- it just comes out from the way the code is organized. 
> Similarly, the "breakpoint command add" could run an iohandler to collect the 
> breakpoint commands, "process continue" could run a loop to forward the 
> inferior stdio, etc.
>
> (The last bit is tricky because of ^C, and it means that we will still need 
> to have some global notion of the "active" or "top" iohandler, which is the 
> one that receives ^Cs, but still, I think that it should be possible to run 
> everything "synchronously" and I hope that would get us rid of a lot of 
> complexity.)


The pushing and popping is done because of how the command interpreter works. 
Think about typing:

  (lldb) script

We are in the IOHandler for the command interpreter for LLDB commands and 
running the code for the "script" command in 
CommandObjectScript::DoExecute(...), and now we need to switch to the python 
interpreter.

Before doing this we might need to remove the "(lldb)" prompt from the screen 
if had already been redisplayed. The idea was while in 
CommandObjectScript::DoExecute(...) we can push a new IOHandler for python and 
let the current function exit. There might be some locks preventing multiple 
commands from executing at the same time, so best to avoid this if this is the 
case. Then when we return from CommandObjectScript::DoExecute(...) we can let 
the IOHandler stack do what it needs to do and switch to the python interpreter.

This flow also allows the "gui" command to do any curses setup and teardown at 
the right times as the IOHandler is pushed and popped.

When the previous IOHandler becomes active again, it can resume where it left 
off, like curses can clear the screen and re-display anything it needs to. So 
the stack does serve a purpose, but I am sure this can be done in another way 
and happy to try a new strategy.

One complexity you won't see here is how the REPL and LLDB prompt can switch 
back and forth. From the Swift REPL, you can drop into the lldb prompt and 
back, and for that we have some special handling that allows the two to switch 
without creating a whole new IOHandler each time they switch.

Also think about a file that is sourced with "command source" and where it it 
contains:

  target stop-hook add
  bt
  fr v

[Lldb-commits] [PATCH] D73148: [lldb/Value] Report size of Value as size of underlying data buffer

2020-01-21 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Would it be better to just ensure that the buffer for DW_OP_piece is at least 
the size of the type instead? To do this right we would really need to track 
which bytes in the buffer are actually valid. This patch assumes we will always 
get the first N bytes of a value. Is it possible to describe bytes 4:7 of a 16 
bit value where bits 0:3 and 8:15 are not valid? In this case, with this patch, 
we would think that bytes 0:3 are valid when they are just not specified, 4:7 
would be valid, and 8:15 would not display because our value doesn't contain 
the value.


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

https://reviews.llvm.org/D73148



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


[Lldb-commits] [PATCH] D73119: [lldb/Initializers] Rename plugins to match their entry points

2020-01-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

I think the remaining discrepancies between the plugin name and the directory 
make sense. For example, I don't really see the benefit of renaming 
`AppleObjCRuntime` to `LanguageRuntimeAppleObjeC`. The `ClangASTContext` is the 
exception, but I really don't want to rename that class :-)


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

https://reviews.llvm.org/D73119



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


[Lldb-commits] [PATCH] D69933: [ASTImporter] Limit imports of structs

2020-01-21 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Clang AST contexts know how to complete types and is done via the external AST 
source code that will ask a type to complete itself. Each object file has an 
AST that knows how to lazily complete a type when and only when it is needed. 
Each object file also only knows about the type information in the binary 
itself. So if we have a forward declaration to "Foo" with something like 
"struct Foo;" that is all the object file AST will ever know about this type. 
This is required because each module can be re-used on subsequent debug 
sessions if they haven't changed. So if we have a forward declaration for "Foo" 
in the AST for "bbb.so" that is ok. We don't want to copy some definition for 
"Foo" from "foo.so" over into bbb.so's AST context because if we run again and 
we get a new foo.so we would have to reload bbb.so because its copy of "Foo" 
might be out of date. And we would need to track these interactions.

When we run expressions, we create a new AST and copy types as needed. It would 
be great if the AST importer only copy over forward declarations of types that 
can be completed later and can also complete types only as needed when asked.

If I understand correctly that is what this patch is trying to do. Seems like 
we have a code path that is copying over the type and also completing it 
sometimes without being asked which should be fixed. If we do fix this, complex 
expressions become a lot faster. To do this right we should always import 
forward declarations from the source, and be able to complete the new types in 
the destination as needed. As teemperor said, the source AST should not be 
mutated in any way. We should track all of this in the importer and know where 
we should try to complete the type from.

When using expression AST contexts it **is** ok to try and import "Foo" from 
bbb.so since that where is where we first saw the type, and if we aren't 
successful, we can grab the definition from anywhere else in the debug session. 
Since each expression has its own AST, it **is** ok to get the type from 
anywhere. When searching for this type we should start in the current 
lldb_private::Block, their pareent blocks, then the file, then the module and 
then all modules. I think that works today already, but I am not sure if this 
works for a type "Foo" that is mentioned in a type from a file that doesn't 
have a complete definition. for example if bbb.so contains:

  struct Bar : public Foo {...};

Due to "-flimit-debug-info" the definition for Foo might be forward declared 
(if the vtable for Foo isn't in the current binary) and not included in this 
binary. This won't happen on darwin since the default is 
-fno-limit-debug-info". The DWARF parser knows how to work around this issue 
when creating the type in the AST for bbb.so, but when we run an expression 
with this type, we want to be able to have an AST type from bbb.so with an 
incomplete definition for "Foo" that we complete during AST import. To do this, 
we will need to use metadata in the bbb.so AST to indicate we have no 
definition for this type when we normally would require one and be able to 
complete the type from another source.

So quick things to stick to:

- no modification of the source AST context
- importer can track anything it needs to in order to complete types in complex 
situations as mentioned above
  - need metadata that tracks types that need to be complete but aren't in the 
debug info so they can be properly imported for expressions ("struct Bar: 
public Foo {}", not ok for Foo to not be complete but we allow it for object 
file AST contexts otherwise clang crashes us)
  - legal forward declarations should be able to be imported as needed even if 
the AST form the original source doesn't have a complete type ("struct Bar { 
Foo *foo_ptr; }", ok for Foo to be forward declared here)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69933



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


[Lldb-commits] [PATCH] D73148: [lldb/Value] Report size of Value as size of underlying data buffer

2020-01-21 Thread Vedant Kumar via Phabricator via lldb-commits
vsk added a comment.

In D73148#1832704 , @clayborg wrote:

> Would it be better to just ensure that the buffer for DW_OP_piece is at least 
> the size of the type instead? To do this right we would really need to track 
> which bytes in the buffer are actually valid. This patch assumes we will 
> always get the first N bytes of a value. Is it possible to describe bytes 4:7 
> of a 16 bit value where bits 0:3 and 8:15 are not valid? In this case, with 
> this patch, we would think that bytes 0:3 are valid when they are just not 
> specified, 4:7 would be valid, and 8:15 would not display because our value 
> doesn't contain the value.


It's not necessary for DW_OP_piece to produce a type-sized result buffer, as 
the description of an object must start at byte offset 0, and we represent the 
undefined bits within the Value either with 0 or by leaving them out. E.g. 
`Evaluate({DW_OP_piece, 1, DW_OP_const1u, 0xff, DW_OP_piece, 1, DW_OP_piece, 
1})` produces the 24-bit scalar `0x00ff00`, where the 0's correspond to the 
undefined low bits and the undefined high bits are left out. It /is/ a bug that 
we use 0 for undefined bits instead of `u` (or something), but we don't need a 
type-sized buffer to fix that (a bitset would suffice). Finding a way to 
improve the representation of undefined bits is something I'm interested in, 
but it seems like a separate problem, and it's more urgent for me to fix the 
memory smasher.

I'm also not sure that making DW_OP_piece produce a type-sized result would be 
a sufficient fix, as there (theoretically) may be clients of 
`Value::ResizeData()` other than the DW_OP_piece logic. I just count one, 
though (`ExpressionVariable::GetValueBytes()`), and I'm not sure whether it can 
resize the buffer to something other than the underlying type size.


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

https://reviews.llvm.org/D73148



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


[Lldb-commits] [PATCH] D73148: [lldb/Value] Report size of Value as size of underlying data buffer

2020-01-21 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

In D73148#1832762 , @vsk wrote:

> In D73148#1832704 , @clayborg wrote:
>
> > Would it be better to just ensure that the buffer for DW_OP_piece is at 
> > least the size of the type instead? To do this right we would really need 
> > to track which bytes in the buffer are actually valid. This patch assumes 
> > we will always get the first N bytes of a value. Is it possible to describe 
> > bytes 4:7 of a 16 bit value where bits 0:3 and 8:15 are not valid? In this 
> > case, with this patch, we would think that bytes 0:3 are valid when they 
> > are just not specified, 4:7 would be valid, and 8:15 would not display 
> > because our value doesn't contain the value.
>
>
> It's not necessary for DW_OP_piece to produce a type-sized result buffer, as 
> the description of an object must start at byte offset 0, and we represent 
> the undefined bits within the Value either with 0 or by leaving them out. 
> E.g. `Evaluate({DW_OP_piece, 1, DW_OP_const1u, 0xff, DW_OP_piece, 1, 
> DW_OP_piece, 1})` produces the 24-bit scalar `0x00ff00`, where the 0's 
> correspond to the undefined low bits and the undefined high bits are left 
> out. It /is/ a bug that we use 0 for undefined bits instead of `u` (or 
> something), but we don't need a type-sized buffer to fix that (a bitset would 
> suffice). Finding a way to improve the representation of undefined bits is 
> something I'm interested in, but it seems like a separate problem, and it's 
> more urgent for me to fix the memory smasher.
>
> I'm also not sure that making DW_OP_piece produce a type-sized result would 
> be a sufficient fix, as there (theoretically) may be clients of 
> `Value::ResizeData()` other than the DW_OP_piece logic. I just count one, 
> though (`ExpressionVariable::GetValueBytes()`), and I'm not sure whether it 
> can resize the buffer to something other than the underlying type size.


Thanks for the clarification. This will work for now.


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

https://reviews.llvm.org/D73148



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


[Lldb-commits] [PATCH] D73148: [lldb/Value] Report size of Value as size of underlying data buffer

2020-01-21 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Actually it would be nice to have a test that will trigger on at least one 
build bot that runs ASAN?


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

https://reviews.llvm.org/D73148



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


[Lldb-commits] [PATCH] D65282: ObjectFileELF: permit thread-local sections with overlapping file addresses

2020-01-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

I'm seeing some really weird behavior for the following two tests and I'm 
honestly kind of puzzled.

  ObjectFile/ELF/PT_LOAD-overlap-PT_TLS.yaml
  ObjectFile/ELF/PT_TLS-overlap-PT_LOAD.yaml

They fail in the same way for a standalone build, both on macOS 
(http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-standalone/1009/) and 
Linux 
(https://ci.swift.org/view/swift-master-rebranch/job/oss-lldb-master-rebranch-incremental-linux-ubuntu-18_04/8/).

For a standalone build the image lookups returns:

  (lldb) image lookup -a 0x1000
Address: PT_LOAD-overlap-PT_TLS.yaml.tmp[0x1000] 
(PT_LOAD-overlap-PT_TLS.yaml.tmp..tbss + 0)

While for a regular in-tree build the image lookup returns:

  (lldb) image lookup -a 0x1000
Address: PT_LOAD-overlap-PT_TLS.yaml.tmp[0x1000] 
(PT_LOAD-overlap-PT_TLS.yaml.tmp.PT_LOAD[0]..data + 0)

I scp'd the binaries between my local machine and the bot and they don't affect 
the outcome, it's just lldb that's different... Pavel, can you think of 
*anything* that might cause this?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D65282



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


[Lldb-commits] [lldb] 1d1ebb9 - [lldb/Initializers] Move all ObjC initializers into AppleObjCRuntime

2020-01-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-21T22:24:32-08:00
New Revision: 1d1ebb9e592bea931845296dd80a46fb46af2642

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

LOG: [lldb/Initializers] Move all ObjC initializers into AppleObjCRuntime

AppleObjCRuntime is the main entry point to the plugin with the same
name. This is part of a greater refactoring to auto generate the
initializers. NFC.

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

Added: 


Modified: 
lldb/source/API/SystemInitializerFull.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
lldb/tools/lldb-test/SystemInitializerTest.cpp

Removed: 




diff  --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index 6ae538045ffb..28c3b3b46a4b 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -63,8 +63,7 @@
 #include "Plugins/Language/ObjC/ObjCLanguage.h"
 #include "Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h"
 #include 
"Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h"
-#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h"
-#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
+#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
 #include 
"Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h"
 #include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
 #include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
@@ -244,8 +243,7 @@ llvm::Error SystemInitializerFull::Initialize() {
 
   SymbolFileDWARFDebugMap::Initialize();
   ItaniumABILanguageRuntime::Initialize();
-  AppleObjCRuntimeV2::Initialize();
-  AppleObjCRuntimeV1::Initialize();
+  AppleObjCRuntime::Initialize();
   SystemRuntimeMacOSX::Initialize();
   RenderScriptRuntime::Initialize();
 
@@ -338,8 +336,7 @@ void SystemInitializerFull::Terminate() {
 
   SymbolFileDWARFDebugMap::Terminate();
   ItaniumABILanguageRuntime::Terminate();
-  AppleObjCRuntimeV2::Terminate();
-  AppleObjCRuntimeV1::Terminate();
+  AppleObjCRuntime::Terminate();
   SystemRuntimeMacOSX::Terminate();
   RenderScriptRuntime::Terminate();
 

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index 7076959bee97..a7cc5d042194 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -8,10 +8,12 @@
 
//===--===//
 
 #include "AppleObjCRuntime.h"
+#include "AppleObjCRuntimeV1.h"
+#include "AppleObjCRuntimeV2.h"
 #include "AppleObjCTrampolineHandler.h"
-
-#include "clang/AST/Type.h"
-
+#include "Plugins/Language/ObjC/NSString.h"
+#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
+#include "Plugins/Process/Utility/HistoryThread.h"
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
@@ -35,10 +37,7 @@
 #include "lldb/Utility/Scalar.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/StreamString.h"
-
-#include "Plugins/Process/Utility/HistoryThread.h"
-#include "Plugins/Language/ObjC/NSString.h"
-#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
+#include "clang/AST/Type.h"
 
 #include 
 
@@ -55,6 +54,16 @@ AppleObjCRuntime::AppleObjCRuntime(Process *process)
   ReadObjCLibraryIfNeeded(process->GetTarget().GetImages());
 }
 
+void AppleObjCRuntime::Initialize() {
+  AppleObjCRuntimeV2::Initialize();
+  AppleObjCRuntimeV1::Initialize();
+}
+
+void AppleObjCRuntime::Terminate() {
+  AppleObjCRuntimeV2::Terminate();
+  AppleObjCRuntimeV1::Terminate();
+}
+
 bool AppleObjCRuntime::GetObjectDescription(Stream &str, ValueObject &valobj) {
   CompilerType compiler_type(valobj.GetCompilerType());
   bool is_signed;
@@ -479,7 +488,7 @@ ValueObjectSP AppleObjCRuntime::GetExceptionObjectForThread(
 
   auto descriptor = GetClassDescriptor(*cpp_exception);
   if (!descriptor || !descriptor->IsValid()) return ValueObjectSP();
-  
+
   while (descriptor) {
 ConstString class_name(descriptor->GetClassName());
 if (class_name == "NSException")

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
index 79ac53e1e440..d8959b4b050b 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCR

[Lldb-commits] [PATCH] D73121: [lldb/Initializers] Move all ObjC initializers into AppleObjCRuntime

2020-01-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
JDevlieghere marked an inline comment as done.
Closed by commit rG1d1ebb9e592b: [lldb/Initializers] Move all ObjC initializers 
into AppleObjCRuntime (authored by JDevlieghere).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73121

Files:
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
  lldb/tools/lldb-test/SystemInitializerTest.cpp

Index: lldb/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -53,8 +53,7 @@
 #include "Plugins/Language/ObjC/ObjCLanguage.h"
 #include "Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h"
 #include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h"
-#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h"
-#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
+#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
 #include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h"
 #include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
 #include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
@@ -215,8 +214,7 @@
 
   SymbolFileDWARFDebugMap::Initialize();
   ItaniumABILanguageRuntime::Initialize();
-  AppleObjCRuntimeV2::Initialize();
-  AppleObjCRuntimeV1::Initialize();
+  AppleObjCRuntime::Initialize();
   SystemRuntimeMacOSX::Initialize();
   RenderScriptRuntime::Initialize();
 
@@ -308,8 +306,7 @@
 
   SymbolFileDWARFDebugMap::Terminate();
   ItaniumABILanguageRuntime::Terminate();
-  AppleObjCRuntimeV2::Terminate();
-  AppleObjCRuntimeV1::Terminate();
+  AppleObjCRuntime::Terminate();
   SystemRuntimeMacOSX::Terminate();
   RenderScriptRuntime::Terminate();
 
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
@@ -31,6 +31,10 @@
 
   static char ID;
 
+  static void Initialize();
+
+  static void Terminate();
+
   bool isA(const void *ClassID) const override {
 return ClassID == &ID || ObjCLanguageRuntime::isA(ClassID);
   }
@@ -84,7 +88,7 @@
   bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override;
 
   lldb::SearchFilterSP CreateExceptionSearchFilter() override;
-  
+
   static std::tuple GetExceptionThrowLocation();
 
   lldb::ValueObjectSP GetExceptionObjectForThread(
@@ -97,7 +101,7 @@
 
   virtual void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true,
 lldb::addr_t &cf_false);
-
+
   virtual bool IsTaggedPointer (lldb::addr_t addr) { return false; }
 
 protected:
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -8,10 +8,12 @@
 //===--===//
 
 #include "AppleObjCRuntime.h"
+#include "AppleObjCRuntimeV1.h"
+#include "AppleObjCRuntimeV2.h"
 #include "AppleObjCTrampolineHandler.h"
-
-#include "clang/AST/Type.h"
-
+#include "Plugins/Language/ObjC/NSString.h"
+#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
+#include "Plugins/Process/Utility/HistoryThread.h"
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
@@ -35,10 +37,7 @@
 #include "lldb/Utility/Scalar.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/StreamString.h"
-
-#include "Plugins/Process/Utility/HistoryThread.h"
-#include "Plugins/Language/ObjC/NSString.h"
-#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
+#include "clang/AST/Type.h"
 
 #include 
 
@@ -55,6 +54,16 @@
   ReadObjCLibraryIfNeeded(process->GetTarget().GetImages());
 }
 
+void AppleObjCRuntime::Initialize() {
+  AppleObjCRuntimeV2::Initialize();
+  AppleObjCRuntimeV1::Initialize();
+}
+
+void AppleObjCRuntime::Terminate() {
+  AppleObjCRuntimeV2::Terminate();
+  AppleObjCRuntimeV1::Terminate();
+}
+
 bool AppleObjCRuntime::GetObjectDescription(Stream &str, ValueObject &valobj) {
   CompilerType compiler_type(valobj.GetCompilerType());
   bool is_signed;
@@ -479,7 +488,7 @@
 
   auto descriptor = GetClassDescriptor(*cpp_exceptio

[Lldb-commits] [lldb] c9a39a8 - [lldb] Add a display name to ClangASTContext instances

2020-01-21 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-01-22T08:54:10+01:00
New Revision: c9a39a896c95402ede07061380346c725556e308

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

LOG: [lldb] Add a display name to ClangASTContext instances

Summary:
I often struggle to understand what exactly LLDB is doing by looking at our 
expression evaluation logging as our messages look like this:
```
CompleteTagDecl[2] on (ASTContext*)0x7ff31f01d240 Completing 
(TagDecl*)0x7ff31f01d568 named DeclName1
```

From the log messages it's unclear what this ASTContext is. Is it the scratch 
context, the expression context, some decl vendor context or a context from a 
module?
The pointer value isn't helpful for anyone unless I'm in a debugger where I 
could inspect the memory at the address. But even with a debugger it's not easy 
to
figure out what this ASTContext is without having deeper understanding about 
all the different ASTContext instances in LLDB (e.g., valid SourceLocation
from the file system usually means that this is the Objective-C decl vendor, a 
file name from multiple expressions is probably the scratch context, etc.).

This patch adds a name field to ClangASTContext instances that we can use to 
store a name which can be used for logging and debugging. With this
our log messages now look like this:
```
CompleteTagDecl[2] on scratch ASTContext. Completing (TagDecl*)0x7ff31f01d568 
named Foo
```
We can now also just print a ClangASTContext from the debugger and see a useful 
name in the `m_display_name` field, e.g.
```
  m_display_name = "AST for /Users/user/test/main.o";
```

Reviewers: shafik, labath, JDevlieghere, mib

Reviewed By: shafik

Subscribers: clayborg, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/include/lldb/Symbol/ClangASTContext.h
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
lldb/source/Symbol/ClangASTContext.cpp
lldb/unittests/Symbol/TestClangASTContext.cpp
lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h

Removed: 




diff  --git a/lldb/include/lldb/Symbol/ClangASTContext.h 
b/lldb/include/lldb/Symbol/ClangASTContext.h
index 338417b20b8a..d59fee8d4ca7 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -57,17 +57,20 @@ class ClangASTContext : public TypeSystem {
 
   /// Constructs a ClangASTContext with an ASTContext using the given triple.
   ///
+  /// \param name The name for the ClangASTContext (for logging purposes)
   /// \param triple The llvm::Triple used for the ASTContext. The triple 
defines
   ///   certain characteristics of the ASTContext and its types
   ///   (e.g., whether certain primitive types exist or what their
   ///   signedness is).
-  explicit ClangASTContext(llvm::Triple triple);
+  explicit ClangASTContext(llvm::StringRef name, llvm::Triple triple);
 
   /// Constructs a ClangASTContext that uses an existing ASTContext internally.
   /// Useful when having an existing ASTContext created by Clang.
   ///
+  /// \param name The name for the ClangASTContext (for logging purposes)
   /// \param existing_ctxt An existing ASTContext.
-  explicit ClangASTContext(clang::ASTContext &existing_ctxt);
+  explicit ClangASTContext(llvm::StringRef name,
+   clang::ASTContext &existing_ctxt);
 
   ~ClangASTContext() override;
 
@@ -104,6 +107,10 @@ class ClangASTContext : public TypeSystem {
 return llvm::dyn_cast(&type_system_or_err.get());
   }
 
+  /// Returns the display name of this ClangASTContext that indicates what
+  /// purpose it serves in LLDB. Used for example in logs.
+  llvm::StringRef getDisplayName() const { return m_display_name; }
+
   clang::ASTContext &getASTContext();
 
   clang::MangleContext *getMangleContext();
@@ -947,6 +954,10 @@ class ClangASTContext : public TypeSystem {
   std::unique_ptr m_mangle_ctx_up;
   uint32_t m_pointer_byte_size = 0;
   bool m_ast_owned = false;
+  /// A string describing what this ClangASTContext represents (e.g.,
+  /// AST for debug information, an expression, some other utility ClangAST).
+  /// Useful for logging and debugging.
+  std::string m_display_name;
 
   typedef llvm::DenseMap 
DeclMetadataMap;
   /// Maps Decls to their associated ClangASTMetadata.

diff  --git a/lldb/source/Plugins/Expression

[Lldb-commits] [PATCH] D72391: [lldb] Add a display name to ClangASTContext instances

2020-01-21 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc9a39a896c95: [lldb] Add a display name to ClangASTContext 
instances (authored by teemperor).

Changed prior to commit:
  https://reviews.llvm.org/D72391?vs=236786&id=239495#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72391

Files:
  lldb/include/lldb/Symbol/ClangASTContext.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
  lldb/source/Symbol/ClangASTContext.cpp
  lldb/unittests/Symbol/TestClangASTContext.cpp
  lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
  lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h

Index: lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h
===
--- lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h
+++ lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h
@@ -22,7 +22,8 @@
 }
 
 inline std::unique_ptr createAST() {
-  return std::make_unique(HostInfo::GetTargetTriple());
+  return std::make_unique("test ASTContext",
+   HostInfo::GetTargetTriple());
 }
 
 inline CompilerType createRecord(ClangASTContext &ast, llvm::StringRef name) {
Index: lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
===
--- lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
+++ lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
@@ -39,7 +39,7 @@
 // defining here, causing this test to fail, feel free to delete it.
 TEST_F(DWARFASTParserClangTests,
EnsureAllDIEsInDeclContextHaveBeenParsedParsesOnlyMatchingEntries) {
-  ClangASTContext ast_ctx(HostInfoBase::GetTargetTriple());
+  ClangASTContext ast_ctx("dummy ASTContext", HostInfoBase::GetTargetTriple());
   DWARFASTParserClangStub ast_parser(ast_ctx);
 
   DWARFUnit *unit = nullptr;
Index: lldb/unittests/Symbol/TestClangASTContext.cpp
===
--- lldb/unittests/Symbol/TestClangASTContext.cpp
+++ lldb/unittests/Symbol/TestClangASTContext.cpp
@@ -26,7 +26,8 @@
   SubsystemRAII subsystems;
 
   void SetUp() override {
-m_ast.reset(new ClangASTContext(HostInfo::GetTargetTriple()));
+m_ast.reset(
+new ClangASTContext("test ASTContext", HostInfo::GetTargetTriple()));
   }
 
   void TearDown() override { m_ast.reset(); }
@@ -220,6 +221,16 @@
   VerifyEncodingAndBitSize(*m_ast, eEncodingIEEE754, 64);
 }
 
+TEST_F(TestClangASTContext, TestDisplayName) {
+  ClangASTContext ast("some name", llvm::Triple());
+  EXPECT_EQ("some name", ast.getDisplayName());
+}
+
+TEST_F(TestClangASTContext, TestDisplayNameEmpty) {
+  ClangASTContext ast("", llvm::Triple());
+  EXPECT_EQ("", ast.getDisplayName());
+}
+
 TEST_F(TestClangASTContext, TestIsClangType) {
   clang::ASTContext &context = m_ast->getASTContext();
   lldb::opaque_compiler_type_t bool_ctype =
Index: lldb/source/Symbol/ClangASTContext.cpp
===
--- lldb/source/Symbol/ClangASTContext.cpp
+++ lldb/source/Symbol/ClangASTContext.cpp
@@ -499,7 +499,9 @@
   Opts.NoInlineDefine = !Opt;
 }
 
-ClangASTContext::ClangASTContext(llvm::Triple target_triple) {
+ClangASTContext::ClangASTContext(llvm::StringRef name,
+ llvm::Triple target_triple) {
+  m_display_name = name.str();
   if (!target_triple.str().empty())
 SetTargetTriple(target_triple.str());
   // The caller didn't pass an ASTContext so create a new one for this
@@ -507,7 +509,9 @@
   CreateASTContext();
 }
 
-ClangASTContext::ClangASTContext(ASTContext &existing_ctxt) {
+ClangASTContext::ClangASTContext(llvm::StringRef name,
+ ASTContext &existing_ctxt) {
+  m_display_name = name.str();
   SetTargetTriple(existing_ctxt.getTargetInfo().getTriple().str());
 
   m_ast_up.reset(&existing_ctxt);
@@ -556,9 +560,11 @@
 }
   }
 
-  if (module)
-return std::make_shared(triple);
-  else if (target && target->IsValid())
+  if (module) {
+std::string ast_name =
+"ASTContext for '" + module->GetFileSpec().GetPath() + "'";
+return std::make_shared(ast_name, triple);
+  } else if (target && target->IsValid())
 return std::make_shared(*target, triple);
   return lldb::TypeSystemSP();
 }
@@ -9252,7 +9258,8 @@
 
 ClangASTContextForExpressions::ClangASTContextForExpressions(
 Target &target, llvm::Triple triple)
-: ClangASTContext(triple), m_target_wp(target.shared_from_this()),
+: ClangASTContext("scratch