Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-26 08:42:44

0001 /* Inline GDB pretty printer for result
0002 (C) 2024 Niall Douglas <http://www.nedproductions.biz/> (6 commits)
0003 File Created: Jun 2024
0004 
0005 
0006 Boost Software License - Version 1.0 - August 17th, 2003
0007 
0008 Permission is hereby granted, free of charge, to any person or organization
0009 obtaining a copy of the software and accompanying documentation covered by
0010 this license (the "Software") to use, reproduce, display, distribute,
0011 execute, and transmit the Software, and to prepare derivative works of the
0012 Software, and to permit third-parties to whom the Software is furnished to
0013 do so, all subject to the following:
0014 
0015 The copyright notices in the Software and this entire statement, including
0016 the above license grant, this restriction and the following disclaimer,
0017 must be included in all copies of the Software, in whole or in part, and
0018 all derivative works of the Software, unless such copies or derivative
0019 works are solely in the form of machine-executable object code generated by
0020 a source language processor.
0021 
0022 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0023 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0024 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
0025 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
0026 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
0027 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
0028 DEALINGS IN THE SOFTWARE.
0029 */
0030 
0031 #ifndef BOOST_OUTCOME_INLINE_GDB_PRETTY_PRINTER_H
0032 #define BOOST_OUTCOME_INLINE_GDB_PRETTY_PRINTER_H
0033 
0034 #ifndef BOOST_OUTCOME_DISABLE_INLINE_GDB_PRETTY_PRINTERS
0035 #if defined(__ELF__)
0036 #ifdef __clang__
0037 #pragma clang diagnostic push
0038 #pragma clang diagnostic ignored "-Woverlength-strings"
0039 #endif
0040 __asm__(".pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n"
0041         ".byte 4 /* Python Text */\n"
0042         ".ascii \"gdb.inlined-script\\n\"\n"
0043         ".ascii \"import gdb.printing\\n\"\n"
0044         ".ascii \"import os\\n\"\n"
0045 
0046         ".ascii \"def synthesise_gdb_value_from_string(s):\\n\"\n"
0047         ".ascii \"    '''For when you want to return a synthetic string from children()'''\\n\"\n"
0048         ".ascii \"    return gdb.Value(s + '\\0').cast(gdb.lookup_type('char').pointer())\\n\"\n"
0049 
0050         ".ascii \"class OutcomeBasicOutcomePrinter(object):\\n\"\n"
0051         ".ascii \"    '''Print an outcome::basic_outcome<T> and outcome::basic_result<T>'''\\n\"\n"
0052 
0053         ".ascii \"    def __init__(self, val):\\n\"\n"
0054         ".ascii \"        self.val = val\\n\"\n"
0055 
0056         ".ascii \"    def children(self):\\n\"\n"
0057         ".ascii \"        if self.val['_state']['_status']['status_value'] & 1 == 1:\\n\"\n"
0058         ".ascii \"            yield ('value', self.val['_state']['_value'])\\n\"\n"
0059         ".ascii \"        if self.val['_state']['_status']['status_value'] & 2 == 2:\\n\"\n"
0060         ".ascii \"            yield ('error', self.val['_state']['_error'])\\n\"\n"
0061         ".ascii \"        if self.val['_state']['_status']['status_value'] & 4 == 4:\\n\"\n"
0062         ".ascii \"            yield ('exception', self.val['_ptr'])\\n\"\n"
0063 
0064         ".ascii \"    def display_hint(self):\\n\"\n"
0065         ".ascii \"        return None\\n\"\n"
0066 
0067         ".ascii \"    def to_string(self):\\n\"\n"
0068         ".ascii \"        if self.val['_state']['_status']['status_value'] & 54 == 54:\\n\"\n"
0069         ".ascii \"            return 'errored (errno, moved from) + exceptioned'\\n\"\n"
0070         ".ascii \"        if self.val['_state']['_status']['status_value'] & 50 == 50:\\n\"\n"
0071         ".ascii \"            return 'errored (errno, moved from)'\\n\"\n"
0072         ".ascii \"        if self.val['_state']['_status']['status_value'] & 38 == 38:\\n\"\n"
0073         ".ascii \"            return 'errored + exceptioned (moved from)'\\n\"\n"
0074         ".ascii \"        if self.val['_state']['_status']['status_value'] & 36 == 36:\\n\"\n"
0075         ".ascii \"            return 'exceptioned (moved from)'\\n\"\n"
0076         ".ascii \"        if self.val['_state']['_status']['status_value'] & 35 == 35:\\n\"\n"
0077         ".ascii \"            return 'errored (moved from)'\\n\"\n"
0078         ".ascii \"        if self.val['_state']['_status']['status_value'] & 33 == 33:\\n\"\n"
0079         ".ascii \"            return 'valued (moved from)'\\n\"\n"
0080         ".ascii \"        if self.val['_state']['_status']['status_value'] & 22 == 22:\\n\"\n"
0081         ".ascii \"            return 'errored (errno) + exceptioned'\\n\"\n"
0082         ".ascii \"        if self.val['_state']['_status']['status_value'] & 18 == 18:\\n\"\n"
0083         ".ascii \"            return 'errored (errno)'\\n\"\n"
0084         ".ascii \"        if self.val['_state']['_status']['status_value'] & 6 == 6:\\n\"\n"
0085         ".ascii \"            return 'errored + exceptioned'\\n\"\n"
0086         ".ascii \"        if self.val['_state']['_status']['status_value'] & 4 == 4:\\n\"\n"
0087         ".ascii \"            return 'exceptioned'\\n\"\n"
0088         ".ascii \"        if self.val['_state']['_status']['status_value'] & 2 == 2:\\n\"\n"
0089         ".ascii \"            return 'errored'\\n\"\n"
0090         ".ascii \"        if self.val['_state']['_status']['status_value'] & 1 == 1:\\n\"\n"
0091         ".ascii \"            return 'valued'\\n\"\n"
0092         ".ascii \"        if self.val['_state']['_status']['status_value'] & 0xff == 0:\\n\"\n"
0093         ".ascii \"            return 'empty'\\n\"\n"
0094 
0095         ".ascii \"class OutcomeCResultStatusPrinter(object):\\n\"\n"
0096         ".ascii \"    '''Print a C result'''\\n\"\n"
0097 
0098         ".ascii \"    def __init__(self, val):\\n\"\n"
0099         ".ascii \"        self.val = val\\n\"\n"
0100 
0101         ".ascii \"    def children(self):\\n\"\n"
0102         ".ascii \"        if self.val['flags'] & 1 == 1:\\n\"\n"
0103         ".ascii \"            yield ('value', self.val['value'])\\n\"\n"
0104         ".ascii \"        if self.val['flags'] & 2 == 2:\\n\"\n"
0105         ".ascii \"            yield ('error', self.val['error'])\\n\"\n"
0106 
0107         ".ascii \"    def display_hint(self):\\n\"\n"
0108         ".ascii \"        return None\\n\"\n"
0109 
0110         ".ascii \"    def to_string(self):\\n\"\n"
0111         ".ascii \"        if self.val['flags'] & 50 == 50:\\n\"\n"
0112         ".ascii \"            return 'errored (errno, moved from)'\\n\"\n"
0113         ".ascii \"        if self.val['flags'] & 35 == 35:\\n\"\n"
0114         ".ascii \"            return 'errored (moved from)'\\n\"\n"
0115         ".ascii \"        if self.val['flags'] & 33 == 33:\\n\"\n"
0116         ".ascii \"            return 'valued (moved from)'\\n\"\n"
0117         ".ascii \"        if self.val['flags'] & 18 == 18:\\n\"\n"
0118         ".ascii \"            return 'errored (errno)'\\n\"\n"
0119         ".ascii \"        if self.val['flags'] & 2 == 2:\\n\"\n"
0120         ".ascii \"            return 'errored'\\n\"\n"
0121         ".ascii \"        if self.val['flags'] & 1 == 1:\\n\"\n"
0122         ".ascii \"            return 'valued'\\n\"\n"
0123         ".ascii \"        if self.val['flags'] & 0xff == 0:\\n\"\n"
0124         ".ascii \"            return 'empty'\\n\"\n"
0125 
0126 
0127         ".ascii \"class OutcomeCStatusCodePrinter(object):\\n\"\n"
0128         ".ascii \"    '''Print a C status code'''\\n\"\n"
0129 
0130         ".ascii \"    def __init__(self, val):\\n\"\n"
0131         ".ascii \"        self.val = val\\n\"\n"
0132 
0133         ".ascii \"    def children(self):\\n\"\n"
0134         ".ascii \"        yield ('domain', self.val['domain'])\\n\"\n"
0135         ".ascii \"        yield ('value', self.val['value'])\\n\"\n"
0136 
0137         ".ascii \"    def display_hint(self):\\n\"\n"
0138         ".ascii \"        return None\\n\"\n"
0139 
0140         ".ascii \"    def to_string(self):\\n\"\n"
0141         ".ascii \"        s = str(self.val['domain'])\\n\"\n"
0142         ".ascii \"        if 'posix_code_domain' in s or 'generic_code_domain' in s:\\n\"\n"
0143         ".ascii \"            return str(self.val['value']) + ' (' + os.strerror(int(self.val['value'])) + ')'\\n\"\n"
0144         ".ascii \"        else:\\n\"\n"
0145         ".ascii \"            return self.val['value']\\n\"\n"
0146 
0147         ".ascii \"def build_pretty_printer():\\n\"\n"
0148         ".ascii \"    pp = gdb.printing.RegexpCollectionPrettyPrinter('outcome_v2')\\n\"\n"
0149         ".ascii \"    pp.add_printer('outcome_v2::basic_result', '^(boost::)?outcome_v2[_0-9a-f]*::basic_result<.*>$', OutcomeBasicOutcomePrinter)\\n\"\n"
0150         ".ascii \"    pp.add_printer('outcome_v2::basic_outcome', '^(boost::)?outcome_v2[_0-9a-f]*::basic_outcome<.*>$', OutcomeBasicOutcomePrinter)\\n\"\n"
0151         ".ascii \"    pp.add_printer('cxx_result_status_code_*', '^cxx_result_status_code_.*$', OutcomeCResultStatusPrinter)\\n\"\n"
0152         ".ascii \"    pp.add_printer('cxx_status_code_*', '^cxx_status_code_.*$', OutcomeCStatusCodePrinter)\\n\"\n"
0153         ".ascii \"    return pp\\n\"\n"
0154 
0155         ".ascii \"def register_printers(obj = None):\\n\"\n"
0156         ".ascii \"    gdb.printing.register_pretty_printer(obj, build_pretty_printer(), replace = True)\\n\"\n"
0157 
0158         ".ascii \"register_printers(gdb.current_objfile())\\n\"\n"
0159 
0160         ".byte 0\n"
0161         ".popsection\n");
0162 #ifdef __clang__
0163 #pragma clang diagnostic pop
0164 #endif
0165 #endif
0166 #endif
0167 
0168 #endif