[lldb-dev] [Bug 34341] New: Fix lldb to use path normalization for these listed scenarios
via lldb-dev
lldb-dev at lists.llvm.org
Mon Aug 28 01:15:06 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=34341
Bug ID: 34341
Summary: Fix lldb to use path normalization for these listed
scenarios
Product: lldb
Version: unspecified
Hardware: PC
OS: FreeBSD
Status: NEW
Severity: enhancement
Priority: P
Component: All Bugs
Assignee: lldb-dev at lists.llvm.org
Reporter: karnajitw at gmail.com
CC: llvm-bugs at lists.llvm.org
Raising this PR based on the following discussion
http://lists.llvm.org/pipermail/lldb-dev/2017-August/012665.html
This issue is seen in 2 scenarios:
Scenario 1: Different source 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
(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_source_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/../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_source_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_source_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 }
* We require all these 3 source mappings to list main, afn & bfn together. But
the LHS and RHS actually points to the same path. So this sould have required
only single mapping.
(lldb)
target.source-map (path-map) =
[0] "/home/karnajitw/lldb_test_execs///test_source_line1" ->
"/u/test/test_source_line1"
[1] "/home/karnajitw/lldb_test_execs/../lldb_test_execs/test_source_line1" ->
"/u/test/test_source_line1"
[2] "/home/karnajitw/lldb_test_execs/test_source_line1" ->
"/u/test/test_source_line1"
Scenario 2: Deep directory structure
$ build/bin/lldb a.out
(lldb) target create "a.out"
Current executable set to 'a.out' (x86_64).
(lldb) settings set target.source-map
/home/karnajitw/lldbtest/obj/a/b/c/d/e/app/../../../../../../../src/a/b/c/d/e/app
/home/karnajitw/app
(lldb) l main
File:
/home/karnajitw/lldbtest/obj/a/b/c/d/e/app/../../../../../../../src/a/b/c/d/e/app/main.c
1 #include "sub/subfile.h"
2
3 int main()
4 {
5 subfn();
6
7 return 0;
8 }
9
(lldb) l subfn
File:
/home/karnajitw/lldbtest/obj/a/b/c/d/e/app/sub/../../../../../../../../src/a/b/c/d/e/app/sub/subfile.c
(lldb) settings append target.source-map
/home/karnajitw/lldbtest/obj/a/b/c/d/e/app/sub/../../../../../../../../src/a/b/c/d/e/app
/home/karnajitw/app
(lldb) l subfn
File:
/home/karnajitw/lldbtest/obj/a/b/c/d/e/app/sub/../../../../../../../../src/a/b/c/d/e/app/sub/subfile.c
1 #include <stdio.h>
2 #include "subfile.h"
3
4 void subfn()
5 {
6 printf("This is subfn...\n");
7 }
8
* Similarly, this requires 2 source mappings to list both main and subfn.
(lldb) settings show target.source-map
target.source-map (path-map) =
[0]
"/home/karnajitw/lldbtest/obj/a/b/c/d/e/app/../../../../../../../src/a/b/c/d/e/app"
-> "/home/karnajitw/app"
[1]
"/home/karnajitw/lldbtest/obj/a/b/c/d/e/app/sub/../../../../../../../../src/a/b/c/d/e/app"
-> "/home/karnajitw/app"
* Jim has already given the hint to solve this issue
"There's a method in FileSpec (GetNormalizedPath) that canonicalizes paths by
doing the obvious text substitution (unwinding ..'s and removing /./ and /// ->
/, etc.) Somewhere in the comparison of the source and build paths we aren't
using this when we should do. There's also a FileSpec::Equal method that
allows a canonicalized comparison. It might be that there's just some obvious
place we should have been using that."
--
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/20170828/02e3e45c/attachment.html>
More information about the lldb-dev
mailing list