support mtrack... my new little memory tracker so i can finally live

track down leaks and other badnesses.



SVN revision: 65335
This commit is contained in:
Carsten Haitzler 2011-11-17 10:19:50 +00:00
parent 72d14f5466
commit cef3afa355
4 changed files with 40 additions and 1 deletions

View File

@ -73,6 +73,8 @@ e_alert_show(int sig)
}
restart_e:
if (getenv("E_START_MTRACK"))
e_util_env_set("MTRACK", "track");
ecore_app_restart();
}

View File

@ -207,6 +207,8 @@ _e_ipc_cb_client_data(void *data __UNUSED__, int type __UNUSED__, void *event)
switch (e->minor)
{
case E_ALERT_OP_RESTART:
if (getenv("E_START_MTRACK"))
e_util_env_set("MTRACK", "track");
ecore_app_restart();
break;
case E_ALERT_OP_EXIT:

View File

@ -182,6 +182,8 @@ main(int argc, char **argv)
snprintf(buff, sizeof(buff), "%1.1f", tstart);
e_util_env_set("E_START_TIME", buff);
if (getenv("E_START_MTRACK"))
e_util_env_set("MTRACK", NULL);
TS("Eina Init");
if (!eina_init())
{
@ -969,6 +971,8 @@ main(int argc, char **argv)
if (restart)
{
e_util_env_set("E_RESTART_OK", "1");
if (getenv("E_START_MTRACK"))
e_util_env_set("MTRACK", "track");
ecore_app_restart();
}

View File

@ -351,9 +351,40 @@ main(int argc, char **argv)
}
done:
/* mtrack memory tracker support */
p = getenv("HOME");
if (p)
{
FILE *f;
/* if you have ~/.e-mtrack, then the tracker will be enabled
* using the content of this file as the path to the mtrack.so
* shared object that is the mtrack preload */
snprintf(buf, sizeof(buf), "%s/.e-mtrack", p);
f = fopen(buf, "r");
if (f)
{
if (fgets(buf, sizeof(buf), f))
{
int len = strlen(buf);
if ((len > 1) && (buf[len - 1] == '\n'))
{
buf[len - 1] = 0;
len--;
}
env_set("LD_PRELOAD", buf);
env_set("MTRACK", "track");
env_set("E_START_MTRACK", "track");
snprintf(buf, sizeof(buf), "%s/.e-mtrack.log", p);
env_set("MTRACK_TRACE_FILE", buf);
}
fclose(f);
}
}
/* try dbus-launch */
snprintf(buf, sizeof(buf), "%s/enlightenment", eina_prefix_bin_get(pfx));
args = alloca((argc + 2 + VALGRIND_MAX_ARGS) * sizeof(char *));
if ((!getenv("DBUS_SESSION_BUS_ADDRESS")) &&
(!getenv("DBUS_LAUNCHD_SESSION_BUS_SOCKET")))