Logging function calls

Federico Maggi <[email protected]> Mon, 1 Feb 2010 23:42:53 +0100
Newsgroups gmane.comp.mozilla.devel.nspr
Message-ID <[email protected]>
Hello,
	I am working on a branch of mozila-central for a research project: I needed to log every NSPR call while Firefox runs.

To this end, I wrote a simple macro that calls syslog() and passes __func__ to it: this is all I need, although it might sound very idiotic.

I only miss one thing: I would like to be able to separate/isolate the log entries per URL. More precisely, at this moment what I get looks like:

[...]
slog: pr_FindSymbolInProg
slog: PR_GetPageSize
slog: GetPageSize
slog: PR_Calloc
slog: PR_GetEnv
slog: PR_Calloc
slog: PR_GetEnv
slog: PR_Calloc
slog: PR_GetEnv
slog: PR_Calloc
slog: PR_GetEnv
slog: PR_Calloc
[...]
slog: PR_GetEnv
slog: PR_Calloc
slog: PR_GetEnv
slog: PR_Calloc
slog: PR_GetEnv
slog: PR_Calloc
slog: PR_GetEnv
slog: PR_Calloc
slog: PR_GetEnv
slog: PR_Calloc
slog: PR_GetEnv
slog: PR_Calloc
slog: PR_GetEnv
slog: _MD_EarlyInit
slog: _PR_InitLocks
slog: _PR_InitAtomic
[...]

What I would like to achieve is something like the following:

[...]
slog: pr_FindSymbolInProg
slog: PR_GetPageSize
slog: URL http://www.example.com is being loaded <----- [begin]
slog: GetPageSize
slog: PR_Calloc
slog: PR_GetEnv
slog: PR_Calloc
slog: PR_GetEnv
slog: PR_Calloc
slog: PR_GetEnv
slog: PR_Calloc
slog: PR_GetEnv
slog: PR_Calloc
slog: PR_GetEnv
slog: PR_Calloc
slog: PR_GetEnv
[...]
slog: PR_GetEnv
slog: PR_Calloc
slog: PR_GetEnv
slog: PR_Calloc
slog: PR_GetEnv
slog: PR_Calloc
slog: URL http://www.example.com is fully loaded <----- [end]
slog: PR_GetEnv
slog: PR_Calloc
slog: PR_GetEnv
slog: _MD_EarlyInit
slog: _PR_InitLocks
slog: _PR_InitAtomic
[...]

Do you think it's possible to trace such events down into NSPR? If not, what would you suggest do to?

Since I am at an early stage of development, I am open also to dramatic changes in the logging approach.

Thanks in advance. Regards,
-- Fede