[Lldb-commits] [PATCH] D49980: [PDB] Parse UDT symbols and pointers to members (combined patch)

2018-08-22 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a subscriber: labath.
aleksandr.urakov added a comment.

It seems that the cause of the failure is https://reviews.llvm.org/rL340206, 
but I'm not sure if the adding of `-gpubnames` switch to `clang` will be a 
correct fix for that?


Repository:
  rL LLVM

https://reviews.llvm.org/D49980



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


[Lldb-commits] [PATCH] D49685: LLDB does not respect platform sysroot when loading core on Linux

2018-08-22 Thread Eugene Birukov via Phabricator via lldb-commits
EugeneBi updated this revision to Diff 161959.
EugeneBi added a comment.

Do not use /tmp directory in the test


https://reviews.llvm.org/D49685

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
  source/Target/Platform.cpp

Index: source/Target/Platform.cpp
===
--- source/Target/Platform.cpp
+++ source/Target/Platform.cpp
@@ -228,17 +228,36 @@
 module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr,
 did_create_ptr, false);
 
+  // Module resolver lambda.
+  auto resolver = [&](const ModuleSpec &spec) {
+Status error(eErrorTypeGeneric);
+ModuleSpec resolved_spec;
+// Check if we have sysroot set.
+if (m_sdk_sysroot) {
+  // Prepend sysroot to module spec.
+  resolved_spec = spec;
+  resolved_spec.GetFileSpec().PrependPathComponent(
+m_sdk_sysroot.GetStringRef());
+  // Try to get shared module with resolved spec.
+  error = ModuleList::GetSharedModule( 
+resolved_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, 
+did_create_ptr, false);
+}
+// If we don't have sysroot or it didn't work then 
+// try original module spec.
+if (!error.Success()) {
+  resolved_spec = spec;
+  error = ModuleList::GetSharedModule(
+resolved_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, 
+did_create_ptr, false);
+}
+if (error.Success() && module_sp)
+  module_sp->SetPlatformFileSpec(resolved_spec.GetFileSpec());
+return error;
+  };
+
   return GetRemoteSharedModule(module_spec, process, module_sp,
-   [&](const ModuleSpec &spec) {
- Status error = ModuleList::GetSharedModule(
- spec, module_sp, module_search_paths_ptr,
- old_module_sp_ptr, did_create_ptr, false);
- if (error.Success() && module_sp)
-   module_sp->SetPlatformFileSpec(
-   spec.GetFileSpec());
- return error;
-   },
-   did_create_ptr);
+   resolver, did_create_ptr);
 }
 
 bool Platform::GetModuleSpec(const FileSpec &module_file_spec,
Index: packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
===
--- packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -6,6 +6,7 @@
 
 import shutil
 import struct
+import os
 
 import lldb
 from lldbsuite.test.decorators import *
@@ -203,6 +204,30 @@
 for regname, value in values.iteritems():
 self.expect("register read {}".format(regname), substrs=["{} = {}".format(regname, value)])
 
+@expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"])
+@skipIf(triple='^mips')
+@skipIfLLVMTargetMissing("X86")
+def test_i386_sysroot(self):
+"""Test that lldb can find the exe for an i386 linux core file using the sysroot."""
+
+# Copy linux-i386.out to tmp_sysroot/home/labath/test/a.out (since it was compiled as
+# /home/labath/test/a.out)
+tmp_sysroot = os.path.join(self.getBuildDir(), "lldb_i386_mock_sysroot")
+executable = os.path.join(tmp_sysroot, "home", "labath", "test", "a.out")
+lldbutil.mkdir_p(os.path.dirname(executable))
+shutil.copyfile("linux-i386.out", executable)
+
+# Set sysroot and load core
+self.runCmd("platform select remote-linux --sysroot '%s'" % tmp_sysroot)
+target = self.dbg.CreateTarget(None)
+self.assertTrue(target, VALID_TARGET)
+process = target.LoadCore("linux-i386.core")
+
+# Check that we found a.out from the sysroot
+self.check_all(process, self._i386_pid, self._i386_regions, "a.out")
+
+self.dbg.DeleteTarget(target)
+
 def check_memory_regions(self, process, region_count):
 region_list = process.GetMemoryRegions()
 self.assertEqual(region_list.GetSize(), region_count)
@@ -299,15 +324,7 @@
 self.dbg.SetOutputFileHandle(None, False)
 self.dbg.SetErrorFileHandle(None, False)
 
-def do_test(self, filename, pid, region_count, thread_name):
-target = self.dbg.CreateTarget(filename + ".out")
-process = target.LoadCore(filename + ".core")
-self.assertTrue(process, PROCESS_IS_VALID)
-self.assertEqual(process.GetNumThreads(), 1)
-self.assertEqual(process.GetProcessID(), pid)
-
-self.check_state(process)
-
+def check_stack(self, process, pid, thread_name):
 thread = process.GetSelectedThread()
 self.asser

[Lldb-commits] [PATCH] D49685: LLDB does not respect platform sysroot when loading core on Linux

2018-08-22 Thread Eugene Birukov via Phabricator via lldb-commits
EugeneBi marked an inline comment as done.
EugeneBi added inline comments.



Comment at: 
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py:215
+# /home/labath/test/a.out)
+tmp_sysroot = "/tmp/lldb_i386_mock_sysroot"
+executable = tmp_sysroot + "/home/labath/test/a.out"

labath wrote:
> Please put this in the build folder (self.getBuildDir) instead of `/tmp`.
I uploaded new diff and closed revision. 
Do I need to do anything else?


https://reviews.llvm.org/D49685



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


Re: [Lldb-commits] [PATCH] D49980: [PDB] Parse UDT symbols and pointers to members (combined patch)

2018-08-22 Thread Zachary Turner via lldb-commits
On Wed, Aug 22, 2018 at 12:34 AM Aleksandr Urakov via Phabricator <
revi...@reviews.llvm.org> wrote:

> aleksandr.urakov added a subscriber: labath.
> aleksandr.urakov added a comment.
>
> It seems that the cause of the failure is
> https://reviews.llvm.org/rL340206, but I'm not sure if the adding of
> `-gpubnames` switch to `clang` will be a correct fix for that?
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D49980
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D50864: Add libc++ data formatter for std::function

2018-08-22 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik updated this revision to Diff 161997.
shafik added a comment.

Updating comment


https://reviews.llvm.org/D50864

Files:
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
  source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  source/Plugins/Language/CPlusPlus/LibCxx.cpp
  source/Plugins/Language/CPlusPlus/LibCxx.h

Index: source/Plugins/Language/CPlusPlus/LibCxx.h
===
--- source/Plugins/Language/CPlusPlus/LibCxx.h
+++ source/Plugins/Language/CPlusPlus/LibCxx.h
@@ -32,6 +32,10 @@
 const TypeSummaryOptions
 &options); // libc++ std::shared_ptr<> and std::weak_ptr<>
 
