Click here to Skip to main content
15,667,904 members
Please Sign up or sign in to vote.
3.33/5 (3 votes)
See more:
I am working in c++ code that is developed and maintained in unix. I need to develop a UI based debugger something like visual studio which will help me in faster debugging and provides all information like stack frame, watch etc. We currently have GDB to debug code in unix.But it is not developer friendly. So I am looking for some open source upon which I can have some add-on to have a debugger with good UI and that will help me greatly in understanding the code flow as well.

Regards, Deepika .
Updated 14-May-12 20:58pm
enhzflep 15-May-12 1:10am    
That was big fat 1 from me. (see below for added solution)
Reason? Title was FAR too long and was in fact, the same as the question body.
I have changed the question title to something more appropriate.

Oh, and go ahead - download the source code for GDB. There's a great start.

Another thing to look into would be "Rasta Ring 0 Debugger", though it appears not to have been maintained since 2006 or so.

Ps - Hope you're ready for a nasty, bumpy ride. Writing a debugger is no easy feat!
Sergey Alexandrovich Kryukov 15-May-12 3:19am    
My 5. Could be a fair answer.
enhzflep 15-May-12 3:50am    
Thank-you SA. New solution provided in response to updated question.
Sandeep Mewara 15-May-12 2:00am    
If you have anything to add, use 'Improve Question' link to edit/update the question.

Look, I'm just going to come straight out and ask..

Do you actually have any of your own code and experience? OR Are you trying to understand how _someone else's_ website works?

Are you familiar with AJAX? (Asynchronous JavaScript And Xml)

Except for plugins like Flash Player, there is no C++ code executed on the client machine. It all happens on the server. Even then, there is most often nothing other than XAMPP or ASP.NET running natively, everything else is a script like ASP, VBScript, PHP.

That is how pages refresh/update their content.
1) User clicks button to do 'something'
2) JavaScript on the webpage responds to this click.
3) Javascript sends request to server for relevant information
4) Server finds information, sends reply
5) Javascript on the page receives information
6) Javascript on page updates/adds the page contents with the new info.

I created a webpage for viewing Student timetables at a college I worked at. The timetables were held inside a database that was internal to a (Windows) native application. This application exposed functionality via COM.

When the web-page was loaded, an AJAX request was sent, that asked for a list of all the student IDs. The response was in the form of the HTML needed for a ListBox that contained all of the IDs.

Then, when you selected a student & hit "Get Timetable", Javascript on the webpage got the selected item's index from the ListBox. It then got the text(the student's ID) from the ListBox using this index. For this example lets say ID=12345678 From there, it sent a request to retrieve the page located at "textTimetable.php?id=12345678&type=student"
Because it's a PHP page, it doesn't just get spewed out from the server like an HTML page or an image, it gets examined and executed. The file textTimetable.php then looks to see that it has the variables "id" and "type" it then creates a COM object that allows it to communicate with the Timetable Scheduling Software (Syllabus Plus by Scientia) It finds the relevant student, gets their list of classes(and their times/days). From there, it sorts the classes by start-time, before printing the classes out, each on a separate line. :phew! what a mouthful:

When the response is received from textTimetable.php it is inserted as the innerHTML of the target container on the HTML page.

I also have pdfTimetable.php and pngTimetable.php - these are essentially identical to textTimetable.php, with the exception of the exact format of the content they return. It is essentially same process whether I want an HTML table, a PNG or an (inline) PDF - albeit with minor differences to the way it's inserted into the page. The HTML can just go as the innerHTML of a DIV, the (url of the) PNG get set as the URL of an image on the page, whereas the PDF gets set as the source of an IFrame.
I am aware of no means by which the PHP running on the server may be visually debugged as it is running. The Javascript, certainly.

Now then, if your app is filling the role of Syllabus Plus - you will need to Attach To Process - after some action on the page has caused your code to be called, and while it's still running. Once done, one would pause execution and begin single-stepping.

