Commit 0dcbf2cd authored by rdubner's avatar rdubner
Browse files

Track down the VAR_NODE.occurs uninitialized variable in COBST

parent d025c0dc
@ECHO OFF
SETLOCAL
::
:: Make sure cobc can run, using the default environment if one has
:: not already been set up
::
if not defined COB_CONFIG_DIR (
call cobenv --setenv >NUL
)
::
:: Bust up the input parameters into one that come before the single
:: COBOL source module we know how to handle, the COBOL module itself,
:: and the ones after
::
set BEFORESOURCE=
set SOURCEFILE=
set BASENAME=
set AFTERSOURCE=
set XorM=-m
IF "%1"=="-x" (
SET XorM=-x
SHIFT
)
IF "%1"=="-m" (
SET XorM=-m
SHIFT
)
set SOURCEFILE=%1
set BASENAME=%~n1
:parameter_loop
IF "%1"=="-x" (
SET XorM=-x
)
IF /i "%~x1"==".cbl" (
set SOURCEFILE=%1
set BASENAME=%~n1
goto parameter_continue
)
IF /i "%~x1"==".cob" (
set SOURCEFILE=%1
set BASENAME=%~n1
goto parameter_continue
)
IF "%SOURCEFILE%"=="" (
set BEFORESOURCE=%BEFORESOURCE% %1
) ELSE (
set AFTERSOURCE=%AFTERSOURCE% %1
)
:parameter_continue
shift
if not "%~1"=="" goto parameter_loop
:: echo BEFORESOURCE %BEFORESOURCE%
:: echo SOURCEFILE %SOURCEFILE%
:: echo AFTERSOURCE %AFTERSOURCE%
:: echo BASENAME %BASENAME%
:: echo XorM %XorM%
if "%BASENAME%"=="" (
echo No input files
......@@ -22,48 +57,59 @@ if "%BASENAME%"=="" (
:: Do a -S compile to create the .s file
set COB_CFLAGS=-fPIC -Wa,-L,-anchls=%BASENAME%.lst -I/mingw32/include -Wno-unused -fsigned-char -Wno-pointer-sign -D__USE_MINGW_ANSI_STDIO=1 -I/mingw32/include -march=i686 -mtune=generic -pipe -pipe
cobc -S -d -g %XorM% --fgen-c-line-directives --fgen-c-labels -T %BASENAME%.cbl.lst --tlines=0 --tsymbols %SOURCEFILE%
cobc -S -d -g %XorM% --fgen-c-line-directives --fgen-c-labels -T %BASENAME%.cbl.lst --tlines=0 --tsymbols %BEFORESOURCE% %SOURCEFILE%
IF NOT ERRORLEVEL 0 GOTO bail
:: Do a -c compile to create the .h, .i, and .lst file that COBST needs
cobc -c -d -g %XorM% --fgen-c-line-directives --fgen-c-labels -T %BASENAME%.cbl.lst --tlines=0 --tsymbols %SOURCEFILE%
cobc -c -d -g %XorM% --fgen-c-line-directives --fgen-c-labels -T %BASENAME%.cbl.lst --tlines=0 --tsymbols %BEFORESOURCE% %SOURCEFILE%
IF NOT ERRORLEVEL 0 GOTO bail
:: Get rid of the .o file we won't be using, just to avoid possible confusion
erase %BASENAME%.o
IF NOT ERRORLEVEL 0 GOTO bail
:: Run COBST to create basename.sym.c
cobst -q %BASENAME%
IF NOT ERRORLEVEL 0 GOTO bail
:: Compile basename.sym.c to create basename.sym.o
set COB_CFLAGS=
cobc -c -o %BASENAME%.sym.o %BASENAME%.sym.c
IF NOT ERRORLEVEL 0 GOTO bail
:: Use SFIX to modify the basename.s file
sfix -q %BASENAME%.s %BASENAME%-2.s %BASENAME%.c %SOURCEFILE%
IF NOT ERRORLEVEL 0 GOTO bail
:: Assemble the modified .s file
cobc -c -o %BASENAME%.o %BASENAME%-2.s
IF NOT ERRORLEVEL 0 GOTO bail
:: Link the two .o modules together
IF "%XorM%"=="-x" (
cobc %XorM% %BASENAME%.o %BASENAME%.sym.o
cobc -x %BASENAME%.o %BASENAME%.sym.o %AFTERSOURCE%
IF NOT ERRORLEVEL 0 GOTO bail
) ELSE (
gcc -shared -o %BASENAME% %BASENAME%.o %BASENAME%.sym.o -lcob
gcc -shared -o %BASENAME%.dll %BASENAME%.o %BASENAME%.sym.o -lcob %AFTERSOURCE%
IF NOT ERRORLEVEL 0 GOTO bail
)
SET CPRINTPY=
for %%I in (cprint.py) do SET CPRINTPY=%%~$PATH:I
if "%CPRINTPY%"=="" (
echo Couldn't find a copy of cprint.py on the PATH
) ELSE (
copy %CPRINTPY% %BASENAME%-gdb.py >NUL
)
:bail
if "%COBCDNOCLEAN%"=="" (
erase /Q %BASENAME%.c %BASENAME%.s %BASENAME%*.h %BASENAME%.i %BASENAME%.lst ^
%BASENAME%.cbl.lst %BASENAME%.full.tab %BASENAME%.tab %BASENAME%.o ^
%BASENAME%.cbl.o %BASENAME%-2.lst %BASENAME%.sym.c %BASENAME%.sym.o ^
%BASENAME%-2.s %BASENAME%.o
%BASENAME%-2.s %BASENAME%.o %BASENAME%-2.o
)
ENDLOCAL
\ No newline at end of file
......@@ -115,11 +115,11 @@ GAS_SYMBOLS::GetSymbolsFromFile(const string &source, const string &scope, ifstr
smatch sm;
if(regex_match(input,sm,symbol32) OR regex_match(input,sm,symbol16)) {
GAS_SYMBOL gs;
gs.gas_section = sm[2];
gs.line_number = stoi(sm[1]);
gs.gas_value = stoll(sm[3],NULL,16);
gs.gas_section = sm[2].str();
gs.line_number = stoi(sm[1].str());
gs.gas_value = stoll(sm[3].str(),NULL,16);
string stripped_symbol = sm[4];
string stripped_symbol = sm[4].str();
// When compiled in the Windows environment, symbols get prefixed with
// an underscore.
if( stripped_symbol.length() > 1 AND stripped_symbol[0] EQ '_' ) {
......@@ -510,8 +510,8 @@ COB_LABELS::GetSymbolsFromFile(const string &source, const string &scope, ifstre
static const regex linkage(".*\\(([^,]+),[^']+[']([^']+).*$");
if(regex_match(input,sm,linkage)) {
pair<string,string> cobol_c;
cobol_c.first = sm[1];
cobol_c.second = sm[2];
cobol_c.first = sm[1].str();
cobol_c.second = sm[2].str();
if( linkage_weve_seen.find(cobol_c) EQ linkage_weve_seen.end() ) {
linkage_weve_seen.insert(cobol_c);
COB_LABEL cs;
......@@ -521,12 +521,12 @@ COB_LABELS::GetSymbolsFromFile(const string &source, const string &scope, ifstre
if(program_id_stack.size() >= 1) {
cs.program = program_id_stack.back();
}
cs.entry = sm[2];
cs.entry = sm[2].str();
cs.section = "Linkage";
cs.paragraph = current_paragraph;
// Linkage isn't in .text, but rather .data.rel.local
cs.gas_section = ".data.rel.local";
cs.gas_symbol = sm[1];
cs.gas_symbol = sm[1].str();
symbols.push_back(cs);
}
}
......@@ -546,8 +546,8 @@ COB_LABELS::GetSymbolsFromFile(const string &source, const string &scope, ifstre
static const regex linkage(".*\\(COB_SET_DATA [^,]+, ([^)]+)[^\"]+\"([^\"]+).*$");
if(regex_match(input,sm,linkage)) {
pair<string,string> cobol_c;
cobol_c.first = sm[1];
cobol_c.second = sm[2];
cobol_c.first = sm[1].str();
cobol_c.second = sm[2].str();
if( linkage_weve_seen.find(cobol_c) EQ linkage_weve_seen.end() ) {
linkage_weve_seen.insert(cobol_c);
COB_LABEL cs;
......@@ -557,12 +557,12 @@ COB_LABELS::GetSymbolsFromFile(const string &source, const string &scope, ifstre
if(program_id_stack.size() >= 1) {
cs.program = program_id_stack.back();
}
cs.entry = sm[2];
cs.entry = sm[2].str();
cs.section = "Linkage";
cs.paragraph = current_paragraph;
// Linkage isn't in .text, but rather .data.rel.local
cs.gas_section = ".data.rel.local";
cs.gas_symbol = sm[1];
cs.gas_symbol = sm[1].str();
symbols.push_back(cs);
}
}
......@@ -575,16 +575,16 @@ COB_LABELS::GetSymbolsFromFile(const string &source, const string &scope, ifstre
static const regex csd("COB_SET_DATA [(]([^,]+), ([^)]+).*$");
string spiece = input.substr(ncob);
if(regex_match(spiece,sm,csd)) {
string target = sm[1];
string source = sm[2];
string target = sm[1].str();
string source = sm[2].str();
string base = sm[2];
string base = sm[2].str();
string offset;
static const regex offset_match("(.*) [+] (.*)");
smatch sm2;
if(regex_match(source,sm2,offset_match)) {
base = sm2[1];
offset = sm2[2];
base = sm2[1].str();
offset = sm2[2].str();
}
gas_symbol_table.UpdateBaseOffset(target,base,offset);
}
......@@ -848,12 +848,12 @@ DATA_DESCRIPTIONS::ProcessDataStorage(ifstream &ifs,const string &source)
inpic = false;
picture_string.clear();
} else {
string ch = sm[1];
string ch = sm[1].str();
picture_string += ch[0];
int n = stoi(sm[2]);
int n = stoi(sm[2].str());
if(n > 1) {
picture_string += '(';
picture_string += sm[2];
picture_string += sm[2].str();
picture_string += ')';
}
}
......@@ -894,8 +894,8 @@ DATA_DESCRIPTIONS::ProcessDataStorage(ifstream &ifs,const string &source)
ds.storage_type = "Storage";
ds.storage_scope = scope;
ds.cbl_symbol = GetCommentText(input);
ds.gas_symbol = sm[1];
ds.storage_size = stoll(sm[2]);
ds.gas_symbol = sm[1].str();
ds.storage_size = stoll(sm[2].str());
symbols.push_back(ds);
// It turns out that the program kinda lies when it gets
......@@ -999,12 +999,12 @@ DATA_DESCRIPTIONS::ProcessDataStorage(ifstream &ifs,const string &source)
// look for b_17 + 10
smatch sm2;
static const regex offset_match("(.*) [+] (.*)");
string base_offset = sm[3];
string base = sm[3];
string base_offset = sm[3].str();
string base = sm[3].str();
string offset;
if(regex_match(base_offset,sm2,offset_match)) {
base = sm2[1];
offset = sm2[2];
base = sm2[1].str();
offset = sm2[2].str();
}
// As mentioned in the b_ processing, the program_id at
......@@ -1029,14 +1029,14 @@ DATA_DESCRIPTIONS::ProcessDataStorage(ifstream &ifs,const string &source)
ds.program_id = mapped_program_id;
ds.storage_type = "Field";
ds.storage_scope = scope;
ds.gas_symbol = sm[1];
ds.field_size = stoi(sm[2]);
ds.gas_symbol = sm[1].str();
ds.field_size = stoi(sm[2].str());
if(base EQ "NULL") {
base.clear();
}
ds.field_data_pointer = base;
ds.field_data_offset = offset;
ds.field_attr_pointer = sm[4];
ds.field_attr_pointer = sm[4].str();
ds.cbl_symbol = GetCommentText(input);
symbols.push_back(ds);
}
......@@ -1049,7 +1049,7 @@ DATA_DESCRIPTIONS::ProcessDataStorage(ifstream &ifs,const string &source)
smatch sm;
static const regex re_picture(".*cob_pic_symbol ([^[]+).*");
if(regex_match(input,sm,re_picture)) {
picture_symbol = sm[1];
picture_symbol = sm[1].str();
inpic = true;
continue;
}
......
......@@ -45,6 +45,7 @@ VAR_NODE::VAR_NODE()
size = 0;
offset = 0;
level = LEVEL_ROOT;
occurs = 0;
parent = nullptr;
field_size = 0;
......
file rtest
set height 0
b 174
r
print header
......
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