[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] gcc-4.5.0-mint-20100511
Hi,
On Tuesday 18 May 2010, Vincent Rivière wrote:
> I have updated the GCC patch to enable some nice debugging facilities:
> - the -fstack-protector-all option for buffer overflow checking.
> - mudflap for advanced runtime checks and reporting.
>
> These features even work on plain TOS :-)
Great! :-)
> 2) mudflap
> Compile and link with -fmudflap -lmudflap ad the end of the command line.
Btw. Did you have time to test whether the multithreaded mudflap support
works also? (one needs to use -fmudflapth for threaded programs)
I've used mudflap for debugging some memory access issues in Hatari emulator
and add following stuff to Hatari's Makefile.cnf (common Makefile settings
file in Hatari):
---------------
ifneq ($(MUDFLAP),)
# Run-time checks with GCC "mudflap" etc:
# - stack protection
# - checking of pointer accesses
#
# Before build, install "libmudflap<version>-<gcc-version>-dev" package
#
# To build, use:
# make clean; make MUDFLAP=1
#
# To run, use something like (disable sound as it can break things):
# MUDFLAP_OPTIONS="-viol-gdb" ./hatari --sound off
#
# For more info, see (for now, works properly only for x86 gcc):
# http://gcc.gnu.org/wiki/Mudflap_Pointer_Debugging
#
RUNCHECKS = -fstack-protector-all -fmudflapth #-fmudflapir
LDRUNCHECKS = -fmudflapth -lmudflap
endif
# Set flags passed to the compiler (e.g. optimization flags)
CFLAGS := -g $(WARNFLAGS) $(OPTFLAGS) $(RUNCHECKS)
LDFLAGS ?= $(LDRUNCHECKS)
---------------
To access memory coming from external libraries without invoking false
positive Mudflap warnings, one needs to tell Mudflap about them. I do it
like this in Hatari code:
---------
#ifdef _MUDFLAP
__mf_register(sdlscrn->pixels, sdlscrn->pitch*sdlscrn->h,
__MF_TYPE_GUESS, "SDL pixels");
#endif
---------
And when that memory is freed, it needs to be told also:
---------
#ifdef _MUDFLAP
__mf_unregister(sdlscrn->pixels, sdlscrn->pitch*sdlscrn->h,
__MF_TYPE_GUESS);
#endif
---------
For code which doesn't access memory gotten from non-mudflap-compiled
libraries, one can use additional Mudflap run-time checking options. For
example (these are from Hatari test code):
export MUDFLAP_OPTIONS="-viol-gdb -internal-checking -wipe-stack -wipe-heap"
Btw. Vincent, does GDB invocation from Mudflap code work?
- Eero