[Lldb-commits] [PATCH] D53759: [PDB] Support PDB-backed expressions evaluation

2018-11-28 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov updated this revision to Diff 175634.

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

https://reviews.llvm.org/D53759

Files:
  lit/SymbolFile/PDB/Inputs/ExpressionsTest.cpp
  lit/SymbolFile/PDB/Inputs/ExpressionsTest0.script
  lit/SymbolFile/PDB/Inputs/ExpressionsTest1.script
  lit/SymbolFile/PDB/Inputs/ExpressionsTest2.script
  lit/SymbolFile/PDB/expressions.test
  source/Expression/IRExecutionUnit.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/Process/Windows/Common/ProcessWindows.cpp
  source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
  source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  source/Plugins/SymbolFile/PDB/PDBASTParser.h
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp

Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -286,6 +286,10 @@
 const PDBSymbolFunc &pdb_func, const lldb_private::SymbolContext &sc) {
   lldbassert(sc.comp_unit && sc.module_sp.get());
 
+  if (FunctionSP result =
+  sc.comp_unit->FindFunctionByUID(pdb_func.getSymIndexId()))
+return result.get();
+
   auto file_vm_addr = pdb_func.getVirtualAddress();
   if (file_vm_addr == LLDB_INVALID_ADDRESS || file_vm_addr == 0)
 return nullptr;
@@ -1047,8 +1051,6 @@
 const lldb_private::ConstString &name,
 const lldb_private::CompilerDeclContext *parent_decl_ctx,
 uint32_t max_matches, lldb_private::VariableList &variables) {
-  if (!parent_decl_ctx)
-parent_decl_ctx = m_tu_decl_ctx_up.get();
   if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
 return 0;
   if (name.IsEmpty())
@@ -1078,9 +1080,8 @@
 if (sc.comp_unit == nullptr)
   continue;
 
-auto actual_parent_decl_ctx =
-GetDeclContextContainingUID(result->getSymIndexId());
-if (actual_parent_decl_ctx != *parent_decl_ctx)
+if (parent_decl_ctx && GetDeclContextContainingUID(
+   result->getSymIndexId()) != *parent_decl_ctx)
   continue;
 
 ParseVariables(sc, *pdb_data, &variables);
@@ -1269,20 +1270,28 @@
 CacheFunctionNames();
 
 std::set resolved_ids;
-auto ResolveFn = [include_inlines, &name, &sc_list, &resolved_ids,
-  this](UniqueCStringMap &Names) {
+auto ResolveFn = [this, &name, parent_decl_ctx, include_inlines, &sc_list,
+  &resolved_ids](UniqueCStringMap &Names) {
   std::vector ids;
-  if (Names.GetValues(name, ids)) {
-for (auto id : ids) {
-  if (resolved_ids.find(id) == resolved_ids.end()) {
-if (ResolveFunction(id, include_inlines, sc_list))
-  resolved_ids.insert(id);
-  }
-}
+  if (!Names.GetValues(name, ids))
+return;
+
+  for (uint32_t id : ids) {
+if (resolved_ids.find(id) != resolved_ids.end())
+  continue;
+
+if (parent_decl_ctx &&
+GetDeclContextContainingUID(id) != *parent_decl_ctx)
+  continue;
+
+if (ResolveFunction(id, include_inlines, sc_list))
+  resolved_ids.insert(id);
   }
 };
 if (name_type_mask & eFunctionNameTypeFull) {
   ResolveFn(m_func_full_names);
+  ResolveFn(m_func_base_names);
+  ResolveFn(m_func_method_names);
 }
 if (name_type_mask & eFunctionNameTypeBase) {
   ResolveFn(m_func_base_names);
@@ -1418,8 +1427,6 @@
 llvm::StringRef name,
 const lldb_private::CompilerDeclContext *parent_decl_ctx,
 uint32_t max_matches, lldb_private::TypeMap &types) {
-  if (!parent_decl_ctx)
-parent_decl_ctx = m_tu_decl_ctx_up.get();
   std::unique_ptr results;
   if (name.empty())
 return;
@@ -1453,9 +1460,8 @@
 if (!ResolveTypeUID(result->getSymIndexId()))
   continue;
 
-auto actual_parent_decl_ctx =
-GetDeclContextContainingUID(result->getSymIndexId());
-if (actual_parent_decl_ctx != *parent_decl_ctx)
+if (parent_decl_ctx && GetDeclContextContainingUID(
+   result->getSymIndexId()) != *parent_decl_ctx)
   continue;
 
 auto iter = m_types.find(result->getSymIndexId());
Index: source/Plugins/SymbolFile/PDB/PDBASTParser.h
===
--- source/Plugins/SymbolFile/PDB/PDBASTParser.h
+++ source/Plugins/SymbolFile/PDB/PDBASTParser.h
@@ -69,7 +69,8 @@
   typedef llvm::DenseMap
   CXXRecordDeclToUidMap;
   typedef llvm::DenseMap UidToDeclMap;
-  typedef llvm::DenseMap>
+  typedef std::set NamespacesSet;
+  typedef llvm::DenseMap
   ParentToNamespacesMap;
   typedef llvm::DenseMap
   DeclContextToUidMap;
@@ -109,6 +110,7 @@
   CXXRecordDeclToUidMap m_forward_decl_to_uid;
   UidToDeclMap m_uid_to_decl;
   ParentToNamespacesMap m_parent_to_namespaces;
+  NamespacesSet m_namespaces;
   DeclContextToUidMap m_decl_context_to_u

[Lldb-commits] [PATCH] D53759: [PDB] Support PDB-backed expressions evaluation

2018-11-28 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov marked 2 inline comments as done.
aleksandr.urakov added inline comments.



Comment at: source/Core/RichManglingContext.cpp:134-135
 get(m_cxx_method_parser)->GetBasename();
+if (!m_buffer.data())
+  m_buffer = llvm::StringRef("", 0);
 return;

labath wrote:
> Why is this necessary? It looks like somebody is misusing the returned 
> StringRef by assuming that it always points to at least a single valid byte 
> (which is definitely not the case in general, even for StringRefs with a 
> non-null `data()`).
> 
> It would be better to fix the caller instead.
Yes, you are right. This change was made much time ago, I've fixed in this way 
the same problem, which Aaron have fixed in D52626, and have forgot to remove 
this. Thanks for pointing to this!


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

https://reviews.llvm.org/D53759



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


[Lldb-commits] [PATCH] D54942: [PDB] Make PDB lit tests use the new builder

2018-11-28 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

Thanks all!

In D54942#1310224 , @zturner wrote:

> Makes sense.  Just curious, is the order file strictly necessary for this 
> test?  `/Gy` is the same as `-ffunction-sections`, so there could be an 
> argument to be made for exposing `--function-sections` on the command line of 
> `build.py`.  On the other hand, there's no harm in falling back to the old 
> mechanism here since this test isn't intended to be portable.


Yes, the order is necessary for the test, because it tests exactly correct 
processing of source files that are not continuous in the result binary. But 
I'm not against leaving it as is.

> Ahh, right.  I wonder if we should have something like `--arch=lldb` that 
> means "match the architecture of LLDB".  It's not urgent for this patch, but 
> it could be useful as a followup.

Yes, I thought about a solution like these too. May be we could even make it 
the default `arch`?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D54942



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


[Lldb-commits] [PATCH] D54751: [LLDB] - Fix setting the breakpoints when -gsplit-dwarf and DWARF 5 were used for building the executable.

2018-11-28 Thread George Rimar via Phabricator via lldb-commits
grimar marked an inline comment as done.
grimar added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:355-356
+  if (addr_base == LLDB_INVALID_ADDRESS)
+addr_base = cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
+   DW_AT_GNU_addr_base, 0);
   dwo_cu->SetAddrBase(addr_base);

clayborg wrote:
> Do we still want the addr_base to default to zero instead of 
> LLDB_INVALID_ADDRESS here?
I believe so. Setting the addr_base to default zero looks fine to me. That way 
the existent code does not
need to check for LLDB_INVALID_ADDRESS and can just call the `GetAddrBase` and 
add the result
to the offset calculation.
That is how things already work and I do not see any benefits from changing 
this behavior probably?


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

https://reviews.llvm.org/D54751



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


[Lldb-commits] [PATCH] D54914: Add a generic build script for building test inferiors

2018-11-28 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D54914#1310337 , @zturner wrote:

> In D54914#1309700 , @labath wrote:
>
> > I didn't look at the code in detail, as most of it deals with windows 
> > stuff, and I don't know much about those anyway. However, the interesting 
> > question for me would be how to make this useful for cross-compiling. Right 
> > now that sort of works for NativePDB tests because --compiler=clang-cl 
> > implies windows, but that won't help if I want to compile say a linux arm64 
> > binary. I think that instead --arch, we should have a `--triple` argument, 
> > which specifies the exact target you want to build for. That can default to 
> > "host", and we can have special pseudo-triples like "host32" and "host64", 
> > if we want to be able to say "I want to build for a 32-bit flavour of the 
> > host arch". That could also make gcc detection easier, since you could just 
> > search for `$triple-gcc`.
>
>
> A triple is one way.  I don't know much about gcc, does it support the same 
> triple format as clang?


Gcc is different that clang in that the target triple is baked into the binary. 
For example, on my machine, I have a binary called `x86_64-pc-linux-gnu-gcc` 
(`gcc` is just a symlink to that), which always produces binaries for x86_64 
linux. If I had a arm64 cross-gcc installed, it would be called something like 
`aarch64-linux-gnu-gcc` and so on. So the actual mechanism to search for the 
compiler and invoke it will be different, but a triple is still a good starting 
point.

> Also, are there any existing use cases for specifying a triple in the lit 
> test suite?

You can take a look at the tests in `lit/SymbolFile/DWARF`. Their purpose is 
very similar to the NativePDB tests -- check the operation of the dwarf parser, 
regardless of the host platform. Since mac uses a somewhat different flavour of 
dwarf than  other platforms, the sources are usually compiled twice, targetting 
linux and mac.

>   I do agree we will need the ability to support triple specification, but it 
> seems better to do this as a followup.  I don't think it should be too hard 
> as long as we can make some assumptions such as "specification of --triple 
> limits the possible supported compilers", etc.

I don't think there needs to be much code initially, but I think it would be 
good to decide on the direction up front. For example, if we decide to go the 
triple way then we could avoid the churn in the tests by making all of them use 
`--triple=x86_64-pc-windows` instead of the current `--arch=64`, even if the 
actual implementation simply aborts in the more complicated cases.


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

https://reviews.llvm.org/D54914



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


[Lldb-commits] [PATCH] D54914: Add a generic build script for building test inferiors

2018-11-28 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D54914#1309901 , @aprantl wrote:

> I would like to ask a general question that I (indirectly) also asked in 
> D54731 : Why do we want to implement support 
> for building inferiors in LIT-based tests? IMHO, if we need to support for 
> dealing with specific compilers, we should implement that once in 
> `Makefile.rules` (which is in a declarative domain-specific-language for 
> describing build logic) and write a `dotest.py`-style test instead. I'm 
> assuming here that we need the support in `Makefile.rules` anyway to support 
> the bulk of the tests. Having this support in two places increases the 
> maintenance effort and cognitive load.


While I agree that having two ways to do something is bad, I have to say that 
the current Makefile.rules system is far from perfect. First of, it is geared 
towards creating a fully working executables (the kind that dotest tests 
expect), and if you want to do something more exotic, things get a lot harder. 
Also writing more complex logic in makefiles is hard, particularly when you 
need to be portable across various shells and make implementations.  In fact, 
the biggest feature of make, automatic dependency tracking, is unused now that 
we build tests out of tree and clean by nuking the build dir.


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

https://reviews.llvm.org/D54914



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


[Lldb-commits] [lldb] r347758 - Revert r347673 "Catch up with EvaluateAsInt() clang API change."

2018-11-28 Thread Hans Wennborg via lldb-commits
Author: hans
Date: Wed Nov 28 06:30:18 2018
New Revision: 347758

URL: http://llvm.org/viewvc/llvm-project?rev=347758&view=rev
Log:
Revert r347673 "Catch up with EvaluateAsInt() clang API change."

r347417 was re-committed in Clang.

Modified:
lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=347758&r1=347757&r2=347758&view=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Nov 28 06:30:18 2018
@@ -5965,10 +5965,10 @@ GetObjCFieldAtIndex(clang::ASTContext *a
 
 if (is_bitfield && ast) {
   clang::Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth();
-  llvm::APSInt bitfield_apsint;
+  clang::Expr::EvalResult result;
   if (bitfield_bit_size_expr &&
-  bitfield_bit_size_expr->EvaluateAsInt(bitfield_apsint,
-*ast)) {
+  bitfield_bit_size_expr->EvaluateAsInt(result, *ast)) {
+llvm::APSInt bitfield_apsint = result.Val.getInt();
 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
   }
 }
@@ -6025,10 +6025,11 @@ CompilerType ClangASTContext::GetFieldAt
 
 if (is_bitfield) {
   clang::Expr *bitfield_bit_size_expr = field->getBitWidth();
-  llvm::APSInt bitfield_apsint;
+  clang::Expr::EvalResult result;
   if (bitfield_bit_size_expr &&
-  bitfield_bit_size_expr->EvaluateAsInt(bitfield_apsint,
+  bitfield_bit_size_expr->EvaluateAsInt(result,
 *getASTContext())) {
+llvm::APSInt bitfield_apsint = result.Val.getInt();
 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
   }
 }


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


[Lldb-commits] [PATCH] D55002: [NativePDB] Fix ast-reconstruction test on x86

2018-11-28 Thread Leonid Mashinskiy via Phabricator via lldb-commits
leonid.mashinskiy created this revision.
leonid.mashinskiy added reviewers: zturner, stella.stamenova.
leonid.mashinskiy added a project: LLDB.
Herald added a subscriber: lldb-commits.

This patch fixes ast-reconstruction.cpp test on x86 platform.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D55002

Files:
  lit/SymbolFile/NativePDB/ast-reconstruction.cpp


Index: lit/SymbolFile/NativePDB/ast-reconstruction.cpp
===
--- lit/SymbolFile/NativePDB/ast-reconstruction.cpp
+++ lit/SymbolFile/NativePDB/ast-reconstruction.cpp
@@ -92,11 +92,11 @@
 // CHECK: (TrivialE) TE = TE_A
 // CHECK: (A::B::C) ABCInt = (ABCMember = 0)
 // CHECK: (A::B::C) ABCFloat = (ABCMember = 0)
-// CHECK: (A::B::C) ABCVoid = (ABCSpecializationMember = 
0x)
+// CHECK: (A::B::C) ABCVoid = (ABCSpecializationMember = 0x{{0+}})
 // CHECK: (A::C<0>) AC0 = {}
 // CHECK: (A::C<-1>) ACNeg1 = {}
-// CHECK: (A::C<0>::D) AC0D = (ACDMember = 0, CPtr = 0x)
-// CHECK: (A::C<-1>::D) ACNeg1D = (ACDMember = 0, CPtr = 0x)
+// CHECK: (A::C<0>::D) AC0D = (ACDMember = 0, CPtr = 0x{{0+}})
+// CHECK: (A::C<-1>::D) ACNeg1D = (ACDMember = 0, CPtr = 0x{{0+}})
 // CHECK: (A::D) AD = {}
 // CHECK: (A::D::E) ADE = (ADDMember = 0)
 // CHECK: Dumping clang ast for 1 modules.


Index: lit/SymbolFile/NativePDB/ast-reconstruction.cpp
===
--- lit/SymbolFile/NativePDB/ast-reconstruction.cpp
+++ lit/SymbolFile/NativePDB/ast-reconstruction.cpp
@@ -92,11 +92,11 @@
 // CHECK: (TrivialE) TE = TE_A
 // CHECK: (A::B::C) ABCInt = (ABCMember = 0)
 // CHECK: (A::B::C) ABCFloat = (ABCMember = 0)
-// CHECK: (A::B::C) ABCVoid = (ABCSpecializationMember = 0x)
+// CHECK: (A::B::C) ABCVoid = (ABCSpecializationMember = 0x{{0+}})
 // CHECK: (A::C<0>) AC0 = {}
 // CHECK: (A::C<-1>) ACNeg1 = {}
-// CHECK: (A::C<0>::D) AC0D = (ACDMember = 0, CPtr = 0x)
-// CHECK: (A::C<-1>::D) ACNeg1D = (ACDMember = 0, CPtr = 0x)
+// CHECK: (A::C<0>::D) AC0D = (ACDMember = 0, CPtr = 0x{{0+}})
+// CHECK: (A::C<-1>::D) ACNeg1D = (ACDMember = 0, CPtr = 0x{{0+}})
 // CHECK: (A::D) AD = {}
 // CHECK: (A::D::E) ADE = (ADDMember = 0)
 // CHECK: Dumping clang ast for 1 modules.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D54914: Add a generic build script for building test inferiors

2018-11-28 Thread Zachary Turner via Phabricator via lldb-commits
zturner added a comment.

In D54914#1311137 , @labath wrote:

> In D54914#1310337 , @zturner wrote:
>
> > In D54914#1309700 , @labath wrote:
> >
> > > I didn't look at the code in detail, as most of it deals with windows 
> > > stuff, and I don't know much about those anyway. However, the interesting 
> > > question for me would be how to make this useful for cross-compiling. 
> > > Right now that sort of works for NativePDB tests because 
> > > --compiler=clang-cl implies windows, but that won't help if I want to 
> > > compile say a linux arm64 binary. I think that instead --arch, we should 
> > > have a `--triple` argument, which specifies the exact target you want to 
> > > build for. That can default to "host", and we can have special 
> > > pseudo-triples like "host32" and "host64", if we want to be able to say 
> > > "I want to build for a 32-bit flavour of the host arch". That could also 
> > > make gcc detection easier, since you could just search for `$triple-gcc`.
> >
> >
> > A triple is one way.  I don't know much about gcc, does it support the same 
> > triple format as clang?
>
>
> Gcc is different that clang in that the target triple is baked into the 
> binary. For example, on my machine, I have a binary called 
> `x86_64-pc-linux-gnu-gcc` (`gcc` is just a symlink to that), which always 
> produces binaries for x86_64 linux. If I had a arm64 cross-gcc installed, it 
> would be called something like `aarch64-linux-gnu-gcc` and so on. So the 
> actual mechanism to search for the compiler and invoke it will be different, 
> but a triple is still a good starting point.
>
> > Also, are there any existing use cases for specifying a triple in the lit 
> > test suite?
>
> You can take a look at the tests in `lit/SymbolFile/DWARF`. Their purpose is 
> very similar to the NativePDB tests -- check the operation of the dwarf 
> parser, regardless of the host platform. Since mac uses a somewhat different 
> flavour of dwarf than  other platforms, the sources are usually compiled 
> twice, targetting linux and mac.
>
> >   I do agree we will need the ability to support triple specification, but 
> > it seems better to do this as a followup.  I don't think it should be too 
> > hard as long as we can make some assumptions such as "specification of 
> > --triple limits the possible supported compilers", etc.
>
> I don't think there needs to be much code initially, but I think it would be 
> good to decide on the direction up front. For example, if we decide to go the 
> triple way then we could avoid the churn in the tests by making all of them 
> use `--triple=x86_64-pc-windows` instead of the current `--arch=64`, even if 
> the actual implementation simply aborts in the more complicated cases.


I think it would be good to use the way dotest works as a starting point.  You 
can specify --arch, and then you can run the test on multiple arches this way 
by running dotest several times in succession, each with different arch flags.

I think a --triple option could be useful in limited scenarios, but I think 
that most of the use cases will not need it.  Most tests will probably want to 
specify nothing at all and let the lit configuration pass the correct 
information through.  Actually, I think this is the same with the --arch flag 
though.  Because as soon as you specify something, then it limits the ability 
of the test to run over and over with different parameters.

Perhaps we could support *both* a --triple and a --arch flag.  Maybe we can 
make the script error if they're both specified.  This would give each test the 
capability to be written in the simplest way possible.


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

https://reviews.llvm.org/D54914



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


[Lldb-commits] [PATCH] D54751: [LLDB] - Fix setting the breakpoints when -gsplit-dwarf and DWARF 5 were used for building the executable.

2018-11-28 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added inline comments.
This revision is now accepted and ready to land.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:355-356
+  if (addr_base == LLDB_INVALID_ADDRESS)
+addr_base = cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
+   DW_AT_GNU_addr_base, 0);
   dwo_cu->SetAddrBase(addr_base);

grimar wrote:
> clayborg wrote:
> > Do we still want the addr_base to default to zero instead of 
> > LLDB_INVALID_ADDRESS here?
> I believe so. Setting the addr_base to default zero looks fine to me. That 
> way the existent code does not
> need to check for LLDB_INVALID_ADDRESS and can just call the `GetAddrBase` 
> and add the result
> to the offset calculation.
> That is how things already work and I do not see any benefits from changing 
> this behavior probably?
Sounds good, just wanted to check.


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

https://reviews.llvm.org/D54751



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


[Lldb-commits] [PATCH] D55012: [CMake] Streamline code signing for debugserver #2

2018-11-28 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz created this revision.
Herald added subscribers: llvm-commits, mgorny.

The first patch had to be reverted as I missed a few details. This review 
continues from https://reviews.llvm.org/D54476 and I will add the required 
fixes.

Change log:

- Use llvm_codesign to sign debugserver with entitlements.
- Set global LLVM_CODESIGNING_IDENTITY from LLDB_CODESIGN_IDENTITY (if given).
- Pass through ENTITLEMENTS from add_lldb_executable to add_llvm_executable.
- Handle reconfigurations correctly.

We have a lot of cases, make them explicit:

(1) build and sign debugserver, if all conditions apply:

- LLDB_NO_DEBUGSERVER=OFF (default)
- On Darwin: LLDB_USE_SYSTEM_DEBUGSERVER=OFF (default)
- On Darwin: LLVM_CODESIGNING_IDENTITY == lldb_codesign

(2) use system debugserver, if on Darwin and any of:

- LLDB_USE_SYSTEM_DEBUGSERVER=ON and found on system (explicit case)
- LLVM_CODESIGNING_IDENTITY != lldb_codesign and found on system (fallback case)

(3) debugserver will not be available, in case of:

- LLDB_NO_DEBUGSERVER=ON
- On Darwin: LLVM_CODESIGNING_IDENTITY != lldb_codesign and not found on system

(4) error state, in case of:

- LLDB_USE_SYSTEM_DEBUGSERVER=ON and not found on system
- LLDB_USE_SYSTEM_DEBUGSERVER=ON and LLDB_NO_DEBUGSERVER=ON


Repository:
  rL LLVM

https://reviews.llvm.org/D55012

Files:
  CMakeLists.txt
  cmake/modules/AddLLDB.cmake
  test/CMakeLists.txt
  tools/debugserver/CMakeLists.txt
  tools/debugserver/source/CMakeLists.txt
  unittests/tools/CMakeLists.txt

Index: unittests/tools/CMakeLists.txt
===
--- unittests/tools/CMakeLists.txt
+++ unittests/tools/CMakeLists.txt
@@ -1,5 +1,5 @@
 if(CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|Linux|NetBSD")
-  if ((CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_DEBUGSERVER) OR (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_LLDB_SERVER_BUILD))
+  if ((CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_TEST_DEBUGSERVER) OR (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_LLDB_SERVER_BUILD))
 # These tests are meant to test lldb-server/debugserver in isolation, and
 # don't provide any value if run against a server copied from somewhere.
   else()
Index: tools/debugserver/source/CMakeLists.txt
===
--- tools/debugserver/source/CMakeLists.txt
+++ tools/debugserver/source/CMakeLists.txt
@@ -94,32 +94,102 @@
 
 add_library(lldbDebugserverCommon ${lldbDebugserverCommonSources})
 
+option(LLDB_NO_DEBUGSERVER "Disable the debugserver target" OFF)
+option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver instead of building it from source (Darwin only)." OFF)
 
-set(LLDB_CODESIGN_IDENTITY "lldb_codesign"
-  CACHE STRING "Identity used for code signing. Set to empty string to skip the signing step.")
+# Incompatible options
+if(LLDB_NO_DEBUGSERVER AND LLDB_USE_SYSTEM_DEBUGSERVER)
+  message(FATAL_ERROR "Inconsistent options: LLDB_NO_DEBUGSERVER and LLDB_USE_SYSTEM_DEBUGSERVER")
+endif()
 
-if(NOT LLDB_CODESIGN_IDENTITY STREQUAL "")
-  set(DEBUGSERVER_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "Path to debugserver.")
-  set(SKIP_DEBUGSERVER OFF CACHE BOOL "Skip building the in-tree debug server")
-else()
+# Try to locate the system debugserver.
+# Subsequent feasibility checks depend on it.
+if(APPLE AND CMAKE_HOST_APPLE)
   execute_process(
 COMMAND xcode-select -p
-OUTPUT_VARIABLE XCODE_DEV_DIR)
-  string(STRIP ${XCODE_DEV_DIR} XCODE_DEV_DIR)
-  if(EXISTS "${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/")
-set(DEBUGSERVER_PATH
-  "${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/Resources/debugserver" CACHE PATH "Path to debugserver.")
-  elseif(EXISTS "${XCODE_DEV_DIR}/Library/PrivateFrameworks/LLDB.framework/")
-set(DEBUGSERVER_PATH
-  "${XCODE_DEV_DIR}/Library/PrivateFrameworks/LLDB.framework/Resources/debugserver" CACHE PATH "Path to debugserver.")
+OUTPUT_VARIABLE xcode_dev_dir)
+  string(STRIP ${xcode_dev_dir} xcode_dev_dir)
+
+  set(debugserver_rel_path "LLDB.framework/Resources/debugserver")
+  set(debugserver_shared "${xcode_dev_dir}/../SharedFrameworks/${debugserver_rel_path}")
+  set(debugserver_private "${xcode_dev_dir}/Library/PrivateFrameworks/${debugserver_rel_path}")
+
+  if(EXISTS ${debugserver_shared})
+set(system_debugserver ${debugserver_shared})
+  elseif(EXISTS ${debugserver_private})
+set(system_debugserver ${debugserver_private})
+  endif()
+endif()
+
+# Handle unavailability
+if(LLDB_USE_SYSTEM_DEBUGSERVER)
+  if(system_debugserver)
+set(use_system_debugserver ON)
+  elseif(APPLE AND CMAKE_HOST_APPLE)
+# Binary not found on system. Keep cached variable, to try again on reconfigure.
+message(SEND_ERROR
+  "LLDB_USE_SYSTEM_DEBUGSERVER option set, but no debugserver found in:\
+${debugserver_shared}\
+${debugserver_private}")
   else()
-message(SEND_ERROR "Cannot find debugserv

[Lldb-commits] [PATCH] D55012: [CMake] Streamline code signing for debugserver #2

2018-11-28 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 175725.
sgraenitz added a comment.

Fix target directory for debugserver: it must not be LLVM_TOOLS_BINARY_DIR but 
LLVM_RUNTIME_OUTPUT_INTDIR. It's a difference in standalone builds of LLDB. 
LLVM_TOOLS_BINARY_DIR was wrong here as it points to the binary directory in 
the detached LLVM build tree. It should make no difference for in-tree builds.


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

https://reviews.llvm.org/D55012

Files:
  tools/debugserver/source/CMakeLists.txt


Index: tools/debugserver/source/CMakeLists.txt
===
--- tools/debugserver/source/CMakeLists.txt
+++ tools/debugserver/source/CMakeLists.txt
@@ -156,7 +156,7 @@
 # because the value of DEBUGSERVER_PATH is used to build LLDB_DOTEST_ARGS,
 # which is used for configuring lldb-dotest.in, which does not have a generator
 # step at the moment.
-set(default_debugserver_path 
"${LLVM_TOOLS_BINARY_DIR}/debugserver${CMAKE_EXECUTABLE_SUFFIX}")
+set(default_debugserver_path 
"${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver${CMAKE_EXECUTABLE_SUFFIX}")
 
 # Remember where debugserver binary goes and whether or not we have to test it.
 set(DEBUGSERVER_PATH "" CACHE FILEPATH "Path to debugserver")
@@ -166,7 +166,7 @@
 if(use_system_debugserver)
   add_custom_target(debugserver
 COMMAND ${CMAKE_COMMAND} -E copy_if_different
-${system_debugserver} ${LLVM_TOOLS_BINARY_DIR}
+${system_debugserver} ${LLVM_RUNTIME_OUTPUT_INTDIR}
 COMMENT "Copying the system debugserver to LLDB's binaries directory.")
 
   # Don't test debugserver itself.


Index: tools/debugserver/source/CMakeLists.txt
===
--- tools/debugserver/source/CMakeLists.txt
+++ tools/debugserver/source/CMakeLists.txt
@@ -156,7 +156,7 @@
 # because the value of DEBUGSERVER_PATH is used to build LLDB_DOTEST_ARGS,
 # which is used for configuring lldb-dotest.in, which does not have a generator
 # step at the moment.
-set(default_debugserver_path "${LLVM_TOOLS_BINARY_DIR}/debugserver${CMAKE_EXECUTABLE_SUFFIX}")
+set(default_debugserver_path "${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver${CMAKE_EXECUTABLE_SUFFIX}")
 
 # Remember where debugserver binary goes and whether or not we have to test it.
 set(DEBUGSERVER_PATH "" CACHE FILEPATH "Path to debugserver")
@@ -166,7 +166,7 @@
 if(use_system_debugserver)
   add_custom_target(debugserver
 COMMAND ${CMAKE_COMMAND} -E copy_if_different
-${system_debugserver} ${LLVM_TOOLS_BINARY_DIR}
+${system_debugserver} ${LLVM_RUNTIME_OUTPUT_INTDIR}
 COMMENT "Copying the system debugserver to LLDB's binaries directory.")
 
   # Don't test debugserver itself.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D55012: [CMake] Streamline code signing for debugserver #2

2018-11-28 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 175729.
sgraenitz added a comment.

The default identity for code signing must be lldb_codesign. Also remove the 
comment to deprecate LLDB_CODESIGN_IDENTITY in favor of 
LLVM_CODESIGNING_IDENTITY.


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

https://reviews.llvm.org/D55012

Files:
  CMakeLists.txt
  tools/debugserver/CMakeLists.txt


Index: tools/debugserver/CMakeLists.txt
===
--- tools/debugserver/CMakeLists.txt
+++ tools/debugserver/CMakeLists.txt
@@ -16,9 +16,11 @@
   include_directories(${LLDB_SOURCE_DIR}/include)
 
   option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if 
available" ON)
+  set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
+  "Identity for code signing debugserver (Darwin only)")
+
   if(LLDB_CODESIGN_IDENTITY)
-# In the future we may use LLVM_CODESIGNING_IDENTITY directly.
-set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY})
+set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY} CACHE STRING "" 
FORCE)
   endif()
 endif()
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -12,9 +12,11 @@
 include(AddLLDB)
 
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" 
ON)
+set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
+"Identity for code signing debugserver (Darwin only)")
+
 if(LLDB_CODESIGN_IDENTITY)
