Commit 21ad4aac authored by rdubner's avatar rdubner

Release version 0.10.1

This version involves a moderately radical change.  Up until now, the process involved
creating a .tab file that was left next to the .cbl source file.  The cprint.py script
embedded in the executable would look for the .tab file and get line number and COBOL/C
symbol table cross-reference information from there.  In this version, obmod reads
the .tab file and embeds the data into the cprint.py script.  The symbols ride with
the executable, and the .tab file isn't needed once obmod runs.
parent 02730c20
......@@ -412,94 +412,6 @@ CreateCSV(PARAMETERS &params,
csv.Generate(params.csv);
}
static void
CreateCModule(PARAMETERS &params,
const COB_LABELS &cob_labels,
const VARIABLE_TREE &var_tree)
{
/* This routine puts the COBOL-identifier/C-identifier cross-reference
information into a .c module destined to be compiled and linked into
the the executable.
*/
params.csym << "// COBOL-to-C symbol cross reference, generated by \n";
params.csym << "// the COBST program.\n";
params.csym << "// For safety's sake, compile with -O0 'no optimization' switch\n";
params.csym << endl;
// Build an oddball name, to zeroize collision possibilities
params.csym << "volatile char *" << params.cbl_filename.GetFname()
<< "_o0O0o_Symbols[] = {" << endl;
// Do the line/address information from the .text in the minimal form
// used by cprint.py to figure out which program a trap has occurred in.
string current_program = "";
for(int i=0; i<cob_labels.size(); i++) {
COB_LABEL cs = cob_labels[i];
if( cs.section EQ "Linkage" ) {
// This information was previously transferred to the
// data_description information, so don't put it out here because
// it's potentially confusing.
continue;
}
stringstream ss;
ios_base::fmtflags deflags = ss.flags();
if( cs.program != current_program) {
current_program = cs.program;
ss << "P|";
ss << cs.line_number << "|";
ss << cs.program << "|";
params.csym << " \"" << ss.str() << "\"," << endl;
}
}
// You can't change the order of things here unless you also change
// the ordering in cprint.py They are tightly linked, and that's that!
for(int i=0; i<var_tree.size(); i++) {
const VAR_NODE var = var_tree[i];
stringstream ss;
ss << "D|";
ss << var.GetSection().substr(0,2) << "|";
ss << var.GetLevel() << "|" ;
ss << var.GetCanonicalName() << "|" ;
ss << var.GetBaseSymbol() << "|" ;
ss << var.GetOffset() << "|" ;
ss << var.GetType().substr(0,1) << "|" ;
ss << var.GetSize() << "|" ;
ss << var.GetPicture() << "|" ;
ss << var.GetOccurs() << "|" ;
ss << var.GetFieldSize() << "|" ;
ss << var.GetAttrType() << "|" ;
ss << var.GetAttrDigits() << "|" ;
ss << var.GetAttrScale() << "|" ;
ss << var.GetAttrFlags() << "|";
// To save bytes, let's assume that any "||" will be interpreted as
// being the same as "|0|"
string s = ss.str();
for(;;) {
size_t n = s.find("|0|");
if( n EQ string::npos ) {
break;
}
s.replace(n,3,"||");
}
params.csym << " \"" << s << "\"," << endl;
}
params.csym << " (char *)(0)" << endl;
params.csym << " };" << endl;
params.csym << endl;
}
int main(int argc, char *argv[])
{
PROFILER;
......@@ -588,9 +500,5 @@ int main(int argc, char *argv[])
// Create our actual useful .TAB file.
CreateCSV(params,cob_labels,variable_tree);
// Create our C-code cross-reference module
CreateCModule(params,cob_labels,variable_tree);
return 0;
}
......@@ -234,7 +234,6 @@ PARAMETERS GetParameters(int argc, char *argv[])
retval.cbl_lst_filename.Decode(retval.cbl_filename.Stem() + ".cbl.lst");
retval.full_csv_filename.Decode(retval.cbl_filename.Stem() + ".full.tab");
retval.csv_filename.Decode(retval.cbl_filename.Stem() + ".tab");
retval.csym_filename.Decode(retval.cbl_filename.Stem() + ".sym.c");
OpenOrFail(retval.cbl,retval.cbl_filename.WholePath());
OpenOrFail(retval.i,retval.i_filename.WholePath());
......@@ -243,7 +242,6 @@ PARAMETERS GetParameters(int argc, char *argv[])
OpenOrFail(retval.cbl_lst,retval.cbl_lst_filename.WholePath());
OpenOrFail(retval.full_csv,retval.full_csv_filename.WholePath());
OpenOrFail(retval.csv,retval.csv_filename.WholePath());
OpenOrFail(retval.csym,retval.csym_filename.WholePath());
return retval;
}
......
......@@ -85,8 +85,6 @@ public:
// // we know in it.
FILENAME csv_filename; // Our output file, destined to be read
// // downstream
FILENAME csym_filename; // Our output file, destined to be
// // compiled into the executable
std::ifstream cbl; // Streams for the above files
std::ifstream cbl_lst;
......@@ -95,7 +93,6 @@ public:
std::ifstream lst;
std::ofstream full_csv;
std::ofstream csv;
std::ofstream csym;
bool quiet;
};
......
......@@ -27,7 +27,7 @@ public:
std::string list_type; //
size_t list_size; // Length of data
std::string picture;
std::string usage;
std::string usage;
int occurs;
USHORT attr_type;
USHORT attr_digits;
......
......@@ -48,9 +48,11 @@ int main(int argc, char **argv)
elf.InsertDebugScript("cprint.py",params.o_input_filename.GetFname());
// Put the COBOL symbols into the elf segments
// Took this out in January 2020; it was corrupting more complex
// source files like NC101A and NC250A
// Put the COBOL symbols into the elf segments.
// This was an experimental effort to figure out how to insert symbols
// into the ELF relocatable. They weren't used for anything.
// I took it out in January 2020 because it was corrupting more complex
// source files like NC101A and NC250A.
// elf.AugmentSymbolTable();
#if 0
......
......@@ -35,8 +35,7 @@ $(project) : $(project).cbl
@# Get rid of intermediate files, leaving behind the .tab file needed by gdb
rm -f $(project).c $(project).o $(project).cbl.o $(project)*.h $(project).i \
$(project).lst $(project).cbl.lst $(project).full.tab \
$(project).sym.c $(project).sym.o
$(project).lst $(project).cbl.lst $(project).full.tab $(project).tab
# This cleans up the various project files, along with any additional
# $(CLEAN) files specified by the parent Makefile It also clobbers any
......
......@@ -91,18 +91,6 @@ import re
import sys
import os
def GetByte(address) :
byte = None
command = "x/1b " + str(address)
address += 1
byte_string = gdb.execute(command,False,True)
print(address, byte_string)
nfound = byte_string.rfind("\t")
if nfound > -1 :
byte_string = byte_string[nfound+1:]
byte = int(byte_string,16)
return byte
def LeftRight(s,splitchar) :
"""Splits what is presumably a numeric string with a possible
splitting character into left and right pieces"""
......@@ -160,18 +148,6 @@ def Picture(s) :
return r
def FlagLeadingZeroes(s) :
""" Replace leading zeroes with 'z' """
r = ""
z = 'z'
for ch in s :
if ch == '0' :
r += z
else :
r += ch
z = '0'
return r
def MachineInterfaceBody(s) :
### convert display_body for machine interface:
body = s
......@@ -211,6 +187,11 @@ class VarTrieNode() :
def AddCanonicalName(self,name) :
pass
def BlankIsZero(v) :
if len(v) == 0 :
v = "0"
return int(v)
class VarTrie() :
def __init__(self):
self.storage_list = []
......@@ -240,8 +221,7 @@ class VarTrie() :
# and we are done
def LoadFromLine(self,variable_line) :
if len(variable_line) >= 1 and variable_line[1] == "D" :
if len(variable_line) >= 1 and variable_line[0] == "D" :
# These correspond to the list of outputs generated by obmod
indexSection=1
indexLevel=2
......@@ -266,21 +246,21 @@ class VarTrie() :
payload.Program = name_tokens[-1]
payload.Section = tokens[indexSection]
payload.Name = tokens[indexName]
payload.Level = int(tokens[indexLevel])
payload.Level = int(BlankIsZero(tokens[indexLevel]))
payload.Base = tokens[indexBase]
payload.Field = tokens[indexField]
payload.Attr = tokens[indexAttr]
payload.Offset = int(tokens[indexOffset])
#payload.Field = tokens[indexField]
#payload.Attr = tokens[indexAttr]
payload.Offset = int(BlankIsZero(tokens[indexOffset]))
payload.ListType = tokens[indexListType]
payload.ListSize = int(tokens[indexListSize])
payload.ListSize = int(BlankIsZero(tokens[indexListSize]))
payload.Picture = tokens[indexPicture]
payload.Usage = tokens[indexUsage]
payload.Occurs = int(tokens[indexOccurs])
payload.FieldSize = int(tokens[indexListSize])
payload.AttrType = int(tokens[indexAttrType])
payload.AttrDigits = int(tokens[indexAttrDigits])
payload.AttrScale = int(tokens[indexAttrScale])
payload.AttrFlags = int(tokens[indexAttrFlags])
payload.Occurs = int(BlankIsZero(tokens[indexOccurs]))
payload.FieldSize = int(BlankIsZero(tokens[indexListSize]))
payload.AttrType = int(BlankIsZero(tokens[indexAttrType]))
payload.AttrDigits = int(BlankIsZero(tokens[indexAttrDigits]))
payload.AttrScale = int(BlankIsZero(tokens[indexAttrScale]))
payload.AttrFlags = int(BlankIsZero(tokens[indexAttrFlags]))
if payload.Section == "IN" :
payload.Section = "INPUT-OUTPUT"
......@@ -288,7 +268,7 @@ class VarTrie() :
payload.Section = "WORKING-STORAGE"
elif payload.Section == "LO" :
payload.Section = "LOCAL-STORAGE"
elif payload.Section == "L" :
elif payload.Section == "LI" :
payload.Section = "LINKAGE"
if payload.ListType == "A" :
......@@ -371,8 +351,8 @@ class VarTrie() :
if boy_index < len(boys) :
# we still have at least one boy to leave off at his tree
boy = boys[boy_index]
print("DEBUG boy",boy)
print("DEBUG trie.children.keys",trie.children.keys())
#print("DEBUG boy",boy)
#print("DEBUG trie.children.keys",trie.children.keys())
if boy in trie.children :
# We have found this boy's tree. Advance both the boy
# and the trie.
......@@ -886,15 +866,15 @@ class CobolVariable() :
command = "info address cob_local_ptr"
address_string = gdb.execute(command,False,True)
print(command)
print(address_string)
#print(command)
#print(address_string)
address_string = gdb.execute(command,False,True)
match = re.search("address 0x([0-9a-f]+)\.",address_string)
if not match :
print("No match")
else :
print(match.group(1))
#print(match.group(1))
address = int(match.group(1),16)
address += self.Offset
return address
......@@ -3033,13 +3013,15 @@ class CWatchWorker() :
# There are one or more arguments. Use our clever routine
# to come up with the possibilities:
possibilities = TabFile.var_trie.GetListOfPossibilities(args)
if len(possibilities) == 1 :
# There's only one possibility, which is nice and simple.
if len(possibilities) == 1 and not pstar:
# There's only one possibility, and it wasn't a star.
# This is nice and simple.
# We'll just move ahead and process it.
payload_number = possibilities[0]
elif len(possibilities) > 1 :
# There are multiple possibilities. Load them into
# short-term memory:
elif len(possibilities) > 1 or (len(possibilities) > 0 and pstar) :
# There are multiple possibilities, or there is one
# possibility found via a 'p *'.
# Load them into short-term memory:
ShortTermMemory.short_term_memory = possibilities
# and show them to our user
......
*.c
*.sym.c
*.c.*
*.h
*.lst
*.cbl.lst
......
......@@ -51,16 +51,13 @@ $(project) : $(project).cbl $(OBMOD) $(COBST)
@# used by obmod and
$(COBST) $(project).cbl
@# Compile the cobst-generated .sym.c file
gcc -O0 -c -o $(project).sym.o $(project).sym.c
@# obmod creates a modified relocatable .o ELF file from project.tab and
@# the .o file created by cobc
$(OBMOD) -i $(project).o -t $(project).tab -o $(project).cbl.o
@# This second invocation of cobc creates the modified ELF executable from
@# the modified .o ELF relocatable
$(COBC) -x -o $(project) $(project).cbl.o $(project).sym.o
$(COBC) -x -o $(project) $(project).cbl.o
# This rule creates project.x, which is an unmodified ELF executable created
# with all the same switches as the modified one. The debugging information
......@@ -83,7 +80,7 @@ $(project).s : $(project).cbl
# .txt files that might be lying around; I often create .txt files
# from dwarfdump and hexdump.
.PHONY : clean
suffixes = .c .s *.h .i .lst .cbl.lst .full.tab .tab .o .cbl.o .x .sym.c .sym.o
suffixes = .c .s *.h .i .lst .cbl.lst .full.tab .tab .o .cbl.o .x
clean:
rm -f $(addprefix $(project),$(suffixes)) $(project) *.txt $(CLEAN)
......
......@@ -173,56 +173,56 @@ DISPLAY " "
DISPLAY header
DISPLAY withpic
DISPLAY "def-BINARY-CHAR " def-BINARY-CHAR
DISPLAY "def-BINARY-CHAR-SIGNED " def-BINARY-CHAR-SIGNED
DISPLAY "def-BINARY-CHAR-UNSIGNED " def-BINARY-CHAR-UNSIGNED
DISPLAY "def-BINARY-C-LONG " def-BINARY-C-LONG
DISPLAY "def-BINARY-C-LONG-SIGNED " def-BINARY-C-LONG-SIGNED
DISPLAY "def-BINARY-C-LONG-UNSIGNED " def-BINARY-C-LONG-UNSIGNED
DISPLAY "def-BINARY-DOUBLE " def-BINARY-DOUBLE
DISPLAY "def-BINARY-DOUBLE-SIGNED " def-BINARY-DOUBLE-SIGNED
DISPLAY "def-BINARY-DOUBLE-UNSIGNED " def-BINARY-DOUBLE-UNSIGNED
DISPLAY "def-BINARY-INT " def-BINARY-INT
DISPLAY "def-BINARY-LONG " def-BINARY-LONG
DISPLAY "def-BINARY-LONG-SIGNED " def-BINARY-LONG-SIGNED
DISPLAY "def-BINARY-LONG-UNSIGNED " def-BINARY-LONG-UNSIGNED
DISPLAY "def-BINARY-LONG-LONG " def-BINARY-LONG-LONG
DISPLAY "def-BINARY-SHORT " def-BINARY-SHORT
DISPLAY "def-BINARY-SHORT-SIGNED " def-BINARY-SHORT-SIGNED
DISPLAY "def-BINARY-SHORT-UNSIGNED " def-BINARY-SHORT-UNSIGNED
DISPLAY "def-COMPUTATIONAL " def-COMPUTATIONAL
DISPLAY "def-COMP-1 " def-COMP-1
DISPLAY "def-COMP-2 " def-COMP-2
DISPLAY "def-COMPUTATIONAL-1 " def-COMPUTATIONAL-1
DISPLAY "def-COMPUTATIONAL-2 " def-COMPUTATIONAL-2
DISPLAY "def-FLOAT-DECIMAL-16 " def-FLOAT-DECIMAL-16
DISPLAY "def-FLOAT-DECIMAL-34 " def-FLOAT-DECIMAL-34
DISPLAY "def-FLOAT-LONG " def-FLOAT-LONG
DISPLAY "def-FLOAT-SHORT " def-FLOAT-SHORT
DISPLAY "def-INDEX " def-INDEX
DISPLAY "def-SIGNED-INT " def-SIGNED-INT
DISPLAY "def-SIGNED-LONG " def-SIGNED-LONG
DISPLAY "def-SIGNED-SHORT " def-SIGNED-SHORT
DISPLAY "def-UNSIGNED-INT " def-UNSIGNED-INT
DISPLAY "def-UNSIGNED-LONG " def-UNSIGNED-LONG
DISPLAY "def-UNSIGNED-SHORT " def-UNSIGNED-SHORT
DISPLAY "def-COMP-3 " def-COMP-3
DISPLAY "def-COMPUTATIONAL-3 " def-COMPUTATIONAL-3
DISPLAY "def-PACKED-DECIMAL " def-PACKED-DECIMAL
DISPLAY "def-PACKED-DECIMAL-S " def-PACKED-DECIMAL-S
DISPLAY "def-BINARY " def-BINARY
DISPLAY "def-BINARY-S " def-BINARY-S
DISPLAY "def-COMP " def-COMP
DISPLAY "def-COMPUTATIONAL " def-COMPUTATIONAL
DISPLAY "def-COMP-4 " def-COMP-4
DISPLAY "def-COMPUTATIONAL-4 " def-COMPUTATIONAL-4
DISPLAY "def-COMP-5 " def-COMP-5
DISPLAY "def-COMPUTATIONAL-5 " def-COMPUTATIONAL-5
DISPLAY "def-COMP-6 " def-COMP-6
DISPLAY "def-COMP-X " def-COMP-X
DISPLAY "def-COMPUTATIONAL-X " def-COMPUTATIONAL-X
DISPLAY "def-COMP-XX " def-COMP-XX
DISPLAY "def-DISPLAY " def-DISPLAY
DISPLAY def-BINARY-CHAR " def-BINARY-CHAR "
DISPLAY def-BINARY-CHAR-SIGNED " def-BINARY-CHAR-SIGNED "
DISPLAY def-BINARY-CHAR-UNSIGNED " def-BINARY-CHAR-UNSIGNED "
DISPLAY def-BINARY-C-LONG " def-BINARY-C-LONG "
DISPLAY def-BINARY-C-LONG-SIGNED " def-BINARY-C-LONG-SIGNED "
DISPLAY def-BINARY-C-LONG-UNSIGNED " def-BINARY-C-LONG-UNSIGNED "
DISPLAY def-BINARY-DOUBLE " def-BINARY-DOUBLE "
DISPLAY def-BINARY-DOUBLE-SIGNED " def-BINARY-DOUBLE-SIGNED "
DISPLAY def-BINARY-DOUBLE-UNSIGNED " def-BINARY-DOUBLE-UNSIGNED "
DISPLAY def-BINARY-INT " def-BINARY-INT "
DISPLAY def-BINARY-LONG " def-BINARY-LONG "
DISPLAY def-BINARY-LONG-SIGNED " def-BINARY-LONG-SIGNED "
DISPLAY def-BINARY-LONG-UNSIGNED " def-BINARY-LONG-UNSIGNED "
DISPLAY def-BINARY-LONG-LONG " def-BINARY-LONG-LONG "
DISPLAY def-BINARY-SHORT " def-BINARY-SHORT "
DISPLAY def-BINARY-SHORT-SIGNED " def-BINARY-SHORT-SIGNED "
DISPLAY def-BINARY-SHORT-UNSIGNED " def-BINARY-SHORT-UNSIGNED "
DISPLAY def-COMPUTATIONAL " def-COMPUTATIONAL "
DISPLAY def-COMP-1 " def-COMP-1 "
DISPLAY def-COMP-2 " def-COMP-2 "
DISPLAY def-COMPUTATIONAL-1 " def-COMPUTATIONAL-1 "
DISPLAY def-COMPUTATIONAL-2 " def-COMPUTATIONAL-2 "
DISPLAY def-FLOAT-DECIMAL-16 " def-FLOAT-DECIMAL-16 "
DISPLAY def-FLOAT-DECIMAL-34 " def-FLOAT-DECIMAL-34 "
DISPLAY def-FLOAT-LONG " def-FLOAT-LONG "
DISPLAY def-FLOAT-SHORT " def-FLOAT-SHORT "
DISPLAY def-INDEX " def-INDEX "
DISPLAY def-SIGNED-INT " def-SIGNED-INT "
DISPLAY def-SIGNED-LONG " def-SIGNED-LONG "
DISPLAY def-SIGNED-SHORT " def-SIGNED-SHORT "
DISPLAY def-UNSIGNED-INT " def-UNSIGNED-INT "
DISPLAY def-UNSIGNED-LONG " def-UNSIGNED-LONG "
DISPLAY def-UNSIGNED-SHORT " def-UNSIGNED-SHORT "
DISPLAY def-COMP-3 " def-COMP-3 "
DISPLAY def-COMPUTATIONAL-3 " def-COMPUTATIONAL-3 "
DISPLAY def-PACKED-DECIMAL " def-PACKED-DECIMAL "
DISPLAY def-PACKED-DECIMAL-S " def-PACKED-DECIMAL-S "
DISPLAY def-BINARY " def-BINARY "
DISPLAY def-BINARY-S " def-BINARY-S "
DISPLAY def-COMP " def-COMP "
DISPLAY def-COMPUTATIONAL " def-COMPUTATIONAL "
DISPLAY def-COMP-4 " def-COMP-4 "
DISPLAY def-COMPUTATIONAL-4 " def-COMPUTATIONAL-4 "
DISPLAY def-COMP-5 " def-COMP-5 "
DISPLAY def-COMPUTATIONAL-5 " def-COMPUTATIONAL-5 "
DISPLAY def-COMP-6 " def-COMP-6 "
DISPLAY def-COMP-X " def-COMP-X "
DISPLAY def-COMPUTATIONAL-X " def-COMPUTATIONAL-X "
DISPLAY def-COMP-XX " def-COMP-XX "
DISPLAY def-DISPLAY " def-DISPLAY "
STOP RUN.
......
......@@ -3,7 +3,6 @@ boat.o
launchso.o
launchso
elbarco.c
elbarco.sym.c
elbarco.c.h
elbarco.c.l.h
elbarco.c.l1.h
......
dd_output
optfde01
optfde01.c
optfde01.sym.c
optfde01.c.h
optfde01.c.l.h
optfde01.cbl.lst
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment