[Lldb-commits] [lldb] r251505 - Changes for Bug 17384

Ravitheja Addepally via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 28 02:47:30 PDT 2015


Author: ravitheja
Date: Wed Oct 28 04:47:29 2015
New Revision: 251505

URL: http://llvm.org/viewvc/llvm-project?rev=251505&view=rev
Log:
Changes for Bug 17384

Summary:
Virtual dynamic shared objects, or vdso files were 
not loaded for Linux OS.In Bug 17384 the call 
stack could not be unwinded from functions
residing in the vdso object.

This commit adds support for loading such files by
reading the Aux vectors since a vdso is invisibily 
mapped to the inferiors address space and the
 actual file is not present in the filesystem. The 
presence of the vdso is detected by inspecting 
the Aux vector for AT_SYSINFO_EHDR tag.

Reviewers: lldb-commits, ovyalov, tberghammer

Subscribers: lldb-commits

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

Modified:
    lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
    lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
    lldb/trunk/test/functionalities/inferior-assert/TestInferiorAssert.py
    lldb/trunk/test/python_api/hello_world/TestHelloWorld.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=251505&r1=251504&r2=251505&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp Wed Oct 28 04:47:29 2015
@@ -91,7 +91,8 @@ DynamicLoaderPOSIXDYLD::DynamicLoaderPOS
       m_load_offset(LLDB_INVALID_ADDRESS),
       m_entry_point(LLDB_INVALID_ADDRESS),
       m_auxv(),
-      m_dyld_bid(LLDB_INVALID_BREAK_ID)
+      m_dyld_bid(LLDB_INVALID_BREAK_ID),
+      m_vdso_base(LLDB_INVALID_ADDRESS)
 {
 }
 
