• Stars
    star
    114
  • Rank 297,962 (Top 7 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created over 10 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

tool to show the structure layout of types in your C/C++ program, highlighting padding

struct_layout

tool to show the structure layout of types in your C/C++ program, highlighting padding.

It recreates the structure layout based on DWARF debug information from a binary or object file. This tool analyzes the output from dwarfdump which will need to be installed for struct_layout to work.

On Mac, debug symbols are not typically linked into the final executable, but this tool can still be used on individual object and .dSYM files.

It is typically a good idea to pipe the output from struct_layout to less. Since the default is to colorize the output:

./struct_layout.py <object-file>.o | less -r

usage

usage: ./struct_layout.py [options] exe-file [name-prefix-filter]

exe-file must have DWARF debug symbols in it. It
may be an object file, shared library or executable. On Mac
dsymutils will be invoked for files with no direct debug symbols
in them.

name-prefix-filter is an optional argument. When
specified, only types whose prefix matches this are
printed. Names are fully qualified and start with ::
to denote the global scope.

OPTIONS
-a           print all types, including standard library
             and implementation detail types
-c           disable color output
-p <file>    use the specified access_profile output file
             to display use counts for only instrumented types

the dwarfdump tool is a dependency and need to be
installed on your system. On Mac OS X you may need dsymutil
in order to link debug symbols together

Output is colorized by default, use -c to disable. Types belonging to the standard library and compiler specific libraries are not printed by default. To see those types as well, pass in -a.

The optional filter simply filters the prefix of types. This is primarily useful if you're only interested in types from a specific namespace. For instance, passing in ::boost:: will only print types defined in the boost namespace.

The -p option takes the profile output generated from access_profiler.

example output

struct ::libtorrent::i2p_connection [104 Bytes]
     : [shared_ptr<libtorrent::i2p_stream> : 16] m_sam_socket
    0:   [i2p_stream* : 8] px
     :   [shared_count : 8] pn
    8:     [sp_counted_base* : 8] pi_
     : [proxy_settings : 40] m_sam_router
     :   [basic_string<char> : 8] hostname
     :     [_Alloc_hider : 8] _M_dataplus
     :       [allocator<char> : 1] <base-class>
   16:         [new_allocator<char> : 1] <base-class>
   16:       [char* : 8] _M_p
   24:   [int : 4] port
   --- 4 Bytes padding ---
     :   [basic_string<char> : 8] username
     :     [_Alloc_hider : 8] _M_dataplus
     :       [allocator<char> : 1] <base-class>
   32:         [new_allocator<char> : 1] <base-class>
   32:       [char* : 8] _M_p
     :   [basic_string<char> : 8] password
     :     [_Alloc_hider : 8] _M_dataplus
     :       [allocator<char> : 1] <base-class>
   40:         [new_allocator<char> : 1] <base-class>
   40:       [char* : 8] _M_p
   48:   [enum proxy_type : 4] type
   52:   [bool : 1] proxy_hostnames
   53:   [bool : 1] proxy_peer_connections
   --- 2 Bytes padding ---
     : [basic_string<char> : 8] m_i2p_local_endpoint
     :   [_Alloc_hider : 8] _M_dataplus
     :     [allocator<char> : 1] <base-class>
   56:       [new_allocator<char> : 1] <base-class>
   56:     [char* : 8] _M_p
     : [basic_string<char> : 8] m_session_id
     :   [_Alloc_hider : 8] _M_dataplus
     :     [allocator<char> : 1] <base-class>
   64:       [new_allocator<char> : 1] <base-class>
   64:     [char* : 8] _M_p
     : ["list<std::pair<std::basic_string<char>, boost::function<void (const boost::system::error_code &, const char * : 16] m_name_lookup
     :   ["_List_base<std::pair<std::basic_string<char>, boost::function<void (const boost::system::error_code &, const char * : 16] <base-class>
     :     [_List_impl : 16] _M_impl
     :       ["allocator<std::_List_node<std::pair<std::basic_string<char>, boost::function<void (const boost::system::error_code &, const char * : 1] <base-class>
   72:         ["new_allocator<std::_List_node<std::pair<std::basic_string<char>, boost::function<void (const boost::system::error_code &, const char * : 1] <base-class>
     :       [_List_node_base : 16] _M_node
   72:         [_List_node_base* : 8] _M_next
   80:         [_List_node_base* : 8] _M_prev
   88: [enum state_t : 4] m_state
   --- 4 Bytes padding ---
   96: [io_service& : 8] m_io_service

More Repositories

1

libtorrent

an efficient feature complete C++ bittorrent implementation
C++
4,957
star
2

btfs

a user space file system for efficiently downloading and seeding torrents
C++
69
star
3

access_profiler

a tool to count accesses to member variables in c++ programs
C++
69
star
4

libtorrent-webui

a WebUI implementation for libtorrent based clients
C++
45
star
5

utrack

fast UDP bittorrent tracker
C++
38
star
6

libsimulator

libsimulator is a library for building discrete event simulations, implementing the ``boost.asio`` API.
C++
21
star
7

bdecode

an efficient bdecoder / parser
C++
16
star
8

libtorrent-daemon

a bittorrent client for servers
C++
14
star
9

try_signal

Turns signals within a scope into c++ exceptions
C++
13
star
10

torrent-tools

tools for creating, inspecting and modifying torrent files
C++
10
star
11

peer_ordering

This is a simple simulation of peer connections in a bittorrent swarm, illustrating the potential performance issues (peer clustering) of widely used first-come-first-serve logic for accepting incoming connections as well as a solution to that problem.
Python
8
star
12

bittorrent-trace

A tool to reconstruct and analyze bittorrent stream from a packet capture
C++
7
star
13

inline-namespace-abi-versioning

Example and test of an approach to gradually introduce proper ABI versioning with inline namespaces in a library
C++
6
star
14

libtorrent-fuzz

fuzzing infrastructure for libtorrent
C++
3
star
15

torrent-analyzer

A tool to run statistics analysis on a set of .torrent files
C++
3
star
16

bittorrent-multi-have

a bittorrent extension proposal
Python
2
star
17

moving_average

an implementation of integer moving average algorithm
Python
2
star
18

conan-boost-build-gen

a conan generator for boost-build
Python
1
star
19

hash_complete_prefix

Experiment to count "complete bit prefixes" of output from various hashes, given complete bit prefix inputs. A complete bit prefix is a number of bits in the prefix of the digest where every bit combination is present in the set of digests.
C++
1
star