Hello, 

We want to add source-level debugging to GNU Cobol.  

The Cobol compiler generates C, and then invokes gcc to produce ELF
object code, of course. We are entertaining approaches to
replace/amplify the DWARF records produced by gcc with new ones
referencing the Cobol source.  Before diving into 30 KLOC of
dwarf-generation logic, we thought it prudent to ask for advice here.  

We are considering how best to insert DWARF records that refer to the
Cobol source, while retaining the Cobol-to-C-to-ELF design.  One way to
do that would be to supply gcc with information about "superior"
language constructs (meaning "above", not "better").  ISTM Cobol is
neither the first nor last language to use C as a kind of idealized
assembler.  

AFAIK there is no interface to supply debugging information to gcc.  

I don't know if its possible in DWARF to have one position in the
object code be defined by two source files (Cobol and C).  Ideally,
we would find a way to keep the C records and add Cobol records, and
tell the debugger which ones to use.  

Absent direct gcc support, we're considering the following approach: 

1.  Maintain a map of Cobol-to-C constructs.
2.  Invoke gcc -g to produce dwarf records.
3.  Use libdwarf or similar to iterate over the dwarf records, 
    and to generate new, Cobol records for (some of) the same
    locations using the map from step #1.  

If the Cobol records cannot coexist with the C records in the same
file, then between steps 2 and 3 we would extract them to a dwo file
with objcopy. 

Is gcc capable of accepting additional dwarf information, or would the
team be interested in such support?  Other suggestions on how the goal
might be met?  

Kind regards, 

--jkl




Reply via email to