The crash does not make much sense to me, but if you were to provide a call stack it would be quite helpful (or send me your source code offline and I can take a quick look).
Alex
From: anshul makkar [mailto:xxxxx@gmail.com]
Sent: Tuesday, August 04, 2009 6:39 AM
To: Alex Bendetov
Cc: Windows System Software Devs Interest List
Subject: Re: [ntdev] ControlCallBack Function in WPP
Hi,
Yes, Finally I was able to make it work.
As rightly pointed out the problem was with the EnableFlag in EnableTrace function. If I comment this function then no crash was occuring, although no etl file was generated.
Changes to Make it work :
WPP_DEFINE_BIT(Info) // I used only this one.
EnableTrace(TRUE, 0x01, TRACE_LEVEL_INFORMATION, (LPCGUID)(&MyProviderGUID), hSession).
Then it worked.
On debugging I found that
If EnableFlag is 0xff then
with TestWPPLog call goes to ETWTraceMessage -> ETWTraceMessageVA and first parameter passed to this function was 0xffff . In this scenario crash was occuring.
Even If I give EnableFlag value as 0x03 then also crash was occuring .
Crash used to occur exactly at the implementaion of TestWPPLog function.
But if EnableFlags value is 0x01 then , it worked fine.
Please can you explain this behavior.
THanks
Anshul Makkar
On Mon, Aug 3, 2009 at 11:02 PM, Alex Bendetov > wrote:
Hi,
Flags match your WPP_DEFINE_BIT definitions. For example MY_ERROR is bit 0, Info is bit 1, etc…
#define WPP_CONTROL_GUIDS <br> WPP_DEFINE_CONTROL_GUID (MyProviderGUID, (11223344, AAAA, BBBB, CCCC, DDFFFF112233), <br> WPP_DEFINE_BIT(MY_ERROR) <br> WPP_DEFINE_BIT(Info))
About your code crashing - can you attach the debugger and share the call stack at the time of the crash?
Thanks,
Alex
From: anshul makkar [mailto:xxxxx@gmail.commailto:xxxxx]
Sent: Monday, August 03, 2009 7:45 AM
To: Windows System Software Devs Interest List
Cc: Alex Bendetov
Subject: Re: [ntdev] ControlCallBack Function in WPP
Hi,
Some progress…
I looked at the EnableFlags param of the EnableTrace function but could’nt figure out what value should I give to EnableFlags param
“Provider-defined value that specifies the class of events for which the provider generates events. A provider that generates only one class of events will typically ignore this flag” . I searched for the class of event but could’nt figure out much. Further it was given that I can ignore this param and in code I was giving 0 for it, so it seemed correct.
Then I touched upon this observation in EnableTraceEx function:
“To include all events that a provider provides, set MatchAnyKeyword to zero (for a manifest-basedhttp: provider and 0xFFFFFFFF for a classichttp: provider).”
And furhter it was written that this parameter is mapped to EnableFlags param in EnableTrace function.
So now I modified my EnableTrace function to
EnableTrace(TRUE, 0xFFFFFFFF, TRACE_LEVEL_INFORMATION, LPCGUID(&MyProviderGUID), hSession);
Now a strange thing his happening…
My code crashes in main function at the line TestWppLog(Info, “%s”, “Hello World”);
As CloseSession() and WPP_CLEANUP macros statements never gets executed, I have to restart the machine to establish a new session.
But when I restart the machine I noted that the etl file has been generated and it contains a log “Hello World”.
Please can anyone explain this behavior and why the crash is happening.
Thanks
Anshul Makkar
On Sat, Aug 1, 2009 at 2:32 AM, Alex Bendetov > wrote:
The problem is most likely with enable trace:
Here is the doc: http://msdn.microsoft.com/en-us/library/aa363710(VS.85).aspx you are passing 0 for Flag (flags are things such as MY_ERROR, Info). If you step through the code with the debugger it should become more or less obvious why enble check is failing.
Thanks,
Alex
From: xxxxx@lists.osr.commailto:xxxxx [mailto:xxxxx@lists.osr.commailto:xxxxx] On Behalf Of anshul makkar
Sent: Friday, July 31, 2009 9:46 AM
To: Windows System Software Devs Interest List
Cc: Alex Bendetov
Subject: Re: [ntdev] ControlCallBack Function in WPP
ok…
If I launch the consumer application like tracelog prior to running my application then WPP logs are being logged properly in etl file. But if I try to programmatically start a session and log events to etl file, then the log file is getting generated but it doesn’t contain any events.
Here is the brief code snippet of what I am doing :
Source file
static const GUID MyProviderGUID =
{ 0x11223344, 0xAAAA, 0xBBBB, { 0xCC, 0xCC, 0xDD, 0xFF, 0xFF, 0x11, 0x22, 0x33 } };
1) Filling EVENT_PROPERTIES structure
pEvntProp->Wnode.BufferSize = ulBufferSize;
pEvntProp->Wnode.Flags = WNODE_FLAG_TRACED_GUID;
pEvntProp->Wnode.ClientContext = 1;
CopyMemory((PVOID)&(pEvntProp->Wnode.Guid),&MyTraceSession , sizeof(GUID));
pEvntProp->LogFileMode = EVENT_TRACE_FILE_MODE_CIRCULAR | ENT_TRACE_USE_PAGED_MEMORY;
pEvntProp->MaximumFileSize = 20; // 20 MB
pEvntProp->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES);
pEvntProp->LogFileNameOffset = sizeof(EVENT_TRACE_PROPERTIES) + sizeof (LOGSESSION_NAME);
StringCbCopy((LPWSTR)((char*)pEvntProp + pEvntProp->LogFileNameOffset),<br> sizeof(LOGFILE_PATH), LOGFILE_PATH);
2) StartTrace
dwStatus = StartTrace((PTRACEHANDLE )&hSession, LOGSESSION_NAME, pEventTrProp);
3) EnableTrace
dwStatus = EnableTrace(TRUE,0,TRACE_LEVEL_INFORMATION,<br> (LPCGUID)(&MyProviderGUID),hSession);
4) WPP_INIT_TRACING(L"TestWPP");
5)TestWPPLog(Info, “%s”, “Hello World”);
6) CloseSession
dwStatus = ControlTrace((TRACEHANDLE)NULL, LOGSESSION_NAME, pEventTrProp, EVENT_TRACE_CONTROL_STOP);
7)WPP_CLEANUP
Header File:
#define WPP_CONTROL_GUIDS <br> WPP_DEFINE_CONTROL_GUID (MyProviderGUID, (11223344, AAAA, BBBB, CCCC, DDFFFF112233), <br> WPP_DEFINE_BIT(MY_ERROR) <br> WPP_DEFINE_BIT(Info))
Another observation, when I open my log etl file, it says Flags as 0x7FFFFFFF and level as 0XFF.
These fields are proper if run the consumer application before logging WPP event.
Can this give some indication about error.
Or I am missing somethng in the code.
Anshul Makkar
On Fri, Jul 31, 2009 at 9:43 PM, Alex Bendetov > wrote:
WPP is a wrapper around ETW and implements the callback for you. WPP_INIT_TRACING() macro does registeration under the cover. Your other mail – the function I mentioned is auto-generated by WPP pre-processor.
Alex
________________________________
From: xxxxx@lists.osr.commailto:xxxxx [xxxxx@lists.osr.commailto:xxxxx] on behalf of anshul makkar [xxxxx@gmail.commailto:xxxxx]
Sent: Friday, July 31, 2009 8:12 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] ControlCallBack Function in WPP
Hi,
In ETW for Win2k/XP in RegisterTraceGUID() we define EventControCallback, which is called when the provider is enabled.
How to register similar type of control back in WPP environment. I tried to find the answer but could’nt . This is the only point that, I think , may be missing in my WPP implementation.
Please give some hints on that.
Thanks
Anshul Makkar
— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx></mailto:xxxxx></mailto:xxxxx></mailto:xxxxx></http:></http:></mailto:xxxxx>