-pedantic> flags which enforce stricter ANSI rules.
If using the C<gcc -Wall> note that not all the possible warnings (like
-C<-Wunitialized>) are given unless you also compile with C<-O>.
+C<-Wuninitialized>) are given unless you also compile with C<-O>.
Note that if using gcc, starting from Perl 5.9.5 the Perl core source
code files (the ones at the top level of the source code distribution,
printf("i = %"IVdf"\n", (IV)something_very_small_and_signed);
+See L<perlguts/Formatted Printing of Size_t and SSize_t> for how to
+print those.
+
Also remember that the C<%p> format really does require a void pointer:
U8* p = ...;
To really poke around with Perl, you'll probably want to build Perl for
debugging, like this:
- ./Configure -d -D optimize=-g
+ ./Configure -d -DDEBUGGING
make
-C<-g> is a flag to the C compiler to have it produce debugging
-information which will allow us to step through a running program, and
-to see in which C function we are at (without the debugging information
-we might see only the numerical addresses of the functions, which is
-not very helpful).
-
-F<Configure> will also turn on the C<DEBUGGING> compilation symbol
-which enables all the internal debugging code in Perl. There are a
-whole bunch of things you can debug with this: L<perlrun> lists them
-all, and the best way to find out about them is to play about with
-them. The most useful options are probably
+C<-DDEBUGGING> turns on the C compiler's C<-g> flag to have it produce
+debugging information which will allow us to step through a running
+program, and to see in which C function we are at (without the debugging
+information we might see only the numerical addresses of the functions,
+which is not very helpful). It will also turn on the C<DEBUGGING>
+compilation symbol which enables all the internal debugging code in Perl.
+There are a whole bunch of things you can debug with this: L<perlrun>
+lists them all, and the best way to find out about them is to play about
+with them. The most useful options are probably
l Context (loop) stack processing
+ s Stack snapshots (with v, displays all stacks)
t Trace execution
o Method and overloading resolution
c String/numeric conversions
-Some of the functionality of the debugging code can be achieved using
-XS modules.
+For example
+
+ $ perl -Dst -e '$a + 1'
+ ....
+ (-e:1) gvsv(main::a)
+ => UNDEF
+ (-e:1) const(IV(1))
+ => UNDEF IV(1)
+ (-e:1) add
+ => NV(1)
+
+
+Some of the functionality of the debugging code can be achieved with a
+non-debugging perl by using XS modules:
-Dr => use re 'debug'
-Dx => use O 'Debug'
execution and data flows. As a matter of fact, this is exactly how C
compilers know to give warnings about dubious code.
-=head2 lint, splint
+=head2 lint
The good old C code quality inspector, C<lint>, is available in several
platforms, but please be aware that there are several different
implementations of it by different vendors, which means that the flags
are not identical across different platforms.
-There is a lint variant called C<splint> (Secure Programming Lint)
-available from http://www.splint.org/ that should compile on any
-Unix-like platform.
-
-There are C<lint> and <splint> targets in Makefile, but you may have to
+There is a C<lint> target in Makefile, but you may have to
diddle with the flags (see above).
=head2 Coverity