[Lldb-commits] [lldb] r176492 - Add support on POSIX to determine if an inferior has changed while debugging it.
Matt Kopec
Matt.Kopec at intel.com
Tue Mar 5 09:23:58 PST 2013
Author: mkopec
Date: Tue Mar 5 11:23:57 2013
New Revision: 176492
URL: http://llvm.org/viewvc/llvm-project?rev=176492&view=rev
Log:
Add support on POSIX to determine if an inferior has changed while debugging it.
Modified:
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
lldb/trunk/test/functionalities/inferior-changed/TestInferiorChanged.py
Modified: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp?rev=176492&r1=176491&r2=176492&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp Tue Mar 5 11:23:57 2013
@@ -114,7 +114,7 @@ DynamicLoaderPOSIXDYLD::DidAttach()
m_auxv.reset(new AuxVector(m_process));
- executable = m_process->GetTarget().GetExecutableModule();
+ executable = GetTargetExecutable();
load_offset = ComputeLoadOffset();
if (executable.get() && load_offset != LLDB_INVALID_ADDRESS)
@@ -135,7 +135,7 @@ DynamicLoaderPOSIXDYLD::DidLaunch()
m_auxv.reset(new AuxVector(m_process));
- executable = m_process->GetTarget().GetExecutableModule();
+ executable = GetTargetExecutable();
load_offset = ComputeLoadOffset();
if (executable.get() && load_offset != LLDB_INVALID_ADDRESS)
@@ -148,6 +148,46 @@ DynamicLoaderPOSIXDYLD::DidLaunch()
}
}
+ModuleSP
+DynamicLoaderPOSIXDYLD::GetTargetExecutable()
+{
+ Target &target = m_process->GetTarget();
+ ModuleSP executable = target.GetExecutableModule();
+
+ if (executable.get())
+ {
+ if (executable->GetFileSpec().Exists())
+ {
+ ModuleSpec module_spec (executable->GetFileSpec(), executable->GetArchitecture());
+ ModuleSP module_sp (new Module (module_spec));
+
+ // Check if the executable has changed and set it to the target executable if they differ.
+ if (module_sp.get() && module_sp->GetUUID().IsValid() && executable->GetUUID().IsValid())
+ {
+ if (module_sp->GetUUID() != executable->GetUUID())
+ executable.reset();
+ }
+ else if (executable->FileHasChanged())
+ {
+ executable.reset();
+ }
+
+ if (!executable.get())
+ {
+ executable = target.GetSharedModule(module_spec);
+ if (executable.get() != target.GetExecutableModulePointer())
+ {
+ // Don't load dependent images since we are in dyld where we will know
+ // and find out about all images that are loaded
+ const bool get_dependent_images = false;
+ target.SetExecutableModule(executable, get_dependent_images);
+ }
+ }
+ }
+ }
+ return executable;
+}
+
Error
DynamicLoaderPOSIXDYLD::ExecutePluginCommand(Args &command, Stream *strm)
{
Modified: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h?rev=176492&r1=176491&r2=176492&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h Tue Mar 5 11:23:57 2013
@@ -158,6 +158,11 @@ protected:
lldb::addr_t
GetEntryPoint();
+ /// Checks to see if the target module has changed, updates the target
+ /// accordingly and returns the target executable module.
+ lldb::ModuleSP
+ GetTargetExecutable();
+
private:
DISALLOW_COPY_AND_ASSIGN(DynamicLoaderPOSIXDYLD);
};
Modified: lldb/trunk/test/functionalities/inferior-changed/TestInferiorChanged.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/inferior-changed/TestInferiorChanged.py?rev=176492&r1=176491&r2=176492&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/inferior-changed/TestInferiorChanged.py (original)
+++ lldb/trunk/test/functionalities/inferior-changed/TestInferiorChanged.py Tue Mar 5 11:23:57 2013
@@ -21,12 +21,15 @@ class ChangedInferiorTestCase(TestBase):
self.setTearDownCleanup(dictionary=d)
self.inferior_not_crashing()
- @expectedFailureLinux # bugzilla 14662 - POSIX dynamic loader asserts on re-launch
def test_inferior_crashing_dwarf(self):
"""Test lldb reloads the inferior after it was changed during the session."""
self.buildDwarf()
self.inferior_crashing()
self.cleanup()
+ # lldb needs to recognize the inferior has changed. If lldb needs to check the
+ # new module timestamp, make sure it is not the same as the old one, so add a
+ # 1 second delay.
+ time.sleep(1)
d = {'C_SOURCES': 'main2.c'}
self.buildDwarf(dictionary=d)
self.setTearDownCleanup(dictionary=d)
@@ -46,16 +49,19 @@ class ChangedInferiorTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
- # FIXME: This expected stop reason is Darwin-specific
+ if sys.platform.startswith("darwin"):
+ stop_reason = 'stop reason = EXC_BAD_ACCESS'
+ else:
+ stop_reason = 'stop reason = invalid address'
+
# The stop reason of the thread should be a bad access exception.
self.expect("thread list", STOPPED_DUE_TO_EXC_BAD_ACCESS,
substrs = ['stopped',
- 'stop reason = EXC_BAD_ACCESS'])
+ stop_reason])
- # FIXME: This expected stop reason is Darwin-specific
# And it should report the correct line number.
self.expect("thread backtrace all",
- substrs = ['stop reason = EXC_BAD_ACCESS',
+ substrs = [stop_reason,
'main.c:%d' % self.line1])
def inferior_not_crashing(self):
@@ -64,8 +70,12 @@ class ChangedInferiorTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
self.runCmd("process status")
- # FIXME: This unexpected stop reason is Darwin-specific
- if 'EXC_BAD_ACCESS' in self.res.GetOutput():
+ if sys.platform.startswith("darwin"):
+ stop_reason = 'EXC_BAD_ACCESS'
+ else:
+ stop_reason = 'invalid address'
+
+ if stop_reason in self.res.GetOutput():
self.fail("Inferior changed, but lldb did not perform a reload")
# Break inside the main.
More information about the lldb-commits
mailing list