[Bug 25133] New: log enable --stack isn't getting function or line info in liblldb.so on Ubuntu 14.04

Bug ID 25133
Summary log enable --stack isn’t getting function or line info in liblldb.so on Ubuntu 14.04
Product lldb
Version unspecified
Hardware PC
OS Linux
Status NEW
Severity normal
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter todd.fiala@gmail.com
CC llvm-bugs@lists.llvm.org
Classification Unclassified

With a cmake/ninja build configured like so:

    CC=/usr/bin/clang-3.6 CXX=/usr/bin/clang++-3.6 \
    cmake \
        -GNinja \
        -DCMAKE_BUILD_TYPE=Debug \
        -DCMAKE_EXE_LINKER_FLAGS:STRING=-fuse-ld=gold \
        -DCMAKE_SHARED_LINKER_FLAGS:STRING=-fuse-ld=gold \
        -Wno-dev \
        $SOURCE_DIR

Using the following:
$ lldb
(lldb)  log enable --stack lldb process
 log enable --stack lldb process
(lldb) log enable --stack lldb target
log enable --stack lldb target
(lldb) target create /bin/ls
target create /bin/ls
Target::Target created with architecture x86_64 (x86_64-unknown-linux)
0  liblldb.so.3.8 0x00007fbae0047eae
1  liblldb.so.3.8 0x00007fbae014fe66
2  liblldb.so.3.8 0x00007fbae0155879
3  liblldb.so.3.8 0x00007fbae03aa025
4  liblldb.so.3.8 0x00007fbae03c1285
5  liblldb.so.3.8 0x00007fbae03c09cc
6  liblldb.so.3.8 0x00007fbae03bfa7b
7  liblldb.so.3.8 0x00007fbae0750b52
8  liblldb.so.3.8 0x00007fbae0231fe6
9  liblldb.so.3.8 0x00007fbae0222e90
10 liblldb.so.3.8 0x00007fbae02268f9
11 liblldb.so.3.8 0x00007fbae0226e77
12 liblldb.so.3.8 0x00007fbae012ea7d
13 liblldb.so.3.8 0x00007fbae0104657
14 liblldb.so.3.8 0x00007fbae02276b7
15 liblldb.so.3.8 0x00007fbade7dc7e1
lldb::SBDebugger::RunCommandInterpreter(bool, bool) + 129
16 lldb           0x0000000000406208
17 lldb           0x0000000000406774
18 libc.so.6      0x00007fbadcd10ec5 __libc_start_main + 245
19 lldb           0x0000000000403069
Target::Target created with architecture x86_64 (x86_64--linux-gnu)
0  liblldb.so.3.8 0x00007fbae0047eae
1  liblldb.so.3.8 0x00007fbae014fe66
2  liblldb.so.3.8 0x00007fbae0155879
3  liblldb.so.3.8 0x00007fbae03aa025
4  liblldb.so.3.8 0x00007fbae03c1379
5  liblldb.so.3.8 0x00007fbae03c09cc
6  liblldb.so.3.8 0x00007fbae03c1788
7  liblldb.so.3.8 0x00007fbae03c16d9
8  liblldb.so.3.8 0x00007fbae0106aa1
9  liblldb.so.3.8 0x00007fbae03c154d
10 liblldb.so.3.8 0x00007fbae03c09cc
11 liblldb.so.3.8 0x00007fbae03bfa7b
12 liblldb.so.3.8 0x00007fbae0750b52
13 liblldb.so.3.8 0x00007fbae0231fe6
14 liblldb.so.3.8 0x00007fbae0222e90
15 liblldb.so.3.8 0x00007fbae02268f9
16 liblldb.so.3.8 0x00007fbae0226e77
17 liblldb.so.3.8 0x00007fbae012ea7d
18 liblldb.so.3.8 0x00007fbae0104657
19 liblldb.so.3.8 0x00007fbae02276b7
20 liblldb.so.3.8 0x00007fbade7dc7e1
lldb::SBDebugger::RunCommandInterpreter(bool, bool) + 129
21 lldb           0x0000000000406208
22 lldb           0x0000000000406774
23 libc.so.6      0x00007fbadcd10ec5 __libc_start_main + 245
24 lldb           0x0000000000403069
Current executable set to '/bin/ls' (x86_64).
(lldb)

we are not getting any file/function/line number info for the vast majority of
the backtrace.  This is with a Debug-style cmake build using clang-3.6.  We
should have all the debuginfo we need here.

I'm going to try with other compilers to see if this situation changes.

Todd Fiala changed bug 25133

What | Removed | Added |

Comment # 3 on bug 25133 from Todd Fiala

Playing with the llvm_add_symbol_exports did not yield anything interesting for
me.  It requires generating export statements for everything to be publicly
exported.

What I *did* find that worked was the following:

Step #1: remove the step that sets up an explicit exports in the
source/API/CMakeLists.txt file for cmake.  (i.e. *don't* do the
llvm_add_symbol_exports.  It looks like the second that is called for the SB
API, then nothing else gets out, even with step 2 below).

Step #2: pass the following linker flag to cmake:
-DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=gold -Wl,-E"

My full build line was:
CC=/usr/bin/clang-3.6 CXX=/usr/bin/clang++-3.6 cmake -GNinja
-DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=gold -Wl,-E"
-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=gold -DCMAKE_BUILD_TYPE=Debug ../llvm 2>&1 |
tee ~/logs/cmake-symbols.log

This got my --stack line to show useful info.

I'll add a cmake flag that lets us essentially say "skip explicit liblldb
exports".  Specifying that, along with whatever linker flags are needed to say
"export everything", takes care of this.

I'll get something up for review on that tomorrow morning.