Re: [Lldb-commits] [PATCH] D20065: Fix race in TestExitDuringStep and unify pseudo_barrier handling

2016-05-10 Thread Pavel Labath via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269025: Fix race in TestExitDuringStep and unify 
pseudo_barrier handling (authored by labath).

Changed prior to commit:
  http://reviews.llvm.org/D20065?vs=56567&id=56669#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20065

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp
  lldb/trunk/packages/Python/lldbsuite/test/make/test_common.h

Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp
@@ -13,19 +13,9 @@
 #include 
 #include 
 
-// Note that although hogging the CPU while waiting for a variable to change
-// would be terrible in production code, it's great for testing since it
-// avoids a lot of messy context switching to get multiple threads synchronized.
 #define do_nothing()
 
-#define pseudo_barrier_wait(bar) \
---bar;   \
-while (bar > 0)  \
-do_nothing();
-
-#define pseudo_barrier_init(bar, count) (bar = count)
-
-std::atomic_int g_barrier;
+pseudo_barrier_t g_barrier;
 
 volatile int g_thread_created = 0;
 volatile int g_test = 0;
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp
@@ -23,22 +23,10 @@
 #include 
 #include 
 
-// Note that although hogging the CPU while waiting for a variable to change
-// would be terrible in production code, it's great for testing since it
-// avoids a lot of messy context switching to get multiple threads synchronized.
-#define do_nothing()
-
-#define pseudo_barrier_wait(bar) \
---bar;   \
-while (bar > 0)  \
-do_nothing();
-
-#define pseudo_barrier_init(bar, count) (bar = count)
-
 typedef std::vector > action_counts;
 typedef std::vector thread_vector;
 
-std::atomic_int g_barrier;
+pseudo_barrier_t g_barrier;
 int g_breakpoint = 0;
 int g_sigusr1_count = 0;
 std::atomic_int g_watchme;
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp
@@ -13,19 +13,7 @@
 #include 
 #include 
 
-// Note that although hogging the CPU while waiting for a variable to change
-// would be terrible in production code, it's great for testing since it
-// avoids a lot of messy context switching to get multiple threads synchronized.
-#define do_nothing()
-
-#define pseudo_barrier_wait(bar) \
---bar;   \
-while (bar > 0)  \
-do_nothing();
-
-#define pseudo_barrier_init(bar, count) (bar = count)
-
-std::atomic_int g_barrier;
+pseudo_barrier_t g_barrier;
 
 volatile int g_test = 0;
 
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp
@@ -12,21 +12,9 @@
 #include 
 #include 
 
-// Note that although hogging the CPU while waiting for a variable to change
-// would be terrible in production code, it's great for testing since it
-// avoids a lot of messy context switching to get multiple threads synchronized.
-#define do_nothing()
-
-#define pseudo_barrier_wait(bar) \
---bar;   \
-while (bar > 0)  \
-do_nothing();
-
-#define pseudo_barrier_init(bar, count) (bar = count)
-
-std::atomic_int g_barrier1;
-std::atomic_int g_barrier2;
-std::atomic_int g_barrier3;

[Lldb-commits] [lldb] r269025 - Fix race in TestExitDuringStep and unify pseudo_barrier handling

2016-05-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue May 10 02:54:25 2016
New Revision: 269025

URL: http://llvm.org/viewvc/llvm-project?rev=269025&view=rev
Log:
Fix race in TestExitDuringStep and unify pseudo_barrier handling

Summary:
TestExitDuringStep was very rarely hanging on the buildbots. I can't be sure, 
but I believe this
was because of the fact that it declared its pseudo_barrier variable as 
"volatile int", which is
not sufficient to guarantee corectness (also, all other tests used atomic 
variables for this, and
they were passing reliably AFAIK). Besides switching to an atomic variable in 
this test as well,
I have also took this opportunity to unify all the copies of the pseudo_barrier 
code to a single
place to reduce the chance of this happening again.

Reviewers: clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D20065

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp
lldb/trunk/packages/Python/lldbsuite/test/make/test_common.h

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp?rev=269025&r1=269024&r2=269025&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp
 Tue May 10 02:54:25 2016
@@ -19,24 +19,12 @@
 
 volatile int g_test = 0;
 
-// Note that although hogging the CPU while waiting for a variable to change
-// would be terrible in production code, it's great for testing since it
-// avoids a lot of messy context switching to get multiple threads 
synchronized.
-#define do_nothing()  
-
-#define pseudo_barrier_wait(bar) \
---bar;   \
-while (bar > 0)  \
-do_nothing();
-
-#define pseudo_barrier_init(bar, count) (bar = count)
-
 // A barrier to synchronize all the threads.
-std::atomic_int g_barrier1;
+pseudo_barrier_t g_barrier1;
 
 // A barrier to keep the threads from exiting until after the breakpoint has
 // been passed.
-std::atomic_int g_barrier2;
+pseudo_barrier_t g_barrier2;
 
 void *
 break_thread_func ()

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp?rev=269025&r1=269024&r2=269025&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp
 Tue May 10 02:54:25 2016
@@ -23,22 +23,10 @@ using namespace std;
 #include 
 #include 
 
-// Note that although hogging the CPU while waiting for a variable to change
-// would be terrible in production code, it's great for testing since it
-// avoids a lot of messy context switching to get multiple threads 
synchronized.
-#define do_nothing()
-
-#define pseudo_barrier_wait(bar) \
---bar;   \
-while (bar > 0)  \
-do_nothing();
-
-#define pseudo_barrier_init(bar, count) (bar = count)
-
 typedef std::vector > action_counts;
 typedef std::vector thread_vector;
 
-std::atomic_int g_barrier;
+pseudo_barrier_t g_barrier;
 int g_breakpoint = 0;
 int g_sigusr1_count = 0;
 std::atomic_int g_watchme;

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp?rev=269025&r1=269024&r2=269025&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp
 Tue May 10 02:54:25 2016
@@ -13,19 +13,9 @@
 #inclu

[Lldb-commits] [lldb] r269057 - Fix SymbolFilePDBTests.cpp

2016-05-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue May 10 08:46:22 2016
New Revision: 269057

URL: http://llvm.org/viewvc/llvm-project?rev=269057&view=rev
Log:
Fix SymbolFilePDBTests.cpp

Modified:
lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp

Modified: lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp?rev=269057&r1=269056&r2=269057&view=diff
==
--- lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp (original)
+++ lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp Tue May 10 
08:46:22 2016
@@ -134,28 +134,29 @@ protected:
 }
 
 int
-GetGlobalConstantInteger(const llvm::IPDBSession &session, llvm::StringRef 
var) const
+GetGlobalConstantInteger(const llvm::pdb::IPDBSession &session, 
llvm::StringRef var) const
 {
 auto global = session.getGlobalScope();
-auto results = global->findChildren(llvm::PDB_SymType::Data, var, 
llvm::PDB_NameSearchFlags::NS_Default);
+auto results =
+global->findChildren(llvm::pdb::PDB_SymType::Data, var, 
llvm::pdb::PDB_NameSearchFlags::NS_Default);
 uint32_t count = results->getChildCount();
 if (count == 0)
 return -1;
 
 auto item = results->getChildAtIndex(0);
-auto symbol = llvm::dyn_cast(item.get());
+auto symbol = llvm::dyn_cast(item.get());
 if (!symbol)
 return -1;
-llvm::Variant value = symbol->getValue();
+llvm::pdb::Variant value = symbol->getValue();
 switch (value.Type)
 {
-case llvm::PDB_VariantType::Int16:
+case llvm::pdb::PDB_VariantType::Int16:
 return value.Value.Int16;
-case llvm::PDB_VariantType::Int32:
+case llvm::pdb::PDB_VariantType::Int32:
 return value.Value.Int32;
-case llvm::PDB_VariantType::UInt16:
+case llvm::pdb::PDB_VariantType::UInt16:
 return value.Value.UInt16;
-case llvm::PDB_VariantType::UInt32:
+case llvm::pdb::PDB_VariantType::UInt32:
 return value.Value.UInt32;
 default:
 return 0;
@@ -396,7 +397,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_
 
 SymbolVendor *plugin = module->GetSymbolVendor();
 SymbolFilePDB *symfile = static_cast(plugin->GetSymbolFile());
-const llvm::IPDBSession &session = symfile->GetPDBSession();
+const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
 SymbolContext sc;
 llvm::DenseSet searched_files;
 TypeMap results;
@@ -417,7 +418,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_
 
 SymbolVendor *plugin = module->GetSymbolVendor();
 SymbolFilePDB *symfile = static_cast(plugin->GetSymbolFile());
-const llvm::IPDBSession &session = symfile->GetPDBSession();
+const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
 SymbolContext sc;
 llvm::DenseSet searched_files;
 TypeMap results;
@@ -427,7 +428,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_
 EXPECT_EQ(ConstString("Class::NestedClass"), udt_type->GetName());
 CompilerType compiler_type = udt_type->GetForwardCompilerType();
 
EXPECT_TRUE(ClangASTContext::IsClassType(compiler_type.GetOpaqueQualType()));
-EXPECT_EQ(GetGlobalConstantInteger(session, "sizeof_NestedClass"), 
udt_type->GetByteSize());
+EXPECT_EQ(uint64_t(GetGlobalConstantInteger(session, 
"sizeof_NestedClass")), udt_type->GetByteSize());
 }
 
 TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestClassInNamespace))
@@ -438,7 +439,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_
 
 SymbolVendor *plugin = module->GetSymbolVendor();
 SymbolFilePDB *symfile = static_cast(plugin->GetSymbolFile());
-const llvm::IPDBSession &session = symfile->GetPDBSession();
+const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
 SymbolContext sc;
 llvm::DenseSet searched_files;
 TypeMap results;
@@ -459,7 +460,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_
 
 SymbolVendor *plugin = module->GetSymbolVendor();
 SymbolFilePDB *symfile = static_cast(plugin->GetSymbolFile());
-const llvm::IPDBSession &session = symfile->GetPDBSession();
+const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
 SymbolContext sc;
 llvm::DenseSet searched_files;
 const char *EnumsToCheck[] = {"Enum", "ShortEnum"};
@@ -502,7 +503,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_
 
 SymbolVendor *plugin = module->GetSymbolVendor();
 SymbolFilePDB *symfile = static_cast(plugin->GetSymbolFile());
-const llvm::IPDBSession &session = symfile->GetPDBSession();
+const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
 SymbolContext sc;
 llvm::DenseSet searched_files;
 TypeMap results;


___
lldb-co

[Lldb-commits] [lldb] r269058 - Fix logging in Listener.cpp

2016-05-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue May 10 08:46:25 2016
New Revision: 269058

URL: http://llvm.org/viewvc/llvm-project?rev=269058&view=rev
Log:
Fix logging in Listener.cpp

Clear() log message was claiming it was the destructor, which had me very 
confused when looking
at the log messages. Fix the message, and add a log message to the real 
destructor.

Also noticed that the destructor was needlessly locking the broadcaster mutex 
(as Clear was
locking it again anyway), so remove that as well.

Modified:
lldb/trunk/source/Core/Listener.cpp

Modified: lldb/trunk/source/Core/Listener.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Listener.cpp?rev=269058&r1=269057&r2=269058&view=diff
==
--- lldb/trunk/source/Core/Listener.cpp (original)
+++ lldb/trunk/source/Core/Listener.cpp Tue May 10 08:46:25 2016
@@ -56,9 +56,12 @@ Listener::Listener(const char *name) :
 
 Listener::~Listener()
 {
-Mutex::Locker locker (m_broadcasters_mutex);
+Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
 
 Clear();
+
+if (log)
+log->Printf("%p Listener::%s('%s')", this, __FUNCTION__, 
m_name.c_str());
 }
 
 void
@@ -87,9 +90,8 @@ Listener::Clear()
 manager_sp->RemoveListener(this);
 }
 
-if (log != nullptr)
-log->Printf ("%p Listener::~Listener('%s')",
- static_cast(this), m_name.c_str());
+if (log)
+log->Printf("%p Listener::%s('%s')", this, __FUNCTION__, 
m_name.c_str());
 }
 
 uint32_t


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


[Lldb-commits] [PATCH] D20106: Generalize child process monitoring functions

2016-05-10 Thread Pavel Labath via lldb-commits
labath created this revision.
labath added reviewers: clayborg, zturner, emaste, krytarowski.
labath added a subscriber: lldb-commits.

This replaces the C-style "void *" baton of the child process monitoring 
functions with a more
C++-like API taking a std::function. The motivation for this was that it was 
very difficult to
handle the ownership of the object passed into the callback function -- each 
caller ended up
implementing his own way of doing it, some doing it better than others. With 
the new API, one can
just pass a smart pointer into the callback and all of the lifetime management 
will be handled
automatically.

