473,396 Members | 1,814 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,396 software developers and data experts.

C++ parser for diagnostics

Hi, I think I have a nice simple requirement, but haven't been able to find
anything to meet it.

All I want to do is to insert a line before every C++ statement in my
application, so that the line is executed before the statement. The line
would be a diagnostic call which would put a line out to a file containing
the current line number etc being executed. This would give me a crude map
of what code was run, and help when I get a crash to know what was the last
line run before the crash.

I appreciate there are whole dev suites which can do this, and that I can
use things like exception handling to catch errors, but I'm after a nice
simple general purpose solution.

I figure if I can find something that will convert "break;" into
"{TRACE_MACRO;break;}" that would be handy, but it would have to know about
C++ lines spanning multiple file lines, and know when the start and ends of
funcitons are, etc, so I guess a crude C++ parser would be required.

Ideally it would read all the files in one directory and create similar
named ones in another, so I can compile the modified version of the app the
same way as the original.

Any hints or tips, or suggestions of better ways to meet my needs, would be
great.
Nov 17 '05 #1
4 1225
Hi Dave!
All I want to do is to insert a line before every C++ statement in my
application, so that the line is executed before the statement. The line
would be a diagnostic call which would put a line out to a file containing
the current line number etc being executed. This would give me a crude map
of what code was run, and help when I get a crash to know what was the last
line run before the crash.


Why do you want to make such "slow" implementation just for the case
your application crashes?
Why not just create a minidump-file in your own
Unhandled-Exception-Filter? And then you see at least the callstack and,
depending on the settings, even more infos. To make it "handy" you can
use the "symstore" program and "symsrv" to store/retrive the exe/pdb files.
This is the recommended way.

But if you want to trak it by your won, you can use the /Gh compiler
switch. This allows at least the tracking if function-enter/exit (via
_penter / _pleave)

See: /Gh (Enable _penter Hook Function) (Visual C++ Concepts)
http://msdn.microsoft.com/library/en...ore_.2f.gh.asp

This is the only supported "build-in" feature of VC.

All other apps (like Purify) are using "native" (or own-build)
instrumentation of the EXE/DLLs.

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 17 '05 #2
Thanks very much for that response.

I was thinking of this code beyond just exception handling, but the minidump
stuff sounds neat so we'll look into that too.

I guess the _penter logic can't determine the file/line/funcname of the
function being entered? I'll check it out though.

I was more thinking of a source level preprocessor to addresss this
requirement.

Thanks for the ideas though,
Dave
"Jochen Kalmbach [MVP]" <no********************@holzma.de> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Dave!
All I want to do is to insert a line before every C++ statement in my
application, so that the line is executed before the statement. The line
would be a diagnostic call which would put a line out to a file containing the current line number etc being executed. This would give me a crude map of what code was run, and help when I get a crash to know what was the last line run before the crash.
Why do you want to make such "slow" implementation just for the case
your application crashes?
Why not just create a minidump-file in your own
Unhandled-Exception-Filter? And then you see at least the callstack and,
depending on the settings, even more infos. To make it "handy" you can
use the "symstore" program and "symsrv" to store/retrive the exe/pdb

files. This is the recommended way.

But if you want to trak it by your won, you can use the /Gh compiler
switch. This allows at least the tracking if function-enter/exit (via
_penter / _pleave)

See: /Gh (Enable _penter Hook Function) (Visual C++ Concepts)
http://msdn.microsoft.com/library/en...ore_.2f.gh.asp

This is the only supported "build-in" feature of VC.

All other apps (like Purify) are using "native" (or own-build)
instrumentation of the EXE/DLLs.

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/

Nov 17 '05 #3
"Dave Williams" <do**@mail.me> wrote in message
news:Od**************@TK2MSFTNGP14.phx.gbl...
I was thinking of this code beyond just exception handling, but the minidump stuff sounds neat so we'll look into that too.

I was more thinking of a source level preprocessor to addresss this
requirement.

Dave


The DMS Software Reengineering Toolkit could do this pretty easily.
It is a full C++ parser/transformer/prettyprinter, where you can provide
custom transforms. See
http://www.semdesigns.com/Products/DMS/DMSToolkit.html.

If you follow this link: http://www.semdesigns.com/Products/TestCoverage,
there's a whitepaper on that page that discusses breifly how DMS works,
and precisely how to put instrumentation into code.
--
Ira D. Baxter, Ph.D., CTO 512-250-1018
Semantic Designs, Inc. www.semdesigns.com
Nov 17 '05 #4

Just came across this while researching penter/pleave myself.

These guys at BugSplat (http://www.bugsplatsoftware.com
have a mechanism for capturing crashes that might work for you.

cheers
Mar
-
shortblondemar
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
-----------------------------------------------------------------------

Nov 17 '05 #5

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

Similar topics

1
by: Karalius, Joseph | last post by:
Can anyone explain what is happening here? I haven't found any useful info on Google yet. Thanks in advance. mmagnet:/home/jkaralius/src/zopeplone/Python-2.3.5 # make gcc -pthread -c...
3
by: Himanshu Garg | last post by:
Hello, I am trying to pinpoint an apparent bug in HTML::Parser. The encoding of the text seems to change incorrectly if the locale isn't set properly. However Parser.pm in the directory...
3
by: Rhino | last post by:
I just stumbled on something odd but I'm not sure if it's a bug in DB2 or something that is "working as designed." I have a simple SQL PL stored procedure which is doing an "INSERT SELECT..."...
5
by: Bill Cunningham | last post by:
In comp.programming I asked for advice for writing a parser. The code someone showed me wouldn't compile. I don't know what's wrong. I just want to write the simpliest of parsers. int...
5
by: Kenneth P | last post by:
Hi, I get a Parser Error message when I try to start my asp.net app. Parser Error Message: Could not load type 'DiskoWeb.dLogin'. I have a code behind file and it's class name is dLogin. ...
1
by: Patrick | last post by:
When Tracing in ASP.NET, the IIS process (on IIs5.1) is locking on the Trace file, and I can't read the trace file without restarting the IIS: Even the following does NOT work (how could I fix...
2
by: XxLicherxX | last post by:
Hello, I tried posting this in a different VB.net newsgroup, but never got a response. Please let me know if there is a better group to post this in. Thanks. For some reason I cannot look at...
121
by: jacob navia | last post by:
Hi guys I have written this small parser to print out the functions defined in a C file. This is an example of parsing in C, that I want to add to my tutorial. Comments (and bug reports) are...
0
by: UncleRic | last post by:
Environment: Mac OS X (10.4.10) on MacBook Pro I'm a Perl Neophyte. I've downloaded the XML::Parser module and am attempting to install it in my working directory (referenced via PERL5LIB env): ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.