This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa] rfa [long]: mudflap prototype


Hi -

Attached is the prototype mudflap instrumentation (as gcc patches)
and runtime (as new files for .../libmudflap).  To use it, build
a native gcc from the patched ssa branch on a modern linux host.
Separately build libmudflap.a and put it someplace handy.  Then
compile/link a program with "-fmudflap".  If all is well, you will
see runtime warning messages for certain classes of pointer use
errors.

For example, the toy program below contains two separate problems
that mudflap can detect.

% cat foo.c
#include <stdlib.h>
int main ()
{
  char *buf = malloc (1000);
  free (buf);
  buf[0] = 'a';
  return 0;
}
% newlybuilt/gcc -fmudflap -Lhandy foo.c
% ./a.out

*******
mudflap warning: unaccessed registered object:
mudflap object 0x8057610: name=`malloc region'
bounds=[08057220,08057607] area=heap access-count=0
alloc time=1028847553.754394 pc=080493c8
      ./a.out [0x804885f]
      ./a.out [0x80493c8]
      ./a.out(backtrace_symbols+0x140) [0x80485cc]
      /lib/libc.so.6(__libc_start_main+0x93) [0x40045777]
      ./a.out(backtrace_symbols+0x35) [0x80484c1]
dealloc time=1028847553.754680 pc=08049477
      ./a.out [0x8048a01]
      ./a.out [0x8049477]
      ./a.out(backtrace_symbols+0x14e) [0x80485da]
      /lib/libc.so.6(__libc_start_main+0x93) [0x40045777]
      ./a.out(backtrace_symbols+0x35) [0x80484c1]
*******
mudflap violation 1: time=1028847553.755182 ptr=08057220 size=4 pc=08048686 type=check
Nearby object 1: ptr is 0B into
mudflap object 0x8057610: name=`malloc region'
bounds=[08057220,08057607] area=heap access-count=0
alloc time=1028847553.754394 pc=080493c8
      ./a.out [0x804885f]
      ./a.out [0x80493c8]
      ./a.out(backtrace_symbols+0x140) [0x80485cc]
      /lib/libc.so.6(__libc_start_main+0x93) [0x40045777]
      ./a.out(backtrace_symbols+0x35) [0x80484c1]
dealloc time=1028847553.754680 pc=08049477
      ./a.out [0x8048a01]
      ./a.out [0x8049477]
      ./a.out(backtrace_symbols+0x14e) [0x80485da]
      /lib/libc.so.6(__libc_start_main+0x93) [0x40045777]
      ./a.out(backtrace_symbols+0x35) [0x80484c1]
number of nearby objects: 1
*******
mudflap stats:
calls to __mf_check: 1 rot: 0/0
         __mf_register: 1 [0B, 1000B, 0B, 0B]
         __mf_unregister: 1 [1B]
         __mf_violation: [0, 1, 0, 0]
lookup cache slots used: 0  unused: 256  peak-reuse: 0
number of live objects: 0
          persistent dead objects: 1
number of leaked objects: 0


We have a lot more coming.


- FChE

Attachment: mudflap-diffs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]