You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/01/06 18:37:51 UTC

[GitHub] [arrow] pitrou opened a new pull request #12092: ARROW-12735: [C++] Write GDB plugin (WIP)

pitrou opened a new pull request #12092:
URL: https://github.com/apache/arrow/pull/12092


   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.
   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
   $2 = 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 ]
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] ursabot commented on pull request #12092: ARROW-12735: [C++] Write GDB plugin

Posted by GitBox <gi...@apache.org>.
ursabot commented on pull request #12092:
URL: https://github.com/apache/arrow/pull/12092#issuecomment-1017765706


   Benchmark runs are scheduled for baseline = b1b8728ee692359f6990ef8d188c88f482f632b6 and contender = a3efe72f99b1b9f23b1d11afc648f4306d32e330. a3efe72f99b1b9f23b1d11afc648f4306d32e330 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Scheduled] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/4e6ed509334c43d784135bb1715b117e...dd608f6a1bda4922bef705ab08bbda9a/)
   [Scheduled] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/66846def44e44692b9d087781442d177...f58de9bb70fe4030a1a0ef40544d0969/)
   [Scheduled] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/3a66c0a7c9c148afbe323eda941a8d83...202c60eaf7714fb989ca8db120a552ed/)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] ursabot edited a comment on pull request #12092: ARROW-12735: [C++] Write GDB plugin

Posted by GitBox <gi...@apache.org>.
ursabot edited a comment on pull request #12092:
URL: https://github.com/apache/arrow/pull/12092#issuecomment-1017765706


   Benchmark runs are scheduled for baseline = b1b8728ee692359f6990ef8d188c88f482f632b6 and contender = a3efe72f99b1b9f23b1d11afc648f4306d32e330. a3efe72f99b1b9f23b1d11afc648f4306d32e330 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/4e6ed509334c43d784135bb1715b117e...dd608f6a1bda4922bef705ab08bbda9a/)
   [Scheduled] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/66846def44e44692b9d087781442d177...f58de9bb70fe4030a1a0ef40544d0969/)
   [Finished :arrow_down:0.43% :arrow_up:0.13%] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/3a66c0a7c9c148afbe323eda941a8d83...202c60eaf7714fb989ca8db120a552ed/)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] pitrou commented on pull request #12092: ARROW-12735: [C++] Write GDB plugin

Posted by GitBox <gi...@apache.org>.
pitrou commented on pull request #12092:
URL: https://github.com/apache/arrow/pull/12092#issuecomment-1017755810


   Crossbow Python builds at https://github.com/ursacomputing/crossbow/branches/all?page=1&query=build-591


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] pitrou commented on a change in pull request #12092: ARROW-12735: [C++] Write GDB plugin

Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #12092:
URL: https://github.com/apache/arrow/pull/12092#discussion_r788987815