+bool LibcxxFunctionSummaryProvider(
+ValueObject &valobj, Stream &stream,
+const TypeSummaryOptions &options); // libc++ std::function<>
+
 SyntheticChildrenFrontEnd *
 LibcxxVectorBoolSyntheticFrontEndCreator(CXXSyntheticChildren *,
  lldb::ValueObjectSP);
@@ -124,9 +128,6 @@
 LibcxxInitializerListSyntheticFrontEndCreator(CXXSyntheticChildren *,
   lldb::ValueObjectSP);
 
-SyntheticChildrenFrontEnd *LibcxxFunctionFrontEndCreator(CXXSyntheticChildren *,
- lldb::ValueObjectSP);
-
 SyntheticChildrenFrontEnd *LibcxxQueueFrontEndCreator(CXXSyntheticChildren *,
   lldb::ValueObjectSP);
 
Index: source/Plugins/Language/CPlusPlus/LibCxx.cpp
===
--- source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -12,6 +12,7 @@
 // C Includes
 // C++ Includes
 // Other libraries and framework includes
+#include "llvm/ADT/ScopeExit.h"
 // Project includes
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/FormatEntity.h"
@@ -23,6 +24,7 @@
 #include "lldb/DataFormatters/VectorIterator.h"
 #include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Target/ProcessStructReader.h"
