Skip Menu |

This queue is for tickets about the Devel-MAT-Dumper CPAN distribution.

Report information
The Basics
Id: 132414
Status: resolved
Priority: 0/
Queue: Devel-MAT-Dumper

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.41
Fixed in: 0.42



Subject: Dumper cannot dump extra context flags on PAD-related structures
Primarily the PadnameFLAGS() and various other fields of padname structures, but also other bits and pieces. This is because dumper doesn't know which AVs are actually PAD-related when it encounters them. Possible thoughts: Dump extra information about pads at the time we encounter the CV they're attached to, and patch them up at load time. -- Paul Evans
On Thu Apr 23 15:46:41 2020, PEVANS wrote: Show quoted text
> Possible thoughts: Dump extra information about pads at the time we > encounter the CV they're attached to, and patch them up at load time.
Having now looked into writing this, I now remember there's already a bunch of PMAT_CODEx_... extensions to deal with pad structures; so adding another one for PadnameFLAGS is easy enough. Patches attached for D:M:Dumper and D:M itself. -- Paul Evans
Subject: rt132414-devel-mat-dumper.patch
=== modified file 'doc/format.txt' --- old/doc/format.txt 2019-02-01 18:30:39 +0000 +++ new/doc/format.txt 2020-04-23 23:11:41 +0000 @@ -223,6 +223,14 @@ STR PADNAME PTR OURSTASH + type: PADNAME_FLAGS + UINT PADIX + U8 FLAGS 0x01 : OUTER + 0x02 : STATE + 0x04 : LVALUE + 0x08 : TYPED + 0x10 : OUR + type: IO Header(2I): UINT IFILENO === modified file 'lib/Devel/MAT/Dumper.xs' --- old/lib/Devel/MAT/Dumper.xs 2020-04-23 23:00:39 +0000 +++ new/lib/Devel/MAT/Dumper.xs 2020-04-23 23:11:41 +0000 @@ -145,6 +145,7 @@ /* PMAT_CODEx_PADSV was 6 */ PMAT_CODEx_PADNAMES = 7, PMAT_CODEx_PAD, + PMAT_CODEx_PADNAME_FLAGS, }; enum PMAT_CTXt { @@ -636,6 +637,16 @@ write_uint(fh, padix); write_str(fh, PadnamePV(pn)); write_svptr(fh, (SV*)PadnameOURSTASH(pn)); + + if(PadnameFLAGS(pn)) { + write_u8(fh, PMAT_CODEx_PADNAME_FLAGS); + write_uint(fh, padix); + write_u8(fh, (PadnameOUTER(pn) ? 0x01 : 0) | + (PadnameIsSTATE(pn) ? 0x02 : 0) | + (PadnameLVALUE(pn) ? 0x04 : 0) | + (PadnameFLAGS(pn) & PADNAMEt_TYPED ? 0x08 : 0) | + (PadnameFLAGS(pn) & PADNAMEt_OUR ? 0x10 : 0)); + } } } # else
Subject: rt132414-devel-mat.patch
=== modified file 'doc/format.txt' --- old/doc/format.txt 2019-02-01 18:33:36 +0000 +++ new/doc/format.txt 2020-04-23 23:42:02 +0000 @@ -223,6 +223,14 @@ STR PADNAME PTR OURSTASH + type: PADNAME_FLAGS + UINT PADIX + U8 FLAGS 0x01 : OUTER + 0x02 : STATE + 0x04 : LVALUE + 0x08 : TYPED + 0x10 : OUR + type: IO Header(2I): UINT IFILENO === modified file 'lib/Devel/MAT/SV.pm' --- old/lib/Devel/MAT/SV.pm 2020-04-23 18:41:57 +0000 +++ new/lib/Devel/MAT/SV.pm 2020-04-23 23:42:02 +0000 @@ -1694,8 +1694,16 @@ use List::Util 1.44 qw( uniq ); -use Struct::Dumb 0.07 qw( readonly_struct ); -readonly_struct Padname => [qw( name ourstash )]; +use Struct::Dumb 0.07 qw( struct ); +struct Padname => [qw( name ourstash flags )]; +{ + no strict 'refs'; + *{__PACKAGE__."::Padname::is_outer"} = sub { shift->flags & 0x01 }; + *{__PACKAGE__."::Padname::is_state"} = sub { shift->flags & 0x02 }; + *{__PACKAGE__."::Padname::is_lvalue"} = sub { shift->flags & 0x04 }; + *{__PACKAGE__."::Padname::is_typed"} = sub { shift->flags & 0x08 }; + *{__PACKAGE__."::Padname::is_our"} = sub { shift->flags & 0x10 }; +} =head1 Devel::MAT::SV::CODE @@ -1735,6 +1743,8 @@ elsif( $type == 7 ) { $self->_set_padnames_at( $df->_read_ptr ); } elsif( $type == 8 ) { my $depth = $df->_read_uint; $self->{pads_at}[$depth] = $df->_read_ptr; } + elsif( $type == 9 ) { my $padix = $df->_read_uint; + $self->{padnames}[$padix]->flags = $df->_read_u8; } else { die "TODO: unhandled CODEx type $type"; } @@ -1745,7 +1755,7 @@ { my ( $df ) = @_; - return Padname( $df->_read_str, $df->_read_ptr ); + return Padname( $df->_read_str, $df->_read_ptr, 0 ); } sub _fixup
Included in DMD 0.42 / Devel-MAT 0.43 -- Paul Evans