Commit 74e73fd3 authored by rdubner's avatar rdubner

Debugging build chain works with MINGW64

parent 3c1f2b88
......@@ -37,8 +37,8 @@ pregit:
install :
ifdef DESTDIR
mkdir -p $(DESTDIR)/bin/
sudo install $(project) $(DESTDIR)/bin/
install $(project) $(DESTDIR)/bin/
else
sudo install $(project) /usr/local/bin/
install $(project) /usr/local/bin/
endif
\ No newline at end of file
......@@ -454,7 +454,8 @@ ZeroIsNull(const LONGLONG &v)
static void
CreateSymc(PARAMETERS &params,
const COB_LABELS &cob_labels,
const VARIABLE_TREE &var_tree)
const VARIABLE_TREE &var_tree,
bool tack_on_python)
{
/* This routine creates the .sym.c file, which contains a global
variable comprising the cross-reference information, followed
......@@ -565,62 +566,65 @@ CreateSymc(PARAMETERS &params,
delete[] py;
/* As per https://sourceware.org/gdb/current/onlinedocs/gdb/dotdebug_005fgdb_005fscripts-section.html,
we are going to format that string in a way that reflects this example:
#include "symcat.h"
#include "gdb/section-scripts.h"
asm(
".pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n"
".byte " XSTRING (SECTION_SCRIPT_ID_PYTHON_TEXT) "\n"
".ascii \"gdb.inlined-script\\n\"\n"
".ascii \"class test_cmd (gdb.Command):\\n\"\n"
".ascii \" def __init__ (self):\\n\"\n"
".ascii \" super (test_cmd, self).__init__ (\\\"test-cmd\\\", gdb.COMMAND_OBSCURE)\\n\"\n"
".ascii \" def invoke (self, arg, from_tty):\\n\"\n"
".ascii \" print (\\\"test-cmd output, arg = %s\\\" % arg)\\n\"\n"
".ascii \"test_cmd ()\\n\"\n"
".byte 0\n"
".popsection\n"
);
*/
if(tack_on_python) {
/* As per https://sourceware.org/gdb/current/onlinedocs/gdb/dotdebug_005fgdb_005fscripts-section.html,
we are going to format that string in a way that reflects this example:
#include "symcat.h"
#include "gdb/section-scripts.h"
asm(
".pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n"
".byte " XSTRING (SECTION_SCRIPT_ID_PYTHON_TEXT) "\n"
".ascii \"gdb.inlined-script\\n\"\n"
".ascii \"class test_cmd (gdb.Command):\\n\"\n"
".ascii \" def __init__ (self):\\n\"\n"
".ascii \" super (test_cmd, self).__init__ (\\\"test-cmd\\\", gdb.COMMAND_OBSCURE)\\n\"\n"
".ascii \" def invoke (self, arg, from_tty):\\n\"\n"
".ascii \" print (\\\"test-cmd output, arg = %s\\\" % arg)\\n\"\n"
".ascii \"test_cmd ()\\n\"\n"
".byte 0\n"
".popsection\n"
);
*/
s = ss.str();
s = ss.str();
params.symc << "asm(" << endl;
params.symc << "\".pushsection \\\".debug_gdb_scripts\\\", \\\"MS\\\",@progbits,1\\n\"" << endl;
params.symc << "\".byte 4\\n\"" << endl;
params.symc << "\".ascii \\\"gdb.inlined-script\\\\n\\\"\\n\"";
params.symc << "asm(" << endl;
params.symc << "\".pushsection \\\".debug_gdb_scripts\\\", \\\"MS\\\",@progbits,1\\n\"" << endl;
params.symc << "\".byte 4\\n\"" << endl;
params.symc << "\".ascii \\\"gdb.inlined-script\\\\n\\\"\\n\"";
int char_count = 0;
size_t i = 0;
while( i < s.size() ) {
if(char_count EQ 0) {
params.symc << "\".ascii \\\"";
char_count = 10 ;
}
if( char_count >= 120 ) {
params.symc << "\"" << endl << "\"";
char_count = 1;
continue;
}
char ch = s[i++];
if( ch EQ '\n' ) {
params.symc << "\\\\n\\\"\\n\"" << endl;
char_count = 0;
continue;
}
if( ch EQ '\\' OR ch EQ '\"' ) {
params.symc << "\\\\\\";
int char_count = 0;
size_t i = 0;
while( i < s.size() ) {
if(char_count EQ 0) {
params.symc << "\".ascii \\\"";
char_count = 10 ;
}
if( char_count >= 120 ) {
params.symc << "\"" << endl << "\"";
char_count = 1;
continue;
}
char ch = s[i++];
if( ch EQ '\n' ) {
params.symc << "\\\\n\\\"\\n\"" << endl;
char_count = 0;
continue;
}
if( ch EQ '\\' OR ch EQ '\"' ) {
params.symc << "\\\\\\";
char_count += 1;
}
params.symc << ch;
char_count += 1;
}
params.symc << ch;
char_count += 1;
}
params.symc << "\".byte 0\\n\"" << endl;
params.symc << "\".popsection\\n\"" << endl;
params.symc << ");" << endl;
params.symc << "\".byte 0\\n\"" << endl;
params.symc << "\".popsection\\n\"" << endl;
params.symc << ");" << endl;
}
return;
}
......@@ -717,23 +721,12 @@ main(int argc, char *argv[])
// Create the .sym.c file that will be compiled and linked into the
// executable, providing the text that will become the executable's
// .debug_gdb_scripts section
CreateSymc(params,cob_labels,variable_tree);
return 0;
}
/*
#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
#define STRINGX(s) #s
#if defined(_WIN32)
bool tack_on_python = false;
#else
#define STRINGX(s) "s"
bool tack_on_python = true;
#endif
CreateSymc(params,cob_labels,variable_tree,tack_on_python);
#define XSTRING(s) STRINGX(s)
#define SECTION_SCRIPT_ID_PYTHON_TEXT 4
*/
\ No newline at end of file
return 0;
}
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28922.388
......@@ -13,14 +12,14 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BED69709-3451-4776-A749-E65B04F95803}.Debug|x64.ActiveCfg = Debug|Win32
{BED69709-3451-4776-A749-E65B04F95803}.Debug|x64.Build.0 = Debug|Win32
{BED69709-3451-4776-A749-E65B04F95803}.Debug|x64.ActiveCfg = Debug|x64
{BED69709-3451-4776-A749-E65B04F95803}.Debug|x64.Build.0 = Debug|x64
{BED69709-3451-4776-A749-E65B04F95803}.Debug|x86.ActiveCfg = Debug|Win32
{BED69709-3451-4776-A749-E65B04F95803}.Debug|x86.Build.0 = Debug|Win32
{BED69709-3451-4776-A749-E65B04F95803}.Release|x64.ActiveCfg = Debug|Win32
{BED69709-3451-4776-A749-E65B04F95803}.Release|x64.Build.0 = Debug|Win32
{BED69709-3451-4776-A749-E65B04F95803}.Release|x86.ActiveCfg = Debug|Win32
{BED69709-3451-4776-A749-E65B04F95803}.Release|x86.Build.0 = Debug|Win32
{BED69709-3451-4776-A749-E65B04F95803}.Release|x64.ActiveCfg = Release|x64
{BED69709-3451-4776-A749-E65B04F95803}.Release|x64.Build.0 = Release|x64
{BED69709-3451-4776-A749-E65B04F95803}.Release|x86.ActiveCfg = Release|Win32
{BED69709-3451-4776-A749-E65B04F95803}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommandArguments>c:\temp\bob01</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>C:\projects\1-symas\cbl-gdb\samples\optfde01\optfde01</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerCommandArguments>c:\temp\bob01</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>C:\projects\1-symas\cbl-gdb\samples\optfde01\optfde01</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerCommandArguments>c:\temp\bob01</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>C:\projects\1-symas\cbl-gdb\samples\optfde01\optfde01</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerCommandArguments>c:\temp\bob01</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>C:\projects\1-symas\cbl-gdb\samples\optfde01\optfde01</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
\ No newline at end of file
......@@ -90,6 +90,15 @@ GAS_SYMBOLS::GetSymbolsFromFile(const string &source, const string &scope, ifstr
break;
}
// When running on Windows, the program.lst DEFINED SYMBOL section
// entries start with a "C:\whatever\ file name. This messes up the
// following regex, which expect two, not three colons.
// Fix it by just stripping off the first two characters:
if( input.length() >2 AND input[1] EQ ':' ) {
input = input.substr(2);
}
// These are examples of what we are looking for:
// /tmp/ccAi92uI.s:329 .text:0000000000000041 RTEST_
......@@ -1053,7 +1062,7 @@ DATA_DESCRIPTIONS::ProcessDataStorage(ifstream &ifs,const string &source)
ds.program_id = program_id;
ds.storage_type = "String";
ds.storage_scope = scope;
ds.field_size = svalue.size()+1;
ds.field_size = (int)svalue.size()+1;
ds.field_data_pointer = svalue;
ds.gas_symbol = sym;
symbols.push_back(ds);
......
......@@ -33,7 +33,7 @@
#include <string>
#include <fstream>
#define VERSION "1.3.2"
#define VERSION "2.1"
class FILENAME
{
......
gnucobol/
pkg/
src/
*.log
*.zst
......@@ -5,7 +5,7 @@
_realname=gnucobol
pkgbase=mingw-w64-${_realname}-svn
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}-svn
pkgver=.r3530
pkgver=.r3533
_specialversion=-dev
pkgrel=1
pkgdesc="GnuCOBOL, a free and modern COBOL compiler (mingw-w64)"
......@@ -86,8 +86,8 @@ build() {
check() {
cd ${srcdir}/build-${CARCH}
# make check
# make test || true # note: may fail, but this is the SVN version...
# make check
# make test || true # note: may fail, but this is the SVN version...
}
package() {
......
Bob Dubner, 2020-05-15
This is the tale of a wasted week, trying to get the COBOL debugging toolchain
working in a native Windows way using the MSYS2 environment.
To get back to where I was when I shut down, you would need to install 64-bit
MSYS2 from www.msys2.org on a 64-bit Windows Professional platform.
Configure and install it thusly:
running as msys 64-bit: (C:\msys64\msys2_shell.cmd -mingw64)
pacman -S base-devel
pacman -S subversion
pacman -S rsync
pacman -S mingw-w64-x86_64-toolchain
There are a couple of files in the mingw-w64-gnucobol-svn.zip package that
Simon Sobisch sent me on 2020-04-14 that need to be renamed:
cobenv.ctxt becomes cobenv.cmd
cobenv.stxt becomes cobenv.sh
The enclosed .zip file was provided by Simon Sobisch.
To get the build to work, I had to modify a couple of things:
......@@ -27,51 +8,7 @@ In PKGBUILD, line 25: change "diff" to "diffutils"
line 89: comment out 'make check'
line 90: comment out 'make test'
# Simon said to run this:
makepkg-mingw -sCLf --check
makepkg-mingw -sCLf
Ultimate that worked, creating an install package. Not knowing
what to do with it, I went to ./src/build-x86_64 and
make install
That installed cobc in /mingw64/bin
Magic environment variables, which I put into .profile, allowed the
cobc compiler to work.
export COB_CONFIG_DIR=c:/msys64/mingw64/share/gnucobol/config
export COB_LIBRARY_PATH=C:/msys64/mingw64/lib
export COB_COPY_DIR=C:/msys64/mingw64/share/gnucobol/copy
I came up with a compilation script, here named "cobcd_for_msys2", which
creates a debuggable executable.
The bad news: When gdb 9.1 loads that executable, you have to execute
"l rtest.cbl:1" before it understands you are working with an executable
pointing back to the source code module rtest.cbl. With a .c module, gdb seems
to default to the proper .c code; with .cbl it seems confused until you "prime
the pump" with that explicit listing command.
You need to have a "rtest-gdb.py" copy of the cprint.py script where gdb can find
it. (The method used in Linux, which is to embed cprint.py into the executable,
doesn't work in Windows. Unlike a ELF file, the COFF/PE+ file format doesn't have
provision for a .debug_gdb_scripts section.)
The additional bad news: The Python script doesn't quite work. It tries to
run, but the "p *" command doesn't find all of the variables that it ought to.
Plus, some of the variables that it does find don't seem to display properly.
It needs debugging.
And that is where I said, "Hold, enough!"
Following those changes:
makepkg-mingw -sCLf ## --check
......@@ -3140,7 +3140,7 @@ if 'gdb' in sys.modules :
def __init__ (self):
super (CPrint, self).__init__ ("print", gdb.COMMAND_USER)
print('registering CPrint (Usage is "print <COBOL identifier>") [Version 1.3.1]')
print('registering CPrint (Usage is "print <COBOL identifier>") [Version 2.1]')
self.Worker = CPrintWorker()
self.TabFile = TabFileInformation();
......
m
l
gdb.scr
optfde01-gdb.py
optfde01.exe
......@@ -6,6 +6,5 @@
DISPLAY "one"
DISPLAY "two"
DISPLAY "three"
DISPLAY "Ding
STOP RUN.
END PROGRAM RTEST.
......@@ -32,8 +32,8 @@ pregit:
install :
ifdef DESTDIR
mkdir -p $(DESTDIR)/bin/
sudo install $(project) $(DESTDIR)/bin/
install $(project) $(DESTDIR)/bin/
else
sudo install $(project) /usr/local/bin/
install $(project) /usr/local/bin/
endif
\ No newline at end of file
......@@ -241,11 +241,6 @@ OpenOrFail(std::ofstream &ofs,const std::string &fname,std::ios_base::openmode m
PARAMETERS
GetParameters(int argc, char *argv[])
{
if(argc < 5) {
Usage();
exit(1);
}
PARAMETERS retval;
string s_input_parameter;
......@@ -256,6 +251,7 @@ GetParameters(int argc, char *argv[])
switch (c) {
case 'v':
Version();
exit(0);
break;
case 'q':
retval.quiet = true;
......@@ -271,6 +267,11 @@ GetParameters(int argc, char *argv[])
}
}
if(argc < 5) {
Usage();
exit(1);
}
s_input_parameter = argv[optind++];
s_output_parameter = argv[optind++];
retval.c_filename = argv[optind++];
......
......@@ -34,7 +34,7 @@
#include <fstream>
#include <vector>
#define VERSION "1.1.3"
#define VERSION "2.1"
class FILENAME
{
......
......@@ -217,7 +217,7 @@ main(int argc, char **argv)
}
continue;
}
if(next_function_reference_index < function_references.size()
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;
......
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