Hi,

I am working to add Tracing Functionality to Vala, and can use some help on
which direction to take.

What is Tracing Functionality?
=========================
When you compile with the "--trace" flag, and run a vala program, every
time a Vala Function (not a library/System function) is called, a message
is printed in your console.

For example, if you have a program like
function foo(int x) {
  // do something
}

int main() {
  foo (42);
}

And you run this program, there will be an output like:
[TRACE] foo(42)

I am modelling this on Mono's Tracing functionality [1]

Why is tracing functionality useful?
=============================
It will help vastly while debugging and for a new contributor to quickly
identify the code path, so he/she can identify the relevant functions which
are executed when a bug is reproduced or a feature is activated.

This gives a much better starting point for people unfamiliar with the
codebase, which I hope will be orders of magnitude more productive than
"grep"ping the code each time.

How am I implementing tracing?
============================
I have attached a patch with an initial version of tracing functionality.
It merely adds a "printf" whenever there is a new function call. It
currently fails to compile programs because it doesn't add stdio.h to the C
Code.

But it is certainly possible and quite easy to add tracing functionality.

My Questions
============
1. If I polish the functionality, are you willing to merge this feature
upstream?

2. I found 2 places where I can add this functionality so far: in
ValaCCodeFunction and ValaCCodeMethodModule (latter as suggested by flo on
#vala)

I felt the first one was easier, so I went ahead with that. Should I
continue in this direction or should I consider adding it in the Method
Module?

3. Is there a way to get the current Line Number and File of the source
vala file that is being converted?

4. I understand that this would have some pretty annoying issues in
multi-threaded programs. So I thought that I could have an output like this:
[Thread/Process ID][Trace] filename.vala:32 foo_bar_func(param, param)

so the output can be written to a file, and then:
cat output.txt | grep threadID | less

can be used to study the logs, and this will be free of any issues. I don't
know enough C to get the Thread/Process ID. Can you tell me how to do this?

Thank you,
Anirudh

[1]: http://www.mono-project.com/Debugging#Tracing_Program_Execution

-- 
Co-founder and Developer, RazorFlow
http://razorflow.com

Attachment: 0001-Initial-work-on-a-trace-feature.patch
Description: Binary data

_______________________________________________
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to