How to debug a C++ code which only runs on Fedora platform

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2007
Posts: 11
Reputation: ahjiefreak is an unknown quantity at this point 
Solved Threads: 1
ahjiefreak ahjiefreak is offline Offline
Newbie Poster

How to debug a C++ code which only runs on Fedora platform

 
0
  #1
Apr 6th, 2008
Hi,

I recently has a C++ code which only run on Fedora Platform.

I wanted to run debugging on these code as I came across some unexplainable
scenario output.

Can anyone suggest how could I use any debugger? I tried to use GNU GDB but then the code I am dealing now are involving multiple files background. So, I am not too sure how to debug in this matter.

I also thought of porting to Visual C++, but I am not so sure how to.

Please advise. Thanks..
Rgrds,
Jason
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,413
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1470
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: How to debug a C++ code which only runs on Fedora platform

 
0
  #2
Apr 6th, 2008
you can't use VC++ on Fedora because VC++ only runs on MS-Windows.

I have not used gdb in years but it should be able to handle a multi-file program with ease.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,861
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 301
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Roasting Maven

Re: How to debug a C++ code which only runs on Fedora platform

 
0
  #3
Apr 6th, 2008
If you post your code, we could have a look if it's easy to port it to Windows.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,413
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1470
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: How to debug a C++ code which only runs on Fedora platform

 
0
  #4
Apr 6th, 2008
Oh yea, I misread his post about VC++.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 11
Reputation: ahjiefreak is an unknown quantity at this point 
Solved Threads: 1
ahjiefreak ahjiefreak is offline Offline
Newbie Poster

Re: How to debug a C++ code which only runs on Fedora platform

 
0
  #5
Apr 8th, 2008
Hi,

I tried to debug using GDB but since the code is large and wrap-up with Make; it cant point to the exact location of gdb.

The error which I get is cannot read run count from ./stamp-labels

For your information, the source file relates to multiple files. I am not so sure you guys would mind help me look at it.

If so, you could let me know and I try to make it available. I have been stucked for months and depressed.

For your information, I try before to add some extra code inside but it doesnt work. And I try to understand the code but couldnt.

Please advise. Thanks.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,413
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1470
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: How to debug a C++ code which only runs on Fedora platform

 
0
  #6
Apr 8th, 2008
vc++ 2008 has an excellent debugger -- you don't need dbg for anything. just learn to use the debugger that's build into the vc++ IDE.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 14
Reputation: sinkingships7 is an unknown quantity at this point 
Solved Threads: 2
sinkingships7 sinkingships7 is offline Offline
Newbie Poster

Re: How to debug a C++ code which only runs on Fedora platform

 
1
  #7
Apr 8th, 2008
I can't be completely positive, but I'm almost sure that VC++ runs well under WINE, the windows duplication layer for Linux. I'm an Ubuntu user myself, but Fedora is debian based, so this should work (type it in the terminal):
  1. sudo apt-get install wine
That should install WINE for you. If not, check for the Fedora code for it.

Download VC++ and right-click the .exe, choosing open with. Select WINE Windows Emulator from the menu presented, and the install should start. Make sure it's VC++ 2005, as I'm pretty sure WINE doesn't yet have support for 2008.

I can't help with the debugging part, but that should get VC++ up and running for you so you can follow the advice of the other people on this forum.


EDIT: If you're not too apt to port, and would rather just debug, I suggest Geany. It's a great C++ IDE (as well as many others) and has a very easy to follow debugging tool built in.
  1. sudo apt-get install geany
Last edited by sinkingships7; Apr 8th, 2008 at 8:56 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 11
Reputation: ahjiefreak is an unknown quantity at this point 
Solved Threads: 1
ahjiefreak ahjiefreak is offline Offline
Newbie Poster

Re: How to debug a C++ code which only runs on Fedora platform

 
0
  #8
Apr 9th, 2008
HI.

Thanks. I try download Eclipse and execute the debugger. However, it still gives me the same limited error which is:

"cannot read count from ./stamp-labels"

I am stuck and do not know how to proceed with this. The file of stamp-labels contain "100" and I just do not know what other debugging ways to append this "100" in order for debugging to work.

Please advise. Appreciate alot.


Originally Posted by sinkingships7 View Post
I can't be completely positive, but I'm almost sure that VC++ runs well under WINE, the windows duplication layer for Linux. I'm an Ubuntu user myself, but Fedora is debian based, so this should work (type it in the terminal):
  1. sudo apt-get install wine
That should install WINE for you. If not, check for the Fedora code for it.

Download VC++ and right-click the .exe, choosing open with. Select WINE Windows Emulator from the menu presented, and the install should start. Make sure it's VC++ 2005, as I'm pretty sure WINE doesn't yet have support for 2008.

I can't help with the debugging part, but that should get VC++ up and running for you so you can follow the advice of the other people on this forum.


EDIT: If you're not too apt to port, and would rather just debug, I suggest Geany. It's a great C++ IDE (as well as many others) and has a very easy to follow debugging tool built in.
  1. sudo apt-get install geany
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,413
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1470
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: How to debug a C++ code which only runs on Fedora platform

 
0
  #9
Apr 9th, 2008
you have not posted any code so how in the world do you expect anyone to tell you what's wrong ?
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 11
Reputation: ahjiefreak is an unknown quantity at this point 
Solved Threads: 1
ahjiefreak ahjiefreak is offline Offline
Newbie Poster

Re: How to debug a C++ code which only runs on Fedora platform

 
0
  #10
Apr 9th, 2008
Okay.

