Friday, July 19, 2013

LLDB Project Notes

This has been moved to:

# Useful links

Subversion Commit Access:

lldb build page:

lldb Linux buglist:

lldb-dev archives:
lldb-commits archives:

LLDB Reference Documentation:
GDB commands in LLDB:

Code reviews with Phabricator:
 - This phabricator thing produces easy to read diffs so I can submit patches like this:
 - "arc diff" and "arc submit" are the two main commands.
   Warning: they can be a bit of a pain when working with multiple patches.

Rad's working lldb branch:
 - has a couple fixes not merged into lldb svn branch yet (largest is libedit 3.1).

Rad's bugs/work list:

I've set up two lldb enlistments:
 - Our working mercurial branch: ~/data/src/lldb.hg
     (tools/lldb is from our Mercurial branch)
 - Official Subversion branch: ~/data/src/lldb.svn
     (tools/lldb is from lld Subversion branch)

Each branch looks like this on my machine:

  `-- build
      `-- tools
          +-- clang
          `-- lldb

I test individual patches, submit, test official tree from lldb.svn, and work out of lldb.hg.

# Tools

cmake version
ninja 1.3.3
Mercurial Distributed SCM (version 2.6)
svn, version 1.7.9 (r1462340), compiled Apr 6 2013, 21:23:46
Clang 3.3 (

# Other useful tools:
TortoiseHg Dialogs (version 2.8), Mercurial (version 2.6)
meld 1.7.3
CGDB 20130523 (cgdb built from
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04

# internal patch to get lldb build warnings down (until these can be fixed).

Index: ../../cmake/modules/HandleLLVMOptions.cmake
--- ../../cmake/modules/HandleLLVMOptions.cmake (revision 186469)
+++ ../../cmake/modules/HandleLLVMOptions.cmake (working copy)
@@ -206,6 +206,12 @@
     append("-Wall -W -Wno-unused-parameter -Wwrite-strings" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)

+       # option(RAD_EXTRA_CFLAGS "View the TERM environment var" OFF)
+        message(RAD_EXTRA_CFLAGS " environment variable is ${RAD_EXTRA_CFLAGS}")
+    endif(RAD_EXTRA_CFLAGS)
     # Turn off missing field initializer warnings for gcc to avoid noise from
     # false positives with empty {}. Turn them on otherwise (they're off by
     # default for clang).

# My bash aliases for working with lldb project
# Can run following from lldb build directories:
#   ninja lldb
#   ninja check-lldb
# To run individual tests, something like this from lldb/test directory:
#   ./ -C clang -v -t -f PlatformCommandTestCase.test_process_list

# cd lldb_src_hg, etc. will work if "shopt -s cdable_vars" is set.
export lldb_src_hg=~/data/src/llvm.hg/llvm/tools/lldb
export lldb_src_svn=~/data/src/llvm.svn/llvm/tools/lldb
export lldb_build_hg=~/data/src/llvm.hg/build
export lldb_build_svn=~/data/src/llvm.svn/build

path_append ()  { path_remove $1; export PATH="$PATH:$1"; }
path_prepend () { path_remove $1; export PATH="$1:$PATH"; }
path_remove ()  { export PATH=`echo -n $PATH | awk -v RS=: -v ORS=: '$0 != "'$1'"' | sed 's/:$//'`; }

    path_remove "/home/mikesart/data/src/llvm.hg/build/bin"
    path_prepend "/home/mikesart/data/src/llvm.svn/build/bin"
    path_remove "/home/mikesart/data/src/llvm.svn/build/bin"
    path_prepend "/home/mikesart/data/src/llvm.hg/build/bin"
    # run from lldb build directory to create ninja build files
    CC=clang cmake -DRAD_EXTRA_CFLAGS="-Wno-c99-extensions -Wno-sign-compare -Wno-four-char-constants -Wno-extended-offsetof -Wno-unused-function" -DCMAKE_CXX_FLAGS="-fcolor-diagnostics" -DCMAKE_BUILD_TYPE=Debug -C ../llvm -G Ninja

# Faster debugging with gdb...

Gdb with lldb is super slow loading the symbols. Connecting can take ~15 seconds. I run this alias after building (takes about 19 seconds) and loading symbols with gdb drops to less than 1 second.

mikesart@mikesart-rad:~/data/src/llvm.hg/llvm/tools/lldb/test$ type lldb_gdb_add_index
lldb_gdb_add_index is a function
lldb_gdb_add_index ()
    echo gdb-add-index $(readlink -f $(dirname $(which lldb))/../lib/;
    time gdb-add-index $(readlink -f $(dirname $(which lldb))/../lib/

mikesart@mikesart-rad:~/data/src/llvm.hg/llvm/tools/lldb/test$ cat ~/bin/gdb-add-index
#! /bin/sh

# Add a .gdb_index section to a file.

# Copyright (C) 2010 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <>.


# We don't care if gdb gives an error.
/home/mikesart/data/src/gdb-7.6/gdb/gdb --data-directory=/home/mikesart/data/src/gdb-7.6/gdb/data-directory -nx --batch-silent -ex "file $file" -ex "save gdb-index $dir"

if test -f "${file}.gdb-index"; then
   objcopy --add-section .gdb_index="${file}.gdb-index" --set-section-flags .gdb_index=readonly "$file" "$file"
   rm -f "${file}.gdb-index"

exit 0

No comments:

Post a Comment