Add a GDB pretty printer for base::flat_map

Desktop / Chromium - brettw [chromium.org] - 19 May 2017 15:46 EDT

This improves the output somewhat. As explained in the added comment, it's not ideal but I had trouble figuring out how to work with the vector inside of the flat_map without hardcoding internals of how std::vector is implemented.

This also adds some hints about debugging the printers at the top of the file.

Before for base::flat_map:

(gdb) print qwer $2 = {, std::allocator >, std::pair, std::allocator >, int>, base::internal::GetKeyFromValuePairFirst, std::allocator >, int>, std::less, std::allocator > > >> = { impl_ = {, std::allocator >, std::pair, std::allocator >, int>, base::internal::GetKeyFromValuePairFirst, std::allocator >, int>, std::less, std::allocator > > >::value_compare> = {, std::allocator > >> = {, std::allocator >, std::basic_string, std::allocator >, bool>> = {}, }, }, body_ = std::__debug::vector of length 3, capacity 4 = {{ first = "a", second = 1}, {first = "nonsense", second = 9}, { first = "zebra", second = 1123123}}}}, }

After:

base: :flat_map with std::__debug::vector of length 3, capacity 4 = {{first = "a", second = 1}, {first = "nonsense", second = 9}, {first = "zebra", second = 1123123}} Review-Url: https://codereview.chromium.org/2897573004 Cr-Commit-Position: refs/heads/master@{#473286}

462b7ca Add a GDB pretty printer for base::flat_map.
tools/gdb/gdb_chrome.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

Upstream: git.chromium.org


  • Share