GIF87a; 404

MY HEART




Upload:

Command:

diavoloapp@18.224.21.26: ~ $
# pahole command for gdb

# Copyright (C) 2008, 2009, 2012 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import gdb

class Pahole (gdb.Command):
    """Show the holes in a structure.
This command takes a single argument, a type name.
It prints the type and displays comments showing where holes are."""

    def __init__ (self):
        super (Pahole, self).__init__ ("pahole", gdb.COMMAND_NONE,
                                       gdb.COMPLETE_SYMBOL)

    def maybe_print_hole(self, bitpos, field_bitpos):
        if bitpos != field_bitpos:
            hole = field_bitpos - bitpos
            print '  /* XXX %d bit hole, try to pack */' % hole

    def pahole (self, type, level, name):
        if name is None:
            name = ''
        tag = type.tag
        if tag is None:
            tag = ''
        print '%sstruct %s {' % (' ' * (2 * level), tag)
        bitpos = 0
        for field in type.fields ():
            # Skip static fields.
            if not hasattr (field, ('bitpos')):
                continue

            ftype = field.type.strip_typedefs()

            self.maybe_print_hole(bitpos, field.bitpos)
            bitpos = field.bitpos
            if field.bitsize > 0:
                fieldsize = field.bitsize
            else:
                # TARGET_CHAR_BIT here...
                fieldsize = 8 * ftype.sizeof

            # TARGET_CHAR_BIT
            print ' /* %3d %3d */' % (int (bitpos / 8), int (fieldsize / 8)),
            bitpos = bitpos + fieldsize

            if ftype.code == gdb.TYPE_CODE_STRUCT:
                self.pahole (ftype, level + 1, field.name)
            else:
                print ' ' * (2 + 2 * level),
                print '%s %s' % (str (ftype), field.name)

        if level == 0:
            self.maybe_print_hole(bitpos, 8 * type.sizeof)

        print ' ' * (14 + 2 * level),
        print '} %s' % name

    def invoke (self, arg, from_tty):
        type = gdb.lookup_type (arg)
        type = type.strip_typedefs ()
        if type.code != gdb.TYPE_CODE_STRUCT:
            raise TypeError, '%s is not a struct type' % arg
        print ' ' * 14,
        self.pahole (type, 0, '')

Pahole()

Filemanager

Name Type Size Permission Actions
__init__.py File 694 B 0644
__init__.pyc File 132 B 0644
__init__.pyo File 132 B 0644
explore.py File 26.2 KB 0644
explore.pyc File 22.78 KB 0644
explore.pyo File 22.78 KB 0644
frame_filters.py File 16.04 KB 0644
frame_filters.pyc File 17.35 KB 0644
frame_filters.pyo File 17.35 KB 0644
ignore_errors.py File 1.33 KB 0644
ignore_errors.pyc File 1.01 KB 0644
ignore_errors.pyo File 1.01 KB 0644
pahole.py File 2.73 KB 0644
pahole.pyc File 2.31 KB 0644
pahole.pyo File 2.31 KB 0644
pretty_printers.py File 14.13 KB 0644
pretty_printers.pyc File 10.92 KB 0644
pretty_printers.pyo File 10.92 KB 0644
prompt.py File 2.08 KB 0644
prompt.pyc File 1.94 KB 0644
prompt.pyo File 1.94 KB 0644
type_printers.py File 4.32 KB 0644
type_printers.pyc File 4.72 KB 0644
type_printers.pyo File 4.72 KB 0644