Page 1 of 1

GDB print NTL variable's value

PostPosted: Wed Mar 02, 2016 10:45 pm
by guglielmoL
How to find/print ZZ or ZZX variable's value using GDB debugger ?

Re: GDB print NTL variable's value

PostPosted: Wed Mar 02, 2016 11:15 pm
by victorshoup
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.

Re: GDB print NTL variable's value

PostPosted: Thu Mar 03, 2016 12:23 am
by peiworld
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.