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

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.

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.

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.

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):

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.

sudo apt-get install geany
Comments
helpfull post

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):

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.

sudo apt-get install geany

Okay.

The code file is lectic.cc

#include <argp.h>
#include <cassert>
#include <cstdio>
#include <ext/hash_map>
#include <fstream>
#include <iostream>
#include <numeric>
#include <queue>
#include <vector>
#include "CompactReport.h"
#include "NumRuns.h"
#include "PredStats.h"
#include "Progress/Bounded.h"
#include "ReportReader.h"
#include "RunsDirectory.h"
#include "RunSet.h"
#include "OutcomeRunSets.h"
#include "SiteCoords.h"
#include "classify_runs.h"
#include "fopen.h"
#include "termination.h"
#include "utils.h"

using namespace std;
using __gnu_cxx::hash_map;

////////////////////////////////////////////////////////////////////////
//
//  information about one interesting predicate
//


struct PredInfo
{
    OutcomeRunSets tek;
    OutcomeRunSets lek;
};

class PredInfos : public hash_map<PredCoords, PredInfo>
{
};

static PredInfos predInfos;

class Reader : public ReportReader
{
public:
    Reader(Outcome, unsigned);

protected:
    void handleSite(const SiteCoords &, vector<count_tp> &);

private:
    void notice(const SiteCoords &coords, unsigned, bool) const;

    const Outcome outcome;
    const unsigned runId;
};


inline
Reader::Reader(Outcome outcome, unsigned runId)
    : outcome(outcome),
      runId(runId)
{
}


static void process_cmdline(int argc, char **argv)
{
    static const argp_child children[] = {
	{ &CompactReport::argp, 0, 0, 0 },
	{ &NumRuns::argp, 0, 0, 0 },
	{ &ReportReader::argp, 0, 0, 0 },
	{ &RunsDirectory::argp, 0, 0, 0 },
	{ 0, 0, 0, 0 }
    };

    static const argp argp = {
	0, 0, 0, 0, children, 0, 0
    };

    argp_parse(&argp, argc, argv, 0, 0, 0);
};

int main(int argc, char** argv)
{
    set_terminate_verbose();
    process_cmdline(argc, argv);

    classify_runs();

    ofstream ofp("tek.txt");
    ofstream tfp("lek.txt");

    // interesting predicates in "preds.txt" order
    typedef queue<const PredInfo *> InterestingPreds;
    InterestingPreds interesting;

    {
	const unsigned numPreds = PredStats::count();
	Progress::Bounded progress("reading interesting predicate list", numPreds);
	FILE * const pfp = fopenRead(PredStats::filename);
	pred_info pi;
	while (read_pred_full(pfp, pi)) {
	    progress.step();
	    const PredInfo &info = predInfos[pi];
	    interesting.push(&info);
	}
	fclose(pfp);
    }

[B]    {
	Progress::Bounded progress("computing tek lek", NumRuns::count());
	for (unsigned runId = NumRuns::begin; runId < NumRuns::end; ++runId) {
	    progress.step();

	    Outcome outcome = 0;
	    if (is_srun[runId])
		outcome = &OutcomeRunSets::success;
	    else if (is_frun[runId])
		outcome = &OutcomeRunSets::failure;
	    else
		continue;

	    Reader(outcome, runId).read(runId);
	}
    }

[/B]    {
	Progress::Bounded progress("printing tek and lek", predInfos.size());
	while (!interesting.empty()) {
	    progress.step();
	    const PredInfo * const info = interesting.front();
	    ofp << info->tek ;
	    tfp << info->lek;
	    interesting.pop();
	}
    }

    return 0;
}

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

while (file >> runId && runId < numRuns) {
    progress.stepTo(runId);
    if (runId >= NumRuns::begin) {
        bits[runId] = 1;
        ++count;
    }
    }

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 ?

This article has been dead for over six months. Start a new discussion instead.