473,569 Members | 2,400 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with DUMP function

3 New Member
Hi,

I am tracing this c program and I know nothing about this x_DUMP code. Can somebody explain to me ? Thanks.
Expand|Select|Wrap|Line Numbers
  1. /* header */
  2. # include <stdlib.h>
  3. # if x _DUMP
  4. # include <stdio.h>
  5. # endif
  6.  
  7. /* functions */
  8.  
  9. void function_name (int something)
  10. {
  11.  
  12. # if x_DUMP
  13. printf(" this is function a ");
  14. fflush(stdout);
  15. #endif
  16.  
  17. printf("something");
  18. }
  19.  
  20. # if x_DUMP
  21. void x_dump( )
  22. {
  23.  
  24. printf("something");
  25. printf(" something");
  26.  
  27. fflush(stdout);
  28. }
  29.  
  30. # endif
Jul 2 '07 #1
5 4257
weaknessforcats
9,208 Recognized Expert Moderator Expert
The person who wrote this code did not know how to use a debugger. So instead, a bunch of printf() statements are spattered all over the application.

Now when you build, if you define x_DUMP, all those printf() will be part of the build. Then when the program is working you build again without defining x_DUMP and all the printf() are not part of the build.

The problem with this appraoch is that the program that tested with x_DUMP defined is not the same code with x_DUMP not defined. In effect, you release untested code.

Personally, I would rip all if the x_DUMP out of the code and start using a debugger.

Don't forget that you can also use asserts.
Jul 2 '07 #2
matt287
3 New Member
Thank you so much for the explanation. Actually each of separated functions contain more than 500 lines of codes. Maybe it is easier for us to trace either is is functioning or not with the x_DUMP. The problem now is I don't know how to invoke the x-DUMP in each function. What should I do?

Thank you.
Jul 2 '07 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
You just need to define x_DUMP.


x_DUMP does not need to be a particular value.

#define x_DUMP

is all you need.

If there is a header file that is included in all of your course files you could put the #define in that header. It is preferable, though, to define x_DUMP on the command line of the compiler. That way, you don't have to remember to delete the #define and rebuild before releasing your code.

If you use Visual Studio.NET, you can define this in the project properties under C/C++ and the PreProcessor.

All this does is make the compiler command line contain -Dx_DUMP.

If you are not using Visual Studio, check out how to set preprocessor directives as property values.
Jul 2 '07 #4
matt287
3 New Member
Thank you so much. The x_DUMP already defined in the header file, x.h .

When I checked the header file , x.h , one of the line of code already defined x_DUMP as follow:

#define TTHEAP_DUMP 0

Roughly, 2 files involved: x.c and x.h

x.c call the x.h file.

coding in the x.c are as mentioned above , and the x.c also had #include <x.h>

In the x.h , it defined the x_DUMP , as #define TTHEAP_DUMP 0

There is no main function in the x.c

I don't know how to trace the program.
Jul 2 '07 #5
weaknessforcats
9,208 Recognized Expert Moderator Expert
In the x.h , it defined the x_DUMP , as #define TTHEAP_DUMP 0
This defines TTHEAP_DUMP and not x_DUMP.

What, exactly, is the code in your x.h header?

If there is no main() in x.c, then x.c is part of a larger program. If you want to debug the code in x.c, you set a debugger breakpoint and wait for the path of execution to go into x.c where it will hit your breakpoint, stop, and drop you into your debugger. Then yoyu can step through the code.
Jul 3 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3828
by: KENNY L. CHEN | last post by:
I have a table with a CHAR column which stored a COBOL redefined record. I tried to retrieve part of the field from the column with Oracle substr function. Here is one of example: The SQL/result are shown below: SQL: select length(substr(MY_COLUMN,36,8)) str_length, dump(substr(MY_COLUMN,36,8)) INFO,
1
4402
by: WangKhar | last post by:
Hi (sorry this has turned into a bit of an epic...thought I'd as the experts!) SQL 2k, sp3a. Dual xeon 2.4. 2 gig ram. everything on a 3 disk raid 5. Microsoft SQL Server 2000 - 8.00.760 (Intel X86) Enterprise Edition on Windows NT 5.0 (Build 2195: ) Problem seems to be some extended procs that seemed to be running fine
2
2543
by: D. Dante Lorenso | last post by:
First I created a function that selected the next available pin code from a table of pre-defined pin codes: CREATE FUNCTION "public"."get_next_pin_code" () RETURNS varchar AS' DECLARE my_pin_code VARCHAR; BEGIN ... /* this is the pincode we just fetched */ RETURN (my_pin_code);
2
5552
by: Mike | last post by:
Greetings, Having a major problem here. running version 8.2 on win2003 server. The problem I am having is backing up a database seems to get to the last part of the backup and then fails. This brings the whole instance down and it has to be restarted. In addition the job seems to be stuck in the TOOLSDB as if I try to delete the backup job I...
5
3865
by: NG | last post by:
Hi, We are having DB2-V7.2 DB on AIX 5.2 machine. Recently we upgraded our system to fixpack 13 and activated activate AIX asynchronous IO function. Our DB is going to crash recovery with this error 0xFFFFF707. I have attached the related details. Any suggestions is much appreciated.
9
5158
by: tym | last post by:
HELP!!! I'm going round the twist with this... I have a VB6 application which is using DAO to access a database (Please - no lectures on ADO, I know what I'm doing with DAO!!) Ok, problem is this.... importing a large csv file (189000 lines, 7 fileds per line)
15
2351
by: MLH | last post by:
In this forum, under a different subject title, I have explored the following: I want to examine each procedure in my class modules and standard modules (A97) Since the other subject title was substantially different from this objective, I have posted my topic as a new thread more appropriately titled. Question: Can someone tell me how...
26
2182
by: Bail | last post by:
I will have a exam on the oncoming friday, my professor told us that it will base upon this program. i am having troubles understanding this program, for example what if i want to add all the total calories that the user input together. determine which food has the largest calories. how do i start to modifiy the program inorder to do the...
4
4838
by: wqyuwss | last post by:
Hi, We have several core dumps in our product. These core dump can be reproduced in the same place. That is system function call std::basic_istream<char,std::char_traits<char>>::getline. The result of pstack for the core dump is > pstack core | c++filt
5
2550
by: weidongtom | last post by:
Hi, I tried to implement the Universal Machine as described in http://www.boundvariable.org/task.shtml, and I managed to get one implemented (After looking at what other's have done.) But when I use to run a UM program, I kept on getting error messages. I have used someone else's implementation and it runs fine. I have compared my code...
0
7618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7983
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6287
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3657
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
946
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.