Fixing Thumb Disassemble Issue of LLDB-310 and Later

Symptoms

The lldb-310 and later revisions couldn’t disassemble and trace thumb code block correctly without full debug symbols.

Analyse

It’s must be a defect brought by the lldb-310, because the lldb-300 could handle thumb code block correctly without full debug symbols. It’s done by utilising the Function Starts data embedded in modern MachO file.

Resolution

Modify the code of Target::SetExecutableModule in Source/Target/Target.cpp in LLDB source tree. Do not clear the m_section_load_history, because embedded symbol parse phase needs section list of the executable which maintained by m_section_load_history. An empty section list will leads to misinterpreting some data.

Like this:

void
Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
{
    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TARGET));
    //ClearModules(false);
    ModulesDidUnload (m_images, false);
    //m_section_load_history.Clear();
    m_images.Clear();
    m_scratch_ast_context_ap.reset();
    m_scratch_ast_source_ap.reset();
    m_ast_importer_ap.reset();
    
    if (executable_sp.get())
    { ... }
}

You’ve spotted Apple’s bug, but manually fixing the bug in each LLDB from Xcode seems a little bit complicated for most of the rookie developers. Can you offer a further solution?

尝试使用第三方反汇编引擎抛弃苹果引擎
Using the third party disassembly-engine instead. XD

那个可以说中文麽,多谢分享