summaryrefslogtreecommitdiffstats
path: root/testing/tools/fileid/linux_fileid.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'testing/tools/fileid/linux_fileid.cpp')
-rw-r--r--testing/tools/fileid/linux_fileid.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/testing/tools/fileid/linux_fileid.cpp b/testing/tools/fileid/linux_fileid.cpp
new file mode 100644
index 000000000..de1ecbd1c
--- /dev/null
+++ b/testing/tools/fileid/linux_fileid.cpp
@@ -0,0 +1,41 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include <stdio.h>
+#include <string>
+
+#include "common/linux/file_id.h"
+#include "common/memory.h"
+
+using std::string;
+
+using google_breakpad::auto_wasteful_vector;
+using google_breakpad::FileID;
+using google_breakpad::PageAllocator;
+
+int main(int argc, char** argv)
+{
+
+ if (argc != 2) {
+ fprintf(stderr, "usage: fileid <elf file>\n");
+ return 1;
+ }
+
+ PageAllocator allocator;
+ auto_wasteful_vector<uint8_t, sizeof(MDGUID)> identifier(&allocator);
+ FileID file_id(argv[1]);
+ if (!file_id.ElfFileIdentifier(identifier)) {
+ fprintf(stderr, "%s: unable to generate file identifier\n",
+ argv[1]);
+ return 1;
+ }
+
+ string result_guid = FileID::ConvertIdentifierToUUIDString(identifier);
+
+ // Add an extra "0" at the end. PDB files on Windows have an 'age'
+ // number appended to the end of the file identifier; this isn't
+ // really used or necessary on other platforms, but be consistent.
+ printf("%s0\n", result_guid.c_str());
+ return 0;
+}