[vala] valac: Add --enable-mem-profiler option
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] valac: Add --enable-mem-profiler option
- Date: Sat, 9 Jan 2010 15:48:33 +0000 (UTC)
commit 8a8a7bdc8d18ec3209329e33f3944f77871560f0
Author: Jörn Magens <interflug1 gmx net>
Date: Sat Jan 9 16:47:20 2010 +0100
valac: Add --enable-mem-profiler option
Enables the GLib memory profiler.
Fixes bug 530627.
codegen/valaccodemethodmodule.vala | 9 ++++++++-
compiler/valacompiler.vala | 3 +++
vala/valacodecontext.vala | 5 +++++
3 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index ef8c41d..b2c28ef 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -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")));
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala
index bddaa1f..af599a2 100644
--- a/compiler/valacompiler.vala
+++ b/compiler/valacompiler.vala
@@ -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;
diff --git a/vala/valacodecontext.vala b/vala/valacodecontext.vala
index e9e694d..c1559f1 100644
--- a/vala/valacodecontext.vala
+++ b/vala/valacodecontext.vala
@@ -119,6 +119,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.
*/
public Method module_init_method { get; set; }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]