Hi,

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"
"{\n"
"    unsigned char $__lldb_local_val = *$__lldb_arg_ptr;\n"
"}";
----------------------------------------------------------------------

becomes

--------------------------------------------------------------------
static const char g_valid_pointer_check_text[] =
"void\n"
"$__lldb_valid_pointer_check (unsigned char *$__lldb_arg_ptr)\n"
"{\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.

Regards,
Bhushan
_______________________________________________
lldb-dev mailing list
lldb-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev

Reply via email to