-  # In the future we may use LLVM_CODESIGNING_IDENTITY directly.
-  set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY})
+  set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY} CACHE STRING "" 
FORCE)
 endif()
 
 # Define the LLDB_CONFIGURATION_xxx matching the build type


Index: tools/debugserver/CMakeLists.txt
===
--- tools/debugserver/CMakeLists.txt
+++ tools/debugserver/CMakeLists.txt
@@ -16,9 +16,11 @@
   include_directories(${LLDB_SOURCE_DIR}/include)
 
   option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
+  set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
+  "Identity for code signing debugserver (Darwin only)")
+
   if(LLDB_CODESIGN_IDENTITY)
-# In the future we may use LLVM_CODESIGNING_IDENTITY directly.
-set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY})
+set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY} CACHE STRING "" FORCE)
   endif()
 endif()
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -12,9 +12,11 @@
 include(AddLLDB)
 
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
+set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
+"Identity for code signing debugserver (Darwin only)")
+
 if(LLDB_CODESIGN_IDENTITY)
-  # In the future we may use LLVM_CODESIGNING_IDENTITY directly.
-  set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY})
+  set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY} CACHE STRING "" FORCE)
 endif()
 
 # Define the LLDB_CONFIGURATION_xxx matching the build type
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D55012: [CMake] Streamline code signing for debugserver #2

