[Lldb-commits] [PATCH] D66249: [JIT][Breakpoint] Add "BreakpointInjectedSite" and FCB Trampoline

2019-08-27 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Ok, it sounds we're in agreement then. I'l looking forward to the updated 
patches. :)




Comment at: lldb/include/lldb/Target/ABI.h:165
+
+  virtual size_t GetJumpSize() { return 0; }
+

mib wrote:
> labath wrote:
> > The point of my earlier suggestion to use ArrayRef is that you don't need 
> > to have a separate `XXXSize` function. `ArrayRef` will encode both 
> > the size and the contents.
> > 
> > That said, I'm not convinced that this is a good api anyway. I think it 
> > would be extremely hard to make anything on top of these functions that 
> > would *not* be target specific (e.g. how would you handle the fact that on 
> > arm the jump target is expressed as a relative offset to the address of the 
> > jump instruction **+ 8**?).
> > 
> > I think it would be better to just have the ABI plugin just return the 
> > fully constructed trampoline jump sequence (say by giving it the final 
> > address of the sequence, and the address it should jump to) instead of 
> > somebody trying to create a target-independent assembler on top of it.
> I got rid of those getters, except `GetJumpSize`, which is used in the 
> `Process::SaveInstructions` method to copy enough instructions to write the 
> jump instruction.
Ok, I see. In that case, I'd recommend tweaking the interfaces so that this 
isn't needed also. For instance, the ABI plugin could save the instructions 
itself, or it could just return the bytes it wants to write, and have the 
Process class (or somebody) do the actual writing. The advantages of that would 
be:
- the knowledge about the size of the jump instruction (sequence) is encoded in 
a single place
- the abi class is free to dynamically choose the best jump sequence based on 
the target address (e.g., on thumb, the range for a single jump instruction is 
ridiculously small, and even the +/-2GB range in intel may not always be enough)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66249



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


[Lldb-commits] [lldb] r370026 - Fix an unused variable warning in no-assert builds

2019-08-27 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Aug 27 00:46:07 2019
New Revision: 370026

URL: http://llvm.org/viewvc/llvm-project?rev=370026&view=rev
Log:
Fix an unused variable warning in no-assert builds

Modified:
lldb/trunk/source/Host/common/MainLoop.cpp

Modified: lldb/trunk/source/Host/common/MainLoop.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/MainLoop.cpp?rev=370026&r1=370025&r2=370026&view=diff
==
--- lldb/trunk/source/Host/common/MainLoop.cpp (original)
+++ lldb/trunk/source/Host/common/MainLoop.cpp Tue Aug 27 00:46:07 2019
@@ -320,6 +320,7 @@ MainLoop::RegisterSignal(int signo, cons
   // Even if using kqueue, the signal handler will still be invoked, so it's
   // important to replace it with our "benign" handler.
   int ret = sigaction(signo, &new_action, &info.old_action);
+  (void)ret;
   assert(ret == 0 && "sigaction failed");
 
 #if HAVE_SYS_EVENT_H


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


[Lldb-commits] [lldb] r370027 - DWARFExpression: Simplify class interface

2019-08-27 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Aug 27 00:49:41 2019
New Revision: 370027

URL: http://llvm.org/viewvc/llvm-project?rev=370027&view=rev
Log:
DWARFExpression: Simplify class interface

Summary:
The DWARFExpression methods have a lot of arguments. This removes two of
them by removing the ability to slice the expression via two offset+size
parameters. This is a functionality that it is not always needed, and
when it is, we already have a different handy way of slicing a data
extractor which we can use instead.

Reviewers: JDevlieghere, clayborg

Subscribers: aprantl, lldb-commits

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

Modified:
lldb/trunk/include/lldb/Expression/DWARFExpression.h
lldb/trunk/source/Expression/DWARFExpression.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp
lldb/trunk/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
lldb/trunk/source/Target/RegisterContext.cpp
lldb/trunk/unittests/Expression/DWARFExpressionTest.cpp

Modified: lldb/trunk/include/lldb/Expression/DWARFExpression.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/DWARFExpression.h?rev=370027&r1=370026&r2=370027&view=diff
==
--- lldb/trunk/include/lldb/Expression/DWARFExpression.h (original)
+++ lldb/trunk/include/lldb/Expression/DWARFExpression.h Tue Aug 27 00:49:41 
2019
@@ -50,15 +50,8 @@ public:
   /// \param[in] data
   /// A data extractor configured to read the DWARF location expression's
   /// bytecode.
-  ///
-  /// \param[in] data_offset
-  /// The offset of the location expression in the extractor.
-  ///
-  /// \param[in] data_length
-  /// The byte length of the location expression.
   DWARFExpression(lldb::ModuleSP module, const DataExtractor &data,
-  const DWARFUnit *dwarf_cu, lldb::offset_t data_offset,
-  lldb::offset_t data_length);
+  const DWARFUnit *dwarf_cu);
 
   /// Destructor
   virtual ~DWARFExpression();
@@ -211,12 +204,6 @@ public:
   /// in the case where an expression needs to be evaluated while building
   /// the stack frame list, this short-cut is available.
   ///
-  /// \param[in] offset
-  /// The offset of the location expression in the data extractor.
-  ///
-  /// \param[in] length
-  /// The length in bytes of the location expression.
-  ///
   /// \param[in] reg_set
   /// The call-frame-info style register kind.
   ///
@@ -236,8 +223,7 @@ public:
   /// details of the failure are provided through it.
   static bool Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx,
lldb::ModuleSP opcode_ctx, const DataExtractor &opcodes,
-   const DWARFUnit *dwarf_cu, const lldb::offset_t offset,
-   const lldb::offset_t length,
+   const DWARFUnit *dwarf_cu,
const lldb::RegisterKind reg_set,
const Value *initial_value_ptr,
const Value *object_address_ptr, Value &result,

Modified: lldb/trunk/source/Expression/DWARFExpression.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=370027&r1=370026&r2=370027&view=diff
==
--- lldb/trunk/source/Expression/DWARFExpression.cpp (original)
+++ lldb/trunk/source/Expression/DWARFExpression.cpp Tue Aug 27 00:49:41 2019
@@ -59,12 +59,9 @@ DWARFExpression::DWARFExpression()
 
 DWARFExpression::DWARFExpression(lldb::ModuleSP module_sp,
  const DataExtractor &data,
- const DWARFUnit *dwarf_cu,
- lldb::offset_t data_offset,
- lldb::offset_t data_length)
-: m_module_wp(), m_data(data, data_offset, data_length),
-  m_dwarf_cu(dwarf_cu), m_reg_kind(eRegisterKindDWARF),
-  m_loclist_slide(LLDB_INVALID_ADDRESS) {
+ const DWARFUnit *dwarf_cu)
+: m_module_wp(), m_data(data), m_dwarf_cu(dwarf_cu),
+  m_reg_kind(eRegisterKindDWARF), m_loclist_slide(LLDB_INVALID_ADDRESS) {
   if (module_sp)
 m_module_wp = module_sp;
 }
@@ -1135,9 +1132,9 @@ bool DWARFExpression::Evaluate(Execution
 
 if (length > 0 && lo_pc <= pc && pc < hi_pc) {
   return DWARFExpression::Evaluate(
-  exe_ctx, reg_ctx, module_sp, m_data, m_dwarf_cu, offset, length,
-  m_reg_kind, initial_value_ptr, object_address_ptr, result,
-  error_ptr);
+  exe_ct

[Lldb-commits] [PATCH] D66745: DWARFExpression: Simplify class interface

2019-08-27 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe588b8b66456: DWARFExpression: Simplify class interface 
(authored by labath).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D66745?vs=217159&id=217317#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66745

Files:
  lldb/include/lldb/Expression/DWARFExpression.h
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp
  lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
  lldb/source/Target/RegisterContext.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp

Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -24,8 +24,8 @@
   Status status;
   if (!DWARFExpression::Evaluate(
   /*exe_ctx*/ nullptr, /*reg_ctx*/ nullptr, /*opcode_ctx*/ nullptr,
-  extractor, /*dwarf_cu*/ nullptr, /*offset*/ 0, expr.size(),
-  lldb::eRegisterKindLLDB, /*initial_value_ptr*/ nullptr,
+  extractor, /*dwarf_cu*/ nullptr, lldb::eRegisterKindLLDB,
+  /*initial_value_ptr*/ nullptr,
   /*object_address_ptr*/ nullptr, result, &status))
 return status.ToError();
 
Index: lldb/source/Target/RegisterContext.cpp
===
--- lldb/source/Target/RegisterContext.cpp
+++ lldb/source/Target/RegisterContext.cpp
@@ -82,14 +82,12 @@
   DataExtractor dwarf_data(dwarf_opcode_ptr, dwarf_opcode_len,
arch.GetByteOrder(), addr_size);
   ModuleSP opcode_ctx;
-  DWARFExpression dwarf_expr(opcode_ctx, dwarf_data, nullptr, 0,
- dwarf_opcode_len);
+  DWARFExpression dwarf_expr(opcode_ctx, dwarf_data, nullptr);
   Value result;
   Status error;
-  const lldb::offset_t offset = 0;
   if (dwarf_expr.Evaluate(&exe_ctx, this, opcode_ctx, dwarf_data, nullptr,
-  offset, dwarf_opcode_len, eRegisterKindDWARF, nullptr,
-  nullptr, result, &error)) {
+  eRegisterKindDWARF, nullptr, nullptr, result,
+  &error)) {
 expr_result = result.GetScalar().SInt(-1);
 switch (expr_result) {
 case 0:
Index: lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
@@ -174,7 +174,7 @@
   DataBufferSP buffer =
   std::make_shared(stream.GetData(), stream.GetSize());
   DataExtractor extractor(buffer, byte_order, address_size, byte_size);
-  DWARFExpression result(module, extractor, nullptr, 0, buffer->GetByteSize());
+  DWARFExpression result(module, extractor, nullptr);
   result.SetRegisterKind(register_kind);
 
   return result;
Index: lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp
===
--- lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp
@@ -122,7 +122,7 @@
   DataBufferSP buffer =
   std::make_shared(stream.GetData(), stream.GetSize());
   DataExtractor extractor(buffer, byte_order, address_size, byte_size);
-  DWARFExpression result(module, extractor, nullptr, 0, buffer->GetByteSize());
+  DWARFExpression result(module, extractor, nullptr);
   result.SetRegisterKind(register_kind);
 
   return result;
@@ -247,6 +247,6 @@
   .take_front(size);
   buffer->CopyData(bytes.data(), size);
   DataExtractor extractor(buffer, lldb::eByteOrderLittle, address_size);
-  DWARFExpression result(nullptr, extractor, nullptr, 0, size);
+  DWARFExpression result(nullptr, extractor, nullptr);
   return result;
 }
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3243,15 +3243,18 @@
 uint32_t block_offset =
 form_value.BlockData() - debug_info_data.GetDataStart();
 uint32_t block_length = form_value.Unsigned();
-location = DWARFExpression(module, debug_info_data, die.GetCU(),
-   block_of

[Lldb-commits] [PATCH] D66789: Remove DWARFExpression::LocationListSize

2019-08-27 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: JDevlieghere, clayborg.
Herald added subscribers: kristof.beyls, javed.absar, aprantl.

The only reason for this function's existance is so that we could pass
the correct size into the DWARFExpression constructor. However, there is
no harm in passing the entire data extractor into the DWARFExpression,
since the same code is performing the size determination as well as the
subsequent parse. So, if we get malformed input or there's a bug in the
parser, we'd compute the wrong size anyway.

Additionally, reducing the number of entry points into the location list
parsing machinery makes it easier to switch the llvm debug_loc(lists)
parsers.

While inside, I added a couple of tests for invalid location list
handling.


https://reviews.llvm.org/D66789

Files:
  include/lldb/Expression/DWARFExpression.h
  lit/SymbolFile/DWARF/debug_loc.s
  source/Expression/DWARFExpression.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3302,17 +3302,11 @@
   module, DataExtractor(data, block_offset, block_length),
   die.GetCU());
 } else {
-  const DWARFDataExtractor &debug_loc_data = DebugLocData();
-  const dw_offset_t debug_loc_offset = form_value.Unsigned();
-
-  size_t loc_list_length = DWARFExpression::LocationListSize(
-  die.GetCU(), debug_loc_data, debug_loc_offset);
-  if (loc_list_length > 0) {
-location = DWARFExpression(module,
-   DataExtractor(debug_loc_data,
- debug_loc_offset,
- loc_list_length),
-   die.GetCU());
+  DataExtractor data = DebugLocData();
+  const dw_offset_t offset = form_value.Unsigned();
+  if (data.ValidOffset(offset)) {
+data = DataExtractor(data, offset, data.GetByteSize() - offset);
+location = DWARFExpression(module, data, die.GetCU());
 assert(func_low_pc != LLDB_INVALID_ADDRESS);
 location.SetLocationListSlide(
 func_low_pc -
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -343,17 +343,11 @@
   *frame_base = DWARFExpression(
   module, DataExtractor(data, block_offset, block_length), cu);
 } else {
-  const DWARFDataExtractor &debug_loc_data = dwarf.DebugLocData();
-  const dw_offset_t debug_loc_offset = form_value.Unsigned();
-
-  size_t loc_list_length = DWARFExpression::LocationListSize(
-  cu, debug_loc_data, debug_loc_offset);
-  if (loc_list_length > 0) {
-*frame_base = DWARFExpression(module,
-  DataExtractor(debug_loc_data,
-debug_loc_offset,
-loc_list_length),
-  cu);
+  DataExtractor data = dwarf.DebugLocData();
+  const dw_offset_t offset = form_value.Unsigned();
+  if (data.ValidOffset(offset)) {
+data = DataExtractor(data, offset, data.GetByteSize() - offset);
+*frame_base = DWARFExpression(module, data, cu);
 if (lo_pc != LLDB_INVALID_ADDRESS) {
   assert(lo_pc >= cu->GetBaseAddress());
   frame_base->SetLocationListSlide(lo_pc -
Index: source/Expression/DWARFExpression.cpp
===
--- source/Expression/DWARFExpression.cpp
+++ source/Expression/DWARFExpression.cpp
@@ -2708,29 +2708,6 @@
   return true; // Return true on success
 }
 
-size_t DWARFExpression::LocationListSize(const DWARFUnit *dwarf_cu,
- const DataExtractor &debug_loc_data,
- lldb::offset_t offset) {
-  const lldb::offset_t debug_loc_offset = offset;
-  while (debug_loc_data.ValidOffset(offset)) {
-lldb::addr_t start_addr = LLDB_INVALID_ADDRESS;
-lldb::addr_t end_addr = LLDB_INVALID_ADDRESS;
-if (!AddressRangeForLocationListEntry(dwarf_cu, debug_loc_data, &offset,
-  start_addr, end_addr))
-  

[Lldb-commits] [PATCH] D66744: NativeProcessLinux: Remove some register context boilerplate

2019-08-27 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

> {Read,Write}[GF]PR now no longer check whether the supplied buffers are null, 
> because they never are

But then there is `NativeRegisterContextLinux_x86_64::GetFPRBuffer()`. Which is 
never used so maybe together with 
`NativeRegisterContextLinux_x86_64::GetFPRSize()` they could be just 
`assert(0);`. It can be also considered as a different cleanup patch.

I did not test these patches but at least I am finally setting up now a 
(silent) buildbot for `s390x`+`ppc64le` (I haven't found a suitable ARM offer 
yet).




Comment at: source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp:918
 
-  return ReadRegisterSet(&ioVec, buf_size, NT_PRSTATUS);
+  return ReadRegisterSet(&ioVec, GetGPRSize(), NT_PRSTATUS);
 #endif // __arm__

This keeps the existing bug in place as the size should be rather 
`sizeof(ioVec)`. But then `sizeof(ioVec)` is also not much useful as it is used 
only for `PtraceDisplayBytes`. It is probably considered as a different cleanup 
patch so this patch does not touch it.



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

https://reviews.llvm.org/D66744



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


[Lldb-commits] [PATCH] D66634: Postfix: move more code out of the PDB plugin

2019-08-27 Thread Pavel Labath via Phabricator via lldb-commits
labath marked 3 inline comments as done.
labath added a comment.

Please find my replies inline (including my yesterday's reply to Aleksandr, 
which I apparently failed to submit).




Comment at: 
lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp:61
 
+  for (auto it = parsed.begin(), end = parsed.end(); it != end; ++it) {
 // Emplace valid dependent subtrees to make target assignment independent

amccarth wrote:
> I would recommend making `parsed` a `const` vector.  The lambda captures the 
> iterator, and while the code currently looks fine, I'd hate for something to 
> change in the future that could invalidate the captured iterator.
Making it `const` won't work because the symbol resolution process can actually 
modify the contents (not the size) of the vector -- if the RHS is a `SymbolNode 
*` directly, then we may need to replace that with a different kind of a node.

I don't think that the invalidation problem is really specific to the lambda -- 
even without the lambda, if anything modified the vector size while we were 
iterating over it, we would blow up.



Comment at: 
lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp:69
+  return pair.second;
+  }
+

amccarth wrote:
> This looks O(n^2).  Will that matter here or will the expressions always be 
> short?
I don't think that should matter, the expressions will typically have three of 
four assignments (frame base, aligned frame base, esp, eip). It may have 
additional entries for spilled registers, but there aren't that many of those 
either.



Comment at: lldb/trunk/source/Symbol/PostfixExpression.cpp:101
+if (!rhs)
+  return {};
+result.emplace_back(lhs, rhs);

amccarth wrote:
> Is it correct to return an empty vector here rather than `result`?  If 
> there's one bad expression, you'll consider the entire FPO program empty.  
> That's sounds plausible, but I thought I'd ask.
Yeah, that was intentional here. If there's an error parsing one of the 
expressions, I am not sure we want to trust  the parse of the preceding partial 
results either. I  wouldn't really use the term "correct" here, because 
normally we should never fail to parse the expression, and the failure would 
either mean a bug in the parser, or the producer. And it's hard to say what is 
the "correct" thing to do in those cases without knowing the specifics...



Comment at: 
source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp:58
  llvm::BumpPtrAllocator &alloc) {
-  llvm::DenseMap dependent_programs;
-
-  size_t cur = 0;
-  while (true) {
-size_t assign_index = program.find('=', cur);
-if (assign_index == llvm::StringRef::npos) {
-  llvm::StringRef tail = program.slice(cur, llvm::StringRef::npos);
-  if (!tail.trim().empty()) {
-// missing assign operator
-return nullptr;
-  }
-  break;
-}
-llvm::StringRef assignment_program = program.slice(cur, assign_index);
-
-llvm::StringRef lvalue_name;
-Node *rvalue_ast = nullptr;
-if (!ParseFPOSingleAssignmentProgram(assignment_program, alloc, 
lvalue_name,
- rvalue_ast)) {
-  return nullptr;
-}
-
-lldbassert(rvalue_ast);
+  std::vector> parsed =
+  postfix::ParseFPOProgram(program, alloc);

aleksandr.urakov wrote:
> Do I understand right, you use a vector of pairs instead of a map due to the 
> small number of expressions in a program (then a search on a small vector 
> will be faster than on a map)?
Not exactly. The main reason for using a vector is that the order of 
expressions (according to my understanding) in these expressions is important. 
So `a b = b c =` would mean something different than `b c = a b =`. And once I 
already have them in a vector, I didn't see a point in putting them also into a 
map to get fast lookups (because the number of elements is small).

The previous implementation avoided that by parsing and resolving in the same 
loop, but here I first parse and then resolve stuff. This made it easier to 
implement, and I doubt the performance loss is noticeable due to the size of 
the data involved.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66634



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


[Lldb-commits] [PATCH] D66654: Prevent D66398 `TestDataFormatterStdList`-like regressions in the future

2019-08-27 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D66654#1645792 , @jankratochvil 
wrote:

> In D66654#1645658 , @clayborg wrote:
>
> > What about having the first one that matched being the one that is used and 
> > avoid errors all together?
>
>
> This is how it worked so far before the fix D66398 
>  (which made the regexes unambiguous - 
> always matching at most 1 regex for any string).  The previous version of the 
> patch  just sorted the regexes 
> alphabetically because original LLDB did not sort them at all printing random 
> results.
>
> @labath did not like the alphabetical sorting as (IIUC) adding formatters 
> from a new library can affect formatting for a different library.


Kind of, yes. My concern was a bit more general, in that the alphabetical 
sorting just seems arbitrary and I don't believe anybody would expect that. It 
happens to do what we want here, but I can imagine that in some cases it might 
do the exact opposite, and then we'd have to massage the regular expressions to 
reverse their sort order, but retain meaning...

Personally, I'd go for the registration order, or possibly the reverse 
registration order, depending on what we want to give precedence to. It seems 
to me that this would give the most predictable results, and would make it easy 
to swap the precedence of two formatters if needed. But I don't feel strongly 
about that, so if you want to go with alphabetical, then I guess that's fine 
with me (it's definitely better than sorting on pointer values :P).


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D66654



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


[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-08-27 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk created this revision.
Herald added subscribers: llvm-commits, lldb-commits, MaskRay, hiraditya, 
arichardson, mgorny, emaste.
Herald added a reviewer: espindola.
Herald added projects: LLDB, LLVM.
kwk added reviewers: labath, jankratochvil.
kwk marked an inline comment as done.
kwk updated this revision to Diff 217331.
kwk added a comment.
kwk marked an inline comment as not done.

- Change header comment of minidebuginfo




Comment at: 
lldb/packages/Python/lldbsuite/test/linux/minidebuginfo/TestMiniDebugInfo.py:1
+""" Testing debugging of a binary with "mixed" dwarf (with/without fission). 
"""
+import lldb

I just saw that this header makes no sense.


If the .symtab section is stripped from the binary it might be that
there's a .gnu_debugdata section which contains a smaller .symtab in
order to provide enough information to create a backtrace with function
names or to set and hit a breakpoint on a function name.

This change looks for a .gnu_debugdata section in the ELF object file.
The .gnu_debugdata section contains a xz-compressed ELF file with a
.symtab section inside. Symbols from that compressed .symtab section
are merged with the main object file's .dynsym symbols (if any).
In addition we always load the .dynsym even if there's a .symtab
section.

For example, the Fedora and RHEL operating systems strip their binaries
but keep a .gnu_debugdata section. While gdb already can read this
section, LLDB until this patch couldn't. To test this patch on a
Fedora or RHEL operating system, try to set a breakpoint on the "help"
symbol in the "zip" binary. Before this patch, only GDB can set this
breakpoint; now LLDB also can do so without installing extra debug
symbols:

  lldb /usr/bin/zip -b -o "b help" -o "r" -o "bt" -- -h

The above line runs LLDB in batch mode and on the "/usr/bin/zip -h"
target:

  (lldb) target create "/usr/bin/zip"
  Current executable set to '/usr/bin/zip' (x86_64).
  (lldb) settings set -- target.run-args  "-h"

Before the program starts, we set a breakpoint on the "help" symbol:

  (lldb) b help
  Breakpoint 1: where = zip`help, address = 0x004093b0

Once the program is run and has hit the breakpoint we ask for a
backtrace:

  (lldb) r
  Process 10073 stopped
  * thread #1, name = 'zip', stop reason = breakpoint 1.1
  frame #0: 0x004093b0 zip`help
  zip`help:
  ->  0x4093b0 <+0>:  pushq  %r12
  0x4093b2 <+2>:  movq   0x2af5f(%rip), %rsi   ;  + 4056
  0x4093b9 <+9>:  movl   $0x1, %edi
  0x4093be <+14>: xorl   %eax, %eax
  
  Process 10073 launched: '/usr/bin/zip' (x86_64)
  (lldb) bt
  * thread #1, name = 'zip', stop reason = breakpoint 1.1
* frame #0: 0x004093b0 zip`help
  frame #1: 0x00403970 zip`main + 3248
  frame #2: 0x77d8bf33 libc.so.6`__libc_start_main + 243
  frame #3: 0x00408cee zip`_start + 46

In addition to supporting minidebuginfo this changes ensures that
yaml2obj doens't generate a .symtab section if there previously wasn't
any "Symbols" entry in the YAML file. Initially I planned to test my
code using LLDB-Lit but then I figured that it is necessary to not only
find a symbol but to make sure that we can also hit a breakpoint on a
symbol. I noticed during the development of this change, that one can
set a breakpoint but not necessarily hit it.

In order to support the .gnu_debugdata section, one has to have LZMA
development headers installed. The CMake section, that controls this
part looks for the LZMA headers and enables .gnu_debugdata support by
default if they are found; otherwise or if explicitly requested, the
minidebuginfo support is disabled.

GDB supports the "mini debuginfo" section .gnu_debugdata since v7.6
(2013).

This is another error fixed by this commit that has nothing to do with
this change in general:

Fixed compile error: no memcpy in std ns

/home/kkleine/llvm/llvm/include/llvm/Support/MathExtras.h:271:8: error: no 
member named 'memcpy' in namespace 'std'; did you mean 'wmemcpy'?

  std::memcpy(in, &Val, sizeof(Val));
  ~^~
   wmemcpy


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66791

Files:
  lldb/packages/Python/lldbsuite/test/linux/minidebuginfo/Makefile
  lldb/packages/Python/lldbsuite/test/linux/minidebuginfo/TestMiniDebugInfo.py
  lldb/packages/Python/lldbsuite/test/linux/minidebuginfo/main.c
  lldb/source/Plugins/ObjectFile/ELF/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
  lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
  llvm/include/llvm/ObjectYAML/ELFYAML.h
  llvm/include/llvm/Support/MathExtras.h
  llvm/lib/ObjectYAML/ELFEmitter.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/tools/obj2yaml/elf2yaml.cpp

Index: llvm/tools/obj2yaml/elf2yaml.cpp
===
--- llvm/tools/obj2yaml/elf2yaml.cpp
+++ llvm/tools/obj2yaml/elf2yaml.cpp
@@ -192,8 +

[Lldb-commits] [PATCH] D66744: NativeProcessLinux: Remove some register context boilerplate

2019-08-27 Thread Pavel Labath via Phabricator via lldb-commits
labath marked an inline comment as done.
labath added a comment.

In D66744#1646514 , @jankratochvil 
wrote:

> > {Read,Write}[GF]PR now no longer check whether the supplied buffers are 
> > null, because they never are
>
> But then there is `NativeRegisterContextLinux_x86_64::GetFPRBuffer()`. Which 
> is never used so maybe together with 
> `NativeRegisterContextLinux_x86_64::GetFPRSize()` they could be just 
> `assert(0);`. It can be also considered as a different cleanup patch.


Hm.. I didn't notice that. I'll put that in separately. Ideally, I'd say these 
functions should be used, but that may require more cleanups in the x86 
register context, such as detecting the register type earlier on instead of 
just when the operations fail. Overall, there's a lot of room for improvement 
in this area...

> I did not test these patches but at least I am finally setting up now a 
> (silent) buildbot for `s390x`+`ppc64le` (I haven't found a suitable ARM offer 
> yet).

That would be awesome. Btw, we already have some arm (32&64) lldb bots set up 
by linaro, though they don't seem to be in a particularly good shape right 
now...




Comment at: source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp:918
 
-  return ReadRegisterSet(&ioVec, buf_size, NT_PRSTATUS);
+  return ReadRegisterSet(&ioVec, GetGPRSize(), NT_PRSTATUS);
 #endif // __arm__

jankratochvil wrote:
> This keeps the existing bug in place as the size should be rather 
> `sizeof(ioVec)`. But then `sizeof(ioVec)` is also not much useful as it is 
> used only for `PtraceDisplayBytes`. It is probably considered as a different 
> cleanup patch so this patch does not touch it.
> 
Yeah, I noticed that. I am keeping that for some other patch. Ideally, I'd like 
to refactor this even more so that one does not have to construct the iovec 
manually, and fix PtraceDisplayBytes to show the contents of the iovec, but I 
don't have a clear idea on the best way to do that.


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

https://reviews.llvm.org/D66744



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


[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-08-27 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk marked an inline comment as done.
kwk added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/linux/minidebuginfo/TestMiniDebugInfo.py:1
+""" Testing debugging of a binary with "mixed" dwarf (with/without fission). 
"""
+import lldb

I just saw that this header makes no sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791



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


[Lldb-commits] [PATCH] D59692: [ASTImporter] Fix name conflict handling with different strategies

2019-08-27 Thread Gabor Marton via Phabricator via lldb-commits
martong updated this revision to Diff 217330.
martong marked 2 inline comments as done.
martong added a comment.

- Revert changes in VisitFieldDecl and in VisitIndirectFieldDecl
- Remove test suite ConflictingDeclsWithConservativeStrategy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59692

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/lib/AST/ASTImporter.cpp
  clang/test/Analysis/Inputs/ctu-other.c
  clang/unittests/AST/ASTImporterFixtures.cpp
  clang/unittests/AST/ASTImporterFixtures.h
  clang/unittests/AST/ASTImporterTest.cpp
  lldb/include/lldb/Symbol/ClangASTImporter.h

Index: lldb/include/lldb/Symbol/ClangASTImporter.h
===
--- lldb/include/lldb/Symbol/ClangASTImporter.h
+++ lldb/include/lldb/Symbol/ClangASTImporter.h
@@ -252,7 +252,9 @@
 : clang::ASTImporter(*target_ctx, master.m_file_manager, *source_ctx,
  master.m_file_manager, true /*minimal*/),
   m_decls_to_deport(nullptr), m_decls_already_deported(nullptr),
-  m_master(master), m_source_ctx(source_ctx) {}
+  m_master(master), m_source_ctx(source_ctx) {
+setODRHandling(clang::ASTImporter::ODRHandlingType::Liberal);
+  }
 
 /// Scope guard that attaches a CxxModuleHandler to an ASTImporterDelegate
 /// and deattaches it at the end of the scope. Supports being used multiple
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1879,7 +1879,7 @@
   auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
   // We expect one (ODR) warning during the import.
   EXPECT_EQ(1u, ToTU->getASTContext().getDiagnostics().getNumWarnings());
-  EXPECT_EQ(2u,
+  EXPECT_EQ(1u,
 DeclCounter().match(ToTU, recordDecl(hasName("X";
 }
 
@@ -2432,6 +2432,62 @@
   EXPECT_EQ(ToD1, ToD2);
 }
 
+TEST_P(ImportFunctionTemplates,
+   ImportFunctionWhenThereIsAFunTemplateWithSameName) {
+  getToTuDecl(
+  R"(
+  template 
+  void foo(T) {}
+  void foo();
+  )",
+  Lang_CXX);
+  Decl *FromTU = getTuDecl("void foo();", Lang_CXX);
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("foo")));
+  auto *ImportedD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ImportedD);
+}
+
+TEST_P(ImportFunctionTemplates,
+   ImportConstructorWhenThereIsAFunTemplateWithSameName) {
+  auto Code =
+  R"(
+  struct Foo {
+template 
+Foo(T) {}
+Foo();
+  };
+  )";
+  getToTuDecl(Code, Lang_CXX);
+  Decl *FromTU = getTuDecl(Code, Lang_CXX);
+  auto *FromD =
+  LastDeclMatcher().match(FromTU, cxxConstructorDecl());
+  auto *ImportedD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ImportedD);
+}
+
+TEST_P(ImportFunctionTemplates,
+   ImportOperatorWhenThereIsAFunTemplateWithSameName) {
+  getToTuDecl(
+  R"(
+  template 
+  void operator<(T,T) {}
+  struct X{};
+  void operator<(X, X);
+  )",
+  Lang_CXX);
+  Decl *FromTU = getTuDecl(
+  R"(
+  struct X{};
+  void operator<(X, X);
+  )",
+  Lang_CXX);
+  auto *FromD = LastDeclMatcher().match(
+  FromTU, functionDecl(hasOverloadedOperatorName("<")));
+  auto *ImportedD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ImportedD);
+}
+
 struct ImportFriendFunctions : ImportFunctions {};
 
 TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainProto) {
@@ -5127,15 +5183,6 @@
   }
 }
 
-INSTANTIATE_TEST_CASE_P(ParameterizedTests, ErrorHandlingTest,
-DefaultTestValuesForRunOptions, );
-
-INSTANTIATE_TEST_CASE_P(ParameterizedTests, DeclContextTest,
-::testing::Values(ArgVector()), );
-
-INSTANTIATE_TEST_CASE_P(ParameterizedTests, CanonicalRedeclChain,
-::testing::Values(ArgVector()), );
-
 TEST_P(ASTImporterOptionSpecificTestBase, LambdaInFunctionBody) {
   Decl *FromTU = getTuDecl(
   R"(
@@ -5233,8 +5280,8 @@
   // prototype (inside 'friend') for it comes first in the AST and is not
   // linked to the definition.
   EXPECT_EQ(ImportedDef, ToClassDef);
-}  
-  
+}
+
 struct LLDBLookupTest : ASTImporterOptionSpecificTestBase {
   LLDBLookupTest() {
 Creator = [](ASTContext &ToContext, FileManager &ToFileManager,
@@ -5362,10 +5409,205 @@
   EXPECT_EQ(ImportedX->isAggregate(), FromX->isAggregate());
 }
 
+struct ConflictingDeclsWithLiberalStrategy : ASTImporterOptionSpecificTestBase {
+  ConflictingDeclsWithLiberalStrategy() {
+this->ODRHandling = ASTImporter::ODRHandlingType::Liberal;
+  }
+};
+
+// Check that a Decl has been successfully imported into a standalone redecl
+// chain.
+template 
+static void CheckImportedAsNew(llvm::Expected &Result, Decl *ToTU,
+   PatternTy Pattern) {
+ 

[Lldb-commits] [PATCH] D59692: [ASTImporter] Fix name conflict handling with different strategies

2019-08-27 Thread Gabor Marton via Phabricator via lldb-commits
martong marked 4 inline comments as done.
martong added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:3452
 << FoundField->getType();
-
-  return make_error(ImportError::NameConflict);
+  ConflictingDecls.push_back(FoundField);
 }

shafik wrote:
> I am a little concerned about this change. I am wondering if this was 
> previously handled differently as a band-aid for some other issues that only 
> showed up in rare cases when they iterated over all the results but not when 
> they errored out on the first. 
> 
> Could we make the changes to `VisitFieldDecl` a separate PR so it is easier 
> to revert later on if we do find this causes a regression we are not 
> currently covering?
Ok, I reverted these hunks. I am going to create a follow-up patch which will 
include these changes.



Comment at: clang/unittests/AST/ASTImporterTest.cpp:5615
+
+TEST_P(ConflictingDeclsWithLiberalStrategy, Typedef) {
+  Decl *ToTU = getToTuDecl(

shafik wrote:
> Since the "Liberal" strategy should be the current status quo, I think it 
> might make sense to have a first PR that just has the `*LiberalStrategy` 
> tests to verify that indeed this is the current behavior as we expect.
Ok, I removed the test suite `ConflictingDeclsWithConservativeStrategy`. I am 
going to create a subsequent patch which adds comprehensive testing for both 
strategies.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59692



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


[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-08-27 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 217331.
kwk added a comment.

- Change header comment of minidebuginfo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  lldb/packages/Python/lldbsuite/test/linux/minidebuginfo/Makefile
  lldb/packages/Python/lldbsuite/test/linux/minidebuginfo/TestMiniDebugInfo.py
  lldb/packages/Python/lldbsuite/test/linux/minidebuginfo/main.c
  lldb/source/Plugins/ObjectFile/ELF/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
  lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
  llvm/include/llvm/ObjectYAML/ELFYAML.h
  llvm/include/llvm/Support/MathExtras.h
  llvm/lib/ObjectYAML/ELFEmitter.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/tools/obj2yaml/elf2yaml.cpp

Index: llvm/tools/obj2yaml/elf2yaml.cpp
===
--- llvm/tools/obj2yaml/elf2yaml.cpp
+++ llvm/tools/obj2yaml/elf2yaml.cpp
@@ -192,8 +192,8 @@
   return TableOrErr.takeError();
 ShndxTable = *TableOrErr;
   }
-  if (SymTab)
-if (Error E = dumpSymbols(SymTab, Y->Symbols))
+  if (SymTab && Y->Symbols)
+if (Error E = dumpSymbols(SymTab, *Y->Symbols))
   return std::move(E);
   if (DynSymTab)
 if (Error E = dumpSymbols(DynSymTab, Y->DynamicSymbols))
Index: llvm/lib/ObjectYAML/ELFYAML.cpp
===
--- llvm/lib/ObjectYAML/ELFYAML.cpp
+++ llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -911,6 +911,7 @@
 
 StringRef MappingTraits::validate(IO &IO,
ELFYAML::Symbol &Symbol) {
+  (void)IO;
   if (Symbol.Index && Symbol.Section.data())
 return "Index and Section cannot both be specified for Symbol";
   if (Symbol.NameIndex && !Symbol.Name.empty())
Index: llvm/lib/ObjectYAML/ELFEmitter.cpp
===
--- llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -192,7 +192,12 @@
 std::make_unique(
 ELFYAML::Section::SectionKind::RawContent, /*IsImplicit=*/true));
 
-  std::vector ImplicitSections = {".symtab", ".strtab", ".shstrtab"};
+  std::vector ImplicitSections = {".strtab", ".shstrtab"};
+  // We only generate .symtab ELF section if there was a "Symbols" entry in the
+  // YAML file.
+  if (Doc.HasSymbolsEntryInYAML()) {
+ImplicitSections.insert(ImplicitSections.begin(), {".symtab"});
+  }
   if (!Doc.DynamicSymbols.empty())
 ImplicitSections.insert(ImplicitSections.end(), {".dynsym", ".dynstr"});
 
@@ -478,7 +483,8 @@
  ELFYAML::Section *YAMLSec) {
 
   bool IsStatic = STType == SymtabType::Static;
-  const auto &Symbols = IsStatic ? Doc.Symbols : Doc.DynamicSymbols;
+  const auto &Symbols =
+  IsStatic && Doc.Symbols ? *Doc.Symbols : Doc.DynamicSymbols;
 
   ELFYAML::RawContentSection *RawSec =
   dyn_cast_or_null(YAMLSec);
@@ -1013,14 +1019,15 @@
 }
 
 template  bool ELFState::buildSymbolIndexes() {
-  return buildSymbolsMap(Doc.Symbols, SymN2I) &&
+  return Doc.Symbols && buildSymbolsMap(*Doc.Symbols, SymN2I) &&
  buildSymbolsMap(Doc.DynamicSymbols, DynSymN2I);
 }
 
 template  void ELFState::finalizeStrings() {
   // Add the regular symbol names to .strtab section.
-  for (const ELFYAML::Symbol &Sym : Doc.Symbols)
-DotStrtab.add(dropUniqueSuffix(Sym.Name));
+  if (Doc.Symbols)
+for (const ELFYAML::Symbol &Sym : *Doc.Symbols)
+  DotStrtab.add(dropUniqueSuffix(Sym.Name));
   DotStrtab.finalize();
 
   // Add the dynamic symbol names to .dynstr section.
Index: llvm/include/llvm/Support/MathExtras.h
===
--- llvm/include/llvm/Support/MathExtras.h
+++ llvm/include/llvm/Support/MathExtras.h
@@ -268,7 +268,7 @@
 T reverseBits(T Val) {
   unsigned char in[sizeof(Val)];
   unsigned char out[sizeof(Val)];
-  std::memcpy(in, &Val, sizeof(Val));
+  memcpy(in, &Val, sizeof(Val));
   for (unsigned i = 0; i < sizeof(Val); ++i)
 out[(sizeof(Val) - i) - 1] = BitReverseTable256[in[i]];
   std::memcpy(&Val, out, sizeof(Val));
Index: llvm/include/llvm/ObjectYAML/ELFYAML.h
===
--- llvm/include/llvm/ObjectYAML/ELFYAML.h
+++ llvm/include/llvm/ObjectYAML/ELFYAML.h
@@ -314,8 +314,10 @@
   // cleaner and nicer if we read them from the YAML as a separate
   // top-level key, which automatically ensures that invariants like there
   // being a single SHT_SYMTAB section are upheld.
-  std::vector Symbols;
+  Optional> Symbols;
   std::vector DynamicSymbols;
+
+  bool HasSymbolsEntryInYAML() const { return Symbols.hasValue(); }
 };
 
 } // end namespace ELFYAML
Index: lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
===
--- lldb/so

[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-08-27 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 217334.
kwk added a comment.

- Improve documentation of GetGnuDebugDataObjectFile


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  lldb/packages/Python/lldbsuite/test/linux/minidebuginfo/Makefile
  lldb/packages/Python/lldbsuite/test/linux/minidebuginfo/TestMiniDebugInfo.py
  lldb/packages/Python/lldbsuite/test/linux/minidebuginfo/main.c
  lldb/source/Plugins/ObjectFile/ELF/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
  lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
  llvm/include/llvm/ObjectYAML/ELFYAML.h
  llvm/include/llvm/Support/MathExtras.h
  llvm/lib/ObjectYAML/ELFEmitter.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/tools/obj2yaml/elf2yaml.cpp

Index: llvm/tools/obj2yaml/elf2yaml.cpp
===
--- llvm/tools/obj2yaml/elf2yaml.cpp
+++ llvm/tools/obj2yaml/elf2yaml.cpp
@@ -192,8 +192,8 @@
   return TableOrErr.takeError();
 ShndxTable = *TableOrErr;
   }
-  if (SymTab)
-if (Error E = dumpSymbols(SymTab, Y->Symbols))
+  if (SymTab && Y->Symbols)
+if (Error E = dumpSymbols(SymTab, *Y->Symbols))
   return std::move(E);
   if (DynSymTab)
 if (Error E = dumpSymbols(DynSymTab, Y->DynamicSymbols))
Index: llvm/lib/ObjectYAML/ELFYAML.cpp
===
--- llvm/lib/ObjectYAML/ELFYAML.cpp
+++ llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -911,6 +911,7 @@
 
 StringRef MappingTraits::validate(IO &IO,
ELFYAML::Symbol &Symbol) {
+  (void)IO;
   if (Symbol.Index && Symbol.Section.data())
 return "Index and Section cannot both be specified for Symbol";
   if (Symbol.NameIndex && !Symbol.Name.empty())
Index: llvm/lib/ObjectYAML/ELFEmitter.cpp
===
--- llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -192,7 +192,12 @@
 std::make_unique(
 ELFYAML::Section::SectionKind::RawContent, /*IsImplicit=*/true));
 
-  std::vector ImplicitSections = {".symtab", ".strtab", ".shstrtab"};
+  std::vector ImplicitSections = {".strtab", ".shstrtab"};
+  // We only generate .symtab ELF section if there was a "Symbols" entry in the
+  // YAML file.
+  if (Doc.HasSymbolsEntryInYAML()) {
+ImplicitSections.insert(ImplicitSections.begin(), {".symtab"});
+  }
   if (!Doc.DynamicSymbols.empty())
 ImplicitSections.insert(ImplicitSections.end(), {".dynsym", ".dynstr"});
 
@@ -478,7 +483,8 @@
  ELFYAML::Section *YAMLSec) {
 
   bool IsStatic = STType == SymtabType::Static;
-  const auto &Symbols = IsStatic ? Doc.Symbols : Doc.DynamicSymbols;
+  const auto &Symbols =
+  IsStatic && Doc.Symbols ? *Doc.Symbols : Doc.DynamicSymbols;
 
   ELFYAML::RawContentSection *RawSec =
   dyn_cast_or_null(YAMLSec);
@@ -1013,14 +1019,15 @@
 }
 
 template  bool ELFState::buildSymbolIndexes() {
-  return buildSymbolsMap(Doc.Symbols, SymN2I) &&
+  return Doc.Symbols && buildSymbolsMap(*Doc.Symbols, SymN2I) &&
  buildSymbolsMap(Doc.DynamicSymbols, DynSymN2I);
 }
 
 template  void ELFState::finalizeStrings() {
   // Add the regular symbol names to .strtab section.
-  for (const ELFYAML::Symbol &Sym : Doc.Symbols)
-DotStrtab.add(dropUniqueSuffix(Sym.Name));
+  if (Doc.Symbols)
+for (const ELFYAML::Symbol &Sym : *Doc.Symbols)
+  DotStrtab.add(dropUniqueSuffix(Sym.Name));
   DotStrtab.finalize();
 
   // Add the dynamic symbol names to .dynstr section.
Index: llvm/include/llvm/Support/MathExtras.h
===
--- llvm/include/llvm/Support/MathExtras.h
+++ llvm/include/llvm/Support/MathExtras.h
@@ -268,7 +268,7 @@
 T reverseBits(T Val) {
   unsigned char in[sizeof(Val)];
   unsigned char out[sizeof(Val)];
-  std::memcpy(in, &Val, sizeof(Val));
+  memcpy(in, &Val, sizeof(Val));
   for (unsigned i = 0; i < sizeof(Val); ++i)
 out[(sizeof(Val) - i) - 1] = BitReverseTable256[in[i]];
   std::memcpy(&Val, out, sizeof(Val));
Index: llvm/include/llvm/ObjectYAML/ELFYAML.h
===
--- llvm/include/llvm/ObjectYAML/ELFYAML.h
+++ llvm/include/llvm/ObjectYAML/ELFYAML.h
@@ -314,8 +314,10 @@
   // cleaner and nicer if we read them from the YAML as a separate
   // top-level key, which automatically ensures that invariants like there
   // being a single SHT_SYMTAB section are upheld.
-  std::vector Symbols;
+  Optional> Symbols;
   std::vector DynamicSymbols;
+
+  bool HasSymbolsEntryInYAML() const { return Symbols.hasValue(); }
 };
 
 } // end namespace ELFYAML
Index: lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
===

[Lldb-commits] [PATCH] D59692: [ASTImporter] Fix name conflict handling with different strategies

2019-08-27 Thread Gabor Marton via Phabricator via lldb-commits
martong updated this revision to Diff 217337.
martong added a comment.

- Apply clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59692

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/lib/AST/ASTImporter.cpp
  clang/test/Analysis/Inputs/ctu-other.c
  clang/unittests/AST/ASTImporterFixtures.cpp
  clang/unittests/AST/ASTImporterFixtures.h
  clang/unittests/AST/ASTImporterTest.cpp
  lldb/include/lldb/Symbol/ClangASTImporter.h

Index: lldb/include/lldb/Symbol/ClangASTImporter.h
===
--- lldb/include/lldb/Symbol/ClangASTImporter.h
+++ lldb/include/lldb/Symbol/ClangASTImporter.h
@@ -252,7 +252,9 @@
 : clang::ASTImporter(*target_ctx, master.m_file_manager, *source_ctx,
  master.m_file_manager, true /*minimal*/),
   m_decls_to_deport(nullptr), m_decls_already_deported(nullptr),
-  m_master(master), m_source_ctx(source_ctx) {}
+  m_master(master), m_source_ctx(source_ctx) {
+  setODRHandling(clang::ASTImporter::ODRHandlingType::Liberal);
+}
 
 /// Scope guard that attaches a CxxModuleHandler to an ASTImporterDelegate
 /// and deattaches it at the end of the scope. Supports being used multiple
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1879,7 +1879,7 @@
   auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
   // We expect one (ODR) warning during the import.
   EXPECT_EQ(1u, ToTU->getASTContext().getDiagnostics().getNumWarnings());
-  EXPECT_EQ(2u,
+  EXPECT_EQ(1u,
 DeclCounter().match(ToTU, recordDecl(hasName("X";
 }
 
@@ -2432,6 +2432,62 @@
   EXPECT_EQ(ToD1, ToD2);
 }
 
+TEST_P(ImportFunctionTemplates,
+   ImportFunctionWhenThereIsAFunTemplateWithSameName) {
+  getToTuDecl(
+  R"(
+  template 
+  void foo(T) {}
+  void foo();
+  )",
+  Lang_CXX);
+  Decl *FromTU = getTuDecl("void foo();", Lang_CXX);
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("foo")));
+  auto *ImportedD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ImportedD);
+}
+
+TEST_P(ImportFunctionTemplates,
+   ImportConstructorWhenThereIsAFunTemplateWithSameName) {
+  auto Code =
+  R"(
+  struct Foo {
+template 
+Foo(T) {}
+Foo();
+  };
+  )";
+  getToTuDecl(Code, Lang_CXX);
+  Decl *FromTU = getTuDecl(Code, Lang_CXX);
+  auto *FromD =
+  LastDeclMatcher().match(FromTU, cxxConstructorDecl());
+  auto *ImportedD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ImportedD);
+}
+
+TEST_P(ImportFunctionTemplates,
+   ImportOperatorWhenThereIsAFunTemplateWithSameName) {
+  getToTuDecl(
+  R"(
+  template 
+  void operator<(T,T) {}
+  struct X{};
+  void operator<(X, X);
+  )",
+  Lang_CXX);
+  Decl *FromTU = getTuDecl(
+  R"(
+  struct X{};
+  void operator<(X, X);
+  )",
+  Lang_CXX);
+  auto *FromD = LastDeclMatcher().match(
+  FromTU, functionDecl(hasOverloadedOperatorName("<")));
+  auto *ImportedD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ImportedD);
+}
+
 struct ImportFriendFunctions : ImportFunctions {};
 
 TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainProto) {
@@ -5127,15 +5183,6 @@
   }
 }
 
