aboutsummaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorTed Mielczarek <ted@mielczarek.org>2015-09-16 06:46:55 -0400
committerTed Mielczarek <ted@mielczarek.org>2015-09-16 06:46:55 -0400
commit8079ae192d6465c2fa0f1241f9a0436932509ed6 (patch)
tree10877e4154da99087e8bc6f8b2c8ba7eefbfcbd5 /src/tools
parentUpdate gitignore to ignore more GYP things (diff)
downloadbreakpad-8079ae192d6465c2fa0f1241f9a0436932509ed6.tar.xz
Fix Mac Breakpad host tools to build in Linux cross-compile
We're working on building our Firefox Mac builds as a Linux cross-compile (https://bugzilla.mozilla.org/show_bug.cgi?id=921040) and we need symbol dumping to work. This change ports the Mac dump_syms tool to build and work on Linux. I've tested it and it produces identical output to running the tool on Mac. The bulk of the work here was converting src/common/mac/dump_syms.mm and src/tools/mac/dump_syms/dump_syms_tool.mm from ObjC++ to C++ and removing their use of Foundation classes in favor of standard C/C++. This won't compile out-of-the-box on Linux, it requires some Mac system headers that are not included in this patch. I have those tentatively in a separate patch to land in Gecko (http://hg.mozilla.org/users/tmielczarek_mozilla.com/mc/rev/5fb8da23c83c), but I wasn't sure if you'd be interested in having them in the Breakpad tree. We could almost certainly pare down the set of headers included there, I didn't spend too much time trying to minimize them (we primarily just need the Mach-O structs and a few associated bits). I just realized that this patch is missing updating the XCode project files (ugh). I'll fix that up in a bit. R=mark@chromium.org BUG=https://bugzilla.mozilla.org/show_bug.cgi?id=543111 Review URL: https://codereview.chromium.org/1340543002 .
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/mac/dump_syms/dump_syms.xcodeproj/project.pbxproj16
-rw-r--r--src/tools/mac/dump_syms/dump_syms_tool.cc (renamed from src/tools/mac/dump_syms/dump_syms_tool.mm)26
-rw-r--r--src/tools/mac/tools_mac.gypi2
3 files changed, 21 insertions, 23 deletions
diff --git a/src/tools/mac/dump_syms/dump_syms.xcodeproj/project.pbxproj b/src/tools/mac/dump_syms/dump_syms.xcodeproj/project.pbxproj
index 16759f4c..ee20b2dd 100644
--- a/src/tools/mac/dump_syms/dump_syms.xcodeproj/project.pbxproj
+++ b/src/tools/mac/dump_syms/dump_syms.xcodeproj/project.pbxproj
@@ -97,8 +97,8 @@
B8C5B51A1166534700D34F4E /* file_id.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9BE650410B52F6D800611104 /* file_id.cc */; };
B8C5B51B1166534700D34F4E /* macho_id.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9BE650430B52F6D800611104 /* macho_id.cc */; };
B8C5B51C1166534700D34F4E /* macho_walker.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9BE650450B52F6D800611104 /* macho_walker.cc */; };
- B8C5B51D1166534700D34F4E /* dump_syms.mm in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* dump_syms.mm */; };
- B8C5B51E1166534700D34F4E /* dump_syms_tool.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9BDF186E0B1BB43700F8391B /* dump_syms_tool.mm */; };
+ B8C5B51D1166534700D34F4E /* dump_syms.cc in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* dump_syms.cc */; };
+ B8C5B51E1166534700D34F4E /* dump_syms_tool.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9BDF186E0B1BB43700F8391B /* dump_syms_tool.cc */; };
B8C5B523116653BA00D34F4E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; };
D21F97D711CBA12300239E38 /* test_assembler_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = B88FB0D9116CEC0600407530 /* test_assembler_unittest.cc */; };
D21F97D811CBA13D00239E38 /* libgtestmockall.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B88FB024116BDFFF00407530 /* libgtestmockall.a */; };
@@ -270,7 +270,7 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
- 08FB7796FE84155DC02AAC07 /* dump_syms.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = dump_syms.mm; path = ../../../common/mac/dump_syms.mm; sourceTree = "<group>"; };
+ 08FB7796FE84155DC02AAC07 /* dump_syms.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = dump_syms.cc; path = ../../../common/mac/dump_syms.cc; sourceTree = "<group>"; };
08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
162F64F8161C591500CD68D5 /* arch_utilities.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = arch_utilities.cc; path = ../../../common/mac/arch_utilities.cc; sourceTree = "<group>"; };
162F64F9161C591500CD68D5 /* arch_utilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = arch_utilities.h; path = ../../../common/mac/arch_utilities.h; sourceTree = "<group>"; };
@@ -281,7 +281,7 @@
8B3102D411F0D60300FCF3E4 /* BreakpadDebug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = BreakpadDebug.xcconfig; path = ../../../common/mac/BreakpadDebug.xcconfig; sourceTree = SOURCE_ROOT; };
8B3102D511F0D60300FCF3E4 /* BreakpadRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = BreakpadRelease.xcconfig; path = ../../../common/mac/BreakpadRelease.xcconfig; sourceTree = SOURCE_ROOT; };
9BDF186D0B1BB43700F8391B /* dump_syms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = dump_syms.h; path = ../../../common/mac/dump_syms.h; sourceTree = "<group>"; };
- 9BDF186E0B1BB43700F8391B /* dump_syms_tool.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = dump_syms_tool.mm; sourceTree = "<group>"; };
+ 9BDF186E0B1BB43700F8391B /* dump_syms_tool.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = dump_syms_tool.cc; sourceTree = "<group>"; };
9BE650410B52F6D800611104 /* file_id.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = file_id.cc; path = ../../../common/mac/file_id.cc; sourceTree = SOURCE_ROOT; };
9BE650420B52F6D800611104 /* file_id.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = file_id.h; path = ../../../common/mac/file_id.h; sourceTree = SOURCE_ROOT; };
9BE650430B52F6D800611104 /* macho_id.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = macho_id.cc; path = ../../../common/mac/macho_id.cc; sourceTree = SOURCE_ROOT; };
@@ -493,8 +493,8 @@
9BE650410B52F6D800611104 /* file_id.cc */,
9BE650420B52F6D800611104 /* file_id.h */,
9BDF186D0B1BB43700F8391B /* dump_syms.h */,
- 08FB7796FE84155DC02AAC07 /* dump_syms.mm */,
- 9BDF186E0B1BB43700F8391B /* dump_syms_tool.mm */,
+ 08FB7796FE84155DC02AAC07 /* dump_syms.cc */,
+ 9BDF186E0B1BB43700F8391B /* dump_syms_tool.cc */,
B89E0E701166573700DD08C9 /* macho_dump.cc */,
4D72CAF413DFBAC2006CABE3 /* md5.cc */,
08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */,
@@ -1077,8 +1077,8 @@
B8C5B51A1166534700D34F4E /* file_id.cc in Sources */,
B8C5B51B1166534700D34F4E /* macho_id.cc in Sources */,
B8C5B51C1166534700D34F4E /* macho_walker.cc in Sources */,
- B8C5B51D1166534700D34F4E /* dump_syms.mm in Sources */,
- B8C5B51E1166534700D34F4E /* dump_syms_tool.mm in Sources */,
+ B8C5B51D1166534700D34F4E /* dump_syms.cc in Sources */,
+ B8C5B51E1166534700D34F4E /* dump_syms_tool.cc in Sources */,
B88FAE1911665FE400407530 /* dwarf2diehandler.cc in Sources */,
B88FAE261166603300407530 /* dwarf_cu_to_module.cc in Sources */,
B88FAE271166603300407530 /* dwarf_line_to_module.cc in Sources */,
diff --git a/src/tools/mac/dump_syms/dump_syms_tool.mm b/src/tools/mac/dump_syms/dump_syms_tool.cc
index 7d56809a..54f29226 100644
--- a/src/tools/mac/dump_syms/dump_syms_tool.mm
+++ b/src/tools/mac/dump_syms/dump_syms_tool.cc
@@ -29,12 +29,13 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// dump_syms_tool.mm: Command line tool that uses the DumpSymbols class.
+// dump_syms_tool.cc: Command line tool that uses the DumpSymbols class.
// TODO(waylonis): accept stdin
#include <mach-o/arch.h>
#include <unistd.h>
+#include <algorithm>
#include <iostream>
#include <vector>
@@ -51,8 +52,9 @@ using std::vector;
struct Options {
Options()
: srcPath(), dsymPath(), arch(), cfi(true), handle_inter_cu_refs(true) {}
- NSString *srcPath;
- NSString *dsymPath;
+
+ string srcPath;
+ string dsymPath;
const NXArchInfo *arch;
bool cfi;
bool handle_inter_cu_refs;
@@ -114,8 +116,10 @@ static bool Start(const Options &options) {
// requested, then consider the Module as "split" and dump all the debug data
// from the primary debug info file, the dSYM, and then dump additional CFI
// data from the source Mach-O file.
- bool split_module = options.dsymPath && options.srcPath && options.cfi;
- NSString* primary_file = split_module ? options.dsymPath : options.srcPath;
+ bool split_module =
+ !options.dsymPath.empty() && !options.srcPath.empty() && options.cfi;
+ const string& primary_file =
+ split_module ? options.dsymPath : options.srcPath;
if (!dump_symbols.Read(primary_file))
return false;
@@ -124,7 +128,7 @@ static bool Start(const Options &options) {
if (!dump_symbols.SetArchitecture(options.arch->cputype,
options.arch->cpusubtype)) {
fprintf(stderr, "%s: no architecture '%s' is present in file.\n",
- [primary_file fileSystemRepresentation], options.arch->name);
+ primary_file.c_str(), options.arch->name);
size_t available_size;
const SuperFatArch *available =
dump_symbols.AvailableArchitectures(&available_size);
@@ -214,8 +218,7 @@ static void SetupOptions(int argc, const char *argv[], Options *options) {
break;
}
case 'g':
- options->dsymPath = [[NSFileManager defaultManager]
- stringWithFileSystemRepresentation:optarg length:strlen(optarg)];
+ options->dsymPath = optarg;
break;
case 'c':
options->cfi = false;
@@ -237,21 +240,16 @@ static void SetupOptions(int argc, const char *argv[], Options *options) {
exit(1);
}
- options->srcPath = [[NSFileManager defaultManager]
- stringWithFileSystemRepresentation:argv[optind]
- length:strlen(argv[optind])];
+ options->srcPath = argv[optind];
}
//=============================================================================
int main (int argc, const char * argv[]) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
Options options;
bool result;
SetupOptions(argc, argv, &options);
result = Start(options);
- [pool release];
-
return !result;
}
diff --git a/src/tools/mac/tools_mac.gypi b/src/tools/mac/tools_mac.gypi
index ae06f030..7457573b 100644
--- a/src/tools/mac/tools_mac.gypi
+++ b/src/tools/mac/tools_mac.gypi
@@ -55,7 +55,7 @@
'target_name': 'dump_syms',
'type': 'executable',
'sources': [
- 'dump_syms/dump_syms_tool.mm',
+ 'dump_syms/dump_syms_tool.cc',
],
'link_settings': {
'libraries': [