2018-11-28 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 175730.
sgraenitz added a comment.

Move code sign settings to LLDBConfig.cmake + polishing


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

https://reviews.llvm.org/D55012

Files:
  CMakeLists.txt
  cmake/modules/LLDBConfig.cmake
  tools/debugserver/CMakeLists.txt
  tools/debugserver/source/CMakeLists.txt


Index: tools/debugserver/source/CMakeLists.txt
===
--- tools/debugserver/source/CMakeLists.txt
+++ tools/debugserver/source/CMakeLists.txt
@@ -142,7 +142,7 @@
   if(CMAKE_HOST_APPLE AND NOT LLVM_CODESIGNING_IDENTITY STREQUAL 
"lldb_codesign")
 set(msg "Cannot code sign debugserver with identity 
'${LLVM_CODESIGNING_IDENTITY}'.")
 if(system_debugserver)
-  message(WARNING "${msg} Will fall back to system's debugserver.")
+  message(WARNING "${msg} Will fall back to copy system's debugserver.")
   set(use_system_debugserver ON)
 else()
   message(WARNING "${msg} debugserver will not be available.")
Index: tools/debugserver/CMakeLists.txt
===
--- tools/debugserver/CMakeLists.txt
+++ tools/debugserver/CMakeLists.txt
@@ -15,7 +15,7 @@
   set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
   include_directories(${LLDB_SOURCE_DIR}/include)
 
-  option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if 
available" ON)
+  option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if 
available" ON)
   set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
   "Identity for code signing debugserver (Darwin only)")
 
Index: cmake/modules/LLDBConfig.cmake
===
--- cmake/modules/LLDBConfig.cmake
+++ cmake/modules/LLDBConfig.cmake
@@ -50,6 +50,14 @@
   add_definitions( -DLLDB_DISABLE_CURSES )
 endif()
 
+option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if 
available" ON)
+set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
+"Identity for code signing debugserver (Darwin only)")
+
+if(LLDB_CODESIGN_IDENTITY)
+  set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY} CACHE STRING "" 
FORCE)
+endif()
+
 # On Windows, we can't use the normal FindPythonLibs module that comes with 
CMake,
 # for a number of reasons.
 # 1) Prior to MSVC 2015, it is only possible to embed Python if python itself 
was
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -11,14 +11,6 @@
 include(LLDBConfig)
 include(AddLLDB)
 
-option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" 
ON)
-set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
-"Identity for code signing debugserver (Darwin only)")
-
-if(LLDB_CODESIGN_IDENTITY)
-  set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY} CACHE STRING "" 
FORCE)
-endif()
-
 # Define the LLDB_CONFIGURATION_xxx matching the build type
 if( uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
   add_definitions( -DLLDB_CONFIGURATION_DEBUG )


Index: tools/debugserver/source/CMakeLists.txt
===
--- tools/debugserver/source/CMakeLists.txt
+++ tools/debugserver/source/CMakeLists.txt
@@ -142,7 +142,7 @@
   if(CMAKE_HOST_APPLE AND NOT LLVM_CODESIGNING_IDENTITY STREQUAL "lldb_codesign")
 set(msg "Cannot code sign debugserver with identity '${LLVM_CODESIGNING_IDENTITY}'.")
 if(system_debugserver)
-  message(WARNING "${msg} Will fall back to system's debugserver.")
+  message(WARNING "${msg} Will fall back to copy system's debugserver.")
   set(use_system_debugserver ON)
 else()
   message(WARNING "${msg} debugserver will not be available.")
Index: tools/debugserver/CMakeLists.txt
===
--- tools/debugserver/CMakeLists.txt
+++ tools/debugserver/CMakeLists.txt
@@ -15,7 +15,7 @@
   set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
   include_directories(${LLDB_SOURCE_DIR}/include)
 
-  option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
+  option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if available" ON)
   set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
   "Identity for code signing debugserver (Darwin only)")
 
Index: cmake/modules/LLDBConfig.cmake
===
--- cmake/modules/LLDBConfig.cmake
+++ cmake/modules/LLDBConfig.cmake
@@ -50,6 +50,14 @@
   add_definitions( -DLLDB_DISABLE_CURSES )
 endif()
 
+option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if available" ON)
+set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
+"Identity for code signing debugserver (Darwin only)")
+
+if(LLDB_CODESIGN_IDENTITY)
+  set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY} CACHE STRING "" FORCE)
+endif()
+
 # On Windows, we 

[Lldb-commits] [PATCH] D55013: [CMake] Streamline code signing for debugserver #2

2018-11-28 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz created this revision.
Herald added a subscriber: mgorny.

The first patch had to be reverted as I missed a few details. This review 
continues from D54476  and I will add the 
required fixes.

Change log:

- Use llvm_codesign to sign debugserver with entitlements.
- Set global LLVM_CODESIGNING_IDENTITY from LLDB_CODESIGN_IDENTITY (if given).
- Pass through ENTITLEMENTS from add_lldb_executable to add_llvm_executable.
- Handle reconfigurations correctly.

We have a lot of cases, make them explicit:

(1) build and sign debugserver, if all conditions apply:

- LLDB_NO_DEBUGSERVER=OFF (default)
- On Darwin: LLDB_USE_SYSTEM_DEBUGSERVER=OFF (default)
- On Darwin: LLVM_CODESIGNING_IDENTITY == lldb_codesign

(2) use system debugserver, if on Darwin and any of:

- LLDB_USE_SYSTEM_DEBUGSERVER=ON and found on system (explicit case)
- LLVM_CODESIGNING_IDENTITY != lldb_codesign and found on system (fallback case)

(3) debugserver will not be available, in case of:

- LLDB_NO_DEBUGSERVER=ON
- On Darwin: LLVM_CODESIGNING_IDENTITY != lldb_codesign and not found on system

(4) error state, in case of:

- LLDB_USE_SYSTEM_DEBUGSERVER=ON and not found on system
- LLDB_USE_SYSTEM_DEBUGSERVER=ON and LLDB_NO_DEBUGSERVER=ON


https://reviews.llvm.org/D55013

Files:
  CMakeLists.txt
  cmake/modules/AddLLDB.cmake
  test/CMakeLists.txt
  tools/debugserver/CMakeLists.txt
  tools/debugserver/source/CMakeLists.txt
  unittests/tools/CMakeLists.txt

Index: unittests/tools/CMakeLists.txt
===
--- unittests/tools/CMakeLists.txt
+++ unittests/tools/CMakeLists.txt
@@ -1,5 +1,5 @@
 if(CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|Linux|NetBSD")
-  if ((CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_DEBUGSERVER) OR (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_LLDB_SERVER_BUILD))
+  if ((CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_TEST_DEBUGSERVER) OR (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_LLDB_SERVER_BUILD))
 # These tests are meant to test lldb-server/debugserver in isolation, and
 # don't provide any value if run against a server copied from somewhere.
   else()
Index: tools/debugserver/source/CMakeLists.txt
===
--- tools/debugserver/source/CMakeLists.txt
+++ tools/debugserver/source/CMakeLists.txt
@@ -94,32 +94,102 @@
 
 add_library(lldbDebugserverCommon ${lldbDebugserverCommonSources})
 
+option(LLDB_NO_DEBUGSERVER "Disable the debugserver target" OFF)
+option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver instead of building it from source (Darwin only)." OFF)
 
-set(LLDB_CODESIGN_IDENTITY "lldb_codesign"
-  CACHE STRING "Identity used for code signing. Set to empty string to skip the signing step.")
+# Incompatible options
+if(LLDB_NO_DEBUGSERVER AND LLDB_USE_SYSTEM_DEBUGSERVER)
+  message(FATAL_ERROR "Inconsistent options: LLDB_NO_DEBUGSERVER and LLDB_USE_SYSTEM_DEBUGSERVER")
+endif()
 
-if(NOT LLDB_CODESIGN_IDENTITY STREQUAL "")
-  set(DEBUGSERVER_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "Path to debugserver.")
-  set(SKIP_DEBUGSERVER OFF CACHE BOOL "Skip building the in-tree debug server")
-else()
+# Try to locate the system debugserver.
+# Subsequent feasibility checks depend on it.
+if(APPLE AND CMAKE_HOST_APPLE)
   execute_process(
 COMMAND xcode-select -p
-OUTPUT_VARIABLE XCODE_DEV_DIR)
-  string(STRIP ${XCODE_DEV_DIR} XCODE_DEV_DIR)
-  if(EXISTS "${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/")
-set(DEBUGSERVER_PATH
-  "${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/Resources/debugserver" CACHE PATH "Path to debugserver.")
-  elseif(EXISTS "${XCODE_DEV_DIR}/Library/PrivateFrameworks/LLDB.framework/")
-set(DEBUGSERVER_PATH
-  "${XCODE_DEV_DIR}/Library/PrivateFrameworks/LLDB.framework/Resources/debugserver" CACHE PATH "Path to debugserver.")
+OUTPUT_VARIABLE xcode_dev_dir)
+  string(STRIP ${xcode_dev_dir} xcode_dev_dir)
+
+  set(debugserver_rel_path "LLDB.framework/Resources/debugserver")
+  set(debugserver_shared "${xcode_dev_dir}/../SharedFrameworks/${debugserver_rel_path}")
+  set(debugserver_private "${xcode_dev_dir}/Library/PrivateFrameworks/${debugserver_rel_path}")
+
+  if(EXISTS ${debugserver_shared})
+set(system_debugserver ${debugserver_shared})
+  elseif(EXISTS ${debugserver_private})
+set(system_debugserver ${debugserver_private})
+  endif()
+endif()
+
+# Handle unavailability
+if(LLDB_USE_SYSTEM_DEBUGSERVER)
+  if(system_debugserver)
+set(use_system_debugserver ON)
+  elseif(APPLE AND CMAKE_HOST_APPLE)
+# Binary not found on system. Keep cached variable, to try again on reconfigure.
+message(SEND_ERROR
+  "LLDB_USE_SYSTEM_DEBUGSERVER option set, but no debugserver found in:\
+${debugserver_shared}\
+${debugserver_private}")
   else()
