aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonard Grey <lgrey@chromium.org>2023-05-18 14:09:08 -0400
committerLeonard Grey <lgrey@chromium.org>2023-05-18 21:12:03 +0000
commit38b6eebda19a4127299a7bf806c67868dde7fca3 (patch)
treeb2035024c98bbe2e5ad3b926dda7e451a25d6ce2
parent5850e262b1d955c99ab4c404fe357959a8a616f0 (diff)
downloadgoogle-breakpad-38b6eebda19a4127299a7bf806c67868dde7fca3.tar.gz
Mac: shorten sym file names in upload_system_symbols
macOS caps filenames at 255 characters. When upload_system_symbols runs `dump_syms`, the resulting filename is based on a mangled version of the file's full path. In some circumstances (for example, the dumped file itself lives in a temp directory), this name can exceed the max. This change replaces the current mangling by mapping each path component but the last to its first initial, greatly shortening the resulting filename. Bug: 1400770 Change-Id: I68203a98eda2912893c5d8f7c676faee17e39e91 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/4519231 Reviewed-by: Robert Sesek <rsesek@chromium.org>
-rw-r--r--src/tools/mac/upload_system_symbols/upload_system_symbols.go25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/tools/mac/upload_system_symbols/upload_system_symbols.go b/src/tools/mac/upload_system_symbols/upload_system_symbols.go
index ba067276..f34c288a 100644
--- a/src/tools/mac/upload_system_symbols/upload_system_symbols.go
+++ b/src/tools/mac/upload_system_symbols/upload_system_symbols.go
@@ -163,6 +163,29 @@ func main() {
}
}
+// manglePath reduces an absolute filesystem path to a string suitable as the
+// base for a file name which encodes some of the original path. The result
+// concatenates the leading initial from each path component except the last to
+// the last path component; for example /System/Library/Frameworks/AppKit
+// becomes SLFAppKit.
+// Assumes ASCII.
+func manglePath(path string) string {
+ components := strings.Split(path, "/")
+ n := len(components)
+ builder := strings.Builder{}
+ for i, component := range components {
+ if len(component) == 0 {
+ continue
+ }
+ if i < n-1 {
+ builder.WriteString(component[:1])
+ } else {
+ builder.WriteString(component)
+ }
+ }
+ return builder.String()
+}
+
type WorkerPool struct {
wg sync.WaitGroup
}
@@ -296,7 +319,7 @@ func (dq *DumpQueue) worker() {
dumpSyms := path.Join(*breakpadTools, "dump_syms")
for req := range dq.queue {
- filebase := path.Join(dq.dumpPath, strings.Replace(req.path, "/", "_", -1))
+ filebase := path.Join(dq.dumpPath, manglePath(req.path))
symfile := fmt.Sprintf("%s_%s.sym", filebase, req.arch)
f, err := os.Create(symfile)
if err != nil {