GDB print NTL variable's value

An NTL discussion forum

GDB print NTL variable's value

Postby guglielmoL » Wed Mar 02, 2016 10:45 pm

How to find/print ZZ or ZZX variable's value using GDB debugger ?
guglielmoL
 
Posts: 1
Joined: Wed Mar 02, 2016 10:32 pm

Re: GDB print NTL variable's value

Postby victorshoup » Wed Mar 02, 2016 11:15 pm

I'm no expert, but I was told it is possible to build some kind of plug in. If you find out how, let me know. Better yet, make one that I can include in a future release.
victorshoup
Site Admin
 
Posts: 32
Joined: Mon Jan 13, 2014 3:18 am

Re: GDB print NTL variable's value

Postby peiworld » Thu Mar 03, 2016 12:23 am

You can print the value of ZZ just like other int or long types. See my example.

void printZZ(string name, const ZZ n){
#ifdef INFO
if (name.length()>0)
cout << name << "=" << n << endl;
else
cout << n << endl;
#endif
}

The ZZX is a polynomial function. I used the following functions to do the job. It just print the polynomials in a petty form.

void printZZX(string name, const ZZX poly){
#ifdef INFO
string output;
for(int i=0; i<deg(poly)+1; i++){
if(poly[i]!=0){
// addition sign
if(output.length()>0 && poly[i] >0) output.append(" + ");
if (poly[i]!=1 || i==0) output.append(ZZToString(poly[i]));
if(i>0) output.append(syms).append("^").append(to_string(i));
}
}

if (name.length()>0)
cout << name << "=" << output << endl;
else
cout << output << endl;
#endif
}

void printZZX(const ZZX poly){
printZZX("", poly);
}

I hope this helps.
peiworld
 
Posts: 8
Joined: Mon Feb 22, 2016 3:09 am


Return to NTL

Who is online

Users browsing this forum: No registered users and 1 guest

cron