diff options
| author | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-18 00:31:54 +0200 |
|---|---|---|
| committer | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-18 00:31:54 +0200 |
| commit | 268a53de823a6750d6256ee1fb1e7707b4b45740 (patch) | |
| tree | 42c1799a9a82b2f7d9790ee9fe181d72a7274751 /debugger | |
| download | sdcc-gas-268a53de823a6750d6256ee1fb1e7707b4b45740.tar.gz | |
sdcc-3.9.0 fork implementing GNU assembler syntax
This fork aims to provide better support for stm8-binutils
Diffstat (limited to 'debugger')
28 files changed, 20335 insertions, 0 deletions
diff --git a/debugger/README b/debugger/README new file mode 100644 index 0000000..ccf3e76 --- /dev/null +++ b/debugger/README @@ -0,0 +1,518 @@ +sdcc/debugger + +SDCDB debugger - Development notes. +====================== + + +ddd - Notes from Martin Helmling, May 23, 2003 +======================== + +Additionally following new commands work: + +ignore <breakpointnumber> <ignorecount> - ignore the breakpoint n times +condition <breakpointnumber> <variable> <|>|<=|>=|==|!= <constant> - break condition +commands - see gdb description - + +ddd - Notes from Martin Helmling, April 28, 2003 +======================== + +To fullfill the requirements of 'ddd' ( Data Display Debugger ) to use it at +graphical frontend to 'sdcdb' some new commands must be implemented. + +Now you can run the ddd with the commandline + +ddd -debugger 'sdcdb -cpu 8032 <file>' + +Following commands are additional implemented: + +1. execution: + +stepi - Step one instruction exactly using simulator 'step' command. +nexti - Step one instruction, but proceed through subroutine calls using simulator 'next' command. +break *<addr> - Set breakpoint at program address + +log examples: +-> "stepi\n" +<- "Simulator stopped at Address 0x0051\n" + "\032\032x.c:31:1:beg:0x00000051\n" + "(sdcdb) " +-> "nexti\n" +<- "Simulator stopped at Address 0x0055\n" + "\032\032x.c:33:1:beg:0x00000055\n" + "(sdcdb) " + +2. show machine code window: + +x /i - disassemble one asm command +x disassemble asm commands + +log examples: +-> "x /i 0x00000055\n" +<- "0x00000055 <main+6>:\t\tmov\tr0,#_l\n" + "(sdcdb) " +-> "disassemble 0x00000055\n" +<- "Dump of assembler code for function main:\n" + "0x0000004f <main>:\t\tmov\tr0,#_ttt\n" + "0x00000051 <main+2>:\t\tmov\t@r0,#0x01\n" +<- "0x00000053 <main+4>:\t\tmov\tr2,#0x09\n" + "0x00000055 <main+6>:\t\tmov\tr0,#_l\n" +... + "0x000000c1 <main+114>:\t\tret\n" + "End of assembler dump.\n" + "(sdcdb) " +-> "disassemble 0x40 0x45\n" +<- "Dump of assembler code from 0x00000040 to 0x00000045:\n" + "0x00000040 <subfunc1+8>:\t\tinc\tr0\n" + "0x00000041 <subfunc1+9>:\t\tmov\t@r0,ar3\n" + "0x00000043 <subfunc1+11>:\t\tmov\ta,r3\n" + "0x00000044 <subfunc1+12>:\t\trlc\ta\n" + "0x00000045 <subfunc1+13>:\t\tsubb\ta,acc\n" + "End of assembler dump.\n" + "(sdcdb) " +-> "break x.c:23\n" +<- "Breakpoint 1 at 0x4b: file x.c, line 23.\n" + "(sdcdb) " +-> "info breakpoints\n" +<- "Num Type Disp Enb Address What\n" + "1 breakpoint keep y 0x0000004b at x.c:23\n" + "(sdcdb) " +-> + +3. show registers and stack + +frame - print information about the current Stack +where - print stack +up - Select and print stack frame that called this one +down - Select and print stack frame that called this one +info registers - show registers +info all-registers - show also special these function registers, + which are symbolical defined. +help <cmd> show short help for ddd tooltip info +log examples: + +-> "where\n" +<- "#0 0x0000004b in subfunc1 () at x.c:23\n" + "#1 0x0000004f in main () at x.c:31\n" + "(sdcdb) " +-> "frame\n" +<- "#0 0x0000004b in subfunc1 () at x.c:23\n" + "\032\032x.c:23:1:beg:0x0000004b\n" + "(sdcdb) " +-> "up\n" +<- "#1 0x0000004f in main () at x.c:31\n" + "\032\032x.c:31:1:beg:0x0000004f\n" + "(sdcdb) " +-> "frame\n" +<- "#1 0x0000004f in main () at x.c:31\n" + "\032\032x.c:31:1:beg:0x0000004f\n" + "(sdcdb) " +-> "down\n" +<- "#0 0x0000004b in subfunc1 () at x.c:23\n" + "\032\032x.c:23:1:beg:0x0000004b\n" + "(sdcdb) " +-> "frame\n" +<- "#0 0x0000004b in subfunc1 () at x.c:23\n" + "\032\032x.c:23:1:beg:0x0000004b\n" + "(sdcdb) " +-> "info registers\n" +<- "R0 : 0x87 135 .\n" + "R1 : 0x00 0 .\n" + "R2 : 0x05 5 .\n" + "R3 : 0x00 0 .\n" + "R4 : 0x00 0 .\n" + "R5 : 0x08 8 .\n" + "R6 : 0x00 0 .\n" + "ACC : 0x00 0 .\n" + "B : 0x00 0 .\n" + "DPTR: 0x0005 5\n" + "@DPTR: 0x00 0 .\n" + "PSW : 0x00 | CY : 0 | AC : 0 | OV : 0 | P : 0\n" + "(sdcdb) " +# Showing all registers. +-> "info all-registers\n" +<- "R0 : 0x87 135 .\n" + "R1 : 0x00 0 .\n" + "R2 : 0x05 5 .\n" + "R3 : 0x00 0 .\n" + "R4 : 0x00 0 .\n" + "R5 : 0x08 8 .\n" + "R6 : 0x00 0 .\n" + "ACC : 0x00 0 .\n" + "B : 0x00 0 .\n" + "DPTR: 0x0005 5\n" + "@DPTR: 0x00 0 .\n" + "PSW : 0x00 | CY : 0 | AC : 0 | OV : 0 | P : 0\n" + "Special Function Registers:\n" +<- "P0=0xff P0_0=1 P0_1=1 P0_2=1 P0_3=1\n" + "SP=0x13\n" + "(sdcdb) " +-> "help step\n" +<- "Step program until it reaches a different source line.\n" + "(sdcdb) " +-> "help stepi\n" +<- "Step one instruction exactly.\n" + "(sdcdb) " + +4. show and set variables: +output [/<fmt>] <expr1> print value of <expr1> without newline for tooltip of ddd +print [/<fmt>] <expr1> print value of <expr1> with newline +display [/<fmt>] <expr1> print value of <expr1> every time the program is stopped + or 'display' command without args is used. + +set variable <expr1> = <value> + + +<fmt> is the format for the basic type which is print out. +If no format is set the default format is used. +format is set by ddd 'x' as hex 'o' as octal, 'd' as dezimal and 't' as binary. + +<expr1> can by a variable , a array element , a structure element ( [] and . is parsed ). +indices of arrays may be constants or variables. +( dereference of pointers and casting today not implemented !! ) + +log examples: +code: + +typedef unsigned char uchar; +idata long l; +typedef struct _txstate +{ + uchar dstatus[4]; + uchar avalue [8 ]; +} txstate_t; + +xdata txstate_t txstates[8]; + +-> "output l\n" +<- "5(sdcdb) " +-> "display l\n" +<- "(sdcdb) " +-> "display /x l\n" +<- "(sdcdb) " +-> "display\n" +<- "2: /x l = 0x00000005\n" + "1: l = 5\n" + "(sdcdb) " +-> "display /o l\n" +<- "(sdcdb) " +-> "display\n" +<- "3: /o l = 00000000005\n" + "2: /x l = 0x00000005\n" + "1: l = 5\n" + "(sdcdb) " +-> "display /d l\n" +<- "(sdcdb) " +-> "display\n" +<- "4: /d l = 5\n" + "3: /o l = 00000000005\n" + "2: /x l = 0x00000005\n" + "1: l = 5\n" + "(sdcdb) " +-> "display /t l\n" +<- "(sdcdb) " +-> "display\n" +<- "5: /t l = 00000000000000000000000000000101\n" + "4: /d l = 5\n" + "3: /o l = 00000000005\n" + "2: /x l = 0x00000005\n" + "1: l = 5\n" + "(sdcdb) " +-> "output l\n" +<- "5(sdcdb) " +-> "print txstates\n" +<- "$2 = { { dstatus = {\'\\1\',\'\\0\',\'\\0\',\'\\0\'}, + avalue = {\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\'}}, + { dstatus = {\'\\0\',\'\\2\',\'\\0\',\'\\0\'}, + avalue = {\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\'}}, + { dstatus = {\'\\0\',\'\\0\',\'\\375\',\'\\0\'}, + avalue = {\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\'}}, + { dstatus = {\'\\0\',\'\\0\',\'\\0\',\'\\0\'}, + avalue = {\'\\0\',\'\\0\',\'\\0\',\'\\4\',\'\\0\',\'\\0\',\'\\0\',\ +'\\0\'}}, { dstatus = {\'\\0\',\'\\0\',\'\\0\',\'\\0\'}, + avalue = {\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\'}}, + { dstatus = {\'\\0\',\'\\0\',\'\\0\',\'\\0\'}, + avalue = {\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\'}}, + { dstatus = {\'\\0\',\'\\0\',\'\\0\',\'\\0\'}, + avalue = {\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\'}}, + { dstatus = {\'\\0\',\'\\0\',\'\\0\',\'\\0\'}, + avalue = {\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\ +0\'}}}\n" + "(sdcdb) " +-> "print txstates[1].dstatus[1]\n" +<- "$5 = \'\\2\'\n" + "(sdcdb) " +-> "print /x txstates[1].dstatus[1]\n" +<- "$7 = 0x02\n" +-> "output txstates[1].dstatus[1]\n" +<- "\'\\2\'(sdcdb) " +-> "set variable txstates[1].dstatus[1] = 0x10\n" +<- "(sdcdb) " +-> "print /t txstates[1].dstatus[1]\n" +<- "$9 = 00010000\n" +-> "print /x txstates[1].dstatus[1]\n" +<- "$10 = 0x10\n" + +-> "output l\n" +<- "5(sdcdb) " +-> "set variable l = 2\n" +<- "(sdcdb) " +-> "print l\n" +<- "$15 = 2\n" +-> "print /x txstates[l].dstatus[2]\n" +<- "$16 = 0xfd\n" + + +--------------------------------------------------- + +Implementation Notes: + +IMEM and XMEM are cached to optimize the printaut of structures and arrays + + + +Notes April 23, 2003 +======================== +Martin Helmling added support for ddd GUI debugger. +Code added to display assembly, set variables, and other commands +to interface to ddd. + +From Martins email: + +in the attachment is my actual patch. + +The 'up' and 'down' stack commands are not implemented. +But the features for 'ddd' to see bopth the c source and the assembler +works, +also the display of variables. +Set variables are only implemented for basic types. +Register variables can also displayed, but here I think a problem in the +*.cdb file exists. +Sometimes the register name not exists: + +S:LcacheTxAnalogValue$offset$1$1({1}SC:U),E,0,0 +S:LcacheTxAnalogValue$i$1$1({1}SC:S),R,0,0,[] +S:LcacheTxAnalogValue$val$1$1({4}ST__00020000:S),E,0,0 +S:LcacheTxAnalogValue$value$1$1({1}SC:U),R,0,0,[] +S:LcacheTxAnalogValue$sloc0$1$0({4}SL:U),E,0,0 +S:LsetRelays$addr$1$1({1}SC:U),R,0,0,[r2] +S:LsetRelays$state$1$1({1}SC:U),R,0,0,[r3] +S:LsetRelays$value$1$1({1}SC:U),R,0,0,[r5] +S:L_main$i$1$1({1}SC:U),R,0,0,[] +S:L_main$j$1$1({1}SC:U),R,0,0,[r3] +S:L_main$ok$1$1({1}SC:U),R,0,0,[r3] + +the empty [] I mean !! + +Is this a known bug in sdcc ? + +Also sometimes not the correct breakpoints for stepping found in sdcdb. +I try to fix this tomorrow. + +Additional patches and notes from Martin(4-24-03): +in the attachment you found three patches: +debugpatch: Only for debugging, you can switch on and off the 4 different + debug and you can grep the debug by the prefix. +signalpatch:Now the simulator stops if the user sends an interrupt + ( or 'ddd' ) and also the simulator does not die by another + user signal. + +sympatch: This is not a feature, THIS is the fix of a BUG !!! + In some circumstances in the *.cdb file the Symbol record + comes before the function record. So the symbol was + generated TWO TIMES in the symbol list. The L:G and L:XG + + records then insert entry and exit address to the wrong + symbol. So before a new symbol is generated for the + function, a lookup in the symboltable is done. + +Example of a *.cdb: + +S:G$ZpuInitialize$0$0({2}DF,SV:S),C,0,0 +S:G$ZpuInitialize$0$0({2}DF,SV:S),C,0,0 +F:G$ZpuInitialize$0$0({2}DF,SV:S),Z,0,0,0,0,0 +S:LZpuInitialize$i$1$1({2}SI:S),R,0,0,[] +L:G$ZpuInitialize$0$0:ADF +L:XG$ZpuInitialize$0$0:BBB + + +Notes Feb 10, 2002 - Karl Bongers +======================== + +SDCDB is a debugger for SDCC compiler. It works as a front +end to the ucSim simulator/disassembler program. + +WARNING: SDCDB is EXPERIMENTAL and NOT A FULLY FUNCTIONING TOOL. + +SDCDB does hold out promise for a nice debugger tool that +could integrate well with ucSim and other SDCC tools. It has +some nice functionality that could augment ucSim nicely. +It reads in a lot of symbolic information from the .CDB +debug files as well as the source code and assembly +listings referred to in these CDB files. +This can be used to display your program data, list +c or asm source code and set breakpoints. + +Unfortunately, SDCDB is not quite finished and does not +function well enough yet to recommend for general use. + + +Usage Notes +====================== +Compile with --debug option: +sdcc --debug hi.c +This should generate .cdb symbolic debug files. + +Load sdcdb, like this: +sdcdb hi.ihx + +Then you need to do an initial "run" command. It should hopefully +stop somewhere at the main() entrypoint. + +Now you should be able to list code, and set breakpoints. Type +"c" to continue running to a breakpoint, or type "s" to single +step or "n" to skip function calls. Tpye "help" for a summary +of commands. + +Use a preceeding bang("!") to do s51 simulator commands. So for +example: +!pc +will send the "pc" command to ucSim and +give you the program counter and list the current line of assembly. +!help +will give you the brief command line help listing of ucSim. But +this help will scroll of the screen. So to get a list, I redirect +stdout to a text file to examine like this: +sdcdb hi.ihx 2>&1 | tee sdcdb.log + +Type '.' to toggle to a full time ucSim prompt. + + +SDCDB problem areas. +====================== + +Ok, so what are some of its problems? Lets try to itemize +them so we can fix them: + +* It hangs sometimes when trying to do step or next. + + This probably has something to do with the context + sdcdb tries to build dynamically. Sdcdb tries to + trace program operation by placing hidden breakpoints + and stepping threw the simulation between these. + +* Does not print variables properly. Seems to use the + wrong address for the variable. (fixed) + +* ASM listing not implemented. + This should be easy enough to add. This feature + really needs to be implemented before this is a useful + tool. That or addresses of code functions need to be + readily available for raw ucSim commands. + +* No way to browse symbols, files names. + Preferably, it is easy to learn the addresses of variables + and functions too. + (working on this... see new ls,lm,lf commands) + +* Does not allow listing, setting breakpoints or viewing variables + before starting the simulation. + (I am fixing now, partly fixed) + +* p codestr - print on code char * broken, could be CDB info invalid. + + +Changes Made +====================== + +Added a -z option. Any options after -z on sdcdb invocation line + are passed directly to ucSim. + +Fixed print basic variable command(was not parsing or expecting + "0x" in data coming from ucSim). Dump bit command changed from + "db" to "dump". + +Add support for the following alternative ucSim binaries: + -mz80 - use "uz80" simulator. + -mavr - use "uavr" simulator. + -mxa - use "uxa" simulator. + + Note that Z80(and probably avr/xa) does not produce enough + CDB debugging information to + make SDCDB useful. Hopefully CDB support will be + added to these other linkers and code generators. + +Added lf,lm,ls commands(list functions, list modules, list symbols). + This allows browsing some the CDB information SDCDB pulls in + to do the wonderful things it does. + +Added '.' prefix/command, used alone switches back and forth + from ucSim/SDCDB command mode). Also when at the (ucsim) prompt, + if a command is prefixed with '.' it will route the command to + the SDCDB command processor. (This could obsolete the '!' prefix). + + +====================== + +Fix any remaining shortcomings above and make sdcdb integrate better with +ucSim. + +Concerning the hanging on next/step instructions: This is critical +to fix. I beleive the problem is related to SDCDB's attempt to +dynamically track context. To do this, it sets many temporary break +points and uses these to progress step by step through the source code. +It does not seem reliable. It might be an idea to offer a simplified +mode of stepping and breakpoints. Need to study this more. + +Make SDCDB integrate better with ucSim. +I think if sdcdb can act more transparently in regard to ucSim +it would be used more. So stress adding value and enhancing +ucSim operation, and not block or hide the functionality of ucSim. + +* combine print "p" & "pt" together. We have room on the screen, +might as well print its type, address and value in one command. + +* "fr" command prints the current position in the C code. +Should also print the raw code address for dumping ucSim code. + + + +Developer Notes: +====================== +To debug, it might be helpful to turn on verbose debug dumps +by uncommenting #define SDCDB_DEBUG in sdcdb.h. + +Some basic layout: +sdcdb.c - main shell of the program. +cmd.c - process user commands typed in. +simi.c - handle talking to the simulator via a socket connection. +symtab.c - Misc. functions to translate and process linked list + structures(modules, functions, symbols, etc) and CDB file + parsing. +break.c - track and implement break points. + +Understanding the structures and access mechanisms of SDCDB +is a bit of work. The structures include generic linked list +and function access. These lists are accessed in part by the +functions from ../../src/SDCCset.c and SDCChash.c. See the +cmd.c:infoSymbols() routine to gain some insight into these +main program structures. Or type "info symbols" to dump +out some of these. The new ls,lm,lf commands are also based +on showing information about these lists of structures. + +Generic functions are used to act on these linked lists of +structures. For example, in cmd.c, DEFSETFUNC(funcWithName) +function will find a function structure with a given name. +So the linked list of function structures(with the head +"functions") is traversed and when one is found with a matching +name, a pointer to the function structure is returned. + +The src/SDCCset.c,SDCCset.h contain much of the core helper +routines to allowed to implement these linked list access +functions. + +The dynamic context tracking is difficult to understand. +It has some concept of stack use, as in +cmd.c:printSymValue(), where it can print variables relative +to the stack pointer. + + diff --git a/debugger/mcs51/Makefile b/debugger/mcs51/Makefile new file mode 100644 index 0000000..eafe8a8 --- /dev/null +++ b/debugger/mcs51/Makefile @@ -0,0 +1,118 @@ +# +# +# + +SHELL = /bin/sh +CC = gcc +CPP = gcc -E +INSTALL = /usr/bin/install -c +STRIP = strip +MAKEDEP = gcc -MM + +top_builddir = ../../ +top_srcdir = ./../.. +SLIB = $(top_srcdir)/support/util +SDCCLIB = $(top_srcdir)/src + + +srcdir = . + +prefix = /usr/local +exec_prefix = ${prefix} +bindir = ${exec_prefix}/bin + +transform = s,x,x, + +STD_INC = @sdcc_include_dir@ +CPPFLAGS = -I. -I$(top_builddir) -I$(top_srcdir) -I$(SLIB) -DHAVE_CONFIG_H +CFLAGS = -pipe -ggdb -g -O2 -Wall +LDFLAGS = + +EXEEXT = + +LIBS = -lnsl -lreadline +LIBDIRS = + +OBJECTS = sdcdb.o symtab.o simi.o \ + break.o cmd.o +SLIBOBJS = NewAlloc.o +SDCCOBJS = SDCCset.o SDCChasht.o SDCCerr.o + +SOURCES = $(patsubst %.o,%.c,$(OBJECTS)) +SLIBSOURCES = $(patsubst %.o,$(SLIB)/%.c,$(SLIBOBJS)) +SDCCSOURCES = $(patsubst %.o,$(SDCCLIB)/%.c,$(SDCCOBJS)) + +TARGET = $(top_builddir)/bin/sdcdb$(EXEEXT) + + +# Compiling entire program or any subproject +# ------------------------------------------ +all: checkconf $(TARGET) + +# Compiling and installing everything and runing test +# --------------------------------------------------- +install: all installdirs + $(INSTALL) $(TARGET) $(DESTDIR)$(bindir)/`echo sdcdb|sed '$(transform)'`$(EXEEXT) + $(STRIP) $(DESTDIR)$(bindir)/`echo sdcdb|sed '$(transform)'`$(EXEEXT) + cp $(srcdir)/sdcdb.el $(DESTDIR)$(bindir)/`echo 'sdcdb'|sed '$(transform)'`.el + cp $(srcdir)/sdcdbsrc.el $(DESTDIR)$(bindir)/`echo 'sdcdbsrc'|sed '$(transform)'`.el + + +# Deleting all the installed files +# -------------------------------- +uninstall: + rm -f $(DESTDIR)$(bindir)/`echo sdcdb|sed '$(transform)'`$(EXEEXT) + rm -f $(DESTDIR)$(bindir)/`echo 'sdcdb'|sed '$(transform)'`.el + rm -f $(DESTDIR)$(bindir)/`echo 'sdcdbsrc'|sed '$(transform)'`.el + +# Performing self-test +# -------------------- +check: + + +# Performing installation test +# ---------------------------- +installcheck: + + +# Creating installation directories +# --------------------------------- +installdirs: + $(INSTALL) -d $(DESTDIR)$(bindir) + + +# Creating dependencies +# --------------------- +dep: Makefile.dep + +Makefile.dep: $(SOURCES) $(SLIBSOURCES) $(SDCCSOURCES) $(srcdir)/*.h $(top_builddir)/*.h $(top_srcdir)/*.h + $(MAKEDEP) $(CPPFLAGS) $(filter %.c,$^) >Makefile.dep + +ifeq "$(findstring $(MAKECMDGOALS),uninstall installcheck installdirs checkconf \ + clean distclean mostlyclean realclean)" "" + -include Makefile.dep +endif +include $(srcdir)/clean.mk + +# My rules +# -------- +$(TARGET): $(OBJECTS) $(SLIBOBJS) $(SDCCOBJS) + $(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(SLIBOBJS) $(SDCCOBJS) $(LIBDIRS) $(LIBS) + +.c.o: + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< + +$(SLIBOBJS):%.o:$(SLIB)/%.c + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< + +$(SDCCOBJS):%.o:$(SDCCLIB)/%.c + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< + +# Remaking configuration +# ---------------------- +checkconf: + @if [ -f $(top_builddir)/devel ]; then\ + $(MAKE) -f conf.mk srcdir="$(srcdir)" top_builddir="$(top_builddir)" freshconf;\ + fi + +# End of cpp/Makefile diff --git a/debugger/mcs51/Makefile.dep b/debugger/mcs51/Makefile.dep new file mode 100644 index 0000000..edfdf21 --- /dev/null +++ b/debugger/mcs51/Makefile.dep @@ -0,0 +1,22 @@ +sdcdb.o: sdcdb.c sdcdb.h config.h ../../src/SDCCset.h \ + ../../src/SDCChasht.h ../../src/SDCCbitv.h symtab.h simi.h break.h cmd.h \ + ../../support/util/newalloc.h +symtab.o: symtab.c sdcdb.h config.h ../../src/SDCCset.h \ + ../../src/SDCChasht.h ../../src/SDCCbitv.h symtab.h \ + ../../support/util/newalloc.h +simi.o: simi.c sdcdb.h config.h ../../src/SDCCset.h ../../src/SDCChasht.h \ + ../../src/SDCCbitv.h simi.h ../../support/util/newalloc.h +break.o: break.c sdcdb.h config.h ../../src/SDCCset.h \ + ../../src/SDCChasht.h ../../src/SDCCbitv.h symtab.h break.h simi.h cmd.h \ + ../../support/util/newalloc.h +cmd.o: cmd.c sdcdb.h config.h ../../src/SDCCset.h ../../src/SDCChasht.h \ + ../../src/SDCCbitv.h symtab.h simi.h break.h cmd.h \ + ../../support/util/newalloc.h +NewAlloc.o: ../../support/util/NewAlloc.c ../../support/util/newalloc.h +SDCCset.o: ../../src/SDCCset.c ../../support/util/newalloc.h \ + ../../src/SDCCerr.h ../../src/SDCCset.h +SDCChasht.o: ../../src/SDCChasht.c ../../src/SDCCerr.h \ + ../../src/SDCCglobl.h ../../src/SDCCset.h config.h ../../src/SDCChasht.h \ + ../../support/util/newalloc.h +SDCCerr.o: ../../src/SDCCerr.c ../../src/SDCCglobl.h ../../src/SDCCset.h \ + config.h ../../src/SDCCerr.h diff --git a/debugger/mcs51/Makefile.in b/debugger/mcs51/Makefile.in new file mode 100644 index 0000000..1806515 --- /dev/null +++ b/debugger/mcs51/Makefile.in @@ -0,0 +1,118 @@ +# +# +# + +SHELL = /bin/sh +CC = @CC@ +CPP = @CPP@ +INSTALL = @INSTALL@ +STRIP = @STRIP@ +MAKEDEP = @MAKEDEP@ + +top_builddir = ../../ +top_srcdir = @srcdir@/../.. +SLIB = $(top_srcdir)/support/util +SDCCLIB = $(top_srcdir)/src + +VPATH = @srcdir@ +srcdir = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ + +transform = @program_transform_name@ + +STD_INC = @sdcc_include_dir@ +CPPFLAGS = @CPPFLAGS@ -I. -I$(top_builddir) -I$(top_srcdir) -I$(SLIB) -DHAVE_CONFIG_H +CFLAGS = @CFLAGS@ @WALL_FLAG@ +LDFLAGS = @LDFLAGS@ + +EXEEXT = @EXEEXT@ + +LIBS = @LIBS@ @LIBREADLINE@ +LIBDIRS = + +OBJECTS = sdcdb.o symtab.o simi.o \ + break.o cmd.o +SLIBOBJS = NewAlloc.o +SDCCOBJS = SDCCset.o SDCChasht.o SDCCerr.o + +SOURCES = $(patsubst %.o,%.c,$(OBJECTS)) +SLIBSOURCES = $(patsubst %.o,$(SLIB)/%.c,$(SLIBOBJS)) +SDCCSOURCES = $(patsubst %.o,$(SDCCLIB)/%.c,$(SDCCOBJS)) + +TARGET = $(top_builddir)/bin/sdcdb$(EXEEXT) + + +# Compiling entire program or any subproject +# ------------------------------------------ +all: checkconf $(TARGET) + +# Compiling and installing everything and runing test +# --------------------------------------------------- +install: all installdirs + $(INSTALL) $(TARGET) $(DESTDIR)$(bindir)/`echo sdcdb|sed '$(transform)'`$(EXEEXT) + $(STRIP) $(DESTDIR)$(bindir)/`echo sdcdb|sed '$(transform)'`$(EXEEXT) + cp $(srcdir)/sdcdb.el $(DESTDIR)$(bindir)/`echo 'sdcdb'|sed '$(transform)'`.el + cp $(srcdir)/sdcdbsrc.el $(DESTDIR)$(bindir)/`echo 'sdcdbsrc'|sed '$(transform)'`.el + + +# Deleting all the installed files +# -------------------------------- +uninstall: + rm -f $(DESTDIR)$(bindir)/`echo sdcdb|sed '$(transform)'`$(EXEEXT) + rm -f $(DESTDIR)$(bindir)/`echo 'sdcdb'|sed '$(transform)'`.el + rm -f $(DESTDIR)$(bindir)/`echo 'sdcdbsrc'|sed '$(transform)'`.el + +# Performing self-test +# -------------------- +check: + + +# Performing installation test +# ---------------------------- +installcheck: + + +# Creating installation directories +# --------------------------------- +installdirs: + $(INSTALL) -d $(DESTDIR)$(bindir) + + +# Creating dependencies +# --------------------- +dep: Makefile.dep + +Makefile.dep: $(SOURCES) $(SLIBSOURCES) $(SDCCSOURCES) $(srcdir)/*.h $(top_builddir)/*.h $(top_srcdir)/*.h + $(MAKEDEP) $(CPPFLAGS) $(filter %.c,$^) >Makefile.dep + +ifeq "$(findstring $(MAKECMDGOALS),uninstall installcheck installdirs checkconf \ + clean distclean mostlyclean realclean)" "" + -include Makefile.dep +endif +include $(srcdir)/clean.mk + +# My rules +# -------- +$(TARGET): $(OBJECTS) $(SLIBOBJS) $(SDCCOBJS) + $(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(SLIBOBJS) $(SDCCOBJS) $(LIBDIRS) $(LIBS) + +.c.o: + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< + +$(SLIBOBJS):%.o:$(SLIB)/%.c + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< + +$(SDCCOBJS):%.o:$(SDCCLIB)/%.c + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< + +# Remaking configuration +# ---------------------- +checkconf: + @if [ -f $(top_builddir)/devel ]; then\ + $(MAKE) -f conf.mk srcdir="$(srcdir)" top_builddir="$(top_builddir)" freshconf;\ + fi + +# End of cpp/Makefile diff --git a/debugger/mcs51/acinclude.m4 b/debugger/mcs51/acinclude.m4 new file mode 100644 index 0000000..efec09a --- /dev/null +++ b/debugger/mcs51/acinclude.m4 @@ -0,0 +1,78 @@ +dnl Borut Razem +dnl +dnl This macro checks for the presence of the readline library. +dnl It works also in cross-compilation environment. +dnl +dnl To get it into the aclocal.m4 dnl file, do this: +dnl aclocal -I . --verbose +dnl +dnl The --verbose will show all of the files that are searched +dnl for .m4 macros. + +AC_DEFUN([wi_LIB_READLINE], [ + dnl check for the readline.h header file + + AC_CHECK_HEADER(readline/readline.h) + + if test "$ac_cv_header_readline_readline_h" = yes; then + dnl check the readline version + + AC_MSG_CHECKING([for GNU Readline version]) + cat > conftest.$ac_ext <<EOF +#include <stdio.h> +#include <readline/readline.h> +wi_LIB_READLINE_VERSION RL_VERSION_MAJOR RL_VERSION_MINOR +EOF + + wi_READLINE_VERSION=$($CPP $CPPFLAGS conftest.$ac_ext | sed -n -e "s/^wi_LIB_READLINE_VERSION *\([[0-9]][[0-9]]*\) *\([[0-9]][[0-9]]*\)$/\1.\2/p") + rm -rf conftest* + + if test -n "$wi_READLINE_VERSION"; then + wi_MAJOR=$(expr $wi_READLINE_VERSION : '\([[0-9]][[0-9]]*\)\.') + wi_MINOR=$(expr $wi_READLINE_VERSION : '[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)') + if test $wi_MINOR -lt 10; then + wi_MINOR=$(expr $wi_MINOR \* 10) + fi + wi_READLINE_VERSION=$(expr $wi_MAJOR \* 100 + $wi_MINOR) + else + wi_READLINE_VERSION=-1 + fi + AC_MSG_RESULT($wi_READLINE_VERSION) + + dnl check for the readline library + + ac_save_LIBS="$LIBS" + # Note: $LIBCURSES is permitted to be empty. + + for LIBREADLINE in "-lreadline.dll" "-lreadline" "-lreadline $LIBCURSES" "-lreadline -ltermcap" "-lreadline -lncurses" "-lreadline -lcurses" + do + AC_MSG_CHECKING([for GNU Readline library $LIBREADLINE]) + + LIBS="$ac_save_LIBS $LIBREADLINE" + + AC_TRY_LINK([ + /* includes */ + #include <stdio.h> + #include <readline/readline.h> + ],[ + /* function-body */ + int dummy = rl_completion_append_character; /* rl_completion_append_character appeared in version 2.1 */ + readline(NULL); + ],[ + wi_cv_lib_readline=yes + AC_MSG_RESULT(yes) + ],[ + wi_cv_lib_readline=no + AC_MSG_RESULT(no) + ]) + + if test "$wi_cv_lib_readline" = yes; then + AC_SUBST(LIBREADLINE) + AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE, $wi_READLINE_VERSION, [Readline]) + break + fi + done + + LIBS="$ac_save_LIBS" + fi +]) diff --git a/debugger/mcs51/aclocal.m4 b/debugger/mcs51/aclocal.m4 new file mode 100644 index 0000000..6caec60 --- /dev/null +++ b/debugger/mcs51/aclocal.m4 @@ -0,0 +1,15 @@ +# generated automatically by aclocal 1.16.1 -*- Autoconf -*- + +# Copyright (C) 1996-2018 Free Software Foundation, Inc. + +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) +m4_include([acinclude.m4]) diff --git a/debugger/mcs51/break.c b/debugger/mcs51/break.c new file mode 100644 index 0000000..efec91e --- /dev/null +++ b/debugger/mcs51/break.c @@ -0,0 +1,613 @@ +/*------------------------------------------------------------------------- + break.c - Source file for break point management + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include "sdcdb.h" +#undef DATADIR +#include "symtab.h" +#include "break.h" +#include "cmd.h" +#include "newalloc.h" + +hTab *bptable = NULL; +char doingSteps = 0; +char userBpPresent = 0; + +/* call stack can be 1024 deep */ +STACK_DCL(callStack,function *,1024) + +#ifdef SDCDB_DEBUG +char *debug_bp_type_strings[] = + {"ERR-0", + "DATA", + "CODE" , + "A_CODE" , + "USER" , + "STEP" , + "NEXT" , + "FENTRY" , + "FEXIT", "TMPUSER", ""}; +#endif + +static long bpnum = 0; + +long getLastBreakptNumber() +{ + return bpnum; +} + +void resetHitCount() +{ + int k; + breakp *bp; + for ( bp = hTabFirstItem(bptable,&k); bp ; + bp = hTabNextItem(bptable,&k)) + { + bp->hitCnt = 0; + bp->ignoreCnt = 0; + } +} + +/*-----------------------------------------------------------------*/ +/* setBreakPoint - creates an entry in the break point table */ +/*-----------------------------------------------------------------*/ +int setBreakPoint (unsigned addr, char addrType, char bpType, + int (*callBack)(unsigned,breakp *,context *) , + char *fileName, int lineno) +{ + breakp *bp, *bpl; + + Dprintf(D_break, ("setBreakPoint: addr:%x atype:%s bpType:%s [%s:%d]\n", + addr, + debug_bp_type_strings[(int)addrType], + debug_bp_type_strings[(int)bpType], + fileName, lineno+1)); + + /* allocate & init a new bp */ + bp = Safe_calloc(1,sizeof(breakp)); + bp->addr = addr; + bp->addrType = addrType; + bp->bpType = bpType; + bp->callBack = callBack; + bp->bpnum = ((bpType == USER || bpType == TMPUSER)? ++bpnum : 0); + bp->filename = fileName; + bp->lineno = lineno; + + /* if this is an user break point then + check if there already exists one for this address */ + if (bpType == USER || bpType == TMPUSER) + { + for ( bpl = hTabFirstItemWK(bptable,addr) ; bpl; + bpl = hTabNextItemWK(bptable)) + { + + /* if also a user break point then issue Note : */ + if (bpl->bpType == USER || bpType == TMPUSER) + fprintf(stderr,"Note: breakpoint %d also set at pc 0x%x\n", + bpl->bpnum,bpl->addr); + } + + fprintf(stderr,"Breakpoint %d at 0x%x: file %s, line %d.\n", + bp->bpnum, addr, fileName, lineno+1); + + userBpPresent++; + } + + if (bpType != STEP && bpType != NEXT) + { + /* if a break point does not already exist then + send command to simulator to add one */ + if (!hTabSearch(bptable,addr)) + /* send the break command to the simulator */ + simSetBP (addr); + } + + /* now add the break point to list */ + hTabAddItem(&bptable,addr,bp); + + return bp->bpnum ; +} + +/*-----------------------------------------------------------------*/ +/* deleteSTEPbp - deletes all step break points */ +/*-----------------------------------------------------------------*/ +void deleteSTEPbp () +{ + breakp *bp; + int k; + + Dprintf(D_break, ("break: Deleting all STEP BPs\n")); + /* for break points delete if they are STEP */ + for ( bp = hTabFirstItem(bptable,&k); bp ; + bp = hTabNextItem(bptable,&k)) + { + + /* if this is a step then delete */ + if (bp->bpType == STEP) + { + hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); + Safe_free(bp); + } + } + +} + +/*-----------------------------------------------------------------*/ +/* deleteNEXTbp - deletes all step break points */ +/*-----------------------------------------------------------------*/ +void deleteNEXTbp () +{ + breakp *bp; + int k; + + Dprintf(D_break, ("break: Deleting all NEXT BPs\n")); + + /* for break points delete if they are NEXT */ + for ( bp = hTabFirstItem(bptable,&k); bp ; + bp = hTabNextItem(bptable,&k)) + { + + /* if this is a step then delete */ + if (bp->bpType == NEXT) + { + hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); + Safe_free(bp); + } + } + +} + +static void freeUSERbp(breakp *bp) +{ + if ( bp->commands ) + Safe_free(bp->commands); + if ( bp->condition ) + Safe_free(bp->condition); + Safe_free(bp); +} + +/*-----------------------------------------------------------------*/ +/* deleteUSERbp - deletes USER break point with number */ +/*-----------------------------------------------------------------*/ +void deleteUSERbp (int bpnum) +{ + breakp *bp; + int k; + + Dprintf(D_break, ("break: deleteUSERbp %d\n", bpnum)); + + /* for break points delete if they are STEP */ + for ( bp = hTabFirstItem(bptable,&k); bp ; + bp = hTabNextItem(bptable,&k)) { + + /* if this is a user then delete if break + point matches or bpnumber == -1 (meaning delete + all user break points */ + if ((bp->bpType == USER || bp->bpType == TMPUSER ) + && ( bp->bpnum == bpnum || bpnum == -1)) + { + hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); + + /* if this leaves no other break points then + send command to simulator to delete bp from this addr */ + if (hTabSearch(bptable,bp->addr) == NULL) { + simClearBP (bp->addr); + Dprintf(D_break, ("break: deleteUSERbp:simClearBP 0x%x\n", bp->addr)); + + } + fprintf(stdout,"Deleted breakpoint %d\n",bp->bpnum); + userBpPresent-- ; + freeUSERbp(bp); + if (bpnum == -1) + continue ; + else + break; + } + } + + if (!bp && bpnum != -1) + fprintf(stderr,"No breakpoint number %d.\n",bpnum); +} + +/*-----------------------------------------------------------------*/ +/* setUserbpCommand - set commandstring for breakpoint */ +/*-----------------------------------------------------------------*/ +void setUserbpCommand (int bpnum, char *cmds) +{ + breakp *bp; + int k; + Dprintf(D_break, ("break: setUserbpCommand %d: commands:\n%send\n", + bpnum, cmds)); + + for ( bp = hTabFirstItem(bptable,&k); bp ; + bp = hTabNextItem(bptable,&k)) + { + if ((bp->bpType == USER || bp->bpType == TMPUSER ) + && ( bp->bpnum == bpnum )) + { + if ( bp->commands ) + Safe_free(bp->commands); + bp->commands = cmds; + return; + } + } + fprintf(stderr,"No breakpoint number %d.\n",bpnum); +} + +/*-----------------------------------------------------------------*/ +/* setUserbpCondition - set condition string for breakpoint */ +/*-----------------------------------------------------------------*/ +void setUserbpCondition (int bpnum, char *cond) +{ + breakp *bp; + int k; + Dprintf(D_break, ("break: setUserbpCondition %d: condition:'%s'\n", + bpnum, cond?cond:"")); + + for ( bp = hTabFirstItem(bptable,&k); bp ; + bp = hTabNextItem(bptable,&k)) + { + if ((bp->bpType == USER || bp->bpType == TMPUSER ) + && ( bp->bpnum == bpnum )) + { + if ( bp->condition ) + Safe_free(bp->condition); + bp->condition = cond; + return; + } + } + fprintf(stderr,"No breakpoint number %d.\n",bpnum); +} + +/*-----------------------------------------------------------------*/ +/* setUserbpIgnCount - set ignorecount for breakpoint */ +/*-----------------------------------------------------------------*/ +void setUserbpIgnCount (int bpnum, int ignorecnt ) +{ + breakp *bp; + int k; + Dprintf(D_break, ("break: setUserbpIgnCount %d: ignorecnt=%d\n", + bpnum, ignorecnt)); + + for ( bp = hTabFirstItem(bptable,&k); bp ; + bp = hTabNextItem(bptable,&k)) + { + if ((bp->bpType == USER || bp->bpType == TMPUSER ) + && ( bp->bpnum == bpnum )) + { + bp->ignoreCnt = bp->hitCnt + ignorecnt; + return; + } + } + fprintf(stderr,"No breakpoint number %d.\n",bpnum); +} + +/*-----------------------------------------------------------------*/ +/* listUSERbp - list all user break points */ +/*-----------------------------------------------------------------*/ +void listUSERbp () +{ + breakp *bp; + int k, isuser; + + /* if there are none then say so & return */ + if (!userBpPresent) { + fprintf(stdout,"No breakpoints.\n"); + return ; + } + fprintf(stdout,"Num Type Disp Enb Address What\n"); + for ( bp = hTabFirstItem(bptable,&k) ; bp ; + bp = hTabNextItem(bptable,&k)) { + + isuser = 0; + if (bp->bpType == USER ) { + fprintf(stdout,"%-3d breakpoint keep y 0x%08x at %s:%d\n", + bp->bpnum,bp->addr, + bp->filename,bp->lineno+1); + isuser = 1; + } + else if (bp->bpType == TMPUSER ) { + fprintf(stdout,"%-3d breakpoint del y 0x%08x at %s:%d\n", + bp->bpnum,bp->addr, + bp->filename,bp->lineno+1); + isuser = 1; + } + if ( ! isuser ) + continue; + if ( bp->ignoreCnt > bp->hitCnt ) + fprintf(stdout,"\tignore next %d hits\n", + bp->ignoreCnt - bp->hitCnt ); + if ( bp->condition ) + fprintf(stdout,"\tstop only if %s\n",bp->condition ); + if ( bp->hitCnt > 0 ) + fprintf(stdout,"\tbreakpoint already hit %d time%s\n", + bp->hitCnt,bp->hitCnt>1?"s":"" ); + + + } +} + +/*-----------------------------------------------------------------*/ +/* simStopBPCB - simulator stopped break point */ +/*-----------------------------------------------------------------*/ +static int simStopBPCB( unsigned int addr) +{ + fprintf(stdout,"Simulator stopped at Address 0x%04x\n",addr); + fprintf(stdout,"%s",simResponse()); + return 1; +} + +/*-----------------------------------------------------------------*/ +/* clearUSERbp - deletes USER break point at address */ +/*-----------------------------------------------------------------*/ +void clearUSERbp ( unsigned int addr ) +{ + breakp *bp; + + /* for break points delete if they are STEP */ + for ( bp = hTabFirstItemWK(bptable,addr); bp ; + bp = hTabNextItemWK(bptable)) { + + /* if this is a step then delete */ + if (bp->bpType == USER || bp->bpType == TMPUSER) + { + hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); + + /* if this leaves no other break points then + send command to simulator to delete bp from this addr */ + if (hTabSearch(bptable,bp->addr) == NULL) + { + simClearBP(bp->addr); + } + fprintf(stdout,"Deleted breakpoint %d\n", + bp->bpnum); + userBpPresent-- ; + freeUSERbp(bp); + break; + } + } + + if (!bp) + fprintf(stderr,"No breakpoint at address 0x%x.\n",addr); +} + +/*-----------------------------------------------------------------*/ +/* dispatchCB - will lookup the bp table and dispatch the cb funcs */ +/*-----------------------------------------------------------------*/ +int dispatchCB (unsigned addr, context *ctxt) +{ + breakp *bp; + int rv =0; + + Dprintf(D_break, ("break: dispatchCB: addr:0x%x \n", addr)); + + /* if no break points set for this address + then use a simulator stop break point */ + if ((bp = hTabFirstItemWK(bptable,addr)) == NULL) { + if ( doingSteps == 2 ) return 1; + if ( doingSteps ) return 0; + if ( contsim ) return 0; + return simStopBPCB(addr); + } + + /* dispatch the call back functions */ + for (; bp; bp = hTabNextItemWK(bptable)) + { + rv += (*bp->callBack)(addr,bp,ctxt); + } + + if (rv == 0) { + Dprintf(D_break, ("break: dispatchCB: WARNING rv==0\n")); + } + + return rv; +} + +/*-----------------------------------------------------------------*/ +/* fentryCB - callback function for function entry */ +/*-----------------------------------------------------------------*/ +BP_CALLBACK(fentryCB) +{ + function *func; + + /* we save the value of SP + which will be used to display the value of local variables + and parameters on the stack */ + ctxt->func->stkaddr = simGetValue (0x81,'I',1); + + Dprintf(D_break, ("break: fentryCB: BP_CALLBACK entry %s sp=0x%02x %p\n", + ctxt->func->sym->name, + ctxt->func->stkaddr, p_callStack)); + + /* and set laddr of calling function to return addr from stack */ + if ((func = STACK_PEEK(callStack))) + { + /* extern stack ?? 'A' */ + func->laddr = simGetValue (ctxt->func->stkaddr-1,'B',2); + } + /* add the current function into the call stack */ + STACK_PUSH(callStack,ctxt->func); + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* fexitCB - call back for function exit */ +/*-----------------------------------------------------------------*/ +BP_CALLBACK(fexitCB) +{ + function *func; + /* pop the top most from the call stack */ + func = STACK_POP(callStack); + + if (!func) + { + fprintf(stdout, "Stack underflow\n"); + return 1; + } + + Dprintf(D_break, ("break: fexitCB: BP_CALLBACK entry %s %p\n", func->sym->name, p_callStack)); + + /* check main function */ + if ( !strcmp(func->sym->name, "main")) + { + fprintf(stdout, "Program exited with code %lu.\n", simGetValue (0x82,'I',2)); + return 1; + } + return 0; +} +/*-----------------------------------------------------------------*/ +/* userBpCB - call back function for user break points */ +/*-----------------------------------------------------------------*/ +BP_CALLBACK(userBpCB) +{ + bp->hitCnt++ ; + Dprintf(D_break, ("break: userBpCB: BP_CALLBACK entry hit=%d ignor=%d\n", + bp->hitCnt, bp->ignoreCnt)); + + if ( bp->ignoreCnt > bp->hitCnt ) + return 0; + + if ( bp->condition ) + { + if (! conditionIsTrue( bp->condition, ctxt )) + return 0; + } + + if ( bp->commands ) + { + Dprintf(D_break, ("break: userBpCB: commands:%p\n", bp->commands)); + setCmdLine(bp->commands); + } + + if (srcMode == SRC_CMODE) { + fprintf(stdout,"Breakpoint %d, %s() at %s:%d\n", + bp->bpnum, + ctxt->func->sym->name, + ctxt->func->mod->c_name, + ctxt->cline+1); + if (ctxt->func->mod && ctxt->cline > 0) + fprintf(stdout,"%d\t%s",ctxt->cline+1, + ctxt->func->mod->cLines[ctxt->cline]->src); + } else { + fprintf(stdout,"Breakpoint %d, %s() at %s:%d\n", + bp->bpnum, + ctxt->func->sym->name, + ctxt->func->mod->asm_name, + ctxt->asmline+1); + if (ctxt->func->mod && ctxt->asmline > 0) + fprintf(stdout,"%d\t%s",ctxt->asmline+1, + ctxt->func->mod->asmLines[ctxt->asmline]->src); + } + + if ( bp->bpType == TMPUSER && bp->bpnum > 0 ) + { + hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); + + /* if this leaves no other break points then + send command to simulator to delete bp from this addr */ + if (hTabSearch(bptable,bp->addr) == NULL) + { + simClearBP (bp->addr); + Dprintf(D_break, ("break: simClearBP 0x%x\n", bp->addr)); + + } + userBpPresent-- ; + freeUSERbp(bp); + } + return 1; +} + +/*-----------------------------------------------------------------*/ +/* stepBpCB - call back function for step break points */ +/*-----------------------------------------------------------------*/ +BP_CALLBACK(stepBpCB) +{ + static function *lfunc = NULL; + + Dprintf(D_break, ("break: stepBpCB: BP_CALLBACK entry\n")); + + if (srcMode == SRC_CMODE) { + if ((lfunc && lfunc != ctxt->func) || !lfunc) + fprintf(stdout,"%s () at %s:%d\n", + ctxt->func->sym->name, + ctxt->func->mod->c_name, + ctxt->cline+1); + + if (ctxt->func->mod && ctxt->cline > 0) { + fprintf(stdout,"%d\t%s",ctxt->cline+1 , + ctxt->func->mod->cLines[ctxt->cline]->src); + } + } else { + if ((lfunc && lfunc != ctxt->func) || !lfunc) + fprintf(stdout,"%s () at %s:%d\n", + ctxt->func->sym->name, + ctxt->func->mod->asm_name, + ctxt->asmline); + + if (ctxt->func->mod && ctxt->cline > 0) { + fprintf(stdout,"%d\t%s",ctxt->asmline , + ctxt->func->mod->asmLines[ctxt->asmline]->src); + } + } + lfunc = ctxt->func; + + deleteSTEPbp(); + return 1; +} + +/*-----------------------------------------------------------------*/ +/* nextBpCB - call back function for next break points */ +/*-----------------------------------------------------------------*/ +BP_CALLBACK(nextBpCB) +{ + static function *lfunc = NULL; + + Dprintf(D_break, ("break: nextBpCB: BP_CALLBACK entry\n")); + + if (srcMode == SRC_CMODE) { + if ((lfunc && lfunc != ctxt->func) || !lfunc) + fprintf(stdout,"%s () at %s:%d\n", + ctxt->func->sym->name, + ctxt->func->mod->c_name, + ctxt->cline+1); + + if (ctxt->func->mod && ctxt->cline > 0) + fprintf(stdout,"%d\t%s",ctxt->cline+1, + ctxt->func->mod->cLines[ctxt->cline]->src); + } else { + if ((lfunc && lfunc != ctxt->func) || !lfunc) + fprintf(stdout,"%s () at %s:%d\n", + ctxt->func->sym->name, + ctxt->func->mod->asm_name, + ctxt->asmline); + + if (ctxt->func->mod && ctxt->asmline > 0) + fprintf(stdout,"%d\t%s",ctxt->asmline, + ctxt->func->mod->asmLines[ctxt->asmline]->src); + + } + lfunc = ctxt->func; + + deleteNEXTbp(); + return 1; +} diff --git a/debugger/mcs51/break.h b/debugger/mcs51/break.h new file mode 100644 index 0000000..062cb22 --- /dev/null +++ b/debugger/mcs51/break.h @@ -0,0 +1,98 @@ +/*------------------------------------------------------------------------- + break.h - Header file for break point management + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SDCDB_BREAK_H +#define SDCDB_BREAK_H + +#include "simi.h" + +/* break point type */ +enum { + DATA = 1, + CODE , + A_CODE , + USER , + STEP , + NEXT , + FENTRY , + FEXIT, + TMPUSER }; + +typedef struct breakp +{ + unsigned addr; /* address of break point */ + int bpnum ; /* break point number */ + char addrType; /* data or code */ + char bpType ; /* bp type USER/ LOGICAL */ + char *filename; /* file name */ + int lineno ; /* lineno */ + int (*callBack) + (unsigned,struct breakp *,context *);/* address of call back + * function */ + char *commands; + int ignoreCnt; + int hitCnt; + char *condition; +} breakp; + + +#define BP_CALLBACK(func) \ + int func (unsigned addr, \ + breakp *bp, \ + context *ctxt) + +#define EXTERN_BP_CALLBACK(func) \ + extern int func (unsigned addr, \ + breakp *bp, \ + context *ctxt) + +extern char userBpPresent; +extern char doingSteps; +extern hTab *bptable; + + + +int setBreakPoint (unsigned , char , char, + int (*callBack)(unsigned,breakp *bp,context *),char *, int); + +long getLastBreakptNumber(void); +void resetHitCount(void); +void setUserbpCommand (int , char *); +void setUserbpCondition (int , char *); +void setUserbpIgnCount (int , int ); + +void clearUSERbp ( unsigned int ); +void deleteSTEPbp(); +void deleteNEXTbp(); +void deleteUSERbp(int); +int dispatchCB (unsigned, context *); +void listUSERbp (); + +/* call back functions */ +EXTERN_BP_CALLBACK(fexitCB); +EXTERN_BP_CALLBACK(fentryCB); +EXTERN_BP_CALLBACK(userBpCB); +EXTERN_BP_CALLBACK(stepBpCB); +EXTERN_BP_CALLBACK(nextBpCB); + +#endif diff --git a/debugger/mcs51/clean.mk b/debugger/mcs51/clean.mk new file mode 100644 index 0000000..e105224 --- /dev/null +++ b/debugger/mcs51/clean.mk @@ -0,0 +1,23 @@ +# Deleting all files created by building the program +# -------------------------------------------------- +clean: + rm -f *core *[%~] *.[oa] + rm -f .[a-z]*~ + rm -f $(top_builddir)/bin/sdcdb$(EXEEXT) + +# Deleting all files created by configuring or building the program +# ----------------------------------------------------------------- +distclean: clean + rm -f config.h config.cache config.log config.status + rm -f Makefile *.dep + + +# Like clean but some files may still exist +# ----------------------------------------- +mostlyclean: clean + + +# Deleting everything that can reconstructed by this Makefile. It deletes +# everything deleted by distclean plus files created by bison, etc. +# ----------------------------------------------------------------------- +realclean: distclean diff --git a/debugger/mcs51/cmd.c b/debugger/mcs51/cmd.c new file mode 100644 index 0000000..2104ff0 --- /dev/null +++ b/debugger/mcs51/cmd.c @@ -0,0 +1,3557 @@ +/*------------------------------------------------------------------------- + cmd.c - source file for debugger command execution + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include "sdcdb.h" +#undef DATADIR +#include "symtab.h" +#include "simi.h" +#include "break.h" +#include "cmd.h" +#include "newalloc.h" + +/* default number of lines to list out */ +#define LISTLINES 10 +static int listlines = LISTLINES; + +/* mainly used to retain a reference to the active module being + listed. May be used as a general context for other commands if + no better context is available */ +static module *list_mod = NULL; + +EXTERN_STACK_DCL(callStack,function *,1024) + +#if defined(__APPLE__) && defined(__MACH__) +static char *copying= +{" GNU GENERAL PUBLIC LICENSE Version 2"}; +static char *warranty= +{" NO WARRANTY"}; +#else +static char *copying= +" GNU GENERAL PUBLIC LICENSE\n" +" Version 2, June 1991\n" +"\n" +" Copyright (C) 1989, 1991 Free Software Foundation, Inc.\n" +" 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA\n" +" Everyone is permitted to copy and distribute verbatim copies\n" +" of this license document, but changing it is not allowed.\n" +"\n" +" Preamble\n" +"\n" +" The licenses for most software are designed to take away your\n" +"freedom to share and change it. By contrast, the GNU General Public\n" +"License is intended to guarantee your freedom to share and change free\n" +"software--to make sure the software is free for all its users. This\n" +"General Public License applies to most of the Free Software\n" +"Foundation's software and to any other program whose authors commit to\n" +"using it. (Some other Free Software Foundation software is covered by\n" +"the GNU Library General Public License instead.) You can apply it to\n" +"your programs, too.\n" +"\n" +" When we speak of free software, we are referring to freedom, not\n" +"price. Our General Public Licenses are designed to make sure that you\n" +"have the freedom to distribute copies of free software (and charge for\n" +"this service if you wish), that you receive source code or can get it\n" +"if you want it, that you can change the software or use pieces of it\n" +"in new free programs; and that you know you can do these things.\n" +"\n" +" To protect your rights, we need to make restrictions that forbid\n" +"anyone to deny you these rights or to ask you to surrender the rights.\n" +"These restrictions translate to certain responsibilities for you if you\n" +"distribute copies of the software, or if you modify it.\n" +"\n" +" For example, if you distribute copies of such a program, whether\n" +"gratis or for a fee, you must give the recipients all the rights that\n" +"you have. You must make sure that they, too, receive or can get the\n" +"source code. And you must show them these terms so they know their\n" +"rights.\n" +"\n" +" We protect your rights with two steps: (1) copyright the software, and\n" +"(2) offer you this license which gives you legal permission to copy,\n" +"distribute and/or modify the software.\n" +"\n" +" Also, for each author's protection and ours, we want to make certain\n" +"that everyone understands that there is no warranty for this free\n" +"software. If the software is modified by someone else and passed on, we\n" +"want its recipients to know that what they have is not the original, so\n" +"that any problems introduced by others will not reflect on the original\n" +"authors' reputations.\n" +"\n" +" Finally, any free program is threatened constantly by software\n" +"patents. We wish to avoid the danger that redistributors of a free\n" +"program will individually obtain patent licenses, in effect making the\n" +"program proprietary. To prevent this, we have made it clear that any\n" +"patent must be licensed for everyone's free use or not licensed at all.\n" +"\n" +" The precise terms and conditions for copying, distribution and\n" +"modification follow.\n" +"^L\n" +" GNU GENERAL PUBLIC LICENSE\n" +" TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n" +"\n" +" 0. This License applies to any program or other work which contains\n" +"a notice placed by the copyright holder saying it may be distributed\n" +"under the terms of this General Public License. The \"Program\", below,\n" +"refers to any such program or work, and a \"work based on the Program\"\n" +"means either the Program or any derivative work under copyright law:\n" +"that is to say, a work containing the Program or a portion of it,\n" +"either verbatim or with modifications and/or translated into another\n" +"language. (Hereinafter, translation is included without limitation in\n" +"the term \"modification\".) Each licensee is addressed as \"you\".\n" +"\n" +"Activities other than copying, distribution and modification are not\n" +"covered by this License; they are outside its scope. The act of\n" +"running the Program is not restricted, and the output from the Program\n" +"is covered only if its contents constitute a work based on the\n" +"Program (independent of having been made by running the Program).\n" +"Whether that is true depends on what the Program does.\n" +"\n" +" 1. You may copy and distribute verbatim copies of the Program's\n" +"source code as you receive it, in any medium, provided that you\n" +"conspicuously and appropriately publish on each copy an appropriate\n" +"copyright notice and disclaimer of warranty; keep intact all the\n" +"notices that refer to this License and to the absence of any warranty;\n" +"and give any other recipients of the Program a copy of this License\n" +"along with the Program.\n" +"\n" +"You may charge a fee for the physical act of transferring a copy, and\n" +"you may at your option offer warranty protection in exchange for a fee.\n" +"\n" +" 2. You may modify your copy or copies of the Program or any portion\n" +"of it, thus forming a work based on the Program, and copy and\n" +"distribute such modifications or work under the terms of Section 1\n" +"above, provided that you also meet all of these conditions:\n" +"\n" +" a) You must cause the modified files to carry prominent notices\n" +" stating that you changed the files and the date of any change.\n" +"\n" +" b) You must cause any work that you distribute or publish, that in\n" +" whole or in part contains or is derived from the Program or any\n" +" part thereof, to be licensed as a whole at no charge to all third\n" +" parties under the terms of this License.\n" +"\n" +" c) If the modified program normally reads commands interactively\n" +" when run, you must cause it, when started running for such\n" +" interactive use in the most ordinary way, to print or display an\n" +" announcement including an appropriate copyright notice and a\n" +" notice that there is no warranty (or else, saying that you provide\n" +" a warranty) and that users may redistribute the program under\n" +" these conditions, and telling the user how to view a copy of this\n" +" License. (Exception: if the Program itself is interactive but\n" +" does not normally print such an announcement, your work based on\n" +" the Program is not required to print an announcement.)\n" +"\n" +"These requirements apply to the modified work as a whole. If\n" +"identifiable sections of that work are not derived from the Program,\n" +"and can be reasonably considered independent and separate works in\n" +"themselves, then this License, and its terms, do not apply to those\n" +"sections when you distribute them as separate works. But when you\n" +"distribute the same sections as part of a whole which is a work based\n" +"on the Program, the distribution of the whole must be on the terms of\n" +"this License, whose permissions for other licensees extend to the\n" +"entire whole, and thus to each and every part regardless of who wrote it.\n" +"\n" +"Thus, it is not the intent of this section to claim rights or contest\n" +"your rights to work written entirely by you; rather, the intent is to\n" +"exercise the right to control the distribution of derivative or\n" +"collective works based on the Program.\n" +"\n" +"In addition, mere aggregation of another work not based on the Program\n" +"with the Program (or with a work based on the Program) on a volume of\n" +"a storage or distribution medium does not bring the other work under\n" +"the scope of this License.\n" +"\n" +" 3. You may copy and distribute the Program (or a work based on it,\n" +"under Section 2) in object code or executable form under the terms of\n" +"Sections 1 and 2 above provided that you also do one of the following:\n" +"\n" +" a) Accompany it with the complete corresponding machine-readable\n" +" source code, which must be distributed under the terms of Sections\n" +" 1 and 2 above on a medium customarily used for software interchange; or,\n" +"\n" +" b) Accompany it with a written offer, valid for at least three\n" +" years, to give any third party, for a charge no more than your\n" +" cost of physically performing source distribution, a complete\n" +" machine-readable copy of the corresponding source code, to be\n" +" distributed under the terms of Sections 1 and 2 above on a medium\n" +" customarily used for software interchange; or,\n" +"\n" +" c) Accompany it with the information you received as to the offer\n" +" to distribute corresponding source code. (This alternative is\n" +" allowed only for noncommercial distribution and only if you\n" +" received the program in object code or executable form with such\n" +" an offer, in accord with Subsection b above.)\n" +"\n" +"The source code for a work means the preferred form of the work for\n" +"making modifications to it. For an executable work, complete source\n" +"code means all the source code for all modules it contains, plus any\n" +"associated interface definition files, plus the scripts used to\n" +"control compilation and installation of the executable. However, as a\n" +"special exception, the source code distributed need not include\n" +"anything that is normally distributed (in either source or binary\n" +"form) with the major components (compiler, kernel, and so on) of the\n" +"operating system on which the executable runs, unless that component\n" +"itself accompanies the executable.\n" +"\n" +"If distribution of executable or object code is made by offering\n" +"access to copy from a designated place, then offering equivalent\n" +"access to copy the source code from the same place counts as\n" +"distribution of the source code, even though third parties are not\n" +"compelled to copy the source along with the object code.\n" +"^L\n" +" 4. You may not copy, modify, sublicense, or distribute the Program\n" +"except as expressly provided under this License. Any attempt\n" +"otherwise to copy, modify, sublicense or distribute the Program is\n" +"void, and will automatically terminate your rights under this License.\n" +"However, parties who have received copies, or rights, from you under\n" +"this License will not have their licenses terminated so long as such\n" +"parties remain in full compliance.\n" +"\n" +" 5. You are not required to accept this License, since you have not\n" +"signed it. However, nothing else grants you permission to modify or\n" +"distribute the Program or its derivative works. These actions are\n" +"prohibited by law if you do not accept this License. Therefore, by\n" +"modifying or distributing the Program (or any work based on the\n" +"Program), you indicate your acceptance of this License to do so, and\n" +"all its terms and conditions for copying, distributing or modifying\n" +"the Program or works based on it.\n" +"\n" +" 6. Each time you redistribute the Program (or any work based on the\n" +"Program), the recipient automatically receives a license from the\n" +"original licensor to copy, distribute or modify the Program subject to\n" +"these terms and conditions. You may not impose any further\n" +"restrictions on the recipients' exercise of the rights granted herein.\n" +"You are not responsible for enforcing compliance by third parties to\n" +"this License.\n" +"\n" +" 7. If, as a consequence of a court judgment or allegation of patent\n" +"infringement or for any other reason (not limited to patent issues),\n" +"conditions are imposed on you (whether by court order, agreement or\n" +"otherwise) that contradict the conditions of this License, they do not\n" +"excuse you from the conditions of this License. If you cannot\n" +"distribute so as to satisfy simultaneously your obligations under this\n" +"License and any other pertinent obligations, then as a consequence you\n" +"may not distribute the Program at all. For example, if a patent\n" +"license would not permit royalty-free redistribution of the Program by\n" +"all those who receive copies directly or indirectly through you, then\n" +"the only way you could satisfy both it and this License would be to\n" +"refrain entirely from distribution of the Program.\n" +"\n" +"If any portion of this section is held invalid or unenforceable under\n" +"any particular circumstance, the balance of the section is intended to\n" +"apply and the section as a whole is intended to apply in other\n" +"circumstances.\n" +"\n" +"It is not the purpose of this section to induce you to infringe any\n" +"patents or other property right claims or to contest validity of any\n" +"such claims; this section has the sole purpose of protecting the\n" +"integrity of the free software distribution system, which is\n" +"implemented by public license practices. Many people have made\n" +"generous contributions to the wide range of software distributed\n" +"through that system in reliance on consistent application of that\n" +"system; it is up to the author/donor to decide if he or she is willing\n" +"to distribute software through any other system and a licensee cannot\n" +"impose that choice.\n" +"\n" +"This section is intended to make thoroughly clear what is believed to\n" +"be a consequence of the rest of this License.\n" +"\n" +" 8. If the distribution and/or use of the Program is restricted in\n" +"certain countries either by patents or by copyrighted interfaces, the\n" +"original copyright holder who places the Program under this License\n" +"may add an explicit geographical distribution limitation excluding\n" +"those countries, so that distribution is permitted only in or among\n" +"countries not thus excluded. In such case, this License incorporates\n" +"the limitation as if written in the body of this License.\n" +"\n" +" 9. The Free Software Foundation may publish revised and/or new versions\n" +"of the General Public License from time to time. Such new versions will\n" +"be similar in spirit to the present version, but may differ in detail to\n" +"address new problems or concerns.\n" +"\n" +"Each version is given a distinguishing version number. If the Program\n" +"specifies a version number of this License which applies to it and \"any\n" +"later version\", you have the option of following the terms and conditions\n" +"either of that version or of any later version published by the Free\n" +"Software Foundation. If the Program does not specify a version number of\n" +"this License, you may choose any version ever published by the Free Software\n" +"Foundation.\n" +"\n" +" 10. If you wish to incorporate parts of the Program into other free\n" +"programs whose distribution conditions are different, write to the author\n" +"to ask for permission. For software which is copyrighted by the Free\n" +"Software Foundation, write to the Free Software Foundation; we sometimes\n" +"make exceptions for this. Our decision will be guided by the two goals\n" +"of preserving the free status of all derivatives of our free software and\n" +"of promoting the sharing and reuse of software generally.\n"; + +static char *warranty= +" NO WARRANTY\n" +"\n" +" 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\n" +"FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN\n" +"OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\n" +"PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\n" +"OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n" +"MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS\n" +"TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE\n" +"PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\n" +"REPAIR OR CORRECTION.\n" +"\n" +" 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n" +"WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\n" +"REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\n" +"INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\n" +"OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\n" +"TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\n" +"YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\n" +"PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\n" +"POSSIBILITY OF SUCH DAMAGES.\n"; +#endif + +static void printTypeInfo(st_link *); +static void printValAggregates (symbol *,st_link *,char,unsigned int,int); +static int printOrSetSymValue (symbol *sym, context *cctxt, + int flg, int dnum, int fmt, + char *rs, char *val, char cmp); + +int srcMode = SRC_CMODE ; +set *dispsymbols = NULL ; /* set of displayable symbols */ +static int currentFrame = 0; /* actual displayed frame */ +/*-----------------------------------------------------------------*/ +/* funcWithName - returns function with name */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(funcWithName) +{ + function *func = item; + V_ARG(char *, name); + V_ARG(function **, funcp); + + if (*funcp) + return 0; + + if (strcmp(func->sym->name, name) == 0) + { + *funcp = func; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* symWithAddr - look for symbol with sfr / sbit address */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(symWithAddr) +{ + symbol *sym = item; + V_ARG(unsigned long,laddr); + V_ARG(int ,laddrspace); + V_ARG(symbol **,rsym); + + if (*rsym) + return 0; + + if ( sym->addr == laddr && sym->addrspace == laddrspace ) + { + *rsym = sym; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* setBPatModLine - set break point at the line specified for the */ +/*-----------------------------------------------------------------*/ +static void setBPatModLine (module *mod, int line, char bpType ) +{ + int next_line; + + /* look for the first executable line after the line + specified & get the break point there */ + + if ( line < 0 ) + return; + + if (srcMode == SRC_CMODE && line > mod->ncLines) + { + fprintf(stderr,"No line %d in file \"%s\".\n", + line,mod->c_name); + return ; + } + + if (srcMode == SRC_AMODE && line > mod->nasmLines) + { + fprintf(stderr,"No line %d in file \"%s\".\n", + line,mod->asm_name); + return ; + } + + next_line = line; + for ( ; + next_line < (srcMode == SRC_CMODE ? mod->ncLines : mod->nasmLines ) ; + next_line++ ) + { + if (srcMode == SRC_CMODE) + { + if (mod->cLines[next_line]->addr != INT_MAX) + { + setBreakPoint (mod->cLines[next_line]->addr, CODE, bpType, + userBpCB, mod->c_name, next_line); + return; +// break; + } + } + else + { + if (mod->asmLines[next_line]->addr != INT_MAX) + { + setBreakPoint (mod->asmLines[next_line]->addr, CODE, bpType, + userBpCB, mod->asm_name, next_line); + return; +// break; + } + } + } + + fprintf(stderr, "No line %d or after in file \"%s\"..\n", + line, mod->c_name); + + return; +} + +/*-----------------------------------------------------------------*/ +/* clearBPatModLine - clr break point at the line specified */ +/*-----------------------------------------------------------------*/ +static void clearBPatModLine (module *mod, int line) +{ + /* look for the first executable line after the line + specified & get the break point there */ + if (srcMode == SRC_CMODE && line > mod->ncLines) + { + fprintf(stderr,"No line %d in file \"%s\".\n", + line,mod->c_name); + return; + } + + if (srcMode == SRC_AMODE && line > mod->ncLines) + { + fprintf(stderr,"No line %d in file \"%s\".\n", + line,mod->c_name); + return; + } + + for ( ; + line < (srcMode == SRC_CMODE ? mod->ncLines : mod->nasmLines ) ; + line++ ) + { + if (srcMode == SRC_CMODE) + { + if (mod->cLines[line]->addr) + { + clearUSERbp (mod->cLines[line]->addr); + break; + } + } + else + { + if (mod->asmLines[line]->addr) + { + clearUSERbp (mod->asmLines[line]->addr); + break; + } + } + } + + return; +} + +/*-----------------------------------------------------------------*/ +/* moduleLineWithAddr - finds and returns a line with a given address */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(moduleLineWithAddr) +{ + module *mod = item; + int i; + + V_ARG(unsigned int,addr); + V_ARG(module **,rmod); + V_ARG(int *,line); + + if (*rmod) + return 0; + + for (i=0; i < mod->nasmLines; i++ ) + { + if ( mod->asmLines[i]->addr == addr) + { + *rmod = mod ; + if (line ) + { + *line = 0; + for ( i=0; i < mod->ncLines; i++ ) + { + if ( mod->cLines[i]->addr > addr) + break; + *line = i; + } + return 1; + } + } + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* funcWithNameModule - returns functions with a name module combo */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(funcWithNameModule) +{ + function *func = item; + V_ARG(char *,fname); + V_ARG(char *,mname); + V_ARG(function **,funcp); + + if (*funcp) + return 0; + + if (strcmp(func->sym->name,fname) == 0 && + strcmp(func->mod->c_name,mname) == 0) + { + *funcp = func; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* funcInAddr - given an address returns the function */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(funcInAddr) +{ + function *func = item; + V_ARG(unsigned int,addr); + V_ARG(function **,funcp); + + if (*funcp) + return 0; + + /* in the address range */ + if (func->sym->addr <= addr && func->sym->eaddr >= addr) + { + *funcp = func; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* setStepBp - will set STEP Bp @ function entry points */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(setStepBp) +{ + function *func = item; + + if (func->sym && func->sym->addr ) + { + /* set the entry break point */ + setBreakPoint (func->sym->addr , CODE , STEP , + stepBpCB ,func->mod->c_name , func->entryline); + + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* setStepEPBp - sets a given type of bp @ the execution point */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(setStepEPBp) +{ + exePoint *ep = item; + V_ARG(int,bptype); + V_ARG(char *,mname); + + setBreakPoint (ep->addr, CODE, bptype, stepBpCB, mname, ep->line); + return 1; +} + +/*-----------------------------------------------------------------*/ +/* setNextEPBp - sets a given type of bp @ the execution point */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(setNextEPBp) +{ + exePoint *ep = item; + V_ARG(int,bptype); + V_ARG(char *,mname); + + setBreakPoint (ep->addr, CODE, bptype, nextBpCB, mname, ep->line); + return 1; +} + +/*-----------------------------------------------------------------*/ +/* lineAtAddr - for execution points returns the one with addr */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(lineAtAddr) +{ + exePoint *ep = item; + V_ARG(unsigned int,addr); + V_ARG(int *,line); + V_ARG(int *,block); + V_ARG(int *,level); + + /* address must be an exact match */ + if (ep->addr == addr) + { + *line = ep->line; + if (block) + *block = ep->block; + if (level) + *level = ep->level; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* lineNearAddr - for execution points returns the one with addr */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(lineNearAddr) +{ + exePoint *ep = item; + V_ARG(unsigned int,addr); + V_ARG(int *,line); + V_ARG(int *,block); + V_ARG(int *,level); + + /* the line in which the address is */ + if (ep->addr <= addr) + { + *line = ep->line; + if (block) + *block = ep->block ; + if (level) + *level = ep->level ; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* discoverContext - find out the current context of the bp */ +/*-----------------------------------------------------------------*/ +context *discoverContext (unsigned addr, function *func) +{ + module *mod = NULL; + int line = 0; + + /* find the function we are in */ + if (!func && !applyToSet(functions,funcInAddr,addr,&func)) + { + if (!applyToSet(functions,funcWithName,"_main",&func) || + !applyToSet(modules,moduleLineWithAddr,addr,&mod,NULL)) + { + fprintf(stderr, "addr 0x%x in no module/function (runtime env?)\n",addr); + return NULL; + } + currCtxt->func = func; + currCtxt->addr = addr; + currCtxt->modName = mod->name; + currCtxt->cline = func->exitline; + } + else + { + currCtxt->func = func; + currCtxt->addr = func->laddr = addr; + currCtxt->modName = func->modName; + + /* find the c line number */ + if(applyToSet(func->cfpoints,lineAtAddr,addr, + &line,&currCtxt->block,&currCtxt->level)) + currCtxt->cline = func->lline = line; + else if(applyToSet(func->cfpoints,lineNearAddr,addr, + &line,&currCtxt->block,&currCtxt->level)) + currCtxt->cline = func->lline = line; + else + currCtxt->cline = -1; + } + /* find the asm line number */ + line = 0; + if (applyToSet(func->afpoints,lineAtAddr,addr, + &line,NULL,NULL)) + currCtxt->asmline = line; + else + currCtxt->asmline = -1; + + return currCtxt ; +} + +/*-----------------------------------------------------------------*/ +/* simGo - send 'go' cmd to simulator and wait till a break occurs */ +/*-----------------------------------------------------------------*/ +void simGo (unsigned int gaddr) +{ + unsigned int addr ; + context *ctxt; + int rv; + stopCommandList(); + +top: + if ( userinterrupt ) + { + userinterrupt = 0; + return; + } + if ( gaddr == 0 ) + { + function *func = NULL; + if (applyToSet(functions,funcInAddr,gaddr,&func)) + STACK_PUSH(callStack,func); + } + addr = simGoTillBp (gaddr); + + /* got the pc for the break point now first + discover the program context i.e. module, function + linenumber of the source etc, etc etc */ + currentFrame = 0; + ctxt = discoverContext (addr, NULL); + + /* dispatch all the break point call back functions */ + rv = dispatchCB (addr,ctxt); + + /* the dispatch call back function will return + non-zero if an user break point has been hit + if not then we continue with the execution + of the program */ + if (!rv) + { + if ( gaddr == 0 ) + gaddr = -1; + if ( gaddr == -1 || doingSteps == 1 ) + goto top ; + } +} + +/*-----------------------------------------------------------------*/ +/* preparePrint - common parse function for set variable, */ +/* output, print and display */ +/*-----------------------------------------------------------------*/ +static char *preparePrint(char *s, context *cctxt, int *fmt, symbol **sym) +{ + char *bp; + char save_ch ; + + *fmt = FMT_NON; + *sym = NULL; + + s = trim(s); + if (!*s) + return (char *)0; + + if ( *s == '/' ) + { + /* format of printout */ + switch ( *++s ) + { + case 'x': + *fmt = FMT_HEX ; + break; + case 'o': + *fmt = FMT_OCT ; + break; + default: + case 'd': + *fmt = FMT_DEZ ; + break; + case 't': + *fmt = FMT_BIN ; + break; + } + s++; + s = trim_left(s); + } + for ( bp = s; *bp && ( isalnum( *bp ) || *bp == '_' || *bp == '$'); bp++ ); + save_ch = *bp; + if ( *bp ) + *bp = '\0'; + + if ( *s ) + *sym = symLookup(s,cctxt); + *bp = save_ch; + + if ( ! *sym ) + fprintf(stdout,"No symbol \"%s\" in current context.\n", s); + return bp; +} + +static int printAsmLine( function *func, module *m, unsigned saddr, unsigned eaddr) +{ + int i,j,delta; + unsigned symaddr; + unsigned lastaddr = saddr+1; + char *symname; + + if ( func ) + { + symaddr = func->sym->addr; + symname = func->sym->name; + } + else + { + symaddr = saddr; + symname = "" ; + } + for (j=0,i=0; i < m->nasmLines; i++ ) + { + if ( saddr >= 0 && m->asmLines[i]->addr < saddr) + { + continue; + } + if ( eaddr >= 0 && m->asmLines[i]->addr > eaddr) + { + continue; + } + if ( func && + (m->asmLines[i]->addr < func->sym->addr || + m->asmLines[i]->addr > func->sym->eaddr )) + { + continue; + } + delta = m->asmLines[i]->addr - symaddr; + if ( delta >= 0 ) + { + j++; + lastaddr = m->asmLines[i]->addr; + printf("0x%08x <%s",lastaddr,symname); + if (delta > 0) + printf("+%d",delta); + printf(">:\t%s",m->asmLines[i]->src); + } + } + return lastaddr; +} + +/*-----------------------------------------------------------------*/ +/* cmdDisasm - disassemble asm instruction */ +/*-----------------------------------------------------------------*/ +static int cmdDisasm (char *s, context *cctxt, int args) +{ + function *func = NULL; + long saddr = -1; + long eaddr = -1; + int found = 0; + module *modul; + /* white space skip */ + + if ( args > 0 ) + { + s = trim_left(s); + + if ( isdigit(*s)) + { + saddr = strtol(s,&s,0); + if ( args > 1 ) + { + s = trim_left(s); + + if ( isdigit(*s)) + eaddr = strtol(s,0,0); + } + else + { + eaddr = saddr+1; + } + } + } + + if ( eaddr == -1 ) + { + /* no start or only start so dump function */ + if ( saddr == -1 ) + { + func = cctxt->func; + } + else + { + applyToSet(functions,funcInAddr,saddr,&func); + } + if ( func ) + { + printf("Dump of assembler code for function %s:\n",func->sym->name); + printAsmLine(func,func->mod,-1,-1); + printf("End of assembler dump.\n"); + return 0; + } + else + { + if (applyToSet(modules,moduleLineWithAddr,saddr,&modul,NULL)) + { + eaddr = saddr + 5; + printf("Dump of assembler code:\n"); + printAsmLine(NULL,modul,saddr,eaddr); + printf("End of assembler dump.\n"); + return 0; + } + } + } + else + { + if ( args > 1 ) + printf("Dump of assembler code from 0x%08lx to 0x%08lx:\n",saddr,eaddr); + found = 0; + while ( saddr < eaddr ) + { + func = NULL; + if (applyToSet(functions,funcInAddr,saddr,&func)) + { + found = 1; + modul = func->mod; + } + else + { + if ( found ) + break; + if (!applyToSet(modules,moduleLineWithAddr,saddr,&modul,NULL)) + break; + } + saddr = printAsmLine(func,modul,saddr,eaddr) + 1; + } + if( saddr >= eaddr) + { + if ( args > 1 ) + printf("End of assembler dump.\n"); + return 0; + } + } + fprintf(stderr,"No function contains specified address.\n"); + if( saddr >= 0 ) + { + char lbuf[64]; + sprintf(lbuf,"dis 0x%lx 0 %ld\n",saddr,( eaddr == -1 )?1L:eaddr-saddr); + sendSim(lbuf); + waitForSim(1000, NULL); + fputs(simResponse(),stdout); + } + return 0; +} +/*-----------------------------------------------------------------*/ +/* cmdDisasm1 - disassemble one asm instruction */ +/*-----------------------------------------------------------------*/ +int cmdDisasm1 (char *s, context *cctxt) +{ + return cmdDisasm( s, cctxt, 1); +} + +/*-----------------------------------------------------------------*/ +/* cmdDisasmF - disassemble asm instructions */ +/*-----------------------------------------------------------------*/ +int cmdDisasmF(char *s, context *cctxt) +{ + return cmdDisasm( s, cctxt, 2); +} + +static int commonSetUserBp(char *s, context *cctxt, char bpType) +{ + char *bp ; + function *func = NULL; + + /* user break point location specification can be of the following + forms + a) <nothing> - break point at current location + b) lineno - number of the current module + c) filename:lineno - line number of the given file + e) filename:function- function X in file Y (useful for static functions) + f) function - function entry point + g) *addr - break point at address + */ + + if (!cctxt) + { + fprintf (stdout, "No symbol table is loaded. Use the \"file\" command.\n"); + return 0; + } + /* trim left and right */ + s = trim(s); + + /* case a) nothing */ + /* if nothing given then current location : we know + the current execution location from the currentContext */ + if (! *s ) + { + /* if current context is known */ + if (cctxt->func) + { + Dprintf (D_break, ("commonSetUserBp: a) cctxtaddr:%x \n", cctxt->addr)); + if (srcMode == SRC_CMODE) + { + /* set the break point */ + setBreakPoint (cctxt->addr, CODE, bpType, userBpCB, + cctxt->func->mod->c_name, cctxt->cline); + } + else + { + setBreakPoint (cctxt->addr, CODE, bpType, userBpCB, + cctxt->func->mod->asm_name, cctxt->asmline); + } + } + else + { + fprintf(stderr, "No default breakpoint address now.\n"); + } + + goto ret; + } + /* case g) *addr */ + if (*s == '*' && isdigit(*(s+1))) + { + int line = 0; + long braddr = strtol(s+1, 0, 0); + if (!applyToSet (functions, funcInAddr, braddr, &func)) + { + module *modul; + if (!applyToSet (modules, moduleLineWithAddr, braddr, &modul, &line)) + { + fprintf (stderr, "Address 0x%08lx not exists in code.\n", braddr); + } + else + { + Dprintf (D_break, ("commonSetUserBp: g) addr:%lx \n", braddr)); + setBreakPoint (braddr, CODE, bpType, userBpCB, modul->c_name, line); + } + goto ret; + } + else + { + int line = func->exitline; + if (!applyToSet (func->cfpoints, lineAtAddr, braddr, &line, NULL, NULL)) + { + applyToSet (func->cfpoints, lineNearAddr, braddr, &line, NULL, NULL); + } + setBreakPoint (braddr, CODE, bpType, userBpCB, func->mod->c_name, line); + } + goto ret; + } + /* case b) lineno */ + /* check if line number */ + if (!strchr(s,':') && isdigit(*s)) + { + /* get the lineno */ + int line = atoi(s) -1; + Dprintf (D_break, ("commonSetUserBp: b) line:%d \n", line)); + if (line < 0) + { + fprintf(stdout, "linenumber <= 0\n"); + goto ret; + } + /* if current context not present then we must get the module + which has main & set the break point @ line number provided + of that module : if current context known then set the bp + at the line number given for the current module + */ + if (cctxt->func) + { + if (!cctxt->func->mod) + { + if (!applyToSet (functions, funcWithName, "main", &func)) + { + fprintf (stderr, "Function \"main\" not defined.\n"); + } + else + { + setBPatModLine (func->mod, line, bpType); + } + } + else + { + setBPatModLine(cctxt->func->mod,line, bpType); + } + } + else + { + if (list_mod) + { + setBPatModLine (list_mod, line, bpType); + } + else + { + fprintf (stdout, "Sdcdb fails to have module symbol context at %d\n", __LINE__); + } + } + + goto ret; + } + + if ((bp = strchr(s,':'))) + { + module *mod = NULL; + *bp = '\0'; + + if (srcMode == SRC_CMODE) + { + if (!applyToSet (modules, moduleWithCName, s, &mod)) + { + fprintf (stderr, "No source file named %s.\n", s); + goto ret; + } + } + else + { + if (!applyToSet (modules, moduleWithAsmName, s, &mod)) + { + fprintf (stderr, "No source file named %s.\n", s); + goto ret; + } + } + + /* case c) filename:lineno */ + if (isdigit(*(bp +1))) + { + Dprintf (D_break, ("commonSetUserBp: c) line:%d \n", atoi(bp+1))); + setBPatModLine (mod, atoi(bp+1)-1, bpType); + goto ret; + } + /* case d) filename:function */ + if (!applyToSet (functions, funcWithNameModule, bp+1, s, &func)) + { + fprintf(stderr, "Function \"%s\" not defined.\n", bp+1); + } + else + { + Dprintf (D_break, ("commonSetUserBp: d) \n")); + setBPatModLine (mod, + (srcMode == SRC_CMODE ? + func->entryline : + func->aentryline),bpType); + } + goto ret; + } + + /* case e) function */ + Dprintf (D_break, ("commonSetUserBp: e) \n")); + if (!applyToSet (functions, funcWithName, s, &func)) + { + fprintf(stderr,"Function \"%s\" not defined.\n", s); + } + else + { + setBPatModLine (func->mod, + (srcMode == SRC_CMODE ? + func->entryline : + func->aentryline),bpType); + } + +ret: + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdSetTmpUserBp - settempory break point at the user specified location */ +/*-----------------------------------------------------------------*/ +int cmdSetTmpUserBp (char *s, context *cctxt) +{ + return commonSetUserBp(s, cctxt, TMPUSER ); +} + +/*-----------------------------------------------------------------*/ +/* cmdSetUserBp - set break point at the user specified location */ +/*-----------------------------------------------------------------*/ +int cmdSetUserBp (char *s, context *cctxt) +{ + return commonSetUserBp(s, cctxt, USER ); +} + +/*-----------------------------------------------------------------*/ +/* cmdJump - set program counter */ +/*-----------------------------------------------------------------*/ +int cmdJump (char *s, context *cctxt) +{ + char *bp; + if (STACK_EMPTY(callStack)) + { + fprintf(stdout,"The program is not running.\n"); + return 0; + } + + /* trim left and right */ + s = trim(s); + + if (! *s ) + { + fprintf(stdout,"No argument: need line or *addr.\n"); + return 0; + } + if ( *s == '*' && isdigit(*(s+1))) + { + unsigned int addr = atoi(s); + if (cctxt && cctxt->func && + cctxt->func->sym->addr <= addr && + cctxt->func->sym->eaddr >= addr) + { + simSetPC(addr); + return 0; + } + fprintf(stdout,"Warning addr 0x%x outside actual function.\n",addr); + simSetPC(addr); + return 0; + } + if (isdigit(*s)) + { + /* get the lineno */ + int line = atoi(s) -1; + if (!cctxt || !cctxt->func || !cctxt->func->mod) + { + fprintf(stderr,"Function not defined.\n"); + return 0; + } + if (line >= cctxt->func->entryline && + line <= cctxt->func->exitline ) + { + simSetPC(cctxt->func->mod->cLines[line]->addr); + return 0; + } + if (line >= cctxt->func->mod->ncLines ) + { + fprintf(stderr,"line not in module.\n"); + return 0; + } + fprintf(stdout,"Warning line %d outside actual function.\n",line+1); + simSetPC(cctxt->func->mod->cLines[line]->addr); + return 0; + } + if ((bp = strchr(s,':'))) + { + int line; + module *mod = NULL; + *bp++ = '\0'; + if (!applyToSet(modules,moduleWithCName,s,&mod)) + { + fprintf (stderr,"No source file named %s.\n",s); + return 0; + } + if (!isdigit(*bp)) + { + fprintf (stderr,"No line number.\n"); + return 0; + } + line = atoi(bp) -1; + if (line >= mod->ncLines ) + { + fprintf(stderr,"line not in module.\n"); + return 0; + } + if ( mod != cctxt->func->mod || + line < cctxt->func->entryline || + line > cctxt->func->exitline ) + { + fprintf(stdout,"Warning line %d outside actual function.\n", + line+1); + } + simSetPC(mod->cLines[line]->addr); + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdListAsm - list assembler source code */ +/*-----------------------------------------------------------------*/ +int cmdListAsm (char *s, context *cctxt) +{ + if ( cctxt && cctxt->func) + { + /* actual line */ + if ( cctxt->addr != INT_MAX ) + { + if (printAsmLine(cctxt->func,cctxt->func->mod, + (long)cctxt->addr,(long)cctxt->addr)) + return 0; + } + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdSetOption - set debugger options */ +/*-----------------------------------------------------------------*/ +int cmdSetOption (char *s, context *cctxt) +{ + s = trim_left(s); + if (strncmp(s,"srcmode",7) == 0 ) + { + if (srcMode == SRC_CMODE) + srcMode = SRC_AMODE; + else + srcMode = SRC_CMODE; + fprintf(stderr,"source mode set to '%s'\n", + (srcMode == SRC_CMODE ? "C" : "asm")); + return 0; + } + + if (strncmp(s,"listsize ",9) == 0) + { + listlines = strtol(s+9,0,0); + if ( listlines < LISTLINES ) + listlines = LISTLINES; + return 0; + } + +#ifdef SDCDB_DEBUG + if (strncmp(s,"debug ",6) == 0) + { + sdcdbDebug = strtol(s+6,0,0); + return 0; + } +#endif + if (strncmp(s,"variable ",9) == 0) + { + symbol *sym ; + int fmt; + char *rs; + s += 9; + if ( !( rs = preparePrint(s, cctxt, &fmt, &sym ))) + return 0; + s = rs; + while (*s && *s != '=') + s++; + *s++ = '\0'; + s = trim_left(s); + if (*s && sym) + { + printOrSetSymValue(sym,cctxt,0,0,0,rs,s,'\0'); + return 0; + } + else + { + fprintf(stdout,"No new value for \"%s\".\n",s); + } + return 0; + } + + fprintf(stderr,"'set %s' command not yet implemented\n",s); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdContinue - continue till next break point */ +/*-----------------------------------------------------------------*/ +int cmdContinue (char *s, context *cctxt) +{ + if (STACK_EMPTY(callStack)) + { + fprintf(stdout,"The program is not being run.\n"); + return 0; + } + + fprintf(stdout,"Continuing.\n"); + simGo(-1); + showfull = 1; + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdIgnore - set ignorecount for breakpoint */ +/*-----------------------------------------------------------------*/ +int cmdIgnore (char *s, context *cctxt) +{ + int bpnum, cnt ; + s = trim_left(s); + if (!*s ) + { + fprintf(stdout,"Argument required (breakpoint number).\n"); + return 0; + } + bpnum = strtol(s,&s,10); + s = trim_left(s); + if (!*s ) + { + fprintf(stdout,"Second argument (specified ignore-count) is missing."); + return 0; + } + cnt = strtol(s,0,10); + setUserbpIgnCount(bpnum,cnt); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdCondition - set condition for breakpoint */ +/*-----------------------------------------------------------------*/ +int cmdCondition (char *s, context *cctxt) +{ + int bpnum ; + s = trim_left(s); + if (!*s ) + { + fprintf(stdout,"Argument required (breakpoint number).\n"); + return 0; + } + bpnum = strtol(s,&s,10); + s = trim_left(s); + if (*s) + s = Safe_strdup(s); + else + s = NULL; + setUserbpCondition(bpnum,s); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdCommands - set commands for breakpoint */ +/*-----------------------------------------------------------------*/ +int cmdCommands (char *s, context *cctxt) +{ + int bpnum ; + char *cmds,*line; + s = trim_left(s); + + if (!*s ) + bpnum = getLastBreakptNumber(); + else + bpnum = strtol(s,0,10); + + cmds = NULL; + while ((line = getNextCmdLine())) + { + line = trim_left(line); + if (!strncmp(line,"end",3)) + break; + if (! cmds ) + { + cmds = Safe_strdup(line); + } + else + { + cmds = Safe_realloc( cmds, strlen(cmds) + 1 + strlen(line)); + strcat(cmds,line); + } + } + setUserbpCommand(bpnum,cmds); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdDelUserBp - delete user break point */ +/*-----------------------------------------------------------------*/ +int cmdDelUserBp (char *s, context *cctxt) +{ + int bpnum ; + s = trim_left(s); + + if (!*s ) + { + if (userBpPresent) + { + char buffer[10]; + fprintf (stdout,"Delete all breakpoints? (y or n) "); + fflush(stdout); + if (fgets(buffer,sizeof(buffer),stdin) && toupper(buffer[0]) == 'Y') + deleteUSERbp(-1); + } + return 0; + } + + /* determine the break point number */ + if (sscanf(s,"%d",&bpnum) == 1) + deleteUSERbp(bpnum); + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdStepi - single step exactly one instruction */ +/*-----------------------------------------------------------------*/ +int cmdStepi (char *s, context *cctxt) +{ + if (0 /*STACK_EMPTY(callStack)*/) + { + fprintf(stdout,"The program is not being run.\n"); + } + else + { + doingSteps = 2; + simGo(2); + doingSteps = 0; + showfull = 1; + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdStep - single step thru C source file */ +/*-----------------------------------------------------------------*/ +int cmdStep (char *s, context *cctxt) +{ + function *func = NULL; + + if (STACK_EMPTY(callStack)) + { + fprintf(stdout,"The program is not being run.\n"); + } + else + { + /* if we are @ the end of a function then set + break points at execution points of the + function in the call stack... */ + if (cctxt->addr == cctxt->func->sym->eaddr) + { + if ((func = STACK_PEEK(callStack))) + { + if (srcMode == SRC_CMODE) + applyToSet (func->cfpoints,setStepEPBp,STEP, + func->mod->c_name); + else + applyToSet (func->afpoints,setStepEPBp,STEP, + func->mod->asm_name); + } + } + else + { + /* set breakpoints at all function entry points + and all exepoints of this functions & for + all functions one up in the call stack */ + + /* all function entry points */ + applyToSet(functions,setStepBp); + + if (srcMode == SRC_CMODE) + { + /* for all execution points in this function */ + applyToSet(cctxt->func->cfpoints,setStepEPBp,STEP, + cctxt->func->mod->c_name); + + /* set a break point @ the current function's + exit */ + setBreakPoint (cctxt->func->sym->eaddr, CODE, STEP , + stepBpCB, cctxt->func->mod->c_name, + cctxt->func->exitline); + + /* now break point @ callers execution points */ + if ((func = STACK_PPEEK(callStack))) + { + applyToSet (func->cfpoints,setStepEPBp,STEP, + func->mod->c_name); + /* set bp @ callers exit point */ + setBreakPoint (func->sym->eaddr, CODE, STEP , + stepBpCB, func->mod->c_name, + func->exitline); + } + } + else + { + /* for all execution points in this function */ + applyToSet(cctxt->func->afpoints,setStepEPBp,STEP, + cctxt->func->mod->asm_name); + + /* set a break point @ the current function's + exit */ + setBreakPoint (cctxt->func->sym->eaddr, CODE, STEP , + stepBpCB, cctxt->func->mod->asm_name, + cctxt->func->aexitline); + + /* now break point @ callers execution points */ + if ((func = STACK_PPEEK(callStack))) + { + applyToSet (func->afpoints,setStepEPBp,STEP, + func->mod->asm_name); + + /* set bp @ callers exit point */ + setBreakPoint (func->sym->eaddr, CODE, STEP , + stepBpCB, func->mod->asm_name, + func->aexitline); + } + } + } + + doingSteps = 1; + simGo(2); + doingSteps = 0; + showfull = 1; + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdNexti - next instruction but proceed function call */ +/*-----------------------------------------------------------------*/ +int cmdNexti (char *s, context *cctxt) +{ + if (STACK_EMPTY(callStack)) + { + fprintf(stdout,"The program is not being run.\n"); + } + else + { + doingSteps = 2; + simGo(1); + doingSteps = 0; + showfull = 1; + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdNext - next executable C statement file */ +/*-----------------------------------------------------------------*/ +int cmdNext (char *s, context *cctxt) +{ + function *func = NULL; + /* next is almost the same as step except we don't + we don't set break point for all function entry + points */ + if (STACK_EMPTY(callStack)) + { + fprintf(stdout,"The program is not being run.\n"); + } + else + { + /* if we are @ the end of a function then set + break points at execution points of the + function in the call stack... */ + if (cctxt->addr == cctxt->func->sym->eaddr) + { + if ((func = STACK_PEEK(callStack))) + { + if (srcMode == SRC_CMODE) + applyToSet (func->cfpoints,setStepEPBp,NEXT, + func->mod->c_name); + else + applyToSet (func->afpoints,setStepEPBp,NEXT, + func->mod->asm_name); + } + } + else + { + if (srcMode == SRC_CMODE) + { + /* for all execution points in this function */ + applyToSet(cctxt->func->cfpoints,setNextEPBp,NEXT, + cctxt->func->mod->c_name); + /* set a break point @ the current function's + exit */ + setBreakPoint (cctxt->func->sym->eaddr, CODE, NEXT , + nextBpCB, cctxt->func->mod->c_name, + cctxt->func->exitline); + + /* now break point @ callers execution points */ + if ((func = STACK_PPEEK(callStack))) + { + applyToSet (func->cfpoints,setNextEPBp,NEXT , + func->mod->c_name); + /* set bp @ callers exit point */ + setBreakPoint (func->sym->eaddr, CODE, NEXT , + stepBpCB, func->mod->c_name, + func->exitline); + } + } + else + { + /* for all execution points in this function */ + applyToSet(cctxt->func->afpoints,setNextEPBp,NEXT, + cctxt->func->mod->asm_name); + /* set a break point @ the current function's + exit */ + setBreakPoint (cctxt->func->sym->eaddr, CODE, NEXT , + nextBpCB, cctxt->func->mod->asm_name, + cctxt->func->aexitline); + + /* now break point @ callers execution points */ + if ((func = STACK_PPEEK(callStack))) + { + applyToSet (func->cfpoints,setNextEPBp,NEXT , + func->mod->asm_name); + /* set bp @ callers exit point */ + setBreakPoint (func->sym->eaddr, CODE, NEXT , + stepBpCB, func->mod->asm_name, + func->aexitline); + } + } + } + doingSteps = 1; + simGo(1); + doingSteps = 0; + showfull = 1; + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdRun - run till next break point */ +/*-----------------------------------------------------------------*/ +int cmdRun (char *s, context *cctxt) +{ + char buff[10]; + if (STACK_EMPTY(callStack)) + { + fprintf(stdout,"Starting program\n"); + if ( ! simactive ) + { + fprintf(stdout,"No executable file specified.\nUse the \"file\" command.\n"); + return 0; + } + resetHitCount(); + simGo(0); + } + else + { + fprintf(stdout, + "The program being debugged has been started already.\n"); + fprintf(stdout,"Start it from the beginning? (y or n) "); + fflush(stdout); + + if (fgets(buff,sizeof(buff),stdin) && toupper(buff[0]) == 'Y') + { + simReset(); + resetHitCount(); + simGo(0); + } + } + showfull = 1; + return 0; +} + +/*----------------------------------------------------------------- + cmdListSymbols - list symbols +|-----------------------------------------------------------------*/ +int cmdListSymbols (char *s, context *cctxt) +{ + int our_verbose = 0; + symbol *sy; + int i; + + if (strstr(s, "v1")) + { + our_verbose = 1; + } + else if (strstr(s, "v2")) + { + our_verbose = 2; + } + + printf("[symbols]\n"); + sy = setFirstItem(symbols); + i = 0; + for (;;) + { + if (sy == NULL) + break; + if (our_verbose <= 1) + printf("<%s>", sy->name); + + if (our_verbose > 1) + { + printf(" %d) name:%s, size:%d, level:%d block:%d\n", i, + sy->name, sy->size, sy->level, sy->block); + printf(" isonstack:%d, isfunc:%d, offset:%d addr:%d\n", + sy->isonstack, sy->isfunc, sy->offset, sy->addr); + printf(" eaddr:%d, addr_type:%c, type:%p etype:%p\n", + sy->eaddr, sy->addr_type, sy->type, sy->etype); + printf(" scopetype:%c, sname:%s, rname:%s addrspace:%c\n", + sy->scopetype, sy->sname, sy->rname, sy->addrspace); + printf(" next:%p\n", sy->next); + } + ++i; + sy = setNextItem(symbols); + } + printf(" %d symbols\n", i); + return 0; +} + +/*----------------------------------------------------------------- + cmdListFunctions - list functions. +|-----------------------------------------------------------------*/ +int cmdListFunctions (char *s, context *cctxt) +{ + function *f; + int i; + int our_verbose = 0; + + if (strstr(s, "v1")) + { + our_verbose = 1; + } + else if (strstr(s, "v2")) + { + our_verbose = 2; + } + + printf("[functions]\n"); + f = setFirstItem(functions); + i = 0; + while (f != NULL) + { + if (our_verbose) + { + printf(" %d) sym:%p, fname:%s, modName:%s, mod:%p\n", i, + f->sym, f->sym->name, f->modName, f->mod); + printf(" entryline:%d, aentryline:%d, exitline:%d, aexitline:%d\n", + f->entryline, f->aentryline, f->exitline, f->aexitline); + printf(" cfpoints:%p, afpoints:%p, laddr:%x, lline:%d\n", + f->cfpoints, f->afpoints, f->laddr, f->lline); + } + else + { + printf("<%s>", f->sym->name); + } + ++i; + f = setNextItem(functions); + } + printf(" %d functions\n", i); + return 0; +} + +/*----------------------------------------------------------------- + cmdListModules - list modules. +|-----------------------------------------------------------------*/ +int cmdListModules (char *s, context *cctxt) +{ + module *m; + srcLine *cs, *as; + int i, mi; + int our_verbose = 0; + + if (strstr(s, "v1")) + { + our_verbose = 1; + } + else if (strstr(s, "v2")) + { + our_verbose = 2; + } + + printf("[modules]\n"); + m = setFirstItem(modules); + mi = 0; + for (; ; ) + { + if (m == NULL) + break; + + if (our_verbose >= 0) + { + printf(" %d) cfullname:%s, afullname:%s, name:%s\n", ++mi, + m->cfullname, m->afullname, m->name); + printf(" c_name:%s, asm_name:%s, ncLines:%d, nasmLines:%d\n", + m->c_name, m->asm_name, m->ncLines, m->nasmLines); + printf(" cLines:%p, asmLines:%p\n", + m->cLines, m->asmLines); + } + if (our_verbose >= 2) + { + if (m->ncLines) + { + printf(" [cLines] "); + if (our_verbose) + { + for (i = 0; i < m->ncLines; i++) + { + cs = m->cLines[i]; + printf(" (%d) addr:%x, block:%d, level:%d, src:%s\n", + i, cs->addr, cs->block, cs->level, cs->src); + } + } + } + if (m->nasmLines) + { + printf(" [asmLines] "); + if (our_verbose) + { + for (i = 0; i < m->nasmLines; i++) + { + as = m->asmLines[i]; + printf(" (%d) addr:%x, block:%d, level:%d, src:%s\n", + i, as->addr, as->block, as->level, as->src); + } + } + } + printf("\n"); + } + m = setNextItem(modules); + } + return 0; +} + +/*----------------------------------------------------------------- + infoSymbols - This is really just a tool to dump all these + huge program structures out into human readable form. +|-----------------------------------------------------------------*/ +static void infoSymbols(context *ctxt) +{ + int our_verbose = 0; + + printf("[context:%p] func:%p modName:%s addr:%x\n", + ctxt, ctxt->func, ctxt->modName, ctxt->addr); + + printf(" cline:%d asmline:%d block:%d level:%d\n", + ctxt->cline, ctxt->asmline, ctxt->block, ctxt->level); + + printf("[globals] currCtxt:%p, modules:%p, functions:%p symbols:%p\n", + currCtxt, modules, functions, symbols); + printf(" nStructs:%d, structs:%p, ssdirl:%s\n", + nStructs, structs, ssdirl); + + /**************** modules *******************/ + { + module *m; + srcLine *cs, *as; + int i, mi; + printf("[modules]\n"); + m = setFirstItem(modules); + mi = 0; + for (;;) + { + if (m == NULL) + break; + printf(" %d) cfullname:%s, afullname:%s, name:%s\n", ++mi, + m->cfullname, m->afullname, m->name); + printf(" c_name:%s, asm_name:%s, ncLines:%d, nasmLines:%d\n", + m->c_name, m->asm_name, m->ncLines, m->nasmLines); + printf(" cLines:%p, asmLines:%p\n", + m->cLines, m->asmLines); + i = 0; + if (m->cLines) + { + cs = m->cLines[i++]; + printf(" [cLines] "); + while (cs) + { + if (our_verbose) + printf(" (%d) addr:%x, block:%d, level:%d, src:%s\n", + i, cs->addr, cs->block, cs->level, cs->src); + cs = m->cLines[i++]; + } + if (!our_verbose) + printf("%d records", i); + } + i = 0; + if (m->asmLines) + { + as = m->asmLines[i++]; + printf(" [asmLines] "); + while (as) + { + if (our_verbose) + printf(" (%d) addr:%x, block:%d, level:%d, src:%s\n", + i, as->addr, as->block, as->level, as->src); + as = m->asmLines[i++]; + } + if (!our_verbose) + printf("%d records", i); + } + printf("\n"); + + m = setNextItem(modules); + } + } + + /**************** functions *******************/ + { + function *f; + int i; + printf("[functions]\n"); + f = setFirstItem(functions); + i = 0; + for (;;) + { + if (f == NULL) + break; + if (our_verbose) + { + printf(" %d) sym:%p, modName:%s, mod:%p\n", i, + f->sym, f->modName, f->mod); + printf(" entryline:%d, aentryline:%d, exitline:%d, aexitline:%d\n", + f->entryline, f->aentryline, f->exitline, f->aexitline); + printf(" cfpoints:%p, afpoints:%p, laddr:%x, lline:%d\n", + f->cfpoints, f->afpoints, f->laddr, f->lline); + } + ++i; + f = setNextItem(functions); + } + if (!our_verbose) + printf(" %d functions\n", i); + } + + /**************** symbols *******************/ + { + symbol *s; + int i; + printf("[symbols]\n"); + s = setFirstItem(symbols); + i = 0; + for (;;) + { + if (s == NULL) + break; + if (our_verbose) + { + printf(" %d) name:%s, size:%d, level:%d block:%d\n", i, + s->name, s->size, s->level, s->block); + printf(" isonstack:%d, isfunc:%d, offset:%d addr:%d\n", + s->isonstack, s->isfunc, s->offset, s->addr); + printf(" eaddr:%d, addr_type:%c, type:%p etype:%p\n", + s->eaddr, s->addr_type, s->type, s->etype); + printf(" scopetype:%c, sname:%s, rname:%s addrspace:%c\n", + s->scopetype, s->sname, s->rname, s->addrspace); + printf(" next:%p\n", s->next); + } + ++i; + s = setNextItem(symbols); + } + if (!our_verbose) + printf(" %d symbols\n", i); + } + +} + +/*-----------------------------------------------------------------*/ +/* infoRegisters - print register information */ +/*-----------------------------------------------------------------*/ +static void infoRegisters( int all, context *ctxt) +{ + static int regaddrs[] = {0x81,0x82,0x83,0xb8,0xd0,0xe0,0xf0,0}; + unsigned long val; + int i,j,*r; + + i = simGetValue (0xd0,'I',1); + fprintf(stdout,"IP : 0x%04X RegisterBank %d:\nR0-7:",ctxt->addr,(i>>3)&3); + for ( j = 0; j < 8 ; j++ ) + { + val = simGetValue (j,'R',1); + fprintf(stdout," 0x%02lX",val); + } + fprintf(stdout,"\n"); + val = simGetValue (0xe0,'I',1); + fprintf(stdout,"ACC : 0x%02lX %lu %c\n",val,val,(isprint(val) ? (char)val : '.')); + val = simGetValue (0xf0,'I',1); + fprintf(stdout,"B : 0x%02lX %lu %c\n",val,val,(isprint(val) ? (char)val : '.')); + val = simGetValue (0x82,'I',2); + fprintf(stdout,"DPTR: 0x%04lX %lu\n",val,val); + val = simGetValue (0x81,'I',1); + fprintf(stdout,"SP : 0x%02lX (0x%04lX)\n",val,simGetValue (val-1,'B',2)); + fprintf(stdout,"PSW : 0x%02X | CY : %c | AC : %c | OV : %c | P : %c\n", + i,(i&0x80)?'1':'0',(i&0x40)?'1':'0',(i&4)?'1':'0',(i&1)?'1':'0'); + if ( all ) + { + fprintf(stdout,"Special Function Registers:\n"); + r = regaddrs; + for ( i = 0x80 ; i < 0x100 ; i++ ) + { + symbol *sym = NULL; + if ( *r && *r == i ) + { + /* skip normal registers */ + r++ ; + continue; + } + if (applyToSetFTrue(sfrsymbols,symWithAddr,i,'I',&sym)) + { + val = simGetValue (sym->addr,sym->addrspace,sym->size); + fprintf(stdout,"%s : 0x%02lx",sym->name,val); + if ( !(i & 0x07 )) + { + for ( j = 0 ; j < 8 ; j++ ) + { + sym = NULL; + if (applyToSetFTrue(sfrsymbols,symWithAddr,i+j,'J',&sym)) + { + //val = simGetValue (sym->addr,sym->addrspace,sym->size); + fprintf(stdout," %s=%c",sym->name,(val&1)? '1':'0'); + } + val >>= 1; + } + } + fprintf(stdout,"\n"); + } + } + } +} + +/*-----------------------------------------------------------------*/ +/* infoStack - print call stack information */ +/*-----------------------------------------------------------------*/ +static void infoStack(context *ctxt) +{ + function *func ; + int i = 0 ; + + STACK_STARTWALK(callStack) ; + while ((func = STACK_WALK(callStack))) + { + Dprintf(D_break, ("break: infoStack: %s %p (%p)\n",func->sym->name, w_callStack,p_callStack)); + + fprintf(stdout,"#%d 0x%08x in %s () at %s:%d\n",i++, + func->laddr,func->sym->name, + func->mod->c_name,func->lline+1); + } + if ( !i ) + fprintf(stdout,"no stack.\n"); +} + +/*-----------------------------------------------------------------*/ +/* cmdWhere - where command */ +/*-----------------------------------------------------------------*/ +int cmdWhere(char *s, context *cctxt) +{ + infoStack(cctxt); + return 0; +} + + +static int infomode = 0; +/*-----------------------------------------------------------------*/ +/* cmdInfo - info command */ +/*-----------------------------------------------------------------*/ +int cmdInfo (char *s, context *cctxt) +{ + /* trim left and_right*/ + s = trim(s); + + /* list all break points */ + if (strncmp(s,"break",5) == 0) + { + listUSERbp(); + return 0; + } + + /* info frame same as frame */ + if (strncmp(s,"frame",5) == 0) + { + cmdFrame (s+5,cctxt); + return 0; + } + + if (strncmp(s,"line",4) == 0) + { + infomode=1; + cmdListSrc (s+4,cctxt); + return 0; + } + if (strncmp(s,"source",6) == 0) + { + module *m; + if ( s[6] == 's' ) + { + int k = 0; + fprintf(stdout,"Source files for which symbols have been read in:\n\n"); + for (m = setFirstItem(modules); m ; m = setNextItem(modules)) + { + fprintf(stdout,"%s%s, %s",k ? ", ":"",m->cfullname, m->afullname); + k = 1; + } + fprintf(stdout,"\n"); + } + else + { + if (!cctxt || !cctxt->func || !cctxt->func->mod) + { + fprintf(stdout,"No source file loaded\n"); + return 0; + } + m = cctxt->func->mod; + fprintf(stdout,"Current source file is %s\n",m->c_name); + fprintf(stdout,"Located in %s\n",m->cfullname); + fprintf(stdout,"Contains %d lines.\nSource language is c.\n", + m->ncLines); + } + return 0; + } + if (strcmp(s,"functions") == 0) + { + function *f; + module *m = NULL; + fprintf(stdout,"All defined functions:\n"); + for ( f = setFirstItem(functions); f ; f = setNextItem(functions)) + { + if ( f->mod != m ) + { + m = f->mod; + fprintf(stdout,"\nFile %s\n", m->c_name); + } + fprintf(stdout,"%s();\n",f->sym->name); + } + return 0; + } + /* info stack display call stack */ + if (strcmp(s,"stack") == 0) + { + infoStack(cctxt); + showfull = 1; + return 0; + } + + /* info stack display call stack */ + if (strcmp(s,"registers") == 0) + { + infoRegisters(0,cctxt); + return 0; + } + + /* info stack display call stack */ + if (strcmp(s,"all-registers") == 0) + { + infoRegisters(1,cctxt); + return 0; + } + + /* info stack display call stack */ + if (strcmp(s,"symbols") == 0) + { + /* dump out symbols we have read in */ + fprintf(stdout,"Dumping symbols...\n"); + infoSymbols(cctxt); + return 0; + } + + if (strcmp(s,"variables") == 0) + { + /* dump out symbols we have read in */ + fprintf(stdout,"Dumping symbols...\n"); + infoSymbols(cctxt); + return 0; + } + + fprintf(stdout,"Undefined info command: \"%s\". Try \"help\n",s); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdQuit - quit debugging */ +/*-----------------------------------------------------------------*/ +int cmdQuit (char *s, context *cctxt) +{ + if (simactive) + closeSimulator(); + return 1; +} + +/*-----------------------------------------------------------------*/ +/* cmdListSrc - list src */ +/*-----------------------------------------------------------------*/ +int cmdListSrc (char *s, context *cctxt) +{ + static int currline = 0; + int i =0 ; + int pline = 0; + int llines = listlines; + function *func = NULL; + + s = trim_left(s); + + /* if the user has spcified line numer then the line number + can be of the following formats + LINE - just line number + FILE:LINE - filename line number + FILE:LINE,LASTLINE + last line + FUNCTION - list a function + FILE:FUNCTION - function in file */ + + if (*s) + { + /* case a) LINE */ + if (isdigit(*s)) + { + if (!cctxt || !cctxt->func || !cctxt->func->mod) + { + if (!list_mod) + { + fprintf(stdout,"Sdcdb fails to have a proper context at %d.\n", __LINE__); + return 0; + } + } + else + { + list_mod = cctxt->func->mod; + } + pline = strtol(s,&s,10) - 1; + if (s && (s = strchr(s,','))) + { + /* LINE,LASTLINE */ + llines = strtol(s+1,0,10); + if ( llines > 0 ) + llines -= pline+1; + else + llines = listlines; + } + } + else + { + char *bp; + + /* if ':' present then FILE:LINE || FILE:FUNCTION */ + if ((bp = strchr(s,':'))) + { + *bp = '\0'; + bp ++; + if (isdigit(*bp)) + { + /* FILE:LINE */ + list_mod=NULL; /* bug fix 2-09-02, moduleWithCName expects mod to be null */ + if (srcMode == SRC_CMODE) + { + if (!applyToSet(modules,moduleWithCName,s,&list_mod)) + { + fprintf (stderr,"No c source file named %s.\n",s); + return 0; + } + } + else + { + if (!applyToSet(modules,moduleWithAsmName,s,&list_mod)) + { + fprintf (stderr,"No source file named %s.\n",s); + return 0; + } + } + pline = strtol(bp,&bp,10) - 1; + if (bp && (bp = strchr(bp,','))) + { + /* FILE:LINE,LASTLINE */ + llines = strtol(bp+1,0,10); + if ( llines > 0 ) + llines -= pline+1; + else + llines = listlines; + } + } + else + { + /* FILE:FUCTION */ + if (!applyToSet(functions,funcWithNameModule,bp,s,&func)) + { + fprintf(stdout,"Function \"%s\" not defined.\n",bp); + return 0; + } + list_mod = func->mod; + if (srcMode == SRC_CMODE) + { + pline = func->entryline; + llines = func->exitline - func->entryline + 1; + } + else + { + pline = func->aentryline; + llines = func->aexitline - func->aentryline + 1; + } + } + } + else + { + /* FUNCTION */ + if (*s == '\'') + { + /* 'FUNCTION' */ + s++; + if ((bp = strrchr(s,'\''))) + { + *bp = '\0'; + } + } + if (!applyToSet(functions,funcWithName,s,&func)) + { + fprintf(stderr,"Function \"%s\" not defined.\n",s); + return 0; + } + else + { + list_mod = func->mod; + if (srcMode == SRC_CMODE) + { + pline = func->entryline; + llines = func->exitline - func->entryline + 1; + } + else + { + pline = func->aentryline; + llines = func->aexitline - func->aentryline + 1; + } + } + } + } + } + else + { + /* if no line specified & we had listed + before then continue from that listing */ + if (currline) + pline = currline; + else + { + if (!cctxt || !cctxt->func || !cctxt->func->mod) + { + fprintf(stdout,"Missing context at %d. Try list filename:lineno\n", __LINE__); + return 0; + } + list_mod = cctxt->func->mod; + if (srcMode == SRC_CMODE) + pline = cctxt->cline; + else + pline = cctxt->asmline; + } + } + + if (!list_mod) + { + fprintf(stdout,"Sdcdb fails to have a valid module context at %d.\n", __LINE__); + return 0; + } + + if ( pline < 0 ) + return 0; + if ( infomode ) + { + unsigned firstaddr, lastaddr; + + if (pline >= list_mod->ncLines) + { + if (!cctxt) + { + fprintf(stdout, "Missing context at %d. Try list filename:lineno\n", __LINE__); + return 0; + } + else + { + pline = cctxt->cline; + } + } + + firstaddr = lastaddr = list_mod->cLines[pline]->addr; + if (!func && cctxt && cctxt->func ) + func = cctxt->func; + fprintf(stdout,"Line %d of \"%s\" starts at address 0x%08x <%s+%d>", + pline+1, + list_mod->c_name, lastaddr, + func ? func->sym->name : "?", + func ? lastaddr -func->sym->addr : 0); + llines = pline +1; + for ( ; pline < list_mod->ncLines; pline++ ) + { + if ( list_mod->cLines[pline]->addr > lastaddr ) + { + lastaddr = list_mod->cLines[pline]->addr -1; + break; + } + } + fprintf(stdout," and ends at 0x%08x <%s+%d>.\n", + lastaddr, + func ? func->sym->name : "?", + func ? lastaddr -func->sym->addr : 0); + infomode=0; + if ( func ) + fprintf(stdout,"\032\032%s:%d:1:beg:0x%08x\n", + func->mod->cfullname, + llines,firstaddr); + else + showfull=1; + return 0; + } + for ( i = 0 ; i < llines ; i++ ) + { + if (srcMode == SRC_CMODE) + { + if ( (pline + i) >= list_mod->ncLines ) + break; + fprintf(stdout,"%d\t%s",pline + i, + list_mod->cLines[pline +i]->src); + } + else + { + if ( (pline + i) >= list_mod->nasmLines ) + break; + fprintf(stdout,"%d\t%s",pline + i, + list_mod->asmLines[pline +i]->src); + } + } + currline = pline + i ; + return 0; +} + +static unsigned long getValBasic(symbol *sym, st_link *type, char *val) +{ + char *s; + union + { + float f; + unsigned long val; + long sval; + struct + { + unsigned short lo; + unsigned short hi; + } i; + unsigned char b[4]; + } v; + + if (IS_FLOAT(type)) + { + v.f = (float)strtod(val,NULL); + } + else if (IS_PTR(type)) + { + v.val = strtol(val,NULL,0); + } + else if (IS_INTEGRAL(type)) + { + st_link *etype; + if ( type->next ) + etype = type->next; + else + etype = type; + + if (IS_CHAR(etype)) + { + if (( s = strchr(val,'\''))) + { + if ( s[1] == '\\' ) + v.b[0] = (unsigned char)strtol(s+2,NULL,8); + else + v.b[0] = s[1]; + } + else + { + v.b[0] = (unsigned char)strtol(val,NULL,0); + } + } + else if (IS_INT(etype)) + { + if (IS_LONG(etype)) + v.val = strtol(val,NULL,0); + else + v.i.lo = (unsigned short)strtol(val,NULL,0); + } + else + { + v.val = strtol(val,NULL,0); + } + } + else + { + v.val = strtol(val,NULL,0); + } + return v.val; +} + +/*-----------------------------------------------------------------*/ +/* printFmtInteger - print value in bin,oct,dez or hex */ +/*-----------------------------------------------------------------*/ +static void printFmtInteger(char *deffmt,int fmt, long val, + int sign, int size) +{ + static char digits[] = + { + '0' , '1' , '2' , '3' , '4' , '5' , + '6' , '7' , '8' , '9' , 'a' , 'b' , + 'c' , 'd' , 'e' , 'f' , 'g' , 'h' + }; + static int radixOfFormat[] = { 0 , 2, 8 ,10, 16 }; + static int olenOfSize[] = { 0 , 3, 6 , 8, 11 }; + char buf[40]; + char negative = 0; + int charPos = 38; + int radix; + + if ( fmt == FMT_NON || fmt == FMT_DEZ ) + { + fprintf(stdout,deffmt,val); + return; + } + radix = radixOfFormat[fmt]; + + /* + if ( sign && val < 0 ) + negative = 1; + */ + + if (!negative) + val = -val; + + buf[39] = '\0'; + while (val <= -radix) + { + buf[charPos--] = digits[-(val % radix)]; + val = val / radix; + } + buf[charPos] = digits[-val]; + + switch ( fmt ) + { + case FMT_OCT: + radix = olenOfSize[size]; + break; + case FMT_HEX: + radix = size << 1; + break; + case FMT_BIN: + radix = size << 3; + break; + } + + while (charPos > 39 - radix ) + { + buf[--charPos] = '0'; + } + switch ( fmt ) + { + case FMT_OCT: + if ( buf[charPos] != '0' ) + buf[--charPos] = '0'; + break; + case FMT_HEX: + buf[--charPos] = 'x'; + buf[--charPos] = '0'; + break; + } + if (negative) + { + buf[--charPos] = '-'; + } + fputs(&buf[charPos],stdout); +} + +/*-----------------------------------------------------------------*/ +/* printValBasic - print value of basic types */ +/*-----------------------------------------------------------------*/ +static void printValBasic(symbol *sym, st_link *type, + char mem, unsigned addr,int size, int fmt) +{ + union + { + float f; + unsigned long val; + long sval; + struct + { + unsigned short lo; + unsigned short hi; + } i; + unsigned char b[4]; + } v; + + v.val = simGetValue(addr,mem,size); + /* if this a floating point number then */ + if (IS_FLOAT(type)) + { + fprintf(stdout, "%f", v.f); + } + else if (IS_PTR(type)) + { + fprintf(stdout, "0x%*lx", size<<1, v.val); + } + else if (IS_INTEGRAL(type)) + { + st_link *etype; + if ( type->next ) + etype = type->next; + else + etype = type; + if (IS_CHAR(etype)) + { + if ( isprint(v.val)) + printFmtInteger((SPEC_USIGN(etype)?"0x%02x":"'%c'"), + fmt, (long)v.val, 0, size); + else + printFmtInteger((SPEC_USIGN(etype)?"0x%02x":"'\\%o'"), + fmt, (long)v.val, 0, size); + } + else if (IS_INT(etype)) + { + if (IS_LONG(etype)) + if (SPEC_USIGN(etype)) + printFmtInteger("%u", fmt, (long)v.val,0, size); + else + printFmtInteger("%d", fmt, (long)v.sval,1, size); + else + if (SPEC_USIGN(etype)) + printFmtInteger("%u", fmt, (long)v.i.lo,0, size); + else + printFmtInteger("%d", fmt, (long)v.i.lo,1, size); + } + else if (IS_BITVAR(etype)) + { + fprintf(stdout, "%c", (v.val?'1':'0')); + } + else + { + fprintf(stdout, "0x%0*lx", size<<1, v.val); + } + } + else + { + fprintf(stdout, "0x%0*lx", size<<1, v.val); + } +} + +/*-----------------------------------------------------------------*/ +/* printValFunc - prints function values */ +/*-----------------------------------------------------------------*/ +static void printValFunc (symbol *sym, int fmt) +{ + fprintf(stdout,"print function not yet implemented"); +} + +/*-----------------------------------------------------------------*/ +/* printArrayValue - will print the values of array elements */ +/*-----------------------------------------------------------------*/ +static void printArrayValue (symbol *sym, st_link *type, + char space, unsigned int addr, int fmt) +{ + st_link *elem_type = type->next; + int i; + + fprintf(stdout,"{"); + for (i = 0 ; i < DCL_ELEM(type) ; i++) + { + if (IS_AGGREGATE(elem_type)) + { + printValAggregates(sym,elem_type,space,addr,fmt); + } + else + { + printValBasic(sym,elem_type,space,addr,getSize(elem_type),fmt); + } + addr += getSize(elem_type); + if (i != DCL_ELEM(type) -1) + fprintf(stdout,","); + } + + fprintf(stdout,"}"); +} + +/*-----------------------------------------------------------------*/ +/* printStructValue - prints structures elements */ +/*-----------------------------------------------------------------*/ +static void printStructValue (symbol *sym, st_link *type, + char space, unsigned int addr, int fmt) +{ + symbol *fields = SPEC_STRUCT(type)->fields; + int first = 1; + + fprintf(stdout," { "); + while (fields) + { + fprintf(stdout,"%s%s = ",(first ? "": ", "),fields->name); + first = 0; + if (IS_AGGREGATE(fields->type)) + { + printValAggregates(fields,fields->type,space, addr, fmt); + } + else + { + printValBasic(fields,fields->type,space,addr,getSize(fields->type), fmt); + } + addr += getSize(fields->type); + fields = fields->next; + } + fprintf(stdout,"}"); +} + +/*-----------------------------------------------------------------*/ +/* printValAggregates - print value of aggregates */ +/*-----------------------------------------------------------------*/ +static void printValAggregates (symbol *sym, st_link *type, + char space,unsigned int addr, int fmt) +{ + if (IS_ARRAY(type)) + { + printArrayValue(sym, type, space, addr, fmt); + return; + } + + if (IS_STRUCT(type)) + { + printStructValue(sym, type, space, addr, fmt); + return; + } +} + +/*-----------------------------------------------------------------*/ +/* printOrSetSymValue - print or set value of a symbol */ +/*-----------------------------------------------------------------*/ +static int printOrSetSymValue (symbol *sym, context *cctxt, + int flg, int dnum, int fmt, char *rs, + char *val, char cmp ) +{ + static char fmtChar[] = " todx "; + static int stack = 1; + symbol *fields; + st_link *type; + unsigned int addr, size; + int n; + char *s, *s2; + char save_ch, save_ch2; + + /* if it is on stack then compute address & fall thru */ + if (sym->isonstack) + { + symbol *bp = symLookup("bp",cctxt); + if (!bp) + { + fprintf(stdout,"cannot determine stack frame\n"); + return 1; + } + + sym->addr = simGetValue(bp->addr,bp->addrspace,bp->size) + sym->offset; + } + + /* get the value from the simulator and print it */ + switch (flg) + { + case 0: + default: + break; + case 1: + fprintf(stdout,"$%d = ",stack++); + break; + case 2: + fprintf(stdout,"%d: ", dnum); + if ( fmt != FMT_NON ) + fprintf(stdout,"/%c ",fmtChar[fmt]); + fprintf(stdout,"%s%s = ",sym->name,rs); + break; + } + + addr = sym->addr; + type = sym->type; + size = sym->size; + + while ( *rs ) + { + if ( *rs == '[' && IS_ARRAY(type)) + { + s = rs+1; + while ( *rs && *rs != ']' ) + rs++; + save_ch = *rs; + *rs = '\0' ; + if ( ! isdigit(*s )) + { + /* index seems a variable */ + for ( s2 = s; *s2 && ( isalnum( *s2 ) || *s2 == '_'); s2++ ); + save_ch2 = *s2; + if ( *s2 ) + *s2 = '\0'; + fields = symLookup(s,cctxt); + *s2 = save_ch2; + if ( ! fields ) + { + fprintf(stdout,"Unknown variable \"%s\" for index.\n", s); + return 1; + } + /* arrays & structures first */ + if (! IS_INTEGRAL(fields->type)) + { + fprintf(stdout,"Wrong type of variable \"%s\" for index \n", s); + return 1; + } + n = simGetValue(fields->addr,fields->addrspace,getSize(fields->type)); + } + else + { + n = strtol(s,0,0); + } + if ( n < 0 || n >= DCL_ELEM(type)) + { + fprintf(stdout,"Wrong index %d.\n", n); + return 1; + } + type = type->next; + size = getSize(type); + addr += size * n; + *rs++ = save_ch; + } + else if ( *rs == '.' && IS_STRUCT(type)) + { + s = rs+1; + /* search structure element */ + for ( rs = s; *rs && ( isalnum( *rs ) || *rs == '_'); rs++ ); + save_ch = *rs; + if ( *rs ) + *rs = '\0'; + for (fields = SPEC_STRUCT(type)->fields; fields; fields = fields->next) + { + if (!(strcmp(s,fields->name))) + break; + } + *rs = save_ch; + if ( ! fields ) + { + fprintf(stdout,"Unknown field \"%s\" of structure\n", s); + return 1; + } + type = fields->type; + size = getSize(type); + addr += fields->offset; + } + else + { + break; + } + } + + if (IS_AGGREGATE(type)) /* arrays & structures first */ + { + if ( val ) + { + fprintf(stdout,"Cannot set/compare aggregate variable\n"); + return 1; + } + else + { + printValAggregates(sym,type,sym->addrspace,addr,fmt); + } + } + else if (IS_FUNC(type)) /* functions */ + { + if ( !val ) + printValFunc(sym,fmt); + else + return 1; + } + else + { + if ( val ) + { + unsigned long newval; + newval = getValBasic(sym,type,val); + + if ( cmp ) + { + unsigned long lval; + lval = simGetValue(addr,sym->addrspace,size); + switch ( cmp ) + { + case '<' : return ( lval < newval ? 1:0 ); break; + case '>' : return ( lval > newval ? 1:0 ); break; + case 'l' : return ( lval <= newval ? 1:0 ); break; + case 'g' : return ( lval >= newval ? 1:0 ); break; + case '=' : return ( lval == newval ? 1:0 ); break; + case '!' : return ( lval != newval ? 1:0 ); break; + } + } + else + { + if ( sym->addrspace == 'I' && addr == 0xb8 ) + { + /* Symbol with address of IP */ + if ( cctxt ) + cctxt->addr = newval; + simSetPC(cctxt->addr); + } + else + { + simSetValue(addr,sym->addrspace,size,newval); + } + return 1; + } + } + else + { + printValBasic(sym,type,sym->addrspace,addr,size,fmt); + } + } + if ( flg > 0 ) fprintf(stdout,"\n"); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* printStructInfo - print out structure information */ +/*-----------------------------------------------------------------*/ +static void printStructInfo (structdef *sdef) +{ + symbol *field = sdef->fields ; + int i = 0 ; + + while (field) + { + i += field->offset; + field = field->next; + } + + fprintf(stdout,"%s %s {\n",(i ? "struct" : "union" ), sdef->tag); + field = sdef->fields; + while (field) + { + printTypeInfo (field->type); + fprintf(stdout," %s ;\n",field->name); + field = field->next ; + } + + fprintf(stdout,"}\n"); +} + +/*-----------------------------------------------------------------*/ +/* printTypeInfo - print out the type information */ +/*-----------------------------------------------------------------*/ +static void printTypeInfo(st_link *p) +{ + if (!p) + return; + + if (IS_DECL(p)) + { + switch (DCL_TYPE(p)) + { + case FUNCTION: + printTypeInfo (p->next); + fprintf(stdout,"()"); + break; + case ARRAY: + printTypeInfo (p->next); + fprintf(stdout,"[%d]",DCL_ELEM(p)); + break; + + case IPOINTER: + case PPOINTER: + case POINTER: + printTypeInfo (p->next); + fprintf(stdout,"(_near *)"); + break; + + case FPOINTER: + printTypeInfo (p->next); + fprintf(stdout,"(_xdata *)"); + break; + + case CPOINTER: + printTypeInfo( p->next); + fprintf(stdout,"(_code *)"); + break; + + case GPOINTER: + printTypeInfo( p->next); + fprintf(stdout,"(_generic *)"); + break; + } + } + else + { + switch (SPEC_NOUN(p)) /* depending on the specifier type */ + { + case V_INT: + (IS_LONG(p) ? fputs("long ",stdout) : + ( IS_SHORT(p) ? fputs("short ",stdout) : + fputs("int ",stdout))) ; + break; + case V_FLOAT: + fputs("float ",stdout); + break; + + case V_CHAR: + fputs ("char ",stdout); + break; + + case V_VOID: + fputs("void ",stdout); + break; + + case V_STRUCT: + printStructInfo (SPEC_STRUCT(p)); + break; + + case V_SBIT: + fputs("sbit ",stdout); + break; + + case V_BIT: + fprintf(stdout,": %d" ,SPEC_BLEN(p)); + break; + } + } +} + +/*-----------------------------------------------------------------*/ +/* conditionIsTrue - compare variable with constant value */ +/*-----------------------------------------------------------------*/ +int conditionIsTrue( char *s, context *cctxt) +{ + symbol *sym = NULL; + int fmt; + char *rs, *dup, cmp_char; + dup = s = Safe_strdup(s); + if ( !( rs = preparePrint(s, cctxt, &fmt, &sym )) || !sym) + fmt = 1; + else if (!( s = strpbrk(rs,"<>=!"))) + fmt = 1; + else + { + cmp_char = *s; + *s++ = '\0'; + if ( *s == '=' ) + { + /* if <= or >= an other char is used + * == or != not checked in switch + */ + switch( cmp_char ) + { + case '>': cmp_char = 'g' ; break; + case '<': cmp_char = 'l' ; break; + } + s++; + } + s = trim_left(s); + fmt = printOrSetSymValue(sym,cctxt,0,0,0,rs,s,cmp_char); + } + Safe_free(dup); + return fmt; +} + +/*-----------------------------------------------------------------*/ +/* cmdPrint - print value of variable */ +/*-----------------------------------------------------------------*/ +int cmdPrint (char *s, context *cctxt) +{ + symbol *sym ; + int fmt; + char *rs; + if ( !( rs = preparePrint(s, cctxt, &fmt, &sym ))) + return 0; + + if ( sym ) + { + printOrSetSymValue(sym,cctxt,1,0,fmt,rs,NULL,'\0'); + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdOutput - print value of variable without number and newline */ +/*-----------------------------------------------------------------*/ +int cmdOutput (char *s, context *cctxt) +{ + symbol *sym ; + int fmt; + char *rs; + if ( !( rs = preparePrint(s, cctxt, &fmt, &sym ))) + return 0; + + if ( sym ) + { + printOrSetSymValue(sym,cctxt,0,0,fmt,rs,NULL,'\0'); + } + return 0; +} + +/** find display entry with this number */ + +DEFSETFUNC(dsymWithNumber) +{ + dsymbol *dsym = item; + V_ARG(int , dnum); + V_ARG(dsymbol **,dsymp); + + if ( dsym->dnum == dnum ) + { + *dsymp = dsym; + return 1; + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* displayAll - display all valid variables */ +/*-----------------------------------------------------------------*/ +void displayAll(context *cctxt) +{ + dsymbol *dsym; + symbol *sym; + if ( !dispsymbols ) + return; + for (dsym = setFirstItem(dispsymbols); + dsym ; + dsym = setNextItem(dispsymbols)) + { + if ( (sym = symLookup(dsym->name,cctxt))) + printOrSetSymValue(sym,cctxt,2,dsym->dnum,dsym->fmt, + dsym->rs,NULL,'\0'); + } +} + +/*-----------------------------------------------------------------*/ +/* cmdDisplay - display value of variable */ +/*-----------------------------------------------------------------*/ +int cmdDisplay (char *s, context *cctxt) +{ + static int dnum = 1; + symbol *sym ; + int fmt; + char *rs; + if ( !( rs = preparePrint(s, cctxt, &fmt, &sym ))) + { + displayAll(cctxt); + return 0; + } + + if ( sym ) + { + dsymbol *dsym = (dsymbol *)Safe_calloc(1,sizeof(dsymbol)); + dsym->dnum = dnum++ ; + dsym->name = sym->name; + dsym->fmt = fmt; + dsym->rs = gc_strdup(rs); + addSetHead(&dispsymbols,dsym); + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdUnDisplay - undisplay value of variable */ +/*-----------------------------------------------------------------*/ +int cmdUnDisplay (char *s, context *cctxt) +{ + dsymbol *dsym; + int dnum; + + s = trim_left(s); + if (!*s) + { + for (dsym = setFirstItem(dispsymbols); + dsym; + dsym = setNextItem(dispsymbols)) + { + Safe_free(dsym->rs); + Safe_free(dsym); + } + deleteSet(&dispsymbols); + return 0; + } + while ( s && *s ) + { + dnum = strtol(s,&s,10); + if (applyToSetFTrue(dispsymbols,dsymWithNumber,dnum,&dsym)) + { + deleteSetItem(&dispsymbols,dsym); + Safe_free(dsym->rs); + Safe_free(dsym); + } + else + { + fprintf(stdout,"Arguments must be display numbers.\n"); + } + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdPrintType - print type of a variable */ +/*-----------------------------------------------------------------*/ +int cmdPrintType (char *s, context *cctxt) +{ + symbol *sym; + + /* trim left and right */ + s = trim(s); + if (!*s) + return 0; + + if ((sym = symLookup(s,cctxt))) + { + printTypeInfo(sym->type); + fprintf(stdout,"\n"); + } + else + { + fprintf(stdout, + "No symbol \"%s\" in current context.\n", + s); + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdClrUserBp - clear user break point */ +/*-----------------------------------------------------------------*/ +int cmdClrUserBp (char *s, context *cctxt) +{ + char *bp ; + function *func = NULL; + + /* clear break point location specification can be of the following + forms + a) <nothing> - break point at current location + b) lineno - number of the current module + c) filename:lineno - line number of the given file + e) filename:function- function X in file Y (useful for static functions) + f) function - function entry point + */ + + if (!cctxt) + { + fprintf(stdout,"No symbol table is loaded. Use the \"file\" command.\n"); + return 0; + } + + /* trim left and right */ + s = trim(s); + + /* case a) nothing */ + /* if nothing given then current location : we know + the current execution location from the currentContext */ + if (! *s ) + { + /* if current context is known */ + if (cctxt->func) + /* clear the break point @ current location */ + clearUSERbp (cctxt->addr); + else + fprintf(stderr,"No default breakpoint address now.\n"); + + goto ret ; + } + + /* case b) lineno */ + /* check if line number */ + if (isdigit(*s)) + { + /* get the lineno */ + int line = atoi(s); + + /* if current context not present then we must get the module + which has main & set the break point @ line number provided + of that module : if current context known then set the bp + at the line number given for the current module + */ + if (cctxt->func) + { + if (!cctxt->func->mod) + { + if (!applyToSet (functions, funcWithName, "main", &func)) + fprintf(stderr,"Function \"main\" not defined.\n"); + else + clearBPatModLine(func->mod,line); + } + else + { + clearBPatModLine(cctxt->func->mod,line); + } + } + + goto ret; + } + + if ((bp = strchr(s,':'))) + { + module *mod = NULL; + *bp = '\0'; + + if (!applyToSet(modules,moduleWithCName,s,&mod)) + { + fprintf (stderr,"No source file named %s.\n",s); + goto ret; + } + + /* case c) filename:lineno */ + if (isdigit(*(bp +1))) + { + clearBPatModLine (mod,atoi(bp+1)); + goto ret; + } + /* case d) filename:function */ + if (!applyToSet(functions,funcWithNameModule,bp+1,s,&func)) + fprintf(stderr,"Function \"%s\" not defined.\n",bp+1); + else + clearBPatModLine (mod,func->entryline); + + goto ret; + } + + /* case e) function */ + if (!applyToSet(functions,funcWithName,s,&func)) + fprintf(stderr,"Function \"%s\" not defined.\n",s); + else + clearBPatModLine(func->mod,func->entryline); + +ret: + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdSimulator - send command to simulator */ +/*-----------------------------------------------------------------*/ +int cmdSimulator (char *s, context *cctxt) +{ + char tmpstr[82]; + + if (strlen(s) > 80) + { + printf("error 3A\n"); + exit(1); + } + strcpy(tmpstr, s); + strcat(tmpstr, "\n"); + sendSim(tmpstr); + waitForSim(200, NULL); + fprintf(stdout, "%s", simResponse()); + return 0; +} + +void setMainContext() +{ + function *func = NULL; + currentFrame = 0; + if (!applyToSet(functions, funcWithName, "_main", &func) && + !applyToSet(functions, funcWithName, "main", &func)) + { + return; + } + discoverContext (func->sym->addr, func); +} + +function *needExtraMainFunction() +{ + function *func = NULL; + if (!applyToSet(functions, funcWithName, "_main", &func)) + { + if (applyToSet(functions, funcWithName, "main", &func)) + { + return func; + } + } + return NULL; +} + +static void printFrame() +{ + int i; + function *func = NULL; + + if ( currentFrame < 0 ) + { + currentFrame = 0; + fprintf(stdout,"Bottom (i.e., innermost) frame selected; you cannot go down.\n"); + return; + } + STACK_STARTWALK(callStack) ; + for ( i = 0; i <= currentFrame ; i++ ) + { + func = STACK_WALK(callStack); + if ( !func ) + { + currentFrame = i-1; + fprintf(stdout,"Initial frame selected; you cannot go up.\n"); + return; + } + } + fprintf(stdout,"#%d 0x%08x in %s () at %s:%d\n", + currentFrame,func->laddr,func->sym->name,func->mod->c_name,func->lline+1); + fprintf(stdout,"\032\032%s:%d:1:beg:0x%08x\n", + func->mod->cfullname,func->lline+1,func->laddr); + + discoverContext (func->laddr, func); +} + + +/*-----------------------------------------------------------------*/ +/* cmdUp - Up command */ +/*-----------------------------------------------------------------*/ +int cmdUp(char *s, context *cctxt) +{ + s = trim_left(s); + if ( *s ) + currentFrame += strtol(s,0,10); + else + currentFrame++ ; + + printFrame(); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdDown - down command */ +/*-----------------------------------------------------------------*/ +int cmdDown(char *s, context *cctxt) +{ + s = trim_left(s); + if ( *s ) + currentFrame -= strtol(s,0,10); + else + currentFrame-- ; + + printFrame(); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdFrame - Frame command */ +/*-----------------------------------------------------------------*/ +int cmdFrame (char *s, context *cctxt) +{ + s = trim_left(s); + if ( *s ) + currentFrame = strtol(s,0,10); + printFrame(); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdFinish - exec till end of current function */ +/*-----------------------------------------------------------------*/ +int cmdFinish (char *s, context *ctxt) +{ + if (STACK_EMPTY(callStack)) + { + fprintf(stdout,"The program is not running.\n"); + return 0; + } + + if (srcMode == SRC_CMODE) + { + setBreakPoint (ctxt->func->sym->eaddr, CODE, STEP, + stepBpCB, ctxt->func->mod->c_name, + ctxt->func->exitline); + } + else + { + setBreakPoint (ctxt->func->sym->eaddr, CODE, STEP, + stepBpCB, ctxt->func->mod->asm_name, + ctxt->func->aexitline); + } + + simGo(-1); + showfull = 1; + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdShow - show command */ +/*-----------------------------------------------------------------*/ +int cmdShow (char *s, context *cctxt) +{ + /* skip white space */ + s = trim_left(s); + + if (strcmp(s,"copying") == 0) + { + fputs(copying,stdout); + return 0; + } + + if (strcmp(s,"warranty") == 0) + { + fputs(warranty,stdout); + return 0; + } + + return 0; +} diff --git a/debugger/mcs51/cmd.h b/debugger/mcs51/cmd.h new file mode 100644 index 0000000..41a46eb --- /dev/null +++ b/debugger/mcs51/cmd.h @@ -0,0 +1,73 @@ +/*------------------------------------------------------------------------- + cmd.h - header file for debugger command execution + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SDCDB_CMD_H +#define SDCDB_CMD_H +/* forward definition for command functions */ +extern int cmdSetTmpUserBp (char *, context *); +extern int cmdSetUserBp (char *, context *); +extern int cmdClrUserBp (char *, context *); +extern int cmdHelp (char *, context *); +extern int cmdJump (char *, context *); +extern int cmdListSrc (char *, context *); +extern int cmdListAsm (char *, context *); +extern int cmdSetOption (char *, context *); +extern int cmdCondition (char *, context *); +extern int cmdIgnore (char *, context *); +extern int cmdContinue (char *, context *); +extern int cmdDelUserBp (char *, context *); +extern int cmdStep (char *, context *); +extern int cmdRun (char *, context *); +extern int cmdNext (char *, context *); +extern int cmdPrint (char *, context *); +extern int cmdFrame (char *, context *); +extern int cmdSimulator (char *, context *); +extern int cmdQuit (char *, context *); +extern int cmdPrintType (char *, context *); +extern int cmdFile (char *, context *); +extern int cmdInfo (char *, context *); +extern int cmdShow (char *, context *); +extern int cmdFinish (char *, context *); +extern int cmdCommands (char *, context *); +extern int cmdStepi (char *, context *); +extern int cmdNexti (char *, context *); +extern int cmdUp (char *, context *); +extern int cmdDown (char *, context *); +extern int cmdWhere (char *, context *); +extern int cmdOutput (char *, context *); +extern int cmdDisasm1 (char *, context *); +extern int cmdDisasmF (char *, context *); +extern int cmdDisplay (char *, context *); +extern int cmdUnDisplay (char *, context *); +extern int cmdSource (char *, context *); +extern void displayAll (context *); + +extern int cmdListModules (char *s, context *cctxt); +extern int cmdListFunctions (char *s, context *cctxt); +extern int cmdListSymbols (char *s, context *cctxt); + +extern void setMainContext( void); +extern function *needExtraMainFunction(void); +int conditionIsTrue( char *s, context *cctxt); + +#endif diff --git a/debugger/mcs51/conf.mk b/debugger/mcs51/conf.mk new file mode 100644 index 0000000..ac65f24 --- /dev/null +++ b/debugger/mcs51/conf.mk @@ -0,0 +1,10 @@ +# +# Makefile targets to remake configuration +# + +freshconf: Makefile + +Makefile: $(srcdir)/Makefile.in $(top_srcdir)/configure.in + cd $(top_builddir) && $(SHELL) ./config.status + +# End of conf.mk diff --git a/debugger/mcs51/config.h b/debugger/mcs51/config.h new file mode 100644 index 0000000..a286450 --- /dev/null +++ b/debugger/mcs51/config.h @@ -0,0 +1,77 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* XXX */ +#define DATADIR "/usr/local/share" + +/* XXX */ +#define DIR_SEPARATOR_STRING "/" + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `nsl' library (-lnsl). */ +#define HAVE_LIBNSL 1 + +/* Readline */ +#define HAVE_LIBREADLINE -1 + +/* Define to 1 if you have the `socket' library (-lsocket). */ +/* #undef HAVE_LIBSOCKET */ + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the <sys/socket.h> header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <sys/wait.h> header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the <winsock2.h> header file. */ +/* #undef HAVE_WINSOCK2_H */ + +/* XXX */ +#define LIB_DIR_SUFFIX DIR_SEPARATOR_STRING "sdcc/lib" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 diff --git a/debugger/mcs51/config.h.in b/debugger/mcs51/config.h.in new file mode 100644 index 0000000..1fb3dca --- /dev/null +++ b/debugger/mcs51/config.h.in @@ -0,0 +1,76 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* XXX */ +#undef DATADIR + +/* XXX */ +#undef DIR_SEPARATOR_STRING + +/* Define to 1 if you have the <inttypes.h> header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `nsl' library (-lnsl). */ +#undef HAVE_LIBNSL + +/* Readline */ +#undef HAVE_LIBREADLINE + +/* Define to 1 if you have the `socket' library (-lsocket). */ +#undef HAVE_LIBSOCKET + +/* Define to 1 if you have the <memory.h> header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the <stdint.h> header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the <stdlib.h> header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the <strings.h> header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the <string.h> header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the <sys/socket.h> header file. */ +#undef HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the <sys/types.h> header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the <sys/wait.h> header file. */ +#undef HAVE_SYS_WAIT_H + +/* Define to 1 if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the <winsock2.h> header file. */ +#undef HAVE_WINSOCK2_H + +/* XXX */ +#undef LIB_DIR_SUFFIX + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS diff --git a/debugger/mcs51/config.log b/debugger/mcs51/config.log new file mode 100644 index 0000000..d5daaa4 --- /dev/null +++ b/debugger/mcs51/config.log @@ -0,0 +1,630 @@ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by configure, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ ./configure --disable-option-checking --prefix=/usr/local --disable-mcs51-port --disable-z80-port --disable-z180-port --disable-r2k-port --disable-r3ka-port --disable-gbz80-port --disable-tlcs90-port --disable-ez80_z80-port --disable-ds390-port --disable-ds400-port --disable-pic14-port --disable-pic16-port --disable-hc08-port --disable-s08-port --disable-pdk13-port --disable-pdk14-port --disable-pdk15-port --enable-pdk16-port --disable-ucsim --disable-device-lib --disable-packihx --disable-pdk16-port docdir=${datarootdir}/doc/${PACKAGE} --cache-file=/dev/null --srcdir=. + +## --------- ## +## Platform. ## +## --------- ## + +hostname = xavier-asus +uname -m = x86_64 +uname -r = 4.15.0-65-generic +uname -s = Linux +uname -v = #74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019 + +/usr/bin/uname -p = unknown +/bin/uname -X = unknown + +/bin/arch = unknown +/usr/bin/arch -k = unknown +/usr/convex/getsysinfo = unknown +/usr/bin/hostinfo = unknown +/bin/machine = unknown +/usr/bin/oslevel = unknown +/bin/universe = unknown + +PATH: /home/xavier/.cargo/bin +PATH: /home/xavier/.local/bin +PATH: /usr/local/sbin +PATH: /usr/local/bin +PATH: /usr/sbin +PATH: /usr/bin +PATH: /sbin +PATH: /bin +PATH: /usr/games +PATH: /usr/local/games +PATH: /snap/bin +PATH: /usr/local/xtensa-esp32-elf/bin + + +## ----------- ## +## Core tests. ## +## ----------- ## + +configure:2100: checking for gcc +configure:2116: found /usr/bin/gcc +configure:2127: result: gcc +configure:2356: checking for C compiler version +configure:2365: gcc --version >&5 +gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0 +Copyright (C) 2017 Free Software Foundation, Inc. +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +configure:2376: $? = 0 +configure:2365: gcc -v >&5 +Using built-in specs. +COLLECT_GCC=gcc +COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper +OFFLOAD_TARGET_NAMES=nvptx-none +OFFLOAD_TARGET_DEFAULT=1 +Target: x86_64-linux-gnu +Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.4.0-1ubuntu1~18.04.1' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu +Thread model: posix +gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1) +configure:2376: $? = 0 +configure:2365: gcc -V >&5 +gcc: error: unrecognized command line option '-V' +gcc: fatal error: no input files +compilation terminated. +configure:2376: $? = 1 +configure:2365: gcc -qversion >&5 +gcc: error: unrecognized command line option '-qversion'; did you mean '--version'? +gcc: fatal error: no input files +compilation terminated. +configure:2376: $? = 1 +configure:2396: checking whether the C compiler works +configure:2418: gcc conftest.c >&5 +configure:2422: $? = 0 +configure:2470: result: yes +configure:2473: checking for C compiler default output file name +configure:2475: result: a.out +configure:2481: checking for suffix of executables +configure:2488: gcc -o conftest conftest.c >&5 +configure:2492: $? = 0 +configure:2514: result: +configure:2536: checking whether we are cross compiling +configure:2544: gcc -o conftest conftest.c >&5 +configure:2548: $? = 0 +configure:2555: ./conftest +configure:2559: $? = 0 +configure:2574: result: no +configure:2579: checking for suffix of object files +configure:2601: gcc -c conftest.c >&5 +configure:2605: $? = 0 +configure:2626: result: o +configure:2630: checking whether we are using the GNU C compiler +configure:2649: gcc -c conftest.c >&5 +configure:2649: $? = 0 +configure:2658: result: yes +configure:2667: checking whether gcc accepts -g +configure:2687: gcc -c -g conftest.c >&5 +configure:2687: $? = 0 +configure:2728: result: yes +configure:2745: checking for gcc option to accept ISO C89 +configure:2808: gcc -c -g -O2 conftest.c >&5 +configure:2808: $? = 0 +configure:2821: result: none needed +configure:2847: checking how to run the C preprocessor +configure:2878: gcc -E conftest.c +configure:2878: $? = 0 +configure:2892: gcc -E conftest.c +conftest.c:9:10: fatal error: ac_nonexistent.h: No such file or directory + #include <ac_nonexistent.h> + ^~~~~~~~~~~~~~~~~~ +compilation terminated. +configure:2892: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "" +| #define PACKAGE_TARNAME "" +| #define PACKAGE_VERSION "" +| #define PACKAGE_STRING "" +| #define PACKAGE_BUGREPORT "" +| #define PACKAGE_URL "" +| /* end confdefs.h. */ +| #include <ac_nonexistent.h> +configure:2917: result: gcc -E +configure:2937: gcc -E conftest.c +configure:2937: $? = 0 +configure:2951: gcc -E conftest.c +conftest.c:9:10: fatal error: ac_nonexistent.h: No such file or directory + #include <ac_nonexistent.h> + ^~~~~~~~~~~~~~~~~~ +compilation terminated. +configure:2951: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "" +| #define PACKAGE_TARNAME "" +| #define PACKAGE_VERSION "" +| #define PACKAGE_STRING "" +| #define PACKAGE_BUGREPORT "" +| #define PACKAGE_URL "" +| /* end confdefs.h. */ +| #include <ac_nonexistent.h> +configure:2980: checking for grep that handles long lines and -e +configure:3038: result: /bin/grep +configure:3043: checking for egrep +configure:3105: result: /bin/grep -E +configure:3110: checking for ANSI C header files +configure:3130: gcc -c -g -O2 conftest.c >&5 +configure:3130: $? = 0 +configure:3203: gcc -o conftest -g -O2 conftest.c >&5 +configure:3203: $? = 0 +configure:3203: ./conftest +configure:3203: $? = 0 +configure:3214: result: yes +configure:3227: checking for sys/types.h +configure:3227: gcc -c -g -O2 conftest.c >&5 +configure:3227: $? = 0 +configure:3227: result: yes +configure:3227: checking for sys/stat.h +configure:3227: gcc -c -g -O2 conftest.c >&5 +configure:3227: $? = 0 +configure:3227: result: yes +configure:3227: checking for stdlib.h +configure:3227: gcc -c -g -O2 conftest.c >&5 +configure:3227: $? = 0 +configure:3227: result: yes +configure:3227: checking for string.h +configure:3227: gcc -c -g -O2 conftest.c >&5 +configure:3227: $? = 0 +configure:3227: result: yes +configure:3227: checking for memory.h +configure:3227: gcc -c -g -O2 conftest.c >&5 +configure:3227: $? = 0 +configure:3227: result: yes +configure:3227: checking for strings.h +configure:3227: gcc -c -g -O2 conftest.c >&5 +configure:3227: $? = 0 +configure:3227: result: yes +configure:3227: checking for inttypes.h +configure:3227: gcc -c -g -O2 conftest.c >&5 +configure:3227: $? = 0 +configure:3227: result: yes +configure:3227: checking for stdint.h +configure:3227: gcc -c -g -O2 conftest.c >&5 +configure:3227: $? = 0 +configure:3227: result: yes +configure:3227: checking for unistd.h +configure:3227: gcc -c -g -O2 conftest.c >&5 +configure:3227: $? = 0 +configure:3227: result: yes +configure:3241: checking readline/readline.h usability +configure:3241: gcc -c -g -O2 conftest.c >&5 +configure:3241: $? = 0 +configure:3241: result: yes +configure:3241: checking readline/readline.h presence +configure:3241: gcc -E conftest.c +configure:3241: $? = 0 +configure:3241: result: yes +configure:3241: checking for readline/readline.h +configure:3241: result: yes +configure:3250: checking for GNU Readline version +configure:3271: result: -1 +configure:3280: checking for GNU Readline library -lreadline.dll +configure:3304: gcc -o conftest -g -O2 conftest.c -lreadline.dll >&5 +/usr/bin/ld: cannot find -lreadline.dll +collect2: error: ld returned 1 exit status +configure:3304: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "" +| #define PACKAGE_TARNAME "" +| #define PACKAGE_VERSION "" +| #define PACKAGE_STRING "" +| #define PACKAGE_BUGREPORT "" +| #define PACKAGE_URL "" +| #define STDC_HEADERS 1 +| #define HAVE_SYS_TYPES_H 1 +| #define HAVE_SYS_STAT_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| #define HAVE_MEMORY_H 1 +| #define HAVE_STRINGS_H 1 +| #define HAVE_INTTYPES_H 1 +| #define HAVE_STDINT_H 1 +| #define HAVE_UNISTD_H 1 +| /* end confdefs.h. */ +| +| /* includes */ +| #include <stdio.h> +| #include <readline/readline.h> +| +| int +| main () +| { +| +| /* function-body */ +| int dummy = rl_completion_append_character; /* rl_completion_append_character appeared in version 2.1 */ +| readline(NULL); +| +| ; +| return 0; +| } +configure:3313: result: no +configure:3280: checking for GNU Readline library -lreadline +configure:3304: gcc -o conftest -g -O2 conftest.c -lreadline >&5 +configure:3304: $? = 0 +configure:3307: result: yes +configure:3385: checking for gcc +configure:3412: result: gcc +configure:3641: checking for C compiler version +configure:3650: gcc --version >&5 +gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0 +Copyright (C) 2017 Free Software Foundation, Inc. +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +configure:3661: $? = 0 +configure:3650: gcc -v >&5 +Using built-in specs. +COLLECT_GCC=gcc +COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper +OFFLOAD_TARGET_NAMES=nvptx-none +OFFLOAD_TARGET_DEFAULT=1 +Target: x86_64-linux-gnu +Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.4.0-1ubuntu1~18.04.1' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu +Thread model: posix +gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1) +configure:3661: $? = 0 +configure:3650: gcc -V >&5 +gcc: error: unrecognized command line option '-V' +gcc: fatal error: no input files +compilation terminated. +configure:3661: $? = 1 +configure:3650: gcc -qversion >&5 +gcc: error: unrecognized command line option '-qversion'; did you mean '--version'? +gcc: fatal error: no input files +compilation terminated. +configure:3661: $? = 1 +configure:3665: checking whether we are using the GNU C compiler +configure:3693: result: yes +configure:3702: checking whether gcc accepts -g +configure:3763: result: yes +configure:3780: checking for gcc option to accept ISO C89 +configure:3856: result: none needed +configure:3881: checking how to run the C preprocessor +configure:3951: result: gcc -E +configure:3971: gcc -E conftest.c +configure:3971: $? = 0 +configure:3985: gcc -E conftest.c +conftest.c:20:10: fatal error: ac_nonexistent.h: No such file or directory + #include <ac_nonexistent.h> + ^~~~~~~~~~~~~~~~~~ +compilation terminated. +configure:3985: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "" +| #define PACKAGE_TARNAME "" +| #define PACKAGE_VERSION "" +| #define PACKAGE_STRING "" +| #define PACKAGE_BUGREPORT "" +| #define PACKAGE_URL "" +| #define STDC_HEADERS 1 +| #define HAVE_SYS_TYPES_H 1 +| #define HAVE_SYS_STAT_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| #define HAVE_MEMORY_H 1 +| #define HAVE_STRINGS_H 1 +| #define HAVE_INTTYPES_H 1 +| #define HAVE_STDINT_H 1 +| #define HAVE_UNISTD_H 1 +| #define HAVE_LIBREADLINE -1 +| /* end confdefs.h. */ +| #include <ac_nonexistent.h> +configure:4056: checking for a BSD-compatible install +configure:4124: result: /usr/bin/install -c +configure:4178: checking for ranlib +configure:4194: found /usr/bin/ranlib +configure:4205: result: ranlib +configure:4229: checking for autoconf +configure:4245: found /usr/bin/autoconf +configure:4257: result: autoconf +configure:4267: checking for strip +configure:4283: found /usr/bin/strip +configure:4295: result: strip +configure:4305: checking for as +configure:4321: found /usr/bin/as +configure:4333: result: as +configure:4343: checking for cp +configure:4359: found /bin/cp +configure:4371: result: cp +configure:4402: checking for unistd.h +configure:4402: result: yes +configure:4402: checking sys/wait.h usability +configure:4402: gcc -c -g -O2 conftest.c >&5 +configure:4402: $? = 0 +configure:4402: result: yes +configure:4402: checking sys/wait.h presence +configure:4402: gcc -E conftest.c +configure:4402: $? = 0 +configure:4402: result: yes +configure:4402: checking for sys/wait.h +configure:4402: result: yes +configure:4415: checking sys/socket.h usability +configure:4415: gcc -c -g -O2 conftest.c >&5 +configure:4415: $? = 0 +configure:4415: result: yes +configure:4415: checking sys/socket.h presence +configure:4415: gcc -E conftest.c +configure:4415: $? = 0 +configure:4415: result: yes +configure:4415: checking for sys/socket.h +configure:4415: result: yes +configure:4445: checking for socket in -lsocket +configure:4470: gcc -o conftest -g -O2 conftest.c -lsocket >&5 +/usr/bin/ld: cannot find -lsocket +collect2: error: ld returned 1 exit status +configure:4470: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "" +| #define PACKAGE_TARNAME "" +| #define PACKAGE_VERSION "" +| #define PACKAGE_STRING "" +| #define PACKAGE_BUGREPORT "" +| #define PACKAGE_URL "" +| #define STDC_HEADERS 1 +| #define HAVE_SYS_TYPES_H 1 +| #define HAVE_SYS_STAT_H 1 +| #define HAVE_STDLIB_H 1 +| #define HAVE_STRING_H 1 +| #define HAVE_MEMORY_H 1 +| #define HAVE_STRINGS_H 1 +| #define HAVE_INTTYPES_H 1 +| #define HAVE_STDINT_H 1 +| #define HAVE_UNISTD_H 1 +| #define HAVE_LIBREADLINE -1 +| #define HAVE_UNISTD_H 1 +| #define HAVE_SYS_WAIT_H 1 +| #define HAVE_SYS_SOCKET_H 1 +| /* end confdefs.h. */ +| +| /* Override any GCC internal prototype to avoid an error. +| Use char because int might match the return type of a GCC +| builtin and then its argument prototype would still apply. */ +| #ifdef __cplusplus +| extern "C" +| #endif +| char socket (); +| int +| main () +| { +| return socket (); +| ; +| return 0; +| } +configure:4479: result: no +configure:4490: checking for xdr_short in -lnsl +configure:4515: gcc -o conftest -g -O2 conftest.c -lnsl >&5 +configure:4515: $? = 0 +configure:4524: result: yes +configure:4588: checking whether preprocessor accepts -MM or -M +Using built-in specs. +COLLECT_GCC=gcc +OFFLOAD_TARGET_NAMES=nvptx-none +OFFLOAD_TARGET_DEFAULT=1 +Target: x86_64-linux-gnu +Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.4.0-1ubuntu1~18.04.1' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu +Thread model: posix +gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1) +COLLECT_GCC_OPTIONS='-E' '-v' '-MM' '-mtune=generic' '-march=x86-64' + /usr/lib/gcc/x86_64-linux-gnu/7/cc1 -E -quiet -v -imultiarch x86_64-linux-gnu -MM _test_.c -mtune=generic -march=x86-64 -fstack-protector-strong -Wformat -Wformat-security +ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" +ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/include" +#include "..." search starts here: +#include <...> search starts here: + /usr/lib/gcc/x86_64-linux-gnu/7/include + /usr/local/include + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed + /usr/include/x86_64-linux-gnu + /usr/include +End of search list. +_test_.o: _test_.c +COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/ +LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-E' '-v' '-MM' '-mtune=generic' '-march=x86-64' +configure:4603: result: -MM +configure:4609: checking whether accepts -ggdb +configure:4629: gcc -c -ggdb conftest.c >&5 +configure:4629: $? = 0 +configure:4637: result: yes +configure:4647: checking whether accepts -pipe +configure:4667: gcc -c -pipe conftest.c >&5 +configure:4667: $? = 0 +configure:4675: result: yes +configure:4731: checking for gcc option to accept ISO C99 +configure:4880: gcc -c -pipe -ggdb -g -O2 conftest.c >&5 +configure:4880: $? = 0 +configure:4893: result: none needed +configure:5122: creating ./config.status + +## ---------------------- ## +## Running config.status. ## +## ---------------------- ## + +This file was extended by config.status, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = + CONFIG_HEADERS = + CONFIG_LINKS = + CONFIG_COMMANDS = + $ ./config.status + +on xavier-asus + +config.status:821: creating Makefile +config.status:821: creating config.h +config.status:996: config.h is unchanged + +## ---------------- ## +## Cache variables. ## +## ---------------- ## + +ac_cv_c_compiler_gnu=yes +ac_cv_env_CC_set= +ac_cv_env_CC_value= +ac_cv_env_CFLAGS_set= +ac_cv_env_CFLAGS_value= +ac_cv_env_CPPFLAGS_set= +ac_cv_env_CPPFLAGS_value= +ac_cv_env_CPP_set= +ac_cv_env_CPP_value= +ac_cv_env_LDFLAGS_set= +ac_cv_env_LDFLAGS_value= +ac_cv_env_LIBS_set= +ac_cv_env_LIBS_value= +ac_cv_env_build_alias_set= +ac_cv_env_build_alias_value= +ac_cv_env_host_alias_set= +ac_cv_env_host_alias_value= +ac_cv_env_lib_dir_suffix_set= +ac_cv_env_lib_dir_suffix_value= +ac_cv_env_sdccconf_h_dir_separator_set= +ac_cv_env_sdccconf_h_dir_separator_value= +ac_cv_env_target_alias_set= +ac_cv_env_target_alias_value= +ac_cv_header_inttypes_h=yes +ac_cv_header_memory_h=yes +ac_cv_header_readline_readline_h=yes +ac_cv_header_stdc=yes +ac_cv_header_stdint_h=yes +ac_cv_header_stdlib_h=yes +ac_cv_header_string_h=yes +ac_cv_header_strings_h=yes +ac_cv_header_sys_socket_h=yes +ac_cv_header_sys_stat_h=yes +ac_cv_header_sys_types_h=yes +ac_cv_header_sys_wait_h=yes +ac_cv_header_unistd_h=yes +ac_cv_lib_nsl_xdr_short=yes +ac_cv_lib_socket_socket=no +ac_cv_objext=o +ac_cv_path_EGREP='/bin/grep -E' +ac_cv_path_GREP=/bin/grep +ac_cv_path_install='/usr/bin/install -c' +ac_cv_prog_AS=as +ac_cv_prog_AUTOCONF=autoconf +ac_cv_prog_CP=cp +ac_cv_prog_CPP='gcc -E' +ac_cv_prog_STRIP=strip +ac_cv_prog_ac_ct_CC=gcc +ac_cv_prog_ac_ct_RANLIB=ranlib +ac_cv_prog_cc_c89= +ac_cv_prog_cc_c99= +ac_cv_prog_cc_g=yes +bor_cv_c_ggdb=yes +bor_cv_c_pipe=yes +sdcc_cv_MM=-MM +wi_cv_lib_readline=yes + +## ----------------- ## +## Output variables. ## +## ----------------- ## + +AS='as' +AUTOCONF='autoconf' +C99_FLAG='--std=c99' +CC='gcc' +CFLAGS=' -pipe -ggdb -g -O2' +CP='cp' +CPP='gcc -E' +CPPFLAGS='' +DEFS='-DHAVE_CONFIG_H' +ECHO_C='' +ECHO_N='-n' +ECHO_T='' +EGREP='/bin/grep -E' +EXEEXT='' +GREP='/bin/grep' +INSTALL_DATA='${INSTALL} -m 644' +INSTALL_PROGRAM='${INSTALL}' +INSTALL_SCRIPT='${INSTALL}' +LDFLAGS='' +LIBOBJS='' +LIBREADLINE='-lreadline' +LIBS='-lnsl ' +LTLIBOBJS='' +MAKEDEP='gcc -MM' +OBJEXT='o' +PACKAGE_BUGREPORT='' +PACKAGE_NAME='' +PACKAGE_STRING='' +PACKAGE_TARNAME='' +PACKAGE_URL='' +PACKAGE_VERSION='' +PATH_SEPARATOR=':' +RANLIB='ranlib' +SHELL='/bin/bash' +STRIP='strip' +WALL_FLAG='-Wall' +ac_ct_CC='gcc' +bindir='${exec_prefix}/bin' +build_alias='' +datadir='${datarootdir}' +datarootdir='${prefix}/share' +docdir='${datarootdir}/doc/${PACKAGE}' +dvidir='${docdir}' +exec_prefix='${prefix}' +host_alias='' +htmldir='${docdir}' +includedir='${prefix}/include' +infodir='${datarootdir}/info' +lib_dir_suffix='sdcc/lib' +libdir='${exec_prefix}/lib' +libexecdir='${exec_prefix}/libexec' +localedir='${datarootdir}/locale' +localstatedir='${prefix}/var' +mandir='${datarootdir}/man' +oldincludedir='/usr/include' +pdfdir='${docdir}' +prefix='/usr/local' +program_transform_name='s,x,x,' +psdir='${docdir}' +runstatedir='${localstatedir}/run' +sbindir='${exec_prefix}/sbin' +sdccconf_h_dir_separator='/' +sharedstatedir='${prefix}/com' +sysconfdir='${prefix}/etc' +target_alias='' + +## ----------- ## +## confdefs.h. ## +## ----------- ## + +/* confdefs.h */ +#define PACKAGE_NAME "" +#define PACKAGE_TARNAME "" +#define PACKAGE_VERSION "" +#define PACKAGE_STRING "" +#define PACKAGE_BUGREPORT "" +#define PACKAGE_URL "" +#define STDC_HEADERS 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRING_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_LIBREADLINE -1 +#define HAVE_UNISTD_H 1 +#define HAVE_SYS_WAIT_H 1 +#define HAVE_SYS_SOCKET_H 1 +#define HAVE_LIBNSL 1 +#define DIR_SEPARATOR_STRING "/" +#define DATADIR "/usr/local/share" +#define LIB_DIR_SUFFIX DIR_SEPARATOR_STRING "sdcc/lib" + +configure: exit 0 diff --git a/debugger/mcs51/config.status b/debugger/mcs51/config.status new file mode 100755 index 0000000..7b37eae --- /dev/null +++ b/debugger/mcs51/config.status @@ -0,0 +1,1016 @@ +#! /bin/bash +# Generated by configure. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=${CONFIG_SHELL-/bin/bash} +export SHELL +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by $as_me, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +# Files that config.status was made for. +config_files=" Makefile" +config_headers=" config.h" + +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Report bugs to the package provider." + +ac_cs_config="'--disable-option-checking' '--prefix=/usr/local' '--disable-mcs51-port' '--disable-z80-port' '--disable-z180-port' '--disable-r2k-port' '--disable-r3ka-port' '--disable-gbz80-port' '--disable-tlcs90-port' '--disable-ez80_z80-port' '--disable-ds390-port' '--disable-ds400-port' '--disable-pic14-port' '--disable-pic16-port' '--disable-hc08-port' '--disable-s08-port' '--disable-pdk13-port' '--disable-pdk14-port' '--disable-pdk15-port' '--enable-pdk16-port' '--disable-ucsim' '--disable-device-lib' '--disable-packihx' '--disable-pdk16-port' 'docdir=\${datarootdir}/doc/\${PACKAGE}' '--cache-file=/dev/null' '--srcdir=.'" +ac_cs_version="\ +config.status +configured by ./configure, generated by GNU Autoconf 2.69, + with options \"$ac_cs_config\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='/home/xavier/sdcc/debugger/mcs51' +srcdir='.' +INSTALL='/usr/bin/install -c' +test -n "$AWK" || AWK=awk +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +if $ac_cs_recheck; then + set X /bin/bash './configure' '--disable-option-checking' '--prefix=/usr/local' '--disable-mcs51-port' '--disable-z80-port' '--disable-z180-port' '--disable-r2k-port' '--disable-r3ka-port' '--disable-gbz80-port' '--disable-tlcs90-port' '--disable-ez80_z80-port' '--disable-ds390-port' '--disable-ds400-port' '--disable-pic14-port' '--disable-pic16-port' '--disable-hc08-port' '--disable-s08-port' '--disable-pdk13-port' '--disable-pdk14-port' '--disable-pdk15-port' '--enable-pdk16-port' '--disable-ucsim' '--disable-device-lib' '--disable-packihx' '--disable-pdk16-port' 'docdir=${datarootdir}/doc/${PACKAGE}' '--cache-file=/dev/null' '--srcdir=.' $ac_configure_extra_args --no-create --no-recursion + shift + $as_echo "running CONFIG_SHELL=/bin/bash $*" >&6 + CONFIG_SHELL='/bin/bash' + export CONFIG_SHELL + exec "$@" +fi + +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +cat >>"$ac_tmp/subs1.awk" <<\_ACAWK && +S["LTLIBOBJS"]="" +S["LIBOBJS"]="" +S["lib_dir_suffix"]="sdcc/lib" +S["sdccconf_h_dir_separator"]="/" +S["C99_FLAG"]="--std=c99" +S["WALL_FLAG"]="-Wall" +S["MAKEDEP"]="gcc -MM" +S["CP"]="cp" +S["AS"]="as" +S["STRIP"]="strip" +S["AUTOCONF"]="autoconf" +S["RANLIB"]="ranlib" +S["INSTALL_DATA"]="${INSTALL} -m 644" +S["INSTALL_SCRIPT"]="${INSTALL}" +S["INSTALL_PROGRAM"]="${INSTALL}" +S["LIBREADLINE"]="-lreadline" +S["EGREP"]="/bin/grep -E" +S["GREP"]="/bin/grep" +S["CPP"]="gcc -E" +S["OBJEXT"]="o" +S["EXEEXT"]="" +S["ac_ct_CC"]="gcc" +S["CPPFLAGS"]="" +S["LDFLAGS"]="" +S["CFLAGS"]=" -pipe -ggdb -g -O2" +S["CC"]="gcc" +S["target_alias"]="" +S["host_alias"]="" +S["build_alias"]="" +S["LIBS"]="-lnsl " +S["ECHO_T"]="" +S["ECHO_N"]="-n" +S["ECHO_C"]="" +S["DEFS"]="-DHAVE_CONFIG_H" +S["mandir"]="${datarootdir}/man" +S["localedir"]="${datarootdir}/locale" +S["libdir"]="${exec_prefix}/lib" +S["psdir"]="${docdir}" +S["pdfdir"]="${docdir}" +S["dvidir"]="${docdir}" +S["htmldir"]="${docdir}" +S["infodir"]="${datarootdir}/info" +S["docdir"]="${datarootdir}/doc/${PACKAGE}" +S["oldincludedir"]="/usr/include" +S["includedir"]="${prefix}/include" +S["runstatedir"]="${localstatedir}/run" +S["localstatedir"]="${prefix}/var" +S["sharedstatedir"]="${prefix}/com" +S["sysconfdir"]="${prefix}/etc" +S["datadir"]="${datarootdir}" +S["datarootdir"]="${prefix}/share" +S["libexecdir"]="${exec_prefix}/libexec" +S["sbindir"]="${exec_prefix}/sbin" +S["bindir"]="${exec_prefix}/bin" +S["program_transform_name"]="s,x,x," +S["prefix"]="/usr/local" +S["exec_prefix"]="${prefix}" +S["PACKAGE_URL"]="" +S["PACKAGE_BUGREPORT"]="" +S["PACKAGE_STRING"]="" +S["PACKAGE_VERSION"]="" +S["PACKAGE_TARNAME"]="" +S["PACKAGE_NAME"]="" +S["PATH_SEPARATOR"]=":" +S["SHELL"]="/bin/bash" +_ACAWK +cat >>"$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +D["PACKAGE_NAME"]=" \"\"" +D["PACKAGE_TARNAME"]=" \"\"" +D["PACKAGE_VERSION"]=" \"\"" +D["PACKAGE_STRING"]=" \"\"" +D["PACKAGE_BUGREPORT"]=" \"\"" +D["PACKAGE_URL"]=" \"\"" +D["STDC_HEADERS"]=" 1" +D["HAVE_SYS_TYPES_H"]=" 1" +D["HAVE_SYS_STAT_H"]=" 1" +D["HAVE_STDLIB_H"]=" 1" +D["HAVE_STRING_H"]=" 1" +D["HAVE_MEMORY_H"]=" 1" +D["HAVE_STRINGS_H"]=" 1" +D["HAVE_INTTYPES_H"]=" 1" +D["HAVE_STDINT_H"]=" 1" +D["HAVE_UNISTD_H"]=" 1" +D["HAVE_LIBREADLINE"]=" -1" +D["HAVE_UNISTD_H"]=" 1" +D["HAVE_SYS_WAIT_H"]=" 1" +D["HAVE_SYS_SOCKET_H"]=" 1" +D["HAVE_LIBNSL"]=" 1" +D["DIR_SEPARATOR_STRING"]=" \"/\"" +D["DATADIR"]=" \"/usr/local/share\"" +D["LIB_DIR_SUFFIX"]=" DIR_SEPARATOR_STRING \"sdcc/lib\"" + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+[_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ][_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]*([\t (]|$)/ { + line = $ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} + ac_datarootdir_hack=' + s&@datadir@&${datarootdir}&g + s&@docdir@&${datarootdir}/doc/${PACKAGE}&g + s&@infodir@&${datarootdir}/info&g + s&@localedir@&${datarootdir}/locale&g + s&@mandir@&${datarootdir}/man&g + s&\${datarootdir}&${prefix}/share&g' ;; +esac +ac_sed_extra="/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +} + +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi + ;; + + + esac + +done # for ac_tag + + +as_fn_exit 0 diff --git a/debugger/mcs51/configure b/debugger/mcs51/configure new file mode 100644 index 0000000..640ec3b --- /dev/null +++ b/debugger/mcs51/configure @@ -0,0 +1,6287 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.69. +# +# +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +test -n "$DJDIR" || exec 7<&0 </dev/null +exec 6>&1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= +PACKAGE_URL= + +ac_unique_file="Makefile.in" +# Factoring default headers for most tests. +ac_includes_default="\ +#include <stdio.h> +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#ifdef HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif +#ifdef STDC_HEADERS +# include <stdlib.h> +# include <stddef.h> +#else +# ifdef HAVE_STDLIB_H +# include <stdlib.h> +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include <memory.h> +# endif +# include <string.h> +#endif +#ifdef HAVE_STRINGS_H +# include <strings.h> +#endif +#ifdef HAVE_INTTYPES_H +# include <inttypes.h> +#endif +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif" + +ac_subst_vars='LTLIBOBJS +LIBOBJS +lib_dir_suffix +sdccconf_h_dir_separator +C99_FLAG +WALL_FLAG +MAKEDEP +CP +AS +STRIP +AUTOCONF +RANLIB +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +LIBREADLINE +EGREP +GREP +CPP +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +runstatedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP +sdccconf_h_dir_separator +lib_dir_suffix' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir runstatedir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures this package to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a + nonstandard directory <lib dir> + LIBS libraries to pass to the linker, e.g. -l<library> + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if + you have headers in a nonstandard directory <include dir> + CPP C preprocessor + sdccconf_h_dir_separator + needed in sdccconf.h: either "/" (default) or "\\" + lib_dir_suffix + appended to datadir to define SDCC's library root directory + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to the package provider. +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +configure +generated by GNU Autoconf 2.69 + +Copyright (C) 2012 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by $as_me, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +ac_config_headers="$ac_config_headers config.h" + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdio.h> +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdarg.h> +#include <stdio.h> +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <string.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdlib.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <ctype.h> +#include <stdlib.h> +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + ac_fn_c_check_header_mongrel "$LINENO" "readline/readline.h" "ac_cv_header_readline_readline_h" "$ac_includes_default" +if test "x$ac_cv_header_readline_readline_h" = xyes; then : + +fi + + + + if test "$ac_cv_header_readline_readline_h" = yes; then + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU Readline version" >&5 +$as_echo_n "checking for GNU Readline version... " >&6; } + cat > conftest.$ac_ext <<EOF +#include <stdio.h> +#include <readline/readline.h> +wi_LIB_READLINE_VERSION RL_VERSION_MAJOR RL_VERSION_MINOR +EOF + + wi_READLINE_VERSION=$($CPP $CPPFLAGS conftest.$ac_ext | sed -n -e "s/^wi_LIB_READLINE_VERSION *\([0-9][0-9]*\) *\([0-9][0-9]*\)$/\1.\2/p") + rm -rf conftest* + + if test -n "$wi_READLINE_VERSION"; then + wi_MAJOR=$(expr $wi_READLINE_VERSION : '\([0-9][0-9]*\)\.') + wi_MINOR=$(expr $wi_READLINE_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\)') + if test $wi_MINOR -lt 10; then + wi_MINOR=$(expr $wi_MINOR \* 10) + fi + wi_READLINE_VERSION=$(expr $wi_MAJOR \* 100 + $wi_MINOR) + else + wi_READLINE_VERSION=-1 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $wi_READLINE_VERSION" >&5 +$as_echo "$wi_READLINE_VERSION" >&6; } + + + ac_save_LIBS="$LIBS" + # Note: $LIBCURSES is permitted to be empty. + + for LIBREADLINE in "-lreadline.dll" "-lreadline" "-lreadline $LIBCURSES" "-lreadline -ltermcap" "-lreadline -lncurses" "-lreadline -lcurses" + do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU Readline library $LIBREADLINE" >&5 +$as_echo_n "checking for GNU Readline library $LIBREADLINE... " >&6; } + + LIBS="$ac_save_LIBS $LIBREADLINE" + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + /* includes */ + #include <stdio.h> + #include <readline/readline.h> + +int +main () +{ + + /* function-body */ + int dummy = rl_completion_append_character; /* rl_completion_append_character appeared in version 2.1 */ + readline(NULL); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + wi_cv_lib_readline=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +else + + wi_cv_lib_readline=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + if test "$wi_cv_lib_readline" = yes; then + + +cat >>confdefs.h <<_ACEOF +#define HAVE_LIBREADLINE $wi_READLINE_VERSION +_ACEOF + + break + fi + done + + LIBS="$ac_save_LIBS" + fi + + +# Required programs +# =========================================================================== +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdarg.h> +#include <stdio.h> +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if ${ac_cv_path_install+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +# Extract the first word of "autoconf", so it can be a program name with args. +set dummy autoconf; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AUTOCONF+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AUTOCONF"; then + ac_cv_prog_AUTOCONF="$AUTOCONF" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AUTOCONF="autoconf" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_prog_AUTOCONF" && ac_cv_prog_AUTOCONF=":" +fi +fi +AUTOCONF=$ac_cv_prog_AUTOCONF +if test -n "$AUTOCONF"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AUTOCONF" >&5 +$as_echo "$AUTOCONF" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +# Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_prog_STRIP" && ac_cv_prog_STRIP=":" +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +# Extract the first word of "as", so it can be a program name with args. +set dummy as; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AS+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AS"; then + ac_cv_prog_AS="$AS" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AS="as" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_prog_AS" && ac_cv_prog_AS=":" +fi +fi +AS=$ac_cv_prog_AS +if test -n "$AS"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 +$as_echo "$AS" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +# Extract the first word of "cp", so it can be a program name with args. +set dummy cp; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CP"; then + ac_cv_prog_CP="$CP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CP="cp" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_prog_CP" && ac_cv_prog_CP=":" +fi +fi +CP=$ac_cv_prog_CP +if test -n "$CP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CP" >&5 +$as_echo "$CP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. +# By default was `s,x,x', remove it if useless. +ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' +program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` + +# Checking for header files. +# =========================================================================== +for ac_header in unistd.h sys/wait.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +socket_type=unknown +for ac_header in sys/socket.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sys/socket.h" "ac_cv_header_sys_socket_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_socket_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_SOCKET_H 1 +_ACEOF + socket_type=sys_socket_h +fi + +done + +if test $socket_type = unknown; then + for ac_header in winsock2.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "winsock2.h" "ac_cv_header_winsock2_h" "$ac_includes_default" +if test "x$ac_cv_header_winsock2_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_WINSOCK2_H 1 +_ACEOF + socket_type=winsock2_h +fi + +done + +fi + +# Checking for functions/libs +# =========================================================================== +if test $socket_type = winsock2_h; then + LIBS="-lws2_32 $LIBS" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5 +$as_echo_n "checking for socket in -lsocket... " >&6; } +if ${ac_cv_lib_socket_socket+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsocket $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char socket (); +int +main () +{ +return socket (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_socket_socket=yes +else + ac_cv_lib_socket_socket=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5 +$as_echo "$ac_cv_lib_socket_socket" >&6; } +if test "x$ac_cv_lib_socket_socket" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSOCKET 1 +_ACEOF + + LIBS="-lsocket $LIBS" + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for xdr_short in -lnsl" >&5 +$as_echo_n "checking for xdr_short in -lnsl... " >&6; } +if ${ac_cv_lib_nsl_xdr_short+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lnsl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char xdr_short (); +int +main () +{ +return xdr_short (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_nsl_xdr_short=yes +else + ac_cv_lib_nsl_xdr_short=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_xdr_short" >&5 +$as_echo "$ac_cv_lib_nsl_xdr_short" >&6; } +if test "x$ac_cv_lib_nsl_xdr_short" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBNSL 1 +_ACEOF + + LIBS="-lnsl $LIBS" + +fi + +fi + + +# Macro definitions +# =========================================================================== + +# Check whether the compiler for the current language is SunPRO. + + + +# bor_IS_VALID_OPTION macro checks if the current compiler, selected by +# AC_LANG, supports option specified as the 1st parameter. The test fails if +# the compiler returns an error or in case something is writeen to stderr. +# For example: bor_VALID_OPT(fPIC) + + + +# This macro expands DIR and assigns it to RET. +# If DIR is NONE, then it's replaced by DEFAULT. +# +# Based on AC_DEFINE_DIR +# +# Examples: +# +# adl_EXPAND(prefix, "/usr/local", expanded_prefix) + + + +# adl_NORMALIZE_PATH +# +# - empty paths are changed to '.' +# - trailing slashes are removed +# - repeated slashes are squeezed except a leading doubled slash '//' +# (which might indicate a networked disk on some OS). +# +# +# REFERENCE_STRING is used to turn '/' into '\' and vice-versa: if +# REFERENCE_STRING contains some backslashes, all slashes and backslashes +# are turned into backslashes, otherwise they are all turned into slashes. +# +# This makes processing of DOS filenames quite easier, because you can turn a +# filename to the Unix notation, make your processing, and turn it back to +# original notation. + + + + + + + +# Checking characteristics of compilers and other programs +# =========================================================================== +if test "$ac_cv_c_compiler_gnu" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether preprocessor accepts -MM or -M" >&5 +$as_echo_n "checking whether preprocessor accepts -MM or -M... " >&6; } +if ${sdcc_cv_MM+:} false; then : + $as_echo_n "(cached) " >&6 +else + echo "#include <stdio.h>" >_test_.c + echo "" >>_test_.c + $CPP -v -MM _test_.c 1>&5 2>&5 + if test "$?" = "0"; then + sdcc_cv_MM="-MM" + else + sdcc_cv_MM="-M" + fi + rm -f _test_.* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $sdcc_cv_MM" >&5 +$as_echo "$sdcc_cv_MM" >&6; } + + # This is the first time when CFLAGS are set/modified!! + ac_test_CFLAGS=${CFLAGS+set} +bor_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $C accepts -ggdb" >&5 +$as_echo_n "checking whether $C accepts -ggdb... " >&6; } +if ${bor_cv_c_ggdb+:} false; then : + $as_echo_n "(cached) " >&6 +else + bor_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + + CFLAGS="-ggdb" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bor_cv_c_ggdb=yes +else + bor_cv_c_ggdb=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$bor_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bor_cv_c_ggdb" >&5 +$as_echo "$bor_cv_c_ggdb" >&6; } + CFLAGS=$bor_save_CFLAGS + + if test "$bor_cv_c_ggdb" = "yes"; then + CFLAGS="-ggdb ${CFLAGS}" + fi + + ac_test_CFLAGS=${CFLAGS+set} +bor_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $C accepts -pipe" >&5 +$as_echo_n "checking whether $C accepts -pipe... " >&6; } +if ${bor_cv_c_pipe+:} false; then : + $as_echo_n "(cached) " >&6 +else + bor_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + + CFLAGS="-pipe" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bor_cv_c_pipe=yes +else + bor_cv_c_pipe=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$bor_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bor_cv_c_pipe" >&5 +$as_echo "$bor_cv_c_pipe" >&6; } + CFLAGS=$bor_save_CFLAGS + + if test "$bor_cv_c_pipe" = "yes"; then + CFLAGS="-pipe $CFLAGS" + fi + + WALL_FLAG="-Wall" + C99_FLAG="--std=c99" + MAKEDEP="$CC $sdcc_cv_MM" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the SunPRO C compiler" >&5 +$as_echo_n "checking whether we are using the SunPRO C compiler... " >&6; } +if ${bor_cv_c_compiler_sunpro+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#if !defined __SUNPRO_C && !defined __SUNPRO_CC + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bor_compiler_sunpro=yes +else + bor_compiler_sunpro=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +bor_cv_c_compiler_sunpro=$bor_compiler_sunpro + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bor_cv_c_compiler_sunpro" >&5 +$as_echo "$bor_cv_c_compiler_sunpro" >&6; } + if test "$bor_cv_c_compiler_sunpro" = "yes"; then + C99_FLAG="-xc99" + CFLAGS="-xO2 ${C99_FLAG} ${CFLAGS}" + WALL_FLAG= + MAKEDEP="$CC ${C99_FLAG} -xM1" + fi +fi + + + + + +# Try to append a c99 flag +# ------------------------------------------------------------------------- + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5 +$as_echo_n "checking for $CC option to accept ISO C99... " >&6; } +if ${ac_cv_prog_cc_c99+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c99=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdarg.h> +#include <stdbool.h> +#include <stdlib.h> +#include <wchar.h> +#include <stdio.h> + +// Check varargs macros. These examples are taken from C99 6.10.3.5. +#define debug(...) fprintf (stderr, __VA_ARGS__) +#define showlist(...) puts (#__VA_ARGS__) +#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) +static void +test_varargs_macros (void) +{ + int x = 1234; + int y = 5678; + debug ("Flag"); + debug ("X = %d\n", x); + showlist (The first, second, and third items.); + report (x>y, "x is %d but y is %d", x, y); +} + +// Check long long types. +#define BIG64 18446744073709551615ull +#define BIG32 4294967295ul +#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) +#if !BIG_OK + your preprocessor is broken; +#endif +#if BIG_OK +#else + your preprocessor is broken; +#endif +static long long int bignum = -9223372036854775807LL; +static unsigned long long int ubignum = BIG64; + +struct incomplete_array +{ + int datasize; + double data[]; +}; + +struct named_init { + int number; + const wchar_t *name; + double average; +}; + +typedef const char *ccp; + +static inline int +test_restrict (ccp restrict text) +{ + // See if C++-style comments work. + // Iterate through items via the restricted pointer. + // Also check for declarations in for loops. + for (unsigned int i = 0; *(text+i) != '\0'; ++i) + continue; + return 0; +} + +// Check varargs and va_copy. +static void +test_varargs (const char *format, ...) +{ + va_list args; + va_start (args, format); + va_list args_copy; + va_copy (args_copy, args); + + const char *str; + int number; + float fnumber; + + while (*format) + { + switch (*format++) + { + case 's': // string + str = va_arg (args_copy, const char *); + break; + case 'd': // int + number = va_arg (args_copy, int); + break; + case 'f': // float + fnumber = va_arg (args_copy, double); + break; + default: + break; + } + } + va_end (args_copy); + va_end (args); +} + +int +main () +{ + + // Check bool. + _Bool success = false; + + // Check restrict. + if (test_restrict ("String literal") == 0) + success = true; + char *restrict newvar = "Another string"; + + // Check varargs. + test_varargs ("s, d' f .", "string", 65, 34.234); + test_varargs_macros (); + + // Check flexible array members. + struct incomplete_array *ia = + malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); + ia->datasize = 10; + for (int i = 0; i < ia->datasize; ++i) + ia->data[i] = i * 1.234; + + // Check named initializers. + struct named_init ni = { + .number = 34, + .name = L"Test wide string", + .average = 543.34343, + }; + + ni.number = 58; + + int dynamic_array[ni.number]; + dynamic_array[ni.number - 1] = 543; + + // work around unused variable warnings + return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' + || dynamic_array[ni.number - 1] != 543); + + ; + return 0; +} +_ACEOF +for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99 +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c99=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c99" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c99" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c99" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 +$as_echo "$ac_cv_prog_cc_c99" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c99" != xno; then : + +fi + + +if test "$ac_cv_prog_cc_c99" != "no"; then + CFLAGS="$ac_cv_prog_cc_c99 ${CFLAGS}" +fi + +# Set standard installation paths +# =========================================================================== + +# In the Makefiles we need paths with '/' as directory separator, even if +# crosscompiling for Win32. +# And we want to preserve the macros (e.g. ${prefix}) in the Makefiles. +# The variables in the Makefiles are replaced by AC_SUBST() +# +# In sdccconf.h the '/' in paths can be replaced by "\\" (normalized), if +# +# The macros are expanded for the header. +# The variables in the header are replaced by AC_*DEFINE*() +# sdccconf_h_dir_separator contains a backslash. + +if test "x${sdccconf_h_dir_separator}" = "x"; then + sdccconf_h_dir_separator="/" +fi + +# Makefiles +########### + +# lib_dir_suffix: +# *nix default: "sdcc/lib" + +if test "${lib_dir_suffix}" = ""; then + lib_dir_suffix="sdcc/lib" +fi + + + + +# sdccconf.h +############ + + +cat >>confdefs.h <<_ACEOF +#define DIR_SEPARATOR_STRING "${sdccconf_h_dir_separator}" +_ACEOF + + +# datadir: +# default: "${prefix}/share" + + test "x$prefix" = xNONE && prefix="$ac_default_prefix" + test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + ac_expand=$datadir + test "x$ac_expand" = xNONE && ac_expand="$"NONE"" + ac_expand=`eval echo $ac_expand` + expanded_datadir=`eval echo $ac_expand` + + + ac_ndu=$expanded_datadir + case ":$ac_ndu:" in + ::) ac_ndu='.' ;; + :*[\\/]:) ac_ndu=`echo "$ac_ndu" | sed 's,[\\/]*$,,'` ;; + :*:) ;; +esac +case $sdccconf_h_dir_separator in + + *\\*) ac_ndu=`echo "$ac_ndu" | sed 's,\(.\)[\\/][\\/]*,\1\\\\\\\\,g + s,^[\\/],\\\\\\\\,'` ;; + + *) ac_ndu=`echo "$ac_ndu" | sed 's,\(.\)[\\/][\\/]*,\1/,g'` ;; +esac + +cat >>confdefs.h <<_ACEOF +#define DATADIR "${ac_ndu}" +_ACEOF + + + +# lib suffix +norm_lib_dir_suffix=${lib_dir_suffix} +case ":$norm_lib_dir_suffix:" in + ::) norm_lib_dir_suffix='.' ;; + :*[\\/]:) norm_lib_dir_suffix=`echo "$norm_lib_dir_suffix" | sed 's,[\\/]*$,,'` ;; + :*:) ;; +esac +case $sdccconf_h_dir_separator in + + *\\*) norm_lib_dir_suffix=`echo "$norm_lib_dir_suffix" | sed 's,\(.\)[\\/][\\/]*,\1\\\\\\\\,g + s,^[\\/],\\\\\\\\,'` ;; + + *) norm_lib_dir_suffix=`echo "$norm_lib_dir_suffix" | sed 's,\(.\)[\\/][\\/]*,\1/,g'` ;; +esac + +cat >>confdefs.h <<_ACEOF +#define LIB_DIR_SUFFIX DIR_SEPARATOR_STRING "${norm_lib_dir_suffix}" +_ACEOF + + + +# Generating output files +# =========================================================================== +ac_config_files="$ac_config_files Makefile" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by $as_me, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Report bugs to the package provider." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' <conf$$subs.awk | sed ' +/^[^""]/{ + N + s/\n// +} +' >>$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' <confdefs.h | sed ' +s/'"$ac_delim"'/"\\\ +"/g' >>$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi + ;; + + + esac + +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + + +# End of configure/configure.in diff --git a/debugger/mcs51/configure.ac b/debugger/mcs51/configure.ac new file mode 100644 index 0000000..8ab78fe --- /dev/null +++ b/debugger/mcs51/configure.ac @@ -0,0 +1,253 @@ +#!/bin/sh + +AC_PREREQ(2.60) +AC_INIT +AC_CONFIG_SRCDIR([Makefile.in]) +AC_CONFIG_HEADER(config.h) + + +wi_LIB_READLINE + +# Required programs +# =========================================================================== +AC_PROG_CC +AC_PROG_CPP +AC_PROG_INSTALL +AC_PROG_RANLIB +AC_CHECK_PROG(AUTOCONF, autoconf, autoconf, :) +AC_CHECK_PROG(STRIP, strip, strip, :) +AC_CHECK_PROG(AS, as, as, :) +AC_CHECK_PROG(CP, cp, cp, :) + +AC_LANG_C + +AC_ARG_PROGRAM +# Checking for header files. +# =========================================================================== +AC_CHECK_HEADERS(unistd.h sys/wait.h) +socket_type=unknown +AC_CHECK_HEADERS(sys/socket.h, socket_type=sys_socket_h) +if test $socket_type = unknown; then + AC_CHECK_HEADERS(winsock2.h, socket_type=winsock2_h) +fi + +# Checking for functions/libs +# =========================================================================== +if test $socket_type = winsock2_h; then + LIBS="-lws2_32 $LIBS" +else + AC_CHECK_LIB(socket,socket) + AC_CHECK_LIB(nsl,xdr_short) +fi + + +# Macro definitions +# =========================================================================== + +# Check whether the compiler for the current language is SunPRO. + +AC_DEFUN([bor_IS_SUNPRO], +[AC_CACHE_CHECK([whether we are using the SunPRO _AC_LANG compiler], + [bor_cv_[]_AC_LANG_ABBREV[]_compiler_sunpro], + [_AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#if !defined __SUNPRO_C && !defined __SUNPRO_CC + choke me +#endif +]])], + [bor_compiler_sunpro=yes], + [bor_compiler_sunpro=no]) +bor_cv_[]_AC_LANG_ABBREV[]_compiler_sunpro=$bor_compiler_sunpro +])]) + +# bor_IS_VALID_OPTION macro checks if the current compiler, selected by +# AC_LANG, supports option specified as the 1st parameter. The test fails if +# the compiler returns an error or in case something is writeen to stderr. +# For example: bor_VALID_OPT(fPIC) + +AC_DEFUN([bor_IS_VALID_OPTION], +[ac_test_[]_AC_LANG_PREFIX[]FLAGS=${[]_AC_LANG_PREFIX[]FLAGS+set} +bor_save_[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS +AC_CACHE_CHECK(whether $_AC_LANG_PREFIX accepts -$1, bor_cv_[]_AC_LANG_ABBREV[]_$1, + [bor_save_[]_AC_LANG_ABBREV[]_werror_flag=$ac_[]_AC_LANG_ABBREV[]_werror_flag + ac_[]_AC_LANG_ABBREV[]_werror_flag=yes + + []_AC_LANG_PREFIX[]FLAGS="-$1" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], + [bor_cv_[]_AC_LANG_ABBREV[]_$1=yes], + [bor_cv_[]_AC_LANG_ABBREV[]_$1=no]) + ac_[]_AC_LANG_ABBREV[]_werror_flag=$bor_save_[]_AC_LANG_ABBREV[]_werror_flag]) + []_AC_LANG_PREFIX[]FLAGS=$bor_save_[]_AC_LANG_PREFIX[]FLAGS +]) + +# This macro expands DIR and assigns it to RET. +# If DIR is NONE, then it's replaced by DEFAULT. +# +# Based on AC_DEFINE_DIR +# +# Examples: +# +# adl_EXPAND(prefix, "/usr/local", expanded_prefix) + +AC_DEFUN([adl_EXPAND], [ + test "x$prefix" = xNONE && prefix="$ac_default_prefix" + test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + ac_expand=[$]$1 + test "x$ac_expand" = xNONE && ac_expand="[$]$2" + ac_expand=`eval echo [$]ac_expand` + $3=`eval echo [$]ac_expand` +]) + +# adl_NORMALIZE_PATH +# +# - empty paths are changed to '.' +# - trailing slashes are removed +# - repeated slashes are squeezed except a leading doubled slash '//' +# (which might indicate a networked disk on some OS). +# +# +# REFERENCE_STRING is used to turn '/' into '\' and vice-versa: if +# REFERENCE_STRING contains some backslashes, all slashes and backslashes +# are turned into backslashes, otherwise they are all turned into slashes. +# +# This makes processing of DOS filenames quite easier, because you can turn a +# filename to the Unix notation, make your processing, and turn it back to +# original notation. + +dnl Available from the GNU Autoconf Macro Archive at: +dnl http://www.gnu.org/software/ac-archive/htmldoc/normpath.html +dnl +AC_DEFUN([adl_NORMALIZE_PATH], +[case ":[$]$1:" in +dnl change empty paths to '.' + ::) $1='.' ;; +dnl strip trailing slashes + :*[[\\/]]:) $1=`echo "[$]$1" | sed 's,[[\\/]]*[$],,'` ;; + :*:) ;; +esac +dnl squeze repeated slashes +case ifelse($2,,"[$]$1",$2) in +dnl if the path contains any backslashes, turn slashes into backslashes + +dnl Bernhard Held 2003-04-06 +dnl This was the original line. It does not: +dnl - convert the first slash +dnl - replace a slash with a double-backslash +dnl *\\*) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1\\\\,g'` ;; + *\\*) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1\\\\\\\\,g + s,^[[\\/]],\\\\\\\\,'` ;; + +dnl if the path contains slashes, also turn backslashes into slashes + *) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1/,g'` ;; +esac]) + + +dnl adl_NORMALIZE_DEFINE_UNQUOTED(var, DEFINE, REFERENCE_STRING) +AC_DEFUN([adl_NORMALIZE_DEFINE_UNQUOTED], [ + ac_ndu=[$]$1 + adl_NORMALIZE_PATH([ac_ndu], [$]$3) + AC_DEFINE_UNQUOTED($2, "${ac_ndu}", [XXX]) +]) + + +# Checking characteristics of compilers and other programs +# =========================================================================== +if test "$ac_cv_c_compiler_gnu" = "yes"; then + AC_CACHE_CHECK(whether preprocessor accepts -MM or -M,sdcc_cv_MM, + echo "#include <stdio.h>" >_test_.c + echo "" >>_test_.c + $CPP -v -MM _test_.c 1>&5 2>&5 + if test "$?" = "0"; then + sdcc_cv_MM="-MM" + else + sdcc_cv_MM="-M" + fi + rm -f _test_.*) + + # This is the first time when CFLAGS are set/modified!! + bor_IS_VALID_OPTION(ggdb) + if test "$bor_cv_c_ggdb" = "yes"; then + CFLAGS="-ggdb ${CFLAGS}" + fi + + bor_IS_VALID_OPTION(pipe) + if test "$bor_cv_c_pipe" = "yes"; then + CFLAGS="-pipe $CFLAGS" + fi + + WALL_FLAG="-Wall" + C99_FLAG="--std=c99" + MAKEDEP="$CC $sdcc_cv_MM" +else + bor_IS_SUNPRO + if test "$bor_cv_c_compiler_sunpro" = "yes"; then + C99_FLAG="-xc99" + CFLAGS="-xO2 ${C99_FLAG} ${CFLAGS}" + WALL_FLAG= + MAKEDEP="$CC ${C99_FLAG} -xM1" + fi +fi + +AC_SUBST(MAKEDEP) +AC_SUBST(WALL_FLAG) +AC_SUBST(C99_FLAG) + +# Try to append a c99 flag +# ------------------------------------------------------------------------- +AC_PROG_CC_C99 +if test "$ac_cv_prog_cc_c99" != "no"; then + CFLAGS="$ac_cv_prog_cc_c99 ${CFLAGS}" +fi + +# Set standard installation paths +# =========================================================================== + +# In the Makefiles we need paths with '/' as directory separator, even if +# crosscompiling for Win32. +# And we want to preserve the macros (e.g. ${prefix}) in the Makefiles. +# The variables in the Makefiles are replaced by AC_SUBST() +# +# In sdccconf.h the '/' in paths can be replaced by "\\" (normalized), if +# +# The macros are expanded for the header. +# The variables in the header are replaced by AC_*DEFINE*() +# sdccconf_h_dir_separator contains a backslash. +AC_ARG_VAR(sdccconf_h_dir_separator, needed in sdccconf.h: either "/" (default) or "\\") +if test "x${sdccconf_h_dir_separator}" = "x"; then + sdccconf_h_dir_separator="/" +fi + +# Makefiles +########### + +# lib_dir_suffix: +# *nix default: "sdcc/lib" +AC_ARG_VAR(lib_dir_suffix, appended to datadir to define SDCC's library root directory) +if test "${lib_dir_suffix}" = ""; then + lib_dir_suffix="sdcc/lib" +fi +AC_SUBST(lib_dir_suffix) + +AC_SUBST(EXEEXT) + +# sdccconf.h +############ + +AC_DEFINE_UNQUOTED(DIR_SEPARATOR_STRING, "${sdccconf_h_dir_separator}", [XXX]) + +# datadir: +# default: "${prefix}/share" +adl_EXPAND(datadir, "NONE", expanded_datadir) +adl_NORMALIZE_DEFINE_UNQUOTED(expanded_datadir, DATADIR, sdccconf_h_dir_separator) + +# lib suffix +norm_lib_dir_suffix=${lib_dir_suffix} +adl_NORMALIZE_PATH([norm_lib_dir_suffix], [$sdccconf_h_dir_separator]) +AC_DEFINE_UNQUOTED(LIB_DIR_SUFFIX, + DIR_SEPARATOR_STRING "${norm_lib_dir_suffix}", [XXX]) + + +# Generating output files +# =========================================================================== +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT + +# End of configure/configure.in diff --git a/debugger/mcs51/sdcdb.c b/debugger/mcs51/sdcdb.c new file mode 100644 index 0000000..76d92f8 --- /dev/null +++ b/debugger/mcs51/sdcdb.c @@ -0,0 +1,2124 @@ +/*------------------------------------------------------------------------- + sdcdb.c - main source file for sdcdb debugger + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include "sdcdb.h" + +char *ssdirl = DATADIR LIB_DIR_SUFFIX ":" DATADIR LIB_DIR_SUFFIX DIR_SEPARATOR_STRING "small" ; + +#undef DATADIR +#include "symtab.h" +#include "simi.h" +#include "break.h" +#include "cmd.h" +#include "newalloc.h" +#if defined HAVE_LIBREADLINE && HAVE_LIBREADLINE != -1 +#define HAVE_READLINE_COMPLETITION 1 +#endif +#ifdef HAVE_LIBREADLINE +#include <readline/readline.h> +#include <readline/history.h> +#endif /* HAVE_LIBREADLINE */ +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#elif defined _WIN32 +#include <direct.h> +#endif +#ifdef HAVE_SYS_WAIT_H +#include <sys/wait.h> +#endif + +#ifdef SDCDB_DEBUG +int sdcdbDebug = 0; +#endif + +char *currModName = NULL; +cdbrecs *recsRoot = NULL; +set *modules = NULL; /* set of all modules */ +set *functions = NULL; /* set of functions */ +set *symbols = NULL; /* set of symbols */ +set *sfrsymbols = NULL; /* set of symbols of sfr or sbit */ +int nStructs = 0 ; +structdef **structs = NULL; /* all structures */ +int nLinkrecs = 0; +linkrec **linkrecs = NULL; /* all linkage editor records */ +context *currCtxt = NULL; +short fullname = 0; +short showfull = 0; +char userinterrupt = 0; +char nointerrupt = 0; +char contsim = 0; +char *simArgs[40]; +int nsimArgs = 0; +char model_str[20]; +/* fake filename & lineno to make linker */ +char *filename = NULL; +int lineno = 0; +int fatalError = 0; + +static void commandLoop(FILE *cmdfile); +#ifdef HAVE_READLINE_COMPLETITION +char *completionCmdSource(const char *text, int state); +char *completionCmdFile(const char *text, int state); +char *completionCmdInfo(const char *text, int state); +char *completionCmdShow(const char *text, int state); +char *completionCmdListSymbols(const char *text, int state); +char *completionCmdPrintType(const char *text, int state); +char *completionCmdPrint(const char *text, int state); +char *completionCmdDelUserBp(const char *text, int state); +char *completionCmdUnDisplay(const char *text, int state); +char *completionCmdSetUserBp(const char *text, int state); +char *completionCmdSetOption(const char *text, int state); +#else +#define completionCmdSource NULL +#define completionCmdFile NULL +#define completionCmdInfo NULL +#define completionCmdShow NULL +#define completionCmdListSymbols NULL +#define completionCmdPrintType NULL +#define completionCmdPrint NULL +#define completionCmdDelUserBp NULL +#define completionCmdUnDisplay NULL +#define completionCmdSetUserBp NULL +#define completionCmdSetOption NULL +#endif /* HAVE_READLINE_COMPLETITION */ + +/* command table */ +struct cmdtab +{ + const char *cmd; /* command the user will enter */ + int (*cmdfunc)(char *,context *); /* function to execute when command is entered */ +#ifdef HAVE_READLINE_COMPLETITION + rl_compentry_func_t *completion_func; +#else + void *dummy; +#endif /* HAVE_READLINE_COMPLETITION */ + const char *htxt; /* short help text */ +} cmdTab[] = { + /* NOTE:- the search is done from the top, so "break" should + precede the synonym "b" */ + /* break point */ + { "break" , cmdSetUserBp , completionCmdSetUserBp, + "{b}reak\t[LINE | FILE:LINE | FILE:FUNCTION | FUNCTION | *<address>]" + }, + { "tbreak" , cmdSetTmpUserBp , completionCmdSetUserBp/*same as "break"*/, + "tbreak\t[LINE | FILE:LINE | FILE:FUNCTION | FUNCTION | *<address>]" + }, + { "b" , cmdSetUserBp , completionCmdSetUserBp , NULL,}, + + { "jump" , cmdJump , NULL, + "jump\tContinue program being debugged at specified line or address\n" + "\t[LINE | FILE:LINE | *<address>]", + }, + { "clear" , cmdClrUserBp , completionCmdSetUserBp/*same as "break"*/, + "{cl}ear\t[LINE | FILE:LINE | FILE:FUNCTION | FUNCTION]" + }, + { "cl" , cmdClrUserBp , completionCmdSetUserBp/*same as "break"*/ , + NULL + }, + { "continue" , cmdContinue , NULL, + "{c}ontinue\tContinue program being debugged, after breakpoint." + }, + { "condition" , cmdCondition , completionCmdDelUserBp/*same as "delete"*/, + "condition brkpoint_number expr\tSet condition for breakpoint." + }, + { "ignore" , cmdIgnore , completionCmdDelUserBp/*same as "delete"*/, + "ignore brkpoint_number count\tSet ignore count for breakpoint." + }, + { "commands" , cmdCommands , completionCmdDelUserBp/*same as "delete"*/, + "commands [brkpoint_number]\tSetting commands for breakpoint." + }, + { "c" , cmdContinue , NULL , + NULL + }, + { "disassemble",cmdDisasmF , NULL, + "disassemble [startaddr [endaddress]]\tdisassemble asm commands" + }, + { "delete" , cmdDelUserBp , completionCmdDelUserBp, + "{d}elete n\tclears break point number n" + }, + { "display" , cmdDisplay , completionCmdPrint/*same as "print"*/, + "display [/<fmt>] [<variable>]\tprint value of given variable each time the program stops" + }, + { "undisplay" , cmdUnDisplay , completionCmdUnDisplay, + "undisplay [<variable>]\tdon't display this variable or all" + }, + { "down" , cmdDown , NULL, + "down\tSelect and print stack frame called by this one.\n" + "\tAn argument says how many frames down to go." + }, + { + "up" , cmdUp , NULL, + "up\tSelect and print stack frame that called this one.\n" + "\tAn argument says how many frames up to go." + }, + { "d" , cmdDelUserBp , completionCmdDelUserBp, + NULL + }, + { "info" , cmdInfo , completionCmdInfo, + "info <break stack frame registers all-registers line source functions symbols variables>\t" + "list all break points, call-stack, frame or register information" + }, + { "listasm" , cmdListAsm , NULL, + "listasm {la}\tlist assembler code for the current C line" + }, + { "la" , cmdListAsm , NULL, + NULL + }, + { "ls" , cmdListSymbols , completionCmdListSymbols, + "ls,lf,lm\tlist symbols,functions,modules" + }, + { "lf" , cmdListFunctions, completionCmdListSymbols, + NULL + }, + { "lm" , cmdListModules , completionCmdListSymbols, + NULL + }, + { "list" , cmdListSrc , completionCmdSetUserBp/*same as "break"*/, + "{l}ist\t[LINE | FILE:LINE | FILE:FUNCTION | FUNCTION]" + }, + { "l" , cmdListSrc , completionCmdSetUserBp/*same as "break"*/, + NULL + }, + { "show" , cmdShow , completionCmdShow, + "show <copying warranty>\tcopying & distribution terms, warranty" + }, + { "set" , cmdSetOption , completionCmdSetOption, + "set <srcmode>\ttoggle between c/asm.\nset variable <var> = >value\tset variable to new value" + }, + { "stepi" , cmdStepi , NULL, + "stepi\tStep one instruction exactly." + }, + { "step" , cmdStep , NULL, + "{s}tep\tStep program until it reaches a different source line." + }, + { "source" , cmdSource , completionCmdSource, + "source <FILE>\tRead commands from a file named FILE." + }, + { "s" , cmdStep , NULL, + NULL + }, + { "nexti" , cmdNexti , NULL, + "nexti\tStep one instruction, but proceed through subroutine calls." + }, + { "next" , cmdNext , NULL, + "{n}ext\tStep program, proceeding through subroutine calls." + }, + { "n" , cmdNext , NULL, + NULL + }, + { "run" , cmdRun , NULL, + "{r}un\tStart debugged program. " + }, + { "r" , cmdRun , NULL, + NULL + }, + { "ptype" , cmdPrintType , completionCmdPrintType, + "{pt}ype <variable>\tprint type information of a variable" + }, + { "pt" , cmdPrintType , NULL, + NULL + }, + { "print" , cmdPrint , completionCmdPrintType, + "{p}rint <variable>\tprint value of given variable" + }, + { "output" , cmdOutput , completionCmdPrint/*same as "print"*/, + "output <variable>\tprint value of given variable without $ and newline" + }, + { "p" , cmdPrint , completionCmdPrintType, + NULL + }, + { "file" , cmdFile , completionCmdFile, + "file <filename>\tload symbolic information from <filename>" + }, + { "frame" , cmdFrame , NULL, + "{fr}ame\tprint information about the current Stack" + }, + { "finish" , cmdFinish , NULL, + "{fi}nish\texecute till return of current function" + }, + { "fi" , cmdFinish , NULL, + NULL + }, + { "where" , cmdWhere , NULL, + "where\tprint stack" + }, + { "fr" , cmdFrame , NULL, + NULL + }, + { "f" , cmdFrame , NULL, + NULL + }, + { "x /i" , cmdDisasm1 , NULL, + "x\tdisassemble one asm command" + }, + { "!" , cmdSimulator , NULL, + "!<simulator command>\tsend a command directly to the simulator" + }, + { "." , cmdSimulator , NULL, + ".{cmd}\tswitch from simulator or debugger command mode" + }, + { "help" , cmdHelp , NULL, + "{h|?}elp\t[CMD_NAME | 0,1,2,3(help page)] (general help or specific help)" + }, + { "?" , cmdHelp , NULL, + NULL + }, + { "h" , cmdHelp , NULL, + NULL + }, + { "quit" , cmdQuit , NULL, + "{q}uit\t\"Watch me now. I'm going Down. My name is Bobby Brown\"" + }, + { "q" , cmdQuit , NULL, + NULL + } +}; + +/*-----------------------------------------------------------------*/ +/* trimming functions */ +/*-----------------------------------------------------------------*/ +char *trim_left(char *s) +{ + while (isspace(*s)) + ++s; + + return s; +} + +char *trim_right(char *s) +{ + char *p = &s[strlen(s) - 1]; + + while (p >= s && isspace(*p)) + --p; + *++p = '\0'; + + return s; +} + +char *trim(char *s) +{ + return trim_right(trim_left(s)); +} + +/*-----------------------------------------------------------------*/ +/* gc_strdup - make a string duplicate garbage collector aware */ +/*-----------------------------------------------------------------*/ +char *gc_strdup(const char *s) +{ + char *ret; + ret = Safe_malloc(strlen(s)+1); + strcpy(ret, s); + return ret; +} + +/*-----------------------------------------------------------------*/ +/* alloccpy - allocate copy and return a new string */ +/*-----------------------------------------------------------------*/ +char *alloccpy ( char *s, int size) +{ + char *d; + + if (!size) + return NULL; + + d = Safe_malloc(size+1); + memcpy(d,s,size); + d[size] = '\0'; + + return d; +} + +/*-----------------------------------------------------------------*/ +/* resize - resizes array of type with new size */ +/*-----------------------------------------------------------------*/ +void **resize (void **array, int newSize) +{ + void **vptr; + + if (array) + vptr = Safe_realloc(array, newSize*(sizeof(void **))); + else + vptr = calloc(1, sizeof(void **)); + + if (!vptr) + { + fprintf(stderr, "sdcdb: out of memory\n"); + exit(1); + } + + return vptr; +} + +/*-----------------------------------------------------------------*/ +/* readCdb - reads the cdb files & puts the records into cdbLine */ +/* linked list */ +/*-----------------------------------------------------------------*/ +static int readCdb (FILE *file) +{ + cdbrecs *currl; + char buffer[1024]; + char *bp; + + if (!(bp = fgets(buffer, sizeof(buffer), file))) + return 0; + + currl = Safe_calloc(1, sizeof(cdbrecs)); + recsRoot = currl; + + while (1) + { + /* make sure this is a cdb record */ + if (strchr("STLFM",*bp) && *(bp+1) == ':') + { + /* depending on the record type */ + + switch (*bp) + { + case 'S': + /* symbol record */ + currl->type = SYM_REC; + break; + case 'T': + currl->type = STRUCT_REC; + break; + case 'L': + currl->type = LNK_REC; + break; + case 'F': + currl->type = FUNC_REC; + break; + case 'M': + currl->type = MOD_REC ; + break; + } + + bp += 2; + currl->line = Safe_malloc(strlen(bp)); + strncpy(currl->line, bp, strlen(bp)-1); + currl->line[strlen(bp)-1] = '\0'; + } + + if (!(bp = fgets(buffer, sizeof(buffer), file))) + break; + + if (feof(file)) + break; + + currl->next = Safe_calloc(1, sizeof(cdbrecs)); + currl = currl->next; + } + + return (recsRoot->line ? 1 : 0); +} + +/*-----------------------------------------------------------------*/ +/* searchDirsFname - search directory list & return the filename */ +/*-----------------------------------------------------------------*/ +char *searchDirsFname (char *fname) +{ + char *dirs , *sdirs; + FILE *rfile = NULL; + char buffer[128]; + + /* first try the current directory */ + if ((rfile = fopen(fname, "r"))) + { + fclose(rfile); + return strdup(fname) ; + } + + if (!ssdirl) + return strdup(fname); + + /* make a copy of the source directories */ + dirs = sdirs = strdup(ssdirl); + + /* assume that the separator is ':' + and try for each directory in the search list */ + dirs = strtok(dirs, ":"); + while (dirs) + { + if (dirs[strlen(dirs)] == '/') + sprintf(buffer, "%s%s", dirs, fname); + else + sprintf(buffer, "%s/%s", dirs, fname); + if ((rfile = fopen(buffer, "r"))) + break; + dirs = strtok(NULL, ":"); + } + + free(sdirs); + if (rfile) + { + fclose(rfile); + return strdup(buffer); + } + else //not found + { + char *p, *found; + +// sprintf(buffer, "%s", fname); + p = fname; + while (NULL != (p = strchr(p, '_'))) + { + *p = '.'; // try again with '_' replaced by '.' + if (NULL != (found = searchDirsFname(fname))) + return found; + *p = '_'; // not found, restore '_' and try next '_' + } + } + return NULL; +} + +/*-----------------------------------------------------------------*/ +/* searchDirsFopen - go thru list of directories for filename given*/ +/*-----------------------------------------------------------------*/ +FILE *searchDirsFopen(char *fname) +{ + char *dirs , *sdirs; + FILE *rfile = NULL; + char buffer[128]; + + /* first try the current directory */ + if ((rfile = fopen(fname, "r"))) + return rfile; + + if (!ssdirl) + return NULL; + + /* make a copy of the source directories */ + dirs = sdirs = strdup(ssdirl); + + /* assume that the separator is ':' + and try for each directory in the search list */ + dirs = strtok(dirs, ":"); + while (dirs) + { + sprintf(buffer, "%s/%s", dirs, fname); + if ((rfile = fopen(buffer, "r"))) + break; + dirs = strtok(NULL, ":"); + } + + free(sdirs); + return rfile ; +} + +/*-----------------------------------------------------------------*/ +/* loadFile - loads a file into module buffer */ +/*-----------------------------------------------------------------*/ +srcLine **loadFile (char *name, int *nlines) +{ + FILE *mfile; + char buffer[512]; + char *bp; + srcLine **slines = NULL; + + if (!(mfile = searchDirsFopen(name))) + { + fprintf(stderr, "sdcdb: cannot open module %s -- use '--directory=<source directory> option\n", name); + return NULL; + } + + while ((bp = fgets(buffer, sizeof(buffer), mfile))) + { + (*nlines)++; + + slines = (srcLine **)resize((void **)slines, *nlines); + + slines[(*nlines)-1] = Safe_calloc(1, sizeof(srcLine)); + slines[(*nlines)-1]->src = alloccpy(bp, strlen(bp)); + slines[(*nlines)-1]->addr = INT_MAX; + } + + fclose(mfile); + return slines; +} + + +/*-----------------------------------------------------------------*/ +/* loadModules - reads the source files into module structure */ +/*-----------------------------------------------------------------*/ +static void loadModules (void) +{ + cdbrecs *loop; + module *currMod; + char *rs; + + /* go thru the records & find out the module + records & load the modules specified */ + for ( loop = recsRoot ; loop ; loop = loop->next ) + { + switch (loop->type) + { + /* for module records do */ + case MOD_REC: + currMod = parseModule(loop->line, TRUE); + currModName = currMod->name ; + + /* search the c source file and load it into buffer */ + currMod->cfullname = searchDirsFname(currMod->c_name); + currMod->cLines = loadFile (currMod->c_name, &currMod->ncLines); + + /* do the same for the assembler file */ + currMod->afullname = searchDirsFname(currMod->asm_name); + currMod->asmLines = loadFile (currMod->asm_name, &currMod->nasmLines); + break; + + /* if this is a function record */ + case FUNC_REC: + parseFunc(loop->line); + break; + + /* if this is a structure record */ + case STRUCT_REC: + parseStruct(loop->line); + break; + + /* if symbol then parse the symbol */ + case SYM_REC: + parseSymbol(loop->line, &rs, 2); + break; + + case LNK_REC: + parseLnkRec(loop->line); + break; + } + } +} + +/*-----------------------------------------------------------------*/ +/* generate extra sets of sfr and sbit symbols */ +/*-----------------------------------------------------------------*/ +static void specialFunctionRegs (void) +{ + symbol *sym; + for (sym = setFirstItem(symbols); sym; sym = setNextItem(symbols)) + { + if ( sym->addrspace == 'I' || sym->addrspace == 'J') + { + addSet(&sfrsymbols, sym); + } + } +} +/*-----------------------------------------------------------------*/ +/* functionPoints - determine the execution points within a func */ +/*-----------------------------------------------------------------*/ +static void functionPoints (void) +{ + function *func; + symbol *sym; + exePoint *ep; + + // add _main dummy for runtime env + if ((func = needExtraMainFunction())) + { + function *func1; + + /* alloc new _main function */ + func1 = Safe_calloc(1, sizeof(function)); + *func1 = *func; + func1->sym = Safe_calloc(1, sizeof(symbol)); + *func1->sym = *func->sym; + func1->sym->name = alloccpy("_main", 5); + func1->sym->rname = alloccpy("G$_main$0$", 10); + /* TODO must be set by symbol information */ + func1->sym->addr = 0; + func1->sym->eaddr = 0x2f; + addSet(&functions, func1); + } + + /* for all functions do */ + for ( func = setFirstItem(functions); func; func = setNextItem(functions)) + { + int j ; + module *mod; + + sym = func->sym; + + Dprintf(D_sdcdb, ("sdcdb: func '%s' has entry '0x%x' exit '0x%x'\n", + func->sym->name, + func->sym->addr, + func->sym->eaddr)); + + if (!func->sym->addr && !func->sym->eaddr) + continue; + + /* for all source lines in the module find + the ones with address >= start and <= end + and put them in the point */ + mod = NULL ; + if (! applyToSet(modules, moduleWithName, func->modName, &mod)) + continue; + func->mod = mod; + func->entryline= INT_MAX-2; + func->exitline = 0; + func->aentryline = INT_MAX-2; + func->aexitline = 0; + + /* do it for the C Lines first */ + for ( j = 0 ; j < mod->ncLines ; j++ ) + { + if (mod->cLines[j]->addr < INT_MAX && + mod->cLines[j]->addr >= sym->addr && + mod->cLines[j]->addr <= sym->eaddr ) + { + /* add it to the execution point */ + if (func->entryline > j) + func->entryline = j; + + if (func->exitline < j) + func->exitline = j; + + ep = Safe_calloc(1, sizeof(exePoint)); + ep->addr = mod->cLines[j]->addr ; + ep->line = j; + ep->block= mod->cLines[j]->block; + ep->level= mod->cLines[j]->level; + addSet(&func->cfpoints, ep); + } + } + /* check double line execution points of module */ + for (ep = setFirstItem(mod->cfpoints); ep; ep = setNextItem(mod->cfpoints)) + { + if (ep->addr >= sym->addr && ep->addr <= sym->eaddr ) + { + addSet(&func->cfpoints, ep); + } + } + /* do the same for asm execution points */ + for ( j = 0 ; j < mod->nasmLines ; j++ ) + { + if (mod->asmLines[j]->addr < INT_MAX && + mod->asmLines[j]->addr >= sym->addr && + mod->asmLines[j]->addr <= sym->eaddr ) + { + exePoint *ep ; + /* add it to the execution point */ + if (func->aentryline > j) + func->aentryline = j; + + if (func->aexitline < j) + func->aexitline = j; + + /* add it to the execution point */ + ep = Safe_calloc(1, sizeof(exePoint)); + ep->addr = mod->asmLines[j]->addr; + ep->line = j; + addSet(&func->afpoints, ep); + } + } + if ( func->entryline == INT_MAX-2 ) + func->entryline = 0; + if ( func->aentryline == INT_MAX-2 ) + func->aentryline = 0; + +#ifdef SDCDB_DEBUG + if (!( D_sdcdb & sdcdbDebug)) + continue; + + Dprintf(D_sdcdb, ("sdcdb: function '%s' has the following C exePoints\n", + func->sym->name)); + { + exePoint *ep; + + for (ep = setFirstItem(func->cfpoints); ep; ep = setNextItem(func->cfpoints)) + { + Dprintf(D_sdcdb, ("sdcdb: {0x%x,%d} %s", + ep->addr, ep->line+1, mod->cLines[ep->line]->src)); + } + + Dprintf(D_sdcdb, ("sdcdb: and the following ASM exePoints\n")); + for (ep = setFirstItem(func->afpoints); ep; ep = setNextItem(func->afpoints)) + { + Dprintf (D_sdcdb, ("sdcdb: {0x%x,%d} %s", + ep->addr, ep->line+1, mod->asmLines[ep->line]->src)); + } + } +#endif + } +} + + +/*-----------------------------------------------------------------*/ +/* setEntryExitBP - set the entry & exit Break Points for functions*/ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(setEntryExitBP) +{ + function *func = item; + + if (func->sym && func->sym->addr && func->sym->eaddr) + { + /* set the entry break point */ + setBreakPoint (func->sym->addr, CODE, FENTRY, + fentryCB, func->mod->c_name, func->entryline); + + /* set the exit break point */ + setBreakPoint (func->sym->eaddr, CODE, FEXIT, + fexitCB, func->mod->c_name, func->exitline); + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdFile - load file into the debugger */ +/*-----------------------------------------------------------------*/ +int cmdFile (char *s,context *cctxt) +{ + FILE *cdbFile; + char buffer[128]; + char *bp; + + s = trim_left(s); + + if (!*s) + { + fprintf(stdout, "No exec file now.\nNo symbol file now.\n"); + return 0; + } + + sprintf(buffer, "%s.cdb", s); + /* try creating the cdbfile */ + if (!(cdbFile = searchDirsFopen(buffer))) + { + fprintf(stdout, "Cannot open file\"%s\", no symbolic information loaded\n", buffer); + // return 0; + } + + /* allocate for context */ + currCtxt = Safe_calloc(1, sizeof(context)); + + if (cdbFile) + { + /* read in the debug information */ + if (!readCdb (cdbFile)) + { + fprintf(stdout,"No symbolic information found in file %s.cdb\n",s); + //return 0; + } + } + + /* parse and load the modules required */ + loadModules(); + + /* determine the execution points for this module */ + functionPoints(); + + /* extract known special function registers */ + specialFunctionRegs(); + + /* start the simulator & setup connection to it */ +#ifdef _WIN32 + if (INVALID_SOCKET == sock) +#else + if ( sock == -1 ) +#endif + openSimulator((char **)simArgs, nsimArgs); + fprintf(stdout, "%s", simResponse()); + /* now send the filename to be loaded to the simulator */ + sprintf(buffer, "%s.ihx", s); + bp = searchDirsFname(buffer); + simLoadFile(bp); + free(bp); + + /* set the break points + required by the debugger . i.e. the function entry + and function exit break points */ + applyToSet(functions, setEntryExitBP); + + setMainContext(); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdSource - read commands from file */ +/*-----------------------------------------------------------------*/ +int cmdSource (char *s, context *cctxt) +{ + FILE *cmdfile; + + s = trim(s); + + if (!( cmdfile = searchDirsFopen(s))) + { + fprintf(stderr,"commandfile '%s' not found\n",s); + return 0; + } + commandLoop( cmdfile ); + fclose( cmdfile ); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdHelp - help command */ +/*-----------------------------------------------------------------*/ +#define TEXT_OFFSET 24 + +static void printHelpLine(const char *htxt, int offs) +{ + static char *spaces = NULL; + const char *p; + int state = 0; + + if (NULL == spaces) + { + spaces = Safe_malloc(TEXT_OFFSET + 1); + memset(spaces, ' ', TEXT_OFFSET); + spaces[TEXT_OFFSET] = '\0'; + } + + p = htxt; + + do + { + const char *ps = p; + int len; + while (*p && *p != '\t' && *p != '\n') + ++p; + len = p - ps; + + if (state == 0) + { + printf("%.*s%.*s", offs, spaces, len, ps); /* command text */ + + if (len >= TEXT_OFFSET - offs) + printf("\n%s", spaces); + else + printf("%.*s", TEXT_OFFSET - offs - len, spaces); + } + else + { + printf("%.*s\n", len, ps); /* help text */ + } + state = *p == '\t'; + } + while (*p++); +} + +int cmdHelp (char *s, context *cctxt) +{ + int i ; + int endline = 999; + int startline = 0; + + s = trim_left(s); + + if (isdigit(*s)) + { + endline = ((*s - '0') * 20) + 20; + if (endline > 0) + startline = endline - 20; + } + else if (*s) + { + for (i = 0 ; i < (sizeof(cmdTab)/sizeof(struct cmdtab)) ; i++) + { + if ((cmdTab[i].htxt) && !strcmp(cmdTab[i].cmd,s)) + { + printHelpLine(cmdTab[i].htxt, 0); + break; + } + } + return 0; + } + + for (i = 0 ; i < (sizeof(cmdTab)/sizeof(struct cmdtab)) ; i++) + { + /* command string matches */ + + if ((cmdTab[i].htxt) && (i >= startline)) + printHelpLine(cmdTab[i].htxt, 0); + if (i == endline) + break; + } + + return 0; +} + +#define MAX_CMD_LEN 512 +static char cmdbuff[MAX_CMD_LEN]; +static int sim_cmd_mode = 0; + +/*----------------------------------------------------------------- + interpretCmd - interpret and do the command. Return 0 to continue, + return 1 to exit program. +|-----------------------------------------------------------------*/ +int interpretCmd (char *s) +{ + static char *pcmd = NULL; + int i ; + int rv = 0 ; + + /* if nothing & previous command exists then + execute the previous command again */ + if (*s == '\n' && pcmd) + strcpy(s,pcmd); + + /* if previous command exists & is different + from the current command then copy it */ + if (pcmd) + { + if (strcmp(pcmd,s)) + { + free(pcmd); + pcmd = strdup(s); + } + } + else + { + pcmd = strdup(s); + } + + /* trim trailing blanks */ + s = trim_right(s); + + if (sim_cmd_mode) + { + if (strcmp(s,".") == 0) + { + sim_cmd_mode = 0; + return 0; + } + else if (s[0] == '.') + { + /* kill the preceeding '.' and pass on as SDCDB command */ + char *s1 = s+1; + char *s2 = s; + while (*s1 != 0) + *s2++ = *s1++; + *s2 = 0; + } + else + { + cmdSimulator (s, currCtxt); + return 0; + } + } + else + { + if (strcmp(s,".") ==0) + { + sim_cmd_mode = 1; + return 0; + } + } + + for (i = 0 ; i < (sizeof(cmdTab)/sizeof(struct cmdtab)) ; i++) + { + /* command string matches */ + if (strncmp(s,cmdTab[i].cmd,strlen(cmdTab[i].cmd)) == 0) + { + if (!cmdTab[i].cmdfunc) + return 1; + + rv = (*cmdTab[i].cmdfunc)(s + strlen(cmdTab[i].cmd),currCtxt); + + /* if full name then give the file name & position */ + if (fullname && showfull && currCtxt && currCtxt->func) + { + showfull = 0; + if (srcMode == SRC_CMODE) + fprintf(stdout,"\032\032%s:%d:1:beg:0x%08x\n", + currCtxt->func->mod->cfullname, + currCtxt->cline+1,currCtxt->addr); + else + fprintf(stdout,"\032\032%s:%d:1:beg:0x%08x\n", + currCtxt->func->mod->afullname, + currCtxt->asmline,currCtxt->addr); + displayAll(currCtxt); + } + goto ret; + } + } + fprintf(stdout,"Undefined command: \"%s\". Try \"help\".\n",s); + +ret: + return rv; +} + +static FILE *actualcmdfile=NULL ; +static char *actualcmds=NULL; +static int stopcmdlist; +/*-----------------------------------------------------------------*/ +/* getNextCmdLine get additional lines used by special commands */ +/*-----------------------------------------------------------------*/ +char *getNextCmdLine(void) +{ + //fprintf(stderr,"getNextCmdLine() actualcmdfile=%p\n",actualcmdfile); + if (!actualcmdfile) + return NULL; + fprintf(stdout,">"); + fflush(stdout); + if (fgets(cmdbuff,sizeof(cmdbuff),actualcmdfile) == NULL) + { + // fprintf(stderr,"getNextCmdLine() returns null\n"); + return NULL; + } + //fprintf(stderr,"getNextCmdLine() returns: %s",cmdbuff); + return cmdbuff; +} + +void setCmdLine( char *cmds ) +{ + actualcmds = cmds; +} + +void stopCommandList() +{ + stopcmdlist = 1; +} + +#ifdef HAVE_READLINE_COMPLETITION +// helper function for doing readline completion. +// input: toknum=index of token to find (0=first token) +// output: *start=first character index of the token, +// or the index of '\0' +// *end=first blank character right after the token, +// or the index of '\0' +// return value: 0=token not found, 1=token found +int completionHelper_GetTokenNumber(int toknum, int *start, int *end) +{ + int tok_index; + const char *p = rl_line_buffer; + + tok_index = 0; + *start = *end = 0; + while (p[*end] != 0) + { + // start = skip blanks from end + *start = *end; + while (p[*start] && isspace( p[*start] )) + (*start)++; + + // end = skip non-blanks from start + *end = *start; + while (p[*end] && !isspace( p[*end] )) + (*end)++; + + if (tok_index == toknum) + return 1; // found + + tok_index++; + } + + return 0; // not found +} + +// helper function for doing readline completion. +// returns the token number that we were asked to complete. +// 0=first token (command name), 1=second token... +int completionHelper_GetCurrTokenNumber() +{ + int toknum, start, end; + + toknum = start = end = 0; + while (1) + { + if (!completionHelper_GetTokenNumber(toknum, &start, &end)) + return toknum; + + if (rl_point <= end) + return toknum; + + toknum++; + } +} + +// exapmle for vallist on entry: +// "copying\0warranty\0"; +char *completionCompleteFromStrList(const char *text, int state, char *vallist) +{ + static char *ptr; + int len; + + if (state == 0) + ptr = vallist; + else + ptr += strlen(ptr)+1; + + len = strlen(text); + while (*ptr) + { + if ( (len < strlen(ptr)) && !strncmp(text, ptr, len) ) + return strdup(ptr); + + ptr += strlen(ptr)+1; + } + + return NULL; +} + +// readline library completion function. +// completes from the list of all sdcdb command. +char *completionCommandsList(const char *text, int state) +{ + static int i = 0; + + if (state == 0) // new completion? + { // yes, only complete if this is the first token on the line. + int ok = 0; // try to complete this request? + char *p = rl_line_buffer; + + // skip blanks + while (p && isspace(*p)) + { + if (p-rl_line_buffer == rl_point) + ok = 1; + p++; + } + + while (p && !isspace(*p)) + { + if (p-rl_line_buffer == rl_point) + ok = 1; + p++; + } + + if (p-rl_line_buffer == rl_point) + ok = 1; + + if ( !ok ) + return NULL; // no more completions + + i = 0; // ok, gonna complete. initialize static variable. + } + else + { + i++; + } + + for (; i < (sizeof(cmdTab)/sizeof(struct cmdtab)) ; i++) + { + int len = strlen(text); + if (len <= strlen(cmdTab[i].cmd)) + { + if (strncmp(text,cmdTab[i].cmd,len) == 0) + return strdup(cmdTab[i].cmd); + } + } + + return NULL; // no more completions +} + +// readline library completion function. +// completes from the list of symbols. +char *completionSymbolName(const char *text, int state) +{ + static symbol *sy; + + if (state == 0) // new completion? + sy = setFirstItem(symbols); // yes + else + sy = setNextItem(symbols); + + for (; sy != NULL; ) + { + int len = strlen(text); + if (len <= strlen(sy->name)) + { + if (strncmp(text,sy->name,len) == 0) + return strdup(sy->name); + } + + sy = setNextItem(symbols); + } + return NULL; +} + +// readline library completion function. +// completes from the list known functions. +// module_flag - if false, ignore function module name +// if true, compare against module_name:fnction_name +char *completionFunctionName(const char *text, int state, int module_flag) +{ + static function *f; + + if (state == 0) // new completion? + f = setFirstItem(functions); // yes + else + f = setNextItem(functions); + + for (; f != NULL; ) + { + int text_len = strlen(text); + + if (!module_flag) + { + if (text_len <= strlen(f->sym->name) && + !strncmp(text,f->sym->name,text_len)) + { + return strdup(f->sym->name); + } + } + else + { + int modname_len = strlen(f->mod->c_name); + int funcname_len = strlen(f->sym->name); + char *functext = malloc(modname_len+funcname_len+2); + //assert(functext); + strcpy(functext,f->mod->c_name); + strcat(functext,":"); + strcat(functext,f->sym->name); + if (text_len <= strlen(functext) && + !strncmp(text,functext,text_len)) + { + return functext; + } + else + { + free(functext); + } + } + f = setNextItem(functions); + } + return NULL; +} + +// readline library completion function. +// completes from the list known modules. +char *completionModuleName(const char *text, int state) +{ + static module *m; + + if (state == 0) // new completion? + m = setFirstItem(modules); // yes + else + m = setNextItem(modules); + + for (; m != NULL; ) + { + int len = strlen(text); + if ( (len <= strlen(m->c_name)) && + !strncmp(text,m->c_name,len) ) + { + return strdup(m->c_name); + } + + if ( (len <= strlen(m->asm_name)) && + (strncmp(text,m->asm_name,len) == 0) ) + { + return strdup(m->asm_name); + } + + m = setNextItem(modules); + } + return NULL; +} + +// readline completion function for "file" command +char *completionCmdFile(const char *text, int state) +{ + if (state == 0) + { + if (completionHelper_GetCurrTokenNumber() != 1) + return NULL; + } + + // we use filename_completion_function() from the readline library. + return rl_filename_completion_function(text, state); +} + +// readline completion function for "source" command +char *completionCmdSource(const char *text, int state) +{ + return completionCmdFile(text, state); +} + +// readline completion function for "info" command +char *completionCmdInfo(const char *text, int state) +{ + if (state == 0) + { + if (completionHelper_GetCurrTokenNumber() != 1) + return NULL; + } + + return completionCompleteFromStrList(text, state, + "break\0stack\0frame\0registers\0all-registers\0" + "line\0source\0functions\0symbols\0variables\0"); +} + +// readline completion function for "show" command +char *completionCmdShow(const char *text, int state) +{ + if (state == 0) + { + if (completionHelper_GetCurrTokenNumber() != 1) + return NULL; + } + return completionCompleteFromStrList(text, state, "copying\0warranty\0"); +} + +// readline completion function for "la" command +char *completionCmdListSymbols(const char *text, int state) +{ + if (state == 0) + { + if (completionHelper_GetCurrTokenNumber() != 1) + return NULL; + } + return completionCompleteFromStrList(text, state, "v1\0v2\0"); +} + +char *completionCmdPrintType(const char *text, int state) +{ + if (state == 0) + { + if (completionHelper_GetCurrTokenNumber() != 1) + return NULL; + } + return completionSymbolName(text, state); +} + +char *completionCmdPrint(const char *text, int state) +{ + if (state == 0) + { + int i = completionHelper_GetCurrTokenNumber(); + if (i != 1 && i != 2) + return NULL; + } + return completionSymbolName(text, state); +} + +char *completionCmdDelUserBp(const char *text, int state) +{ + static breakp *bp; + static int k; + + if (state == 0) + { + if (completionHelper_GetCurrTokenNumber() != 1) + return NULL; + + if (!userBpPresent) + return NULL; + + bp = hTabFirstItem(bptable,&k); + } + else + { + bp = hTabNextItem(bptable,&k); + } + + for ( ; bp ; bp = hTabNextItem(bptable,&k)) + { + if (bp->bpType == USER || bp->bpType == TMPUSER) + { + char buff[20]; + sprintf(buff, "%d", bp->bpnum); + return strdup(buff); + } + } + + return NULL; +} + +// readline completion function for "undisplay" command +char *completionCmdUnDisplay(const char *text, int state) +{ + static dsymbol *dsym; + + if (state == 0) + { + if (completionHelper_GetCurrTokenNumber() != 1) + return NULL; + dsym = setFirstItem(dispsymbols); + } + + if (dsym) + { + char buff[30]; + sprintf(buff, "%d", dsym->dnum); + dsym = setNextItem(dispsymbols); + return strdup(buff); + } + return NULL; +} + +char *completionCmdSetUserBp(const char *text, int state) +{ + static int internal_state; // 0=calling completionFunctionName(text, state, 0) + // 1=calling completionFunctionName(text, 1, 1) + if (state == 0) + { + if (completionHelper_GetCurrTokenNumber() != 1) + return NULL; + + internal_state = 0; + } + if (internal_state == 0) + { + char *p = completionFunctionName(text, state, 0); + if (p) + return p; + internal_state = 1; + return completionFunctionName(text, 0, 1); + } + else + { + return completionFunctionName(text, 1, 1); + } +} + +char *completionCmdSetOption(const char *text, int state) +{ + static int currtok; + + if (state == 0) + { + int start,end; + + currtok = completionHelper_GetCurrTokenNumber(); + + if (currtok == 2 || currtok == 3) + { + // make sure token 1 == "variable" + completionHelper_GetTokenNumber(1, &start, &end); + if (end - start != 8 || + strncmp(rl_line_buffer+start,"variable",8)) + { + return NULL; + } + } + else if (currtok != 1) + { + return NULL; + } + } + + switch (currtok) + { + case 1: + return completionCompleteFromStrList(text, state, +#ifdef SDCDB_DEBUG + "debug\0" +#endif + "srcmode\0listsize\0variable\0"); + case 2: + return completionSymbolName(text, state); + + case 3: + return completionCompleteFromStrList(text, state, "=\0"); + } + return NULL; +} + +// our main readline completion function +// calls the other completion functions as needed. +char *completionMain(const char *text, int state) +{ + static rl_compentry_func_t *compl_func; + int i, start, end, len; + + if (state == 0) // new completion? + { + compl_func = NULL; + + if (completionHelper_GetCurrTokenNumber() == 0) + { + compl_func = &completionCommandsList; + } + else + { // not completing first token, find the right completion + // function according to the first token the user typed. + completionHelper_GetTokenNumber(0, &start, &end); + len = end-start; + + for (i=0; i < (sizeof(cmdTab)/sizeof(struct cmdtab)) ; i++) + { + if (!strncmp(rl_line_buffer+start,cmdTab[i].cmd,len) && + cmdTab[i].cmd[len] == '\0') + { + compl_func = cmdTab[i].completion_func; + break; + } + } + } + if (!compl_func) + return NULL; + } + + return (*compl_func)(text,state); +} +#endif /* HAVE_READLINE_COMPLETITION */ + +/*-----------------------------------------------------------------*/ +/* commandLoop - the main command loop or loop over command file */ +/*-----------------------------------------------------------------*/ +static void commandLoop(FILE *cmdfile) +{ + char *line, save_ch, *s; +#ifdef HAVE_LIBREADLINE + char *line_read; + + FILE *old_rl_instream, *old_rl_outstream; + actualcmdfile = cmdfile; + +#ifdef HAVE_READLINE_COMPLETITION + rl_completion_entry_function = completionMain; +#endif /* HAVE_READLINE_COMPLETITION */ + rl_readline_name = "sdcdb"; // Allow conditional parsing of the ~/.inputrc file. + + // save readline's input/output streams + // this is done to support nested calls to commandLoop() + // i wonder if it works... + old_rl_instream = rl_instream; + old_rl_outstream = rl_outstream; + + // set new streams for readline + if ( cmdfile == stdin ) + rl_instream = rl_outstream = NULL; // use stdin/stdout pair + else + rl_instream = rl_outstream = cmdfile; + + while (1) + { + if ( cmdfile == stdin ) + { + if (sim_cmd_mode) + line_read = (char*)readline ("(sim) "); + else + line_read = (char*)readline ("(sdcdb) "); + } + else + line_read = (char*)readline (""); + + if (line_read) + { + /* If the line has any text in it, + save it on the history. */ + if (line_read && *line_read) + add_history (line_read); + + // FIX: readline returns malloced string. + // should check the source to verify it can be used + // directly. for now - just copy it to cmdbuff. + strcpy(cmdbuff,line_read); +#if defined(_WIN32) || defined(HAVE_RL_FREE) + rl_free(line_read); +#else + free(line_read); +#endif + line_read = NULL; + } + else + { + break; // EOF + } +#else /* HAVE_LIBREADLINE */ + actualcmdfile = cmdfile; + + while (1) + { + if ( cmdfile == stdin ) + { + if (sim_cmd_mode) + printf("(sim) "); + else + fprintf(stdout,"(sdcdb) "); + fflush(stdout); + } + //fprintf(stderr,"commandLoop actualcmdfile=%p cmdfile=%p\n", + // actualcmdfile,cmdfile); + if (fgets(cmdbuff,sizeof(cmdbuff),cmdfile) == NULL) + break; +#endif /* HAVE_LIBREADLINE */ + + if (interpretCmd(cmdbuff)) + break; + + while ( actualcmds ) + { + strcpy(cmdbuff,actualcmds); + actualcmds = NULL; + stopcmdlist= 0; + for ( line = cmdbuff; *line ; line = s ) + { + if ( (s=strchr(line ,'\n'))) + { + save_ch = *++s; + *s = '\0'; + } + else + { + s += strlen( line ); + save_ch = '\0'; + } + if (interpretCmd( line )) + { + *s = save_ch; + break; + } + *s = save_ch; + if ( stopcmdlist ) + break; + } + } + } +#ifdef HAVE_LIBREADLINE + // restore readline's input/output streams + rl_instream = old_rl_instream; + rl_outstream = old_rl_outstream; +#endif /* HAVE_LIBREADLINE */ +} + +/*-----------------------------------------------------------------*/ +/* printVersionInfo - print the version information */ +/*-----------------------------------------------------------------*/ +static void printVersionInfo(void) +{ + fprintf(stdout, + "SDCDB is free software and you are welcome to distribute copies of it\n" + "under certain conditions; type \"show copying\" to see the conditions.\n" + "There is absolutely no warranty for SDCDB; type \"show warranty\" for details.\n" + "SDCDB " SDCDB_VERSION ". Copyright (C) 1999 Sandeep Dutta (sandeep.dutta@usa.net)\n"); +} + +/*-----------------------------------------------------------------*/ +/* printHelp - print help */ +/*-----------------------------------------------------------------*/ +static void printHelp(void) +{ + fprintf(stdout, "Type ? for help\n"); +} + +/*-----------------------------------------------------------------*/ +/* escapeQuotes - escape double quotes */ +/*-----------------------------------------------------------------*/ +#define CHUNK 256 + +static const char *escapeQuotes(const char *arg) +{ +#define extend(n) do { if ((size_t)(ps - str + (n)) > strLen) str = Safe_realloc (str, strLen += CHUNK); } while (0) + + static char *str = NULL; + static size_t strLen = 0; + char *ps; + const char *pa; + + if (NULL == str) + { + strLen = CHUNK; + str = Safe_malloc (strLen); + } + + for (ps = str, pa = arg; '\0' != *pa; ++pa) + { + if ('"' == *pa) + { + extend (2); + *ps++ = '\\'; /* excape the quote */ + *ps++ = *pa; + } + else + { + extend (1); + *ps++ = *pa; + } + } + extend (1); + *ps = '\0'; + + return str; +} + +/*-----------------------------------------------------------------*/ +/* argsToCmdLine - concatenate arguments ti command line */ +/*-----------------------------------------------------------------*/ +char *argsToCmdLine(char **args, int nargs) +{ + static char *cmd = NULL; + static size_t cmdLen = 0; + int i; + size_t cmdPos = 0; + + if (NULL == cmd) + { + cmd = Safe_malloc(CHUNK); + cmdLen = CHUNK; + } + + for (i = 0; i < nargs; ++i) + { + size_t argLen; + size_t allocLen = 0; + int quote = 0; + const char *arg; + + if (0 < i) + ++allocLen; /* space for space character */ + + if (NULL != strchr(args[i], ' ')) + { + quote = 1; + allocLen += 2; /* space for inital and final quote */ + arg = escapeQuotes(args[i]); + } + else + { + arg = args[i]; + } + + argLen = strlen(arg); + allocLen += argLen; /* space for argument */ + + /* extend the buffer */ + if (cmdPos + allocLen >= cmdLen) + { + do + { + cmdLen += cmdLen; + } + while (cmdPos + allocLen >= cmdLen); + cmd = Safe_realloc(cmd, cmdLen); + } + + if (0 < i) + { + cmd[cmdPos++] = ' '; /* append space character */ + } + + if (quote) + { + cmd[cmdPos++] = '"'; /* append initial quote */ + } + + memcpy(&cmd[cmdPos], arg, argLen); /* append argument */ + cmdPos += argLen; + + if (quote) + cmd[cmdPos++] = '"'; /* append final quote */ + } + + cmd[cmdPos] = '\0'; + + return cmd; +} + +static void usage(void) +{ + const char *args = + "-{h|?}, --help\tDisplay this help\n" + "-v\tVerbose: show the simulator invocation commald line\n" + "--directory=<dir>\tSearch modules in <dir> directory\n" + "-fullname\tGive the file name & position\n" + "-cd=<dir>, -cd <dir>\tChange directory to <dir>\n" +#ifdef SDCDB_DEBUG + "-d=<msk>\tSet debugging to <mask>\n" +#endif + "-contsim\tContinuous simulation\n" + "-q\tIgnored\n" + "-m<model>\tModel string: avr, xa, z80\n" + "-z\tAll remaining options are for simulator"; + + const char *simArgs = + "-t <cpu>, -cpu <cpu>\tCpu type\n" + "-frequency <frequency>, -X <frequency>\tXTAL Frequency\n" + "-{s|S} <serial_port>\tSerial port\n" + "-k\tNetwork serial port"; + + printf("usage: sdcdb [args] [simulator args] [filename]\n" + "args:\n"); + printHelpLine(args, 2); + printf("simulator args:\n"); + printHelpLine(simArgs, 2); + putchar('\n'); + printVersionInfo(); +} + +/*-----------------------------------------------------------------*/ +/* parseCmdLine - parse the commandline arguments */ +/*-----------------------------------------------------------------*/ +static void parseCmdLine (int argc, char **argv) +{ + int i; + char *filename = NULL; + int passon_args_flag = 0; /* if true, pass on args to simulator */ + int verbose = 0; + + Dprintf(D_sdcdb, ("sdcdb: parseCmdLine\n")); + contsim = 0; + + for (i = 1; i < argc ; i++) + { + if (passon_args_flag) /* if true, pass on args to simulator */ + { + simArgs[nsimArgs++] = strdup(argv[i]); + continue; + } + + /* if this is an option */ + if (argv[i][0] == '-') + { + /* display usage */ + if (strcmp(argv[i], "-h") == 0 || + strcmp(argv[i], "-?") == 0 || + strcmp(argv[i], "--help") == 0) + { + usage(); + exit(0); + } + + /* verbose */ + if (strcmp(argv[i], "-v") == 0) + { + verbose = 1; + continue; + } + + /* if directory then mark directory */ + if (strncmp(argv[i], "--directory=", 12) == 0) + { + if (!ssdirl) + { + ssdirl = &argv[i][12]; + } + else + { + char *p = Safe_malloc(strlen(ssdirl)+strlen(&argv[i][12])+2); + strcat(strcat(strcpy(p,&argv[i][12]),":"),ssdirl); + ssdirl = p; + } + continue; + } + + if (strcmp(argv[i], "-fullname") == 0) + { + fullname = TRUE; + continue; + } + + if (strncmp(argv[i], "-cd=", 4) == 0) + { + if (0 > chdir(&argv[i][4])) + { + fprintf(stderr, "can't change directory to %s\n", &argv[i][4]); + exit(1); + } + continue; + } + + if (strcmp(argv[i], "-cd") == 0) + { + i++; + if (0 > chdir(argv[i])) + { + fprintf(stderr, "can't change directory to %s\n", argv[i]); + exit(1); + } + continue; + } + +#ifdef SDCDB_DEBUG + if (strncmp(argv[i], "-d=", 3) == 0) + { + sdcdbDebug = strtol(&argv[i][3],0,0); + continue; + } +#endif + if (strcmp(argv[i], "-contsim") == 0) + { + contsim=1; + continue; + } + if (strcmp(argv[i], "-q") == 0) + { + continue; + } + + /* model string */ + if (strncmp(argv[i],"-m", 2) == 0) + { + strncpy(model_str, &argv[i][2], 15); + if (strcmp(model_str, "avr") == 0) + simArgs[0] = "savr"; + else if (strcmp(model_str, "xa") == 0) + simArgs[0] = "sxa"; + else if (strcmp(model_str, "z80") == 0) + simArgs[0] = "sz80"; + continue; + } + + /* -z all remaining options are for simulator */ + if (strcmp(argv[i], "-z") == 0) + { + passon_args_flag = 1; + continue; + } + + /* the simulator arguments */ + + /* cpu */ + if (strcmp(argv[i], "-t") == 0 || + strcmp(argv[i], "-cpu") == 0) + { + simArgs[nsimArgs++] = "-t"; + simArgs[nsimArgs++] = strdup(argv[++i]); + continue; + } + + /* XTAL Frequency */ + if (strcmp(argv[i], "-X") == 0 || + strcmp(argv[i], "-frequency") == 0) + { + simArgs[nsimArgs++] = "-X"; + simArgs[nsimArgs++] = strdup(argv[++i]); + continue; + } + + /* serial port */ + if ((strcmp(argv[i], "-S") == 0) || + (strcmp(argv[i], "-s") == 0)) + { + simArgs[nsimArgs++] = strdup(argv[i]); + simArgs[nsimArgs++] = strdup(argv[++i]); + continue; + } + + /* network serial port */ + if ((strcmp(argv[i], "-k") == 0)) + { + simArgs[nsimArgs++] = strdup(argv[i]); + simArgs[nsimArgs++] = strdup(argv[++i]); + continue; + } + + fprintf(stderr,"unknown option %s --- ignored\n", argv[i]); + } + else + { + FILE* file; + + /* must be file name */ + if (filename) + { + fprintf(stderr, + "too many filenames .. parameter '%s' ignored\n", + argv[i]); + continue ; + } + + file = fopen(argv[i], "r"); + if (file) + { + /* file exists: strip the cdb or ihx extension */ + char *p = strrchr(argv[i], '.'); + + fclose(file); + if (NULL != p && + (0 == strcmp(p, ".cdb") || 0 == strcmp(p, ".ihx"))) + { + *p = '\0'; + } + } + filename = argv[i]; + } + } + + if (filename) + cmdFile(filename,NULL); + + if (verbose) + printf("+ %s\n", argsToCmdLine(simArgs, nsimArgs)); +} + +/*-----------------------------------------------------------------*/ +/* setsignals - catch some signals */ +/*-----------------------------------------------------------------*/ +#include <signal.h> +static void +bad_signal(int sig) +{ + if ( simactive ) + closeSimulator(); + exit(1); +} + +static void +sigintr(int sig) +{ + /* may be interrupt from user: stop debugger and also simulator */ + userinterrupt = 1; + if ( !nointerrupt ) + sendSim("stop\n"); +} + +#ifndef _WIN32 +/* the only child can be the simulator */ +static void sigchld(int sig) +{ + /* the only child can be the simulator */ + int status; + wait ( &status ); + simactive = 0; +} +#endif + +static void +setsignals() +{ + signal(SIGINT , sigintr ); + signal(SIGABRT, bad_signal); + signal(SIGTERM, bad_signal); + +#ifndef _WIN32 + signal(SIGHUP , SIG_IGN); + signal(SIGCONT, SIG_IGN); + signal(SIGCHLD, sigchld ); + + signal(SIGALRM, bad_signal); + //signal(SIGFPE, bad_signal); + //signal(SIGILL, bad_signal); + signal(SIGPIPE, bad_signal); + signal(SIGQUIT, bad_signal); + //signal(SIGSEGV, bad_signal); +#endif +} + +/*-----------------------------------------------------------------*/ +/* main - */ +/*-----------------------------------------------------------------*/ + +int main ( int argc, char **argv) +{ + simArgs[nsimArgs++] = "s51"; + simArgs[nsimArgs++] = "-P"; + simArgs[nsimArgs++] = "-r"; + simArgs[nsimArgs++] = "9756"; + + /* parse command line */ + parseCmdLine(argc, argv); + + printVersionInfo(); + printHelp(); + printf("WARNING: SDCDB is EXPERIMENTAL.\n"); + + setsignals(); + + commandLoop(stdin); + + return 0; +} diff --git a/debugger/mcs51/sdcdb.el b/debugger/mcs51/sdcdb.el new file mode 100644 index 0000000..6919b1c --- /dev/null +++ b/debugger/mcs51/sdcdb.el @@ -0,0 +1,650 @@ +;;; sdcdb.el --- run sdcdb under Emacs + +;; Author: W. Schelter, University of Texas +;; wfs@rascal.ics.utexas.edu +;; Rewritten by rms. +;; Keywords: c, unix, tools, debugging + +;; Some ideas are due to Masanobu. + +;; This file is part of XEmacs. + +;; XEmacs is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; XEmacs is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with XEmacs; see the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +;; 02111-1307, USA. + +;;; Synched up with: Not in FSF + +;;; Commentary: + +;; Description of SDCDB interface: + +;; A facility is provided for the simultaneous display of the source code +;; in one window, while using sdcdb to step through a function in the +;; other. A small arrow in the source window, indicates the current +;; line. + +;; Starting up: + +;; In order to use this facility, invoke the command SDCDB to obtain a +;; shell window with the appropriate command bindings. You will be asked +;; for the name of a file to run. Sdcdb will be invoked on this file, in a +;; window named *sdcdb-foo* if the file is foo. + +;; M-s steps by one line, and redisplays the source file and line. + +;; You may easily create additional commands and bindings to interact +;; with the display. For example to put the sdcdb command next on \M-n +;; (def-sdcdb next "\M-n") + +;; This causes the emacs command sdcdb-next to be defined, and runs +;; sdcdb-display-frame after the command. + +;; sdcdb-display-frame is the basic display function. It tries to display +;; in the other window, the file and line corresponding to the current +;; position in the sdcdb window. For example after a sdcdb-step, it would +;; display the line corresponding to the position for the last step. Or +;; if you have done a backtrace in the sdcdb buffer, and move the cursor +;; into one of the frames, it would display the position corresponding to +;; that frame. + +;; sdcdb-display-frame is invoked automatically when a filename-and-line-number +;; appears in the output. + +;;; Code: + +(require 'comint) +(require 'shell) + +(condition-case nil + (if (featurep 'toolbar) + (require 'eos-toolbar "sun-eos-toolbar")) + (error nil)) + +(defvar sdcdb-last-frame) +(defvar sdcdb-delete-prompt-marker) +(defvar sdcdb-filter-accumulator) +(defvar sdcdb-last-frame-displayed-p) +(defvar sdcdb-arrow-extent nil) +(or (fboundp 'make-glyph) (fset 'make-glyph 'identity)) ; work w/ pre beta v12 +(defvar sdcdb-arrow-glyph (make-glyph "=>")) + +(make-face 'sdcdb-arrow-face) +(or (face-differs-from-default-p 'sdcdb-arrow-face) + ;; Usually has a better default value than highlight does + (copy-face 'isearch 'sdcdb-arrow-face)) + +;; Hooks can side-effect extent arg to change extent properties +(defvar sdcdb-arrow-extent-hooks '()) + +(defvar sdcdb-prompt-pattern "^>\\|^(.*sdcdb[+]?) *\\|^---Type <return> to.*--- *" + "A regexp to recognize the prompt for sdcdb or sdcdb+.") + +(defvar sdcdb-mode-map nil + "Keymap for sdcdb-mode.") + +(defvar sdcdb-toolbar nil) + +(if sdcdb-mode-map + nil + (setq sdcdb-mode-map (make-sparse-keymap)) + (set-keymap-name sdcdb-mode-map 'sdcdb-mode-map) + (set-keymap-parents sdcdb-mode-map (list comint-mode-map)) + (define-key sdcdb-mode-map "\C-l" 'sdcdb-refresh) + (define-key sdcdb-mode-map "\C-c\C-c" 'sdcdb-control-c-subjob) + (define-key sdcdb-mode-map "\t" 'comint-dynamic-complete) + (define-key sdcdb-mode-map "\M-?" 'comint-dynamic-list-completions)) + +(define-key ctl-x-map " " 'sdcdb-break) +(define-key ctl-x-map "&" 'send-sdcdb-command) + +;;Of course you may use `def-sdcdb' with any other sdcdb command, including +;;user defined ones. + +(defmacro def-sdcdb (name key &optional doc &rest forms) + (let* ((fun (intern (format "sdcdb-%s" name))) + (cstr (list 'if '(not (= 1 arg)) + (list 'format "%s %s" name 'arg) + name))) + (list 'progn + (nconc (list 'defun fun '(arg) + (or doc "") + '(interactive "p") + (list 'sdcdb-call cstr)) + forms) + (and key (list 'define-key 'sdcdb-mode-map key (list 'quote fun)))))) + +(def-sdcdb "step" "\M-s" "Step one source line with display" + (sdcdb-delete-arrow-extent)) +(def-sdcdb "stepi" "\M-i" "Step one instruction with display" + (sdcdb-delete-arrow-extent)) +(def-sdcdb "finish" "\C-c\C-f" "Finish executing current function" + (sdcdb-delete-arrow-extent)) +(def-sdcdb "run" nil "Run the current program" + (sdcdb-delete-arrow-extent)) + +;;"next" and "cont" were bound to M-n and M-c in Emacs 18, but these are +;;poor choices, since M-n is used for history navigation and M-c is +;;capitalize-word. These are defined without key bindings so that users +;;may choose their own bindings. +(def-sdcdb "next" "\C-c\C-n" "Step one source line (skip functions)" + (sdcdb-delete-arrow-extent)) +(def-sdcdb "cont" "\C-c\M-c" "Proceed with the program" + (sdcdb-delete-arrow-extent)) + +(def-sdcdb "up" "\C-c<" "Go up N stack frames (numeric arg) with display") +(def-sdcdb "down" "\C-c>" "Go down N stack frames (numeric arg) with display") + +(defvar sdcdb-display-mode nil + "Minor mode for sdcdb frame display") +(or (assq 'sdcdb-display-mode minor-mode-alist) + (setq minor-mode-alist + (purecopy + (append minor-mode-alist + '((sdcdb-display-mode " Frame")))))) + +(defun sdcdb-display-mode (&optional arg) + "Toggle SDCDB Frame display mode +With arg, turn display mode on if and only if arg is positive. +In the display minor mode, source file are displayed in another +window for repective \\[sdcdb-display-frame] commands." + (interactive "P") + (setq sdcdb-display-mode (if (null arg) + (not sdcdb-display-mode) + (> (prefix-numeric-value arg) 0)))) + +;; Using cc-mode's syntax table is broken. +(defvar sdcdb-mode-syntax-table nil + "Syntax table for SDCDB mode.") + +;; This is adapted from CC Mode 5.11. +(unless sdcdb-mode-syntax-table + (setq sdcdb-mode-syntax-table (make-syntax-table)) + ;; DO NOT TRY TO SET _ (UNDERSCORE) TO WORD CLASS! + (modify-syntax-entry ?_ "_" sdcdb-mode-syntax-table) + (modify-syntax-entry ?\\ "\\" sdcdb-mode-syntax-table) + (modify-syntax-entry ?+ "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?- "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?= "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?% "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?< "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?> "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?& "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?| "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?\' "\"" sdcdb-mode-syntax-table) + ;; add extra comment syntax + (modify-syntax-entry ?/ ". 14" sdcdb-mode-syntax-table) + (modify-syntax-entry ?* ". 23" sdcdb-mode-syntax-table)) + + +(defun sdcdb-mode () + "Major mode for interacting with an inferior Sdcdb process. +The following commands are available: + +\\{sdcdb-mode-map} + +\\[sdcdb-display-frame] displays in the other window +the last line referred to in the sdcdb buffer. See also +\\[sdcdb-display-mode]. + +\\[sdcdb-step],\\[sdcdb-next], and \\[sdcdb-nexti] in the sdcdb window, +call sdcdb to step,next or nexti and then update the other window +with the current file and position. + +If you are in a source file, you may select a point to break +at, by doing \\[sdcdb-break]. + +Commands: +Many commands are inherited from comint mode. +Additionally we have: + +\\[sdcdb-display-frame] display frames file in other window +\\[sdcdb-step] advance one line in program +\\[send-sdcdb-command] used for special printing of an arg at the current point. +C-x SPACE sets break point at current line." + (interactive) + (comint-mode) + (use-local-map sdcdb-mode-map) + (set-syntax-table sdcdb-mode-syntax-table) + (make-local-variable 'sdcdb-last-frame-displayed-p) + (make-local-variable 'sdcdb-last-frame) + (make-local-variable 'sdcdb-delete-prompt-marker) + (make-local-variable 'sdcdb-display-mode) + (make-local-variable' sdcdb-filter-accumulator) + (setq sdcdb-last-frame nil + sdcdb-delete-prompt-marker nil + sdcdb-filter-accumulator nil + sdcdb-display-mode t + major-mode 'sdcdb-mode + mode-name "Inferior SDCDB" + comint-prompt-regexp sdcdb-prompt-pattern + sdcdb-last-frame-displayed-p t) + (set (make-local-variable 'shell-dirtrackp) t) + ;;(make-local-variable 'sdcdb-arrow-extent) + (and (extentp sdcdb-arrow-extent) + (delete-extent sdcdb-arrow-extent)) + (setq sdcdb-arrow-extent nil) + ;; XEmacs change: + (make-local-hook 'kill-buffer-hook) + (add-hook 'kill-buffer-hook 'sdcdb-delete-arrow-extent nil t) + (add-hook 'comint-input-filter-functions 'shell-directory-tracker nil t) + (run-hooks 'sdcdb-mode-hook)) + +(defun sdcdb-delete-arrow-extent () + (let ((inhibit-quit t)) + (if sdcdb-arrow-extent + (delete-extent sdcdb-arrow-extent)) + (setq sdcdb-arrow-extent nil))) + +(defvar current-sdcdb-buffer nil) + +;;;###autoload +(defvar sdcdb-command-name "sdcdb" + "Pathname for executing sdcdb.") + +;;;###autoload +(defun sdcdb (path &optional corefile) + "Run sdcdb on program FILE in buffer *sdcdb-FILE*. +The directory containing FILE becomes the initial working directory +and source-file directory for SDCDB. If you wish to change this, use +the SDCDB commands `cd DIR' and `directory'." + (interactive "FRun sdcdb on file: ") + (setq path (file-truename (expand-file-name path))) + (let ((file (file-name-nondirectory path))) + (switch-to-buffer (concat "*sdcdb-" file "*")) + (setq default-directory (file-name-directory path)) + (or (bolp) (newline)) + (insert "Current directory is " default-directory "\n") + (apply 'make-comint + (concat "sdcdb-" file) + (substitute-in-file-name sdcdb-command-name) + nil + "-fullname" + "-cd" default-directory + file + (and corefile (list corefile))) + (set-process-filter (get-buffer-process (current-buffer)) 'sdcdb-filter) + (set-process-sentinel (get-buffer-process (current-buffer)) 'sdcdb-sentinel) + ;; XEmacs change: turn on sdcdb mode after setting up the proc filters + ;; for the benefit of shell-font.el + (sdcdb-mode) + (sdcdb-set-buffer))) + +;;;###autoload +(defun sdcdb-with-core (file corefile) + "Debug a program using a corefile." + (interactive "fProgram to debug: \nfCore file to use: ") + (sdcdb file corefile)) + +(defun sdcdb-set-buffer () + (cond ((eq major-mode 'sdcdb-mode) + (setq current-sdcdb-buffer (current-buffer)) + (if (featurep 'eos-toolbar) + (set-specifier default-toolbar (cons (current-buffer) + sdcdb-toolbar)))))) + + +;; This function is responsible for inserting output from SDCDB +;; into the buffer. +;; Aside from inserting the text, it notices and deletes +;; each filename-and-line-number; +;; that SDCDB prints to identify the selected frame. +;; It records the filename and line number, and maybe displays that file. +(defun sdcdb-filter (proc string) + (let ((inhibit-quit t)) + (save-current-buffer + (set-buffer (process-buffer proc)) + (if sdcdb-filter-accumulator + (sdcdb-filter-accumulate-marker + proc (concat sdcdb-filter-accumulator string)) + (sdcdb-filter-scan-input proc string))))) + +(defun sdcdb-filter-accumulate-marker (proc string) + (setq sdcdb-filter-accumulator nil) + (if (> (length string) 1) + (if (= (aref string 1) ?\032) + (let ((end (string-match "\n" string))) + (if end + (progn + (let* ((first-colon (string-match ":" string 2)) + (second-colon + (string-match ":" string (1+ first-colon)))) + (setq sdcdb-last-frame + (cons (substring string 2 first-colon) + (string-to-int + (substring string (1+ first-colon) + second-colon))))) + (setq sdcdb-last-frame-displayed-p nil) + (sdcdb-filter-scan-input proc + (substring string (1+ end)))) + (setq sdcdb-filter-accumulator string))) + (sdcdb-filter-insert proc "\032") + (sdcdb-filter-scan-input proc (substring string 1))) + (setq sdcdb-filter-accumulator string))) + +(defun sdcdb-filter-scan-input (proc string) + (if (equal string "") + (setq sdcdb-filter-accumulator nil) + (let ((start (string-match "\032" string))) + (if start + (progn (sdcdb-filter-insert proc (substring string 0 start)) + (sdcdb-filter-accumulate-marker proc + (substring string start))) + (sdcdb-filter-insert proc string))))) + +(defun sdcdb-filter-insert (proc string) + (let ((moving (= (point) (process-mark proc))) + (output-after-point (< (point) (process-mark proc)))) + (save-excursion + ;; Insert the text, moving the process-marker. + (goto-char (process-mark proc)) + (insert-before-markers string) + (set-marker (process-mark proc) (point)) + (sdcdb-maybe-delete-prompt) + ;; Check for a filename-and-line number. + (sdcdb-display-frame + ;; Don't display the specified file + ;; unless (1) point is at or after the position where output appears + ;; and (2) this buffer is on the screen. + (or output-after-point + (not (get-buffer-window (current-buffer)))) + ;; Display a file only when a new filename-and-line-number appears. + t)) + (if moving (goto-char (process-mark proc)))) + + (let (s) + (if (and (should-use-dialog-box-p) + (setq s (or (string-match " (y or n) *\\'" string) + (string-match " (yes or no) *\\'" string)))) + (sdcdb-mouse-prompt-hack (substring string 0 s) (current-buffer)))) + ) + +(defun sdcdb-mouse-prompt-hack (prompt buffer) + (popup-dialog-box + (list prompt + (vector "Yes" (list 'sdcdb-mouse-prompt-hack-answer 't buffer) t) + (vector "No" (list 'sdcdb-mouse-prompt-hack-answer 'nil buffer) t) + nil + (vector "Cancel" (list 'sdcdb-mouse-prompt-hack-answer 'nil buffer) t) + ))) + +(defun sdcdb-mouse-prompt-hack-answer (answer buffer) + (let ((b (current-buffer))) + (unwind-protect + (progn + (set-buffer buffer) + (goto-char (process-mark (get-buffer-process buffer))) + (delete-region (point) (point-max)) + (insert (if answer "yes" "no")) + (comint-send-input)) + (set-buffer b)))) + +(defun sdcdb-sentinel (proc msg) + (cond ((null (buffer-name (process-buffer proc))) + ;; buffer killed + ;; Stop displaying an arrow in a source file. + ;(setq overlay-arrow-position nil) -- done by kill-buffer-hook + (set-process-buffer proc nil)) + ((memq (process-status proc) '(signal exit)) + ;; Stop displaying an arrow in a source file. + (sdcdb-delete-arrow-extent) + ;; Fix the mode line. + (setq modeline-process + (concat ": sdcdb " (symbol-name (process-status proc)))) + (let* ((obuf (current-buffer))) + ;; save-excursion isn't the right thing if + ;; process-buffer is current-buffer + (unwind-protect + (progn + ;; Write something in *compilation* and hack its mode line, + (set-buffer (process-buffer proc)) + ;; Force mode line redisplay soon + (set-buffer-modified-p (buffer-modified-p)) + (if (eobp) + (insert ?\n mode-name " " msg) + (save-excursion + (goto-char (point-max)) + (insert ?\n mode-name " " msg))) + ;; If buffer and mode line will show that the process + ;; is dead, we can delete it now. Otherwise it + ;; will stay around until M-x list-processes. + (delete-process proc)) + ;; Restore old buffer, but don't restore old point + ;; if obuf is the sdcdb buffer. + (set-buffer obuf)))))) + + +(defun sdcdb-refresh (&optional arg) + "Fix up a possibly garbled display, and redraw the arrow." + (interactive "P") + (recenter arg) + (sdcdb-display-frame)) + +(defun sdcdb-display-frame (&optional nodisplay noauto) + "Find, obey and delete the last filename-and-line marker from SDCDB. +The marker looks like \\032\\032FILENAME:LINE:CHARPOS\\n. +Obeying it means displaying in another window the specified file and line." + (interactive) + (sdcdb-set-buffer) + (and sdcdb-last-frame (not nodisplay) + sdcdb-display-mode + (or (not sdcdb-last-frame-displayed-p) (not noauto)) + (progn (sdcdb-display-line (car sdcdb-last-frame) (cdr sdcdb-last-frame)) + (setq sdcdb-last-frame-displayed-p t)))) + +;; Make sure the file named TRUE-FILE is in a buffer that appears on the screen +;; and that its line LINE is visible. +;; Put the overlay-arrow on the line LINE in that buffer. + +(defun sdcdb-display-line (true-file line &optional select-method) + ;; FILE to display + ;; LINE number to highlight and make visible + ;; SELECT-METHOD 'source, 'debugger, or 'none. (default is 'debugger) + (and (null select-method) (setq select-method 'debugger)) + (let* ((pre-display-buffer-function nil) ; screw it, put it all in one screen + (pop-up-windows t) + (source-buffer (find-file-noselect true-file)) + (source-window (display-buffer source-buffer)) + (debugger-window (get-buffer-window current-sdcdb-buffer)) + (extent sdcdb-arrow-extent) + pos) + ;; XEmacs change: make sure we find a window displaying the source file + ;; even if we are already sitting in it when a breakpoint is hit. + ;; Otherwise the t argument to display-buffer will prevent it from being + ;; displayed. + (save-excursion + (cond ((eq select-method 'debugger) + ;; might not already be displayed + (setq debugger-window (display-buffer current-sdcdb-buffer)) + (select-window debugger-window)) + ((eq select-method 'source) + (select-window source-window)))) + (and extent + (not (eq (extent-object extent) source-buffer)) + (setq extent (delete-extent extent))) + (or extent + (progn + (setq extent (make-extent 1 1 source-buffer)) + (set-extent-face extent 'sdcdb-arrow-face) + (set-extent-begin-glyph extent sdcdb-arrow-glyph) + (set-extent-begin-glyph-layout extent 'whitespace) + (set-extent-priority extent 2000) + (setq sdcdb-arrow-extent extent))) + (save-current-buffer + (set-buffer source-buffer) + (save-restriction + (widen) + (goto-line line) + (set-window-point source-window (point)) + (setq pos (point)) + (end-of-line) + (set-extent-endpoints extent pos (point)) + (run-hook-with-args 'sdcdb-arrow-extent-hooks extent)) + (cond ((or (< pos (point-min)) (> pos (point-max))) + (widen) + (goto-char pos)))) + ;; Added by Stig. It caused lots of problems for several users + ;; and since its purpose is unclear it is getting commented out. + ;;(and debugger-window + ;; (set-window-point debugger-window pos)) + )) + +(defun sdcdb-call (command) + "Invoke sdcdb COMMAND displaying source in other window." + (interactive) + (goto-char (point-max)) + ;; Record info on the last prompt in the buffer and its position. + ;; This is used in sdcdb-maybe-delete-prompt + ;; to prevent multiple prompts from accumulating. + (save-excursion + (goto-char (process-mark (get-buffer-process current-sdcdb-buffer))) + (let ((pt (point))) + (beginning-of-line) + (setq sdcdb-delete-prompt-marker + (if (= (point) pt) + nil + (list (point-marker) (- pt (point)) + (buffer-substring (point) pt)))))) + (sdcdb-set-buffer) + (process-send-string (get-buffer-process current-sdcdb-buffer) + (concat command "\n"))) + +(defun sdcdb-maybe-delete-prompt () + (if sdcdb-delete-prompt-marker + ;; Get the string that we used as the prompt before. + (let ((prompt (nth 2 sdcdb-delete-prompt-marker)) + (length (nth 1 sdcdb-delete-prompt-marker))) + ;; Position after it. + (goto-char (+ (car sdcdb-delete-prompt-marker) length)) + ;; Delete any duplicates of it which follow right after. + (while (and (<= (+ (point) length) (point-max)) + (string= prompt + (buffer-substring (point) (+ (point) length)))) + (delete-region (point) (+ (point) length))) + ;; If that didn't take us to where output is arriving, + ;; we have encountered something other than a prompt, + ;; so stop trying to delete any more prompts. + (if (not (= (point) + (process-mark (get-buffer-process current-sdcdb-buffer)))) + (progn + (set-marker (car sdcdb-delete-prompt-marker) nil) + (setq sdcdb-delete-prompt-marker nil)))))) + +(defun sdcdb-break (temp) + "Set SDCDB breakpoint at this source line. With ARG set temporary breakpoint." + (interactive "P") + (let* ((file-name (file-name-nondirectory buffer-file-name)) + (line (save-restriction + (widen) + (beginning-of-line) + (1+ (count-lines 1 (point))))) + (cmd (concat (if temp "tbreak " "break ") file-name ":" + (int-to-string line)))) + (set-buffer current-sdcdb-buffer) + (goto-char (process-mark (get-buffer-process current-sdcdb-buffer))) + (delete-region (point) (point-max)) + (insert cmd) + (comint-send-input) + ;;(process-send-string (get-buffer-process current-sdcdb-buffer) cmd) + )) + +(defun sdcdb-clear () + "Set SDCDB breakpoint at this source line." + (interactive) + (let* ((file-name (file-name-nondirectory buffer-file-name)) + (line (save-restriction + (widen) + (beginning-of-line) + (1+ (count-lines 1 (point))))) + (cmd (concat "clear " file-name ":" + (int-to-string line)))) + (set-buffer current-sdcdb-buffer) + (goto-char (process-mark (get-buffer-process current-sdcdb-buffer))) + (delete-region (point) (point-max)) + (insert cmd) + (comint-send-input) + ;;(process-send-string (get-buffer-process current-sdcdb-buffer) cmd) + )) + +(defun sdcdb-read-address() + "Return a string containing the core-address found in the buffer at point." + (save-excursion + (let ((pt (point)) found begin) + (setq found (if (search-backward "0x" (- pt 7) t)(point))) + (cond (found (forward-char 2) + (buffer-substring found + (progn (re-search-forward "[^0-9a-f]") + (forward-char -1) + (point)))) + (t (setq begin (progn (re-search-backward "[^0-9]") (forward-char 1) + (point))) + (forward-char 1) + (re-search-forward "[^0-9]") + (forward-char -1) + (buffer-substring begin (point))))))) + + +(defvar sdcdb-commands nil + "List of strings or functions used by send-sdcdb-command. +It is for customization by you.") + +(defun send-sdcdb-command (arg) + + "This command reads the number where the cursor is positioned. It + then inserts this ADDR at the end of the sdcdb buffer. A numeric arg + selects the ARG'th member COMMAND of the list sdcdb-print-command. If + COMMAND is a string, (format COMMAND ADDR) is inserted, otherwise + (funcall COMMAND ADDR) is inserted. eg. \"p (rtx)%s->fld[0].rtint\" + is a possible string to be a member of sdcdb-commands. " + + + (interactive "P") + (let (comm addr) + (if arg (setq comm (nth arg sdcdb-commands))) + (setq addr (sdcdb-read-address)) + (if (eq (current-buffer) current-sdcdb-buffer) + (set-mark (point))) + (cond (comm + (setq comm + (if (stringp comm) (format comm addr) (funcall comm addr)))) + (t (setq comm addr))) + (switch-to-buffer current-sdcdb-buffer) + (goto-char (point-max)) + (insert comm))) + +(fset 'sdcdb-control-c-subjob 'comint-interrupt-subjob) + +;(defun sdcdb-control-c-subjob () +; "Send a Control-C to the subprocess." +; (interactive) +; (process-send-string (get-buffer-process (current-buffer)) +; "\C-c")) + +(defun sdcdb-toolbar-break () + (interactive) + (save-excursion + (message (car sdcdb-last-frame)) + (set-buffer (find-file-noselect (car sdcdb-last-frame))) + (sdcdb-break nil))) + +(defun sdcdb-toolbar-clear () + (interactive) + (save-excursion + (message (car sdcdb-last-frame)) + (set-buffer (find-file-noselect (car sdcdb-last-frame))) + (sdcdb-clear))) + +(provide 'sdcdb) + +;;; sdcdb.el ends here diff --git a/debugger/mcs51/sdcdb.h b/debugger/mcs51/sdcdb.h new file mode 100644 index 0000000..d9f8b81 --- /dev/null +++ b/debugger/mcs51/sdcdb.h @@ -0,0 +1,295 @@ +/*------------------------------------------------------------------------- + sdcdb.h - Header file used by ALL source files for the debugger + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SDCDB_H +#define SDCDB_H + +#define SDCDB_VERSION "0.9" + +#define SDCDB_DEBUG + +#ifdef SDCDB_DEBUG +// set D_x to 0 to turn off, 1 to turn on. +#define D_break 0x01 +#define D_simi 0x02 +#define D_sdcdb 0x04 +#define D_symtab 0x08 + +extern int sdcdbDebug; + +#define Dprintf(f, fs) {if (f & sdcdbDebug) printf fs ; } +#else +#define Dprintf(f, fs) { } +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <limits.h> +#ifdef HAVE_CONFIG_H +# include "config.h" +#elif defined(_WIN32) && !defined(__MINGW32__) +# include "sdcc_vc.h" +#else +# include "sdccconf.h" +#endif +#include "src/SDCCset.h" +#include "src/SDCChasht.h" + +#define TRUE 1 +#define FALSE !TRUE + +typedef short bool; + +#ifndef max +#define max(a,b) (a > b ? a : b) +#endif + +#ifndef min +#define min(a,b) (a < b ? a : b) +#endif + +/* + * #ifndef ALLOC + * #define ALLOC(x,sz) if (!(x = calloc(1, sz))) \ + * { \ + * fprintf(stderr,"sdcdb: out of memory\n"); \ + * exit (1); \ + * } + * #endif + * #ifndef ALLOC_ATOMIC + * #define ALLOC_ATOMIC(x,sz) if (!(x = calloc(1, sz))) \ + * { \ + * fprintf(stderr,"sdcdb: out of memory\n"); \ + * exit (1); \ + * } + * #endif + */ + +/* generalpurpose stack related macros */ +#define STACK_DCL(stack, type, size) \ + typedef type t_##stack; \ + t_##stack stack[size]; \ + t_##stack *p_##stack = stack - 1; \ + t_##stack *w_##stack; + +/* define extern stack */ +#define EXTERN_STACK_DCL(stack, type, size) \ + typedef type t_##stack; \ + extern t_##stack stack[size]; \ + extern t_##stack *p_##stack; \ + extern t_##stack *w_##stack; + +#define STACK_EMPTY(stack) ((p_##stack) < stack) +#define STACK_FULL(stack) ((p_##stack) >= (stack + \ + sizeof(stack) / sizeof(*stack) - 1) ) + +#define STACK_PUSH_(stack, x) (*++p_##stack = (x)) +#define STACK_POP_(stack) (*p_##stack--) + +#define STACK_PUSH(stack, x) (STACK_FULL(stack) \ + ? (STACK_ERR(1, stack), *p_##stack) \ + : STACK_PUSH_(stack, x) ) + +#define STACK_POP(stack) (STACK_EMPTY(stack) \ + ? (STACK_ERR(-1, stack), *stack) \ + : STACK_POP_(stack) ) + +#define STACK_PEEK(stack) (STACK_EMPTY(stack) \ + ? (STACK_ERR(0, stack), *stack) \ + : *p_##stack ) + +#define STACK_PPEEK(stack) (((p_##stack - 1) < stack) \ + ? (STACK_ERR(0, stack), *stack) \ + : *(p_##stack - 1) ) + +#define STACK_ERR(o, stack) (fprintf(stderr, "stack '%s' %s\n", \ + #stack, \ + (o < 0) \ + ? "underflow" \ + : (o > 0) \ + ? "overflow" \ + : "empty") ) + +#define STACK_STARTWALK(stack) (w_##stack = p_##stack) + +#define STACK_WALK(stack) (w_##stack >= stack \ + ? NULL : STACK_POP_(stack) ) + +#include "src/SDCCbitv.h" + +enum { + SYM_REC = 1, + LNK_REC, + FUNC_REC, + STRUCT_REC, + MOD_REC +}; + +enum { + FMT_NON = 0, + FMT_BIN = 1, + FMT_OCT = 2, + FMT_DEZ = 3, + FMT_HEX = 4 +}; + +enum { SRC_CMODE = 1, SRC_AMODE }; + +/*-----------------------------------------------------------------*/ +/* source line structure */ +/*-----------------------------------------------------------------*/ +typedef struct srcLine +{ + unsigned addr ; + short block, level; /* scope information */ + char *src ; + +} srcLine ; + +/*-----------------------------------------------------------------*/ +/* structure for cdb record */ +/*-----------------------------------------------------------------*/ +typedef struct cdbrecs { + char type ; /* type of line */ + char *line; /* contents of line */ + struct cdbrecs *next; /* next in chain */ +} cdbrecs ; + +/*-----------------------------------------------------------------*/ +/* module definition */ +/*-----------------------------------------------------------------*/ +typedef struct module { + char *cfullname ; /* full name Includeing path for the module */ + char *afullname; /* fullname of assembly file */ + char *name ; /* name of module */ + char *c_name; /* c filename */ + char *asm_name; /* asm file name */ + int ncLines; /* number of lines in this module */ + int nasmLines; /* # of lines in the assembler file */ + srcLine **cLines; /* actual source lines */ + srcLine **asmLines; /* actual assembler source lines*/ + set *cfpoints; /* set of double line execution points */ +} module; + +/*-----------------------------------------------------------------*/ +/* execution point definition */ +/*-----------------------------------------------------------------*/ +typedef struct exePoint +{ + unsigned addr ; + int line ; + short block , level ; +} exePoint ; + +/*-----------------------------------------------------------------*/ +/* definition for a function */ +/*-----------------------------------------------------------------*/ +typedef struct function { + struct symbol *sym ;/* pointer to symbol for function */ + char *modName ;/* module name */ + module *mod ;/* module for this function */ + int entryline ;/* first line in the function */ + int aentryline ; + int exitline ;/* last line in the function */ + int aexitline ; + set *cfpoints ;/* set of all C execution points in func */ + set *afpoints ;/* set of all ASM execution points in func */ + unsigned int laddr ;/* last executed address */ + int lline ;/* last executed linenumber */ + unsigned int stkaddr ;/* stackpointer at beginning of function + * (not reentrant ! ) only actual */ +} function ; + +/*-----------------------------------------------------------------*/ +/* link record defintion */ +/*-----------------------------------------------------------------*/ +typedef struct linkrec { + char type; /* type of linker rec */ + unsigned addr ; /* address specified by the linker rec */ + char *name ; /* name specified by linker rec */ +} linkrec; + +/*-----------------------------------------------------------------*/ +/* program context */ +/*-----------------------------------------------------------------*/ +typedef struct context { + function *func; /* current function we are in */ + char *modName; /* name of the module */ + unsigned int addr ; /* current pc */ + int cline ; /* current c line number */ + int asmline; /* current asm line number */ + int block ; /* current block number */ + int level ; /* current level number */ +} context ; + +/*-----------------------------------------------------------------*/ +/* symbol display information */ +/*-----------------------------------------------------------------*/ +typedef struct _dsymbol +{ + char *name; + int dnum; + int fmt; + char *rs; +} dsymbol; + + +extern cdbrecs *recsRoot ; +extern context *currCtxt ; +extern set *modules ; /* set of modules */ +extern set *functions; /* set of functions */ +extern set *symbols ; /* set of symbols */ +extern set *sfrsymbols;/* set of symbols of sfr or sbit */ +extern set *dispsymbols; /* set of displayable symbols */ + + +extern char *currModName ; +extern char userinterrupt ; +extern char nointerrupt ; +extern short showfull ; +extern int nStructs ; +extern struct structdef **structs ; /* all structures */ +extern char *ssdirl; /* source directory search path */ +void **resize (void **, int ); +char *alloccpy(char *,int ); +char *gc_strdup(const char *s); +srcLine **loadFile (char *name, int *nlines); + +extern short fullname; +extern int srcMode; +extern char contsim; +char *searchDirsFname (char *); +char *getNextCmdLine(void); +void setCmdLine(char *); +void stopCommandList(void); + +char *argsToCmdLine(char **args, int nargs); + +/* trimming functions */ +extern char *trim_left(char *s); +extern char *trim_right(char *s); +extern char *trim(char *s); + +#endif diff --git a/debugger/mcs51/sdcdb.vcxproj b/debugger/mcs51/sdcdb.vcxproj new file mode 100644 index 0000000..a0663d7 --- /dev/null +++ b/debugger/mcs51/sdcdb.vcxproj @@ -0,0 +1,116 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{76B78C5A-6B31-4BA1-9226-F1409B48F839}</ProjectGuid>
+ <RootNamespace>sdcdb</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\bin_vc\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\bin_vc\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\;..\..\support\util\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;WIN32;_CONSOLE;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineX86</TargetMachine>
+ <OutputFile>..\..\bin_vc\$(TargetFileName)</OutputFile>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <AdditionalIncludeDirectories>..\..\;..\..\support\util\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;WIN32;_CONSOLE;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineX86</TargetMachine>
+ <OutputFile>..\..\bin_vc\$(TargetFileName)</OutputFile>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="break.c" />
+ <ClCompile Include="cmd.c" />
+ <ClCompile Include="..\..\support\util\NewAlloc.c" />
+ <ClCompile Include="..\..\src\SDCCerr.c" />
+ <ClCompile Include="..\..\src\SDCChasht.c" />
+ <ClCompile Include="..\..\src\SDCCset.c" />
+ <ClCompile Include="sdcdb.c" />
+ <ClCompile Include="simi.c" />
+ <ClCompile Include="symtab.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="break.h" />
+ <ClInclude Include="cmd.h" />
+ <ClInclude Include="..\..\support\util\newalloc.h" />
+ <ClInclude Include="..\..\src\SDCCerr.h" />
+ <ClInclude Include="..\..\src\SDCChasht.h" />
+ <ClInclude Include="..\..\src\SDCCset.h" />
+ <ClInclude Include="sdcdb.h" />
+ <ClInclude Include="simi.h" />
+ <ClInclude Include="symtab.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/debugger/mcs51/sdcdb.vcxproj.filters b/debugger/mcs51/sdcdb.vcxproj.filters new file mode 100644 index 0000000..f5091cd --- /dev/null +++ b/debugger/mcs51/sdcdb.vcxproj.filters @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{6b949536-f21d-4c2c-bd9a-84b6a0455a08}</UniqueIdentifier>
+ <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{99f34930-b657-4537-9c23-8fdea5cc4519}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="break.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="cmd.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\support\util\NewAlloc.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\SDCCerr.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\SDCChasht.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\SDCCset.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="sdcdb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="simi.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="symtab.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="break.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="cmd.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\support\util\newalloc.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\SDCCerr.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\SDCChasht.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\SDCCset.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="sdcdb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="simi.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="symtab.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/debugger/mcs51/sdcdbsrc.el b/debugger/mcs51/sdcdbsrc.el new file mode 100644 index 0000000..7b3f7b9 --- /dev/null +++ b/debugger/mcs51/sdcdbsrc.el @@ -0,0 +1,1557 @@ +;;; sdcdbsrc.el -- Source-based (as opposed to comint-based) debugger +;; interaction mode eventually, this will be unified with GUD +;; (after gud works reliably w/ XEmacs...) +;; Keywords: c, unix, tools, debugging + +;; Copyright (C) 1990 Debby Ayers <ayers@austin.ibm.com>, and +;; Rich Schaefer <schaefer@asc.slb.com> +;; Copyright (C) 1994, 1995 Tinker Systems and INS Engineering Corp. +;; +;; Copyright (C) 1999 Sandeep Dutta <sandeep.dutta@usa.net> +;; +;; This file is part of XEmacs. +;; +;; XEmacs is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2 of the License, or +;; (at your option) any later version. +;; +;; XEmacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with XEmacs; if not, write to the Free Software +;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +;; Based upon code for version18 by Debra Ayers <ayers@austin.ibm.com> + +;;; SDCDBSRC:: +;;; Sdcdbsrc extends the emacs SDCDB interface to accept sdcdb commands issued +;;; from the source code buffer. Sdcdbsrc behaves similar to sdcdb except +;;; now most debugging may be done from the source code using the *sdcdb* +;;; buffer to view output. Supports a point and click model under X to +;;; evaluate source code expressions (no more typing long variable names). +;;; +;;; Supports C source at the moment but C++ support will be added if there +;;; is sufficient interest. +;;; + +;; SDCDBSRC::Sdcdb Source Mode Interface description. +;; Sdcdbsrc extends the emacs SDCDB interface to accept sdcdb commands issued +;; from the source code buffer. Sdcdbsrc behaves similar to sdcdb except now all +;; debugging may be done from the currently focused source buffer using +;; the *sdcdb* buffer to view output. + +;; When source files are displayed through sdcdbsrc, buffers are put in +;; sdcdbsrc-mode minor mode. This mode puts the buffer in read-only state +;; and sets up a special key and mouse map to invoke communication with +;; the current sdcdb process. The minor mode may be toggled on/off as needed. +;; (ESC-T) + +;; C-expressions may be evaluated by sdcdbsrc by simply pointing at text in the +;; current source buffer with the mouse or by centering the cursor over text +;; and typing a single key command. ('p' for print, '*' for print *). + +;; As code is debugged and new buffers are displayed, the focus of sdcdbsrc +;; follows to each new source buffer. Makes debugging fun. (sound like a +;; commercial or what!) +;; + +;; Current Listing :: +;;key binding Comment +;;--- ------- ------- +;; +;; r sdcdb-return-from-src SDCDB return command +;; n sdcdb-next-from-src SDCDB next command +;; b sdcdb-back-from-src SDCDB back command +;; w sdcdb-where-from-src SDCDB where command +;; f sdcdb-finish-from-src SDCDB finish command +;; u sdcdb-up-from-src SDCDB up command +;; d sdcdb-down-from-src SDCDB down command +;; c sdcdb-cont-from-src SDCDB continue command +;; i sdcdb-stepi-from-src SDCDB step instruction command +;; s sdcdb-step-from-src SDCDB step command +;; ? sdcdb-whatis-c-sexp SDCDB whatis command for data at +;; buffer point +;; x sdcdbsrc-delete SDCDB Delete all breakpoints if no arg +;; given or delete arg (C-u arg x) +;; m sdcdbsrc-frame SDCDB Display current frame if no arg, +;; given or display frame arg +;; * sdcdb-*print-c-sexp SDCDB print * command for data at +;; buffer point +;; ! sdcdbsrc-goto-sdcdb Goto the SDCDB output buffer +;; p sdcdb-print-c-sexp SDCDB print * command for data at +;; buffer point +;; g sdcdbsrc-goto-sdcdb Goto the SDCDB output buffer +;; t sdcdbsrc-mode Toggles Sdcdbsrc mode (turns it off) +;; +;; C-c C-f sdcdb-finish-from-src SDCDB finish command +;; +;; C-x SPC sdcdb-break Set break for line with point +;; ESC t sdcdbsrc-mode Toggle Sdcdbsrc mode +;; ESC m sdcdbsrc-srcmode Toggle list mode +;; +;; Local Bindings for buffer when you exit Sdcdbsrc minor mode +;; +;; C-x SPC sdcdb-break Set break for line with point +;; ESC t sdcdbsrc-mode Toggle Sdcdbsrc mode +;; + +;;; (eval-when-compile +;;; (or noninteractive +;;; (progn +;;; (message "ONLY compile sdcdbsrc except with -batch because of advice") +;;; (ding) +;;; ))) +;;; sdcdb.el --- run sdcdb under Emacs + +;; Author: W. Schelter, University of Texas +;; wfs@rascal.ics.utexas.edu +;; Rewritten by rms. +;; Keywords: c, unix, tools, debugging + +;; Some ideas are due to Masanobu. + +;; This file is part of XEmacs. + +;; XEmacs is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; XEmacs is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with XEmacs; see the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +;; 02111-1307, USA. + +;;; Synched up with: Not in FSF + +;;; Commentary: + +;; Description of SDCDB interface: + +;; A facility is provided for the simultaneous display of the source code +;; in one window, while using sdcdb to step through a function in the +;; other. A small arrow in the source window, indicates the current +;; line. + +;; Starting up: + +;; In order to use this facility, invoke the command SDCDB to obtain a +;; shell window with the appropriate command bindings. You will be asked +;; for the name of a file to run. Sdcdb will be invoked on this file, in a +;; window named *sdcdb-foo* if the file is foo. + +;; M-s steps by one line, and redisplays the source file and line. + +;; You may easily create additional commands and bindings to interact +;; with the display. For example to put the sdcdb command next on \M-n +;; (def-sdcdb next "\M-n") + +;; This causes the emacs command sdcdb-next to be defined, and runs +;; sdcdb-display-frame after the command. + +;; sdcdb-display-frame is the basic display function. It tries to display +;; in the other window, the file and line corresponding to the current +;; position in the sdcdb window. For example after a sdcdb-step, it would +;; display the line corresponding to the position for the last step. Or +;; if you have done a backtrace in the sdcdb buffer, and move the cursor +;; into one of the frames, it would display the position corresponding to +;; that frame. + +;; sdcdb-display-frame is invoked automatically when a filename-and-line-number +;; appears in the output. + +;;; Code: + +(require 'comint) +(require 'shell) + +(condition-case nil + (if (featurep 'toolbar) + (require 'eos-toolbar "sun-eos-toolbar")) + (error nil)) + +(defvar sdcdb-last-frame) +(defvar sdcdb-delete-prompt-marker) +(defvar sdcdb-filter-accumulator) +(defvar sdcdb-last-frame-displayed-p) +(defvar sdcdb-arrow-extent nil) +(or (fboundp 'make-glyph) (fset 'make-glyph 'identity)) ; work w/ pre beta v12 +(defvar sdcdb-arrow-glyph (make-glyph "=>")) + +(make-face 'sdcdb-arrow-face) +(or (face-differs-from-default-p 'sdcdb-arrow-face) + ;; Usually has a better default value than highlight does + (copy-face 'isearch 'sdcdb-arrow-face)) + +;; Hooks can side-effect extent arg to change extent properties +(defvar sdcdb-arrow-extent-hooks '()) + +(defvar sdcdb-prompt-pattern "^>\\|^(.*sdcdb[+]?) *\\|^---Type <return> to.*--- *" + "A regexp to recognize the prompt for sdcdb or sdcdb+.") + +(defvar sdcdb-mode-map nil + "Keymap for sdcdb-mode.") + +(defvar sdcdb-toolbar nil) + +(if sdcdb-mode-map + nil + (setq sdcdb-mode-map (make-sparse-keymap)) + (set-keymap-name sdcdb-mode-map 'sdcdb-mode-map) + (set-keymap-parents sdcdb-mode-map (list comint-mode-map)) + (define-key sdcdb-mode-map "\C-l" 'sdcdb-refresh) + (define-key sdcdb-mode-map "\C-c\C-c" 'sdcdb-control-c-subjob) + (define-key sdcdb-mode-map "\t" 'comint-dynamic-complete) + (define-key sdcdb-mode-map "\M-?" 'comint-dynamic-list-completions)) + +(define-key ctl-x-map " " 'sdcdb-break) +(define-key ctl-x-map "&" 'send-sdcdb-command) + +;;Of course you may use `def-sdcdb' with any other sdcdb command, including +;;user defined ones. + +(defmacro def-sdcdb (name key &optional doc &rest forms) + (let* ((fun (intern (format "sdcdb-%s" name))) + (cstr (list 'if '(not (= 1 arg)) + (list 'format "%s %s" name 'arg) + name))) + (list 'progn + (nconc (list 'defun fun '(arg) + (or doc "") + '(interactive "p") + (list 'sdcdb-call cstr)) + forms) + (and key (list 'define-key 'sdcdb-mode-map key (list 'quote fun)))))) + +(def-sdcdb "step" "\M-s" "Step one source line with display" + (sdcdb-delete-arrow-extent)) +(def-sdcdb "stepi" "\M-i" "Step one instruction with display" + (sdcdb-delete-arrow-extent)) +(def-sdcdb "finish" "\C-c\C-f" "Finish executing current function" + (sdcdb-delete-arrow-extent)) +(def-sdcdb "run" nil "Run the current program" + (sdcdb-delete-arrow-extent)) + +;;"next" and "cont" were bound to M-n and M-c in Emacs 18, but these are +;;poor choices, since M-n is used for history navigation and M-c is +;;capitalize-word. These are defined without key bindings so that users +;;may choose their own bindings. +(def-sdcdb "next" "\C-c\C-n" "Step one source line (skip functions)" + (sdcdb-delete-arrow-extent)) +(def-sdcdb "cont" "\C-c\M-c" "Proceed with the program" + (sdcdb-delete-arrow-extent)) + +(def-sdcdb "up" "\C-c<" "Go up N stack frames (numeric arg) with display") +(def-sdcdb "down" "\C-c>" "Go down N stack frames (numeric arg) with display") + +(defvar sdcdb-display-mode nil + "Minor mode for sdcdb frame display") +(or (assq 'sdcdb-display-mode minor-mode-alist) + (setq minor-mode-alist + (purecopy + (append minor-mode-alist + '((sdcdb-display-mode " Frame")))))) + +(defun sdcdb-display-mode (&optional arg) + "Toggle SDCDB Frame display mode +With arg, turn display mode on if and only if arg is positive. +In the display minor mode, source file are displayed in another +window for repective \\[sdcdb-display-frame] commands." + (interactive "P") + (setq sdcdb-display-mode (if (null arg) + (not sdcdb-display-mode) + (> (prefix-numeric-value arg) 0)))) + +;; Using cc-mode's syntax table is broken. +(defvar sdcdb-mode-syntax-table nil + "Syntax table for SDCDB mode.") + +;; This is adapted from CC Mode 5.11. +(unless sdcdb-mode-syntax-table + (setq sdcdb-mode-syntax-table (make-syntax-table)) + ;; DO NOT TRY TO SET _ (UNDERSCORE) TO WORD CLASS! + (modify-syntax-entry ?_ "_" sdcdb-mode-syntax-table) + (modify-syntax-entry ?\\ "\\" sdcdb-mode-syntax-table) + (modify-syntax-entry ?+ "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?- "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?= "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?% "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?< "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?> "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?& "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?| "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?\' "\"" sdcdb-mode-syntax-table) + ;; add extra comment syntax + (modify-syntax-entry ?/ ". 14" sdcdb-mode-syntax-table) + (modify-syntax-entry ?* ". 23" sdcdb-mode-syntax-table)) + + +(defun sdcdb-mode () + "Major mode for interacting with an inferior Sdcdb process. +The following commands are available: + +\\{sdcdb-mode-map} + +\\[sdcdb-display-frame] displays in the other window +the last line referred to in the sdcdb buffer. See also +\\[sdcdb-display-mode]. + +\\[sdcdb-step],\\[sdcdb-next], and \\[sdcdb-nexti] in the sdcdb window, +call sdcdb to step,next or nexti and then update the other window +with the current file and position. + +If you are in a source file, you may select a point to break +at, by doing \\[sdcdb-break]. + +Commands: +Many commands are inherited from comint mode. +Additionally we have: + +\\[sdcdb-display-frame] display frames file in other window +\\[sdcdb-step] advance one line in program +\\[send-sdcdb-command] used for special printing of an arg at the current point. +C-x SPACE sets break point at current line." + (interactive) + (comint-mode) + (use-local-map sdcdb-mode-map) + (set-syntax-table sdcdb-mode-syntax-table) + (make-local-variable 'sdcdb-last-frame-displayed-p) + (make-local-variable 'sdcdb-last-frame) + (make-local-variable 'sdcdb-delete-prompt-marker) + (make-local-variable 'sdcdb-display-mode) + (make-local-variable' sdcdb-filter-accumulator) + (setq sdcdb-last-frame nil + sdcdb-delete-prompt-marker nil + sdcdb-filter-accumulator nil + sdcdb-display-mode t + major-mode 'sdcdb-mode + mode-name "Inferior SDCDB" + comint-prompt-regexp sdcdb-prompt-pattern + sdcdb-last-frame-displayed-p t) + (set (make-local-variable 'shell-dirtrackp) t) + ;;(make-local-variable 'sdcdb-arrow-extent) + (and (extentp sdcdb-arrow-extent) + (delete-extent sdcdb-arrow-extent)) + (setq sdcdb-arrow-extent nil) + ;; XEmacs change: + (make-local-hook 'kill-buffer-hook) + (add-hook 'kill-buffer-hook 'sdcdb-delete-arrow-extent nil t) + (add-hook 'comint-input-filter-functions 'shell-directory-tracker nil t) + (run-hooks 'sdcdb-mode-hook)) + +(defun sdcdb-delete-arrow-extent () + (let ((inhibit-quit t)) + (if sdcdb-arrow-extent + (delete-extent sdcdb-arrow-extent)) + (setq sdcdb-arrow-extent nil))) + +(defvar current-sdcdb-buffer nil) + +;;;###autoload +(defvar sdcdb-command-name "sdcdb" + "Pathname for executing sdcdb.") +;; +;; default values should be changed as needed +;; +(defvar sdcdbsrc-cpu-type "51") +(defvar sdcdbsrc-frequency "11059200") +(defvar sdcdbsrc-serial nil) + +;;;###autoload +(defun sdcdb (path &optional corefile) + "Run sdcdb on program FILE in buffer *sdcdb-FILE*. +The directory containing FILE becomes the initial working directory +and source-file directory for SDCDB. If you wish to change this, use +the SDCDB commands `cd DIR' and `directory'." + (interactive "FRun sdcdb on file: ") + (setq path (file-truename (expand-file-name path))) + (let ((file (file-name-nondirectory path))) + (switch-to-buffer (concat "*sdcdb-" file "*")) + (setq default-directory (file-name-directory path)) + (or (bolp) (newline)) + (insert "Current directory is " default-directory "\n") + (apply 'make-comint + (concat "sdcdb-" file) + (substitute-in-file-name sdcdb-command-name) + nil + "-cpu" + sdcdbsrc-cpu-type + "-X" + sdcdbsrc-frequency + "-fullname" + file + (and corefile (list corefile))) + (set-process-filter (get-buffer-process (current-buffer)) 'sdcdb-filter) + (set-process-sentinel (get-buffer-process (current-buffer)) 'sdcdb-sentinel) + ;; XEmacs change: turn on sdcdb mode after setting up the proc filters + ;; for the benefit of shell-font.el + (sdcdb-mode) + (sdcdb-set-buffer))) + +;;;###autoload +(defun sdcdb-with-core (file corefile) + "Debug a program using a corefile." + (interactive "fProgram to debug: \nfCore file to use: ") + (sdcdb file corefile)) + +(defun sdcdb-set-buffer () + (cond ((eq major-mode 'sdcdb-mode) + (setq current-sdcdb-buffer (current-buffer)) + (if (featurep 'eos-toolbar) + (set-specifier default-toolbar (cons (current-buffer) + sdcdb-toolbar)))))) + + +;; This function is responsible for inserting output from SDCDB +;; into the buffer. +;; Aside from inserting the text, it notices and deletes +;; each filename-and-line-number; +;; that SDCDB prints to identify the selected frame. +;; It records the filename and line number, and maybe displays that file. +(defun sdcdb-filter (proc string) + (let ((inhibit-quit t)) + (save-current-buffer + (set-buffer (process-buffer proc)) + (if sdcdb-filter-accumulator + (sdcdb-filter-accumulate-marker + proc (concat sdcdb-filter-accumulator string)) + (sdcdb-filter-scan-input proc string))))) + +(defun sdcdb-filter-accumulate-marker (proc string) + (setq sdcdb-filter-accumulator nil) + (if (> (length string) 1) + (if (= (aref string 1) ?\032) + (let ((end (string-match "\n" string))) + (if end + (progn + (let* ((first-colon (string-match ":" string 2)) + (second-colon + (string-match ":" string (1+ first-colon)))) + (setq sdcdb-last-frame + (cons (substring string 2 first-colon) + (string-to-int + (substring string (1+ first-colon) + second-colon))))) + (setq sdcdb-last-frame-displayed-p nil) + (sdcdb-filter-scan-input proc + (substring string (1+ end)))) + (setq sdcdb-filter-accumulator string))) + (sdcdb-filter-insert proc "\032") + (sdcdb-filter-scan-input proc (substring string 1))) + (setq sdcdb-filter-accumulator string))) + +(defun sdcdb-filter-scan-input (proc string) + (if (equal string "") + (setq sdcdb-filter-accumulator nil) + (let ((start (string-match "\032" string))) + (if start + (progn (sdcdb-filter-insert proc (substring string 0 start)) + (sdcdb-filter-accumulate-marker proc + (substring string start))) + (sdcdb-filter-insert proc string))))) + +(defun sdcdb-filter-insert (proc string) + (let ((moving (= (point) (process-mark proc))) + (output-after-point (< (point) (process-mark proc)))) + (save-excursion + ;; Insert the text, moving the process-marker. + (goto-char (process-mark proc)) + (insert-before-markers string) + (set-marker (process-mark proc) (point)) + (sdcdb-maybe-delete-prompt) + ;; Check for a filename-and-line number. + (sdcdb-display-frame + ;; Don't display the specified file + ;; unless (1) point is at or after the position where output appears + ;; and (2) this buffer is on the screen. + (or output-after-point + (not (get-buffer-window (current-buffer)))) + ;; Display a file only when a new filename-and-line-number appears. + t)) + (if moving (goto-char (process-mark proc)))) + + (let (s) + (if (and (should-use-dialog-box-p) + (setq s (or (string-match " (y or n) *\\'" string) + (string-match " (yes or no) *\\'" string)))) + (sdcdb-mouse-prompt-hack (substring string 0 s) (current-buffer)))) + ) + +(defun sdcdb-mouse-prompt-hack (prompt buffer) + (popup-dialog-box + (list prompt + (vector "Yes" (list 'sdcdb-mouse-prompt-hack-answer 't buffer) t) + (vector "No" (list 'sdcdb-mouse-prompt-hack-answer 'nil buffer) t) + nil + (vector "Cancel" (list 'sdcdb-mouse-prompt-hack-answer 'nil buffer) t) + ))) + +(defun sdcdb-mouse-prompt-hack-answer (answer buffer) + (let ((b (current-buffer))) + (unwind-protect + (progn + (set-buffer buffer) + (goto-char (process-mark (get-buffer-process buffer))) + (delete-region (point) (point-max)) + (insert (if answer "yes" "no")) + (comint-send-input)) + (set-buffer b)))) + +(defun sdcdb-sentinel (proc msg) + (cond ((null (buffer-name (process-buffer proc))) + ;; buffer killed + ;; Stop displaying an arrow in a source file. + ;(setq overlay-arrow-position nil) -- done by kill-buffer-hook + (set-process-buffer proc nil)) + ((memq (process-status proc) '(signal exit)) + ;; Stop displaying an arrow in a source file. + (sdcdb-delete-arrow-extent) + ;; Fix the mode line. + (setq modeline-process + (concat ": sdcdb " (symbol-name (process-status proc)))) + (let* ((obuf (current-buffer))) + ;; save-excursion isn't the right thing if + ;; process-buffer is current-buffer + (unwind-protect + (progn + ;; Write something in *compilation* and hack its mode line, + (set-buffer (process-buffer proc)) + ;; Force mode line redisplay soon + (set-buffer-modified-p (buffer-modified-p)) + (if (eobp) + (insert ?\n mode-name " " msg) + (save-excursion + (goto-char (point-max)) + (insert ?\n mode-name " " msg))) + ;; If buffer and mode line will show that the process + ;; is dead, we can delete it now. Otherwise it + ;; will stay around until M-x list-processes. + (delete-process proc)) + ;; Restore old buffer, but don't restore old point + ;; if obuf is the sdcdb buffer. + (set-buffer obuf)))))) + + +(defun sdcdb-refresh (&optional arg) + "Fix up a possibly garbled display, and redraw the arrow." + (interactive "P") + (recenter arg) + (sdcdb-display-frame)) + +(defun sdcdb-display-frame (&optional nodisplay noauto) + "Find, obey and delete the last filename-and-line marker from SDCDB. +The marker looks like \\032\\032FILENAME:LINE:CHARPOS\\n. +Obeying it means displaying in another window the specified file and line." + (interactive) + (sdcdb-set-buffer) + (and sdcdb-last-frame (not nodisplay) + sdcdb-display-mode + (or (not sdcdb-last-frame-displayed-p) (not noauto)) + (progn (sdcdb-display-line (car sdcdb-last-frame) (cdr sdcdb-last-frame)) + (setq sdcdb-last-frame-displayed-p t)))) + +;; Make sure the file named TRUE-FILE is in a buffer that appears on the screen +;; and that its line LINE is visible. +;; Put the overlay-arrow on the line LINE in that buffer. + +(defun sdcdb-display-line (true-file line &optional select-method) + ;; FILE to display + ;; LINE number to highlight and make visible + ;; SELECT-METHOD 'source, 'debugger, or 'none. (default is 'debugger) + (and (null select-method) (setq select-method 'debugger)) + (let* ((pre-display-buffer-function nil) ; screw it, put it all in one screen + (pop-up-windows t) + (source-buffer (find-file-noselect true-file)) + (source-window (display-buffer source-buffer)) + (debugger-window (get-buffer-window current-sdcdb-buffer)) + (extent sdcdb-arrow-extent) + pos) + ;; XEmacs change: make sure we find a window displaying the source file + ;; even if we are already sitting in it when a breakpoint is hit. + ;; Otherwise the t argument to display-buffer will prevent it from being + ;; displayed. + (save-excursion + (cond ((eq select-method 'debugger) + ;; might not already be displayed + (setq debugger-window (display-buffer current-sdcdb-buffer)) + (select-window debugger-window)) + ((eq select-method 'source) + (select-window source-window)))) + (and extent + (not (eq (extent-object extent) source-buffer)) + (setq extent (delete-extent extent))) + (or extent + (progn + (setq extent (make-extent 1 1 source-buffer)) + (set-extent-face extent 'sdcdb-arrow-face) + (set-extent-begin-glyph extent sdcdb-arrow-glyph) + (set-extent-begin-glyph-layout extent 'whitespace) + (set-extent-priority extent 2000) + (setq sdcdb-arrow-extent extent))) + (save-current-buffer + (set-buffer source-buffer) + (save-restriction + (widen) + (goto-line line) + (set-window-point source-window (point)) + (setq pos (point)) + (end-of-line) + (set-extent-endpoints extent pos (point)) + (run-hook-with-args 'sdcdb-arrow-extent-hooks extent)) + (cond ((or (< pos (point-min)) (> pos (point-max))) + (widen) + (goto-char pos)))) + ;; Added by Stig. It caused lots of problems for several users + ;; and since its purpose is unclear it is getting commented out. + ;;(and debugger-window + ;; (set-window-point debugger-window pos)) + )) + +(defun sdcdb-call (command) + "Invoke sdcdb COMMAND displaying source in other window." + (interactive) + (goto-char (point-max)) + ;; Record info on the last prompt in the buffer and its position. + ;; This is used in sdcdb-maybe-delete-prompt + ;; to prevent multiple prompts from accumulating. + (save-excursion + (goto-char (process-mark (get-buffer-process current-sdcdb-buffer))) + (let ((pt (point))) + (beginning-of-line) + (setq sdcdb-delete-prompt-marker + (if (= (point) pt) + nil + (list (point-marker) (- pt (point)) + (buffer-substring (point) pt)))))) + (sdcdb-set-buffer) + (process-send-string (get-buffer-process current-sdcdb-buffer) + (concat command "\n"))) + +(defun sdcdb-maybe-delete-prompt () + (if sdcdb-delete-prompt-marker + ;; Get the string that we used as the prompt before. + (let ((prompt (nth 2 sdcdb-delete-prompt-marker)) + (length (nth 1 sdcdb-delete-prompt-marker))) + ;; Position after it. + (goto-char (+ (car sdcdb-delete-prompt-marker) length)) + ;; Delete any duplicates of it which follow right after. + (while (and (<= (+ (point) length) (point-max)) + (string= prompt + (buffer-substring (point) (+ (point) length)))) + (delete-region (point) (+ (point) length))) + ;; If that didn't take us to where output is arriving, + ;; we have encountered something other than a prompt, + ;; so stop trying to delete any more prompts. + (if (not (= (point) + (process-mark (get-buffer-process current-sdcdb-buffer)))) + (progn + (set-marker (car sdcdb-delete-prompt-marker) nil) + (setq sdcdb-delete-prompt-marker nil)))))) + +(defun sdcdb-break (temp) + "Set SDCDB breakpoint at this source line. With ARG set temporary breakpoint." + (interactive "P") + (let* ((file-name (file-name-nondirectory buffer-file-name)) + (line (save-restriction + (widen) + (beginning-of-line) + (1+ (count-lines 1 (point))))) + (cmd (concat (if temp "tbreak " "break ") file-name ":" + (int-to-string line)))) + (set-buffer current-sdcdb-buffer) + (goto-char (process-mark (get-buffer-process current-sdcdb-buffer))) + (delete-region (point) (point-max)) + (insert cmd) + (comint-send-input) + ;;(process-send-string (get-buffer-process current-sdcdb-buffer) cmd) + )) + +(defun sdcdb-clear () + "Set SDCDB breakpoint at this source line." + (interactive) + (let* ((file-name (file-name-nondirectory buffer-file-name)) + (line (save-restriction + (widen) + (beginning-of-line) + (1+ (count-lines 1 (point))))) + (cmd (concat "clear " file-name ":" + (int-to-string line)))) + (set-buffer current-sdcdb-buffer) + (goto-char (process-mark (get-buffer-process current-sdcdb-buffer))) + (delete-region (point) (point-max)) + (insert cmd) + (comint-send-input) + ;;(process-send-string (get-buffer-process current-sdcdb-buffer) cmd) + )) + +(defun sdcdb-read-address() + "Return a string containing the core-address found in the buffer at point." + (save-excursion + (let ((pt (point)) found begin) + (setq found (if (search-backward "0x" (- pt 7) t)(point))) + (cond (found (forward-char 2) + (buffer-substring found + (progn (re-search-forward "[^0-9a-f]") + (forward-char -1) + (point)))) + (t (setq begin (progn (re-search-backward "[^0-9]") (forward-char 1) + (point))) + (forward-char 1) + (re-search-forward "[^0-9]") + (forward-char -1) + (buffer-substring begin (point))))))) + + +(defvar sdcdb-commands nil + "List of strings or functions used by send-sdcdb-command. +It is for customization by you.") + +(defun send-sdcdb-command (arg) + + "This command reads the number where the cursor is positioned. It + then inserts this ADDR at the end of the sdcdb buffer. A numeric arg + selects the ARG'th member COMMAND of the list sdcdb-print-command. If + COMMAND is a string, (format COMMAND ADDR) is inserted, otherwise + (funcall COMMAND ADDR) is inserted. eg. \"p (rtx)%s->fld[0].rtint\" + is a possible string to be a member of sdcdb-commands. " + + + (interactive "P") + (let (comm addr) + (if arg (setq comm (nth arg sdcdb-commands))) + (setq addr (sdcdb-read-address)) + (if (eq (current-buffer) current-sdcdb-buffer) + (set-mark (point))) + (cond (comm + (setq comm + (if (stringp comm) (format comm addr) (funcall comm addr)))) + (t (setq comm addr))) + (switch-to-buffer current-sdcdb-buffer) + (goto-char (point-max)) + (insert comm))) + +(fset 'sdcdb-control-c-subjob 'comint-interrupt-subjob) + +;(defun sdcdb-control-c-subjob () +; "Send a Control-C to the subprocess." +; (interactive) +; (process-send-string (get-buffer-process (current-buffer)) +; "\C-c")) + +(defun sdcdb-toolbar-break () + (interactive) + (save-excursion + (message (car sdcdb-last-frame)) + (set-buffer (find-file-noselect (car sdcdb-last-frame))) + (sdcdb-break nil))) + +(defun sdcdb-toolbar-clear () + (interactive) + (save-excursion + (message (car sdcdb-last-frame)) + (set-buffer (find-file-noselect (car sdcdb-last-frame))) + (sdcdb-clear))) + +(provide 'sdcdb) + +(require 'sdcdb "sdcdb") ; NOT gud! (yet...) + +(defvar sdcdbsrc-active-p t + "*Set to nil if you do not want source files put in sdcdbsrc-mode") + +(defvar sdcdbsrc-call-p nil + "True if sdcdb command issued from a source buffer") + +(defvar sdcdbsrc-associated-buffer nil + "Buffer name of attached sdcdb process") + +(defvar sdcdbsrc-mode nil + "Indicates whether buffer is in sdcdbsrc-mode or not") +(make-variable-buffer-local 'sdcdbsrc-mode) + +(defvar sdcdbsrc-global-mode nil + "Indicates whether global sdcdbsrc bindings are in effect or not") + +(defvar sdcdb-prompt-pattern "^[^)#$%>\n]*[)#$%>] *" + "A regexp for matching the end of the sdcdb prompt") + +(defvar eos::toolbar-toggle-srcmode + + (toolbar-make-button-list + (expand-file-name "recycle.xbm" eos::toolbar-icon-directory)) + "A Run icon pair.") +;;; bindings + +(defvar sdcdbsrc-global-map + (let ((map (make-sparse-keymap))) + (set-keymap-name map 'sdcdbsrc-global-map) + (define-key map "\C-x " 'sdcdb-break) + (define-key map "\M-\C-t" 'sdcdbsrc-mode) + (define-key map "\M-\C-g" 'sdcdbsrc-goto-sdcdb) + (define-key map "\M-m" 'sdcdbsrc-srcmode) + ;; middle button to select and print expressions... + (define-key map '(meta button2) 'sdcdbsrc-print-csexp) + (define-key map '(meta shift button2) 'sdcdbsrc-*print-csexp) + ;; left button to position breakpoints + (define-key map '(meta button1) 'sdcdbsrc-set-break) + (define-key map '(meta shift button1) 'sdcdbsrc-set-tbreak-continue) + map) + "Global minor keymap that is active whenever sdcdbsrc is running.") + +(add-minor-mode 'sdcdbsrc-global-mode " SdcdbGlobal" sdcdbsrc-global-map) + +(defvar sdcdbsrc-mode-map + (let ((map (make-sparse-keymap))) + (suppress-keymap map) + (set-keymap-name map 'sdcdbsrc-mode-map) + ;; inherit keys from global sdcdbsrc map just in case that somehow gets turned off. + (set-keymap-parents map (list sdcdbsrc-global-map)) + (define-key map "\C-x\C-q" 'sdcdbsrc-mode) ; toggle read-only + (define-key map "\C-c\C-c" 'sdcdbsrc-mode) + (define-key map "b" 'sdcdb-break) + (define-key map "g" 'sdcdbsrc-goto-sdcdb) + (define-key map "!" 'sdcdbsrc-goto-sdcdb) + (define-key map "p" 'sdcdb-print-c-sexp) + (define-key map "*" 'sdcdb-*print-c-sexp) + (define-key map "?" 'sdcdb-whatis-c-sexp) + (define-key map "R" 'sdcdbsrc-reset) + map) + "Minor keymap for buffers in sdcdbsrc-mode") + +(add-minor-mode 'sdcdbsrc-mode " SdcdbSrc" sdcdbsrc-mode-map) + +(defvar sdcdbsrc-toolbar + '([eos::toolbar-stop-at-icon + sdcdb-break + t + "Stop at selected position"] + [eos::toolbar-stop-in-icon + sdcdb-break + t + "Stop in function whose name is selected"] + [eos::toolbar-clear-at-icon + sdcdb-clear + t + "Clear at selected position"] + [eos::toolbar-evaluate-icon + sdcdb-print-c-sexp + t + "Evaluate selected expression; shows in separate XEmacs frame"] + [eos::toolbar-run-icon + sdcdbsrc-run + t + "Run current program"] + [eos::toolbar-cont-icon + sdcdbsrc-cont + t + "Continue current program"] + [eos::toolbar-step-into-icon + sdcdbsrc-step + t + "Step into (aka step)"] + [eos::toolbar-step-over-icon + sdcdbsrc-next + t + "Step over (aka next)"] + [eos::toolbar-fix-icon + nil + nil + "Fix (not available with sdcdb)"] + [eos::toolbar-build-icon + toolbar-compile + t + "Build (aka make -NYI)"] + [eos::toolbar-toggle-srcmode + sdcdbsrc-srcmode + t + "Toggle Source C <-> Asm"] + )) + +(defmacro def-sdcdb-from-src (sdcdb-command key &optional doc &rest forms) + "Create a function that will call SDCDB-COMMAND with KEY." + (let* ((fname (format "sdcdbsrc-%s" sdcdb-command)) + (cstr (list 'if 'arg + (list 'format "%s %s" sdcdb-command '(prefix-numeric-value arg)) + sdcdb-command)) + fun) + (while (string-match " " fname) + (aset fname (match-beginning 0) ?-)) + (setq fun (intern fname)) + + (list 'progn + (nconc (list 'defun fun '(arg) + (or doc "") + '(interactive "P") + (list 'sdcdb-call-from-src cstr)) + forms) + (list 'define-key 'sdcdbsrc-mode-map key (list 'quote fun))))) + +(def-sdcdb-from-src "step" "s" "Step one instruction in src" + (sdcdb-delete-arrow-extent)) +(def-sdcdb-from-src "stepi" "i" "Step one source line (skip functions)" + (sdcdb-delete-arrow-extent)) +(def-sdcdb-from-src "cont" "c" "Continue with display" + (sdcdb-delete-arrow-extent)) +(def-sdcdb-from-src "down" "d" "Go down N stack frames (numeric arg) ") +(def-sdcdb-from-src "up" "u" "Go up N stack frames (numeric arg)") +(def-sdcdb-from-src "finish" "f" "Finish frame") +(def-sdcdb-from-src "where" "w" "Display (N frames of) backtrace") +(def-sdcdb-from-src "next" "n" "Step one line with display" + (sdcdb-delete-arrow-extent)) +(def-sdcdb-from-src "run" "r" "Run program from start" + (sdcdb-delete-arrow-extent)) +(def-sdcdb-from-src "return" "R" "Return from selected stack frame") +(def-sdcdb-from-src "disable" "x" "Disable all breakpoints") +(def-sdcdb-from-src "delete" "X" "Delete all breakpoints") +(def-sdcdb-from-src "quit" "Q" "Quit sdcdb." + (sdcdb-delete-arrow-extent)) +(def-sdcdb-from-src "info locals" "l" "Show local variables") +(def-sdcdb-from-src "info break" "B" "Show breakpoints") +(def-sdcdb-from-src "" "\r" "Repeat last command") +(def-sdcdb-from-src "frame" "m" "Show frame if no arg, with arg go to frame") + +;;; code + +;;;###autoload +(defun sdcdbsrc (path &optional core-or-pid) + "Activates a sdcdb session with sdcdbsrc-mode turned on. A numeric prefix +argument can be used to specify a running process to attach, and a non-numeric +prefix argument will cause you to be prompted for a core file to debug." + (interactive (let ((file (read-file-name "Program to debug: " nil nil t))) + (cond ((numberp current-prefix-arg) + (list file (int-to-string current-prefix-arg))) + (current-prefix-arg + (list file (read-file-name "Core file: " nil nil t))) + (t (list file))) + )) + ;; FIXME - this is perhaps an uncool thing to do --Stig + (delete-other-windows) + (split-window-vertically) + (other-window 0) + + (sdcdb path core-or-pid) + (local-set-key 'button2 'sdcdbsrc-select-or-yank) + (setq mode-motion-hook 'sdcdbsrc-mode-motion) + ;; XEmacs change: + (make-local-hook 'kill-buffer-hook) + (add-hook 'kill-buffer-hook 'sdcdbsrc-reset nil t)) + +(defun sdcdbsrc-global-mode () + ;; this can be used as a hook for sdcdb-mode.... + (or current-sdcdb-buffer + (and (eq major-mode 'sdcdb-mode) ; doesn't work w/ energize yet + (setq current-sdcdb-buffer (current-buffer)) + ;; XEmacs change: + (progn + (make-local-hook 'kill-buffer-hook) + (add-hook 'kill-buffer-hook 'sdcdbsrc-reset nil t))) + (error "Cannot determine current-sdcdb-buffer")) +;;; (set-process-filter +;;; (get-buffer-process current-sdcdb-buffer) 'sdcdbsrc-mode-filter) +;;; (set-process-sentinel +;;; (get-buffer-process current-sdcdb-buffer) 'sdcdbsrc-mode-sentinel) + ;; sdcdbsrc-global-mode was set to t here but that tended to piss + ;; people off + (setq sdcdbsrc-global-mode nil + sdcdbsrc-active-p t + sdcdbsrc-call-p nil + sdcdbsrc-mode nil) + (message "Gbd source mode active")) + +(add-hook 'sdcdb-mode-hook 'sdcdbsrc-global-mode) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Sdcdb Source minor mode. +;;; + +(defvar sdcdbsrc-associated-buffer nil + "The sdcdb buffer to send commands to.") +(defvar sdcdbsrc-initial-readonly 'undefined + "read-only status of buffer when not in sdcdbsrc-mode") +(defvar sdcdbsrc-old-toolbar nil + "saved toolbar for buffer") + +(defun sdcdbsrc-mode (arg &optional quiet) + "Minor mode for interacting with sdcdb from a c source file. +With arg, turn sdcdbsrc-mode on iff arg is positive. In sdcdbsrc-mode, +you may send an associated sdcdb buffer commands from the current buffer +containing c source code." + (interactive "P") + (setq sdcdbsrc-mode + (if (null arg) + (not sdcdbsrc-mode) + (> (prefix-numeric-value arg) 0))) + + (cond (sdcdbsrc-mode + (cond ((not (local-variable-p 'sdcdbsrc-initial-readonly (current-buffer))) + (set (make-local-variable 'sdcdbsrc-initial-readonly) + buffer-read-only) + (set (make-local-variable 'sdcdbsrc-associated-buffer) + current-sdcdb-buffer) + (if (featurep 'toolbar) + (set (make-local-variable 'sdcdbsrc-old-toolbar) + (specifier-specs default-toolbar (current-buffer)))) + ) + ) + (if (featurep 'toolbar) + (set-specifier default-toolbar (cons (current-buffer) + sdcdbsrc-toolbar))) + (setq buffer-read-only t) + (or quiet (message "Entering sdcdbsrc-mode..."))) + (t + (and (local-variable-p 'sdcdbsrc-initial-readonly (current-buffer)) + (progn + (if (featurep 'toolbar) + (if sdcdbsrc-old-toolbar + (set-specifier default-toolbar + (cons (current-buffer) + sdcdbsrc-old-toolbar)) + (remove-specifier default-toolbar (current-buffer)))) + (kill-local-variable 'sdcdbsrc-old-toolbar) + (setq buffer-read-only sdcdbsrc-initial-readonly) + (kill-local-variable 'sdcdbsrc-initial-readonly) + (kill-local-variable 'sdcdbsrc-associated-buffer) + )) + (or quiet (message "Exiting sdcdbsrc-mode...")))) + (redraw-modeline t)) + +;; +;; Sends commands to sdcdb process. + +(defun sdcdb-call-from-src (command) + "Send associated sdcdb process COMMAND displaying source in this window." + (setq sdcdbsrc-call-p t) + (let ((src-win (selected-window)) + (buf (or sdcdbsrc-associated-buffer current-sdcdb-buffer))) + (or (buffer-name buf) + (error "SDCDB buffer deleted")) + (pop-to-buffer buf) + (goto-char (point-max)) + (beginning-of-line) + ;; Go past sdcdb prompt + (re-search-forward + sdcdb-prompt-pattern (save-excursion (end-of-line) (point)) t) + ;; Delete any not-supposed-to-be-there text + (delete-region (point) (point-max)) + (insert command) + (comint-send-input) + (select-window src-win) + )) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; +;;; Define Commands for SDCDB SRC Mode Buffer +;;; + +;;; ;; #### - move elsewhere +(or (fboundp 'event-buffer) + (defun event-buffer (event) + "Return buffer assocaited with EVENT, or nil." + (let ((win (event-window event))) + (and win (window-buffer win))))) + +(defun set-sdcdbsrc-mode-motion-extent (st en action) + ;; by Stig@hackvan.com + (let ((ex (make-extent st en))) + (set-extent-face ex 'highlight) + (set-extent-property ex 'sdcdbsrc t) + (set-extent-property ex 'action action) + (setq mode-motion-extent ex))) + +(defun nuke-mode-motion-extent () + ;; by Stig@hackvan.com + (cond (mode-motion-extent + (delete-extent mode-motion-extent) + (setq mode-motion-extent nil)))) + +(defun looking-at-any (regex-list) + ;; by Stig@hackvan.com + (catch 'found + (while regex-list + (and (looking-at (car regex-list)) + (throw 'found t)) + (setq regex-list (cdr regex-list))))) + +(defconst sdcdb-breakpoint-patterns + '( + ;; when execution stops... + ;;Breakpoint 1, XlwMenuRedisplay (w=0x4d2e00, ev=0xefffe3f8, region=0x580e60) + ;; at /net/stig/src/xemacs/lwlib/xlwmenu.c:2518 + "^[BW][ra][et][ac][kh]point [0-9]+, .*\\(\n\\s .*\\)*" + ;; output of the breakpoint command: + ;;Breakpoint 1 at 0x19f5c8: file /net/stig/src/xemacs/lwlib/xlwmenu.c, line 2715. + "^[BW][ra][et][ac][kh]point [0-9]+ at .*: file \\([^ ,\n]+\\), line \\([0-9]+\\)." + ;;Num Type Disp Enb Address What + ;;1 breakpoint keep y 0x0019ee60 in XlwMenuRedisplay + ;; at /net/stig/src/xemacs/lwlib/xlwmenu.c:2518 + "^[0-9]+\\s +[bw][ra][et][ac][kh]point.* in .*\\(\n\\s +\\)?at [^ :\n]+:[0-9]+\\(\n\\s .*\\)*" + ) + "list of patterns to match sdcdb's various ways of displaying a breakpoint") + +(defun sdcdbsrc-make-breakpoint-action (string) + ;; by Stig@hackvan.com + (if (or (string-match "file \\([^ ,\n]+\\), line \\([0-9]+\\)" string) + (string-match "at \\([^ :\n]+\\):\\([0-9]+\\)" string)) + (list 'sdcdbsrc-display + (match-string 1 string) + (string-to-int (match-string 2 string))))) + +(defconst sdcdb-stack-frame-pattern + ;;#9 0x62f08 in emacs_Xt_next_event (emacs_event=0x4cf804) + ;; at /net/stig/src/xemacs/src/event-Xt.c:1778 + "^#\\([0-9]+\\)\\s +\\(0x[0-9a-f]+ in .*\\|.*\\sw+.* (.*) at .*\\)\\(\n\\s .*\\)*" + "matches the first line of a sdcdb stack frame and all continuation lines. +subex 1 is frame number.") + +(defun sdcdbsrc-mode-motion (ee) + ;; by Stig@hackvan.com + (save-excursion + (set-buffer (event-buffer ee)) + (save-excursion + (if (not (event-point ee)) + (nuke-mode-motion-extent) + (goto-char (event-point ee)) + (beginning-of-line) + (while (and (not (bobp)) (eq ? (char-syntax (following-char)))) + (forward-line -1)) + (if (extent-at (point) (current-buffer) 'sdcdbsrc) + nil + (nuke-mode-motion-extent) + (cond ((looking-at-any sdcdb-breakpoint-patterns) + (set-sdcdbsrc-mode-motion-extent + (match-beginning 0) + (match-end 0) + (sdcdbsrc-make-breakpoint-action (match-string 0)))) + ((looking-at sdcdb-stack-frame-pattern) + (set-sdcdbsrc-mode-motion-extent + (match-beginning 0) + (match-end 0) + (list 'sdcdbsrc-frame + (string-to-int (match-string 1))))) + ))) + ))) + +(defun sdcdbsrc-display (file line) + ;; by Stig@hackvan.com + (select-window (display-buffer (find-file-noselect file))) + (goto-line line)) + +(defun click-inside-selection-p (click) + (or (click-inside-extent-p click primary-selection-extent) + (click-inside-extent-p click zmacs-region-extent) + )) + +(defun click-inside-extent-p (click extent) + "Returns non-nil if the button event is within the bounds of the primary +selection-extent, nil otherwise." + ;; stig@hackvan.com + (let ((ewin (event-window click)) + (epnt (event-point click))) + (and ewin + epnt + extent + (eq (window-buffer ewin) + (extent-object extent)) + (extent-start-position extent) + (> epnt (extent-start-position extent)) + (> (extent-end-position extent) epnt)))) + +(defun point-inside-extent-p (extent) + "Returns non-nil if the point is within or just after the bounds of the +primary selection-extent, nil otherwise." + ;; stig@hackvan.com + (and extent ; FIXME - I'm such a sinner... + (eq (current-buffer) + (extent-object extent)) + (> (point) (extent-start-position extent)) + (>= (extent-end-position extent) (point)))) + +(defun sdcdbsrc-select-or-yank (ee) + ;; by Stig@hackvan.com + (interactive "e") + (let ((action (save-excursion + (set-buffer (event-buffer ee)) + (and mode-motion-extent + (click-inside-extent-p ee mode-motion-extent) + (extent-property mode-motion-extent 'action))) + )) + (if action + (eval action) + (mouse-yank ee)))) + +(defvar sdcdb-print-format "" + "Set this variable to a valid format string to print c-sexps in a +different way (hex,octal, etc).") + +(defun sdcdb-print-c-sexp () + "Find the nearest c-mode sexp. Send it to sdcdb with print command." + (interactive) + (let* ((tag (find-c-sexp)) + (command (concat "print " sdcdb-print-format tag))) + (sdcdb-call-from-src command))) + +(defun sdcdbsrc-srcmode () + "Toggle between assembler & C source modes." + (sdcdb-call-from-src "set srcmode")) + +(defun sdcdb-*print-c-sexp () + "Find the nearest c-mode sexp. Send it to sdcdb with the print * command." + (interactive) + (let* ((tag (find-c-sexp)) + (command (concat "print " sdcdb-print-format "*" tag))) + (sdcdb-call-from-src command))) + +(defun sdcdb-whatis-c-sexp () + "Find the nearest c-mode sexp. Send it to sdcdb with the whatis command. " + (interactive) + (let* ((tag (sdcdbsrc-selection-or-sexp)) + (command (concat "ptype " tag))) + (sdcdb-call-from-src command))) + +(defun sdcdbsrc-goto-sdcdb () + "Hop back and forth between the sdcdb interaction buffer and the sdcdb source +buffer. " + ;; by Stig@hackvan.com + (interactive) + (let ((gbuf (or sdcdbsrc-associated-buffer current-sdcdb-buffer))) + (cond ((eq (current-buffer) gbuf) + (and sdcdb-arrow-extent + (extent-object sdcdb-arrow-extent) + (progn (pop-to-buffer (extent-object sdcdb-arrow-extent)) + (goto-char (extent-start-position sdcdb-arrow-extent))))) + ((buffer-name gbuf) (pop-to-buffer gbuf)) + ((y-or-n-p "No debugger. Start a new one? ") + (call-interactively 'sdcdbsrc)) + (t (error "No sdcdb buffer.")) + ))) + +(defvar sdcdbsrc-last-src-buffer nil) + +(defun sdcdbsrc-goto-src () + (interactive) + (let* ((valid (and sdcdbsrc-last-src-buffer + (memq sdcdbsrc-last-src-buffer (buffer-list)))) + (win (and valid + (get-buffer-window sdcdbsrc-last-src-buffer)))) + (cond (win (select-window win)) + (valid (pop-to-buffer sdcdbsrc-last-src-buffer))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; +;;; The following functions are used to extract the closest surrounding +;;; c expression from point +;;; +(defun back-sexp () + "Version of backward-sexp that catches errors" + (condition-case nil + (backward-sexp) + (error t))) + +(defun forw-sexp () + "Version of forward-sexp that catches errors" + (condition-case nil + (forward-sexp) + (error t))) + +(defun sexp-compound-sep (span-start span-end) + "Returns '.' for '->' & '.', returns ' ' for white space, +returns '?' for other puctuation" + (let ((result ? ) + (syntax)) + (while (< span-start span-end) + (setq syntax (char-syntax (char-after span-start))) + (cond + ((= syntax ? ) t) + ((= syntax ?.) (setq syntax (char-after span-start)) + (cond + ((= syntax ?.) (setq result ?.)) + ((and (= syntax ?-) (= (char-after (+ span-start 1)) ?>)) + (setq result ?.) + (setq span-start (+ span-start 1))) + (t (setq span-start span-end) + (setq result ??))))) + (setq span-start (+ span-start 1))) + result + ) + ) + +(defun sexp-compound (first second) + "Returns non-nil if the concatenation of two S-EXPs result in a Single C +token. The two S-EXPs are represented as a cons cells, where the car +specifies the point in the current buffer that marks the begging of the +S-EXP and the cdr specifies the character after the end of the S-EXP +Link S-Exps of the form: + Sexp -> SexpC + Sexp . Sexp + Sexp (Sexp) Maybe exclude if first Sexp is: if, while, do, for, switch + Sexp [Sexp] + (Sexp) Sexp + [Sexp] Sexp" + (let ((span-start (cdr first)) + (span-end (car second)) + (syntax)) + (setq syntax (sexp-compound-sep span-start span-end)) + (cond + ((= (car first) (car second)) nil) + ((= (cdr first) (cdr second)) nil) + ((= syntax ?.) t) + ((= syntax ? ) + (setq span-start (char-after (- span-start 1))) + (setq span-end (char-after span-end)) + (cond + ((= span-start ?) ) t ) + ((= span-start ?] ) t ) + ((= span-end ?( ) t ) + ((= span-end ?[ ) t ) + (t nil)) + ) + (t nil)) + ) + ) + +(defun sexp-cur () + "Returns the S-EXP that Point is a member, Point is set to begging of S-EXP. +The S-EXPs is represented as a cons cell, where the car specifies the point in +the current buffer that marks the begging of the S-EXP and the cdr specifies +the character after the end of the S-EXP" + (let ((p (point)) (begin) (end)) + (back-sexp) + (setq begin (point)) + (forw-sexp) + (setq end (point)) + (if (>= p end) + (progn + (setq begin p) + (goto-char p) + (forw-sexp) + (setq end (point)) + ) + ) + (goto-char begin) + (cons begin end) + ) + ) + +(defun sexp-prev () + "Returns the previous S-EXP, Point is set to begging of that S-EXP. +The S-EXPs is represented as a cons cell, where the car specifies the point in +the current buffer that marks the begging of the S-EXP and the cdr specifies +the character after the end of the S-EXP" + (let ((begin) (end)) + (back-sexp) + (setq begin (point)) + (forw-sexp) + (setq end (point)) + (goto-char begin) + (cons begin end)) +) + +(defun sexp-next () + "Returns the following S-EXP, Point is set to begging of that S-EXP. +The S-EXPs is represented as a cons cell, where the car specifies the point in +the current buffer that marks the begging of the S-EXP and the cdr specifies +the character after the end of the S-EXP" + (let ((begin) (end)) + (forw-sexp) + (forw-sexp) + (setq end (point)) + (back-sexp) + (setq begin (point)) + (cons begin end) + ) + ) + +(defun find-c-sexp () + "Returns the Complex S-EXP that surrounds Point" + (interactive) + (save-excursion + (let ((p) (sexp) (test-sexp)) + (setq p (point)) + (setq sexp (sexp-cur)) + (setq test-sexp (sexp-prev)) + (while (sexp-compound test-sexp sexp) + (setq sexp (cons (car test-sexp) (cdr sexp))) + (goto-char (car sexp)) + (setq test-sexp (sexp-prev)) + ) + (goto-char p) + (setq test-sexp (sexp-next)) + (while (sexp-compound sexp test-sexp) + (setq sexp (cons (car sexp) (cdr test-sexp))) + (setq test-sexp (sexp-next)) + ) + (buffer-substring (car sexp) (cdr sexp)) + ) + ) + ) + +(defun sdcdbsrc-selection-or-sexp (&optional ee) + ;; FIXME - fix this docstring + "If the EVENT is within the primary selection, then return the selected +text, otherwise parse the expression at the point of the mouse click and +return that. If EVENT is nil, then return the C sexp at point." + ;; stig@hackvan.com + (cond ((or (and ee (click-inside-selection-p ee)) + (and (not ee) (point-inside-selection-p))) + (replace-in-string (extent-string primary-selection-extent) "\n\\s *" " ")) + (ee + (sdcdbsrc-get-csexp-at-click ee)) + (t + (find-c-sexp)) + )) + +(defun sdcdbsrc-get-csexp-at-click (ee) + "Returns the containing s-expression located at the mouse cursor to point." + ;; " + ;; by Stig@hackvan.com + (let ((ewin (event-window ee)) + (epnt (event-point ee))) + (or (and ewin epnt) + (error "Must click within a window")) + (save-excursion + (set-buffer (window-buffer ewin)) + (save-excursion + (goto-char epnt) + (find-c-sexp))))) + +(defun sdcdbsrc-print-csexp (&optional ee) + (interactive) + (or ee (setq ee current-mouse-event)) + (sdcdb-call-from-src + (concat "print " sdcdb-print-format (sdcdbsrc-selection-or-sexp ee)))) + +(defun sdcdbsrc-*print-csexp (&optional ee) + (interactive) + (or ee (setq ee current-mouse-event)) + (sdcdb-call-from-src + (concat "print *" sdcdb-print-format (sdcdbsrc-selection-or-sexp ee)))) + +;; (defun sdcdbsrc-print-region (arg) +;; (let (( command (concat "print " sdcdb-print-format (x-get-cut-buffer)))) +;; (sdcdb-call-from-src command))) +;; +;; (defun sdcdbsrc-*print-region (arg) +;; (let (( command (concat "print *" sdcdb-print-format (x-get-cut-buffer)))) +;; (sdcdb-call-from-src command))) + +(defun sdcdbsrc-file:lno () + "returns \"file:lno\" specification for location of point. " + ;; by Stig@hackvan.com + (format "%s:%d" + (file-name-nondirectory buffer-file-name) + (save-restriction + (widen) + (1+ (count-lines (point-min) + (save-excursion (beginning-of-line) (point))))) + )) + +(defun sdcdbsrc-set-break (ee) + "Sets a breakpoint. Click on the selection and it will set a breakpoint +using the selected text. Click anywhere in a source file, and it will set +a breakpoint at that line number of that file." + ;; by Stig@hackvan.com + ;; there is already sdcdb-break, so this only needs to work with mouse clicks. + (interactive "e") + (sdcdb-call-from-src + (concat "break " + (if (click-inside-selection-p ee) + (extent-string primary-selection-extent) + (mouse-set-point ee) + (or buffer-file-name (error "No file in window")) + (- (sdcdbsrc-file:lno) 1) + )))) + +(defun sdcdbsrc-set-tbreak-continue (&optional ee) + "Set a temporary breakpoint at the position of the mouse click and then +continues. This can be bound to either a key or a mouse button." + ;; by Stig@hackvan.com + (interactive) + (or ee (setq ee current-mouse-event)) + (and ee (mouse-set-point ee)) + (sdcdb-call-from-src (concat "tbreak " (sdcdbsrc-file:lno))) + (sdcdb-call-from-src "c")) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Functions extended from sdcdb.el for sdcdbsrc. +;; +;; sdcdbsrc-set-buffer - added a check to set buffer to sdcdbsrc-associated-buffer +;; to handle multiple sdcdb sessions being driven from src +;; files. + +(require 'advice) + +(defadvice sdcdb-set-buffer (after sdcdbsrc activate) ; () + "Advised to work from a source buffer instead of just the sdcdb buffer." + ;; by Stig@hackvan.com + ;; the operations below have tests which are disjoint from the tests in + ;; the original `sdcdb-set-buffer'. Current-sdcdb-buffer cannot be set twice. + (and sdcdbsrc-call-p + sdcdbsrc-associated-buffer + (setq current-sdcdb-buffer sdcdbsrc-associated-buffer))) + +(defadvice sdcdb-display-line (around sdcdbsrc activate) + ;; (true-file line &optional select-method) + "Advised to select the source buffer instead of the sdcdb-buffer" + ;; by Stig@hackvan.com + (ad-set-arg 2 'source) ; tell it not to select the sdcdb window + ad-do-it + (save-excursion + (let* ((buf (extent-object sdcdb-arrow-extent)) + (win (get-buffer-window buf))) + (setq sdcdbsrc-last-src-buffer buf) + (select-window win) + (set-window-point win (extent-start-position sdcdb-arrow-extent)) + (set-buffer buf)) + (and sdcdbsrc-active-p + (not sdcdbsrc-mode) + (not (eq (current-buffer) current-sdcdb-buffer)) + (sdcdbsrc-mode 1)))) + +(defadvice sdcdb-filter (after sdcdbsrc activate) ; (proc string) + ;; by Stig@hackvan.com + ;; if we got a sdcdb prompt and it wasn't a sdcdbsrc command, then it's sdcdb + ;; hitting a breakpoint or having a core dump, so bounce back to the sdcdb + ;; window. + (let* ((selbuf (window-buffer (selected-window))) + win) + ;; if we're at a sdcdb prompt, then display the buffer + (and (save-match-data (string-match sdcdb-prompt-pattern (ad-get-arg 1))) + (prog1 + (not sdcdbsrc-call-p) + (setq sdcdbsrc-call-p nil)) + (setq win (display-buffer current-sdcdb-buffer)) + ;; if we're not in either the source buffer or the sdcdb buffer, + ;; then select the window too... + (not (eq selbuf current-sdcdb-buffer)) + (not (eq selbuf sdcdbsrc-last-src-buffer)) + (progn + (ding nil 'warp) + (select-window win))) + )) + +(defun sdcdbsrc-reset () + ;; tidy house and turn off sdcdbsrc-mode in all buffers + ;; by Stig@hackvan.com + (sdcdb-delete-arrow-extent) + (setq sdcdbsrc-global-mode nil) + (mapcar #'(lambda (buffer) + (set-buffer buffer) + (cond ((eq sdcdbsrc-associated-buffer current-sdcdb-buffer) + (sdcdbsrc-mode -1)))) + (buffer-list))) + +(defadvice sdcdb-sentinel (after sdcdbsrc freeze) ; (proc msg) + ;; by Stig@hackvan.com + (sdcdbsrc-reset) + (message "Sdcdbsrc finished")) + +(provide 'sdcdbsrc) diff --git a/debugger/mcs51/simi.c b/debugger/mcs51/simi.c new file mode 100644 index 0000000..3e1ae89 --- /dev/null +++ b/debugger/mcs51/simi.c @@ -0,0 +1,774 @@ +/*------------------------------------------------------------------------- + simi.c - source file for simulator interaction + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "sdcdb.h" +#undef DATADIR +#include "simi.h" +#include "newalloc.h" + +#ifdef _WIN32 +# include <windows.h> +# include <winsock2.h> +# include <io.h> +#else +# ifdef __sun +# define BSD_COMP +# include <sys/file.h> +# endif +# ifdef HAVE_SYS_SOCKET_H +# include <sys/types.h> +# include <sys/socket.h> +# include <netinet/in.h> +# include <arpa/inet.h> +# include <unistd.h> +# include <sys/ioctl.h> +# else +# error "Cannot build debugger without socket support" +# endif +#endif +#include <fcntl.h> +#include <signal.h> +#include <time.h> + +FILE *simin ; /* stream for simulator input */ +FILE *simout; /* stream for simulator output */ + +#ifdef _WIN32 +SOCKET sock = INVALID_SOCKET; +PROCESS_INFORMATION *simPid = NULL; +#else +int sock = -1; /* socket descriptor to comm with simulator */ +pid_t simPid = -1; +#endif +static char simibuff[MAX_SIM_BUFF]; /* sim buffer */ +static char *sbp = simibuff; /* simulator buffer pointer */ +char simactive = 0; + +static memcache_t memCache[NMEM_CACHE]; + +/*-----------------------------------------------------------------*/ +/* get data from memory cache/ load cache from simulator */ +/*-----------------------------------------------------------------*/ +static char *getMemCache(unsigned int addr,int cachenum, unsigned int size) +{ + char *resp, *buf; + unsigned int laddr; + memcache_t *cache = &memCache[cachenum]; + + if ( cache->size <= 0 || + cache->addr > addr || + cache->addr + cache->size < addr + size ) + { + if ( cachenum == IMEM_CACHE ) + { + sendSim("di 0x0 0xff\n"); + } + else if ( cachenum == SREG_CACHE ) + { + sendSim("ds 0x80 0xff\n"); + } + else + { + laddr = addr & 0xffffffc0; + sprintf(cache->buffer,"dx 0x%x 0x%x\n",laddr,laddr+0xff ); + sendSim(cache->buffer); + } + waitForSim(100,NULL); + resp = simResponse(); + cache->addr = strtol(resp,0,0); + buf = cache->buffer; + cache->size = 0; + while ( *resp && *(resp+1) && *(resp+2)) + { + /* cache is a stringbuffer with ascii data like + " 00 00 00 00 00 00 00 00" + */ + resp += 2; + laddr = 0; + /* skip thru the address part */ + while (isxdigit(*resp)) + resp++; + while ( *resp && *resp != '\n') + { + if ( laddr < 24 ) + { + laddr++ ; + *buf++ = *resp ; + } + resp++; + } + resp++ ; + cache->size += 8; + } + *buf = '\0'; + if ( cache->addr > addr || + cache->addr + cache->size < addr + size ) + { + return NULL; + } + } + return cache->buffer + (addr - cache->addr)*3; +} + +/*-----------------------------------------------------------------*/ +/* invalidate memory cache */ +/*-----------------------------------------------------------------*/ +static void invalidateCache( int cachenum ) +{ + memCache[cachenum].size = 0; +} + +/*-----------------------------------------------------------------*/ +/* waitForSim - wait till simulator is done doing its job */ +/*-----------------------------------------------------------------*/ +void waitForSim(int timeout_ms, char *expect) +{ + int ch; + clock_t timeout; + + Dprintf(D_simi, ("simi: waitForSim start(%d)\n", timeout_ms)); + sbp = simibuff; + + timeout = clock() + ((timeout_ms * CLOCKS_PER_SEC) / 1000); + while (((ch = fgetc(simin)) > 0 ) && (clock() <= timeout)) + { + *sbp++ = ch; + } + *sbp = 0; + Dprintf(D_simi, ("waitForSim(%d) got[%s]\n", timeout_ms, simibuff)); +} + +/*-----------------------------------------------------------------*/ +/* openSimulator - create a pipe to talk to simulator */ +/*-----------------------------------------------------------------*/ +#ifdef _WIN32 +static void init_winsock(void) +{ + static int is_initialized = 0; + + if (!is_initialized) + { + WSADATA wsaData; + int iResult; + + // Initialize Winsock + iResult = WSAStartup(MAKEWORD(2,2), &wsaData); + if (0 != iResult) + { + fprintf(stderr, "WSAStartup failed: %d\n", iResult); + exit(1); + } + } +} + +static PROCESS_INFORMATION *execSimulator(char **args, int nargs) +{ + STARTUPINFO si; + static PROCESS_INFORMATION pi; + char *cmdLine = argsToCmdLine(args, nargs); + + memset(&si, 0, sizeof(si)); + si.cb = sizeof(si); + memset(&pi, 0, sizeof(pi)); + + // Start the child process. + if (!CreateProcess(NULL, // No module name (use command line) + cmdLine, // Command line + NULL, // Process handle not inheritable + NULL, // Thread handle not inheritable + FALSE, // Set handle inheritance to FALSE + 0, // No creation flags + NULL, // Use parent's environment block + NULL, // Use parent's starting directory + &si, // Pointer to STARTUPINFO structure + &pi) // Pointer to PROCESS_INFORMATION structure + ) + { + Safe_free(cmdLine); + printf( "CreateProcess failed (%lu).\n", GetLastError() ); + return NULL; + } + + return π +} + +void openSimulator (char **args, int nargs) +{ + struct sockaddr_in sin; + int retry = 0; + int i; + int iResult; + int fh; + u_long iMode; + + init_winsock(); + + Dprintf(D_simi, ("simi: openSimulator\n")); +#ifdef SDCDB_DEBUG + if (D_simi & sdcdbDebug) + { + printf("simi: openSimulator: "); + for (i=0; i < nargs; i++ ) + { + printf("arg%d: %s ", i, args[i]); + } + printf("\n"); + } +#endif + invalidateCache(XMEM_CACHE); + invalidateCache(IMEM_CACHE); + invalidateCache(SREG_CACHE); + + if (INVALID_SOCKET == (sock = WSASocket(PF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, 0))) + { + fprintf(stderr, "cannot create socket: %d\n", WSAGetLastError()); + exit(1); + } + + memset(&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = inet_addr("127.0.0.1"); + sin.sin_port = htons(9756); + + try_connect: + /* connect to the simulator */ + if (SOCKET_ERROR == connect(sock, (struct sockaddr *)&sin, sizeof(sin))) + { + /* if failed then wait 1 second & try again + do this for 10 secs only */ + if (retry < 10) + { + if ( !retry ) + simPid = execSimulator(args, nargs); + retry ++; + Sleep(1000); + goto try_connect; + } + perror("connect failed :"); + exit(1); + } + + iMode = 1; /* set non-blocking mode */ + iResult = ioctlsocket(sock, FIONBIO, &iMode); + if (iResult != NO_ERROR) + { + perror("ioctlsocket failed"); + exit(1); + } + + fh = _open_osfhandle(sock, _O_TEXT); + if (-1 == fh) + { + perror("cannot _open_osfhandle"); + exit(1); + } + + /* got the socket now turn it into a file handle */ + if (!(simin = fdopen(fh, "r"))) + { + perror("cannot open socket for read"); + exit(1); + } + + fh = _open_osfhandle(sock, _O_TEXT); + if (-1 == fh) + { + perror("cannot _open_osfhandle"); + exit(1); + } + + if (!(simout = fdopen(fh, "w"))) + { + perror("cannot open socket for write"); + exit(1); + } + /* now that we have opened, wait for the prompt */ + waitForSim(200, NULL); + simactive = 1; +} +#else +static int execSimulator(char **args, int nargs) +{ + if ((simPid = fork())) + { + Dprintf(D_simi, ("simi: simulator pid %d\n",(int) simPid)); + } + else + { + /* we are in the child process : start the simulator */ + signal(SIGINT , SIG_IGN ); + signal(SIGABRT, SIG_IGN ); + signal(SIGHUP , SIG_IGN ); + signal(SIGCHLD, SIG_IGN ); + + if (execvp(args[0],args) < 0) + { + perror("cannot exec simulator"); + exit(1); + } + } + return simPid; +} + +void openSimulator (char **args, int nargs) +{ + struct sockaddr_in sin; + int retry = 0; + int i; + int iResult; +#if defined(__sun) || defined(__CYGWIN__) + u_long iMode; +#endif + + Dprintf(D_simi, ("simi: openSimulator\n")); +#ifdef SDCDB_DEBUG + if (D_simi & sdcdbDebug) + { + printf("simi: openSimulator: "); + for (i=0; i < nargs; i++ ) + { + printf("arg%d: %s ",i,args[i]); + } + printf("\n"); + } +#endif + invalidateCache(XMEM_CACHE); + invalidateCache(IMEM_CACHE); + invalidateCache(SREG_CACHE); + + if ((sock = socket(AF_INET,SOCK_STREAM,0)) < 0) + { + perror("cannot create socket"); + exit(1); + } + + memset(&sin,0,sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = inet_addr("127.0.0.1"); + sin.sin_port = htons(9756); + + try_connect: + /* connect to the simulator */ + if (connect(sock,(struct sockaddr *) &sin, sizeof(sin)) < 0) + { + /* if failed then wait 1 second & try again + do this for 10 secs only */ + if (retry < 10) + { + if ( !retry ) + { + simPid = execSimulator(args, nargs); + } + retry ++; + sleep (1); + goto try_connect; + } + perror("connect failed :"); + exit(1); + } + +#if defined(__sun) || defined(__CYGWIN__) + iMode = 1; /* set non-blocking mode */ + iResult = ioctl(sock, FIONBIO, &iMode); +#else + iResult = fcntl(sock, F_SETFL, O_NONBLOCK | O_ASYNC); +#endif + if (iResult != 0) + { + perror("ioctl failed"); + exit(1); + } + + /* got the socket now turn it into a file handle */ + if (!(simin = fdopen(sock, "r"))) + { + fprintf(stderr,"cannot open socket for read\n"); + exit(1); + } + + if (!(simout = fdopen(sock, "w"))) + { + fprintf(stderr,"cannot open socket for write\n"); + exit(1); + } + /* now that we have opened, wait for the prompt */ + waitForSim(200,NULL); + simactive = 1; +} +#endif + +/*-----------------------------------------------------------------*/ +/* simResponse - returns buffer to simulator's response */ +/*-----------------------------------------------------------------*/ +char *simResponse(void) +{ + return simibuff; +} + +/*-----------------------------------------------------------------*/ +/* sendSim - sends a command to the simuator */ +/*-----------------------------------------------------------------*/ +void sendSim(char *s) +{ + if ( ! simout ) + return; + + Dprintf(D_simi, ("simi: sendSim-->%s", s)); // s has LF at end already + fputs(s,simout); + fflush(simout); +} + + +static int getMemString(char *buffer, char wrflag, + unsigned int *addr, char mem, unsigned int size ) +{ + int cachenr = NMEM_CACHE; + char *prefix; + char *cmd ; + + if ( wrflag ) + cmd = "set mem"; + else + cmd = "dump"; + buffer[0] = '\0' ; + + switch (mem) + { + case 'A': /* External stack */ + case 'F': /* External ram */ + prefix = "xram"; + cachenr = XMEM_CACHE; + break; + case 'C': /* Code */ + case 'D': /* Code / static segment */ + prefix = "rom"; + break; + case 'B': /* Internal stack */ + case 'E': /* Internal ram (lower 128) bytes */ + case 'G': /* Internal ram */ + prefix = "iram"; + cachenr = IMEM_CACHE; + break; + case 'H': /* Bit addressable */ + case 'J': /* SBIT space */ + cachenr = BIT_CACHE; + if ( wrflag ) + { + cmd = "set bit"; + } + sprintf(buffer,"%s 0x%x\n",cmd,*addr); + return cachenr; + case 'I': /* SFR space */ + prefix = "sfr" ; + cachenr = SREG_CACHE; + break; + case 'R': /* Register space */ + prefix = "iram"; + /* get register bank */ + cachenr = simGetValue (0xd0,'I',1); + *addr += cachenr & 0x18 ; + cachenr = IMEM_CACHE; + break; + default: + case 'Z': /* undefined space code */ + return cachenr; + } + if ( wrflag ) + sprintf(buffer,"%s %s 0x%x\n",cmd,prefix,*addr); + else + sprintf(buffer,"%s %s 0x%x 0x%x\n",cmd,prefix,*addr,*addr+size-1); + return cachenr; +} + +void simSetPC( unsigned int addr ) +{ + char buffer[40]; + sprintf(buffer,"pc %d\n", addr); + sendSim(buffer); + waitForSim(100,NULL); + simResponse(); +} + +int simSetValue (unsigned int addr,char mem, unsigned int size, unsigned long val) +{ + unsigned int i; + char cachenr; + char buffer[40]; + char *s; + + if ( size <= 0 ) + return 0; + + cachenr = getMemString(buffer, 1, &addr, mem, size); + if ( cachenr < NMEM_CACHE ) + { + invalidateCache(cachenr); + } + s = buffer + strlen(buffer) -1; + for ( i = 0 ; i < size ; i++ ) + { + sprintf(s," 0x%lx", val & 0xff); + s += strlen(s); + val >>= 8; + } + sprintf(s,"\n"); + sendSim(buffer); + waitForSim(100,NULL); + simResponse(); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* simGetValue - get value @ address for mem space */ +/*-----------------------------------------------------------------*/ +unsigned long simGetValue (unsigned int addr,char mem, unsigned int size) +{ + unsigned int b[4] = {0,0,0,0}; /* can be a max of four bytes long */ + char cachenr; + char buffer[40]; + char *resp; + + if ( size <= 0 ) + return 0; + + cachenr = getMemString(buffer, 0, &addr, mem, size); + + resp = NULL; + if ( cachenr < NMEM_CACHE ) + { + resp = getMemCache(addr,cachenr,size); + } + if ( !resp ) + { + /* create the simulator command */ + sendSim(buffer); + waitForSim(100,NULL); + resp = simResponse(); + + /* got the response we need to parse it the response + is of the form + [address] [v] [v] [v] ... special case in + case of bit variables which case it becomes + [address] [assembler bit address] [v] */ + /* first skip thru white space */ + resp = trim_left(resp); + + if (strncmp(resp, "0x",2) == 0) + resp += 2; + + /* skip thru the address part */ + while (isxdigit(*resp)) + resp++; + } + /* make the branch for bit variables */ + if ( cachenr == BIT_CACHE) + { + /* skip until newline */ + while (*resp && *resp != '\n' ) + resp++ ; + if ( *--resp != '0' ) + b[0] = 1; + } + else + { + unsigned int i; + + for (i = 0 ; i < size ; i++ ) + { + /* skip white space */ + resp = trim_left(resp); + + b[i] = strtol(resp,&resp,16); + } + } + + return b[0] | b[1] << 8 | b[2] << 16 | b[3] << 24 ; +} + +/*-----------------------------------------------------------------*/ +/* simSetBP - set break point for a given address */ +/*-----------------------------------------------------------------*/ +void simSetBP (unsigned int addr) +{ + char buff[50]; + + sprintf(buff, "break 0x%x\n", addr); + sendSim(buff); + waitForSim(100, NULL); +} + +/*-----------------------------------------------------------------*/ +/* simClearBP - clear a break point */ +/*-----------------------------------------------------------------*/ +void simClearBP (unsigned int addr) +{ + char buff[50]; + + sprintf(buff, "clear 0x%x\n", addr); + sendSim(buff); + waitForSim(100, NULL); +} + +/*-----------------------------------------------------------------*/ +/* simLoadFile - load the simulator file */ +/*-----------------------------------------------------------------*/ +void simLoadFile (char *s) +{ + char buff[128]; + + sprintf(buff, "file \"%s\"\n", s); + printf("%s",buff); + sendSim(buff); + waitForSim(500, NULL); +} + +/*-----------------------------------------------------------------*/ +/* simGoTillBp - send 'go' to simulator till a bp then return addr */ +/*-----------------------------------------------------------------*/ +unsigned int simGoTillBp ( unsigned int gaddr) +{ + char *sr; + int wait_ms = 1000; + + invalidateCache(XMEM_CACHE); + invalidateCache(IMEM_CACHE); + invalidateCache(SREG_CACHE); + if (gaddr == 0) + { + /* initial start, start & stop from address 0 */ + //char buf[20]; + + // this program is setting up a bunch of breakpoints automatically + // at key places. Like at startup & main() and other function + // entry points. So we don't need to setup one here.. + //sendSim("break 0x0\n"); + //sleep(1); + //waitForSim(); + + sendSim("reset\n"); + waitForSim(wait_ms, NULL); + sendSim("run 0x0\n"); + } + else if (gaddr == -1) + { /* resume */ + sendSim ("run\n"); + wait_ms = 100; + } + else if (gaddr == 1 ) + { /* nexti or next */ + sendSim ("next\n"); + wait_ms = 100; + } + else if (gaddr == 2 ) + { /* stepi or step */ + sendSim ("step\n"); + wait_ms = 100; + } + else + { + printf("Error, simGoTillBp > 0!\n"); + exit(1); + } + + waitForSim(wait_ms, NULL); + + /* get the simulator response */ + sr = simResponse(); + /* check for errors */ + while ( *sr ) + { + while ( *sr && *sr != 'E' ) + sr++ ; + if ( !*sr ) + break; + if ( ! strncmp(sr, "Error:", 6)) + { + fputs(sr, stdout); + break; + } + sr++ ; + } + + nointerrupt = 1; + /* get answer of stop command */ + if ( userinterrupt ) + waitForSim(wait_ms, NULL); + + /* better solution: ask pc */ + sendSim ("pc\n"); + waitForSim(100, NULL); + sr = simResponse(); + nointerrupt = 0; + + gaddr = strtol(sr+3, 0, 0); + return gaddr; +} + +/*-----------------------------------------------------------------*/ +/* simReset - reset the simulator */ +/*-----------------------------------------------------------------*/ +void simReset (void) +{ + invalidateCache(XMEM_CACHE); + invalidateCache(IMEM_CACHE); + invalidateCache(SREG_CACHE); + sendSim("res\n"); + waitForSim(100, NULL); +} + +/*-----------------------------------------------------------------*/ +/* closeSimulator - close connection to simulator */ +/*-----------------------------------------------------------------*/ +void closeSimulator (void) +{ +#ifdef _WIN32 + if ( ! simin || ! simout || INVALID_SOCKET == sock ) +#else + if ( ! simin || ! simout || sock == -1 ) +#endif + { + simactive = 0; + return; + } + simactive = 0; + sendSim("quit\n"); + shutdown(sock, 2); +#ifdef _WIN32 + closesocket(sock); + sock = -1; + if (NULL != simPid) + { + TerminateProcess(simPid->hProcess, 0); + // Close process and thread handles. + CloseHandle(simPid->hProcess); + CloseHandle(simPid->hThread); + } +#else + close(sock); + sock = -1; + if ( simPid > 0 ) + kill (simPid,SIGKILL); +#endif + /* simin/simout are now dead as they are both associated with the closed socket */ + simin = NULL; + simout = NULL; +} diff --git a/debugger/mcs51/simi.h b/debugger/mcs51/simi.h new file mode 100644 index 0000000..0de2145 --- /dev/null +++ b/debugger/mcs51/simi.h @@ -0,0 +1,77 @@ +/*------------------------------------------------------------------------- + simi.h - Header file for simulator interaction + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SIMI_H +#define SIMI_H + +#ifdef _WIN32 +/* ugly hack to prevent the incusion of objidl.h */ +#ifdef __MINGW32__ +#define _OLE2_H +#elif defined _MSC_VER +#define _WINSOCK_DEPRECATED_NO_WARNINGS +#define _OLE2_H_ +#endif +#include <winsock2.h> +#endif + +#define MAX_SIM_BUFF 8*1024 + +#define MAX_CACHE_SIZE 2048 +/* number of cache */ +#define IMEM_CACHE 0 +#define XMEM_CACHE 1 +#define SREG_CACHE 2 +#define NMEM_CACHE 3 +/* special index */ +#define BIT_CACHE 4 + +typedef struct _memcache +{ + unsigned int addr; + unsigned int size; + char buffer[MAX_CACHE_SIZE]; +} memcache_t; + +//#define SIMNAME "s51" +#ifdef _WIN32 +extern SOCKET sock; +#else +extern int sock; +#endif +extern char simactive; +void openSimulator (char **,int); +void waitForSim(int timeout_ms, char *expect); +void closeSimulator (); +void sendSim(char *); +char *simResponse(); +void simSetPC (unsigned int); +void simSetBP (unsigned int); +void simClearBP (unsigned int); +void simLoadFile(char *); +void simReset (); +char *simRegs() ; +unsigned int simGoTillBp (unsigned int); +unsigned long simGetValue (unsigned int ,char , unsigned int ); +int simSetValue (unsigned int ,char , unsigned int, unsigned long ); +#endif diff --git a/debugger/mcs51/symtab.c b/debugger/mcs51/symtab.c new file mode 100644 index 0000000..fd4e586 --- /dev/null +++ b/debugger/mcs51/symtab.c @@ -0,0 +1,842 @@ +/*------------------------------------------------------------------------- + symtab.c - Header file for symbol table for sdcdb ( debugger ) + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include "sdcdb.h" +#include "symtab.h" +#include "newalloc.h" + +structdef *structWithName (char *); +DEFSETFUNC(symWithRName); + +/*-----------------------------------------------------------------*/ +/* gc_strcat - allocate and return concatenated strings */ +/*-----------------------------------------------------------------*/ +char *gc_strcat(const char *s1, const char *s2, const char *s3) +{ + char *p = Safe_malloc(strlen(s1) + strlen(s2) + strlen(s3) + 1); + strcat(strcat(strcpy(p, s1), s2), s3); + return p; +} + +/*------------------------------------------------------------------*/ +/* getSize - returns size of a type chain in bits */ +/*------------------------------------------------------------------*/ +unsigned int getSize ( st_link *p ) +{ + /* if nothing return 0 */ + if ( ! p ) + return 0; + + if ( IS_SPEC(p) ) /* if this is the specifier then */ + { + switch (SPEC_NOUN(p)) /* depending on the specifier type */ + { + case V_INT: + return (IS_LONG(p) ? LONGSIZE : ( IS_SHORT(p) ? SHORTSIZE: INTSIZE)); + case V_FLOAT: + return FLOATSIZE; + case V_CHAR: + return CHARSIZE; + case V_VOID: + return 0; + case V_STRUCT: + return SPEC_STRUCT(p)->size; + case V_LABEL: + return 0 ; + case V_SBIT: + return BITSIZE; + case V_BIT: + return ((SPEC_BLEN(p) / 8) + (SPEC_BLEN(p) % 8 ? 1 : 0)); + default: + return 0; + } + } + + /* this is a specifier */ + switch (DCL_TYPE(p)) + { + case FUNCTION: + return 2; + case ARRAY: + return DCL_ELEM(p) * getSize (p->next); + case IPOINTER: + case PPOINTER: + case POINTER: + return ( PTRSIZE ); + case FPOINTER: + case CPOINTER: + return ( FPTRSIZE ); + case GPOINTER: + return ( GPTRSIZE ); + + default: + return 0; + } +} + +/*-----------------------------------------------------------------*/ +/* parseFunc - creates a function record entry */ +/*-----------------------------------------------------------------*/ +void parseFunc (char *line) +{ + function *func; + char *rs = line; + int i; + + while (*rs && *rs != '(') + rs++; + *--rs = '\0'; + + func = Safe_calloc(1, sizeof(function)); + func->sym = NULL; + applyToSetFTrue(symbols, symWithRName, line, &func->sym); + *rs++ = '0'; + if (! func->sym) + func->sym = parseSymbol(line, &rs, 1); + func->sym->isfunc = 1; + func->modName = currModName; + while(*rs && *rs != ',') + rs++; + rs++; + sscanf(rs, "%d,%d,%hd", &i, + &(SPEC_INTN(func->sym->etype)), + &(SPEC_BANK(func->sym->etype))); + SPEC_INTRTN(func->sym->etype) = i; + addSet(&functions, func); +} + +/*-----------------------------------------------------------------*/ +/* parseTypeInfo - parse the type info of a symbol expects the type*/ +/* info to be of the form */ +/* ({<size>}<type info chain) */ +/*-----------------------------------------------------------------*/ +static char *parseTypeInfo (symbol *sym, char *s) +{ + char *bp; + + s += 2; /* go past the ({ */ + /* get the size */ + sym->size = (short)strtol (s, &bp, 10); + /* bp now points to '}' ... go past it */ + s = ++bp; + while (*s != ')') /* till we reach the end */ + { + st_link *type; + type = Safe_calloc(1, sizeof(st_link)); + if (*s == ',') + s++; + + /* is a declarator */ + if (*s == 'D') + { + s++; + switch (*s) + { + case 'F': + DCL_TYPE(type) = FUNCTION; + s++; + break; + case 'G': + DCL_TYPE(type) = GPOINTER; + s++; + break; + case 'C': + DCL_TYPE(type) = CPOINTER; + s++; + break; + case 'X': + DCL_TYPE(type) = FPOINTER; + s++; + break; + case 'D': + DCL_TYPE(type) = POINTER; + s++; + break; + case 'I': + DCL_TYPE(type) = IPOINTER; + s++; + break; + case 'P': + DCL_TYPE(type) = PPOINTER; + s++; + break; + case 'A': + s++; + DCL_TYPE(type) = ARRAY ; + DCL_ELEM(type) = (short)strtol(s,&s,10); + break; + } + } + else + { + /* is a specifier */ + type->class = SPECIFIER; + s++; + switch (*s) + { + case 'L': + SPEC_NOUN(type) = V_INT; + SPEC_LONG(type) = 1; + s++; + break; + case 'I': + SPEC_NOUN(type) = V_INT; + s++; + break; + case 'S': + case 'C': + SPEC_NOUN(type) = V_CHAR ; + s++; + break; + case 'V': + SPEC_NOUN(type) = V_VOID; + s++; + break; + case 'F': + SPEC_NOUN(type) = V_FLOAT; + s++; + break; + case 'T': + s++; + SPEC_NOUN(type) = V_STRUCT; + { + char *ss = strtok(strdup(s), ",):"); + + SPEC_STRUCT(type) = structWithName(ss); + free(ss); + } + break; + case 'X': + s++; + SPEC_NOUN(type) = V_SBIT; + break; + case 'B': + SPEC_NOUN(type) = V_BIT; + s++; + SPEC_BSTR(type) = strtol(s, &s, 10); + s++; + SPEC_BLEN(type) = strtol(s, &s, 10); + break; + } + while (*s != ':') + s++; + s++; + if (*s++ == 'S') + SPEC_USIGN(type) = 0; + else + SPEC_USIGN(type) = 1; + } + + /* add the type to the symbol's type chain */ + if (sym->type) + sym->etype = sym->etype->next = type; + else + sym->type = sym->etype = type; + } + + return ++s; +} + +/*-----------------------------------------------------------------*/ +/* symFromRec - parse a symbol record and extract and create a sym */ +/* expects the input string to be of the form */ +/* {G|F<filename>|L<filename>'.'<functionName>}'$' */ +/* <name>'$'<level>'$'<block><type info> */ +/*-----------------------------------------------------------------*/ +symbol *parseSymbol (char *s, char **rs, int doadd) +{ + symbol *nsym; + char save_ch; + char *bp = s; + + /* go the mangled name */ + for ( bp = s; *bp && *bp != '('; bp++ ) + ; + save_ch = *--bp; + *bp = '\0'; + nsym = NULL; + if ( doadd == 2 ) + { + /* add only if not present and if linkrecord before symbol record */ + if ( applyToSetFTrue(symbols, symWithRName, s, &nsym)) + { + if ( nsym->rname != nsym->name ) + return NULL; + doadd = 0; + } + } + if ( ! nsym ) + { + nsym = Safe_calloc(1, sizeof(symbol)); + nsym->rname = alloccpy(s, bp - s); + } + *bp = save_ch; + /* if this is a Global Symbol */ + nsym->scopetype = *s; + s++; + if (nsym->scopetype != 'G') + { + /* get the function name it is local to */ + bp = s; + while (*s != '$') + s++; + nsym->sname = alloccpy(bp, s - bp); + } + + /* next get the name */ + bp = ++s; + while ( *s != '$' ) + s++; + nsym->name = alloccpy(bp, s - bp); + + s++; + /* get the level number */ + nsym->level = (short)strtol (s, &bp, 10); + s = ++bp; + /* skip the '$' & get the block number */ + nsym->block = (short)strtol (s, &bp, 10); + + s = parseTypeInfo(nsym, bp); + + /* get the address space after going past the comma */ + s++; + nsym->addrspace = *s; + + s+= 2; + nsym->isonstack = (short)strtol(s, &s, 10); + /* get the stack offset */ + s++; + nsym->offset = strtol(s, &s, 10); + + if ( nsym->addrspace == 'R' ) + { + /* get registeroffset */ + while (*s && *s != '[') + s++; + s++; + if ( *s == 'r' ) + { + nsym->addr = strtol(s+1, &s, 10); + } + while (*s && *s != ']') + s++; + } + + *rs = s; + if ( doadd ) + addSet(&symbols, nsym); + + Dprintf(D_symtab, ("symtab: par %s(0x%x) add=%d sym=%p\n", + nsym->name, nsym->addr, doadd, nsym)); + + return nsym; +} + +/*-----------------------------------------------------------------*/ +/* parseStruct - parses a structure record expected in format */ +/* {F<filename>}$<tag>[()()()...] */ +/*-----------------------------------------------------------------*/ +structdef *parseStruct (char *s) +{ + structdef *nsdef ; + char *bp; + char *name; + symbol *fields = NULL; + + while (*s != '$') + s++; + + bp =++s; + while (*s != '[') + s++; + name = alloccpy(bp,s - bp); + nsdef = structWithName(name); + nsdef->fields = NULL; + nsdef->size = 0; + s++; + while (*s && *s != ']') + { + int offset ; + symbol *sym ; + while (!isdigit(*s)) + s++; + offset = strtol(s,&s,10); + while (*s != ':') + s++; + s++; + sym = parseSymbol(s,&s,0); + sym->offset = offset ; + s += 3; + if (!fields) + fields = nsdef->fields = sym; + else + fields = fields->next = sym; + nsdef->size += sym->size; + } + + return nsdef; +} + +/*-----------------------------------------------------------------*/ +/* parseModule - creates a module with a given name */ +/*-----------------------------------------------------------------*/ +module *parseModule (char *s, bool createName ) +{ + module *nmod ; + char buffer[512]; + + nmod = Safe_calloc(1, sizeof(module)); + + addSet (&modules, nmod); + + /* create copy file name */ + nmod->name = s; + + if (createName) + { + sprintf(buffer, "%s.c", s); + nmod->c_name = Safe_malloc(strlen(buffer)+1); + strcpy(nmod->c_name, buffer); + + sprintf(buffer, "%s.asm", s); + nmod->asm_name = Safe_malloc(strlen(buffer)+1); + strcpy(nmod->asm_name, buffer); + } + + return nmod; +} + +/*-----------------------------------------------------------------*/ +/* moduleWithName - finds and returns a module with a given name */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(moduleWithName) +{ + module *mod = item; + V_ARG(char *, s); + V_ARG(module **, rmod); + + if (*rmod) + return 0; + + if (strcmp(mod->name, s) == 0) + { + *rmod = mod; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* moduleWithCName - finds and returns a module with a given c_name*/ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(moduleWithCName) +{ + module *mod = item; + V_ARG(char *, s); + V_ARG(module **, rmod); + + if (*rmod) + return 0; + + if (strcmp(mod->c_name, s) == 0) + { + *rmod = mod; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* moduleWithAsmName - finds & returns a module with given asm_name*/ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(moduleWithAsmName) +{ + module *mod = item; + V_ARG(char *, s); + V_ARG(module **, rmod); + + if (*rmod) + return 0; + + if (strcmp(mod->asm_name, s) == 0) + { + *rmod = mod; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* structWithName - returns a structure with a given name */ +/*-----------------------------------------------------------------*/ +structdef *structWithName (char *s) +{ + int i; + structdef *nsdef ; + + /* go thru the struct table looking for a match */ + for ( i = 0 ; i < nStructs ; i++ ) + { + if (strcmp(currModName,structs[i]->sname) == 0 && + strcmp(s,structs[i]->tag) == 0) + { + return structs[i]; + } + } + + nsdef = Safe_calloc(1,sizeof(structdef)); + nsdef->tag = alloccpy(s,strlen(s)); + nsdef->sname = currModName ; + + nStructs++; + structs = (struct structdef **)resize((void **)structs,nStructs); + structs[nStructs-1] = nsdef; + return nsdef; +} + +/*-----------------------------------------------------------------*/ +/* symWithRName - look for symbol with mangled name = parm */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(symWithRName) +{ + symbol *sym = item; + V_ARG(char *, s); + V_ARG(symbol **, rsym); + + if (*rsym) + return 0; + + if (strcmp(sym->rname, s) == 0) + { + *rsym = sym; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* funcWithRName - look for function with name */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(funcWithRName) +{ + function *func = item; + V_ARG(char *,s); + V_ARG(function **,rfunc); + + if (*rfunc) + return 0; + + if (strcmp(func->sym->rname,s) == 0) + { + *rfunc = func; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* symLocal - local symbol respecting blocks & levels */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(symLocal) +{ + symbol *sym = item; + V_ARG(char *, name); + V_ARG(char *, sname); + V_ARG(int, block); + V_ARG(int, level); + V_ARG(symbol **, rsym); + + if (strcmp(name, sym->name) == 0 && /* name matches */ + sym->scopetype != 'G' && /* local scope */ + sym->sname && + strcmp(sym->sname, sname) == 0 && /* scope == specified scope */ + sym->block <= block && /* block & level kindo matches */ + sym->level <= level) + { + /* if a symbol was previously found then + sure that ones block & level are less + then this one */ + if (*rsym && (*rsym)->block >= block && (*rsym)->level >= level) + return 0; + + *rsym = sym; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* symGlobal - return global symbol of name */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(symGlobal) +{ + symbol *sym = item; + V_ARG(char *, name); + V_ARG(symbol **, rsym); + + if (*rsym) + return 0; + + /* simple :: global & name matches */ + if (sym->scopetype == 'G' && + strcmp(sym->name, name) == 0) + { + *rsym = sym; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* symLookup - determine symbol from name & context */ +/*-----------------------------------------------------------------*/ +symbol *symLookup (char *name, context *ctxt) +{ + symbol *sym = NULL; + + if ((ctxt) && (ctxt->func) && + (ctxt->func->sym) && (ctxt->func->sym->name)) + { + char *sname = gc_strcat(ctxt->func->mod->name, ".", ctxt->func->sym->name); + /* first try & find a local variable for the given name */ + if ( applyToSet(symbols, symLocal, + name, + sname, + ctxt->block, + ctxt->level, + &sym)) + { + Safe_free(sname); + return sym; + } + Safe_free(sname); + sym = NULL; + } + + if ((ctxt) && (ctxt->func) && + (ctxt->func->mod) && (ctxt->func->mod->name)) + { + /* then try local to this module */ + if (applyToSet(symbols, symLocal, + name, + ctxt->func->mod->name, + 0, + 0, + &sym)) + { + return sym; + } + sym = NULL; + } + + /* no:: try global */ + if ( applyToSet(symbols, symGlobal, name, &sym)) + return sym; + + /* cannot find return null */ + return NULL; +} + +/*-----------------------------------------------------------------*/ +/* lnkFuncEnd - link record for end of function */ +/*-----------------------------------------------------------------*/ +static void lnkFuncEnd (char *s) +{ + char sname[128], *bp = sname; + function *func; + + /* copy till we get to a ':' */ + while ( *s != ':' ) + *bp++ = *s++; + bp -= 1; + *bp = '\0'; + + func = NULL; + if (!applyToSet(functions,funcWithRName,sname,&func)) + return ; + + s++; + sscanf(s,"%x",&func->sym->eaddr); + + Dprintf(D_symtab, ("symtab: ead %s(0x%x)\n",func->sym->name,func->sym->eaddr)); +} + +/*-----------------------------------------------------------------*/ +/* lnkSymRec - record for a symbol */ +/*-----------------------------------------------------------------*/ +static void lnkSymRec (char *s) +{ + char *bp, save_ch ; + symbol *sym; + + /* search to a ':' */ + for ( bp = s; *bp && *bp != ':'; bp++ ); + save_ch = *--bp; + *bp = '\0'; + + sym = NULL; + applyToSetFTrue(symbols,symWithRName,s,&sym); + if (! sym) + { + sym = Safe_calloc(1,sizeof(symbol)); + sym->rname = alloccpy(s,bp - s); + sym->scopetype = *s; + sym->name = sym->rname; + addSet(&symbols,sym); + } + *bp = save_ch; + if ( *bp ) + { + sscanf(bp+2,"%x",&sym->addr); + } + Dprintf(D_symtab, ("symtab: lnk %s(0x%x)\n",sym->name,sym->addr)); +} + +/*-----------------------------------------------------------------*/ +/* lnkAsmSrc - process linker record for asm sources */ +/*-----------------------------------------------------------------*/ +static void lnkAsmSrc (char *s) +{ + char mname[128], *bp = mname; + int line ; + unsigned addr; + module *mod = NULL; + + /* input will be of format + filename$<line>:<address> */ + while (*s != '$' && *s != '.') + *bp++ = *s++; + *bp = '\0'; + /* skip to line stuff */ + while (*s != '$') + s++; + + if (!applyToSet(modules, moduleWithName, mname, &mod)) + return ; + + if (sscanf(s, "$%d:%x", &line, &addr) != 2) + return ; + + line--; + if (line < mod->nasmLines) + { + mod->asmLines[line]->addr = addr; + Dprintf(D_symtab, ("symtab: asm %s(%d:0x%x) %s", mod->asm_name, line, addr, mod->asmLines[line]->src)); + } +} + +/*-----------------------------------------------------------------*/ +/* lnkCSrc - process linker output for c source */ +/*-----------------------------------------------------------------*/ +static void lnkCSrc (char *s) +{ + char mname[128], *bp = mname; + int block,level,line; + unsigned int addr; + module *mod ; + + /* input will be of format + filename.ext$<line>$<level>$<block>:<address> */ + /* get the module name */ + while (*s != '$' ) + *bp++ = *s++; + *bp = '\0'; + /* skip the extension */ + while (*s != '$') + s++; + + if (sscanf(s,"$%d$%d$%d:%x", &line,&level,&block,&addr) != 4) + return ; + + mod = NULL; + if (!applyToSet(modules,moduleWithCName,mname,&mod)) + { + mod = parseModule(mname, FALSE); + mod->c_name = alloccpy(mname,strlen(mname)); + mod->cfullname=searchDirsFname(mod->c_name); + mod->cLines = loadFile(mod->c_name,&mod->ncLines); + } + + line--; + /* one line can have more than one address : (for loops !)*/ + if (line < mod->ncLines && line > 0 /*&& + ( !mod->cLines[line]->addr || + mod->cLines[line]->level > level )*/ ) + { + if ( mod->cLines[line]->addr != INT_MAX ) + { + /* save double line information for exepoints */ + exePoint *ep ; + ep = Safe_calloc(1,sizeof(exePoint)); + ep->addr = mod->cLines[line]->addr ; + ep->line = line; + ep->block= mod->cLines[line]->block; + ep->level= mod->cLines[line]->level; + addSet(&mod->cfpoints,ep); + Dprintf(D_symtab, ("symtab: exe %s(%d:0x%x) %s", mod->c_name, + line+1, addr, mod->cLines[line]->src)); + } + mod->cLines[line]->addr = addr; + mod->cLines[line]->block = block; + mod->cLines[line]->level = level; + Dprintf(D_symtab, ("symtab: ccc %s(%d:0x%x) %s", mod->c_name, + line+1, addr, mod->cLines[line]->src)); + } + return; +} + +/*-----------------------------------------------------------------*/ +/* parseLnkRec - parses a linker generated record */ +/*-----------------------------------------------------------------*/ +void parseLnkRec (char *s) +{ + /* link records can be several types + dpeneding on the type do */ + + switch (*s) + { + /* c source line address */ + case 'C': + lnkCSrc(s+2); + break; + /* assembler source address */ + case 'A': + lnkAsmSrc(s+2); + break; + + case 'X': + lnkFuncEnd(s+1); + break; + + default : + lnkSymRec(s); + break; + } +} diff --git a/debugger/mcs51/symtab.h b/debugger/mcs51/symtab.h new file mode 100644 index 0000000..40b1922 --- /dev/null +++ b/debugger/mcs51/symtab.h @@ -0,0 +1,247 @@ +/*------------------------------------------------------------------------- + symtab.h - Header file for symbol table for sdcdb ( debugger ) + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SYMTAB_H +#define SYMTAB_H + +#define MAX_NEST_LEVEL 256 +#define SDCC_NAME_MAX 64 + +typedef struct structdef { + char *tag ; /* tag part of structure */ + unsigned char level ; /* Nesting level */ + struct symbol *fields ; /* pointer to fields */ + unsigned size ; /* sizeof the table in bytes */ + char *sname ; /* scope name */ + char scopetype ; /* scope type 'G' or 'F' */ +} structdef ; + +/* noun definitions */ +enum { V_INT = 0, + V_FLOAT , + V_CHAR , + V_VOID , + V_STRUCT , + V_LABEL , + V_BIT , + V_SBIT }; + +/* storage class */ +enum { S_FIXED = 0, + S_AUTO , + S_REGISTER , + S_CONSTANT , + S_SFR , + S_SBIT , + S_CODE , + S_XDATA , + S_DATA , + S_IDATA , + S_PDATA , + S_LITERAL , + S_STACK , + S_XSTACK , + S_BIT }; + +/* specifier is the last in the type-chain */ +typedef struct specifier { + unsigned noun ; /* CHAR INT STRUCTURE LABEL */ + unsigned sclass ; /* REGISTER,AUTO,FIX,CONSTANT */ + unsigned _long : 1 ; /* 1=long */ + unsigned _short: 1 ; /* 1=short int */ + unsigned _unsigned: 1 ; /* 1=unsigned, 0=signed */ + unsigned _static: 1 ; /* 1=static keyword found */ + unsigned _extern: 1 ; /* 1=extern found */ + unsigned _absadr: 1 ; /* absolute address specfied */ + unsigned _reent : 1 ; /* function is reentrant */ + unsigned _intrtn: 1 ; /* this is an interrupt routin*/ + unsigned _rbank : 1 ; /* seperate register bank */ + unsigned _volatile : 1; /* is marked as volatile */ + unsigned _const:1 ; /* is a constant */ + unsigned _critical:1 ; /* critical function */ + unsigned _typedef :1 ; /* is typedefed */ + unsigned _IntNo ; /* 1=Interrupt svc routine */ + short _regbank ; /* register bank 2b used */ + unsigned _addr ; /* address of symbol */ + unsigned _stack ; /* stack offset for stacked v */ + unsigned _bitStart ; /* bit start position */ + unsigned _bitLength ; /* bit length */ + + struct structdef *v_struct; /* structure pointer */ +} specifier ; + +/* types of declarators */ +enum { POINTER = 0, /* pointer to near data */ + FPOINTER , /* pointer to far data */ + CPOINTER , /* pointer to code space */ + GPOINTER , /* _generic pointer */ + PPOINTER , /* paged area pointer */ + IPOINTER , /* pointer to upper 128 bytes */ + UPOINTER , /* unknown pointer used only when parsing */ + ARRAY , + FUNCTION }; + +typedef struct declarator { + short dcl_type; /* POINTER,ARRAY or FUNCTION */ + short num_elem; /* # of elems if type==array */ + short ptr_const :1; /* pointer is constant */ + short ptr_volatile:1; /* pointer is volatile */ + struct st_link *tspec; /* pointer type specifier */ +} declarator ; + +#define DECLARATOR 0 +#define SPECIFIER 1 + +typedef struct st_link { + unsigned class : 1 ; /* DECLARATOR or SPECIFIER */ + unsigned tdef : 1 ; /* current link created by */ + /* typedef if this flag is set*/ + union { + specifier s ; /* if CLASS == SPECIFIER */ + declarator d ; /* if CLASS == DECLARATOR */ + } select ; + + struct st_link *next ; /* next element on the chain */ +} st_link ; + +typedef struct symbol { + char *name ; + + short size ; + short level ; /* declration lev,fld offset */ + short block ; /* sequential block # of defintion */ + short isonstack ; /* is the variable on stack */ + unsigned isfunc :1 ; /* is a functions */ + unsigned offset ; /* offset from top if struct */ + unsigned addr ; /* address if the symbol */ + unsigned eaddr ; /* end address for functions */ + char addr_type ; /* which address space */ + st_link *type ; /* start of type chain */ + st_link *etype ; /* end of type chain */ + char scopetype ; /* 'G' global, 'F' - file, 'L' local */ + char *sname ; /* if 'F' or 'L' then scope name */ + char *rname ; /* real name i.e. mangled beyond recognition */ + char addrspace ; /* address space designator */ + struct symbol *next ; +} symbol ; + +/* size's in bytes */ +#define CHARSIZE 1 +#define SHORTSIZE 1 +#define INTSIZE 2 +#define LONGSIZE 4 +#define PTRSIZE 1 +#define FPTRSIZE 2 +#define GPTRSIZE 3 +#define BITSIZE 1 +#define FLOATSIZE 4 +#define MAXBASESIZE 4 + +/* Easy Access Macros */ +#define DCL_TYPE(l) l->select.d.dcl_type +#define DCL_ELEM(l) l->select.d.num_elem +#define DCL_PTR_CONST(l) l->select.d.ptr_const +#define DCL_PTR_VOLATILE(l) l->select.d.ptr_volatile +#define DCL_TSPEC(l) l->select.d.tspec +#define SPEC_NOUN(x) x->select.s.noun +#define SPEC_LONG(x) x->select.s._long +#define SPEC_SHORT(x) x->select.s._short +#define SPEC_USIGN(x) x->select.s._unsigned +#define SPEC_SCLS(x) x->select.s.sclass +#define SPEC_OCLS(x) x->select.s.oclass +#define SPEC_STAT(x) x->select.s._static +#define SPEC_EXTR(x) x->select.s._extern +#define SPEC_CODE(x) x->select.s._codesg +#define SPEC_RENT(x) x->select.s._reent +#define SPEC_INTN(x) x->select.s._IntNo +#define SPEC_ABSA(x) x->select.s._absadr +#define SPEC_BANK(x) x->select.s._regbank +#define SPEC_ADDR(x) x->select.s._addr +#define SPEC_STAK(x) x->select.s._stack +#define SPEC_CVAL(x) x->select.s.const_val +#define SPEC_BSTR(x) x->select.s._bitStart +#define SPEC_BLEN(x) x->select.s._bitLength +#define SPEC_BNKF(x) x->select.s._rbank +#define SPEC_INTRTN(x) x->select.s._intrtn +#define SPEC_CRTCL(x) x->select.s._critical +#define SPEC_VOLATILE(x) x->select.s._volatile +#define SPEC_CONST(x) x->select.s._const +#define SPEC_STRUCT(x) x->select.s.v_struct +#define SPEC_TYPEDEF(x) x->select.s._typedef + +/* type check macros */ +#define IS_DECL(x) ( x && x->class == DECLARATOR ) +#define IS_SPEC(x) ( x && x->class == SPECIFIER ) +#define IS_ARRAY(x) (IS_DECL(x) && DCL_TYPE(x) == ARRAY) +#define IS_PTR(x) (IS_DECL(x) && (DCL_TYPE(x) == POINTER || \ + DCL_TYPE(x) == FPOINTER || \ + DCL_TYPE(x) == GPOINTER || \ + DCL_TYPE(x) == IPOINTER || \ + DCL_TYPE(x) == PPOINTER || \ + DCL_TYPE(x) == CPOINTER || \ + DCL_TYPE(x) == UPOINTER )) +#define IS_PTR_CONST(x) (IS_PTR(x) && DCL_PTR_CONST(x)) +#define IS_FARPTR(x) (IS_DECL(x) && DCL_TYPE(x) == FPOINTER) +#define IS_GENPTR(x) (IS_DECL(x) && DCL_TYPE(x) == GPOINTER) +#define IS_FUNC(x) (IS_DECL(x) && DCL_TYPE(x) == FUNCTION) +#define IS_LONG(x) (IS_SPEC(x) && x->select.s._long) +#define IS_SHORT(x) (IS_SPEC(x) && x->select.s._short) +#define IS_TYPEDEF(x) (IS_SPEC(x) && x->select.s._typedef) +#define IS_CONSTANT(x) (IS_SPEC(x) && (x->select.s.sclass == S_CONSTANT ||\ + x->select.s._const == 1)) +#define IS_STRUCT(x) (IS_SPEC(x) && x->select.s.noun == V_STRUCT) +#define IS_ABSOLUTE(x) (IS_SPEC(x) && x->select.s._absadr ) +#define IS_REGISTER(x) (IS_SPEC(x) && SPEC_SCLS(x) == S_REGISTER) +#define IS_RENT(x) (IS_SPEC(x) && x->select.s._reent ) +#define IS_STATIC(x) (IS_SPEC(x) && SPEC_STAT(x)) +#define IS_INT(x) (IS_SPEC(x) && x->select.s.noun == V_INT) +#define IS_VOID(x) (IS_SPEC(x) && x->select.s.noun == V_VOID) +#define IS_CHAR(x) (IS_SPEC(x) && x->select.s.noun == V_CHAR) +#define IS_EXTERN(x) (IS_SPEC(x) && x->select.s._extern) +#define IS_VOLATILE(x) (IS_SPEC(x) && x->select.s._volatile ) +#define IS_INTEGRAL(x) (IS_SPEC(x) && (x->select.s.noun == V_INT || \ + x->select.s.noun == V_CHAR || \ + x->select.s.noun == V_BIT || \ + x->select.s.noun == V_SBIT )) +#define IS_BITFIELD(x) (IS_SPEC(x) && (x->select.s.noun == V_BIT)) +#define IS_BITVAR(x) (IS_SPEC(x) && (x->select.s.noun == V_BIT || \ + x->select.s.noun == V_SBIT )) +#define IS_FLOAT(x) (IS_SPEC(x) && x->select.s.noun == V_FLOAT) +#define IS_ARITHMETIC(x) (IS_INTEGRAL(x) || IS_FLOAT(x)) +#define IS_AGGREGATE(x) (IS_ARRAY(x) || IS_STRUCT(x)) +#define IS_LITERAL(x) (IS_SPEC(x) && x->select.s.sclass == S_LITERAL) +#define IS_ISR(x) (IS_SPEC(x) && SPEC_INTRTN(x)) + + +symbol *parseSymbol (char *, char **, int); +structdef *parseStruct (char *); +void parseFunc (char *); +module *parseModule (char *, bool); +void parseLnkRec (char *); +symbol *symLookup (char *,context *); +DEFSETFUNC(moduleWithName); +DEFSETFUNC(moduleWithCName); +DEFSETFUNC(moduleWithAsmName); +unsigned int getSize (st_link *); + +#endif |
