in reply to Re: tracing system calls a perl script is making
in thread tracing system calls a perl script is making

So I rewrote the perl program and the C program to write to the same text file

I get something like this in my output.txt:

237 time system call 8 238 time system call 8 239 time system call 5 240 time system call 5 241 time system call 72 242 time system call 72 243 time system call 1 Started #The BEGIN block 244 time system call 1 245 time system call 3 246 time system call 3 247 time system call 2 248 time system call 2 249 time system call 8 250 time system call 8 251 time system call 16 252 time system call 16 253 time system call 8 254 time system call 8 255 time system call 5 256 time system call 5 257 time system call 72 258 time system call 72 259 time system call 1 hello world 260 time system call 1 261 time system call 3 262 time system call 3 .... .... At 400 about I get the END block print and then 3 more system calls before termination

Unfortunately I don't know now when I should start monitoring the target problem. I want to write something of a generic tracer for any perl script. I thought I would see a pattern in the perl interpreter's system calls but I don't. Any ideas?

Replies are listed 'Best First'.
Re^3: tracing system calls a perl script is making
by shmem (Chancellor) on Jun 03, 2013 at 10:24 UTC

    What BrowserUk says - use INIT, not BEGIN, since BEGIN blocks are executed in the compile phase of the perl script.

    I want to write something of a generic tracer for any perl script.

    Why? GNU/Linux has tools for that ready - strace(1), ltrace(1). I suspect an XY problem here. What are you trying to to with that which you are ostensibly trying to do?

    Then, perl is linked against many libraries, and it can well be that most of those syscalls happen inside calls to functions in these libraries. To verify that, you can use ltrace(1), which displays library calls, together with the -S switch to display system calls as well.

      use INIT, not BEGIN

      Yes, it is INIT not begin. I put in a typo. Sorry!

      I suspect an XY problem here. What are you trying to to with that which you are ostensibly trying to do?

      Oh, no no! It's not. I'm just trying to learn how a debugger is built :) I downloaded the source for strace and gdb but it's just too large to understand..

      Mostly, it's a exercise in perl, C and Linux I've given myself to write a program that can list out all system calls a perl script is making while executing that program .

Re^3: tracing system calls a perl script is making
by BrowserUk (Patriarch) on Jun 02, 2013 at 19:54 UTC

    The only thing I would add is that I recommended INIT and END; not BEGIN and END; and that difference may well account for much of your syscall activity, as modules files are read and parsed and memory allocated to accommodate them.


    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".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^3: tracing system calls a perl script is making
by BrowserUk (Patriarch) on Jun 02, 2013 at 18:03 UTC

    I cannot help you with that as I don't run *nix.


    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".
    In the absence of evidence, opinion is indistinguishable from prejudice.