source: vendor/emx/current/src/doc/emxgnu.src

Last change on this file was 18, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 60.7 KB
Line 
1þtext
2===============================================================================
3emxgnu.doc emx 0.9d GNU DEVELOPMENT TOOLS INFORMATION 21-Dec-1998
4===============================================================================
5 Copyright (c) 1990-1998 by Eberhard Mattes
6þendtext
7
8þtitle GNU Development Tools Information
9
10þformat bold emx emxbind emximp emxomf emxomfld emxtsf pmgdb
11þformat bold GCC CPP GDB GAS GASP readline ld ar nm objdump GPPDEMID
12þformat bold genclass makeinfo texindex termcap texinfo
13
14þformat tty .a .cc .cpp .cxx .C .def .dll .exe .o .obj .res .map
15þformat tty install.doc build.doc emxl.exe emx.dll emxlibc.dll emxlibcm.dll
16þformat tty emxlibcs.dll emxomf.exe
17þformat tty gcc.exe cpp.exe cc1.exe cc1plus.exe cc1obj.exe as.exe
18þformat tty c_alias.a c_alias.lib sys.lib os2.a os2.lib
19þformat tty emx2.a emx2.lib libg++
20þformat tty dll0.o dll0.obj crt0.o lib1.a lib2.a
21þformat tty .gdbinit termcap.dat gppdemid.dll
22þformat tty /emx /emx/bin /emx/etc
23þformat tty -mepilogue -mno-epilogue -mprobe -mno-probe -pg -pn -fstack-check
24þformat tty -Zdll -Zexe -Zmt -Zmtd -Zmts -Zomf -Zstack -Zso -Zno-rte -Zcrtdll
25þformat tty -Zsys -Zno-demangle -Zdemangle-proto -Zbsd-signals -Zsysv-signals
26þformat tty -Zsmall-conv
27þformat tty -lgpp -lobjc -ltermcap -lbtermcap -lstdcpp -ltmalloc
28þformat tty -c -s -d -da -freg-struct-return
29þformat tty -fpcc-struct-return -E -R -l -r -b -ZC++-comments -Zc++-comments
30þformat tty -Zlinker -O -Xlinker -Zmap -Zstrip -Zbin-files
31
32þformat tty __MT__ __32BIT__ __EMX__
33
34þformat tty alloca() fopen() open() ptrace() malloc() _heapchk() _tmalloc()
35þformat tty fork()
36þformat tty <stdarg.h> <varargs.h> <fix-args.h>
37þformat tty DosCreateThread DosAllocMem
38
39þformat tty __.SYMDEF
40
41þformat abbrev etc. W.M.
42
43
44þif text
45þh= Table of Contents
46þtoc
47þendif
48
49
50þh1 Introduction to GNU Development Tools Information
51þipf
52:font facename=Helv size=24x14.:hp2.GNU Development Tools Information
53:ehp2.
54:p.
55:font facename=Helv size=16x10. Copyright (c) 1990-1993 by Eberhard Mattes
56:font facename=default size=0x0.
57:p.
58þendipf
59
60 This text describes how to use the GNU C Compiler and other GNU
61 utilities with emx.
62þif text
63 See emxdev.doc for instructions for the emx utilities.
64þendif
65 For detailed information about GCC, GDB, and GAS, read the GCC, GDB,
66 and GAS manuals, see install.doc. See build.doc for details on
67 compiling the GNU utilities.
68
69 All programs assume that the entire package is installed on one
70 disk drive in these directories:
71
72þexample
73/emx/bin Executable files
74/emx/etc termcap.dat
75/emx/lib Library files
76/emx/include Header files (C language)
77/emx/include/cpp Header files (C++ language)
78/emx/include/objc Header files (Objective C language)
79þendexample
80
81If the /emx directory is not on the current drive, use the
82C_INCLUDE_PATH and LIBRARY_PATH environment variables, for instance
83
84þexample
85set C_INCLUDE_PATH=c:/emx/include
86set LIBRARY_PATH=c:/emx/lib
87þendexample
88
89 to use drive C.
90
91 Use forward slashes instead of backward slashes in path names!
92
93 Directories:
94
95þexample
96/emx Main directory, empty
97/emx/bin Executable files and batch files
98/emx/dll Dynamic link libraries
99/emx/doc Documentation
100/emx/etc termcap.dat
101/emx/gnu/binutils.old old GNU binary utilities (sources)
102/emx/gnu/binutils.26 new GNU binary utilities (sources)
103/emx/gnu/doc Documentation
104/emx/gnu/duel DUEL (for GDB)
105/emx/gnu/gcc-2.8 GNU C compiler source (GCC)
106/emx/gnu/gdb-4.16 GNU debugger source (GDB)
107/emx/gnu/gppdemid C++ demangler for LINK386
108/emx/gnu/info GNU info source
109/emx/gnu/libtxi -libtxi (for GNU info)
110/emx/gnu/libg++-2.8.1.1a GNU C++ library (obsolete)
111/emx/gnu/libstdc++-2.8.1.1 GNU standard C++ library
112/emx/gnu/makeinfo GNU makeinfo source
113/emx/gnu/termcap GNU termcap
114/emx/gnu/texindex GNU texindex source
115/emx/include header files (C language)
116/emx/include/cpp Header files (C++ language)
117/emx/include/objc Header files (Objective C language)
118/emx/lib Libraries
119þendexample
120
121
122þh1 GCC -- compiling and linking C and C++ programs
123þlabel GCC
124þi1 GCC
125þkeyword GCC
126
127 GCC 2.8.1 has been ported to emx, including Richard W.M. Jones's
128 bounds checking patches.
129
130þipfminitoc
131
132þh2 Calling GCC
133þlabel Calling GCC
134
135For small projects, one invokation GCC can be used to compile and link
136the program. Example:
137
138þexample
139gcc dwim.c
140þendexample
141
142 This assumes that emxl.exe can be found in one of the directories
143 listed in the EMXPATH and PATH environment variables, or in the
144 directory /emx/bin, see also þhpt{ld}. If no output file name is
145 given, the name of the first input file, with .exe extension (or
146 .dll extension if -Zdll is given), is used for the output file
147 unless linking is suppressed (with the -c option, for instance).
148 That is, the above example creates þtt{dwim.exe}.
149
150 Please note that the example given above creates a file named
151 þtt{dwim} which will be deleted after conversion to .exe format.
152
153 If the output file name doesn't end in .exe or .dll, the output file
154 will have a.out format (however, see þhpt{-Zexe}). Example:
155
156þexample
157gcc -o dwim dwim.c
158þendexample
159
160 This example creates the a.out file `þtt{dwim}'.
161
162
163þh2 Environment variables
164þlabel Environment variables for GCC
165
166 If you want to develop programs on a drive different from the drive
167 where emx is installed, you have to set the C_INCLUDE_PATH and
168 LIBRARY_PATH environment variables, for instance,
169
170þexample
171set C_INCLUDE_PATH=c:/emx/include
172set LIBRARY_PATH=c:/emx/lib
173þendexample
174
175 If you want to compile þhpt{C++} programs, set CPLUS_INCLUDE_PATH as well:
176
177þexample
178set CPLUS_INCLUDE_PATH=c:/emx/include/cpp;c:/emx/include
179þendexample
180
181 If you want to compile þhpt{Objective C} programs, set
182 OBJC_INCLUDE_PATH as well:
183
184þexample
185set OBJC_INCLUDE_PATH=c:/emx/include
186þendexample
187
188 The genclass utility needs the following environment variable:
189
190þexample
191set PROTODIR=c:/emx/include/cpp/gen
192þendexample
193
194 If the TMPDIR, TMP and TEMP environment variables are not set, GCC
195 writes temporary files in the current working directory. GCC tries
196 TMPDIR, TMP and TEMP in turn and uses the first valid one. Note
197 that þtt{c:} is not a valid directory name, you have to use þtt{c:/}
198 or þtt{\} instead. In other cases, a trailing slash or backslash is
199 optional. For instance, use
200
201þexample
202SET TMPDIR=f:/tmp/
203þendexample
204
205 to put temporary files into the þtt{f:/tmp} directory.
206
207 When compiling projects consisting of many modules (such as
208 libraries) under OS/2, you can speed up compilation if you have
209 enough memory by keeping GCC in memory. For example, to keep GCC in
210 memory for 5 minutes, use
211
212þexample
213set GCCLOAD=5
214þendexample
215
216 The following programs use GCCLOAD: gcc.exe, cpp.exe, cc1.exe,
217 cc1plus.exe, cc1obj.exe, as.exe and emxomf.exe.
218
219 You can put GCC options into the environment variable GCCOPT. These
220 options will be read before the options given on the command line.
221 For example, to use þtt{-pipe}, type
222
223þexample
224set GCCOPT=-pipe
225þendexample
226
227þh2 Bounds checking
228
229 The emx port of GCC includes Richard W.M. Jones's bounds checking
230 patches. See the GCC manual and þtt{\emx\gnu\doc\bounds\README} for
231 details. The complete report is in
232 þtt{\emx\gnu\doc\bounds\bcrep2.ps} (shipped in þtt{gnudoc.zip}).
233 Use GhostScript if you don't have a PostScript printer.
234 þtt{\emx\gnu\doc\bounds\bcreport.txt} contains important excerpts
235 from an earlier version of the report as plain ASCII text.
236
237 There are a few additional restrictions under OS/2:
238
239þitemize
240þitem
241 Bounds checking is not available for multithread programs
242þitem
243 Bounds checking is available for statically linked programs only
244þitem
245 Bounds checking is not available for DLLs
246þitem
247 If your program uses _tmalloc(), you have use the -ltmalloc
248 option as the bounds checking library þtt{check.a} replaces
249 malloc()
250þenditemize
251
252 The header files <stdarg.h> and <varargs.h> automatically include
253 <fix-args.h> if bounds checking is enabled. Therefore you don't
254 have to include <fix-args.h> yourself.
255
256
257þh2 #pragma statement
258þlabel #pragma statement
259þlabel #pragma pack()
260þindex #pragma pack()
261þkeyword #pragma
262
263 The emx port of GCC supports the
264
265þtypewriter
266 #pragma pack(þpa{N})
267þendtypewriter
268
269 statement where þpa{N} is 1, 2 or 4. The default is 4. Structure
270 fields are aligned to multiples of þpa{N} bytes, according to the
271 value þpa{N} as set by the last þtt{#pragma pack} statement.
272
273þexample
274#pragma pack()
275þendexample
276
277 reverts to the default (4). Note that other C compilers revert to
278 the value in effect before the previous þtt{#pragma pack}
279 statement.
280
281
282þh2 Additional command line options
283þlabel Additional command line options
284
285 Several command line options have been added to GCC:
286
287þlist
288þitem þhpt{-mepilogue}
289
290 emit only one epilogue per function
291
292þitem -mno-epilogue
293
294 emit multiple epilogues per function if appropriate (default)
295
296þitem þhpt{-mprobe}
297
298 generate stack probes
299
300þitem -mno-probe
301
302 do not generate stack probes (default)
303
304þitem þhpt{-pn}
305
306 Enable profiling but do not generate profile hooks
307
308þitem þhpt{-Zbin-files}
309
310 open files in binary mode by default
311
312þitem þhpt{-Zbsd-signals}
313
314 select the `BSD' signal processing model
315
316þitem þhpt{-Zcrtdll}
317
318 link the C library dynamically
319
320þitem þhpt{-Zdll}
321
322 create a dynamic link library
323
324þitem þhpt{-Zexe}
325
326 touch output file, add .exe extension
327
328þitem þhpt{-Zmap}
329
330 let LINK386 or emxbind create a .map file
331
332þitem þhpt{-Zlinker}
333
334 pass option to LINK386
335
336þitem þhpt{-Zmt}
337
338 multithread code
339
340þitem þhpt{-Zmtd}
341
342 multithread code, link C library dynamically
343
344þitem þhpt{-Zmts}
345
346 multithread code, link C library statically
347
348þitem þhpt{-Zno-rte}
349
350 create DLL without runtime environment
351
352þitem þhpt{-Zomf}
353
354 create .obj files instead of .o files
355
356þitem þhpt{-Zsmall-conv}
357
358 use small, fast, and inaccurate routines for converting decimal
359 numbers to binary and vice versa
360
361þitem þhpt{-Zstack}
362
363 set the stack size
364
365þitem þhpt{-Zso}
366
367 create stand-alone DLL
368
369þitem þhpt{-Zsys}
370
371 create stand-alone OS/2 program (no emx.dll)
372
373þitem þhpt{-Zsysv-signals}
374
375 select the `System V' signal processing model
376
377þendlist
378
379 The following table shows which compiler phases are affected by the
380 options. If an option affects the preprocessor, the compiler, or
381 the assembler, you should use that option when compiling. When an
382 option affects the linker, you should use that option when linking.
383 However, you can use options affecting the preprocessor, the
384 compiler, or the assembler also when not compiling; you can use
385 options affecting the linker also when not linking.
386
387þexample
388 ³ Prepro- ³ Com- ³ Assem- ³
389Option ³ cessor ³ piler ³ bler ³ Linker
390ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄ
391-mepilogue ³ X ³ X ³ ³
392-mno-epilogue ³ X ³ X ³ ³
393-mprobe ³ ³ X ³ ³
394-mno-probe ³ ³ X ³ ³
395ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄ
396-pg ³ X ³ X ³ ³ X
397-pn ³ ³ ³ ³ X
398ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄ
399-Zcrtdll ³ ³ ³ ³ X
400-Zdll ³ ³ ³ ³ X
401-Zmt ³ X ³ ³ ³ X
402-Zmtd ³ X ³ ³ ³ X
403-Zmts ³ X ³ ³ ³ X
404-Zomf ³ X ³ ³ X ³ X
405-Zno-rte ³ ³ ³ ³ X
406-Zso ³ ³ ³ ³ X
407-Zsys ³ ³ ³ ³ X
408ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄ
409-Zexe ³ ³ ³ ³ X
410-Zlinker ³ ³ ³ ³ X
411-Zmap ³ ³ ³ ³ X
412-Zstack ³ ³ ³ ³ X
413ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄ
414-Zbin-files ³ ³ ³ ³ X
415-Zbsd-signals ³ ³ ³ ³ X
416-Zsmall-conv ³ ³ ³ ³ X
417-Zsysv-signals ³ ³ ³ ³ X
418þendexample
419
420
421þh3 -mepilogue
422þlabel -mepilogue
423þi2 -mepilogue
424þi2 -mno-epilogue
425þkeyword -mepilogue -mno-epilogue
426
427 By default (-mno-epilogue), GCC may emit multiple epilogues (return
428 statements) per function if appropriate. With -mepilogue, GCC emits
429 only one epilogue at the end of each function; any function exit in
430 the middle of a function jumps to the epilogue at the end of the
431 function. Moreover, -mepilogue causes a symbol to be defined at the
432 start of the epilogue code. The name of that symbol is constructed
433 by prepending `tt{__POST$}' to the function's label.
434
435 -mno-epilogue generates faster code. For tracing with the OS/2
436 þtt{TRACE} command, however, each function should have only one
437 epilogue, so that a tracepoint can be defined for the epilogue.
438
439 The C library for emx has been compiled with -mepilogue to enable
440 tracing of DLLs. See also þhpt{emxtsf}.
441
442þh3 -mprobe
443þlabel -mprobe
444þi2 -mprobe
445þi2 -mno-probe
446þkeyword -mprobe -mno-probe
447
448 -mprobe enables generation of þhpt{stack probes} (see below),
449 -mno-probe (which is the default) disables generation of stack
450 probes. See also GCC's -fstack-check option.
451
452 All libraries for emx are compiled with both stack probes and stack
453 checking enabled.
454
455
456þh3 -pn
457þlabel -pn
458þi2 -pn
459þkeyword -pn
460
461 -pn enables profiling by using þtt{gcrt0.o} instead of þtt{crt0.o}
462 for linking the program. In contrast to -pg, no profiling hooks are
463 generated.
464
465þh3 -Zbin-files
466þlabel -Zbin-files
467þi2 -Zbin-files
468þkeyword -Zbin-files
469
470 The additional GCC command line option -Zbin-files causes the
471 program to be linked with þtt{binmode.o}, selecting binary mode
472 as default for fopen(), open(), etc.
473
474
475þh3 -Zbsd-signals
476þlabel -Zbsd-signals
477þi2 -Zbsd-signals
478þkeyword -Zbsd-signals
479
480 The additional GCC command line option -Zbsd-signals causes the
481 program to be linked with þtt{sigbsd.o}, selecting the `BSD' signal
482 processing model. See also þhpt{-Zsysv-signals}. -Zbsd-signals
483 cannot be used with þhpt{-Zsys}.
484
485
486þh3 -Zcrtdll
487þlabel -Zcrtdll
488þi2 -Zcrtdll
489þkeyword -Zcrtdll
490
491 -Zcrtdll causes the executable file to be linked dynamically to the
492 C runtime library. If -Zmt is also given, the program will use
493 emxlibcm.dll. Otherwise, the program will use emxlibcs.dll.
494 Without -Zcrtdll, the executable file is linked statically to the C
495 runtime library.
496
497 -Zcrtdll uses the import library þtt{c_import} and a small static
498 library (þtt{c_static}) which contains code that must be linked
499 statically. To link with a different import library, use
500 þsy{-Zcrtdll=<lib>} instead of -Zcrtdll. The library name
501 þsy{<lib>} must not include a directory or a suffix. The library
502 will be sought in the standard library path, therefore you can use
503 the þtt{-L} option for adding another library directory. Example:
504þexample
505gcc -Zcrtdll=myclib -L/mylib myprog.c
506þendexample
507þif ipf
508 See also þhpt{-Zmt}, þhpt{-Zmtd}, þhpt{-Zmts}, and þhpt{Startup
509 modules and libraries}.
510þendif
511
512
513þh3 -Zdll
514þlabel -Zdll
515þi2 -Zdll
516þkeyword -Zdll
517
518 The additional GCC command line option -Zdll causes the program to
519 be linked with dll0.o (or dll0.obj if þhpt{-Zomf} is given) instead
520 of crt0.o. This is required for creating dynamic link libraries.
521þif ipf
522 See also þhpt{Startup modules and libraries}.
523þendif
524
525
526þh3 -Zexe
527þlabel -Zexe
528þi2 -Zexe
529þkeyword -Zexe
530
531 To avoid changing Unix-style makefiles, the additional GCC command line
532 option -Zexe can be used. If -Zexe is present, the linker (ld or
533 emxomfld) automatically adds the .exe extension to the output file
534 name and creates an empty file of that name (without .exe) to keep
535 the þbf{make} utility happy. The output file name must not have an
536 extension. See the descriptions of þhpt{ld} and þhpt{emxomfld} for details.
537
538þh3 -Zlinker
539þlabel -Zlinker
540þi2 -Zlinker
541þkeyword -Zlinker
542
543 Use the additional GCC command line option -Zlinker to pass an
544 option to LINK386. -Zlinker should be used only when using the
545 -Zomf option. The argument following -Zlinker will be passed to
546 þhpt{emxomfld} (preceded by an -O option) which in turn will pass it
547 to LINK386. The LINK386 option must start with a slash. Example:
548
549þexample
550gcc yzzyx.obj -Zomf -Zlinker /runfromvdm
551þendexample
552
553 Don't confuse the -Zlinker option with the -Xlinker option, which
554 passes an option to þhpt{ld} or emxomfld.
555
556þh3 -Zmap
557þlabel -Zmap
558þi2 -Zmap
559þkeyword -Zmap
560
561 Use the additional GCC command line option -Zmap to let LINK386 or
562 emxbind create a .map file. The name of the .map file will be
563 derived from the output file name, both LINK386 and emxbind add the
564 default extension .map. To specify the name of the .map file, use
565 þsy{-Zmap=<map_file>}.
566
567 GCC passes the -Zmap option down to emxomfld (or ld) which passes
568 the file name down to LINK386 (or emxbind).
569
570 To get a detailed .map file including all the public symbols, also
571 use þtt{-Zlinker /map} with -Zomf. By default, the .map file
572 created by LINK386 lists only the segments. Example:
573
574þexample
575gcc -o dwimtest.exe dwim.c -Zomf -Zmap -Zlinker /map
576þendexample
577
578 Note that LINK386 creates the .map file in the same directory as the
579 .exe file unless the name of the .map file includes a path.
580
581þh3 -Zmt
582þlabel -Zmt
583þi2 -Zmt
584þkeyword -Zmt
585
586 Use the additional GCC command line option -Zmt to compile
587 multithread code. The preprocessor macro __MT__ will be
588 defined when -Zmt is used.
589þif ipf
590 See also þhpt{-Zmts} and þhpt{-Zmtd}.
591þendif
592
593
594þh3 -Zmtd
595þlabel -Zmtd
596þi2 -Zmtd
597þkeyword -Zmtd
598
599 Use the additional GCC command line option -Zmtd to link a
600 multithread program that uses emxlibcm.dll, the DLL version of
601 the C library. The preprocessor macro __MT__ will be defined when
602 -Zmtd is used. -Zmtd is equivalent to -Zmt -Zcrtdll and is provided
603 for compatibility with existing makefiles.
604þif ipf
605 See also þhpt{-Zcrtdll}, þhpt{-Zmt}, þhpt{-Zmts}, and þhpt{Startup
606 modules and libraries}.
607þendif
608
609
610þh3 -Zmts
611þlabel -Zmts
612þi2 -Zmts
613þkeyword -Zmts
614
615 Use the additional GCC command line option -Zmts to link a
616 multithread program which is statically linked with the C
617 library. The preprocessor macro __MT__ will be defined if -Zmts is
618 used. -Zmts is equivalent to -Zmt (without -Zcrtdll) and is provided
619 for compatibility with existing makefiles.
620þif ipf
621 See also þhpt{-Zcrtdll}, þhpt{-Zmt}, þhpt{-Zmtd}, and þhpt{Startup
622 modules and libraries}.
623þendif
624
625
626þh3 -Zno-rte
627þlabel -Zno-rte
628þi2 -Zno-rte
629þkeyword -Zno-rte
630
631 Use -Zno-rte with þhpt{-Zdll} and þhpt{-Zomf} (all of which must be
632 specified) to create a DLL without runtime environment
633 not use the runtime environment of its client application.
634 þhpt{-Zcrtdll}, þhpt{-Zmt}, þhpt{-Zmtd}, þhpt{-Zmts}, þhpt{-Zso}, and
635 þhpt{-Zsys} must not be used with -Zno-rte.
636þif ipf
637 See also þhpt{Startup modules and libraries}.
638þendif
639
640
641þh3 -Zomf
642þlabel -Zomf
643þi2 -Zomf
644þkeyword -Zomf
645
646 The additional GCC command line option -Zomf causes GCC to call
647 þhpt{emxomf} for converting .o files to .obj files and to call
648 þhpt{emxomfld} instead of þhpt{ld}. As emxomfld calls LINK386, this
649 option works only under OS/2. You should use a module definition
650 file (.def file) or the þhpt{-Zstack} option if you need a stack
651 bigger than 0x8000 bytes. Note that LINK386 adds a default
652 extension (.exe or .dll) to the output file name.
653
654þh3 -Zsmall-conv
655þlabel -Zsmall-conv
656þi2 -Zsmall-conv
657þkeyword -Zsmall-conv
658
659 The additional GCC command line option -Zomf causes the program to
660 be linked with þtt{smallcnv.o}, select smaller, faster, and
661 inaccurate routines for converting decimal numbers to binary and
662 vice versa. By default, accurate conversion routines are used.
663 -Zsmall-conv saves about 14KB for programs which use binary to
664 decimal conversions, about 11KB for programs which use decimal to
665 binary conversions, and about 15KB for programs which use both.
666
667 The -Zsmall-conv option cannot be used with the -Zcrtdll option;
668 the C runtime DLLs always use the accurate conversion routines.
669
670þh3 -Zstack
671þlabel -Zstack
672þi2 -Zstack
673þkeyword -Zstack
674
675 The -Zstack option sets the OS/2 stack size of the executable.
676 -Zstack takes an argument, which is the stack size in KByte. The
677 stack size can be given in decimal, octal or hexadecimal, using C
678 notation. The -Zstack option is passed down unmodified to þhpt{ld}
679 or þhpt{emxomfld}. Example:
680
681þexample
682gcc bigstack.c -Zomf -Zstack 0x2000
683þendexample
684
685 This sets the stack size to 8 MBytes.
686
687þh3 -Zso
688þlabel -Zso
689þi2 -Zso
690þkeyword -Zso
691
692 Use -Zso with þhpt{-Zdll}, þhpt{-Zsys}, and þhpt{-Zomf} (all of
693 which must be specified) to create a stand-alone DLL, that is, a DLL
694 which does not use the runtime environment of its client application
695 but has a runtime environment of its own.
696þif ipf
697 See also þhpt{Startup modules and libraries}.
698þendif
699
700
701þh3 -Zsys
702þlabel -Zsys
703þi2 -Zsys
704þkeyword -Zsys
705
706 Use -Zsys with þhpt{-Zomf} to link with the system call library (emx
707 emulator) sys.lib instead of using the run time library emx.dll for
708 system calls. The library version of the system calls provide only
709 a subset of the emx system call interface. þhpt{fork()}, for
710 instance, isn't supported with -Zsys. DLLs created with -Zsys must
711 be either custom C runtime DLLs or stand-alone DLLs (see þhpt{-Zso}).
712þif ipf
713 See also þhpt{Startup modules and libraries}.
714þendif
715
716
717þh3 -Zsysv-signals
718þlabel -Zsysv-signals
719þi2 -Zsysv-signals
720þkeyword -Zsysv-signals
721
722 The additional GCC command line option -Zsysv-signals causes the
723 program to be linked with þtt{sigsysv.o}, selecting the `System V'
724 signal processing model. See also þhpt{-Zbsd-signals}.
725 -Zsysv-signals cannot be used with þhpt{-Zsys}.
726
727
728þh2 Special file extensions
729þlabel Special file extensions
730
731 You can give the name of a module definition file on the command
732 line. The name must end with .def and is passed to þhpt{ld}, which
733 in turn passes it to þhpt{emxbind}. When using þhpt{-Zomf}, the
734 name is passed to þhpt{emxomfld}, which in turn passes it to
735 LINK386. If the output file names ends with .dll, a default module
736 definition file is used by emxbind unless a .def file is given on
737 the GCC command line.
738
739 You can give the name of a binary resource file on the command
740 line. The name must end with .res and is passed to ld, which in
741 turn passes it to emxbind. When using -Zomf, the name is passed to
742 emxomfld, which runs þbf{rc} to copy the resources to the output
743 file.
744
745þh2 Startup modules and libraries
746þlabel Startup modules and libraries
747
748 The following table shows the startup module and the libraries
749 passed to the linker by GCC, depending on the command line options
750 þhpt{-Zcrtdll}, þhpt{-Zmt}, þhpt{-Zomf}, þhpt{-Zso}, þhpt{-Zsys}, and
751 þhpt{-Zdll}. Note that -Zmtd is equivalent to -Zmt -Zcrtdll and
752 -Zmts is equivalent to -Zmt without -Zcrtdll:
753
754þexample
755Options ³Startup³ Libraries
756ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
757-Zomf not specified ³ *.o ³ *.a
758-Zomf specified ³ *.a ³ *.lib
759ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
760(none) ³ crt0 ³ gcc st/c st/c_app st/emx emx2
761 -Zmt³ crt0 ³ gcc mt/c mt/c_app mt/emx emx2
762 -Zsys ³ crt0 ³ gcc st/c st/c_app st/sys
763 -Zsys -Zmt³ crt0 ³ gcc mt/c mt/c_app mt/sys
764 -Zcrtdll ³ crt0 ³ c_static st/c_import emx2
765 -Zcrtdll -Zmt³ crt0 ³ c_static mt/c_import emx2
766ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
767-Zdll ³ dll0 ³ gcc st/c st/c_dllrt st/emx emx2
768-Zdll -Zmt³ dll0 ³ gcc mt/c mt/c_dllrt mt/emx emx2
769-Zdll -Zsys ³ dll0 ³ gcc st/c st/c_dllrt st/sys
770-Zdll -Zsys -Zmt³ dll0 ³ gcc mt/c mt/c_dllrt mt/sys
771-Zdll -Zsys -Zso ³ dll0 ³ gcc st/c st/c_dllso st/sys
772-Zdll -Zsys -Zso -Zmt³ dll0 ³ gcc mt/c mt/c_dllso mt/sys
773-Zdll -Zno-rte ³ dll0 ³ gcc st/c c_dllnrt
774-Zdll -Zcrtdll ³ dll0 ³ c_static st/c_import emx2
775-Zdll -Zcrtdll -Zmt³ dll0 ³ c_static mt/c_import emx2
776þendexample
777
778 In addition to the libraries mentioned above, the alias library
779 (c_alias.a or c_alias.lib) and the OS/2 import library (os2.a or
780 os2.lib) are always passed to the linker. If -Zomf is used,
781 þtt{end.lib} is also passed to the linker. Note that -Zomf must be
782 used if -Zsys is used.
783
784þh2 Assertions
785þlabel Assertions
786
787 The following assertions are predefined in the emx port of GCC:
788 þtt{#system(unix)}, þtt{#system(emx)}, þtt{#cpu(i386)} and
789 þtt{#machine(i386)}.
790
791
792þh2 C++
793þlabel C++
794
795 Files containing C++ programs should have one of the following file
796 name extensions:
797
798þdescription
799þitem .cc
800
801 Unix style
802
803þitem .cpp
804
805 PC style (GCC has been patched to recognize this)
806
807þitem .cxx
808
809 (?)
810
811þitem .C
812
813 Type an upper-case C!
814
815þenddescription
816
817 Use the -lstdcpp command line option to link C++ programs with the
818 GNU standard C++ library (þhpt{libstdc++}), which includes the
819 former iostream library.
820
821 Use the -lgpp command line option to link C++ programs with the GNU
822 C++ class libraray (þhpt{libg++}). If you link with libg++,
823 you have to obey the rules stated in þtt{/emx/doc/COPYING.LIB}.
824
825 Example:
826
827þexample
828gcc hello.cc -lstdcpp -s
829þendexample
830
831 The þbf{collect} program is not required with the emx port of GCC.
832
833 Hint: Use the -s option (of GCC, þhpt{emxomf} or þhpt{emxbind}) to
834 remove the symbol table; it's quite big.
835
836
837þh2 Objective C
838þlabel Objective C
839
840 To link a program written in the Objective C language, you have to
841 use library þtt{objc}: use -lobjc on the GCC command line. Example:
842
843þexample
844gcc objcsamp.m -lobjc -s
845þendexample
846
847 Note that GCC does not include any class libraries for Objective C.
848
849
850þh2 Stack probes
851þlabel Stack probes
852þlabel stack probes
853
854 Stack probes are used to manage automatic stack growth if the stack
855 is not completely committed. When allocating stack space, the new
856 stack pages are touched before changing the stack pointer to make
857 them accessible. Generation of stack probes is disabled by default.
858 Use the þhpt{-mprobe} option to enable generation of stack probes.
859
860 The -fstack-check option of GCC generates stack probes for stack
861 checking; when there's not enough stack space, an exception will be
862 generated. Unlike -mprobe, -fstack-check guarantees "enough" stack
863 space left for running a simple exception handler.
864
865 You need stack probes if
866
867þitemize
868þitem
869
870 you use DosCreateThread to create a thread that doesn't have a
871 completely committed stack, that is, if bit 1 of the
872 þsl{ulThreadFlags} argument is zero, or
873
874þitem
875
876 you create a DLL which might be used by an application which uses
877 DosCreateThread to create a thread that doesn't have a completely
878 committed stack, or
879
880þitem
881
882 you want to trap the stack overflow exception issued when hitting
883 the guard page at the bottom of the stack. (You should use
884 -fstack-check instead of -mprobe.)
885
886þenditemize
887
888 Stack probes are not generated for all allocations of stack space: A
889 stack probe is not generated if the size of the allocated memory
890 block is constant and less than 4096 bytes. This optimization
891 causes a problem if two such allocations of stack space occur
892 without access to the stack between the allocations. There are two
893 occasions for this: Two calls in a row to þhpt{alloca()} with
894 constant argument which is less than 4096 and where nothing is
895 stored to the first pointer returned by alloca() before getting the
896 second pointer:
897
898þexample
899p = alloca (0xf00);
900q = alloca (0xf00);
901þendexample
902
903 The second case is a function with less than 4096 bytes of local
904 data which calls alloca() with constant argument which is less than
905 4096 before accessing a local variable or calling a function:
906
907þexample
908void test (void)
909{
910 char local[0xf00], *p;
911
912 p = alloca (0xf00);
913 /*...*/
914}
915þendexample
916
917 As both cases are unlikely to occur in practice, I chose to not
918 generate a stack probe for less than 4096 bytes. If you experience
919 problems (that is, stack exceptions), insert the statement
920
921þexample
922{char *p=alloca (0); *p = 0;}
923þendexample
924
925 in critical places, as between the two alloca() calls in the first
926 example and before the alloca() call in the second example.
927
928 All emx libraries are compiled with both stack probes and stack
929 checking enabled.
930
931
932þh2 Other changes
933þlabel Other changes
934
935 The preprocessor CPP defines the symbols __32BIT__ and __EMX__. If
936 the þhpt{-Zmt}, þhpt{-Zmts}, or þhpt{-Zmtd} option is given on the
937 GCC command line, the symbol __MT__ is defined.
938
939 The file name extensions of the debugging output files (-d option)
940 have been changed as follows:
941
942þexample
943combine -> cmb
944cse -> cs1
945cse2 -> cs2
946flow -> flo
947greg -> gre
948jump -> jp1
949jump2 -> jp2
950loop -> loo
951lreg -> lre
952sched -> sd1
953sched2 -> sd2
954stack -> stk
955þendexample
956
957 The extension is added to the base name of the input file, not to
958 the complete name of the input file. For instance, when compiling
959 þtt{world.c}, the file þtt{world.cs1} will be created instead of
960 þtt{world.c.cse}. If using the -da GCC option, you should use the
961 þtt{-h30} emx option.
962
963
964þh2 Calling conventions
965þlabel Calling conventions
966
967 The calling convention used by GCC is almost compatible with the
968 `þtt{system}' calling convention of IBM C Set/2. Structures are
969 returned differently: IBM C Set/2 uses a hidden parameter which is
970 removed from the stack by the caller, GCC returns the structure in
971 registers EAX and EDX if its size is 8 bytes or less
972 (-freg-struct-return is the default). GCC uses a hidden parameter
973 if the size of the structure is more than 8 bytes, but the callee
974 removes the hidden parameter from the stack. Currently, the GCC
975 option -fpcc-struct-return doesn't solve that problem. Instead,
976 rewrite the function and the function call as follows:
977
978þexample
979/* Original code */
980struct s1 func1 (int a1)
981{
982 struct s1 t1;
983 ...
984 return (t1);
985}
986...
987
988struct s1 v1;
989v1 = f1 (0);
990þendexample
991
992
993þexample
994/* Modified code */
995
996struct s1 *f1 (struct s1 *ret, int a1)
997{
998 struct s1 t1;
999 ...
1000 *ret = t1;
1001 return (ret);
1002}
1003
1004...
1005
1006struct s1 v1;
1007f1 (&v1, 0);
1008þendexample
1009
1010þi1
1011
1012þh1 libg++ -- the GNU C++ library (gpp.a and gpp.lib)
1013þlabel libg++
1014þlabel gpp
1015þindex libg++
1016þindex gpp
1017
1018 libg++ 2.8.1.1a, the obsolete GNU C++ library, has been ported to
1019 emx.
1020
1021 If you link with libg++, (-lgpp), you have to obey the rules
1022 stated in þtt{/emx/doc/COPYING.LIB}.
1023
1024 Due to name collisions, the following include files have been renamed:
1025
1026þexample
1027Complex.h -> Complx.h
1028Regex.h -> Regx.h
1029String.h -> Strng.h
1030þendexample
1031
1032
1033þh1 libstdc++ -- the GNU standard C++ library
1034þlabel libstdc++
1035þindex libstdc++
1036
1037 libstdc++ 2.8.1.1, the GNU standard C++ library, is provided for emx.
1038 Use the -lstdcpp option to link with that library.
1039 See þtt{/emx/doc/COPYING.SCP} for copyright information.
1040
1041 The þtt{istream::seekg}, þtt{istream::tellg}, þtt{ostream::seekp},
1042 and þtt{ostream::tellg} methods do not work for text files.
1043
1044
1045þh1 GDB -- debugging programs
1046þlabel GDB
1047þindex GDB
1048þkeyword GDB
1049
1050 GDB uses GNU þhpt{readline}, see below. GDB works only with a.out
1051 files (under DOS) and with bound files (both under OS/2 and DOS),
1052 not with arbitrary DOS or OS/2 progams. The DUEL debugging language
1053 has been added to GDB, see below. Anthony Green's þhpt{GDBRX}
1054 extension has been added to GDB, see below.
1055
1056 See the GDB manual for details.
1057
1058 A preliminary version of a Presentation Manager front end for GDB is
1059 shipped with emx. See the online help and the online tutorial of
1060 pmgdb for details.
1061
1062þh2 Example
1063
1064 The following example shows how to debug a fictitious program
1065 þtt{myprog.exe}. See install.doc for an example with one of the emx
1066 sample programs.
1067
1068þexample
1069C> gcc -g myprog.c (compile)
1070C> gdb myprog.exe (start debugger)
1071(gdb) set args -o myprog.out myprog.in (set arguments)
1072(gdb) b main (set breakpoint)
1073(gdb) run (start program)
1074(gdb) dl argv[0..argc-1] (display arguments)
1075(gdb) s (step)
1076þendexample
1077
1078 Command line arguments for the program to be debugged can be passed
1079 on the GDB command line if the þtt{--args} option is used:
1080
1081þexample
1082C> gcc -g myprog.c (compile)
1083C> gdb --args myprog.exe -o myprog.out myprog.in (start debugger)
1084(gdb) b main (set breakpoint)
1085(gdb) run (start program)
1086(gdb) dl argv[0..argc-1] (display arguments)
1087(gdb) s (step)
1088þendexample
1089
1090 If the executable file cannot be found and does not include a
1091 filename extension, GDB appends `þtt{.exe}' to the filename and
1092 tries again.
1093
1094 Continuing the example, if there's no file named `þtt{myprog}', you
1095 can omit the `þtt{.exe}' extension of the executable file name:
1096
1097þexample
1098C> gdb --args myprog -o myprog.out myprog.in
1099þendexample
1100
1101 That is, you can just prepend `þtt{gdb --args}' to the command line.
1102
1103þh2 Restrictions
1104
1105 Please do not use backslashes in path names. For your convenience,
1106 backslashes in path names specified as command line arguments of GDB
1107 are automatically turned into slashes. For commands entered
1108 interactively, you have to use slashes yourself.
1109
1110 The following GDB commands do not work or do not work completely or
1111 have been changed:
1112
1113þitemize
1114þitem
1115
1116 `þtt{signal}' does not work under OS/2 unless the same signal is used
1117 by which the debuggee has been stopped
1118
1119þitem
1120
1121 `þtt{attach}' and `þtt{detach}' cannot work in general; however,
1122 these commands can be used in a limited way for descendant processes
1123 as explained below
1124
1125þitem
1126
1127 `þtt{tty}' and `þtt{term-status}' are not implemented
1128
1129þitem
1130
1131 `þtt{directory}' has been changed to use semicolons instead of
1132 colons for separating directories.
1133
1134þitem
1135
1136 `þtt{watch}' is almost unusable because GDB disables the watchpoints
1137 as soon as a function without debugging symbols is called, such as
1138 an OS/2 API function. That could be fixed by making GDB believe
1139 that the functions in os2.a have debugging symbols.
1140
1141þenditemize
1142
1143þh2 Special features
1144
1145 Various special features have been added to the emx port of GDB.
1146
1147þipfminitoc
1148
1149þh3 Setting command line arguments for the program being debugged
1150
1151 The þtt{--args} option of GDB causes all arguments following the
1152 name of the executable file on the command line of GDB to be used as
1153 arguments for the program for the program being to debugged.
1154 Example:
1155
1156þexample
1157gdb --args -nx myprog.exe -o myprog.out myprog.in
1158þendexample
1159
1160 This invocation of GDB is equivalent to running
1161
1162þexample
1163gdb -nx myprog.exe
1164þendexample
1165
1166 and typing the GDB command
1167
1168þexample
1169set args -o myprog.out myprog.in
1170þendexample
1171
1172 However, the `þtt{set args}' command supports redirection operators,
1173 whereas þtt{--args} passes them as command line arguments to the
1174 program being debugged. The `þtt{show args}' command does not print
1175 the equivalent `þtt{set args}' arguments for achieving the effect of
1176 þtt{--args}; for instance, quoting is not correct.
1177
1178þh3 Running the debuggee in the same window
1179
1180 If you want to run the debuggee in the same OS/2 session (window) as
1181 GDB (for instance if you're running GDB in a full-screen session),
1182 use the -E emx option.
1183
1184þh3 Switching sessions
1185
1186 By default, GDB selects the child session when executing a þtt{CALL}
1187 instruction of the inferior process. Use the `þtt{set switch off}'
1188 command to disable that feature. Use `þtt{set switch on}' to turn
1189 on switching to the child session. Use `þtt{show switch}' to
1190 display the current setting. Under DOS, `þtt{set switch}' is
1191 ignored.
1192
1193 To debug a Presentation Manager application, run GDB full-screen and
1194 use `þtt{set switch on}'. Do not manually switch to the
1195 Presentation Manager session while the program is stopped!
1196 Otherwise the Presentation Manager will hang and you will have to reboot.
1197 Alternatively, you can use pmgdb to debug Presentation Manager
1198 applications.
1199
1200 As import method þhpt{(I1)} uses a þtt{JMP} instruction instead of a
1201 þtt{CALL} instruction to call OS/2 API functions, the `þtt{stepi}'
1202 command must not be used to step into the code generated by emximp
1203 for a method (I1) import. Use `þtt{nexti}' on the call to that
1204 code, instead.
1205
1206þh3 Closing the window after termination of the debuggee
1207
1208 Use the `þtt{set close}' command to control whether to close the
1209 child session window after termination of the debuggee. `þtt{set
1210 close off}' is the default -- the window will stay open. After a
1211 debuggee has been started, `þtt{set close}' doesn't take effect for
1212 that debuggee.
1213
1214þh3 Debugging threads
1215
1216 You can freeze a thread with the `þtt{thread disable}' command
1217 (`þtt{freeze}' is an alias). Without argument, this command freezes
1218 the current thread. Otherwise, the argument must be a thread
1219 number. A frozen thread won't execute until you thaw it.
1220
1221 You can thaw a thread with the `þtt{thread enable}' command
1222 (`þtt{thaw}' is an alias). Without argument, this command thaws the
1223 current thread. Otherwise, the argument must be a thread number.
1224
1225 You can freeze or thaw multiple threads with one command by using
1226 `þtt{thread apply}':
1227
1228þexample
1229thread apply all thaw
1230thread apply 2-4 6 freeze
1231þendexample
1232
1233 Restarting the process being debugged while the current thread is
1234 frozen will result in this message:
1235
1236þexample
1237ptrace: No such process.
1238þendexample
1239
1240 Use the `þtt{thread}' command to switch to an enabled thread when
1241 this happens:
1242
1243þexample
1244thread 5
1245þendexample
1246
1247 Note that debugging multithread processes has some rough edges. See
1248 the GDB manual for more information on debugging multithread
1249 processes.
1250
1251þh3 Debugging DLLs
1252
1253 GDB automatically loads the symbols of DLLs created with ld and
1254 emxbind. Currently, there are a few rough edges such as problems
1255 with restarting the program being debugged if symbols have been
1256 loaded from DLLs.
1257
1258 Use the `þtt{set show-dlls on}' command to let GDB show the path names
1259 of DLLs as they are loaded and freed.
1260
1261 Use the `þtt{dll-break}' command to set a stop-on-load breakpoint on
1262 a DLL. The `þtt{dll-break}' command takes one argument, the name of
1263 the DLL. The name must not include a path; the extension
1264 `þtt{.dll}' will be added if no extension is provided. Letter case
1265 does not matter. When the named DLL is loaded, GDB will stop the
1266 program being debugged. Then, you can set breakpoints in the DLL
1267 and continue. The `þtt{dll-clear}' command removes a stop-on-load
1268 breakpoint by number; the `þtt{info dll-break}' command lists all
1269 stop-on-load breakpoints, showing the number of the stop-on-load
1270 breakpoint and the name of the DLL.
1271
1272þh3 Debugging descendant processes
1273
1274 Under OS/2, you can optionally debug processes (descendant
1275 processes) started by the debuggee. For each descendant process to
1276 be debugged, one extra instance of GDB will be required. Due to
1277 OS/2 limitations, session switching does not work for descendants;
1278 therefore descendants which are Presentation Manager applications
1279 cannot be debugged.
1280
1281 GDB maintains a list of programs to be debugged when started by the
1282 debuggee. The `þtt{descendant add}' command adds a program to that
1283 list. The first argument of that command is the name of the
1284 executable file, which can be specified in the following three ways:
1285
1286þenumerate
1287þitem
1288 A path name (including a directory) will be turned into an absolute
1289 path name by GDB; all descendants matching the absolute path name
1290 will be debugged. The path name should include the correct file
1291 name extension as no default extension will be applied.
1292þitem
1293 A file name (without directory); all descendants whose file name
1294 (without directory) match the specified file name will be debugged.
1295 The file name should include the correct file name extension as no
1296 default extension will be applied.
1297þitem
1298 The word `þtt{fork}' means that this entry applies to child
1299 processes created with fork().
1300þitem
1301 A `þtt{*}' means that this entry applies to all descendants, without
1302 regard to their file names.
1303þendenumerate
1304
1305 The second argument specifies the action to be taken when a
1306 descendant with a matching executable file name is started. The
1307 following actions are available:
1308
1309þdescription
1310þitem þtt{window}
1311 Start a new instance of GDB, running in a new windowed session.
1312
1313þitem þtt{fs}
1314 Start a new instance of GDB, running in a new full-screen session.
1315
1316þitem þtt{cont}
1317 Do not start a new instance of GDB and continue the debuggee. The
1318 descendant will block until GDB is attached to the descendant. Note
1319 that the debuggee may also block if it waits for the start or
1320 completion of the child process.
1321þenddescription
1322
1323 If the first argument is `þtt{fork}' and the third argument is
1324 `þtt{init}', you'll be able to debug the initialization code of the
1325 forked process; this is used for debugging the implementation of
1326 fork(). If there is no third argument or if the third argument is
1327 not `þtt{init}', debugging of the child process will start in the
1328 fork() call; one `þtt{step}' command will step to the location (in
1329 the child process) from which fork() has been called (in the parent
1330 process).
1331
1332 Any remaining arguments should be GDB options and will be passed to
1333 the new instance of GDB. This is in particular useful to set up GDB
1334 with commands from a file specified with `þtt{--command}' or to
1335 prevent GDB from reading the `þtt{!gdbinit}' file with `þtt{-nx}'.
1336
1337 Examples for `þtt{descendant add}':
1338
1339þexample
1340desc add * window
1341desc add fork window init -q
1342desc add special.exe window --command special.gdb
1343þendexample
1344
1345 At least one descendant must be defined with `þtt{descendant add}'
1346 þem{before} the start of the debuggee; otherwise debugging of
1347 descendants will be disabled. If debugging of descendants is
1348 enabled (by defining at least one descendant), GDB will show a
1349 message each time a new descendant is started:
1350
1351þexample
1352[New process: 4713 C:/EMX/TEST/ARGS.EXE]
1353þendexample
1354
1355 The message includes the process ID (4713 in the example) and the
1356 path name of the executable file. If the path name does not match
1357 any entry in the table of descendants, the descendant will be run
1358 with debugging disabled. The descendant will be terminated or will
1359 block if the instance of GDB debugging its parent process ends.
1360
1361 If the path name matches an entry in the table of descendants, the
1362 associated action will be performed. First, the table is searched
1363 for a matching absolute path name. If there is no matching entry,
1364 all entries having file names (without directory) will be searched.
1365 If there is still no matching entry, the `þtt{*}' entry will be used
1366 if present. That is, the most stricly matching entry will be used,
1367 falling back to more general entries if there is no matching entry.
1368
1369 For the actions `þtt{window}' and `þtt{fs}' a new instance of GDB
1370 will be started for the descendant. Now, you can set a breakpoint
1371 (usually on `þtt{main}') and continue execution of the descendant
1372 with the `þtt{continue}' command. If the descendant has been
1373 created with fork(), use the `þtt{step}' command. The instance of
1374 GDB debugging the parent process of the descendant must not be
1375 terminated until debugging of all the descendants of that parent
1376 process is complete.
1377
1378 The following example shows how to debug `þtt{args.exe}' when run
1379 from `þtt{exec.exe}'. Both are test programs in þtt{\emx\test}.
1380 First, start GDB on the parent process:
1381
1382þexample
1383[c:\emx\test]gdb -q exec.exe
1384(gdb) desc add * window -q
1385Debugging of descendant * enabled (number 1).
1386(gdb) set close
1387(gdb) run
1388Starting program: c:/emx/test/exec.exe
1389[New thread 1]
1390þendexample
1391
1392 Now type `þtt{run args a b c}' in the `þtt{exec.exe}' window. This
1393 will cause `þtt{exec.exe}' to start `þtt{args.exe}'. GDB will display
1394
1395þexample
1396[New process: 41 C:/EMX/TEST/ARGS.EXE]
1397þendexample
1398
1399 and a new window will show up, running GDB:
1400
1401þexample
14020x138 in ?? ()
1403(gdb)
1404þendexample
1405
1406 Now, you can debug `þtt{args.exe}':
1407
1408þexample
1409(gdb) b main
1410Breakpoint 1 at 0x1007f: file args.c, line 11.
1411(gdb) cont
1412Continuing.
1413[New thread 1]
1414[Switching to thread 1]
1415
1416Breakpoint 1, main (argc=4, argv=0x282ffd4, envp=0x282fdc8) at args.c:11
141711 _envargs (&argc, &argv, "ARGS");
1418(gdb) p argv[1]
1419$1 = 0x282fff0 "a"
1420(gdb) cont
1421Continuing.
1422[Thread terminated: 1]
1423
1424Program exited normally.
1425(gdb) q
1426þendexample
1427
1428 If the action `þtt{cont}' is specified for a descendant, you have to
1429 start GDB manually to debug the descendant. Use the `þtt{attach}'
1430 command with the process ID of the descendant as argument:
1431
1432þexample
1433[C:\EMX\TEST]gdb -q args.exe
1434(gdb) attach 41
1435Attaching to program `c:/emx/test/args.exe', process 41
14360x138 in ?? ()
1437(gdb)
1438þendexample
1439
1440 You can take the process ID from the output of the instance of GDB
1441 debugging the parent process. The `þtt{detach}' command detaches
1442 GDB from the descendant, letting the descendant run without
1443 debugging (as long as the instance of GDB debugging the parent
1444 process lives).
1445
1446 Note that GDB's table of descendants applies to the first level of
1447 descendants only; to debug a child process of a descendant process,
1448 you have to issue another `þtt{descendant add}' command in the
1449 second instance of GDB. Child processes of descendants not defined
1450 in the table of descendants cannot be debugged.
1451
1452 The `þtt{info descendants}' command lists the table of descendands;
1453 for each descendant, a number, the path name or file name, the
1454 action, and the GDB options are shown.
1455
1456 The `þtt{descendant clear}' command removes an entry of the table of
1457 descendants. You have to specify the number of the entry, as shown
1458 by `þtt{info descendants}'.
1459
1460 To modify an entry of the table of descendants, just issue another
1461 `þtt{descendant add}' command for the same file name or path name.
1462
1463
1464þh3 Examining the heap
1465
1466 If the debuggee has been linked with the emx or GNU implementation
1467 of malloc(), you can examine the heap with the `þtt{info heap}'
1468 command. That command will list all used and free blocks of the
1469 heap. You'll get more detailed information if you type `þtt{info
1470 heap /v}'. Moreover, you can type an argument which specifies the
1471 address of the heap to examine. If the address points to a
1472 substructure of the heap, such as a block or a segment, that
1473 substructure will be displayed.
1474
1475 For programs linked with -Zcrtdll, GDB does not know the address of
1476 the heap. Therefore, you have to use the `þtt{info heap}' command
1477 with the address of the heap (this works with the emx implementation
1478 of malloc() only):
1479þenumerate
1480þitem
1481 Before starting the program, type
1482þexample
1483set show-dlls
1484þendexample
1485 to let GDB print information about DLLs.
1486þitem
1487 Start the program with the `þtt{run}' command. GDB will show
1488 the names and addresses of the DLLs. You need the address of
1489 the þtt{.data} object of emxlibcs.dll or emxlibcm.dll:
1490þexample
1491[Load DLL: C:\EMX\DLL\EMXLIBCM.DLL]
1492[.text: 0x0e400000 - 0x0e419c10]
1493[.data: 0x0e420000 - 0x0e425f90]
1494[.bss: 0x0e425f90 - 0x0e428190]
1495þendexample
1496 In this example, the address of the þtt{.data} object is 0xe420000.
1497þitem
1498 Search the file þtt{\emx\etc\emxlibcs.map} (or
1499 þtt{\emx\etc\emxlibcm.map}, depending on which DLL is used) for
1500 the symbol þtt{_um_regular_heap}:
1501þexample
1502 0002:00007CB4 _um_regular_heap
1503þendexample
1504 In this example, the offset we're looking for is 0x7cb4.
1505þitem
1506 Compute the address of the þtt{_um_regular_heap} variable by
1507 adding the address of the þtt{.data} object and the offset
1508 of the variable. In the example, the address is 0xe427cb4.
1509þitem
1510 Display the value of the variable:
1511þexample
1512x/w 0xe427cb4
1513þendexample
1514 GDB responds with
1515þexample
15160xe427cb4 <end+239105292>: 0x02970000
1517þendexample
1518 In this example, the address of the heap is 0x2970000.
1519þitem
1520 Use the `þtt{info heap}' command with the address of the heap:
1521þexample
1522info heap 0x2970000
1523þendexample
1524 All numbers in this recipe are samples.
1525þendenumerate
1526
1527 If the debuggee has the _heapchk() function linked in, you can call
1528 it from GDB to check the heap:
1529
1530þexample
1531call _heapchk()
1532þendexample
1533
1534 That function returns 0 if the heap is OK, 1 if the heap is empty
1535 (uninitialized). Other return values indicate heap corruption. To
1536 check the heap each time the program stops, use
1537
1538þexample
1539display _heapchk()
1540þendexample
1541
1542 _heapchk() works with the emx implementation of malloc() only.
1543 Other malloc packages may support a similar function.
1544
1545þh3 Initialization file
1546
1547 The .gdbinit file has been renamed þtt{!gdbinit}. To save typing,
1548 you might want to create a file named þtt{!gdbinit} in the directory
1549 where you're debugging. Here's an example of a þtt{!gdbinit} file:
1550
1551þexample
1552file myprog.exe
1553set arg -o test.out test.inp
1554b main
1555set close on
1556run
1557set switch off
1558þendexample
1559
1560þh3 DUEL
1561
1562 Michael Golan's DUEL debugging language has been added to GDB.
1563 You'll find detailed instructions in þtt{\emx\doc\duel.man}. Note
1564 that GDB has not been modified to require `þtt{##}' for comments,
1565 therefore you have to use alternate names for two DUEL operators:
1566 Use `þtt{%/}' instead of `þtt{#/}', and `þtt{%%}' instead of
1567 `þtt{#}'.
1568
1569
1570þh3 GDBRX -- use REXX in GDB
1571þlabel GDBRX
1572
1573 The `þtt{rexx}' command of GDB invokes the OS/2 REXX interpreter.
1574 The argument of the `þtt{rexx}' command is interpreted as a REXX
1575 program. `þtt{rx}' is an alias for the `þtt{rexx}' command.
1576 Important: use single quotes instead of double quotes in REXX
1577 commands as GDB treats double quotes specially. Example:
1578
1579þexample
1580(gdb) rx say 'Hello World!'
1581Hello World!
1582þendexample
1583
1584 Once the REXX interpreter has been invoked, the default subcommand
1585 handler is GDBRX. This means that any commands REXX doesn't
1586 understand get passed back to GDB for processing. Any output from
1587 GDB gets passed back to REXX through the standard result variable
1588 þtt{RC}. Example:
1589
1590þexample
1591(gdb) rx do i = 2 to 4; 'p 'i; say rc; end
1592$1 = 2
1593$2 = 3
1594$3 = 4
1595þendexample
1596
1597 This is where the real power of the REXX command lies. It makes it
1598 really easy to hack together quick and dirty debugging functions.
1599 For instance, þtt{\emx\bin\logargs.cmd} is a REXX program that logs
1600 all parameters used in calls to a given function. You invoke it
1601 with
1602
1603þexample
1604(gdb) rx call logargs
1605þendexample
1606
1607 þtt{logargs.cmd} assumes that you have loaded the program, and have
1608 breaked somewhere in it (since it starts off with a
1609 `þtt{continue}').
1610
1611 When you run it you get something like this:
1612
1613þexample
1614cd \emx\test
1615gdb version.exe
1616(gdb) b main
1617(gdb) set sw off
1618(gdb) set cl on
1619(gdb) run
1620(gdb) rx call logargs
1621logargs 1.1
1622Enter function name:
1623bit
1624Running...
1625þendexample
1626
1627 And you end up with a very useful þtt{logargs.txt} file:
1628
1629þexample
1630*** logargs 1.1 --- 20:02:33 02 Jul 1993 ***
1631s=0x100b7 "VCPI ", n=1
1632s=0x100c1 "XMS ", n=2
1633s=0x100cb "VDISK 3.3", n=4
1634s=0x100d5 "DESQview ", n=8
1635s=0x100df "287 ", n=16
1636s=0x100e9 "387 ", n=32
1637s=0x100f3 "OS/2 2.x ", n=512
1638s=0x100fd "-t ", n=1024
1639s=0x10107 "-ac ", n=2048
1640þendexample
1641
1642 where each line represents the parameters passed to þtt{bit()}.
1643
1644 When analyzing þtt{RC}, note that newlines are represented by two
1645 characters, CR and LF.
1646
1647
1648þh2 Hints
1649
1650 To debug an .exe file which doesn't have a symbol table use
1651 the symbol table from the a.out file and type
1652
1653þexample
1654gdb -e myprog.exe -s myprog
1655þendexample
1656
1657 You can do post-mortem debugging by using the þtt{core} file written
1658 by emx when a program aborts.
1659
1660 You can use the following redirection specifications with `þtt{set
1661 args}':
1662
1663þlist
1664þitem þtt{<}þpa{FILENAME}
1665
1666 Redirect the file named þpa{FILENAME} to standard input
1667
1668þitem þtt{>}þpa{FILENAME}
1669
1670 Redirect standard output to the file named þpa{FILENAME},
1671 overwriting
1672
1673þitem þtt{>>}þpa{FILENAME}
1674
1675 Redirect standard output to the file named þpa{FILENAME},
1676 appending
1677
1678þendlist
1679
1680 You can prepend a handle number (0 to 9) to such a redirection
1681 specification; for instance
1682
1683þtypewriter
1684 2>þpa{FILENAME}
1685þendtypewriter
1686
1687 redirects standard error to þpa{FILENAME}. Use quotation marks to
1688 include `þtt{<}', `þtt{>}', spaces, or TABs in arguments. Use
1689 backslashes to escape quotation marks.
1690
1691 Example:
1692
1693þexample
1694set args "first arg" "second arg" <input >output 2>error
1695þendexample
1696
1697
1698þh1 GAS -- assembling
1699þlabel GAS
1700þindex GAS
1701þindex assembler
1702þkeyword GAS
1703
1704 GAS is the GNU assembler. The executable file name of GAS is
1705 as.exe. The GNU assembler preprocessor, GASP, is also
1706 available. Usually, GAS is called by þhpt{GCC}. See the GAS and GASP
1707 manuals for details.
1708
1709 This port of GAS supports two additional command line options:
1710
1711þdescription
1712
1713þitem -Zomf
1714
1715 Call emxomf to convert the output file to OMF. This option is
1716 used for creating .obj files.
1717
1718þitem -Zstrip
1719
1720 Pass the -s option to emxomf. This option is used with -Zomf
1721 to omit debugging information.
1722
1723þenddescription
1724
1725
1726þh1 ld -- linking
1727þlabel ld
1728þindex ld
1729þindex linker
1730þkeyword ld
1731
1732 ld is the GNU linker.
1733
1734 If the output file has an .exe or .dll extension, þhpt{emxbind} will
1735 automatically be called to bind emxl.exe and the temporary a.out
1736 file into an .exe or .dll file. See þtt{/emx/gnu/binutils.old/ld.c} and
1737 the description of þhpt{emxomfld} for command line options. ld is
1738 usually called only by GCC, not from the command line.
1739
1740 The -s option (strip symbols) is passed on to emxbind. If ld
1741 doesn't call emxbind, ld will strip the symbol table.
1742 Unfortunately, ld doesn't correctly strip the symbol table.
1743
1744 This port of ld supports several additional command line options:
1745
1746þdescription
1747
1748þitem -R
1749
1750 The -R option is used for creating relocatable executable files. -R
1751 is automatically set if the output file has a .dll extension. -R is
1752 also automatically set if an import definition of type þhpt{(I2)} is
1753 referenced. This is used to import functions from dynamic link
1754 libraries. If you link with import definitions of type (I1), you
1755 have to manually supply the -R option.
1756
1757þitem -Zexe
1758
1759 If the -Zexe option is present, ld deletes the output file (whose
1760 name is given on the command line) and, after linking, calls emxbind
1761 to create an .exe file (.exe is appended to the name of the output
1762 file) After calling emxbind, ld creates an empty output file
1763 (without .exe). This feature is used for minimizing changes to
1764 Unix-style makefiles. See also the þhpt{-Zexe} option of þhpt{GCC}
1765 and þhpt{emxomfld}. The output file name must not have an extension
1766 if -Zexe is used.
1767
1768þitem -Zmap
1769
1770 Let emxbind create a .map file. The name of the .map file will be
1771 derived from the output file name, the default extension is .map.
1772 To specify the name of the .map file, use þsy{-Zmap=<map_file>}.
1773
1774þitem -Zstack
1775
1776 The -Zstack option is passed down to emxbind to set the stack size
1777 for OS/2 programs.
1778
1779þitem -Zno-demangle
1780
1781 Don't demangle C++ symbols in error messages.
1782
1783þitem -Zdemangle-proto
1784
1785 Include parameters and qualifiers in demangled C++ symbols in error
1786 messages.
1787
1788þenddescription
1789
1790 If a file name with .def extension is given on the ld command line,
1791 it will be passed as module definition file (-d option) to emxbind.
1792 If there is no .def file on the command line and the output file is
1793 a .dll file, the -d option without argument is passed to emxbind;
1794 emxbind will use the name of the output file (with .def extension)
1795 for the module definition file.
1796
1797 If a file name with .res extension is given on the ld command line,
1798 it will be passed as resource file (-r option) to emxbind.
1799
1800 Note that the sequence of .o and .a files and -l options is
1801 essential. crt0.o or dll0.o must come first. Libraries are
1802 considered only once, that is, if a library references symbols
1803 defined in another library, the former one must be used before the
1804 latter one. If library lib1.a uses library lib2.a, which in turn
1805 uses library lib1.a, you have to use þtt{-llib1 -llib2 -llib1}.
1806
1807
1808þh1 ranlib
1809þindex ranlib
1810þkeyword ranlib
1811
1812 þbf{ranlib} is not available. Use the þtt{s} command of þbf{ar}
1813 instead.
1814
1815
1816þh1 strip -- removing the symbol table
1817þlabel strip
1818þindex strip
1819þkeyword strip
1820
1821 þbf{strip} is used to delete symbols from an a.out file. It cannot
1822 be applied to bound .exe files. See þtt{/emx/gnu/binutils.old/strip.c}
1823 for command line options. See also the þhpt{emxbind} (-s command
1824 and the -s option of the -b command).
1825
1826
1827þh1 info -- browsing info files
1828þlabel info
1829þindex info
1830þkeyword info
1831
1832 Before using þbf{info}, you have to install termcap. This is done by
1833 setting the TERM environment variable and one of the following
1834 environment variables: INIT, EMXETC, TERMCAP. Here's an example:
1835
1836þexample
1837set term=mono
1838set termcap=c:/emx/etc/termcap.dat
1839þendexample
1840
1841 Then, you have to set the INFOPATH environment variable. It's a
1842 list of directories, separated by semicolons. The þtt{/emx/info}
1843 directory should be included. Example:
1844
1845þexample
1846set infopath=.;c:/emx/info
1847þendexample
1848
1849 If the INFOPATH environment variable is not set, the following list
1850 of directories will be used:
1851
1852þexample
1853.;/emx/info;/emacs/info
1854þendexample
1855
1856 After setting all the environment variables, you can run info by
1857 typing
1858
1859þexample
1860info
1861þendexample
1862
1863 Type þtt{?} to get a list of keys.
1864
1865
1866þh1 makeinfo -- creating info files
1867þlabel makeinfo
1868þindex makeinfo
1869þkeyword makeinfo
1870
1871 makeinfo creates info files from texinfo files. Type makeinfo to
1872 get a list of options. There's also texinfo documentation available
1873 for makeinfo.
1874
1875 When splitting files, makeinfo uses the extensions þtt{i01},
1876 þtt{i02}, ..., þtt{i99}.
1877
1878
1879þh1 texindex -- creating the index for a printed manual
1880þlabel texindex
1881þindex texindex
1882þkeyword texindex
1883
1884 texindex sorts the index for typesetting a texinfo file with
1885 þbf{TeX}. To compile a texinfo file under OS/2, simply move to the
1886 directory where the source file resides and enter
1887
1888þtypewriter
1889 texi2dvi þpa{FILENAME}
1890þendtypewriter
1891
1892 where þpa{FILENAME} is the name of the source file. Example:
1893
1894þexample
1895cd \emx\gnu\texinfo
1896texi2dvi texi.tex
1897þendexample
1898
1899 þbf{texi2dvi} is a REXX procedure which calls þbf{TeX} and texindex.
1900 See the first two statements of þtt{/emx/bin/texi2dvi.cmd} for
1901 customization.
1902
1903
1904þh1 termcap -- terminal capabilities
1905þlabel termcap
1906þindex termcap
1907þkeyword termcap
1908
1909 For using termcap, you have to put termcap.dat in the current
1910 working directory, into directory /emx/etc on the current drive, or
1911 into a directory listed in the INIT or EMXETC environment
1912 variables. You can also set the TERMCAP environment variable to
1913 contain the absolute path name of termcap.dat. If the TERM
1914 environment variable isn't set, ansi will be used (þtt{ansi.sys}
1915 required). Otherwise, the terminal given in the TERM environment
1916 variable will be used. I recommend using þtt{mono}. See
1917 termcap.dat for details.
1918
1919 To link a program with the GNU termcap library, specify -ltermcap on
1920 the GCC command line. Read the license in þtt{/emx/doc/COPYING}!
1921
1922 Alternatively, the BSD termcap library is available. See
1923 þtt{emxbsd.doc} and þtt{emxbsd.inf} for details.
1924
1925þh1 readline
1926þlabel readline
1927þindex readline
1928þkeyword readline
1929
1930 The standard þbf{Emacs}/þbf{readline} key bindings are used with the
1931 following exceptions and additions:
1932
1933þexample
1934BS, C-H rubout
1935HOME beg_of_line
1936END end_of_line
1937UP get_previous_history
1938DOWN get_next_history
1939LEFT backward
1940RIGHT forward
1941PAGEUP beginning_of_history
1942PAGEDOWN end_of_history
1943DELETE delete
1944C-LEFT backward_word
1945C-RIGHT forward_word
1946C-HOME backward_kill_line
1947C-END kill_line
1948þendexample
1949
1950 The readline library source comes with the GDB source files.
1951
1952
1953þh1 GPPDEMID -- an identifier manipulation DLL for G++
1954þlabel GPPDEMID
1955þi1 GPPDEMID
1956þkeyword GPPDEMID
1957
1958 GPPDEMID (þtt{/emx/dll/gppdemid.dll}) is a dynamic link library
1959 which demangles symbols mangled by the G++ compiler. This DLL is
1960 used by LINK386 to demangle symbols to make error messages more
1961 readable when linking C++ programs. LINK386 is told about the name
1962 of the DLL by a special record inserted into the .obj files by
1963 þhpt{emxomf}.
1964
1965 GPPDEMID is subject to the GNU Library General Public License, see
1966 þtt{/emx/doc/COPYING.LIB} for details. The source code for GPPDEMID
1967 can be found in the þtt{gnusrc.zip} archive.
1968
1969
1970þh1 Known problems
1971þlabel Known problems
1972
1973þitemize
1974
1975þitem
1976
1977 gcc.exe cannot pass more than 24 (temporary) files derived by
1978 the GCC command from source files to the linker
1979
1980þitem
1981
1982 If GDB fails under OS/2 with an error message like
1983
1984þexample
1985DosDebug error: 00000135
1986þendexample
1987
1988 stop any screen savers you are running. If that does not help, use
1989 the -E emx option:
1990
1991þexample
1992set emxopt=-E
1993þendexample
1994
1995 and run GDB from a full-screen command prompt.
1996
1997þenditemize
1998
1999þtext
2000
2001--------------------------- END OF EMXGNU.DOC ------------------------------
2002þendtext
Note: See TracBrowser for help on using the repository browser.