diff options
author | rsesek@chromium.org <rsesek@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2014-07-31 19:11:29 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2014-07-31 19:11:29 +0000 |
commit | 9c932f1d0c5667846124663e738656db73595645 (patch) | |
tree | 6208adcf0b69510c9b01bbed395b0e3013900068 /src/tools/mac/upload_system_symbols/upload_system_symbols.go | |
parent | In Mac dump_syms, allow reading debug data out of both the Mach-O file and th... (diff) | |
download | breakpad-9c932f1d0c5667846124663e738656db73595645.tar.xz |
upload_system_symbols: Use the Go1.3 improvements to debug/macho.
This removes the custom MachO header reading functionality, since the stdlib can
now read Fat files.
R=andybons@chromium.org, mark@chromium.org
Review URL: https://breakpad.appspot.com/10684002
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1360 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/tools/mac/upload_system_symbols/upload_system_symbols.go')
-rw-r--r-- | src/tools/mac/upload_system_symbols/upload_system_symbols.go | 51 |
1 files changed, 41 insertions, 10 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 869a2773..35561208 100644 --- a/src/tools/mac/upload_system_symbols/upload_system_symbols.go +++ b/src/tools/mac/upload_system_symbols/upload_system_symbols.go @@ -43,6 +43,7 @@ Both i386 and x86_64 architectures will be dumped and uploaded. package main import ( + "debug/macho" "flag" "fmt" "io" @@ -58,10 +59,11 @@ import ( ) var ( - breakpadTools = flag.String("breakpad-tools", "out/Release/", "Path to the Breakpad tools directory, containing dump_syms and symupload.") - uploadOnlyPath = flag.String("upload-from", "", "Upload a directory of symbol files that has been dumped independently.") - dumpOnlyPath = flag.String("dump-to", "", "Dump the symbols to the specified directory, but do not upload them.") - systemRoot = flag.String("system-root", "", "Path to the root of the Mac OS X system whose symbols will be dumped.") + breakpadTools = flag.String("breakpad-tools", "out/Release/", "Path to the Breakpad tools directory, containing dump_syms and symupload.") + uploadOnlyPath = flag.String("upload-from", "", "Upload a directory of symbol files that has been dumped independently.") + dumpOnlyPath = flag.String("dump-to", "", "Dump the symbols to the specified directory, but do not upload them.") + systemRoot = flag.String("system-root", "", "Path to the root of the Mac OS X system whose symbols will be dumped.") + dumpArchitecture = flag.String("arch", "", "The CPU architecture for which symbols should be dumped. If not specified, dumps all architectures.") ) var ( @@ -373,17 +375,46 @@ func (fq *findQueue) worker() { continue } - imageinfos, err := GetMachOImageInfo(fp) - if err != nil && err != ErrNotMachO { + f, err := os.Open(fp) + if err != nil { log.Printf("%s: %v", fp, err) continue } - for _, imageinfo := range imageinfos { - if imageinfo.Type == MachODylib || imageinfo.Type == MachOBundle { - - fq.dq.DumpSymbols(fp, imageinfo.Arch) + fatFile, err := macho.NewFatFile(f) + if err == nil { + // The file is fat, so dump its architectures. + for _, fatArch := range fatFile.Arches { + fq.dumpMachOFile(fp, fatArch.File) + } + fatFile.Close() + } else if err == macho.ErrNotFat { + // The file isn't fat but may still be MachO. + thinFile, err := macho.NewFile(f) + if err != nil { + log.Printf("%s: %v", fp, err) + continue } + fq.dumpMachOFile(fp, thinFile) + thinFile.Close() + } else { + f.Close() } } } + +func (fq *findQueue) dumpMachOFile(fp string, image *macho.File) { + if image.Type != MachODylib && image.Type != MachOBundle { + return + } + + arch := getArchStringFromHeader(image.FileHeader) + if arch == "" { + // Don't know about this architecture type. + return + } + + if (*dumpArchitecture != "" && *dumpArchitecture == arch) || *dumpArchitecture == "" { + fq.dq.DumpSymbols(fp, arch) + } +} |