[lldb-dev] Difficulty in using target.source-map to map source files
karnajit wangkhem via lldb-dev
lldb-dev at lists.llvm.org
Mon Aug 21 12:02:44 PDT 2017
Hi All,
Below is a sample example, where target.source-map seems to have a
limitation. The limitation seems to be because
1. lldb does not have an equivalent command like directory in gdb
2. target.source-map does not accept multiple mapping entries. I checked
this only with freebsd.
(lldb) settings show target.source-map
target.source-map (path-map) =
[0] "/home/karnajitw/lldb_test_execs/test_source_line1" ->
"/u/test/test_source_line1"
3. Haven't checked in the code yet, but if we see the mappings of scenario
1, they all point to a single real path
/home/karnajitw/lldb_test_execs/test_source_line1.
But looks like the mapping logic only considers strings into account. But,
at the same time, I am not claiming that they should be interpreted as path
from a different machine during the mapping.
I want to check on this issue in-depth. But before that, want to confirm if
this is real issue or there are other ways to deal these scenarios which I
am not aware of?
I am referring below link for the lldb commands.
https://lldb.llvm.org/lldb-gdb.html
1. First scenario: Different souce file path representation
[/home/karnajitw/lldb_test_execs/test_source_line1] $ clang -O0 -g
/home/karnajitw/lldb_test_execs///test_source_line1/main.c
/home/karnajitw/lldb_test_execs/../lldb_test_execs/test_source_line1/a/ainc.c
/home/karnajitw/lldb_test_execs/test_source_line1/a/b/binc.c
Machine 1: /home/karnajitw/lldb_test_execs/test_source_line1 -> Machine 2:
/u/test/test_source_line1
test_source_line1
|-- a
| |-- ainc.c
| |-- ainc.h
| `-- b
| |-- binc.c
| `-- binc.h
|-- a.out
`-- main.c
% ./lldb test_source_line1/a.out
(lldb) target create "test_source_line1/a.out"
Current executable set to 'test_source_line1/a.out' (x86_64).
(lldb) l main
File: /home/karnajitw/lldb_test_execs///test_source_line1/main.c
(lldb) l afn
File: /home/karnajitw/lldb_test_execs/../lldb_test_execs/test_sour
ce_line1/a/ainc.c
(lldb) l bfn
File: /home/karnajitw/lldb_test_execs/test_source_line1/a/b/binc.c
(lldb) settings set target.source-map
/home/karnajitw/lldb_test_execs///test_source_line1
/u/test/test_source_line1
(lldb) l main
File: /home/karnajitw/lldb_test_execs///test_source_line1/main.c
1 #include "a/ainc.h"
2
3 int main()
4 {
5 afn();
6
7 bfn();
8
9 return 0;
10 }
(lldb) l afn
File: /home/karnajitw/lldb_test_execs/../lldb_test_execs/test_sour
ce_line1/a/ainc.c
(lldb) l bfn
File: /home/karnajitw/lldb_test_execs/test_source_line1/a/b/binc.c
(lldb) settings set target.source-map /home/karnajitw/lldb_test_exec
s/../lldb_test_execs/test_source_line1 /u/test/test_source_line1
(lldb) l main
File: /home/karnajitw/lldb_test_execs///test_source_line1/main.c
(lldb) l afn
File: /home/karnajitw/lldb_test_execs/../lldb_test_execs/test_sour
ce_line1/a/ainc.c
1 #include <stdio.h>
2 #include "ainc.h"
3
4 void afn()
5 {
6 printf("Hello this is afn...\n");
7 }
(lldb) l bfn
File: /home/karnajitw/lldb_test_execs/test_source_line1/a/b/binc.c
(lldb) settings set target.source-map
/home/karnajitw/lldb_test_execs/test_source_line1
/u/test/test_source_line1
(lldb) l main
File: /home/karnajitw/lldb_test_execs///test_source_line1/main.c
(lldb) l afn
File: /home/karnajitw/lldb_test_execs/../lldb_test_execs/test_sour
ce_line1/a/ainc.c
(lldb) l bfn
File: /home/karnajitw/lldb_test_execs/test_source_line1/a/b/binc.c
1 #include <stdio.h>
2 #include "binc.h"
3
4 void bfn()
5 {
6 printf("Hello this is bfn...\n");
7 }
2. Scenario 2: Deep directory structure
<top>/obj/a/b/c/d/e/app/sub/../../../../../../../../src/a/b/
c/d/e/app/sub/file
<top>/obj/a/b/c/d/e/app/../../../../../../../src/a/b/c/d/e/app/file
- If we carry the copy the source file to machine 2, we cannot easily map
the source file without creating dummy <top>/obj/a/b/c/d/e/f/g.
3. Scenario 3: External libraries
- I haven't exactly tested this yet. But I belive in scenario too we might
need to change the source-map.
Please look into this and guide me for the same.
Regards,
Karan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20170822/00c2e51a/attachment.html>
More information about the lldb-dev
mailing list