Solved

How to debug into sub functions in Perl?

Posted on 2011-03-24
3
460 Views
Last Modified: 2012-05-11
Hi,
I have subfunction in my code and Perl debugger cannot go into it.

Here is what I do:

perl -d myFile
b linenumber
c
s

Open in new window



It stops at linenumber and when I say step into it it skips. n also does not work.

Here is the beginning of my sub function:

SOME CODE

my (%c, %d);
sub logFunc {
    my ($a, $b) = @_;
    my $S;
    my $file;

SOME OTHER CODE

} #myFunc

SOME MORE CODE

Open in new window



How can I debug this code?
0
Comment
Question by:Tolgar
3 Comments
 
LVL 8

Expert Comment

by:point_pleasant
ID: 35210385
n runs until the next statement (the one immediately following this one in the current file) is about to execute. Note that if the current line is a subroutine call, the debugger won't stop until returning from that subroutine. To stop at the first line of the called subroutine, use the s (single-step) command instead. The r command executes until returning from the current subroutine (i.e., until we pop the activation stack).

0
 

Author Comment

by:Tolgar
ID: 35210568
Well, I already use s but it still does not go into the subroutine. Why is that?

Thanks,
0
 
LVL 25

Accepted Solution

by:
clockwatcher earned 500 total points
ID: 35211636
This may be a stupid question but are you expecting what you posted to actually step into that function?  

SOME CODE

my (%c, %d);
sub logFunc {
    my ($a, $b) = @_;
    my $S;
    my $file;

SOME OTHER CODE

} #myFunc

Open in new window


If you are, that's your problem right there.  The code that you posted never calls your function so the debugger won't ever actually be in there to step into it.  If you actually call your function, then you'll step into that section of the code.

SOME CODE

my (%c, %d);
sub logFunc {
    my ($a, $b) = @_;
    my $S;
    my $file;

SOME OTHER CODE

} #myFunc

# call your function
my $val = logFunc( 5, 5);

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now