Here is how I usually debug XSS code (not with Komodo, though):
  1. Recompile the C code with CFLAGS=-g -O0 to have debugging symbols in the resultant library that will be loaded from Perl. -O0 will remove optmization, this makes it easier to step through the code.
  2. Edit the Perl code and put a dump() somewhere before the offending XSS function is called. This will make your Perl exit immediately when calling this function and dump a core. Note that you must have core files enabled (on UNIX, you achieve this by issuing ulimit -c unlimited).
  3. Fire up a debugger (I recommend the venerable gdb) and read in the core
    r@everything:/tmp$ gdb (gdb) core core ... (gdb) file /usr/bin/perl Reading symbols from /usr/bin/perl...(no debugging symbols found)...do +ne. (gdb) set args a.pl (gdb) r Starting program: /usr/bin/perl a.pl ...
    Now, you have all the symbols read in by gdb, so you can start placing breakpoints whereever you want.
  4. After placing the breakpoints, remove the dump() from your Perl code, rerun and wow, your debugger will stop at your breakpoint.
Two final notes are in order here. First, I haven't tested this on Windows, but something along these lines should work there too. Second, the above method will allow you to step through only the XSS code but not the Perl code. I don't quite know any methods to simultaneously debug C and Perl code at the same time.

In reply to Re: debugging perl module written in C by rg0now
in thread debugging perl module written in C by chuckd

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.