Commit 838a2b67 authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

Add libc++ pretty printers to tools/gdb

Turns this:

separator = {
  <std::__1::__basic_string_common<true>> = {<No data fields>},
  members of std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >:
  static __short_mask = 1,
  static __long_mask = 1,
  __r_ = {
    <std::__1::__compressed_pair_elem<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep, 0, false>> = {
      __value_ = {
        {
          __l = {
            __cap_ = 2108420,
            __size_ = 0,
            __data_ = 0x0
          },
          __s = {
            {
              __size_ = 4 '\004',
              __lx = 4 '\004'
            },
            __data_ = ", ", '\000' <repeats 20 times>
          },
          __r = {
            __words = {[0] = 2108420, [1] = 0, [2] = 0}
          }
        }
      }
    },
    <std::__1::__compressed_pair_elem<std::__1::allocator<char>, 1, true>> = {
      <std::__1::allocator<char>> = {<No data fields>}, <No data fields>}, <No data fields>},
  static npos = 18446744073709551615
}

Into this:

separator = ", "

BUG=866697
R=thakis
CC=leszeks

Change-Id: I4b35799c6023743b5876aa89a2448b8f841c7751
Reviewed-on: https://chromium-review.googlesource.com/1152087Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579085}
parent 193e138d
This diff is collapsed.
dpranke@chromium.org
leszeks@chromium.org
thomasanderson@chromium.org
Name: libcxx-pretty-printers
URL: https://github.com/LeszekSwirski/libcxx-pretty-printers
Version: dc4eb17426ce62262992d7c52aa1140f9b707c37
License: GPL v3
License File: LICENSE
Security Critical: no
Description:
GDB Pretty Printers for libc++ of Clang/LLVM
Local patches:
None
Upgrading:
$ git clone https://github.com/LeszekSwirski/libcxx-pretty-printers.git
$ rm -rf .git .gitignore
* Add README.chromium
* Add OWNERS
libcxx-pretty-printers
======================
GDB Pretty Printers for libc++ of Clang/LLVM
python
import sys
sys.path.insert(0, '<path_to_libcxx-pp_src_dir>')
from libcxx.v1.printers import register_libcxx_printers
register_libcxx_printers (None)
end
This diff is collapsed.
# This is gdbinit for source level debugging with -fdebug-compilation-dir
# compile option.
# compile option or when building with libc++.
python
import os
import subprocess
import sys
def get_current_debug_file_directories():
dir = gdb.execute("show debug-file-directory", to_string=True)
......@@ -20,6 +22,28 @@ def add_debug_file_directory(dir):
to_string=True)
libcxx_pretty_printers_loaded = False
def load_libcxx_pretty_printers(compile_dir):
global libcxx_pretty_printers_loaded
if libcxx_pretty_printers_loaded:
return
git = subprocess.Popen(
['git', '-C', compile_dir, 'rev-parse', '--show-toplevel'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
src_dir, _ = git.communicate()
if git.returncode:
return
libcxx_pretty_printers = os.path.join(src_dir.rstrip(), 'third_party',
'libcxx-pretty-printers', 'src')
if not os.path.isdir(libcxx_pretty_printers):
return
sys.path.insert(1, libcxx_pretty_printers)
from libcxx.v1.printers import register_libcxx_printers
register_libcxx_printers(None)
libcxx_pretty_printers_loaded = True
def newobj_handler(event):
compile_dir = os.path.dirname(event.new_objfile.filename)
if not compile_dir:
......@@ -33,6 +57,8 @@ def newobj_handler(event):
# https://crbug.com/603286#c35
add_debug_file_directory(compile_dir)
load_libcxx_pretty_printers(compile_dir)
# Event hook for newly loaded objfiles.
# https://sourceware.org/gdb/onlinedocs/gdb/Events-In-Python.html
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment