Skip to content

Commit

Permalink
Add examine(ZZ) (shows GMP internals)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-torrance committed Nov 25, 2024
1 parent f15ed84 commit 742f6b4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions M2/Macaulay2/d/debugging.dd
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,18 @@ showsym(s:Symbol):void := (

examine(e:Expr):Expr := (
when e
is x:ZZcell do (
stdIO << "ZZ cell (GMP integer): " << endl
<< " number of limbs: " << Ccode(int, x.v, "->_mp_size") << endl;
for i from 0 to Ccode(int, "mpz_size(", x.v, ")") - 1 do (
buf := newstring(19);
Ccode(void, "gmp_sprintf((char *)", buf, "->array, \"%#Mx\", ",
x.v, "->_mp_d[", i, "])");
Ccode(void, buf, "->len = strlen((char *)", buf, "->array)");
stdIO << " limb #" << i << ": " << buf << endl);
stdIO << " number of limbs currently allocated: "
<< Ccode(int, x.v, "->_mp_alloc") << endl;
nullE)
is sc:SymbolClosure do (
f := sc.frame;
s := sc.symbol;
Expand Down

0 comments on commit 742f6b4

Please sign in to comment.