[Lldb-commits] [lldb] r331637 - Fix "file ./a.out" and file "../a.out" so that is works after recent FileSpec normalization path changes.

2018-05-07 Thread Greg Clayton via lldb-commits
Author: gclayton
Date: Mon May  7 07:21:04 2018
New Revision: 331637

URL: http://llvm.org/viewvc/llvm-project?rev=331637&view=rev
Log:
Fix "file ./a.out" and file "../a.out" so that is works after recent FileSpec 
normalization path changes.

Test coming soon, but I want to unbreak people.


Modified:
lldb/trunk/source/Target/TargetList.cpp

Modified: lldb/trunk/source/Target/TargetList.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=331637&r1=331636&r2=331637&view=diff
==
--- lldb/trunk/source/Target/TargetList.cpp (original)
+++ lldb/trunk/source/Target/TargetList.cpp Mon May  7 07:21:04 2018
@@ -367,16 +367,12 @@ Status TargetList::CreateTargetInternal(
   user_exe_path_is_bundle = true;
 
 if (file.IsRelative() && !user_exe_path.empty()) {
-  // Ignore paths that start with "./" and "../"
-  if (!user_exe_path.startswith("./") && !user_exe_path.startswith("../")) 
{
-llvm::SmallString<64> cwd;
-if (! llvm::sys::fs::current_path(cwd)) {
-  cwd += '/';
-  cwd += user_exe_path;
-  FileSpec cwd_file(cwd, false);
-  if (cwd_file.Exists())
-file = cwd_file;
-}
+  llvm::SmallString<64> cwd;
+  if (! llvm::sys::fs::current_path(cwd)) {
+FileSpec cwd_file(cwd.c_str(), false);
+cwd_file.AppendPathComponent(file);
+if (cwd_file.Exists())
+  file = cwd_file;
   }
 }
 


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


Re: [Lldb-commits] [lldb] r331082 - Fix build bots after r331049 broke them.

2018-05-07 Thread Greg Clayton via lldb-commits
Fixed with:

svn commit source/Target/TargetList.cpp
Sendingsource/Target/TargetList.cpp
Transmitting file data .done
Committing transaction...
Committed revision 331637.

Test coming soon.

> On May 4, 2018, at 10:55 AM, Davide Italiano  wrote:
> 
> On Fri, May 4, 2018 at 10:54 AM, Greg Clayton  wrote:
>> So it seems that if specify "./blah" as your program then this fails, but if 
>> you specify just "blah" then this succeeds. Looks like we need to resolve 
>> the path when creating a target with a local copy of the file. I will look 
>> into this.
>> 
>> Greg
>> 
> 
> Please take a look at this quickly today, as it's breaking a
> user-visible feature.
> 
> --
> Davide

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


[Lldb-commits] [PATCH] D46529: Add support to object files for accessing the .debug_types section

2018-05-07 Thread Greg Clayton via Phabricator via lldb-commits
clayborg created this revision.
clayborg added reviewers: labath, aprantl.
Herald added subscribers: JDevlieghere, arichardson, emaste.
Herald added a reviewer: espindola.

In an effort to make the .debug_types patch smaller, breaking out the part that 
reads the .debug_types from object files into a separate patch.


https://reviews.llvm.org/D46529

Files:
  include/lldb/lldb-enumerations.h
  source/Core/Section.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Symbol/ObjectFile.cpp

Index: source/Symbol/ObjectFile.cpp
===
--- source/Symbol/ObjectFile.cpp
+++ source/Symbol/ObjectFile.cpp
@@ -359,6 +359,7 @@
   case eSectionTypeDWARFDebugRanges:
   case eSectionTypeDWARFDebugStr:
   case eSectionTypeDWARFDebugStrOffsets:
+  case eSectionTypeDWARFDebugTypes:
   case eSectionTypeDWARFAppleNames:
   case eSectionTypeDWARFAppleTypes:
   case eSectionTypeDWARFAppleNamespaces:
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -246,6 +246,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_ranges_data();
   const lldb_private::DWARFDataExtractor &get_debug_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data();
+  const lldb_private::DWARFDataExtractor &get_debug_types_data();
   const lldb_private::DWARFDataExtractor &get_apple_names_data();
   const lldb_private::DWARFDataExtractor &get_apple_types_data();
   const lldb_private::DWARFDataExtractor &get_apple_namespaces_data();
@@ -492,6 +493,7 @@
   DWARFDataSegment m_data_debug_ranges;
   DWARFDataSegment m_data_debug_str;
   DWARFDataSegment m_data_debug_str_offsets;
+  DWARFDataSegment m_data_debug_types;
   DWARFDataSegment m_data_apple_names;
   DWARFDataSegment m_data_apple_types;
   DWARFDataSegment m_data_apple_namespaces;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -665,6 +665,10 @@
   m_data_debug_str_offsets);
 }
 
+const DWARFDataExtractor &SymbolFileDWARF::get_debug_types_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugTypes, m_data_debug_types);
+}
+
 const DWARFDataExtractor &SymbolFileDWARF::get_apple_names_data() {
   return GetCachedSectionData(eSectionTypeDWARFAppleNames, m_data_apple_names);
 }
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -696,6 +696,7 @@
 static ConstString g_sect_name_dwarf_debug_pubtypes(".debug_pubtypes");
 static ConstString g_sect_name_dwarf_debug_ranges(".debug_ranges");
 static ConstString g_sect_name_dwarf_debug_str(".debug_str");
+static ConstString g_sect_name_dwarf_debug_types(".debug_types");
 static ConstString g_sect_name_eh_frame(".eh_frame");
 static ConstString g_sect_name_go_symtab(".gosymtab");
 SectionType section_type = eSectionTypeOther;
@@ -744,6 +745,8 @@
   section_type = eSectionTypeDWARFDebugRanges;
 else if (const_sect_name == g_sect_name_dwarf_debug_str)
   section_type = eSectionTypeDWARFDebugStr;
+else if (const_sect_name == g_sect_name_dwarf_debug_types)
+  section_type = eSectionTypeDWARFDebugTypes;
 else if (const_sect_name == g_sect_name_eh_frame)
   section_type = eSectionTypeEHFrame;
 else if (const_sect_name == g_sect_name_go_symtab)
Index: source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1205,6 +1205,7 @@
   case eSectionTypeDWARFDebugRanges:
   case eSectionTypeDWARFDebugStr:
   case eSectionTypeDWARFDebugStrOffsets:
+  case eSectionTypeDWARFDebugTypes:
   case eSectionTypeDWARFAppleNames:
   case eSectionTypeDWARFAppleTypes:
   case eSectionTypeDWARFAppleNamespaces:
@@ -1458,6 +1459,7 @@
   static ConstString g_sect_name_dwarf_debug_pubtypes("__debug_pubtypes");
   static ConstString g_sect_name_dwarf_debug_ranges("__debug_ranges");
   static ConstString g_sect_name_dwarf_debug_str("__debug_str");
+  static ConstString g_sect_name

[Lldb-commits] [PATCH] D32167: Add support for type units (.debug_types) to LLDB in a way that is compatible with DWARF 5

2018-05-07 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In https://reviews.llvm.org/D32167#1087627, @labath wrote:

> Maybe we could start by splitting of the ObjectFile recognition code for the 
> debug_types section into a separate patch. That should be sufficiently 
> non-controversial and it would reduce the number of files touched by this 
> patch a bit.


I broke out the object file parsing code:

https://reviews.llvm.org/D46529


https://reviews.llvm.org/D32167



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


[Lldb-commits] [PATCH] D46548: Really test type lookup in TestCppTypeLookup.py

2018-05-07 Thread Frederic Riss via Phabricator via lldb-commits
friss created this revision.
friss added reviewers: clayborg, jingham.

... and fix one bug found this way. Currently, the test works not because
types are looked up correctly, but because by injecting local variables
we also materialize the types for Clang. If we disable the local variable
injection, then one check fails.

The reason of the failure is that FindTypes is run with max_matches==1
and this value is passed down to the symbol lookup functions. When the
search is performed only on the basename (like it's the case for an
entity defined in the root namespace), then the search will stop after
having found one match on the basename. But that match might be in a
namespace, we were really just looking up the basename in the accelerator
tables.