##########
File path: cpp/gdb_arrow.py
##########
@@ -0,0 +1,1894 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from collections import namedtuple
+from collections.abc import Sequence
+import decimal
+import enum
+from functools import lru_cache, partial
+import struct
+import sys
+import warnings
+
+import gdb
+from gdb.types import get_basic_type
+
+# gdb API docs at https://sourceware.org/gdb/onlinedocs/gdb/Python-API.html#Python-API
+
+# TODO check guidelines here: https://sourceware.org/gdb/onlinedocs/gdb/Writing-a-Pretty_002dPrinter.html
+# TODO investigate auto-loading: https://sourceware.org/gdb/onlinedocs/gdb/Auto_002dloading-extensions.html#Auto_002dloading-extensions
+
+
+_type_ids = [
+    'NA', 'BOOL', 'UINT8', 'INT8', 'UINT16', 'INT16', 'UINT32', 'INT32',
+    'UINT64', 'INT64', 'HALF_FLOAT', 'FLOAT', 'DOUBLE', 'STRING', 'BINARY',
+    'FIXED_SIZE_BINARY', 'DATE32', 'DATE64', 'TIMESTAMP', 'TIME32', 'TIME64',
+    'INTERVAL_MONTHS', 'INTERVAL_DAY_TIME', 'DECIMAL128', 'DECIMAL256',
+    'LIST', 'STRUCT', 'SPARSE_UNION', 'DENSE_UNION', 'DICTIONARY', 'MAP',
+    'EXTENSION', 'FIXED_SIZE_LIST', 'DURATION', 'LARGE_STRING',
+    'LARGE_BINARY', 'LARGE_LIST', 'INTERVAL_MONTH_DAY_NANO']
+
+# Mirror the C++ Type::type enum
+Type = enum.IntEnum('Type', _type_ids, start=0)
+
+
+@lru_cache()
+def byte_order():
+    """
+    Get the target program (not the GDB host's) endianness.
+    """
+    s = gdb.execute("show endian", to_string=True).strip()
+    if 'big' in s:
+        return 'big'
+    elif 'little' in s:
+        return 'little'
+    warnings.warn('Could not determine target endianness '
+                  f'from GDB\'s response:\n"""{s}"""')
+    # Fall back to host endianness
+    return sys.byteorder
+
+
+def for_evaluation(val, ty=None):
+    """
+    Return a parsable form of gdb.Value `val`, optionally with gdb.Type `ty`.
+    """
+    if ty is None:
+        ty = get_basic_type(val.type)
+    if ty.code == gdb.TYPE_CODE_PTR:
+        # It's already a pointer, can represent it directly
+        return f"(({ty}) ({val}))"
+    if val.address is None:
+        raise ValueError(f"Cannot further evaluate rvalue: {val}")
+    return f"(* ({ty}*) ({val.address}))"
+
+
+def is_char_star(ty):
+    # Note that "const char*" can have TYPE_CODE_INT as target type...
+    ty = get_basic_type(ty)
+    return (ty.code == gdb.TYPE_CODE_PTR and
+            get_basic_type(ty.target()).code
+                in (gdb.TYPE_CODE_CHAR, gdb.TYPE_CODE_INT))
+
+
+def deref(val):
+    """
+    Dereference a raw or smart pointer.
+    """
+    ty = get_basic_type(val.type)
+    if ty.code == gdb.TYPE_CODE_PTR:
+        return val.dereference()
+    if ty.name.startswith('std::'):
+        if "shared" in ty.name:
+            return SharedPtr(val).value
+        if "unique" in ty.name:
+            return UniquePtr(val).value
+    raise TypeError(f"Cannot dereference value of type '{ty.name}'")
+
+
+_string_literal_mapping = {
+    ord('\\'): r'\\',
+    ord('\n'): r'\n',
+    ord('\r'): r'\r',
+    ord('\t'): r'\t',
+    ord('"'): r'\"',
+}
+
+for c in range(0, 32):
+    if c not in _string_literal_mapping:
+        _string_literal_mapping[c] = f"\\x{c:02x}"
+
+
+def string_literal(s):
+    """
+    Format a Python string or gdb.Value for display as a literal.
+    """
+    max_len = 50
+    if isinstance(s, gdb.Value):
+        s = s.string()
+    if len(s) > max_len:
+        s = s[:max_len]
+        return '"' + s.translate(_string_literal_mapping) + '" [continued]'
+    else:
+        return '"' + s.translate(_string_literal_mapping) + '"'
+
+
+def bytes_literal(val, size=None):
+    """
+    Format a gdb.Value for display as a literal containing possibly
+    unprintable characters.
+    """
+    return val.lazy_string(length=size).value()
+
+
+def utf8_literal(val, size=None):
+    """
+    Format a gdb.Value for display as a utf-8 literal.
+    """
+    if size is None:
+        s = val.string(encoding='utf8', errors='backslashreplace')
+    elif size != 0:
+        s = val.string(encoding='utf8', errors='backslashreplace', length=size)
+    else:
+        s = ""
+    return string_literal(s)
+
+
+def half_float_value(val):
+    """
+    Return a Python float of the given half-float (represented as a uint64_t
+    gdb.Value).
+    """
+    buf = gdb.selected_inferior().read_memory(val.address, 2)
+    return struct.unpack("e", buf)[0]
+
+
+def load_atomic(val):
+    """
+    Load a std::atomic<T>'s value.
+    """
+    valty = val.type.template_argument(0)
+    # XXX This assumes std::atomic<T> has the same layout as a raw T.
+    return val.address.reinterpret_cast(valty.pointer()).dereference()
+
+
+def load_null_count(val):
+    """
+    Load a null count from a gdb.Value of an integer (either atomic or not).
+    """
+    if get_basic_type(val.type).code != gdb.TYPE_CODE_INT:
+        val = load_atomic(val)
+    return val
+
+
+def format_null_count(val):
+    """
+    Format a null count value.
+    """
+    if not isinstance(val, int):
+        null_count = int(load_null_count(val))
+    return (f"null count {null_count}" if null_count != -1
+            else "unknown null count")
+
+
+def short_time_unit(val):
+    return ['s', 'ms', 'us', 'ns'][int(val)]
+
+
+def format_month_interval(val):
+    """
+    Format a MonthInterval value.
+    """
+    return f"{int(val)}M"
+
+
+def cast_to_concrete(val, ty):
+    return (val.reference_value().reinterpret_cast(ty.reference())
+            .referenced_value())
+
+
+def scalar_class_from_type(name):
+    """
+    Given a DataTypeClass class name (such as "BooleanType"), return the
+    corresponding Scalar class name.
+    """
+    assert name.endswith("Type")
+    return name[:-4] + "Scalar"
+
+
+def array_class_from_type(name):
+    """
+    Given a DataTypeClass class name (such as "BooleanType"), return the
+    corresponding Array class name.
+    """
+    assert name.endswith("Type")
+    return name[:-4] + "Array"
+
+
+class CString:
+    """
+    A `const char*` or similar value.
+    """
+
+    def __init__(self, val):
+        self.val = val
+
+    def __bool__(self):
+        return int(data) != 0 and int(data[0]) != 0
+
+    @property
+    def data(self):
+        return self.val
+
+    def bytes_literal(self):
+        return self.val.lazy_string().value()
+
+    def string_literal(self):
+        # XXX use lazy_string() as well?
+        return string_literal(self.val)
+
+    def string(self):
+        return self.val.string()
+
+    def __format__(self, fmt):
+        return str(self.bytes_literal())
+
+
+# NOTE: gdb.parse_and_eval() is *slow* and calling it multiple times
+# may add noticeable latencies.  For standard C++ classes, we therefore
+# try to fetch their properties from libstdc++ internals (which hopefully
+# are stable), before falling back on calling the public API methods.
+
+class SharedPtr:
+    """
+    A `std::shared_ptr<T>` value.
+    """
+
+    def __init__(self, val):
+        self.val = val
+        try:
+            # libstdc++ internals
+            self._ptr = val['_M_ptr']
+        except gdb.error:
+            # fallback for other C++ standard libraries
+            self._ptr = gdb.parse_and_eval(f"{for_evaluation(val)}.get()")

