debugging (stepping thru in debugger) within a try block

debugging (stepping thru in debugger) within a try block

am 14.02.2006 01:13:02 von Badari Kakumani

folks,

i have recently started using the exception handling using
try ... catch ... otherwise ... finally.

those are great OO concepts.

when i use perl debugger on code using the above try... catch etc,
i am unable to step thru the code in those try ... catch blocks.

is there any way to step thru those blocks of code which seem to be
getting executed as a single unit (like eval i think)?

thanks for your help,
-badari

Re: debugging (stepping thru in debugger) within a try block

am 14.02.2006 17:23:16 von Eric Schwartz

"Badari Kakumani" writes:
> i have recently started using the exception handling using
> try ... catch ... otherwise ... finally.
>
> those are great OO concepts.

They also don't exist in Perl, at least not under those names. Are
you using a module which provides functions with those names, such as
Exception::Class::TryCatch? If so, you really need to tell us,
because CPAN is huge, and nobody knows offhand which modules you're
using if you don't tell us.

Also, have you read the Posting Guidelines? They're not meant to
cause you pain, but if you read them, and follow them, then you will
make it very easy for us to help you. Specifically, one of the
guidelines is that you should post the smallest complete program
possible that exhibits your problem. Once you get it running (I think
it should only be 10 or 12 lines, at most), cut and paste it here-- do
NOT retype it! Every single time I see somebody retype their code,
they always make a mistake. When you cut and paste, if there is a
mistake, it's a real one, not a mistake introduced by typos.

> when i use perl debugger on code using the above try... catch etc,
> i am unable to step thru the code in those try ... catch blocks.
>
> is there any way to step thru those blocks of code which seem to be
> getting executed as a single unit (like eval i think)?

You need to tell us what these try/catch blocks are, and how you get
them. Perl does not have them by default, so it is your job to tell
us where they came from.

-=Eric

Re: debugging (stepping thru in debugger) within a try block

am 14.02.2006 17:24:13 von Eric Schwartz

Eric Schwartz writes:
> Also, have you read the Posting Guidelines?

Oops, my mistake, sorry. I thought I was in c.l.p.misc, not .modules.
Anyway, if the OP were to read the Posting Guidelines in c.l.p.misc,
they would help him ask helpful questions. :)

-=Eric

Re: debugging (stepping thru in debugger) within a try block

am 14.02.2006 20:48:25 von Badari Kakumani

hi eric,

no problem. actually the guidelines you noted are good in general and
am
going to follow for my further posts.

writing sample program gave me the solution :)

looks like my problem was that my code was using 'try' as defined
by Error.pm std perl module. looks like this module would try to
execute
the entire 'try block' as some anonymous code segment and hence won't
allow
you to step into the code.

looks like perl 5.8.6 does understand try natively and if you use it,
debugger has
no problem stepping into the try blocks.

hopefully the program listing i have answers your other quesions as to
which cpan module i am using etc.

thanks,
-badari

# note that in the program below you will be able to step into the
# try blocks if you comment out 'use Error qw(:try)'.


#!/usr/cisco/bin/perl5.8 -w

use Error qw(:try);
use Exception::Class (
SubExc => {},
);


sub main {
try {
my $v1 = 'v1'; # you can't break here if you are using
Error::try
sub2();
} catch Exception::Class::Base with {
shift->throw();
} otherwise {
shift->throw();
}
}

sub sub2 {
try {
my $v1 = 'abc';
throw SubExc "exception while performing sub processing";
}
}

&main();

Re: debugging (stepping thru in debugger) within a try block

am 15.02.2006 17:18:51 von Eric Schwartz

"Badari Kakumani" writes:
> no problem. actually the guidelines you noted are good in general
> and am going to follow for my further posts.
>
> writing sample program gave me the solution :)

That's usually the case, which is why the advice to do so in the first
place. :)

> looks like my problem was that my code was using 'try' as defined
> by Error.pm std perl module.

I have never used that module. I'm not sure I even knew it existed.
I may have to play with it a bit, just for giggles.

-=Eric