1 This is a loose collection of notes for people hacking on simulators.
2 If this document gets big enough it can be prettied up then.
6 - The "common" directory
7 - Common Makefile Support
9 - Generating "configure" files
11 - C Language Assumptions
12 - "dump" commands under gdb
14 The "common" directory
15 ======================
17 The common directory contains:
19 - common documentation files (e.g. run.1, and maybe in time .texi files)
20 - common source files (e.g. run.c)
21 - common Makefile fragment and configury (e.g. Make-common.in, aclocal.m4).
23 In addition "common" contains portions of the system call support
24 (e.g. callback.c, nltvals.def).
26 Even though no files are built in this directory, it is still configured
27 so support for regenerating nltvals.def is present.
29 Common Makefile Support
30 =======================
32 A common configuration framework is available for simulators that want
33 to use it. The common framework exists to remove a lot of duplication
34 in configure.in and Makefile.in, and it also provides a foundation for
35 enhancing the simulators uniformly (e.g. the more they share in common
36 the easier a feature added to one is added to all).
38 The configure.in of a simulator using the common framework should look like:
41 dnl Process this file with autoconf to produce a configure script.
47 ... target specific additions ...
54 - invokes the autoconf macros most often used by the simulators
55 - defines --enable/--with options usable by all simulators
56 - initializes sim_link_files/sim_link_links as the set of symbolic links
61 - creates the symbolic links defined in sim_link_{files,links}
63 - creates the Makefile
65 The Makefile.in of a simulator using the common framework should look like:
68 # Makefile for blah ...
71 ## COMMON_PRE_CONFIG_FRAG
73 # These variables are given default values in COMMON_PRE_CONFIG_FRAG.
74 # We override the ones we need to here.
75 # Not all of these need to be mentioned, only the necessary ones.
76 # In fact it is better to *not* mention ones if the value is the default.
78 # List of object files, less common parts.
80 # List of extra dependencies.
81 # Generally this consists of simulator specific files included by sim-main.h.
83 # List of flags to always pass to $(CC).
85 # List of extra libraries to link with.
87 # List of extra program dependencies.
89 # List of main object files for `run'.
91 # Dependency of `all' to build any extra files.
93 # Dependency of `install' to install any extra files.
95 # Dependency of `clean' to clean any extra files.
98 ## COMMON_POST_CONFIG_FRAG
100 # Rules need to build $(SIM_OBJS), plus whatever else the target wants.
102 ... target specific rules ...
105 COMMON_{PRE,POST}_CONFIG_FRAG are markers for SIM_AC_OUTPUT to tell it
106 where to insert the two pieces of common/Make-common.in.
107 The resulting Makefile is created by doing autoconf substitions on
108 both the target's Makefile.in and Make-common.in, and inserting
109 the two pieces of Make-common.in into the target's Makefile.in at
110 COMMON_{PRE,POST}_CONFIG_FRAG.
112 Note that SIM_EXTRA_{INSTALL,CLEAN} could be removed and "::" targets
113 could be used instead. However, it's not clear yet whether "::" targets
119 Many files generate program symbols at compile time.
120 Such symbols can't be found with grep nor do they normally appear in
121 the TAGS file. To get around this, source files can add the comment
123 /* TAGS: foo1 foo2 */
125 where foo1, foo2 are program symbols. Symbols found in such comments
126 are greppable and appear in the TAGS file.
128 Generating "configure" files
129 ============================
131 For targets using the common framework, "configure" can be generated
132 by running `autoconf'.
134 To regenerate the configure files for all targets using the common framework:
137 $ make -f Makefile.in SHELL=/bin/sh autoconf-common
139 To add a change-log entry to the ChangeLog file for each updated
140 directory (WARNING - check the modified new-ChangeLog files before
143 $ make -f Makefile.in SHELL=/bin/sh autoconf-changelog
144 $ more */new-ChangeLog
145 $ make -f Makefile.in SHELL=/bin/sh autoconf-install
147 In a similar vein, both the configure and config.in files can be
148 updated using the sequence:
151 $ make -f Makefile.in SHELL=/bin/sh autoheader-common
152 $ make -f Makefile.in SHELL=/bin/sh autoheader-changelog
153 $ more */new-ChangeLog
154 $ make -f Makefile.in SHELL=/bin/sh autoheader-install
159 File tconfig.in defines one or more target configuration macros
160 (e.g. a tm.h file). There are very few that need defining.
161 For a list of all of them, see common/tconfig.in.
162 It contains them all, commented out.
163 The intent is that a new port can just copy this file and
164 define the ones it needs.
166 C Language Assumptions
167 ======================
169 The programmer may assume that the simulator is being built using an
170 ANSI C compiler that supports a 64 bit data type. Consequently:
172 o prototypes can be used (although using
173 PARAMS() and K&R declarations wouldn't
176 o If sim-types.h is included, the two
177 types signed64 and unsigned64 are
180 o The type `unsigned' is valid.
182 However, the user should be aware of the following:
184 o GCC's `<number>LL' is NOT acceptable.
185 Microsoft-C doesn't reconize it.
187 o MSC's `<number>i64' is NOT acceptable.
188 GCC doesn't reconize it.
190 o GCC's `long long' MSC's `_int64' can
191 NOT be used to define 64 bit integer data
194 o An empty array (eg int a[0]) is not valid.
196 When building with GCC it is effectivly a requirement that
197 --enable-sim-warnings be specified during configuration.
199 "dump" commands under gdb
200 =========================
202 gdbinit.in contains the following
205 set sim_debug_dump ()
208 Simulators that define the sim_debug_dump function can then have their
209 internal state pretty printed from gdb.
211 FIXME: This can obviously be made more elaborate. As needed it will be.
213 "dump" commands under gdb
214 =========================
216 gdbinit.in contains the following
219 set sim_debug_dump ()
222 Simulators that define the sim_debug_dump function can then have their
223 internal state pretty printed from gdb.
225 FIXME: This can obviously be made more elaborate. As needed it will be.