[Lldb-commits] [lldb] r244573 - Add size field to library load event (MI)

Ilia K via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 10 23:07:14 PDT 2015


Author: ki.stfu
Date: Tue Aug 11 01:07:14 2015
New Revision: 244573

URL: http://llvm.org/viewvc/llvm-project?rev=244573&view=rev
Log:
Add size field to library load event (MI)

Summary:
(This revision supersedes the abandon: http://reviews.llvm.org/D9716)
Size field is used to let the debugger attribute an address to a specific library when symbols are not available. 
For example:
	OpenGLESApp4.app!Cube_draw() Line 74	C
 	OpenGLESApp4.app!-[GameViewController glkView:drawInRect:](GameViewController * self, SEL _cmd, GLKView * view, CGRect rect) Line 89	C++
 	GLKit!<redacted>	
 	QuartzCore!<redacted>	
 	QuartzCore!<redacted>	
 	QuartzCore!<redacted>	
 	QuartzCore!<redacted>	
 	QuartzCore!<redacted>	
 	UIKit!<redacted>	
 	UIKit!<redacted>	
 	UIKit!<redacted>	
 	UIKit!<redacted>	
 	FrontBoardServices!<redacted>	
 	CoreFoundation!<redacted>	

Patch from paulmay at microsoft.com

Reviewers: ChuckR, abidh, ki.stfu

Subscribers: greggm, lldb-commits

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


Modified:
    lldb/trunk/test/tools/lldb-mi/TestMiLibraryLoaded.py
    lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
    lldb/trunk/tools/lldb-mi/MIExtensions.txt

Modified: lldb/trunk/test/tools/lldb-mi/TestMiLibraryLoaded.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/TestMiLibraryLoaded.py?rev=244573&r1=244572&r2=244573&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/TestMiLibraryLoaded.py (original)
+++ lldb/trunk/test/tools/lldb-mi/TestMiLibraryLoaded.py Tue Aug 11 01:07:14 2015
@@ -26,10 +26,9 @@ class MiLibraryLoadedTestCase(lldbmi_tes
         import os
         path = os.path.join(os.getcwd(), self.myexe)
         symbols_path = os.path.join(path + ".dSYM", "Contents", "Resources", "DWARF", self.myexe)
-        self.expect([
-                "=library-loaded,id=\"%s\",target-name=\"%s\",host-name=\"%s\",symbols-loaded=\"1\",symbols-path=\"%s\",loaded_addr=\"-\"" % (path, path, path, symbols_path),
-                "=library-loaded,id=\"%s\",target-name=\"%s\",host-name=\"%s\",symbols-loaded=\"0\",loaded_addr=\"-\"" % (path, path, path)
-            ], exactly = True)
+        def add_slashes(x): return x.replace("\\", "\\\\").replace("\"", "\\\"").replace("\'", "\\\'").replace("\0", "\\\0")
+        self.expect([ "=library-loaded,id=\"%s\",target-name=\"%s\",host-name=\"%s\",symbols-loaded=\"1\",symbols-path=\"%s\",loaded_addr=\"-\",size=\"[0-9]+\"" % (add_slashes(path), add_slashes(path), add_slashes(path), add_slashes(symbols_path)),
+                      "=library-loaded,id=\"%s\",target-name=\"%s\",host-name=\"%s\",symbols-loaded=\"0\",loaded_addr=\"-\",size=\"[0-9]+\"" % (add_slashes(path), add_slashes(path), add_slashes(path)) ])
 
 if __name__ == '__main__':
     unittest2.main()

Modified: lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp?rev=244573&r1=244572&r2=244573&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp Tue Aug 11 01:07:14 2015
@@ -688,17 +688,17 @@ CMICmnLLDBDebuggerHandleEvents::MiHelpGe
     std::unique_ptr<char[]> apPath(new char[PATH_MAX]);
     vModule.GetFileSpec().GetPath(apPath.get(), PATH_MAX);
     const CMIUtilString strTargetPath(apPath.get());
-    const CMICmnMIValueConst miValueConst(strTargetPath);
+    const CMICmnMIValueConst miValueConst(strTargetPath.AddSlashes());
     const CMICmnMIValueResult miValueResult("id", miValueConst);
     vwrMiOutOfBandRecord.Add(miValueResult);
     // Build "target-name" field
-    const CMICmnMIValueConst miValueConst2(strTargetPath);
+    const CMICmnMIValueConst miValueConst2(strTargetPath.AddSlashes());
     const CMICmnMIValueResult miValueResult2("target-name", miValueConst2);
     vwrMiOutOfBandRecord.Add(miValueResult2);
     // Build "host-name" field
     vModule.GetPlatformFileSpec().GetPath(apPath.get(), PATH_MAX);
     const CMIUtilString strHostPath(apPath.get());
-    const CMICmnMIValueConst miValueConst3(strHostPath);
+    const CMICmnMIValueConst miValueConst3(strHostPath.AddSlashes());
     const CMICmnMIValueResult miValueResult3("host-name", miValueConst3);
     vwrMiOutOfBandRecord.Add(miValueResult3);
 
@@ -715,12 +715,12 @@ CMICmnLLDBDebuggerHandleEvents::MiHelpGe
         // Build "symbols-path" field
         if (bSymbolsLoaded)
         {
-            const CMICmnMIValueConst miValueConst5(strSymbolsPath);
+            const CMICmnMIValueConst miValueConst5(strSymbolsPath.AddSlashes());
             const CMICmnMIValueResult miValueResult5("symbols-path", miValueConst5);
             vwrMiOutOfBandRecord.Add(miValueResult5);
         }
         // Build "loaded_addr" field
-        const lldb::SBAddress sbAddress(vModule.GetObjectFileHeaderAddress());
+        lldb::SBAddress sbAddress(vModule.GetObjectFileHeaderAddress());
         CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
         const lldb::addr_t nLoadAddress(sbAddress.GetLoadAddress(rSessionInfo.GetTarget()));
         const CMIUtilString strLoadedAddr(nLoadAddress != LLDB_INVALID_ADDRESS ?
@@ -728,6 +728,13 @@ CMICmnLLDBDebuggerHandleEvents::MiHelpGe
         const CMICmnMIValueConst miValueConst6(strLoadedAddr);
         const CMICmnMIValueResult miValueResult6("loaded_addr", miValueConst6);
         vwrMiOutOfBandRecord.Add(miValueResult6);
+        
+        // Build "size" field
+        lldb::SBSection sbSection = sbAddress.GetSection();
+        const CMIUtilString strSize(CMIUtilString::Format("%" PRIu64, sbSection.GetByteSize()));
+        const CMICmnMIValueConst miValueConst7(strSize);
+        const CMICmnMIValueResult miValueResult7("size", miValueConst7);
+        vwrMiOutOfBandRecord.Add(miValueResult7);
     }
 
     return bOk;

Modified: lldb/trunk/tools/lldb-mi/MIExtensions.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MIExtensions.txt?rev=244573&r1=244572&r2=244573&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MIExtensions.txt (original)
+++ lldb/trunk/tools/lldb-mi/MIExtensions.txt Tue Aug 11 01:07:14 2015
@@ -83,14 +83,15 @@ Example:
 
 # =library-loaded notification
 
-The =library-loaded notification has 3 extra fields:
+The =library-loaded notification has 4 extra fields:
     symbols-loaded - indicates that there are symbols for the loaded library
     symbols-path   - if symbols are exist then it contains a path for symbols of the loaded library
     loaded_addr    - contains an address of the loaded library or "-" if address isn't resolved yet
+    size           - contains the size in bytes of the section loaded at 'loaded_addr'
 
 For example:
-    =library-loaded,id="/Users/IliaK/p/hello",target-name="/Users/IliaK/p/hello",host-name="/Users/IliaK/p/hello",symbols-loaded="1",symbols-path="/Users/IliaK/p/hello.dSYM/Contents/Resources/DWARF/hello",loaded_addr="-"
-    =library-loaded,id="/usr/lib/dyld",target-name="/usr/lib/dyld",host-name="/usr/lib/dyld",symbols-loaded="0",loaded_addr="0x00007fff5fc00000"
+    =library-loaded,id="/Users/IliaK/p/hello",target-name="/Users/IliaK/p/hello",host-name="/Users/IliaK/p/hello",symbols-loaded="1",symbols-path="/Users/IliaK/p/hello.dSYM/Contents/Resources/DWARF/hello",loaded_addr="-",size="4096"
+    =library-loaded,id="/usr/lib/dyld",target-name="/usr/lib/dyld",host-name="/usr/lib/dyld",symbols-loaded="0",loaded_addr="0x00007fff5fc00000",size="4096"
 
 # -target-attach
 




More information about the lldb-commits mailing list