-INSTANTIATE_TEST_CASE_P(ParameterizedTests, ErrorHandlingTest,
-DefaultTestValuesForRunOptions, );
-
-INSTANTIATE_TEST_CASE_P(ParameterizedTests, DeclContextTest,
-::testing::Values(ArgVector()), );
-
-INSTANTIATE_TEST_CASE_P(ParameterizedTests, CanonicalRedeclChain,
-::testing::Values(ArgVector()), );
-
 TEST_P(ASTImporterOptionSpecificTestBase, LambdaInFunctionBody) {
   Decl *FromTU = getTuDecl(
   R"(
@@ -5233,8 +5280,8 @@
   // prototype (inside 'friend') for it comes first in the AST and is not
   // linked to the definition.
   EXPECT_EQ(ImportedDef, ToClassDef);
-}  
-  
+}
+
 struct LLDBLookupTest : ASTImporterOptionSpecificTestBase {
   LLDBLookupTest() {
 Creator = [](ASTContext &ToContext, FileManager &ToFileManager,
@@ -5362,10 +5409,197 @@
   EXPECT_EQ(ImportedX->isAggregate(), FromX->isAggregate());
 }
 
+struct ConflictingDeclsWithLiberalStrategy : ASTImporterOptionSpecificTestBase {
+  ConflictingDeclsWithLiberalStrategy() {
+this->ODRHandling = ASTImporter::ODRHandlingType::Liberal;
+  }
+};
+
+// Check that a Decl has been successfully imported into a standalone redecl
+// chain.
+template 
+static void CheckImportedAsNew(llvm::Expected &Result, Decl *ToTU,
+   PatternTy Pattern) {
+  ASSERT_TRUE(isSuccess(Result));
+  Decl *ImportedD = *Result;
+  ASSERT_TRUE(ImportedD);
+  auto *ToD = FirstDeclMatcher().match(ToTU, Pattern);
+  EXPECT_NE(

[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-08-27 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 217341.
kwk added a comment.

- Added documentation source for mini debuginfo commands


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  lldb/packages/Python/lldbsuite/test/linux/minidebuginfo/Makefile
  lldb/packages/Python/lldbsuite/test/linux/minidebuginfo/TestMiniDebugInfo.py
  lldb/packages/Python/lldbsuite/test/linux/minidebuginfo/main.c
  lldb/source/Plugins/ObjectFile/ELF/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
  lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
  llvm/include/llvm/ObjectYAML/ELFYAML.h
  llvm/include/llvm/Support/MathExtras.h
  llvm/lib/ObjectYAML/ELFEmitter.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/tools/obj2yaml/elf2yaml.cpp

Index: llvm/tools/obj2yaml/elf2yaml.cpp
===
--- llvm/tools/obj2yaml/elf2yaml.cpp
+++ llvm/tools/obj2yaml/elf2yaml.cpp
@@ -192,8 +192,8 @@
   return TableOrErr.takeError();
 ShndxTable = *TableOrErr;
   }
-  if (SymTab)
-if (Error E = dumpSymbols(SymTab, Y->Symbols))
+  if (SymTab && Y->Symbols)
+if (Error E = dumpSymbols(SymTab, *Y->Symbols))
   return std::move(E);
   if (DynSymTab)
 if (Error E = dumpSymbols(DynSymTab, Y->DynamicSymbols))
Index: llvm/lib/ObjectYAML/ELFYAML.cpp
===
--- llvm/lib/ObjectYAML/ELFYAML.cpp
+++ llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -911,6 +911,7 @@
 
 StringRef MappingTraits::validate(IO &IO,
ELFYAML::Symbol &Symbol) {
+  (void)IO;
   if (Symbol.Index && Symbol.Section.data())
 return "Index and Section cannot both be specified for Symbol";
   if (Symbol.NameIndex && !Symbol.Name.empty())
Index: llvm/lib/ObjectYAML/ELFEmitter.cpp
===
--- llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -192,7 +192,12 @@
 std::make_unique(
 ELFYAML::Section::SectionKind::RawContent, /*IsImplicit=*/true));
 
-  std::vector ImplicitSections = {".symtab", ".strtab", ".shstrtab"};
+  std::vector ImplicitSections = {".strtab", ".shstrtab"};
+  // We only generate .symtab ELF section if there was a "Symbols" entry in the
+  // YAML file.
+  if (Doc.HasSymbolsEntryInYAML()) {
+ImplicitSections.insert(ImplicitSections.begin(), {".symtab"});
+  }
   if (!Doc.DynamicSymbols.empty())
 ImplicitSections.insert(ImplicitSections.end(), {".dynsym", ".dynstr"});
 
@@ -478,7 +483,8 @@
  ELFYAML::Section *YAMLSec) {
 
   bool IsStatic = STType == SymtabType::Static;
-  const auto &Symbols = IsStatic ? Doc.Symbols : Doc.DynamicSymbols;
+  const auto &Symbols =
+  IsStatic && Doc.Symbols ? *Doc.Symbols : Doc.DynamicSymbols;
 
   ELFYAML::RawContentSection *RawSec =
   dyn_cast_or_null(YAMLSec);
@@ -1013,14 +1019,15 @@
 }
 
 template  bool ELFState::buildSymbolIndexes() {
-  return buildSymbolsMap(Doc.Symbols, SymN2I) &&
+  return Doc.Symbols && buildSymbolsMap(*Doc.Symbols, SymN2I) &&
  buildSymbolsMap(Doc.DynamicSymbols, DynSymN2I);
 }
 
 template  void ELFState::finalizeStrings() {
   // Add the regular symbol names to .strtab section.
-  for (const ELFYAML::Symbol &Sym : Doc.Symbols)
-DotStrtab.add(dropUniqueSuffix(Sym.Name));
+  if (Doc.Symbols)
+for (const ELFYAML::Symbol &Sym : *Doc.Symbols)
+  DotStrtab.add(dropUniqueSuffix(Sym.Name));
   DotStrtab.finalize();
 
   // Add the dynamic symbol names to .dynstr section.
Index: llvm/include/llvm/Support/MathExtras.h
===
--- llvm/include/llvm/Support/MathExtras.h
+++ llvm/include/llvm/Support/MathExtras.h
@@ -268,7 +268,7 @@
 T reverseBits(T Val) {
   unsigned char in[sizeof(Val)];
   unsigned char out[sizeof(Val)];
-  std::memcpy(in, &Val, sizeof(Val));
+  memcpy(in, &Val, sizeof(Val));
   for (unsigned i = 0; i < sizeof(Val); ++i)
 out[(sizeof(Val) - i) - 1] = BitReverseTable256[in[i]];
   std::memcpy(&Val, out, sizeof(Val));
Index: llvm/include/llvm/ObjectYAML/ELFYAML.h
===
--- llvm/include/llvm/ObjectYAML/ELFYAML.h
+++ llvm/include/llvm/ObjectYAML/ELFYAML.h
@@ -314,8 +314,10 @@
   // cleaner and nicer if we read them from the YAML as a separate
   // top-level key, which automatically ensures that invariants like there
   // being a single SHT_SYMTAB section are upheld.
-  std::vector Symbols;
+  Optional> Symbols;
   std::vector DynamicSymbols;
+
+  bool HasSymbolsEntryInYAML() const { return Symbols.hasValue(); }
 };
 
 } // end namespace ELFYAML
Index: lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
===

[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-08-27 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 217339.
kwk added a comment.

- Fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  lldb/packages/Python/lldbsuite/test/linux/minidebuginfo/Makefile
  lldb/packages/Python/lldbsuite/test/linux/minidebuginfo/TestMiniDebugInfo.py
  lldb/packages/Python/lldbsuite/test/linux/minidebuginfo/main.c
  lldb/source/Plugins/ObjectFile/ELF/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
  lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
  llvm/include/llvm/ObjectYAML/ELFYAML.h
  llvm/include/llvm/Support/MathExtras.h
  llvm/lib/ObjectYAML/ELFEmitter.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/tools/obj2yaml/elf2yaml.cpp

Index: llvm/tools/obj2yaml/elf2yaml.cpp
===
--- llvm/tools/obj2yaml/elf2yaml.cpp
+++ llvm/tools/obj2yaml/elf2yaml.cpp
@@ -192,8 +192,8 @@
   return TableOrErr.takeError();
 ShndxTable = *TableOrErr;
   }
-  if (SymTab)
-if (Error E = dumpSymbols(SymTab, Y->Symbols))
+  if (SymTab && Y->Symbols)
+if (Error E = dumpSymbols(SymTab, *Y->Symbols))
   return std::move(E);
   if (DynSymTab)
 if (Error E = dumpSymbols(DynSymTab, Y->DynamicSymbols))
Index: llvm/lib/ObjectYAML/ELFYAML.cpp
===
--- llvm/lib/ObjectYAML/ELFYAML.cpp
+++ llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -911,6 +911,7 @@
 
 StringRef MappingTraits::validate(IO &IO,
ELFYAML::Symbol &Symbol) {
+  (void)IO;
   if (Symbol.Index && Symbol.Section.data())
 return "Index and Section cannot both be specified for Symbol";
   if (Symbol.NameIndex && !Symbol.Name.empty())
Index: llvm/lib/ObjectYAML/ELFEmitter.cpp
===
--- llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -192,7 +192,12 @@
 std::make_unique(
 ELFYAML::Section::SectionKind::RawContent, /*IsImplicit=*/true));
 
-  std::vector ImplicitSections = {".symtab", ".strtab", ".shstrtab"};
+  std::vector ImplicitSections = {".strtab", ".shstrtab"};
+  // We only generate .symtab ELF section if there was a "Symbols" entry in the
+  // YAML file.
+  if (Doc.HasSymbolsEntryInYAML()) {
+ImplicitSections.insert(ImplicitSections.begin(), {".symtab"});
+  }
   if (!Doc.DynamicSymbols.empty())
 ImplicitSections.insert(ImplicitSections.end(), {".dynsym", ".dynstr"});
 
@@ -478,7 +483,8 @@
  ELFYAML::Section *YAMLSec) {
 
   bool IsStatic = STType == SymtabType::Static;
-  const auto &Symbols = IsStatic ? Doc.Symbols : Doc.DynamicSymbols;
+  const auto &Symbols =
+  IsStatic && Doc.Symbols ? *Doc.Symbols : Doc.DynamicSymbols;
 
   ELFYAML::RawContentSection *RawSec =
   dyn_cast_or_null(YAMLSec);
@@ -1013,14 +1019,15 @@
 }
 
 template  bool ELFState::buildSymbolIndexes() {
-  return buildSymbolsMap(Doc.Symbols, SymN2I) &&
+  return Doc.Symbols && buildSymbolsMap(*Doc.Symbols, SymN2I) &&
  buildSymbolsMap(Doc.DynamicSymbols, DynSymN2I);
 }
 
 template  void ELFState::finalizeStrings() {
   // Add the regular symbol names to .strtab section.
-  for (const ELFYAML::Symbol &Sym : Doc.Symbols)
-DotStrtab.add(dropUniqueSuffix(Sym.Name));
+  if (Doc.Symbols)
+for (const ELFYAML::Symbol &Sym : *Doc.Symbols)
+  DotStrtab.add(dropUniqueSuffix(Sym.Name));
   DotStrtab.finalize();
 
   // Add the dynamic symbol names to .dynstr section.
Index: llvm/include/llvm/Support/MathExtras.h
===
--- llvm/include/llvm/Support/MathExtras.h
+++ llvm/include/llvm/Support/MathExtras.h
@@ -268,7 +268,7 @@
 T reverseBits(T Val) {
   unsigned char in[sizeof(Val)];
   unsigned char out[sizeof(Val)];
-  std::memcpy(in, &Val, sizeof(Val));
+  memcpy(in, &Val, sizeof(Val));
   for (unsigned i = 0; i < sizeof(Val); ++i)
 out[(sizeof(Val) - i) - 1] = BitReverseTable256[in[i]];
   std::memcpy(&Val, out, sizeof(Val));
Index: llvm/include/llvm/ObjectYAML/ELFYAML.h
===
--- llvm/include/llvm/ObjectYAML/ELFYAML.h
+++ llvm/include/llvm/ObjectYAML/ELFYAML.h
@@ -314,8 +314,10 @@
   // cleaner and nicer if we read them from the YAML as a separate
   // top-level key, which automatically ensures that invariants like there
   // being a single SHT_SYMTAB section are upheld.
-  std::vector Symbols;
+  Optional> Symbols;
   std::vector DynamicSymbols;
+
+  bool HasSymbolsEntryInYAML() const { return Symbols.hasValue(); }
 };
 
 } // end namespace ELFYAML
Index: lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
===
--- lldb/source/Plugins/SymbolVendor/ELF/

[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-08-27 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Looks mostly fine, but you'll need to split this patch up. You'll want a 
separate review (and test) for the yaml2obj changes. Also, the lzma code should 
not live inside ObjectFileELF. I'd put it somewhere under `lldb/Host/LZMA.h`. 
For how to wrap lzma, I'd suggest looking at `llvm/Support/Compression.h` for 
inspiration.




Comment at: lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp:79
+  // If there's none in the orignal object file, we add it to it.
+  if (auto gdd_obj_file =
+  obj_file->GetGnuDebugDataObjectFile()) {

Wouldn't it be better to first check for the external file, and then fall back 
to gnu_debugdata, as the external file will likely have more complete debug 
info?



Comment at: lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp:62
 lldb_private::Stream *feedback_strm) {
+  (void)feedback_strm;
+

You seem to have a particularly fussy compiler. I don't remember ever needing 
to mark function arguments (not locals) as unused in the default llvm config.



Comment at: llvm/include/llvm/ObjectYAML/ELFYAML.h:320
+
+  bool HasSymbolsEntryInYAML() const { return Symbols.hasValue(); }
 };

This would be lower camel case in llvm style. (But honestly, I'm not sure if 
this function adds any value).



Comment at: llvm/include/llvm/Support/MathExtras.h:271
   unsigned char out[sizeof(Val)];
-  std::memcpy(in, &Val, sizeof(Val));
+  memcpy(in, &Val, sizeof(Val));
   for (unsigned i = 0; i < sizeof(Val); ++i)

Huh?



Comment at: llvm/lib/ObjectYAML/ELFEmitter.cpp:201
+  }
   if (!Doc.DynamicSymbols.empty())
 ImplicitSections.insert(ImplicitSections.end(), {".dynsym", ".dynstr"});

So, the .dynsym section is emitted only if the yaml table is non-empty, but now 
.symtab will be emitted only when the yaml key is present? I think the .symtab 
behavior is more reasonable (because then you are actually able to generate an 
*empty* .symtab if needed), but consistency is important to. I think we'll need 
to discuss this on the yaml patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791



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


[Lldb-commits] [PATCH] D66744: NativeProcessLinux: Remove some register context boilerplate

2019-08-27 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In D66744#1646572 , @labath wrote:

> In D66744#1646514 , @jankratochvil 
> wrote:
>
> > But then there is `NativeRegisterContextLinux_x86_64::GetFPRBuffer()`. 
> > Which is never used so maybe together with 
> > `NativeRegisterContextLinux_x86_64::GetFPRSize()` they could be just 
> > `assert(0);`. It can be also considered as a different cleanup patch.
>
>
> Hm.. I didn't notice that. I'll put that in separately. Ideally, I'd say 
> these functions should be used, but that may require more cleanups in the x86 
> register context, such as detecting the register type earlier on instead of 
> just when the operations fail.


If it is left as runtime detected then the current default implementation of 
`NativeRegisterContextLinux::ReadFPR()` and 
`NativeRegisterContextLinux::WriteFPR()` could be also another class layer with 
that `virtual void *GetFPRBuffer() = 0; virtual size_t GetFPRSize() = 0;`.


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

https://reviews.llvm.org/D66744



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


[Lldb-commits] [PATCH] D66655: [lldb] Fix x86 compilation

2019-08-27 Thread Leonid Mashinskiy via Phabricator via lldb-commits
leonid.mashinskiy updated this revision to Diff 217359.
leonid.mashinskiy added a reviewer: tatyana-krasnukha.

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D66655

Files:
  source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.cpp
  source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.h
  source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.cpp
  source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.h
  source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp
  source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.h

Index: source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.h
===
--- source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.h
+++ source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.h
@@ -6,7 +6,7 @@
 //
 //===--===//
 
-#if defined(_WIN64)
+#if defined(__x86_64__) || defined(_M_X64)
 #ifndef liblldb_NativeRegisterContextWindows_x86_64_h_
 #define liblldb_NativeRegisterContextWindows_x86_64_h_
 
@@ -79,4 +79,4 @@
 } // namespace lldb_private
 
 #endif // liblldb_NativeRegisterContextWindows_x86_64_h_
-#endif // defined(_WIN64)
+#endif // defined(__x86_64__) || defined(_M_X64)
Index: source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp
===
--- source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp
+++ source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp
@@ -6,7 +6,7 @@
 //
 //===--===//
 
-#if defined(_WIN64)
+#if defined(__x86_64__) || defined(_M_X64)
 
 #include "NativeRegisterContextWindows_x86_64.h"
 #include "NativeRegisterContextWindows_WoW64.h"
@@ -476,9 +476,9 @@
   const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
   if (reg == LLDB_INVALID_REGNUM) {
 // This is likely an internal register for lldb use only and should not be
-// directly queried.
+// directly written.
 error.SetErrorStringWithFormat("register \"%s\" is an internal-only lldb "
-   "register, cannot read directly",
+   "register, cannot write directly",
reg_info->name);
 return error;
   }
@@ -576,4 +576,4 @@
   return 0;
 }
 
-#endif // defined(_WIN64)
+#endif // defined(__x86_64__) || defined(_M_X64)
Index: source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.h
===
--- source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.h
+++ source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.h
@@ -6,7 +6,7 @@
 //
 //===--===//
 
-#if defined(_WIN64)
+#if defined(__i386__) || defined(_M_IX86)
 #ifndef liblldb_NativeRegisterContextWindows_i386_h_
 #define liblldb_NativeRegisterContextWindows_i386_h_
 
@@ -71,4 +71,4 @@
 } // namespace lldb_private
 
 #endif // liblldb_NativeRegisterContextWindows_i386_h_
-#endif // defined(_WIN64)
+#endif // defined(__i386__) || defined(_M_IX86)
Index: source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.cpp
===
--- source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.cpp
+++ source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.cpp
@@ -6,7 +6,7 @@
 //
 //===--===//
 
-#if defined(_WIN32) && !defined(_WIN64)
+#if defined(__i386__) || defined(_M_IX86)
 
 #include "NativeRegisterContextWindows_i386.h"
 
@@ -242,7 +242,6 @@
 NativeRegisterContextWindows_i386::ReadRegister(const RegisterInfo *reg_info,
 RegisterValue ®_value) {
   Status error;
-  Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
 
   if (!reg_info) {
 error.SetErrorString("reg_info NULL");
@@ -267,7 +266,6 @@
 
 Status NativeRegisterContextWindows_i386::WriteRegister(
 const RegisterInfo *reg_info, const RegisterValue ®_value) {
-  Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
   Status error;
 
   if (!reg_info) {
@@ -278,20 +276,20 @@
   const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
   if (reg == LLDB_INVALID_REGNUM) {
 // This is likely an internal register for lldb use only and should not be
-// directly queried.
+// directly written.
 error.SetErrorStringWithFormat("register \"%s\" is an internal-only lldb "
- 

[Lldb-commits] [lldb] r370043 - [lldb] Allow partial completions to fix directory completion.

2019-08-27 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Aug 27 04:32:22 2019
New Revision: 370043

URL: http://llvm.org/viewvc/llvm-project?rev=370043&view=rev
Log:
[lldb] Allow partial completions to fix directory completion.

On the command line we usually insert a space after a completion to indicate 
that
the completion was successful. After the completion API refactoring, this also
happens with directories which essentially breaks file path completion (as
adding a space terminates the path and starts a new arg). This patch restores 
the old
behavior by again allowing partial completions. Also extends the iohandler
and SB API tests as the implementation for this is different in Editline
and SB API.

Modified:
lldb/trunk/include/lldb/Utility/CompletionRequest.h

lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py

lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
lldb/trunk/source/Commands/CommandCompletions.cpp
lldb/trunk/source/Host/common/Editline.cpp

Modified: lldb/trunk/include/lldb/Utility/CompletionRequest.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/CompletionRequest.h?rev=370043&r1=370042&r2=370043&view=diff
==
--- lldb/trunk/include/lldb/Utility/CompletionRequest.h (original)
+++ lldb/trunk/include/lldb/Utility/CompletionRequest.h Tue Aug 27 04:32:22 2019
@@ -17,7 +17,15 @@
 
 namespace lldb_private {
 enum class CompletionMode {
+  // The current token has been completed.
   Normal,
+  // The current token has been partially completed. This means that we found
+  // a completion, but that the completed token is still incomplete. Examples
+  // for this are file paths, where we want to complete "/bi" to "/bin/", but
+  // the file path token is still incomplete after the completion. Clients
+  // should not indicate to the user that this is a full completion (e.g. by
+  // not inserting the usual trailing space after a successful completion).
+  Partial,
   // The full line has been rewritten by the completion.
   RewriteLine,
 };

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py?rev=370043&r1=370042&r2=370043&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
 Tue Aug 27 04:32:22 2019
@@ -137,6 +137,13 @@ class CommandLineCompletionTestCase(Test
 self.complete_from_to('log enable lldb expr -f ' + src_dir,
   ['main.cpp'])
 
+@skipIfFreeBSD  # timing out on the FreeBSD buildbot
+def test_log_file(self):
+# Complete in our source directory which contains a 'main.cpp' file.
+src_dir =  os.path.dirname(os.path.realpath(__file__))
+self.complete_from_to('log enable lldb expr -f ' + src_dir,
+  [src_dir + "/"])
+
 # 
 @skipIfFreeBSD  # timing out on the FreeBSD buildbot
 def test_infinite_loop_while_completing(self):

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py?rev=370043&r1=370042&r2=370043&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
 Tue Aug 27 04:32:22 2019
@@ -2,6 +2,8 @@
 Test completion in our IOHandlers.
 """
 
+import os
+
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -48,6 +50,18 @@ class IOHandlerCompletionTest(TestBase):
 self.expect_string(prompt + "register")
 self.child.send("\n")
 
+# Try tab completing directories and files. Also tests the partial
+# completion where LLDB shouldn't print a space after the directory
+# completion (as it didn't completed the full token).
+dir_without_slashes = 
os.path.realpath(os.path.dirname(__file__)).rstrip("/")
+self.child.send("file " + dir_without_slashes + "\t")
+self.expect_string("iohandler/completion/")
+# If we get a correct partial completion without a trailing space, 
then this
+# should complete the current test file.
+self.child.send("TestIOHandler\t")
+self.expect_string("TestIOHandlerCompletion.py")
+self.child.send("\n")
+
 # Start tab completion and abort showing 

[Lldb-commits] [lldb] r370047 - [lldb][NFC] Give added test method a unique name

2019-08-27 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Aug 27 04:43:54 2019
New Revision: 370047

URL: http://llvm.org/viewvc/llvm-project?rev=370047&view=rev
Log:
[lldb][NFC] Give added test method a unique name

Otherwise dotest doesn't run the test and just lets it always pass.
Also update the comment to explain that we do directory and not
file completion.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py?rev=370047&r1=370046&r2=370047&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
 Tue Aug 27 04:43:54 2019
@@ -138,8 +138,8 @@ class CommandLineCompletionTestCase(Test
   ['main.cpp'])
 
 @skipIfFreeBSD  # timing out on the FreeBSD buildbot
-def test_log_file(self):
-# Complete in our source directory which contains a 'main.cpp' file.
+def test_log_dir(self):
+# Complete our source directory.
 src_dir =  os.path.dirname(os.path.realpath(__file__))
 self.complete_from_to('log enable lldb expr -f ' + src_dir,
   [src_dir + "/"])


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


[Lldb-commits] [lldb] r370050 - [lldb][NFC] Add some tests for the target subcommands

2019-08-27 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Aug 27 04:57:26 2019
New Revision: 370050

URL: http://llvm.org/viewvc/llvm-project?rev=370050&view=rev
Log:
[lldb][NFC] Add some tests for the target subcommands

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py?rev=370050&r1=370049&r2=370050&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py
 Tue Aug 27 04:57:26 2019
@@ -3,7 +3,9 @@ Test some target commands: create, list,
 """
 
 from __future__ import print_function
-
+import os
+import stat
+import tempfile
 
 import lldb
 from lldbsuite.test.decorators import *
@@ -293,3 +295,145 @@ class targetCommandTestCase(TestBase):
 
 self.expect("target stop-hook delete 1", error=True, substrs=['unknown 
stop hook id: "1"'])
 self.expect("target stop-hook delete blub", error=True, 
substrs=['invalid stop hook id: "blub"'])
+
+@no_debug_info_test
+def test_target_list_args(self):
+self.expect("target list blub", error=True,
+substrs=["the 'target list' command takes no arguments"])
+
+@no_debug_info_test
+def test_target_select_no_index(self):
+self.expect("target select", error=True,
+substrs=["'target select' takes a single argument: a 
target index"])
+
+@no_debug_info_test
+def test_target_select_invalid_index(self):
+self.runCmd("target delete --all")
+self.expect("target select 0", error=True,
+substrs=["index 0 is out of range since there are no 
active targets"])
+self.buildB()
+self.runCmd("file " + self.getBuildArtifact("b.out"), 
CURRENT_EXECUTABLE_SET)
+self.expect("target select 1", error=True,
+substrs=["index 1 is out of range, valid target indexes 
are 0 - 0"])
+
+
+@no_debug_info_test
+def test_target_create_multiple_args(self):
+self.expect("target create a b", error=True,
+substrs=["'target create' takes exactly one executable 
path"])
+
+@no_debug_info_test
+def test_target_create_nonexistent_core_file(self):
+self.expect("target create -c doesntexist", error=True,
+substrs=["core file 'doesntexist' doesn't exist"])
+
+# Write only files don't seem to be supported on Windows.
+@skipIfWindows
+@no_debug_info_test
+def test_target_create_unreadable_core_file(self):
+tf = tempfile.NamedTemporaryFile()
+os.chmod(tf.name, stat.S_IWRITE)
+self.expect("target create -c '" + tf.name + "'", error=True,
+substrs=["core file '", "' is not readable"])
+
+@no_debug_info_test
+def test_target_create_nonexistent_sym_file(self):
+self.expect("target create -s doesntexist doesntexisteither", 
error=True,
+substrs=["invalid symbol file path 'doesntexist'"])
+
+@no_debug_info_test
+def test_target_create_invalid_core_file(self):
+invalid_core_path = os.path.join(self.getSourceDir(), 
"invalid_core_file")
+self.expect("target create -c '" + invalid_core_path + "'", error=True,
+substrs=["Unable to find process plug-in for core file '"])
+
+
+# Write only files don't seem to be supported on Windows.
+@skipIfWindows
+@no_debug_info_test
+def test_target_create_unreadable_sym_file(self):
+tf = tempfile.NamedTemporaryFile()
+os.chmod(tf.name, stat.S_IWRITE)
+self.expect("target create -s '" + tf.name + "' no_exe", error=True,
+substrs=["symbol file '", "' is not readable"])
+
+@no_debug_info_test
+def test_target_delete_all(self):
+self.buildAll()
+self.runCmd("file " + self.getBuildArtifact("a.out"), 
CURRENT_EXECUTABLE_SET)
+self.runCmd("file " + self.getBuildArtifact("b.out"), 
CURRENT_EXECUTABLE_SET)
+self.expect("target delete --all")
+self.expect("target list", substrs=["No targets."])
+
+@no_debug_info_test
+def test_target_delete_by_index(self):
+self.buildAll()
+self.runCmd("file " + self.getBuildArtifact("a.out"), 
CURRENT_EXECUTABLE_SET)
+self.runCmd("file " + self.getBuildArtifact("b.out"), 
CURRENT_EXECUTABLE_SET)
+self.runCmd("file " + self.getBuildArtifact("c.out"), 
CURRENT_EXECUTABLE_SET)
+self.expect("target delete 3", error=True,
+substrs=["target index 3 is out of range, valid target 
indexes are 0 - 2"])
+
+self.runC

[Lldb-commits] [PATCH] D59692: [ASTImporter] Fix name conflict handling with different strategies

2019-08-27 Thread Gabor Marton via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf035b75d8f07: [ASTImporter] Fix name conflict handling with 
different strategies (authored by martong).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59692

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/lib/AST/ASTImporter.cpp
  clang/test/Analysis/Inputs/ctu-other.c
  clang/unittests/AST/ASTImporterFixtures.cpp
  clang/unittests/AST/ASTImporterFixtures.h
  clang/unittests/AST/ASTImporterTest.cpp
  lldb/include/lldb/Symbol/ClangASTImporter.h

Index: lldb/include/lldb/Symbol/ClangASTImporter.h
===
--- lldb/include/lldb/Symbol/ClangASTImporter.h
+++ lldb/include/lldb/Symbol/ClangASTImporter.h
@@ -252,7 +252,9 @@
 : clang::ASTImporter(*target_ctx, master.m_file_manager, *source_ctx,
  master.m_file_manager, true /*minimal*/),
   m_decls_to_deport(nullptr), m_decls_already_deported(nullptr),
-  m_master(master), m_source_ctx(source_ctx) {}
+  m_master(master), m_source_ctx(source_ctx) {
+  setODRHandling(clang::ASTImporter::ODRHandlingType::Liberal);
+}
 
 /// Scope guard that attaches a CxxModuleHandler to an ASTImporterDelegate
 /// and deattaches it at the end of the scope. Supports being used multiple
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1879,7 +1879,7 @@
   auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
   // We expect one (ODR) warning during the import.
   EXPECT_EQ(1u, ToTU->getASTContext().getDiagnostics().getNumWarnings());
-  EXPECT_EQ(2u,
+  EXPECT_EQ(1u,
 DeclCounter().match(ToTU, recordDecl(hasName("X";
 }
 
@@ -2432,6 +2432,62 @@
   EXPECT_EQ(ToD1, ToD2);
 }
 
+TEST_P(ImportFunctionTemplates,
+   ImportFunctionWhenThereIsAFunTemplateWithSameName) {
+  getToTuDecl(
+  R"(
+  template 
+  void foo(T) {}
+  void foo();
+  )",
+  Lang_CXX);
+  Decl *FromTU = getTuDecl("void foo();", Lang_CXX);
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("foo")));
+  auto *ImportedD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ImportedD);
+}
+
+TEST_P(ImportFunctionTemplates,
+   ImportConstructorWhenThereIsAFunTemplateWithSameName) {
+  auto Code =
+  R"(
+  struct Foo {
+template 
+Foo(T) {}
+Foo();
+  };
+  )";
+  getToTuDecl(Code, Lang_CXX);
+  Decl *FromTU = getTuDecl(Code, Lang_CXX);
+  auto *FromD =
+  LastDeclMatcher().match(FromTU, cxxConstructorDecl());
+  auto *ImportedD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ImportedD);
+}
+
+TEST_P(ImportFunctionTemplates,
+   ImportOperatorWhenThereIsAFunTemplateWithSameName) {
+  getToTuDecl(
+  R"(
+  template 
+  void operator<(T,T) {}
+  struct X{};
+  void operator<(X, X);
+  )",
+  Lang_CXX);
+  Decl *FromTU = getTuDecl(
+  R"(
+  struct X{};
+  void operator<(X, X);
+  )",
+  Lang_CXX);
+  auto *FromD = LastDeclMatcher().match(
+  FromTU, functionDecl(hasOverloadedOperatorName("<")));
+  auto *ImportedD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ImportedD);
+}
+
 struct ImportFriendFunctions : ImportFunctions {};
 
 TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainProto) {
@@ -5127,15 +5183,6 @@
   }
 }
 
-INSTANTIATE_TEST_CASE_P(ParameterizedTests, ErrorHandlingTest,
-DefaultTestValuesForRunOptions, );
-
-INSTANTIATE_TEST_CASE_P(ParameterizedTests, DeclContextTest,
-::testing::Values(ArgVector()), );
-
-INSTANTIATE_TEST_CASE_P(ParameterizedTests, CanonicalRedeclChain,
-::testing::Values(ArgVector()), );
-
 TEST_P(ASTImporterOptionSpecificTestBase, LambdaInFunctionBody) {
   Decl *FromTU = getTuDecl(
   R"(
@@ -5233,8 +5280,8 @@
   // prototype (inside 'friend') for it comes first in the AST and is not
   // linked to the definition.
   EXPECT_EQ(ImportedDef, ToClassDef);
-}  
-  
+}
+
 struct LLDBLookupTest : ASTImporterOptionSpecificTestBase {
   LLDBLookupTest() {
 Creator = [](ASTContext &ToContext, FileManager &ToFileManager,
@@ -5362,10 +5409,197 @@
   EXPECT_EQ(ImportedX->isAggregate(), FromX->isAggregate());
 }
 
+struct ConflictingDeclsWithLiberalStrategy : ASTImporterOptionSpecificTestBase {
+  ConflictingDeclsWithLiberalStrategy() {
+this->ODRHandling = ASTImporter::ODRHandlingType::Liberal;
+  }
+};
+
+// Check that a Decl has been successfully imported into a standalone redecl
+// chain.
+template 
+static void CheckImportedAsNew(llvm::Expected &Result, Decl *ToTU,
+   PatternTy Pattern) {
+  ASSERT_TRUE(isSuccess(Result));
+  Decl *ImportedD = *

[Lldb-commits] [PATCH] D66654: Prevent D66398 `TestDataFormatterStdList`-like regressions in the future

2019-08-27 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil planned changes to this revision.
jankratochvil marked an inline comment as done.
jankratochvil added inline comments.



Comment at: lldb/include/lldb/Core/ValueObject.h:460
+  // Store error from Expected<> parameter unless some error is already stored.
+  template  void TakeError(llvm::Expected &&e) {
+if (!e && !GetError().Fail())

labath wrote:
> I didn't mention this in the previous patches, but I think you're overusing 
> the rvalue references here. It's generally better to use regular value 
> objects in cases like these because this enforces proper contracts between 
> functions.
> 
> Using rvalue references leaves open the possibility for a bug (which you've 
> actually made here) that the `TakeError` function will do nothing to the 
> passed-in object (on some path of execution), which means that the object 
> will continue to exist in the "untaken" state in the caller, and then 
> probably assert some distance away from where it was meant to be used.
> 
> Passing the argument as a plain object means that this function *must* do 
> something with it (really *take* it) or *it* will assert. The cost of that is 
> a single object move, but that should generally be trivial for objects that 
> implement moving properly.
Thanks for this notification, I see I was automatically using the && parameter 
specifier excessively. rvalues still work properly with std::move() even 
without using this parameter specifier.
I also agree there was the bug with possibly untaken Error asserting later (I 
find that as an orthogonal bug to the && one).



Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D66654



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


[Lldb-commits] [PATCH] D63591: DWARFDebugLoc: Make parsing and error reporting more robust

2019-08-27 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 217378.
labath added a comment.

Rebase the patch on top of DataExtractor Cursor changes.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D63591

Files:
  include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
  lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
  lib/DebugInfo/DWARF/DWARFVerifier.cpp
  test/DebugInfo/X86/dwarfdump-debug-loc-error-cases.s
  test/DebugInfo/X86/dwarfdump-debug-loclists-error-cases.s

Index: test/DebugInfo/X86/dwarfdump-debug-loclists-error-cases.s
===
--- /dev/null
+++ test/DebugInfo/X86/dwarfdump-debug-loclists-error-cases.s
@@ -0,0 +1,71 @@
+# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE1=0 -o %t1.o
+# RUN: llvm-dwarfdump -debug-loclists %t1.o 2>&1 | FileCheck %s --check-prefix=ULEB
+
+# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE2=0 -o %t2.o
+# RUN: llvm-dwarfdump -debug-loclists %t2.o 2>&1 | FileCheck %s --check-prefix=ULEB
+
+# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE3=0 -o %t3.o
+# RUN: llvm-dwarfdump -debug-loclists %t3.o 2>&1 | FileCheck %s --check-prefix=ULEB
+
+# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE4=0 -o %t4.o
+# RUN: llvm-dwarfdump -debug-loclists %t4.o 2>&1 | FileCheck %s
+
+# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE5=0 -o %t5.o
+# RUN: llvm-dwarfdump -debug-loclists %t5.o 2>&1 | FileCheck %s
+
+# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE6=0 -o %t6.o
+# RUN: llvm-dwarfdump -debug-loclists %t6.o 2>&1 | FileCheck %s
+
+# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE7=0 -o %t7.o
+# RUN: llvm-dwarfdump -debug-loclists %t7.o 2>&1 | FileCheck %s --check-prefix=UNIMPL
+
+# CHECK: error: unexpected end of data
+# ULEB: error: malformed uleb128, extends past end
+# UNIMPL: error: LLE of kind 47 not supported
+
+.section  .debug_loclists,"",@progbits
+  .long  .Ldebug_loclist_table_end0-.Ldebug_loclist_table_start0
+.Ldebug_loclist_table_start0:
+ .short 5# Version.
+ .byte 8 # Address size.
+ .byte 0 # Segment selector size.
+ .long 0 # Offset entry count.
+.Lloclists_table_base0:
+.Ldebug_loc0:
+.ifdef CASE1
+  .byte  4   # DW_LLE_offset_pair
+.endif
+.ifdef CASE2
+  .byte  4   # DW_LLE_offset_pair
+  .uleb128 0x0   #   starting offset
+.endif
+.ifdef CASE3
+  .byte  4   # DW_LLE_offset_pair
+  .uleb128 0x0   #   starting offset
+  .uleb128 0x10  #   ending offset
+.endif
+.ifdef CASE4
+  .byte  4   # DW_LLE_offset_pair
+  .uleb128 0x0   #   starting offset
+  .uleb128 0x10  #   ending offset
+  .byte  1   # Loc expr size
+.endif
+.ifdef CASE5
+  .byte  4   # DW_LLE_offset_pair
+  .uleb128 0x0   #   starting offset
+  .uleb128 0x10  #   ending offset
+  .byte  1   # Loc expr size
+  .byte  117 # DW_OP_breg5
+.endif
+.ifdef CASE6
+  .byte  4   # DW_LLE_offset_pair
+  .uleb128 0x0   #   starting offset
+  .uleb128 0x10  #   ending offset
+  .uleb128 0xdeadbeef# Loc expr size
+.endif
+.ifdef CASE7
+  .byte 0x47
+.endif
+
+.Ldebug_loclist_table_end0:
+
Index: test/DebugInfo/X86/dwarfdump-debug-loc-error-cases.s
===
--- /dev/null
+++ test/DebugInfo/X86/dwarfdump-debug-loc-error-cases.s
@@ -0,0 +1,58 @@
+# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE1=0 -o %t1.o
+# RUN: llvm-dwarfdump -debug-loc %t1.o 2>&1 | FileCheck %s
+
+# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE2=0 -o %t2.o
+# RUN: llvm-dwarfdump -debug-loc %t2.o 2>&1 | FileCheck %s
+
+# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE3=0 -o %t3.o
+# RUN: llvm-dwarfdump -debug-loc %t3.o 2>&1 | FileCheck %s
+
+# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE4=0 -o %t4.o
+# RUN: llvm-dwarfdump -debug-loc %t4.o 2>&1 | FileCheck %s
+
+# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE5=0 -o %t5.o
+# RUN: llvm-dwarfdump -debug-loc %t5.o 2>&1 | FileCheck %s
+
+# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE6=0 -o %t6.o
+# RUN: llvm-dwarfdump -debug-loc %t6.o 2>&1 | FileCheck %s
+
+# CHECK: error: unexpected end of data
+
+.section  .debug_loc,"",@progbits
+.ifdef CASE1
+  .byte  1   # bogus
+.endif
+.ifdef CASE2
+  .long  0   # starting offset
+.endif
+.ifdef CASE3
+  .long  0   # starting offset
+  .long  1   # en

[Lldb-commits] [lldb] r370054 - Stabilize TestIOHandlerCompletion

2019-08-27 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Aug 27 06:09:40 2019
New Revision: 370054

URL: http://llvm.org/viewvc/llvm-project?rev=370054&view=rev
Log:
Stabilize TestIOHandlerCompletion

pexpect gives as raw data going to a terminal. This means that if the
completed line does not fit the emulated line, the returned data will
contain line breaks. On my machine these line breaks happened to be
inside the "iohandler/completion" string that the test was searching
for.

Work around this by telling pexpect to emulate a very wide terminal.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py?rev=370054&r1=370053&r2=370054&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
 Tue Aug 27 06:09:40 2019
@@ -38,7 +38,8 @@ class IOHandlerCompletionTest(TestBase):
 
 self.child = pexpect.spawn(
 '%s %s %s %s' %
-(lldbtest_config.lldbExec, self.lldbOption, "", exe))
+(lldbtest_config.lldbExec, self.lldbOption, "", exe),
+dimensions=(100, 500))
 
 self.expect_string(prompt)
 # Start tab completion, go to the next page and then display all with 
'a'.


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


[Lldb-commits] [lldb] r370057 - [lldb][NFC] Add missing invalid_core_file to TestTargetCommand test

2019-08-27 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Aug 27 06:34:15 2019
New Revision: 370057

URL: http://llvm.org/viewvc/llvm-project?rev=370057&view=rev
Log:
[lldb][NFC] Add missing invalid_core_file to TestTargetCommand test

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/invalid_core_file

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/invalid_core_file
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/invalid_core_file?rev=370057&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/invalid_core_file
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/invalid_core_file
 Tue Aug 27 06:34:15 2019
@@ -0,0 +1 @@
+stub


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


[Lldb-commits] [PATCH] D59692: [ASTImporter] Fix name conflict handling with different strategies

2019-08-27 Thread Gabor Marton via Phabricator via lldb-commits
martong added a comment.

Jenkins is not green 
http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/743/
However, the newly failing test is `TestTargetCommand.py`, which seems to be 
unrelated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59692



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


[Lldb-commits] [PATCH] D59692: [ASTImporter] Fix name conflict handling with different strategies

2019-08-27 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D59692#1646990 , @martong wrote:

> Jenkins is not green 
> http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/743/
>  However, the newly failing test is `TestTargetCommand.py`, which seems to be 
> unrelated.


That ought to be fixed by r370057.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59692



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


[Lldb-commits] [PATCH] D66655: [lldb] Fix x86 compilation

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

LGTM


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D66655



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


[Lldb-commits] [PATCH] D66655: [lldb] Fix x86 compilation

2019-08-27 Thread Leonid Mashinskiy via Phabricator via lldb-commits
leonid.mashinskiy added a comment.

@tatyana-krasnukha Can you commit this please because I have no commit access


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D66655



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


[Lldb-commits] [PATCH] D66789: Remove DWARFExpression::LocationListSize

2019-08-27 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

Thanks, Pavel!


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

https://reviews.llvm.org/D66789



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


[Lldb-commits] [PATCH] D63591: DWARFDebugLoc: Make parsing and error reporting more robust

2019-08-27 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

LGTM


Repository:
  rL LLVM

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

https://reviews.llvm.org/D63591



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


[Lldb-commits] [lldb] r370078 - [lldb] Fix x86 compilation

2019-08-27 Thread Tatyana Krasnukha via lldb-commits
Author: tkrasnukha
Date: Tue Aug 27 10:22:03 2019
New Revision: 370078

URL: http://llvm.org/viewvc/llvm-project?rev=370078&view=rev
Log:
[lldb] Fix x86 compilation

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

Patch by Leonid Mashinskiy

Modified:

lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.cpp

lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.h

lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.cpp

lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.h

lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp

lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.h

Modified: 
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.cpp?rev=370078&r1=370077&r2=370078&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.cpp
 Tue Aug 27 10:22:03 2019
@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-#if defined(_WIN64)
+#if defined(__x86_64__) || defined(_M_X64)
 
 #include "NativeRegisterContextWindows_WoW64.h"
 
@@ -265,9 +265,9 @@ Status NativeRegisterContextWindows_WoW6
   const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
   if (reg == LLDB_INVALID_REGNUM) {
 // This is likely an internal register for lldb use only and should not be
-// directly queried.
+// directly written.
 error.SetErrorStringWithFormat("register \"%s\" is an internal-only lldb "
-   "register, cannot read directly",
+   "register, cannot write directly",
reg_info->name);
 return error;
   }
@@ -359,4 +359,4 @@ uint32_t NativeRegisterContextWindows_Wo
   return 0;
 }
 
-#endif // defined(_WIN64)
+#endif // defined(__x86_64__) || defined(_M_X64)

Modified: 
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.h?rev=370078&r1=370077&r2=370078&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.h
 (original)
+++ 
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.h
 Tue Aug 27 10:22:03 2019
@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-#if defined(_WIN64)
+#if defined(__x86_64__) || defined(_M_X64)
 #ifndef liblldb_NativeRegisterContextWindows_WoW64_h_
 #define liblldb_NativeRegisterContextWindows_WoW64_h_
 
@@ -71,4 +71,4 @@ private:
 } // namespace lldb_private
 
 #endif // liblldb_NativeRegisterContextWindows_WoW64_h_
-#endif // defined(_WIN64)
+#endif // defined(__x86_64__) || defined(_M_X64)

Modified: 
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.cpp?rev=370078&r1=370077&r2=370078&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.cpp
 Tue Aug 27 10:22:03 2019
@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-#if defined(_WIN32) && !defined(_WIN64)
+#if defined(__i386__) || defined(_M_IX86)
 
 #include "NativeRegisterContextWindows_i386.h"
 
@@ -242,7 +242,6 @@ Status
 NativeRegisterContextWindows_i386::ReadRegister(const RegisterInfo *reg_info,
 RegisterValue ®_value) {
   Status error;
-  Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
 
   if (!reg_info) {
 error.SetErrorString("reg_info NULL");
@@ -267,7 +266,6 @@ NativeRegisterContextWindows_i386::ReadR
 
 Status NativeRegisterContextWindows_i386::WriteRegister(
 const RegisterInfo *reg_info, const RegisterValue ®_value) {
-  Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
   Status error;
 
   if (!reg_info) {
@@ -278,20 +276,20 @@ Status NativeRegisterContextWindows_i386
   const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
   if (reg == LLDB_INVALID_REGNUM

[Lldb-commits] [PATCH] D66655: [lldb] Fix x86 compilation

2019-08-27 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370078: [lldb] Fix x86 compilation (authored by tkrasnukha, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66655?vs=217359&id=217430#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66655

Files:
  
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.cpp
  
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.h
  
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.cpp
  
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.h
  
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp
  
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.h

Index: lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.h
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.h
+++ lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.h
@@ -6,7 +6,7 @@
 //
 //===--===//
 
-#if defined(_WIN64)
+#if defined(__i386__) || defined(_M_IX86)
 #ifndef liblldb_NativeRegisterContextWindows_i386_h_
 #define liblldb_NativeRegisterContextWindows_i386_h_
 
@@ -71,4 +71,4 @@
 } // namespace lldb_private
 
 #endif // liblldb_NativeRegisterContextWindows_i386_h_
-#endif // defined(_WIN64)
+#endif // defined(__i386__) || defined(_M_IX86)
Index: lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.cpp
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.cpp
+++ lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.cpp
@@ -6,7 +6,7 @@
 //
 //===--===//
 
-#if defined(_WIN64)
+#if defined(__x86_64__) || defined(_M_X64)
 
 #include "NativeRegisterContextWindows_WoW64.h"
 
@@ -265,9 +265,9 @@
   const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
   if (reg == LLDB_INVALID_REGNUM) {
 // This is likely an internal register for lldb use only and should not be
-// directly queried.
+// directly written.
 error.SetErrorStringWithFormat("register \"%s\" is an internal-only lldb "
-   "register, cannot read directly",
+   "register, cannot write directly",
reg_info->name);
 return error;
   }
@@ -359,4 +359,4 @@
   return 0;
 }
 
-#endif // defined(_WIN64)
+#endif // defined(__x86_64__) || defined(_M_X64)
Index: lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp
+++ lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp
@@ -6,7 +6,7 @@
 //
 //===--===//
 
-#if defined(_WIN64)
+#if defined(__x86_64__) || defined(_M_X64)
 
 #include "NativeRegisterContextWindows_x86_64.h"
 #include "NativeRegisterContextWindows_WoW64.h"
@@ -476,9 +476,9 @@
   const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
   if (reg == LLDB_INVALID_REGNUM) {
 // This is likely an internal register for lldb use only and should not be
-// directly queried.
+// directly written.
 error.SetErrorStringWithFormat("register \"%s\" is an internal-only lldb "
-   "register, cannot read directly",
+   "register, cannot write directly",
reg_info->name);
 return error;
   }
@@ -576,4 +576,4 @@
   return 0;
 }
 
-#endif // defined(_WIN64)
+#endif // defined(__x86_64__) || defined(_M_X64)
Index: lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.h
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.h
+++ lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.h
@@ -6,7 +6,7 @@
 //
 //===--===//
 
-#if defined(_WIN64)
+#if defined(__x86_64__) || defined(_M_X64)
 #ifndef liblldb_NativeRegisterContextWindows_WoW64_h_
 #define liblldb_NativeRegisterContextWindows_WoW64_h_
 
@@ -71,4 +71,4 @@
 } // namespace lldb_private
 
 #endif //

[Lldb-commits] [PATCH] D66811: [dotest] Remove results port

2019-08-27 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: LLDB.
Herald added a subscriber: abidh.
Herald added a project: LLDB.

The results port was used by `dosep` to deal with test results coming form 
different processes. With dosep gone, I don't think we need this any longer.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D66811

Files:
  lldb/packages/Python/lldbsuite/test/configuration.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/dotest_args.py
  lldb/packages/Python/lldbsuite/test_event/formatter/__init__.py
  lldb/packages/Python/lldbsuite/test_event/formatter/curses.py
  lldb/packages/Python/lldbsuite/test_event/formatter/pickled.py
  lldb/packages/Python/lldbsuite/test_event/formatter/results_formatter.py
  lldb/packages/Python/lldbsuite/test_event/formatter/xunit.py

Index: lldb/packages/Python/lldbsuite/test_event/formatter/xunit.py
===
--- lldb/packages/Python/lldbsuite/test_event/formatter/xunit.py
+++ lldb/packages/Python/lldbsuite/test_event/formatter/xunit.py
@@ -155,14 +155,14 @@
 regex_list.append(re.compile(pattern))
 return regex_list
 
-def __init__(self, out_file, options, file_is_stream):
+def __init__(self, out_file, options):
 """Initializes the XunitFormatter instance.
 @param out_file file-like object where formatted output is written.
 @param options specifies a dictionary of options for the
 formatter.
 """
 # Initialize the parent
-super(XunitFormatter, self).__init__(out_file, options, file_is_stream)
+super(XunitFormatter, self).__init__(out_file, options)
 self.text_encoding = "UTF-8"
 self.invalid_xml_re = XunitFormatter._build_illegal_xml_regex()
 self.total_test_count = 0
Index: lldb/packages/Python/lldbsuite/test_event/formatter/results_formatter.py
===
--- lldb/packages/Python/lldbsuite/test_event/formatter/results_formatter.py
+++ lldb/packages/Python/lldbsuite/test_event/formatter/results_formatter.py
@@ -114,7 +114,7 @@
   'the summary output.'))
 return parser
 
-def __init__(self, out_file, options, file_is_stream):
+def __init__(self, out_file, options):
 super(ResultsFormatter, self).__init__()
 self.out_file = out_file
 self.options = options
@@ -123,7 +123,6 @@
 raise Exception("ResultsFormatter created with no file object")
 self.start_time_by_test = {}
 self.terminate_called = False
-self.file_is_stream = file_is_stream
 
 # Track the most recent test start event by worker index.
 # We'll use this to assign TIMEOUT and exceptional
Index: lldb/packages/Python/lldbsuite/test_event/formatter/pickled.py
===
--- lldb/packages/Python/lldbsuite/test_event/formatter/pickled.py
+++ lldb/packages/Python/lldbsuite/test_event/formatter/pickled.py
@@ -46,18 +46,14 @@
 def serialize(test_event, out_file):
 cPickle.dump(test_event, out_file)
 
-def __init__(self, out_file, options, file_is_stream):
+def __init__(self, out_file, options):
 super(
 RawPickledFormatter,
 self).__init__(
 out_file,
-options,
-file_is_stream)
+options)
 self.pid = os.getpid()
-if file_is_stream:
-self.serializer = self.StreamSerializer()
-else:
-self.serializer = self.BlockSerializer()
+self.serializer = self.BlockSerializer()
 
 def handle_event(self, test_event):
 super(RawPickledFormatter, self).handle_event(test_event)
Index: lldb/packages/Python/lldbsuite/test_event/formatter/curses.py
===
--- lldb/packages/Python/lldbsuite/test_event/formatter/curses.py
+++ lldb/packages/Python/lldbsuite/test_event/formatter/curses.py
@@ -26,9 +26,9 @@
 class Curses(results_formatter.ResultsFormatter):
 """Receives live results from tests that are running and reports them to the terminal in a curses GUI"""
 
-def __init__(self, out_file, options, file_is_stream):
+def __init__(self, out_file, options):
 # Initialize the parent
-super(Curses, self).__init__(out_file, options, file_is_stream)
+super(Curses, self).__init__(out_file, options)
 self.using_terminal = True
 self.have_curses = True
 self.initialize_event = None
Index: lldb/packages/Python/lldbsuite/test_event/formatter/__init__.py
===
--- lldb/packages/Python/lldbsuite/test_event/formatter/__init__.py
+++ lldb/packages/Python/lldbsuite/test_event/formatter/__init__.py
@@ -24,7 +24,6 @@
 
 def __init__(self):
 

[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-08-27 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: llvm/include/llvm/Support/MathExtras.h:271
   unsigned char out[sizeof(Val)];
-  std::memcpy(in, &Val, sizeof(Val));
+  memcpy(in, &Val, sizeof(Val));
   for (unsigned i = 0; i < sizeof(Val); ++i)

What are you building on that `memcpy` is not in the `std` namespace? This is 
non-conforming. 

C standard library headers provided by `cname` headers have their functions 
within the `std` namespace and it is unspecified whether these names are 
available in the global namespace. See [headers 
p5](http://eel.is/c++draft/headers#5).

Also it is not consistent since the `memcpy` below is left as-is. Why does one 
trigger the warning and not the other?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791



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


[Lldb-commits] [PATCH] D66811: [dotest] Remove results port

2019-08-27 Thread Macide Celik via Phabricator via lldb-commits
BlackAngel35 requested changes to this revision.
BlackAngel35 added a comment.
This revision now requires changes to proceed.

EnDing


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D66811



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


[Lldb-commits] [PATCH] D66811: [dotest] Remove results port

2019-08-27 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.

LGTM


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D66811



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


[Lldb-commits] [lldb] r370090 - [dotest] Remove results port

2019-08-27 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Tue Aug 27 11:18:46 2019
New Revision: 370090

URL: http://llvm.org/viewvc/llvm-project?rev=370090&view=rev
Log:
[dotest] Remove results port

The results port was used by dosep.py to deal with test results coming
form different processes. With dosep.py gone, I don't think we need this
any longer.

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

Modified:
lldb/trunk/packages/Python/lldbsuite/test/configuration.py
lldb/trunk/packages/Python/lldbsuite/test/dotest.py
lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py
lldb/trunk/packages/Python/lldbsuite/test_event/formatter/__init__.py
lldb/trunk/packages/Python/lldbsuite/test_event/formatter/curses.py
lldb/trunk/packages/Python/lldbsuite/test_event/formatter/pickled.py

lldb/trunk/packages/Python/lldbsuite/test_event/formatter/results_formatter.py
lldb/trunk/packages/Python/lldbsuite/test_event/formatter/xunit.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/configuration.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/configuration.py?rev=370090&r1=370089&r2=370090&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/configuration.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/configuration.py Tue Aug 27 
11:18:46 2019
@@ -117,7 +117,6 @@ exclusive_test_subdir = None
 
 # Test results handling globals
 results_filename = None
-results_port = None
 results_formatter_name = None
 results_formatter_object = None
 results_formatter_options = None

Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=370090&r1=370089&r2=370090&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Tue Aug 27 11:18:46 2019
@@ -429,15 +429,6 @@ def parseOptionsAndInitTestdirs():
 if args.results_file:
 configuration.results_filename = args.results_file
 
-if args.results_port:
-configuration.results_port = args.results_port
-
-if args.results_file and args.results_port:
-sys.stderr.write(
-"only one of --results-file and --results-port should "
-"be specified\n")
-usage(args)
-
 if args.results_formatter:
 configuration.results_formatter_name = args.results_formatter
 if args.results_formatter_options:
@@ -516,7 +507,6 @@ def setupTestResults():
 formatter_config.formatter_name = configuration.results_formatter_name
 formatter_config.formatter_options = (
 configuration.results_formatter_options)
-formatter_config.port = configuration.results_port
 
 # Create the results formatter.
 formatter_spec = formatter.create_results_formatter(

Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py?rev=370090&r1=370089&r2=370090&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py Tue Aug 27 
11:18:46 2019
@@ -231,12 +231,6 @@ def create_parser():
 help=('Specifies the file where test results will be written '
   'according to the results-formatter class used'))
 group.add_argument(
-'--results-port',
-action='store',
-type=int,
-help=('Specifies the localhost port to which the results '
-  'formatted output should be sent'))
-group.add_argument(
 '--results-formatter',
 action='store',
 help=('Specifies the full package/module/class name used to translate '

Modified: lldb/trunk/packages/Python/lldbsuite/test_event/formatter/__init__.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test_event/formatter/__init__.py?rev=370090&r1=370089&r2=370090&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test_event/formatter/__init__.py 
(original)
+++ lldb/trunk/packages/Python/lldbsuite/test_event/formatter/__init__.py Tue 
Aug 27 11:18:46 2019
@@ -24,7 +24,6 @@ class FormatterConfig(object):
 
 def __init__(self):
 self.filename = None
-self.port = None
 self.formatter_name = None
 self.formatter_options = None
 
@@ -48,43 +47,10 @@ def create_results_formatter(config):
 @return an instance of CreatedFormatter.
 """
 
-def create_socket(port):
-"""Creates a socket to the localhost on the given port.
-
-@param port the port number of the listening port on
-the localhos

[Lldb-commits] [PATCH] D66811: [dotest] Remove results port

2019-08-27 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370090: [dotest] Remove results port (authored by 
JDevlieghere, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66811?vs=217433&id=217446#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66811

Files:
  lldb/trunk/packages/Python/lldbsuite/test/configuration.py
  lldb/trunk/packages/Python/lldbsuite/test/dotest.py
  lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py
  lldb/trunk/packages/Python/lldbsuite/test_event/formatter/__init__.py
  lldb/trunk/packages/Python/lldbsuite/test_event/formatter/curses.py
  lldb/trunk/packages/Python/lldbsuite/test_event/formatter/pickled.py
  lldb/trunk/packages/Python/lldbsuite/test_event/formatter/results_formatter.py
  lldb/trunk/packages/Python/lldbsuite/test_event/formatter/xunit.py

Index: lldb/trunk/packages/Python/lldbsuite/test_event/formatter/results_formatter.py
===
--- lldb/trunk/packages/Python/lldbsuite/test_event/formatter/results_formatter.py
+++ lldb/trunk/packages/Python/lldbsuite/test_event/formatter/results_formatter.py
@@ -114,7 +114,7 @@
   'the summary output.'))
 return parser
 
-def __init__(self, out_file, options, file_is_stream):
+def __init__(self, out_file, options):
 super(ResultsFormatter, self).__init__()
 self.out_file = out_file
 self.options = options
@@ -123,7 +123,6 @@
 raise Exception("ResultsFormatter created with no file object")
 self.start_time_by_test = {}
 self.terminate_called = False
-self.file_is_stream = file_is_stream
 
 # Track the most recent test start event by worker index.
 # We'll use this to assign TIMEOUT and exceptional
Index: lldb/trunk/packages/Python/lldbsuite/test_event/formatter/curses.py
===
--- lldb/trunk/packages/Python/lldbsuite/test_event/formatter/curses.py
+++ lldb/trunk/packages/Python/lldbsuite/test_event/formatter/curses.py
@@ -26,9 +26,9 @@
 class Curses(results_formatter.ResultsFormatter):
 """Receives live results from tests that are running and reports them to the terminal in a curses GUI"""
 
-def __init__(self, out_file, options, file_is_stream):
+def __init__(self, out_file, options):
 # Initialize the parent
-super(Curses, self).__init__(out_file, options, file_is_stream)
+super(Curses, self).__init__(out_file, options)
 self.using_terminal = True
 self.have_curses = True
 self.initialize_event = None
Index: lldb/trunk/packages/Python/lldbsuite/test_event/formatter/__init__.py
===
--- lldb/trunk/packages/Python/lldbsuite/test_event/formatter/__init__.py
+++ lldb/trunk/packages/Python/lldbsuite/test_event/formatter/__init__.py
@@ -24,7 +24,6 @@
 
 def __init__(self):
 self.filename = None
-self.port = None
 self.formatter_name = None
 self.formatter_options = None
 
@@ -48,43 +47,10 @@
 @return an instance of CreatedFormatter.
 """
 
-def create_socket(port):
-"""Creates a socket to the localhost on the given port.
-
-@param port the port number of the listening port on
-the localhost.
-
-@return (socket object, socket closing function)
-"""
-
-def socket_closer(open_sock):
-"""Close down an opened socket properly."""
-open_sock.shutdown(socket.SHUT_RDWR)
-open_sock.close()
-
-sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-sock.connect(("localhost", port))
-
-# Wait for the ack from the listener side.
-# This is needed to prevent a race condition
-# in the main dosep.py processing loop: we
-# can't allow a worker queue thread to die
-# that has outstanding messages to a listener
-# socket before the listener socket asyncore
-# listener socket gets spun up; otherwise,
-# we lose the test result info.
-read_bytes = sock.recv(1)
-if read_bytes is None or (len(read_bytes) < 1) or (read_bytes != b'*'):
-raise Exception(
-"listening socket did not respond with ack byte: response={}".format(read_bytes))
-
-return sock, lambda: socket_closer(sock)
-
 default_formatter_name = None
 results_file_object = None
 cleanup_func = None
 
-file_is_stream = False
 if config.filename:
 # Open the results file for writing.
 if config.filename == 'stdout':
@@ -98,12 +64,6 @@
 cleanup_func = results_file_object.close
 default_formatter_name = (
 "lldbsuite.test_even

[Lldb-commits] [PATCH] D65677: [VirtualFileSystem] Support encoding working directories in a VFS mapping.

2019-08-27 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 217487.
JDevlieghere retitled this revision from "[VirtualFileSystem] Support encoding 
a current working directory in a VFS mapping." to "[VirtualFileSystem] Support 
encoding working directories in a VFS mapping.".
JDevlieghere added a comment.

Support multiple working directories.


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

https://reviews.llvm.org/D65677

Files:
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1994,3 +1994,108 @@
   EXPECT_EQ(FS->getRealPath("/non_existing", RealPath),
 errc::no_such_file_or_directory);
 }
+
+TEST_F(VFSFromYAMLTest, WorkingDirectoriesOneMatch) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addDirectory("//root/");
+  Lower->addDirectory("//root/foo");
+  Lower->addRegularFile("//root/foo/a");
+  Lower->addRegularFile("//root/foo/b");
+  IntrusiveRefCntPtr FS = getFromYAMLString(
+  "{ 'use-external-names': false,\n"
+  "  'working-directories': ['//root/quux/', '//root/bar']\n"
+  "  'roots': [\n"
+  "{\n"
+  "  'type': 'directory',\n"
+  "  'name': '//root/',\n"
+  "  'contents': [ {\n"
+  "  'type': 'file',\n"
+  "  'name': 'bar/a',\n"
+  "  'external-contents': '//root/foo/a'\n"
+  "}\n"
+  "  ]\n"
+  "}\n"
+  "]\n"
+  "}",
+  Lower);
+  ASSERT_TRUE(FS.get() != nullptr);
+
+  llvm::ErrorOr Status = FS->status("./a");
+  ASSERT_FALSE(Status.getError());
+  EXPECT_TRUE(Status->isStatusKnown());
+  EXPECT_FALSE(Status->isDirectory());
+  EXPECT_TRUE(Status->isRegularFile());
+  EXPECT_FALSE(Status->isSymlink());
+  EXPECT_FALSE(Status->isOther());
+  EXPECT_TRUE(Status->exists());
+}
+
+TEST_F(VFSFromYAMLTest, WorkingDirectoriesNoMatch) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addDirectory("//root/");
+  Lower->addDirectory("//root/foo");
+  Lower->addRegularFile("//root/foo/a");
+  Lower->addRegularFile("//root/foo/b");
+  IntrusiveRefCntPtr FS = getFromYAMLString(
+  "{ 'use-external-names': false,\n"
+  "  'working-directories': ['//root/foo/', '//root/quux/']\n"
+  "  'roots': [\n"
+  "{\n"
+  "  'type': 'directory',\n"
+  "  'name': '//root/',\n"
+  "  'contents': [ {\n"
+  "  'type': 'file',\n"
+  "  'name': 'bar/a',\n"
+  "  'external-contents': '//root/foo/a'\n"
+  "}\n"
+  "  ]\n"
+  "}\n"
+  "]\n"
+  "}",
+  Lower);
+  ASSERT_TRUE(FS.get() != nullptr);
+
+  llvm::ErrorOr Status = FS->status("./a");
+  ASSERT_TRUE(Status.getError());
+}
+
+TEST_F(VFSFromYAMLTest, WorkingDirectoriesMultipleMatches) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addDirectory("//root/");
+  Lower->addDirectory("//root/foo");
+  Lower->addRegularFile("//root/foo/a", sys::fs::owner_read);
+  Lower->addRegularFile("//root/foo/b", sys::fs::owner_write);
+  IntrusiveRefCntPtr FS = getFromYAMLString(
+  "{ 'use-external-names': false,\n"
+  "  'working-directories': ['//root/bar/', '//root/baz/']\n"
+  "  'roots': [\n"
+  "{\n"
+  "  'type': 'directory',\n"
+  "  'name': '//root/',\n"
+  "  'contents': [ {\n"
+  "  'type': 'file',\n"
+  "  'name': 'bar/a',\n"
+  "  'external-contents': '//root/foo/a'\n"
+  "},\n"
+  "{\n"
+  "  'type': 'file',\n"
+  "  'name': 'bar/a',\n"
+  "  'external-contents': '//root/foo/b'\n"
+  "}\n"
+  "  ]\n"
+  "}\n"
+  "]\n"
+  "}",
+  Lower);
+  ASSERT_TRUE(FS.get() != nullptr);
+
+  llvm::ErrorOr Status = FS->status("./a");
+  ASSERT_FALSE(Status.getError());
+  EXPECT_TRUE(Status->isStatusKnown());
+  EXPECT_FALSE(Status->isDirectory());
+  EXPECT_TRUE(Status->isRegularFile());
+  EXPECT_FALSE(Status->isSymlink());
+  EXPECT_FALSE(Status->isOther());
+  EXPECT_TRUE(Status->exists());
+  EXPECT_EQ(Status->getPermissions(), sys::fs::owner_read);
+}
Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -1043,6 +1043,10 @@
   return ExternalFS->setCurrentWorkingDirectory(Path);
 }
 
+void RedirectingFileSystem::addWorkingDirectory(const Twine &Path) {
+  WorkingDirs.push_back(Path.str());
+}
+
 std::error_code RedirectingFileSystem::isLocal(const T

[Lldb-commits] [lldb] r370120 - [dotest] Remove check for LLDB_TESTSUITE_FORCE_FINISH

2019-08-27 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Tue Aug 27 14:59:24 2019
New Revision: 370120

URL: http://llvm.org/viewvc/llvm-project?rev=370120&view=rev
Log:
[dotest] Remove check for LLDB_TESTSUITE_FORCE_FINISH

Modified:
lldb/trunk/packages/Python/lldbsuite/test/dotest.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=370120&r1=370119&r2=370120&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Tue Aug 27 14:59:24 2019
@@ -1338,12 +1338,6 @@ def run_suite():
 "%s - %d\n" %
 (category, configuration.failuresPerCategory[category]))
 
-# Terminate the test suite if ${LLDB_TESTSUITE_FORCE_FINISH} is defined.
-# This should not be necessary now.
-if ("LLDB_TESTSUITE_FORCE_FINISH" in os.environ):
-print("Terminating Test suite...")
-subprocess.Popen(["/bin/sh", "-c", "kill %s; exit 0" % (os.getpid())])
-
 # Exiting.
 exitTestSuite(configuration.failed)
 


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


[Lldb-commits] [PATCH] D66837: [dotest] Remove -q (quiet) flag.

2019-08-27 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: LLDB.
Herald added a subscriber: teemperor.
Herald added a project: LLDB.

I propose removing the `-q` (quiet) flag and changing the default behavior. 
Currently the flag serves two purposes that are somewhat contradictory, as 
illustrated by the difference between the argument name (quiet) and the 
configuration flag (parsable). On the one hand it reduces output, but on the 
other hand it prints more output, like the result of individual tests. My 
proposal is to guard the extra output behind the verbose flag and always print 
the individual test results.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D66837

Files:
  lldb/docs/resources/test.rst
  lldb/lit/Suite/lit.cfg
  lldb/packages/Python/lldbsuite/test/configuration.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/dotest_args.py
  lldb/packages/Python/lldbsuite/test/test_result.py
  lldb/utils/lldb-dotest/lldb-dotest.in

Index: lldb/utils/lldb-dotest/lldb-dotest.in
===
--- lldb/utils/lldb-dotest/lldb-dotest.in
+++ lldb/utils/lldb-dotest/lldb-dotest.in
@@ -9,7 +9,7 @@
 wrapper_args = sys.argv[1:]
 dotest_args = dotest_args_str.split(';')
 # Build dotest.py command.
-cmd = [sys.executable, dotest_path, '-q']
+cmd = [sys.executable, dotest_path]
 cmd.extend(dotest_args)
 cmd.extend(wrapper_args)
 # Invoke dotest.py and return exit code.
Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -180,10 +180,9 @@
 return
 
 super(LLDBTestResult, self).addSuccess(test)
-if configuration.parsable:
-self.stream.write(
-"PASS: LLDB (%s) :: %s\n" %
-(self._config_string(test), str(test)))
+self.stream.write(
+"PASS: LLDB (%s) :: %s\n" %
+(self._config_string(test), str(test)))
 if self.results_formatter:
 self.results_formatter.handle_event(
 EventBuilder.event_for_success(test))
@@ -220,10 +219,9 @@
 method = getattr(test, "markError", None)
 if method:
 method()
-if configuration.parsable:
-self.stream.write(
-"FAIL: LLDB (%s) :: %s\n" %
-(self._config_string(test), str(test)))
+self.stream.write(
+"FAIL: LLDB (%s) :: %s\n" %
+(self._config_string(test), str(test)))
 if self.results_formatter:
 # Handle build errors as a separate event type
 if self._isBuildError(err):
@@ -238,10 +236,9 @@
 method = getattr(test, "markCleanupError", None)
 if method:
 method()
-if configuration.parsable:
-self.stream.write(
-"CLEANUP ERROR: LLDB (%s) :: %s\n" %
-(self._config_string(test), str(test)))
+self.stream.write(
+"CLEANUP ERROR: LLDB (%s) :: %s\n" %
+(self._config_string(test), str(test)))
 if self.results_formatter:
 self.results_formatter.handle_event(
 EventBuilder.event_for_cleanup_error(
@@ -258,10 +255,9 @@
 method = getattr(test, "markFailure", None)
 if method:
 method()
-if configuration.parsable:
-self.stream.write(
-"FAIL: LLDB (%s) :: %s\n" %
-(self._config_string(test), str(test)))
+self.stream.write(
+"FAIL: LLDB (%s) :: %s\n" %
+(self._config_string(test), str(test)))
 if configuration.useCategories:
 test_categories = self.getCategoriesForTest(test)
 for category in test_categories:
@@ -280,10 +276,9 @@
 method = getattr(test, "markExpectedFailure", None)
 if method:
 method(err, bugnumber)
-if configuration.parsable:
-self.stream.write(
-"XFAIL: LLDB (%s) :: %s\n" %
-(self._config_string(test), str(test)))
+self.stream.write(
+"XFAIL: LLDB (%s) :: %s\n" %
+(self._config_string(test), str(test)))
 if self.results_formatter:
 self.results_formatter.handle_event(
 EventBuilder.event_for_expected_failure(
@@ -295,10 +290,9 @@
 method = getattr(test, "markSkippedTest", None)
 if method:
 method()
-if configuration.parsable:
-self.stream.write(
-"UNSUPPORTED: LLDB (%s) :: %s (%s) \n" %
-(self._config_string(test), str(test), reason))
+self.stream.write(
+"UNSUPPORTED: LLDB (%s) :: %s (%s) \n" %
+(self._config_string(test), str(test), reason))
 

[Lldb-commits] [lldb] r370126 - Revert "[lldb] Move redundant persistent variable counter to ClangPersistentVariables"

2019-08-27 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Tue Aug 27 15:50:40 2019
New Revision: 370126

URL: http://llvm.org/viewvc/llvm-project?rev=370126&view=rev
Log:
Revert "[lldb] Move redundant persistent variable counter to 
ClangPersistentVariables"

This reverts commit r367842 since it wasn't quite as NFC as advertised
and broke Swift support.  See https://reviews.llvm.org/D46083 for the
rationale behind the original functionality.

rdar://problem/54619322

Modified:
lldb/trunk/include/lldb/Expression/ExpressionVariable.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/source/Expression/ExpressionVariable.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h

Modified: lldb/trunk/include/lldb/Expression/ExpressionVariable.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ExpressionVariable.h?rev=370126&r1=370125&r2=370126&view=diff
==
--- lldb/trunk/include/lldb/Expression/ExpressionVariable.h (original)
+++ lldb/trunk/include/lldb/Expression/ExpressionVariable.h Tue Aug 27 15:50:40 
2019
@@ -223,8 +223,8 @@ public:
uint32_t addr_byte_size) = 0;
 
   /// Return a new persistent variable name with the specified prefix.
-  virtual ConstString GetNextPersistentVariableName(Target &target,
-llvm::StringRef prefix) = 
0;
+  ConstString GetNextPersistentVariableName(Target &target,
+llvm::StringRef prefix);
 
   virtual llvm::StringRef
   GetPersistentVariablePrefix(bool is_error = false) const = 0;

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=370126&r1=370125&r2=370126&view=diff
==
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Tue Aug 27 15:50:40 2019
@@ -1106,6 +1106,11 @@ public:
 
   lldb::ExpressionVariableSP GetPersistentVariable(ConstString name);
 
+  /// Return the next available number for numbered persistent variables.
+  unsigned GetNextPersistentVariableIndex() {
+return m_next_persistent_variable_index++;
+  }
+
   lldb::addr_t GetPersistentSymbol(ConstString name);
 
   /// This method will return the address of the starting function for
@@ -1315,6 +1320,7 @@ protected:
   bool m_valid;
   bool m_suppress_stop_hooks;
   bool m_is_dummy_target;
+  unsigned m_next_persistent_variable_index = 0;
 
   static void ImageSearchPathsChanged(const PathMappingList &path_list,
   void *baton);

Modified: lldb/trunk/source/Expression/ExpressionVariable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ExpressionVariable.cpp?rev=370126&r1=370125&r2=370126&view=diff
==
--- lldb/trunk/source/Expression/ExpressionVariable.cpp (original)
+++ lldb/trunk/source/Expression/ExpressionVariable.cpp Tue Aug 27 15:50:40 2019
@@ -76,3 +76,13 @@ void PersistentExpressionState::Register
 }
   }
 }
+
+ConstString PersistentExpressionState::GetNextPersistentVariableName(
+Target &target, llvm::StringRef Prefix) {
+  llvm::SmallString<64> name;
+  {
+llvm::raw_svector_ostream os(name);
+os << Prefix << target.GetNextPersistentVariableIndex();
+  }
+  return ConstString(name);
+}

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h?rev=370126&r1=370125&r2=370126&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h 
Tue Aug 27 15:50:40 2019
@@ -46,16 +46,6 @@ public:
 
   void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override;
 
-  ConstString GetNextPersistentVariableName(Target &target,
-llvm::StringRef prefix) override {
-llvm::SmallString<64> name;
-{
-  llvm::raw_svector_ostream os(name);
-  os << prefix << m_next_persistent_variable_id++;
-}
-return ConstString(name);
-  }
-
   llvm::StringRef GetPersistentVariablePrefix(bool is_error) const override {
 return "$";
   }


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


[Lldb-commits] [PATCH] D66837: [dotest] Remove -q (quiet) flag.

2019-08-27 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

LGTM


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D66837



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


[Lldb-commits] [PATCH] D66841: Skip test_target_create_invalid_core_file on Windows

2019-08-27 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth created this revision.
amccarth added a reviewer: teemperor.

The operation is supposed to fail, but apparently it fails on Windows for a 
different reason than the test anticipated.


https://reviews.llvm.org/D66841

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py


Index: 
lldb/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py
===
--- 
lldb/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py
+++ 
lldb/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py
@@ -341,6 +341,7 @@
 self.expect("target create -s doesntexist doesntexisteither", 
error=True,
 substrs=["invalid symbol file path 'doesntexist'"])
 
+@skipIfWindows
 @no_debug_info_test
 def test_target_create_invalid_core_file(self):
 invalid_core_path = os.path.join(self.getSourceDir(), 
"invalid_core_file")


Index: lldb/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py
@@ -341,6 +341,7 @@
 self.expect("target create -s doesntexist doesntexisteither", error=True,
 substrs=["invalid symbol file path 'doesntexist'"])
 
+@skipIfWindows
 @no_debug_info_test
 def test_target_create_invalid_core_file(self):
 invalid_core_path = os.path.join(self.getSourceDir(), "invalid_core_file")
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D66845: [lit] Don't set DYLD_LIBRARY_PATH when DYLD_INSERT_LIBRARIES is set.

2019-08-27 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: aprantl, mgorny.
Herald added a subscriber: abidh.
Herald added a project: LLDB.

Setting `DYLD_INSERT_LIBRARIES` to the Asan runtime and `DYLD_LIBRARY_PATH ` to 
the LLVM shared library dir causes the test suite to crash with a segfault. We 
see this on the LLDB sanitized bot [1] on GreenDragon. I've spent some time 
investigating, but I'm not sure what's going on (yet).

Originally I thought this was because we were building compiler-rt and were 
loading an incompatible, just-built Asan library. However, the issue persists 
even without compiler-rt. It doesn't look like the Asan runtime is opening any 
other libraries that might be found in LLVM's shared library dir and talking to 
the team confirms that. Another possible explanation is that we're loading lldb 
form a place we don't expect, but that doesn't make sense either, because 
`DYLD_LIBRARY_PATH` is always set without the crash. I tried different Python 
versions and interpreters but the issue persist.

As a (temporary?) workaround I propose not setting `DYLD_LIBRARY_PATH` when 
`DYLD_INSERT_LIBRARIES` is set so we can turn the Asan bot on again and get 
useful results.

[1] http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-sanitized/


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D66845

Files:
  lldb/lit/Suite/lit.cfg


Index: lldb/lit/Suite/lit.cfg
===
--- lldb/lit/Suite/lit.cfg
+++ lldb/lit/Suite/lit.cfg
@@ -31,7 +31,6 @@
'libclang_rt.asan_osx_dynamic.dylib')
 config.environment['DYLD_INSERT_LIBRARIES'] = runtime
 
-# Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
 def find_shlibpath_var():
   if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']:
 yield 'LD_LIBRARY_PATH'
@@ -40,18 +39,21 @@
   elif platform.system() == 'Windows':
 yield 'PATH'
 
-for shlibpath_var in find_shlibpath_var():
-  # In stand-alone build llvm_shlib_dir specifies LLDB's lib directory
-  # while llvm_libs_dir specifies LLVM's lib directory.
-  shlibpath = os.path.pathsep.join(
-(config.llvm_shlib_dir,
- config.llvm_libs_dir,
- config.environment.get(shlibpath_var, '')))
-  config.environment[shlibpath_var] = shlibpath
-  break
-else:
-  lit_config.warning("unable to inject shared library path on '{}'"
- .format(platform.system()))
+if not config.environment['DYLD_INSERT_LIBRARIES']:
+  # Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
+  # This clashes with DYLD_INSERT_LIBRARIES which is needed on Darwin.
+  for shlibpath_var in find_shlibpath_var():
+# In stand-alone build llvm_shlib_dir specifies LLDB's lib directory while
+# llvm_libs_dir specifies LLVM's lib directory.
+shlibpath = os.path.pathsep.join(
+  (config.llvm_shlib_dir,
+  config.llvm_libs_dir,
+  config.environment.get(shlibpath_var, '')))
+config.environment[shlibpath_var] = shlibpath
+break
+  else:
+lit_config.warning("unable to inject shared library path on '{}'"
+  .format(platform.system()))
 
 # Build dotest command.
 dotest_cmd = [config.dotest_path, '-q']


Index: lldb/lit/Suite/lit.cfg
===
--- lldb/lit/Suite/lit.cfg
+++ lldb/lit/Suite/lit.cfg
@@ -31,7 +31,6 @@
'libclang_rt.asan_osx_dynamic.dylib')
 config.environment['DYLD_INSERT_LIBRARIES'] = runtime
 
-# Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
 def find_shlibpath_var():
   if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']:
 yield 'LD_LIBRARY_PATH'
@@ -40,18 +39,21 @@
   elif platform.system() == 'Windows':
 yield 'PATH'
 
-for shlibpath_var in find_shlibpath_var():
-  # In stand-alone build llvm_shlib_dir specifies LLDB's lib directory
-  # while llvm_libs_dir specifies LLVM's lib directory.
-  shlibpath = os.path.pathsep.join(
-(config.llvm_shlib_dir,
- config.llvm_libs_dir,
- config.environment.get(shlibpath_var, '')))
-  config.environment[shlibpath_var] = shlibpath
-  break
-else:
-  lit_config.warning("unable to inject shared library path on '{}'"
- .format(platform.system()))
+if not config.environment['DYLD_INSERT_LIBRARIES']:
+  # Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
+  # This clashes with DYLD_INSERT_LIBRARIES which is needed on Darwin.
+  for shlibpath_var in find_shlibpath_var():
+# In stand-alone build llvm_shlib_dir specifies LLDB's lib directory while
+# llvm_libs_dir specifies LLVM's lib directory.
+shlibpath = os.path.pathsep.join(
+  (config.llvm_shlib_dir,
+  config.llvm_libs_dir,
+  config.environment.get(shlibpath_var, '')))
+config.environment[shlibpath_var] = shlibpath
+break
+  else:
+lit_config.warning("unable to inject shared library path on '{

[Lldb-commits] [PATCH] D66845: [lit] Don't set DYLD_LIBRARY_PATH when DYLD_INSERT_LIBRARIES is set.

2019-08-27 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

It's a hack, but it's a well-documented one.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D66845



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


[Lldb-commits] [PATCH] D66634: Postfix: move more code out of the PDB plugin

2019-08-27 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added a comment.

When I added my comments, Phabricator showed this patch as still open.  Now it 
looks like it landed four hours before that. :-(


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66634



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


[Lldb-commits] [lldb] r370135 - [lit] Don't set DYLD_LIBRARY_PATH when DYLD_INSERT_LIBRARIES is set.

2019-08-27 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Tue Aug 27 17:32:19 2019
New Revision: 370135

URL: http://llvm.org/viewvc/llvm-project?rev=370135&view=rev
Log:
[lit] Don't set DYLD_LIBRARY_PATH when DYLD_INSERT_LIBRARIES is set.

Setting DYLD_INSERT_LIBRARIES to the Asan runtime and DYLD_LIBRARY_PATH
to the LLVM shared library dir causes the test suite to crash with a
segfault. We see this on the LLDB sanitized bot [1] on GreenDragon. I've
spent some time investigating, but I'm not sure what's going on (yet).

Originally I thought this was because we were building compiler-rt and
were loading an incompatible, just-built Asan library. However, the
issue persists even without compiler-rt. It doesn't look like the Asan
runtime is opening any other libraries that might be found in LLVM's
shared library dir and talking to the team confirms that. Another
possible explanation is that we're loading lldb form a place we don't
expect, but that doesn't make sense either, because DYLD_LIBRARY_PATH is
always set without the crash. I tried different Python versions and
interpreters but the issue persist.

As a (temporary?) workaround I propose not setting DYLD_LIBRARY_PATH
when DYLD_INSERT_LIBRARIES is set so we can turn the Asan bot on again
and get useful results.

[1] http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-sanitized/

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

Modified:
lldb/trunk/lit/Suite/lit.cfg

Modified: lldb/trunk/lit/Suite/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Suite/lit.cfg?rev=370135&r1=370134&r2=370135&view=diff
==
--- lldb/trunk/lit/Suite/lit.cfg (original)
+++ lldb/trunk/lit/Suite/lit.cfg Tue Aug 27 17:32:19 2019
@@ -31,7 +31,6 @@ if 'Address' in config.llvm_use_sanitize
'libclang_rt.asan_osx_dynamic.dylib')
 config.environment['DYLD_INSERT_LIBRARIES'] = runtime
 
-# Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
 def find_shlibpath_var():
   if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']:
 yield 'LD_LIBRARY_PATH'
@@ -40,18 +39,21 @@ def find_shlibpath_var():
   elif platform.system() == 'Windows':
 yield 'PATH'
 
-for shlibpath_var in find_shlibpath_var():
-  # In stand-alone build llvm_shlib_dir specifies LLDB's lib directory
-  # while llvm_libs_dir specifies LLVM's lib directory.
-  shlibpath = os.path.pathsep.join(
-(config.llvm_shlib_dir,
- config.llvm_libs_dir,
- config.environment.get(shlibpath_var, '')))
-  config.environment[shlibpath_var] = shlibpath
-  break
-else:
-  lit_config.warning("unable to inject shared library path on '{}'"
- .format(platform.system()))
+if not config.environment['DYLD_INSERT_LIBRARIES']:
+  # Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
+  # This clashes with DYLD_INSERT_LIBRARIES which is needed on Darwin.
+  for shlibpath_var in find_shlibpath_var():
+# In stand-alone build llvm_shlib_dir specifies LLDB's lib directory while
+# llvm_libs_dir specifies LLVM's lib directory.
+shlibpath = os.path.pathsep.join(
+  (config.llvm_shlib_dir,
+  config.llvm_libs_dir,
+  config.environment.get(shlibpath_var, '')))
+config.environment[shlibpath_var] = shlibpath
+break
+  else:
+lit_config.warning("unable to inject shared library path on '{}'"
+  .format(platform.system()))
 
 # Build dotest command.
 dotest_cmd = [config.dotest_path, '-q']


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


[Lldb-commits] [PATCH] D66845: [lit] Don't set DYLD_LIBRARY_PATH when DYLD_INSERT_LIBRARIES is set.

2019-08-27 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370135: [lit] Don't set DYLD_LIBRARY_PATH when 
DYLD_INSERT_LIBRARIES is set. (authored by JDevlieghere, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66845?vs=217524&id=217539#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66845

Files:
  lldb/trunk/lit/Suite/lit.cfg


Index: lldb/trunk/lit/Suite/lit.cfg
===
--- lldb/trunk/lit/Suite/lit.cfg
+++ lldb/trunk/lit/Suite/lit.cfg
@@ -31,7 +31,6 @@
'libclang_rt.asan_osx_dynamic.dylib')
 config.environment['DYLD_INSERT_LIBRARIES'] = runtime
 
-# Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
 def find_shlibpath_var():
   if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']:
 yield 'LD_LIBRARY_PATH'
@@ -40,18 +39,21 @@
   elif platform.system() == 'Windows':
 yield 'PATH'
 
-for shlibpath_var in find_shlibpath_var():
-  # In stand-alone build llvm_shlib_dir specifies LLDB's lib directory
-  # while llvm_libs_dir specifies LLVM's lib directory.
-  shlibpath = os.path.pathsep.join(
-(config.llvm_shlib_dir,
- config.llvm_libs_dir,
- config.environment.get(shlibpath_var, '')))
-  config.environment[shlibpath_var] = shlibpath
-  break
-else:
-  lit_config.warning("unable to inject shared library path on '{}'"
- .format(platform.system()))
+if not config.environment['DYLD_INSERT_LIBRARIES']:
+  # Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
+  # This clashes with DYLD_INSERT_LIBRARIES which is needed on Darwin.
+  for shlibpath_var in find_shlibpath_var():
+# In stand-alone build llvm_shlib_dir specifies LLDB's lib directory while
+# llvm_libs_dir specifies LLVM's lib directory.
+shlibpath = os.path.pathsep.join(
+  (config.llvm_shlib_dir,
+  config.llvm_libs_dir,
+  config.environment.get(shlibpath_var, '')))
+config.environment[shlibpath_var] = shlibpath
+break
+  else:
+lit_config.warning("unable to inject shared library path on '{}'"
+  .format(platform.system()))
 
 # Build dotest command.
 dotest_cmd = [config.dotest_path, '-q']


Index: lldb/trunk/lit/Suite/lit.cfg
===
--- lldb/trunk/lit/Suite/lit.cfg
+++ lldb/trunk/lit/Suite/lit.cfg
@@ -31,7 +31,6 @@
'libclang_rt.asan_osx_dynamic.dylib')
 config.environment['DYLD_INSERT_LIBRARIES'] = runtime
 
-# Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
 def find_shlibpath_var():
   if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']:
 yield 'LD_LIBRARY_PATH'
@@ -40,18 +39,21 @@
   elif platform.system() == 'Windows':
 yield 'PATH'
 
-for shlibpath_var in find_shlibpath_var():
-  # In stand-alone build llvm_shlib_dir specifies LLDB's lib directory
-  # while llvm_libs_dir specifies LLVM's lib directory.
-  shlibpath = os.path.pathsep.join(
-(config.llvm_shlib_dir,
- config.llvm_libs_dir,
- config.environment.get(shlibpath_var, '')))
-  config.environment[shlibpath_var] = shlibpath
-  break
-else:
-  lit_config.warning("unable to inject shared library path on '{}'"
- .format(platform.system()))
+if not config.environment['DYLD_INSERT_LIBRARIES']:
+  # Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
+  # This clashes with DYLD_INSERT_LIBRARIES which is needed on Darwin.
+  for shlibpath_var in find_shlibpath_var():
+# In stand-alone build llvm_shlib_dir specifies LLDB's lib directory while
+# llvm_libs_dir specifies LLVM's lib directory.
+shlibpath = os.path.pathsep.join(
+  (config.llvm_shlib_dir,
+  config.llvm_libs_dir,
+  config.environment.get(shlibpath_var, '')))
+config.environment[shlibpath_var] = shlibpath
+break
+  else:
+lit_config.warning("unable to inject shared library path on '{}'"
+  .format(platform.system()))
 
 # Build dotest command.
 dotest_cmd = [config.dotest_path, '-q']
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r370136 - [test] Disable TestConcurrentManySignals on Darwin.

2019-08-27 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Tue Aug 27 17:35:37 2019
New Revision: 370136

URL: http://llvm.org/viewvc/llvm-project?rev=370136&view=rev
Log:
[test] Disable TestConcurrentManySignals on Darwin.

This test is flaky on GreenDragon. Disable it until we figure out why.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManySignals.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManySignals.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManySignals.py?rev=370136&r1=370135&r2=370136&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManySignals.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManySignals.py
 Tue Aug 27 17:35:37 2019
@@ -14,6 +14,8 @@ class ConcurrentManySignals(ConcurrentEv
 
 # Atomic sequences are not supported yet for MIPS in LLDB.
 @skipIf(triple='^mips')
+# This test is flaky on Darwin.
+@skipIfDarwin
 def test(self):
 """Test 100 signals from 100 threads."""
 self.build(dictionary=self.getBuildFlags())


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


[Lldb-commits] [lldb] r370138 - [lit] Fix the way we check if an environment var is set

2019-08-27 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Tue Aug 27 17:52:08 2019
New Revision: 370138

URL: http://llvm.org/viewvc/llvm-project?rev=370138&view=rev
Log:
[lit] Fix the way we check if an environment var is set

The old method would throw a KeyError.

Modified:
lldb/trunk/lit/Suite/lit.cfg

Modified: lldb/trunk/lit/Suite/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Suite/lit.cfg?rev=370138&r1=370137&r2=370138&view=diff
==
--- lldb/trunk/lit/Suite/lit.cfg (original)
+++ lldb/trunk/lit/Suite/lit.cfg Tue Aug 27 17:52:08 2019
@@ -39,7 +39,7 @@ def find_shlibpath_var():
   elif platform.system() == 'Windows':
 yield 'PATH'
 
-if not config.environment['DYLD_INSERT_LIBRARIES']:
+if 'DYLD_INSERT_LIBRARIES' in os.environ:
   # Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
   # This clashes with DYLD_INSERT_LIBRARIES which is needed on Darwin.
   for shlibpath_var in find_shlibpath_var():


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


[Lldb-commits] [PATCH] D66858: POSIX DYLD: add workaround for android L loader

2019-08-27 Thread Saleem Abdulrasool via Phabricator via lldb-commits
compnerd created this revision.
compnerd added reviewers: davide, xiaobai.
Herald added subscribers: abidh, srhines.
Herald added a project: LLDB.

In certain cases, the loader does not report the base address of the DSO.
Attempt to infer it from the loaded address of the object file.  This was
originally added in the Swift fork of LLDB, this simply is upstreaming the
workaround for the system loader.  Unfortunately, without a recent test case, it
is difficult to construct a test case for this.  However, this problem is also
something which is worked around in the unwinder and has been seen multiple
times previously.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D66858

Files:
  source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp


Index: source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
===
--- source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -550,6 +550,18 @@

   UpdateBaseAddrIfNecessary(entry, file_path);

+  // On Android L (5.0, 5.1) the base address for the lirbary is sometimes not
+  // reported.  Attempt to discover it based on the load address of the object
+  // file.
+  if (entry.base_addr == 0) {
+lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
+bool is_loaded = false;
+Error error =
+m_process->GetFileLoadAddress(entry.file_spec, is_loaded, load_addr);
+if (error.Success() && is_loaded)
+  entry.base_addr = load_addr;
+  }
+
   return true;
 }



Index: source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
===
--- source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -550,6 +550,18 @@

   UpdateBaseAddrIfNecessary(entry, file_path);

+  // On Android L (5.0, 5.1) the base address for the lirbary is sometimes not
+  // reported.  Attempt to discover it based on the load address of the object
+  // file.
+  if (entry.base_addr == 0) {
+lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
+bool is_loaded = false;
+Error error =
+m_process->GetFileLoadAddress(entry.file_spec, is_loaded, load_addr);
+if (error.Success() && is_loaded)
+  entry.base_addr = load_addr;
+  }
+
   return true;
 }

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


[Lldb-commits] [lldb] r370152 - Update name of objc runtime SPI function we call for class names.

2019-08-27 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Tue Aug 27 19:14:07 2019
New Revision: 370152

URL: http://llvm.org/viewvc/llvm-project?rev=370152&view=rev
Log:
Update name of objc runtime SPI function we call for class names.

A new SPI was added to the objc runtime to get class names without
any demangling; AppleObjCRuntimeV2::ParseClassInfoArray was using
the original prototype name but had not been updated for the final
name yet, so lldb was falling back to the old function and doing
extra work for classes that were demangled.  This commit fixes that.


Modified:

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

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=370152&r1=370151&r2=370152&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 Tue Aug 27 19:14:07 2019
@@ -1601,7 +1601,7 @@ AppleObjCRuntimeV2::UpdateISAToDescripto
 // use that in our jitted expression.  Else fall back to the old
 // class_getName.
 static ConstString g_class_getName_symbol_name("class_getName");
-static ConstString g_class_getNameRaw_symbol_name("class_getNameRaw");
+static ConstString 
g_class_getNameRaw_symbol_name("objc_debug_class_getNameRaw");
 ConstString class_name_getter_function_name = g_class_getName_symbol_name;
 
 ObjCLanguageRuntime *objc_runtime = ObjCLanguageRuntime::Get(*process);


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