3

Let's say I have a .c file on my Macbook ~/github/leetcode/c/src/hello.c.

After compile with cc -g command, I have a binary file at ~/github/leetcode/c/bin/hello.o

Now I want to use LLDB to debug,

lldb ~/github/leetcode/c/bin/hello.o

it works,

(lldb) target create "/Users/Wei/github/leetcode/c/bin/DifferentWaysToAddParentheses.o"
Current executable set to '/Users/Wei/github/leetcode/c/bin/DifferentWaysToAddParentheses.o' (x86_64).

but when I try to add a break point,

breakpoint set --file "~/github/leetcode/c/src/DifferentWaysToAddParentheses.c" --line 10

it seems that the .c file can not be found,

Breakpoint 1: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.

but, when I simply use the file name without the path,

breakpoint set --file DifferentWaysToAddParentheses.c --line 10

now it works,

Breakpoint 2: where = DifferentWaysToAddParentheses.o`main + 44 at DifferentWaysToAddParentheses.c:10, address = 0x0000000100000dec

It really confused me! Why LLDB can not work with the path? The second question is, how can LLDB find the file without the path? Thx!

shen
  • 933
  • 10
  • 19
  • 1
    take a look here. Maybe this is what you are looking for? https://stackoverflow.com/questions/12973633/lldb-equivalent-of-gdb-directory-command-for-specifying-source-search-path – Oo.oO Jul 11 '17 at 03:53
  • seems you have the point. thx @mko XD – shen Jul 11 '17 at 04:03
  • 1
    `~` is a shell function. LLDB is presumably using direct OS calls to open files, so in your case absolute path would be `/Users/Wei/github/leetcode/c/src/DifferentWaysToAddParentheses.c`. – tgregory Jul 11 '17 at 08:35
  • thx @tgregory . – shen Jul 11 '17 at 14:04

0 Answers0