943,607 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2668
  • C++ RSS
Apr 6th, 2008
0

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

Expand Post »
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
Reputation Points: 10
Solved Threads: 1
Newbie Poster
ahjiefreak is offline Offline
11 posts
since Dec 2007
Apr 6th, 2008
0

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

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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005
Apr 6th, 2008
0

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

If you post your code, we could have a look if it's easy to port it to Windows.
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006
Apr 6th, 2008
0

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

Oh yea, I misread his post about VC++.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005
Apr 8th, 2008
0

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

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.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
ahjiefreak is offline Offline
11 posts
since Dec 2007
Apr 8th, 2008
0

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

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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005
Apr 8th, 2008
1

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

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):
C++ Syntax (Toggle Plain Text)
  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.
C++ Syntax (Toggle Plain Text)
  1. sudo apt-get install geany
Last edited by sinkingships7; Apr 8th, 2008 at 8:56 am.
Reputation Points: 13
Solved Threads: 2
Newbie Poster
sinkingships7 is offline Offline
14 posts
since Mar 2008
Apr 9th, 2008
0

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

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.


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):
C++ Syntax (Toggle Plain Text)
  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.
C++ Syntax (Toggle Plain Text)
  1. sudo apt-get install geany
Reputation Points: 10
Solved Threads: 1
Newbie Poster
ahjiefreak is offline Offline
11 posts
since Dec 2007
Apr 9th, 2008
0

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

you have not posted any code so how in the world do you expect anyone to tell you what's wrong ?
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005
Apr 9th, 2008
0

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

Okay.

The code file is lectic.cc
C++ Syntax (Toggle Plain Text)
  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
C++ Syntax (Toggle Plain Text)
  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.

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
Reputation Points: 10
Solved Threads: 1
Newbie Poster
ahjiefreak is offline Offline
11 posts
since Dec 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: create and work with Word document from VC++
Next Thread in C++ Forum Timeline: atol vs strtol





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC