symbolizer: Fix symlink handling
It turns out that the symbolizer used fts_open() for a reason:
base::ListFilesRecursive doesn't handle symlinks. Turns out that
handling symlinks is non-trivial because we have to prevent infinite
loops. fts_open() does all that for us. This commit:
* Reverts a bunch of commits:
* ee90928bb222("Move GetFileSize() from symbolizer to base/file_utils.h")
* ad3da2777b62("Revert "Link against libfts when compiling against musl"")
* 2abbc726fa5a("Avoid using fts_open and fts_read")
* Cherrypicks a fix from base::ListFilesRecursive from commit
63ad74ac51b7 ("Do not use ScopedResource for FindFirstFile handle")
* Adds unittests with symlinks.
Tested by:
* Building and running unittests on windows
* Building and running unintests on Linux
* Building in CI android musl:
https://android-build.googleplex.com/builds/abtd/run/L35900000958749217
Bug: 261712935
Change-Id: Ibdf87f05394f1922430dd5513e5d53848096d7d7
diff --git a/Android.bp b/Android.bp
index 82456b8..212882f 100644
--- a/Android.bp
+++ b/Android.bp
@@ -8755,6 +8755,8 @@
srcs: [
"src/profiling/symbolizer/breakpad_parser.cc",
"src/profiling/symbolizer/breakpad_symbolizer.cc",
+ "src/profiling/symbolizer/filesystem_posix.cc",
+ "src/profiling/symbolizer/filesystem_windows.cc",
"src/profiling/symbolizer/local_symbolizer.cc",
"src/profiling/symbolizer/scoped_read_mmap_posix.cc",
"src/profiling/symbolizer/scoped_read_mmap_windows.cc",
@@ -11822,6 +11824,13 @@
"src/traced/probes/filesystem/testdata/**/*",
"src/traced/probes/ftrace/test/data/**/*",
],
+ target: {
+ musl: {
+ static_libs: [
+ "libfts",
+ ],
+ },
+ },
}
// GN: //test/vts:perfetto_vts_deps
@@ -12344,6 +12353,11 @@
],
},
},
+ musl: {
+ static_libs: [
+ "libfts",
+ ],
+ },
},
}
@@ -12528,6 +12542,13 @@
cflags: [
"-DHAVE_HIDDEN",
],
+ target: {
+ musl: {
+ static_libs: [
+ "libfts",
+ ],
+ },
+ },
}
// GN: //src/traced/service:traced