473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Function name

Hello!

How can I get the info about the function at which goes the execution.

I mean information that can be obtained with the help of
__FUNCTION__ , __FILE__, __LINE__ in the C-language.

--
Vadym Stetsyak
ICQ 161730125

He, who commands the past - commands the future
He, who commands the present - commands the past
Nov 13 '05 #1
2 4830
Hello,
How can I get the info about the function at which goes the execution.

I mean information that can be obtained with the help of
__FUNCTION__ , __FILE__, __LINE__ in the C-language.


"System.Diagnostics" namespace contains interesting helper classes -
StackTrace and StackFrame. Below listed code sample demonstrating how it
works. Unfortunately it's not exactly what you need, this code only works
for Debug build, and IIRC it requires in debug symbols (.pdb file), where
stored information about files, line numbers, etc.

<code>
public class Foo
{
public void foo1()
{
foo2();
}

public void foo2()
{
foo3();
}

public void foo3()
{
StackTrace st = new StackTrace(0, true);
StackFrame frame = st.GetFrame(0);
Console.WriteLine(frame.GetFileName());
Console.WriteLine(frame.GetFileLineNumber());
Console.WriteLine(frame.GetFileColumnNumber());
Console.WriteLine(frame.GetMethod());
}
}

.....
Foo foo = new Foo();
foo.foo1();
</code>

...
Regards,
Vadim.
Nov 13 '05 #2
thank you, Vadim.

"Vadim Melnik" <vm****@REMOVETHISdocsultant.com> wrote in message
news:uM**************@tk2msftngp13.phx.gbl...
Hello,
How can I get the info about the function at which goes the execution.

I mean information that can be obtained with the help of
__FUNCTION__ , __FILE__, __LINE__ in the C-language.


"System.Diagnostics" namespace contains interesting helper classes -
StackTrace and StackFrame. Below listed code sample demonstrating how it
works. Unfortunately it's not exactly what you need, this code only works
for Debug build, and IIRC it requires in debug symbols (.pdb file), where
stored information about files, line numbers, etc.

<code>
public class Foo
{
public void foo1()
{
foo2();
}

public void foo2()
{
foo3();
}

public void foo3()
{
StackTrace st = new StackTrace(0, true);
StackFrame frame = st.GetFrame(0);
Console.WriteLine(frame.GetFileName());
Console.WriteLine(frame.GetFileLineNumber());
Console.WriteLine(frame.GetFileColumnNumber());
Console.WriteLine(frame.GetMethod());
}
}

....
Foo foo = new Foo();
foo.foo1();
</code>

..
Regards,
Vadim.

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Nick Coghlan | last post by:
Time for another random syntax idea. . . So, I was tinkering in the interactive interpreter, and came up with the following one-size-fits-most default argument hack: Py> x = 1 Py> def...
6
by: marcelf3 | last post by:
Hello.. This page opens a window with some information, but everytime the user changes a field in the parent window, the child window needs to be closed. These 2 functions were supposed to do the...
12
by: Susan Cranford | last post by:
Please forgive, I have looked at so much info I can't figure out how to put it together even though I know it must be fairly simple. I have an array of input text boxes (txtDOBn) where n is...
6
by: Bill Rubin | last post by:
The following code snippet shows that VC++ 7.1 correctly compiles a static member function invocation from an Unrelated class, since this static member function is public. I expected to compile the...
4
by: poojak | last post by:
I have write two different js function in a external file. one function write a table (I used innerHTML for this.) and another function is for showing/ hideing some rows depending on radio button...
2
by: ELINTPimp | last post by:
Hello all, Have a really interesting problem (at least to me) with my upload_file() function. I have it working now, with a bit of a work around, but would like to know what everyone thinks in...
6
by: Maguila007 | last post by:
Hi Is there any way to obtain the name of the function, inside the function which was called. Ex: function something() { alert( "The name of the function you invoke is " ......should
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
2
by: WGW | last post by:
Hello all, I need another set of eyes cause it just isn't working, no matter how identical I make it. The initRotator function works when called by itself, but when adding another function, only the...
5
by: mad.scientist.jr | last post by:
According to http://www.quirksmode.org/js/forms.html you need to look through a radio button's members to find the value: I tried writing a reusable function to return the value, see code at:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.