|
From: Jeremy F. <je...@go...> - 2005-02-17 01:51:44
|
CVS commit by fitzhardinge:
Don't crash if the tool doesn't implement SK_(malloc)/(free) and the
client uses the MALLOC/FREE client requests. This is needed so the core
can allocate memory for the client, which the client can then free.
M +5 -4 gen_toolint.pl 1.7
M +2 -4 vg_default.c 1.26
--- valgrind/coregrind/gen_toolint.pl #1.6:1.7
@@ -85,4 +85,5 @@
print "$ret $pfxmap{$pfx}($func)($args);\n";
+ print "$ret VG_(missing_$func)($args);\n";
print "Bool VG_(defined_$func)(void);\n";
}
@@ -100,9 +101,9 @@
my $args = join ", ", @args;
- print "static $ret missing_${pfx}_$func($args) {\n";
+ print "__attribute__ ((weak))\n$ret VG_(missing_$func)($args) {\n";
print " VG_(missing_tool_func)(\"${pfx}_$func\");\n";
print "}\n";
print "Bool VG_(defined_$func)(void) {\n";
- print " return $struct.${pfx}_$func != missing_${pfx}_$func;\n";
+ print " return $struct.${pfx}_$func != VG_(missing_$func);\n";
print "}\n\n";
};
@@ -136,5 +137,5 @@
my ($pfx, $ret, $func, @args) = @_;
- print "$indent.${pfx}_$func = missing_${pfx}_$func,\n"
+ print "$indent.${pfx}_$func = VG_(missing_$func),\n"
};
$indent = " ";
@@ -150,5 +151,5 @@
{
if (func == NULL)
- func = missing_${pfx}_$func;
+ func = VG_(missing_$func);
if (VG_(defined_$func)())
VG_(printf)("Warning tool is redefining $func\\n");
--- valgrind/coregrind/vg_default.c #1.25:1.26
@@ -79,6 +79,5 @@ Bool VG_(sk_malloc_called_by_scheduler)
malloc()-replacing tool cannot forget to implement SK_(malloc)() or
SK_(free)(). */
-__attribute__ ((weak))
-void* SK_(malloc)( SizeT size )
+void* VG_(missing_malloc)( SizeT size )
{
if (VG_(sk_malloc_called_by_scheduler))
@@ -88,6 +87,5 @@ void* SK_(malloc)( SizeT size )
}
-__attribute__ ((weak))
-void SK_(free)( void* p )
+void VG_(missing_free)( void* p )
{
/* see comment for SK_(malloc)() above */
|