+#include "lldb/Target/SectionLoadList.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/Endian.h"
@@ -33,6 +35,226 @@
 using namespace lldb_private;
 using namespace lldb_private::formatters;
 
+bool lldb_private::formatters::LibcxxFunctionSummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+
+  ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
+
+  if (!valobj_sp)
+return false;
+
+  // Member __f_ has type __base*, the contents of which will hold:
+  // 1) a vtable entry which may hold type information needed to discover the
+  //lambda being called
+  // 2) possibly hold a pointer to the callable object
+  // e.g.
+  //
+  // (lldb) frame var -R  f_display
+  // (std::__1::function) f_display = {
+  //  __buf_ = {
+  //  …
+  // }
+  //  __f_ = 0x7ffeefbffa00
+  // }
+  // (lldb) memory read -fA 0x7ffeefbffa00
+  // 0x7ffeefbffa00: ... `vtable for std::__1::__function::__funcGetChildMemberWithName(ConstString("__f_"), true));
+  lldb::addr_t member__f_pointer_value = member__f_->GetValueAsUnsigned(0);
+
+  ExecutionContext exe_ctx(valobj_sp->GetExecutionContextRef());
+  Process *process = exe_ctx.GetProcessPtr();
+
+  if (process == nullptr)
+return false;
+
+  uint32_t address_size = process->GetAddressByteSize();
+  Status status;
+
+  // First item pointed to by __f_ should be the pointer to the vtable for
+  // a __base object.
+  lldb::addr_t vtable_address =
+  process->ReadPointerFromMemory(member__f_pointer_value, status);
+
+  if (status.Fail())
+return false;
+
+  bool found_wrapped_function = false;
+
+  // Using scoped exit so we can use early return and still execute the default
+  // action in case we don't find the wrapper function. Otherwise we can't use
+  // early exit without duplicating code.
+  auto default_print_on_exit = llvm::make_scope_exit(
+  [&found_wrapped_function, &stream, &member__f_pointer_value]() {
+if (!found_wrapped_function)
+  stream.Printf(" __f_ = %llu", member__f_pointer_value);
+  });
+
+  lldb::addr_t address_after_vtable = member__f_pointer_value + address_size;
+  // As commened above we may not have a function pointer but if we do we will
+  // need it.
+  lldb::addr_t possible_function_address =
+  process->ReadPointerFromMemory(address_after_vtable, status);
+
+  if (status.Fail())
+return false;
+
+  Target &target = process->GetTarget();
+
+  if (target.GetSectionLoadList().IsEmpty())
+return false;
+
+  Address vtable_addr_resolved;
+  SymbolContext sc;
+  Symbol *symbol;
+
+  if (!target.GetSectionLoadList().ResolveLoadAddress(vtable_address,
+  vtable_add

[Lldb-commits] [PATCH] D50298: Add unit test for StringLexer

2018-08-22 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

This is another one of classes we should probably get rid of (it looks like all 
of this functionality is available in StringRef), but while we have it, it 
might as well be tested.


https://reviews.llvm.org/D50298



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


[Lldb-commits] [lldb] r340448 - Add unit test for StringLexer

2018-08-22 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Aug 22 13:22:34 2018
New Revision: 340448

URL: http://llvm.org/viewvc/llvm-project?rev=340448&view=rev
Log:
Add unit test for StringLexer

Reviewers: labath, #lldb

Reviewed By: labath

Subscribers: jloser, mgorny, lldb-commits

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

Added:
lldb/trunk/unittests/Utility/StringLexerTest.cpp
Modified:
lldb/trunk/unittests/Utility/CMakeLists.txt

Modified: lldb/trunk/unittests/Utility/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/CMakeLists.txt?rev=340448&r1=340447&r2=340448&view=diff
==
--- lldb/trunk/unittests/Utility/CMakeLists.txt (original)
+++ lldb/trunk/unittests/Utility/CMakeLists.txt Wed Aug 22 13:22:34 2018
@@ -19,6 +19,7 @@ add_lldb_unittest(UtilityTests
   StreamTeeTest.cpp
   StreamTest.cpp
   StringExtractorTest.cpp
+  StringLexerTest.cpp
   StringListTest.cpp
   StructuredDataTest.cpp
   TildeExpressionResolverTest.cpp

Added: lldb/trunk/unittests/Utility/StringLexerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/StringLexerTest.cpp?rev=340448&view=auto
==
--- lldb/trunk/unittests/Utility/StringLexerTest.cpp (added)
+++ lldb/trunk/unittests/Utility/StringLexerTest.cpp Wed Aug 22 13:22:34 2018
@@ -0,0 +1,141 @@
+//===-- StringLexerTest.cpp -*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "lldb/Utility/StringLexer.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_utility;
+
+TEST(StringLexerTest, GetUnlexed) {
+  StringLexer l("foo");
+  EXPECT_EQ("foo", l.GetUnlexed());
+  l.Next();
+  EXPECT_EQ("oo", l.GetUnlexed());
+  l.Next();
+  l.Next();
+  EXPECT_EQ("", l.GetUnlexed());
+}
+
+TEST(StringLexerTest, HasAtLeast) {
+  StringLexer l("foo");
+  EXPECT_FALSE(l.HasAtLeast(5));
+  EXPECT_FALSE(l.HasAtLeast(4));
+  EXPECT_TRUE(l.HasAtLeast(3));
+  EXPECT_TRUE(l.HasAtLeast(2));
+  EXPECT_TRUE(l.HasAtLeast(1));
+
+  l.Next();
+  EXPECT_FALSE(l.HasAtLeast(5));
+  EXPECT_FALSE(l.HasAtLeast(4));
+  EXPECT_FALSE(l.HasAtLeast(3));
+  EXPECT_TRUE(l.HasAtLeast(2));
+  EXPECT_TRUE(l.HasAtLeast(1));
+
+  l.Next();
+  l.Next();
+  EXPECT_FALSE(l.HasAtLeast(5));
+  EXPECT_FALSE(l.HasAtLeast(4));
+  EXPECT_FALSE(l.HasAtLeast(3));
+  EXPECT_FALSE(l.HasAtLeast(2));
+  EXPECT_FALSE(l.HasAtLeast(1));
+}
+
+TEST(StringLexerTest, AdvanceIf) {
+  StringLexer l("foobar");
+
+  EXPECT_FALSE(l.AdvanceIf("oo"));
+  // Skip the "fo" part.
+  EXPECT_TRUE(l.AdvanceIf("fo"));
+  EXPECT_FALSE(l.AdvanceIf("obarz"));
+  // Skip the remaining string.
+  EXPECT_TRUE(l.AdvanceIf("obar"));
+
+  EXPECT_FALSE(l.AdvanceIf("obarz"));
+  EXPECT_FALSE(l.AdvanceIf("foo"));
+  EXPECT_FALSE(l.AdvanceIf("o"));
+  EXPECT_FALSE(l.AdvanceIf(" "));
+}
+
+TEST(StringLexerTest, PutBack) {
+  StringLexer l("foo");
+
+  l.Next();
+  l.PutBack(1);
+  EXPECT_EQ("foo", l.GetUnlexed());
+
+  l.Next();
+  l.Next();
+  l.Next();
+  l.PutBack(2);
+  EXPECT_EQ("oo", l.GetUnlexed());
+
+  l.PutBack(1);
+  EXPECT_EQ("foo", l.GetUnlexed());
+}
+
+TEST(StringLexerTest, Peek) {
+  StringLexer l("foo");
+
+  EXPECT_EQ('f', l.Peek());
+  l.Next();
+  EXPECT_EQ('o', l.Peek());
+  l.Next();
+  EXPECT_EQ('o', l.Peek());
+}
+
+TEST(StringLexerTest, Next) {
+  StringLexer l("foo");
+  EXPECT_EQ('f', l.Next());
+  EXPECT_EQ('o', l.Next());
+  EXPECT_EQ('o', l.Next());
+}
+
+TEST(StringLexerTest, NextIf) {
+  StringLexer l("foo");
+
+  EXPECT_FALSE(l.NextIf('\0'));
+  EXPECT_FALSE(l.NextIf(' '));
+  EXPECT_FALSE(l.NextIf('o'));
+
+  EXPECT_TRUE(l.NextIf('f'));
+
+  EXPECT_FALSE(l.NextIf('\0'));
+  EXPECT_FALSE(l.NextIf(' '));
+  EXPECT_FALSE(l.NextIf('f'));
+
+  EXPECT_TRUE(l.NextIf('o'));
+
+  EXPECT_FALSE(l.NextIf('\0'));
+  EXPECT_FALSE(l.NextIf(' '));
+  EXPECT_FALSE(l.NextIf('f'));
+
+  EXPECT_TRUE(l.NextIf('o'));
+}
+
+TEST(StringLexerTest, NextIfList) {
+  StringLexer l("foo");
+
+  EXPECT_FALSE(l.NextIf({'\0', ' ', 'o'}).first);
+
+  auto r = l.NextIf({'f'});
+  EXPECT_TRUE(r.first);
+  EXPECT_EQ('f', r.second);
+
+  EXPECT_FALSE(l.NextIf({'\0', ' ', 'f'}).first);
+
+  r = l.NextIf({'f', 'o'});
+  EXPECT_TRUE(r.first);
+  EXPECT_EQ('o', r.second);
+
+  EXPECT_FALSE(l.NextIf({'\0', ' ', 'f'}).first);
+
+  r = l.NextIf({'*', 'f', 'o', 'o'});
+  EXPECT_TRUE(r.first);
+  EXPECT_EQ('o', r.second);
+}


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


[Lldb-commits] [PATCH] D50298: Add unit test for StringLexer

2018-08-22 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340448: Add unit test for StringLexer (authored by 
teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50298?vs=159193&id=162038#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50298

Files:
  lldb/trunk/unittests/Utility/CMakeLists.txt
  lldb/trunk/unittests/Utility/StringLexerTest.cpp

Index: lldb/trunk/unittests/Utility/StringLexerTest.cpp
===
--- lldb/trunk/unittests/Utility/StringLexerTest.cpp
+++ lldb/trunk/unittests/Utility/StringLexerTest.cpp
@@ -0,0 +1,141 @@
+//===-- StringLexerTest.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "lldb/Utility/StringLexer.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_utility;
+
+TEST(StringLexerTest, GetUnlexed) {
+  StringLexer l("foo");
+  EXPECT_EQ("foo", l.GetUnlexed());
+  l.Next();
+  EXPECT_EQ("oo", l.GetUnlexed());
+  l.Next();
+  l.Next();
+  EXPECT_EQ("", l.GetUnlexed());
+}
+
+TEST(StringLexerTest, HasAtLeast) {
+  StringLexer l("foo");
+  EXPECT_FALSE(l.HasAtLeast(5));
+  EXPECT_FALSE(l.HasAtLeast(4));
+  EXPECT_TRUE(l.HasAtLeast(3));
+  EXPECT_TRUE(l.HasAtLeast(2));
+  EXPECT_TRUE(l.HasAtLeast(1));
+
+  l.Next();
+  EXPECT_FALSE(l.HasAtLeast(5));
+  EXPECT_FALSE(l.HasAtLeast(4));
+  EXPECT_FALSE(l.HasAtLeast(3));
+  EXPECT_TRUE(l.HasAtLeast(2));
+  EXPECT_TRUE(l.HasAtLeast(1));
+
+  l.Next();
+  l.Next();
+  EXPECT_FALSE(l.HasAtLeast(5));
+  EXPECT_FALSE(l.HasAtLeast(4));
+  EXPECT_FALSE(l.HasAtLeast(3));
+  EXPECT_FALSE(l.HasAtLeast(2));
+  EXPECT_FALSE(l.HasAtLeast(1));
+}
+
+TEST(StringLexerTest, AdvanceIf) {
+  StringLexer l("foobar");
+
+  EXPECT_FALSE(l.AdvanceIf("oo"));
+  // Skip the "fo" part.
+  EXPECT_TRUE(l.AdvanceIf("fo"));
+  EXPECT_FALSE(l.AdvanceIf("obarz"));
+  // Skip the remaining string.
+  EXPECT_TRUE(l.AdvanceIf("obar"));
+
+  EXPECT_FALSE(l.AdvanceIf("obarz"));
+  EXPECT_FALSE(l.AdvanceIf("foo"));
+  EXPECT_FALSE(l.AdvanceIf("o"));
+  EXPECT_FALSE(l.AdvanceIf(" "));
+}
+
+TEST(StringLexerTest, PutBack) {
+  StringLexer l("foo");
+
+  l.Next();
+  l.PutBack(1);
+  EXPECT_EQ("foo", l.GetUnlexed());
+
+  l.Next();
+  l.Next();
+  l.Next();
+  l.PutBack(2);
+  EXPECT_EQ("oo", l.GetUnlexed());
+
+  l.PutBack(1);
+  EXPECT_EQ("foo", l.GetUnlexed());
+}
+
+TEST(StringLexerTest, Peek) {
+  StringLexer l("foo");
+
+  EXPECT_EQ('f', l.Peek());
+  l.Next();
+  EXPECT_EQ('o', l.Peek());
+  l.Next();
+  EXPECT_EQ('o', l.Peek());
+}
+
+TEST(StringLexerTest, Next) {
+  StringLexer l("foo");
+  EXPECT_EQ('f', l.Next());
+  EXPECT_EQ('o', l.Next());
+  EXPECT_EQ('o', l.Next());
+}
+
+TEST(StringLexerTest, NextIf) {
+  StringLexer l("foo");
+
+  EXPECT_FALSE(l.NextIf('\0'));
+  EXPECT_FALSE(l.NextIf(' '));
+  EXPECT_FALSE(l.NextIf('o'));
+
+  EXPECT_TRUE(l.NextIf('f'));
+
+  EXPECT_FALSE(l.NextIf('\0'));
+  EXPECT_FALSE(l.NextIf(' '));
+  EXPECT_FALSE(l.NextIf('f'));
+
+  EXPECT_TRUE(l.NextIf('o'));
+
+  EXPECT_FALSE(l.NextIf('\0'));
+  EXPECT_FALSE(l.NextIf(' '));
+  EXPECT_FALSE(l.NextIf('f'));
+
+  EXPECT_TRUE(l.NextIf('o'));
+}
+
+TEST(StringLexerTest, NextIfList) {
+  StringLexer l("foo");
+
+  EXPECT_FALSE(l.NextIf({'\0', ' ', 'o'}).first);
+
+  auto r = l.NextIf({'f'});
+  EXPECT_TRUE(r.first);
+  EXPECT_EQ('f', r.second);
+
+  EXPECT_FALSE(l.NextIf({'\0', ' ', 'f'}).first);
+
+  r = l.NextIf({'f', 'o'});
+  EXPECT_TRUE(r.first);
+  EXPECT_EQ('o', r.second);
+
+  EXPECT_FALSE(l.NextIf({'\0', ' ', 'f'}).first);
+
+  r = l.NextIf({'*', 'f', 'o', 'o'});
+  EXPECT_TRUE(r.first);
+  EXPECT_EQ('o', r.second);
+}
Index: lldb/trunk/unittests/Utility/CMakeLists.txt
===
--- lldb/trunk/unittests/Utility/CMakeLists.txt
+++ lldb/trunk/unittests/Utility/CMakeLists.txt
@@ -19,6 +19,7 @@
   StreamTeeTest.cpp
   StreamTest.cpp
   StringExtractorTest.cpp
+  StringLexerTest.cpp
   StringListTest.cpp
   StructuredDataTest.cpp
   TildeExpressionResolverTest.cpp
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D48463: Prevent dead locking when calling PrintAsync

2018-08-22 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor abandoned this revision.
teemperor marked 2 inline comments as done.
teemperor added a comment.

Abandon in favor of https://reviews.llvm.org/D50912


https://reviews.llvm.org/D48463



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


[Lldb-commits] [PATCH] D50481: Fix broken builtin functions in the expression command

2018-08-22 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor edited reviewers, added: LLDB; removed: jingham.
teemperor added a comment.

(Adding the team as a reviewer, because the code this patch touches doesn't 
seem to have a dedicated code owner).


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D50481



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


[Lldb-commits] [PATCH] D50481: Fix broken builtin functions in the expression command

2018-08-22 Thread Vedant Kumar via Phabricator via lldb-commits
vsk accepted this revision as: vsk.
vsk added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM!


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D50481



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


[Lldb-commits] [PATCH] D50912: Don't cancel the current IOHandler when we push a handler for an utility function run.

2018-08-22 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: source/Target/Process.cpp:4692-4693
+// the IOHandler for Editline).
+bool cancel_top_handler = m_mod_id.IsRunningUtilityFunction();
+GetTarget().GetDebugger().PushIOHandler(io_handler_sp, cancel_top_handler);
 return true;

Another possible fix is to avoid pushing the IOHandler all together? Something 
like:

```
if (!m_mod_id.IsRunningUtilityFunction())
  GetTarget().GetDebugger().PushIOHandler(io_handler_sp);
```

This would avoid an needed changes to the IOHandler stuff?


https://reviews.llvm.org/D50912



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


[Lldb-commits] [PATCH] D50481: Fix broken builtin functions in the expression command

2018-08-22 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Changed look fine. Wondering if we want to be adding pexpect style tests 
though. Those tests tend to be flaky. This could easily be done with SB API 
calls instead of using pexpect.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D50481



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


[Lldb-commits] [PATCH] D50481: Fix broken builtin functions in the expression command

2018-08-22 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor planned changes to this revision.
teemperor added a comment.

@clayborg Thanks, getting rid of pexpect sounds good.

TODO:

- Get rid of pexpect.
- Fix some of the comments in the test that are still referring to the test I 
copied this from.
- Reuse `builtin_context` instead of calling `PP.getBuiltinInfo()` twice in 
`ClangExpressionParser.cpp`.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D50481



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


[Lldb-commits] [PATCH] D50912: Don't cancel the current IOHandler when we push a handler for an utility function run.

2018-08-22 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

What would happen to any output that the process produced while running the 
utility function if we did this.


https://reviews.llvm.org/D50912



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


[Lldb-commits] [PATCH] D50912: Don't cancel the current IOHandler when we push a handler for an utility function run.

2018-08-22 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In https://reviews.llvm.org/D50912#1209994, @jingham wrote:

> What would happen to any output that the process produced while running the 
> utility function if we did this.


I believe it would still be fetched on next stop. Just not real time. Do you 
think anyone running a utility function would need to ever fetch data real 
time? "utility" in my mind means not started by a interactive user. Am I wrong?


https://reviews.llvm.org/D50912



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


[Lldb-commits] [PATCH] D50912: Don't cancel the current IOHandler when we push a handler for an utility function run.

2018-08-22 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

It's not a huge deal, but it would be disconcerting to have a bunch of text 
dumped to your console the next time you continue.  I think the ideal solution 
would be for utility functions to push a "capture & report" IO handler, so the 
Utility function could retrieve what went to stdout when it was running, and 
choose whether to display it or not (for instance, display it only if the 
function errored out...)


https://reviews.llvm.org/D50912



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


[Lldb-commits] [lldb] r340460 - Add include directory for libxml on macOS

2018-08-22 Thread Stephane Sezer via lldb-commits
Author: sas
Date: Wed Aug 22 15:25:45 2018
New Revision: 340460

URL: http://llvm.org/viewvc/llvm-project?rev=340460&view=rev
Log:
Add include directory for libxml on macOS

Summary:
Builds fail because libxml/xmlreader.h isn't found. Adding the include
directory to the include list fixes the issue. This is what we already do on
non-macOS platforms in the same file.

Reviewers: clayborg, xiaobai, lanza

Reviewed By: clayborg, lanza

Subscribers: mgorny

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

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

Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBConfig.cmake?rev=340460&r1=340459&r2=340460&view=diff
==
--- lldb/trunk/cmake/modules/LLDBConfig.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake Wed Aug 22 15:25:45 2018
@@ -336,14 +336,13 @@ if (APPLE)
${CORE_SERVICES_LIBRARY}
${SECURITY_LIBRARY}
${DEBUG_SYMBOLS_LIBRARY})
-
+  include_directories(${LIBXML2_INCLUDE_DIR})
 else()
   if (LIBXML2_FOUND)
 add_definitions( -DLIBXML2_DEFINED )
 list(APPEND system_libs ${LIBXML2_LIBRARIES})
 include_directories(${LIBXML2_INCLUDE_DIR})
   endif()
-
 endif()
 
 if( WIN32 AND NOT CYGWIN )


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