MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / KCore

Method KCore

Source/ThirdParty/tracy/client/TracyKCore.cpp:65–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63};
64
65KCore::KCore()
66 : m_offsets( 16 )
67{
68 m_fd = open( "/proc/kcore", O_RDONLY );
69 if( m_fd == -1 ) return;
70
71 elf_ehdr ehdr;
72 if( read( m_fd, &ehdr, sizeof( ehdr ) ) != sizeof( ehdr ) ) goto err;
73
74 assert( ehdr.e_phentsize == sizeof( elf_phdr ) );
75
76 for( elf_half i=0; i<ehdr.e_phnum; i++ )
77 {
78 elf_phdr phdr;
79 if( lseek( m_fd, ehdr.e_phoff + i * ehdr.e_phentsize, SEEK_SET ) == -1 ) goto err;
80 if( read( m_fd, &phdr, sizeof( phdr ) ) != sizeof( phdr ) ) goto err;
81 if( phdr.p_type != 1 ) continue;
82
83 auto ptr = m_offsets.push_next();
84 ptr->start = phdr.p_vaddr;
85 ptr->size = phdr.p_memsz;
86 ptr->offset = phdr.p_offset;
87 }
88
89 std::sort( m_offsets.begin(), m_offsets.end(), []( const Offset& lhs, const Offset& rhs ) { return lhs.start < rhs.start; } );
90 TracyDebug( "KCore: %zu segments found\n", m_offsets.size() );
91 return;
92
93err:
94 close( m_fd );
95 m_fd = -1;
96}
97
98KCore::~KCore()
99{

Callers

nothing calls this directly

Calls 7

readFunction · 0.85
sortFunction · 0.85
closeFunction · 0.85
push_nextMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected