This revision was automatically updated to reflect the committed changes.
Closed by commit rL244573: Add size field to library load event (MI) (authored
by ki.stfu).
Changed prior to commit:
http://reviews.llvm.org/D11574?vs=31038&id=31772#toc
Repository:
rL LLVM
http://reviews.llvm.org/D11574
Files:
lldb/trunk/test/tools/lldb-mi/TestMiLibraryLoaded.py
lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
lldb/trunk/tools/lldb-mi/MIExtensions.txt
Index: lldb/trunk/tools/lldb-mi/MIExtensions.txt
===================================================================
--- lldb/trunk/tools/lldb-mi/MIExtensions.txt
+++ lldb/trunk/tools/lldb-mi/MIExtensions.txt
@@ -83,14 +83,15 @@
# =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
Index: lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
===================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
@@ -688,17 +688,17 @@
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,19 +715,26 @@
// 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
?
CMIUtilString::Format("0x%016"
PRIx64, nLoadAddress) : "-");
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;
Index: lldb/trunk/test/tools/lldb-mi/TestMiLibraryLoaded.py
===================================================================
--- lldb/trunk/test/tools/lldb-mi/TestMiLibraryLoaded.py
+++ lldb/trunk/test/tools/lldb-mi/TestMiLibraryLoaded.py
@@ -26,10 +26,9 @@
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()
Index: lldb/trunk/tools/lldb-mi/MIExtensions.txt
===================================================================
--- lldb/trunk/tools/lldb-mi/MIExtensions.txt
+++ lldb/trunk/tools/lldb-mi/MIExtensions.txt
@@ -83,14 +83,15 @@
# =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
Index: lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
===================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
@@ -688,17 +688,17 @@
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,19 +715,26 @@
// 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 ?
CMIUtilString::Format("0x%016" PRIx64, nLoadAddress) : "-");
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;
Index: lldb/trunk/test/tools/lldb-mi/TestMiLibraryLoaded.py
===================================================================
--- lldb/trunk/test/tools/lldb-mi/TestMiLibraryLoaded.py
+++ lldb/trunk/test/tools/lldb-mi/TestMiLibraryLoaded.py
@@ -26,10 +26,9 @@
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()
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits