[Lldb-commits] [PATCH] D60654: Fix UNPREDICTABLE check in EmulateInstructionARM::EmulateADDRegShift

2019-04-15 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

I don't think I can provide a test for this because I don't really know the 
code so well (and generating an UNPREDICTABLE seems tricky too). I'll leave 
this up for a bit to see if someone comes up with a test (or I'll have time to 
dig into the code) and then commit.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60654



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


[Lldb-commits] [PATCH] D60667: Allow direct comparison of ConstString against StringRef

2019-04-15 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

LGTM.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60667



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


[Lldb-commits] [PATCH] D60667: Allow direct comparison of ConstString against StringRef

2019-04-15 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added a comment.

I, too, have some concern that this could have unintended side effects.  To 
make the temporary `StringRef`s from the zero-terminated strings requires a 
`strlen` call each time.  So we're making two passes over a string each time 
(once to measure and once to compare).  Granted, these are mostly very short.

Probably not (yet) practical, but I wonder if `ConstString::ConstString(const 
char *)` could be `constexpr` in the future or if the side effect of 
manipulating the string pool would always prohibit that.

I'd love to see the static const variables for the short constant strings, just 
to weigh readability hit.




Comment at: lldb/include/lldb/Utility/ConstString.h:173
+// StringRef doesn't. Therefore we have to do this check manually now.
+if (!m_string ^ !rhs.data())
+  return false;

This is very clever way to express the constraint, but it's quite a bit of 
cognitive load for the reader to figure out what's being tested here.  The 
comment sort of explains, but leaves it up to the reader to see how that maps 
to the condition.  (It also leaves me wondering whether it's useful to have 
ConstString treat empty strings and nullptr as distinct things.)

A simpler way to communicate the condition to humans might be:

if (m_string == nullptr && rhs.data() != nullptr) return false;
if (m_string != nullptr && rhs.data() == nullptr) return false;

The clever expression requires the reader to know or deduce:

1.  that `m_string` and `rhs.data()` are pointers,
2.  that `!p` is equivalent to `p != 0` and that the `0` will be implicitly 
converted to `nullptr`, yielding a `bool` that's `true` if `p` is a nullptr,
3.  that `^` is bitwise exclusive or,
4.  that boolean `!` and bitwise `^` have the appropriate operator precedence, 
which is not always obvious when mixing types like this,
5.  that `true` and `false` are guaranteed to have values such that bitwise `^` 
will do the expected thing to the promoted types,
6.  and that the resulting `int` will be implicitly compared for inequality to 
0.

Most of these are reasonable things to expect a C++ programmer to know, but 
expecting them to apply all of that knowledge (correctly) to figure out what 
the expression does seems like an unnecessarily high cognitive burden.



Comment at: lldb/source/Core/Disassembler.cpp:1407
 return (op.m_type == Instruction::Operand::Type::Register &&
-(op.m_register == ConstString(info.name) ||
- op.m_register == ConstString(info.alt_name)));
+(op.m_register == info.name || op.m_register == info.alt_name));
   };

This is _probably_ a performance win here, but it's not obvious.  If the 
resulting lambda is called many times, and it actually captured 
`ConstString(info.name)` and `ConstString(info.alt_name)` rather than 
`info.name` and `info.alt_name`, then we're trying off two pointer comparisons 
for two StringRef comparisons.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60667



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


[Lldb-commits] [PATCH] D60655: Fix typo in ArmUnwindInfo::GetUnwindPlan

2019-04-15 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.
This revision is now accepted and ready to land.

Agreed, this change is correct.  I double checked this in the 
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf 
doc (mod 24 Nov 2015) and the only difference in Section 9.3 "Frame unwinding 
instructions" Table 4 and this code is in the comment - they now refer to this 
as 'Pop VFP double-precision registers D[8]-D[8+nnn] saved (as if) by VPUSH 
(see remark d)'.   But there's no benefit in updating this one comment while 
the others are using the older comments (this code was originally written 
against the 30 Nov 2012 version of the doc).

We don't have any tests for the ARM.exidx exception handling information today, 
it would be take some work to add that.  It's a format like darwin's compact 
unwind or less correctly, eh_frame, only defined for 32-bit arm.  I would 
commit this obvious fix without a test.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60655



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


[Lldb-commits] [PATCH] D59667: Regression test to ensure that we handling importing of anonymous enums correctly