Review comment:
       Hmm, as you can see in the `StdVector` constructor, there can be a bit more divergence, so I'm not sure a simple get/fallback function would suffice.
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] bkietz commented on a change in pull request #12092: ARROW-12735: [C++] Write GDB plugin

Posted by GitBox <gi...@apache.org>.
bkietz commented on a change in pull request #12092:
URL: https://github.com/apache/arrow/pull/12092#discussion_r788920949



##########
File path: cpp/gdb_arrow.py
##########
@@ -0,0 +1,1894 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from collections import namedtuple
+from collections.abc import Sequence
+import decimal
+import enum
+from functools import lru_cache, partial
+import struct
+import sys
+import warnings
+
+import gdb
+from gdb.types import get_basic_type
+
+# gdb API docs at https://sourceware.org/gdb/onlinedocs/gdb/Python-API.html#Python-API
+
+# TODO check guidelines here: https://sourceware.org/gdb/onlinedocs/gdb/Writing-a-Pretty_002dPrinter.html
+# TODO investigate auto-loading: https://sourceware.org/gdb/onlinedocs/gdb/Auto_002dloading-extensions.html#Auto_002dloading-extensions
+
+
+_type_ids = [
+    'NA', 'BOOL', 'UINT8', 'INT8', 'UINT16', 'INT16', 'UINT32', 'INT32',
+    'UINT64', 'INT64', 'HALF_FLOAT', 'FLOAT', 'DOUBLE', 'STRING', 'BINARY',
+    'FIXED_SIZE_BINARY', 'DATE32', 'DATE64', 'TIMESTAMP', 'TIME32', 'TIME64',
+    'INTERVAL_MONTHS', 'INTERVAL_DAY_TIME', 'DECIMAL128', 'DECIMAL256',
+    'LIST', 'STRUCT', 'SPARSE_UNION', 'DENSE_UNION', 'DICTIONARY', 'MAP',
+    'EXTENSION', 'FIXED_SIZE_LIST', 'DURATION', 'LARGE_STRING',
+    'LARGE_BINARY', 'LARGE_LIST', 'INTERVAL_MONTH_DAY_NANO']
+
+# Mirror the C++ Type::type enum
+Type = enum.IntEnum('Type', _type_ids, start=0)
+
+
+@lru_cache()
+def byte_order():
+    """
+    Get the target program (not the GDB host's) endianness.
+    """
+    s = gdb.execute("show endian", to_string=True).strip()
+    if 'big' in s:
+        return 'big'
+    elif 'little' in s:
+        return 'little'
+    warnings.warn('Could not determine target endianness '
+                  f'from GDB\'s response:\n"""{s}"""')
+    # Fall back to host endianness
+    return sys.byteorder
+
+
+def for_evaluation(val, ty=None):
+    """
+    Return a parsable form of gdb.Value `val`, optionally with gdb.Type `ty`.
+    """
+    if ty is None:
+        ty = get_basic_type(val.type)
+    if ty.code == gdb.TYPE_CODE_PTR:
+        # It's already a pointer, can represent it directly
+        return f"(({ty}) ({val}))"
+    if val.address is None:
+        raise ValueError(f"Cannot further evaluate rvalue: {val}")
+    return f"(* ({ty}*) ({val.address}))"
+
+
+def is_char_star(ty):
+    # Note that "const char*" can have TYPE_CODE_INT as target type...
+    ty = get_basic_type(ty)
+    return (ty.code == gdb.TYPE_CODE_PTR and
+            get_basic_type(ty.target()).code
+                in (gdb.TYPE_CODE_CHAR, gdb.TYPE_CODE_INT))
+
+
+def deref(val):
+    """
+    Dereference a raw or smart pointer.
+    """
+    ty = get_basic_type(val.type)
+    if ty.code == gdb.TYPE_CODE_PTR:
+        return val.dereference()
+    if ty.name.startswith('std::'):
+        if "shared" in ty.name:
+            return SharedPtr(val).value
+        if "unique" in ty.name:
+            return UniquePtr(val).value
+    raise TypeError(f"Cannot dereference value of type '{ty.name}'")
+
+
+_string_literal_mapping = {
+    ord('\\'): r'\\',
+    ord('\n'): r'\n',
+    ord('\r'): r'\r',
+    ord('\t'): r'\t',
+    ord('"'): r'\"',
+}
+
+for c in range(0, 32):
+    if c not in _string_literal_mapping:
+        _string_literal_mapping[c] = f"\\x{c:02x}"
+
+
+def string_literal(s):
+    """
+    Format a Python string or gdb.Value for display as a literal.
+    """
+    max_len = 50
+    if isinstance(s, gdb.Value):
+        s = s.string()
+    if len(s) > max_len:
+        s = s[:max_len]
+        return '"' + s.translate(_string_literal_mapping) + '" [continued]'
+    else:
+        return '"' + s.translate(_string_literal_mapping) + '"'
+
+
+def bytes_literal(val, size=None):
+    """
+    Format a gdb.Value for display as a literal containing possibly
+    unprintable characters.
+    """
+    return val.lazy_string(length=size).value()
+
+
+def utf8_literal(val, size=None):
+    """
+    Format a gdb.Value for display as a utf-8 literal.
+    """
+    if size is None:
+        s = val.string(encoding='utf8', errors='backslashreplace')
+    elif size != 0:
+        s = val.string(encoding='utf8', errors='backslashreplace', length=size)
+    else:
+        s = ""
+    return string_literal(s)
+
+
+def half_float_value(val):
+    """
+    Return a Python float of the given half-float (represented as a uint64_t
+    gdb.Value).
+    """
+    buf = gdb.selected_inferior().read_memory(val.address, 2)
+    return struct.unpack("e", buf)[0]
+
+
+def load_atomic(val):
+    """
+    Load a std::atomic<T>'s value.
+    """
+    valty = val.type.template_argument(0)
+    # XXX This assumes std::atomic<T> has the same layout as a raw T.
+    return val.address.reinterpret_cast(valty.pointer()).dereference()
+
+
+def load_null_count(val):
+    """
+    Load a null count from a gdb.Value of an integer (either atomic or not).
+    """
+    if get_basic_type(val.type).code != gdb.TYPE_CODE_INT:
+        val = load_atomic(val)
+    return val
+
+
+def format_null_count(val):
+    """
+    Format a null count value.
+    """
+    if not isinstance(val, int):
+        null_count = int(load_null_count(val))
+    return (f"null count {null_count}" if null_count != -1
+            else "unknown null count")
+
+
+def short_time_unit(val):
+    return ['s', 'ms', 'us', 'ns'][int(val)]
+
+
+def format_month_interval(val):
+    """
+    Format a MonthInterval value.
+    """
+    return f"{int(val)}M"
+
+
+def cast_to_concrete(val, ty):
+    return (val.reference_value().reinterpret_cast(ty.reference())
+            .referenced_value())
+
+
+def scalar_class_from_type(name):
+    """
+    Given a DataTypeClass class name (such as "BooleanType"), return the
+    corresponding Scalar class name.
+    """
+    assert name.endswith("Type")
+    return name[:-4] + "Scalar"
+
+
+def array_class_from_type(name):
+    """
+    Given a DataTypeClass class name (such as "BooleanType"), return the
+    corresponding Array class name.
+    """
+    assert name.endswith("Type")
+    return name[:-4] + "Array"
+
+
+class CString:
+    """
+    A `const char*` or similar value.
+    """
+
+    def __init__(self, val):
+        self.val = val
+
+    def __bool__(self):
+        return int(data) != 0 and int(data[0]) != 0
+
+    @property
+    def data(self):
+        return self.val
+
+    def bytes_literal(self):
+        return self.val.lazy_string().value()
+
+    def string_literal(self):
+        # XXX use lazy_string() as well?
+        return string_literal(self.val)
+
+    def string(self):
+        return self.val.string()
+
+    def __format__(self, fmt):
+        return str(self.bytes_literal())
+
+
+# NOTE: gdb.parse_and_eval() is *slow* and calling it multiple times
+# may add noticeable latencies.  For standard C++ classes, we therefore
+# try to fetch their properties from libstdc++ internals (which hopefully
+# are stable), before falling back on calling the public API methods.
+
+class SharedPtr:
+    """
+    A `std::shared_ptr<T>` value.
+    """
+
+    def __init__(self, val):
+        self.val = val
+        try:
+            # libstdc++ internals
+            self._ptr = val['_M_ptr']
+        except gdb.error:
+            # fallback for other C++ standard libraries
+            self._ptr = gdb.parse_and_eval(f"{for_evaluation(val)}.get()")

