[Lldb-commits] [PATCH] D65691: Various build fixes for lldb on MinGW

2019-08-03 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In D65691#1613395 , @mstorsjo wrote:

> As context (I haven't followed lldb almost at all), what's the general status 
> of lldb on windows - generally working, or still a work in progress? Does it 
> work with dwarf debug info in COFF (as commonly used in mingw environments), 
> in addition to PDB? I.e. is the existing dwarf support tied to the ELF/MachO 
> formats, or is it decoupled?


It is decoupled. As long as the ObjectFileCOFF hands out the right section for 
the section enumeration in lldb-enumerations.h in the lldb::SectionType, it 
should all just work. The enumerations in question are all of the enums that 
start with eSectionTypeDWARF. It seems to have support in 
ObjectFilePECOFF::CreateSections(...). So I think it should all just work. Let 
us know if there are any issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65691



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


[Lldb-commits] [PATCH] D65691: Various build fixes for lldb on MinGW

2019-08-03 Thread Dávid Bolvanský via Phabricator via lldb-commits
xbolva00 added inline comments.



Comment at: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:19
 #endif
+#ifdef __MINGW32__
+// usleep

Maybe drop usleep and use C++’s

https://en.cppreference.com/w/cpp/thread/sleep_for ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65691



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


[Lldb-commits] [PATCH] D65555: [lldb] [Process/NetBSD] Enable reporting of new and exited threads [WIP]

2019-08-03 Thread Michał Górny via Phabricator via lldb-commits
mgorny marked 6 inline comments as done.
mgorny added a comment.

@jfb, could you please remove your red flag now? ;-)




Comment at: lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:738
+if (*it && ((*it)->GetID() == thread_id)) {
+  m_threads.erase(it);
+  break;

mgorny wrote:
> Note to self, this should be `it =... `
Nevermind myself. It `breaks` immediately, so it doesn't matter.


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

https://reviews.llvm.org/D6



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


[Lldb-commits] [PATCH] D65555: [lldb] [Process/NetBSD] Enable reporting of new and exited threads [WIP]

2019-08-03 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 213231.

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

https://reviews.llvm.org/D6

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentBreakpointOneDelayBreakpointThreads.py
  
lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentCrashWithBreak.py
  
lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentCrashWithSignal.py
  
lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentDelayedCrashWithBreakpointSignal.py
  
lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointThreads.py
  
lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
  
lldb/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py
  lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
  lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h

Index: lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
===
--- lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
+++ lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
@@ -98,6 +98,7 @@
   bool HasThreadNoLock(lldb::tid_t thread_id);
 
   NativeThreadNetBSD &AddThread(lldb::tid_t thread_id);
+  void RemoveThread(lldb::tid_t thread_id);
 
   void MonitorCallback(lldb::pid_t pid, int signal);
   void MonitorExited(lldb::pid_t pid, WaitStatus status);
Index: lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
===
--- lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
+++ lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
@@ -9,7 +9,6 @@
 #include "NativeProcessNetBSD.h"
 
 
-
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
 #include "lldb/Host/HostProcess.h"
 #include "lldb/Host/common/NativeRegisterContext.h"
@@ -99,6 +98,14 @@
   pid, launch_info.GetPTY().ReleaseMasterFileDescriptor(), native_delegate,
   Info.GetArchitecture(), mainloop));
 
+  // Enable event reporting
+  ptrace_event_t events;
+  // TODO: PTRACE_FORK | PTRACE_VFORK | PTRACE_POSIX_SPAWN?
+  events.pe_set_event = PTRACE_LWP_CREATE | PTRACE_LWP_EXIT;
+  status = PtraceWrapper(PT_SET_EVENT_MASK, pid, &events, sizeof(events));
+  if (status.Fail())
+return status.ToError();
+
   status = process_up->ReinitializeThreads();
   if (status.Fail())
 return status.ToError();
@@ -238,6 +245,30 @@
   static_cast(*thread).SetStoppedByExec();
 SetState(StateType::eStateStopped, true);
   } break;
+  case TRAP_LWP: {
+ptrace_state_t pst;
+Status error = PtraceWrapper(PT_GET_PROCESS_STATE, GetID(), &pst,
+ sizeof(pst));
+if (error.Fail()) {
+  SetState(StateType::eStateInvalid);
+  return;
+}
+
+switch (pst.pe_report_event) {
+  case PTRACE_LWP_CREATE:
+AddThread(pst.pe_lwp);
+break;
+  case PTRACE_LWP_EXIT:
+RemoveThread(pst.pe_lwp);
+break;
+}
+
+error = PtraceWrapper(PT_CONTINUE, GetID(), reinterpret_cast(1), 0);
+if (error.Fail()) {
+  SetState(StateType::eStateInvalid);
+  return;
+}
+  } break;
   case TRAP_DBREG: {
 // Find the thread.
 NativeThreadNetBSD* thread = nullptr;
@@ -694,6 +725,21 @@
   return static_cast(*m_threads.back());
 }
 
+void NativeProcessNetBSD::RemoveThread(lldb::tid_t thread_id) {
+  Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD));
+  LLDB_LOG(log, "pid {0} removing thread with tid {1}", GetID(), thread_id);
+
+  assert(HasThreadNoLock(thread_id) &&
+ "attempted to remove a thread that does not exist");
+
+  for (auto it = m_threads.begin(); it != m_threads.end(); ++it) {
+if ((*it)->GetID() == thread_id) {
+  m_threads.erase(it);
+  break;
+}
+  }
+}
+
 Status NativeProcessNetBSD::Attach() {
   // Attach to the requested process.
   // An attach will cause the thread to stop with a SIGSTOP.
Index: lldb/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py
@@ -25,7 +25,6 @@
 bugnumber="llvm.org/pr18066 inferior does not exit")
 @skipIfWindows # This test will hang on windows llvm.org/pr21753
 @expectedFailureAll(oslist=["windows"])
-@expectedFailureNetBSD
 def test_step_single_thread(self):
 """Test thread step out on one thread via command interpreter. """
 self.build(dictionary=self.getBuildFlags())
@@ -42,7 +41,6 @@
 @skipIfWindows # This test will hang on windows llvm.org/pr2