Merge pull request #5675 from mono/glib-debug-symbols
[mono.git] / tools / sgen / sgen-grep-binprot-main.c
index 7a4c363762d00f45466a2de51d5f98dc631db0df..bcfbb54f54ae7223a82468a77f75675ac39c0051 100644 (file)
 #include "sgen-entry-stream.h"
 #include "sgen-grep-binprot.h"
 
+/* FIXME Add grepers for specific endianness */
+GrepEntriesFunction grepers [] = {
+       sgen_binary_protocol_grep_entries32p, /* We have header, structures are packed, 32 bit word */
+       sgen_binary_protocol_grep_entries64p, /* We have header, structures are packed, 64 bit word */
+       sgen_binary_protocol_grep_entries /* No header, uses default word size and structure layout */
+};
+
 int
 main (int argc, char *argv[])
 {
@@ -85,8 +92,14 @@ main (int argc, char *argv[])
 
        input_file = input_path ? open (input_path, O_RDONLY) : STDIN_FILENO;
        init_stream (&stream, input_file);
-       sgen_binary_protocol_grep_entries (&stream, num_nums, nums, num_vtables, vtables,
-                               dump_all, pause_times, color_output, first_entry_to_consider);
+       for (i = 0; i < sizeof (grepers) / sizeof (GrepEntriesFunction); i++) {
+               if (grepers [i] (&stream, num_nums, nums, num_vtables, vtables, dump_all,
+                               pause_times, color_output, first_entry_to_consider)) {
+                       /* Success */
+                       break;
+               }
+               reset_stream (&stream);
+       }
        close_stream (&stream);
        if (input_path)
                close (input_file);