8.1 CodeBuilder Development Tools8.1.1 Programs, Libraries and Include Files8.2 PEF and XCOFF
8.1.2 Documentation
8.1.3 Program Sources
8.3 Shared Libraries8.3.1 Shared Library Production8.4 Traditional UNIX Libraries
8.3.2 Run-Time and Compile-Time Libraries
8.3.3 Run-Time and Compile-Time Naming Conventions
8.5 Header Files8.5.1 Pre-Defined Names8.6 Compiling Sources8.6.1 Ada8.7 Linking Executables
8.6.2 C
8.6.3 Objective-C
8.6.4 C++
8.6.5 Fortran
8.6.6 Java8.7.1 ld8.8 To make or pmake
8.7.2 mkpef
8.9 Symbol Information
8.10 Debugging8.10.1 Debugging Using gdb8.10.3 Environment Variables for Debugging and Monitoring
8.10.2 Macintosh Debugging Tools
8.10.2.1 MacsBug
8.10.2.2 The Debugger
8.10.2.3 Macintosh Debugger for PowerPC
8.10.2.4 Metrowerks Debugger8.10.3.1 DEBUGGERFIRST8.11 Making Macintosh Applications
8.10.3.2 STACKCHK
8.10.3.3 MEMSTATS8.11.1 Macintosh OS Header Definition Files8.12 Cross-Development Tools And Targets
8.11.2 Macintosh OS Interface Libraries
8.11.3 Macintosh Application Startup Routine
8.11.4 Macintosh Application Construction8.12.1 Default CodeBuilder Environment8.13 Porting Software to CodeBuilder8.13.1 Real Memory Issues8.14 Programming Example8.13.1.1 Stack Overrun
8.13.1.2 Allocating Memory in CodeBuilder
8.13.1.3 Calculating Memory Requirements
8.13.1.4 Setting the CodeBuilder Heap Size
8.13.1.5 Problem Areas8.14.1 Rogue
8.14.2 Building the Executable
8.14.3 Debugging Using MacsBug or Other Macintosh Debuggers
MachTen CodeBuilder provides a rich UNIX software development environment.
The CodeBuilder software tool suite has been modified to work in real memory
for Macintosh hardware. The traditional UNIX software development tools
- ld, nm, ar, etc. - have been ported to run
in PowerPC native mode and produce PowerPC native mode Code Fragments.
TOOLS FOR MANAGING SOFTWARE DEVELOPMENT | |
---|---|
Revision
Control System (RCS) | Automates the storing, retrieval, logging, identification and merging
of multiple revisions of text |
TOOLS FOR SUPPORTING SOURCE CODE DEVELOPMENT | |
---|---|
flex | Generates lexical analysis programs |
indent | Formats C Code |
yacc | "yet another compiler-compiler" |
TOOLS FOR BUILDING
LIBRARIES AND PROGRAMS | |
---|---|
ar | Library archive utility. |
as | PPC assembler. |
cpp | GNU preprocessor. |
g++ | Wrapper for calling gcc with appropriate options for compiling and loading
C++ objects. |
g77 | Wrapper for calling gcc with appropriate options for compiling and loading
Fortran objects. |
gcc | GNU CC compiler director: forks the appropriate tools for compiling
and loading the objects specified. |
gdb | Symbolic debugger. |
gnatmake | GNAT make program. |
ld | Combines several object files into one, resolving external references
and searching libraries. |
make | Executes a scripted set of commands to update one or more target files;
GNU version. |
nm | Prints lists of symbols in object files. |
pmake | Executes a scripted set of commands to update one or more target files;
BSD version. |
ranlib | Converts archives to a form which ld can load more rapidly. |
restool | Provides access to Macintosh file resources. |
setstackspace | Adjusts size of program stack. |
COMPILER ENGINES | |
---|---|
cc1 | GNU C language compiler |
cc1plus | GNU C++ language compiler |
f771 | GNU Fortran language compiler |
gnat1 | GNU Ada language compiler |
cc1obj | GNU Objective-C compiler |
LIBRARIES | |
---|---|
libc.a | the C library |
libobjc.a | the Objective-C library |
libcap.a | Columbia AppleTalk Protocol library |
libcompat.a | Contains obsolete BSD4.3 functions for compatibility |
libcurses.a | Old screen functions with cursor motion |
libf2c.a | The GNU Fortran library |
libfl.a | The library for flex |
libg++.a | The GNU C++ library; includes libio.a functions |
libgdbm.a | GNU database management functions |
libgnat.a | The GNU Ada library |
libgthreads.a | POSIX Threads functions |
libio.a | New GNU C++ iostream classes |
libiostream.a | Old GNU C++ iostream classes; use libio.a instead |
libkaffe-agent.a | kaffe support library |
libkaffe-native.a | kaffe support library |
libkaffe-net.a | kaffe support library |
libkaffe-vm.a | kaffe support library |
libkvm.a | Kernel memory interface functions |
libm.a | Math library |
libncurses.a | New screen functions with cursor motion |
libresolv.a | Domain Name Server interface functions |
librpc.a | Remote procedure call library |
librx.a | GNU regular expression functions |
libstdc++.a | GNU ANSI C++ library |
libterm.a | Terminal independent operation library package |
libutil.a | Daemon support functions |
liby.a | The library for yacc |
TOOLS FOR BUILDING X WINDOWS PROGRAMS | |
---|---|
imake | X platform independent make environment |
libFS.a | Font Service library for X font clients |
libICE.a | Inter Client Exchange library |
liboldX.a | X11R4 support library |
libolgx.a | OpenLook graphics library |
libPEX5.a | PHIGS Extensions to X |
libSM.a | X Session Management library |
libX11.a | Core X protocol library |
libXau.a | X security authorization library |
libXaw.a | The Athena widget set of buttons, pull-down menus, labels, etc. |
libXdmcp.a | X Display Manager Control Protocol library |
libXext.a | X extensions library |
libXi.a | Alternative input device extension library |
libXIE.a | X Image Extensions library |
libXmu.a | X miscellaneous utilities library |
libXpm.a | X pixmap image library |
libXt.a | X Intrinsics toolkit library |
libXtst.a | X Test library |
libXview.a | X View library |
symbAUsing the command line flag Xlexport=some_symbols, the three symbols would be found in the shared library and would be set up for export and linkage when an application program requested that the library be included in its import file list.
symbB
symbC
gcc -o /hfs/shlb/shrlib -sharedlibrary -expall *.owill produce a run-time shared library in the file shrlib, and will produce a compile-time shared library in the file /hfs/shlb/shrlib.a that exports all symbols. Note that shared libraries must be created as HFS files because they require the setting of certain Macintosh resources via the MacOS Resource Manager.
#ifdef __MACHTEN__Similarly, definitions, declarations, and code which CodeBuilder does not support should be enclosed as follows:
/* Code generic to any CodeBuilder environment */
#endif
#ifdef __MACHTEN_68K__
/* 68K specific code */
#endif
#ifdef __MACHTEN_PPC__
/* PPC specific code */
#endif
#ifndef __MACHTEN__
/* Code that is inappropriate for CodeBuilder */
#endif
#ifndef __MACHTEN_68K__
/* Code that is inappropriate for the 68K */
#endif
#ifndef __MACHTEN_PPC__
/* Code that is inappropriate for the PPC */
#endif
gnatmake hellognatmake is a master program which invokes the tools to perform necessary compilation, binding, and linking, in the proper order. Alternatively, gcc may be used to generate an object file or assembly source as shown below:
gcc -c -O hello.adbThese commands generate the files hello.o and hello.s, respectively. Intermediate files from the compilation tools are discarded.
gcc -S -O hello.adb
gcc -O -o hello hello.cSometimes, the object file is needed, or even the intermediate assembly code or preprocessor output. Again using hello.c as our example, the following commands:
gcc -O -c hello.cgenerate the files hello.o, hello.s, and hello.i, respectively.
gcc -O -S hello.c
gcc -E -o hello.i hello.c
gcc -O -o hello hello.m Printer.m -lobjcSometimes, the object file is needed, or even the intermediate assembly code or preprocessor output. Again using hello.c as our example, the following commands:
gcc -O -c hello.mgenerate the files hello.o, hello.s, and hello.i, respectively.
gcc -O -S hello.m
gcc -E -o hello.i hello.m
g++ -O -o hello hello.CSometimes, the object file is needed, or even the intermediate assembly code or preprocessor output. Again using hello.C as our example, the following commands:
g++ -O -c hello.Cgenerate the files hello.o, hello.s, and hello.ii, respectively.
g++ -O -S hello.C
g++ -E -o hello.ii hello.C
g77 -O -o hello hello.FSometimes, the object file is needed, or even the intermediate assembly code or preprocessor output. Again using hello.F as our example, the following commands:
g77 -O -c hello.Fgenerate the files hello.o, hello.s, and hello.i, respectively.
g77 -O -S hello.F
g77 -E -o hello.i hello.F
setenv CLASSPATH .:/usr/share/kaffe/classes.zipThe following command illustrates compiling Java source:
setenv KAFFEHOME /usr/share/kaffe
setenv LD_LIBRARY_PATH /usr/lib
javac hello.javaIt generates the file hello.class, which may be loaded and executed by:
kaffe helloNote that the argument to kaffe is the class name, not the file name.
nm -n afile.xcoffwill produce symbol information relative to location zero for application data and text.
gcc -g -o hello hello.cwill produce the PEF output file hello and the XCOFF output file named hello.xcoff. Note that the optimization flag (-O) has been left out to avoid confusing matchups between source code lines and the generated assembly code.
gdb hellowill start execution of the gdb application which will automatically search for both PEF and XCOFF files. Once both files are found, UNIX standard gdb commands may be given to set break points, examine data and complete the debugging process. Further information on the gdb application can be found in the gdb manual page accessed via the CodeBuilder man command.
setenv variable value
unsetenv variable
export variable=valueConsult the man page for your shell of choice for the complete details on setting or unsetting environment variables, and the special shell script file(s) that are processed during start-up.
unset variable
mkpef -lfilename:=fragmentname -creator XXXX -type shlb inputfile.xcoff outputfile
gcc -O -I/usr/include/MacOS -Dpascal="" -c hello.cwill define (with -D) pascal to be nothing for MacOS compatibility, and will search the /usr/include/MacOS directory for include files. It will also use optimization as usual for a faster and more compact binary.
ld -o /hfs/APPL/hello -Xlcreator 'MISC' -Xltype APPL \will create an output file hello in the /hfs/APPL folder. Note that the application must be created as an HFS file because it requires the setting of certain Macintosh resources via the MacOS Resource Manager.
/usr/macppc/lib/MacOS/Mac_start.o \
hello.o \
/usr/macppc/lib/MacOS/InterfaceLib.a
etext, edata, end | In a virtual memory environment, programs can make assumptions about
the relative locations of the programs text, data, and bss sections. In
real memory these assumptions simply are not valid. Programs using the symbols
etext, edata, and end probably require modifications
to not depend on the relative locations of these symbols. |
sbrk | Some programs that call sbrk() make the assumption that each
successive call to sbrk will return memory addresses contiguous to the previous
call. This is not possible to support in a "real memory" environment,
thus these programs require modifications to work with CodeBuilder. In CodeBuilder,
sbrk translates into a heap-oriented memory allocation call. |
page boundary | Typical virtual memory implementations allocate memory on page boundaries,
thus requests to allocate less than some minimum amount actually allocate
this minimum. Some programs may accidentally depend on this by accessing
past the minimum memory length requested, without causing problems. In a
real memory implementation, memory is a scarce resource, and memory requests
are typically rounded to a much smaller size, like a multiple of 16 or 32
bytes. Accidentally accessing past this real memory boundary will most certainly
cause problems to the actual owner of this space. |
out of memory during compile | Both the C compiler (gcc and cc1) and the make
program (make) require a lot of memory to run. If you are compiling
large files and have an elaborate program generation environment built up
where a Makefile causes multiple copies of make to run at the same
time, this will require large amounts of memory and may cause either the
C compiler or make to fail during some memory allocation request,
aborting the program generation. A potential solution to this problem is
to use some of make's more sophisticated features, such as VPATH, and to
reorganize the program generation process to be completely controlled from
one or two make invocations. |
fragmentation | In a real memory situation it is possibly to fragment memory in such
a way that, although the total free memory is sufficient to satisfy a particular
allocation request, none of the individual memory pieces is big enough to
satisfy the request. This situation can be aggravated by use of the realloc()
call, with successively larger sizes. Quitting, and then restarting CodeBuilder
will solve this. |
sticky bits | The compilers, cc1, cc1plus, f771, cclobs,
and gnat1 are installed with the "sticky bit" set. This
causes them to remain in memory once they are used until CodeBuilder quits.
This speeds execution, but may reserve too much memory if you are using
multiple languages and have limited memory. Removing the sticky bit will
cause the programs to be loaded into memory each time they are used. This
may be done as root by: chmod 555 /usr/macppc/bin/filename. |
cd /base/src/bsd4.4/games/rogueThe first pmake command creates the directory that the symbolic link obj points to if it does not already exist; in this example it is /base/macppc/bsd4.4/games/rogue. This is the directory in which the objects and executable will be generated.
pmake objdir
pmake