Commit 349f7777 authored by rdubner's avatar rdubner

Remove excess functions from SFIX

parent df479475
......@@ -256,28 +256,6 @@ FigureOutReplacements(const PARAMETERS &params,
return retval;
}
VSTRING
ReadEntireFileV(const string &filename)
{
PROFILER;
VSTRING retval;
FILE *f = fopen(filename.c_str(), "r");
if( !f ) {
cerr << "Couldn't the open input file " << filename << endl;
exit(1);
}
char ach[OVERSIZED];
while(fgets(ach,sizeof(ach),f)) {
if(strlen(ach) AND ach[strlen(ach)-1] EQ '\n') {
ach[strlen(ach)-1] = '\0';
}
retval.push_back(ach);
}
fclose(f);
return retval;
}
void
ReadEntireFile(const string &filename,WHOLEFILE &fd)
{
......@@ -305,132 +283,6 @@ ReadEntireFile(const string &filename,WHOLEFILE &fd)
fd.current_index=0;
}
void
buildV(PARAMETERS &params,
map<string,int> &input_file_mappings,
map<int,int> &replacements,
VSTRING &input_file,
VINT &function_references)
{
PROFILER;
// Let's hang around here and do the hard work:
stringstream ss;
// Start the file off with our filename:
ss << "\t.file\t\"" << params.cbl_filename << "\"" << endl;
// And then, let's put the modified list of filenames right at the beginning:
for(map<string,int>::const_iterator it=input_file_mappings.begin();
it != input_file_mappings.end();
it++
) {
int oldnum = it->second;
int newnum = replacements[oldnum];
if( newnum ) {
ss << "\t.file " << newnum << " \"" << it->first << "\"" << endl;
}
}
int next_function_reference_index = 0;
// Start at 1, rather than zero; we need to get rid of the original
// " .file blah.c " line.
for( size_t i=1; i<input_file.size(); i++ ) {
// We have learned that the GDB trapping can get confused if there isn't
// a .loc reference in the first few lines after a function declaration.
// When we created the function_references array, we added offset we
// need to put a .loc into the right place. So, when i = function_references,
// it's time to put a .loc in.
if(next_function_reference_index < (int)function_references.size()
&& i EQ function_references[next_function_reference_index] ) {
// We have found a match.
next_function_reference_index += 1;
// We are going to look ahead for the next valid .loc, and put
// that same loc in right here. The duplications don't seem to
// cause GDB any problem.
size_t ii = i+4;
while(ii < input_file.size() ) {
VSTRING tokens = Split(input_file[ii]," \t");
if( tokens.size() > 1 AND tokens[1] EQ ".loc" ) {
// We need to replace the old file number with the new one
int old_num = STOI(tokens[2]);
int new_num = replacements[old_num];
if( new_num != 0 ) {
// Build the replacement line:
int new_line = STOI(tokens[3])-1;
ss << "\t.loc";
ss << " " << new_num ;
ss << " " << new_line ;
size_t index = 5;
while( index < tokens.size() ) {
ss << " ";
ss << tokens[index++];
}
ss << endl;
break;
}
}
ii += 1;
}
}
VSTRING tokens = Split(Trim(input_file[i])," \t");
if( !tokens.empty() ) {
if( tokens[0] EQ ".file" ) {
// We've already taken care of all .file lines
continue;
}
if( tokens[0] EQ ".loc" ) {
// We need to replace the old file number with the new one
int oldnum = STOI(tokens[1]);
int newnum = replacements[oldnum];
if( newnum != 0 ) {
// Rebuild the .loc line
ss << "\t";
ss << tokens[0];
ss << " ";
ss << newnum;
size_t index = 2;
while( index < tokens.size() ) {
ss << " ";
ss << tokens[index++];
}
ss << endl;
}
continue;
}
}
if( input_file[i].find("endbr64") EQ string::npos ) {
// When gcc went from version 8 to version 9, the compiler started
// inserting endbr64 assembly language instructions. It's safer, says
// the documentation.
//
// They screw up our efforts to trick GDB into doing our bidding -- GDB loses
// track of what lines to display after subroutine calls -- so I took the easy
// way out and just removed the suckers.
ss << input_file[i] << endl;
}
}
FILE *f = fopen(params.s_output_filename.WholePath().c_str(),"w");
if( !f ) {
cerr << "Couldn't open the output file " << params.s_output_filename.WholePath() << endl;
exit(1);
}
fprintf(f,"%s",ss.str().c_str());
fclose(f);
}
void
ExtractLOCData(char *s, int &fileno, char **ppRemainder )
{
......
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