Commit Graph

3 Commits

Author SHA1 Message Date
Zoltan Somogyi
8ddce575d4 Introduce two new directories, trace and browser, containing libraries
Estimated hours taken: 10

Introduce two new directories, trace and browser, containing libraries
holding the C and Mercury code of the debugger respectively. (Although
the browser directory does not have a browser in it yet, the browser
should soon become its biggest component.) Take the opportunity to
rename the existing libraries, for consistency.

After this change, the linking order becomes:

	the object of the auto-generated init file
	program object files
	trace library (libmer_trace.a)
	browser library (libmer_browser.a)
	standard library (libmer_std.a)
	runtime library (libmer_rt.a)
	Boehm collector (libgc.a)

To avoid circularities, libraries cannot contain direct calls to
any routines that are defined in libraries (or object files) that
occur earlier in the above list.  Any such calls must be made into
indirect calls via function pointers.

In particular, there was a circularity caused by the library calling
MR_trace() which invokes the tracer which in turn invokes the
library.  This circularity was broken by having MR_trace(),
which is defined in the runtime, call the tracer indirectly via
a global variable named MR_trace_func_ptr.  This global variable
is initialized by the auto-generated *_init.c file.

To avoid linking in the tracer even when it is not being used,
this global variable is only set to point to MR_trace_real()
if you're using a debugging grade or if c2init was invoked
with the `-t' flag.  Otherwise it is set to MR_trace_fake()
which just prints an error message telling the user to
rebuild the executable with debugging enabled.

Makefile.DLLs:
	Reserve random locations for the two new libraries. Whether they work
	will be decided by testing on Windows.

Mmake.common.in:
	Add variables naming the new directories, and create variables
	naming the libraries.

Mmakefile:
	Add targets for the new directories, and modify existing rules
	as appropriate.

browser/Mmakefile:
	Mmakefile for the new directory, modelled on library/Mmakefile.

browser/browser_library.m:
	Umbrella file for the new directory, modelled on library/library.m.

{browser,library}/debugger_interface.m:
	Moved this file from library to browser without change.

browser/help.m:
	A new module for the help system of the debugger. Not yet used.

compiler/Mmakefile:
	Update to refer to the new directories and libraries where
	appropriate.

compiler/mercury_compile.m:
	If we are doing tracing, then pass -t instead of -i to c2init.

compiler/modules.m:
	When generating the .dep file, get the grade flags passed to c2init.

doc/Mmakefile:
	Remove the special treatment of library/debugger_interface.m.

library/Mmakefile:
	Update to refer to the new directories and libraries where
	appropriate, and to conform to the new name of the library.

library/library.m:
	Do not import debugger_interface.

profiler/Mmakefile:
	Update to refer to the new directories and libraries where
	appropriate.

runtime/Mmakefile:
	Update to refer to the new directories and libraries where
	appropriate, and to conform to the new name of the library.

	Remove references to files being moved to the trace directory.

runtime/mercury_init.h:
	Refer to the automatically generated dll header file by its new name
	(renamed because the runtime library is renamed).

	Add declarations to support the new global variable MR_trace_func_ptr.

runtime/mercury_memory_handlers.c:
runtime/mercury_memory_zones.c:
runtime/mercury_misc.c:
	Remove inappropriate #includes of "mercury_trace.h", and substitute
	a #include of "mercury_trace_base.h" if necessary.

{runtime,trace}/mercury_trace.[ch]:
{runtime,trace}/mercury_trace_external.[ch]:
{runtime,trace}/mercury_trace_internal.[ch]:
	Move these files from the runtime to the trace directory.

	The only changes are the removal from mercury_trace.h of declarations
	added to runtime/mercury_trace_base.h, and the change from MR_trace
	to MR_trace_real.

runtime/mercury_trace_base.[ch]:
	Define MR_trace(), which does an indirect call through
	MR_trace_func_ptr if the event should be traced.

	Define MR_trace_fake, which just prints an error message.
	Its address will be assigned to MR_trace_func_ptr if tracing
	is not enabled.

	Define the types needed by the signature of MR_trace.

	Fix an old bug: s/MERCURY_TRACE_PERMANENT_H/MERCURY_TRACE_BASE_H/.

runtime/mercury_wrapper.[ch]:
	Add the new global variable MR_trace_func_ptr.

scripts/c2init.in:
	Add a new option, -t/--trace, which enables tracing by causing the
	address of MR_trace_real to be assigned to MR_trace_func_ptr.

	Have this option be implied by the grade. Also have the old option
	-i (need initialization code) be implied by the grade, as well as by
	-t.

scripts/ml.in:
	Include the new libraries in the link command.

tests/debugger/Mmakefile:
	Include -t instead of -i in the list of c2init options. (-t implies
	-i.)

tools/bootcheck:
	Copy and build the new directories as appropriate. The trace directory
	is treated like the runtime, the browser directory is treated like the
	library.

trace/Mmakefile:
	Mmakefile for the new directory, modelled on runtime/Mmakefile.

util/mkinit.c:
	Add the new option -t, as discussed above.
	Mmakefile for the new directory, modelled on runtime/Mmakefile.

util/Mmakefile:
	Specify -O0, since with the default optimization level, gcc on
	cyclone ignores the assignment of TRUE to need_tracing when -t is
	given (!!!).
1998-09-29 05:12:06 +00:00
Fergus Henderson
cb59959834 Fix a syntax error.
Estimated hours taken: 0.1

Makefile.DLLs:
	Fix a syntax error.
1997-09-29 17:22:07 +00:00
Fergus Henderson
c6af510323 Implement support for DLLs on Windows.
Estimated hours taken: 24

Implement support for DLLs on Windows.
The changes consisted of

1.  Adding `Makefile.DLLs', which is a file I wrote contains
    GNU Make rules for building DLLs.  Making sure that
    the various Mmakefiles include that one.

