Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters

[PATCH] Add ENTER_with_name and LEAVE_with_name to automaticly check matching scopes when debugging

 

 

Perl porters RSS feed   Index | Next | Previous | View Threaded


gerard at ggoossen

Nov 12, 2009, 2:51 AM

Post #1 of 12 (420 views)
Permalink
[PATCH] Add ENTER_with_name and LEAVE_with_name to automaticly check matching scopes when debugging

Add ENTER_with_name and LEAVE_with_name, which work identical to ENTER and
LEAVE, but when LEAVE_with_name is done it is checked that it corresponds
to an ENTER_with_name with the same name.

Also includes fixes of universal.c sv_does and POSIX.xs sigaction where
LEAVEs where missing.

Gerard
Attachments: 0001-Add-ENTER_with_name-and-LEAVE_with_name-to-automatic.patch (23.7 KB)


frank.wiegand at gmail

Nov 12, 2009, 2:56 AM

Post #2 of 12 (406 views)
Permalink
Re: [PATCH] Add ENTER_with_name and LEAVE_with_name to automaticly check matching scopes when debugging [In reply to]

Am Donnerstag, den 12.11.2009, 11:51 +0100 schrieb Gerard Goossen:
> diff --git a/scope.h b/scope.h
> index 7517798..e58f76a 100644
> --- a/scope.h
> +++ b/scope.h
> @@ -100,6 +100,20 @@ Opening bracket on a callback. See C<LEAVE> and
> L<perlcall>.
> =for apidoc Ams||LEAVE
> Closing bracket on a callback. See C<ENTER> and L<perlcall>.
>
> +=over
> +
> +=item ENTER_with_name(name)
> +
> +Same as C<ENTER>, but when debugging is enable it also associates the
^^^^^^
Should be »enabled«.


nj88udd02 at sneakemail

Nov 12, 2009, 3:31 AM

Post #3 of 12 (406 views)
Permalink
Re: [PATCH] Add ENTER_with_name and LEAVE_with_name to automaticlycheck matching scopes when debugging [In reply to]

Hi Gerard,

Gerard Goossen wrote:
> Add ENTER_with_name and LEAVE_with_name, which work identical to ENTER and
> LEAVE, but when LEAVE_with_name is done it is checked that it corresponds
> to an ENTER_with_name with the same name.

I like the idea. I have a hard time commenting on the implementation,
though, for lack of clue.

> Also includes fixes of universal.c sv_does and POSIX.xs sigaction where
> LEAVEs where missing.

Could you submit these two unrelated patches as separate commits? I
think the second part can be applied unconditionally.

Cheers,
Steffen


perl at profvince

Nov 12, 2009, 5:37 AM

Post #4 of 12 (407 views)
Permalink
Re: [PATCH] Add ENTER_with_name and LEAVE_with_name to automaticly check matching scopes when debugging [In reply to]

> Add ENTER_with_name and LEAVE_with_name, which work identical to ENTER and
> LEAVE, but when LEAVE_with_name is done it is checked that it corresponds
> to an ENTER_with_name with the same name.

I kinda like the idea, but not the name. Since they're going to be spread
all other the core, I'd rather have something sorter and prettier.

> Also includes fixes of universal.c sv_does and POSIX.xs sigaction where
> LEAVEs where missing.
>

Please resend it as a separate commit.

Vincent.


gerard at ggoossen

Nov 12, 2009, 5:43 AM

Post #5 of 12 (406 views)
Permalink
Re: [PATCH] Add ENTER_with_name and LEAVE_with_name to automaticly check matching scopes when debugging [In reply to]

On Thu, Nov 12, 2009 at 11:56:50AM +0100, Frank Wiegand wrote:
> Am Donnerstag, den 12.11.2009, 11:51 +0100 schrieb Gerard Goossen:
> > diff --git a/scope.h b/scope.h
> > index 7517798..e58f76a 100644
> > --- a/scope.h
> > +++ b/scope.h
> > @@ -100,6 +100,20 @@ Opening bracket on a callback. See C<LEAVE> and
> > L<perlcall>.
> > =for apidoc Ams||LEAVE
> > Closing bracket on a callback. See C<ENTER> and L<perlcall>.
> >
> > +=over
> > +
> > +=item ENTER_with_name(name)
> > +
> > +Same as C<ENTER>, but when debugging is enable it also associates the
> ^^^^^^
> Should be ??enabled??.

Thanks, fixed typo. And also removed the universal.c and POSIX fixes.

Gerard
Attachments: 0001-Add-ENTER_with_name-and-LEAVE_with_name-to-automatic.patch (22.1 KB)


