[Lldb-commits] [PATCH] D31366: Do not dereference std::unique_ptr by default

2017-03-28 Thread Tamas Berghammer via Phabricator via lldb-commits
tberghammer added a comment.

My understanding (don't have an OSX machine at hand right now to try out) is 
that OSX ships with the libstdc++ belonging to gcc-4.2.1 and that version of 
libstdc++ is too old to support c++11 features such as std::unique_ptr.

Regarding skipping tests I am not aware of any way to skip a test based on the 
STL library we are using (Pavel is working on it for libc++ at 
https://reviews.llvm.org/D30984) and actually the problem here is that the 
version of libstdc++ shipping on  OSX is too old so I think skipIfDarwin is the 
correct decorator (we do it in several other tests as well). Alternative option 
could be to try to compile the source code and skip the test if compilation 
fails but that seems a bit flaky and might cause false negatives on other 
systems where we expect the test to pass.


https://reviews.llvm.org/D31366



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


[Lldb-commits] [PATCH] D31368: Add support for sythetic operator dereference

2017-03-28 Thread Tamas Berghammer via Phabricator via lldb-commits
tberghammer updated this revision to Diff 93241.
tberghammer added a comment.

Changed StackFrame to use Dereference instead of accessing the $$dereference$$ 
magic field.


https://reviews.llvm.org/D31368

Files:
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
  source/Core/ValueObject.cpp
  source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
  source/Target/StackFrame.cpp

Index: source/Target/StackFrame.cpp
===
--- source/Target/StackFrame.cpp
+++ source/Target/StackFrame.cpp
@@ -606,8 +606,10 @@
 // Calculate the next separator index ahead of time
 ValueObjectSP child_valobj_sp;
 const char separator_type = var_expr[0];
+bool expr_is_ptr = false;
 switch (separator_type) {
 case '-':
+  expr_is_ptr = true;
   if (var_expr.size() >= 2 && var_expr[1] != '>')
 return ValueObjectSP();
 
@@ -624,11 +626,32 @@
   return ValueObjectSP();
 }
   }
+
+  // If we have a non pointer type with a sythetic value then lets check if
+  // we have an sythetic dereference specified.
+  if (!valobj_sp->IsPointerType() && valobj_sp->HasSyntheticValue()) {
+Error deref_error;
+if (valobj_sp->GetCompilerType().IsReferenceType()) {
+  valobj_sp = valobj_sp->GetSyntheticValue()->Dereference(deref_error);
+  if (error.Fail()) {
+error.SetErrorStringWithFormatv(
+"Failed to dereference reference type: %s", deref_error);
+return ValueObjectSP();
+  }
+}
+
+valobj_sp = valobj_sp->Dereference(deref_error);
+if (error.Fail()) {
+  error.SetErrorStringWithFormatv(
+  "Failed to dereference sythetic value: %s", deref_error);
+  return ValueObjectSP();
+}
+expr_is_ptr = false;
+  }
+
   var_expr = var_expr.drop_front(); // Remove the '-'
   LLVM_FALLTHROUGH;
 case '.': {
-  const bool expr_is_ptr = var_expr[0] == '>';
-
   var_expr = var_expr.drop_front(); // Remove the '.' or '>'
   separator_idx = var_expr.find_first_of(".-[");
   ConstString child_name(var_expr.substr(0, var_expr.find_first_of(".-[")));
Index: source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
===
--- source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
+++ source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
@@ -114,7 +114,8 @@
 return 0;
   if (name == ConstString("del") || name == ConstString("deleter"))
 return 1;
-  if (name == ConstString("obj") || name == ConstString("object"))
+  if (name == ConstString("obj") || name == ConstString("object") ||
+  name == ConstString("$$dereference$$"))
 return 2;
   return UINT32_MAX;
 }
Index: source/Core/ValueObject.cpp
===
--- source/Core/ValueObject.cpp
+++ source/Core/ValueObject.cpp
@@ -2889,6 +2889,11 @@
   child_is_base_class, child_is_deref_of_parent, eAddressTypeInvalid,
   language_flags);
 }