This has enabled me to simplify the rather complicated handshake in 
Host::RunShellCommand. I have
left handling of MonitorDebugServerProcess (my original motivation for this 
change) to a separate
commit to reduce the scope of this change.

http://reviews.llvm.org/D20106

Files:
  include/lldb/Host/Host.h
  include/lldb/Host/HostNativeProcessBase.h
  include/lldb/Host/HostProcess.h
  include/lldb/Host/posix/HostProcessPosix.h
  include/lldb/Target/Process.h
  include/lldb/Target/ProcessLaunchInfo.h
  source/Host/common/Host.cpp
  source/Host/common/HostProcess.cpp
  source/Host/common/MonitoringProcessLauncher.cpp
  source/Host/posix/HostProcessPosix.cpp
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  source/Target/Process.cpp
  source/Target/ProcessLaunchInfo.cpp

Index: source/Target/ProcessLaunchInfo.cpp
===
--- source/Target/ProcessLaunchInfo.cpp
+++ source/Target/ProcessLaunchInfo.cpp
@@ -244,12 +244,9 @@
 }
 
 void
-ProcessLaunchInfo::SetMonitorProcessCallback (Host::MonitorChildProcessCallback callback,
-   void *baton,
-   bool monitor_signals)
+ProcessLaunchInfo::SetMonitorProcessCallback(const Host::MonitorChildProcessCallback &callback, bool monitor_signals)
 {
 m_monitor_callback = callback;
-m_monitor_callback_baton = baton;
 m_monitor_signals = monitor_signals;
 }
 
@@ -259,7 +256,6 @@
 if (m_monitor_callback && ProcessIDIsValid())
 {
 Host::StartMonitoringChildProcess (m_monitor_callback,
-   m_monitor_callback_baton,
GetProcessID(),
m_monitor_signals);
 return true;
Index: source/Target/Process.cpp
===
--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -1512,21 +1512,15 @@
 // found in the global target list (we want to be completely sure that the
 // lldb_private::Process doesn't go away before we can deliver the signal.
 bool
-Process::SetProcessExitStatus (void *callback_baton,
-   lldb::pid_t pid,
-   bool exited,
-   int signo,  // Zero for no signal
-   int exit_status // Exit value of process if signal is zero
-)
+Process::SetProcessExitStatus(lldb::pid_t pid, bool exited,
+  int signo,  // Zero for no signal
+  int exit_status // Exit value of process if signal is zero
+  )
 {
 Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PROCESS));
 if (log)