Ah-hah! Found it. Here's the Javascript on the web-page that is called when I hit the "GetClassList" button. Also, the content of the PHP page that it requests.
(Man, what a tiring answer. Think I need a coffee or 4 and a 6 pack of V) :D
//	handler for the button that displays the class list
function loadClassList()
	var actName, actId, dayNum, weekNum, dayStr, weekStr, str;
	var dayIn=byId("dayList"), weekIn=byId("weekList"), actIn=byId("actListDaily");
	weekNum = weekIn.options.selectedIndex;

	dayStr = dayIn.options[dayIn.options.selectedIndex].text;
	actName = actIn.options[actIn.options.selectedIndex].text;
	actId = actIn.options[actIn.options.selectedIndex].value;

	byId("blueHeaderBarTitle").innerHTML = actName;

	var day, week, str, isOk, url;

	dayNum = dayIn.options.selectedIndex;
	weekNum = weekIn.options.selectedIndex;

	// strip off the HASH symbol - it screws up the HTTP 'GET' process - we'l stick it back on at the  other end (getStudentList.php)
	actId = actId.replace("#", "");

	// request the SELECT list of the day's activities
	url = "getStudentList.php";
	url += "?dayNum="+dayNum;
	url += "&weekNum=" + weekNum;
	url += "&actId=" + actId;

	byId("classListHolder").innerHTML = '<div class="progBar2">LOADING</div>';
	myGetAjaxResponseWithCallback(byId("classListHolder"), url, function(){doScrollBars(byId("infoBoxHolder"));});

	$dayNum = $_GET['dayNum'];
	$weekNum = $_GET['weekNum'];
	$actId = $_GET['actId'];

	$actId = sprintf('#%s', $actId);

	1. find the activiy
	2. get it's list of student sets.
	3. iterate through each student set
	4.	 get it's list of students
	5.   add each one to the master list of students
	6. Return the list
	$app=new COM('Splus.application') or die('Cannot start syllabus for you');
	$mCollege = $app->ActiveCollege;
	$mActivities = $mCollege->Activities;

	$nameArray = array();
	$studentArray = array();

	$myAct = $mActivities->Find($actId, "", "");
	$curAct = $myAct[1];
	catch (Exception $e)
		printf('<p>You need to select a valid activity first<p>');

	foreach ($myAct as $curAct)
		$myStudentSets = $curAct->StudentSets;

		foreach ($myStudentSets as $curSet)
				if ($curSet->RealSize() != 0)
				foreach ($curSet->Students as $curStudent)
					$studentArray[] = new sylStudent($curStudent->Name, $curStudent->HostKey, $curStudent->Department, $curStudent->Email, $curStudent->Gender);
	$didSort = usort($studentArray, array('sylStudent', '_cmpStudentIdAsc'));

class sylStudent
	var $name;				// (string) studentName
	var $id;				// (string) id
	var $department;		// (string) department
	var $email;				// (string) email addr
	var $gender;			// (bool) isMale

	function sylStudent($name, $id, $department, $email, $gender)
		$this->name = $name;
		$this->id = $id;
		$this->department = $department;
		$this->email = $email;
		$this->gender = $gender;

	// compare function. compare by student ID
	function _cmpStudentIdAsc($item1, $item2)
		return ($item1->id < $item2->id) ? -1 : 1;
	// compare function. compare by student Name
	function _cmpStudentNameAsc($item1, $item2)
		return (strcmp($item1->name, $item2->name)<0) ? -1 : 1;

	// compare function. compare by student email
	function _cmpStudentEmailAsc($item1, $item2)
		return (strcmp($item1->email, $item2->email)<0) ? -1 : 1;

function makeInnerContentPHP($name, $id, $department, $email, $gender, $rowNum)
	$genderStr = array('Male', 'Female');
	if ($gender<>0)
	$str = sprintf("<div id=\"sc%d\" class='switchcontent'>", $rowNum);
	$str = sprintf('%s%s', $str, '<table>');
	$str = sprintf('%s%s', $str, "<tr><td rowspan=\"6\"class=\"studPic\"><img src=\"$imgSrc\" alt=\'$imgSrc\'></td><th>Name</th><td>$name</td></tr>");
	$str = sprintf('%s%s', $str, "<tr><th>ID:</th><td>$id</td></tr>");
	$str = sprintf('%s%s', $str, "<tr><th>Email:</th><td>$email</td></tr>");
	$str = sprintf('%s%s', $str, "<tr><th>Department:</th><td>$department</td></tr>");
	$str = sprintf('%s%s', $str, "<tr><th>Gender:</th><td>$genderStr[$gender]</td></tr>");
	$str = sprintf('%s%s', $str, "<tr><th>Timetable:</th><td><a onclick=\"showTextTt($id);\">html</a> <a onclick=\"showPdfTt($id);\">pdf</a> <a onclick=\"showPngTt($id);\">png</a></td></tr>");
	$str = sprintf('%s%s', $str, '</table></div>');
	return $str;

function makeOuterContentPHP($name, $id, $email, $rowNum)
	$imgStr = "bulDown.gif";
	$str = sprintf('%s', "<div id='row$rowNum' class='row1'><div class='imgCell'><img alt=\"bullet\" id=\"bul$rowNum\"src=\"$imgStr\"></div><div onclick='expandContent(\"sc$rowNum\", \"bul$rowNum\", \"row$rowNum\");'");
	$str = sprintf('%s%s', $str, "class=\"authcateCell\" title=\"click here to expand/contract\">$id</div>");
	$str = sprintf('%s%s', $str, "<div class=\"nameCell\">$name</div>");
	$str = sprintf('%s%s', $str, "<div class=\"emailCell\">$email</div>");
	$str = sprintf('%s%s', $str, '</div>');
	return $str;

function makeOuterContentPHP2($name, $id, $email, $rowNum)
	$imgStr = "bulRight.gif";
	$str = sprintf('%s', "<div id=\"row$rowNum\" class=\"row1\">");
	$str = sprintf('%s%s', $str, "<table cellspacing='0' cellpadding='0'>\n");
		$str = sprintf('%s%s', $str, '<tr>');
			$str = sprintf('%s%s', $str, "<td class=\"imgCell\"><img alt=\"bullet\" id=\"bul$rowNum\" src=\"$imgStr\"></td>");
			$str = sprintf('%s%s', $str, "<td class='authcateCell' onclick='expandContent(\"sc$rowNum\", \"bul$rowNum\", \"row$rowNum\");'>$id</td>");
			$str = sprintf('%s%s', $str, "<td class=\"nameCell\">$name</td>");
			$str = sprintf('%s%s', $str, "<td class=\"emailCell\">$email</td>");
		$str = sprintf('%s%s', $str, '<tr>');
	$str = sprintf('%s%s', $str, '</table></div>');
	return $str;

function makeAccordianEntryPHP($name, $id, $email, $gender, $department, $rowNum)
	$str1 = makeInnerContentPHP($name, $id, $department, $email, $gender, $rowNum);
	$str2 = makeOuterContentPHP2($name, $id, $email, $rowNum);
	return sprintf('%s%s', $str2, $str1);

function createAccordianPHP($studentArray)
		printf('<div id=\'contentList\' class=\'contentList\'>');
		for ($i=0; $i<count($studentArray); $i++)
			printf('%s', makeAccordianEntryPHP($studentArray[$i]->name, $studentArray[$i]->id, $studentArray[$i]->email, $studentArray[$i]->gender, $studentArray[$i]->department, $i));


// takes a 'LastName, Given Names' format name and modifies it to 'Given Names LastName'
function fixName($name)
	$commaPos = strpos($name, ',');
	$spacePos = $commaPos;
	$christianNamePos = $spacePos+1;
	$newStr = substr($name, $christianNamePos);
	$newStr = sprintf('%s %s', $newStr, substr($name, 0, $commaPos));
	return $newStr;
Share this answer
Sergey Alexandrovich Kryukov 17-May-12 16:13pm    
This is impressive effort, but you messed up HTML code pretty well here, because you have forgotten to escape <> with XML/HTML entities &lt; &gt;.
I tried to fix it, but you need to check up.
enhzflep 17-May-12 23:10pm    
Thank-you very much SA!
Oops, sure did mess it up, didn't I..
There was still something a little odd, so I just tried using Notepad++ to escape problem characters ( TextFX->TextFX Convert->Encode HTML (&<>") ), think I'll be using this tool in the future!
This isn't an answer as such, but rather a working demonstration of the result of the above code.

Here is an example of the (functional) output of getStudentList.php

Copy all of the below into a new file, name it someFile.html then open in your browser.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>Test Page</title>

<script type="text/javascript">
function expandContent(idDiv, idImg, rowId)
    var div, img, row;

    div = document.getElementById(idDiv);
    img = document.getElementById(idImg);
    row = document.getElementById(rowId);

    // content is expanded already. Contract it
    if ("block")
        row.className = "row1Hover";

    // content needs expansion
        row.className = "rowOpenHover";

function newElemClass(strType, strClass)
    var elem = document.createElement(strType);
    elem.className = strClass;
    return elem;
function byId(elem){return document.getElementById(elem);}

function addItemToAccordian(authcate, name, email, content)
    var accordian = byId("contentList");
    var numKids = accordian.childNodes.length;
//  alert(numKids);

    numKids /= 2;
    var rowNum = parseInt(numKids);

    var headingDiv, div1, div2, div3, div4, secretContent;
    headingDiv = newElemClass("div", "row1"); = "row"+rowNum;
    div2 = newElemClass("div", "authcateCell"); div2.innerHTML = authcate;
    headingDiv.onmouseover = function(){headingDiv.className += "Hover"; = "underline";}
    headingDiv.onmouseout =
            var name = headingDiv.className, nameLen;
            nameLen = name.length;
            name = name.substr(0, nameLen-5);
            headingDiv.className = name;
   = "";
    div1 = newElemClass("div", "imgCell");
    div1.innerHTML="<img id='bul"+rowNum+"' src='bluebullet.gif'>";

    div2 = newElemClass("div", "authcateCell"); div2.innerHTML = authcate;
    div2.onmouseover = function(){"bold";"black";"underline";div2.focus();}
    div2.onmouseout = function(){"normal";"";"";}
    div2.onclick = function()
                        var rn=rowNum;
                        expandContent("sc"+rn, "bul"+rn, "row"+rn);
    div3 = newElemClass("div", "nameCell"); div3.innerHTML=name;
    div4 = newElemClass("div", "emailCell"); div4.innerHTML=email;
    secretContent = newElemClass("div", "switchcontent"); = "sc"+rowNum;
    secretContent.innerHTML = content;



function init()
    var i, content;
    for (i=1; i<=10; i++)
        addItemToAccordian("Student"+i, "Name, Student", "", content)

function makeInnerContent()
    var str;
    var num = 4;
    if (num.toString().length < 2)
        num = ("0"+num.toString());
    var imgStr = "thumbs/tn"+num+".jpg";

    str = "<table>"
    str += "<tr><td rowspan='7'><img src='"+imgStr+"'></td><th>Name:</th><td>Roxie</td></tr>";
    str += "<tr><td></td><td></td></tr>";
    str += "<tr><th>Age:</td><td>20</td></tr>";
    str += "<tr><th>Gender:</th><td>Female</td></tr>";
    str += "<tr><th>Country:</th><td>Singapore</td></tr>";
    str += "</table>";
    return str;


.switchcontent {
  border: 1px solid #adadac;
  display: none;
  text-indent: 2em;
  width: 94%;
  left: 4%;
  position: relative;
  padding: 4px;
  background-color: #EFEFEF;
  margin-bottom: 15px;
.row1, .rowOpen {
  background-repeat: repeat-x;
  background-image: url(contentbgLight2.png);
  height: 24px;

.row1Hover, .rowOpenHover{
  background-repeat: repeat-x;
  background-image: url(contentbgLight3.png);
  height: 24px;

.rowOpen {
  background-image: url(contentbgLight.png);
  margin-top: 5px;

    margin-top: 5px;
.row1:hover, .rowOpen:hover{
  background-image: url(contentbgLight3.png);
    width: 20px;
    padding-top: 8px;
    margin: 0px;

.authcateCell {
    cursor: pointer;
    width: 100px;
    color: #888888;
    position: absolute;
    left: 20px;
    width: 150px;
    position: absolute;
    left: 120px
width: 180px;
position: absolute;
left: 270px;
.rowOpen:hover .authcateCell, .row1:hover .authcateCell{
  text-decoration: underline;
.authcateCell:hover {
  color: #000000;
  text-decoration: italic;
  font-weight: bold;
.contentList {
  border-style: solid;
  padding: 4px;
  border-color: #8c8c8c;
/*  height: 400px; */
  width: 700px;
  left: 25%;
  position: absolute;
  overflow-y: auto;
body {
  width: 850px;
    text-align: right;
.switchcontent img{
    background-color: white;
    padding: 4px;
    padding-bottom: 16px;
    border: 1px solid #888888;


<body onload = "init();">
<div id="weekListHolder"> </div>
<div id="contentList" class="contentList"></div>

Share this answer
Okay then, with the extra information added to your question it becomes far easier to be confident that one may provide a useful solution for you. I've also changed my vote, the extra clarity deserves it. :)

On further reading, my (new) understanding is that your need is actually to aquire a user friendly debugger that works under unix.

Previously, the question was phased in such a way that I understood you to be interested in developing a user friendly debugger.

Going on this new assumption, I would ask if you have investigated
  • Eclipse CDT
  • DDD
  • KDevelop

All of them have visual interfaces, and in the case of DDD very nice diagramming of structures such as linked lists.

Eclipse doesn't appear to offer a (plain)unix distro, only offering for Linux, Windows and Mac OSX.

DDD is only available as source, so you build it yourself - can't see anything that precludes it's use on unix though.

KDevelop is only available for Linux

Looks like the road may not be so bumpy after-all. :)
Share this answer
DeepikaMP 15-May-12 4:45am    
Hi enhzflep,

Thanks for your response I'm actually looking into a kind of debugger that bring me a simulator of my application.

For example, i ve a web page with some buttons. so when i set few break points in my code and run it, i ll be getting the web page and on clicking the button should hit the break points present in the flow.

So, I want to understand how to get started with this. I have the code base in unix. But how to integrate it with the windows UI debugger and proceed further.

Please correct me if any of my statements is wrong.

Thanks in advance !

enhzflep 15-May-12 4:57am    
Gday DeepikaMP,

I'm not so sure I understand your requirements. As you're likely aware, the debuggers I linked to are designed for debugging native code - that is code that is executed (without interpretation) on the cpu.

Now that you're speaking about web-pages, I'm no longer sure of your requirements. I think I understand you to be saying that action performed on
a webpage will cause your (c++, unix native) program to be invoked. I'm imagining something like a Flash container on a webpage, a container object you've developed yourself.

If this is the case, I suppose that you don't have the chance to start the program from the command-line. With this in mind, opening your program in the debugger before using the web-page will mean a different instance of your program will be running in (a) the debugger & (b) under the web-browser.

In that case, I suppose you would need to use a debugger that is able to Attach to (a running) Process. I'm not familiar with these debuggers - haven't used GDB in close to 15 years.

Is this the kind of thing you're after?
DeepikaMP 15-May-12 12:15pm    

First lemme elaborate the requirement to get expected solution :)

1) My application is a web based application.For instance. consider any online shopping app like amazon,ebay
2) I have a native code in unix. So I need a IDE that runs in windows. I get the code source to local and integrate with the windows IDE
3) Now, when I compile and run my code, the application page opens up. As in example the first page that displays the list of items of merchants
4) I have set some break points in my code. Now I need to find which part of code gets hit when I click the checkout button selecting any item.
5) From that break point, I need to continue the debugging by stepping into the functions and understand the code flow on my own which also gives the all details like stack frame, watch etc

My requirement is as follows:
a) which IDE could I use for this purpose?
b) how to integrate the code present in local to the IDE

Hope this gives better explanation :)

enhzflep 15-May-12 12:24pm    
Hey there.

Couple of questions, to ensure we're speaking about the same thing here

1) Web-based (runs in browser) or web-enabled(native code, uses internet without browser)?

2) I have a native code in unix. So I need a IDE that runs in windows.
Windows the operating system, or 'windows' as in "GUI app"?

b) how to integrate the code present in local to the IDE.
In 'local'.. What do you mean by local?

Definitely more clear now. Just a couple uncertainties. :)
DeepikaMP 15-May-12 12:57pm    
yes.. please find the answer below:

1) web based application
2) 'windows' as in 'GUI' app
3) I get my code to local disk drive using WinSCP or FileZilla

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900