+  } else if (HasSyntheticValue()) {
+m_deref_valobj =
+GetSyntheticValue()
+->GetChildMemberWithName(ConstString("$$dereference$$"), true)
+.get();
   }
 
   if (m_deref_valobj) {
Index: packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
===
--- packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
+++ packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
@@ -42,13 +42,17 @@
 self.expect("frame variable sdp", substrs=['sdp = 0x', 'deleter = ', 'a = 3', 'b = 4'])
 
 self.assertEqual(123, frame.GetValueForVariablePath("iup.object").GetValueAsUnsigned())
+self.assertEqual(123, frame.GetValueForVariablePath("*iup").GetValueAsUnsigned())
 self.assertFalse(frame.GetValueForVariablePath("iup.deleter").IsValid())
 
 self.assertEqual('"foobar"', frame.GetValueForVariablePath("sup.object").GetSummary())
+self.assertEqual('"foobar"', frame.GetValueForVariablePath("*sup").GetSummary())
 self.assertFalse(frame.GetValueForVariablePath("sup.deleter").IsValid())
 
 self.assertEqual(456, frame.GetValueForVariablePath("idp.object").GetValueAsUnsigned())
+self.assertEqual(456, frame.GetValueForVariablePath("*idp").GetValueAsUnsigned())
 self.assertEqual('"baz"', frame.GetValueForVariablePath("sdp.object").GetSummary())
+self.assertEqual('"baz"', frame.GetValueForVariablePath("*sdp").GetSummary())
 
 idp_deleter = f

[Lldb-commits] [PATCH] D31131: [LLDB] OpenBSD support

2017-03-28 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: source/CMakeLists.txt:25
+include_directories(
+  Plugins/Process/POSIX
+  )

krytarowski wrote:
> @labath are the includes for Plugins/Process/FreeBSD and 
> Plugins/Process/FreeBSD necessary? I don't need to add Plugins/Process/NetBSD 
> in order to make things work.
> 
> (it's not related to OpenBSD patch here)
You probably need the ProcessPosixLog file at least. However, the only thing 
which this affects is how you need to include them, so if you use the long 
`Plugins/Process/POSIX/XXX` path, you are fine.

As a matter of fact, we should probably use that path everywhere, and then 
these can go away. (future cleanup idea).


https://reviews.llvm.org/D31131



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


[Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver

2017-03-28 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I am afraid I will be away for two weeks as well.. :(

The FileLogCallback thingy seems a bit unfortunate, but I don't see anything 
too controversial based on a quick scan..


https://reviews.llvm.org/D31357



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


[Lldb-commits] [PATCH] D31374: Add support for tracing hello-world application on NetBSD

2017-03-28 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I wasn't able to go into this too deeply, but here is what I have after a quick 
pass. I won't be able to review this thoroughly that soon, but I think it can 
go in after you take my comments into consideration.




Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:450
+  Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+  LLDB_LOG(log, "selecting running thread for interrupt target");
+

this comment does not make sense in this context



Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:620
+  lldb::addr_t &addr) {
+  return Error();
+}

This will return a success value. You probably wan't `return 
Error("Unimplemented");` or something like that.



Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:624
+Error NativeProcessNetBSD::DeallocateMemory(lldb::addr_t addr) {
+  return Error();
+}

same here



Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:666
+   FileSpec &file_spec) {
+  FileSpec module_file_spec(module_path, true);
+

`return Error("Unimplemented");`



Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:801
+  int status;
+  ::pid_t wait_pid = waitpid(WAIT_ANY, &status, WALLSIG | WNOHANG);
+

you could probably use process id instead of WAIT_ANY. The reason we needed -1 
on linux is because each thread is reported separately.



Comment at: source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp:32
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  if (log)
+log->Printf("NativeThreadNetBSD::%s called with signal 0x%02" PRIx32,

How about using LLDB_LOG here?



Comment at: source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp:142
+uint32_t watch_flags, bool hardware) {
+  return Error();
+}

"Unimplemented" (and below as well).


Repository:
  rL LLVM

https://reviews.llvm.org/D31374



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


[Lldb-commits] [PATCH] D31368: Add support for sythetic operator dereference

2017-03-28 Thread Jim Ingham via Phabricator via lldb-commits
jingham requested changes to this revision.
jingham added a comment.
This revision now requires changes to proceed.

This seems great.  The only remaining thing is to document this in the 
Synthetic Children section of the Variable Formatting page 
(www/varformats.html).


https://reviews.llvm.org/D31368



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


[Lldb-commits] [PATCH] D31374: Add support for tracing hello-world application on NetBSD

2017-03-28 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

In https://reviews.llvm.org/D31374#712221, @labath wrote:

> I wasn't able to go into this too deeply, but here is what I have after a 
> quick pass. I won't be able to review this thoroughly that soon, but I think 
> it can go in after you take my comments into consideration.


Thank you!

I will apply the changes as suggested.


Repository:
  rL LLVM

https://reviews.llvm.org/D31374



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


[Lldb-commits] [PATCH] D31371: Stop calling ValueObject::SetName from synthetic child providers

2017-03-28 Thread Jim Ingham via Phabricator via lldb-commits
jingham requested changes to this revision.
jingham added a comment.
This revision now requires changes to proceed.

If SetName is the wrong thing to use for synthetic child providers, then we 
need to make Clone available to the SB API's as well.  In any case where they 
want to return an extant ValueObject with a different name - as opposed to 
making one up out of whole cloth - won't they need the same operation?

Also, probably should document this requirement in the varformats.html.




Comment at: include/lldb/Core/ValueObject.h:607-610
+  // Creates a copy of the ValueObject with a new name setting he current value
+  // object as its parent. It should be used when we want to chane the name of 
a
+  // value object without modifying the actul value object (e.g. sythetic child
+  // provider).

Spelling... "he" -> "the", "chane" -> "change",  "actul" -> "actual" 


https://reviews.llvm.org/D31371



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


[Lldb-commits] [PATCH] D31374: Add support for tracing hello-world application on NetBSD

2017-03-28 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

This code is used as a base for further improvements, I'm going to commit it... 
debugging hello world still works.

  $ lldb ./hello

   
  (lldb) target create "./hello"
  Current executable set to './hello' (x86_64).
  (lldb) r
  Process 3955 launched: './hello' (x86_64)
  Hello world!
  Process 3955 exited with status = 0 (0x) 
  (lldb) version
  lldb version 5.0.0 (http://llvm.org/svn/llvm-project/lldb/trunk revision 
298810)
  (lldb) platform status
Platform: host
  Triple: x86_64-unknown-netbsd7.99
  OS Version: 7.99.66 (0799006600)
  Kernel: NetBSD 7.99.66 (GENERIC) #5: Tue Mar 28 17:42:09 CEST 2017  
root@chieftec:/public/netbsd-root/sys/arch/amd64/compile/GENERIC
Hostname: 127.0.0.1
  WorkingDir: /public/lldb_devel
  Kernel: NetBSD
 Release: 7.99.66
 Version: NetBSD 7.99.66 (GENERIC) #5: Tue Mar 28 17:42:09 CEST 2017  
root@chieftec:/public/netbsd-root/sys/arch/amd64/compile/GENERIC
  (lldb) 


Repository:
  rL LLVM

https://reviews.llvm.org/D31374



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


[Lldb-commits] [PATCH] D31374: Add support for tracing hello-world application on NetBSD

2017-03-28 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski updated this revision to Diff 93312.
krytarowski added a comment.

Apply changes from review.


Repository:
  rL LLVM

https://reviews.llvm.org/D31374

Files:
  source/Plugins/Process/NetBSD/CMakeLists.txt
  source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
  source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
  source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
  source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
  source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
  source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
  source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
  source/Plugins/Process/NetBSD/NativeThreadNetBSD.h

Index: source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
===
--- source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
+++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
@@ -22,6 +22,45 @@
 
 public:
   NativeThreadNetBSD(NativeProcessNetBSD *process, lldb::tid_t tid);
+
+  // -
+  // NativeThreadProtocol Interface
+  // -
+  std::string GetName() override;
+
+  lldb::StateType GetState() override;
+
+  bool GetStopReason(ThreadStopInfo &stop_info,
+ std::string &description) override;
+
+  NativeRegisterContextSP GetRegisterContext() override;
+
+  Error SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags,
+  bool hardware) override;
+
+  Error RemoveWatchpoint(lldb::addr_t addr) override;
+
+  Error SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
+
+  Error RemoveHardwareBreakpoint(lldb::addr_t addr) override;
+
+private:
+  // -
+  // Interface for friend classes
+  // -
+
+  void SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr);
+  void SetStoppedByBreakpoint();
+  void SetStopped();
+  void SetRunning();
+
+  // -
+  // Member Variables
+  // -
+  lldb::StateType m_state;
+  ThreadStopInfo m_stop_info;
+  NativeRegisterContextSP m_reg_context_sp;
+  std::string m_stop_description;
 };
 
 typedef std::shared_ptr NativeThreadNetBSDSP;
Index: source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
===
--- source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
+++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
@@ -12,10 +12,131 @@
 
 #include "NativeProcessNetBSD.h"
 
+#include "Plugins/Process/POSIX/CrashReason.h"
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#include "lldb/Core/RegisterValue.h"
+#include "lldb/Core/State.h"
+
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::process_netbsd;
 
 NativeThreadNetBSD::NativeThreadNetBSD(NativeProcessNetBSD *process,
lldb::tid_t tid)
-: NativeThreadProtocol(process, tid) {}
+: NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid),
+  m_stop_info(), m_reg_context_sp(), m_stop_description() {}
+
+void NativeThreadNetBSD::SetStoppedBySignal(uint32_t signo,
+const siginfo_t *info) {
+  Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD));
+  LLDB_LOG(log, "tid = {0} in called with signal {1}", GetID(), signo);
+
+  SetStopped();
+
+  m_stop_info.reason = StopReason::eStopReasonSignal;
+  m_stop_info.details.signal.signo = signo;
+
+  m_stop_description.clear();
+  if (info) {
+switch (signo) {
+case SIGSEGV:
+case SIGBUS:
+case SIGFPE:
+case SIGILL:
+  const auto reason = GetCrashReason(*info);
+  m_stop_description = GetCrashReasonString(reason, *info);
+  break;
+}
+  }
+}
+
+void NativeThreadNetBSD::SetStoppedByBreakpoint() {
+  SetStopped();
+  m_stop_info.reason = StopReason::eStopReasonBreakpoint;
+  m_stop_info.details.signal.signo = SIGTRAP;
+}
+
+void NativeThreadNetBSD::SetStopped() {
+  const StateType new_state = StateType::eStateStopped;
+  m_state = new_state;
+  m_stop_description.clear();
+}
+
+void NativeThreadNetBSD::SetRunning() {
+  m_state = StateType::eStateRunning;
+  m_stop_info.reason = StopReason::eStopReasonNone;
+}
+
+std::string NativeThreadNetBSD::GetName() { return std::string(""); }
+
+lldb::StateType NativeThreadNetBSD::GetState() { return m_state; }
+
+bool NativeThreadNetBSD::GetStopReason(ThreadStopInfo &stop_info,
+   std::string &description) {
+  Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD));
+
+  description.clear();
+
+  switch (m_state) {
+  case eStateS

[Lldb-commits] [lldb] r298953 - Add support for tracing hello-world application on NetBSD

2017-03-28 Thread Kamil Rytarowski via lldb-commits
Author: kamil
Date: Tue Mar 28 17:43:17 2017
New Revision: 298953

URL: http://llvm.org/viewvc/llvm-project?rev=298953&view=rev
Log:
Add support for tracing hello-world application on NetBSD

Summary:
This patch is a stripped down from features a NetBSD process
code (patch is kept under 2k LOC). This code has assumption that
there is only one thread within a debugged process. The only
debugger trap supported is software breakpoint (TRAP_BRKPT).
The generic platform code requires to add dummy function for
watchpoints etc. These functions are currently empty.
This code is not the final platform support as is and it's treated as
a base to extend, refactor and address issues afterwards.

Supported features:
 - handle software breakpoints,
 - correctly attach to a tracee,
 - support NetBSD specific ptrace(2),
 - monitor process termination,
 - monitor SIGTRAP events,
 - monitor SIGSTOP events,
 - monitor other signals events,
 - resume the whole process,
 - get memory region info perms,
 - read memory from tracee,
 - write memory to tracee,
 - read ELF AUXV,
 - x86_64 GPR read and write code

For the generic framework include:
 - halt,
 - detach,
 - signal,
 - kill,
 - allocatememory,
 - deallocatememory,
 - update threads,
 - getarchitecture,
 - getfileloadaddress,
 - and others.

This code has preliminary AddThread code.

Out of interest in this patch:
 - exec() traps,
 - hardware debug register traps,
 - single step trap,
 - thread creation/termination trap,
 - process fork(2), vfork(2) and vfork(2) done traps,
 - syscall entry and exit trap,
 - threads,
 - FPR registers,
 - retrieving tracee's thread name,
 - non x86_64 support.

This code can be used to start a hello world application and trace it.

This code can be used by other BSD systems as a starting point to get similar
capabilities.

Sponsored by 

Reviewers: emaste, joerg, kettenis, labath

Subscribers: mgorny, #lldb

Tags: #lldb

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

Added:

lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp

lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
Modified:
lldb/trunk/source/Plugins/Process/NetBSD/CMakeLists.txt
lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h

Modified: lldb/trunk/source/Plugins/Process/NetBSD/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/CMakeLists.txt?rev=298953&r1=298952&r2=298953&view=diff
==
--- lldb/trunk/source/Plugins/Process/NetBSD/CMakeLists.txt (original)
+++ lldb/trunk/source/Plugins/Process/NetBSD/CMakeLists.txt Tue Mar 28 17:43:17 
2017
@@ -5,6 +5,7 @@ include_directories(../Utility)
 add_lldb_library(lldbPluginProcessNetBSD PLUGIN
   NativeProcessNetBSD.cpp
   NativeRegisterContextNetBSD.cpp
+  NativeRegisterContextNetBSD_x86_64.cpp
   NativeThreadNetBSD.cpp
 
   LINK_LIBS

Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp?rev=298953&r1=298952&r2=298953&view=diff
==
--- lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp (original)
+++ lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp Tue Mar 28 
17:43:17 2017
@@ -14,18 +14,77 @@
 // C++ Includes
 
 // Other libraries and framework includes
-
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#include "lldb/Core/State.h"
+#include "lldb/Host/HostProcess.h"
+#include "lldb/Host/common/NativeBreakpoint.h"
+#include "lldb/Host/common/NativeRegisterContext.h"
+#include "lldb/Host/posix/ProcessLauncherPosixFork.h"
+#include "lldb/Target/Process.h"
 
 // System includes - They have to be included after framework includes because
 // they define some
 // macros which collide with variable names in other modules
+// clang-format off
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+// clang-format on
 
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::process_netbsd;
 using namespace llvm;
 
+static ExitType convert_pid_status_to_exit_type(int status) {
+  if (WIFEXITED(status))
+return ExitType::eExitTypeExit;
+  else if (WIFSIGNALED(status))
+return ExitType::eExitTypeSignal;
+  else if (WIFSTOPPED(status))
+return ExitType::eExitTypeStop;
+  else {
+// We don't know what this is.
+return ExitType::eExitTypeInvalid;
+  }
+}
+
+static int convert_pid_st

[Lldb-commits] [PATCH] D31374: Add support for tracing hello-world application on NetBSD

2017-03-28 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298953: Add support for tracing hello-world application on 
NetBSD (authored by kamil).

Changed prior to commit:
  https://reviews.llvm.org/D31374?vs=93312&id=93315#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31374

Files:
  lldb/trunk/source/Plugins/Process/NetBSD/CMakeLists.txt
  lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
  lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
  lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
  lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
  
lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
  lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
  lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
  lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h

Index: lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
===
--- lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
+++ lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
@@ -33,6 +33,19 @@
   CreateHostNativeRegisterContextNetBSD(const ArchSpec &target_arch,
 NativeThreadProtocol &native_thread,
 uint32_t concrete_frame_idx);
+
+protected:
+  virtual Error ReadGPR();
+  virtual Error WriteGPR();
+  virtual void *GetGPRBuffer() { return nullptr; }
+  virtual size_t GetGPRSize() {
+return GetRegisterInfoInterface().GetGPRSize();
+  }
+  virtual Error DoReadGPR(void *buf);
+  virtual Error DoWriteGPR(void *buf);
+
+  virtual NativeProcessNetBSD &GetProcess();
+  virtual ::pid_t GetProcessPid();
 };
 
 } // namespace process_netbsd
Index: lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
===
--- lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
+++ lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
@@ -14,38 +14,978 @@
 // C++ Includes
 
 // Other libraries and framework includes
-
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#include "lldb/Core/State.h"
+#include "lldb/Host/HostProcess.h"
+#include "lldb/Host/common/NativeBreakpoint.h"
+#include "lldb/Host/common/NativeRegisterContext.h"
+#include "lldb/Host/posix/ProcessLauncherPosixFork.h"
+#include "lldb/Target/Process.h"
 
 // System includes - They have to be included after framework includes because
 // they define some
 // macros which collide with variable names in other modules
+// clang-format off
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+// clang-format on
 
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::process_netbsd;
 using namespace llvm;
 
+static ExitType convert_pid_status_to_exit_type(int status) {
+  if (WIFEXITED(status))
+return ExitType::eExitTypeExit;
+  else if (WIFSIGNALED(status))
+return ExitType::eExitTypeSignal;
+  else if (WIFSTOPPED(status))
+return ExitType::eExitTypeStop;
+  else {
+// We don't know what this is.
+return ExitType::eExitTypeInvalid;
+  }
+}
+
+static int convert_pid_status_to_return_code(int status) {
+  if (WIFEXITED(status))
+return WEXITSTATUS(status);
+  else if (WIFSIGNALED(status))
+return WTERMSIG(status);
+  else if (WIFSTOPPED(status))
+return WSTOPSIG(status);
+  else {
+// We don't know what this is.
+return ExitType::eExitTypeInvalid;
+  }
+}
+
+// Simple helper function to ensure flags are enabled on the given file
+// descriptor.
+static Error EnsureFDFlags(int fd, int flags) {
+  Error error;
+
+  int status = fcntl(fd, F_GETFL);
+  if (status == -1) {
+error.SetErrorToErrno();
+return error;
+  }
+
+  if (fcntl(fd, F_SETFL, status | flags) == -1) {
+error.SetErrorToErrno();
+return error;
+  }
+
+  return error;
+}
+
 // -
 // Public Static Methods
 // -
 
 Error NativeProcessProtocol::Launch(
 ProcessLaunchInfo &launch_info,
 NativeProcessProtocol::NativeDelegate &native_delegate, MainLoop &mainloop,
 NativeProcessProtocolSP &native_process_sp) {
-  return Error();
+  Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+
+  Error error;
+
+  // Verify the working directory is valid if one was specified.
+  FileSpec working_dir{launch_info.GetWorkingDirectory()};
+  if (working_dir && (!working_dir.ResolvePath() ||
+  !llvm::sys::fs::is_directory(working_dir.GetPath( {
+error.SetErrorStringWithFormat("No such file or directory: %s",
+   working_dir.GetCString());
+   

[Lldb-commits] [lldb] r298958 - Print the error if dsymForUUID sometimes produces bad plists.

2017-03-28 Thread Jim Ingham via lldb-commits
Author: jingham
Date: Tue Mar 28 18:25:34 2017
New Revision: 298958

URL: http://llvm.org/viewvc/llvm-project?rev=298958&view=rev
Log:
Print the error if dsymForUUID sometimes produces bad plists.

Not much we can do about it but at least we can print the bad
plist and the error.

Modified:
lldb/trunk/examples/python/crashlog.py

Modified: lldb/trunk/examples/python/crashlog.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/crashlog.py?rev=298958&r1=298957&r2=298958&view=diff
==
--- lldb/trunk/examples/python/crashlog.py (original)
+++ lldb/trunk/examples/python/crashlog.py Tue Mar 28 18:25:34 2017
@@ -259,7 +259,11 @@ class CrashLog(symbolication.Symbolicato
 self.dsymForUUIDBinary, uuid_str)
 s = commands.getoutput(dsym_for_uuid_command)
 if s:
-plist_root = plistlib.readPlistFromString(s)
+try:
+plist_root = plistlib.readPlistFromString(s)
+except:
+print("Got exception: ", sys.exc_value, " handling 
dsymForUUID output: \n", s) 
+raise
 if plist_root:
 plist = plist_root[uuid_str]
 if plist:


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


[Lldb-commits] [lldb] r298970 - Remove dead include from the NetBSD code.

2017-03-28 Thread Kamil Rytarowski via lldb-commits
Author: kamil
Date: Tue Mar 28 20:10:21 2017
New Revision: 298970

URL: http://llvm.org/viewvc/llvm-project?rev=298970&view=rev
Log:
Remove dead include  from the NetBSD code.

Modified:
lldb/trunk/source/Host/netbsd/Host.cpp

Modified: lldb/trunk/source/Host/netbsd/Host.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/netbsd/Host.cpp?rev=298970&r1=298969&r2=298970&view=diff
==
--- lldb/trunk/source/Host/netbsd/Host.cpp (original)
+++ lldb/trunk/source/Host/netbsd/Host.cpp Tue Mar 28 20:10:21 2017
@@ -1,5 +1,4 @@
-//===-- source/Host/netbsd/Host.cpp --*- C++
-//-*-===//
+//===-- source/Host/netbsd/Host.cpp -*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -15,7 +14,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 


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


[Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements

2017-03-28 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski created this revision.
krytarowski added a project: LLDB.

Include initial support for:

- single step mode (PT_STEP)
- single step trap handling (TRAP_TRACE)
- exec() trap (TRAP_EXEC)
- add placeholder interfaces for FPR
- initial code for NetBSD core(5) files
- minor tweaks

While there improve style of altered elf-core/ files.

This code raises the number of passing tests on NetBSD to around 50% 
(600+/1200+).

The introduced code is subject to improve afterwards for additional features 
and bug fixes.

Sponsored by 


Repository:
  rL LLVM

https://reviews.llvm.org/D31450

Files:
  source/Host/common/Host.cpp
  source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
  source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
  source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
  source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
  source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
  source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
  source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
  source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
  source/Plugins/Process/elf-core/ProcessElfCore.cpp
  source/Plugins/Process/elf-core/ThreadElfCore.cpp

Index: source/Plugins/Process/elf-core/ThreadElfCore.cpp
===
--- source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -21,6 +21,7 @@
 #include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_s390x.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
+#include "Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h"
 #include "Plugins/Process/Utility/RegisterContextOpenBSD_i386.h"
 #include "Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h"
 #include "Plugins/Process/Utility/RegisterInfoPOSIX_arm.h"
@@ -112,6 +113,17 @@
   break;
 }
 
+case llvm::Triple::NetBSD: {
+  switch (arch.GetMachine()) {
+  case llvm::Triple::x86_64:
+reg_interface = new RegisterContextNetBSD_x86_64(arch);
+break;
+  default:
+break;
+  }
+  break;
+}
+
 case llvm::Triple::Linux: {
   switch (arch.GetMachine()) {
   case llvm::Triple::arm:
@@ -144,8 +156,8 @@
 reg_interface = new RegisterInfoPOSIX_arm(arch);
 break;
   case llvm::Triple::x86:
-	reg_interface = new RegisterContextOpenBSD_i386(arch);
-	break;
+reg_interface = new RegisterContextOpenBSD_i386(arch);
+break;
   case llvm::Triple::x86_64:
 reg_interface = new RegisterContextOpenBSD_x86_64(arch);
 break;
@@ -260,7 +272,6 @@
   pr_cstime.tv_sec = data.GetPointer(&offset);
   pr_cstime.tv_usec = data.GetPointer(&offset);
 
-
   return error;
 }
 
@@ -317,9 +328,7 @@
 //
 // Parse SIGINFO from NOTE entry
 //
-ELFLinuxSigInfo::ELFLinuxSigInfo() {
-  memset(this, 0, sizeof(ELFLinuxSigInfo));
-}
+ELFLinuxSigInfo::ELFLinuxSigInfo() { memset(this, 0, sizeof(ELFLinuxSigInfo)); }
 
 Error ELFLinuxSigInfo::Parse(DataExtractor &data, const ArchSpec &arch) {
   Error error;
Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -62,8 +62,8 @@
 // to ignore possible presence of the header extension.
 const size_t header_size = sizeof(llvm::ELF::Elf64_Ehdr);
 
-auto data_sp =
-DataBufferLLVM::CreateSliceFromPath(crash_file->GetPath(), header_size, 0);
+auto data_sp = DataBufferLLVM::CreateSliceFromPath(crash_file->GetPath(),
+   header_size, 0);
 if (data_sp && data_sp->GetByteSize() == header_size &&
 elf::ELFHeader::MagicBytesMatch(data_sp->GetBytes())) {
   elf::ELFHeader elf_header;
@@ -223,7 +223,7 @@
   bool siginfo_signal_found = false;
   bool prstatus_signal_found = false;
   // Check we found a signal in a SIGINFO note.
-  for (const auto &thread_data: m_thread_data) {
+  for (const auto &thread_data : m_thread_data) {
 if (thread_data.signo != 0)
   siginfo_signal_found = true;
 if (thread_data.prstatus_sig != 0)
@@ -233,7 +233,7 @@
 // If we don't have signal from SIGINFO use the signal from each threads
 // PRSTATUS note.
 if (prstatus_signal_found) {
-  for (auto &thread_data: m_thread_data)
+  for (auto &thread_data : m_thread_data)
 thread_data.signo = thread_data.prstatus_sig;
 } else if (m_thread_data.size() > 0) {
   // If all else fails force the first thread to be SIGSTOP
@@ -449,6 +449,11 @@
 };
 }
 
+namespace NETBSD {
+
+enum { NT_PROCINFO = 1, NT_AUXV, NT_AMD64_REGS = 33, NT_AMD64_FPREGS =

[Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements

2017-03-28 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

Next: watchpoints, FPR.

Current core(5) file format is a subject to change (AUXV can be shortened)... 
I'm working on the final nits for the NetBSD-8 interfaces.


Repository:
  rL LLVM

https://reviews.llvm.org/D31450



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


[Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements

2017-03-28 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a reviewer: jingham.
krytarowski added a comment.

Adding Jim as a reviewer, since Pavel is mostly out of the keyboard for longer 
time.


Repository:
  rL LLVM

https://reviews.llvm.org/D31450



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


[Lldb-commits] [PATCH] D31073: Enable lldm-mi commands -stack-list-locals -stack-list-variables and -var-create to work only with variables in scope

2017-03-28 Thread Ilia K via Phabricator via lldb-commits
ki.stfu requested changes to this revision.
ki.stfu added a comment.
This revision now requires changes to proceed.

Hi.

LGTM. Just fix a few minor issues before committing.

Thank you for your contribution to LLDB project!




Comment at: 
packages/Python/lldbsuite/test/tools/lldb-mi/lexical-scope/Makefile:1
+LEVEL = ../../../make
+

Rename directory to lexical**_**scope.



Comment at: 
packages/Python/lldbsuite/test/tools/lldb-mi/lexical-scope/TestLexicalScope.py:1
+# coding=utf8
+"""

Remove please. We don't specify encoding in other files.



Comment at: 
packages/Python/lldbsuite/test/tools/lldb-mi/lexical-scope/TestLexicalScope.py:1
+# coding=utf8
+"""

ki.stfu wrote:
> Remove please. We don't specify encoding in other files.
Rename this to 
packages/Python/lldbsuite/test/tools/lldb-mi/lexical**_**scope/Test**Mi**LexicalScope.py.


https://reviews.llvm.org/D31073



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