Detect disassembly failures.

This commit is contained in:
Bartosz Taudul 2020-04-19 14:40:36 +02:00
parent c78e11872c
commit b157d4c161
2 changed files with 3 additions and 0 deletions

View File

@ -150,6 +150,7 @@ bool SourceView::Disassemble( uint64_t symAddr, const Worker& worker )
uint32_t len;
auto code = worker.GetSymbolCode( symAddr, len );
if( !code ) return false;
m_disasmFail = -1;
csh handle;
cs_err rval = CS_ERR_ARCH;
switch( arch )
@ -176,6 +177,7 @@ bool SourceView::Disassemble( uint64_t symAddr, const Worker& worker )
size_t cnt = cs_disasm( handle, (const uint8_t*)code, len, symAddr, 0, &insn );
if( cnt > 0 )
{
if( insn[cnt-1].address - symAddr + insn[cnt-1].size < len ) m_disasmFail = insn[cnt-1].address - symAddr;
int mLenMax = 0;
m_asm.reserve( cnt );
for( size_t i=0; i<cnt; i++ )

View File

@ -89,6 +89,7 @@ private:
DecayValue<uint32_t> m_hoveredSource;
int m_displayMode;
uint32_t m_codeLen;
int32_t m_disasmFail;
DecayValue<uint64_t> m_highlightAddr;
bool m_asmRelative;
bool m_asmShowSourceLocation;