From 982a448ead1e76d1891ff3bd1ddc7e365a0846dc Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 25 Feb 2017 02:59:47 +0000 Subject: .gdbinit: rp_bignum * .gdbinit (rp_bignum): print bignum from higher digits. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- .gdbinit | 59 ++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/.gdbinit b/.gdbinit index 09013ab53c..6e67341a2f 100644 --- a/.gdbinit +++ b/.gdbinit @@ -168,19 +168,7 @@ define rp ((struct RStruct *)($arg0))->as.heap.ptr) @ $len else if ($flags & RUBY_T_MASK) == RUBY_T_BIGNUM - set $len = (($flags & RUBY_FL_USER2) ? \ - ($flags & (RUBY_FL_USER5|RUBY_FL_USER4|RUBY_FL_USER3)) >> (RUBY_FL_USHIFT+3) : \ - ((struct RBignum*)($arg0))->as.heap.len) - printf "%sT_BIGNUM%s: sign=%d len=%ld ", $color_type, $color_end, \ - (($flags & RUBY_FL_USER1) != 0), $len - if $flags & RUBY_FL_USER2 - printf "(embed) " - end - print (struct RBignum *)($arg0) - output/x *(($flags & RUBY_FL_USER2) ? \ - ((struct RBignum*)($arg0))->as.ary : \ - ((struct RBignum*)($arg0))->as.heap.digits) @ $len - printf "\n" + rp_bignum $arg0 else if ($flags & RUBY_T_MASK) == RUBY_T_RATIONAL printf "%sT_RATIONAL%s: ", $color_type, $color_end @@ -488,6 +476,51 @@ document rp_string Print the content of a String. end +define rp_bignum + set $flags = ((struct RBignum*)($arg0))->basic.flags + set $len = (($flags & RUBY_FL_USER2) ? \ + ($flags & (RUBY_FL_USER5|RUBY_FL_USER4|RUBY_FL_USER3)) >> (RUBY_FL_USHIFT+3) : \ + ((struct RBignum*)($arg0))->as.heap.len) + printf "%sT_BIGNUM%s: sign=%d len=%ld ", $color_type, $color_end, \ + (($flags & RUBY_FL_USER1) != 0), $len + if $flags & RUBY_FL_USER2 + printf "(embed) " + end + print (struct RBignum *)($arg0) + set $ptr = (($flags & RUBY_FL_USER2) ? \ + ((struct RBignum*)($arg0))->as.ary : \ + ((struct RBignum*)($arg0))->as.heap.digits) + set $len = $len-1 + printf "0x%x", $ptr[$len] + while $len > 0 + set $len = $len-1 + set $val = $ptr[$len] + set $w = sizeof($ptr[0]) + printf "_" + if $w > 8 + printf "%.32x", $val + else + if $w > 4 + printf "%.16x", $val + else + if $w > 2 + printf "%.8x", $val + else + if $w > 1 + printf "%.4x", $val + else + printf "%.2x", $val + end + end + end + end + end + printf "\n" +end +document rp_bignum + Print the content of a Bignum. +end + define rp_class printf "(struct RClass *) %p", (void*)$arg0 if ((struct RClass *)($arg0))->ptr.origin_ != $arg0 -- cgit v1.2.3