-message(SEND_ERROR "Cannot find debugserver on system.")
+# Non-

[Lldb-commits] [lldb] r347796 - [unittests] Fix the File System Test on Windows

2018-11-28 Thread Stella Stamenova via lldb-commits
Author: stella.stamenova
Date: Wed Nov 28 11:34:01 2018
New Revision: 347796

URL: http://llvm.org/viewvc/llvm-project?rev=347796&view=rev
Log:
[unittests] Fix the File System Test on Windows

Two of the file system tests are failing on Windows - this updates them to 
expect the correct values after the refactor of the file system code.

Modified:
lldb/trunk/unittests/Host/FileSystemTest.cpp

Modified: lldb/trunk/unittests/Host/FileSystemTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/FileSystemTest.cpp?rev=347796&r1=347795&r2=347796&view=diff
==
--- lldb/trunk/unittests/Host/FileSystemTest.cpp (original)
+++ lldb/trunk/unittests/Host/FileSystemTest.cpp Wed Nov 28 11:34:01 2018
@@ -225,11 +225,7 @@ TEST(FileSystemTest, MakeAbsolute) {
 SmallString<16> foo(foo_relative);
 auto EC = fs.MakeAbsolute(foo);
 EXPECT_FALSE(EC);
-#ifdef _WIN32
-EXPECT_TRUE(foo.equals("\\foo"));
-#else
 EXPECT_TRUE(foo.equals("/foo"));
-#endif
   }
 
   {
@@ -247,11 +243,7 @@ TEST(FileSystemTest, Resolve) {
 StringRef foo_relative = "foo";
 SmallString<16> foo(foo_relative);
 fs.Resolve(foo);
-#ifdef _WIN32
-EXPECT_TRUE(foo.equals("\\foo"));
-#else
 EXPECT_TRUE(foo.equals("/foo"));
-#endif
   }
 
   {


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


[Lldb-commits] [PATCH] D55013: [CMake] Streamline code signing for debugserver #2

2018-11-28 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 175734.
sgraenitz added a comment.

Fix target directory for debugserver: it must not be LLVM_TOOLS_BINARY_DIR but 
LLVM_RUNTIME_OUTPUT_INTDIR. It's a difference in standalone builds of LLDB. 
LLVM_TOOLS_BINARY_DIR was wrong here as it points to the binary directory in 
the detached LLVM build tree. It should make no difference for in-tree builds.


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

https://reviews.llvm.org/D55013

Files:
  CMakeLists.txt
  cmake/modules/AddLLDB.cmake
  test/CMakeLists.txt
  tools/debugserver/CMakeLists.txt
  tools/debugserver/source/CMakeLists.txt
  unittests/tools/CMakeLists.txt

Index: unittests/tools/CMakeLists.txt
===
--- unittests/tools/CMakeLists.txt
+++ unittests/tools/CMakeLists.txt
@@ -1,5 +1,5 @@
 if(CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|Linux|NetBSD")
-  if ((CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_DEBUGSERVER) OR (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_LLDB_SERVER_BUILD))
+  if ((CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_TEST_DEBUGSERVER) OR (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_LLDB_SERVER_BUILD))
 # These tests are meant to test lldb-server/debugserver in isolation, and
 # don't provide any value if run against a server copied from somewhere.
   else()
Index: tools/debugserver/source/CMakeLists.txt
===
--- tools/debugserver/source/CMakeLists.txt
+++ tools/debugserver/source/CMakeLists.txt
@@ -94,32 +94,102 @@
 
 add_library(lldbDebugserverCommon ${lldbDebugserverCommonSources})
 
+option(LLDB_NO_DEBUGSERVER "Disable the debugserver target" OFF)
+option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver instead of building it from source (Darwin only)." OFF)
 
-set(LLDB_CODESIGN_IDENTITY "lldb_codesign"
-  CACHE STRING "Identity used for code signing. Set to empty string to skip the signing step.")
+# Incompatible options
+if(LLDB_NO_DEBUGSERVER AND LLDB_USE_SYSTEM_DEBUGSERVER)
+  message(FATAL_ERROR "Inconsistent options: LLDB_NO_DEBUGSERVER and LLDB_USE_SYSTEM_DEBUGSERVER")
+endif()
 
-if(NOT LLDB_CODESIGN_IDENTITY STREQUAL "")
-  set(DEBUGSERVER_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "Path to debugserver.")
-  set(SKIP_DEBUGSERVER OFF CACHE BOOL "Skip building the in-tree debug server")
-else()
+# Try to locate the system debugserver.
+# Subsequent feasibility checks depend on it.
+if(APPLE AND CMAKE_HOST_APPLE)
   execute_process(
 COMMAND xcode-select -p
-OUTPUT_VARIABLE XCODE_DEV_DIR)
-  string(STRIP ${XCODE_DEV_DIR} XCODE_DEV_DIR)
-  if(EXISTS "${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/")
-set(DEBUGSERVER_PATH
-  "${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/Resources/debugserver" CACHE PATH "Path to debugserver.")
-  elseif(EXISTS "${XCODE_DEV_DIR}/Library/PrivateFrameworks/LLDB.framework/")
-set(DEBUGSERVER_PATH
-  "${XCODE_DEV_DIR}/Library/PrivateFrameworks/LLDB.framework/Resources/debugserver" CACHE PATH "Path to debugserver.")
+OUTPUT_VARIABLE xcode_dev_dir)
+  string(STRIP ${xcode_dev_dir} xcode_dev_dir)
+
+  set(debugserver_rel_path "LLDB.framework/Resources/debugserver")
+  set(debugserver_shared "${xcode_dev_dir}/../SharedFrameworks/${debugserver_rel_path}")
+  set(debugserver_private "${xcode_dev_dir}/Library/PrivateFrameworks/${debugserver_rel_path}")
+
+  if(EXISTS ${debugserver_shared})
+set(system_debugserver ${debugserver_shared})
+  elseif(EXISTS ${debugserver_private})
+set(system_debugserver ${debugserver_private})
+  endif()
+endif()
+
+# Handle unavailability
+if(LLDB_USE_SYSTEM_DEBUGSERVER)
+  if(system_debugserver)
+set(use_system_debugserver ON)
+  elseif(APPLE AND CMAKE_HOST_APPLE)
+# Binary not found on system. Keep cached variable, to try again on reconfigure.
+message(SEND_ERROR
+  "LLDB_USE_SYSTEM_DEBUGSERVER option set, but no debugserver found in:\
+${debugserver_shared}\
+${debugserver_private}")
   else()
-message(SEND_ERROR "Cannot find debugserver on system.")
+# Non-Apple target platform or non-Darwin host. Reset invalid cached variable.
+message(WARNING "Reverting invalid option LLDB_USE_SYSTEM_DEBUGSERVER (Darwin only)")
+set(LLDB_USE_SYSTEM_DEBUGSERVER OFF CACHE BOOL "" FORCE)
   endif()
-  set(SKIP_DEBUGSERVER ON CACHE BOOL "Skip building the in-tree debug server")
+elseif(NOT LLDB_NO_DEBUGSERVER)
+  # Default case: on Darwin we need the right code signing ID.
+  # See lldb/docs/code-signing.txt for details.
+  if(CMAKE_HOST_APPLE AND NOT LLVM_CODESIGNING_IDENTITY STREQUAL "lldb_codesign")
+set(msg "Cannot code sign debugserver with identity '${LLVM_CODESIGNING_IDENTITY}'.")
+if(system_debugserver)
+  message(WARNING "${msg} Will fall back to system's debugserver.")
+  set(use_system_debugserver ON)
+else()
+  message(WARNI

[Lldb-commits] [PATCH] D55013: [CMake] Streamline code signing for debugserver #2

2018-11-28 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 175736.
sgraenitz added a comment.

Default identity for code signing must be lldb_codesign. Also remove the 
comment to deprecate LLDB_CODESIGN_IDENTITY in favor of 
LLVM_CODESIGNING_IDENTITY.


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

https://reviews.llvm.org/D55013

Files:
  CMakeLists.txt
  cmake/modules/AddLLDB.cmake
  test/CMakeLists.txt
  tools/debugserver/CMakeLists.txt
  tools/debugserver/source/CMakeLists.txt
  unittests/tools/CMakeLists.txt

Index: unittests/tools/CMakeLists.txt
===
--- unittests/tools/CMakeLists.txt
+++ unittests/tools/CMakeLists.txt
@@ -1,5 +1,5 @@
 if(CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|Linux|NetBSD")
-  if ((CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_DEBUGSERVER) OR (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_LLDB_SERVER_BUILD))
+  if ((CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_TEST_DEBUGSERVER) OR (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_LLDB_SERVER_BUILD))
 # These tests are meant to test lldb-server/debugserver in isolation, and
 # don't provide any value if run against a server copied from somewhere.
   else()
Index: tools/debugserver/source/CMakeLists.txt
===
--- tools/debugserver/source/CMakeLists.txt
+++ tools/debugserver/source/CMakeLists.txt
@@ -94,32 +94,102 @@
 
 add_library(lldbDebugserverCommon ${lldbDebugserverCommonSources})
 
+option(LLDB_NO_DEBUGSERVER "Disable the debugserver target" OFF)
+option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver instead of building it from source (Darwin only)." OFF)
 
-set(LLDB_CODESIGN_IDENTITY "lldb_codesign"
-  CACHE STRING "Identity used for code signing. Set to empty string to skip the signing step.")
+# Incompatible options
+if(LLDB_NO_DEBUGSERVER AND LLDB_USE_SYSTEM_DEBUGSERVER)
+  message(FATAL_ERROR "Inconsistent options: LLDB_NO_DEBUGSERVER and LLDB_USE_SYSTEM_DEBUGSERVER")
+endif()
 
-if(NOT LLDB_CODESIGN_IDENTITY STREQUAL "")
-  set(DEBUGSERVER_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "Path to debugserver.")
-  set(SKIP_DEBUGSERVER OFF CACHE BOOL "Skip building the in-tree debug server")
-else()
+# Try to locate the system debugserver.
+# Subsequent feasibility checks depend on it.
+if(APPLE AND CMAKE_HOST_APPLE)
   execute_process(
 COMMAND xcode-select -p
-OUTPUT_VARIABLE XCODE_DEV_DIR)
-  string(STRIP ${XCODE_DEV_DIR} XCODE_DEV_DIR)
-  if(EXISTS "${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/")
-set(DEBUGSERVER_PATH
-  "${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/Resources/debugserver" CACHE PATH "Path to debugserver.")
-  elseif(EXISTS "${XCODE_DEV_DIR}/Library/PrivateFrameworks/LLDB.framework/")
-set(DEBUGSERVER_PATH
-  "${XCODE_DEV_DIR}/Library/PrivateFrameworks/LLDB.framework/Resources/debugserver" CACHE PATH "Path to debugserver.")
+OUTPUT_VARIABLE xcode_dev_dir)
+  string(STRIP ${xcode_dev_dir} xcode_dev_dir)
+
+  set(debugserver_rel_path "LLDB.framework/Resources/debugserver")
+  set(debugserver_shared "${xcode_dev_dir}/../SharedFrameworks/${debugserver_rel_path}")
+  set(debugserver_private "${xcode_dev_dir}/Library/PrivateFrameworks/${debugserver_rel_path}")
+
+  if(EXISTS ${debugserver_shared})
+set(system_debugserver ${debugserver_shared})
+  elseif(EXISTS ${debugserver_private})
+set(system_debugserver ${debugserver_private})
+  endif()
+endif()
+
+# Handle unavailability
+if(LLDB_USE_SYSTEM_DEBUGSERVER)
+  if(system_debugserver)
+set(use_system_debugserver ON)
+  elseif(APPLE AND CMAKE_HOST_APPLE)
+# Binary not found on system. Keep cached variable, to try again on reconfigure.
+message(SEND_ERROR
+  "LLDB_USE_SYSTEM_DEBUGSERVER option set, but no debugserver found in:\
+${debugserver_shared}\
+${debugserver_private}")
   else()
-message(SEND_ERROR "Cannot find debugserver on system.")
+# Non-Apple target platform or non-Darwin host. Reset invalid cached variable.
+message(WARNING "Reverting invalid option LLDB_USE_SYSTEM_DEBUGSERVER (Darwin only)")
+set(LLDB_USE_SYSTEM_DEBUGSERVER OFF CACHE BOOL "" FORCE)
   endif()
-  set(SKIP_DEBUGSERVER ON CACHE BOOL "Skip building the in-tree debug server")
+elseif(NOT LLDB_NO_DEBUGSERVER)
+  # Default case: on Darwin we need the right code signing ID.
+  # See lldb/docs/code-signing.txt for details.
+  if(CMAKE_HOST_APPLE AND NOT LLVM_CODESIGNING_IDENTITY STREQUAL "lldb_codesign")
+set(msg "Cannot code sign debugserver with identity '${LLVM_CODESIGNING_IDENTITY}'.")
+if(system_debugserver)
+  message(WARNING "${msg} Will fall back to system's debugserver.")
+  set(use_system_debugserver ON)
+else()
+  message(WARNING "${msg} debugserver will not be available.")
+endif()
+  else()
+set(build_and_sign_debugserver ON)
+  endif()
+endif()
+
+# TODO: We don't use t

[Lldb-commits] [PATCH] D48752: Quiet command regex instructions during batch execution

2018-11-28 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.

Seems like we should just add a "bool interactive" as a second parameter to 
"IOHandlerActivated". Then it will be easy to find the other places that need 
to be fixed up.




Comment at: include/lldb/Core/IOHandler.h:201
 
   virtual void IOHandlerActivated(IOHandler &io_handler) {}
 

Maybe remove the function below and add a "bool interactive" as a second 
parameter to this function?



Comment at: source/Commands/CommandObjectCommands.cpp:983
 protected:
-  void IOHandlerActivated(IOHandler &io_handler) override {
+  void IOHandlerActivatedInteractively(IOHandler &io_handler) override {
 StreamFileSP output_sp(io_handler.GetOutputStreamFile());

See above inline comment about leaving the name the same but adding the "bool 
interactive" as a paramter



Comment at: source/Commands/CommandObjectCommands.cpp:985
 StreamFileSP output_sp(io_handler.GetOutputStreamFile());
 if (output_sp) {
+  output_sp->PutCString("Enter one or more sed substitution commands in "

If we make changes I requested above this would become:
```
if (output_sp && interactive)
```



Comment at: source/Core/IOHandler.cpp:335-337
   m_delegate.IOHandlerActivated(*this);
+  if (GetIsInteractive())
+m_delegate.IOHandlerActivatedInteractively(*this);

```
m_delegate. IOHandlerActivated(*this, GetIsInteractive());
```


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

https://reviews.llvm.org/D48752



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


[Lldb-commits] [PATCH] D55013: [CMake] Streamline code signing for debugserver #2

2018-11-28 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 175739.
sgraenitz added a comment.

Move code sign settings to LLDBConfig.cmake


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

https://reviews.llvm.org/D55013

Files:
  cmake/modules/AddLLDB.cmake
  cmake/modules/LLDBConfig.cmake
  test/CMakeLists.txt
  tools/debugserver/CMakeLists.txt
  tools/debugserver/source/CMakeLists.txt
  unittests/tools/CMakeLists.txt

Index: unittests/tools/CMakeLists.txt
===
--- unittests/tools/CMakeLists.txt
+++ unittests/tools/CMakeLists.txt
@@ -1,5 +1,5 @@
 if(CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|Linux|NetBSD")
-  if ((CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_DEBUGSERVER) OR (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_LLDB_SERVER_BUILD))
+  if ((CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_TEST_DEBUGSERVER) OR (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_LLDB_SERVER_BUILD))
 # These tests are meant to test lldb-server/debugserver in isolation, and
 # don't provide any value if run against a server copied from somewhere.
   else()
Index: tools/debugserver/source/CMakeLists.txt
===
--- tools/debugserver/source/CMakeLists.txt
+++ tools/debugserver/source/CMakeLists.txt
@@ -94,32 +94,102 @@
 
 add_library(lldbDebugserverCommon ${lldbDebugserverCommonSources})
 
+option(LLDB_NO_DEBUGSERVER "Disable the debugserver target" OFF)
+option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver instead of building it from source (Darwin only)." OFF)
 
-set(LLDB_CODESIGN_IDENTITY "lldb_codesign"
-  CACHE STRING "Identity used for code signing. Set to empty string to skip the signing step.")
+# Incompatible options
+if(LLDB_NO_DEBUGSERVER AND LLDB_USE_SYSTEM_DEBUGSERVER)
+  message(FATAL_ERROR "Inconsistent options: LLDB_NO_DEBUGSERVER and LLDB_USE_SYSTEM_DEBUGSERVER")
+endif()
 
-if(NOT LLDB_CODESIGN_IDENTITY STREQUAL "")
-  set(DEBUGSERVER_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "Path to debugserver.")
-  set(SKIP_DEBUGSERVER OFF CACHE BOOL "Skip building the in-tree debug server")
-else()
+# Try to locate the system debugserver.
+# Subsequent feasibility checks depend on it.
+if(APPLE AND CMAKE_HOST_APPLE)
   execute_process(
 COMMAND xcode-select -p
-OUTPUT_VARIABLE XCODE_DEV_DIR)
-  string(STRIP ${XCODE_DEV_DIR} XCODE_DEV_DIR)
-  if(EXISTS "${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/")
-set(DEBUGSERVER_PATH
-  "${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/Resources/debugserver" CACHE PATH "Path to debugserver.")
-  elseif(EXISTS "${XCODE_DEV_DIR}/Library/PrivateFrameworks/LLDB.framework/")
-set(DEBUGSERVER_PATH
-  "${XCODE_DEV_DIR}/Library/PrivateFrameworks/LLDB.framework/Resources/debugserver" CACHE PATH "Path to debugserver.")
+OUTPUT_VARIABLE xcode_dev_dir)
+  string(STRIP ${xcode_dev_dir} xcode_dev_dir)
+
+  set(debugserver_rel_path "LLDB.framework/Resources/debugserver")
+  set(debugserver_shared "${xcode_dev_dir}/../SharedFrameworks/${debugserver_rel_path}")
+  set(debugserver_private "${xcode_dev_dir}/Library/PrivateFrameworks/${debugserver_rel_path}")
+
+  if(EXISTS ${debugserver_shared})
+set(system_debugserver ${debugserver_shared})
+  elseif(EXISTS ${debugserver_private})
+set(system_debugserver ${debugserver_private})
+  endif()
+endif()
+
+# Handle unavailability
+if(LLDB_USE_SYSTEM_DEBUGSERVER)
+  if(system_debugserver)
+set(use_system_debugserver ON)
+  elseif(APPLE AND CMAKE_HOST_APPLE)
+# Binary not found on system. Keep cached variable, to try again on reconfigure.
+message(SEND_ERROR
+  "LLDB_USE_SYSTEM_DEBUGSERVER option set, but no debugserver found in:\
+${debugserver_shared}\
+${debugserver_private}")
   else()
-message(SEND_ERROR "Cannot find debugserver on system.")
+# Non-Apple target platform or non-Darwin host. Reset invalid cached variable.
+message(WARNING "Reverting invalid option LLDB_USE_SYSTEM_DEBUGSERVER (Darwin only)")
+set(LLDB_USE_SYSTEM_DEBUGSERVER OFF CACHE BOOL "" FORCE)
   endif()
-  set(SKIP_DEBUGSERVER ON CACHE BOOL "Skip building the in-tree debug server")
+elseif(NOT LLDB_NO_DEBUGSERVER)
+  # Default case: on Darwin we need the right code signing ID.
+  # See lldb/docs/code-signing.txt for details.
+  if(CMAKE_HOST_APPLE AND NOT LLVM_CODESIGNING_IDENTITY STREQUAL "lldb_codesign")
+set(msg "Cannot code sign debugserver with identity '${LLVM_CODESIGNING_IDENTITY}'.")
+if(system_debugserver)
+  message(WARNING "${msg} Will fall back to system's debugserver.")
+  set(use_system_debugserver ON)
+else()
+  message(WARNING "${msg} debugserver will not be available.")
+endif()
+  else()
+set(build_and_sign_debugserver ON)
+  endif()
+endif()
+
+# TODO: We don't use the $ generator expression here,
+# because the value of DEBUGSERVER_PATH is used to build LLDB_DOT

[Lldb-commits] [PATCH] D54914: Add a generic build script for building test inferiors

2018-11-28 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

I ran the tests with this change and there are about a dozen new failures:

  2018-11-28T20:25:29.2437909Z  
  2018-11-28T20:25:29.2581909Z  FAIL: LLDB :: 
SymbolFile/NativePDB/function-types-builtins.cpp (16962 of 45532)
  2018-11-28T20:25:29.2593650Z   TEST 'LLDB :: 
SymbolFile/NativePDB/function-types-builtins.cpp' FAILED 
  2018-11-28T20:25:29.2627299Z  Script:
  2018-11-28T20:25:29.2627541Z  --
  2018-11-28T20:25:29.2628080Z  : 'RUN: at line 4';   C:\Program Files 
(x86)\Microsoft Visual Studio\Shared\Python36_64\python.exe 
E:\_work\80\s\llvm\tools\lldb\lit\helper\build.py --compiler=any --arch=64 
--tools-dir=E:/_work/80/b/LLVMBuild/Release/bin --compiler=clang-cl 
--nodefaultlib -o 
E:\_work\80\b\LLVMBuild\tools\lldb\lit\SymbolFile\NativePDB\Output\function-types-builtins.cpp.tmp.exe
 -- 
E:\_work\80\s\llvm\tools\lldb\lit\SymbolFile\NativePDB\function-types-builtins.cpp
  2018-11-28T20:25:29.2629494Z  : 'RUN: at line 5';   env 
LLDB_USE_NATIVE_PDB_READER=1 E:\_work\80\b\LLVMBuild\Release\bin\lldb.EXE -S 
E:/_work/80/s/llvm/tools/lldb/lit\lit-lldb-init -f 
E:\_work\80\b\LLVMBuild\tools\lldb\lit\SymbolFile\NativePDB\Output\function-types-builtins.cpp.tmp.exe
 -s  
E:\_work\80\s\llvm\tools\lldb\lit\SymbolFile\NativePDB/Inputs/function-types-builtins.lldbinit
 | E:\_work\80\b\LLVMBuild\Release\bin\FileCheck.EXE 
E:\_work\80\s\llvm\tools\lldb\lit\SymbolFile\NativePDB\function-types-builtins.cpp
  2018-11-28T20:25:29.2629805Z  --
  2018-11-28T20:25:29.2629901Z  Exit Code: 127
  2018-11-28T20:25:29.2630016Z  
  2018-11-28T20:25:29.2630140Z  Command Output (stdout):
  2018-11-28T20:25:29.2630258Z  --
  2018-11-28T20:25:29.2630427Z  $ ":" "RUN: at line 4"
  2018-11-28T20:25:29.2630915Z  $ "C:\Program" "Files" 
"(x86)\Microsoft" "Visual" "Studio\Shared\Python36_64\python.exe" 
"E:\_work\80\s\llvm\tools\lldb\lit\helper\build.py" "--compiler=any" 
"--arch=64" "--tools-dir=E:/_work/80/b/LLVMBuild/Release/bin" 
"--compiler=clang-cl" "--nodefaultlib" "-o" 
"E:\_work\80\b\LLVMBuild\tools\lldb\lit\SymbolFile\NativePDB\Output\function-types-builtins.cpp.tmp.exe"
 "--" 
"E:\_work\80\s\llvm\tools\lldb\lit\SymbolFile\NativePDB\function-types-builtins.cpp"
  2018-11-28T20:25:29.2631273Z  # command stderr:
  2018-11-28T20:25:29.2631382Z  'C:\\Program': command not found

It looks like the script doesn't handle paths that have spaces correctly. I 
think the issue is on line 45 where we add sys.executable as the command - we 
need quotes around that. I'm going to rerun the tests with that change to see 
the result.




Comment at: lldb/lit/helper/toolchain.py:45
+ToolSubst('%build',
+  command=sys.executable,
+  extra_args=build_script_args)

I think this is where we need quotes around sys.executable, so that if the path 
contains spaces it is handled correctly


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

https://reviews.llvm.org/D54914



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


Re: [Lldb-commits] [PATCH] D54914: Add a generic build script for building test inferiors

2018-11-28 Thread Zachary Turner via lldb-commits
I can repro this, so I'll work on a fix.

On Wed, Nov 28, 2018 at 12:38 PM Stella Stamenova via Phabricator <
revi...@reviews.llvm.org> wrote:

> stella.stamenova added a comment.
>
> I ran the tests with this change and there are about a dozen new failures:
>
>   2018-11-28T20:25:29.2437909Z  
>   2018-11-28T20:25:29.2581909Z  FAIL: LLDB ::
> SymbolFile/NativePDB/function-types-builtins.cpp (16962 of 45532)
>   2018-11-28T20:25:29.2593650Z   TEST 'LLDB ::
> SymbolFile/NativePDB/function-types-builtins.cpp' FAILED
> 
>   2018-11-28T20:25:29.2627299Z  Script:
>   2018-11-28T20:25:29.2627541Z  --
>   2018-11-28T20:25:29.2628080Z  : 'RUN: at line 4';   C:\Program
> Files (x86)\Microsoft Visual Studio\Shared\Python36_64\python.exe
> E:\_work\80\s\llvm\tools\lldb\lit\helper\build.py --compiler=any --arch=64
> --tools-dir=E:/_work/80/b/LLVMBuild/Release/bin --compiler=clang-cl
> --nodefaultlib -o
> E:\_work\80\b\LLVMBuild\tools\lldb\lit\SymbolFile\NativePDB\Output\function-types-builtins.cpp.tmp.exe
> --
> E:\_work\80\s\llvm\tools\lldb\lit\SymbolFile\NativePDB\function-types-builtins.cpp
>   2018-11-28T20:25:29.2629494Z  : 'RUN: at line 5';   env
> LLDB_USE_NATIVE_PDB_READER=1 E:\_work\80\b\LLVMBuild\Release\bin\lldb.EXE
> -S E:/_work/80/s/llvm/tools/lldb/lit\lit-lldb-init -f
> E:\_work\80\b\LLVMBuild\tools\lldb\lit\SymbolFile\NativePDB\Output\function-types-builtins.cpp.tmp.exe
> -s
> E:\_work\80\s\llvm\tools\lldb\lit\SymbolFile\NativePDB/Inputs/function-types-builtins.lldbinit
> | E:\_work\80\b\LLVMBuild\Release\bin\FileCheck.EXE
> E:\_work\80\s\llvm\tools\lldb\lit\SymbolFile\NativePDB\function-types-builtins.cpp
>   2018-11-28T20:25:29.2629805Z  --
>   2018-11-28T20:25:29.2629901Z  Exit Code: 127
>   2018-11-28T20:25:29.2630016Z
>   2018-11-28T20:25:29.2630140Z  Command Output (stdout):
>   2018-11-28T20:25:29.2630258Z  --
>   2018-11-28T20:25:29.2630427Z  $ ":" "RUN: at line 4"
>   2018-11-28T20:25:29.2630915Z  $ "C:\Program" "Files"
> "(x86)\Microsoft" "Visual" "Studio\Shared\Python36_64\python.exe"
> "E:\_work\80\s\llvm\tools\lldb\lit\helper\build.py" "--compiler=any"
> "--arch=64" "--tools-dir=E:/_work/80/b/LLVMBuild/Release/bin"
> "--compiler=clang-cl" "--nodefaultlib" "-o"
> "E:\_work\80\b\LLVMBuild\tools\lldb\lit\SymbolFile\NativePDB\Output\function-types-builtins.cpp.tmp.exe"
> "--"
> "E:\_work\80\s\llvm\tools\lldb\lit\SymbolFile\NativePDB\function-types-builtins.cpp"
>   2018-11-28T20:25:29.2631273Z  # command stderr:
>   2018-11-28T20:25:29.2631382Z  'C:\\Program': command not found
>
> It looks like the script doesn't handle paths that have spaces correctly.
> I think the issue is on line 45 where we add sys.executable as the command
> - we need quotes around that. I'm going to rerun the tests with that change
> to see the result.
>
>
>
> 
> Comment at: lldb/lit/helper/toolchain.py:45
> +ToolSubst('%build',
> +  command=sys.executable,
> +  extra_args=build_script_args)
> 
> I think this is where we need quotes around sys.executable, so that if the
> path contains spaces it is handled correctly
>
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D54914/new/
>
> https://reviews.llvm.org/D54914
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D54914: Add a generic build script for building test inferiors

2018-11-28 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

It works for me when you make the command:

  command='"%s"' % (sys.executable),

I haven't tested it on Linux yet, but the tests work fine on Windows.


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

https://reviews.llvm.org/D54914



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


Re: [Lldb-commits] [PATCH] D54914: Add a generic build script for building test inferiors

2018-11-28 Thread Zachary Turner via lldb-commits
Yea, I don't really want to fix it there though because the problem will
just happen again.  I think it should be done inside of ToolSubst.

On Wed, Nov 28, 2018 at 12:59 PM Stella Stamenova via Phabricator <
revi...@reviews.llvm.org> wrote:

> stella.stamenova added a comment.
>
> It works for me when you make the command:
>
>   command='"%s"' % (sys.executable),
>
> I haven't tested it on Linux yet, but the tests work fine on Windows.
>
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D54914/new/
>
> https://reviews.llvm.org/D54914
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D43886: [lldb] Add GetCurrentException APIs to SBThread, add frame recognizer for objc_exception_throw for Obj-C runtimes

2018-11-28 Thread Kuba (Brecka) Mracek via Phabricator via lldb-commits
kubamracek updated this revision to Diff 175752.
kubamracek added a comment.

Updated patch. I've added a static 
`AppleObjCRuntime::GetExceptionThrowLocation()`, which returns the location of 
the exception throw breakpoint for the Obj-C runtime. I tried adding it as 
virtual method on LanguageRuntime instead, but then it wasn't clear to me how 
to make it easily return either an optional (there's runtimes that don't have 
exceptions) or an array (as you said, C++ will need multiple locations) and how 
to make existing code CreateExceptionResolver work with that. Let me know if 
that's okay.


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

https://reviews.llvm.org/D43886

Files:
  include/lldb/API/SBThread.h
  include/lldb/Target/StackFrameRecognizer.h
  include/lldb/Target/Thread.h
  packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
  source/API/SBThread.cpp
  source/Commands/CommandObjectThread.cpp
  source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
  source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
  source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
  source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  source/Target/StackFrameRecognizer.cpp
  source/Target/Thread.cpp

Index: source/Target/Thread.cpp
===
--- source/Target/Thread.cpp
+++ source/Target/Thread.cpp
@@ -25,6 +25,7 @@
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/StackFrameRecognizer.h"
 #include "lldb/Target/StopInfo.h"
 #include "lldb/Target/SystemRuntime.h"
 #include "lldb/Target/Target.h"
@@ -2186,3 +2187,18 @@
   }
   return error;
 }
+
+ValueObjectSP Thread::GetCurrentException() {
+  StackFrameSP frame_sp(GetStackFrameAtIndex(0));
+  if (!frame_sp) return ValueObjectSP();
+
+  RecognizedStackFrameSP recognized_frame(frame_sp->GetRecognizedFrame());
+  if (!recognized_frame) return ValueObjectSP();
+
+  return recognized_frame->GetExceptionObject();
+}
+
+/* TODO(kubamracek)
+ThreadSP Thread::GetCurrentExceptionBacktrace() {
+  return ThreadSP();
+}*/
Index: source/Target/StackFrameRecognizer.cpp
===
--- source/Target/StackFrameRecognizer.cpp
+++ source/Target/StackFrameRecognizer.cpp
@@ -49,8 +49,9 @@
 
 class StackFrameRecognizerManagerImpl {
 public:
-  void AddRecognizer(StackFrameRecognizerSP recognizer, ConstString &module,
- ConstString &symbol, bool first_instruction_only) {
+  void AddRecognizer(StackFrameRecognizerSP recognizer,
+ const ConstString &module, const ConstString &symbol,
+ bool first_instruction_only) {
 m_recognizers.push_front({(uint32_t)m_recognizers.size(), false, recognizer, false, module, RegularExpressionSP(),
   symbol, RegularExpressionSP(),
   first_instruction_only});
@@ -152,8 +153,8 @@
 }
 
 void StackFrameRecognizerManager::AddRecognizer(
-StackFrameRecognizerSP recognizer, ConstString &module, ConstString &symbol,
-bool first_instruction_only) {
+StackFrameRecognizerSP recognizer, const ConstString &module,
+const ConstString &symbol, bool first_instruction_only) {
   GetStackFrameRecognizerManagerImpl().AddRecognizer(recognizer, module, symbol,
  first_instruction_only);
 }
Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
===
--- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -25,6 +25,7 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
+#include "lldb/Core/ValueObjectConstResult.h"
 #include "lldb/Core/ValueObjectVariable.h"
 #include "lldb/Expression/DiagnosticManager.h"
 #include "lldb/Expression/FunctionCaller.h"
@@ -39,10 +40,12 @@
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/TypeList.h"
 #include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/ABI.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/StackFrameRecognizer.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Utility/ConstString.h"
@@ -373,6 +376,8 @@
   }
 }
 
+static void RegisterObjCExceptionRecognizer();
+
 AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process,
const ModuleSP &objc_module_sp)
 : AppleObjCRuntime(process), m_get_class_info_code(),
@@ -393,6 +398,7 @@
   static const ConstString g_gdb_object_g

[Lldb-commits] [PATCH] D43886: [lldb] Add GetCurrentException APIs to SBThread, add frame recognizer for objc_exception_throw for Obj-C runtimes

2018-11-28 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.

This isn't an external API, so we can generalize it when we get around to 
extending the Recognizers to C++ exceptions.  This is fine for now.

Thanks for doing this!


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

https://reviews.llvm.org/D43886



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


[Lldb-commits] [PATCH] D55013: [CMake] Streamline code signing for debugserver #2

2018-11-28 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: tools/debugserver/CMakeLists.txt:18
+
+  option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if 
available" ON)
+  set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING

Why do we need to define this option again for the debugserver? Why can't it 
use the one from LLDBConfig.cmake?


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

https://reviews.llvm.org/D55013



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


[Lldb-commits] [lldb] r347813 - [lldb] Add GetCurrentException APIs to SBThread, add frame recognizer for objc_exception_throw for Obj-C runtimes

2018-11-28 Thread Kuba Mracek via lldb-commits
Author: kuba.brecka
Date: Wed Nov 28 14:01:52 2018
New Revision: 347813

URL: http://llvm.org/viewvc/llvm-project?rev=347813&view=rev
Log:
[lldb] Add GetCurrentException APIs to SBThread, add frame recognizer for 
objc_exception_throw for Obj-C runtimes

This adds new APIs and a command to deal with exceptions (mostly Obj-C 
exceptions): SBThread and Thread get GetCurrentException API, which returns an 
SBValue/ValueObjectSP with the current exception for a thread. "Current" means 
an exception that is currently being thrown, caught or otherwise processed. In 
this patch, we only know about the exception when in objc_exception_throw, but 
subsequent patches will expand this (and add GetCurrentExceptionBacktrace, 
which will return an SBThread/ThreadSP containing a historical thread backtrace 
retrieved from the exception object. Currently unimplemented, subsequent 
patches will implement this).

Extracting the exception from objc_exception_throw is implemented by adding a 
frame recognizer.

This also add a new sub-command "thread exception", which prints the current 
exception.

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


Modified:
lldb/trunk/include/lldb/API/SBThread.h
lldb/trunk/include/lldb/Target/StackFrameRecognizer.h
lldb/trunk/include/lldb/Target/Thread.h

lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
lldb/trunk/source/API/SBThread.cpp
lldb/trunk/source/Commands/CommandObjectThread.cpp

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

lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h

lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp

lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/trunk/source/Target/StackFrameRecognizer.cpp
lldb/trunk/source/Target/Thread.cpp

Modified: lldb/trunk/include/lldb/API/SBThread.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=347813&r1=347812&r2=347813&view=diff
==
--- lldb/trunk/include/lldb/API/SBThread.h (original)
+++ lldb/trunk/include/lldb/API/SBThread.h Wed Nov 28 14:01:52 2018
@@ -198,6 +198,11 @@ public:
 
   uint32_t GetExtendedBacktraceOriginatingIndexID();
 
+  SBValue GetCurrentException();
+
+  // TODO(kubamracek): Extract backtrace from SBValue into SBThread
+  // SBThread GetCurrentExceptionBacktrace();
+
   bool SafeToCallFunctions();
 
 #ifndef SWIG

Modified: lldb/trunk/include/lldb/Target/StackFrameRecognizer.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrameRecognizer.h?rev=347813&r1=347812&r2=347813&view=diff
==
--- lldb/trunk/include/lldb/Target/StackFrameRecognizer.h (original)
+++ lldb/trunk/include/lldb/Target/StackFrameRecognizer.h Wed Nov 28 14:01:52 
2018
@@ -30,6 +30,9 @@ public:
   virtual lldb::ValueObjectListSP GetRecognizedArguments() {
 return m_arguments;
   }
+  virtual lldb::ValueObjectSP GetExceptionObject() {
+return lldb::ValueObjectSP();
+  }
   virtual ~RecognizedStackFrame(){};
 
 protected:
@@ -97,7 +100,8 @@ private:
 class StackFrameRecognizerManager {
 public:
   static void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
-ConstString &module, ConstString &symbol,
+const ConstString &module,
+const ConstString &symbol,
 bool first_instruction_only = true);
 
   static void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,

Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=347813&r1=347812&r2=347813&view=diff
==
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Wed Nov 28 14:01:52 2018
@@ -1253,6 +1253,11 @@ public:
   //--
   virtual uint64_t GetExtendedBacktraceToken() { return LLDB_INVALID_ADDRESS; }
 
+  lldb::ValueObjectSP GetCurrentException();
+
+  // TODO(kubamracek): Extract backtrace from ValueObjectSP into ThreadSP
+  // lldb::ThreadSP GetCurrentExceptionBacktrace();
+
 protected:
   friend class ThreadPlan;
   friend class ThreadList;

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py?rev=347813&r1=347812&r2=347813&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/T

[Lldb-commits] [PATCH] D43886: [lldb] Add GetCurrentException APIs to SBThread, add frame recognizer for objc_exception_throw for Obj-C runtimes

2018-11-28 Thread Kuba (Brecka) Mracek via Phabricator via lldb-commits
kubamracek added a comment.

Landed, thanks for the review!


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D43886



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


[Lldb-commits] [PATCH] D43886: [lldb] Add GetCurrentException APIs to SBThread, add frame recognizer for objc_exception_throw for Obj-C runtimes

2018-11-28 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB347813: [lldb] Add GetCurrentException APIs to SBThread, 
add frame recognizer for… (authored by kuba.brecka, committed by ).
Herald added a subscriber: teemperor.

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D43886

Files:
  include/lldb/API/SBThread.h
  include/lldb/Target/StackFrameRecognizer.h
  include/lldb/Target/Thread.h
  packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
  source/API/SBThread.cpp
  source/Commands/CommandObjectThread.cpp
  source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
  source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
  source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
  source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  source/Target/StackFrameRecognizer.cpp
  source/Target/Thread.cpp

Index: packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
===
--- packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
+++ packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
@@ -23,6 +23,16 @@
 target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
 self.assertTrue(target, VALID_TARGET)
 
+lldbutil.run_to_name_breakpoint(self, "objc_exception_throw")
+
+self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+substrs=['stopped', 'stop reason = breakpoint'])
+
+self.expect('thread exception', substrs=[
+'(NSException *) exception = ',
+'name: "ThrownException" - reason: "SomeReason"',
+])
+
 lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.m"))
 
 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
Index: source/API/SBThread.cpp
===
--- source/API/SBThread.cpp
+++ source/API/SBThread.cpp
@@ -1484,6 +1484,21 @@
   return LLDB_INVALID_INDEX32;
 }
 
+SBValue SBThread::GetCurrentException() {
+  ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
+  if (!thread_sp) return SBValue();
+
+  return SBValue(thread_sp->GetCurrentException());
+}
+
+/* TODO(kubamracek)
+SBThread SBThread::GetCurrentExceptionBacktrace() {
+  ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
+  if (!thread_sp) return SBThread();
+
+  return SBThread(thread_sp->GetCurrentExceptionBacktrace());
+}*/
+
 bool SBThread::SafeToCallFunctions() {
   ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
   if (thread_sp)
Index: source/Target/StackFrameRecognizer.cpp
===
--- source/Target/StackFrameRecognizer.cpp
+++ source/Target/StackFrameRecognizer.cpp
@@ -49,8 +49,9 @@
 
 class StackFrameRecognizerManagerImpl {
 public:
-  void AddRecognizer(StackFrameRecognizerSP recognizer, ConstString &module,
- ConstString &symbol, bool first_instruction_only) {
+  void AddRecognizer(StackFrameRecognizerSP recognizer,
+ const ConstString &module, const ConstString &symbol,
+ bool first_instruction_only) {
 m_recognizers.push_front({(uint32_t)m_recognizers.size(), false, recognizer, false, module, RegularExpressionSP(),
   symbol, RegularExpressionSP(),
   first_instruction_only});
@@ -152,8 +153,8 @@
 }
 
 void StackFrameRecognizerManager::AddRecognizer(
-StackFrameRecognizerSP recognizer, ConstString &module, ConstString &symbol,
-bool first_instruction_only) {
+StackFrameRecognizerSP recognizer, const ConstString &module,
+const ConstString &symbol, bool first_instruction_only) {
   GetStackFrameRecognizerManagerImpl().AddRecognizer(recognizer, module, symbol,
  first_instruction_only);
 }
Index: source/Target/Thread.cpp
===
--- source/Target/Thread.cpp
+++ source/Target/Thread.cpp
@@ -25,6 +25,7 @@
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/StackFrameRecognizer.h"
 #include "lldb/Target/StopInfo.h"
 #include "lldb/Target/SystemRuntime.h"
 #include "lldb/Target/Target.h"
@@ -2199,3 +2200,18 @@
   }
   return error;
 }
+
+ValueObjectSP Thread::GetCurrentException() {
+  StackFrameSP frame_sp(GetStackFrameAtIndex(0));
+  if (!frame_sp) return ValueObjectSP();
+
+  RecognizedStackFrameSP recognized_frame(frame_sp->GetRecognizedFrame());
+  if (!recognized_frame) return ValueObjectSP();
+
+  return recognized_frame->GetExceptionObject();
+}
+
+/* TODO(kubamracek)
+ThreadSP Thread::GetCurrentExceptio

[Lldb-commits] [lldb] r347814 - Make standalone build find tabelgen

2018-11-28 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Nov 28 14:10:01 2018
New Revision: 347814

URL: http://llvm.org/viewvc/llvm-project?rev=347814&view=rev
Log:
Make standalone build find tabelgen

The standalone build couldn't find tablegen because we didn't include
it. This patch rectifies that.

Modified:
lldb/trunk/cmake/modules/LLDBStandalone.cmake

Modified: lldb/trunk/cmake/modules/LLDBStandalone.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBStandalone.cmake?rev=347814&r1=347813&r2=347814&view=diff
==
--- lldb/trunk/cmake/modules/LLDBStandalone.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBStandalone.cmake Wed Nov 28 14:10:01 2018
@@ -83,6 +83,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   endif()
 
   include(AddLLVM)
+  include(TableGen)
   include(HandleLLVMOptions)
   include(CheckAtomic)
 


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


[Lldb-commits] [lldb] r347817 - [driver] Some NFC cleanup

2018-11-28 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Nov 28 14:39:17 2018
New Revision: 347817

URL: http://llvm.org/viewvc/llvm-project?rev=347817&view=rev
Log:
[driver] Some NFC cleanup

This patch includes some small things I noticed while refactoring the
driver but didn't want to include in that patch.

Modified:
lldb/trunk/tools/driver/Driver.cpp
lldb/trunk/tools/driver/Driver.h

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=347817&r1=347816&r2=347817&view=diff
==
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Wed Nov 28 14:39:17 2018
@@ -26,9 +26,11 @@
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/Format.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 
 #include 
@@ -280,8 +282,7 @@ bool Driver::GetDebugMode() const { retu
 // indicating whether or not to start up the full debugger (i.e. the Command
 // Interpreter) or not.  Return FALSE if the arguments were invalid OR if the
 // user only wanted help or version information.
-SBError Driver::ProcessArgs(const opt::InputArgList &args, FILE *out_fh,
-bool &exiting) {
+SBError Driver::ProcessArgs(const opt::InputArgList &args, bool &exiting) {
   SBError error;
   ResetOptionValues();
 
@@ -497,15 +498,12 @@ SBError Driver::ProcessArgs(const opt::I
   for (auto value : arg->getValues())
 m_option_data.m_args.push_back(value);
 }
-  } else {
-if (args.getLastArgNoClaim()) {
-  ::fprintf(out_fh,
-"Warning: program arguments are ignored when attaching.\n");
-}
+  } else if (args.getLastArgNoClaim()) {
+WithColor::warning() << "program arguments are ignored when attaching.\n";
   }
 
   if (m_option_data.m_print_version) {
-::fprintf(out_fh, "%s\n", m_debugger.GetVersionString());
+llvm::outs() << m_debugger.GetVersionString() << '\n';
 exiting = true;
 return error;
   }
@@ -516,11 +514,11 @@ SBError Driver::ProcessArgs(const opt::I
   char python_path[PATH_MAX];
   size_t num_chars = python_file_spec.GetPath(python_path, PATH_MAX);
   if (num_chars < PATH_MAX) {
-::fprintf(out_fh, "%s\n", python_path);
+llvm::outs() << python_path << '\n';
   } else
-::fprintf(out_fh, "\n");
+llvm::outs() << "\n";
 } else
-  ::fprintf(out_fh, "\n");
+  llvm::outs() << "\n";
 exiting = true;
 return error;
   }
@@ -544,11 +542,13 @@ static ::FILE *PrepareCommandsForSourcin
   if (err == 0) {
 ssize_t nrwr = write(fds[WRITE], commands_data, commands_size);
 if (nrwr < 0) {
-  fprintf(stderr,
-  "error: write(%i, %p, %" PRIu64 ") failed (errno = %i) "
-  "when trying to open LLDB commands pipe\n",
-  fds[WRITE], static_cast(commands_data),
-  static_cast(commands_size), errno);
+  WithColor::error()
+  << format(
+ "write(%i, %p, %" PRIu64
+ ") failed (errno = %i) when trying to open LLDB commands 
pipe",
+ fds[WRITE], static_cast(commands_data),
+ static_cast(commands_size), errno)
+  << '\n';
 } else if (static_cast(nrwr) == commands_size) {
 // Close the write end of the pipe so when we give the read end to
 // the debugger/command interpreter it will exit when it consumes all
@@ -568,15 +568,15 @@ static ::FILE *PrepareCommandsForSourcin
 // descriptor Hand ownership if the FILE * over to the
 // debugger for "commands_file".
   } else {
-fprintf(stderr,
-"error: fdopen(%i, \"r\") failed (errno = %i) when "
-"trying to open LLDB commands pipe\n",
-fds[READ], errno);
+WithColor::error() << format("fdopen(%i, \"r\") failed (errno = %i) "
+ "when trying to open LLDB commands pipe",
+ fds[READ], errno)
+   << '\n';
   }
 }
   } else {
-fprintf(stderr,
-"error: can't create pipe file descriptors for LLDB commands\n");
+WithColor::error()
+<< "can't create pipe file descriptors for LLDB commands\n";
   }
 
   return commands_file;
@@ -724,9 +724,9 @@ int Driver::MainLoop() {
 if (error.Fail()) {
   const char *error_cstr = error.GetCString();
   if (error_cstr && error_cstr[0])
-fprintf(stderr, "error: %s\n", error_cstr);
+WithColor::error() << error_cstr << '\n';
   else
-fprintf(stderr, "error: %u\n", error.GetError());
+WithColor::error() << error.GetError() << '\n';
 }
   } else {
 // Check if we have

[Lldb-commits] [PATCH] D55032: [CMake] Fix standalone build for debugserver on macOS

2018-11-28 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz created this revision.
sgraenitz added reviewers: xiaobai, beanz.
Herald added a subscriber: mgorny.

Quick-fix to avoid CMake config issue:

  CMake Error at /path/to/lldb/cmake/modules/AddLLDB.cmake:116 
(add_dependencies):
Cannot add target-level dependencies to non-existent target "lldb-suite".


https://reviews.llvm.org/D55032

Files:
  tools/debugserver/CMakeLists.txt


Index: tools/debugserver/CMakeLists.txt
===
--- tools/debugserver/CMakeLists.txt
+++ tools/debugserver/CMakeLists.txt
@@ -15,6 +15,11 @@
   set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
   include_directories(${LLDB_SOURCE_DIR}/include)
 
+  # lldb-suite is a dummy target that encompasses all the necessary tools and
+  # libraries for building a fully-functioning liblldb.
+  add_custom_target(lldb-suite)
+  set(LLDB_SUITE_TARGET lldb-suite)
+
   option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if 
available" ON)
   set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
   "Identity for code signing debugserver (Darwin only)")


Index: tools/debugserver/CMakeLists.txt
===
--- tools/debugserver/CMakeLists.txt
+++ tools/debugserver/CMakeLists.txt
@@ -15,6 +15,11 @@
   set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
   include_directories(${LLDB_SOURCE_DIR}/include)
 
+  # lldb-suite is a dummy target that encompasses all the necessary tools and
+  # libraries for building a fully-functioning liblldb.
+  add_custom_target(lldb-suite)
+  set(LLDB_SUITE_TARGET lldb-suite)
+
   option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if available" ON)
   set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
   "Identity for code signing debugserver (Darwin only)")
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D54747: Discard debuginfo for object files empty after GC

2018-11-28 Thread Rui Ueyama via Phabricator via lldb-commits
ruiu added a comment.

Thank you for the patch.

What you are doing in this patch is not too complicated and makes sense to me. 
That said, if actual size saving is not significant as you said in 
https://github.com/rust-lang/rust/issues/56068#issuecomment-440160568, it may 
not be worth doing. It seems to me that if debug info is already 2.4GB, 
shrinking it to 2GB doesn't make much difference. Do you have more convincing 
examples?


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D54747



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


[Lldb-commits] [PATCH] D55013: [CMake] Streamline code signing for debugserver #2

2018-11-28 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz marked an inline comment as done.
sgraenitz added a comment.

Thanks for having a look.




Comment at: tools/debugserver/CMakeLists.txt:18
+
+  option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if 
available" ON)
+  set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING

JDevlieghere wrote:
> Why do we need to define this option again for the debugserver? Why can't it 
> use the one from LLDBConfig.cmake?
In a debugserver standalone build we don't `include(LLDBConfig)`. It makes 
sense to me, because there is not much to configure when only building the 
debugserver.


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

https://reviews.llvm.org/D55013



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


[Lldb-commits] [PATCH] D55032: [CMake] Fix standalone build for debugserver on macOS

2018-11-28 Thread Alex Langford via Phabricator via lldb-commits
xiaobai accepted this revision.
xiaobai added a comment.
This revision is now accepted and ready to land.

This change looks fine to me. Have you considered creating something like a 
"debugserverStandalone.cmake" file similar to how LLDB standalone builds work? 
Might save us from some duplication, but I'm not sure if it would be overkill.


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

https://reviews.llvm.org/D55032



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


[Lldb-commits] [PATCH] D54747: Discard debuginfo for object files empty after GC

2018-11-28 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added a comment.

If we decide to optimize DWARF garbage collection, something generic will be 
cool.

This generic-abi thread has some discussion about that 
https://groups.google.com/d/msg/generic-abi/A-1rbP8hFCA/EDA7Sf3KBwAJ (e.g. 
using COMDAT but it seems challenging and it comes with its own costs)


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D54747



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


[Lldb-commits] [PATCH] D55013: [CMake] Streamline code signing for debugserver #2

2018-11-28 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added a comment.

In-tree builds look good now. I successfully built and tested with these 
configurations:

  green dragon: xcrun cmake -GNinja -DCMAKE_BUILD_TYPE=Release 
-DLLVM_ENABLE_ASSERTIONS=On -DLLVM_ENABLE_MODULES=On ../llvm
  my default: xcrun cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo 
-DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" ../llvm

Had a short look at standalone builds. Including the test suite is currently 
not supported. With this config I could build the binaries successfully (with a 
quick-fix for debugserver D55032 ):

  LLDB standalone: xcrun cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo 
-DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" 
-DLLVM_CONFIG=/path/to/llvm-build/llvm-config ../lldb
  debugserver standalone: xcrun cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo 
-DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" 
-DLLVM_CONFIG=/path/to/llvm-build/bin/llvm-config ../lldb/tools/debugserver


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

https://reviews.llvm.org/D55013



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


[Lldb-commits] [PATCH] D55013: [CMake] Streamline code signing for debugserver #2

2018-11-28 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: tools/debugserver/CMakeLists.txt:18
+
+  option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if 
available" ON)
+  set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING

sgraenitz wrote:
> JDevlieghere wrote:
> > Why do we need to define this option again for the debugserver? Why can't 
> > it use the one from LLDBConfig.cmake?
> In a debugserver standalone build we don't `include(LLDBConfig)`. It makes 
> sense to me, because there is not much to configure when only building the 
> debugserver.
Makes sense. Maybe we could put this in the top level CMakeLists.txt? 


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

https://reviews.llvm.org/D55013



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


[Lldb-commits] [PATCH] D54692: [Driver] Use libOption with tablegen.

2018-11-28 Thread Leonard Mosescu via Phabricator via lldb-commits
lemo added a comment.

I noticed a small problem, this change breaks "lldb -c ". The inline 
comment explains the root cause.

Thanks




Comment at: lldb/trunk/tools/driver/Driver.cpp:310
+  if (args.hasArg(OPT_core)) {
+SBFileSpec file(optarg);
+if (file.Exists()) {

there's a small bug in here: optarg is the global definition, I assume the 
intention was to use the getValue() instead. as is, it breaks "lldb -c 
"

it would be nice to get rid the global optarg as well since it masks these kind 
of mistakes.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D54692



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


[Lldb-commits] [lldb] r347821 - [driver] Fix --core/-c and add test

2018-11-28 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Nov 28 16:22:28 2018
New Revision: 347821

URL: http://llvm.org/viewvc/llvm-project?rev=347821&view=rev
Log:
[driver] Fix --core/-c and add test

Because the optarg variable was shadowed we didn't notice we weren't
extracting the value from the option. This patch fixes that and renames
the variable to prevent this from happening in the future.

I also added two tests to check the error output for --core and --file
when the given value doesn't exist.

Added:
lldb/trunk/lit/Driver/TestCore.test
lldb/trunk/lit/Driver/TestFile.test
Modified:
lldb/trunk/tools/driver/Driver.cpp
lldb/trunk/tools/driver/Options.td

Added: lldb/trunk/lit/Driver/TestCore.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Driver/TestCore.test?rev=347821&view=auto
==
--- lldb/trunk/lit/Driver/TestCore.test (added)
+++ lldb/trunk/lit/Driver/TestCore.test Wed Nov 28 16:22:28 2018
@@ -0,0 +1,2 @@
+# RUN: not %lldb -c /bogus/path 2>&1 | FileCheck %s
+# CHECK: error: file specified in --core (-c) option doesn't exist

Added: lldb/trunk/lit/Driver/TestFile.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Driver/TestFile.test?rev=347821&view=auto
==
--- lldb/trunk/lit/Driver/TestFile.test (added)
+++ lldb/trunk/lit/Driver/TestFile.test Wed Nov 28 16:22:28 2018
@@ -0,0 +1,2 @@
+# RUN: not %lldb -f /bogus/path 2>&1 | FileCheck %s
+# CHECK: error: file specified in --file (-f) option doesn't exist

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=347821&r1=347820&r2=347821&view=diff
==
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Wed Nov 28 16:22:28 2018
@@ -307,15 +307,16 @@ SBError Driver::ProcessArgs(const opt::I
 m_option_data.m_batch = true;
   }
 
-  if (args.hasArg(OPT_core)) {
-SBFileSpec file(optarg);
-if (file.Exists()) {
-  m_option_data.m_core_file = optarg;
-} else {
+  if (auto *arg = args.getLastArg(OPT_core)) {
+auto arg_value = arg->getValue();
+SBFileSpec file(arg_value);
+if (!file.Exists()) {
   error.SetErrorStringWithFormat(
-  "file specified in --core (-c) option doesn't exist: '%s'", optarg);
+  "file specified in --core (-c) option doesn't exist: '%s'",
+  arg_value);
   return error;
 }
+m_option_data.m_core_file = arg_value;
   }
 
   if (args.hasArg(OPT_editor)) {
@@ -332,33 +333,34 @@ SBError Driver::ProcessArgs(const opt::I
   }
 
   if (auto *arg = args.getLastArg(OPT_file)) {
-auto optarg = arg->getValue();
-SBFileSpec file(optarg);
+auto arg_value = arg->getValue();
+SBFileSpec file(arg_value);
 if (file.Exists()) {
-  m_option_data.m_args.push_back(optarg);
+  m_option_data.m_args.push_back(arg_value);
 } else if (file.ResolveExecutableLocation()) {
   char path[PATH_MAX];
   file.GetPath(path, sizeof(path));
   m_option_data.m_args.push_back(path);
 } else {
   error.SetErrorStringWithFormat(
-  "file specified in --file (-f) option doesn't exist: '%s'", optarg);
+  "file specified in --file (-f) option doesn't exist: '%s'",
+  arg_value);
   return error;
 }
   }
 
   if (auto *arg = args.getLastArg(OPT_arch)) {
-auto optarg = arg->getValue();
-if (!m_debugger.SetDefaultArchitecture(optarg)) {
+auto arg_value = arg->getValue();
+if (!m_debugger.SetDefaultArchitecture(arg_value)) {
   error.SetErrorStringWithFormat(
-  "invalid architecture in the -a or --arch option: '%s'", optarg);
+  "invalid architecture in the -a or --arch option: '%s'", arg_value);
   return error;
 }
   }
 
   if (auto *arg = args.getLastArg(OPT_script_language)) {
-auto optarg = arg->getValue();
-m_option_data.m_script_lang = m_debugger.GetScriptingLanguage(optarg);
+auto arg_value = arg->getValue();
+m_option_data.m_script_lang = m_debugger.GetScriptingLanguage(arg_value);
   }
 
   if (args.hasArg(OPT_no_use_colors)) {
@@ -366,16 +368,16 @@ SBError Driver::ProcessArgs(const opt::I
   }
 
   if (auto *arg = args.getLastArg(OPT_reproducer)) {
-auto optarg = arg->getValue();
-SBFileSpec file(optarg);
+auto arg_value = arg->getValue();
+SBFileSpec file(arg_value);
 if (file.Exists()) {
-  SBError repro_error = m_debugger.ReplayReproducer(optarg);
+  SBError repro_error = m_debugger.ReplayReproducer(arg_value);
   if (repro_error.Fail())
 return repro_error;
 } else {
   error.SetErrorStringWithFormat("file specified in --reproducer "
  "(-z) option doesn't exist: '%s'",
- optarg);
+ 

[Lldb-commits] [PATCH] D55038: [Reproducers] Change how reproducers are initialized.

2018-11-28 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: jingham, aprantl, sgraenitz, labath.
JDevlieghere added a project: LLDB.
Herald added subscribers: teemperor, abidh, mgorny.

This patch changes the way the reproducer is initialized. Rather than making 
changes at run time we now do everything at initialization time. To make this 
happen we had to introduce initializer options and their SB variant. This 
allows us to tell the initializer that we're running in reproducer 
capture/replay mode.

Because of this change we also had to alter our testing strategy. We cannot 
reinitialize LLDB when using the dotest infrastructure. Instead we use lit and 
invoke two instances of the driver.

Another consequence is that we can no longer enable capture or replay through 
commands. This was bound to go away form the beginning, but I had something in 
mind where you could enable/disable specific providers. However this seems like 
it adds very little value right now so I just removed the corresponding 
commands. This also means you now have to control this through the driver, for 
which I replaced `--reproducer` with `--capture` and `--replay`.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D55038

Files:
  include/lldb/API/SBDebugger.h
  include/lldb/API/SBDefines.h
  include/lldb/API/SBFileSpec.h
  include/lldb/API/SBInitializerOptions.h
  include/lldb/Core/Debugger.h
  include/lldb/Host/HostInfoBase.h
  include/lldb/Initialization/SystemInitializer.h
  include/lldb/Initialization/SystemInitializerCommon.h
  include/lldb/Initialization/SystemLifetimeManager.h
  include/lldb/Utility/Reproducer.h
  lit/Reproducer/Inputs/GDBRemoteCapture.in
  lit/Reproducer/Inputs/GDBRemoteReplay.in
  lit/Reproducer/Inputs/simple.c
  lit/Reproducer/TestGDBRemoteRepro.test
  packages/Python/lldbsuite/test/functionalities/reproducer/gdb-remote/Makefile
  
packages/Python/lldbsuite/test/functionalities/reproducer/gdb-remote/TestGdbRemoteReproducer.py
  packages/Python/lldbsuite/test/functionalities/reproducer/gdb-remote/main.c
  scripts/interface/SBDebugger.i
  scripts/interface/SBInitializerOptions.i
  scripts/lldb.swig
  source/API/CMakeLists.txt
  source/API/SBDebugger.cpp
  source/API/SBInitializerOptions.cpp
  source/API/SystemInitializerFull.cpp
  source/API/SystemInitializerFull.h
  source/Commands/CommandObjectReproducer.cpp
  source/Core/Debugger.cpp
  source/Host/common/HostInfoBase.cpp
  source/Initialization/SystemInitializerCommon.cpp
  source/Initialization/SystemLifetimeManager.cpp
  source/Utility/Reproducer.cpp
  tools/driver/CMakeLists.txt
  tools/driver/Driver.cpp
  tools/driver/Options.td
  tools/lldb-server/SystemInitializerLLGS.cpp
  tools/lldb-server/SystemInitializerLLGS.h
  tools/lldb-server/lldb-server.cpp
  tools/lldb-test/SystemInitializerTest.cpp
  tools/lldb-test/SystemInitializerTest.h
  tools/lldb-test/lldb-test.cpp
  unittests/Utility/ReproducerTest.cpp

Index: unittests/Utility/ReproducerTest.cpp
===
--- unittests/Utility/ReproducerTest.cpp
+++ unittests/Utility/ReproducerTest.cpp
@@ -32,34 +32,44 @@
   static char ID;
 };
 
+class DummyReproducer : public Reproducer {
+public:
+  DummyReproducer() : Reproducer(){};
+
+  llvm::Error SetCapture(bool b) { return Reproducer::SetCapture(b); }
+
+  llvm::Error SetReplay(llvm::Optional root) {
+return Reproducer::SetReplay(root);
+  }
+};
+
 char DummyProvider::ID = 0;
 
 TEST(ReproducerTest, SetCapture) {
-  Reproducer reproducer;
+  DummyReproducer reproducer;
 
   // Initially both generator and loader are unset.
   EXPECT_EQ(nullptr, reproducer.GetGenerator());
   EXPECT_EQ(nullptr, reproducer.GetLoader());
 
   // Enable capture and check that means we have a generator.
-  EXPECT_THAT_ERROR(reproducer.SetCapture(FileSpec("/bogus/path")),
-Succeeded());
+  EXPECT_THAT_ERROR(reproducer.SetCapture(true), Succeeded());
   EXPECT_NE(nullptr, reproducer.GetGenerator());
-  EXPECT_EQ(FileSpec("/bogus/path"), reproducer.GetGenerator()->GetRoot());
-  EXPECT_EQ(FileSpec("/bogus/path"), reproducer.GetReproducerPath());
+  EXPECT_NE(FileSpec(), reproducer.GetGenerator()->GetRoot());
+  EXPECT_NE(FileSpec(), reproducer.GetReproducerPath());
 
   // Ensure that we cannot enable replay.
   EXPECT_THAT_ERROR(reproducer.SetReplay(FileSpec("/bogus/path")), Failed());
   EXPECT_EQ(nullptr, reproducer.GetLoader());
 
   // Ensure we can disable the generator again.
-  EXPECT_THAT_ERROR(reproducer.SetCapture(llvm::None), Succeeded());
+  EXPECT_THAT_ERROR(reproducer.SetCapture(false), Succeeded());
   EXPECT_EQ(nullptr, reproducer.GetGenerator());
   EXPECT_EQ(nullptr, reproducer.GetLoader());
 }
 
 TEST(ReproducerTest, SetReplay) {
-  Reproducer reproducer;
+  DummyReproducer reproducer;
 
   // Initially both generator and loader are unset.
   EXPECT_EQ(nullptr, reproducer.GetGenerator());
@@ -75,30 +85,27 @@
   EXPECT_EQ(FileSpec("/bogus/path"), reproducer.GetReprod

Re: [Lldb-commits] [PATCH] D54692: [Driver] Use libOption with tablegen.

2018-11-28 Thread Jonas Devlieghere via lldb-commits
Thanks, Zachary also pinged me on IRC. This was fixed in r347821.

> On Nov 28, 2018, at 4:09 PM, Leonard Mosescu via Phabricator 
>  wrote:
> 
> lemo added a comment.
> 
> I noticed a small problem, this change breaks "lldb -c ". The 
> inline comment explains the root cause.
> 
> Thanks
> 
> 
> 
> 
> Comment at: lldb/trunk/tools/driver/Driver.cpp:310
> +  if (args.hasArg(OPT_core)) {
> +SBFileSpec file(optarg);
> +if (file.Exists()) {
> 
> there's a small bug in here: optarg is the global definition, I assume the 
> intention was to use the getValue() instead. as is, it breaks "lldb -c 
> "
> 
> it would be nice to get rid the global optarg as well since it masks these 
> kind of mistakes.
> 
> 
> Repository:
>  rL LLVM
> 
> CHANGES SINCE LAST ACTION
>  https://reviews.llvm.org/D54692/new/
> 
> https://reviews.llvm.org/D54692
> 
> 
> 

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


[Lldb-commits] [PATCH] D54747: Discard debuginfo for object files empty after GC

2018-11-28 Thread Eric Christopher via Phabricator via lldb-commits
echristo added a comment.

In D54747#1312161 , @ruiu wrote:

> Thank you for the patch.
>
> What you are doing in this patch is not too complicated and makes sense to 
> me. That said, if actual size saving is not significant as you said in 
> https://github.com/rust-lang/rust/issues/56068#issuecomment-440160568, it may 
> not be worth doing. It seems to me that if debug info is already 2.4GB, 
> shrinking it to 2GB doesn't make much difference. Do you have more convincing 
> examples?


400MB is 400MB... or, if you'd prefer 17% of overall size that was mentioned 
there. Additional testing might be nice in order to get a better idea of what 
we're looking at in practice (I guess a clang build would be another good 
choice), but the overall patch seems to be small and in a lot of ways 
simplifying for how we're linking.


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D54747



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


[Lldb-commits] [PATCH] D53368: [Symbol] Search symbols with name and type in a symbol file

2018-11-28 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

Ping! Can you take a look, please?


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

https://reviews.llvm.org/D53368



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