|
Yes i tried that, it works.
|
|
|
|
|
Hello everybody,
is it possible to determine at realtime the function which has called the current function?
Example
void A(void)
{
DoWork();
}
void B(void)
{
DoWork();
}
void DoWork(void)
{
char *trace = GetTraceOf5LastFunction();
OutputDebugString("DoWork called from function : ");
OutputDebugString(trace);
}
Is it possible?
Big thanks for any help
Edit:
I have found a fonction called "backtrace" which is placed into execinfo.h
But i don't have a such header-file on my system (Visual Studio)
modified on Tuesday, January 27, 2009 6:26 AM
|
|
|
|
|
Can you use of dll's you can load your functions of dll on the current function.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Is there a DLL which executes the work of backtracing?
|
|
|
|
|
Hi,
the easiest way may well be the low-tech one: add a string parameter to the function, and pass the caller's name. That works no matter what.
DoWork("A");
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Tuesday, January 27, 2009 8:10 AM
|
|
|
|
|
This method is the simplest, but i can't write over 100 Debug-Lines into the code
But thanks anyway
|
|
|
|
|
Hi baerten,
I agree with Luc. However you may be able to use a pre-defined macro[^] something like below:
VOID FunctionB(int iVal,char *caller,int line)
{
char szBuf[MAX_PATH];
sprintf(szBuf,"I was called by %s on line %d",caller,line);
MessageBoxA(NULL,szBuf,0,0);
}
VOID FunctionA()
{
FunctionB(1,__FUNCTION__,__LINE__);
}
baerten wrote: i can't write over 100 Debug-Lines into the code
A stack trace is several times more expensive at runtime.
Best Wishes,
-David Delaune
|
|
|
|
|
You need a stack walking function. Here are some[^] links[^] that may be useful.
The second is probably best - John Robbins is a well regarded expert on debugging and things like that. His SUPERASSERT code includes stack tracing code - see the dialog screenshot about half way through the article for an example of what you can get. Obviously you only need the last item in the trace.
One last thing - IIRC, without debug symbols, all you're going to get is the address that called you, not a function name.
|
|
|
|
|
Hi,
I want to perform basic operations on database like add,update,delete using VS2005 and SQLServer 2005.
Which are the set of functions to work with this?
Please suggest any useful link to start with.
Thanks in advance.
R.
|
|
|
|
|
|
Thanks Rahul for your help.
|
|
|
|
|
You can use of CDatabase class and see this[^] example.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Thanks Hamid for ur help. Can you plz tell me how can i find sample for ODBC with VC++?
|
|
|
|
|
Hi All,
This query is regarding memory issue on WinXP (SP2). I have a simple application developed on MSVS2005 IDE. I am observing a peculiar behaviour of this application's memory usage when run on XP(SP2) machine:
Internally i make use of the COM interface to access the database - MSADO.
1. WinXP(SP2 with WLAN API patch) - Memory usage around 9Mb
2. WinXP(Microsoft IDE 2005 with SP2 with WLAN API patch) - Memory usage around 26Mb
Do anyone have any idea behid this dire memory consumption when the application is run on XP with Visual Studio being installed.
Thanks in advance for your time and support...
Sunil
|
|
|
|
|
Some questions - - Is this a debug or release build
- Are you running the application under VS2005 when you get the 26MB memory usage
Maybe you could use Dependency Walker[^] to see what DLLs are being loaded into the executable, maybe some of them are Visual Studio related?
|
|
|
|
|
Hi Sunil,
Microsoft Windows will map many extra DLL's into your process space which do not appear in a PE image dependency walker. These extra libraries which are mapped into your process can be completely different on each users machine.
Some examples of extra dynamic link libraries which could be mapped into your process:
1.) AppInit_DLLs[^]
2.) Window Hooks[^]
3.) Application Compatibility Layer[^] (Much of the AppCompat/Shim Engine is NDA undocumented)
4.) Device Drivers may map extra DLL's into a process.
If you want to visually inspect which libraries are loaded in each situation then I would recommend downloading Process Explorer by Mark Russinovich[^]. You can export your process information to a text file and differentiate them.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi all,
I have made a Report style List control in my Dialog based application. I have two columns and I want to compare first column value with second column value i.e it will perform a linear search for comparing items. My problem is sometimes my list has thousands of item so it takes very long time for doing so.... my second list items are sorted.....
Can anybody tell me how to reduce searching time and make my program run faster.....
Thanks in advance......
|
|
|
|
|
- I would (pretty much always) hold the data separate from the list control (using the LVS_OWNERDATA[^] style). That way you compare data using some container (STL rather than MFC, please, for me) which will be much quicker than by putting the data in the list control.
- As the second column is sorted, you can search through it using a binary search[^], which the STL has built-in....although you want to use lower_bound[^] rather than the more obvious binary_search[^]
HTH!
|
|
|
|
|
Hi,
I'm c++ beginner.
Can you help me,
because I dont know how to "specify the path"
of the text file i want to access.
thanks.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
// "path of input.txt"
ifstream iFile("input.txt");
while (!iFile.eof())
{
int x;
iFile >> x;
cerr << x << endl;
}
return 0;
}
|
|
|
|
|
What's your problem exactly ? Just pass the path to your file to the ifstream constructor. Be carefull when passing the character '\', you'll need to escape it (e.g. something like this "folder1\\folder2\\myFile.txt").
If you are using relative path, you need to take care of your working directory. The working directory is configured through your project options.
|
|
|
|
|
because I want to add exact path in the code just like in
vb command "Open Path & Filename For Input As #1"
thanks
|
|
|
|
|
Err sorry, I have no idea what "Open Path & Filename For Input As #1" does.
What do you mean by exact path ? Did you try my suggestion ?
|
|
|
|
|
yes, i can read/access the txtfile,
but i want to try to specify the path in code itself.
example.
in code there is a msg
"pls input the directory or path where you save the file"
thanks again.
|
|
|
|
|
Sorry, but you will need to be much more explicit because I'm lost.
mac_g wrote: but i want to try to specify the path in code itself.
That was what I explained you: just pass a string which contains the path.
mac_g wrote: in code there is a msg
"pls input the directory or path where you save the file"
In code ? You mean you display that message on the console and wait until the user type the path ? If yes, just retrieve the string he typed and pass it to the ifstream constructor, that's as easy as that.
So, where are you stuck exactly ? In the part where you have to retrieve the string from the user or passing the string to the constructor ?
Please also explain what you already did and what is the exact problem you encounter.
|
|
|
|
|
can you give me an example for retrieving the string to the ifstream constructor?
thanks
|
|
|
|