2019-04-15 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik updated this revision to Diff 195254.
shafik marked 3 inline comments as done.
shafik added a comment.

Small updated to test, remove use of `printf` and associated include.


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

https://reviews.llvm.org/D59667

Files:
  
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
  
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
  
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp


Index: 
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp
===
--- /dev/null
+++ 
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp
@@ -0,0 +1,9 @@
+typedef enum {
+A=0,
+} flow_e;
+
+int main() {
+   flow_e f;
+
+   return 0; // break here
+}
Index: 
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
===
--- /dev/null
+++ 
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
@@ -0,0 +1,22 @@
+"""
+Test Expression Parser regression text to ensure that we handle anonymous
+enums importing correctly.
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCastIntToAnonymousEnum(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test_cast_int_to_anonymous_enum(self):
+self.build()
+
+lldbutil.run_to_source_breakpoint(self, '// break here',
+lldb.SBFileSpec("main.cpp", False))
+
+self.expect("expr (flow_e)0", substrs=['(flow_e) $0 = A'])
Index: 
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
===
--- /dev/null
+++ 
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules


Index: packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp
===
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp
@@ -0,0 +1,9 @@
+typedef enum {
+A=0,
+} flow_e;
+
+int main() {
+   flow_e f;
+
+   return 0; // break here
+}
Index: packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
===
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
@@ -0,0 +1,22 @@
+"""
+Test Expression Parser regression text to ensure that we handle anonymous
+enums importing correctly.
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCastIntToAnonymousEnum(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test_cast_int_to_anonymous_enum(self):
+self.build()
+
+lldbutil.run_to_source_breakpoint(self, '// break here',
+lldb.SBFileSpec("main.cpp", False))
+
+self.expect("expr (flow_e)0", substrs=['(flow_e) $0 = A'])
Index: packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
===
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D59667: Regression test to ensure that we handling importing of anonymous enums correctly

2019-04-15 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: 
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp:8
+int main() {
+   flow_e f;
+

aprantl wrote:
> It looks like this variable is not actually used by the test?
I need the type in the test, so this forces the debug information to be 
generated.


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

https://reviews.llvm.org/D59667



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


[Lldb-commits] [PATCH] D59667: Regression test to ensure that we handling importing of anonymous enums correctly

2019-04-15 Thread Shafik Yaghmour via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358462: [ASTImporter] Regression test to ensure that we 
handling importing of anonymous… (authored by shafik, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59667?vs=195254&id=195266#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59667

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
  
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp


Index: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
@@ -0,0 +1,22 @@
+"""
+Test Expression Parser regression text to ensure that we handle anonymous
+enums importing correctly.
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCastIntToAnonymousEnum(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test_cast_int_to_anonymous_enum(self):
+self.build()
+
+lldbutil.run_to_source_breakpoint(self, '// break here',
+lldb.SBFileSpec("main.cpp", False))
+
+self.expect("expr (flow_e)0", substrs=['(flow_e) $0 = A'])
Index: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
Index: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp
@@ -0,0 +1,9 @@
+typedef enum {
+A=0,
+} flow_e;
+
+int main() {
+   flow_e f;
+
+   return 0; // break here
+}


Index: lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
@@ -0,0 +1,22 @@
+"""
+Test Expression Parser regression text to ensure that we handle anonymous
+enums importing correctly.
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCastIntToAnonymousEnum(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test_cast_int_to_anonymous_enum(self):
+self.build()
+
+lldbutil.run_to_source_breakpoint(self, '// break here',
+lldb.SBFileSpec("main.cpp", False))
+
+self.expect("expr (flow_e)0", substrs=['(flow_e) $0 = A'])
Index: lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
===
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
Index: lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp
===
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp
@@ -0,0 +1,9 @@
+typedef enum {
+A=0,
+} flow_e;
+
+int main() {
+   flow_e f;
+
+   return 0; // break here
+}
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.ll

[Lldb-commits] [lldb] r358462 - [ASTImporter] Regression test to ensure that we handling importing of anonymous enums correctly

2019-04-15 Thread Shafik Yaghmour via lldb-commits
Author: shafik
Date: Mon Apr 15 16:05:45 2019
New Revision: 358462

URL: http://llvm.org/viewvc/llvm-project?rev=358462&view=rev
Log:
[ASTImporter] Regression test to ensure that we handling importing of anonymous 
enums correctly

Summary:
https://reviews.llvm.org/D51633 added error handling in the ASTImporter.cpp 
which uncovered an underlying bug in which we used the wrong name when handling 
naming conflicts. This could cause a segmentation fault when attempting to cast 
an int to an enum during expression parsing.

This test should pass once https://reviews.llvm.org/D59665 is committed.

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

Added:

lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/

lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile

lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py

lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile?rev=358462&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
 Mon Apr 15 16:05:45 2019
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py?rev=358462&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
 Mon Apr 15 16:05:45 2019
@@ -0,0 +1,22 @@
+"""
+Test Expression Parser regression text to ensure that we handle anonymous
+enums importing correctly.
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCastIntToAnonymousEnum(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test_cast_int_to_anonymous_enum(self):
+self.build()
+
+lldbutil.run_to_source_breakpoint(self, '// break here',
+lldb.SBFileSpec("main.cpp", False))
+
+self.expect("expr (flow_e)0", substrs=['(flow_e) $0 = A'])

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp?rev=358462&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp
 Mon Apr 15 16:05:45 2019
@@ -0,0 +1,9 @@
+typedef enum {
+A=0,
+} flow_e;
+
+int main() {
+   flow_e f;
+
+   return 0; // break here
+}


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


[Lldb-commits] [PATCH] D60737: [lldb] Don't filter variable list when doing a lookup by mangled name in SymbolFileDWARF::FindGlobalVariables

2019-04-15 Thread Kuba (Brecka) Mracek via Phabricator via lldb-commits
kubamracek created this revision.
kubamracek added a reviewer: jingham.
kubamracek added a project: LLDB.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D60737

Files:
  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
@@ -2036,6 +2036,7 @@
 
   llvm::StringRef basename;
   llvm::StringRef context;
+  bool name_is_mangled = (bool)Mangled(name);
 
   if (!CPlusPlusLanguage::ExtractContextAndIdentifier(name.GetCString(),
   context, basename))
@@ -2085,7 +2086,8 @@
  &variables);
   while (pruned_idx < variables.GetSize()) {
 VariableSP var_sp = variables.GetVariableAtIndex(pruned_idx);
-if (var_sp->GetName().GetStringRef().contains(name.GetStringRef()))
+if (name_is_mangled ||
+var_sp->GetName().GetStringRef().contains(name.GetStringRef()))
   ++pruned_idx;
 else
   variables.RemoveVariableAtIndex(pruned_idx);


Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2036,6 +2036,7 @@
 
   llvm::StringRef basename;
   llvm::StringRef context;
+  bool name_is_mangled = (bool)Mangled(name);
 
   if (!CPlusPlusLanguage::ExtractContextAndIdentifier(name.GetCString(),
   context, basename))
@@ -2085,7 +2086,8 @@
  &variables);
   while (pruned_idx < variables.GetSize()) {
 VariableSP var_sp = variables.GetVariableAtIndex(pruned_idx);
-if (var_sp->GetName().GetStringRef().contains(name.GetStringRef()))
+if (name_is_mangled ||
+var_sp->GetName().GetStringRef().contains(name.GetStringRef()))
   ++pruned_idx;
 else
   variables.RemoveVariableAtIndex(pruned_idx);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D56229: [PECOFF] Implementation of ObjectFilePECOFF:: GetUUID()

2019-04-15 Thread Aaron Smith via Phabricator via lldb-commits
asmith updated this revision to Diff 195282.
asmith edited the summary of this revision.

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

https://reviews.llvm.org/D56229

Files:
  lit/Modules/PECOFF/export-dllfunc.yaml
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -286,6 +286,8 @@
   llvm::Optional m_deps_filespec;
   typedef llvm::object::OwningBinary OWNBINType;
   llvm::Optional m_owningbin;
+
+  lldb_private::UUID m_uuid;
 };
 
 #endif // liblldb_ObjectFilePECOFF_h_
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -40,6 +40,31 @@
 using namespace lldb;
 using namespace lldb_private;
 
+namespace {
+UUID GetCoffUUID(const FileSpec &file_spec) {
+  auto binary = llvm::object::createBinary(file_spec.GetPath());
+  if (!binary)
+return UUID();
+  if (!binary->getBinary()->isCOFF() &&
+  !binary->getBinary()->isCOFFImportFile())
+return UUID();
+
+  auto COFFObj =
+  llvm::dyn_cast(binary->getBinary());
+  if (!COFFObj)
+return UUID();
+
+  // Return PDB's GUID if any.
+  const llvm::codeview::DebugInfo *pdb_info = nullptr;
+  llvm::StringRef pdb_file;
+  if (!COFFObj->getDebugPDBInfo(pdb_info, pdb_file) && pdb_info)
+return UUID::fromOptionalData(pdb_info->PDB70.Signature);
+
+  return UUID();
+}
+
+} // namespace
+
 void ObjectFilePECOFF::Initialize() {
   PluginManager::RegisterPlugin(
   GetPluginNameStatic(), GetPluginDescriptionStatic(), CreateInstance,
@@ -128,18 +153,24 @@
   if (pe_signature != IMAGE_NT_SIGNATURE)
 return false;
   if (ParseCOFFHeader(data, &offset, coff_header)) {
-ArchSpec spec;
+ModuleSpec module_spec(file);
+ArchSpec &spec = module_spec.GetArchitecture();
+
+lldb_private::UUID &uuid = module_spec.GetUUID();
+if (!uuid.IsValid())
+  uuid = GetCoffUUID(file);
+
 if (coff_header.machine == MachineAmd64) {
   spec.SetTriple("x86_64-pc-windows");
-  specs.Append(ModuleSpec(file, spec));
+  specs.Append(module_spec);
 } else if (coff_header.machine == MachineX86) {
   spec.SetTriple("i386-pc-windows");
-  specs.Append(ModuleSpec(file, spec));
+  specs.Append(module_spec);
   spec.SetTriple("i686-pc-windows");
-  specs.Append(ModuleSpec(file, spec));
+  specs.Append(module_spec);
 } else if (coff_header.machine == MachineArmNt) {
   spec.SetTriple("arm-pc-windows");
-  specs.Append(ModuleSpec(file, spec));
+  specs.Append(module_spec);
 }
   }
 }
@@ -828,7 +859,13 @@
   }
 }
 
-UUID ObjectFilePECOFF::GetUUID() { return UUID(); }
+UUID ObjectFilePECOFF::GetUUID() {
+  if (m_uuid.IsValid())
+return m_uuid;
+
+  m_uuid = GetCoffUUID(GetFileSpec());
+  return m_uuid;
+}
 
 uint32_t ObjectFilePECOFF::ParseDependentModules() {
   ModuleSP module_sp(GetModule());
@@ -850,8 +887,7 @@
 static_cast(this), static_cast(module_sp.get()),
 module_sp->GetSpecificationDescription().c_str(),
 static_cast(m_owningbin.getPointer()),
-m_owningbin ? static_cast(m_owningbin->getBinary())
-: nullptr);
+static_cast(m_owningbin->getBinary()));
 
   auto COFFObj =
   llvm::dyn_cast(m_owningbin->getBinary());
@@ -912,7 +948,8 @@
   if (!section_list)
 m_entry_point_address.SetOffset(file_addr);
   else
-m_entry_point_address.ResolveAddressUsingFileSections(file_addr, section_list);
+m_entry_point_address.ResolveAddressUsingFileSections(file_addr,
+  section_list);
   return m_entry_point_address;
 }
 
Index: lit/Modules/PECOFF/export-dllfunc.yaml
===
--- lit/Modules/PECOFF/export-dllfunc.yaml
+++ lit/Modules/PECOFF/export-dllfunc.yaml
@@ -1,11 +1,15 @@
 # REQUIRES: system-windows
 # RUN: yaml2obj < %s > %t.obj
 #
-# RUN: lld-link /machine:x64 /out:%t.dll /noentry /nodefaultlib /dll %t.obj /export:DllFunc
+# RUN: lld-link /machine:x64 /out:%t.dll /noentry /nodefaultlib /debug /dll %t.obj /export:DllFunc
 #
 # RUN: lldb-test object-file %t.dll | FileCheck -check-prefix=BASIC-CHECK %s
 # RUN: lldb-test object-file -dep-modules %t.dll | FileCheck -check-prefix=DEPS %s
 
+# BASIC-CHECK: Plugin name: pe-coff
+
+# timestamp and build id of debug info in the coff header varies. So does its UUID.
+# BASIC-CHECK-DAG: UUID: {{[0-9A-F]{7,}[0-

[Lldb-commits] [PATCH] D60737: [lldb] Don't filter variable list when doing a lookup by mangled name in SymbolFileDWARF::FindGlobalVariables

2019-04-15 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

A test case?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60737



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