(name)
return gdb.lookup_type(name)
Load symbol by name from headers in standard system include directory
Load symbol by name from headers in standard system include directory
Load symbol by name from headers in standard system include directory
def load(name):
    """Load symbol by name from headers in standard system include directory"""
    try:
        return gdb.lookup_type(name)
    except gdb.error:
        pass

    # s, _ = gdb.lookup_symbol(name)

    # Try to find an architecture-specific include path
    arch = pwndbg.arch.current.split(':')[0]

    include_dir = glob.glob('/usr/%s*/include' % arch)

    if include_dir:
        include_dir = include_dir[0]
    else:
        include_dir = '/usr/include'

    source = '#include <fstream>\n'

    for subdir in ['', 'sys', 'netinet']:
        dirname = os.path.join(include_dir, subdir)
        for path in glob.glob(os.path.join(dirname, '*.h')):
            if any(b in path for b in blacklist):
              continue
            print(path)
            source += '#include "%s"\n' % path


    source += '''
{name} foo;
'''.format(**locals())

    filename = '%s/%s_%s.cc' % (pwndbg.tempfile.cachedir('typeinfo'), arch, '-'.join(name.split()))

    with open(filename, 'w+') as f:
        f.write(source)
        f.flush()
        os.fsync(f.fileno())

    compile(filename)

    return gdb.lookup_type(name)
def load ( name ) : try : return gdb . lookup_type ( name ) except gdb . error : pass # s, _ = gdb.lookup_symbol(name) # Try to find an architecture-specific include path arch = pwndbg . arch . current . split ( ':' ) [ 0 ] include_dir = glob . glob ( '/usr/%s*/include' % arch ) if include_dir : include_dir = include_dir [ 0 ] else : include_dir = '/usr/include' source = '#include <fstream>\n' for subdir in [ '' , 'sys' , 'netinet' ] : dirname = os . path . join ( include_dir , subdir ) for path in glob . glob ( os . path . join ( dirname , '*.h' ) ) : if any ( b in path for b in blacklist ) : continue print ( path ) source += '#include "%s"\n' % path source += '''
{name} foo;
''' . format ( * * locals ( ) ) filename = '%s/%s_%s.cc' % ( pwndbg . tempfile . cachedir ( 'typeinfo' ) , arch , '-' . join ( name . split ( ) ) ) with open ( filename , 'w+' ) as f : f . write ( source ) f . flush ( ) os . fsync ( f . fileno ( ) ) compile ( filename ) return gdb . lookup_type ( name )