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

Two Questions

RJJ
Hi,

Firstly, I've just taken on a large project that looks like it's been
designed by a 2 year old. It's absolutely jam packed with very large macros
which invoke other large macros that use do/while, switch/case,
token-pasting, gotos etc. which I'm finding very difficult to debug. Is
there a piece of software/utility that will unravel/unroll/convert these
ridiculous structures into inline functions, or is there a way to "force"
the complier to single step through them in debug mode (visual c++ v6.0 on
XP).

Secondly, I trying to write some information out to a file from a dll I'm
debugging. Under what circumstances would the program seem to trace through
the code on a single step debug session but not create the file on the hard
drive (discount file space, incorrect filename etc - the code works in a
separate win32 project).

Any help appreciated,

RJJ.
Nov 14 '05 #1
3 1090
RJJ <RJ********@munged.c0m> wrote:
Firstly, I've just taken on a large project that looks like it's been
designed by a 2 year old. It's absolutely jam packed with very large macros
which invoke other large macros that use do/while, switch/case,
token-pasting, gotos etc. which I'm finding very difficult to debug. Is
there a piece of software/utility that will unravel/unroll/convert these
ridiculous structures into inline functions, or is there a way to "force"
the complier to single step through them in debug mode (visual c++ v6.0 on
XP).
Converting a macro into a function (inline or not) can quite often
be impossible. E.g.

#define MAX( a, b ) ( a ) > ( b ) ? ( a ) : ( b )

can't be converted into a function because functions always expect
typed arguments while the macro will work with whatever types of
variables you invoke it with (and some silly games you can play with
the macro, like using it with MAX(x++, yy++)m can't be reproduced by
a function).

I guess that most compilers will allows you to just proprocess the
input file, i.e. output what the compiler really is going to see
after all the include files have been inserted and all macros have
been expanded. Then you can see what's exactly happening at the
places where the macros are used and perhaps simply get rid of them
by replacing the macros in the original code by the code generated
by the preprocessor (just be careful not to replace stuff generated
due to macros from the C header files).

Since debuggers typically just rely on the original source code
macros aren't expanded, keeping you from stepping through them.
I guess your best chance would be to take the preprocessor output
(as described above) and feed that to the compiler instead of the
original code. Then you can simply step through all the code
generated for the macros. Perhaps your debugger has some commands
that let you step through thatmacro generated code without that
trick, but there you have to ask in a newsgroup that deals with the
one you're using (and debuggers are a bit off-topic here anyway;-).
Secondly, I trying to write some information out to a file from a dll I'm
debugging. Under what circumstances would the program seem to trace through
the code on a single step debug session but not create the file on the hard
drive (discount file space, incorrect filename etc - the code works in a
separate win32 project).


The only possibility I can see is to skip in the debugger all commands
that would open the file, write to it and close the file. Why can't
you just make a backup of the file you don't want overwritten and
copy it back when you're done with debugging? (I don't know what a
"seperate win32 project" is if that's supposed to be an explanation
of why you can't do that.)
Regards, Jens
--
\ Jens Thoms Toerring ___ Je***********@physik.fu-berlin.de
\__________________________ http://www.toerring.de
Nov 14 '05 #2
On Wed, 11 Aug 2004, RJJ wrote:
Hi,

Firstly, I've just taken on a large project that looks like it's been
designed by a 2 year old. It's absolutely jam packed with very large macros
which invoke other large macros that use do/while, switch/case,
token-pasting, gotos etc. which I'm finding very difficult to debug. Is
there a piece of software/utility that will unravel/unroll/convert these
ridiculous structures into inline functions, or is there a way to "force"
the complier to single step through them in debug mode (visual c++ v6.0 on
XP).
You will probably have to get specifics from a newsgroup that deals with
your compiler but there is generally a way to retain the files generated
after pre-processing. You could tell your environment to do just the
pre-processing stage and they work with the files it generates. You'd
probably want to comment out the standard header files so they don't get
pre-processed as well.
Secondly, I trying to write some information out to a file from a dll I'm
debugging. Under what circumstances would the program seem to trace through
the code on a single step debug session but not create the file on the hard
drive (discount file space, incorrect filename etc - the code works in a
separate win32 project).
If the code is there and functional you have me stumped. I'd guess that it
is also a system specific problem. A newsgroup that deals with your
environment might be able to help you better than here.

Just a wild guess, is the file being created with an absolute path? If
not, the relative directory might not be what you expect. COM objects will
use %SystemRoot% as the current address for relative addresses.
Any help appreciated,

RJJ.


--
Send e-mail to: darrell at cs dot toronto dot edu
Don't send e-mail to vi************@whitehouse.gov
Nov 14 '05 #3
RJJ wrote:
Hi,

Firstly, I've just taken on a large project that looks like it's been
designed by a 2 year old. It's absolutely jam packed with very large macros
which invoke other large macros that use do/while, switch/case,
token-pasting, gotos etc. which I'm finding very difficult to debug. Is
there a piece of software/utility that will unravel/unroll/convert these
ridiculous structures into inline functions, or is there a way to "force"
the complier to single step through them in debug mode (visual c++ v6.0 on
XP).

Secondly, I trying to write some information out to a file from a dll I'm
debugging. Under what circumstances would the program seem to trace through
the code on a single step debug session but not create the file on the hard
drive (discount file space, incorrect filename etc - the code works in a
separate win32 project).

Any help appreciated,


Hi yourself. Niether of your questions have to do with the C
programming language. You need to be somewhere people care about
Microsoft Visual Studio. Not here.

Having that off my chest, macros can be hard to read. My C compiler
allows me to write an intermediate file of the preprocessed source
in which the macros have disappeared and their results remain.

--
Joe Wright mailto:jo********@comcast.net
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 14 '05 #4

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

Similar topics

0
by: softwareengineer2006 | last post by:
All Interview Questions And Answers 10000 Interview Questions And Answers(C,C++,JAVA,DOTNET,Oracle,SAP) I have listed over 10000 interview questions asked in interview/placement test papers for...
0
by: connectrajesh | last post by:
INTERVIEWINFO.NET http://www.interviewinfo.net FREE WEB SITE AND SERVICE FOR JOB SEEKERS /FRESH GRADUATES NO ADVERTISEMENT
2
by: freepdfforjobs | last post by:
Full eBook with 4000 C#, JAVA,.NET and SQL Server Interview questions http://www.questpond.com/SampleInterviewQuestionBook.zip Download the JAVA , .NET and SQL Server interview sheet and rate...
4
by: Drew | last post by:
I posted this to the asp.db group, but it doesn't look like there is much activity on there, also I noticed that there are a bunch of posts on here pertaining to database and asp. Sorry for...
8
by: Krypto | last post by:
Hi, I have used Python for a couple of projects last year and I found it extremely useful. I could write two middle size projects in 2-3 months (part time). Right now I am a bit rusty and trying...
0
by: ramu | last post by:
C# Interview Questions and Answers8 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers8.html C# Interview Questions and Answers7...
1
by: ramu | last post by:
C# Interview Questions and Answers8 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers8.html C# Interview Questions and Answers7...
0
by: ramu | last post by:
C# Interview Questions and Answers8 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers8.html C# Interview Questions and Answers7...
0
by: reema | last post by:
EJB Interview Questions http://interviewdoor.com/technical/EJB-Interview-Questions.htm CSS Interview Questions http://interviewdoor.com/technical/CSS-Interview-Questions.htm C Interview Questions...
0
by: reema | last post by:
EJB Interview Questions http://interviewdoor.com/technical/EJB-Interview-Questions.htm CSS Interview Questions http://interviewdoor.com/technical/CSS-Interview-Questions.htm C Interview Questions...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.