aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia K <ki.stfu@gmail.com>2015-08-11 06:07:14 +0000
committerIlia K <ki.stfu@gmail.com>2015-08-11 06:07:14 +0000
commitdf57ff6eee51abd6e6c122e886e1623674836e85 (patch)
tree949676787397badfa5a8eb77d00b3906b42ef58d
parentaf34d909bb3041a214233f2b3d082bc511c54fef (diff)
downloadlldb-df57ff6eee51abd6e6c122e886e1623674836e85.tar.gz
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@244573 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/tools/lldb-mi/TestMiLibraryLoaded.py7
-rw-r--r--tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp17
-rw-r--r--tools/lldb-mi/MIExtensions.txt7
3 files changed, 19 insertions, 12 deletions
diff --git a/test/tools/lldb-mi/TestMiLibraryLoaded.py b/test/tools/lldb-mi/TestMiLibraryLoaded.py
index 615b748bc..27073ac7a 100644
--- a/test/tools/lldb-mi/TestMiLibraryLoaded.py
+++ b/test/tools/lldb-mi/TestMiLibraryLoaded.py
@@ -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()
diff --git a/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp b/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
index 7c271cb3e..1c97016b8 100644
--- a/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
+++ b/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
@@ -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;
diff --git a/tools/lldb-mi/MIExtensions.txt b/tools/lldb-mi/MIExtensions.txt
index 966cb2f07..716c055f7 100644
--- a/tools/lldb-mi/MIExtensions.txt
+++ b/tools/lldb-mi/MIExtensions.txt
@@ -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