-log->Printf ("Process::SetProcessExitStatus (baton=%p, pid=%" PRIu64 ", exited=%i, signal=%i, exit_status=%i)\n",
- callback_baton,
- pid,
- exited,
- signo,
- exit_status);
+log->Printf("Process::SetProcessExitStatus (pid=%" PRIu64 ", exited=%i, signal=%i, exit_status=%i)\n", pid,
+exited, signo, exit_status);
 
 if (exited)
 {
Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
===
--- source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -405,11 +405,7 @@
 AsyncThread (void *arg);
 
 static bool
-MonitorDebugserverProcess (void *callback_baton,
-   lldb::pid_t pid,
-   bool exited,
-   int signo,
-   int exit_status);
+MonitorDebugserverProcess(ProcessGDBRemote *process, lldb::pid_t pid, bool exited, int signo, int exit_status);
 
 lldb::StateType
 SetThreadStopInfo (StringExtractor& stop_packet);
Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===

[Lldb-commits] [PATCH] D20107: Fix a race in ProcessGDBRemote::MonitorDebugServerProcess

2016-05-10 Thread Pavel Labath via lldb-commits
labath created this revision.
labath added a reviewer: clayborg.
labath added subscribers: lldb-commits, tberghammer.

MonitorDebugServerProcess went to a lot of effort to make sure its asynchronous 
invocation does
not cause any mischief, but it was still not race-free. Specifically, in a 
quick stop-restart
sequence (like the one in TestAddressBreakpoints) the copying of the process 
shared pointer via
target_sp->GetProcessSP() was racing with the resetting of the pointer in 
DeleteCurrentProcess,
as they were both accessing the same shared_ptr object.

To avoid this, I simply pass in a weak_ptr to the process when the callback is 
created. Locking
this pointer is race-free as they are two separate object even though they 
point to the same
process instance. This also removes the need for the complicated tap-dance 
around retrieving the
process pointer.

http://reviews.llvm.org/D20107

Files:
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.h

Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
===
--- source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -405,7 +405,8 @@
 AsyncThread (void *arg);
 
 static bool
-MonitorDebugserverProcess(ProcessGDBRemote *process, lldb::pid_t pid, bool exited, int signo, int exit_status);
+MonitorDebugserverProcess(std::weak_ptr process_wp, lldb::pid_t pid, bool exited, int signo,
+  int exit_status);
 
 lldb::StateType
 SetThreadStopInfo (StringExtractor& stop_packet);
Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -3597,7 +3597,8 @@
 // special terminal key sequences (^C) don't affect debugserver.
 debugserver_launch_info.SetLaunchInSeparateProcessGroup(true);
 
-debugserver_launch_info.SetMonitorProcessCallback(std::bind(MonitorDebugserverProcess, this, _1, _2, _3, _4),
+const std::weak_ptr this_wp = std::static_pointer_cast(shared_from_this());
+debugserver_launch_info.SetMonitorProcessCallback(std::bind(MonitorDebugserverProcess, this_wp, _1, _2, _3, _4),
   false);
 debugserver_launch_info.SetUserID(process_info.GetUserID());
 
@@ -3660,87 +3661,58 @@
 }
 
 bool
-ProcessGDBRemote::MonitorDebugserverProcess(ProcessGDBRemote *process, lldb::pid_t debugserver_pid,
+ProcessGDBRemote::MonitorDebugserverProcess(std::weak_ptr process_wp, lldb::pid_t debugserver_pid,
 bool exited,// True if the process did exit
 int signo,  // Zero for no signal
 int exit_status // Exit value of process if signal is zero
 )
 {
-// The baton is a "ProcessGDBRemote *". Now this class might be gone
-// and might not exist anymore, so we need to carefully try to get the
-// target for this process first since we have a race condition when
-// we are done running between getting the notice that the inferior
-// process has died and the debugserver that was debugging this process.
-// In our test suite, we are also continually running process after
-// process, so we must be very careful to make sure:
-// 1 - process object hasn't been deleted already
-// 2 - that a new process object hasn't been recreated in its place
-
 // "debugserver_pid" argument passed in is the process ID for
 // debugserver that we are tracking...
 Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+const bool handled = true;
 
-// Get a shared pointer to the target that has a matching process pointer.
-// This target could be gone, or the target could already have a new process
-// object inside of it
-TargetSP target_sp (Debugger::FindTargetWithProcess(process));
+if (log)
+log->Printf("ProcessGDBRemote::%s(process_wp, pid=%" PRIu64 ", signo=%i (0x%x), exit_status=%i)", __FUNCTION__,
+debugserver_pid, signo, signo, exit_status);
 
+std::shared_ptr process_sp = process_wp.lock();
 if (log)
-log->Printf("ProcessGDBRemote::%s(process=%p, pid=%" PRIu64 ", signo=%i (0x%x), exit_status=%i)", __FUNCTION__,
-process, debugserver_pid, signo, signo, exit_status);
-
-if (target_sp)
-{
-// We found a process in a target that matches, but another thread
-// might be in the process of launching a new process that will
-// soon replace it, so get a shared pointer to the process so we
-// can keep it alive.
-  

Re: [Lldb-commits] [PATCH] D20106: Generalize child process monitoring functions

2016-05-10 Thread Pavel Labath via lldb-commits
labath added a comment.

I am going to try building this on as many systems as I can get my hands on 
tomorrow, as I am pretty sure I have missed some changes on host-specific code. 
I am posting this here now, to get early feedback and some round-trips.


http://reviews.llvm.org/D20106



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


Re: [Lldb-commits] [PATCH] D20106: Generalize child process monitoring functions

2016-05-10 Thread Pavel Labath via lldb-commits
labath added a comment.

In http://reviews.llvm.org/D20106#425825, @labath wrote:

> I am going to try building this on as many systems as I can get my hands on 
> tomorrow, as I am pretty sure I have missed some changes on host-specific 
> code. I am posting this here now, to get early feedback and some round-trips.


... **avoid** some round-trips.


http://reviews.llvm.org/D20106



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


Re: [Lldb-commits] [PATCH] D20107: Fix a race in ProcessGDBRemote::MonitorDebugServerProcess

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

Looks good.


http://reviews.llvm.org/D20107



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


[Lldb-commits] [lldb] r269095 - In some cases, type lookup has to deal with situations where it cannot reconstruct a compile unit or a function, but it still has a valid symbol - and it can use that i

2016-05-10 Thread Enrico Granata via lldb-commits
Author: enrico
Date: Tue May 10 13:16:33 2016
New Revision: 269095

URL: http://llvm.org/viewvc/llvm-project?rev=269095&view=rev
Log:
In some cases, type lookup has to deal with situations where it cannot 
reconstruct a compile unit or a function, but it still has a valid symbol - and 
it can use that in order to figure out the preferential language for lookups

This is not the right thing for all clients (notably the expression parser), so 
put it in type lookup specific code

Fixes rdar://problem/22422313


Modified:
lldb/trunk/source/Commands/CommandObjectType.cpp

Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=269095&r1=269094&r2=269095&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Tue May 10 13:16:33 2016
@@ -34,6 +34,7 @@
 #include "lldb/Interpreter/OptionValueBoolean.h"
 #include "lldb/Interpreter/OptionValueLanguage.h"
 #include "lldb/Interpreter/OptionValueString.h"
+#include "lldb/Symbol/Symbol.h"
 #include "lldb/Target/Language.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/StackFrame.h"
@@ -3209,6 +3210,27 @@ CommandObjectTypeFilterAdd::CommandOptio
 class CommandObjectTypeLookup : public CommandObjectRaw
 {
 protected:
+// this function is allowed to do a more aggressive job at guessing 
languages than the expression parser
+// is comfortable with - so leave the original call alone and add one that 
is specific to type lookup
+lldb::LanguageType
+GuessLanguage (StackFrame *frame)
+{
+lldb::LanguageType lang_type = lldb::eLanguageTypeUnknown;
+
+if (!frame)
+return lang_type;
+
+lang_type = frame->GuessLanguage();
+if (lang_type != lldb::eLanguageTypeUnknown)
+return lang_type;
+
+Symbol *s = frame->GetSymbolContext(eSymbolContextSymbol).symbol;
+if (s)
+lang_type = s->GetMangled().GuessLanguage();
+
+return lang_type;
+}
+
 class CommandOptions : public OptionGroup
 {
 public:
@@ -3403,7 +3425,7 @@ public:
 // so the cost of the sort is going to be dwarfed by the actual lookup 
anyway
 if (StackFrame* frame = m_exe_ctx.GetFramePtr())
 {
-LanguageType lang = frame->GuessLanguage();
+LanguageType lang = GuessLanguage(frame);
 if (lang != eLanguageTypeUnknown)
 {
 std::sort(languages.begin(),


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


Re: [Lldb-commits] [PATCH] D20106: Generalize child process monitoring functions

2016-05-10 Thread Greg Clayton via lldb-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

Just get rid of the extra typedef as specified in inline comments and this is 
good to go.



Comment at: include/lldb/Host/HostProcess.h:41
@@ -41,1 +40,3 @@
+public:
+typedef Host::MonitorChildProcessCallback MonitorCallback;
 

We can probably get rid of this and just use Host::MonitorChildProcessCallback


Comment at: include/lldb/Host/HostProcess.h:54
@@ -53,1 +53,3 @@
+HostThread
+StartMonitoring(const MonitorCallback &callback, bool monitor_signals);
 

Use Host::MonitorChildProcessCallback directly.


Comment at: include/lldb/Host/posix/HostProcessPosix.h:43
@@ -43,1 +42,3 @@
+HostThread
+StartMonitoring(const HostProcess::MonitorCallback &callback, bool 
monitor_signals) override;
 };

Use Host::MonitorChildProcessCallback directly


http://reviews.llvm.org/D20106



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


Re: [Lldb-commits] [PATCH] D20106: Generalize child process monitoring functions

2016-05-10 Thread Zachary Turner via lldb-commits
It's too bad llvm doesn't have an equivalent of boost::any, because that
would be perfect here :-/

On Tue, May 10, 2016 at 12:39 PM Greg Clayton  wrote:

> clayborg requested changes to this revision.
> clayborg added a comment.
> This revision now requires changes to proceed.
>
> Just get rid of the extra typedef as specified in inline comments and this
> is good to go.
>
>
> 
> Comment at: include/lldb/Host/HostProcess.h:41
> @@ -41,1 +40,3 @@
> +public:
> +typedef Host::MonitorChildProcessCallback MonitorCallback;
>
> 
> We can probably get rid of this and just use
> Host::MonitorChildProcessCallback
>
> 
> Comment at: include/lldb/Host/HostProcess.h:54
> @@ -53,1 +53,3 @@
> +HostThread
> +StartMonitoring(const MonitorCallback &callback, bool
> monitor_signals);
>
> 
> Use Host::MonitorChildProcessCallback directly.
>
> 
> Comment at: include/lldb/Host/posix/HostProcessPosix.h:43
> @@ -43,1 +42,3 @@
> +HostThread
> +StartMonitoring(const HostProcess::MonitorCallback &callback, bool
> monitor_signals) override;
>  };
> 
> Use Host::MonitorChildProcessCallback directly
>
>
> http://reviews.llvm.org/D20106
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D20106: Generalize child process monitoring functions

2016-05-10 Thread Ed Maste via lldb-commits
emaste added a comment.

Nice.

For test building FreeBSD, snapshot VM images are available at 
ftp://ftp.freebsd.org/pub/FreeBSD/snapshots/VM-IMAGES/11.0-CURRENT/amd64/Latest/
 and I have some instructions for building lldb on FreeBSD at 
https://wiki.freebsd.org/lldb.


http://reviews.llvm.org/D20106



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


Re: [Lldb-commits] [lldb] r269025 - Fix race in TestExitDuringStep and unify pseudo_barrier handling

2016-05-10 Thread Ed Maste via lldb-commits
On 10 May 2016 at 03:54, Pavel Labath via lldb-commits
 wrote:
> Author: labath
> Date: Tue May 10 02:54:25 2016
> New Revision: 269025
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269025&view=rev
> Log:
> Fix race in TestExitDuringStep and unify pseudo_barrier handling

After this change TestThreadExit is failing on FreeBSD 10 with:
...
  File 
"/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py",
line 36, in test
bp3_id = lldbutil.run_break_set_by_file_and_line (self,
"main.cpp", self.break_3, num_expected_locations=1)
  File 
"/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/lldbutil.py",
line 342, in run_break_set_by_file_and_line
check_breakpoint_result (test, break_results, num_locations =
num_expected_locations)
  File 
"/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/lldbutil.py",
line 474, in check_breakpoint_result
test.assertTrue (num_locations == out_num_locations, "Expecting %d
locations, got %d."%(num_locations, out_num_locations))
AssertionError: False is not True : Expecting 1 locations, got 2.
...

"breakpoint list" shows:

3: file = 
'/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp',
line = 67, locations = 2
  3.1: where = a.out`main + 1437 at main.cpp:67, address =
0x004018bd, unresolved, hit count = 0
  3.2: where = a.out`main + 1846 at main.cpp:67, address =
0x00401a56, unresolved, hit count = 0
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D20035: Add source file mapping to inline frames' SymbolContext line_entry.file

2016-05-10 Thread Ted Woodward via lldb-commits
ted abandoned this revision.
ted added a comment.

Problem will be fixed in another way.


http://reviews.llvm.org/D20035



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


[Lldb-commits] [PATCH] D20135: Keep original source path and mapped path in LineEntry

2016-05-10 Thread Ted Woodward via lldb-commits
ted created this revision.
ted added reviewers: jingham, clayborg.
ted added a subscriber: lldb-commits.

The "file" variable in a LineEntry was mapped using target.source-map, except 
when stepping through inlined code. This patch adds a new variable to 
LineEntry, "original_file", that contains the original file from the debug 
info. "file" will continue to (possibly) be mapped.

Some code has been changed to use "original_file". This is code dealing with 
symbols. Code dealing with source files will still use "file". Reviewers, 
please confirm that these particular changes are correct.

Tests run on Ubuntu 12.04 show no regression.

http://reviews.llvm.org/D20135

Files:
  include/lldb/Symbol/LineEntry.h
  source/Breakpoint/BreakpointResolver.cpp
  source/Symbol/LineEntry.cpp
  source/Symbol/LineTable.cpp
  source/Symbol/SymbolContext.cpp
  source/Target/StackFrame.cpp
  source/Target/StackFrameList.cpp
  source/Target/ThreadPlanStepOverRange.cpp
  source/Target/ThreadPlanStepRange.cpp

Index: source/Target/ThreadPlanStepRange.cpp
===
--- source/Target/ThreadPlanStepRange.cpp
+++ source/Target/ThreadPlanStepRange.cpp
@@ -155,7 +155,7 @@
 SymbolContext new_context(frame->GetSymbolContext(eSymbolContextEverything));
 if (m_addr_context.line_entry.IsValid() && new_context.line_entry.IsValid())
 {
-if (m_addr_context.line_entry.file == new_context.line_entry.file)
+if (m_addr_context.line_entry.original_file == new_context.line_entry.original_file)
 {
 if (m_addr_context.line_entry.line == new_context.line_entry.line)
 {
Index: source/Target/ThreadPlanStepOverRange.cpp
===
--- source/Target/ThreadPlanStepOverRange.cpp
+++ source/Target/ThreadPlanStepOverRange.cpp
@@ -256,7 +256,7 @@
 // some code fragment by using #include  directly.
 LineEntry prev_line_entry;
 if (line_table->GetLineEntryAtIndex(entry_idx - 1, prev_line_entry)
-&& prev_line_entry.file == line_entry.file)
+&& prev_line_entry.original_file == line_entry.original_file)
 {
 SymbolContext prev_sc;
 Address prev_address = prev_line_entry.range.GetBaseAddress();
@@ -289,7 +289,7 @@
 if (next_line_function != m_addr_context.function)
 break;
 
-if (next_line_entry.file == m_addr_context.line_entry.file)
+if (next_line_entry.original_file == m_addr_context.line_entry.original_file)
 {
 const bool abort_other_plans = false;
 const RunMode stop_other_threads = RunMode::eAllThreads;
Index: source/Target/StackFrameList.cpp
===
--- source/Target/StackFrameList.cpp
+++ source/Target/StackFrameList.cpp
@@ -350,6 +350,7 @@
 if (unwind_block)
 {
 Address curr_frame_address (unwind_frame_sp->GetFrameCodeAddress());
+TargetSP target_sp = m_thread.CalculateTarget();
 // Be sure to adjust the frame address to match the address
 // that was used to lookup the symbol context above. If we are
 // in the first concrete frame, then we lookup using the current
@@ -362,9 +363,8 @@
 // If curr_frame_address points to the first address in a section then after
 // adjustment it will point to an other section. In that case resolve the
 // address again to the correct section plus offset form.
-TargetSP target = m_thread.CalculateTarget();
-addr_t load_addr = curr_frame_address.GetOpcodeLoadAddress(target.get(), eAddressClassCode);
-curr_frame_address.SetOpcodeLoadAddress(load_addr - 1, target.get(), eAddressClassCode);
+addr_t load_addr = curr_frame_address.GetOpcodeLoadAddress(target_sp.get(), eAddressClassCode);
+curr_frame_address.SetOpcodeLoadAddress(load_addr - 1, target_sp.get(), eAddressClassCode);
 }
 else
 {
@@ -377,17 +377,18 @@
 
 while (unwind_sc.GetParentOfInlinedScope(curr_frame_address, next_frame_sc, next_frame_address))
 {
-StackFra

Re: [Lldb-commits] [PATCH] D20135: Keep original source path and mapped path in LineEntry

2016-05-10 Thread Jim Ingham via lldb-commits
jingham requested changes to this revision.
jingham added a comment.
This revision now requires changes to proceed.

This approach seems right to me.

See the inline comment for BreakpointResolver.

In ThreadPlanStepOverRange at line 235 this instance should also be changed to 
original_file:

  if (sc.line_entry.file != m_addr_context.line_entry.file

Also, there are a couple of places where we test equality of the files in 
line_entries:

the "struct SourceInfo" operators in CommandObjectSource
LineEntry::GetSameLineContiguousAddressRange () const

I am pretty sure both of those should test original_file, so they don't depend 
on when/if the line_entries tested got re-mapped.



Comment at: source/Breakpoint/BreakpointResolver.cpp:88-93
@@ -87,8 +87,8 @@
 {
-match_file_spec = sc.line_entry.file;
+match_file_spec = sc.line_entry.original_file;
 matches = true;
 first_entry = false;
 }
 else
-matches = (sc.line_entry.file == match_file_spec);
+matches = (sc.line_entry.original_file == match_file_spec);
 

In this case, we probably want to try both.  This code is where we set file & 
line breakpoints.  If we're showing the re-mapped file in source listings or 
anything like that, we should allow people to use it to set breakpoints.  But I 
wouldn't want setting breakpoints by the debug info name to fail as well.


http://reviews.llvm.org/D20135



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