[all-commits] [llvm/llvm-project] 506144: [lldb][DataFormatters] Support pretty printing std...
Jordan Rupprecht via All-commits
all-commits at lists.llvm.org
Fri Nov 22 10:47:39 PST 2019
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 506144da04b94d7d492ad34f7d3d81e8368677bb
https://github.com/llvm/llvm-project/commit/506144da04b94d7d492ad34f7d3d81e8368677bb
Author: Jordan Rupprecht <rupprecht at google.com>
Date: 2019-11-22 (Fri, 22 Nov 2019)
Changed paths:
M lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
M lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
M lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
M lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
M lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
Log Message:
-----------
[lldb][DataFormatters] Support pretty printing std::string when built with -funsigned-char.
Summary:
When built w/ `-funsigned-char`, `std::string` becomes equivalent to `std::basic_string<unsigned char>`, causing these formatters to not match. This patch adds overloads for both libstdc++ and libc++ string formatters that accepts unsigned char.
Motivated by the following example:
```
$ cat pretty_print.cc
template <typename T>
void print_val(T s) {
std::cerr << s << '\n'; // Set a breakpoint here!
}
int main() {
std::string val = "hello";
print_val(val);
return 0;
}
$ clang++ -stdlib=libc++ -funsigned-char -fstandalone-debug -g pretty_print.cc
$ lldb ./a.out -b -o 'b pretty_print.cc:6' -o r -o 'fr v'
...
(lldb) fr v
(std::__1::basic_string<unsigned char, std::__1::char_traits<unsigned char>, std::__1::allocator<unsigned char> >) s = {
__r_ = {
std::__1::__compressed_pair_elem<std::__1::basic_string<unsigned char, std::__1::char_traits<unsigned char>, std::__1::allocator<unsigned char> >::__rep, 0, false> = {
__value_ = {
= {
__l = (__cap_ = 122511465736202, __size_ = 0, __data_ = 0x0000000000000000)
__s = {
= (__size_ = '\n', __lx = '\n')
__data_ = {
[0] = 'h'
[1] = 'e'
[2] = 'l'
[3] = 'l'
[4] = 'o'
[5] = '\0'
...
```
Reviewers: labath, JDevlieghere, shafik
Subscribers: christof, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70517
More information about the All-commits
mailing list