LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-02-2006, 12:32 AM   #1
ik_nitk
LQ Newbie
 
Registered: Jan 2006
Posts: 12

Rep: Reputation: 0
Lightbulb Tracing function calls... How?


In C++

if you write like this ,

class sample; // contructor prints function name entry line no
// destructor prints function return line no

foo(){
sample s("foo");
...//foo body
}

when we execute this it will print
"calling foo 1245"
"exiting foo 1260"

Now can we do the same thing in C by adding only a single line at the start of the function call.


~ik
 
Old 06-02-2006, 05:50 AM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,376

Rep: Reputation: 147Reputation: 147
You could add a println() or even a macro which will then print out some diagnostics; but maybe I don't properly understand your question.
 
Old 06-05-2006, 05:53 AM   #3
ik_nitk
LQ Newbie
 
Registered: Jan 2006
Posts: 12

Original Poster
Rep: Reputation: 0
but maybe I don't properly understand your question

Quote:
Originally Posted by graemef
You could add a println() or even a macro which will then print out some diagnostics; but maybe I don't properly understand your question.
Basically , i want to call some trace function's when i enter into the functions and and when i come out of it by adding a single line after the function name.

example.
foo(){
sample("foo");
..
..
..
}

sample("foo") will print "foo" when the function is called and also returned.

basically constructors and destructors function.

i am not sure if it is really possible in C. But it is possible in C++.

~ik
 
Old 06-05-2006, 07:05 AM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,376

Rep: Reputation: 147Reputation: 147
I'm still uncertain because a constructor and destructor are linked to the life of a object not the life of a method (read function).
 
  


Reply

Tags
calls, function, trace


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tracing system calls of sendmail sOldFiSh Programming 2 11-30-2005 02:34 PM
Tracing the system calls arunachalam Linux - Software 2 09-24-2005 02:41 AM
timing function calls in C? (recvfrom() on Pentium II) pingswept Programming 4 05-24-2004 07:55 AM
libc function calls h/w Programming 4 02-13-2004 03:00 PM
using timer for repeated function calls poojamanu Programming 1 04-09-2003 08:17 PM


All times are GMT -5. The time now is 11:04 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration