[Lldb-commits] [lldb] r371017 - Breakpad: Basic support for STACK WIN unwinding

2019-09-05 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Sep  5 00:05:15 2019
New Revision: 371017

URL: http://llvm.org/viewvc/llvm-project?rev=371017&view=rev
Log:
Breakpad: Basic support for STACK WIN unwinding

Summary:
This patch makes it possible to unwind via breakpad STACK WIN records.
It is "basic" because two important features are missing:
- support for the .raSearch keyword
- support for multiple STACK WIN records within a single function
Right now, we just reject the .raSearch records, and always pick the
first record for the whole function
SymbolFileBreakpad, and so I think it can serve as a good example of
what is needed of the symbol file and unwinding machinery to make this
work.

However, it is already useful for unwinding in some situations, and it
sets up the general framework for the parsing of these kinds of records,
which reduces the size of the followup patches implementing the two
other components.

Reviewers: amccarth, rnk, markmentovai

Subscribers: lldb-commits

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

Added:
lldb/trunk/lit/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.syms
lldb/trunk/lit/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.yaml
lldb/trunk/lit/SymbolFile/Breakpad/unwind-via-stack-win.test
Modified:
lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h

Added: lldb/trunk/lit/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.syms
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.syms?rev=371017&view=auto
==
--- lldb/trunk/lit/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.syms (added)
+++ lldb/trunk/lit/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.syms Thu Sep 
 5 00:05:15 2019
@@ -0,0 +1,17 @@
+MODULE windows x86 897DD83EA8C8411897F3A925EE4BF7411 unwind-via-stack-win.pdb
+INFO CODE_ID 5D499B5C5000 unwind-via-stack-win.exe
+PUBLIC  0 0 dummy
+PUBLIC 10 0 call_many
+PUBLIC 80 0 main
+PUBLIC 90 0 many_pointer_args
+PUBLIC 100 0 bogus_rule
+PUBLIC 110 0 bogus_cfa_rhs
+PUBLIC 120 0 bogus_esp_rhs
+PUBLIC 130 0 temporary_var
+STACK WIN 4 10 6d 0 0 0 0 0 0 1 $T0 $esp 80 + = $eip $T0 ^ = $esp $T0 4 + =
+STACK WIN 4 80 8 0 0 0 0 0 0 1 $T0 $esp = $eip $T0 ^ = $esp $T0 4 + =
+STACK WIN 4 90 5 0 0 50 0 0 0 1 $T0 $esp = $eip $T0 ^ = $esp $T0 4 + =
+STACK WIN 4 100 4 0 0 0 0 0 0 1 bogus
+STACK WIN 4 110 4 0 0 0 0 0 0 1 $T0 $bogus = $eip $T0 ^ = $esp $T0 4 + =
+STACK WIN 4 120 4 0 0 0 0 0 0 1 $T0 $esp = $eip $T0 ^ = $esp $bogus 4 + =
+STACK WIN 4 130 4 0 0 0 0 0 0 1 $T0 $esp = $bogus $T0 = $eip $bogus ^ = $esp 
$T0 4 + =

Added: lldb/trunk/lit/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.yaml?rev=371017&view=auto
==
--- lldb/trunk/lit/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.yaml (added)
+++ lldb/trunk/lit/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.yaml Thu Sep 
 5 00:05:15 2019
@@ -0,0 +1,35 @@
+--- !minidump
+Streams:
+  - Type:ThreadList
+Threads:
+  - Thread Id:   0x290C
+Priority Class:  0x0020
+Environment Block: 0x00A98000
+Context: 
3F0001007F022B0053002B002B0080100B0080100B50A90080100B0080100B00E4FECF0092100B002300440301007CFECF002B007F02801F0200144E3D6C2100EA1E00F4C000E507FC012CE3C014D8E20201E507880F401D839DC60140007F00880F401D0A00900F401D0100EA1E9808E5077F009008E50799016002E5072CABC87708346474B423010044E3C014200020532777A80F401D4F346474D00F401D6F378CCC5C4CD5013AFCD72F90E3C01418CE3470B423B80F401DC00F401DC80F401DD00F401D
+Stack:
+  Start of Memory Range: 0x00CFFE78
+  Content: 
79100B100B100B100B100B100B1

[Lldb-commits] [PATCH] D67067: Breakpad: Basic support for STACK WIN unwinding

2019-09-05 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371017: Breakpad: Basic support for STACK WIN unwinding 
(authored by labath, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67067?vs=218611&id=218848#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67067

Files:
  lldb/trunk/lit/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.syms
  lldb/trunk/lit/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.yaml
  lldb/trunk/lit/SymbolFile/Breakpad/unwind-via-stack-win.test
  lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h

Index: lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -15,7 +15,6 @@
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Symbol/PostfixExpression.h"
 #include "lldb/Symbol/SymbolVendor.h"
 #include "lldb/Symbol/TypeMap.h"
 #include "lldb/Utility/Log.h"
@@ -421,7 +420,17 @@
   return ResolveRegister(resolver, name);
 }
 
-bool SymbolFileBreakpad::ParseUnwindRow(llvm::StringRef unwind_rules,
+llvm::ArrayRef SymbolFileBreakpad::SaveAsDWARF(postfix::Node &node) {
+  ArchSpec arch = m_objfile_sp->GetArchitecture();
+  StreamString dwarf(Stream::eBinary, arch.GetAddressByteSize(),
+ arch.GetByteOrder());
+  ToDWARF(node, dwarf);
+  uint8_t *saved = m_allocator.Allocate(dwarf.GetSize());
+  std::memcpy(saved, dwarf.GetData(), dwarf.GetSize());
+  return {saved, dwarf.GetSize()};
+}
+
+bool SymbolFileBreakpad::ParseCFIUnwindRow(llvm::StringRef unwind_rules,
 const RegisterInfoResolver &resolver,
 UnwindPlan::Row &row) {
   Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS);
@@ -454,18 +463,12 @@
   return false;
 }
 
-ArchSpec arch = m_objfile_sp->GetArchitecture();
-StreamString dwarf(Stream::eBinary, arch.GetAddressByteSize(),
-   arch.GetByteOrder());
-ToDWARF(*rhs, dwarf);
-uint8_t *saved = m_allocator.Allocate(dwarf.GetSize());
-std::memcpy(saved, dwarf.GetData(), dwarf.GetSize());
-
+llvm::ArrayRef saved = SaveAsDWARF(*rhs);
 if (lhs == ".cfa") {
-  row.GetCFAValue().SetIsDWARFExpression(saved, dwarf.GetSize());
+  row.GetCFAValue().SetIsDWARFExpression(saved.data(), saved.size());
 } else if (const RegisterInfo *info = ResolveRegisterOrRA(resolver, lhs)) {
   UnwindPlan::Row::RegisterLocation loc;
-  loc.SetIsDWARFExpression(saved, dwarf.GetSize());
+  loc.SetIsDWARFExpression(saved.data(), saved.size());
   row.SetRegisterInfo(info->kinds[eRegisterKindLLDB], loc);
 } else
   LLDB_LOG(log, "Invalid register `{0}` in unwind rule.", lhs);
@@ -481,20 +484,27 @@
 SymbolFileBreakpad::GetUnwindPlan(const Address &address,
   const RegisterInfoResolver &resolver) {
   ParseUnwindData();
-  const UnwindMap::Entry *entry =
-  m_unwind_data->FindEntryThatContains(address.GetFileAddress());
-  if (!entry)
-return nullptr;
+  if (auto *entry =
+  m_unwind_data->cfi.FindEntryThatContains(address.GetFileAddress()))
+return ParseCFIUnwindPlan(entry->data, resolver);
+  if (auto *entry =
+  m_unwind_data->win.FindEntryThatContains(address.GetFileAddress()))
+return ParseWinUnwindPlan(entry->data, resolver);
+  return nullptr;
+}
 
+UnwindPlanSP
+SymbolFileBreakpad::ParseCFIUnwindPlan(const Bookmark &bookmark,
+   const RegisterInfoResolver &resolver) {
   addr_t base = GetBaseFileAddress();
   if (base == LLDB_INVALID_ADDRESS)
 return nullptr;
 
-  LineIterator It(*m_objfile_sp, Record::StackCFI, entry->data),
+  LineIterator It(*m_objfile_sp, Record::StackCFI, bookmark),
   End(*m_objfile_sp);
   llvm::Optional init_record = StackCFIRecord::parse(*It);
-  assert(init_record.hasValue());
-  assert(init_record->Size.hasValue());
+  assert(init_record.hasValue() && init_record->Size.hasValue() &&
+ "Record already parsed successfully in ParseUnwindData!");
 
   auto plan_sp = std::make_shared(lldb::eRegisterKindLLDB);
   plan_sp->SetSourceName("breakpad STACK CFI");
@@ -507,7 +517,7 @@
 
   auto row_sp = std::make_shared();
   row_sp->SetOffset(0);
-  if (!ParseUnwindRow(init_record->UnwindRules, resolver, *row_sp))
+  if (!ParseCFIUnwindRow(init_record->UnwindRules, resolver, *row_sp))
 return nullptr;
   plan_sp->AppendRow(row_sp);
   for (++It; It != End; ++It) {
@@ -519,13 +529,98 @@
 
 row_sp = st

[Lldb-commits] [PATCH] D67067: Breakpad: Basic support for STACK WIN unwinding

2019-09-05 Thread Pavel Labath via Phabricator via lldb-commits
labath marked an inline comment as done.
labath added inline comments.



Comment at: source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp:549
+  llvm::Optional record = StackWinRecord::parse(*It);
+  assert(record.hasValue());
+

amccarth wrote:
> labath wrote:
> > amccarth wrote:
> > > Should we log and bail out rather than just assert?  A corrupt symbol 
> > > file shouldn't kill the debugger, right?
> > > 
> > > Also, it's Optional rather than Expected, so it seems even more plausible 
> > > to hit this.
> > This is an internal consistency check. An entry will be added to the 
> > `m_unwind_data->win` map only if it was already parsed successfully down in 
> > `ParseUnwindData`. This is parsing the same data once more, so it should 
> > always succeed.
> > 
> > Now the next question is, why parse the same data twice? :)
> > The first parse is to build an index of the ranges covered by the breakpad 
> > file. In the second pass we actually parse the undwind data. Theoretically 
> > we could avoid the second parse if we stored more data in the first one. 
> > However, here I am operating under the assumption that most record will not 
> > be touched, so it's worth to save some space for *each* record for the 
> > price of having to parse twice *some* of them. This seems like a good 
> > tradeoff intuitively, but I am don't have hard data to back that up.
> > 
> > Also, the case was much stronger for STACK CFI records (which do the same 
> > thing), as there I only have to put the STACK CFI INIT records into the map 
> > (and each INIT record is followed by a potentially large number of non-INIT 
> > records). STACK WIN records don't have an INIT records, so I have to insert 
> > all of them anyway, which makes the savings smaller, but it still seems 
> > worth it.
> Cool.  Could you just add a comment at the assertion that says a short 
> version of that.  For example, "We've already parsed it once, so it shouldn't 
> fail this time."
Will do. I'll also add the comment to the STACK CFI version of this function.


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

https://reviews.llvm.org/D67067



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


[Lldb-commits] [lldb] r371018 - Obliterate LLDB_CONFIGURATION_BUILDANDINTEGRATION

2019-09-05 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Sep  5 00:09:31 2019
New Revision: 371018

URL: http://llvm.org/viewvc/llvm-project?rev=371018&view=rev
Log:
Obliterate LLDB_CONFIGURATION_BUILDANDINTEGRATION

Summary:
With the XCode project gone, there doesn't seem to be anything setting
this macro anymore -- and the macro wasn't doing much anyway.

Reviewers: jingham, sgraenitz

Subscribers: emaste, lldb-commits

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

Modified:
lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
lldb/trunk/source/Plugins/Process/POSIX/CrashReason.cpp
lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp

Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp?rev=371018&r1=371017&r2=371018&view=diff
==
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp Thu Sep  5 
00:09:31 2019
@@ -37,9 +37,6 @@
 using namespace lldb;
 using namespace lldb_private;
 
-// We disable the tracing of ptrace calls for integration builds to avoid the
-// additional indirection and checks.
-#ifndef LLDB_CONFIGURATION_BUILDANDINTEGRATION
 // Wrapper for ptrace to catch errors and log calls.
 
 const char *Get_PT_IO_OP(int op) {
@@ -137,9 +134,6 @@ extern long PtraceWrapper(int req, lldb:
 
 #define PTRACE(req, pid, addr, data)   
\
   PtraceWrapper((req), (pid), (addr), (data), #req, __FILE__, __LINE__)
-#else
-PtraceWrapper((req), (pid), (addr), (data))
-#endif
 
 // Static implementations of ProcessMonitor::ReadMemory and
 // ProcessMonitor::WriteMemory.  This enables mutual recursion between these

Modified: lldb/trunk/source/Plugins/Process/POSIX/CrashReason.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/CrashReason.cpp?rev=371018&r1=371017&r2=371018&view=diff
==
--- lldb/trunk/source/Plugins/Process/POSIX/CrashReason.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/CrashReason.cpp Thu Sep  5 00:09:31 
2019
@@ -229,11 +229,6 @@ std::string GetCrashReasonString(CrashRe
 }
 
 const char *CrashReasonAsString(CrashReason reason) {
-#ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION
-  // Just return the code in ascii for integration builds.
-  chcar str[8];
-  sprintf(str, "%d", reason);
-#else
   const char *str = nullptr;
 
   switch (reason) {
@@ -315,8 +310,6 @@ const char *CrashReasonAsString(CrashRea
 str = "eFloatSubscriptRange";
 break;
   }
-#endif
-
   return str;
 }
 

Modified: lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp?rev=371018&r1=371017&r2=371018&view=diff
==
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp Thu Sep  5 
00:09:31 2019
@@ -15,11 +15,6 @@ const char *ProcessMessage::PrintCrashRe
 }
 
 const char *ProcessMessage::PrintKind(Kind kind) {
-#ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION
-  // Just return the code in ascii for integration builds.
-  chcar str[8];
-  sprintf(str, "%d", reason);
-#else
   const char *str = nullptr;
 
   switch (kind) {
@@ -60,8 +55,6 @@ const char *ProcessMessage::PrintKind(Ki
 str = "eExecMessage";
 break;
   }
-#endif
-
   return str;
 }
 


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


[Lldb-commits] [PATCH] D66742: Obliterate LLDB_CONFIGURATION_BUILDANDINTEGRATION

2019-09-05 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371018: Obliterate LLDB_CONFIGURATION_BUILDANDINTEGRATION 
(authored by labath, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66742

Files:
  lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
  lldb/trunk/source/Plugins/Process/POSIX/CrashReason.cpp
  lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp


Index: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
===
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
@@ -37,9 +37,6 @@
 using namespace lldb;
 using namespace lldb_private;
 
-// We disable the tracing of ptrace calls for integration builds to avoid the
-// additional indirection and checks.
-#ifndef LLDB_CONFIGURATION_BUILDANDINTEGRATION
 // Wrapper for ptrace to catch errors and log calls.
 
 const char *Get_PT_IO_OP(int op) {
@@ -137,9 +134,6 @@
 
 #define PTRACE(req, pid, addr, data)   
\
   PtraceWrapper((req), (pid), (addr), (data), #req, __FILE__, __LINE__)
-#else
-PtraceWrapper((req), (pid), (addr), (data))
-#endif
 
 // Static implementations of ProcessMonitor::ReadMemory and
 // ProcessMonitor::WriteMemory.  This enables mutual recursion between these
Index: lldb/trunk/source/Plugins/Process/POSIX/CrashReason.cpp
===
--- lldb/trunk/source/Plugins/Process/POSIX/CrashReason.cpp
+++ lldb/trunk/source/Plugins/Process/POSIX/CrashReason.cpp
@@ -229,11 +229,6 @@
 }
 
 const char *CrashReasonAsString(CrashReason reason) {
-#ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION
-  // Just return the code in ascii for integration builds.
-  chcar str[8];
-  sprintf(str, "%d", reason);
-#else
   const char *str = nullptr;
 
   switch (reason) {
@@ -315,8 +310,6 @@
 str = "eFloatSubscriptRange";
 break;
   }
-#endif
-
   return str;
 }
 
Index: lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp
===
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp
@@ -15,11 +15,6 @@
 }
 
 const char *ProcessMessage::PrintKind(Kind kind) {
-#ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION
-  // Just return the code in ascii for integration builds.
-  chcar str[8];
-  sprintf(str, "%d", reason);
-#else
   const char *str = nullptr;
 
   switch (kind) {
@@ -60,8 +55,6 @@
 str = "eExecMessage";
 break;
   }
-#endif
-
   return str;
 }
 


Index: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
===
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
@@ -37,9 +37,6 @@
 using namespace lldb;
 using namespace lldb_private;
 
-// We disable the tracing of ptrace calls for integration builds to avoid the
-// additional indirection and checks.
-#ifndef LLDB_CONFIGURATION_BUILDANDINTEGRATION
 // Wrapper for ptrace to catch errors and log calls.
 
 const char *Get_PT_IO_OP(int op) {
@@ -137,9 +134,6 @@
 
 #define PTRACE(req, pid, addr, data)   \
   PtraceWrapper((req), (pid), (addr), (data), #req, __FILE__, __LINE__)
-#else
-PtraceWrapper((req), (pid), (addr), (data))
-#endif
 
 // Static implementations of ProcessMonitor::ReadMemory and
 // ProcessMonitor::WriteMemory.  This enables mutual recursion between these
Index: lldb/trunk/source/Plugins/Process/POSIX/CrashReason.cpp
===
--- lldb/trunk/source/Plugins/Process/POSIX/CrashReason.cpp
+++ lldb/trunk/source/Plugins/Process/POSIX/CrashReason.cpp
@@ -229,11 +229,6 @@
 }
 
 const char *CrashReasonAsString(CrashReason reason) {
-#ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION
-  // Just return the code in ascii for integration builds.
-  chcar str[8];
-  sprintf(str, "%d", reason);
-#else
   const char *str = nullptr;
 
   switch (reason) {
@@ -315,8 +310,6 @@
 str = "eFloatSubscriptRange";
 break;
   }
-#endif
-
   return str;
 }
 
Index: lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp
===
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp
@@ -15,11 +15,6 @@
 }
 
 const char *ProcessMessage::PrintKind(Kind kind) {
-#ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION
-  // Just return the code in ascii for integration builds.
-  chcar str[8];
-  sprintf(str, "%d", reason);
-#else
   const char *str = nullptr;
 
 

[Lldb-commits] [PATCH] D65677: [VirtualFileSystem] Make the RedirectingFileSystem hold on to its own working directory.

2019-09-05 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Though I am not very familiar VFS, this seems like the most intuitive solution 
out of everything that we had so far. But... shouldn't you also check that the 
directory you're `chdir`-ing into "exists" before you actually change the cwd? 
Also, the chdir operation should probably follow the usual semantics of a 
non-absolute chdir path being treated as relative to the previous cwd. And 
lastly :), what is the initial cwd value? Since previously the class shared the 
cwd with the underlying filesystem, one option might be to fetch the initial 
cwd from there (though I don't know if that is actually desired). Another 
option might be to just pick the first directory in the yaml file or 
something...


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D65677



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


[Lldb-commits] [PATCH] D67173: [dotest] Centralize initialization commands even more

2019-09-05 Thread Pavel Labath via Phabricator via lldb-commits
labath marked an inline comment as done.
labath added inline comments.



Comment at: packages/Python/lldbsuite/test/lldbtest.py:709
+if lldbtest_config.inferior_env:
+commands.append('settings set target.env-vars ' +
+lldbtest_config.inferior_env)

JDevlieghere wrote:
> I'm curious why you changed this to use `+` instead of `format`? 
In that moment, it seemed better to me because it is shorter, so I did it as a 
drive-by. Though now, it's not clear to me that it is really an improvement. 
I'll just put that back...


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

https://reviews.llvm.org/D67173



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


[Lldb-commits] [lldb] r371019 - [dotest] Centralize initialization commands even more

2019-09-05 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Sep  5 00:35:45 2019
New Revision: 371019

URL: http://llvm.org/viewvc/llvm-project?rev=371019&view=rev
Log:
[dotest] Centralize initialization commands even more

Summary:
In r367234 we introduced a central place to hold the set up commands for
the various ways we have of launching lldb. However, a number of
commands still remained outside of that.

This patch moves the remaining set up commands into this function, which
allows us to remove manual clang module path setting code in
TestBatchMode.

One unfortunate victim of this approach is TestSTTYBeforeAndAfter which,
due to how it launches lldb (pexpect->expect->lldb), fails get the
quoting right. It would be possible to fix the quoting there, it would be a bit
icky, and none of the commands in this list are really relevant for what this
test is doing, so I just remove the commands outright.

Reviewers: JDevlieghere, jankratochvil

Subscribers: lldb-commits

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

Modified:
lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py?rev=371019&r1=371018&r2=371019&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py 
(original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py 
Thu Sep  5 00:35:45 2019
@@ -24,11 +24,9 @@ class DriverBatchModeTest(PExpectTest):
 self.build()
 
 exe = self.getBuildArtifact("a.out")
-module_cache = self.getBuildArtifact("module.cache")
 
 # Pass CRASH so the process will crash and stop in batch mode.
 extra_args = ['-b',
-'-o', "settings set symbols.clang-modules-cache-path 
'%s'"%module_cache,
 '-o', 'break set -n main',
 '-o', 'run',
 '-o', 'continue',
@@ -57,11 +55,9 @@ class DriverBatchModeTest(PExpectTest):
 self.build()
 
 exe = self.getBuildArtifact("a.out")
-module_cache = self.getBuildArtifact("module.cache")
 
 # Now do it again, and make sure if we don't crash, we quit:
 extra_args = ['-b',
-'-o', "settings set symbols.clang-modules-cache-path 
'%s'"%module_cache,
 '-o', 'break set -n main',
 '-o', 'run',
 '-o', 'continue',
@@ -96,7 +92,6 @@ class DriverBatchModeTest(PExpectTest):
 self.setTearDownCleanup()
 
 exe = self.getBuildArtifact("a.out")
-module_cache = self.getBuildArtifact("module.cache")
 
 # Start up the process by hand, attach to it, and wait for its 
completion.
 # Attach is funny, since it looks like it stops with a signal on most 
Unixen so
@@ -117,7 +112,6 @@ class DriverBatchModeTest(PExpectTest):
 
 extra_args = [
 '-b',
-'-o', "settings set symbols.clang-modules-cache-path 
'%s'"%module_cache,
 '-o', 'process attach -p %d'%victim_pid,
 '-o', "breakpoint set --file '%s' -p 'Stop here to unset 
keep_waiting' -N keep_waiting"%self.source,
 '-o', 'continue',

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=371019&r1=371018&r2=371019&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Thu Sep  5 00:35:45 
2019
@@ -684,16 +684,31 @@ class Base(unittest2.TestCase):
 """Return absolute path to a file in the test's source directory."""
 return os.path.join(self.getSourceDir(), name)
 
-@staticmethod
-def setUpCommands():
-return [
+@classmethod
+def setUpCommands(cls):
+commands = [
 # Disable Spotlight lookup. The testsuite creates
 # different binaries with the same UUID, because they only
 # differ in the debug info, which is not being hashed.
 "settings set symbols.enable-external-lookup false",
 
 # Testsuite runs in parallel and the host can have also other load.
-"settings set plugin.process.gdb-remote.packet-timeout 60"]
+"settings set plugin.process.gdb-remote.packet-timeout 60",
+
+'settings set symbols.clang-modules-cache-path "{}"'.format(
+configuration.module_cache_dir),
+"settings set use-color fal

[Lldb-commits] [PATCH] D67173: [dotest] Centralize initialization commands even more

2019-09-05 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371019: [dotest] Centralize initialization commands even 
more (authored by labath, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67173?vs=218694&id=218853#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67173

Files:
  lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
  lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
  lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py
  
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py

Index: lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py
+++ lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py
@@ -73,7 +73,7 @@
 child.logfile_read = None
 
 # Invoke the lldb command.
-child.sendline('%s %s' % (lldbtest_config.lldbExec, self.lldbOption))
+child.sendline(lldbtest_config.lldbExec)
 child.expect_exact(lldb_prompt)
 
 # Immediately quit.
Index: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
@@ -684,16 +684,31 @@
 """Return absolute path to a file in the test's source directory."""
 return os.path.join(self.getSourceDir(), name)
 
-@staticmethod
-def setUpCommands():
-return [
+@classmethod
+def setUpCommands(cls):
+commands = [
 # Disable Spotlight lookup. The testsuite creates
 # different binaries with the same UUID, because they only
 # differ in the debug info, which is not being hashed.
 "settings set symbols.enable-external-lookup false",
 
 # Testsuite runs in parallel and the host can have also other load.
-"settings set plugin.process.gdb-remote.packet-timeout 60"]
+"settings set plugin.process.gdb-remote.packet-timeout 60",
+
+'settings set symbols.clang-modules-cache-path "{}"'.format(
+configuration.module_cache_dir),
+"settings set use-color false",
+]
+# Make sure that a sanitizer LLDB's environment doesn't get passed on.
+if cls.platformContext and cls.platformContext.shlib_environment_var in os.environ:
+commands.append('settings set target.env-vars {}='.format(
+cls.platformContext.shlib_environment_var))
+
+# Set environment variables for the inferior.
+if lldbtest_config.inferior_env:
+commands.append('settings set target.env-vars {}'.format(
+lldbtest_config.inferior_env))
+return commands
 
 def setUp(self):
 """Fixture for unittest test case setup.
@@ -1851,25 +1866,9 @@
 # decorators.
 Base.setUp(self)
 
-# Set the clang modules cache path used by LLDB.
-self.runCmd(
-'settings set symbols.clang-modules-cache-path "{}"'.format(
-configuration.module_cache_dir))
-
 for s in self.setUpCommands():
 self.runCmd(s)
 
-# Disable color.
-self.runCmd("settings set use-color false")
-
-# Make sure that a sanitizer LLDB's environment doesn't get passed on.
-if 'DYLD_LIBRARY_PATH' in os.environ:
-self.runCmd('settings set target.env-vars DYLD_LIBRARY_PATH=')
-
-# Set environment variables for the inferior.
-if lldbtest_config.inferior_env:
-self.runCmd('settings set target.env-vars {}'.format(lldbtest_config.inferior_env))
-
 if "LLDB_MAX_LAUNCH_COUNT" in os.environ:
 self.maxLaunchCount = int(os.environ["LLDB_MAX_LAUNCH_COUNT"])
 
Index: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -12,7 +12,7 @@
 self.assertTrue(os.path.exists(self.lldbVSCodeExec),
 'lldb-vscode must exist')
 self.vscode = vscode.DebugAdaptor(
-executable=self.lldbVSCodeExec, init_commands=Base.setUpCommands())
+executable=self.lldbVSCodeExec, init_commands=self.setUpCommands())
 
 def build_and_create_debug_adaptor(self):
 self.build()
Index: lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatc

[Lldb-commits] [lldb] r371020 - [dotest] Remove top-level Makefile

2019-09-05 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Sep  5 00:38:55 2019
New Revision: 371020

URL: http://llvm.org/viewvc/llvm-project?rev=371020&view=rev
Log:
[dotest] Remove top-level Makefile

This appears to be a really ancient  way of running the test suite. It
is also completely disfunctional now, and probably has been for a long
time.

Removed:
lldb/trunk/packages/Python/lldbsuite/test/Makefile

Removed: lldb/trunk/packages/Python/lldbsuite/test/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/Makefile?rev=371019&view=auto
==
--- lldb/trunk/packages/Python/lldbsuite/test/Makefile (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/Makefile (removed)
@@ -1,32 +0,0 @@
-include $(LLDB_LEVEL)/Makefile
-
-.PHONY: programs
-
-all:: check-local
-
-#--
-# Make all of the test programs
-#--
-programs:
-   find . -type d -depth 1 | xargs -J % find % \
-   -name Makefile \
-   -exec echo \; \
-   -exec echo make -f '{}' \; \
-   -execdir make \;
-
-#--
-# Clean all of the test programs
-#--
-clean::
-   find . -type d -depth 1 | xargs -J % find % \
-   -name Makefile \
-   -exec echo \; \
-   -exec echo make -f '{}' clean \; \
-   -execdir make clean \;
-
-#--
-# Run the tests
-#--
-check-local::
-   rm -rf lldb-test-traces
-   python $(PROJ_SRC_DIR)/dotest.py --executable $(ToolDir)/lldb -q -s 
lldb-test-traces -u CXXFLAGS -u CFLAGS -C $(subst ccache,,$(CC))


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


[Lldb-commits] [lldb] r371028 - [lldb][NFC] Stabilize gui/basic test by waiting on prompt

2019-09-05 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Sep  5 01:45:20 2019
New Revision: 371028

URL: http://llvm.org/viewvc/llvm-project?rev=371028&view=rev
Log:
[lldb][NFC] Stabilize gui/basic test by waiting on prompt

We should wait on the GUI to exit before tearing down the test.

Modified:
lldb/trunk/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py?rev=371028&r1=371027&r2=371028&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py 
(original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py 
Thu Sep  5 01:45:20 2019
@@ -56,4 +56,5 @@ class BasicGuiCommandTest(PExpectTest):
 # Press escape to quit the gui
 self.child.send(escape_key)
 
+self.expect_prompt()
 self.quit()


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


[Lldb-commits] [PATCH] D66994: [lldb][CMake] Fix windows-x86-debug compilation with python enabled using multi-target generator

2019-09-05 Thread Leonid Mashinskiy via Phabricator via lldb-commits
leonid.mashinskiy updated this revision to Diff 218877.
leonid.mashinskiy added a comment.

Extracted python lookup logic into function


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D66994

Files:
  cmake/modules/LLDBConfig.cmake

Index: cmake/modules/LLDBConfig.cmake
===
--- cmake/modules/LLDBConfig.cmake
+++ cmake/modules/LLDBConfig.cmake
@@ -134,6 +134,48 @@
 #locate 64-bit Python libraries.
 # This function is designed to address those limitations.  Currently it only partially
 # addresses them, but it can be improved and extended on an as-needed basis.
+function(find_python_libs_windows_helper LOOKUP_DEBUG OUT_EXE_PATH_VARNAME OUT_LIB_PATH_VARNAME OUT_DLL_PATH_VARNAME OUT_VERSION_VARNAME)
+  if(LOOKUP_DEBUG)
+  set(POSTFIX "_d")
+  else()
+  set(POSTFIX "")
+  endif()
+  
+  file(TO_CMAKE_PATH "${PYTHON_HOME}/python${POSTFIX}.exe"   PYTHON_EXE)
+  file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/${PYTHONLIBS_BASE_NAME}${POSTFIX}.lib" PYTHON_LIB)
+  file(TO_CMAKE_PATH "${PYTHON_HOME}/${PYTHONLIBS_BASE_NAME}${POSTFIX}.dll"  PYTHON_DLL)
+
+  foreach(component PYTHON_EXE;PYTHON_LIB;PYTHON_DLL)
+if(NOT EXISTS ${${component}})
+  message(WARNING "Unable to find ${component}")
+  unset(${component})
+endif()
+  endforeach()
+
+  if (NOT PYTHON_EXE OR NOT PYTHON_LIB OR NOT PYTHON_DLL)
+message(WARNING "Unable to find all Python components.  Python support will be disabled for this build.")
+set(LLDB_DISABLE_PYTHON 1 PARENT_SCOPE)
+return()
+  endif()
+
+  # Find the version of the Python interpreter.
+  execute_process(COMMAND "${PYTHON_EXE}" -c
+  "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:3]]))"
+  OUTPUT_VARIABLE PYTHON_VERSION_OUTPUT
+  RESULT_VARIABLE PYTHON_VERSION_RESULT
+  ERROR_QUIET)
+
+  if(PYTHON_VERSION_RESULT)
+message(WARNING "Unable to retrieve Python executable version")
+set(PYTHON_VERSION_OUTPUT "")
+  endif()
+  
+  set(${OUT_EXE_PATH_VARNAME} ${PYTHON_EXE} PARENT_SCOPE)
+  set(${OUT_LIB_PATH_VARNAME} ${PYTHON_LIB} PARENT_SCOPE)
+  set(${OUT_DLL_PATH_VARNAME} ${PYTHON_DLL} PARENT_SCOPE)
+  set(${OUT_VERSION_VARNAME}  ${PYTHON_VERSION_OUTPUT} PARENT_SCOPE)
+endfunction()
+
 function(find_python_libs_windows)
   if ("${PYTHON_HOME}" STREQUAL "")
 message(WARNING "LLDB embedded Python on Windows requires specifying a value for PYTHON_HOME.  Python support disabled.")
@@ -161,55 +203,65 @@
   file(TO_CMAKE_PATH "${PYTHON_HOME}" PYTHON_HOME)
   # TODO(compnerd) when CMake Policy `CMP0091` is set to NEW, we should use
   # if(CMAKE_MSVC_RUNTIME_LIBRARY MATCHES MultiThreadedDebug)
-  if(CMAKE_BUILD_TYPE STREQUAL Debug)
-file(TO_CMAKE_PATH "${PYTHON_HOME}/python_d.exe" PYTHON_EXE)
-file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/${PYTHONLIBS_BASE_NAME}_d.lib" PYTHON_LIB)
-file(TO_CMAKE_PATH "${PYTHON_HOME}/${PYTHONLIBS_BASE_NAME}_d.dll" PYTHON_DLL)
-  else()
-file(TO_CMAKE_PATH "${PYTHON_HOME}/python.exe" PYTHON_EXE)
-file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/${PYTHONLIBS_BASE_NAME}.lib" PYTHON_LIB)
-file(TO_CMAKE_PATH "${PYTHON_HOME}/${PYTHONLIBS_BASE_NAME}.dll" PYTHON_DLL)
-  endif()
-
-  foreach(component PYTHON_EXE;PYTHON_LIB;PYTHON_DLL)
-if(NOT EXISTS ${${component}})
-  message(WARNING "unable to find ${component}")
-  unset(${component})
+  if(NOT DEFINED CMAKE_BUILD_TYPE)
+# Multi-target generator was selected (like Visual Studio or Xcode) where no concrete build type was passed
+# Lookup for both debug and release python installations
+find_python_libs_windows_helper(TRUE  PYTHON_DEBUG_EXE   PYTHON_DEBUG_LIB   PYTHON_DEBUG_DLL   PYTHON_DEBUG_VERSION_STRING)
+find_python_libs_windows_helper(FALSE PYTHON_RELEASE_EXE PYTHON_RELEASE_LIB PYTHON_RELEASE_DLL PYTHON_RELEASE_VERSION_STRING)
+if(LLDB_DISABLE_PYTHON)
+  set(LLDB_DISABLE_PYTHON 1 PARENT_SCOPE)
+  return()
 endif()
-  endforeach()
+
+# We should have been found both debug and release python here
+# Now check that their versions are equal
+if(NOT PYTHON_DEBUG_VERSION_STRING STREQUAL PYTHON_RELEASE_VERSION_STRING)
+  message(FATAL_ERROR "Python versions for debug (${PYTHON_DEBUG_VERSION_STRING}) and release (${PYTHON_RELEASE_VERSION_STRING}) are different."
+  "Python installation is corrupted")
+endif ()
 
-  if (NOT PYTHON_EXE OR NOT PYTHON_LIB OR NOT PYTHON_DLL)
-message(WARNING "Unable to find all Python components.  Python support will be disabled for this build.")
-set(LLDB_DISABLE_PYTHON 1 PARENT_SCOPE)
-return()
+set(PYTHON_EXECUTABLE $<$:${PYTHON_DEBUG_EXE}>$<$>:${PYTHON_RELEASE_EXE}>)
+set(PYTHON_LIBRARY$<$:${PYTHON_DEBUG_LIB}>$<$>:${PYTHON_RELEASE_LIB}>)
+set(PYTHON_DLL$<$:${PYTHON_DEBUG_DLL}>

[Lldb-commits] [PATCH] D66994: [lldb][CMake] Fix windows-x86-debug compilation with python enabled using multi-target generator

2019-09-05 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Thanks. The new version seems fine to me. I'll leave it for the windows folks 
to have the final say on this..


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D66994



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


[Lldb-commits] [PATCH] D67022: Enhance SymbolFileDWARF::ParseDeclsForContext performance

2019-09-05 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Thanks. The code looks fine to me. Losing the ability to unit test is a bit of 
a pity, but since test was pretty icky to begin with, I can't say I'm going to 
miss it too much...
One way we could possibly test this is with a full scale test via the "target 
modules dump ast" command. So, the idea would be to run to process to some 
point, evaluate some expressions, run "target modules dump ast" and check the 
things are in the output (or that they are *not* there).

It's hard to say what exactly you should be checking for, since the assumption 
is that we are not changing the behavior here, and so the existing tests should 
cover that in theory, but the "dump ast" command is a new thing, we don't have 
too many of tests for it, and so any tests you add will be useful, even if 
they're not specifically targeting the thing you fix in this patch. If you are 
able to test the thing that the previous patch fixed in this way, than that 
would be great though. I'm not 100% sure it can be done, but since (IIUC) the 
bug/problem was about parsing too many things, I would expect that would 
manifest itself in some additional entries showing up in the parsed ast.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67022



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


[Lldb-commits] [PATCH] D67222: [Windows] Added support of watchpoints to `NativeProcessWindows`

2019-09-05 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov created this revision.
aleksandr.urakov added reviewers: asmith, amccarth, stella.stamenova.
aleksandr.urakov added a project: LLDB.
Herald added subscribers: lldb-commits, JDevlieghere, jfb.

This patch adds support of watchpoints to the new `NativeProcessWindows` 
plugin. The same tests as in D67168  pass with 
these changes when the old plugin is turned off, so they will cover this 
functionality when the old plugin is gone.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67222

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

Index: lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.cpp
@@ -132,11 +132,30 @@
 
 Status NativeThreadWindows::SetWatchpoint(lldb::addr_t addr, size_t size,
   uint32_t watch_flags, bool hardware) {
-  return Status("unimplemented.");
+  if (!hardware)
+return Status("not implemented");
+  if (m_state == eStateLaunching)
+return Status();
+  Status error = RemoveWatchpoint(addr);
+  if (error.Fail())
+return error;
+  uint32_t wp_index =
+  m_reg_context_up->SetHardwareWatchpoint(addr, size, watch_flags);
+  if (wp_index == LLDB_INVALID_INDEX32)
+return Status("Setting hardware watchpoint failed.");
+  m_watchpoint_index_map.insert({addr, wp_index});
+  return Status();
 }
 
 Status NativeThreadWindows::RemoveWatchpoint(lldb::addr_t addr) {
-  return Status("unimplemented");
+  auto wp = m_watchpoint_index_map.find(addr);
+  if (wp == m_watchpoint_index_map.end())
+return Status();
+  uint32_t wp_index = wp->second;
+  m_watchpoint_index_map.erase(wp);
+  if (m_reg_context_up->ClearHardwareWatchpoint(wp_index))
+return Status();
+  return Status("Clearing hardware watchpoint failed.");
 }
 
 Status NativeThreadWindows::SetHardwareBreakpoint(lldb::addr_t addr,
Index: lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.h
===
--- lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.h
+++ lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.h
@@ -50,10 +50,6 @@
 
   Status ClearAllHardwareWatchpoints() override;
 
-  Status SetHardwareWatchpointWithIndex(lldb::addr_t addr, size_t size,
-uint32_t watch_flags,
-uint32_t wp_index);
-
   uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
  uint32_t watch_flags) override;
 
@@ -63,17 +59,21 @@
 
 protected:
   Status GPRRead(const uint32_t reg, RegisterValue ®_value);
-
   Status GPRWrite(const uint32_t reg, const RegisterValue ®_value);
 
   Status FPRRead(const uint32_t reg, RegisterValue ®_value);
-
   Status FPRWrite(const uint32_t reg, const RegisterValue ®_value);
 
+  Status DRRead(const uint32_t reg, RegisterValue ®_value);
+  Status DRWrite(const uint32_t reg, const RegisterValue ®_value);
+
 private:
-  bool IsGPR(uint32_t reg_index) const;
+  Status ApplyHardwareBreakpoint(uint32_t wp_index, lldb::addr_t addr,
+ size_t size, uint32_t flags);
 
+  bool IsGPR(uint32_t reg_index) const;
   bool IsFPR(uint32_t reg_index) const;
+  bool IsDR(uint32_t reg_index) const;
 };
 
 } // namespace lldb_private
Index: lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp
+++ lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp
@@ -101,11 +101,11 @@
   // Register context for a WoW64 application.
   if (target_arch.GetAddressByteSize() == 4)
 return std::make_unique(target_arch,
- native_thread);
+native_thread);
 
   // Register context for a native 64-bit application.
   return std::make_unique(target_arch,
-nativ

[Lldb-commits] [PATCH] D67168: [Windows] Add support of watchpoints to `ProcessWindows`

2019-09-05 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov updated this revision to Diff 218897.
aleksandr.urakov added a comment.

Determine whether 8-byte watchpoints are supported or not statically.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67168

Files:
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchlocation/TestWatchLocation.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchpoint/TestMyFirstWatchpoint.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/multiple_hits/TestMultipleHits.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/condition/TestWatchpointConditionCmd.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_on_vectors/TestValueOfVectorVariable.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_size/TestWatchpointSizes.py
  lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
  lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.h
  lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
  lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
  lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
  lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp

Index: lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
+++ lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
@@ -267,9 +267,7 @@
   }
 
   // Physically update the registers in the target process.
-  TargetThreadWindows &wthread = static_cast(m_thread);
-  return ::SetThreadContext(
-  wthread.GetHostThread().GetNativeThread().GetSystemHandle(), &m_context);
+  return ApplyAllRegisterValues();
 }
 
 bool RegisterContextWindows_x86::ReadRegisterHelper(
Index: lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -532,9 +532,7 @@
   }
 
   // Physically update the registers in the target process.
-  TargetThreadWindows &wthread = static_cast(m_thread);
-  return ::SetThreadContext(
-  wthread.GetHostThread().GetNativeThread().GetSystemHandle(), &m_context);
+  return ApplyAllRegisterValues();
 }
 
 #endif // defined(__x86_64__) || defined(_M_X64)
Index: lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
===
--- lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
+++ lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
@@ -33,28 +33,28 @@
   uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
uint32_t num) override;
 
-  // Subclasses can override these functions if desired
-  uint32_t NumSupportedHardwareBreakpoints() override;
-
-  uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
-
-  bool ClearHardwareBreakpoint(uint32_t hw_idx) override;
-
-  uint32_t NumSupportedHardwareWatchpoints() override;
+  bool HardwareSingleStep(bool enable) override;
 
- 

[Lldb-commits] [PATCH] D67168: [Windows] Add support of watchpoints to `ProcessWindows`

2019-09-05 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov marked 3 inline comments as done.
aleksandr.urakov added inline comments.



Comment at: 
lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp:82
 
-bool RegisterContextWindows::ClearHardwareBreakpoint(uint32_t hw_idx) {
-  return false;
-}
+  if (!size || size > 8 || size & (size - 1))
+return false;

labath wrote:
> aleksandr.urakov wrote:
> > zturner wrote:
> > > amccarth wrote:
> > > > Clever!  It took me a minute or two to figure out what the point of 
> > > > that was checking.  Perhaps a comment to explain?
> > > Isn't this equivalent to:
> > > 
> > > ```
> > > switch (size)
> > > {
> > > case 1:
> > > case 2:
> > > case 4:
> > > case 8:
> > > break;
> > > default:
> > > return false;
> > > }
> > > ```
> > > 
> > > ?  That definitely seems much clearer.
> > > 
> > > I'm also pretty sure that on x86 you can't add a 64-bit watch, So you'd 
> > > have to do something different depending on the target bitness if you 
> > > want this to be correct for x86.
> > Yes, it is equivalent, I've chosen the previous form due to its less 
> > verbosity. But you are right, clearance is better (especially after adding 
> > the architecture check). Fixed it, thanks!
>  or, you could just use `llvm::isPowerOf2_32` from `MathExtras.h`.
I didn't know about the such function, thanks! But I think that Zachary's 
approach is better in exactly this case (taking in account the bitness check).



Comment at: 
lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp:87-89
+#if defined(_M_AMD64)
+  case 8:
+#endif

In the old plugin a required register context is created based on the target 
architecture check and the bitness of LLDB, but cross-targets (e.g. WoW64) are 
not supported, and even the type of `m_context` is determined statically. So we 
can safely determine the max watchpoint size statically too.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67168



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


[Lldb-commits] [lldb] r371077 - [lldb][NFC] Add dimensions to pexpect tests failing on sanitizer bot

2019-09-05 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Sep  5 07:51:23 2019
New Revision: 371077

URL: http://llvm.org/viewvc/llvm-project?rev=371077&view=rev
Log:
[lldb][NFC] Add dimensions to pexpect tests failing on sanitizer bot

I'm still unable to reproduce this locally, so let's see if this
is enough to make the bots happy. The missing dimension parameter
seems to be the biggest difference between these tests and
TestIOHandlerCompletion.py which runs just fine on the same bot,
so that's the motivation for trying this out.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py
lldb/trunk/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py?rev=371077&r1=371076&r2=371077&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py
 Thu Sep  5 07:51:23 2019
@@ -15,7 +15,7 @@ class MultilineCompletionTest(PExpectTes
 """Test that we can complete a simple multiline expression"""
 self.build()
 
-self.launch(executable=self.getBuildArtifact("a.out"))
+self.launch(executable=self.getBuildArtifact("a.out"), 
dimensions=(100,500))
 self.expect("b main", substrs=["Breakpoint 1", "address ="])
 self.expect("run", substrs=["stop reason ="])
 

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py?rev=371077&r1=371076&r2=371077&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py 
(original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py 
Thu Sep  5 07:51:23 2019
@@ -15,7 +15,7 @@ class BasicGuiCommandTest(PExpectTest):
 def test_gui(self):
 self.build()
 
-self.launch(executable=self.getBuildArtifact("a.out"))
+self.launch(executable=self.getBuildArtifact("a.out"), 
dimensions=(100,500))
 self.expect('br set -f main.c -p "// Break here"', 
substrs=["Breakpoint 1", "address ="])
 self.expect("run", substrs=["stop reason ="])
 


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


[Lldb-commits] [PATCH] D67227: [lldb] Extend and document TestIRInterpreter.py

2019-09-05 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: davide.
Herald added subscribers: lldb-commits, JDevlieghere.
Herald added a project: LLDB.

There are a bunch of arithmetic and comparison instructions supported by the 
IRInterpreter and we
currently don't test these at all in the test suit. This patch extends the 
IRInterpreter test to try out these operations
with different types and values. Also documents the test case a bit while I'm 
at it.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67227

Files:
  
lldb/packages/Python/lldbsuite/test/commands/expression/ir-interpreter/TestIRInterpreter.py

Index: lldb/packages/Python/lldbsuite/test/commands/expression/ir-interpreter/TestIRInterpreter.py
===
--- lldb/packages/Python/lldbsuite/test/commands/expression/ir-interpreter/TestIRInterpreter.py
+++ lldb/packages/Python/lldbsuite/test/commands/expression/ir-interpreter/TestIRInterpreter.py
@@ -40,6 +40,29 @@
 
 self.runCmd("run", RUN_SUCCEEDED)
 
+class Operator:
+def __init__(self, name):
+   self.name = name
+
+def can_handle_operands(self, lhs, rhs):
+"""True iff this operator can handle the variables as operands."""
+if self.name in ['<<', '>>']:
+# Shifting negative values doesn't work.
+if lhs.value <= 0:
+return False
+# Shifting longer than size of a type also doesn't work.
+if rhs.value <= 0 or rhs.value >= 7:
+return False
+return True
+
+
+class Variable:
+def __init__(self, uid, type, value):
+self.name = "$i_" + str(uid) + "_" + type.replace(" ", "_")
+self.value = value
+self.type = type
+self.decl_expr = type + " " + self.name + " = " + str(self.value)
+
 @add_test_categories(['pyapi'])
 # getpid() is POSIX, among other problems, see bug
 @expectedFailureAll(
@@ -50,35 +73,73 @@
 oslist=['linux'],
 archs=['arm'],
 bugnumber="llvm.org/pr27868")
-def test_ir_interpreter(self):
+def test_ir_interpreter_int_ops(self):
 self.build_and_run()
 
+# Normal expression options we use for JITed expressions.
 options = lldb.SBExpressionOptions()
 options.SetLanguage(lldb.eLanguageTypeC_plus_plus)
 
-set_up_expressions = ["int $i = 9", "int $j = 3", "int $k = 5"]
-
-expressions = ["$i + $j",
-   "$i - $j",
-   "$i * $j",
-   "$i / $j",
-   "$i % $k",
-   "$i << $j",
-   "$i & $j",
-   "$i | $j",
-   "$i ^ $j"]
-
-for expression in set_up_expressions:
-self.frame().EvaluateExpression(expression, options)
-
-for expression in expressions:
+# Expression options that prevent that we use the JIT.
+nojit_options = lldb.SBExpressionOptions()
+nojit_options.SetLanguage(lldb.eLanguageTypeC_plus_plus)
+nojit_options.SetAllowJIT(False)
+
+# List of operators the interpreter supports and we want to test.
+operators = ['+', '-', '*', '%', '/',
+ '<<', '>>', '&', '|', '^',
+ '>', '<', '>=', '<=', '!=', '==']
+operator_list = []
+for opname in operators:
+operator_list.append(self.Operator(opname))
+
+# Variable types that should be tested with the operators.
+types_to_test = ['int', 'unsigned int']
+
+# Values these variables can have.
+values_to_test = [255, 256, -1, 0, 1, 255, 256]
+
+# Id for every variable to give them unique names.
+uid = 0
+# Define a variable for every type and for every value in LLDB.
+variable_list = []
+for t in types_to_test:
+for value in values_to_test:
+v = self.Variable(uid, t, value)
+variable_list.append(v)
+interp_result = self.frame().EvaluateExpression(
+v.decl_expr, nojit_options).GetValueAsUnsigned()
+uid += 1
+
+# Create a list of expressions that use every operator.
+exprs_to_run = []
+for op in operator_list:
+# Try all combinations of variables with the operator.
+for var1 in variable_list:
+for var2 in variable_list:
+if not op.can_handle_operands(var1, var2):
+continue
+# Create an expression using the operator.
+expr = var1.name + " " + op.name + " " + var2.name
+# Resolve the variable values and add that as a comment
+# to the expression. This will be shown when the test fails.
+expr += " // " + str(var1

[Lldb-commits] [PATCH] D66994: [lldb][CMake] Fix windows-x86-debug compilation with python enabled using multi-target generator

2019-09-05 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth accepted this revision.
amccarth added a comment.
This revision is now accepted and ready to land.

Thanks for factoring out the duplication.

Fingers crossed.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D66994



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


[Lldb-commits] [PATCH] D66994: [lldb][CMake] Fix windows-x86-debug compilation with python enabled using multi-target generator

2019-09-05 Thread Leonid Mashinskiy via Phabricator via lldb-commits
leonid.mashinskiy added a comment.

Thanks for the review!

Can somebody commit this please because I don't have commit access?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D66994



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


[Lldb-commits] [PATCH] D67227: [lldb] Extend and document TestIRInterpreter.py

2019-09-05 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/commands/expression/ir-interpreter/TestIRInterpreter.py:54
+# Shifting longer than size of a type also doesn't work.
+if rhs.value <= 0 or rhs.value >= 7:
+return False

I may be missing something here but this looks like it should be `32` instead 
of `7` or rather `sizeof(int)*8`

When we say doesn't work do we mean undefined behavior?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67227



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


[Lldb-commits] [PATCH] D66994: [lldb][CMake] Fix windows-x86-debug compilation with python enabled using multi-target generator

2019-09-05 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added a comment.

Yes, I can commit it for you soon.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D66994



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


[Lldb-commits] [PATCH] D67230: Remove call to obsolete gethostbyname, using getaddrinfo

2019-09-05 Thread serge via Phabricator via lldb-commits
serge-sans-paille created this revision.
serge-sans-paille added a reviewer: k8stone.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

>From the man page:

> The  gethostbyname*()  and  gethostbyaddr*()  functions  are  obsolete.
>  Applications should use getaddrinfo(3) and getnameinfo(3) instead.

That's what I did, using the canonical name as a relevant entry, which looks 
like the closer match to the original call.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67230

Files:
  lldb/source/Host/posix/HostInfoPosix.cpp


Index: lldb/source/Host/posix/HostInfoPosix.cpp
===
--- lldb/source/Host/posix/HostInfoPosix.cpp
+++ lldb/source/Host/posix/HostInfoPosix.cpp
@@ -32,10 +32,16 @@
   char hostname[PATH_MAX];
   hostname[sizeof(hostname) - 1] = '\0';
   if (::gethostname(hostname, sizeof(hostname) - 1) == 0) {
-struct hostent *h = ::gethostbyname(hostname);
-if (h)
-  s.assign(h->h_name);
-else
+struct addrinfo hints;
+struct addrinfo *res = nullptr;
+std::memset(&hints, 0, sizeof(hints));
+hints.ai_flags = AI_CANONNAME;
+int err = ::getaddrinfo(hostname, nullptr, &hints, &res);
+if (err == 0) {
+  assert(res->ai_canonname && "getaddrinfo found a canonical name");
+  s.assign(res->ai_canonname);
+  freeaddrinfo(res);
+} else
   s.assign(hostname);
 return true;
   }


Index: lldb/source/Host/posix/HostInfoPosix.cpp
===
--- lldb/source/Host/posix/HostInfoPosix.cpp
+++ lldb/source/Host/posix/HostInfoPosix.cpp
@@ -32,10 +32,16 @@
   char hostname[PATH_MAX];
   hostname[sizeof(hostname) - 1] = '\0';
   if (::gethostname(hostname, sizeof(hostname) - 1) == 0) {
-struct hostent *h = ::gethostbyname(hostname);
-if (h)
-  s.assign(h->h_name);
-else
+struct addrinfo hints;
+struct addrinfo *res = nullptr;
+std::memset(&hints, 0, sizeof(hints));
+hints.ai_flags = AI_CANONNAME;
+int err = ::getaddrinfo(hostname, nullptr, &hints, &res);
+if (err == 0) {
+  assert(res->ai_canonname && "getaddrinfo found a canonical name");
+  s.assign(res->ai_canonname);
+  freeaddrinfo(res);
+} else
   s.assign(hostname);
 return true;
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r371090 - Fix windows-x86-debug compilation with python enabled using multi-target generator

2019-09-05 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Thu Sep  5 10:22:30 2019
New Revision: 371090

URL: http://llvm.org/viewvc/llvm-project?rev=371090&view=rev
Log:
Fix windows-x86-debug compilation with python enabled using multi-target 
generator

[Patch by Leonid Mashinskiy]

Visual Studio CMake generator is multi-target and does not define
CMAKE_BUILD_TYPE, so Debug build on VS was failing due selection of release
python library. This patch reverts back some of latest changes and fixes
building by raw VS using CMake expression generators.

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

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=371090&r1=371089&r2=371090&view=diff
==
--- lldb/trunk/cmake/modules/LLDBConfig.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake Thu Sep  5 10:22:30 2019
@@ -134,6 +134,48 @@ endif()
 #locate 64-bit Python libraries.
 # This function is designed to address those limitations.  Currently it only 
partially
 # addresses them, but it can be improved and extended on an as-needed basis.
+function(find_python_libs_windows_helper LOOKUP_DEBUG OUT_EXE_PATH_VARNAME 
OUT_LIB_PATH_VARNAME OUT_DLL_PATH_VARNAME OUT_VERSION_VARNAME)
+  if(LOOKUP_DEBUG)
+  set(POSTFIX "_d")
+  else()
+  set(POSTFIX "")
+  endif()
+
+  file(TO_CMAKE_PATH "${PYTHON_HOME}/python${POSTFIX}.exe" 
  PYTHON_EXE)
+  file(TO_CMAKE_PATH 
"${PYTHON_HOME}/libs/${PYTHONLIBS_BASE_NAME}${POSTFIX}.lib" PYTHON_LIB)
+  file(TO_CMAKE_PATH "${PYTHON_HOME}/${PYTHONLIBS_BASE_NAME}${POSTFIX}.dll"
  PYTHON_DLL)
+
+  foreach(component PYTHON_EXE;PYTHON_LIB;PYTHON_DLL)
+if(NOT EXISTS ${${component}})
+  message(WARNING "Unable to find ${component}")
+  unset(${component})
+endif()
+  endforeach()
+
+  if (NOT PYTHON_EXE OR NOT PYTHON_LIB OR NOT PYTHON_DLL)
+message(WARNING "Unable to find all Python components.  Python support 
will be disabled for this build.")
+set(LLDB_DISABLE_PYTHON 1 PARENT_SCOPE)
+return()
+  endif()
+
+  # Find the version of the Python interpreter.
+  execute_process(COMMAND "${PYTHON_EXE}" -c
+  "import sys; sys.stdout.write('.'.join([str(x) for x in 
sys.version_info[:3]]))"
+  OUTPUT_VARIABLE PYTHON_VERSION_OUTPUT
+  RESULT_VARIABLE PYTHON_VERSION_RESULT
+  ERROR_QUIET)
+
+  if(PYTHON_VERSION_RESULT)
+message(WARNING "Unable to retrieve Python executable version")
+set(PYTHON_VERSION_OUTPUT "")
+  endif()
+
+  set(${OUT_EXE_PATH_VARNAME} ${PYTHON_EXE} PARENT_SCOPE)
+  set(${OUT_LIB_PATH_VARNAME} ${PYTHON_LIB} PARENT_SCOPE)
+  set(${OUT_DLL_PATH_VARNAME} ${PYTHON_DLL} PARENT_SCOPE)
+  set(${OUT_VERSION_VARNAME}  ${PYTHON_VERSION_OUTPUT} PARENT_SCOPE)
+endfunction()
+
 function(find_python_libs_windows)
   if ("${PYTHON_HOME}" STREQUAL "")
 message(WARNING "LLDB embedded Python on Windows requires specifying a 
value for PYTHON_HOME.  Python support disabled.")
@@ -161,55 +203,65 @@ function(find_python_libs_windows)
   file(TO_CMAKE_PATH "${PYTHON_HOME}" PYTHON_HOME)
   # TODO(compnerd) when CMake Policy `CMP0091` is set to NEW, we should use
   # if(CMAKE_MSVC_RUNTIME_LIBRARY MATCHES MultiThreadedDebug)
-  if(CMAKE_BUILD_TYPE STREQUAL Debug)
-file(TO_CMAKE_PATH "${PYTHON_HOME}/python_d.exe" PYTHON_EXE)
-file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/${PYTHONLIBS_BASE_NAME}_d.lib" 
PYTHON_LIB)
-file(TO_CMAKE_PATH "${PYTHON_HOME}/${PYTHONLIBS_BASE_NAME}_d.dll" 
PYTHON_DLL)
-  else()
-file(TO_CMAKE_PATH "${PYTHON_HOME}/python.exe" PYTHON_EXE)
-file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/${PYTHONLIBS_BASE_NAME}.lib" 
PYTHON_LIB)
-file(TO_CMAKE_PATH "${PYTHON_HOME}/${PYTHONLIBS_BASE_NAME}.dll" PYTHON_DLL)
-  endif()
-
-  foreach(component PYTHON_EXE;PYTHON_LIB;PYTHON_DLL)
-if(NOT EXISTS ${${component}})
-  message(WARNING "unable to find ${component}")
-  unset(${component})
+  if(NOT DEFINED CMAKE_BUILD_TYPE)
+# Multi-target generator was selected (like Visual Studio or Xcode) where 
no concrete build type was passed
+# Lookup for both debug and release python installations
+find_python_libs_windows_helper(TRUE  PYTHON_DEBUG_EXE   PYTHON_DEBUG_LIB  
 PYTHON_DEBUG_DLL   PYTHON_DEBUG_VERSION_STRING)
+find_python_libs_windows_helper(FALSE PYTHON_RELEASE_EXE 
PYTHON_RELEASE_LIB PYTHON_RELEASE_DLL PYTHON_RELEASE_VERSION_STRING)
+if(LLDB_DISABLE_PYTHON)
+  set(LLDB_DISABLE_PYTHON 1 PARENT_SCOPE)
+  return()
 endif()
-  endforeach()
 
-  if (NOT PYTHON_EXE OR NOT PYTHON_LIB OR NOT PYTHON_DLL)
-message(WARNING "Unable to find all Python components.  Python support 
will be disabled for this build.")
-set(LLDB_DISABLE_PYTHON 1 PARENT_SCOPE)
-return()
+# We should have been found both debug and

[Lldb-commits] [PATCH] D66994: [lldb][CMake] Fix windows-x86-debug compilation with python enabled using multi-target generator

2019-09-05 Thread Adrian McCarthy via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371090: Fix windows-x86-debug compilation with python 
enabled using multi-target… (authored by amccarth, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66994?vs=218877&id=218946#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66994

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

Index: lldb/trunk/cmake/modules/LLDBConfig.cmake
===
--- lldb/trunk/cmake/modules/LLDBConfig.cmake
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake
@@ -134,6 +134,48 @@
 #locate 64-bit Python libraries.
 # This function is designed to address those limitations.  Currently it only partially
 # addresses them, but it can be improved and extended on an as-needed basis.
+function(find_python_libs_windows_helper LOOKUP_DEBUG OUT_EXE_PATH_VARNAME OUT_LIB_PATH_VARNAME OUT_DLL_PATH_VARNAME OUT_VERSION_VARNAME)
+  if(LOOKUP_DEBUG)
+  set(POSTFIX "_d")
+  else()
+  set(POSTFIX "")
+  endif()
+
+  file(TO_CMAKE_PATH "${PYTHON_HOME}/python${POSTFIX}.exe"   PYTHON_EXE)
+  file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/${PYTHONLIBS_BASE_NAME}${POSTFIX}.lib" PYTHON_LIB)
+  file(TO_CMAKE_PATH "${PYTHON_HOME}/${PYTHONLIBS_BASE_NAME}${POSTFIX}.dll"  PYTHON_DLL)
+
+  foreach(component PYTHON_EXE;PYTHON_LIB;PYTHON_DLL)
+if(NOT EXISTS ${${component}})
+  message(WARNING "Unable to find ${component}")
+  unset(${component})
+endif()
+  endforeach()
+
+  if (NOT PYTHON_EXE OR NOT PYTHON_LIB OR NOT PYTHON_DLL)
+message(WARNING "Unable to find all Python components.  Python support will be disabled for this build.")
+set(LLDB_DISABLE_PYTHON 1 PARENT_SCOPE)
+return()
+  endif()
+
+  # Find the version of the Python interpreter.
+  execute_process(COMMAND "${PYTHON_EXE}" -c
+  "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:3]]))"
+  OUTPUT_VARIABLE PYTHON_VERSION_OUTPUT
+  RESULT_VARIABLE PYTHON_VERSION_RESULT
+  ERROR_QUIET)
+
+  if(PYTHON_VERSION_RESULT)
+message(WARNING "Unable to retrieve Python executable version")
+set(PYTHON_VERSION_OUTPUT "")
+  endif()
+
+  set(${OUT_EXE_PATH_VARNAME} ${PYTHON_EXE} PARENT_SCOPE)
+  set(${OUT_LIB_PATH_VARNAME} ${PYTHON_LIB} PARENT_SCOPE)
+  set(${OUT_DLL_PATH_VARNAME} ${PYTHON_DLL} PARENT_SCOPE)
+  set(${OUT_VERSION_VARNAME}  ${PYTHON_VERSION_OUTPUT} PARENT_SCOPE)
+endfunction()
+
 function(find_python_libs_windows)
   if ("${PYTHON_HOME}" STREQUAL "")
 message(WARNING "LLDB embedded Python on Windows requires specifying a value for PYTHON_HOME.  Python support disabled.")
@@ -161,55 +203,65 @@
   file(TO_CMAKE_PATH "${PYTHON_HOME}" PYTHON_HOME)
   # TODO(compnerd) when CMake Policy `CMP0091` is set to NEW, we should use
   # if(CMAKE_MSVC_RUNTIME_LIBRARY MATCHES MultiThreadedDebug)
-  if(CMAKE_BUILD_TYPE STREQUAL Debug)
-file(TO_CMAKE_PATH "${PYTHON_HOME}/python_d.exe" PYTHON_EXE)
-file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/${PYTHONLIBS_BASE_NAME}_d.lib" PYTHON_LIB)
-file(TO_CMAKE_PATH "${PYTHON_HOME}/${PYTHONLIBS_BASE_NAME}_d.dll" PYTHON_DLL)
-  else()
-file(TO_CMAKE_PATH "${PYTHON_HOME}/python.exe" PYTHON_EXE)
-file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/${PYTHONLIBS_BASE_NAME}.lib" PYTHON_LIB)
-file(TO_CMAKE_PATH "${PYTHON_HOME}/${PYTHONLIBS_BASE_NAME}.dll" PYTHON_DLL)
-  endif()
-
-  foreach(component PYTHON_EXE;PYTHON_LIB;PYTHON_DLL)
-if(NOT EXISTS ${${component}})
-  message(WARNING "unable to find ${component}")
-  unset(${component})
+  if(NOT DEFINED CMAKE_BUILD_TYPE)
+# Multi-target generator was selected (like Visual Studio or Xcode) where no concrete build type was passed
+# Lookup for both debug and release python installations
+find_python_libs_windows_helper(TRUE  PYTHON_DEBUG_EXE   PYTHON_DEBUG_LIB   PYTHON_DEBUG_DLL   PYTHON_DEBUG_VERSION_STRING)
+find_python_libs_windows_helper(FALSE PYTHON_RELEASE_EXE PYTHON_RELEASE_LIB PYTHON_RELEASE_DLL PYTHON_RELEASE_VERSION_STRING)
+if(LLDB_DISABLE_PYTHON)
+  set(LLDB_DISABLE_PYTHON 1 PARENT_SCOPE)
+  return()
 endif()
-  endforeach()
 
-  if (NOT PYTHON_EXE OR NOT PYTHON_LIB OR NOT PYTHON_DLL)
-message(WARNING "Unable to find all Python components.  Python support will be disabled for this build.")
-set(LLDB_DISABLE_PYTHON 1 PARENT_SCOPE)
-return()
+# We should have been found both debug and release python here
+# Now check that their versions are equal
+if(NOT PYTHON_DEBUG_VERSION_STRING STREQUAL PYTHON_RELEASE_VERSION_STRING)
+  message(FATAL_ERROR "Python versions for debug (${PYTHON_DEBUG_VERSION_STRING}) and release (${PYTHON_RELEASE_VERSION_STRING}) are different."
+   

[Lldb-commits] [PATCH] D67227: [lldb] Extend and document TestIRInterpreter.py

2019-09-05 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor marked an inline comment as done.
teemperor added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/commands/expression/ir-interpreter/TestIRInterpreter.py:54
+# Shifting longer than size of a type also doesn't work.
+if rhs.value <= 0 or rhs.value >= 7:
+return False

shafik wrote:
> I may be missing something here but this looks like it should be `32` instead 
> of `7` or rather `sizeof(int)*8`
> 
> When we say doesn't work do we mean undefined behavior?
Good catch, originally that was supposed to be `> 7` so that we don't overflow 
any data type (assuming we ever extend the test to char). But I can change it 
to `>= 32` until we actually use any 8-bit type.

And 'doesn't work' means that it will literally cause the test to fail and this 
test stops working. The interpreter will do something else than the JIT in 
these cases which is a bug. We probably should detect UB when interpreting 
these expressions and throw an error, but that's a whole new story. This is 
more about adding testing to the existing code.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67227



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


[Lldb-commits] [PATCH] D67022: Enhance SymbolFileDWARF::ParseDeclsForContext performance

2019-09-05 Thread Guilherme Andrade via Phabricator via lldb-commits
guiandrade added a comment.

In D67022#1659155 , @labath wrote:

> Thanks. The code looks fine to me. Losing the ability to unit test is a bit 
> of a pity, but since test was pretty icky to begin with, I can't say I'm 
> going to miss it too much...
>  One way we could possibly test this is with a full scale test via the 
> "target modules dump ast" command. So, the idea would be to run to process to 
> some point, evaluate some expressions, run "target modules dump ast" and 
> check the things are in the output (or that they are *not* there).
>
> It's hard to say what exactly you should be checking for, since the 
> assumption is that we are not changing the behavior here, and so the existing 
> tests should cover that in theory, but the "dump ast" command is a new thing, 
> we don't have too many of tests for it, and so any tests you add will be 
> useful, even if they're not specifically targeting the thing you fix in this 
> patch. If you are able to test the thing that the previous patch fixed in 
> this way, than that would be great though. I'm not 100% sure it can be done, 
> but since (IIUC) the bug/problem was about parsing too many things, I would 
> expect that would manifest itself in some additional entries showing up in 
> the parsed ast.


I'm trying to play with that command to see if anything changes there, but I 
haven't been able to do so yet. I'm using the following snippet.

  // main.cpp
  #include "Foo.h"
  int main() { while (true) foo(); /*Breakpoint A*/ /*Breakpoint C*/ }
  
  // Foo.h
  #pragma once
  void foo();
  
  // Foo.cpp
  #include "Foo.h"
  namespace {
struct C { void f() {} };
struct C0 : public C {
int c00, c01, c02;
};
  };
  void foo() {
C0 c0; // Breakpoint B
c0.f();
  }

Removing this patch and the other one, these are the GetClangDeclForDIE calls 
we make https://pastebin.com/AcKGCBz7.
After applying this patch, we cut that down to https://pastebin.com/BjwmbmE0.
Nevertheless, in either case our AST ends up looking the same at breakpoint 'C'.

  TranslationUnitDecl 0x55fe81dff238 <> 
  |-FunctionDecl 0x55fe81dffb28 <>  main 'int ()' 
extern
  |-FunctionDecl 0x55fe81dffbf8 <>  foo 'void ()' 
extern
  |-NamespaceDecl 0x55fe81dffc98 <> 
  | `-CXXRecordDecl 0x55fe81dffd20 <>  
 struct C0
  `-UsingDirectiveDecl 0x55fe81dffec0 <>  Namespace 
0x55fe81dffc98 ''

I'm not sure if there's a way to have the AST reflect the extra calls (but I 
also know very little about how that part of the code works). Can you guys 
think of a piece of code that could do that?

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67022



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


[Lldb-commits] [PATCH] D65469: Remove `bugreport` command

2019-09-05 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.

We don't need to keep this command around.  It was originated by Tamas in 2015,
https://reviews.llvm.org/D10868
but never got used for anything - Tamas was working on unwind things back then 
iirc, and may it looks like he thought it would be useful for that.  On Darwin 
systems we do ship with a python command for diagnosing unwind problems 
("script import  lldb.diagnose"; "diagnose-unwind") which can be used when the 
current backtrace looks like it may be missing stack frames, or truncate early. 
 The unwinder hasn't seen a lot of active development for years, so we don't 
have cause to use this very often.

I think removing this is fine.  The reproducers will be a great way to include 
everything needed to repro a bug that a user sees.  Not everyone can produce a 
bug report with all of their binaries etc, but the bugreport command suffers 
from the obvious problem that it can only gather state after something bad has 
happened.  (as Jim notes in the original phab)


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D65469



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


[Lldb-commits] [PATCH] D65677: [VirtualFileSystem] Make the RedirectingFileSystem hold on to its own working directory.

2019-09-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 218979.
JDevlieghere added a comment.

Thanks for the feedback, Pavel.


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,60 @@
   EXPECT_EQ(FS->getRealPath("/non_existing", RealPath),
 errc::no_such_file_or_directory);
 }
+
+TEST_F(VFSFromYAMLTest, WorkingDirectory) {
+  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"
+  "  '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);
+  FS->setCurrentWorkingDirectory("//root/bar/");
+
+  llvm::ErrorOr WorkingDir = FS->getCurrentWorkingDirectory();
+  ASSERT_TRUE(WorkingDir);
+  EXPECT_EQ(*WorkingDir, "//root/bar/");
+
+  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());
+
+  std::error_code EC = FS->setCurrentWorkingDirectory("bogus");
+  ASSERT_TRUE(EC);
+  WorkingDir = FS->getCurrentWorkingDirectory();
+  ASSERT_TRUE(WorkingDir);
+  EXPECT_EQ(*WorkingDir, "//root/bar/");
+
+  EC = FS->setCurrentWorkingDirectory("//root/");
+  ASSERT_FALSE(EC);
+  WorkingDir = FS->getCurrentWorkingDirectory();
+  ASSERT_TRUE(WorkingDir);
+  EXPECT_EQ(*WorkingDir, "//root/");
+
+  EC = FS->setCurrentWorkingDirectory("bar/");
+  ASSERT_FALSE(EC);
+  WorkingDir = FS->getCurrentWorkingDirectory();
+  ASSERT_TRUE(WorkingDir);
+  EXPECT_EQ(*WorkingDir, "//root/bar/");
+}
Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -989,6 +989,15 @@
 // RedirectingFileSystem implementation
 //===---===/
 
+RedirectingFileSystem::RedirectingFileSystem(
+IntrusiveRefCntPtr ExternalFS)
+: ExternalFS(std::move(ExternalFS)) {
+  if (ExternalFS)
+if (auto ExternalWorkingDirectory =
+ExternalFS->getCurrentWorkingDirectory())
+  WorkingDirectory = *ExternalWorkingDirectory;
+}
+
 // FIXME: reuse implementation common with OverlayFSDirIterImpl as these
 // iterators are conceptually similar.
 class llvm::vfs::VFSFromYamlDirIterImpl
@@ -1035,12 +1044,27 @@
 
 llvm::ErrorOr
 RedirectingFileSystem::getCurrentWorkingDirectory() const {
-  return ExternalFS->getCurrentWorkingDirectory();
+  return WorkingDirectory;
 }
 
 std::error_code
 RedirectingFileSystem::setCurrentWorkingDirectory(const Twine &Path) {
-  return ExternalFS->setCurrentWorkingDirectory(Path);
+  // Don't change the working directory if the path doesn't exist.
+  if (!exists(Path))
+return errc::no_such_file_or_directory;
+
+  // Non-absolute paths are relative to the current working directory.
+  if (!sys::path::is_absolute(Path)) {
+SmallString<128> AbsolutePath;
+Path.toVector(AbsolutePath);
+if (std::error_code EC = makeAbsolute(AbsolutePath))
+  return EC;
+WorkingDirectory = AbsolutePath.str();
+return {};
+  }
+
+  WorkingDirectory = Path.str();
+  return {};
 }
 
 std::error_code RedirectingFileSystem::isLocal(const Twine &Path,
Index: llvm/include/llvm/Support/VirtualFileSystem.h
===
--- llvm/include/llvm/Support/VirtualFileSystem.h
+++ llvm/include/llvm/Support/VirtualFileSystem.h
@@ -650,6 +650,9 @@
   /// The root(s) of the virtual file system.
   std::vector> Roots;
 
+  /// The current working directory of the file system.
+  std::string WorkingDirectory;
+
   /// The file system to use for external references.
   IntrusiveRefCntPtr ExternalFS;
 
@@ -689,8 +692,7 @@
   true;
 #endif
 
-  RedirectingFileSystem(IntrusiveRefCntPtr ExternalFS)
-  : ExternalFS(std::move(ExternalFS)) {}
+  RedirectingFileSystem(IntrusiveRefCntPtr ExternalF

[Lldb-commits] [PATCH] D67227: [lldb] Extend and document TestIRInterpreter.py

2019-09-05 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/commands/expression/ir-interpreter/TestIRInterpreter.py:54
+# Shifting longer than size of a type also doesn't work.
+if rhs.value <= 0 or rhs.value >= 7:
+return False

teemperor wrote:
> shafik wrote:
> > I may be missing something here but this looks like it should be `32` 
> > instead of `7` or rather `sizeof(int)*8`
> > 
> > When we say doesn't work do we mean undefined behavior?
> Good catch, originally that was supposed to be `> 7` so that we don't 
> overflow any data type (assuming we ever extend the test to char). But I can 
> change it to `>= 32` until we actually use any 8-bit type.
> 
> And 'doesn't work' means that it will literally cause the test to fail and 
> this test stops working. The interpreter will do something else than the JIT 
> in these cases which is a bug. We probably should detect UB when interpreting 
> these expressions and throw an error, but that's a whole new story. This is 
> more about adding testing to the existing code.
if I am not missing anything here in C++ and C the operands of expressions 
undergo the usual arithmetic conversions and for integral types they undergo 
integer promotions. This means that the smallest type should be `int` or 
`unsigned int`.

[More details](https://stackoverflow.com/a/24372323/1708801).


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67227



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


[Lldb-commits] [PATCH] D67239: [Core] Remove use of ClangASTContext in DumpDataExtractor

2019-09-05 Thread Alex Langford via Phabricator via lldb-commits
xiaobai created this revision.
xiaobai added reviewers: clayborg, JDevlieghere, jingham.
Herald added a project: LLDB.

DumpDataExtractor uses ClangASTContext in order to get the proper llvm
fltSemantics for the type it needs so that it can dump floats in a more
precise way. However, there's no reason that this behavior needs to be
specific ClangASTContext. Instead, I think it makes sense to ask
TypeSystems for the float semantics for a type of a given size.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67239

Files:
  lldb/include/lldb/Symbol/ClangASTContext.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Core/DumpDataExtractor.cpp
  lldb/source/Symbol/ClangASTContext.cpp

Index: lldb/source/Symbol/ClangASTContext.cpp
===
--- lldb/source/Symbol/ClangASTContext.cpp
+++ lldb/source/Symbol/ClangASTContext.cpp
@@ -4991,6 +4991,22 @@
 }
 // Exploring the type
 
+const llvm::fltSemantics &
+ClangASTContext::GetFloatTypeSemantics(size_t byte_size) {
+  if (auto *ast = getASTContext()) {
+const size_t bit_size = byte_size * 8;
+if (bit_size == ast->getTypeSize(ast->FloatTy))
+  return ast->getFloatTypeSemantics(ast->FloatTy);
+else if (bit_size == ast->getTypeSize(ast->DoubleTy))
+  return ast->getFloatTypeSemantics(ast->DoubleTy);
+else if (bit_size == ast->getTypeSize(ast->LongDoubleTy))
+  return ast->getFloatTypeSemantics(ast->LongDoubleTy);
+else if (bit_size == ast->getTypeSize(ast->HalfTy))
+  return ast->getFloatTypeSemantics(ast->HalfTy);
+  }
+  return llvm::APFloatBase::Bogus();
+}
+
 Optional
 ClangASTContext::GetBitSize(lldb::opaque_compiler_type_t type,
 ExecutionContextScope *exe_scope) {
Index: lldb/source/Core/DumpDataExtractor.cpp
===
--- lldb/source/Core/DumpDataExtractor.cpp
+++ lldb/source/Core/DumpDataExtractor.cpp
@@ -14,7 +14,6 @@
 #include "lldb/Core/Address.h"
 #include "lldb/Core/Disassembler.h"
 #include "lldb/Core/ModuleList.h"
-#include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/ExecutionContextScope.h"
 #include "lldb/Target/SectionLoadList.h"
@@ -556,61 +555,37 @@
   if (exe_scope)
 target_sp = exe_scope->CalculateTarget();
   if (target_sp) {
-ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
-if (clang_ast) {
-  clang::ASTContext *ast = clang_ast->getASTContext();
-  if (ast) {
-llvm::SmallVector sv;
-// Show full precision when printing float values
-const unsigned format_precision = 0;
-const unsigned format_max_padding =
-target_sp->GetMaxZeroPaddingInFloatFormat();
-size_t item_bit_size = item_byte_size * 8;
-
-if (item_bit_size == ast->getTypeSize(ast->FloatTy)) {
-  llvm::Optional apint =
-  GetAPInt(DE, &offset, item_byte_size);
-  if (apint.hasValue()) {
-llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->FloatTy),
-  apint.getValue());
-apfloat.toString(sv, format_precision, format_max_padding);
-  }
-} else if (item_bit_size == ast->getTypeSize(ast->DoubleTy)) {
-  llvm::Optional apint =
-  GetAPInt(DE, &offset, item_byte_size);
-  if (apint.hasValue()) {
-llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->DoubleTy),
-  apint.getValue());
-apfloat.toString(sv, format_precision, format_max_padding);
-  }
-} else if (item_bit_size == ast->getTypeSize(ast->LongDoubleTy)) {
-  const auto &semantics =
-  ast->getFloatTypeSemantics(ast->LongDoubleTy);
-
-  offset_t byte_size = item_byte_size;
-  if (&semantics == &llvm::APFloatBase::x87DoubleExtended())
-byte_size = (llvm::APFloat::getSizeInBits(semantics) + 7) / 8;
-
-  llvm::Optional apint =
-  GetAPInt(DE, &offset, byte_size);
-  if (apint.hasValue()) {
-llvm::APFloat apfloat(semantics, apint.getValue());
-apfloat.toString(sv, format_precision, format_max_padding);
-  }
-} else if (item_bit_size == ast->getTypeSize(ast->HalfTy)) {
-  llvm::Optional apint =
-  GetAPInt(DE, &offset, item_byte_size);
-  if (apint.hasValue()) {
-llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->HalfTy),
-  apint.getValue());
-apfloat.toString(sv, format_precision, format_max_padding);
+auto type_system_or_err =
+target_sp->GetScratchTypeSystemForLanguage(eLanguageTy

[Lldb-commits] [lldb] r371132 - Remove `bugreport` command

2019-09-05 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Thu Sep  5 14:43:32 2019
New Revision: 371132

URL: http://llvm.org/viewvc/llvm-project?rev=371132&view=rev
Log:
Remove `bugreport` command

The bugreport command exists to create domain-specific bug reports.
Currently it has one implementation for filing bugs on the unwinder. As
far as we can tell, it has never been of use. Although not exactly the
same as the reproducers, it's a bit confusing to have two parallel
command trees for (kind of) the same thing.

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

Removed:
lldb/trunk/source/Commands/CommandObjectBugreport.cpp
lldb/trunk/source/Commands/CommandObjectBugreport.h
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
lldb/trunk/source/Commands/CMakeLists.txt
lldb/trunk/source/Interpreter/CommandInterpreter.cpp

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=371132&r1=371131&r2=371132&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
 Thu Sep  5 14:43:32 2019
@@ -363,7 +363,7 @@ class CommandLineCompletionTestCase(Test
 """Test descriptions of top-level command completions"""
 self.check_completion_with_desc("", [
 ["command", "Commands for managing custom LLDB commands."],
-["bugreport", "Commands for creating domain-specific bug reports."]
+["breakpoint", "Commands for operating on breakpoints (see 'help 
b' for shorthand.)"]
 ])
 
 self.check_completion_with_desc("pl", [

Modified: lldb/trunk/source/Commands/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CMakeLists.txt?rev=371132&r1=371131&r2=371132&view=diff
==
--- lldb/trunk/source/Commands/CMakeLists.txt (original)
+++ lldb/trunk/source/Commands/CMakeLists.txt Thu Sep  5 14:43:32 2019
@@ -7,7 +7,6 @@ add_lldb_library(lldbCommands
   CommandObjectApropos.cpp
   CommandObjectBreakpoint.cpp
   CommandObjectBreakpointCommand.cpp
-  CommandObjectBugreport.cpp
   CommandObjectCommands.cpp
   CommandObjectDisassemble.cpp
   CommandObjectExpression.cpp

Removed: lldb/trunk/source/Commands/CommandObjectBugreport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBugreport.cpp?rev=371131&view=auto
==
--- lldb/trunk/source/Commands/CommandObjectBugreport.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBugreport.cpp (removed)
@@ -1,124 +0,0 @@
-//===-- CommandObjectBugreport.cpp --*- C++ 
-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "CommandObjectBugreport.h"
-
-#include 
-
-
-#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Interpreter/OptionGroupOutputFile.h"
-#include "lldb/Target/Thread.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-// "bugreport unwind"
-
-class CommandObjectBugreportUnwind : public CommandObjectParsed {
-public:
-  CommandObjectBugreportUnwind(CommandInterpreter &interpreter)
-  : CommandObjectParsed(
-interpreter, "bugreport unwind",
-"Create a bugreport for a bug in the stack unwinding code.",
-nullptr),
-m_option_group(), m_outfile_options() {
-m_option_group.Append(&m_outfile_options, LLDB_OPT_SET_ALL,
-  LLDB_OPT_SET_1 | LLDB_OPT_SET_2 | LLDB_OPT_SET_3);
-m_option_group.Finalize();
-  }
-
-  ~CommandObjectBugreportUnwind() override {}
-
-  Options *GetOptions() override { return &m_option_group; }
-
-protected:
-  bool DoExecute(Args &command, CommandReturnObject &result) override {
-StringList commands;
-commands.AppendString("thread backtrace");
-
-Thread *thread = m_exe_ctx.GetThreadPtr();
-if (thread) {
-  char command_buffer[256];
-
-  uint32_t frame_count = thread->GetStackFrameCount();
-  for (uint32_t i = 0; i < frame_count; ++i) {
-StackFrameSP frame = thread->GetStackFrameAtIndex(i);
-lldb::addr_t pc = frame->GetStackID().GetPC();
-
-snprintf(command_buffer, sizeof(command_buffer),
- "disassemble --bytes --address 0x%" PRIx64, pc);
-comman

[Lldb-commits] [PATCH] D65469: Remove `bugreport` command

2019-09-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf5687d7c1257: Remove `bugreport` command (authored by 
JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D65469?vs=212406&id=218989#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65469

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
  lldb/source/Commands/CMakeLists.txt
  lldb/source/Commands/CommandObjectBugreport.cpp
  lldb/source/Commands/CommandObjectBugreport.h
  lldb/source/Interpreter/CommandInterpreter.cpp

Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -16,7 +16,6 @@
 
 #include "Commands/CommandObjectApropos.h"
 #include "Commands/CommandObjectBreakpoint.h"
-#include "Commands/CommandObjectBugreport.h"
 #include "Commands/CommandObjectCommands.h"
 #include "Commands/CommandObjectDisassemble.h"
 #include "Commands/CommandObjectExpression.h"
@@ -444,8 +443,6 @@
   m_command_dict["apropos"] = CommandObjectSP(new CommandObjectApropos(*this));
   m_command_dict["breakpoint"] =
   CommandObjectSP(new CommandObjectMultiwordBreakpoint(*this));
-  m_command_dict["bugreport"] =
-  CommandObjectSP(new CommandObjectMultiwordBugreport(*this));
   m_command_dict["command"] =
   CommandObjectSP(new CommandObjectMultiwordCommands(*this));
   m_command_dict["disassemble"] =
Index: lldb/source/Commands/CommandObjectBugreport.h
===
--- lldb/source/Commands/CommandObjectBugreport.h
+++ /dev/null
@@ -1,27 +0,0 @@
-//===-- CommandObjectBugreport.h *- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#ifndef liblldb_CommandObjectBugreport_h_
-#define liblldb_CommandObjectBugreport_h_
-
-#include "lldb/Interpreter/CommandObjectMultiword.h"
-
-namespace lldb_private {
-
-// CommandObjectMultiwordBugreport
-
-class CommandObjectMultiwordBugreport : public CommandObjectMultiword {
-public:
-  CommandObjectMultiwordBugreport(CommandInterpreter &interpreter);
-
-  ~CommandObjectMultiwordBugreport() override;
-};
-
-} // namespace lldb_private
-
-#endif // liblldb_CommandObjectBugreport_h_
Index: lldb/source/Commands/CommandObjectBugreport.cpp
===
--- lldb/source/Commands/CommandObjectBugreport.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-//===-- CommandObjectBugreport.cpp --*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "CommandObjectBugreport.h"
-
-#include 
-
-
-#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Interpreter/OptionGroupOutputFile.h"
-#include "lldb/Target/Thread.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-// "bugreport unwind"
-
-class CommandObjectBugreportUnwind : public CommandObjectParsed {
-public:
-  CommandObjectBugreportUnwind(CommandInterpreter &interpreter)
-  : CommandObjectParsed(
-interpreter, "bugreport unwind",
-"Create a bugreport for a bug in the stack unwinding code.",
-nullptr),
-m_option_group(), m_outfile_options() {
-m_option_group.Append(&m_outfile_options, LLDB_OPT_SET_ALL,
-  LLDB_OPT_SET_1 | LLDB_OPT_SET_2 | LLDB_OPT_SET_3);
-m_option_group.Finalize();
-  }
-
-  ~CommandObjectBugreportUnwind() override {}
-
-  Options *GetOptions() override { return &m_option_group; }
-
-protected:
-  bool DoExecute(Args &command, CommandReturnObject &result) override {
-StringList commands;
-commands.AppendString("thread backtrace");
-
-Thread *thread = m_exe_ctx.GetThreadPtr();
-if (thread) {
-  char command_buffer[256];
-
-  uint32_t frame_count = thread->GetStackFrameCount();
-  for (uint32_t i = 0; i < frame_count; ++i) {
-StackFrameSP frame = thread->GetStackFrameAtIndex(i);
-lldb::addr_t pc = frame->GetStackID().GetPC();
-
-snprintf(command_buffer, sizeof(command_buffer),
- "disassemble --bytes --address 0x%" PRIx64, pc);
-commands.AppendString(command_buffer);
-
-snprintf(command_buffer, sizeof(command_buffer),
-   

[Lldb-commits] [PATCH] D66638: Unwind: Add a stack scanning mechanism to support win32 unwinding

2019-09-05 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added a comment.

I don't have any specific code comments, but I do have a couple general 
questions and points to consider.

1. `isFoundHeuristically` is very generic.  It's true that it's a heuristic 
approach, but it's a very specific heuristic.  Might there be other heuristic 
approaches in the future?  Should we name it something more specific like 
`isRaSearch`?

2. `max_iterations` means how many stack positions the heuristic will scan 
before giving up, right?  Are there any alignment issues here?  Should we 
assert that the return address hint is a multiple of the stack alignment?

3. The 100 for `max_iterations` is probably fine, but I wonder if there's a way 
to determine a more specific limit without just guessing.  What things could be 
on the stack between the hint and the actual return address?  It seems like 
only arguments for a call that the current function is preparing to make.  The 
standard says that the actual number of parameters is implementation-defined, 
but that it suggests a minimum of 256.  Should `max_iterations` be 256?  Is 
there much risk in making it bigger than it needs to be?

4. Is checking for executable permission slow?  Would it be worth doing some 
culling or caching?  I imagine a lot of non-return address values on the stack 
will be simple small numbers, like 0 or 1, which, for Windows, would never be a 
valid executable address.




Comment at: include/lldb/Symbol/SymbolFile.h:254
+  /// variables and spilled registers, but it should not include paramenters, 
as
+  /// they are considered to be a part of the callers frame.
+  virtual llvm::Expected GetOwnFrameSize(Symbol &symbol) {

Typos:

paramenters -> parameters
callers -> caller's



Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D66638



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


[Lldb-commits] [PATCH] D67239: [Core] Remove use of ClangASTContext in DumpDataExtractor

2019-09-05 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.

Looks like a good improvement.

Does the `APFloatBase::Bogus` result of `GetFloatTypeSemantics` affect the 
functional behavior of the `DumpDataExtractor ` or does `GetAPInt` just return 
`None` in that case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67239



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


[Lldb-commits] [PATCH] D65677: [VirtualFileSystem] Make the RedirectingFileSystem hold on to its own working directory.

2019-09-05 Thread Volodymyr Sapsai via Phabricator via lldb-commits
vsapsai added a subscriber: Bigcheese.
vsapsai added a comment.

Adding Michael Spencer as he was doing some work for a working directory in VFS.


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

https://reviews.llvm.org/D65677



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


[Lldb-commits] [PATCH] D67168: [Windows] Add support of watchpoints to `ProcessWindows`

2019-09-05 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth accepted this revision.
amccarth added a comment.
This revision is now accepted and ready to land.

Thanks for the changes!  I think this looks good now.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67168



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


[Lldb-commits] [PATCH] D67239: [Core] Remove use of ClangASTContext in DumpDataExtractor

2019-09-05 Thread Alex Langford via Phabricator via lldb-commits
xiaobai added a comment.

Hmm, good question. If you call `GetAPInt` with a `byte_size` of 0, it should 
assert when trying to read 0 bytes with the `DataExtractor`. In the worst case, 
it gives you a broken APInt. I think guarded the call to `GetAPInt` to protect 
against this, but I think that it would also be a good idea to make `GetAPInt` 
return `llvm::None` in that case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67239



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


[Lldb-commits] [lldb] r371144 - [Reproducer] Add a `cont` to ModuleCXX.test

2019-09-05 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Thu Sep  5 16:36:57 2019
New Revision: 371144

URL: http://llvm.org/viewvc/llvm-project?rev=371144&view=rev
Log:
[Reproducer] Add a `cont` to ModuleCXX.test

On more than one occasion I've found this test got stuck during replay
while waiting for a packet from debugserver when the debugger was in the
process of being destroyed. For some reason it's more prevalent on the
downstream Swift fork. Adding a cont mitigates the problem while I
investigate.

Modified:
lldb/trunk/lit/Reproducer/Modules/Inputs/ModuleCXX.in

Modified: lldb/trunk/lit/Reproducer/Modules/Inputs/ModuleCXX.in
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Reproducer/Modules/Inputs/ModuleCXX.in?rev=371144&r1=371143&r2=371144&view=diff
==
--- lldb/trunk/lit/Reproducer/Modules/Inputs/ModuleCXX.in (original)
+++ lldb/trunk/lit/Reproducer/Modules/Inputs/ModuleCXX.in Thu Sep  5 16:36:57 
2019
@@ -3,4 +3,5 @@ run
 expr -l Objective-C++ -- @import Foo
 expr -l Objective-C++ -- @import Bar
 expr -- Bar()
+cont
 reproducer generate


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


[Lldb-commits] [lldb] r371166 - [Windows] Add support of watchpoints to `ProcessWindows`

2019-09-05 Thread Aleksandr Urakov via lldb-commits
Author: aleksandr.urakov
Date: Thu Sep  5 22:37:03 2019
New Revision: 371166

URL: http://llvm.org/viewvc/llvm-project?rev=371166&view=rev
Log:
[Windows] Add support of watchpoints to `ProcessWindows`

Summary:
This patch adds support of watchpoints to the old `ProcessWindows` plugin.

The `ProcessWindows` plugin uses the `RegisterContext` to set and reset
watchpoints. The `RegisterContext` has some interface to access watchpoints,
but it is very limited (e.g. it is impossible to retrieve the last triggered
watchpoint with it), that's why I have implemented a slightly different
interface in the `RegisterContextWindows`. Moreover, I have made the
`ProcessWindows` plugin responsible for search of a vacant watchpoint slot,
because watchpoints exist per-process (not per-thread), then we can place
the same watchpoint in the same slot in different threads. With this scheme
threads don't need to have their own watchpoint lists, and it simplifies
identifying of the last triggered watchpoint.

Reviewers: asmith, stella.stamenova, amccarth

Reviewed By: amccarth

Subscribers: labath, zturner, leonid.mashinskiy, abidh, JDevlieghere, 
lldb-commits

Tags: #lldb

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchlocation/TestWatchLocation.py

lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchpoint/TestMyFirstWatchpoint.py

lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/multiple_hits/TestMultipleHits.py

lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py

lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py

lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py

lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py

lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py

lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/condition/TestWatchpointConditionCmd.py

lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py

lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py

lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_on_vectors/TestValueOfVectorVariable.py

lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py

lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_size/TestWatchpointSizes.py

lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py

lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py

lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py

lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py

lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py

lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
lldb/trunk/source/Plugins/Process/Windows/Common/ProcessDebugger.h
lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.h
lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h

lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp

lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchlocation/TestWatchLocation.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchlocation/TestWatchLocation.py?rev=371166&r1=371165&r2=371166&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchlocation/TestWatchLocation.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchlocation/TestWatchLocation.py
 Thu Sep  5 22:37:03 2019
@@ -31,9 +31,6 @@ class HelloWatchLocationTestCase(TestBas
 self.exe_name = self.testMethodName
 self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name}
 
-@expectedFailureAll(
-oslist=["windows"],
-bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not 
supported on Windows")
 # Most of the MIPS

[Lldb-commits] [PATCH] D67168: [Windows] Add support of watchpoints to `ProcessWindows`

2019-09-05 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

Thanks all!


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67168



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


[Lldb-commits] [PATCH] D67168: [Windows] Add support of watchpoints to `ProcessWindows`

2019-09-05 Thread Aleksandr Urakov via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371166: [Windows] Add support of watchpoints to 
`ProcessWindows` (authored by aleksandr.urakov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67168?vs=218897&id=219028#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67168

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchlocation/TestWatchLocation.py
  
lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchpoint/TestMyFirstWatchpoint.py
  
lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/multiple_hits/TestMultipleHits.py
  
lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
  
lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
  
lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
  
lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py
  
lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py
  
lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/condition/TestWatchpointConditionCmd.py
  
lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py
  
lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py
  
lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_on_vectors/TestValueOfVectorVariable.py
  
lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
  
lldb/trunk/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_size/TestWatchpointSizes.py
  
lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py
  
lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
  
lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py
  
lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
  
lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
  
lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
  lldb/trunk/source/Plugins/Process/Windows/Common/ProcessDebugger.h
  lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
  lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.h
  lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
  lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
  
lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
  
lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp

Index: lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
@@ -36,7 +36,6 @@
 archs=["aarch64"],
 triple=no_match(".*-android"),
 bugnumber="llvm.org/pr27710")
-@skipIfWindows  # Watchpoints not supported on Windows, and this test hangs
 def test_watchpoint_cond_api(self):
 """Test watchpoint condition API."""
 self.build(dictionary=self.d)
Index: lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
@@ -25,9 +25,6 @@
 self.source, '// Set break point at this line.')
 
 @add_test_categories(['pyapi'])
-@expectedFailureAll(
-oslist=["windows"],
-bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
 # Read-write watchpoints not supported on SystemZ
 @expectedFailureAll(archs=['s390x'])
 def test_set_watch_ignore_count(self):
Index: lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py
+++ lldb/trunk/packages/Python/lldb