Exemple #1
0
    def _pointer(self):
        inner = self.val.type.template_argument(0)
        storage = template_type(rawtype(self.val.type.template_argument(1)))

        if storage == 'HPHP::detail::AtomicStorage':
            return idx.atomic_get(self.val['m_s']).cast(inner.pointer())
        else:
            return self.val['m_s'].cast(inner.pointer())
Exemple #2
0
    def _pointer(self):
        inner = self.val.type.template_argument(0)
        storage = template_type(rawtype(self.val.type.template_argument(1)))

        if storage == 'HPHP::detail::AtomicStorage':
            return idx.atomic_get(self.val['m_s']).cast(inner.pointer())
        else:
            return self.val['m_s'].cast(inner.pointer())
Exemple #3
0
def create_php(idx, ar, rip='0x????????', pc=None):
    """Collect metadata for a PHP frame.

    All arguments are expected to be gdb.Values, except `idx'.
    """
    func = ar['m_func']
    shared = rawptr(func['m_shared'])

    # Pull the function name.
    if not shared['m_isClosureBody']:
        func_name = nameof(func)
    else:
        func_name = nameof(func['m_baseCls'])
        func_name = func_name[:func_name.find(';')]

    if len(func_name) == 0:
        func_name = '<pseudomain>'

    frame = {
        'idx':  idx,
        'sp':   str(ar),
        'rip':  _format_rip(rip),
        'func': '[PHP] %s()' % func_name,
    }

    attrs = idxs.atomic_get(func['m_attrs']['m_attrs'])

    if attrs & V('HPHP::AttrBuiltin'):
        # Builtins don't have source files.
        return frame

    # Pull the PC from Func::base() and ar->m_soff if necessary.
    if pc is None:
        pc = shared['m_base'] + ar['m_soff']

    # Adjust it for calls.
    op_ptype = T('HPHP::Op').pointer()
    op = (func['m_unit']['m_bc'] + pc).cast(op_ptype).dereference()

    if op in [V('HPHP::Op::' + x) for x in
              ['PopR', 'UnboxR', 'UnboxRNop']]:
        pc -= 1

    frame['file'] = php_filename(func)
    frame['line'] = php_line_number(func, pc)

    return frame
Exemple #4
0
def create_php(idx, ar, rip='0x????????', pc=None):
    """Collect metadata for a PHP frame.

    All arguments are expected to be gdb.Values, except `idx'.
    """
    func = ar['m_func']
    shared = rawptr(func['m_shared'])

    # Pull the function name.
    if not shared['m_isClosureBody']:
        func_name = nameof(func)
    else:
        func_name = nameof(func['m_baseCls'])
        func_name = func_name[:func_name.find(';')]

    if len(func_name) == 0:
        func_name = '<pseudomain>'

    frame = {
        'idx':  idx,
        'fp':   str(ar),
        'rip':  _format_rip(rip),
        'func': '[PHP] %s()' % func_name,
    }

    attrs = idxs.atomic_get(func['m_attrs']['m_attrs'])

    if attrs & V('HPHP::AttrBuiltin'):
        # Builtins don't have source files.
        return frame

    # Pull the PC from Func::base() and ar->m_soff if necessary.
    if pc is None:
        pc = shared['m_base'] + ar['m_soff']

    # Adjust it for calls.
    op_ptype = T('HPHP::Op').pointer()
    op = (func['m_unit']['m_bc'] + pc).cast(op_ptype).dereference()

    if op in [V('HPHP::Op::' + x) for x in
              ['PopR', 'UnboxR', 'UnboxRNop']]:
        pc -= 1

    frame['file'] = php_filename(func)
    frame['line'] = php_line_number(func, pc)

    return frame
Exemple #5
0
def create_php(idx, ar, rip="0x????????", pc=None):
    """Collect metadata for a PHP frame.

    All arguments are expected to be gdb.Values, except `idx'.
    """
    func = ar["m_func"]
    shared = rawptr(func["m_shared"])

    # Pull the function name.
    if not shared["m_isClosureBody"]:
        func_name = nameof(func)
    else:
        func_name = nameof(func["m_baseCls"])
        func_name = func_name[: func_name.find(";")]

    if len(func_name) == 0:
        func_name = "<pseudomain>"

    frame = {"idx": idx, "sp": str(ar), "rip": _format_rip(rip), "func": "[PHP] {0!s}()".format(func_name)}

    attrs = idxs.atomic_get(func["m_attrs"]["m_attrs"])

    if attrs & V("HPHP::AttrBuiltin"):
        # Builtins don't have source files.
        return frame

    # Pull the PC from Func::base() and ar->m_soff if necessary.
    if pc is None:
        pc = shared["m_base"] + ar["m_soff"]

    # Adjust it for calls.
    op_ptype = T("HPHP::Op").pointer()
    op = (func["m_unit"]["m_bc"] + pc).cast(op_ptype).dereference()

    if op in [V("HPHP::Op::" + x) for x in ["PopR", "UnboxR", "UnboxRNop"]]:
        pc -= 1

    frame["file"] = php_filename(func)
    frame["line"] = php_line_number(func, pc)

    return frame
Exemple #6
0
def create_php(idx, ar, rip='0x????????', pc=None):
    """Collect metadata for a PHP frame.

    All arguments are expected to be gdb.Values, except `idx'.
    """
    func = ar['m_func']
    shared = rawptr(func['m_shared'])

    # Pull the function name.
    if not shared['m_isClosureBody']:
        func_name = nameof(func)
    else:
        func_name = nameof(func['m_baseCls'].cast(T('HPHP::Class').pointer()))
        func_name = func_name[:func_name.find(';')]

    if len(func_name) == 0:
        func_name = '<pseudomain>'

    frame = {
        'idx': idx,
        'fp': str(ar),
        'rip': _format_rip(rip),
        'func': '[PHP] %s()' % func_name,
    }

    attrs = idxs.atomic_get(func['m_attrs']['m_attrs'])

    if attrs & V('HPHP::AttrBuiltin'):
        # Builtins don't have source files.
        return frame

    # Pull the PC from Func::base() and ar->m_callOff if necessary.
    if pc is None:
        pc = shared['m_base'] + (ar['m_callOffAndFlags'] >> 2)

    frame['file'] = php_filename(func)
    frame['line'] = php_line_number(func, pc)

    return frame