Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » the debugger
Re: the debugger [message #18716 is a reply to message #17358] Sat, 18 October 2008 12:40 Go to previous messageGo to previous message
cocob is currently offline  cocob
Messages: 156
Registered: January 2008
Experienced Member
Here a little code to solve my problem of printing values in STL vectors. I think it would be great to improve this to print values for other types.

String Gdb::GetVarType(const String& var)
{
	String type = FastCmd("ptype " + var);
	StringStream ss(type);
	String ln = ss.GetLine();
	const char *s = strchr(ln, '=');
	if(s) {
		s++;
		while(*s == ' ')
			s++;
		return String(s);
	}
	else
		return "";
}

String Gdb::TransformExp(const String& exp)
{
	String newExp;
	int b = exp.Find('[');
	if(b>0) {
		int e = exp.Find(']', b+1);
		if(b>0) {
			// we have a *[*] expression so evaluate the index
			String index = exp.Mid(b+1, e-b-1);
			index = Print(index);
			String tab = exp.Mid(0, b);
			String tabType = GetVarType(tab);
			if(tabType.GetLength()==0) return exp;
			if(tabType.Left(17)=="class std::vector") {
				newExp << "*(" << tab << "._M_impl._M_start+" << index << ")";
				return newExp;
			} else {
				newExp << tab << "[" << index << "]";
				return newExp;
			}
		}
	}
	
	return exp;
}

String Gdb::Print(const String& exp)
{
	String newExp = TransformExp(exp);
	String q = FastCmd("print " + newExp);
	StringStream ss(q);
	String ln = ss.GetLine();
	const char *s = strchr(ln, '=');
	if(s) {
		s++;
		while(*s == ' ')
			s++;
		return DataClean(s);
	}
	else
		return DataClean(ln);
}

[Updated on: Sat, 18 October 2008 19:05]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: A problem with UPP application scale . . . UPP exonerated, the rest of the story.
Next Topic: Project isn't portable from windows to linux
Goto Forum:
  


Current Time: Tue Apr 16 14:30:45 CEST 2024

Total time taken to generate the page: 0.02200 seconds