Click here to Skip to main content
13,898,182 members
Click here to Skip to main content
Add your own
alternative version


46 bookmarked
Posted 23 Apr 2001

Extended Trace: Trace Macros for Win32

, 23 Apr 2001
Rate this:
Please Sign up or sign in to vote.
Trace macros that provide messages with source code link, run-time callstack information, and function prototype information with parameter values

Sample Image - ExtendedTrace.gif


Extended Trace is a collection of a lot of useful traces for Win32, such as:

  • TRACE(...) implementation for Win32.
  • Messages with source code links. Just double click on the message in the Output Window, and jump to the source code.
  • Function parameters. Are you wondering what parameters your function was called with? Just call a simple macro, and it will trace your function prototype with the actual parameter values to the Output Window.
  • Call stack information. You can trace the call stack with function prototypes and parameters' values. Just like the Visual Studio Call Stack window, but this is in run-time.


Add the ExtendedTrace.cpp to your project, and include ExtendedTrace.h to your source file.



Initialize the symbol information. IniSymbolPath is the search path for the symbol files. The built-in path is ".;%_NT_SYMBOL_PATH%;%_NT_ALTERNATE_SYMBOL_PATH%;%SYSTEMROOT%;%SYSTEMROOT%\System32;". IniSymbolPath will be added to the built-in path. IniSymbolPath can be NULL.


Frees up the symbol information.


Write a message(Msg) to the Output Window with a link to File(Line).


Write a message(Msg) to the Output Window with a link to its source code.


Write the function prototype with parameters to the Output Window. You can call this function anytime in a function.


Dumps the call stack with function prototypes and the parameters' values to the Output Window. The call stack elements dumped with source code links, so you can jump directly to them.


Same as the MFC TRACE(...)

Note: If you're using only TRACEF(...) or SRCLINKTRACExxx(...) macros, you don't need EXTENDEDTRACEINITIALIZE(...)/EXTENDEDTRACEUNINITIALIZE.


#include "ExtendedTrace.h"

void g ( LPTSTR )
	// Dumps the actual call stack

void f( int, int, int )
	// What parameters was this function called with?
	g( NULL );

int main( int, char** )
	// Just like the TRACE(...) in MFC
	TRACEF( _T("Application started at %d\n"), clock() );

	// Initializes the symbol files

	// Trace message with a link to this line in the source code
	SRCLINKTRACE( _T("I'm calling f(...)\n") );

	f( 1, 2, 3);

	// Cleaning up

	TRACEF( _T("Application ended at %d\n"), clock() );

	return 0;

The output in the Output Window:

Application started at 578
Loaded 'D:\WINNT\system32\dbghelp.dll', no matching symbolic information found.
c:\temp\magictrace\main.cpp(28) : I'm calling f(...)
Function info(thread=0x36C) : void f(int=0x00000001,int=0x00000002,int=0x00000003)
Call stack info(thread=0x36C) : 
     c:\temp\magictrace\main.cpp(12) : void g(char *=0x00000000)
     c:\temp\magictrace\main.cpp(19) : void f(int=0x00000001,int=0x00000002,int=0x00000003)
     c:\temp\magictrace\main.cpp(30) : main(int=0x00000001,TCHAR * *=0x00522C88)
     crtexe.c(338) : mainCRTStartup()
     KERNEL32!0x77E87903 : SetUnhandledExceptionFilter
Application ended at 1171
The thread 0x36C has exited with code 0 (0x0).



This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.

A list of licenses authors might use can be found here.


About the Author

Zoltan Csizmadia
Web Developer
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMissing argument in some error messages Pin
Menuki6-Mar-09 2:21
memberMenuki6-Mar-09 2:21 
GeneralcallStack.AddrFrame.Offset != 0 Pin
xrinlar13-May-07 10:24
memberxrinlar13-May-07 10:24 
GeneralSometimes, it doesn't work. Pin
mAtrIxdjg8-Nov-06 21:33
membermAtrIxdjg8-Nov-06 21:33 
GeneralWorks for me Pin
hector [.j.] rivas22-Feb-06 6:11
memberhector [.j.] rivas22-Feb-06 6:11 
Generalincorrect symbols Pin
Anonymous25-Sep-02 7:33
memberAnonymous25-Sep-02 7:33 
GeneralCan't Get it to work Pin
5-Apr-02 5:05
suss5-Apr-02 5:05 
GeneralRe: Can't Get it to work Pin
Anonymous1-Aug-02 3:45
memberAnonymous1-Aug-02 3:45 
Generalvc7 Pin
23-Mar-02 9:24
suss23-Mar-02 9:24 
GeneralRe: vc7 Pin
Anthony_Yio22-Sep-04 21:01
memberAnthony_Yio22-Sep-04 21:01 
GeneralRe: vc7 Pin
Scott Langham17-Dec-04 8:24
memberScott Langham17-Dec-04 8:24 
GeneralRe: vc7 Pin
SanDiegoPhil30-Aug-06 11:36
memberSanDiegoPhil30-Aug-06 11:36 
Bobby G. Vinyard8-Mar-02 20:58
memberBobby G. Vinyard8-Mar-02 20:58 
GeneralGreat Work Pin
28-Dec-01 10:43
suss28-Dec-01 10:43 
GeneralRe: Great Work Pin
2-Jan-02 22:16
suss2-Jan-02 22:16 
GeneralWorks only on NT/2000 Pin
25-Apr-01 5:58
suss25-Apr-01 5:58 
GeneralTRACE, but no more than 512 characters Pin
24-Apr-01 19:35
suss24-Apr-01 19:35 
GeneralRe: TRACE, but no more than 512 characters Pin
l a u r e n24-Apr-01 20:19
memberl a u r e n24-Apr-01 20:19 
GeneralRe: TRACE, but no more than 512 characters Pin
Mehmet Ozgul25-Apr-01 6:29
memberMehmet Ozgul25-Apr-01 6:29 
GeneralRe: TRACE, but no more than 512 characters Pin
Zoltan Csizmadia25-Apr-01 6:58
memberZoltan Csizmadia25-Apr-01 6:58 
GeneralRe: TRACE, but no more than 512 characters Pin
Rick York25-Apr-01 18:05
mveRick York25-Apr-01 18:05 
GeneralRe: TRACE, but no more than 512 characters Pin
T1000_RUS31-Jul-07 0:56
memberT1000_RUS31-Jul-07 0:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190306.1 | Last Updated 24 Apr 2001
Article Copyright 2001 by Zoltan Csizmadia
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid