Greg Clayton | 546a056 | 2013-06-18 01:01:31 +0000 | [diff] [blame] | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
| 2 | <html xmlns="http://www.w3.org/1999/xhtml">
|
| 3 | <head>
|
| 4 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
| 5 | <link href="style.css" rel="stylesheet" type="text/css" />
|
| 6 | <title>LLDB FAQ</title>
|
| 7 | </head>
|
| 8 |
|
| 9 | <body>
|
| 10 | <div class="www_title">
|
| 11 | Troubleshooting <strong>LLDB</strong>
|
| 12 | </div>
|
| 13 |
|
| 14 | <div id="container">
|
| 15 | <div id="content">
|
| 16 | <!--#include virtual="sidebar.incl"-->
|
| 17 | <div class="postfooter"></div>
|
| 18 | <div id="middle">
|
| 19 | <div class="post">
|
| 20 | <h1 class ="postheader">File and line breakpoints are not getting hit</h1>
|
| 21 | <div class="postcontent">
|
| 22 | <p>First you must make sure that your source files were compiled with
|
| 23 | debug information. Typically this means passing <code>-g</code> to the
|
| 24 | compiler when compiling your source file.
|
| 25 | </p>
|
| 26 | <p>When setting breakpoints in <b>implementation</b> source files
|
| 27 | (.c, cpp, cxx, .m, .mm, etc), LLDB by default will only search for compile units whose filename matches. If your
|
| 28 | code does tricky things like using <font color=purple>#include</font> to include source files:
|
| 29 | <code><pre><tt>% <b>cat foo.c</b>
|
| 30 | <font color=purple>#include</font> "bar.c"
|
| 31 | <font color=purple>#include</font> "baz.c"
|
| 32 | ...
|
| 33 | </tt></pre></code>
|
| 34 | <p> This will cause breakpoints in "bar.c" to be inlined into the compile unit for "foo.c".
|
| 35 | If your code does this, or if your build system combines multiple files in some way such
|
| 36 | that breakpoints from one implementation file will be compiled into another implementation file,
|
| 37 | you will need to tell LLDB to always search for inlined breakpoint locations
|
| 38 | by adding the following line to your <code>~/.lldbinit</code> file:
|
| 39 | </p>
|
| 40 | <code><pre><tt>% <b>echo "settings set target.inline-breakpoint-strategy always" >> ~/.lldbinit</b></tt></pre></code>
|
| 41 | <p> This tells LLDB to always look in all compile units and search for breakpoint
|
| 42 | locations by file and line even if the implementation file doesn't match. Settings breakpoints
|
| 43 | in header files always searches all compile units because inline functions are commonly defined
|
| 44 | in header files and often cause multiple breakpoints to have source line information that matches
|
| 45 | the header files paths.
|
| 46 | </p>
|
| 47 | <p> If you set a file and line breakpoint using a full path to the source file, like Xcode does when setting a
|
Jason Molenda | 3407e76 | 2013-07-16 21:11:29 +0000 | [diff] [blame] | 48 | breakpoint in its GUI on Mac OS X when you click in the gutter of the source view, this path must match
|
Greg Clayton | 546a056 | 2013-06-18 01:01:31 +0000 | [diff] [blame] | 49 | the full paths in the debug information. If the paths mismatch, possibly due to
|
| 50 | passing in a resolved source file path that doesn't match an unresolved path in the debug
|
| 51 | information, this can cause breakpoints to not be resolved. Try setting breakpoints using the file
|
Jason Molenda | 3407e76 | 2013-07-16 21:11:29 +0000 | [diff] [blame] | 52 | basename only.
|
Greg Clayton | 546a056 | 2013-06-18 01:01:31 +0000 | [diff] [blame] | 53 | <p> If you are using an IDE and you move your project in your file system and build again, sometimes doing a
|
| 54 | clean then build will solve the issue.This will fix the issue if some .o files didn't get rebuilt
|
| 55 | after the move as the .o files in the build folder might still contain stale debug information with
|
| 56 | the old source locations.
|
| 57 | </p>
|
| 58 | </div>
|
| 59 | <div class="postfooter"></div>
|
| 60 | </div>
|
| 61 | </div>
|
| 62 | <div class="postfooter"></div>
|
| 63 | <div id="middle">
|
| 64 | <div class="post">
|
| 65 | <h1 class ="postheader">How do I check if I have debug symbols?</h1>
|
| 66 | <div class="postcontent">
|
| 67 | <p> Checking if a module has any compile units (source files) is a good way to check
|
| 68 | if there is debug information in a module:
|
| 69 | <code><pre><tt>
|
| 70 | (lldb) <b>file /tmp/a.out</b>
|
| 71 | (lldb) <b>image list</b>
|
| 72 | [ 0] 71E5A649-8FEF-3887-9CED-D3EF8FC2FD6E 0x0000000100000000 /tmp/a.out
|
| 73 | /tmp/a.out.dSYM/Contents/Resources/DWARF/a.out
|
| 74 | [ 1] 6900F2BA-DB48-3B78-B668-58FC0CF6BCB8 0x00007fff5fc00000 /usr/lib/dyld
|
| 75 | ....
|
| 76 | (lldb) <b>script lldb.target.module['/tmp/a.out'].GetNumCompileUnits()</b>
|
| 77 | 1
|
| 78 | (lldb) <b>script lldb.target.module['/usr/lib/dyld'].GetNumCompileUnits()</b>
|
| 79 | 0
|
| 80 | </tt></pre></code>
|
| 81 | <p> Above we can see that "/tmp/a.out" does have a compile unit, and "/usr/lib/dyld" does not.
|
| 82 | </div>
|
| 83 | <div class="postfooter"></div>
|
| 84 | </div>
|
| 85 | </div>
|
| 86 | </div>
|
| 87 | </div>
|
| 88 | </body>
|
Jason Molenda | 3407e76 | 2013-07-16 21:11:29 +0000 | [diff] [blame] | 89 | </html>
|