Missing symbols in pass stack trace

I’m working on a pass (both LLVM and the pass have been compiled in debug+asserts mode) but when the pass crashes in the stack trace printed by opt the names of the functions inside my pass don’t appear (see frames 14-16). How can I have them displayed?

I’m working on a pass (both LLVM and the pass have been compiled in debug+asserts mode) but when the pass crashes in the stack trace printed by opt the names of the functions inside my pass don’t appear (see frames 14-16). How can I have them displayed?

cafxx@ubuntu:~/Projects/llvm2/Debug+Asserts/bin$ clear && ./opt -load=CGF.so -cgf -debug test.S
[...]
While deleting: i32 %
Use still stuck around after Def is destroyed: ret i32 <badref>
opt: Value.cpp:76: virtual llvm::Value::~Value(): Assertion use_empty() && “Uses remain when a value is destroyed!”’ failed. 0 opt 0x0000000000d75265 1 opt 0x0000000000d75061 2 libpthread.so.0 0x00007f640c60bc60 3 libc.so.6 0x00007f640b8f6d05 gsignal + 53 4 libc.so.6 0x00007f640b8faab6 abort + 390 5 libc.so.6 0x00007f640b8ef7c5 __assert_fail + 245 6 opt 0x0000000000d1b287 llvm::Value::~Value() + 393 7 opt 0x0000000000c18b67 llvm::User::~User() + 99 8 opt 0x0000000000cc9ee2 llvm::Instruction::~Instruction() + 114 9 opt 0x0000000000ccbf68 llvm::CallInst::~CallInst() + 58 10 opt 0x0000000000ccbf9a llvm::CallInst::~CallInst() + 24 11 opt 0x00000000008db456 llvm::ilist_node_traitsllvm::Instruction::deleteNode(llvm::Instruction*) + 42 12 opt 0x00000000008d9ffd llvm::iplist<llvm::Instruction, llvm::ilist_traitsllvm::Instruction >::erase(llvm::ilist_iteratorllvm::Instruction) + 43 13 opt 0x0000000000cca004 llvm::Instruction::eraseFromParent() + 66 14 CGF.so 0x00007f640b6a0042 15 CGF.so 0x00007f640b69f7c3 16 CGF.so 0x00007f640b6a24fd 17 opt 0x0000000000cf75f2 llvm::MPPassManager::runOnModule(llvm::Module&) + 456 18 opt 0x0000000000cf7ae7 llvm::PassManagerImpl::run(llvm::Module&) + 125 19 opt 0x0000000000cf7ef5 llvm::PassManager::run(llvm::Module&) + 39 20 opt 0x00000000008b33e3 main + 4434 21 libc.so.6 0x00007f640b8e1eff __libc_start_main + 255 22 opt 0x00000000008a3ec9 Stack dump: 0. Program arguments: ./opt -load=CGF.so -cgf -debug test.S 1. Running pass ‘CGF’ on module ‘test.S’.`

Looks like your shared library is not being compiled with symbols. Did you verify that your sources are compiled with -g?

<cafxx.vcf>_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Thanks,

Justin Holewinski

Looks like your shared library is not being compiled with symbols. Did you verify that your sources are compiled with -g?

I think so, this is the makefile (based on the one in the Hello pass):

LEVEL = ../../..
LIBRARYNAME = CGF
LOADABLE_MODULE = 1
USEDLIBS =

ifneq ($(REQUIRES_RTTI), 1)
ifneq ($(REQUIRES_EH), 1)
EXPORTED_SYMBOL_FILE = $(PROJ_SRC_DIR)/CGF.exports
endif
endif

include $(LEVEL)/Makefile.common

and this is the invocation:

Looks like your shared library is not being compiled with symbols. Did you verify that your sources are compiled with -g?

I think so, this is the makefile (based on the one in the Hello pass):

LEVEL = ../../..
LIBRARYNAME = CGF
LOADABLE_MODULE = 1
USEDLIBS =

ifneq ($(REQUIRES_RTTI), 1)
ifneq ($(REQUIRES_EH), 1)
EXPORTED_SYMBOL_FILE = $(PROJ_SRC_DIR)/CGF.exports
endif
endif

include $(LEVEL)/Makefile.common

and this is the invocation:

cafxx@ubuntu:~/Projects/llvm2/lib/Transforms/cgf$ make
llvm[0]: Compiling CGFPass.cpp for Debug+Asserts build (PIC)
llvm[0]: Linking Debug+Asserts Loadable Module CGF.so

Try building with “make VERBOSE=1”, which will show you the command-lines passed to the compiler/linker. Post the output here.

Thanks,

Justin Holewinski

Try building with “make VERBOSE=1”, which will show you the command-lines passed to the compiler/linker. Post the output here.

there you go:

Try building with “make VERBOSE=1”, which will show you the command-lines passed to the compiler/linker. Post the output here.

there you go:

cafxx@ubuntu:~/Projects/llvm2/lib/Transforms/cgf$ make VERBOSE=1
llvm[0]: Compiling CGFPass.cpp for Debug+Asserts build (PIC)
if g++ -I/home/cafxx/Projects/llvm2/include -I/home/cafxx/Projects/llvm2/lib/Transforms/cgf -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -g -fno-exceptions -fno-rtti -fPIC -Woverloaded-virtual -Wcast-qual -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -c -MMD -MP -MF "/home/cafxx/Projects/llvm2/lib/Transforms/cgf/Debug+Asserts/CGFPass.d.tmp" -MT "/home/cafxx/Projects/llvm2/lib/Transforms/cgf/Debug+Asserts/CGFPass.o" -MT "/home/cafxx/Projects/llvm2/lib/Transforms/cgf/Debug+Asserts/CGFPass.d" CGFPass.cpp -o /home/cafxx/Projects/llvm2/lib/Transforms/cgf/Debug+Asserts/CGFPass.o ; \
then /bin/mv -f "/home/cafxx/Projects/llvm2/lib/Transforms/cgf/Debug+Asserts/CGFPass.d.tmp" "/home/cafxx/Projects/llvm2/lib/Transforms/cgf/Debug+Asserts/CGFPass.d"; else /bin/rm "/home/cafxx/Projects/llvm2/lib/Transforms/cgf/Debug+Asserts/CGFPass.d.tmp"; exit 1; fi
llvm[0]: Linking Debug+Asserts Loadable Module CGF.so
g++ -I/home/cafxx/Projects/llvm2/include -I/home/cafxx/Projects/llvm2/lib/Transforms/cgf -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -g -fno-exceptions -fno-rtti -fPIC -Woverloaded-virtual -Wcast-qual -g -Wl,-R -Wl,'$ORIGIN' -L/home/cafxx/Projects/llvm2/Debug+Asserts/lib -L/home/cafxx/Projects/llvm2/Debug+Asserts/lib -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -shared -o /home/cafxx/Projects/llvm2/Debug+Asserts/lib/CGF.so /home/cafxx/Projects/llvm2/lib/Transforms/cgf/Debug+Asserts/CGFPass.o \
-Wl,--version-script,/home/cafxx/Projects/llvm2/lib/Transforms/cgf/Debug+Asserts/CGF.exports.map -lpthread -ldl -lm

Are you loading the shared library directly from the build directory, or are you installing it first? If you run “file CGF.so” on the file you actually load, does it say it is stripped or non-stripped?

<cafxx.vcf>_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Thanks,

Justin Holewinski

Are you loading the shared library directly from the build directory, or are you installing it first?

I’m invoking it directly, I guess: ./opt -load=CGF.so -cgf -debug test.S
should I install it? (I have no idea about how to do it, though…)

If you run “file CGF.so” on the file you actually load, does it say it is stripped or non-stripped?

cafxx@ubuntu:~/Projects/llvm2/Debug+Asserts/bin$ file ../lib/CGF.so
../lib/CGF.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped

Are you loading the shared library directly from the build directory, or are you installing it first?

I’m invoking it directly, I guess: ./opt -load=CGF.so -cgf -debug test.S
should I install it? (I have no idea about how to do it, though…)

If you run “file CGF.so” on the file you actually load, does it say it is stripped or non-stripped?

cafxx@ubuntu:~/Projects/llvm2/Debug+Asserts/bin$ file ../lib/CGF.so
../lib/CGF.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped

That’s a weird one. Does addr2line work?

$ addr2line -e CGF.so

<cafxx.vcf>_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Thanks,

Justin Holewinski

That’s a weird one. Does addr2line work?
$ addr2line -e CGF.so

cafxx@ubuntu:~/Projects/llvm2/Debug+Asserts/bin$ objdump -t ../lib/CGF.so | grep flatten
0000000000005622 l F .text 0000000000000aa6 _ZN12_GLOBAL__N_111CGFFunction7flattenEv
00000000000041d6 l F .text 000000000000049c _ZN12_GLOBAL__N_111CGFCallSite7flattenEv
000000000001a600 l O .rodata 0000000000000026 _ZZN12_GLOBAL__N_111CGFCallSite7flattenEvE19__PRETTY_FUNCTION__
0000000000019920 l O .rodata 0000000000000026 _ZZN12_GLOBAL__N_111CGFFunction7flattenEvE19__PRETTY_FUNCTION__
cafxx@ubuntu:~/Projects/llvm2/Debug+Asserts/bin$ addr2line -e ../lib/CGF.so 5622
/home/cafxx/Projects/llvm2/lib/Transforms/cgf/CGFFunction.cppi:27

the file name and line are correct…

That’s a weird one. Does addr2line work?
$ addr2line -e CGF.so

cafxx@ubuntu:~/Projects/llvm2/Debug+Asserts/bin$ objdump -t ../lib/CGF.so | grep flatten
0000000000005622 l F .text 0000000000000aa6 _ZN12_GLOBAL__N_111CGFFunction7flattenEv
00000000000041d6 l F .text 000000000000049c _ZN12_GLOBAL__N_111CGFCallSite7flattenEv
000000000001a600 l O .rodata 0000000000000026 _ZZN12_GLOBAL__N_111CGFCallSite7flattenEvE19__PRETTY_FUNCTION__
0000000000019920 l O .rodata 0000000000000026 _ZZN12_GLOBAL__N_111CGFFunction7flattenEvE19__PRETTY_FUNCTION__
cafxx@ubuntu:~/Projects/llvm2/Debug+Asserts/bin$ addr2line -e ../lib/CGF.so 5622
/home/cafxx/Projects/llvm2/lib/Transforms/cgf/CGFFunction.cppi:27

the file name and line are correct…

I meant on the stack trace, for your initial trace:

$ addr2line -e CGF.so 0x00007f640b6a24fd

<cafxx.vcf>_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Thanks,

Justin Holewinski

I meant on the stack trace, for your initial trace:

$ addr2line -e CGF.so 0x00007f640b6a24fd

It doesn’t work (it prints ??:0) I guess because it’s PIC code (in the address above the blue part changes at each invocation of opt)

Seems to be some issue with gdb not being able to read all of the debug symbols. I’m not sure what else to try.

<cafxx.vcf>

Thanks,

Justin Holewinski

I meant on the stack trace, for your initial trace:

$ addr2line -e CGF.so 0x00007f640b6a24fd

It doesn’t work (it prints ??:0) I guess because it’s PIC code (in the address above the blue part changes at each invocation of opt)

Anybody else has any suggestions?
Basically the problem is: how can I make stack traces in opt to show the symbols (function/line) of my modulepass (loadable module, PIC, based on the hello pass)?