Review comment:
       Would it be worth extracting a helper function like
   ```suggestion
           self._ptr = get_or_evaluate(lambda: val['_M_ptr'], # libstdc++
                                       lambda: val['__ptr_'], # libcxx
                                       f"{for_evaluation(val)}.get()")
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] ursabot edited a comment on pull request #12092: ARROW-12735: [C++] Write GDB plugin

Posted by GitBox <gi...@apache.org>.
ursabot edited a comment on pull request #12092:
URL: https://github.com/apache/arrow/pull/12092#issuecomment-1017765706


   Benchmark runs are scheduled for baseline = b1b8728ee692359f6990ef8d188c88f482f632b6 and contender = a3efe72f99b1b9f23b1d11afc648f4306d32e330. a3efe72f99b1b9f23b1d11afc648f4306d32e330 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/4e6ed509334c43d784135bb1715b117e...dd608f6a1bda4922bef705ab08bbda9a/)
   [Failed :arrow_down:0.0% :arrow_up:0.0%] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/66846def44e44692b9d087781442d177...f58de9bb70fe4030a1a0ef40544d0969/)
   [Finished :arrow_down:0.43% :arrow_up:0.13%] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/3a66c0a7c9c148afbe323eda941a8d83...202c60eaf7714fb989ca8db120a552ed/)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] pitrou closed pull request #12092: ARROW-12735: [C++] Write GDB plugin

Posted by GitBox <gi...@apache.org>.
pitrou closed pull request #12092:
URL: https://github.com/apache/arrow/pull/12092


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] pitrou commented on pull request #12092: ARROW-12735: [C++] Write GDB plugin

Posted by GitBox <gi...@apache.org>.
pitrou commented on pull request #12092:
URL: https://github.com/apache/arrow/pull/12092#issuecomment-1017740010


   Writing documentation is covered in https://issues.apache.org/jira/browse/ARROW-15390


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] ursabot edited a comment on pull request #12092: ARROW-12735: [C++] Write GDB plugin

Posted by GitBox <gi...@apache.org>.
ursabot edited a comment on pull request #12092:
URL: https://github.com/apache/arrow/pull/12092#issuecomment-1017765706


   Benchmark runs are scheduled for baseline = b1b8728ee692359f6990ef8d188c88f482f632b6 and contender = a3efe72f99b1b9f23b1d11afc648f4306d32e330. a3efe72f99b1b9f23b1d11afc648f4306d32e330 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/4e6ed509334c43d784135bb1715b117e...dd608f6a1bda4922bef705ab08bbda9a/)
   [Scheduled] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/66846def44e44692b9d087781442d177...f58de9bb70fe4030a1a0ef40544d0969/)
   [Scheduled] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/3a66c0a7c9c148afbe323eda941a8d83...202c60eaf7714fb989ca8db120a552ed/)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] commented on pull request #12092: ARROW-12735: [C++] Write GDB plugin (WIP)

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #12092:
URL: https://github.com/apache/arrow/pull/12092#issuecomment-1006824489






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org