gerard at ggoossen

Nov 12, 2009, 5:44 AM

Post #6 of 12 (406 views)
Permalink
Re: [PATCH] Add ENTER_with_name and LEAVE_with_name to automaticly check matching scopes when debugging [In reply to]

On Thu, Nov 12, 2009 at 02:37:59PM +0100, Vincent Pit wrote:
> > Add ENTER_with_name and LEAVE_with_name, which work identical to ENTER and
> > LEAVE, but when LEAVE_with_name is done it is checked that it corresponds
> > to an ENTER_with_name with the same name.
>
> I kinda like the idea, but not the name. Since they're going to be spread
> all other the core, I'd rather have something sorter and prettier.

I agree, but I couldn't think of anything better, so if you have a suggestion.

> > Also includes fixes of universal.c sv_does and POSIX.xs sigaction where
> > LEAVEs where missing.
> >
>
> Please resend it as a separate commit.

Just did that.


Gerard


Tim.Bunce at pobox

Nov 12, 2009, 12:56 PM

Post #7 of 12 (394 views)
Permalink
Re: [PATCH] Add ENTER_with_name and LEAVE_with_name to automaticly check matching scopes when debugging [In reply to]

On Thu, Nov 12, 2009 at 11:51:56AM +0100, Gerard Goossen wrote:
> Add ENTER_with_name and LEAVE_with_name, which work identical to ENTER and
> LEAVE, but when LEAVE_with_name is done it is checked that it corresponds
> to an ENTER_with_name with the same name.

