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@microsoft.com

Reviewers: ChuckR, abidh, ki.stfu

Subscribers: greggm, lldb-commits

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

llvm-svn: 244573
This commit is contained in:
Ilia K 2015-08-11 06:07:14 +00:00
parent 4988786b0f
commit d7f932a8c8
3 changed files with 19 additions and 12 deletions

View File

@ -26,10 +26,9 @@ class MiLibraryLoadedTestCase(lldbmi_testcase.MiTestCaseBase):
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()

View File

@ -688,17 +688,17 @@ CMICmnLLDBDebuggerHandleEvents::MiHelpGetModuleInfo(const lldb::SBModule &vModul
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::MiHelpGetModuleInfo(const lldb::SBModule &vModul
// 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::MiHelpGetModuleInfo(const lldb::SBModule &vModul
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;

View File

@ -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