[lldb-dev] [Bug 19974] New: C: lldb cant find file:line in "included" code (set breakpoint / source list)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jun 7 10:53:49 PDT 2014


            Bug ID: 19974
           Summary: C: lldb cant find file:line in "included" code (set
                    breakpoint / source list)
           Product: lldb
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at cs.uiuc.edu
          Reporter: sford at geeky-boy.com
    Classification: Unclassified

Searched bugzilla, couldn't find.  Might be a bug in clang or llvm, but the
symptom is in lldb, so I'm putting it here.  Tool versions listed below. 

If I have a C module include additional C code using #include, I can't set
breakpoints or list source by file / line.  I can use file / line for the main
.c file which does the including, and other separately-compiled modules, but
not in the included file.


file x.c:
1  #include <stdio.h>
2  void x1();
3  int main(int argc, char **argv)
4  {
5    printf("main starts\n");
6    x1();
7    printf("main exiting\n");
8    return 0;
9  }
10 #include "x1.c"

file x1.c:
1  void x1()
2  {
3    printf("in x1\n");
4  }

Build line:
1  $ clang -g -o x x.c
2  $ clang -v
3  Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
4  Target: x86_64-apple-darwin13.2.0
5  Thread model: posix

Debug session:
1  lldb ./x
2  Current executable set to './x' (x86_64).
3  (lldb) v
4  lldb-310.2.37

5  (lldb) b x1.c:3
6  Breakpoint 1: no locations (pending).
7  WARNING:  Unable to resolve breakpoint to any actual locations.

8  (lldb) b x.c:6
9  Breakpoint 2: where = x`main + 32 at x.c:6, address = 0x0000000100000f00

10 (lldb) source list -f x.c -l 3
11   3       int main(int argc, char **argv)
12   4       {
13   5           printf("main starting\n");
14   6           x1();
15   7           printf("main exiting\n");
16   8       }
17   9       #include "x1.c"

18 (lldb) source list -f x1.c -l 1
19 error: Could not find source file "x1.c".

I also tried the full breakpoint set command with long options with no
difference.  I also tried using x.c with line numbers above 10, thinking it
might attribute the x1.c lines as additional lines in x.c.  No help.

However, I am able to set a breakpoint on the x1() function:
21 (lldb) breakpoint set -name x1
22 Breakpoint 3: where = x`x1 + 15 at x1.c:3, address = 0x0000000100000f3f
Interesting that it is able to *report* the location as "x1.c:3", but you can't
break on that specification.

Also, if I remove x.c line 10 (#include "x1.c"), add stdio.h to x1.c, compile
them separately and link them, it works OK.

P.S. - in case anybody is curious why I would include C code like that, x1.c is
unit test code that wants to do white-box testing and therefore wants access to
structure fields and static functions not available to separately-compiled
modules.  Yes, there are other ways to do it; this is the way I do it.

You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140607/9352e979/attachment.html>

More information about the lldb-dev mailing list