@@ -126,6 +127,8 @@ DynamicLoaderPOSIXDYLD::DidAttach()
     if (log)
         log->Printf ("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " executable '%s', load_offset 0x%" PRIx64, __FUNCTION__, m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID, executable_sp ? executable_sp->GetFileSpec().GetPath().c_str () : "<null executable>", load_offset);
 
+    EvalVdsoStatus();
+
     // if we dont have a load address we cant re-base
     bool rebase_exec = (load_offset == LLDB_INVALID_ADDRESS) ? false : true;
 
@@ -213,6 +216,7 @@ DynamicLoaderPOSIXDYLD::DidLaunch()
 
     executable = GetTargetExecutable();
     load_offset = ComputeLoadOffset();
+    EvalVdsoStatus();
 
     if (executable.get() && load_offset != LLDB_INVALID_ADDRESS)
     {
@@ -503,7 +507,15 @@ DynamicLoaderPOSIXDYLD::LoadAllCurrentMo
     // that ourselves here.
     ModuleSP executable = GetTargetExecutable();
     m_loaded_modules[executable] = m_rendezvous.GetLinkMapAddress();
-
+    if (m_vdso_base != LLDB_INVALID_ADDRESS)
+    {
+        FileSpec file_spec("[vdso]", false);
+        ModuleSP module_sp = LoadModuleAtAddress(file_spec, LLDB_INVALID_ADDRESS, m_vdso_base, false);
+        if (module_sp.get())
+        {
+            module_list.Append(module_sp);
+        }
+    }
     for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I)
     {
         ModuleSP module_sp = LoadModuleAtAddress(I->file_spec, I->link_addr, I->base_addr, true);
@@ -551,6 +563,16 @@ DynamicLoaderPOSIXDYLD::ComputeLoadOffse
     return m_load_offset;
 }
 
+void
+DynamicLoaderPOSIXDYLD::EvalVdsoStatus()
+{
+    AuxVector::iterator I = m_auxv->FindEntry(AuxVector::AT_SYSINFO_EHDR);
+
+    if (I != m_auxv->end())
+        m_vdso_base = I->value;
+
+}
+
 addr_t
 DynamicLoaderPOSIXDYLD::GetEntryPoint()
 {

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=251505&r1=251504&r2=251505&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h Wed Oct 28 04:47:29 2015
@@ -88,6 +88,10 @@ protected:
     /// Rendezvous breakpoint.
     lldb::break_id_t m_dyld_bid;
 
+    /// Contains AT_SYSINFO_EHDR, which means a vDSO has been
+    /// mapped to the address space
+    lldb::addr_t m_vdso_base;
+
     /// Loaded module list. (link map for each module)
     std::map<lldb::ModuleWP, lldb::addr_t, std::owner_less<lldb::ModuleWP>> m_loaded_modules;
 
@@ -159,6 +163,11 @@ protected:
     lldb::addr_t
     GetEntryPoint();
 
+    /// Evaluate if Aux vectors contain vDSO information
+    /// in case they do, read and assign the address to m_vdso_base
+    void
+    EvalVdsoStatus();
+
     /// Loads Module from inferior process.
     void
     ResolveExecutableModule(lldb::ModuleSP &module_sp);

Modified: lldb/trunk/test/functionalities/inferior-assert/TestInferiorAssert.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/inferior-assert/TestInferiorAssert.py?rev=251505&r1=251504&r2=251505&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/inferior-assert/TestInferiorAssert.py (original)
+++ lldb/trunk/test/functionalities/inferior-assert/TestInferiorAssert.py Wed Oct 28 04:47:29 2015
@@ -12,7 +12,6 @@ class AssertingInferiorTestCase(TestBase
 
     mydir = TestBase.compute_mydir(__file__)
 
-    @expectedFailurei386("llvm.org/pr17384: lldb needs to be aware of linux-vdso.so to unwind stacks properly")
     @expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows")
     def test_inferior_asserting(self):
         """Test that lldb reliably catches the inferior asserting (command)."""
@@ -26,7 +25,6 @@ class AssertingInferiorTestCase(TestBase
         self.build()
         self.inferior_asserting_registers()
 
-    @expectedFailurei386("llvm.org/pr17384: lldb needs to be aware of linux-vdso.so to unwind stacks properly")
     @expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows")
     def test_inferior_asserting_disassemble(self):
         """Test that lldb reliably disassembles frames after asserting (command)."""
@@ -40,14 +38,12 @@ class AssertingInferiorTestCase(TestBase
         self.build()
         self.inferior_asserting_python()
 
-    @expectedFailurei386('llvm.org/pr17384: lldb needs to be aware of linux-vdso.so to unwind stacks properly')
     @expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows")
     def test_inferior_asserting_expr(self):
         """Test that the lldb expression interpreter can read from the inferior after asserting (command)."""
         self.build()
         self.inferior_asserting_expr()
 
-    @expectedFailurei386("llvm.org/pr17384: lldb needs to be aware of linux-vdso.so to unwind stacks properly")
     @expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows")
     def test_inferior_asserting_step(self):
         """Test that lldb functions correctly after stepping through a call to assert()."""
@@ -146,6 +142,12 @@ class AssertingInferiorTestCase(TestBase
         thread = process.GetThreadAtIndex(0)
         self.assertTrue(thread.IsValid(), "current thread is valid")
 
+        lastframeID = thread.GetFrameAtIndex(thread.GetNumFrames() - 1).GetFrameID()
+
+        isi386Arch = False
+        if "i386" in self.getArchitecture():
+            isi386Arch = True
+
         # lldb should be able to disassemble frames from the inferior after asserting.
         for frame in thread:
             self.assertTrue(frame.IsValid(), "current frame is valid")
@@ -160,6 +162,9 @@ class AssertingInferiorTestCase(TestBase
             pc_backup_offset = 1
             if frame.GetFrameID() == 0:
                 pc_backup_offset = 0
+            if isi386Arch == True:
+                if lastframeID == frame.GetFrameID():
+                    pc_backup_offset = 0
             self.expect("disassemble -a %s" % (frame.GetPC() - pc_backup_offset),
                     substrs = ['<+0>: '])
 

Modified: lldb/trunk/test/python_api/hello_world/TestHelloWorld.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/hello_world/TestHelloWorld.py?rev=251505&r1=251504&r2=251505&view=diff
==============================================================================
--- lldb/trunk/test/python_api/hello_world/TestHelloWorld.py (original)
+++ lldb/trunk/test/python_api/hello_world/TestHelloWorld.py Wed Oct 28 04:47:29 2015
@@ -73,7 +73,6 @@ class HelloWorldTestCase(TestBase):
         self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE)
 
     @add_test_categories(['pyapi'])
-    @expectedFailurei386 # llvm.org/pr17384: lldb needs to be aware of linux-vdso.so to unwind stacks properly
     @expectedFailureWindows("llvm.org/pr24600")
     def test_with_attach_to_process_with_id_api(self):
         """Create target, spawn a process, and attach to it with process id."""
@@ -102,7 +101,6 @@ class HelloWorldTestCase(TestBase):
                        '(int)argc=3'])
 
     @add_test_categories(['pyapi'])
-    @expectedFailurei386 # llvm.org/pr17384: lldb needs to be aware of linux-vdso.so to unwind stacks properly
     @expectedFailureWindows("llvm.org/pr24600")
     def test_with_attach_to_process_with_name_api(self):
         """Create target, spawn a process, and attach to it with process name."""




More information about the lldb-commits mailing list