Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: How to find perl line after segfault.

by Steve_BZ (Chaplain)
on Feb 10, 2015 at 12:53 UTC ( #1116177=note: print w/replies, xml ) Need Help??


in reply to Re: How to find perl line after segfault.
in thread How to find perl line after segfault.

Hi BrowserUK,

It look perfect. Although the code calls scroll up the screen like lightning, I could write them to a file for post-mortem examination. In fact the last few lines would probably be enough.

I'll see if I can play with it.

Thanks very much.

Regards

Steve

  • Comment on Re^2: How to find perl line after segfault.

Replies are listed 'Best First'.
Re^3: How to find perl line after segfault.
by QM (Parson) on Feb 10, 2015 at 14:52 UTC
    Although the code calls scroll up the screen like lightning, I could write them to a file for post-mortem examination.

    tee is your friend.

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

      Hi QM,

      It looks like the printouts are produced by CallTrace, So I'd have to modify CallTrace to use 'tee', is that what you are suggesting?

      As it's being called with -d, I don't imagine tee in the child program or the parent program will make much difference.

      At the moment CallTrace writes to STDERR, but it could be tee'd to another file too, do you think?

      Regards

      Steve.

        Whatever is dumping to the screen should be teed to a file. You may have to redirect STDERR to do so (which is shell-dependent, I always look at Unix Power Tools: Common Standard I/O Redirections).

        This may involve changing the command line call. Or CallTrace may allow you to log directly to a file. (I know nothing about CallTrace. It's a generic-enough term that it's hard for me to decide which software you are referring to.)

        Another choice is to use script to log the entire session. This starts a new shell, where you can then run your commands.

        -QM
        --
        Quantum Mechanics: The dreams stuff is made of

Re^3: How to find perl line after segfault.
by BrowserUk (Patriarch) on Feb 10, 2015 at 19:33 UTC

    Generally, when tracking down a segfault, all you are interested in is the last few lines of the output telling you which sub faulted; and possibly how you got there; so I set it running and minimise the session. When I go back a while later, the information I need is left right there on the last line (or last few lines) of the screen.

    If you do redirect to a file, then tail theLog gives you the same information.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

      Hi Browser UK,

      perl -d:CallTrace i-Mage.pl 2> trace.txt

      absolutely did the job and found the problem immediately. It was a Wx::Timer process that I had forgotten about starting off a little early. There seemed to be very little performance overhead, maybe the program loaded a bit slower but after that it seemed about the same as always.

      Now I'd like to call it from open3 like this:

      my @array = qw(perl -d:CallTrace i-Mage.pl); my $child_pid = open3( '<&STDIN', ">trace.txt", *CHILD_ERROR, @array );

      The code starts, but there is no sign of "trace.txt".

      Not sure where I'vwe gone wrong.

      Regards

      Steve.

        Sorry, but I never had any luck at all with open3() when I first tried it, as a consequence I never use it. You'll need help from someone who does.

        As an aside; I wasn't aware that open3(), accepted strings for the file handles. Nor does anything in the documentation lead me to believe it does.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
        In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1116177]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2023-01-30 19:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?