Skip to content

Commit

Permalink
ARROW-12735: [C++] Write GDB plugin
Browse files Browse the repository at this point in the history
Add a GDB plugin (written in Python) that registers custom printers for common Arrow C++ types, and makes their values much more readable when printed on the GDB prompt.

Currently covered types are:
- `string_view`, `optional`, `Variant`
- `Status`, `Result`
- `Buffer` (and subclasses)
- `BasicDecimal{128,256}` (and subclasses)
- `DataType` (and subclasses), `Field`, `Schema`, `KeyValueMetadata`
- `Scalar` (and subclasses)
- `ArrayData`, `Array` (and subclasses)
- `ChunkedArray`, `RecordBatch`, `Table`, `Datum`

The plugin is tested using a test harness in PyArrow, for convenience.

Here is for example `arrow::util::Variant<int, bool, std::string>`:
* with the GDB plugin:
```gdb
(gdb) p int_variant
$1 = arrow::util::Variant of index 0 (actual type int), value 42
```
* without the GDB plugin:
```gdb
(gdb) p int_variant
$1 = {
  <arrow::util::detail::VariantImpl<arrow::util::Variant<int, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, int, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {
    <arrow::util::detail::VariantImpl<arrow::util::Variant<int, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {
      <arrow::util::detail::VariantImpl<arrow::util::Variant<int, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {
        <arrow::util::detail::VariantImpl<arrow::util::Variant<int, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >> = {
          <arrow::util::detail::VariantStorage<int, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {
[ snip more lines of inscrutable implementation details ]
```

Closes #12092 from pitrou/ARROW-12735-gdb

Authored-by: Antoine Pitrou <antoine@python.org>
Signed-off-by: Antoine Pitrou <antoine@python.org>
  • Loading branch information
pitrou committed Jan 20, 2022
1 parent b1b8728 commit a3efe72
Show file tree
Hide file tree
Showing 12 changed files with 3,278 additions and 5 deletions.
1 change: 1 addition & 0 deletions ci/scripts/python_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export ARROW_SOURCE_DIR=${arrow_dir}
export ARROW_TEST_DATA=${arrow_dir}/testing/data
export PARQUET_TEST_DATA=${arrow_dir}/cpp/submodules/parquet-testing/data
export LD_LIBRARY_PATH=${ARROW_HOME}/lib:${LD_LIBRARY_PATH}
export ARROW_GDB_SCRIPT=${arrow_dir}/cpp/gdb_arrow.py

# Enable some checks inside Python itself
export PYTHONDEVMODE=1
Expand Down
Loading

0 comments on commit a3efe72

Please sign in to comment.