[cfe-dev] Debugging Clang with LLDB
Adrian Prantl via cfe-dev
cfe-dev at lists.llvm.org
Mon Mar 25 12:56:20 PDT 2019
> On Mar 25, 2019, at 6:08 AM, Jan Svoboda via cfe-dev <cfe-dev at lists.llvm.org> wrote:
>
> Hi,
> I'm trying to use LLDB to debug Clang built with the LLVM toolchain.
>
> However, whenever I try to evaluate a method call in the debugger,
> I get the following error instead of the actual result:
>
> error: Execution was interrupted,
> reason: signal SIGSEGV: invalid address (fault address: 0x0).
>
> (See the full output below.)
>
> What am I doing wrong? GDB works fine in this scenario. LLDB works
> fine with other projects I have on hand. Any help appreciated.
>
> Thanks,
> Jan
>
> --
>
> $ lldb-8 ./llvm-project/build/bin/clang
> (lldb) target create "./llvm-project/build/bin/clang"
> Current executable set to './llvm-project/build/bin/clang' (x86_64).
> (lldb) b main
> Breakpoint 1: where = clang`main + 25 at driver.cpp:322:18, address = 0x00000000043142d9
> (lldb) r
> Process 4920 launched: '/home/jan/Code/llvm-project/build/bin/clang' (x86_64)
> Process 4920 stopped
> * thread #1, name = 'clang', stop reason = breakpoint 1.1
> frame #0: 0x00000000043142d9 clang`main(argc_=1, argv_=0x00007fffffffdf28) at driver.cpp:322:18
> 319 }
> 320
> 321 int main(int argc_, const char **argv_) {
> -> 322 llvm::InitLLVM X(argc_, argv_);
> 323 SmallVector<const char *, 256> argv(argv_, argv_ + argc_);
> 324
> 325 if (llvm::sys::Process::FixupStandardFileDescriptors())
> (lldb) n
> Process 4920 stopped
> * thread #1, name = 'clang', stop reason = step over
> frame #0: 0x00000000043142ed clang`main(argc_=1, argv_=0x00007fffffffdf28) at driver.cpp:323:39
> 320
> 321 int main(int argc_, const char **argv_) {
> 322 llvm::InitLLVM X(argc_, argv_);
> -> 323 SmallVector<const char *, 256> argv(argv_, argv_ + argc_);
> 324
> 325 if (llvm::sys::Process::FixupStandardFileDescriptors())
> 326 return 1;
> (lldb) n
> Process 4920 stopped
> * thread #1, name = 'clang', stop reason = step over
> frame #0: 0x000000000431430c clang`main(argc_=1, argv_=0x00007fffffffdf28) at driver.cpp:325:7
> 322 llvm::InitLLVM X(argc_, argv_);
> 323 SmallVector<const char *, 256> argv(argv_, argv_ + argc_);
> 324
> -> 325 if (llvm::sys::Process::FixupStandardFileDescriptors())
> 326 return 1;
> 327
> 328 llvm::InitializeAllTargets();
> (lldb) e argv
> (llvm::SmallVector<const char *, 256>) $0 = {
> llvm::SmallVectorImpl<const char *> = {
> llvm::SmallVectorTemplateBase<const char *, true> = {
> llvm::SmallVectorTemplateCommon<const char *> = {
> llvm::SmallVectorBase = (BeginX = 0x00007fffffffd598, Size = 1, Capacity = 256)
> }
> }
> }
> llvm::SmallVectorStorage<const char *, 256> = {
> InlineElts = {
> ... // actual elements here
> }
> }
> }
> (lldb) e argv.size()
> error: Execution was interrupted, reason: signal SIGSEGV: invalid address (fault address: 0x0).
> The process has been returned to the state before expression evaluation.
> (lldb)
This error message indicates that the expression you compiled "argv.size()" crashed with a SIGSEV. If this is unoptimized code this looks like it could be a bug in LLDB. What OS are you using and what compiler did you compile clang with?
-- adrian
More information about the cfe-dev
mailing list