2.  Making sure we #include the "libfoo_dll.h" header file
    generated by `Makefile.DLLs' before every place that
    references a global variable.

3.  Making sure that code which defines the DLLs is
    compiled with -Dlibfoo_DEFINE_DLL.

5.  Changing various places to explicitly register the data
    segment as a root set with the conservative garbage collector.
    This was necessary to get GC working with DLLs under Windows
    (there doesn't seem to be any way of automatically finding
    the data segments of DLLs under win32).

6.  Changing the way names are mangled to ensure that the assembler
    names always contain a leading underscore, since `dlltool'
    on gnu-win32 requires this.

TODO:
- Document how users can create their own DLLs.
- Add support for that to Mmake.

configure.in:
Mmake.common.in:
	Add USE_DLLS variable.  (Most of the Makefile changes below are
	conditionalized on this variable.)

boehm_gc/Makefile:
	Add dependency $(OBJS) : libgc_dll.h.
	Add `-DGC_DEFINE_DLL' to CFLAGS.
	Include Mmakefile.DLLs.
	Add new targets `dll' and `test_dll'.

boehm_gc/Mmakefile:
	Add stuff to install libgc_dll.h and libgc_globals.h.

boehm_gc/gc.h:
	For __CYGWIN32__, #include "libgc_dll.h".
	This is necessary to handle global variables in DLLs on Windows.
	For __CYGWIN32__, define GC_INIT() to add the
	data segment of the current DLL or executable as
	a new root set.

library/Mmakefile:
	Add stuff needed for building DLLs.

runtime/wrapper.mod:
library/io.m:
	Add call to GC_INIT() to register the root set for
	libmer.dll and libmercury.dll respectively.
	In wrapper.mod, move the call to GC_is_visible
	_after_ the calls to GC_INIT().

runtime/Mmakefile:
	Add stuff needed for building DLLs.

runtime/init.h:
runtime/imp.h:
runtime/dummy.c:
runtime/label.c:
runtime/memory.c:
runtime/table.c:
	For __CYGWIN32__, make sure we #include "libmer_dll.h".
	before defining global variables.
	This is necessary to handle global variables in DLLs
	on Windows.

runtime/goto.h:
util/mdemangle.c:
prof/demangle.m:
	Change the way names are mangled to ensure that the assembler
	names always contain a leading underscore, since `dlltool'
	on gnu-win32 requires this.

util/mkinit.c:
	For __CYGIN32__, when using DLLs, make sure we initialize the
	_impure_ptr of the DLLs that we're using.

library/Mmake:
runtime/Mmake:
	Compile with -Dlibfoo_USE_DLL options.
	Add code to install libfoo_dll.h and libfoo_globals.h.
	Include Mmakefile.DLLs.
1997-08-28 17:52:54 +00:00