Commit -v -d changes that were laying around uncommitted... draft default tip
authorTed Mielczarek <ted@mielczarek.org>
Wed, 31 Aug 2016 10:51:21 -0400
changeset 1 8b308832a6d38dac44a9f28a4c582be3ff926af9
parent 0 bff8d0789d784bb1d9d2f7593844a27ac5e5f0c4
push id2
push usertmielczarek@mozilla.com
push dateWed, 31 Aug 2016 14:51:24 +0000
Commit -v -d changes that were laying around uncommitted...
Makefile
dumpmodules.cc
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,9 @@
-BREAKPAD_SRCDIR := ../google-breakpad
+BREAKPAD_SRCDIR := ../breakpad/src
 BREAKPAD_OBJDIR := ../obj-breakpad
 BREAKPAD_LIBS := $(BREAKPAD_OBJDIR)/src/libbreakpad.a $(BREAKPAD_OBJDIR)/src/third_party/libdisasm/libdisasm.a
 
 BIN := dumpmodules
 all: $(BIN)
 
 $(BIN): $(BIN).cc $(BREAKPAD_LIBS)
 	$(CXX) $(CXXFLAGS) -o $@ $< $(BREAKPAD_LIBS) -I$(BREAKPAD_SRCDIR)/src
--- a/dumpmodules.cc
+++ b/dumpmodules.cc
@@ -22,20 +22,23 @@
 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+#include <algorithm>
+
 #include <limits.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include "google_breakpad/processor/basic_source_line_resolver.h"
 #include "google_breakpad/processor/minidump.h"
 #include "google_breakpad/processor/minidump_processor.h"
 #include "google_breakpad/processor/stack_frame_cpu.h"
 #include "google_breakpad/processor/system_info.h"
 #include "processor/pathname_stripper.h"
 #include "processor/simple_symbol_supplier.h"
@@ -50,32 +53,70 @@ void error(const char* fmt, ...)
   fprintf(stderr, "\n");
   va_end(args);
 
   exit(1);
 }
 
 int main(int argc, char** argv)
 {
-  if (argc != 2) {
-    error("Usage: %s <minidump>\n", argv[0]);
+  if (argc < 2) {
+    error("Usage: %s [-v|-d] <minidump>\n\
+\t-v\tAlso print debug IDs\n\
+\t-d\tPrint relative paths to symbol files that would be loaded", argv[0]);
   }
 
-  Minidump dump(argv[1]);
+  const char* dumpname = argv[1];
+  bool verbose = false;
+  bool debuginfo = false;
+  if (strcmp(argv[1], "-v") == 0) {
+    dumpname = argv[2];
+    verbose = true;
+  } else if (strcmp(argv[1], "-d") == 0) {
+    dumpname = argv[2];
+    debuginfo = true;
+  }
+
+  Minidump dump(dumpname);
   if (!dump.Read()) {
     error("Couldn't read minidump %s", argv[1]);
   }
 
   MinidumpModuleList *modules = dump.GetModuleList();
 
   if (!modules) {
     error("Minidump %s is missing module list", argv[1]);
   }
 
   unsigned int module_count = modules->module_count();
   for (unsigned int module_sequence = 0;
        module_sequence < module_count;
        ++module_sequence) {
     const CodeModule *module = modules->GetModuleAtSequence(module_sequence);
-    printf("%s\n", module->code_file().c_str());
+    if (debuginfo) {
+      string debug_file_name = PathnameStripper::File(module->debug_file());
+      string path = debug_file_name;
+      path.append("/");
+      path.append(module->debug_identifier());
+      path.append("/");
+
+      string debug_file_extension;
+      if (debug_file_name.size() > 4)
+        debug_file_extension = debug_file_name.substr(debug_file_name.size() - 4);
+      std::transform(debug_file_extension.begin(), debug_file_extension.end(),
+                     debug_file_extension.begin(), tolower);
+      if (debug_file_extension == ".pdb") {
+        path.append(debug_file_name.substr(0, debug_file_name.size() - 4));
+      } else {
+        path.append(debug_file_name);
+      }
+      path.append(".sym");
+      printf("%s\n", path.c_str());
+    } else {
+      printf("%s", module->code_file().c_str());
+      if (verbose) {
+        printf("\t%s", module->debug_identifier().c_str());
+      }
+      printf("\n");
+    }
   }
   return 0;
 }