The solution is to not pass max_matches down, but to search without a
limit and let RemoveMismatchedTypes do its job afterwards. Note the
patch includes 2 hunks with the same change, but only the latter is
tested. I couldn't find a way to create a testcase for the other
branch of the if ('image lookup -t' allows me to get there, but it
only ever returns one type anyway).


https://reviews.llvm.org/D46548

Files:
  packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py
  source/Core/Module.cpp


Index: source/Core/Module.cpp
===
--- source/Core/Module.cpp
+++ source/Core/Module.cpp
@@ -997,6 +997,7 @@
   const bool append = true;
   TypeClass type_class = eTypeClassAny;
   TypeMap typesmap;
+
   if (Type::GetTypeScopeAndBasename(type_name_cstr, type_scope, type_basename,
 type_class)) {
 // Check if "name" starts with "::" which means the qualified type starts
@@ -1019,12 +1020,12 @@
   // The "type_name_cstr" will have been modified if we have a valid type
   // class prefix (like "struct", "class", "union", "typedef" etc).
   FindTypes_Impl(sc, ConstString(type_basename), nullptr, append,
- max_matches, searched_symbol_files, typesmap);
+ UINT_MAX, searched_symbol_files, typesmap);
   typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
  exact_match);
   num_matches = typesmap.GetSize();
 } else {
-  num_matches = FindTypes_Impl(sc, name, nullptr, append, max_matches,
+  num_matches = FindTypes_Impl(sc, name, nullptr, append, UINT_MAX,
searched_symbol_files, typesmap);
   if (exact_match) {
 std::string name_str(name.AsCString(""));
Index: packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py
===
--- packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py
+++ packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py
@@ -38,6 +38,11 @@
 # Get frame for current thread
 frame = thread.GetSelectedFrame()
 
+# We are testing LLDB's type lookup machinery, but if we inject local
+# variables, the types for those will be found because they have been
+# imported through the variable, not because the type lookup worked.
+self.runCmd("settings set target.experimental.inject-local-vars false")
+
 # Make sure we don't accidentally accept structures that exist only
 # in namespaces when evaluating expressions with top level types.
 # Prior to the revision that added this test, we would accidentally


Index: source/Core/Module.cpp
===
--- source/Core/Module.cpp
+++ source/Core/Module.cpp
@@ -997,6 +997,7 @@
   const bool append = true;
   TypeClass type_class = eTypeClassAny;
   TypeMap typesmap;
+
   if (Type::GetTypeScopeAndBasename(type_name_cstr, type_scope, type_basename,
 type_class)) {
 // Check if "name" starts with "::" which means the qualified type starts
@@ -1019,12 +1020,12 @@
   // The "type_name_cstr" will have been modified if we have a valid type
   // class prefix (like "struct", "class", "union", "typedef" etc).
   FindTypes_Impl(sc, ConstString(type_basename), nullptr, append,
- max_matches, searched_symbol_files, typesmap);
+ UINT_MAX, searched_symbol_files, typesmap);
   typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
  exact_match);
   num_matches = typesmap.GetSize();
 } else {
-  num_matches = FindTypes_Impl(sc, name, nullptr, append, max_matches,
+  num_matches = FindTypes_Impl(sc, name, nullptr, append, UINT_MAX,
searched_symbol_files, typesmap);
   if (exact_match) {
 std::string name_str(name.AsCString(""));
Index: packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py
==

[Lldb-commits] [PATCH] D46548: Really test type lookup in TestCppTypeLookup.py

2018-05-07 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

main problem with this approach is if the client tries to lookup 
"reference_type" as an example... It will end up pulling in and completing 
every STL type and returning the typedef only for us to weed this out.

Nothing we can do about this at the moment unless we make our 
SymbolFile::FindType() take some extra parameters where we can specify a decl 
content in an abstract way (like "at the tranlsation unit level, find me 
'reference_unit', or "in class A and in class B find 'reference_type'". For now 
we could try to specify a parent_decl_context that is the translation unit, but 
we would need to fix the lookup code to fill in the correct translation unit 
for each module.

So for now, this works and is our best solution, but there are many problems 
with out type lookup that do need to be fixed, but those will need to happen 
later.


https://reviews.llvm.org/D46548



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


[Lldb-commits] [RFC] Type lookup for template types is broken...

2018-05-07 Thread Frédéric Riss via lldb-commits
(...At least when using accelerator tables)

If you apply the following patch, TestClassTemplateParameterPack.py will start 
failing:
diff --git 
a/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp
 
b/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp
index 90e63b40f..304872a15 100644
--- 
a/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp
+++ 
b/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp
@@ -37,7 +37,7 @@ template <> struct D : D {
 
 int main (int argc, char const *argv[])
 {
-C myC;
+C myC; //% self.runCmd("settings set 
target.experimental.inject-local-vars false")
 C myLesserC;
 myC.member = 64;
 (void)C().isSixteenThirtyTwo();

The test does things like invoke methods on temporary template objects:
//% self.expect("expression -- C().isSixteenThirtyTwo()", 
DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"])

The above expression currently works because there’s a local of type C. With injected locals, the type is made readily available to Clang. No type 
lookup is required for this to work in this setup.

If you stop injecting locals, the test fails. We don’t provide the information 
to Clang to understand what C is. The reason is that when Clang parses “C”, it is going to ask about “C”, not the fully templated name. Our 
accelerator tables contain references to the full names, but not to C alone and 
we never find it. If I change Clang and dsymutil to add an accelerator for “C” 
each time an instance of C is seen then it nearly works. I just need this 
additional lldb patch:
diff --git a/source/Symbol/TypeMap.cpp b/source/Symbol/TypeMap.cpp
index 2838039ad..d2f2026bf 100644
--- a/source/Symbol/TypeMap.cpp
+++ b/source/Symbol/TypeMap.cpp
@@ -227,8 +227,11 @@ void TypeMap::RemoveMismatchedTypes(const std::string 
&type_scope,
   } else {
 // The type we are currently looking at doesn't exists in a namespace
 // or class, so it only matches if there is no type scope...
-keep_match =
-type_scope.empty() && type_basename.compare(match_type_name) == 0;
+if (type_scope.empty()) {
+  keep_match = type_basename.compare(match_type_name) == 0 ||
+(strlen(match_type_name) > type_basename.size() &&
+ match_type_name[type_basename.size()] == '<');
+}
   }
 }

I didn’t post this as a Phabricator review as it requires changes in llvm 
before doing anything in LLDB and I wanted to make sure we agree this is the 
right thing to do. I’m also not sure if this works out of the box on platforms 
without accelerator tables.

WDYT?

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


[Lldb-commits] [lldb] r331679 - Test Commit: fix a comment to be grammatically correct

2018-05-07 Thread Stella Stamenova via lldb-commits
Author: stella.stamenova
Date: Mon May  7 14:19:14 2018
New Revision: 331679

URL: http://llvm.org/viewvc/llvm-project?rev=331679&view=rev
Log:
Test Commit: fix a comment to be grammatically correct

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=331679&r1=331678&r2=331679&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Mon May  7 14:19:14 2018
@@ -1230,7 +1230,7 @@ def run_suite():
 checkLibcxxSupport()
 checkDebugInfoSupport()
 
-# Don't do debugserver tests on everything except OS X.
+# Don't do debugserver tests on anything except OS X.
 configuration.dont_do_debugserver_test = "linux" in target_platform or 
"freebsd" in target_platform or "windows" in target_platform
 
 # Don't do lldb-server (llgs) tests on anything except Linux.


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


[Lldb-commits] [PATCH] D46551: Inject only relevant local variables in the expression evaluation context

2018-05-07 Thread Frederic Riss via Phabricator via lldb-commits
friss created this revision.
friss added reviewers: jingham, clayborg.

In r259902, LLDB started injecting all the locals in every expression
evaluation. This fixed a bunch of issues, but also caused others, mostly
performance regressions on some codebases. The regressions were bad
enough that we added a setting in r274783 to control the behavior and
we have been shipping with the setting off to avoid the perf regressions.

This patch changes the logic injecting the local variables to only inject
the ones present in the expression typed by the user. The approach is
fairly simple and just scans the typed expression for every local name.
Hopefully this gives us the best of both world as it just realizes the
types of the variables really used by the expression.

Landing this requires the 2 other issues I pointed out today to be addressed
but I wanted to gather comments right away.


https://reviews.llvm.org/D46551

Files:
  
packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py
  source/Expression/ExpressionSourceCode.cpp

Index: source/Expression/ExpressionSourceCode.cpp
===
--- source/Expression/ExpressionSourceCode.cpp
+++ source/Expression/ExpressionSourceCode.cpp
@@ -9,6 +9,9 @@
 
 #include "lldb/Expression/ExpressionSourceCode.h"
 
+#include "llvm/ADT/StringRef.h"
+#include "clang/Basic/CharInfo.h"
+
 #include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
 #include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
 #include "lldb/Symbol/Block.h"
@@ -165,14 +168,29 @@
   }
 }
 
+static bool ExprBodyContainsVar(llvm::StringRef var, llvm::StringRef body) {
+  int from = 0;
+  while ((from = body.find(var, from)) != llvm::StringRef::npos) {
+if ((from != 0 && clang::isIdentifierBody(body[from-1])) ||
+(from + var.size() != body.size() &&
+ clang::isIdentifierBody(body[from+var.size()]))) {
+  ++from;
+  continue;
+}
+return true;
+  }
+  return false;
+}
+
 static void AddLocalVariableDecls(const lldb::VariableListSP &var_list_sp,
-  StreamString &stream) {
+  StreamString &stream, const std::string &expr) {
   for (size_t i = 0; i < var_list_sp->GetSize(); i++) {
 lldb::VariableSP var_sp = var_list_sp->GetVariableAtIndex(i);
 
 ConstString var_name = var_sp->GetName();
 if (!var_name || var_name == ConstString("this") ||
-var_name == ConstString(".block_descriptor"))
+var_name == ConstString(".block_descriptor") ||
+!ExprBodyContainsVar(var_name.AsCString(), expr))
   continue;
 
 stream.Printf("using $__lldb_local_vars::%s;\n", var_name.AsCString());
@@ -260,7 +278,7 @@
   if (target->GetInjectLocalVariables(&exe_ctx)) {
 lldb::VariableListSP var_list_sp =
 frame->GetInScopeVariableList(false, true);
-AddLocalVariableDecls(var_list_sp, lldb_local_var_decls);
+AddLocalVariableDecls(var_list_sp, lldb_local_var_decls, m_body);
   }
 }
   }
Index: packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py
===
--- packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py
+++ packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py
@@ -155,7 +155,9 @@
 frame = thread.GetSelectedFrame()
 self.assertTrue(frame.IsValid())
 
+self.enable_expression_log()
 val = frame.EvaluateExpression("a")
+self.disable_expression_log_and_check_for_locals(['a'])
 self.assertTrue(val.IsValid())
 self.assertEqual(val.GetValueAsUnsigned(), 12345)
 
@@ -189,6 +191,12 @@
 self.assertTrue(val.IsValid())
 self.assertEqual(val.GetValueAsUnsigned(), 10003)
 
+self.enable_expression_log()
+val = frame.EvaluateExpression("c-b")
+self.disable_expression_log_and_check_for_locals(['c','b'])
+self.assertTrue(val.IsValid())
+self.assertEqual(val.GetValueAsUnsigned(), 1)
+
 self.process.Continue()
 self.assertTrue(
 self.process.GetState() == lldb.eStateStopped,
@@ -211,6 +219,13 @@
 self.assertTrue(val.IsValid())
 self.assertEqual(val.GetValueAsUnsigned(), 778899)
 
+self.enable_expression_log()
+val = frame.EvaluateExpression("a+b")
+self.disable_expression_log_and_check_for_locals(['a','b'])
+self.assertTrue(val.IsValid())
+self.assertEqual(val.GetValueAsUnsigned(), 3)
+
+
 def _load_exe(self):
 self.build()
 
@@ -234,7 +249,9 @@
 frame = thread.GetSelectedFrame()
 self.assertTrue(frame.IsValid())
 
+self.enable_expression_log()
 val = frame.EvaluateExpr

[Lldb-commits] [lldb] r331686 - [lit, lldbsuite] Fixes for several tests LLDB tests for Python 3 or Windows

2018-05-07 Thread Stella Stamenova via lldb-commits
Author: stella.stamenova
Date: Mon May  7 14:57:00 2018
New Revision: 331686

URL: http://llvm.org/viewvc/llvm-project?rev=331686&view=rev
Log:
[lit, lldbsuite] Fixes for several tests LLDB tests for Python 3 or Windows

Summary:
In decorators.py, when opening streams, open them in text mode. In Py3, if they 
are not opened in text mode, the data is also expected to be binary, but we 
always use text data.
In TestLinuxCore, skip the tests that are not applicable on Windows
In the python api main.c, update the code to be compilable on Windows

Reviewers: asmith, zturner

Reviewed By: zturner

Subscribers: zturner

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

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

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/main.c

Modified: lldb/trunk/packages/Python/lldbsuite/test/decorators.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/decorators.py?rev=331686&r1=331685&r2=331686&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/decorators.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/decorators.py Mon May  7 14:57:00 
2018
@@ -680,7 +680,7 @@ def skipUnlessSupportedTypeAttribute(att
 compiler_path = self.getCompiler()
 f = tempfile.NamedTemporaryFile()
 cmd = [self.getCompiler(), "-x", "c++", "-c", "-o", f.name, "-"]
-p = subprocess.Popen(cmd, stdin=subprocess.PIPE, 
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+p = subprocess.Popen(cmd, stdin=subprocess.PIPE, 
stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
 stdout, stderr = p.communicate('struct __attribute__((%s)) Test 
{};'%attr)
 if attr in stderr:
 return "Compiler does not support attribute %s"%(attr)
@@ -715,7 +715,7 @@ def skipUnlessUndefinedBehaviorSanitizer
 
 def is_compiler_clang_with_ubsan(self):
 # Write out a temp file which exhibits UB.
-inputf = tempfile.NamedTemporaryFile(suffix='.c')
+inputf = tempfile.NamedTemporaryFile(suffix='.c', mode='w')
 inputf.write('int main() { int x = 0; return x / x; }\n')
 inputf.flush()
 

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py?rev=331686&r1=331685&r2=331686&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
 Mon May  7 14:57:00 2018
@@ -46,16 +46,19 @@ class LinuxCoreTestCase(TestBase):
 """Test that lldb can read the process information from an i386 linux 
core file."""
 self.do_test("linux-i386", self._i386_pid, self._i386_regions, "a.out")
 
+@skipIf(oslist=['windows'])
 def test_mips_o32(self):
 """Test that lldb can read the process information from an MIPS O32 
linux core file."""
 self.do_test("linux-mipsel-gnuabio32", self._mips_o32_pid,
 self._mips_regions, "linux-mipsel-gn")
 
+@skipIf(oslist=['windows'])
 def test_mips_n32(self):
 """Test that lldb can read the process information from an MIPS N32 
linux core file """
 self.do_test("linux-mips64el-gnuabin32", self._mips64_n32_pid,
 self._mips_regions, "linux-mips64el-")
 
+@skipIf(oslist=['windows'])
 def test_mips_n64(self):
 """Test that lldb can read the process information from an MIPS N64 
linux core file """
 self.do_test("linux-mips64el-gnuabi64", self._mips64_n64_pid,

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/main.c
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/main.c?rev=331686&r1=331685&r2=331686&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/main.c 
(original)
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/main.c Mon 
May  7 14:57:00 2018
@@ -1,5 +1,11 @@
 #include 
+#ifdef _MSC_VER
+#include 
+#define sleep(x) Sleep((x) * 1000)
+#else
 #include 
+#endif
+
 int main(int argc, char const *argv[])
 {
 lldb_enable_attach();


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


[Lldb-commits] [PATCH] D46551: Inject only relevant local variables in the expression evaluation context

2018-05-07 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: source/Expression/ExpressionSourceCode.cpp:174-179
+if ((from != 0 && clang::isIdentifierBody(body[from-1])) ||
+(from + var.size() != body.size() &&
+ clang::isIdentifierBody(body[from+var.size()]))) {
+  ++from;
+  continue;
+}

Might be clearer as:

```
const int prev = from-1;
if (prev >= 0 && clang::isIdentifierBody(body[prev]))
  continue;
const int next = from + var.size()
if (next == body.size() || clang::isIdentifierBody(body[next]))
  continue;
```


https://reviews.llvm.org/D46551



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


[Lldb-commits] [PATCH] D46551: Inject only relevant local variables in the expression evaluation context

2018-05-07 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

I forgot to increment from before continuing in my example. No need to update 
code if you don't feel it is clearer


https://reviews.llvm.org/D46551



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


[Lldb-commits] [PATCH] D46551: Inject only relevant local variables in the expression evaluation context

2018-05-07 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.

I'm still a little sad we can't get this to happen correctly in clang's lookup, 
but this is a clever way to get the benefit of this workaround without paying 
all the cost, and is a fine temporary solution.

The implementation looks okay to me either way.


https://reviews.llvm.org/D46551



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


[Lldb-commits] [lldb] r331719 - Really test type lookup in TestCppTypeLookup.py

2018-05-07 Thread Frederic Riss via lldb-commits
Author: friss
Date: Mon May  7 20:08:46 2018
New Revision: 331719

URL: http://llvm.org/viewvc/llvm-project?rev=331719&view=rev
Log:
Really test type lookup in TestCppTypeLookup.py

Summary:
... and fix one bug found this way. Currently, the test works not because
types are looked up correctly, but because by injecting local variables
we also materialize the types for Clang. If we disable the local variable
injection, then one check fails.

The reason of the failure is that FindTypes is run with max_matches==1
and this value is passed down to the symbol lookup functions. When the
search is performed only on the basename (like it's the case for an
entity defined in the root namespace), then the search will stop after
having found one match on the basename. But that match might be in a
namespace, we were really just looking up the basename in the accelerator
tables.

The solution is to not pass max_matches down, but to search without a
limit and let RemoveMismatchedTypes do its job afterwards. Note the
patch includes 2 hunks with the same change, but only the latter is
tested. I couldn't find a way to create a testcase for the other
branch of the if ('image lookup -t' allows me to get there, but it
only ever returns one type anyway).

Reviewers: clayborg, jingham

Subscribers: lldb-commits

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py
lldb/trunk/source/Core/Module.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py?rev=331719&r1=331718&r2=331719&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py
 Mon May  7 20:08:46 2018
@@ -38,6 +38,11 @@ class TestCppTypeLookup(TestBase):
 # Get frame for current thread
 frame = thread.GetSelectedFrame()
 
+# We are testing LLDB's type lookup machinery, but if we inject local
+# variables, the types for those will be found because they have been
+# imported through the variable, not because the type lookup worked.
+self.runCmd("settings set target.experimental.inject-local-vars false")
+
 # Make sure we don't accidentally accept structures that exist only
 # in namespaces when evaluating expressions with top level types.
 # Prior to the revision that added this test, we would accidentally

Modified: lldb/trunk/source/Core/Module.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=331719&r1=331718&r2=331719&view=diff
==
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Mon May  7 20:08:46 2018
@@ -997,6 +997,7 @@ size_t Module::FindTypes(
   const bool append = true;
   TypeClass type_class = eTypeClassAny;
   TypeMap typesmap;
+
   if (Type::GetTypeScopeAndBasename(type_name_cstr, type_scope, type_basename,
 type_class)) {
 // Check if "name" starts with "::" which means the qualified type starts
@@ -1019,12 +1020,12 @@ size_t Module::FindTypes(
   // The "type_name_cstr" will have been modified if we have a valid type
   // class prefix (like "struct", "class", "union", "typedef" etc).
   FindTypes_Impl(sc, ConstString(type_basename), nullptr, append,
- max_matches, searched_symbol_files, typesmap);
+ UINT_MAX, searched_symbol_files, typesmap);
   typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
  exact_match);
   num_matches = typesmap.GetSize();
 } else {
-  num_matches = FindTypes_Impl(sc, name, nullptr, append, max_matches,
+  num_matches = FindTypes_Impl(sc, name, nullptr, append, UINT_MAX,
searched_symbol_files, typesmap);
   if (exact_match) {
 std::string name_str(name.AsCString(""));


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


[Lldb-commits] [PATCH] D46548: Really test type lookup in TestCppTypeLookup.py

2018-05-07 Thread Frederic Riss via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331719: Really test type lookup in TestCppTypeLookup.py 
(authored by friss, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D46548

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py
  lldb/trunk/source/Core/Module.cpp


Index: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py
@@ -38,6 +38,11 @@
 # Get frame for current thread
 frame = thread.GetSelectedFrame()
 
+# We are testing LLDB's type lookup machinery, but if we inject local
+# variables, the types for those will be found because they have been
+# imported through the variable, not because the type lookup worked.
+self.runCmd("settings set target.experimental.inject-local-vars false")
+
 # Make sure we don't accidentally accept structures that exist only
 # in namespaces when evaluating expressions with top level types.
 # Prior to the revision that added this test, we would accidentally
Index: lldb/trunk/source/Core/Module.cpp
===
--- lldb/trunk/source/Core/Module.cpp
+++ lldb/trunk/source/Core/Module.cpp
@@ -997,6 +997,7 @@
   const bool append = true;
   TypeClass type_class = eTypeClassAny;
   TypeMap typesmap;
+
   if (Type::GetTypeScopeAndBasename(type_name_cstr, type_scope, type_basename,
 type_class)) {
 // Check if "name" starts with "::" which means the qualified type starts
@@ -1019,12 +1020,12 @@
   // The "type_name_cstr" will have been modified if we have a valid type
   // class prefix (like "struct", "class", "union", "typedef" etc).
   FindTypes_Impl(sc, ConstString(type_basename), nullptr, append,
- max_matches, searched_symbol_files, typesmap);
+ UINT_MAX, searched_symbol_files, typesmap);
   typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
  exact_match);
   num_matches = typesmap.GetSize();
 } else {
-  num_matches = FindTypes_Impl(sc, name, nullptr, append, max_matches,
+  num_matches = FindTypes_Impl(sc, name, nullptr, append, UINT_MAX,
searched_symbol_files, typesmap);
   if (exact_match) {
 std::string name_str(name.AsCString(""));


Index: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py
@@ -38,6 +38,11 @@
 # Get frame for current thread
 frame = thread.GetSelectedFrame()
 
+# We are testing LLDB's type lookup machinery, but if we inject local
+# variables, the types for those will be found because they have been
+# imported through the variable, not because the type lookup worked.
+self.runCmd("settings set target.experimental.inject-local-vars false")
+
 # Make sure we don't accidentally accept structures that exist only
 # in namespaces when evaluating expressions with top level types.
 # Prior to the revision that added this test, we would accidentally
Index: lldb/trunk/source/Core/Module.cpp
===
--- lldb/trunk/source/Core/Module.cpp
+++ lldb/trunk/source/Core/Module.cpp
@@ -997,6 +997,7 @@
   const bool append = true;
   TypeClass type_class = eTypeClassAny;
   TypeMap typesmap;
+
   if (Type::GetTypeScopeAndBasename(type_name_cstr, type_scope, type_basename,
 type_class)) {
 // Check if "name" starts with "::" which means the qualified type starts
@@ -1019,12 +1020,12 @@
   // The "type_name_cstr" will have been modified if we have a valid type
   // class prefix (like "struct", "class", "union", "typedef" etc).
   FindTypes_Impl(sc, ConstString(type_basename), nullptr, append,
- max_matches, searched_symbol_files, typesmap);
+ UINT_MAX, searched_symbol_files, typesmap);
   typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
  exact_match);
   num_matches = typesmap.GetSize();
 } else {
-  num_matches = FindTypes_Impl(sc, name, nullptr, append, max_matches,
+  num_matches = FindTypes_Impl(sc, name, nullptr, append, UINT_MAX,