[lldb-dev] llvm assertion while evaluating expressions for MIPS on Linux

Bhushan Attarde via lldb-dev lldb-dev at lists.llvm.org
Mon Oct 19 23:30:09 PDT 2015


I am facing issue (llvm assertion) in evaluating expressions for MIPS on Linux.

(lldb) p fooptr(a,b)
lldb: /home/battarde/git/llvm/lib/MC/ELFObjectWriter.cpp:791: void {anonymous}::ELFObjectWriter::computeSymbolTable(llvm::MCAssembler&, const llvm::MCAsmLayout&, const SectionIndexMapTy&, const RevGroupMapTy&, {anonymous}::ELFObjectWriter::SectionOffsetsTy&): Assertion `Local || !Symbol.isTemporary()' failed.

I debugged it and found that, LLDB inserts calls to dynamic checker function for pointer validation at appropriate locations in expression's IR.

The issue is that this checker function's name (hard-coded in LLDB in lldb\source\Expression\IRDynamicChecks.cpp) starts with "$" i.e "$__lldb_valid_pointer_check".
While creating a MCSymbol (MCContext::createSymbol() in llvm/lib/MC/MCContext.cpp) for this function llvm detects the name starts with "$" and marks that symbol as 'temporary' symbol (PrivateGlobalPrefix is '$' for MIPS)
Further while computing a symbol table in ELFObjectWriter::computeSymbolTable() the assertion triggers because this symbol is 'temporary'.

I tried couple of things that solves this issue for MIPS.

1. Remove '$' from the function name.
2. Remove "C Language linkage" from the dynamic pointer validation function i.e the below piece of code in lldb\source\Expression\IRDynamicChecks.cpp
static const char g_valid_pointer_check_text[] =
"extern \"C\" void\n"
"$__lldb_valid_pointer_check (unsigned char *$__lldb_arg_ptr)\n"
"    unsigned char $__lldb_local_val = *$__lldb_arg_ptr;\n"


static const char g_valid_pointer_check_text[] =
"$__lldb_valid_pointer_check (unsigned char *$__lldb_arg_ptr)\n"
"    unsigned char $__lldb_local_val = *$__lldb_arg_ptr;\n"

Removing C Language linkage will enable mangling and will mangle "$__lldb_valid_pointer_check" to something like "_Z27$__lldb_valid_pointer_checkPh".
So the mangled name won't start with '$' and the symbol will not be marked as Temporary and hence assertion won't be triggered.

Please let me know if there is any better solution to this issue.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20151020/3073336a/attachment-0001.html>

More information about the lldb-dev mailing list