[Lldb-commits] [lldb] r172286 - in /lldb/trunk: examples/synthetic/libcxx.py include/lldb/Core/FormatManager.h source/Core/FormatManager.cpp test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/ test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
Enrico Granata
egranata at apple.com
Fri Jan 11 17:22:57 PST 2013
Author: enrico
Date: Fri Jan 11 19:22:57 2013
New Revision: 172286
URL: http://llvm.org/viewvc/llvm-project?rev=172286&view=rev
Log:
<rdar://problem/12239827>
Making a summary for std::wstring as provided by libstdc++ along with a relevant test case
Added:
lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/
lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile
lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
Modified:
lldb/trunk/examples/synthetic/libcxx.py
lldb/trunk/include/lldb/Core/FormatManager.h
lldb/trunk/source/Core/FormatManager.cpp
Modified: lldb/trunk/examples/synthetic/libcxx.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/libcxx.py?rev=172286&r1=172285&r2=172286&view=diff
==============================================================================
--- lldb/trunk/examples/synthetic/libcxx.py (original)
+++ lldb/trunk/examples/synthetic/libcxx.py Fri Jan 11 19:22:57 2013
@@ -6,6 +6,9 @@
# ships with current releases of OS X - They will not work for other implementations
# of the standard C++ library - and they are bound to use the libc++-specific namespace
+# the std::string summary is just an example for your convenience
+# the actual summary that LLDB uses is C++ code inside the debugger's own core
+
# this could probably be made more efficient but since it only reads a handful of bytes at a time
# we probably don't need to worry too much about this for the time being
def make_string(F,L):
Modified: lldb/trunk/include/lldb/Core/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=172286&r1=172285&r2=172286&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatManager.h (original)
+++ lldb/trunk/include/lldb/Core/FormatManager.h Fri Jan 11 19:22:57 2013
@@ -759,16 +759,16 @@
// most would actually belong to the users' lldbinit file or to some other form of configurable
// storage
void
- LoadSTLFormatters();
+ LoadLibStdcppFormatters ();
void
- LoadLibcxxFormatters();
+ LoadLibcxxFormatters ();
void
- LoadSystemFormatters();
+ LoadSystemFormatters ();
void
- LoadObjCFormatters();
+ LoadObjCFormatters ();
};
} // namespace lldb_private
Modified: lldb/trunk/source/Core/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=172286&r1=172285&r2=172286&view=diff
==============================================================================
--- lldb/trunk/source/Core/FormatManager.cpp (original)
+++ lldb/trunk/source/Core/FormatManager.cpp Fri Jan 11 19:22:57 2013
@@ -704,7 +704,7 @@
{
LoadSystemFormatters();
- LoadSTLFormatters();
+ LoadLibStdcppFormatters();
LoadLibcxxFormatters();
LoadObjCFormatters();
@@ -777,7 +777,7 @@
#endif
void
-FormatManager::LoadSTLFormatters()
+FormatManager::LoadLibStdcppFormatters()
{
TypeSummaryImpl::Flags stl_summary_flags;
stl_summary_flags.SetCascades(true)
@@ -802,6 +802,19 @@
gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::basic_string<char, std::char_traits<char>, std::allocator<char> >"),
std_string_summary_sp);
+ // making sure we force-pick the summary for printing wstring (_M_p is a wchar_t*)
+ lldb::TypeSummaryImplSP std_wstring_summary_sp(new StringSummaryFormat(stl_summary_flags,
+ "${var._M_dataplus._M_p%S}"));
+
+ gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::wstring"),
+ std_wstring_summary_sp);
+ gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::basic_string<wchar_t>"),
+ std_wstring_summary_sp);
+ gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >"),
+ std_wstring_summary_sp);
+ gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >"),
+ std_wstring_summary_sp);
+
#ifndef LLDB_DISABLE_PYTHON
Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile?rev=172286&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile (added)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile Fri Jan 11 19:22:57 2013
@@ -0,0 +1,8 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
+
+CXXFLAGS += -stdlib=libstdc++ -O0
+LDFLAGS += -stdlib=libstdc++
\ No newline at end of file
Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py?rev=172286&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py (added)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py Fri Jan 11 19:22:57 2013
@@ -0,0 +1,81 @@
+#coding=utf8
+"""
+Test lldb data formatter subsystem.
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+import lldbutil
+
+class StdStringDataFormatterTestCase(TestBase):
+
+ mydir = os.path.join("functionalities", "data-formatter", "data-formatter-stl", "libstdcpp", "string")
+
+ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+ @dsym_test
+ def test_with_dsym_and_run_command(self):
+ """Test data formatter commands."""
+ self.buildDsym()
+ self.data_formatter_commands()
+
+ @skipOnLinux # No standard locations for libc++ on Linux, so skip for now
+ @dwarf_test
+ def test_with_dwarf_and_run_command(self):
+ """Test data formatter commands."""
+ self.buildDwarf()
+ self.data_formatter_commands()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def data_formatter_commands(self):
+ """Test that that file and class static variables display correctly."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.expect("frame variable",
+ substrs = ['(std::wstring) s = L"hello world! ××× ×××!"',
+ '(std::wstring) S = L"!!!!"',
+ '(const wchar_t *) mazeltov = 0x','L"××× ×××"',
+ '(std::string) q = "hello world"',
+ '(std::string) Q = "quite a long std::strin with lots of info inside it"'])
+
+ self.runCmd("n")
+
+ self.expect("frame variable",
+ substrs = ['(std::wstring) s = L"hello world! ××× ×××!"',
+ '(std::wstring) S = L"!!!!!"',
+ '(const wchar_t *) mazeltov = 0x','L"××× ×××"',
+ '(std::string) q = "hello world"',
+ '(std::string) Q = "quite a long std::strin with lots of info inside it"'])
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp?rev=172286&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp (added)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp Fri Jan 11 19:22:57 2013
@@ -0,0 +1,12 @@
+#include <string>
+
+int main()
+{
+ std::wstring s(L"hello world! ××× ×××!");
+ std::wstring S(L"!!!!");
+ const wchar_t *mazeltov = L"××× ×××";
+ std::string q("hello world");
+ std::string Q("quite a long std::strin with lots of info inside it");
+ S.assign(L"!!!!!"); // Set break point at this line.
+ return 0;
+}
\ No newline at end of file
More information about the lldb-commits
mailing list