> +#define ENTER_with_name(name) \
> + STMT_START { \
> + push_scope(); \
> + PL_scopestack_name[PL_scopestack_ix-1] = name; \
> + DEBUG_SCOPE("ENTER \"" name "\"") \
> + } STMT_END
> +#define LEAVE_with_name(name) \
> + STMT_START { \
> + DEBUG_SCOPE("LEAVE \"" name "\"") \
> + assert(strEQ(PL_scopestack_name[PL_scopestack_ix-1], name)); \

Most compilers will store only a single copy of identical literal
strings. So changing that assert to check the pointer first, i.e.,

assert((PL_scopestack_name[PL_scopestack_ix-1] == name) \
|| strEQ(PL_scopestack_name[PL_scopestack_ix-1], name)); \

would significantly reduce the cost.

Tim.


rurban at x-ray

Nov 16, 2009, 11:17 PM

Post #8 of 12 (362 views)
Permalink
Re: [PATCH] Add ENTER_with_name and LEAVE_with_name to automaticly check matching scopes when debugging [In reply to]

2009/11/12 Vincent Pit <perl [at] profvince>:
>> Add ENTER_with_name and LEAVE_with_name, which work identical to ENTER and
>> LEAVE, but when LEAVE_with_name is done it is checked that it corresponds
>> to an ENTER_with_name with the same name.
>
> I kinda like the idea, but not the name. Since they're going to be spread
> all other the core, I'd rather have something sorter and prettier.

ENTER_N and LEAVE_N maybe

_with_name as new public opname is way too long.
--
Reini Urban
http://phpwiki.org/ http://murbreak.at/


nj88udd02 at sneakemail

Nov 17, 2009, 12:15 AM

Post #9 of 12 (362 views)
Permalink
Re: [PATCH] Add ENTER_with_name and LEAVE_with_name to automaticly check matching scopes when debugging [In reply to]

Hi Reini, hi all,

Reini Urban wrote:
> 2009/11/12 Vincent Pit <perl [at] profvince>:
>>> Add ENTER_with_name and LEAVE_with_name, which work identical to ENTER and
>>> LEAVE, but when LEAVE_with_name is done it is checked that it corresponds
>>> to an ENTER_with_name with the same name.
>> I kinda like the idea, but not the name. Since they're going to be spread
>> all other the core, I'd rather have something sorter and prettier.
>
> ENTER_N and LEAVE_N maybe
>
> _with_name as new public opname is way too long.

I hate getting into bike-shedding discussions (or starting them), but why?

If there is one thing that I abhor about the perl API, it's that
everything is shortened to the extreme so that you only grasp the
meaning if you already know it all. It steepens the beginning of the
learning curve by a sizable factor if not an exponent. So what about
ENTER_NAMED or NAMED_ENTER if you want to hint at "naming"?

At least nowadays, people around here seem to spend *a lot* more time
reading perl's code for debugging than actually typing all-new code.

Cheers,
Steffen

PS:
strLT: Does anyone write this regularly? I bet not. So why isn't it
string_less_than?
Newx: What the hell? It *dropped* the x!
vcmp? Yeah.
dSOMETHING meaning "declare SOMETHING"... similarly a... and p... It's
consistent, yes, but if you're new to perl and just read some core or XS
code, it'll take you a while. Same for the PL prefix.
*PUSH*, *POP* for the stack.
We can't fix these, but can we please try to avoid more obscurity?


nj88udd02 at sneakemail

Nov 17, 2009, 2:00 AM

Post #10 of 12 (362 views)
Permalink
Re: [PATCH] Add ENTER_with_name and LEAVE_with_name to automaticlycheck matching scopes when debugging [In reply to]

Steffen Mueller wrote:
> So what about ENTER_NAMED or NAMED_ENTER if you want to hint at
> "naming"?

Second thought: But it's scoping we're after, isn't it? ENTER_SCOPE(D?)
SCOPE_ENTER?


perl at profvince

Nov 17, 2009, 2:42 AM

Post #11 of 12 (360 views)
Permalink
Re: [PATCH] Add ENTER_with_name and LEAVE_with_name to automaticly check matching scopes when debugging [In reply to]

> Hi Reini, hi all,
>
> Reini Urban wrote:
>> 2009/11/12 Vincent Pit <perl [at] profvince>:
>>>> Add ENTER_with_name and LEAVE_with_name, which work identical to ENTER
>>>> and
>>>> LEAVE, but when LEAVE_with_name is done it is checked that it
>>>> corresponds
>>>> to an ENTER_with_name with the same name.
>>> I kinda like the idea, but not the name. Since they're going to be
>>> spread
>>> all other the core, I'd rather have something sorter and prettier.
>>
>> ENTER_N and LEAVE_N maybe
>>
>> _with_name as new public opname is way too long.
>
> I hate getting into bike-shedding discussions (or starting them), but why?
>
> If there is one thing that I abhor about the perl API, it's that
> everything is shortened to the extreme so that you only grasp the
> meaning if you already know it all. It steepens the beginning of the
> learning curve by a sizable factor if not an exponent. So what about
> ENTER_NAMED or NAMED_ENTER if you want to hint at "naming"?
>
> At least nowadays, people around here seem to spend *a lot* more time
> reading perl's code for debugging than actually typing all-new code.
>
> Cheers,
> Steffen
>
> PS:
> strLT: Does anyone write this regularly? I bet not. So why isn't it
> string_less_than?
> Newx: What the hell? It *dropped* the x!
> vcmp? Yeah.
> dSOMETHING meaning "declare SOMETHING"... similarly a... and p... It's
> consistent, yes, but if you're new to perl and just read some core or XS
> code, it'll take you a while. Same for the PL prefix.
> *PUSH*, *POP* for the stack.

Well, yeah, I guess you need 5 minutes to learn what they represent. I
agree that can discourage some people from contributing (hint, hint).

There is a lot of recurrent FUD about how the internals are full of ugly
macros and that make them hard to learn. Before that, it was perforce that
prevented people from contributing. I used to kept two trees of the
rsynced source and diff them, and that didn't seem to prevent me from
sending patches. Not that I'm nostalgic of the perforce times in any way.

But the hard stuff is not learning the API, which you get through in a
couple of hours, it's :
- understanding how small pieces of code spread at very different places
work together ;
- taking into account all the different flavours of perl (depending on the
arch, OS and options) and their specifics ;
- knowing exactly what which instruction is meant to do at the Perl level
(which requires you to have a very good knowledge of Perl and, yes, that's
much harder than learning C) ;
- the regexp engine and the tokenizer.
I don't believe that longer^W^Wclearer names would help with this.
Conventions can't replace experience and knowledge.

That said, I like ENTER_N, and I like ENTER_NAMED as well. Maybe more the
latter, actually.

Vincent.


rurban at x-ray

Nov 17, 2009, 2:11 PM

Post #12 of 12 (348 views)
Permalink
Re: [PATCH] Add ENTER_with_name and LEAVE_with_name to automaticly check matching scopes when debugging [In reply to]

2009/11/17 Vincent Pit <perl [at] profvince>:
> That said, I like ENTER_N, and I like ENTER_NAMED as well. Maybe more the
> latter, actually.

The longest similar op so far is OP_METHOD_NAMED (see opnames.h),
so ENTER_NAMED and LEAVE_NAMED would indeed be best.

I have a problem with long names because of the table formatting in
opcode.pl (CORE),
and bytecode.pl (in B::ByteCode)
It will get messy with overlong ops.
--
Reini Urban
http://phpwiki.org/ http://murbreak.at/

Perl porters RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.