# define Newx(v,n,t) New(0,v,n,t)
#endif /* !Newx */
+#define DD_DEBUGf_UPDATED_LINESTR 1
+#define DD_DEBUGf_TRACE 2
+
+#define DD_DEBUG_UPDATED_LINESTR (dd_debug & DD_DEBUGf_UPDATED_LINESTR)
+#define DD_DEBUG_TRACE (dd_debug & DD_DEBUGf_TRACE)
static int dd_debug = 0;
#define LEX_NORMAL 10
SvCUR_set(PL_linestr, new_len);
PL_bufend = SvPVX(PL_linestr) + new_len;
+
+ if ( DD_DEBUG_UPDATED_LINESTR && PERLDB_LINE && PL_curstash != PL_debstash) {
+ // Cribbed from toke.c
+ SV * const sv = NEWSV(85,0);
+
+ sv_upgrade(sv, SVt_PVMG);
+ sv_setpvn(sv,PL_bufptr,PL_bufend-PL_bufptr);
+ (void)SvIOK_on(sv);
+ SvIV_set(sv, 0);
+ av_store(CopFILEAV(&PL_compiling),(I32)CopLINE(&PL_compiling),sv);
+ }
}
char* dd_get_lex_stuff(pTHX) {
PERL_UNUSED_VAR(user_data);
if (in_declare) {
- if (dd_debug) {
+ if (DD_DEBUG_TRACE) {
printf("Deconstructing declare\n");
printf("PL_bufptr: %s\n", PL_bufptr);
printf("bufend at: %i\n", PL_bufend - PL_bufptr);
FREETMPS;
LEAVE;
- if (dd_debug) {
+ if (DD_DEBUG_TRACE) {
printf("PL_bufptr: %s\n", PL_bufptr);
printf("bufend at: %i\n", PL_bufend - PL_bufptr);
printf("linestr: %s\n", SvPVX(PL_linestr));
if (!DD_AM_LEXING)
return o; /* not lexing? */
- if (dd_debug) {
+ if (DD_DEBUG_TRACE) {
printf("Checking GV %s -> %s\n", HvNAME(GvSTASH(kGVOP_gv)), GvNAME(kGVOP_gv));
}
if (dd_flags == -1)
return o;
- if (dd_debug) {
+ if (DD_DEBUG_TRACE) {
printf("dd_flags are: %i\n", dd_flags);
printf("PL_tokenbuf: %s\n", PL_tokenbuf);
}
#endif
sv = POPs;
if (SvPOK(sv)) {
- if (dd_debug) {
+ if (DD_DEBUG_TRACE) {
printf("mangling eval sv\n");
}
if (SvREADONLY(sv))
BOOT:
if (getenv ("DD_DEBUG")) {
- dd_debug = 1;
+ dd_debug = atoi(getenv("DD_DEBUG"));
}
--- /dev/null
+use strict;
+use warnings;
+
+use Devel::Declare;
+
+BEGIN {
+
+ Devel::Declare->install_declarator(
+ 'DeclareTest', 'method', DECLARE_PACKAGE | DECLARE_PROTO,
+ sub {
+ my ($name, $proto) = @_;
+ return 'my $self = shift;' unless defined $proto && $proto ne '@_';
+ return 'my ($self'.(length $proto ? ", ${proto}" : "").') = @_;';
+ },
+ sub {
+ my ($name, $proto, $sub, @rest) = @_;
+ if (defined $name && length $name) {
+ unless ($name =~ /::/) {
+ $name = "DeclareTest::${name}";
+ }
+ no strict 'refs';
+ *{$name} = $sub;
+ }
+ return wantarray ? ($sub, @rest) : $sub;
+ }
+ );
+
+}
+
+my ($test_method1, $test_method2, @test_list);
+
+{
+ package DeclareTest;
+
+ method new {
+ };
+
+}
+
+{ no strict;
+ no warnings 'uninitialized';
+ print @{"_<t/debug.pl"};
+}
--- /dev/null
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+use Cwd qw/cwd/;
+use FindBin qw/$Bin/;
+
+$ENV{PERLDB_OPTS} = "NonStop";
+$ENV{DD_DEBUG} = 1;
+cwd("$Bin/..");
+
+# Write a .perldb file so we make sure we dont use the users one
+open PERLDB, ">", "$Bin/../.perldb" or die "Cannot open $Bin/../.perldb: $!";
+close PERLDB;
+
+$SIG{CHLD} = 'IGNORE';
+$SIG{ALRM} = sub {
+ fail("SIGALRM timeout triggered");
+ kill(9, $$);
+};
+
+alarm 10;
+my $output = `$^X -d t/debug.pl`;
+
+like($output, qr/method new {}, sub {my \$self = shift;/,
+ "replaced line string visible in debug lines");
+1;