]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
valac: Add --enable-mem-profiler option
authorJörn Magens <interflug1@gmx.net>
Sat, 9 Jan 2010 15:47:20 +0000 (16:47 +0100)
committerJürg Billeter <j@bitron.ch>
Sat, 9 Jan 2010 15:47:20 +0000 (16:47 +0100)
Enables the GLib memory profiler.

Fixes bug 530627.

codegen/valaccodemethodmodule.vala
compiler/valacompiler.vala
vala/valacodecontext.vala

index ef8c41d8fc3b452d4e13ad030e098668d960376c..b2c28efba8ec54b74989c2efd4ba481384f3f1bb 100644 (file)
@@ -756,7 +756,14 @@ internal class Vala.CCodeMethodModule : CCodeStructModule {
                                        var thread_init_call = new CCodeFunctionCall (new CCodeIdentifier ("g_thread_init"));
                                        thread_init_call.line = cmain.line;
                                        thread_init_call.add_argument (new CCodeConstant ("NULL"));
-                                       main_block.add_statement (new CCodeExpressionStatement (thread_init_call)); 
+                                       main_block.add_statement (new CCodeExpressionStatement (thread_init_call));
+                               }
+
+                               if (context.mem_profiler) {
+                                       var mem_profiler_init_call = new CCodeFunctionCall (new CCodeIdentifier ("g_mem_set_vtable"));
+                                       mem_profiler_init_call.line = cmain.line;
+                                       mem_profiler_init_call.add_argument (new CCodeConstant ("glib_mem_profiler_table"));
+                                       main_block.add_statement (new CCodeExpressionStatement (mem_profiler_init_call));
                                }
 
                                var type_init_call = new CCodeExpressionStatement (new CCodeFunctionCall (new CCodeIdentifier ("g_type_init")));
index bddaa1f4984bee915ad7e9442d7c3555bb02b68e..af599a202590ada177bacbdc24d52f0ef1244b1a 100644 (file)
@@ -55,6 +55,7 @@ class Vala.Compiler {
        static string output;
        static bool debug;
        static bool thread;
+       static bool mem_profiler;
        static bool disable_assert;
        static bool enable_checking;
        static bool deprecated;
@@ -100,6 +101,7 @@ class Vala.Compiler {
                { "output", 'o', 0, OptionArg.FILENAME, ref output, "Place output in file FILE", "FILE" },
                { "debug", 'g', 0, OptionArg.NONE, ref debug, "Produce debug information", null },
                { "thread", 0, 0, OptionArg.NONE, ref thread, "Enable multithreading support", null },
+               { "enable-mem-profiler", 0, 0, OptionArg.NONE, ref mem_profiler, "Enable GLib memory profiler", null },
                { "define", 'D', 0, OptionArg.STRING_ARRAY, ref defines, "Define SYMBOL", "SYMBOL..." },
                { "main", 0, 0, OptionArg.STRING, ref entry_point, "Use SYMBOL as entry point", "SYMBOL..." },
                { "disable-assert", 0, 0, OptionArg.NONE, ref disable_assert, "Disable assertions", null },
@@ -235,6 +237,7 @@ class Vala.Compiler {
                }
                context.debug = debug;
                context.thread = thread;
+               context.mem_profiler = mem_profiler;
                context.save_temps = save_temps;
                if (profile == "posix") {
                        context.profile = Profile.POSIX;
index e9e694df7c7e9f02da1c465aa36b667a648d09bc..c1559f113a21c196d061197a531d3dbd9bb6d65f 100644 (file)
@@ -118,6 +118,11 @@ public class Vala.CodeContext {
         */
        public bool thread { get; set; }
 
+       /**
+        * Enable memory profiler.
+        */
+       public bool mem_profiler { get; set; }
+
        /**
         * Specifies the optional module initialization method.
         */