php extension debugger

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben

    php extension debugger

    Hello,

    I'm a very, very novice C programmer and I have written an extension
    for php that does its purpose well, or at least it used to until they
    asked for that one extra feature. It's a very little thing, very easy,
    but damn it all, it has a mysterious bug. I tracked it down to one
    specific line where the weirdness occurs, but I can't figure out *why*
    it is occuring.

    This extension uses the php_streams and as such, is wed enough to php
    that my first inclination (compile it on its own and debug it that way)
    is a no-go. Is there any way to use a debugger on this so I can step
    through it?

    I only know enough C for it to be painful. Any help would be
    appreciated.

    Thanks,
    Ben

  • Chung Leong

    #2
    Re: php extension debugger


    Ben wrote:[color=blue]
    > Hello,
    >
    > I'm a very, very novice C programmer and I have written an extension
    > for php that does its purpose well, or at least it used to until they
    > asked for that one extra feature. It's a very little thing, very easy,
    > but damn it all, it has a mysterious bug. I tracked it down to one
    > specific line where the weirdness occurs, but I can't figure out *why*
    > it is occuring.
    >
    > This extension uses the php_streams and as such, is wed enough to php
    > that my first inclination (compile it on its own and debug it that way)
    > is a no-go. Is there any way to use a debugger on this so I can step
    > through it?[/color]

    What platform are you on? If you're using Visual Studio on Windows,
    what you do is attach the debugger to the Apache process then set the
    break points. Upon hitting the page the debugger will stop the process
    at the break point for you to trace through.

    Comment

    • Ben

      #3
      Re: php extension debugger

      I'm on freeBSD without X11, editing the file on OS X through a samba
      mount.

      I'll google around for attaching a debugger to an Apache process.
      Thanks for the direction.

      Comment

      • Chung Leong

        #4
        Re: php extension debugger

        The thing to remember is that you need to attach to a child process
        spawned by the Apache as opposed to the original process. Be sure to
        adjust your Apache config so it wouldn't spawn some fifty children.
        Otherwise it'd be pretty hard to tell which one is handling a given
        request.

        It's been ages since I last used gdb. Just look in the manpage. Should
        tell you what commands to use.

        Comment

        • Ben

          #5
          Re: php extension debugger

          Thanks a lot. With some help I managed to solve my problem (very
          stupid, naturally) before it got to the interactive debugger phrase,
          but I'm sure next time I manage to get myself stuck or even next time I
          find myself idly investigating I'll give gdb a shot.

          Thanks for the tips.

          Comment

          Working...