The code file is lectic.cc
  1. #include <argp.h>
  2. #include <cassert>
  3. #include <cstdio>
  4. #include <ext/hash_map>
  5. #include <fstream>
  6. #include <iostream>
  7. #include <numeric>
  8. #include <queue>
  9. #include <vector>
  10. #include "CompactReport.h"
  11. #include "NumRuns.h"
  12. #include "PredStats.h"
  13. #include "Progress/Bounded.h"
  14. #include "ReportReader.h"
  15. #include "RunsDirectory.h"
  16. #include "RunSet.h"
  17. #include "OutcomeRunSets.h"
  18. #include "SiteCoords.h"
  19. #include "classify_runs.h"
  20. #include "fopen.h"
  21. #include "termination.h"
  22. #include "utils.h"
  23.  
  24. using namespace std;
  25. using __gnu_cxx::hash_map;
  26.  
  27. ////////////////////////////////////////////////////////////////////////
  28. //
  29. // information about one interesting predicate
  30. //
  31.  
  32.  
  33. struct PredInfo
  34. {
  35. OutcomeRunSets tek;
  36. OutcomeRunSets lek;
  37. };
  38.  
  39. class PredInfos : public hash_map<PredCoords, PredInfo>
  40. {
  41. };
  42.  
  43. static PredInfos predInfos;
  44.  
  45. class Reader : public ReportReader
  46. {
  47. public:
  48. Reader(Outcome, unsigned);
  49.  
  50. protected:
  51. void handleSite(const SiteCoords &, vector<count_tp> &);
  52.  
  53. private:
  54. void notice(const SiteCoords &coords, unsigned, bool) const;
  55.  
  56. const Outcome outcome;
  57. const unsigned runId;
  58. };
  59.  
  60.  
  61. inline
  62. Reader::Reader(Outcome outcome, unsigned runId)
  63. : outcome(outcome),
  64. runId(runId)
  65. {
  66. }
  67.  
  68.  
  69. static void process_cmdline(int argc, char **argv)
  70. {
  71. static const argp_child children[] = {
  72. { &CompactReport::argp, 0, 0, 0 },
  73. { &NumRuns::argp, 0, 0, 0 },
  74. { &ReportReader::argp, 0, 0, 0 },
  75. { &RunsDirectory::argp, 0, 0, 0 },
  76. { 0, 0, 0, 0 }
  77. };
  78.  
  79. static const argp argp = {
  80. 0, 0, 0, 0, children, 0, 0
  81. };
  82.  
  83. argp_parse(&argp, argc, argv, 0, 0, 0);
  84. };
  85.  
  86. int main(int argc, char** argv)
  87. {
  88. set_terminate_verbose();
  89. process_cmdline(argc, argv);
  90.  
  91. classify_runs();
  92.  
  93. ofstream ofp("tek.txt");
  94. ofstream tfp("lek.txt");
  95.  
  96. // interesting predicates in "preds.txt" order
  97. typedef queue<const PredInfo *> InterestingPreds;
  98. InterestingPreds interesting;
  99.  
  100. {
  101. const unsigned numPreds = PredStats::count();
  102. Progress::Bounded progress("reading interesting predicate list", numPreds);
  103. FILE * const pfp = fopenRead(PredStats::filename);
  104. pred_info pi;
  105. while (read_pred_full(pfp, pi)) {
  106. progress.step();
  107. const PredInfo &info = predInfos[pi];
  108. interesting.push(&info);
  109. }
  110. fclose(pfp);
  111. }
  112.  
  113. [B] {
  114. Progress::Bounded progress("computing tek lek", NumRuns::count());
  115. for (unsigned runId = NumRuns::begin; runId < NumRuns::end; ++runId) {
  116. progress.step();
  117.  
  118. Outcome outcome = 0;
  119. if (is_srun[runId])
  120. outcome = &OutcomeRunSets::success;
  121. else if (is_frun[runId])
  122. outcome = &OutcomeRunSets::failure;
  123. else
  124. continue;
  125.  
  126. Reader(outcome, runId).read(runId);
  127. }
  128. }
  129.  
  130. [/B] {
  131. Progress::Bounded progress("printing tek and lek", predInfos.size());
  132. while (!interesting.empty()) {
  133. progress.step();
  134. const PredInfo * const info = interesting.front();
  135. ofp << info->tek ;
  136. tfp << info->lek;
  137. interesting.pop();
  138. }
  139. }
  140.  
  141. return 0;
  142. }
Basically I am trying to understand some other people's code which is written in C++. This is basically a system which generates two files; tek.txt and lek.txt which are executed with 100 runs (100 test inputs). It generates 100 folder which have Outcome file and Label file.(I attached as folder 0, 1, 2). Supposed there are 100 of these folders with different values in these files. The code which generate these numbers is from lectic.cc.

However, I could not understand how these crunchy numbers are generated.
My initial guess is this function actually generated data for tek.txt and lek.txt.I do not understand how the numbers are generated especially with lek.txt ; the entry of "S: " is empty. Perhaps my understanding of the code is wrong. As what I understand so far, it first call cairns.cc file which gather information and do the counts in it.In this file, it has read_run function. In this function, I am not too sure how the while loop of
  1. while (file >> runId && runId < numRuns) {
  2. progress.stepTo(runId);
  3. if (runId >= NumRuns::begin) {
  4. bits[runId] = 1;
  5. ++count;
  6. }
  7. }
are doing. Does it means assigning value of 1 to every numRuns?
If that is the case, back in the file lectic.cc, every single is_srun[run_id] and is_frun[run_id] are always 1.

Perhaps its too vague after seeing the code, Do let me know because the original files are too large unless I can try upload in some server and you guys could download to see whole picture of it.

THanks.

Originally Posted by Ancient Dragon View Post
you have not posted any code so how in the world do you expect anyone to tell you what's wrong ?
Last edited by Narue; Apr 9th, 2008 at 1:51 pm. Reason: Added code tags
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC