[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [open-cobol-list] gdb support from gcc-cobol
From: |
Bernard Giroud |
Subject: |
Re: [open-cobol-list] gdb support from gcc-cobol |
Date: |
Tue May 27 13:24:13 2003 |
Keisuke Nishida a écrit :
> At Sun, 25 May 2003 21:09:48 +0200,
> Bernard Giroud wrote:
> >
> > I think I found what happens: in C, you have the function definition
> > with parameters,
> > and the top level block where the vars are defined. When you call
> > poplevel from
> > cb_end_function, because the flag functionbody is on, the BLOCK_VARS is
> > reset to 0. If that last statement is commented out, we get the vars
> > defined in the
> > assembly file.
> >
> > So I'm currently trying to modify slightly the code of cb_end_function
> > to
> > insert a new block which will hold the needed vars, but with no success
> > ATM:
> > the vars are still not output from the second level block.
> >
> > Is my reasoning wrong ? Any hint would be welcome (See function below.)
>
> I am not sure. I encountered the same problem and have not
> investigated it yet.
>
> Maybe we could start with a tiny front end, apart from gcc-cobol,
> investigate how to generate debugging information, and integrate
> it into gcc-cobol.
>
Here are the last results:
with function cb_end_function as:
static void
cb_end_function (void)
{
tree fn_vars = getdecls(); /* save vars which will be reset by poplevel */
tree fn_block = poplevel (1, 0, 1);
/* expand_end_bindings (poplevel (1, 0, 1), 0, 1); */
BLOCK_VARS (fn_block) = fn_vars; /* and restore them */
expand_end_bindings (fn_block, 0, 1);
expand_function_end ("test", 5, 0);
rest_of_compilation (current_function_decl);
current_function_decl = NULL_TREE;
}
I get:
GNU gdb 20030201
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
.gdbinit:4: Error in sourced command file:
/home/bg/gcc/gcc/gcc/gdbinit.in:100: Error in sourced command file:
Function "fancy_abort" not defined.
(gdb) b t
Breakpoint 1 at 0x80487c3: file /home/bg/test/t.cob, line 17.
(gdb) run
Starting program: /home/bg/gcc/build/gcc/t.exe
Breakpoint 1, t (b_LK_PARM=0x1 <Address 0x1 out of bounds>)
at /home/bg/test/t.cob:17
17 move 2 to return-code
(gdb) info scope t
Scope for t:
Symbol b_LK_PARM is an argument at stack/frame offset 8, length 4.
Symbol b_WS_G1 is in static storage at address 0x8049a7b, length 7.
Symbol f_WSNAME2 is in static storage at address 0x8049914, length 12.
Symbol c_1 is in static storage at address 0x8049908, length 12.
Symbol f_WS_NAME is in static storage at address 0x80498fc, length 12.
Symbol b_WS_NAME is in static storage at address 0x8049a78, length 3.
Symbol c_0 is in static storage at address 0x80498f0, length 12.
Symbol i_RETURN_CODE is in static storage at address 0x8049a74, length 4.
Symbol b_WSNAME2 is in static storage at address 0x8049a6c, length 6.
Symbol i is a local variable at frame offset -316, length 4.
Symbol env is in static storage at address 0x8049a64, length 8.
Symbol d is in static storage at address 0x8049a50, length 20.
Symbol f is a local variable at frame offset -312, length 60.
Symbol n is a local variable at frame offset -236, length 4.
Symbol frame_stack is a local variable at frame offset -232, length 200.
Symbol frame_index is a local variable at frame offset -20, length 4.
Symbol tail is a local variable at frame offset -16, length 4.
Symbol head is a local variable at frame offset -12, length 4.
(gdb) p i_RETURN_CODE
$1 = 0
(gdb) set lang cobol
(gdb) p i_RETURN_CODE
No symbol "i_RETURN_CODE" in current context.
(gdb) quit
The program is running. Exit anyway? (y or n)
So the scope seems to be OK (and the variables
are seen as static) if language set to "c" (even the
parameter LK-PARM is ok, though meaningless
for a main), but not if I switch to lang "cobol".
This is probably due to the mods I've done in GDB.
The next step should be to change the variable
names to suppress the leading b_ or i_, maybe
make invisible the f_* variables, and, but only
when my mods in GDB are sufficiently ready,
suppress the translation of '-' to '_' in except in
ASSEMBLER_NAME.
Also, the names of the original file in the assembly
should be altered to reflect the .cob file and not the
.i one.
See the attached generated file t.s.
>
> Keisuke
>
--
Bernard Giroud
GOBOL Developer
.file "cci7M1H6.i"
.stabs "/home/bg/gcc/build/gcc/",100,0,0,.Ltext0
.stabs "/tmp/cci7M1H6.i",100,0,0,.Ltext0
.text
.Ltext0:
.stabs "gcc2_compiled.",60,0,0,0
.stabs "int:t(0,1)=r(0,1);-2147483648;2147483647;",128,0,0,0
.stabs "char:t(0,2)=r(0,2);0;127;",128,0,0,0
.stabs "long int:t(0,3)=r(0,3);-2147483648;2147483647;",128,0,0,0
.stabs "unsigned int:t(0,4)=r(0,4);0;-1;",128,0,0,0
.stabs "long unsigned int:t(0,5)=r(0,5);0;-1;",128,0,0,0
.stabs "long long int:t(0,6)address@hidden;r(0,6);0;-1;",128,0,0,0
.stabs "long long unsigned
int:t(0,7)address@hidden;r(0,7);0;-1;",128,0,0,0
.stabs "short int:t(0,8)address@hidden;r(0,8);-32768;32767;",128,0,0,0
.stabs "short unsigned
int:t(0,9)address@hidden;r(0,9);0;65535;",128,0,0,0
.stabs "signed char:t(0,10)address@hidden;r(0,10);-128;127;",128,0,0,0
.stabs "unsigned char:t(0,11)address@hidden;r(0,11);0;255;",128,0,0,0
.stabs "float:t(0,12)=r(0,1);4;0;",128,0,0,0
.stabs "double:t(0,13)=r(0,1);8;0;",128,0,0,0
.stabs "long double:t(0,14)=r(0,1);12;0;",128,0,0,0
.stabs "complex
int:t(0,15)=s8real:(0,1),0,32;imag:(0,1),32,32;;",128,0,0,0
.stabs "complex float:t(0,16)=R3;8;0;",128,0,0,0
.stabs "complex double:t(0,17)=R4;16;0;",128,0,0,0
.stabs "complex long double:t(0,18)=R5;24;0;",128,0,0,0
.stabs "__builtin_va_list:t(0,19)=*(0,2)",128,0,0,0
.stabs "_Bool:t(0,20)address@hidden;-16;",128,0,0,0
.local initialized.0
.comm initialized.0,4,4
.local d.1
.comm d.1,20,4
.local env.2
.comm env.2,8,4
.local b_WS_NAME2.3
.comm b_WS_NAME2.3,6,1
.local i_RETURN_CODE.4
.comm i_RETURN_CODE.4,4,4
.section .rodata
.LC2:
.ascii "ab"
.data
.align 4
.type c_0.5, @object
.size c_0.5, 12
c_0.5:
.long 2
.long .LC2
.long cob_alnum_attr
.local b_WS_NAME.6
.comm b_WS_NAME.6,3,1
.align 4
.type f_WS_NAME.7, @object
.size f_WS_NAME.7, 12
f_WS_NAME.7:
.long 2
.long b_WS_NAME.6
.long cob_alnum_attr
.section .rodata
.LC3:
.ascii "fg"
.data
.align 4
.type c_1.8, @object
.size c_1.8, 12
c_1.8:
.long 2
.long .LC3
.long cob_alnum_attr
.align 4
.type f_WS_NAME2.9, @object
.size f_WS_NAME2.9, 12
f_WS_NAME2.9:
.long 5
.long b_WS_NAME2.3
.long cob_alnum_attr
.local b_WS_G1.10
.comm b_WS_G1.10,7,1
.section .rodata
.LC0:
.ascii "abc "
.LC1:
.ascii "/home/bg/test/t.cob"
.text
.stabs "t:F(0,1)",36,0,22,t
.stabs "b_LK_PARM:p(0,21)=*(0,11)",160,0,22,8
.globl t
.type t, @function
t:
.stabs "test",132,0,0,.Ltext1
.Ltext1:
.stabn 68,0,5,.LM1-t
.LM1:
pushl %ebp
movl %esp, %ebp
subl $344, %esp
movl $env.2, (%esp)
call cob_push_environment
cmpl $0, initialized.0
jne .L2
call cob_module_init
movl $0, -316(%ebp)
.L3:
cmpl $0, -316(%ebp)
js .L5
jmp .L4
.L5:
movl -316(%ebp), %edx
movl %edx, %eax
sall $2, %eax
addl %edx, %eax
sall $2, %eax
addl $d.1, %eax
movl %eax, (%esp)
call cob_decimal_init
leal -316(%ebp), %eax
incl (%eax)
jmp .L3
.L4:
movb $46, env.2
movb $36, env.2+1
movb $44, env.2+2
movl $5, 8(%esp)
movl $.LC0, 4(%esp)
movl $b_WS_NAME2.3, (%esp)
call memcpy
movl $1, initialized.0
.L2:
movl $0, -20(%ebp)
movl -20(%ebp), %eax
movl $-1, -232(%ebp,%eax,8)
.L7:
.L6:
.stabs "/home/bg/test/t.cob",132,0,0,.Ltext2
.Ltext2:
.stabn 68,0,17,.LM2-t
.LM2:
movl $.LC1, cob_source_file
movl $17, cob_source_line
movl $2, i_RETURN_CODE.4
.stabn 68,0,18,.LM3-t
.LM3:
movl $18, cob_source_line
movl $f_WS_NAME.7, 4(%esp)
movl $c_0.5, (%esp)
call cob_move
.stabn 68,0,19,.LM4-t
.LM4:
movl $19, cob_source_line
movl $f_WS_NAME2.9, 4(%esp)
movl $c_1.8, (%esp)
call cob_move
.stabn 68,0,20,.LM5-t
.LM5:
movl $20, cob_source_line
movw $3, b_WS_G1.10
call cob_stop_run
.L10:
call cob_pop_environment
movl cob_return_code, %eax
.stabs "test",132,0,0,.Ltext3
.Ltext3:
.stabn 68,0,5,.LM6-t
.LM6:
leave
ret
.size t, .-t
.stabs
"b_WS_G1:V(0,22)=ar(0,23)=r(0,23);0000000000000;0037777777777;;0;6;(0,11)",40,0,22,b_WS_G1.10
.stabs
"f_WS_NAME2:V(0,24)=s12size:(0,4),0,32;data:(0,21),32,32;attr:(0,25)=*(0,26)=(0,26),64,32;;",38,0,22,f_WS_NAME2.9
.stabs "c_1:V(0,24)",38,0,22,c_1.8
.stabs "f_WS_NAME:V(0,24)",38,0,22,f_WS_NAME.7
.stabs "b_WS_NAME:V(0,27)=ar(0,23);0;2;(0,11)",40,0,22,b_WS_NAME.6
.stabs "c_0:V(0,24)",38,0,22,c_0.5
.stabs "RETURN-CODE:V(0,1)",40,0,22,i_RETURN_CODE.4
.stabs "b_WS_NAME2:V(0,28)=ar(0,23);0;5;(0,11)",40,0,22,b_WS_NAME2.3
.stabs "i:(0,1)",128,0,22,-316
.stabs
"env:V(0,29)=s8decimal_point:(0,11),0,8;currency_symbol:(0,11),8,8;numeric_separator:(0,11),16,8;next:(0,25),32,32;;",40,0,22,env.2
.stabs
"d:V(0,30)=ar(0,23);0;0;(0,31)=s20data:(0,32)=ar(0,23);0;3;(0,1),0,128;expt:(0,2),128,8;;",40,0,22,d.1
.stabs "f:(0,33)=ar(0,23);0;4;(0,24)",128,0,22,-312
.stabs "n:(0,34)=ar(0,23);0;0;(0,1)",128,0,22,-236
.stabs
"frame_stack:(0,35)=ar(0,23);0;24;(0,36)=s8perform_through:(0,1),0,32;return_address:(0,25),32,32;;",128,0,22,-232
.stabs "frame_index:(0,1)",128,0,22,-20
.stabs "tail:(0,1)",128,0,22,-16
.stabs "head:(0,1)",128,0,22,-12
.Lscope0:
.stabs "",36,0,0,.Lscope0-t
.stabs "main:F(0,1)",36,0,22,main
.stabs "argc:p(0,1)",160,0,22,8
.stabs "argv:p(0,37)=*(0,38)=*(0,2)",160,0,22,12
.globl main
.type main, @function
main:
.stabn 68,0,5,.LM7-main
.LM7:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
movl 12(%ebp), %eax
movl %eax, 4(%esp)
movl 8(%ebp), %eax
movl %eax, (%esp)
call cob_init
call t
movl cob_return_code, %eax
.stabn 68,0,5,.LM8-main
.LM8:
leave
ret
.size main, .-main
.stabs "wk_test:(0,1)",128,0,22,-4
.Lscope1:
.stabs "",36,0,0,.Lscope1-main
.text
.stabs "",100,0,0,.Letext
.Letext:
.ident "GCC: (GNU) 3.3 20030503 (prerelease)"