1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

In python environments where components are loaded as shared libraries, capstone sometimes fails to resolve the std-library symbols. This can be worked around by explicitly setting 'CS_OPT_MEM' which can provide custom functions for memory allocation / system functions, with those which they are expected to be defaulted to

This commit is contained in:
simplyWiri 2023-11-14 19:20:19 +11:00
parent 2f2f9939db
commit 5b08e2b468
2 changed files with 15 additions and 0 deletions

View File

@ -696,6 +696,13 @@ bool SourceView::Disassemble( uint64_t symAddr, const Worker& worker )
uint32_t len;
auto code = worker.GetSymbolCode( symAddr, len );
if( !code ) return false;
cs_opt_mem setup;
setup.malloc = &malloc;
setup.calloc = &calloc;
setup.realloc = &realloc;
setup.free = &free;
setup.vsnprintf = &vsnprintf;
cs_option(0, CS_OPT_MEM, reinterpret_cast<size_t>(&setup));
m_disasmFail = -1;
csh handle;
cs_err rval = CS_ERR_ARCH;

View File

@ -3825,6 +3825,14 @@ void Worker::AddSymbolCode( uint64_t ptr, const char* data, size_t sz )
m_data.symbolCodeSize += sz;
if( m_data.cpuArch == CpuArchUnknown ) return;
cs_opt_mem setup;
setup.malloc = &malloc;
setup.calloc = &calloc;
setup.realloc = &realloc;
setup.free = &free;
setup.vsnprintf = &vsnprintf;
cs_option(0, CS_OPT_MEM, reinterpret_cast<size_t>(&setup));
csh handle;
cs_err rval = CS_ERR_ARCH;
switch( m_data.cpuArch )