(s)
This function should be used as ``argparse.ArgumentParser`` .add_argument method's `type` helper.

    This makes the type being parsed as gdb value and if that parsing fails,
    a string is returned.

    :param s: String.
    :return: Whatever gdb.parse_and_eval returns or string.
This function should be used as ``argparse.ArgumentParser`` .add_argument method's `type` helper.
This function should be used as argparse . ArgumentParser . add_argument method s type helper .
def sloppy_gdb_parse(s):
    """
    This function should be used as ``argparse.ArgumentParser`` .add_argument method's `type` helper.

    This makes the type being parsed as gdb value and if that parsing fails,
    a string is returned.

    :param s: String.
    :return: Whatever gdb.parse_and_eval returns or string.
    """
    try:
        val = gdb.parse_and_eval(s)
        # We can't just return int(val) because GDB may return:
        # "Python Exception <class 'gdb.error'> Cannot convert value to long."
        # e.g. for:
        # pwndbg> pi int(gdb.parse_and_eval('__libc_start_main'))
        #
        # Here, the _mask_val.type should be `unsigned long long`
        return int(val.cast(_mask_val_type))
    except (TypeError, gdb.error):
        return s
def sloppy_gdb_parse ( s ) : try : val = gdb . parse_and_eval ( s ) # We can't just return int(val) because GDB may return: # "Python Exception <class 'gdb.error'> Cannot convert value to long." # e.g. for: # pwndbg> pi int(gdb.parse_and_eval('__libc_start_main')) # # Here, the _mask_val.type should be `unsigned long long` return int ( val . cast ( _mask_val_type ) ) except ( TypeError , gdb . error ) : return s