[Lldb-commits] [lldb] r319731 - Add target.process.stop-on-exec setting, and obey it.
Jim Ingham via lldb-commits
lldb-commits at lists.llvm.org
Mon Dec 4 18:50:45 PST 2017
Author: jingham
Date: Mon Dec 4 18:50:45 2017
New Revision: 319731
URL: http://llvm.org/viewvc/llvm-project?rev=319731&view=rev
Log:
Add target.process.stop-on-exec setting, and obey it.
Also add a test. There should also be control for this
in ProcessLaunchInfo and a "target launch" flag, but at least
this will allow you to control it somehow.
<rdar://problem/35842137>
Modified:
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
lldb/trunk/source/Target/Process.cpp
lldb/trunk/source/Target/StopInfo.cpp
Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=319731&r1=319730&r2=319731&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Mon Dec 4 18:50:45 2017
@@ -99,6 +99,8 @@ public:
bool GetWarningsOptimization() const;
+ bool GetStopOnExec() const;
+
protected:
static void OptionValueChangedCallback(void *baton,
OptionValue *option_value);
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py?rev=319731&r1=319730&r2=319731&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py Mon Dec 4 18:50:45 2017
@@ -29,7 +29,16 @@ class ExecTestCase(TestBase):
@skipUnlessDarwin
@expectedFailureAll(archs=['i386'], bugnumber="rdar://28656532")
@expectedFailureAll(oslist=["ios", "tvos", "watchos", "bridgeos"], bugnumber="rdar://problem/34559552") # this exec test has problems on ios systems
- def test(self):
+ def test_hitting_exec (self):
+ self.do_test(False)
+
+ @skipUnlessDarwin
+ @expectedFailureAll(archs=['i386'], bugnumber="rdar://28656532")
+ @expectedFailureAll(oslist=["ios", "tvos", "watchos", "bridgeos"], bugnumber="rdar://problem/34559552") # this exec test has problems on ios systems
+ def test_skipping_exec (self):
+ self.do_test(False)
+
+ def do_test(self, skip_exec):
if self.getArchitecture() == 'x86_64':
source = os.path.join(os.getcwd(), "main.cpp")
o_file = os.path.join(os.getcwd(), "main.o")
@@ -60,6 +69,16 @@ class ExecTestCase(TestBase):
None, None, self.get_process_working_directory())
self.assertTrue(process, PROCESS_IS_VALID)
+ if skip_exec:
+ self.debugger.HandleCommand("settings set target.process.stop-on-exec false")
+ def cleanup():
+ self.runCmd("settings set target.process.stop-on-exec false",
+ check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+
for i in range(6):
# The stop reason of the thread should be breakpoint.
self.assertTrue(process.GetState() == lldb.eStateStopped,
@@ -84,17 +103,18 @@ class ExecTestCase(TestBase):
# Run and we should stop due to exec
process.Continue()
- self.assertTrue(process.GetState() == lldb.eStateStopped,
- "Process should be stopped at __dyld_start")
+ if not skip_exec:
+ self.assertTrue(process.GetState() == lldb.eStateStopped,
+ "Process should be stopped at __dyld_start")
+
+ threads = lldbutil.get_stopped_threads(
+ process, lldb.eStopReasonExec)
+ self.assertTrue(
+ len(threads) == 1,
+ "We got a thread stopped for exec.")
- threads = lldbutil.get_stopped_threads(
- process, lldb.eStopReasonExec)
- self.assertTrue(
- len(threads) == 1,
- "We got a thread stopped for exec.")
-
- # Run and we should stop at breakpoint in main after exec
- process.Continue()
+ # Run and we should stop at breakpoint in main after exec
+ process.Continue()
threads = lldbutil.get_threads_stopped_at_breakpoint(
process, breakpoint)
Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=319731&r1=319730&r2=319731&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Mon Dec 4 18:50:45 2017
@@ -144,6 +144,9 @@ static PropertyDefinition g_properties[]
{"optimization-warnings", OptionValue::eTypeBoolean, false, true, nullptr,
nullptr, "If true, warn when stopped in code that is optimized where "
"stepping and variable availability may not behave as expected."},
+ {"stop-on-exec", OptionValue::eTypeBoolean, true, true,
+ nullptr, nullptr,
+ "If true, stop when a shared library is loaded or unloaded."},
{nullptr, OptionValue::eTypeInvalid, false, 0, nullptr, nullptr, nullptr}};
enum {
@@ -155,7 +158,8 @@ enum {
ePropertyStopOnSharedLibraryEvents,
ePropertyDetachKeepsStopped,
ePropertyMemCacheLineSize,
- ePropertyWarningOptimization
+ ePropertyWarningOptimization,
+ ePropertyStopOnExec
};
ProcessProperties::ProcessProperties(lldb_private::Process *process)
@@ -271,6 +275,12 @@ bool ProcessProperties::GetWarningsOptim
return m_collection_sp->GetPropertyAtIndexAsBoolean(
nullptr, idx, g_properties[idx].default_uint_value != 0);
}
+
+bool ProcessProperties::GetStopOnExec() const {
+ const uint32_t idx = ePropertyStopOnExec;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(
+ nullptr, idx, g_properties[idx].default_uint_value != 0);
+}
void ProcessInstanceInfo::Dump(Stream &s, Platform *platform) const {
const char *cstr;
Modified: lldb/trunk/source/Target/StopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=319731&r1=319730&r2=319731&view=diff
==============================================================================
--- lldb/trunk/source/Target/StopInfo.cpp (original)
+++ lldb/trunk/source/Target/StopInfo.cpp Mon Dec 4 18:50:45 2017
@@ -1088,6 +1088,10 @@ private:
ExpressionVariableSP m_expression_variable_sp;
};
+//----------------------------------------------------------------------
+// StopInfoExec
+//----------------------------------------------------------------------
+
class StopInfoExec : public StopInfo {
public:
StopInfoExec(Thread &thread)
@@ -1095,6 +1099,13 @@ public:
~StopInfoExec() override = default;
+ bool ShouldStop(Event *event_ptr) override {
+ ThreadSP thread_sp(m_thread_wp.lock());
+ if (thread_sp)
+ return thread_sp->GetProcess()->GetStopOnExec();
+ return false;
+ }
+
StopReason GetStopReason() const override { return eStopReasonExec; }
const char *GetDescription() override { return "exec"; }
More information about the lldb-commits
mailing list